https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HomogenizedTotalLagrangianStressDivergenceA Class Reference

Total Lagrangian formulation with most homogenization terms (one disp_xyz field and one scalar) The macro_gradient variable is split into two scalars: the first component called '_hvar' herein and all other components called '_avar' herein. More...

#include <HomogenizedTotalLagrangianStressDivergenceA.h>

Inheritance diagram for HomogenizedTotalLagrangianStressDivergenceA:
[legend]

Public Types

typedef std::vector< intJvarMap
 

Public Member Functions

 HomogenizedTotalLagrangianStressDivergenceA (const InputParameters &parameters)
 
virtual void initialSetup () override
 
template<>
void initialSetup ()
 
template<>
void initialSetup ()
 
template<>
void initialSetup ()
 
virtual void computeOffDiagJacobian (unsigned int jvar) override
 
unsigned int mapJvarToCvar (unsigned int jvar)
 
int mapJvarToCvar (unsigned int jvar, const JvarMap &jvar_map)
 
bool mapJvarToCvar (unsigned int jvar, unsigned int &cvar)
 
const JvarMapgetJvarMap ()
 
const JvarMapgetParameterJvarMap (std::string parameter_name)
 

Static Public Member Functions

static InputParameters validParams ()
 
static InputParameters baseParams ()
 

Protected Member Functions

virtual Real computeQpResidual () override
 
virtual Real computeQpJacobianDisplacement (unsigned int alpha, unsigned int beta) override
 
virtual void computeScalarResidual () override
 Method for computing the scalar part of residual for _kappa. More...
 
virtual void computeScalarJacobian () override
 Method for computing the scalar variable part of Jacobian for d-_kappa-residual / d-_kappa. More...
 
virtual void computeScalarOffDiagJacobian (const unsigned int jvar_num) override
 Method for computing an off-diagonal jacobian component d-_kappa-residual / d-jvar jvar is looped over all field variables, which herein is just disp_x and disp_y. More...
 
virtual Real computeScalarQpOffDiagJacobian (const unsigned int jvar_num) override
 Method for computing an off-diagonal jacobian component at quadrature points. More...
 
virtual void computeOffDiagJacobianScalarLocal (const unsigned int svar_num) override
 Method for computing an off-diagonal jacobian component d-_var-residual / d-svar. More...
 
virtual Real computeQpOffDiagJacobianScalar (const unsigned int svar_num) override
 Method for computing d-_var-residual / d-_svar at quadrature points. More...
 
virtual void computeScalarOffDiagJacobianScalar (const unsigned int svar_num) override
 Method for computing an off-diagonal jacobian component d-_kappa-residual / d-svar svar is looped over other scalar variables, which herein is just _kappa_other. More...
 
virtual RankTwoTensor gradTest (unsigned int component) override
 
virtual RankTwoTensor gradTrial (unsigned int component) override
 
virtual void precalculateJacobianDisplacement (unsigned int component) override
 Prepare the average shape function gradients for stabilization. More...
 
virtual Real computeQpJacobianTemperature (unsigned int cvar) override
 
virtual Real computeQpJacobianOutOfPlaneStrain () override
 
virtual void precalculateJacobian () override
 
virtual void precalculateOffDiagJacobian (unsigned int jvar) override
 
virtual Real computeQpJacobian () override
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar) override
 

Protected Attributes

const unsigned int _beta
 Which component of the scalar vector residual this constraint is responsible for. More...
 
const MooseVariableScalar *const _kappao_var_ptr
 (Pointer to) Scalar variable this kernel operates on More...
 
const unsigned int _kappao_var
 The unknown scalar variable ID. More...
 
const unsigned int _ko_order
 Order of the scalar variable, used in several places. More...
 
const VariableValue_kappa_other
 Reference to the current solution at the current quadrature point. More...
 
HomogenizationA::ConstraintMap _cmap
 Type of each constraint (stress or strain) for each component. More...
 
HomogenizationA::ConstraintType _ctype = HomogenizationA::ConstraintType::None
 The constraint type; initialize with 'none'. More...
 
unsigned int _m
 Used internally to iterate over each scalar component. More...
 
unsigned int _n
 
unsigned int _a
 
unsigned int _b
 
const MaterialProperty< RankTwoTensor > & _pk1
 The 1st Piola-Kirchhoff stress. More...
 
const MaterialProperty< RankFourTensor > & _dpk1
 The derivative of the PK1 stress with respect to the deformation gradient. More...
 
const bool _large_kinematics
 If true use large deformation kinematics. More...
 
const bool _stabilize_strain
 If true calculate the deformation gradient derivatives for F_bar. More...
 
const std::string _base_name
 Prepend to the material properties. More...
 
const unsigned int _alpha
 Which component of the vector residual this kernel is responsible for. More...
 
const unsigned int _ndisp
 Total number of displacements/size of residual vector. More...
 
std::vector< unsigned int_disp_nums
 The displacement numbers. More...
 
std::vector< std::vector< RankTwoTensor > > _avg_grad_trial
 
const MaterialProperty< RankTwoTensor > & _F_ust
 The unmodified deformation gradient. More...
 
const MaterialProperty< RankTwoTensor > & _F_avg
 The element-average deformation gradient. More...
 
const MaterialProperty< RankTwoTensor > & _f_inv
 The inverse increment deformation gradient. More...
 
const MaterialProperty< RankTwoTensor > & _F_inv
 The inverse deformation gradient. More...
 
const MaterialProperty< RankTwoTensor > & _F
 The actual (stabilized) deformation gradient. More...
 
const MooseVariable_temperature
 Temperature, if provided. This is used only to get the trial functions. More...
 
const MooseVariable_out_of_plane_strain
 Out-of-plane strain, if provided. More...
 
std::vector< std::vector< const MaterialProperty< RankTwoTensor > * > > _deigenstrain_dargs
 Eigenstrain derivatives wrt generate coupleds. More...
 
const unsigned int _n_args
 

Detailed Description

Total Lagrangian formulation with most homogenization terms (one disp_xyz field and one scalar) The macro_gradient variable is split into two scalars: the first component called '_hvar' herein and all other components called '_avar' herein.

For parameter _beta = 0, the primary scalar (_kappa) is _hvar and the coupled scalar is _avar. For parameter _beta = 1, the primary scalar (_kappa) is _avar and the coupled scalar is _hvar. Just like the primary field variable (_var) is either disp_x or disp_y or disp_z depending on _alpha.

Thus, each instance of HomogenizedTotalLagrangianStressDivergenceA acts on one field variable (_disp_alpha) and one scalar variable (_hvar_beta). The job of the kernel is to assemble the residual of all dofs of _disp_alpha and of all dofs of _hvar_beta (namely, selected entries). It assembles a symmetric portion of the Jacobian for _disp_alpha and _hvar_beta, with some logical checks to access only the particular desired terms (often for _alpha or _beta = 0). The entries for the other field/scalar variables are handled by other instances of the kernel, which have other values of _alpha AND _beta. The logical checks ensure the proper decomposition of the jobs.

In summary, for x=disp_x etc. and h=_hvar and a=_avar, then the contributions of the instances are _alpha=0, _beta=0 R = [Rx, 00, 00, Rh, 00 ]^T J = [Jxx, Jxy, Jxz, Jxh, 000 Jhx, 000, 000, Jhh, Jha] _alpha=1, _beta=0 R = [00, Ry, 00, 00, 00 ]^T J = [Jyx, Jyy, Jyz, Jyh, 000 000, Jhy, 000, 000, 000] _alpha=2, _beta=0 R = [00, 00, Rz, 00, 00 ]^T J = [Jzx, Jzy, Jzz, Jzh, 000 000, 000, Jhz, 000, 000] _alpha=0, _beta=1 R = [00, 00, 00, 00, Ra ]^T J = [000, 000, 000, 000, Jxa Jax, 000, 000, Jah, Jaa] _alpha=1, _beta=1 R = [00, 00, 00, 00, 00 ]^T J = [000, 000, 000, 000, Jya 000, Jay, 000, 000, 000] _alpha=2, _beta=1 R = [00, 00, 00, 00, 00 ]^T J = [000, 000, 000, 000, Jza 000, 000, Jaz, 000, 000]

In this manner, the full R and J are obtained with NO duplication of jobs: R = [Rx, Ry, Rz, Rh, Ra ]^T J = [Jxx, Jxy, Jxz, Jxh, Jxa Jyx, Jyy, Jyz, Jyh, Jya Jzx, Jzy, Jzz, Jzh, Jza Jhx, Jhy, Jhz, Jhh, Jha Jax, Jay, Jaz, Jah, Jaa]

Definition at line 80 of file HomogenizedTotalLagrangianStressDivergenceA.h.

Constructor & Destructor Documentation

◆ HomogenizedTotalLagrangianStressDivergenceA()

HomogenizedTotalLagrangianStressDivergenceA::HomogenizedTotalLagrangianStressDivergenceA ( const InputParameters parameters)

Definition at line 45 of file HomogenizedTotalLagrangianStressDivergenceA.C.

48  _beta(getParam<unsigned int>("prime_scalar")),
49  _kappao_var_ptr(getScalarVar("macro_other", 0)),
50  _kappao_var(coupledScalar("macro_other")),
51  _ko_order(getScalarVar("macro_other", 0)->order()),
52  _kappa_other(coupledScalarValue("macro_other"))
53 {
54  // Constraint types
55  auto types = getParam<MultiMooseEnum>("constraint_types");
56  if (types.size() != Moose::dim * Moose::dim)
57  mooseError("Number of constraint types must equal dim * dim. ", types.size(), " are provided.");
58 
59  // Targets to hit
60  const std::vector<FunctionName> & fnames = getParam<std::vector<FunctionName>>("targets");
61 
62  // Prepare the constraint map
63  unsigned int fcount = 0;
64  for (const auto j : make_range(Moose::dim))
65  for (const auto i : make_range(Moose::dim))
66  {
67  const auto idx = i + Moose::dim * j;
68  const auto ctype = static_cast<HomogenizationA::ConstraintType>(types.get(idx));
70  {
71  const Function * const f = &getFunctionByName(fnames[fcount++]);
72  _cmap[{i, j}] = {ctype, f};
73  }
74  }
75 }
const unsigned int _ko_order
Order of the scalar variable, used in several places.
void mooseError(Args &&... args)
static constexpr std::size_t dim
HomogenizationA::ConstraintMap _cmap
Type of each constraint (stress or strain) for each component.
const MooseVariableScalar *const _kappao_var_ptr
(Pointer to) Scalar variable this kernel operates on
Real f(Real x)
Test function for Brents method.
const unsigned int _beta
Which component of the scalar vector residual this constraint is responsible for. ...
const unsigned int _kappao_var
The unknown scalar variable ID.
TotalLagrangianStressDivergenceBaseS< GradientOperatorCartesian > TotalLagrangianStressDivergenceS
IntRange< T > make_range(T beg, T end)
ConstraintType
Constraint type: stress/PK stress or strain/deformation gradient.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const VariableValue & _kappa_other
Reference to the current solution at the current quadrature point.
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)

Member Function Documentation

◆ baseParams()

template<class G >
InputParameters TotalLagrangianStressDivergenceBaseS< G >::baseParams ( )
staticinherited

Definition at line 14 of file TotalLagrangianStressDivergenceBaseS.C.

Referenced by TotalLagrangianStressDivergenceBaseS< G >::validParams().

15 {
17  // This kernel requires use_displaced_mesh to be off
18  params.suppressParameter<bool>("use_displaced_mesh");
19  return params;
20 }
void suppressParameter(const std::string &name)

◆ computeOffDiagJacobianScalarLocal()

