LifeV
MultiscaleModel0D.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 File containing the Multiscale Model 0D
30  *
31  * @version 1.0
32  * @date 30-09-2011
33  * @author Mahmoud Jafargholi <mahmoud.jafargholi@epfl.ch>
34  *
35  * @contributors Cristiano Malossi <cristiano.malossi@epfl.ch>
36  * @mantainer Cristiano Malossi <cristiano.malossi@epfl.ch>
37  */
38 
39 #include <lifev/multiscale/models/MultiscaleModel0D.hpp>
40 
41 namespace LifeV
42 {
43 namespace Multiscale
44 {
45 
46 // ===================================================
47 // Constructors & Destructor
48 // ===================================================
50  M_data ( new data_Type() ),
51  M_solver (),
52  M_bc ( new bcInterface_Type() )
53 {
54 
55 #ifdef HAVE_LIFEV_DEBUG
56  debugStream ( 8160 ) << "MultiscaleModel0D::MultiscaleModel0D() \n";
57 #endif
58 
60 }
61 
62 // ===================================================
63 // MultiscaleModel Methods
64 // ===================================================
65 void
66 MultiscaleModel0D::setupData ( const std::string& fileName )
67 {
68 
69 #ifdef HAVE_LIFEV_DEBUG
70  debugStream ( 8160 ) << "MultiscaleModel0D::setupData( fileName ) \n";
71 #endif
72 
73  GetPot dataFile ( fileName );
74 
75  std::string circuitDataFile = dataFile ( "0D_Model/CircuitDataFile", "./inputFile.dat" );
76  M_bc->createHandler();
77  M_bc->fillHandler ( circuitDataFile, "Files" );
78 
79  M_data->setup (dataFile, M_bc->handler() );
80  if ( M_globalData.get() )
81  {
82  setupGlobalData ( fileName );
83  }
84 
85  // The 0D solver requires Rythmos/NOX/Thyra for now
86 #if ( defined(HAVE_NOX_THYRA) && defined(HAVE_TRILINOS_RYTHMOS) )
87  M_solver.reset ( new solver_Type ( M_data->unknownCounter(), M_comm, M_data->circuitData() ) );
88  M_solver->setup ( M_data->solverData() );
89 #endif
90 }
91 
92 void
94 {
95 
96 #ifdef HAVE_LIFEV_DEBUG
97  debugStream ( 8160 ) << "MultiscaleModel0D::setupModel() \n";
98 #endif
99 
100  M_data->initializeSolution();
101 }
102 
103 void
105 {
106 
107 #ifdef HAVE_LIFEV_DEBUG
108  debugStream ( 8160 ) << "MultiscaleModel0D::buildModel() \n";
109 #endif
110 
111 }
112 
113 void
115 {
116 
117 #ifdef HAVE_LIFEV_DEBUG
118  debugStream ( 8160 ) << "MultiscaleModel0D::updateModel() \n";
119 #endif
120 
121 }
122 
123 void
125 {
126 
127 #ifdef HAVE_LIFEV_DEBUG
128  debugStream ( 8160 ) << "MultiscaleModel0D::solveModel() \n";
129 #endif
130 
131  // The 0D solver requires Rythmos/NOX/Thyra for now
132 #if ( defined(HAVE_NOX_THYRA) && defined(HAVE_TRILINOS_RYTHMOS) )
133  M_solver->takeStep ( M_data->dataTime()->previousTime(), M_data->dataTime()->time() );
134 #endif
135 
136 }
137 
138 void
140 {
141 
142 #ifdef HAVE_LIFEV_DEBUG
143  debugStream ( 8160 ) << "MultiscaleModel0D::updateSolution() \n";
144 #endif
145 
146 }
147 
148 void
150 {
151 
152 #ifdef HAVE_LIFEV_DEBUG
153  debugStream ( 8160 ) << "MultiscaleModel0D::saveSolution() \n";
154 #endif
155 
156  M_data->saveSolution();
157 }
158 
159 void
161 {
162  if ( M_comm->MyPID() == 0 )
163  {
164  multiscaleModel_Type::showMe();
165 
166  M_data->showMe();
167  }
168 }
169 
170 Real
172 {
173  return M_data->circuitData()->Nodes()->nodeListAt ( 1 )->voltage() + M_data->circuitData()->Elements()->elementListAt ( 1 )->current();
174 }
175 
176 
177 
178 // ===================================================
179 // Private Methods
180 // ===================================================
181 void
182 MultiscaleModel0D::setupGlobalData ( const std::string& fileName )
183 {
184 
185 #ifdef HAVE_LIFEV_DEBUG
186  debugStream ( 8160 ) << "MultiscaleModel0D::setupGlobalData( fileName ) \n";
187 #endif
188 
189  GetPot dataFile ( fileName );
190 
191  //Global data time
192  M_data->setTimeData ( M_globalData->dataTime() );
193 }
194 
195 } // Namespace Multiscale
196 } // Namespace LifeV
void setupGlobalData(const std::string &fileName)
Setup the global data of the model.
void updateInverseJacobian(const UInt &iQuadPt)
void setupData(const std::string &fileName)
Setup the data of the model.
void showMe()
Display some information about the model.
MultiscaleModel0D - Multiscale model for 0D simulations.
double Real
Generic real data.
Definition: LifeV.hpp:175
void saveSolution()
Save the solution.
void updateSolution()
Update the solution.
Real checkSolution() const
Return a specific scalar quantity to be used for a comparison with a reference value.
void buildModel()
Build the initial model.