LifeV
MultiscaleCommunicatorsManager.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 Communicators Manager
30  *
31  * @date 13-04-2011
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #ifndef MultiscaleCommunicatorsManager_H
38 #define MultiscaleCommunicatorsManager_H 1
39 
40 #include <lifev/multiscale/framework/MultiscaleDefinitions.hpp>
41 
42 namespace LifeV
43 {
44 namespace Multiscale
45 {
46 
47 //! MultiscaleCommunicatorsManager - The Multiscale Communicators Manager
48 /*!
49  * @author Cristiano Malossi
50  *
51  * @see Full description of the Geometrical Multiscale Framework: \cite Malossi-Thesis
52  * @see Methodology: \cite Malossi2011Algorithms \cite Malossi2011Algorithms1D \cite Malossi2011Algorithms3D1DFSI \cite BlancoMalossi2012
53  * @see Applications: \cite Malossi2011Algorithms3D1DFSIAortaIliac \cite LassilaMalossi2012IdealLeftVentricle \cite BonnemainMalossi2012LVAD
54  *
55  * The MultiscaleCommunicatorsManager class partitions a communicator among different models.
56  */
58 {
59 public:
60 
61  //! @name Type definitions
62  //@{
63 
71 
72  //@}
73 
74 
75  //! @name Constructors & Destructor
76  //@{
77 
78  //! Constructor
80 
81  //! Destructor
83 
84  //@}
85 
86 
87  //! @name Methods
88  //@{
89 
90  //! Split the communicator among the models
91  void splitCommunicator();
92 
93  //! Determine if the model is owned by the process
94  /*!
95  * @param modelID ID of the model.
96  * @return true if the model is owned by the process, false otherwise
97  */
98  bool myModel ( const UInt& modelID ) const;
99 
100  //! Determine the number of model owned by the process
101  /*!
102  * @return number of model owned by the process
103  */
105  {
106  return M_commContainer.size();
107  }
108 
109  //! Display some information about the communicators
110  void showMe();
111 
112  //@}
113 
114 
115  //! @name Set Methods
116  //@{
117 
118  //! Set the main epetra communicator
119  /*!
120  * @param comm Epetra communicator
121  */
123  {
124  M_comm = comm;
125  }
126 
127  //! Add a group of models
128  /*!
129  * This method add a group of models for the forthcoming partitioning of the communicator.
130  *
131  * @param load percentage load of the model (-1 means each model on a different processor).
132  * @param modelsIDList list of models.
133  */
134  void addGroup ( const Real& load, const modelsID_Type& modelsID );
135 
136  //@}
137 
138 
139  //! @name Get Methods
140  //@{
141 
142  //! Get the communicator of a specific model
143  /*!
144  * @param modelID ID of the model.
145  * @return communicator.
146  */
147  const multiscaleCommPtr_Type& modelCommunicator ( const UInt& modelID ) const
148  {
149  return M_commContainer.find ( modelID )->second;
150  }
151 
152  //@}
153 
154 private:
155 
156  //! @name Unimplemented Methods
157  //@{
158 
160 
162 
163  //@}
164 
165 
166  //! @name Private Methods
167  //@{
168 
169  void parallelProcessesDistribution ( std::vector<Real>& localNumberOfProcesses, const Int& numberOfProcesses );
170 
171  void parallelProcessesAssignment ( std::vector< std::vector< Int > >& parallelProcesses, const std::vector<Real>& localNumberOfProcesses, const Int& numberOfProcesses );
172 
173  //! Round a real number to the closest integer
174  /*!
175  * NOTE: x.5 is rounded to x+1;
176  * @param value Real value
177  * @return rounded integer value
178  */
179  Int roundToInteger ( const Real& value ) const
180  {
181  return static_cast<Int> ( std::floor ( value + 0.5 ) );
182  }
183 
184  //@}
185 
186  // Main Communicator
188 
189  // Models communicators
191 
192  // Serial models data
195 
196  // Parallel models data
200 };
201 
202 } // Namespace multiscale
203 } // Namespace LifeV
204 
205 #endif /* MultiscaleCommunicatorsManager_H */
MultiscaleCommunicatorsManager(const MultiscaleCommunicatorsManager &solver)
void parallelProcessesAssignment(std::vector< std::vector< Int > > &parallelProcesses, const std::vector< Real > &localNumberOfProcesses, const Int &numberOfProcesses)
const multiscaleCommPtr_Type & modelCommunicator(const UInt &modelID) const
Get the communicator of a specific model.
Displayer::commPtr_Type multiscaleCommPtr_Type
UInt myModelsNumber() const
Determine the number of model owned by the process.
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
MultiscaleCommunicatorsManager & operator=(const MultiscaleCommunicatorsManager &solver)
void updateInverseJacobian(const UInt &iQuadPt)
void setCommunicator(const multiscaleCommPtr_Type &comm)
Set the main epetra communicator.
void showMe()
Display some information about the communicators.
void addGroup(const Real &load, const modelsID_Type &modelsID)
Add a group of models.
void parallelProcessesDistribution(std::vector< Real > &localNumberOfProcesses, const Int &numberOfProcesses)
Int roundToInteger(const Real &value) const
Round a real number to the closest integer.
double Real
Generic real data.
Definition: LifeV.hpp:175
std::map< UInt, multiscaleCommPtr_Type > modelsCommunicatorContainer_Type
bool myModel(const UInt &modelID) const
Determine if the model is owned by the process.
void splitCommunicator()
Split the communicator among the models.
modelsCommunicatorContainer_Type::const_iterator modelsCommunicatorContainerIterator_Type
MultiscaleCommunicatorsManager - The Multiscale Communicators Manager.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191