Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/df/d34/ADIOS2Writers_8h_source.html
DOLFINx  0.5.1
DOLFINx C++ interface
ADIOS2Writers.h
1 // Copyright (C) 2021 Jørgen S. Dokken and 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 #ifdef HAS_ADIOS2
10 
11 #include <cassert>
12 #include <complex>
13 #include <filesystem>
14 #include <memory>
15 #include <mpi.h>
16 #include <string>
17 #include <variant>
18 #include <vector>
19 
20 namespace adios2
21 {
22 class ADIOS;
23 class IO;
24 class Engine;
25 } // namespace adios2
26 
27 namespace dolfinx::fem
28 {
29 template <typename T>
30 class Function;
31 }
32 
33 namespace dolfinx::mesh
34 {
35 class Mesh;
36 }
37 
38 namespace dolfinx::io
39 {
40 
43 {
44 public:
50  using U = std::vector<
51  std::variant<std::shared_ptr<const Fdr>, std::shared_ptr<const Fdc>>>;
52 
53 private:
60  ADIOS2Writer(MPI_Comm comm, const std::filesystem::path& filename,
61  const std::string& tag,
62  const std::shared_ptr<const mesh::Mesh>& mesh, const U& u);
63 
64 protected:
70  ADIOS2Writer(MPI_Comm comm, const std::filesystem::path& filename,
71  const std::string& tag, std::shared_ptr<const mesh::Mesh> mesh);
72 
78  ADIOS2Writer(MPI_Comm comm, const std::filesystem::path& filename,
79  const std::string& tag, const U& u);
80 
82  ADIOS2Writer(ADIOS2Writer&& writer) = default;
83 
85  ADIOS2Writer(const ADIOS2Writer&) = delete;
86 
88  ~ADIOS2Writer();
89 
91  ADIOS2Writer& operator=(ADIOS2Writer&& writer) = default;
92 
93  // Copy assignment
94  ADIOS2Writer& operator=(const ADIOS2Writer&) = delete;
95 
96 public:
98  void close();
99 
100 protected:
101  std::unique_ptr<adios2::ADIOS> _adios;
102  std::unique_ptr<adios2::IO> _io;
103  std::unique_ptr<adios2::Engine> _engine;
104  std::shared_ptr<const mesh::Mesh> _mesh;
105  U _u;
106 };
107 
111 class FidesWriter : public ADIOS2Writer
112 {
113 public:
120  FidesWriter(MPI_Comm comm, const std::filesystem::path& filename,
121  std::shared_ptr<const mesh::Mesh> mesh);
122 
129  FidesWriter(MPI_Comm comm, const std::filesystem::path& filename,
130  const ADIOS2Writer::U& u);
131 
132  // Copy constructor
133  FidesWriter(const FidesWriter&) = delete;
134 
136  FidesWriter(FidesWriter&& file) = default;
137 
139  ~FidesWriter() = default;
140 
143 
144  // Copy assignment
145  FidesWriter& operator=(const FidesWriter&) = delete;
146 
149  void write(double t);
150 };
151 
156 class VTXWriter : public ADIOS2Writer
157 {
158 public:
167  VTXWriter(MPI_Comm comm, const std::filesystem::path& filename,
168  std::shared_ptr<const mesh::Mesh> mesh);
169 
177  VTXWriter(MPI_Comm comm, const std::filesystem::path& filename, const U& u);
178 
179  // Copy constructor
180  VTXWriter(const VTXWriter&) = delete;
181 
183  VTXWriter(VTXWriter&& file) = default;
184 
186  ~VTXWriter() = default;
187 
190 
191  // Copy assignment
192  VTXWriter& operator=(const VTXWriter&) = delete;
193 
196  void write(double t);
197 };
198 
199 } // namespace dolfinx::io
200 
201 #endif
This class represents a function in a finite element function space , given by.
Definition: Function.h:45
Base class for ADIOS2-based writers.
Definition: ADIOS2Writers.h:43
ADIOS2Writer & operator=(ADIOS2Writer &&writer)=default
Move assignment.
void close()
Close the file.
Definition: ADIOS2Writers.cpp:694
ADIOS2Writer(const ADIOS2Writer &)=delete
Copy constructor.
ADIOS2Writer(ADIOS2Writer &&writer)=default
Move constructor.
~ADIOS2Writer()
Destructor.
Definition: ADIOS2Writers.cpp:692
std::vector< std::variant< std::shared_ptr< const Fdr >, std::shared_ptr< const Fdc > >> U
Typedefs.
Definition: ADIOS2Writers.h:51
Output of meshes and functions compatible with the Fides Paraview reader, see https://fides....
Definition: ADIOS2Writers.h:112
FidesWriter(MPI_Comm comm, const std::filesystem::path &filename, std::shared_ptr< const mesh::Mesh > mesh)
Create Fides writer for a mesh.
Definition: ADIOS2Writers.cpp:703
void write(double t)
Write data with a given time.
Definition: ADIOS2Writers.cpp:780
FidesWriter(FidesWriter &&file)=default
Move constructor.
~FidesWriter()=default
Destructor.
FidesWriter & operator=(FidesWriter &&)=default
Move assignment.
Writer for meshes and functions using the ADIOS2 VTX format, see https://adios2.readthedocs....
Definition: ADIOS2Writers.h:157
~VTXWriter()=default
Destructor.
void write(double t)
Write data with a given time.
Definition: ADIOS2Writers.cpp:862
VTXWriter(VTXWriter &&file)=default
Move constructor.
VTXWriter & operator=(VTXWriter &&)=default
Move assignment.
VTXWriter(MPI_Comm comm, const std::filesystem::path &filename, std::shared_ptr< const mesh::Mesh > mesh)
Create a VTX writer for a mesh. This format supports arbitrary degree meshes.
Definition: ADIOS2Writers.cpp:796
Finite element method functionality.
Definition: assemble_matrix_impl.h:25
Support for file IO.
Definition: ADIOS2Writers.h:39
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:30