https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NodalConstraint.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12// MOOSE includes
13#include "Constraint.h"
15
16#include <map>
17#include <set>
18
19class MooseMesh;
20
24{
25public:
27
29
34 std::vector<dof_id_type> & getPrimaryNodeId() { return _primary_node_vector; }
35
40 std::vector<dof_id_type> & getSecondaryNodeId() { return _connected_nodes; }
41
51 virtual void updateConnectivity();
52
61
65 virtual void meshChanged() override { updateConstrainedNodes(); }
66
76
80 virtual void computeResidual() override final
81 {
82 mooseError("NodalConstraint do not need computeResidual()");
83 }
84 virtual void computeResidual(const NumericVector<Number> & residual);
85
89 virtual void computeJacobian() override final
90 {
91 mooseError("NodalConstraint do not need computeJacobian()");
92 }
93 virtual void computeJacobian(const SparseMatrix<Number> & jacobian);
94
98 const MooseVariable & variable() const override { return _var; }
99
100protected:
104 std::vector<dof_id_type> gatherAndRetainConnectedElems(MooseMesh & mesh,
105 const std::vector<dof_id_type> & node_ids);
106
111 void ghostConnectedElems(const std::vector<dof_id_type> & node_ids);
112
117 std::vector<dof_id_type> localSecondaryNodes(const std::vector<dof_id_type> & node_ids) const;
118
120 std::map<MooseMesh *, std::set<Elem *>> _retained_elems;
121
127
133
135
137
141 std::vector<dof_id_type> _connected_nodes;
143 std::vector<dof_id_type> _primary_node_vector;
152 std::vector<Real> _weights;
154 unsigned int _i;
155 unsigned int _j;
156};
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
OutputTools< Real >::VariableValue VariableValue
Definition MooseTypes.h:348
Base class for all Constraint types.
Definition Constraint.h:20
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
Enhances MooseVariableInterface interface provide values from neighbor elements.
virtual void computeResidual() override final
Computes the nodal residual.
Moose::ConstraintFormulationType _formulation
Specifies formulation type used to apply constraints.
std::vector< dof_id_type > localSecondaryNodes(const std::vector< dof_id_type > &node_ids) const
Select the nodes of 'node_ids' that this process owns, which are the secondary nodes it is responsibl...
unsigned int _i
Counter for primary and secondary nodes.
virtual void meshChanged() override
Rebuilds the constrained nodes, which the mesh change may have redistributed.
virtual Real computeQpResidual(Moose::ConstraintType type)=0
This is the virtual that derived classes should override for computing the residual on neighboring el...
std::vector< dof_id_type > _primary_node_vector
node IDs of the primary node
const MooseVariable & variable() const override
The variable number that this object operates on.
std::vector< dof_id_type > _connected_nodes
node IDs connected to the primary node (secondary nodes)
void updateConstrainedNodes()
Rebuild the constrained node lists and the ghosting they require.
std::vector< Real > _weights
When the secondary node is constrained to move as a linear combination of the primary 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.
std::map< MooseMesh *, std::set< Elem * > > _retained_elems
Elements this constraint retained on each distributed mesh during the previous mesh update.
static InputParameters validParams()
virtual void updateConnectivity()
Fill _primary_node_vector and _connected_nodes for this constraint.
virtual Real computeQpJacobian(Moose::ConstraintJacobianType type)=0
This is the virtual that derived classes should override for computing the Jacobian on neighboring el...
MooseVariable & _var
virtual void computeJacobian() override final
Computes the jacobian for the current element.
MooseVariable & _var_secondary
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.
std::vector< dof_id_type > & getSecondaryNodeId()
Get the list of connected secondary nodes.
void reinitConstraintNodes()
Reinitialize the primary and secondary nodes on the SubProblem that owns this constraint's variables.
std::vector< dof_id_type > & getPrimaryNodeId()
Get the list of primary nodes.
void ghostConnectedElems(const std::vector< dof_id_type > &node_ids)
Gather and retain one element per node on the reference mesh, and on the displaced mesh when one exis...
ConstraintFormulationType
Type of constraint formulation.
Definition MooseTypes.h:977
ConstraintType
Definition MooseTypes.h:817
ConstraintJacobianType
Definition MooseTypes.h:856