Skip to content

Commit

Permalink
less copying
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinPrivitera committed Mar 26, 2024
1 parent ed40d6f commit 4563567
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/libs/blueprint/conduit_blueprint_mesh_matset_xforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,9 +1561,6 @@ to_silo(const conduit::Node &specset,
const int_accessor silo_mix_mat = silo_matset["mix_mat"].value();
const int_accessor silo_mix_next = silo_matset["mix_next"].value();

std::vector<int> speclist;
std::vector<int> mix_spec;

auto calculate_species_index = [&](const int zoneId, const int mat_index)
{
// To get the value for the speclist for this zone, we must determine
Expand Down Expand Up @@ -1612,6 +1609,10 @@ to_silo(const conduit::Node &specset,
// our negative 1-index into the mix_spec array
int mix_start_index = -1;

dest["speclist"].set(DataType::int64(nzones));
int64_array speclist = dest["speclist"].value();
std::vector<int> mix_spec;

// now we create the speclist and mix_spec arrays, traversing through the zones
for (int zoneId = 0; zoneId < nzones; zoneId ++)
{
Expand All @@ -1624,14 +1625,14 @@ to_silo(const conduit::Node &specset,
// I can use the material number to determine which part of the speclist to index into
const int &matno = matlist_entry;
const int mat_index = matmap_map[matno];
speclist.push_back(calculate_species_index(zoneId, mat_index));
speclist[zoneId] = calculate_species_index(zoneId, mat_index);
}
else
{
// mixed

// we save the negated 1-index into the mix_spec array
speclist.push_back(mix_start_index);
speclist[zoneId] = mix_start_index;

// for mixed zones, the numbers in the matlist are negated 1-indices into
// the silo mixed data arrays. To turn them into zero-indices, we must add
Expand Down Expand Up @@ -1666,18 +1667,26 @@ to_silo(const conduit::Node &specset,

// number of materials
dest["nmat"] = nmat;

// number of species associated with each material
// we already saved nmatspec

// indices into species_mf and mix_spec
dest["speclist"].set(speclist.data(), speclist.size());
// we already saved speclist

// length of the species_mf array
dest["nspecies_mf"] = nspecies_mf;

// mass fractions of the matspecies in an array of length nspecies_mf
dest["species_mf"].set(species_mf.data(), species_mf.size());

// array of length mixlen containing indices into the species_mf array
dest["mix_spec"].set(mix_spec.data(), mix_spec.size());

// length of mix_spec array
dest["mixlen"] = mixlen;

// species names
// we already saved species names
}

Expand Down

0 comments on commit 4563567

Please sign in to comment.