2 #include "../../misc/lazy_list.hpp" 4 #include "../../mpi/mpi_commands.hpp" 8 (
const vector<pair<const SimpleCellUpdater::Condition*, const SimpleCellUpdater::Action*> > sequence,
bool SR,
double G) :
9 sequence_(sequence), SR_(SR), G_(G), entropy_(
"Entropy") {}
11 SimpleCellUpdater::~SimpleCellUpdater(
void)
13 for (
size_t i = 0; i < sequence_.size(); ++i) {
14 delete sequence_[i].first;
15 delete sequence_[i].second;
19 SimpleCellUpdater::Condition::~Condition(
void) {}
21 SimpleCellUpdater::Action::~Action(
void) {}
45 bool HighRelativeKineticEnergy(
Tessellation const& tess,
size_t index, vector<Extensive>
const& cells,
48 std::vector<int> neigh;
50 size_t N = neigh.size();
52 size_t Norg =
static_cast<size_t>(tess.
GetPointNo());
55 for (
size_t i = 0; i < N; ++i)
56 if (neigh[i] < static_cast<int>(Norg) || tess.
GetOriginalIndex(static_cast<int>(neigh[i]))>
static_cast<int>(Norg))
57 maxDV =
std::max(maxDV,
abs(Vcell - cells.at(static_cast<size_t>(neigh[i])).momentum / cells[
static_cast<size_t>(neigh[i])].mass));
58 return 0.005*maxDV*maxDV > Et;
61 void regular_update(
const EquationOfState& eos, vector<Extensive>& extensives,
71 const double volume = cd.
volumes[index];
76 double energy = extensive.
energy / extensive.
mass -
79 for (
size_t i = 0; i < extensive.
tracers.size(); ++i)
84 if (entropy_index < res.
tracers.size())
89 EntropyFix(eos, res, entropy_index, tracerstickernames, energy, extensive);
94 if (HighRelativeKineticEnergy(tess, index, extensives, extensive))
96 EntropyFix(eos, res, entropy_index, tracerstickernames, energy, extensive);
102 if (new_entropy < 0.75*res.
tracers[entropy_index])
104 EntropyFix(eos, res, entropy_index, tracerstickernames, energy, extensive);
110 res.
tracers[entropy_index] = new_entropy;
111 extensive.
tracers[entropy_index] = new_entropy * extensive.
mass;
125 eo.
AddEntry(
"Cell index", static_cast<double>(index));
131 for (
size_t i = 0; i < tracerstickernames.
tracer_names.size(); ++i)
137 void regular_updateSR(
const EquationOfState& eos, vector<Extensive>& extensives,
142 size_t entropy_index,
146 Extensive& extensive = extensives[index];
148 const double volume = 1.0 / cd.
volumes[index];
155 for (
size_t i = 0; i < extensive.
tracers.size(); ++i)
162 + (1.0 / gamma_1 - 1)*res.
density);
164 if (entropy_index < res.
tracers.size())
170 EntropyFixSR(eos, res, entropy_index, tracerstickernames, enthalpy, extensive, cd.
volumes[index]);
176 res.
tracers[entropy_index] = new_entropy;
177 extensive.
tracers[entropy_index] = new_entropy * extensive.
mass;
185 vector<Extensive>& extensives,
186 const vector<ComputationalCell>& old,
188 const vector<pair<const SimpleCellUpdater::Condition*, const SimpleCellUpdater::Action*> >& sequence,
194 for (
size_t i = 0; i < sequence.size(); ++i)
196 if ((*sequence[i].first)(tess, pg, eos, extensives, old, cd, index, tracerstickernames))
198 res = (*sequence[i].second)(tess, pg, eos, extensives, old, cd, index, tracerstickernames, time);
203 regular_update(eos, extensives, old.at(index), cd, index, res, entropyindex, tracerstickernames, tess);
205 regular_updateSR(eos, extensives, old.at(index), cd, index, res, entropyindex, tracerstickernames, tess, G);
209 vector<ComputationalCell> SimpleCellUpdater::operator()
213 vector<Extensive>& extensives,
214 const vector<ComputationalCell>& old,
219 size_t N =
static_cast<size_t>(tess.
GetPointNo());
220 vector<ComputationalCell> res(N, old[0]);
222 size_t tindex = old[0].tracers.size();
223 vector<string>::const_iterator it =
binary_find(tracerstickernames.tracer_names.begin(),
224 tracerstickernames.tracer_names.end(), entropy_);
225 if (it != tracerstickernames.tracer_names.end())
226 tindex = static_cast<size_t>(it - tracerstickernames.tracer_names.begin());
228 if (tindex < old[0].tracers.size())
229 MPI_exchange_data(tess, extensives,
true);
231 for (
size_t i = 0; i < N; ++i)
232 update_single(tess, pg, eos, extensives, old, cd, sequence_, i, res[i], tindex, tracerstickernames, time, SR_, G_);
234 if (tindex < old[0].tracers.size())
235 extensives.resize(static_cast<size_t>(tess.
GetPointNo()));
241 (
const string& sticker_name) :
242 sticker_name_(sticker_name) {}
244 bool HasSticker::operator()
248 const vector<Extensive>& ,
249 const vector<ComputationalCell>& cells,
254 vector<string>::const_iterator it =
binary_find(tracerstickernames.sticker_names.begin(), tracerstickernames.sticker_names.end(),
256 assert(it != tracerstickernames.sticker_names.end());
257 return cells[index].stickers[
static_cast<size_t>(it - tracerstickernames.sticker_names.begin())];
260 SkipUpdate::SkipUpdate(
void) {}
264 const PhysicalGeometry& ,
265 const EquationOfState& ,
266 const vector<Extensive>& ,
267 const vector<ComputationalCell>& cells,
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.
virtual double de2p(double d, double e, tvector const &tracers=tvector(), vector< string > const &tracernames=vector< string >()) const =0
Calculates the pressure.
Vector2D momentum
momentum, in relativity it is = rho*h*gamma*v
Container for error reports.
double mass
rest mass times gamma
double max(vector< double > const &v)
returns the maximal term in a vector
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)
double GetVelocity(Extensive const &cell, double G)
Calculates velocity from extensive in SR.
double ScalarProd(Vector3D const &v1, Vector3D const &v2)
Scalar product of two vectors.
virtual double dp2s(double d, double p, tvector const &tracers=tvector(), vector< string > const &tracernames=vector< string >()) const =0
Calculates the entropy per unit mass.
virtual double sd2p(double s, double d, tvector const &tracers=tvector(), vector< string > const &tracernames=vector< string >()) const =0
Calculates the pressure from the netropy.
Base class for equation of state.
const CachedLazyList< double > volumes
List of cell volumes.
Container for cache data.
HasSticker(const string &sticker_name)
Class constructor.
std::vector< std::string > tracer_names
The names of the tracers.
svector stickers
Stickers (stick to the same cell)
SimpleCellUpdater(const vector< pair< const SimpleCellUpdater::Condition *, const SimpleCellUpdater::Action *> > sequence=vector< pair< const SimpleCellUpdater::Condition *, const SimpleCellUpdater::Action *> >(), bool SR=false, double G=0)
Class constructor.
Class for keeping the names of the tracers and stickers.
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 abs(Vector3D const &v)
Norm of a vector.
void AddEntry(std::string const &field, double value)
Adds an entry to the list.
Vector2D velocity
Velocity.
Iter binary_find(Iter begin, Iter end, T val)
Binary search that return iterator of found object or end if not found.
virtual vector< int > GetNeighbors(int index) const =0
Returns the indeces of the neighbors.
Base class for physical geometry.
double fastabs(Vector2D const &v)
Norm of a vector, less accurate.
double x
Component in the x direction.