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 : 13 : namespace CSG 14 : { 15 : 16 530 : CSGCell::CSGCell(const std::string & name, const CSGRegion & region) : _name(name), _region(region) 17 : { 18 106 : _fill_type = "VOID"; 19 106 : } 20 : 21 49 : CSGCell::CSGCell(const std::string & name, const std::string & mat_name, const CSGRegion & region) 22 245 : : _name(name), _fill_name(mat_name), _region(region) 23 : { 24 49 : _fill_type = "CSG_MATERIAL"; 25 49 : } 26 : 27 20 : CSGCell::CSGCell(const std::string & name, const CSGUniverse * univ, const CSGRegion & region) 28 100 : : _name(name), _fill_name(univ->getName()), _region(region), _fill_universe(univ) 29 : { 30 20 : _fill_type = "UNIVERSE"; 31 20 : } 32 : 33 : const CSGUniverse & 34 12 : CSGCell::getFillUniverse() const 35 : { 36 12 : if (getFillType() != "UNIVERSE") 37 24 : mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not UNIVERSE."); 38 : else 39 8 : return *_fill_universe; 40 : } 41 : 42 : const std::string & 43 10 : CSGCell::getFillMaterial() const 44 : { 45 10 : if (getFillType() != "CSG_MATERIAL") 46 24 : mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not CSG_MATERIAL."); 47 : else 48 6 : return _fill_name; 49 : } 50 : 51 : bool 52 120 : CSGCell::operator==(const CSG::CSGCell & other) const 53 : { 54 120 : const auto name_eq = this->getName() == other.getName(); 55 120 : const auto region_eq = this->getRegion() == other.getRegion(); 56 : const auto fill_type_eq = 57 120 : (this->getFillType() == other.getFillType()) && (this->getFillName() == other.getFillName()); 58 120 : if (name_eq && region_eq && fill_type_eq) 59 : { 60 10 : if (this->getFillType() == "CSG_MATERIAL") 61 2 : return this->getFillMaterial() == other.getFillMaterial(); 62 8 : else if (this->getFillType() == "UNIVERSE") 63 2 : return this->getFillUniverse() == other.getFillUniverse(); 64 : else 65 6 : return true; 66 : } 67 : else 68 110 : return false; 69 : } 70 : 71 : bool 72 110 : CSGCell::operator!=(const CSG::CSGCell & other) const 73 : { 74 110 : return !(*this == other); 75 : } 76 : 77 : } // namespace CSG