20#include "libmesh/string_to_enum.h"
25 MooseEnum orders(
"FIRST SECOND THIRD FOURTH",
"FIRST");
27 params.
addParam<BoundaryName>(
"secondary",
"The boundary ID associated with the secondary side");
28 params.
addParam<BoundaryName>(
"primary",
"The boundary ID associated with the primary side");
29 params.
addParam<Real>(
"tangential_tolerance",
30 "Tangential distance to extend edges of contact surfaces");
32 "normal_smoothing_distance",
33 "Distance from edge in parametric coordinates over which to smooth contact normal");
34 params.
addParam<std::string>(
"normal_smoothing_method",
35 "Method to use to smooth normals (edge_based|nodal_normal_based)");
36 params.
addParam<
MooseEnum>(
"order", orders,
"The finite element order used for projections");
38 "ghost_whole_interface",
40 "Whether to geometrically and algebraically ghost the entire primary side of the interface "
41 "for node-face constraints.");
47 const auto enabled = obj_params.
get<
bool>(
"ghost_whole_interface");
51 rm_params.
set<
bool>(
"attach_geometric_early") = !
enabled;
52 rm_params.
set<
bool>(
"use_displaced_mesh") = obj_params.
get<
bool>(
"use_displaced_mesh");
53 rm_params.
set<BoundaryName>(
"secondary_boundary") =
54 obj_params.
get<BoundaryName>(
"secondary");
55 rm_params.
set<BoundaryName>(
"primary_boundary") = obj_params.
get<BoundaryName>(
"primary");
58 params.
addCoupledVar(
"primary_variable",
"The variable on the primary side of the domain");
69 this, true,
Moose::VarKindType::VAR_SOLVER,
Moose::VarFieldType::VAR_FIELD_STANDARD),
70 _secondary(_mesh.getBoundaryID(getParam<BoundaryName>(
"secondary"))),
71 _primary(_mesh.getBoundaryID(getParam<BoundaryName>(
"primary"))),
72 _var(_sys.getFieldVariable<Real>(_tid, parameters.get<NonlinearVariableName>(
"variable"))),
74 _primary_q_point(_assembly.qPointsFace()),
75 _primary_qrule(_assembly.qRuleFace()),
78 getPenetrationLocator(getParam<BoundaryName>(
"primary"),
79 getParam<BoundaryName>(
"secondary"),
82 _current_node(_var.node()),
83 _current_primary(_var.neighbor()),
84 _u_secondary(_var.dofValues()),
88 _primary_var(*getVar(
"primary_variable", 0)),
89 _primary_var_num(_primary_var.number()),
91 _phi_primary(_assembly.phiFaceNeighbor(_primary_var)),
92 _grad_phi_primary(_assembly.gradPhiFaceNeighbor(_primary_var)),
94 _test_primary(_var.phiFaceNeighbor()),
95 _grad_test_primary(_var.gradPhiFaceNeighbor()),
97 _u_primary(_primary_var.slnNeighbor()),
98 _grad_u_primary(_primary_var.gradSlnNeighbor()),
100 _dof_map(_sys.dofMap()),
101 _node_to_elem_map(_mesh.nodeToElemMap()),
103 _overwrite_secondary_residual(true),
104 _primary_JxW(_assembly.JxWNeighbor())
150 "The secondary residual has not yet been computed, so the value will be garbage!");
258 for (
_j = 0;
_j < primary_jsize;
_j++)
270 for (
_j = 0;
_j < primary_jsize;
_j++)
281 std::set<dof_id_type> unique_dof_indices;
284 mooseAssert(node_to_elem_pair !=
_node_to_elem_map.end(),
"Missing entry in node to elem map");
285 const std::vector<dof_id_type> & elems = node_to_elem_pair->second;
288 for (
const auto & cur_elem : elems)
290 std::vector<dof_id_type> dof_indices;
294 for (
const auto & dof : dof_indices)
295 unique_dof_indices.insert(dof);
298 for (
const auto & dof : unique_dof_indices)
308const std::set<BoundaryID> &
Base class for all Constraint types.
static InputParameters validParams()
const InputParameters & parameters() const
Get the parameters of the object.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual Elem * elemPtr(const dof_id_type i)
std::set< SubdomainID > getBoundaryConnectedBlocks(const BoundaryID bid) const
Get the list of subdomains associated with the given boundary.
virtual bool enabled() const
Return the enabled status of the object.
virtual void getDofIndices(const Elem *, std::vector< dof_id_type > &) const
unsigned int number() const
Get variable number coming from libMesh.
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
const dof_id_type & nodalDofIndex() const override
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual const std::vector< dof_id_type > & dofIndicesNeighbor() const =0
Get neighbor DOF indices for currently selected element.
Enhances MooseVariableInterface interface provide values from neighbor elements.
std::set< SubdomainID > getSecondaryConnectedBlocks() const
PenetrationLocator & _penetration_locator
const Node *const & _current_node
current node being processed
virtual Real computeQpSecondaryValue()=0
Compute the value the secondary node should have at the beginning of a timestep.
virtual void computeOffDiagJacobian(unsigned int jvar) override
Computes d-residual / d-jvar...
void residualSetup() override
Gets called just before the residual is computed and before this object is asked to do its job.
DenseMatrix< Number > _Kee
The Jacobian corresponding to the derivatives of the elemental/secondary residual with respect to the...
VariableTestValue _test_secondary
Shape function on the secondary side. This will always only have one entry and that entry will always...
std::vector< dof_id_type > _connected_dof_indices
virtual Real computeQpJacobian(Moose::ConstraintJacobianType type)=0
This is the virtual that derived classes should override for computing the Jacobian on neighboring el...
const VariableTestValue & _test_primary
Side test function.
bool _overwrite_secondary_residual
Whether or not the secondary's residual should be overwritten.
Real _secondary_residual
The value of the secondary residual.
DenseMatrix< Number > _Kne
The Jacobian corresponding to the derivatives of the neighbor/primary residual with respect to the el...
NodeFaceConstraint(const InputParameters ¶meters)
virtual void computeJacobian() override
Computes the jacobian for the current element.
static InputParameters validParams()
const std::set< BoundaryID > & buildBoundaryIDs()
Builds the _boundary_ids data member and returns it.
virtual void computeResidual() override
Computes the residual Nodal residual.
const VariablePhiValue & _phi_primary
Side shape function.
virtual bool overwriteSecondaryResidual()
Whether or not the secondary's residual should be overwritten.
virtual Real computeQpOffDiagJacobian(Moose::ConstraintJacobianType, unsigned int)
This is the virtual that derived classes should override for computing the off-diag Jacobian.
VariablePhiValue _phi_secondary
Shape function on the secondary side. This will always.
MooseVariable & _primary_var
Primary side variable.
std::set< BoundaryID > _boundary_ids
the union of the secondary and primary boundary ids
virtual void getConnectedDofIndices(unsigned int var_num)
Gets the indices for all dofs connected to the constraint.
BoundaryID _secondary
Boundary ID for the secondary surface.
Real secondaryResidual() const
DenseMatrix< Number > _Ken
The Jacobian corresponding to the derivatives of the elemental/secondary residual with respect to the...
virtual ~NodeFaceConstraint()
const std::unordered_map< dof_id_type, std::vector< dof_id_type > > & _node_to_elem_map
virtual Real computeQpResidual(Moose::ConstraintType type)=0
This is the virtual that derived classes should override for computing the residual on neighboring el...
virtual void computeSecondaryValue(NumericVector< Number > ¤t_solution)
Compute the value the secondary node should have at the beginning of a timestep.
BoundaryID _primary
Boundary ID for the primary surface.
bool _secondary_residual_computed
Whether the secondary residual has been computed.
void setNormalSmoothingMethod(std::string nsmString)
void setTangentialTolerance(Real tangential_tolerance)
void setNormalSmoothingDistance(Real normal_smoothing_distance)
MooseMesh & _mesh
Reference to this Kernel's mesh object.
Assembly & _assembly
Reference to this Kernel's assembly object.
const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
Retrieve the variable object from our system associated with jvar_num.
SystemBase & _sys
Reference to the EquationSystem object.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
DenseMatrix< Number > _local_ke
Holds local Jacobian entries as they are accumulated by this Kernel.
void accumulateTaggedLocalMatrix()
Local Jacobian blocks will be appended by adding the current local kernel Jacobian.
void accumulateTaggedLocalResidual()
Local residual blocks will be appended by adding the current local kernel residual.
void prepareMatrixTagNeighbor(Assembly &assembly, unsigned int ivar, unsigned int jvar, Moose::DGJacobianType type)
Prepare data for computing element jacobian according to the active tags for DG and interface kernels...
void prepareVectorTagNeighbor(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual the according to active tags for DG and interface kernels...
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual according to active tags.
void assignTaggedLocalResidual()
Local residual blocks will assigned as the current local kernel residual.
DenseVector< Number > _local_re
Holds local residual entries as they are accumulated by this Kernel.
void resize(const unsigned int new_m, const unsigned int new_n)
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...