#ifndef CURRENT_COLLECTOR_H #define CURRENT_COLLECTOR_H #include "simulation/coordinates.h" #include "simulation/energy_binning.h" #include "simulation/particle.h" #include "simulation/position_binning.h" #include "simulation/timer.h" // class to store and calculate particle currents class CurrentCollector { public: // Constructor: takes a CylinderBinning object to create the crossing and area arrays // a shared_ptr of a timer object (object be shared between all // CurrentCollectors and DensityFields regardless of specie) CurrentCollector(const CylinderBinning& position_binning, std::shared_ptr timer); // from the pointer to the particle and the Coordinate of an old position (e.g. before movement) // crossings over bin boundaries are determined and stored void collect(particle::Particle* particle, const Coordinate& old_position); // returns the blitz::Array containing the crossings out of the bins in radial direction blitz::Array negativeCrossingsInR() const; // returns the blitz::Array containing the crossins into the bins in radial direction blitz::Array positiveCrossingsInR() const; // return a blitz::Array with the areas of the bin borders in radial direction blitz::Array areaInR() const; // return a blitz::Array with the particle current in radial direction (in m^-2s^-1) blitz::Array currentInR() const; // returns the blitz::Array containing the crossings out of the bins in azimuthal direction blitz::Array negativeCrossingsInPhi() const; // returns the blitz::Array containing the crossins into the bins in azimuthal direction blitz::Array positiveCrossingsInPhi() const; // return a blitz::Array with the areas of the bin borders in azimuthal direction blitz::Array areaInPhi() const; // return a blitz::Array with the particle current in azimuthal direction (in m^-2s^-1) blitz::Array currentInPhi() const; // returns the blitz::Array containing the crossings out of the bins in longitudinal direction blitz::Array negativeCrossingsInZ() const; // returns the blitz::Array containing the crossins into the bins in longitudinal direction blitz::Array positiveCrossingsInZ() const; // return a blitz::Array with the areas of the bin borders in longitudinal direction blitz::Array areaInZ() const; // return a blitz::Array with the particle current in longitudinal direction (in m^-2s^-1) blitz::Array currentInZ() const; // return the time from the Timer object double physicalTime() const; // give the CpuSynchronizer class access to the private member variables to // make synchronization between processes simpler friend class CpuSynchronizer; private: // determine whether the particle moves out of or into a bin in radial direction from two TinyVectors containing // the indices of two bins of the CylinderBinning, the corresponding crossings member array // is then updated at the closest boundary position of the new bin; if multiple bins would // be crossed only the boundary described above will receive an update void collectRadialMovement(const blitz::TinyVector& bin_old, const blitz::TinyVector& bin_new); // determine whether the particle moves out of or into a bin in longitudinal direction from two TinyVectors containing // the indices of two bins of the CylinderBinning, the corresponding crossings member array // is then updated at the closest boundary position of the new bin; if multiple bins would // be crossed only the boundary described above will receive an update void collectLongitudinalMovement(const blitz::TinyVector& bin_old, const blitz::TinyVector& bin_new); // determine whether the particle moves out of or into a bin in azimuthal direction from two TinyVectors containing // the indices of two bins of the CylinderBinning, the corresponding crossings member array // is then updated at the closest boundary position of the new bin (periodic nature is accouted for); if multiple bins would // be crossed only the boundary described above will receive an update void collectAzimuthalMovement(const blitz::TinyVector& bin_old, const blitz::TinyVector& bin_new); /* schematics for the numbering of the bins and the corresponding borders longitudinal: underflow bin 0 bin 1 bin 2 ... bin N-1 overflow ---------|------------|------------|------------| ... |------------|-------- border_0 border_1 border_2 border_3 ... border_N-1 border_N radial: bin 0 bin 1 bin 2 ... bin N-1 overflow ----------|------------|------------| ... |------------|-------- border_0 border_1 border_2 ... border_N-2 border_N-1 azimuthal: bin N-1 bin 0 bin 1 bin 2 ... bin N-1 bin 0 ---------|------------|------------|------------| ... |------------|-------- border_0 border_1 border_2 border_3 ... border_N-1 border_0 */ // create the array containing the areas of the different boundary sections between bins in longitudinal direction // uses the provided CylinderBinning for the spacings of the bins blitz::Array createAreaLongitudinal( const CylinderBinning& position_binning); // return an array for the counting of crossings across the bin borders in longitudinal direction blitz::Array createCrossingsLongitudinal( const CylinderBinning& position_binning); // return an array containing the areas of the different boundary sections between bins in radial direction // uses the provided CylinderBinning for the spacings of the bins blitz::Array createAreaRadial( const CylinderBinning& position_binning); // return an array for the counting of crossings across the bin borders in radial direction blitz::Array createCrossingsRadial( const CylinderBinning& position_binning); // create the array containing the areas of the different boundary sections between bins in azimuthal direction // uses the provided CylinderBinning for the spacings of the bins blitz::Array createAreaAzimuthal( const CylinderBinning& position_binning); // return an array for the counting of crossings across the bin borders in azimuthal direction blitz::Array createCrossingsAzimuthal( const CylinderBinning& position_binning); // Arrays for the storage of boundary crossings blitz::Array z_negative_crossings; blitz::Array z_positive_crossings; blitz::Array phi_negative_crossings; blitz::Array phi_positive_crossings; blitz::Array r_negative_crossings; blitz::Array r_positive_crossings; // Arrays with the size area of the boundary segments blitz::Array collector_areas_r; blitz::Array collector_areas_phi; blitz::Array collector_areas_z; CylinderBinning position_binning_; std::shared_ptr timer_; }; #endif /* CURRENT_COLLECTOR_H */