void HomogenizedTotalLagrangianStressDivergenceA::computeOffDiagJacobianScalarLocal ( const unsigned int  svar_num)
overrideprotectedvirtual

Method for computing an off-diagonal jacobian component d-_var-residual / d-svar.

svar is looped over all scalar variables, which herein is just _kappa and _kappa_other

Definition at line 295 of file HomogenizedTotalLagrangianStressDivergenceA.C.

297 {
298  // Assembly J_beta_alpha ONLY
299  if (svar_num == _kappa_var)
300  {
301  _local_ke.resize(_test.size(), _k_order);
302 
303  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
304  {
305  // single index for Jacobian row; double indices for constraint tensor component
306  unsigned int l = 0;
307  Real dV = _JxW[_qp] * _coord[_qp];
308  for (auto && [indices, constraint] : _cmap)
309  {
310  // identical logic to computeScalarResidual, but for column index
311  if (_beta == 0)
312  {
313  if (l == 1)
314  break;
315  }
316  else
317  {
318  if (l == 0)
319  {
320  l++;
321  continue;
322  }
323  }
324  // copy constraint indices to protected variables to pass to Qp routine
325  _m = indices.first;
326  _n = indices.second;
327  _ctype = constraint.first;
328  initScalarQpJacobian(svar_num);
329  for (_i = 0; _i < _test.size(); _i++)
330  {
331  _local_ke(_i, -_beta + l) += dV * computeQpOffDiagJacobianScalar(svar_num);
332  }
333  l++;
334  }
335  }
336 
337  addJacobian(_assembly,
338  _local_ke,
339  _var.dofIndices(),
340  _kappa_var_ptr->dofIndices(),
341  _var.scalingFactor());
342  }
343 }
HomogenizationA::ConstraintMap _cmap
Type of each constraint (stress or strain) for each component.
const unsigned int _beta
Which component of the scalar vector residual this constraint is responsible for. ...
HomogenizationA::ConstraintType _ctype
The constraint type; initialize with &#39;none&#39;.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int _m
Used internally to iterate over each scalar component.
virtual Real computeQpOffDiagJacobianScalar(const unsigned int svar_num) override
Method for computing d-_var-residual / d-_svar at quadrature points.

◆ computeQpJacobian()

Real LagrangianStressDivergenceBaseS::computeQpJacobian ( )
overrideprotectedvirtualinherited

Definition at line 115 of file LagrangianStressDivergenceBaseS.C.

116 {
118 }
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

◆ computeQpJacobianDisplacement()

Real HomogenizedTotalLagrangianStressDivergenceA::computeQpJacobianDisplacement ( unsigned int  alpha,
unsigned int  beta 
)
overrideprotectedvirtual

Reimplemented from TotalLagrangianStressDivergenceBaseS< G >.

Definition at line 88 of file HomogenizedTotalLagrangianStressDivergenceA.C.

90 {
91  // Assemble J-alpha-beta if _beta==0
92  if (_beta == 0)
93  return gradTest(alpha).doubleContraction(_dpk1[_qp] * gradTrial(beta));
94  else
95  return 0.0;
96 }
const unsigned int _beta
Which component of the scalar vector residual this constraint is responsible for. ...
virtual RankTwoTensor gradTest(unsigned int component) override
Real doubleContraction(const RankTwoTensorTempl< Real > &a) const
static const std::string alpha
Definition: NS.h:134
const MaterialProperty< RankFourTensor > & _dpk1
The derivative of the PK1 stress with respect to the deformation gradient.
virtual RankTwoTensor gradTrial(unsigned int component) override

◆ computeQpJacobianOutOfPlaneStrain()

template<class G >
Real TotalLagrangianStressDivergenceBaseS< G >::computeQpJacobianOutOfPlaneStrain ( )
overrideprotectedvirtualinherited

Implements LagrangianStressDivergenceBaseS.

Definition at line 128 of file TotalLagrangianStressDivergenceBaseS.C.

129 {
130  return _dpk1[_qp].contractionKl(2, 2, gradTest(_alpha)) * _out_of_plane_strain->phi()[_j][_qp];
131 }
const unsigned int _alpha
Which component of the vector residual this kernel is responsible for.
const MooseVariable * _out_of_plane_strain
Out-of-plane strain, if provided.
const FieldVariablePhiValue & phi() const override
virtual RankTwoTensor gradTest(unsigned int component) override
const MaterialProperty< RankFourTensor > & _dpk1
The derivative of the PK1 stress with respect to the deformation gradient.

◆ computeQpJacobianTemperature()

template<class G >
Real TotalLagrangianStressDivergenceBaseS< G >::computeQpJacobianTemperature ( unsigned int  cvar)
overrideprotectedvirtualinherited

Implements LagrangianStressDivergenceBaseS.

Definition at line 110 of file TotalLagrangianStressDivergenceBaseS.C.

111 {
112  usingTensorIndices(i_, j_, k_, l_);
113  // Multiple eigenstrains may depend on the same coupled var
114  RankTwoTensor total_deigen;
115  for (const auto deigen_darg : _deigenstrain_dargs[cvar])
116  total_deigen += (*deigen_darg)[_qp];
117 
118  const auto A = _f_inv[_qp].inverse();
119  const auto B = _F_inv[_qp].inverse();
120  const auto U = 0.5 * (A.template times<i_, k_, l_, j_>(B) + A.template times<i_, l_, k_, j_>(B));
121 
122  return -(_dpk1[_qp] * U * total_deigen).doubleContraction(gradTest(_alpha)) *
123  _temperature->phi()[_j][_qp];
124 }
const MooseVariable * _temperature
Temperature, if provided. This is used only to get the trial functions.
const unsigned int _alpha
Which component of the vector residual this kernel is responsible for.
const MaterialProperty< RankTwoTensor > & _f_inv
The inverse increment deformation gradient.
const FieldVariablePhiValue & phi() const override
virtual RankTwoTensor gradTest(unsigned int component) override
std::vector< std::vector< const MaterialProperty< RankTwoTensor > * > > _deigenstrain_dargs
Eigenstrain derivatives wrt generate coupleds.
const MaterialProperty< RankTwoTensor > & _F_inv
The inverse deformation gradient.
const MaterialProperty< RankFourTensor > & _dpk1
The derivative of the PK1 stress with respect to the deformation gradient.

