https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SCMTriCoreMeshGenerator.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 "MooseUtils.h"
12
13#include <array>
14#include <cmath>
15
17
20{
23 "Places triangular-lattice subchannel assembly meshes on a hexagonal core lattice. Each "
24 "assembly keeps its own subdomains and boundaries; assemblies are not connected.");
25 params.setDocString(
26 "inputs",
27 "The SCMTriAssemblyMeshGenerator, SCMTriDuctMeshGenerator, or "
28 "SCMTriVisualizationAssemblyMeshGenerator meshes that can be placed in the core");
29 params.setDocString(
30 "pattern",
31 "Hexagonal core pattern of indices into 'inputs', using the row syntax of "
32 "PatternedHexMeshGenerator; -1 marks an empty position. Row i is placed as the i-th column "
33 "from -x, and the entries of a row are placed from -y to +y.");
34 return params;
35}
36
38 : SCMCoreMeshGeneratorBase(parameters)
39{
40 const auto n_rows = _pattern.size();
41 if (n_rows == 0)
42 paramError("pattern", "The pattern must contain at least one row.");
43 if (n_rows % 2 == 0)
44 paramError("pattern", "A hexagonal pattern must have an odd number of rows.");
45
46 // Number of positions along each side of the hexagonal pattern
47 const auto n_side = (n_rows + 1) / 2;
48 for (const auto i : index_range(_pattern))
49 {
50 const auto row_length = n_side + std::min(i, n_rows - 1 - i);
51 if (_pattern[i].size() != row_length)
52 paramError("pattern",
53 "Row ",
54 i,
55 " has ",
56 _pattern[i].size(),
57 " entries; a hexagonal pattern with ",
58 n_rows,
59 " rows requires ",
60 row_length,
61 ".");
62
63 for (const auto j : index_range(_pattern[i]))
64 {
65 // The SCM assemblies have a duct corner on the +x axis, so their flat normals point at 30,
66 // 90 and 150 degrees. Placing rows as columns, with neighboring columns offset by half a
67 // pitch, puts every pair of neighboring positions along one of those normals.
68 const Real x = (Real(i) - Real(n_side - 1)) * _assembly_pitch * std::sqrt(3.0) / 2.0;
69 const Real y = (Real(j) - 0.5 * Real(row_length - 1)) * _assembly_pitch;
70 addAssembly(_pattern[i][j], Point(x, y, 0.0));
71 }
72 }
73
74 if (_assemblies.empty())
75 paramError("pattern", "The pattern must contain at least one assembly.");
76}
77
78void
80{
81 for (const auto & input_name : _input_names)
82 {
83 if (!hasMeshProperty<Real>("flat_to_flat", input_name))
84 paramError("inputs",
85 "Input '",
86 input_name,
87 "' does not provide 'flat_to_flat' metadata. Inputs must be "
88 "SCMTriAssemblyMeshGenerator, SCMTriDuctMeshGenerator, or "
89 "SCMTriVisualizationAssemblyMeshGenerator objects.");
90 _flat_to_flat.push_back(getMeshProperty<Real>("flat_to_flat", input_name));
91 }
92}
93
94bool
95SCMTriCoreMeshGenerator::overlap(const unsigned int input_a,
96 const unsigned int input_b,
97 const Point & offset) const
98{
99 // The ducts are hexagons with the same orientation, and the set of center offsets at which two
100 // of them overlap is a hexagon of that orientation whose apothem is the sum of their apothems.
101 // They therefore overlap if and only if the center offset projected on every flat normal is
102 // shorter than the sum of the apothems.
103 const std::array<Point, 3> flat_normals = {Point(std::sqrt(3.0) / 2.0, 0.5, 0.0),
104 Point(0.0, 1.0, 0.0),
105 Point(-std::sqrt(3.0) / 2.0, 0.5, 0.0)};
106 // Ducts that exactly touch (assembly_pitch equal to the flat-to-flat size) are allowed; the
107 // tolerance, relative to the pitch, absorbs roundoff in the lattice coordinates.
109 const Real sum_apothems = 0.5 * (_flat_to_flat[input_a] + _flat_to_flat[input_b]);
110 for (const auto & normal : flat_normals)
111 if (!MooseUtils::absoluteFuzzyLessThan(std::abs(offset * normal), sum_apothems, tol))
112 return false;
113 return true;
114}
const std::vector< double > y
const double tol
const std::vector< double > x
registerMooseObject("SubChannelApp", SCMTriCoreMeshGenerator)
void setDocString(const std::string &name, const std::string &doc)
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
Base class for mesh generators that place SCM assembly meshes on a core lattice and merge them into o...
const Real _assembly_pitch
Center-to-center distance between neighboring assembly positions [m].
static InputParameters validParams()
const std::vector< std::vector< int > > & _pattern
Core pattern of indices into the inputs; -1 marks an empty position.
std::vector< std::pair< unsigned int, Point > > _assemblies
Placed assemblies in pattern order: (index into the inputs, x-y center of the assembly)
void addAssembly(int entry, const Point &center)
Check that a pattern entry is -1 or a valid input index and, if it is an index, place that input at c...
const std::vector< MeshGeneratorName > & _input_names
Names of the input SCM 1D assembly, duct, or 3D visualization assembly mesh generators.
Places triangular-lattice SCM assembly meshes on a hexagonal core lattice and merges them into one me...
SCMTriCoreMeshGenerator(const InputParameters &parameters)
static InputParameters validParams()
std::vector< Real > _flat_to_flat
Flat-to-flat duct size of each input [m].
bool overlap(unsigned int input_a, unsigned int input_b, const Point &offset) const override
Whether the ducts of two inputs overlap when their centers are offset apart.
void readAssemblySizes() override
Read the duct size metadata of every input.
static constexpr Real TOLERANCE