diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 08797c33b..f6f8c7ea7 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -53,8 +53,7 @@ struct RGBColor { typedef xt::xtensor ImageData; -struct IdData -{ +struct IdData { // Constructor IdData(int h_res, int v_res); @@ -65,8 +64,7 @@ struct IdData xt::xtensor data_; //!< 2D array of cell & material ids }; -struct PropertyData -{ +struct PropertyData { // Constructor PropertyData(int h_res, int v_res); diff --git a/openmc/capi/plot.py b/openmc/capi/plot.py index 7e429be6c..f9873f4bd 100644 --- a/openmc/capi/plot.py +++ b/openmc/capi/plot.py @@ -214,14 +214,18 @@ def id_map(plot): """ img_data = np.zeros((plot.v_res, plot.h_res, 2), dtype=np.dtype('int32')) - _dll.openmc_id_map(POINTER(_PlotBase)(plot), - img_data.ctypes.data_as(POINTER(c_int32))) + _dll.openmc_id_map(plot, img_data.ctypes.data_as(POINTER(c_int32))) return img_data +_dll.openmc_id_map.argtypes = [POINTER(_PlotBase), POINTER(c_double)] +_dll.openmc_id_map.restype = c_int +_dll.openmc_id_map.errcheck = _error_handler + + def property_map(plot): """ - Generate a 2-D map of (cell_temperature, material_density). Used for + Generate a 2-D map of cell temperature and material density. Used for in-memory image generation. Parameters @@ -236,8 +240,6 @@ def property_map(plot): OpenMC property ids with dtype float """ - prop_data = np.zeros((plot.v_res, plot.h_res, 2), - dtype=np.dtype('float')) - _dll.openmc_property_map(POINTER(_PlotBase)(plot), - prop_data.ctypes.data_as(POINTER(c_double))) + prop_data = np.zeros((plot.v_res, plot.h_res, 2)) + _dll.openmc_property_map(plot, prop_data.ctypes.data_as(POINTER(c_double))) return prop_data diff --git a/src/plot.cpp b/src/plot.cpp index edb50ed09..9b5f5c3bc 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -32,9 +32,9 @@ const RGBColor WHITE {255, 255, 255}; constexpr int PLOT_LEVEL_LOWEST {-1}; //!< lower bound on plot universe level constexpr int32_t NOT_FOUND {-2}; -IdData::IdData(int h_res, int v_res) { - data_ = xt::xtensor({v_res, h_res, 2}, NOT_FOUND); -} +IdData::IdData(int h_res, int v_res) + : data_({v_res, h_res, 2}, NOT_FOUND) +{ } void IdData::set_value(int y, int x, const Particle& p, int level) { @@ -49,9 +49,9 @@ IdData::set_value(int y, int x, const Particle& p, int level) { } } -PropertyData::PropertyData(int h_res, int v_res) { - data_ = xt::xtensor({v_res, h_res, 2}, NOT_FOUND); -} +PropertyData::PropertyData(int h_res, int v_res) + : data_({v_res, h_res, 2}, NOT_FOUND) +{ } void PropertyData::set_value(int y, int x, const Particle& p, int level) {