◆ computeQpOffDiagJacobian()

Real LagrangianStressDivergenceBaseS::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtualinherited

Definition at line 121 of file LagrangianStressDivergenceBaseS.C.

122 {
123  // Bail if jvar not coupled
124  if (getJvarMap()[jvar] < 0)
125  return 0.0;
126 
127  // Off diagonal terms for other displacements
128  for (auto beta : make_range(_ndisp))
129  if (jvar == _disp_nums[beta])
131 
132  // Off diagonal temperature term due to eigenstrain
133  if (_temperature && jvar == _temperature->number())
135 
136  // Off diagonal term due to weak plane stress
139 
140  return 0;
141 }
const MooseVariable * _temperature
Temperature, if provided. This is used only to get the trial functions.
std::vector< unsigned int > _disp_nums
The displacement numbers.
const unsigned int _alpha
Which component of the vector residual this kernel is responsible for.
unsigned int number() const
const MooseVariable * _out_of_plane_strain
Out-of-plane strain, if provided.
const unsigned int _ndisp
Total number of displacements/size of residual vector.
virtual Real computeQpJacobianOutOfPlaneStrain()=0
virtual Real computeQpJacobianDisplacement(unsigned int alpha, unsigned int beta)=0
virtual Real computeQpJacobianTemperature(unsigned int cvar)=0
IntRange< T > make_range(T beg, T end)

◆ computeQpOffDiagJacobianScalar()

Real HomogenizedTotalLagrangianStressDivergenceA::computeQpOffDiagJacobianScalar ( const unsigned int  svar_num)
overrideprotectedvirtual

Method for computing d-_var-residual / d-_svar at quadrature points.

Definition at line 346 of file HomogenizedTotalLagrangianStressDivergenceA.C.

Referenced by computeOffDiagJacobianScalarLocal().

347 {
348  if (svar_num == _kappa_var)
349  return _dpk1[_qp].contractionKl(_m, _n, gradTest(_alpha));
350  else
351  return 0.;
352 }
const unsigned int _alpha
Which component of the vector residual this kernel is responsible for.
virtual RankTwoTensor gradTest(unsigned int component) override
unsigned int _m
Used internally to iterate over each scalar component.
const MaterialProperty< RankFourTensor > & _dpk1
The derivative of the PK1 stress with respect to the deformation gradient.

◆ computeQpResidual()

Real HomogenizedTotalLagrangianStressDivergenceA::computeQpResidual ( )
overrideprotectedvirtual

Reimplemented from TotalLagrangianStressDivergenceBaseS< G >.

Definition at line 78 of file HomogenizedTotalLagrangianStressDivergenceA.C.

79 {
80  // Assemble R_alpha if _beta==0
81  if (_beta == 0)
82  return gradTest(_alpha).doubleContraction(_pk1[_qp]);
83  else
84  return 0.0;
85 }
const unsigned int _alpha
Which component of the vector residual this kernel is responsible for.
const unsigned int _beta
Which component of the scalar vector residual this constraint is responsible for. ...
virtual RankTwoTensor gradTest(unsigned int component) override
Real doubleContraction(const RankTwoTensorTempl< Real > &a) const
const MaterialProperty< RankTwoTensor > & _pk1
The 1st Piola-Kirchhoff stress.

◆ computeScalarJacobian()

void HomogenizedTotalLagrangianStressDivergenceA::computeScalarJacobian ( )
overrideprotectedvirtual

Method for computing the scalar variable part of Jacobian for d-_kappa-residual / d-_kappa.

Definition at line 165 of file HomogenizedTotalLagrangianStressDivergenceA.C.

166 {
167  _local_ke.resize(_k_order, _k_order);
168 
169  // Assemble J_beta_beta if _alpha==0
170  if (_alpha == 0)
171  {
172  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
173  {
174  initScalarQpJacobian(_kappa_var);
175  Real dV = _JxW[_qp] * _coord[_qp];
176 
177  _h = 0;
178  for (auto && [indices1, constraint1] : _cmap)
179  {
180  auto && [i, j] = indices1;
181  auto && ctype = constraint1.first;
182 
183  // identical logic to computeScalarResidual
184  if (_beta == 0)
185  {
186  if (_h == 1)
187  break;
188  }
189  else
190  {
191  if (_h == 0)
192  {
193  _h++;
194  continue;
195  }
196  }
197 
198  _l = 0;
199  for (auto && indices2 : _cmap)
200  {
201  auto && [a, b] = indices2.first;
202 
203  // identical logic to computeScalarResidual, but for column index
204  if (_beta == 0)
205  {
206  if (_l == 1)
207  break;
208  }
209  else
210  {
211  if (_l == 0)
212  {
213  _l++;
214  continue;
215  }
216  }
217 
218  unsigned int c_ind = -_beta + _l; // move 1 column left if _beta=1 for the other scalar
219  _l++; // increment the index before we forget
221  _local_ke(-_beta + _h, c_ind) += dV * (_dpk1[_qp](i, j, a, b));
222  else if (ctype == HomogenizationA::ConstraintType::Strain)
223  {
224  if (_large_kinematics)
225  _local_ke(-_beta + _h, c_ind) += dV * (Real(i == a && j == b));
226  else
227  _local_ke(-_beta + _h, c_ind) +=
228  dV * (0.5 * Real(i == a && j == b) + 0.5 * Real(i == b && j == a));
229  }
230  else
231  mooseError("Unknown constraint type in Jacobian calculator!");
232  }
233  _h++;
234  }
235  }
236  }
237 
238  addJacobian(_assembly,
239  _local_ke,
240  _kappa_var_ptr->dofIndices(),
241  _kappa_var_ptr->dofIndices(),
242  _kappa_var_ptr->scalingFactor());
243 }
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)
HomogenizationA::ConstraintMap _cmap
Type of each constraint (stress or strain) for each component.
const unsigned int _beta
Which component of the scalar vector residual this constraint is responsible for. ...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const MaterialProperty< RankFourTensor > & _dpk1
The derivative of the PK1 stress with respect to the deformation gradient.

