Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::Solid Class Referenceabstract

Abstract base class for solids. More...

#include <Solid.hh>

+ Inheritance diagram for Garfield::Solid:

Public Types

enum  BoundaryCondition {
  Voltage = 1 , Charge , Float , Dielectric ,
  DielectricCharge , ParallelField , PerpendicularField
}
 

Public Member Functions

 Solid ()=delete
 Default constructor.
 
 Solid (const double cx, const double cy, const double cz, const std::string &name)
 Constructor.
 
virtual ~Solid ()
 Destructor.
 
virtual bool IsInside (const double x, const double y, const double z) const =0
 Check whether a given point is inside the solid.
 
virtual bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const =0
 Return the bounding box of the solid.
 
virtual bool IsBox () const
 Return true if the solid is a box.
 
virtual bool IsTube () const
 Return true if the solid is a tube.
 
virtual bool IsSphere () const
 Return true if the solid is a sphere.
 
virtual bool IsHole () const
 Return true if the solid is a hole.
 
virtual bool IsRidge () const
 Return true if the solid is a ridge.
 
bool GetCentre (double &x, double &y, double &z) const
 Retrieve the centre point of the solid.
 
bool GetOrientation (double &ctheta, double &stheta, double &cphi, double &sphi) const
 Retrieve the orientation (azimuthal and polar angles) of the solid.
 
virtual double GetHalfLengthX () const
 Return the half-length along x.
 
virtual double GetHalfLengthY () const
 Return the half-length along y.
 
virtual double GetHalfLengthZ () const
 Return the half-length along z.
 
virtual double GetInnerRadius () const
 Return the inner radius.
 
virtual double GetOuterRadius () const
 Return the outer radius.
 
virtual double GetRadius () const
 Return the radius.
 
virtual double GetLowerRadius () const
 Return the lower radius (of a hole).
 
virtual double GetUpperRadius () const
 Return the upper radius (of a hole).
 
virtual double GetRidgeOffset () const
 Return the x-offset of a ridge.
 
virtual double GetRidgeHeight () const
 Return the height of a ridge.
 
unsigned int GetId () const
 Get the ID of the solid.
 
virtual bool SolidPanels (std::vector< Panel > &panels)=0
 Retrieve the surface panels of the solid.
 
virtual double GetDiscretisationLevel (const Panel &panel)=0
 Retrieve the discretization level of a panel.
 
void SetBoundaryPotential (const double v)
 Apply Dirichlet boundary conditions (fixed voltage).
 
void SetBoundaryChargeDensity (const double q)
 Apply fixed-charge boundary conditions.
 
void SetBoundaryFloat ()
 Make the potential at the surface of the solid floating.
 
void SetBoundaryDielectric ()
 Make the surfaces of the solid dielectric-dielectric interfaces.
 
void SetBoundaryParallelField ()
 
void SetBoundaryPerpendicularField ()
 
BoundaryCondition GetBoundaryConditionType () const
 Retrieve the type of boundary condition.
 
double GetBoundaryPotential () const
 Retrieve the potential.
 
double GetBoundaryChargeDensity () const
 Retrieve the surface charge density.
 
void EnableDebugging (const bool on=true)
 Switch debugging messages on/off.
 

Protected Member Functions

void ToLocal (const double x, const double y, const double z, double &u, double &v, double &w) const
 
void ToGlobal (const double u, const double v, const double w, double &x, double &y, double &z) const
 
void VectorToLocal (const double x, const double y, const double z, double &u, double &v, double &w)
 Transform a vector from global to local coordinates.
 
void SetDirection (const double dx, const double dy, const double dz)
 

Protected Attributes

double m_cX = 0.
 Centre of the solid.
 
double m_cY = 0.
 
double m_cZ = 0.
 
double m_dX = 0.
 Direction vector.
 
double m_dY = 0.
 
double m_dZ = 1.
 
double m_cPhi = 1.
 Azimuthal angle.
 
double m_sPhi = 0.
 
double m_cTheta = 1.
 Polar angle.
 
double m_sTheta = 0.
 
std::string m_className = "Solid"
 Class name.
 
bool m_debug = false
 Debug flag.
 
BoundaryCondition m_bctype = Voltage
 Type of boundary condition.
 
