LCOV - code coverage report
Current view: top level - include/csg - CSGCell.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 6 6 100.0 %
Date: 2026-05-29 20:35:17 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       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             : #ifdef MOOSE_UNIT_TEST
      13             : #include "gtest/gtest.h"
      14             : #endif
      15             : 
      16             : #include "CSGRegion.h"
      17             : #include "CSGTransformationHelper.h"
      18             : 
      19             : namespace CSG
      20             : {
      21             : 
      22             : class CSGUniverse;
      23             : class CSGLattice;
      24             : 
      25             : /**
      26             :  * CSGCell creates an internal representation of a Constructive Solid Geometry (CSG)
      27             :  * cell, which represents a region of space filled by a material or void
      28             :  */
      29             : class CSGCell : public CSGTransformationHelper
      30             : {
      31             : public:
      32             :   /**
      33             :    * Constructor for void cell
      34             :    *
      35             :    * @param name name of cell
      36             :    * @param region cell region
      37             :    */
      38             :   CSGCell(const std::string & name, const CSGRegion & region);
      39             : 
      40             :   /**
      41             :    * Constructor for Material Cell
      42             :    *
      43             :    * @param name name of cell
      44             :    * @param mat_name name of the CSG material (not a MOOSE material) to use as the cell fill
      45             :    * @param region cell region
      46             :    */
      47             :   CSGCell(const std::string & name, const std::string & mat_name, const CSGRegion & region);
      48             : 
      49             :   /**
      50             :    * Constructor for Universe Cell
      51             :    *
      52             :    * @param name name of cell
      53             :    * @param univ universe to be the fill
      54             :    * @param region cell region
      55             :    */
      56             :   CSGCell(const std::string & name, const CSGUniverse * univ, const CSGRegion & region);
      57             : 
      58             :   /**
      59             :    * @brief Constructor for a Lattice Cell
      60             :    *
      61             :    * @param name name of cell
      62             :    * @param lattice lattice to be the fill
      63             :    * @param region cell region
      64             :    */
      65             :   CSGCell(const std::string & name, const CSGLattice * lattice, const CSGRegion & region);
      66             : 
      67             :   /**
      68             :    * Destructor
      69             :    */
      70         844 :   virtual ~CSGCell() = default;
      71             : 
      72             :   /**
      73             :    * @brief Get the type of fill for the cell
      74             :    *
      75             :    * @return fill type
      76             :    */
      77        3842 :   const std::string getFillType() const { return _fill_type; }
      78             : 
      79             :   /**
      80             :    * @brief Get the cell fill if fill type is UNIVERSE
      81             :    *
      82             :    * @return Reference to CSGUniverse fill
      83             :    */
      84             :   const CSGUniverse & getFillUniverse() const;
      85             : 
      86             :   /**
      87             :    * @brief Get the cell fill material name if fill fype is CSG_MATERIAL
      88             :    *
      89             :    * @return name of the cell's CSG material fill
      90             :    */
      91             :   const std::string & getFillMaterial() const;
      92             : 
      93             :   /**
      94             :    * @brief Get the cell fill if fill type is LATTICE
      95             :    *
      96             :    * @return Reference to CSGLattice fill
      97             :    */
      98             :   const CSGLattice & getFillLattice() const;
      99             : 
     100             :   /**
     101             :    * @brief Get the name of the fill, regardless of its type
     102             :    *
     103             :    * @return std::string fill name
     104             :    */
     105             :   const std::string & getFillName() const;
     106             : 
     107             :   /**
     108             :    * @brief Get the cell name
     109             :    *
     110             :    * @return const std::string cell name
     111             :    */
     112        4575 :   const std::string & getName() const { return _name; }
     113             : 
     114             :   /**
     115             :    * @brief Get the cell region
     116             :    *
     117             :    * @return const CSGRegion& region of the cell
     118             :    */
     119         938 :   const CSGRegion & getRegion() const { return _region; }
     120             : 
     121             :   /**
     122             :    * @brief Reset the cell fill to void
     123             :    *
     124             :    */
     125             :   void resetCellFill();
     126             : 
     127             :   /**
     128             :    * @brief Set the cell fill to a material name
     129             :    *
     130             :    * @param mat_name name of material fill
     131             :    */
     132             :   void updateCellFill(const std::string & mat_name);
     133             : 
     134             :   /**
     135             :    * @brief Set the cell fill to a universe
     136             :    *
     137             :    * @param univ universe fill
     138             :    */
     139             :   void updateCellFill(const CSGUniverse * univ);
     140             : 
     141             :   /**
     142             :    * @brief Set the cell fill to a lattice
     143             :    *
     144             :    * @param lattice lattice fill
     145             :    */
     146             :   void updateCellFill(const CSGLattice * lattice);
     147             : 
     148             :   /// Operator overload for checking if two CSGCell objects are equal
     149             :   bool operator==(const CSGCell & other) const;
     150             : 
     151             :   /// Operator overload for checking if two CSGCell objects are not equal
     152             :   bool operator!=(const CSGCell & other) const;
     153             : 
     154             : protected:
     155             :   /**
     156             :    * @brief Update surface references of cell region based on map of input surface references
     157             :    *
     158             :    * @param identical_surface_refs map of surface name to surface references that region should be
     159             :    *                               defined with
     160             :    */
     161             :   void updateCellRegionSurfaces(
     162             :       std::map<std::string, std::reference_wrapper<const CSGSurface>> & identical_surface_refs);
     163             : 
     164             :   // set the name of the cell - intentionally not public because
     165             :   // name needs to be managed at the CSGCellList level
     166         118 :   void setName(const std::string & name) { _name = name; }
     167             : 
     168             :   // update the region of the cell to a new region - not public because
     169             :   // it needs to be called from CSGBase so that the surfaces can be checked first.
     170          20 :   void updateRegion(const CSGRegion & region) { _region = region; }
     171             : 
     172             :   /// Name of surface
     173             :   std::string _name;
     174             : 
     175             :   /// An enum for type of fill for cell region
     176             :   MooseEnum _fill_type{"VOID CSG_MATERIAL UNIVERSE LATTICE"};
     177             : 
     178             :   /// name of the fill object for CSG_MATERIAL fills
     179             :   std::string _fill_name;
     180             : 
     181             :   /// Cell region, represented as a CSGRegion object
     182             :   CSGRegion _region;
     183             : 
     184             :   /// Fill object if fill is CSGUniverse
     185             :   const CSGUniverse * _fill_universe;
     186             : 
     187             :   /// Fill object if fill is CSGLattice
     188             :   const CSGLattice * _fill_lattice;
     189             : 
     190             :   friend class CSGCellList; // needed for setName() access
     191             :   friend class CSGBase;     // needed for updateRegion() access
     192             : 
     193             : #ifdef MOOSE_UNIT_TEST
     194             :   /// Friends for unit testing
     195             :   ///@{
     196             :   FRIEND_TEST(CSGCellTest, testSetName);
     197             :   FRIEND_TEST(CSGCellTest, testUpdateRegion);
     198             :   FRIEND_TEST(CSGCellTest, testCellEquality);
     199             :   ///@}
     200             : #endif
     201             : };
     202             : } // namespace CSG

Generated by: LCOV version 1.14