◆ computeScalarOffDiagJacobian()

void HomogenizedTotalLagrangianStressDivergenceA::computeScalarOffDiagJacobian ( const unsigned int  jvar_num)
overrideprotectedvirtual

Method for computing an off-diagonal jacobian component d-_kappa-residual / d-jvar jvar is looped over all field variables, which herein is just disp_x and disp_y.

Definition at line 246 of file HomogenizedTotalLagrangianStressDivergenceA.C.

248 {
249  // Assembly J_alpha_beta ONLY
250  if (jvar_num == _var.number())
251  {
252  _local_ke.resize(_k_order, _test.size());
253 
254  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
255  {
256  // single index for Jacobian column; double indices for constraint tensor component
257  unsigned int h = 0;
258  Real dV = _JxW[_qp] * _coord[_qp];
259  for (auto && [indices, constraint] : _cmap)
260  {
261  // identical logic to computeScalarResidual
262  if (_beta == 0)
263  {
264  if (h == 1)
265  break;
266  }
267  else
268  {
269  if (h == 0)
270  {
271  h++;
272  continue;
273  }
274  }
275  // copy constraint indices to protected variables to pass to Qp routine
276  _m = indices.first;
277  _n = indices.second;
278  _ctype = constraint.first;
279  initScalarQpOffDiagJacobian(_var);
280  for (_j = 0; _j < _test.size(); _j++)
281  _local_ke(-_beta + h, _j) += dV * computeScalarQpOffDiagJacobian(jvar_num);
282  h++;
283  }
284  }
285 
286  addJacobian(_assembly,
287  _local_ke,
288  _kappa_var_ptr->dofIndices(),
289  _var.dofIndices(),
290  _kappa_var_ptr->scalingFactor());
291  }
292 }
virtual Real computeScalarQpOffDiagJacobian(const unsigned int jvar_num) override
Method for computing an off-diagonal jacobian component at quadrature points.
HomogenizationA::ConstraintMap _cmap
Type of each constraint (stress or strain) for each component.
const unsigned int _beta
Which component of the scalar vector residual this constraint is responsible for. ...
HomogenizationA::ConstraintType _ctype
The constraint type; initialize with &#39;none&#39;.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int _m
Used internally to iterate over each scalar component.

◆ computeScalarOffDiagJacobianScalar()

void HomogenizedTotalLagrangianStressDivergenceA::computeScalarOffDiagJacobianScalar ( const unsigned int  svar_num)
overrideprotectedvirtual

Method for computing an off-diagonal jacobian component d-_kappa-residual / d-svar svar is looped over other scalar variables, which herein is just _kappa_other.

Definition at line 375 of file HomogenizedTotalLagrangianStressDivergenceA.C.

377 {
378  // Only do this for the other macro variable
379  if (svar_num == _kappao_var)
380  {
381  _local_ke.resize(_k_order, _ko_order);
382 
383  // Assemble J-kappa-kappa_other if _alpha==0
384  if (_alpha == 0)
385  {
386  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
387  {
388  initScalarQpJacobian(_kappa_var);
389  Real dV = _JxW[_qp] * _coord[_qp];
390 
391  _h = 0;
392  for (auto && [indices1, constraint1] : _cmap)
393  {
394  auto && [i, j] = indices1;
395  auto && ctype = constraint1.first;
396 
397  // identical logic to computeScalarResidual
398  if (_beta == 0)
399  {
400  if (_h == 1)
401  break;
402  }
403  else
404  {
405  if (_h == 0)
406  {
407  _h++;
408  continue;
409  }
410  }
411 
412  _l = 0;
413  for (auto && indices2 : _cmap)
414  {
415  auto && [a, b] = indices2.first;
416 
417  // OPPOSITE logic/scalar from computeScalarResidual, AND for column index
418  if (_beta == 1)
419  {
420  if (_l == 1) // only assemble first=0 component of _hvar, then break the loop
421  break;
422  }
423  else
424  {
425  if (_l == 0) // skip first component (_hvar) & continue to "first" component of _avar
426  {
427  _l++;
428  continue;
429  }
430  }
431 
432  unsigned int c_ind =
433  -(1 - _beta) + _l; // DON'T move 1 column left if _beta=1 for the other scalar
434  _l++;
436  _local_ke(-_beta + _h, c_ind) += dV * (_dpk1[_qp](i, j, a, b));
437  else if (ctype == HomogenizationA::ConstraintType::Strain)
438  {
439  if (_large_kinematics)
440  _local_ke(-_beta + _h, c_ind) += dV * (Real(i == a && j == b));
441  else
442  _local_ke(-_beta + _h, c_ind) +=
443  dV * (0.5 * Real(i == a && j == b) + 0.5 * Real(i == b && j == a));
444  }
445  else
446  mooseError("Unknown constraint type in Jacobian calculator!");
447  }
448  _h++;
449  }
450  }
451  }
452 
453  addJacobian(_assembly,
454  _local_ke,
455  _kappa_var_ptr->dofIndices(),
457  _kappa_var_ptr->scalingFactor());
458  }
459 }
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.
const unsigned int _ko_order
Order of the scalar variable, used in several places.
void mooseError(Args &&... args)
HomogenizationA::ConstraintMap _cmap
Type of each constraint (stress or strain) for each component.
const MooseVariableScalar *const _kappao_var_ptr
(Pointer to) Scalar variable this kernel operates on
const unsigned int _beta
Which component of the scalar vector residual this constraint is responsible for. ...
virtual const std::vector< dof_id_type > & dofIndices() const
const unsigned int _kappao_var
The unknown scalar variable ID.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const MaterialProperty< RankFourTensor > & _dpk1
The derivative of the PK1 stress with respect to the deformation gradient.

