1#ifndef G_COMPONENT_GRID_H
2#define G_COMPONENT_GRID_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;
37 Medium*
GetMedium(
const double x,
const double y,
const double z)
override;
41 double& eymax,
double& ezmin,
double& ezmax);
42 bool GetBoundingBox(
double& xmin,
double& ymin,
double& zmin,
double& xmax,
43 double& ymax,
double& zmax)
override;
51 bool SetMesh(
const unsigned int nx,
const unsigned int ny,
52 const unsigned int nz,
const double xmin,
const double xmax,
53 const double ymin,
const double ymax,
const double zmin,
56 bool GetMesh(
unsigned int& nx,
unsigned int& ny,
unsigned int& nz,
57 double& xmin,
double& xmax,
double& ymin,
double& ymax,
58 double& zmin,
double& zmax)
const;
77 const bool withPotential,
const bool withFlag,
78 const double scaleX = 1.,
79 const double scaleE = 1.,
const double scaleP = 1.);
83 const bool withPotential,
84 const double scaleX = 1.,
const double scaleE = 1.,
85 const double scaleP = 1.);
88 const double time,
const bool withPotential,
89 const double scaleX = 1.,
const double scaleE = 1.,
90 const double scaleP = 1.);
99 const double scaleX = 1.,
const double scaleB = 1.);
107 const std::string& format);
115 const std::string& filename,
116 const std::string& format);
120 const unsigned int k,
double& v,
double& ex,
double& ey,
129 Medium* m_medium =
nullptr;
136 std::vector<std::vector<std::vector<Node> > > m_efields;
138 std::vector<std::vector<std::vector<Node> > > m_bfields;
140 std::vector<std::vector<std::vector<Node> > > m_wfields;
142 std::vector<std::vector<std::vector<std::vector<Node> > > > m_wdfields;
143 std::vector<double> m_wdtimes;
145 std::vector<std::vector<std::vector<bool> > > m_active;
148 unsigned int m_nX = 0, m_nY = 0, m_nZ = 0;
149 double m_xMin = 0., m_yMin = 0., m_zMin = 0.;
150 double m_xMax = 0., m_yMax = 0., m_zMax = 0.;
151 double m_dx = 0., m_dy = 0., m_dz = 0.;
153 bool m_hasMesh =
false;
154 bool m_hasPotential =
false;
155 bool m_hasEfield =
false;
156 bool m_hasBfield =
false;
157 bool m_hasWfield =
false;
160 double m_wField_xOffset = 0.;
161 double m_wField_yOffset = 0.;
162 double m_wField_zOffset = 0.;
165 double m_pMin = 0., m_pMax = 0.;
168 bool LoadMesh(
const std::string& filename, std::string format,
169 const double scaleX);
171 bool LoadData(
const std::string& filename, std::string format,
172 const bool withPotential,
const bool withFlag,
173 const double scaleX,
const double scaleF,
const double scaleP,
174 std::vector<std::vector<std::vector<Node> > >& field);
176 void Reset()
override;
177 void UpdatePeriodicity()
override;
180 bool GetField(
const double x,
const double y,
const double z,
181 const std::vector<std::vector<std::vector<Node> > >& field,
182 double& fx,
double& fy,
double& fz,
double& p,
bool& active);
184 double Reduce(
const double xin,
const double xmin,
const double xmax,
185 const bool simplePeriodic,
const bool mirrorPeriodic,
186 bool& isMirrored)
const;
188 void Initialise(std::vector<std::vector<std::vector<Node> > >& fields);
Abstract base class for components.
Component for interpolating field maps on a regular mesh.
~ComponentGrid()
Destructor.
bool 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)
bool SaveElectricField(ComponentBase *cmp, const std::string &filename, const std::string &format)
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the bounding box coordinates.
ComponentGrid()
Constructor.
bool LoadElectricField(const std::string &filename, const std::string &format, const bool withPotential, const bool withFlag, const double scaleX=1., const double scaleE=1., const double scaleP=1.)
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 GetMesh(unsigned int &nx, unsigned int &ny, unsigned int &nz, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax) const
Retrieve the parameters of the grid.
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
bool GetVoltageRange(double &vmin, double &vmax) override
Calculate the voltage range [V].
bool SaveWeightingField(ComponentBase *cmp, const std::string &id, const std::string &filename, const std::string &format)
void SetMedium(Medium *m)
Set the medium.
Medium * GetMedium() const
Get the medium.
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.
bool GetElectricField(const unsigned int i, const unsigned int j, const unsigned int k, double &v, double &ex, double &ey, double &ez) const
Return the field at a given node.
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.
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 Clear() override
Reset.
bool GetElectricFieldRange(double &exmin, double &exmax, double &eymin, double &eymax, double &ezmin, double &ezmax)
void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status) override
void SetWeightingFieldOffset(const double x, const double y, const double z)
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
Abstract base class for media.