www.mooseframework.org
GeneralizedPlaneStrainOffDiag.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 // MOOSE includes
11 #include "Assembly.h"
12 #include "Material.h"
13 #include "MooseVariable.h"
14 #include "MooseVariableScalar.h"
15 #include "RankTwoTensor.h"
16 #include "RankFourTensor.h"
17 
18 #include "libmesh/quadrature.h"
19 
20 template <>
21 InputParameters
23 {
24  InputParameters params = validParams<Kernel>();
25  params.addClassDescription("Generalized Plane Strain kernel to provide contribution of the "
26  "out-of-plane strain to other kernels");
27  params.addRequiredParam<std::vector<NonlinearVariableName>>("displacements",
28  "Variable for the displacements");
29  params.addParam<NonlinearVariableName>("temperature", "Variable for the temperature");
30  params.addCoupledVar("scalar_out_of_plane_strain",
31  "Scalar variable for generalized plane strain");
32  params.addParam<UserObjectName>("subblock_index_provider",
33  "SubblockIndexProvider user object name");
34  params.addParam<unsigned int>(
35  "scalar_out_of_plane_strain_index",
36  "The index number of scalar_out_of_plane_strain this kernel acts on");
37  params.addParam<std::string>("base_name", "Material property base name");
38  params.addParam<std::vector<MaterialPropertyName>>(
39  "eigenstrain_names", "List of eigenstrains to be applied in this strain calculation");
40 
41  return params;
42 }
43 
45  : DerivativeMaterialInterface<Kernel>(parameters),
46  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
47  _Jacobian_mult(getMaterialProperty<RankFourTensor>(_base_name + "Jacobian_mult")),
48  _eigenstrain_names(getParam<std::vector<MaterialPropertyName>>("eigenstrain_names")),
49  _deigenstrain_dT(_eigenstrain_names.size()),
50  _scalar_out_of_plane_strain_var(coupledScalar("scalar_out_of_plane_strain")),
51  _subblock_id_provider(isParamValid("subblock_index_provider")
52  ? &getUserObject<SubblockIndexProvider>("subblock_index_provider")
53  : nullptr),
54  _scalar_var_id(isParamValid("scalar_out_of_plane_strain_index")
55  ? getParam<unsigned int>("scalar_out_of_plane_strain_index")
56  : 0),
57  _temp_var(isParamValid("temperature")
58  ? &_subproblem.getVariable(_tid, getParam<NonlinearVariableName>("temperature"))
59  : NULL),
60  _num_disp_var(getParam<std::vector<NonlinearVariableName>>("displacements").size())
61 {
62  const std::vector<NonlinearVariableName> & nl_vnames(
63  getParam<std::vector<NonlinearVariableName>>("displacements"));
64  if (_num_disp_var > 2)
65  mooseError("GeneralizedPlaneStrainOffDiag only works for 1D axisymmetric or 2D Cartesian "
66  "generalized plane strain cases!");
67 
68  for (unsigned int i = 0; i < _num_disp_var; ++i)
69  _disp_var.push_back(&_subproblem.getVariable(_tid, nl_vnames[i]));
70 
71  for (unsigned int i = 0; i < _deigenstrain_dT.size(); ++i)
72  _deigenstrain_dT[i] = &getMaterialPropertyDerivative<RankTwoTensor>(
74 
75  if (isParamValid("scalar_variable_index_provider") &&
76  !isParamValid("scalar_out_of_plane_strain_index"))
77  mooseError("scalar_out_of_plane_strain_index should be provided if more "
78  "than one is available");
79 }
80 
81 void
83 {
84  const unsigned int elem_scalar_var_id =
86 
87  if (elem_scalar_var_id == _scalar_var_id)
88  {
89  if (_assembly.coordSystem() == Moose::COORD_XYZ)
91  else if (_assembly.coordSystem() == Moose::COORD_RZ)
93 
94  if (_var.number() == _disp_var[0]->number())
96  else if (_num_disp_var == 2 && _var.number() == _disp_var[1]->number())
98  else if (isParamValid("temperature") ? _var.number() == _temp_var->number() : 0)
100  }
101 }
102 
103 void
105  unsigned int jvar)
106 {
108  {
109  DenseMatrix<Number> & ken = _assembly.jacobianBlock(_var.number(), jvar);
110  DenseMatrix<Number> & kne = _assembly.jacobianBlock(jvar, _var.number());
111  MooseVariableScalar & jv = _sys.getScalarVariable(_tid, jvar);
112 
113  for (_i = 0; _i < _test.size(); ++_i)
114  for (_j = 0; _j < jv.order(); ++_j)
115  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
116  {
117  ken(_i, _j) += _JxW[_qp] * _coord[_qp] *
120  component,
121  component) *
122  _grad_test[_i][_qp](component);
123  kne(_j, _i) += _JxW[_qp] * _coord[_qp] *
124  _Jacobian_mult[_qp](_scalar_out_of_plane_strain_direction,
126  component,
127  component) *
128  _grad_test[_i][_qp](component);
129  }
130  }
131 }
132 
133 void
135 {
137  {
138  DenseMatrix<Number> & kne = _assembly.jacobianBlock(jvar, _var.number());
139  MooseVariableScalar & jv = _sys.getScalarVariable(_tid, jvar);
140  unsigned int n_eigenstrains = _deigenstrain_dT.size();
141 
142  for (_i = 0; _i < _test.size(); ++_i)
143  for (_j = 0; _j < jv.order(); ++_j)
144  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
145  for (unsigned int ies = 0; ies < n_eigenstrains; ++ies)
146  kne(_j, _i) +=
147  _JxW[_qp] * _coord[_qp] *
148  (_Jacobian_mult[_qp] * (*_deigenstrain_dT[ies])[_qp])(
150  _test[_i][_qp];
151  }
152 }
const std::vector< MaterialPropertyName > _eigenstrain_names
GeneralizedPlaneStrainOffDiag(const InputParameters &parameters)
virtual unsigned int getSubblockIndex(const Elem &) const =0
The index of subblock this element is on.
Abstract base class for user objects that provide an index for a given element that is independent of...
Real component(const SymmTensor &symm_tensor, unsigned int index)
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)
std::vector< MooseVariable * > _disp_var
std::vector< const MaterialProperty< RankTwoTensor > * > _deigenstrain_dT
virtual void computeTempOffDiagJacobianScalar(unsigned int jvar)
InputParameters validParams< GeneralizedPlaneStrainOffDiag >()
const MaterialProperty< RankFourTensor > & _Jacobian_mult
const SubblockIndexProvider * _subblock_id_provider