Gmsh file contains a list of nodes and their coordinates, along with a list of elements and those nodes which define them. We read in and store the list of nodes in #m_node and store the list of elements in #m_element. Each new element is supplied with a list of entries from #m_node which defines the element. Finally some mesh statistics are printed.
{
vector<string> filename;
filename.push_back(
m_config[
"infile"].as<string>());
m_mesh->m_expDim = graph->GetMeshDimension ();
m_mesh->m_spaceDim = graph->GetSpaceDimension();
map<int, NodeSharedPtr> vIdMap;
int nVerts = graph->GetNvertices();
for (int i = 0; i < nVerts; ++i)
{
graph->GetVertex(i);
(*vert)(0), (*vert)(1), (*vert)(2)));
m_mesh->m_vertexSet.insert(n);
vIdMap[vert->GetVid()] = n;
}
map<int, EdgeSharedPtr> eIdMap;
map<int, FaceSharedPtr> fIdMap;
{
int nel = 0;
pair<EdgeSet::iterator,bool> testIns;
nel += tmp.size();
for (it = tmp.begin(); it != tmp.end(); ++it)
{
pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
it->first, boost::dynamic_pointer_cast<
SpatialDomains::Geometry>(it->second));
vector<NodeSharedPtr> curve;
int id0 = it->second->GetVid(0);
int id1 = it->second->GetVid(1);
curve, ptype));
testIns =
m_mesh->m_edgeSet.insert(ed);
(*(testIns.first))->m_id = it->second->GetEid();
eIdMap[it->second->GetEid()] = ed;
}
}
{
int nel = 0;
pair<FaceSet::iterator,bool> testIns;
nel += tmp.size();
for (it = tmp.begin(); it != tmp.end(); ++it)
{
pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
it->first, boost::dynamic_pointer_cast<
SpatialDomains::Geometry>(it->second));
vector<NodeSharedPtr> faceVertices;
vector<EdgeSharedPtr> faceEdges;
vector<NodeSharedPtr> faceNodes;
for(int i = 0; i < 3; ++i)
{
faceVertices.push_back(vIdMap[it->second->GetVid(i)]);
faceEdges.push_back(eIdMap[it->second->GetEid(i)]);
}
testIns =
m_mesh->m_faceSet.insert(fac);
(*(testIns.first))->m_id = it->second->GetFid();
fIdMap[it->second->GetFid()] = fac;
}
for (it2 = tmp3.begin(); it2 != tmp3.end(); ++it2)
{
pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
it2->first, boost::dynamic_pointer_cast<
SpatialDomains::Geometry>(it2->second));
vector<NodeSharedPtr> faceVertices;
vector<EdgeSharedPtr> faceEdges;
vector<NodeSharedPtr> faceNodes;
for(int i = 0; i < 4; ++i)
{
faceVertices.push_back(vIdMap[it2->second->GetVid(i)]);
faceEdges.push_back(eIdMap[it2->second->GetEid(i)]);
}
testIns =
m_mesh->m_faceSet.insert(fac);
(*(testIns.first))->m_id = it2->second->GetFid();
fIdMap[it2->second->GetFid()] = fac;
}
}
for(int i = 0; i < cvec.size(); ++i)
{
int id = cvec[i]->m_curveID;
ASSERTL1(eIdMap.find(
id) != eIdMap.end(),
"Failed to find curved edge");
edg->m_curveType = cvec[i]->m_ptype;
for(int j = 0; j < cvec[i]->m_points.size()-2; ++j)
{
(*cvec[i]->m_points[j+1])(1),
(*cvec[i]->m_points[j+1])(2)));
edg->m_edgeNodes.push_back(n);
}
}
cvec = graph->GetCurvedFaces();
for(int i = 0; i < cvec.size(); ++i)
{
int id = cvec[i]->m_curveID;
ASSERTL1(fIdMap.find(
id) != fIdMap.end(),
"Failed to find curved edge");
fac->m_curveType = cvec[i]->m_ptype;
int Ntot = cvec[i]->m_points.size();
{
int N = ((int)sqrt(8.0*Ntot+1.0)-1)/2;
for(int j = 3+3*(N-2); j < Ntot; ++j)
{
(*cvec[i]->m_points[j])(1),
(*cvec[i]->m_points[j])(2)));
fac->m_faceNodes.push_back(n);
}
}
else
{
int N = (int)sqrt((double)Ntot);
for(int j = 1; j < N-1; ++j)
{
for(int k = 1; k < N-1; ++k)
{
(*cvec[i]->m_points[j*N+k])(0),
(*cvec[i]->m_points[j*N+k])(1),
(*cvec[i]->m_points[j*N+k])(2)));
fac->m_faceNodes.push_back(n);
}
}
}
}
int nel = 0;
for(compIt = GraphComps.begin(); compIt != GraphComps.end(); ++compIt)
{
int dim = (*compIt->second)[0]->GetShapeDim();
{
nel += (*compIt->second).size();
}
}
for(compIt = GraphComps.begin(); compIt != GraphComps.end(); ++compIt)
{
int dim = (*compIt->second)[0]->GetShapeDim();
for(geomIt = (*compIt->second).begin();
geomIt != (*compIt->second).end();
++geomIt)
{
ElmtConfig conf((*geomIt)->GetShapeType(),1,true,true);
vector<NodeSharedPtr> nodeList;
for (int i = 0; i < (*geomIt)->GetNumVerts(); ++i)
{
nodeList.push_back(vIdMap[(*geomIt)->GetVid(i)]);
}
vector<int> tags;
tags.push_back(compIt->first);
CreateInstance((*geomIt)->GetShapeType(),conf,nodeList,tags);
E->SetId((*geomIt)->GetGlobalID());
{
m_mesh->m_element[dim][(*geomIt)->GetGlobalID()] = E;
}
else
{
m_mesh->m_element[dim].push_back(E);
}
if(dim > 1)
{
for (int i = 0; i < (*geomIt)->GetNumEdges(); ++i)
{
E->SetEdge(i,edg);
edg->m_elLink.push_back(pair<ElementSharedPtr,int>(E,i));
}
}
if(dim == 3)
{
for (int i = 0; i < (*geomIt)->GetNumFaces(); ++i)
{
E->SetFace(i,fac);
fac->m_elLink.push_back(pair<ElementSharedPtr,int>(E,i));
}
}
}
}
}