16 #include "metaphysicl/metaphysicl_version.h" 17 #include "metaphysicl/dualsemidynamicsparsenumberarray.h" 18 #include "metaphysicl/parallel_dualnumber.h" 19 #if METAPHYSICL_MAJOR_VERSION < 2 20 #include "metaphysicl/parallel_dynamic_std_array_wrapper.h" 22 #include "metaphysicl/parallel_dynamic_array_wrapper.h" 24 #include "metaphysicl/parallel_semidynamicsparsenumberarray.h" 38 "The frictional Lagrange's multiplier for an addtional direction.");
41 "Coupled function to evaluate friction with values from contact pressure and relative " 42 "tangential velocities");
43 params.
addParam<
Real>(
"c_t", 1e0,
"Numerical parameter for tangential constraints");
47 "Minimum value of contact pressure that will trigger frictional enforcement");
49 "mu",
"mu > 0",
"The friction coefficient for the Coulomb friction law");
51 "The weighted tangential velocities user object.");
60 _c_t(getParam<
Real>(
"c_t")),
61 _secondary_x_dot(_secondary_var.adUDot()),
62 _primary_x_dot(_primary_var.adUDotNeighbor()),
63 _secondary_y_dot(adCoupledDot(
"disp_y")),
64 _primary_y_dot(adCoupledNeighborValueDot(
"disp_y")),
65 _secondary_z_dot(_has_disp_z ? &adCoupledDot(
"disp_z") : nullptr),
66 _primary_z_dot(_has_disp_z ? &adCoupledNeighborValueDot(
"disp_z") : nullptr),
67 _epsilon(getParam<
Real>(
"epsilon")),
68 _mu(isParamValid(
"function_friction") ?
std::numeric_limits<double>::quiet_NaN()
69 : getParam<
Real>(
"mu")),
70 _function_friction(isParamValid(
"function_friction") ? &getFunction(
"function_friction")
72 _has_friction_function(isParamValid(
"function_friction")),
79 "Please only provide friction either as a function or as a constant value, but not both.");
81 paramError(
"mu",
"Please provide a value or a function for the coefficient of friction.");
83 if (!getParam<bool>(
"use_displaced_mesh"))
85 "'use_displaced_mesh' must be true for the " 86 "ComputeFrictionalForceLMMechanicalContact object");
90 "Three-dimensional mortar frictional contact simulations require an additional " 91 "frictional Lagrange's multiplier to enforce a second tangential pressure");
102 "Frictional contact constraints only support elemental variables of CONSTANT order");
123 const auto & dof_to_weighted_tangential_velocity =
126 const std::unordered_map<const DofObject *, std::pair<ADReal, Real>> & dof_to_weighted_gap =
131 for (
const auto & [dof_object, weighted_velocities_pr] : dof_to_weighted_tangential_velocity)
136 const auto & [weighted_gap_pr, normalization] =
137 libmesh_map_find(dof_to_weighted_gap, dof_object);
154 const std::unordered_set<const Node *> & inactive_lm_nodes)
156 const auto & dof_to_weighted_tangential_velocity =
160 for (
const auto & [dof_object, weighted_velocities_pr] : dof_to_weighted_tangential_velocity)
163 if ((inactive_lm_nodes.find(static_cast<const Node *>(dof_object)) !=
164 inactive_lm_nodes.end()) ||
185 using std::max, std::sqrt;
197 std::array<dof_id_type, 2> friction_dof_indices;
198 std::array<ADReal, 2> friction_lm_values;
200 const unsigned int num_tangents = 2;
223 dof_residual = friction_lm_values[0];
224 dof_residual_dir = friction_lm_values[1];
229 const Real epsilon_sqrt = 1.0e-48;
231 const auto lamdba_plus_cg = contact_pressure +
c * weighted_gap;
232 std::array<ADReal, 2> lambda_t_plus_ctu;
233 lambda_t_plus_ctu[0] = friction_lm_values[0] + c_t * *tangential_vel[0] *
_dt;
234 lambda_t_plus_ctu[1] = friction_lm_values[1] + c_t * *tangential_vel[1] *
_dt;
236 const auto term_1_x =
max(mu_ad * lamdba_plus_cg,
237 sqrt(lambda_t_plus_ctu[0] * lambda_t_plus_ctu[0] +
238 lambda_t_plus_ctu[1] * lambda_t_plus_ctu[1] + epsilon_sqrt)) *
239 friction_lm_values[0];
241 const auto term_1_y =
max(mu_ad * lamdba_plus_cg,
242 sqrt(lambda_t_plus_ctu[0] * lambda_t_plus_ctu[0] +
243 lambda_t_plus_ctu[1] * lambda_t_plus_ctu[1] + epsilon_sqrt)) *
244 friction_lm_values[1];
246 const auto term_2_x = mu_ad *
max(0.0, lamdba_plus_cg) * lambda_t_plus_ctu[0];
248 const auto term_2_y = mu_ad *
max(0.0, lamdba_plus_cg) * lambda_t_plus_ctu[1];
250 dof_residual = term_1_x - term_2_x;
251 dof_residual_dir = term_1_y - term_2_y;
255 std::array<ADReal, 1>{{dof_residual}},
256 std::array<dof_id_type, 1>{{friction_dof_indices[0]}},
259 std::array<ADReal, 1>{{dof_residual_dir}},
260 std::array<dof_id_type, 1>{{friction_dof_indices[1]}},
267 using std::abs, std::max;
294 dof_residual = friction_lm_value;
297 const auto term_1 =
max(mu_ad * (contact_pressure +
c * weighted_gap),
298 abs(friction_lm_value + c_t * tangential_vel *
_dt)) *
300 const auto term_2 = mu_ad *
max(0.0, contact_pressure +
c * weighted_gap) *
301 (friction_lm_value + c_t * tangential_vel *
_dt);
303 dof_residual = term_1 - term_2;
307 std::array<ADReal, 1>{{dof_residual}},
308 std::array<dof_id_type, 1>{{friction_dof_index}},
314 const ADReal & tangential_vel,
315 const ADReal & tangential_vel_dir)
326 ADReal tangential_vel_magnitude =
327 sqrt(tangential_vel * tangential_vel + tangential_vel_dir * tangential_vel_dir + 1.0e-24);
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
virtual const NumericVector< Number > *const & currentSolution() const=0
void addResidualsAndJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
void paramError(const std::string ¶m, Args... args) const
unsigned int number() const
const InputParameters & parameters() const
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
Creates dof object to weighted tangential velocities map.
DualNumber< Real, DNDerivativeType, true > ADReal
auto max(const L &left, const R &right)
const std::unordered_map< const DofObject *, std::array< ADReal, 2 > > & dofToWeightedVelocities() const
Get the degree of freedom to weighted velocities information.
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.
MooseVariable *const _var
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
IntRange< T > make_range(T beg, T end)
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)
bool isParamValid(const std::string &name) const
virtual Real value(Real t, const Point &p) const
processor_id_type processor_id() const