Corrections after rebase.

This commit is contained in:
Patrick Shriwise 2020-10-26 13:14:25 -05:00
parent 80e62611c1
commit ba6816d4df
2 changed files with 100 additions and 84 deletions

View file

@ -222,8 +222,6 @@ public:
double negative_grid_boundary(int* ijk, int i) const override;
int n_surface_bins() const override;
std::pair<std::vector<double>, std::vector<double>>
plot(Position plot_ll, Position plot_ur) const override;
@ -294,6 +292,9 @@ public:
//! Add a variable to the mesh instance
virtual void add_score(const std::string& var_name) = 0;
//! Remove variable from the mesh instance
virtual void remove_score(const std::string& var_name) = 0;
//! Set the value of a bin for a variable on the mesh instance
virtual void set_score_data(const std::string& var_name,
std::vector<double> values,
@ -324,6 +325,15 @@ public:
void to_hdf5(hid_t group) const override;
//! Count number of bank sites in each mesh bin / energy bin
//
//! \param[in] bank Array of bank sites
//! \param[out] Whether any bank sites are outside the mesh
//! \return Array indicating number of sites in each mesh/energy bin
xt::xtensor<double, 1> count_sites(const Particle::Bank* bank,
int64_t length,
bool* outside) const;
// Data members
bool output_ {true};
std::string filename_; //!< Path to unstructured mesh file
@ -370,7 +380,7 @@ public:
std::vector<double> std_dev) override;
//! Remove a score from the mesh instance
void remove_score(std::string score) const;
void remove_score(const std::string& score) override;
//! Set data for a score
void set_score_data(const std::string& score,
@ -517,6 +527,8 @@ public:
void add_score(const std::string& var_name) override;
void remove_score(const std::string& var_name) override;
void set_score_data(const std::string& var_name,
std::vector<double> values,
std::vector<double> std_dev) override;

View file

@ -162,7 +162,7 @@ UnstructuredMesh::to_hdf5(hid_t group) const
write_dataset(mesh_group, "library", this->library());
// write volume of each tet
std::vector<double> tet_vols;
xt::xtensor<double, 2> centroids({this->n_bins(), 3});
xt::xtensor<double, 2> centroids({(size_t)this->n_bins(), 3});
for (int i = 0; i < this->n_bins(); i++) {
tet_vols.emplace_back(this->volume(i));
auto c = this->centroid(i);
@ -180,90 +180,90 @@ UnstructuredMesh::to_hdf5(hid_t group) const
// RegularMesh implementation
//==============================================================================
RegularMesh::RegularMesh(pugi::xml_node node)
: StructuredMesh {node}
{
// Determine number of dimensions for mesh
if (check_for_node(node, "dimension")) {
shape_ = get_node_xarray<int>(node, "dimension");
int n = n_dimension_ = shape_.size();
if (n != 1 && n != 2 && n != 3) {
fatal_error("Mesh must be one, two, or three dimensions.");
}
// RegularMesh::RegularMesh(pugi::xml_node node)
// : StructuredMesh {node}
// {
// // Determine number of dimensions for mesh
// if (check_for_node(node, "dimension")) {
// shape_ = get_node_xarray<int>(node, "dimension");
// int n = n_dimension_ = shape_.size();
// if (n != 1 && n != 2 && n != 3) {
// fatal_error("Mesh must be one, two, or three dimensions.");
// }
// Check that dimensions are all greater than zero
if (xt::any(shape_ <= 0)) {
fatal_error("All entries on the <dimension> element for a tally "
"mesh must be positive.");
}
}
// // Check that dimensions are all greater than zero
// if (xt::any(shape_ <= 0)) {
// fatal_error("All entries on the <dimension> element for a tally "
// "mesh must be positive.");
// }
// }
// Check for lower-left coordinates
if (check_for_node(node, "lower_left")) {
// Read mesh lower-left corner location
lower_left_ = get_node_xarray<double>(node, "lower_left");
} else {
fatal_error("Must specify <lower_left> on a mesh.");
}
// // Check for lower-left coordinates
// if (check_for_node(node, "lower_left")) {
// // Read mesh lower-left corner location
// lower_left_ = get_node_xarray<double>(node, "lower_left");
// } else {
// fatal_error("Must specify <lower_left> on a mesh.");
// }
if (check_for_node(node, "width")) {
// Make sure both upper-right or width were specified
if (check_for_node(node, "upper_right")) {
fatal_error("Cannot specify both <upper_right> and <width> on a mesh.");
}
// if (check_for_node(node, "width")) {
// // Make sure both upper-right or width were specified
// if (check_for_node(node, "upper_right")) {
// fatal_error("Cannot specify both <upper_right> and <width> on a mesh.");
// }
width_ = get_node_xarray<double>(node, "width");
// width_ = get_node_xarray<double>(node, "width");
// Check to ensure width has same dimensions
auto n = width_.size();
if (n != lower_left_.size()) {
fatal_error("Number of entries on <width> must be the same as "
"the number of entries on <lower_left>.");
}
// // Check to ensure width has same dimensions
// auto n = width_.size();
// if (n != lower_left_.size()) {
// fatal_error("Number of entries on <width> must be the same as "
// "the number of entries on <lower_left>.");
// }
// Check for negative widths
if (xt::any(width_ < 0.0)) {
fatal_error("Cannot have a negative <width> on a tally mesh.");
}
// // Check for negative widths
// if (xt::any(width_ < 0.0)) {
// fatal_error("Cannot have a negative <width> on a tally mesh.");
// }
// Set width and upper right coordinate
upper_right_ = xt::eval(lower_left_ + shape_ * width_);
// // Set width and upper right coordinate
// upper_right_ = xt::eval(lower_left_ + shape_ * width_);
} else if (check_for_node(node, "upper_right")) {
upper_right_ = get_node_xarray<double>(node, "upper_right");
// } else if (check_for_node(node, "upper_right")) {
// upper_right_ = get_node_xarray<double>(node, "upper_right");
// Check to ensure width has same dimensions
auto n = upper_right_.size();
if (n != lower_left_.size()) {
fatal_error("Number of entries on <upper_right> must be the "
"same as the number of entries on <lower_left>.");
}
// // Check to ensure width has same dimensions
// auto n = upper_right_.size();
// if (n != lower_left_.size()) {
// fatal_error("Number of entries on <upper_right> must be the "
// "same as the number of entries on <lower_left>.");
// }
// Check that upper-right is above lower-left
if (xt::any(upper_right_ < lower_left_)) {
fatal_error("The <upper_right> coordinates must be greater than "
"the <lower_left> coordinates on a tally mesh.");
}
// // Check that upper-right is above lower-left
// if (xt::any(upper_right_ < lower_left_)) {
// fatal_error("The <upper_right> coordinates must be greater than "
// "the <lower_left> coordinates on a tally mesh.");
// }
// Set width
if (shape_.size() > 0) {
width_ = xt::eval((upper_right_ - lower_left_) / shape_);
}
} else {
fatal_error("Must specify either <upper_right> and <width> on a mesh.");
}
// // Set width
// if (shape_.size() > 0) {
// width_ = xt::eval((upper_right_ - lower_left_) / shape_);
// }
// } else {
// fatal_error("Must specify either <upper_right> and <width> on a mesh.");
// }
// 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>.");
}
// // 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>.");
// }
// Set volume fraction
volume_frac_ = 1.0/xt::prod(shape_)();
}
}
// // Set volume fraction
// volume_frac_ = 1.0/xt::prod(shape_)();
// }
// }
void StructuredMesh::get_indices(Position r, int* ijk, bool* in_mesh) const
{
@ -2087,7 +2087,7 @@ MOABUnstructuredMesh::add_score(const std::string& score) {
auto score_tags = get_score_tags(score);
}
void UnstructuredMesh::remove_score(std::string score) const {
void MOABUnstructuredMesh::remove_score(const std::string& score) {
auto value_name = score + "_mean";
moab::Tag tag;
moab::ErrorCode rval = mbi_->tag_get_handle(value_name.c_str(), tag);
@ -2163,16 +2163,14 @@ MOABUnstructuredMesh::write(std::string base_filename) const {
auto msg = fmt::format("Failed to write unstructured mesh {}", id_);
warning(msg);
}
}
xt::xarray<double>
UnstructuredMesh::count_sites(const std::vector<Particle::Bank>& bank,
bool* outside) const {
xt::array<double> out;
xt::xtensor<double, 1>
UnstructuredMesh::count_sites(const Particle::Bank* bank,
int64_t length,
bool* outside) const {
xt::xtensor<double, 1> out;
return out;
}
double UnstructuredMesh::get_volume_frac(int bin = -1) const {
return 0.0;
}
#endif
@ -2263,6 +2261,12 @@ LibMesh::add_score(const std::string& var_name) {
}
}
void
LibMesh::remove_score(const std::string& var_name) {
return;
}
void
LibMesh::set_score_data(const std::string& var_name,
std::vector<double> values,