SolverInterface.h 2.19 KB
Newer Older
Dmitry Bagaev's avatar
Dmitry Bagaev committed
1
2
#ifndef INMOST_SOLVER_INTERFACE_H
#define INMOST_SOLVER_INTERFACE_H
Dmitry Bagaev's avatar
Dmitry Bagaev committed
3
4

#include <string>
Dmitry Bagaev's avatar
Dmitry Bagaev committed
5
#include <sstream>
Dmitry Bagaev's avatar
Dmitry Bagaev committed
6
7
#include "inmost_sparse.h"

Kirill Terekhov's avatar
Kirill Terekhov committed
8
#define SILENCE_SET_PARAMETER
Dmitry Bagaev's avatar
Dmitry Bagaev committed
9
#if defined(USE_SOLVER)
10
namespace INMOST {
Dmitry Bagaev's avatar
Dmitry Bagaev committed
11

Dmitry Bagaev's avatar
Dmitry Bagaev committed
12
13
    class SolverParameters {
    public:
Dmitry Bagaev's avatar
Dmitry Bagaev committed
14
15
16
        std::string solverName;
        std::string solverPrefix;
        std::string internalFile;
Dmitry Bagaev's avatar
Dmitry Bagaev committed
17
18
19
20
21
22
23
24
25
26
27

        std::vector<std::pair<std::string, std::string> > parameters;

        SolverParameters(std::string solverName, std::string solverPrefix, std::string internalFile);
        SolverParameters(const SolverParameters &other);

        ~SolverParameters();
    };

    typedef std::vector<std::pair<std::string, std::string> >::iterator parameters_iterator_t;

Dmitry Bagaev's avatar
Dmitry Bagaev committed
28
29
30
31
    class SolverInterface {
    protected:
        INMOST_MPI_Comm communicator;
    public:
Dmitry Bagaev's avatar
Dmitry Bagaev committed
32
        SolverInterface() {};
Dmitry Bagaev's avatar
Dmitry Bagaev committed
33

Dmitry Bagaev's avatar
Dmitry Bagaev committed
34
        virtual SolverInterface *Copy(const SolverInterface *other) = 0;
Dmitry Bagaev's avatar
Dmitry Bagaev committed
35
36

        virtual void Assign(const SolverInterface *other) = 0;
Dmitry Bagaev's avatar
Dmitry Bagaev committed
37

Dmitry Bagaev's avatar
Dmitry Bagaev committed
38
        virtual void Setup(int *argc, char ***argv, SolverParameters &p) = 0;
Dmitry Bagaev's avatar
Dmitry Bagaev committed
39
40
41
42
43

        virtual void SetMatrix(Sparse::Matrix &A, bool ModifiedPattern, bool OldPreconditioner) = 0;

        virtual bool Solve(INMOST::Sparse::Vector &RHS, INMOST::Sparse::Vector &SOL) = 0;

Dmitry Bagaev's avatar
Dmitry Bagaev committed
44
45
46
47
        virtual bool Clear() = 0;

        virtual bool isMatrixSet() = 0;

Dmitry Bagaev's avatar
Dmitry Bagaev committed
48
        virtual std::string GetParameter(std::string name) const = 0;
Dmitry Bagaev's avatar
Dmitry Bagaev committed
49

Dmitry Bagaev's avatar
Dmitry Bagaev committed
50
        virtual void SetParameter(std::string name, std::string value) = 0;
Dmitry Bagaev's avatar
Dmitry Bagaev committed
51

52
        virtual INMOST_DATA_ENUM_TYPE Iterations() const = 0;
Dmitry Bagaev's avatar
Dmitry Bagaev committed
53

54
        virtual INMOST_DATA_REAL_TYPE Residual() const = 0;
Dmitry Bagaev's avatar
Dmitry Bagaev committed
55

Dmitry Bagaev's avatar
Dmitry Bagaev committed
56
57
58
59
60
        virtual const std::string ReturnReason() const = 0;

        virtual const std::string SolverName() const = 0;

        virtual void Finalize() = 0;
Dmitry Bagaev's avatar
Dmitry Bagaev committed
61

Dmitry Bagaev's avatar
Dmitry Bagaev committed
62
63
64
65
        virtual const INMOST_DATA_REAL_TYPE Condest(INMOST_DATA_REAL_TYPE tol, INMOST_DATA_ENUM_TYPE maxiter) {
            throw INMOST::SolverUnsupportedOperation;
        };

Dmitry Bagaev's avatar
Dmitry Bagaev committed
66
67
68
69
70
71
72
73
74
        virtual ~SolverInterface() {};

        void SetCommunicator(INMOST_MPI_Comm _communicator) {
            communicator = _communicator;
        }

        INMOST_MPI_Comm GetCommunicator() {
            return communicator;
        }
Dmitry Bagaev's avatar
Dmitry Bagaev committed
75

Dmitry Bagaev's avatar
Dmitry Bagaev committed
76
77
78
    };

}
79
#endif //USE_SOLVER
Dmitry Bagaev's avatar
Dmitry Bagaev committed
80
81


Dmitry Bagaev's avatar
Dmitry Bagaev committed
82
#endif //INMOST_SOLVER_INTERFACE_H