ZeroDimensionalRythmosModelInterface.hpp 6.12 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
//@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
Cristiano Malossi's avatar
Cristiano Malossi committed
29
 *  @brief Rythmos Model Interface
30
 *  @version alpha (experimental)
31
32
33
34
 *
 *  @date 21-11-2011
 *  @author Mahmoud Jafargholi
 *
35
36
 *  @contributors Cristiano Malossi <cristiano.malossi@epfl.ch>
 *  @mantainer    Cristiano Malossi <cristiano.malossi@epfl.ch>
37
38
39
40
41
 */

#ifndef ZeroDimensionalRythmosModelInterface_H
#define ZeroDimensionalRythmosModelInterface_H 1

42
// Include definitions
43
#include <lifev/zero_dimensional/solver/ZeroDimensionalDefinitions.hpp>
44
45
46

#if ( defined(HAVE_NOX_THYRA) && defined(HAVE_TRILINOS_RYTHMOS) )

47
48
49
50
51
52
53
54
55
56
// Tell the compiler to ignore specific kind of warnings:
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"

#include <NOX.H>
#include <NOX_Epetra.H>
#include <NOX_Epetra_Interface_Required.H> // base class
#include <NOX_Epetra_Interface_Jacobian.H> // base class
#include <NOX_Epetra_Interface_Preconditioner.H> // base class
#include <NOX_Thyra.H>
57

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

62
// LIFEV
63
#include <lifev/zero_dimensional/solver/ZeroDimensionalCircuitData.hpp>
64

65
66
67
68
69
70
namespace NOX
{
    namespace Parameter
    {
        class List;
    }
71
72
73
}
namespace LifeV
{
74

75
76
77
78
79
80
    //! Rhytmos model interface.
    /*!
     * Rhytmos solver interface will communicate with this class.
     * this class have access to circuit data. The main task of this class is to
     * provide the residual and jacobian at every step to Rhythmos solver interface.
     */
81
class RythmosModelInterface : public NOX::Epetra::Interface::Required,
82
83
84
public NOX::Epetra::Interface::Jacobian,
public NOX::Epetra::Interface::Preconditioner
{
85
86
public:

87
88
    //! Constructor
    RythmosModelInterface(Int NumGlobalElements, Epetra_Comm* comm, zeroDimensionalCircuitDataPtr_Type circuitData);
89

90
91
    //! Destructor
    virtual ~RythmosModelInterface();
92

93
94
    //! This method is empty.
    virtual bool computeF(const Epetra_Vector& x, Epetra_Vector& FVec, FillType fillType = Residual);
95

96
97
    //! This method is empty.
    virtual bool computeJacobian(const Epetra_Vector& x, Epetra_Operator& Jac);
98

99
100
    //! This method is empty
    virtual bool computePrecMatrix(const Epetra_Vector& x);
101

102
103
    //! This method is empty
    virtual bool computePreconditioner(const Epetra_Vector& x, Epetra_Operator& Prec, Teuchos::ParameterList* precParams = 0);
104

105
106
    //! get solution vector
    Epetra_Vector& getSolutionY();
107

108
109
    //! get derivative of solution vector respect to time
    Epetra_Vector& getSolutionYp();
110

111
    Epetra_Map& getMap();
112

113
    Epetra_CrsGraph& getGraph();
114

115
116
    //! this method empty.
    virtual bool evaluate(Real t, const Epetra_Vector* x, Epetra_Vector* f );
117

118
119
    //! compute Implicit residual.
    virtual bool evaluateFImplicit(const Real& t, const Epetra_Vector* x,const Epetra_Vector* x_dot, Epetra_Vector* f );
120

121
122
    //! compute jacobian.
    virtual bool evaluateWImplicit(const Real& t, const Real& alpha,const Real& beta,const Epetra_Vector* x, const Epetra_Vector* x_dot, Epetra_CrsMatrix* W );
123

124
    virtual bool initializeSolnY();
125

126
    bool initializeSolnY(const vectorEpetra_Type& y);
127

128
    virtual bool initializeSolnYp();
129

130
    bool initializeSolnYp(const vectorEpetra_Type& yp);
131

132
133
    //! hafter complete Rythmos step, this method will update circuit data.
    void extractSolution(const Real &t1,const vectorEpetra_Type& y , const vectorEpetra_Type& yp );
134

135
    Int numCircuitElements() { return M_numCircuitElements; }
136
137

protected:
138
    Int                                             M_numCircuitElements; // Total Number of elements
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
    Int                                             M_numMyElements; // Number of elements owned by this process
    Int                                             M_myPID; // Process number
    Int                                             M_numProc; // Total number of processes

    Epetra_CrsGraph*                                M_graph;
    boost::shared_ptr<Epetra_CrsGraph>              M_graphSharedPtr;
    Epetra_Comm*                                    M_comm;
    boost::shared_ptr<Epetra_Comm>                  M_commSharedPtr;
    Epetra_Map*                                     M_standardMap;
    Epetra_Vector*                                  M_initialSolutionY;
    Epetra_Vector*                                  M_initialSolutionYp;

    zeroDimensionalCircuitDataPtr_Type              M_circuitData;
    matrixPtr_Type                                  M_A;
    matrixPtr_Type                                  M_B;
    vectorPtr_Type                                  M_C;
    vectorEpetraPtr_Type                            M_Y0;
    vectorEpetraPtr_Type                            M_Yp0;
    boost::shared_ptr<MapEpetra>                    M_mapEpetraPtr;
    vectorEpetraPtr_Type                            M_fA;//dummy variable
    vectorEpetraPtr_Type                            M_fB;//dummy variable
160
};
161
162
163

typedef boost::shared_ptr< RythmosModelInterface >  rythmosModelInterfacePtr_Type;
typedef Teuchos::RCP< RythmosModelInterface >       rythmosModelInterfacePtrRCP_Type;
164
165
} // LifeV namespace

166
167
#endif /* HAVE_NOX_THYRA && HAVE_TRILINOS_RYTHMOS */

168
#endif //ZeroDimensionalRythmosModelInterface_H