17#include "libmesh/point_locator_base.h"
18#include "libmesh/elem.h"
19#include "libmesh/enum_point_locator_type.h"
20#include "libmesh/point.h"
23 : _point_locator(), _point_equal_distance_sq(
libMesh::TOLERANCE *
libMesh::TOLERANCE)
34 std::pair<std::vector<Point>, std::vector<Real>> & multi_point_list =
_points[elem];
36 const unsigned int npoint = multi_point_list.first.size();
37 mooseAssert(npoint == multi_point_list.second.size(),
38 "Different sizes for location and point value data");
40 for (
unsigned int i = 0; i < npoint; ++i)
44 multi_point_list.second[i] += value;
49 multi_point_list.first.push_back(p);
50 multi_point_list.second.push_back(value);
63 std::vector<Point> & point_list =
_points[elem].first;
65 for (
const auto & pt : point_list)
86 unsigned pl_needs_rebuild =
_elements.size();
87 mesh.comm().max(pl_needs_rebuild);
116 const std::set<SubdomainID> &
blocks,
117 const PointNotFoundBehavior point_not_found_behavior,
132 consumer.
mooseError(
"PointLocator is not initialized!");
139 const Elem * elem = (*_point_locator)(p, &
blocks);
145 dof_id_type elem_id = elem ? elem->id() : DofObject::invalid_id;
149 dof_id_type min_elem_id = elem_id;
150 mesh.comm().min(min_elem_id);
152 if (min_elem_id == DofObject::invalid_id)
154 std::stringstream msg;
156 switch (point_not_found_behavior)
158 case PointNotFoundBehavior::ERROR:
161 case PointNotFoundBehavior::WARNING:
162 mooseDoOnce(consumer.
mooseWarning(msg.str() +
"This message will not be repeated."));
164 case PointNotFoundBehavior::IGNORE:
172 if (min_elem_id != DofObject::invalid_id)
173 if (
const auto min_elem =
mesh.queryElemPtr(min_elem_id);
174 min_elem && min_elem->processor_id() ==
mesh.processor_id())
182 const Real dist_sq = (a - b).norm_sq();
bool hasPoint(const Elem *elem, const Point &p)
Return true if we have Point 'p' in Element 'elem'.
const Real _point_equal_distance_sq
threshold distance squared below which two points are considered identical
MultiPointMap _points
The list of physical xyz Points that need to be evaluated in each element.
virtual ~DiracKernelInfo()
void clearPoints()
Remove all of the current points and elements.
std::unique_ptr< libMesh::PointLocatorBase > _point_locator
The DiracKernelInfo object manages a PointLocator object which is used by all DiracKernels to find Po...
void addPoint(const Elem *elem, const Point &p, const Real &value=1)
Adds a point source.
const Elem * findPoint(const Point &p, const MooseMesh &mesh, const std::set< SubdomainID > &blocks, const PointNotFoundBehavior point_not_found_behavior, const MooseBase &consumer)
Used by client DiracKernel classes to determine the Elem in which the Point p resides.
std::set< const Elem * > _elements
The list of elements that need distributions.
void updatePointLocator(const MooseMesh &mesh)
Called during FEProblemBase::meshChanged() to update the PointLocator object used by the DiracKernels...
bool pointsFuzzyEqual(const Point &, const Point &)
Check if two points are equal with respect to a tolerance.
Base class for everything in MOOSE with a name and a type.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
std::string stringify(const T &t)
conversion to string
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...