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 // ===================================================
51 
53 {
54  M_comm = comm->Clone();
55  ( *M_comm ).PrintInfo ( std::cout );
58  M_commSharedPtr ) );
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  }
76 
77  M_graph = new Epetra_CrsGraph ( M_A->matrixPtr()->Graph() );
79  M_C.reset ( new vector_Type ( *M_mapEpetraPtr ) );
80 
83 
86 
89  ;
92 }
93 
94 // Destructor
96 {
97 
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 
146 {
147  return *M_initialSolutionY;
148 }
149 
151 {
152  return *M_initialSolutionYp;
153 }
154 
156 {
157  return *M_standardMap;
158 }
159 
161 {
163  return true;
164 }
165 
167 {
168  ( *M_initialSolutionY ) = y;
169  return true;
170 }
171 
173 {
174  ( *M_initialSolutionYp ) = yp;
175  return true;
176 }
177 
179 {
181  return true;
182 }
184 {
185  return *M_graph;
186 }
187 
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
200  x,
201  x_dot );
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 
236  const Real& alpha,
237  const Real& beta,
238  const Epetra_Vector* x,
239  const Epetra_Vector* x_dot,
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
248  x,
249  x_dot );
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 );
262  ( *W ) = ( *tmp );
263 #ifdef HAVE_LIFEV_DEBUG
264  W->Print (std::cout);
265 #endif
266  return true;
267 }
268 
270  const vectorEpetra_Type& y,
271  const vectorEpetra_Type& yp )
272 {
274 }
275 
276 #endif /* HAVE_NOX_THYRA && HAVE_TRILINOS_RYTHMOS */
277 
278 } // LifeV namespace
void updateInverseJacobian(const UInt &iQuadPt)