diff --git a/cpp/full_code/joint_acc_vel_stats.cpp b/cpp/full_code/joint_acc_vel_stats.cpp index 238047556b5845dde8e8bf4d0310c936c0046366..6c6708190bd87b5fd7442587eeb3bf448782a328 100644 --- a/cpp/full_code/joint_acc_vel_stats.cpp +++ b/cpp/full_code/joint_acc_vel_stats.cpp @@ -45,6 +45,7 @@ int joint_acc_vel_stats<rnumber>::initialize(void) this->dky, this->dkz, this->vorticity->fftw_plan_rigor); + this->template copy_parameters_into<rnumber, FFTW>(this->ve); hid_t parameter_file = H5Fopen( (this->simname + std::string(".h5")).c_str(), H5F_ACC_RDONLY, diff --git a/cpp/full_code/postprocess.cpp b/cpp/full_code/postprocess.cpp index e8c7fb279821fff0e3fd82c85b1c490a0b6a68e7..a6bbe18bf2024afa15814883ff1a1ba93c53f0c9 100644 --- a/cpp/full_code/postprocess.cpp +++ b/cpp/full_code/postprocess.cpp @@ -70,9 +70,33 @@ int postprocess::read_parameters() this->fk0 = hdf5_tools::read_value<double>(parameter_file, "parameters/fk0"); this->fk1 = hdf5_tools::read_value<double>(parameter_file, "parameters/fk1"); this->energy = hdf5_tools::read_value<double>(parameter_file, "parameters/energy"); + this->injection_rate = hdf5_tools::read_value<double>(parameter_file, "parameters/injection_rate"); std::string tmp = hdf5_tools::read_string(parameter_file, "parameters/forcing_type"); snprintf(this->forcing_type, 511, "%s", tmp.c_str()); H5Fclose(parameter_file); return EXIT_SUCCESS; } +template <typename rnumber, + field_backend be> +int postprocess::copy_parameters_into( + vorticity_equation<rnumber, be> *dst) +{ + dst->nu = this->nu; + dst->fmode = this->fmode; + dst->famplitude = this->famplitude; + dst->fk0 = this->fk0; + dst->fk1 = this->fk1; + dst->injection_rate = this->injection_rate; + dst->energy = this->energy; + dst->friction_coefficient = this->friction_coefficient; + strncpy(this->forcing_type, dst->forcing_type, 128); + return EXIT_SUCCESS; +} + +template int postprocess::copy_parameters_into<float, FFTW>( + vorticity_equation<float, FFTW> *dst); + +template int postprocess::copy_parameters_into<double, FFTW>( + vorticity_equation<double, FFTW> *dst); + diff --git a/cpp/full_code/postprocess.hpp b/cpp/full_code/postprocess.hpp index 65e6eadd1fd05615eb69cb7d8ca1754abd1b7e42..25e023b841425063a5c693827377eb6f85ebfe5b 100644 --- a/cpp/full_code/postprocess.hpp +++ b/cpp/full_code/postprocess.hpp @@ -32,6 +32,7 @@ #include <sys/stat.h> #include <vector> #include "base.hpp" +#include "vorticity_equation.hpp" #include "full_code/code_base.hpp" class postprocess: public code_base @@ -40,13 +41,18 @@ class postprocess: public code_base std::vector<int> iteration_list; hid_t stat_file; - /* parameters that are read in read_parameters */ + /* parameters that are read in read_parameters. + * This includes physical parameters, such that children of `postprocess` + * do not need to read them (but they do need to be copied with + * the `copy_parameters_into` method or similar. + * */ double dt; double famplitude; double friction_coefficient; double fk0; double fk1; double energy; + double injection_rate; int fmode; char forcing_type[512]; double nu; @@ -65,6 +71,14 @@ class postprocess: public code_base int main_loop(void); virtual int read_parameters(void); + + /* Method to copy physical simulation parameters into arbitrary + * `vorticity_equation` object (defined by children classes). + * */ + template <typename rnumber, + field_backend be> + int copy_parameters_into( + vorticity_equation<rnumber, be> *dst); }; #endif//POSTPROCESS_HPP