DOLFINx 0.12.0.0
DOLFINx C++
Loading...
Searching...
No Matches
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 <concepts>
10#include <dolfinx/common/MPI.h>
11#include <dolfinx/common/types.h>
12#include <filesystem>
13#include <functional>
14#include <memory>
15#include <string>
16#include <string_view>
17
18namespace pugi
19{
20class xml_document;
21}
22
23namespace dolfinx::fem
24{
25template <dolfinx::scalar T, std::floating_point U>
26class Function;
27}
28
29namespace dolfinx::mesh
30{
31template <std::floating_point T>
32class Mesh;
33}
34
35namespace dolfinx::io
36{
37
48{
49public:
51 VTKFile(MPI_Comm comm, const std::filesystem::path& filename,
52 std::string_view file_mode);
53
54 // Copy constructor (deleted)
55 VTKFile(const VTKFile& file) = delete;
56
61 VTKFile(VTKFile&& file) noexcept;
62
64 ~VTKFile();
65
66 // Copy assignment (deleted)
67 VTKFile& operator=(const VTKFile& file) = delete;
68
71 VTKFile& operator=(VTKFile&& file) noexcept;
72
74 void close();
75
77 void flush();
78
85 template <std::floating_point U>
86 void write(const mesh::Mesh<U>& mesh, double t = 0.0);
87
104 template <dolfinx::scalar T, std::floating_point U = scalar_value_t<T>>
105 void
106 write(const std::vector<std::reference_wrapper<const fem::Function<T, U>>>& u,
107 double t);
108
109private:
110 std::unique_ptr<pugi::xml_document> _pvd_xml;
111
112 std::filesystem::path _filename;
113
114 // MPI communicator
115 dolfinx::MPI::Comm _comm;
116};
117} // namespace dolfinx::io
A duplicate MPI communicator and manage lifetime of the communicator.
Definition MPI.h:47
Definition Function.h:44
VTKFile & operator=(VTKFile &&file) noexcept
void write(const mesh::Mesh< U > &mesh, double t=0.0)
Write a mesh to file.
Definition VTKFile.cpp:772
void close()
Close file.
Definition VTKFile.cpp:740
~VTKFile()
Destructor.
Definition VTKFile.cpp:730
void flush()
Flushes XML files to disk.
Definition VTKFile.cpp:757
VTKFile(VTKFile &&file) noexcept
VTKFile(MPI_Comm comm, const std::filesystem::path &filename, std::string_view file_mode)
Create VTK file.
Definition VTKFile.cpp:714
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition Mesh.h:25
Finite element method functionality.
Definition assemble_expression_impl.h:22
Support for file IO.
Definition ADIOS2Writers.h:43
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32