www.mooseframework.org
DiracKernel.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 "DiracKernelInfo.h"
14 #include "MooseObject.h"
15 #include "SetupInterface.h"
17 #include "FunctionInterface.h"
18 #include "UserObjectInterface.h"
20 #include "TransientInterface.h"
21 #include "PostprocessorInterface.h"
23 #include "MooseVariableFE.h"
24 #include "Restartable.h"
25 #include "MeshChangedInterface.h"
26 #include "MooseVariableInterface.h"
27 #include "TaggingInterface.h"
28 
29 // Forward Declarations
30 class Assembly;
31 class DiracKernel;
32 class SubProblem;
33 class MooseMesh;
34 
35 template <>
37 
45 class DiracKernel : public MooseObject,
46  public SetupInterface,
48  public MooseVariableInterface<Real>,
49  public FunctionInterface,
50  public UserObjectInterface,
51  public TransientInterface,
54  protected GeometricSearchInterface,
55  public Restartable,
56  public MeshChangedInterface,
57  public TaggingInterface
58 {
59 public:
61  virtual ~DiracKernel() {}
62 
66  virtual void computeResidual();
67 
71  virtual void computeJacobian();
72 
76  virtual Real computeQpOffDiagJacobian(unsigned int jvar);
77 
81  virtual void computeOffDiagJacobian(unsigned int jvar);
82 
87 
92 
97  virtual void addPoints() = 0;
98 
102  bool hasPointsOnElem(const Elem * elem);
103 
107  bool isActiveAtPoint(const Elem * elem, const Point & p);
108 
112  void clearPoints();
113 
119  virtual void meshChanged() override;
120 
121 protected:
125  virtual Real computeQpResidual() = 0;
126 
130  virtual Real computeQpJacobian();
131 
136  void addPoint(const Elem * elem, Point p, unsigned id = libMesh::invalid_uint);
137 
144  const Elem * addPoint(Point p, unsigned id = libMesh::invalid_uint);
145 
152  unsigned currentPointCachedID();
153 
156 
158 
160 
163 
166 
169 
173 
176 
179 
181  const Elem * const & _current_elem;
182 
184  unsigned int _qp;
190  const QBase * const & _qrule;
193 
195  unsigned int _i, _j;
196 
197  // shape functions
198 
203 
204  // test functions
205 
210 
212  const VariableValue & _u;
215 
218 
219 private:
222  typedef std::map<unsigned, std::pair<const Elem *, Point>> point_cache_t;
224 
228  typedef std::map<const Elem *, std::vector<std::pair<Point, unsigned>>> reverse_cache_t;
230 
236  void updateCaches(const Elem * old_elem, const Elem * new_elem, Point p, unsigned id);
237 
240  const Elem * addPointWithValidId(Point p, unsigned id);
241 };
242 
OutputTools< Real >::VariableGradient VariableGradient
Definition: MooseTypes.h:198
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
Definition: DiracKernel.h:192
unsigned int _qp
Quadrature point index.
Definition: DiracKernel.h:184
A class for creating restricted objects.
Definition: Restartable.h:29
The DiracKernelInfo object is a place where all the Dirac points added by different DiracKernels are ...
unsigned currentPointCachedID()
Returns the user-assigned ID of the current Dirac point if it exits, and libMesh::invalid_uint otherw...
Definition: DiracKernel.C:404
reverse_cache_t _reverse_point_cache
Definition: DiracKernel.h:229
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
This gets called by computeOffDiagJacobian() at each quadrature point.
Definition: DiracKernel.C:189
const VariablePhiGradient & _grad_phi
Gradients of shape functions at QPs.
Definition: DiracKernel.h:202
Keeps track of stuff related to assembling.
Definition: Assembly.h:62
SystemBase & _sys
Definition: DiracKernel.h:155
virtual Real computeQpResidual()=0
This is the virtual that derived classes should override for computing the residual.
SubProblem & subProblem()
Return a reference to the subproblem.
Definition: DiracKernel.C:458
void addPoint(const Elem *elem, Point p, unsigned id=libMesh::invalid_uint)
Add the physical x,y,z point located in the element "elem" to the list of points this DiracKernel wil...
Definition: DiracKernel.C:195
MooseMesh & _mesh
Mesh this kernels acts on.
Definition: DiracKernel.h:165
THREAD_ID _tid
Definition: DiracKernel.h:157
const bool _drop_duplicate_points
drop duplicate points or consider them in residual and Jacobian
Definition: DiracKernel.h:217
const Elem * addPointWithValidId(Point p, unsigned id)
A helper function for addPoint(Point, id) for when id != invalid_uint.
Definition: DiracKernel.C:224
virtual void computeResidual()
Computes the residual for the current element.
Definition: DiracKernel.C:96
bool isActiveAtPoint(const Elem *elem, const Point &p)
Whether or not this DiracKernel has something to distribute at this Point.
Definition: DiracKernel.C:433
MooseVariable & _var
Variable this kernel acts on.
Definition: DiracKernel.h:162
point_cache_t _point_cache
Definition: DiracKernel.h:223
DiracKernel(const InputParameters &parameters)
Definition: DiracKernel.C:50
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Assembly & _assembly
Definition: DiracKernel.h:159
const VariableTestGradient & _grad_test
Gradients of test functions at QPs.
Definition: DiracKernel.h:209
std::map< const Elem *, std::vector< std::pair< Point, unsigned > > > reverse_cache_t
Map from Elem* to a list of (Dirac point, id) pairs which can be used in a user&#39;s computeQpResidual()...
Definition: DiracKernel.h:228
const Elem *const & _current_elem
Definition: DiracKernel.h:181
Base class for a system (of equations)
Definition: SystemBase.h:92
DiracKernelInfo & _dirac_kernel_info
Place for storing Point/Elem information shared across all DiracKernel objects.
Definition: DiracKernel.h:172
const VariableGradient & _grad_u
Holds the solution gradient at the current quadrature points.
Definition: DiracKernel.h:214
bool hasPointsOnElem(const Elem *elem)
Whether or not this DiracKernel has something to distribute on this element.
Definition: DiracKernel.C:427
virtual void computeOffDiagJacobian(unsigned int jvar)
Computes the off-diagonal Jacobian for variable jvar.
Definition: DiracKernel.C:149
virtual Real computeQpJacobian()
This is the virtual that derived classes should override for computing the Jacobian.
Definition: DiracKernel.C:183
Interface for objects that needs transient capabilities.
unsigned int _j
Definition: DiracKernel.h:195
const Moose::CoordinateSystemType & _coord_sys
Coordinate system.
Definition: DiracKernel.h:168
virtual ~DiracKernel()
Definition: DiracKernel.h:61
Interface for notifications that the mesh has changed.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
OutputTools< Real >::VariableTestValue VariableTestValue
Definition: MooseTypes.h:205
DiracKernelInfo _local_dirac_kernel_info
Place for storing Point/Elem information only for this DiracKernel.
Definition: DiracKernel.h:175
const MooseArray< Point > & _physical_point
Physical points.
Definition: DiracKernel.h:188
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
void updateCaches(const Elem *old_elem, const Elem *new_elem, Point p, unsigned id)
This function is used internally when the Elem for a locally-cached point needs to be updated...
Definition: DiracKernel.C:464
const QBase *const & _qrule
Quadrature rule.
Definition: DiracKernel.h:190
Interface for objects that need to use UserObjects.
MooseVariable & variable()
The variable number that this kernel operates on.
Definition: DiracKernel.C:452
CoordinateSystemType
Definition: MooseTypes.h:556
std::map< unsigned, std::pair< const Elem *, Point > > point_cache_t
Data structure for caching user-defined IDs which can be mapped to specific std::pair<const Elem*...
Definition: DiracKernel.h:222
virtual void addPoints()=0
This is where the DiracKernel should call addPoint() for each point it needs to have a value distribu...
InputParameters validParams< DiracKernel >()
Definition: DiracKernel.C:21
Point _current_point
The current point.
Definition: DiracKernel.h:178
OutputTools< Real >::VariablePhiGradient VariablePhiGradient
Definition: MooseTypes.h:202
const VariableTestValue & _test
Values of test functions at QPs.
Definition: DiracKernel.h:207
unsigned int _i
i-th, j-th index for enumerating shape and test functions
Definition: DiracKernel.h:195
virtual void meshChanged() override
Clear point cache when the mesh changes, so that element coarsening, element deletion, and distributed mesh repartitioning don&#39;t leave this with an invalid cache.
Definition: DiracKernel.C:445
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:59
An interface for accessing Materials.
const VariablePhiValue & _phi
Values of shape functions at QPs.
Definition: DiracKernel.h:200
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
Interface for objects that need to get values of MooseVariables.
OutputTools< Real >::VariableTestGradient VariableTestGradient
Definition: MooseTypes.h:206
const VariableValue & _u
Holds the solution at current quadrature points.
Definition: DiracKernel.h:212
virtual void computeJacobian()
Computes the jacobian for the current element.
Definition: DiracKernel.C:122
Interface for objects that need to use functions.
A DiracKernel is used when you need to add contributions to the residual by means of multiplying some...
Definition: DiracKernel.h:45
SubProblem & _subproblem
Definition: DiracKernel.h:154
Interface class for classes which interact with Postprocessors.
void clearPoints()
Remove all of the current points and elements.
Definition: DiracKernel.C:439
unsigned int THREAD_ID
Definition: MooseTypes.h:161
const MooseArray< Point > & _q_point
Quadrature points.
Definition: DiracKernel.h:186