https://mooseframework.inl.gov
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 
18 namespace CSG
19 {
20 
26 {
27 public:
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 
181 protected:
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 
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
213  FRIEND_TEST(CSGLatticeTest, testHexSetUniverses);
216  FRIEND_TEST(CSGLatticeTest, testConvertRowsRings);
218 #endif
219 };
220 
223 unsigned int nRowToRing(int nrow);
224 
226 unsigned int nRingToRow(int nring);
227 
228 } // namespace CSG
std::string name(const ElemQuality q)
void setPitch(Real pitch)
set the pitch of the lattice
unsigned int _nring
number of rings in the hexagonal lattice, should be consistent with the number of rows ...
virtual bool compareAttributes(const CSGLattice &other) const override
compare the attributes returned in getAttributes of this lattice to another lattice ...
Real getPitch() const
get the pitch of the lattice
std::unique_ptr< CSGLattice > clone() const override
clone this hexagonal lattice
CSGLattice is the abstract class for defining lattices.
Definition: CSGLattice.h:34
virtual ~CSGHexagonalLattice()=default
Destructor.
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 ...
unsigned int getNRings() const
get number of rings in the lattice
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.
CSGHexagonalLattice is the class for constructing hexagonal lattices of CSGUniverses arranged in conc...
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...
unsigned int nRowToRing(int nrow)
methods to help convert between number of rows and rings get the total number of rings from the numbe...
Real _pitch
lattice pitch (flat-to-flat distance between adjacent hex elements)
virtual std::unordered_map< std::string, AttributeVariant > getAttributes() const override
Get attributes that define the lattice (excluding the universe map).
void buildIndexMap()
build a mapping of row-column indices to ring-position indices for quick conversion and look-up...
unsigned int nRingToRow(int nring)
get the total number of rows from the number of rings
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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 getNRows() const
get number of rows in the lattices
unsigned int _nrow
number of rows in the hexagonal lattice (must be odd), should be consistent with the number of rings ...
virtual void setUniverses(std::vector< std::vector< std::reference_wrapper< const CSGUniverse >>> universes) override
set the universes that define the lattice layout
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.
CSGHexagonalLattice(const std::string &name, Real pitch, std::vector< std::vector< std::reference_wrapper< const CSGUniverse >>> universes, const std::optional< OuterVariant > &outer=std::nullopt)
Construct a new CSGHexagonalLattice from a map of universes.
FRIEND_TEST(CSGLatticeTest, testHexSetUniverses)
Friends for unit testing.