mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
(1) Made OpenMC load plots.xml upon initialization even if not in the plot runmode; (2) Made the finalize method clear plotting data; (3) allowed the openmc.lib and openmc.model package to call plot_geometry now that plots.xml would have been loaded
This commit is contained in:
parent
b335f82792
commit
20c8043c1c
5 changed files with 26 additions and 18 deletions
|
|
@ -30,9 +30,7 @@ namespace model {
|
|||
extern std::unordered_map<int, int> plot_map; //!< map of plot ids to index
|
||||
extern vector<Plot> plots; //!< Plot instance container
|
||||
|
||||
extern uint64_t
|
||||
plotter_prn_seeds[N_STREAMS]; // Random number seeds used for plotter
|
||||
extern int plotter_stream; // Stream index used by the plotter
|
||||
extern uint64_t plotter_seed; // Stream index used by the plotter
|
||||
|
||||
} // namespace model
|
||||
|
||||
|
|
@ -274,6 +272,9 @@ void voxel_finalize(hid_t dspace, hid_t dset, hid_t memspace);
|
|||
//! Read plot specifications from a plots.xml file
|
||||
void read_plots_xml();
|
||||
|
||||
//! Clear memory
|
||||
void free_memory_plot();
|
||||
|
||||
//! Create a ppm image for a plot object
|
||||
//! \param[in] plot object
|
||||
void create_ppm(Plot const& pl);
|
||||
|
|
|
|||
|
|
@ -664,18 +664,12 @@ class Model:
|
|||
"before executing this method!")
|
||||
|
||||
with _change_directory(Path(cwd)):
|
||||
# TODO: openmc.is_initialized doesnt read plots.xml unless it is
|
||||
# in plot mode so the following will not work. Commented out for
|
||||
# now and replacing with non-C API code
|
||||
self.export_to_xml()
|
||||
openmc.plot_geometry(output=output, openmc_exec=openmc_exec)
|
||||
|
||||
# if self.is_initialized:
|
||||
# # Compute the volumes
|
||||
# openmc.lib.plot_geometry(output)
|
||||
# else:
|
||||
# self.export_to_xml()
|
||||
# openmc.plot_geometry(output=output, openmc_exec=openmc_exec)
|
||||
if self.is_initialized:
|
||||
# Compute the volumes
|
||||
openmc.lib.plot_geometry(output)
|
||||
else:
|
||||
self.export_to_xml()
|
||||
openmc.plot_geometry(output=output, openmc_exec=openmc_exec)
|
||||
|
||||
if convert:
|
||||
for p in self.plots:
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "openmc/message_passing.h"
|
||||
#include "openmc/nuclide.h"
|
||||
#include "openmc/photon.h"
|
||||
#include "openmc/plot.h"
|
||||
#include "openmc/random_lcg.h"
|
||||
#include "openmc/settings.h"
|
||||
#include "openmc/simulation.h"
|
||||
|
|
@ -45,6 +46,7 @@ void free_memory()
|
|||
free_memory_mesh();
|
||||
free_memory_tally();
|
||||
free_memory_bank();
|
||||
free_memory_plot();
|
||||
if (mpi::master) {
|
||||
free_memory_cmfd();
|
||||
}
|
||||
|
|
@ -128,6 +130,7 @@ int openmc_finalize()
|
|||
data::temperature_min = 0.0;
|
||||
data::temperature_max = INFTY;
|
||||
model::root_universe = -1;
|
||||
model::plotter_seed = 1;
|
||||
openmc::openmc_set_seed(DEFAULT_SEED);
|
||||
|
||||
// Deallocate arrays
|
||||
|
|
|
|||
|
|
@ -305,9 +305,11 @@ void read_input_xml()
|
|||
// Initialize distribcell_filters
|
||||
prepare_distribcell();
|
||||
|
||||
// Read the plots.xml regardless of plot mode in case plots are requested
|
||||
// via the API
|
||||
read_plots_xml();
|
||||
if (settings::run_mode == RunMode::PLOTTING) {
|
||||
// Read plots.xml if it exists
|
||||
read_plots_xml();
|
||||
if (mpi::master && settings::verbosity >= 5)
|
||||
print_plot();
|
||||
|
||||
|
|
|
|||
12
src/plot.cpp
12
src/plot.cpp
|
|
@ -119,9 +119,11 @@ extern "C" int openmc_plot_geometry()
|
|||
|
||||
void read_plots_xml()
|
||||
{
|
||||
// Check if plots.xml exists
|
||||
// Check if plots.xml exists; this is only necessary when the plot runmode is
|
||||
// initiated. Otherwise, we want to read plots.xml because it may be called
|
||||
// later via the API. In that case, its ok for a plots.xml to not exist
|
||||
std::string filename = settings::path_input + "plots.xml";
|
||||
if (!file_exists(filename)) {
|
||||
if (!file_exists(filename) && settings::run_mode == RunMode::PLOTTING) {
|
||||
fatal_error(fmt::format("Plots XML file '{}' does not exist!", filename));
|
||||
}
|
||||
|
||||
|
|
@ -138,6 +140,12 @@ void read_plots_xml()
|
|||
}
|
||||
}
|
||||
|
||||
void free_memory_plot()
|
||||
{
|
||||
model::plots.clear();
|
||||
model::plot_map.clear();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// CREATE_PPM creates an image based on user input from a plots.xml <plot>
|
||||
// specification in the portable pixmap format (PPM)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue