OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
SolenoidRep.cpp
Go to the documentation of this file.
1//
2// Class SolenoidRep
3// Representation for a solenoid magnet.
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//
20
21namespace {
22 struct Entry {
23 const char* name;
24 double (SolenoidRep::*get)() const;
25 void (SolenoidRep::*set)(double);
26 };
27
28 const Entry entries[] = {
31 {0, 0, 0}};
32} // namespace
33
34SolenoidRep::SolenoidRep() : Solenoid(), geometry(), field() {}
35
37 : Solenoid(right), geometry(right.geometry), field(right.field) {}
38
39SolenoidRep::SolenoidRep(const std::string& name) : Solenoid(name), geometry(), field() {}
40
42
43ElementBase* SolenoidRep::clone() const { return new SolenoidRep(*this); }
44
45Channel* SolenoidRep::getChannel(const std::string& aKey, bool create) {
46 for (const Entry* entry = entries; entry->name != 0; ++entry) {
47 if (aKey == entry->name) {
48 return new IndirectChannel<SolenoidRep>(*this, entry->get, entry->set);
49 }
50 }
51
52 return ElementBase::getChannel(aKey, create);
53}
54
56
57const ConstBzField& SolenoidRep::getField() const { return field; }
58
60
62
63double SolenoidRep::getBz() const { return field.getBz(); }
64
65void SolenoidRep::setBz(double Bz) { field.setBz(Bz); }
Abstract interface for read/write access to variable.
Definition Channel.h:30
A homogeneous magnetostatic field in z-direction.
virtual double getBz() const
Get component.
virtual void setBz(double Bz)
Set component.
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getElementLength() const
Get design length.
virtual void setElementLength(double length)
Set design length.
Access to a [b]double[/b] data member.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
virtual StraightGeometry & getGeometry()
Get geometry.
virtual ElementBase * clone() const
Return clone.
ConstBzField field
The solenoid field.
Definition SolenoidRep.h:76
StraightGeometry geometry
The solenoid geometry.
Definition SolenoidRep.h:73
virtual ~SolenoidRep()
virtual double getBz() const
Get field.
virtual void setBz(double Bz)
Set field.
virtual ConstBzField & getField()
Get field.
Abstract class for a solenoid magnet.
Definition Solenoid.h:33
A geometry representing a straight line.