13 #include "libmesh/edge_edge2.h" 23 SCMQuadSubChannelMeshGenerator,
27 QuadSubChannelMeshGenerator,
31 SCMQuadPinMeshGenerator,
43 params.
addClassDescription(
"Creates one mesh containing both 1D subchannels and 1D pins in a " 44 "square lattice arrangement");
48 params.
addParam<
Real>(
"unheated_length_entry", 0.0,
"Unheated length at entry [m]");
50 params.
addParam<
Real>(
"unheated_length_exit", 0.0,
"Unheated length at exit [m]");
53 "spacer_z", {},
"Axial location of spacers/vanes/mixing vanes [m]");
55 "spacer_k", {},
"K-loss coefficient of spacers/vanes/mixing vanes [-]");
57 params.
addParam<std::vector<Real>>(
"z_blockage",
58 std::vector<Real>({0.0, 0.0}),
59 "Axial location of blockage (inlet, outlet) [m]");
60 params.
addParam<std::vector<unsigned int>>(
"index_blockage",
61 std::vector<unsigned int>({0}),
62 "Index of subchannels affected by blockage");
63 params.
addParam<std::vector<Real>>(
"reduction_blockage",
64 std::vector<Real>({1.0}),
65 "Area reduction of subchannels affected by blockage");
67 "k_blockage", std::vector<Real>({0.0}),
"Form loss coefficient of blocked subchannels");
69 params.
addParam<
Real>(
"Kij", 0.5,
"Lateral form loss coefficient [-]");
70 params.
addRequiredParam<
unsigned int>(
"n_cells",
"The number of cells in the axial direction");
71 params.
addRequiredParam<
unsigned int>(
"nx",
"Number of channels in the x direction [-]");
72 params.
addRequiredParam<
unsigned int>(
"ny",
"Number of channels in the y direction [-]");
76 "The side gap, not to be confused with the gap between pins; this refers to the gap next " 77 "to the duct or else the distance between the subchannel centroid and the duct wall. " 78 "distance(edge pin center, duct wall) = pitch / 2 + side_gap [m]");
80 params.
addParam<
unsigned int>(
"subchannel_block_id", 0,
"Subchannel block id");
81 params.
addParam<
unsigned int>(
"pin_block_id", 1,
"Fuel Pin block id");
88 _unheated_length_entry(getParam<
Real>(
"unheated_length_entry")),
89 _heated_length(getParam<
Real>(
"heated_length")),
90 _unheated_length_exit(getParam<
Real>(
"unheated_length_exit")),
91 _spacer_z(getParam<
std::vector<
Real>>(
"spacer_z")),
92 _spacer_k(getParam<
std::vector<
Real>>(
"spacer_k")),
93 _z_blockage(getParam<
std::vector<
Real>>(
"z_blockage")),
94 _index_blockage(getParam<
std::vector<unsigned
int>>(
"index_blockage")),
95 _reduction_blockage(getParam<
std::vector<
Real>>(
"reduction_blockage")),
96 _k_blockage(getParam<
std::vector<
Real>>(
"k_blockage")),
97 _kij(getParam<
Real>(
"Kij")),
98 _pitch(getParam<
Real>(
"pitch")),
99 _pin_diameter(getParam<
Real>(
"pin_diameter")),
100 _n_cells(getParam<unsigned
int>(
"n_cells")),
101 _nx(getParam<unsigned
int>(
"nx")),
102 _ny(getParam<unsigned
int>(
"ny")),
106 _side_gap(getParam<
Real>(
"side_gap")),
107 _subchannel_block_id(getParam<unsigned
int>(
"subchannel_block_id")),
108 _pin_block_id(getParam<unsigned
int>(
"pin_block_id"))
113 paramError(
"n_cells",
"The number of axial cells must be greater than zero");
115 if (total_length <= 0.0)
116 mooseError(
"Total bundle length must be greater than zero");
119 mooseError(
"The number of subchannels must be greater than zero in each direction");
122 mooseError(
"The number of subchannels cannot be less than 2 in both directions. " 123 "Smallest assembly allowed is either 2X1 or 1X2.");
130 mooseError(
"Size of vector spacer_z should equal size of spacer_k");
133 if (spacer_z < 0.0 || spacer_z > total_length)
134 paramError(
"spacer_z",
"Spacer locations must be between zero and total bundle length");
137 paramError(
"z_blockage",
"Size of vector z_blockage must be 2");
140 paramError(
"z_blockage",
"z_blockage inlet location must not exceed outlet location");
144 paramError(
"index_blockage",
"Blocked subchannel index exceeds valid subchannel range");
148 paramError(
"reduction_blockage",
"Area reduction of blocked subchannels cannot exceed 1");
152 mooseError(
"Sizes of blockage-related vectors cannot exceed total number of subchannels");
157 mooseError(
"index_blockage, reduction_blockage, and k_blockage must have equal size");
172 std::vector<int> spacer_cell;
174 spacer_cell.emplace_back(std::round(elem *
_n_cells / L));
177 std::vector<Real> kgrid(
_n_cells + 1, 0.0);
181 for (
unsigned int index = 0; index < spacer_cell.size(); index++)
182 kgrid[spacer_cell[index]] +=
_spacer_k[index];
190 for (
unsigned int i = 0; i <
_n_cells + 1; i++)
193 unsigned int index = 0;
215 for (
unsigned int j = 0;
j < 3;
j++)
219 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
223 const Real positive_flow = 1.0;
224 const Real negative_flow = -1.0;
228 for (
unsigned int iy = 0; iy <
_ny; iy++)
229 for (
unsigned int ix = 0; ix <
_nx; ix++)
231 const unsigned int i_ch =
_nx * iy + ix;
232 const bool is_corner = (ix == 0 && iy == 0) || (ix ==
_nx - 1 && iy == 0) ||
233 (ix == 0 && iy ==
_ny - 1) || (ix ==
_nx - 1 && iy ==
_ny - 1);
234 const bool is_edge = (ix == 0 || iy == 0 || ix ==
_nx - 1 || iy ==
_ny - 1);
251 unsigned int i_gap = 0;
252 for (
unsigned int iy = 0; iy <
_ny; iy++)
253 for (
unsigned int ix = 0; ix <
_nx - 1; ix++)
255 const unsigned int i_ch =
_nx * iy + ix;
256 const unsigned int j_ch =
_nx * iy + (ix + 1);
264 if (iy == 0 || iy ==
_ny - 1)
273 for (
unsigned int iy = 0; iy <
_ny - 1; iy++)
274 for (
unsigned int ix = 0; ix <
_nx; ix++)
276 const unsigned int i_ch =
_nx * iy + ix;
277 const unsigned int j_ch =
_nx * (iy + 1) + ix;
285 if (ix == 0 || ix ==
_nx - 1)
293 for (
unsigned int iz = 1; iz <
_n_cells + 1; iz++)
297 for (
unsigned int iy = 0; iy <
_ny - 1; iy++)
298 for (
unsigned int ix = 0; ix <
_nx - 1; ix++)
300 const unsigned int i_pin = (
_nx - 1) * iy + ix;
301 const unsigned int i_chan_1 =
_nx * iy + ix;
302 const unsigned int i_chan_2 =
_nx * (iy + 1) + ix;
303 const unsigned int i_chan_3 =
_nx * (iy + 1) + (ix + 1);
304 const unsigned int i_chan_4 =
_nx * iy + (ix + 1);
313 for (
unsigned int iy = 0; iy <
_ny; iy++)
314 for (
unsigned int ix = 0; ix <
_nx; ix++)
316 const unsigned int i_ch =
_nx * iy + ix;
326 for (
unsigned int iy = 0; iy <
_ny; iy++)
327 for (
unsigned int ix = 0; ix <
_nx; ix++)
329 const unsigned int i_ch =
_nx * iy + ix;
332 if (iy == 0 && ix == 0)
334 else if (iy ==
_ny - 1 && ix == 0)
336 else if (iy == 0 && ix ==
_nx - 1)
338 else if (iy ==
_ny - 1 && ix ==
_nx - 1)
346 else if (iy ==
_ny - 1)
356 else if (ix ==
_nx - 1)
372 for (
unsigned int ig = 0; ig <
_n_gaps; ig++)
382 for (
unsigned int i : i_pins)
383 for (
unsigned int j : j_pins)
412 BoundaryInfo & boundary_info)
414 mesh_base.reserve_elem(mesh_base.n_elem() +
_n_cells *
_ny *
_nx);
415 mesh_base.reserve_nodes(mesh_base.n_nodes() + (
_n_cells + 1) *
_ny *
_nx);
426 for (
unsigned int iy = 0; iy <
_ny; iy++)
427 for (
unsigned int ix = 0; ix <
_nx; ix++)
429 const unsigned int i_ch =
_nx * iy + ix;
432 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
433 _nodes[i_ch].push_back(mesh_base.add_point(
440 for (
unsigned int iy = 0; iy <
_ny; iy++)
441 for (
unsigned int ix = 0; ix <
_nx; ix++)
442 for (
unsigned int iz = 0; iz <
_n_cells; iz++)
444 Elem * elem = mesh_base.add_elem(std::make_unique<Edge2>());
446 elem->set_id(elem_id++);
448 const unsigned int i_ch =
_nx * iy + ix;
449 elem->set_node(0,
_nodes[i_ch][iz]);
450 elem->set_node(1,
_nodes[i_ch][iz + 1]);
453 boundary_info.add_side(elem, 0, 0);
455 boundary_info.add_side(elem, 1, 1);
464 mesh_base.reserve_elem(mesh_base.n_elem() +
_n_cells * (
_ny - 1) * (
_nx - 1));
465 mesh_base.reserve_nodes(mesh_base.n_nodes() + (
_n_cells + 1) * (
_ny - 1) * (
_nx - 1));
476 for (
unsigned int iy = 0; iy <
_ny - 1; iy++)
477 for (
unsigned int ix = 0; ix <
_nx - 1; ix++)
479 const unsigned int i_pin = (
_nx - 1) * iy + ix;
482 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
483 _pin_nodes[i_pin].push_back(mesh_base.add_point(
489 for (
unsigned int iy = 0; iy <
_ny - 1; iy++)
490 for (
unsigned int ix = 0; ix <
_nx - 1; ix++)
491 for (
unsigned int iz = 0; iz <
_n_cells; iz++)
493 Elem * elem = mesh_base.add_elem(std::make_unique<Edge2>());
495 elem->set_id(elem_id++);
497 const unsigned int i_pin = (
_nx - 1) * iy + ix;
548 std::unique_ptr<MeshBase>
552 BoundaryInfo & boundary_info = mesh_base->get_boundary_info();
554 mesh_base->set_spatial_dimension(3);
561 boundary_info.sideset_name(0) =
"inlet";
562 boundary_info.sideset_name(1) =
"outlet";
563 boundary_info.nodeset_name(0) =
"inlet";
564 boundary_info.nodeset_name(1) =
"outlet";
566 mesh_base->prepare_for_use();
570 sch_mesh.computeAssemblyHydraulicParameters();
std::vector< std::vector< unsigned int > > _chan_to_pin_map
stores the fuel pins belonging to each subchannel
std::vector< std::vector< unsigned int > > _chan_to_gap_map
map relating subchannel index to gap index
Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_pin_map
map relating gap index to fuel pin index
std::vector< std::vector< Node * > > _nodes
channel nodes
Real _heated_length
heated length of the fuel Pin
std::vector< Real > _z_grid
axial location of nodes
Real _pin_diameter
fuel Pin diameter
Real _kij
lateral form loss coefficient
void buildPinMesh(MeshBase &mesh_base)
Build the 1D pin elements for assemblies with pins.
std::vector< std::vector< Real > > _k_grid
axial form loss coefficient per computational cell
void paramError(const std::string ¶m, Args... args) const
unsigned int _n_gaps
Number of gaps per layer.
std::vector< std::vector< Node * > > _pin_nodes
pin nodes
unsigned int _n_pins
number of pins
std::vector< EChannelType > _subch_type
Subchannel type.
Real _unheated_length_exit
unheated length of the fuel Pin at the exit of the assembly
std::vector< std::vector< unsigned int > > _pin_to_chan_map
map relating fuel pin index to subchannel index
std::vector< std::vector< unsigned int > > _pin_to_chan_map
stores the map from pins to channels
std::vector< std::vector< Real > > _k_grid
axial form loss coefficient per computational cell
Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
registerMooseObject("SubChannelApp", SCMQuadAssemblyMeshGenerator)
std::vector< std::vector< unsigned int > > _chan_to_pin_map
map relating subchannel index to fuel pin index
unsigned int _ny
number of subchannels in the y direction
std::vector< std::vector< Real > > _gij_map
gap size
unsigned int _ny
number of subchannels in the y direction
Creates the mesh of subchannels in a quadrilateral lattice.
std::vector< std::vector< Real > > _subchannel_position
x,y coordinates of the subchannel centroids
static InputParameters validParams()
SCMQuadAssemblyMeshGenerator(const InputParameters ¶ms)
unsigned int _n_pins
Number of pins.
void transferMetadata(QuadSubChannelMesh &sch_mesh)
Move generated mesh metadata into the concrete QuadSubChannelMesh object.
unsigned int _nx
number of subchannels in the x direction
Real _side_gap
The side gap, not to be confused with the gap between pins, this refers to the gap next to the duct o...
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_chan_map
map relating gap index to subchannel index
static void generateZGrid(Real unheated_length_entry, Real heated_length, Real unheated_length_exit, unsigned int n_cells, std::vector< Real > &z_grid)
Generate the spacing in z-direction using heated and unteaded lengths.
std::vector< unsigned int > _index_blockage
index of subchannels affected by blockage
std::vector< Real > _spacer_k
form loss coefficient of the spacers
std::vector< Real > _spacer_k
form loss coefficient of the spacers
unsigned int _n_channels
total number of subchannels
unsigned int _subchannel_block_id
subchannel block index
std::vector< Real > _spacer_z
axial location of the spacers
Real _unheated_length_exit
unheated length of the fuel Pin at the exit of the assembly
void buildSubchannelMesh(MeshBase &mesh_base, BoundaryInfo &boundary_info)
Build the 1D subchannel elements and inlet/outlet boundaries.
std::vector< Real > _z_blockage
axial location of blockage (inlet, outlet) [m]
Real _pin_diameter
fuel Pin diameter
void initializeChannelData()
Build subchannel, gap, pin, and cross-flow maps used by QuadSubChannelMesh.
std::vector< Real > _k_blockage
form loss coefficient of subchannels affected by blockage
std::vector< Real > _reduction_blockage
area reduction of subchannels affected by blockage
static InputParameters validParams()
std::vector< Real > _z_grid
axial location of nodes
Real _pitch
Distance between the neighbor fuel pins, pitch.
std::vector< Real > _spacer_z
axial location of the spacers
virtual std::unique_ptr< MeshBase > generate() override
std::vector< std::vector< double > > _sign_id_crossflow_map
Matrix used to give local sign to crossflow quantities.
unsigned int _n_channels
number of subchannels in total
std::vector< std::vector< Real > > _sign_id_crossflow_map
matrix used to give local sign to crossflow quantities
unsigned int _n_gaps
number of gaps per layer
std::vector< std::vector< Node * > > _gapnodes
gap nodes
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_pin_map
stores the fuel pin pairs for each gap
std::vector< std::vector< Real > > _gij_map
Vector to store gap size.
Mesh generator that builds a mesh of 1D lines representing subchannels and pins in a quadrilateral as...
Real _pitch
distance between neighbor fuel pins, pitch
Real _side_gap
The side gap, not to be confused with the gap between pins, this refers to the gap next to the duct o...
std::vector< std::vector< Node * > > _nodes
vector of subchannel nodes
std::vector< std::vector< Node * > > _pin_nodes
vector of fuel pin nodes
void mooseError(Args &&... args) const
std::vector< std::vector< Real > > _subchannel_position
x,y coordinates of the subchannel centroids
registerMooseObjectRenamed("SubChannelApp", SCMQuadSubChannelMeshGenerator, "06/30/2027 24:00", SCMQuadAssemblyMeshGenerator)
std::vector< Real > _reduction_blockage
area reduction of subchannels affected by blockage
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< std::vector< Node * > > _gapnodes
vector of gap (interface between pairs of neighboring subchannels) nodes
unsigned int _nx
number of subchannels in the x direction
Real _kij
Lateral form loss coefficient.
unsigned int _n_cells
number of axial cells
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_chan_map
stores the channel pairs for each gap
unsigned int _pin_block_id
pin block index
unsigned int _n_cells
number of axial cells
std::vector< Real > _z_blockage
axial location of blockage (inlet, outlet) [m]
void ErrorVector unsigned int
Real _heated_length
heated length of the fuel Pin
std::vector< EChannelType > _subch_type
subchannel type
std::vector< unsigned int > _index_blockage
index of subchannels affected by blockage
std::vector< std::vector< unsigned int > > _chan_to_gap_map
stores the gaps that form each subchannel