mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Reword src to source for consistency
This commit is contained in:
parent
6428bc9bc1
commit
e427dbde50
18 changed files with 123 additions and 122 deletions
|
|
@ -18,7 +18,7 @@ namespace simulation {
|
|||
|
||||
extern std::vector<Particle::Bank> source_bank;
|
||||
|
||||
extern SharedArray<Particle::Bank> surf_src_bank;
|
||||
extern SharedArray<Particle::Bank> surf_source_bank;
|
||||
|
||||
extern SharedArray<Particle::Bank> fission_bank;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ extern "C" bool run_CE; //!< run with continuous-energy data?
|
|||
extern bool source_latest; //!< write latest source at each batch?
|
||||
extern bool source_separate; //!< write source to separate file?
|
||||
extern bool source_write; //!< write source in HDF5 files?
|
||||
extern bool surf_src_write; //!< write surface source file?
|
||||
extern bool surf_src_read; //!< read surface source file?
|
||||
extern bool surf_source_write; //!< write surface source file?
|
||||
extern bool surf_source_read; //!< read surface source file?
|
||||
extern bool survival_biasing; //!< use survival biasing?
|
||||
extern bool temperature_multipole; //!< use multipole data?
|
||||
extern "C" bool trigger_on; //!< tally triggers enabled?
|
||||
|
|
@ -87,7 +87,7 @@ extern std::vector<std::string> res_scat_nuclides; //!< Nuclides using res. ups
|
|||
extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.)
|
||||
extern std::unordered_set<int> sourcepoint_batch; //!< Batches when source should be written
|
||||
extern std::unordered_set<int> statepoint_batch; //!< Batches when state should be written
|
||||
extern std::unordered_set<int> src_write_surf_id; //!< Surface ids where sources will be written
|
||||
extern std::unordered_set<int> source_write_surf_id; //!< Surface ids where sources will be written
|
||||
extern int64_t max_surf_banks; //!< maximum number of particles to be banked on surfaces per process
|
||||
extern TemperatureMethod temperature_method; //!< method for choosing temperatures
|
||||
extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ extern const RegularMesh* ufs_mesh;
|
|||
extern std::vector<double> k_generation;
|
||||
extern std::vector<int64_t> work_index;
|
||||
|
||||
extern std::vector<int64_t> surf_src_index;
|
||||
extern std::vector<int64_t> surf_source_index;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
namespace openmc {
|
||||
|
||||
void load_state_point();
|
||||
int query_surf_src_size();
|
||||
void write_source_point(const char* filename, bool surf_src_bank = false);
|
||||
void write_source_bank(hid_t group_id, bool surf_src_bank);
|
||||
int query_surf_source_size();
|
||||
void write_source_point(const char* filename, bool surf_source_bank = false);
|
||||
void write_source_bank(hid_t group_id, bool surf_source_bank);
|
||||
void read_source_bank(hid_t group_id, std::vector<Particle::Bank>& sites, bool distribute);
|
||||
void write_tally_results_nr(hid_t file_id);
|
||||
void restart_set_keff();
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public:
|
|||
int id_; //!< Unique ID
|
||||
std::string name_; //!< User-defined name
|
||||
std::shared_ptr<BoundaryCondition> bc_ {nullptr}; //!< Boundary condition
|
||||
bool surf_src_ {false}; //!< Activate source banking for the surface?
|
||||
bool surf_source_ {false}; //!< Activate source banking for the surface?
|
||||
|
||||
explicit Surface(pugi::xml_node surf_node);
|
||||
Surface();
|
||||
|
|
|
|||
|
|
@ -143,11 +143,11 @@ class Settings:
|
|||
Options for writing state points. Acceptable keys are:
|
||||
|
||||
:batches: list of batches at which to write source
|
||||
surf_src_read : dict
|
||||
surf_source_read : dict
|
||||
Options for reading surface source points. Acceptable keys are:
|
||||
|
||||
:path: Path to surface source file (str).
|
||||
surf_src_write : dict
|
||||
surf_source_write : dict
|
||||
Options for writing surface source points. Acceptable keys are:
|
||||
|
||||
:surf_ids: List of surface ids at which crossing particles are to be
|
||||
|
|
@ -240,8 +240,8 @@ class Settings:
|
|||
self._statepoint = {}
|
||||
self._sourcepoint = {}
|
||||
|
||||
self._surf_src_read = {}
|
||||
self._surf_src_write = {}
|
||||
self._surf_source_read = {}
|
||||
self._surf_source_write = {}
|
||||
|
||||
self._no_reduce = None
|
||||
|
||||
|
|
@ -371,12 +371,12 @@ class Settings:
|
|||
return self._statepoint
|
||||
|
||||
@property
|
||||
def surf_src_read(self):
|
||||
return self._surf_src_read
|
||||
def surf_source_read(self):
|
||||
return self._surf_source_read
|
||||
|
||||
@property
|
||||
def surf_src_write(self):
|
||||
return self._surf_src_write
|
||||
def surf_source_write(self):
|
||||
return self._surf_source_write
|
||||
|
||||
@property
|
||||
def no_reduce(self):
|
||||
|
|
@ -589,20 +589,20 @@ class Settings:
|
|||
"statepoint options.".format(key))
|
||||
self._statepoint = statepoint
|
||||
|
||||
@surf_src_read.setter
|
||||
def surf_src_read(self, surf_src_read):
|
||||
cv.check_type('surface source reading options', surf_src_read, Mapping)
|
||||
for key, value in surf_src_read.items():
|
||||
@surf_source_read.setter
|
||||
def surf_source_read(self, surf_source_read):
|
||||
cv.check_type('surface source reading options', surf_source_read, Mapping)
|
||||
for key, value in surf_source_read.items():
|
||||
cv.check_value('surface source reading key', key,
|
||||
('path'))
|
||||
if key == 'path':
|
||||
cv.check_type('path to surface source file', value, str)
|
||||
self._surf_src_read = surf_src_read
|
||||
self._surf_source_read = surf_source_read
|
||||
|
||||
@surf_src_write.setter
|
||||
def surf_src_write(self, surf_src_write):
|
||||
cv.check_type('surface source writing options', surf_src_write, Mapping)
|
||||
for key, value in surf_src_write.items():
|
||||
@surf_source_write.setter
|
||||
def surf_source_write(self, surf_source_write):
|
||||
cv.check_type('surface source writing options', surf_source_write, Mapping)
|
||||
for key, value in surf_source_write.items():
|
||||
cv.check_value('surface source writing key', key,
|
||||
('surf_ids', 'max_surf_banks'))
|
||||
if key == 'surf_ids':
|
||||
|
|
@ -616,7 +616,7 @@ class Settings:
|
|||
value, Integral)
|
||||
cv.check_greater_than('maximum particle banks on surfaces per process',
|
||||
value, 0)
|
||||
self._surf_src_write = surf_src_write
|
||||
self._surf_source_write = surf_source_write
|
||||
|
||||
@confidence_intervals.setter
|
||||
def confidence_intervals(self, confidence_intervals):
|
||||
|
|
@ -940,23 +940,23 @@ class Settings:
|
|||
subelement = ET.SubElement(element, "overwrite_latest")
|
||||
subelement.text = str(self._sourcepoint['overwrite']).lower()
|
||||
|
||||
def _create_surf_src_read_subelement(self, root):
|
||||
if self._surf_src_read:
|
||||
element = ET.SubElement(root, "surf_src_read")
|
||||
if 'path' in self._surf_src_read:
|
||||
def _create_surf_source_read_subelement(self, root):
|
||||
if self._surf_source_read:
|
||||
element = ET.SubElement(root, "surf_source_read")
|
||||
if 'path' in self._surf_source_read:
|
||||
subelement = ET.SubElement(element, "path")
|
||||
subelement.text = self._surf_src_read['path']
|
||||
subelement.text = self._surf_source_read['path']
|
||||
|
||||
def _create_surf_src_write_subelement(self, root):
|
||||
if self._surf_src_write:
|
||||
element = ET.SubElement(root, "surf_src_write")
|
||||
if 'surf_ids' in self._surf_src_write:
|
||||
def _create_surf_source_write_subelement(self, root):
|
||||
if self._surf_source_write:
|
||||
element = ET.SubElement(root, "surf_source_write")
|
||||
if 'surf_ids' in self._surf_source_write:
|
||||
subelement = ET.SubElement(element, "surf_ids")
|
||||
subelement.text = ' '.join(
|
||||
str(x) for x in self._surf_src_write['surf_ids'])
|
||||
if 'max_surf_banks' in self._surf_src_write:
|
||||
str(x) for x in self._surf_source_write['surf_ids'])
|
||||
if 'max_surf_banks' in self._surf_source_write:
|
||||
subelement = ET.SubElement(element, "max_surf_banks")
|
||||
subelement.text = str(self._surf_src_write['max_surf_banks'])
|
||||
subelement.text = str(self._surf_source_write['max_surf_banks'])
|
||||
|
||||
def _create_confidence_intervals(self, root):
|
||||
if self._confidence_intervals is not None:
|
||||
|
|
@ -1220,15 +1220,15 @@ class Settings:
|
|||
value = [int(x) for x in value.split()]
|
||||
self.sourcepoint[key] = value
|
||||
|
||||
def _surf_src_read_from_xml_element(self, root):
|
||||
elem = root.find('surf_src_read')
|
||||
def _surf_source_read_from_xml_element(self, root):
|
||||
elem = root.find('surf_source_read')
|
||||
if elem is not None:
|
||||
value = get_text(elem, 'path')
|
||||
if value is not None:
|
||||
self.surf_src_read['path'] = value
|
||||
self.surf_source_read['path'] = value
|
||||
|
||||
def _surf_src_write_from_xml_element(self, root):
|
||||
elem = root.find('surf_src_write')
|
||||
def _surf_source_write_from_xml_element(self, root):
|
||||
elem = root.find('surf_source_write')
|
||||
if elem is not None:
|
||||
for key in ('surf_ids', 'max_surf_banks'):
|
||||
value = get_text(elem, key)
|
||||
|
|
@ -1237,7 +1237,7 @@ class Settings:
|
|||
value = [int(x) for x in value.split()]
|
||||
elif key in ('max_surf_banks'):
|
||||
value = int(value)
|
||||
self.surf_src_write[key] = value
|
||||
self.surf_source_write[key] = value
|
||||
|
||||
def _confidence_intervals_from_xml_element(self, root):
|
||||
text = get_text(root, 'confidence_intervals')
|
||||
|
|
@ -1437,8 +1437,8 @@ class Settings:
|
|||
self._create_output_subelement(root_element)
|
||||
self._create_statepoint_subelement(root_element)
|
||||
self._create_sourcepoint_subelement(root_element)
|
||||
self._create_surf_src_read_subelement(root_element)
|
||||
self._create_surf_src_write_subelement(root_element)
|
||||
self._create_surf_source_read_subelement(root_element)
|
||||
self._create_surf_source_write_subelement(root_element)
|
||||
self._create_confidence_intervals(root_element)
|
||||
self._create_electron_treatment_subelement(root_element)
|
||||
self._create_energy_mode_subelement(root_element)
|
||||
|
|
@ -1512,8 +1512,8 @@ class Settings:
|
|||
settings._output_from_xml_element(root)
|
||||
settings._statepoint_from_xml_element(root)
|
||||
settings._sourcepoint_from_xml_element(root)
|
||||
settings._surf_src_read_from_xml_element(root)
|
||||
settings._surf_src_write_from_xml_element(root)
|
||||
settings._surf_source_read_from_xml_element(root)
|
||||
settings._surf_source_write_from_xml_element(root)
|
||||
settings._confidence_intervals_from_xml_element(root)
|
||||
settings._electron_treatment_from_xml_element(root)
|
||||
settings._energy_mode_from_xml_element(root)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace simulation {
|
|||
|
||||
std::vector<Particle::Bank> source_bank;
|
||||
|
||||
SharedArray<Particle::Bank> surf_src_bank;
|
||||
SharedArray<Particle::Bank> surf_source_bank;
|
||||
|
||||
// The fission bank is allocated as a SharedArray, rather than a vector, as it will
|
||||
// be shared by all threads in the simulation. It will be allocated to a fixed
|
||||
|
|
@ -39,7 +39,7 @@ std::vector<int64_t> progeny_per_particle;
|
|||
void free_memory_bank()
|
||||
{
|
||||
simulation::source_bank.clear();
|
||||
simulation::surf_src_bank.clear();
|
||||
simulation::surf_source_bank.clear();
|
||||
simulation::fission_bank.clear();
|
||||
simulation::progeny_per_particle.clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -297,8 +297,8 @@ void load_dagmc_geometry()
|
|||
s->id_ = model::DAG->id_by_index(2, s->dag_index_);
|
||||
s->dagmc_ptr_ = model::DAG;
|
||||
|
||||
if (contains(settings::src_write_surf_id, s->id_)) {
|
||||
s->surf_src_ = true;
|
||||
if (contains(settings::source_write_surf_id, s->id_)) {
|
||||
s->surf_source_ = true;
|
||||
}
|
||||
|
||||
// set BCs
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ Particle::cross_surface()
|
|||
write_message(1, " Crossing surface {}", surf->id_);
|
||||
}
|
||||
|
||||
if (surf->surf_src_ && simulation::current_batch == settings::n_batches) {
|
||||
if (surf->surf_source_ && simulation::current_batch == settings::n_batches) {
|
||||
Particle::Bank site;
|
||||
site.r = this->r();
|
||||
site.u = this->u();
|
||||
|
|
@ -424,7 +424,7 @@ Particle::cross_surface()
|
|||
site.particle = this->type_;
|
||||
site.parent_id = this->id_;
|
||||
site.progeny_id = this->n_progeny_;
|
||||
int64_t idx = simulation::surf_src_bank.thread_safe_append(site);
|
||||
int64_t idx = simulation::surf_source_bank.thread_safe_append(site);
|
||||
}
|
||||
|
||||
// Handle any applicable boundary conditions.
|
||||
|
|
|
|||
|
|
@ -139,11 +139,11 @@ element settings {
|
|||
attribute overwrite_latest {xsd:boolean})?
|
||||
}? &
|
||||
|
||||
element surf_src_read {
|
||||
element surf_source_read {
|
||||
(element path { xsd:string } | attribute path { xsd:string })
|
||||
}? &
|
||||
|
||||
element surf_src_write {
|
||||
element surf_source_write {
|
||||
(element surf_ids { list { xsd:positiveInteger+ } } |
|
||||
attribute surf_ids { list { xsd:positiveInteger+ } }) &
|
||||
(element max_surf_banks { xsd:positiveInteger } |
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@
|
|||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="surf_src_read">
|
||||
<element name="surf_source_read">
|
||||
<choice>
|
||||
<element name="path">
|
||||
<data type="string"/>
|
||||
|
|
@ -651,7 +651,7 @@
|
|||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="surf_src_write">
|
||||
<element name="surf_source_write">
|
||||
<interleave>
|
||||
<choice>
|
||||
<element name="surf_ids">
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ bool run_CE {true};
|
|||
bool source_latest {false};
|
||||
bool source_separate {false};
|
||||
bool source_write {true};
|
||||
bool surf_src_write {false};
|
||||
bool surf_src_read {false};
|
||||
bool surf_source_write {false};
|
||||
bool surf_source_read {false};
|
||||
bool survival_biasing {false};
|
||||
bool temperature_multipole {false};
|
||||
bool trigger_on {false};
|
||||
|
|
@ -100,7 +100,7 @@ std::vector<std::string> res_scat_nuclides;
|
|||
RunMode run_mode {RunMode::UNSET};
|
||||
std::unordered_set<int> sourcepoint_batch;
|
||||
std::unordered_set<int> statepoint_batch;
|
||||
std::unordered_set<int> src_write_surf_id;
|
||||
std::unordered_set<int> source_write_surf_id;
|
||||
int64_t max_surf_banks;
|
||||
TemperatureMethod temperature_method {TemperatureMethod::NEAREST};
|
||||
double temperature_tolerance {10.0};
|
||||
|
|
@ -442,10 +442,10 @@ void read_settings_xml()
|
|||
}
|
||||
|
||||
// Check if the user has specified to read surface source
|
||||
if (check_for_node(root, "surf_src_read")) {
|
||||
surf_src_read = true;
|
||||
if (check_for_node(root, "surf_source_read")) {
|
||||
surf_source_read = true;
|
||||
// Get surface source read node
|
||||
xml_node node_ssr = root.child("surf_src_read");
|
||||
xml_node node_ssr = root.child("surf_source_read");
|
||||
|
||||
std::string path = "surface_source.h5";
|
||||
// Check if the user has specified different file for surface source reading
|
||||
|
|
@ -641,16 +641,16 @@ void read_settings_xml()
|
|||
}
|
||||
|
||||
// Check if the user has specified to write surface source
|
||||
if (check_for_node(root, "surf_src_write")) {
|
||||
surf_src_write = true;
|
||||
if (check_for_node(root, "surf_source_write")) {
|
||||
surf_source_write = true;
|
||||
// Get surface source write node
|
||||
xml_node node_ssw = root.child("surf_src_write");
|
||||
xml_node node_ssw = root.child("surf_source_write");
|
||||
|
||||
// Determine surface ids at which crossing particles are to be banked
|
||||
if (check_for_node(node_ssw, "surf_ids")) {
|
||||
auto temp = get_node_array<int>(node_ssw, "surf_ids");
|
||||
for (const auto& b : temp) {
|
||||
src_write_surf_id.insert(b);
|
||||
source_write_surf_id.insert(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -832,7 +832,7 @@ void read_settings_xml()
|
|||
void free_memory_settings() {
|
||||
settings::statepoint_batch.clear();
|
||||
settings::sourcepoint_batch.clear();
|
||||
settings::src_write_surf_id.clear();
|
||||
settings::source_write_surf_id.clear();
|
||||
settings::res_scat_nuclides.clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ int openmc_simulation_init()
|
|||
} else {
|
||||
// Only initialize primary source bank for eigenvalue simulations
|
||||
// or when a surface source file is provided.
|
||||
if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_src_read) {
|
||||
if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_source_read) {
|
||||
initialize_source();
|
||||
}
|
||||
}
|
||||
|
|
@ -271,7 +271,7 @@ const RegularMesh* ufs_mesh {nullptr};
|
|||
std::vector<double> k_generation;
|
||||
std::vector<int64_t> work_index;
|
||||
|
||||
std::vector<int64_t> surf_src_index;
|
||||
std::vector<int64_t> surf_source_index;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
@ -287,14 +287,14 @@ void allocate_banks()
|
|||
|
||||
// Allocate fission bank
|
||||
init_fission_bank(3*simulation::work_per_rank);
|
||||
} else if (settings::surf_src_read) {
|
||||
} else if (settings::surf_source_read) {
|
||||
// Allocate source bank for reading surface source file.
|
||||
simulation::source_bank.resize(simulation::work_per_rank);
|
||||
}
|
||||
|
||||
if (settings::surf_src_write) {
|
||||
if (settings::surf_source_write) {
|
||||
// Allocate surface source bank
|
||||
simulation::surf_src_bank.reserve(settings::max_surf_banks);
|
||||
simulation::surf_source_bank.reserve(settings::max_surf_banks);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -389,7 +389,7 @@ void finalize_batch()
|
|||
}
|
||||
|
||||
// Write out surface source if requested.
|
||||
if (settings::surf_src_write && simulation::current_batch == settings::n_batches) {
|
||||
if (settings::surf_source_write && simulation::current_batch == settings::n_batches) {
|
||||
|
||||
auto filename = settings::path_output + "surface_source.h5";
|
||||
write_source_point(filename.c_str(), true);
|
||||
|
|
@ -458,7 +458,7 @@ void finalize_generation()
|
|||
void initialize_history(Particle& p, int64_t index_source)
|
||||
{
|
||||
// set defaults
|
||||
if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_src_read) {
|
||||
if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_source_read) {
|
||||
// set defaults for eigenvalue simulations and surface source reading from primary bank
|
||||
p.from_source(&simulation::source_bank[index_source - 1]);
|
||||
} else if (settings::run_mode == RunMode::FIXED_SOURCE) {
|
||||
|
|
|
|||
|
|
@ -525,45 +525,45 @@ hid_t h5banktype() {
|
|||
return banktype;
|
||||
}
|
||||
|
||||
int query_surf_src_size()
|
||||
int query_surf_source_size()
|
||||
{
|
||||
int64_t total;
|
||||
|
||||
simulation::surf_src_index.resize(mpi::n_procs + 1);
|
||||
simulation::surf_src_index[0] = 0;
|
||||
simulation::surf_source_index.resize(mpi::n_procs + 1);
|
||||
simulation::surf_source_index[0] = 0;
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
std::vector<int64_t> bank_size;
|
||||
bank_size.resize(mpi::n_procs);
|
||||
|
||||
// Collect the number of surface source banks from all processes
|
||||
int64_t size = simulation::surf_src_bank.size();
|
||||
int64_t size = simulation::surf_source_bank.size();
|
||||
MPI_Gather(&size, 1, MPI_INT64_T,
|
||||
bank_size.data(), 1, MPI_INT64_T,
|
||||
0, mpi::intracomm);
|
||||
|
||||
if (mpi::master) {
|
||||
// Populate the surf_src_index with cumulative sum of the number of
|
||||
// Populate the surf_source_index with cumulative sum of the number of
|
||||
// surface source banks per process
|
||||
for (int i = 1; i < mpi::n_procs + 1; ++i) {
|
||||
simulation::surf_src_index[i] = \
|
||||
simulation::surf_src_index[i - 1] + bank_size[i - 1];
|
||||
simulation::surf_source_index[i] = \
|
||||
simulation::surf_source_index[i - 1] + bank_size[i - 1];
|
||||
}
|
||||
total = simulation::surf_src_index[mpi::n_procs];
|
||||
total = simulation::surf_source_index[mpi::n_procs];
|
||||
}
|
||||
MPI_Bcast(simulation::surf_src_index.data(), mpi::n_procs + 1, MPI_INT64_T, 0, mpi::intracomm);
|
||||
MPI_Bcast(simulation::surf_source_index.data(), mpi::n_procs + 1, MPI_INT64_T, 0, mpi::intracomm);
|
||||
MPI_Bcast(&total, 1, MPI_INT64_T, 0, mpi::intracomm);
|
||||
|
||||
#else
|
||||
simulation::surf_src_index[mpi::n_procs] = simulation::surf_src_bank.size();
|
||||
total = simulation::surf_src_bank.size();
|
||||
simulation::surf_source_index[mpi::n_procs] = simulation::surf_source_bank.size();
|
||||
total = simulation::surf_source_bank.size();
|
||||
#endif
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
void
|
||||
write_source_point(const char* filename, bool surf_src_bank)
|
||||
write_source_point(const char* filename, bool surf_source_bank)
|
||||
{
|
||||
// When using parallel HDF5, the file is written to collectively by all
|
||||
// processes. With MPI-only, the file is opened and written by the master
|
||||
|
|
@ -593,13 +593,13 @@ write_source_point(const char* filename, bool surf_src_bank)
|
|||
}
|
||||
|
||||
// Get pointer to source bank and write to file
|
||||
write_source_bank(file_id, surf_src_bank);
|
||||
write_source_bank(file_id, surf_source_bank);
|
||||
|
||||
if (mpi::master || parallel) file_close(file_id);
|
||||
}
|
||||
|
||||
void
|
||||
write_source_bank(hid_t group_id, bool surf_src_bank)
|
||||
write_source_bank(hid_t group_id, bool surf_source_bank)
|
||||
{
|
||||
hid_t banktype = h5banktype();
|
||||
|
||||
|
|
@ -609,21 +609,21 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
|
||||
// Set vectors for source bank and starting bank index of each process
|
||||
std::vector<int64_t>* bank_index = &simulation::work_index;
|
||||
std::vector<Particle::Bank>* src_bank = &simulation::source_bank;
|
||||
std::vector<Particle::Bank> surf_src_bank_vector;
|
||||
std::vector<Particle::Bank>* source_bank = &simulation::source_bank;
|
||||
std::vector<Particle::Bank> surf_source_bank_vector;
|
||||
|
||||
// Reset dataspace sizes and vectors for surface source bank
|
||||
if (surf_src_bank) {
|
||||
dims_size = query_surf_src_size();
|
||||
count_size = simulation::surf_src_bank.size();
|
||||
if (surf_source_bank) {
|
||||
dims_size = query_surf_source_size();
|
||||
count_size = simulation::surf_source_bank.size();
|
||||
|
||||
bank_index = &simulation::surf_src_index;
|
||||
bank_index = &simulation::surf_source_index;
|
||||
|
||||
// Copy data in a SharedArray into a vector.
|
||||
surf_src_bank_vector.resize(count_size);
|
||||
surf_src_bank_vector.assign(simulation::surf_src_bank.data(),
|
||||
simulation::surf_src_bank.data() + count_size);
|
||||
src_bank = &surf_src_bank_vector;
|
||||
surf_source_bank_vector.resize(count_size);
|
||||
surf_source_bank_vector.assign(simulation::surf_source_bank.data(),
|
||||
simulation::surf_source_bank.data() + count_size);
|
||||
source_bank = &surf_source_bank_vector;
|
||||
}
|
||||
|
||||
#ifdef PHDF5
|
||||
|
|
@ -646,7 +646,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE);
|
||||
|
||||
// Write data to file in parallel
|
||||
H5Dwrite(dset, banktype, memspace, dspace, plist, src_bank->data());
|
||||
H5Dwrite(dset, banktype, memspace, dspace, plist, source_bank->data());
|
||||
|
||||
// Free resources
|
||||
H5Sclose(dspace);
|
||||
|
|
@ -665,7 +665,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
|
||||
// Save source bank sites since the array is overwritten below
|
||||
#ifdef OPENMC_MPI
|
||||
std::vector<Particle::Bank> temp_source {src_bank->begin(), src_bank->end()};
|
||||
std::vector<Particle::Bank> temp_source {source_bank->begin(), source_bank->end()};
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < mpi::n_procs; ++i) {
|
||||
|
|
@ -676,7 +676,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
#ifdef OPENMC_MPI
|
||||
// Receive source sites from other processes
|
||||
if (i > 0)
|
||||
MPI_Recv(src_bank->data(), count[0], mpi::bank, i, i,
|
||||
MPI_Recv(source_bank->data(), count[0], mpi::bank, i, i,
|
||||
mpi::intracomm, MPI_STATUS_IGNORE);
|
||||
#endif
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr);
|
||||
|
||||
// Write data to hyperslab
|
||||
H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, (*src_bank).data());
|
||||
H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, (*source_bank).data());
|
||||
|
||||
H5Sclose(memspace);
|
||||
H5Sclose(dspace);
|
||||
|
|
@ -697,11 +697,11 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
|
||||
#ifdef OPENMC_MPI
|
||||
// Restore state of source bank
|
||||
std::copy(temp_source.begin(), temp_source.end(), src_bank->begin());
|
||||
std::copy(temp_source.begin(), temp_source.end(), source_bank->begin());
|
||||
#endif
|
||||
} else {
|
||||
#ifdef OPENMC_MPI
|
||||
MPI_Send(src_bank->data(), count_size, mpi::bank,
|
||||
MPI_Send(source_bank->data(), count_size, mpi::bank,
|
||||
0, mpi::rank, mpi::intracomm);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ Surface::Surface(pugi::xml_node surf_node)
|
|||
{
|
||||
if (check_for_node(surf_node, "id")) {
|
||||
id_ = std::stoi(get_node_value(surf_node, "id"));
|
||||
if (contains(settings::src_write_surf_id, id_)) {
|
||||
surf_src_ = true;
|
||||
if (contains(settings::source_write_surf_id, id_)) {
|
||||
surf_source_ = true;
|
||||
}
|
||||
} else {
|
||||
fatal_error("Must specify id of surface in geometry XML file.");
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
<run_mode>fixed source</run_mode>
|
||||
<particles>1000</particles>
|
||||
<batches>10</batches>
|
||||
<surf_src_read>
|
||||
<surf_source_read>
|
||||
<path>surface_source_true.h5</path>
|
||||
</surf_src_read>
|
||||
</surf_source_read>
|
||||
<seed>1</seed>
|
||||
</settings>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
<parameters>0 0 0</parameters>
|
||||
</space>
|
||||
</source>
|
||||
<surf_src_write>
|
||||
<surf_source_write>
|
||||
<surf_ids>1</surf_ids>
|
||||
<max_surf_banks>1000</max_surf_banks>
|
||||
</surf_src_write>
|
||||
</surf_source_write>
|
||||
<seed>1</seed>
|
||||
</settings>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ def model(request):
|
|||
pt_src = openmc.Source(space=point)
|
||||
openmc_model.settings.source = pt_src
|
||||
|
||||
openmc_model.settings.surf_src_write = {'surf_ids': [1],
|
||||
'max_surf_banks': 1000}
|
||||
openmc_model.settings.surf_source_write = {'surf_ids': [1],
|
||||
'max_surf_banks': 1000}
|
||||
elif surf_src_op == 'read':
|
||||
openmc_model.settings.surf_src_read = {'path': 'surface_source_true.h5'}
|
||||
|
||||
|
|
@ -66,22 +66,23 @@ class SurfaceSourceTestHarness(PyAPITestHarness):
|
|||
"""Make sure surface_source.h5 has also been created."""
|
||||
super()._test_output_created()
|
||||
# Check if 'surface_source.h5' has been created.
|
||||
if self._model.settings.surf_src_write:
|
||||
if self._model.settings.surf_source_write:
|
||||
assert os.path.exists('surface_source.h5'), \
|
||||
'Surface source file does not exist.'
|
||||
|
||||
def _compare_output(self):
|
||||
"""Make sure the current surface_source.h5 agree with the reference."""
|
||||
if self._model.settings.surf_src_write:
|
||||
if self._model.settings.surf_source_write:
|
||||
with h5py.File("surface_source_true.h5", 'r') as f:
|
||||
src_true = f['source_bank'][()]
|
||||
source_true = f['source_bank'][()]
|
||||
# Convert dtye from mixed to a float for comparison assertion
|
||||
src_true.dtype = 'float64'
|
||||
source_true.dtype = 'float64'
|
||||
with h5py.File("surface_source.h5", 'r') as f:
|
||||
src_test = f['source_bank'][()]
|
||||
source_test = f['source_bank'][()]
|
||||
# Convert dtye from mixed to a float for comparison assertion
|
||||
src_test.dtype = 'float64'
|
||||
np.testing.assert_allclose(np.sort(src_true), np.sort(src_test),
|
||||
source_test.dtype = 'float64'
|
||||
np.testing.assert_allclose(np.sort(source_true),
|
||||
np.sort(source_test),
|
||||
atol=1e-07)
|
||||
|
||||
def execute_test(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue