IOSS 2.0

AdiosWrapper.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2010 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // * Neither the name of NTESS nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 #ifndef IOSS_Ioad_AdiosWrapper_h
34 #define IOSS_Ioad_AdiosWrapper_h
35
36 #include <Ioss_PropertyManager.h>
37 #include <adios2.h>
38 #include <string>
39
40 namespace Ioad {
41
42 class AdiosWrapper : private adios2::ADIOS, private adios2::IO, private adios2::Engine
43 {
44 public:
45 AdiosWrapper(MPI_Comm communicator, const std::string &filename, bool is_input,
46 unsigned long rank, const Ioss::PropertyManager &properties);
47 AdiosWrapper(AdiosWrapper &&wrapper);
48 ~AdiosWrapper();
49 adios2::StepStatus BeginStep();
50 void EndStep();
51 template <typename T>
52 void DefineMetaVariable(const std::string &meta_name, const std::string &variable_name = "");
53
54 template <typename T>
55 void DefineVariable(const std::string &name, const adios2::Dims &shape = adios2::Dims(),
56 const adios2::Dims &start = adios2::Dims(),
57 const adios2::Dims &count = adios2::Dims(),
58 const bool constantDims = false);
59 template <typename T> void Put(const std::string &name, const T *value);
60
61 template <typename T> void DefineAttribute(const std::string &name, const T &value);
62
63 template <typename T> void InquireAndPut(const std::string &name, const T *value);
64 template <typename T>
65 T GetAttribute(const std::string &attribute_name, bool ignore_missing = false,
66 T default_value = T());
67
68 template <typename T> void GetSync(adios2::Variable<T> var, T *data);
69
70 template <typename T> void GetSync(std::string var_name, T *data);
71
72 template <typename T> void GetSync(adios2::Variable<T> var, T &data);
73 template <typename T> void GetSync(std::string var_name, T &data);
74
75 template <typename T>
76 void PutMetaVariable(const std::string &meta_name, T value,
77 const std::string &variable_name = "");
78 template <typename T>
79 T GetMetaVariable(const std::string &meta_name, const std::string &variable_name = "");
80 std::pair<std::string, std::string> DecodeMetaName(std::string name) const;
81 std::string EncodeMetaVariable(const std::string &meta_name,
82 const std::string &variable_name = "") const;
83
84 bool IsStreaming() const { return m_IsStreaming; };
85
86 using adios2::Engine::AllStepsBlocksInfo;
87 using adios2::IO::AvailableVariables;
88 using adios2::IO::InquireAttribute;
89 using adios2::IO::InquireVariable;
90
91 private:
92 adios2::IO IOInit(const Ioss::PropertyManager &properties, bool is_input);
93 adios2::Engine EngineInit(const std::string &filename, bool is_input);
94
95 const std::string m_MetaSeparator{"::"};
96
97 const int m_Rank;
98 const MPI_Comm m_Communicator;
99
100 bool m_OpenStep;
101 bool m_IsStreaming;
102 int count_real_begin = 0;
103 };
104
105 } // end of namespace Ioad
106
107 #include "adios/AdiosWrapper.hpp"
108
109 #endif
Ioad::AdiosWrapper::IOInit
adios2::IO IOInit(const Ioss::PropertyManager &properties, bool is_input)
Definition: AdiosWrapper.C:47
Ioad::AdiosWrapper::m_IsStreaming
bool m_IsStreaming
Definition: AdiosWrapper.h:101
Ioad::AdiosWrapper::AdiosWrapper
AdiosWrapper(MPI_Comm communicator, const std::string &filename, bool is_input, unsigned long rank, const Ioss::PropertyManager &properties)
Definition: AdiosWrapper.C:39
Ioad::AdiosWrapper::DecodeMetaName
std::pair< std::string, std::string > DecodeMetaName(std::string name) const
Definition: AdiosWrapper.C:157
Ioad::AdiosWrapper::EncodeMetaVariable
std::string EncodeMetaVariable(const std::string &meta_name, const std::string &variable_name="") const
Definition: AdiosWrapper.C:146
Ioad::AdiosWrapper::m_Communicator
const MPI_Comm m_Communicator
Definition: AdiosWrapper.h:98
Ioad::AdiosWrapper::GetAttribute
T GetAttribute(const std::string &attribute_name, bool ignore_missing=false, T default_value=T())
Ioad
A namespace for the adios database format.
Definition: AdiosWrapper.C:37
Ioad::AdiosWrapper::BeginStep
adios2::StepStatus BeginStep()
Definition: AdiosWrapper.C:124
Ioad::AdiosWrapper::count_real_begin
int count_real_begin
Definition: AdiosWrapper.h:102
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Ioad::AdiosWrapper::GetMetaVariable
T GetMetaVariable(const std::string &meta_name, const std::string &variable_name="")
Ioad::AdiosWrapper::EndStep
void EndStep()
Definition: AdiosWrapper.C:138
Ioad::AdiosWrapper::m_Rank
const int m_Rank
Definition: AdiosWrapper.h:97
Ioad::AdiosWrapper::m_OpenStep
bool m_OpenStep
Definition: AdiosWrapper.h:100
anonymous_namespace{Iocgns_DecompositionData.C}::rank
int rank
Definition: Iocgns_DecompositionData.C:55
Ioad::AdiosWrapper::Put
void Put(const std::string &name, const T *value)
Ioad::AdiosWrapper::~AdiosWrapper
~AdiosWrapper()
Definition: AdiosWrapper.C:118
Ioad::AdiosWrapper::DefineAttribute
void DefineAttribute(const std::string &name, const T &value)
Ioad::AdiosWrapper::PutMetaVariable
void PutMetaVariable(const std::string &meta_name, T value, const std::string &variable_name="")
Ioss_PropertyManager.h
Ioad::AdiosWrapper::DefineMetaVariable
void DefineMetaVariable(const std::string &meta_name, const std::string &variable_name="")
Ioad::AdiosWrapper::DefineVariable
void DefineVariable(const std::string &name, const adios2::Dims &shape=adios2::Dims(), const adios2::Dims &start=adios2::Dims(), const adios2::Dims &count=adios2::Dims(), const bool constantDims=false)
anonymous_namespace{cth_pressure_map.C}::data
std::vector< char > data
Definition: cth_pressure_map.C:74
Ioad::AdiosWrapper::IsStreaming
bool IsStreaming() const
Definition: AdiosWrapper.h:84
anonymous_namespace{io_info.C}::name
std::string name(const Ioss::GroupingEntity *entity)
Definition: io_info.C:89
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:96
Ioad::AdiosWrapper
Definition: AdiosWrapper.h:42
Ioad::AdiosWrapper::EngineInit
adios2::Engine EngineInit(const std::string &filename, bool is_input)
Definition: AdiosWrapper.C:109
Ioad::AdiosWrapper::InquireAndPut
void InquireAndPut(const std::string &name, const T *value)
Ioad::AdiosWrapper::GetSync
void GetSync(adios2::Variable< T > var, T *data)
Ioad::AdiosWrapper::m_MetaSeparator
const std::string m_MetaSeparator
Definition: AdiosWrapper.h:95