// ============================================================================
// == ==
// == AMDiS - Adaptive multidimensional simulations ==
// == ==
// ============================================================================
// == ==
// == crystal growth group ==
// == ==
// == Stiftung caesar ==
// == Ludwig-Erhard-Allee 2 ==
// == 53175 Bonn ==
// == germany ==
// == ==
// ============================================================================
// == ==
// == http://www.caesar.de/cg/AMDiS ==
// == ==
// ============================================================================
/** \file FileWriter.h */
/** \defgroup Output Output module
* @{
@}
*/
#ifndef AMDIS_FILEWRITER_H
#define AMDIS_FILEWRITER_H
#include
#include "MemoryManager.h"
#include "MatrixVector.h"
#include "Mesh.h"
namespace AMDiS {
class ProblemScal;
class ProblemInstat;
class Mesh;
class SystemVector;
class FiniteElemSpace;
class AdaptInfo;
template class DOFVector;
// ============================================================================
// ===== class FileWriterInterface ============================================
// ============================================================================
class FileWriterInterface
{
public:
FileWriterInterface()
: filename(""),
traverseLevel(-1),
traverseFlag(Mesh::CALL_LEAF_EL),
writeElement(NULL)
{};
virtual ~FileWriterInterface() {};
/** \brief
* Interface. Must be overridden in subclasses.
* \param time time index of solution vector.
* \param force enforces the output operation for the last timestep.
*/
virtual void writeFiles(AdaptInfo *adaptInfo, bool force,
int level = -1,
Flag traverseFlag = Mesh::CALL_LEAF_EL,
bool (*writeElem)(ElInfo*) = NULL) = 0;
void setTraverseProperties(int level,
Flag flag,
bool (*writeElem)(ElInfo*))
{
traverseLevel = level;
traverseFlag |= flag;
writeElement = writeElem;
};
::std::string getFilename() {
return filename;
};
void setFilename(::std::string n) {
filename = n;
};
protected:
/** \brief
* Used filename prefix.
*/
::std::string filename;
int traverseLevel;
Flag traverseFlag;
bool (*writeElement)(ElInfo*);
};
// ============================================================================
// ===== class FileWriter =====================================================
// ============================================================================
/**
* \ingroup Output
*
* \brief
* Base class of FileWriterScal and FileWriterVec. Manages the file output
* of solution vectors.
*/
class FileWriter : public FileWriterInterface
{
public:
MEMORY_MANAGED(FileWriter);
/** \brief
* Constructor for a filewriter for one data component.
*/
FileWriter(const ::std::string& name_,
Mesh *mesh_,
DOFVector *vec);
/** \brief
* Constructor for a filewriter with more than one data component.
*/
FileWriter(const ::std::string& name_,
Mesh *mesh_,
::std::vector< DOFVector* > vecs);
/** \brief
* Constructor for a filewriter, when the solution vector is a vector
* of WorldVectors.
*/
FileWriter(const ::std::string &name_,
Mesh *mesh_,
DOFVector< WorldVector > *vec);
/** \brief
* Destructor.
*/
virtual ~FileWriter();
/** \brief
* Implementation of FileWriterInterface::writeFiles().
*/
virtual void writeFiles(AdaptInfo *adaptInfo, bool force,
int level = -1,
Flag traverseFlag = Mesh::CALL_LEAF_EL,
bool (*writeElem)(ElInfo*) = NULL);
protected:
/** \brief
* Initialization of the filewriter.
*/
void initialize();
/** \brief
* Reads all file writer dependend parameters from the init file.
*/
void readParameters();
/** \brief
* Name of the writer.
*/
::std::string name;
/** \brief
* TecPlot file extension.
*/
::std::string tecplotExt;
/** \brief
* AMDiS mesh-file extension.
*/
::std::string amdisMeshExt;
/** \brief
* AMDiS solution-file extension.
*/
::std::string amdisDataExt;
/** \brief
* VTK file extension.
*/
::std::string paraViewFileExt;
/** \brief
* Periodic file extension.
*/
::std::string periodicFileExt;
/** \brief
* 0: Don't write TecPlot files.
* 1: Write TecPlot files.
*/
int writeTecPlotFormat;
/** \brief
* 0: Don't write AMDiS files.
* 1: Write AMDiS files.
*/
int writeAMDiSFormat;
/** \brief
* 0: Don't write ParaView files.
* 1: Write ParaView files.
*/
int writeParaViewFormat;
/** \brief
* 0: Don't write periodic files.
* 1: Write periodic files.
*/
int writePeriodicFormat;
/** \brief
* 0: Don't append time index to filename prefix.
* 1: Append time index to filename prefix.
*/
int appendIndex;
/** \brief
* Total length of appended time index.
*/
int indexLength;
/** \brief
* Number of decimals in time index.
*/
int indexDecimals;
/** \brief
* Timestep modulo: write only every tsModulo-th timestep!
*/
int tsModulo;
/**
*/
int timestepNumber;
/** \brief
* Mesh used for output.
*/
Mesh *mesh;
/** \brief
* fespace used for output.
*/
const FiniteElemSpace *feSpace;
/** \brief
* Pointers to the vectors which store the solution.
*/
::std::vector< DOFVector* > solutionVecs_;
/** \brief
* Stores the number of temporal solutions vectors, which have been created
* in the constructor. If this number is greater than zero, the vectors
* stored in solutionVecs_ must be deleted in the destructor.
*/
int nTmpSolutions_;
};
}
#endif // AMDIS_FILEWRITER_H