LifeV
fsi/testsuite/fsi_segregated/boundaryConditions.hpp
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
30 
31  @author Gilles Fourestey <gilles.fourestey@epfl.ch>
32  @date 00-00-0000
33  */
34 
35 #ifndef BC_HPP
36 #define BC_HPP
37 
38 #include "lifev/core/LifeV.hpp"
39 #include "ud_functions.hpp"
40 #include "lifev/core/fem/BCHandler.hpp"
41 #include "lifev/core/fem/BCFunction.hpp"
42 
43 #include "lifev/fsi/solver/FSIExactJacobian.hpp"
44 #include "lifev/fsi/solver/FSIFixedPoint.hpp"
45 
46 
47 #define OUTLET 3
48 #define INLET 2
49 #define FLUIDINTERFACE 100
50 #define SOLIDINTERFACE 100
51 #define OUTERWALL 1000
52 #define RING 2
53 #define RING2 3
54 #define INOUTEDGE 20
55 #define INEDGE 30
56 
57 //#define FLUX
58 
59 namespace LifeV
60 {
61 
62 typedef FSIOperator::fluid_Type fluid;
63 typedef FSIOperator::solid_Type solid;
64 
65 FSIOperator::fluidBchandlerPtr_Type BCh_harmonicExtension (FSIOperator& _oper)
66 {
67 
68  // debugStream(10000) << "SP harmonic extension\n";
69  // fixedPoint *FPOper = dynamic_cast<fixedPoint *>(&_oper);
70 
71  // FPOper->setStructureDispToHarmonicExtension(_oper.lambdaFluid());
72 
73  if (! _oper.isFluid() )
74  {
75  return FSIOperator::fluidBchandlerPtr_Type();
76  }
77 
78  // FPOper->bcvStructureDispToHarmonicExtension()->showMe(true,std::cout);
79 
80  // Boundary condition for the mesh
81  debugStream ( 10000 ) << "Boundary condition for the harmonic extension\n";
82 
83  BCFunctionBase bcf (fZero);
84 
85  FSISolver::fluidBchandlerPtr_Type BCh_he (new FSIOperator::fluidBchandler_Type );
86 
87 
88 
89  BCh_he->addBC ("Edges", INOUTEDGE, Essential, Full, bcf, 3);
90  BCh_he->addBC ("Edges", INEDGE, Essential, Full, bcf, 3);
91  BCh_he->addBC ("Base", INLET, Essential, Full, bcf, 3);
92 
93  // BCh_he->addBC("Top", 3, Essential, Full, bcf, 3);
94  // BCh_he->addBC("Base", 2, Essential, Full, bcf, 3);
95 
96 
97  if (_oper.data().method() == "steklovPoincare")
98  {
99  // debugStream(10000) << "SP harmonic extension\n";
100  // steklovPoincare *SPOper = dynamic_cast<steklovPoincare *>(&_oper);
101  // SPOper->setFluidInterfaceDisp((LifeV::Vector&) _oper.lambdaFluidRepeated());
102  // BCh_he->addBC("Interface", 1, Essential, Full,
103  // *SPOper->bcvFluidInterfaceDisp(), 3);
104  }
105  else if (_oper.data().method() == "exactJacobian")
106  {
107  debugStream (10000) << "EJ harmonic extension\n";
108  FSIExactJacobian* EJOper = dynamic_cast<FSIExactJacobian*> (&_oper);
109  EJOper->setStructureDispToHarmonicExtension (_oper.lambdaFluidRepeated() );
110  BCh_he->addBC ("Interface", FLUIDINTERFACE, Essential, Full,
111  *EJOper->bcvStructureDispToHarmonicExtension(), 3);
112  }
113  else if (_oper.data().method() == "fixedPoint")
114  {
115  debugStream (10000) << "FP harmonic extension\n";
116  FSIFixedPoint* FPOper = dynamic_cast<FSIFixedPoint*> (&_oper);
117 
118  FPOper->setStructureDispToHarmonicExtension (_oper.lambdaFluidRepeated() );
119  BCh_he->addBC ("Interface", FLUIDINTERFACE, Essential, Full,
120  *FPOper->bcvStructureDispToHarmonicExtension(), 3);
121  }
122 
123 
124 
125  return BCh_he;
126 }
127 
128 
129 FSIOperator::fluidBchandlerPtr_Type BCh_fluid (FSIOperator& _oper)
130 {
131  // Boundary conditions for the fluid velocity
132  debugStream ( 10000 ) << "Boundary condition for the fluid\n";
133 
134  if (! _oper.isFluid() )
135  {
136  return FSIOperator::fluidBchandlerPtr_Type();
137  }
138 
139  FSIOperator::fluidBchandlerPtr_Type BCh_fluid ( new FSIOperator::fluidBchandler_Type );
140 
141  BCFunctionBase bcf (fZero);
142  BCFunctionBase in_flow (u2);
143  // BCFunctionBase in_flow_flux (PhysFlux);
144  BCFunctionBase out_flow (fZero);
145 
146 
147 #ifdef FLUX
148  BCh_fluid->addBC ("InFlow" , 2, Flux, Normal, in_flow, 3);
149 #else
150  BCh_fluid->addBC ("InFlow" , 2, Natural, Full, in_flow, 3);
151 #endif
152 
153  BCh_fluid->addBC ("OutFlow", 3, Natural, Full, out_flow, 3);
154  //BCh_fluid->addBC("EdgesIn", 20, EssentialVertices, Full, bcf, 3);
155 
156 
157 
158 
159  // BCh_fluid->showMe();
160 
161  _oper.setStructureToFluid (_oper.veloFluidMesh() );
162  // _oper.setHarmonicExtensionVelToFluid(_oper.veloFluidMesh());
163 
164  if (_oper.data().algorithm() == "RobinNeumann")
165  {
166  // _oper.setAlphafbcf(alpha); // if alpha is bcFunction define in ud_function.cpp
167 
168  // assert(false);
169  _oper.setSolidLoadToStructure ( _oper.minusSigmaFluidRepeated() );
170  _oper.setStructureToFluidParameters();
171 
172  BCh_fluid->addBC ("Interface", FLUIDINTERFACE, Robin, Full,
173  *_oper.bcvStructureToFluid(), 3);
174  BCh_fluid->addBC ("Interface", FLUIDINTERFACE, Natural, Full,
175  *_oper.bcvSolidLoadToStructure(), 3);
176  }
177  else
178  {
179  BCh_fluid->addBC ("Interface", FLUIDINTERFACE, Essential, Full,
180  *_oper.bcvStructureToFluid(), 3);
181  }
182  return BCh_fluid;
183 }
184 
185 
186 FSIOperator::fluidBchandlerPtr_Type BCh_fluidInv (FSIOperator& _oper)
187 {
188 
189  if (! _oper.isFluid() )
190  {
191  return FSIOperator::fluidBchandlerPtr_Type();
192  }
193 
194  // Boundary conditions for the fluid velocity
195  debugStream ( 10000 ) << "Boundary condition for the inverse fluid\n";
196  FSIOperator::fluidBchandlerPtr_Type BCh_fluidInv ( new FSIOperator::fluidBchandler_Type );
197 
198  BCFunctionBase bcf (fZero);
199  BCFunctionBase in_flow (u2);
200 
201  BCh_fluidInv->addBC ("InFlow", 2, Natural, Full, in_flow, 3);
202  BCh_fluidInv->addBC ("EdgesIn", 20, EssentialVertices, Full, bcf, 3);
203 
204  return BCh_fluidInv;
205 }
206 
207 
208 
209 
210 FSIOperator::fluidBchandlerPtr_Type BCh_fluidLin (FSIOperator& _oper)
211 {
212  if (! _oper.isFluid() )
213  {
214  return FSIOperator::fluidBchandlerPtr_Type();
215  }
216 
217  // Boundary conditions for the fluid velocity
218  debugStream ( 10000 ) << "Boundary condition for the linearized fluid\n";
219  FSIOperator::fluidBchandlerPtr_Type BCh_fluidLin ( new FSIOperator::fluidBchandler_Type );
220 
221  BCFunctionBase bcf (fZero);
222  BCFunctionBase in_flow (u2);
223 
224 #ifdef FLUX
225  BCh_fluidLin->addBC ("InFlow", 2, Flux, Normal, bcf, 3);
226 #else
227  //BCh_fluidLin->addBC("InFlow", 2, Natural, Full, bcf, 3);
228 #endif
229 
230  BCh_fluidLin->addBC ("outFlow", 3, Natural, Full, bcf, 3);
231  //BCh_fluidLin->addBC("Edges", 20, EssentialVertices, Full, bcf, 3);//this condition must be equal to the one
232 
233  //BCh_fluidLin->addBC("ainterface", 1, Essential, Full, bcf, 3);
234 
235 
236  if (_oper.data().method() == "steklovPoincare")
237  {
238  // steklovPoincare *SPOper = dynamic_cast<steklovPoincare *>(&_oper);
239  // SPOper->setDerHarmonicExtensionVelToFluid(_oper.dw());
240  // BCh_fluidLin->addBC("Wall" , 1, Essential , Full,
241  // *SPOper->bcvDerHarmonicExtensionVelToFluid(), 3);
242  }
243  if (_oper.data().method() == "exactJacobian")
244  {
245  FSIExactJacobian* EJOper = dynamic_cast<FSIExactJacobian*> (&_oper);
246  EJOper->setDerHarmonicExtensionVelToFluid (_oper.derVeloFluidMesh() );
247  BCh_fluidLin->addBC ("Interface", FLUIDINTERFACE, Essential , Full,
248  *_oper.bcvDerHarmonicExtensionVelToFluid(), 3);
249  }
250 
251  return BCh_fluidLin;
252 }
253 
254 
255 
256 FSIOperator::solidBchandlerPtr_Type BCh_solid (FSIOperator& _oper)
257 {
258 
259  if (! _oper.isSolid() )
260  {
261  return FSIOperator::solidBchandlerPtr_Type();
262  }
263 
264  // Boundary conditions for the solid displacement
265  debugStream ( 10000 ) << "Boundary condition for the solid\n";
266  FSIOperator::solidBchandlerPtr_Type BCh_solid ( new FSIOperator::solidBchandler_Type );
267 
268  BCFunctionBase bcf (fZero);
269 
270 
271  BCh_solid->addBC ("Top", 3, Essential, Full, bcf, 3);
272  BCh_solid->addBC ("Base", 2, Essential, Full, bcf, 3);
273  //BCh_solid->addBC("EdgesIn", 20, EssentialVertices, Full, bcf, 3);
274 
275  std::vector<ID> zComp (1);
276  zComp[0] = 3;
277  // debugStream(10000) << "SP harmonic extension\n";
278 
279  if (_oper.data().method() == "steklovPoincare")
280  {
281  // steklovPoincare *SPOper = dynamic_cast<steklovPoincare *>(&_oper);
282  // SPOper->setSolidInterfaceDisp((LifeV::Vector&) _oper.displacement());
283 
284  // BCh_solid->addBC("Interface", 1, Essential, Full,
285  // *SPOper->bcvSolidInterfaceDisp(), 3);
286  }
287  else if (_oper.data().method() == "exactJacobian")
288  {
289  FSIExactJacobian* EJOper = dynamic_cast<FSIExactJacobian*> (&_oper);
290  EJOper->setFluidLoadToStructure (_oper.sigmaSolidRepeated() );
291 
292  BCh_solid->addBC ("Interface", SOLIDINTERFACE, Natural, Full,
293  *EJOper->bcvFluidLoadToStructure(), 3);
294  }
295  else if (_oper.data().method() == "fixedPoint")
296  {
297  FSIFixedPoint* FPOper = dynamic_cast<FSIFixedPoint*> (&_oper);
298 
299  FPOper->setFluidLoadToStructure (_oper.sigmaSolidRepeated() );
300 
301  BCh_solid->addBC ("Interface", FLUIDINTERFACE, Natural, Full,
302  *FPOper->bcvFluidLoadToStructure(), 3);
303  }
304 
305  return BCh_solid;
306 }
307 
308 
309 FSIOperator::solidBchandlerPtr_Type BCh_solidLin (FSIOperator& _oper)
310 {
311  if (! _oper.isSolid() )
312  {
313  return FSIOperator::solidBchandlerPtr_Type();
314  }
315 
316  // Boundary conditions for the solid displacement
317  debugStream ( 10000 ) << "Boundary condition for the linear solid\n";
318  FSIOperator::solidBchandlerPtr_Type BCh_solidLin ( new FSIOperator::solidBchandler_Type );
319 
320  BCFunctionBase bcf (fZero);
321 
322  BCh_solidLin->addBC ("Top", 3, Essential, Full, bcf, 3);
323  BCh_solidLin->addBC ("Base", 2, Essential, Full, bcf, 3);
324  //BCh_solidLin->addBC("EdgesIn", 20, EssentialVertices, Full, bcf, 3);
325 
326  std::vector<ID> zComp (1);
327  zComp[0] = 3;
328 
329  if (_oper.data().method() == "steklovPoincare")
330  {
331  // steklovPoincare *SPOper = dynamic_cast<steklovPoincare *>(&_oper);
332  // SPOper->setSolidLinInterfaceDisp((LifeV::Vector&) _oper.displacement());
333  // BCh_solidLin->addBC("Interface", 1, Essential, Full,
334  // *SPOper->bcvSolidLinInterfaceDisp(), 3);
335  }
336  else if (_oper.data().method() == "exactJacobian")
337  {
338  FSIExactJacobian* EJOper = dynamic_cast<FSIExactJacobian*> (&_oper);
339  EJOper->setDerFluidLoadToStructure (_oper.sigmaSolidRepeated() );
340  BCh_solidLin->addBC ("Interface", SOLIDINTERFACE, Natural, Full,
341  *EJOper->bcvDerFluidLoadToStructure(), 3);
342  }
343 
344  return BCh_solidLin;
345 }
346 
347 FSIOperator::solidBchandlerPtr_Type BCh_solidInvLin (FSIOperator& _oper)
348 {
349 
350  if (! _oper.isSolid() )
351  {
352  return FSIOperator::solidBchandlerPtr_Type();
353  }
354 
355  // Boundary conditions for the solid displacement
356  debugStream ( 10000 ) << "Boundary condition for the inverse linear solid\n";
357  FSIOperator::solidBchandlerPtr_Type BCh_solidLinInv ( new FSIOperator::solidBchandler_Type );
358 
359  BCFunctionBase bcf (fZero);
360 
361  BCh_solidLinInv->addBC ("Base", 2, Essential, Full, bcf, 3);
362  BCh_solidLinInv->addBC ("EdgesIn", 20, EssentialVertices, Full, bcf, 3);
363 
364  // if (_oper.method() == "steklovPoincare")
365  // {
366  // steklovPoincare *SPOper = dynamic_cast<steklovPoincare *>(&_oper);
367  // SPOper->setSolidInvLinInterfaceStress((LifeV::Vector&) _oper.residual());
368 
369  // BCh_solidLinInv->addBC("Interface", 100, Natural, Full,
370  // *SPOper->bcvSolidInvLinInterfaceStress(), 3);
371  // }
372  // else
373  // {
374  // exactJacobian *EJOper = dynamic_cast<exactJacobian *>(&_oper);
375  // EJOper->setDerFluidLoadToStructure(_oper.fluid().residual());
376  // BCh_solidLinInv->addBC("Interface", 1, Natural, Full,
377  // *EJOper->bcvDerFluidLoadToStructure(), 3);
378  // }
379 
380  return BCh_solidLinInv;
381 }
382 
383 
384 
385 
386 
387 
388 
389 
390 
391 }
392 
393 #endif
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
FSIOperator::fluidBchandlerPtr_Type BCh_fluidLin(FSIOperator &_oper)
FSIOperator::solidBchandlerPtr_Type BCh_solid(FSIOperator &_oper)
#define debugStream
Definition: LifeDebug.hpp:182
FSIOperator::solidBchandlerPtr_Type BCh_solidLin(FSIOperator &_oper)
FSIOperator::fluidBchandlerPtr_Type BCh_fluid(FSIOperator &_oper)
FSIModelExactJacobian - Implementation of an FSI (Operator) with Newton algorithm.
NdebugStream noDebugStream(int=0, NdebugStream::stprintf=&printf)
Definition: LifeDebug.hpp:183
FSIFixedPont - Implementation of an FSI with fixed point iterations.
FSIOperator::solidBchandlerPtr_Type BCh_solidInvLin(FSIOperator &_oper)
FSIOperator::fluidBchandlerPtr_Type BCh_fluidInv(FSIOperator &_oper)