50 "Reads Gmsh msh file.");
52 std::map<unsigned int, ElmtConfig> InputGmsh::elmMap =
53 InputGmsh::GenElmMap();
60 const std::vector<int> &nodes,
int n)
62 std::vector<int> nodeList;
65 nodeList.resize(nodes.size());
68 nodeList[0] = nodes[0];
71 nodeList[n-1] = nodes[1];
72 nodeList[n*n-1] = nodes[2];
73 nodeList[n*(n-1)] = nodes[3];
75 for (
int i = 1; i < n-1; ++i)
77 nodeList[i] = nodes[4+i-1];
79 for (
int i = 1; i < n-1; ++i)
81 nodeList[n*n-1-i] = nodes[4+2*(n-2)+i-1];
88 std::vector<int> interior((n-2)*(n-2));
89 std::copy(nodes.begin() + 4+4*(n-2), nodes.end(), interior.begin());
93 for (
int j = 1; j < n-1; ++j)
95 nodeList[j*n] = nodes[4+3*(n-2)+n-2-j];
96 for (
int i = 1; i < n-1; ++i)
98 nodeList[j*n+i] = interior[(j-1)*(n-2)+(i-1)];
100 nodeList[(j+1)*n-1] = nodes[4+(n-2)+j-1];
108 const std::vector<int> &nodes,
int n)
110 std::vector<int> nodeList;
113 nodeList.resize(nodes.size());
116 nodeList[0] = nodes[0];
119 nodeList[n-1] = nodes[1];
120 nodeList[n*(n+1)/2 - 1] = nodes[2];
125 for (
int i = 1; i < n-1; ++i)
127 nodeList[i] = nodes[3+i-1];
128 nodeList[cnt] = nodes[3+3*(n-2)-i];
129 nodeList[cnt+n-i-1] = nodes[3+(n-2)+i-1];
137 std::vector<int> interior((n-3)*(n-2)/2);
138 std::copy(nodes.begin() + 3+3*(n-2), nodes.end(), interior.begin());
144 for (
int j = 1; j < n-2; ++j)
146 for (
int i = 0; i < n-j-2; ++i)
148 nodeList[cnt+i+1] = interior[cnt2+i];
201 boost::unordered_map<int, vector<int> > orderingMap;
202 boost::unordered_map<int, vector<int> >
::iterator oIt;
206 cout <<
"InputGmsh: Start reading file..." << endl;
212 stringstream s(line);
217 if (word ==
"$Nodes")
220 stringstream s(line);
223 for (
int i = 0; i < nVertices; ++i)
226 stringstream st(line);
227 double x = 0, y = 0, z = 0;
228 st >>
id >> x >> y >> z;
230 if ((x * x) > 0.000001 &&
m_mesh->m_spaceDim < 1)
234 if ((y * y) > 0.000001 &&
m_mesh->m_spaceDim < 2)
238 if ((z * z) > 0.000001 &&
m_mesh->m_spaceDim < 3)
247 cerr <<
"Gmsh vertex ids should be contiguous" << endl;
251 m_mesh->m_node.push_back(boost::shared_ptr<Node>(
new Node(
id, x, y, z)));
255 else if (word ==
"$Elements")
258 stringstream s(line);
260 for (
int i = 0; i < nEntities; ++i)
263 stringstream st(line);
264 int id = 0, num_tag = 0, num_nodes = 0;
266 st >>
id >> elm_type >> num_tag;
269 it =
elmMap.find(elm_type);
272 cerr <<
"Error: element type " << elm_type
273 <<
" not supported" << endl;
279 for (
int j = 0; j < num_tag; ++j)
287 maxTagId = max(maxTagId, tags[0]);
290 vector<NodeSharedPtr> nodeList;
292 for (
int k = 0; k < num_nodes; ++k)
297 nodeList.push_back(
m_mesh->m_node[node]);
301 oIt = orderingMap.find(elm_type);
304 if (oIt == orderingMap.end())
306 oIt = orderingMap.insert(
312 if (oIt->second.size() > 0)
314 vector<int> &mapping = oIt->second;
315 vector<NodeSharedPtr> tmp = nodeList;
316 for (
int i = 0; i < mapping.size(); ++i)
318 nodeList[i] = tmp[mapping[i]];
324 CreateInstance(it->second.m_e,it->second,nodeList,tags);
327 if (E->GetDim() >
m_mesh->m_expDim) {
328 m_mesh->m_expDim = E->GetDim();
330 m_mesh->m_element[E->GetDim()].push_back(E);
337 map<int, map<LibUtilities::ShapeType, int> > compMap;
338 map<int, map<LibUtilities::ShapeType, int> >
::iterator cIt;
341 for (
int i = 0; i <
m_mesh->m_element[
m_mesh->m_expDim].size(); ++i)
346 vector<int> tags = el->GetTagList();
349 cIt = compMap.find(tag);
351 if (cIt == compMap.end())
353 compMap[tag][type] = tag;
358 sIt = cIt->second.find(type);
359 if (sIt == cIt->second.end())
362 cIt->second[type] = maxTagId;
364 el->SetTagList(tags);
366 else if (sIt->second != tag)
368 tags[0] = sIt->second;
369 el->SetTagList(tags);
373 bool printInfo =
false;
374 for (cIt = compMap.begin(); cIt != compMap.end(); ++cIt)
376 if (cIt->second.size() > 1)
385 cout <<
"Multiple elements in composite detected; remapped:"
387 for (cIt = compMap.begin(); cIt != compMap.end(); ++cIt)
389 if (cIt->second.size() > 1)
391 sIt = cIt->second.begin();
392 cout <<
"- Tag " << cIt->first <<
" => " << sIt->second
397 for (; sIt != cIt->second.end(); ++sIt)
399 cout <<
", " << sIt->second <<
" ("
425 it =
elmMap.find(InputGmshEntity);
429 cerr <<
"Unknown element type " << InputGmshEntity << endl;
433 switch(it->second.m_e)
449 it->second.m_faceCurveType =
462 cerr <<
"Unknown element type!" << endl;
482 it =
elmMap.find(InputGmshEntity);
486 cerr <<
"Unknown element type " << InputGmshEntity << endl;
492 switch(it->second.m_e)
514 vector<int> returnVal;
523 const int order = conf.
m_order;
524 const int n = order-1;
527 vector<int> mapping(3);
528 for (
int i = 0; i < 3; ++i)
539 mapping.resize(3 + 3*n);
541 for (
int i = 3; i < 3+3*n; ++i)
552 vector<int> interior(n*(n-1)/2);
553 for (
int i = 0; i < interior.size(); ++i)
555 interior[i] = i + 3+3*n;
558 if (interior.size() > 0)
563 mapping.insert(mapping.end(), interior.begin(), interior.end());
572 const int order = conf.
m_order;
573 const int n = order-1;
576 vector<int> mapping(4);
577 for (
int i = 0; i < 4; ++i)
588 mapping.resize(4 + 4*n);
590 for (
int i = 4; i < 4+4*n; ++i)
601 vector<int> interior(n*n);
602 for (
int i = 0; i < interior.size(); ++i)
604 interior[i] = i + 4+4*n;
607 if (interior.size() > 0)
611 mapping.insert(mapping.end(), interior.begin(), interior.end());
620 const int order = conf.
m_order;
621 const int n = order-1;
622 const int n2 = n*(n-1)/2;
625 vector<int> mapping(4);
628 for (i = 0; i < 4; ++i)
639 mapping.resize(4 + 6*n);
642 static int gmshToNekEdge[6] = {0,1,2,3,5,4};
643 static int gmshToNekRev [6] = {0,0,1,1,1,1};
647 for (i = 0; i < 6; ++i)
649 offset = 4 + n * gmshToNekEdge[i];
653 for (
int j = 0; j < n; ++j)
655 mapping[offset+n-j-1] = cnt++;
660 for (
int j = 0; j < n; ++j)
662 mapping[offset+j] = cnt++;
673 mapping.resize(4 + 6*n + 4*n2);
675 static int gmshToNekFace[4] = {0,1,3,2};
677 vector<int> triVertId(3);
678 triVertId[0] = 0; triVertId[1] = 1; triVertId[2] = 2;
681 for (i = 0; i < 4; ++i)
683 int face = gmshToNekFace[i];
684 int offset2 = 4 + 6*n + i *n2;
685 offset = 4 + 6*n + face*n2;
688 vector<int> faceNodes(n2);
689 vector<int> toAlign (3);
690 for (j = 0; j < n2; ++j)
692 faceNodes[j] = offset2 + j;
701 if (i == 0 || i == 2)
704 toAlign[0] = 0; toAlign[1] = 2; toAlign[2] = 1;
705 hoTri.
Align(toAlign);
710 toAlign[0] = 1; toAlign[1] = 2; toAlign[2] = 0;
711 hoTri.
Align(toAlign);
715 for (j = 0; j < n2; ++j)
734 const int order = conf.
m_order;
735 const int n = order-1;
738 vector<int> mapping(6);
743 static int gmshToNekVerts[6] = {3,4,1,0,5,2};
745 for (i = 0; i < 6; ++i)
747 mapping[i] = gmshToNekVerts[i];
756 mapping.resize(6 + 9*n);
758 static int gmshToNekEdge[9] = {2,7,3,6,1,8,0,4,5};
759 static int gmshToNekRev [9] = {1,0,1,0,1,1,0,0,0};
763 for (i = 0; i < 9; ++i)
765 offset = 6 + n * gmshToNekEdge[i];
769 for (
int j = 0; j < n; ++j)
771 mapping[offset+n-j-1] = cnt++;
776 for (
int j = 0; j < n; ++j)
778 mapping[offset+j] = cnt++;
790 cerr <<
"Gmsh prisms of order > 2 with face curvature "
791 <<
"not supported in MeshConvert (or indeed Gmsh at"
792 <<
"time of writing)." << endl;
809 const int order = conf.
m_order;
810 const int n = order-1;
811 const int n2 = n * n;
817 static int gmshToNekEdge[12] = {
818 0, -3, 4, 1, 5, 2, 6, 7, 8, -11, 9, 10
823 for (i = 0; i < 8; ++i)
834 mapping.resize(8 + 12*n);
838 for (i = 0; i < 12; ++i)
840 int edge = gmshToNekEdge[i];
841 offset = 8 + n * abs(edge);
845 for (
int j = 0; j < n; ++j)
847 mapping[offset+n-j-1] = cnt++;
852 for (
int j = 0; j < n; ++j)
854 mapping[offset+j] = cnt++;
865 mapping.resize(8 + 12*n + 6*n2);
868 static int gmsh2NekFace[6] = {0,1,4,2,3,5};
877 StdRegions::eDir1FwdDir1_Dir2FwdDir2
880 for (i = 0; i < 6; ++i)
882 int face = gmsh2NekFace[i];
883 int offset2 = 8 + 12 * n + i * n2;
884 offset = 8 + 12 * n + face * n2;
887 vector<int> faceNodes(n2);
888 for (j = 0; j < n2; ++j)
890 faceNodes[j] = offset2 + j;
902 for (j = 0; j < n2; ++j)
904 mapping[offset+j] = tmp[j];
910 for (j = 0; j < n; ++j)
912 for (k = 0; k < n; ++k)
914 mapping[offset + j*n + k] = tmp[k*n + j];
920 for (j = 0; j < n; ++j)
922 for (k = 0; k < n; ++k)
924 mapping[offset + j*n + k] = tmp[j*n + (n-k-1)];
935 const int totPoints = (order+1) * (order+1) * (order+1);
936 mapping.resize(totPoints);
939 for (i = 8 + 12*n + 6*n2; i < totPoints; ++i)
959 using namespace LibUtilities;
960 std::map<unsigned int, ElmtConfig> tmp;