◆ computeScalarQpOffDiagJacobian()

Real HomogenizedTotalLagrangianStressDivergenceA::computeScalarQpOffDiagJacobian ( const unsigned int  jvar_num)
overrideprotectedvirtual

Method for computing an off-diagonal jacobian component at quadrature points.

Definition at line 355 of file HomogenizedTotalLagrangianStressDivergenceA.C.

Referenced by computeScalarOffDiagJacobian().

356 {
357  if (jvar_num == _var.number())
358  {
360  return _dpk1[_qp].contractionIj(_m, _n, gradTrial(_alpha));
362  if (_large_kinematics)
363  return Real(_m == _alpha) * gradTrial(_alpha)(_m, _n);
364  else
365  return 0.5 * (Real(_m == _alpha) * gradTrial(_alpha)(_m, _n) +
366  Real(_n == _alpha) * gradTrial(_alpha)(_n, _m));
367  else
368  mooseError("Unknown constraint type in kernel calculation!");
369  }
370  else
371  return 0.;
372 }
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)
HomogenizationA::ConstraintType _ctype
The constraint type; initialize with &#39;none&#39;.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int _m
Used internally to iterate over each scalar component.
const MaterialProperty< RankFourTensor > & _dpk1
The derivative of the PK1 stress with respect to the deformation gradient.
virtual RankTwoTensor gradTrial(unsigned int component) override

◆ computeScalarResidual()

void HomogenizedTotalLagrangianStressDivergenceA::computeScalarResidual ( )
overrideprotectedvirtual

Method for computing the scalar part of residual for _kappa.

Definition at line 99 of file HomogenizedTotalLagrangianStressDivergenceA.C.

100 {
101  std::vector<Real> scalar_residuals(_k_order);
102 
103  // Assemble R_beta if _alpha==0
104  if (_alpha == 0)
105  {
106  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
107  {
108  initScalarQpResidual();
109  Real dV = _JxW[_qp] * _coord[_qp];
110  _h = 0; // single index for residual vector; double indices for constraint tensor component
111  for (auto && [indices, constraint] : _cmap)
112  {
113  auto && [i, j] = indices;
114  auto && [ctype, ctarget] = constraint;
115 
116  // ONLY the component(s) that this constraint will contribute here;
117  // other one is handled in the other constraint
118  if (_beta == 0)
119  {
120  if (_h == 1) // only assemble first=0 component of _hvar, then break the loop
121  break;
122  }
123  else
124  {
125  // skip the first component (_hvar) and continue to "first" component of _avar
126  if (_h == 0)
127  {
128  _h++;
129  continue;
130  }
131  }
132 
133  // I am not great with C++ precedence; so, store the index
134  unsigned int r_ind = -_beta + _h; // move 1 row up if _beta=1 for the other scalar
135  _h++; // increment the index before we forget
136  if (_large_kinematics)
137  {
139  scalar_residuals[r_ind] += dV * (_pk1[_qp](i, j) - ctarget->value(_t, _q_point[_qp]));
140  else if (ctype == HomogenizationA::ConstraintType::Strain)
141  scalar_residuals[r_ind] +=
142  dV * (_F[_qp](i, j) - (Real(i == j) + ctarget->value(_t, _q_point[_qp])));
143  else
144  mooseError("Unknown constraint type in the integral!");
145  }
146  else
147  {
149  scalar_residuals[r_ind] += dV * (_pk1[_qp](i, j) - ctarget->value(_t, _q_point[_qp]));
150  else if (ctype == HomogenizationA::ConstraintType::Strain)
151  scalar_residuals[r_ind] += dV * (0.5 * (_F[_qp](i, j) + _F[_qp](j, i)) -
152  (Real(i == j) + ctarget->value(_t, _q_point[_qp])));
153  else
154  mooseError("Unknown constraint type in the integral!");
155  }
156  }
157  }
158  }
159 
160  addResiduals(
161  _assembly, scalar_residuals, _kappa_var_ptr->dofIndices(), _kappa_var_ptr->scalingFactor());
162 }
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)
HomogenizationA::ConstraintMap _cmap
Type of each constraint (stress or strain) for each component.
const unsigned int _beta
Which component of the scalar vector residual this constraint is responsible for. ...
const MaterialProperty< RankTwoTensor > & _F
The actual (stabilized) deformation gradient.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const MaterialProperty< RankTwoTensor > & _pk1
The 1st Piola-Kirchhoff stress.

◆ gradTest()

template<class G >
RankTwoTensor TotalLagrangianStressDivergenceBaseS< G >::gradTest ( unsigned int  component)
overrideprotectedvirtualinherited

◆ gradTrial()

template<class G >
RankTwoTensor TotalLagrangianStressDivergenceBaseS< G >::gradTrial ( unsigned int  component)
overrideprotectedvirtualinherited

Implements LagrangianStressDivergenceBaseS.

Definition at line 41 of file TotalLagrangianStressDivergenceBaseS.C.

Referenced by HomogenizedTotalLagrangianStressDivergenceR::computeQpJacobianDisplacement(), computeQpJacobianDisplacement(), HomogenizedTotalLagrangianStressDivergenceS::computeScalarQpOffDiagJacobian(), HomogenizedTotalLagrangianStressDivergenceR::computeScalarQpOffDiagJacobian(), and computeScalarQpOffDiagJacobian().

42 {
44 }
static const std::string component
Definition: NS.h:153
virtual RankTwoTensor gradTrialUnstabilized(unsigned int component)
The unstabilized trial function gradient.
virtual RankTwoTensor gradTrialStabilized(unsigned int component)
The stabilized trial function gradient.
const bool _stabilize_strain
If true calculate the deformation gradient derivatives for F_bar.

