Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
Nektar::Utilities::OutputNekpp Class Reference

Converter for Gmsh files. More...

#include <OutputNekpp.h>

Inheritance diagram for Nektar::Utilities::OutputNekpp:
[legend]

Public Member Functions

 OutputNekpp (NekMeshUtils::MeshSharedPtr m)
 
virtual ~OutputNekpp ()
 
virtual void Process ()
 Write mesh to output file. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::OutputModule
NEKMESHUTILS_EXPORT OutputModule (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void OpenStream ()
 Open a file for output. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT Module (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void RegisterConfig (std::string key, std::string value=std::string())
 Register a configuration option with a module. More...
 
NEKMESHUTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
NEKMESHUTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
NEKMESHUTILS_EXPORT MeshSharedPtr GetMesh ()
 
virtual NEKMESHUTILS_EXPORT void ProcessVertices ()
 Extract element vertices. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessElements ()
 Generate element IDs. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessComposites ()
 Generate composites. More...
 
virtual NEKMESHUTILS_EXPORT void ClearElementLinks ()
 

Static Public Member Functions

static std::shared_ptr< Modulecreate (NekMeshUtils::MeshSharedPtr m)
 Creates an instance of this class. More...
 

Static Public Attributes

static NekMeshUtils::ModuleKey className1
 
static NekMeshUtils::ModuleKey className2
 

Private Member Functions

void TransferVertices (SpatialDomains::MeshGraphSharedPtr graph)
 
void TransferEdges (SpatialDomains::MeshGraphSharedPtr graph, std::unordered_map< int, SpatialDomains::SegGeomSharedPtr > &edgeMap)
 
void TransferFaces (SpatialDomains::MeshGraphSharedPtr graph, std::unordered_map< int, SpatialDomains::SegGeomSharedPtr > &edgeMap)
 
void TransferElements (SpatialDomains::MeshGraphSharedPtr graph)
 
void TransferCurves (SpatialDomains::MeshGraphSharedPtr graph)
 
void TransferComposites (SpatialDomains::MeshGraphSharedPtr graph)
 
void TransferDomain (SpatialDomains::MeshGraphSharedPtr graph)
 

Private Attributes

LibUtilities::Interpreter m_strEval
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
NEKMESHUTILS_EXPORT void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::NekMeshUtils::OutputModule
io::filtering_ostream m_mshFile
 Output stream. More...
 
std::ofstream m_mshFileStream
 Input stream. More...
 
- Protected Attributes inherited from Nektar::NekMeshUtils::Module
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 

Detailed Description

Converter for Gmsh files.

Definition at line 46 of file OutputNekpp.h.

Constructor & Destructor Documentation

◆ OutputNekpp()

Nektar::Utilities::OutputNekpp::OutputNekpp ( NekMeshUtils::MeshSharedPtr  m)

Definition at line 73 of file OutputNekpp.cpp.

References Nektar::NekMeshUtils::Module::m_config.

73  : OutputModule(m)
74 {
75  m_config["test"] = ConfigOption(
76  true, "0", "Attempt to load resulting mesh and create meshgraph.");
77  m_config["stats"] = ConfigOption(
78  true, "0", "Print out basic mesh statistics.");
79  m_config["uncompress"] = ConfigOption(true, "0", "Uncompress xml sections");
80  m_config["order"] = ConfigOption(false, "-1", "Enforce a polynomial order");
81  m_config["testcond"] = ConfigOption(
82  false, "", "Test a condition.");
83 }
Represents a command-line configuration option.
std::map< std::string, ConfigOption > m_config
List of configuration values.
NEKMESHUTILS_EXPORT OutputModule(MeshSharedPtr p_m)

◆ ~OutputNekpp()

Nektar::Utilities::OutputNekpp::~OutputNekpp ( )
virtual

Definition at line 85 of file OutputNekpp.cpp.

86 {
87 }

Member Function Documentation

◆ create()

static std::shared_ptr<Module> Nektar::Utilities::OutputNekpp::create ( NekMeshUtils::MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 50 of file OutputNekpp.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

51  {
53  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ Process()

void Nektar::Utilities::OutputNekpp::Process ( )
virtual

Write mesh to output file.

Implements Nektar::NekMeshUtils::Module.

Definition at line 143 of file OutputNekpp.cpp.

References Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::Interpreter::DefineFunction(), Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::SpatialDomains::GetMeshGraphFactory(), Nektar::NekMeshUtils::Module::m_config, Nektar::NekMeshUtils::Module::m_mesh, m_strEval, Nektar::SpatialDomains::MeshGraph::Read(), Nektar::Utilities::TestElmts(), TransferComposites(), TransferCurves(), TransferDomain(), TransferEdges(), TransferElements(), TransferFaces(), and TransferVertices().

144 {
145  if (m_mesh->m_verbose)
146  {
147  cout << "OutputNekpp: Writing file..." << endl;
148  }
149 
150  int order = m_config["order"].as<int>();
151 
152  if (order != -1)
153  {
154  m_mesh->MakeOrder(order, LibUtilities::ePolyEvenlySpaced);
155  }
156 
157  string file = m_config["outfile"].as<string>();
158  string ext = boost::filesystem::extension(file);
159 
160  if (m_config["stats"].beenSet)
161  {
162  m_mesh->PrintStats(std::cout);
163  }
164 
165  // Default to compressed XML output.
166  std::string type = "XmlCompressed";
167 
168  // Extract the output filename and extension
169  string filename = m_config["outfile"].as<string>();
170 
171  // Compress output and append .gz extension
172  if(boost::iequals(ext, ".xml") && m_config["uncompress"].beenSet)
173  {
174  type = "Xml";
175  }
176  else if(boost::iequals(ext, ".nekg"))
177  {
178  type = "HDF5";
179  }
180 
183  graph->Empty(m_mesh->m_expDim, m_mesh->m_spaceDim);
184 
185  TransferVertices(graph);
186 
187  std::unordered_map<int, SegGeomSharedPtr> segMap;
188  TransferEdges(graph, segMap);
189  TransferFaces(graph, segMap);
190  TransferElements(graph);
191  TransferCurves(graph);
192  TransferComposites(graph);
193  TransferDomain(graph);
194 
195  string out = m_config["outfile"].as<string>();
196  graph->WriteGeometry(out, true, m_mesh->m_metadata);
197 
198  // Test the resulting XML file (with a basic test) by loading it
199  // with the session reader, generating the MeshGraph and testing if
200  // each element is valid.
201  if (m_config["test"].beenSet)
202  {
203  // Create an equation based on the test condition. Should evaluate to 1
204  // or 0 using boolean logic.
205  string testcond = m_config["testcond"].as<string>();
206  int exprId = -1;
207 
208  if (testcond.length() > 0)
209  {
210  exprId = m_strEval.DefineFunction("x y z", testcond);
211  }
212 
213  vector<string> filenames(1);
214 
215  if (type == "HDF5")
216  {
217  vector<string> tmp;
218  boost::split(tmp, filename, boost::is_any_of("."));
219  filenames[0] = tmp[0] + ".xml";
220  }
221  else
222  {
223  filenames[0] = filename;
224  }
225 
226  char *prgname = const_cast<char *>("NekMesh");
228  LibUtilities::SessionReader::CreateInstance(1, &prgname, filenames,
229  m_mesh->m_comm);
232 
233  TestElmts(graph->GetAllSegGeoms(), graph, m_strEval, exprId);
234  TestElmts(graph->GetAllTriGeoms(), graph, m_strEval, exprId);
235  TestElmts(graph->GetAllQuadGeoms(), graph, m_strEval, exprId);
236  TestElmts(graph->GetAllTetGeoms(), graph, m_strEval, exprId);
237  TestElmts(graph->GetAllPrismGeoms(), graph, m_strEval, exprId);
238  TestElmts(graph->GetAllPyrGeoms(), graph, m_strEval, exprId);
239  TestElmts(graph->GetAllHexGeoms(), graph, m_strEval, exprId);
240  }
241 }
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
void TransferDomain(SpatialDomains::MeshGraphSharedPtr graph)
int DefineFunction(const std::string &vlist, const std::string &expr)
Defines a function for the purposes of evaluation.
void TransferComposites(SpatialDomains::MeshGraphSharedPtr graph)
void TransferElements(SpatialDomains::MeshGraphSharedPtr graph)
void TestElmts(const std::map< int, std::shared_ptr< T > > &geomMap, SpatialDomains::MeshGraphSharedPtr &graph, LibUtilities::Interpreter &strEval, int exprId)
Definition: OutputNekpp.cpp:89
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:64
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.
Definition: NekFactory.hpp:144
LibUtilities::Interpreter m_strEval
Definition: OutputNekpp.h:63
void TransferCurves(SpatialDomains::MeshGraphSharedPtr graph)
MeshGraphFactory & GetMeshGraphFactory()
Definition: MeshGraph.cpp:76
void TransferFaces(SpatialDomains::MeshGraphSharedPtr graph, std::unordered_map< int, SpatialDomains::SegGeomSharedPtr > &edgeMap)
std::map< std::string, ConfigOption > m_config
List of configuration values.
void TransferEdges(SpatialDomains::MeshGraphSharedPtr graph, std::unordered_map< int, SpatialDomains::SegGeomSharedPtr > &edgeMap)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
void TransferVertices(SpatialDomains::MeshGraphSharedPtr graph)
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, DomainRangeShPtr rng=NullDomainRangeShPtr, bool fillGraph=true)
Definition: MeshGraph.cpp:113

◆ TransferComposites()

void Nektar::Utilities::OutputNekpp::TransferComposites ( SpatialDomains::MeshGraphSharedPtr  graph)
private

Definition at line 558 of file OutputNekpp.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, and Nektar::NekMeshUtils::Module::m_mesh.

Referenced by Process().

559 {
560  SpatialDomains::CompositeMap &comps = graph->GetComposites();
561  map<int, string> &compLabels = graph->GetCompositesLabels();
562 
563  int j = 0;
564 
565  for(auto &it : m_mesh->m_composite)
566  {
567  if(it.second->m_items.size() > 0)
568  {
569  int indx = it.second->m_id;
572 
573  if(it.second->m_label.size())
574  {
575  compLabels[indx] = it.second->m_label;
576  }
577 
578  switch (it.second->m_tag[0])
579  {
580  case 'V':
581  {
582  PointGeomMap &pointMap = graph->GetAllPointGeoms();
583  for(int i = 0; i < it.second->m_items.size(); i++)
584  {
585  curVector->m_geomVec.push_back(pointMap[it.second->m_items[i]->GetId()]);
586  }
587  }
588  break;
589  case 'S':
590  case 'E':
591  {
592  SegGeomMap &segMap = graph->GetAllSegGeoms();
593  for(int i = 0; i < it.second->m_items.size(); i++)
594  {
595  curVector->m_geomVec.push_back(segMap[it.second->m_items[i]->GetId()]);
596  }
597  }
598  break;
599  case 'Q':
600  {
601  QuadGeomMap &quadMap = graph->GetAllQuadGeoms();
602  for(int i = 0; i < it.second->m_items.size(); i++)
603  {
604  curVector->m_geomVec.push_back(quadMap[it.second->m_items[i]->GetId()]);
605  }
606  }
607  break;
608  case 'T':
609  {
610  TriGeomMap &triMap = graph->GetAllTriGeoms();
611  for(int i = 0; i < it.second->m_items.size(); i++)
612  {
613  curVector->m_geomVec.push_back(triMap[it.second->m_items[i]->GetId()]);
614  }
615  }
616  break;
617  case 'F':
618  {
619  QuadGeomMap &quadMap = graph->GetAllQuadGeoms();
620  TriGeomMap &triMap = graph->GetAllTriGeoms();
621  for(int i = 0; i < it.second->m_items.size(); i++)
622  {
623  auto f = quadMap.find(it.second->m_items[i]->GetId());
624  if(f != quadMap.end())
625  {
626  curVector->m_geomVec.push_back(f->second);
627  }
628  else
629  {
630  auto f2 = triMap.find(it.second->m_items[i]->GetId());
631  curVector->m_geomVec.push_back(f2->second);
632  }
633  }
634  }
635  break;
636  case 'A':
637  {
638  TetGeomMap &tetMap = graph->GetAllTetGeoms();
639  for(int i = 0; i < it.second->m_items.size(); i++)
640  {
641  curVector->m_geomVec.push_back(tetMap[it.second->m_items[i]->GetId()]);
642  };
643  }
644  break;
645  case 'P':
646  {
647  PyrGeomMap &pyrMap = graph->GetAllPyrGeoms();
648  for(int i = 0; i < it.second->m_items.size(); i++)
649  {
650  curVector->m_geomVec.push_back(pyrMap[it.second->m_items[i]->GetId()]);
651  }
652  }
653  break;
654  case 'R':
655  {
656  PrismGeomMap &prismMap = graph->GetAllPrismGeoms();
657  for(int i = 0; i < it.second->m_items.size(); i++)
658  {
659  curVector->m_geomVec.push_back(prismMap[it.second->m_items[i]->GetId()]);
660  }
661  }
662  break;
663  case 'H':
664  {
665  HexGeomMap &hexMap = graph->GetAllHexGeoms();
666  for(int i = 0; i < it.second->m_items.size(); i++)
667  {
668  curVector->m_geomVec.push_back(hexMap[it.second->m_items[i]->GetId()]);
669  }
670  }
671  break;
672  default:
673  ASSERTL0(false, "Unknown element type");
674  }
675 
676  comps[indx] = curVector;
677  }
678  j++;
679  }
680 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::map< int, CompositeSharedPtr > CompositeMap
Definition: MeshGraph.h:137
std::map< int, PrismGeomSharedPtr > PrismGeomMap
Definition: PrismGeom.h:89
std::shared_ptr< Composite > CompositeSharedPtr
Definition: MeshGraph.h:136
std::map< int, PyrGeomSharedPtr > PyrGeomMap
Definition: PyrGeom.h:81
std::map< int, TetGeomSharedPtr > TetGeomMap
Definition: TetGeom.h:90
std::map< int, TriGeomSharedPtr > TriGeomMap
Definition: TriGeom.h:59
std::map< int, SegGeomSharedPtr > SegGeomMap
Definition: SegGeom.h:52
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::map< int, QuadGeomSharedPtr > QuadGeomMap
Definition: QuadGeom.h:54
std::map< int, PointGeomSharedPtr > PointGeomMap
Definition: PointGeom.h:54
std::map< int, HexGeomSharedPtr > HexGeomMap
Definition: HexGeom.h:91

◆ TransferCurves()

void Nektar::Utilities::OutputNekpp::TransferCurves ( SpatialDomains::MeshGraphSharedPtr  graph)
private

Definition at line 444 of file OutputNekpp.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and Nektar::NekMeshUtils::Module::m_mesh.

Referenced by Process().

445 {
446  CurveMap &edges = graph->GetCurvedEdges();
447 
448  int edgecnt = 0;
449 
450  for(auto &it : m_mesh->m_edgeSet)
451  {
452  if(it->m_edgeNodes.size() > 0)
453  {
455  it->m_curveType);
456  vector<NodeSharedPtr> ns;
457  it->GetCurvedNodes(ns);
458  for(int i = 0; i < ns.size(); i++)
459  {
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);
463  }
464 
465  edges[it->m_id] = curve;
466  edgecnt++;
467  }
468  }
469 
470  if(m_mesh->m_expDim == 1 && m_mesh->m_spaceDim > 1)
471  {
472  for(int e = 0; e < m_mesh->m_element[1].size(); e++)
473  {
474  ElementSharedPtr el = m_mesh->m_element[1][e];
475  vector<NodeSharedPtr> ns;
476  el->GetCurvedNodes(ns);
477  if(ns.size() > 2)
478  {
480  el->GetId(), el->GetCurveType());
481 
482  for(int i = 0; i < ns.size(); i++)
483  {
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);
487  }
488 
489  edges[el->GetId()] = curve;
490  edgecnt++;
491  }
492  }
493  }
494 
495  CurveMap &faces = graph->GetCurvedFaces();
496 
497  int facecnt = 0;
498 
499  for(auto &it : m_mesh->m_faceSet)
500  {
501  if(it->m_faceNodes.size() > 0)
502  {
503  CurveSharedPtr curve =
505  it->m_curveType);
506  vector<NodeSharedPtr> ns;
507  it->GetCurvedNodes(ns);
508  for(int i = 0; i < ns.size(); i++)
509  {
510  PointGeomSharedPtr vert =
512  (m_mesh->m_spaceDim, facecnt, ns[i]->m_x, ns[i]->m_y,
513  ns[i]->m_z);
514  curve->m_points.push_back(vert);
515  }
516 
517  faces[it->m_id] = curve;
518  facecnt++;
519  }
520  }
521 
522  /*
523  if(m_mesh->m_expDim == 2 && m_mesh->m_spaceDim == 3)
524  {
525  //manifold case
526  for(int e = 0; e < m_mesh->m_element[2].size(); e++)
527  {
528  ElementSharedPtr el = m_mesh->m_element[2][e];
529 
530  if(el->GetVolumeNodes().size() > 0) // needed for extract surf case
531  {
532  vector<NodeSharedPtr> ns;
533  el->GetCurvedNodes(ns);
534  if(ns.size() > 4)
535  {
536  CurveSharedPtr curve =
537  MemoryManager<Curve>::AllocateSharedPtr
538  (el->GetId(), el->GetCurveType());
539 
540  for(int i = 0; i < ns.size(); i++)
541  {
542  PointGeomSharedPtr vert =
543  MemoryManager<PointGeom>::AllocateSharedPtr
544  (m_mesh->m_spaceDim, facecnt, ns[i]->m_x, ns[i]->m_y,
545  ns[i]->m_z);
546  curve->m_points.push_back(vert);
547  }
548 
549  faces[el->GetId()] = curve;
550  facecnt++;
551  }
552  }
553  }
554  }
555  */
556 }
std::unordered_map< int, CurveSharedPtr > CurveMap
Definition: Curve.hpp:62
std::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:59
std::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:61

