Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentFieldMap.hh
Go to the documentation of this file.
1#ifndef G_COMPONENT_FIELD_MAP_H
2#define G_COMPONENT_FIELD_MAP_H
3
4#include "ComponentBase.hh"
5#include "TMatrixD.h"
6
7namespace Garfield {
8
10
11 public:
12 // Constructor
14 // Destructor
15 virtual ~ComponentFieldMap() {}
16
17 // Ranges
18 // Calculates x, y, z, V and angular ranges
19 virtual void SetRange();
20 // Shows x, y, z, V and angular ranges
21 void PrintRange();
22 // Returns the current sensor size
23 virtual bool IsInBoundingBox(const double x, const double y, const double z);
24 virtual bool GetBoundingBox(double& xmin, double& ymin, double& zmin,
25 double& xmax, double& ymax, double& zmax);
26
27 bool GetVoltageRange(double& vmin, double& vmax) {
28 vmin = mapvmin;
29 vmax = mapvmax;
30 return true;
31 }
32
33 // Materials
34 // List all currently defined materials
35 void PrintMaterials();
36 // Make into a drift medium
37 void DriftMedium(int imat);
38 // Make into a non-drift medium
39 void NotDriftMedium(int imat);
40 // Number of materials
42 // Return permittivity
43 double GetPermittivity(const int imat);
44 // Return conductivity
45 double GetConductivity(const int imat);
46 // Associate a material with a Medium class
47 void SetMedium(const int imat, Medium* medium);
48 // Returns the medium for a material
49 Medium* GetMedium(const unsigned int& i) const;
50 Medium* GetMedium(const double& x, const double& y, const double& z) = 0;
51 int GetNumberOfMedia() { return nMaterials; }
52
53 int GetNumberOfElements() const { return nElements; }
54 bool GetElement(const int i, double& vol, double& dmin, double& dmax);
55
56 virtual void ElectricField(const double x, const double y, const double z,
57 double& ex, double& ey, double& ez, Medium*& m,
58 int& status) = 0;
59 virtual void ElectricField(const double x, const double y, const double z,
60 double& ex, double& ey, double& ez, double& v,
61 Medium*& m, int& status) = 0;
62
63 virtual void WeightingField(const double x, const double y, const double z,
64 double& wx, double& wy, double& wz,
65 const std::string label) = 0;
66
67 virtual double WeightingPotential(const double x, const double y,
68 const double z,
69 const std::string label) = 0;
70
71 // Options
74 lastElement = -1;
75 }
79
80 friend class ViewFEMesh;
81
82 protected:
83 bool is3d;
84
85 // Elements
87 struct element {
88 // Nodes
89 int emap[10];
90 // Material
91 int matmap;
93 // Bounding box of the element
94 double xmin, ymin, zmin, xmax, ymax, zmax;
95 };
96 std::vector<element> elements;
98 // Flag to check if bounding boxes of elements are cached
100
101 // Nodes
103 struct node {
104 // Coordinates
105 double x, y, z;
106 // Potential
107 double v;
108 // Weighting potentials
109 std::vector<double> w;
110 };
111 std::vector<node> nodes;
112
113 // Materials
115 struct material {
116 // Permittivity
117 double eps;
118 // Resistivity
119 double ohm;
121 // Associated medium
123 };
124 std::vector<material> materials;
125
127 std::vector<std::string> wfields;
128 std::vector<bool> wfieldsOk;
129
130 // Bounding box
134
135 // Ranges and periodicities
141
143 double mapsx, mapsy, mapsz;
144
147
148 // Options
149 // Delete meshing in conductors
151 // Scan for multiple elements that contain a point
153
154 // Warnings flag
156
157 // Reset the component
158 void Reset() {};
159
160 // Periodicities
161 virtual void UpdatePeriodicity() = 0;
162 void UpdatePeriodicity2d();
164
165 // Local coordinates
166 // Calculate coordinates for curved quadratic triangles
167 int Coordinates3(double x, double y, double z, double& t1, double& t2,
168 double& t3, double& t4, double jac[4][4], double& det,
169 int imap);
170 // Calculate coordinates for linear quadrilaterals
171 int Coordinates4(double x, double y, double z, double& t1, double& t2,
172 double& t3, double& t4, double jac[4][4], double& det,
173 int imap);
174 // Calculate coordinates for curved quadratic quadrilaterals
175 int Coordinates5(double x, double y, double z, double& t1, double& t2,
176 double& t3, double& t4, double jac[4][4], double& det,
177 int imap);
178 // Calculate coordinates in linear tetrahedra
179 int Coordinates12(double x, double y, double z, double& t1, double& t2,
180 double& t3, double& t4, int imap);
181 // Calculate coordinates for curved quadratic tetrahedra
182 int Coordinates13(double x, double y, double z, double& t1, double& t2,
183 double& t3, double& t4, double jac[4][4], double& det,
184 int imap);
185 // Calculate coordinates for a cube
186 int CoordinatesCube(double x, double y, double z, double& t1, double& t2,
187 double& t3, TMatrixD*& jac, std::vector<TMatrixD*>& dN,
188 int imap);
189
190 // Calculate Jacobian for curved quadratic triangles
191 void Jacobian3(int i, double u, double v, double w, double& det,
192 double jac[4][4]);
193 // Calculate Jacobian for curved quadratic quadrilaterals
194 void Jacobian5(int i, double u, double v, double& det, double jac[4][4]);
195 // Calculate Jacobian for curved quadratic tetrahedra
196 void Jacobian13(int i, double t, double u, double v, double w, double& det,
197 double jac[4][4]);
198 // Calculate Jacobian for a cube
199 void JacobianCube(int i, double t1, double t2, double t3, TMatrixD*& jac,
200 std::vector<TMatrixD*>& dN);
201
202 // Find the element for a point in curved quadratic quadrilaterals
203 int FindElement5(const double x, const double y, const double z, double& t1,
204 double& t2, double& t3, double& t4, double jac[4][4],
205 double& det);
206 // Find the element for a point in curved quadratic tetrahedra
207 int FindElement13(const double x, const double y, const double z, double& t1,
208 double& t2, double& t3, double& t4, double jac[4][4],
209 double& det);
210 // Find the element for a point in a cube
211 int FindElementCube(const double x, const double y, const double z,
212 double& t1, double& t2, double& t3, TMatrixD*& jac,
213 std::vector<TMatrixD*>& dN);
214
215 // Move (xpos, ypos, zpos) to field map coordinates
216 void MapCoordinates(double& xpos, double& ypos, double& zpos, bool& xmirrored,
217 bool& ymirrored, bool& zmirrored, double& rcoordinate,
218 double& rotation) const;
219 // Move (ex, ey, ez) to global coordinates
220 void UnmapFields(double& ex, double& ey, double& ez, double& xpos,
221 double& ypos, double& zpos, bool& xmirrored, bool& ymirrored,
222 bool& zmirrored, double& rcoordinate, double& rotation);
223
224 int ReadInteger(char* token, int def, bool& error);
225 double ReadDouble(char* token, double def, bool& error);
226
227 virtual double GetElementVolume(const int i) = 0;
228 virtual void GetAspectRatio(const int i, double& dmin, double& dmax) = 0;
229
230 // Calculate the bounding boxes of all elements after initialization
232};
233}
234
235#endif
double GetPermittivity(const int imat)
int Coordinates13(double x, double y, double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det, int imap)
int Coordinates5(double x, double y, double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det, int imap)
double ReadDouble(char *token, double def, bool &error)
void Jacobian5(int i, double u, double v, double &det, double jac[4][4])
virtual void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string label)=0
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
void MapCoordinates(double &xpos, double &ypos, double &zpos, bool &xmirrored, bool &ymirrored, bool &zmirrored, double &rcoordinate, double &rotation) const
virtual double WeightingPotential(const double x, const double y, const double z, const std::string label)=0
std::vector< material > materials
Medium * GetMedium(const unsigned int &i) const
int Coordinates12(double x, double y, double z, double &t1, double &t2, double &t3, double &t4, int imap)
void UnmapFields(double &ex, double &ey, double &ez, double &xpos, double &ypos, double &zpos, bool &xmirrored, bool &ymirrored, bool &zmirrored, double &rcoordinate, double &rotation)
int ReadInteger(char *token, int def, bool &error)
int FindElementCube(const double x, const double y, const double z, double &t1, double &t2, double &t3, TMatrixD *&jac, std::vector< TMatrixD * > &dN)
bool GetElement(const int i, double &vol, double &dmin, double &dmax)
Medium * GetMedium(const double &x, const double &y, const double &z)=0
void JacobianCube(int i, double t1, double t2, double t3, TMatrixD *&jac, std::vector< TMatrixD * > &dN)
int Coordinates4(double x, double y, double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det, int imap)
virtual double GetElementVolume(const int i)=0
std::vector< element > elements
virtual void UpdatePeriodicity()=0
int FindElement5(const double x, const double y, const double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det)
void Jacobian3(int i, double u, double v, double w, double &det, double jac[4][4])
int Coordinates3(double x, double y, double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det, int imap)
virtual bool IsInBoundingBox(const double x, const double y, const double z)
int FindElement13(const double x, const double y, const double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det)
virtual void GetAspectRatio(const int i, double &dmin, double &dmax)=0
virtual void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
bool GetVoltageRange(double &vmin, double &vmax)
void Jacobian13(int i, double t, double u, double v, double w, double &det, double jac[4][4])
void SetMedium(const int imat, Medium *medium)
virtual void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)=0
std::vector< std::string > wfields
int CoordinatesCube(double x, double y, double z, double &t1, double &t2, double &t3, TMatrixD *&jac, std::vector< TMatrixD * > &dN, int imap)
double GetConductivity(const int imat)