//------------------------------------------------------------------------------ bool BulirschStoer::Step(void) { if (!isInitialized) return false; // waw: 06/28/04 Unused variable // Real nextstep = stepSize; // bool reduct = false; bool converged = false; Real tnew = 0.0; // waw: 06/28/04 Initialized Real eEstimate = 0.0; // waw: 06/28/04 Initialized do { tnew = stepSize; if (tnew == 0.0) return false; for (kused = 0; kused < kmax; ++kused) { level = kused; MidpointMethod(subinterval[kused+1]); PolyExtrapolate(); // Now do the error control eEstimate = EstimateError(); levelError[kused] = eEstimate; if ((kused > 1) && (eEstimate < tolerance)) { converged = true; if (!AdaptStep(eEstimate)) return false; break; } } if (!converged) { if (!AdaptStep(eEstimate)) return false; } if (stepAttempts >= maxStepAttempts) return false; } while (!converged); memcpy(outState, estimatedState, dimension * sizeof(Real)); physicalModel->IncrementTime(stepTaken); return true; }
//------------------------------------------------------------------------------ bool PredictorCorrector::Step() { #ifdef DEBUG_PROPAGATION MessageInterface::ShowMessage("Called PredictorCorrector::Step()\n"); #endif if (!isInitialized) return false; // if (physicalModel->StateChanged(true)) // { // MessageInterface::ShowMessage(" Resetting in Step()\n"); // Reset(); // } bool wasStartup = false; do { if (!startupComplete) { wasStartup = true; if (ddt == NULL) { ddt = physicalModel->GetDerivativeArray(); if (ddt == NULL) return false; } // First load up the derivatives for the current state physicalModel->GetDerivatives(inState); memcpy(history[startupCount+1], ddt, dimension * sizeof(Real)); #ifdef DEBUG_PROPAGATION MessageInterface::ShowMessage("startup ddt = [%le %le %le...]\n", ddt[0], ddt[1], ddt[2]); #endif bool retval = FireStartupStep(); if (retval) timeleft -= stepTaken; else return false; // Omit any error from the starter code -- we assume it is good // enough for startup purposes maxError = 0.0; } else { #ifdef DEBUG_PROPAGATION MessageInterface::ShowMessage("Pred-Corr step "); #endif ++stepAttempts; if (!Predict()) return false; if (!Correct()) return false; if (EstimateError() < 0.0) return false; if (maxError <= tolerance) { memcpy(outState, correctorState, dimension * sizeof(Real)); physicalModel->IncrementTime(stepSize); stepTaken = stepSize; timeleft -= stepTaken; } #ifdef DEBUG_PROPAGATION MessageInterface::ShowMessage("Max error = %le, tolerance = %le\n", maxError, tolerance); #endif if ((maxError > tolerance) || (maxError < lowerError)) if (maxError != 0.0) if (!AdaptStep(maxError)) return false; } if (stepAttempts >= maxStepAttempts) return false; } while (maxError > tolerance); #ifdef DEBUG_PROPAGATION MessageInterface::ShowMessage("Good step\n"); #endif if ((startupComplete) && (wasStartup == false)) { stepAttempts = 0; } return true; }