https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CSG::CSGCartesianLattice Class Reference

CSGCartesianLattice is the class for constructing regular Cartesian lattices of CSGUniverses. More...

#include <CSGCartesianLattice.h>

Inheritance diagram for CSG::CSGCartesianLattice:
[legend]

Public Member Functions

 CSGCartesianLattice (const std::string &name, const Real pitch, std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > universes, const std::optional< OuterVariant > &outer=std::nullopt)
 Construct a new CSGCartesianLattice object from the map of universes provided.
 
 CSGCartesianLattice (const std::string &name, const Real pitch, const std::optional< OuterVariant > &outer=std::nullopt)
 Construct a new empty CSGCartesianLattice object with specified pitch.
 
virtual ~CSGCartesianLattice ()=default
 Destructor.
 
std::unique_ptr< CSGLatticeclone () const override
 clone this Cartesian lattice
 
virtual std::unordered_map< std::string, AttributeVariantgetAttributes () const override
 Get attributes that define the lattice (excluding the universe map).
 
virtual bool isValidIndex (const std::pair< int, int > index) const override
 Checks if the given index location (row, column) is a valid index for the lattice.
 
virtual bool isValidUniverseMap (std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > universes) const override
 check that any provided list of list of CSGUniverses are the correct dimensions.
 
unsigned int getNRows () const
 get the number of rows
 
unsigned int getNCols () const
 get number of columns
 
Real getPitch () const
 get lattice pitch
 
void setPitch (Real pitch)
 set the pitch of the lattice
 
const std::string & getName () const
 Get the name of lattice.
 
const std::string getType () const
 Get the lattice type.
 
const std::string getOuterType () const
 Get the type of outer that fills the space around the lattice elements.
 
const CSGUniversegetOuterUniverse () const
 Get the outer universe if outer type is UNIVERSE.
 
const std::string & getOuterMaterial () const
 Get the outer material name if outer fype is CSG_MATERIAL.
 
std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > getUniverses () const
 Get the arrangement of CSGUniverses in the lattice.
 
const std::vector< std::vector< std::string > > getUniverseNameMap () const
 Get the arrangement of CSGUniverses in the lattice as their names.
 
bool hasUniverse (const std::string &name) const
 whether or not the universe of the specified name exists in the lattice
 
const CSGUniversegetUniverseAtIndex (const std::pair< int, int > index)
 Get the universe located at the given index.
 
const std::vector< std::pair< unsigned int, unsigned int > > getUniverseIndices (const std::string &univ_name) const
 get all locations in lattice where universe of the specified name exists
 
void resetOuter ()
 reset the outer fill around the lattice elements to be VOID
 
const std::vector< std::reference_wrapper< const CSGUniverse > > getUniqueUniverses () const
 Get the list of unique universe objects in the lattice.
 
bool operator== (const CSGLattice &other) const
 Operator overload for checking if two CSGLattice objects are equal.
 
bool operator!= (const CSGLattice &other) const
 Operator overload for checking if two CSGLattice objects are not equal.
 
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations () const
 Get the list of transformations.
 
std::vector< std::pair< std::string, std::tuple< Real, Real, Real > > > getTransformationsAsStrings () const
 Get the transformations of this object with string representations for types.
 

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.
 
static std::string getTransformationTypeString (TransformationType type)
 Get the string representation of the transformation type.
 

Protected Member Functions

virtual bool compareAttributes (const CSGLattice &other) const override
 compare the attributes returned in getAttributes of this lattice to another lattice
 
virtual void setUniverses (std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > universes) override
 set the universes that define the lattice layout
 
void setName (const std::string &name)
 
void setUniverseAtIndex (const CSGUniverse &universe, const std::pair< int, int > index)
 replace the element at specified index in the lattice with the provided CSGUniverse.
 
void updateOuter (const std::string &outer_name)
 Update the outer of the lattice to be the provided material name.
 
void updateOuter (const CSGUniverse &outer_universe)
 Update the outer of the lattice to be the provided universe.
 
void addTransformation (TransformationType type, const std::tuple< Real, Real, Real > &values)
 Add a transformation to the list of transformations.
 
Point applyReverseTransformsToPoint (Point p) const
 update the value of point p by applying the inverse of the list of transformations to the point
 
 FRIEND_TEST (CSGLatticeTest, testCartSetUniverses)
 Friends for unit testing.
 
 FRIEND_TEST (CSGLatticeTest, testCartSetUniverseAtIndex)
 
 FRIEND_TEST (CSGLatticeTest, testEmptyToFilled)
 
 FRIEND_TEST (CSGLatticeTest, testCartLatticeEquality)
 
 FRIEND_TEST (CSGLatticeTest, testSetName)
 Friends for unit testing.
 
 FRIEND_TEST (CSGLatticeTest, testUpdateOuter)
 
 FRIEND_TEST (CSGBaseTest, testAddLattice)
 
 FRIEND_TEST (CSGSurfaceTest, testHalfspaceWithTransform)
 Friends for unit testing.
 
 FRIEND_TEST (CSGSurfaceTest, testHalfspaceWithNullTransform)
 
 FRIEND_TEST (CSGEngUnitTest, testEngUnitEqual)
 

Protected Attributes

Real _pitch
 pitch
 
unsigned int _nrow
 number of elements in the first dimension (rows)
 
unsigned int _ncol
 number of elements in the second direction (columns)
 
std::string _name
 Name of lattice.
 
std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > _universe_map
 Universes in the arrangement of how they appear in the lattice; dimensions depends on lattice type.
 
std::string _outer_type
 An enum for type of outer fill for lattice.
 
std::string _outer_material
 name of the outer material
 
const CSGUniverse_outer_universe
 outer object if fill is CSGUniverse
 
std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > _transformations
 List of transformations applied to this object.
 

Friends

class CSGBase
 

Detailed Description

CSGCartesianLattice is the class for constructing regular Cartesian lattices of CSGUniverses.

Definition at line 24 of file CSGCartesianLattice.h.

Constructor & Destructor Documentation

◆ CSGCartesianLattice() [1/2]

CSG::CSGCartesianLattice::CSGCartesianLattice ( const std::string &  name,
const Real  pitch,
std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > >  universes,
const std::optional< OuterVariant > &  outer = std::nullopt 
)

Construct a new CSGCartesianLattice object from the map of universes provided.

Parameters
nameunique identifying name of lattice
pitchpitch of lattice elements
universeslist of list of universes to set as the lattice map
outeroptional outer universe or material name that fills space around lattice elements. If not provided, outer is assumed to be VOID.

Definition at line 15 of file CSGCartesianLattice.C.

20 : CSGLattice(name, outer), _pitch(pitch)
21{
22 setUniverses(universes); // this will set _nrow and _ncol
23 if (_pitch < 0)
24 mooseError("Lattice " + getName() + " must have pitch greater than 0.");
25}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
virtual void setUniverses(std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > universes) override
set the universes that define the lattice layout
const std::string & getName() const
Get the name of lattice.
Definition CSGLattice.h:60
CSGLattice(const std::string &name, const std::optional< OuterVariant > &outer=std::nullopt)
Construct a new CSGLattice of specific type.
Definition CSGLattice.C:16

◆ CSGCartesianLattice() [2/2]

CSG::CSGCartesianLattice::CSGCartesianLattice ( const std::string &  name,
const Real  pitch,
const std::optional< OuterVariant > &  outer = std::nullopt 
)

Construct a new empty CSGCartesianLattice object with specified pitch.

NOTE: must call setLatticeUniverses to populate the universe map.

Parameters
nameunique identifying name of lattice
pitchpitch of lattice elements
outeroptional outer universe or material name that fills space around lattice elements. If not provided, outer is assumed to be VOID.

Definition at line 27 of file CSGCartesianLattice.C.

30 : CSGLattice(name, outer), _pitch(pitch), _nrow(0), _ncol(0)
31{
32 if (_pitch < 0)
33 mooseError("Lattice " + getName() + " must have pitch greater than 0.");
34}
unsigned int _ncol
number of elements in the second direction (columns)
unsigned int _nrow
number of elements in the first dimension (rows)

◆ ~CSGCartesianLattice()

virtual CSG::CSGCartesianLattice::~CSGCartesianLattice ( )
virtualdefault

Destructor.

Member Function Documentation

◆ 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.

18{
20 mooseError("Invalid transformation values provided for transformation type " +
22 _transformations.emplace_back(type, values);
23}
std::array< Real, 2 > values
Definition MortarUtils.C:52
static std::string getTransformationTypeString(TransformationType type)
Get the string representation of the transformation type.
static bool isValidTransformationValue(TransformationType type, const std::tuple< Real, Real, Real > &values)
Check if the transformation value is valid for the given type.
std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > _transformations
List of transformations applied to this object.

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

◆ 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.

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}
Real scale
Definition MortarUtils.C:62

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

◆ clone()

std::unique_ptr< CSGLattice > CSG::CSGCartesianLattice::clone ( ) const
inlineoverridevirtual

clone this Cartesian lattice

Returns
std::unique_ptr<CSGLattice> unique pointer to cloned Cartesian lattice

Implements CSG::CSGLattice.

Definition at line 64 of file CSGCartesianLattice.h.

65 {
66 return std::make_unique<CSGCartesianLattice>(*this);
67 }

◆ compareAttributes()

bool CSG::CSGCartesianLattice::compareAttributes ( const CSGLattice other) const
overrideprotectedvirtual

compare the attributes returned in getAttributes of this lattice to another lattice

Implements CSG::CSGLattice.

Definition at line 93 of file CSGCartesianLattice.C.

94{
95 if (other.getType() != this->getType())
96 return false;
97
98 auto this_dims = this->getAttributes();
99 auto other_dims = other.getAttributes();
100 if (std::get<unsigned int>(this_dims["nrow"]) != std::get<unsigned int>(other_dims["nrow"]))
101 return false;
102 if (std::get<unsigned int>(this_dims["ncol"]) != std::get<unsigned int>(other_dims["ncol"]))
103 return false;
104 if (std::get<Real>(this_dims["pitch"]) != std::get<Real>(other_dims["pitch"]))
105 return false;
106 return true;
107}
virtual std::unordered_map< std::string, AttributeVariant > getAttributes() const override
Get attributes that define the lattice (excluding the universe map).

◆ FRIEND_TEST() [1/10]

CSG::CSGLattice::FRIEND_TEST ( CSGBaseTest  ,
testAddLattice   
)
protectedinherited

◆ FRIEND_TEST() [2/10]

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

◆ FRIEND_TEST() [3/10]

CSG::CSGCartesianLattice::FRIEND_TEST ( CSGLatticeTest  ,
testCartLatticeEquality   
)
protected

◆ FRIEND_TEST() [4/10]

CSG::CSGCartesianLattice::FRIEND_TEST ( CSGLatticeTest  ,
testCartSetUniverseAtIndex   
)
protected

◆ FRIEND_TEST() [5/10]

CSG::CSGCartesianLattice::FRIEND_TEST ( CSGLatticeTest  ,
testCartSetUniverses   
)
protected

Friends for unit testing.

◆ FRIEND_TEST() [6/10]

CSG::CSGCartesianLattice::FRIEND_TEST ( CSGLatticeTest  ,
testEmptyToFilled   
)
protected

◆ FRIEND_TEST() [7/10]

CSG::CSGLattice::FRIEND_TEST ( CSGLatticeTest  ,
testSetName   
)
protectedinherited

