add mesh bp remove util#1607
Conversation
|
TODO: Test cases are WIP, need to add many more:
|
|
presence of * as category name indicates that we should remove everything from that category will fully remove for state, other than |
|
added specset test and python interface and python test |
|
There are many places we could leverage this (perhaps in Silo tests) that would provide additional testing coverage. |
JustinPrivitera
left a comment
There was a problem hiding this comment.
Reviewing now. Are you going to add a changelog entry?
|
Thanks, yes I will add Change log entry |
…nduit into task/2026_05_mesh_bp_remove_util
JustinPrivitera
left a comment
There was a problem hiding this comment.
Love the lambdas. I have some comments about a few things.
| std::regex comp_regex(comp_pat_adj); | ||
| if(std::regex_match(comp_name, comp_regex)) | ||
| { | ||
| //std::cout << "true" << std::endl; | ||
| n_comp.remove(comp_name); | ||
| } |
There was a problem hiding this comment.
I don't understand why we need to do regex match again. We already used it earlier to populate the set, so can't we just remove everything in the set unconditionally?
There was a problem hiding this comment.
The set contains the regex, not the expanded names.
The prior walk explicitly records dependents, but the outer matches are not explicitly recorded.
There was a problem hiding this comment.
I see. The set gets populated even further above in init_set_from_opts.
| // past to clean up matsets | ||
| // matsets: for any field that refs a matset, | ||
| // remove that ref and any matset values | ||
|
|
||
| for(size_t i = 0; i < domains.size(); i++) | ||
| { | ||
| conduit::Node *dom = domains[i]; |
There was a problem hiding this comment.
Why not remove fields that depend on a matset entirely? The field may or may not be in a valid state after the operation you've implemented here. If the field is material-dependent, then it will still be valid, but if it is mixed (https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html#fields), then it is no longer valid and should be removed entirely.
There was a problem hiding this comment.
fully material-dependent is rare, usually values exists and is useful even without the matset values. That said, I this should check for that case.
Matset values can be very large, removing them when not needed is a savings if folks only want to save or process the overall field values.
There was a problem hiding this comment.
- check for material-dependent case (no values), and remove field if when no useful data is left over.
There was a problem hiding this comment.
I think it is sufficient to check for the existence of values after scrubbing the matset association, and remove if there are no values. However, fields are handled differently from everything else in remove. Maybe there is an option to aggressively remove fields versus conservatively removing them? It just seems like an unexpected behavior of the function. If I am removing a matset would I not want associated fields to also be removed? I think both choices are valid.
There was a problem hiding this comment.
The relationship between fields and matsets is a bit different.
I think removing the entire field is too aggressive in this case b/c it removes data that is still useful.
Most viz uses cases will use values and never touch matset values unless the user is doing something sophisticated.
They can always remove any field fully by name or pattern.
| // removing the matset should remove the specset as well | ||
| EXPECT_TRUE(n_mesh.has_path("matsets/mesh")); | ||
| EXPECT_FALSE(n_mesh.has_path("specsets/mesh")); |
There was a problem hiding this comment.
| // removing the matset should remove the specset as well | |
| EXPECT_TRUE(n_mesh.has_path("matsets/mesh")); | |
| EXPECT_FALSE(n_mesh.has_path("specsets/mesh")); | |
| // removing the matset should remove the specset as well | |
| EXPECT_FALSE(n_mesh.has_path("matsets/mesh")); | |
| EXPECT_FALSE(n_mesh.has_path("specsets/mesh")); |
There was a problem hiding this comment.
looks like this was copied from above and not updated to reflect the comment. It doesn't test what the comment says it does.
There was a problem hiding this comment.
It is a copy and paste problem -- but the above comment is what is wrong.
In this case we are removing the specset, that matset should still exist.
There was a problem hiding this comment.
No, look closer - this test is copied from the case right before it. Right now both tests are identical. It makes sense to test three cases for specsets:
- removing a specset, which is tested twice
- removing a matset which should remove the specset also, which your comment suggested you wanted to test, but is not tested as things currently stand
- removing a topo which should remove the matset which should remove the specset, which is tested at the end
I think you want to keep the original comment and fix the options that are tested and the resulting EXPECT_***.
There was a problem hiding this comment.
thank, you I think have this sorted out now. Can you take one more look?
There was a problem hiding this comment.
currently we can either give a name or give "*"? Do we want to support "*_name" or any other regex stuff?
There was a problem hiding this comment.
See my comment about glob vs regex, I will work on support for that so that * isn't a special case
Co-authored-by: Justin Privitera <35237779+JustinPrivitera@users.noreply.github.com>
|
For filtering, what we really want is glob matching, not regex matching. We can convert glob style matching into a regex, I will add a utility to do that. This will also be useful in other cases (extending mesh blueprint read to read subsets of a mesh with same style of args used here) |
| { | ||
| conduit::blueprint::mesh::examples::generate("misc",n_mesh); | ||
| EXPECT_TRUE(n_mesh.has_path("topologies/mesh")); | ||
| EXPECT_TRUE(n_mesh.has_path("fields/radial")); | ||
| EXPECT_TRUE(n_mesh.has_path("matsets/mesh")); | ||
| EXPECT_TRUE(n_mesh.has_path("specsets/mesh")); | ||
|
|
||
| n_opts.reset(); | ||
| n_opts["specsets"] = "mesh"; | ||
|
|
||
| echo_node("[before]",n_mesh); | ||
| echo_node("[options]",n_opts); | ||
| conduit::blueprint::mesh::remove(n_opts,n_mesh); | ||
| EXPECT_TRUE(conduit::blueprint::mesh::verify(n_mesh, n_info)); | ||
| echo_node("[after]",n_mesh); | ||
| echo_node("[info]",n_info); | ||
|
|
||
| // after removing specset, matset should remain | ||
| EXPECT_TRUE(n_mesh.has_path("matsets/mesh")); | ||
| EXPECT_FALSE(n_mesh.has_path("specsets/mesh")); |
There was a problem hiding this comment.
this test should be updated to test removing a matset: #1607 (comment)
There was a problem hiding this comment.
I think this is sorted, please give it one more look (sorry for the double comment)
|
I created a glob match util and remove refactored to use it. |
add
conduit::mesh::blueprint::remove, which allows you to remove components of a mesh (like topologies, fields, etc) along with there dependencies.For example, removing a topology will remove any fields defined on that topology, removing a matset will remove references and matset specific values for any related fields.