14 #include "libmesh/null_output_iterator.h" 15 #include "libmesh/parallel.h" 16 #include "libmesh/parallel_elem.h" 17 #include "libmesh/parallel_node.h" 34 struct CompareElemsByLevel
36 bool operator()(
const Elem * a,
const Elem * b)
const 40 const unsigned int al = a->level(), bl = b->level();
43 return (al == bl) ? aid < bid : al < bl;
56 "Constraint for enforcing that variables on each side of a boundary are equivalent.");
60 "The ID of the primary node. If no ID is provided, first node of secondary set is chosen.");
61 params.
addParam<std::vector<unsigned int>>(
62 "secondary_node_ids", {},
"The IDs of the secondary node");
64 "secondary",
"NaN",
"The boundary ID associated with the secondary side");
71 _primary_node_id(getParam<unsigned
int>(
"primary")),
72 _secondary_node_ids(getParam<
std::vector<unsigned
int>>(
"secondary_node_ids")),
73 _secondary_node_set_id(getParam<BoundaryName>(
"secondary")),
74 _penalty(getParam<
Real>(
"penalty"))
92 mooseError(
"Please specify secondary node ids or boundary id.");
95 std::vector<dof_id_type> nodelist =
97 std::vector<dof_id_type>::iterator in;
103 in = std::min_element(nodelist.begin(), nodelist.end());
104 dof_id_type node_id = (in == nodelist.end()) ? DofObject::invalid_id : *in;
112 for (in = nodelist.begin(); in != nodelist.end(); ++in)
138 bool found_elems = (node_to_elem_pair != node_to_elem_map.end());
147 bool someone_found_elems = found_elems;
149 mooseAssert(someone_found_elems,
"Missing entry in node to elem map");
152 std::set<Elem *, CompareElemsByLevel> primary_elems_to_ghost;
153 std::set<Node *> nodes_to_ghost;
161 primary_elems_to_ghost.insert(elem);
163 const unsigned int n_nodes = elem->n_nodes();
164 for (
unsigned int n = 0; n !=
n_nodes; ++n)
165 nodes_to_ghost.insert(elem->node_ptr(n));
172 nodes_to_ghost.begin(),
173 nodes_to_ghost.end(),
177 primary_elems_to_ghost.begin(),
178 primary_elems_to_ghost.end(),
186 found_elems = (node_to_elem_pair != new_node_to_elem_map.end());
190 mooseError(
"Couldn't find any elements connected to primary node");
192 const std::vector<dof_id_type> & elems = node_to_elem_pair->second;
194 if (elems.size() == 0)
195 mooseError(
"Couldn't find any elements connected to primary node");
MooseMesh & _mesh
Reference to this Kernel's mesh object.
unsigned int _primary_node_id
void updateConstrainedNodes()
Update the sets of nodes with constrained DOFs.
const VariableValue & _u_primary
Holds the current solution at the current quadrature point.
virtual void meshChanged() override
Called on this object when the mesh changes.
virtual const Node * queryNodePtr(const dof_id_type i) const
const VariableValue & _u_secondary
Value of the unknown variable this BC is action on.
std::vector< unsigned int > _secondary_node_ids
const Parallel::Communicator & _communicator
static InputParameters validParams()
virtual const Node & nodeRef(const dof_id_type i) const
unsigned int _i
Counter for primary and secondary nodes.
auto max(const L &left, const R &right)
virtual Elem * queryElemPtr(const dof_id_type i)
std::vector< dof_id_type > _primary_node_vector
node IDs of the primary node
const dof_id_type n_nodes
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
void min(const T &r, T &o, Request &req) const
std::vector< dof_id_type > _connected_nodes
node IDs connected to the primary node (secondary nodes)
SubProblem & _subproblem
Reference to this kernel's SubProblem.
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.
void update()
Calls buildNodeListFromSideList(), buildNodeList(), and buildBndElemList().
const std::string & type() const
Get the type of this class.
registerMooseObject("MooseApp", EqualValueBoundaryConstraint)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
EqualValueBoundaryConstraint(const InputParameters ¶meters)
virtual void addGhostedElem(dof_id_type elem_id)=0
Will make sure that all dofs connected to elem_id are ghosted to this processor.
virtual Real computeQpJacobian(Moose::ConstraintJacobianType type) override
Computes the jacobian for the constraint.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
BoundaryName _secondary_node_set_id
virtual Real computeQpResidual(Moose::ConstraintType type) override
Computes the residual for the current secondary node.
processor_id_type processor_id() const
void ErrorVector unsigned int
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
Get the associated BoundaryID for the boundary name.
const std::map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected...