OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
SFunction.cpp
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2// $RCSfile: SFunction.cpp,v $
3// ------------------------------------------------------------------------
4// $Revision: 1.1.1.1 $
5// ------------------------------------------------------------------------
6// Copyright: see Copyright.readme
7// ------------------------------------------------------------------------
8//
9// Class: SFunction
10// Object handling the position funcitions SI(), SC(), and SO().
11//
12// ------------------------------------------------------------------------
13//
14// $Date: 2000/03/27 09:33:42 $
15// $Author: Andreas Adelmann $
16//
17// ------------------------------------------------------------------------
18
21
22
23// The pointer to the current s-dependent function.
24// ------------------------------------------------------------------------
25
26const SFunction *SFunction::sfun = 0;
27
28
29// Class SFunction
30// ------------------------------------------------------------------------
31
33 reset();
34 sfun = this;
35}
36
37
39 sfun = 0;
40}
41
42
44 if(sfun) {
45 return sfun->position(1.0);
46 } else {
47 throw OpalException("arcIn()",
48 "The use of function \"SI()\" "
49 "is not valid in this context.");
50 }
51}
52
53
55 if(sfun) {
56 return sfun->position(0.5);
57 } else {
58 throw OpalException("arcCtr()",
59 "The use of function \"SC()\" "
60 "is not valid in this context.");
61 }
62}
63
64
66 if(sfun) {
67 return sfun->position(0.0);
68 } else {
69 throw OpalException("arcOut()",
70 "The use of function \"SO()\" "
71 "is not valid in this context.");
72 }
73}
74
75
77 elementLength = 0.0;
78 exitArc = 0.0;
79}
80
81
82void SFunction::update(double length) {
83 elementLength = length;
85}
86
87
88double SFunction::position(double flag) const {
89 // Backtrack to desired position.
90 return exitArc - flag * elementLength;
91}
Functions of arc length.
Definition: SFunction.h:31
double exitArc
Definition: SFunction.h:73
double elementLength
Definition: SFunction.h:70
SFunction()
Default constructor.
Definition: SFunction.cpp:32
static double arcIn()
Return arc length at entrance SI().
Definition: SFunction.cpp:43
static double arcOut()
Return arc length at exit SO().
Definition: SFunction.cpp:65
void reset()
Reset the arc length to zero.
Definition: SFunction.cpp:76
~SFunction()
Destructor.
Definition: SFunction.cpp:38
static const SFunction * sfun
Definition: SFunction.h:77
static double arcCtr()
Return arc length at center SC().
Definition: SFunction.cpp:54
double position(double flag) const
Definition: SFunction.cpp:88
void update(double length)
Advance position by element length.
Definition: SFunction.cpp:82
The base class for all OPAL exceptions.
Definition: OpalException.h:28