Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 (MeshSharedPtr m)
 
virtual ~InputVtk ()
 
virtual void Process ()
 Populate and validate required data structures. More...
 
- Public Member Functions inherited from Nektar::Utilities::InputModule
 InputModule (FieldSharedPtr p_m)
 
void AddFile (string fileType, string fileName)
 
 InputModule (MeshSharedPtr p_m)
 
void OpenStream ()
 Open a file for input. More...
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
virtual void Process (po::variables_map &vm)=0
 
virtual std::string GetModuleName ()=0
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
void RegisterConfig (std::string key, std::string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
virtual void ClearElementLinks ()
 

Static Public Member Functions

static ModuleSharedPtr create (MeshSharedPtr m)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::InputModule
void PrintSummary ()
 Print summary of elements. More...
 
void PrintSummary ()
 Print summary of elements. More...
 
- Protected Member Functions inherited from Nektar::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::InputModule
set< string > m_allowedFiles
 
std::ifstream m_mshFile
 Input stream. More...
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
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 ( MeshSharedPtr  m)

Definition at line 56 of file InputVtk.cpp.

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

Definition at line 60 of file InputVtk.cpp.

61 {
62 }

Member Function Documentation

static ModuleSharedPtr Nektar::Utilities::InputVtk::create ( 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::Utilities::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::Utilities::Module::m_config, Nektar::Utilities::Module::m_mesh, npts, Nektar::Utilities::Module::ProcessComposites(), Nektar::Utilities::Module::ProcessEdges(), Nektar::Utilities::Module::ProcessElements(), Nektar::Utilities::Module::ProcessFaces(), and Nektar::Utilities::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: Element.h:58
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
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
Represents a point in the domain.
Definition: Node.h:60
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
virtual void ProcessVertices()
Extract element vertices.
virtual void ProcessElements()
Generate element IDs.
static std::string npts
Definition: InputFld.cpp:43
virtual void ProcessComposites()
Generate composites.
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:52

Member Data Documentation

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

Definition at line 55 of file InputVtk.h.