// ============================================================================
// == ==
// == AMDiS - Adaptive multidimensional simulations ==
// == ==
// == http://www.amdis-fem.org ==
// == ==
// ============================================================================
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.
/** \file FileWriter.h */
/** \defgroup Output Output module
* @{
@}
*/
#ifndef AMDIS_FILEWRITER_H
#define AMDIS_FILEWRITER_H
#include
#include
#include "AMDiS_fwd.h"
#include "Mesh.h"
#include "DataCollector.h"
namespace AMDiS {
typedef enum {
NONE = 0,
GZIP = 1,
BZIP2 = 2
} FileCompression;
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:
/// Used filename prefix.
std::string filename;
int traverseLevel;
Flag traverseFlag;
bool (*writeElement)(ElInfo*);
};
/**
* \ingroup Output
*
* \brief
* Base class of FileWriterScal and FileWriterVec. Manages the file output
* of solution vectors.
*/
class FileWriter : public FileWriterInterface
{
public:
/// Constructor for a filewriter for one data component.
FileWriter(std::string name, Mesh *mesh, DOFVector *vec);
/// Constructor for a filewriter with more than one data component.
FileWriter(std::string name,
Mesh *mesh,
std::vector< DOFVector* > vecs);
/** \brief
* Constructor for a filewriter, when the solution vector is a vector
* of WorldVectors.
*/
FileWriter(std::string name,
Mesh *mesh,
DOFVector< WorldVector > *vec);
/// Destructor
virtual ~FileWriter();
/// 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:
/// Initialization of the filewriter.
void initialize();
/// Reads all file writer dependend parameters from the init file.
void readParameters();
/// Name of the writer.
std::string name;
/// AMDiS mesh-file extension.
std::string amdisMeshExt;
/// AMDiS solution-file extension.
std::string amdisDataExt;
/// VTK file extension.
std::string paraviewFileExt;
/// Parallel VTK file extension.
std::string paraviewParallelFileExt;
/// Periodic file extension.
std::string periodicFileExt;
/// 0: Don't write AMDiS files; 1: Write AMDiS files.
int writeAMDiSFormat;
/// 0: Don't write ParaView files; 1: Write ParaView files.
int writeParaViewFormat;
/// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
int writeParaViewAnimation;
/// 0: Don't write periodic files; 1: Write periodic files.
int writePeriodicFormat;
/// 0: Don't write png files; 1: Write png image files.
int writePngFormat;
/// 0: Gray color picture; 1: RGB picture.
int pngType;
/// 0: Don't write Povray scripts; 1: Write Povray scripts
int writePovrayFormat;
/// camera position for povray script files
std::string povrayCameraLocation;
/// orientation for camera in povray script files
std::string povrayCameraLookAt;
/// name of the template file that will be prepended to all created *.pov files
std::string povrayTemplate;
/** \brief
* 0: Don't append time index to filename prefix.
* 1: Append time index to filename prefix.
*/
int appendIndex;
/// Total length of appended time index.
int indexLength;
/// Number of decimals in time index.
int indexDecimals;
/// Timestep modulo: write only every tsModulo-th timestep!
int tsModulo;
/// Stores all writen filename to a ParaView animation file.
std::vector< std::string > paraviewAnimationFrames;
///
int timestepNumber;
/// Mesh used for output.
Mesh *mesh;
/// fespace used for output.
const FiniteElemSpace *feSpace;
/// 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;
/** \brief
* Defines if, and with what kind of compression, the file should be compressed
* during writing.
*/
FileCompression compression;
};
}
#endif // AMDIS_FILEWRITER_H