Update use of xtensor within code

This commit is contained in:
Paul Romano 2019-07-19 09:09:59 -05:00
parent 833680d6a7
commit 2f68ab112d
5 changed files with 11 additions and 16 deletions

View file

@ -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<double, 1>({n}, vol_frac);
} else {
// count number of source sites in each ufs mesh cell

View file

@ -155,8 +155,8 @@ RegularMesh::RegularMesh(pugi::xml_node node)
fatal_error("Must specify either <upper_right> and <width> 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 <lower_left> must be the same "
"as the number of entries on <dimension>.");

View file

@ -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<double, 1> 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;
}

View file

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

View file

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