Rename source classes

This commit is contained in:
Paul Romano 2020-10-23 13:45:28 -05:00
parent f2526ec439
commit 0bb39005bc
8 changed files with 46 additions and 41 deletions

View file

@ -6,13 +6,13 @@
#include "openmc/source.h"
#include "openmc/particle.h"
class Source : public openmc::SourceDistribution {
class RingSource : public openmc::Source {
public:
Source(double radius, double energy) : radius_(radius), energy_(energy) { }
RingSource(double radius, double energy) : radius_(radius), energy_(energy) { }
// Defines a function that can create a unique pointer to a new instance of this class
// by extracting the parameters from the provided string.
static std::unique_ptr<Source> from_string(std::string parameters)
static std::unique_ptr<RingSource> from_string(std::string parameters)
{
std::unordered_map<std::string, std::string> parameter_mapping;
@ -27,7 +27,7 @@ class Source : public openmc::SourceDistribution {
double radius = std::stod(parameter_mapping["radius"]);
double energy = std::stod(parameter_mapping["energy"]);
return std::make_unique<Source>(radius, energy);
return std::make_unique<RingSource>(radius, energy);
}
// Samples from an instance of this class.
@ -59,7 +59,7 @@ class Source : public openmc::SourceDistribution {
// A function to create a unique pointer to an instance of this class when generated
// via a plugin call using dlopen/dlsym.
// You must have external C linkage here otherwise dlopen will not find the file
extern "C" std::unique_ptr<Source> openmc_create_source(std::string parameters)
extern "C" std::unique_ptr<RingSource> openmc_create_source(std::string parameters)
{
return Source::from_string(parameters);
return RingSource::from_string(parameters);
}