Moved drawing from density to seperate classes
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "simulation/coordinates.h"
|
||||
#include "simulation/scalar_field.h"
|
||||
#include "simulation/density_field.h"
|
||||
|
||||
struct Limit {
|
||||
Limit() : min(0), max(0){};
|
||||
@@ -14,6 +15,9 @@ struct Limit {
|
||||
double max;
|
||||
};
|
||||
|
||||
// Might be possible to generalize the distributions (i.e. create parent class
|
||||
// and let the two that are defined now inherit from it)
|
||||
|
||||
class EventPositionDistribution {
|
||||
public:
|
||||
EventPositionDistribution(std::shared_ptr<ScalarField> mother_density,
|
||||
@@ -33,4 +37,31 @@ class EventPositionDistribution {
|
||||
std::uniform_real_distribution<double> density_values;
|
||||
};
|
||||
|
||||
// Class to draw a position from the density provided by a pointer
|
||||
// to a DynamicDensityField object
|
||||
class PositionDistributionFromDensity {
|
||||
public:
|
||||
// Constructor taking a pointer to a DynamicDensityField object
|
||||
PositionDistributionFromDensity(std::shared_ptr<DynamicDensityField> density);
|
||||
|
||||
// draw a position from the density provided at construction using the rejection method
|
||||
CylinderCoordinate drawPosition(std::mt19937* engine);
|
||||
// sets the maximum density value needed for the rejection method
|
||||
// should not be called frequently, since during each call the density field is
|
||||
// recalculated from scratch by the DynamicDensityField object
|
||||
void setMaximumDensity();
|
||||
|
||||
private:
|
||||
// variable storing the maximum value of the density
|
||||
double maximum_density_ = 1.;
|
||||
|
||||
std::shared_ptr<DynamicDensityField> density_;
|
||||
|
||||
// distributions for the spatial directions and for the density
|
||||
std::uniform_real_distribution<double> r_values;
|
||||
std::uniform_real_distribution<double> phi_values;
|
||||
std::uniform_real_distribution<double> z_values;
|
||||
std::uniform_real_distribution<double> density_values;
|
||||
};
|
||||
|
||||
#endif /* EVENT_POSITION_DISTRIBUTION_H */
|
||||
|
||||
Reference in New Issue
Block a user