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

140 lines
7.2 KiB
C++
Executable File

#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> 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<double, 3> negativeCrossingsInR() const;
// returns the blitz::Array containing the crossins into the bins in radial direction
blitz::Array<double, 3> positiveCrossingsInR() const;
// return a blitz::Array with the areas of the bin borders in radial direction
blitz::Array<double, 3> areaInR() const;
// return a blitz::Array with the particle current in radial direction (in m^-2s^-1)
blitz::Array<double, 3> currentInR() const;
// returns the blitz::Array containing the crossings out of the bins in azimuthal direction
blitz::Array<double, 3> negativeCrossingsInPhi() const;
// returns the blitz::Array containing the crossins into the bins in azimuthal direction
blitz::Array<double, 3> positiveCrossingsInPhi() const;
// return a blitz::Array with the areas of the bin borders in azimuthal direction
blitz::Array<double, 3> areaInPhi() const;
// return a blitz::Array with the particle current in azimuthal direction (in m^-2s^-1)
blitz::Array<double, 3> currentInPhi() const;
// returns the blitz::Array containing the crossings out of the bins in longitudinal direction
blitz::Array<double, 3> negativeCrossingsInZ() const;
// returns the blitz::Array containing the crossins into the bins in longitudinal direction
blitz::Array<double, 3> positiveCrossingsInZ() const;
// return a blitz::Array with the areas of the bin borders in longitudinal direction
blitz::Array<double, 3> areaInZ() const;
// return a blitz::Array with the particle current in longitudinal direction (in m^-2s^-1)
blitz::Array<double, 3> 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<int, 3>& bin_old,
const blitz::TinyVector<int, 3>& 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<int, 3>& bin_old,
const blitz::TinyVector<int, 3>& 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<int, 3>& bin_old,
const blitz::TinyVector<int, 3>& 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<double, 3> createAreaLongitudinal(
const CylinderBinning& position_binning);
// return an array for the counting of crossings across the bin borders in longitudinal direction
blitz::Array<double, 3> 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<double, 3> createAreaRadial(
const CylinderBinning& position_binning);
// return an array for the counting of crossings across the bin borders in radial direction
blitz::Array<double, 3> 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<double, 3> createAreaAzimuthal(
const CylinderBinning& position_binning);
// return an array for the counting of crossings across the bin borders in azimuthal direction
blitz::Array<double, 3> createCrossingsAzimuthal(
const CylinderBinning& position_binning);
// Arrays for the storage of boundary crossings
blitz::Array<double, 3> z_negative_crossings;
blitz::Array<double, 3> z_positive_crossings;
blitz::Array<double, 3> phi_negative_crossings;
blitz::Array<double, 3> phi_positive_crossings;
blitz::Array<double, 3> r_negative_crossings;
blitz::Array<double, 3> r_positive_crossings;
// Arrays with the size area of the boundary segments
blitz::Array<double, 3> collector_areas_r;
blitz::Array<double, 3> collector_areas_phi;
blitz::Array<double, 3> collector_areas_z;
CylinderBinning position_binning_;
std::shared_ptr<Timer> timer_;
};
#endif /* CURRENT_COLLECTOR_H */