| 1 |
// Copyright(C) 1999-2021 National Technology & Engineering Solutions |
| 2 |
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
// NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
// |
| 5 |
// See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
#include "Ioss_SideBlock.h" // for SideBlockContainer |
| 8 |
#include "adios/Ioad_Constants.h" |
| 9 |
#include "adios/Ioad_Helper.h" |
| 10 |
|
| 11 |
namespace Ioad { |
| 12 |
int find_field_in_mapset(const std::string &entity_type, const std::string &field_name, |
| 13 |
const std::map<std::string, std::set<std::string>> &mapset) |
| 14 |
{ |
| 15 |
if (mapset.find(entity_type) == mapset.end()) { |
| 16 |
// No field for this entity_type in the map. |
| 17 |
return 0; |
| 18 |
} |
| 19 |
const std::set<std::string> &entity_set = mapset.at(entity_type); |
| 20 |
if (entity_set.find(field_name) != entity_set.end()) { |
| 21 |
return 1; |
| 22 |
} |
| 23 |
return 0; |
| 24 |
} |
| 25 |
|
| 26 |
std::string get_property_variable_name(const std::string &property_name) |
| 27 |
{ |
| 28 |
return property_meta + property_name; |
| 29 |
} |
| 30 |
|
| 31 |
std::vector<std::string> properties_to_save(const Ioss::GroupingEntity *const entity_block) |
| 32 |
{ |
| 33 |
std::vector<std::string> property_list = entity_block->property_describe(); |
| 34 |
|
| 35 |
for (auto ignore_property : Ignore_properties) { |
| 36 |
property_list.erase(std::remove(property_list.begin(), property_list.end(), ignore_property), |
| 37 |
property_list.end()); |
| 38 |
} |
| 39 |
property_list.erase(std::remove_if(property_list.begin(), property_list.end(), |
| 40 |
[&](std::string property_name) -> bool { |
| 41 |
Ioss::Property property = |
| 42 |
entity_block->get_property(property_name); |
| 43 |
return (property.is_invalid() || property.is_implicit()); |
| 44 |
}), |
| 45 |
property_list.end()); |
| 46 |
return property_list; |
| 47 |
} |
| 48 |
|
| 49 |
std::string stringify_side_block_names(const Ioss::SideBlockContainer &sblocks) |
| 50 |
{ |
| 51 |
std::string stringified_sblock_names; |
| 52 |
for (auto sblock : sblocks) { |
| 53 |
stringified_sblock_names += Sideblock_separator + sblock->name(); |
| 54 |
} |
| 55 |
return stringified_sblock_names; |
| 56 |
} |
| 57 |
|
| 58 |
std::string encode_field_name(std::vector<std::string> names) |
| 59 |
{ |
| 60 |
std::string encoded_name; |
| 61 |
size_t count = 0; |
| 62 |
for (std::vector<std::string>::iterator it = names.begin(); it != names.end() - 1; |
| 63 |
++it, ++count) { |
| 64 |
encoded_name += *it + Name_separator; |
| 65 |
} |
| 66 |
// sentinel value to avoid having to test if the string is empty or not. |
| 67 |
names.push_back(""); |
| 68 |
return encoded_name + names[count]; |
| 69 |
} |
| 70 |
|
| 71 |
std::string encode_sideblock_name(const std::string &type_string, const std::string &name) |
| 72 |
{ |
| 73 |
return encode_field_name({type_string, name, sideblock_names}); |
| 74 |
} |
| 75 |
|
| 76 |
bool is_sideblock_name(const std::string &name) |
| 77 |
{ |
| 78 |
size_t pos = name.find(sideblock_names); |
| 79 |
return (pos == 0); |
| 80 |
} |
| 81 |
|
| 82 |
bool use_transformed_storage(const Ioss::Field &field, const std::string &entity_type, |
| 83 |
const std::string &field_name) |
| 84 |
{ |
| 85 |
return (field.get_role() == Ioss::Field::RoleType::TRANSIENT || |
| 86 |
find_field_in_mapset(entity_type, field_name, Use_transformed_storage_map)); |
| 87 |
} |
| 88 |
} // namespace Ioad |