libgenua
Basic Geometry, Numerical Algorithms and Interfaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
FFANode Class Reference

Detailed Description

Node in FFA data file.

The FFA file format is used by simulation codes implemented by the Swedish Aeronautical Research Establishment (FFA), which is now part of FOI (http://www.foi.se). The most important application of this classe inside libgenua is the format's use in the EDGE flow solver, which writes its meshes, boundary conditions and top-level configuration to FFA format files.

FFA files are hierarchically structured, where each level of the hierarchy is a two-dimensional array. In some sense, it is really a tree of matrices. Files are stored in a fortran-compatible record-based binary format, which is reasonably efficient as long as nodes are suffiently highly loaded, that is, the number of tree nodes per unit of stored data is small.

Unfortunately, the typical access pattern for FFA binary files makes them rather unsuitable for use with Windows network shares. Very often, the read/write times in that case are much longer than for the equivalent amount of data in CGNS files (for example).

Todo:
Implement streaming format (version 2014)
See Also
MxMesh

#include <ffanode.h>

Public Member Functions

 FFANode ()
 create empty, undefined node
 
 FFANode (const std::string &s)
 create named parent node
 
const std::string & name () const
 access node name
 
void rename (const std::string &s)
 change node name
 
FFADataType contentType () const
 access element type
 
size_t nrows () const
 number of rows ('size')
 
size_t ncols () const
 number of columns ('dimension')
 
size_t numel () const
 number of values (rows*cols)
 
size_t nbytes () const
 number of bytes in content array
 
uint nchildren () const
 number of child nodes
 
FFANodePtr child (uint k) const
 access child node k
 
const FFANodeArray & siblings () const
 convenience interface to facilitate iteration
 
uint findChild (const std::string &s) const
 locate child node named s
 
FFANodePtr findPath (const std::string &path) const
 recursively descend path
 
void copy (const int &x)
 copy single int into node
 
void copy (const int64_t &x)
 copy single int into node
 
void copy (const float &x)
 copy single float into node
 
void copy (const double &x)
 copy single double into node
 
void copy (FFADataType t, int nr, int nc, const void *ptr)
 copy raw data into node
 
void copy (int nr, int nc, const int *ptr)
 copy int array into node
 
void copy (int nr, int nc, const int64_t *ptr)
 copy int array into node
 
void copy (int nr, int nc, const float *ptr)
 copy float array into node
 
void copy (int nr, int nc, const double *ptr)
 copy double array into node
 
void copy (const std::string &s)
 copy single string into node
 
void retrieve (void *dest) const
 retrieve raw data from node
 
void retrieve (std::string &s) const
 put contents into string
 
void retrieve (double &v) const
 retrieve a scalar value
 
void retrieve (int &v) const
 retrieve a scalar value
 
bool retrieve (const std::string &tag, std::string &x) const
 convenience function : find child, retreive x if found
 
bool retrieve (const std::string &tag, double &x) const
 convenience function : find child, retreive x if found
 
bool retrieve (const std::string &tag, int &x) const
 convenience function : find child, retreive x if found
 
FFANodePtr append (const FFANodePtr &np)
 append child node
 
FFANodePtr append (FFANode *np)
 append child node and take ownership
 
FFANodePtr append (const std::string &tag, const std::string &content)
 convenience function : add a named node with string content
 
template<typename NumericType >
FFANodePtr append (const std::string &tag, int nr, int nc, const NumericType values[])
 convenience function : add a matrix node
 
FFANodePtr append (const std::string &tag, double x)
 convenience function : add a scalar value node
 
FFANodePtr append (const std::string &tag, int x)
 convenience function : add a scalar value node
 
FFANodePtr append (const std::string &tag, int64_t x)
 convenience function : add a scalar value node
 
std::string summary () const
 generate summary string
 
void write (const std::string &s) const
 write to file; determine format by extension
 
void read (const std::string &s)
 read from file; determine format by extension
 
void awrite (std::ostream &os) const
 write to ascii file
 
void aread (std::istream &is)
 read from ascii file
 
void bwrite (std::ostream &os) const
 write to binary file
 
void bread (std::istream &is)
 read from binary file
 

Static Public Member Functions

static int elementSize (FFADataType t)
 size of a single element in bytes
 
static char elementCode (FFADataType t)
 data type code character
 
static FFANodePtr create (const std::string &s="")
 utility
 

Private Member Functions

template<class Element >
Elementitem (int i, int j)
 pointer to item at (i,j)
 
template<class Element >
const Elementitem (int i, int j) const
 pointer to item at (i,j)
 
void swapBytes () const
 byte-swap contents
 

Private Attributes

std::string tag
 name of this node
 
FFADataType type
 data type of this node
 
size_t nrow
 number of rows and columns
 
FFANodeArray children
 array of sibling nodes
 
std::vector< char > rblock
 raw storage
 

Static Private Attributes

static float s_tsys
 i/o timing data
 

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