https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CSG::CSGUniverseEngUnit Class Referenceabstract

CSGUniverseEngUnit is an abstract base class for "engineering units" that are universe-like. More...

#include <CSGUniverseEngUnit.h>

Inheritance diagram for CSG::CSGUniverseEngUnit:
[legend]

Public Member Functions

const std::string & getName () const override
 Satisfy CSGEngUnit::getName() (resolved via CSGUniverse::getName()) More...
 
bool isEngUnit () const override
 Engineering units report true so comparisons can skip the dynamic_cast fast path. More...
 
bool operator== (const CSGUniverseEngUnit &other) const
 Disambiguate == and != by forwarding to CSGEngUnit (name/property-based comparison) More...
 
bool operator!= (const CSGUniverseEngUnit &other) const
 
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations () const override
 Delegate to CSGUniverse (CSGTransformationHelper) More...
 
std::vector< std::pair< std::string, std::tuple< Real, Real, Real > > > getTransformationsAsStrings () const override
 Delegate to CSGUniverse (CSGTransformationHelper) More...
 
const CSGCellgetCell (const std::string &name)
 Get the CSGCell object by name. More...
 
bool hasCell (const std::string &name) const
 check if cell of provided name is present in universe More...
 
const std::vector< std::reference_wrapper< const CSGCell > > & getAllCells () const
 Get list of the all cells in the universe. More...
 
bool isRoot () const
 return true if the universe is the root universe More...
 
bool operator== (const CSGUniverse &other) const
 Operator overload for checking if two CSGUniverse objects are equal. More...
 
bool operator!= (const CSGUniverse &other) const
 Operator overload for checking if two CSGUniverse objects are not equal. More...
 
