https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LagrangianStressDivergenceBase.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#include "RankFourTensor.h"
12
15{
17
18 params.addRequiredParam<unsigned int>("component", "Which direction this kernel acts in");
19 params.addRequiredCoupledVar("displacements", "The displacement components");
20
21 params.addDeprecatedParam<bool>(
22 "large_kinematics",
23 false,
24 "Use large displacement kinematics",
25 "large_kinematics is no longer set on the stress-divergence kernel; it is derived from the "
26 "ComputeLagrangianStrain calculator (the single source of truth) via the LARGE_KINEMATICS "
27 "guarantee. Remove it here and set it only on the strain calculator.");
28 params.addParam<bool>(
29 "stabilize_strain",
30 false,
31 "Average the volumetric strains (must match the strain calculator's setting)");
32 MooseEnum F_bar_mode("total incremental", "total");
33 params.addParam<MooseEnum>(
34 "F_bar_mode",
35 F_bar_mode,
36 "Which F gets the F-bar volumetric correction (must match the strain calc's setting). "
37 "'total' (default) reproduces existing behavior; 'incremental' makes the F-bar element-"
38 "average operate on the incremental F so cumulative strain matches OLD's "
39 "`ComputeFiniteStrain` + `volumetric_locking_correction = true`.");
40
41 params.addParam<std::string>("base_name", "Material property base name");
42
43 params.addCoupledVar("temperature",
44 "The name of the temperature variable used in the "
45 "ComputeThermalExpansionEigenstrain. (Not required for "
46 "simulations without temperature coupling.)");
47
48 params.addParam<std::vector<MaterialPropertyName>>(
49 "eigenstrain_names",
50 {},
51 "List of eigenstrains used in the strain calculation. Used for computing their derivatives "
52 "for off-diagonal Jacobian terms.");
53
54 params.addCoupledVar("out_of_plane_strain",
55 "The out-of-plane strain variable for weak plane stress formulation.");
56
57 return params;
58}
59
63 // Derived from the strain calculator's guarantee in initialSetup(); the local parameter is
64 // deprecated and only consulted for a consistency cross-check.
65 _large_kinematics(false),
66 _stabilize_strain(getParam<bool>("stabilize_strain")),
67 _F_bar_mode(getParam<MooseEnum>("F_bar_mode") == "incremental" ? FBarMode::Incremental
68 : FBarMode::Total),
69 _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
70 _alpha(getParam<unsigned int>("component")),
71 _ndisp(coupledComponents("displacements")),
72 _disp_nums(_ndisp),
73 _avg_grad_trial(_ndisp),
74 _avg_grad_spatial_phi(_ndisp),
75 _avg_test_phi_cross(3, std::vector<std::vector<std::vector<Real>>>(3)),
76 _F_ust(
77 getMaterialPropertyByName<RankTwoTensor>(_base_name + "unstabilized_deformation_gradient")),
78 _F_ust_old(getMaterialPropertyOldByName<RankTwoTensor>(_base_name +
79 "unstabilized_deformation_gradient")),
80 _F_avg(getMaterialPropertyByName<RankTwoTensor>(_base_name + "average_deformation_gradient")),
81 _f_inv(getMaterialPropertyByName<RankTwoTensor>(_base_name +
82 "inverse_incremental_deformation_gradient")),
83 _F_inv(getMaterialPropertyByName<RankTwoTensor>(_base_name + "inverse_deformation_gradient")),
84 _F(getMaterialPropertyByName<RankTwoTensor>(_base_name + "deformation_gradient")),
85 _F_actual(getMaterialPropertyByName<RankTwoTensor>(_base_name + "actual_deformation_gradient")),
86 _d_deformation_gradient_increment_d_F(getMaterialPropertyByName<RankFourTensor>(
87 _base_name + "d_spatial_deformation_gradient_increment_d_deformation_gradient")),
88 _d_F_d_grad_u(getMaterialPropertyByName<RankFourTensor>(
89 _base_name + "d_deformation_gradient_d_grad_displacement")),
90 _d_F_stab_d_F_ust(
91 getMaterialPropertyByName<RankFourTensor>(_base_name + "d_F_stab_d_F_unstabilized")),
92 _d_F_stab_d_F_avg(
93 getMaterialPropertyByName<RankFourTensor>(_base_name + "d_F_stab_d_F_average")),
94 _temperature(isCoupled("temperature") ? getVar("temperature", 0) : nullptr),
95 _out_of_plane_strain(isCoupled("out_of_plane_strain") ? getVar("out_of_plane_strain", 0)
96 : nullptr)
97{
98 // Do the vector coupling of the displacements
99 for (unsigned int i = 0; i < _ndisp; i++)
100 _disp_nums[i] = coupled("displacements", i);
101
102 // We need to use identical discretizations for all displacement components
103 auto order_x = getVar("displacements", 0)->order();
104 for (unsigned int i = 1; i < _ndisp; i++)
105 {
106 if (getVar("displacements", i)->order() != order_x)
107 mooseError("The Lagrangian StressDivergence kernels require equal "
108 "order interpolation for all displacements.");
109 }
110
111 // fetch eigenstrain derivatives
112 const auto nvar = _coupled_moose_vars.size();
113 _deigenstrain_dargs.resize(nvar);
114 for (std::size_t i = 0; i < nvar; ++i)
115 for (auto eigenstrain_name : getParam<std::vector<MaterialPropertyName>>("eigenstrain_names"))
116 _deigenstrain_dargs[i].push_back(&getMaterialPropertyDerivative<RankTwoTensor>(
117 eigenstrain_name, _coupled_moose_vars[i]->name()));
118
119 // The direct-chain temperature off-diagonal Jacobian needs d_sigma/d_eigenstrain. Only
120 // fetch it when eigenstrains are coupled -- otherwise the temperature Jacobian short-
121 // circuits to zero and this property would be a needless dependency that other Cauchy-
122 // providing materials would have to publish.
123 if (!getParam<std::vector<MaterialPropertyName>>("eigenstrain_names").empty())
125 &getMaterialPropertyByName<RankFourTensor>(_base_name + "dcauchy_stress_d_eigenstrain");
126
127 // The F-bar spatial push-forward consumes F_ust^{-1}/det(F_ust) published by the strain calc.
128 // Fetch them (and thereby mark them active for the strain material's isPropertyActive gate)
129 // only when stabilization is on -- the only mode where the push-forward runs.
131 {
132 _F_ust_inv = &getMaterialPropertyByName<RankTwoTensor>(
133 _base_name + "inverse_unstabilized_deformation_gradient");
134 _F_ust_det =
135 &getMaterialPropertyByName<Real>(_base_name + "det_unstabilized_deformation_gradient");
136 _d_nl_fbar = &getMaterialPropertyByName<RankFourTensor>(_base_name + "d_nl_fbar_operator");
137 }
138}
139
140void
142{
144
145 // Derive the kinematics regime from the strain calculator's LARGE_KINEMATICS guarantee -- the
146 // single source of truth. hasGuaranteedMaterialProperty is block-restricted (per subdomain) and
147 // keyed by the base_name-prefixed deformation_gradient, so a given base_name resolves against its
148 // own strain calculator.
151
152 // The deprecated local parameter must not silently disagree with the strain calculator.
153 if (isParamSetByUser("large_kinematics") &&
154 getParam<bool>("large_kinematics") != _large_kinematics)
155 paramError("large_kinematics",
156 "large_kinematics disagrees with the ComputeLagrangianStrain calculator (which "
157 "computes ",
158 _large_kinematics ? "large" : "small",
159 " kinematics). large_kinematics is deprecated here; set it only on the strain "
160 "calculator.");
161
162 // The kernel builds its F-bar Jacobian (and, for incremental F-bar, a B-bar residual term) for
163 // its own settings, so they must match the F-bar that the strain calculator applies
164 const std::string F_name = _base_name + "deformation_gradient";
166 paramError("stabilize_strain",
167 "stabilize_strain disagrees with the ComputeLagrangianStrain calculator. Set it to "
168 "the same value on both, e.g. in GlobalParams.");
171 paramError("F_bar_mode",
172 "F_bar_mode disagrees with the ComputeLagrangianStrain calculator. Set it to the "
173 "same value on both, e.g. in GlobalParams.");
174}
175
176void
178{
179 // Skip if we are not doing stabilization
181 return;
182
183 // We need the gradients of shape functions in the reference frame
184 _fe_problem.prepareShapes(_var.number(), _tid);
185 _avg_grad_trial[_alpha].resize(_phi.size());
187}
188
189void
191{
192 // Skip if we are not doing stabilization
194 return;
195
196 for (auto beta : make_range(_ndisp))
197 if (jvar == _disp_nums[beta])
198 {
199 // We need the gradients of shape functions in the reference frame
200 _fe_problem.prepareShapes(jvar, _tid);
201 _avg_grad_trial[beta].resize(_phi.size());
203 }
204}
205
206Real
211
214{
216 return RankTwoTensor();
217 // `_d_nl_fbar` (the composed non-local operator) and F_ust^{-1}/det come from the stress and
218 // strain materials as per-qp properties -- no kernel-side cache to refresh.
219 const RankTwoTensor delta_sigma_nl = (*_d_nl_fbar)[_qp] * delta_F_avg;
221 return (*_F_ust_det)[_qp] * delta_sigma_nl * (*_F_ust_inv)[_qp].transpose();
222 return delta_sigma_nl;
223}
224
225Real
227{
228 // Bail if jvar not coupled
229 if (getJvarMap()[jvar] < 0)
230 return 0.0;
231
232 // Off diagonal terms for other displacements
233 for (auto beta : make_range(_ndisp))
234 if (jvar == _disp_nums[beta])
236
237 // Off diagonal temperature term due to eigenstrain
238 if (_temperature && jvar == _temperature->number())
240
241 // Off diagonal term due to weak plane stress
244
245 return 0;
246}
@ LARGE_KINEMATICS
@ F_BAR_INCREMENTAL
void mooseError(Args &&... args)
const std::string name
Definition Setup.h:21
void ErrorVector unsigned int
Add-on class that provides the functionality to check if guarantees for material properties are provi...
bool hasGuaranteedMaterialProperty(const MaterialPropertyName &prop, Guarantee guarantee)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
const MaterialProperty< Real > * _F_ust_det
virtual void precalculateOffDiagJacobian(unsigned int jvar) override
RankTwoTensor deltaPK1NonLocalFBar(const RankTwoTensor &delta_F_avg) const
Non-local F-bar contribution to deltaPK1 at the current _qp, given the perturbation delta_F_avg of th...
const bool _stabilize_strain
If true calculate the deformation gradient derivatives for F_bar.
const unsigned int _alpha
Which component of the vector residual this kernel is responsible for.
virtual Real computeQpJacobianDisplacement(unsigned int alpha, unsigned int beta)=0
const MaterialProperty< RankTwoTensor > * _F_ust_inv
F_ust^{-1} and det(F_ust) from the strain calculator, consumed by the F-bar spatial push-forward (gra...
const unsigned int _ndisp
Total number of displacements/size of residual vector.
const MooseVariable * _out_of_plane_strain
Out-of-plane strain, if provided.
LagrangianStressDivergenceBase(const InputParameters &parameters)
const FBarMode _F_bar_mode
What F gets F-bar volumetric correction (Total vs.
virtual Real computeQpJacobianOutOfPlaneStrain()=0
bool _large_kinematics
If true use large deformation kinematics.
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
std::vector< unsigned int > _disp_nums
The displacement numbers.
FBarMode
Mirrors ComputeLagrangianStrainBase::FBarMode.
std::vector< std::vector< RankTwoTensor > > _avg_grad_trial
virtual Real computeQpJacobianTemperature(unsigned int cvar)=0
std::vector< std::vector< const MaterialProperty< RankTwoTensor > * > > _deigenstrain_dargs
Eigenstrain derivatives wrt generate coupleds.
const std::string _base_name
Prepend to the material properties.
const MooseVariable * _temperature
Temperature, if provided. This is used only to get the trial functions.
const MaterialProperty< RankFourTensor > * _dcauchy_stress_d_eigenstrain
Derivative of the Cauchy stress with respect to the eigenstrain (published by ComputeLagrangianObject...
const MaterialProperty< RankFourTensor > * _d_nl_fbar
Composed non-local F-bar operator D_nl = cauchy_jac : d(dL)/dF : d(F_stab)/d(F_avg),...
virtual void precalculateJacobianDisplacement(unsigned int component)=0
Prepare the average shape function gradients for stabilization.
virtual void initialSetup() override
Derive _large_kinematics from the strain calculator's LARGE_KINEMATICS guarantee.
unsigned int number() const
RankTwoTensorTempl< T > transpose() const