115 if (!_problem->getDisplacedProblem())
116 mooseError(
"Contact requires updated coordinates. Use the 'displacements = ...' line in the " 123 if (!_problem->isSNESMFReuseBaseSetbyUser())
124 _problem->setSNESMFReuseBase(
false,
false);
126 std::string action_name = MooseUtils::shortName(
name());
128 std::vector<VariableName> displacements;
129 if (isParamValid(
"displacements"))
130 displacements = getParam<std::vector<VariableName>>(
"displacements");
134 if (!isParamValid(
"disp_x"))
135 mooseError(
"Specify displacement variables using the `displacements` parameter.");
136 displacements.push_back(getParam<VariableName>(
"disp_x"));
138 if (isParamValid(
"disp_y"))
140 displacements.push_back(getParam<VariableName>(
"disp_y"));
141 if (isParamValid(
"disp_z"))
142 displacements.push_back(getParam<VariableName>(
"disp_z"));
145 mooseDeprecated(
"use the `displacements` parameter rather than the `disp_*` parameters (those " 146 "will go away with the deprecation of the Solid Mechanics module).");
150 const unsigned int ndisp = displacements.size();
153 std::vector<VariableName> coupled_displacements(ndisp);
154 for (
unsigned int i = 0; i < ndisp; ++i)
155 coupled_displacements[i] = displacements[i];
157 if (_current_task ==
"add_dirac_kernel")
163 InputParameters params = _factory.getValidParams(
"MechanicalContactConstraint");
164 params.applyParameters(parameters(), {
"displacements",
"formulation"});
166 params.set<std::vector<VariableName>>(
"nodal_area") = {
"nodal_area_" +
name()};
167 params.set<std::vector<VariableName>>(
"displacements") = coupled_displacements;
168 params.set<BoundaryName>(
"boundary") =
_master;
169 params.set<
bool>(
"use_displaced_mesh") =
true;
171 for (
unsigned int i = 0; i < ndisp; ++i)
173 std::string
name = action_name +
"_constraint_" + Moose::stringify(i);
175 params.set<
unsigned int>(
"component") = i;
176 params.set<NonlinearVariableName>(
"variable") = displacements[i];
177 params.set<std::vector<VariableName>>(
"master_variable") = {coupled_displacements[i]};
178 _problem->addConstraint(
"MechanicalContactConstraint",
name, params);
185 InputParameters params = _factory.getValidParams(
"ContactMaster");
186 params.applyParameters(parameters(), {
"displacements",
"formulation"});
188 params.set<std::vector<VariableName>>(
"nodal_area") = {
"nodal_area_" +
name()};
189 params.set<std::vector<VariableName>>(
"displacements") = coupled_displacements;
190 params.set<BoundaryName>(
"boundary") =
_master;
191 params.set<
bool>(
"use_displaced_mesh") =
true;
193 for (
unsigned int i = 0; i < ndisp; ++i)
195 std::string
name = action_name +
"_master_" + Moose::stringify(i);
196 params.set<
unsigned int>(
"component") = i;
197 params.set<NonlinearVariableName>(
"variable") = displacements[i];
198 _problem->addDiracKernel(
"ContactMaster",
name, params);
203 InputParameters params = _factory.getValidParams(
"SlaveConstraint");
204 params.applyParameters(parameters(), {
"displacements",
"formulation"});
206 params.set<std::vector<VariableName>>(
"nodal_area") = {
"nodal_area_" +
name()};
207 params.set<std::vector<VariableName>>(
"displacements") = coupled_displacements;
208 params.set<BoundaryName>(
"boundary") =
_slave;
209 params.set<
bool>(
"use_displaced_mesh") =
true;
211 for (
unsigned int i = 0; i < ndisp; ++i)
213 std::string
name = action_name +
"_slave_" + Moose::stringify(i);
214 params.set<
unsigned int>(
"component") = i;
215 params.set<NonlinearVariableName>(
"variable") = displacements[i];
216 _problem->addDiracKernel(
"SlaveConstraint",
name, params);