Nektar++
OutputVtk.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: OutputVtk.h
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Vtk output module using the VTK library
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef FIELDUTILS_OUTPUTVTK
36 #define FIELDUTILS_OUTPUTVTK
37 
38 #include "OutputVtkBase.h"
39 #include <tinyxml.h>
40 
41 #include <vtkNew.h>
42 #include <vtkSmartPointer.h>
43 #include <vtkUnstructuredGrid.h>
44 
45 namespace Nektar
46 {
47 namespace FieldUtils
48 {
49 
50 /// Converter from fld to vtk.
51 class OutputVtk final : public OutputVtkBase
52 {
53 public:
54  /// Creates an instance of this class
55  static std::shared_ptr<Module> create(const FieldSharedPtr &f)
56  {
58  }
59 
61 
62  explicit OutputVtk(FieldSharedPtr f);
63 
64  ~OutputVtk() final = default;
65 
66 protected:
67  virtual std::string v_GetModuleName() override final
68  {
69  return "OutputVtk";
70  }
71 
72  /// Write from pts to output file.
73  virtual void v_OutputFromPts(po::variables_map &vm) override final;
74 
75  /// Write from m_exp to output file.
76  virtual void v_OutputFromExp(po::variables_map &vm) override final;
77 
78  /// Write from data to output file.
79  virtual void v_OutputFromData(po::variables_map &vm) override final;
80 
81  /// Cache file for unstructured grid VTK mesh data
82  vtkSmartPointer<vtkUnstructuredGrid> m_vtkMesh;
83 
84  /// Number of planes if homogeneous
85  int m_numPlanes = 1;
86 
87  /// Flag if extra plane in case of fourier expansion in homogeneous dir
88  bool m_extraPlane = false;
89 
90  /// Flag if mesh has been cached
91  bool m_cachedMesh = false;
92 
93 private:
94  /// Prepare high order Lagrange VTK output
95  vtkSmartPointer<vtkUnstructuredGrid> OutputFromExpHighOrder(
96  po::variables_map &vm);
97 
98  /// Add field data to high order Lagrange VTK output
100  po::variables_map &vm, std::string &filename,
101  vtkSmartPointer<vtkUnstructuredGrid> &vtkMesh);
102 
103  /// Prepare low order VTK output
104  vtkSmartPointer<vtkUnstructuredGrid> OutputFromExpLowOrder();
105 
106  /// Add field data to low order VTK output
108  po::variables_map &vm, std::string &filename,
109  vtkSmartPointer<vtkUnstructuredGrid> &vtkMesh);
110 
111  /// Prepare low order multi-block VTK output & add field data
112  void OutputFromExpLowOrderMultiBlock(po::variables_map &vm,
113  std::string &filename);
114 
115  /// Write VTK file using @param vtkMesh
116  void WriteVTK(vtkDataObject *vtkMesh, std::string &filename,
117  po::variables_map &vm);
118 
119  /// Write the parallel .pvtu file
120  void WritePVtu(po::variables_map &vm);
121 };
122 } // namespace FieldUtils
123 } // namespace Nektar
124 
125 #endif
Converter from fld to vtk.
Definition: OutputVtkBase.h:48
Converter from fld to vtk.
Definition: OutputVtk.h:52
vtkSmartPointer< vtkUnstructuredGrid > OutputFromExpLowOrder()
Prepare low order VTK output.
Definition: OutputVtk.cpp:856
void AddFieldDataToVTKHighOrder(po::variables_map &vm, std::string &filename, vtkSmartPointer< vtkUnstructuredGrid > &vtkMesh)
Add field data to high order Lagrange VTK output.
Definition: OutputVtk.cpp:1431
void OutputFromExpLowOrderMultiBlock(po::variables_map &vm, std::string &filename)
Prepare low order multi-block VTK output & add field data.
Definition: OutputVtk.cpp:1023
OutputVtk(FieldSharedPtr f)
Definition: OutputVtk.cpp:59
vtkSmartPointer< vtkUnstructuredGrid > m_vtkMesh
Cache file for unstructured grid VTK mesh data.
Definition: OutputVtk.h:82
bool m_extraPlane
Flag if extra plane in case of fourier expansion in homogeneous dir.
Definition: OutputVtk.h:88
int m_numPlanes
Number of planes if homogeneous.
Definition: OutputVtk.h:85
virtual std::string v_GetModuleName() override final
Definition: OutputVtk.h:67
virtual void v_OutputFromPts(po::variables_map &vm) override final
Write from pts to output file.
Definition: OutputVtk.cpp:1604
void AddFieldDataToVTKLowOrder(po::variables_map &vm, std::string &filename, vtkSmartPointer< vtkUnstructuredGrid > &vtkMesh)
Add field data to low order VTK output.
Definition: OutputVtk.cpp:979
void WriteVTK(vtkDataObject *vtkMesh, std::string &filename, po::variables_map &vm)
Write VTK file using.
Definition: OutputVtk.cpp:1462
static std::shared_ptr< Module > create(const FieldSharedPtr &f)
Creates an instance of this class.
Definition: OutputVtk.h:55
vtkSmartPointer< vtkUnstructuredGrid > OutputFromExpHighOrder(po::variables_map &vm)
Prepare high order Lagrange VTK output.
Definition: OutputVtk.cpp:1302
static ModuleKey m_className
Definition: OutputVtk.h:60
virtual void v_OutputFromData(po::variables_map &vm) override final
Write from data to output file.
Definition: OutputVtk.cpp:1596
virtual void v_OutputFromExp(po::variables_map &vm) override final
Write from m_exp to output file.
Definition: OutputVtk.cpp:1609
bool m_cachedMesh
Flag if mesh has been cached.
Definition: OutputVtk.h:91
void WritePVtu(po::variables_map &vm)
Write the parallel .pvtu file.
Definition: OutputVtk.cpp:1524
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:991
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:317
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2