LifeV
OneDFSIPhysicsLinear.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 a class providing linear physical operations for the 1D model data.
30  *
31  * @version 1.0
32  * @date 01-07-2004
33  * @author Vincent Martin
34  *
35  * @version 2.0
36  * @date 13-04-2010
37  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
38  *
39  * @contributor Simone Rossi <simone.rossi@epfl.ch>
40  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
41  */
42 
43 #include <lifev/one_d_fsi/solver/OneDFSIPhysicsLinear.hpp>
44 
45 namespace LifeV
46 {
47 
48 // ===================================================
49 // Conversion Methods
50 // ===================================================
51 void
52 OneDFSIPhysicsLinear::fromUToW ( Real& W1, Real& W2, const Real& U1, const Real& U2, const UInt& iNode ) const
53 {
54  W1 = U2 + celerity0 ( iNode ) * ( U1 - M_dataPtr->area0 ( iNode ) );
55 
56  W2 = U2 - celerity0 ( iNode ) * ( U1 - M_dataPtr->area0 ( iNode ) );
57 
58 #ifdef HAVE_LIFEV_DEBUG
59  debugStream ( 6320 ) << "[OneDFSIModel_Physics_Linear::fromUToW] Q " << U2 << "\n";
60  debugStream ( 6320 ) << "[OneDFSIModel_Physics_Linear::fromUToW] W1 " << W1 << "\n";
61  debugStream ( 6320 ) << "[OneDFSIModel_Physics_Linear::fromUToW] W2 " << W2 << "\n";
62  debugStream ( 6320 ) << "[OneDFSIModel_Physics_Linear::fromUToW] celerity " << celerity0 ( iNode ) << "\n";
63  debugStream ( 6320 ) << "[OneDFSIModel_Physics_Linear::fromUToW] ( _U1 - area0( iNode ) ) " << ( U1 - M_dataPtr->area0 ( iNode ) ) << "\n";
64 #endif
65 }
66 
67 void
68 OneDFSIPhysicsLinear::fromWToU ( Real& U1, Real& U2, const Real& W1, const Real& W2, const UInt& iNode ) const
69 {
70  U1 = M_dataPtr -> area0 ( iNode ) + ( W1 - W2) / ( 2 * celerity0 ( iNode ) );
71 
72  U2 = ( W1 + W2 ) / 2;
73 }
74 
75 Real
76 OneDFSIPhysicsLinear::fromWToP ( const Real& W1, const Real& W2, const UInt& iNode ) const
77 {
78  return ( M_dataPtr -> beta0 ( iNode )
79  * ( OneDFSI::pow05 ( 1 / M_dataPtr->area0 ( iNode ), M_dataPtr -> beta1 ( iNode ) )
80  * OneDFSI::pow05 ( (W1 - W2 ) / ( 2 * celerity0 ( iNode ) ) + M_dataPtr -> area0 ( iNode ), M_dataPtr -> beta1 ( iNode ) )
81  - 1 )
82  );
83 }
84 
85 Real
86 OneDFSIPhysicsLinear::fromPToW ( const Real& P, const Real& W, const ID& iW, const UInt& iNode ) const
87 {
88  Real add ( 2 * celerity0 ( iNode ) * M_dataPtr -> area0 ( iNode ) * ( OneDFSI::pow20 ( P / M_dataPtr -> beta0 ( iNode ) + 1,
89  1 / M_dataPtr -> beta1 ( iNode ) ) - 1 ) );
90 
91 #ifdef HAVE_LIFEV_DEBUG
92  debugStream (6320) << "[fromPToW] "
93  << "2 * celerity0( iNode ) * area0( iNode ) = " << 2 * celerity0 ( iNode ) * M_dataPtr -> area0 ( iNode )
94  << ", pow( ( P / beta0( iNode ) + 1 ), 1 / beta1( iNode ) ) = "
95  << OneDFSI::pow20 ( P / M_dataPtr -> beta0 ( iNode ) + 1 , 1 / M_dataPtr -> beta1 ( iNode ) ) << "\n";
96  debugStream (6320) << "[fromPToW] add term = " << add << "\n";
97 #endif
98 
99  if ( iW == 0 )
100  {
101  return W - add;
102  }
103  if ( iW == 1 )
104  {
105  return W + add;
106  }
107 
108  ERROR_MSG ("You can only find W1 or W2 as function of P");
109  return -1.;
110 }
111 
112 Real
113 OneDFSIPhysicsLinear::fromQToW ( const Real& Q, const Real& /*W_tn*/, const Real& W, const ID& iW, const UInt& /*iNode*/ ) const
114 {
115  Real add ( 2 * Q );
116 
117  if ( iW == 0 ) // W1 given
118  {
119  return add - W;
120  }
121 
122  if ( iW == 1 ) // W2 given
123  {
124  return add - W;
125  }
126 
127  ERROR_MSG ("You can only find W1 or W2 as function of Q");
128  return -1.;
129 }
130 
131 // ===================================================
132 // Derivatives Methods
133 // ===================================================
134 Real
135 OneDFSIPhysicsLinear::dPdW ( const Real& W1, const Real& W2, const ID& iW, const UInt& iNode ) const
136 {
137  Real beta0beta1overA0beta1 ( M_dataPtr->beta0 ( iNode ) * M_dataPtr -> beta1 ( iNode ) / OneDFSI::pow05 ( M_dataPtr -> area0 ( iNode ),
138  M_dataPtr -> beta1 ( iNode ) ) );
139 
140  Real oneover2celerity ( 1 / ( 2 * celerity0 ( iNode ) ) );
141 
142  Real result ( beta0beta1overA0beta1 * oneover2celerity );
143  result *= ( ( W1 - W2 ) * oneover2celerity + M_dataPtr -> area0 ( iNode ) );
144 
145  if ( iW == 0 ) //! dP/dW1
146  {
147  return result;
148  }
149 
150  if ( iW == 1 ) //! dP/dW2
151  {
152  return -result;
153  }
154 
155  ERROR_MSG ("P(W1,W2)'s differential function has only 2 components.");
156  return -1.;
157 }
158 
159 }
void fromWToU(Real &U1, Real &U2, const Real &W1, const Real &W2, const UInt &iNode) const
Compute from .
Real celerity0(const UInt &iNode) const
Compute the reference celerity.
void updateInverseJacobian(const UInt &iQuadPt)
Real fromPToW(const Real &P, const Real &W, const ID &iW, const UInt &iNode) const
Compute or from .
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
Real dPdW(const Real &W1, const Real &W2, const ID &iW, const UInt &iNode) const
Compute the derivative of pressure with respect to .
uint32_type ID
IDs.
Definition: LifeV.hpp:194
Real fromQToW(const Real &Q, const Real &W_tn, const Real &W, const ID &iW, const UInt &iNode) const
Compute or from .
OneDFSIPhysicsLinear - Class providing linear physical operations for the 1D model data...
double Real
Generic real data.
Definition: LifeV.hpp:175
Real fromWToP(const Real &W1, const Real &W2, const UInt &iNode) const
Compute from .
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
void fromUToW(Real &W1, Real &W2, const Real &U1, const Real &U2, const UInt &iNode) const
Compute from .