Commit 3d291c93 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* ParaView animation file writer

parent c7001e3c
...@@ -23,7 +23,6 @@ namespace AMDiS { ...@@ -23,7 +23,6 @@ namespace AMDiS {
FUNCNAME("FileWriter::FileWriter()"); FUNCNAME("FileWriter::FileWriter()");
initialize(); initialize();
readParameters();
feSpace = vec->getFESpace(); feSpace = vec->getFESpace();
...@@ -41,7 +40,6 @@ namespace AMDiS { ...@@ -41,7 +40,6 @@ namespace AMDiS {
FUNCNAME("FileWriter::FileWriter()"); FUNCNAME("FileWriter::FileWriter()");
initialize(); initialize();
readParameters();
for (int i = 0; i < static_cast<int>(vecs.size()); i++) { for (int i = 0; i < static_cast<int>(vecs.size()); i++) {
TEST_EXIT(vecs[0]->getFESpace() == vecs[i]->getFESpace()) TEST_EXIT(vecs[0]->getFESpace() == vecs[i]->getFESpace())
...@@ -62,7 +60,6 @@ namespace AMDiS { ...@@ -62,7 +60,6 @@ namespace AMDiS {
FUNCNAME("FileWriter::FileWriter()"); FUNCNAME("FileWriter::FileWriter()");
initialize(); initialize();
readParameters();
// Create the temporal DOFVectors for all components of WorldVector. // Create the temporal DOFVectors for all components of WorldVector.
nTmpSolutions_ = (*vec)[0].getSize(); nTmpSolutions_ = (*vec)[0].getSize();
...@@ -107,12 +104,16 @@ namespace AMDiS { ...@@ -107,12 +104,16 @@ namespace AMDiS {
writeTecPlotFormat = 0; writeTecPlotFormat = 0;
writeAMDiSFormat = 0; writeAMDiSFormat = 0;
writeParaViewFormat = 0; writeParaViewFormat = 0;
writeParaViewAnimation = 0;
writePeriodicFormat = 0; writePeriodicFormat = 0;
appendIndex = 0; appendIndex = 0;
indexLength = 5; indexLength = 5;
indexDecimals = 3; indexDecimals = 3;
tsModulo = 1; tsModulo = 1;
nTmpSolutions_ = 0; nTmpSolutions_ = 0;
paraViewAnimationFrames_.resize(0);
readParameters();
} }
void FileWriter::readParameters() void FileWriter::readParameters()
...@@ -126,7 +127,8 @@ namespace AMDiS { ...@@ -126,7 +127,8 @@ namespace AMDiS {
GET_PARAMETER(0, name + "->AMDiS mesh ext", &amdisMeshExt); GET_PARAMETER(0, name + "->AMDiS mesh ext", &amdisMeshExt);
GET_PARAMETER(0, name + "->AMDiS data ext", &amdisDataExt); GET_PARAMETER(0, name + "->AMDiS data ext", &amdisDataExt);
GET_PARAMETER(0, name + "->ParaView format", "%d", &writeParaViewFormat); GET_PARAMETER(0, name + "->ParaView format", "%d", &writeParaViewFormat);
GET_PARAMETER(0, name + "->ParaView ext", &paraViewFileExt); GET_PARAMETER(0, name + "->ParaView animation", "%d", &writeParaViewAnimation);
GET_PARAMETER(0, name + "->ParaView ext", &paraViewFileExt);
GET_PARAMETER(0, name + "->Periodic format", "%d", &writePeriodicFormat); GET_PARAMETER(0, name + "->Periodic format", "%d", &writePeriodicFormat);
GET_PARAMETER(0, name + "->Periodic ext", &periodicFileExt); GET_PARAMETER(0, name + "->Periodic ext", &periodicFileExt);
GET_PARAMETER(0, name + "->append index", "%d", &appendIndex); GET_PARAMETER(0, name + "->append index", "%d", &appendIndex);
...@@ -211,6 +213,12 @@ namespace AMDiS { ...@@ -211,6 +213,12 @@ namespace AMDiS {
MSG("ParaView file written to %s\n", (fn + paraViewFileExt).c_str()); MSG("ParaView file written to %s\n", (fn + paraViewFileExt).c_str());
} }
if (writeParaViewAnimation) {
VtkWriter::updateAnimationFile(fn + paraViewFileExt,
&paraViewAnimationFrames_,
const_cast<char*>( (filename + ".pvd").c_str()));
}
for (int i = 0; i < static_cast<int>(dc.size()); i++) { for (int i = 0; i < static_cast<int>(dc.size()); i++) {
DELETE dc[i]; DELETE dc[i];
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#ifndef AMDIS_FILEWRITER_H #ifndef AMDIS_FILEWRITER_H
#define AMDIS_FILEWRITER_H #define AMDIS_FILEWRITER_H
#include <vector>
#include <string> #include <string>
#include "MemoryManager.h" #include "MemoryManager.h"
#include "MatrixVector.h" #include "MatrixVector.h"
...@@ -208,6 +209,12 @@ namespace AMDiS { ...@@ -208,6 +209,12 @@ namespace AMDiS {
*/ */
int writeParaViewFormat; int writeParaViewFormat;
/** \brief
* 0: Don't write ParaView animation file.
* 1: Write ParaView animation file.
*/
int writeParaViewAnimation;
/** \brief /** \brief
* 0: Don't write periodic files. * 0: Don't write periodic files.
* 1: Write periodic files. * 1: Write periodic files.
...@@ -235,6 +242,11 @@ namespace AMDiS { ...@@ -235,6 +242,11 @@ namespace AMDiS {
*/ */
int tsModulo; int tsModulo;
/** \brief
* Stores all writen filename to a ParaView animation file.
*/
::std::vector< ::std::string > paraViewAnimationFrames_;
/** /**
*/ */
int timestepNumber; int timestepNumber;
......
...@@ -80,7 +80,7 @@ namespace AMDiS { ...@@ -80,7 +80,7 @@ namespace AMDiS {
* Destructor * Destructor
*/ */
virtual ~ProblemScal() { virtual ~ProblemScal() {
FUNCNAME("~ProblemScal"); FUNCNAME("ProblemScal::~ProblemScal()");
}; };
/** \brief /** \brief
......
#include <stdio.h>
#include <string> #include <string>
#include <fstream> #include <fstream>
...@@ -132,4 +133,35 @@ namespace AMDiS { ...@@ -132,4 +133,35 @@ namespace AMDiS {
return 0; return 0;
} }
int VtkWriter::updateAnimationFile(::std::string valueFilename,
::std::vector< ::std::string > *paraViewAnimationFrames,
const char *animationFilename)
{
size_t found = valueFilename.find_last_of("/\\");
paraViewAnimationFrames->push_back(valueFilename.substr(found + 1));
::std::ofstream file;
file.open(animationFilename);
file << "<?xml version=\"1.0\"?>" << ::std::endl;
file << "<VTKFile type=\"Collection\" version=\"0.1\" >" << ::std::endl;
file << "<Collection>" << ::std::endl;
int counter = 0;
::std::vector< ::std::string >::iterator it;
for (it = paraViewAnimationFrames->begin();
it < paraViewAnimationFrames->end();
++it, counter++) {
file << "<DataSet timestep=\"" << counter
<< "\" part=\"0\" file=\"" << (*it) << "\"/>" << ::std::endl;
}
file << "</Collection>" << ::std::endl;
file << "</VTKFile>" << ::std::endl;
file.close();
return 0;
}
} }
...@@ -29,8 +29,18 @@ namespace AMDiS { ...@@ -29,8 +29,18 @@ namespace AMDiS {
class VtkWriter class VtkWriter
{ {
public: public:
/** \brief
* Writes a ParaView-VTK file.
*/
static int writeFile(::std::vector<DataCollector*> *dc, static int writeFile(::std::vector<DataCollector*> *dc,
const char *name); const char *name);
/** \brief
* Adds a new entry to a ParaView animation file.
*/
static int updateAnimationFile(::std::string valueFilename,
::std::vector< ::std::string > *paraViewAnimationFrames,
const char *animationFilename);
}; };
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment