50 "Reads Gmsh msh file.");
52 std::map<unsigned int, ElmtConfig> InputGmsh::elmMap =
53 InputGmsh::GenElmMap();
96 cout <<
"InputGmsh: Start reading file..." << endl;
102 stringstream s(line);
107 if (word ==
"$Nodes")
110 stringstream s(line);
113 for (
int i = 0; i < nVertices; ++i)
116 stringstream st(line);
117 double x = 0, y = 0, z = 0;
118 st >>
id >> x >> y >> z;
120 if ((x * x) > 0.000001 &&
m_mesh->m_spaceDim < 1)
124 if ((y * y) > 0.000001 &&
m_mesh->m_spaceDim < 2)
128 if ((z * z) > 0.000001 &&
m_mesh->m_spaceDim < 3)
137 cerr <<
"Gmsh vertex ids should be contiguous" << endl;
141 m_mesh->m_node.push_back(boost::shared_ptr<Node>(
new Node(
id, x, y, z)));
145 else if (word ==
"$Elements")
148 stringstream s(line);
150 for (
int i = 0; i < nEntities; ++i)
153 stringstream st(line);
154 int id = 0, num_tag = 0, num_nodes = 0;
156 st >>
id >> elm_type >> num_tag;
159 it =
elmMap.find(elm_type);
162 cerr <<
"Error: element type " << elm_type
163 <<
" not supported" << endl;
169 for (
int j = 0; j < num_tag; ++j)
178 vector<NodeSharedPtr> nodeList;
180 for (
int k = 0; k < num_nodes; ++k)
185 nodeList.push_back(
m_mesh->m_node[node]);
193 swap(nodeList[0], nodeList[3]);
194 swap(nodeList[1], nodeList[4]);
195 swap(nodeList[2], nodeList[5]);
198 swap(nodeList[4], nodeList[2]);
200 if (it->second.m_order == 2)
202 vector<NodeSharedPtr> nodemap(18);
205 nodemap[ 0] = nodeList[ 0];
206 nodemap[ 1] = nodeList[ 1];
207 nodemap[ 2] = nodeList[ 2];
208 nodemap[ 3] = nodeList[ 3];
209 nodemap[ 4] = nodeList[ 4];
210 nodemap[ 5] = nodeList[ 5];
213 nodemap[ 6] = nodeList[12];
214 nodemap[ 7] = nodeList[10];
215 nodemap[ 8] = nodeList[ 6];
216 nodemap[ 9] = nodeList[ 8];
217 nodemap[10] = nodeList[13];
218 nodemap[11] = nodeList[14];
219 nodemap[12] = nodeList[ 9];
220 nodemap[13] = nodeList[ 7];
221 nodemap[14] = nodeList[11];
223 nodemap[15] = nodeList[15];
224 nodemap[16] = nodeList[16];
225 nodemap[17] = nodeList[17];
229 else if (it->second.m_order > 2)
231 cerr <<
"Error: gmsh prisms only supported up "
232 <<
"to second order." << endl;
239 CreateInstance(it->second.m_e,it->second,nodeList,tags);
242 if (E->GetDim() >
m_mesh->m_expDim) {
243 m_mesh->m_expDim = E->GetDim();
245 m_mesh->m_element[E->GetDim()].push_back(E);
267 it =
elmMap.find(InputGmshEntity);
271 cerr <<
"Unknown element type " << InputGmshEntity << endl;
275 switch(it->second.m_e)
302 cerr <<
"Unknown element type!" << endl;
322 using namespace LibUtilities;
323 std::map<unsigned int, ElmtConfig> tmp;