NEML2 2.0.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
TensorName< T > Struct Template Reference

The name of a tensor object that can be referenced in the input files. More...

Detailed Description

template<typename T>
struct neml2::TensorName< T >

The name of a tensor object that can be referenced in the input files.

All tokens in the input files are essentially strings, and it is not always possible to represent all quantities as strings. This class enables cross-referencing tensor or model output variable (by name) defined in the input file. The object name is used as the label, and the object value is not resolved at parse time. The method TensorName::resolve() is used to explicitly resolve the name to a tensor object or a model's output variable. Note that the resolution takes place upon the first call to TensorName::resolve(), and subsequent calls simply return the cached value.

#include <TensorName.h>

Public Member Functions

 TensorName ()=default
 
 TensorName (std::string raw)
 
TensorNameoperator= (const std::string &other)
 Assignment operator.
 
const T & resolve () const
 Resolve the TensorName to a Tensor object.
 
const T & resolve (Model *caller, const std::string &pname) const
 
bool operator== (const TensorName &other) const
 Test equality.
 
std::string & raw ()
 Get the raw string literal.
 
const std::string & raw () const
 

Constructor & Destructor Documentation

◆ TensorName() [1/2]

template<typename T>
TensorName ( )
default

◆ TensorName() [2/2]

template<typename T>
TensorName ( std::string raw)
inline

Member Function Documentation

◆ operator=()

template<typename T>
TensorName & operator= ( const std::string & other)
inline

Assignment operator.

This simply assigns the string without parsing and resolving the cross-reference

◆ operator==()

template<typename T>
bool operator== ( const TensorName< T > & other) const
inline

Test equality.

◆ raw() [1/2]

template<typename T>
std::string & raw ( )
inline

Get the raw string literal.

Returns
const std::string& The raw string literal.

◆ raw() [2/2]

template<typename T>
const std::string & raw ( ) const
inline

◆ resolve() [1/2]

template<typename T>
const T & resolve ( ) const

Resolve the TensorName to a Tensor object.

The underlying string is parsed and used to resolve the cross-reference. It is assumed that the cross-referenced tensor object has already been manufactured at this point.

◆ resolve() [2/2]

template<typename T>
const T & resolve ( Model * caller,
const std::string & pname ) const