Peano
Loading...
Searching...
No Matches
TrajectoryDatabase.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include <iomanip>
6#include <list>
7#include <map>
8#include <string>
9
11#include "tarch/la/Vector.h"
12#include "tarch/logging/Log.h"
14
15namespace toolbox {
16 namespace particles {
17 class TrajectoryDatabase;
18 } // namespace particles
19} // namespace toolbox
20
30private:
32
33 std::string _fileName;
34 double _dataDelta;
39
40 double _timeDelta;
41
45
57
59
60 static constexpr double _deltaCutOffThreshold = 1e-6;
61
68 int _rank;
69
71
72 struct Entry {
74 double timestamp;
75 double* data;
81
82 Entry(const Entry&);
83 ~Entry();
84 Entry(const TrajectoryDatabase& database, const tarch::la::Vector<Dimensions, double>& x_, double timestamp_);
85 };
86
87 std::map<std::pair<int, int>, std::list<Entry>> _data;
88
90
92
101 const std::pair<int, int>& number, const tarch::la::Vector<Dimensions, double>& x, double timestamp
102 );
103
114 const std::pair<int, int>& number,
116 double timestamp,
117 int numberOfDataEntries,
118 double* data
119 );
120
133
134public:
224 int growthBetweenTwoDatabaseFlushes,
225 double positionDelta = 1e-8,
226 double dataDelta = 1e-8,
227 double timeDelta = 0.0,
228 bool clearDatabaseAfterFlush = true,
229 bool deltasAreRelative = false
230 );
232
239 void clear(bool lockSemaphore = true);
240
245 void clearHistory(bool lockSemaphore = true);
246
258 void dumpCSVFile();
259
260 void setOutputFileName(const std::string& filename);
261 void setOutputPrecision(int precision);
262 void setDataDeltaBetweenTwoSnapshots(double value, bool deltasAreRelative = false);
263 void setPositionDeltaBetweenTwoSnapshots(double value, bool deltasAreRelative = false);
264 void setTimeDeltaBetweenTwoSnapshots(double value);
265
266 void clearDatabaseAfterFlush(bool value);
267
293 const std::pair<int, int>& number, double timestamp, const tarch::la::Vector<Dimensions, double>& x
294 );
295
296 void addParticleSnapshot(int number0, int number1, double timestamp, const tarch::la::Vector<Dimensions, double>& x);
297
299 const std::pair<int, int>& number,
300 double timestamp,
302 int numberOfDataEntries,
303 double* data
304 );
305
307 int number0,
308 int number1,
309 double timestamp,
311 int numberOfDataEntries,
312 double* data
313 );
314};
Log Device.
Definition Log.h:516
void setDataDeltaBetweenTwoSnapshots(double value, bool deltasAreRelative=false)
static constexpr double _deltaCutOffThreshold
AddSnapshotAction getAction(const std::pair< int, int > &number, const tarch::la::Vector< Dimensions, double > &x, double timestamp)
Determine what to do with new entry.
int _rank
This is a hack: Usually, I'd just ask the rank what its number is.
TrajectoryDatabase(int growthBetweenTwoDatabaseFlushes, double positionDelta=1e-8, double dataDelta=1e-8, double timeDelta=0.0, bool clearDatabaseAfterFlush=true, bool deltasAreRelative=false)
Trajectory database.
bool _clearDatabaseAfterFlush
Flag that indicates if we erase the database after a flush.
void dumpCSVFile()
Dump data into CSV file.
void addParticleSnapshot(const std::pair< int, int > &number, double timestamp, const tarch::la::Vector< Dimensions, double > &x)
Add particle snapshot.
void setOutputFileName(const std::string &filename)
std::map< std::pair< int, int >, std::list< Entry > > _data
void clearHistory(bool lockSemaphore=true)
This call does not throw away all particles, but it throws away all the history behind the particles.
void setPositionDeltaBetweenTwoSnapshots(double value, bool deltasAreRelative=false)
tarch::multicore::BooleanSemaphore _semaphore
Simple vector class.
Definition Vector.h:134
const int numberOfDataEntries
Have to memorise this guy to be able to write a proper copy constructor.
tarch::la::Vector< Dimensions, double > x