62 std::map<unsigned int, ElmtConfig> InputGmsh::elmMap = InputGmsh::GenElmMap();
 
   70     std::vector<int> nodeList;
 
   73     nodeList.resize(nodes.size());
 
   76     nodeList[0] = nodes[0];
 
   79         nodeList[n - 1]     = nodes[1];
 
   80         nodeList[n * n - 1] = nodes[2];
 
   81         nodeList[n * (n - 1)] = nodes[3];
 
   83     for (
int i = 1; i < n - 1; ++i)
 
   85         nodeList[i] = nodes[4 + i - 1];
 
   87     for (
int i = 1; i < n - 1; ++i)
 
   89         nodeList[n * n - 1 - i] = nodes[4 + 2 * (n - 2) + i - 1];
 
   96         std::vector<int> interior((n - 2) * (n - 2));
 
   98             nodes.begin() + 4 + 4 * (n - 2), nodes.end(), interior.begin());
 
  102         for (
int j = 1; j < n - 1; ++j)
 
  104             nodeList[j * n] = nodes[4 + 3 * (n - 2) + n - 2 - j];
 
  105             for (
int i = 1; i < n - 1; ++i)
 
  107                 nodeList[j * n + i] = interior[(j - 1) * (n - 2) + (i - 1)];
 
  109             nodeList[(j + 1) * n - 1] = nodes[4 + (n - 2) + j - 1];
 
  118     std::vector<int> nodeList;
 
  121     nodeList.resize(nodes.size());
 
  124     nodeList[0] = nodes[0];
 
  127         nodeList[n - 1] = nodes[1];
 
  128         nodeList[n * (n + 1) / 2 - 1] = nodes[2];
 
  133     for (
int i = 1; i < n - 1; ++i)
 
  135         nodeList[i]               = nodes[3 + i - 1];
 
  136         nodeList[cnt]             = nodes[3 + 3 * (n - 2) - i];
 
  137         nodeList[cnt + n - i - 1] = nodes[3 + (n - 2) + i - 1];
 
  145         std::vector<int> interior((n - 3) * (n - 2) / 2);
 
  147             nodes.begin() + 3 + 3 * (n - 2), nodes.end(), interior.begin());
 
  153         for (
int j = 1; j < n - 2; ++j)
 
  155             for (
int i = 0; i < n - j - 2; ++i)
 
  157                 nodeList[cnt + i + 1] = interior[cnt2 + i];
 
  208     boost::unordered_map<int, vector<int> > orderingMap;
 
  209     boost::unordered_map<int, vector<int> >
::iterator oIt;
 
  213         cout << 
"InputGmsh: Start reading file..." << endl;
 
  219         stringstream s(line);
 
  224         if (word == 
"$Nodes")
 
  227             stringstream s(line);
 
  230             for (
int i = 0; i < nVertices; ++i)
 
  233                 stringstream st(line);
 
  234                 double x = 0, y = 0, z = 0;
 
  235                 st >> 
id >> x >> y >> z;
 
  237                 if ((x * x) > 0.000001 && 
m_mesh->m_spaceDim < 1)
 
  241                 if ((y * y) > 0.000001 && 
m_mesh->m_spaceDim < 2)
 
  245                 if ((z * z) > 0.000001 && 
m_mesh->m_spaceDim < 3)
 
  252                 if (
id - prevId != 1)
 
  254                     cerr << 
"Gmsh vertex ids should be contiguous" << endl;
 
  259                     boost::shared_ptr<Node>(
new Node(
id, x, y, z)));
 
  263         else if (word == 
"$Elements")
 
  266             stringstream s(line);
 
  268             for (
int i = 0; i < nEntities; ++i)
 
  271                 stringstream st(line);
 
  272                 int id = 0, num_tag = 0, num_nodes = 0;
 
  274                 st >> 
id >> elm_type >> num_tag;
 
  277                 it = 
elmMap.find(elm_type);
 
  280                     cerr << 
"Error: element type " << elm_type
 
  281                          << 
" not supported" << endl;
 
  287                 for (
int j = 0; j < num_tag; ++j)
 
  295                 maxTagId = max(maxTagId, tags[0]);
 
  298                 vector<NodeSharedPtr> nodeList;
 
  300                 for (
int k = 0; k < num_nodes; ++k)
 
  305                     nodeList.push_back(
m_mesh->m_node[node]);
 
  309                 oIt = orderingMap.find(elm_type);
 
  312                 if (oIt == orderingMap.end())
 
  314                     oIt = orderingMap.insert(
 
  319                 if (oIt->second.size() > 0)
 
  321                     vector<int> &mapping      = oIt->second;
 
  322                     vector<NodeSharedPtr> tmp = nodeList;
 
  323                     for (
int i = 0; i < mapping.size(); ++i)
 
  325                         nodeList[i] = tmp[mapping[i]];
 
  331                     it->second.m_e, it->second, nodeList, tags);
 
  334                 if (E->GetDim() > 
m_mesh->m_expDim)
 
  336                     m_mesh->m_expDim = E->GetDim();
 
  338                 m_mesh->m_element[E->GetDim()].push_back(E);
 
  345     map<int, map<LibUtilities::ShapeType, int> > compMap;
 
  346     map<int, map<LibUtilities::ShapeType, int> >
::iterator cIt;
 
  349     for (
int i = 0; i < 
m_mesh->m_element[
m_mesh->m_expDim].size(); ++i)
 
  354         vector<int> tags = el->GetTagList();
 
  357         cIt = compMap.find(tag);
 
  359         if (cIt == compMap.end())
 
  361             compMap[tag][type] = tag;
 
  366         sIt = cIt->second.find(type);
 
  367         if (sIt == cIt->second.end())
 
  370             cIt->second[type] = maxTagId;
 
  372             el->SetTagList(tags);
 
  374         else if (sIt->second != tag)
 
  376             tags[0] = sIt->second;
 
  377             el->SetTagList(tags);
 
  381     bool printInfo = 
false;
 
  382     for (cIt = compMap.begin(); cIt != compMap.end(); ++cIt)
 
  384         if (cIt->second.size() > 1)
 
  393         cout << 
"Multiple elements in composite detected; remapped:" << endl;
 
  394         for (cIt = compMap.begin(); cIt != compMap.end(); ++cIt)
 
  396             if (cIt->second.size() > 1)
 
  398                 sIt = cIt->second.begin();
 
  399                 cout << 
"- Tag " << cIt->first << 
" => " << sIt->second << 
" (" 
  403                 for (; sIt != cIt->second.end(); ++sIt)
 
  405                     cout << 
", " << sIt->second << 
" (" 
  430     it = 
elmMap.find(InputGmshEntity);
 
  434         cerr << 
"Unknown element type " << InputGmshEntity << endl;
 
  438     switch (it->second.m_e)
 
  441             nNodes = Point::GetNumNodes(it->second);
 
  444             nNodes = Line::GetNumNodes(it->second);
 
  447             nNodes = Triangle::GetNumNodes(it->second);
 
  450             nNodes = Quadrilateral::GetNumNodes(it->second);
 
  453             nNodes = Tetrahedron::GetNumNodes(it->second);
 
  457             nNodes = Pyramid::GetNumNodes(it->second);
 
  460             nNodes = Prism::GetNumNodes(it->second);
 
  463             nNodes = Hexahedron::GetNumNodes(it->second);
 
  466             cerr << 
"Unknown element type!" << endl;
 
  486     it = 
elmMap.find(InputGmshEntity);
 
  490         cerr << 
"Unknown element type " << InputGmshEntity << endl;
 
  496     switch (it->second.m_e)
 
  518     vector<int> returnVal;
 
  527     const int order = conf.
