https://mooseframework.inl.gov
GeneralizedPlaneStrainOffDiag.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 
12 // MOOSE includes
13 #include "Assembly.h"
14 #include "Material.h"
15 #include "MooseVariable.h"
16 #include "MooseVariableScalar.h"
17 #include "RankTwoTensor.h"
18 #include "RankFourTensor.h"
19 #include "UserObject.h"
20 
21 #include "libmesh/quadrature.h"
22 
24 
27 {
29  params.addClassDescription("Generalized Plane Strain kernel to provide contribution of the "
30  "out-of-plane strain to other kernels");
31  params.addRequiredParam<std::vector<VariableName>>("displacements",
32  "Variable for the displacements");
33  params.addCoupledVar("temperature", "Variable for the temperature");
34 
35  params.addCoupledVar("scalar_out_of_plane_strain",
36  "Scalar variable for generalized plane strain");
37  MooseEnum outOfPlaneDirection("x y z", "z");
38  params.addParam<MooseEnum>(
39  "out_of_plane_direction", outOfPlaneDirection, "The direction of the out-of-plane strain.");
40  params.addParam<UserObjectName>("subblock_index_provider",
41  "SubblockIndexProvider user object name");
42  params.addParam<unsigned int>(
43  "scalar_out_of_plane_strain_index",
44  "The index number of scalar_out_of_plane_strain this kernel acts on");
45  params.addParam<std::string>("base_name", "Material property base name");
46  params.addParam<std::vector<MaterialPropertyName>>(
47  "eigenstrain_names", {}, "List of eigenstrains to be applied in this strain calculation");
48 
49  return params;
50 }
51 
53  : DerivativeMaterialInterface<Kernel>(parameters),
54  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
55  _Jacobian_mult(getMaterialProperty<RankFourTensor>(_base_name + "Jacobian_mult")),
56  _eigenstrain_names(getParam<std::vector<MaterialPropertyName>>("eigenstrain_names")),
57  _deigenstrain_dT(_eigenstrain_names.size()),
58  _scalar_out_of_plane_strain_var(coupledScalar("scalar_out_of_plane_strain")),
59  _subblock_id_provider(isParamValid("subblock_index_provider")
60  ? &getUserObject<SubblockIndexProvider>("subblock_index_provider")
61  : nullptr),
62  _scalar_var_id(isParamValid("scalar_out_of_plane_strain_index")
63  ? getParam<unsigned int>("scalar_out_of_plane_strain_index")
64  : 0),
65  _temp_var(isCoupled("temperature") ? getVar("temperature", 0) : nullptr),
66  _num_disp_var(getParam<std::vector<VariableName>>("displacements").size()),
67  _scalar_out_of_plane_strain_direction(getParam<MooseEnum>("out_of_plane_direction"))
68 {
69  const std::vector<VariableName> & nl_vnames(getParam<std::vector<VariableName>>("displacements"));
70 
72  mooseError("For 1D axisymmetric or 2D cartesian simulations where the out-of-plane direction "
73  "is z, the number of supplied displacements to GeneralizedPlaneStrainOffDiag must "
74  "be less than three.");
76  mooseError("For 2D cartesian simulations where the out-of-plane direction is x or y the number "
77  "of supplied displacements must be three.");
78 
79  for (unsigned int i = 0; i < _num_disp_var; ++i)
80  _disp_var.push_back(&_subproblem.getStandardVariable(_tid, nl_vnames[i]));
81 
82  for (unsigned int i = 0; i < _deigenstrain_dT.size(); ++i)
83  _deigenstrain_dT[i] = &getMaterialPropertyDerivative<RankTwoTensor>(
85 
86  if (isParamValid("scalar_variable_index_provider") &&
87  !isParamValid("scalar_out_of_plane_strain_index"))
88  paramError("scalar_out_of_plane_index",
89  "scalar_out_of_plane_strain_index should be provided if more "
90  "than one is available");
91  if (coupledComponents("temperature") > 1)
92  paramError("temperature", "Only one variable my be specified in 'temperature'");
93 }
94 
95 void
97 {
98  const unsigned int elem_scalar_var_id =
100 
101  if (elem_scalar_var_id == _scalar_var_id)
102  {
103  if (_assembly.coordSystem() == Moose::COORD_RZ)
105 
106  if (_var.number() == _disp_var[0]->number())
108  else if (_num_disp_var == 2 && _var.number() == _disp_var[1]->number())
110  else if (_temp_var && _var.number() == _temp_var->number())
112  }
113 }
114 
115 void
117  unsigned int jvar)
118 {
120  {
121  prepareMatrixTag(_assembly, _var.number(), jvar);
122  MooseVariableScalar & jv = _sys.getScalarVariable(_tid, jvar);
123 
124  // Set appropriate components for scalar kernels, including in the cases where a planar model is
125  // running in planes other than the x-y plane (defined by _out_of_plane_strain_direction).
127  component += 1;
128  else if (_scalar_out_of_plane_strain_direction == 1 && component == 1)
129  component += 1;
130 
131  for (_i = 0; _i < _test.size(); ++_i)
132  for (_j = 0; _j < jv.order(); ++_j)
133  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
134  _local_ke(_i, _j) += _JxW[_qp] * _coord[_qp] *
137  component,
138  component) *
139  _grad_test[_i][_qp](component);
140  accumulateTaggedLocalMatrix();
141  _ke_copy = _local_ke;
142 
143  prepareMatrixTag(_assembly, jvar, _var.number());
144  _ke_copy.get_transpose(_local_ke);
145  accumulateTaggedLocalMatrix();
146  }
147 }
148 
149 void
151 {
153  {
154  prepareMatrixTag(_assembly, _var.number(), jvar);
155  MooseVariableScalar & jv = _sys.getScalarVariable(_tid, jvar);
156  unsigned int n_eigenstrains = _deigenstrain_dT.size();
157 
158  for (_i = 0; _i < _test.size(); ++_i)
159  for (_j = 0; _j < jv.order(); ++_j)
160  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
161  for (unsigned int ies = 0; ies < n_eigenstrains; ++ies)
162  _local_ke(_i, _j) +=
163  _JxW[_qp] * _coord[_qp] *
164  (_Jacobian_mult[_qp] * (*_deigenstrain_dT[ies])[_qp])(
166  _test[_i][_qp];
167  accumulateTaggedLocalMatrix();
168  }
169 }
static InputParameters validParams()
const std::vector< MaterialPropertyName > _eigenstrain_names
unsigned int _scalar_out_of_plane_strain_var
Variable number of the out-of-plane strain scalar variable.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
GeneralizedPlaneStrainOffDiag(const InputParameters &parameters)
void mooseError(Args &&... args)
unsigned int number() const
static const std::string component
Definition: NS.h:153
Abstract base class for user objects that provide an index for a given element that is independent of...
const std::string & name() const override
const std::string _base_name
Base name of the material system that this kernel applies to.
void computeOffDiagJacobianScalar(unsigned int jvar) override
These methods are used to compute the off-diagonal jacobian for the coupling between scalar variable ...
virtual void computeDispOffDiagJacobianScalar(unsigned int component, unsigned int jvar)
void addRequiredParam(const std::string &name, const std::string &doc_string)
std::vector< MooseVariable * > _disp_var
DenseMatrix< Number > _ke_copy
Member variable to avoid constant dense matrix heap allocations.
void get_transpose(DenseMatrix< Number > &dest) const
std::vector< const MaterialProperty< RankTwoTensor > * > _deigenstrain_dT
virtual void computeTempOffDiagJacobianScalar(unsigned int jvar)
const SubblockIndexProvider *const _subblock_id_provider
A Userobject that carries the subblock ID for all elements.
void addCoupledVar(const std::string &name, const std::string &doc_string)
virtual unsigned int getSubblockIndex(const Elem &) const =0
The index of subblock this element is on.
const MaterialProperty< RankFourTensor > & _Jacobian_mult
void addClassDescription(const std::string &doc_string)
registerMooseObject("SolidMechanicsApp", GeneralizedPlaneStrainOffDiag)
void ErrorVector unsigned int
unsigned int _scalar_out_of_plane_strain_direction
The direction of the out-of-plane strain.