https://mooseframework.inl.gov
RayTracingObject.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 #include "RayTracingStudy.h"
13 
14 // MOOSE includes
15 #include "MooseObject.h"
16 #include "SetupInterface.h"
17 #include "FunctionInterface.h"
18 #include "PostprocessorInterface.h"
20 #include "MeshChangedInterface.h"
21 #include "TransientInterface.h"
22 #include "UserObjectInterface.h"
24 
25 // Local includes
26 #include "ElemExtrema.h"
27 
28 // Forward declarations
29 class AuxiliarySystem;
31 class TraceRay;
32 
37  public SetupInterface,
38  public FunctionInterface,
41  public MeshChangedInterface,
42  public TransientInterface,
43  public UserObjectInterface,
45 {
46 public:
47  RayTracingObject(const InputParameters & params);
48 
50 
51  const std::set<std::string> & getRequestedItems() override { return _depend_names; }
52  const std::set<std::string> & getSuppliedItems() override { return _supplied_names; }
53 
57  RayTracingStudy & study() { return _study; }
61  const RayTracingStudy & study() const { return _study; }
62 
67  template <typename T>
68  T & getStudy();
69 
73  virtual void preExecuteStudy(){};
77  virtual void postExecuteStudy(){};
78 
79 protected:
83  const std::shared_ptr<Ray> & currentRay() const { return *_current_ray; }
84 
88  void dependsOn(const std::string name) { _depend_names.insert(name); }
89 
96 
98  const THREAD_ID _tid;
99 
102 
107 
112 
115 
117  const Elem * const & _current_elem;
121  const unsigned short & _current_intersected_side;
124 
125 private:
127  std::set<std::string> _depend_names;
129  std::set<std::string> _supplied_names;
130 
132  const std::shared_ptr<Ray> * const & _current_ray;
133 };
134 
135 template <typename T>
136 T &
138 {
139  static_assert(std::is_base_of<RayTracingStudy, T>::value, "Not derived from a RayTracingStudy");
140 
141  if (T * cast_study = dynamic_cast<T *>(&_study))
142  return *cast_study;
143 
144  std::stringstream err;
145  err << "Supplied study of type " << _study.type() << " is not the required study type "
146  << MooseUtils::prettyCppType<T>();
147  if (isParamValid("study"))
148  paramError("study", err.str());
149  else
150  mooseError(err.str());
151 }
152 
153 #define usingRayTracingObjectMembers \
154  usingMooseObjectMembers; \
155  usingFunctionInterfaceMembers; \
156  usingPostprocessorInterfaceMembers; \
157  usingTransientInterfaceMembers; \
158  using RayTracingObject::currentRay
OStreamProxy err
const unsigned short & _current_intersected_side
The side that _current_ray intersects (if any)
Base class for a MooseObject used in ray tracing.
std::set< std::string > _supplied_names
The names of the supplied objects: just this one.
FEProblemBase & _fe_problem
The FEProblemBase.
Helper for defining if at an element&#39;s edge, vertex, or neither.
Definition: ElemExtrema.h:25
const std::shared_ptr< Ray > & currentRay() const
Gets the current Ray that this is working on.
const std::set< std::string > & getRequestedItems() override
T & getStudy()
Casts the RayTracingStudy associated with this object to a study of type T with a meaningful error me...
virtual const std::string & name() const
std::set< std::string > _depend_names
The names of the objects this depends on.
bool isParamValid(const std::string &name) const
MooseMesh & _mesh
The MooseMesh.
virtual void postExecuteStudy()
Insertion point called immediately after executing the RayTracingStudy.
const Elem *const & _current_elem
The current Elem that _current_ray is tracing through.
static InputParameters validParams()
RayTracingObject(const InputParameters &params)
const std::string & type() const
const THREAD_ID _tid
The thread id.
const RayTracingStudy & study() const
The RayTracingStudy associated with this object.
void paramError(const std::string &param, Args... args) const
RayTracingStudy & study()
The RayTracingStudy associated with this object.
NonlinearSystemBase * _nl
The nonlinear system, we might not have one.
const TraceRay & _trace_ray
The TraceRay object associated with this thread.
NonlinearSystemBase * getNonlinearSystem()
Get the right nonlinear system.
void dependsOn(const std::string name)
Add an object of this classes base type that this class depends on.
AuxiliarySystem & _aux
The aux system.
void mooseError(Args &&... args) const
const ElemExtrema & _current_intersected_extrema
The elem extrema (vertex/edge) that _current_ray intersects (if any)
virtual void preExecuteStudy()
Insertion point called immediately before executing the RayTracingStudy.
const SubdomainID & _current_subdomain_id
The subdomain ID of the _current_elem that the ray is tracing through.
RayTracingStudy & _study
The RayTracingStudy associated with this object.
const std::set< std::string > & getSuppliedItems() override
const std::shared_ptr< Ray > *const & _current_ray
The current Ray that the action is being applied to.
Traces Rays through the mesh on a single processor.
Definition: TraceRay.h:46
unsigned int THREAD_ID
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...