mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-16 12:54:50 +01:00
Merge branch 'refac/hd5' into 'main'
Draft: hdf5_init See merge request naaice/poet!52
This commit is contained in:
commit
e8c92d2a88
@ -1,8 +1,27 @@
|
|||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
cli11
|
||||||
|
QUIET
|
||||||
|
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
|
||||||
|
GIT_TAG v2.4.2
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
highfive
|
||||||
|
QUIET
|
||||||
|
GIT_REPOSITORY https://github.com/highfive-devs/highfive.git
|
||||||
|
GIT_TAG v3.0.0
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(cli11)
|
||||||
|
FetchContent_MakeAvailable(highfive)
|
||||||
|
|
||||||
add_library(POETLib
|
add_library(POETLib
|
||||||
Init/InitialList.cpp
|
Init/InitialList.cpp
|
||||||
Init/GridInit.cpp
|
Init/GridInit.cpp
|
||||||
Init/DiffusionInit.cpp
|
Init/DiffusionInit.cpp
|
||||||
Init/ChemistryInit.cpp
|
Init/ChemistryInit.cpp
|
||||||
|
IO/checkpoint.cpp
|
||||||
DataStructures/Field.cpp
|
DataStructures/Field.cpp
|
||||||
Transport/DiffusionModule.cpp
|
Transport/DiffusionModule.cpp
|
||||||
Chemistry/ChemistryModule.cpp
|
Chemistry/ChemistryModule.cpp
|
||||||
@ -30,18 +49,10 @@ target_link_libraries(
|
|||||||
PUBLIC RRuntime
|
PUBLIC RRuntime
|
||||||
PUBLIC IPhreeqcPOET
|
PUBLIC IPhreeqcPOET
|
||||||
PUBLIC tug
|
PUBLIC tug
|
||||||
PUBLIC MPI::MPI_C
|
PUBLIC MPI::MPI_C
|
||||||
|
PUBLIC HighFive::HighFive
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
cli11
|
|
||||||
QUIET
|
|
||||||
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
|
|
||||||
GIT_TAG v2.4.2
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_MakeAvailable(cli11)
|
|
||||||
|
|
||||||
# add_library(poetlib
|
# add_library(poetlib
|
||||||
# Base/Grid.cpp
|
# Base/Grid.cpp
|
||||||
|
|||||||
9
src/IO/Datatypes.hpp
Normal file
9
src/IO/Datatypes.hpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <DataStructures/Field.hpp>
|
||||||
|
|
||||||
|
struct Checkpoint_s {
|
||||||
|
poet::Field &field;
|
||||||
|
uint32_t iteration;
|
||||||
|
};
|
||||||
8
src/IO/HDF5Functions.hpp
Normal file
8
src/IO/HDF5Functions.hpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "Datatypes.hpp"
|
||||||
|
|
||||||
|
int write_checkpoint(const std::string &file_path, struct Checkpoint_s &&checkpoint);
|
||||||
|
|
||||||
|
int read_checkpoint(const std::string &file_path, struct Checkpoint_s &checkpoint);
|
||||||
28
src/IO/checkpoint.cpp
Normal file
28
src/IO/checkpoint.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "IO/Datatypes.hpp"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <highfive/H5Easy.hpp>
|
||||||
|
|
||||||
|
int write_checkpoint(const std::string &file_path, struct Checkpoint_s &&checkpoint){
|
||||||
|
|
||||||
|
// TODO: errorhandling
|
||||||
|
H5Easy::File file(file_path, H5Easy::File::Overwrite);
|
||||||
|
|
||||||
|
|
||||||
|
H5Easy::dump(file, "/MetaParam/Iterations", checkpoint.iteration);
|
||||||
|
H5Easy::dump(file, "/Grid/Names", checkpoint.field.GetProps());
|
||||||
|
H5Easy::dump(file, "/Grid/Chemistry", checkpoint.field.As2DVector());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int read_checkpoint(const std::string &file_path, struct Checkpoint_s &checkpoint){
|
||||||
|
|
||||||
|
H5Easy::File file(file_path, H5Easy::File::ReadOnly);
|
||||||
|
|
||||||
|
checkpoint.iteration = H5Easy::load<uint32_t>(file, "/MetaParam/Iterations");
|
||||||
|
|
||||||
|
checkpoint.field = H5Easy::load<std::vector<std::vector<double>>>(file, "/Grid/Chemistry");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
14
src/poet.cpp
14
src/poet.cpp
@ -26,6 +26,8 @@
|
|||||||
#include "CLI/CLI.hpp"
|
#include "CLI/CLI.hpp"
|
||||||
#include "Chemistry/ChemistryModule.hpp"
|
#include "Chemistry/ChemistryModule.hpp"
|
||||||
#include "DataStructures/Field.hpp"
|
#include "DataStructures/Field.hpp"
|
||||||
|
#include "IO/Datatypes.hpp"
|
||||||
|
#include "IO/HDF5Functions.hpp"
|
||||||
#include "Init/InitialList.hpp"
|
#include "Init/InitialList.hpp"
|
||||||
#include "Transport/DiffusionModule.hpp"
|
#include "Transport/DiffusionModule.hpp"
|
||||||
|
|
||||||
@ -393,6 +395,18 @@ static Rcpp::List RunMasterLoop(RInsidePOET &R, const RuntimeParameters ¶ms,
|
|||||||
// store_result is TRUE)
|
// store_result is TRUE)
|
||||||
call_master_iter_end(R, diffusion.getField(), chem.getField());
|
call_master_iter_end(R, diffusion.getField(), chem.getField());
|
||||||
|
|
||||||
|
// TODO: write checkpoint
|
||||||
|
// checkpoint struct --> field and iteration
|
||||||
|
|
||||||
|
if (iter == 1) {
|
||||||
|
write_checkpoint("checkpoint1.hdf5",
|
||||||
|
{.field = chem.getField(), .iteration = iter});
|
||||||
|
} else if (iter == 2) {
|
||||||
|
Checkpoint_s checkpoint_read{.field = chem.getField()};
|
||||||
|
read_checkpoint("checkpoint1.hdf5", checkpoint_read);
|
||||||
|
iter = checkpoint_read.iteration;
|
||||||
|
}
|
||||||
|
|
||||||
diffusion.getField().update(chem.getField());
|
diffusion.getField().update(chem.getField());
|
||||||
|
|
||||||
MSG("End of *coupling* iteration " + std::to_string(iter) + "/" +
|
MSG("End of *coupling* iteration " + std::to_string(iter) + "/" +
|
||||||
|
|||||||
39
struct_init.org
Normal file
39
struct_init.org
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
Grid/MemoryOrder (single integer 0=zyx (colmaj); 1=xyz (rowmaj))
|
||||||
|
Grid/Dimensionality (single integer)
|
||||||
|
Grid/Cells (uint32_t length=Grid/Dimensionality)
|
||||||
|
Grid/Size (double length=Grid/Dimensionality)
|
||||||
|
Grid/ConstantCells (uint32_t array)
|
||||||
|
Grid/Porosity/Length (int 1 (=homog))
|
||||||
|
(int prod(Grid/Cells))
|
||||||
|
Grid/Porosity/Data (double length=Grid/Porosity/Length)
|
||||||
|
|
||||||
|
PhreeqcMatrix/Names (string vector)
|
||||||
|
PhreeqcMatrix/Data (double Matrix length(Names)*NumberOfPQC_IDs)
|
||||||
|
|
||||||
|
InitialConditions/Names (vector of string (=colnames PhreeqcMatrix))
|
||||||
|
InitialConditions/Data (vector (length Names) of arrays (double length=prod(Cells)))
|
||||||
|
|
||||||
|
Diffusion/Names (string vector) transported solutes
|
||||||
|
Diffusion/Boundaries/N int matrix N*3=(ind_bound, type, phreeqc_id)
|
||||||
|
Diffusion/Boundaries/W ''
|
||||||
|
Diffusion/Boundaries/S ''
|
||||||
|
Diffusion/Boundaries/E ''
|
||||||
|
Diffusion/Boundaries/T ''
|
||||||
|
Diffusion/Boundaries/B ''
|
||||||
|
|
||||||
|
Diffusion/InnerBoundaries placeholder
|
||||||
|
Diffusion/Alpha
|
||||||
|
Diffusion/Alpha/x (double length=1 (=homog))
|
||||||
|
(double length=prod(Grid/Cells))
|
||||||
|
Diffusion/Alpha/y
|
||||||
|
Diffusion/Alpha/z
|
||||||
|
|
||||||
|
Chemistry
|
||||||
|
Chemistry/Database (string)
|
||||||
|
Chemistry/Input (string)
|
||||||
|
Chemistry/PhreeqcIDs (int vector)
|
||||||
|
Chemistry/Options
|
||||||
|
Chemistry/Options/H0O0 (bool)
|
||||||
|
Chemistry/Options/WithRedox (bool)
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user