https://mooseframework.inl.gov
DetailedPinMeshGeneratorBase.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 "libmesh/cell_prism6.h"
12 
15 {
17  params.addClassDescription(
18  "Base Class used to create the detailed pin mesh in a square lattice arrangement");
19  params.addRequiredParam<Real>("pitch", "Pitch [m]");
20  params.addRequiredParam<Real>("pin_diameter", "Rod diameter [m]");
21  params.addParam<Real>("unheated_length_entry", 0.0, "Unheated length at entry [m]");
22  params.addRequiredParam<Real>("heated_length", "Heated length [m]");
23  params.addParam<Real>("unheated_length_exit", 0.0, "Unheated length at exit [m]");
24  params.addRequiredParam<unsigned int>("n_cells", "The number of cells in the axial direction");
25  params.addParam<unsigned int>("block_id", 1, "Block ID used for the mesh subdomain.");
26  params.addRangeCheckedParam<unsigned int>("num_radial_parts",
27  16,
28  "num_radial_parts>=4",
29  "Number of radial parts (must be at least 4).");
30  return params;
31 }
32 
34  : MeshGenerator(parameters),
35  _unheated_length_entry(getParam<Real>("unheated_length_entry")),
36  _heated_length(getParam<Real>("heated_length")),
37  _unheated_length_exit(getParam<Real>("unheated_length_exit")),
38  _pitch(getParam<Real>("pitch")),
39  _pin_diameter(getParam<Real>("pin_diameter")),
40  _n_cells(getParam<unsigned int>("n_cells")),
41  _block_id(getParam<unsigned int>("block_id")),
42  _num_radial_parts(getParam<unsigned int>("num_radial_parts"))
43 {
45  Real dz = L / _n_cells;
46  for (unsigned int i = 0; i < _n_cells + 1; i++)
47  _z_grid.push_back(dz * i);
48 }
49 
50 void
51 DetailedPinMeshGeneratorBase::generatePin(std::unique_ptr<MeshBase> & mesh_base,
52  const Point & center)
53 {
54  const Real dalpha = 360. / _num_radial_parts;
55  Real radius = _pin_diameter / 2.;
56 
57  // nodes
58  std::vector<std::vector<Node *>> nodes;
59  nodes.resize(_n_cells + 1);
60  for (unsigned int k = 0; k < _n_cells + 1; k++)
61  {
62  const Real elev = _z_grid[k];
63  // center node
64  nodes[k].push_back(mesh_base->add_point(Point(center(0), center(1), elev)));
65  // ring around the center
66  Real alpha = 0.;
67  for (unsigned int i = 0; i < _num_radial_parts; i++, alpha += dalpha)
68  {
69  const Real dx = radius * std::cos(alpha * M_PI / 180.);
70  const Real dy = radius * std::sin(alpha * M_PI / 180.);
71  Point pt(center(0) + dx, center(1) + dy, elev);
72  nodes[k].push_back(mesh_base->add_point(pt));
73  }
74  }
75 
76  // elements
77  for (unsigned int k = 0; k < _n_cells; k++)
78  {
79  for (unsigned int i = 0; i < _num_radial_parts; i++)
80  {
81  Elem * elem = new Prism6;
82  elem->subdomain_id() = _block_id;
83  elem->set_id(_elem_id++);
84  mesh_base->add_elem(elem);
85  const unsigned int ctr_idx = 0;
86  const unsigned int idx1 = (i % _num_radial_parts) + 1;
87  const unsigned int idx2 = ((i + 1) % _num_radial_parts) + 1;
88  elem->set_node(0, nodes[k][ctr_idx]);
89  elem->set_node(1, nodes[k][idx1]);
90  elem->set_node(2, nodes[k][idx2]);
91  elem->set_node(3, nodes[k + 1][ctr_idx]);
92  elem->set_node(4, nodes[k + 1][idx1]);
93  elem->set_node(5, nodes[k + 1][idx2]);
94  }
95  }
96 }
const unsigned int _n_cells
Number of cells in the axial direction.
const Real radius
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
DetailedPinMeshGeneratorBase(const InputParameters &parameters)
const unsigned int & _num_radial_parts
Number of radial parts.
const Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
void addRequiredParam(const std::string &name, const std::string &doc_string)
dof_id_type _elem_id
Counter for element numbering.
const Real _heated_length
heated length of the fuel Pin
const Real _unheated_length_exit
unheated length of the fuel Pin at the exit of the assembly
void generatePin(std::unique_ptr< MeshBase > &mesh_base, const Point &center)
std::vector< Real > _z_grid
axial location of nodes
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string alpha
Definition: NS.h:134
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 const std::string k
Definition: NS.h:130
void ErrorVector unsigned int
const unsigned int & _block_id
Subdomain ID used for the mesh block.
static const std::string center
Definition: NS.h:28
const Real _pin_diameter
fuel Pin diameter