1#ifndef OPALX_FIELDMAP2DMAGNETOSTATIC_HH
2#define OPALX_FIELDMAP2DMAGNETOSTATIC_HH
6#include <Kokkos_Core.hpp>
7#include <Kokkos_DualView.hpp>
54 double& xIni,
double& xFinal,
double& yIni,
double& yFinal,
double& zIni,
55 double& zFinal)
const override;
58 virtual void swap()
override;
61 virtual void getInfo(Inform* msg)
override;
108 template <
class ViewType>
111 const ViewType& Br,
double hr,
double hz,
double zbegin,
int num_gridpr,
113 const double RR = sqrt(R(0) * R(0) + R(1) * R(1));
115 const int indexr = (int)floor(RR / hr);
116 const double leverr = (RR / hr) - indexr;
118 const int indexz = (int)floor((R(2) - zbegin) / hz);
119 const double leverz = (R(2) - zbegin) / hz - indexz;
121 if ((indexz < 0) || (indexz + 2 > num_gridpz))
return;
123 if (indexr + 2 > num_gridpr)
return;
125 int index1 = indexz + indexr * num_gridpz;
126 int index2 = index1 + num_gridpz;
128 double BfieldR = (1.0 - leverz) * (1.0 - leverr) * Br(index1)
129 + leverz * (1.0 - leverr) * Br(index1 + 1)
130 + (1.0 - leverz) * leverr * Br(index2) + leverz * leverr * Br(index2 + 1);
132 double BfieldZ = (1.0 - leverz) * (1.0 - leverr) * Bz(index1)
133 + leverz * (1.0 - leverr) * Bz(index1 + 1)
134 + (1.0 - leverz) * leverr * Bz(index2) + leverz * leverr * Bz(index2 + 1);
137 B(0) += BfieldR * R(0) / RR;
138 B(1) += BfieldR * R(1) / RR;
149 void applyField(std::shared_ptr<ParticleContainer_t> pc,
double scale = 1.0)
override;
ippl::Vector< T, Dim > Vector_t
virtual void swap() override
Swap coordinates.
virtual bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const override
Get the field strength at a given point.
virtual double getFrequency() const override
Get the frequency.
virtual void getFieldDimensions(double &zBegin, double &zEnd) const override
Get the longitudinal dimensions of the field.
void applyField(std::shared_ptr< ParticleContainer_t > pc, double scale=1.0) override
Apply the FM to all the particles.
virtual void getInfo(Inform *msg) override
Print info about the field map.
void freeMap() override
Pure virtual method to free the map data.
void readMap() override
Pure virtual method to read the map data. Called by the public static readMap().
Kokkos::DualView< double * > FieldstrengthBz_m
Fieldstrengths.
static KOKKOS_INLINE_FUNCTION void computeField(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &B, const ViewType &Bz, const ViewType &Br, double hr, double hz, double zbegin, int num_gridpr, int num_gridpz)
Computes the magnetic field B at the position R by interpolating from the fieldmap specified by Bz,...
virtual bool getFieldDerivative(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, const DiffDirection &dir) const override
Get the field derivative with respect to a direction.
virtual void setFrequency(double freq) override
Set the frequency.
bool isInside(const Vector_t< double, 3 > &r) const override
Checks if the given coordinate is inside the volume covered by the fieldmap.
double zbegin_m
Z Bounds relative to element edge.
double rbegin_m
Radius Bounds.
Kokkos::DualView< double * > FieldstrengthBr_m
Abstract base class for all field maps. It acts as a factory for creating specific field map types ba...