https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NodeFaceConstraint.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// libMesh forward declarations
17namespace libMesh
18{
19template <typename T>
20class SparseMatrix;
21}
22
35{
36public:
38
40 virtual ~NodeFaceConstraint();
41
45 virtual void computeSecondaryValue(NumericVector<Number> & current_solution);
46
50 virtual void computeResidual() override;
51
55 virtual void computeJacobian() override;
56
60 virtual void computeOffDiagJacobian(unsigned int jvar) override;
61
65 virtual void getConnectedDofIndices(unsigned int var_num);
66
72 virtual bool shouldApply() { return true; }
73
80 virtual bool overwriteSecondaryResidual();
81
89
94
99
104
108 const MooseVariable & variable() const override { return _var; }
109
110 Real secondaryResidual() const;
111
112 void residualSetup() override;
113
117 virtual const std::unordered_set<unsigned int> & getMatPropDependencies() const;
118
122 virtual bool isExplicitConstraint() const { return false; }
123
127 virtual void overwriteBoundaryVariables(NumericVector<Number> & /*soln*/,
128 const Node & /*secondary_node*/) const
129 {
130 }
131
135 std::set<SubdomainID> getSecondaryConnectedBlocks() const;
136
137protected:
138 // TODO: Make this protected or add an accessor
139 // Do the same for all the other public members
140 const SparseMatrix<Number> * _jacobian;
141
145 virtual Real computeQpSecondaryValue() = 0;
146
152
158
163 unsigned int /*jvar*/)
164 {
165 return 0;
166 }
167
169 virtual const VariableValue & coupledSecondaryValue(const std::string & var_name,
170 unsigned int comp = 0)
171 {
172 return coupledValue(var_name, comp);
173 }
174 virtual const VariableValue & coupledSecondaryValueOld(const std::string & var_name,
175 unsigned int comp = 0)
176 {
177 return coupledValueOld(var_name, comp);
178 }
179 virtual const VariableValue & coupledSecondaryValueOlder(const std::string & var_name,
180 unsigned int comp = 0)
181 {
182 return coupledValueOlder(var_name, comp);
183 }
184
185 virtual const VariableGradient & coupledSecondaryGradient(const std::string & var_name,
186 unsigned int comp = 0)
187 {
188 return coupledGradient(var_name, comp);
189 }
190 virtual const VariableGradient & coupledSecondaryGradientOld(const std::string & var_name,
191 unsigned int comp = 0)
192 {
193 return coupledGradientOld(var_name, comp);
194 }
195 virtual const VariableGradient & coupledSecondaryGradientOlder(const std::string & var_name,
196 unsigned int comp = 0)
197 {
198 return coupledGradientOlder(var_name, comp);
199 }
200
201 virtual const VariableSecond & coupledSecondarySecond(const std::string & var_name,
202 unsigned int comp = 0)
203 {
204 return coupledSecond(var_name, comp);
205 }
206
207 virtual const VariableValue & coupledPrimaryValue(const std::string & var_name,
208 unsigned int comp = 0)
209 {
210 return coupledNeighborValue(var_name, comp);
211 }
212 virtual const VariableValue & coupledPrimaryValueOld(const std::string & var_name,
213 unsigned int comp = 0)
214 {
215 return coupledNeighborValueOld(var_name, comp);
216 }
217 virtual const VariableValue & coupledPrimaryValueOlder(const std::string & var_name,
218 unsigned int comp = 0)
219 {
220 return coupledNeighborValueOlder(var_name, comp);
221 }
222
223 virtual const VariableGradient & coupledPrimaryGradient(const std::string & var_name,
224 unsigned int comp = 0)
225 {
226 return coupledNeighborGradient(var_name, comp);
227 }
228 virtual const VariableGradient & coupledPrimaryGradientOld(const std::string & var_name,
229 unsigned int comp = 0)
230 {
231 return coupledNeighborGradientOld(var_name, comp);
232 }
233 virtual const VariableGradient & coupledPrimaryGradientOlder(const std::string & var_name,
234 unsigned int comp = 0)
235 {
236 return coupledNeighborGradientOlder(var_name, comp);
237 }
238
239 virtual const VariableSecond & coupledPrimarySecond(const std::string & var_name,
240 unsigned int comp = 0)
241 {
242 return coupledNeighborSecond(var_name, comp);
243 }
244
249 const std::set<BoundaryID> & buildBoundaryIDs();
250
255
257
259 const QBase * const & _primary_qrule;
260
262 std::set<BoundaryID> _boundary_ids;
263
265
267 const Node * const & _current_node;
268 const Elem * const & _current_primary;
269
276
279
281 unsigned int _primary_var_num;
282
287
292
297
299 const DofMap & _dof_map;
300
301 const std::unordered_map<dof_id_type, std::vector<dof_id_type>> & _node_to_elem_map;
302
310
313
316
319
321 const std::unordered_set<unsigned int> _empty_mat_prop_deps;
322
323 std::vector<dof_id_type> _connected_dof_indices;
324
329 DenseMatrix<Number> _Kne;
330
337 DenseMatrix<Number> _Kee;
338
343 DenseMatrix<Number> _Ken;
344
346};
347
348inline const std::unordered_set<unsigned int> &
boundary_id_type BoundaryID
OutputTools< Real >::VariablePhiValue VariablePhiValue
Definition MooseTypes.h:353
OutputTools< Real >::VariableTestValue VariableTestValue
Definition MooseTypes.h:358
OutputTools< Real >::VariableGradient VariableGradient
Definition MooseTypes.h:349
OutputTools< Real >::VariableTestGradient VariableTestGradient
Definition MooseTypes.h:359
OutputTools< Real >::VariableValue VariableValue
Definition MooseTypes.h:348
OutputTools< Real >::VariablePhiGradient VariablePhiGradient
Definition MooseTypes.h:354
OutputTools< Real >::VariableSecond VariableSecond
Definition MooseTypes.h:350
Base class for all Constraint types.
Definition Constraint.h:20
virtual const VariableGradient & coupledGradientOlder(const std::string &var_name, unsigned int comp=0) const
Returns an old gradient from two time steps previous of a coupled variable.
virtual const VariableValue & coupledValueOld(const std::string &var_name, unsigned int comp=0) const
Returns an old value from previous time step of a coupled variable.
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0) const
Returns value of a coupled variable.
Definition Coupleable.C:528
virtual const VariableValue & coupledValueOlder(const std::string &var_name, unsigned int comp=0) const
Returns an old value from two time steps previous of a coupled variable.
virtual const VariableSecond & coupledSecond(const std::string &var_name, unsigned int comp=0) const
Returns second spatial derivatives of a coupled variable.
virtual const VariableGradient & coupledGradient(const std::string &var_name, unsigned int comp=0) const
Returns gradient of a coupled variable.
virtual const VariableGradient & coupledGradientOld(const std::string &var_name, unsigned int comp=0) const
Returns an old gradient from previous time step of a coupled variable.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
forward declarations
Definition MooseArray.h:18
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
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
virtual const VariableValue & coupledNeighborValue(const std::string &var_name, unsigned int comp=0) const
virtual const VariableValue & coupledNeighborValueOld(const std::string &var_name, unsigned int comp=0) const
virtual const VariableValue & coupledNeighborValueOlder(const std::string &var_name, unsigned int comp=0) const
virtual const VariableGradient & coupledNeighborGradientOld(const std::string &var_name, unsigned int comp=0) const
virtual const VariableSecond & coupledNeighborSecond(const std::string &var_name, unsigned int i=0) const
virtual const VariableGradient & coupledNeighborGradientOlder(const std::string &var_name, unsigned int comp=0) const
virtual const VariableGradient & coupledNeighborGradient(const std::string &var_name, unsigned int comp=0) const
Enhances MooseVariableInterface interface provide values from neighbor elements.
A NodeFaceConstraint is used when you need to create constraints between two surfaces in a mesh.
virtual const VariableGradient & coupledPrimaryGradientOlder(const std::string &var_name, unsigned int comp=0)
std::set< SubdomainID > getSecondaryConnectedBlocks() const
const VariableGradient & _grad_u_primary
Holds the current solution gradient at the current quadrature point.
PenetrationLocator & _penetration_locator
unsigned int _primary_var_num
Number for the primary variable.
virtual const VariableValue & coupledPrimaryValue(const std::string &var_name, unsigned int comp=0)
const std::unordered_set< unsigned int > _empty_mat_prop_deps
An empty material property dependency set for use with getMatPropDependencies.
const Node *const & _current_node
current node being processed
virtual MooseVariable & primaryVariable()
The variable on the Primary side of the domain.
virtual const VariableSecond & coupledPrimarySecond(const std::string &var_name, unsigned int comp=0)
virtual Real computeQpSecondaryValue()=0
Compute the value the secondary node should have at the beginning of a timestep.
const MooseArray< Point > & _primary_q_point
virtual const VariableGradient & coupledSecondaryGradientOlder(const std::string &var_name, unsigned int comp=0)
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...
const Elem *const & _current_primary
const VariableTestGradient & _grad_test_primary
Gradient of side shape function.
virtual const VariableValue & coupledPrimaryValueOld(const std::string &var_name, unsigned int comp=0)
std::vector< dof_id_type > _connected_dof_indices
virtual const VariableValue & coupledPrimaryValueOlder(const std::string &var_name, unsigned int comp=0)
virtual void overwriteBoundaryVariables(NumericVector< Number > &, const Node &) const
Allows for overwriting boundary variables (explicit dynamics contact).
BoundaryID secondaryBoundary() const
The secondary boundary ID 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...
virtual bool isExplicitConstraint() const
Whether (contact) constraint is of 'explicit dynamics' type.
virtual bool shouldApply()
Whether or not this constraint should be applied.
const QBase *const & _primary_qrule
const VariableTestValue & _test_primary
Side test function.
bool _overwrite_secondary_residual
Whether or not the secondary's residual should be overwritten.
virtual const VariableValue & coupledSecondaryValueOlder(const std::string &var_name, unsigned int comp=0)
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...
virtual void computeJacobian() override
Computes the jacobian for the current element.
const SparseMatrix< Number > * _jacobian
static InputParameters validParams()
virtual const std::unordered_set< unsigned int > & getMatPropDependencies() const
virtual const VariableGradient & coupledSecondaryGradient(const std::string &var_name, unsigned int comp=0)
const std::set< BoundaryID > & buildBoundaryIDs()
Builds the _boundary_ids data member and returns it.
virtual const VariableGradient & coupledPrimaryGradient(const std::string &var_name, unsigned int comp=0)
virtual const VariableGradient & coupledSecondaryGradientOld(const std::string &var_name, unsigned int comp=0)
const VariableValue & _u_secondary
Value of the unknown variable this BC is action on.
virtual void computeResidual() override
Computes the residual Nodal residual.
const VariablePhiValue & _phi_primary
Side shape function.
virtual const VariableValue & coupledSecondaryValueOld(const std::string &var_name, unsigned int comp=0)
const DofMap & _dof_map
DOF map.
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.
BoundaryID primaryBoundary() const
The primary boundary ID for this constraint.
const VariableValue & _u_primary
Holds the current solution at the current quadrature point.
MooseVariable & _primary_var
Primary side variable.
virtual const VariableSecond & coupledSecondarySecond(const std::string &var_name, unsigned int comp=0)
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 const VariableValue & coupledSecondaryValue(const std::string &var_name, unsigned int comp=0)
coupling interface:
const std::unordered_map< dof_id_type, std::vector< dof_id_type > > & _node_to_elem_map
const MooseArray< Real > & _primary_JxW
JxW on the primary face.
const MooseVariable & variable() const override
The variable number that this object operates on.
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 > &current_solution)
Compute the value the secondary node should have at the beginning of a timestep.
virtual bool overwriteSecondaryJacobian()
Whether or not the secondary's Jacobian row should be overwritten.
BoundaryID _primary
Boundary ID for the primary surface.
bool _secondary_residual_computed
Whether the secondary residual has been computed.
virtual const VariableGradient & coupledPrimaryGradientOld(const std::string &var_name, unsigned int comp=0)
const VariablePhiGradient & _grad_phi_primary
Gradient of side shape function.
Nonlinear system to be solved.
ConstraintType
Definition MooseTypes.h:812
ConstraintJacobianType
Definition MooseTypes.h:851
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...