https://mooseframework.inl.gov
QuadSubChannelMesh.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 "QuadSubChannelMesh.h"
11 
12 #include <cmath>
13 
14 #include "libmesh/edge_edge2.h"
15 #include "libmesh/unstructured_mesh.h"
16 
17 registerMooseObject("SubChannelApp", QuadSubChannelMesh);
18 
21 {
23  params.addClassDescription("Creates an subchannel mesh container for a square "
24  "lattice arrangement");
25  return params;
26 }
27 
29  : SubChannelMesh(params), _pin_mesh_exist(false)
30 {
31 }
32 
34  : SubChannelMesh(other_mesh),
35  _nx(other_mesh._nx),
36  _ny(other_mesh._ny),
37  _n_channels(other_mesh._n_channels),
38  _n_gaps(other_mesh._n_gaps),
39  _n_pins(other_mesh._n_pins),
40  _gap(other_mesh._gap),
41  _nodes(other_mesh._nodes),
42  _gapnodes(other_mesh._gapnodes),
43  _gap_to_chan_map(other_mesh._gap_to_chan_map),
44  _gap_to_pin_map(other_mesh._gap_to_pin_map),
45  _chan_to_gap_map(other_mesh._chan_to_gap_map),
46  _chan_to_pin_map(other_mesh._chan_to_pin_map),
47  _pin_to_chan_map(other_mesh._pin_to_chan_map),
48  _sign_id_crossflow_map(other_mesh._sign_id_crossflow_map),
49  _gij_map(other_mesh._gij_map),
50  _pin_mesh_exist(other_mesh._pin_mesh_exist)
51 {
53  if (_nx < 2 && _ny < 2)
54  mooseError(name(),
55  ": The number of subchannels cannot be less than 2 in both directions (x and y). "
56  "Smallest assembly allowed is either 2X1 or 1X2. ");
57 }
58 
59 std::unique_ptr<MooseMesh>
61 {
62  return _app.getFactory().copyConstruct(*this);
63 }
64 
65 void
67 {
68 }
69 
70 unsigned int
72 {
73  Real offset_x = (_nx - 1) * _pitch / 2.0;
74  Real offset_y = (_ny - 1) * _pitch / 2.0;
75  unsigned int i = (p(0) + offset_x + 0.5 * _pitch) / _pitch;
76  unsigned int j = (p(1) + offset_y + 0.5 * _pitch) / _pitch;
77  return j * _nx + i;
78 }
79 
80 unsigned int
81 QuadSubChannelMesh::channelIndex(const Point & pt) const
82 {
83  // this is identical to getSubchannelIndexFromPoint, but when it is given a point "outside" the
84  // normal subchannel geometry (i.e. a point that lies in a gap around the lattice) we still report
85  // a valid subchannel index this is needed for transferring the solution onto a visualization mesh
86 
87  Real offset_x = (_nx - 1) * _pitch / 2.0;
88  Real offset_y = (_ny - 1) * _pitch / 2.0;
89  int i = (pt(0) + offset_x + 0.5 * _pitch) / _pitch;
90  int j = (pt(1) + offset_y + 0.5 * _pitch) / _pitch;
91 
92  i = std::max(0, i);
93  i = std::min(i, (int)(_nx - 1));
94 
95  j = std::max(0, j);
96  j = std::min(j, (int)(_ny - 1));
97 
98  return j * _nx + i;
99 }
100 
101 unsigned int
103 {
104  Real offset_x = (_nx - 2) * _pitch / 2.0;
105  Real offset_y = (_ny - 2) * _pitch / 2.0;
106  unsigned int i = (p(0) + offset_x) / _pitch;
107  unsigned int j = (p(1) + offset_y) / _pitch;
108  return j * (_nx - 1) + i;
109 }
110 
111 unsigned int
112 QuadSubChannelMesh::pinIndex(const Point & p) const
113 {
114  Real offset_x = (_nx - 2) * _pitch / 2.0;
115  Real offset_y = (_ny - 2) * _pitch / 2.0;
116  unsigned int i = (p(0) + offset_x) / _pitch;
117  unsigned int j = (p(1) + offset_y) / _pitch;
118  return j * (_nx - 1) + i;
119 }
120 
121 void
123  unsigned int nx, unsigned int ny, Real pitch, Real elev, std::vector<Point> & pin_centers)
124 {
125  mooseAssert(nx >= 2, "Number of channels in x-direction must be 2 or more.");
126  mooseAssert(ny >= 2, "Number of channels in y-direction must be 2 or more.");
127 
128  Real offset_x = (nx - 2) * pitch / 2.0;
129  Real offset_y = (ny - 2) * pitch / 2.0;
130  for (unsigned int iy = 0; iy < ny - 1; iy++)
131  for (unsigned int ix = 0; ix < nx - 1; ix++)
132  pin_centers.push_back(Point(pitch * ix - offset_x, pitch * iy - offset_y, elev));
133 }
static InputParameters validParams()
registerMooseObject("SubChannelApp", QuadSubChannelMesh)
virtual unsigned int pinIndex(const Point &p) const override
virtual std::unique_ptr< MooseMesh > safeClone() const override
unsigned int _ny
number of subchannels in the y direction
Creates the mesh of subchannels in a quadrilateral lattice.
std::vector< std::vector< Real > > _subchannel_position
x,y coordinates of the subchannel centroids
virtual const std::string & name() const
virtual unsigned int channelIndex(const Point &point) const override
std::unique_ptr< T > copyConstruct(const T &object)
Factory & getFactory()
virtual void buildMesh() override
unsigned int getSubchannelIndexFromPoint(const Point &p) const override
Return a subchannel index for a given physical point p
static const std::string pitch
Real _pitch
Distance between the neighbor fuel pins, pitch.
static void generatePinCenters(unsigned int nx, unsigned int ny, Real pitch, Real elev, std::vector< Point > &pin_centers)
Generate pin centers.
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseApp & _app
QuadSubChannelMesh(const InputParameters &parameters)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
unsigned int getPinIndexFromPoint(const Point &p) const override
Return a pin index for a given physical point p
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
Base class for subchannel meshes.
unsigned int _nx
number of subchannels in the x direction