m_order;
 
  528     const int n     = order - 1;
 
  531     vector<int> mapping(3);
 
  532     for (
int i = 0; i < 3; ++i)
 
  543     mapping.resize(3 + 3 * n);
 
  545     for (
int i = 3; i < 3 + 3 * n; ++i)
 
  556     vector<int> interior(n * (n - 1) / 2);
 
  557     for (
int i = 0; i < interior.size(); ++i)
 
  559         interior[i] = i + 3 + 3 * n;
 
  562     if (interior.size() > 0)
 
  567     mapping.insert(mapping.end(), interior.begin(), interior.end());
 
  576     const int order = conf.
m_order;
 
  577     const int n     = order - 1;
 
  580     vector<int> mapping(4);
 
  581     for (
int i = 0; i < 4; ++i)
 
  592     mapping.resize(4 + 4 * n);
 
  594     for (
int i = 4; i < 4 + 4 * n; ++i)
 
  605     vector<int> interior(n * n);
 
  606     for (
int i = 0; i < interior.size(); ++i)
 
  608         interior[i] = i + 4 + 4 * n;
 
  611     if (interior.size() > 0)
 
  615     mapping.insert(mapping.end(), interior.begin(), interior.end());
 
  624     const int order = conf.
m_order;
 
  625     const int n     = order - 1;
 
  626     const int n2    = n * (n - 1) / 2;
 
  629     vector<int> mapping(4);
 
  632     for (i = 0; i < 4; ++i)
 
  643     mapping.resize(4 + 6 * n);
 
  646     static int gmshToNekEdge[6] = {0, 1, 2, 3, 5, 4};
 
  647     static int gmshToNekRev[6]  = {0, 0, 1, 1, 1, 1};
 
  651     for (i = 0; i < 6; ++i)
 
  653         offset = 4 + n * gmshToNekEdge[i];
 
  657             for (
int j = 0; j < n; ++j)
 
  659                 mapping[offset + n - j - 1] = cnt++;
 
  664             for (
int j = 0; j < n; ++j)
 
  666                 mapping[offset + j] = cnt++;
 
  677     mapping.resize(4 + 6 * n + 4 * n2);
 
  679     static int gmshToNekFace[4] = {0, 1, 3, 2};
 
  681     vector<int> triVertId(3);
 
  687     for (i = 0; i < 4; ++i)
 
  689         int face    = gmshToNekFace[i];
 
  690         int offset2 = 4 + 6 * n + i * n2;
 
  691         offset      = 4 + 6 * n + face * n2;
 
  694         vector<int> faceNodes(n2);
 
  695         vector<int> toAlign(3);
 
  696         for (j = 0; j < n2; ++j)
 
  698             faceNodes[j] = offset2 + j;
 
  707         if (i == 0 || i == 2)
 
  713             hoTri.
Align(toAlign);
 
  721             hoTri.
Align(toAlign);
 
  725         for (j = 0; j < n2; ++j)
 
  727             mapping[offset + j] = hoTri.
surfVerts[j];
 
  744     const int order = conf.
m_order;
 
  745     const int n     = order - 1;
 
  748     vector<int> mapping(6);
 
  753     static int gmshToNekVerts[6] = {3, 4, 1, 0, 5, 2};
 
  755     for (i = 0; i < 6; ++i)
 
  757         mapping[i] = gmshToNekVerts[i];
 
  766     mapping.resize(6 + 9 * n);
 
  768     static int gmshToNekEdge[9] = {2, 7, 3, 6, 1, 8, 0, 4, 5};
 
  769     static int gmshToNekRev[9]  = {1, 0, 1, 0, 1, 1, 0, 0, 0};
 
  773     for (i = 0; i < 9; ++i)
 
  775         offset = 6 + n * gmshToNekEdge[i];
 
  779             for (
int j = 0; j < n; ++j)
 
  781                 mapping[offset + n - j - 1] = cnt++;
 
  786             for (
int j = 0; j < n; ++j)
 
  788                 mapping[offset + j] = cnt++;
 
  800         cerr << 
