diff --git a/cpp/full_code/NSE.cpp b/cpp/full_code/NSE.cpp index 361de8c14f7d85b76d3a331546209c54b5fe78d4..e86a89dadc5681ef9f197b894d2ee2b919506e7c 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(