https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SCMQuadVisualizationAssemblyMeshGenerator.C
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
11#include "QuadSubChannelMesh.h"
12
13#include "libmesh/cell_prism6.h"
14#include "libmesh/unstructured_mesh.h"
15
16#include <array>
17#include <cmath>
18#include <memory>
19
22 SCMDetailedQuadAssemblyMeshGenerator,
23 "06/30/2027 24:00",
26 SCMDetailedQuadSubChannelMeshGenerator,
27 "06/30/2027 24:00",
30 DetailedQuadSubChannelMeshGenerator,
31 "06/30/2027 24:00",
34 SCMDetailedQuadPinMeshGenerator,
35 "06/30/2027 24:00",
38 DetailedQuadPinMeshGenerator,
39 "06/30/2027 24:00",
41
44{
47 "Creates a 3D visualization mesh of subchannels and fuel pins in a square lattice "
48 "arrangement");
49 params.addRequiredParam<Real>("pitch", "Pitch [m]");
50 params.addRequiredParam<Real>("pin_diameter", "Rod diameter [m]");
51 params.addParam<Real>("unheated_length_entry", 0.0, "Unheated length at entry [m]");
52 params.addRequiredParam<Real>("heated_length", "Heated length [m]");
53 params.addParam<Real>("unheated_length_exit", 0.0, "Unheated length at exit [m]");
54 params.addRequiredParam<unsigned int>("n_cells", "The number of cells in the axial direction");
55 params.addRequiredParam<unsigned int>("nx", "Number of channels in the x direction [-]");
56 params.addRequiredParam<unsigned int>("ny", "Number of channels in the y direction [-]");
57 params.addRequiredParam<Real>(
58 "side_gap",
59 "The side gap, not to be confused with the gap between pins, this refers to the gap "
60 "next to the duct or else the distance between the subchannel centroid to the duct wall."
61 "distance(edge pin center, duct wall) = pitch / 2 + side_gap [m]");
62 params.addRangeCheckedParam<unsigned int>("num_sectors",
63 16,
64 "num_sectors>=4",
65 "Number of azimuthal sectors used to discretize each "
66 "circular pin cross section.");
67 params.addParam<unsigned int>("subchannel_block_id", 0, "Subchannel block id.");
68 params.addParam<unsigned int>("pin_block_id", 1, "Fuel pin block id.");
69 return params;
70}
71
73 const InputParameters & parameters)
74 : MeshGenerator(parameters),
75 _unheated_length_entry(getParam<Real>("unheated_length_entry")),
76 _heated_length(getParam<Real>("heated_length")),
77 _unheated_length_exit(getParam<Real>("unheated_length_exit")),
78 _pitch(getParam<Real>("pitch")),
79 _pin_diameter(getParam<Real>("pin_diameter")),
80 _n_cells(getParam<unsigned int>("n_cells")),
81 _nx(getParam<unsigned int>("nx")),
82 _ny(getParam<unsigned int>("ny")),
83 _n_channels(0),
84 _side_gap(getParam<Real>("side_gap")),
85 _num_sectors(getParam<unsigned int>("num_sectors")),
86 _subchannel_block_id(getParam<unsigned int>("subchannel_block_id")),
87 _pin_block_id(getParam<unsigned int>("pin_block_id")),
88 _elem_id(0)
89{
91
92 if (_n_cells == 0)
93 paramError("n_cells", "The number of axial cells must be greater than zero");
94
95 if (L <= 0.0)
96 mooseError("Total bundle length must be greater than zero");
97
98 if (_nx == 0 || _ny == 0)
99 mooseError("The number of subchannels must be greater than zero in each direction");
100
101 if (_nx < 2 && _ny < 2)
102 mooseError("The number of subchannels cannot be less than 2 in both directions. "
103 "Smallest assembly allowed is either 2X1 or 1X2.");
104
105 _n_channels = _nx * _ny;
106
107 // Outer duct size, read by SCMQuadCoreMeshGenerator to check that assemblies placed in a core
108 // do not overlap. The duct wall is pitch / 2 + side_gap from the outer subchannel centroids.
109 declareMeshProperty<Real>("duct_size_x", (_nx - 1) * _pitch + 2.0 * _side_gap);
110 declareMeshProperty<Real>("duct_size_y", (_ny - 1) * _pitch + 2.0 * _side_gap);
111
112 const Real dz = L / _n_cells;
113 for (unsigned int i = 0; i < _n_cells + 1; i++)
114 _z_grid.push_back(dz * i);
115
117 for (unsigned int i = 0; i < _n_channels; i++)
118 {
119 _subchannel_position[i].reserve(3);
120 for (unsigned int j = 0; j < 3; j++)
121 _subchannel_position.at(i).push_back(0.0);
122 }
123
124 _subch_type.resize(_n_channels);
125 for (unsigned int iy = 0; iy < _ny; iy++)
126 for (unsigned int ix = 0; ix < _nx; ix++)
127 {
128 const unsigned int i_ch = _nx * iy + ix;
129 const bool is_corner = (ix == 0 && iy == 0) || (ix == _nx - 1 && iy == 0) ||
130 (ix == 0 && iy == _ny - 1) || (ix == _nx - 1 && iy == _ny - 1);
131 const bool is_edge = (ix == 0 || iy == 0 || ix == _nx - 1 || iy == _ny - 1);
132
133 if (is_corner)
135 else if (is_edge)
137 else
139
140 // Set the subchannel positions so that the center of the assembly is the zero point.
141 const Real offset_x = (_nx - 1) * _pitch / 2.0;
142 const Real offset_y = (_ny - 1) * _pitch / 2.0;
143 _subchannel_position[i_ch][0] = _pitch * ix - offset_x;
144 _subchannel_position[i_ch][1] = _pitch * iy - offset_y;
145 }
146}
147
148void
149SCMQuadVisualizationAssemblyMeshGenerator::generatePin(std::unique_ptr<MeshBase> & mesh_base,
150 const Point & center)
151{
152 const Real dalpha = 360. / _num_sectors;
153 const Real radius = _pin_diameter / 2.;
154
155 // Add a center node and radial boundary nodes on each axial level so each pin is discretized into
156 // triangular prism sectors.
157 std::vector<std::vector<Node *>> nodes;
158 nodes.resize(_n_cells + 1);
159 for (unsigned int k = 0; k < _n_cells + 1; k++)
160 {
161 const Real elev = _z_grid[k];
162 nodes[k].push_back(mesh_base->add_point(Point(center(0), center(1), elev)));
163 Real alpha = 0.;
164 for (unsigned int i = 0; i < _num_sectors; i++, alpha += dalpha)
165 {
166 const Real dx = radius * std::cos(alpha * M_PI / 180.);
167 const Real dy = radius * std::sin(alpha * M_PI / 180.);
168 nodes[k].push_back(mesh_base->add_point(Point(center(0) + dx, center(1) + dy, elev)));
169 }
170 }
171
172 // Add the pin volume elements, linking matching radial sectors between adjacent axial levels.
173 for (unsigned int k = 0; k < _n_cells; k++)
174 for (unsigned int i = 0; i < _num_sectors; i++)
175 {
176 Elem * elem = mesh_base->add_elem(std::make_unique<Prism6>());
177 elem->subdomain_id() = _pin_block_id;
178 elem->set_id(_elem_id++);
179 const unsigned int ctr_idx = 0;
180 const unsigned int idx1 = (i % _num_sectors) + 1;
181 const unsigned int idx2 = ((i + 1) % _num_sectors) + 1;
182 elem->set_node(0, nodes[k][ctr_idx]);
183 elem->set_node(1, nodes[k][idx1]);
184 elem->set_node(2, nodes[k][idx2]);
185 elem->set_node(3, nodes[k + 1][ctr_idx]);
186 elem->set_node(4, nodes[k + 1][idx1]);
187 elem->set_node(5, nodes[k + 1][idx2]);
188 }
189}
190
191std::unique_ptr<MeshBase>
193{
194 auto mesh_base = buildMeshBaseObject();
195 BoundaryInfo & boundary_info = mesh_base->get_boundary_info();
196 mesh_base->set_spatial_dimension(3);
197
198 // Define the resolution (the number of points used to represent a circle). This must be
199 // divisible by 4.
200 const unsigned int n_pins = (_nx - 1) * (_ny - 1);
201
202 const unsigned int theta_res = 16;
203 // Compute the number of points needed to represent one quarter of a circle.
204 const unsigned int points_per_quad = theta_res / 4 + 1;
205
206 // Compute the points needed to represent one axial cross-flow of a subchannel. For the center
207 // subchannel there is one center point plus the points from 4 intersecting circles. For the
208 // corner subchannel there is one center point plus the points from 1 intersecting circle plus 3
209 // corners. For the side subchannel there is one center point plus the points from 2 intersecting
210 // circles plus 2 corners.
211 const unsigned int points_per_center = points_per_quad * 4 + 1;
212 const unsigned int points_per_corner = points_per_quad * 1 + 1 + 3;
213 const unsigned int points_per_side = points_per_quad * 2 + 1 + 2;
214
215 // Compute the number of Prism6 elements which combine to create each subchannel cross-section.
216 const unsigned int elems_per_center = theta_res + 4;
217 const unsigned int elems_per_corner = theta_res / 4 + 4;
218 const unsigned int elems_per_side = theta_res / 2 + 4;
219
220 // Specify the number and type of subchannels.
221 unsigned int n_center, n_side, n_corner;
222 if (_n_channels == 2)
223 {
224 n_corner = 0;
225 n_side = _n_channels;
226 n_center = _n_channels - n_side - n_corner;
227 }
228 else if (_n_channels > 2 && (_ny == 1 || _nx == 1))
229 {
230 n_corner = 0;
231 n_side = 2;
232 n_center = _n_channels - n_side - n_corner;
233 }
234 else
235 {
236 n_corner = 4;
237 n_side = 2 * (_ny - 2) + 2 * (_nx - 2);
238 n_center = _n_channels - n_side - n_corner;
239 }
240
241 const unsigned int points_per_level =
242 n_corner * points_per_corner + n_side * points_per_side + n_center * points_per_center;
243 const unsigned int elems_per_level =
244 n_corner * elems_per_corner + n_side * elems_per_side + n_center * elems_per_center;
245
246 // Pin centers are generated for 2x2 and larger quad assemblies.
247 std::vector<Point> pin_centers;
248 if (n_pins > 0)
250
251 const unsigned int pin_points =
252 n_pins > 0 ? (_n_cells + 1) * (_num_sectors + 1) * pin_centers.size() : 0;
253 const unsigned int pin_elems = n_pins > 0 ? _n_cells * _num_sectors * pin_centers.size() : 0;
254
255 mesh_base->reserve_nodes(points_per_level * (_n_cells + 1) + pin_points);
256 mesh_base->reserve_elem(elems_per_level * _n_cells + pin_elems);
257
258 // Build an array of points arranged in a circle on the xy-plane. The last and first node overlap.
259 const Real radius = _pin_diameter / 2.0;
260 std::array<Point, theta_res + 1> circle_points;
261 {
262 Real theta = 0;
263 for (unsigned int i = 0; i < theta_res + 1; i++)
264 {
265 circle_points[i](0) = radius * std::cos(theta);
266 circle_points[i](1) = radius * std::sin(theta);
267 theta += 2 * M_PI / theta_res;
268 }
269 }
270
271 // Define "quadrant center" reference points. These will be the centers of the 4 circles that
272 // represent the fuel pins. These centers are offset slightly so that in the final mesh, there is
273 // a tiny gap between neighboring subchannel cells. That allows us to easily map a solution to
274 // this detailed mesh with a nearest-neighbor search.
275 const Real shrink_factor = 0.99999;
276 std::array<Point, 4> quadrant_centers;
277 quadrant_centers[0] = Point(_pitch * 0.5 * shrink_factor, _pitch * 0.5 * shrink_factor, 0);
278 quadrant_centers[1] = Point(-_pitch * 0.5 * shrink_factor, _pitch * 0.5 * shrink_factor, 0);
279 quadrant_centers[2] = Point(-_pitch * 0.5 * shrink_factor, -_pitch * 0.5 * shrink_factor, 0);
280 quadrant_centers[3] = Point(_pitch * 0.5 * shrink_factor, -_pitch * 0.5 * shrink_factor, 0);
281
282 const unsigned int m = theta_res / 4;
283 // Build an array of points that represent a cross-section of a center subchannel cell. The points
284 // are ordered in this fashion:
285 // 4 3
286 // 6 5 2 1
287 // 0
288 // 7 8 * *
289 // 9 *
290 std::array<Point, points_per_center> center_points;
291 {
292 unsigned int start;
293 for (unsigned int i = 0; i < 4; i++)
294 {
295 if (i == 0)
296 start = 3 * m;
297 if (i == 1)
298 start = 4 * m;
299 if (i == 2)
300 start = 1 * m;
301 if (i == 3)
302 start = 2 * m;
303 for (unsigned int ii = 0; ii < points_per_quad; ii++)
304 {
305 auto c_pt = circle_points[start - ii];
306 center_points[i * points_per_quad + ii + 1] = quadrant_centers[i] + c_pt;
307 }
308 }
309 }
310
311 // Build an array of points that represent a cross-section of a top left corner subchannel cell.
312 // The points are ordered in this fashion:
313 // 5 4
314 //
315 // 0
316 // 2 3
317 // 6 1
318 std::array<Point, points_per_corner> tl_corner_points;
319 {
320 for (unsigned int ii = 0; ii < points_per_quad; ii++)
321 {
322 auto c_pt = circle_points[2 * m - ii];
323 tl_corner_points[ii + 1] = quadrant_centers[3] + c_pt;
324 }
325 tl_corner_points[points_per_quad + 1] = Point(_pitch * 0.5 * shrink_factor, _side_gap, 0);
326 tl_corner_points[points_per_quad + 2] = Point(-_side_gap, _side_gap, 0);
327 tl_corner_points[points_per_quad + 3] = Point(-_side_gap, -_pitch * 0.5 * shrink_factor, 0);
328 }
329
330 // Build an array of points that represent a cross-section of a top right corner subchannel cell.
331 // The points are ordered in this fashion:
332 // 6 5
333 //
334 // 0
335 // 1 2
336 // 3 4
337 std::array<Point, points_per_corner> tr_corner_points;
338 {
339 for (unsigned int ii = 0; ii < points_per_quad; ii++)
340 {
341 auto c_pt = circle_points[m - ii];
342 tr_corner_points[ii + 1] = quadrant_centers[2] + c_pt;
343 }
344 tr_corner_points[points_per_quad + 1] = Point(_side_gap, -_pitch * 0.5 * shrink_factor, 0);
345 tr_corner_points[points_per_quad + 2] = Point(_side_gap, _side_gap, 0);
346 tr_corner_points[points_per_quad + 3] = Point(-_pitch * 0.5 * shrink_factor, _side_gap, 0);
347 }
348
349 // Build an array of points that represent a cross-section of a bottom left corner subchannel
350 // cell. The points are ordered in this fashion:
351 // 4 3
352 // 2 1
353 // 0
354 //
355 // 5 6
356 std::array<Point, points_per_corner> bl_corner_points;
357 {
358 for (unsigned int ii = 0; ii < points_per_quad; ii++)
359 {
360 auto c_pt = circle_points[3 * m - ii];
361 bl_corner_points[ii + 1] = quadrant_centers[0] + c_pt;
362 }
363 bl_corner_points[points_per_quad + 1] = Point(-_side_gap, _pitch * 0.5 * shrink_factor, 0);
364 bl_corner_points[points_per_quad + 2] = Point(-_side_gap, -_side_gap, 0);
365 bl_corner_points[points_per_quad + 3] = Point(_pitch * 0.5 * shrink_factor, -_side_gap, 0);
366 }
367
368 // Build an array of points that represent a cross-section of a bottom right corner subchannel
369 // cell. The points are ordered in this fashion:
370 // 1 6
371 // 3 2
372 // 0
373 //
374 // 4 5
375 std::array<Point, points_per_corner> br_corner_points;
376 {
377 for (unsigned int ii = 0; ii < points_per_quad; ii++)
378 {
379 auto c_pt = circle_points[4 * m - ii];
380 br_corner_points[ii + 1] = quadrant_centers[1] + c_pt;
381 }
382 br_corner_points[points_per_quad + 1] = Point(-_pitch * 0.5 * shrink_factor, -_side_gap, 0);
383 br_corner_points[points_per_quad + 2] = Point(_side_gap, -_side_gap, 0);
384 br_corner_points[points_per_quad + 3] = Point(_side_gap, _pitch * 0.5 * shrink_factor, 0);
385 }
386
387 // Build an array of points that represent a cross-section of a top side subchannel cell. The
388 // points are ordered in this fashion:
389 // 8 7
390 //
391 // 0
392 // 1 2 5 6
393 // 3 4
394 std::array<Point, points_per_side> top_points;
395 {
396 for (unsigned int ii = 0; ii < points_per_quad; ii++)
397 {
398 auto c_pt = circle_points[m - ii];
399 top_points[ii + 1] = quadrant_centers[2] + c_pt;
400 }
401 for (unsigned int ii = 0; ii < points_per_quad; ii++)
402 {
403 auto c_pt = circle_points[2 * m - ii];
404 top_points[points_per_quad + ii + 1] = quadrant_centers[3] + c_pt;
405 }
406 top_points[2 * points_per_quad + 1] = Point(_pitch * 0.5 * shrink_factor, _side_gap, 0);
407 top_points[2 * points_per_quad + 2] = Point(-_pitch * 0.5 * shrink_factor, _side_gap, 0);
408 }
409
410 // Build an array of points that represent a cross-section of a left side subchannel cell. The
411 // points are ordered in this fashion:
412 // 7 6
413 // 5 4
414 // 0
415 // 2 3
416 // 8 1
417 std::array<Point, points_per_side> left_points;
418 {
419 for (unsigned int ii = 0; ii < points_per_quad; ii++)
420 {
421 auto c_pt = circle_points[2 * m - ii];
422 left_points[ii + 1] = quadrant_centers[3] + c_pt;
423 }
424 for (unsigned int ii = 0; ii < points_per_quad; ii++)
425 {
426 auto c_pt = circle_points[3 * m - ii];
427 left_points[points_per_quad + ii + 1] = quadrant_centers[0] + c_pt;
428 }
429 left_points[2 * points_per_quad + 1] = Point(-_side_gap, _pitch * 0.5 * shrink_factor, 0);
430 left_points[2 * points_per_quad + 2] = Point(-_side_gap, -_pitch * 0.5 * shrink_factor, 0);
431 }
432
433 // Build an array of points that represent a cross-section of a bottom side subchannel cell. The
434 // points are ordered in this fashion:
435 // 4 3
436 // 6 5 2 1
437 // 0
438 //
439 // 7 8
440 std::array<Point, points_per_side> bottom_points;
441 {
442 for (unsigned int ii = 0; ii < points_per_quad; ii++)
443 {
444 auto c_pt = circle_points[3 * m - ii];
445 bottom_points[ii + 1] = quadrant_centers[0] + c_pt;
446 }
447 for (unsigned int ii = 0; ii < points_per_quad; ii++)
448 {
449 auto c_pt = circle_points[4 * m - ii];
450 bottom_points[points_per_quad + ii + 1] = quadrant_centers[1] + c_pt;
451 }
452 bottom_points[2 * points_per_quad + 1] = Point(-_pitch * 0.5 * shrink_factor, -_side_gap, 0);
453 bottom_points[2 * points_per_quad + 2] = Point(_pitch * 0.5 * shrink_factor, -_side_gap, 0);
454 }
455
456 // Build an array of points that represent a cross-section of a right side subchannel cell. The
457 // points are ordered in this fashion:
458 // 1 8
459 // 3 2
460 // 0
461 // 4 5
462 // 6 7
463 std::array<Point, points_per_side> right_points;
464 {
465 for (unsigned int ii = 0; ii < points_per_quad; ii++)
466 {
467 auto c_pt = circle_points[4 * m - ii];
468 right_points[ii + 1] = quadrant_centers[1] + c_pt;
469 }
470 for (unsigned int ii = 0; ii < points_per_quad; ii++)
471 {
472 auto c_pt = circle_points[m - ii];
473 right_points[points_per_quad + ii + 1] = quadrant_centers[2] + c_pt;
474 }
475 right_points[2 * points_per_quad + 1] = Point(_side_gap, -_pitch * 0.5 * shrink_factor, 0);
476 right_points[2 * points_per_quad + 2] = Point(_side_gap, _pitch * 0.5 * shrink_factor, 0);
477 }
478
479 if (_n_channels == 2)
480 {
481 // Special handling for the smallest line meshes, which contain only side subchannels.
482 unsigned int node_id = 0;
483 const Real offset_x = (_nx - 1) * _pitch / 2.0;
484 const Real offset_y = (_ny - 1) * _pitch / 2.0;
485 for (unsigned int iy = 0; iy < _ny; iy++)
486 {
487 Point y0 = {0, _pitch * iy - offset_y, 0};
488 for (unsigned int ix = 0; ix < _nx; ix++)
489 {
490 Point x0 = {_pitch * ix - offset_x, 0, 0};
491 for (auto z : _z_grid)
492 {
493 Point z0{0, 0, z};
494 if (_nx == 1 && iy == 0) // vertical orientation
495 for (unsigned int i = 0; i < points_per_side; i++)
496 mesh_base->add_point(bottom_points[i] + x0 + y0 + z0, node_id++);
497 if (_nx == 1 && iy == 1) // vertical orientation
498 for (unsigned int i = 0; i < points_per_side; i++)
499 mesh_base->add_point(top_points[i] + x0 + y0 + z0, node_id++);
500 if (_ny == 1 && ix == 0) // horizontal orientation
501 for (unsigned int i = 0; i < points_per_side; i++)
502 mesh_base->add_point(left_points[i] + x0 + y0 + z0, node_id++);
503 if (_ny == 1 && ix == 1) // horizontal orientation
504 for (unsigned int i = 0; i < points_per_side; i++)
505 mesh_base->add_point(right_points[i] + x0 + y0 + z0, node_id++);
506 }
507 }
508 }
509 }
510 else if (_n_channels > 2 && (_ny == 1 || _nx == 1))
511 {
512 // Line meshes larger than 2 channels have two side subchannels and center subchannels between
513 // them.
514 unsigned int node_id = 0;
515 const Real offset_x = (_nx - 1) * _pitch / 2.0;
516 const Real offset_y = (_ny - 1) * _pitch / 2.0;
517 for (unsigned int iy = 0; iy < _ny; iy++)
518 {
519 Point y0 = {0, _pitch * iy - offset_y, 0};
520 for (unsigned int ix = 0; ix < _nx; ix++)
521 {
522 Point x0 = {_pitch * ix - offset_x, 0, 0};
523 for (auto z : _z_grid)
524 {
525 Point z0{0, 0, z};
526 if (_nx == 1)
527 {
528 if (iy == 0)
529 for (unsigned int i = 0; i < points_per_side; i++)
530 mesh_base->add_point(bottom_points[i] + x0 + y0 + z0, node_id++);
531 else if (iy == _ny - 1)
532 for (unsigned int i = 0; i < points_per_side; i++)
533 mesh_base->add_point(top_points[i] + x0 + y0 + z0, node_id++);
534 else
535 for (unsigned int i = 0; i < points_per_center; i++)
536 mesh_base->add_point(center_points[i] + x0 + y0 + z0, node_id++);
537 }
538 else if (_ny == 1)
539 {
540 if (ix == 0)
541 for (unsigned int i = 0; i < points_per_side; i++)
542 mesh_base->add_point(left_points[i] + x0 + y0 + z0, node_id++);
543 else if (ix == _nx - 1)
544 for (unsigned int i = 0; i < points_per_side; i++)
545 mesh_base->add_point(right_points[i] + x0 + y0 + z0, node_id++);
546 else
547 for (unsigned int i = 0; i < points_per_center; i++)
548 mesh_base->add_point(center_points[i] + x0 + y0 + z0, node_id++);
549 }
550 }
551 }
552 }
553 }
554 else
555 {
556 // General 2D quad assemblies contain corner, side, and center subchannels.
557 unsigned int node_id = 0;
558 const Real offset_x = (_nx - 1) * _pitch / 2.0;
559 const Real offset_y = (_ny - 1) * _pitch / 2.0;
560 for (unsigned int iy = 0; iy < _ny; iy++)
561 {
562 Point y0 = {0, _pitch * iy - offset_y, 0};
563 for (unsigned int ix = 0; ix < _nx; ix++)
564 {
565 Point x0 = {_pitch * ix - offset_x, 0, 0};
566 if (ix == 0 && iy == 0) // Bottom Left corner
567 for (auto z : _z_grid)
568 {
569 Point z0{0, 0, z};
570 for (unsigned int i = 0; i < points_per_corner; i++)
571 mesh_base->add_point(bl_corner_points[i] + x0 + y0 + z0, node_id++);
572 }
573 else if (ix == _nx - 1 && iy == 0) // Bottom right corner
574 for (auto z : _z_grid)
575 {
576 Point z0{0, 0, z};
577 for (unsigned int i = 0; i < points_per_corner; i++)
578 mesh_base->add_point(br_corner_points[i] + x0 + y0 + z0, node_id++);
579 }
580 else if (ix == 0 && iy == _ny - 1) // top Left corner
581 for (auto z : _z_grid)
582 {
583 Point z0{0, 0, z};
584 for (unsigned int i = 0; i < points_per_corner; i++)
585 mesh_base->add_point(tl_corner_points[i] + x0 + y0 + z0, node_id++);
586 }
587 else if (ix == _nx - 1 && iy == _ny - 1) // top right corner
588 for (auto z : _z_grid)
589 {
590 Point z0{0, 0, z};
591 for (unsigned int i = 0; i < points_per_corner; i++)
592 mesh_base->add_point(tr_corner_points[i] + x0 + y0 + z0, node_id++);
593 }
594 else if (ix == 0 && (iy != _ny - 1 || iy != 0)) // left side
595 for (auto z : _z_grid)
596 {
597 Point z0{0, 0, z};
598 for (unsigned int i = 0; i < points_per_side; i++)
599 mesh_base->add_point(left_points[i] + x0 + y0 + z0, node_id++);
600 }
601 else if (ix == _nx - 1 && (iy != _ny - 1 || iy != 0)) // right side
602 for (auto z : _z_grid)
603 {
604 Point z0{0, 0, z};
605 for (unsigned int i = 0; i < points_per_side; i++)
606 mesh_base->add_point(right_points[i] + x0 + y0 + z0, node_id++);
607 }
608 else if (iy == 0 && (ix != _nx - 1 || ix != 0)) // bottom side
609 for (auto z : _z_grid)
610 {
611 Point z0{0, 0, z};
612 for (unsigned int i = 0; i < points_per_side; i++)
613 mesh_base->add_point(bottom_points[i] + x0 + y0 + z0, node_id++);
614 }
615 else if (iy == _ny - 1 && (ix != _nx - 1 || ix != 0)) // top side
616 for (auto z : _z_grid)
617 {
618 Point z0{0, 0, z};
619 for (unsigned int i = 0; i < points_per_side; i++)
620 mesh_base->add_point(top_points[i] + x0 + y0 + z0, node_id++);
621 }
622 else // center
623 for (auto z : _z_grid)
624 {
625 Point z0{0, 0, z};
626 for (unsigned int i = 0; i < points_per_center; i++)
627 mesh_base->add_point(center_points[i] + x0 + y0 + z0, node_id++);
628 }
629 }
630 }
631 }
632
633 if (_n_channels == 2)
634 {
635 // Build elements for the smallest line meshes.
636 for (unsigned int iy = 0; iy < _ny; iy++)
637 for (unsigned int ix = 0; ix < _nx; ix++)
638 {
639 const unsigned int i_ch = _nx * iy + ix;
640 for (unsigned int iz = 0; iz < _n_cells; iz++)
641 for (unsigned int i = 0; i < elems_per_side; i++)
642 {
643 Elem * elem = mesh_base->add_elem(std::make_unique<Prism6>());
644 elem->subdomain_id() = _subchannel_block_id;
645 elem->set_id(_elem_id++);
646 // index of the central node at base of cell
647 const unsigned int indx1 =
648 iz * points_per_side + points_per_side * (_n_cells + 1) * i_ch;
649 const unsigned int indx2 =
650 (iz + 1) * points_per_side + points_per_side * (_n_cells + 1) * i_ch;
651 const unsigned int elems_per_channel = elems_per_side;
652 elem->set_node(0, mesh_base->node_ptr(indx1));
653 elem->set_node(1, mesh_base->node_ptr(indx1 + i + 1));
654 elem->set_node(2,
655 i != elems_per_channel - 1 ? mesh_base->node_ptr(indx1 + i + 2)
656 : mesh_base->node_ptr(indx1 + 1));
657 elem->set_node(3, mesh_base->node_ptr(indx2));
658 elem->set_node(4, mesh_base->node_ptr(indx2 + i + 1));
659 elem->set_node(5,
660 i != elems_per_channel - 1 ? mesh_base->node_ptr(indx2 + i + 2)
661 : mesh_base->node_ptr(indx2 + 1));
662
663 if (iz == 0)
664 boundary_info.add_side(elem, 0, 0);
665 if (iz == _n_cells - 1)
666 boundary_info.add_side(elem, 4, 1);
667 }
668 }
669 }
670 else if (_n_channels > 2 && (_ny == 1 || _nx == 1))
671 {
672 // Build elements for 1xN and Nx1 line meshes.
673 unsigned int number_of_corner = 0;
674 unsigned int number_of_side = 0;
675 unsigned int number_of_center = 0;
676 unsigned int elems_per_channel = 0;
677 unsigned int points_per_channel = 0;
678 for (unsigned int iy = 0; iy < _ny; iy++)
679 for (unsigned int ix = 0; ix < _nx; ix++)
680 {
681 const unsigned int i_ch = _nx * iy + ix;
682 const auto subch_type = getSubchannelType(i_ch);
683 if (subch_type == EChannelType::CORNER)
684 {
685 number_of_side++;
686 elems_per_channel = elems_per_side;
687 points_per_channel = points_per_side;
688 }
689 else if (subch_type == EChannelType::EDGE)
690 {
691 number_of_center++;
692 elems_per_channel = elems_per_center;
693 points_per_channel = points_per_center;
694 }
695
696 for (unsigned int iz = 0; iz < _n_cells; iz++)
697 {
698 const unsigned int elapsed_points =
699 number_of_corner * points_per_corner * (_n_cells + 1) +
700 number_of_side * points_per_side * (_n_cells + 1) +
701 number_of_center * points_per_center * (_n_cells + 1) -
702 points_per_channel * (_n_cells + 1);
703 // index of the central node at base of cell
704 const unsigned int indx1 = iz * points_per_channel + elapsed_points;
705 const unsigned int indx2 = (iz + 1) * points_per_channel + elapsed_points;
706
707 for (unsigned int i = 0; i < elems_per_channel; i++)
708 {
709 Elem * elem = mesh_base->add_elem(std::make_unique<Prism6>());
710 elem->subdomain_id() = _subchannel_block_id;
711 elem->set_id(_elem_id++);
712 elem->set_node(0, mesh_base->node_ptr(indx1));
713 elem->set_node(1, mesh_base->node_ptr(indx1 + i + 1));
714 elem->set_node(2,
715 i != elems_per_channel - 1 ? mesh_base->node_ptr(indx1 + i + 2)
716 : mesh_base->node_ptr(indx1 + 1));
717 elem->set_node(3, mesh_base->node_ptr(indx2));
718 elem->set_node(4, mesh_base->node_ptr(indx2 + i + 1));
719 elem->set_node(5,
720 i != elems_per_channel - 1 ? mesh_base->node_ptr(indx2 + i + 2)
721 : mesh_base->node_ptr(indx2 + 1));
722
723 if (iz == 0)
724 boundary_info.add_side(elem, 0, 0);
725 if (iz == _n_cells - 1)
726 boundary_info.add_side(elem, 4, 1);
727 }
728 }
729 }
730 }
731 else
732 {
733 // Build elements for general 2D quad assemblies.
734 unsigned int number_of_corner = 0;
735 unsigned int number_of_side = 0;
736 unsigned int number_of_center = 0;
737 unsigned int elems_per_channel = 0;
738 unsigned int points_per_channel = 0;
739 for (unsigned int iy = 0; iy < _ny; iy++)
740 for (unsigned int ix = 0; ix < _nx; ix++)
741 {
742 const unsigned int i_ch = _nx * iy + ix;
743 const auto subch_type = getSubchannelType(i_ch);
744 if (subch_type == EChannelType::CORNER)
745 {
746 number_of_corner++;
747 elems_per_channel = elems_per_corner;
748 points_per_channel = points_per_corner;
749 }
750 else if (subch_type == EChannelType::EDGE)
751 {
752 number_of_side++;
753 elems_per_channel = elems_per_side;
754 points_per_channel = points_per_side;
755 }
756 else
757 {
758 number_of_center++;
759 elems_per_channel = elems_per_center;
760 points_per_channel = points_per_center;
761 }
762
763 for (unsigned int iz = 0; iz < _n_cells; iz++)
764 {
765 const unsigned int elapsed_points =
766 number_of_corner * points_per_corner * (_n_cells + 1) +
767 number_of_side * points_per_side * (_n_cells + 1) +
768 number_of_center * points_per_center * (_n_cells + 1) -
769 points_per_channel * (_n_cells + 1);
770 // index of the central node at base of cell
771 const unsigned int indx1 = iz * points_per_channel + elapsed_points;
772 const unsigned int indx2 = (iz + 1) * points_per_channel + elapsed_points;
773
774 for (unsigned int i = 0; i < elems_per_channel; i++)
775 {
776 Elem * elem = mesh_base->add_elem(std::make_unique<Prism6>());
777 elem->subdomain_id() = _subchannel_block_id;
778 elem->set_id(_elem_id++);
779 elem->set_node(0, mesh_base->node_ptr(indx1));
780 elem->set_node(1, mesh_base->node_ptr(indx1 + i + 1));
781 elem->set_node(2,
782 i != elems_per_channel - 1 ? mesh_base->node_ptr(indx1 + i + 2)
783 : mesh_base->node_ptr(indx1 + 1));
784 elem->set_node(3, mesh_base->node_ptr(indx2));
785 elem->set_node(4, mesh_base->node_ptr(indx2 + i + 1));
786 elem->set_node(5,
787 i != elems_per_channel - 1 ? mesh_base->node_ptr(indx2 + i + 2)
788 : mesh_base->node_ptr(indx2 + 1));
789
790 if (iz == 0)
791 boundary_info.add_side(elem, 0, 0);
792 if (iz == _n_cells - 1)
793 boundary_info.add_side(elem, 4, 1);
794 }
795 }
796 }
797 }
798
799 if (n_pins > 0)
800 for (auto & ctr : pin_centers)
801 generatePin(mesh_base, ctr);
802
803 boundary_info.sideset_name(0) = "inlet";
804 boundary_info.sideset_name(1) = "outlet";
805 mesh_base->set_subdomain_name(_subchannel_block_id, "subchannel", true);
806 if (n_pins > 0)
807 mesh_base->set_subdomain_name(_pin_block_id, "fuel_pins", true);
808 mesh_base->prepare_for_use();
809
810 return mesh_base;
811}
Point center
registerMooseObject("SubChannelApp", SCMQuadVisualizationAssemblyMeshGenerator)
registerMooseObjectRenamed("SubChannelApp", SCMDetailedQuadAssemblyMeshGenerator, "06/30/2027 24:00", SCMQuadVisualizationAssemblyMeshGenerator)
void ErrorVector unsigned int
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
static InputParameters validParams()
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
static void generatePinCenters(unsigned int nx, unsigned int ny, Real pitch, Real elev, std::vector< Point > &pin_centers)
Generate pin centers.
Mesh generator that builds a 3D visualization mesh representing quadrilateral subchannels and pins.
std::vector< std::vector< Real > > _subchannel_position
x,y coordinates of the subchannel centroids
const unsigned int _ny
Number of subchannels in the y direction.
const Real _unheated_length_exit
unheated length of the fuel Pin at the exit of the assembly
const Real _pitch
Distance between the neighbor fuel pins, pitch.
const unsigned int _nx
Number of subchannels in the x direction.
const 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...
const Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
EChannelType getSubchannelType(unsigned int index) const
returns the type of the subchannel given the index
const unsigned int _n_cells
Number of cells in the axial direction.
SCMQuadVisualizationAssemblyMeshGenerator(const InputParameters &parameters)
const unsigned int _num_sectors
Number of azimuthal sectors used to discretize each circular pin cross section.
void generatePin(std::unique_ptr< MeshBase > &mesh_base, const Point &center)
Generate one detailed fuel pin volume centered at the supplied point.
const unsigned int _subchannel_block_id
Subchannel subdomain ID.
virtual std::unique_ptr< MeshBase > generate() override
const Real radius