23 "homogenization constraint Jacobian terms");
25 "scalar_variable",
"macro_var",
"Optional scalar field with the macro gradient");
29 "Type of each constraint: strain, stress, or none. The types are specified in the " 30 "column-major order, and there must be 9 entries in total.");
32 "targets",
"Functions giving the targets to hit for constraint types that are not none.");
42 auto types = getParam<MultiMooseEnum>(
"constraint_types");
44 mooseError(
"Number of constraint types must equal dim * dim. ", types.size(),
" are provided.");
47 const std::vector<FunctionName> & fnames = getParam<std::vector<FunctionName>>(
"targets");
50 unsigned int fcount = 0;
58 const Function *
const f = &getFunctionByName(fnames[fcount++]);
67 std::vector<Real> scalar_residuals(_k_order);
72 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
74 initScalarQpResidual();
75 Real dV = _JxW[_qp] * _coord[_qp];
77 for (
auto && [indices, constraint] :
_cmap)
79 auto && [i,
j] = indices;
80 auto && [ctype, ctarget] = constraint;
85 scalar_residuals[_h++] += dV * (
_pk1[_qp](i,
j) - ctarget->value(_t, _q_point[_qp]));
87 scalar_residuals[_h++] +=
88 dV * (
_F[_qp](i,
j) - (
Real(i ==
j) + ctarget->value(_t, _q_point[_qp])));
90 mooseError(
"Unknown constraint type in the integral!");
95 scalar_residuals[_h++] += dV * (
_pk1[_qp](i,
j) - ctarget->value(_t, _q_point[_qp]));
97 scalar_residuals[_h++] += dV * (0.5 * (
_F[_qp](i,
j) +
_F[_qp](
j, i)) -
98 (
Real(i ==
j) + ctarget->value(_t, _q_point[_qp])));
100 mooseError(
"Unknown constraint type in the integral!");
107 _assembly, scalar_residuals, _kappa_var_ptr->dofIndices(), _kappa_var_ptr->scalingFactor());
113 _local_ke.resize(_k_order, _k_order);
118 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
120 initScalarQpJacobian(_kappa_var);
121 Real dV = _JxW[_qp] * _coord[_qp];
124 for (
auto && [indices1, constraint1] :
_cmap)
126 auto && [i,
j] = indices1;
127 auto && ctype = constraint1.first;
129 for (
auto && indices2 :
_cmap)
131 auto && [
a,
b] = indices2.first;
133 _local_ke(_h, _l++) += dV * (
_dpk1[_qp](i,
j,
a,
b));
137 _local_ke(_h, _l++) += dV * (
Real(i ==
a &&
j ==
b));
139 _local_ke(_h, _l++) +=
140 dV * (0.5 *
Real(i ==
a &&
j ==
b) + 0.5 *
Real(i ==
b &&
j ==
a));
143 mooseError(
"Unknown constraint type in Jacobian calculator!");
150 addJacobian(_assembly,
152 _kappa_var_ptr->dofIndices(),
153 _kappa_var_ptr->dofIndices(),
154 _kappa_var_ptr->scalingFactor());
159 const unsigned int jvar_num)
161 const auto & jvar = getVariable(jvar_num);
163 const auto jvar_size = jvar.phiSize();
164 _local_ke.resize(_k_order, jvar_size);
166 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
170 Real dV = _JxW[_qp] * _coord[_qp];
171 for (
auto && [indices, constraint] :
_cmap)
176 _ctype = constraint.first;
177 initScalarQpOffDiagJacobian(jvar);
178 for (_j = 0; _j < jvar_size; _j++)
184 addJacobian(_assembly,
186 _kappa_var_ptr->dofIndices(),
188 _kappa_var_ptr->scalingFactor());
193 const unsigned int svar_num)
197 const auto & svar = _sys.getScalarVariable(_tid, svar_num);
198 const unsigned int s_order = svar.order();
199 _local_ke.resize(_test.size(), s_order);
201 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
204 Real dV = _JxW[_qp] * _coord[_qp];
205 for (
auto && [indices, constraint] :
_cmap)
210 _ctype = constraint.first;
211 initScalarQpJacobian(svar_num);
212 for (_i = 0; _i < _test.size(); _i++)
220 addJacobian(_assembly, _local_ke, _var.dofIndices(), svar.dofIndices(), _var.scalingFactor());
227 if (svar_num == _kappa_var)
238 if (jvar_num == _var.number())
249 mooseError(
"Unknown constraint type in kernel calculation!");
HomogenizedTotalLagrangianStressDivergenceS(const InputParameters ¶meters)
static InputParameters validParams()
const unsigned int _alpha
Which component of the vector residual this kernel is responsible for.
const bool _large_kinematics
If true use large deformation kinematics.
void mooseError(Args &&... args)
static constexpr std::size_t dim
const MultiMooseEnum constraintType("strain stress none")
Moose constraint type, for input.
Enforce equilibrium with a total Lagrangian formulation.
unsigned int _m
Used internally to iterate over each scalar component.
registerMooseObject("SolidMechanicsTestApp", HomogenizedTotalLagrangianStressDivergenceS)
HomogenizationS::ConstraintType _ctype
The constraint type; initialize with 'none'.
virtual void computeScalarResidual() override
Method for computing the scalar part of residual for _kappa.
Real f(Real x)
Test function for Brents method.
HomogenizationS::ConstraintMap _cmap
Type of each constraint (stress or strain) for each component.
virtual void computeScalarOffDiagJacobian(const unsigned int jvar_num) override
Method for computing an off-diagonal jacobian component d-_kappa-residual / d-jvar.
virtual RankTwoTensor gradTest(unsigned int component) override
virtual Real computeQpOffDiagJacobianScalar(const unsigned int svar_num) override
Method for computing d-_var-residual / d-svar at quadrature points.
const MaterialProperty< RankTwoTensor > & _F
The actual (stabilized) deformation gradient.
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ConstraintType
Constraint type: stress/PK stress or strain/deformation gradient.
virtual void computeOffDiagJacobianScalarLocal(const unsigned int svar_num) override
Method for computing an off-diagonal jacobian component d-_var-residual / d-svar. ...
virtual void computeScalarJacobian() override
Method for computing the scalar variable part of Jacobian for d-_kappa-residual / d-_kappa...
IntRange< T > make_range(T beg, T end)
Total Lagrangian formulation with all homogenization terms (one disp_xyz field and macro_gradient sca...
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
virtual Real computeScalarQpOffDiagJacobian(const unsigned int jvar_num) override
Method for computing an off-diagonal jacobian component at quadrature points.
const MaterialProperty< RankFourTensor > & _dpk1
The derivative of the PK1 stress with respect to the deformation gradient.
const MaterialProperty< RankTwoTensor > & _pk1
The 1st Piola-Kirchhoff stress.
virtual RankTwoTensor gradTrial(unsigned int component) override