Friends for unit testing.

◆ FRIEND_TEST() [8/10]

CSG::CSGLattice::FRIEND_TEST ( CSGLatticeTest  ,
testUpdateOuter   
)
protectedinherited

◆ FRIEND_TEST() [9/10]

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

◆ FRIEND_TEST() [10/10]

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

Friends for unit testing.

◆ getAttributes()

std::unordered_map< std::string, AttributeVariant > CSG::CSGCartesianLattice::getAttributes ( ) const
overridevirtual

Get attributes that define the lattice (excluding the universe map).

  • nrow: number of rows (int)
  • ncol: number of columns (int)
  • pitch: pitch of the lattice element (Real)
Returns
map of string dimension name to value of that dimension

Implements CSG::CSGLattice.

Definition at line 45 of file CSGCartesianLattice.C.

46{
47 return {{"nrow", static_cast<unsigned int>(_nrow)},
48 {"ncol", static_cast<unsigned int>(_ncol)},
49 {"pitch", _pitch}};
50}

Referenced by compareAttributes().

◆ getName()

const std::string & CSG::CSGLattice::getName ( ) const
inlineinherited

◆ getNCols()

unsigned int CSG::CSGCartesianLattice::getNCols ( ) const
inline

get number of columns

Returns
number of columns

Definition at line 110 of file CSGCartesianLattice.h.

110{ return _ncol; }

◆ getNRows()

unsigned int CSG::CSGCartesianLattice::getNRows ( ) const
inline

get the number of rows

Returns
number of rows

Definition at line 103 of file CSGCartesianLattice.h.

103{ return _nrow; }

◆ getOuterMaterial()

const std::string & CSG::CSGLattice::getOuterMaterial ( ) const
inherited

Get the outer material name if outer fype is CSG_MATERIAL.

Returns
name of the CSG material fill

Definition at line 118 of file CSGLattice.C.

119{
120 if (getOuterType() != "CSG_MATERIAL")
121 mooseError("Lattice '" + getName() + "' has " + getOuterType() + " outer, not CSG_MATERIAL.");
122 else
123 return _outer_material;
124}
const std::string getOuterType() const
Get the type of outer that fills the space around the lattice elements.
Definition CSGLattice.h:77
std::string _outer_material
name of the outer material
Definition CSGLattice.h:229

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

◆ getOuterType()

const std::string CSG::CSGLattice::getOuterType ( ) const
inlineinherited

Get the type of outer that fills the space around the lattice elements.

Returns
string of outer type: CSG_MATERIAL, UNIVERSE, or VOID

Definition at line 77 of file CSGLattice.h.

77{ return _outer_type; }
std::string _outer_type
An enum for type of outer fill for lattice.
Definition CSGLattice.h:226

Referenced by CSG::CSGBase::addLatticeToList(), CSG::CSGLattice::getOuterMaterial(), CSG::CSGLattice::getOuterUniverse(), CSG::CSGLattice::operator==(), and CSG::CSGBase::replaceUniverseRefs().

◆ getOuterUniverse()

const CSGUniverse & CSG::CSGLattice::getOuterUniverse ( ) const
inherited

Get the outer universe if outer type is UNIVERSE.

Returns
Reference to CSGUniverse

Definition at line 109 of file CSGLattice.C.

110{
111 if (getOuterType() != "UNIVERSE")
112 mooseError("Lattice '" + getName() + "' has " + getOuterType() + " outer, not UNIVERSE.");
113 else
114 return *_outer_universe;
115}
const CSGUniverse * _outer_universe
outer object if fill is CSGUniverse
Definition CSGLattice.h:232

Referenced by CSG::CSGBase::addLatticeToList(), CSG::CSGLattice::operator==(), and CSG::CSGBase::replaceUniverseRefs().

◆ getPitch()

Real CSG::CSGCartesianLattice::getPitch ( ) const
inline

get lattice pitch

Returns
pitch

