LifeV
fsi/testsuite/fsi_monolithic/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 namespace LifeV
41 {
43  pi (3.141592635),
44  bcOnFluid (true),
45  M_outflux (0),
46  M_influx (0),
47  M_outP (0),
48  M_area0 (0),
49  M_inRadius0 (0),
50  M_outRadius0 (0),
51  M_inDeltaRadius (0),
52  M_outDeltaRadius (0),
53  M_beta (0),
54  M_rhos (0),
55  conditionNumber (0)
56 {
57  outputVector.push_back (0);
58  conditionNumber = FlowConditions::outputVector.size() - 1;
59 }
60 
61 
62 void FlowConditions::initParameters ( FSIOperator& Oper,
63  const int& outflowFlag)
64 {
65 
66  Epetra_SerialDenseVector fluidQuantities (1); // M_area0
67  Epetra_SerialDenseVector solidQuantities (2); // M_beta and M_rhos
68 
69  if (Oper.isFluid() )
70  {
71  fluidQuantities (0) = Oper.fluid().area (outflowFlag);
72  }
73 
74  M_area0 = fluidQuantities (0);
75  M_outRadius0 = std::sqrt (M_area0 / pi);
77 
78  Oper.displayer().leaderPrint ( " Outflow BC : area0 = ", M_area0 );
79  Oper.displayer().leaderPrint ( " Outflow BC : radius = ", M_outRadius0 );
80 
81 
82  if (Oper.isSolid() )
83  {
84  solidQuantities (0) = ( ( Oper.solid().thickness() * Oper.solid().young (1) ) / ( 1 - Oper.solid().poisson (1) * Oper.solid().poisson (1) ) * pi / M_area0 );
85 
86  solidQuantities (1) = Oper.solid().rho();
87 
88  Oper.displayer().leaderPrint ( " Outflow BC : thickness = " , Oper.solid().thickness() );
89  Oper.displayer().leaderPrint ( " Outflow BC : young = " , Oper.solid().young (1) );
90  Oper.displayer().leaderPrint ( " Outflow BC : poisson = " , Oper.solid().poisson (1) );
91 
92  }
93 
94  //Oper.worldComm().Broadcast( solidQuantities.Values(), solidQuantities.Length(),
95  //Oper.getSolidLeaderId() );
96 
97 
98  M_beta = solidQuantities (0);
99  M_rhos = solidQuantities (1);
100  Oper.displayer().leaderPrint ( " Outflow BC : beta = " , M_beta );
101  Oper.displayer().leaderPrint ( " Outflow BC : rho = " , M_rhos );
102 
103 
104 }
105 
106 void FlowConditions::renewParameters ( FSISolver& oper_,
107  const int& outflowFlag)
108 {
109 
110  Epetra_SerialDenseVector fluidQuantities (2); // Flux and Area
111  //Epetra_SerialDenseVector solidQuantities(0); // M_beta and M_rhos
112  FSIOperator* Oper (oper_.FSIOper().get() );
113 
114  if (Oper->isFluid() )
115  {
116  fluidQuantities (0) = Oper->fluid().flux (outflowFlag, oper_.displacement() );
117  fluidQuantities (1) = Oper->fluid().area (outflowFlag);
118  }
119 
120  Oper->worldComm()->Broadcast ( fluidQuantities.Values(), fluidQuantities.Length(),
121  Oper->getFluidLeaderId() );
122 
123 
124  Real qn;
125  Real area;
126 
127  qn = fluidQuantities (0);
128  area = fluidQuantities (1);
129 
130  // Setting parameters for our simulation:
131  // if imposing the absorbing boundary condition through the pressure:
132  if (bcOnFluid)
133  {
134  M_outP = std::pow ( (M_rhos / (2.*std::sqrt (2.) ) * qn / area + std::sqrt (M_beta * std::sqrt (M_area0) ) ), 2.)
135  - M_beta * std::sqrt (M_area0);
136  FlowConditions::outputVector[conditionNumber] = M_outP;
137 
138  Oper->displayer().leaderPrint ( " Flow rate = " , qn );
139  Oper->displayer().leaderPrint ( " outflow pressure = " , M_outP );
140 
141  M_outDeltaRadius = 0;
142 
143 
144  }
145  else
146  {
147  // if imposing the absorbing boundary condition through change in radius: --> Not ready
148 #ifdef TESTING
149  M_outP = Pout;
150 
151  area = qn * std::sqrt (M_rhos) / ( (2.*std::sqrt (2) ) *
152  std::sqrt ( M_outP + M_beta * std::sqrt (M_area0) ) - std::sqrt ( M_beta * std::sqrt (M_area0) ) );
153 
154  assert (area >= 0 );
155  if (area < 1e-8 * M_area0)
156  {
157  area = M_area0;
158  }
159 
160  M_outDeltaRadius = std::sqrt ( area / pi ) - M_outRadius0;
161 
162  Oper->displayer().leaderPrint ( " outflow A = " , area );
163  Oper->displayer().leaderPrint ( " outflow dr = " , M_outDeltaRadius );
164  Oper->displayer().leaderPrint ( " Flow rate = " , qn );
165  Oper->displayer().leaderPrint ( " outflow pressure = " , M_outP );
166 #endif
167 
168  }
169 
170  // for now applying absBC only at outflow
171  M_inDeltaRadius = 0;
172  // M_inP = Pin;
173 
174 }
175 
176 
177 
178 
179 Real FlowConditions::fZero (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
180 {
181  return 0.0;
182 }
183 
184 Real FlowConditions::outPressure0 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
185 {
186  return -FlowConditions::outputVector[0];
187 }
188 
189 Real FlowConditions::outPressure1 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
190 {
191  return -FlowConditions::outputVector[1];
192 }
193 
194 Real FlowConditions::outPressure2 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
195 {
196  return -FlowConditions::outputVector[2];
197 }
198 Real FlowConditions::outPressure3 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
199 {
200  return -FlowConditions::outputVector[4];
201 }
202 
203 Real FlowConditions::outPressure5 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
204 {
205  return -FlowConditions::outputVector[5];
206 }
207 
208 Real FlowConditions::outPressure6 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
209 {
210  return -FlowConditions::outputVector[6];
211 }
212 
213 
214 Real FlowConditions::inDeltaRadius (const Real& /*t*/, const Real& x, const Real& y, const Real& /*z*/, const ID& i)
215 {
216  if (i == 2)
217  {
218  return 0;
219  }
220 
221  Real r ( std::sqrt (x * x + y * y) );
222 
223  switch (i)
224  {
225  case 0:
226  return M_inDeltaRadius * x / r;
227  case 1:
228  return M_inDeltaRadius * y / r;
229  default:
230  ERROR_MSG ("This entry is not allowed: flowConditions.hpp");
231  };
232  return 0.;
233 }
234 
235 Real FlowConditions::outDeltaRadius (const Real& /*t*/, const Real& x, const Real& y, const Real& /*z*/, const ID& i)
236 {
237  if (i == 2)
238  {
239  return 0;
240  }
241 
242  Real r ( std::sqrt (x * x + y * y) );
243 
244  switch (i)
245  {
246  case 0:
247  return M_outDeltaRadius * x / r;
248  case 1:
249  return M_outDeltaRadius * y / r;
250  default:
251  ERROR_MSG ("This entry is not allowed: flowConditions.hpp");
252  };
253  return 0.;
254 }
255 
257 }
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)
static Real outPressure6(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)
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
void renewParameters(FSISolver &oper, const int &outflowFlag)
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)
void initParameters(FSIOperator &oper, const int &outflowFlag)
Real inDeltaRadius(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)