www.mooseframework.org
NodeFaceConstraint.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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
17 namespace libMesh
18 {
19 template <typename T>
20 class SparseMatrix;
21 }
22 
35 {
36 public:
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 
93  virtual MooseVariable & primaryVariable() { return _primary_var; }
94 
98  BoundaryID primaryBoundary() const { return _primary; }
99 
104 
108  const MooseVariable & variable() const override { return _var; }
109 
110  // TODO: Make this protected or add an accessor
111  // Do the same for all the other public members
113 
114  Real secondaryResidual() const;
115 
116  void residualSetup() override;
117 
121  virtual const std::unordered_set<unsigned int> & getMatPropDependencies() const;
122 
126  virtual bool isExplicitConstraint() const { return false; }
127 
132  const Node & /*secondary_node*/) const
133  {
134  }
135 
139  std::set<SubdomainID> getSecondaryConnectedBlocks() const;
140 
141 protected:
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::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 
330 
338 
344 
345  friend class NonlinearSystemBase;
346 };
347 
348 inline const std::unordered_set<unsigned int> &
350 {
351  return _empty_mat_prop_deps;
352 }
virtual const VariableValue & coupledSecondaryValueOld(const std::string &var_name, unsigned int comp=0)
bool _secondary_residual_computed
Whether the secondary residual has been computed.
virtual const VariableGradient & coupledSecondaryGradientOlder(const std::string &var_name, unsigned int comp=0)
OutputTools< Real >::VariableGradient VariableGradient
Definition: MooseTypes.h:303
BoundaryID _secondary
Boundary ID for the secondary surface.
virtual void computeResidual() override
Computes the residual Nodal residual.
const VariableValue & _u_primary
Holds the current solution at the current quadrature point.
virtual bool isExplicitConstraint() const
Whether (contact) constraint is of &#39;explicit dynamics&#39; type.
virtual const VariableValue & coupledPrimaryValueOlder(const std::string &var_name, unsigned int comp=0)
ConstraintType
Definition: MooseTypes.h:670
virtual const VariableSecond & coupledSecond(const std::string &var_name, unsigned int comp=0) const
Returns second spatial derivatives of a coupled variable.
Definition: Coupleable.C:1774
virtual const VariableGradient & coupledPrimaryGradientOld(const std::string &var_name, unsigned int comp=0)
virtual void computeSecondaryValue(NumericVector< Number > &current_solution)
Compute the value the secondary node should have at the beginning of a timestep.
Class for stuff related to variables.
Definition: Adaptivity.h:31
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
virtual const VariableGradient & coupledSecondaryGradientOld(const std::string &var_name, unsigned int comp=0)
unsigned int _primary_var_num
Number for the primary variable.
virtual const VariableGradient & coupledPrimaryGradient(const std::string &var_name, unsigned int comp=0)
MooseVariable & _var
virtual Real computeQpResidual(Moose::ConstraintType type)=0
This is the virtual that derived classes should override for computing the residual on neighboring el...
BoundaryID primaryBoundary() const
The primary boundary ID for this constraint.
virtual const VariableValue & coupledSecondaryValueOlder(const std::string &var_name, unsigned int comp=0)
MooseVariable & _primary_var
Primary side variable.
const Elem *const & _current_primary
std::set< SubdomainID > getSecondaryConnectedBlocks() const
virtual const VariableGradient & coupledNeighborGradient(const std::string &var_name, unsigned int comp=0) const
virtual const VariableGradient & coupledSecondaryGradient(const std::string &var_name, unsigned int comp=0)
Base class for all Constraint types.
Definition: Constraint.h:19
virtual const VariableValue & coupledNeighborValueOlder(const std::string &var_name, unsigned int comp=0) const
DenseMatrix< Number > _Kne
The Jacobian corresponding to the derivatives of the neighbor/primary residual with respect to the el...
virtual const VariableGradient & coupledNeighborGradientOld(const std::string &var_name, unsigned int comp=0) const
const std::map< dof_id_type, std::vector< dof_id_type > > & _node_to_elem_map
Real secondaryResidual() const
virtual const VariableSecond & coupledSecondarySecond(const std::string &var_name, unsigned int comp=0)
DenseMatrix< Number > _Ken
The Jacobian corresponding to the derivatives of the elemental/secondary residual with respect to the...
virtual bool overwriteSecondaryJacobian()
Whether or not the secondary&#39;s Jacobian row should be overwritten.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
const DofMap & _dof_map
DOF map.
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.
Definition: Coupleable.C:985
const MooseArray< Real > & _primary_JxW
JxW on the primary face.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const VariableTestValue & _test_primary
Side test function.
const VariableTestGradient & _grad_test_primary
Gradient of side shape function.
virtual const VariableGradient & coupledGradient(const std::string &var_name, unsigned int comp=0) const
Returns gradient of a coupled variable.
Definition: Coupleable.C:1481
SparseMatrix< Number > * _jacobian
void residualSetup() override
Gets called just before the residual is computed and before this object is asked to do its job...
const Node *const & _current_node
current node being processed
DenseMatrix< Number > _Kee
The Jacobian corresponding to the derivatives of the elemental/secondary residual with respect to the...
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.
Definition: Coupleable.C:1007
virtual void overwriteBoundaryVariables(NumericVector< Number > &, const Node &) const
Allows for overwriting boundary variables (explicit dynamics contact).
Nonlinear system to be solved.
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0) const
Returns value of a coupled variable.
Definition: Coupleable.C:482
virtual const VariableGradient & coupledPrimaryGradientOlder(const std::string &var_name, unsigned int comp=0)
NodeFaceConstraint(const InputParameters &parameters)
Enhances MooseVariableInterface interface provide values from neighbor elements.
const MooseArray< Point > & _primary_q_point
virtual void computeJacobian() override
Computes the jacobian for the current element.
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.
Definition: Coupleable.C:1497
virtual const VariableValue & coupledNeighborValue(const std::string &var_name, unsigned int comp=0) const
std::set< BoundaryID > _boundary_ids
the union of the secondary and primary boundary ids
OutputTools< Real >::VariableTestValue VariableTestValue
Definition: MooseTypes.h:312
boundary_id_type BoundaryID
A NodeFaceConstraint is used when you need to create constraints between two surfaces in a mesh...
virtual void getConnectedDofIndices(unsigned int var_num)
Gets the indices for all dofs connected to the constraint.
virtual MooseVariable & primaryVariable()
The variable on the Primary side of the domain.
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
const VariableGradient & _grad_u_primary
Holds the current solution gradient at the current quadrature point.
const VariableValue & _u_secondary
Value of the unknown variable this BC is action on.
virtual const std::unordered_set< unsigned int > & getMatPropDependencies() const
virtual const VariableGradient & coupledNeighborGradientOlder(const std::string &var_name, unsigned int comp=0) const
Real _secondary_residual
The value of the secondary residual.
virtual const VariableValue & coupledPrimaryValue(const std::string &var_name, unsigned int comp=0)
const std::set< BoundaryID > & buildBoundaryIDs()
Builds the _boundary_ids data member and returns it.
const MooseVariable & variable() const override
The variable number that this object operates on.
virtual const VariableValue & coupledSecondaryValue(const std::string &var_name, unsigned int comp=0)
coupling interface:
virtual void computeOffDiagJacobian(unsigned int jvar) override
Computes d-residual / d-jvar...
VariableTestValue _test_secondary
Shape function on the secondary side. This will always only have one entry and that entry will always...
OutputTools< Real >::VariableValue VariableValue
Definition: MooseTypes.h:302
OutputTools< Real >::VariablePhiGradient VariablePhiGradient
Definition: MooseTypes.h:308
virtual Real computeQpSecondaryValue()=0
Compute the value the secondary node should have at the beginning of a timestep.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const VariablePhiGradient & _grad_phi_primary
Gradient of side shape function.
virtual bool shouldApply()
Whether or not this constraint should be applied.
ConstraintJacobianType
Definition: MooseTypes.h:709
const QBase *const & _primary_qrule
std::vector< dof_id_type > _connected_dof_indices
virtual const VariableSecond & coupledPrimarySecond(const std::string &var_name, unsigned int comp=0)
const InputParameters & parameters() const
Get the parameters of the object.
const VariablePhiValue & _phi_primary
Side shape function.
BoundaryID _primary
Boundary ID for the primary surface.
bool _overwrite_secondary_residual
Whether or not the secondary&#39;s residual should be overwritten.
OutputTools< Real >::VariableSecond VariableSecond
Definition: MooseTypes.h:304
virtual const VariableValue & coupledNeighborValueOld(const std::string &var_name, unsigned int comp=0) const
VariablePhiValue _phi_secondary
Shape function on the secondary side. This will always.
PenetrationLocator & _penetration_locator
OutputTools< Real >::VariableTestGradient VariableTestGradient
Definition: MooseTypes.h:313
BoundaryID secondaryBoundary() const
The secondary boundary ID for this constraint.
virtual bool overwriteSecondaryResidual()
Whether or not the secondary&#39;s residual should be overwritten.
virtual Real computeQpJacobian(Moose::ConstraintJacobianType type)=0
This is the virtual that derived classes should override for computing the Jacobian on neighboring el...
virtual Real computeQpOffDiagJacobian(Moose::ConstraintJacobianType, unsigned int)
This is the virtual that derived classes should override for computing the off-diag Jacobian...
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.
Definition: Coupleable.C:1513
const std::unordered_set< unsigned int > _empty_mat_prop_deps
An empty material property dependency set for use with getMatPropDependencies.
virtual const VariableValue & coupledPrimaryValueOld(const std::string &var_name, unsigned int comp=0)
virtual const VariableSecond & coupledNeighborSecond(const std::string &var_name, unsigned int i=0) const