OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalDrift.cpp
Go to the documentation of this file.
1//
2// Class OpalDrift
3// The class of OPAL drift spaces.
4//
5// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#include "Elements/OpalDrift.h"
22#include "Structure/OpalWake.h"
24
25
27 OpalElement(SIZE, "DRIFT",
28 "The \"DRIFT\" element defines a drift space."),
29 owk_m(nullptr),
30 parmatint_m(nullptr),
31 obgeo_m(nullptr) {
32 // CKR: the following 3 lines are redundant: OpalElement does this already!
33 // they prevent drift from working properly
34 //
35 // itsAttr[LENGTH] = Attributes::makeReal
36 // ("LENGTH", "Drift length");
37
39 ("GEOMETRY", "BoundaryGeometry for Drifts");
40
42 ("NSLICES", "The number of slices/ steps for this element in Map Tracking", 1);
43
45
46 setElement(new DriftRep("DRIFT"));
47}
48
49
50OpalDrift::OpalDrift(const std::string& name, OpalDrift* parent):
51 OpalElement(name, parent),
52 owk_m(nullptr),
53 parmatint_m(nullptr),
54 obgeo_m(nullptr) {
56}
57
58
60 if (owk_m)
61 delete owk_m;
62 if (parmatint_m)
63 delete parmatint_m;
64 if (obgeo_m)
65 delete obgeo_m;
66}
67
68
69OpalDrift* OpalDrift::clone(const std::string& name) {
70 return new OpalDrift(name, this);
71}
72
73
74bool OpalDrift::isDrift() const {
75 return true;
76}
77
78
81
82 DriftRep* drf = static_cast<DriftRep*>(getElement());
83
86
87 if (itsAttr[WAKEF] && owk_m == nullptr) {
90 drf->setWake(owk_m->wf_m);
91 }
92
94 const std::string matterDescriptor = Attributes::getString(itsAttr[PARTICLEMATTERINTERACTION]);
96 parmatint_m = orig->clone(matterDescriptor);
99 }
100
101 if (itsAttr[GEOMETRY] && obgeo_m == nullptr) {
103 if (obgeo_m) {
105 }
106 }
107
108 // Transmit "unknown" attributes.
110}
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:310
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
void setNSlices(const std::size_t &nSlices)
Definition: Drift.cpp:63
virtual void setBoundaryGeometry(BoundaryGeometry *geo)
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:418
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
virtual void setWake(WakeFunction *wf)
attach a wake field to the element
virtual bool isDrift() const
Test for drift.
Definition: OpalDrift.cpp:74
@ GEOMETRY
Definition: OpalDrift.h:33
virtual void update()
Update the embedded CLASSIC drift.
Definition: OpalDrift.cpp:79
ParticleMatterInteraction * parmatint_m
Definition: OpalDrift.h:63
BoundaryGeometry * obgeo_m
Definition: OpalDrift.h:64
OpalDrift()
Exemplar constructor.
Definition: OpalDrift.cpp:26
virtual ~OpalDrift()
Definition: OpalDrift.cpp:59
virtual OpalDrift * clone(const std::string &name)
Make clone.
Definition: OpalDrift.cpp:69
OpalWake * owk_m
Definition: OpalDrift.h:62
@ PARTICLEMATTERINTERACTION
Definition: OpalElement.h:39
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
static BoundaryGeometry * find(const std::string &name)
WakeFunction * wf_m
Definition: OpalWake.h:56
static OpalWake * find(const std::string &name)
Find named WAKE.
Definition: OpalWake.cpp:127
void initWakefunction(const ElementBase &element)
Definition: OpalWake.cpp:147
virtual ParticleMatterInteraction * clone(const std::string &name)
Make clone.
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
ParticleMatterInteractionHandler * handler_m
void initParticleMatterInteractionHandler(ElementBase &element)