AbstractParticle.h 3.05 KB
Newer Older
frey_m's avatar
frey_m committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
//
// Class AbstractParticle
//   Abstract base class for IpplParticleBase and AmrParticleBase
//
// Copyright (c) 2017, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Precise Simulations of Multibunches in High Intensity Cyclotrons"
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
21 22 23 24 25 26 27 28
#ifndef ABSTRACT_PARTICLE_H
#define ABSTRACT_PARTICLE_H

#include "Particle/ParticleLayout.h"
#include "Particle/ParticleAttrib.h"

template <class T, unsigned Dim>
class AbstractParticle {
kraus's avatar
kraus committed
29

30 31 32 33 34 35
public:
    typedef typename ParticleLayout<T, Dim>::SingleParticlePos_t
    SingleParticlePos_t;
    typedef typename ParticleLayout<T, Dim>::Index_t Index_t;
    typedef ParticleAttrib<SingleParticlePos_t> ParticlePos_t;
    typedef ParticleAttrib<Index_t>             ParticleIndex_t;
frey_m's avatar
frey_m committed
36 37
    typedef typename ParticleLayout<T, Dim>::UpdateFlags UpdateFlags;
    typedef typename ParticleLayout<T, Dim>::Position_t Position_t;
38
    typedef ParticleLayout<T, Dim> Layout_t;
kraus's avatar
kraus committed
39

40
public:
kraus's avatar
kraus committed
41

42
    AbstractParticle() : R_p(0), ID_p(0) {}
kraus's avatar
kraus committed
43 44

    virtual ~AbstractParticle() { }
45 46 47 48 49
//     AbstractParticle(ParticlePos_t& R,
//                      ParticleIndex_t& ID) : R_p(&R), ID_p(&ID)
//                      {
//                          std::cout << "AbstractParticle()" << std::endl;
//                     }
kraus's avatar
kraus committed
50

51
    virtual void addAttribute(ParticleAttribBase& pa) = 0;
kraus's avatar
kraus committed
52

53 54 55 56 57 58
    virtual size_t getTotalNum() const = 0;
    virtual size_t getLocalNum() const = 0;
    virtual size_t getDestroyNum() const = 0;
    virtual size_t getGhostNum() const = 0;
    virtual void setTotalNum(size_t n) = 0;
    virtual void setLocalNum(size_t n) = 0;
kraus's avatar
kraus committed
59

60 61
    virtual unsigned int getMinimumNumberOfParticlesPerCore() const = 0;
    virtual void setMinimumNumberOfParticlesPerCore(unsigned int n) = 0;
kraus's avatar
kraus committed
62

63 64
    virtual Layout_t& getLayout() = 0;
    virtual const Layout_t& getLayout() const = 0;
kraus's avatar
kraus committed
65

66
    virtual bool getUpdateFlag(UpdateFlags f) const = 0;
kraus's avatar
kraus committed
67

68
    virtual void setUpdateFlag(UpdateFlags f, bool val) = 0;
kraus's avatar
kraus committed
69

70
    virtual ParticleBConds<Position_t, Dim>& getBConds() = 0;
kraus's avatar
kraus committed
71

72
    virtual void setBConds(const ParticleBConds<Position_t, Dim>& bc) = 0;
kraus's avatar
kraus committed
73

74
    virtual bool singleInitNode() const = 0;
kraus's avatar
kraus committed
75

76
    virtual void resetID() = 0;
kraus's avatar
kraus committed
77 78


79 80
    virtual void update() = 0;
    virtual void update(const ParticleAttrib<char>& canSwap) = 0;
kraus's avatar
kraus committed
81

82 83 84
    virtual void createWithID(unsigned id) = 0;
    virtual void create(size_t) = 0;
    virtual void globalCreate(size_t np) = 0;
kraus's avatar
kraus committed
85

86
    virtual void destroy(size_t, size_t, bool = false) = 0;
kraus's avatar
kraus committed
87

88
    virtual void performDestroy(bool updateLocalNum = false) = 0;
kraus's avatar
kraus committed
89

90
    virtual void ghostDestroy(size_t M, size_t I) = 0;
kraus's avatar
kraus committed
91

92 93 94 95 96
public:
    ParticlePos_t* R_p;
    ParticleIndex_t* ID_p;
};

kraus's avatar
kraus committed
97
#endif