LifeV
MultiscaleModelFluid3D.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 Multiscale Model Fluid3D
30  *
31  * @date 12-03-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 
38 #ifndef MultiscaleModelFluid3D_H
39 #define MultiscaleModelFluid3D_H 1
40 
41 #include <lifev/core/mesh/MeshPartitioner.hpp>
42 #include <lifev/core/mesh/RegionMesh.hpp>
43 #include <lifev/navier_stokes/solver/OseenData.hpp>
44 #include <lifev/core/mesh/MeshData.hpp>
45 
46 #include <lifev/bc_interface/3D/function/fluid/BCInterfaceFunctionParserFluid3D.hpp>
47 #include <lifev/bc_interface/3D/function/fluid/BCInterfaceFunctionParserSolverFluid3D.hpp>
48 #include <lifev/bc_interface/3D/function/fluid/BCInterfaceFunctionUserDefinedFluid3D.hpp>
49 
50 
51 #include <lifev/bc_interface/3D/bc/BCInterface3D.hpp>
52 #include <lifev/core/algorithm/NonLinearAitken.hpp>
53 #include <lifev/core/fem/FESpace.hpp>
54 #include <lifev/core/filter/ExporterEnsight.hpp>
55 #ifdef HAVE_HDF5
56 #include <lifev/core/filter/ExporterHDF5.hpp>
57 #endif
58 #include <lifev/navier_stokes/fem/TimeAdvanceBDFNavierStokes.hpp>
59 #include <lifev/navier_stokes/solver/OseenSolverShapeDerivative.hpp>
60 
61 #include <lifev/multiscale/models/MultiscaleModel.hpp>
62 #include <lifev/multiscale/framework/MultiscaleInterface.hpp>
63 
64 namespace LifeV
65 {
66 namespace Multiscale
67 {
68 
69 //! MultiscaleModelFluid3D - Multiscale model for 3D Fluid simulations
70 /*!
71  * @author Cristiano Malossi
72  *
73  * @see Full description of the Geometrical Multiscale Framework: \cite Malossi-Thesis
74  * @see Methodology: \cite Malossi2011Algorithms \cite Malossi2011Algorithms1D \cite Malossi2011Algorithms3D1DFSI \cite BlancoMalossi2012
75  * @see Applications: \cite Malossi2011Algorithms3D1DFSIAortaIliac \cite LassilaMalossi2012IdealLeftVentricle \cite BonnemainMalossi2012LVAD
76  *
77  * The MultiscaleModelFluid3D class is an implementation of the multiscaleModel_Type
78  * for 3D Fluid problem (in particular Oseen with Shape Derivatives).
79  */
80 class MultiscaleModelFluid3D: public virtual multiscaleModel_Type,
81  public virtual MultiscaleInterface
82 {
83 public:
84 
85  //! @name Public Types
86  //@{
87 
89  typedef MeshPartitioner< mesh_Type > MeshPartitioner_Type;
90 
91 
95 
96  typedef Exporter< mesh_Type > IOFile_Type;
98  typedef ExporterData< mesh_Type > IOData_Type;
99 
101 #ifdef HAVE_HDF5
103 #endif
104 
105  typedef BCHandler bc_Type;
107  typedef BCInterface3D< bc_Type, fluid_Type > bcInterface_Type;
109 
111  typedef OseenData data_Type;
112 
115 
116  //@}
117 
118 
119  //! @name Constructors & Destructor
120  //@{
121 
122  //! Constructor
123  explicit MultiscaleModelFluid3D();
124 
125  //! Destructor
127 
128  //@}
129 
130 
131  //! @name MultiscaleModel Methods
132  //@{
133 
134  //! Setup the data of the model.
135  /*!
136  * @param fileName Name of data file.
137  */
138  void setupData ( const std::string& fileName );
139 
140  //! Setup the model.
141  void setupModel();
142 
143  //! Build the initial model.
144  void buildModel();
145 
146  //! Update the model.
147  void updateModel();
148 
149  //! Solve the model.
150  void solveModel();
151 
152  //! Update the solution.
153  void updateSolution();
154 
155  //! Save the solution
156  void saveSolution();
157 
158  //! Display some information about the model.
159  void showMe();
160 
161  //! Return a specific scalar quantity to be used for a comparison with a reference value.
162  /*!
163  * This method is meant to be used for night checks.
164  * @return reference quantity.
165  */
166  Real checkSolution() const;
167 
168  //@}
169 
170 
171  //! @name MultiscaleInterface Methods
172  //@{
173 
174  //! Impose the flow rate on a specific interface of the model
175  /*!
176  * @param boundaryID ID of the boundary interface
177  * @param function boundary condition function
178  */
179  void imposeBoundaryFlowRate ( const multiscaleID_Type& boundaryID, const function_Type& function );
180 
181  //! Impose the integral of the mean normal stress on a specific boundary interface of the model
182  /*!
183  * @param boundaryID ID of the boundary interface
184  * @param function boundary condition function
185  */
186  void imposeBoundaryMeanNormalStress ( const multiscaleID_Type& boundaryID, const function_Type& function );
187 
188  //! Impose the integral of the mean total normal stress on a specific boundary interface of the model
189  /*!
190  * Note: mean total normal stress cannot be imposed at the interfaces of this model.
191  *
192  * @param boundaryID ID of the boundary interface
193  * @param function boundary condition function
194  */
195  void imposeBoundaryMeanTotalNormalStress ( const multiscaleID_Type& /*boundaryID*/, const function_Type& /*function*/ )
196  {
197  multiscaleErrorCheck ( ModelInterface, "Invalid interface [MeanTotalNormalStress] for model type [" + enum2String ( M_type, multiscaleModelsMap ) + "]", M_comm->MyPID() == 0 );
198  }
199 
200  //! Impose the area on a specific boundary interface of the model
201  /*!
202  * Note: area cannot be imposed at the interfaces of this model.
203  *
204  * @param boundaryID ID of the boundary interface
205  * @param function boundary condition function
206  */
207  void imposeBoundaryArea ( const multiscaleID_Type& /*boundaryID*/, const function_Type& /*function*/ )
208  {
209  multiscaleErrorCheck ( ModelInterface, "Invalid interface [Area] for model type [" + enum2String ( M_type, multiscaleModelsMap ) + "]", M_comm->MyPID() == 0 );
210  }
211 
212  //! Get the flow rate on a specific boundary interface of the model
213  /*!
214  * @param boundaryID ID of the boundary interface
215  * @return flow rate value
216  */
217  Real boundaryFlowRate ( const multiscaleID_Type& boundaryID ) const
218  {
219  return M_fluid->flux ( boundaryFlag ( boundaryID ) );
220  }
221 
222  //! Get the integral of the mean normal stress on a specific boundary interface of the model
223  /*!
224  * @param boundaryID ID of the boundary interface
225  * @return mean normal stress value
226  */
227  Real boundaryMeanNormalStress ( const multiscaleID_Type& boundaryID ) const
228  {
229  return M_fluid->meanNormalStress ( boundaryFlag ( boundaryID ), *M_bc->handler() );
230  }
231 
232  //! Get the integral of the mean total normal stress on a specific boundary interface of the model
233  /*!
234  * @param boundaryID ID of the boundary interface
235  * @return mean total normal stress value
236  */
237  Real boundaryMeanTotalNormalStress ( const multiscaleID_Type& boundaryID ) const
238  {
239  return M_fluid->meanTotalNormalStress ( boundaryFlag ( boundaryID ), *M_bc->handler() );
240  }
241 
242  //! Get the area on a specific boundary interface of the model
243  /*!
244  * @param boundaryID ID of the boundary interface
245  * @return area value
246  */
247  Real boundaryArea ( const multiscaleID_Type& boundaryID ) const
248  {
249  return M_fluid->area ( boundaryFlag ( boundaryID ) );
250  }
251 
252  //! Get the variation of the flow rate (on a specific boundary interface) using the linear model
253  /*!
254  * @param boundaryID ID of the boundary interface
255  * @param solveLinearSystem a flag to which determine if the linear system has to be solved
256  * @return variation of the flow rate
257  */
258  Real boundaryDeltaFlowRate ( const multiscaleID_Type& boundaryID, bool& solveLinearSystem );
259 
260  //! Get the variation of the integral of the mean normal stress (on a specific boundary interface) using the linear model
261  /*!
262  * @param boundaryID ID of the boundary interface
263  * @param solveLinearSystem a flag to which determine if the linear system has to be solved
264  * @return variation of the mean normal stress
265  */
266  Real boundaryDeltaMeanNormalStress ( const multiscaleID_Type& boundaryID, bool& solveLinearSystem );
267 
268  //! Get the variation of the integral of the mean total normal stress (on a specific boundary interface) using the linear model
269  /*!
270  * @param boundaryID ID of the boundary interface
271  * @param solveLinearSystem a flag to which determine if the linear system has to be solved
272  * @return variation of the mean total normal stress
273  */
274  Real boundaryDeltaMeanTotalNormalStress ( const multiscaleID_Type& boundaryID, bool& solveLinearSystem );
275 
276  //! Get the variation of the integral of the area (on a specific boundary interface) using the linear model
277  /*!
278  * Note: returns always a NaN, since this method is not used by the current interface equations.
279  *
280  * @param boundaryID ID of the boundary interface
281  * @param solveLinearSystem a flag to which determine if the linear system has to be solved
282  * @return variation of the area
283  */
284  Real boundaryDeltaArea ( const multiscaleID_Type& /*boundaryID*/, bool& /*solveLinearSystem*/ )
285  {
286  return NaN;
287  }
288 
289  //@}
290 
291 
292  //! @name Set Methods
293  //@{
294 
295  //! Set the solution vector
296  /*!
297  * @param solution solution vector
298  */
299  void setSolution ( const fluidVectorPtr_Type& solution );
300 
301  //@}
302 
303 
304  //! @name Get Methods
305  //@{
306 
307  //! Get the BCInterface container of the boundary conditions of the model
308  /*!
309  * @return BCInterface container
310  */
312  {
313  return *M_bc;
314  }
315 
316  //! Get the density on a specific boundary face of the model
317  /*!
318  * @return density value
319  */
321  {
322  return M_data->density();
323  }
324 
325  //! Get the viscosity on a specific boundary face of the model
326  /*!
327  * @return viscosity value
328  */
330  {
331  return M_data->viscosity();
332  }
333 
334  //! Get the integral of the pressure (on a specific boundary face)
335  /*!
336  * @param boundaryID ID of the boundary interface
337  * @return pressure value
338  */
339  Real boundaryPressure ( const multiscaleID_Type& boundaryID ) const
340  {
341  return M_fluid->pressure ( boundaryFlag ( boundaryID ) );
342  }
343 
344  //! Get the integral of the total pressure (on a specific boundary face)
345  /*!
346  * @param boundaryID ID of the boundary interface
347  * @return total pressure value
348  */
349  Real boundaryTotalPressure ( const multiscaleID_Type& boundaryID ) const
350  {
351  return M_fluid->pressure ( boundaryFlag ( boundaryID ) ) + M_fluid->kineticNormalStress ( boundaryFlag ( boundaryID ) );
352  }
353 
354  //! Get the data container
355  /*!
356  * @return Data container
357  */
358  const data_Type& data() const
359  {
360  return *M_data;
361  }
362 
363  //! Get the solution vector
364  /*!
365  * @return Solution vector
366  */
367  const fluidVector_Type& solution() const
368  {
369  return *M_solution;
370  }
371 
372  //@}
373 
374 private:
375 
376  //! @name Unimplemented Methods
377  //@{
378 
380 
382 
383  //@}
384 
385 
386  //! @name Private Methods
387  //@{
388 
389  //! Setup the global data of the model.
390  /*!
391  * In particular, it replaces the default local values with the ones in the global container.
392  * If a value is already specified in the data file, do not perform the replacement.
393  *
394  * @param fileName File name of the specific model.
395  */
396  void setupGlobalData ( const std::string& fileName );
397 
398  //! Initialize the solution.
399  void initializeSolution();
400 
401  //! Setup the exporter and the importer
402  /*!
403  * @param fileName File name of the specific model.
404  */
405  void setupExporterImporter ( const std::string& fileName );
406 
407  //! Setup the mesh for the fluid problem
408  void setupMesh();
409 
410  //! Setup the FE space for pressure and velocity
411  void setupFEspace();
412 
413  //! Setup the DOF of the model
414  void setupDOF();
415 
416  //! Setup the offset for fluxes boundary conditions
417  void setupBCOffset ( const bcPtr_Type& BC );
418 
419  //! Setup the linear model
420  void setupLinearModel();
421 
422  //! Update the linear system matrix and vectors
423  void updateLinearModel();
424 
425  //! Solve the linear problem
426  void solveLinearModel ( bool& solveLinearSystem );
427 
428  //! Impose the coupling perturbation on the correct BC inside the BCHandler
429  void imposePerturbation();
430 
431  //! Reset all the coupling perturbations imposed on the BCHandler
432  void resetPerturbation();
433 
434  Real bcFunctionDeltaZero ( const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const UInt& /*id*/ )
435  {
436  return 0.;
437  }
438  Real bcFunctionDeltaOne ( const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const UInt& /*id*/ )
439  {
440  return 1.;
441  }
442 
443  //@}
444 
447 
448  std::string M_fileName; //TODO Temporary - To be removed
449 
450  // Fluid problem
459 
460  // Linear Fluid problem
463 
464  // FE spaces
467 
468  // Lagrange multipliers
470 
471  // Problem coefficients
475 
476  // NS parameters
480 };
481 
482 //! Factory create function
483 inline multiscaleModel_Type* createMultiscaleModelFluid3D()
484 {
485  return new MultiscaleModelFluid3D();
486 }
487 
488 } // Namespace multiscale
489 } // Namespace LifeV
490 
491 #endif /* MultiscaleModelFluid3D_H */
Real boundaryDeltaMeanTotalNormalStress(const multiscaleID_Type &boundaryID, bool &solveLinearSystem)
Get the variation of the integral of the mean total normal stress (on a specific boundary interface) ...
Real boundaryPressure(const multiscaleID_Type &boundaryID) const
Get the integral of the pressure (on a specific boundary face)
MultiscaleModelFluid3D & operator=(const MultiscaleModelFluid3D &model)
OseenSolverShapeDerivative< mesh_Type > fluid_Type
void setupDOF()
Setup the DOF of the model.
void solveLinearModel(bool &solveLinearSystem)
Solve the linear problem.
ExporterEnsight data exporter.
std::shared_ptr< bcInterface_Type > bcInterfacePtr_Type
const fluidVector_Type & solution() const
Get the solution vector.
FESpace - Short description here please!
Definition: FESpace.hpp:78
Real boundaryViscosity() const
Get the viscosity on a specific boundary face of the model.
bcInterface_Type & bcInterface()
Get the BCInterface container of the boundary conditions of the model.
Real bcFunctionDeltaOne(const Real &, const Real &, const Real &, const Real &, const UInt &)
multiscaleModel_Type * createMultiscaleModelFluid3D()
Factory create function.
Real boundaryDeltaMeanNormalStress(const multiscaleID_Type &boundaryID, bool &solveLinearSystem)
Get the variation of the integral of the mean normal stress (on a specific boundary interface) using ...
void setupBCOffset(const bcPtr_Type &BC)
Setup the offset for fluxes boundary conditions.
Real boundaryMeanTotalNormalStress(const multiscaleID_Type &boundaryID) const
Get the integral of the mean total normal stress on a specific boundary interface of the model...
Real checkSolution() const
Return a specific scalar quantity to be used for a comparison with a reference value.
void initializeSolution()
Initialize the solution.
Real boundaryDeltaFlowRate(const multiscaleID_Type &boundaryID, bool &solveLinearSystem)
Get the variation of the flow rate (on a specific boundary interface) using the linear model...
Real bcFunctionDeltaZero(const Real &, const Real &, const Real &, const Real &, const UInt &)
void setupGlobalData(const std::string &fileName)
Setup the global data of the model.
void setupFEspace()
Setup the FE space for pressure and velocity.
void setSolution(const fluidVectorPtr_Type &solution)
Set the solution vector.
NonLinearAitken< fluidVector_Type > M_generalizedAitken
Real boundaryTotalPressure(const multiscaleID_Type &boundaryID) const
Get the integral of the total pressure (on a specific boundary face)
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
TimeAdvanceBDFNavierStokes< fluidVector_Type > bdf_Type
Real boundaryMeanNormalStress(const multiscaleID_Type &boundaryID) const
Get the integral of the mean normal stress on a specific boundary interface of the model...
NonLinearAitken - LifeV class for the non-linear generalized Aitken algorithm.
void imposePerturbation()
Impose the coupling perturbation on the correct BC inside the BCHandler.
void imposeBoundaryMeanNormalStress(const multiscaleID_Type &boundaryID, const function_Type &function)
Impose the integral of the mean normal stress on a specific boundary interface of the model...
Real boundaryDeltaArea(const multiscaleID_Type &, bool &)
Get the variation of the integral of the area (on a specific boundary interface) using the linear mod...
std::shared_ptr< FESpace_Type > FESpacePtr_Type
void setupMesh()
Setup the mesh for the fluid problem.
double Real
Generic real data.
Definition: LifeV.hpp:175
Real boundaryArea(const multiscaleID_Type &boundaryID) const
Get the area on a specific boundary interface of the model.
const data_Type & data() const
Get the data container.
void imposeBoundaryMeanTotalNormalStress(const multiscaleID_Type &, const function_Type &)
Impose the integral of the mean total normal stress on a specific boundary interface of the model...
Real boundaryDensity() const
Get the density on a specific boundary face of the model.
MultiscaleModelFluid3D(const MultiscaleModelFluid3D &model)
Real boundaryFlowRate(const multiscaleID_Type &boundaryID) const
Get the flow rate on a specific boundary interface of the model.
void resetPerturbation()
Reset all the coupling perturbations imposed on the BCHandler.
void imposeBoundaryArea(const multiscaleID_Type &, const function_Type &)
Impose the area on a specific boundary interface of the model.
void setupExporterImporter(const std::string &fileName)
Setup the exporter and the importer.
std::shared_ptr< MeshPartitioner_Type > M_mesh
void updateLinearModel()
Update the linear system matrix and vectors.
BCInterface3D< bc_Type, fluid_Type > bcInterface_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
void showMe()
Display some information about the model.
void imposeBoundaryFlowRate(const multiscaleID_Type &boundaryID, const function_Type &function)
Impose the flow rate on a specific interface of the model.
std::shared_ptr< fluidVector_Type > fluidVectorPtr_Type
void setupData(const std::string &fileName)
Setup the data of the model.