VtkMeshWriter.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #ifndef VTKMESHWRITER_HPP_
00030 #define VTKMESHWRITER_HPP_
00031 
00032 #ifdef CHASTE_VTK
00033 //Requires  "sudo aptitude install libvtk5-dev" or similar
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 //Requires  "sudo aptitude install libvtk5-dev" or similar
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 /*VTKMESHWRITER_HPP_*/

Generated on Tue May 31 14:31:48 2011 for Chaste by  doxygen 1.5.5