13 #include "libmesh/face_quad4.h" 14 #include "libmesh/unstructured_mesh.h" 27 "Creates a mesh of 1D duct cells around a triangular lattice subassembly");
28 params.
addRequiredParam<MeshGeneratorName>(
"input",
"The corresponding subchannel mesh");
29 params.
addParam<
unsigned int>(
"block_id", 2,
"Domain Index");
30 params.
addRequiredParam<
unsigned int>(
"n_cells",
"The number of cells in the axial direction");
31 params.
addParam<
Real>(
"unheated_length_entry", 0.0,
"Unheated length at entry [m]");
33 params.
addParam<
Real>(
"unheated_length_exit", 0.0,
"Unheated length at exit [m]");
35 params.
addRequiredParam<
unsigned int>(
"nrings",
"Number of fuel Pin rings per assembly [-]");
37 "Flat to flat distance for the hexagonal assembly [m]");
44 _n_cells(getParam<unsigned
int>(
"n_cells")),
45 _unheated_length_entry(getParam<
Real>(
"unheated_length_entry")),
46 _heated_length(getParam<
Real>(
"heated_length")),
47 _unheated_length_exit(getParam<
Real>(
"unheated_length_exit")),
48 _block_id(getParam<unsigned
int>(
"block_id")),
49 _pitch(getParam<
Real>(
"pitch")),
50 _n_rings(getParam<unsigned
int>(
"nrings")),
51 _flat_to_flat(getParam<
Real>(
"flat_to_flat"))
57 std::unique_ptr<MeshBase>
60 std::unique_ptr<MeshBase> mesh_base = std::move(
_input);
62 mooseError(
"SCMTriDuctMeshGenerator has to be connected to a sub channel mesh generator.");
64 mesh_base->set_mesh_dimension(3);
66 std::vector<Point> corners;
68 std::vector<Point> xsec;
70 std::vector<Point> points;
72 std::vector<std::vector<size_t>> elem_point_indices;
74 std::vector<Node *> duct_nodes;
78 mesh_base->prepare_for_use();
82 sch_mesh._duct_mesh_exist =
true;
90 const Point &
center)
const 97 Point
corner = {r_corner * std::cos(theta), r_corner * std::sin(theta)};
104 const std::vector<Point> & corners,
107 Real flat_to_flat)
const 113 Real side_length = (corners[0] - corners[1]).
norm();
115 for (
size_t i = 0; i < corners.size(); i++)
117 auto left = corners[i];
118 auto right = corners[(i + 1) % corners.size()];
119 xsec.push_back(left);
120 auto direc = (right - left).unit();
121 for (
Real offset_from_corner = start_offset; offset_from_corner < side_length;
122 offset_from_corner +=
pitch)
123 xsec.push_back(left + direc * offset_from_corner);
130 unsigned int point)
const 132 return layer * points_per_layer + point;
137 const std::vector<Point> & xsec,
138 const std::vector<Real> & z_layers)
const 140 points.resize(xsec.size() * z_layers.size());
141 for (
size_t i = 0; i < z_layers.size(); i++)
142 for (
size_t j = 0;
j < xsec.size();
j++)
143 points[
ductPointIndex(xsec.size(), i,
j)] = Point(xsec[
j](0), xsec[
j](1), z_layers[i]);
148 unsigned int n_layers,
149 unsigned int points_per_layer)
const 151 elem_point_indices.clear();
152 for (
unsigned int i = 0; i < n_layers - 1; i++)
154 unsigned int bottom = i;
155 unsigned int top = i + 1;
156 for (
unsigned int j = 0;
j < points_per_layer;
j++)
158 unsigned int left =
j;
159 unsigned int right = (
j + 1) % points_per_layer;
160 elem_point_indices.push_back({
ductPointIndex(points_per_layer, bottom, left),
170 std::vector<Node *> & duct_nodes,
171 const std::vector<Point> & points,
172 const std::vector<std::vector<size_t>> & elem_point_indices,
175 for (
size_t i = 0; i < points.size(); i++)
176 duct_nodes.push_back(
mesh->add_point(points[i]));
178 for (
auto & elem_indices : elem_point_indices)
180 auto elem =
mesh->add_elem(
new Quad4());
181 elem->subdomain_id() = block;
182 for (
size_t i = 0; i < elem_indices.size(); i++)
183 elem->set_node(i, duct_nodes[elem_indices[i]]);
void ductElems(std::vector< std::vector< size_t >> &elem_point_indices, unsigned int n_layers, unsigned int points_per_layer) const
Calculates the groups of points/nodes that comprise each element in the duct mesh.
const Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
T & getMesh(MooseMesh &mesh)
function to cast mesh
void setChannelToDuctMaps(const std::vector< Node *> &duct_nodes)
Function that gets the channel node from the duct node.
static const unsigned int N_CORNERS
number of corners in the duct x-sec
std::unique_ptr< MeshBase > generate() override
virtual const std::string & name() const
const Real _flat_to_flat
the distance between flat surfaces of the duct facing each other
const Real _unheated_length_exit
unheated length of the fuel Pin at the exit of the assembly
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 InputParameters validParams()
const unsigned int _n_cells
number of axial cells
static const std::string pitch
const unsigned int _block_id
block index
registerMooseObject("SubChannelApp", SCMTriDuctMeshGenerator)
std::unique_ptr< MeshBase > & _input
Mesh that comes from another generator.
registerMooseObjectRenamed("SubChannelApp", TriDuctMeshGenerator, "06/30/2025 24:00", SCMTriDuctMeshGenerator)
static InputParameters validParams()
void buildDuct(std::unique_ptr< MeshBase > &mesh, std::vector< Node *> &duct_nodes, const std::vector< Point > &points, const std::vector< std::vector< size_t >> &elem_point_indices, SubdomainID block) const
buildDuct generates and adds mesh node and element objects to the given mesh corresponding to the giv...
const Real _pitch
Distance between the neighbor fuel pins, pitch.
Mesh class for triangular, edge and corner subchannels for hexagonal lattice fuel assemblies...
const unsigned int _n_rings
number of rings of fuel pins
void ductPoints(std::vector< Point > &points, const std::vector< Point > &xsec, const std::vector< Real > &z_layers) const
Calculates all the point/node positions that will be used to form elements making the duct...
SCMTriDuctMeshGenerator(const InputParameters ¶meters)
void ductCorners(std::vector< Point > &corners, Real flat_to_flat, const Point ¢er) const
calculate the x-y coordinates of the corner points for the duct cross section.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< Real > _z_grid
axial location of nodes
void mooseError(Args &&... args) const
size_t ductPointIndex(unsigned int points_per_layer, unsigned int layer, unsigned int point) const
Returns an index into the vector of point/node positions used/generated by ductPoints.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const Real _heated_length
heated length of the fuel Pin
void ErrorVector unsigned int
static const std::string center
void ductXsec(std::vector< Point > &xsec, const std::vector< Point > &corners, unsigned int nrings, Real pitch, Real flat_to_flat) const
calcultes the points around the duct cross section boundary (perpendicular to z axis) using assembly ...
Mesh generator for hexagonal duct.