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++)
127 for (i = 0; i < NDIMS; i++)
130 for (i = 0; i < NDIMS; i++)
142 in >> part.position[0] >> part.position[2];
143 part.position[1] = 0;
145 in >> part.velocity[0] >> part.velocity[2];
146 part.velocity[1] = 0;
150 in >> part.rotation[1];
151 part.rotation[0] = part.rotation[2] = 0;
153 in >> part.angularV[1];
154 part.angularV[0] = part.angularV[2] = 0;
156 in >> part.speciesID;
164 template<std::
size_t NDIMS>
171 template<std::
size_t NDIMS>
227 typename std::vector< MercuryParticle<NDIMS> >::iterator
begin()
235 typename std::vector< MercuryParticle<NDIMS> >::const_iterator
begin()
const
243 typename std::vector< MercuryParticle<NDIMS> >::iterator
end()
251 typename std::vector< MercuryParticle<NDIMS> >::const_iterator
end()
const
318 template<std::
size_t NDIMS2>
332 template<std::
size_t NDIMS>
338 for (i = 0; i < NDIMS; i++)
341 for (i = 0; i < NDIMS; i++)
356 template<std::
size_t NDIMS>
453 operator bool()
const
469 template<std::
size_t NDIMS>
473 std::ios::pos_type currentPosition =
file_.tellg();
478 std::getline(
file_, line);
479 file_.seekg(currentPosition);
481 std::istringstream lineStream(line);
488 bool isValid = lineStream.good();
493 isValid = isValid && !lineStream.good();
503 template<std::
size_t NDIMS>
524 template<std::
size_t NDIMS>
539 template<std::
size_t NDIMS>
549 template<std::
size_t NDIMS>
560 template<std::
size_t NDIMS>
562 template<std::
size_t NDIMS>
566 template<std::
size_t NDIMS>
574 std::istringstream lineStream(line);
579 if (lineStream.eof())
587 lastReadTimeStep_.storage_.resize(lastReadTimeStep_.numParticles_);
594 lineStream.str(line);
constexpr std::size_t getNumberOfDimensions() const
returns the number of dimensions used.
std::vector< MercuryParticle< NDIMS > >::iterator begin()
Iterator functions for range based for loops.
std::vector< MercuryParticle< NDIMS > > storage_
MercuryTimeStep(std::size_t id, MercuryDataFile *pData)
Constructor used by the MercuryTimeStepIterator, to flag a functional timestep.
std::size_t getTimeStepID() const
Gets the timestep ID Returns the timestep ID, which is a consecutively ascending number unique for th...
MercuryDataFile * dataFile_
bool operator!=(MercuryTimeStepIterator< NDIMS > other) const
Not-equals operator, as defined for ForwardIterators.
IteratorProxy< NDIMS > as()
friend std::istream & operator>>(std::istream &, MercuryTimeStep< NDIMS2 > &)
MercuryTimeStepIterator< NDIMS > end() const
Returns a forwarditerator one past the last timestep.
bool isMercuryDataFile()
Checks if this file is a valid Mercury 3D data file. This function jumps to the start of the file...
MercuryParticle< NDIMS > & operator[](std::size_t idx)
Random access function into the particles.
const MercuryTimeStep< NDIMS > & operator*() const
Const dereference operator, as defined for constant ForwardIterators.
MercuryTimeStepIterator< NDIMS > begin()
Returns a forwarditerator to the timesteps Returns a forwarditerator to the timesteps, invalidating any other valid iterators in the process (since this is a lazy loader and does not actually load the entire file in memory). End iterators do not get invalidated. This function makes no guarantee for the validity of the file-state.
std::vector< MercuryParticle< NDIMS > >::const_iterator end() const
Iterator functions for range based for loops.
std::istream & operator>>(std::istream &in, MercuryParticle< NDIMS > &part)
Read a single particle from a istream.
MercuryTimeStepIterator< NDIMS > end()
MercuryTimeStep< NDIMS > & operator*()
Dereference operator, as defined for ForwardIterators.
void operator++()
Pre-increment operator, as defined for ForwardIterators This method populates the timestep...
std::size_t size() const
Gets the number of particles recorded in this timestep.
MercuryTimeStepIterator< NDIMS > begin()
MercuryTimeStep()
EOF-Timestep constructor used by MercuryTimeStepIterator (and MercuryDataFile::isMercury3DDataFile())...
MercuryTimeStep< NDIMS > lastReadTimeStep_
MercuryTimeStepIterator()
std::size_t numParticles_
MercuryDataFile * dataFile_
MercuryDataFile(std::string name)
MercuryTimeStepIterator(MercuryDataFile *pData)
IteratorProxy(MercuryDataFile *pData)
std::vector< MercuryParticle< NDIMS > >::const_iterator begin() const
Iterator functions for range based for loops.
const MercuryParticle< NDIMS > & operator[](std::size_t idx) const
Random access function into the particles.
std::size_t getNumberOfParticles() const
Gets the number of particles recorded in this timestep.
double getTime() const
Gets the time associated with this timestep.
std::vector< MercuryParticle< NDIMS > >::iterator end()
Iterator functions for range based for loops.