diff options
author | 2022-02-17 22:21:00 -0500 | |
---|---|---|
committer | 2022-02-17 19:21:00 -0800 | |
commit | 8e1517ae8c09c65f6602c772e6bf9f0dcb5829a8 (patch) | |
tree | 532afc5113eb03ddcfa85a36140e7bf3982cb281 /Source/Diagnostics/WarpXOpenPMD.cpp | |
parent | bc6991e6b58f455a139401c96d77dccfa35003a6 (diff) | |
download | WarpX-8e1517ae8c09c65f6602c772e6bf9f0dcb5829a8.tar.gz WarpX-8e1517ae8c09c65f6602c772e6bf9f0dcb5829a8.tar.zst WarpX-8e1517ae8c09c65f6602c772e6bf9f0dcb5829a8.zip |
openPMD: Add ADIOS2 Engine Parameter Control (#2872)
* Adds support for ADIOS engines #2866
Input file can now have lines like
diag1.adios2_engine.parameters.NumAggregators=2
* Docs for ADIOS engine type and parameters #2866
* Aesthetic edit in adios2 engine documentation #2866
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Removed debug print statement #2866
* Style Updates
Co-authored-by: Mehta, Kshitij V <kshitij-v-mehta@github.com>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Diagnostics/WarpXOpenPMD.cpp')
-rw-r--r-- | Source/Diagnostics/WarpXOpenPMD.cpp | 83 |
1 files changed, 66 insertions, 17 deletions
diff --git a/Source/Diagnostics/WarpXOpenPMD.cpp b/Source/Diagnostics/WarpXOpenPMD.cpp index ada56da36..87a588b9d 100644 --- a/Source/Diagnostics/WarpXOpenPMD.cpp +++ b/Source/Diagnostics/WarpXOpenPMD.cpp @@ -122,9 +122,18 @@ namespace detail */ inline std::string getSeriesOptions (std::string const & operator_type, - std::map< std::string, std::string > const & operator_parameters) + std::map< std::string, std::string > const & operator_parameters, + std::string const & engine_type, + std::map< std::string, std::string > const & engine_parameters) { + if (operator_type.empty() && engine_type.empty()) + return "{}"; + std::string options; + std::string top_block; + std::string end_block; + std::string op_block; + std::string en_block; std::string op_parameters; for (const auto& kv : operator_parameters) { @@ -133,31 +142,68 @@ namespace detail .append("\"").append(kv.first).append("\": ") /* key */ .append("\"").append(kv.second).append("\""); /* value (as string) */ } - if (!operator_type.empty()) { - options = R"END( + + std::string en_parameters; + for (const auto& kv : engine_parameters) { + if (!en_parameters.empty()) en_parameters.append(",\n"); + en_parameters.append(std::string(12, ' ')) /* just pretty alignment */ + .append("\"").append(kv.first).append("\": ") /* key */ + .append("\"").append(kv.second).append("\""); /* value (as string) */ + } + + // create the outer-level blocks + top_block = R"END( { - "adios2": { + "adios2": {)END"; + + end_block = R"END( + } +})END"; + + // add the operator string block + if (!operator_type.empty()) { + op_block = R"END( "dataset": { "operators": [ { "type": ")END"; - options += operator_type + "\""; - } - if (!operator_type.empty() && !op_parameters.empty()) { - options += R"END( - ,"parameters": { + op_block += operator_type + "\""; + + if (!op_parameters.empty()) { + op_block += R"END(, + "parameters": { )END"; - options += op_parameters + "}"; + op_block += op_parameters + "}"; } - if (!operator_type.empty()) - options += R"END( + op_block += R"END( } ] - } - } -} + })END"; + if (!engine_type.empty()) + op_block += ","; + + } // end operator string block + + // add the engine string block + if (!engine_type.empty()) { + en_block = R"END( + "engine": { + "type": ")END"; + en_block += engine_type + "\""; + + if (!en_parameters.empty()) { + en_block += R"END(, + "parameters": { )END"; - if (options.empty()) options = "{}"; + en_block += en_parameters + "}"; + } + + en_block += R"END( + })END"; + + } // end engine string block + + options = top_block + op_block + en_block + end_block; return options; } @@ -337,6 +383,8 @@ WarpXOpenPMDPlot::WarpXOpenPMDPlot ( std::string openPMDFileType, std::string operator_type, std::map< std::string, std::string > operator_parameters, + std::string engine_type, + std::map< std::string, std::string > engine_parameters, std::vector<bool> fieldPMLdirections) :m_Series(nullptr), m_Encoding(ie), @@ -355,7 +403,8 @@ WarpXOpenPMDPlot::WarpXOpenPMDPlot ( m_OpenPMDFileType = "json"; #endif - m_OpenPMDoptions = detail::getSeriesOptions(operator_type, operator_parameters); + m_OpenPMDoptions = detail::getSeriesOptions(operator_type, operator_parameters, + engine_type, engine_parameters); } WarpXOpenPMDPlot::~WarpXOpenPMDPlot () |