Remove old source_sampling custom source method

Custom sources are now created only through the new class-based method,
which supports parameterization.
New method also slightly adjusted to create the source as managed by a
unique_ptr.
Examples and tests updated to align with this approach.
Documentation updated.
This commit is contained in:
Dan Short 2020-08-21 12:05:43 +01:00
parent 475656e6e0
commit 821e7d9825
10 changed files with 177 additions and 151 deletions

View file

@ -1,11 +1,14 @@
#include <iostream>
#include <memory>
#include "openmc/random_lcg.h"
#include "openmc/source.h"
#include "openmc/particle.h"
// you must have external C linkage here otherwise
// dlopen will not find the file
extern "C" openmc::Particle::Bank sample_source(uint64_t *seed) {
class Source : openmc::CustomSource
{
openmc::Particle::Bank sample_source(uint64_t *seed)
{
openmc::Particle::Bank particle;
// wgt
particle.particle = openmc::Particle::Type::neutron;
@ -20,4 +23,13 @@ extern "C" openmc::Particle::Bank sample_source(uint64_t *seed) {
particle.E = 14.08e6;
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<Source> openmc_create_source()
{
return std::unique_ptr<Source> (new Source());
}