https://mooseframework.inl.gov
CSGCell.C
Go to the documentation of this file.
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 CSGCell::CSGCell(const std::string & name, const CSGRegion & region) : _name(name), _region(region)
17 {
18  _fill_type = "VOID";
19 }
20 
21 CSGCell::CSGCell(const std::string & name, const std::string & mat_name, const CSGRegion & region)
22  : _name(name), _fill_name(mat_name), _region(region)
23 {
24  _fill_type = "CSG_MATERIAL";
25 }
26 
27 CSGCell::CSGCell(const std::string & name, const CSGUniverse * univ, const CSGRegion & region)
28  : _name(name), _fill_name(univ->getName()), _region(region), _fill_universe(univ)
29 {
30  _fill_type = "UNIVERSE";
31 }
32 
33 const CSGUniverse &
35 {
36  if (getFillType() != "UNIVERSE")
37  mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not UNIVERSE.");
38  else
39  return *_fill_universe;
40 }
41 
42 const std::string &
44 {
45  if (getFillType() != "CSG_MATERIAL")
46  mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not CSG_MATERIAL.");
47  else
48  return _fill_name;
49 }
50 
51 bool
52 CSGCell::operator==(const CSG::CSGCell & other) const
53 {
54  const auto name_eq = this->getName() == other.getName();
55  const auto region_eq = this->getRegion() == other.getRegion();
56  const auto fill_type_eq =
57  (this->getFillType() == other.getFillType()) && (this->getFillName() == other.getFillName());
58  if (name_eq && region_eq && fill_type_eq)
59  {
60  if (this->getFillType() == "CSG_MATERIAL")
61  return this->getFillMaterial() == other.getFillMaterial();
62  else if (this->getFillType() == "UNIVERSE")
63  return this->getFillUniverse() == other.getFillUniverse();
64  else
65  return true;
66  }
67  else
68  return false;
69 }
70 
71 bool
72 CSGCell::operator!=(const CSG::CSGCell & other) const
73 {
74  return !(*this == other);
75 }
76 
77 } // namespace CSG
std::string name(const ElemQuality q)
const CSGUniverse & getFillUniverse() const
Get the cell fill if fill type is UNIVERSE.
Definition: CSGCell.C:34
const std::string & getName() const
Get the cell name.
Definition: CSGCell.h:94
const std::string getFillType() const
Get the type of fill for the cell.
Definition: CSGCell.h:66
MooseEnum _fill_type
An enum for type of fill for cell region.
Definition: CSGCell.h:130
CSGRegions creates an internal representation of a CSG region, which can refer to an intersection...
Definition: CSGRegion.h:21
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe...
Definition: CSGUniverse.h:26
const std::string & getFillName() const
Get the name of the fill, regardless of its type.
Definition: CSGCell.h:87
CSGCell(const std::string &name, const CSGRegion &region)
Constructor for void cell.
Definition: CSGCell.C:16
CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell...
Definition: CSGCell.h:27
bool operator!=(const CSGCell &other) const
Operator overload for checking if two CSGCell objects are not equal.
Definition: CSGCell.C:72
std::string _fill_name
name of the fill object
Definition: CSGCell.h:133
const CSGRegion & getRegion() const
Get the cell region.
Definition: CSGCell.h:101
const CSGUniverse * _fill_universe
Fill object if fill is CSGUniverse.
Definition: CSGCell.h:139
const std::string & getFillMaterial() const
Get the cell fill material name if fill fype is CSG_MATERIAL.
Definition: CSGCell.C:43
bool operator==(const CSGCell &other) const
Operator overload for checking if two CSGCell objects are equal.
Definition: CSGCell.C:52