1#ifndef G_COMPONENT_VOXEL_H
2#define G_COMPONENT_VOXEL_H
26 void SetMesh(
const unsigned int nx,
const unsigned int ny,
27 const unsigned int nz,
const double xmin,
const double xmax,
28 const double ymin,
const double ymax,
const double zmin,
47 const bool withPotential,
const bool withRegion,
48 const double scaleX = 1.,
const double scaleE = 1.,
49 const double scaleP = 1.);
52 const std::string& format,
const bool withPotential,
53 const double scaleX = 1.,
const double scaleE = 1.,
54 const double scaleP = 1.);
62 const std::string& format,
const double time,
63 const bool withPotential,
const double scaleX = 1.,
64 const double scaleE = 1.,
const double scaleP = 1.);
67 const double scaleX = 1.,
const double scaleB = 1.);
77 bool GetElement(
const double xi,
const double yi,
const double zi,
78 unsigned int& i,
unsigned int& j,
unsigned int& k,
79 bool& xMirrored,
bool& yMirrored,
bool& zMirrored)
const;
81 bool GetElement(
const unsigned int i,
const unsigned int j,
82 const unsigned int k,
double& v,
double& ex,
double& ey,
86 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
87 double& ey,
double& ez,
double& v, Medium*& m,
88 int& status)
override;
89 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
90 double& ey,
double& ez, Medium*& m,
int& status)
override;
91 using Component::ElectricField;
93 double& wx,
double& wy,
double& wz,
94 const std::string& label)
override;
96 const std::string& label)
override;
98 const double t,
double& wx,
double& wy,
double& wz,
99 const std::string& label)
override;
101 const double z,
const double t,
102 const std::string& label)
override;
103 void MagneticField(
const double x,
const double y,
const double z,
double& bx,
104 double& by,
double& bz,
int& status)
override;
107 Medium*
GetMedium(
const double x,
const double y,
const double z)
override;
111 double& eymax,
double& ezmin,
double& ezmax);
113 double& ymax,
double& zmax)
override;
115 double& ymax,
double& zmax)
override;
127 std::vector<std::vector<std::vector<Element> > >
m_efields;
129 std::vector<std::vector<std::vector<Element> > >
m_bfields;
131 std::vector<std::vector<std::vector<Element> > >
m_wfields;
133 std::vector<std::vector<std::vector<std::vector<Element> > > >
m_wdfields;
158 bool LoadData(
const std::string& filename, std::string format,
159 const bool withPotential,
const bool withRegion,
160 const double scaleX,
const double scaleF,
const double scaleP,
161 std::vector<std::vector<std::vector<Element> > >& field);
167 bool GetField(
const double x,
const double y,
const double z,
168 const std::vector<std::vector<std::vector<Element> > >& field,
169 double& fx,
double& fy,
double& fz,
double& p,
int& region);
171 double Reduce(
const double xin,
const double xmin,
const double xmax,
172 const bool simplePeriodic,
const bool mirrorPeriodic,
173 bool& isMirrored)
const;
175 void Initialise(std::vector<std::vector<std::vector<Element> > >& fields);
std::vector< std::vector< std::vector< int > > > m_regions
Region indices.
bool HasMagneticField() const override
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
std::vector< Medium * > m_media
~ComponentVoxel()
Destructor.
std::vector< std::vector< std::vector< Element > > > m_wfields
Prompt weighting field values and potentials at each mesh element.
bool GetField(const double x, const double y, const double z, const std::vector< std::vector< std::vector< Element > > > &field, double &fx, double &fy, double &fz, double &p, int ®ion)
Look up/interpolate the field at a given point.
void SetWeightingFieldOffset(const double x, const double y, const double z)
Offset coordinates in the weighting field, such that the same numerical weighting field map can be us...
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.
void Initialise(std::vector< std::vector< std::vector< Element > > > &fields)
Set the dimensions of a table according to the mesh.
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
bool GetElectricFieldRange(double &exmin, double &exmax, double &eymin, double &eymax, double &ezmin, double &ezmax)
void UpdatePeriodicity() override
std::vector< std::vector< std::vector< std::vector< Element > > > > m_wdfields
Delayed weighting field values and potentials at each mesh element.
Medium * GetMedium(const unsigned int i) const
Get the medium in region i.
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 LoadData(const std::string &filename, std::string format, const bool withPotential, const bool withRegion, const double scaleX, const double scaleF, const double scaleP, std::vector< std::vector< std::vector< Element > > > &field)
Read data from file.
bool GetVoltageRange(double &vmin, double &vmax) override
bool GetElementaryCell(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
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
std::vector< std::vector< std::vector< Element > > > m_efields
Electric field values and potentials at each mesh element.
Medium * GetMedium(const double x, const double y, const double z) override
bool GetElement(const unsigned int i, const unsigned int j, const unsigned int k, double &v, double &ex, double &ey, double &ez) const
Return the field for an element with given index.
double Reduce(const double xin, const double xmin, const double xmax, const bool simplePeriodic, const bool mirrorPeriodic, bool &isMirrored) const
Reduce a coordinate to the basic cell (in case of periodicity).
bool LoadWeightingField(const std::string &filename, const std::string &format, const double time, const bool withPotential, const double scaleX=1., const double scaleE=1., const double scaleP=1.)
Import delayed weighting field from file.
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
double DelayedWeightingPotential(const double x, const double y, const double z, const double t, const std::string &label) override
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status) override
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)
Define the grid.
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
std::vector< std::vector< std::vector< Element > > > m_bfields
Magnetic field values at each mesh element.
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.)
Import electric field and potential values from a file.
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.