-
Notifications
You must be signed in to change notification settings - Fork 580
load mesh objects from weight_windows.h5 file #3598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
3329b41
1074e77
a2c05a8
869b107
1784abc
38c90d9
795b6d5
8286f4a
3966ccb
5afbae1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -238,6 +238,17 @@ Mesh::Mesh(pugi::xml_node node) | |||||||||
| name_ = get_node_value(node, "name"); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| Mesh::Mesh(hid_t group) | ||||||||||
| { | ||||||||||
| // Read mesh ID | ||||||||||
| read_attribute(group, "id", id_); | ||||||||||
|
|
||||||||||
| // Read mesh name | ||||||||||
| if (object_exists(group, "name")) { | ||||||||||
| read_dataset(group, "name", name_); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| void Mesh::set_id(int32_t id) | ||||||||||
| { | ||||||||||
| assert(id >= 0 || id == C_NONE); | ||||||||||
|
|
@@ -627,6 +638,46 @@ UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| UnstructuredMesh::UnstructuredMesh(hid_t group) : Mesh(group) | ||||||||||
| { | ||||||||||
| n_dimension_ = 3; | ||||||||||
|
|
||||||||||
| // check the mesh type | ||||||||||
| if (object_exists(group, "type")) { | ||||||||||
| std::string temp; | ||||||||||
| read_dataset(group, "type", temp); | ||||||||||
| if (temp != mesh_type) { | ||||||||||
| fatal_error(fmt::format("Invalid mesh type: {}", temp)); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // check if a length unit multiplier was specified | ||||||||||
| if (object_exists(group, "length_multiplier")) { | ||||||||||
| read_dataset(group, "length_multiplier", length_multiplier_); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // get the filename of the unstructured mesh to load | ||||||||||
| if (object_exists(group, "filename")) { | ||||||||||
| read_dataset(group, "filename", filename_); | ||||||||||
| if (!file_exists(filename_)) { | ||||||||||
| fatal_error("Mesh file '" + filename_ + "' does not exist!"); | ||||||||||
| } | ||||||||||
| } else { | ||||||||||
| fatal_error(fmt::format( | ||||||||||
| "No filename supplied for unstructured mesh with ID: {}", id_)); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (attribute_exists(group, "options")) { | ||||||||||
| read_attribute(group, "options", options_); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // check if mesh tally data should be written with | ||||||||||
| // statepoint files | ||||||||||
| if (attribute_exists(group, "output")) { | ||||||||||
| read_attribute(group, "output", output_); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| void UnstructuredMesh::determine_bounds() | ||||||||||
| { | ||||||||||
| double xmin = INFTY; | ||||||||||
|
|
@@ -1174,6 +1225,73 @@ RegularMesh::RegularMesh(pugi::xml_node node) : StructuredMesh {node} | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| RegularMesh::RegularMesh(hid_t group) : StructuredMesh {group} | ||||||||||
| { | ||||||||||
| // Determine number of dimensions for mesh | ||||||||||
| if (!object_exists(group, "dimension")) { | ||||||||||
| fatal_error("Must specify <dimension> on a regular mesh."); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| xt::xtensor<int, 1> shape; | ||||||||||
| read_dataset(group, "dimension", shape); | ||||||||||
| int n = n_dimension_ = shape.size(); | ||||||||||
| if (n != 1 && n != 2 && n != 3) { | ||||||||||
| fatal_error("Mesh must be one, two, or three dimensions."); | ||||||||||
| } | ||||||||||
| std::copy(shape.begin(), shape.end(), shape_.begin()); | ||||||||||
|
|
||||||||||
| // 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 (object_exists(group, "lower_left")) { | ||||||||||
| // Read mesh lower-left corner location | ||||||||||
| read_dataset(group, "lower_left", lower_left_); | ||||||||||
| } else { | ||||||||||
| fatal_error("Must specify <lower_left> on a mesh."); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Make sure lower_left and dimension match | ||||||||||
| 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>."); | ||||||||||
|
||||||||||
| fatal_error("Number of entries on <lower_left> must be the same " | |
| "as the number of entries on <dimension>."); | |
| fatal_error("Number of entries on lower_left dataset must be the same " | |
| "as the number of entries for the mesh dimension."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other, similar error messages that imply the mesh is read from an XML file that we should probably update below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could factor out some of this logical checking into new methods for RegularMesh and RectilinearMesh like the CylindricalMesh::set_grid method does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to refactor most of the logical checking.
Uh oh!
There was an error while loading. Please reload this page.