modular_flux_calculator.cpp
1 #include "modular_flux_calculator.hpp"
3 #include "../../misc/utils.hpp"
4 
7  const RiemannSolver& rs):
8  sr_(sr), rs_(rs), interpolated_(vector<pair<ComputationalCell, ComputationalCell> >()) {}
9 
10 namespace
11 {
12  pair<Vector2D, Vector2D> calc_parallel_normal(const Tessellation& tess, const Edge& edge)
13  {
14  Vector2D n = normalize(tess.GetMeshPoint(edge.neighbors.second) - tess.GetMeshPoint(edge.neighbors.first));
15  return pair<Vector2D, Vector2D>(Vector2D(n.y, -n.x), n);
16  }
17 
18  Extensive convert_conserved_to_extensive(const Conserved& conserved, const pair<ComputationalCell, ComputationalCell>& cells)
19  {
20  Extensive res;
21  res.mass = conserved.Mass;
22  res.momentum = conserved.Momentum;
23  res.energy = conserved.Energy;
24  res.tracers.resize(cells.first.tracers.size());
25  size_t N = res.tracers.size();
26  for (size_t i = 0; i < N; ++i)
27  res.tracers[i] = conserved.Mass*(conserved.Mass>0 ? cells.first.tracers[i] : cells.second.tracers[i]);
28  return res;
29  }
30 
31 }
32 
33 vector<Extensive> ModularFluxCalculator::operator() (const Tessellation& tess, const vector<Vector2D>& edge_velocities,
34  const vector<ComputationalCell>& cells, const vector<Extensive>& /*extensives*/, const CacheData& cd,
35  const EquationOfState& eos, const double time, const double /*dt*/,
36  TracerStickerNames const& tracerstickernames) const
37 {
38  interpolated_.resize(static_cast<size_t>(tess.GetTotalSidesNumber()),
39  pair<ComputationalCell, ComputationalCell>(cells[0], cells[0]));
40  sr_(tess, cells, time, interpolated_, tracerstickernames,cd);
41  vector<bool> flags(static_cast<size_t>(tess.getAllEdges().size()), false);
42  vector<Extensive> res(tess.getAllEdges().size());
43  for (size_t i = 0; i < tess.getAllEdges().size(); ++i)
44  {
45  if (!flags.at(i))
46  {
47  flags.at(i) = true;
48  const pair<Vector2D, Vector2D> p_n = calc_parallel_normal(tess, tess.getAllEdges().at(i));
49  const Edge edge = tess.getAllEdges().at(i);
50  const double speed = ScalarProd(p_n.second, edge_velocities.at(i)) / abs(p_n.second);
51  const Primitive p_left =
53  (interpolated_.at(i).first, eos,tracerstickernames);
54  const Primitive p_right =
56  (interpolated_.at(i).second, eos,tracerstickernames);
57  res.at(i) =
58  convert_conserved_to_extensive
60  (rs_, p_left, p_right,
61  speed, p_n.second, p_n.first), interpolated_.at(i));
62  }
63  }
64  return res;
65 }
Set of conserved variables (extensive)
Extensive variables.
Definition: extensive.hpp:18
Vector2D Momentum
Momentum.
vector< Extensive > operator()(const Tessellation &tess, const vector< Vector2D > &edge_velocities, const vector< ComputationalCell > &cells, const vector< Extensive > &extensives, const CacheData &cd, const EquationOfState &eos, const double time, const double dt, TracerStickerNames const &tracerstickernames) const
Calculates fluxes.
Spatial reconstruction of the primitive functions.
Abstract class for tessellation.
Vector2D momentum
momentum, in relativity it is = rho*h*gamma*v
Definition: extensive.hpp:31
Primitive convert_to_primitive(const ComputationalCell &cell, const EquationOfState &eos, TracerStickerNames const &tracerstickernames)
Converts computational cell to primitive variables.
double mass
rest mass times gamma
Definition: extensive.hpp:25
Interface between two cells.
Definition: Edge.hpp:13
virtual Vector2D GetMeshPoint(int index) const =0
Returns Position of mesh generating point.
ModularFluxCalculator(const SpatialReconstruction &sr, const RiemannSolver &rs)
Class constructor.
double Energy
Total energy (kinetic + thermal)
double energy
energy, in relativity it is = rho*h*gamma^2-P-rho
Definition: extensive.hpp:28
double y
Component in the y direction.
Definition: geometry.hpp:48
Simple flux calculator.
Base class for Riemann solver.
tvector tracers
tracers
Definition: extensive.hpp:34
Conserved rotate_solve_rotate_back(const RiemannSolver &rs, const Primitive &left, const Primitive &right, const double velocity, const Vector2D &n, const Vector2D &p)
Rotates, solve riemann problem and rotates results back.
double ScalarProd(Vector3D const &v1, Vector3D const &v2)
Scalar product of two vectors.
Definition: Vector3D.cpp:185
virtual const vector< Edge > & getAllEdges(void) const =0
Returns reference to the list of all edges.
Base class for equation of state.
Container for cache data.
Definition: cache_data.hpp:14
Vector2D normalize(const Vector2D &v)
Normalized a vector.
Definition: geometry.cpp:158
Class for keeping the names of the tracers and stickers.
virtual int GetTotalSidesNumber(void) const =0
Returns the total number of faces.
std::pair< int, int > neighbors
Neighboring cells.
Definition: Edge.hpp:21
double abs(Vector3D const &v)
Norm of a vector.
Definition: Vector3D.cpp:44
Primitive hydrodynamic variables.
2D Mathematical vector
Definition: geometry.hpp:15
double x
Component in the x direction.
Definition: geometry.hpp:45