20 "Create positions along a hexagonal grid. Numbering of positions increases first " 21 "counterclockwise, then expanding outwards from the inner ring. " 22 "Inner-numbering is within a radial ring.");
26 "lattice_flat_to_flat",
27 "lattice_flat_to_flat>0",
28 "Distance between two (inner) opposite sides of a lattice. Also known as bundle pitch or " 29 "inner flat-to-flat distance");
36 "A double-indexed hexagonal-shaped array starting with the upper-left corner. '-1's are not " 37 "selected as positions.");
38 params.
addParam<std::vector<unsigned int>>(
39 "include_in_pattern", {},
"A vector of the numbers in the pattern to include");
40 params.
addParam<std::vector<std::vector<int>>>(
43 "A double-indexed hexagonal-shaped array with the index of other Positions objects starting " 44 "with the upper-left corner. These positions objects will be distributed within the " 45 "hexagonal grid. The indexing is given in 'positions_pattern_indexing'. Use '-1' to discard " 46 "a position in the lattice.");
47 params.
addParam<std::map<std::string, unsigned int>>(
48 "positions_pattern_indexing",
50 "A map from the name of positions objects to their index in the 'positions_pattern'");
53 params.
set<
bool>(
"auto_sort") =
false;
55 params.
set<
bool>(
"auto_broadcast") =
false;
62 _center(getParam<Point>(
"center")),
63 _lattice_flat_to_flat(getParam<
Real>(
"lattice_flat_to_flat")),
64 _pin_pitch(getParam<
Real>(
"pin_pitch")),
66 _nr(getParam<unsigned
int>(
"nr")),
67 _pattern(getParam<
std::vector<
std::vector<unsigned
int>>>(
"pattern")),
69 std::set<unsigned
int>(getParam<
std::vector<unsigned
int>>(
"include_in_pattern").begin(),
70 getParam<
std::vector<unsigned
int>>(
"include_in_pattern").end())),
71 _positions_pattern(getParam<
std::vector<
std::vector<
int>>>(
"positions_pattern")),
72 _positions_pattern_indexing(
73 getParam<
std::map<
std::string, unsigned
int>>(
"positions_pattern_indexing"))
80 "For one ring, the lattice flat to flat must be at least the pin pitch");
87 "Lattice flat to flat distance is less than the minimum (3 * nr - 1) * pin_pitch " 88 "/ sqrt(3) given nr rings with a pitch of pin_pitch");
96 "The 'pattern' parameter and the 'include_in_pattern' must be both specified or both not " 97 "specified by the user.");
102 if (std::find(row.begin(), row.end(), include) != row.end())
106 "Pattern item '" + std::to_string(include) +
107 "' to include is not present in the pattern");
114 "The 'positions_pattern' parameter and the 'positions_pattern_indexing' must be " 115 "both specified or both not specified by the user.");
120 if (std::find(row.begin(), row.end(), index) != row.end())
124 "Pattern item '" + pos_name +
"' with index '" + std::to_string(index) +
125 "' to include is not present in the pattern");
133 "'pattern'/'include_in_pattern' are not supported in combination with " 134 "'positions_pattern/positions_pattern_indexing'. Only one pattern is supported");
148 _hex_latt = std::make_unique<HexagonalLatticeUtils>(
154 std::vector<int> pattern_unrolled;
159 std::size_t pattern_size = 0;
161 pattern_size += row.size();
162 if (
_pattern.size() != cast_int<std::size_t>(2 *
_nr - 1))
165 ") should be equal to twice the number of hexagonal rings minus one");
169 ") does not match the number of pins with ",
180 unsigned int row_i, within_row_i;
181 _hex_latt->get2DInputPatternIndex(i, row_i, within_row_i);
182 pattern_unrolled[i++] =
_pattern[row_i][within_row_i];
190 unsigned int n_exclusions = 0;
192 for (
const auto patt : pattern_unrolled)
197 const auto n_positions = cast_int<std::size_t>(
_hex_latt->totalPins(
_nr) - n_exclusions);
202 unsigned int pos_i = 0;
203 for (
const auto patt_i :
index_range(pattern_unrolled))
214 unsigned pattern_size = 0;
216 pattern_size += row.size();
218 mooseError(
"Number of rows in 'positions_pattern' (",
220 ") should be equal to twice the number of hexagonal rings minus one");
224 " does not match the number of pins with ",
230 unsigned num_pos = 0;
237 std::map<unsigned int, PositionsName> index_to_pos;
239 index_to_pos[index] = pos_name;
242 std::vector<PositionsName> pattern_unrolled;
249 unsigned int row_i, within_row_i;
250 _hex_latt->get2DInputPatternIndex(i, row_i, within_row_i);
252 if (
auto it = index_to_pos.find(cast_int<unsigned int>(pos_index));
253 it != index_to_pos.end())
254 pattern_unrolled[i++] = it->second;
255 else if (pos_index != -1)
257 "Index '" + std::to_string(pos_index) +
258 "' in pattern is not found in 'positions_pattern_indexing'");
260 pattern_unrolled[i++] =
"-1";
264 for (
const auto patt_i :
index_range(pattern_unrolled))
266 const auto & pos_name = pattern_unrolled[patt_i];
267 if (pos_name !=
"-1")
static InputParameters validParams()
const Real _pin_pitch
Pitch between fuel pins.
std::map< std::string, unsigned int > _positions_pattern_indexing
Indexing of the positions objects in the pattern.
void initialize() override
const ExecFlagType & getCurrentExecuteOnFlag() const
const Real _lattice_flat_to_flat
Distance from one side to the one facing it of the lattice.
Creates positions (points) following an hexagonal grid.
bool hasUserObject(const std::string &name) const
const Positions & getPositionsObject(const std::string &name) const
std::vector< std::vector< int > > _positions_pattern
List of positions objects, the positions of which are translated in the parent hexagonal pattern...
std::set< unsigned int > _include_in_pattern
List of the pattern locations to include. Include all if empty.
HexagonalGridPositions(const InputParameters ¶meters)
void libmesh_ignore(const Args &...)
const MooseEnum _z_axis_index
Axial component for the Z axis.
std::unique_ptr< HexagonalLatticeUtils > _hex_latt
Hexagonal lattice utility object.
registerMooseObject("ReactorApp", HexagonalGridPositions)
std::vector< Point > & _positions
unsigned int getNumPositions(bool initial=false) const
void paramError(const std::string ¶m, Args... args) const
const std::vector< Point > & getPositions(bool initial) const
bool isParamSetByUser(const std::string &nm) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
FEProblemBase & _fe_problem
IntRange< T > make_range(T beg, T end)
virtual void finalize() override
void mooseError(Args &&... args) const
static InputParameters validParams()
std::vector< std::vector< unsigned int > > _pattern
2D pattern of the pins to select (if specified)
void ErrorVector unsigned int
auto index_range(const T &sizable)
bool absoluteFuzzyGreaterThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
const ExecFlagType EXEC_INITIAL
const unsigned int _nr
Number of rings in the radial direction.