https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
HexagonalGridDivision Class Reference

Divides the mesh based on a hexagonal grid. More...

#include <HexagonalGridDivision.h>

Inheritance diagram for HexagonalGridDivision:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 HexagonalGridDivision (const InputParameters &parameters)
 
virtual void initialize () override
 
virtual unsigned int divisionIndex (const Point &pt) const override
 
virtual unsigned int divisionIndex (const Elem &elem) const override
 
unsigned int getNumDivisions () const
 
bool coversEntireMesh () const
 
virtual void meshChanged () override
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
virtual void initialSetup ()
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void subdomainSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnumgetExecuteOnEnum () const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

const ConsoleStream _console
 

Protected Member Functions

void setNumDivisions (const unsigned int ndivs)
 

Protected Attributes

const Point _center
 Center of the lattice (single lattice) More...
 
const Positions_center_positions
 Centers of the lattices (lattices centered around positions) More...
 
const Real _lattice_flat_to_flat
 Distance from one side to the one facing it of the lattice. More...
 
const Real _pin_pitch
 Pitch between fuel pins. More...
 
const MooseEnum _z_axis_index
 Axial component for the Z axis. More...
 
const Real _min_z
 Minimal axial coordinate. More...
 
const Real _max_z
 Maximal axial coordinate. More...
 
const unsigned int _nr
 Number of rings in the radial direction. More...
 
const unsigned int _nz
 Number of divisions in the Z direction. More...
 
const bool _outside_grid_counts_as_border
 Whether to map outside the grid onto the corner. More...
 
std::unique_ptr< HexagonalLatticeUtils_hex_latt
 Hexagonal lattice utility object. More...
 
const FEProblemBase *const _fe_problem
 
const MooseMesh_mesh
 
bool _mesh_fully_indexed
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
const ExecFlagEnum_execute_enum
 
const ExecFlagType_current_execute_flag
 
FEProblemBase_mci_feproblem
 
const Parallel::Communicator & _communicator
 

Detailed Description

Divides the mesh based on a hexagonal grid.

Definition at line 20 of file HexagonalGridDivision.h.

Constructor & Destructor Documentation

◆ HexagonalGridDivision()

HexagonalGridDivision::HexagonalGridDivision ( const InputParameters parameters)

Definition at line 50 of file HexagonalGridDivision.C.

52  _center(isParamValid("center") ? getParam<Point>("center") : Point(0, 0, 0)),
54  isParamValid("center_positions")
55  ? &_fe_problem->getPositionsObject(getParam<PositionsName>("center_positions"))
56  : nullptr),
57  _lattice_flat_to_flat(getParam<Real>("lattice_flat_to_flat")),
58  _pin_pitch(getParam<Real>("pin_pitch")),
59  _z_axis_index(MooseEnum("X Y Z", "Z")),
60  _min_z(getParam<Real>("z_min")),
61  _max_z(getParam<Real>("z_max")),
62  _nr(getParam<unsigned int>("nr")),
63  _nz(getParam<unsigned int>("nz")),
64  _outside_grid_counts_as_border(getParam<bool>("assign_domain_outside_grid_to_border"))
65 {
67 
68  if (!isParamValid("center") && !_center_positions)
69  paramError("center", "A center must be provided, or a Positions object for the centers");
71  mooseError("lattice_flat_to_flat", "Pin pitch should be smaller than bundle pitch");
73  paramError("nz", "Subdivision number must be 1 if width is 0 in Z direction");
74 }
MeshDivision(const InputParameters &parameters)
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
const Point _center
Center of the lattice (single lattice)
const unsigned int _nr
Number of rings in the radial direction.
const Positions * _center_positions
Centers of the lattices (lattices centered around positions)
const Real _pin_pitch
Pitch between fuel pins.
const unsigned int _nz
Number of divisions in the Z direction.
const Positions & getPositionsObject(const std::string &name) const
const MooseEnum _z_axis_index
Axial component for the Z axis.
bool isParamValid(const std::string &name) const
virtual void initialize() override
const Real _min_z
Minimal axial coordinate.
const bool _outside_grid_counts_as_border
Whether to map outside the grid onto the corner.
void paramError(const std::string &param, Args... args) const
const Real _max_z
Maximal axial coordinate.
const FEProblemBase *const _fe_problem
void mooseError(Args &&... args) const
const InputParameters & parameters() const
const Real _lattice_flat_to_flat
Distance from one side to the one facing it of the lattice.

Member Function Documentation

◆ divisionIndex() [1/2]

unsigned int HexagonalGridDivision::divisionIndex ( const Point &  pt) const
overridevirtual

Implements MeshDivision.

Definition at line 112 of file HexagonalGridDivision.C.

Referenced by divisionIndex().

113 {
114  unsigned int offset = 0;
115 
116  // Get point in the coordinates of the lattice. This can involve a projection due to
117  // the axis of the lattice, or simply a translation if there are lattices distributed
118  // using positions
119  Point pc;
120  if (_center_positions)
121  {
122  // If dividing using positions, find the closest position and
123  // look at the relative position of the point compared to that position
124  const bool initial = _fe_problem->getCurrentExecuteOnFlag() == EXEC_INITIAL;
125  const auto nearest_grid_center_index = _center_positions->getNearestPositionIndex(pt, initial);
126  offset = nearest_grid_center_index * _hex_latt->totalPins(_nr) * _nz;
127  const auto nearest_grid_center =
128  _center_positions->getPosition(nearest_grid_center_index, initial);
129 
130  // Project in local hexagonal grid
131  pc = pt - nearest_grid_center;
132  }
133  else
134  pc = pt - _center;
135 
136  // Get radial division index, using the channel as the pins are 0-radius
137  // The logic in get pin index requires getting the point in the plane of the pin centers
138  auto ir = _hex_latt->pinIndex(pc);
139  const auto n_pins = _hex_latt->nPins();
140 
142  {
143  if (ir == n_pins)
148  }
149 
150  // If too far from the grid to have a valid radial index, use the closest pin
151  if (ir == n_pins)
152  ir = _hex_latt->closestPinIndex(pc);
153 
154  // Find axial index
155  const auto not_found = MooseMeshDivision::INVALID_DIVISION_INDEX;
156  auto iz = not_found;
157  for (const auto jz : make_range(_nz + 1))
158  {
159  const auto border_z = _min_z + (_max_z - _min_z) * jz / _nz;
160  if (jz > 0 && jz < _nz && MooseUtils::absoluteFuzzyEqual(border_z, pc(_z_axis_index)))
161  mooseWarning(
162  "Querying the division index for a point of a boundary between two regions in Z: " +
163  Moose::stringify(pt),
164  ", in local hex grid frame: ",
165  Moose::stringify(pc));
166  if (border_z >= pc(_z_axis_index))
167  {
168  iz = (jz > 0) ? jz - 1 : 0;
169  break;
170  }
171  }
172 
173  // Look on the top of the grid
175  iz = _nz - 1;
176 
177  // Handle edge case on widths
178  if (iz == not_found && MooseUtils::absoluteFuzzyEqual(_max_z - _min_z, 0))
179  iz = 0;
180  mooseAssert(ir != not_found, "We should have found a mesh division bin radially");
181  mooseAssert(iz != not_found, "We should have found a mesh division bin in Z");
182 
183  const auto n_radial = _hex_latt->totalPins(_nr);
184  return offset + ir + iz * n_radial;
185 }
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
const Point _center
Center of the lattice (single lattice)
const ExecFlagType & getCurrentExecuteOnFlag() const
const unsigned int _nr
Number of rings in the radial direction.
const Positions * _center_positions
Centers of the lattices (lattices centered around positions)
const Point & getPosition(unsigned int index, bool initial) const
const unsigned int _nz
Number of divisions in the Z direction.
void mooseWarning(Args &&... args) const
const MooseEnum _z_axis_index
Axial component for the Z axis.
unsigned int getNearestPositionIndex(const Point &target, bool initial) const
const Real _min_z
Minimal axial coordinate.
const bool _outside_grid_counts_as_border
Whether to map outside the grid onto the corner.
bool absoluteFuzzyLessThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
const Real _max_z
Maximal axial coordinate.
std::string stringify(const T &t)
unsigned int INVALID_DIVISION_INDEX
std::unique_ptr< HexagonalLatticeUtils > _hex_latt
Hexagonal lattice utility object.
const FEProblemBase *const _fe_problem
IntRange< T > make_range(T beg, T end)
bool absoluteFuzzyGreaterEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
bool absoluteFuzzyGreaterThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
const ExecFlagType EXEC_INITIAL

◆ divisionIndex() [2/2]

unsigned int HexagonalGridDivision::divisionIndex ( const Elem &  elem) const
overridevirtual

Implements MeshDivision.

Definition at line 106 of file HexagonalGridDivision.C.

107 {
108  return divisionIndex(elem.vertex_average());
109 }
virtual unsigned int divisionIndex(const Point &pt) const override

◆ initialize()

void HexagonalGridDivision::initialize ( )
overridevirtual

Reimplemented from MeshDivision.

Definition at line 77 of file HexagonalGridDivision.C.

Referenced by HexagonalGridDivision().

