https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
28class RayTracingStudy;
29class MooseMesh;
30
35{
36public:
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
65protected:
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
104 const libMesh::BoundingBox & inflatedBoundingBox(const processor_id_type pid) const
105 {
106 return _inflated_bboxes[pid];
107 }
108
112 const processor_id_type _pid;
113
115 const bool _do_exchange;
116
121
122private:
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};
unsigned long int RayID
Type for a Ray's ID.
Definition Ray.h:44
Helper object for claiming Rays.
Definition ClaimRays.h:35
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
void possiblyClaim(const std::shared_ptr< Ray > &obj)
Possibly claim a Ray.
Definition ClaimRays.C:94
const libMesh::BoundingBox & inflatedBoundingBox(const processor_id_type pid) const
Get the inflated bounding box for rank \pid.
Definition ClaimRays.h:104
const std::vector< std::shared_ptr< Ray > > & _rays
The Rays that need to be searched to possibly claimed.
Definition ClaimRays.h:157
bool _needs_init
Whether or not an init is needed (bounding boxes, neighbors)
Definition ClaimRays.h:171
MooseMesh & _mesh
The mesh.
Definition ClaimRays.h:110
virtual void meshChanged() override
Call on mesh changes to reinit the necessary data structures.
Definition ClaimRays.C:175
RayTracingStudy & _study
The RayTracingStudy.
Definition ClaimRays.h:118
virtual void init()
Initialize the object.
Definition ClaimRays.C:168
ParallelStudy< std::shared_ptr< Ray >, Ray > & _parallel_study
The ParallelStudy, used as the context for communicating rays.
Definition ClaimRays.h:120
std::unordered_map< dof_id_type, std::vector< const Elem * > > _elem_point_neighbors
Map of point neighbors for each element.
Definition ClaimRays.h:168
virtual RayID getID(const std::shared_ptr< Ray > &ray) const
Gets an ID associated with the Ray for claiming purposes.
Definition ClaimRays.h:99
virtual void postClaim()
Entry point after claim()
Definition ClaimRays.h:78
const processor_id_type _pid
This processor ID.
Definition ClaimRays.h:112
virtual void prePossiblyClaimRay(const std::shared_ptr< Ray > &)
Entry point before possibly claiming a Ray.
Definition ClaimRays.h:82
std::vector< libMesh::BoundingBox > _inflated_bboxes
The inflated bounding boxes for all processors.
Definition ClaimRays.h:165
void claim()
Claim the Rays.
Definition ClaimRays.C:42
std::vector< std::shared_ptr< Ray > > & _local_rays
The local Rays that are claimed.
Definition ClaimRays.h:159
std::unique_ptr< libMesh::PointLocatorBase > _point_locator
The point locator.
Definition ClaimRays.h:162
void buildPointNeighbors()
Build the map of elements to all of their point neighbors.
Definition ClaimRays.C:201
const Elem * claimPoint(const Point &point, const RayID id, const Elem *elem)
Try to claim a spatial point.
Definition ClaimRays.C:108
virtual void preClaim()
Entry point before claim()
Definition ClaimRays.h:74
void buildBoundingBoxes()
Builds the bounding boxes (_inflated_bboxes).
Definition ClaimRays.C:181
void verifyClaiming()
Verifies that the claiming process succeeded.
Definition ClaimRays.C:226
const bool _do_exchange
Whether or not the Rays need to be initially exchanged.
Definition ClaimRays.h:115
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...
Basic datastructure for a ray that will traverse the mesh.
Definition Ray.h:58