LifeV
OneDFSIPhysicsNonLinear.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 non 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/OneDFSIPhysicsNonLinear.hpp>
44 
45 namespace LifeV
46 {
47 // ===================================================
48 // Conversion methods
49 // ===================================================
50 void
51 OneDFSIPhysicsNonLinear::fromUToW ( Real& W1, Real& W2, const Real& A, const Real& Q, const UInt& iNode ) const
52 {
53  Real celerity ( celerity0 ( iNode ) * std::sqrt ( OneDFSI::pow05 ( A / M_dataPtr->area0 ( iNode ), M_dataPtr->beta1 ( iNode ) ) ) );
54 
55  Real add ( std::sqrt ( M_dataPtr->robertsonCorrection() ) * ( celerity - celerity0 ( iNode ) ) * 2 / M_dataPtr->beta1 ( iNode ) );
56 
57  Real QoverA = Q / A;
58 
59  W1 = QoverA + add;
60  W2 = QoverA - add;
61 }
62 
63 void
64 OneDFSIPhysicsNonLinear::fromWToU ( Real& A, Real& Q, const Real& W1, const Real& W2, const UInt& iNode ) const
65 {
66  Real rhooverbeta0beta1 ( M_dataPtr->densityRho() / ( M_dataPtr->beta0 ( iNode ) * M_dataPtr->beta1 ( iNode ) ) );
67 
68  Real beta1over4SQRTchi ( M_dataPtr->beta1 ( iNode ) / ( std::sqrt (M_dataPtr->robertsonCorrection() ) * 4 ) );
69 
70  A = M_dataPtr->area0 ( iNode )
71  * OneDFSI::pow20 ( rhooverbeta0beta1, 1 / M_dataPtr->beta1 ( iNode ) )
72  * OneDFSI::pow40 ( beta1over4SQRTchi * (W1 - W2) + celerity0 ( iNode ), 2 / M_dataPtr->beta1 ( iNode ) );
73 
74  Q = A * ( W1 + W2 ) / 2;
75 }
76 
77 Real
78 OneDFSIPhysicsNonLinear::fromWToP ( const Real& W1, const Real& W2, const UInt& iNode ) const
79 {
80  Real rhooverbeta0beta1 ( M_dataPtr->densityRho() / ( M_dataPtr->beta0 ( iNode ) * M_dataPtr->beta1 ( iNode ) ) );
81 
82  Real beta1over4SQRTchi ( M_dataPtr->beta1 ( iNode ) / ( std::sqrt (M_dataPtr->robertsonCorrection() ) * 4 ) );
83 
84  return M_dataPtr->beta0 ( iNode ) * ( rhooverbeta0beta1 * ( beta1over4SQRTchi * (W1 - W2) + celerity0 ( iNode ) ) *
85  ( beta1over4SQRTchi * (W1 - W2) + celerity0 ( iNode ) ) - 1 );
86 }
87 
88 Real
89 OneDFSIPhysicsNonLinear::fromPToW ( const Real& P, const Real& W, const ID& iW, const UInt& iNode ) const
90 {
91  Real SQRTbeta0beta1overrho ( M_dataPtr->beta0 ( iNode ) * M_dataPtr->beta1 ( iNode ) / M_dataPtr->densityRho() );
92  SQRTbeta0beta1overrho = std::sqrt ( SQRTbeta0beta1overrho );
93 
94  Real SQRTchi4overbeta1 ( std::sqrt (M_dataPtr->robertsonCorrection() ) * 4 / M_dataPtr->beta1 ( iNode ) );
95 
96  Real add ( SQRTchi4overbeta1 * SQRTbeta0beta1overrho
97  * ( std::sqrt ( P / M_dataPtr->beta0 ( iNode ) + 1 ) - 1 ) );
98 
99 #ifdef HAVE_LIFEV_DEBUG
100  debugStream (6320) << "[OneDFSIModel_Physics_NonLinear::W_fromP] "
101  << "SQRTchi4overbeta1 = " << SQRTchi4overbeta1
102  << ", beta0beta1overrho = " << SQRTbeta0beta1overrho
103  << ", pow( ( P / M_dataPtr->beta0( iNode ) + 1 ), 0.5 ) = " << std::sqrt ( ( P / M_dataPtr->beta0 ( iNode ) + 1 ) ) << "\n";
104  debugStream (6320) << "[OneDFSIModel_Physics_NonLinear::W_fromP] add term = " << add << "\n";
105 #endif
106 
107  if ( iW == 0 )
108  {
109  return W - add;
110  }
111  if ( iW == 1 )
112  {
113  return W + add;
114  }
115 
116  ERROR_MSG ("You can only find W1 or W2 as function of P");
117  return -1.;
118 }
119 
120 Real
121 OneDFSIPhysicsNonLinear::fromQToW ( const Real& Q, const Real& W_tn, const Real& W, const ID& iW, const UInt& iNode ) const
122 {
123  Real K0 ( M_dataPtr->beta1 ( iNode ) / ( std::sqrt (M_dataPtr->robertsonCorrection() ) * 4 ) );
124 
125  Real K1 ( (M_dataPtr->area0 ( iNode ) / 2) );
126  K1 *= OneDFSI::pow20 ( M_dataPtr->densityRho() / (M_dataPtr->beta0 ( iNode ) * M_dataPtr->beta1 ( iNode ) ), 1 / M_dataPtr->beta1 ( iNode ) );
127  K1 *= OneDFSI::pow40 ( K0, 2 / M_dataPtr->beta1 ( iNode ) );
128 
129  Real f_k, df_k, tau_k (0);
130 
131  if ( iW == 0 ) // W1 given
132  {
133  f_k = OneDFSI::pow40 ( W - W_tn + celerity0 ( iNode ) / K0, 2 / M_dataPtr->beta1 ( iNode ) );
134  tau_k = OneDFSI::pow40 ( W - W_tn + celerity0 ( iNode ) / K0, 2 / M_dataPtr->beta1 ( iNode ) );
135  df_k = (-2 / M_dataPtr->beta1 ( iNode ) ) * OneDFSI::pow30 ( W - W_tn + celerity0 ( iNode ) / K0, 2 / M_dataPtr->beta1 ( iNode ) - 1 );
136  }
137  if ( iW == 1 ) // W2 given
138  {
139  f_k = OneDFSI::pow40 ( W_tn - W + celerity0 ( iNode ) / K0, 2 / M_dataPtr->beta1 ( iNode ) );
140  tau_k = OneDFSI::pow40 ( W_tn - W + celerity0 ( iNode ) / K0, 2 / M_dataPtr->beta1 ( iNode ) );
141  df_k = (-2 / M_dataPtr->beta1 ( iNode ) ) * OneDFSI::pow30 ( W_tn - W + celerity0 ( iNode ) / K0, 2 / M_dataPtr->beta1 ( iNode ) - 1 );
142  }
143  f_k *= (W + W_tn);
144  f_k += - Q / K1;
145  df_k *= (W + W_tn);
146  df_k += f_k;
147 
148 #ifdef HAVE_LIFEV_DEBUG
149  debugStream (6320) << "[OneDFSIModel_Physics_NonLinear::W_fromQ] "
150  << "K0 = " << K0
151  << ", K1 = " << K1
152  << ", tau_k = " << tau_k << "\n";
153 #endif
154 
155  Real w_kp1 = Q / (K1 * tau_k) - W;
156 
157  return w_kp1;
158 }
159 
160 // ===================================================
161 // Derivatives methods
162 // ===================================================
163 Real
164 OneDFSIPhysicsNonLinear::dPdW ( const Real& W1, const Real& W2, const ID& iW, const UInt& iNode ) const
165 {
166  Real rhoover2SQRTchi ( M_dataPtr->densityRho() / ( std::sqrt (M_dataPtr->robertsonCorrection() ) * 2 ) );
167 
168  Real beta1over4SQRTchi ( M_dataPtr->beta1 ( iNode ) / ( std::sqrt (M_dataPtr->robertsonCorrection() ) * 4 ) );
169 
170  Real result ( beta1over4SQRTchi * (W1 - W2) );
171  result += celerity0 ( iNode );
172  result *= rhoover2SQRTchi;
173 
174  if ( iW == 0 ) //! dP/dW1
175  {
176  return result;
177  }
178 
179  if ( iW == 1 ) //! dP/dW2
180  {
181  return -result;
182  }
183 
184  ERROR_MSG ("P(W1,W2)'s differential function has only 2 components.");
185  return -1.;
186 }
187 
188 }
Real fromPToW(const Real &P, const Real &W, const ID &iW, const UInt &iNode) const
Compute or from .
Real fromQToW(const Real &Q, const Real &W_tn, const Real &W, const ID &iW, const UInt &iNode) const
Compute or from .
Real celerity0(const UInt &iNode) const
Compute the reference celerity.
void updateInverseJacobian(const UInt &iQuadPt)
Real fromWToP(const Real &W1, const Real &W2, const UInt &iNode) const
Compute from .
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
void fromWToU(Real &U1, Real &U2, const Real &W1, const Real &W2, const UInt &iNode) const
Compute from .
uint32_type ID
IDs.
Definition: LifeV.hpp:194
double Real
Generic real data.
Definition: LifeV.hpp:175
OneDFSIPhysicsNonLinear - Class providing non linear physical operations for the 1D model data...
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 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 .