78 {
79  // We make very large pins so they cover the entire position
80  _hex_latt = std::make_unique<HexagonalLatticeUtils>(
82 
83  if (!_center_positions)
84  setNumDivisions(_hex_latt->totalPins(_nr) * _nz);
85  else
87 
88  // Check that the grid is well-defined
90  {
91  const Real min_center_dist = _center_positions->getMinDistanceBetweenPositions();
92  // Note that if the positions are not aligned on a hexagonal lattice themselves,
93  // this bound is not sufficiently strict. The simplest example would be non-coplanar
94  // points, which can be a great distance away axially but be on the same axis
97  "Hexagonal grids centered on the positions are too close to each other (min distance: ",
98  min_center_dist,
99  "), closer than the extent of each grid (",
101  "). Mesh division is ill-defined ");
102  }
103 }
const unsigned int _nr
Number of rings in the radial direction.
const Positions * _center_positions
Centers of the lattices (lattices centered around positions)
const Real _pin_pitch
Pitch between fuel pins.
const unsigned int _nz
Number of divisions in the Z direction.
void mooseWarning(Args &&... args) const
const MooseEnum _z_axis_index
Axial component for the Z axis.
unsigned int getNumPositions(bool initial=false) const
std::unique_ptr< HexagonalLatticeUtils > _hex_latt
Hexagonal lattice utility object.
void setNumDivisions(const unsigned int ndivs)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real getMinDistanceBetweenPositions() const
bool absoluteFuzzyGreaterThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
const Real _lattice_flat_to_flat
Distance from one side to the one facing it of the lattice.

◆ validParams()

InputParameters HexagonalGridDivision::validParams ( )
static

Definition at line 20 of file HexagonalGridDivision.C.

21 {
23  params.addClassDescription(
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");
27 
28  params.addParam<Point>("center", "Center of the hexagonal grid");
29  params.addParam<PositionsName>("center_positions", "Centers of the hexagonal grids");
30 
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");
36  params.addRequiredRangeCheckedParam<Real>("pin_pitch", "pin_pitch>0", "Distance between pins");
37 
38  params.addRequiredParam<Real>("z_min", "Minimal axial extent of the lattice");
39  params.addRequiredParam<Real>("z_max", "Maximum axial extent of the lattice");
40  params.addRequiredRangeCheckedParam<unsigned int>("nr", "nr>0", "Number of hexagonal rings");
41  params.addRequiredRangeCheckedParam<unsigned int>("nz", "nz>0", "Number of divisions in Z");
42  params.addParam<bool>(
43  "assign_domain_outside_grid_to_border",
44  false,
45  "Whether to map the domain outside the grid back to the border of the grid");
46 
47  return params;
48 }
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()

Member Data Documentation

◆ _center

const Point HexagonalGridDivision::_center
protected

Center of the lattice (single lattice)

Definition at line 33 of file HexagonalGridDivision.h.

Referenced by divisionIndex().

◆ _center_positions

const Positions* HexagonalGridDivision::_center_positions
protected

Centers of the lattices (lattices centered around positions)

Definition at line 35 of file HexagonalGridDivision.h.

Referenced by divisionIndex(), HexagonalGridDivision(), and initialize().

◆ _hex_latt

std::unique_ptr<HexagonalLatticeUtils> HexagonalGridDivision::_hex_latt
protected

Hexagonal lattice utility object.

Definition at line 59 of file HexagonalGridDivision.h.

Referenced by divisionIndex(), and initialize().

◆ _lattice_flat_to_flat

const Real HexagonalGridDivision::_lattice_flat_to_flat
protected

Distance from one side to the one facing it of the lattice.

Definition at line 39 of file HexagonalGridDivision.h.

Referenced by HexagonalGridDivision(), and initialize().

◆ _max_z

const Real HexagonalGridDivision::_max_z
protected

Maximal axial coordinate.

Definition at line 49 of file HexagonalGridDivision.h.

Referenced by divisionIndex(), and HexagonalGridDivision().

◆ _min_z

const Real HexagonalGridDivision::_min_z
protected

Minimal axial coordinate.

Definition at line 47 of file HexagonalGridDivision.h.

Referenced by divisionIndex(), and HexagonalGridDivision().

◆ _nr

const unsigned int HexagonalGridDivision::_nr
protected

Number of rings in the radial direction.

Definition at line 52 of file HexagonalGridDivision.h.

Referenced by divisionIndex(), and initialize().

◆ _nz

const unsigned int HexagonalGridDivision::_nz
protected

Number of divisions in the Z direction.

Definition at line 54 of file HexagonalGridDivision.h.

Referenced by divisionIndex(), HexagonalGridDivision(), and initialize().

◆ _outside_grid_counts_as_border

const bool HexagonalGridDivision::_outside_grid_counts_as_border
protected

Whether to map outside the grid onto the corner.

Definition at line 56 of file HexagonalGridDivision.h.

Referenced by divisionIndex().

◆ _pin_pitch

const Real HexagonalGridDivision::_pin_pitch
protected

Pitch between fuel pins.

Definition at line 41 of file HexagonalGridDivision.h.

Referenced by HexagonalGridDivision(), and initialize().

◆ _z_axis_index

const MooseEnum HexagonalGridDivision::_z_axis_index
protected

Axial component for the Z axis.

Definition at line 44 of file HexagonalGridDivision.h.

Referenced by divisionIndex(), and initialize().


The documentation for this class was generated from the following files: