MFEM  v4.3.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
vtk.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2021, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_VTK
13 #define MFEM_VTK
14 
15 #include "../fem/geom.hpp"
16 
17 namespace mfem
18 {
19 
20 // Helpers for reading and writing VTK format
21 
22 // VTK element types defined at: https://git.io/JvZLm
24 {
25  static const int POINT = 1;
26  static const int SEGMENT = 3;
27  static const int TRIANGLE = 5;
28  static const int SQUARE = 9;
29  static const int TETRAHEDRON = 10;
30  static const int CUBE = 12;
31  static const int PRISM = 13;
32 
33  static const int QUADRATIC_SEGMENT = 21;
34  static const int QUADRATIC_TRIANGLE = 22;
35  static const int BIQUADRATIC_SQUARE = 28;
36  static const int QUADRATIC_TETRAHEDRON = 24;
37  static const int TRIQUADRATIC_CUBE = 29;
38  static const int QUADRATIC_PRISM = 26;
39  static const int BIQUADRATIC_QUADRATIC_PRISM = 32;
40 
41  static const int LAGRANGE_SEGMENT = 68;
42  static const int LAGRANGE_TRIANGLE = 69;
43  static const int LAGRANGE_SQUARE = 70;
44  static const int LAGRANGE_TETRAHEDRON = 71;
45  static const int LAGRANGE_CUBE = 72;
46  static const int LAGRANGE_PRISM = 73;
47 
48  static const int PrismMap[6];
50 
51  static const int Map[Geometry::NUM_GEOMETRIES];
54 
55  static Geometry::Type GetMFEMGeometry(int vtk_geom);
56  static bool IsLagrange(int vtk_geom);
57  static bool IsQuadratic(int vtk_geom);
58  static int GetOrder(int vtk_geom, int npoints);
59 };
60 
61 enum class VTKFormat
62 {
63  ASCII,
64  BINARY,
65  BINARY32
66 };
67 
68 /// Create the VTK element connectivity array for a given element geometry and
69 /// refinement level. Converts node numbers from MFEM to VTK ordering.
71  int ref);
72 
73 /// Outputs encoded binary data in the format needed by VTK. The binary data
74 /// will be base 64 encoded, and compressed if @a compression_level is not
75 /// zero. The proper header will be prepended to the data.
76 void WriteVTKEncodedCompressed(std::ostream &out, const void *bytes,
77  uint32_t nbytes, int compression_level);
78 
79 int BarycentricToVTKTriangle(int *b, int ref);
80 
81 const char *VTKByteOrder();
82 
83 } // namespace mfem
84 
85 #endif
static const int BIQUADRATIC_SQUARE
Definition: vtk.hpp:35
static const int HighOrderMap[Geometry::NUM_GEOMETRIES]
Definition: vtk.hpp:53
static const int QUADRATIC_TETRAHEDRON
Definition: vtk.hpp:36
const Geometry::Type geom
Definition: ex1.cpp:40
static const int SQUARE
Definition: vtk.hpp:28
static bool IsLagrange(int vtk_geom)
Definition: vtk.cpp:80
static const int LAGRANGE_CUBE
Definition: vtk.hpp:45
static const int CUBE
Definition: vtk.hpp:30
static const int PRISM
Definition: vtk.hpp:31
static const int QUADRATIC_TRIANGLE
Definition: vtk.hpp:34
int BarycentricToVTKTriangle(int *b, int ref)
Definition: vtk.cpp:153
static const int TRIQUADRATIC_CUBE
Definition: vtk.hpp:37
double b
Definition: lissajous.cpp:42
static const int Map[Geometry::NUM_GEOMETRIES]
Definition: vtk.hpp:51
static const int LAGRANGE_SEGMENT
Definition: vtk.hpp:41
VTKFormat
Definition: vtk.hpp:61
static const int LAGRANGE_SQUARE
Definition: vtk.hpp:43
static const int BIQUADRATIC_QUADRATIC_PRISM
Definition: vtk.hpp:39
static const int QuadraticMap[Geometry::NUM_GEOMETRIES]
Definition: vtk.hpp:52
static Geometry::Type GetMFEMGeometry(int vtk_geom)
Definition: vtk.cpp:45
static const int TRIANGLE
Definition: vtk.hpp:27
static const int LAGRANGE_TETRAHEDRON
Definition: vtk.hpp:44
static const int QUADRATIC_SEGMENT
Definition: vtk.hpp:33
static const int TETRAHEDRON
Definition: vtk.hpp:29
const char * VTKByteOrder()
Definition: vtk.cpp:590
static const int POINT
Definition: vtk.hpp:25
void WriteVTKEncodedCompressed(std::ostream &out, const void *bytes, uint32_t nbytes, int compression_level)
Definition: vtk.cpp:547
static const int QUADRATIC_PRISM
Definition: vtk.hpp:38
static const int LAGRANGE_TRIANGLE
Definition: vtk.hpp:42
static const int PrismMap[6]
Definition: vtk.hpp:48
void CreateVTKElementConnectivity(Array< int > &con, Geometry::Type geom, int ref)
Definition: vtk.cpp:489
static const int SEGMENT
Definition: vtk.hpp:26
static bool IsQuadratic(int vtk_geom)
Definition: vtk.cpp:85
static const int * VertexPermutation[Geometry::NUM_GEOMETRIES]
Definition: vtk.hpp:49
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition: globals.hpp:66
static int GetOrder(int vtk_geom, int npoints)
Definition: vtk.cpp:91
static const int LAGRANGE_PRISM
Definition: vtk.hpp:46