AbstractParticle.h 2.93 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
#ifndef ABSTRACT_PARTICLE_H
#define ABSTRACT_PARTICLE_H

#include "Particle/ParticleLayout.h"
25 26 27

template<class T> class ParticleAttrib;
class ParticleAttribBase;
28 29 30

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

32 33 34 35 36 37
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
38 39
    typedef typename ParticleLayout<T, Dim>::UpdateFlags UpdateFlags;
    typedef typename ParticleLayout<T, Dim>::Position_t Position_t;
40
    typedef ParticleLayout<T, Dim> Layout_t;
kraus's avatar
kraus committed
41

42
public:
kraus's avatar
kraus committed
43

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

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

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

55 56 57 58 59 60
    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
61

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

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

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

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

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

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

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


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

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

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

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

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

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

kraus's avatar
kraus committed
96
#endif