00001 /* 00002 00003 Copyright (C) University of Oxford, 2005-2009 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 00030 #ifndef _ABSTRACTTETRAHEDRALMESHWRITER_HPP_ 00031 #define _ABSTRACTTETRAHEDRALMESHWRITER_HPP_ 00032 00033 // Forward declaration prevents circular include chain 00034 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM> 00035 class AbstractTetrahedralMesh; 00036 00037 #include <vector> 00038 #include <string> 00039 #include <fstream> 00040 #include <iostream> 00041 #include <sstream> 00042 #include <iomanip> 00043 00044 #include "Exception.hpp" 00045 #include "OutputFileHandler.hpp" 00046 #include "AbstractMeshReader.hpp" 00047 #include "NodeMap.hpp" 00048 00052 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM> 00053 class AbstractTetrahedralMeshWriter 00054 { 00055 protected: 00056 00057 OutputFileHandler *mpOutputFileHandler; 00058 std::string mBaseName; 00060 std::vector< std::vector<double> > mNodeData; 00061 std::vector< std::vector<unsigned> > mElementData; 00062 std::vector< std::vector<unsigned> > mBoundaryFaceData; 00064 std::vector< std::vector<double> >::iterator mpNodeIterator; 00065 std::vector< std::vector<unsigned> >::iterator mpElementIterator; 00066 std::vector< std::vector<unsigned> >::iterator mpBoundaryFaceIterator; 00068 bool mIndexFromZero; 00069 bool mWriteMetaFile; 00071 public: 00072 00080 AbstractTetrahedralMeshWriter(const std::string& rDirectory, 00081 const std::string& rBaseName, 00082 const bool clearOutputDir=true); 00083 00087 virtual ~AbstractTetrahedralMeshWriter(); 00088 00092 std::string GetOutputDirectory(); 00093 00099 void SetNextNode(std::vector<double> nextNode); 00100 00106 virtual void SetNextElement(std::vector<unsigned> nextElement); 00107 00113 void SetNextBoundaryFace(std::vector<unsigned> nextFace); 00114 00119 virtual void WriteFiles()=0; 00120 00124 unsigned GetNumNodes(); 00125 00129 unsigned GetNumElements(); 00130 00134 unsigned GetNumBoundaryFaces(); 00135 00139 unsigned GetNumBoundaryEdges(); 00140 00146 void WriteFilesUsingMesh(AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>& rMesh); 00147 00155 void WriteFilesUsingMesh(const AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>& rMesh); 00156 00162 void WriteFilesUsingMeshReader(AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>& rMeshReader); 00163 00170 void WriteFilesUsingMeshReader(AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>& rMeshReader, 00171 const std::vector<unsigned>& rNodePermutation); 00172 }; 00173 00174 #endif //_ABSTRACTTETRAHEDRALMESHWRITER_HPP_