Commit bb5b31af authored by Heinrich Schindler's avatar Heinrich Schindler
Browse files

Add function HasMagneticField

parent a11bf017
......@@ -287,6 +287,9 @@ class Component {
/// Switch off debugging messages.
void DisableDebugging() { m_debug = false; }
/// Does the component have a non-zero magnetic field?
virtual bool HasMagneticField() const;
/// Does the component have maps of the Townsend coefficient?
virtual bool HasTownsendMap() const { return false; }
/// Does the component have attachment maps?
......
......@@ -46,6 +46,8 @@ class ComponentGrid : public Component {
bool GetElementaryCell(double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) override;
bool HasMagneticField() const override;
/** Define the grid.
* \param nx,ny,nz number of nodes along \f$x, y, z\f$.
* \param xmin,xmax range along \f$x\f$.
......
......@@ -39,6 +39,8 @@ class ComponentUser : public Component {
bool GetBoundingBox(double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) override;
bool HasMagneticField() const override;
/// Set the function to be called for calculating the electric field.
void SetElectricField(
std::function<void(const double, const double, const double,
......
......@@ -34,6 +34,8 @@ class ComponentVoxel : public Component {
void MagneticField(const double x, const double y, const double z, double& bx,
double& by, double& bz, int& status) override;
bool HasMagneticField() const override;
/// Interpolate between field values at the element centres.
void EnableInterpolation(const bool on = true) { m_interpolate = on; }
......
......@@ -3,6 +3,7 @@
#include "Garfield/Component.hh"
#include "Garfield/FundamentalConstants.hh"
#include "Garfield/GarfieldConstants.hh"
#include "Garfield/Numerics.hh"
namespace Garfield {
......@@ -132,6 +133,11 @@ bool Component::CrossedPlane(
return false;
}
bool Component::HasMagneticField() const {
return fabs(m_b0[0]) > Small || fabs(m_b0[1]) > Small ||
fabs(m_b0[2]) > Small;
}
double Component::IntegrateFluxCircle(const double xc, const double yc,
const double r, const unsigned int nI) {
// FLDIN2, FCHK3
......
......@@ -175,6 +175,10 @@ void ComponentGrid::MagneticField(const double x, const double y,
}
}
bool ComponentGrid::HasMagneticField() const {
return m_bfields.empty() ? Component::HasMagneticField() : true;
}
Medium* ComponentGrid::GetMedium(const double x, const double y,
const double z) {
// Make sure the field map has been loaded.
......
......@@ -70,8 +70,7 @@ void ComponentUser::MagneticField(const double x, const double y,
const double z, double& bx, double& by,
double& bz, int& status) {
if (!m_bfield) {
bx = by = bz = 0.;
status = -10;
Component::MagneticField(x, y, z, bx, by, bz, status);
return;
}
m_bfield(x, y, z, bx, by, bz);
......@@ -118,6 +117,10 @@ bool ComponentUser::GetBoundingBox(
return true;
}
bool ComponentUser::HasMagneticField() const {
return m_bfield ? true : Component::HasMagneticField();
}
void ComponentUser::SetElectricField(
std::function<void(const double, const double, const double,
double&, double&, double&)> f) {
......
......@@ -144,6 +144,10 @@ void ComponentVoxel::MagneticField(const double x, const double y,
}
}
bool ComponentVoxel::HasMagneticField() const {
return m_hasBfield ? true : Component::HasMagneticField();
}
Medium* ComponentVoxel::GetMedium(const double x, const double y,
const double z) {
// Make sure the field map has been loaded.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment