FLeafBalance.hpp 2.15 KB
Newer Older
1
// ===================================================================================
2 3 4 5
// Copyright ScalFmm 2016 INRIA, Olivier Coulaud, Bérenger Bramas,
// Matthias Messner olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the
// FMM.
6
//
7
// This software is governed by the CeCILL-C and LGPL licenses and
8
// abiding by the rules of distribution of free software.
9 10 11
// An extension to the license is given to allow static linking of scalfmm
// inside a proprietary application (no matter its license).
// See the main license file for more details.
12
//
13 14 15
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 17 18
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
// ===================================================================================

#ifndef FLEAFBALANCE_H
#define FLEAFBALANCE_H

#include "./FAbstractBalanceAlgorithm.hpp"
#include "../Utils/FMath.hpp"

/**
 * @author Cyrille Piacibello
 * @class FLeafBalance
 *
 * @brief This class inherits from FAbstractBalanceAlgorithm. It
 * provides balancing methods based on leaf numbers only.
 */
class FLeafBalance : public FAbstractBalanceAlgorithm{

public:
  /**
   * Does not need the number of particles. Just divide the leaves
   * over processus
   */
41 42
  FSize getRight(const FSize numberOfLeaves,
                 const int numberOfProc, const int idxOfProc){
43 44 45 46 47
    const double step = (double(numberOfLeaves) / double(numberOfProc));
    const FSize res = FSize(FMath::Ceil(step * double(idxOfProc+1)));
    if(res > numberOfLeaves) return numberOfLeaves;
    else return res;
  }
48

49 50 51 52
  /**
   * Does not need the number of particles. Just divide the leaves
   * over processus
   */
53 54
  FSize getLeft(const FSize numberOfLeaves,
                const int numberOfProc, const int idxOfProc){
55 56 57 58 59 60 61 62
    const double step = (double(numberOfLeaves) / double(numberOfProc));
    return FSize(FMath::Ceil(step * double(idxOfProc)));
  }

};


#endif // FLEAFBALANCE_H