Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentTcad3d.hh
Go to the documentation of this file.
1#ifndef G_COMPONENT_TCAD_3D_H
2#define G_COMPONENT_TCAD_3D_H
3
4#include <memory>
5
7#include "TetrahedralTree.hh"
8
9namespace Garfield {
10
11/// Interpolation in a three-dimensional field map created by Sentaurus Device.
12
14 public:
15 /// Constructor
17 /// Destructor
19
20 void ElectricField(const double x, const double y, const double z, double& ex,
21 double& ey, double& ez, double& v, Medium*& m,
22 int& status) override;
23 void ElectricField(const double x, const double y, const double z, double& ex,
24 double& ey, double& ez, Medium*& m, int& status) override;
25
26 Medium* GetMedium(const double x, const double y, const double z) override;
27
28 bool GetBoundingBox(double& xmin, double& ymin, double& zmin,
29 double& xmax, double& ymax, double& zmax) override;
30 bool GetElementaryCell(double& xmin, double& ymin, double& zmin,
31 double& xmax, double& ymax, double& zmax) override;
32
33 /** Retrieve the properties of an element.
34 * \param i index of the element
35 * \param vol volume
36 * \param dmin smallest length in the element
37 * \param dmax largest length in the element
38 * \param type element type
39 * \param nodes indices of the constituent vertices
40 * \param reg region
41 */
42 bool GetElement(const size_t i, double& vol, double& dmin, double& dmax,
43 int& type, std::vector<size_t>& nodes, int& reg) const;
44 /// Get the coordinates of a mesh node and the potential and
45 /// electric field at this node.
46 bool GetNode(const size_t i, double& x, double& y, double& z, double& v,
47 double& ex, double& ey, double& ez) const;
48
49 private:
50
51 // Tetrahedral tree.
52 std::unique_ptr<TetrahedralTree> m_tree;
53
54 void Reset() override {
55 Cleanup();
56 m_ready = false;
57 }
58
59 size_t FindElement(const double x, const double y, const double z,
60 std::array<double, nMaxVertices>& w) const;
61 bool InElement(const double x, const double y, const double z,
62 const Element& element,
63 std::array<double, nMaxVertices>& w) const {
64 if (x < element.bbMin[0] || x > element.bbMax[0] ||
65 y < element.bbMin[1] || y > element.bbMax[1] ||
66 z < element.bbMin[2] || z > element.bbMax[2]) {
67 return false;
68 }
69 bool inside = false;
70 switch (element.type) {
71 case 2:
72 if (InTriangle(x, y, z, element, w)) inside = true;
73 break;
74 case 5:
75 if (InTetrahedron(x, y, z, element, w)) inside = true;
76 break;
77 default:
78 std::cerr << m_className << "::InElement:\n"
79 << " Invalid element type (" << element.type << ").\n";
80 break;
81 }
82 return inside;
83 }
84 bool InTetrahedron(const double x, const double y, const double z,
85 const Element& element,
86 std::array<double, nMaxVertices>& w) const;
87 bool InTriangle(const double x, const double y, const double z,
88 const Element& element,
89 std::array<double, nMaxVertices>& w) const;
90
91 bool Interpolate(const double x, const double y, const double z,
92 const std::vector<double>& field, double& f) override;
93 bool Interpolate(const double x, const double y, const double z,
94 const std::vector<std::array<double, 3> >& field,
95 double& fx, double& fy, double& fz) override;
96 void FillTree() override;
97
98};
99}
100#endif
Interpolation in a three-dimensional field map created by Sentaurus Device.
bool GetElementaryCell(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the coordinates of the elementary cell.
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).
bool GetNode(const size_t i, double &x, double &y, double &z, double &v, double &ex, double &ey, double &ez) const
bool GetElement(const size_t i, double &vol, double &dmin, double &dmax, int &type, std::vector< size_t > &nodes, int &reg) const
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the bounding box coordinates.
Medium * GetMedium(const double x, const double y, const double z) override
Get the medium at a given location (x, y, z).
Interpolation in a field map created by Sentaurus Device.
std::string m_className
Class name.
Definition: Component.hh:329
bool m_ready
Ready for use?
Definition: Component.hh:338
Abstract base class for media.
Definition: Medium.hh:13
Definition: neBEM.h:155