Skip to content

Commit 2e39077

Browse files
committed
IOSS: Default to not munging block/set names on database
Original behavior was to convert all database block/set names to lowercase and convert spaces to '_'. The new default is proposed to be leaving the database names as they are read from the database and adding an alias of the name lowercased. Added property `LOWER_CASE_DATABASE_NAMES` which is false by default. If true, then previous behavior is returned. io_shell has --lower_case_database_names option to also select that behavior for testing.
1 parent c00424c commit 2e39077

File tree

13 files changed

+47
-16
lines changed

13 files changed

+47
-16
lines changed

packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.C

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ namespace Ioss {
347347
}
348348

349349
Utils::check_set_bool_property(properties, "LOWER_CASE_VARIABLE_NAMES", lowerCaseVariableNames);
350+
Utils::check_set_bool_property(properties, "LOWER_CASE_DATABASE_NAMES", lowerCaseDatabaseNames);
350351
Utils::check_set_bool_property(properties, "USE_GENERIC_CANONICAL_NAMES",
351352
useGenericCanonicalName);
352353
Utils::check_set_bool_property(properties, "IGNORE_DATABASE_NAMES", ignoreDatabaseNames);

packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright(C) 1999-2024 National Technology & Engineering Solutions
1+
// Copyright(C) 1999-2025 National Technology & Engineering Solutions
22
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
// NTESS, the U.S. Government retains certain rights in this software.
44
//
@@ -531,6 +531,11 @@ namespace Ioss {
531531
lowerCaseVariableNames = true_false;
532532
}
533533

