Skip to content
Snippets Groups Projects
Commit 740ace1a authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

Add ATH_RESTRICT to addBiotSavart inputs, as they are tagged with it from the...

Add ATH_RESTRICT to addBiotSavart inputs, as they are tagged with it from the function calling it. Also check first if we are inside the r span of a cell BFieldCache::inside
parent 359a3dba
No related branches found
No related tags found
No related merge requests found
......@@ -57,8 +57,7 @@ BFieldCache::inside(double z, double r, double phi) const
if (phi < m_phimin) {
phi += 2.0 * M_PI;
}
return (phi >= m_phimin && phi <= m_phimax && z >= m_zmin && z <= m_zmax &&
r >= m_rmin && r <= m_rmax);
return (r <= m_rmax && r >= m_rmin && z <= m_zmax && z >= m_zmin &&
phi <= m_phimax && phi >= m_phimin);
}
......@@ -21,7 +21,10 @@ class BFieldCond
{
public:
// constructor
BFieldCond(bool finite, const double* p1, const double* p2, double curr)
BFieldCond(bool finite,
const double* p1,
const double* p2,
double curr)
: m_finite(finite)
, m_p1(Eigen::Map<const Eigen::Vector3d>(p1))
, m_p2(Eigen::Map<const Eigen::Vector3d>(p2))
......@@ -32,9 +35,9 @@ public:
// compute magnetic field, plus derivatives if requested, and add
void addBiotSavart(double scaleFactor,
const double* xyz,
double* B,
double* deriv = nullptr) const;
const double* ATH_RESTRICT xyz,
double* ATH_RESTRICT B,
double* ATH_RESTRICT deriv = nullptr) const;
// scale the current wrt the nominal current
void scaleCurrent(double factor) { m_curr = factor * m_nomCurr; }
// accessors
......
......@@ -10,9 +10,9 @@
*/
inline void
BFieldCond::addBiotSavart(double scaleFactor,
const double* xyz,
double* B_in,
double* deriv) const
const double* ATH_RESTRICT xyz,
double* ATH_RESTRICT B_in,
double* ATH_RESTRICT deriv) const
{
static const double mu04pi = 1.0e-7; // mu_0/4pi
static const double minvsq = 10. * 10.; // (1 cm)^2
......
......@@ -18,6 +18,7 @@
#include "MagFieldElements/BFieldCache.h"
#include "MagFieldElements/BFieldVector.h"
#include "CxxUtils/restrict.h"
#include <array>
#include <cmath>
#include <vector>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment