https://mooseframework.inl.gov
HexagonalLatticeUtils.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 "Moose.h"
13 #include "MooseTypes.h"
14 
15 #ifndef CARDINAL_ENUM_H
16 namespace channel_type
17 {
20 {
24 };
25 } // namespace channel_type
26 #endif
27 
39 {
40 public:
41  HexagonalLatticeUtils(const Real bundle_inner_flat_to_flat,
42  const Real pin_pitch,
43  const Real pin_diameter,
44  const Real wire_diameter,
45  const Real wire_pitch,
46  const unsigned int n_rings,
47  const unsigned int axis);
48 
55  Real distanceFromGap(const Point & pt, const unsigned int gap_index) const;
56 
62  unsigned int gapIndex(const Point & point) const;
63 
70  void gapIndexAndDistance(const Point & point, unsigned int & index, Real & distance) const;
71 
77  Real sideTranslationX(const unsigned int side) const { return _unit_translation_x[side]; }
78 
84  Real sideTranslationY(const unsigned int side) const { return _unit_translation_y[side]; }
85 
91  unsigned int firstPinInRing(const unsigned int ring) const;
92 
98  unsigned int lastPinInRing(const unsigned int ring) const;
99 
105  bool lastGapInRing(const unsigned int gap_index) const;
106 
112  unsigned int ringIndex(const unsigned int pin) const;
113 
118  const std::vector<Point> & gapUnitNormals() const { return _gap_unit_normals; }
119 
125  unsigned int pins(const unsigned int n) const;
126 
132  unsigned int totalPins(const unsigned int n) const;
133 
139  unsigned int rings(const unsigned int n) const;
140 
146  unsigned int interiorChannels(const unsigned int ring);
147 
152  unsigned int nInteriorGaps() const { return _n_interior_gaps; }
153 
158  const std::vector<Point> & gapCenters() const { return _gap_centers; }
159 
164  unsigned int nGaps() const { return _n_gaps; }
165 
170  Real pitchToDiameter() const { return _P_over_D; }
171 
176  Real heightToDiameter() const { return _L_over_D; }
177 
182  unsigned int axis() const { return _axis; }
183 
188  Real pinDiameter() const { return _pin_diameter; }
189 
194  Real wirePitch() const { return _wire_pitch; }
195 
200  Real wireDiameter() const { return _wire_diameter; }
201 
206  Real pinPitch() const { return _pin_pitch; }
207 
212  Real bundlePitch() const { return _bundle_pitch; }
213 
219 
225 
230  unsigned int nInteriorPins() const { return _n_interior_pins; }
231 
236  unsigned int nEdgePins() const { return _n_edge_pins; }
237 
242  unsigned int nCornerPins() const { return _n_corner_pins; }
243 
248  unsigned int nPins() const { return _n_pins; }
249 
255 
260  Real edgeHydraulicDiameter() const { return _edge_Dh; }
261 
267 
272  Real hydraulicDiameter() const { return _Dh; }
273 
279 
285 
291 
296  Real wettedArea() const { return _wetted_area; }
297 
303 
309 
315 
321 
326  Real edgeVolume() const { return _edge_volume; }
327 
332  Real cornerVolume() const { return _corner_volume; }
333 
338  Real flowVolume() const { return _flow_volume; }
339 
344  unsigned int nInteriorChannels() const { return _n_interior_channels; }
345 
350  unsigned int nEdgeChannels() const { return _n_edge_channels; }
351 
356  unsigned int nCornerChannels() const { return _n_corner_channels; }
357 
362  unsigned int nChannels() const { return _n_channels; }
363 
369 
374  const std::vector<Point> & pinCenters() const { return _pin_centers; }
375 
380  const std::vector<std::vector<Point>> & pinCenteredCornerCoordinates() const
381  {
383  }
384 
390 
396 
402  Real minDuctWallDistance(const Point & p) const;
403 
409  Real minDuctCornerDistance(const Point & p) const;
410 
416  channel_type::ChannelTypeEnum channelType(const Point & p) const;
417 
424 
431 
436  Real pinRadius() const;
437 
443  Real hexagonArea(const Real pitch) const;
444 
450  Real hexagonSide(const Real pitch) const;
451 
457  Real hexagonVolume(const Real side) const;
458 
464  Real hexagonPitch(const Real volume) const;
465 
471  Real triangleArea(const Real side) const;
472 
478  Real triangleHeight(const Real side) const;
479 
485  Real triangleSide(const Real height) const;
486 
492  Real triangleVolume(const Real side) const;
493 
498  const std::vector<std::vector<unsigned int>> & interiorChannelPinIndices() const
499  {
501  }
502 
507  const std::vector<std::vector<unsigned int>> & edgeChannelPinIndices() const
508  {
510  }
511 
516  const std::vector<std::vector<unsigned int>> & cornerChannelPinIndices() const
517  {
519  }
520 
525  const std::vector<std::pair<int, int>> & gapIndices() const { return _gap_indices; }
526 
531  const std::vector<std::vector<int>> & localToGlobalGaps() const { return _local_to_global_gaps; }
532 
539  const std::vector<Point>
540  interiorChannelCornerCoordinates(const unsigned int interior_channel_id) const;
541 
548  const std::vector<Point> edgeChannelCornerCoordinates(const unsigned int edge_channel_id) const;
549 
556  const std::vector<Point>
557  cornerChannelCornerCoordinates(const unsigned int corner_channel_id) const;
558 
564  Point channelCentroid(const std::vector<Point> & corners) const;
565 
571  unsigned int pinIndex(const Point & point) const;
572 
578  unsigned int closestPinIndex(const Point & point) const;
579 
585  unsigned int channelIndex(const Point & point) const;
586 
591  bool insideLattice(const Point & point) const;
592 
603  void get2DInputPatternIndex(const unsigned int pin_index,
604  unsigned int & row_index,
605  unsigned int & within_row_index) const;
606 
607 protected:
613  unsigned int globalGapIndex(const std::pair<int, int> & local_gap) const;
614 
617 
620 
623 
626 
629 
631  const unsigned int _n_rings;
632 
634  const unsigned int _axis;
635 
638 
641 
644 
647 
650 
653 
656 
659 
662 
665 
668 
671 
673  unsigned int _n_pins;
674 
676  unsigned int _n_interior_pins;
677 
679  unsigned int _n_edge_pins;
680 
682  unsigned int _n_corner_pins;
683 
685  unsigned int _n_channels;
686 
688  unsigned int _n_interior_channels;
689 
691  unsigned int _n_edge_channels;
692 
694  unsigned int _n_corner_channels;
695 
698 
701 
704 
707 
710 
713 
716 
719 
722 
725 
728 
731 
734 
737 
740 
743 
745  std::vector<Point> _pin_centers;
746 
748  std::vector<std::vector<Point>> _pin_centered_corner_coordinates;
749 
751  std::vector<Point> _duct_corners;
752 
759  std::vector<std::vector<Real>> _duct_coeffs;
760 
762  std::vector<std::vector<unsigned int>> _interior_channel_pin_indices;
763 
765  std::vector<std::vector<unsigned int>> _edge_channel_pin_indices;
766 
768  std::vector<std::vector<unsigned int>> _corner_channel_pin_indices;
769 
771  std::vector<std::pair<int, int>> _gap_indices;
772 
774  std::vector<std::vector<int>> _local_to_global_gaps;
775 
777  std::vector<std::vector<Point>> _gap_points;
778 
780  std::vector<Point> _gap_unit_normals;
781 
783  unsigned int _n_interior_gaps;
784 
786  unsigned int _n_gaps;
787 
788  static const Real SIN60;
789 
790  static const Real COS60;
791 
793  static const unsigned int NUM_SIDES;
794 
796  std::vector<Real> _unit_translation_x;
797 
799  std::vector<Real> _unit_translation_y;
800 
802  std::vector<Point> _gap_centers;
803 
805  unsigned int _ix;
806 
808  unsigned int _iy;
809 
810 private:
812  void computeGapIndices();
813 
816 
819 
822 
824  void computeFlowVolumes();
825 
827  void computeWettedAreas();
828 
831 
839 
842 };
const Real _wire_diameter
Wire diameter.
Real hexagonPitch(const Real volume) const
Get the pitch of a hexagonal prism based on its per-wire-pitch volume.
void computeGapIndices()
Determine the global gap indices, sorted first by lower pin ID and next by higher pin ID...
Real edgeHydraulicDiameter() const
Get the hydraulic diameter of an edge channel.
std::vector< Point > _gap_unit_normals
Unit normal vectors for each gap.
const std::vector< Point > & gapCenters() const
Get the center coordinates of the gaps.
unsigned int _n_interior_pins
Number of interior pins.
Real cornerFlowVolume() const
Get the flow volume of an corner channel per wire pitch.
ChannelTypeEnum
Type of subchannel.
unsigned int _n_interior_gaps
Number of gaps that touch an interior channel.
const unsigned int _n_rings
Total number of rings of pins.
std::vector< std::vector< Point > > _pin_centered_corner_coordinates
Corner coordinates of a hexagon surrounding each pin.
Real cornerWettedArea() const
Get the wetted area of a corner channel per wire pitch.
Real _corner_flow_volume
Flow volume of a corner channel per wire pitch.
Real wireVolumePerPitch() const
Get the wire volume per pitch.
Real _wire_volume_per_pitch
Single-wire volume per wire pitch.
void computeHydraulicDiameters()
Compute the hydraulic diameters for each channel type.
Real pinVolumePerPitch() const
Get the pin volume per pitch.
const Real _wire_area
Wire cross-sectional area.
void get2DInputPatternIndex(const unsigned int pin_index, unsigned int &row_index, unsigned int &within_row_index) const
Conversion from lattice pin indexing to the 2D input file index.
unsigned int rings(const unsigned int n) const
Get the number of rings for a specified number of pins.
unsigned int pinIndex(const Point &point) const
Get the pin index given a point.
const Real _pin_diameter
Pin diameter.
Real distanceFromGap(const Point &pt, const unsigned int gap_index) const
Distance from a point and a gap.
unsigned int nInteriorPins() const
Get the number of interior pins.
Real hexagonSide(const Real pitch) const
Get the side length of a hexagon with given flat-to-flat distance (pitch)
Real _flow_volume
Bundle-wide flow volume per wire pitch.
unsigned int nChannels() const
Get the total number of channels.
Real _corner_volume
Total volume of a corner channel per wire pitch.
unsigned int totalPins(const unsigned int n) const
Get the total number of pins for all rings.
const Real _P_over_D
Pitch-to-diameter ratio.
unsigned int channelIndex(const Point &point) const
Get the channel index given a point.
channel_type::ChannelTypeEnum channelType(const Point &p) const
Get the channel type (interior, edge, corner) given a point.
Real interiorFlowVolume() const
Get the flow volume of an interior channel per wire pitch.
void computePinAndChannelTypes()
Compute the number of pins and channels and their types for the lattice.
const std::vector< Point > cornerChannelCornerCoordinates(const unsigned int corner_channel_id) const
Get the corner coordinates of a corner channel given an ID (relative to the start of the corner chann...
Real hexagonArea(const Real pitch) const
Get the area of a hexagon with given flat-to-flat distance (pitch)
const std::vector< std::vector< unsigned int > > & interiorChannelPinIndices() const
Get the pin indices forming the corners of all interior channels.
Real minDuctWallDistance(const Point &p) const
Get the minimum distance from a point to the duct inner surface.
std::vector< Point > _gap_centers
Center points of all the gaps.
Real flowVolume() const
Get the flow volume of the bundle per wire pitch.
unsigned int nEdgeChannels() const
Get the number of edge channels.
const Real _pin_area
Pin cross-sectional area.
void computePinBundleSpacing()
Compute the spacing between the outer pins and the duct inner walls.
Real pinBundleSpacing() const
Get the distance between the outermost pins and the duct walls.
Real edgeWettedArea() const
Get the wetted area of an edge channel per wire pitch.
unsigned int _n_interior_channels
Total number of interior channels.
std::vector< std::vector< unsigned int > > _edge_channel_pin_indices
Pin indices forming two of the corners of each edge channel.
const std::vector< std::vector< unsigned int > > & cornerChannelPinIndices() const
Get the pin indices forming one of the corners of all corner channels.
unsigned int nCornerPins() const
Get the number of corner pins.
const Real _L_over_D
Wire axial lead length to diameter ratio.
const std::vector< Point > edgeChannelCornerCoordinates(const unsigned int edge_channel_id) const
Get the corner coordinates of an edge channel given an ID (relative to the start of the edge channels...
Real distance(const Point &p)
Real wireDiameter() const
Get the wire diameter.
const std::vector< std::vector< unsigned int > > & edgeChannelPinIndices() const
Get the pin indices forming two of the corners of all edge channels.
unsigned int interiorChannels(const unsigned int ring)
Get the number of interior channels between ring and ring - 1 (0 indexing)
unsigned int gapIndex(const Point &point) const
Get the index for the gap closest to the point.
const Real _wire_pitch
Wire pitch.
const unsigned int _axis
Vertical axis of the bundle along which the pins are aligned.
Real _interior_wetted_area
Wetted area of an interior channel per wire pitch.
std::vector< Point > _pin_centers
Pin center coordinates.
Real wirePitch() const
Get the wire pitch.
Real triangleVolume(const Real side) const
Get the volume of an equilateral triangle prism per wire pitch.
Real _corner_Dh
Hydraulic diameter of corner channel.
Real _corner_edge_length
Half the distance for which a corner channel is in contact with the duct.
const Real _bundle_pitch
Bundle pitch (distance across bundle measured flat-to-flat on the inside of the duct) ...
Class providing various utility functions related to triangular lattices of pins enclosed in a hexago...
void computeChannelPinIndices()
Get the pin indices that form the corners of each channel type.
const Real _pin_pitch
Pin pitch.
Real _interior_volume
Total volume of an interior channel per wire pitch.
unsigned int nCornerChannels() const
Get the number of corner channels.
static const std::string pitch
Real _interior_Dh
Hydraulic diameter of interior channel.
Real edgeVolume() const
Get the total volume of an edge channel per wire pitch.
unsigned int globalGapIndex(const std::pair< int, int > &local_gap) const
Get the global gap index from the local gap index.
Real sideTranslationY(const unsigned int side) const
Get the unit vector translation to move a center point to a duct wall.
std::vector< std::vector< unsigned int > > _corner_channel_pin_indices
Pin indices forming one of the corners of each corner channel.
Real wettedArea() const
Get the wetted area of entire bundle per wire pitch.
Real heightToDiameter() const
Get the (wire) axial pitch-to-diameter ratio.
Real _interior_flow_volume
Flow volume of an interior channel per wire pitch.
unsigned int _iy
Index representing "second" coordinate of 2-D plane.
unsigned int _ix
Index representing "first" coordinate of 2-D plane.
unsigned int nInteriorChannels() const
Get the number of interior channels.
Real cornerVolume() const
Get the total volume of an corner channel per wire pitch.
const Real _pin_circumference
Pin circumference.
unsigned int pins(const unsigned int n) const
Get the number of pins in a given ring.
Real _pin_bundle_spacing
Spacing between the duct inner wall and the pin surface.
std::vector< std::pair< int, int > > _gap_indices
Gap indices, connecting two pins or one pin and a side, ordered by global gap ID. ...
Real _wetted_area
Wetted area of entire bundle per wire pitch.
const Real _pin_volume_per_pitch
Single-pin volume per wire pitch.
unsigned int closestPinIndex(const Point &point) const
Get the closest pin index given a point outside the lattice.
Real sideTranslationX(const unsigned int side) const
Get the unit vector translation to move a center point to a duct wall.
Real channelHydraulicDiameter(const channel_type::ChannelTypeEnum &channel) const
Get the hydraulic diameter of a channel.
std::vector< std::vector< unsigned int > > _interior_channel_pin_indices
Pin indices forming the corner of each interior channel.
void computePinAndDuctCoordinates()
Compute the pin center coordinates and the duct corner coordinates.
std::vector< std::vector< int > > _local_to_global_gaps
Local-to-global gap indexing, ordered by channel ID.
const Real _bundle_side_length
Side length of duct.
unsigned int _n_corner_pins
Number of corner pins.
void computeWettedAreas()
Compute the wetted areas for each channel type.
Real pinSurfaceAreaPerPitch() const
Get the pin surface area per wire pitch.
bool lastGapInRing(const unsigned int gap_index) const
Whether this gap is the "last" in the ring, i.e.
const std::vector< std::vector< int > > & localToGlobalGaps() const
For each subchannel, get the indices of the gaps that touch that subchannel.
unsigned int nEdgePins() const
Get the number of edge pins.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
HexagonalLatticeUtils(const Real bundle_inner_flat_to_flat, const Real pin_pitch, const Real pin_diameter, const Real wire_diameter, const Real wire_pitch, const unsigned int n_rings, const unsigned int axis)
const std::vector< std::pair< int, int > > & gapIndices() const
Get the pin and side indices on each gap.
unsigned int _n_edge_pins
Number of edge pins.
const std::vector< Point > interiorChannelCornerCoordinates(const unsigned int interior_channel_id) const
Get the corner coordinates of an interior channel given an ID (relative to the start of the interior ...
Real pinRadius() const
Get the pin outer radius.
void computeWireVolumeAndAreaPerPitch()
Compute the volume and surface area const occupied by the wire in one with pitch. ...
Real _edge_Dh
Hydraulic diameter of edge channel.
Real channelSpecificSurfaceArea(const channel_type::ChannelTypeEnum &channel) const
Get the specific surface area of a channel.
unsigned int _n_gaps
Total number of gaps.
Real _edge_wetted_area
Wetted area of an edge channel per wire pitch.
std::vector< std::vector< Point > > _gap_points
Two points on each gap, in order to compute distance-from-gap calculations.
const std::vector< std::vector< Point > > & pinCenteredCornerCoordinates() const
Get the corner coordinates of a hexagon surrounding each pin.
const Real _pin_surface_area_per_pitch
Pin surface area per wire pitch.
unsigned int _n_channels
Total number of channels.
Real _Dh
Bundle-wide hydraulic diameter.
unsigned int nGaps() const
Get the number of gaps.
const std::vector< Point > & gapUnitNormals() const
Get the unit normals for all of the gaps.
std::vector< Real > _unit_translation_y
(unitless) y-translations to apply to move from a center point to a side of a hexagon ...
Real _corner_wetted_area
Wetted area of a corner channel per wire pitch.
Real hydraulicDiameter() const
Get the overall bundle hydraulic diameter.
const std::vector< Point > & pinCenters() const
Get the center coordinates of the pins.
Real interiorWettedArea() const
Get the wetted area of an interior channel per wire pitch.
void computeFlowVolumes()
Compute the flow volumes for each channel type.
unsigned int _n_corner_channels
Total number of corner channels.
unsigned int _n_pins
Total number of pins.
Real triangleHeight(const Real side) const
Get the height of an equilateral triangle with given side length.
Point channelCentroid(const std::vector< Point > &corners) const
Get the centroid of a channel given the corner coordinates.
unsigned int axis() const
Get the vertical axis of the bed along which pins are aligned.
Real pinPitch() const
Get the pin pitch.
Real triangleArea(const Real side) const
Get the area of an equilateral triangle with given side length.
std::vector< std::vector< Real > > _duct_coeffs
Coefficients in the line equations defining each duct wall.
unsigned int ringIndex(const unsigned int pin) const
Get the index of the ring for a certain pin index.
unsigned int firstPinInRing(const unsigned int ring) const
Get the index of the "first" pin in a ring.
Real pitchToDiameter() const
Get the (pin) pitch-to-diameter ratio.
std::vector< Point > _duct_corners
Six corner coordinates for the ducts.
Real cornerEdgeLength() const
Get half the distance of the duct that a corner channel is in contact with.
Real triangleSide(const Real height) const
Get the side of an equilateral triangle with given height.
Real cornerHydraulicDiameter() const
Get the hydraulic diameter of a corner channel.
Real _edge_flow_volume
Flow volume of an edge channel per wire pitch.
unsigned int _n_edge_channels
Total number of edge channels.
unsigned int nInteriorGaps() const
Get the number of gaps that touch an interior channel.
Real edgeFlowVolume() const
Get the flow volume of an edge channel per wire pitch.
Real minDuctCornerDistance(const Point &p) const
Get the minimum distance from a point to the duct corners.
Real hexagonVolume(const Real side) const
Get the volume of a hexagonal prism per wire pitch.
Real _edge_volume
Total volume of an edge channel per wire pitch.
std::vector< Real > _unit_translation_x
(unitless) x-translations to apply to move from a center point to a side of a hexagon ...
unsigned int nPins() const
Get the total number of pins for the lattice.
unsigned int lastPinInRing(const unsigned int ring) const
Get the index of the "last" pin in a ring.
const Real _wire_circumference
Wire circumference.
void gapIndexAndDistance(const Point &point, unsigned int &index, Real &distance) const
Get the gap index and distance to that gap for a given point.
Real interiorHydraulicDiameter() const
Get the hydraulic diameter of an interior channel.
Real bundlePitch() const
Get the bundle pitch.
static const unsigned int NUM_SIDES
Number of sides in a hexagon.
Real pinDiameter() const
Get the pin diameter.
Real interiorVolume() const
Get the total volume of an interior channel per wire pitch.
Real _wire_surface_area_per_pitch
Wire surface area per wire pitch.
bool insideLattice(const Point &point) const
Whether the point is inside the lattice.