LifeV
BCInterfaceFunctionSolverDefinedFSI3D.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 File containing the BCInterfaceFunctionSolverDefined class and specializations
30  *
31  * @date 23-04-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #ifndef BCInterfaceFunctionSolverDefinedFSI3D_H
38 #define BCInterfaceFunctionSolverDefinedFSI3D_H 1
39 
40 // FSI includes
41 #include <lifev/fsi/solver/FSIExactJacobian.hpp>
42 #include <lifev/fsi/solver/FSIFixedPoint.hpp>
43 
44 #include <lifev/fsi/solver/FSIMonolithicGE.hpp>
45 #include <lifev/fsi/solver/FSIMonolithicGI.hpp>
46 
47 // BCInterface includes
48 #include <lifev/bc_interface/3D/bc/BCInterfaceData3D.hpp>
49 #include <lifev/bc_interface/core/function/BCInterfaceFunctionSolverDefined.hpp>
50 
51 namespace LifeV
52 {
53 
54 //! BCInterfaceFunctionSolverDefined - Template specialization of \c BCInterfaceFunctionSolverDefined for 3D FSI problems
55 /*!
56  * @author Cristiano Malossi
57  *
58  *
59  * The BCInterfaceFunctionSolverDefined class provides the interface between the
60  * \c BCInterface3D and the solver defined boundary conditions of the \c FSIOperator.
61  *
62  * <b>DETAILS:</b> <BR>
63  * The constructor of the class takes a string contains the ID of the boundary condition to impose.
64  * The list of available conditions is the \c FSIFunction enum. These are:
65  *
66  * <ol>
67  * <li> DerFluidLoadToFluid, (not implemented)
68  * <li> DerFluidLoadToStructure,
69  * <li> DerHarmonicExtensionVelToFluid,
70  * <li> DerStructureDispToSolid, (not implemented)
71  * <li> FluidInterfaceDisp, (not working)
72  * <li> FluidLoadToStructure,
73  * <li> HarmonicExtensionVelToFluid,
74  * <li> SolidLoadToStructure,
75  * <li> StructureDispToHarmonicExtension,
76  * <li> StructureDispToSolid, (not implemented)
77  * <li> StructureToFluid
78  * <li> RobinWall
79  * </ol>
80  *
81  * The class automatically recognize which FSI algorithm is used among:
82  * <ol>
83  * <li> EXACTJACOBIAN;
84  * <li> FIXEDPOINT;
85  * <li> MONOLITHIC_GE;
86  * <li> MONOLITHIC_GI;
87  * </ol>
88  */
89 template< >
90 class BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >
91 {
92 public:
93 
94  //! @name Type definitions
95  //@{
96 
97  typedef BCHandler bcHandler_Type;
99 
100  typedef FSIOperator physicalSolver_Type;
102 
103  typedef BCInterfaceFactory< bcHandler_Type, physicalSolver_Type > factory_Type;
104  typedef BCInterfaceFunction< bcHandler_Type, physicalSolver_Type > bcFunction_Type;
107 
108  typedef BCInterfaceFunctionParserSolver< bcHandler_Type, physicalSolver_Type > functionParserSolver_Type;
110 
111  typedef BCInterfaceData3D data_Type;
113 
114  //@}
115 
116 
117  //! @name Constructors & Destructor
118  //@{
119 
120  //! Constructor
122 
123  //! Destructor
125 
126  //@}
127 
128 
129  //! @name Methods
130  //@{
131 
132  //! Copy the stored parameters in the data container
133  /*!
134  * @param data boundary condition data loaded from \c GetPot file
135  */
136  void exportData ( dataPtr_Type& data );
137 
138  //! Assign a boundary function to the boundary condition vector base
139  /*!
140  * @param physicalSolver FSI physical solver,
141  * @param base boundary condition base
142  */
143  template< class BCBaseType >
144  void assignFunction ( BCBaseType& base );
145 
146  //! Update the solver variables
148 
149  //@}
150 
151 
152  //! @name Set methods
153  //@{
154 
155  //! Set data
156  /*!
157  * @param data boundary condition data loaded from \c GetPot file
158  */
159  void setData ( const dataPtr_Type& data );
160 
161  //! Set the physical solver
162  /*!
163  * @param physicalSolver physical solver
164  */
165  void setPhysicalSolver ( const physicalSolverPtr_Type& physicalSolver )
166  {
167  M_physicalSolver = physicalSolver;
168  }
169 
170  //@}
171 
172 
173  //! @name Get methods
174  //@{
175 
176  //! Detect the correct base type
177  /*!
178  * @param bcBaseType the type of the base
179  */
180  baseContainer_Type baseType() const;
181 
182  //@}
183 
184 private:
185 
186  //! @name Unimplemented Methods
187  //@{
188 
189  BCInterfaceFunctionSolverDefined ( const BCInterfaceFunctionSolverDefined& function );
190 
191  BCInterfaceFunctionSolverDefined& operator= ( const BCInterfaceFunctionSolverDefined& function );
192 
193  //@}
194 
195 
196  //! @name Private Methods
197  //@{
198 
199  template< class MethodType >
200  void checkFunction ( BCVectorInterface& base );
201 
202  template< class MethodType >
203  void checkFunction ( BCVector& base );
204 
205  template< class MethodType >
206  void checkFunction ( BCFunctionBase& base );
207 
208  //@}
209 
211  {
213  };
214 
216  {
229  };
230 
232 
234 
235  // The following members are required since the FSI BC are applied
236  // a posteriori, when setPhysicalSolver() is called.
237 
238  // Classical parameters
239  bcName_Type M_name;
240  bcFlag_Type M_flag;
241  bcType_Type M_type;
242  bcMode_Type M_mode;
243  bcComponentsVec_Type M_componentsVector;
244 
245  // RobinViscoelastic
247  FSIOperator::vectorPtr_Type M_robinRHS;
248  FSIOperator::vectorPtr_Type M_robinAlphaCoefficient;
249  FSIOperator::vectorPtr_Type M_robinBetaCoefficient;
250 };
251 
252 // ===================================================
253 // Methods
254 // ===================================================
255 template< class BCBaseType >
256 inline void
257 BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::assignFunction ( BCBaseType& base )
258 {
259  //Set mapMethod
260  std::map< std::string, FSIMethod > mapMethod;
261 
262  mapMethod["exactJacobian"] = EXACTJACOBIAN;
263  mapMethod["fixedPoint"] = FIXEDPOINT;
264  mapMethod["monolithicGE"] = MONOLITHIC_GE;
265  mapMethod["monolithicGI"] = MONOLITHIC_GI;
266 
267  switch ( mapMethod[M_physicalSolver->data().method()] )
268  {
269  case EXACTJACOBIAN:
270 
271 #ifdef HAVE_LIFEV_DEBUG
272  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkMethod exactJacobian" << "\n";
273 #endif
274 
275  checkFunction< FSIExactJacobian > ( base );
276 
277  break;
278 
279  case FIXEDPOINT:
280 
281 #ifdef HAVE_LIFEV_DEBUG
282  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkMethod fixedPoint" << "\n";
283 #endif
284 
285  checkFunction< FSIFixedPoint > ( base );
286 
287  break;
288 
289  case MONOLITHIC_GE:
290 
291 #ifdef HAVE_LIFEV_DEBUG
292  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkMethod monolithicGE" << "\n";
293 #endif
294 
295  checkFunction< FSIMonolithicGE > ( base );
296 
297  break;
298 
299  case MONOLITHIC_GI:
300 
301 #ifdef HAVE_LIFEV_DEBUG
302  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkMethod monolithicGI" << "\n";
303 #endif
304 
305  checkFunction< FSIMonolithicGI > ( base );
306 
307  break;
308 
309  default:
310 
311  std::cout << " !!! Warning:" << mapMethod[M_physicalSolver->data().method()] << " not assigned !!!" << std::endl;
312 
313  break;
314 
315  }
316 }
317 
318 // ===================================================
319 // Private functions
320 // ===================================================
321 template< class MethodType >
322 inline void BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::checkFunction ( BCVectorInterface& base )
323 {
324  std::shared_ptr< MethodType > operMethod = std::dynamic_pointer_cast< MethodType > ( M_physicalSolver );
325 
326  switch ( M_FSIFunction )
327  {
328  case DerFluidLoadToFluid:
329 
330 #ifdef HAVE_LIFEV_DEBUG
331  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction DerFluidLoadToFluid" << "\n";
332 #endif
333 
334  break;
335 
337 
338 #ifdef HAVE_LIFEV_DEBUG
339  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction DerFluidLoadToStructure" << "\n";
340 #endif
341  if ( !operMethod->isSolid() )
342  {
343  return;
344  }
345 
346  operMethod->setDerFluidLoadToStructure ( operMethod->sigmaSolidRepeated() );
347 
348  base = *operMethod->bcvDerFluidLoadToStructure();
349 
350  break;
351 
353 
354 #ifdef HAVE_LIFEV_DEBUG
355  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction DerHarmonicExtensionVelToFluid" << "\n";
356 #endif
357 
358  if ( !operMethod->isFluid() )
359  {
360  return;
361  }
362 
363  operMethod->setDerHarmonicExtensionVelToFluid ( operMethod->derVeloFluidMesh() );
364 
365  base = *operMethod->bcvDerHarmonicExtensionVelToFluid();
366 
367  break;
368 
370 
371 #ifdef HAVE_LIFEV_DEBUG
372  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction DerStructureDispToSolid" << "\n";
373 #endif
374 
375  break;
376 
377  case FluidInterfaceDisp:
378 
379 #ifdef HAVE_LIFEV_DEBUG
380  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction FluidInterfaceDisp" << "\n";
381 #endif
382 
383  //operMethod->FluidInterfaceDisp( (LifeV::Vector&) operMethod->lambdaFluidRepeated() );
384 
385  //base = *operMethod->bcvFluidInterfaceDisp();
386 
387  break;
388 
390 
391 #ifdef HAVE_LIFEV_DEBUG
392  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction FluidLoadToStructure" << "\n";
393 #endif
394 
395  if ( !operMethod->isSolid() )
396  {
397  return;
398  }
399 
400  operMethod->setFluidLoadToStructure ( operMethod->sigmaSolidRepeated() );
401 
402  base = *operMethod->bcvFluidLoadToStructure();
403 
404  break;
405 
407 
408 #ifdef HAVE_LIFEV_DEBUG
409  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction HarmonicExtensionVelToFluid" << "\n";
410 #endif
411 
412  if ( !operMethod->isFluid() )
413  {
414  return;
415  }
416 
417  operMethod->setHarmonicExtensionVelToFluid ( operMethod->veloFluidMesh() );
418 
419  base = *operMethod->bcvHarmonicExtensionVelToFluid();
420 
421  break;
422 
424 
425 #ifdef HAVE_LIFEV_DEBUG
426  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction SolidLoadToStructure" << "\n";
427 #endif
428  if ( !operMethod->isFluid() )
429  {
430  return;
431  }
432 
433  operMethod->setSolidLoadToStructure ( operMethod->minusSigmaFluidRepeated() );
434 
435  base = *operMethod->bcvSolidLoadToStructure();
436 
437  break;
438 
440 
441 #ifdef HAVE_LIFEV_DEBUG
442  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction StructureDispToHarmonicExtension" << "\n";
443 #endif
444 
445  if ( !operMethod->isFluid() )
446  {
447  return;
448  }
449 
450  operMethod->setStructureDispToHarmonicExtension ( operMethod->lambdaFluidRepeated() );
451 
452  base = *operMethod->bcvStructureDispToHarmonicExtension();
453 
454  break;
455 
457 
458 #ifdef HAVE_LIFEV_DEBUG
459  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction StructureDispToSolid" << "\n";
460 #endif
461 
462  break;
463 
464  case StructureToFluid:
465 
466 #ifdef HAVE_LIFEV_DEBUG
467  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction StructureToFluid" << "\n";
468 #endif
469 
470  if ( !operMethod->isFluid() )
471  {
472  return;
473  }
474 
475  operMethod->setStructureToFluid ( operMethod->veloFluidMesh() );
476  operMethod->setStructureToFluidParameters();
477 
478  base = *operMethod->bcvStructureToFluid();
479 
480  break;
481 
482  default:
483 
484  std::cout << " !!! Error: " << M_FSIFunction << " is not available as a BCVectorInterface !!!" << std::endl;
485 
486  break;
487  }
488 }
489 
490 template< class MethodType >
491 inline void BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::checkFunction ( BCVector& base )
492 {
493  std::shared_ptr< MethodType > operMethod = std::dynamic_pointer_cast< MethodType > ( M_physicalSolver );
494 
495  switch ( M_FSIFunction )
496  {
497  case RobinWall:
498 
499 #ifdef HAVE_LIFEV_DEBUG
500  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction RobinWall" << "\n";
501 #endif
502 
503  if ( !operMethod->isSolid() )
504  {
505  return;
506  }
507 
508  // Define the vectors
509  M_robinRHS.reset ( new physicalSolver_Type::vector_Type ( operMethod->dFESpace().map(), Repeated, Zero ) );
510  M_robinAlphaCoefficient.reset ( new physicalSolver_Type::vector_Type ( operMethod->dFESpace().map(), Repeated, Zero ) );
511  M_robinBetaCoefficient.reset ( new physicalSolver_Type::vector_Type ( operMethod->dFESpace().map(), Repeated, Zero ) );
512 
513  // Set the vectors (still empty)
514  base.setRhsVector ( *M_robinRHS, operMethod->dFESpace().dof().numTotalDof(), 0 );
515  base.setRobinCoeffVector ( *M_robinAlphaCoefficient );
516  base.setBetaCoeffVector ( *M_robinBetaCoefficient );
517 
518  // Set the physical solver in the Robin functions for alpha and beta
519  for ( UInt i ( 0 ); i < M_vectorFunctionRobin.size(); ++i )
520  {
521  functionParserSolverPtr_Type castedFunctionSolver = std::dynamic_pointer_cast< functionParserSolver_Type > ( M_vectorFunctionRobin[i] );
522 
523  if ( castedFunctionSolver != 0 )
524  {
525  castedFunctionSolver->setPhysicalSolver ( M_physicalSolver );
526  }
527  }
528 
529  break;
530 
531  default:
532 
533  std::cout << " !!! Error: " << M_FSIFunction << " is not available as a BCVector !!!" << std::endl;
534 
535  break;
536  }
537 }
538 
539 template< class MethodType >
540 inline void BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::checkFunction ( BCFunctionBase& /*base*/ )
541 {
542  std::shared_ptr< MethodType > operMethod = std::dynamic_pointer_cast< MethodType > ( M_physicalSolver );
543 
544  switch ( M_FSIFunction )
545  {
546  default:
547 
548  std::cout << " !!! Error: " << M_FSIFunction << " is not available as a BCFunction !!!" << std::endl;
549 
550  return;
551  }
552 }
553 
554 } // Namespace LifeV
555 
556 #endif /* BCInterfaceFunctionSolverDefined_H */
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
void setPhysicalSolver(const physicalSolverPtr_Type &physicalSolver)
Set the physical solver.
BCInterfaceFunction< bcHandler_Type, physicalSolver_Type > bcFunction_Type
BCInterfaceFunctionSolverDefined(const BCInterfaceFunctionSolverDefined &function)
void assignFunction(BCBaseType &base)
Assign a boundary function to the boundary condition vector base.
BCInterfaceFunctionParserSolver< bcHandler_Type, physicalSolver_Type > functionParserSolver_Type
BCInterfaceFunctionSolverDefined & operator=(const BCInterfaceFunctionSolverDefined &function)
void exportData(dataPtr_Type &data)
Copy the stored parameters in the data container.