15 #include "metaphysicl/dualsemidynamicsparsenumberarray.h" 16 #include "metaphysicl/parallel_dualnumber.h" 17 #include "metaphysicl/parallel_dynamic_std_array_wrapper.h" 18 #include "metaphysicl/parallel_semidynamicsparsenumberarray.h" 29 const auto & disp_x_name = ret.
get<std::vector<VariableName>>(
"disp_x");
30 if (disp_x_name.size() != 1)
31 mooseError(
"We require that the disp_x parameter have exactly one coupled name");
34 ret.
set<VariableName>(
"secondary_variable") = disp_x_name[0];
35 ret.
set<VariableName>(
"primary_variable") = disp_x_name[0];
45 params.
addClassDescription(
"Computes the weighted gap that will later be used to enforce the " 46 "zero-penetration mechanical contact conditions");
51 params.
addCoupledVar(
"disp_z",
"The z displacement variable");
53 "c", 1e6,
"Parameter for balancing the size of the gap and contact pressure");
57 "Whether to normalize c by weighting function norm. When unnormalized " 58 "the value of c effectively depends on element size since in the constraint we compare nodal " 59 "Lagrange Multiplier values to integrated gap values (LM nodal value is independent of " 60 "element size, where integrated values are dependent on element size).");
61 params.
set<
bool>(
"use_displaced_mesh") =
true;
62 params.
set<
bool>(
"interpolate_normals") =
false;
63 params.
addRequiredParam<UserObjectName>(
"weighted_gap_uo",
"The weighted gap user object");
70 _secondary_disp_x(adCoupledValue(
"disp_x")),
71 _primary_disp_x(adCoupledNeighborValue(
"disp_x")),
72 _secondary_disp_y(adCoupledValue(
"disp_y")),
73 _primary_disp_y(adCoupledNeighborValue(
"disp_y")),
74 _has_disp_z(isCoupled(
"disp_z")),
75 _secondary_disp_z(_has_disp_z ? &adCoupledValue(
"disp_z") : nullptr),
76 _primary_disp_z(_has_disp_z ? &adCoupledNeighborValue(
"disp_z") : nullptr),
77 _c(getParam<
Real>(
"c")),
78 _normalize_c(getParam<bool>(
"normalize_c")),
79 _nodal(getVar(
"disp_x", 0)->feType().family ==
LAGRANGE),
80 _disp_x_var(getVar(
"disp_x", 0)),
81 _disp_y_var(getVar(
"disp_y", 0)),
82 _disp_z_var(_has_disp_z ? getVar(
"disp_z", 0) : nullptr),
85 if (!getParam<bool>(
"use_displaced_mesh"))
88 "'use_displaced_mesh' must be true for the ComputeWeightedGapLMMechanicalContact object");
92 mooseError(
"Normal contact constraints only support elemental variables of CONSTANT order");
97 mooseError(
"We should never call computeQpResidual for ComputeWeightedGapLMMechanicalContact");
140 parallel_object_only();
144 for (
const auto & [dof_object, weighted_gap_pr] : dof_to_weighted_gap)
149 const auto & [weighted_gap, normalization] = weighted_gap_pr;
159 const std::unordered_set<const Node *> & inactive_lm_nodes)
163 for (
const auto & [dof_object, weighted_gap_pr] : dof_to_weighted_gap)
165 if ((inactive_lm_nodes.find(static_cast<const Node *>(dof_object)) !=
166 inactive_lm_nodes.end()) ||
170 const auto & [weighted_gap, normalization] = weighted_gap_pr;
188 const ADReal dof_residual = std::min(lm_value, weighted_gap *
c);
191 std::array<ADReal, 1>{{dof_residual}},
192 std::array<dof_id_type, 1>{{dof_index}},
virtual const NumericVector< Number > *const & currentSolution() const=0
const libMesh::FEType & feType() const
void addResidualsAndJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
void mooseError(Args &&... args)
unsigned int number() const
DualNumber< Real, DNDerivativeType, true > ADReal
virtual void computeResidual() override
void paramError(const std::string ¶m, Args... args) const
unsigned int number() const
const std::unordered_map< const DofObject *, std::pair< ADReal, Real > > & dofToWeightedGap() const
Get the degree of freedom to weighted gap information.
bool isNodal() const override
MooseVariable *const _var
Creates dof object to weighted gap map.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void computeJacobian() override
void mooseError(Args &&... args) const
static InputParameters validParams()
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)
processor_id_type processor_id() const
void scalingFactor(const std::vector< Real > &factor)