bool Solver::solveStep() { if ( _field->isSolved() ) { emit solvingDone(true); return true; } d->rules->solve(); #ifdef DEBUG PRINT_ELAPSED("fast rules") #endif if( _field->isSolved() ) { emit solvingDone(true); return true; } CoordSet surePoints; AdviseFull::ProbabilityMap probabilities; AdviseFull::adviseFull(d->facts, &surePoints, &probabilities); #ifdef DEBUG PRINT_ELAPSED("full rules") #endif if(!surePoints.empty()) { CoordSet::iterator i; for(i=surePoints.begin(); i!=surePoints.end(); ++i) { bool b = d->rules->reveal(*i); assert(b); } } else if ( !_noGuess ) { #ifdef DEBUG cout << "Applying heuristics!" << endl; cout << *_field << endl; #endif // Minimum probability logic assert(!probabilities.empty()); #ifdef DEBUG AdviseFull::ProbabilityMap::iterator i=probabilities.begin(); cout << "Probability is " << i->first << endl; #endif bool success = d->rules->reveal(probabilities.begin()->second); if ( !success ) { emit solvingDone(false); return false; } } if (_inOneStep) return solveStep(); else QTimer::singleShot(0, this, SLOT(solveStep())); return false; }
void Transient::takeStep(Real input_dt) { _picard_it = 0; _problem.backupMultiApps(EXEC_TIMESTEP_BEGIN); _problem.backupMultiApps(EXEC_TIMESTEP_END); while (_picard_it<_picard_max_its && _picard_converged == false) { if (_picard_max_its > 1) { _console << "\nBeginning Picard Iteration " << _picard_it << "\n" << std::endl; if (_picard_it == 0) // First Picard iteration - need to save off the initial nonlinear residual { _picard_initial_norm = _problem.computeResidualL2Norm(); _console << "Initial Picard Norm: " << _picard_initial_norm << '\n'; } } // For every iteration other than the first, we need to restore the state of the MultiApps if (_picard_it > 0) { _problem.restoreMultiApps(EXEC_TIMESTEP_BEGIN); _problem.restoreMultiApps(EXEC_TIMESTEP_END); } solveStep(input_dt); // If the last solve didn't converge then we need to exit this step completely (even in the case of Picard) // So we can retry... if (!lastSolveConverged()) return; if (_picard_max_its > 1) { _picard_timestep_end_norm = _problem.computeResidualL2Norm(); _console << "Picard Norm after TIMESTEP_END MultiApps: " << _picard_timestep_end_norm << '\n'; Real max_norm = std::max(_picard_timestep_begin_norm, _picard_timestep_end_norm); Real max_relative_drop = max_norm / _picard_initial_norm; if (max_norm < _picard_abs_tol || max_relative_drop < _picard_rel_tol) { _console << "Picard converged!" << std::endl; _picard_converged = true; return; } } ++_picard_it; } }
bool Solver::initSolve(bool oneStep, bool noGuess) { _inOneStep = oneStep; _noGuess = noGuess; delete d->facts; d->facts = new AdviseFast::FactSet(_field); delete d->rules; d->rules = new AdviseFast::RuleSet(d->facts); #ifdef DEBUG d->t0 = time(0); #endif return solveStep(); }
void Transient::takeStep(Real input_dt) { _picard_it = 0; while (_picard_it<_picard_max_its && _picard_converged == false) { if (_picard_max_its > 1) _console << "Beginning Picard Iteration " << _picard_it << "\n" << std::endl; solveStep(input_dt); ++_picard_it; } }
// Try to over-ride reseting the sub-apps void AutoRBTransient::takeStep(Real input_dt) { _picard_it = 0; _problem.backupMultiApps(EXEC_TIMESTEP_BEGIN); _problem.backupMultiApps(EXEC_TIMESTEP_END); //his_initial_norm_old = getPostprocessorValue("InitialResidual"); // _console << "Update his_old_initial \n" << std::endl; while (_picard_it<_picard_max_its && _picard_converged == false) { if (_picard_max_its > 1) { _console << "\nBeginning Picard Iteration " << _picard_it << "\n" << std::endl; Real _current_norm = _problem.computeResidualL2Norm(); if (_picard_it == 0) // First Picard iteration - need to save off the initial nonlinear residual { _picard_initial_norm = _current_norm; _console << "Initial Picard Norm: " << _picard_initial_norm << '\n'; } } // For every iteration other than the first, we need to restore the state of the MultiApps if (_picard_it > 0) { // This is supposed to regain the previous behavior //_problem.restoreMultiApps(EXEC_TIMESTEP_BEGIN); //_problem.restoreMultiApps(EXEC_TIMESTEP_END); } solveStep(input_dt); /* // Remove this check, we check at the beginning of solveStep. // We could reformulate this check like the other, but I don't think we gain anything. if (_picard_max_its > 1) { _picard_timestep_end_norm = _problem.computeResidualL2Norm(); _console << "Picard Norm after TIMESTEP_END MultiApps: " << _picard_timestep_end_norm << '\n'; Real max_norm = std::max(_picard_timestep_begin_norm, _picard_timestep_end_norm); Real max_relative_drop = max_norm / _picard_initial_norm; if (max_norm < _picard_abs_tol || max_relative_drop < _picard_rel_tol) { _console << "Picard converged!" << std::endl; _picard_converged = true; return; } } */ ++_picard_it; } }