39 #include <boost/core/ignore_unused.hpp> 40 #include <boost/algorithm/string/classification.hpp> 41 #include <boost/algorithm/string/split.hpp> 42 #include <boost/algorithm/string/predicate.hpp> 43 #include <boost/iostreams/filtering_streambuf.hpp> 44 #include <boost/iostreams/copy.hpp> 45 #include <boost/iostreams/filter/gzip.hpp> 46 #include <boost/filesystem.hpp> 47 namespace io = boost::iostreams;
66 "Writes a Nektar++ xml file.");
71 "Writes a Nektar++ file with hdf5.");
76 true,
"0",
"Attempt to load resulting mesh and create meshgraph.");
78 true,
"0",
"Print out basic mesh statistics.");
82 false,
"",
"Test a condition.");
90 const std::map<
int, std::shared_ptr<T> > &geomMap,
95 boost::ignore_unused(graph);
97 for (
auto &geomIt : geomMap)
105 int nq = geom->GetXmap()->GetTotPoints();
106 int dim = geom->GetCoordim();
110 for (
int i = 0; i < 3; ++i)
115 for (
int i = 0; i < dim; ++i)
117 geom->GetXmap()->BwdTrans(geom->GetCoeffs(i), coords[i]);
120 for (
int i = 0; i < nq; ++i)
123 exprId, coords[0][i], coords[1][i], coords[2][i], 0.0);
124 ASSERTL0(output == 1.0,
"Output mesh failed coordinate test");
130 for (
int i = 0; i < dim; ++i)
132 evalPt[i] = geom->GetXmap()->PhysEvaluate(eta, coords[i]);
136 exprId, evalPt[0], evalPt[1], evalPt[2], 0.0);
138 "Output mesh failed coordinate midpoint test");
147 cout <<
"OutputNekpp: Writing file..." << endl;
150 int order =
m_config[
"order"].as<
int>();
157 string file =
m_config[
"outfile"].as<
string>();
158 string ext = boost::filesystem::extension(file);
162 m_mesh->PrintStats(std::cout);
166 std::string type =
"XmlCompressed";
169 string filename =
m_config[
"outfile"].as<
string>();
172 if(boost::iequals(ext,
".xml") &&
m_config[
"uncompress"].beenSet)
176 else if(boost::iequals(ext,
".nekg"))
187 std::unordered_map<int, SegGeomSharedPtr> segMap;
195 string out =
m_config[
"outfile"].as<
string>();
196 graph->WriteGeometry(out,
true,
m_mesh->m_metadata);
205 string testcond =
m_config[
"testcond"].as<
string>();
208 if (testcond.length() > 0)
213 vector<string> filenames(1);
218 boost::split(tmp, filename, boost::is_any_of(
"."));
219 filenames[0] = tmp[0] +
".xml";
223 filenames[0] = filename;
226 char *prgname =
const_cast<char *
>(
"NekMesh");
246 for(
auto &it :
m_mesh->m_vertexSet)
249 m_mesh->m_spaceDim, it->m_id, it->m_x, it->m_y, it->m_z);
250 vert->SetGlobalID(it->m_id);
251 pointMap[it->m_id] = vert;
257 std::unordered_map<int, SegGeomSharedPtr> &edgeMap)
259 if (
m_mesh->m_expDim >= 2)
262 for(
auto &it :
m_mesh->m_edgeSet)
265 graph->GetVertex(it->m_n2->m_id)};
267 it->m_id,
m_mesh->m_spaceDim, verts);
268 segMap [it->m_id] = edge;
269 edgeMap[it->m_id] = edge;
276 std::unordered_map<int, SegGeomSharedPtr> &edgeMap)
282 for(
auto &it :
m_mesh->m_faceSet)
284 if(it->m_edgeList.size() == 3)
288 edgeMap[it->m_edgeList[0]->m_id],
289 edgeMap[it->m_edgeList[1]->m_id],
290 edgeMap[it->m_edgeList[2]->m_id]
294 triMap[it->m_id] = tri;
300 edgeMap[it->m_edgeList[0]->m_id],
301 edgeMap[it->m_edgeList[1]->m_id],
302 edgeMap[it->m_edgeList[2]->m_id],
303 edgeMap[it->m_edgeList[3]->m_id]
307 quadMap[it->m_id] = quad;
315 vector<ElementSharedPtr> &elmt =
m_mesh->m_element[
m_mesh->m_expDim];
325 for (
int i = 0; i < elmt.size(); ++i)
327 switch (elmt[i]->GetTag()[0])
331 int id = elmt[i]->GetId();
333 graph->GetVertex(elmt[i]->GetVertex(0)->m_id),
334 graph->GetVertex(elmt[i]->GetVertex(1)->m_id)};
340 int id = elmt[i]->GetId();
342 graph->GetSegGeom(elmt[i]->GetEdge(0)->m_id),
343 graph->GetSegGeom(elmt[i]->GetEdge(1)->m_id),
344 graph->GetSegGeom(elmt[i]->GetEdge(2)->m_id)};
351 int id = elmt[i]->GetId();
353 graph->GetSegGeom(elmt[i]->GetEdge(0)->m_id),
354 graph->GetSegGeom(elmt[i]->GetEdge(1)->m_id),
355 graph->GetSegGeom(elmt[i]->GetEdge(2)->m_id),
356 graph->GetSegGeom(elmt[i]->GetEdge(3)->m_id)};
363 int id = elmt[i]->GetId();
365 for(
int j = 0; j < 4; ++j)
368 graph->GetGeometry2D(elmt[i]->GetFace(j)->m_id);
369 tfaces[j] = static_pointer_cast<
TriGeom>(face);
379 int id = elmt[i]->GetId();
380 for(
int j = 0; j < 5; ++j)
383 graph->GetGeometry2D(elmt[i]->GetFace(j)->m_id);
385 if (face->GetShapeType() ==
388 faces[j] = static_pointer_cast<
TriGeom>(face);
390 else if (face->GetShapeType() ==
393 faces[j] = static_pointer_cast<
QuadGeom>(face);
403 int id = elmt[i]->GetId();
404 for(
int j = 0; j < 5; ++j)
407 graph->GetGeometry2D(elmt[i]->GetFace(j)->m_id);
409 if (face->GetShapeType() ==
412 faces[j] = static_pointer_cast<
TriGeom>(face);
414 else if (face->GetShapeType() ==
417 faces[j] = static_pointer_cast<
QuadGeom>(face);
427 int id = elmt[i]->GetId();
428 for(
int j = 0; j < 6; ++j)
431 graph->GetGeometry2D(elmt[i]->GetFace(j)->m_id);
432 faces[j] = static_pointer_cast<
QuadGeom>(face);
439 ASSERTL0(
false,
"Unknown element type");
446 CurveMap &edges = graph->GetCurvedEdges();
450 for(
auto &it :
m_mesh->m_edgeSet)
452 if(it->m_edgeNodes.size() > 0)
456 vector<NodeSharedPtr> ns;
457 it->GetCurvedNodes(ns);
458 for(
int i = 0; i < ns.size(); i++)
461 m_mesh->m_spaceDim, edgecnt, ns[i]->m_x, ns[i]->m_y, ns[i]->m_z);
462 curve->m_points.push_back(vert);
465 edges[it->m_id] = curve;
472 for(
int e = 0; e <
m_mesh->m_element[1].size(); e++)
475 vector<NodeSharedPtr> ns;
476 el->GetCurvedNodes(ns);
480 el->GetId(), el->GetCurveType());
482 for(
int i = 0; i < ns.size(); i++)
485 m_mesh->m_spaceDim, edgecnt, ns[i]->m_x, ns[i]->m_y, ns[i]->m_z);
486 curve->m_points.push_back(vert);
489 edges[el->GetId()] = curve;
495 CurveMap &faces = graph->GetCurvedFaces();
499 for(
auto &it :
m_mesh->m_faceSet)
501 if(it->m_faceNodes.size() > 0)
506 vector<NodeSharedPtr> ns;
507 it->GetCurvedNodes(ns);
508 for(
int i = 0; i < ns.size(); i++)
512 (
m_mesh->m_spaceDim, facecnt, ns[i]->m_x, ns[i]->m_y,
514 curve->m_points.push_back(vert);
517 faces[it->m_id] = curve;
561 map<int, string> &compLabels = graph->GetCompositesLabels();
565 for(
auto &it :
m_mesh->m_composite)
567 if(it.second->m_items.size() > 0)
569 int indx = it.second->m_id;
573 if(it.second->m_label.size())
575 compLabels[indx] = it.second->m_label;
578 switch (it.second->m_tag[0])
583 for(
int i = 0; i < it.second->m_items.size(); i++)
585 curVector->m_geomVec.push_back(pointMap[it.second->m_items[i]->GetId()]);
593 for(
int i = 0; i < it.second->m_items.size(); i++)
595 curVector->m_geomVec.push_back(segMap[it.second->m_items[i]->GetId()]);
602 for(
int i = 0; i < it.second->m_items.size(); i++)
604 curVector->m_geomVec.push_back(quadMap[it.second->m_items[i]->GetId()]);
611 for(
int i = 0; i < it.second->m_items.size(); i++)
613 curVector->m_geomVec.push_back(triMap[it.second->m_items[i]->GetId()]);
621 for(
int i = 0; i < it.second->m_items.size(); i++)
623 auto f = quadMap.find(it.second->m_items[i]->GetId());
624 if(f != quadMap.end())
626 curVector->m_geomVec.push_back(f->second);
630 auto f2 = triMap.find(it.second->m_items[i]->GetId());
631 curVector->m_geomVec.push_back(f2->second);
639 for(
int i = 0; i < it.second->m_items.size(); i++)
641 curVector->m_geomVec.push_back(tetMap[it.second->m_items[i]->GetId()]);
648 for(
int i = 0; i < it.second->m_items.size(); i++)
650 curVector->m_geomVec.push_back(pyrMap[it.second->m_items[i]->GetId()]);
657 for(
int i = 0; i < it.second->m_items.size(); i++)
659 curVector->m_geomVec.push_back(prismMap[it.second->m_items[i]->GetId()]);
666 for(
int i = 0; i < it.second->m_items.size(); i++)
668 curVector->m_geomVec.push_back(hexMap[it.second->m_items[i]->GetId()]);
673 ASSERTL0(
false,
"Unknown element type");
676 comps[indx] = curVector;
684 vector<SpatialDomains::CompositeMap> &domain = graph->GetDomain();
688 for(
auto &it :
m_mesh->m_composite)
690 if(it.second->m_items[0]->GetDim() ==
m_mesh->m_expDim)
692 if(list.length() > 0)
696 list += boost::lexical_cast<
string>(it.second->m_id);
701 graph->GetCompositeList(list, fullDomain);
702 domain.push_back(fullDomain);
#define ASSERTL0(condition, msg)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
void TransferDomain(SpatialDomains::MeshGraphSharedPtr graph)
virtual void Process()
Write mesh to output file.
int DefineFunction(const std::string &vlist, const std::string &expr)
Defines a function for the purposes of evaluation.
std::shared_ptr< Geometry2D > Geometry2DSharedPtr
void TransferComposites(SpatialDomains::MeshGraphSharedPtr graph)
std::unordered_map< int, CurveSharedPtr > CurveMap
NekDouble Evaluate(const int id)
Evaluate a function which depends only on constants and/or parameters.
std::shared_ptr< QuadGeom > QuadGeomSharedPtr
Abstract base class for output modules.
std::map< int, CompositeSharedPtr > CompositeMap
std::map< int, PrismGeomSharedPtr > PrismGeomMap
MeshSharedPtr m_mesh
Mesh object.
std::shared_ptr< Composite > CompositeSharedPtr
void TransferElements(SpatialDomains::MeshGraphSharedPtr graph)
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
std::map< int, PyrGeomSharedPtr > PyrGeomMap
void TestElmts(const std::map< int, std::shared_ptr< T > > &geomMap, SpatialDomains::MeshGraphSharedPtr &graph, LibUtilities::Interpreter &strEval, int exprId)
std::map< int, TetGeomSharedPtr > TetGeomMap
std::map< int, TriGeomSharedPtr > TriGeomMap
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::shared_ptr< TriGeom > TriGeomSharedPtr
std::pair< ModuleType, std::string > ModuleKey
LibUtilities::Interpreter m_strEval
void TransferCurves(SpatialDomains::MeshGraphSharedPtr graph)
std::shared_ptr< Element > ElementSharedPtr
MeshGraphFactory & GetMeshGraphFactory()
Represents a command-line configuration option.
std::map< int, SegGeomSharedPtr > SegGeomMap
std::shared_ptr< Geometry > GeometrySharedPtr
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void TransferFaces(SpatialDomains::MeshGraphSharedPtr graph, std::unordered_map< int, SpatialDomains::SegGeomSharedPtr > &edgeMap)
std::map< std::string, ConfigOption > m_config
List of configuration values.
std::shared_ptr< PointGeom > PointGeomSharedPtr
Interpreter class for the evaluation of mathematical expressions.
std::map< int, QuadGeomSharedPtr > QuadGeomMap
void TransferEdges(SpatialDomains::MeshGraphSharedPtr graph, std::unordered_map< int, SpatialDomains::SegGeomSharedPtr > &edgeMap)
std::shared_ptr< Curve > CurveSharedPtr
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::map< int, PointGeomSharedPtr > PointGeomMap
std::pair< ModuleType, std::string > ModuleKey
std::shared_ptr< SegGeom > SegGeomSharedPtr
std::map< int, HexGeomSharedPtr > HexGeomMap
std::shared_ptr< SessionReader > SessionReaderSharedPtr
void TransferVertices(SpatialDomains::MeshGraphSharedPtr graph)
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, DomainRangeShPtr rng=NullDomainRangeShPtr, bool fillGraph=true)
ModuleFactory & GetModuleFactory()