◆ initialSetup() [1/4]

template<>
void TotalLagrangianStressDivergenceBaseS< GradientOperatorCartesian >::initialSetup ( )
inlineinherited

Definition at line 26 of file TotalLagrangianStressDivergenceS.h.

27 {
28  if (getBlockCoordSystem() != Moose::COORD_XYZ)
29  mooseError("This kernel should only act in Cartesian coordinates.");
30 }
void mooseError(Args &&... args)

◆ initialSetup() [2/4]

Definition at line 26 of file TotalLagrangianStressDivergenceCentrosymmetricSphericalS.h.

27 {
28  if (getBlockCoordSystem() != Moose::COORD_RSPHERICAL)
29  mooseError("This kernel should only act in centrosymmetric spherical coordinates.");
30 }
void mooseError(Args &&... args)
COORD_RSPHERICAL

◆ initialSetup() [3/4]

Definition at line 26 of file TotalLagrangianStressDivergenceAxisymmetricCylindricalS.h.

27 {
28  if (getBlockCoordSystem() != Moose::COORD_RZ)
29  mooseError("This kernel should only act in axisymmetric cylindrical coordinates.");
30 }
void mooseError(Args &&... args)

◆ initialSetup() [4/4]

template<class G >
virtual void TotalLagrangianStressDivergenceBaseS< G >::initialSetup ( )
overridevirtualinherited

◆ precalculateJacobian()

void LagrangianStressDivergenceBaseS::precalculateJacobian ( )
overrideprotectedvirtualinherited

Definition at line 85 of file LagrangianStressDivergenceBaseS.C.

86 {
87  // Skip if we are not doing stabilization
88  if (!_stabilize_strain)
89  return;
90 
91  // We need the gradients of shape functions in the reference frame
92  _fe_problem.prepareShapes(_var.number(), _tid);
93  _avg_grad_trial[_alpha].resize(_phi.size());
95 }
const unsigned int _alpha
Which component of the vector residual this kernel is responsible for.
const bool _stabilize_strain
If true calculate the deformation gradient derivatives for F_bar.
std::vector< std::vector< RankTwoTensor > > _avg_grad_trial
virtual void precalculateJacobianDisplacement(unsigned int component)=0
Prepare the average shape function gradients for stabilization.

◆ precalculateJacobianDisplacement()

template<class G >
void TotalLagrangianStressDivergenceBaseS< G >::precalculateJacobianDisplacement ( unsigned int  component)
overrideprotectedvirtualinherited

Prepare the average shape function gradients for stabilization.

Implements LagrangianStressDivergenceBaseS.

Definition at line 80 of file TotalLagrangianStressDivergenceBaseS.C.

81 {
82  // For total Lagrangian, the averaging is taken on the reference frame regardless of geometric
83  // nonlinearity. Convenient!
84  for (auto j : make_range(_phi.size()))
86  [this, component, j](unsigned int qp)
87  { return G::gradOp(component, _grad_phi[j][qp], _phi[j][qp], _q_point[qp]); },
88  _JxW,
89  _coord);
90 }
static const std::string component
Definition: NS.h:153
std::vector< std::vector< RankTwoTensor > > _avg_grad_trial
IntRange< T > make_range(T beg, T end)
auto elementAverage(const Functor &f, const MooseArray< Real > &JxW, const MooseArray< Real > &coord)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")

◆ precalculateOffDiagJacobian()

void LagrangianStressDivergenceBaseS::precalculateOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtualinherited

Definition at line 98 of file LagrangianStressDivergenceBaseS.C.

99 {
100  // Skip if we are not doing stabilization
101  if (!_stabilize_strain)
102  return;
103 
104  for (auto beta : make_range(_ndisp))
105  if (jvar == _disp_nums[beta])
106  {
107  // We need the gradients of shape functions in the reference frame
108  _fe_problem.prepareShapes(jvar, _tid);
109  _avg_grad_trial[beta].resize(_phi.size());
111  }
112 }
std::vector< unsigned int > _disp_nums
The displacement numbers.
const unsigned int _ndisp
Total number of displacements/size of residual vector.
const bool _stabilize_strain
If true calculate the deformation gradient derivatives for F_bar.
std::vector< std::vector< RankTwoTensor > > _avg_grad_trial
IntRange< T > make_range(T beg, T end)
virtual void precalculateJacobianDisplacement(unsigned int component)=0
Prepare the average shape function gradients for stabilization.

◆ validParams()

InputParameters HomogenizedTotalLagrangianStressDivergenceA::validParams ( )
static

Definition at line 25 of file HomogenizedTotalLagrangianStressDivergenceA.C.

26 {
28  params.addClassDescription("Total Lagrangian stress equilibrium kernel with "
29  "homogenization constraint Jacobian terms");
30  params.renameCoupledVar(
31  "scalar_variable", "macro_var", "Optional scalar field with the macro gradient");
32  params.addRequiredCoupledVar("macro_other", "Other components of coupled scalar variable");
33  params.addRequiredParam<unsigned int>("prime_scalar", "Either 0=_var or 1=_other scalar");
35  "constraint_types",
37  "Type of each constraint: strain, stress, or none. The types are specified in the "
38  "column-major order, and there must be 9 entries in total.");
39  params.addRequiredParam<std::vector<FunctionName>>(
40  "targets", "Functions giving the targets to hit for constraint types that are not none.");
41 
42  return params;
43 }
static InputParameters validParams()
void renameCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
void addRequiredParam(const std::string &name, const std::string &doc_string)
const MultiMooseEnum constraintType("strain stress none")
Moose constraint type, for input.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _a

unsigned int HomogenizedTotalLagrangianStressDivergenceA::_a
protected

◆ _alpha

const unsigned int LagrangianStressDivergenceBaseS::_alpha
protectedinherited

◆ _avg_grad_trial

