62 lines
2.3 KiB
C++
Executable File
62 lines
2.3 KiB
C++
Executable File
#include "simulation/vector_field.h"
|
|
|
|
#include "simulation/coordinates.h"
|
|
|
|
VectorFieldFromArray::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)
|
|
: Fr_(radial_component.copy()),
|
|
Fphi_(azimuthal_component.copy()),
|
|
Fz_(longitudial_component.copy()),
|
|
binning_(CylinderBinning(radial_component.extent(0),
|
|
radius,
|
|
radial_component.extent(1),
|
|
radial_component.extent(2),
|
|
length)) {}
|
|
|
|
CylinderVector VectorFieldFromArray::value(const Coordinate& coordinate) const {
|
|
const blitz::TinyVector<int, 3> bin =
|
|
binning_.bin(coordinate.cylinderEntries());
|
|
return value(bin);
|
|
}
|
|
|
|
CylinderVector VectorFieldFromArray::value(
|
|
const blitz::TinyVector<int, 3>& bin) const {
|
|
if (Fr_.isInRange(bin)) {
|
|
return CylinderVector(
|
|
blitz::TinyVector<double, 3>(Fr_(bin), Fphi_(bin), Fz_(bin)));
|
|
} else {
|
|
return CylinderVector(blitz::TinyVector<double, 3>(0., 0., 0.));
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
VectorFieldConstant::VectorFieldConstant(const CylinderVector& constant)
|
|
: constant_(constant) {}
|
|
|
|
CylinderVector VectorFieldConstant::value(const Coordinate& coordinate) const {
|
|
return constant_;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
VectorFieldFunctionInZ::VectorFieldFunctionInZ(
|
|
std::function<double(double, double, double)> F_z)
|
|
: F_z_(F_z) {}
|
|
|
|
CylinderVector VectorFieldFunctionInZ::value(
|
|
const Coordinate& coordinate) const {
|
|
const blitz::TinyVector<double, 3> cylinder_position =
|
|
coordinate.cylinderEntries();
|
|
return CylinderVector(blitz::TinyVector<double, 3>(
|
|
0., 0.,
|
|
F_z_(cylinder_position(0), cylinder_position(1), cylinder_position(2))));
|
|
} |