LifeV
OneDFSIFunctionSolverDefined.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 some functions for the boundary conditions of 1D models.
30  *
31  * @version 1.0
32  * @date 01-08-2006
33  * @author Lucia Mirabella <lucia.mirabella@gmail.com>
34  * @author Tiziano Passerini <tiziano.passerini@gmail.com>
35  *
36  * @version 2.0
37  * @date 20-04-2010
38  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
39  *
40  * @contributors Ricardo Ruiz-Baier <ricardo.ruiz@epfl.ch>
41  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
42  */
43 
44 #ifndef OneDFSIBCFunctionDefault_H
45 #define OneDFSIBCFunctionDefault_H
46 
47 #include <lifev/one_d_fsi/function/OneDFSIFunction.hpp>
48 #include <lifev/one_d_fsi/solver/OneDFSIData.hpp>
49 #include <lifev/one_d_fsi/solver/OneDFSIFlux.hpp>
50 #include <lifev/one_d_fsi/solver/OneDFSISource.hpp>
51 #include <array>
52 
53 namespace LifeV
54 {
55 
56 //! OneDFSIModelBCFunctionDefault - Base class for deriving specific 1D boundary functions
57 /*!
58  * @author Lucia Mirabella, Tiziano Passerini, Cristiano Malossi
59  * @see Equations and networks of 1-D models \cite FormaggiaLamponi2003
60  * @see Geometrical multiscale coupling of 1-D models \cite Malossi2011Algorithms \cite Malossi2011Algorithms1D
61  *
62  * This class provide a general interface for implementing some specific boundary conditions
63  * for the 1D segment.
64  */
66 {
67 public:
68 
69  //! @name Type definitions and Enumerators
70  //@{
71 
74 
77 
80 
82  typedef data_Type::mesh_Type mesh_Type;
83 
84  typedef data_Type::container2D_Type container2D_Type;
85 
90 
92 
95 
96  typedef OneDFSI::bcLine_Type bcLine_Type;
97  typedef OneDFSI::bcSide_Type bcSide_Type;
98  typedef OneDFSI::bcType_Type bcType_Type;
99 
100  //@}
101 
102 
103  //! @name Constructors & Destructor
104  //@{
105 
106  //! Constructor
107  /*!
108  * @param bcLine the line of the boundary condition (first or second).
109  * @param bcType the type of the boundary condition (\f$Q\f$, \f$A\f$, \f$P\f$, \f$S\f$, \f$W_1\f$, \f$W_2\f$).
110  */
111  explicit OneDFSIFunctionSolverDefined ( const bcSide_Type& bcSide, const bcType_Type& bcType );
112 
113  //! Copy constructor
114  /*!
115  * @param bcFunctionDefault OneDFSIFunctionSolverDefined
116  */
117  explicit OneDFSIFunctionSolverDefined ( const OneDFSIFunctionSolverDefined& bcFunctionDefault );
118 
119  //! Destructor
121 
122  //@}
123 
124 
125  //! @name Methods
126  //@{
127 
128  //! Operator()
129  /*!
130  * Evaluate the function.
131  *
132  * @param time the current time.
133  * @param timeStep the time step.
134  * @return the value of the function.
135  */
136  virtual Real operator() ( const Real& time, const Real& timeStep );
137 
138  //@}
139 
140 
141  //! @name Set Methods
142  //@{
143 
144  //! Set the flux and the source classes for the problem
145  /*!
146  * @param fluxPtr pointer to the flux term of the problem.
147  * @param sourcePtr pointer to the source term of the problem.
148  */
149  void setFluxSource ( const fluxPtr_Type& fluxPtr, const sourcePtr_Type& sourcePtr );
150 
151  //! Set the solution of the problem
152  /*!
153  * @param solutionPtr pointer to the solution of the problem.
154  */
155  void setSolution ( const solutionPtr_Type& solutionPtr )
156  {
157  M_solutionPtr = solutionPtr;
158  }
159 
160  //@}
161 
162 protected:
163 
164  //! @name Protected Methods
165  //@{
166 
167  //! Automatically identify the boundary node.
168  virtual void setupNode();
169 
170  //@}
171 
175 
177  bcSide_Type M_bcSide;
178  bcType_Type M_bcType;
179 };
180 
181 
182 
183 //! OneDFSIFunctionSolverDefinedRiemann - Class which implements Riemann boundary conditions for the 1D segment
184 /*!
185  * @author Lucia Mirabella, Tiziano Passerini
186  *
187  * \cond \TODO Add the equation and some descriptions \endcond
188  */
190 {
191 public:
192 
193  //! @name Type definitions and Enumerators
194  //@{
195 
197  typedef super::container2D_Type container2D_Type;
198 
199  //@}
200 
201 
202  //! @name Constructors & Destructor
203  //@{
204 
205  //! Constructor
206  /*!
207  * @param bcLine the line of the boundary condition (first or second).
208  * @param bcType the type of the boundary condition (\f$Q\f$, \f$A\f$, \f$P\f$, \f$S\f$, \f$W_1\f$, \f$W_2\f$).
209  */
210  explicit OneDFSIFunctionSolverDefinedRiemann ( const bcSide_Type& bcSide, const bcType_Type& bcType );
211 
212  //! Copy constructor
213  /*!
214  * @param bcFunctionRiemann OneDFSIFunctionSolverDefinedRiemann
215  */
216  explicit OneDFSIFunctionSolverDefinedRiemann ( const OneDFSIFunctionSolverDefinedRiemann& bcFunctionRiemann );
217 
218  //! Destructor
220 
221  //@}
222 
223 
224  //! @name Methods
225  //@{
226 
227  //! Operator()
228  /*!
229  * Evaluate the function.
230  *
231  * @param time the current time.
232  * @param timeStep the time step.
233  * @return the value of the function.
234  */
235  virtual Real operator() ( const Real& time, const Real& timeStep );
236 
237  //@}
238 
239 protected:
240 
241  //! @name Protected Methods
242  //@{
243 
244  //! Update the boundary condition variables.
245  void updateBCVariables();
246 
247  //@}
248 
249  //! Value of U at the boundary
250  container2D_Type M_bcU;
251 
252  //! Value of W at the boundary
253  container2D_Type M_bcW;
254 };
255 
256 
257 //! OneDFSIFunctionSolverDefinedCompatibility - Class which implements Compatibility boundary conditions for the 1D segment
258 /*!
259  * @author Lucia Mirabella, Tiziano Passerini, Cristiano Malossi
260  *
261  * The compatibility equations are derived using the pseudo-characteristic teory:
262  *
263  * \f[
264  * \mathbf L(\mathbf U^{n+1}-\mathbf U^{n}_\star + \mathbf U^0 - \mathbf U^0_\star) =
265  * \Delta t \left( \mathbf \Lambda \displaystyle\frac{\partial \mathbf L}{\partial z}(\mathbf U^n_\star -
266  * \mathbf U^0_\star) - \mathbf L \mathbf B(\mathbf U^n_\star) + \mathbf L \mathbf B(\mathbf U^0_\star) \right).
267  * \f]
268  */
270 {
271 public:
272 
273  //! @name Type definitions
274  //@{
275 
277 
278  typedef super::fluxPtr_Type fluxPtr_Type;
279  typedef super::sourcePtr_Type sourcePtr_Type;
280  typedef super::solutionPtr_Type solutionPtr_Type;
281 
282  typedef super::mesh_Type mesh_Type;
283  typedef super::container2D_Type container2D_Type;
284 
285  //@}
286 
287 
288  //! @name Constructors & Destructor
289  //@{
290 
291  //! Constructor
292  /*!
293  * @param bcLine the line of the boundary condition (first or second).
294  * @param bcType the type of the boundary condition (\f$Q\f$, \f$A\f$, \f$P\f$, \f$S\f$, \f$W_1\f$, \f$W_2\f$).
295  */
296  explicit OneDFSIFunctionSolverDefinedCompatibility ( const bcSide_Type& bcSide, const bcType_Type& bcType );
297 
298  //! Copy constructor
299  /*!
300  * @param bcFunctionCompatibility OneDFSIFunctionSolverDefinedCompatibility
301  */
303 
304  //! Destructor
306 
307  //@}
308 
309 
310  //! @name Methods
311  //@{
312 
313  //! Operator()
314  /*!
315  * Evaluate the function.
316  *
317  * @param time the current time.
318  * @param timeStep the time step.
319  * @return the value of the function.
320  */
321  virtual Real operator() ( const Real& /*time*/, const Real& timeStep )
322  {
323  return computeRHS ( timeStep );
324  }
325 
326  //@}
327 
328 protected:
329 
330  //! @name Protected Methods
331  //@{
332 
333  //! Automatically identify the boundary node.
334  void setupNode();
335 
336  //! Compute the rhs
337  /*!
338  * @param timeStep the time step.
339  * @return rhs of the problem.
340  */
341  Real computeRHS ( const Real& timeStep );
342 
343  //! Compute the current eigenvalues and eigenvectors
345 
346  //! Compute the rhs
347  /*!
348  * @param eigenvalue eigenvalue
349  * @param eigenvector eigenvector
350  * @param deltaEigenvector derivative of the eigenvector
351  * @param timeStep the time step.
352  * @return rhs of the problem
353  */
354  Real evaluateRHS ( const Real& eigenvalue, const container2D_Type& eigenvector,
355  const container2D_Type& deltaEigenvector, const Real& timeStep );
356 
357  //! Compute the current CFL
358  /*!
359  * @param eigenvalue eigenvalue
360  * @param timeStep the time step.
361  * @return CFL
362  */
363  Real computeCFL ( const Real& eigenvalue, const Real& timeStep ) const;
364 
365  //! Scalar product between 2 2D vectors
366  /*!
367  * @pararm vector1 first vector
368  * @pararm vector2 second vector
369  * @return scalar product
370  */
371  Real scalarProduct ( const container2D_Type& vector1, const container2D_Type& vector2 )
372  {
373  return vector1[0] * vector2[0] + vector1[1] * vector2[1];
374  }
375 
376  //@}
377 
378  //! ID of the boundary edge
380  //! Dof of the internal node adjacent to the boundary
382 
383  //! Eigen values of the jacobian diffFlux (= dF/dU = H)
384  container2D_Type M_eigenvalues;
385  container2D_Type M_deltaEigenvalues;
386 
387  //! Left eigen vectors for the two eigen values
388  container2D_Type M_leftEigenvector1;
389  container2D_Type M_leftEigenvector2;
390  container2D_Type M_deltaLeftEigenvector1;
391  container2D_Type M_deltaLeftEigenvector2;
392 };
393 
394 
395 //! OneDFSIFunctionSolverDefinedAbsorbing - Class which implements absorbing boundary conditions for the 1D segment
396 /*!
397  * @author Maria Rita de Luca
398  *
399  * \cond \TODO Add the equation and some descriptions \endcond
400  */
402 {
403 public:
404 
405  //! @name Type definitions
406  //@{
407 
409 
410  typedef super::fluxPtr_Type fluxPtr_Type;
411  typedef super::sourcePtr_Type sourcePtr_Type;
412  typedef super::solutionPtr_Type solutionPtr_Type;
413 
414  typedef super::mesh_Type mesh_Type;
415 
416  //@}
417 
418 
419  //! @name Constructors & Destructor
420  //@{
421 
422  //! Constructor
423  /*!
424  * @param bcLine the line of the boundary condition (first or second).
425  * @param bcType the type of the boundary condition (\f$Q\f$, \f$A\f$, \f$P\f$, \f$S\f$, \f$W_1\f$, \f$W_2\f$).
426  */
427  explicit OneDFSIFunctionSolverDefinedAbsorbing ( const bcSide_Type& bcSide, const bcType_Type& bcType ) : super ( bcSide, bcType ) {}
428 
429  //! Copy constructor
430  /*!
431  * @param bcFunctionAbsorbing OneDFSIFunctionSolverDefinedAbsorbing
432  */
433  explicit OneDFSIFunctionSolverDefinedAbsorbing ( const OneDFSIFunctionSolverDefinedAbsorbing& bcFunctionAbsorbing ) : super ( bcFunctionAbsorbing ) {}
434 
435  //! Destructor
437 
438  //@}
439 
440 
441  //! @name Methods
442  //@{
443 
444  //! Operator()
445  /*!
446  * Evaluate the function.
447  *
448  * @param time the current time.
449  * @param timeStep the time step.
450  * @return the value of the function.
451  */
452  Real operator() ( const Real& time, const Real& timeStep );
453 
454  //@}
455 
456 protected:
457 
458  //! Set the value of the resistance
459  /*!
460  * For absorbing BC do nothing.
461  * @param resistance value of the resistance
462  */
463  virtual void resistance ( Real& /*resistance*/ )
464  {
465  /*Do nothing => absorbing!*/
466  }
467 
468  //! Venous pressure
469  /*!
470  * For absorbing BC the venous pressure is equal to the external pressure.
471  * @return venous pressure.
472  */
474  {
475  return M_fluxPtr->physics()->externalPressure();
476  }
477 
478 };
479 
480 
481 //! OneDFSIFunctionSolverDefinedResistance - Class which implements resistance boundary conditions for the 1D segment
482 /*!
483  * @author Lucia Mirabella, Tiziano Passerini
484  *
485  * \cond \TODO Add the equation and some descriptions \endcond
486  */
488 {
489 public:
490 
491  //! @name Type definitions
492  //@{
493 
495 
496  typedef super::fluxPtr_Type fluxPtr_Type;
497  typedef super::sourcePtr_Type sourcePtr_Type;
498  typedef super::solutionPtr_Type solutionPtr_Type;
499 
500  //@}
501 
502 
503  //! @name Constructors & Destructor
504  //@{
505 
506  //! Constructor
507  /*!
508  * @param bcLine the line of the boundary condition (first or second).
509  * @param bcType the type of the boundary condition (\f$Q\f$, \f$A\f$, \f$P\f$, \f$S\f$, \f$W_1\f$, \f$W_2\f$).
510  * @param resistance the terminal resistance.
511  */
512  explicit OneDFSIFunctionSolverDefinedResistance ( const bcSide_Type& bcSide, const bcType_Type& bcType, const Real& resistance );
513 
514  //! Copy constructor
515  /*!
516  * @param bcFunctionResistance OneDFSIFunctionSolverDefinedResistance
517  */
519 
520  //! Destructor
522 
523  //@}
524 
525 protected:
526 
527  //! Set the value of the resistance
528  /*!
529  * @param resistance value of the resistance
530  */
531  void resistance ( Real& resistance )
532  {
533  resistance = M_resistance;
534  }
535 
536  //! Venous pressure
537  /*!
538  * @return venous pressure.
539  */
541  {
542  return M_fluxPtr->physics()->venousPressure();
543  }
544 
546 };
547 
548 
549 
550 //! OneDFSIFunctionSolverDefinedWindkessel3 - Class which implements windkessel RCR boundary conditions for the 1D segment
551 /*!
552  *
553  * \cond \TODO Description should be reordered using latex etc... \endcond
554  * \cond \TODO This method has not been tested yet \endcond
555  *
556  * * Q -> ---R1-------R2---
557  * ^ | ^
558  * P C Pv
559  * ^ | ^
560  *
561  * The holding equation is:
562  *
563  * P + C R2 dP/dt = (R1 + R2 ) * Q + R1 R2 C dQ/dt + Pv
564  *
565  * where the "venous" pressure Pv is taken constant and equal to 5mmHg (6666 dyn/cm^2).
566  *
567  * You can solve this ODE in analytical fashion and obtain:
568  *
569  * P(t) = P(0) + [ \int_0^t ( pv + (R1+R2) Q(s) + R1*R2*C dQ(s)/ds ) exp( s / (R2*C) ) ds ] * exp( - t / (R2*C) )
570  *
571  * then you just need to exploit numerical integration rules.
572  * Here a simple trapezoidal rule is used, with a first order approximation of derivative
573  *
574  * dQ(s)/ds = Q(t(n+1)) - Q(t(n)) * (1/dt)
575  *
576  * @author Lucia Mirabella, Tiziano Passerini
577  */
579 {
580 public:
581 
582  //! @name Type definitions
583  //@{
584 
586 
587  typedef super::fluxPtr_Type fluxPtr_Type;
588  typedef super::sourcePtr_Type sourcePtr_Type;
589  typedef super::solutionPtr_Type solutionPtr_Type;
590 
591  //@}
592 
593 
594  //! @name Constructors & Destructor
595  //@{
596 
597  //! Constructor
598  /*!
599  * @param bcLine the line of the boundary condition (first or second).
600  * @param bcType the type of the boundary condition (\f$Q\f$, \f$A\f$, \f$P\f$, \f$S\f$, \f$W_1\f$, \f$W_2\f$).
601  * @param resistance1 the first terminal resistance.
602  * @param resistance2 the second terminal resistance.
603  * @param compliance the compliance.
604  * @param absorbing is an absorbing boundary condition
605  * @param venousPressure the venous pressure
606  */
607  explicit OneDFSIFunctionSolverDefinedWindkessel3 ( const bcSide_Type& bcSide, const bcType_Type& bcType,
608  const Real& resistance1, const Real& resistance2,
609  const Real& compliance,
610  const bool& absorbing = false,
611  const Real& venousPressure = 6666. );
612 
613  //! Copy constructor
614  /*!
615  * @param bcFunctionWindkessel3 OneDFSIFunctionSolverDefinedWindkessel3
616  */
618 
619  //! Destructor
621 
622  //@}
623 
624 
625  //! @name Methods
626  //@{
627 
628  //! Operator()
629  /*!
630  * Evaluate the function.
631  *
632  * @param time the current time.
633  * @param timeStep the time step.
634  * @return the value of the function.
635  */
636  Real operator() ( const Real& time, const Real& timeStep );
637 
638  //@}
639 
640 protected:
641 
647 
648  // Initial value of the pressure
650 
651  // Q at previous time step
653 
654  // dQdt at the previous time step
656 
657  // Integral of the pressure at the previous time step
659 };
660 
661 }
662 
663 #endif // OneDFSIBCFunctionDefault_H
void setFluxSource(const fluxPtr_Type &fluxPtr, const sourcePtr_Type &sourcePtr)
Set the flux and the source classes for the problem.
Real computeCFL(const Real &eigenvalue, const Real &timeStep) const
Compute the current CFL.
std::array< vectorPtr_Type, 2 > vectorPtrContainer_Type
RegionMesh< LinearLine > mesh_Type
OneDFSIFunctionSolverDefinedCompatibility(const bcSide_Type &bcSide, const bcType_Type &bcType)
Constructor.
OneDFSIFunctionSolverDefinedAbsorbing - Class which implements absorbing boundary conditions for the ...
void setSolution(const solutionPtr_Type &solutionPtr)
Set the solution of the problem.
OneDFSIFunctionSolverDefinedWindkessel3(const bcSide_Type &bcSide, const bcType_Type &bcType, const Real &resistance1, const Real &resistance2, const Real &compliance, const bool &absorbing=false, const Real &venousPressure=6666.)
Constructor.
Real operator()(const Real &time, const Real &timeStep)
Operator()
container2D_Type M_bcW
Value of W at the boundary.
virtual Real operator()(const Real &time, const Real &timeStep)
Operator()
OneDFSIData - Class which read and holds all the data for the One Dimensional Model Solver...
UInt M_bcInternalNode
Dof of the internal node adjacent to the boundary.
VectorEpetra vector_type
MatrixEpetra< Real > matrix_type
void resistance(Real &resistance)
Set the value of the resistance.
OneDFSIFlux - Base class for the flux term of the 1D hyperbolic problem.
Definition: OneDFSIFlux.hpp:63
virtual void resistance(Real &)
Set the value of the resistance.
OneDFSISource - Base class for the source term of the 1D hyperbolic problem.
container2D_Type M_leftEigenvector1
Left eigen vectors for the two eigen values.
void updateInverseJacobian(const UInt &iQuadPt)
OneDFSIFunction - Base class for 1D BC Functions.
OneDFSIFunctionSolverDefinedWindkessel3 - Class which implements windkessel RCR boundary conditions f...
OneDFSIFunctionSolverDefinedCompatibility super
virtual Real operator()(const Real &time, const Real &timeStep)
Operator()
Real computeRHS(const Real &timeStep)
Compute the rhs.
Real operator()(const Real &time, const Real &timeStep)
Operator()
OneDFSIFunctionSolverDefined(const OneDFSIFunctionSolverDefined &bcFunctionDefault)
Copy constructor.
OneDFSIFunctionSolverDefinedResistance - Class which implements resistance boundary conditions for th...
Real evaluateRHS(const Real &eigenvalue, const container2D_Type &eigenvector, const container2D_Type &deltaEigenvector, const Real &timeStep)
Compute the rhs.
OneDFSIFunctionSolverDefinedRiemann(const OneDFSIFunctionSolverDefinedRiemann &bcFunctionRiemann)
Copy constructor.
OneDFSIFunctionSolverDefinedResistance(const OneDFSIFunctionSolverDefinedResistance &bcFunctionResistance)
Copy constructor.
OneDFSIFunctionSolverDefinedCompatibility - Class which implements Compatibility boundary conditions ...
OneDFSIFunctionSolverDefinedAbsorbing(const OneDFSIFunctionSolverDefinedAbsorbing &bcFunctionAbsorbing)
Copy constructor.
void setupNode()
Automatically identify the boundary node.
OneDFSIFunctionSolverDefined(const bcSide_Type &bcSide, const bcType_Type &bcType)
Constructor.
container2D_Type M_eigenvalues
Eigen values of the jacobian diffFlux (= dF/dU = H)
OneDFSIFunctionSolverDefinedCompatibility(const OneDFSIFunctionSolverDefinedCompatibility &bcFunctionCompatibility)
Copy constructor.
std::shared_ptr< bcFunction_Type > bcFunctionPtr_Type
SolverAmesos - Class to wrap linear solver.
virtual Real operator()(const Real &, const Real &timeStep)
Operator()
double Real
Generic real data.
Definition: LifeV.hpp:175
std::array< Real, 2 > container2D_Type
std::shared_ptr< solution_Type > solutionPtr_Type
OneDFSIModelBCFunctionDefault - Base class for deriving specific 1D boundary functions.
void updateBCVariables()
Update the boundary condition variables.
virtual void setupNode()
Automatically identify the boundary node.
OneDFSIFunctionSolverDefinedResistance(const bcSide_Type &bcSide, const bcType_Type &bcType, const Real &resistance)
Constructor.
OneDFSIFunctionSolverDefinedAbsorbing(const bcSide_Type &bcSide, const bcType_Type &bcType)
Constructor.
OneDFSIFunctionSolverDefinedWindkessel3(const OneDFSIFunctionSolverDefinedWindkessel3 &bcFunctionWindkessel3)
Copy constructor.
OneDFSIFunctionSolverDefinedRiemann(const bcSide_Type &bcSide, const bcType_Type &bcType)
Constructor.
std::map< std::string, vectorPtr_Type > solution_Type
void computeEigenValuesVectors()
Compute the current eigenvalues and eigenvectors.
Real scalarProduct(const container2D_Type &vector1, const container2D_Type &vector2)
Scalar product between 2 2D vectors.
container2D_Type M_bcU
Value of U at the boundary.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
OneDFSIFunctionSolverDefinedRiemann - Class which implements Riemann boundary conditions for the 1D s...