#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 containing the values defining a bin // and the position frac within that bin BinCoordinate(const blitz::TinyVector& bin, const blitz::TinyVector& frac); // Constructor using a blitz::TinyVector containing the position and the spacing // to calculate the bin and frac values BinCoordinate(blitz::TinyVector position, blitz::TinyVector spacing); blitz::TinyVector bin; blitz::TinyVector frac; // return the blitz::TinyVector containing the bin of the variable // position using the specified "spacing" static blitz::TinyVector binValue( blitz::TinyVector position, blitz::TinyVector spacing); // return the blitz::TinyVector containing the fractional value within a bin // of the variable position using the specified "spacing" static blitz::TinyVector binFrac( blitz::TinyVector position, blitz::TinyVector 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 cartesianEntries() const = 0; // return the value of the stored coordinate transformed to Cylinder space virtual blitz::TinyVector 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& 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 cartesianEntries() const; // return the value of the stored coordinate transformed to Cylider space blitz::TinyVector cylinderEntries() const; // add the values of the parameter coordinate to the value stored in this variable void add(const Coordinate& coordinate); private: blitz::TinyVector 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& 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 cartesianEntries() const; // return the value of the stored coordinate transformed to Cylinder space blitz::TinyVector 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 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 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 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 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 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 cylinderEntries( const Coordinate& coordinate) const; // returns the entries of the CylinderVector without the need for the Coordinate blitz::TinyVector 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 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 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 cartesianEntries( const Coordinate& coordinate) const; // returns the entries of the CartesianVector without the need for the Coordinate blitz::TinyVector cartesianEntries() const; // return the stored value as a cylinder vector, the transformation depends on // the Coordinate, where the CartesianVector is defined blitz::TinyVector 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 cartesian_vector; }; #endif /* COORDINATES_H */