12 #include "libmesh/edge_edge2.h" 17 QuadSubChannelMeshGenerator,
25 params.
addClassDescription(
"Creates a mesh of 1D subchannels in a square lattice arrangement");
28 params.
addParam<
Real>(
"unheated_length_entry", 0.0,
"Unheated length at entry [m]");
30 params.
addParam<
Real>(
"unheated_length_exit", 0.0,
"Unheated length at exit [m]");
31 params.
addParam<std::vector<Real>>(
"spacer_z",
32 "Axial location of spacers/vanes/mixing_vanes [m]");
33 params.
addParam<std::vector<Real>>(
"spacer_k",
34 "K-loss coefficient of spacers/vanes/mixing_vanes [-]");
35 params.
addParam<std::vector<Real>>(
"z_blockage",
36 std::vector<Real>({0.0, 0.0}),
37 "axial location of blockage (inlet, outlet) [m]");
38 params.
addParam<std::vector<unsigned int>>(
"index_blockage",
39 std::vector<unsigned int>({0}),
40 "index of subchannels affected by blockage");
43 std::vector<Real>({1.0}),
44 "Area reduction of subchannels affected by blockage (number to muliply the area)");
45 params.
addParam<std::vector<Real>>(
"k_blockage",
46 std::vector<Real>({0.0}),
47 "Form loss coefficient of subchannels affected by blockage");
49 params.
addParam<
Real>(
"Kij", 0.5,
"Lateral form loss coefficient [-]");
50 params.
addRequiredParam<
unsigned int>(
"n_cells",
"The number of cells in the axial direction");
51 params.
addRequiredParam<
unsigned int>(
"nx",
"Number of channels in the x direction [-]");
52 params.
addRequiredParam<
unsigned int>(
"ny",
"Number of channels in the y direction [-]");
54 "(Its an added distance between a perimetric pin and the duct: " 55 "Edge Pitch W = (pitch/2 - pin_diameter/2 + gap) [m]");
56 params.
addParam<
unsigned int>(
"block_id", 0,
"Domain Index");
62 _unheated_length_entry(getParam<
Real>(
"unheated_length_entry")),
63 _heated_length(getParam<
Real>(
"heated_length")),
64 _unheated_length_exit(getParam<
Real>(
"unheated_length_exit")),
65 _spacer_z(getParam<
std::vector<
Real>>(
"spacer_z")),
66 _spacer_k(getParam<
std::vector<
Real>>(
"spacer_k")),
67 _z_blockage(getParam<
std::vector<
Real>>(
"z_blockage")),
68 _index_blockage(getParam<
std::vector<unsigned
int>>(
"index_blockage")),
69 _reduction_blockage(getParam<
std::vector<
Real>>(
"reduction_blockage")),
70 _k_blockage(getParam<
std::vector<
Real>>(
"k_blockage")),
71 _kij(getParam<
Real>(
"Kij")),
72 _pitch(getParam<
Real>(
"pitch")),
73 _pin_diameter(getParam<
Real>(
"pin_diameter")),
74 _n_cells(getParam<unsigned
int>(
"n_cells")),
75 _nx(getParam<unsigned
int>(
"nx")),
76 _ny(getParam<unsigned
int>(
"ny")),
77 _n_channels(_nx * _ny),
78 _n_gaps((_nx - 1) * _ny + (_ny - 1) * _nx),
79 _n_pins((_nx - 1) * (_ny - 1)),
80 _gap(getParam<
Real>(
"gap")),
81 _block_id(getParam<unsigned
int>(
"block_id"))
84 mooseError(
name(),
": Size of vector spacer_z should be equal to size of vector spacer_k");
87 mooseError(
name(),
": Location of spacers should be less than the total bundle length");
94 ": The index of the blocked subchannel cannot be more than the max index of the " 98 mooseError(
name(),
": The area reduction of the blocked subchannels cannot be more than 1");
103 ": Size of vectors: index_blockage, reduction_blockage, k_blockage, cannot be more " 104 "than the total number of subchannels");
110 ": Size of vectors: index_blockage, reduction_blockage, k_blockage, must be equal " 115 ": The number of subchannels cannot be less than 2 in both directions (x and y). " 116 "Smallest assembly allowed is either 2X1 or 1X2. ");
125 std::vector<int> spacer_cell;
127 spacer_cell.emplace_back(std::round(elem *
_n_cells / L));
130 std::vector<Real> kgrid;
135 for (
unsigned int index = 0; index < spacer_cell.size(); index++)
136 kgrid[spacer_cell[index]] +=
_spacer_k[index];
144 for (
unsigned int i = 0; i <
_n_cells + 1; i++)
148 unsigned int index(0);
171 for (
unsigned int j = 0;
j < 3;
j++)
177 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
183 Real positive_flow = 1.0;
184 Real negative_flow = -1.0;
188 for (
unsigned int iy = 0; iy <
_ny; iy++)
190 for (
unsigned int ix = 0; ix <
_nx; ix++)
192 unsigned int i_ch =
_nx * iy + ix;
193 bool is_corner = (ix == 0 && iy == 0) || (ix ==
_nx - 1 && iy == 0) ||
194 (ix == 0 && iy ==
_ny - 1) || (ix ==
_nx - 1 && iy ==
_ny - 1);
195 bool is_edge = (ix == 0 || iy == 0 || ix ==
_nx - 1 || iy ==
_ny - 1);
218 unsigned int i_gap = 0;
219 for (
unsigned int iy = 0; iy <
_ny; iy++)
221 for (
unsigned int ix = 0; ix <
_nx - 1; ix++)
223 unsigned int i_ch =
_nx * iy + ix;
224 unsigned int j_ch =
_nx * iy + (ix + 1);
232 if (iy == 0 || iy ==
_ny - 1)
241 for (
unsigned int iy = 0; iy <
_ny - 1; iy++)
243 for (
unsigned int ix = 0; ix <
_nx; ix++)
245 unsigned int i_ch =
_nx * iy + ix;
246 unsigned int j_ch =
_nx * (iy + 1) + ix;
254 if (ix == 0 || ix ==
_nx - 1)
262 for (
unsigned int iz = 1; iz <
_n_cells + 1; iz++)
268 for (
unsigned int iy = 0; iy <
_ny - 1; iy++)
270 for (
unsigned int ix = 0; ix <
_nx - 1; ix++)
272 unsigned int i_pin = (
_nx - 1) * iy + ix;
273 unsigned int i_chan_1 =
_nx * iy + ix;
274 unsigned int i_chan_2 =
_nx * (iy + 1) + ix;
275 unsigned int i_chan_3 =
_nx * (iy + 1) + (ix + 1);
276 unsigned int i_chan_4 =
_nx * iy + (ix + 1);
285 for (
unsigned int iy = 0; iy <
_ny; iy++)
287 for (
unsigned int ix = 0; ix <
_nx; ix++)
289 unsigned int i_ch =
_nx * iy + ix;
291 if (iy == 0 && ix == 0)
295 else if (iy ==
_ny - 1 && ix == 0)
299 else if (iy == 0 && ix ==
_nx - 1)
303 else if (iy ==
_ny - 1 && ix ==
_nx - 1)
313 else if (iy ==
_ny - 1)
323 else if (ix ==
_nx - 1)
346 for (
unsigned int i_gap = 0; i_gap <
_n_gaps; i_gap++)
354 for (
unsigned int i : i_pins)
356 for (
unsigned int j : j_pins)
387 std::unique_ptr<MeshBase>
391 BoundaryInfo & boundary_info = mesh_base->get_boundary_info();
392 mesh_base->set_spatial_dimension(3);
402 unsigned int node_id = 0;
403 for (
unsigned int iy = 0; iy <
_ny; iy++)
405 for (
unsigned int ix = 0; ix <
_nx; ix++)
407 int i_ch =
_nx * iy + ix;
409 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
411 _nodes[i_ch].push_back(mesh_base->add_point(
419 unsigned int elem_id = 0;
420 for (
unsigned int iy = 0; iy <
_ny; iy++)
422 for (
unsigned int ix = 0; ix <
_nx; ix++)
424 for (
unsigned int iz = 0; iz <
_n_cells; iz++)
426 Elem * elem =
new Edge2;
428 elem->set_id(elem_id++);
429 elem = mesh_base->add_elem(elem);
432 elem->set_node(0, mesh_base->node_ptr(indx1));
433 elem->set_node(1, mesh_base->node_ptr(indx2));
436 boundary_info.add_side(elem, 0, 0);
438 boundary_info.add_side(elem, 1, 1);
443 boundary_info.sideset_name(0) =
"inlet";
444 boundary_info.sideset_name(1) =
"outlet";
445 boundary_info.nodeset_name(0) =
"inlet";
446 boundary_info.nodeset_name(1) =
"outlet";
448 mesh_base->prepare_for_use();
462 sch_mesh._kij =
_kij;
471 sch_mesh._gap =
_gap;
const unsigned int _n_gaps
Number of gaps per layer.
Class for Subchannel mesh generation in the square lattice geometry.
const std::vector< Real > & _spacer_k
form loss coefficient of the spacers
const Real _pitch
Distance between the neighbor fuel pins, pitch.
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_chan_map
const std::vector< unsigned int > _index_blockage
index of subchannels affected by blockage
const Real _gap
The gap, not to be confused with the gap between pins, this refers to the gap next to the duct...
const std::vector< Real > _z_blockage
axial location of blockage (inlet, outlet) [m]
Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
std::vector< std::vector< unsigned int > > _chan_to_pin_map
static InputParameters validParams()
Creates the mesh of subchannels in a quadrilateral lattice.
const unsigned int _n_cells
number of axial cells
const unsigned int _ny
Number of subchannels in the y direction.
virtual const std::string & name() const
std::vector< std::vector< Real > > _subchannel_position
x,y coordinates of the subchannel centroid
const unsigned int _n_channels
Total number of subchannels.
const Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
registerMooseObject("SubChannelApp", SCMQuadSubChannelMeshGenerator)
const std::vector< Real > _k_blockage
form loss coefficient of subchannels affected by blockage
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.
registerMooseObjectRenamed("SubChannelApp", QuadSubChannelMeshGenerator, "06/30/2025 24:00", SCMQuadSubChannelMeshGenerator)
std::vector< std::vector< Node * > > _nodes
Channel nodes.
const unsigned int _nx
Number of subchannels in the x direction.
const std::vector< Real > _reduction_blockage
area reduction of subchannels affected by blockage
static InputParameters validParams()
std::vector< EChannelType > _subch_type
Subchannel type.
std::unique_ptr< MeshBase > generate() override
std::vector< std::vector< Real > > _gij_map
Vector to store gap size.
SCMQuadSubChannelMeshGenerator(const InputParameters ¶meters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::vector< Node * > > _gapnodes
gap nodes
const Real _pin_diameter
fuel Pin diameter
std::vector< std::vector< unsigned int > > _chan_to_gap_map
const Real _unheated_length_exit
unheated length of the fuel Pin at the exit of the assembly
const std::vector< Real > & _spacer_z
axial location of the spacers
std::vector< std::vector< unsigned int > > _pin_to_chan_map
void mooseError(Args &&... args) const
std::vector< std::vector< double > > _sign_id_crossflow_map
Matrix used to give local sign to crossflow quantities.
const unsigned int _block_id
block index
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const Real & _kij
Lateral form loss coefficient.
std::vector< std::vector< Real > > _k_grid
axial form loss coefficient per computational cell
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_pin_map
const Real _heated_length
heated length of the fuel Pin
std::vector< Real > _z_grid
axial location of nodes
void ErrorVector unsigned int
const unsigned int _n_pins
Number of pins.