LifeV
BCInterface0D.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 BCInterface0D class
30  *
31  * @date 30-03-2011
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #ifndef BCInterface0D_H
38 #define BCInterface0D_H 1
39 
40 // BCInterface includes
41 #include <lifev/bc_interface/core/bc/BCInterface.hpp>
42 #include <lifev/bc_interface/0D/bc/BCInterfaceData0D.hpp>
43 
44 // Template specializations
45 #include <lifev/bc_interface/0D/function/BCInterfaceFunctionParser0D.hpp>
46 #include <lifev/bc_interface/0D/function/BCInterfaceFunctionParserSolver0D.hpp>
47 #include <lifev/bc_interface/0D/function/BCInterfaceFunctionUserDefined0D.hpp>
48 
49 namespace LifeV
50 {
51 
52 //! BCInterface0D - LifeV interface to load boundary conditions for 0D problems completely from a \c GetPot file
53 /*!
54  * @author Cristiano Malossi
55  *
56  * This class allows to impose boundary conditions for a 0D problem completely from a file.
57  *
58  * <b>EXAMPLE - DATA FILE</b> <BR>
59  * In the GetPot data file, \c BCInterface reads a new section: <CODE> [boundary_conditions] </CODE>.
60  *
61  * Inside the new section there is a list of boundary conditions which correspond to other sub-section
62  * with the same name, for example: <CODE> list = 'InFlow OutFlow' </CODE>
63  *
64  * Each boundary condition has a similar structure. The list of properties depends from the type of the
65  * boundary condition. For example:
66  *
67  * <CODE>
68  * [InFlow] <BR>
69  * flag = 0 <BR>
70  * type0D = Current <BR>
71  * function = 'sin(2*pi*t)' <BR>
72  *
73  * [OutFlow] <BR>
74  * flag = 1 <BR>
75  * type0D = Voltage <BR>
76  * function = 0 <BR>
77  * </CODE>
78  *
79  * where \c flag, and \c type0D are the classical parameters for a 0D boundary condition.
80  * The string \c function represents the base module and can be replaced by other derived/alternative modules.
81  * The following functions are available (see the related classes for more information):
82  *
83  * <ol>
84  * <li> \c function, which is implemented in \c BCInterfaceFunctionParser;
85  * <li> \c functionFile, which is implemented in \c BCInterfaceFunctionParserFile;
86  * <li> \c functionSolver, which is implemented in \c BCInterfaceFunctionParserSolver;
87  * <li> \c functionFileSolver, which is implemented in \c BCInterfaceFunctionParserFileSolver;
88  * <li> \c functionUD, which is implemented in \c BCInterfaceFunctionUserDefined.
89  * </ol>
90  *
91  * All the parameters are case sensitive.
92  *
93  * See \c BCInterface base class for more details.
94  */
95 template< class BcHandler, class PhysicalSolverType >
96 class BCInterface0D : public virtual BCInterface< BcHandler, PhysicalSolverType >
97 {
98 public:
99 
100  //! @name Type definitions
101  //@{
102 
103  typedef BCInterface< BcHandler, PhysicalSolverType > bcInterface_Type;
104 
107 
110 
112 
115 
118 
121 
122  //@}
123 
124 
125  //! @name Constructors & Destructor
126  //@{
127 
128  //! Constructor
129  explicit BCInterface0D() : bcInterface_Type(), M_data ( new data_Type() ) {}
130 
131  //! Destructor
132  virtual ~BCInterface0D() {}
133 
134  //@}
135 
136 
137  //! @name Methods
138  //@{
139 
140  //! Read a specific boundary condition from a file and add it to the data container
141  /*!
142  * @param fileName Name of the data file
143  * @param dataSection section in the data file
144  * @param name name of the boundary condition
145  */
146  void readBC ( const std::string& fileName, const std::string& dataSection, const std::string& name )
147  {
148  M_data->readBC ( fileName, dataSection, name );
149  }
150 
151  //! Insert the current boundary condition in the BChandler
152  void insertBC();
153 
154  //@}
155 
156 
157  //! @name Get Methods
158  //@{
159 
160  //! Get the data container
161  /*!
162  * @return the data container
163  */
165  {
166  return *M_data;
167  }
168 
169  //@}
170 
171 private:
172 
173  //! @name Unimplemented Methods
174  //@{
175 
176  BCInterface0D ( const BCInterface0D& interface0D );
177 
178  BCInterface0D& operator= ( const BCInterface0D& interface0D );
179 
180  //@}
181 
182 
183  //! @name Private Methods
184  //@{
185 
186  template< class BCBaseType >
187  void addBcToHandler ( BCBaseType& base );
188 
189  //@}
190 
191  // Data
193 };
194 
195 // ===================================================
196 // Methods
197 // ===================================================
198 template< class BcHandler, class PhysicalSolverType >
199 inline void
200 BCInterface0D< BcHandler, PhysicalSolverType >::insertBC()
201 {
202 
203 #ifdef HAVE_LIFEV_DEBUG
204  debugStream ( 5020 ) << "BCInterface0D::insertBC\n";
205 #endif
206 
208 
209  switch ( M_data->base().second )
210  {
211  case BCIFunctionParser:
212  case BCIFunctionParserFile:
213  case BCIFunctionParserSolver:
214  case BCIFunctionParserFileSolver:
215  case BCIFunctionUserDefined:
216  {
217  factory_Type factory;
218  this->M_vectorFunction.push_back ( factory.createFunctionParser ( M_data ) );
219  this->M_vectorFunction.back()->assignFunction ( base );
220 
221  addBcToHandler ( base );
222 
223  return;
224  }
225 
226  default:
227 
228  std::cout << " !!! Error: " << M_data->base().first << " is not valid in BCInterface0D !!!" << std::endl;
229  break;
230  }
231 }
232 
233 
234 
235 // ===================================================
236 // Private Methods
237 // ===================================================
238 template< class BcHandler, class PhysicalSolverType > template< class BCBaseType >
239 inline void
240 BCInterface0D< BcHandler, PhysicalSolverType >::addBcToHandler ( BCBaseType& base )
241 {
242  if ( !this->M_handler.get() ) // If BCHandler has not been created yet, we do it now
243  {
244  this->createHandler();
245  }
246 
247  this->M_handler->setBC ( M_data->flag(), M_data->type(), base );
248 }
249 
250 } // Namespace LifeV
251 
252 #endif /* BCInterface0D_H */
bcInterface_Type::bcHandler_Type bcHandler_Type
BCInterface0D()
Constructor.
BCInterfaceData0D - The BCInterface1D data container.
bcInterface_Type::bcHandlerPtr_Type bcHandlerPtr_Type
void addBcToHandler(BCBaseType &base)
virtual ~BCInterface0D()
Destructor.
bcInterface_Type::physicalSolver_Type physicalSolver_Type
std::shared_ptr< data_Type > dataPtr_Type
void updateInverseJacobian(const UInt &iQuadPt)
bcInterface_Type::vectorFunction_Type vectorFunction_Type
bcInterface_Type::vectorFunctionSolverDefined_Type vectorFunctionSolverDefined_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.
BCInterface0D(const BCInterface0D &interface0D)
BCInterface< BcHandler, PhysicalSolverType > bcInterface_Type
data_Type & dataContainer()
Get the data container.
bcInterface_Type::factory_Type factory_Type
BCInterfaceData0D data_Type
BCInterface0D & operator=(const BCInterface0D &interface0D)
BCInterface0D - LifeV interface to load boundary conditions for 0D problems completely from a GetPot ...
bcInterface_Type::bcFunctionSolverDefinedPtr_Type bcFunctionSolverDefinedPtr_Type
void insertBC()
Insert the current boundary condition in the BChandler.
ZeroDimensionalFunction - A boundary conditions function for zero-dimensional models.
BCInterface - LifeV interface to load boundary conditions completely from a GetPot file...
bcInterface_Type::physicalSolverPtr_Type physicalSolverPtr_Type
bcInterface_Type::bcFunctionPtr_Type bcFunctionPtr_Type