LifeV
fsi/examples/example_SmoothAneurysm/resistance.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 "resistance.hpp"
39 
40 #define PI 3.141592653589793
41 
42 namespace LifeV
43 {
44 
45 ResistanceBCs::ResistanceBCs() :
46  pi (3.141592635),
47  M_outflux (0),
48  M_resistance (0),
49  M_hydrostaticP (0),
50  M_outP (0),
51  M_flag (0),
52  M_name ( ),
53  conditionNumber (0)
54 {
55  outputVector.push_back (0);
56  conditionNumber = ResistanceBCs::outputVector.size() - 1;
57 }
58 
59 
60 void ResistanceBCs::initParameters ( const int flag,
61  const Real resistance,
62  const Real hydrostatic,
63  const std::string name)
64 {
65  // In this function we set up the pressure and the resistance value
66  // The resistance BCs are applied as Neumann BCs using the flux at
67  // the previous time
68 
69  M_resistance = resistance;
70  M_hydrostaticP = hydrostatic;
71  M_flag = flag;
72  M_name = name;
73 
74 }
75 
76 void ResistanceBCs::renewParameters ( OseenSolverShapeDerivative<RegionMesh<LinearTetra> >& solver,
77  const VectorEpetra& solution,
78  const Real time)
79 {
80 
81  M_resistance = 0.0;
82  M_resistance = computeResistance ( time );
83 
84  // Compute the flux using the solution on the desired flag
85  M_outflux = solver.flux ( M_flag, solution);
86 
87  M_outP = 1.0 * ( M_resistance * M_outflux + M_hydrostaticP );
88 
89  solver.getDisplayer().leaderPrint ( " ****************** Resistance BCs infos ***************************x\n" );
90  solver.getDisplayer().leaderPrint ( " Flow rate = " , M_outflux );
91  solver.getDisplayer().leaderPrint ( " \n" );
92  solver.getDisplayer().leaderPrint ( " Area Inlet = " , solver.area (2) );
93  solver.getDisplayer().leaderPrint ( " \n" );
94  solver.getDisplayer().leaderPrint ( " Area Outlet = ", solver.area (3) );
95  solver.getDisplayer().leaderPrint ( " \n" );
96  solver.getDisplayer().leaderPrint ( " Hydrostatic pressure = " , M_hydrostaticP );
97  solver.getDisplayer().leaderPrint ( " \n" );
98  solver.getDisplayer().leaderPrint ( " Resistance = " , M_resistance );
99  solver.getDisplayer().leaderPrint ( " \n" );
100  solver.getDisplayer().leaderPrint ( " Outflow pressure = " , M_outP );
101  solver.getDisplayer().leaderPrint ( " \n" );
102  solver.getDisplayer().leaderPrint ( " ****************** Resistance BCs infos ***************************" );
103 
104  ResistanceBCs::outputVector[conditionNumber] = M_outP;
105 }
106 
107 Real ResistanceBCs::computeResistance (const Real t )
108 {
109  Real resistance (0);
110 
111  Real highestResistance ( 501950 );
112  Real totalTime = 1.012;
113  Real halfTime = totalTime / 3.0;
114 
115  Real m = ( 0.8 * highestResistance ) / ( totalTime - halfTime );
116 
117  if ( t <= halfTime )
118  {
119  resistance = ( ( highestResistance / 5 ) / ( halfTime ) ) * t ;
120  }
121 
122  if ( t > halfTime && t <= totalTime)
123  {
124  resistance = m * (t - halfTime ) + highestResistance / 5 ;
125  }
126 
127  if ( t > totalTime )
128  {
129  resistance = highestResistance;
130  }
131 
132  // Real a = ( highestResistance / 2 ) * ( 1/ ( halfTime * halfTime ) );
133 
134  // if ( t <= halfTime )
135  // resistance = a * t*t;
136 
137  // if ( t > halfTime )
138  // resistance = - a * (t - totalTime)*(t - totalTime) + highestResistance;
139 
140 
141  return resistance;
142 }
143 
144 
145 
146 
147 Real ResistanceBCs::fZero (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
148 {
149  return 0.0;
150 }
151 
152 Real ResistanceBCs::outPressure0 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
153 {
154  return -ResistanceBCs::outputVector[0];
155 }
156 
157 Real ResistanceBCs::outPressure1 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
158 {
159  return -ResistanceBCs::outputVector[1];
160 }
161 
162 Real ResistanceBCs::outPressure2 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
163 {
164  return -ResistanceBCs::outputVector[2];
165 }
166 Real ResistanceBCs::outPressure3 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
167 {
168  return -ResistanceBCs::outputVector[3];
169 }
170 
171 Real ResistanceBCs::outPressure4 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
172 {
173  return -ResistanceBCs::outputVector[4];
174 }
175 
176 
177 Real ResistanceBCs::outPressure5 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
178 {
179  return -ResistanceBCs::outputVector[5];
180 }
181 
182 Real ResistanceBCs::outPressure6 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
183 {
184  return -ResistanceBCs::outputVector[6];
185 }
186 
187 std::vector<Real> ResistanceBCs::outputVector;
188 
189 
190 // Implicit resistance type
191 
192 ImplicitResistance::ImplicitResistance() :
193  bcVectorResistance( ),
194  coefficient ( 0 ),
195  fluidVector ( )
196 {
197 }
198 
199 
200 void ImplicitResistance::setQuantities ( FSIOperator& _oper,
201  const Real resistance )
202 {
203  // Imposing resistance BCs
204  fluidVector.reset( new FSIOperator::vector_Type( _oper.uFESpacePtr()->map(), Repeated ) );
205  fluidVector->epetraVector().PutScalar(0.0);
206 
207  bcVectorResistance.setRhsVector( *fluidVector,_oper.uFESpacePtr()->dof().numTotalDof(),1);
208  bcVectorResistance.setResistanceCoeff( resistance );
209 
210 }
211 
212 }