mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Making pointer for property_map const and fixing property_map tests.
This commit is contained in:
parent
b9a57b02d4
commit
cdaad6ad54
4 changed files with 8 additions and 11 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
|
|
@ -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<PlotBase*>(plot);
|
||||
auto plt = reinterpret_cast<const PlotBase*>(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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue