1#ifndef G_COMPONENT_VOXEL_H
2#define G_COMPONENT_VOXEL_H
17 void Clear()
override { Reset(); }
19 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
20 double& ey,
double& ez,
double& v,
Medium*& m,
21 int& status)
override;
22 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
23 double& ey,
double& ez,
Medium*& m,
int& status)
override;
25 void WeightingField(
const double x,
const double y,
const double z,
26 double& wx,
double& wy,
double& wz,
27 const std::string& label)
override;
29 const std::string& label)
override;
31 const double t,
double& wx,
double& wy,
double& wz,
32 const std::string& label)
override;
34 void MagneticField(
const double x,
const double y,
const double z,
double& bx,
35 double& by,
double& bz,
int& status)
override;
45 Medium*
GetMedium(
const double x,
const double y,
const double z)
override;
49 double& eymax,
double& ezmin,
double& ezmax);
51 double& xmax,
double& ymax,
double& zmax)
override;
53 double& xmax,
double& ymax,
double& zmax)
override;
61 void SetMesh(
const unsigned int nx,
const unsigned int ny,
62 const unsigned int nz,
const double xmin,
const double xmax,
63 const double ymin,
const double ymax,
const double zmin,
82 const bool withPotential,
const bool withRegion,
83 const double scaleX = 1.,
const double scaleE = 1.,
84 const double scaleP = 1.);
87 const bool withPotential,
88 const double scaleX = 1.,
const double scaleE = 1.,
89 const double scaleP = 1.);
92 const double time,
const bool withPotential,
93 const double scaleX = 1.,
const double scaleE = 1.,
94 const double scaleP = 1.);
97 const double scaleX = 1.,
const double scaleB = 1.);
100 bool GetElement(
const double xi,
const double yi,
const double zi,
101 unsigned int& i,
unsigned int& j,
unsigned int& k,
102 bool& xMirrored,
bool& yMirrored,
bool& zMirrored)
const;
104 bool GetElement(
const unsigned int i,
const unsigned int j,
105 const unsigned int k,
double& v,
double& ex,
double& ey,
116 std::vector<Medium*> m_media;
123 std::vector<std::vector<std::vector<int> > > m_regions;
125 std::vector<std::vector<std::vector<Element> > > m_efields;
127 std::vector<std::vector<std::vector<Element> > > m_bfields;
129 std::vector<std::vector<std::vector<Element> > > m_wfields;
131 std::vector<std::vector<std::vector<std::vector<Element> > > > m_wdfields;
132 std::vector<double> m_wdtimes;
135 unsigned int m_nX = 0, m_nY = 0, m_nZ = 0;
136 double m_xMin = 0., m_yMin = 0., m_zMin = 0.;
137 double m_xMax = 0., m_yMax = 0., m_zMax = 0.;
138 double m_dx = 0., m_dy = 0., m_dz = 0.;
140 bool m_interpolate =
false;
142 bool m_hasMesh =
false;
143 bool m_hasPotential =
false;
144 bool m_hasEfield =
false;
145 bool m_hasBfield =
false;
146 bool m_hasWfield =
false;
149 double m_wField_xOffset = 0.;
150 double m_wField_yOffset = 0.;
151 double m_wField_zOffset = 0.;
154 double m_pMin = 0., m_pMax = 0.;
157 bool LoadData(
const std::string& filename, std::string format,
158 const bool withPotential,
const bool withRegion,
159 const double scaleX,
const double scaleF,
const double scaleP,
160 std::vector<std::vector<std::vector<Element> > >& field);
162 void Reset()
override;
163 void UpdatePeriodicity()
override;
166 bool GetField(
const double x,
const double y,
const double z,
167 const std::vector<std::vector<std::vector<Element> > >& field,
168 double& fx,
double& fy,
double& fz,
double& p,
int& region);
170 double Reduce(
const double xin,
const double xmin,
const double xmax,
171 const bool simplePeriodic,
const bool mirrorPeriodic,
172 bool& isMirrored)
const;
174 void Initialise(std::vector<std::vector<std::vector<Element> > >& fields);
175 void InitialiseRegions();
Component for interpolating field maps stored in a regular mesh.
ComponentVoxel()
Constructor.
void EnableInterpolation(const bool on=true)
Interpolate between field values at the element centres.
void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status) override
~ComponentVoxel()
Destructor.
void Clear() override
Reset.
void SetWeightingFieldOffset(const double x, const double y, const double z)
void PrintRegions() const
Print all regions.
bool LoadWeightingField(const std::string &filename, const std::string &format, const bool withPotential, const double scaleX=1., const double scaleE=1., const double scaleP=1.)
Import (prompt) weighting field from file.
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the bounding box coordinates.
bool GetElectricFieldRange(double &exmin, double &exmax, double &eymin, double &eymax, double &ezmin, double &ezmax)
void DelayedWeightingField(const double x, const double y, const double z, const double t, double &wx, double &wy, double &wz, const std::string &label) override
bool GetElement(const double xi, const double yi, const double zi, unsigned int &i, unsigned int &j, unsigned int &k, bool &xMirrored, bool &yMirrored, bool &zMirrored) const
Return the indices of the element at a given point.
bool GetVoltageRange(double &vmin, double &vmax) override
Calculate the voltage range [V].
bool GetElementaryCell(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the coordinates of the elementary cell.
void SetMedium(const unsigned int i, Medium *m)
Set the medium in region i.
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
Medium * GetMedium(const double x, const double y, const double z) override
Get the medium at a given location (x, y, z).
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status) override
Calculate the drift field [V/cm] and potential [V] at (x, y, z).
void SetMesh(const unsigned int nx, const unsigned int ny, const unsigned int nz, const double xmin, const double xmax, const double ymin, const double ymax, const double zmin, const double zmax)
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
bool LoadElectricField(const std::string &filename, const std::string &format, const bool withPotential, const bool withRegion, const double scaleX=1., const double scaleE=1., const double scaleP=1.)
bool LoadMagneticField(const std::string &filename, const std::string &format, const double scaleX=1., const double scaleB=1.)
Import magnetic field values from a file.
Abstract base class for components.
Abstract base class for media.