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 void computeOffDiagJacobian(unsigned int jvar) override = 0;
40 
45  virtual void addPoints() = 0;
46 
50  bool hasPointsOnElem(const Elem * elem);
51 
55  bool isActiveAtPoint(const Elem * elem, const Point & p);
56 
61  void clearPoints();
62 
66  void clearPointsCaches();
67 
73  virtual void meshChanged() override { clearPointsCaches(); };
74 
75 protected:
80  void addPoint(const Elem * elem, Point p, unsigned id = libMesh::invalid_uint);
81 
88  const Elem * addPoint(Point p, unsigned id = libMesh::invalid_uint);
89 
96  unsigned currentPointCachedID();
97 
99  const Elem * const & _current_elem;
100 
103 
107 
110 
113 
115  unsigned int _qp;
121  const QBase * const & _qrule;
124 
126  unsigned int _i, _j;
127 
130 
131  // @{ Point-not-found behavior
133  {
134  ERROR,
135  WARNING,
136  IGNORE
137  };
139  // @}
140 
143 
146  typedef std::map<unsigned, std::pair<const Elem *, Point>> point_cache_t;
148 
152  typedef std::map<const Elem *, std::vector<std::pair<Point, unsigned>>> reverse_cache_t;
154 
155 private:
161  void updateCaches(const Elem * old_elem, const Elem * new_elem, Point p, unsigned id);
162 
165  const Elem * addPointWithValidId(Point p, unsigned id);
166 };
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.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
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*...
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
This is the common base class for objects that give residual contributions.
unsigned int _j
CoordinateSystemType
Definition: MooseTypes.h:858
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 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.