LifeV
fsi/examples/example_SmoothAneurysm/flowConditions.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 boundary conditions for the Monolithic Test
30  *
31  * @date 2009-04-09
32  * @author Paolo Crosetto <crosetto@iacspc70.epfl.ch>
33  *
34  * @contributor Cristiano Malossi <cristiano.malossi@epfl.ch>
35  * @maintainer Paolo Crosetto <crosetto@iacspc70.epfl.ch>
36  */
37 
38 #include "flowConditions.hpp"
39 
40 #define PI 3.141592653589793
41 
42 namespace LifeV
43 {
45  pi (3.141592635),
46  bcOnFluid (true),
47  M_outflux (0),
48  M_influx (0),
49  M_outP (0),
50  M_area0 (0),
51  M_inRadius0 (0),
52  M_outRadius0 (0),
53  M_inDeltaRadius (0),
54  M_outDeltaRadius (0),
55  M_beta (0),
56  M_rhos (0),
57  conditionNumber (0)
58 {
59  outputVector.push_back (0);
60  conditionNumber = FlowConditions::outputVector.size() - 1;
61 }
62 
63 
64 void FlowConditions::initParameters ( FSIOperator& Oper,
65  const int& outflowFlag)
66 {
67 
68  UInt flag = 1;
69  Epetra_SerialDenseVector fluidQuantities (1); // M_area0
70  Epetra_SerialDenseVector solidQuantities (2); // M_beta and M_rhos
71 
72 
73  if (Oper.isFluid() )
74  {
75 
76  fluidQuantities (0) = Oper.fluid().area (outflowFlag);
77 
78  }
79 
80  M_area0 = fluidQuantities (0);
81  M_outRadius0 = std::sqrt (M_area0 / pi);
83 
84  Oper.displayer().leaderPrint ( " Outflow BC : area0 = ", M_area0 );
85  Oper.displayer().leaderPrint ( " Outflow BC : radius = ", M_outRadius0 );
86  if (Oper.isSolid() )
87  {
88  solidQuantities (0) = ( ( Oper.solid().thickness() * Oper.solid().young ( flag ) ) / ( 1 - Oper.solid().poisson ( flag ) * Oper.solid().poisson ( flag ) ) * pi / M_area0 );
89 
90  solidQuantities (1) = Oper.solid().rho( );
91 
92  Oper.displayer().leaderPrint ( " Outflow BC : thickness = " , Oper.solid().thickness() );
93  Oper.displayer().leaderPrint ( " Outflow BC : young = " , Oper.solid().young ( flag ) );
94  Oper.displayer().leaderPrint ( " Outflow BC : poisson = " , Oper.solid().poisson ( flag ) );
95 
96  }
97 
98  //Oper.worldComm().Broadcast( solidQuantities.Values(), solidQuantities.Length(),
99  //Oper.getSolidLeaderId() );
100 
101 
102  M_beta = solidQuantities (0);
103  M_rhos = solidQuantities (1);
104  Oper.displayer().leaderPrint ( " Outflow BC : beta = " , M_beta );
105  Oper.displayer().leaderPrint ( " Outflow BC : rho = " , M_rhos );
106 
107 
108 }
109 
110 void FlowConditions::renewParameters ( FSISolver& oper_,
111  const int& outflowFlag,
112  const FSIOperator::vector_Type& fluidSolution)
113 {
114 
115  Epetra_SerialDenseVector fluidQuantities (2); // Flux and Area
116  //Epetra_SerialDenseVector solidQuantities(0); // M_beta and M_rhos
117  FSIOperator* Oper (oper_.FSIOper().get() );
118 
119  if (Oper->isFluid() )
120  {
121  fluidQuantities (0) = Oper->fluid().flux (outflowFlag, fluidSolution );
122  fluidQuantities (1) = Oper->fluid().area (outflowFlag);
123  }
124 
125  Oper->worldComm()->Broadcast ( fluidQuantities.Values(), fluidQuantities.Length(),
126  Oper->getFluidLeaderId() );
127 
128 
129  Real qn;
130  Real area;
131  Real area0;
132 
133  qn = fluidQuantities (0);
134  area = fluidQuantities (1);
135  area0 = 0.0034212;
136  // Fluid density
137  // Real density = 1.0;
138  UInt flag = 1;
139 
140  // Setting parameters for our simulation:
141  // if imposing the absorbing boundary condition through the pressure:
142  if (bcOnFluid)
143  {
144 
145  // Moura et al.
146  //Alexandra's Abc
147  Real exp = 5 / 4;
148  Real beta = ( std::sqrt (PI) * Oper->solid().thickness() * Oper->solid().young ( flag ) ) / (1 - Oper->solid().poisson ( flag ) * Oper->solid().poisson ( flag ) );
149  Real R = ( std::sqrt (Oper->solid().rho( ) * beta ) ) / ( std::sqrt (2.0) * std::pow (area0, exp) );
150 
151  M_outP = R * qn;
152 
153  // Nobile & Vergara
154  // M_outP = pow((std::sqrt(density)/(2.*std::sqrt(2))*qn/area + std::sqrt(M_beta*sqrt(M_area0))),2)
155  // - M_beta*std::sqrt(M_area0);
156  FlowConditions::outputVector[conditionNumber] = M_outP;
157 
158  Oper->displayer().leaderPrint ( " Flow rate = " , qn );
159  Oper->displayer().leaderPrint ( " outflow pressure = " , M_outP );
160 
161  M_outDeltaRadius = 0;
162 
163 
164  }
165  else
166  {
167  // if imposing the absorbing boundary condition through change in radius: --> Not ready
168 #ifdef TESTING
169  M_outP = Pout;
170 
171  area = qn * std::sqrt (M_rhos) / ( (2.*std::sqrt (2) ) *
172  std::sqrt ( M_outP + M_beta * std::sqrt (M_area0) ) - std::sqrt ( M_beta * std::sqrt (M_area0) ) );
173 
174  assert (area >= 0 );
175  if (area < 1e-8 * M_area0)
176  {
177  area = M_area0;
178  }
179 
180  M_outDeltaRadius = std::sqrt ( area / pi ) - M_outRadius0;
181 
182  Oper->displayer().leaderPrint ( " outflow A = " , area );
183  Oper->displayer().leaderPrint ( " outflow dr = " , M_outDeltaRadius );
184  Oper->displayer().leaderPrint ( " Flow rate = " , qn );
185  Oper->displayer().leaderPrint ( " outflow pressure = " , M_outP );
186 #endif
187 
188  }
189 
190  // for now applying absBC only at outflow
191  M_inDeltaRadius = 0;
192  // M_inP = Pin;
193 
194 }
195 
196 
197 
198 
199 Real FlowConditions::fZero (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
200 {
201  return 0.0;
202 }
203 
204 Real FlowConditions::outPressure0 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
205 {
206  return -FlowConditions::outputVector[0];
207 }
208 
209 Real FlowConditions::outPressure1 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
210 {
211  return -FlowConditions::outputVector[1];
212 }
213 
214 Real FlowConditions::outPressure2 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
215 {
216  return -FlowConditions::outputVector[2];
217 }
218 Real FlowConditions::outPressure3 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
219 {
220  return -FlowConditions::outputVector[3];
221 }
222 
223 Real FlowConditions::outPressure4 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
224 {
225  return -FlowConditions::outputVector[4];
226 }
227 
228 
229 Real FlowConditions::outPressure5 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
230 {
231  return -FlowConditions::outputVector[5];
232 }
233 
234 Real FlowConditions::outPressure6 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
235 {
236  return -FlowConditions::outputVector[6];
237 }
238 
239 
240 Real FlowConditions::inDeltaRadius (const Real& /*t*/, const Real& x, const Real& y, const Real& /*z*/, const ID& i)
241 {
242  if (i == 2)
243  {
244  return 0;
245  }
246 
247  Real r ( std::sqrt (x * x + y * y) );
248 
249  switch (i)
250  {
251  case 0:
252  return M_inDeltaRadius * x / r;
253  case 1:
254  return M_inDeltaRadius * y / r;
255  default:
256  ERROR_MSG ("This entry is not allowed: flowConditions.hpp");
257  };
258  return 0.;
259 }
260 
261 Real FlowConditions::outDeltaRadius (const Real& /*t*/, const Real& x, const Real& y, const Real& /*z*/, const ID& i)
262 {
263  if (i == 2)
264  {
265  return 0;
266  }
267 
268  Real r ( std::sqrt (x * x + y * y) );
269 
270  switch (i)
271  {
272  case 0:
273  return M_outDeltaRadius * x / r;
274  case 1:
275  return M_outDeltaRadius * y / r;
276  default:
277  ERROR_MSG ("This entry is not allowed: flowConditions.hpp");
278  };
279  return 0.;
280 }
281 
283 }
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
static Real outPressure3(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
Real outDeltaRadius(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
#define PI
static Real outPressure6(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
static Real outPressure4(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
static Real outPressure1(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
void renewParameters(FSISolver &oper, const int &outflowFlag, const FSIOperator::vector_Type &fluidSolution)
static Real outPressure0(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
static Real outPressure5(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
uint32_type ID
IDs.
Definition: LifeV.hpp:194
Real fZero(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
double Real
Generic real data.
Definition: LifeV.hpp:175
static Real outPressure2(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
void initParameters(FSIOperator &oper, const int &outflowFlag)
Real inDeltaRadius(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)