36 #include "AbstractCachedMeshReader.hpp"
45 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
47 : mNumNodeAttributes(0),
50 mNumElementAttributes(0),
57 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
59 const std::string& rFileName)
63 std::vector<std::string> raw_data;
64 std::ifstream data_file(rFileName.c_str());
68 if (!data_file.is_open())
70 EXCEPTION(
"Could not open data file " + rFileName);
75 getline(data_file, raw_line);
82 long hash_location = raw_line.find(
'#', 0);
83 if (hash_location >= 0)
85 raw_line = raw_line.substr(0, hash_location);
89 long not_blank_location = raw_line.find_first_not_of(
" \t", 0);
90 if (not_blank_location >= 0)
92 raw_data.push_back(raw_line);
96 getline(data_file, raw_line);
103 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
107 std::vector<std::vector<unsigned> >::iterator the_iterator;
109 unsigned max_node_index = 0;
111 for (the_iterator = mElementData.begin(); the_iterator < mElementData.end(); the_iterator++)
113 std::vector<unsigned> indices = *the_iterator;
115 for (
unsigned i = 0; i < ELEMENT_DIM+1; i++)
117 if (indices[i] > max_node_index)
119 max_node_index = indices[i];
124 return max_node_index;
127 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
131 std::vector<std::vector<unsigned> >::iterator the_iterator;
133 unsigned min_node_index = UINT_MAX;
135 for (the_iterator = mElementData.begin(); the_iterator < mElementData.end(); the_iterator++)
137 std::vector<unsigned> indices = *the_iterator;
139 for (
unsigned i = 0; i < ELEMENT_DIM+1; i++)
141 if (indices[i] < min_node_index)
143 min_node_index = indices[i];
148 return min_node_index;
151 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
156 if (mpNodeIterator == mNodeData.end())
161 std::vector<double> next_node = *mpNodeIterator;
168 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
173 if (mpElementIterator == mElementData.end())
187 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
190 mpElementIterator = mElementData.begin();
191 mpFaceIterator = mFaceData.begin();
192 mpNodeIterator = mNodeData.begin();
195 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
200 if (mpFaceIterator == mFaceData.end())
202 EXCEPTION(
"All faces (or edges) already got");
214 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
217 return mElementData.size();
220 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
223 return mNodeData.size();
226 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
229 return mFaceData.size();
unsigned GetMaxNodeIndex()
unsigned GetMinNodeIndex()
ElementData GetNextFaceData()
#define EXCEPTION(message)
std::vector< std::string > GetRawDataFromFile(const std::string &rFileName)
ElementData GetNextElementData()
std::vector< unsigned > NodeIndices
AbstractCachedMeshReader()
unsigned GetNumElements() const
unsigned GetNumFaces() const
std::vector< double > GetNextNode()
unsigned GetNumNodes() const