12 #include "FEProblem.h"
13 #include "Conversion.h"
23 params.addRequiredParam<std::vector<BoundaryName>>(
24 "boundary",
"The list of boundary IDs from the mesh where the pressure will be applied");
25 params.addRequiredParam<std::vector<VariableName>>(
"displacements",
26 "The nonlinear displacement variables");
27 params.addParam<std::vector<AuxVariableName>>(
28 "save_in",
"Auxiliary variables to save the displacement residuals");
29 params.addParam<std::string>(
"output",
"The name to use for the cavity pressure value");
30 params.addParam<
bool>(
31 "use_displaced_mesh",
true,
"Whether to use displaced mesh in the boundary condition");
32 params.addParam<
bool>(
"use_automatic_differentiation",
34 "Flag to use automatic differentiation (AD) objects when possible");
39 : Action(params), _use_ad(getParam<bool>(
"use_automatic_differentiation"))
46 auto displacements = getParam<std::vector<VariableName>>(
"displacements");
47 auto save_in = getParam<std::vector<AuxVariableName>>(
"save_in");
49 unsigned int ndisp = displacements.size();
50 if (save_in.size() > 0 && save_in.size() != ndisp)
51 mooseError(
"Number of save_in variables should equal to the number of displacement variables ",
54 std::string ad_append =
"";
55 std::string ad_prepend =
"";
58 ad_append =
"<RESIDUAL>";
62 std::string kernel_name = ad_prepend +
"Pressure";
64 InputParameters params = _factory.getValidParams(kernel_name + ad_append);
65 params.applyParameters(parameters());
67 params.set<PostprocessorName>(
"postprocessor") =
68 isParamValid(
"output") ? getParam<std::string>(
"output") : _name;
70 for (
unsigned int i = 0; i < ndisp; ++i)
72 params.set<
unsigned int>(
"component") = i;
73 params.set<NonlinearVariableName>(
"variable") = displacements[i];
75 params.set<std::vector<AuxVariableName>>(
"save_in") = {save_in[i]};
76 std::string unique_kernel_name = _name +
"_" + Moose::stringify(i);
80 _problem->addBoundaryCondition(
81 kernel_name + ad_append, unique_kernel_name +
"_residual", params);
82 _problem->addBoundaryCondition(
83 kernel_name +
"<JACOBIAN>", unique_kernel_name +
"_jacobian", params);
84 _problem->haveADObjects(
true);
88 _problem->addBoundaryCondition(kernel_name, unique_kernel_name, params);