LifeV
BCInterfaceFunctionParserSolver.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 BCInterfaceFunctionParserSolver class
30  *
31  * @date 24-08-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #ifndef BCInterfaceFunctionParserSolver_H
38 #define BCInterfaceFunctionParserSolver_H 1
39 
40 // BCInterface includes
41 #include <lifev/bc_interface/core/function/BCInterfaceFunctionParser.hpp>
42 
43 namespace LifeV
44 {
45 
46 //! BCInterfaceFunctionParserSolver - LifeV boundary condition function file wrapper for \c BCInterface
47 /*!
48  * @author Cristiano Malossi
49  *
50  * This class is an interface between the \c BCInterface, the \c Parser, and a general
51  * LifeV physical solver (such as \c OseenSolver or \c FSISolver). It allows to construct LifeV
52  * function types for boundary conditions, using a functions string loaded from
53  * a \c GetPot file in which are present some physical solver parameters.
54  *
55  * The class can be used in two ways:
56  *
57  * <ol>
58  * <li> first hereditate it and then implement the template specialization for the methods \c createAccessList() and \c updatePhysicalSolverVariables();
59  * <li> manually setting the variables by using the \c setVariable() method.
60  * </ol>
61  *
62  * See \c BCInterfaceFunctionParser class for more details.
63  *
64  * <b>AVAILABLE VARIABLES</b> <BR>
65  * Current available variables are:
66  *
67  * <ul>
68  * <li> f_timeStep
69  * <li> f_area
70  * <li> f_density
71  * <li> f_flux
72  * <li> f_pressure
73  * <li> f_viscosity
74  * <li> f_venousPressure
75  * <li> s_density
76  * <li> s_poisson
77  * <li> s_thickness
78  * <li> s_young
79  * <li> s_externalPressure
80  * </ul>
81  *
82  * Of course, some of those variables are available only for fluid problems, other only for solid problems.
83  */
84 template< typename BcHandlerType, typename PhysicalSolverType >
85 class BCInterfaceFunctionParserSolver: public virtual BCInterfaceFunctionParser< BcHandlerType, PhysicalSolverType >
86 {
87 public:
88 
89  //! @name Type definitions
90  //@{
91 
92  typedef BcHandlerType bcHandler_Type;
93  typedef PhysicalSolverType physicalSolver_Type;
94 
98  typedef typename PhysicalSolverType::solutionPtr_Type solutionPtr_Type;
99 
100  typedef typename function_Type::data_Type data_Type;
102 
103  //@}
104 
105 
106  //! @name Constructors & Destructor
107  //@{
108 
109  //! Constructor
111 
112  //! Destructor
114 
115  //@}
116 
117 
118  //! @name Methods
119  //@{
120 
121  //! Update the solver variables
122  /*!
123  * <b>NOTE:</b> A template specialization of this method should be provided for each solver.
124  */
126  {
127  std::cout << " !!! WARNING: updatePhysicalSolverVariables() is not defined for the selected solver. !!!" << std::endl;
128  }
129 
130  //@}
131 
132 
133  //! @name Set Methods
134  //@{
135 
136  //! Set data for boundary conditions
137  /*!
138  * @param data BC data loaded from GetPot file
139  */
140  virtual void setData ( const dataPtr_Type& data );
141 
142  //! Set the physical solver
143  /*!
144  * @param physicalSolver physical solver
145  */
146  void setPhysicalSolver ( const physicalSolverPtr_Type& physicalSolver )
147  {
148  M_physicalSolver = physicalSolver;
149  }
150 
151  //! Set solution
152  /*!
153  * @param solution The solution container of the 1D problem
154  */
155  void setSolution ( const solutionPtr_Type& solution )
156  {
157  M_solution = solution;
158  }
159 
160  //! Set variable function
161  /*!
162  * @param name name of the variable
163  * @param value value of the variable
164  */
165  void setVariable ( const std::string& name, const Real& value )
166  {
167  functionParser_Type::M_parser->setVariable ( name, value );
168  }
169 
170  //@}
171 
172 protected:
173 
174  //! @name Protected Methods
175  //@{
176 
177  //! Create the list of variables for the physical solver.
178  /*!
179  * NOTE: A template specialization of this method should be provided for each solver.
180  */
181  void createAccessList ( const dataPtr_Type& /*data*/ )
182  {
183  std::cout << " !!! WARNING: createAccessList() is not defined for the selected solver. !!!" << std::endl;
184  }
185 
186  //@}
187 
188  //List of all available operators (f: fluid; s: solid;)
190  {
203  };
204 
207 
210 
211 private:
212 
213  //! @name Unimplemented Methods
214  //@{
215 
217 
219 
220  //@}
221 
222 
223  //! @name Private Methods
224  //@{
225 
226  void createFluidMap ( std::map< std::string, physicalSolverList >& mapList );
227  void createSolidMap ( std::map< std::string, physicalSolverList >& mapList );
228  void createList ( const std::map< std::string, physicalSolverList >& mapList, const dataPtr_Type& data );
229 
230  void switchErrorMessage ( const std::string& operatorType )
231  {
232  std::cout << "ERROR: Invalid variable type for " << operatorType << " FunctionSolver" << std::endl;
233  }
234 
235  //@}
236 
237 };
238 
239 // ===================================================
240 // Factory
241 // ===================================================
242 //! Factory create function
243 template< typename BcHandlerType, typename PhysicalSolverType >
244 inline BCInterfaceFunctionParser< BcHandlerType, PhysicalSolverType >* createBCInterfaceFunctionParserSolver()
245 {
246  return new BCInterfaceFunctionParserSolver< BcHandlerType, PhysicalSolverType > ();
247 }
248 
249 // ===================================================
250 // Constructors
251 // ===================================================
252 template< typename BcHandlerType, typename PhysicalSolverType >
253 BCInterfaceFunctionParserSolver< BcHandlerType, PhysicalSolverType >::BCInterfaceFunctionParserSolver() :
254  function_Type (),
256  M_physicalSolver (),
257  M_solution (),
258  M_boundaryID (),
259  M_list ()
260 {
261 
262 #ifdef HAVE_LIFEV_DEBUG
263  debugStream ( 5023 ) << "BCInterfaceFunctionSolver::BCInterfaceFunctionSolver()" << "\n";
264 #endif
265 
266 }
267 
268 
269 
270 // ===================================================
271 // Set Methods
272 // ===================================================
273 template< typename BcHandlerType, typename PhysicalSolverType >
274 void
275 BCInterfaceFunctionParserSolver< BcHandlerType, PhysicalSolverType >::setData ( const dataPtr_Type& data )
276 {
277 
278 #ifdef HAVE_LIFEV_DEBUG
279  debugStream ( 5023 ) << "BCInterfaceFunctionSolver::setData( data )" << "\n";
280 #endif
281 
282  M_boundaryID = data->boundaryID();
283 
284  functionParser_Type::setData ( data );
285 
286  createAccessList ( data );
287 }
288 
289 
290 
291 // ===================================================
292 // Private Methods
293 // ===================================================
294 template< typename BcHandlerType, typename PhysicalSolverType >
295 inline void
296 BCInterfaceFunctionParserSolver< BcHandlerType, PhysicalSolverType >::createFluidMap ( std::map< std::string, physicalSolverList >& mapList )
297 {
298  mapList["f_timeStep"] = f_timeStep;
299  mapList["f_area"] = f_area;
300  mapList["f_density"] = f_density;
301  mapList["f_flux"] = f_flux;
302  mapList["f_pressure"] = f_pressure;
303  mapList["f_viscosity"] = f_viscosity;
304  mapList["f_venousPressure"] = f_venousPressure;
305 }
306 
307 template< typename BcHandlerType, typename PhysicalSolverType >
308 inline void
309 BCInterfaceFunctionParserSolver< BcHandlerType, PhysicalSolverType >::createSolidMap ( std::map< std::string, physicalSolverList >& mapList )
310 {
311  mapList["s_density"] = s_density;
312  mapList["s_poisson"] = s_poisson;
313  mapList["s_thickness"] = s_thickness;
314  mapList["s_young"] = s_young;
315  mapList["s_externalPressure"] = s_externalPressure;
316 }
317 
318 template< typename BcHandlerType, typename PhysicalSolverType >
319 inline void
320 BCInterfaceFunctionParserSolver< BcHandlerType, PhysicalSolverType >::createList ( const std::map< std::string, physicalSolverList >& mapList, const dataPtr_Type& data )
321 {
322  M_list.clear();
323  for ( typename std::map< std::string, physicalSolverList >::const_iterator j = mapList.begin(); j != mapList.end(); ++j )
324  if ( boost::find_first ( data->baseString(), j->first ) )
325  {
326  M_list.insert ( j->second );
327  }
328 }
329 
330 } // Namespace LifeV
331 
332 #endif /* BCInterfaceFunctionParserSolver_H */
BCInterfaceFunction< bcHandler_Type, physicalSolver_Type > function_Type
std::shared_ptr< physicalSolver_Type > physicalSolverPtr_Type
BCInterfaceFunctionParserSolver - LifeV boundary condition function file wrapper for BCInterface...
void setVariable(const std::string &name, const Real &value)
Set variable function.
void setSolution(const solutionPtr_Type &solution)
Set solution.
BCInterfaceFunctionParserSolver & operator=(const BCInterfaceFunctionParserSolver &function)
void updateInverseJacobian(const UInt &iQuadPt)
void setPhysicalSolver(const physicalSolverPtr_Type &physicalSolver)
Set the physical solver.
void createSolidMap(std::map< std::string, physicalSolverList > &mapList)
PhysicalSolverType::solutionPtr_Type solutionPtr_Type
uint32_type ID
IDs.
Definition: LifeV.hpp:194
void createAccessList(const dataPtr_Type &)
Create the list of variables for the physical solver.
void updatePhysicalSolverVariables()
Update the solver variables.
BCInterfaceFunctionParser - LifeV boundary condition function wrapper for BCInterface.
void switchErrorMessage(const std::string &operatorType)
BCInterfaceFunctionParserSolver(const BCInterfaceFunctionParserSolver &function)
BCInterfaceFunctionParser< bcHandler_Type, physicalSolver_Type > functionParser_Type
double Real
Generic real data.
Definition: LifeV.hpp:175
void createFluidMap(std::map< std::string, physicalSolverList > &mapList)
void createList(const std::map< std::string, physicalSolverList > &mapList, const dataPtr_Type &data)
virtual void setData(const dataPtr_Type &data)
Set data for boundary conditions.
BCInterfaceFunction - Base class for BCInterface boundary functions.
BCInterfaceFunctionParser< BcHandlerType, PhysicalSolverType > * createBCInterfaceFunctionParserSolver()
Factory create function.