double m_volt = 0.
 Potential at the surface.
 
double m_charge = 0.
 Surface charge density.
 
double m_eps = 0.
 Dielectric constant.
 

Detailed Description

Abstract base class for solids.

Definition at line 28 of file Solid.hh.

Member Enumeration Documentation

◆ BoundaryCondition

Enumerator
Voltage 
Charge 
Float 
Dielectric 
DielectricCharge 
ParallelField 
PerpendicularField 

Definition at line 125 of file Solid.hh.

125 {
126 Voltage = 1,
127 Charge,
128 Float,
133 };
@ DielectricCharge
Definition: Solid.hh:130
@ PerpendicularField
Definition: Solid.hh:132

Constructor & Destructor Documentation

◆ Solid() [1/2]

Garfield::Solid::Solid ( )
delete

Default constructor.

◆ Solid() [2/2]

Garfield::Solid::Solid ( const double  cx,
const double  cy,
const double  cz,
const std::string &  name 
)
inline

Constructor.

Definition at line 33 of file Solid.hh.

35 : m_cX(cx), m_cY(cy), m_cZ(cz), m_className(name) {
36 m_id = s_id++;
37 }
double m_cZ
Definition: Solid.hh:164
double m_cY
Definition: Solid.hh:164
double m_cX
Centre of the solid.
Definition: Solid.hh:164
std::string m_className
Class name.
Definition: Solid.hh:174

◆ ~Solid()

virtual Garfield::Solid::~Solid ( )
inlinevirtual

Destructor.

Definition at line 40 of file Solid.hh.

40{}

Member Function Documentation

◆ EnableDebugging()

void Garfield::Solid::EnableDebugging ( const bool  on = true)
inline

Switch debugging messages on/off.

Definition at line 160 of file Solid.hh.

160{ m_debug = on; }
bool m_debug
Debug flag.
Definition: Solid.hh:177

◆ GetBoundaryChargeDensity()

double Garfield::Solid::GetBoundaryChargeDensity ( ) const
inline

Retrieve the surface charge density.

Definition at line 157 of file Solid.hh.

157{ return m_charge; }
double m_charge
Surface charge density.
Definition: Solid.hh:184

◆ GetBoundaryConditionType()

BoundaryCondition Garfield::Solid::GetBoundaryConditionType ( ) const
inline

Retrieve the type of boundary condition.

Definition at line 153 of file Solid.hh.

153{ return m_bctype; }
BoundaryCondition m_bctype
Type of boundary condition.
Definition: Solid.hh:180

◆ GetBoundaryPotential()

double Garfield::Solid::GetBoundaryPotential ( ) const
inline

Retrieve the potential.

Definition at line 155 of file Solid.hh.

155{ return m_volt; }
double m_volt
Potential at the surface.
Definition: Solid.hh:182

◆ GetBoundingBox()

virtual bool Garfield::Solid::GetBoundingBox ( double &  xmin,
double &  ymin,
double &  zmin,
double &  xmax,
double &  ymax,
double &  zmax 
) const
pure virtual

◆ GetCentre()

bool Garfield::Solid::GetCentre ( double &  x,
double &  y,
double &  z 
) const
inline

Retrieve the centre point of the solid.

Definition at line 61 of file Solid.hh.

61 {
62 x = m_cX;
63 y = m_cY;
64 z = m_cZ;
65 return true;
66 }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetDiscretisationLevel()

virtual double Garfield::Solid::GetDiscretisationLevel ( const Panel panel)
pure virtual

Retrieve the discretization level of a panel.

Implemented in Garfield::SolidBox, Garfield::SolidHole, Garfield::SolidRidge, Garfield::SolidSphere, and Garfield::SolidTube.

◆ GetHalfLengthX()

virtual double Garfield::Solid::GetHalfLengthX ( ) const
inlinevirtual

Return the half-length along x.

Reimplemented in Garfield::SolidBox, Garfield::SolidHole, and Garfield::SolidRidge.

Definition at line 78 of file Solid.hh.

78 {
79 return NotImplemented("GetHalfLengthX");
80 }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetHalfLengthY()

virtual double Garfield::Solid::GetHalfLengthY ( ) const
inlinevirtual

