PartBinsCyc.cpp 1.77 KB
Newer Older
gsell's avatar
gsell committed
1 2
#include "Algorithms/PartBinsCyc.h"
#include "Physics/Physics.h"
kraus's avatar
kraus committed
3 4
#include <cfloat>
#include <vector>
gsell's avatar
gsell committed
5 6
extern Inform *gmsg;

kraus's avatar
kraus committed
7
// constructer function for cyclotron
gsell's avatar
gsell committed
8 9 10 11
PartBinsCyc::PartBinsCyc(int specifiedNumBins, int bins, size_t  partInBin[])
    : PartBins::PartBins(specifiedNumBins, 0) {

    bins_m = specifiedNumBins;        // max bin number
kraus's avatar
kraus committed
12
    nemittedBins_m = bins;            // the bin number with particles
gsell's avatar
gsell committed
13 14 15 16 17 18 19
    binsEmitted_m = new bool[bins_m]; // flag whether the bin contain particles or not
    nBin_m = new size_t[bins_m];      // number of particles in the bins on the local node

    for(int i = 0; i < bins_m; i++) {
        nBin_m[i] = 0;
        binsEmitted_m[i] = false;
    }
kraus's avatar
kraus committed
20

gsell's avatar
gsell committed
21 22 23

    for(int i = 0; i < nemittedBins_m; i++) {
        nBin_m[i] = partInBin[i];
kraus's avatar
kraus committed
24

gsell's avatar
gsell committed
25 26 27 28 29 30 31 32 33 34 35
        *gmsg << "Read in: Bin=" << i << " Particles Num=" << getTotalNumPerBin(i) << endl;
        binsEmitted_m[i] = true;
    }

}

// constructer function for cyclotron for restart run.
PartBinsCyc::PartBinsCyc(int specifiedNumBins, int bins)
    : PartBins::PartBins(specifiedNumBins, 0) {

    bins_m = specifiedNumBins;        // max bin number
kraus's avatar
kraus committed
36
    nemittedBins_m = bins;            // the bin number with particles
gsell's avatar
gsell committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    binsEmitted_m = new bool[bins_m]; // flag whether the bin contain particles or not
    nBin_m = new size_t[bins_m];      // number of particles in the bins on the local node

    for(int i = 0; i < bins_m; i++) {
        nBin_m[i] = 0;
        binsEmitted_m[i] = false;
    }

    for(int i = 0; i < nemittedBins_m; i++) {
      binsEmitted_m[i] = true;
    }
}

PartBinsCyc::~PartBinsCyc() {
    if(nBin_m) {
        delete nBin_m;
        delete xbinmax_m;
        delete xbinmin_m;
        delete binsEmitted_m;
    }
    tmppart_m.clear();
    isEmitted_m.clear();
    if(h_m)
        delete h_m;
}