1#ifndef G_COMPONENT_FIELD_MAP_H
2#define G_COMPONENT_FIELD_MAP_H
26 virtual bool IsInBoundingBox(
const double x,
const double y,
const double z)
const;
27 virtual bool GetBoundingBox(
double& xmin,
double& ymin,
double& zmin,
28 double& xmax,
double& ymax,
double& zmax);
59 bool GetElement(
const unsigned int i,
double& vol,
double& dmin,
62 virtual void ElectricField(
const double x,
const double y,
const double z,
63 double& ex,
double& ey,
double& ez,
Medium*& m,
65 virtual void ElectricField(
const double x,
const double y,
const double z,
66 double& ex,
double& ey,
double& ez,
double& v,
67 Medium*& m,
int& status) = 0;
70 double& wx,
double& wy,
double& wz,
71 const std::string& label) = 0;
75 const std::string& label) = 0;
79 m_checkMultipleElement =
true;
89 m_useTetrahedralTree = on;
118 std::vector<double>
w;
173 int FindElement5(
const double x,
const double y,
const double z,
double& t1,
174 double& t2,
double& t3,
double& t4,
double jac[4][4],
177 int FindElement13(
const double x,
const double y,
const double z,
double& t1,
178 double& t2,
double& t3,
double& t4,
double jac[4][4],
182 double& t1,
double& t2,
double& t3, TMatrixD*& jac,
183 std::vector<TMatrixD*>& dN);
186 void MapCoordinates(
double& xpos,
double& ypos,
double& zpos,
bool& xmirrored,
187 bool& ymirrored,
bool& zmirrored,
double& rcoordinate,
188 double& rotation)
const;
190 void UnmapFields(
double& ex,
double& ey,
double& ez,
double& xpos,
191 double& ypos,
double& zpos,
bool& xmirrored,
bool& ymirrored,
192 bool& zmirrored,
double& rcoordinate,
double& rotation)
const;
194 int ReadInteger(
char* token,
int def,
bool& error);
195 double ReadDouble(
char* token,
double def,
bool& error);
203 std::cerr <<
m_className <<
"::" << header <<
":\n"
204 <<
" Warnings have been issued for this field map.\n";
208 std::cerr <<
m_className <<
"::" << header <<
":\n"
209 <<
" Field map not yet initialised.\n";
211 void PrintElement(
const std::string& header,
const double x,
const double y,
212 const double z,
const double t1,
const double t2,
213 const double t3,
const double t4,
const unsigned int i,
214 const unsigned int n,
const int iw = -1)
const;
218 bool m_checkMultipleElement;
221 bool m_useTetrahedralTree;
222 bool m_isTreeInitialized;
226 bool m_cacheElemBoundingBoxes;
232 int Coordinates3(
double x,
double y,
double z,
double& t1,
double& t2,
233 double& t3,
double& t4,
double jac[4][4],
double& det,
234 const unsigned int imap)
const;
236 int Coordinates4(
const double x,
const double y,
const double z,
double& t1,
237 double& t2,
double& t3,
double& t4,
double jac[4][4],
238 double& det,
const unsigned int imap)
const;
240 int Coordinates5(
const double x,
const double y,
const double z,
double& t1,
241 double& t2,
double& t3,
double& t4,
double jac[4][4],
242 double& det,
const unsigned int imap)
const;
244 int Coordinates12(
const double x,
const double y,
const double z,
double& t1,
245 double& t2,
double& t3,
double& t4,
246 const unsigned int imap)
const;
248 int Coordinates13(
const double x,
const double y,
const double z,
double& t1,
249 double& t2,
double& t3,
double& t4,
double jac[4][4],
250 double& det,
const unsigned int imap)
const;
252 int CoordinatesCube(
const double x,
const double y,
const double z,
253 double& t1,
double& t2,
double& t3, TMatrixD*& jac,
254 std::vector<TMatrixD*>& dN,
255 const unsigned int imap)
const;
258 void Jacobian3(
const unsigned int i,
const double u,
const double v,
259 const double w,
double& det,
double jac[4][4])
const;
261 void Jacobian5(
const unsigned int i,
const double u,
const double v,
262 double& det,
double jac[4][4])
const;
264 void Jacobian13(
const unsigned int i,
const double t,
const double u,
265 const double v,
const double w,
double& det,
266 double jac[4][4])
const;
268 void JacobianCube(
const unsigned int i,
const double t1,
const double t2,
269 const double t3, TMatrixD*& jac,
270 std::vector<TMatrixD*>& dN)
const;
273 void CalculateElementBoundingBoxes();
276 bool InitializeTetrahedralTree();
Abstract base class for components.
std::string m_className
Class name.
Base class for components based on finite-element field maps.
Medium * GetMedium(const double x, const double y, const double z)=0
Get the medium at a given location (x, y, z).
void DriftMedium(const unsigned int imat)
Flag a field map material as a drift medium.
void PrintRange()
Show x, y, z, V and angular ranges.
virtual double GetElementVolume(const unsigned int i)=0
void SetMedium(const unsigned int imat, Medium *medium)
Associate a field map material with a Medium class.
void PrintMaterials()
List all currently defined materials.
void EnableCheckMapIndices()
int GetNumberOfElements() const
Return the number of mesh elements.
double ReadDouble(char *token, double def, bool &error)
void DisableDeleteBackgroundElements()
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)
Get the bounding box coordinates.
std::vector< bool > wfieldsOk
void MapCoordinates(double &xpos, double &ypos, double &zpos, bool &xmirrored, bool &ymirrored, bool &zmirrored, double &rcoordinate, double &rotation) const
Move (xpos, ypos, zpos) to field map coordinates.
void PrintWarning(const std::string &header)
virtual void GetAspectRatio(const unsigned int i, double &dmin, double &dmax)=0
void DisableCheckMapIndices()
void UpdatePeriodicityCommon()
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)
Find the element for a point in a cube.
unsigned int m_nMaterials
void PrintElement(const std::string &header, const double x, const double y, const double z, const double t1, const double t2, const double t3, const double t4, const unsigned int i, const unsigned int n, const int iw=-1) const
virtual ~ComponentFieldMap()
Destructor.
virtual void UpdatePeriodicity()=0
Verify periodicities.
unsigned int GetNumberOfMaterials() const
Return the number of materials in the field map.
double GetConductivity(const unsigned int imat) const
Return the conductivity of a field map material.
void EnableTetrahedralTreeForElementSearch(const bool on=true)
unsigned int GetNumberOfMedia() const
void Reset()
Geometry checks.
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)
Find the element for a point in curved quadratic quadrilaterals.
double GetPermittivity(const unsigned int imat) const
Return the permittivity of a field map material.
std::vector< Material > materials
void UpdatePeriodicity2d()
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)
Find the element for a point in curved quadratic tetrahedra.
void EnableDeleteBackgroundElements()
Medium * GetMedium(const unsigned int i) const
Return the Medium associated to a field map material.
void NotDriftMedium(const unsigned int imat)
Flag a field map materials as a non-drift medium.
std::vector< Node > nodes
virtual bool GetVoltageRange(double &vmin, double &vmax)
Calculate the voltage range [V].
virtual void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
virtual double WeightingPotential(const double x, const double y, const double z, const std::string &label)=0
bool GetElement(const unsigned int i, double &vol, double &dmin, double &dmax)
Return the volume and aspect ratio of a mesh element.
virtual void SetRange()
Calculate x, y, z, V and angular ranges.
std::vector< Element > elements
ComponentFieldMap()
Constructor.
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
virtual bool IsInBoundingBox(const double x, const double y, const double z) const
std::vector< std::string > wfields
void UnmapFields(double &ex, double &ey, double &ez, double &xpos, double &ypos, double &zpos, bool &xmirrored, bool &ymirrored, bool &zmirrored, double &rcoordinate, double &rotation) const
Move (ex, ey, ez) to global coordinates.
void PrintNotReady(const std::string &header) const
Abstract base class for media.
Helper class for searches in field maps.
Draw the mesh of a field-map component.