https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: e421f05eb65c8a2efadfcb5c216385a977791e63 authored by wenqing on 13 June 2023, 11:31:41 UTC
Merge branch 'imprv_fixed_stress' into 'master'
Tip revision: e421f05
EquationSystem.h
/**
 * \file
 * \copyright
 * Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#pragma once

#include "MathLib/LinAlg/MatrixSpecifications.h"

namespace NumLib
{
//! \addtogroup ODESolver
//! @{

//! Status flags telling the NonlinearSolver if an iteration succeeded.
enum class IterationResult : char
{
    SUCCESS,
    FAILURE,
    REPEAT_ITERATION
};

/*! Collection of basic methods every equation system must provide.
 */
class EquationSystem
{
public:
    /*! Check whether this is actually a linear equation system.
     *
     * \remark
     * Depending on its parameters an in general nonlinear equation system
     * can be linear in special cases. With this method it is possible to
     * detect that at runtime and thus save some computations.
     */
    virtual bool isLinear() const = 0;

    /*! Prepares a new iteration in the solution process of this equation.
     *
     * \param iter the current iteration number, starting from 1.
     * \param x    the current approximate solution of the equation.
     */
    virtual void preIteration(const unsigned iter, GlobalVector const& x)
    {
        (void)iter;
        (void)x;  // by default do nothing
    }

    /*! Post-processes an iteration in the solution process of this equation.
     *
     * \param x the current approximate solution of the equation.
     *
     * \return A status flag indicating id the current iteration succeeded.
     */
    virtual IterationResult postIteration(GlobalVector const& x)
    {
        (void)x;  // by default do nothing
        return IterationResult::SUCCESS;
    }

    virtual MathLib::MatrixSpecifications getMatrixSpecifications(
        const int process_id) const = 0;

    virtual ~EquationSystem() = default;
};

//! @}
}  // namespace NumLib
back to top