15#include "libmesh/elem.h"
24 "Divide the mesh along a hexagonal grid. Numbering of pin divisions increases first "
25 "counterclockwise, then expanding outwards from the inner ring, then axially. "
26 "Inner-numbering is within a radial ring, outer-numbering is axial divisions");
28 params.
addParam<Point>(
"center",
"Center of the hexagonal grid");
29 params.
addParam<PositionsName>(
"center_positions",
"Centers of the hexagonal grids");
32 "lattice_flat_to_flat",
33 "lattice_flat_to_flat>0",
34 "Distance between two (inner) opposite sides of a lattice. Also known as bundle pitch or "
35 "inner flat-to-flat distance");
38 params.
addRequiredParam<Real>(
"z_min",
"Minimal axial extent of the lattice");
39 params.
addRequiredParam<Real>(
"z_max",
"Maximum axial extent of the lattice");
43 "assign_domain_outside_grid_to_border",
45 "Whether to map the domain outside the grid back to the border of the grid");
46 params.
addParam<Real>(
"rotation_around_axis",
48 "Rotation angle to apply to the underlying hexagonal lattice (in degrees)");
55 _center(isParamValid(
"center") ? getParam<Point>(
"center") : Point(0, 0, 0)),
57 isParamValid(
"center_positions")
58 ? &_fe_problem->getPositionsObject(getParam<PositionsName>(
"center_positions"))
60 _lattice_flat_to_flat(getParam<Real>(
"lattice_flat_to_flat")),
61 _pin_pitch(getParam<Real>(
"pin_pitch")),
63 _min_z(getParam<Real>(
"z_min")),
64 _max_z(getParam<Real>(
"z_max")),
65 _nr(getParam<unsigned
int>(
"nr")),
66 _nz(getParam<unsigned
int>(
"nz")),
67 _outside_grid_counts_as_border(getParam<bool>(
"assign_domain_outside_grid_to_border"))
72 paramError(
"center",
"A center must be provided, or a Positions object for the centers");
74 mooseError(
"lattice_flat_to_flat",
"Pin pitch should be smaller than bundle pitch");
76 paramError(
"nz",
"Subdivision number must be 1 if width is 0 in Z direction");
90 getParam<Real>(
"rotation_around_axis"));
106 "Hexagonal grids centered on the positions are too close to each other (min distance: ",
108 "), closer than the extent of each grid (",
110 "). Mesh division is ill-defined ");
123 unsigned int offset = 0;
136 const auto nearest_grid_center =
140 pc = pt - nearest_grid_center;
166 for (
const auto jz : make_range(
_nz + 1))
169 if (jz > 0 && jz <
_nz && MooseUtils::absoluteFuzzyEqual(border_z, pc(
_z_axis_index)))
171 "Querying the division index for a point of a boundary between two regions in Z: " +
173 ", in local hex grid frame: ",
177 iz = (jz > 0) ? jz - 1 : 0;
187 if (iz == not_found && MooseUtils::absoluteFuzzyEqual(
_max_z -
_min_z, 0))
189 mooseAssert(ir != not_found,
"We should have found a mesh division bin radially");
190 mooseAssert(iz != not_found,
"We should have found a mesh division bin in Z");
193 return offset + ir + iz * n_radial;
registerMooseObject("ReactorApp", HexagonalGridDivision)
const ExecFlagType EXEC_INITIAL
void ErrorVector unsigned int
const ExecFlagType & getCurrentExecuteOnFlag() const
Divides the mesh based on a hexagonal grid.
const MooseEnum _z_axis_index
Axial component for the Z axis.
const Point _center
Center of the lattice (single lattice)
HexagonalGridDivision(const InputParameters ¶meters)
std::unique_ptr< HexagonalLatticeUtils > _hex_latt
Hexagonal lattice utility object.
const unsigned int _nr
Number of rings in the radial direction.
const Real _pin_pitch
Pitch between fuel pins.
const unsigned int _nz
Number of divisions in the Z direction.
const Real _lattice_flat_to_flat
Distance from one side to the one facing it of the lattice.
virtual void initialize() override
const Positions * _center_positions
Centers of the lattices (lattices centered around positions)
static InputParameters validParams()
const Real _max_z
Maximal axial coordinate.
virtual unsigned int divisionIndex(const Point &pt) const override
const Real _min_z
Minimal axial coordinate.
const bool _outside_grid_counts_as_border
Whether to map outside the grid onto the corner.
static InputParameters validParams()
const FEProblemBase *const _fe_problem
void setNumDivisions(const unsigned int ndivs)
void paramError(const std::string ¶m, Args... args) const
void mooseError(Args &&... args) const
void mooseWarning(Args &&... args) const
bool isParamValid(const std::string &name) const
const Point & getPosition(unsigned int index, bool initial) const
unsigned int getNearestPositionIndex(const Point &target, bool initial) const
unsigned int getNumPositions(bool initial=false) const
Real getMinDistanceBetweenPositions() const
unsigned int INVALID_DIVISION_INDEX
std::string stringify(const T &t)