diff --git a/include/openmc/capi.h b/include/openmc/capi.h index 5e74446f1..617153b6c 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -71,7 +71,7 @@ extern "C" { int openmc_nuclide_name(int index, const char** name); int openmc_plot_geometry(); int openmc_id_map(const void* slice, int32_t *data_out); - int openmc_property_map(void* slice, double *data_out); + int openmc_property_map(const void* slice, double *data_out); int openmc_reset(); int openmc_run(); void openmc_set_seed(int64_t new_seed); diff --git a/openmc/capi/plot.py b/openmc/capi/plot.py index e8d1c06b4..c950f278b 100644 --- a/openmc/capi/plot.py +++ b/openmc/capi/plot.py @@ -236,7 +236,7 @@ def property_map(plot): of OpenMC property ids with dtype float """ - prop_data = np.zeros((plot.vRes, plot.hRes, 2), + 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))) diff --git a/src/plot.cpp b/src/plot.cpp index 5a35ceb40..45782b802 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -1075,19 +1075,18 @@ extern "C" int openmc_id_map(const void* plot, int32_t* data_out) return 0; } -extern "C" int openmc_property_map(void* plot, double* data_out) { +extern "C" int openmc_property_map(const void* plot, double* data_out) { - auto plt = reinterpret_cast(plot); + auto plt = reinterpret_cast(plot); if (!plt) { set_errmsg("Invalid slice pointer passed to openmc_id_map"); return OPENMC_E_INVALID_ARGUMENT; } - PropertyData data = plt->get_property_map(); + PropertyData props = plt->get_property_map(); // write id data to array - size_t i = 0; - for (auto v : data) { data_out[i++] = v; } + std::copy(props.begin(), props.end(), data_out); return 0; } diff --git a/tests/unit_tests/test_capi.py b/tests/unit_tests/test_capi.py index 1d2fb2ecb..14dac21fc 100644 --- a/tests/unit_tests/test_capi.py +++ b/tests/unit_tests/test_capi.py @@ -430,13 +430,11 @@ def test_property_map(capi_init): s = openmc.capi.plot._PlotBase() s.width = 1.26 s.height = 1.26 - s.vRes = 3 - s.hRes = 3 + s.v_res = 3 + s.h_res = 3 s.origin = (0.0, 0.0, 0.0) s.basis = 'xy' s.level = -1 properties = openmc.capi.plot.property_map(s) - print(properties) - print(expected_properties) assert np.allclose(expected_properties, properties, atol=1e-04)