Esempio n. 1
0
void ConvergenceCriterionResidual::checkResidual(const GlobalVector& residual)
{
    auto norm_res = MathLib::LinAlg::norm(residual, _norm_type);

    if (_is_first_iteration) {
        INFO("Convergence criterion: |r0|=%.4e", norm_res);
        _residual_norm_0 = norm_res;
    } else {
        INFO("Convergence criterion: |r|=%.4e |r0|=%.4e |r|/|r0|=%.4e",
             norm_res, _residual_norm_0, norm_res / _residual_norm_0);
    }

    bool satisfied_abs = false;
    bool satisfied_rel = false;

    if (_abstol) {
        satisfied_abs = norm_res < *_abstol;
    }
    if (_reltol && !_is_first_iteration) {
        satisfied_rel =
            checkRelativeTolerance(*_reltol, norm_res, _residual_norm_0);
    }

    _satisfied = _satisfied && (satisfied_abs || satisfied_rel);
}
Esempio n. 2
0
void ConvergenceCriterionPerComponentDeltaX::checkDeltaX(
    const GlobalVector& minus_delta_x, GlobalVector const& x)
{
    if ((!_dof_table) || (!_mesh))
        OGS_FATAL("D.o.f. table or mesh have not been set.");

    bool satisfied_abs = true;
    bool satisfied_rel = true;

    for (unsigned global_component = 0; global_component < _abstols.size();
         ++global_component)
    {
        // TODO short cut if tol <= 0.0
        auto error_dx = norm(minus_delta_x, global_component, _norm_type,
                             *_dof_table, *_mesh);
        auto norm_x =
            norm(x, global_component, _norm_type, *_dof_table, *_mesh);

        INFO(
            "Convergence criterion, component %u: |dx|=%.4e, |x|=%.4e, "
            "|dx|/|x|=%.4e",
            error_dx, global_component, norm_x, error_dx / norm_x);

        satisfied_abs = satisfied_abs && error_dx < _abstols[global_component];
        satisfied_rel =
            satisfied_rel && checkRelativeTolerance(_reltols[global_component],
                                                    error_dx, norm_x);
    }

    _satisfied = _satisfied && (satisfied_abs || satisfied_rel);
}
void ConvergenceCriterionPerComponentResidual::checkResidual(
    const GlobalVector& residual)
{
    if ((!_dof_table) || (!_mesh))
    {
        OGS_FATAL("D.o.f. table or mesh have not been set.");
    }

    bool satisfied_abs = true;
    // Make sure that in the first iteration the relative residual tolerance is
    // not satisfied.
    bool satisfied_rel = !_is_first_iteration;

    for (unsigned global_component = 0; global_component < _abstols.size();
         ++global_component)
    {
        // TODO short cut if tol <= 0.0
        auto norm_res = norm(residual, global_component, _norm_type,
                             *_dof_table, *_mesh);

        if (_is_first_iteration) {
            INFO("Convergence criterion, component %u: |r0|=%.4e", global_component, norm_res);
            _residual_norms_0[global_component] = norm_res;
        } else {
            auto const norm_res0 = _residual_norms_0[global_component];
            INFO(
                "Convergence criterion, component %u: |r|=%.4e, |r0|=%.4e, "
                "|r|/|r0|=%.4e",
                global_component, norm_res, norm_res0,
                (norm_res0 == 0. ? std::numeric_limits<double>::quiet_NaN()
                                 : (norm_res / norm_res0)));
        }

        satisfied_abs = satisfied_abs && norm_res < _abstols[global_component];
        satisfied_rel =
            satisfied_rel &&
            checkRelativeTolerance(_reltols[global_component], norm_res,
                                   _residual_norms_0[global_component]);
    }

    _satisfied = _satisfied && (satisfied_abs || satisfied_rel);
}
Esempio n. 4
0
void ConvergenceCriterionDeltaX::checkDeltaX(const GlobalVector& minus_delta_x,
                                             GlobalVector const& x)
{
    auto error_dx = MathLib::LinAlg::norm(minus_delta_x, _norm_type);
    auto norm_x = MathLib::LinAlg::norm(x, _norm_type);

    INFO("Convergence criterion: |dx|=%.4e, |x|=%.4e, |dx|/|x|=%.4e", error_dx,
         norm_x, error_dx / norm_x);

    bool satisfied_abs = false;
    bool satisfied_rel = false;

    if (_abstol) {
        satisfied_abs = error_dx < *_abstol;
    }
    if (_reltol) {
        satisfied_rel = checkRelativeTolerance(*_reltol, error_dx, norm_x);
    }

    _satisfied = _satisfied && (satisfied_abs || satisfied_rel);
}