https://mooseframework.inl.gov
DiracKernelBase.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 "DiracKernelInfo.h"
14 #include "ResidualObject.h"
18 #include "MooseVariableField.h"
19 #include "MooseVariableInterface.h"
20 #include "BlockRestrictable.h"
21 
28  protected GeometricSearchInterface,
29  public BlockRestrictable
30 {
31 public:
33 
35 
39  virtual Real computeQpOffDiagJacobian(unsigned int jvar);
40 
44  virtual void computeOffDiagJacobian(unsigned int jvar) override = 0;
45 
50  virtual void addPoints() = 0;
51 
55  bool hasPointsOnElem(const Elem * elem);
56 
60  bool isActiveAtPoint(const Elem * elem, const Point & p);
61 
66  void clearPoints();
67 
71  void clearPointsCaches();
72 
78  virtual void meshChanged() override { clearPointsCaches(); };
79 
80 protected:
85  void addPoint(const Elem * elem, Point p, unsigned id = libMesh::invalid_uint);
86 
93  const Elem * addPoint(Point p, unsigned id = libMesh::invalid_uint);
94 
101  unsigned currentPointCachedID();
102 
104  const Elem * const & _current_elem;
105 
108 
112 
115 
118 
120  unsigned int _qp;
126  const QBase * const & _qrule;
129 
131  unsigned int _i, _j;
132 
135 
136  // @{ Point-not-found behavior
138  {
139  ERROR,
140  WARNING,
141  IGNORE
142  };
144  // @}
145 
148 
151  typedef std::map<unsigned, std::pair<const Elem *, Point>> point_cache_t;
153 
157  typedef std::map<const Elem *, std::vector<std::pair<Point, unsigned>>> reverse_cache_t;
159 
160 private:
166  void updateCaches(const Elem * old_elem, const Elem * new_elem, Point p, unsigned id);
167 
170  const Elem * addPointWithValidId(Point p, unsigned id);
171 };
const QBase *const & _qrule
Quadrature rule.
const bool _allow_moving_sources
Whether Dirac sources can move during the simulation.
bool hasPointsOnElem(const Elem *elem)
Whether or not this DiracKernel has something to distribute on this element.
const PointNotFoundBehavior _point_not_found_behavior
The DiracKernelInfo object is a place where all the Dirac points added by different DiracKernels are ...
const MooseArray< Point > & _q_point
Quadrature points.
const unsigned int invalid_uint
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()...
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.
void clearPoints()
Remove all of the current points and elements.
DiracKernelInfo & _dirac_kernel_info
Place for storing Point/Elem information shared across all DiracKernel objects.
point_cache_t _point_cache
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...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
unsigned currentPointCachedID()
Returns the user-assigned ID of the current Dirac point if it exits, and libMesh::invalid_uint otherw...
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*...
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
This gets called by computeOffDiagJacobian() at each quadrature point.
DiracKernelBase(const InputParameters &parameters)
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
static InputParameters validParams()
bool isActiveAtPoint(const Elem *elem, const Point &p)
Whether or not this DiracKernel has something to distribute at this Point.
const MooseArray< Point > & _physical_point
Physical points.
DiracKernelInfo _local_dirac_kernel_info
Place for storing Point/Elem information only for this DiracKernel.
const Elem *const & _current_elem
reverse_cache_t _reverse_point_cache
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This is the common base class for objects that give residual contributions.
unsigned int _j
CoordinateSystemType
Definition: MooseTypes.h:809
An interface for accessing Materials.
const Moose::CoordinateSystemType & _coord_sys
Coordinate system.
unsigned int _qp
Quadrature point index.
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
void clearPointsCaches()
Clear the cache of points because the points may have moved.
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
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...
virtual void addPoints()=0
This is where the DiracKernel should call addPoint() for each point it needs to have a value distribu...
const InputParameters & parameters() const
Get the parameters of the object.
const bool _drop_duplicate_points
drop duplicate points or consider them in residual and Jacobian
unsigned int _i
i-th, j-th index for enumerating shape and test functions
virtual void computeOffDiagJacobian(unsigned int jvar) override=0
Computes the off-diagonal Jacobian for variable jvar.
DiracKernelBase is the base class for all DiracKernel type classes.
const Elem * addPointWithValidId(Point p, unsigned id)
A helper function for addPoint(Point, id) for when id != invalid_uint.
Point _current_point
The current point.