-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26054 from dschwen/projected_stateful_properties
Projected stateful properties
- Loading branch information
Showing
53 changed files
with
2,003 additions
and
130 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
framework/doc/content/source/actions/ProjectedStatefulMaterialStorageAction.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# ProjectedStatefulMaterialStorageAction | ||
|
||
## Description | ||
|
||
The `ProjectedStatefulMaterialStorageAction` is the main action in the | ||
[ProjectedStatefulMaterialStorage](/ProjectedStatefulMaterialStorage/index.md) | ||
system which sets up all necessary objects to project material property | ||
components onto nodal or elemental basis functions. | ||
|
||
Projected and interpolated old state can be enabled using the | ||
`use_inerpolated_state` parameter available in the `MaterialPropertyInterface`. |
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
...doc/content/source/auxkernels/ProjectedMaterialPropertyNodalPatchRecoveryAux.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# ProjectedMaterialPropertyNodalPatchRecoveryAux | ||
|
||
This AuxKernel performs nodal patch recovery of a material property component with data prepared by a [ProjectedStatefulMaterialNodalPatchRecovery](ProjectedStatefulMaterialNodalPatchRecovery.md) object with the purpose of projecting the property onto a nodal basis function (e.g. first order Lagrange). | ||
|
||
This object is set up by the [ProjectedStatefulMaterialStorageAction](ProjectedStatefulMaterialStorageAction.md). | ||
|
||
See also [ProjectedStatefulMaterialAux](ProjectedStatefulMaterialAux.md) for the AuxKernel that projects onto elemental basis functions. | ||
|
||
!syntax description /AuxKernels/ProjectedMaterialPropertyNodalPatchRecoveryAux | ||
|
||
!syntax parameters /AuxKernels/ProjectedMaterialPropertyNodalPatchRecoveryAux | ||
|
||
!syntax inputs /AuxKernels/ProjectedMaterialPropertyNodalPatchRecoveryAux | ||
|
||
!syntax children /AuxKernels/ProjectedMaterialPropertyNodalPatchRecoveryAux |
27 changes: 27 additions & 0 deletions
27
framework/doc/content/source/auxkernels/ProjectedStatefulMaterialAux.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# ProjectedStatefulMaterial...Aux | ||
|
||
This AuxKernel simply returns the value of a given material property (or component of the property value) at a quadrature point with the purpose of projecting the property onto an elemental basis function (e.g. first order monomial). | ||
|
||
Variants include: | ||
- `ProjectedStatefulMaterialRealAux` | ||
- `ProjectedStatefulMaterialRealVectorValueAux` | ||
- `ProjectedStatefulMaterialRankTwoTensorAux` | ||
- `ProjectedStatefulMaterialRankFourTensorAux` | ||
- `ADProjectedStatefulMaterialRealAux` | ||
- `ADProjectedStatefulMaterialRealVectorValueAux` | ||
- `ADProjectedStatefulMaterialRankTwoTensorAux` | ||
- `ADProjectedStatefulMaterialRankFourTensorAux` | ||
|
||
At step zero this object will compute the material QP values by explicitly calling `initStatefulProperties` in order to project the state that will correspond to the *old state* in the first timestep. | ||
|
||
This object is set up by the [ProjectedStatefulMaterialStorageAction](ProjectedStatefulMaterialStorageAction.md). | ||
|
||
See also [ProjectedMaterialPropertyNodalPatchRecoveryAux](ProjectedMaterialPropertyNodalPatchRecoveryAux.md) for the AuxKernel that projects onto nodal basis functions. | ||
|
||
!syntax description /AuxKernels/ProjectedStatefulMaterialRealAux | ||
|
||
!syntax parameters /AuxKernels/ProjectedStatefulMaterialRealAux | ||
|
||
!syntax inputs /AuxKernels/ProjectedStatefulMaterialRealAux | ||
|
||
!syntax children /AuxKernels/ProjectedStatefulMaterialRealAux |
4 changes: 4 additions & 0 deletions
4
.../doc/content/source/interfaces/InterpolatedStatefulMaterialPropertyInterface.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# InterpolatedStatefulMaterialPropertyInterface | ||
|
||
The InterpolatedStatefulMaterialPropertyInterface provides the `getInterpolatedMaterialPropertyOld` | ||
and `getInterpolatedMaterialPropertyOldByName` methods. This is likely to get integrated into the `MaterialPropertyInterface`. |
23 changes: 23 additions & 0 deletions
23
framework/doc/content/source/materials/InterpolatedStatefulMaterial.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# InterpolatedStatefulMaterial... | ||
|
||
!syntax description /Materials/InterpolatedStatefulMaterialReal | ||
|
||
## Description | ||
|
||
`InterpolatedStatefulMaterial` reconstitutes the old state of a material property from the old state of the AuxVariables holding the projected components of the material property. | ||
|
||
Variants include: | ||
- `InterpolatedStatefulMaterialReal` | ||
- `InterpolatedStatefulMaterialRealVectorValue` | ||
- `InterpolatedStatefulMaterialRankTwoTensor` | ||
- `InterpolatedStatefulMaterialRankFourTensor` | ||
|
||
This object is set up by the [ProjectedStatefulMaterialStorageAction](ProjectedStatefulMaterialStorageAction.md). | ||
|
||
!syntax parameters /Materials/InterpolatedStatefulMaterialReal | ||
|
||
!syntax inputs /Materials/InterpolatedStatefulMaterialReal | ||
|
||
!syntax children /Materials/InterpolatedStatefulMaterialReal | ||
|
||
!bibtex bibliography |
14 changes: 14 additions & 0 deletions
14
framework/doc/content/source/userobjects/NodalPatchRecoveryMaterialProperty.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# NodalPatchRecoveryMaterialProperty | ||
|
||
This user object performs the calculations and parallel communication to perform | ||
the Zienkiewicz-Zhu nodal patch recovery for a scalar component of a provided | ||
material property. Supported material property types are listed in | ||
[IndexableProperty](IndexableProperty.md). | ||
|
||
!syntax description /UserObjects/NodalPatchRecoveryMaterialProperty | ||
|
||
!syntax parameters /UserObjects/NodalPatchRecoveryMaterialProperty | ||
|
||
!syntax inputs /UserObjects/NodalPatchRecoveryMaterialProperty | ||
|
||
!syntax children /UserObjects/NodalPatchRecoveryMaterialProperty |
23 changes: 23 additions & 0 deletions
23
...k/doc/content/source/userobjects/ProjectedStatefulMaterialNodalPatchRecovery.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# ProjectedStatefulMaterialNodalPatchRecovery... | ||
|
||
This user object performs patch recovery for a material property component. At step zero this object will compute the material QP values by explicitly calling `initStatefulProperties` in order to project the state that will correspond to the *old state* in the first time step. | ||
|
||
Variants include: | ||
- `ProjectedStatefulMaterialNodalPatchRecoveryReal` | ||
- `ProjectedStatefulMaterialNodalPatchRecoveryRealVectorValue` | ||
- `ProjectedStatefulMaterialNodalPatchRecoveryRankTwoTensor` | ||
- `ProjectedStatefulMaterialNodalPatchRecoveryRankFourTensor` | ||
- `ADProjectedStatefulMaterialNodalPatchRecoveryReal` | ||
- `ADProjectedStatefulMaterialNodalPatchRecoveryRealVectorValue` | ||
- `ADProjectedStatefulMaterialNodalPatchRecoveryRankTwoTensor` | ||
- `ADProjectedStatefulMaterialNodalPatchRecoveryRankFourTensor` | ||
|
||
This object is set up by the [ProjectedStatefulMaterialStorageAction](ProjectedStatefulMaterialStorageAction.md). | ||
|
||
!syntax description /UserObjects/ProjectedStatefulMaterialNodalPatchRecoveryReal | ||
|
||
!syntax parameters /UserObjects/ProjectedStatefulMaterialNodalPatchRecoveryReal | ||
|
||
!syntax inputs /UserObjects/ProjectedStatefulMaterialNodalPatchRecoveryReal | ||
|
||
!syntax children /UserObjects/ProjectedStatefulMaterialNodalPatchRecoveryReal |
13 changes: 13 additions & 0 deletions
13
framework/doc/content/syntax/ProjectedStatefulMaterialStorage/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# ProjectedStatefulMaterialStorage System | ||
|
||
The `ProjectedStatefulMaterialStorage` Action sets up the required objects to | ||
store old material state projected onto finite element basis functions. See the | ||
documentation for | ||
[ProjectedStatefulMaterialStorageAction](ProjectedStatefulMaterialStorageAction.md) | ||
for details. | ||
|
||
!syntax list /ProjectedStatefulMaterialStorage objects=True actions=False subsystems=False | ||
|
||
!syntax list /ProjectedStatefulMaterialStorage objects=False actions=False subsystems=True | ||
|
||
!syntax list /ProjectedStatefulMaterialStorage objects=False actions=True subsystems=False |
179 changes: 179 additions & 0 deletions
179
framework/include/actions/ProjectedStatefulMaterialStorageAction.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
//* 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 "Action.h" | ||
#include "Registry.h" | ||
#include "Conversion.h" | ||
#include "SerialAccess.h" | ||
#include "RankTwoTensorForward.h" | ||
#include "RankFourTensorForward.h" | ||
#include "libmesh/fe_type.h" | ||
|
||
// created types | ||
#include "InterpolatedStatefulMaterial.h" | ||
#include "ProjectedStatefulMaterialAux.h" | ||
#include "ProjectedStatefulMaterialNodalPatchRecovery.h" | ||
|
||
/** | ||
* Set up AuxKernels and AuxVariables for projected material property storage (PoMPS). | ||
*/ | ||
class ProjectedStatefulMaterialStorageAction : public Action | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
ProjectedStatefulMaterialStorageAction(const InputParameters & parameters); | ||
|
||
virtual void act() override; | ||
|
||
using Action::addRelationshipManagers; | ||
virtual void addRelationshipManagers(Moose::RelationshipManagerType input_rm_type) override; | ||
|
||
/// List of supported raw types (equivalent AD types are also supported) | ||
typedef Moose::TypeList<Real, RealVectorValue, RankTwoTensor, RankFourTensor> SupportedTypes; | ||
|
||
/// get an enum with all supported types | ||
static MooseEnum getTypeEnum(); | ||
|
||
template <typename T, bool is_ad> | ||
void processProperty(const MaterialPropertyName & prop_name); | ||
|
||
protected: | ||
template <typename T, int I> | ||
struct ProcessProperty | ||
{ | ||
static void apply(ProjectedStatefulMaterialStorageAction * self, | ||
const MaterialPropertyName & prop_name) | ||
{ | ||
self->processProperty<T, false>(prop_name); | ||
self->processProperty<T, true>(prop_name); | ||
} | ||
}; | ||
|
||
template <typename... Ts> | ||
static MooseEnum getTypeEnum(typename Moose::TypeList<Ts...>); | ||
|
||
/// Property names for which we will do stateful material property projection | ||
const std::vector<MaterialPropertyName> & _prop_names; | ||
|
||
/// Variable order to project the properties into | ||
const MooseEnum _order; | ||
|
||
/// FEType for the variables to project the properties into | ||
FEType _fe_type; | ||
|
||
/// MooseObject name for the underlying variable type | ||
const std::string _var_type; | ||
}; | ||
|
||
template <typename... Ts> | ||
MooseEnum | ||
ProjectedStatefulMaterialStorageAction::getTypeEnum(Moose::TypeList<Ts...>) | ||
{ | ||
return MooseEnum(Moose::stringify(std::vector<std::string>{typeid(Ts).name()...}, " ")); | ||
} | ||
|
||
template <typename T, bool is_ad> | ||
void | ||
ProjectedStatefulMaterialStorageAction::processProperty(const MaterialPropertyName & prop_name) | ||
{ | ||
// check if a property of type T exists | ||
const auto & block_data = _problem->getMaterialData(Moose::BLOCK_MATERIAL_DATA); | ||
const auto & boundary_data = _problem->getMaterialData(Moose::BOUNDARY_MATERIAL_DATA); | ||
if (!block_data.haveGenericProperty<T, is_ad>(prop_name) && | ||
!boundary_data.haveGenericProperty<T, is_ad>(prop_name)) | ||
return; | ||
|
||
// number of scalar components | ||
const auto size = Moose::SerialAccess<T>::size(); | ||
|
||
// generate variable names | ||
std::vector<VariableName> vars; | ||
for (const auto i : make_range(size)) | ||
vars.push_back("_var_" + prop_name + '_' + Moose::stringify(i)); | ||
|
||
if (_current_task == "setup_projected_properties") | ||
{ | ||
// add the AuxVars for storage | ||
for (const auto & var : vars) | ||
{ | ||
auto params = _factory.getValidParams(_var_type); | ||
params.applyParameters(parameters()); | ||
params.set<std::vector<OutputName>>("outputs") = {"none"}; | ||
_problem->addAuxVariable(_var_type, var, params); | ||
} | ||
|
||
// add material | ||
{ | ||
const auto type = Registry::getClassName<InterpolatedStatefulMaterialTempl<T>>(); | ||
auto params = _factory.getValidParams(type); | ||
params.applySpecificParameters(parameters(), {"block"}); | ||
params.template set<std::vector<VariableName>>("old_state") = vars; | ||
params.template set<MaterialPropertyName>("prop_name") = prop_name; | ||
_problem->addMaterial(type, "_mat_" + prop_name, params); | ||
} | ||
|
||
// use nodal patch recovery for lagrange | ||
if (_fe_type.family == LAGRANGE) | ||
{ | ||
// nodal variables require patch recovery (add user object) | ||
const auto & type = | ||
Registry::getClassName<ProjectedStatefulMaterialNodalPatchRecoveryTempl<T, is_ad>>(); | ||
auto params = _factory.getValidParams(type); | ||
params.applySpecificParameters(parameters(), {"block"}); | ||
params.template set<MaterialPropertyName>("property") = prop_name; | ||
params.template set<MooseEnum>("patch_polynomial_order") = _order; | ||
params.template set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END}; | ||
params.template set<bool>("force_preaux") = true; | ||
_problem->addUserObject(type, "_npruo_" + prop_name, params); | ||
} | ||
} | ||
|
||
if (_current_task == "add_aux_kernel") | ||
{ | ||
// create variables | ||
std::vector<std::string> auxnames; | ||
for (const auto i : make_range(size)) | ||
auxnames.push_back("_aux_" + prop_name + '_' + Moose::stringify(i)); | ||
|
||
// use nodal patch recovery for lagrange | ||
if (_fe_type.family == LAGRANGE) | ||
{ | ||
// nodal variables require patch recovery (add aux kernel) | ||
const auto & type = "ProjectedMaterialPropertyNodalPatchRecoveryAux"; | ||
for (const auto i : make_range(size)) | ||
{ | ||
auto params = _factory.getValidParams(type); | ||
params.applySpecificParameters(parameters(), {"block"}); | ||
params.template set<AuxVariableName>("variable") = vars[i]; | ||
params.template set<unsigned int>("component") = i; | ||
params.template set<UserObjectName>("nodal_patch_recovery_uo") = "_npruo_" + prop_name; | ||
params.template set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END}; | ||
_problem->addAuxKernel(type, auxnames[i], params); | ||
} | ||
} | ||
else | ||
{ | ||
// elemental variables | ||
const auto & type = Registry::getClassName<ProjectedStatefulMaterialAuxTempl<T, is_ad>>(); | ||
for (const auto i : make_range(size)) | ||
{ | ||
auto params = _factory.getValidParams(type); | ||
params.applySpecificParameters(parameters(), {"block"}); | ||
params.template set<AuxVariableName>("variable") = vars[i]; | ||
params.template set<unsigned int>("component") = i; | ||
params.template set<MaterialPropertyName>("prop") = prop_name; | ||
params.template set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END}; | ||
_problem->addAuxKernel(type, auxnames[i], params); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//* 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 "NodalPatchRecoveryAuxBase.h" | ||
|
||
/// Forward declare user object | ||
class NodalPatchRecoveryBase; | ||
|
||
class NodalPatchRecoveryAux : public NodalPatchRecoveryAuxBase | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
NodalPatchRecoveryAux(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual Real nodalPatchRecovery() override; | ||
|
||
private: | ||
const NodalPatchRecoveryBase & _npr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.