22 "Constraint for enforcing that variables on each side of a boundary are equivalent.");
25 "The ID of the primary node. If no ID is provided, first node of secondary set is chosen.");
26 params.
addParam<Point>(
"primary_node_coord",
"Coordinates of the primary node to locate.");
27 params.
addParam<std::vector<unsigned int>>(
"secondary_node_ids",
"The IDs of the secondary node");
28 params.
addParam<BoundaryName>(
"secondary",
"The boundary ID associated with the secondary side");
29 params.
addRequiredParam<Real>(
"penalty",
"The penalty used for the boundary term");
58 paramError(
"secondary",
"Either secondary or secondary_node_ids must be provided.");
63 "Both 'secondary' and 'secondary_node_ids' parameters are set. They are mutually "
75 const auto & secondary_bnd = getParam<BoundaryName>(
"secondary");
78 for (
const auto & nid : secondary_nodes)
85 const auto & secondary_node_ids = getParam<std::vector<unsigned int>>(
"secondary_node_ids");
86 for (
const auto & nid : secondary_node_ids)
99 "Both 'primary' and 'primary_node_coord' parameters are set. They are mutually exclusive.");
101 dof_id_type primary_node_id = Node::invalid_id;
108 primary_node_id = getParam<unsigned int>(
"primary");
127 mooseAssert(primary_node_id != Node::invalid_id,
"We should have found a primary node");
143 std::unordered_set<dof_id_type> local_primary_node_ids;
144 const auto & primary_node_coord = getParam<Point>(
"primary_node_coord");
149 if ((*(bnd_node->_node) - primary_node_coord).norm() < eps)
159 local_primary_node_ids.insert(bnd_node->_node->id());
164 const std::vector<dof_id_type> local_node_vec(local_primary_node_ids.begin(),
165 local_primary_node_ids.end());
166 std::vector<std::vector<dof_id_type>> gathered_node_vecs;
170 std::unordered_set<dof_id_type> global_primary_node_ids;
171 for (
const auto & vec : gathered_node_vecs)
172 global_primary_node_ids.insert(vec.begin(), vec.end());
175 if (global_primary_node_ids.size() == 0)
176 mooseError(
"Couldn't find a node ID for the specified primary_node_coord.");
177 else if (global_primary_node_ids.size() > 1)
178 mooseError(
"Multiple nodes found for the specified primary_node_coord.");
180 return *global_primary_node_ids.begin();
189 const auto connected_elem_ids =
191 const auto primary_elem_id = connected_elem_ids.front();
196 const auto displaced_connected_elem_ids =
198 const auto displaced_primary_elem_id = displaced_connected_elem_ids.front();
199 if (displaced_primary_elem_id != primary_elem_id)
200 mooseError(
"Reference and displaced meshes selected different primary elements");
registerMooseObject("MooseApp", EqualValueBoundaryConstraint)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
std::shared_ptr< DisplacedProblem > displaced_problem
dof_id_type getPrimaryNodeIDByCoord() const
Get the primary node ID by searching for the node with coordinates matching _primary_node_coord on th...
virtual Real computeQpJacobian(Moose::ConstraintJacobianType type) override
Computes the jacobian for the constraint.
void pickPrimaryNode()
Pick the primary node from user input or from the secondary node set.
void populateSecondaryNodes()
Populate the set of secondary nodes from user input.
void ghostPrimary()
Ghost elements and nodes connected to the primary node.
EqualValueBoundaryConstraint(const InputParameters ¶meters)
void updateConstrainedNodes()
Update the sets of nodes with constrained DOFs.
static InputParameters validParams()
Real _penalty
Penalty if constraint is not satisfied.
virtual void meshChanged() override
Called on this object when the mesh changes.
virtual Real computeQpResidual(Moose::ConstraintType type) override
Computes the residual for the current secondary node.
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
virtual MooseMesh & mesh() override
const std::string & type() const
Get the type of this class.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
virtual const Node & nodeRef(const dof_id_type i) const
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
Get the associated BoundaryID for the boundary name.
const std::vector< dof_id_type > & getNodeList(boundary_id_type nodeset_id) const
Return a writable reference to a vector of node IDs that belong to nodeset_id.
libMesh::StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
virtual const Node * queryNodePtr(const dof_id_type i) const
unsigned int _i
Counter for primary and secondary nodes.
std::vector< dof_id_type > _primary_node_vector
node IDs of the primary node
std::vector< dof_id_type > _connected_nodes
node IDs connected to the primary node (secondary nodes)
std::vector< dof_id_type > gatherAndRetainConnectedElems(MooseMesh &mesh, const std::vector< dof_id_type > &node_ids)
Gather and retain elements connected to the provided nodes on the provided mesh.
static InputParameters validParams()
const VariableValue & _u_secondary
Value of the unknown variable this BC is action on.
const VariableValue & _u_primary
Holds the current solution at the current quadrature point.
MooseMesh & _mesh
Reference to this Kernel's mesh object.
SubProblem & _subproblem
Reference to this kernel's SubProblem.
FEProblemBase & _fe_problem
Reference to this kernel's FEProblemBase.
virtual void addGhostedElem(dof_id_type elem_id)=0
Will make sure that all dofs connected to elem_id are ghosted to this processor.
void min(const T &r, T &o, Request &req) const
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
static constexpr Real TOLERANCE