diff --git a/bfps/DNS.py b/bfps/DNS.py index c7d77956d1364ea9e743c93da83e4c4151e1006a..e6ace758a1f6efb240cfa0655cc661a83a1ab6e2 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): @@ -168,6 +148,11 @@ class DNS(_code): self.NSVEp_extra_parameters['tracers0_integration_steps'] = int(4) self.NSVEp_extra_parameters['tracers0_neighbours'] = int(1) self.NSVEp_extra_parameters['tracers0_smoothness'] = int(1) + self.NSVEp_extra_parameters['tracers0_enable_p2p'] = int(0) + self.NSVEp_extra_parameters['tracers0_enable_inner'] = int(0) + self.NSVEp_extra_parameters['tracers0_enable_vorticity_omega'] = int(0) + self.NSVEp_extra_parameters['tracers0_cutoff'] = float(1) + self.NSVEp_extra_parameters['tracers0_inner_v0'] = float(1) #self.extra_parameters = {} #for key in ['NSVE', 'NSVE_no_output', 'NSVEparticles', 'NSVEparticles_no_output', 'NSVEcomplex_particles']: # self.extra_parameters[key] = {} diff --git a/bfps/cpp/full_code/NSVE.cpp b/bfps/cpp/full_code/NSVE.cpp index e8bf9fd2e9786bd5df8a4c9d7dc9b37e15de85c1..d9cb72a220aaf6cb124cb37f827373f9a44b03ac 100644 --- a/bfps/cpp/full_code/NSVE.cpp +++ b/bfps/cpp/full_code/NSVE.cpp @@ -7,6 +7,7 @@ template <typename rnumber> int NSVE<rnumber>::initialize(void) { + TIMEZONE("NSVE::initialize"); this->read_iteration(); this->read_parameters(); if (this->myrank == 0) @@ -67,6 +68,7 @@ int NSVE<rnumber>::initialize(void) template <typename rnumber> int NSVE<rnumber>::step(void) { + TIMEZONE("NSVE::step"); this->fs->step(this->dt); this->iteration = this->fs->iteration; return EXIT_SUCCESS; @@ -75,6 +77,7 @@ int NSVE<rnumber>::step(void) template <typename rnumber> int NSVE<rnumber>::write_checkpoint(void) { + TIMEZONE("NSVE::write_checkpoint"); this->fs->io_checkpoint(false); this->checkpoint = this->fs->checkpoint; this->write_iteration(); @@ -84,6 +87,7 @@ int NSVE<rnumber>::write_checkpoint(void) template <typename rnumber> int NSVE<rnumber>::finalize(void) { + TIMEZONE("NSVE::finalize"); if (this->myrank == 0) H5Fclose(this->stat_file); delete this->fs; @@ -104,6 +108,7 @@ int NSVE<rnumber>::finalize(void) template <typename rnumber> int NSVE<rnumber>::do_stats() { + TIMEZONE("NSVE::do_stats"); if (!(this->iteration % this->niter_stat == 0)) return EXIT_SUCCESS; hid_t stat_group; @@ -137,6 +142,29 @@ int NSVE<rnumber>::do_stats() return EXIT_SUCCESS; } +template <typename rnumber> +int NSVE<rnumber>::read_parameters(void) +{ + TIMEZONE("NSVE::read_parameters"); + 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/NSVE_field_stats.cpp b/bfps/cpp/full_code/NSVE_field_stats.cpp index 7e33acf93644208d292c5d8df66653f4bb7b806f..15980a20141a563be08ad0b28a3190b3e9e1c17c 100644 --- a/bfps/cpp/full_code/NSVE_field_stats.cpp +++ b/bfps/cpp/full_code/NSVE_field_stats.cpp @@ -7,6 +7,7 @@ template <typename rnumber> int NSVE_field_stats<rnumber>::initialize(void) { + TIMEZONE("NSVE_field_stats::initialize"); this->postprocess::read_parameters(); this->vorticity = new field<rnumber, FFTW, THREE>( nx, ny, nz, @@ -49,6 +50,7 @@ int NSVE_field_stats<rnumber>::initialize(void) template <typename rnumber> int NSVE_field_stats<rnumber>::read_current_cvorticity(void) { + TIMEZONE("NSVE_field_stats::read_current_cvorticity"); this->vorticity->real_space_representation = false; if (this->bin_IO != NULL) { @@ -76,6 +78,7 @@ int NSVE_field_stats<rnumber>::read_current_cvorticity(void) template <typename rnumber> int NSVE_field_stats<rnumber>::finalize(void) { + TIMEZONE("NSVE_field_stats::finalize"); if (this->bin_IO != NULL) delete this->bin_IO; delete this->vorticity; @@ -85,6 +88,7 @@ int NSVE_field_stats<rnumber>::finalize(void) template <typename rnumber> int NSVE_field_stats<rnumber>::work_on_current_iteration(void) { + TIMEZONE("NSVE_field_stats::work_on_current_iteration"); return EXIT_SUCCESS; } diff --git a/bfps/cpp/full_code/NSVE_no_output.hpp b/bfps/cpp/full_code/NSVE_no_output.hpp index 0047a45a02dd58ae8934f78fdd8d804424ae817c..045db08ec74b74206973e0dfbcb30716d62be0de 100644 --- a/bfps/cpp/full_code/NSVE_no_output.hpp +++ b/bfps/cpp/full_code/NSVE_no_output.hpp @@ -1,3 +1,29 @@ +/********************************************************************** +* * +* Copyright 2017 Max Planck Institute * +* for Dynamics and Self-Organization * +* * +* This file is part of bfps. * +* * +* bfps is free software: you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published * +* by the Free Software Foundation, either version 3 of the License, * +* or (at your option) any later version. * +* * +* bfps is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with bfps. If not, see <http://www.gnu.org/licenses/> * +* * +* Contact: Cristian.Lalescu@ds.mpg.de * +* * +**********************************************************************/ + + + #ifndef NSVE_NO_OUTPUT_HPP #define NSVE_NO_OUTPUT_HPP @@ -16,9 +42,9 @@ class NSVE_no_output: public NSVE<rnumber> ~NSVE_no_output(){} int write_checkpoint(void) { - return 0; + TIMEZONE("NSVE_no_output::write_checkpoint"); + return EXIT_SUCCESS; } - int read_parameters(void); }; #endif//NSVE_NO_OUTPUT_HPP diff --git a/bfps/cpp/full_code/NSVEcomplex_particles.cpp b/bfps/cpp/full_code/NSVEcomplex_particles.cpp index 93d0edc17e24925b25513dd3a4832f687255329a..81c6cd5ff37443fb110a0feb46a0858d274d4489 100644 --- a/bfps/cpp/full_code/NSVEcomplex_particles.cpp +++ b/bfps/cpp/full_code/NSVEcomplex_particles.cpp @@ -1,3 +1,29 @@ +/********************************************************************** +* * +* Copyright 2017 Max Planck Institute * +* for Dynamics and Self-Organization * +* * +* This file is part of bfps. * +* * +* bfps is free software: you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published * +* by the Free Software Foundation, either version 3 of the License, * +* or (at your option) any later version. * +* * +* bfps is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with bfps. If not, see <http://www.gnu.org/licenses/> * +* * +* Contact: Cristian.Lalescu@ds.mpg.de * +* * +**********************************************************************/ + + + #include <string> #include <cmath> #include "NSVEcomplex_particles.hpp" @@ -9,6 +35,7 @@ template <typename rnumber> int NSVEcomplex_particles<rnumber>::initialize(void) { + TIMEZONE("NSVEcomplex_particles::initialize"); this->NSVE<rnumber>::initialize(); p2p_computer<double, long long int> current_p2p_computer; @@ -63,6 +90,7 @@ int NSVEcomplex_particles<rnumber>::initialize(void) template <typename rnumber> int NSVEcomplex_particles<rnumber>::step(void) { + TIMEZONE("NSVEcomplex_particles::step"); this->fs->compute_velocity(this->fs->cvorticity); this->fs->cvelocity->ift(); if(enable_vorticity_omega){ @@ -80,6 +108,7 @@ int NSVEcomplex_particles<rnumber>::step(void) template <typename rnumber> int NSVEcomplex_particles<rnumber>::write_checkpoint(void) { + TIMEZONE("NSVEcomplex_particles::write_checkpoint"); this->NSVE<rnumber>::write_checkpoint(); this->particles_output_writer_mpi->open_file(this->fs->get_current_fname()); // TODO P2P write particle data too @@ -96,6 +125,7 @@ int NSVEcomplex_particles<rnumber>::write_checkpoint(void) template <typename rnumber> int NSVEcomplex_particles<rnumber>::finalize(void) { + TIMEZONE("NSVEcomplex_particles::finalize"); delete this->nabla_u; delete this->particles_output_writer_mpi; delete this->particles_sample_writer_mpi; @@ -109,6 +139,7 @@ int NSVEcomplex_particles<rnumber>::finalize(void) template <typename rnumber> int NSVEcomplex_particles<rnumber>::do_stats() { + TIMEZONE("NSVEcomplex_particles::do_stats"); /// perform fluid stats this->NSVE<rnumber>::do_stats(); @@ -184,6 +215,30 @@ int NSVEcomplex_particles<rnumber>::do_stats() this->ps->getLocalNbParticles(), this->ps->get_step_idx()-1); + // deallocate temporary data array + // TODO: is it required/safe to call the release method here? + //pdata.release(); + + return EXIT_SUCCESS; +} + +template <typename rnumber> +int NSVEcomplex_particles<rnumber>::read_parameters(void) +{ + TIMEZONE("NSVEcomplex_particles::read_parameters"); + 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"); + this->enable_p2p = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_enable_p2p"); + this->enable_inner = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_enable_inner"); + this->enable_vorticity_omega = hdf5_tools::read_value<int>(parameter_file, "parameters/tracers0_enable_vorticity_omega"); + this->cutoff = hdf5_tools::read_value<double>(parameter_file, "parameters/tracers0_cutoff"); + this->inner_v0 = hdf5_tools::read_value<double>(parameter_file, "parameters/tracers0_inner_v0"); + H5Fclose(parameter_file); return EXIT_SUCCESS; } diff --git a/bfps/cpp/full_code/NSVEp_extra_sampling.cpp b/bfps/cpp/full_code/NSVEp_extra_sampling.cpp index 3d002d341e26ba547ef4c6ecc47769923e41b8f8..22357510d2683f4a88f4af7a5371d74fdd45043d 100644 --- a/bfps/cpp/full_code/NSVEp_extra_sampling.cpp +++ b/bfps/cpp/full_code/NSVEp_extra_sampling.cpp @@ -5,6 +5,7 @@ template <typename rnumber> int NSVEp_extra_sampling<rnumber>::initialize(void) { + TIMEZONE("NSVEp_extra_sampling::initialize"); this->NSVEparticles<rnumber>::initialize(); /// allocate grad vel field @@ -30,6 +31,7 @@ int NSVEp_extra_sampling<rnumber>::initialize(void) template <typename rnumber> int NSVEp_extra_sampling<rnumber>::finalize(void) { + TIMEZONE("NSVEp_extra_sampling::finalize"); delete this->nabla_u; delete this->pressure; delete this->nabla_p; @@ -41,6 +43,7 @@ int NSVEp_extra_sampling<rnumber>::finalize(void) template <typename rnumber> int NSVEp_extra_sampling<rnumber>::do_stats() { + TIMEZONE("NSVEp_extra_sampling::do_stats"); this->NSVEparticles<rnumber>::do_stats(); if (!(this->iteration % this->niter_part == 0)) return EXIT_SUCCESS; diff --git a/bfps/cpp/full_code/NSVEparticles.cpp b/bfps/cpp/full_code/NSVEparticles.cpp index bbdd96c36f05eb1b8dd755dfc59c9f2a1f98d49d..b09e32805bbfb61469926be9f9d1b259066f9080 100644 --- a/bfps/cpp/full_code/NSVEparticles.cpp +++ b/bfps/cpp/full_code/NSVEparticles.cpp @@ -1,3 +1,6 @@ + + + #include <string> #include <cmath> #include "NSVEparticles.hpp" @@ -6,6 +9,7 @@ template <typename rnumber> int NSVEparticles<rnumber>::initialize(void) { + TIMEZONE("NSVEparticles::intialize"); this->NSVE<rnumber>::initialize(); this->pressure = new field<rnumber, FFTW, ONE>( this->fs->cvelocity->rlayout->sizes[2], @@ -45,6 +49,7 @@ int NSVEparticles<rnumber>::initialize(void) template <typename rnumber> int NSVEparticles<rnumber>::step(void) { + TIMEZONE("NSVEparticles::step"); this->fs->compute_velocity(this->fs->cvorticity); this->fs->cvelocity->ift(); this->ps->completeLoop(this->dt); @@ -55,6 +60,7 @@ int NSVEparticles<rnumber>::step(void) template <typename rnumber> int NSVEparticles<rnumber>::write_checkpoint(void) { + TIMEZONE("NSVEparticles::write_checkpoint"); this->NSVE<rnumber>::write_checkpoint(); this->particles_output_writer_mpi->open_file(this->fs->get_current_fname()); this->particles_output_writer_mpi->template save<3>( @@ -70,6 +76,7 @@ int NSVEparticles<rnumber>::write_checkpoint(void) template <typename rnumber> int NSVEparticles<rnumber>::finalize(void) { + TIMEZONE("NSVEparticles::finalize"); delete this->pressure; this->ps.release(); delete this->particles_output_writer_mpi; @@ -84,6 +91,7 @@ int NSVEparticles<rnumber>::finalize(void) template <typename rnumber> int NSVEparticles<rnumber>::do_stats() { + TIMEZONE("NSVEparticles::do_stats"); /// fluid stats go here this->NSVE<rnumber>::do_stats(); @@ -142,6 +150,21 @@ int NSVEparticles<rnumber>::do_stats() return EXIT_SUCCESS; } +template <typename rnumber> +int NSVEparticles<rnumber>::read_parameters(void) +{ + TIMEZONE("NSVEparticles::read_parameters"); + 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/NSVEparticles_no_output.hpp b/bfps/cpp/full_code/NSVEparticles_no_output.hpp index 264fd75ac9b0628aff167d018d888030b7029a35..5b9d5e15e00fd1b2d8551995e99e0a157339925c 100644 --- a/bfps/cpp/full_code/NSVEparticles_no_output.hpp +++ b/bfps/cpp/full_code/NSVEparticles_no_output.hpp @@ -16,9 +16,9 @@ class NSVEparticles_no_output: public NSVEparticles<rnumber> ~NSVEparticles_no_output(){} int write_checkpoint(void) { - return 0; + TIMEZONE("NSVEparticles_no_output::write_checkpoint"); + return EXIT_SUCCESS; } - int read_parameters(void); }; #endif//NSVEPARTICLES_NO_OUTPUT_HPP diff --git a/bfps/cpp/full_code/code_base.cpp b/bfps/cpp/full_code/code_base.cpp index 1b06fe8e66a4180034b9f6a494a1a432ae5ea3f9..a6487c726de44b018392128f955ccebf7e7100a1 100644 --- a/bfps/cpp/full_code/code_base.cpp +++ b/bfps/cpp/full_code/code_base.cpp @@ -1,12 +1,42 @@ +/********************************************************************** +* * +* Copyright 2017 Max Planck Institute * +* for Dynamics and Self-Organization * +* * +* This file is part of bfps. * +* * +* bfps is free software: you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published * +* by the Free Software Foundation, either version 3 of the License, * +* or (at your option) any later version. * +* * +* bfps is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with bfps. If not, see <http://www.gnu.org/licenses/> * +* * +* Contact: Cristian.Lalescu@ds.mpg.de * +* * +**********************************************************************/ + + + +#define NDEBUG + #include "code_base.hpp" #include "scope_timer.hpp" + code_base::code_base( const MPI_Comm COMMUNICATOR, const std::string &simulation_name): comm(COMMUNICATOR), simname(simulation_name) { + TIMEZONE("code_base::code_base"); MPI_Comm_rank(this->comm, &this->myrank); MPI_Comm_size(this->comm, &this->nprocs); this->stop_code_now = false; @@ -14,6 +44,7 @@ code_base::code_base( int code_base::check_stopping_condition(void) { + TIMEZONE("code_base::check_stopping_condition"); if (myrank == 0) { std::string fname = ( @@ -34,3 +65,18 @@ int code_base::check_stopping_condition(void) return EXIT_SUCCESS; } +int code_base::read_parameters(void) +{ + TIMEZONE("code_base::read_parameters"); + 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..c0b0441e5b274cbe088b6fd0903823c6d17b2076 100644 --- a/bfps/cpp/full_code/direct_numerical_simulation.cpp +++ b/bfps/cpp/full_code/direct_numerical_simulation.cpp @@ -8,6 +8,7 @@ int direct_numerical_simulation::grow_file_datasets() { + TIMEZONE("direct_numerical_simulation::grow_file_datasets"); return hdf5_tools::grow_file_datasets( this->stat_file, "statistics", @@ -16,6 +17,7 @@ int direct_numerical_simulation::grow_file_datasets() int direct_numerical_simulation::read_iteration(void) { + TIMEZONE("direct_numerical_simulation::read_iteration"); /* read iteration */ hid_t dset; hid_t iteration_file = H5Fopen( @@ -56,6 +58,7 @@ int direct_numerical_simulation::read_iteration(void) int direct_numerical_simulation::write_iteration(void) { + TIMEZONE("direct_numerical_simulation::write_iteration"); if (this->myrank == 0) { hid_t dset = H5Dopen( @@ -88,6 +91,7 @@ int direct_numerical_simulation::write_iteration(void) int direct_numerical_simulation::main_loop(void) { + TIMEZONE("direct_numerical_simulation::main_loop"); this->start_simple_timer(); int max_iter = (this->iteration + this->niter_todo - (this->iteration % this->niter_todo)); @@ -117,3 +121,15 @@ int direct_numerical_simulation::main_loop(void) return EXIT_SUCCESS; } +int direct_numerical_simulation::read_parameters(void) +{ + TIMEZONE("direct_numerical_simulation::read_parameters"); + 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/bfps/cpp/full_code/field_output_test.cpp b/bfps/cpp/full_code/field_output_test.cpp index f54400647bee3d8b05d7ef4dc58b9a90998ac184..30df4e7512bec3c08325fe156b21789f80882f54 100644 --- a/bfps/cpp/full_code/field_output_test.cpp +++ b/bfps/cpp/full_code/field_output_test.cpp @@ -8,6 +8,7 @@ template <typename rnumber> int field_output_test<rnumber>::initialize(void) { + TIMEZONE("field_output_test::initialize"); this->read_parameters(); return EXIT_SUCCESS; } @@ -15,12 +16,14 @@ int field_output_test<rnumber>::initialize(void) template <typename rnumber> int field_output_test<rnumber>::finalize(void) { + TIMEZONE("field_output_test::finalize"); return EXIT_SUCCESS; } template <typename rnumber> int field_output_test<rnumber>::read_parameters() { + TIMEZONE("field_output_test::read_parameters"); this->test::read_parameters(); return EXIT_SUCCESS; } @@ -28,6 +31,7 @@ int field_output_test<rnumber>::read_parameters() template <typename rnumber> int field_output_test<rnumber>::do_work(void) { + TIMEZONE("field_output_test::do_work"); // allocate field<rnumber, FFTW, ONE> *scal_field = new field<rnumber, FFTW, ONE>( this->nx, this->ny, this->nz, diff --git a/bfps/cpp/full_code/field_single_to_double.cpp b/bfps/cpp/full_code/field_single_to_double.cpp index bb34abd22ca3d629a2b05e1d3e0a94b903010610..92976ecfb3ff32dc798a2f6f4b17bfd44441a158 100644 --- a/bfps/cpp/full_code/field_single_to_double.cpp +++ b/bfps/cpp/full_code/field_single_to_double.cpp @@ -7,6 +7,7 @@ template <typename rnumber> int field_single_to_double<rnumber>::initialize(void) { + TIMEZONE("field_single_to_double::intialize"); this->NSVE_field_stats<rnumber>::initialize(); DEBUG_MSG("after NSVE_field_stats::initialize\n"); this->kk = new kspace<FFTW, SMOOTH>( @@ -47,7 +48,7 @@ int field_single_to_double<rnumber>::initialize(void) template <typename rnumber> int field_single_to_double<rnumber>::work_on_current_iteration(void) { - DEBUG_MSG("entered field_single_to_double::work_on_current_iteration\n"); + TIMEZONE("field_single_to_double::work_on_current_iteration"); this->read_current_cvorticity(); // using CLOOP as opposed to a global std::copy because CLOOP @@ -83,6 +84,7 @@ int field_single_to_double<rnumber>::work_on_current_iteration(void) template <typename rnumber> int field_single_to_double<rnumber>::finalize(void) { + TIMEZONE("field_single_to_double::finalize"); delete this->vec_field_double; delete this->kk; return EXIT_SUCCESS; diff --git a/bfps/cpp/full_code/field_test.cpp b/bfps/cpp/full_code/field_test.cpp index 5c323e547900cc2e52561c0df16748659a7006b6..1627bc4088581468ebedab585db7ca9d6519d3a3 100644 --- a/bfps/cpp/full_code/field_test.cpp +++ b/bfps/cpp/full_code/field_test.cpp @@ -8,6 +8,7 @@ template <typename rnumber> int field_test<rnumber>::initialize(void) { + TIMEZONE("field_test::initialize"); this->read_parameters(); return EXIT_SUCCESS; } @@ -15,23 +16,22 @@ int field_test<rnumber>::initialize(void) template <typename rnumber> int field_test<rnumber>::finalize(void) { + TIMEZONE("field_test::finalize"); + this->read_parameters(); return EXIT_SUCCESS; } template <typename rnumber> int field_test<rnumber>::read_parameters() { + TIMEZONE("field_test::read_parameters"); this->test::read_parameters(); // in case any parameters are needed, this is where they should be read - hid_t parameter_file; - hid_t dset; - parameter_file = H5Fopen( + hid_t parameter_file = H5Fopen( (this->simname + std::string(".h5")).c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); - dset = H5Dopen(parameter_file, "/parameters/filter_length", H5P_DEFAULT); - H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->filter_length); - H5Dclose(dset); + this->filter_length = hdf5_tools::read_value<double>(parameter_file, "/parameters/filter_length"); H5Fclose(parameter_file); return EXIT_SUCCESS; } @@ -39,6 +39,7 @@ int field_test<rnumber>::read_parameters() template <typename rnumber> int field_test<rnumber>::do_work(void) { + TIMEZONE("field_test::do_work"); // allocate field<rnumber, FFTW, ONE> *scal_field = new field<rnumber, FFTW, ONE>( this->nx, this->ny, this->nz, diff --git a/bfps/cpp/full_code/filter_test.cpp b/bfps/cpp/full_code/filter_test.cpp index 80c4f83db69106c533e4ef21cecdf5874a24a06e..4db13843fa8f69db77f8a15cbd0563feb087dfcf 100644 --- a/bfps/cpp/full_code/filter_test.cpp +++ b/bfps/cpp/full_code/filter_test.cpp @@ -7,6 +7,7 @@ template <typename rnumber> int filter_test<rnumber>::initialize(void) { + TIMEZONE("filter_test::initialize"); this->read_parameters(); this->scal_field = new field<rnumber, FFTW, ONE>( nx, ny, nz, @@ -30,6 +31,7 @@ int filter_test<rnumber>::initialize(void) template <typename rnumber> int filter_test<rnumber>::finalize(void) { + TIMEZONE("filter_test::finalize"); delete this->scal_field; delete this->kk; return EXIT_SUCCESS; @@ -38,16 +40,13 @@ int filter_test<rnumber>::finalize(void) template <typename rnumber> int filter_test<rnumber>::read_parameters() { + TIMEZONE("filter_test::read_parameters"); this->test::read_parameters(); - hid_t parameter_file; - hid_t dset; - parameter_file = H5Fopen( + hid_t parameter_file = H5Fopen( (this->simname + std::string(".h5")).c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); - dset = H5Dopen(parameter_file, "/parameters/filter_length", H5P_DEFAULT); - H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->filter_length); - H5Dclose(dset); + this->filter_length = hdf5_tools::read_value<double>(parameter_file, "/parameters/filter_length"); H5Fclose(parameter_file); return EXIT_SUCCESS; } @@ -56,6 +55,7 @@ template <typename rnumber> int filter_test<rnumber>::reset_field( int dimension) { + TIMEZONE("filter_test::reset_field"); this->scal_field->real_space_representation = true; *this->scal_field = 0.0; if (this->scal_field->rlayout->starts[0] == 0) @@ -95,6 +95,7 @@ int filter_test<rnumber>::reset_field( template <typename rnumber> int filter_test<rnumber>::do_work(void) { + TIMEZONE("filter_test::do_work"); std::string filename = this->simname + std::string("_fields.h5"); for (int dimension = 0; dimension < 3; dimension++) { diff --git a/bfps/cpp/full_code/get_rfields.cpp b/bfps/cpp/full_code/get_rfields.cpp index 3986b5f9de93cdeb83341402750dc05bf7e4b695..376a265946cb4682a619040a1c907f5f2abbd8e1 100644 --- a/bfps/cpp/full_code/get_rfields.cpp +++ b/bfps/cpp/full_code/get_rfields.cpp @@ -7,6 +7,7 @@ template <typename rnumber> int get_rfields<rnumber>::initialize(void) { + TIMEZONE("get_rfields::initialize"); this->NSVE_field_stats<rnumber>::initialize(); DEBUG_MSG("after NSVE_field_stats::initialize\n"); this->kk = new kspace<FFTW, SMOOTH>( @@ -15,23 +16,15 @@ int get_rfields<rnumber>::initialize(void) (this->simname + std::string(".h5")).c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); - hid_t dset = H5Dopen(parameter_file, "/parameters/niter_out", H5P_DEFAULT); - H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->niter_out); - H5Dclose(dset); - if (H5Lexists(parameter_file, "/parameters/checkpoints_per_file", H5P_DEFAULT)) - { - dset = H5Dopen(parameter_file, "/parameters/checkpoints_per_file", H5P_DEFAULT); - H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &this->checkpoints_per_file); - H5Dclose(dset); - } - else + this->niter_out = hdf5_tools::read_value<int>(parameter_file, "/parameters/niter_out"); + this->checkpoints_per_file = hdf5_tools::read_value<int>(parameter_file, "/parameters/checkpoints_per_file"); + if (this->checkpoints_per_file == INT_MAX) // value returned if dataset does not exist this->checkpoints_per_file = 1; H5Fclose(parameter_file); parameter_file = H5Fopen( (this->simname + std::string("_post.h5")).c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); - DEBUG_MSG("before read_vector\n"); this->iteration_list = hdf5_tools::read_vector<int>( parameter_file, "/get_rfields/parameters/iteration_list"); @@ -42,7 +35,7 @@ int get_rfields<rnumber>::initialize(void) template <typename rnumber> int get_rfields<rnumber>::work_on_current_iteration(void) { - DEBUG_MSG("entered get_rfields::work_on_current_iteration\n"); + TIMEZONE("get_rfields::work_on_current_iteration"); this->read_current_cvorticity(); field<rnumber, FFTW, THREE> *vel = new field<rnumber, FFTW, THREE>( this->nx, this->ny, this->nz, @@ -97,6 +90,7 @@ int get_rfields<rnumber>::work_on_current_iteration(void) template <typename rnumber> int get_rfields<rnumber>::finalize(void) { + TIMEZONE("get_rfields::finalize"); delete this->kk; this->NSVE_field_stats<rnumber>::finalize(); return EXIT_SUCCESS; diff --git a/bfps/cpp/full_code/joint_acc_vel_stats.cpp b/bfps/cpp/full_code/joint_acc_vel_stats.cpp index e4f4d5d40772292f44c7e776dcd4d1b82c4ce222..1c28527e5986e12a5d66151a5623194e4ffab3aa 100644 --- a/bfps/cpp/full_code/joint_acc_vel_stats.cpp +++ b/bfps/cpp/full_code/joint_acc_vel_stats.cpp @@ -7,6 +7,7 @@ template <typename rnumber> int joint_acc_vel_stats<rnumber>::initialize(void) { + TIMEZONE("joint_acc_vel_stats::initialize"); this->NSVE_field_stats<rnumber>::initialize(); this->kk = new kspace<FFTW, SMOOTH>( this->vorticity->clayout, this->dkx, this->dky, this->dkz); @@ -85,7 +86,7 @@ int joint_acc_vel_stats<rnumber>::initialize(void) template <typename rnumber> int joint_acc_vel_stats<rnumber>::work_on_current_iteration(void) { - DEBUG_MSG("entered joint_acc_vel_stats::work_on_current_iteration\n"); + TIMEZONE("joint_acc_vel_stats::work_on_current_iteration"); /// read current vorticity, place it in this->ve->cvorticity this->read_current_cvorticity(); *this->ve->cvorticity = this->vorticity->get_cdata(); @@ -156,6 +157,7 @@ int joint_acc_vel_stats<rnumber>::work_on_current_iteration(void) template <typename rnumber> int joint_acc_vel_stats<rnumber>::finalize(void) { + DEBUG_MSG("entered joint_acc_vel_stats::finalize\n"); delete this->ve; delete this->kk; if (this->myrank == 0) diff --git a/bfps/cpp/full_code/native_binary_to_hdf5.cpp b/bfps/cpp/full_code/native_binary_to_hdf5.cpp index 7774e2dea9012394c389858038e8ca82674256d7..fb5a39c2af8a88a158df679ad27ce0f08fab37f8 100644 --- a/bfps/cpp/full_code/native_binary_to_hdf5.cpp +++ b/bfps/cpp/full_code/native_binary_to_hdf5.cpp @@ -7,6 +7,7 @@ template <typename rnumber> int native_binary_to_hdf5<rnumber>::initialize(void) { + TIMEZONE("native_binary_to_hdf5::initialize"); this->read_parameters(); this->vec_field = new field<rnumber, FFTW, THREE>( nx, ny, nz, @@ -24,6 +25,7 @@ int native_binary_to_hdf5<rnumber>::initialize(void) template <typename rnumber> int native_binary_to_hdf5<rnumber>::work_on_current_iteration(void) { + TIMEZONE("native_binary_to_hdf5::work_on_current_iteration"); char itername[16]; sprintf(itername, "i%.5x", this->iteration); std::string native_binary_fname = ( @@ -45,6 +47,7 @@ int native_binary_to_hdf5<rnumber>::work_on_current_iteration(void) template <typename rnumber> int native_binary_to_hdf5<rnumber>::finalize(void) { + TIMEZONE("native_binary_to_hdf5::finalize"); delete this->bin_IO; delete this->vec_field; return EXIT_SUCCESS; @@ -53,6 +56,7 @@ int native_binary_to_hdf5<rnumber>::finalize(void) template <typename rnumber> int native_binary_to_hdf5<rnumber>::read_parameters(void) { + TIMEZONE("native_binary_to_hdf5::read_parameters"); this->postprocess::read_parameters(); hid_t parameter_file = H5Fopen( (this->simname + std::string(".h5")).c_str(), diff --git a/bfps/cpp/full_code/postprocess.cpp b/bfps/cpp/full_code/postprocess.cpp index cb04a030123f3f5ecaa501ca11b22511d1a8ca84..13bee7009e3d8d03e0f2ce10c8a3c1706318b460 100644 --- a/bfps/cpp/full_code/postprocess.cpp +++ b/bfps/cpp/full_code/postprocess.cpp @@ -8,6 +8,7 @@ int postprocess::main_loop(void) { + TIMEZONE("postprocess::main_loop"); this->start_simple_timer(); for (unsigned int iteration_counter = 0; iteration_counter < iteration_list.size(); @@ -33,41 +34,20 @@ int postprocess::main_loop(void) int postprocess::read_parameters() { - hid_t parameter_file; - char fname[256]; - sprintf(fname, "%s.h5", this->simname.c_str()); - parameter_file = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); - this->dealias_type = hdf5_tools::read_value<int>( - parameter_file, "/parameters/dealias_type"); - 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->dt = hdf5_tools::read_value<double>( - parameter_file, "/parameters/dt"); - 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->fmode = hdf5_tools::read_value<int>( - parameter_file, "/parameters/fmode"); - sprintf(this->forcing_type, "%s", - hdf5_tools::read_string(parameter_file, "/parameters/forcing_type").c_str()); - this->nu = hdf5_tools::read_value<double>( - parameter_file, "/parameters/nu"); - 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"); + TIMEZONE("postprocess::read_parameters"); + this->code_base::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"); + 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 0; + return EXIT_SUCCESS; } diff --git a/bfps/cpp/full_code/postprocess.hpp b/bfps/cpp/full_code/postprocess.hpp index 660e561a1ddba6b355ee5ecf49c5cea1b7153eff..65e6eadd1fd05615eb69cb7d8ca1754abd1b7e42 100644 --- a/bfps/cpp/full_code/postprocess.hpp +++ b/bfps/cpp/full_code/postprocess.hpp @@ -46,6 +46,7 @@ class postprocess: public code_base double friction_coefficient; double fk0; double fk1; + double energy; int fmode; char forcing_type[512]; double nu; diff --git a/bfps/cpp/full_code/resize.cpp b/bfps/cpp/full_code/resize.cpp index 41d68ef725ab89c9ad2d55e5f9cc014844294b71..de555a7436786d7ffdfd6a1b7206d74850065b6b 100644 --- a/bfps/cpp/full_code/resize.cpp +++ b/bfps/cpp/full_code/resize.cpp @@ -7,6 +7,7 @@ template <typename rnumber> int resize<rnumber>::initialize(void) { + TIMEZONE("resize::initialize"); this->NSVE_field_stats<rnumber>::initialize(); DEBUG_MSG("after NSVE_field_stats::initialize\n"); hid_t parameter_file = H5Fopen( @@ -46,7 +47,7 @@ int resize<rnumber>::initialize(void) template <typename rnumber> int resize<rnumber>::work_on_current_iteration(void) { - DEBUG_MSG("entered resize::work_on_current_iteration\n"); + TIMEZONE("resize::work_on_current_iteration"); this->read_current_cvorticity(); std::string fname = ( @@ -64,6 +65,7 @@ int resize<rnumber>::work_on_current_iteration(void) template <typename rnumber> int resize<rnumber>::finalize(void) { + TIMEZONE("resize::finalize"); delete this->new_field; this->NSVE_field_stats<rnumber>::finalize(); return EXIT_SUCCESS; diff --git a/bfps/cpp/full_code/symmetrize_test.cpp b/bfps/cpp/full_code/symmetrize_test.cpp index 3b4cd5a5b7304e233735cab87f603b5e164ef0eb..821161da846a323721c07ed47a7c66d9efea78f0 100644 --- a/bfps/cpp/full_code/symmetrize_test.cpp +++ b/bfps/cpp/full_code/symmetrize_test.cpp @@ -8,6 +8,7 @@ template <typename rnumber> int symmetrize_test<rnumber>::initialize(void) { + TIMEZONE("symmetrize_test::initialize"); this->read_parameters(); return EXIT_SUCCESS; } @@ -15,12 +16,14 @@ int symmetrize_test<rnumber>::initialize(void) template <typename rnumber> int symmetrize_test<rnumber>::finalize(void) { + TIMEZONE("symmetrize_test::finalize"); return EXIT_SUCCESS; } template <typename rnumber> int symmetrize_test<rnumber>::read_parameters() { + TIMEZONE("symmetrize_test::read_parameters"); this->test::read_parameters(); hid_t parameter_file = H5Fopen( (this->simname + std::string(".h5")).c_str(), @@ -35,6 +38,7 @@ int symmetrize_test<rnumber>::read_parameters() template <typename rnumber> int symmetrize_test<rnumber>::do_work(void) { + TIMEZONE("symmetrize_test::do_work"); // allocate DEBUG_MSG("about to allocate field0\n"); field<rnumber, FFTW, THREE> *test_field0 = new field<rnumber, FFTW, THREE>( diff --git a/bfps/cpp/full_code/test.cpp b/bfps/cpp/full_code/test.cpp index 9c2e4e6744b4ecd8945615da730c9dcd14382e78..aa909362df050c95282fd9c7de66de3d8a1acc34 100644 --- a/bfps/cpp/full_code/test.cpp +++ b/bfps/cpp/full_code/test.cpp @@ -8,9 +8,7 @@ int test::main_loop(void) { - #ifdef USE_TIMINGOUTPUT - TIMEZONE("test::main_loop"); - #endif + TIMEZONE("test::main_loop"); this->start_simple_timer(); this->do_work(); this->print_simple_timer( @@ -18,36 +16,3 @@ int test::main_loop(void) return EXIT_SUCCESS; } - -int test::read_parameters() -{ - hid_t parameter_file; - hid_t dset; - char fname[256]; - 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/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; -} - diff --git a/bfps/cpp/full_code/test.hpp b/bfps/cpp/full_code/test.hpp index 134a01512b3fd836a8ac4d40068b3954752c4844..96ddaf8104f1dd3d050b4acf16a68dbcd539b290 100644 --- a/bfps/cpp/full_code/test.hpp +++ b/bfps/cpp/full_code/test.hpp @@ -56,7 +56,6 @@ class test: public code_base virtual int finalize(void) = 0; int main_loop(void); - virtual int read_parameters(void); }; #endif//TEST_HPP diff --git a/bfps/cpp/full_code/test_interpolation.cpp b/bfps/cpp/full_code/test_interpolation.cpp index b194d372f6b40916bcd64ff8268a44694b0465d0..5ef11de44b6f6a36ab6827facae3c637b702bc58 100644 --- a/bfps/cpp/full_code/test_interpolation.cpp +++ b/bfps/cpp/full_code/test_interpolation.cpp @@ -4,6 +4,7 @@ template <typename rnumber> int test_interpolation<rnumber>::read_parameters(void) { + TIMEZONE("test_interpolation::read_parameters"); this->test::read_parameters(); hid_t parameter_file = H5Fopen( (this->simname + std::string(".h5")).c_str(), @@ -24,6 +25,7 @@ int test_interpolation<rnumber>::read_parameters(void) template <typename rnumber> int test_interpolation<rnumber>::initialize(void) { + TIMEZONE("test_interpolation::initialize"); this->read_parameters(); this->vorticity = new field<rnumber, FFTW, THREE>( this->nx, this->ny, this->nz, @@ -86,6 +88,7 @@ int test_interpolation<rnumber>::initialize(void) template <typename rnumber> int test_interpolation<rnumber>::finalize(void) { + TIMEZONE("test_interpolation::finalize"); delete this->nabla_u; delete this->velocity; delete this->vorticity; @@ -99,6 +102,7 @@ int test_interpolation<rnumber>::finalize(void) template <typename rnumber> int test_interpolation<rnumber>::do_work() { + TIMEZONE("test_interpolation::do_work"); *this->nabla_u = 0.0; this->velocity->real_space_representation = false; this->vorticity->real_space_representation = false; diff --git a/bfps/cpp/scope_timer.hpp b/bfps/cpp/scope_timer.hpp index 2c48e2eda06ded74e668825181f0444eef22f647..890f522c415d7a102a0fff25c5292502cbcb459c 100644 --- a/bfps/cpp/scope_timer.hpp +++ b/bfps/cpp/scope_timer.hpp @@ -791,7 +791,8 @@ extern EventManager global_timer_manager; #define TIMEZONE(NAME) \ ScopeEvent TIMEZONE_Core_Pre_Merge(____TIMEZONE_AUTO_ID, __LINE__)( \ - NAME, global_timer_manager, ScopeEventUniqueKey); + NAME, global_timer_manager, ScopeEventUniqueKey); \ + DEBUG_MSG((NAME + std::string("\n")).c_str()); #define TIMEZONE_MULTI_REF(NAME) \ ScopeEvent TIMEZONE_Core_Pre_Merge(____TIMEZONE_AUTO_ID, __LINE__)( \ NAME, global_timer_manager, ScopeEventMultiRefKey); diff --git a/cpp_build.py b/cpp_build.py new file mode 100644 index 0000000000000000000000000000000000000000..a312191aadd3c54d1f5461823e4d39fe54355e79 --- /dev/null +++ b/cpp_build.py @@ -0,0 +1,85 @@ +####################################################################### +# # +# Copyright 2015 Max Planck Institute # +# for Dynamics and Self-Organization # +# # +# This file is part of bfps. # +# # +# bfps is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published # +# by the Free Software Foundation, either version 3 of the License, # +# or (at your option) any later version. # +# # +# bfps is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with bfps. If not, see <http://www.gnu.org/licenses/> # +# # +# Contact: Cristian.Lalescu@ds.mpg.de # +# # +####################################################################### + + + +import os +import subprocess + +src_file_list = ['hdf5_tools', + 'full_code/get_rfields', + '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', + 'full_code/NSVEparticles', + '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', + 'fftw_tools', + 'spline_n1', + 'spline_n2', + 'spline_n3', + 'spline_n4', + 'spline_n5', + 'spline_n6', + 'spline_n7', + 'spline_n8', + 'spline_n9', + 'spline_n10', + 'Lagrange_polys', + 'scope_timer'] + +def get_dependency_list(): + ofile = open('dependencies.txt', 'w') + for src_file in src_file_list: + p = subprocess.Popen( + ['g++', '-Ibfps/cpp', '-MM', 'bfps/cpp/' + src_file + '.cpp'], + stdout = subprocess.PIPE) + out, err = p.communicate() + p.terminate() + deps = str(out, 'ASCII').replace('\\\n', '') + print(deps.split()[0]) + ofile.write(' '.join(deps.split()[1:]) + '\n') + ofile.close() + return None + +if __name__ == '__main__': + #pass + get_dependency_list() + 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 = [ diff --git a/tests/run_all_tests.sh b/tests/run_all_tests.sh new file mode 100644 index 0000000000000000000000000000000000000000..7865a8a3d9a3b7d56194b0dcda2bc24925aaeafd --- /dev/null +++ b/tests/run_all_tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +bfps.test_fftw +bfps.test_Parseval +bfps.test_NSVEparticles + +# test postprocessing +bfps PP field_single_to_double --simname dns_nsveparticles --iter0 32 --iter1 32 +bfps PP get_rfields --simname dns_nsveparticles --iter0 0 --iter1 64 +bfps PP joint_acc_vel_stats --simname dns_nsveparticles --iter0 0 --iter1 64 +bfps PP resize --simname dns_nsveparticles --new_nx 96 --new_ny 96 --new_nz 96 --new_simname dns_nsveparticles_resized