https://mooseframework.inl.gov
TriInterWrapperMesh.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 "TriInterWrapperMesh.h"
11 #include <cmath>
12 #include "libmesh/node.h"
13 
15 
18 {
20  params.addClassDescription("Creates an inter-wrappper mesh container for a triangular "
21  "lattice subchannel arrangement");
22  return params;
23 }
24 
26 {
27 }
28 
30  : InterWrapperMesh(other_mesh),
31  _n_rings(other_mesh._n_rings),
32  _n_channels(other_mesh._n_channels),
33  _flat_to_flat(other_mesh._flat_to_flat),
34  _duct_to_pin_gap(other_mesh._duct_to_pin_gap),
35  _nodes(other_mesh._nodes),
36  _duct_nodes(other_mesh._duct_nodes),
37  _chan_to_duct_node_map(other_mesh._chan_to_duct_node_map),
38  _duct_node_to_chan_map(other_mesh._duct_node_to_chan_map),
39  _gap_to_chan_map(other_mesh._gap_to_chan_map),
40  _gap_to_pin_map(other_mesh._gap_to_pin_map),
41  _chan_to_gap_map(other_mesh._chan_to_gap_map),
42  _sign_id_crossflow_map(other_mesh._sign_id_crossflow_map),
43  _gij_map(other_mesh._gij_map),
44  _subchannel_position(other_mesh._subchannel_position),
45  _pin_position(other_mesh._pin_position),
46  _pins_in_rings(other_mesh._pins_in_rings),
47  _chan_to_pin_map(other_mesh._chan_to_pin_map),
48  _n_assemblies(other_mesh._n_assemblies),
49  _n_gaps(other_mesh._n_gaps),
50  _subch_type(other_mesh._subch_type),
51  _gap_type(other_mesh._gap_type),
52  _gap_pairs_sf(other_mesh._gap_pairs_sf),
53  _chan_pairs_sf(other_mesh._chan_pairs_sf),
54  _pin_to_chan_map(other_mesh._pin_to_chan_map),
55  _tight_side_bypass(other_mesh._tight_side_bypass)
56 {
57 }
58 
59 std::unique_ptr<MooseMesh>
61 {
62  return _app.getFactory().copyConstruct(*this);
63 }
64 
65 unsigned int
67 {
68  Real distance0 = 1.0e+8;
69  Real distance1;
70  unsigned int j = 0;
71 
72  for (unsigned int i = 0; i < _n_channels; i++)
73  {
74  distance1 = std::sqrt(std::pow((p(0) - _subchannel_position[i][0]), 2.0) +
75  std::pow((p(1) - _subchannel_position[i][1]), 2.0));
76 
77  if (distance1 < distance0)
78  {
79  j = i;
80  distance0 = distance1;
81  } // if
82  } // for
83  return j;
84 }
85 
86 unsigned int
87 TriInterWrapperMesh::channelIndex(const Point & /*point*/) const
88 {
89  mooseAssert(false, "This is not implemented");
90  return 0;
91 }
92 
93 void
95 {
96 }
97 
98 unsigned int
100 {
101  mooseAssert(false, "This is not implemented");
102  return 0;
103 }
104 
105 unsigned int
106 TriInterWrapperMesh::pinIndex(const Point & /*p*/) const
107 {
108  mooseAssert(false, "This is not implemented");
109  return 0;
110 }
111 
112 void
113 TriInterWrapperMesh::rodPositions(std::vector<Point> & positions,
114  unsigned int nrings,
115  Real assembly_pitch,
116  Point center)
117 {
119  // distance: it is the distance to the next Pin
120  //
121  Real theta = 0.0;
122  Real dtheta = 0.0;
123  Real distance = 0.0;
124  Real theta1 = 0.0;
125  Real theta_corrected = 0.0;
126  Real pi = libMesh::pi;
127  unsigned int k = 0;
128  positions.emplace_back(0.0, 0.0);
129  for (unsigned int i = 1; i < nrings; i++)
130  {
131  dtheta = 2.0 * pi / (i * 6);
132  theta = 0.0;
133  for (unsigned int j = 0; j < i * 6; j++)
134  {
135  k = k + 1;
136  theta1 = fmod(theta + 1.0e-10, pi / 3.0);
137  distance = std::sqrt(
138  (pow(i * assembly_pitch, 2) + pow(theta1 / dtheta * assembly_pitch, 2) -
139  2.0 * i * assembly_pitch * (theta1 / dtheta * assembly_pitch) * std::cos(pi / 3.0)));
140  theta_corrected = std::acos(1.0 / (i * assembly_pitch) / distance / 2.0 *
141  (std::pow(i * assembly_pitch, 2) + std::pow(distance, 2) -
142  std::pow(theta1 / dtheta * assembly_pitch, 2)));
143  if (theta1 < 1.0e-6)
144  {
145  theta_corrected = theta;
146  }
147  else
148  {
149  if (theta > pi / 3.0 && theta <= 2.0 / 3.0 * pi)
150  theta_corrected = theta_corrected + pi / 3.0;
151  else if (theta > 2.0 / 3.0 * pi && theta <= pi)
152  theta_corrected = theta_corrected + 2.0 / 3.0 * pi;
153  else if (theta > pi && theta <= 4.0 / 3.0 * pi)
154  theta_corrected = theta_corrected + pi;
155  else if (theta > 4.0 / 3.0 * pi && theta <= 5.0 / 3.0 * pi)
156  theta_corrected = theta_corrected + 4.0 / 3.0 * pi;
157  else if (theta > 5.0 / 3.0 * pi && theta <= 2.0 * pi)
158  theta_corrected = theta_corrected + 5.0 / 3.0 * pi;
159  }
160  positions.emplace_back(center(0) + distance * std::cos(theta_corrected),
161  center(1) + distance * std::sin(theta_corrected));
162  theta = theta + dtheta;
163  } // j
164  } // i
165 }
166 
167 void
168 TriInterWrapperMesh::setChannelToDuctMaps(const std::vector<Node *> & duct_nodes)
169 {
170  const Real tol = 1e-10;
171  for (size_t i = 0; i < duct_nodes.size(); i++)
172  {
173  int min_chan = 0;
174  Real min_dist = std::numeric_limits<double>::max();
175  Point ductpos((*duct_nodes[i])(0), (*duct_nodes[i])(1), 0);
176  for (size_t j = 0; j < _subchannel_position.size(); j++)
177  {
178  Point chanpos(_subchannel_position[j][0], _subchannel_position[j][1], 0);
179  auto dist = (chanpos - ductpos).norm();
180  if (dist < min_dist)
181  {
182  min_dist = dist;
183  min_chan = j;
184  }
185  }
186 
187  Node * chan_node = nullptr;
188  for (auto cn : _nodes[min_chan])
189  {
190  if (std::abs((*cn)(2) - (*duct_nodes[i])(2)) < tol)
191  {
192  chan_node = cn;
193  break;
194  }
195  }
196 
197  if (chan_node == nullptr)
198  mooseError("failed to find matching channel node for duct node");
199 
200  _duct_node_to_chan_map[duct_nodes[i]] = chan_node;
201  _chan_to_duct_node_map[chan_node] = duct_nodes[i];
202  }
203 
204  _duct_nodes = duct_nodes;
205 }
static InputParameters validParams()
TriInterWrapperMesh(const InputParameters &parameters)
std::vector< Node * > _duct_nodes
A list of all mesh nodes that form the (elements of) the hexagonal duct mesh that surrounds the pins/...
Base class for inter-wrapper meshes.
const double tol
static InputParameters validParams()
std::vector< std::vector< Real > > _subchannel_position
x,y coordinates of the interstice
static const std::string assembly_pitch
Real distance(const Point &p)
std::unique_ptr< T > copyConstruct(const T &object)
Factory & getFactory()
static void rodPositions(std::vector< Point > &positions, unsigned int nrings, Real assembly_pitch, Point center)
Calculates and stores the Pin positions/centers for a hexagonal assembly containing the given number ...
std::map< Node *, Node * > _duct_node_to_chan_map
A map for providing the closest/corresponding interstice node associated with each duct node...
registerMooseObject("SubChannelApp", TriInterWrapperMesh)
void setChannelToDuctMaps(const std::vector< Node *> &duct_nodes)
Setup the internal maps when there is a outside duct present.
auto norm(const T &a) -> decltype(std::abs(a))
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseApp & _app
virtual unsigned int getSubchannelIndexFromPoint(const Point &p) const override
Return a inter-wrapper index for a given physical point p
unsigned int _n_channels
number of subchannels
virtual unsigned int getPinIndexFromPoint(const Point &p) const override
Return a pin index for a given physical point p
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
virtual unsigned int pinIndex(const Point &p) const override
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< std::vector< Node * > > _nodes
nodes
virtual unsigned int channelIndex(const Point &point) const override
std::map< Node *, Node * > _chan_to_duct_node_map
A map for providing the closest/corresponding duct node associated with each interstice node...
Mesh class for triangular, edge and corner inter_wrappers for hexagonal lattice fuel assemblies...
MooseUnits pow(const MooseUnits &, int)
static const std::string k
Definition: NS.h:130
static const std::string center
Definition: NS.h:28
virtual void buildMesh() override
const Real pi
virtual std::unique_ptr< MooseMesh > safeClone() const override