Line data Source code
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 : #include "Moose.h" 13 : #include "MooseTypes.h" 14 : #include "MooseEnum.h" 15 : 16 : #include <set> 17 : #include <map> 18 : #include <memory> 19 : 20 : // Forward declarations 21 : class MooseMesh; 22 : class MooseBase; 23 : 24 : namespace libMesh 25 : { 26 : class Elem; 27 : class PointLocatorBase; 28 : class Point; 29 : } 30 : 31 : /** 32 : * The DiracKernelInfo object is a place where all the Dirac points 33 : * added by different DiracKernels are collected. It is used, for 34 : * example, by the FEProblemBase class to determine if finite element data 35 : * needs to be recomputed on a given element. 36 : */ 37 : class DiracKernelInfo 38 : { 39 : public: 40 : DiracKernelInfo(); 41 : virtual ~DiracKernelInfo(); 42 : 43 : public: 44 : /** 45 : * Adds a point source 46 : * @param elem Pointer to the geometric element in which the point is located 47 : * @param p The (x,y,z) location of the Dirac point 48 : * @param value The value accumulated for this point when it coincides with an existing point 49 : */ 50 : void addPoint(const Elem * elem, const Point & p, const Real & value = 1); 51 : 52 : /** 53 : * Remove all of the current points and elements. 54 : */ 55 : void clearPoints(); 56 : 57 : /** 58 : * Return true if we have Point 'p' in Element 'elem' 59 : */ 60 : bool hasPoint(const Elem * elem, const Point & p); 61 : 62 : /** 63 : * Returns a writeable reference to the _elements container. 64 : */ 65 357739 : std::set<const Elem *> & getElements() { return _elements; } 66 : 67 : typedef std::map<const Elem *, std::pair<std::vector<Point>, std::vector<Real>>> MultiPointMap; 68 : 69 : /** 70 : * Returns a writeable reference to the _points container. 71 : */ 72 317703 : MultiPointMap & getPoints() { return _points; } 73 : 74 : /** 75 : * Called during FEProblemBase::meshChanged() to update the PointLocator 76 : * object used by the DiracKernels. 77 : */ 78 : void updatePointLocator(const MooseMesh & mesh); 79 : 80 : /// Point-not-found behavior 81 423753 : CreateMooseEnumClass(PointNotFoundBehavior, ERROR, WARNING, IGNORE); 82 : 83 : /** 84 : * Used by client DiracKernel classes to determine the Elem in which 85 : * the Point p resides. Uses the PointLocator owned by this object. 86 : * @param p the point to find the element which contains it 87 : * @param mesh the mesh with elements to look at 88 : * @param blocks block restriction to find the element in 89 : * @param point_not_found_behavior what to do if the point is not found 90 : * @param consumer the object calling calling this routine 91 : */ 92 : const Elem * findPoint(const Point & p, 93 : const MooseMesh & mesh, 94 : const std::set<SubdomainID> & blocks, 95 : const PointNotFoundBehavior point_not_found_behavior, 96 : const MooseBase & consumer); 97 : 98 : protected: 99 : /** 100 : * Check if two points are equal with respect to a tolerance 101 : */ 102 : bool pointsFuzzyEqual(const Point &, const Point &); 103 : 104 : /// The list of elements that need distributions. 105 : std::set<const Elem *> _elements; 106 : 107 : /// The list of physical xyz Points that need to be evaluated in each element. 108 : MultiPointMap _points; 109 : 110 : /// The DiracKernelInfo object manages a PointLocator object which is used 111 : /// by all DiracKernels to find Points. It needs to be centrally managed and it 112 : /// also needs to be rebuilt in FEProblemBase::meshChanged() to work with Mesh 113 : /// adaptivity. 114 : std::unique_ptr<libMesh::PointLocatorBase> _point_locator; 115 : 116 : /// threshold distance squared below which two points are considered identical 117 : const Real _point_equal_distance_sq; 118 : };