-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error of missing () in residual integration loop
Add test cases and gold files for the 2d homogenization
- Loading branch information
Showing
11 changed files
with
497 additions
and
32 deletions.
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
modules/tensor_mechanics/test/include/materials/ComputeHomogenizedLagrangianStrainS.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,57 @@ | ||
//* 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" | ||
|
||
// Helpers common to the whole homogenization system | ||
namespace HomogenizationM | ||
{ | ||
/// Moose constraint type, for input | ||
const MultiMooseEnum constraintType("strain stress none"); | ||
/// Constraint type: stress/PK stress or strain/deformation gradient | ||
enum class ConstraintType | ||
{ | ||
Strain, | ||
Stress, | ||
None | ||
}; | ||
typedef std::map<std::pair<unsigned int, unsigned int>, std::pair<ConstraintType, const Function *>> | ||
ConstraintMap; | ||
} | ||
|
||
/// Calculate the tensor corresponding to homogenization gradient | ||
/// | ||
/// This class takes a scalar field of the right size representing a | ||
/// constant deformation gradient over the domain and casts it into | ||
/// a RankTwo material property | ||
/// | ||
class ComputeHomogenizedLagrangianStrainS : public Material | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
ComputeHomogenizedLagrangianStrainS(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual void computeQpProperties() override; | ||
|
||
protected: | ||
/// The base name for material properties | ||
const std::string _base_name; | ||
|
||
/// Constraint map | ||
HomogenizationM::ConstraintMap _cmap; | ||
|
||
/// ScalarVariable with the field | ||
const VariableValue & _macro_gradient; | ||
|
||
/// Unwrapped into a tensor | ||
MaterialProperty<RankTwoTensor> & _homogenization_contribution; | ||
}; |
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
76 changes: 76 additions & 0 deletions
76
modules/tensor_mechanics/test/src/materials/ComputeHomogenizedLagrangianStrainS.C
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,76 @@ | ||
//* 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 | ||
|
||
#include "ComputeHomogenizedLagrangianStrainS.h" | ||
|
||
registerMooseObject("TensorMechanicsApp", ComputeHomogenizedLagrangianStrainS); | ||
|
||
InputParameters | ||
ComputeHomogenizedLagrangianStrainS::validParams() | ||
{ | ||
InputParameters params = Material::validParams(); | ||
params.addParam<std::string>("base_name", "Material property base name"); | ||
params.addParam<MaterialPropertyName>("homogenization_gradient_name", | ||
"homogenization_gradient", | ||
"Name of the constant gradient field"); | ||
params.addRequiredParam<MultiMooseEnum>( | ||
"constraint_types", | ||
HomogenizationM::constraintType, | ||
"Type of each constraint: strain, stress, or none. The types are specified in the " | ||
"column-major order, and there must be 9 entries in total."); | ||
params.addRequiredParam<std::vector<FunctionName>>( | ||
"targets", "Functions giving the targets to hit for constraint types that are not none."); | ||
params.addRequiredCoupledVar("macro_gradient", | ||
"Scalar field defining the " | ||
"macro gradient"); | ||
return params; | ||
} | ||
|
||
ComputeHomogenizedLagrangianStrainS::ComputeHomogenizedLagrangianStrainS( | ||
const InputParameters & parameters) | ||
: Material(parameters), | ||
_base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), | ||
_macro_gradient(coupledScalarValue("macro_gradient")), | ||
_homogenization_contribution( | ||
declareProperty<RankTwoTensor>(_base_name + "homogenization_gradient_name")) | ||
{ | ||
// Constraint types | ||
auto types = getParam<MultiMooseEnum>("constraint_types"); | ||
if (types.size() != Moose::dim * Moose::dim) | ||
mooseError("Number of constraint types must equal dim * dim. ", types.size(), " are provided."); | ||
|
||
// Targets to hit | ||
const std::vector<FunctionName> & fnames = getParam<std::vector<FunctionName>>("targets"); | ||
|
||
// Prepare the constraint map | ||
unsigned int fcount = 0; | ||
for (const auto j : make_range(Moose::dim)) | ||
for (const auto i : make_range(Moose::dim)) | ||
{ | ||
const auto idx = i + Moose::dim * j; | ||
const auto ctype = static_cast<HomogenizationM::ConstraintType>(types.get(idx)); | ||
if (ctype != HomogenizationM::ConstraintType::None) | ||
{ | ||
const Function * const f = &getFunctionByName(fnames[fcount++]); | ||
_cmap[{i, j}] = {ctype, f}; | ||
} | ||
} | ||
} | ||
|
||
void | ||
ComputeHomogenizedLagrangianStrainS::computeQpProperties() | ||
{ | ||
_homogenization_contribution[_qp].zero(); | ||
unsigned int count = 0; | ||
for (auto && indices : _cmap) | ||
{ | ||
auto && [i, j] = indices.first; | ||
_homogenization_contribution[_qp](i, j) = _macro_gradient[count++]; | ||
} | ||
} |
Binary file added
BIN
+9.67 KB
...ensor_mechanics/test/tests/lagrangian/cartesian/total/homogenization/scalar_kernel/2d.exo
Binary file not shown.
Oops, something went wrong.