LCOV - code coverage report
Current view: top level - include/userobjects - ViewFactorRayStudy.h (source / functions) Hit Total Coverage
Test: idaholab/moose heat_transfer: #31405 (292dce) with base fef103 Lines: 11 11 100.0 %
Date: 2025-09-04 07:53:51 Functions: 1 1 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             : #include "RayTracingAngularQuadrature.h"
      15             : 
      16             : /**
      17             :  * RayTracingStudy used to generate Rays for view factor computation
      18             :  * using the angular quadrature method.
      19             :  */
      20             : class ViewFactorRayStudy : public RayTracingStudy
      21             : {
      22             : public:
      23             :   ViewFactorRayStudy(const InputParameters & parameters);
      24             : 
      25             :   static InputParameters validParams();
      26             : 
      27             :   void initialSetup() override;
      28             : 
      29             :   /**
      30             :    * Data structure used for storing all of the information needed to spawn
      31             :    * Rays from a single element.
      32             :    */
      33        9844 :   struct StartElem
      34             :   {
      35             :     StartElem() {}
      36             : 
      37        3048 :     StartElem(const Elem * elem,
      38             :               const Elem * start_elem,
      39             :               const unsigned short int incoming_side,
      40             :               const BoundaryID bnd_id,
      41             :               const std::vector<Point> & points,
      42             :               const std::vector<Real> & weights)
      43        3048 :       : _elem(elem),
      44        3048 :         _start_elem(start_elem),
      45        3048 :         _incoming_side(incoming_side),
      46        3048 :         _bnd_id(bnd_id),
      47        3048 :         _points(points),
      48        3048 :         _weights(weights)
      49             :     {
      50             :       mooseAssert(_points.size() == _weights.size(), "Point and weight size not equal");
      51        3048 :     }
      52             : 
      53             :     /// The element the points originate from
      54             :     const Elem * _elem;
      55             :     /// The element the trace will start from
      56             :     const Elem * _start_elem;
      57             :     /// The incoming side on start_elem that the trace will start from
      58             :     unsigned short int _incoming_side;
      59             :     /// The boundary ID associated with this start elem
      60             :     BoundaryID _bnd_id;
      61             :     /// The points on start_elem to spawn Rays from
      62             :     std::vector<Point> _points;
      63             :     /// The weights associated with each point
      64             :     std::vector<Real> _weights;
      65             :   };
      66             : 
      67             :   /**
      68             :    * Adds into the view factor info; to be used in ViewFactorRayBC
      69             :    * @param value The value to add
      70             :    * @param from_id The from boundary
      71             :    * @param to_id The to boundary
      72             :    * @param tid The thread
      73             :    */
      74             :   void addToViewFactorInfo(Real value,
      75             :                            const BoundaryID from_id,
      76             :                            const BoundaryID to_id,
      77             :                            const THREAD_ID tid);
      78             : 
      79             :   /**
      80             :    * Accessor for the finalized view factor info
      81             :    * @param from_id The from boundary
      82             :    * @param to_id The to boundary
      83             :    */
      84             :   Real viewFactorInfo(const BoundaryID from_id, const BoundaryID to_id) const;
      85             : 
      86             :   /**
      87             :    * Get the index in the Ray aux data for the starting boundary ID
      88             :    */
      89         187 :   RayDataIndex rayIndexStartBndID() const { return _ray_index_start_bnd_id; }
      90             :   /**
      91             :    * Get the index in the Ray aux data for the starting total weight (dot * qp weight)
      92             :    */
      93         187 :   RayDataIndex rayIndexStartTotalWeight() const { return _ray_index_start_total_weight; }
      94             : 
      95             : protected:
      96             :   void generateRays() override;
      97             :   void preExecuteStudy() override;
      98             :   void postExecuteStudy() override;
      99             : 
     100             :   void generateStartElems();
     101             : 
     102             :   /// The vector of user supplied boundary IDs we need view factors on
     103             :   const std::vector<BoundaryID> _bnd_ids_vec;
     104             :   /// The user supplied boundary IDs we need view factors on
     105             :   const std::set<BoundaryID> _bnd_ids;
     106             : 
     107             :   /// The convention for spawning rays from internal sidesets
     108             :   const MooseEnum _internal_convention;
     109             : 
     110             :   /// Index in the Ray aux data for the starting boundary ID
     111             :   const RayDataIndex _ray_index_start_bnd_id;
     112             :   /// Index in the Ray aux data for the starting total weight (dot * qp weight)
     113             :   const RayDataIndex _ray_index_start_total_weight;
     114             : 
     115             :   /// Face FE used for creating face quadrature points and weights
     116             :   const std::unique_ptr<libMesh::FEBase> _fe_face;
     117             :   /// Face quadrature used for _fe_face
     118             :   const std::unique_ptr<libMesh::QBase> _q_face;
     119             : 
     120             :   // Whether or not the mesh is 3D
     121             :   const bool _is_3d;
     122             : 
     123             : private:
     124             :   /// View factor information by tid and then from/to pair; [tid][from_bid][to_bid] = val
     125             :   std::vector<std::unordered_map<BoundaryID, std::unordered_map<BoundaryID, Real>>>
     126             :       _threaded_vf_info;
     127             :   /// Cumulative view factor information; [from_bid][to_bid] = val
     128             :   std::map<BoundaryID, std::map<BoundaryID, Real>> _vf_info;
     129             : 
     130             :   /// The StartElem objects that this proc needs to spawn Rays from
     131             :   std::vector<StartElem> _start_elems;
     132             : 
     133             :   ///@{ angular quadrature info
     134             :   std::vector<Real> _2d_aq_angles;
     135             :   std::vector<Real> _2d_aq_weights;
     136             :   std::unique_ptr<RayTracingAngularQuadrature> _3d_aq;
     137             :   std::size_t _num_dir;
     138             :   ///@}
     139             : };
     140             : 
     141             : namespace libMesh
     142             : {
     143             : namespace Parallel
     144             : {
     145             : template <>
     146             : class Packing<ViewFactorRayStudy::StartElem>
     147             : {
     148             : public:
     149             :   typedef Real buffer_type;
     150             : 
     151             :   static unsigned int packing_size(const std::size_t num_points);
     152             : 
     153             :   static unsigned int packed_size(typename std::vector<Real>::const_iterator in);
     154             : 
     155             :   static unsigned int packable_size(const ViewFactorRayStudy::StartElem & start_elem, const void *);
     156             : 
     157             :   template <typename Iter, typename Context>
     158             :   static void pack(const ViewFactorRayStudy::StartElem & object, Iter data_out, const Context *);
     159             : 
     160             :   template <typename BufferIter, typename Context>
     161             :   static ViewFactorRayStudy::StartElem unpack(BufferIter in, Context *);
     162             : };
     163             : 
     164             : } // namespace Parallel
     165             : 
     166             : } // namespace libMesh

Generated by: LCOV version 1.14