https://mooseframework.inl.gov
ClaimRays.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 // Local includes
13 #include "ParallelStudy.h"
14 #include "Ray.h"
15 
16 // MOOSE includes
17 #include "MeshChangedInterface.h"
18 
19 // System includes
20 #include <unordered_map>
21 
22 // libMesh includes
23 #include "libmesh/bounding_box.h"
24 #include "libmesh/parallel_object.h"
25 #include "libmesh/point_locator_base.h"
26 
27 // Forward declarations
28 class RayTracingStudy;
29 class MooseMesh;
30 
35 {
36 public:
47  ClaimRays(RayTracingStudy & study,
48  const std::vector<std::shared_ptr<Ray>> & rays,
49  std::vector<std::shared_ptr<Ray>> & local_rays,
50  const bool do_exchange);
51 
55  virtual void meshChanged() override;
56 
63  void claim();
64 
65 protected:
69  virtual void init();
70 
74  virtual void preClaim() {}
78  virtual void postClaim() {}
82  virtual void prePossiblyClaimRay(const std::shared_ptr<Ray> & /* ray */) {}
86  virtual void postClaimRay(std::shared_ptr<Ray> & ray, const Elem * elem);
87 
99  virtual RayID getID(const std::shared_ptr<Ray> & ray) const { return ray->id(); }
100 
105  {
106  return _inflated_bboxes[pid];
107  }
108 
113 
115  const bool _do_exchange;
116 
121 
122 private:
126  void buildBoundingBoxes();
127 
133  void buildPointNeighbors();
134 
138  void possiblyClaim(const std::shared_ptr<Ray> & obj);
139 
144  void verifyClaiming();
145 
154  const Elem * claimPoint(const Point & point, const RayID id, const Elem * elem);
155 
157  const std::vector<std::shared_ptr<Ray>> & _rays;
159  std::vector<std::shared_ptr<Ray>> & _local_rays;
160 
162  std::unique_ptr<libMesh::PointLocatorBase> _point_locator = nullptr;
163 
165  std::vector<libMesh::BoundingBox> _inflated_bboxes;
166 
168  std::unordered_map<dof_id_type, std::vector<const Elem *>> _elem_point_neighbors;
169 
172 };
bool _needs_init
Whether or not an init is needed (bounding boxes, neighbors)
Definition: ClaimRays.h:171
unsigned long int RayID
Type for a Ray&#39;s ID.
Definition: Ray.h:43
ClaimRays(RayTracingStudy &study, const std::vector< std::shared_ptr< Ray >> &rays, std::vector< std::shared_ptr< Ray >> &local_rays, const bool do_exchange)
Constructor.
Definition: ClaimRays.C:24
void verifyClaiming()
Verifies that the claiming process succeeded.
Definition: ClaimRays.C:226
virtual void postClaimRay(std::shared_ptr< Ray > &ray, const Elem *elem)
Entry point for acting on a Ray after it is claimed.
Definition: ClaimRays.C:145
ParallelStudy< std::shared_ptr< Ray >, Ray > & _parallel_study
The ParallelStudy, used as the context for communicating rays.
Definition: ClaimRays.h:120
virtual void postClaim()
Entry point after claim()
Definition: ClaimRays.h:78
const processor_id_type _pid
This processor ID.
Definition: ClaimRays.h:112
void buildPointNeighbors()
Build the map of elements to all of their point neighbors.
Definition: ClaimRays.C:201
const std::vector< std::shared_ptr< Ray > > & _rays
The Rays that need to be searched to possibly claimed.
Definition: ClaimRays.h:157
uint8_t processor_id_type
std::vector< libMesh::BoundingBox > _inflated_bboxes
The inflated bounding boxes for all processors.
Definition: ClaimRays.h:165
MooseMesh & _mesh
The mesh.
Definition: ClaimRays.h:110
std::vector< std::shared_ptr< Ray > > & _local_rays
The local Rays that are claimed.
Definition: ClaimRays.h:159
Basic datastructure for a ray that will traverse the mesh.
Definition: Ray.h:56
RayTracingStudy & _study
The RayTracingStudy.
Definition: ClaimRays.h:118
virtual RayID getID(const std::shared_ptr< Ray > &ray) const
Gets an ID associated with the Ray for claiming purposes.
Definition: ClaimRays.h:99
void buildBoundingBoxes()
Builds the bounding boxes (_inflated_bboxes).
Definition: ClaimRays.C:181
void claim()
Claim the Rays.
Definition: ClaimRays.C:42
void possiblyClaim(const std::shared_ptr< Ray > &obj)
Possibly claim a Ray.
Definition: ClaimRays.C:94
Helper object for claiming Rays.
Definition: ClaimRays.h:34
const bool _do_exchange
Whether or not the Rays need to be initially exchanged.
Definition: ClaimRays.h:115
virtual void preClaim()
Entry point before claim()
Definition: ClaimRays.h:74
virtual void meshChanged() override
Call on mesh changes to reinit the necessary data structures.
Definition: ClaimRays.C:175
std::unordered_map< dof_id_type, std::vector< const Elem * > > _elem_point_neighbors
Map of point neighbors for each element.
Definition: ClaimRays.h:168
const libMesh::BoundingBox & inflatedBoundingBox(const processor_id_type pid) const
Get the inflated bounding box for rank .
Definition: ClaimRays.h:104
std::unique_ptr< libMesh::PointLocatorBase > _point_locator
The point locator.
Definition: ClaimRays.h:162
const Elem * claimPoint(const Point &point, const RayID id, const Elem *elem)
Try to claim a spatial point.
Definition: ClaimRays.C:108
virtual void prePossiblyClaimRay(const std::shared_ptr< Ray > &)
Entry point before possibly claiming a Ray.
Definition: ClaimRays.h:82
virtual void init()
Initialize the object.
Definition: ClaimRays.C:168
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...