const std::string getBehavior () const
 Get the behavior of this engineering unit (surface (i.e. More...
 
const std::string getUnitType () const
 Get the type name of this engineering unit. More...
 
virtual std::unordered_map< std::string, AttributeVariantgetAttributes () const =0
 Get the attributes that define this engineering unit. More...
 
bool operator== (const CSGEngUnit &other) const
 Operator overload for checking if two CSGEngUnit objects are equal. More...
 
bool operator!= (const CSGEngUnit &other) const
 Operator overload for checking if two CSGEngUnit objects are not equal. More...
 

Static Public Member Functions

static bool isValidTransformationValue (TransformationType type, const std::tuple< Real, Real, Real > &values)
 Check if the transformation value is valid for the given type. More...
 
static std::string getTransformationTypeString (TransformationType type)
 Get the string representation of the transformation type. More...
 

Protected Member Functions

 CSGUniverseEngUnit (const std::string &name, bool is_root=false)
 Constructor for derived classes. More...
 
virtual std::unique_ptr< CSGUniverseEngUnitclone () const =0
 Create a deep copy of this engineering unit for use in a different CSGBase instance. More...
 
void expandUnit () override=0
 Populate _internal_base with the CSGUniverse and any supporting objects. More...
 
const CSGUniversegetExpandedUniverse () const
 Return the root universe of _internal_base, which IS the expanded universe. More...
 
void removeCell (const std::string &name)
 remove a cell of the specified name from the universe More...
 
void removeAllCells ()
 remove all cells from the universe More...
 
void setName (const std::string &name)
 
void addTransformation (TransformationType type, const std::tuple< Real, Real, Real > &values)
 Add a transformation to the list of transformations. More...
 
Point applyReverseTransformsToPoint (Point p) const
 update the value of point p by applying the inverse of the list of transformations to the point More...
 
CSGBasegetBase ()
 Get the internal CSGBase owned by this engineering unit. More...
 
std::unique_ptr< CSGBasereleaseBase ()
 Transfer ownership of the internal CSGBase out of this unit. More...
 
void addCell (const CSGCell &)=delete
 addCell updates are not permitted on engineering units. More...
 
 FRIEND_TEST (CSGUniverseTest, testGetCell)
 Friends for unit testing. More...
 
 FRIEND_TEST (CSGUniverseTest, testAddCell)
 
 FRIEND_TEST (CSGUniverseTest, testRemoveCell)
 
 FRIEND_TEST (CSGUniverseTest, testRemoveAllCells)
 
 FRIEND_TEST (CSGUniverseTest, testSetName)
 
 FRIEND_TEST (CSGUniverseTest, testUniverseEquality)
 
 FRIEND_TEST (CSGSurfaceTest, testHalfspaceWithTransform)
 Friends for unit testing. More...
 
 FRIEND_TEST (CSGSurfaceTest, testHalfspaceWithNullTransform)
 
 FRIEND_TEST (CSGEngUnitTest, testEngUnitEqual)
 

Protected Attributes

std::string _name
 Name of universe. More...
 
std::vector< std::reference_wrapper< const CSGCell > > _cells
 list of references to cells in universe More...
 
bool _is_root
 whether or not this universe is the root universe More...
 
std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > _transformations
 List of transformations applied to this object. More...
 
std::unique_ptr< CSGBase_internal_base
 CSGBase populated by expandUnit(); joined into the parent CSGBase by expandEngUnit() More...
 
MooseEnum _behavior {"SURFACE CELL UNIVERSE"}
 The basic CSG type this unit produces: "SURFACE", "CELL", or "UNIVERSE". More...
 

Friends

class CSGBase
 

Detailed Description

CSGUniverseEngUnit is an abstract base class for "engineering units" that are universe-like.

Derived classes define domain-specific attributes and implement expandUnit() to produce the equivalent CSGUniverse representation, along with all supporting surfaces and cells.

Derived classes must implement:

Definition at line 38 of file CSGUniverseEngUnit.h.

Constructor & Destructor Documentation

◆ CSGUniverseEngUnit()

CSG::CSGUniverseEngUnit::CSGUniverseEngUnit ( const std::string &  name,
bool  is_root = false 
)
protected

Constructor for derived classes.

Parameters
nameunique name of the universe (will be preserved on the plain CSGUniverse)
is_roottrue if this is the root universe (default false)

Definition at line 16 of file CSGUniverseEngUnit.C.

17  : CSGUniverse(name, is_root), CSGEngUnit("UNIVERSE")
18 {
19 }
CSGEngUnit(const std::string &behavior)
Constructor for intermediate EngUnit abstract classes.
Definition: CSGEngUnit.C:18
CSGUniverse(const std::string &name, bool is_root=false)
Construct a new CSGUniverse object.
Definition: CSGUniverse.C:18

Member Function Documentation

◆ addCell()

void CSG::CSGUniverseEngUnit::addCell ( const CSGCell )
protecteddelete

addCell updates are not permitted on engineering units.

The geometry is defined by the derived class and produced only via expandUnit().

◆ addTransformation()

void CSG::CSGTransformationHelper::addTransformation ( TransformationType  type,
const std::tuple< Real, Real, Real > &  values 
)
protectedinherited

Add a transformation to the list of transformations.

Parameters
typeThe type of transformation
valuesThe values for the transformation

Definition at line 16 of file CSGTransformationHelper.C.

Referenced by CSG::CSGBase::expandEngUnit().

18 {
20  mooseError("Invalid transformation values provided for transformation type " +
22  _transformations.emplace_back(type, values);
23 }
static bool isValidTransformationValue(TransformationType type, const std::tuple< Real, Real, Real > &values)
Check if the transformation value is valid for the given type.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
static std::string getTransformationTypeString(TransformationType type)
Get the string representation of the transformation type.
std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > _transformations
List of transformations applied to this object.
std::array< Real, 2 > values
Definition: MortarUtils.C:52

◆ applyReverseTransformsToPoint()

Point CSG::CSGTransformationHelper::applyReverseTransformsToPoint ( Point  p) const
protectedinherited

update the value of point p by applying the inverse of the list of transformations to the point

Parameters
ppoint to transform
Returns
transformed point

Definition at line 74 of file CSGTransformationHelper.C.

Referenced by CSG::CSGSurface::getHalfspaceFromPoint().

75 {
76  // iterate list of transformations in reverse and apply the inverse operation
77  for (auto it = _transformations.rbegin(); it != _transformations.rend(); ++it)
78  {
79  auto trans_type = it->first;
80  auto val = it->second;
81 
82  if (trans_type == TransformationType::TRANSLATION)
83  {
84  Point offset(std::get<0>(val), std::get<1>(val), std::get<2>(val));
85  p -= offset;
86  }
87  else if (trans_type == TransformationType::SCALE)
88  {
89  Point scale(std::get<0>(val), std::get<1>(val), std::get<2>(val));
90  for (int i = 0; i < 3; ++i)
91  p(i) /= scale(i);
92  }
93  else if (trans_type == TransformationType::ROTATION)
94  {
95  // get the transpose of the original rotation matrix and apply to point p
96  const auto rot_matrix = RealTensorValue::intrinsic_rotation_matrix(
97  std::get<0>(val), std::get<1>(val), std::get<2>(val));
98  const auto rot_transpose = rot_matrix.transpose();
99  p = rot_transpose * p;
100  }
101  else
102  mooseError("Transformation type is not recognized.");
103  }
104  return p;
105 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
Real scale
Definition: MortarUtils.C:62
std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > _transformations
List of transformations applied to this object.
static TensorValue< Real > intrinsic_rotation_matrix(Real phi, Real theta, Real psi)

◆ clone()

virtual std::unique_ptr<CSGUniverseEngUnit> CSG::CSGUniverseEngUnit::clone ( ) const
protectedpure virtual

Create a deep copy of this engineering unit for use in a different CSGBase instance.

Derived classes must implement this and return a fully-constructed copy with the same attributes.

Returns
unique_ptr to a fresh copy of this engineering unit

◆ expandUnit()

void CSG::CSGUniverseEngUnit::expandUnit ( )
overrideprotectedpure virtual

Populate _internal_base with the CSGUniverse and any supporting objects.

Called exclusively by CSGBase. The root universe of _internal_base represents this engineering unit's expanded universe. The implementation should:

  1. Create any needed surfaces via _internal_base->addSurface(...).
  2. Create cells via _internal_base->createCell(...) (they go to the root automatically).
  3. Create any non-root fill universes via _internal_base->createUniverse(...).
  4. Rename the root with _internal_base->renameRootUniverse("desired_name") if needed.

Implements CSG::CSGEngUnit.

Referenced by CSG::CSGBase::expandEngUnit().

◆ FRIEND_TEST() [1/9]

CSG::CSGTransformationHelper::FRIEND_TEST ( CSGSurfaceTest  ,
testHalfspaceWithTransform   
)
protectedinherited

Friends for unit testing.

◆ FRIEND_TEST() [2/9]

CSG::CSGTransformationHelper::FRIEND_TEST ( CSGSurfaceTest  ,
testHalfspaceWithNullTransform   
)
protectedinherited

◆ FRIEND_TEST() [3/9]

CSG::CSGTransformationHelper::FRIEND_TEST ( CSGEngUnitTest  ,
testEngUnitEqual   
)
protectedinherited

◆ FRIEND_TEST() [4/9]

CSG::CSGUniverse::FRIEND_TEST ( CSGUniverseTest  ,
testGetCell   
)
protectedinherited

Friends for unit testing.

◆ FRIEND_TEST() [5/9]

CSG::CSGUniverse::FRIEND_TEST ( CSGUniverseTest  ,
testAddCell   
)
protectedinherited

◆ FRIEND_TEST() [6/9]

CSG::CSGUniverse::FRIEND_TEST ( CSGUniverseTest  ,
testRemoveCell   
)
protectedinherited

◆ FRIEND_TEST() [7/9]

CSG::CSGUniverse::FRIEND_TEST ( CSGUniverseTest  ,
testRemoveAllCells   
)
protectedinherited

◆ FRIEND_TEST() [8/9]

CSG::CSGUniverse::FRIEND_TEST ( CSGUniverseTest  ,
testSetName   
)
protectedinherited

◆ FRIEND_TEST() [9/9]

CSG::CSGUniverse::FRIEND_TEST ( CSGUniverseTest  ,
testUniverseEquality   
)
protectedinherited

◆ getAllCells()

const std::vector<std::reference_wrapper<const CSGCell> >& CSG::CSGUniverse::getAllCells ( ) const
inlineinherited

Get list of the all cells in the universe.

Returns
list of pointers to cells in universe

Definition at line 73 of file CSGUniverse.h.

Referenced by CSG::CSGBase::addUniverseToList(), CSG::CSGBase::CSGBase(), CSG::CSGBase::getLinkedUniverses(), CSG::CSGUniverse::operator==(), and CSG::CSGBase::replaceCellRefs().

73 { return _cells; }
std::vector< std::reference_wrapper< const CSGCell > > _cells
list of references to cells in universe
Definition: CSGUniverse.h:134

◆ getAttributes()

virtual std::unordered_map<std::string, AttributeVariant> CSG::CSGEngUnit::getAttributes ( ) const
pure virtualinherited

Get the attributes that define this engineering unit.

Returns a map of domain-specific parameter names to their values, describing the EngUnit in meaningful engineering terms.

Returns
map of attribute name to AttributeVariant value

Implemented in CSG::CSGNPolygonUnit.

Referenced by CSG::CSGEngUnit::operator==().

◆ getBase()

CSGBase& CSG::CSGEngUnit::getBase ( )
inlineprotectedinherited

Get the internal CSGBase owned by this engineering unit.

Returns
reference to the internal CSGBase

Definition at line 117 of file CSGEngUnit.h.

117 { return *_internal_base; }
std::unique_ptr< CSGBase > _internal_base
CSGBase populated by expandUnit(); joined into the parent CSGBase by expandEngUnit() ...
Definition: CSGEngUnit.h:130

◆ getBehavior()

const std::string CSG::CSGEngUnit::getBehavior ( ) const
inlineinherited

Get the behavior of this engineering unit (surface (i.e.

region), cell, or universe).

Returns "SURFACE", "CELL", or "UNIVERSE" depending on which intermediate EngUnit class the concrete type derives from. Set automatically at construction.

Returns
the behavior string

Definition at line 56 of file CSGEngUnit.h.

Referenced by CSG::CSGEngUnit::operator==().

56 { return _behavior; }
MooseEnum _behavior
The basic CSG type this unit produces: "SURFACE", "CELL", or "UNIVERSE".
Definition: CSGEngUnit.h:133

◆ getCell()

const CSGCell & CSG::CSGUniverse::getCell ( const std::string &  name)
inherited

Get the CSGCell object by name.

Parameters
namename of cell
Returns
reference to the cell of the specified name in this universe

Definition at line 40 of file CSGUniverse.C.

41 {
42  if (!hasCell(name))
43  mooseError("Cell with name " + name + " does not exist in universe " + _name + ".");
44  for (const CSGCell & cell : _cells)
45  if (cell.getName() == name)
46  return cell;
47  mooseError("Should not reach here.");
48 }
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::string _name
Name of universe.
Definition: CSGUniverse.h:131
bool hasCell(const std::string &name) const
check if cell of provided name is present in universe
Definition: CSGUniverse.C:51
std::vector< std::reference_wrapper< const CSGCell > > _cells
list of references to cells in universe
Definition: CSGUniverse.h:134

◆ getExpandedUniverse()

const CSGUniverse & CSG::CSGUniverseEngUnit::getExpandedUniverse ( ) const
protected

Return the root universe of _internal_base, which IS the expanded universe.

Valid after expandUnit() has populated _internal_base. Not valid after CSGBase::expandEngUnit() has run (the internal base is consumed by the join).

Returns
const reference to the root CSGUniverse of _internal_base

Definition at line 22 of file CSGUniverseEngUnit.C.

23 {
24  // if root universe contains no cells, then it has not be expanded (or not implemented correctly)
25  if (_internal_base->getRootUniverse().getAllCells().empty())
26  mooseError("Root universe of ",
27  getName(),
28  " contains no cells. ",
29  "Either getExpandedUniverse() has been called before expandUnit() or expandUnit() ",
30  "is not implemented correctly.");
31 
32  // Check that all universes and cells created in _internal_base are reachable from the root.
33  if (!_internal_base->areUniversesLinked())
34  mooseError("CSGUniverseEngUnit '",
35  getName(),
36  "' of type '",
37  getUnitType(),
38  "' contains unlinked universes or cells. All objects created in expandUnit() must be"
39  " reachable from the expanded root universe. Check implementation of expandUnit().");
40 
41  return _internal_base->getRootUniverse();
42 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::unique_ptr< CSGBase > _internal_base
CSGBase populated by expandUnit(); joined into the parent CSGBase by expandEngUnit() ...
Definition: CSGEngUnit.h:130
const std::string & getName() const override
Satisfy CSGEngUnit::getName() (resolved via CSGUniverse::getName())
const std::string getUnitType() const
Get the type name of this engineering unit.
Definition: CSGEngUnit.h:63

◆ getName()

const std::string& CSG::CSGUniverseEngUnit::getName ( ) const
inlineoverridevirtual

Satisfy CSGEngUnit::getName() (resolved via CSGUniverse::getName())

Implements CSG::CSGEngUnit.

Definition at line 42 of file CSGUniverseEngUnit.h.

Referenced by CSG::CSGBase::expandEngUnit(), and getExpandedUniverse().

42 { return CSGUniverse::getName(); }
const std::string & getName() const
Get the name of the universe.
Definition: CSGUniverse.h:80

◆ getTransformations()

const std::vector<std::pair<TransformationType, std::tuple<Real, Real, Real> > >& CSG::CSGUniverseEngUnit::getTransformations ( ) const
inlineoverridevirtual

Delegate to CSGUniverse (CSGTransformationHelper)

Implements CSG::CSGEngUnit.

Definition at line 53 of file CSGUniverseEngUnit.h.

54  {
56  }
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const
Get the list of transformations.

◆ getTransformationsAsStrings()

std::vector<std::pair<std::string, std::tuple<Real, Real, Real> > > CSG::CSGUniverseEngUnit::getTransformationsAsStrings ( ) const
inlineoverridevirtual

Delegate to CSGUniverse (CSGTransformationHelper)

Implements CSG::CSGEngUnit.

Definition at line 60 of file CSGUniverseEngUnit.h.

61  {
63  }
std::vector< std::pair< std::string, std::tuple< Real, Real, Real > > > getTransformationsAsStrings() const
Get the transformations of this object with string representations for types.

◆ getTransformationTypeString()

std::string CSG::CSGTransformationHelper::getTransformationTypeString ( TransformationType  type)
staticinherited

Get the string representation of the transformation type.

Parameters
typeThe transformation type
Returns
String name of the transformation type

Definition at line 56 of file CSGTransformationHelper.C.

Referenced by CSG::CSGTransformationHelper::addTransformation(), and CSG::CSGTransformationHelper::getTransformationsAsStrings().

57 {
58  // Set the enum to the value and convert it to string
60  enum_copy = static_cast<int>(type);
61  return std::string(enum_copy);
62 }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:54
static const MooseEnum transformation_type_enum
MooseEnum for transformation types, matching the TransformationType enum values.

◆ getUnitType()

const std::string CSG::CSGEngUnit::getUnitType ( ) const
inlineinherited

Get the type name of this engineering unit.

Returns
the unit type string

Definition at line 63 of file CSGEngUnit.h.

Referenced by CSG::CSGCellEngUnit::getExpandedCell(), getExpandedUniverse(), and CSG::CSGEngUnit::operator==().

64  {
65  return MooseUtils::prettyCppType(libMesh::demangle(typeid(*this).name()));
66  }
std::string demangle(const char *name)
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1151

◆ hasCell()

bool CSG::CSGUniverse::hasCell ( const std::string &  name) const
inherited

check if cell of provided name is present in universe

Parameters
namename of cell
Returns
true if cell of name is in universe, otherwise false

Definition at line 51 of file CSGUniverse.C.

Referenced by CSG::CSGUniverse::addCell(), CSG::CSGUniverse::getCell(), and CSG::CSGUniverse::removeCell().

52 {
53  for (const CSGCell & cell : _cells)
54  if (cell.getName() == name)
55  return true;
56  return false;
57 }
std::string name(const ElemQuality q)
std::vector< std::reference_wrapper< const CSGCell > > _cells
list of references to cells in universe
Definition: CSGUniverse.h:134

◆ isEngUnit()

bool CSG::CSGUniverseEngUnit::isEngUnit ( ) const
inlineoverridevirtual

Engineering units report true so comparisons can skip the dynamic_cast fast path.

Reimplemented from CSG::CSGUniverse.

Definition at line 45 of file CSGUniverseEngUnit.h.

45 { return true; }

◆ isRoot()

bool CSG::CSGUniverse::isRoot ( ) const
inlineinherited

return true if the universe is the root universe

Returns
true / false

Definition at line 87 of file CSGUniverse.h.

87 { return _is_root; }
bool _is_root
whether or not this universe is the root universe
Definition: CSGUniverse.h:137

◆ isValidTransformationValue()

bool CSG::CSGTransformationHelper::isValidTransformationValue ( TransformationType  type,
const std::tuple< Real, Real, Real > &  values 
)
staticinherited

Check if the transformation value is valid for the given type.

Parameters
typeThe type of transformation
valuesThe values for the transformation
Returns
True if the values are valid for the type

Definition at line 26 of file CSGTransformationHelper.C.

Referenced by CSG::CSGTransformationHelper::addTransformation().

28 {
29  // Additional validation specific to each transformation type could be added here
30  switch (type)
31  {
33  // All translation values are inherently valid
34  return true;
35 
37  // Rotation uses euler notation; values are angles in degrees (phi, theta, psi)
38  // For consistency with TransformGenerator, there are no restrictions on the angles
39  // phi: rotation around Z-axis
40  // theta: rotation around new X-axis
41  // psi: rotation around new Z-axis
42  return true;
43 
45  // Scaling factors should be non-zero
46  if (std::get<0>(values) == 0.0 || std::get<1>(values) == 0.0 || std::get<2>(values) == 0.0)
47  return false;
48  return true;
49 
50  default:
51  mooseError("Unknown transformation type");
52  }
53 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::array< Real, 2 > values
Definition: MortarUtils.C:52

◆ operator!=() [1/3]

bool CSG::CSGUniverseEngUnit::operator!= ( const CSGUniverseEngUnit other) const
inline

Definition at line 49 of file CSGUniverseEngUnit.h.

49 { return CSGEngUnit::operator!=(other); }
bool operator!=(const CSGEngUnit &other) const
Operator overload for checking if two CSGEngUnit objects are not equal.
Definition: CSGEngUnit.C:50

◆ operator!=() [2/3]

bool CSG::CSGEngUnit::operator!= ( const CSGEngUnit other) const
inherited

Operator overload for checking if two CSGEngUnit objects are not equal.

Definition at line 50 of file CSGEngUnit.C.

Referenced by CSG::CSGCellEngUnit::operator!=(), operator!=(), and CSG::CSGSurfaceEngUnit::operator!=().

51 {
52  return !(*this == other);
53 }

◆ operator!=() [3/3]

bool CSG::CSGUniverse::operator!= ( const CSGUniverse other) const
inherited

Operator overload for checking if two CSGUniverse objects are not equal.

Definition at line 104 of file CSGUniverse.C.

105 {
106  return !(*this == other);
107 }

◆ operator==() [1/3]

bool CSG::CSGUniverseEngUnit::operator== ( const CSGUniverseEngUnit other) const
inline

Disambiguate == and != by forwarding to CSGEngUnit (name/property-based comparison)

Definition at line 48 of file CSGUniverseEngUnit.h.

48 { return CSGEngUnit::operator==(other); }
bool operator==(const CSGEngUnit &other) const
Operator overload for checking if two CSGEngUnit objects are equal.
Definition: CSGEngUnit.C:34

◆ operator==() [2/3]

bool CSG::CSGEngUnit::operator== ( const CSGEngUnit other) const
inherited

Operator overload for checking if two CSGEngUnit objects are equal.

Definition at line 34 of file CSGEngUnit.C.

Referenced by CSG::CSGCellEngUnit::operator==(), operator==(), and CSG::CSGSurfaceEngUnit::operator==().

35 {
36  if (getName() != other.getName())
37  return false;
38  if (getBehavior() != other.getBehavior())
39  return false;
40  if (getUnitType() != other.getUnitType())
41  return false;
42  if (getAttributes() != other.getAttributes())
43  return false;
44  if (getTransformations() != other.getTransformations())
45  return false;
46  return true;
47 }
virtual const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const =0
Get the list of transformations applied to this engineering unit.
const std::string getUnitType() const
Get the type name of this engineering unit.
Definition: CSGEngUnit.h:63
virtual std::unordered_map< std::string, AttributeVariant > getAttributes() const =0
Get the attributes that define this engineering unit.
const std::string getBehavior() const
Get the behavior of this engineering unit (surface (i.e.
Definition: CSGEngUnit.h:56
virtual const std::string & getName() const =0
Get the unique instance name of this engineering unit.

◆ operator==() [3/3]

bool CSG::CSGUniverse::operator== ( const CSGUniverse other) const
inherited

Operator overload for checking if two CSGUniverse objects are equal.

Definition at line 74 of file CSGUniverse.C.

75 {
76  // If both objects are engineering units, delegate to CSGEngUnit::operator==. The
77  // isEngUnit() check keeps the common plain-universe path free of any dynamic_cast;
78  // the casts below only run once we know the objects are engineering units.
79  if (isEngUnit())
80  {
81  if (other.isEngUnit())
82  return *dynamic_cast<const CSGEngUnit *>(this) == *dynamic_cast<const CSGEngUnit *>(&other);
83  return false; // an engineering unit cannot equal a plain universe
84  }
85 
86  if ((this->getName() != other.getName()) ||
87  (this->getTransformations() != other.getTransformations()))
88  return false;
89  const auto & all_cells = getAllCells();
90  const auto & other_cells = other.getAllCells();
91  const bool num_cells_eq = all_cells.size() == other_cells.size();
92  if (num_cells_eq)
93  {
94  for (unsigned int i = 0; i < all_cells.size(); ++i)
95  if (all_cells[i].get() != other_cells[i].get())
96  return false;
97  return true;
98  }
99  else
100  return false;
101 }
const std::vector< std::reference_wrapper< const CSGCell > > & getAllCells() const
Get list of the all cells in the universe.
Definition: CSGUniverse.h:73
const std::string & getName() const
Get the name of the universe.
Definition: CSGUniverse.h:80
virtual bool isEngUnit() const
Whether this universe is an engineering unit.
Definition: CSGUniverse.h:98
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const
Get the list of transformations.

◆ releaseBase()

std::unique_ptr< CSGBase > CSG::CSGEngUnit::releaseBase ( )
protectedinherited

Transfer ownership of the internal CSGBase out of this unit.

Called once by CSGBase::expandEngUnit() to join the internal base into the parent. After this call _internal_base is null.

Returns
unique_ptr to the internal CSGBase

Definition at line 28 of file CSGEngUnit.C.

29 {
30  return std::move(_internal_base);
31 }
std::unique_ptr< CSGBase > _internal_base
CSGBase populated by expandUnit(); joined into the parent CSGBase by expandEngUnit() ...
Definition: CSGEngUnit.h:130

◆ removeAllCells()

void CSG::CSGUniverse::removeAllCells ( )
inlineprotectedinherited

remove all cells from the universe

Definition at line 124 of file CSGUniverse.h.

124 { _cells.clear(); }
std::vector< std::reference_wrapper< const CSGCell > > _cells
list of references to cells in universe
Definition: CSGUniverse.h:134

◆ removeCell()

void CSG::CSGUniverse::removeCell ( const std::string &  name)
protectedinherited

remove a cell of the specified name from the universe

Parameters
namename of cell to remove

Definition at line 60 of file CSGUniverse.C.

Referenced by CSG::CSGBase::removeCellFromUniverse().

61 {
62  if (!hasCell(name))
63  mooseError("Cannot remove cell. Cell with name " + name + " does not exist in universe " +
64  _name + ".");
65  for (auto it = _cells.begin(); it != _cells.end(); ++it)
66  if (it->get().getName() == name)
67  {
68  _cells.erase(it);
69  break;
70  }
71 }
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::string _name
Name of universe.
Definition: CSGUniverse.h:131
bool hasCell(const std::string &name) const
check if cell of provided name is present in universe
Definition: CSGUniverse.C:51
std::vector< std::reference_wrapper< const CSGCell > > _cells
list of references to cells in universe
Definition: CSGUniverse.h:134

◆ setName()

void CSG::CSGUniverse::setName ( const std::string &  name)
inlineprotectedinherited

Definition at line 128 of file CSGUniverse.h.

128 { _name = name; }
std::string name(const ElemQuality q)
std::string _name
Name of universe.
Definition: CSGUniverse.h:131

Friends And Related Function Documentation

◆ CSGBase

friend class CSGBase
friend

Definition at line 113 of file CSGUniverseEngUnit.h.

Member Data Documentation

◆ _behavior

MooseEnum CSG::CSGEngUnit::_behavior {"SURFACE CELL UNIVERSE"}
protectedinherited

The basic CSG type this unit produces: "SURFACE", "CELL", or "UNIVERSE".

Definition at line 133 of file CSGEngUnit.h.

Referenced by CSG::CSGEngUnit::CSGEngUnit(), and CSG::CSGEngUnit::getBehavior().

◆ _cells

std::vector<std::reference_wrapper<const CSGCell> > CSG::CSGUniverse::_cells
protectedinherited

◆ _internal_base

std::unique_ptr<CSGBase> CSG::CSGEngUnit::_internal_base
protectedinherited

◆ _is_root

bool CSG::CSGUniverse::_is_root
protectedinherited

whether or not this universe is the root universe

Definition at line 137 of file CSGUniverse.h.

Referenced by CSG::CSGUniverse::isRoot().

◆ _name

std::string CSG::CSGUniverse::_name
protectedinherited

◆ _transformations

std::vector<std::pair<TransformationType, std::tuple<Real, Real, Real> > > CSG::CSGTransformationHelper::_transformations
protectedinherited

The documentation for this class was generated from the following files: