diff --git a/res/cmake/dep/cppdict.cmake b/res/cmake/dep/cppdict.cmake index 44b5fdedc..87173652c 100644 --- a/res/cmake/dep/cppdict.cmake +++ b/res/cmake/dep/cppdict.cmake @@ -1,6 +1,9 @@ -set(CPPDICT_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/cppdict) -set(CPPDICT_VERSION master) -phare_github_get_or_update(cppdict ${CPPDICT_SRCDIR} LaboratoryOfPlasmaPhysics/cppdict ${CPPDICT_VERSION}) +if(NOT DEFINED PHARE_CPPDICT_VERION) + SET(PHARE_CPPDICT_VERION "superserial") +endif() +set(CPPDICT_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/cppdict) +# phare_github_get_or_update(cppdict ${CPPDICT_SRCDIR} LaboratoryOfPlasmaPhysics/cppdict ${PHARE_CPPDICT_VERION}) +phare_github_get_or_update(cppdict ${CPPDICT_SRCDIR} PhilipDeegan/cppdict ${PHARE_CPPDICT_VERION}) diff --git a/res/cmake/dep/highfive.cmake b/res/cmake/dep/highfive.cmake index b74081c68..3bb5164df 100644 --- a/res/cmake/dep/highfive.cmake +++ b/res/cmake/dep/highfive.cmake @@ -3,10 +3,13 @@ set (PHARE_HAS_HIGHFIVE "0") if(HighFive) + if(NOT DEFINED PHARE_HIGHFIVE_VERSION) + SET(PHARE_HIGHFIVE_VERSION "master") + endif() + set (HIGHFIVE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/highfive) - set (HIGHFIVE_VERSION master) - phare_github_get_or_update(HighFive ${HIGHFIVE_SRC} BlueBrain/HighFive ${HIGHFIVE_VERSION}) + phare_github_get_or_update(HighFive ${HIGHFIVE_SRC} BlueBrain/HighFive ${PHARE_HIGHFIVE_VERSION}) include_directories( ${HIGHFIVE_SRC}/include diff --git a/res/cmake/dep/pybind.cmake b/res/cmake/dep/pybind.cmake index fb2e90135..b74ab9ac4 100644 --- a/res/cmake/dep/pybind.cmake +++ b/res/cmake/dep/pybind.cmake @@ -9,6 +9,10 @@ function(get_pybind) set (PHARE_FLAGS ${PHARE_FLAGS} -fsized-deallocation) endif() + if(NOT DEFINED PHARE_PYBIND11_VERSION) + SET(PHARE_PYBIND11_VERSION "master") + endif() + message("downloading subproject pybind11") set(PYBIND11_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/pybind11) set(PYBIND11_VERSION master) diff --git a/res/cmake/dep/samrai.cmake b/res/cmake/dep/samrai.cmake index d4cc3354f..d90f2a86b 100644 --- a/res/cmake/dep/samrai.cmake +++ b/res/cmake/dep/samrai.cmake @@ -10,11 +10,15 @@ if (NOT SAMRAI_FOUND) if(DEFINED SAMRAI_ROOT) find_package(SAMRAI PATHS ${SAMRAI_ROOT} REQUIRED) else() - set(SAMRAI_VERSION develop) + + if(NOT DEFINED PHARE_SAMRAI_VERSION) + SET(PHARE_SAMRAI_VERSION "develop") + endif() + set(SAMRAI_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/samrai) set(SAMRAI_BIN ${CMAKE_CURRENT_BINARY_DIR}/subprojects/samrai) - phare_github_get_or_update(SAMRAI ${SAMRAI_SRCDIR} LLNL/SAMRAI ${SAMRAI_VERSION}) + phare_github_get_or_update(SAMRAI ${SAMRAI_SRCDIR} LLNL/SAMRAI ${PHARE_SAMRAI_VERSION}) if (NOT CMAKE_BUILD_TYPE STREQUAL "Release") # enable samrai assertions if not in release mode diff --git a/res/cmake/release.cmake b/res/cmake/release.cmake new file mode 100644 index 000000000..a479f4174 --- /dev/null +++ b/res/cmake/release.cmake @@ -0,0 +1,12 @@ + +# https://github.com/LLNL/SAMRAI/releases/tag/v-4-3-0 +SET(PHARE_SAMRAI_VERSION "v4.3.0") + +# https://github.com/pybind/pybind11/releases/tag/v2.13.6 +SET(PHARE_PYBIND11_VERSION "v2.13.6") + +# https://github.com/BlueBrain/HighFive/releases/tag/v2.10.0 +SET(PHARE_HIGHFIVE_VERSION "v2.10.0") + +# https://github.com/LaboratoryOfPlasmaPhysics/cppdict/releases/tag/v1.0.0 +SET(PHARE_CPPDICT_VERION "v1.0.0") diff --git a/src/initializer/data_provider.hpp b/src/initializer/data_provider.hpp index c48f31a6e..91fe976ac 100644 --- a/src/initializer/data_provider.hpp +++ b/src/initializer/data_provider.hpp @@ -11,6 +11,8 @@ #include "core/def.hpp" #include "core/utilities/span.hpp" +#include "cppdict/include/dict/exp/serializer.hpp" + namespace PHARE { namespace initializer @@ -52,6 +54,25 @@ namespace initializer std::size_t, std::optional, std::string, InitFunction<1>, InitFunction<2>, InitFunction<3>>; + void inline dump_phare_dict(PHAREDict const& dict, std::string const& filename) + { + using Serializer + = cppdict::DictSerializer, double, std::vector, + std::size_t, std::optional, std::string, + InitFunction<1>, InitFunction<2>, InitFunction<3>>; + + Serializer{filename}(dict); + } + + auto inline load_phare_dict(std::string const& filename) + { + using Deserializer + = cppdict::DictDeSerializer, double, std::vector, + std::size_t, std::optional, std::string, + InitFunction<1>, InitFunction<2>, InitFunction<3>>; + return Deserializer{filename}(); + } + class PHAREDictHandler { @@ -69,6 +90,14 @@ namespace initializer return *phareDict; } + void dump(std::string const& filename) const { dump_phare_dict(*phareDict, filename); } + + static auto& load(std::string const& filename) + { + INSTANCE().phareDict = std::make_unique(); // reset + return (*INSTANCE().phareDict = load_phare_dict(filename)); // ? + } + private: PHAREDictHandler() = default; std::unique_ptr phareDict; diff --git a/tests/initializer/phare_dict.cpp b/tests/initializer/phare_dict.cpp new file mode 100644 index 000000000..24928e3c4 --- /dev/null +++ b/tests/initializer/phare_dict.cpp @@ -0,0 +1,112 @@ + +#include "phare_core.hpp" + +#include "core/numerics/ion_updater/ion_updater.hpp" +#include "tests/core/data/vecfield/test_vecfield_fixtures.hpp" +#include "tests/core/data/tensorfield/test_tensorfield_fixtures.hpp" +#include "tests/initializer/init_functions.hpp" + +using namespace PHARE::initializer::test_fn::func_1d; +using InitFunctionT = PHARE::initializer::InitFunction<1>; + +PHARE::initializer::PHAREDict createDict() +{ + PHARE::initializer::PHAREDict dict; + dict["ions"]["nbrPopulations"] = std::size_t{2}; + dict["ions"]["pop0"]["name"] = std::string{"protons"}; + dict["ions"]["pop0"]["mass"] = 1.; + dict["ions"]["pop0"]["particle_initializer"]["name"] + = std::string{"MaxwellianParticleInitializer"}; + dict["ions"]["pop0"]["particle_initializer"]["density"] = static_cast(density); + + dict["ions"]["pop0"]["particle_initializer"]["bulk_velocity_x"] + = static_cast(vx); + + dict["ions"]["pop0"]["particle_initializer"]["bulk_velocity_y"] + = static_cast(vy); + + dict["ions"]["pop0"]["particle_initializer"]["bulk_velocity_z"] + = static_cast(vz); + + + dict["ions"]["pop0"]["particle_initializer"]["thermal_velocity_x"] + = static_cast(vthx); + + dict["ions"]["pop0"]["particle_initializer"]["thermal_velocity_y"] + = static_cast(vthy); + + dict["ions"]["pop0"]["particle_initializer"]["thermal_velocity_z"] + = static_cast(vthz); + + + dict["ions"]["pop0"]["particle_initializer"]["nbrPartPerCell"] = int{100}; + dict["ions"]["pop0"]["particle_initializer"]["charge"] = -1.; + dict["ions"]["pop0"]["particle_initializer"]["basis"] = std::string{"Cartesian"}; + + dict["ions"]["pop1"]["name"] = std::string{"alpha"}; + dict["ions"]["pop1"]["mass"] = 1.; + dict["ions"]["pop1"]["particle_initializer"]["name"] + = std::string{"MaxwellianParticleInitializer"}; + dict["ions"]["pop1"]["particle_initializer"]["density"] = static_cast(density); + + dict["ions"]["pop1"]["particle_initializer"]["bulk_velocity_x"] + = static_cast(vx); + + dict["ions"]["pop1"]["particle_initializer"]["bulk_velocity_y"] + = static_cast(vy); + + dict["ions"]["pop1"]["particle_initializer"]["bulk_velocity_z"] + = static_cast(vz); + + + dict["ions"]["pop1"]["particle_initializer"]["thermal_velocity_x"] + = static_cast(vthx); + + dict["ions"]["pop1"]["particle_initializer"]["thermal_velocity_y"] + = static_cast(vthy); + + dict["ions"]["pop1"]["particle_initializer"]["thermal_velocity_z"] + = static_cast(vthz); + + + dict["ions"]["pop1"]["particle_initializer"]["nbrPartPerCell"] = int{100}; + dict["ions"]["pop1"]["particle_initializer"]["charge"] = -1.; + dict["ions"]["pop1"]["particle_initializer"]["basis"] = std::string{"Cartesian"}; + + dict["electromag"]["name"] = std::string{"EM"}; + dict["electromag"]["electric"]["name"] = std::string{"E"}; + dict["electromag"]["magnetic"]["name"] = std::string{"B"}; + + dict["electromag"]["magnetic"]["initializer"]["x_component"] = static_cast(bx); + dict["electromag"]["magnetic"]["initializer"]["y_component"] = static_cast(by); + dict["electromag"]["magnetic"]["initializer"]["z_component"] = static_cast(bz); + + dict["electrons"]["pressure_closure"]["name"] = std::string{"isothermal"}; + dict["electrons"]["pressure_closure"]["Te"] = 0.12; + + return dict; +} + + + +int main(int argc, char** argv) +{ + std::string const filename = "pharedict.dat"; + PHARE::initializer::dump_phare_dict(createDict(), filename); + // auto const dict = PHARE::initializer::load_phare_dict(filename); + + auto const dict = PHARE::initializer::PHAREDictHandler::load(filename); + + int r = 0; + + r += dict["ions"]["nbrPopulations"].to() != 2; + + r += dict["ions"]["pop0"]["particle_initializer"]["nbrPartPerCell"].to() != 100; + r += dict["ions"]["pop1"]["particle_initializer"]["nbrPartPerCell"].to() != 100; + + r += dict["electromag"]["magnetic"]["initializer"]["x_component"].isValue(); // NOT SERIALIZABLE + + r += dict["electrons"]["pressure_closure"]["Te"].to() != 0.12; + + return r; +}