https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SCMTriAssemblyMeshGenerator.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 "TriSubChannelMesh.h"
12#include "MooseUtils.h"
13#include <cmath>
14#include <memory>
15#include "libmesh/edge_edge2.h"
16#include "libmesh/unstructured_mesh.h"
17
20 SCMTriSubChannelMeshGenerator,
21 "06/30/2027 24:00",
24 TriSubChannelMeshGenerator,
25 "06/30/2027 24:00",
28 SCMTriPinMeshGenerator,
29 "06/30/2027 24:00",
32 TriPinMeshGenerator,
33 "06/30/2027 24:00",
35
38{
41 "Creates a mesh of 1D subchannels and 1D pins in a triangular lattice arrangement");
42 params.addRequiredParam<unsigned int>("n_cells", "The number of cells in the axial direction");
43 params.addRequiredParam<Real>("pitch", "Pitch [m]");
44 params.addRequiredParam<Real>("pin_diameter", "Rod diameter [m]");
45 params.addParam<Real>("unheated_length_entry", 0.0, "Unheated length at entry [m]");
46 params.addRequiredParam<Real>("heated_length", "Heated length [m]");
47 params.addParam<Real>("unheated_length_exit", 0.0, "Unheated length at exit [m]");
48 params.addRequiredParam<unsigned int>(
49 "nrings",
50 "Number of fuel-pin rings per assembly, counting the center pin as the first ring [-]");
51 params.addRequiredParam<Real>("flat_to_flat",
52 "Flat to flat distance for the hexagonal assembly [m]");
53 params.addRequiredParam<Real>("dwire", "Wire diameter [m]");
54 params.addRequiredParam<Real>("hwire", "Wire lead length [m]");
55 params.addParam<std::vector<Real>>(
56 "spacer_z", {}, "Axial location of spacers/vanes/mixing vanes [m]");
57 params.addParam<std::vector<Real>>(
58 "spacer_k", {}, "K-loss coefficient of spacers/vanes/mixing vanes [-]");
59 params.addParam<Real>("Kij", 0.5, "Lateral form loss coefficient [-]");
60 params.addParam<std::vector<Real>>("z_blockage",
61 std::vector<Real>({0.0, 0.0}),
62 "axial location of blockage (inlet, outlet) [m]");
63 params.addParam<std::vector<unsigned int>>("index_blockage",
64 std::vector<unsigned int>({0}),
65 "index of subchannels affected by blockage");
66 params.addParam<std::vector<Real>>(
67 "reduction_blockage",
68 std::vector<Real>({1.0}),
69 "Area reduction of subchannels affected by blockage (number to muliply the area)");
70 params.addParam<std::vector<Real>>("k_blockage",
71 std::vector<Real>({0.0}),
72 "Form loss coefficient of subchannels affected by blockage");
73 params.addParam<unsigned int>("block_id", 0, "Subchannel block id");
74 params.deprecateParam("block_id", "subchannel_block_id", "07/01/2027");
75 params.addParam<unsigned int>("pin_block_id", 1, "Fuel Pin block id");
76 return params;
77}
78
80 : MeshGenerator(params),
81 _unheated_length_entry(getParam<Real>("unheated_length_entry")),
82 _heated_length(getParam<Real>("heated_length")),
83 _unheated_length_exit(getParam<Real>("unheated_length_exit")),
84 _subchannel_block_id(getParam<unsigned int>("subchannel_block_id")),
85 _pin_block_id(getParam<unsigned int>("pin_block_id")),
86 _spacer_z(getParam<std::vector<Real>>("spacer_z")),
87 _spacer_k(getParam<std::vector<Real>>("spacer_k")),
88 _z_blockage(getParam<std::vector<Real>>("z_blockage")),
89 _index_blockage(getParam<std::vector<unsigned int>>("index_blockage")),
90 _reduction_blockage(getParam<std::vector<Real>>("reduction_blockage")),
91 _k_blockage(getParam<std::vector<Real>>("k_blockage")),
92 _pitch(getParam<Real>("pitch")),
93 _kij(getParam<Real>("Kij")),
94 _pin_diameter(getParam<Real>("pin_diameter")),
95 _n_cells(getParam<unsigned int>("n_cells")),
96 _n_rings(getParam<unsigned int>("nrings")),
97 _n_channels(0),
98 _flat_to_flat(getParam<Real>("flat_to_flat")),
99 _dwire(getParam<Real>("dwire")),
100 _hwire(getParam<Real>("hwire")),
101 _duct_to_pin_gap(0.5 *
102 (_flat_to_flat - (_n_rings - 1) * _pitch * std::sqrt(3.0) - _pin_diameter)),
103 _npins(0),
104 _n_gaps(0)
105{
106 // Read by SCMTriCoreMeshGenerator to check that assemblies placed in a core do not overlap
107 declareMeshProperty<Real>("flat_to_flat", _flat_to_flat);
108
109 const Real total_length = _unheated_length_entry + _heated_length + _unheated_length_exit;
110
111 if (_n_rings < 2)
112 paramError("nrings",
113 "'nrings' must be at least 2. In this mesh generator, the center pin counts as "
114 "the first ring, so a 7-pin bundle uses nrings = 2.");
115
116 if (_n_cells == 0)
117 paramError("n_cells", "The number of axial cells must be greater than zero");
118
119 const Real pin_gap = _pitch - _pin_diameter;
120 if (pin_gap <= 0.0)
121 paramError("pitch", "The pin pitch must be greater than the pin diameter");
122
123 if (MooseUtils::absoluteFuzzyGreaterThan(_dwire, pin_gap))
124 paramError("dwire", "The wire diameter must not exceed the pin-to-pin gap");
125
126 if (total_length <= 0.0)
127 mooseError("Total bundle length must be greater than zero");
128
129 if (_spacer_z.size() != _spacer_k.size())
130 mooseError("Size of vector spacer_z should be equal to size of vector spacer_k");
131
132 for (const auto spacer_z : _spacer_z)
133 if (spacer_z < 0.0 || spacer_z > total_length)
134 paramError("spacer_z", "Location of spacers should be between zero and total bundle length");
135
136 if (_z_blockage.size() != 2)
137 paramError("z_blockage", "Size of vector z_blockage must be 2");
138
139 if (_z_blockage.front() > _z_blockage.back())
140 paramError("z_blockage", "z_blockage inlet location must not exceed outlet location");
141
142 if (*max_element(_reduction_blockage.begin(), _reduction_blockage.end()) > 1)
143 paramError("reduction_blockage",
144 "The area reduction of the blocked subchannels cannot be more than 1");
145
146 if ((_index_blockage.size() != _reduction_blockage.size()) ||
147 (_index_blockage.size() != _k_blockage.size()) ||
148 (_reduction_blockage.size() != _k_blockage.size()))
149 mooseError("Size of vectors: index_blockage, reduction_blockage, k_blockage, must be equal "
150 "to eachother");
151
154
155 // Defining the total length from 3 axial sections
156 Real L = total_length;
157
158 // Defining the position of the spacer grid in the numerical solution array
159 std::vector<int> spacer_cell;
160 for (const auto & elem : _spacer_z)
161 spacer_cell.emplace_back(std::round(elem * _n_cells / L));
162
163 // Defining the array for axial resistances
164 std::vector<Real> kgrid;
165 kgrid.resize(_n_cells + 1, 0.0);
166
167 // Summing the spacer resistance to the grid resistance array
168 for (unsigned int index = 0; index < spacer_cell.size(); index++)
169 kgrid[spacer_cell[index]] += _spacer_k[index];
170
171 // compute the hex mesh variables
172 // -------------------------------------------
173 // x coordinate for the first position
174 Real x0 = 0.0;
175 // y coordinate for the first position
176 Real y0 = 0.0;
177 // x coordinate for the second position
178 Real x1 = 0.0;
179 // y coordinate for the second position dummy variable
180 Real y1 = 0.0;
181 // dummy variable
182 Real a1 = 0.0;
183 // dummy variable
184 Real a2 = 0.0;
185 // average x coordinate
186 Real avg_coor_x = 0.0;
187 // average y coordinate
188 Real avg_coor_y = 0.0;
189 // distance between two points
190 Real dist = 0.0;
191 // distance between two points
192 Real dist0 = 0.0;
193 // integer counter
194 unsigned int kgap = 0;
195 // dummy integer
196 unsigned int icorner = 0;
197 // used to defined global direction of the cross_flow_map coefficients for each subchannel and gap
198 const Real positive_flow = 1.0;
199 // used to defined global direction of the cross_flow_map coefficients for each subchannel and gap
200 const Real negative_flow = -1.0;
201 // the indicator used while setting _gap_to_chan_map array
202 std::vector<std::pair<unsigned int, unsigned int>> gap_fill;
204 _npins = _pin_position.size();
205 // assign the pins to the corresponding rings
206 unsigned int k = 0; // initialize the fuel Pin counter index
207 _pins_in_rings.resize(_n_rings);
208 _pins_in_rings[0].push_back(k++);
209 for (unsigned int i = 1; i < _n_rings; i++)
210 for (unsigned int j = 0; j < i * 6; j++)
211 _pins_in_rings[i].push_back(k++);
212 // Given the number of pins and number of fuel Pin rings, the number of subchannels can be
213 // computed as follows:
214 unsigned int chancount = 0.0;
215 // Summing internal channels
216 for (unsigned int j = 0; j < _n_rings - 1; j++)
217 chancount += j * 6;
218 // Adding external channels to the total count
219 _n_channels = chancount + _npins - 1 + (_n_rings - 1) * 6 + 6;
220
221 if (*max_element(_index_blockage.begin(), _index_blockage.end()) > (_n_channels - 1))
222 paramError("index_blockage",
223 "The index of the blocked subchannel cannot be more than the max index of the "
224 "subchannels");
225
226 if ((_index_blockage.size() > _n_channels) || (_reduction_blockage.size() > _n_channels) ||
227 (_k_blockage.size() > _n_channels))
228 mooseError("Size of vectors: index_blockage, reduction_blockage, k_blockage, cannot be more "
229 "than the total number of subchannels");
230
231 // Defining the 2D array for axial resistances
232 _k_grid.resize(_n_channels, std::vector<Real>(_n_cells + 1));
233 for (unsigned int i = 0; i < _n_channels; i++)
234 _k_grid[i] = kgrid;
235
236 // Add blockage resistance to the 2D grid resistane array
237 Real dz = L / _n_cells;
238 for (unsigned int i = 0; i < _n_cells + 1; i++)
239 {
240 if ((dz * i >= _z_blockage.front() && dz * i <= _z_blockage.back()))
241 {
242 unsigned int index(0);
243 for (const auto & i_ch : _index_blockage)
244 {
245 _k_grid[i_ch][i] += _k_blockage[index];
246 index++;
247 }
248 }
249 }
250
252 _pin_to_chan_map.resize(_npins);
253 _subch_type.resize(_n_channels);
254 _n_gaps = _n_channels + _npins - 1;
256 _gap_to_pin_map.resize(_n_gaps);
257 gap_fill.resize(_n_gaps);
261 _gij_map.resize(_n_cells + 1);
263 _gap_type.resize(_n_gaps);
265
266 for (unsigned int i = 0; i < _n_channels; i++)
267 {
268 _chan_to_pin_map[i].reserve(3);
269 _chan_to_gap_map[i].reserve(3);
270 _sign_id_crossflow_map[i].reserve(3);
271 _subchannel_position[i].reserve(3);
272 for (unsigned int j = 0; j < 3; j++)
273 {
274 _sign_id_crossflow_map.at(i).push_back(positive_flow);
275 _subchannel_position.at(i).push_back(0.0);
276 }
277 }
278
279 for (unsigned int iz = 0; iz < _n_cells + 1; iz++)
280 {
281 _gij_map[iz].reserve(_n_gaps);
282 }
283
284 for (unsigned int i = 0; i < _npins; i++)
285 _pin_to_chan_map[i].reserve(6);
286
287 // create the subchannels
288 k = 0; // initialize the subchannel counter index
289 kgap = 0;
290 // for each ring we trace the subchannels by pairing up to neighbor pins and looking for the third
291 // Pin at inner or outer ring compared to the current ring.
292 for (unsigned int i = 1; i < _n_rings; i++)
293 {
294 // find the closest Pin at back ring
295 for (unsigned int j = 0; j < _pins_in_rings[i].size(); j++)
296 {
297 if (j == _pins_in_rings[i].size() - 1)
298 {
299 _chan_to_pin_map[k].push_back(_pins_in_rings[i][j]);
300 _chan_to_pin_map[k].push_back(_pins_in_rings[i][0]);
301 avg_coor_x =
302 0.5 * (_pin_position[_pins_in_rings[i][j]](0) + _pin_position[_pins_in_rings[i][0]](0));
303 avg_coor_y =
304 0.5 * (_pin_position[_pins_in_rings[i][j]](1) + _pin_position[_pins_in_rings[i][0]](1));
305 _gap_to_pin_map[kgap].first = _pins_in_rings[i][0];
306 _gap_to_pin_map[kgap].second = _pins_in_rings[i][j];
308 kgap = kgap + 1;
309 }
310 else
311 {
312 _chan_to_pin_map[k].push_back(_pins_in_rings[i][j]);
313 _chan_to_pin_map[k].push_back(_pins_in_rings[i][j + 1]);
314 avg_coor_x = 0.5 * (_pin_position[_pins_in_rings[i][j]](0) +
315 _pin_position[_pins_in_rings[i][j + 1]](0));
316 avg_coor_y = 0.5 * (_pin_position[_pins_in_rings[i][j]](1) +
317 _pin_position[_pins_in_rings[i][j + 1]](1));
318 _gap_to_pin_map[kgap].first = _pins_in_rings[i][j];
319 _gap_to_pin_map[kgap].second = _pins_in_rings[i][j + 1];
321 kgap = kgap + 1;
322 }
323
324 dist0 = 1.0e+5;
325
326 _chan_to_pin_map[k].push_back(_pins_in_rings[i - 1][0]);
327 unsigned int l0 = 0;
328
329 for (unsigned int l = 0; l < _pins_in_rings[i - 1].size(); l++)
330 {
331 dist = std::sqrt(pow(_pin_position[_pins_in_rings[i - 1][l]](0) - avg_coor_x, 2) +
332 pow(_pin_position[_pins_in_rings[i - 1][l]](1) - avg_coor_y, 2));
333
334 if (dist < dist0)
335 {
336 _chan_to_pin_map[k][2] = _pins_in_rings[i - 1][l];
337 l0 = l;
338 dist0 = dist;
339 } // if
340 } // l
341
342 _gap_to_pin_map[kgap].first = _pins_in_rings[i][j];
343 _gap_to_pin_map[kgap].second = _pins_in_rings[i - 1][l0];
345 kgap = kgap + 1;
347 k = k + 1;
348 } // for j
349
350 // find the closest Pin at front ring
351 for (unsigned int j = 0; j < _pins_in_rings[i].size(); j++)
352 {
353 if (j == _pins_in_rings[i].size() - 1)
354 {
355 _chan_to_pin_map[k].push_back(_pins_in_rings[i][j]);
356 _chan_to_pin_map[k].push_back(_pins_in_rings[i][0]);
357 avg_coor_x =
358 0.5 * (_pin_position[_pins_in_rings[i][j]](0) + _pin_position[_pins_in_rings[i][0]](0));
359 avg_coor_y =
360 0.5 * (_pin_position[_pins_in_rings[i][j]](1) + _pin_position[_pins_in_rings[i][0]](1));
361 }
362 else
363 {
364 _chan_to_pin_map[k].push_back(_pins_in_rings[i][j]);
365 _chan_to_pin_map[k].push_back(_pins_in_rings[i][j + 1]);
366 avg_coor_x = 0.5 * (_pin_position[_pins_in_rings[i][j]](0) +
367 _pin_position[_pins_in_rings[i][j + 1]](0));
368 avg_coor_y = 0.5 * (_pin_position[_pins_in_rings[i][j]](1) +
369 _pin_position[_pins_in_rings[i][j + 1]](1));
370 }
371
372 // if the outermost ring, set the edge subchannels first... then the corner subchannels
373 if (i == _n_rings - 1)
374 {
375 // add edges
376 _subch_type[k] = EChannelType::EDGE; // an edge subchannel is created
377 _gap_to_pin_map[kgap].first = _pins_in_rings[i][j];
378 _gap_to_pin_map[kgap].second = _pins_in_rings[i][j];
380 _chan_to_gap_map[k].push_back(kgap);
381 kgap = kgap + 1;
382 k = k + 1;
383
384 if (j % i == 0)
385 {
386 // generate a corner subchannel, generate the additional gap and fix chan_to_gap_map
387 _gap_to_pin_map[kgap].first = _pins_in_rings[i][j];
388 _gap_to_pin_map[kgap].second = _pins_in_rings[i][j];
390
391 // corner subchannel
392 _chan_to_pin_map[k].push_back(_pins_in_rings[i][j]);
393 _chan_to_gap_map[k].push_back(kgap - 1);
394 _chan_to_gap_map[k].push_back(kgap);
396
397 kgap = kgap + 1;
398 k = k + 1;
399 }
400 // if not the outer most ring
401 }
402 else
403 {
404 dist0 = 1.0e+5;
405 unsigned int l0 = 0;
406 _chan_to_pin_map[k].push_back(_pins_in_rings[i + 1][0]);
407 for (unsigned int l = 0; l < _pins_in_rings[i + 1].size(); l++)
408 {
409 dist = std::sqrt(pow(_pin_position[_pins_in_rings[i + 1][l]](0) - avg_coor_x, 2) +
410 pow(_pin_position[_pins_in_rings[i + 1][l]](1) - avg_coor_y, 2));
411 if (dist < dist0)
412 {
413 _chan_to_pin_map[k][2] = _pins_in_rings[i + 1][l];
414 dist0 = dist;
415 l0 = l;
416 } // if
417 } // l
418
419 _gap_to_pin_map[kgap].first = _pins_in_rings[i][j];
420 _gap_to_pin_map[kgap].second = _pins_in_rings[i + 1][l0];
422 kgap = kgap + 1;
424 k = k + 1;
425 } // if
426 } // for j
427 } // for i
428
429 // Constructing pins to channels mao
430 for (unsigned int loc_rod = 0; loc_rod < _npins; loc_rod++)
431 {
432 for (unsigned int i = 0; i < _n_channels; i++)
433 {
434 bool rod_in_sc = false;
435 for (unsigned int j : _chan_to_pin_map[i])
436 {
437 if (j == loc_rod)
438 rod_in_sc = true;
439 }
440 if (rod_in_sc)
441 {
442 _pin_to_chan_map[loc_rod].push_back(i);
443 }
444 }
445 }
446
459 for (unsigned int i = 0; i < _n_channels; i++)
460 {
462 {
463 for (unsigned int j = 0; j < _n_gaps; j++)
464 {
466 {
467 if (((_chan_to_pin_map[i][0] == _gap_to_pin_map[j].first) &&
468 (_chan_to_pin_map[i][1] == _gap_to_pin_map[j].second)) ||
469 ((_chan_to_pin_map[i][0] == _gap_to_pin_map[j].second) &&
470 (_chan_to_pin_map[i][1] == _gap_to_pin_map[j].first)))
471 {
472 _chan_to_gap_map[i].push_back(j);
473 }
474
475 if (((_chan_to_pin_map[i][0] == _gap_to_pin_map[j].first) &&
476 (_chan_to_pin_map[i][2] == _gap_to_pin_map[j].second)) ||
477 ((_chan_to_pin_map[i][0] == _gap_to_pin_map[j].second) &&
478 (_chan_to_pin_map[i][2] == _gap_to_pin_map[j].first)))
479 {
480 _chan_to_gap_map[i].push_back(j);
481 }
482
483 if (((_chan_to_pin_map[i][1] == _gap_to_pin_map[j].first) &&
484 (_chan_to_pin_map[i][2] == _gap_to_pin_map[j].second)) ||
485 ((_chan_to_pin_map[i][1] == _gap_to_pin_map[j].second) &&
486 (_chan_to_pin_map[i][2] == _gap_to_pin_map[j].first)))
487 {
488 _chan_to_gap_map[i].push_back(j);
489 }
490 }
491 } // for j
492 }
493 else if (_subch_type[i] == EChannelType::EDGE)
494 {
495 for (unsigned int j = 0; j < _n_gaps; j++)
496 {
498 {
499 if (((_chan_to_pin_map[i][0] == _gap_to_pin_map[j].first) &&
500 (_chan_to_pin_map[i][1] == _gap_to_pin_map[j].second)) ||
501 ((_chan_to_pin_map[i][0] == _gap_to_pin_map[j].second) &&
502 (_chan_to_pin_map[i][1] == _gap_to_pin_map[j].first)))
503 {
504 _chan_to_gap_map[i].push_back(j);
505 }
506 }
507 }
508
509 icorner = 0;
510 for (unsigned int k = 0; k < _n_channels; k++)
511 {
513 _chan_to_pin_map[i][1] == _chan_to_pin_map[k][0])
514 {
515 _chan_to_gap_map[i].push_back(_chan_to_gap_map[k][1]);
516 icorner = 1;
517 break;
518 } // if
519 } // for
520
521 // Check whether the edge channel's first pin is also a corner pin. This second corner lookup
522 // is only needed while the edge channel still needs another perimeter gap.
523 if (_chan_to_gap_map[i].size() < 3)
524 {
525 for (unsigned int k = 0; k < _n_channels; k++)
526 {
528 _chan_to_pin_map[i][0] == _chan_to_pin_map[k][0])
529 {
530 _chan_to_gap_map[i].push_back(_chan_to_gap_map[k][1] + 1);
531 icorner = 1;
532 break;
533 }
534 }
535 }
536
537 if (icorner == 0)
538 {
539 _chan_to_gap_map[i].push_back(_chan_to_gap_map[i][0] + 1);
540 }
541 }
542 }
543
544 // find gap_to_chan_map pair
545 for (unsigned int j = 0; j < _n_gaps; j++)
546 {
547 for (unsigned int i = 0; i < _n_channels; i++)
548 {
550 {
551 if ((j == _chan_to_gap_map[i][0]) || (j == _chan_to_gap_map[i][1]) ||
552 (j == _chan_to_gap_map[i][2]))
553 {
554 if (_gap_to_chan_map[j].first == 0 && gap_fill[j].first == 0)
555 {
556 _gap_to_chan_map[j].first = i;
557 gap_fill[j].first = 1;
558 }
559 else if (_gap_to_chan_map[j].second == 0 && gap_fill[j].second == 0)
560 {
561 _gap_to_chan_map[j].second = i;
562 gap_fill[j].second = 1;
563 }
564 else
565 {
566 }
567 }
568 }
569 else if (_subch_type[i] == EChannelType::CORNER)
570 {
571 if ((j == _chan_to_gap_map[i][0]) || (j == _chan_to_gap_map[i][1]))
572 {
573 if (_gap_to_chan_map[j].first == 0 && gap_fill[j].first == 0)
574 {
575 _gap_to_chan_map[j].first = i;
576 gap_fill[j].first = 1;
577 }
578 else if (_gap_to_chan_map[j].second == 0 && gap_fill[j].second == 0)
579 {
580 _gap_to_chan_map[j].second = i;
581 gap_fill[j].second = 1;
582 }
583 else
584 {
585 }
586 }
587 }
588 } // i
589 } // j
590
591 for (unsigned int k = 0; k < _n_channels; k++)
592 {
594 {
595 _gap_pairs_sf[k].first = _chan_to_gap_map[k][0];
596 _gap_pairs_sf[k].second = _chan_to_gap_map[k][2];
597 auto k1 = _gap_pairs_sf[k].first;
598 auto k2 = _gap_pairs_sf[k].second;
599 if (_gap_to_chan_map[k1].first == k)
600 {
601 _chan_pairs_sf[k].first = _gap_to_chan_map[k1].second;
602 }
603 else
604 {
605 _chan_pairs_sf[k].first = _gap_to_chan_map[k1].first;
606 }
607
608 if (_gap_to_chan_map[k2].first == k)
609 {
610 _chan_pairs_sf[k].second = _gap_to_chan_map[k2].second;
611 }
612 else
613 {
614 _chan_pairs_sf[k].second = _gap_to_chan_map[k2].first;
615 }
616 }
617 else if (_subch_type[k] == EChannelType::CORNER)
618 {
619 _gap_pairs_sf[k].first = _chan_to_gap_map[k][1];
620 _gap_pairs_sf[k].second = _chan_to_gap_map[k][0];
621
622 auto k1 = _gap_pairs_sf[k].first;
623 auto k2 = _gap_pairs_sf[k].second;
624
625 if (_gap_to_chan_map[k1].first == k)
626 {
627 _chan_pairs_sf[k].first = _gap_to_chan_map[k1].second;
628 }
629 else
630 {
631 _chan_pairs_sf[k].first = _gap_to_chan_map[k1].first;
632 }
633
634 if (_gap_to_chan_map[k2].first == k)
635 {
636 _chan_pairs_sf[k].second = _gap_to_chan_map[k2].second;
637 }
638 else
639 {
640 _chan_pairs_sf[k].second = _gap_to_chan_map[k2].first;
641 }
642 }
643 }
644
645 // set the _gij_map
646 for (unsigned int iz = 0; iz < _n_cells + 1; iz++)
647 {
648 for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
649 {
650 if (_gap_type[i_gap] == EChannelType::CENTER)
651 {
652 _gij_map[iz].push_back(_pitch - _pin_diameter);
653 }
654 else if (_gap_type[i_gap] == EChannelType::EDGE || _gap_type[i_gap] == EChannelType::CORNER)
655 {
656 _gij_map[iz].push_back(_duct_to_pin_gap);
657 }
658 }
659 }
660
661 for (unsigned int i = 0; i < _n_channels; i++)
662 {
664 {
665 for (unsigned int k = 0; k < 3; k++)
666 {
667 for (unsigned int j = 0; j < _n_gaps; j++)
668 {
669 if (_chan_to_gap_map[i][k] == j && i == _gap_to_chan_map[j].first)
670 {
671 if (i > _gap_to_chan_map[j].second)
672 {
673 _sign_id_crossflow_map[i][k] = negative_flow;
674 }
675 else
676 {
677 _sign_id_crossflow_map[i][k] = positive_flow;
678 }
679 }
680 else if (_chan_to_gap_map[i][k] == j && i == _gap_to_chan_map[j].second)
681 {
682 if (i > _gap_to_chan_map[j].first)
683 {
684 _sign_id_crossflow_map[i][k] = negative_flow;
685 }
686 else
687 {
688 _sign_id_crossflow_map[i][k] = positive_flow;
689 }
690 }
691 } // j
692 } // k
693 }
694 else if (_subch_type[i] == EChannelType::CORNER)
695 {
696 for (unsigned int k = 0; k < 2; k++)
697 {
698 for (unsigned int j = 0; j < _n_gaps; j++)
699 {
700 if (_chan_to_gap_map[i][k] == j && i == _gap_to_chan_map[j].first)
701 {
702 if (i > _gap_to_chan_map[j].second)
703 {
704 _sign_id_crossflow_map[i][k] = negative_flow;
705 }
706 else
707 {
708 _sign_id_crossflow_map[i][k] = positive_flow;
709 }
710 }
711 else if (_chan_to_gap_map[i][k] == j && i == _gap_to_chan_map[j].second)
712 {
713 if (i > _gap_to_chan_map[j].first)
714 {
715 _sign_id_crossflow_map[i][k] = negative_flow;
716 }
717 else
718 {
719 _sign_id_crossflow_map[i][k] = positive_flow;
720 }
721 }
722 } // j
723 } // k
724 } // subch_type =2
725 } // i
726
727 // set the subchannel positions
728 for (unsigned int i = 0; i < _n_channels; i++)
729 {
731 {
735 3.0;
739 3.0;
740 }
741 else if (_subch_type[i] == EChannelType::EDGE)
742 {
743 for (unsigned int j = 0; j < _n_channels; j++)
744 {
746 ((_chan_to_pin_map[i][0] == _chan_to_pin_map[j][0] &&
747 _chan_to_pin_map[i][1] == _chan_to_pin_map[j][1]) ||
748 (_chan_to_pin_map[i][0] == _chan_to_pin_map[j][1] &&
749 _chan_to_pin_map[i][1] == _chan_to_pin_map[j][0])))
750 {
751 x0 = _pin_position[_chan_to_pin_map[j][2]](0);
752 y0 = _pin_position[_chan_to_pin_map[j][2]](1);
753 }
754 else if (_subch_type[j] == EChannelType::CENTER &&
755 ((_chan_to_pin_map[i][0] == _chan_to_pin_map[j][0] &&
756 _chan_to_pin_map[i][1] == _chan_to_pin_map[j][2]) ||
757 (_chan_to_pin_map[i][0] == _chan_to_pin_map[j][2] &&
758 _chan_to_pin_map[i][1] == _chan_to_pin_map[j][0])))
759 {
760 x0 = _pin_position[_chan_to_pin_map[j][1]](0);
761 y0 = _pin_position[_chan_to_pin_map[j][1]](1);
762 }
763 else if (_subch_type[j] == EChannelType::CENTER &&
764 ((_chan_to_pin_map[i][0] == _chan_to_pin_map[j][1] &&
765 _chan_to_pin_map[i][1] == _chan_to_pin_map[j][2]) ||
766 (_chan_to_pin_map[i][0] == _chan_to_pin_map[j][2] &&
767 _chan_to_pin_map[i][1] == _chan_to_pin_map[j][1])))
768 {
769 x0 = _pin_position[_chan_to_pin_map[j][0]](0);
770 y0 = _pin_position[_chan_to_pin_map[j][0]](1);
771 }
772 x1 = 0.5 *
774 y1 = 0.5 *
776 a1 = _pin_diameter / 2.0 + _duct_to_pin_gap / 2.0;
777 a2 = std::sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)) + a1;
778 _subchannel_position[i][0] = (a2 * x1 - a1 * x0) / (a2 - a1);
779 _subchannel_position[i][1] = (a2 * y1 - a1 * y0) / (a2 - a1);
780 } // j
781 }
782 else if (_subch_type[i] == EChannelType::CORNER)
783 {
784 x0 = _pin_position[0](0);
785 y0 = _pin_position[0](1);
786 x1 = _pin_position[_chan_to_pin_map[i][0]](0);
787 y1 = _pin_position[_chan_to_pin_map[i][0]](1);
788 a1 = _pin_diameter / 2.0 + _duct_to_pin_gap / 2.0;
789 a2 = std::sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)) + a1;
790 _subchannel_position[i][0] = (a2 * x1 - a1 * x0) / (a2 - a1);
791 _subchannel_position[i][1] = (a2 * y1 - a1 * y0) / (a2 - a1);
792 }
793 }
794
795 // Reduce reserved memory in the channel-to-gap map.
796 for (auto & gap : _chan_to_gap_map)
797 {
798 gap.shrink_to_fit();
799 }
800}
801
802void
804{
805 if (_npins == 0)
806 return;
807
808 mesh_base.reserve_elem(_n_cells * _npins);
809 mesh_base.reserve_nodes((_n_cells + 1) * _npins);
810
811 _pin_nodes.clear();
812 _pin_nodes.resize(_npins);
813
814 // Defining the extent of the subchannel mesh to append the pin mesh to the current subchannel
815 // mesh.
816 const unsigned int node_sub = mesh_base.n_nodes();
817 const unsigned int elem_sub = mesh_base.n_elem();
818
819 // Add the points in the shape of a rectilinear grid. The grid is regular on the xy-plane at the
820 // triangular lattice pin positions. The grid along z is also regular. Store pointers in the
821 // _pin_nodes array so we can keep track of which points are in which pins.
822 unsigned int node_id = node_sub;
823 for (unsigned int i = 0; i < _npins; i++)
824 {
825 _pin_nodes[i].reserve(_n_cells + 1);
826 for (unsigned int iz = 0; iz < _n_cells + 1; iz++)
827 _pin_nodes[i].push_back(mesh_base.add_point(
828 Point(_pin_position[i](0), _pin_position[i](1), _z_grid[iz]), node_id++));
829 }
830
831 // Add the elements which in this case are 2-node edges that link each pin's nodes vertically.
832 unsigned int elem_id = elem_sub;
833 for (unsigned int i = 0; i < _npins; i++)
834 for (unsigned int iz = 0; iz < _n_cells; iz++)
835 {
836 Elem * elem = mesh_base.add_elem(std::make_unique<Edge2>());
837 elem->subdomain_id() = _pin_block_id;
838 elem->set_id(elem_id++);
839 const int indx1 = (_n_cells + 1) * i + iz + node_sub;
840 const int indx2 = (_n_cells + 1) * i + (iz + 1) + node_sub;
841 elem->set_node(0, mesh_base.node_ptr(indx1));
842 elem->set_node(1, mesh_base.node_ptr(indx2));
843 }
844
845 mesh_base.set_subdomain_name(_pin_block_id, "fuel_pins", true);
846}
847
848std::unique_ptr<MeshBase>
850{
851 auto mesh_base = buildMeshBaseObject();
852
853 BoundaryInfo & boundary_info = mesh_base->get_boundary_info();
854 mesh_base->set_spatial_dimension(3);
855 mesh_base->reserve_elem(_n_cells * (_n_channels + _npins));
856 mesh_base->reserve_nodes((_n_cells + 1) * (_n_channels + _npins));
857 _nodes.resize(_n_channels);
858 // Add the points for the give x,y subchannel positions. The grid is hexagonal.
859 // The grid along
860 // z is irregular to account for Pin spacers. Store pointers in the _nodes
861 // array so we can keep track of which points are in which channels.
862 unsigned int node_id = 0;
863 for (unsigned int i = 0; i < _n_channels; i++)
864 {
865 _nodes[i].reserve(_n_cells + 1);
866 for (unsigned int iz = 0; iz < _n_cells + 1; iz++)
867 {
868 _nodes[i].push_back(mesh_base->add_point(
869 Point(_subchannel_position[i][0], _subchannel_position[i][1], _z_grid[iz]), node_id++));
870 }
871 }
872
873 // Add the elements which in this case are 2-node edges that link each
874 // subchannel's nodes vertically.
875 unsigned int elem_id = 0;
876 for (unsigned int i = 0; i < _n_channels; i++)
877 {
878 for (unsigned int iz = 0; iz < _n_cells; iz++)
879 {
880 Elem * elem = mesh_base->add_elem(std::make_unique<Edge2>());
881 elem->subdomain_id() = _subchannel_block_id;
882 elem->set_id(elem_id++);
883 const int indx1 = (_n_cells + 1) * i + iz;
884 const int indx2 = (_n_cells + 1) * i + (iz + 1);
885 elem->set_node(0, mesh_base->node_ptr(indx1));
886 elem->set_node(1, mesh_base->node_ptr(indx2));
887
888 if (iz == 0)
889 boundary_info.add_side(elem, 0, 0);
890 if (iz == _n_cells - 1)
891 boundary_info.add_side(elem, 1, 1);
892 }
893 }
894 boundary_info.sideset_name(0) = "inlet";
895 boundary_info.sideset_name(1) = "outlet";
896 boundary_info.nodeset_name(0) = "inlet";
897 boundary_info.nodeset_name(1) = "outlet";
898
899 // Naming the block
900 mesh_base->set_subdomain_name(_subchannel_block_id, "subchannel", true);
901 buildPinMesh(*mesh_base);
902
903 mesh_base->prepare_for_use();
904
905 // move the meta data into TriSubChannelMesh
906 auto & sch_mesh = cast_ref<TriSubChannelMesh &>(*_mesh);
907 sch_mesh._unheated_length_entry = _unheated_length_entry;
908 sch_mesh._heated_length = _heated_length;
909 sch_mesh._unheated_length_exit = _unheated_length_exit;
910 sch_mesh._z_grid = _z_grid;
911 sch_mesh._k_grid = _k_grid;
912 sch_mesh._spacer_z = _spacer_z;
913 sch_mesh._spacer_k = _spacer_k;
914 sch_mesh._z_blockage = _z_blockage;
915 sch_mesh._index_blockage = _index_blockage;
916 sch_mesh._reduction_blockage = _reduction_blockage;
917 sch_mesh._kij = _kij;
918 sch_mesh._pitch = _pitch;
919 sch_mesh._pin_diameter = _pin_diameter;
920 sch_mesh._n_cells = _n_cells;
921 sch_mesh._n_rings = _n_rings;
922 sch_mesh._n_channels = _n_channels;
923 sch_mesh._flat_to_flat = _flat_to_flat;
924 sch_mesh._dwire = _dwire;
925 sch_mesh._hwire = _hwire;
926 sch_mesh._duct_to_pin_gap = _duct_to_pin_gap;
927 sch_mesh._nodes = _nodes;
928 sch_mesh._gap_to_chan_map = _gap_to_chan_map;
929 sch_mesh._gap_to_pin_map = _gap_to_pin_map;
930 sch_mesh._chan_to_gap_map = _chan_to_gap_map;
931 sch_mesh._sign_id_crossflow_map = _sign_id_crossflow_map;
932 sch_mesh._gij_map = _gij_map;
933 sch_mesh._subchannel_position = _subchannel_position;
934 sch_mesh._pin_position = _pin_position;
935 sch_mesh._pins_in_rings = _pins_in_rings;
936 sch_mesh._chan_to_pin_map = _chan_to_pin_map;
937 sch_mesh._npins = _npins;
938 sch_mesh._n_gaps = _n_gaps;
939 sch_mesh._subch_type = _subch_type;
940 sch_mesh._gap_type = _gap_type;
941 sch_mesh._gap_pairs_sf = _gap_pairs_sf;
942 sch_mesh._chan_pairs_sf = _chan_pairs_sf;
943 sch_mesh._pin_to_chan_map = _pin_to_chan_map;
944 sch_mesh._pin_nodes = _pin_nodes;
945 sch_mesh._pin_mesh_exist = (_npins > 0);
946 sch_mesh.computeAssemblyHydraulicParameters();
947
948 return mesh_base;
949}
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
registerMooseObject("SubChannelApp", SCMTriAssemblyMeshGenerator)
registerMooseObjectRenamed("SubChannelApp", SCMTriSubChannelMeshGenerator, "06/30/2027 24:00", SCMTriAssemblyMeshGenerator)
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 deprecateParam(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
MooseMesh *const _mesh
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
Mesh generator that builds a mesh of 1D lines representing subchannels and pins in a triangular assem...
const std::vector< Real > _reduction_blockage
area reduction of subchannels affected by blockage
std::vector< std::vector< Real > > _sign_id_crossflow_map
Defines the global cross-flow direction -1 or 1 for each subchannel and for all gaps that are belongi...
std::unique_ptr< MeshBase > generate() override
const Real _pitch
Distance between the neighbor fuel pins, pitch.
std::vector< std::vector< Node * > > _pin_nodes
pin nodes
const unsigned int _n_rings
number of rings of fuel pins
std::vector< std::vector< unsigned int > > _pin_to_chan_map
stores the map from pins to channels
const std::vector< Real > _k_blockage
form loss coefficient of subchannels affected by blockage
SCMTriAssemblyMeshGenerator(const InputParameters &parameters)
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_pin_map
stores the fuel pin pairs for each gap each gap
std::vector< std::vector< Real > > _subchannel_position
x,y coordinates of the subchannel centroids
const Real _heated_length
heated length of the fuel Pin
std::vector< std::pair< unsigned int, unsigned int > > _gap_pairs_sf
sweeping flow model gap pairs per channel to specify directional edge flow
std::vector< std::vector< Real > > _k_grid
axial form loss coefficient per computational cell
const std::vector< Real > & _spacer_k
form loss coefficient of the spacers
const Real _flat_to_flat
the distance between flat surfaces of the duct facing each other
const unsigned int _pin_block_id
pin block index
void buildPinMesh(MeshBase &mesh_base)
Build the 1D pin elements and append them to the subchannel mesh.
const std::vector< Real > _z_blockage
axial location of blockage (inlet, outlet) [m]
unsigned int _n_channels
number of subchannels
std::vector< std::pair< unsigned int, unsigned int > > _chan_pairs_sf
sweeping flow model channel pairs to specify directional edge flow
const std::vector< Real > & _spacer_z
axial location of the spacers
std::vector< std::vector< Real > > _pins_in_rings
fuel pins that are belonging to each ring
const Real _unheated_length_exit
unheated length of the fuel Pin at the exit of the assembly
std::vector< EChannelType > _subch_type
subchannel type
const unsigned int _subchannel_block_id
subchannel block index
std::vector< std::vector< Node * > > _nodes
nodes
std::vector< std::vector< Real > > _gij_map
gap size
std::vector< std::vector< unsigned int > > _chan_to_gap_map
stores the gaps that forms each subchannel
std::vector< Real > _z_grid
axial location of nodes
unsigned int _npins
number of fuel pins
std::vector< EChannelType > _gap_type
gap type
const Real _pin_diameter
fuel Pin diameter
const Real _duct_to_pin_gap
the gap thickness between the duct and peripheral fuel pins
const std::vector< unsigned int > _index_blockage
index of subchannels affected by blockage
const Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
const Real & _kij
Lateral form loss coefficient.
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_chan_map
stores the channel pairs for each gap
std::vector< Point > _pin_position
x,y coordinates of the fuel pins
std::vector< std::vector< unsigned int > > _chan_to_pin_map
stores the fuel pins belonging to each subchannel
const unsigned int _n_cells
number of axial cells
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.
static void pinPositions(std::vector< Point > &positions, unsigned int nrings, Real pitch, Point center)
Calculates and stores the pin positions/centers for a hexagonal assembly containing the given number ...