Files
karl/include/simulation/vector_field.h
T
2024-12-04 17:15:04 +01:00

72 lines
2.7 KiB
C++
Executable File

#ifndef VECTOR_FIELD_H
#define VECTOR_FIELD_H
#include <functional>
#include "blitz/array.h"
#include "simulation/coordinates.h"
#include "simulation/position_binning.h"
// class for vector fields
class VectorField {
public:
// return the value of the vector field at the Coordinate coordinate as a
// CylinderVector object
virtual CylinderVector value(const Coordinate& coordinate) const = 0;
};
// class for vector fields that are defined by an array (e.g. from data that was used as input)
class VectorFieldFromArray : public VectorField {
public:
// Constructor: takes the radial, azimuthal and longitudinal component of the vector field
// as 3d arrays; all three arrays have to have the same size (not checked)
// also takes the radius and length of the domain, where the vector field is defined
VectorFieldFromArray(const blitz::Array<double, 3>& radial_component,
const blitz::Array<double, 3>& azimuthal_component,
const blitz::Array<double, 3>& longitudial_component,
double radius,
double length);
// return the value at the Coordinate coordinate, if the coordinate does not fall into
// the region where the vector field is defined in return (0,0,0)
CylinderVector value(const Coordinate& coordinate) const;
private:
const blitz::Array<double, 3> Fr_;
const blitz::Array<double, 3> Fphi_;
const blitz::Array<double, 3> Fz_;
// used to determine which array element is neccessary in the value() function
CylinderBinning binning_;
CylinderVector value(const blitz::TinyVector<int, 3>& bin) const;
};
// class for spatially constant vector fields
class VectorFieldConstant : public VectorField {
public:
// Constructor: takes the value of the constant cylinder vector for the vector field
VectorFieldConstant(const CylinderVector& constant);
// return the value of the vector field at the Coordinate coordinate as a CylinderVector
CylinderVector value(const Coordinate& coordinate) const;
private:
const CylinderVector constant_;
};
// class for a vector field that has a z-dependence that can be described by an
// analytic function and is 0 for the radial and azimuthal component
class VectorFieldFunctionInZ : public VectorField {
public:
// Constructor: takes a function that describes the value of the longitudinal
// component as a function of r,phi,z
VectorFieldFunctionInZ(std::function<double(double, double, double)> v_z);
// return the value of the vector field at the Coordinate coordinate as a CylinderVector
CylinderVector value(const Coordinate& coordinate) const;
private:
std::function<double(double, double, double)> F_z_;
};
#endif /* VECTOR_FIELD_H */