From bb50c38898515aeac5d51bc8e278fd862d8a46c4 Mon Sep 17 00:00:00 2001 From: pdziekan Date: Wed, 6 Mar 2019 11:20:52 +0100 Subject: [PATCH 1/2] option to specify interval of saving velocity fields for piggybacking --- src/slvr_piggy.hpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/slvr_piggy.hpp b/src/slvr_piggy.hpp index 132253435e..3b3d102365 100644 --- a/src/slvr_piggy.hpp +++ b/src/slvr_piggy.hpp @@ -21,6 +21,7 @@ class slvr_piggy< { private: bool save_vel; // should velocity field be stored for piggybacking + long long int save_vel_interval; setup::real_t prs_tol; // store a copy for output purposes protected: @@ -54,13 +55,16 @@ class slvr_piggy< void hook_post_step() { parent_t::hook_post_step(); // includes changes of velocity field due to vip_rhs_impl_fnlz() - this->mem->barrier(); - // save velocity field - if(this->rank==0 && save_vel) + if(save_vel && (this->timestep % save_vel_interval == 0)) { - for (int d = 0; d < parent_t::n_dims; ++d) + this->mem->barrier(); + if(this->rank==0) { - f_vel_out << this->state(this->vip_ixs[d]); + // save velocity field + for (int d = 0; d < parent_t::n_dims; ++d) + { + f_vel_out << this->state(this->vip_ixs[d]); + } } } } @@ -68,6 +72,7 @@ class slvr_piggy< struct rt_params_t : parent_t::rt_params_t { bool save_vel; + long long int save_vel_interval; // ctor rt_params_t() @@ -76,12 +81,16 @@ class slvr_piggy< opts.add_options() ("save_vel", po::value()->default_value(false), "should velocity field be stored for piggybacking") ; + opts.add_options() + ("save_vel_interval", po::value()->default_value(1), "per how many timesteps velocity field is stored for piggybacking") + ; opts.add_options() ("prs_tol", po::value()->default_value(1e-6) , "pressure solver tolerance"); po::variables_map vm; handle_opts(opts, vm); save_vel = vm["save_vel"].as(); + save_vel_interval = vm["save_vel_interval"].as(); this->prs_tol = vm["prs_tol"].as(); } }; @@ -93,6 +102,7 @@ class slvr_piggy< ) : parent_t(args, p), save_vel(p.save_vel), + save_vel_interval(p.save_vel_interval), prs_tol(p.prs_tol) {} }; From fb718ee61706bb35d972128b7ee0e3ebe5abc0c6 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Mon, 18 Mar 2019 12:04:40 +0100 Subject: [PATCH 2/2] more reasonable nan/negchecks --- src/slvr_common.hpp | 4 +++- src/slvr_lgrngn.hpp | 7 +++++-- src/slvr_piggy.hpp | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/slvr_common.hpp b/src/slvr_common.hpp index de3bd658b7..ecff80c5ab 100644 --- a/src/slvr_common.hpp +++ b/src/slvr_common.hpp @@ -286,7 +286,8 @@ class slvr_common : public slvr_dim void hook_post_step() { - negtozero(this->mem->advectee(ix::rv)(this->ijk), "rv at start of slvr_common::hook_post_step"); + negcheck(this->mem->advectee(ix::th)(this->ijk), "th at start of slvr_common::hook_post_step (i.e. after advection)"); + negtozero(this->mem->advectee(ix::rv)(this->ijk), "rv at start of slvr_common::hook_post_step (i.e. after advection)"); parent_t::hook_post_step(); // includes output this->mem->barrier(); @@ -310,6 +311,7 @@ class slvr_common : public slvr_dim } } negcheck(this->mem->advectee(ix::rv)(this->ijk), "rv at end of slvr_common::hook_post_step"); + negcheck(this->mem->advectee(ix::th)(this->ijk), "th at end of slvr_common::hook_post_step"); } public: diff --git a/src/slvr_lgrngn.hpp b/src/slvr_lgrngn.hpp index 54e41d1152..4813cd959c 100644 --- a/src/slvr_lgrngn.hpp +++ b/src/slvr_lgrngn.hpp @@ -636,9 +636,12 @@ class slvr_lgrngn : public slvr_common void hook_mixed_rhs_post_step() { - negcheck(this->mem->advectee(ix::rv)(this->ijk), "rv after advection"); + nancheck(this->mem->advectee(ix::th)(this->ijk), "th at start of slvr_lgrngn::mixed_rhs_post_step"); + nancheck(this->mem->advectee(ix::rv)(this->ijk), "rv at start of slvr_lgrngn::mixed_rhs_post_step"); + negcheck(this->mem->advectee(ix::th)(this->ijk), "th at start of slvr_lgrngn::mixed_rhs_post_step"); + negcheck(this->mem->advectee(ix::rv)(this->ijk), "rv at start of slvr_lgrngn::mixed_rhs_post_step"); this->update_rhs(this->rhs, this->dt, 1); - negcheck(this->rhs.at(ix::rv)(this->ijk), "RHS rv after update_rhs in mixed_rhs_post_step"); +// negcheck(this->rhs.at(ix::rv)(this->ijk), "RHS rv after update_rhs in mixed_rhs_post_step"); this->apply_rhs(this->dt); // no negtozero after apply, because only w changed here // TODO: add these nanchecks/negchecks to apply_rhs, since they are repeated twice now diff --git a/src/slvr_piggy.hpp b/src/slvr_piggy.hpp index 3b3d102365..4fb63d5929 100644 --- a/src/slvr_piggy.hpp +++ b/src/slvr_piggy.hpp @@ -178,6 +178,7 @@ class slvr_piggy< // read in through buffer, if done directly caused data races f_vel_in >> in_bfr; this->state(this->vip_ixs[d]) = in_bfr; + nancheck(this->state(this->vip_ixs[d]), "velocity field loaded from vel_in"); //std::cout << this->state(this->vip_ixs[d]); } }