Garfield 0.3
Toolkit for the detailed simulation of particle detectors based on ionization measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentComsol.hh
Go to the documentation of this file.
1#pragma once
2
4
5namespace Garfield {
6
8
10 public:
14 ComponentComsol(const std::string &mesh, const std::string &mplist,
15 const std::string &field, const std::string &unit = "m");
18
19 void SetImportRange(const double xmin, const double xmax, const double ymin,
20 const double ymax, const double zmin, const double zmax) {
21 // TODO: Must happen before initialise function
22 m_range.set = true;
23 m_range.xmin = xmin;
24 m_range.ymin = ymin;
25 m_range.zmin = zmin;
26
27 m_range.xmax = xmax;
28 m_range.ymax = ymax;
29 m_range.zmax = zmax;
30 }
31
38 bool Initialise(const std::string &header = "mesh.mphtxt",
39 const std::string &mplist = "dielectrics.dat",
40 const std::string &field = "field.txt",
41 const std::string &unit = "m");
42
44 bool SetWeightingPotential(const std::string &file, const std::string &label);
45 bool SetWeightingField(const std::string &file, const std::string &label) {
46 return SetWeightingPotential(file, label);
47 }
48
49 bool SetDynamicWeightingPotential(const std::string &file,
50 const std::string &label);
52 void SetTimeInterval(const double mint, const double maxt,
53 const double stept);
55 void GetTimeInterval(std::vector<double> &delayedTimes) {
56 delayedTimes = m_wdtimes;
57 }
58
61 void SetImportMaterial(const double epsr = 1.) {
62 m_materialSelect = true;
63 m_epsr = epsr;
64 }
65
66#ifdef USEGPU
68 double CreateGPUTransferObject(ComponentGPU *&comp_gpu) override;
69
70#endif
71 private:
72 double m_unit = 100.;
73 bool m_timeset = false;
74 static constexpr double MaxNodeDistance = 1.e-8;
75
76 bool m_materialSelect = false;
77 double m_epsr = 1.;
78
79 bool GetTimeInterval(const std::string &file);
80
81 struct Range {
82 bool set = false;
83
84 double xmin = 0;
85 double xmax = 0;
86
87 double ymin = 0;
88 double ymax = 0;
89
90 double zmin = 0;
91 double zmax = 0;
92 };
93
95
96 bool CheckInRange(const double x, const double y, const double z) const {
97 if (!m_range.set) return true;
98
99 if (x < m_range.xmin || x > m_range.xmax || y < m_range.ymin ||
100 y > m_range.ymax || z < m_range.zmin || z > m_range.zmax)
101 return false;
102
103 return true;
104 }
105
106 bool ElementInRange(const Element &element,
107 const std::vector<Node> &nodes) const {
108 if (m_range.set) {
109 for (size_t i = 0; i < 10; i++) {
110 const Node &node = nodes[element.emap[i]];
111 if (!CheckInRange(node.x, node.y, node.z)) return false;
112 }
113 }
114 if (m_materialSelect && m_materials[element.matmap].eps != m_epsr)
115 return false;
116 return true;
117 }
118 bool LoadPotentials(const std::string &field, std::vector<double> &pot);
119};
120} // namespace Garfield
bool SetWeightingPotential(const std::string &file, const std::string &label)
Import the weighting potential maps.
bool LoadPotentials(const std::string &field, std::vector< double > &pot)
void SetTimeInterval(const double mint, const double maxt, const double stept)
Set the time interval of the time-dependent weighting field.
bool Initialise(const std::string &header="mesh.mphtxt", const std::string &mplist="dielectrics.dat", const std::string &field="field.txt", const std::string &unit="m")
Import a field map.
bool SetDynamicWeightingPotential(const std::string &file, const std::string &label)
Import the time-dependent weighting field maps.
bool CheckInRange(const double x, const double y, const double z) const
bool SetWeightingField(const std::string &file, const std::string &label)
ComponentComsol()
Default constructor.
void GetTimeInterval(std::vector< double > &delayedTimes)
Get times of time-sliced dynamic weighting field.
void SetImportMaterial(const double epsr=1.)
Select material that will exclusivaly be imported based on its relative permitivity.
ComponentComsol(const std::string &mesh, const std::string &mplist, const std::string &field, const std::string &unit="m")
Constructor from file names.
bool ElementInRange(const Element &element, const std::vector< Node > &nodes) const
bool GetTimeInterval(const std::string &file)
static constexpr double MaxNodeDistance
void SetImportRange(const double xmin, const double xmax, const double ymin, const double ymax, const double zmin, const double zmax)
std::vector< Material > m_materials
ComponentFieldMap()=delete
Default constructor.
double CreateGPUTransferObject(ComponentGPU *&comp_gpu) override
Create and initialise GPU Transfer class.