Skip to content

Commit

Permalink
needed to use the extern in source.h and redefine in the source.cpp i…
Browse files Browse the repository at this point in the history
…n openmc model namespace. ig it passes all the tests now
  • Loading branch information
magnoxemo committed Nov 22, 2024
1 parent 1643150 commit f0656bd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/openmc/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace model {

extern vector<unique_ptr<Source>> external_sources;
// DiscreteIndex class for the alias sampling
DiscreteIndex external_sources_alias_sampler;
extern DiscreteIndex external_sources_alias_sampler;

} // namespace model

Expand Down
2 changes: 1 addition & 1 deletion src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ void read_settings_xml(pugi::xml_node root)
for (auto& s : model::external_sources) {
source_strengths.push_back(s->strength());
}
external_source_alias_sampler.assign(source_strengths);
openmc::model::external_sources_alias_sampler.assign(source_strengths);

// If no source specified, default to isotropic point source at origin with
// Watt spectrum. No default source is needed in random ray mode.
Expand Down
5 changes: 4 additions & 1 deletion src/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ namespace model {

vector<unique_ptr<Source>> external_sources;

// DiscreteIndex class for the alias sampling
DiscreteIndex external_sources_alias_sampler;

}

//==============================================================================
Expand Down Expand Up @@ -612,7 +615,7 @@ SourceSite sample_external_source(uint64_t* seed)
// Sample from among multiple source distributions
int i = 0;
if (model::external_sources.size() > 1) {
i = external_source_alias_sampler.sample(seed);
i = model::external_sources_alias_sampler.sample(seed);
}

// Sample source site from i-th source distribution
Expand Down

0 comments on commit f0656bd

Please sign in to comment.