Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentVoxel.hh
Go to the documentation of this file.
1// Interpolation in a regular mesh
2
3#ifndef G_COMPONENT_VOXEL_H
4#define G_COMPONENT_VOXEL_H
5
6#ifndef __CINT__
7#include <map>
8#endif
9#include "ComponentBase.hh"
10
11namespace Garfield {
12
14
15 public:
16 // Constructor
18 // Destructor
20
21 void ElectricField(const double x, const double y, const double z, double& ex,
22 double& ey, double& ez, double& v, Medium*& m,
23 int& status);
24 void ElectricField(const double x, const double y, const double z, double& ex,
25 double& ey, double& ez, Medium*& m, int& status);
26
27 Medium* GetMedium(const double& x, const double& y, const double& z);
28
29 bool GetVoltageRange(double& vmin, double& vmax);
30 bool GetElectricFieldRange(double& exmin, double& exmax, double& eymin,
31 double& eymax, double& ezmin, double& ezmax);
32 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
33 double& ymax, double& zmax);
34 // Setup the grid.
35 void SetMesh(const unsigned int nx, const unsigned int ny,
36 const unsigned int nz, const double xmin, const double xmax,
37 const double ymin, const double ymax, const double zmin,
38 const double zmax);
39 // Import electric field and potential values from a file.
40 // The file is supposed to contain one line for each mesh point starting with
41 // - either two or three floating point numbers,
42 // specifying the coordinates (in cm) of the element centre or
43 // - two or three integers specifying the index of the element in the mesh,
44 // followed by
45 // - two or three floating point numbers for the electric field (in V/cm),
46 // and (depending on the values of withPotential and withRegion),
47 // - a floating point number specifying the potential (in V), and
48 // - an integer specifying the "region" of the element.
49 // Format types are:
50 // "xy", "xyz": elements are specified by the coordinates of their centres
51 // "ij", "ijk": elements are specified by their indices
52 bool LoadData(const std::string filename, std::string format,
53 const bool withPotential, const bool withRegion,
54 const double scaleX = 1., const double scaleE = 1.,
55 const double scaleP = 1.);
56
57 bool GetElement(const double xi, const double yi, const double zi,
58 unsigned int& i, unsigned int& j, unsigned int& k,
59 bool& xMirrored, bool& yMirrored, bool& zMirrored);
60 bool GetElement(const unsigned int i, const unsigned int j,
61 const unsigned int k, double& v, double& ex, double& ey,
62 double& ez);
63
64 void SetMedium(const int i, Medium* m);
65 Medium* GetMedium(const unsigned int& i);
66 void PrintRegions();
67
68 private:
69#ifndef __CINT__
70 std::map<int, Medium*> m_media;
71#endif
72 struct element {
73 // Electric field
74 double ex, ey, ez;
75 // Potential
76 double v;
77 // Index of region
78 int region;
79 };
80 std::vector<std::vector<std::vector<element> > > m_mesh;
81 // Dimensions of the mesh
82 unsigned int m_nX, m_nY, m_nZ;
83 double m_xMin, m_yMin, m_zMin;
84 double m_xMax, m_yMax, m_zMax;
85
86 bool m_hasMesh;
87 bool m_hasPotential;
88 bool m_hasField;
89
90 // Voltage range
91 double m_pMin, m_pMax;
92
93 // Reset the component
94 void Reset();
95 // Periodicities
96 void UpdatePeriodicity();
97};
98}
99#endif
void SetMedium(const int i, Medium *m)
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Medium * GetMedium(const double &x, const double &y, const double &z)
bool GetElectricFieldRange(double &exmin, double &exmax, double &eymin, double &eymax, double &ezmin, double &ezmax)
bool GetVoltageRange(double &vmin, double &vmax)
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)
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)
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)
bool LoadData(const std::string filename, std::string format, const bool withPotential, const bool withRegion, const double scaleX=1., const double scaleE=1., const double scaleP=1.)