LifeV
ZeroDimensionalRythmosSolverInterface.cpp
Go to the documentation of this file.
1
//@HEADER
2
/*
3
*******************************************************************************
4
5
Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6
Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7
8
This file is part of LifeV.
9
10
LifeV is free software; you can redistribute it and/or modify
11
it under the terms of the GNU Lesser General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
14
15
LifeV is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public License
21
along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22
23
*******************************************************************************
24
*/
25
//@HEADER
26
27
/*!
28
* @file
29
* @brief Rythmos solver Interface.
30
*
31
* @date 21-11-2011
32
* @author Mahmoud Jafargholi
33
*
34
* @contributors Cristiano Malossi <cristiano.malossi@epfl.ch>
35
* @mantainer Cristiano Malossi <cristiano.malossi@epfl.ch>
36
*/
37
38
#
include
<
lifev
/
zero_dimensional
/
solver
/
ZeroDimensionalRythmosSolverInterface
.
hpp
>
39
40
namespace
LifeV
41
{
42
43
#
if
(
defined
(
HAVE_NOX_THYRA
)
&&
defined
(
HAVE_TRILINOS_RYTHMOS
)
)
44
// ===================================================
45
// Constructors
46
// ===================================================
47
RythmosSolverInterface
::
RythmosSolverInterface
(
Int
numCircuitElements
,
48
Teuchos
::
RCP
<
Epetra_Comm
>&
epetra_comm_ptr
,
49
rythmosModelInterfacePtrRCP_Type
theModel
) :
50
M_epetraCommPtr
(
epetra_comm_ptr
),
M_numElements
(
numCircuitElements
),
M_problemInterfacePtr
(
theModel
),
M_comm
(
epetra_comm_ptr
)
51
{
52
initialize
();
53
}
54
55
void
RythmosSolverInterface
::
initialize
()
56
{
57
M_epetraMapPtr
=
Teuchos
::
rcp
(
new
Epetra_Map
(
M_problemInterfacePtr
->
getMap
() ) );
58
M_Wgraph
=
Teuchos
::
rcp
(
new
Epetra_CrsGraph
(
M_problemInterfacePtr
->
getGraph
() ) );
59
}
60
61
// Overridden from EpetraExt::ModelEvaluator
62
Teuchos
::
RCP
<
const
Epetra_Map
>
RythmosSolverInterface
::
get_x_map
()
const
63
{
64
return
M_epetraMapPtr
;
65
}
66
67
Teuchos
::
RCP
<
const
Epetra_Map
>
RythmosSolverInterface
::
get_f_map
()
const
68
{
69
return
M_epetraMapPtr
;
70
}
71
72
Teuchos
::
RCP
<
const
Epetra_Vector
>
RythmosSolverInterface
::
get_x_init
()
const
73
{
74
Epetra_Vector
&
soln
=
M_problemInterfacePtr
->
getSolutionY
();
75
Teuchos
::
RCP
<
Epetra_Vector
>
x_init
=
Teuchos
::
rcp
(
new
Epetra_Vector
(
soln
) );
76
return
x_init
;
77
}
78
79
Teuchos
::
RCP
<
const
Epetra_Vector
>
RythmosSolverInterface
::
get_x_dot_init
()
const
80
{
81
Epetra_Vector
&
soln
=
M_problemInterfacePtr
->
getSolutionYp
();
82
Teuchos
::
RCP
<
Epetra_Vector
>
x_dot_init
=
Teuchos
::
rcp
(
new
Epetra_Vector
(
soln
) );
83
return
x_dot_init
;
84
}
85
86
Teuchos
::
RCP
<
Epetra_Operator
>
RythmosSolverInterface
::
create_W
()
const
87
{
88
Teuchos
::
RCP
<
Epetra_Operator
>
W
=
Teuchos
::
rcp
(
new
Epetra_CrsMatrix
( ::
Copy
,
89
*
M_Wgraph
) );
90
return
W
;
91
}
92
93
EpetraExt
::
ModelEvaluator
::
InArgs
RythmosSolverInterface
::
createInArgs
()
const
94
{
95
InArgsSetup
inArgs
;
96
inArgs
.
setSupports
(
IN_ARG_x
,
true
);
97
inArgs
.
setSupports
(
IN_ARG_x_dot
,
true
);
98
inArgs
.
setSupports
(
IN_ARG_alpha
,
true
);
99
inArgs
.
setSupports
(
IN_ARG_beta
,
true
);
100
inArgs
.
setSupports
(
IN_ARG_t
,
true
);
101
return
inArgs
;
102
}
103
104
EpetraExt
::
ModelEvaluator
::
OutArgs
RythmosSolverInterface
::
createOutArgs
()
const
105
{
106
OutArgsSetup
outArgs
;
107
outArgs
.
setSupports
(
OUT_ARG_f
,
true
);
108
outArgs
.
setSupports
(
OUT_ARG_W
,
true
);
109
outArgs
.
setSupports
(
OUT_ARG_W
,
true
);
110
outArgs
.
set_W_properties
(
DerivativeProperties
(
DERIV_LINEARITY_NONCONST
,
DERIV_RANK_UNKNOWN
,
true
) );
111
return
outArgs
;
112
}
113
114
void
RythmosSolverInterface
::
evalModel
(
const
InArgs
&
inArgs
,
115
const
OutArgs
&
outArgs
)
const
116
{
117
Teuchos
::
RCP
<
const
Epetra_Vector
>
x
=
inArgs
.
get_x
();
118
Teuchos
::
RCP
<
const
Epetra_Vector
>
xdot
=
inArgs
.
get_x_dot
();
119
Real
t
=
inArgs
.
get_t
();
120
121
#
ifdef
HAVE_LIFEV_DEBUG
122
std
::
cout
<<
"RythmosSolverInterface::evalModel ---------------------------{"
<<
std
::
endl
;
123
std
::
cout
<<
"x = "
<<
std
::
endl
;
124
x
->
Print
(
std
::
cout
);
125
std
::
cout
<<
"xdot = "
<<
std
::
endl
;
126
xdot
->
Print
(
std
::
cout
);
127
#
endif
// HAVE_LIFEV_DEBUG
128
129
Teuchos
::
RCP
<
Epetra_Vector
>
f
;
130
if
( (
f
=
outArgs
.
get_f
() ).
get
() )
131
{
132
M_problemInterfacePtr
->
evaluateFImplicit
(
t
, &*
x
, &*
xdot
, &*
f
);
133
#
ifdef
HAVE_LIFEV_DEBUG
134
std
::
cout
<<
"f = "
<<
std
::
endl
;
135
f
->
Print
(
std
::
cout
);
136
#
endif
// HAVE_LIFEV_DEBUG
137
138
}
139
Teuchos
::
RCP
<
Epetra_Operator
>
W
;
140
if
( (
W
=
outArgs
.
get_W
() ).
get
() )
141
{
142
const
Real
alpha
=
inArgs
.
get_alpha
();
143
const
Real
beta
=
inArgs
.
get_beta
();
144
Epetra_CrsMatrix
&
jac
=
Teuchos
::
dyn_cast
<
Epetra_CrsMatrix
> ( *
W
);
145
M_problemInterfacePtr
->
evaluateWImplicit
(
t
,
alpha
,
beta
, &*
x
, &*
xdot
, &
jac
);
146
#
ifdef
HAVE_LIFEV_DEBUG
147
std
::
cout
<<
"jac = "
<<
std
::
endl
;
148
jac
.
Print
(
std
::
cout
);
149
#
endif
// HAVE_LIFEV_DEBUG
150
}
151
#
ifdef
HAVE_LIFEV_DEBUG
152
std
::
cout
<<
"RythmosSolverInterface::evalModel ---------------------------}"
<<
std
::
endl
;
153
#
endif
// HAVE_LIFEV_DEBUG
154
}
155
156
#
endif
/* HAVE_NOX_THYRA && HAVE_TRILINOS_RYTHMOS */
157
158
}
// LifeV namespace
ETCurrentFE::updateInverseJacobian
void updateInverseJacobian(const UInt &iQuadPt)
Definition:
ETCurrentFE.cpp:405
lifev-release-doc
lifev
zero_dimensional
solver
ZeroDimensionalRythmosSolverInterface.cpp
Generated on Wed Mar 7 2018 19:51:04 for LifeV by
1.8.13