OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
BMultipoleField.h
Go to the documentation of this file.
1#ifndef OPALX_BMultipoleField_HH
2#define OPALX_BMultipoleField_HH
3
5
17public:
19 // Constructs a null field.
21
23 virtual ~BMultipoleField();
25
27 // Return the time-independent part of the magnetic field in point [b]P[/b].
28 // This override forces implementation in derived classes.
29 virtual BVector Bfield(const Point3D& P) const;
30
32 // Return the magnetic field at time [b]t[/b] in point [b]P[/b].
33 // This override forces implementation in derived classes.
34 virtual BVector Bfield(const Point3D& P, double t) const;
35
37 // Return the value of the n'th normal multipole component in T/m**(n-1).
38 // If [b]n[/b] is larger than N, the return value is zero.
39 double getNormalComponent(int n) const;
40
42 // Return the value of the n'th skew multipole component in T/m**(n-1).
43 // If [b]n[/b] is larger than N, the return value is zero.
44 double getSkewComponent(int n) const;
45
47 // Assign the value of the n'th normal multipole component in T/m**(n-1).
48 // If [b]n[/b] is larger than N, the new field component is inserted.
49 void setNormalComponent(int n, double Bn);
50
52 // Assign the value of the n'th skew multipole component in T/m**(n-1).
53 // If [b]n[/b] is larger than N, the new field component is inserted.
54 void setSkewComponent(int n, double Bn);
55
57 // Return the value of the n'th normal multipole component in T/m**(n-1).
58 // Fast version: [b]n[/b] is not checked.
59 // the result is undefined if it is larger than N.
60 double normal(int) const;
61
63 // Return the value of the n'th skew multipole component in T/m**(n-1).
64 // Fast version: [b]n[/b] is not checked.
65 // the result is undefined if it is larger than N.
66 double skew(int) const;
67
69 // Return a reference to the n'th normal multipole component in T/m**(n-1).
70 // Fast version: [b]n[/b] is not checked.
71 // the result is undefined if it is larger than N.
72 double& normal(int);
73
75 // Return a reference to the n'th skew multipole component in T/m**(n-1).
76 // Fast version: [b]n[/b] is not checked.
77 // the result is undefined if it is larger than N.
78 double& skew(int);
79
81 // Add [b]field[/b] to the old field; return new field.
83
85 // Subtract [b]field[/b] from the old field; return new field.
87
89 // Multiply the field by [b]scalar[/b].
90 void scale(double scalar);
91
93 int order() const;
94
95private:
96 struct Pair {
97 // constructors and destructor
98 Pair();
99 Pair(double normal, double skewed = 0.0);
100 Pair(const Pair&);
101 ~Pair();
102
103 // operators
104 void operator=(const Pair&);
105 Pair operator+(const Pair&) const;
106 Pair operator-(const Pair&) const;
107 Pair operator*(double scale) const;
108 void operator+=(const Pair&);
109 void operator-=(const Pair&);
110 void operator*=(double scale);
111 Pair operator-() const;
112
113 double B; // normal multipole coefficient
114 double A; // skewed multipole coefficient
115 };
116
117 // Reserve space for additional coefficients.
118 void reserve(int n);
119
120 // The array of multipole coefficients.
121 // The dimension is N, where N is the largest order (2N-pole),
122 // and pairs[n-1] is the coefficient for the (2n-pole).
124
125 // The highest order N.
126 // Means pairs is filled up to itsOrder-1.
128};
129
130// Inline functions
131// ------------------------------------------------------------------------
132
136inline int BMultipoleField::order() const { return itsOrder; }
137
141inline double BMultipoleField::getNormalComponent(int n) const {
142 if (n >= 0 && n < itsOrder) {
143 return pairs[n].B;
144 } else {
145 return 0.0;
146 }
147}
148
152inline double BMultipoleField::getSkewComponent(int n) const {
153 if (n >= 0 && n < itsOrder) {
154 return pairs[n].A;
155 } else {
156 return 0.0;
157 }
158}
159
160inline double& BMultipoleField::normal(int n) { return pairs[n].B; }
161
162inline double& BMultipoleField::skew(int n) { return pairs[n].A; }
163
164inline double BMultipoleField::normal(int n) const { return pairs[n].B; }
165
166inline double BMultipoleField::skew(int n) const { return pairs[n].A; }
167
168#endif // OPALX_BMultipoleField_HH
The magnetic field of a multipole.
BMultipoleField & addField(const BMultipoleField &field)
Add to field.
int order() const
Return order.
double getNormalComponent(int n) const
Get component.
virtual BVector Bfield(const Point3D &P) const
Get field.
BMultipoleField & operator=(const BMultipoleField &)
BMultipoleField & subtractField(const BMultipoleField &field)
Subtract from field.
BMultipoleField()
Default constructor.
void scale(double scalar)
Scale the field.
virtual ~BMultipoleField()
double getSkewComponent(int n) const
Get component.
void setNormalComponent(int n, double Bn)
Set component.
void setSkewComponent(int n, double Bn)
Set component.
double normal(int) const
Get component.
double skew(int) const
Get component.
A magnetic field vector.
Definition EMField.h:88
A point in 3 dimensions.
Definition EMField.h:32
Abstract base class for static magnetic fields.
Pair operator+(const Pair &) const
void operator*=(double scale)
void operator-=(const Pair &)
void operator=(const Pair &)
void operator+=(const Pair &)
Pair operator*(double scale) const