From 1585b08fc19021649ba7cf66c493201d2ac9a284 Mon Sep 17 00:00:00 2001 From: Gary Hu Date: Wed, 18 Dec 2024 08:35:18 -0600 Subject: [PATCH 01/11] NEML2 submodule update - Update neml2 submodule - Remove dependency on LabeledTensor - Update all neml2 models - Update all moose-neml2 input files - Attempted to speedup data transfer between moose and neml2 - Make moose data types trivially copyable - Add a neml2 crystal plasticity example - Add ability to initialize neml2 variables in neml2 action ref #29579 --- .../GenericConstantRealVectorValue.h | 34 +++ framework/include/utils/MooseArray.h | 3 + framework/include/utils/RankFourTensor.h | 2 +- .../utils/RankFourTensorImplementation.h | 9 - framework/include/utils/RankTwoTensor.h | 2 +- .../utils/RankTwoTensorImplementation.h | 8 - .../include/utils/SymmetricRankFourTensor.h | 2 +- .../SymmetricRankFourTensorImplementation.h | 8 - .../GenericConstantRealVectorValue.C | 53 ++++ .../invOpt_elasticity_modular/elasticity.i | 8 +- .../invOpt_elasticity_modular/grad.i | 1 - modules/solid_mechanics/contrib/neml2 | 2 +- .../ComputeLagrangianCauchyCustomStress.h | 30 ++ .../lagrangian/ComputeLagrangianStrainBase.h | 3 + .../include/neml2/actions/NEML2Action.h | 33 +++ .../include/neml2/actions/NEML2ActionCommon.h | 6 + .../include/neml2/interfaces/MOOSEToNEML2.h | 3 +- .../neml2/interfaces/NEML2ModelInterface.h | 41 +-- .../materials/NEML2ToMOOSEMaterialProperty.h | 10 +- .../MOOSEMaterialPropertyToNEML2.h | 6 +- .../neml2/userobjects/MOOSEToNEML2Batched.h | 82 +++++- .../neml2/userobjects/MOOSEVariableToNEML2.h | 4 +- .../neml2/userobjects/NEML2ModelExecutor.h | 38 ++- .../include/neml2/utils/NEML2Utils.h | 222 ++++++-------- .../ComputeLagrangianCauchyCustomStress.C | 42 +++ .../lagrangian/ComputeLagrangianStrainBase.C | 5 + .../src/neml2/actions/NEML2Action.C | 271 +++++++++++------- .../src/neml2/actions/NEML2ActionCommon.C | 39 ++- .../src/neml2/interfaces/MOOSEToNEML2.C | 9 +- .../materials/NEML2ToMOOSEMaterialProperty.C | 47 +-- .../MOOSEMaterialPropertyToNEML2.C | 21 +- .../userobjects/MOOSEPostprocessorToNEML2.C | 2 +- .../neml2/userobjects/MOOSEToNEML2Batched.C | 60 ---- .../neml2/userobjects/MOOSEVariableToNEML2.C | 9 - .../neml2/userobjects/NEML2ModelExecutor.C | 146 +++++----- .../src/neml2/utils/NEML2Utils.C | 124 +------- .../test/neml2/include/NEML2TestModel.h | 2 + .../test/neml2/src/NEML2TestModel.cxx | 13 +- .../test/tests/neml2/crystal_plasticity.i | 118 ++++++++ .../test/tests/neml2/custom_model.i | 1 - .../tests/neml2/gold/crystal_plasticity.e | Bin 0 -> 77488 bytes .../tests/neml2/models/crystal_plasticity.i | 128 +++++++++ .../test/tests/neml2/models/elasticity.i | 4 +- .../test/tests/neml2/models/elasticity_2.i | 8 +- .../test/tests/neml2/models/error.i | 4 +- .../rate_independent_plasticity_isoharden.i | 4 +- ...rate_independent_plasticity_isokinharden.i | 4 +- .../rate_independent_plasticity_kinharden.i | 4 +- .../rate_independent_plasticity_perfect.i | 4 +- .../neml2/models/viscoplasticity_chaboche.i | 4 +- .../neml2/models/viscoplasticity_isoharden.i | 4 +- .../models/viscoplasticity_isokinharden.i | 4 +- .../neml2/models/viscoplasticity_kinharden.i | 4 +- .../neml2/models/viscoplasticity_perfect.i | 4 +- .../models/viscoplasticity_radial_return.i | 8 +- .../solid_mechanics/test/tests/neml2/tests | 10 + .../solid_mechanics/unit/src/NEML2UtilsTest.C | 174 +++++++++++ 57 files changed, 1209 insertions(+), 682 deletions(-) create mode 100644 framework/include/materials/GenericConstantRealVectorValue.h create mode 100644 framework/src/materials/GenericConstantRealVectorValue.C create mode 100644 modules/solid_mechanics/include/materials/lagrangian/ComputeLagrangianCauchyCustomStress.h create mode 100644 modules/solid_mechanics/src/materials/lagrangian/ComputeLagrangianCauchyCustomStress.C delete mode 100644 modules/solid_mechanics/src/neml2/userobjects/MOOSEToNEML2Batched.C create mode 100644 modules/solid_mechanics/test/tests/neml2/crystal_plasticity.i create mode 100644 modules/solid_mechanics/test/tests/neml2/gold/crystal_plasticity.e create mode 100644 modules/solid_mechanics/test/tests/neml2/models/crystal_plasticity.i create mode 100644 modules/solid_mechanics/unit/src/NEML2UtilsTest.C diff --git a/framework/include/materials/GenericConstantRealVectorValue.h b/framework/include/materials/GenericConstantRealVectorValue.h new file mode 100644 index 000000000000..97accfb9d4ac --- /dev/null +++ b/framework/include/materials/GenericConstantRealVectorValue.h @@ -0,0 +1,34 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "Material.h" + +/** + * Declares a constant material property of type RealVectorValue. + */ +template +class GenericConstantRealVectorValueTempl : public Material +{ +public: + static InputParameters validParams(); + + GenericConstantRealVectorValueTempl(const InputParameters & parameters); + +protected: + virtual void initQpStatefulProperties() override; + virtual void computeQpProperties() override; + + const RealVectorValue _vector; + GenericMaterialProperty & _prop; +}; + +typedef GenericConstantRealVectorValueTempl GenericConstantRealVectorValue; +typedef GenericConstantRealVectorValueTempl ADGenericConstantRealVectorValue; diff --git a/framework/include/utils/MooseArray.h b/framework/include/utils/MooseArray.h index 1d4941628bfa..ebde89e93773 100644 --- a/framework/include/utils/MooseArray.h +++ b/framework/include/utils/MooseArray.h @@ -173,10 +173,13 @@ class MooseArray */ std::vector stdVector() const; + ///@{ /** * Reference to first element of array */ const T * data() const { return _data; } + T * data() { return _data; } + ///@} private: /// Smart pointer storage diff --git a/framework/include/utils/RankFourTensor.h b/framework/include/utils/RankFourTensor.h index b930eae69105..350b730bf031 100644 --- a/framework/include/utils/RankFourTensor.h +++ b/framework/include/utils/RankFourTensor.h @@ -201,7 +201,7 @@ class RankFourTensorTempl void printReal(std::ostream & stm = Moose::out) const; /// copies values from a into this tensor - RankFourTensorTempl & operator=(const RankFourTensorTempl & a); + RankFourTensorTempl & operator=(const RankFourTensorTempl & a) = default; /** * Assignment-from-scalar operator. Used only to zero out the tensor. diff --git a/framework/include/utils/RankFourTensorImplementation.h b/framework/include/utils/RankFourTensorImplementation.h index a5cd05461db0..06bb326ba52e 100644 --- a/framework/include/utils/RankFourTensorImplementation.h +++ b/framework/include/utils/RankFourTensorImplementation.h @@ -120,15 +120,6 @@ RankFourTensorTempl::zero() _vals[i] = 0.0; } -template -RankFourTensorTempl & -RankFourTensorTempl::operator=(const RankFourTensorTempl & a) -{ - for (auto i : make_range(N4)) - _vals[i] = a._vals[i]; - return *this; -} - template template