-
-
Notifications
You must be signed in to change notification settings - Fork 251
VTXWriter: support file modes #4177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a1669b5
29e1102
3db6a54
5cbaf28
f79b1ee
476f551
0d7f6de
1911667
6c85ae8
3e08fd3
8147934
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,12 @@ | |
|
|
||
| #pragma once | ||
|
|
||
| #include <string_view> | ||
| #ifdef HAS_ADIOS2 | ||
|
|
||
| #include "vtk_utils.h" | ||
| #include <adios2.h> | ||
| #include <adios2/common/ADIOSTypes.h> | ||
| #include <algorithm> | ||
| #include <basix/mdspan.hpp> | ||
| #include <cassert> | ||
|
|
@@ -59,11 +61,12 @@ class ADIOS2Writer | |
| /// @brief Create an ADIOS2-based writer | ||
| /// @param[in] comm The MPI communicator | ||
| /// @param[in] filename Name of output file | ||
| /// @param[in] mode Mode to open file with | ||
| /// @param[in] tag The ADIOS2 object name | ||
| /// @param[in] engine ADIOS2 engine type. See | ||
| /// https://adios2.readthedocs.io/en/latest/engines/engines.html. | ||
| ADIOS2Writer(MPI_Comm comm, const std::filesystem::path& filename, | ||
| std::string tag, std::string engine); | ||
| adios2::Mode mode, std::string tag, std::string engine); | ||
|
|
||
| /// @brief Move constructor | ||
| ADIOS2Writer(ADIOS2Writer&& writer) = default; | ||
|
|
@@ -157,6 +160,11 @@ extract_common_mesh(const typename adios2_writer::U<T>& u) | |
| return mesh; | ||
| } | ||
|
|
||
| /// Convert string to corresponding adios2 mode. | ||
| /// @param[in] mode Mode in string representation, either "w" or "a". | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving aside Enum vs no Enum, it's generally most transparent to map modes directly e.g. "Read" -> "adios2::Mode::Read". Then I have a clear idea what "Read" means in the context of the underlying library.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| /// @returns Adios2 mode. | ||
| adios2::Mode mode(std::string_view mode); | ||
|
|
||
| } // namespace impl_adios2 | ||
|
|
||
| /// @privatesection | ||
|
|
@@ -461,16 +469,18 @@ class VTXWriter : public ADIOS2Writer | |
| /// | ||
| /// @param[in] comm MPI communicator to open the file on. | ||
| /// @param[in] filename Name of output file. | ||
| /// @param[in] mode Mode to open file with | ||
| /// @param[in] mesh Mesh to write. | ||
| /// @param[in] engine ADIOS2 engine type. | ||
| /// @note This format supports arbitrary degree meshes. | ||
| /// @note The mesh geometry can be updated between write steps but the | ||
| /// topology should not be changed between write steps. | ||
| VTXWriter(MPI_Comm comm, const std::filesystem::path& filename, | ||
| std::shared_ptr<const mesh::Mesh<T>> mesh, | ||
| const std::string& mode, std::shared_ptr<const mesh::Mesh<T>> mesh, | ||
| std::string engine = "BPFile") | ||
| : ADIOS2Writer(comm, filename, "VTX mesh writer", engine), _mesh(mesh), | ||
| _mesh_reuse_policy(VTXMeshPolicy::update), | ||
| : ADIOS2Writer(comm, filename, impl_adios2::mode(mode), "VTX mesh writer", | ||
| engine), | ||
| _mesh(mesh), _mesh_reuse_policy(VTXMeshPolicy::update), | ||
| _has_piecewise_constant(false) | ||
| { | ||
| // Define VTK scheme attribute for mesh | ||
|
|
@@ -484,6 +494,7 @@ class VTXWriter : public ADIOS2Writer | |
| /// | ||
| /// @param[in] comm The MPI communicator to open the file on | ||
| /// @param[in] filename Name of output file | ||
| /// @param[in] mode Mode to open file with | ||
| /// @param[in] u List of functions. The functions must (1) share the | ||
| /// same mesh and (2) be (discontinuous) Lagrange functions. The | ||
| /// element family and degree, and degree-of-freedom map (up to the | ||
|
|
@@ -494,9 +505,11 @@ class VTXWriter : public ADIOS2Writer | |
| /// step. | ||
| /// @note This format supports arbitrary degree meshes. | ||
| VTXWriter(MPI_Comm comm, const std::filesystem::path& filename, | ||
| const typename adios2_writer::U<T>& u, std::string engine, | ||
| const std::string& mode, const typename adios2_writer::U<T>& u, | ||
| std::string engine, | ||
| VTXMeshPolicy mesh_policy = VTXMeshPolicy::update) | ||
| : ADIOS2Writer(comm, filename, "VTX function writer", engine), | ||
| : ADIOS2Writer(comm, filename, impl_adios2::mode(mode), | ||
| "VTX function writer", engine), | ||
| _mesh(impl_adios2::extract_common_mesh<T>(u)), _u(u), | ||
| _mesh_reuse_policy(mesh_policy), _has_piecewise_constant(false) | ||
| { | ||
|
|
@@ -595,6 +608,7 @@ class VTXWriter : public ADIOS2Writer | |
| /// | ||
| /// @param[in] comm The MPI communicator to open the file on | ||
| /// @param[in] filename Name of output file | ||
| /// @param[in] mode Mode to open file with | ||
| /// @param[in] u List of functions. The functions must (1) share the | ||
| /// same mesh and (2) be (discontinuous) Lagrange functions. The | ||
| /// element family and degree must be the same for all functions. | ||
|
|
@@ -603,9 +617,9 @@ class VTXWriter : public ADIOS2Writer | |
| /// step. | ||
| /// @note This format supports arbitrary degree meshes. | ||
| VTXWriter(MPI_Comm comm, const std::filesystem::path& filename, | ||
| const typename adios2_writer::U<T>& u, | ||
| const std::string& mode, const typename adios2_writer::U<T>& u, | ||
| VTXMeshPolicy mesh_policy = VTXMeshPolicy::update) | ||
| : VTXWriter(comm, filename, u, "BPFile", mesh_policy) | ||
| : VTXWriter(comm, filename, mode, u, "BPFile", mesh_policy) | ||
| { | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if and else?