mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Move finalize_batch and write_source_point to C++
This commit is contained in:
parent
8c64139c06
commit
a4ddaf9ed6
21 changed files with 211 additions and 223 deletions
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/container_util.h"
|
||||
#include "openmc/distribution.h"
|
||||
#include "openmc/distribution_multi.h"
|
||||
#include "openmc/distribution_spatial.h"
|
||||
|
|
@ -87,6 +88,8 @@ int res_scat_method {RES_SCAT_ARES};
|
|||
double res_scat_energy_min {0.01};
|
||||
double res_scat_energy_max {1000.0};
|
||||
int run_mode {-1};
|
||||
std::unordered_set<int> sourcepoint_batch;
|
||||
std::unordered_set<int> statepoint_batch;
|
||||
int temperature_method {TEMPERATURE_NEAREST};
|
||||
double temperature_tolerance {10.0};
|
||||
double temperature_default {293.6};
|
||||
|
|
@ -507,7 +510,7 @@ void read_settings_xml()
|
|||
// Reshape into track_identifiers
|
||||
int n_tracks = temp.size() / 3;
|
||||
for (int i = 0; i < n_tracks; ++i) {
|
||||
settings::track_identifiers.push_back({temp[3*i], temp[3*i + 1],
|
||||
track_identifiers.push_back({temp[3*i], temp[3*i + 1],
|
||||
temp[3*i + 2]});
|
||||
}
|
||||
}
|
||||
|
|
@ -548,7 +551,7 @@ void read_settings_xml()
|
|||
// If the user did not specify how many mesh cells are to be used in
|
||||
// each direction, we automatically determine an appropriate number of
|
||||
// cells
|
||||
int n = std::ceil(std::pow(settings::n_particles / 20.0, 1.0/3.0));
|
||||
int n = std::ceil(std::pow(n_particles / 20.0, 1.0/3.0));
|
||||
m.shape_ = {n, n, n};
|
||||
m.n_dimension_ = 3;
|
||||
|
||||
|
|
@ -557,7 +560,7 @@ void read_settings_xml()
|
|||
}
|
||||
|
||||
// Turn on Shannon entropy calculation
|
||||
settings::entropy_on = true;
|
||||
entropy_on = true;
|
||||
}
|
||||
|
||||
// Uniform fission source weighting mesh
|
||||
|
|
@ -590,18 +593,48 @@ void read_settings_xml()
|
|||
|
||||
if (index_ufs_mesh >= 0) {
|
||||
// Turn on uniform fission source weighting
|
||||
settings::ufs_on = true;
|
||||
ufs_on = true;
|
||||
}
|
||||
|
||||
// TODO: Read <state_point>
|
||||
// Check if the user has specified to write state points
|
||||
if (check_for_node(root, "state_point")) {
|
||||
|
||||
// Get pointer to state_point node
|
||||
auto node_sp = root.child("state_point");
|
||||
|
||||
// Determine number of batches at which to store state points
|
||||
if (check_for_node(node_sp, "batches")) {
|
||||
// User gave specific batches to write state points
|
||||
auto temp = get_node_array<int>(node_sp, "batches");
|
||||
for (const auto& b : temp) {
|
||||
statepoint_batch.insert(b);
|
||||
}
|
||||
} else {
|
||||
// If neither were specified, write state point at last batch
|
||||
statepoint_batch.insert(n_batches);
|
||||
}
|
||||
} else {
|
||||
// If no <state_point> tag was present, by default write state point at
|
||||
// last batch only
|
||||
statepoint_batch.insert(n_batches);
|
||||
}
|
||||
|
||||
// Check if the user has specified to write source points
|
||||
if (check_for_node(root, "source_point")) {
|
||||
// Get source_point node
|
||||
xml_node node_sp = root.child("source_point");
|
||||
|
||||
// TODO: Read source point batches
|
||||
// Determine batches at which to store source points
|
||||
if (check_for_node(node_sp, "batches")) {
|
||||
// User gave specific batches to write source points
|
||||
auto temp = get_node_array<int>(node_sp, "batches");
|
||||
for (const auto& b : temp) {
|
||||
sourcepoint_batch.insert(b);
|
||||
}
|
||||
} else {
|
||||
// If neither were specified, write source points with state points
|
||||
sourcepoint_batch = statepoint_batch;
|
||||
}
|
||||
|
||||
// Check if the user has specified to write binary source file
|
||||
if (check_for_node(node_sp, "separate")) {
|
||||
|
|
@ -618,10 +651,19 @@ void read_settings_xml()
|
|||
// If no <source_point> tag was present, by default we keep source bank in
|
||||
// statepoint file and write it out at statepoints intervals
|
||||
source_separate = false;
|
||||
// TODO: add defaults
|
||||
sourcepoint_batch = statepoint_batch;
|
||||
}
|
||||
|
||||
// TODO: Check source points are subset
|
||||
// If source is not seperate and is to be written out in the statepoint file,
|
||||
// make sure that the sourcepoint batch numbers are contained in the
|
||||
// statepoint list
|
||||
if (!source_separate) {
|
||||
for (const auto& b : sourcepoint_batch) {
|
||||
if (!contains(statepoint_batch, b)) {
|
||||
fatal_error("Sourcepoint batches are not a subset of statepoint batches.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the user has specified to not reduce tallies at the end of every
|
||||
// batch
|
||||
|
|
@ -787,6 +829,11 @@ extern "C" {
|
|||
const char* openmc_path_particle_restart() {
|
||||
return settings::path_particle_restart.c_str();
|
||||
}
|
||||
|
||||
void free_memory_settings_c() {
|
||||
settings::statepoint_batch.clear();
|
||||
settings::sourcepoint_batch.clear();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue