https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CSGHexagonalLattice.h
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#pragma once
11
12#include "CSGLattice.h"
13
14#ifdef MOOSE_UNIT_TEST
15#include "gtest/gtest.h"
16#endif
17
18namespace CSG
19{
20
26{
27public:
38 CSGHexagonalLattice(const std::string & name,
39 Real pitch,
40 std::vector<std::vector<std::reference_wrapper<const CSGUniverse>>> universes,
41 const std::optional<OuterVariant> & outer = std::nullopt);
42
52 CSGHexagonalLattice(const std::string & name,
53 Real pitch,
54 const std::optional<OuterVariant> & outer = std::nullopt);
55
59 virtual ~CSGHexagonalLattice() = default;
60
66 std::unique_ptr<CSGLattice> clone() const override
67 {
68 return std::make_unique<CSGHexagonalLattice>(*this);
69 }
70
78 virtual std::unordered_map<std::string, AttributeVariant> getAttributes() const override;
79
86 virtual bool isValidIndex(const std::pair<int, int> index) const override;
87
96 virtual bool isValidUniverseMap(
97 std::vector<std::vector<std::reference_wrapper<const CSGUniverse>>> universes) const override;
98
104 unsigned int getNRows() const { return _nrow; }
105
111 unsigned int getNRings() const { return _nring; }
112
138 std::pair<int, int> getRowIndexFromRingIndex(const std::pair<int, int> & row_col_index) const;
139
165 std::pair<int, int> getRingIndexFromRowIndex(const std::pair<int, int> & row_col_index) const;
166
172 Real getPitch() const { return _pitch; }
173
179 void setPitch(Real pitch);
180
181protected:
183 virtual bool compareAttributes(const CSGLattice & other) const override;
184
189 void buildIndexMap();
190
196 virtual void setUniverses(
197 std::vector<std::vector<std::reference_wrapper<const CSGUniverse>>> universes) override;
198
200 Real _pitch;
201
203 unsigned int _nrow;
204
206 unsigned int _nring;
207
209 std::map<std::pair<unsigned int, unsigned int>, std::pair<unsigned int, unsigned int>>
211
212#ifdef MOOSE_UNIT_TEST
215 FRIEND_TEST(CSGLatticeTest, testHexSetUniverses);
216 FRIEND_TEST(CSGLatticeTest, testConvertRowsRings);
218#endif
219};
220
223unsigned int nRowToRing(int nrow);
224
226unsigned int nRingToRow(int nring);
227
228} // namespace CSG
CSGHexagonalLattice is the class for constructing hexagonal lattices of CSGUniverses arranged in conc...
unsigned int _nring
number of rings in the hexagonal lattice, should be consistent with the number of rows
Real _pitch
lattice pitch (flat-to-flat distance between adjacent hex elements)
unsigned int getNRings() const
get number of rings in the lattice
void buildIndexMap()
build a mapping of row-column indices to ring-position indices for quick conversion and look-up.
unsigned int getNRows() const
get number of rows in the lattices
virtual bool compareAttributes(const CSGLattice &other) const override
compare the attributes returned in getAttributes of this lattice to another lattice
std::map< std::pair< unsigned int, unsigned int >, std::pair< unsigned int, unsigned int > > _row_to_ring_map
map of row-column indices to ring-position indices for quick conversion and look-up
virtual bool isValidIndex(const std::pair< int, int > index) const override
check if provided index in row-column form is valid for the given hexagonal lattice
unsigned int _nrow
number of rows in the hexagonal lattice (must be odd), should be consistent with the number of rings
Real getPitch() const
get the pitch of the lattice
virtual ~CSGHexagonalLattice()=default
Destructor.
std::pair< int, int > getRowIndexFromRingIndex(const std::pair< int, int > &row_col_index) const
Given an index in ring-position form, get the corresponding row-column index.
virtual std::unordered_map< std::string, AttributeVariant > getAttributes() const override
Get attributes that define the lattice (excluding the universe map).
std::pair< int, int > getRingIndexFromRowIndex(const std::pair< int, int > &row_col_index) const
Given an index in row-column form, get the corresponding ring-position index.
virtual bool isValidUniverseMap(std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > universes) const override
check if the arrangement of the provided universes is valid for the hexagonal lattice given the numbe...
FRIEND_TEST(CSGLatticeTest, testHexSetUniverses)
Friends for unit testing.
void setPitch(Real pitch)
set the pitch of the lattice
FRIEND_TEST(CSGLatticeTest, testConvertRowsRings)
std::unique_ptr< CSGLattice > clone() const override
clone this hexagonal lattice
virtual void setUniverses(std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > universes) override
set the universes that define the lattice layout
CSGLattice is the abstract class for defining lattices.
Definition CSGLattice.h:35
unsigned int nRowToRing(int nrow)
methods to help convert between number of rows and rings get the total number of rings from the numbe...
unsigned int nRingToRow(int nring)
get the total number of rows from the number of rings