OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
EMField.cpp
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2// $RCSfile: EMField.cpp,v $
3// ------------------------------------------------------------------------
4// $Revision: 1.1.1.1 $
5// ------------------------------------------------------------------------
6// Copyright: see Copyright.readme
7// ------------------------------------------------------------------------
8//
9// Classes:
10// Point3D: a point in 3-dimensional space.
11// EVector: an electric field vector.
12// BVector: a magnetic field vector.
13// EBVectors: an electromagnetic field, containing E and B.
14// EMField: a virtual base class for electromagnetic fields.
15//
16// ------------------------------------------------------------------------
17// Class category: Fields
18// ------------------------------------------------------------------------
19//
20// $Date: 2000/03/27 09:32:35 $
21// $Author: fci $
22//
23// ------------------------------------------------------------------------
24
25#include "Fields/EMField.h"
26
27
28// Class Point3D
29// ------------------------------------------------------------------------
30
31Point3D::Point3D(double xx, double yy, double zz)
32{ x = xx; y = yy; z = zz; }
33
34double Point3D::getX() const
35{ return x; }
36
37double Point3D::getY() const
38{ return y; }
39
40double Point3D::getZ() const
41{ return z; }
42
43
44// Class EVector
45// ------------------------------------------------------------------------
46
47EVector::EVector(double Exx, double Eyy, double Ezz)
48{ Ex = Exx; Ey = Eyy; Ez = Ezz; }
49
50
51EVector EVector::operator*(double scale) const
52{ return EVector(scale * Ex, scale * Ey, scale * Ez); }
53
54
55double EVector::getEx() const
56{ return Ex; }
57
58
59double EVector::getEy() const
60{ return Ey; }
61
62
63double EVector::getEz() const
64{ return Ez; }
65
66
67// Class BVector
68// ------------------------------------------------------------------------
69
70BVector::BVector(double Bxx, double Byy, double Bzz)
71{ Bx = Bxx; By = Byy; Bz = Bzz; }
72
73
74BVector BVector::operator*(double scale) const
75{ return BVector(scale * Bx, scale * By, scale * Bz); }
76
77
78double BVector::getBx() const
79{ return Bx; }
80
81
82double BVector::getBy() const
83{ return By; }
84
85
86double BVector::getBz() const
87{ return Bz; }
88
89
90// Class EBVectors
91// ------------------------------------------------------------------------
92
93EBVectors::EBVectors(const EVector &eField, const BVector &bField):
94 E(eField), B(bField)
95{}
96
97
99{ return E; }
100
101
102double EBVectors::getEx() const
103{ return E.getEx(); }
104
105
106double EBVectors::getEy() const
107{ return E.getEy(); }
108
109
110double EBVectors::getEz() const
111{ return E.getEz(); }
112
113
115{ return B; }
116
117
118double EBVectors::getBx() const
119{ return B.getBx(); }
120
121
122double EBVectors::getBy() const
123{ return B.getBy(); }
124
125
126double EBVectors::getBz() const
127{ return B.getBy(); }
128
129
130// Class EMField
131// ------------------------------------------------------------------------
132
133// Zero field representations.
134const EVector
135EMField::ZeroEfield(0.0, 0.0, 0.0);
136
137
138const BVector
139EMField::ZeroBfield(0.0, 0.0, 0.0);
140
141
142const EBVectors
144
145
147{}
148
149
151{}
152
153
155{}
156
157
159 return *this;
160}
161
162
164 return ZeroEfield;
165}
166
167
169 return ZeroBfield;
170}
171
172
173EVector EMField::Efield(const Point3D &X, double) const {
174 return Efield(X);
175}
176
177
178BVector EMField::Bfield(const Point3D &X, double) const {
179 return Bfield(X);
180}
181
182
184 return EBVectors(Efield(X), Bfield(X));
185}
186
187
188EBVectors EMField::EBfield(const Point3D &X, double) const {
189 return EBfield(X);
190}
#define X(arg)
Definition: fftpack.cpp:112
A point in 3 dimensions.
Definition: EMField.h:33
Point3D(double x, double y, double z)
Constructor.
Definition: EMField.cpp:31
double getZ() const
Return coordinate.
Definition: EMField.cpp:40
double getX() const
Return coordinate.
Definition: EMField.cpp:34
double z
Definition: EMField.h:55
double y
Definition: EMField.h:55
double x
Definition: EMField.h:55
double getY() const
Return coordinate.
Definition: EMField.cpp:37
An electric field vector.
Definition: EMField.h:63
double Ex
Definition: EMField.h:89
double Ez
Definition: EMField.h:89
EVector operator*(double scalar) const
Scale.
Definition: EMField.cpp:51
double getEz() const
Get component.
Definition: EMField.cpp:63
EVector(double, double, double)
Constructor.
Definition: EMField.cpp:47
double getEx() const
Get component.
Definition: EMField.cpp:55
double getEy() const
Get component.
Definition: EMField.cpp:59
double Ey
Definition: EMField.h:89
A magnetic field vector.
Definition: EMField.h:97
BVector operator*(double scalar) const
Scale.
Definition: EMField.cpp:74
double getBz() const
Get component.
Definition: EMField.cpp:86
double Bx
Definition: EMField.h:123
double getBy() const
Get component.
Definition: EMField.cpp:82
double getBx() const
Get component.
Definition: EMField.cpp:78
double Bz
Definition: EMField.h:123
BVector(double, double, double)
Constructor.
Definition: EMField.cpp:70
double By
Definition: EMField.h:123
A representation of an electromagnetic field.
Definition: EMField.h:133
double getEz() const
Get component.
Definition: EMField.cpp:110
EVector E
Definition: EMField.h:176
double getBz() const
Get component.
Definition: EMField.cpp:126
double getEx() const
Get component.
Definition: EMField.cpp:102
double getBy() const
Get component.
Definition: EMField.cpp:122
BVector getB() const
Get field.
Definition: EMField.cpp:114
double getBx() const
Get component.
Definition: EMField.cpp:118
BVector B
Definition: EMField.h:177
EBVectors(const EVector &E, const BVector &B)
Constructor.
Definition: EMField.cpp:93
EVector getE() const
Get component.
Definition: EMField.cpp:98
double getEy() const
Get component.
Definition: EMField.cpp:106
Abstract base class for electromagnetic fields.
Definition: EMField.h:188
EMField()
Default constructor.
Definition: EMField.cpp:146
const EMField & operator=(const EMField &right)
Definition: EMField.cpp:158
static const BVector ZeroBfield
The constant representing a zero magnetic field.
Definition: EMField.h:239
static const EVector ZeroEfield
The constant representing a zero electric field.
Definition: EMField.h:236
virtual BVector Bfield(const Point3D &P) const
Get field.
Definition: EMField.cpp:168
virtual ~EMField()
Definition: EMField.cpp:154
static const EBVectors ZeroEBfield
The constant representing a zero electromagnetic field.
Definition: EMField.h:242
virtual EVector Efield(const Point3D &P) const
Get field.
Definition: EMField.cpp:163
virtual EBVectors EBfield(const Point3D &P) const
Get field.
Definition: EMField.cpp:183