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

multiGridManagement2D.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 
00032 #ifndef MULTI_GRID_MANAGEMENT_2D_H
00033 #define MULTI_GRID_MANAGEMENT_2D_H
00034 
00035 #include "core/globalDefs.h"
00036 #include "core/geometry2D.h"
00037 #include "multiGrid/multiScale.h"
00038 
00039 namespace plb {
00040 
00041 class MultiGridManagement2D {
00042 public:
00043     MultiGridManagement2D(plint coarseNx, plint coarseNy, 
00044                           plint numLevels, plint overlapWidth_=1, plint referenceLevel=0);
00045     MultiGridManagement2D(Box2D coarseBoundingBox, plint numLevels,  plint overlapWidth_=1, plint referenceLevel=0);
00046     
00047     MultiGridManagement2D(MultiGridManagement2D const& rhs);
00048     ~MultiGridManagement2D();
00049     
00050     void swap(MultiGridManagement2D& rhs);
00051     
00053     std::vector<Box2D> const& getBulks(plint iLevel) const;
00054     std::vector<std::vector<Box2D> > const& getBulks() const;
00055     
00057     std::vector<Box2D> const& getUniqueBulks(plint iLevel) const;
00058     std::vector<std::vector<Box2D> > const& getUniqueBulks() const;
00059     
00061     Box2D getBoundingBox(plint level) const;
00062     
00064     void refine(plint level, Box2D domain);
00066     void coarsen(plint level, Box2D domain);
00067 
00069     void refineMultiGrid(plint level, Box2D domain);
00070     
00073     std::vector<std::vector<plint> > const& getMpiProcesses() const;
00074     
00075     std::vector<std::vector<Box2D> > const& getCoarseInterface() const;
00076     std::vector<std::vector<Box2D> > const& getFineInterface() const;
00077     std::vector<std::vector<Array<plint,2> > > const& getCoarseOrientation() const;
00078     std::vector<std::vector<Array<plint,2> > > const& getFineOrientation() const;
00079     
00080     void trimDomain (plint whichLevel, Box2D& domain,bool& touchLeft, 
00081                      bool& touchRight, bool& touchBottom, bool& touchTop ) const;
00082 
00083     plint getNumLevels() const;
00084     plint getReferenceLevel() const;
00085     plint getOverlapWidth() const;
00086     
00088 
00092     void parallelizeX(std::vector<plint> const& finePositions);
00094 
00098     void parallelizeY(std::vector<plint> const& finePositions);
00099     
00101     void parallelize(std::vector<Box2D> parallelRegions, std::vector<plint> const& regionIDs);
00102     
00104     void eliminateUnnecessaryFineInterfaces();
00105 
00106     friend MultiGridManagement2D extractManagement(MultiGridManagement2D management, Box2D coarsestDomain, bool crop);
00107     
00108 private:
00109     void initialize(Box2D const& level0_box);
00110     void parallelizeLevel(plint whichLevel, std::vector<Box2D> const& parallelRegions, 
00111                           std::vector<plint> const& regionIDs);
00112 
00113 private:
00114     plint                                overlapWidth;
00115     plint                                referenceLevel;
00116     
00118     std::vector<Box2D>                   boundingBoxes;
00119     
00121 
00122     std::vector<std::vector<Box2D> >     coarseGridInterfaces;
00124 
00125     std::vector<std::vector<Box2D> >     fineGridInterfaces;
00126 
00128     std::vector<std::vector<Box2D> >     bulks;
00129     
00131     std::vector<std::vector<Array<plint,2> >  > coarseInterfaceOrientations;
00132     std::vector<std::vector<Array<plint,2> >  > fineInterfaceOrientations;
00133     
00135     std::vector<std::vector<plint> >     mpiProcess;
00136     
00137     MultiScaleManager *scaleManager; 
00138 };
00139 
00140 MultiGridManagement2D extractManagement(MultiGridManagement2D management, Box2D coarsestDomain, bool crop=true);
00141 
00142 
00143 } // namespace plb
00144 
00145 #endif  // MULTI_GRID_MANAGEMENT_2D_H
00146