Skip to content

Commit

Permalink
Added field_prefix to the options for conduit::blueprint::mpi::mesh::…
Browse files Browse the repository at this point in the history
…partition_map_back. (#1160)
  • Loading branch information
BradWhitlock committed Aug 30, 2023
1 parent 913a169 commit d495f3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s
#### Relay
- Added ability to read N-dimensional hyperslabs from HDF5 leaf arrays into linear memory arrays.

#### Blueprint
- The `conduit::blueprint::mpi::mesh::partition_map_back()` function was enhanced so it accepts a "field_prefix" value in its options. The prefix is used when looking for the `global_vertex_ids` field, which could have been created with a prefix by the same option in the `conduit::blueprint::mpi::mesh::generate_partition_field()` function.

### Fixed

#### Blueprint
Expand Down
20 changes: 15 additions & 5 deletions src/libs/blueprint/conduit_blueprint_mesh_partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10003,6 +10003,12 @@ Partitioner::map_back_fields(const conduit::Node& repart_mesh,
}
}

// Get a field prefix. Some of the mapping fields used here may have
// used a field_prefix when they were generated.
std::string field_prefix;
if(options.has_child("field_prefix"))
field_prefix = options.fetch_existing("field_prefix").as_string();

// map repart domid -> orig domids
vector<vector<index_t>> map_tgt_domains(repart_doms.size());
// map repart domid -> orig domid -> original elem/vertex ids
Expand Down Expand Up @@ -10044,16 +10050,19 @@ Partitioner::map_back_fields(const conduit::Node& repart_mesh,
// first.
if (has_vert_fields)
{
std::string global_vertex_ids(field_prefix + "global_vertex_ids");

// map of orig domid -> global vert ids
map<index_t, vector<index_t>> orig_dom_gvids;
for (const auto& dom_ent : gid_to_orig_dom)
{
index_t orig_idx = dom_ent.first;
const Node& orig_dom = *dom_ent.second;
const Node& orig_dom_fields = orig_dom.fetch_existing("fields");
vector<index_t>& orig_gvids = orig_dom_gvids[orig_idx];
if (orig_dom["fields"].has_child("global_vertex_ids"))
if (orig_dom_fields.has_child(global_vertex_ids))
{
const index_t_accessor gvids = orig_dom["fields/global_vertex_ids/values"].value();
const index_t_accessor gvids = orig_dom_fields[global_vertex_ids + "/values"].value();
orig_gvids.resize(gvids.number_of_elements());
for (index_t ivert = 0; ivert < gvids.number_of_elements(); ivert++)
{
Expand All @@ -10073,12 +10082,13 @@ Partitioner::map_back_fields(const conduit::Node& repart_mesh,

for (index_t repart_idx = 0; repart_idx < static_cast<index_t>(repart_doms.size()); repart_idx++)
{
const conduit::Node& dom = *repart_doms[repart_idx];
const Node& dom = *repart_doms[repart_idx];
const Node& dom_fields = dom.fetch_existing("fields");

std::unordered_map<index_t, index_t> gvid_to_repart_vid;
if (dom["fields"].has_child("global_vertex_ids"))
if (dom_fields.has_child(global_vertex_ids))
{
const Node& global_vid_node = dom["fields/global_vertex_ids/values"];
const Node& global_vid_node = dom_fields[global_vertex_ids + "/values"];
const index_t_accessor gvids = global_vid_node.value();
for (index_t ivert = 0; ivert < gvids.number_of_elements(); ivert++)
{
Expand Down

0 comments on commit d495f3f

Please sign in to comment.