mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Refactor fixed source sampling so call to custom library is made from call to sample_external_source()
This commit is contained in:
parent
6c188f2578
commit
ce135cc4a9
3 changed files with 10 additions and 15 deletions
|
|
@ -695,12 +695,7 @@ Particle::write_restart() const
|
|||
simulation::work_index[mpi::rank] + i;
|
||||
uint64_t seed = init_seed(id, STREAM_SOURCE);
|
||||
// re-sample source site
|
||||
Particle::Bank site;
|
||||
if (!settings::path_source_library.empty()) {
|
||||
site = sample_custom_source_library(&seed);
|
||||
} else {
|
||||
site = sample_external_source(&seed);
|
||||
}
|
||||
auto site = sample_external_source(&seed);
|
||||
write_dataset(file_id, "weight", site.wgt);
|
||||
write_dataset(file_id, "energy", site.E);
|
||||
write_dataset(file_id, "xyz", site.r);
|
||||
|
|
|
|||
|
|
@ -457,12 +457,7 @@ void initialize_history(Particle* p, int64_t index_source)
|
|||
simulation::work_index[mpi::rank] + index_source;
|
||||
uint64_t seed = init_seed(id, STREAM_SOURCE);
|
||||
// sample from external source distribution or custom library then set
|
||||
Particle::Bank site;
|
||||
if (!settings::path_source_library.empty()) {
|
||||
site = sample_custom_source_library(&seed);
|
||||
} else {
|
||||
site = sample_external_source(&seed);
|
||||
}
|
||||
auto site = sample_external_source(&seed);
|
||||
p->from_source(&site);
|
||||
} else if (settings::run_mode == RunMode::EIGENVALUE) {
|
||||
// set defaults for eigenvalue simulations from primary bank
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ std::vector<SourceDistribution> external_sources;
|
|||
|
||||
namespace {
|
||||
|
||||
typedef Particle::Bank (*sample_t)(uint64_t &seed);
|
||||
using sample_t = Particle::Bank (*)(uint64_t* seed);
|
||||
sample_t custom_source_function;
|
||||
void* custom_source_library;
|
||||
|
||||
|
|
@ -315,6 +315,11 @@ void initialize_source()
|
|||
|
||||
Particle::Bank sample_external_source(uint64_t* seed)
|
||||
{
|
||||
// return values from custom source if using
|
||||
if (!settings::path_source_library.empty()) {
|
||||
return sample_custom_source_library(seed);
|
||||
}
|
||||
|
||||
// Determine total source strength
|
||||
double total_strength = 0.0;
|
||||
for (auto& s : model::external_sources)
|
||||
|
|
@ -363,7 +368,7 @@ void load_custom_source_library()
|
|||
dlerror();
|
||||
|
||||
// get the function from the library
|
||||
//using sample_t = Particle::Bank (*)(uint64_t* seed);
|
||||
using sample_t = Particle::Bank (*)(uint64_t* seed);
|
||||
custom_source_function = reinterpret_cast<sample_t>(dlsym(custom_source_library, "sample_source"));
|
||||
|
||||
// check for any dlsym errors
|
||||
|
|
@ -386,7 +391,7 @@ void close_custom_source_library()
|
|||
|
||||
Particle::Bank sample_custom_source_library(uint64_t* seed)
|
||||
{
|
||||
return custom_source_function(*seed);
|
||||
return custom_source_function(seed);
|
||||
}
|
||||
|
||||
void fill_source_bank_custom_source()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue