Commit bd927f06 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

first postprocessing class seems to work

incidentally, it looks like the binary reader is working.
parent edc9be7b
Pipeline #12950 passed with stage
in 6 minutes and 3 seconds
This diff is collapsed.
......@@ -29,6 +29,7 @@ import argparse
import bfps
from .DNS import DNS
from .PP import PP
from .NavierStokes import NavierStokes
from .NSVorticityEquation import NSVorticityEquation
from .FluidResize import FluidResize
......@@ -65,7 +66,7 @@ def main():
'NSManyParticles-double']
parser.add_argument(
'base_class',
choices = ['DNS'] +
choices = ['DNS', 'PP'] +
NSoptions +
NSVEoptions +
FRoptions +
......@@ -81,6 +82,10 @@ def main():
c = DNS()
c.launch(args = sys.argv[2:])
return None
if opt.base_class == 'PP':
c = PP()
c.launch(args = sys.argv[2:])
return None
if 'double' in opt.base_class:
precision = 'double'
else:
......
......@@ -249,6 +249,8 @@ class _code(_base):
assert(self.compile_code() == 0)
if self.work_dir != os.path.realpath(os.getcwd()):
shutil.copy(self.name, self.work_dir)
if 'niter_todo' not in self.parameters.keys():
self.parameters['niter_todo'] = 1
current_dir = os.getcwd()
os.chdir(self.work_dir)
os.chdir(current_dir)
......
......@@ -50,6 +50,20 @@ int native_binary_to_hdf5<rnumber>::finalize(void)
return EXIT_SUCCESS;
}
template <typename rnumber>
int native_binary_to_hdf5<rnumber>::read_parameters(void)
{
this->postprocess::read_parameters();
hid_t parameter_file = H5Fopen(
(this->simname + std::string(".h5")).c_str(),
H5F_ACC_RDONLY,
H5P_DEFAULT);
this->iteration_list = hdf5_tools::read_vector<int>(
parameter_file,
"/native_binary_to_hdf5/iteration_list");
return EXIT_SUCCESS;
}
template class native_binary_to_hdf5<float>;
template class native_binary_to_hdf5<double>;
......@@ -26,3 +26,66 @@ int postprocess::main_loop(void)
return EXIT_SUCCESS;
}
int postprocess::read_parameters()
{
hid_t parameter_file;
hid_t dset, memtype, space;
char fname[256];
hsize_t dims[1];
char *string_data;
sprintf(fname, "%s.h5", this->simname.c_str());
parameter_file = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT);
dset = H5Dopen(parameter_file, "/parameters/dealias_type", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->dealias_type);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/dkx", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->dkx);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/dky", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->dky);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/dkz", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->dkz);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/dt", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->dt);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/famplitude", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->famplitude);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/fk0", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->fk0);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/fk1", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->fk1);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/fmode", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->fmode);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/forcing_type", H5P_DEFAULT);
space = H5Dget_space(dset);
memtype = H5Dget_type(dset);
string_data = (char*)malloc(256);
H5Dread(dset, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, &string_data);
sprintf(this->forcing_type, "%s", string_data);
free(string_data);
H5Sclose(space);
H5Tclose(memtype);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/nu", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->nu);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/nx", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->nx);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/ny", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->ny);
H5Dclose(dset);
dset = H5Dopen(parameter_file, "/parameters/nz", H5P_DEFAULT);
H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->nz);
H5Dclose(dset);
H5Fclose(parameter_file);
return 0;
}
......@@ -40,6 +40,15 @@ class postprocess: public code_base
std::vector<int> iteration_list;
hid_t stat_file;
/* parameters that are read in read_parameters */
double dt;
double famplitude;
double fk0;
double fk1;
int fmode;
char forcing_type[512];
double nu;
postprocess(
const MPI_Comm COMMUNICATOR,
const std::string &simulation_name):
......@@ -53,6 +62,7 @@ class postprocess: public code_base
virtual int finalize(void) = 0;
int main_loop(void);
virtual int read_parameters(void);
};
#endif//POSTPROCESS_HPP
......
......@@ -111,32 +111,29 @@ std::vector<dtype> hdf5_tools::read_vector_with_single_rank(
return data;
}
namespace hdf5_tools
{
template <>
std::vector<int> read_vector(
template
std::vector<int> hdf5_tools::read_vector<int>(
const hid_t,
const std::string);
template <>
std::vector<double> read_vector(
template
std::vector<double> hdf5_tools::read_vector<double>(
const hid_t,
const std::string);
template <>
std::vector<int> read_vector_with_single_rank(
template
std::vector<int> hdf5_tools::read_vector_with_single_rank<int>(
const int myrank,
const int rank_to_use,
const MPI_Comm COMM,
const hid_t file_id,
const std::string dset_name);
template <>
std::vector<double> read_vector_with_single_rank(
template
std::vector<double> hdf5_tools::read_vector_with_single_rank<double>(
const int myrank,
const int rank_to_use,
const MPI_Comm COMM,
const hid_t file_id,
const std::string dset_name);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment