From 2f68ab112d8ef389766505887ed291b39c9ec9ef Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 19 Jul 2019 09:09:59 -0500 Subject: [PATCH] Update use of xtensor within code --- src/eigenvalue.cpp | 5 +++-- src/mesh.cpp | 4 ++-- src/photon.cpp | 9 +++------ src/settings.cpp | 3 +-- src/tallies/tally.cpp | 6 ++---- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/eigenvalue.cpp b/src/eigenvalue.cpp index a0b7f82c5f..894157c5b0 100644 --- a/src/eigenvalue.cpp +++ b/src/eigenvalue.cpp @@ -572,8 +572,9 @@ void ufs_count_sites() // distributed so that effectively the production of fission sites is not // biased - auto s = xt::view(simulation::source_frac, xt::all()); - s = simulation::ufs_mesh->volume_frac_; + std::size_t n = simulation::ufs_mesh->n_bins(); + double vol_frac = simulation::ufs_mesh->volume_frac_; + simulation::source_frac = xt::xtensor({n}, vol_frac); } else { // count number of source sites in each ufs mesh cell diff --git a/src/mesh.cpp b/src/mesh.cpp index 9e27fc4e6a..590df53e17 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -155,8 +155,8 @@ RegularMesh::RegularMesh(pugi::xml_node node) fatal_error("Must specify either and on a mesh."); } - // TODO: Change to zero when xtensor is updated - if (shape_.size() > 1) { + // Make sure lower_left and dimension match + if (shape_.size() > 0) { if (shape_.size() != lower_left_.size()) { fatal_error("Number of entries on must be the same " "as the number of entries on ."); diff --git a/src/photon.cpp b/src/photon.cpp index 929822bfcf..a2365de5f3 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -181,8 +181,7 @@ PhotonInteraction::PhotonInteraction(hid_t group, int i_element) read_dataset(rgroup, "J", profile_pdf_); // Get Compton profile momentum grid. By deafult, an xtensor has a size of 1. - // TODO: Change to zero when xtensor is updated - if (data::compton_profile_pz.size() == 1) { + if (data::compton_profile_pz.size() == 0) { read_dataset(rgroup, "pz", data::compton_profile_pz); } close_group(rgroup); @@ -213,8 +212,7 @@ PhotonInteraction::PhotonInteraction(hid_t group, int i_element) // Get energy grids used for bremsstrahlung DCS and for stopping powers xt::xtensor electron_energy; read_dataset(rgroup, "electron_energy", electron_energy); - // TODO: Change to zero when xtensor is updated - if (data::ttb_k_grid.size() == 1) { + if (data::ttb_k_grid.size() == 0) { read_dataset(rgroup, "photon_energy", data::ttb_k_grid); } @@ -255,8 +253,7 @@ PhotonInteraction::PhotonInteraction(hid_t group, int i_element) } // Set incident particle energy grid - // TODO: Change to zero when xtensor is updated - if (data::ttb_e_grid.size() == 1) { + if (data::ttb_e_grid.size() == 0) { data::ttb_e_grid = electron_energy; } diff --git a/src/settings.cpp b/src/settings.cpp index 796a2862ad..b647d32e86 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -512,8 +512,7 @@ void read_settings_xml() if (!m) fatal_error("Only regular meshes can be used as an entropy mesh"); simulation::entropy_mesh = m; - // TODO: Change to zero when xtensor is updated - if (m->shape_.size() == 1) { + if (m->shape_.size() == 0) { // If the user did not specify how many mesh cells are to be used in // each direction, we automatically determine an appropriate number of // cells diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index eea43989ef..852918a0cd 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -810,8 +810,7 @@ void Tally::init_results() void Tally::reset() { n_realizations_ = 0; - // TODO: Change to zero when xtensor is updated - if (results_.size() != 1) { + if (results_.size() != 0) { xt::view(results_, xt::all()) = 0.0; } } @@ -1399,8 +1398,7 @@ openmc_tally_results(int32_t index, double** results, size_t* shape) } const auto& t {model::tallies[index]}; - // TODO: Change to zero when xtensor is updated - if (t->results_.size() == 1) { + if (t->results_.size() == 0) { set_errmsg("Tally results have not been allocated yet."); return OPENMC_E_ALLOCATE; }