Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.3.0/v0.9.0/cpp
DOLFINx  0.3.0
DOLFINx C++ interface
VTKFile.h
1 // Copyright (C) 2020 Garth N. Wells
2 //
3 // This file is part of DOLFINx (https://www.fenicsproject.org)
4 //
5 // SPDX-License-Identifier: LGPL-3.0-or-later
6 
7 #pragma once
8 
9 #include <dolfinx/common/MPI.h>
10 #include <dolfinx/fem/Function.h>
11 #include <functional>
12 #include <memory>
13 #include <string>
14 
15 namespace pugi
16 {
17 class xml_document;
18 }
19 
20 namespace dolfinx::function
21 {
22 template <typename T>
23 class Function;
24 }
25 
26 namespace dolfinx::mesh
27 {
28 class Mesh;
29 }
30 
31 namespace dolfinx::io
32 {
33 
40 
43 
44 class VTKFile
45 {
46 public:
48  VTKFile(MPI_Comm comm, const std::string filename,
49  const std::string file_mode);
50 
52  ~VTKFile();
53 
55  void close();
56 
58  void flush();
59 
64  void write(const mesh::Mesh& mesh, double time = 0.0);
65 
69  void write(
70  const std::vector<std::reference_wrapper<const fem::Function<double>>>& u,
71  double t);
72 
76  void write(
77  const std::vector<
78  std::reference_wrapper<const fem::Function<std::complex<double>>>>& u,
79  double t);
80 
81 private:
82  std::unique_ptr<pugi::xml_document> _pvd_xml;
83 
84  std::string _filename;
85 
86  // MPI communicator
87  dolfinx::MPI::Comm _comm;
88 };
89 } // namespace dolfinx::io
A duplicate MPI communicator and manage lifetime of the communicator.
Definition: MPI.h:32
This class represents a function in a finite element function space , given by.
Definition: Function.h:47
Definition: VTKFile.h:23
Output of meshes and functions in VTK/ParaView format. Isoparametric meshes of arbitrary degree are s...
Definition: VTKFile.h:45
~VTKFile()
Destructor.
Definition: VTKFile.cpp:731
void flush()
Flushes XML files to disk.
Definition: VTKFile.cpp:751
void write(const mesh::Mesh &mesh, double time=0.0)
Write mesh to file. Supports arbitrary order Lagrange isoparametric cells.
Definition: VTKFile.cpp:775
void close()
Close file.
Definition: VTKFile.cpp:737
VTKFile(MPI_Comm comm, const std::string filename, const std::string file_mode)
Create VTK file.
Definition: VTKFile.cpp:719
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition: Mesh.h:53
Support for file IO.
Definition: cells.h:22
Mesh data structures and algorithms on meshes.
Definition: DirichletBC.h:20