LifeV
MultiscaleModelWindkessel0D.hpp
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 Windkessel 0D
30  *
31  * @date 08-02-2011
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  * @author Mahmoud Jafargholi <mahmoud.jafargholi@epfl.ch>
34  *
35  * @mantainer Cristiano Malossi <cristiano.malossi@epfl.ch>
36  */
37 
38 #ifndef MultiscaleModelWindkessel0D_H
39 #define MultiscaleModelWindkessel0D_H 1
40 
41 #include <lifev/bc_interface/0D/bc/BCInterface0D.hpp>
42 
43 #include <lifev/zero_dimensional/solver/ZeroDimensionalData.hpp>
44 
45 #include <lifev/multiscale/models/MultiscaleModel.hpp>
46 #include <lifev/multiscale/framework/MultiscaleInterface.hpp>
47 
48 namespace LifeV
49 {
50 namespace Multiscale
51 {
52 
53 //! MultiscaleModelWindkessel0D - Multiscale model for Windkessel 0D terminals
54 /*!
55  * @author Cristiano Malossi, Mahmoud Jafargholi
56  *
57  * @see Full description of the Geometrical Multiscale Framework: \cite Malossi-Thesis
58  * @see Methodology: \cite Malossi2011Algorithms \cite Malossi2011Algorithms1D \cite Malossi2011Algorithms3D1DFSI \cite BlancoMalossi2012
59  * @see Applications: \cite Malossi2011Algorithms3D1DFSIAortaIliac \cite LassilaMalossi2012IdealLeftVentricle \cite BonnemainMalossi2012LVAD
60  *
61  * The MultiscaleModelWindkessel0D class is an implementation of the multiscaleModel_Type
62  * for 0D problems.
63  */
65  public virtual MultiscaleInterface
66 {
67 public:
68 
69  //! @name Type definitions
70  //@{
71 
74 
77 
80 
81  //@}
82 
83 
84  //! @name Constructors & Destructor
85  //@{
86 
87  //! Constructor
88  explicit MultiscaleModelWindkessel0D();
89 
90  //! Destructor
92 
93  //@}
94 
95 
96  //! @name MultiscaleModel Methods
97  //@{
98 
99  //! Setup the data of the model.
100  /*!
101  * @param fileName Name of data file.
102  */
103  void setupData ( const std::string& fileName );
104 
105  //! Setup the model.
106  void setupModel();
107 
108  //! Build the initial model.
109  void buildModel();
110 
111  //! Update the model.
112  void updateModel();
113 
114  //! Solve the model.
115  void solveModel();
116 
117  //! Update the solution.
118  void updateSolution();
119 
120  //! Save the solution
121  void saveSolution();
122 
123  //! Display some information about the model.
124  void showMe();
125 
126  //! Return a specific scalar quantity to be used for a comparison with a reference value.
127  /*!
128  * This method is meant to be used for night checks.
129  * @return reference quantity.
130  */
131  Real checkSolution() const;
132 
133  //@}
134 
135 
136  //! @name MultiscaleInterface Methods
137  //@{
138 
139  //! Impose the flow rate on a specific interface of the model
140  /*!
141  * @param boundaryID ID of the boundary interface
142  * @param function boundary condition function
143  */
144  void imposeBoundaryFlowRate ( const multiscaleID_Type& boundaryID, const function_Type& function );
145 
146  //! Impose the integral of the mean normal stress on a specific boundary interface of the model
147  /*!
148  * @param boundaryID ID of the boundary interface
149  * @param function boundary condition function
150  */
151  void imposeBoundaryMeanNormalStress ( const multiscaleID_Type& boundaryID, const function_Type& function );
152 
153  //! Impose the integral of the mean total normal stress on a specific boundary interface of the model
154  /*!
155  * Note: mean total normal stress cannot be imposed at the interfaces of this model.
156  *
157  * @param boundaryID ID of the boundary interface
158  * @param function boundary condition function
159  */
160  void imposeBoundaryMeanTotalNormalStress ( const multiscaleID_Type& /*boundaryID*/, const function_Type& /*function*/ )
161  {
162  multiscaleErrorCheck ( ModelInterface, "Invalid interface [MeanTotalNormalStress] for model type [" + enum2String ( M_type, multiscaleModelsMap ) + "]", M_comm->MyPID() == 0 );
163  }
164 
165  //! Impose the area on a specific boundary interface of the model
166  /*!
167  * Note: area cannot be imposed at the interfaces of this model.
168  *
169  * @param boundaryID ID of the boundary interface
170  * @param function boundary condition function
171  */
172  void imposeBoundaryArea ( const multiscaleID_Type& /*boundaryID*/, const function_Type& /*function*/ )
173  {
174  multiscaleErrorCheck ( ModelInterface, "Invalid interface [Area] for model type [" + enum2String ( M_type, multiscaleModelsMap ) + "]", M_comm->MyPID() == 0 );
175  }
176 
177  //! Get the flow rate on a specific boundary interface of the model
178  /*!
179  * @param boundaryID ID of the boundary interface
180  * @return flow rate value
181  */
182  Real boundaryFlowRate ( const multiscaleID_Type& boundaryID ) const
183  {
184  return ( boundaryFlag ( boundaryID ) == 0 ) ? M_flowRateLeft : 0;
185  }
186 
187  //! Get the integral of the mean normal stress on a specific boundary interface of the model
188  /*!
189  * @param boundaryID ID of the boundary interface
190  * @return mean normal stress value
191  */
192  Real boundaryMeanNormalStress ( const multiscaleID_Type& boundaryID ) const
193  {
194  return -boundaryPressure ( boundaryID );
195  }
196 
197  //! Get the integral of the mean total normal stress on a specific boundary interface of the model
198  /*!
199  * Note: returns always a NaN since the mean total normal stress is not defined in the windkessel model
200  *
201  * @param boundaryID ID of the boundary interface
202  * @return mean total normal stress value
203  */
204  Real boundaryMeanTotalNormalStress ( const multiscaleID_Type& /*boundaryID*/ ) const
205  {
206  return NaN;
207  }
208 
209  //! Get the area on a specific boundary interface of the model
210  /*!
211  * Note: returns always a NaN since the area is not defined in the windkessel model
212  *
213  * @param boundaryID ID of the boundary interface
214  * @return area value
215  */
216  Real boundaryArea ( const multiscaleID_Type& /*boundaryID*/ ) const
217  {
218  return NaN;
219  }
220 
221  //! Get the variation of the flow rate (on a specific boundary interface) using the linear model
222  /*!
223  * @param boundaryID ID of the boundary interface
224  * @param solveLinearSystem a flag to which determine if the linear system has to be solved
225  * @return variation of the flow rate
226  */
227  Real boundaryDeltaFlowRate ( const multiscaleID_Type& boundaryID, bool& solveLinearSystem );
228 
229  //! Get the variation of the integral of the mean normal stress (on a specific boundary interface) using the linear model
230  /*!
231  * @param boundaryID ID of the boundary interface
232  * @param solveLinearSystem a flag to which determine if the linear system has to be solved
233  * @return variation of the mean normal stress
234  */
235  Real boundaryDeltaMeanNormalStress ( const multiscaleID_Type& boundaryID, bool& solveLinearSystem );
236 
237  //! Get the variation of the integral of the mean total normal stress (on a specific boundary interface) using the linear model
238  /*!
239  * Note: returns always a NaN since the mean total normal stress is not defined in the windkessel model.
240  *
241  * @param boundaryID ID of the boundary interface
242  * @param solveLinearSystem a flag to which determine if the linear system has to be solved
243  * @return variation of the mean total normal stress
244  */
245  Real boundaryDeltaMeanTotalNormalStress ( const multiscaleID_Type& /*boundaryID*/, bool& /*solveLinearSystem*/ )
246  {
247  return NaN;
248  }
249 
250  //! Get the variation of the integral of the area (on a specific boundary interface) using the linear model
251  /*!
252  * Note: returns always a NaN since the area is not defined in the windkessel model.
253  *
254  * @param boundaryID ID of the boundary interface
255  * @param solveLinearSystem a flag to which determine if the linear system has to be solved
256  * @return variation of the area
257  */
258  Real boundaryDeltaArea ( const multiscaleID_Type& /*boundaryID*/, bool& /*solveLinearSystem*/ )
259  {
260  return NaN;
261  }
262 
263  //@}
264 
265 
266  //! @name Get Methods
267  //@{
268 
269  //! Get the BCInterface container of the boundary conditions of the model
270  /*!
271  * @return BCInterface container
272  */
274  {
275  return *M_bc;
276  }
277 
278  //! Get the integral of the pressure (on a specific boundary face)
279  /*!
280  * @param boundaryID ID of the boundary interface
281  * @return pressure value
282  */
283  Real boundaryPressure ( const multiscaleID_Type& boundaryID ) const
284  {
285  return ( boundaryFlag ( boundaryID ) == 0 ) ? M_pressureLeft : M_pressureRight;
286  }
287 
288  //@}
289 
290 private:
291 
292  //! @name Unimplemented Methods
293  //@{
294 
296 
298 
299  //@}
300 
301 
302  //! @name Private Methods
303  //@{
304 
305  //! Setup the global data of the model.
306  /*!
307  * In particular, it replaces the default local values with the ones in the global container.
308  * If a value is already specified in the data file, do not perform the replacement.
309  *
310  * @param fileName File name of the specific model.
311  */
312  void setupGlobalData ( const std::string& fileName );
313 
314  //! Initialize the solution.
315  void initializeSolution();
316 
317  void setupExporterImporter();
318 
319  //! Solving for the flow rate.
320  /*!
321  * TODO ADD THE EQUATIONS
322  * @return the computed flow rate
323  */
325 
326  //! Solving for the pressure.
327  /*!
328  * TODO ADD THE EQUATIONS
329  * @return the computed pressure
330  */
332 
333  //! Solve the tangent problem
334  /*!
335  * @param solveLinearSystem if true the system as already been solved.
336  */
337  void solveLinearModel ( bool& solveLinearSystem );
338 
339  //! Solve the tangent problem for the flow rate
340  /*!
341  * TODO ADD THE EQUATIONS
342  * @return \f$ dQ/dP \f$
343  */
345 
346  //! Solve the tangent problem for the flow rate
347  /*!
348  * TODO ADD THE EQUATIONS
349  * @return \f$ dP/dQ \f$
350  */
352 
353  //@}
354 
355  std::ofstream M_outputFile;
356 
358 
360 
361  Real M_pressureLeft_tn; // pressure left (P1) @ t=t(n)
362  Real M_flowRateLeft_tn; // flowRate left (Q1) @ t=t(n)
363 
364  Real M_pressureLeft; // pressure left (P2) @ t=t(n+1)
365  Real M_flowRateLeft; // flowRate left (Q2) @ t=t(n+1)
366 
367  Real M_pressureRight; // pressure right (usually venous pressure)
368 
369  Real M_tangentPressureLeft; // Tangent pressure left
370  Real M_tangentFlowRateLeft; // Tangent flowRate left
371 
372  Real M_resistance1; // Resistance 1 (R1)
373  Real M_resistance2; // Resistance 2 (R2)
374  Real M_capacitance; // capacitance (C)
375 };
376 
377 //! Factory create function
379 {
380  return new MultiscaleModelWindkessel0D();
381 }
382 
383 } // Namespace multiscale
384 } // Namespace LifeV
385 
386 #endif /* MultiscaleModelWindkessel0D_H */
std::function< Real(const Real &, const Real &, const Real &, const Real &, const ID &) > function_Type
void imposeBoundaryMeanTotalNormalStress(const multiscaleID_Type &, const function_Type &)
Impose the integral of the mean total normal stress on a specific boundary interface of the model...
Real boundaryDeltaMeanNormalStress(const multiscaleID_Type &boundaryID, bool &solveLinearSystem)
Get the variation of the integral of the mean normal stress (on a specific boundary interface) using ...
ZeroDimensionalBCHandler - A boundary conditions handler for zero-dimensional models.
Real tangentSolveForPressure()
Solve the tangent problem for the flow rate.
Real boundaryPressure(const multiscaleID_Type &boundaryID) const
Get the integral of the pressure (on a specific boundary face)
void imposeBoundaryArea(const multiscaleID_Type &, const function_Type &)
Impose the area on a specific boundary interface of the model.
void imposeBoundaryMeanNormalStress(const multiscaleID_Type &boundaryID, const function_Type &function)
Impose the integral of the mean normal stress on a specific boundary interface of the model...
void imposeBoundaryFlowRate(const multiscaleID_Type &boundaryID, const function_Type &function)
Impose the flow rate on a specific interface of the model.
Real boundaryMeanNormalStress(const multiscaleID_Type &boundaryID) const
Get the integral of the mean normal stress on a specific boundary interface of the model...
void updateInverseJacobian(const UInt &iQuadPt)
Real boundaryArea(const multiscaleID_Type &) const
Get the area on a specific boundary interface of the model.
Real boundaryDeltaArea(const multiscaleID_Type &, bool &)
Get the variation of the integral of the area (on a specific boundary interface) using the linear mod...
Real boundaryDeltaMeanTotalNormalStress(const multiscaleID_Type &, bool &)
Get the variation of the integral of the mean total normal stress (on a specific boundary interface) ...
MultiscaleModel multiscaleModel_Type
multiscaleModel_Type * createMultiscaleModelWindkessel0D()
Factory create function.
Real checkSolution() const
Return a specific scalar quantity to be used for a comparison with a reference value.
Real boundaryDeltaFlowRate(const multiscaleID_Type &boundaryID, bool &solveLinearSystem)
Get the variation of the flow rate (on a specific boundary interface) using the linear model...
Real boundaryMeanTotalNormalStress(const multiscaleID_Type &) const
Get the integral of the mean total normal stress on a specific boundary interface of the model...
void showMe()
Display some information about the model.
MultiscaleModelWindkessel0D - Multiscale model for Windkessel 0D terminals.
double Real
Generic real data.
Definition: LifeV.hpp:175
void setupGlobalData(const std::string &fileName)
Setup the global data of the model.
void setupData(const std::string &fileName)
Setup the data of the model.
void solveLinearModel(bool &solveLinearSystem)
Solve the tangent problem.
bcInterface_Type & bcInterface()
Get the BCInterface container of the boundary conditions of the model.
BCInterface0D - LifeV interface to load boundary conditions for 0D problems completely from a GetPot ...
Real tangentSolveForFlowRate()
Solve the tangent problem for the flow rate.
Data container for 0D model.
MultiscaleInterface - The multiscale interface for fluid problems.
MultiscaleModelWindkessel0D(const MultiscaleModelWindkessel0D &model)
Real boundaryFlowRate(const multiscaleID_Type &boundaryID) const
Get the flow rate on a specific boundary interface of the model.
MultiscaleModelWindkessel0D & operator=(const MultiscaleModelWindkessel0D &model)