Put plots in model namespace

This commit is contained in:
Paul Romano 2018-11-08 15:14:01 -06:00
parent c9bd707f04
commit 6393db8daa
4 changed files with 24 additions and 22 deletions

View file

@ -136,7 +136,6 @@ extern "C" {
// Global variables
extern char openmc_err_msg[256];
extern int n_nuclides;
extern int32_t n_plots;
extern int32_t n_realizations;
extern int32_t n_sab_tables;
extern int32_t n_sources;

View file

@ -18,14 +18,14 @@ namespace openmc {
// Global variables
//===============================================================================
extern int PLOT_LEVEL_LOWEST; //!< lower bound on plot universe level
class Plot;
namespace model {
extern std::vector<Plot> plots; //!< Plot instance container
extern std::unordered_map<int, int> plot_map; //!< map of plot ids to index
extern "C" int32_t n_plots; //!< number of plots in openmc run
class Plot;
extern std::vector<Plot> plots; //!< Plot instance container
} // namespace model
//===============================================================================
// RGBColor holds color information for plotted objects
@ -124,8 +124,7 @@ void draw_mesh_lines(Plot pl, ImageData& data);
//! Write a ppm image to file using a plot object's image data
//! \param[in] plot object
//! \param[out] image data associated with the plot object
void output_ppm(Plot pl,
const ImageData& data);
void output_ppm(Plot pl, const ImageData& data);
//! Get the rgb color for a given particle position in a plot
//! \param[in] particle with position for current pixel
@ -141,7 +140,7 @@ void position_rgb(Particle p, Plot pl, RGBColor& rgb, int& id);
//! \param[out] dataset pointer to voxesl data
//! \param[out] pointer to memory space of voxel data
void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace,
hid_t* dset, hid_t* memspace);
hid_t* dset, hid_t* memspace);
//! Write a section of the voxel data to hdf5
//! \param[in] voxel slice
@ -149,7 +148,8 @@ void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace,
//! \param[out] dataset pointer to voxesl data
//! \param[out] pointer to data to write
void voxel_write_slice(int x, hid_t dspace, hid_t dset,
hid_t memspace, void* buf);
hid_t memspace, void* buf);
//! Close voxel file entities
//! \param[in] data space to close
//! \param[in] dataset to close

View file

@ -62,7 +62,7 @@ void print_plot() {
header("PLOTTING SUMMARY", 5);
for (auto pl : plots) {
for (auto pl : model::plots) {
// Plot id
std::cout << "Plot ID: " << pl.id_ << "\n";
// Plot filename

View file

@ -20,19 +20,23 @@
namespace openmc {
//==============================================================================
// Constants
//==============================================================================
const RGBColor WHITE {255, 255, 255};
constexpr int PLOT_LEVEL_LOWEST {-1}; //!< lower bound on plot universe level
//==============================================================================
// Global variables
//==============================================================================
int PLOT_LEVEL_LOWEST = -1;
std::unordered_map<int, int> plot_map;
int n_plots;
namespace model {
std::vector<Plot> plots;
std::unordered_map<int, int> plot_map;
const RGBColor WHITE = {255, 255, 255};
} // namespace model
//==============================================================================
// RUN_PLOT controls the logic for making one or many plots
@ -43,7 +47,7 @@ int openmc_plot_geometry()
{
int err;
for (auto pl : plots) {
for (auto pl : model::plots) {
std::stringstream ss;
ss << "Processing plot " << pl.id_ << ": "
<< pl.path_plot_ << "...";
@ -64,11 +68,10 @@ int openmc_plot_geometry()
void
read_plots(pugi::xml_node* plots_node)
{
n_plots = 0;
for (auto node : plots_node->children("plot")) {
Plot pl(node);
plots.push_back(pl);
plot_map[pl.id_] = n_plots++;
model::plots.push_back(pl);
model::plot_map[pl.id_] = model::plots.size() - 1;
}
}
@ -156,7 +159,7 @@ Plot::set_id(pugi::xml_node plot_node)
}
// Check to make sure 'id' hasn't been used
if (plot_map.find(id_) != plot_map.end()) {
if (model::plot_map.find(id_) != model::plot_map.end()) {
std::stringstream err_msg;
err_msg << "Two or more plots use the same unique ID: " << id_;
fatal_error(err_msg.str());