Files
karl/include/generators/species_generator.h

120 lines
3.3 KiB
C++
Executable File

#ifndef SPECIES_GENERATOR_H
#define SPECIES_GENERATOR_H
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "generators/interaction_generator.h"
#include "simulation/jansson_additionals.h"
#include "simulation/parameter.h"
#include "simulation/species.h"
class Timer;
namespace generator {
struct TrackedSpeciesBuilderInfo {
public:
std::shared_ptr<Mover> mover;
std::shared_ptr<Terminator> terminator;
std::shared_ptr<Reflector> reflector;
std::shared_ptr<DynamicDensityField> density_field;
std::shared_ptr<VelocityDistribution> velocity_distribution;
std::shared_ptr<DriftVelocity> drift_velocity;
std::shared_ptr<DynamicDensityField> last_sync_density_field;
double mass_kg;
double charge_C;
bool explicitly_stored;
species::ImplementedSpecies type;
std::string name;
json_path path_in_json;
};
struct BackgroundSpeciesBuilderInfo {
public:
BackgroundSpeciesBuilderInfo()
: density(nullptr),
velocity_distribution(nullptr),
drift_velocity(nullptr){};
std::shared_ptr<ConstantDensityField> density;
std::shared_ptr<VelocityDistribution> velocity_distribution;
std::shared_ptr<DriftVelocity> drift_velocity;
double mass_kg;
double charge_C;
species::ImplementedSpecies type;
std::string name;
json_path path_in_json;
};
class SpeciesAlias {
public:
static species::ImplementedSpecies alias(const std::string& name);
static std::string name(species::ImplementedSpecies specie);
static bool isAlias(const std::string& name);
private:
static std::map<std::string, species::ImplementedSpecies> specie_aliases;
};
class SpeciesCharges {
public:
static double charge(species::ImplementedSpecies species);
private:
static std::map<species::ImplementedSpecies, double> charge_;
};
class SpeciesBuilder {
public:
SpeciesBuilder(Parameter& parameter);
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
trackedSpecies();
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
backgroundSpecies();
std::shared_ptr<Timer> timer();
std::shared_ptr<Timer> lastSyncTimer();
private:
std::map<std::string, BackgroundSpeciesBuilderInfo> background_species_info;
std::map<std::string, TrackedSpeciesBuilderInfo> tracked_species_info;
std::shared_ptr<Timer> timer_;
std::shared_ptr<Timer> last_sync_timer_;
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
tracked_species;
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
background_species;
void initBackgroundSpecies(Parameter& parameter);
void initTrackedSpecies(Parameter& parameter);
void fillVelocityDistribution(Parameter& parameter);
void fillDriftVelocity(Parameter& parameter);
void fillMass();
void fillCharge();
void fillInteractions(Parameter& parameter);
void fillBackgroundSpecieType(Parameter& parameter);
void fillBackgroundDensity(Parameter& parameter);
void fillTrackedSpecieType(Parameter& parameter);
void fillCurrentCollector(Parameter& parameter);
void fillLoggers(Parameter& parameter);
void fillMover(Parameter& parameter);
void fillTerminator(Parameter& parameter);
void fillReflector(Parameter& parameter);
void fillTrackedDensity(Parameter& parameter);
void initTimer();
void buildSpecies();
};
}; // namespace generator
#endif /* SPECIES_GENERATOR_H */