17 const std::string & lattice_type,
18 const std::optional<OuterVariant> & outer)
19 : _name(
name), _lattice_type(lattice_type), _outer_type(
"VOID"), _outer_universe(nullptr)
23 if (outer.has_value())
25 std::visit([
this](
auto && outer_arg) {
updateOuter(outer_arg); }, outer.value());
32 std::string base_msg =
"Cannot set universe at location (" + std::to_string(index.first) +
", " +
33 std::to_string(index.second) +
") for lattice " +
getName() +
". ";
35 mooseError(base_msg +
"Universe map has not been initialized.");
37 mooseError(base_msg +
"Not a valid location.");
46 if (univ.getName() ==
name)
51 const std::vector<std::vector<std::string>>
54 std::vector<std::vector<std::string>> name_map;
57 std::vector<std::string> name_list;
59 name_list.push_back(univ.getName());
60 name_map.push_back(name_list);
69 mooseError(
"Index (" + std::to_string(index.first) +
", " + std::to_string(index.second) +
70 ") is not a valid index for lattice " +
getName());
75 const std::vector<std::pair<unsigned int, unsigned int>>
81 std::vector<std::pair<unsigned int, unsigned int>> indices;
86 if (univ.
getName() == univ_name)
87 indices.push_back(std::make_pair(i, j));
92 const std::vector<std::reference_wrapper<const CSGUniverse>>
95 std::vector<std::reference_wrapper<const CSGUniverse>> unique_univs;
98 for (
const auto & ulist : all_univs)
99 for (
const auto & u : ulist)
101 auto it = std::find_if(unique_univs.begin(),
103 [&u](
const auto & ref) {
return &ref.get() == &u.get(); });
104 if (it == unique_univs.end())
105 unique_univs.push_back(u);
174 if (this_univs.size() != other_univs.size())
176 for (
unsigned int i = 0; i < this_univs.size(); ++i)
178 if (this_univs[i].size() != other_univs[i].size())
180 for (
unsigned int j = 0; j < this_univs[i].size(); j++)
181 if (this_univs[i][j].
get() != other_univs[i][j].get())
191 return !(*
this == other);
std::string name(const ElemQuality q)
std::string _outer_material
name of the outer material
std::string _outer_type
An enum for type of outer fill for lattice.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
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 operator!=(const CSGLattice &other) const
Operator overload for checking if two CSGLattice objects are not equal.
CSGLattice(const std::string &name, const std::string &lattice_type, const std::optional< OuterVariant > &outer=std::nullopt)
Construct a new CSGLattice of specific type.
virtual bool isValidIndex(const std::pair< int, int > index) const =0
Checks if the given index location is a valid index for the lattice.
const CSGUniverse & getOuterUniverse() const
Get the outer universe if outer type is UNIVERSE.
void setUniverseAtIndex(const CSGUniverse &universe, const std::pair< int, int > index)
replace the element at specified index in the lattice with the provided CSGUniverse.
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe...
const std::string & getType() const
Get the lattice type.
const std::string & getName() const
Get the name of lattice.
const std::vector< std::reference_wrapper< const CSGUniverse > > getUniqueUniverses() const
Get the list of unique universe objects in the lattice.
CSGLattice is the abstract class for defining lattices.
const std::string & getName() const
Get the name of the universe.
void resetOuter()
reset the outer fill around the lattice elements to be VOID
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...
const std::string & getOuterMaterial() const
Get the outer material name if outer fype is CSG_MATERIAL.
const CSGUniverse & getUniverseAtIndex(const std::pair< int, int > index)
Get the universe located at the given index.
void updateOuter(const std::string &outer_name)
Update the outer of the lattice to be the provided material name.
const std::vector< std::vector< std::string > > getUniverseNameMap() const
Get the arrangement of CSGUniverses in the lattice as their names.
void checkValidCSGName(const std::string &name)
Check name of CSG component for disallowed characters and symbols.
const CSGUniverse * _outer_universe
outer object if fill is CSGUniverse
virtual bool compareAttributes(const CSGLattice &other) const =0
helper function to compare the attributes of the lattice type
std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > getUniverses() const
Get the arrangement of CSGUniverses in the lattice.
bool hasUniverse(const std::string &name) const
whether or not the universe of the specified name exists in the lattice
const std::string getOuterType() const
Get the type of outer that fills the space around the lattice elements.
auto index_range(const T &sizable)
bool operator==(const CSGLattice &other) const
Operator overload for checking if two CSGLattice objects are equal.