https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComputeHomogenizedLagrangianStrainA.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_gradientA",
30 "Scalar field defining the 1st component of"
31 "macro gradient");
32 params.addRequiredCoupledVar("macro_gradient",
33 "Scalar field defining the other components of"
34 "macro gradient");
35 return params;
36}
37
39 const InputParameters & parameters)
40 : Material(parameters),
41 _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
42 _macro_gradient(coupledScalarValue("macro_gradient")),
43 _macro_gradientA(coupledScalarValue("macro_gradientA")),
44 _homogenization_contribution(
45 declareProperty<RankTwoTensor>(_base_name + "homogenization_gradient_name"))
46{
47 // Constraint types
48 auto types = getParam<MultiMooseEnum>("constraint_types");
49 if (types.size() != Moose::dim * Moose::dim)
50 mooseError("Number of constraint types must equal dim * dim. ", types.size(), " are provided.");
51
52 // Targets to hit
53 const std::vector<FunctionName> & fnames = getParam<std::vector<FunctionName>>("targets");
54
55 // Prepare the constraint map
56 unsigned int fcount = 0;
57 for (const auto j : make_range(Moose::dim))
58 for (const auto i : make_range(Moose::dim))
59 {
60 const auto idx = i + Moose::dim * j;
61 const auto ctype = static_cast<HomogenizationB::ConstraintType>(types.get(idx));
63 {
64 const Function * const f = &getFunctionByName(fnames[fcount++]);
65 _cmap[{i, j}] = {ctype, f};
66 }
67 }
68}
69
70void
72{
74 unsigned int count = 0;
75 for (auto && indices : _cmap)
76 {
77 auto && [i, j] = indices.first;
78 if (count == 0)
80 else
81 {
82 unsigned int r_ind = count - 1;
83 count++;
85 }
86 }
87}
Real f(Real x)
Test function for Brents method.
registerMooseObject("SolidMechanicsTestApp", ComputeHomogenizedLagrangianStrainA)
unsigned int count
Calculate the tensor corresponding to homogenization gradient.
const VariableValue & _macro_gradient
ScalarVariable with the field.
MaterialProperty< RankTwoTensor > & _homogenization_contribution
Unwrapped into a tensor.
HomogenizationB::ConstraintMap _cmap
Constraint map.
const VariableValue & _macro_gradientA
ScalarVariable with 1st component of the field.
ComputeHomogenizedLagrangianStrainA(const InputParameters &parameters)
const Function & getFunctionByName(const FunctionName &name) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
unsigned int _qp
static InputParameters validParams()
void mooseError(Args &&... args) const
ConstraintType
Constraint type: stress/PK stress or strain/deformation gradient.
const MultiMooseEnum constraintType("strain stress none")
Moose constraint type, for input.
static constexpr std::size_t dim