https://mooseframework.inl.gov
HomogenizedTotalLagrangianStressDivergence.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.addClassDescription("Total Lagrangian stress equilibrium kernel with "
19  "homogenization constraint Jacobian terms");
20  params.addRequiredCoupledVar("macro_gradient", "Optional scalar field with the macro gradient");
21  params.addRequiredParam<UserObjectName>("homogenization_constraint",
22  "The UserObject defining the homogenization constraint");
23 
24  return params;
25 }
26 
28  const InputParameters & parameters)
29  : TotalLagrangianStressDivergence(parameters),
30  _macro_gradient_num(coupledScalar("macro_gradient")),
31  _constraint(getUserObject<HomogenizationConstraint>("homogenization_constraint")),
32  _cmap(_constraint.getConstraintMap())
33 {
34 }
35 
36 void
38 {
39  if (jvar == _macro_gradient_num)
40  {
41  prepareMatrixTag(_assembly, _var.number(), jvar, _ken);
42  prepareMatrixTag(_assembly, jvar, _var.number(), _kne);
43 
44  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
45  {
46  const Real dV = _JxW[_qp] * _coord[_qp];
47  unsigned int h = 0;
48  for (auto && [indices, constraint] : _cmap)
49  {
50  auto && [i, j] = indices;
51  auto && ctype = constraint.first;
52  for (_i = 0; _i < _test.size(); _i++)
53  {
54  // This assumes Galerkin, i.e. the test and trial functions are the same
55  _j = _i;
56 
57  // Base Jacobian
58  _ken(_i, h) += _dpk1[_qp].contractionKl(i, j, gradTest(_alpha)) * dV;
59 
60  // Constraint Jacobian
62  _kne(h, _i) += _dpk1[_qp].contractionIj(i, j, gradTrial(_alpha)) * dV;
65  _kne(h, _i) += Real(i == _alpha) * gradTrial(_alpha)(i, j) * dV;
66  else
67  _kne(h, _i) += 0.5 *
68  (Real(i == _alpha) * gradTrial(_alpha)(i, j) +
69  Real(j == _alpha) * gradTrial(_alpha)(j, i)) *
70  dV;
71  else
72  mooseError("Unknown constraint type in kernel calculation!");
73  }
74  h++;
75  }
76  }
77  accumulateTaggedLocalMatrix(_assembly, _var.number(), jvar, _ken);
78  accumulateTaggedLocalMatrix(_assembly, jvar, _var.number(), _kne);
79  }
80 }
const unsigned int _alpha
Which component of the vector residual this kernel is responsible for.
static InputParameters validParams()
void mooseError(Args &&... args)
DenseMatrix< Number > _kne
Derivatives of jvar with respect to ivar.
registerMooseObject("SolidMechanicsApp", HomogenizedTotalLagrangianStressDivergence)
void addRequiredParam(const std::string &name, const std::string &doc_string)
Computes ${V}(X_{ij}-{X}_{ij})dV$.
virtual RankTwoTensor gradTest(unsigned int component) override
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override
Homogenization constraint diagonal term.
const bool _large_kinematics
If true use large deformation kinematics.
DenseMatrix< Number > _ken
Derivatives of ivar with respect to jvar.
const Homogenization::ConstraintMap & _cmap
The constraint map.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
Total Lagrangian formulation with cross-jacobian homogenization terms.
const MaterialProperty< RankFourTensor > & _dpk1
The derivative of the PK1 stress with respect to the deformation gradient.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Enforce equilibrium with a total Lagrangian formulation.
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
HomogenizedTotalLagrangianStressDivergence(const InputParameters &parameters)
virtual RankTwoTensor gradTrial(unsigned int component) override
const unsigned int _macro_gradient_num
The scalar variable used to enforce the homogenization constraints.