mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
commit
56dc03c19c
20 changed files with 1321 additions and 1181 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#ifndef OPENMC_OUTPUT_H
|
||||
#define OPENMC_OUTPUT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -16,6 +17,21 @@ namespace openmc {
|
|||
|
||||
void header(const char* msg, int level);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//! Retrieve a time stamp
|
||||
//!
|
||||
//! \return current time stamp (format: "yyyy-mm-dd hh:mm:ss")
|
||||
//==============================================================================
|
||||
|
||||
std::string time_stamp();
|
||||
|
||||
//==============================================================================
|
||||
//! Display plot information
|
||||
//==============================================================================
|
||||
|
||||
extern "C" void print_plot();
|
||||
|
||||
//==============================================================================
|
||||
//! Display information regarding cell overlap checking.
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -1,15 +1,181 @@
|
|||
#ifndef OPENMC_PLOT_H
|
||||
#define OPENMC_PLOT_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <sstream>
|
||||
|
||||
#include "xtensor/xarray.hpp"
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
extern "C" void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace,
|
||||
//===============================================================================
|
||||
// Global variables
|
||||
//===============================================================================
|
||||
|
||||
extern int PLOT_LEVEL_LOWEST; //!< lower bound on plot universe level
|
||||
|
||||
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
|
||||
|
||||
//===============================================================================
|
||||
// RGBColor holds color information for plotted objects
|
||||
//===============================================================================
|
||||
|
||||
struct RGBColor {
|
||||
//Constructors
|
||||
RGBColor() : red(0), green(0), blue(0) { };
|
||||
RGBColor(const int v[3]) : red(v[0]), green(v[1]), blue(v[2]) { };
|
||||
RGBColor(int r, int g, int b) : red(r), green(g), blue(b) { };
|
||||
|
||||
RGBColor(const std::vector<int> &v) {
|
||||
if (v.size() != 3) {
|
||||
throw std::out_of_range("Incorrect vector size for RGBColor.");
|
||||
}
|
||||
red = v[0];
|
||||
green = v[1];
|
||||
blue = v[2];
|
||||
}
|
||||
|
||||
// Members
|
||||
uint8_t red, green, blue;
|
||||
};
|
||||
|
||||
typedef xt::xtensor<RGBColor, 2> ImageData;
|
||||
|
||||
enum class PlotType {
|
||||
slice = 1,
|
||||
voxel = 2
|
||||
};
|
||||
|
||||
enum class PlotBasis {
|
||||
xy = 1,
|
||||
xz = 2,
|
||||
yz = 3
|
||||
};
|
||||
|
||||
enum class PlotColorBy {
|
||||
cells = 1,
|
||||
mats = 2
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
// Plot class
|
||||
//===============================================================================
|
||||
|
||||
class Plot
|
||||
{
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Plot(pugi::xml_node plot);
|
||||
|
||||
// Methods
|
||||
private:
|
||||
void set_id(pugi::xml_node plot_node);
|
||||
void set_type(pugi::xml_node plot_node);
|
||||
void set_output_path(pugi::xml_node plot_node);
|
||||
void set_bg_color(pugi::xml_node plot_node);
|
||||
void set_basis(pugi::xml_node plot_node);
|
||||
void set_origin(pugi::xml_node plot_node);
|
||||
void set_width(pugi::xml_node plot_node);
|
||||
void set_universe(pugi::xml_node plot_node);
|
||||
void set_default_colors(pugi::xml_node plot_node);
|
||||
void set_user_colors(pugi::xml_node plot_node);
|
||||
void set_meshlines(pugi::xml_node plot_node);
|
||||
void set_mask(pugi::xml_node plot_node);
|
||||
|
||||
// Members
|
||||
public:
|
||||
int id_; //!< Plot ID
|
||||
PlotType type_; //!< Plot type (Slice/Voxel)
|
||||
PlotColorBy color_by_; //!< Plot coloring (cell/material)
|
||||
Position origin_; //!< Plot origin in geometry
|
||||
Position width_; //!< Plot width in geometry
|
||||
PlotBasis basis_; //!< Plot basis (XY/XZ/YZ)
|
||||
std::array<int, 3> pixels_; //!< Plot size in pixels
|
||||
int meshlines_width_; //!< Width of lines added to the plot
|
||||
int level_; //!< Plot universe level
|
||||
int index_meshlines_mesh_; //!< Index of the mesh to draw on the plot
|
||||
RGBColor meshlines_color_; //!< Color of meshlines on the plot
|
||||
RGBColor not_found_; //!< Plot background color
|
||||
std::vector<RGBColor> colors_; //!< Plot colors
|
||||
std::string path_plot_; //!< Plot output filename
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
// Non-member functions
|
||||
//===============================================================================
|
||||
|
||||
//! Add mesh lines to image data of a plot object
|
||||
//! \param[in] plot object
|
||||
//! \param[out] image data associated with the plot object
|
||||
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);
|
||||
|
||||
//! Get the rgb color for a given particle position in a plot
|
||||
//! \param[in] particle with position for current pixel
|
||||
//! \param[in] plot object
|
||||
//! \param[out] rgb color
|
||||
//! \param[out] cell or material id for particle position
|
||||
void position_rgb(Particle p, Plot pl, RGBColor& rgb, int& id);
|
||||
|
||||
//! Initialize a voxel file
|
||||
//! \param[in] id of an open hdf5 file
|
||||
//! \param[in] dimensions of the voxel file (dx, dy, dz)
|
||||
//! \param[out] dataspace pointer to voxel data
|
||||
//! \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);
|
||||
extern "C" void voxel_write_slice(int x, hid_t dspace, hid_t dset,
|
||||
|
||||
//! Write a section of the voxel data to hdf5
|
||||
//! \param[in] voxel slice
|
||||
//! \param[out] dataspace pointer to voxel data
|
||||
//! \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);
|
||||
extern "C" void voxel_finalize(hid_t dspace, hid_t dset, hid_t memspace);
|
||||
//! Close voxel file entities
|
||||
//! \param[in] data space to close
|
||||
//! \param[in] dataset to close
|
||||
//! \param[in] memory space to close
|
||||
void voxel_finalize(hid_t dspace, hid_t dset, hid_t memspace);
|
||||
|
||||
//===============================================================================
|
||||
// External functions
|
||||
//===============================================================================
|
||||
|
||||
//! Read plots from plots.xml node
|
||||
//! \param[in] plot node of plots.xml
|
||||
extern "C" void read_plots(pugi::xml_node* plot_node);
|
||||
|
||||
//! Create a ppm image for a plot object
|
||||
//! \param[in] plot object
|
||||
void create_ppm(Plot pl);
|
||||
|
||||
//! Create an hdf5 voxel file for a plot object
|
||||
//! \param[in] plot object
|
||||
void create_voxel(Plot pl);
|
||||
|
||||
//! Create a randomly generated RGB color
|
||||
//! \return RGBColor with random value
|
||||
RGBColor random_color();
|
||||
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_PLOT_H
|
||||
|
|
|
|||
22
include/openmc/progress_bar.h
Normal file
22
include/openmc/progress_bar.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef OPENMC_PROGRESSBAR_H
|
||||
#define OPENMC_PROGRESSBAR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class ProgressBar {
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
ProgressBar();
|
||||
|
||||
void set_value(double val);
|
||||
|
||||
private:
|
||||
std::string bar;
|
||||
char bar_old[72] = "???% | |";
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // OPENMC_PROGRESSBAR_H
|
||||
|
||||
|
|
@ -61,7 +61,8 @@ extern std::string path_statepoint; //!< path to a statepoint file
|
|||
|
||||
extern "C" int32_t index_entropy_mesh; //!< Index of entropy mesh in global mesh array
|
||||
extern "C" int32_t index_ufs_mesh; //!< Index of UFS mesh in global mesh array
|
||||
|
||||
extern "C" int32_t index_cmfd_mesh; //!< Index of CMFD mesh in global mesh array
|
||||
|
||||
extern "C" int32_t n_batches; //!< number of (inactive+active) batches
|
||||
extern "C" int32_t n_inactive; //!< number of inactive batches
|
||||
extern "C" int32_t gen_per_batch; //!< number of generations per batch
|
||||
|
|
|
|||
|
|
@ -14,5 +14,7 @@ char* strtrim(char* c_str);
|
|||
|
||||
void to_lower(std::string& str);
|
||||
|
||||
int word_count(std::string const& str);
|
||||
|
||||
} // namespace openmc
|
||||
#endif // STRING_FUNCTIONS_H
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include "xtensor/xarray.hpp"
|
||||
#include "xtensor/xadapt.hpp"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
inline bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue