53 "Reads Nektar++ xml file.");
70 vector<string> filename;
71 filename.push_back(
m_config[
"infile"].as<string>());
73 char *prgname =
const_cast<char *
>(
"NekMesh");
79 auto comm = pSession->GetComm();
80 if (comm->GetType().find(
"MPI") != std::string::npos)
85 m_mesh->m_expDim = graph->GetMeshDimension();
86 m_mesh->m_spaceDim = graph->GetSpaceDimension();
89 map<int, NodeSharedPtr> vIdMap;
90 for (
auto &vit : graph->GetAllPointGeoms())
94 vert->GetGlobalID(), (*vert)(0), (*vert)(1), (*vert)(2));
95 m_mesh->m_vertexSet.insert(n);
96 vIdMap[vert->GetVid()] = n;
99 std::unordered_map<int, EdgeSharedPtr> eIdMap;
100 std::unordered_map<int, FaceSharedPtr> fIdMap;
104 for (
auto &it : graph->GetAllSegGeoms())
106 pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
108 std::dynamic_pointer_cast<SpatialDomains::Geometry>(
112 vector<NodeSharedPtr> curve;
113 int id0 = it.second->GetVid(0);
114 int id1 = it.second->GetVid(1);
116 it.second->GetXmap()->GetPointsKeys()[0].GetPointsType();
118 vIdMap[id0], vIdMap[id1], curve, ptype);
120 auto testIns =
m_mesh->m_edgeSet.insert(ed);
121 (*(testIns.first))->m_id = it.second->GetGlobalID();
122 eIdMap[it.second->GetGlobalID()] = ed;
128 for (
auto &it : graph->GetAllTriGeoms())
130 pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
132 std::dynamic_pointer_cast<SpatialDomains::Geometry>(
135 vector<NodeSharedPtr> faceVertices;
136 vector<EdgeSharedPtr> faceEdges;
137 vector<NodeSharedPtr> faceNodes;
139 for (
int i = 0; i < 3; ++i)
141 faceVertices.push_back(vIdMap[it.second->GetVid(i)]);
142 faceEdges.push_back(eIdMap[it.second->GetEid(i)]);
146 faceVertices, faceNodes, faceEdges,
148 auto testIns =
m_mesh->m_faceSet.insert(fac);
149 (*(testIns.first))->m_id = it.second->GetGlobalID();
150 fIdMap[it.second->GetGlobalID()] = fac;
153 for (
auto &it : graph->GetAllQuadGeoms())
155 pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
157 std::dynamic_pointer_cast<SpatialDomains::Geometry>(
160 vector<NodeSharedPtr> faceVertices;
161 vector<EdgeSharedPtr> faceEdges;
162 vector<NodeSharedPtr> faceNodes;
164 for (
int i = 0; i < 4; ++i)
166 faceVertices.push_back(vIdMap[it.second->GetVid(i)]);
167 faceEdges.push_back(eIdMap[it.second->GetEid(i)]);
171 faceVertices, faceNodes, faceEdges,
173 auto testIns =
m_mesh->m_faceSet.insert(fac);
174 (*(testIns.first))->m_id = it.second->GetGlobalID();
175 fIdMap[it.second->GetGlobalID()] = fac;
182 for (
auto &it : graph->GetCurvedEdges())
185 int id = curve->m_curveID;
186 ASSERTL1(eIdMap.find(
id) != eIdMap.end(),
"Failed to find curved edge");
188 edg->m_curveType = curve->m_ptype;
189 for (
int j = 0; j < curve->m_points.size() - 2; ++j)
191 edg->m_edgeNodes.push_back(
192 std::make_shared<Node>(
194 (*curve->m_points[j + 1])(0),
195 (*curve->m_points[j + 1])(1),
196 (*curve->m_points[j + 1])(2)));
201 for (
auto &it : graph->GetCurvedFaces())
204 int id = curve->m_curveID;
205 ASSERTL1(fIdMap.find(
id) != fIdMap.end(),
"Failed to find curved edge");
207 fac->m_curveType = curve->m_ptype;
208 int Ntot = curve->m_points.size();
214 int N = ((int)sqrt(8.0 * Ntot + 1.0) - 1) / 2;
215 for (
int j = 3 + 3 * (N - 2); j < Ntot; ++j)
217 fac->m_faceNodes.push_back(
218 std::make_shared<Node>(
220 (*curve->m_points[j])(0),
221 (*curve->m_points[j])(1),
222 (*curve->m_points[j])(2)));
227 int N = (int)sqrt((
double)Ntot);
229 for (
int j = 1; j < N - 1; ++j)
231 for (
int k = 1; k < N - 1; ++k)
233 fac->m_faceNodes.push_back(
234 std::make_shared<Node>(
235 (j - 1) * (N - 2) + k - 1,
236 (*curve->m_points[j * N + k])(0),
237 (*curve->m_points[j * N + k])(1),
238 (*curve->m_points[j * N + k])(2)));
246 for (
auto &compIt : graph->GetComposites())
249 int dim = compIt.second->m_geomVec[0]->GetShapeDim();
252 for (
auto &geomIt : compIt.second->m_geomVec)
254 ElmtConfig conf(geomIt->GetShapeType(), 1,
true,
true,
false);
257 vector<NodeSharedPtr> nodeList;
258 for (
int i = 0; i < geomIt->GetNumVerts(); ++i)
260 nodeList.push_back(vIdMap[geomIt->GetVid(i)]);
264 tags.push_back(compIt.first);
267 geomIt->GetShapeType(), conf, nodeList, tags);
269 E->SetId(geomIt->GetGlobalID());
270 m_mesh->m_element[dim].push_back(E);
275 E->SetVolumeNodes(edg->m_edgeNodes);
276 E->SetCurveType(edg->m_curveType);
282 for (
int i = 0; i < geomIt->GetNumEdges(); ++i)
287 edg->m_elLink.push_back(pair<ElementSharedPtr, int>(E, i));
293 E->SetVolumeNodes(fac->m_faceNodes);
294 E->SetCurveType(fac->m_curveType);
301 for (
int i = 0; i < geomIt->GetNumFaces(); ++i)
306 fac->m_elLink.push_back(pair<ElementSharedPtr, int>(E, i));
313 m_mesh->m_faceLabels = graph->GetCompositesLabels();
Basic information about an element.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
MeshSharedPtr m_mesh
Mesh object.
std::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
ElementFactory & GetElementFactory()
std::shared_ptr< Node > NodeSharedPtr
std::shared_ptr< Face > FaceSharedPtr
1D Evenly-spaced points using Lagrange polynomial
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
std::pair< ModuleType, std::string > ModuleKey
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
std::shared_ptr< Element > ElementSharedPtr
std::map< std::string, ConfigOption > m_config
List of configuration values.
std::shared_ptr< PointGeom > PointGeomSharedPtr
2D Nodal Fekete Points on a Triangle
std::shared_ptr< Curve > CurveSharedPtr
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
2D Evenly-spaced points on a Triangle
std::pair< ModuleType, std::string > ModuleKey
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, DomainRangeShPtr rng=NullDomainRangeShPtr, bool fillGraph=true)
2D Nodal Electrostatic Points on a Triangle
ModuleFactory & GetModuleFactory()