LCOV - code coverage report
Current view: top level - src/csg - CSGCell.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: fa5e60 Lines: 77 78 98.7 %
Date: 2026-06-24 08:03:36 Functions: 15 15 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             : #include "CSGCell.h"
      11             : #include "CSGUniverse.h"
      12             : #include "CSGLattice.h"
      13             : #include "CSGUtils.h"
      14             : 
      15             : namespace CSG
      16             : {
      17             : 
      18         154 : CSGCell::CSGCell(const std::string & name, const CSGRegion & region)
      19        1078 :   : _name(name), _fill_name(""), _region(region)
      20             : {
      21         154 :   CSGUtils::checkValidCSGName(name);
      22         154 :   _fill_type = "VOID";
      23         154 : }
      24             : 
      25         155 : CSGCell::CSGCell(const std::string & name, const std::string & mat_name, const CSGRegion & region)
      26         775 :   : _name(name), _fill_name(mat_name), _region(region)
      27             : {
      28         155 :   CSGUtils::checkValidCSGName(name);
      29         155 :   _fill_type = "CSG_MATERIAL";
      30         155 : }
      31             : 
      32          62 : CSGCell::CSGCell(const std::string & name, const CSGUniverse * univ, const CSGRegion & region)
      33         434 :   : _name(name), _fill_name(""), _region(region), _fill_universe(univ)
      34             : {
      35          62 :   CSGUtils::checkValidCSGName(name);
      36          62 :   _fill_type = "UNIVERSE";
      37          62 : }
      38             : 
      39          78 : CSGCell::CSGCell(const std::string & name, const CSGLattice * lattice, const CSGRegion & region)
      40         546 :   : _name(name), _fill_name(""), _region(region), _fill_lattice(lattice)
      41             : {
      42          78 :   CSGUtils::checkValidCSGName(name);
      43          78 :   _fill_type = "LATTICE";
      44          78 : }
      45             : 
      46             : const std::string &
      47         494 : CSGCell::getFillName() const
      48             : {
      49         494 :   if (getFillType() == "UNIVERSE")
      50          94 :     return _fill_universe->getName();
      51         400 :   else if (getFillType() == "LATTICE")
      52         100 :     return _fill_lattice->getName();
      53             :   else
      54         300 :     return _fill_name;
      55             : }
      56             : 
      57             : const CSGUniverse &
      58         148 : CSGCell::getFillUniverse() const
      59             : {
      60         148 :   if (getFillType() != "UNIVERSE")
      61          24 :     mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not UNIVERSE.");
      62             :   else
      63         144 :     return *_fill_universe;
      64             : }
      65             : 
      66             : const std::string &
      67          80 : CSGCell::getFillMaterial() const
      68             : {
      69          80 :   if (getFillType() != "CSG_MATERIAL")
      70          24 :     mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not CSG_MATERIAL.");
      71             :   else
      72          76 :     return _fill_name;
      73             : }
      74             : 
      75             : const CSGLattice &
      76         184 : CSGCell::getFillLattice() const
      77             : {
      78         184 :   if (getFillType() != "LATTICE")
      79           0 :     mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not LATTICE.");
      80             :   else
      81         184 :     return *_fill_lattice;
      82             : }
      83             : 
      84             : void
      85          34 : CSGCell::resetCellFill()
      86             : {
      87          34 :   _fill_name = "";
      88          34 :   _fill_universe = nullptr;
      89          34 :   _fill_lattice = nullptr;
      90          34 :   _fill_type = "VOID";
      91          34 : }
      92             : 
      93             : void
      94           4 : CSGCell::updateCellFill(const std::string & mat_name)
      95             : {
      96           4 :   resetCellFill();
      97           4 :   _fill_type = "CSG_MATERIAL";
      98           4 :   _fill_name = mat_name;
      99           4 : }
     100             : 
     101             : void
     102          12 : CSGCell::updateCellFill(const CSGUniverse * univ)
     103             : {
     104          12 :   resetCellFill();
     105          12 :   _fill_type = "UNIVERSE";
     106          12 :   _fill_universe = univ;
     107          12 : }
     108             : 
     109             : void
     110          10 : CSGCell::updateCellFill(const CSGLattice * lattice)
     111             : {
     112          10 :   resetCellFill();
     113          10 :   _fill_type = "LATTICE";
     114          10 :   _fill_lattice = lattice;
     115          10 : }
     116             : 
     117             : void
     118           4 : CSGCell::updateCellRegionSurfaces(
     119             :     std::map<std::string, std::reference_wrapper<const CSGSurface>> & identical_surface_refs)
     120             : {
     121           4 :   _region.updateSurfaceReferences(identical_surface_refs);
     122           4 : }
     123             : 
     124             : bool
     125         226 : CSGCell::operator==(const CSG::CSGCell & other) const
     126             : {
     127         226 :   const auto name_eq = this->getName() == other.getName();
     128         226 :   const auto region_eq = this->getRegion() == other.getRegion();
     129             :   const auto fill_type_eq =
     130         226 :       (this->getFillType() == other.getFillType()) && (this->getFillName() == other.getFillName());
     131         226 :   const auto transformations_eq = this->getTransformations() == other.getTransformations();
     132         226 :   if (name_eq && region_eq && fill_type_eq && transformations_eq)
     133             :   {
     134          90 :     if (this->getFillType() == "CSG_MATERIAL")
     135          18 :       return this->getFillMaterial() == other.getFillMaterial();
     136          72 :     else if (this->getFillType() == "UNIVERSE")
     137          18 :       return this->getFillUniverse() == other.getFillUniverse();
     138          54 :     else if (this->getFillType() == "LATTICE")
     139          20 :       return this->getFillLattice() == other.getFillLattice();
     140             :     else
     141          34 :       return true;
     142             :   }
     143             :   else
     144         136 :     return false;
     145             : }
     146             : 
     147             : bool
     148         192 : CSGCell::operator!=(const CSG::CSGCell & other) const
     149             : {
     150         192 :   return !(*this == other);
     151             : }
     152             : 
     153             : } // namespace CSG

Generated by: LCOV version 1.14