std::vector<std::vector<RankTwoTensor> > LagrangianStressDivergenceBaseS::_avg_grad_trial
protectedinherited

◆ _b

unsigned int HomogenizedTotalLagrangianStressDivergenceA::_b
protected

◆ _base_name

const std::string LagrangianStressDivergenceBaseS::_base_name
protectedinherited

Prepend to the material properties.

Definition at line 69 of file LagrangianStressDivergenceBaseS.h.

◆ _beta

const unsigned int HomogenizedTotalLagrangianStressDivergenceA::_beta
protected

◆ _cmap

HomogenizationA::ConstraintMap HomogenizedTotalLagrangianStressDivergenceA::_cmap
protected

◆ _ctype

HomogenizationA::ConstraintType HomogenizedTotalLagrangianStressDivergenceA::_ctype = HomogenizationA::ConstraintType::None
protected

The constraint type; initialize with 'none'.

Definition at line 149 of file HomogenizedTotalLagrangianStressDivergenceA.h.

Referenced by computeOffDiagJacobianScalarLocal(), computeScalarOffDiagJacobian(), and computeScalarQpOffDiagJacobian().

◆ _deigenstrain_dargs

std::vector<std::vector<const MaterialProperty<RankTwoTensor> *> > LagrangianStressDivergenceBaseS::_deigenstrain_dargs
protectedinherited

Eigenstrain derivatives wrt generate coupleds.

Definition at line 107 of file LagrangianStressDivergenceBaseS.h.

Referenced by LagrangianStressDivergenceBaseS::LagrangianStressDivergenceBaseS().

◆ _disp_nums

std::vector<unsigned int> LagrangianStressDivergenceBaseS::_disp_nums
protectedinherited

◆ _dpk1

template<class G >
const MaterialProperty<RankFourTensor>& TotalLagrangianStressDivergenceBaseS< G >::_dpk1
protectedinherited

◆ _F

const MaterialProperty<RankTwoTensor>& LagrangianStressDivergenceBaseS::_F
protectedinherited

◆ _F_avg

const MaterialProperty<RankTwoTensor>& LagrangianStressDivergenceBaseS::_F_avg
protectedinherited

The element-average deformation gradient.

Definition at line 89 of file LagrangianStressDivergenceBaseS.h.

◆ _f_inv

const MaterialProperty<RankTwoTensor>& LagrangianStressDivergenceBaseS::_f_inv
protectedinherited

The inverse increment deformation gradient.

Definition at line 92 of file LagrangianStressDivergenceBaseS.h.

◆ _F_inv

const MaterialProperty<RankTwoTensor>& LagrangianStressDivergenceBaseS::_F_inv
protectedinherited

The inverse deformation gradient.

Definition at line 95 of file LagrangianStressDivergenceBaseS.h.

◆ _F_ust

const MaterialProperty<RankTwoTensor>& LagrangianStressDivergenceBaseS::_F_ust
protectedinherited

The unmodified deformation gradient.

Definition at line 86 of file LagrangianStressDivergenceBaseS.h.

◆ _kappa_other

const VariableValue& HomogenizedTotalLagrangianStressDivergenceA::_kappa_other
protected

Reference to the current solution at the current quadrature point.

Definition at line 143 of file HomogenizedTotalLagrangianStressDivergenceA.h.

◆ _kappao_var

const unsigned int HomogenizedTotalLagrangianStressDivergenceA::_kappao_var
protected

The unknown scalar variable ID.

Definition at line 137 of file HomogenizedTotalLagrangianStressDivergenceA.h.

Referenced by computeScalarOffDiagJacobianScalar().

◆ _kappao_var_ptr

const MooseVariableScalar* const HomogenizedTotalLagrangianStressDivergenceA::_kappao_var_ptr
protected

(Pointer to) Scalar variable this kernel operates on

Definition at line 134 of file HomogenizedTotalLagrangianStressDivergenceA.h.

Referenced by computeScalarOffDiagJacobianScalar().

◆ _ko_order

const unsigned int HomogenizedTotalLagrangianStressDivergenceA::_ko_order
protected

Order of the scalar variable, used in several places.

Definition at line 140 of file HomogenizedTotalLagrangianStressDivergenceA.h.

Referenced by computeScalarOffDiagJacobianScalar().

◆ _large_kinematics

const bool LagrangianStressDivergenceBaseS::_large_kinematics
protectedinherited

◆ _m

unsigned int HomogenizedTotalLagrangianStressDivergenceA::_m
protected

◆ _n

unsigned int HomogenizedTotalLagrangianStressDivergenceA::_n
protected

◆ _ndisp

const unsigned int LagrangianStressDivergenceBaseS::_ndisp
protectedinherited

◆ _out_of_plane_strain

const MooseVariable* LagrangianStressDivergenceBaseS::_out_of_plane_strain
protectedinherited

Out-of-plane strain, if provided.

Definition at line 104 of file LagrangianStressDivergenceBaseS.h.

Referenced by LagrangianStressDivergenceBaseS::computeQpOffDiagJacobian().

◆ _pk1

template<class G >
const MaterialProperty<RankTwoTensor>& TotalLagrangianStressDivergenceBaseS< G >::_pk1
protectedinherited

◆ _stabilize_strain

const bool LagrangianStressDivergenceBaseS::_stabilize_strain
protectedinherited

If true calculate the deformation gradient derivatives for F_bar.

Definition at line 66 of file LagrangianStressDivergenceBaseS.h.

Referenced by LagrangianStressDivergenceBaseS::precalculateJacobian(), and LagrangianStressDivergenceBaseS::precalculateOffDiagJacobian().

◆ _temperature

const MooseVariable* LagrangianStressDivergenceBaseS::_temperature
protectedinherited

Temperature, if provided. This is used only to get the trial functions.

Definition at line 101 of file LagrangianStressDivergenceBaseS.h.

Referenced by LagrangianStressDivergenceBaseS::computeQpOffDiagJacobian().


The documentation for this class was generated from the following files: