OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
PluginElement.h
Go to the documentation of this file.
1//
2// Class PluginElement
3// Abstract Interface for (Cyclotron) Plugin Elements (CCollimator, Probe, Stripper, Septum)
4// Implementation via Non-Virtual Interface Template Method
5//
6// Copyright (c) 2018-2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7// All rights reserved
8//
9// This file is part of OPAL.
10//
11// OPAL is free software: you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation, either version 3 of the License, or
14// (at your option) any later version.
15//
16// You should have received a copy of the GNU General Public License
17// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18//
19#ifndef CLASSIC_PluginElement_HH
20#define CLASSIC_PluginElement_HH
21
22#include <memory>
23#include <string>
25
26class LossDataSink;
27class PluginElement : public Component {
28public:
30 explicit PluginElement(const std::string& name);
31
34 void operator=(const PluginElement&) = delete;
35 virtual ~PluginElement();
36
38 virtual void initialise(
39 PartBunch_t* bunch, double& startField, double& endField) override; // not used?
40 void initialise(PartBunch_t* bunch); // replacement for virtual initialise
41 virtual void finalise() final; // final since virtual hook doFinalise
42 virtual void goOffline() final; // final since virtual hook doGoOffline
43 virtual bool bends() const override;
44 virtual void getDimensions(double& zBegin, double& zEnd) const override;
47 virtual bool apply(
48 const size_t& i, const double& t, Vector_t<double, 3>& E, Vector_t<double, 3>& B) override;
49
50 virtual bool apply(
51 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
52 Vector_t<double, 3>& E, Vector_t<double, 3>& B);
53
54
55 virtual bool applyToReferenceParticle(
56 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
57 Vector_t<double, 3>& E, Vector_t<double, 3>& B) override;
59
61 void setDimensions(double xstart, double xend, double ystart, double yend);
62
64 double getXStart() const;
65 double getXEnd() const;
66 double getYStart() const;
67 double getYEnd() const;
70 bool check(PartBunch_t* bunch, const int turnnumber, const double t, const double tstep);
72 int checkPoint(const double& x, const double& y) const;
74 void save();
75
76protected:
78 void setGeom(const double dist);
80 void changeWidth(PartBunch_t* bunch, int i, const double tstep, const double tangle);
82 double calculateIncidentAngle(double xp, double yp) const;
83
84private:
86 bool preCheck(PartBunch_t* bunch) {
87 return doPreCheck(bunch);
88 }
89
90 bool finaliseCheck(PartBunch_t* bunch, bool flagNeedUpdate) {
91 return doFinaliseCheck(bunch, flagNeedUpdate);
92 }
93
94 virtual void doInitialise(PartBunch_t* /*bunch*/) {
95 }
96
97 virtual bool doCheck(
98 PartBunch_t* bunch, const int turnnumber, const double t, const double tstep) = 0;
100 virtual void doSetGeom(){};
102 virtual bool doPreCheck(PartBunch_t*) {
103 return true;
104 }
105
106 virtual bool doFinaliseCheck(PartBunch_t*, bool flagNeedUpdate) {
107 return flagNeedUpdate;
108 }
109
110 virtual void doFinalise(){};
112 virtual void doGoOffline(){};
113
114protected:
115 /* Members */
117 double xstart_m;
118 double xend_m;
119 double ystart_m;
120 double yend_m;
121 double rstart_m;
122 double rend_m;
124 double rmin_m;
127 double A_m, B_m, R_m, C_m;
128
129 std::unique_ptr<LossDataSink> lossDs_m;
131};
132
133#endif // CLASSIC_PluginElement_HH
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
#define Point(triangle_id, vertex_id)
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:44
int checkPoint(const double &x, const double &y) const
Checks if coordinate is within element.
void setGeom(const double dist)
Sets geometry geom_m with element width dist.
virtual void getDimensions(double &zBegin, double &zEnd) const override
virtual bool bends() const override
double C_m
Geometric lengths used in calculations.
double getYStart() const
void changeWidth(PartBunch_t *bunch, int i, const double tstep, const double tangle)
Change probe width depending on step size and angle of particle.
virtual void finalise() final
virtual void doSetGeom()
Virtual hook for setGeom.
virtual void doGoOffline()
Virtual hook for goOffline.
int numPassages_m
Number of turns (number of times save() method is called).
virtual bool apply(const size_t &i, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
Virtual implementation of Component.
virtual bool doCheck(PartBunch_t *bunch, const int turnnumber, const double t, const double tstep)=0
Pure virtual hook for check.
virtual bool doFinaliseCheck(PartBunch_t *, bool flagNeedUpdate)
Virtual hook for finaliseCheck.
virtual void doInitialise(PartBunch_t *)
Pure virtual hook for initialise.
bool finaliseCheck(PartBunch_t *bunch, bool flagNeedUpdate)
Finalise call after check.
virtual void doFinalise()
Virtual hook for finalise.
virtual void goOffline() final
double getXEnd() const
void operator=(const PluginElement &)=delete
bool preCheck(PartBunch_t *bunch)
Check if bunch is close to element.
double calculateIncidentAngle(double xp, double yp) const
Calculate angle of particle/bunch wrt to element.
double xstart_m
input geometry positions
virtual void initialise(PartBunch_t *bunch, double &startField, double &endField) override
Pure virtual implementation of Component.
virtual bool doPreCheck(PartBunch_t *)
Virtual hook for preCheck.
void setDimensions(double xstart, double xend, double ystart, double yend)
Set dimensions and consistency checks.
std::unique_ptr< LossDataSink > lossDs_m
Pointer to Loss instance.
double getXStart() const
Member variable access.
bool check(PartBunch_t *bunch, const int turnnumber, const double t, const double tstep)
double getYEnd() const
double rmin_m
radius closest to the origin
PluginElement(const std::string &name)
Constructor with given name.
virtual ~PluginElement()
virtual bool applyToReferenceParticle(const Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
void save()
Save output.