diff --git a/bfps/DNS.py b/bfps/DNS.py index c7d77956d1364ea9e743c93da83e4c4151e1006a..e6ef006ad5b8251dd7bc893512f240aeb70714ca 100644 --- a/bfps/DNS.py +++ b/bfps/DNS.py @@ -116,26 +116,6 @@ class DNS(_code): with open(self.name + '.cpp', 'w') as outfile: outfile.write(self.version_message + '\n\n') outfile.write(self.includes + '\n\n') - outfile.write( - self.cread_pars( - template_class = '{0}<rnumber>::'.format(self.dns_type), - template_prefix = 'template <typename rnumber> ', - simname_variable = 'this->simname.c_str()', - prepend_this = True) + - '\n\n') - for rnumber in ['float', 'double']: - outfile.write(self.cread_pars( - template_class = '{0}<{1}>::'.format(self.dns_type, rnumber), - template_prefix = 'template '.format(rnumber), - just_declaration = True) + '\n\n') - if self.dns_type in ['NSVEparticles', 'NSVE_no_output', 'NSVEparticles_no_output', 'NSVEcomplex_particles', 'NSVEp_extra_sampling']: - outfile.write('template <typename rnumber> int NSVE<rnumber>::read_parameters(){return EXIT_SUCCESS;}\n') - outfile.write('template int NSVE<float>::read_parameters();\n') - outfile.write('template int NSVE<double>::read_parameters();\n\n') - if self.dns_type in ['NSVEparticles_no_output', 'NSVEp_extra_sampling']: - outfile.write('template <typename rnumber> int NSVEparticles<rnumber>::read_parameters(){return EXIT_SUCCESS;}\n') - outfile.write('template int NSVEparticles<float>::read_parameters();\n') - outfile.write('template int NSVEparticles<double>::read_parameters();\n\n') outfile.write(self.main + '\n') return None def generate_default_parameters(self): diff --git a/bfps/cpp/full_code/NSVE.cpp b/bfps/cpp/full_code/NSVE.cpp index e8bf9fd2e9786bd5df8a4c9d7dc9b37e15de85c1..ce0a95442957c77e80980f34fc8622e3cf60811b 100644 --- a/bfps/cpp/full_code/NSVE.cpp +++ b/bfps/cpp/full_code/NSVE.cpp @@ -137,6 +137,28 @@ int NSVE<rnumber>::do_stats() return EXIT_SUCCESS; } +template <typename rnumber> +int NSVE<rnumber>::read_parameters(void) +{ + this->direct_numerical_simulation::read_parameters(); + hid_t parameter_file = H5Fopen((this->simname + ".h5").c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); + this->nu = hdf5_tools::read_value<double>(parameter_file, "parameters/nu"); + this->dt = hdf5_tools::read_value<double>(parameter_file, "parameters/dt"); + this->fmode = hdf5_tools::read_value<int>(parameter_file, "parameters/fmode"); + this->famplitude = hdf5_tools::read_value<double>(parameter_file, "parameters/famplitude"); + this->friction_coefficient = hdf5_tools::read_value<double>(parameter_file, "parameters/friction_coefficient"); + 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->histogram_bins = hdf5_tools::read_value<int>(parameter_file, "parameters/histogram_bins"); + this->max_velocity_estimate = hdf5_tools::read_value<double>(parameter_file, "parameters/max_velocity_estimate"); + this->max_vorticity_estimate = hdf5_tools::read_value<double>(parameter_file, "parameters/max_vorticity_estimate"); + 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 class NSVE<float>; template class NSVE<double>; diff --git a/bfps/cpp/full_code/NSVEparticles.cpp b/bfps/cpp/full_code/NSVEparticles.cpp index bbdd96c36f05eb1b8dd755dfc59c9f2a1f98d49d..78f3d6a02099ba3525187b333a7b4862190ec638 100644 --- a/bfps/cpp/full_code/NSVEparticles.cpp +++ b/bfps/cpp/full_code/NSVEparticles.cpp @@ -142,6 +142,20 @@ int NSVEparticles<rnumber>::do_stats() return EXIT_SUCCESS; } +template <typename rnumber> +int NSVEparticles<rnumber>::read_parameters(void) +{ + this->NSVE<rnumber>::read_parameters(); + hid_t parameter_file = H5Fopen((this->simname + ".h5").c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); + this->niter_part = hdf5_tools::read_value<int>(parameter_file, "parameters/niter_part"); + this->nparticles = hdf5_tools::read_value<int>(parameter_file, "parameters/nparticles"); + this->tracers0_integration_steps = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_integration_steps"); + this->tracers0_neighbours = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_neighbours"); + this->tracers0_smoothness = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_smoothness"); + H5Fclose(parameter_file); + return EXIT_SUCCESS; +} + template class NSVEparticles<float>; template class NSVEparticles<double>; diff --git a/bfps/cpp/full_code/code_base.cpp b/bfps/cpp/full_code/code_base.cpp index 1b06fe8e66a4180034b9f6a494a1a432ae5ea3f9..32fe9c1cf749ad124296ddf759da4014c7243c3b 100644 --- a/bfps/cpp/full_code/code_base.cpp +++ b/bfps/cpp/full_code/code_base.cpp @@ -34,3 +34,17 @@ int code_base::check_stopping_condition(void) return EXIT_SUCCESS; } +int code_base::read_parameters(void) +{ + hid_t parameter_file = H5Fopen((this->simname + ".h5").c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); + this->dkx = hdf5_tools::read_value<double>(parameter_file, "parameters/dkx"); + this->dky = hdf5_tools::read_value<double>(parameter_file, "parameters/dky"); + this->dkz = hdf5_tools::read_value<double>(parameter_file, "parameters/dkz"); + this->nx = hdf5_tools::read_value<int>(parameter_file, "parameters/nx"); + this->ny = hdf5_tools::read_value<int>(parameter_file, "parameters/ny"); + this->nz = hdf5_tools::read_value<int>(parameter_file, "parameters/nz"); + this->dealias_type = hdf5_tools::read_value<int>(parameter_file, "parameters/dealias_type"); + H5Fclose(parameter_file); + return EXIT_SUCCESS; +} + diff --git a/bfps/cpp/full_code/code_base.hpp b/bfps/cpp/full_code/code_base.hpp index cf0521e2b7383edf925e1129d4fa4a931a55efe4..5ec4260dbfbaaa8ea4e123d8a38b680c0df121eb 100644 --- a/bfps/cpp/full_code/code_base.hpp +++ b/bfps/cpp/full_code/code_base.hpp @@ -108,6 +108,7 @@ class code_base return EXIT_SUCCESS; } + virtual int read_parameters(void); virtual int initialize(void) = 0; virtual int main_loop(void) = 0; virtual int finalize(void) = 0; diff --git a/bfps/cpp/full_code/direct_numerical_simulation.cpp b/bfps/cpp/full_code/direct_numerical_simulation.cpp index edc2f99497a21368c63348167190dc6c64b44712..f763cde96b0979a7dc9205665378e6fe451233bb 100644 --- a/bfps/cpp/full_code/direct_numerical_simulation.cpp +++ b/bfps/cpp/full_code/direct_numerical_simulation.cpp @@ -117,3 +117,14 @@ int direct_numerical_simulation::main_loop(void) return EXIT_SUCCESS; } +int direct_numerical_simulation::read_parameters(void) +{ + this->code_base::read_parameters(); + hid_t parameter_file = H5Fopen((this->simname + ".h5").c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); + this->checkpoints_per_file = hdf5_tools::read_value<int>(parameter_file, "parameters/checkpoints_per_file"); + this->niter_out = hdf5_tools::read_value<int>(parameter_file, "parameters/niter_out"); + this->niter_stat = hdf5_tools::read_value<int>(parameter_file, "parameters/niter_stat"); + this->niter_todo = hdf5_tools::read_value<int>(parameter_file, "parameters/niter_todo"); + H5Fclose(parameter_file); + return EXIT_SUCCESS; +} diff --git a/bfps/cpp/full_code/direct_numerical_simulation.hpp b/bfps/cpp/full_code/direct_numerical_simulation.hpp index 8050bb045b29acf29d655273f7dff310dd10d0fa..15ab698a1128fd836b74b100b9a79d5c6d67d12f 100644 --- a/bfps/cpp/full_code/direct_numerical_simulation.hpp +++ b/bfps/cpp/full_code/direct_numerical_simulation.hpp @@ -51,6 +51,7 @@ class direct_numerical_simulation: public code_base simulation_name){} virtual ~direct_numerical_simulation(){} + virtual int read_parameters(void); virtual int write_checkpoint(void) = 0; virtual int initialize(void) = 0; virtual int step(void) = 0; diff --git a/setup.py b/setup.py index 7889c927cb10d0eb66d14bc422d4ba4d8436d5e8..b427ebe77ab86ec8be96b3a751a97600c629df53 100644 --- a/setup.py +++ b/setup.py @@ -88,40 +88,29 @@ print('This is bfps version ' + VERSION) ### lists of files and MANIFEST.in -src_file_list = ['full_code/NSVEcomplex_particles', +src_file_list = [ + 'full_code/code_base', + 'full_code/direct_numerical_simulation', + 'full_code/NSVE', 'full_code/joint_acc_vel_stats', 'full_code/test', 'full_code/filter_test', 'full_code/field_test', 'full_code/symmetrize_test', 'full_code/field_output_test', - 'full_code/test_interpolation', - 'hdf5_tools', 'full_code/get_rfields', 'full_code/field_single_to_double', 'full_code/resize', 'full_code/NSVE_field_stats', 'full_code/native_binary_to_hdf5', 'full_code/postprocess', - 'full_code/code_base', - 'full_code/direct_numerical_simulation', - 'full_code/NSVE', - 'field_binary_IO', - 'vorticity_equation', 'field', 'kspace', 'field_layout', - 'field_descriptor', - 'rFFTW_distributed_particles', - 'distributed_particles', - 'particles', - 'particles_base', - 'rFFTW_interpolator', - 'interpolator', - 'interpolator_base', - 'fluid_solver', - 'fluid_solver_base', + 'hdf5_tools', 'fftw_tools', + 'vorticity_equation', + 'field_binary_IO', 'spline_n1', 'spline_n2', 'spline_n3', @@ -134,7 +123,11 @@ src_file_list = ['full_code/NSVEcomplex_particles', 'spline_n10', 'Lagrange_polys', 'scope_timer', + 'interpolator', + 'interpolator_base', + 'full_code/test_interpolation', 'full_code/NSVEparticles', + 'full_code/NSVEcomplex_particles', 'full_code/NSVEp_extra_sampling'] particle_headers = [