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

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

#include <ASCII.hpp>

Inheritance diagram for Aqua::InputOutput::ASCII:
Collaboration diagram for Aqua::InputOutput::ASCII:

Public Member Functions

 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

virtual void print_header (std::ofstream &f) const
 Write the file header.
virtual void formatLine (std::string &l)
 Conveniently format a read line.
virtual std::string readField (const std::string field, const std::string line, size_t index, void *data)
 Extract the field value from a 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. This class accepts math expressions to be evaluated during the file parsing.

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
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

◆ ASCII()

Aqua::InputOutput::ASCII::ASCII ( 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)
file_extExtension for the output files
Here is the call graph for this function:

◆ ~ASCII()

Aqua::InputOutput::ASCII::~ASCII ( )
virtual

Destructor.

Member Function Documentation

◆ formatLine()

void Aqua::InputOutput::ASCII::formatLine ( std::string & l)
protectedvirtual

Conveniently format a read line.

Parameters
lLine text.

Reimplemented in Aqua::InputOutput::CSV.

Here is the call graph for this function:

◆ load()

void Aqua::InputOutput::ASCII::load ( )
virtual

Load the data.

Implements Aqua::InputOutput::InputOutput.

Reimplemented in Aqua::InputOutput::CSV.

Here is the call graph for this function:

◆ print_file() [1/2]

virtual void Aqua::InputOutput::ASCII::print_file ( )
inlinevirtual

Print the data to a file.

This function shall be overloaded by the inherited classes. Remember to call this function anyway to set the user event as completed

Note
This method is public to work with the OpenCL callbacks, but it is not meant to be called by the users

Reimplemented from Aqua::InputOutput::Particles.

Reimplemented in Aqua::InputOutput::CSV.

Here is the call graph for this function:

◆ print_file() [2/2]

void Aqua::InputOutput::ASCII::print_file ( const char sep,
const char comp_sep )
protected

Print the data to a file.

Parameters
sepFields separator
comp_sepComponents separator (for vectorial types)
Note
This method is public to work with the OpenCL callbacks, but it is not meant to be called by the users
Here is the call graph for this function:

◆ print_header()

void Aqua::InputOutput::ASCII::print_header ( std::ofstream & f) const
protectedvirtual

Write the file header.

Parameters
fThe file handler

Reimplemented in Aqua::InputOutput::CSV.

Here is the call graph for this function:

◆ readField()

std::string Aqua::InputOutput::ASCII::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 in Aqua::InputOutput::FastASCII.

Here is the call graph for this function:

◆ readNParticles()

size_t Aqua::InputOutput::ASCII::readNParticles ( std::ifstream & f)
protectedvirtual

Count the number of particles present in the input file.

Parameters
fFile to be read.
Returns
The number of particles found in the file.

Reimplemented in Aqua::InputOutput::CSV.

Here is the call graph for this function:

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