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

Converter for Gmsh files. More...

#include <OutputVtk.h>

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

Public Member Functions

 OutputVtk (NekMeshUtils::MeshSharedPtr m)
 
virtual ~OutputVtk ()
 
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 className
 

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 utilities/NekMesh/OutputModules/OutputVtk.h.

Constructor & Destructor Documentation

◆ OutputVtk()

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

Definition at line 56 of file utilities/NekMesh/OutputModules/OutputVtk.cpp.

56  : OutputModule(m)
57 {
58 }
NEKMESHUTILS_EXPORT OutputModule(MeshSharedPtr p_m)

◆ ~OutputVtk()

Nektar::Utilities::OutputVtk::~OutputVtk ( )
virtual

Definition at line 60 of file utilities/NekMesh/OutputModules/OutputVtk.cpp.

61 {
62 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 50 of file utilities/NekMesh/OutputModules/OutputVtk.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::OutputVtk::Process ( )
virtual

Write mesh to output file.

Implements Nektar::NekMeshUtils::Module.

Definition at line 64 of file utilities/NekMesh/OutputModules/OutputVtk.cpp.

References Nektar::NekMeshUtils::Module::m_config, Nektar::NekMeshUtils::Module::m_mesh, and CellMLToNektar.cellml_metadata::p.

65 {
66  if (m_mesh->m_verbose)
67  {
68  cout << "OutputVtk: Writing file..." << endl;
69  }
70 
71  vtkPolyData *vtkMesh = vtkPolyData::New();
72  vtkPoints *vtkPoints = vtkPoints::New();
73  vtkCellArray *vtkPolys = vtkCellArray::New();
74 
75  std::set<NodeSharedPtr> tmp(m_mesh->m_vertexSet.begin(),
76  m_mesh->m_vertexSet.end());
77 
78  for (auto &n : tmp)
79  {
80  vtkPoints->InsertPoint(n->m_id, n->m_x, n->m_y, n->m_z);
81  }
82 
83  vtkIdType p[8];
84  vector<ElementSharedPtr> &elmt = m_mesh->m_element[m_mesh->m_expDim];
85  for (int i = 0; i < elmt.size(); ++i)
86  {
87  int vertexCount = elmt[i]->GetVertexCount();
88  for (int j = 0; j < vertexCount; ++j)
89  {
90  p[j] = elmt[i]->GetVertex(j)->m_id;
91  }
92  vtkPolys->InsertNextCell(vertexCount, &p[0]);
93  }
94 
95  vtkMesh->SetPoints(vtkPoints);
96  vtkMesh->SetPolys(vtkPolys);
97 
98  // Write out the new mesh
99  vtkPolyDataWriter *vtkMeshWriter = vtkPolyDataWriter::New();
100  vtkMeshWriter->SetFileName(m_config["outfile"].as<string>().c_str());
101 #if VTK_MAJOR_VERSION <= 5
102  vtkMeshWriter->SetInput(vtkMesh);
103 #else
104  vtkMeshWriter->SetInputData(vtkMesh);
105 #endif
106  vtkMeshWriter->Update();
107 }
std::map< std::string, ConfigOption > m_config
List of configuration values.

Member Data Documentation

◆ className

ModuleKey Nektar::Utilities::OutputVtk::className
static
Initial value:

Definition at line 54 of file utilities/NekMesh/OutputModules/OutputVtk.h.