2019-08-07 08:02:38 +01:00
|
|
|
#include <iostream>
|
2020-08-21 12:05:43 +01:00
|
|
|
#include <memory>
|
|
|
|
|
|
2021-04-16 15:35:33 -04:00
|
|
|
#include "openmc/particle_data.h"
|
2019-08-07 08:02:38 +01:00
|
|
|
#include "openmc/random_lcg.h"
|
|
|
|
|
#include "openmc/source.h"
|
|
|
|
|
|
2023-06-20 21:27:55 -05:00
|
|
|
class CustomSource : public openmc::Source {
|
2021-04-29 16:23:54 -04:00
|
|
|
openmc::SourceSite sample(uint64_t* seed) const
|
2020-08-21 12:05:43 +01:00
|
|
|
{
|
2021-04-29 16:23:54 -04:00
|
|
|
openmc::SourceSite particle;
|
2019-08-07 08:02:38 +01:00
|
|
|
// wgt
|
2026-02-03 01:23:24 -06:00
|
|
|
particle.particle = openmc::ParticleType::neutron();
|
2019-08-07 08:02:38 +01:00
|
|
|
particle.wgt = 1.0;
|
|
|
|
|
// position
|
2020-10-22 15:05:43 -05:00
|
|
|
|
2019-08-07 08:02:38 +01:00
|
|
|
particle.r.x = 0.;
|
|
|
|
|
particle.r.y = 0.;
|
|
|
|
|
particle.r.z = 0.;
|
|
|
|
|
// angle
|
2020-02-18 09:22:09 +00:00
|
|
|
particle.u = {1.0, 0.0, 0.0};
|
2023-06-20 21:27:55 -05:00
|
|
|
particle.E = 1.00e3;
|
2019-08-07 08:02:38 +01:00
|
|
|
particle.delayed_group = 0;
|
2020-10-22 15:05:43 -05:00
|
|
|
return particle;
|
2020-08-21 12:05:43 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-06-20 21:27:55 -05:00
|
|
|
// 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<CustomSource> openmc_create_source(
|
|
|
|
|
std::string parameters)
|
2020-08-21 12:05:43 +01:00
|
|
|
{
|
2020-10-23 13:45:28 -05:00
|
|
|
return std::make_unique<CustomSource>();
|
2019-08-07 08:02:38 +01:00
|
|
|
}
|