diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 54035fd85..a3b5ee4d8 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -98,6 +98,8 @@ enum class PlotColorBy { class PlotBase { public: IdData get_id_map() const; + xt::xtensor get_cell_ids() const; + PropertyData get_property_map() const; private: diff --git a/src/plot.cpp b/src/plot.cpp index e1bc37657..76af0da97 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -711,6 +711,11 @@ IdData PlotBase::get_id_map() const { return generate_data(); } +xt::xtensor PlotBase::get_cell_ids() const { + auto ids = get_id_map(); + return xt::flip(xt::view(ids.data, xt::all(), xt::all(), 0), 0); +} + PropertyData PlotBase::get_property_map() const { return generate_data(); } @@ -965,30 +970,23 @@ void create_voxel(Plot pl) int id; for (int z = 0; z < pl.pixels_[2]; z++) { pb.set_value(100.*(double)z/(double)(pl.pixels_[2]-1)); - for (int y = 0; y < pl.pixels_[1]; y++) { - for (int x = 0; x < pl.pixels_[0]; x++) { - // get voxel color - position_rgb(p, pl, rgb, id); - // write to plot data - data[y][x] = id; - // advance particle in x direction - p.r().x += vox[0]; - } - // advance particle in y direction - p.r().y += vox[1]; - p.r().x = ll[0]; - } - // advance particle in z direction - p.r().z += vox[2]; - p.r().y = ll[1]; - p.r().x = ll[0]; + PlotBase pltbase; + pltbase.width_ = pl.width_; + pltbase.origin_ = pl.origin_; + pltbase.basis_ = PlotBasis::xy; + pltbase.pixels_ = pl.pixels_; + pltbase.level_ = pl.level_; + + pl.origin_.z += ll.z + z * vox[2]; + + auto data = pltbase.get_cell_ids(); + // Write to HDF5 dataset - voxel_write_slice(z, dspace, dset, memspace, &(data[0])); + voxel_write_slice(z, dspace, dset, memspace, &(data(0,0))); } voxel_finalize(dspace, dset, memspace); file_close(file_id); - } void diff --git a/tests/regression_tests/plot/plots.xml b/tests/regression_tests/plot/plots.xml index ecfe69125..078666e75 100644 --- a/tests/regression_tests/plot/plots.xml +++ b/tests/regression_tests/plot/plots.xml @@ -24,7 +24,7 @@ - 100 100 10 + 500 500 500 0. 0. 0. 20 20 10