https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SCMQuadCoreMeshGenerator.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 <cmath>
14
16
19{
22 "Places square-lattice subchannel assembly meshes on a rectangular core lattice. Each "
23 "assembly keeps its own subdomains and boundaries; assemblies are not connected.");
24 params.setDocString(
25 "inputs",
26 "The SCMQuadAssemblyMeshGenerator, SCMQuadDuctMeshGenerator, or "
27 "SCMQuadVisualizationAssemblyMeshGenerator meshes that can be placed in the core");
28 params.setDocString(
29 "pattern",
30 "Rectangular core pattern of indices into 'inputs', using the row syntax of "
31 "PatternedCartesianMeshGenerator; -1 marks an empty position. All rows must have the same "
32 "length. The first row is placed at +y and the entries of a row are placed from -x to +x.");
33 return params;
34}
35
37 : SCMCoreMeshGeneratorBase(parameters)
38{
39 const auto n_rows = _pattern.size();
40 if (n_rows == 0)
41 paramError("pattern", "The pattern must contain at least one row.");
42
43 const auto n_columns = _pattern[0].size();
44 if (n_columns == 0)
45 paramError("pattern", "Row 0 is empty; every row must contain at least one entry.");
46 for (const auto i : index_range(_pattern))
47 {
48 if (_pattern[i].size() != n_columns)
49 paramError("pattern",
50 "Row ",
51 i,
52 " has ",
53 _pattern[i].size(),
54 " entries; all rows of a rectangular pattern must have the ",
55 n_columns,
56 " entries of the first row.");
57
58 // The lattice is centered on the origin
59 for (const auto j : index_range(_pattern[i]))
60 {
61 const Real x = (Real(j) - 0.5 * Real(n_columns - 1)) * _assembly_pitch;
62 const Real y = (0.5 * Real(n_rows - 1) - Real(i)) * _assembly_pitch;
63 addAssembly(_pattern[i][j], Point(x, y, 0.0));
64 }
65 }
66
67 if (_assemblies.empty())
68 paramError("pattern", "The pattern must contain at least one assembly.");
69}
70
71void
73{
74 for (const auto & input_name : _input_names)
75 {
76 if (!hasMeshProperty<Real>("duct_size_x", input_name) ||
77 !hasMeshProperty<Real>("duct_size_y", input_name))
78 paramError("inputs",
79 "Input '",
80 input_name,
81 "' does not provide 'duct_size_x' and 'duct_size_y' metadata. Inputs must be "
82 "SCMQuadAssemblyMeshGenerator, SCMQuadDuctMeshGenerator, or "
83 "SCMQuadVisualizationAssemblyMeshGenerator objects.");
84 _duct_size.emplace_back(getMeshProperty<Real>("duct_size_x", input_name),
85 getMeshProperty<Real>("duct_size_y", input_name));
86 }
87}
88
89bool
90SCMQuadCoreMeshGenerator::overlap(const unsigned int input_a,
91 const unsigned int input_b,
92 const Point & offset) const
93{
94 // Two axis-aligned rectangles overlap if and only if their center offset is shorter than the
95 // sum of their half widths in x and shorter than the sum of their half heights in y. Ducts that
96 // exactly touch are allowed; the tolerance, relative to the pitch, absorbs roundoff in the
97 // lattice coordinates.
99 const Real half_x = 0.5 * (_duct_size[input_a].first + _duct_size[input_b].first);
100 const Real half_y = 0.5 * (_duct_size[input_a].second + _duct_size[input_b].second);
101 return MooseUtils::absoluteFuzzyLessThan(std::abs(offset(0)), half_x, tol) &&
102 MooseUtils::absoluteFuzzyLessThan(std::abs(offset(1)), half_y, tol);
103}
const std::vector< double > y
const double tol
const std::vector< double > x
registerMooseObject("SubChannelApp", SCMQuadCoreMeshGenerator)
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 square-lattice SCM assembly meshes on a rectangular core lattice and merges them into one mesh...
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.
SCMQuadCoreMeshGenerator(const InputParameters &parameters)
void readAssemblySizes() override
Read the duct size metadata of every input.
std::vector< std::pair< Real, Real > > _duct_size
Outer duct width (x) and height (y) of each input [m].
static InputParameters validParams()
static constexpr Real TOLERANCE