Definition at line 117 of file CSGCartesianLattice.h.

117{ return _pitch; }

◆ getTransformations()

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

◆ getTransformationsAsStrings()

std::vector< std::pair< std::string, std::tuple< Real, Real, Real > > > CSG::CSGTransformationHelper::getTransformationsAsStrings ( ) const
inherited

Get the transformations of this object with string representations for types.

Returns
Vector of transformation pairs with string representations for types

Definition at line 65 of file CSGTransformationHelper.C.

66{
67 std::vector<std::pair<std::string, std::tuple<Real, Real, Real>>> result;
68 for (const auto & transform_pair : _transformations)
69 result.emplace_back(getTransformationTypeString(transform_pair.first), transform_pair.second);
70 return result;
71}

Referenced by CSG::CSGCellEngUnit::getTransformationsAsStrings(), CSG::CSGSurfaceEngUnit::getTransformationsAsStrings(), and CSG::CSGUniverseEngUnit::getTransformationsAsStrings().

◆ 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.

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:55
static const MooseEnum transformation_type_enum
MooseEnum for transformation types, matching the TransformationType enum values.

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

◆ getType()

const std::string CSG::CSGLattice::getType ( ) const
inlineinherited

Get the lattice type.

Returns
std::string type of lattice

Definition at line 67 of file CSGLattice.h.

68 {
69 return MooseUtils::prettyCppType(libMesh::demangle(typeid(*this).name()));
70 }
std::string prettyCppType(const std::string &cpp_type)
std::string demangle(const char *name)

Referenced by compareAttributes(), CSG::CSGHexagonalLattice::compareAttributes(), CSG::CSGLattice::operator==(), setUniverses(), and CSG::CSGHexagonalLattice::setUniverses().

◆ getUniqueUniverses()

const std::vector< std::reference_wrapper< const CSGUniverse > > CSG::CSGLattice::getUniqueUniverses ( ) const
inherited

Get the list of unique universe objects in the lattice.

Returns
list of references to unique CSGUniverse objects

Definition at line 91 of file CSGLattice.C.

92{
93 std::vector<std::reference_wrapper<const CSGUniverse>> unique_univs;
94 auto all_univs = getUniverses();
95
96 for (const auto & ulist : all_univs)
97 for (const auto & u : ulist)
98 {
99 auto it = std::find_if(unique_univs.begin(),
100 unique_univs.end(),
101 [&u](const auto & ref) { return &ref.get() == &u.get(); });
102 if (it == unique_univs.end())
103 unique_univs.push_back(u);
104 }
105 return unique_univs;
106}
for(PetscInt i=0;i< nvars;++i)
std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > getUniverses() const
Get the arrangement of CSGUniverses in the lattice.
Definition CSGLattice.h:98

◆ getUniverseAtIndex()

const CSGUniverse & CSG::CSGLattice::getUniverseAtIndex ( const std::pair< int, int index)
inherited

Get the universe located at the given index.

Parameters
indexpair of ints that specify the location in lattice
Returns
universe at the specified location

Definition at line 64 of file CSGLattice.C.

65{
66 if (!isValidIndex(index))
67 mooseError("Index (" + std::to_string(index.first) + ", " + std::to_string(index.second) +
68 ") is not a valid index for lattice " + getName());
69 else
70 return _universe_map[index.first][index.second];
71}
virtual bool isValidIndex(const std::pair< int, int > index) const =0
Checks if the given index location is a valid index for the lattice.
std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > _universe_map
Universes in the arrangement of how they appear in the lattice; dimensions depends on lattice type.
Definition CSGLattice.h:223

◆ getUniverseIndices()

const std::vector< std::pair< unsigned int, unsigned int > > CSG::CSGLattice::getUniverseIndices ( const std::string &  univ_name) const
inherited

get all locations in lattice where universe of the specified name exists

Parameters
univ_namename of universe
Returns
vector of locations (pairs of ints)

