OpenMC/tests/regression_tests/source_dlopen/source_sampling.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
918 B
C++
Raw Permalink Normal View History

2019-08-07 08:02:38 +01:00
#include <iostream>
#include <memory>
#include "openmc/particle_data.h"
2019-08-07 08:02:38 +01:00
#include "openmc/random_lcg.h"
#include "openmc/source.h"
class CustomSource : public openmc::Source {
2021-04-29 16:23:54 -04:00
openmc::SourceSite sample(uint64_t* seed) const
{
2021-04-29 16:23:54 -04:00
openmc::SourceSite particle;
2019-08-07 08:02:38 +01:00
// wgt
particle.particle = openmc::ParticleType::neutron();
2019-08-07 08:02:38 +01:00
particle.wgt = 1.0;
// position
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};
particle.E = 1.00e3;
2019-08-07 08:02:38 +01:00
particle.delayed_group = 0;
return particle;
}
};
// 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-10-23 13:45:28 -05:00
return std::make_unique<CustomSource>();
2019-08-07 08:02:38 +01:00
}