https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ReactorMeshParams.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
10#include "ReactorMeshParams.h"
11#include "CastUniquePointer.h"
13
14// libMesh includes
15#include "libmesh/mesh_generation.h"
16#include "libmesh/unstructured_mesh.h"
17#include "libmesh/replicated_mesh.h"
18#include "libmesh/point.h"
19#include "libmesh/elem.h"
20#include "libmesh/node.h"
21
23
26{
28 MooseEnum dims("2=2 3", "2");
29 params.addRequiredParam<MooseEnum>("dim", dims, "The dimension of the mesh to be generated");
30
31 MooseEnum geoms("Square Hex", "Square");
32 params.addRequiredParam<MooseEnum>("geom", geoms, "The geometry type of the reactor mesh");
33
34 params.addRequiredParam<Real>("assembly_pitch", "Center to center distance of assemblies");
35 params.addParam<boundary_id_type>("top_boundary_id",
36 "The boundary ID to set on top boundary of the extruded mesh");
37 params.addParam<boundary_id_type>(
38 "bottom_boundary_id", "The boundary ID to set on bottom boundary of the extruded mesh");
39 params.addParam<boundary_id_type>(
40 "radial_boundary_id",
41 "The boundary ID to set on the outer radial boundary of a CoreMeshGenerator object");
42 params.addParam<std::vector<Real>>("axial_regions", "Length of each axial region");
43 params.addParam<std::vector<unsigned int>>(
44 "axial_mesh_intervals", "Number of elements in the Z direction for each axial region");
45 params.addParam<bool>("region_id_as_block_name", false, "Set block names based on region id");
46 params.addParam<bool>(
47 "flexible_assembly_stitching",
48 false,
49 "Use FlexiblePatternGenerator for stitching dissimilar assemblies together");
50 params.addRangeCheckedParam<unsigned int>(
51 "num_sectors_at_flexible_boundary",
52 6,
53 "num_sectors_at_flexible_boundary>2",
54 "Number of sectors to use at assembly boundary interface when flexible patterning is used "
55 "(Defaults to 6)");
56 params.addClassDescription("This ReactorMeshParams object acts as storage for persistent "
57 "information about the reactor geometry.");
58
59 // Declare that this generator has a generateData method
61 // Declare that this generator has a generateCSG method
63 return params;
64}
65
67 : MeshGenerator(parameters),
68 _dim(getParam<MooseEnum>("dim")),
69 _geom(getParam<MooseEnum>("geom")),
70 _assembly_pitch(getParam<Real>("assembly_pitch"))
71{
72 if ((unsigned int)(_dim) == 2)
73 {
74 std::vector<std::string> invalid_params = {
75 "axial_regions", "axial_mesh_intervals", "top_boundary_id", "bottom_boundary_id"};
76 for (const auto & param : invalid_params)
77 if (isParamValid(param))
78 paramError(param, param + " should not be defined for 2-D meshes");
79 }
80 else
81 {
82 _axial_regions = getParam<std::vector<Real>>("axial_regions");
83 _axial_mesh_intervals = getParam<std::vector<unsigned int>>("axial_mesh_intervals");
84
85 if (_axial_regions.size() != _axial_mesh_intervals.size())
87 "The number of axial regions is not consistent with the number of axial intervals.");
89 this->declareMeshProperty(RGMB::axial_mesh_intervals, _axial_mesh_intervals);
90 }
91
92 this->declareMeshProperty(RGMB::mesh_dimensions, (unsigned int)std::stoul(_dim));
96 getParam<bool>(RGMB::region_id_as_block_name));
97
98 const bool flexible_assembly_stitching = getParam<bool>(RGMB::flexible_assembly_stitching);
99 this->declareMeshProperty(RGMB::flexible_assembly_stitching, flexible_assembly_stitching);
100 if (flexible_assembly_stitching)
102 getParam<unsigned int>("num_sectors_at_flexible_boundary"));
103 if (parameters.isParamSetByUser("num_sectors_at_flexible_boundary") &&
104 !flexible_assembly_stitching)
106 "num_sectors_at_flexible_boundary",
107 "This parameter is only relevant when ReactorMeshParams/flexible_assembly_stitching is set "
108 "to true. This value will be ignored");
109
110 // Option to bypass mesh generation depends on whether the current generator is in data only mode
111 bool bypass_meshgen = isDataOnly();
112 this->declareMeshProperty(RGMB::bypass_meshgen, bypass_meshgen);
113
114 if (isParamValid("top_boundary_id"))
115 {
116 _top_boundary = getParam<boundary_id_type>("top_boundary_id");
118 }
119 if (isParamValid("bottom_boundary_id"))
120 {
121 _bottom_boundary = getParam<boundary_id_type>("bottom_boundary_id");
123 }
124 if (isParamValid("radial_boundary_id"))
125 {
126 _radial_boundary = getParam<boundary_id_type>("radial_boundary_id");
128 if (isParamValid("top_boundary_id") && _radial_boundary == _top_boundary)
129 mooseError("top_boundary_id and radial_boundary_id must be unique values");
130 if (isParamValid("bottom_boundary_id") && _radial_boundary == _bottom_boundary)
131 mooseError("bottom_boundary_id and radial_boundary_id must be unique values");
132 }
133 if (isParamValid("top_boundary_id") && isParamValid("bottom_boundary_id") &&
135 mooseError("top_boundary_id and bottom_boundary_id must be unique values");
136}
137
138std::unique_ptr<MeshBase>
140{
141 // If mesh generation is requested and bypass_mesh is true, return a null mesh. generate()
142 // mesh should not be called with this option specified
143 if (getMeshProperty<bool>(RGMB::bypass_meshgen))
144 {
145 auto null_mesh = nullptr;
146 return null_mesh;
147 }
148 auto mesh = buildMeshBaseObject();
149 return dynamic_pointer_cast<MeshBase>(mesh);
150}
151
152std::unique_ptr<CSG::CSGBase>
154{
155 // This MeshGenerator does not produce a mesh, therefore return an empty CSGBase object
156 return std::make_unique<CSG::CSGBase>();
157}
registerMooseObject("ReactorApp", ReactorMeshParams)
bool isParamSetByUser(const std::string &name) const
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 void setHasGenerateCSG(InputParameters &params)
static InputParameters validParams()
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
static void setHasGenerateData(InputParameters &params)
bool isDataOnly() const
T & declareMeshProperty(const std::string &data_name, Args &&... args)
const InputParameters & parameters() const
void paramWarning(const std::string &param, Args... args) const
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
A class to store mesh information that is globally applicable to a reactor.
boundary_id_type _top_boundary
Boundary id assigned to top boundary of extruded mesh.
static InputParameters validParams()
std::vector< Real > _axial_regions
The heights of the axial regions.
ReactorMeshParams(const InputParameters &parameters)
std::unique_ptr< CSG::CSGBase > generateCSG() override
std::vector< unsigned int > _axial_mesh_intervals
The number of mesh divisions in each axial region.
std::unique_ptr< MeshBase > generate() override
const Real _assembly_pitch
The the flat-to-flat size of assemblies in the reactor.
boundary_id_type _bottom_boundary
Boundary id assigned to bottom boundary of extruded mesh.
boundary_id_type _radial_boundary
Boundary id assigned to outer radial boundary of core mesh.
const MooseEnum _geom
The geometry type for the reactor.
const MooseEnum _dim
The number of dimension in the mesh.
MeshBase & mesh
static const std::string bottom_boundary_id
static const std::string radial_boundary_id
static const std::string bypass_meshgen
static const std::string top_boundary_id
static const std::string assembly_pitch
static const std::string mesh_dimensions
static const std::string num_sectors_flexible_stitching
static const std::string flexible_assembly_stitching
static const std::string axial_mesh_sizes
static const std::string region_id_as_block_name
static const std::string axial_mesh_intervals
static const std::string mesh_geometry