OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalSource.cpp
Go to the documentation of this file.
1//
2// Class OpalSource
3// The SOURCE element.
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/OpalSource.h"
19
23#include "Physics/Physics.h"
24
25
27 OpalElement(SIZE, "SOURCE",
28 "The \"SOURCE\" element defines a Source.") {
30 ("DISTRIBUTION", "List of particle distributions to be used ");
31
33 ("TRANSPARENT", "Make the source element transparent to impacting elements; Default value is FALSE", false);
34
36
37 setElement(new SourceRep("SOURCE"));
38}
39
40
41OpalSource::OpalSource(const std::string& name, OpalSource* parent):
42 OpalElement(name, parent) {
44}
45
46
48{}
49
50
51OpalSource *OpalSource::clone(const std::string& name) {
52 return new OpalSource(name, this);
53}
54
55
58
59 SourceRep* sol =
60 dynamic_cast<SourceRep*>(getElement());
61 double length = 0.05;
62
63 sol->setElementLength(length);
64
66 sol->setTransparent();
67 }
68
70
71 // Transmit "unknown" attributes.
73}
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
Attribute makeStringArray(const std::string &name, const std::string &help)
Create a string array attribute.
Definition: Attributes.cpp:473
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:418
void setOutputFN(std::string fn)
Set output filename.
void setTransparent()
Definition: Source.cpp:117
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
@ DISTRIBUTION
Definition: OpalSource.h:30
virtual OpalSource * clone(const std::string &name)
Make clone.
Definition: OpalSource.cpp:51
virtual ~OpalSource()
Definition: OpalSource.cpp:47
OpalSource()
Exemplar constructor.
Definition: OpalSource.cpp:26
virtual void update()
Update the embedded CLASSIC solenoid.
Definition: OpalSource.cpp:56