From bffd065654ee81df65c09d48f970c90efd8fc70a Mon Sep 17 00:00:00 2001 From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de> Date: Mon, 30 Sep 2019 14:11:30 +0200 Subject: [PATCH] fixes static_field now code compiles --- CMakeLists.txt | 2 ++ cpp/full_code/static_field.cpp | 48 +++++++++++++++------------------- cpp/full_code/static_field.hpp | 4 ++- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae33cd44..8fa823c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,6 +176,7 @@ set(cpp_for_lib ${PROJECT_SOURCE_DIR}/cpp/full_code/code_base.cpp ${PROJECT_SOURCE_DIR}/cpp/full_code/direct_numerical_simulation.cpp ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVE.cpp + ${PROJECT_SOURCE_DIR}/cpp/full_code/static_field.cpp ${PROJECT_SOURCE_DIR}/cpp/full_code/joint_acc_vel_stats.cpp ${PROJECT_SOURCE_DIR}/cpp/full_code/test.cpp ${PROJECT_SOURCE_DIR}/cpp/full_code/filter_test.cpp @@ -217,6 +218,7 @@ set(hpp_for_lib ${PROJECT_SOURCE_DIR}/cpp/full_code/code_base.hpp ${PROJECT_SOURCE_DIR}/cpp/full_code/direct_numerical_simulation.hpp ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVE.hpp + ${PROJECT_SOURCE_DIR}/cpp/full_code/static_field.hpp ${PROJECT_SOURCE_DIR}/cpp/full_code/joint_acc_vel_stats.hpp ${PROJECT_SOURCE_DIR}/cpp/full_code/test.hpp ${PROJECT_SOURCE_DIR}/cpp/full_code/filter_test.hpp diff --git a/cpp/full_code/static_field.cpp b/cpp/full_code/static_field.cpp index 56435a90..b7aaad36 100644 --- a/cpp/full_code/static_field.cpp +++ b/cpp/full_code/static_field.cpp @@ -23,8 +23,6 @@ -#define NDEBUG - #include <string> #include <cmath> #include "static_field.hpp" @@ -62,13 +60,13 @@ int static_field<rnumber>::initialize(void) std::endl; return EXIT_FAILURE; } - + this->vorticity = new field<rnumber, FFTW, THREE>( nx, ny, nz, this->comm, fftw_planner_string_to_flag[this->fftw_plan_rigor]); - this->stat_vel = new field<rnumber, FFTW, THREE>( + this->velocity = new field<rnumber, FFTW, THREE>( nx, ny, nz, this->comm, fftw_planner_string_to_flag[this->fftw_plan_rigor]); @@ -81,61 +79,57 @@ int static_field<rnumber>::initialize(void) this->kk = new kspace<FFTW, SMOOTH>( this->vorticity->clayout, this->dkx, this->dky, this->dkz); - // compute the velocity field and store + // compute the velocity field and store invert_curl( this->kk, this->vorticity, - stat_vel_field); - // transform velocity field to real space - this->stat_vel->ift(); + velocity); + // transform velocity and vorticity fields to real space + this->velocity->ift(); + this->vorticity->ift(); return EXIT_SUCCESS; } template <typename rnumber> -int NSVE<rnumber>::step(void) +int static_field<rnumber>::step(void) { - return EXIT_SUCCESS; + return EXIT_SUCCESS; } template <typename rnumber> -int NSVE<rnumber>::write_checkpoint(void) +int static_field<rnumber>::write_checkpoint(void) { return EXIT_SUCCESS; } template <typename rnumber> -int NSVE<rnumber>::finalize(void) +int static_field<rnumber>::finalize(void) { - TIMEZONE("NSVE::finalize"); + TIMEZONE("static_field::finalize"); if (this->myrank == 0) H5Fclose(this->stat_file); - delete this->vorticity; - delete this->stat_vel; + // good practice rule number n+1: always delete in inverse order of allocation delete this->kk; + delete this->velocity; + delete this->vorticity; return EXIT_SUCCESS; } -/** \brief Compute standard statistics for velocity and vorticity fields. +/** \brief Compute statistics. * - * IMPORTANT: at the end of this subroutine, `this->fs->cvelocity` contains - * the Fourier space representation of the velocity field, and - * `this->tmp_vec_field` contains the real space representation of the - * velocity field. - * This behavior is relied upon in the `NSVEparticles` class, so please - * don't break it. */ template <typename rnumber> -int NSVE<rnumber>::do_stats() +int static_field<rnumber>::do_stats() { return EXIT_SUCCESS; } template <typename rnumber> -int NSVE<rnumber>::read_parameters(void) +int static_field<rnumber>::read_parameters(void) { - TIMEZONE("NSVE::read_parameters"); + TIMEZONE("static_field::read_parameters"); this->direct_numerical_simulation::read_parameters(); hid_t parameter_file = H5Fopen((this->simname + ".h5").c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); this->fftw_plan_rigor = hdf5_tools::read_string(parameter_file, "parameters/fftw_plan_rigor"); @@ -143,6 +137,6 @@ int NSVE<rnumber>::read_parameters(void) return EXIT_SUCCESS; } -template class NSVE<float>; -template class NSVE<double>; +template class static_field<float>; +template class static_field<double>; diff --git a/cpp/full_code/static_field.hpp b/cpp/full_code/static_field.hpp index e1cd0b44..c23b87dc 100644 --- a/cpp/full_code/static_field.hpp +++ b/cpp/full_code/static_field.hpp @@ -31,6 +31,8 @@ #include <cstdlib> #include "base.hpp" +#include "kspace.hpp" +#include "field.hpp" #include "full_code/direct_numerical_simulation.hpp" template <typename rnumber> @@ -43,8 +45,8 @@ class static_field: public direct_numerical_simulation /* other stuff */ kspace<FFTW, SMOOTH> *kk; + field<rnumber, FFTW, THREE> *vorticity; field<rnumber, FFTW, THREE> *velocity; - field<rnumber, FFTW, THREE> *stat_vel; static_field( -- GitLab