diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc index 70c2db74165b0d3f19060c7ec201bc5a934364ba..7b3c883b83159d4fb82cc1cdf99929306613929a 100644 --- a/src/one-body-sample.cc +++ b/src/one-body-sample.cc @@ -531,22 +531,24 @@ int main(int argc, char *argv[]) { // Q: is this reasonable? VectorType u; VectorType u_saved; + SingletonVectorType alpha_saved; double lastStateCorrection; for (size_t state_fpi = 1; state_fpi <= state_fpi_max; ++state_fpi) { stateUpdater->solve(v); - { - SingletonVectorType computed_state; - stateUpdater->extractState(computed_state); - double const stateCorrection = - stateEnergyNorm.diff(computed_state, alpha); + stateUpdater->extractState(alpha); - if (state_fpi <= 2 or stateCorrection < - requiredReduction * lastStateCorrection) { - alpha = computed_state; + if (state_fpi == 1) + relaxationWriter << "N "; + else { + double const stateCorrection = + stateEnergyNorm.diff(alpha, alpha_saved); + if (state_fpi <= + 2 // lastStateCorrection is only set for state_fpi > 2 + or stateCorrection < requiredReduction * lastStateCorrection) relaxationWriter << "N "; - } else { - alpha *= relaxation; - Arithmetic::addProduct(alpha, 1.0 - relaxation, computed_state); + else { + alpha *= (1.0 - relaxation); + Arithmetic::addProduct(alpha, relaxation, alpha_saved); relaxationWriter << "Y "; } lastStateCorrection = stateCorrection; @@ -569,6 +571,7 @@ int main(int argc, char *argv[]) { if (state_fpi == state_fpi_max) DUNE_THROW(Dune::Exception, "FPI failed to converge"); + alpha_saved = alpha; u_saved = u; } if (printProgress)