Another fix to this pesky data writing problem - need contiguous memory.

This commit is contained in:
Patrick Shriwise 2020-02-18 18:29:57 -06:00
parent dc7bc30b88
commit 13c5348cd5
3 changed files with 12 additions and 8 deletions

View file

@ -387,8 +387,8 @@ public:
//! Set data for a score
void set_score_data(const std::string& score,
xt::xarray<double> values,
xt::xarray<double> sum_sq) const;
std::vector<double> values,
std::vector<double> sum_sq) const;
//! Write the mesh with any current tally data
void write(std::string base_filename) const;

View file

@ -2081,13 +2081,13 @@ UnstructuredMesh::add_score(std::string score) const {
void
UnstructuredMesh::set_score_data(const std::string& score,
xt::xarray<double> values,
xt::xarray<double> sum_sq) const {
std::vector<double> values,
std::vector<double> sum_sq) const {
auto score_tags = get_score_tags(score);
moab::ErrorCode rval;
// set the score value
rval = mbi_->tag_set_data(score_tags.first, ehs_, &values);
rval = mbi_->tag_set_data(score_tags.first, ehs_, &values.front());
if (rval != moab::MB_SUCCESS) {
std::stringstream msg;
msg << "Failed to set the tally value for score '" << score << "' "
@ -2096,7 +2096,7 @@ UnstructuredMesh::set_score_data(const std::string& score,
}
// set the error value
rval = mbi_->tag_set_data(score_tags.second, ehs_, &sum_sq);
rval = mbi_->tag_set_data(score_tags.second, ehs_, &sum_sq.front());
if (rval != moab::MB_SUCCESS) {
std::stringstream msg;
msg << "Failed to set the tally value for score '" << score << "' "

View file

@ -842,10 +842,14 @@ void Tally::accumulate()
if (umesh) {
for (auto score : scores_) {
umesh->add_score(std::to_string(score));
auto values = xt::view(results_, xt::all(), 0, TallyResult::VALUE);
auto sum_sq = xt::view(results_, xt::all(), 0, TallyResult::SUM_SQ);
std::vector<double> vals_vec(values.begin(), values.end());
std::vector<double> sum_sq_vec(sum_sq.begin(), sum_sq.end());
for (int i = 0; i < results_.shape()[0]; i++) {
umesh->set_score_data(std::to_string(score),
xt::view(results_, xt::all(), 0, TallyResult::VALUE),
xt::view(results_, xt::all(), 0, TallyResult::SUM_SQ));
vals_vec,
sum_sq_vec);
}
}
std::stringstream output_filename;