-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ADIOS2Engine class adapted from ADIOS2Writer
- Loading branch information
Showing
7 changed files
with
158 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (C) 2021-2023 Jørgen S. Dokken and Garth N. Wells | ||
// | ||
// This file is part of DOLFINX (https://www.fenicsproject.org) | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#ifdef HAS_ADIOS2 | ||
|
||
#include "ADIOS2_utils.h" | ||
#include <adios2.h> | ||
#include <mpi.h> | ||
|
||
using namespace dolfinx::io; | ||
|
||
//----------------------------------------------------------------------------- | ||
ADIOS2Engine::ADIOS2Engine(MPI_Comm comm, const std::filesystem::path& filename, | ||
std::string tag, std::string engine, | ||
const adios2::Mode mode) | ||
|
||
: _adios(std::make_unique<adios2::ADIOS>(comm)), | ||
_io(std::make_unique<adios2::IO>(_adios->DeclareIO(tag))) | ||
{ | ||
_io->SetEngine(engine); | ||
_engine = std::make_unique<adios2::Engine>(_io->Open(filename, mode)); | ||
} | ||
//----------------------------------------------------------------------------- | ||
ADIOS2Engine::~ADIOS2Engine() { close(); } | ||
//----------------------------------------------------------------------------- | ||
void ADIOS2Engine::close() | ||
{ | ||
assert(_engine); | ||
if (*_engine) | ||
_engine->Close(); | ||
} | ||
// //----------------------------------------------------------------------------- | ||
// std::unique_ptr<adios2::IO> ADIOS2Engine::io() | ||
// { | ||
// assert(_io); | ||
// if (*_io) | ||
// return _io; | ||
// } | ||
// //----------------------------------------------------------------------------- | ||
// std::unique_ptr<adios2::Engine> ADIOS2Engine::engine() | ||
// { | ||
// assert(_engine); | ||
// if (*_engine) | ||
// return _engine; | ||
// } | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (C) 2021-2023 Jørgen S. Dokken and Garth N. Wells | ||
// | ||
// This file is part of DOLFINX (https://www.fenicsproject.org) | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#ifdef HAS_ADIOS2 | ||
|
||
#include <adios2.h> | ||
#include <cassert> | ||
#include <filesystem> | ||
#include <mpi.h> | ||
|
||
/// @file ADIOS2_utils.h | ||
/// @brief Utils for ADIOS2 | ||
|
||
namespace dolfinx::io | ||
{ | ||
class ADIOS2Engine | ||
{ | ||
public: | ||
/// @brief Create an ADIOS2-based engine writer/reader | ||
/// @param[in] comm The MPI communicator | ||
/// @param[in] filename Name of output file | ||
/// @param[in] tag The ADIOS2 object name | ||
/// @param[in] engine ADIOS2 engine type. See | ||
/// https://adios2.readthedocs.io/en/latest/engines/engines.html. | ||
ADIOS2Engine(MPI_Comm comm, const std::filesystem::path& filename, | ||
std::string tag, std::string engine = "BP5", | ||
const adios2::Mode mode = adios2::Mode::Write); | ||
|
||
/// @brief Move constructor | ||
ADIOS2Engine(ADIOS2Engine&& engine) = default; | ||
|
||
/// @brief Copy constructor | ||
ADIOS2Engine(const ADIOS2Engine&) = delete; | ||
|
||
/// @brief Destructor | ||
~ADIOS2Engine(); | ||
|
||
/// @brief Move assignment | ||
ADIOS2Engine& operator=(ADIOS2Engine&& engine) = default; | ||
|
||
// Copy assignment | ||
ADIOS2Engine& operator=(const ADIOS2Engine&) = delete; | ||
|
||
/// @brief Close the file | ||
void close(); | ||
|
||
// /// @brief Get the IO object | ||
// std::unique_ptr<adios2::IO> io(); | ||
|
||
// /// @brief Close the Engine object | ||
// std::unique_ptr<adios2::Engine> engine(); | ||
|
||
protected: | ||
std::unique_ptr<adios2::ADIOS> _adios; | ||
std::unique_ptr<adios2::IO> _io; | ||
std::unique_ptr<adios2::Engine> _engine; | ||
}; | ||
|
||
} // namespace dolfinx::io | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters