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