chombo-discharge
Loading...
Searching...
No Matches
Functions
DataParser Namespace Reference

Class for simple data parsing from IO files. More...

Functions

LookupTable1D< Real, 1 > simpleFileReadASCII (const std::string a_fileName, const int a_xColumn=0, const int a_yColumn=1, const std::vector< char > a_ignoreChars={'#', '/'})
 Simple file parser which reads a file and puts the data into two columns (a lookup table).
 
LookupTable1D< Real, 1 > fractionalFileReadASCII (const std::string a_fileName, const std::string a_startRead, const std::string a_stopRead, const int a_xColumn=0, const int a_yColumn=1, const std::vector< char > a_ignoreChars={'#', '/'})
 Simple ASCII file parser which reads a file and puts the data into two columns (a lookup table)
 
List< PointParticlereadPointParticlesASCII (const std::string a_fileName, const unsigned int a_xColumn=0, const unsigned int a_yColumn=1, const unsigned int a_zColumn=2, const unsigned int a_wColumn=3, const std::vector< char > a_ignoreChars={'#', '/'})
 Simple file parser which will read particles (position/weight) from an ASCII file.
 
std::vector< std::shared_ptr< Triangle > > readTriangles (const std::string a_filename, const std::string a_vertexDataIdentifier)
 Read a PLY or VTK triangle mesh file and return a list of Triangle objects.
 

Detailed Description

Class for simple data parsing from IO files.

Function Documentation

◆ fractionalFileReadASCII()

LookupTable1D< Real, 1 > DataParser::fractionalFileReadASCII ( const std::string  a_fileName,
const std::string  a_startRead,
const std::string  a_stopRead,
const int  a_xColumn = 0,
const int  a_yColumn = 1,
const std::vector< char a_ignoreChars = {'#', '/'} 
)

Simple ASCII file parser which reads a file and puts the data into two columns (a lookup table)

This version can read a partial file. It will ignore all lines until the a_startRead string is encountered. After that, it will read files as usual, skipping lines that begin with comments. Empty lines are NOT skipped, since an empty line typically identifies the end of a field from e.g. BOLSIG outputs. Instead to stop reading when an empty line is encountered, one can use a_stopRead="".

Parameters
[in]a_fileNameInput file name. Must be an ASCII file organized into rows and columns.
[in]a_startReadIdentifier where we start parsing lines into the table
[in]a_stopReadIdentifier where we stop parsing lines into the table
[in]a_xColumnWhich column to use as the x-column.
[in]a_yColumnWhich column to use as the y-column.
[in]a_ignoreCharsCharacters indicating comments in the file. Lines starting with these characters are ignored.

◆ readPointParticlesASCII()

List< PointParticle > DataParser::readPointParticlesASCII ( const std::string  a_fileName,
const unsigned int  a_xColumn = 0,
const unsigned int  a_yColumn = 1,
const unsigned int  a_zColumn = 2,
const unsigned int  a_wColumn = 3,
const std::vector< char a_ignoreChars = {'#', '/'} 
)

Simple file parser which will read particles (position/weight) from an ASCII file.

Particles should be arranged as rows, e.g. in the form x y z w 0.0 0.0 0.0 1

Parameters
[in]a_fileNameInput file name. Must be an ASCII file organized into rows and columns.
[in]a_xColumnColumn containing the x-coordinate
[in]a_yColumnColumn containing the y-coordinate
[in]a_zColumnColumn containing the z-coordinate
[in]a_wColumnColumn containing the particle weight
[in]a_ignoreCharsCharacters indicating comments in the file. Lines starting with these characters are ignored.

◆ readTriangles()

std::vector< std::shared_ptr< Triangle > > DataParser::readTriangles ( const std::string  a_filename,
const std::string  a_vertexDataIdentifier 
)

Read a PLY or VTK triangle mesh file and return a list of Triangle objects.

Reads vertex positions and face connectivity from the file. If a_vertexDataIdentifier matches a named per-vertex scalar property in the file (a PLY vertex property or a VTK point-data scalar), that data is stored as the vertex metadata on each Triangle via setVertexData(). If the identifier is not found, a warning is issued and all vertex data values are set to zero.

Non-triangular facets are skipped with a warning. The file type is inferred from the extension (.ply / .PLY or .vtk / .VTK); any other extension results in a fatal error.

Parameters
[in]a_filenamePath to the input mesh file.
[in]a_vertexDataIdentifierName of the per-vertex scalar property to read as Triangle vertex metadata.
Returns
Vector of fully initialised Triangle objects, sorted in file order.

◆ simpleFileReadASCII()

LookupTable1D< Real, 1 > DataParser::simpleFileReadASCII ( const std::string  a_fileName,
const int  a_xColumn = 0,
const int  a_yColumn = 1,
const std::vector< char a_ignoreChars = {'#', '/'} 
)

Simple file parser which reads a file and puts the data into two columns (a lookup table).

This will read ASCII row/column data into a LookupTable1D (which is a simple x-y data structure). The user can specify which columns to use as the x and y coordinates in the LookupTable1D. If the user ask for a column that does not exist in the input file, the data will not be read into the LookupTable1D.

Parameters
[in]a_fileNameInput file name. Must be an ASCII file organized into rows and columns.
[in]a_xColumnWhich column to use as the x-column.
[in]a_yColumnWhich column to use as the y-column.
[in]a_ignoreCharsCharacters indicating comments in the file. Lines starting with these characters are ignored.
Note
xColumn = 0 is the FIRST column, xColumn=1 is the SECOND column and so on.