26 #ifndef TOOLS_MERCURYDATA_H
27 #define TOOLS_MERCURYDATA_H
40 template<std::
size_t NDIMS>
115 template<std::
size_t NDIMS>
119 for (
i = 0;
i < NDIMS;
i++)
122 for (
i = 0;
i < NDIMS;
i++) {
130 for (
i = 0;
i < NDIMS;
i++)
133 for (
i = 0;
i < NDIMS;
i++) {
147 in >> part.position[0] >> part.position[2];
148 part.position[1] = 0;
150 in >> part.velocity[0] >> part.velocity[2];
151 part.velocity[1] = 0;
155 in >> part.rotation[1];
156 part.rotation[0] = part.rotation[2] = 0;
158 in >> part.angularV[1];
159 part.angularV[0] = part.angularV[2] = 0;
161 in >> part.speciesID;
169 template<std::
size_t NDIMS>
176 template<std::
size_t NDIMS>
232 typename std::vector< MercuryParticle<NDIMS> >::iterator
begin()
240 typename std::vector< MercuryParticle<NDIMS> >::const_iterator
begin()
const
248 typename std::vector< MercuryParticle<NDIMS> >::iterator
end()
256 typename std::vector< MercuryParticle<NDIMS> >::const_iterator
end()
const
324 template<std::
size_t NDIMS2>
338 template<std::
size_t NDIMS>
344 for (
i = 0;
i < NDIMS;
i++)
347 for (
i = 0;
i < NDIMS;
i++)
362 template<std::
size_t NDIMS>
475 template<std::
size_t NDIMS>
479 std::ios::pos_type currentPosition =
file_.tellg();
484 std::getline(
file_, line);
485 file_.seekg(currentPosition);
487 std::istringstream lineStream(line);
494 bool isValid = lineStream.good() || (lineStream.eof() && !lineStream.fail());
499 isValid = isValid && !lineStream.good();
509 template<std::
size_t NDIMS>
530 template<std::
size_t NDIMS>
545 template<std::
size_t NDIMS>
555 template<std::
size_t NDIMS>
566 template<std::
size_t NDIMS>
568 template<std::
size_t NDIMS>
572 template<std::
size_t NDIMS>
580 std::istringstream lineStream(line);
585 if (lineStream.eof())
600 lineStream.str(line);
std::istream & operator>>(std::istream &in, MercuryParticle< NDIMS > &part)
Read a single particle from a istream.
Definition: MercuryData.h:116
Definition: MercuryData.h:511
MercuryDataFile * data_
Definition: MercuryData.h:517
MercuryTimeStepIterator< NDIMS > end()
Definition: MercuryData.h:523
MercuryTimeStepIterator< NDIMS > begin()
Definition: MercuryData.h:519
IteratorProxy(MercuryDataFile *pData)
Definition: MercuryData.h:513
Definition: MercuryData.h:441
MercuryDataFile(std::string name)
Definition: MercuryData.h:448
MercuryTimeStepIterator< NDIMS > end() const
Returns a forwarditerator one past the last time step.
Definition: MercuryData.h:556
IteratorProxy< NDIMS > as()
Definition: MercuryData.h:531
MercuryTimeStepIterator< NDIMS > begin()
Returns a forwarditerator to the time steps Returns a forwarditerator to the time steps,...
Definition: MercuryData.h:546
std::ifstream file_
Definition: MercuryData.h:564
bool isMercuryDataFile()
Checks if this file is a valid Mercury 3D data file. This function jumps to the start of the file,...
Definition: MercuryData.h:476
Definition: MercuryData.h:364
const MercuryTimeStep< NDIMS > & operator*() const
Const dereference operator, as defined for constant ForwardIterators.
Definition: MercuryData.h:385
MercuryTimeStep< NDIMS > & operator*()
Dereference operator, as defined for ForwardIterators.
Definition: MercuryData.h:377
MercuryTimeStepIterator()
Definition: MercuryData.h:401
MercuryTimeStep< NDIMS > lastReadTimeStep_
Definition: MercuryData.h:420
bool operator!=(MercuryTimeStepIterator< NDIMS > other) const
Not-equals operator, as defined for ForwardIterators.
Definition: MercuryData.h:369
void operator++()
Pre-increment operator, as defined for ForwardIterators This method populates the time step,...
Definition: MercuryData.h:573
MercuryDataFile * dataFile_
Definition: MercuryData.h:428
MercuryTimeStepIterator(MercuryDataFile *pData)
Definition: MercuryData.h:410
bool isEOFTimeStep_
Definition: MercuryData.h:424
Definition: MercuryData.h:178
std::size_t numParticles_
Definition: MercuryData.h:307
std::vector< MercuryParticle< NDIMS > >::iterator end()
Iterator functions for range based for loops.
Definition: MercuryData.h:248
std::size_t size() const
Gets the number of particles recorded in this time step.
Definition: MercuryData.h:215
MercuryTimeStep(std::size_t id, MercuryDataFile *pData)
Constructor used by the MercuryTimeStepIterator, to flag a functional time step.
Definition: MercuryData.h:283
std::vector< MercuryParticle< NDIMS > >::const_iterator begin() const
Iterator functions for range based for loops.
Definition: MercuryData.h:240
double max_[NDIMS]
Definition: MercuryData.h:311
std::size_t getNumberOfParticles() const
Gets the number of particles recorded in this time step.
Definition: MercuryData.h:205
friend std::istream & operator>>(std::istream &, MercuryTimeStep< NDIMS2 > &)
std::size_t ID_
Definition: MercuryData.h:303
std::vector< MercuryParticle< NDIMS > > storage_
Definition: MercuryData.h:322
double getTime() const
Gets the time associated with this time step.
Definition: MercuryData.h:184
std::vector< MercuryParticle< NDIMS > >::const_iterator end() const
Iterator functions for range based for loops.
Definition: MercuryData.h:256
double time_
Definition: MercuryData.h:299
MercuryParticle< NDIMS > & operator[](std::size_t idx)
Random access function into the particles.
Definition: MercuryData.h:264
std::size_t getTimeStepID() const
Gets the time step ID Returns the time step ID, which is a consecutively ascending number unique for ...
Definition: MercuryData.h:195
MercuryDataFile * dataFile_
Definition: MercuryData.h:317
constexpr std::size_t getNumberOfDimensions() const
returns the number of dimensions used.
Definition: MercuryData.h:224
MercuryTimeStep()
EOF-TimeStep constructor used by MercuryTimeStepIterator (and MercuryDataFile::isMercury3DDataFile())
Definition: MercuryData.h:291
const MercuryParticle< NDIMS > & operator[](std::size_t idx) const
Random access function into the particles.
Definition: MercuryData.h:272
double min_[NDIMS]
Definition: MercuryData.h:311
std::vector< MercuryParticle< NDIMS > >::iterator begin()
Iterator functions for range based for loops.
Definition: MercuryData.h:232
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
std::string name
Definition: MercuryProb.h:48
Definition: MercuryData.h:81
std::size_t speciesID
Definition: MercuryData.h:108
double radius
Definition: MercuryData.h:103
Definition: MercuryData.h:42
std::size_t speciesID
Definition: MercuryData.h:69
double rotation[NDIMS]
Definition: MercuryData.h:55
double angularV[NDIMS]
Definition: MercuryData.h:59
double radius
Definition: MercuryData.h:64
double velocity[NDIMS]
Definition: MercuryData.h:51
double position[NDIMS]
Definition: MercuryData.h:47