17 : _name(name), _outer_type(
"VOID"), _outer_universe(nullptr)
21 if (outer.has_value())
23 std::visit([
this](
auto && outer_arg) {
updateOuter(outer_arg); }, outer.value());
30 std::string base_msg =
"Cannot set universe at location (" + std::to_string(index.first) +
", " +
31 std::to_string(index.second) +
") for lattice " +
getName() +
". ";
33 mooseError(base_msg +
"Universe map has not been initialized.");
35 mooseError(base_msg +
"Not a valid location.");
44 if (univ.getName() == name)
49const std::vector<std::vector<std::string>>
52 std::vector<std::vector<std::string>> name_map;
55 std::vector<std::string> name_list;
57 name_list.push_back(univ.getName());
58 name_map.push_back(name_list);
67 mooseError(
"Index (" + std::to_string(index.first) +
", " + std::to_string(index.second) +
68 ") is not a valid index for lattice " +
getName());
73const std::vector<std::pair<unsigned int, unsigned int>>
79 std::vector<std::pair<unsigned int, unsigned int>> indices;
84 if (univ.
getName() == univ_name)
85 indices.push_back(std::make_pair(i, j));
90const std::vector<std::reference_wrapper<const CSGUniverse>>
93 std::vector<std::reference_wrapper<const CSGUniverse>> unique_univs;
96 for (
const auto & ulist : all_univs)
97 for (
const auto & u : ulist)
99 auto it = std::find_if(unique_univs.begin(),
101 [&u](
const auto & ref) { return &ref.get() == &u.get(); });
102 if (it == unique_univs.end())
103 unique_univs.push_back(u);
172 if (this_univs.size() != other_univs.size())
174 for (
unsigned int i = 0; i < this_univs.size(); ++i)
176 if (this_univs[i].size() != other_univs[i].size())
178 for (
unsigned int j = 0; j < this_univs[i].size(); j++)
179 if (this_univs[i][j].get() != other_univs[i][j].get())
189 return !(*
this == other);
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
CSGLattice is the abstract class for defining lattices.
std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > getUniverses() const
Get the arrangement of CSGUniverses in the lattice.
void updateOuter(const std::string &outer_name)
Update the outer of the lattice to be the provided material name.
const std::string & getName() const
Get the name of lattice.
const std::vector< std::vector< std::string > > getUniverseNameMap() const
Get the arrangement of CSGUniverses in the lattice as their names.
const std::string getOuterType() const
Get the type of outer that fills the space around the lattice elements.
const std::string & getOuterMaterial() const
Get the outer material name if outer fype is CSG_MATERIAL.
std::string _outer_material
name of the outer material
bool operator!=(const CSGLattice &other) const
Operator overload for checking if two CSGLattice objects are not equal.
bool operator==(const CSGLattice &other) const
Operator overload for checking if two CSGLattice objects are equal.
const CSGUniverse * _outer_universe
outer object if fill is CSGUniverse
const std::vector< std::reference_wrapper< const CSGUniverse > > getUniqueUniverses() const
Get the list of unique universe objects in the lattice.
const CSGUniverse & getOuterUniverse() const
Get the outer universe if outer type is UNIVERSE.
virtual bool compareAttributes(const CSGLattice &other) const =0
helper function to compare the attributes of the lattice type
void resetOuter()
reset the outer fill around the lattice elements to be VOID
CSGLattice(const std::string &name, const std::optional< OuterVariant > &outer=std::nullopt)
Construct a new CSGLattice of specific type.
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
bool hasUniverse(const std::string &name) const
whether or not the universe of the specified name exists in the lattice
const std::string getType() const
Get the lattice type.
const CSGUniverse & getUniverseAtIndex(const std::pair< int, int > index)
Get the universe located at the given index.
void setUniverseAtIndex(const CSGUniverse &universe, const std::pair< int, int > index)
replace the element at specified index in the lattice with the provided CSGUniverse.
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.
std::string _outer_type
An enum for type of outer fill for lattice.
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe,...
const std::string & getName() const
Get the name of the universe.
void checkValidCSGName(const std::string &name)
Check name of CSG component for disallowed characters and symbols.