Addressing some comments from @promano in the PR.

This commit is contained in:
Patrick Shriwise 2019-03-18 09:48:21 -05:00
parent 44654e7759
commit 2b1d2917f7
3 changed files with 17 additions and 17 deletions

View file

@ -53,8 +53,7 @@ struct RGBColor {
typedef xt::xtensor<RGBColor, 2> ImageData;
struct IdData
{
struct IdData {
// Constructor
IdData(int h_res, int v_res);
@ -65,8 +64,7 @@ struct IdData
xt::xtensor<int32_t, 3> data_; //!< 2D array of cell & material ids
};
struct PropertyData
{
struct PropertyData {
// Constructor
PropertyData(int h_res, int v_res);

View file

@ -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

View file

@ -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<int32_t, 3>({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<double, 3>({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) {