Definition at line 74 of file CSGLattice.C.

75{
76 if (!hasUniverse(univ_name))
77 mooseError("Universe " + univ_name + " does not exist in lattice " + getName());
78
79 std::vector<std::pair<unsigned int, unsigned int>> indices;
80 for (auto i : index_range(_universe_map))
81 for (auto j : index_range(_universe_map[i]))
82 {
83 const CSGUniverse & univ = _universe_map[i][j];
84 if (univ.getName() == univ_name)
85 indices.push_back(std::make_pair(i, j));
86 }
87 return indices;
88}
bool hasUniverse(const std::string &name) const
whether or not the universe of the specified name exists in the lattice
Definition CSGLattice.C:40
auto index_range(const T &sizable)

◆ getUniverseNameMap()

const std::vector< std::vector< std::string > > CSG::CSGLattice::getUniverseNameMap ( ) const
inherited

Get the arrangement of CSGUniverses in the lattice as their names.

Returns
list of list of universe names

Definition at line 50 of file CSGLattice.C.

51{
52 std::vector<std::vector<std::string>> name_map;
53 for (auto & univ_list : _universe_map)
54 {
55 std::vector<std::string> name_list;
56 for (const CSGUniverse & univ : univ_list)
57 name_list.push_back(univ.getName());
58 name_map.push_back(name_list);
59 }
60 return name_map;
61}

◆ getUniverses()

std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > CSG::CSGLattice::getUniverses ( ) const
inlineinherited

Get the arrangement of CSGUniverses in the lattice.

Returns
list of list of universes in their lattice arrangement

Definition at line 98 of file CSGLattice.h.

99 {
100 return _universe_map;
101 }

Referenced by CSG::CSGBase::addLatticeToList(), CSG::CSGBase::createCell(), CSG::CSGLattice::getUniqueUniverses(), CSG::CSGLattice::operator==(), and CSG::CSGBase::replaceUniverseRefs().

◆ hasUniverse()

bool CSG::CSGLattice::hasUniverse ( const std::string &  name) const
inherited

whether or not the universe of the specified name exists in the lattice

Parameters
nameof universe to search for
Returns
true if universe of that name exists in lattice

Definition at line 40 of file CSGLattice.C.

41{
42 for (auto list_univ : _universe_map)
43 for (const CSGUniverse & univ : list_univ)
44 if (univ.getName() == name)
45 return true;
46 return false; // no universe with matching name was found
47}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
std::string name(const ElemQuality q)

Referenced by CSG::CSGLattice::getUniverseIndices().

◆ isValidIndex()

bool CSG::CSGCartesianLattice::isValidIndex ( const std::pair< int, int index) const
overridevirtual

Checks if the given index location (row, column) is a valid index for the lattice.

Allowable indices are: 0 <= row < _nrow and 0 <= column < _ncol.

Parameters
indexlocation in (row, column) form
Returns
true if index is valid for the lattice

Implements CSG::CSGLattice.

Definition at line 85 of file CSGCartesianLattice.C.

86{
87 auto row = index.first; // must be (0 <= row < _nrow); rows
88 auto col = index.second; // must be (0 <= col < _ncol); cols
89 return ((0 <= row && row < (int)_nrow) && (0 <= col && col < (int)_ncol));
90}

◆ 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.

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}

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

◆ isValidUniverseMap()

bool CSG::CSGCartesianLattice::isValidUniverseMap ( std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > >  universes) const
overridevirtual

check that any provided list of list of CSGUniverses are the correct dimensions.

Must have number of lists within universes equal to _nrow. And each sublist must be size _ncol.

Parameters
universeslist of list of universes to be used to define the lattice structure
Returns
true if universe dimensions are valid

Implements CSG::CSGLattice.

Definition at line 53 of file CSGCartesianLattice.C.

