1 #include "condition_action_sequence_2.hpp" 3 #include "../../misc/utils.hpp" 9 (
const vector<pair<const ConditionActionSequence::Condition*, const ConditionActionSequence::Action*> >& sequence,
10 const vector<pair<const ConditionActionSequence::Condition*, const Action2*> >& sequence2,
12 sequence_(sequence),sequence2_(sequence2),interp_(interp),edge_values_(vector<pair<
ComputationalCell,
15 ConditionActionSequence2::~ConditionActionSequence2(
void)
20 pair<Vector2D, Vector2D> calc_parallel_normal(
const Tessellation& tess,
const Edge& edge)
30 return pair<Vector2D, Vector2D>();
33 Extensive convert_conserved_to_extensive(
const Conserved& conserved,
const pair<ComputationalCell, ComputationalCell>& cells)
39 res.
tracers.resize(cells.first.tracers.size());
41 for (
size_t i = 0; i < N; ++i)
42 res.
tracers[i] = conserved.
Mass*(conserved.
Mass>0 ? cells.first.tracers[i] : cells.second.tracers[i]);
49 const vector<ComputationalCell>& cells,
52 const vector<pair<const ConditionActionSequence::Condition*, const ConditionActionSequence::Action*> >& sequence,
53 const vector<pair<const ConditionActionSequence::Condition*, const ConditionActionSequence2::Action2*> >& sequence2,
54 pair<ComputationalCell,ComputationalCell>
const& edge_values,
Extensive &res,
double time,
57 for (
size_t i = 0; i<sequence.size(); ++i)
59 const pair<bool, bool> flag_aux = (*sequence[i].first)
60 (edge, tess, cells,tracerstickernames);
63 (*sequence[i].second)(edge, tess, edge_velocity, cells, eos, flag_aux.second,res,time,tracerstickernames);
67 for (
size_t i = 0; i<sequence2.size(); ++i)
69 const pair<bool, bool> flag_aux = (*sequence2[i].first)
70 (edge, tess, cells,tracerstickernames);
73 (*sequence2[i].second)(edge,index, tess, edge_velocity, cells, eos, flag_aux.second, edge_values,res,time,
82 vector<Extensive> ConditionActionSequence2::operator()
84 const vector<Vector2D>& edge_velocities,
85 const vector<ComputationalCell>& cells,
86 const vector<Extensive>& extensives,
93 for (
size_t i = 0; i < sequence2_.size(); ++i)
94 sequence2_[i].second->Reset();
96 pair<ComputationalCell, ComputationalCell>(cells[0], cells[0]));
97 interp_.operator()(tess, cells, time,edge_values_,tracerstickernames,cd);
98 vector<Extensive> res(tess.
getAllEdges().size(), extensives[0]);
99 for (
size_t i = 0; i < tess.
getAllEdges().size(); ++i)
110 edge_values_[i], res[i], time, tracerstickernames, i);
114 size_t N0 =
static_cast<size_t>(tess.
GetEdge(static_cast<int>(i)).
neighbors.first);
115 size_t N1 =
static_cast<size_t>(tess.
GetEdge(static_cast<int>(i)).
neighbors.second);
116 eo.
AddEntry(
"Error in conditionactionseq2, edge", static_cast<double>(i));
117 eo.
AddEntry(
"density left", edge_values_[i].first.density);
118 eo.
AddEntry(
"pressure left", edge_values_[i].first.pressure);
119 eo.
AddEntry(
"original density left", cells[N0].density);
120 eo.
AddEntry(
"original pressure left", cells[N0].pressure);
121 eo.
AddEntry(
"density right", edge_values_[i].second.density);
122 eo.
AddEntry(
"pressure right", edge_values_[i].second.pressure);
123 eo.
AddEntry(
"original density right", cells[N1].density);
124 eo.
AddEntry(
"original pressure right", cells[N1].pressure);
125 eo.
AddEntry(
"Left neighbor", static_cast<double>(N0));
126 eo.
AddEntry(
"Right neighbor", static_cast<double>(N1));
130 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
131 eo.
AddEntry(
"Rank", static_cast<double>(rank));
140 ConditionActionSequence2::Action2::~Action2(
void) {}
147 void conserved_to_extensive
154 size_t N = cell.
tracers.size();
155 for (
size_t i = 0; i < N; ++i)
160 void RegularFlux2::operator()
165 const vector<ComputationalCell>& ,
168 pair<ComputationalCell,ComputationalCell>
const& edge_values,
173 (tess.GetMeshPoint(edge.
neighbors.second) -
174 tess.GetMeshPoint(edge.
neighbors.first));
181 (edge_values.first, eos,tracerstickernames),
183 (edge_values.second, eos,tracerstickernames),
185 conserved_to_extensive(c,c.
Mass>0 ? edge_values.first : edge_values.second,res);
194 pair<Primitive, Primitive> rigid_wall_states
202 return pair<Primitive, Primitive>(left, right);
207 return pair<Primitive, Primitive>(left, right);
212 void RigidWallFlux2::operator()
217 const vector<ComputationalCell>& ,
220 pair<ComputationalCell,ComputationalCell>
const& edge_values,
240 const pair<Primitive, Primitive> left_right =
243 (aux ? edge_values.first :edge_values.second,eos,tracerstickernames),
250 conserved_to_extensive(c,aux ? edge_values.first : edge_values.second,res);
261 void Ratchet::operator()
266 const vector<ComputationalCell>& cells,
269 const pair<ComputationalCell, ComputationalCell> & edge_values,
275 if (
ScalarProd(n, cells[static_cast<size_t>(aux ? edge.
neighbors.first : edge.
neighbors.second)].velocity)*(2*static_cast<double>(in_)-1) < 0)
276 free_.operator()(edge,tess, edge_velocity, cells, eos, aux,res,time,tracerstickernames);
278 wall_.operator()(edge,index, tess, edge_velocity, cells, eos, aux,edge_values,res,time,tracerstickernames);
285 ws_(vector<double>()),
286 edge_vel_(vector<double>()),
287 Lag_calc_(vector<bool>()),
290 criteria_(criteria) {}
294 ws_.assign(ws_.size(), 0);
295 edge_vel_.assign(edge_vel_.size(), 0);
296 Lag_calc_.assign(Lag_calc_.size(),
false);
300 const EquationOfState& eos,
const bool aux,
const pair<ComputationalCell, ComputationalCell> & edge_values,
Extensive &res,
double time,
305 edge_vel_.resize(N,0.0);
306 Lag_calc_.resize(N,
false);
307 const pair<Vector2D, Vector2D> p_n = calc_parallel_normal(tess, edge);
308 const double speed =
ScalarProd(p_n.second, edge_velocity) /
abs(p_n.second);
311 if (criteria_(edge, index, tess, edge_velocity, cells, eos, aux, edge_values, time, tracerstickernames))
313 res = convert_conserved_to_extensive(
rotate_solve_rotate_back(rs_, p_left, p_right, speed, p_n.second, p_n.first), edge_values);
314 ws_[index] = rs_.energy;
315 Lag_calc_[index] =
true;
319 res = convert_conserved_to_extensive(
rotate_solve_rotate_back(rs2_, p_left, p_right,speed, p_n.second, p_n.first), edge_values);
322 edge_vel_[index] = speed;
325 LagrangianFlux::LagrangianCriteria::~LagrangianCriteria() {}
327 WallsMassFlux::WallsMassFlux() {}
333 const vector<ComputationalCell>& ,
336 const pair<ComputationalCell, ComputationalCell> & ,
Set of conserved variables (extensive)
Vector2D Momentum
Momentum.
LagrangianHLLC Riemann solver for an Eulerian grid.
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.
Spatial reconstruction of the primitive functions.
Abstract class for tessellation.
Condition on when to apply mass transfer fix.
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.
Vector2D momentum
momentum, in relativity it is = rho*h*gamma*v
Container for error reports.
Primitive convert_to_primitive(const ComputationalCell &cell, const EquationOfState &eos, TracerStickerNames const &tracerstickernames)
Converts computational cell to primitive variables.
RegularFlux2(const RiemannSolver &rs)
Class constructor.
double mass
rest mass times gamma
Interface between two cells.
virtual Vector2D GetMeshPoint(int index) const =0
Returns Position of mesh generating point.
double Energy
Total energy (kinetic + thermal)
double energy
energy, in relativity it is = rho*h*gamma^2-P-rho
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)
Base class for Riemann solver.
Ratchet(const RiemannSolver &rs, const bool in)
Class constructor.
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.
RigidWallFlux2(const RiemannSolver &rs)
Class constructor.
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.
std::pair< Vector2D, Vector2D > vertices
Points at the ends of the edge.
Primitive reflect(const Primitive &p, const Vector2D &axis)
Reflects velocity about axis.
Container for cache data.
Vector2D normalize(const Vector2D &v)
Normalized a vector.
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.
LagrangianFlux(const LagrangianHLLC &rs, const LagrangianHLLC &rs2, LagrangianCriteria const &criteria)
Class constructor.
double abs(Vector3D const &v)
Norm of a vector.
void AddEntry(std::string const &field, double value)
Adds an entry to the list.
Primitive hydrodynamic variables.
ConditionActionSequence2(const vector< pair< const ConditionActionSequence::Condition *, const ConditionActionSequence::Action *> > &sequence, const vector< pair< const ConditionActionSequence::Condition *, const ConditionActionSequence2::Action2 *> > &sequence2, SpatialReconstruction const &interp)
Class constructor.
void Reset(void) const
Resets the internal variables.
bool operator()(const Edge &edge, const size_t index, const Tessellation &tess, const Vector2D &edge_velocity, const vector< ComputationalCell > &cells, const EquationOfState &eos, const bool aux, const pair< ComputationalCell, ComputationalCell > &edge_values, double time, TracerStickerNames const &tracerstickernames) const
Criteria for calculating mass flux or not.
double x
Component in the x direction.
void operator()(const Edge &edge, const size_t index, const Tessellation &tess, const Vector2D &edge_velocity, const vector< ComputationalCell > &cells, const EquationOfState &eos, const bool aux, const pair< ComputationalCell, ComputationalCell > &edge_values, Extensive &res, double time, TracerStickerNames const &tracerstickernames) const
Calculates flux.