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