https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
16namespace channel_type
17{
25} // namespace channel_type
26#endif
27
39{
40public:
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
267 Real cornerHydraulicDiameter() const { return _corner_Dh; }
268
273 Real hydraulicDiameter() const { return _Dh; }
274
280
285 Real edgeWettedArea() const { return _edge_wetted_area; }
286
291 Real cornerWettedArea() const { return _corner_wetted_area; }
292
297 Real wettedArea() const { return _wetted_area; }
298
304
309 Real edgeFlowVolume() const { return _edge_flow_volume; }
310
315 Real cornerFlowVolume() const { return _corner_flow_volume; }
316
321 Real interiorVolume() const { return _interior_volume; }
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
369 Real pinBundleSpacing() const { return _pin_bundle_spacing; }
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
396 Real cornerEdgeLength() const { return _corner_edge_length; }
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
608protected:
614 unsigned int globalGapIndex(const std::pair<int, int> & local_gap) const;
615
617 const Real _bundle_pitch;
618
620 const Real _pin_pitch;
621
623 const Real _pin_diameter;
624
626 const Real _wire_diameter;
627
629 const Real _wire_pitch;
630
632 const unsigned int _n_rings;
633
635 const unsigned int _axis;
636
639
641 const RealTensorValue _rotation_matrix;
642
645
647 const Real _pin_area;
648
651
653 const Real _wire_area;
654
657
660
663
665 const Real _P_over_D;
666
668 const Real _L_over_D;
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
696
698 unsigned int _n_edge_channels;
699
701 unsigned int _n_corner_channels;
702
705
708
711
714
716 Real _Dh;
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
817private:
819 void computeGapIndices();
820
823
826
829
831 void computeFlowVolumes();
832
834 void computeWettedAreas();
835
838
846
849};
const Real p
Class providing various utility functions related to triangular lattices of pins enclosed in a hexago...
const Real _bundle_side_length
Side length of duct.
unsigned int _n_corner_channels
Total number of corner channels.
const Real _pin_area
Pin cross-sectional area.
Real wirePitch() const
Get the wire pitch.
Real wireVolumePerPitch() const
Get the wire volume per pitch.
unsigned int _n_pins
Total number of pins.
Real pinBundleSpacing() const
Get the distance between the outermost pins and the duct walls.
const Real _pin_volume_per_pitch
Single-pin volume per wire pitch.
Real _wire_volume_per_pitch
Single-wire volume per wire pitch.
std::vector< std::vector< unsigned int > > _interior_channel_pin_indices
Pin indices forming the corner of each interior channel.
void gapIndexAndDistance(const Point &point, unsigned int &index, Real &distance) const
Get the gap index and distance to that gap for a given point.
std::vector< Point > _pin_centers
Pin center coordinates.
std::vector< Real > _unit_translation_y
(unitless) y-translations to apply to move from a center point to a side of a hexagon
unsigned int nCornerPins() const
Get the number of corner pins.
Real _wetted_area
Wetted area of entire bundle per wire pitch.
Real hexagonPitch(const Real volume) const
Get the pitch of a hexagonal prism based on its per-wire-pitch volume.
unsigned int rings(const unsigned int n) const
Get the number of rings for a specified number of pins.
Real cornerVolume() const
Get the total volume of an corner channel per wire pitch.
const std::vector< Point > & pinCenters() const
Get the center coordinates of the pins.
void computeWettedAreas()
Compute the wetted areas for each channel type.
unsigned int _n_interior_gaps
Number of gaps that touch an interior channel.
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 closestPinIndex(const Point &point) const
Get the closest pin index given a point outside the lattice.
void computeChannelPinIndices()
Get the pin indices that form the corners of each channel type.
Real _Dh
Bundle-wide hydraulic diameter.
const Real _pin_circumference
Pin circumference.
static const unsigned int NUM_SIDES
Number of sides in a hexagon.
unsigned int nInteriorChannels() const
Get the number of interior channels.
Real _flow_volume
Bundle-wide flow volume per wire pitch.
unsigned int nInteriorPins() const
Get the number of interior pins.
const Real _L_over_D
Wire axial lead length to diameter ratio.
std::vector< std::vector< Real > > _duct_coeffs
Coefficients in the line equations defining each duct wall.
Real _wire_surface_area_per_pitch
Wire surface area per wire pitch.
Real distanceFromGap(const Point &pt, const unsigned int gap_index) const
Distance from a point and a gap.
unsigned int pinIndex(const Point &point) const
Get the pin index given a point.
unsigned int _n_channels
Total number of channels.
Real _edge_wetted_area
Wetted area of an edge channel per wire pitch.
const std::vector< Point > & gapCenters() const
Get the center coordinates of the gaps.
const std::vector< Point > & gapUnitNormals() const
Get the unit normals for all of the gaps.
Real _edge_flow_volume
Flow volume of an edge channel per wire pitch.
Real hydraulicDiameter() const
Get the overall bundle hydraulic diameter.
void computeFlowVolumes()
Compute the flow volumes for each channel type.
Real _corner_volume
Total volume of a corner channel per wire pitch.
Real pinPitch() const
Get the pin pitch.
const Real _wire_pitch
Wire pitch.
Real _interior_Dh
Hydraulic diameter of interior channel.
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 cornerEdgeLength() const
Get half the distance of the duct that a corner channel is in contact with.
Real _edge_Dh
Hydraulic diameter of edge channel.
Real heightToDiameter() const
Get the (wire) axial pitch-to-diameter ratio.
Real triangleArea(const Real side) const
Get the area of an equilateral triangle with given side length.
const std::vector< std::vector< unsigned int > > & interiorChannelPinIndices() const
Get the pin indices forming the corners of all interior channels.
unsigned int nEdgePins() const
Get the number of edge pins.
Real interiorWettedArea() const
Get the wetted area of an interior channel per wire pitch.
const Real _wire_area
Wire cross-sectional area.
Real _corner_wetted_area
Wetted area of a corner channel per wire pitch.
Real hexagonSide(const Real pitch) const
Get the side length of a hexagon with given flat-to-flat distance (pitch)
unsigned int nCornerChannels() const
Get the number of corner channels.
Real triangleVolume(const Real side) const
Get the volume of an equilateral triangle prism per wire pitch.
const std::vector< std::pair< int, int > > & gapIndices() const
Get the pin and side indices on each gap.
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 ...
const Real _pin_diameter
Pin diameter.
Real pinVolumePerPitch() const
Get the pin volume per pitch.
const Real _pin_surface_area_per_pitch
Pin surface area per wire pitch.
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.
const std::vector< std::vector< unsigned int > > & cornerChannelPinIndices() const
Get the pin indices forming one of the corners of all corner channels.
unsigned int nChannels() const
Get the total number of channels.
Real pitchToDiameter() const
Get the (pin) pitch-to-diameter ratio.
void computePinAndDuctCoordinates()
Compute the pin center coordinates and the duct corner coordinates.
unsigned int _iy
Index representing "second" coordinate of 2-D plane.
unsigned int lastPinInRing(const unsigned int ring) const
Get the index of the "last" pin in a ring.
const unsigned int _n_rings
Total number of rings of pins.
Real _corner_flow_volume
Flow volume of a corner channel per wire pitch.
const RealTensorValue _rotation_matrix
Rotation matrix to apply the rotation why.
Real edgeFlowVolume() const
Get the flow volume of an edge channel per wire pitch.
const std::vector< std::vector< int > > & localToGlobalGaps() const
For each subchannel, get the indices of the gaps that touch that subchannel.
unsigned int interiorChannels(const unsigned int ring)
Get the number of interior channels between ring and ring - 1 (0 indexing)
Real _interior_wetted_area
Wetted area of an interior channel per wire pitch.
std::vector< std::vector< int > > _local_to_global_gaps
Local-to-global gap indexing, ordered by channel ID.
Real wettedArea() const
Get the wetted area of entire bundle per wire pitch.
unsigned int nPins() const
Get the total number of pins for the lattice.
Real cornerHydraulicDiameter() const
Get the hydraulic diameter of a corner channel.
const Real _bundle_pitch
Bundle pitch (distance across bundle measured flat-to-flat on the inside of the duct)
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 pinSurfaceAreaPerPitch() const
Get the pin surface area per wire pitch.
Real cornerWettedArea() const
Get the wetted area of a corner channel per wire pitch.
Real pinDiameter() const
Get the pin diameter.
Real _pin_bundle_spacing
Spacing between the duct inner wall and the pin surface.
std::vector< Point > _gap_centers
Center points of all the gaps.
unsigned int _ix
Index representing "first" coordinate of 2-D plane.
Real edgeHydraulicDiameter() const
Get the hydraulic diameter of an edge channel.
const Real _P_over_D
Pitch-to-diameter ratio.
Point channelCentroid(const std::vector< Point > &corners) const
Get the centroid of a channel given the corner coordinates.
void computeHydraulicDiameters()
Compute the hydraulic diameters for each channel type.
std::vector< std::vector< unsigned int > > _corner_channel_pin_indices
Pin indices forming one of the corners of each corner channel.
Real hexagonArea(const Real pitch) const
Get the area of a hexagon with given flat-to-flat distance (pitch)
void computeWireVolumeAndAreaPerPitch()
Compute the volume and surface area const occupied by the wire in one with pitch.
std::vector< std::vector< Point > > _gap_points
Two points on each gap, in order to compute distance-from-gap calculations.
unsigned int _n_edge_channels
Total number of edge channels.
void computePinBundleSpacing()
Compute the spacing between the outer pins and the duct inner walls.
std::vector< Point > _gap_unit_normals
Unit normal vectors for each gap.
unsigned int nGaps() const
Get the number of gaps.
Real flowVolume() const
Get the flow volume of the bundle per wire pitch.
bool lastGapInRing(const unsigned int gap_index) const
Whether this gap is the "last" in the ring, i.e.
std::vector< std::vector< unsigned int > > _edge_channel_pin_indices
Pin indices forming two of the corners of each edge channel.
Real pinRadius() const
Get the pin outer radius.
const Real _wire_diameter
Wire diameter.
Real channelHydraulicDiameter(const channel_type::ChannelTypeEnum &channel) const
Get the hydraulic diameter of a channel.
unsigned int firstPinInRing(const unsigned int ring) const
Get the index of the "first" pin in a ring.
Real cornerFlowVolume() const
Get the flow volume of an corner channel per wire pitch.
const std::vector< std::vector< Point > > & pinCenteredCornerCoordinates() const
Get the corner coordinates of a hexagon surrounding each pin.
std::vector< std::pair< int, int > > _gap_indices
Gap indices, connecting two pins or one pin and a side, ordered by global gap ID.
std::vector< std::vector< Point > > _pin_centered_corner_coordinates
Corner coordinates of a hexagon surrounding each pin.
unsigned int channelIndex(const Point &point) const
Get the channel index given a point.
Real _corner_Dh
Hydraulic diameter of corner channel.
Real _interior_flow_volume
Flow volume of an interior channel per wire pitch.
void computeGapIndices()
Determine the global gap indices, sorted first by lower pin ID and next by higher pin ID.
std::vector< Point > _duct_corners
Six corner coordinates for the ducts.
Real bundlePitch() const
Get the bundle pitch.
Real interiorFlowVolume() const
Get the flow volume of an interior channel per wire pitch.
bool insideLattice(const Point &point) const
Whether the point is inside the lattice.
Real sideTranslationX(const unsigned int side) const
Get the unit vector translation to move a center point to a duct wall.
unsigned int axis() const
Get the vertical axis of the bed along which pins are aligned.
Real _edge_volume
Total volume of an edge channel per wire pitch.
const Real _pin_pitch
Pin pitch.
unsigned int _n_gaps
Total number of gaps.
Real channelSpecificSurfaceArea(const channel_type::ChannelTypeEnum &channel) const
Get the specific surface area of a channel.
const std::vector< std::vector< unsigned int > > & edgeChannelPinIndices() const
Get the pin indices forming two of the corners of all edge channels.
Real interiorVolume() const
Get the total volume of an interior 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.
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.
Real interiorHydraulicDiameter() const
Get the hydraulic diameter of an interior channel.
unsigned int _n_interior_pins
Number of interior pins.
Real minDuctWallDistance(const Point &p) const
Get the minimum distance from a point to the duct inner surface.
const unsigned int _axis
Vertical axis of the bundle along which the pins are aligned.
unsigned int _n_edge_pins
Number of edge pins.
Real edgeVolume() const
Get the total volume of an edge channel per wire pitch.
Real hexagonVolume(const Real side) const
Get the volume of a hexagonal prism per wire pitch.
Real triangleHeight(const Real side) const
Get the height of an equilateral triangle with given side length.
channel_type::ChannelTypeEnum channelType(const Point &p) const
Get the channel type (interior, edge, corner) given a point.
unsigned int nInteriorGaps() const
Get the number of gaps that touch an interior channel.
unsigned int _n_corner_pins
Number of corner pins.
const Real _wire_circumference
Wire circumference.
unsigned int gapIndex(const Point &point) const
Get the index for the gap closest to the point.
Real sideTranslationY(const unsigned int side) const
Get the unit vector translation to move a center point to a duct wall.
unsigned int nEdgeChannels() const
Get the number of edge channels.
unsigned int _n_interior_channels
Total number of interior channels.
Real wireDiameter() const
Get the wire diameter.
Real edgeWettedArea() const
Get the wetted area 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 triangleSide(const Real height) const
Get the side of an equilateral triangle with given height.
Real _corner_edge_length
Half the distance for which a corner channel is in contact with the duct.
void computePinAndChannelTypes()
Compute the number of pins and channels and their types for the lattice.
unsigned int pins(const unsigned int n) const
Get the number of pins in a given ring.
Real _interior_volume
Total volume of an interior channel per wire pitch.
unsigned int ringIndex(const unsigned int pin) const
Get the index of the ring for a certain pin index.
ChannelTypeEnum
Type of subchannel.
Real distance(const Point &p)