https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GeneralizedPlaneStrainUserObject.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#include "RankTwoTensor.h"
12#include "RankFourTensor.h"
13#include "Function.h"
14#include "Assembly.h"
15#include "UserObjectInterface.h"
16
17#include "libmesh/quadrature.h"
18
20
23{
26 "Generalized plane strain UserObject to provide residual and diagonal Jacobian entries.");
27 params.addParam<UserObjectName>("subblock_index_provider",
28 "SubblockIndexProvider user object name");
29 params.addParam<FunctionName>("out_of_plane_pressure_function",
30 "Function used to prescribe pressure (applied toward the body) in "
31 "the out-of-plane direction");
32 params.addDeprecatedParam<FunctionName>(
33 "out_of_plane_pressure",
34 "Function used to prescribe pressure (applied toward the body) in the out-of-plane direction "
35 "(y for 1D Axisymmetric or z for 2D Cartesian problems)",
36 "This has been replaced by 'out_of_plane_pressure_function'");
37 params.addParam<MaterialPropertyName>("out_of_plane_pressure_material",
38 "0",
39 "Material used to prescribe pressure (applied toward the "
40 "body) in the out-of-plane direction");
41 MooseEnum outOfPlaneDirection("x y z", "z");
42 params.addParam<MooseEnum>(
43 "out_of_plane_direction", outOfPlaneDirection, "The direction of the out-of-plane strain.");
44 params.addDeprecatedParam<Real>(
45 "factor",
46 "Scale factor applied to prescribed out-of-plane pressure (both material and function)",
47 "This has been replaced by 'pressure_factor'");
48 params.addParam<Real>(
49 "pressure_factor",
50 "Scale factor applied to prescribed out-of-plane pressure (both material and function)");
51 params.addParam<std::string>("base_name", "Material properties base name");
52 params.set<ExecFlagEnum>("execute_on") = {EXEC_LINEAR, EXEC_NONLINEAR};
53
54 return params;
55}
56
58 const InputParameters & parameters)
59 : ElementUserObject(parameters),
60 _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
61 _Jacobian_mult(getMaterialProperty<RankFourTensor>(_base_name + "Jacobian_mult")),
62 _stress(getMaterialProperty<RankTwoTensor>(_base_name + "stress")),
63 _subblock_id_provider(nullptr),
64 _out_of_plane_pressure_function(parameters.isParamSetByUser("out_of_plane_pressure_function")
65 ? &getFunction("out_of_plane_pressure_function")
66 : parameters.isParamSetByUser("out_of_plane_pressure")
67 ? &getFunction("out_of_plane_pressure")
68 : nullptr),
69 _out_of_plane_pressure_material(getMaterialProperty<Real>("out_of_plane_pressure_material")),
70 _pressure_factor(parameters.isParamSetByUser("pressure_factor")
71 ? getParam<Real>("pressure_factor")
72 : parameters.isParamSetByUser("factor") ? getParam<Real>("factor")
73 : 1.0)
74{
75 if (parameters.isParamSetByUser("out_of_plane_pressure_function") &&
76 parameters.isParamSetByUser("out_of_plane_pressure"))
77 mooseError("Cannot specify both 'out_of_plane_pressure_function' and 'out_of_plane_pressure'");
78 if (parameters.isParamSetByUser("pressure_factor") && parameters.isParamSetByUser("factor"))
79 mooseError("Cannot specify both 'pressure_factor' and 'factor'");
80}
81
82void
84{
85 if (isParamValid("subblock_index_provider"))
86 _subblock_id_provider = &getUserObject<SubblockIndexProvider>("subblock_index_provider");
88 _scalar_out_of_plane_strain_direction = getParam<MooseEnum>("out_of_plane_direction");
91 else
92 mooseError("Unsupported coordinate system for generalized plane strain formulation");
93
95 _residual.assign(max_size, 0.0);
96 _reference_residual.assign(max_size, 0.0);
97 _jacobian.assign(max_size, 0.0);
98}
99
100void
102{
103 const unsigned int subblock_id =
105
106 for (unsigned int _qp = 0; _qp < _qrule->n_points(); _qp++)
107 {
108 const Real out_of_plane_pressure =
111 : 0.0) +
114
115 // residual, integral of stress_zz for COORD_XYZ
116 _residual[subblock_id] += _JxW[_qp] * _coord[_qp] *
119 out_of_plane_pressure);
120
121 _reference_residual[subblock_id] += std::abs(
122 _JxW[_qp] * _coord[_qp] *
124
125 // diagonal jacobian, integral of C(2, 2, 2, 2) for COORD_XYZ
126 _jacobian[subblock_id] += _JxW[_qp] * _coord[_qp] *
131 }
132}
133
134void
136{
137 const auto & gpsuo = static_cast<const GeneralizedPlaneStrainUserObject &>(uo);
138 for (unsigned int i = 0; i < _residual.size(); ++i)
139 {
140 _residual[i] += gpsuo._residual[i];
141 _reference_residual[i] += gpsuo._reference_residual[i];
142 _jacobian[i] += gpsuo._jacobian[i];
143 }
144}
145
146void
153
154Real
156{
157 if (_residual.size() <= scalar_var_id)
158 mooseError("Index out of bounds!");
159
160 return _residual[scalar_var_id];
161}
162
163Real
165{
166 // At startup, the GeneralizedPlaneStrainReferenceResidual class can ask for this value
167 // before it has been computed. Return 0.0 in this case. The only way size will stay
168 // zero is if initialize is never called.
169 if (_reference_residual.size() == 0)
170 return 0.0;
171
172 if (_residual.size() <= scalar_var_id)
173 mooseError("Index out of bounds!");
174
175 return _reference_residual[scalar_var_id];
176}
177
178Real
180{
181 if (_jacobian.size() <= scalar_var_id)
182 mooseError("Index out of bounds!");
183
184 return _jacobian[scalar_var_id];
185}
registerMooseObject("SolidMechanicsApp", GeneralizedPlaneStrainUserObject)
const ExecFlagType EXEC_LINEAR
const ExecFlagType EXEC_NONLINEAR
const Moose::CoordinateSystemType & coordSystem() const
static InputParameters validParams()
const QBase *const & _qrule
const Elem *const & _current_elem
const MooseArray< Real > & _coord
const MooseArray< Real > & _JxW
const MooseArray< Point > & _q_point
virtual Real value(Real t, const Point &p) const
const MaterialProperty< Real > & _out_of_plane_pressure_material
Material property defining applied out-of-plane pressure.
GeneralizedPlaneStrainUserObject(const InputParameters &parameters)
const SubblockIndexProvider * _subblock_id_provider
A Userobject that carries the subblock ID for all elements.
const MaterialProperty< RankFourTensor > & _Jacobian_mult
virtual Real returnReferenceResidual(unsigned int scalar_var_id=0) const override
virtual Real returnJacobian(unsigned int scalar_var_id=0) const override
void threadJoin(const UserObject &uo) override
const Real _pressure_factor
Factor applied to out-of-plane pressure applied by function and material.
virtual Real returnResidual(unsigned int scalar_var_id=0) const override
unsigned int _scalar_out_of_plane_strain_direction
The direction of the out-of-plane strain scalar variable.
const MaterialProperty< RankTwoTensor > & _stress
The stress tensor.
const Function * _out_of_plane_pressure_function
Function defining applied out-of-plane pressure.
bool isParamSetByUser(const std::string &name) const
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
const InputParameters & parameters() const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
virtual unsigned int getMaxSubblockIndex() const =0
The max index of subblock.
virtual unsigned int getSubblockIndex(const Elem &) const =0
The index of subblock this element is on.
void gatherSum(T &value)
Assembly & _assembly