00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef VTKMESHWRITER_HPP_
00030 #define VTKMESHWRITER_HPP_
00031
00032 #ifdef CHASTE_VTK
00033
00034 #define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the strstream deprecated warning for now (gcc4.3)
00035 #include <vtkDoubleArray.h>
00036 #include <vtkCellData.h>
00037 #include <vtkPointData.h>
00038 #include <vtkTetra.h>
00039 #include <vtkTriangle.h>
00040 #include <vtkUnstructuredGrid.h>
00041 #include <vtkUnstructuredGridWriter.h>
00042 #include <vtkXMLUnstructuredGridWriter.h>
00043 #include <vtkXMLPUnstructuredGridWriter.h>
00044
00045 #include <vtkDataCompressor.h>
00046 #include "AbstractTetrahedralMeshWriter.hpp"
00047 #include "Version.hpp"
00048
00049 #include <map>
00050
00057 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00058 class VtkMeshWriter : public AbstractTetrahedralMeshWriter<ELEMENT_DIM, SPACE_DIM>
00059 {
00060
00061
00062
00063 private:
00064 bool mWriteParallelFiles;
00066 std::map<unsigned, unsigned> mGlobalToNodeIndexMap;
00068 std::vector<std::vector<unsigned> > mNodesToSendPerProcess;
00069 std::vector<std::vector<unsigned> > mNodesToReceivePerProcess;
00078 vtkUnstructuredGrid* mpVtkUnstructedMesh;
00079
00084 void MakeVtkMesh();
00085 public:
00086
00094 VtkMeshWriter(const std::string& rDirectory, const std::string& rBaseName, const bool& rCleanDirectory=true);
00095
00099 void WriteFiles();
00100
00108 void AddCellData(std::string name, std::vector<double> data);
00109
00117 void AddCellData(std::string name, std::vector<c_vector<double, SPACE_DIM> > data);
00118
00126 void AddPointData(std::string name, std::vector<double> data);
00127
00135 void AddPointData(std::string name, std::vector<c_vector<double, SPACE_DIM> > data);
00136
00143 void SetParallelFiles(AbstractTetrahedralMesh<ELEMENT_DIM,SPACE_DIM>& rMesh);
00144
00157 void WriteFilesUsingMesh(AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>& rMesh,
00158 bool keepOriginalElementIndexing=true);
00159
00165 void AddProvenance(std::string fileName);
00166
00170 virtual ~VtkMeshWriter();
00171 };
00172
00173 #endif //CHASTE_VTK
00174
00175 #endif