$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

defaultMultiGridPolicy3D.h

Go to the documentation of this file.
00001 /* This file is part of the Palabos library.
00002  *
00003  * Copyright (C) 2011 FlowKit Sarl
00004  * Avenue de Chailly 23
00005  * 1012 Lausanne, Switzerland
00006  * E-mail contact: contact@flowkit.com
00007  *
00008  * The most recent release of Palabos can be downloaded at 
00009  * <http://www.palabos.org/>
00010  *
00011  * The library Palabos is free software: you can redistribute it and/or
00012  * modify it under the terms of the GNU Affero General Public License as
00013  * published by the Free Software Foundation, either version 3 of the
00014  * License, or (at your option) any later version.
00015  *
00016  * The library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Affero General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Affero General Public License
00022  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 /* Main author: Daniel Lagrava
00026  **/
00027 
00028 #ifndef DEFAULT_MULTI_GRID_POLICY_3D_H
00029 #define DEFAULT_MULTI_GRID_POLICY_3D_H
00030 
00031 #include "multiBlock/defaultMultiBlockPolicy3D.h"
00032 #include "multiGrid/multiGrid3D.h"
00033 #include "multiGrid/multiGridManagement3D.h"
00034 
00035 #include <cmath>
00036 
00037 namespace plb {
00038 
00039 class DefaultMultiGridPolicy3D {
00040   public:
00042     std::vector< BlockCommunicator3D* > getBlockCommunicator(plint levels){
00043       PLB_ASSERT(levels>0);
00044       std::vector< BlockCommunicator3D* > res;
00045       for (int i = 0; i < levels; ++i){
00046         res.push_back(defaultMultiBlockPolicy3D().getBlockCommunicator());
00047       }
00048       return res;
00049     }
00050     
00052     MultiGridManagement3D getMultiGridManagement(plint nx, plint ny, plint numLevels, plint referenceLevel) {
00053         return MultiGridManagement3D(nx, ny, numLevels, referenceLevel );
00054     }
00055     
00057     std::vector<CombinedStatistics*> getCombinedStatistics(plint levels) {
00058         PLB_ASSERT(levels>0);
00059         std::vector<CombinedStatistics*> stats(levels);
00060         for (int i = 0; i < levels; ++i){
00061             // it will be defaultMultiBlockPolicy3D who will give us serial or parallel
00062             stats[i] = defaultMultiBlockPolicy3D().getCombinedStatistics();
00063         }
00064         return stats;
00065     }
00066 
00067     
00068     friend DefaultMultiGridPolicy3D& defaultMultiGridPolicy3D();
00069     
00070   private:
00071     
00072     DefaultMultiGridPolicy3D()
00073         :numProcesses(global::mpi().getSize()),
00074          gridSpacing(100)
00075     {}
00076     
00077   private:
00078     int               numProcesses;
00079     plint             gridSpacing;
00080 
00081 };
00082 
00083 inline DefaultMultiGridPolicy3D& defaultMultiGridPolicy3D(){
00084   static DefaultMultiGridPolicy3D singleton;
00085   return singleton;
00086 }
00087 
00088 
00089 } // namespace plb
00090 
00091 #endif  // DEFAULT_MULTI_GRID_POLICY_3D_H
00092