103{
104
105 const std::string uo_name =
_name +
"_GeneralizedPlaneStrainUserObject";
106
108 {
109 std::set<SubdomainID> block_ids;
111 for (
const auto & block :
getParam<
std::vector<SubdomainName>>(
"block"))
112 {
113 const auto id =
_mesh->getSubdomainID(block);
115 paramError(
"block",
"Subdomain '", block,
"' was not found in the mesh");
116 block_ids.insert(id);
117 }
118
119 const auto & subdomains = block_ids.empty() ?
_problem->mesh().meshSubdomains() : block_ids;
120 if (subdomains.empty())
121 mooseError(
"No subdomains found for the generalized plane strain action");
122
123 const auto coord_system =
_problem->getCoordSystem(*subdomains.begin());
124 for (const auto subdomain : subdomains)
125 if (
_problem->getCoordSystem(subdomain) != coord_system)
127 "Generalized plane strain requires all selected subdomains to use the same "
128 "coordinate system");
129
131 {
134 "One radial displacement is required for 1D axisymmetric generalized plane "
135 "strain");
136 }
138 {
140 if (
_ndisp != required_displacements)
142 required_displacements,
143 " displacement variables are required when the out-of-plane direction is ",
144 getParam<MooseEnum>("out_of_plane_direction"));
145 }
146 else
148 "Generalized plane strain supports only Cartesian and axisymmetric coordinate "
149 "systems");
150
152 const auto & first_in_plane_variable =
_problem->getVariable(
153 0,
_displacements[first_in_plane_disp], Moose::VarKindType::VAR_SOLVER);
154 const auto solver_sys_num = first_in_plane_variable.sys().number();
155 if (!
_problem->isSolverSystemNonlinear(solver_sys_num))
156 paramError(
"displacements",
"The in-plane displacements must be nonlinear variables");
157
158 for (
unsigned int i = 0; i <
_ndisp; ++i)
161 .sys()
162 .number() != solver_sys_num)
164 "All in-plane displacements must belong to the same nonlinear system");
165
166 auto & nonlinear_system =
_problem->getNonlinearSystemBase(solver_sys_num);
167 const auto & scalar_variable = getParam<VariableName>("scalar_out_of_plane_strain");
168 if (nonlinear_system.hasScalarVariable(scalar_variable))
169 return;
170 if (
_problem->hasScalarVariable(scalar_variable))
172 "Variable '",
173 scalar_variable,
174 "' already exists but is not a nonlinear scalar variable in system '",
175 nonlinear_system.name(),
176 "'");
177 if (
_problem->hasVariable(scalar_variable))
179 "Variable '",
180 scalar_variable,
181 "' already exists as a field variable; a scalar variable is required");
182
186 params.
set<SolverSystemName>(
"solver_sys") = nonlinear_system.name();
187 _problem->addVariable(
"MooseVariableScalar", scalar_variable, params);
188 }
189
190
191
192
194 {
196 {
197 const std::string k_type = "ADGeneralizedPlaneStrain";
199
201 params.
set<std::vector<VariableName>>(
"scalar_out_of_plane_strain") = {
202 getParam<VariableName>("scalar_out_of_plane_strain")};
203
204
205
207 {
210 "Cannot specify both 'out_of_plane_pressure_function' and "
211 "'out_of_plane_pressure'");
212 params.
set<FunctionName>(
"out_of_plane_pressure_function") =
213 getParam<FunctionName>("out_of_plane_pressure");
214 }
216 {
218 paramError(
"pressure_factor",
"Cannot specify both 'pressure_factor' and 'factor'");
219 params.
set<
Real>(
"pressure_factor") = getParam<Real>(
"factor");
220 }
221
223 params.
set<NonlinearVariableName>(
"variable") =
_displacements[first_in_plane_disp];
224 _problem->addKernel(k_type,
_name +
"_ADGeneralizedPlaneStrain", params);
225 }
226 else
227 {
228 std::string k_type = "GeneralizedPlaneStrainOffDiag";
230
232 params.
set<std::vector<VariableName>>(
"scalar_out_of_plane_strain") = {
233 getParam<VariableName>("scalar_out_of_plane_strain")};
234
235
236 for (
unsigned int i = 0; i <
_ndisp; ++i)
237 {
239 continue;
240
243
244 _problem->addKernel(k_type, k_name, params);
245 }
246
247
249 {
250 auto temp = getParam<std::vector<VariableName>>("temperature");
251 if (temp.size() > 1)
252 mooseError(
"Only one variable may be specified in 'temperature'");
253 if (
_problem->getNonlinearSystemBase(0).hasVariable(temp[0]))
254 {
255 std::string k_name =
_name +
"_GeneralizedPlaneStrainOffDiag_temp";
256 params.
set<NonlinearVariableName>(
"variable") = temp[0];
257
258 _problem->addKernel(k_type, k_name, params);
259 }
260 }
261 }
262 }
263
264
265
266
268 {
269
270
272 {
273 std::string uo_type = "GeneralizedPlaneStrainUserObject";
275
276
277
278
279
282 {"out_of_plane_pressure", "out_of_plane_pressure_function", "factor", "pressure_factor"});
284 params.
set<FunctionName>(
"out_of_plane_pressure") =
285 getParam<FunctionName>("out_of_plane_pressure");
287 params.
set<FunctionName>(
"out_of_plane_pressure_function") =
288 getParam<FunctionName>("out_of_plane_pressure_function");
290 params.
set<
Real>(
"factor") = getParam<Real>(
"factor");
292 params.
set<
Real>(
"pressure_factor") = getParam<Real>(
"pressure_factor");
293
294 _problem->addUserObject(uo_type, uo_name, params);
295 }
296 }
297
298
299
300
302 {
303
304
306 {
307 std::string sk_type = "GeneralizedPlaneStrain";
309
310 params.
set<NonlinearVariableName>(
"variable") =
311 getParam<VariableName>("scalar_out_of_plane_strain");
312
313
314 params.
set<UserObjectName>(
"generalized_plane_strain") = uo_name;
315
317 params.
set<std::vector<TagName>>(
"extra_vector_tags") =
318 getParam<std::vector<TagName>>("extra_vector_tags");
320 params.
set<std::vector<TagName>>(
"absolute_value_vector_tags") =
321 getParam<std::vector<TagName>>("absolute_value_vector_tags");
322
323 _problem->addScalarKernel(sk_type,
_name +
"_GeneralizedPlaneStrain", params);
324 }
325 }
326}
std::shared_ptr< MooseMesh > & _mesh
std::shared_ptr< FEProblemBase > & _problem
const std::string & _current_task
InputParameters getValidParams(const std::string &name) const
unsigned int firstInPlaneDisplacementIndex() const
Return the first displacement component in the plane.
const InputParameters & parameters() const
void paramError(const std::string ¶m, Args... args) const
bool isParamSetByUser(const std::string &name) const
void mooseError(Args &&... args) const
const std::string & _name
bool isParamValid(const std::string &name) const
std::string stringify(const T &t)
const SubdomainID INVALID_BLOCK_ID
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real