2 #include "../common/hydrodynamics.hpp" 3 #include "../../tessellation/geometry.hpp" 4 #include "../../misc/utils.hpp" 35 template<
class S,
class T>
class Transform
41 virtual ~Transform(
void) {}
44 class CellIndexValidator :
public Transform<int, bool>
48 explicit CellIndexValidator(
const int point_no) :
49 point_no_(point_no) {}
53 return index >= 0 && index < point_no_;
60 template<
class S,
class T> std::pair<T, T> transform_pair
61 (
const std::pair<S, S>& s,
const Transform<S, T>& t)
63 return std::pair<T, T>(t(s.first), t(s.second));
66 class RiemannProblemInput
76 RiemannProblemInput(
void) :
77 left(), right(), velocity(0), n(), p() {}
80 RiemannProblemInput riemann_reduce
82 const vector<Vector2D>& edge_velocities,
83 const vector<ComputationalCell>& cells,
85 const size_t& edge_index,
90 RiemannProblemInput res;
92 res.p *= 1.0/
abs(res.p);
95 res.n *= 1.0 /
abs(res.n);
96 const std::pair<bool, bool> flags = transform_pair
98 assert(flags.first || flags.second);
102 (cells[static_cast<size_t>(edge.
neighbors.second)], eos,tracerstickernames);
104 res.left =
reflect(res.right, res.p);
108 else if (!flags.second) {
110 (cells[static_cast<size_t>(edge.
neighbors.first)], eos,tracerstickernames);
112 res.right =
reflect(res.left, res.p);
115 (cells[static_cast<size_t>(edge.
neighbors.second)], eos,tracerstickernames);
119 const size_t left_index =
static_cast<size_t>(edge.
neighbors.first);
120 const size_t right_index =
static_cast<size_t>(edge.
neighbors.second);
125 (res.n, edge_velocities.at(edge_index)) /
159 const double velocity,
163 return rotate_back(rs(rotate(left, n, p),
169 Conserved SimpleFluxCalculator::calcHydroFlux
171 const vector<Vector2D>& edge_velocities,
172 const vector<ComputationalCell>& cells,
177 RiemannProblemInput rpi = riemann_reduce
195 double calc_tracer_flux(
size_t i,
197 const vector<ComputationalCell>& cells,
201 const Edge& edge = tess.
GetEdge(static_cast<int>(i));
207 cells[
static_cast<size_t>(edge.
neighbors.first)].tracers.at(tracer_index);
213 cells[
static_cast<size_t>(edge.
neighbors.second)].tracers.at(tracer_index);
218 vector<Extensive> SimpleFluxCalculator::operator()
220 const vector<Vector2D>& edge_velocities,
221 const vector<ComputationalCell>& cells,
222 const vector<Extensive>& ,
230 for (
size_t i = 0; i < tess.
getAllEdges().size(); ++i)
232 const Conserved hydro_flux = calcHydroFlux
233 (tess, edge_velocities, cells, eos, i,tracerstickernames);
234 res[i].mass = hydro_flux.
Mass;
235 res[i].momentum = hydro_flux.
Momentum;
236 res[i].energy = hydro_flux.
Energy;
237 size_t N = cells[0].tracers.size();
240 res[i].tracers.resize(N);
241 for (
size_t j = 0; j < N; ++j)
242 res[i].tracers[j] = calc_tracer_flux(i, tess, cells, j, hydro_flux);
Set of conserved variables (extensive)
Vector2D Momentum
Momentum.
double SoundSpeed
Speed of sound.
Vector2D remove_parallel_component(const Vector2D &v, const Vector2D &p)
Remove parallel component of a vector.
Vector2D Parallel(Edge const &edge)
Calculates a unit vector parallel to an edge.
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.
Vector3D Reflect(Vector3D const &v, Vector3D const &normal)
Reflect vector.
Primitive convert_to_primitive(const ComputationalCell &cell, const EquationOfState &eos, TracerStickerNames const &tracerstickernames)
Converts computational cell to primitive variables.
double Projection(Vector3D const &v1, Vector3D const &v2)
Calculates the projection of one vector in the direction of the second.
Vector2D Velocity
Velocity.
Interface between two cells.
virtual Vector2D GetMeshPoint(int index) const =0
Returns Position of mesh generating point.
virtual double dp2c(double d, double p, tvector const &tracers=tvector(), vector< string > const &tracernames=vector< string >()) const =0
Calculates the speed of sound.
double Energy
Total energy (kinetic + thermal)
double y
Component in the y direction.
tvector tracers
Tracers (can transfer from one cell to another)
virtual Edge const & GetEdge(int index) const =0
Returns edge (interface between cells)
SimpleFluxCalculator(const RiemannSolver &rs)
Class constructor.
Base class for Riemann solver.
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.
virtual const vector< Edge > & getAllEdges(void) const =0
Returns reference to the list of all edges.
Base class for equation of state.
Primitive reflect(const Primitive &p, const Vector2D &axis)
Reflects velocity about axis.
Container for cache data.
std::vector< std::string > tracer_names
The names of the tracers.
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, const TracerStickerNames &tracerstickernames) const
Calculates fluxes.
Class for keeping the names of the tracers and stickers.
std::pair< int, int > neighbors
Neighboring cells.
virtual double dp2e(double d, double p, tvector const &tracers=tvector(), vector< string > const &tracernames=vector< string >()) const =0
Calculates the thermal energy per unit mass.
double Energy
Thermal energy per unit mass, entahalpy in relativistic case.
double abs(Vector3D const &v)
Norm of a vector.
Primitive hydrodynamic variables.
Vector2D velocity
Velocity.
double x
Component in the x direction.