LCOV - code coverage report
Current view: top level - include/base - RayTracingObject.h (source / functions) Hit Total Coverage
Test: idaholab/moose ray_tracing: #31405 (292dce) with base fef103 Lines: 16 17 94.1 %
Date: 2025-09-04 07:56:07 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          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 "RayTracingStudy.h"
      13             : 
      14             : // MOOSE includes
      15             : #include "MooseObject.h"
      16             : #include "SetupInterface.h"
      17             : #include "FunctionInterface.h"
      18             : #include "PostprocessorInterface.h"
      19             : #include "VectorPostprocessorInterface.h"
      20             : #include "MeshChangedInterface.h"
      21             : #include "TransientInterface.h"
      22             : #include "UserObjectInterface.h"
      23             : #include "DependencyResolverInterface.h"
      24             : 
      25             : // Local includes
      26             : #include "ElemExtrema.h"
      27             : 
      28             : // Forward declarations
      29             : class AuxiliarySystem;
      30             : class NonlinearSystemBase;
      31             : class TraceRay;
      32             : 
      33             : /**
      34             :  * Base class for a MooseObject used in ray tracing.
      35             :  */
      36             : class RayTracingObject : public MooseObject,
      37             :                          public SetupInterface,
      38             :                          public FunctionInterface,
      39             :                          public PostprocessorInterface,
      40             :                          public VectorPostprocessorInterface,
      41             :                          public MeshChangedInterface,
      42             :                          public TransientInterface,
      43             :                          public UserObjectInterface,
      44             :                          public DependencyResolverInterface
      45             : {
      46             : public:
      47             :   RayTracingObject(const InputParameters & params);
      48             : 
      49             :   static InputParameters validParams();
      50             : 
      51       19047 :   const std::set<std::string> & getRequestedItems() override { return _depend_names; }
      52       11879 :   const std::set<std::string> & getSuppliedItems() override { return _supplied_names; }
      53             : 
      54             :   /**
      55             :    * The RayTracingStudy associated with this object
      56             :    */
      57             :   RayTracingStudy & study() { return _study; }
      58             :   /**
      59             :    * The RayTracingStudy associated with this object
      60             :    */
      61        9039 :   const RayTracingStudy & study() const { return _study; }
      62             : 
      63             :   /**
      64             :    * Casts the RayTracingStudy associated with this object to a study of type T
      65             :    * with a meaningful error message if it fails
      66             :    */
      67             :   template <typename T>
      68             :   T & getStudy();
      69             : 
      70             :   /**
      71             :    * Insertion point called immediately before executing the RayTracingStudy.
      72             :    */
      73        7459 :   virtual void preExecuteStudy(){};
      74             :   /**
      75             :    * Insertion point called immediately after executing the RayTracingStudy.
      76             :    */
      77       15399 :   virtual void postExecuteStudy(){};
      78             : 
      79             : protected:
      80             :   /**
      81             :    * Gets the current Ray that this is working on
      82             :    */
      83     1694009 :   const std::shared_ptr<Ray> & currentRay() const { return *_current_ray; }
      84             : 
      85             :   /**
      86             :    * Add an object of this classes base type that this class depends on.
      87             :    */
      88         159 :   void dependsOn(const std::string name) { _depend_names.insert(name); }
      89             : 
      90             :   /**
      91             :    * Get the right nonlinear system. Some simulations might not have one,
      92             :    * if some user objects only operate on aux variables we need a special
      93             :    * treatment
      94             :    */
      95             :   NonlinearSystemBase * getNonlinearSystem();
      96             : 
      97             :   /// The thread id
      98             :   const THREAD_ID _tid;
      99             : 
     100             :   /// The FEProblemBase
     101             :   FEProblemBase & _fe_problem;
     102             : 
     103             :   /// The RayTracingStudy associated with this object
     104             :   RayTracingStudy & _study;
     105             :   /// The TraceRay object associated with this thread
     106             :   const TraceRay & _trace_ray;
     107             : 
     108             :   /// The nonlinear system, we might not have one
     109             :   NonlinearSystemBase * _nl;
     110             :   /// The aux system
     111             :   AuxiliarySystem & _aux;
     112             : 
     113             :   /// The MooseMesh
     114             :   MooseMesh & _mesh;
     115             : 
     116             :   /// The current Elem that _current_ray is tracing through
     117             :   const Elem * const & _current_elem;
     118             :   /// The subdomain ID of the _current_elem that the ray is tracing through
     119             :   const SubdomainID & _current_subdomain_id;
     120             :   /// The side that _current_ray intersects (if any)
     121             :   const unsigned short & _current_intersected_side;
     122             :   /// The elem extrema (vertex/edge) that _current_ray intersects (if any)
     123             :   const ElemExtrema & _current_intersected_extrema;
     124             : 
     125             : private:
     126             :   /// The names of the objects this depends on
     127             :   std::set<std::string> _depend_names;
     128             :   /// The names of the supplied objects: just this one
     129             :   std::set<std::string> _supplied_names;
     130             : 
     131             :   /// The current Ray that the action is being applied to
     132             :   const std::shared_ptr<Ray> * const & _current_ray;
     133             : };
     134             : 
     135             : template <typename T>
     136             : T &
     137         204 : RayTracingObject::getStudy()
     138             : {
     139             :   static_assert(std::is_base_of<RayTracingStudy, T>::value, "Not derived from a RayTracingStudy");
     140             : 
     141         204 :   if (T * cast_study = dynamic_cast<T *>(&_study))
     142         200 :     return *cast_study;
     143             : 
     144           4 :   std::stringstream err;
     145           4 :   err << "Supplied study of type " << _study.type() << " is not the required study type "
     146           8 :       << MooseUtils::prettyCppType<T>();
     147           8 :   if (isParamValid("study"))
     148           2 :     paramError("study", err.str());
     149             :   else
     150           2 :     mooseError(err.str());
     151           0 : }
     152             : 
     153             : #define usingRayTracingObjectMembers                                                               \
     154             :   usingMooseObjectMembers;                                                                         \
     155             :   usingFunctionInterfaceMembers;                                                                   \
     156             :   usingPostprocessorInterfaceMembers;                                                              \
     157             :   usingTransientInterfaceMembers;                                                                  \
     158             :   using RayTracingObject::currentRay

Generated by: LCOV version 1.14