RigidWallGenerator.cpp
1 #include "RigidWallGenerator.hpp"
2 
3 namespace
4 {
5  void ReverseNormalVelocity(ComputationalCell &cell, Edge const& edge, size_t index, Tessellation const& tess)
6  {
7  Vector2D normal;
8  if (index == 1)
9  normal = tess.GetMeshPoint(edge.neighbors.first) - tess.GetMeshPoint(edge.neighbors.second);
10  else
11  normal = tess.GetMeshPoint(edge.neighbors.second) - tess.GetMeshPoint(edge.neighbors.first);
12  normal = normal / abs(normal);
13  cell.velocity -= 2 * ScalarProd(cell.velocity, normal)*normal;
14  }
15 }
16 
17 boost::container::flat_map<size_t, ComputationalCell> RigidWallGenerator::operator() (const Tessellation& tess,
18  const vector<ComputationalCell>& cells, double /*time*/,TracerStickerNames const& /*tracerstickernames*/) const
19 {
20  boost::container::flat_map<size_t, ComputationalCell> res;
21  vector<std::pair<size_t, size_t> > ghosts = GetOuterEdgesIndeces(tess);
22  for (size_t i = 0; i < ghosts.size(); ++i)
23  {
24  Edge const& edge = tess.GetEdge(static_cast<int>(ghosts[i].first));
25  size_t ghost_index = ghosts[i].second == 1 ? static_cast<size_t> (edge.neighbors.first)
26  : static_cast<size_t>(edge.neighbors.second);
27  if (tess.GetOriginalIndex(static_cast<int>(ghost_index)) < tess.GetPointNo())
28  {
29  ComputationalCell ctemp = cells[static_cast<size_t>(ghosts[i].second == 2 ? edge.neighbors.first : edge.neighbors.second)];
30  ReverseNormalVelocity(ctemp, edge, ghosts[i].second, tess);
31  res.insert(std::pair<size_t, ComputationalCell>(ghost_index, ctemp));
32  }
33  else
34  res.insert(std::pair<size_t, ComputationalCell>(ghost_index, cells[ghost_index]));
35  }
36  return res;
37 }
38 
40 (Tessellation const& tess,
41  vector<ComputationalCell> const& cells,
42  vector<Slope> const& /*gradients*/,
43  size_t ghost_index, double /*time*/, Edge const& /*edge*/, TracerStickerNames const& /*tracerstickernames*/) const
44 {
45  ComputationalCell cell(cells[static_cast<size_t>(tess.GetOriginalIndex(static_cast<int>(ghost_index)))]);
46  cell.density = 0;
47  cell.pressure = 0;
48  cell.velocity = Vector2D(0, 0);
49  cell.tracers = cells[0].tracers;
50  size_t N = cell.tracers.size();
51  for (size_t i = 0; i < N; ++i)
52  cell.tracers[i] = 0;
53  return Slope(cell, cell);
54 }
boost::container::flat_map< size_t, ComputationalCell > operator()(const Tessellation &tess, const vector< ComputationalCell > &cells, double time, TracerStickerNames const &tracerstickernames) const
Calculates the ghost points.
Abstract class for tessellation.
virtual int GetPointNo(void) const =0
Get Total number of mesh generating points.
virtual int GetOriginalIndex(int point) const
Returns the original index of the duplicated point.
Definition: tessellation.cpp:5
Slope GetGhostGradient(const Tessellation &tess, const vector< ComputationalCell > &cells, const vector< Slope > &gradients, size_t ghost_index, double time, const Edge &edge, TracerStickerNames const &tracerstickernames) const
Calculates the gradients for the ghost cells.
Interface between two cells.
Definition: Edge.hpp:13
virtual Vector2D GetMeshPoint(int index) const =0
Returns Position of mesh generating point.
Class for spatial interpolations.
tvector tracers
Tracers (can transfer from one cell to another)
virtual Edge const & GetEdge(int index) const =0
Returns edge (interface between cells)
double pressure
Pressure.
vector< std::pair< size_t, size_t > > GetOuterEdgesIndeces(Tessellation const &tess) const
Finds the indeces of the outer edges points.
double ScalarProd(Vector3D const &v1, Vector3D const &v2)
Scalar product of two vectors.
Definition: Vector3D.cpp:185
Class for creating computationalcells of ghost points for rigid walls.
Class for keeping the names of the tracers and stickers.
std::pair< int, int > neighbors
Neighboring cells.
Definition: Edge.hpp:21
double abs(Vector3D const &v)
Norm of a vector.
Definition: Vector3D.cpp:44
Vector2D velocity
Velocity.
2D Mathematical vector
Definition: geometry.hpp:15
Computational cell.