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  const Real rotation_around_axis = 0);
49 
56  Real distanceFromGap(const Point & pt, const unsigned int gap_index) const;
57 
63  unsigned int gapIndex(const Point & point) const;
64 
71  void gapIndexAndDistance(const Point & point, unsigned int & index, Real & distance) const;
72 
78  Real sideTranslationX(const unsigned int side) const { return _unit_translation_x[side]; }
79 
85  Real sideTranslationY(const unsigned int side) const { return _unit_translation_y[side]; }
86 
92  unsigned int firstPinInRing(const unsigned int ring) const;
93 
99  unsigned int lastPinInRing(const unsigned int ring) const;
100 
106  bool lastGapInRing(const unsigned int gap_index) const;
107 
113  unsigned int ringIndex(const unsigned int pin) const;
114 
119  const std::vector<Point> & gapUnitNormals() const { return _gap_unit_normals; }
120 
126  unsigned int pins(const unsigned int n) const;
127 
133  unsigned int totalPins(const unsigned int n) const;
134 
140  unsigned int rings(const unsigned int n) const;
141 
147  unsigned int interiorChannels(const unsigned int ring);
148 
153  unsigned int nInteriorGaps() const { return _n_interior_gaps; }
154 
159  const std::vector<Point> & gapCenters() const { return _gap_centers; }
160 
165  unsigned int nGaps() const { return _n_gaps; }
166 
171  Real pitchToDiameter() const { return _P_over_D; }
172 
177  Real heightToDiameter() const { return _L_over_D; }
178 
183  unsigned int axis() const { return _axis; }
184 
189  Real pinDiameter() const { return _pin_diameter; }
190 
195  Real wirePitch() const { return _wire_pitch; }
196 
201  Real wireDiameter() const { return _wire_diameter; }
202 
207  Real pinPitch() const { return _pin_pitch; }
208 
213  Real bundlePitch() const { return _bundle_pitch; }
214 
220 
226 
231  unsigned int nInteriorPins() const { return _n_interior_pins; }
232 
237  unsigned int nEdgePins() const { return _n_edge_pins; }
238 
243  unsigned int nCornerPins() const { return _n_corner_pins; }
244 
249  unsigned int nPins() const { return _n_pins; }
250 
256 
261  Real edgeHydraulicDiameter() const { return _edge_Dh; }
262 
268 
273  Real hydraulicDiameter() const { return _Dh; }
274 
280 
286 
292 
297  Real wettedArea() const { return _wetted_area; }
298 
304 
310 
316 
322 
327  Real edgeVolume() const { return _edge_volume; }
328 
333  Real cornerVolume() const { return _corner_volume; }
334 
339  Real flowVolume() const { return _flow_volume; }
340 
345  unsigned int nInteriorChannels() const { return _n_interior_channels; }
346 
351  unsigned int nEdgeChannels() const { return _n_edge_channels; }
352 
357  unsigned int nCornerChannels() const { return _n_corner_channels; }
358 
363  unsigned int nChannels() const { return _n_channels; }
364 
370 
375  const std::vector<Point> & pinCenters() const { return _pin_centers; }
376 
381  const std::vector<std::vector<Point>> & pinCenteredCornerCoordinates() const
382  {
384  }
385 
391 
397 
403  Real minDuctWallDistance(const Point & p) const;
404 
410  Real minDuctCornerDistance(const Point & p) const;
411 
417  channel_type::ChannelTypeEnum channelType(const Point & p) const;
418 
425 
432 
437  Real pinRadius() const;
438 
444  Real hexagonArea(const Real pitch) const;
445 
451  Real hexagonSide(const Real pitch) const;
452 
458  Real hexagonVolume(const Real side) const;
459 
465  Real hexagonPitch(const Real volume) const;
466 
472  Real triangleArea(const Real side) const;
473 
479  Real triangleHeight(const Real side) const;
480 
486  Real triangleSide(const Real height) const;
487 
493  Real triangleVolume(const Real side) const;
494 
499  const std::vector<std::vector<unsigned int>> & interiorChannelPinIndices() const
500  {
502  }
503 
508  const std::vector<std::vector<unsigned int>> & edgeChannelPinIndices() const
509  {
511  }
512 
517  const std::vector<std::vector<unsigned int>> & cornerChannelPinIndices() const
518  {
520  }
521 
526  const std::vector<std::pair<int, int>> & gapIndices() const { return _gap_indices; }
527 
532  const std::vector<std::vector<int>> & localToGlobalGaps() const { return _local_to_global_gaps; }
533 
540  const std::vector<Point>
541  interiorChannelCornerCoordinates(const unsigned int interior_channel_id) const;
542 
549  const std::vector<Point> edgeChannelCornerCoordinates(const unsigned int edge_channel_id) const;
550 
557  const std::vector<Point>
558  cornerChannelCornerCoordinates(const unsigned int corner_channel_id) const;
559 
565  Point channelCentroid(const std::vector<Point> & corners) const;
566 
572  unsigned int pinIndex(const Point & point) const;
573 
579  unsigned int closestPinIndex(const Point & point) const;
580 
586  unsigned int channelIndex(const Point & point) const;
587 
592  bool insideLattice(const Point & point) const;
593 
604  void get2DInputPatternIndex(const unsigned int pin_index,
605  unsigned int & row_index,
606  unsigned int & within_row_index) const;
607 
608 protected:
614  unsigned int globalGapIndex(const std::pair<int, int> & local_gap) const;
615 
618 
621 
624 
627 
630 
632  const unsigned int _n_rings;
633 
635  const unsigned int _axis;
636 
639 
642 
645 
648 
651 
654 
657 
660 
663 
666 
669 
672 
675 
678 
680  unsigned int _n_pins;
681 
683  unsigned int _n_interior_pins;
684 
686  unsigned int _n_edge_pins;
687 
689  unsigned int _n_corner_pins;
690 
692  unsigned int _n_channels;
693 
695  unsigned int _n_interior_channels;
696 
698  unsigned int _n_edge_channels;
699 
701  unsigned int _n_corner_channels;
702 
705 
708 
711 
714 
717 
720 
723 
726 
729 
732 
735 
738 
741 
744 
747 
750 
752  std::vector<Point> _pin_centers;
753 
755  std::vector<std::vector<Point>> _pin_centered_corner_coordinates;
756 
758  std::vector<Point> _duct_corners;
759 
766  std::vector<std::vector<Real>> _duct_coeffs;
767 
769  std::vector<std::vector<unsigned int>> _interior_channel_pin_indices;
770 
772  std::vector<std::vector<unsigned int>> _edge_channel_pin_indices;
773 
775  std::vector<std::vector<unsigned int>> _corner_channel_pin_indices;
776 
778  std::vector<std::pair<int, int>> _gap_indices;
779 
781  std::vector<std::vector<int>> _local_to_global_gaps;
782 
784  std::vector<std::vector<Point>> _gap_points;
785 
787  std::vector<Point> _gap_unit_normals;
788 
790  unsigned int _n_interior_gaps;
791 
793  unsigned int _n_gaps;
794 
795  static const Real SIN60;
796 
797  static const Real COS60;
798 
800  static const unsigned int NUM_SIDES;
801 
803  std::vector<Real> _unit_translation_x;
804 
806  std::vector<Real> _unit_translation_y;
807 
809  std::vector<Point> _gap_centers;
810 
812  unsigned int _ix;
813 
815  unsigned int _iy;
816 
817 private:
819  void computeGapIndices();
820 
823 
826 
829 
831  void computeFlowVolumes();
832 
834  void computeWettedAreas();
835 
838 
846 
849 };
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.
const RealTensorValue _rotation_matrix
Rotation matrix to apply the rotation why.
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 _rotation_around_axis
Rotation around the axis to apply to the lattice.
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) ...
TensorValue< Real > RealTensorValue
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.
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 Real rotation_around_axis=0)
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
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.