ATLAS Offline Software
Loading...
Searching...
No Matches
BFieldMesh.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
30//
31#ifndef BFIELDMESH_H
32#define BFIELDMESH_H
33
34#include "CxxUtils/restrict.h"
37#include <array>
38#include <cmath>
39#include <vector>
40
41template<class T>
43{
44public:
45 static_assert((std::is_same<T, short>::value ||
46 std::is_same<T, double>::value),
47 "Type for the BField Mesh must be one of short or double");
48 BFieldMesh() = default;
49 BFieldMesh(const BFieldMesh&) = default;
50 BFieldMesh(BFieldMesh&&) = default;
51 BFieldMesh& operator=(const BFieldMesh&) = default;
53 ~BFieldMesh() = default;
56 double zmax,
57 double rmin,
58 double rmax,
59 double phimin,
60 double phimax,
61 double bscale);
62
64 void setRange(double zmin,
65 double zmax,
66 double rmin,
67 double rmax,
68 double phimin,
69 double phimax);
70
72 void setBscale(double bscale);
74 void scaleBscale(double factor);
76 void reserve(int nz, int nr, int nphi, int nfield);
78 void reserve(int nz, int nr, int nphi);
80 void appendMesh(int axis, double value);
84 void buildLUT();
85 /* @brief test if a point is inside this mesh*/
86 bool inside(double z, double r, double phi) const;
87 /* @brief get the cache corresponding to a particular cell*/
88 void getCache(double z,
89 double r,
90 double phi,
91 BFieldCache& cache,
92 double scaleFactor = 1.0) const;
94 void getB(const double* ATH_RESTRICT xyz,
95 double* ATH_RESTRICT B,
96 double* ATH_RESTRICT deriv = nullptr) const;
98 double min(size_t axis) const;
100 double max(size_t axis) const;
102 double zmin() const;
104 double zmax() const;
106 double rmin() const;
108 double rmax() const;
110 double phimin() const;
112 double phimax() const;
114 unsigned nmesh(size_t axis) const;
117 double mesh(size_t axis, size_t index) const;
119 unsigned nfield() const;
121 const BFieldVector<T>& field(size_t index) const;
123 double bscale() const;
125 int memSize() const;
126
127protected:
128 std::array<double, 3> m_min{};
129 std::array<double, 3> m_max{};
130 std::array<std::vector<double>, 3> m_mesh{};
131
132private:
133 std::vector<BFieldVector<T>> m_field;
134 double m_scale{1.0};
135 double m_nomScale{1.0}; // nominal m_scale from the map
136
137 // look-up table and related variables
138 std::array<std::vector<int>, 3> m_LUT{};
139 std::array<double, 3> m_invUnit{}; // inverse unit size in the LUT
140 int m_roff{0};
141 int m_zoff{0};
142};
144#endif
Scalar phi() const
phi method
#define xyz
#define z
BFieldCache.h.
Definition BFieldCache.h:25
BFieldMesh & operator=(BFieldMesh &&)=default
void getB(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT B, double *ATH_RESTRICT deriv=nullptr) const
get the bfield given a point in xyz
void setBscale(double bscale)
set B scale
int memSize() const
memory size
unsigned nfield() const
field entries in mesh
double rmax() const
maximum in r
void appendField(const BFieldVector< T > &field)
append a filed vector
unsigned nmesh(size_t axis) const
number of cells along each axis = 0 (z), 1 (r), 2 (phi)
std::array< double, 3 > m_invUnit
Definition BFieldMesh.h:139
double m_nomScale
Definition BFieldMesh.h:135
void scaleBscale(double factor)
scale B scale by a factor
double min(size_t axis) const
minimum for a particular axis = 0 (z), 1 (r), 2 (phi)
BFieldMesh(BFieldMesh &&)=default
std::vector< BFieldVector< T > > m_field
Definition BFieldMesh.h:133
double m_scale
Definition BFieldMesh.h:134
std::array< double, 3 > m_max
Definition BFieldMesh.h:129
void buildLUT()
build Look Up Table
double zmax() const
maximum in z
const BFieldVector< T > & field(size_t index) const
field vector at cell corner at index
BFieldMesh & operator=(const BFieldMesh &)=default
std::array< double, 3 > m_min
Definition BFieldMesh.h:128
std::array< std::vector< int >, 3 > m_LUT
Definition BFieldMesh.h:138
void getCache(double z, double r, double phi, BFieldCache &cache, double scaleFactor=1.0) const
double phimax() const
maximum in phi
std::array< std::vector< double >, 3 > m_mesh
Definition BFieldMesh.h:130
BFieldMesh()=default
void reserve(int nz, int nr, int nphi)
allocate space to vectors
void appendMesh(int axis, double value)
add a position for a cell corner for an axis
double mesh(size_t axis, size_t index) const
coordinate along axis (0 (z), 1 (r), 2 (phi)) of the cell at index (0 to nmesh-1)
double zmin() const
minimum in z
bool inside(double z, double r, double phi) const
double rmin() const
minimun in r
double bscale() const
scale
double phimin() const
minimun in phi
void reserve(int nz, int nr, int nphi, int nfield)
allocate space to vectors
double max(size_t axis) const
maximum or a particular axis = 0 (z), 1 (r), 2 (phi)
~BFieldMesh()=default
BFieldMesh(double zmin, double zmax, double rmin, double rmax, double phimin, double phimax, double bscale)
constructor with mesh dimensions and scale
void setRange(double zmin, double zmax, double rmin, double rmax, double phimin, double phimax)
set mesh range/dimensions
BFieldMesh(const BFieldMesh &)=default
int r
Definition globals.cxx:22
Definition index.py:1
Macro wrapping the nonstandard restrict keyword.
#define ATH_RESTRICT
Definition restrict.h:31