55{
56 // need at least one row
57 if (universes.size() < 1)
58 return false;
59
60 // check that each row is same size
61 auto row_size = universes[0].size();
62 for (auto univ_list : universes)
63 {
64 if (univ_list.size() != row_size)
65 return false;
66 }
67 return true;
68}

Referenced by setUniverses().

◆ operator!=()

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

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

Definition at line 187 of file CSGLattice.C.

188{
189 return !(*this == other);
190}

◆ operator==()

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

Operator overload for checking if two CSGLattice objects are equal.

Definition at line 151 of file CSGLattice.C.

152{
153 if (this->getName() != other.getName())
154 return false;
155 if (this->getType() != other.getType())
156 return false;
157 if (this->getTransformations() != other.getTransformations())
158 return false;
159 if (this->getOuterType() != other.getOuterType())
160 return false;
161 if ((this->getOuterType() == "CSG_MATERIAL") &&
162 (this->getOuterMaterial() != other.getOuterMaterial()))
163 return false;
164 if ((this->getOuterType() == "UNIVERSE") &&
165 (this->getOuterUniverse() != other.getOuterUniverse()))
166 return false;
167 if (!this->compareAttributes(other))
168 return false;
169
170 const auto & this_univs = this->getUniverses();
171 const auto & other_univs = other.getUniverses();
172 if (this_univs.size() != other_univs.size())
173 return false;
174 for (unsigned int i = 0; i < this_univs.size(); ++i)
175 {
176 if (this_univs[i].size() != other_univs[i].size())
177 return false;
178 for (unsigned int j = 0; j < this_univs[i].size(); j++)
179 if (this_univs[i][j].get() != other_univs[i][j].get())
180 return false;
181 }
182
183 return true;
184}
const std::string & getOuterMaterial() const
Get the outer material name if outer fype is CSG_MATERIAL.
Definition CSGLattice.C:118
const CSGUniverse & getOuterUniverse() const
Get the outer universe if outer type is UNIVERSE.
Definition CSGLattice.C:109
virtual bool compareAttributes(const CSGLattice &other) const =0
helper function to compare the attributes of the lattice type
const std::string getType() const
Get the lattice type.
Definition CSGLattice.h:67
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const
Get the list of transformations.
const Elem & get(const ElemType type_in)

◆ resetOuter()

void CSG::CSGLattice::resetOuter ( )
inherited

reset the outer fill around the lattice elements to be VOID

Definition at line 143 of file CSGLattice.C.

144{
145 _outer_type = "VOID";
146 _outer_material = "";
147 _outer_universe = nullptr;
148}

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

◆ setName()

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

Definition at line 184 of file CSGLattice.h.

184{ _name = name; }

◆ setPitch()

void CSG::CSGCartesianLattice::setPitch ( Real  pitch)

set the pitch of the lattice

Parameters
pitchnew pitch value

Definition at line 37 of file CSGCartesianLattice.C.

38{
39 if (pitch < 0)
40 mooseError("Lattice " + getName() + " must have pitch greater than 0.");
41 _pitch = pitch;
42}

◆ setUniverseAtIndex()

void CSG::CSGLattice::setUniverseAtIndex ( const CSGUniverse universe,
const std::pair< int, int index 
)
protectedinherited

replace the element at specified index in the lattice with the provided CSGUniverse.

This will check that the _universe_map has been initialized and that the index is valid.

Parameters
universeuniverse to add to the lattice at the location index
indexlocation in lattice replace with provided universe

Definition at line 28 of file CSGLattice.C.

29{
30 std::string base_msg = "Cannot set universe at location (" + std::to_string(index.first) + ", " +
31 std::to_string(index.second) + ") for lattice " + getName() + ". ";
32 if (_universe_map.size() == 0)
33 mooseError(base_msg + "Universe map has not been initialized.");
34 if (!isValidIndex(index))
35 mooseError(base_msg + "Not a valid location.");
36 _universe_map[index.first][index.second] = universe;
37}

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

◆ setUniverses()

void CSG::CSGCartesianLattice::setUniverses ( std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > >  universes)
overrideprotectedvirtual

set the universes that define the lattice layout

Parameters
universeslist of list of universes to set as the lattice map

Implements CSG::CSGLattice.

Definition at line 71 of file CSGCartesianLattice.C.

73{
74 // check for valid map arrangment
75 if (!isValidUniverseMap(universes))
76 mooseError("Cannot set lattice " + getName() +
77 " with universes. Does not have valid dimensions for lattice type " + getType());
78 // set attributes based on universe map
79 _nrow = universes.size();
80 _ncol = universes[0].size();
81 _universe_map = universes;
82}
virtual bool isValidUniverseMap(std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > universes) const override
check that any provided list of list of CSGUniverses are the correct dimensions.

Referenced by CSGCartesianLattice().

◆ updateOuter() [1/2]

void CSG::CSGLattice::updateOuter ( const CSGUniverse outer_universe)
protectedinherited

Update the outer of the lattice to be the provided universe.

This will change outer type to UNIVERSE even if it was a different type previously.

Parameters
outer_universepointer to outer universe that will fill space around lattice elements

Definition at line 127 of file CSGLattice.C.

128{
129 _outer_type = "UNIVERSE";
130 _outer_universe = &outer_universe;
131 _outer_material = "";
132}

◆ updateOuter() [2/2]

void CSG::CSGLattice::updateOuter ( const std::string &  outer_name)
protectedinherited

Update the outer of the lattice to be the provided material name.

This will change outer type to CSG_MATERIAL even if it was a different type previously.

Parameters
outer_namename of CSG material that will fill space around lattice elements

Definition at line 135 of file CSGLattice.C.

136{
137 _outer_type = "CSG_MATERIAL";
138 _outer_material = outer_name;
139 _outer_universe = nullptr;
140}

Referenced by CSG::CSGLattice::CSGLattice(), CSG::CSGBase::setLatticeOuter(), and CSG::CSGBase::setLatticeOuter().

Friends And Related Symbol Documentation

◆ CSGBase

friend class CSGBase
friend

Definition at line 147 of file CSGCartesianLattice.h.

Member Data Documentation

◆ _name

std::string CSG::CSGLattice::_name
protectedinherited

Name of lattice.

Definition at line 220 of file CSGLattice.h.

Referenced by CSG::CSGLattice::getName(), and CSG::CSGLattice::setName().

◆ _ncol

unsigned int CSG::CSGCartesianLattice::_ncol
protected

number of elements in the second direction (columns)

Definition at line 145 of file CSGCartesianLattice.h.

Referenced by getAttributes(), getNCols(), isValidIndex(), and setUniverses().

◆ _nrow

unsigned int CSG::CSGCartesianLattice::_nrow
protected

number of elements in the first dimension (rows)

Definition at line 142 of file CSGCartesianLattice.h.

Referenced by getAttributes(), getNRows(), isValidIndex(), and setUniverses().

◆ _outer_material

std::string CSG::CSGLattice::_outer_material
mutableprotectedinherited

◆ _outer_type

std::string CSG::CSGLattice::_outer_type
mutableprotectedinherited

An enum for type of outer fill for lattice.

Definition at line 226 of file CSGLattice.h.

Referenced by CSG::CSGLattice::getOuterType(), CSG::CSGLattice::resetOuter(), CSG::CSGLattice::updateOuter(), and CSG::CSGLattice::updateOuter().

◆ _outer_universe

const CSGUniverse* CSG::CSGLattice::_outer_universe
protectedinherited

◆ _pitch

Real CSG::CSGCartesianLattice::_pitch
protected

◆ _transformations

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

◆ _universe_map

std::vector<std::vector<std::reference_wrapper<const CSGUniverse> > > CSG::CSGLattice::_universe_map
protectedinherited

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