534+
void set_lower_case_database_names(bool true_false) const
535+
{
536+
lowerCaseDatabaseNames = true_false;
537+
}
538+
534539
/* \brief Set the method used to split sidesets into homogeneous blocks.
535540
*
536541
* \param[in] split_type The desired method.
@@ -767,6 +772,7 @@ namespace Ioss {
767772
bool isParallel{false}; //!< true if running in parallel
768773

769774
mutable bool lowerCaseVariableNames{true};
775+
mutable bool lowerCaseDatabaseNames{false};
770776
bool usingParallelIO{false};
771777

772778
// List of element blocks that should be omitted or included from

packages/seacas/libraries/ioss/src/Ioss_Doxygen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ par_cgns | Input/Output | alias for parallel CGNS
4747
----------|:--------:|------------
4848
LOGGING | on/[off] | enable/disable logging of field input/output
4949
LOWER_CASE_VARIABLE_NAMES | [on]/off | Convert all variable names read from input database to lowercase; replace ' ' with '_'
50+
LOWER_CASE_DATABASE_NAMES | on/[off] | Convert all block/set names read from input database to lowercase; replace ' ' with '_'
5051
USE_GENERIC_CANONICAL_NAMES | on/[off] | use `block_{id}` as canonical name of an element block instead of the name (if any) stored on the database. The database name will be an alias.
5152
IGNORE_DATABASE_NAMES | on/[off] | Do not read any element block, nodeset, ... names if they exist on the database. Use only the canonical generated names (entitytype + _ + id)
5253
IGNORE_ATTRIBUTE_NAMES | on/[off] | Do not read the attribute names that may exist on an input database. Instead for an element block with N attributes, the fields will be named `attribute_1` ... `attribute_N`

packages/seacas/libraries/ioss/src/Ioss_EntityBlock.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright(C) 1999-2023 National Technology & Engineering Solutions
1+
// Copyright(C) 1999-2023, 2025 National Technology & Engineering Solutions
22
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
// NTESS, the U.S. Government retains certain rights in this software.
44
//

packages/seacas/libraries/ioss/src/Ioss_Region.C

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,11 @@ namespace Ioss {
17441744
aliases_[type].insert(std::make_pair(uname, canon));
17451745
}
17461746

1747+
std::string lname = Ioss::Utils::lowercase(alias);
1748+
if (lname != alias && lname != canon) {
1749+
aliases_[type].insert(std::make_pair(lname, canon));
1750+
}
1751+
17471752
bool result;
17481753
std::tie(std::ignore, result) = aliases_[type].insert(std::make_pair(alias, canon));
17491754
return result;

packages/seacas/libraries/ioss/src/Ioss_Version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
#pragma once
88
namespace Ioss {
9-
inline const char *Version() { return "2025-03-13"; }
9+
inline const char *Version() { return "2025-04-14"; }
1010
} // namespace Ioss

packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ namespace Ioex {
12681268
else {
12691269
Ioss::SerializeIO serializeio_(this);
12701270
block_name = Ioex::get_entity_name(get_file_pointer(), entity_type, id, basename,
1271-
maximumNameLength, db_has_name);
1271+
maximumNameLength, lowerCaseDatabaseNames, db_has_name);
12721272
}
12731273
if (get_use_generic_canonical_name()) {
12741274
std::swap(block_name, alias);
@@ -1597,7 +1597,7 @@ namespace Ioex {
15971597
}
15981598
else {
15991599
side_set_name = Ioex::get_entity_name(get_file_pointer(), EX_SIDE_SET, id, "surface",
1600-
maximumNameLength, db_has_name);
1600+
maximumNameLength, lowerCaseDatabaseNames, db_has_name);
16011601
}
16021602

16031603
if (side_set_name == "universal_sideset") {
@@ -2002,7 +2002,7 @@ namespace Ioex {
20022002
}
20032003
else {
20042004
Xset_name = Ioex::get_entity_name(get_file_pointer(), type, id, base + "list",
2005-
maximumNameLength, db_has_name);
2005+
maximumNameLength, lowerCaseDatabaseNames, db_has_name);
20062006
}
20072007

20082008
if (get_use_generic_canonical_name()) {

packages/seacas/libraries/ioss/src/exodus/Ioex_Internals.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright(C) 1999-2024 National Technology & Engineering Solutions
1+
// Copyright(C) 1999-2025 National Technology & Engineering Solutions
22
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
// NTESS, the U.S. Government retains certain rights in this software.
44
//

packages/seacas/libraries/ioss/src/exodus/Ioex_Utils.C

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ namespace Ioex {
658658
}
659659

660660
std::string get_entity_name(int exoid, ex_entity_type type, int64_t id,
661-
const std::string &basename, int length, bool &db_has_name)
661+
const std::string &basename, int length, bool lower_case_names, bool &db_has_name)
662662
{
663663
std::vector<char> buffer(length + 1);
664664
buffer[0] = '\0';
@@ -667,16 +667,18 @@ namespace Ioex {
667667
exodus_error(exoid, __LINE__, __func__, __FILE__);
668668
}
669669
if (buffer[0] != '\0') {
670-
Ioss::Utils::fixup_name(Data(buffer));
670+
std::string name{Data(buffer)};
671+
if (lower_case_names) {
672+
Ioss::Utils::fixup_name(name);
673+
}
671674
// Filter out names of the form "basename_id" if the name
672675
// id doesn't match the id in the name...
673-
size_t base_size = basename.size();
674-
if (std::strncmp(basename.c_str(), Data(buffer), base_size) == 0) {
675-
int64_t name_id = extract_id(Data(buffer));
676+
if (Ioss::Utils::substr_equal(basename, name)) {
677+
int64_t name_id = extract_id(name);
676678

677679
// See if name is truly of form "basename_name_id" (e.g. "surface_{id}")
678680
std::string tmp_name = Ioss::Utils::encode_entity_name(basename, name_id);
679-
if (tmp_name == Data(buffer)) {
681+
if (tmp_name == name) {
680682
if (name_id > 0) {
681683
db_has_name = false;
682684
if (name_id != id) {
@@ -686,15 +688,15 @@ namespace Ioex {
686688
"embedded id {}.\n"
687689
" This can cause issues later; the entity will be renamed to '{}' "
688690
"(IOSS)\n\n",
689-
Data(buffer), id, name_id, new_name);
691+
name, id, name_id, new_name);
690692
return new_name;
691693
}
692694
return tmp_name;
693695
}
694696
}
695697
}
696698
db_has_name = true;
697-
return {Data(buffer)};
699+
return name;
698700
}
699701
db_has_name = false;
700702
return Ioss::Utils::encode_entity_name(basename, id);

packages/seacas/libraries/ioss/src/exodus/Ioex_Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ namespace Ioex {
126126

127127
IOSS_NODISCARD IOEX_EXPORT std::string get_entity_name(int exoid, ex_entity_type type, int64_t id,
128128
const std::string &basename, int length,
129-
bool &db_has_name);
129+
bool lower_case_names, bool &db_has_name);
130130

131131
IOEX_EXPORT bool filter_node_list(Ioss::Int64Vector &nodes,
132132
const std::vector<unsigned char> &node_connectivity_status);

0 commit comments

Comments
 (0)