www.mooseframework.org
DiracKernel.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef DIRACKERNEL_H
16 #define DIRACKERNEL_H
17 
18 // MOOSE includes
19 #include "DiracKernelInfo.h"
20 #include "MooseObject.h"
21 #include "SetupInterface.h"
23 #include "FunctionInterface.h"
24 #include "UserObjectInterface.h"
26 #include "TransientInterface.h"
27 #include "PostprocessorInterface.h"
29 #include "MooseVariable.h"
30 #include "Restartable.h"
31 #include "ZeroInterface.h"
32 #include "MeshChangedInterface.h"
33 
34 // Forward Declarations
35 class Assembly;
36 class DiracKernel;
37 class SubProblem;
38 class MooseMesh;
39 
40 template <>
42 
50 class DiracKernel : public MooseObject,
51  public SetupInterface,
53  public FunctionInterface,
54  public UserObjectInterface,
55  public TransientInterface,
58  protected GeometricSearchInterface,
59  public Restartable,
60  public ZeroInterface,
62 {
63 public:
65  virtual ~DiracKernel() {}
66 
70  virtual void computeResidual();
71 
75  virtual void computeJacobian();
76 
80  virtual Real computeQpOffDiagJacobian(unsigned int jvar);
81 
85  virtual void computeOffDiagJacobian(unsigned int jvar);
86 
91 
96 
101  virtual void addPoints() = 0;
102 
106  bool hasPointsOnElem(const Elem * elem);
107 
111  bool isActiveAtPoint(const Elem * elem, const Point & p);
112 
116  void clearPoints();
117 
123  virtual void meshChanged() override;
124 
125 protected:
129  virtual Real computeQpResidual() = 0;
130 
134  virtual Real computeQpJacobian();
135 
140  void addPoint(const Elem * elem, Point p, unsigned id = libMesh::invalid_uint);
141 
148  const Elem * addPoint(Point p, unsigned id = libMesh::invalid_uint);
149 
156  unsigned currentPointCachedID();
157 
160 
162 
164 
167 
170 
173 
177 
180 
183 
185  const Elem *& _current_elem;
186 
188  unsigned int _qp;
194  QBase *& _qrule;
197 
199  unsigned int _i, _j;
200 
201  // shape functions
202 
207 
208  // test functions
209 
214 
216  const VariableValue & _u;
219 
224 
227 
228 private:
231  typedef std::map<unsigned, std::pair<const Elem *, Point>> point_cache_t;
232  point_cache_t _point_cache;
233 
237  typedef std::map<const Elem *, std::vector<std::pair<Point, unsigned>>> reverse_cache_t;
238  reverse_cache_t _reverse_point_cache;
239 
245  void updateCaches(const Elem * old_elem, const Elem * new_elem, Point p, unsigned id);
246 
249  const Elem * addPointWithValidId(Point p, unsigned id);
250 };
251 
252 #endif
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
Definition: DiracKernel.h:196
unsigned int _qp
Quadrature point index.
Definition: DiracKernel.h:188
A class for creating restricted objects.
Definition: Restartable.h:31
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:397
reverse_cache_t _reverse_point_cache
Definition: DiracKernel.h:238
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
This gets called by computeOffDiagJacobian() at each quadrature point.
Definition: DiracKernel.C:182
const VariablePhiGradient & _grad_phi
Gradients of shape functions at QPs.
Definition: DiracKernel.h:206
Keeps track of stuff related to assembling.
Definition: Assembly.h:63
SystemBase & _sys
Definition: DiracKernel.h:159
Class for stuff related to variables.
Definition: MooseVariable.h:43
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:451
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:188
MooseMesh & _mesh
Mesh this kernels acts on.
Definition: DiracKernel.h:169
THREAD_ID _tid
Definition: DiracKernel.h:161
const bool _drop_duplicate_points
drop duplicate points or consider them in residual and Jacobian
Definition: DiracKernel.h:226
const Elem * addPointWithValidId(Point p, unsigned id)
A helper function for addPoint(Point, id) for when id != invalid_uint.
Definition: DiracKernel.C:217
virtual void computeResidual()
Computes the residual for the current element.
Definition: DiracKernel.C:95
bool isActiveAtPoint(const Elem *elem, const Point &p)
Whether or not this DiracKernel has something to distribute at this Point.
Definition: DiracKernel.C:426
MooseVariable & _var
Variable this kernel acts on.
Definition: DiracKernel.h:166
point_cache_t _point_cache
Definition: DiracKernel.h:232
DiracKernel(const InputParameters &parameters)
Definition: DiracKernel.C:54
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Assembly & _assembly
Definition: DiracKernel.h:163
const VariableTestGradient & _grad_test
Gradients of test functions at QPs.
Definition: DiracKernel.h:213
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:237
Base class for a system (of equations)
Definition: SystemBase.h:91
DiracKernelInfo & _dirac_kernel_info
Place for storing Point/Elem information shared across all DiracKernel objects.
Definition: DiracKernel.h:176
const VariableGradient & _grad_u
Holds the solution gradient at the current quadrature points.
Definition: DiracKernel.h:218
bool hasPointsOnElem(const Elem *elem)
Whether or not this DiracKernel has something to distribute on this element.
Definition: DiracKernel.C:420
virtual void computeOffDiagJacobian(unsigned int jvar)
Computes the off-diagonal Jacobian for variable jvar.
Definition: DiracKernel.C:144
virtual Real computeQpJacobian()
This is the virtual that derived classes should override for computing the Jacobian.
Definition: DiracKernel.C:176
Interface for objects that needs transient capabilities.
unsigned int _j
Definition: DiracKernel.h:199
const Moose::CoordinateSystemType & _coord_sys
Coordinate system.
Definition: DiracKernel.h:172
virtual ~DiracKernel()
Definition: DiracKernel.h:65
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:36
DiracKernelInfo _local_dirac_kernel_info
Place for storing Point/Elem information only for this DiracKernel.
Definition: DiracKernel.h:179
const MooseArray< Point > & _physical_point
Physical points.
Definition: DiracKernel.h:192
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:457
Interface for objects that need to use UserObjects.
MooseVariable & variable()
The variable number that this kernel operates on.
Definition: DiracKernel.C:445
CoordinateSystemType
Definition: MooseTypes.h:212
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:231
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:26
Point _current_point
The current point.
Definition: DiracKernel.h:182
const VariableTestValue & _test
Values of test functions at QPs.
Definition: DiracKernel.h:211
unsigned int _i
i-th, j-th index for enumerating shape and test functions
Definition: DiracKernel.h:199
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:438
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:53
Interface to bring zero values inside objects.
Definition: ZeroInterface.h:35
An interface for accessing Materials.
QBase *& _qrule
Quadrature rule.
Definition: DiracKernel.h:194
const VariablePhiValue & _phi
Values of shape functions at QPs.
Definition: DiracKernel.h:204
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:53
const VariableValue & _u
Holds the solution at current quadrature points.
Definition: DiracKernel.h:216
const VariableValue & _du_dot_du
Derivative of u_dot wrt u.
Definition: DiracKernel.h:223
const Elem *& _current_elem
Definition: DiracKernel.h:185
virtual void computeJacobian()
Computes the jacobian for the current element.
Definition: DiracKernel.C:119
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:50
SubProblem & _subproblem
Definition: DiracKernel.h:158
const VariableValue & _u_dot
Time derivative of the solution.
Definition: DiracKernel.h:221
Interface class for classes which interact with Postprocessors.
void clearPoints()
Remove all of the current points and elements.
Definition: DiracKernel.C:432
unsigned int THREAD_ID
Definition: MooseTypes.h:79
const MooseArray< Point > & _q_point
Quadrature points.
Definition: DiracKernel.h:190