Classes | |
struct | Layout |
struct | Layout< RankFourTensor > |
struct | Layout< RankTwoTensor > |
struct | Layout< Real > |
struct | Layout< RealVectorValue > |
struct | Layout< SymmetricRankFourTensor > |
struct | Layout< SymmetricRankTwoTensor > |
Functions | |
std::shared_ptr< neml2::Model > | getModel (neml2::Factory &factory, const std::string &name, neml2::Dtype dtype=neml2::kFloat64) |
Get the NEML2 Model. More... | |
void | assertVariable (const neml2::VariableName &) |
Assert that the NEML2 variable name sits on either the forces or the state subaxis. More... | |
void | assertOldVariable (const neml2::VariableName &) |
Assert that the NEML2 variable name sits on either the old_forces or the old_state subaxis. More... | |
neml2::VariableName | parseVariableName (const std::string &) |
Parse a raw string into NEML2 variable name. More... | |
template<typename T > | |
neml2::Tensor | fromBlob (const std::vector< T > &data) |
Map from std::vector<T> to neml2::Tensor without copying the data. More... | |
template<typename T > | |
void | copyTensorToMOOSEData (const at::Tensor &src, T &dest) |
Directly copy a contiguous chunk of memory of a at::Tensor to a MOOSE data of type T. More... | |
bool | shouldCompute (const SubProblem &) |
Determine whether the NEML2 material model should be evaluated. More... | |
std::string | docstring (const std::string &desc) |
Augment docstring if NEML2 is not enabled. More... | |
void | assertNEML2Enabled () |
Assert that NEML2 is enabled. More... | |
Variables | |
static std::string | NEML2_help_message |
static const std::string | missing_neml2 |
void NEML2Utils::assertNEML2Enabled | ( | ) |
Assert that NEML2 is enabled.
A MooseError is raised if NEML2 is not enabled.
Definition at line 87 of file NEML2Utils.C.
Referenced by NEML2Action::NEML2Action(), NEML2ActionCommon::NEML2ActionCommon(), and NEML2ToMOOSEMaterialProperty< T >::NEML2ToMOOSEMaterialProperty().
void NEML2Utils::assertOldVariable | ( | const neml2::VariableName & | v | ) |
Assert that the NEML2 variable name sits on either the old_forces or the old_state subaxis.
Definition at line 39 of file NEML2Utils.C.
Referenced by MOOSEToNEML2::checkMode().
void NEML2Utils::assertVariable | ( | const neml2::VariableName & | v | ) |
Assert that the NEML2 variable name sits on either the forces or the state subaxis.
Definition at line 29 of file NEML2Utils.C.
Referenced by MOOSEToNEML2::checkMode().
void NEML2Utils::copyTensorToMOOSEData | ( | const at::Tensor & | src, |
T & | dest | ||
) |
Directly copy a contiguous chunk of memory of a at::Tensor to a MOOSE data of type T.
This assumes the at::Tensor and T have the same layout, for example both row-major with T = RankTwoTensor. If the layouts are different, we may need to reshape/reorder/transpose the at::Tensor before copying.
For this method to work,
dest
must align with the first element of the data,dest
must match the number of elements in src
,src
tensor must be of type neml2::kFloat64, anddest
must be reinterpretable as Real. Definition at line 135 of file NEML2Utils.h.
std::string NEML2Utils::docstring | ( | const std::string & | desc | ) |
Augment docstring if NEML2 is not enabled.
Definition at line 77 of file NEML2Utils.C.
Referenced by NEML2ModelExecutor::actionParams(), NEML2ActionCommon::commonParams(), InputParameters::renameCoupledVarInternal(), InputParameters::renameParamInternal(), MOOSEVariableToNEML2Templ< state >::validParams(), MOOSEPostprocessorToNEML2Templ< state >::validParams(), MOOSEMaterialPropertyToNEML2< T, state >::validParams(), NEML2ToMOOSEMaterialProperty< T >::validParams(), NEML2Action::validParams(), NEML2ModelExecutor::validParams(), MOOSEToNEML2::validParams(), NEML2ModelInterface< GeneralUserObject >::validParams(), and NEML2ActionCommon::validParams().
neml2::Tensor NEML2Utils::fromBlob | ( | const std::vector< T > & | data | ) |
Map from std::vector<T> to neml2::Tensor without copying the data.
This method is used in gatherers which gather data from MOOSE as input variables to the NEML2 material model. So in theory, we only need to provide Layout specializations for MOOSE types that can potentially be used as NEML2 input variables.
For this method to work, the underlying data in data
must be reinterpretable as Real (neml2::kFloat64). The data class T must also be aligned and follow the striding implied by Layout<T>::shape. The data class T must also have no padding or overhead.
Definition at line 110 of file NEML2Utils.h.
Referenced by MOOSEToNEML2Batched< Real >::gatheredData().
std::shared_ptr< neml2::Model > NEML2Utils::getModel | ( | neml2::Factory & | factory, |
const std::string & | name, | ||
neml2::Dtype | dtype = neml2::kFloat64 |
||
) |
Get the NEML2 Model.
This is mostly the same as the plain neml2::get_model() method, but it also guards the default dtype and sends the model to the target device.
Definition at line 18 of file NEML2Utils.C.
Referenced by NEML2Action::NEML2Action().
neml2::VariableName NEML2Utils::parseVariableName | ( | const std::string & | s | ) |
Parse a raw string into NEML2 variable name.
Definition at line 49 of file NEML2Utils.C.
Referenced by NEML2ModelExecutor::NEML2ModelExecutor(), MOOSEToNEML2::setMode(), NEML2Action::setupDerivativeMappings(), NEML2Action::setupInputMappings(), NEML2Action::setupOutputMappings(), and NEML2Action::setupParameterDerivativeMappings().
bool NEML2Utils::shouldCompute | ( | const SubProblem & | problem | ) |
Determine whether the NEML2 material model should be evaluated.
Definition at line 59 of file NEML2Utils.C.
Referenced by NEML2BatchIndexGenerator::execute(), BatchMaterial< Tuple, Output, Input >::execute(), BatchMaterial< Tuple, Output, Input >::finalize(), NEML2BatchIndexGenerator::initialize(), BatchMaterial< Tuple, Output, Input >::initialize(), NEML2ModelExecutor::meshChanged(), NEML2BatchIndexGenerator::threadJoin(), and BatchMaterial< Tuple, Output, Input >::threadJoin().
|
static |
Definition at line 55 of file NEML2Utils.C.
Referenced by assertNEML2Enabled(), and docstring().
|
static |
Definition at line 152 of file NEML2Utils.h.
Referenced by NEML2ModelExecutor::applyPredictor(), NEML2ModelExecutor::extractOutputs(), and NEML2ModelExecutor::fillInputs().