LifeV
MultiscaleDefinitions.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 Definitions
30  *
31  * @date 03-11-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #ifndef MS_Definitions_H
38 #define MS_Definitions_H 1
39 
40 
41 // STL classes
42 #include <string>
43 #include <fstream>
44 #include <sstream>
45 
46 // Boost classes
47 #include <boost/array.hpp>
48 #include <boost/shared_ptr.hpp>
49 #include <boost/algorithm/string.hpp>
50 
51 
52 // LifeV classes
53 #include <lifev/core/LifeV.hpp>
54 #include <lifev/core/util/StringUtility.hpp>
55 #include <lifev/core/util/Displayer.hpp>
56 #include <lifev/core/util/Factory.hpp>
57 #include <lifev/core/util/FactorySingleton.hpp>
58 #include <lifev/core/mesh/MarkerDefinitions.hpp>
59 
60 #include <lifev/core/algorithm/LinearSolver.hpp>
61 
62 #include <lifev/core/array/MapEpetra.hpp>
63 #include <lifev/core/array/VectorEpetra.hpp>
64 #include <lifev/core/array/MatrixEpetra.hpp>
65 
66 #include <lifev/multiscale/framework/MultiscaleGlobalData.hpp>
67 
68 namespace LifeV
69 {
70 namespace Multiscale
71 {
72 
73 // Enum objects
74 /*! @enum algorithmsTypes
75  */
77 {
78  Aitken, /*!< Aitken method */
79  Broyden, /*!< Broyden method (start from exact Jacobian Matrix) */
80  Explicit, /*!< Explicit method */
81  Newton /*!< Newton method (with exact Jacobian Matrix) */
82 };
83 
84 /*! @enum modelsTypes
85  */
87 {
88  Fluid3D, /*!< Fluid (Oseen) 3D model */
89  FSI1D, /*!< 1D model */
90  FSI3D, /*!< FSI 3D model */
91  Multiscale, /*!< Multiscale model */
92  Windkessel0D, /*!< Windkessel0D model */
93  ZeroDimensional /*!< 0D model */
94 };
95 
96 /*! @enum couplingsTypes
97  */
99 {
100  BoundaryCondition, /*!< Boundary condition */
101  MeanNormalStress, /*!< Mean normal stress coupling condition */
102  MeanNormalStressArea, /*!< Mean normal stress with area coupling condition */
103  MeanNormalStressValve, /*!< Mean normal stress coupling condition with simple valve*/
104  MeanTotalNormalStress, /*!< Mean total normal stress coupling condition */
105  MeanTotalNormalStressArea /*!< Mean total normal stress with area coupling condition */
106 };
107 
109 {
110  IterationsMaximumNumber, /*!< Maximum number of iterations reached */
111  Tolerance, /*!< Tolerance not satisfied */
112  Residual, /*!< External residual not satisfied */
113  Solution, /*!< Solution check not satisfied */
114  ModelType, /*!< Model type not recognized */
115  CouplingType, /*!< Coupling type not recognized */
116  ModelInterface /*!< Model interface not available */
117 };
118 
119 // Folder of the problem
121 
122 // Folder of the problem
123 extern std::string multiscaleProblemFolder;
124 
125 // Prefix of the problem
126 extern std::string multiscaleProblemPrefix;
127 
128 // Step of the problem ( > 0 when performing a restart )
130 
131 // Save each N time steps
133 
134 // Exit Flag
135 extern bool multiscaleExitFlag;
136 
137 // Map objects
141 
142 // Forward class declarations
143 class MultiscaleAlgorithm;
144 class MultiscaleModel;
146 
147 // Type definitions
151 
153 
156 
159 
162 
166 
170 
174 
178 
182 
185 
186 // ===================================================
187 // Multiscale Utility Methods
188 // ===================================================
189 
190 //! Define the map of the MS objects
191 inline void
193 {
194 #if defined(LIFEV_HAS_NAVIERSTOKES)
195  multiscaleModelsMap["Fluid3D"] = Fluid3D;
196 #endif
197 #if defined(LIFEV_HAS_ONEDFSI)
198  multiscaleModelsMap["FSI1D"] = FSI1D;
199 #endif
200 #if defined(LIFEV_HAS_FSI)
201  multiscaleModelsMap["FSI3D"] = FSI3D;
202 #endif
203  multiscaleModelsMap["Multiscale"] = Multiscale;
204 #if defined(LIFEV_HAS_ZERODIMENSIONAL)
205  multiscaleModelsMap["Windkessel0D"] = Windkessel0D;
206  multiscaleModelsMap["ZeroDimensional"] = ZeroDimensional;
207 #endif
208 
209  multiscaleCouplingsMap["BoundaryCondition"] = BoundaryCondition;
210  multiscaleCouplingsMap["MeanNormalStress"] = MeanNormalStress;
211  multiscaleCouplingsMap["MeanNormalStressValve"] = MeanNormalStressValve;
212  multiscaleCouplingsMap["MeanTotalNormalStress"] = MeanTotalNormalStress;
213 #if defined(LIFEV_HAS_ONEDFSI) && defined(LIFEV_HAS_FSI)
214  multiscaleCouplingsMap["MeanNormalStressArea"] = MeanNormalStressArea;
215  multiscaleCouplingsMap["MeanTotalNormalStressArea"] = MeanTotalNormalStressArea;
216 #endif
217 
218  multiscaleAlgorithmsMap["Aitken"] = Aitken;
219  multiscaleAlgorithmsMap["Broyden"] = Broyden;
220  multiscaleAlgorithmsMap["Explicit"] = Explicit;
221  multiscaleAlgorithmsMap["Newton"] = Newton;
222 }
223 
224 //! Perform a dynamic cast from a base class to a derived class
225 /*!
226  * @param base - pointer to the base object
227  * @return pointer to the derived object
228  */
229 template < typename DerivedType, typename BasePtrType >
230 inline std::shared_ptr< DerivedType >
232 {
233  return std::dynamic_pointer_cast< DerivedType > ( base );
234 }
235 
236 //! Display and error message
237 /*!
238  * @param errorMessage - The message that should be displayed
239  */
240 inline void
241 multiscaleErrorMessage ( const std::stringstream& errorMessage )
242 {
243  std::cerr << std::setprecision ( 10 ) << std::scientific << "MS ERROR: " << errorMessage.str() << std::endl;
244 }
245 
246 //! Create an error message
247 /*!
248  * @param error - The error type
249  * @param message - Additional information about the error
250  */
251 inline void
252 multiscaleErrorCheck ( const errors_Type& error, const std::string& message = "", const UInt& isLeader = true )
253 {
254  if ( isLeader )
255  {
256  std::stringstream errorMessage;
257 
258  switch ( error )
259  {
260  case IterationsMaximumNumber:
261 
262  errorMessage << "Maximum number of iterations reached!\n";
263 
264  break;
265 
266  case Tolerance:
267 
268  errorMessage << "Tolerance not satisfied!\n";
269 
270  break;
271 
272  case Residual:
273 
274  errorMessage << "External residual not satisfied!\n";
275 
276  break;
277 
278  case Solution:
279 
280  errorMessage << "Solution check not satisfied!\n";
281 
282  break;
283 
284  case ModelType:
285 
286  errorMessage << "Model type incorrect!\n";
287 
288  break;
289 
290  case CouplingType:
291 
292  errorMessage << "Coupling type incorrect!\n";
293 
294  break;
295 
296  case ModelInterface:
297 
298  errorMessage << "Model interface not available!\n";
299 
300  break;
301 
302  default:
303 
304  errorMessage << "No error message for this errorType!\n";
305 
306  break;
307  }
308 
309  errorMessage << message << "\n";
310  multiscaleErrorMessage ( errorMessage );
311  }
312 
313  // Change ExitFlag
314  multiscaleExitFlag = EXIT_FAILURE;
315 }
316 
317 } // Namespace Multiscale
318 } // Namespace LifeV
319 
320 #endif /* MS_Definitions_H */
VectorEpetra - The Epetra Vector format Wrapper.
multiscaleCouplingsContainer_Type::iterator multiscaleCouplingsContainerIterator_Type
std::shared_ptr< multiscaleAlgorithm_Type > multiscaleAlgorithmPtr_Type
Teuchos::ParameterList parameterList_Type
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
MultiscaleAlgorithm - The Multiscale Algorithm Interface.
Teuchos::RCP< parameterList_Type > parameterListPtr_Type
multiscaleModelsContainer_Type::iterator multiscaleModelsContainerIterator_Type
FactorySingleton< Factory< multiscaleModel_Type, models_Type > > multiscaleModelFactory_Type
std::shared_ptr< multiscaleCoupling_Type > multiscaleCouplingPtr_Type
Displayer::commPtr_Type multiscaleCommPtr_Type
std::string multiscaleProblemFolder
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
std::shared_ptr< multiscaleData_Type > multiscaleDataPtr_Type
MultiscaleCoupling multiscaleCoupling_Type
std::shared_ptr< comm_Type > commPtr_Type
Definition: Displayer.hpp:70
void multiscaleMapsDefinition()
Define the map of the MS objects.
void updateInverseJacobian(const UInt &iQuadPt)
multiscaleIDContainer_Type::const_iterator multiscaleIDContainerConstIterator_Type
std::map< std::string, couplings_Type > multiscaleCouplingsMap
MultiscaleGlobalData - Global data container for the physical quantities of the problem.
std::shared_ptr< multiscaleModel_Type > multiscaleModelPtr_Type
std::shared_ptr< DerivedType > multiscaleDynamicCast(BasePtrType &base)
Perform a dynamic cast from a base class to a derived class.
void multiscaleErrorMessage(const std::stringstream &errorMessage)
Display and error message.
multiscaleCouplingsContainer_Type::const_iterator multiscaleCouplingsContainerConstIterator_Type
FactorySingleton< Factory< multiscaleAlgorithm_Type, algorithms_Type > > multiscaleAlgorithmFactory_Type
MultiscaleModel multiscaleModel_Type
std::string multiscaleProblemPrefix
LinearSolver - Class to wrap linear solver.
FactorySingleton< Factory< multiscaleCoupling_Type, couplings_Type > > multiscaleCouplingFactory_Type
MatrixEpetra< Real > multiscaleMatrix_Type
std::vector< multiscaleModelPtr_Type > multiscaleModelsContainer_Type
multiscaleModelsContainer_Type::const_iterator multiscaleModelsContainerConstIterator_Type
std::map< std::string, algorithms_Type > multiscaleAlgorithmsMap
MultiscaleAlgorithm multiscaleAlgorithm_Type
std::vector< multiscaleCouplingPtr_Type > multiscaleCouplingsContainer_Type
LinearSolver::parameterList_Type multiscaleParameterList_Type
double Real
Generic real data.
Definition: LifeV.hpp:175
std::vector< multiscaleID_Type > multiscaleIDContainer_Type
MultiscaleGlobalData multiscaleData_Type
std::map< std::string, models_Type > multiscaleModelsMap
LinearSolver::parameterListPtr_Type multiscaleParameterListPtr_Type
MultiscaleCoupling - The Multiscale Physical Coupling.
std::shared_ptr< multiscaleMatrix_Type > multiscaleMatrixPtr_Type
std::shared_ptr< multiscaleVector_Type > multiscaleVectorPtr_Type
MultiscaleModel - The Multiscale Physical Model.
Displayer - This class is used to display messages in parallel simulations.
Definition: Displayer.hpp:62
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
VectorEpetra multiscaleVector_Type