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

CSV particles data files loader/saver. More...

#include <CSV.hpp>

Inheritance diagram for Aqua::InputOutput::CSV:
Collaboration diagram for Aqua::InputOutput::CSV:

Public Member Functions

 CSV (ProblemSetup &sim_data, unsigned int iset, size_t offset, size_t n=0, const std::string file_ext=".csv", const char sep=',')
 Constructor.
 ~CSV ()
 Destructor.
void load () final
 Load the data.
void print_file () final
 Print the data to a file.
Public Member Functions inherited from Aqua::InputOutput::FastASCII
 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.
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

void print_header (std::ofstream &f) const final
 Write the file header.
void formatLine (std::string &l) final
 Conveniently format a read line.
size_t readNParticles (std::ifstream &f) final
 Count the number of particles present in the input file.
Protected Member Functions inherited from Aqua::InputOutput::FastASCII
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
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

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

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

◆ CSV()

Aqua::InputOutput::CSV::CSV ( ProblemSetup & sim_data,
unsigned int iset,
size_t offset,
size_t n = 0,
const std::string file_ext = ".csv",
const char sep = ',' )

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:

◆ ~CSV()

Aqua::InputOutput::CSV::~CSV ( )

Destructor.

Member Function Documentation

◆ formatLine()

void Aqua::InputOutput::CSV::formatLine ( std::string & l)
finalprotectedvirtual

Conveniently format a read line.

Parameters
lLine text.

Reimplemented from Aqua::InputOutput::ASCII.

Here is the call graph for this function:

◆ load()

void Aqua::InputOutput::CSV::load ( )
finalvirtual

Load the data.

Reimplemented from Aqua::InputOutput::ASCII.

Here is the call graph for this function:

◆ print_file()

void Aqua::InputOutput::CSV::print_file ( )
finalvirtual

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

Reimplemented from Aqua::InputOutput::ASCII.

Here is the call graph for this function:

◆ print_header()

void Aqua::InputOutput::CSV::print_header ( std::ofstream & f) const
finalprotectedvirtual

Write the file header.

Parameters
fThe file handler

Reimplemented from Aqua::InputOutput::ASCII.

Here is the call graph for this function:

◆ readNParticles()

size_t Aqua::InputOutput::CSV::readNParticles ( std::ifstream & f)
finalprotectedvirtual

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 from Aqua::InputOutput::ASCII.

Here is the call graph for this function:

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