fixed: some of my doxygen sins remedied

git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@1261 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
akva
2011-10-13 09:00:04 +00:00
committed by Knut Morten Okstad
parent fd91ae6bf1
commit 341fd41ecc
5 changed files with 228 additions and 10 deletions

View File

@@ -10,25 +10,38 @@
class DataWriter;
class SIMparameters;
/*! \brief Admininster and write data using DataWriters
\details This class holds a list of data writers, and SIM classes/vectors
to write.
*/
class DataExporter
{
public:
//! \brief Supported field types
enum FieldType {
VECTOR,
SIM
};
//! \brief An enum used to describe the results to write
enum Results {
PRIMARY=0,
SECONDARY=1,
NORMS=2
};
//! \brief A structure holding information about registered fields
struct FileEntry {
//! \brief The description of the field
std::string description;
//! \brief The type of the field
FieldType field;
//! \brief Which results to store
int results;
//! \brief Pointer to the primary data (e.g. a SIM class)
void* data;
//! \brief Pointer to the secondary data (e.g. a vector)
void* data2;
};
@@ -54,51 +67,105 @@ class DataExporter
const std::string& description,
FieldType field, int results=PRIMARY);
//! \brief Register a data writer
//! \param[in] writer A pointer to the datawriter we want registered
bool registerWriter(DataWriter* writer);
//! \brief Set the data values for a registered field
//! \param[in] name Name the field is registered with
//! \param[in] data The value to set the field to
//! \param[in] data2 (optional) The secondary data of the field
bool setFieldValue(const std::string& name, void* data, void* data2=NULL);
//! \brief This dumps all registered fields using all registered writers
//! \param[in] tp Current time stepping info
//! \param[in] geometryUpdated Whether or not geometries are updated. If true, we write new geometries
bool dumpTimeLevel(SIMparameters* tp=NULL, bool geometryUpdated=false);
//! \brief Loads last time level with first registered writer by default.
//! param[in] level Time level to load, defaults to last time level
//! param[in] info The datawriter to read the info from (e.g. the XML writer)
//! param[in] input The datawriter to read the data from (e.g. the HDF5 writer)
//! \param[in] level Time level to load, defaults to last time level
//! \param[in] info The datawriter to read the info from (e.g. the XML writer)
//! \param[in] input The datawriter to read the data from (e.g. the HDF5 writer)
bool loadTimeLevel(int level=-1, DataWriter* info=NULL, DataWriter* input=NULL);
//! \brief Return the current time level of the exporter
int getTimeLevel();
protected:
//! \brief Internal helper function
int getWritersTimeLevel() const;
//! \brief A map of field names -> field info structures
std::map<std::string,FileEntry> m_entry;
//! \brief A vector of registered data writers
std::vector<DataWriter*> m_writers;
//! \brief If true, we are in charge of freeing up datawriters
bool m_delete;
//! \brief Current time level
int m_level;
//! \brief A stride for dumping. We dump at every m_ndump'th time level
int m_ndump;
//! \brief The temporal order used. We need this to facilitate restart of > first order simulations.
int m_order;
};
//! \brief Convenience type
typedef std::pair<std::string,DataExporter::FileEntry> DataEntry;
/*! \brief Stores and reads data from a file
A DataWriter is a backend for the DataExporter, they abstract different
file formats.
*/
class DataWriter
{
protected:
//! \brief Protected constructor as this is a purely virtual class
DataWriter(const std::string& name);
public:
//! \brief Empty destructor
virtual ~DataWriter() {}
//! \brief Return the last time level stored in file
virtual int getLastTimeLevel() = 0;
//! \brief Open the file at a given time level
//! \param[in] level The requested time level
virtual void openFile(int level) = 0;
//! \brief Close the file
//! \param[in] level Level we just wrote to the file
//! \param[in] force If true, we always close the actual file,
// else it's up to the individual writers
virtual void closeFile(int level, bool force=false) = 0;
//! \brief Write a vector to file
//! \param[in] level The time level to write the vector at
//! \param[in] entry The DataEntry describing the vector
virtual void writeVector(int level, const DataEntry& entry) = 0;
//! \brief Read a vector from file
//! \param[in] level The time level to read the vector at
//! \param[in] entry The DataEntry describing the vector
virtual bool readVector(int level, const DataEntry& entry) = 0;
//! \brief Write data from a SIM to file
//! \param[in] level The time level to write the data at
//! \param[in] entry The DataEntry describing the vector
//! \param[in] geometryUpdated Whether or not geometries should be written
virtual void writeSIM(int level, const DataEntry& entry,
bool geometryUpdated) = 0;
//! \brief Read data from a file into SIM
//! \param[in] level The time level to read the data at
//! \param[in] entry The DataEntry describing the SIM
virtual bool readSIM(int level, const DataEntry& entry) = 0;
//! \brief Write time stepping info to file (currently a dummy)
//! \param[in] level The time level to write the info at
//! \param[in] order The temporal order
//! \param[in] interval The number of time steps between each data dump
//! \param[in] tp The current time stepping info
virtual bool writeTimeInfo(int level, int order, int interval,
SIMparameters& tp) = 0;

View File

@@ -383,8 +383,11 @@ protected:
//! \brief Evaluates the function.
virtual real evaluate(const Vec3& X) const;
//! \brief The (1D) grid the data is associated with
std::vector<double> grid;
//! \brief The (scalar) data values
std::vector<double> values;
//! \brief In which direction to perform the interpolation
int dir;
};

View File

@@ -5,7 +5,7 @@
//!
//! \date Jul 7 2011
//!
//! \author Arne MOrten Kvarving / SINTEF
//! \author Arne Morten Kvarving / SINTEF
//!
//! \brief Output of model and results to HDF5 file.
//!
@@ -29,6 +29,7 @@
#include <mpi.h>
#endif
//! \brief If file system has less than this amount free we bail to avoid corrupting file when a new write is initiated
#define HDF5_SANITY_LIMIT 10*1024*1024LL // 10MB

View File

@@ -7,44 +7,128 @@
class SIMbase;
/*! \brief Write data to a HDF5 file.
\details The HDF5 writer writes data to a HDF5 file. It supports
parallel I/O, and can be used to add restart capability
to applications.
*/
class HDF5Writer : public DataWriter
{
public:
HDF5Writer(const std::string& name, bool append = false, bool keepopen=false);
//! \brief Default constructor
//! \param[in] name The name (filename without extension) of data file
//! \param[in] append Whether to append to or overwrite an existing file
//! \param[in] keepopen Whether to always keep the HDF5 open
HDF5Writer(const std::string& name, bool append = false,
bool keepopen=false);
//! \brief Default destructor
virtual ~HDF5Writer() {}
//! \brief Return the last time level stored in the HDF5 file
virtual int getLastTimeLevel();
//! \brief Open the file at a given time level
//! \param[in] level The requested time level
virtual void openFile(int level);
//! \brief Close the file
//! \param[in] level Level we just wrote to the file
//! \param[in] force If true, we close even if we were given the keepopen flag on construction
virtual void closeFile(int level, bool force=false);
//! \brief Write a vector to file
//! \param[in] level The time level to write the vector at
//! \param[in] entry The DataEntry describing the vector
virtual void writeVector(int level, const DataEntry& entry);
//! \brief Read a vector from file
//! \param[in] level The time level to read the vector at
//! \param[in] entry The DataEntry describing the vector
virtual bool readVector(int level, const DataEntry& entry);
//! \brief Write data from a SIM to file
//! \param[in] level The time level to write the data at
//! \param[in] entry The DataEntry describing the vector
//! \param[in] geometryUpdated Whether or not geometries should be written
virtual void writeSIM(int level, const DataEntry& entry,
bool geometryUpdated);
//! \brief Read data from a file into SIM
//! \param[in] level The time level to read the data at
//! \param[in] entry The DataEntry describing the SIM
virtual bool readSIM(int level, const DataEntry& entry);
//! \brief Write time stepping info to file (currently a dummy)
//! \param[in] level The time level to write the info at
//! \param[in] order The temporal order
//! \param[in] interval The number of time steps between each data dump
//! \param[in] tp The current time stepping info
virtual bool writeTimeInfo(int level, int order, int interval,
SIMparameters& tp);
//! \brief Reads a vector field into a given SIM
//! \param[in] level The time level to read at
//! \param[in] name The name of the field
//! \param[in] vec The vector to read into
//! \param[in] sim The SIM this vector is associated with
//! \param[in] components The number of components in the field
bool readField(int level, const std::string& name,
Vector& vec, SIMbase* sim, int components);
//! \brief Reads a text string
//! \param[in] name The name (path in HDF5 file) to the string
//! \param[out] out The string to read data into
void readString(const std::string& name, std::string& out);
//! \brief Reads a vector
//! \param[in] level The time level to read at
//! \param[in] name The name (path in HDF5 file) to the string
//! \param[in] patch The patch to read
//! \param[out] vec The vector to read data into
bool readVector(int level, const std::string& name,
int patch, Vector& vec);
//! \brief Check if updated geometries exists in file at given time level
//! \param[in] level The time level to check
bool hasGeometries(int level);
protected:
//! \brief Internal helper function. Writes a data array to HDF5 file
//! \param[in] group The HDF5 group to write data into
//! \param[in] name The name of the array
//! \param[in] len The length of the array
//! \param[in] data The array to write
//! \param[in] type The HDF5 type for the data (see H5T)
void writeArray(int group, const std::string& name,
int len, const void* data, int type);
//! \brief Internal helper function. Writes a SIM's basis (geometry) to file
//! \param[in] SIM The SIM we want to write basis for
//! \param[in] name The name of the basis
//! \param[in] basis 1/2 Write primary or secondary basis from SIM
//! \param[in] level The time level to write the basis at
void writeBasis(SIMbase* SIM, const std::string& name,
int basis, int level);
//! \brief Internal helper function. Reads an array into a array of doubles
//! \param[in] group The HDF5 group to read data from
//! \param[in] name The name of the array
//! \param[in] len The length of the data to read
//! \param[out] data The array to read data into
void readArray(int group, const std::string& name,
int& len, double*& data);
//! \brief Internal helper function. Check if a group exists in the HDF5 file
//! \param[in] parent The HDF5 group of the parent
//! \param[in] group The name of the group to check for
//! \return true if group exists, otherwise false
bool checkGroupExistence(int parent, const char* group);
//! \brief The HDF5 handle for our file
int m_file;
//! \brief The file flags to open HDF5 file with
unsigned int m_flag;
//! \brief If true, we always keep the file open
bool m_keepOpen;
};

View File

@@ -9,24 +9,44 @@ class TiXmlNode;
class SIMparameters;
/*! \brief Write data (metadata) to a XML file.
The XML writer writes metadata (name of fields, description,...)
in a humanly readable (XML) text format.
*/
class XMLWriter : public DataWriter
{
public:
//! \brief A structure used when reading info from the file
struct Entry {
//! \brief Name of field
std::string name;
//! \brief Description of field
std::string description;
//! \brief The name of the basis the field is associated with
std::string basis;
//! \brief Number of patches in field
int patches;
//! \brief Number of components in field
int components;
//! \brief The timestep associated with the field
double timestep;
//! \brief The temporal order associated with the field
int order;
//! \brief The dumping interval for the field
int interval;
//! \brief The type of the field
std::string type;
};
//! \brief Default constructor
//! \param[in] name The name (filename without extension) of data file
XMLWriter(const std::string& name);
//! \brief Default destructor
virtual ~XMLWriter() {}
//! \brief Return the last time level stored in file
virtual int getLastTimeLevel();
//! \brief Calculate the real time level, taking order and ndump into account
@@ -35,30 +55,73 @@ public:
//! \brief Calculate the real time level, taking order and ndump into account
int realTimeLevel(int filelevel, int order, int interval) const;
//! \brief Read info from file
void readInfo();
//! \brief Returns a const vector to the entries (\sa readInfo)
const std::vector<Entry>& getEntries() const { return m_entry; }
//! \brief Open the file at a given time level
//! \param[in] level The requested time level
virtual void openFile(int level);
//! \brief Close the file
//! \param[in] level Level we just wrote to the file
//! \param[in] force Ignored
virtual void closeFile(int level, bool force=false);
//! \brief Write a vector to file
//! \param[in] level The time level to write the vector at
//! \param[in] entry The DataEntry describing the vector
virtual void writeVector(int level, const DataEntry& entry);
//! \brief Read a vector from file
//! \param[in] level The time level to read the vector at
//! \param[in] entry The DataEntry describing the vector
virtual bool readVector(int level, const DataEntry& entry);
//! \brief Write data from a SIM to file
//! \param[in] level The time level to write the data at
//! \param[in] entry The DataEntry describing the vector
//! \param[in] geometryUpdated Ignored
virtual void writeSIM(int level, const DataEntry& entry,
bool geometryUpdated);
virtual bool readSIM(int level, const DataEntry& entry);
virtual bool writeTimeInfo(int level, int order, int interval,
SIMparameters& tp);
//! \brief Read data from a file into SIM
//! \param[in] level The time level to read the data at
//! \param[in] entry The DataEntry describing the SIM
virtual bool readSIM(int level, const DataEntry& entry);
//! \brief Write time stepping info to file (currently a dummy)
//! \param[in] level The time level to write the info at
//! \param[in] order The temporal order
//! \param[in] interval The number of time steps between each data dump
//! \param[in] tp The current time stepping info
virtual bool writeTimeInfo(int level, int order, int interval,
SIMparameters& tp);
protected:
//! \brief Internal helper function
//! \param[in] name The name of the field to add
//! \param[in] description The description of the field to add
//! \param[in] geometry The name of the geometry the field uses
//! \param[in] components Number of components in the field
//! \param[in] patches Number of patches in the field
//! \param[in] type The type of the field
void addField(const std::string& name, const std::string& description,
const std::string& geometry, int components, int patches,
const std::string& type="field");
//! \brief A vector of entries read from file
std::vector<Entry> m_entry;
//! \brief Our xml document
TiXmlDocument* m_doc;
//! \brief The document's root node
TiXmlNode* m_node;
//! \brief The current (constant) timestep
double m_dt;
//! \brief The temporal order
int m_order;
//! \brief A stride for dumping. We dump at every m_interval'th time level
int m_interval;
};