Skip to content

Commit

Permalink
relay mesh blueprint save / load improvements (#613)
Browse files Browse the repository at this point in the history
* refactor  relay::blueprint mesh write and read methods

* mesh bp index gen, fix bug with support for new matset flavors

* wrap more mesh bp examples into the blueprint.mesh.examples python module

* bugfix for hdf5 compat check vs conduit empty nodes

* tests for write_mesh opts, cleanup

* lots of moving parts, refactor to simplify testing logic, break out new tests, etc

* use write, read vs save load, to be consistent with other uses related to file creation and or append

* mover barrier into write_mesh -- to avoid fs races out of the box
  • Loading branch information
cyrush committed Sep 16, 2020
1 parent ef03d1a commit 1c58df8
Show file tree
Hide file tree
Showing 34 changed files with 2,091 additions and 508 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s
- Added the conduit.relay.mpi Python module to support Relay MPI in Python.
- Added support to write and read Conduit lists to HDF5 files. Since HDF5 Groups do not support unnamed indexed children, each list child is written using a string name that represents its index and a special attribute is written to the HDF5 group to mark the list case. On read, the special attribute is used to detect and read this style of group back into a Conduit list.
- Added preliminary support to read Sidre Datastore-style HDF5 using Relay IOHandle, those grouped with a root file.
- Added `conduit::relay::io::blueprint::load_mesh` functions, were pulled in from Ascent's Blueprint import logic.
- Added `conduit::relay::io::blueprint::read_mesh` functions, were pulled in from Ascent's Blueprint import logic.

#### Blueprint
- Added support for sparse one-to-many relationships with the new `blueprint::o2mrelation` protocol. See the `blueprint::o2mrelation::examples::uniform` example for details.
Expand All @@ -38,6 +38,7 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s
- Added `blueprint::mesh::number_of_domains` property method for trees that conform to the mesh blueprint.
- Added MPI mesh blueprint methods, `blueprint::mpi::mesh::verify` and `blueprint::mpi::mesh::number_of_domains` (available in the `conduit_blueprint_mpi` library)
- Added `blueprint::mpi::mesh::examples::braid_uniform_multi_domain` and `blueprint::mpi::mesh::examples::spiral_round_robin` distributed-memory mesh examples to the `conduit_blueprint_mpi` library.
- Added `state/path` to the Mesh Blueprint index, needed for consumers to know the proper path to read extended state info (such as `domain_id`)


### Fixed
Expand All @@ -49,6 +50,7 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s

#### Relay
- Use H5F_ACC_RDONLY in relay::io::is_hdf5_file to avoid errors when checking files that already have open HDF5 handles.
- Fixed compatibility check for empty Nodes against HDF5 files with existing paths

### Changed

Expand All @@ -64,8 +66,8 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s

#### Relay
- Provide more context when a Conduit Node cannot be written to a HDF5 file because it is incompatible with the existing HDF5 tree. Error messages now provide the full path and details about the incompatibility.
- `conduit::relay::io_blueprint::save` functions are deprecated in favor of `conduit::relay::io::blueprint::save_mesh`
- `conduit::relay::io::blueprint::save_mesh` functions were pulled in from Ascent's Blueprint export logic.
- `conduit::relay::io_blueprint::save` functions are deprecated in favor of `conduit::relay::io::blueprint::write_mesh`
- `conduit::relay::io::blueprint::write_mesh` functions were pulled in from Ascent's Blueprint export logic.
- `conduit_relay_io_mpi` lib now depends on `conduit_relay_io`. Due to this change, a single build supports either ADIOS serial (no-mpi) or ADIOS with MPI support, but not both. If conduit is configured with MPI support, ADIOS MPI is used.


Expand Down
63 changes: 50 additions & 13 deletions src/libs/blueprint/conduit_blueprint_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2445,17 +2445,25 @@ mesh::generate_index(const Node &mesh,
index_out.reset();

index_out["state/number_of_domains"] = number_of_domains;

// check if the input mesh has state/cycle state/time
// if so, add those to the index
if(mesh.has_path("state/cycle"))
{
index_out["state/cycle"].set(mesh["state/cycle"]);
}

if(mesh.has_path("state/time"))

if(mesh.has_child("state"))
{
index_out["state/time"].set(mesh["state/time"]);
// check if the input mesh has state/cycle state/time
// if so, add those to the index
if(mesh.has_path("state/cycle"))
{
index_out["state/cycle"].set(mesh["state/cycle"]);
}

if(mesh.has_path("state/time"))
{
index_out["state/time"].set(mesh["state/time"]);
}
// state may contain other important stuff, like
// the domain_id, so we need a way to read it
// from the index
index_out["state/path"] = join_path(ref_path, "state");
}

NodeConstIterator itr = mesh["coordsets"].children();
Expand Down Expand Up @@ -2569,11 +2577,40 @@ mesh::generate_index(const Node &mesh,
Node &idx_matset = index_out["matsets"][matset_name];

idx_matset["topology"] = matset["topology"].as_string();
NodeConstIterator mats_itr = matset["volume_fractions"].children();
while(mats_itr.has_next())

// support different flavors of valid matset protos
if(matset.has_child("material_map"))
{
NodeConstIterator mats_itr = matset["material_map"].children();
while(mats_itr.has_next())
{
mats_itr.next();
idx_matset["materials"][mats_itr.name()];
}
}
else if(matset.has_child("materials"))
{
NodeConstIterator mats_itr = matset["materials"].children();
while(mats_itr.has_next())
{
mats_itr.next();
idx_matset["materials"][mats_itr.name()];
}
}
else if(matset.has_child("volume_fractions"))
{
NodeConstIterator mats_itr = matset["volume_fractions"].children();
while(mats_itr.has_next())
{
mats_itr.next();
idx_matset["materials"][mats_itr.name()];
}
}
else // surprise!
{
mats_itr.next();
idx_matset["materials"][mats_itr.name()];
CONDUIT_ERROR("blueprint::mesh::generate_index: "
"Invalid matset flavor."
"Input node does not conform to mesh blueprint.");
}

std::string ms_ref_path = join_path(ref_path, "matsets");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ void venn(const std::string &matset_type,
res["meta/importance/c"] = c_importance;

// Shape in materials; compute fields with matset values.
std::cout << "[Shaping in materials]" << std::endl;

if (matset_type == "full")
{
Expand Down
Loading

0 comments on commit 1c58df8

Please sign in to comment.