LifeV
MultiscaleAlgorithm.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 Algorithm
30  *
31  * @date 23-10-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #ifndef MultiscaleAlgorithm_H
38 #define MultiscaleAlgorithm_H 1
39 
40 #include <lifev/multiscale/framework/MultiscaleDefinitions.hpp>
41 #include <lifev/multiscale/models/MultiscaleModelMultiscale.hpp>
42 
43 
44 #include <Teuchos_XMLParameterListHelpers.hpp>
45 
46 
47 namespace LifeV
48 {
49 namespace Multiscale
50 {
51 
52 // Forward declaration
54 
55 //! MultiscaleAlgorithm - The Multiscale Algorithm Interface
56 /*!
57  * @author Cristiano Malossi
58  *
59  * @see Full description of the Geometrical Multiscale Framework: \cite Malossi-Thesis
60  * @see Methodology: \cite Malossi2011Algorithms \cite Malossi2011Algorithms1D \cite Malossi2011Algorithms3D1DFSI \cite BlancoMalossi2012
61  * @see Applications: \cite Malossi2011Algorithms3D1DFSIAortaIliac \cite LassilaMalossi2012IdealLeftVentricle \cite BonnemainMalossi2012LVAD
62  *
63  * The MultiscaleAlgorithm class provides a general interface between the
64  * MultiscaleSolver and the specific Algorithm to solve the problem.
65  *
66  */
68 {
69 public:
70 
71  //! @name Type definitions
72  //@{
73 
76 
77  //@}
78 
79 
80  //! @name Constructors & Destructor
81  //@{
82 
83  //! Constructor
84  explicit MultiscaleAlgorithm();
85 
86  //! Destructor
87  virtual ~MultiscaleAlgorithm() {}
88 
89  //@}
90 
91 
92  //! @name Multiscale Algorithm Virtual Methods
93  //@{
94 
95  //! Setup the data of the algorithm using a data file
96  /*!
97  * @param fileName Name of the data file.
98  */
99  virtual void setupData ( const std::string& fileName ) = 0;
100 
101  //! Setup coupling variables and other quantities of the algorithm
102  virtual void setupAlgorithm();
103 
104  //! Perform sub-iteration on the coupling variables
105  virtual void subIterate();
106 
107  //! Display some information about the algorithm
108  virtual void showMe();
109 
110  //@}
111 
112 
113  //! @name Methods
114  //@{
115 
116  Real computeResidual() const;
117 
118  //@}
119 
120 
121  //! @name Set Methods
122  //@{
123 
124  //! Set the epetra communicator for the model
125  /*!
126  * @param comm Epetra communicator
127  */
129  {
130  M_comm = comm;
131  }
132 
133  //! Set the main Multiscale model
134  /*!
135  * @param model Multiscale model
136  */
138  {
139  M_multiscale = model;
140  }
141 
142  //! Set the maximum number of subiterations
143  /*!
144  * @param subiterationsMaximumNumber maximum number of subiterations
145  */
146  void setSubiterationsMaximumNumber ( const UInt& subiterationsMaximumNumber )
147  {
148  M_subiterationsMaximumNumber = subiterationsMaximumNumber;
149  }
150 
151  //! Set the tolerance
152  /*!
153  * @param tolerance coupling tolerance
154  */
155  void setTolerance ( const Real& tolerance )
156  {
157  M_tolerance = tolerance;
158  }
159 
160  //! Set the algorithm name
161  /*!
162  * @param parameterList teuchos list of parameters
163  */
164  void setAlgorithmName ( const multiscaleParameterList_Type& parameterList );
165 
166  //! Set the the main parameters of the algorithm (tolerance, maximum number of subiterations, etc.)
167  /*!
168  * @param parameterList teuchos list of parameters
169  */
170  virtual void setAlgorithmParameters ( const multiscaleParameterList_Type& parameterList );
171 
172  //@}
173 
174 
175  //! @name Get Methods
176  //@{
177 
178  //! Get the type of the algorithm
179  /*!
180  * @return type of the algorithm
181  */
182  const algorithms_Type& type() const
183  {
184  return M_type;
185  }
186 
187  //! Get the Multiscale problem
188  /*!
189  * @return shared_ptr to the Multiscale problem
190  */
192  {
193  return M_multiscale;
194  }
195 
196  //! Get the coupling variables
197  /*!
198  * @return pointer to the coupling variables vector
199  */
201  {
202  return M_couplingVariables;
203  }
204 
205  //! Get the coupling residuals
206  /*!
207  * @return pointer to the coupling residuals vector
208  */
210  {
211  return M_couplingResiduals;
212  }
213 
214  //! Get the communicator
215  /*!
216  * @return pointer to the communicator
217  */
219  {
220  return M_comm;
221  }
222 
223  //! Get the subiterations maximum number
224  /*!
225  * @return maximum number of subiterations
226  */
228  {
230  }
231 
232  //! Get the required tolerance
233  /*!
234  * @return tolerance
235  */
236  const Real& tolerance() const
237  {
238  return M_tolerance;
239  }
240 
241  //@}
242 
243 protected:
244 
245  //! @name Protected Methods
246  //@{
247 
248  //! save on a Matlab file the information about the convergence of the algorithm.
249  /*!
250  * @param subiterationsNumber Number of subiterations performed.
251  * @param computeResidual computeResidual.
252  */
253  void save ( const UInt& subiterationsNumber, const Real& residual ) const;
254 
255  //! Update the residual and check if the tolerance has been satisfied
256  /*!
257  * @param subIT subiteration number (for output purpose)
258  * @return true if the tolerance is satisfied
259  */
260  bool checkResidual ( const UInt& subIT = 0 ) const;
261 
262  //@}
263 
265  std::string M_name;
266 
268 
271 
273 
276 
277 private:
278 
279  //! @name Unimplemented Methods
280  //@{
281 
282  MultiscaleAlgorithm ( const MultiscaleAlgorithm& algorithm );
283 
284  MultiscaleAlgorithm& operator= ( const MultiscaleAlgorithm& algorithm );
285 
286  //@}
287 };
288 
289 } // Namespace Multiscale
290 } // Namespace LifeV
291 
292 #endif /* MultiscaleAlgorithm_H */
void save(const UInt &subiterationsNumber, const Real &residual) const
save on a Matlab file the information about the convergence of the algorithm.
void setAlgorithmName(const multiscaleParameterList_Type &parameterList)
Set the algorithm name.
MultiscaleAlgorithm(const MultiscaleAlgorithm &algorithm)
virtual void showMe()
Display some information about the algorithm.
MultiscaleAlgorithm - The Multiscale Algorithm Interface.
MultiscaleModelMultiscale multiscaleModelMultiscale_Type
Displayer::commPtr_Type multiscaleCommPtr_Type
const algorithms_Type & type() const
Get the type of the algorithm.
void setSubiterationsMaximumNumber(const UInt &subiterationsMaximumNumber)
Set the maximum number of subiterations.
virtual void setupAlgorithm()
Setup coupling variables and other quantities of the algorithm.
const multiscaleModelMultiscalePtr_Type & multiScaleProblem() const
Get the Multiscale problem.
void updateInverseJacobian(const UInt &iQuadPt)
void setTolerance(const Real &tolerance)
Set the tolerance.
virtual void setAlgorithmParameters(const multiscaleParameterList_Type &parameterList)
Set the the main parameters of the algorithm (tolerance, maximum number of subiterations, etc.)
const multiscaleVectorPtr_Type & couplingVariables() const
Get the coupling variables.
LinearSolver::parameterList_Type multiscaleParameterList_Type
double Real
Generic real data.
Definition: LifeV.hpp:175
multiscaleModelMultiscale_Type * multiscaleModelMultiscalePtr_Type
multiscaleModelMultiscalePtr_Type M_multiscale
void setCommunicator(const multiscaleCommPtr_Type &comm)
Set the epetra communicator for the model.
bool checkResidual(const UInt &subIT=0) const
Update the residual and check if the tolerance has been satisfied.
void setMultiscaleModel(const multiscaleModelMultiscalePtr_Type model)
Set the main Multiscale model.
const multiscaleVectorPtr_Type & couplingResiduals() const
Get the coupling residuals.
MultiscaleAlgorithm & operator=(const MultiscaleAlgorithm &algorithm)
virtual void subIterate()
Perform sub-iteration on the coupling variables.
const Real & tolerance() const
Get the required tolerance.
MultiscaleModelMultiscale - Multiscale model.
const multiscaleCommPtr_Type & communicator() const
Get the communicator.
const UInt & subiterationsMaximumNumber() const
Get the subiterations maximum number.
std::shared_ptr< multiscaleVector_Type > multiscaleVectorPtr_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191