◆ TransferDomain()

void Nektar::Utilities::OutputNekpp::TransferDomain ( SpatialDomains::MeshGraphSharedPtr  graph)
private

Definition at line 682 of file OutputNekpp.cpp.

References Nektar::NekMeshUtils::Module::m_mesh.

Referenced by Process().

683 {
684  vector<SpatialDomains::CompositeMap> &domain = graph->GetDomain();
685 
686  string list;
687 
688  for(auto &it : m_mesh->m_composite)
689  {
690  if(it.second->m_items[0]->GetDim() == m_mesh->m_expDim)
691  {
692  if(list.length() > 0)
693  {
694  list += ",";
695  }
696  list += boost::lexical_cast<string>(it.second->m_id);
697  }
698  }
699 
700  SpatialDomains::CompositeMap fullDomain;
701  graph->GetCompositeList(list, fullDomain);
702  domain.push_back(fullDomain);
703 }
std::map< int, CompositeSharedPtr > CompositeMap
Definition: MeshGraph.h:137

◆ TransferEdges()

void Nektar::Utilities::OutputNekpp::TransferEdges ( SpatialDomains::MeshGraphSharedPtr  graph,
std::unordered_map< int, SpatialDomains::SegGeomSharedPtr > &  edgeMap 
)
private

Definition at line 255 of file OutputNekpp.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and Nektar::NekMeshUtils::Module::m_mesh.

