Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::InputVtk Class Reference

Converter for VTK files. More...

#include <InputVtk.h>

Inheritance diagram for Nektar::Utilities::InputVtk:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::InputVtk:
Collaboration graph
[legend]

Public Member Functions

 InputVtk (NekMeshUtils::MeshSharedPtr m)
 
virtual ~InputVtk ()
 
virtual void Process ()
 Populate and validate required data structures. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::InputModule
NEKMESHUTILS_EXPORT InputModule (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void OpenStream ()
 Open a file for input. 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)
 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
NekMeshUtils::ModuleSharedPtr 
create (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::InputModule
NEKMESHUTILS_EXPORT void PrintSummary ()
 Print summary of elements. More...
 
- 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::InputModule
io::filtering_istream m_mshFile
 Input stream. More...
 
std::ifstream m_mshFileStream
 Input stream. More...
 
- Protected Attributes inherited from Nektar::NekMeshUtils::Module
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. More...
 

Detailed Description

Converter for VTK files.

Definition at line 47 of file InputVtk.h.

Constructor & Destructor Documentation

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

Definition at line 56 of file InputVtk.cpp.

56  : InputModule(m)
57 {
58 }
NEKMESHUTILS_EXPORT InputModule(MeshSharedPtr p_m)
Nektar::Utilities::InputVtk::~InputVtk ( )
virtual

Definition at line 60 of file InputVtk.cpp.

61 {
62 }

Member Function Documentation

static NekMeshUtils::ModuleSharedPtr Nektar::Utilities::InputVtk::create ( NekMeshUtils::MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 51 of file InputVtk.h.

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

52  {
54  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::InputVtk::Process ( )
virtual

Populate and validate required data structures.

Gmsh file contains a list of nodes and their coordinates, along with a list of elements and those nodes which define them. We read in and store the list of nodes in #m_node and store the list of elements in #m_element. Each new element is supplied with a list of entries from #m_node which defines the element. Finally some mesh statistics are printed.

Parameters
pFilenameFilename of Gmsh file to read.

Implements Nektar::NekMeshUtils::Module.

Definition at line 74 of file InputVtk.cpp.

References Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::eSegment, Nektar::LibUtilities::eTriangle, Nektar::NekMeshUtils::GetElementFactory(), Nektar::NekMeshUtils::Module::m_config, Nektar::NekMeshUtils::Module::m_mesh, class_topology::Node, npts, CellMLToNektar.cellml_metadata::p, Nektar::NekMeshUtils::Module::ProcessComposites(), Nektar::NekMeshUtils::Module::ProcessEdges(), Nektar::NekMeshUtils::Module::ProcessElements(), Nektar::NekMeshUtils::Module::ProcessFaces(), and Nektar::NekMeshUtils::Module::ProcessVertices().

75 {
76  if (m_mesh->m_verbose)
77  {
78  cout << "InputVtk: Start reading file..." << endl;
79  }
80 
81  vtkPolyDataReader *vtkMeshReader = vtkPolyDataReader::New();
82  vtkMeshReader->SetFileName(m_config["infile"].as<string>().c_str());
83  vtkMeshReader->Update();
84  vtkPolyData *vtkMesh = vtkMeshReader->GetOutput();
85 
86  vtkPoints *vtkPoints = vtkMesh->GetPoints();
87 
88  const int numCellTypes = 3;
89  vtkCellArray *vtkCells[numCellTypes];
90  LibUtilities::ShapeType vtkCellTypes[numCellTypes];
91  int vtkNumPoints[numCellTypes];
92  vtkCells[0] = vtkMesh->GetPolys();
93  vtkCells[1] = vtkMesh->GetStrips();
94  vtkCells[2] = vtkMesh->GetLines();
95  vtkCellTypes[0] = LibUtilities::eTriangle;
96  vtkCellTypes[1] = LibUtilities::eTriangle;
97  vtkCellTypes[2] = LibUtilities::eSegment;
98  vtkNumPoints[0] = 3;
99  vtkNumPoints[1] = 3;
100  vtkNumPoints[2] = 2;
101 
102  vtkIdType npts;
103  vtkIdType *pts = 0;
104  double p[3];
105 
106  for (int i = 0; i < vtkPoints->GetNumberOfPoints(); ++i)
107  {
108  vtkPoints->GetPoint(i, p);
109 
110  if ((p[0] * p[0]) > 0.000001 && m_mesh->m_spaceDim < 1)
111  {
112  m_mesh->m_spaceDim = 1;
113  }
114  if ((p[1] * p[1]) > 0.000001 && m_mesh->m_spaceDim < 2)
115  {
116  m_mesh->m_spaceDim = 2;
117  }
118  if ((p[2] * p[2]) > 0.000001 && m_mesh->m_spaceDim < 3)
119  {
120  m_mesh->m_spaceDim = 3;
121  }
122 
123  m_mesh->m_node.push_back(
124  boost::shared_ptr<Node>(new Node(i, p[0], p[1], p[2])));
125  }
126 
127  for (int c = 0; c < numCellTypes; ++c)
128  {
129  vtkCells[c]->InitTraversal();
130  for (int i = 0; vtkCells[c]->GetNextCell(npts, pts); ++i)
131  {
132  for (int j = 0; j < npts - vtkNumPoints[c] + 1; ++j)
133  {
134  // Create element tags
135  vector<int> tags;
136  tags.push_back(0); // composite
137  tags.push_back(vtkCellTypes[c]); // element type
138 
139  // Read element node list
140  vector<NodeSharedPtr> nodeList;
141  for (int k = j; k < j + vtkNumPoints[c]; ++k)
142  {
143  nodeList.push_back(m_mesh->m_node[pts[k]]);
144  }
145 
146  // Create element
147  ElmtConfig conf(vtkCellTypes[c], 1, false, false);
149  vtkCellTypes[c], conf, nodeList, tags);
150 
151  // Determine mesh expansion dimension
152  if (E->GetDim() > m_mesh->m_expDim)
153  {
154  m_mesh->m_expDim = E->GetDim();
155  }
156  m_mesh->m_element[E->GetDim()].push_back(E);
157  }
158  }
159  }
160 
161  ProcessVertices();
162  ProcessEdges();
163  ProcessFaces();
164  ProcessElements();
166 }
Basic information about an element.
Definition: ElementConfig.h:50
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.
Definition: NekFactory.hpp:162
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
virtual NEKMESHUTILS_EXPORT void ProcessElements()
Generate element IDs.
static std::string npts
Definition: InputFld.cpp:43
std::map< std::string, ConfigOption > m_config
List of configuration values.
virtual NEKMESHUTILS_EXPORT void ProcessVertices()
Extract element vertices.
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.

Member Data Documentation

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

Definition at line 55 of file InputVtk.h.