https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"
20#include "BlockRestrictable.h"
21#include "MooseEnum.h"
22
31{
32public:
34
36
40 virtual void computeOffDiagJacobian(unsigned int jvar) override = 0;
41
46 virtual void addPoints() = 0;
47
51 bool hasPointsOnElem(const Elem * elem);
52
56 bool isActiveAtPoint(const Elem * elem, const Point & p);
57
62 void clearPoints();
63
67 void clearPointsCaches();
68
74 virtual void meshChanged() override { clearPointsCaches(); };
75
76protected:
85 void addPoint(const Elem * elem, Point p, unsigned id = libMesh::invalid_uint, Real value = 1.0);
86
96 const Elem * addPoint(Point p, unsigned id = libMesh::invalid_uint, Real value = 1.0);
97
104 unsigned currentPointCachedID();
105
107 const Elem * const & _current_elem;
108
111
115
118
121
123 unsigned int _qp;
129 const QBase * const & _qrule;
132
134 unsigned int _i, _j;
135
138
140 const DiracKernelInfo::PointNotFoundBehavior _point_not_found_behavior;
141
144
147 typedef std::map<unsigned, std::pair<const Elem *, Point>> point_cache_t;
149
153 typedef std::map<const Elem *, std::vector<std::pair<Point, unsigned>>> reverse_cache_t;
155
156private:
162 void updateCaches(const Elem * old_elem, const Elem * new_elem, Point p, unsigned id);
163
166 const Elem * addPointWithValidId(Point p, unsigned id, Real value);
167};
An interface that restricts an object to subdomains via the 'blocks' input parameter.
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
DiracKernelBase is the base class for all DiracKernel type classes.
unsigned int _i
i-th, j-th index for enumerating shape and test functions
const bool _allow_moving_sources
Whether Dirac sources can move during the simulation.
const Elem * addPointWithValidId(Point p, unsigned id, Real value)
A helper function for addPoint(Point, id) for when id != invalid_uint.
const Elem *const & _current_elem
Current element.
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's computeQpResidual()...
unsigned int _qp
Quadrature point index.
reverse_cache_t _reverse_point_cache
virtual void addPoints()=0
This is where the DiracKernel should call addPoint() for each point it needs to have a value distribu...
void addPoint(const Elem *elem, Point p, unsigned id=libMesh::invalid_uint, Real value=1.0)
Add the physical x,y,z point located in the element "elem" to the list of points this DiracKernel wil...
const Moose::CoordinateSystemType & _coord_sys
Coordinate system.
DiracKernelInfo & _dirac_kernel_info
Place for storing Point/Elem information shared across all DiracKernel objects.
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
const DiracKernelInfo::PointNotFoundBehavior _point_not_found_behavior
What to do if the point is not found. See DiracKernelInfo for definition.
const MooseArray< Point > & _q_point
Quadrature points.
bool hasPointsOnElem(const Elem *elem)
Whether or not this DiracKernel has something to distribute on this element.
point_cache_t _point_cache
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*,...
void clearPoints()
Remove all of the current points and elements.
bool isActiveAtPoint(const Elem *elem, const Point &p)
Whether or not this DiracKernel has something to distribute at this Point.
void clearPointsCaches()
Clear the cache of points because the points may have moved.
const QBase *const & _qrule
Quadrature rule.
const MooseArray< Point > & _physical_point
Physical points.
virtual void computeOffDiagJacobian(unsigned int jvar) override=0
Computes the off-diagonal Jacobian for variable jvar.
const bool _drop_duplicate_points
drop duplicate points or consider them in residual and Jacobian
Point _current_point
The current point.
DiracKernelInfo _local_dirac_kernel_info
Place for storing Point/Elem information only for this DiracKernel.
static InputParameters validParams()
virtual void meshChanged() override
Clear point cache when the mesh changes, so that element coarsening, element deletion,...
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.
unsigned currentPointCachedID()
Returns the user-assigned ID of the current Dirac point if it exits, and libMesh::invalid_uint otherw...
The DiracKernelInfo object is a place where all the Dirac points added by different DiracKernels are ...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
An interface for accessing Materials.
forward declarations
Definition MooseArray.h:18
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
This is the common base class for objects that give residual contributions.
CoordinateSystemType
Definition MooseTypes.h:864
const unsigned int invalid_uint