Referenced by Process().

258 {
259  if (m_mesh->m_expDim >= 2)
260  {
261  SegGeomMap &segMap = graph->GetAllSegGeoms();
262  for(auto &it : m_mesh->m_edgeSet)
263  {
264  PointGeomSharedPtr verts[2] = {graph->GetVertex(it->m_n1->m_id),
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;
270  }
271  }
272 }
std::map< int, SegGeomSharedPtr > SegGeomMap
Definition: SegGeom.h:52
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:59
std::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:62

◆ TransferElements()

void Nektar::Utilities::OutputNekpp::TransferElements ( SpatialDomains::MeshGraphSharedPtr  graph)
private

Definition at line 313 of file OutputNekpp.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eTriangle, and Nektar::NekMeshUtils::Module::m_mesh.

Referenced by Process().

314 {
315  vector<ElementSharedPtr> &elmt = m_mesh->m_element[m_mesh->m_expDim];
316 
317  SegGeomMap &segMap = graph->GetAllSegGeoms();
318  TriGeomMap &triMap = graph->GetAllTriGeoms();
319  QuadGeomMap &quadMap = graph->GetAllQuadGeoms();
320  TetGeomMap &tetMap = graph->GetAllTetGeoms();
321  PyrGeomMap &pyrMap = graph->GetAllPyrGeoms();
322  PrismGeomMap &prismMap = graph->GetAllPrismGeoms();
323  HexGeomMap &hexMap = graph->GetAllHexGeoms();
324 
325  for (int i = 0; i < elmt.size(); ++i)
326  {
327  switch (elmt[i]->GetTag()[0])
328  {
329  case 'S':
330  {
331  int id = elmt[i]->GetId();
332  PointGeomSharedPtr vertices[2] = {
333  graph->GetVertex(elmt[i]->GetVertex(0)->m_id),
334  graph->GetVertex(elmt[i]->GetVertex(1)->m_id)};
335  segMap[id] = MemoryManager<SegGeom>::AllocateSharedPtr(id, m_mesh->m_spaceDim, vertices);
336  }
337  break;
338  case 'T':
339  {
340  int id = elmt[i]->GetId();
341  SegGeomSharedPtr edges[TriGeom::kNedges] = {
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)};
345 
346  triMap[id] = MemoryManager<TriGeom>::AllocateSharedPtr(id, edges);
347  }
348  break;
349  case 'Q':
350  {
351  int id = elmt[i]->GetId();
352  SegGeomSharedPtr edges[QuadGeom::kNedges] = {
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)};
357 
358  quadMap[id] = MemoryManager<QuadGeom>::AllocateSharedPtr(id, edges);
359  }
360  break;
361  case 'A':
362  {
363  int id = elmt[i]->GetId();
364  TriGeomSharedPtr tfaces[4];
365  for(int j = 0; j < 4; ++j)
366  {
367  Geometry2DSharedPtr face =
368  graph->GetGeometry2D(elmt[i]->GetFace(j)->m_id);
369  tfaces[j] = static_pointer_cast<TriGeom>(face);
370  }
371 
372  tetMap[id] = MemoryManager<TetGeom>::AllocateSharedPtr(id, tfaces);
373  }
374  break;
375  case 'P':
376  {
377  Geometry2DSharedPtr faces[5];
378 
379  int id = elmt[i]->GetId();
380  for(int j = 0; j < 5; ++j)
381  {
382  Geometry2DSharedPtr face =
383  graph->GetGeometry2D(elmt[i]->GetFace(j)->m_id);
384 
385  if (face->GetShapeType() ==
387  {
388  faces[j] = static_pointer_cast<TriGeom>(face);
389  }
390  else if (face->GetShapeType() ==
392  {
393  faces[j] = static_pointer_cast<QuadGeom>(face);
394  }
395  }
396  pyrMap[id] = MemoryManager<PyrGeom>::AllocateSharedPtr(id, faces);
397  }
398  break;
399  case 'R':
400  {
401  Geometry2DSharedPtr faces[5];
402 
403  int id = elmt[i]->GetId();
404  for(int j = 0; j < 5; ++j)
405  {
406  Geometry2DSharedPtr face =
407  graph->GetGeometry2D(elmt[i]->GetFace(j)->m_id);
408 
409  if (face->GetShapeType() ==
411  {
412  faces[j] = static_pointer_cast<TriGeom>(face);
413  }
414  else if (face->GetShapeType() ==
416  {
417  faces[j] = static_pointer_cast<QuadGeom>(face);
418  }
419  }
420  prismMap[id] = MemoryManager<PrismGeom>::AllocateSharedPtr(id, faces);
421  }
422  break;
423  case 'H':
424  {
425  QuadGeomSharedPtr faces[6];
426 
427  int id = elmt[i]->GetId();
428  for(int j = 0; j < 6; ++j)
429  {
430  Geometry2DSharedPtr face =
431  graph->GetGeometry2D(elmt[i]->GetFace(j)->m_id);
432  faces[j] = static_pointer_cast<QuadGeom>(face);
433  }
434 
435  hexMap[id] = MemoryManager<HexGeom>::AllocateSharedPtr(id, faces);
436  }
437  break;
438  default:
439  ASSERTL0(false, "Unknown element type");
440  }
441  }
442 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::shared_ptr< Geometry2D > Geometry2DSharedPtr
Definition: Geometry.h:65
std::shared_ptr< QuadGeom > QuadGeomSharedPtr
Definition: HexGeom.h:46
std::map< int, PrismGeomSharedPtr > PrismGeomMap
Definition: PrismGeom.h:89
std::map< int, PyrGeomSharedPtr > PyrGeomMap
Definition: PyrGeom.h:81
std::map< int, TetGeomSharedPtr > TetGeomMap
Definition: TetGeom.h:90
std::map< int, TriGeomSharedPtr > TriGeomMap
Definition: TriGeom.h:59
std::shared_ptr< TriGeom > TriGeomSharedPtr
Definition: TriGeom.h:58
std::map< int, SegGeomSharedPtr > SegGeomMap
Definition: SegGeom.h:52
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:59
std::map< int, QuadGeomSharedPtr > QuadGeomMap
Definition: QuadGeom.h:54
std::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:62
std::map< int, HexGeomSharedPtr > HexGeomMap
Definition: HexGeom.h:91

◆ TransferFaces()

void Nektar::Utilities::OutputNekpp::TransferFaces ( SpatialDomains::MeshGraphSharedPtr  graph,
std::unordered_map< int, SpatialDomains::SegGeomSharedPtr > &  edgeMap 
)
private

Definition at line 274 of file OutputNekpp.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and Nektar::NekMeshUtils::Module::m_mesh.

Referenced by Process().

277 {
278  if(m_mesh->m_expDim == 3)
279  {
280  TriGeomMap &triMap = graph->GetAllTriGeoms();
281  QuadGeomMap &quadMap = graph->GetAllQuadGeoms();
282  for(auto &it : m_mesh->m_faceSet)
283  {
284  if(it->m_edgeList.size() == 3)
285  {
286  SegGeomSharedPtr edges[TriGeom::kNedges] =
287  {
288  edgeMap[it->m_edgeList[0]->m_id],
289  edgeMap[it->m_edgeList[1]->m_id],
290  edgeMap[it->m_edgeList[2]->m_id]
291  };
292 
294  triMap[it->m_id] = tri;
295  }
296  else
297  {
298  SegGeomSharedPtr edges[QuadGeom::kNedges] =
299  {
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]
304  };
305 
307  quadMap[it->m_id] = quad;
308  }
309  }
310  }
311 }
std::shared_ptr< QuadGeom > QuadGeomSharedPtr
Definition: HexGeom.h:46
std::map< int, TriGeomSharedPtr > TriGeomMap
Definition: TriGeom.h:59
std::shared_ptr< TriGeom > TriGeomSharedPtr
Definition: TriGeom.h:58
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::map< int, QuadGeomSharedPtr > QuadGeomMap
Definition: QuadGeom.h:54
std::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:62

◆ TransferVertices()

void Nektar::Utilities::OutputNekpp::TransferVertices ( SpatialDomains::MeshGraphSharedPtr  graph)
private

Definition at line 243 of file OutputNekpp.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and Nektar::NekMeshUtils::Module::m_mesh.

Referenced by Process().

244 {
245  PointGeomMap &pointMap = graph->GetAllPointGeoms();
246  for(auto &it : m_mesh->m_vertexSet)
247  {
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;
252  }
253 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:59
std::map< int, PointGeomSharedPtr > PointGeomMap
Definition: PointGeom.h:54

Member Data Documentation

◆ className1

ModuleKey Nektar::Utilities::OutputNekpp::className1
static
Initial value:

Definition at line 54 of file OutputNekpp.h.

◆ className2

ModuleKey Nektar::Utilities::OutputNekpp::className2
static
Initial value:
=
"Writes a Nektar++ file with hdf5.")

Definition at line 54 of file OutputNekpp.h.

◆ m_strEval

LibUtilities::Interpreter Nektar::Utilities::OutputNekpp::m_strEval
private

Definition at line 63 of file OutputNekpp.h.

Referenced by Process().