15#include "metaphysicl/metaphysicl_version.h"
16#include "metaphysicl/dualsemidynamicsparsenumberarray.h"
17#include "metaphysicl/parallel_dualnumber.h"
18#if METAPHYSICL_MAJOR_VERSION < 2
19#include "metaphysicl/parallel_dynamic_std_array_wrapper.h"
21#include "metaphysicl/parallel_dynamic_array_wrapper.h"
23#include "metaphysicl/parallel_semidynamicsparsenumberarray.h"
34 const auto & disp_x_name = ret.
get<std::vector<VariableName>>(
"disp_x");
35 if (disp_x_name.size() != 1)
36 mooseError(
"We require that the disp_x parameter have exactly one coupled name");
39 ret.
set<VariableName>(
"secondary_variable") = disp_x_name[0];
40 ret.
set<VariableName>(
"primary_variable") = disp_x_name[0];
51 params.
addParam<Real>(
"c_t", 1e0,
"Numerical parameter for tangential constraints");
55 "Minimum value of contact pressure that will trigger frictional enforcement");
57 "mu",
"mu > 0",
"The friction coefficient for the Coulomb friction law");
58 MooseEnum friction_projection_degree(
"ONE TWO",
"TWO");
59 friction_projection_degree.addDocumentation(
60 "ONE",
"Use the degree-one Alart-Curnier friction residual.");
61 friction_projection_degree.addDocumentation(
62 "TWO",
"Use the degree-two Hueber-Stadler-Wohlmuth friction residual.");
64 "friction_projection_degree",
65 friction_projection_degree,
66 "Degree of the friction-residual projection; see MortarContactUtils.h.");
73 _c_t(getParam<Real>(
"c_t")),
74 _friction_projection_degree(getParam<
MooseEnum>(
"friction_projection_degree")
75 .getEnum<
Moose::
Mortar::Contact::FrictionProjectionDegree>()),
76 _secondary_x_dot(adCoupledDot(
"disp_x")),
77 _primary_x_dot(adCoupledNeighborValueDot(
"disp_x")),
78 _secondary_y_dot(adCoupledDot(
"disp_y")),
79 _primary_y_dot(adCoupledNeighborValueDot(
"disp_y")),
80 _secondary_z_dot(_has_disp_z ? &adCoupledDot(
"disp_z") : nullptr),
81 _primary_z_dot(_has_disp_z ? &adCoupledNeighborValueDot(
"disp_z") : nullptr),
82 _mu(getParam<Real>(
"mu")),
83 _epsilon(getParam<Real>(
"epsilon"))
97 const auto & secondary_ip_lowerd_map =
101 std::array<ADReal, 3> primary_disp_dot{
103 std::array<ADReal, 3> secondary_disp_dot{
109 const ADReal & prim_x_dot = primary_disp_dot[0];
110 const ADReal & prim_y_dot = primary_disp_dot[1];
111 const ADReal * prim_z_dot =
nullptr;
113 prim_z_dot = &primary_disp_dot[2];
115 const ADReal & sec_x_dot = secondary_disp_dot[0];
116 const ADReal & sec_y_dot = secondary_disp_dot[1];
117 const ADReal * sec_z_dot =
nullptr;
119 sec_z_dot = &secondary_disp_dot[2];
125 relative_velocity = {sec_x_dot - prim_x_dot, sec_y_dot - prim_y_dot, *sec_z_dot - *prim_z_dot};
127 relative_velocity = {sec_x_dot - prim_x_dot, sec_y_dot - prim_y_dot, 0.0};
142 const DofObject *
const dof =
173 const DofObject *
const dof = pr.first;
192 const std::unordered_set<const Node *> & inactive_lm_nodes)
202 const DofObject *
const dof = pr.first;
205 if ((inactive_lm_nodes.find(
static_cast<const Node *
>(dof)) != inactive_lm_nodes.end()) ||
222 const DofObject *
const dof)
224 using std::abs, std::sqrt, std::min;
232 const Real scaling_factor_x =
_lm_vars[0]->scalingFactor();
233 const Real scaling_factor_y =
_lm_vars[1]->scalingFactor();
234 Real scaling_factor_z = 1;
242 dof_id_type dof_index_z(-1);
249 scaling_factor_z =
_lm_vars[2]->scalingFactor();
255 ADReal normal_pressure_value = lm_x * normal(0) + lm_y * normal(1);
256 ADReal tangential_pressure_value = lm_x * tangents[0](0) + lm_y * tangents[0](1);
258 ADReal tangential_pressure_value_dir;
262 normal_pressure_value += lm_z * normal(2);
263 tangential_pressure_value += lm_z * tangents[0](2);
264 tangential_pressure_value_dir =
265 lm_x * tangents[1](0) + lm_y * tangents[1](1) + lm_z * tangents[1](2);
268 ADReal normal_dof_residual = min(normal_pressure_value, weighted_gap *
c);
269 ADReal tangential_dof_residual;
270 ADReal tangential_dof_residual_dir;
274 const std::array<ADReal, 1> tangential_pressure{{tangential_pressure_value}};
277 tangential_dof_residual =
282 normal_pressure_value,
290 const std::array<ADReal, 2> tangential_pressure{
291 {tangential_pressure_value, tangential_pressure_value_dir}};
292 const std::array<ADReal, 2> tangential_velocity{
295 const auto residual =
300 normal_pressure_value,
305 tangential_dof_residual = residual[0];
306 tangential_dof_residual_dir = residual[1];
328 unsigned int component_normal = 0;
331 const Real threshold_for_Jacobian =
_has_disp_z ? 1.0 / sqrt(3.0) : 1.0 / sqrt(2.0);
333 if (abs(ny) > threshold_for_Jacobian)
334 component_normal = 1;
335 else if (abs(nz) > threshold_for_Jacobian)
336 component_normal = 2;
340 std::array<ADReal, 1>{{normal_dof_residual}},
341 std::array<dof_id_type, 1>{{component_normal == 0
343 : (component_normal == 1 ? dof_index_y : dof_index_z)}},
344 component_normal == 0 ? scaling_factor_x
345 : (component_normal == 1 ? scaling_factor_y : scaling_factor_z));
349 std::array<ADReal, 1>{{tangential_dof_residual}},
350 std::array<dof_id_type, 1>{
351 {(component_normal == 0 || component_normal == 2) ? dof_index_y : dof_index_x}},
352 (component_normal == 0 || component_normal == 2) ? scaling_factor_y : scaling_factor_x);
357 std::array<ADReal, 1>{{tangential_dof_residual_dir}},
358 std::array<dof_id_type, 1>{
359 {(component_normal == 0 || component_normal == 1) ? dof_index_z : dof_index_x}},
360 (component_normal == 0 || component_normal == 1) ? scaling_factor_z : scaling_factor_x);
DualNumber< Real, DNDerivativeType, true > ADReal
void mooseError(Args &&... args)
std::map< unsigned int, unsigned int > getSecondaryIpToLowerElementMap(const Elem &lower_secondary_elem) const
std::map< unsigned int, unsigned int > getPrimaryIpToLowerElementMap(const Elem &primary_elem, const Elem &primary_elem_ip, const Elem &lower_secondary_elem) const
static const Elem & primaryInteriorParentOrSelf(const Elem &lower_primary_elem)
const std::array< ADRealVectorValue, 2 > & tangents(const AutomaticMortarGeneration &amg, const Node &node, const Point &stored_normal, bool do_derivatives)
const MooseArray< Real > & _coord
const VariableTestValue & _test
Elem const *const & _lower_secondary_elem
const AutomaticMortarGeneration & amg() const
Elem const *const & _lower_primary_elem
std::vector< Point > _normals
static void trimInteriorNodeDerivatives(const std::map< unsigned int, unsigned int > &primary_ip_lowerd_map, const Variables &moose_var, DualNumbers &ad_vars, const bool is_secondary)
const std::vector< Real > & _JxW_msm
virtual const NumericVector< Number > *const & currentSolution() const=0
unsigned int number() const
void addResidualsAndJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
const Parallel::Communicator & _communicator
processor_id_type processor_id() const
bool doDerivatives(const SubProblem &subproblem, const SystemBase &sys)
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N > > &derivs, libMesh::dof_id_type index, Real value)