"Gmsh prisms of order > 2 with face curvature " 
  801              << 
"not supported in NekMesh (or indeed Gmsh at" 
  802              << 
"time of writing)." << endl;
 
  819     const int order = conf.
m_order;
 
  820     const int n     = order - 1;
 
  821     const int n2    = n * n;
 
  827     static int gmshToNekEdge[12] = {0, -3, 4, 1, 5, 2, 6, 7, 8, -11, 9, 10};
 
  831     for (i = 0; i < 8; ++i)
 
  842     mapping.resize(8 + 12 * n);
 
  846     for (i = 0; i < 12; ++i)
 
  848         int edge = gmshToNekEdge[i];
 
  849         offset   = 8 + n * abs(edge);
 
  853             for (
int j = 0; j < n; ++j)
 
  855                 mapping[offset + n - j - 1] = cnt++;
 
  860             for (
int j = 0; j < n; ++j)
 
  862                 mapping[offset + j] = cnt++;
 
  873     mapping.resize(8 + 12 * n + 6 * n2);
 
  876     static int gmsh2NekFace[6] = {0, 1, 4, 2, 3, 5};
 
  885         StdRegions::eDir1FwdDir1_Dir2FwdDir2};
 
  887     for (i = 0; i < 6; ++i)
 
  889         int face    = gmsh2NekFace[i];
 
  890         int offset2 = 8 + 12 * n + i * n2;
 
  891         offset      = 8 + 12 * n + face * n2;
 
  894         vector<int> faceNodes(n2);
 
  895         for (j = 0; j < n2; ++j)
 
  897             faceNodes[j] = offset2 + j;
 
  909             for (j = 0; j < n2; ++j)
 
  911                 mapping[offset + j] = tmp[j];
 
  917             for (j = 0; j < n; ++j)
 
  919                 for (k = 0; k < n; ++k)
 
  921                     mapping[offset + j * n + k] = tmp[k * n + j];
 
  927             for (j = 0; j < n; ++j)
 
  929                 for (k = 0; k < n; ++k)
 
  931                     mapping[offset + j * n + k] = tmp[j * n + (n - k - 1)];
 
  942     const int totPoints = (order + 1) * (order + 1) * (order + 1);
 
  943     mapping.resize(totPoints);
 
  946     for (i = 8 + 12 * n + 6 * n2; i < totPoints; ++i)
 
  966     using namespace LibUtilities;
 
  967     std::map<unsigned int, ElmtConfig> tmp;
 
bool m_faceNodes
Denotes whether the element contains face nodes. For 2D elements, if this is true then the element co...
vector< T > surfVerts
The triangle surface vertices – templated so that this can either be nodes or IDs. 
std::vector< int > triTensorNodeOrdering(const std::vector< int > &nodes, int n)
Basic information about an element. 
pair< ModuleType, string > ModuleKey
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey. 
std::vector< int > quadTensorNodeOrdering(const std::vector< int > &nodes, int n)
Reorder a quadrilateral to appear in Nektar++ ordering from Gmsh. 
MeshSharedPtr m_mesh
Mesh object. 
ElementFactory & GetElementFactory()
Represents a point in the domain. 
const char *const ShapeTypeMap[]
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges. 
unsigned int m_order
Order of the element. 
virtual void ProcessVertices()
Extract element vertices. 
bool m_volumeNodes
Denotes whether the element contains volume (i.e. interior) nodes. These are not supported by either ...
virtual void ProcessElements()
Generate element IDs. 
virtual void ProcessComposites()
Generate composites. 
A lightweight struct for dealing with high-order triangle alignment. 
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh. 
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces. 
void Align(vector< int > vertId)
Align this surface to a given vertex ID. 
2D Evenly-spaced points on a Triangle 
boost::shared_ptr< Element > ElementSharedPtr
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.