OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalSBend3D.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Chris Rogers
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * 1. Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * 2. Redistributions in binary form must reproduce the above copyright notice,
9  * this list of conditions and the following disclaimer in the documentation
10  * and/or other materials provided with the distribution.
11  * 3. Neither the name of STFC nor the names of its contributors may be used to
12  * endorse or promote products derived from this software without specific
13  * prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "Elements/OpalSBend3D.h"
29 #include "Physics/Physics.h"
30 #include "AbsBeamline/SBend3D.h"
31 #include "Attributes/Attributes.h"
33 
34 extern Inform *gmsg;
35 
37  OpalElement(SIZE, "SBEND3D",
38  "The \"SBEND3D\" element defines a sector bending magnet.") {
40  ("FMAPFN", "The name of the field map.");
41  itsAttr[FIELD_UNITS] = Attributes::makeReal("FIELD_UNITS",
42  "Scale the field map up or down by this factor (default 1. is T).");
43  itsAttr[LENGTH_UNITS] = Attributes::makeReal("LENGTH_UNITS",
44  "Units for length coordinates (default 1. is mm).");
45 
47 
48  setElement(new SBend3D("SBEND3D"));
49 }
50 
51 
52 OpalSBend3D::OpalSBend3D(const std::string &name, OpalSBend3D *parent):
53  OpalElement(name, parent) {
54  setElement(new SBend3D(name));
55 }
56 
57 
59 }
60 
61 
62 OpalSBend3D *OpalSBend3D::clone(const std::string &name) {
63  return new OpalSBend3D(name, this);
64 }
65 
66 
68  SBend3D *bend = dynamic_cast<SBend3D*>(getElement());
69  if (itsAttr[FIELD_UNITS])
71  if (itsAttr[LENGTH_UNITS])
73  // this has to be done last as we initialise field map here
74  // (need units before initialisation)
76  setElement(bend);
77 
78 }
@ SIZE
Definition: IndexMap.cpp:174
Inform * gmsg
Definition: Main.cpp:62
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
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
void setFieldMapFileName(std::string name)
Definition: SBend3D.cpp:97
void setFieldUnits(double fieldUnits)
Definition: SBend3D.h:143
void setLengthUnits(double lengthUnits)
Definition: SBend3D.h:137
void registerOwnership() const
virtual void update()
Definition: OpalSBend3D.cpp:67
virtual OpalSBend3D * clone(const std::string &name)
Definition: OpalSBend3D.cpp:62
virtual ~OpalSBend3D()
Definition: OpalSBend3D.cpp:58
Definition: Inform.h:42