www.mooseframework.org
GeneralizedPlaneStrainUserObject.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 /****************************************************************/
8 #include "RankTwoTensor.h"
9 #include "RankFourTensor.h"
10 #include "Function.h"
11 #include "Assembly.h"
12 
13 #include "libmesh/quadrature.h"
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<ElementUserObject>();
20  params.addClassDescription(
21  "Generalized Plane Strain UserObject to provide Residual and diagonal Jacobian entry");
22  params.addParam<UserObjectName>("subblock_index_provider",
23  "SubblockIndexProvider user object name");
24  params.addParam<FunctionName>(
25  "out_of_plane_pressure",
26  "0",
27  "Function used to prescribe pressure in the out-of-plane direction");
28  params.addParam<Real>("factor", 1.0, "Scale factor applied to prescribed pressure");
29  params.addParam<std::string>("base_name", "Material properties base name");
30  params.set<MultiMooseEnum>("execute_on") = "linear";
31 
32  return params;
33 }
34 
36  const InputParameters & parameters)
37  : ElementUserObject(parameters),
38  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
39  _Cijkl(getMaterialProperty<RankFourTensor>(_base_name + "elasticity_tensor")),
40  _stress(getMaterialProperty<RankTwoTensor>(_base_name + "stress")),
41  _subblock_id_provider(nullptr),
42  _out_of_plane_pressure(getFunction("out_of_plane_pressure")),
43  _factor(getParam<Real>("factor"))
44 {
45 }
46 
47 void
49 {
50  if (isParamValid("subblock_index_provider"))
51  _subblock_id_provider = &getUserObject<SubblockIndexProvider>("subblock_index_provider");
52  if (_assembly.coordSystem() == Moose::COORD_XYZ)
54  else if (_assembly.coordSystem() == Moose::COORD_RZ)
56  else
57  mooseError("Unsupported coordinate system for generalized plane strain formulation");
58 
59  unsigned int max_size = _subblock_id_provider ? _subblock_id_provider->getMaxSubblockIndex() : 1;
60  _residual.assign(max_size, 0.0);
61  _jacobian.assign(max_size, 0.0);
62 }
63 
64 void
66 {
67  const unsigned int subblock_id =
69 
70  for (unsigned int _qp = 0; _qp < _qrule->n_points(); _qp++)
71  {
72  // residual, integral of stress_zz for COORD_XYZ
73  _residual[subblock_id] +=
74  _JxW[_qp] * _coord[_qp] * (_stress[_qp](_scalar_out_of_plane_strain_direction,
76  _out_of_plane_pressure.value(_t, _q_point[_qp]) * _factor);
77  // diagonal jacobian, integral of C(2, 2, 2, 2) for COORD_XYZ
78  _jacobian[subblock_id] +=
79  _JxW[_qp] * _coord[_qp] * _Cijkl[_qp](_scalar_out_of_plane_strain_direction,
83  }
84 }
85 
86 void
88 {
89  const GeneralizedPlaneStrainUserObject & gpsuo =
90  static_cast<const GeneralizedPlaneStrainUserObject &>(uo);
91  for (unsigned int i = 0; i < _residual.size(); ++i)
92  {
93  _residual[i] += gpsuo._residual[i];
94  _jacobian[i] += gpsuo._jacobian[i];
95  }
96 }
97 
98 void
100 {
101  gatherSum(_residual);
102  gatherSum(_jacobian);
103 }
104 
105 Real
106 GeneralizedPlaneStrainUserObject::returnResidual(unsigned int scalar_var_id) const
107 {
108  if (_residual.size() < scalar_var_id)
109  mooseError("Index out of bounds!");
110 
111  return _residual[scalar_var_id];
112 }
113 
114 Real
115 GeneralizedPlaneStrainUserObject::returnJacobian(unsigned int scalar_var_id) const
116 {
117  if (_jacobian.size() < scalar_var_id)
118  mooseError("Index out of bounds!");
119 
120  return _jacobian[scalar_var_id];
121 }
const MaterialProperty< RankTwoTensor > & _stress
virtual Real returnJacobian(unsigned int scalar_var_id=0) const
void threadJoin(const UserObject &uo) override
virtual unsigned int getSubblockIndex(const Elem &) const =0
The index of subblock this element is on.
virtual Real returnResidual(unsigned int scalar_var_id=0) const
InputParameters validParams< GeneralizedPlaneStrainUserObject >()
const SubblockIndexProvider * _subblock_id_provider
virtual unsigned int getMaxSubblockIndex() const =0
The max index of subblock.
const MaterialProperty< RankFourTensor > & _Cijkl
GeneralizedPlaneStrainUserObject(const InputParameters &parameters)