SolverPolicyLinearSolver.hpp 3.48 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//@HEADER
/*
*******************************************************************************

    Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
    Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University

    This file is part of LifeV.

    LifeV is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    LifeV is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with LifeV.  If not, see <http://www.gnu.org/licenses/>.

*******************************************************************************
*/
//@HEADER

/*!
    @file SolverPolicyLinearSolver class
    @brief This class contains all the informations necessary
           to solve a linear system

    @author Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
    @date 07-12-2012
 */

#ifndef SOLVERPOLICYLINEARSOLVER_HPP
#define SOLVERPOLICYLINEARSOLVER_HPP

#include <iostream>
#include <boost/shared_ptr.hpp>

// Tell the compiler to ignore specific kind of warnings:
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"

#ifdef HAVE_MPI
#include <Epetra_MpiComm.h>
#else
#include <Epetra_SerialComm.h>
#endif

#include <Teuchos_ParameterList.hpp>
#include <Teuchos_XMLParameterListHelpers.hpp>
#include <Teuchos_RCP.hpp>

//Tell the compiler to restore the warning previously silented
#pragma GCC diagnostic warning "-Wunused-variable"
#pragma GCC diagnostic warning "-Wunused-parameter"

#include <lifev/core/LifeV.hpp>
#include <lifev/core/array/MatrixEpetra.hpp>
#include <lifev/core/array/VectorEpetra.hpp>
#include <lifev/core/util/Displayer.hpp>
#include <lifev/core/algorithm/LinearSolver.hpp>
#include <lifev/core/algorithm/Preconditioner.hpp>


namespace LifeV
{

struct SolverPolicyLinearSolver
{
public:
    typedef MatrixEpetra<Real>                       matrix_Type;
    typedef boost::shared_ptr<matrix_Type>           matrixPtr_Type;
    typedef VectorEpetra                             vector_Type;
    typedef boost::shared_ptr<VectorEpetra>          vectorPtr_Type;
    typedef Epetra_Comm                              comm_Type;
    typedef boost::shared_ptr<comm_Type>             commPtr_Type;
    typedef LinearSolver                             solver_Type;
    typedef boost::shared_ptr< solver_Type >         solverPtr_Type;
    typedef Preconditioner                           preconditioner_Type;
    typedef boost::shared_ptr<preconditioner_Type>   preconditionerPtr_Type;

    //! Method to set a preconditioner
    /*!
        @param preconditionerPtr Preconditioner to be used to solve the system
     */
    void setPreconditioner ( preconditionerPtr_Type preconditionerPtr );

    //! Method to get a preconditioner
    preconditionerPtr_Type preconditioner();

protected:
    void initSolver ( Teuchos::ParameterList& list );

    int solve ( matrixPtr_Type systemMatrix,
                vectorPtr_Type rhs,
                vectorPtr_Type solution );
    solverPtr_Type M_solver;

    virtual Displayer displayer() = 0;
    virtual commPtr_Type comm() = 0;
};

} // namespace LifeV

#endif /* EXPORTERPOLICYHDF5_HPP */