https://mooseframework.inl.gov
ComputeHomogenizedLagrangianStrainS.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
13 
16 {
18  params.addParam<std::string>("base_name", "Material property base name");
19  params.addParam<MaterialPropertyName>("homogenization_gradient_name",
20  "homogenization_gradient",
21  "Name of the constant gradient field");
23  "constraint_types",
25  "Type of each constraint: strain, stress, or none. The types are specified in the "
26  "column-major order, and there must be 9 entries in total.");
27  params.addRequiredParam<std::vector<FunctionName>>(
28  "targets", "Functions giving the targets to hit for constraint types that are not none.");
29  params.addRequiredCoupledVar("macro_gradient",
30  "Scalar field defining the "
31  "macro gradient");
32  return params;
33 }
34 
36  const InputParameters & parameters)
37  : Material(parameters),
38  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
39  _macro_gradient(coupledScalarValue("macro_gradient")),
40  _homogenization_contribution(
41  declareProperty<RankTwoTensor>(_base_name + "homogenization_gradient_name"))
42 {
43  // Constraint types
44  auto types = getParam<MultiMooseEnum>("constraint_types");
45  if (types.size() != Moose::dim * Moose::dim)
46  mooseError("Number of constraint types must equal dim * dim. ", types.size(), " are provided.");
47 
48  // Targets to hit
49  const std::vector<FunctionName> & fnames = getParam<std::vector<FunctionName>>("targets");
50 
51  // Prepare the constraint map
52  unsigned int fcount = 0;
53  for (const auto j : make_range(Moose::dim))
54  for (const auto i : make_range(Moose::dim))
55  {
56  const auto idx = i + Moose::dim * j;
57  const auto ctype = static_cast<HomogenizationM::ConstraintType>(types.get(idx));
59  {
60  const Function * const f = &getFunctionByName(fnames[fcount++]);
61  _cmap[{i, j}] = {ctype, f};
62  }
63  }
64 }
65 
66 void
68 {
70  unsigned int count = 0;
71  for (auto && indices : _cmap)
72  {
73  auto && [i, j] = indices.first;
75  }
76 }
registerMooseObject("SolidMechanicsTestApp", ComputeHomogenizedLagrangianStrainS)
const VariableValue & _macro_gradient
ScalarVariable with the field.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static constexpr std::size_t dim
void addRequiredParam(const std::string &name, const std::string &doc_string)
unsigned int _qp
static InputParameters validParams()
ConstraintType
Constraint type: stress/PK stress or strain/deformation gradient.
Real f(Real x)
Test function for Brents method.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
HomogenizationM::ConstraintMap _cmap
Constraint map.
const Function & getFunctionByName(const FunctionName &name) const
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
const MultiMooseEnum constraintType("strain stress none")
Moose constraint type, for input.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
MaterialProperty< RankTwoTensor > & _homogenization_contribution
Unwrapped into a tensor.
Calculate the tensor corresponding to homogenization gradient.
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
ComputeHomogenizedLagrangianStrainS(const InputParameters &parameters)