Return the half-length along y.

Reimplemented in Garfield::SolidBox, Garfield::SolidHole, and Garfield::SolidRidge.

Definition at line 82 of file Solid.hh.

82 {
83 return NotImplemented("GetHalfLengthY");
84 }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetHalfLengthZ()

virtual double Garfield::Solid::GetHalfLengthZ ( ) const
inlinevirtual

Return the half-length along z.

Reimplemented in Garfield::SolidBox, Garfield::SolidHole, and Garfield::SolidTube.

Definition at line 86 of file Solid.hh.

86 {
87 return NotImplemented("GetHalfLengthZ");
88 }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetId()

unsigned int Garfield::Solid::GetId ( ) const
inline

◆ GetInnerRadius()

virtual double Garfield::Solid::GetInnerRadius ( ) const
inlinevirtual

Return the inner radius.

Reimplemented in Garfield::SolidTube.

Definition at line 90 of file Solid.hh.

90 {
91 return NotImplemented("GetInnerRadius");
92 }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetLowerRadius()

virtual double Garfield::Solid::GetLowerRadius ( ) const
inlinevirtual

Return the lower radius (of a hole).

Reimplemented in Garfield::SolidHole.

Definition at line 100 of file Solid.hh.

100 {
101 return NotImplemented("GetLowerRadius");
102 }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetOrientation()

bool Garfield::Solid::GetOrientation ( double &  ctheta,
double &  stheta,
double &  cphi,
double &  sphi 
) const
inline

Retrieve the orientation (azimuthal and polar angles) of the solid.

Definition at line 68 of file Solid.hh.

69 {
70 ctheta = m_cTheta;
71 stheta = m_sTheta;
72 cphi = m_cPhi;
73 sphi = m_sPhi;
74 return true;
75 }
double m_cTheta
Polar angle.
Definition: Solid.hh:171
double m_sPhi
Definition: Solid.hh:169
double m_sTheta
Definition: Solid.hh:171
double m_cPhi
Azimuthal angle.
Definition: Solid.hh:169

Referenced by Garfield::ViewGeometry::Plot().

◆ GetOuterRadius()

virtual double Garfield::Solid::GetOuterRadius ( ) const
inlinevirtual

Return the outer radius.

Reimplemented in Garfield::SolidTube.

Definition at line 94 of file Solid.hh.

94 {
95 return NotImplemented("GetOuterRadius");
96 }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetRadius()

virtual double Garfield::Solid::GetRadius ( ) const
inlinevirtual

Return the radius.

Reimplemented in Garfield::SolidSphere, and Garfield::SolidTube.

Definition at line 98 of file Solid.hh.

98{ return NotImplemented("GetRadius"); }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetRidgeHeight()

virtual double Garfield::Solid::GetRidgeHeight ( ) const
inlinevirtual

Return the height of a ridge.

Reimplemented in Garfield::SolidRidge.

Definition at line 112 of file Solid.hh.

112 {
113 return NotImplemented("GetRidgeHeight");
114 }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetRidgeOffset()

virtual double Garfield::Solid::GetRidgeOffset ( ) const
inlinevirtual

Return the x-offset of a ridge.

Reimplemented in Garfield::SolidRidge.

Definition at line 108 of file Solid.hh.

108 {
109 return NotImplemented("GetRidgeOffset");
110 }

Referenced by Garfield::ViewGeometry::Plot().

◆ GetUpperRadius()

virtual double Garfield::Solid::GetUpperRadius ( ) const
inlinevirtual

Return the upper radius (of a hole).

Reimplemented in Garfield::SolidHole.

Definition at line 104 of file Solid.hh.

104 {
105 return NotImplemented("GetUpperRadius");
106 }

Referenced by Garfield::ViewGeometry::Plot().

◆ IsBox()

virtual bool Garfield::Solid::IsBox ( ) const
inlinevirtual

Return true if the solid is a box.

Reimplemented in Garfield::SolidBox.

Definition at line 50 of file Solid.hh.

50{ return false; }

Referenced by Garfield::ViewGeometry::Plot().

◆ IsHole()

virtual bool Garfield::Solid::IsHole ( ) const
inlinevirtual

Return true if the solid is a hole.

Reimplemented in Garfield::SolidHole.

Definition at line 56 of file Solid.hh.

56{ return false; }

Referenced by Garfield::ViewGeometry::Plot().

◆ IsInside()

virtual bool Garfield::Solid::IsInside ( const double  x,
const double  y,
const double  z 
) const
pure virtual

Check whether a given point is inside the solid.

Implemented in Garfield::SolidBox, Garfield::SolidHole, Garfield::SolidRidge, Garfield::SolidSphere, and Garfield::SolidTube.

◆ IsRidge()

virtual bool Garfield::Solid::IsRidge ( ) const
inlinevirtual

Return true if the solid is a ridge.

Reimplemented in Garfield::SolidRidge.

Definition at line 58 of file Solid.hh.

58{ return false; }

Referenced by Garfield::ViewGeometry::Plot().

◆ IsSphere()

virtual bool Garfield::Solid::IsSphere ( ) const
inlinevirtual

Return true if the solid is a sphere.

Reimplemented in Garfield::SolidSphere.

Definition at line 54 of file Solid.hh.

54{ return false; }

Referenced by Garfield::ViewGeometry::Plot().

◆ IsTube()

virtual bool Garfield::Solid::IsTube ( ) const
inlinevirtual

Return true if the solid is a tube.

Reimplemented in Garfield::SolidTube.

Definition at line 52 of file Solid.hh.

52{ return false; }

Referenced by Garfield::ViewGeometry::Plot().

◆ SetBoundaryChargeDensity()

void Garfield::Solid::SetBoundaryChargeDensity ( const double  q)
inline

Apply fixed-charge boundary conditions.

Definition at line 141 of file Solid.hh.

141 {
142 m_charge = q;
144 }

◆ SetBoundaryDielectric()

void Garfield::Solid::SetBoundaryDielectric ( )
inline

Make the surfaces of the solid dielectric-dielectric interfaces.

Definition at line 148 of file Solid.hh.

148{ m_bctype = Dielectric; }

◆ SetBoundaryFloat()

void Garfield::Solid::SetBoundaryFloat ( )
inline

Make the potential at the surface of the solid floating.

Definition at line 146 of file Solid.hh.

146{ m_bctype = Float; }

◆ SetBoundaryParallelField()

void Garfield::Solid::SetBoundaryParallelField ( )
inline

Definition at line 149 of file Solid.hh.

◆ SetBoundaryPerpendicularField()

void Garfield::Solid::SetBoundaryPerpendicularField ( )
inline

Definition at line 150 of file Solid.hh.

◆ SetBoundaryPotential()

void Garfield::Solid::SetBoundaryPotential ( const double  v)
inline

Apply Dirichlet boundary conditions (fixed voltage).

Definition at line 136 of file Solid.hh.

136 {
137 m_volt = v;
139 }

◆ SetDirection()

void Garfield::Solid::SetDirection ( const double  dx,
const double  dy,
const double  dz 
)
protected

Definition at line 12 of file Solid.cc.

12 {
13 const double d = sqrt(dx * dx + dy * dy + dz * dz);
14 if (d < Small) {
15 std::cerr << m_className << ": Direction vector has zero norm.\n";
16 return;
17 }
18 m_dX = dx / d;
19 m_dY = dy / d;
20 m_dZ = dz / d;
21 double phi, theta;
22 const double dt = sqrt(m_dX * m_dX + m_dY * m_dY);
23 if (dt < Small) {
24 phi = 0.;
25 if (m_dZ > 0.) {
26 theta = 0.;
27 } else {
28 theta = Pi;
29 }
30 } else {
31 phi = atan2(m_dY, m_dX);
32 theta = atan2(dt, m_dZ);
33 }
34 m_cTheta = cos(theta);
35 m_sTheta = sin(theta);
36 m_cPhi = cos(phi);
37 m_sPhi = sin(phi);
38}
double m_dZ
Definition: Solid.hh:167
double m_dX
Direction vector.
Definition: Solid.hh:167
double m_dY
Definition: Solid.hh:167
DoubleAc cos(const DoubleAc &f)
Definition: DoubleAc.cpp:432
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:384
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

Referenced by Garfield::SolidBox::SolidBox(), Garfield::SolidHole::SolidHole(), Garfield::SolidRidge::SolidRidge(), and Garfield::SolidTube::SolidTube().

◆ SolidPanels()

virtual bool Garfield::Solid::SolidPanels ( std::vector< Panel > &  panels)
pure virtual

◆ ToGlobal()

void Garfield::Solid::ToGlobal ( const double  u,
const double  v,
const double  w,
double &  x,
double &  y,
double &  z 
) const
inlineprotected

Transform a point from local coordinates (u, v, w) to global coordinates (x, y, z).

Definition at line 202 of file Solid.hh.

203 {
204 x = m_cX + m_cPhi * m_cTheta * u - m_sPhi * v + m_cPhi * m_sTheta * w;
205 y = m_cY + m_sPhi * m_cTheta * u + m_cPhi * v + m_sPhi * m_sTheta * w;
206 z = m_cZ - m_sTheta * u + m_cTheta * w;
207 }

Referenced by Garfield::SolidBox::SolidPanels(), Garfield::SolidHole::SolidPanels(), Garfield::SolidRidge::SolidPanels(), and Garfield::SolidTube::SolidPanels().

◆ ToLocal()

void Garfield::Solid::ToLocal ( const double  x,
const double  y,
const double  z,
double &  u,
double &  v,
double &  w 
) const
inlineprotected

Transform a point from global coordinates (x, y, z) to local coordinates (u, v, w).

Definition at line 190 of file Solid.hh.

191 {
192 const double dx = x - m_cX;
193 const double dy = y - m_cY;
194 const double dz = z - m_cZ;
195
196 u = m_cPhi * m_cTheta * dx + m_sPhi * m_cTheta * dy - m_sTheta * dz;
197 v = -m_sPhi * dx + m_cPhi * dy;
198 w = m_cPhi * m_sTheta * dx + m_sPhi * m_sTheta * dy + m_cTheta * dz;
199 }

Referenced by Garfield::SolidHole::GetDiscretisationLevel(), Garfield::SolidBox::IsInside(), Garfield::SolidHole::IsInside(), Garfield::SolidRidge::IsInside(), and Garfield::SolidTube::IsInside().

◆ VectorToLocal()

void Garfield::Solid::VectorToLocal ( const double  x,
const double  y,
const double  z,
double &  u,
double &  v,
double &  w 
)
inlineprotected

Transform a vector from global to local coordinates.

Definition at line 209 of file Solid.hh.

210 {
211 u = m_cPhi * m_cTheta * x + m_sPhi * m_cTheta * y - m_sTheta * z;
212 v = -m_sPhi * x + m_cPhi * y;
213 w = m_cPhi * m_sTheta * x + m_sPhi * m_sTheta * y + m_cTheta * z;
214 }

Referenced by Garfield::SolidBox::GetDiscretisationLevel(), Garfield::SolidHole::GetDiscretisationLevel(), Garfield::SolidRidge::GetDiscretisationLevel(), and Garfield::SolidTube::GetDiscretisationLevel().

Member Data Documentation

◆ m_bctype

◆ m_charge

double Garfield::Solid::m_charge = 0.
protected

Surface charge density.

Definition at line 184 of file Solid.hh.

Referenced by GetBoundaryChargeDensity(), and SetBoundaryChargeDensity().

◆ m_className

std::string Garfield::Solid::m_className = "Solid"
protected

◆ m_cPhi

◆ m_cTheta

◆ m_cX

◆ m_cY

◆ m_cZ

◆ m_debug

◆ m_dX

double Garfield::Solid::m_dX = 0.
protected

◆ m_dY

double Garfield::Solid::m_dY = 0.
protected

◆ m_dZ

double Garfield::Solid::m_dZ = 1.
protected

◆ m_eps

double Garfield::Solid::m_eps = 0.
protected

Dielectric constant.

Definition at line 186 of file Solid.hh.

◆ m_sPhi

◆ m_sTheta

◆ m_volt

double Garfield::Solid::m_volt = 0.
protected

Potential at the surface.

Definition at line 182 of file Solid.hh.

Referenced by GetBoundaryPotential(), and SetBoundaryPotential().


The documentation for this class was generated from the following files: