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

175 lines
7.4 KiB
C++
Executable File

#ifndef COORDINATES_H
#define COORDINATES_H
#include "blitz/array.h"
// Note: seems to be deprecated
// structure to store a coordinate wrt the binning of the simulation domain
struct BinCoordinate {
// Constructor using a blitz::TinyVector<int,3> containing the values defining a bin
// and the position frac within that bin
BinCoordinate(const blitz::TinyVector<int, 3>& bin,
const blitz::TinyVector<double, 3>& frac);
// Constructor using a blitz::TinyVector<double,3> containing the position and the spacing
// to calculate the bin and frac values
BinCoordinate(blitz::TinyVector<double, 3> position,
blitz::TinyVector<double, 3> spacing);
blitz::TinyVector<int, 3> bin;
blitz::TinyVector<double, 3> frac;
// return the blitz::TinyVector<int, 3> containing the bin of the variable
// position using the specified "spacing"
static blitz::TinyVector<int, 3> binValue(
blitz::TinyVector<double, 3> position,
blitz::TinyVector<double, 3> spacing);
// return the blitz::TinyVector<int, 3> containing the fractional value within a bin
// of the variable position using the specified "spacing"
static blitz::TinyVector<double, 3> binFrac(
blitz::TinyVector<double, 3> position,
blitz::TinyVector<double, 3> spacing);
};
// parent class for different Coordinate types (cartesian, cylinder)
// cannot be instantiated
class Coordinate {
public:
// return the value of the stored coordinate transformed to Cartesian space
virtual blitz::TinyVector<double, 3> cartesianEntries() const = 0;
// return the value of the stored coordinate transformed to Cylinder space
virtual blitz::TinyVector<double, 3> cylinderEntries() const = 0;
// add the values of the parameter coordinate to the value stored in this variable
virtual void add(const Coordinate& coordinate) = 0;
};
// class for storing and handling of coordinates in cartesian space
class CartesianCoordinate : public Coordinate {
public:
// Constructor using a blitz::TinyVector that holds the values of a cartesian coordinate (x,y,z)
CartesianCoordinate(const blitz::TinyVector<double, 3>& cartesian_position);
// Constructor using an arbitrary Coordinate object
CartesianCoordinate(const Coordinate& coordinate);
// return the value of the stored coordinate transformed to Cartesian space
blitz::TinyVector<double, 3> cartesianEntries() const;
// return the value of the stored coordinate transformed to Cylider space
blitz::TinyVector<double, 3> cylinderEntries() const;
// add the values of the parameter coordinate to the value stored in this variable
void add(const Coordinate& coordinate);
private:
blitz::TinyVector<double, 3> cartesian_position;
};
class CylinderCoordinate : public Coordinate {
public:
// Constructor using a blitz::TinyVector that holds the values of a cylinder coordinate (r,phi,z)
CylinderCoordinate(const blitz::TinyVector<double, 3>& cylinder_position);
// Constructor using an arbitrary Coordinate object
CylinderCoordinate(const Coordinate& coordinate);
// return the value of the stored coordinate transformed to Cartesian space
blitz::TinyVector<double, 3> cartesianEntries() const;
// return the value of the stored coordinate transformed to Cylinder space
blitz::TinyVector<double, 3> cylinderEntries() const;
// add the values of the parameter coordinate to the value stored in this variable
void add(const Coordinate& coordinate);
private:
// transform phi to be in the interval [0, 2pi]
void limitPhi();
blitz::TinyVector<double, 3> cylinder_position;
};
// parent class for different types of vectors (cartesian vector, cylinder vector)
class Vector {
public:
// return the stored value as a cartesian vector, the transformation depends on
// the Coordinate, where the Vector is defined
virtual blitz::TinyVector<double, 3> cartesianEntries(
const Coordinate& coordinate) const = 0;
// return the stored value as a cylinder vector, the transformation depends on
// the Coordinate, where the Vector is defined
virtual blitz::TinyVector<double, 3> cylinderEntries(
const Coordinate& coordinate) const = 0;
// Add the Vector vector to the value stored in this object; for the addition both
// Vectors have to be in the same space (i.e. Cartesian or Cylinder) therefore
// the Coordinate is necessary for potential transformations
virtual void add(const Vector& vector, const Coordinate& coordinate) = 0;
};
// class for storing and handling of Cylinder Vectors (v_r, v_phi, v_z)
class CylinderVector : public Vector {
public:
// copy constructor
CylinderVector(const CylinderVector& vector);
// constructor using a blitz::TinyVector containing the cylinder vector components
// of a vector
CylinderVector(const blitz::TinyVector<double, 3> cylinder_vector);
// constructor using an arbitrary vector, needs the Coordinate of the vector
// to transform into cylinder space
CylinderVector(const Vector& vector, const Coordinate& coordinate);
// overwrite the "+"-Operator for the addtion of two CylinderVector objects
CylinderVector operator+(const CylinderVector& coordinate);
// return the stored value as a cartesian vector, the transformation depends on
// the Coordinate, where the CylinderVector is defined
blitz::TinyVector<double, 3> cartesianEntries(
const Coordinate& coordinate) const;
// return the stored values as a cylinder vector; overwrite of the pure virtual
// function in the Vector class
blitz::TinyVector<double, 3> cylinderEntries(
const Coordinate& coordinate) const;
// returns the entries of the CylinderVector without the need for the Coordinate
blitz::TinyVector<double, 3> cylinderEntries() const;
// Add the Vector vector to the value stored in this object; for the addition both
// Vectors have to be in the same space (i.e. Cartesian or Cylinder) therefore
// the Coordinate is necessary for potential transformations
void add(const Vector& vector, const Coordinate& coordinate);
private:
blitz::TinyVector<double, 3> cylinder_vector;
};
// class for storing and handling of Cylinder Vectors (v_x, v_y, v_z)
class CartesianVector : public Vector {
public:
// constructor using a blitz::TinyVector containing the cartesian vector components
// of a vector
CartesianVector(const blitz::TinyVector<double, 3> cartesian_vector);
// copy constructor
CartesianVector(const CartesianVector& vector);
// constructor using an arbitrary vector, needs the Coordinate of the vector
// to transform into cartesian space
CartesianVector(const Vector& vector, const Coordinate& coordinate);
// return the stored values as a cartesian vector; overwrite of the pure virtual
// function in the Vector class
blitz::TinyVector<double, 3> cartesianEntries(
const Coordinate& coordinate) const;
// returns the entries of the CartesianVector without the need for the Coordinate
blitz::TinyVector<double, 3> cartesianEntries() const;
// return the stored value as a cylinder vector, the transformation depends on
// the Coordinate, where the CartesianVector is defined
blitz::TinyVector<double, 3> cylinderEntries(
const Coordinate& coordinate) const;
// Add the Vector vector to the value stored in this object; for the addition both
// Vectors have to be in the same space (i.e. Cartesian or Cylinder) therefore
// the Coordinate is necessary for potential transformations
void add(const Vector& vector, const Coordinate& coordinate);
private:
blitz::TinyVector<double, 3> cartesian_vector;
};
#endif /* COORDINATES_H */