From bca8313ffb045994c51619d3339b9b6d6c900a8e Mon Sep 17 00:00:00 2001 From: Cristian C Lalescu <Cristian.Lalescu@mpcdf.mpg.de> Date: Tue, 1 Apr 2025 06:45:45 +0200 Subject: [PATCH] updates NSE initiialization --- cpp/full_code/NSE.cpp | 62 ++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/cpp/full_code/NSE.cpp b/cpp/full_code/NSE.cpp index 361de8c1..e86a89da 100644 --- a/cpp/full_code/NSE.cpp +++ b/cpp/full_code/NSE.cpp @@ -56,31 +56,43 @@ int NSE<rnumber>::initialize(void) /* initialize field */ this->velocity->real_space_representation = false; - if ((this->iteration == 0) - && (this->field_random_seed != 0)) { - TIMEZONE("NSE::initialize::generate_initial_condition"); - // generate initial condition - make_gaussian_random_field( - this->kk, - this->velocity, - this->field_random_seed, - this->injection_rate, - 1.0, // Lint - 1.5 / this->kk->kM, // etaK - 6.78, - 0.40, - 3./2.); - this->kk->template low_pass<rnumber, THREE>( - this->velocity->get_cdata(), - this->kk->kM); - this->kk->template project_divfree<rnumber>( - this->velocity->get_cdata()); - this->velocity->symmetrize(); - this->velocity->io( - this->get_current_fname(), - "velocity", - this->iteration, - false); + if (this->iteration == 0) { + if (!hdf5_tools::field_exists( + this->get_current_fname(), + "velocity", + "complex", + 0)) { + TIMEZONE("NSE::initialize::generate_initial_condition"); + // generate initial condition + make_gaussian_random_field( + this->kk, + this->velocity, + this->field_random_seed, + this->injection_rate, + 1.0, // Lint + 1.5 / this->kk->kM, // etaK + 6.78, + 0.40, + 3./2.); + this->kk->template low_pass<rnumber, THREE>( + this->velocity->get_cdata(), + this->kk->kM); + this->kk->template project_divfree<rnumber>( + this->velocity->get_cdata()); + this->velocity->symmetrize(); + this->velocity->io( + this->get_current_fname(), + "velocity", + this->iteration, + false); + } else { + TIMEZONE("NSE::initialize::read_initial_condition"); + this->velocity->io( + this->get_current_fname(), + "velocity", + this->iteration, + true); + } } else { TIMEZONE("NSE::initialize::read_initial_condition"); this->velocity->io( -- GitLab