// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == TU Dresden == // == == // == Institut für Wissenschaftliches Rechnen == // == Zellescher Weg 12-14 == // == 01069 Dresden == // == germany == // == == // ============================================================================ // == == // == https://gforge.zih.tu-dresden.de/projects/amdis/ == // == == // ============================================================================ /** \file VtkWriter.h */ #ifndef AMDIS_VTKWRITER_H #define AMDIS_VTKWRITER_H #ifdef HAVE_BOOST #include #include #include #include #endif #include #include "BasisFunction.h" #include "DataCollector.h" #include "FileWriter.h" namespace AMDiS { class VtkWriter { public: VtkWriter(std::vector *dc) : dataCollector(dc), compress(NONE) { degree = (*dataCollector)[0]->getFeSpace()->getBasisFcts()->getDegree(); dim = (*dataCollector)[0]->getMesh()->getDim(); } /// Writes a ParaView-VTK file. int writeFile(std::string name); /// Writes a pvtu file, which contains the links to all the rank files. void writeParallelFile(std::string name, int nRanks, std::string fnPrefix, std::string fnPostfix); /// May be used to simply write ParaView files. static void writeFile(DOFVector *values, std::string filename); /// Set a compressing method for file output. void setCompression(FileCompression c) { compress = c; } /// Adds a new entry to a ParaView animation file. int updateAnimationFile(std::string valueFilename, std::vector< std::string > *paraViewAnimationFrames, std::string animationFilename); protected: /// Writes the VTK file to an arbitrary stream. template void writeFileToStream(T &file); /// Writes all coordinates of vertices and interpolation points to an output file. template void writeVertexCoords(T &file); /// Writes all values of vertices and interpolation point to an output file. template void writeVertexValues(T &file, int componentNo); /// Writes the connectivity of all simplices to an output file. template void writeConnectivity(T &file); /// Writes the connectivity for the case dim = 2 and degree = 2 to an output file. template void writeConnectivity_dim2_degree2(T &file); /// Writes the connectivity for the case dim = 2 and degree = 3 to an output file. template void writeConnectivity_dim2_degree3(T &file); /// Writes the connectivity for the case dim = 2 and degree = 4 to an output file. template void writeConnectivity_dim2_degree4(T &file); #ifdef HAVE_BOOST /// Writes a world coordinate to a given file. inline void writeCoord(boost::iostreams::filtering_ostream &file, WorldVector coord) { for (int i = 0; i < Global::getGeo(WORLD); i++) file << " " << std::scientific << coord[i]; for (int i = Global::getGeo(WORLD); i < 3; i++) file << " 0.0"; file << "\n"; } #endif /// Writes a world coordinate to a given file. inline void writeCoord(std::ofstream &file, WorldVector coord) { for (int i = 0; i < Global::getGeo(WORLD); i++) file << " " << std::scientific << coord[i]; for (int i = Global::getGeo(WORLD); i < 3; i++) file << " 0.0"; file << "\n"; } private: /// List of DataCollectors, for each component of the problem one. std::vector *dataCollector; /** \brief * Defines if the file has to be compressed for ouput, and with which * kind of compress method. */ FileCompression compress; /// Degree of the basis function of the problem. int degree; /// Dimension of the geometry. int dim; }; } #include "VtkWriter.hh" #endif