AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Aqua::InputOutput::FastASCII Class Reference

Plain text particles data files loader/saver. More...

#include <FastASCII.hpp>

Inheritance diagram for Aqua::InputOutput::FastASCII:
Collaboration diagram for Aqua::InputOutput::FastASCII:

Public Member Functions

 FastASCII (ProblemSetup &sim_data, unsigned int iset, size_t offset, size_t n=0, const std::string file_ext=".dat")
 Constructor.
 ~FastASCII ()
 Destructor.
Public Member Functions inherited from Aqua::InputOutput::ASCII
 ASCII (ProblemSetup &sim_data, unsigned int iset, size_t offset, size_t n=0, const std::string file_ext=".dat")
 Constructor.
virtual ~ASCII ()
 Destructor.
virtual void load ()
 Load the data.
virtual void print_file ()
 Print the data to a file.
Public Member Functions inherited from Aqua::InputOutput::Particles
 Particles (ProblemSetup &sim_data, unsigned int iset, size_t offset, size_t n=0)
 Constructor.
virtual ~Particles ()
 Destructor.
const std::string & file () const
 Get the last printed file path.
size_t n () const
 Get the number of particles managed by this instance.
cl_event getUserEvent () const
 Get the user event to be waited for before the file saving is finished.
virtual void waitForSavers ()
 Wait for the eventual parallel saving threads.
virtual void save (float t)
 Save the data.

Protected Member Functions

std::string readField (const std::string field, const std::string line, size_t index, void *data)
 Extract the field value from a line.
Protected Member Functions inherited from Aqua::InputOutput::ASCII
virtual void print_header (std::ofstream &f) const
 Write the file header.
virtual void formatLine (std::string &l)
 Conveniently format a read line.
virtual size_t readNParticles (std::ifstream &f)
 Count the number of particles present in the input file.
void print_file (const char sep, const char comp_sep)
 Print the data to a file.
Protected Member Functions inherited from Aqua::InputOutput::Particles
const ProblemSetupsimData () const
 Get the simulation data structure.
void n (const size_t &n)
 Set the number of particles managed by this instance.
const ulvec2 bounds () const
 Get the particle index bounds of the "set of particles" managed by this class.
unsigned int setId () const
 Get the "particles set" index associated with this class.
void loadDefault ()
 Register some default arrays:
void file (const std::string filename)
 Set the file name.
unsigned int file (const std::string basename, unsigned int start_index, unsigned int digits=5)
float time () const
 Get the current simulation time to be written.
cl_event download (std::vector< std::string > fields)
 Download the data from the device and store it.
std::map< std::string, void * > data () const
 Get the stored memory objects where the device data has been downloaded.
Protected Member Functions inherited from Aqua::InputOutput::InputOutput
 InputOutput ()
 Constructor.
virtual ~InputOutput ()
 Destructor.

Detailed Description

Plain text particles data files loader/saver.

These files are formatted as ASCCI plain text where the particles data are stored by rows, and where the fields are separated by columns.

Note
Comments are allowed using the symbol "#", such that all the text after this symbol, and in the same line, will be discarded. The fields can be separated by the following symbols:
  • " "
  • ","
  • ";"
  • "("
  • ")"
  • "["
  • "]"
  • "{"
  • "}"
  • tabulator
Remarks
In the case of integer numbers (signed or unsigned) this class does not care about decimal points, just truncating the value, i.e. 1.5 will be interpreted as 1, and -1.5 will be interpreted as -1.
Warning
Saving the particles data in plain text format may be heavily hard disk demanding, and therefore it is strongly recommended to consider binary formats like Aqua::InputOutput::VTK.

Constructor & Destructor Documentation

◆ FastASCII()

Aqua::InputOutput::FastASCII::FastASCII ( ProblemSetup & sim_data,
unsigned int iset,
size_t offset,
size_t n = 0,
const std::string file_ext = ".dat" )

Constructor.

Parameters
sim_dataSimulation data
isetParticles set index.
offsetFirst particle managed by this saver/loader.
nNumber of particles managed by this saver/loader. If 0, the number of particles will be obtained from the input file (thus only valid for loaders)
Here is the call graph for this function:

◆ ~FastASCII()

Aqua::InputOutput::FastASCII::~FastASCII ( )

Destructor.

Member Function Documentation

◆ readField()

std::string Aqua::InputOutput::FastASCII::readField ( const std::string field,
const std::string line,
size_t index,
void * data )
protectedvirtual

Extract the field value from a line.

Parameters
fieldField name.
lineText line,
indexIndex of the particle to read.
dataData array.
Returns
Remaining text after extracting the field values.

Reimplemented from Aqua::InputOutput::ASCII.

Here is the call graph for this function:

The documentation for this class was generated from the following files: