AbstractMeshReader.cpp

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 #include <cassert>
00029 #include "AbstractMeshReader.hpp"
00030 #include "Exception.hpp"
00031 
00033 // Implementation
00035 
00036 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00037 unsigned AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetNumElementAttributes() const
00038 {
00039     // By default returns 0.  If a concrete class does read attributes
00040     // it needs to overload this method.
00041     return 0;
00042 }
00043 
00044 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00045 unsigned AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetNumEdges() const
00046 {
00047     return GetNumFaces();
00048 }
00049 
00050 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00051 unsigned AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetNumFaceAttributes() const
00052 {
00053     // By default returns 0.  If a concrete class does read attributes
00054     // it needs to overload this method.
00055     return 0;
00056 }
00057 
00058 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00059 std::vector<double> AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetNodeAttributes()
00060 {
00061     // By default returns an empty vector.  If a concrete class does read node attributes
00062     // it needs to overload this method.
00063     std::vector<double> empty;
00064     return empty;
00065 }
00066 
00067 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00068 ElementData AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetNextEdgeData()
00069 {
00070     return GetNextFaceData();
00071 }
00072 
00073 
00074 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00075 std::vector<double> AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetNode(unsigned index)
00076 {
00077     EXCEPTION("Random access is only implemented in mesh readers for binary mesh files.");
00078 }
00079 
00080 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00081 ElementData AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetElementData(unsigned index)
00082 {
00083     EXCEPTION("Random access is only implemented in mesh readers for binary mesh files.");
00084 }
00085 
00086 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00087 ElementData AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetFaceData(unsigned index)
00088 {
00089     EXCEPTION("Random access is only implemented in mesh readers for binary mesh files.");
00090 }
00091 
00092 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00093 ElementData AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetEdgeData(unsigned index)
00094 {
00095     return GetFaceData(index);
00096 }
00097 
00098 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00099 std::vector<unsigned> AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetContainingElementIndices(unsigned index)
00100 {
00101     EXCEPTION("Ncl files are only implemented in mesh readers for binary mesh files.");
00102 }
00103 
00104 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00105 std::string AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetMeshFileBaseName()
00106 {
00107     return "";
00108 }
00109 
00110 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00111 bool AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::IsFileFormatBinary()
00112 {
00113     return false;
00114 }
00115 
00116 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00117 bool AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::HasNclFile()
00118 {
00119     return false;
00120 }
00121 
00122 
00123 // Cable elements aren't supported in most formats
00124 
00125 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00126 unsigned AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetNumCableElements() const
00127 {
00128     return 0u;
00129 }
00130 
00131 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00132 unsigned AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetNumCableElementAttributes() const
00133 {
00134     return 0u;
00135 }
00136 
00137 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00138 ElementData AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>::GetNextCableElementData()
00139 {
00140     EXCEPTION("Cable elements are not supported by this mesh format.");
00141 }
00142 
00143 
00145 // Explicit instantiation
00147 
00148 template class AbstractMeshReader<0,1>;
00149 template class AbstractMeshReader<1,1>;
00150 template class AbstractMeshReader<1,2>;
00151 template class AbstractMeshReader<1,3>;
00152 template class AbstractMeshReader<2,2>;
00153 template class AbstractMeshReader<2,3>;
00154 template class AbstractMeshReader<3,3>;

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