LifeV
BCInterface3D.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 BCInterface3D class
30  *
31  * @date 01-04-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #ifndef BCInterface3D_H
38 #define BCInterface3D_H 1
39 
40 // BCInterface includes
41 #include <lifev/bc_interface/core/bc/BCInterface.hpp>
42 #include <lifev/bc_interface/3D/bc/BCInterfaceData3D.hpp>
43 
44 /** When using BCInterface3D, you have to include beforehand the relevant functions.
45  * In particular:
46  *
47  * for Fluid:
48 #include <lifev/bc_interface/3D/function/fluid/BCInterfaceFunctionParserFluid3D.hpp>
49 #include <lifev/bc_interface/3D/function/fluid/BCInterfaceFunctionParserSolverFluid3D.hpp>
50 #include <lifev/bc_interface/3D/function/fluid/BCInterfaceFunctionUserDefinedFluid3D.hpp>
51 
52  * for Solid:
53 #include <lifev/bc_interface/3D/function/solid/BCInterfaceFunctionParserSolid3D.hpp>
54 #include <lifev/bc_interface/3D/function/solid/BCInterfaceFunctionParserSolverSolid3D.hpp>
55 #include <lifev/bc_interface/3D/function/solid/BCInterfaceFunctionSolverDefinedSolid3D.hpp>
56 #include <lifev/bc_interface/3D/function/solid/BCInterfaceFunctionUserDefinedSolid3D.hpp>
57 
58  * For FSI:
59 #include <lifev/bc_interface/3D/function/fsi/BCInterfaceFunctionParserFSI3D.hpp>
60 #include <lifev/bc_interface/3D/function/fsi/BCInterfaceFunctionParserSolverFSI3D.hpp>
61 #include <lifev/bc_interface/3D/function/fsi/BCInterfaceFunctionSolverDefinedFSI3D.hpp>
62 #include <lifev/bc_interface/3D/function/fsi/BCInterfaceFunctionUserDefinedFSI3D.hpp>
63 */
64 
65 namespace LifeV
66 {
67 
68 //! BCInterface3D - LifeV interface to load boundary conditions for 3D problems completely from a \c GetPot file
69 /*!
70  * @author Cristiano Malossi
71  *
72  * This class allows to impose boundary conditions for a 3D problem completely from a file.
73  *
74  * <b>EXAMPLE - DATA FILE</b> <BR>
75  * In the GetPot data file, \c BCInterface reads a new section: <CODE> [boundary_conditions] </CODE>.
76  *
77  * Inside the new section there is a list of boundary conditions which correspond to other sub-section
78  * with the same name, for example: <CODE> list = 'InFlow OutFlow' </CODE>
79  *
80  * Each boundary condition has a similar structure. The list of properties depends from the type of the
81  * boundary condition. For example:
82  *
83  * <CODE>
84  * [InFlow] <BR>
85  * type = Essential <BR>
86  * flag = 2 <BR>
87  * mode = Full <BR>
88  * component = 3 <BR>
89  * function = '[0, 0, 3*0.03*(1/4-(x^2+y^2)]' <BR>
90  *
91  * [OutFlow] <BR>
92  * type = Essential <BR>
93  * flag = 3 <BR>
94  * mode = Full <BR>
95  * component = 3 <BR>
96  * function = '0' <BR>
97  * </CODE>
98  *
99  * where \c type, \c flag, \c mode, \c component are the classical parameters for a 3D boundary condition.
100  * The string \c function represents the base module and can be replaced by other derived/alternative modules.
101  * The following functions are available (see the related classes for more information):
102  *
103  * <ol>
104  * <li> \c function, which is implemented in \c BCInterfaceFunctionParser;
105  * <li> \c functionFile, which is implemented in \c BCInterfaceFunctionParserFile;
106  * <li> \c functionSolver, which is implemented in \c BCInterfaceFunctionParserSolver;
107  * <li> \c functionFileSolver, which is implemented in \c BCInterfaceFunctionParserFileSolver;
108  * <li> \c functionUD, which is implemented in \c BCInterfaceFunctionUserDefined;
109  * <li> \c functionSD, which is implemented in \c BCInterfaceFunctionSolverDefined;
110  * <li> \c dataInterpolator, which is implemented in\c BCDataInterpolator;
111  * </ol>
112  *
113  * All the parameters are case sensitive.
114  *
115  * See \c BCInterface base class for more details.
116  */
117 template< class BcHandler, class PhysicalSolverType >
118 class BCInterface3D : public virtual BCInterface< BcHandler, PhysicalSolverType >
119 {
120 public:
121 
122  //! @name Type definitions
123  //@{
124 
125  typedef BCInterface< BcHandler, PhysicalSolverType > bcInterface_Type;
126 
129 
132 
134 
137 
140 
143 
147 
151 
155 
156  //@}
157 
158 
159  //! @name Constructors & Destructor
160  //@{
161 
162  //! Constructor
163  explicit BCInterface3D();
164 
165  //! Destructor
166  virtual ~BCInterface3D() {}
167 
168  //@}
169 
170 
171  //! @name Methods
172  //@{
173 
174  //! Read a specific boundary condition from a file and add it to the data container
175  /*!
176  * @param fileName Name of the data file
177  * @param dataSection section in the data file
178  * @param name name of the boundary condition
179  */
180  void readBC ( const std::string& fileName, const std::string& dataSection, const std::string& name )
181  {
182  M_data->readBC ( fileName, dataSection, name );
183  }
184 
185  //! Insert the current boundary condition in the BChandler
186  void insertBC();
187 
188  //@}
189 
190 
191  //! @name External interface for BCHandler functions
192  //@{
193 
194  //! Add a Boundary Condition using the standard interface of the BCHandler
195  /*!
196  * @param name name of the condition
197  * @param flag list of flags
198  * @param type type of the condition
199  * @param mode mode of the condition
200  * @param base base of the condition
201  */
202  template< class BCBaseType >
203  void addBC ( const bcName_Type& name, const bcFlag_Type& flag, const bcType_Type& type, const bcMode_Type& mode, BCBaseType& base )
204  {
205  this->M_handler->addBC ( name, flag, type, mode, base );
206  }
207 
208  //! Add a Boundary Condition with component using the standard interface of the BCHandler
209  /*!
210  * @param name name of the condition
211  * @param flag list of flags
212  * @param type type of the condition
213  * @param mode mode of the condition
214  * @param base base of the condition
215  * @param comp component of the condition
216  */
217  template< class BCBaseType, class BCCompType >
218  void addBC ( const bcName_Type& name, const bcFlag_Type& flag, const bcType_Type& type, const bcMode_Type& mode, BCBaseType& base, const BCCompType& comp )
219  {
220  this->M_handler->addBC ( name, flag, type, mode, base, comp );
221  }
222 
223  //@}
224 
225 
226  //! @name Set Methods
227  //@{
228 
229  //! Set a physical solver
230  /*!
231  * @param physicalSolver physical solver
232  */
233  void setPhysicalSolver ( const physicalSolverPtr_Type& physicalSolver );
234 
235  //@}
236 
237 
238  //! @name Get Methods
239  //@{
240 
241  //! Get the data container
242  /*!
243  * @return the data container
244  */
246  {
247  return *M_data;
248  }
249 
250  //@}
251 
252 private:
253 
254  //! @name Unimplemented Methods
255  //@{
256 
257  BCInterface3D ( const BCInterface3D& bcInterface3D );
258 
259  BCInterface3D& operator= ( const BCInterface3D& bcInterface3D );
260 
261  //@}
262 
263 
264  //! @name Private Methods
265  //@{
266 
267  template< class BCBaseType >
268  void createFunctionRobin ( BCBaseType& base );
269 
270  template< class BCBaseType >
271  void createFunctionDirectional ( BCBaseType& base );
272 
274 
275  template< class BCBaseType >
276  void addBcToHandler ( BCBaseType& base );
277 
278  //@}
279 
280  // Data
282 
283  // Functions Robin
285 
286  // Functions Directions
288 
289  // Data Interpolator Functions
291 
292 };
293 
294 // ===================================================
295 // Constructors & Destructor
296 // ===================================================
297 template< class BcHandler, class PhysicalSolverType >
298 BCInterface3D< BcHandler, PhysicalSolverType >::BCInterface3D() :
299  bcInterface_Type (),
300  M_data ( new data_Type() ),
304 {
305 
306 #ifdef HAVE_LIFEV_DEBUG
307  debugStream ( 5020 ) << "BCInterface3D::BCInterface3D" << "\n";
308 #endif
309 
310 }
311 
312 // ===================================================
313 // Methods
314 // ===================================================
315 template< class BcHandler, class PhysicalSolverType >
316 void
317 BCInterface3D< BcHandler, PhysicalSolverType >::insertBC()
318 {
319 
320 #ifdef HAVE_LIFEV_DEBUG
321  debugStream ( 5020 ) << "BCInterface3D::insertBC\n";
322 #endif
323 
324  switch ( M_data->base().second )
325  {
326  case BCIFunctionParser:
327  case BCIFunctionParserFile:
328  case BCIFunctionParserSolver:
329  case BCIFunctionParserFileSolver:
330  case BCIFunctionUserDefined:
331  {
332  factory_Type factory;
333  this->M_vectorFunction.push_back ( factory.createFunctionParser ( M_data ) );
334 
335  BCFunctionBase base;
336  this->M_vectorFunction.back()->assignFunction ( base );
337 
338  // Directional BC
339  if ( M_data->mode() == Directional )
340  {
341  createFunctionDirectional ( base );
342  addBcToHandler ( *M_vectorFunctionDirection.back() );
343 
344  return;
345  }
346 
347  // Robin BC
348  if ( M_data->type() == Robin )
349  {
350  createFunctionRobin ( base );
351  addBcToHandler ( *M_vectorFunctionRobin.back() );
352 
353  return;
354  }
355 
356  // All the other type of BC
357  addBcToHandler ( base );
358 
359  return;
360  }
361  case BCIFunctionSolverDefined:
362  {
363  factory_Type factory;
364  this->M_vectorFunctionSolverDefined.push_back ( factory.createFunctionSolverDefined ( M_data ) );
365 
366  return;
367  }
368  case BCI3DDataInterpolator:
369 
370  createFunctionDataInterpolator();
371  addBcToHandler ( *M_vectorDataInterpolator.back() );
372 
373  return;
374 
375  default:
376 
377  std::cout << " !!! Error: " << M_data->base().first << " is not valid in BCInterface3D !!!" << std::endl;
378 
379  break;
380  }
381 }
382 
383 // ===================================================
384 // Set Methods
385 // ===================================================
386 template< class BcHandler, class PhysicalSolverType >
387 void
388 BCInterface3D< BcHandler, PhysicalSolverType >::setPhysicalSolver ( const physicalSolverPtr_Type& physicalSolver )
389 {
390  bcInterface_Type::setPhysicalSolver ( physicalSolver );
391 
392  for ( typename vectorFunctionSolverDefined_Type::const_iterator i = this->M_vectorFunctionSolverDefined.begin() ; i < this->M_vectorFunctionSolverDefined.end() ; ++i )
393  {
394  ( *i )->exportData ( M_data );
395 
396  // Robin BC
397  if ( M_data->type() == Robin )
398  {
399  BCVector base;
400 
401  ( *i )->assignFunction ( base );
402  addBcToHandler ( base );
403  }
404  else
405  {
406  BCVectorInterface base;
407 
408  ( *i )->assignFunction ( base );
409  addBcToHandler ( base );
410  }
411  }
412 }
413 
414 // ===================================================
415 // Private Methods
416 // ===================================================
417 template< class BcHandler, class PhysicalSolverType > template< class BCBaseType >
418 inline void
419 BCInterface3D< BcHandler, PhysicalSolverType >::createFunctionRobin ( BCBaseType& base )
420 {
421  // Parameters for direction BC
422  M_data->setName ( M_data->name() + "_robinMassTerm" );
423  M_data->setRobinBaseAlpha();
424 
425  // Create the mass term function
426  factory_Type factory;
427  this->M_vectorFunction.push_back ( factory.createFunctionParser ( M_data ) );
428 
429  BCFunctionBase baseRobin;
430  this->M_vectorFunction.back()->assignFunction ( baseRobin );
431 
432  // Robin base
433  bcFunctionRobinPtr_Type robinBase ( new bcFunctionRobin_Type ( base.Function(), baseRobin.Function() ) );
434  M_vectorFunctionRobin.push_back ( robinBase );
435 }
436 
437 template< class BcHandler, class PhysicalSolverType > template< class BCBaseType >
438 inline void
439 BCInterface3D< BcHandler, PhysicalSolverType >::createFunctionDirectional ( BCBaseType& base )
440 {
441  // Parameters for direction BC
442  M_data->setName ( M_data->name() + "_directionalField" );
443  M_data->setDirectionalBase();
444 
445  // Create the directional field
446  factory_Type factory;
447  this->M_vectorFunction.push_back ( factory.createFunctionParser ( M_data ) );
448 
449  BCFunctionBase baseDirectional;
450  this->M_vectorFunction.back()->assignFunction ( baseDirectional );
451 
452  // Directional base
453  bcFunctionDirectionalPtr_Type directionalBase ( new bcFunctionDirectional_Type ( base.Function(), baseDirectional.Function() ) );
454  M_vectorFunctionDirection.push_back ( directionalBase );
455 }
456 
457 template< class BcHandler, class PhysicalSolverType >
458 inline void
459 BCInterface3D< BcHandler, PhysicalSolverType >::createFunctionDataInterpolator()
460 {
461  // Directional base
462  bcFunctionDataInterpolatorPtr_Type dataInterpolatorBase ( new bcFunctionDataInterpolator_Type() );
463  dataInterpolatorBase->readData ( M_data->baseString() );
464  dataInterpolatorBase->setInterpolationMethod ( LifeV::BCDataInterpolator::RBF_InverseMultiQuadric);
465  M_vectorDataInterpolator.push_back ( dataInterpolatorBase );
466 }
467 
468 template< class BcHandler, class PhysicalSolverType > template< class BCBaseType >
469 inline void
470 BCInterface3D< BcHandler, PhysicalSolverType >::addBcToHandler ( BCBaseType& base )
471 {
472  if ( !this->M_handler.get() ) // If BCHandler has not been created yet, we do it now
473  {
474  this->createHandler();
475  }
476 
477  switch ( M_data->mode() )
478  {
479  case Scalar:
480  case Normal:
481  case Tangential:
482  case Directional:
483 
484 #ifdef HAVE_LIFEV_DEBUG
485  debugStream ( 5020 ) << "BCInterface3D::addBcToHandler Scalar, Normal, Tangential, Directional" << "\n\n";
486 #endif
487 
488  this->M_handler->addBC ( M_data->name(), M_data->flag(), M_data->type(), M_data->mode(), base );
489 
490  break;
491 
492  case Full:
493 
494 #ifdef HAVE_LIFEV_DEBUG
495  debugStream ( 5020 ) << "BCInterface3D::addBcToHandler Full" << "\n\n";
496 #endif
497 
498  this->M_handler->addBC ( M_data->name(), M_data->flag(), M_data->type(), M_data->mode(), base, M_data->componentsNumber() );
499 
500  break;
501 
502  case Component:
503 
504 #ifdef HAVE_LIFEV_DEBUG
505  debugStream ( 5020 ) << "BCInterface3D::addBcToHandler Component" << "\n\n";
506 #endif
507 
508  this->M_handler->addBC ( M_data->name(), M_data->flag(), M_data->type(), M_data->mode(), base, M_data->componentsVector() );
509 
510  break;
511  }
512 }
513 
514 } // Namespace LifeV
515 
516 #endif /* BCInterface3D_H */
void createFunctionRobin(BCBaseType &base)
bcInterface_Type::vectorFunctionSolverDefined_Type vectorFunctionSolverDefined_Type
std::vector< bcFunctionRobinPtr_Type > vectorFunctionRobin_Type
BCInterface3D(const BCInterface3D &bcInterface3D)
data_Type & dataContainer()
Get the data container.
markerID_Type bcFlag_Type
Definition: BCBase.hpp:118
virtual ~BCInterface3D()
Destructor.
std::shared_ptr< bcFunctionDataInterpolator_Type > bcFunctionDataInterpolatorPtr_Type
bcInterface_Type::factory_Type factory_Type
void readBC(const std::string &fileName, const std::string &dataSection, const std::string &name)
Read a specific boundary condition from a file and add it to the data container.
BCFunctionRobin bcFunctionRobin_Type
std::vector< bcFunctionDataInterpolatorPtr_Type > vectorDataInterpolator_Type
BCInterface< BcHandler, PhysicalSolverType > bcInterface_Type
BCInterface3D - LifeV interface to load boundary conditions for 3D problems completely from a GetPot ...
void addBC(const bcName_Type &name, const bcFlag_Type &flag, const bcType_Type &type, const bcMode_Type &mode, BCBaseType &base, const BCCompType &comp)
Add a Boundary Condition with component using the standard interface of the BCHandler.
bcMode_Type
Definition: BCBase.hpp:102
bcInterface_Type::bcFunctionSolverDefinedPtr_Type bcFunctionSolverDefinedPtr_Type
void updateInverseJacobian(const UInt &iQuadPt)
BCInterface3D & operator=(const BCInterface3D &bcInterface3D)
BCFunctionRobin - class that holds the function used for prescribing Robin boundary conditions...
Definition: BCFunction.hpp:231
std::shared_ptr< bcFunctionDirectional_Type > bcFunctionDirectionalPtr_Type
void insertBC()
Insert the current boundary condition in the BChandler.
BCFunctionBase - class that holds the function used for prescribing boundary conditions.
Definition: BCFunction.hpp:77
vectorFunctionRobin_Type M_vectorFunctionRobin
bcInterface_Type::bcFunctionPtr_Type bcFunctionPtr_Type
void createFunctionDirectional(BCBaseType &base)
bcInterface_Type::bcHandler_Type bcHandler_Type
bcInterface_Type::physicalSolverPtr_Type physicalSolverPtr_Type
void createFunctionDataInterpolator()
BCDataInterpolator bcFunctionDataInterpolator_Type
BCInterfaceData3D - The BCInterface3D data container.
BCVectorInterface - class that holds the FE vectors used for prescribing boundary conditions on Inter...
Definition: BCVector.hpp:475
std::string bcName_Type
Definition: BCBase.hpp:116
bcInterface_Type::bcHandlerPtr_Type bcHandlerPtr_Type
void addBcToHandler(BCBaseType &base)
BCFunctionDirectional bcFunctionDirectional_Type
BCDataInterpolator - Class for interpolating boundary functions from scattered data.
void setPhysicalSolver(const physicalSolverPtr_Type &physicalSolver)
Set a physical solver.
std::shared_ptr< data_Type > dataPtr_Type
bcType_Type
Definition: BCBase.hpp:88
BCFunctionUDepBase - class that holds the function used for prescribing boundary conditions.
Definition: BCFunction.hpp:683
BCInterfaceData3D data_Type
vectorDataInterpolator_Type M_vectorDataInterpolator
BCVector - class that holds the FE vectors used for prescribing boundary conditions.
Definition: BCVector.hpp:381
bcInterface_Type::physicalSolver_Type physicalSolver_Type
vectorFunctionDirectional_Type M_vectorFunctionDirection
void addBC(const bcName_Type &name, const bcFlag_Type &flag, const bcType_Type &type, const bcMode_Type &mode, BCBaseType &base)
Add a Boundary Condition using the standard interface of the BCHandler.
bcInterface_Type::vectorFunction_Type vectorFunction_Type
std::vector< bcFunctionDirectionalPtr_Type > vectorFunctionDirectional_Type
BCInterface - LifeV interface to load boundary conditions completely from a GetPot file...
BCInterface3D()
Constructor.
std::shared_ptr< bcFunctionRobin_Type > bcFunctionRobinPtr_Type