LifeV
ZeroDimensionalRythmosModelInterface.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 Model 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
/
ZeroDimensionalRythmosModelInterface
.
hpp
>
39
40
namespace
LifeV
41
{
42
43
#
if
(
defined
(
HAVE_NOX_THYRA
)
&&
defined
(
HAVE_TRILINOS_RYTHMOS
)
)
44
// ===================================================
45
// Constructors
46
// ===================================================
47
RythmosModelInterface
::
RythmosModelInterface
(
Int
numCircuitElements
,
48
Epetra_Comm
*
comm
,
49
zeroDimensionalCircuitDataPtr_Type
circuitData
) :
50
M_numCircuitElements
(
numCircuitElements
),
M_numMyElements
( 0 ),
M_myPID
(
comm
->
MyPID
() ),
M_numProc
(
comm
->
NumProc
() ),
51
52
M_standardMap
( 0 ),
M_initialSolutionY
( 0 ),
M_initialSolutionYp
( 0 ),
M_circuitData
(
circuitData
)
53
{
54
M_comm
=
comm
->
Clone
();
55
( *
M_comm
).
PrintInfo
(
std
::
cout
);
56
M_commSharedPtr
.
reset
(
M_comm
);
57
M_mapEpetraPtr
.
reset
(
new
MapEpetra
(
M_numCircuitElements
,
58
M_commSharedPtr
) );
59
M_standardMap
= (
M_mapEpetraPtr
->
map
(
Unique
) ).
get
();
60
M_numMyElements
=
M_standardMap
->
NumMyElements
();
61
M_A
.
reset
(
new
matrix_Type
( *
M_mapEpetraPtr
,
62
M_numCircuitElements
) );
63
M_B
.
reset
(
new
matrix_Type
( *
M_mapEpetraPtr
,
64
M_numCircuitElements
) );
65
66
for
(
Int
i
= 0;
i
<
M_numCircuitElements
;
i
++ )
67
{
68
for
(
Int
j
= 0;
j
<
M_numCircuitElements
;
j
++ )
69
{
70
M_A
->
addToCoefficient
(
i
,
j
, 1.0 );
71
M_B
->
addToCoefficient
(
i
,
j
, 1.0 );
72
}
73
}
74
M_A
->
globalAssemble
();
75
M_B
->
globalAssemble
();
76
77
M_graph
=
new
Epetra_CrsGraph
(
M_A
->
matrixPtr
()->
Graph
() );
78
M_graphSharedPtr
.
reset
(
M_graph
);
79
M_C
.
reset
(
new
vector_Type
( *
M_mapEpetraPtr
) );
80
81
M_fA
.
reset
(
new
vectorEpetra_Type
( *
M_standardMap
) );
82
M_fB
.
reset
(
new
vectorEpetra_Type
( *
M_standardMap
) );
83
84
M_Y0
.
reset
(
new
vectorEpetra_Type
( *
M_standardMap
) );
85
M_Yp0
.
reset
(
new
vectorEpetra_Type
( *
M_standardMap
) );
86
87
M_initialSolutionY
=
M_Y0
.
get
();
88
M_initialSolutionYp
=
M_Yp0
.
get
();
89
;
90
initializeSolnY
();
91
initializeSolnYp
();
92
}
93
94
// Destructor
95
RythmosModelInterface
::~
RythmosModelInterface
()
96
{
97
98
M_circuitData
.
reset
();
99
M_mapEpetraPtr
.
reset
();
100
M_graphSharedPtr
.
reset
();
101
M_A
.
reset
();
102
M_B
.
reset
();
103
M_C
.
reset
();
104
M_Y0
.
reset
();
105
M_Yp0
.
reset
();
106
}
107
108
bool
RythmosModelInterface
::
computeF
(
__attribute__
( (
unused
) )
const
Epetra_Vector
&
x
,
109
__attribute__
( (
unused
) )
Epetra_Vector
&
FVec
,
110
__attribute__
( (
unused
) )
NOX
::
Epetra
::
Interface
::
Required
::
FillType
fillType
)
111
{
112
std
::
cout
<<
"Warning: I should not be here, 0D, Rythmos Model Interface"
;
113
return
false
;
114
}
115
116
bool
RythmosModelInterface
::
computeJacobian
(
__attribute__
( (
unused
) )
const
Epetra_Vector
&
x
,
117
__attribute__
( (
unused
) )
Epetra_Operator
&
my_Jac
)
118
{
119
std
::
cout
<<
"Warning: I should not be here, 0D, Rythmos Model Interface"
;
120
return
false
;
121
}
122
123
bool
RythmosModelInterface
::
computePrecMatrix
(
__attribute__
( (
unused
) )
const
Epetra_Vector
&
x
)
124
{
125
std
::
cout
<<
"Warning: I should not be here, 0D, Rythmos Model Interface"
;
126
return
false
;
127
}
128
bool
RythmosModelInterface
::
computePreconditioner
(
__attribute__
( (
unused
) )
const
Epetra_Vector
&
x
,
129
__attribute__
( (
unused
) )
Epetra_Operator
&
my_Prec
,
130
__attribute__
( (
unused
) )
Teuchos
::
ParameterList
*
precParams
)
131
{
132
cout
<<
"ERROR: Interface::preconditionVector() "
<<
endl
;
133
std
::
cout
<<
"Error: I should not be here, 0D, Rythmos Model Interface"
;
134
throw
"Interface Error"
;
135
}
136
137
bool
RythmosModelInterface
::
evaluate
(
__attribute__
( (
unused
) )
Real
t
,
138
__attribute__
( (
unused
) )
const
Epetra_Vector
*
x
,
139
__attribute__
( (
unused
) )
Epetra_Vector
*
f
)
140
{
141
std
::
cout
<<
"Warning: I should not be here. 0D, Rythmos Inreface, ::evaluate"
<<
std
::
endl
;
142
return
true
;
143
}
144
145
Epetra_Vector
&
RythmosModelInterface
::
getSolutionY
()
146
{
147
return
*
M_initialSolutionY
;
148
}
149
150
Epetra_Vector
&
RythmosModelInterface
::
getSolutionYp
()
151
{
152
return
*
M_initialSolutionYp
;
153
}
154
155
Epetra_Map
&
RythmosModelInterface
::
getMap
()
156
{
157
return
*
M_standardMap
;
158
}
159
160
bool
RythmosModelInterface
::
initializeSolnY
()
161
{
162
M_initialSolutionY
->
PutScalar
( 0 );
163
return
true
;
164
}
165
166
bool
RythmosModelInterface
::
initializeSolnY
(
const
vectorEpetra_Type
&
y
)
167
{
168
( *
M_initialSolutionY
) =
y
;
169
return
true
;
170
}
171
172
bool
RythmosModelInterface
::
initializeSolnYp
(
const
vectorEpetra_Type
&
yp
)
173
{
174
( *
M_initialSolutionYp
) =
yp
;
175
return
true
;
176
}
177
178
bool
RythmosModelInterface
::
initializeSolnYp
()
179
{
180
M_initialSolutionYp
->
PutScalar
( 0 );
181
return
true
;
182
}
183
Epetra_CrsGraph
&
RythmosModelInterface
::
getGraph
()
184
{
185
return
*
M_graph
;
186
}
187
188
bool
RythmosModelInterface
::
evaluateFImplicit
(
const
Real
&
t
,
189
const
Epetra_Vector
*
x
,
190
const
Epetra_Vector
*
x_dot
,
191
Epetra_Vector
*
f
)
192
{
193
194
//updateCircuitData from Y and Yp
195
#
ifdef
HAVE_LIFEV_DEBUG
196
x
->
Print
(
std
::
cout
);
197
x_dot
->
Print
(
std
::
cout
);
198
#
endif
199
M_circuitData
->
updateCircuitDataFromY
(
t
,
200
x
,
201
x_dot
);
202
M_circuitData
->
updateABC
( *
M_A
,
203
*
M_B
,
204
*
M_C
);
205
//calculate the sum
206
#
ifdef
HAVE_LIFEV_DEBUG
207
M_A
->
matrixPtr
()->
Print
(
std
::
cout
);
208
M_B
->
matrixPtr
()->
Print
(
std
::
cout
);
209
M_C
->
epetraVector
().
Print
(
std
::
cout
);
210
#
endif
211
212
M_A
->
matrixPtr
()->
Multiply1
(
false
,
213
*
x_dot
,
214
*
M_fA
);
215
#
ifdef
HAVE_LIFEV_DEBUG
216
M_A
->
matrixPtr
()->
Print
(
std
::
cout
);
217
#
endif
218
219
M_B
->
matrixPtr
()->
Multiply1
(
false
,
220
*
x
,
221
*
M_fB
);
222
#
ifdef
HAVE_LIFEV_DEBUG
223
M_B
->
matrixPtr
()->
Print
(
std
::
cout
);
224
#
endif
225
for
(
Int
i
= 0;
i
<
M_numCircuitElements
;
i
++ )
226
{
227
( *
f
) [
i
] = ( *
M_fA
) [
i
] + ( *
M_fB
) [
i
] + ( *
M_C
) [
i
];
228
}
229
#
ifdef
HAVE_LIFEV_DEBUG
230
f
->
Print
(
std
::
cout
);
231
#
endif
232
return
true
;
233
}
234
235
bool
RythmosModelInterface
::
evaluateWImplicit
(
const
Real
&
t
,
236
const
Real
&
alpha
,
237
const
Real
&
beta
,
238
const
Epetra_Vector
*
x
,
239
const
Epetra_Vector
*
x_dot
,
240
Epetra_CrsMatrix
*
W
)
241
{
242
//updateCircuitData from Y and Yp
243
#
ifdef
HAVE_LIFEV_DEBUG
244
x
->
Print
(
std
::
cout
);
245
x_dot
->
Print
(
std
::
cout
);
246
#
endif
247
M_circuitData
->
updateCircuitDataFromY
(
t
,
248
x
,
249
x_dot
);
250
M_circuitData
->
updateABC
( *
M_A
,
251
*
M_B
,
252
*
M_C
);
253
#
ifdef
HAVE_LIFEV_DEBUG
254
M_A
->
matrixPtr
()->
Print
(
std
::
cout
);
255
M_B
->
matrixPtr
()->
Print
(
std
::
cout
);
256
M_C
->
epetraVector
().
Print
(
std
::
cout
);
257
#
endif
258
M_A
->
operator
*= (
alpha
);
259
M_B
->
operator
*= (
beta
);
260
M_A
->
operator
+= ( *
M_B
);
261
Epetra_CrsMatrix
*
tmp
=
M_A
->
matrixPtr
().
get
();
262
( *
W
) = ( *
tmp
);
263
#
ifdef
HAVE_LIFEV_DEBUG
264
W
->
Print
(
std
::
cout
);
265
#
endif
266
return
true
;
267
}
268
269
void
RythmosModelInterface
::
extractSolution
(
const
Real
&
t
,
270
const
vectorEpetra_Type
&
y
,
271
const
vectorEpetra_Type
&
yp
)
272
{
273
M_circuitData
->
extractSolutionFromY
(
t
,
y
,
yp
);
274
}
275
276
#
endif
/* HAVE_NOX_THYRA && HAVE_TRILINOS_RYTHMOS */
277
278
}
// LifeV namespace
ETCurrentFE::updateInverseJacobian
void updateInverseJacobian(const UInt &iQuadPt)
Definition:
ETCurrentFE.cpp:405
lifev-release-doc
lifev
zero_dimensional
solver
ZeroDimensionalRythmosModelInterface.cpp
Generated on Wed Mar 7 2018 19:51:02 for LifeV by
1.8.13