diff --git a/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.C b/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.C index 5638460672..561ecd4a2d 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.C +++ b/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.C @@ -29,13 +29,13 @@ namespace { int file_exists( const Ioss::ParallelUtils &util, const std::string& filename, std::string& message, - bool specifiedDecomp ) + bool filePerRank ) { std::string filenameBase = filename; const int par_size = util.parallel_size(); const int par_rank = util.parallel_rank(); - if( par_size > 1 && !specifiedDecomp ) { + if( par_size > 1 && !filePerRank ) { filenameBase = Ioss::Utils::decode_filename(filenameBase, par_rank, par_size); } @@ -168,8 +168,8 @@ namespace Ioss { if(index >= m_changeSetNames.size()) { std::ostringstream errmsg; fmt::print(errmsg, - "Invalid change set index {} with a max range of {}\n", - index, m_changeSetNames.size()); + "Invalid change set index {} with a max value of {}\n", + index, m_changeSetNames.size()-1); IOSS_ERROR(errmsg); } } @@ -216,9 +216,8 @@ namespace Ioss { db = Ioss::IOFactory::create(dbType, ioDB, usage, util().communicator(), get_database()->get_property_manager()); - int bad_count = 0; std::string error_message; - bool is_valid_file = db != nullptr && db->ok(false, &error_message, &bad_count); + bool is_valid_file = db != nullptr && db->ok(false, &error_message, nullptr); if(!is_valid_file) { delete db; std::ostringstream errmsg; diff --git a/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.h b/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.h index bfdcda1f4a..9bb1aaa8fc 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.h +++ b/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.h @@ -10,16 +10,13 @@ #include "Ioss_DBUsage.h" #include "Ioss_Region.h" #include "Ioss_ParallelUtils.h" +#include "Ioss_PropertyManager.h" #include -#include #include -#include #include -#include #include #include -#include namespace Ioss { @@ -55,6 +52,8 @@ class IOSS_EXPORT ChangeSet { ChangeSet(Ioss::DatabaseIO* db, const std::string& dbName, const std::string& dbType, unsigned fileCyclicCount); virtual ~ChangeSet(); + ChangeSet() = delete; + ChangeSet(const ChangeSet&) = delete; IOSS_NODISCARD unsigned supported_formats() const { return m_supportedFormats; } IOSS_NODISCARD unsigned database_format() const { return m_databaseFormat; } @@ -71,9 +70,6 @@ class IOSS_EXPORT ChangeSet { IOSS_NODISCARD unsigned get_file_cyclic_count() const { return m_fileCyclicCount; } private: - ChangeSet() = delete; - ChangeSet(const ChangeSet&) = delete; - std::vector m_changeSetDatabases; protected: diff --git a/packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.C b/packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.C index f074328479..117ff73b91 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.C +++ b/packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.C @@ -126,6 +126,3 @@ Ioss::ChangeSetFactoryMap *Ioss::ChangeSetFactory::registry() return ®istry_; } -/** \brief Empty method. - */ -void Ioss::ChangeSetFactory::clean() {} diff --git a/packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.h b/packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.h index a76a926fa6..b402470a10 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.h +++ b/packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.h @@ -35,7 +35,6 @@ class IOSS_EXPORT ChangeSetFactory static int describe(NameList *names); IOSS_NODISCARD static NameList describe(); - static void clean(); static const ChangeSetFactory * factory(); diff --git a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.C b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.C index 56b715a4fc..eb191ebe69 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.C +++ b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.C @@ -31,16 +31,14 @@ #include "Ioss_SideSet.h" #include "Ioss_StructuredBlock.h" -#include -#include #include #include #include -#include + +#include +#include #include -#include #include -#include #include #include "Ioss_ParallelUtils.h" @@ -145,7 +143,6 @@ bool file_exists(const Ioss::ParallelUtils &util, const std::string &db_type, Ioss::DatabaseUsage db_usage) { - bool exists = false; int par_size = util.parallel_size(); int par_rank = util.parallel_rank(); bool is_parallel = par_size > 1; @@ -156,20 +153,9 @@ bool file_exists(const Ioss::ParallelUtils &util, full_filename = Ioss::Utils::decode_filename(filename, par_rank, par_size); } - if (!is_parallel || par_rank == 0) { - // Now, see if this file exists... - // Don't want to do a system call on all processors since it can take minutes - // on some of the larger machines, filesystems, and processor counts... - Ioss::FileInfo file = Ioss::FileInfo(full_filename); - exists = file.exists(); - } - - if (is_parallel) { - int iexists = exists ? 1 : 0; - util.broadcast(iexists, 0); - exists = iexists == 1; - } - return exists; + std::string message; + Ioss::FileInfo file = Ioss::FileInfo(full_filename); + return file.parallel_exists(util.communicator(), message); } } @@ -177,7 +163,7 @@ bool file_exists(const Ioss::ParallelUtils &util, namespace Ioss { -void DynamicTopologyObserver::check_region() const +void DynamicTopologyObserver::verify_region_is_registered() const { if(nullptr == m_region) { std::ostringstream errmsg; @@ -265,13 +251,13 @@ bool DynamicTopologyObserver::is_topology_modified() const const ParallelUtils &DynamicTopologyObserver::util() const { - check_region(); + verify_region_is_registered(); return m_region->get_database()->util(); } void DynamicTopologyObserver::synchronize_topology_modified_flags() { - check_region(); + verify_region_is_registered(); int num_processors = m_region->get_database()->parallel_size(); // Synchronize the topology flags between all processors in case // it has not been set consistently. @@ -289,7 +275,7 @@ void DynamicTopologyObserver::synchronize_topology_modified_flags() int DynamicTopologyObserver::get_cumulative_topology_modification_field() { - check_region(); + verify_region_is_registered(); const std::string variable_name = topology_modification_change_name(); int ivalue = 0; diff --git a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h index 6b57d55750..0a8da4de5e 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h +++ b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h @@ -10,18 +10,15 @@ #include "Ioss_DatabaseIO.h" // for DatabaseIO #include "Ioss_ParallelUtils.h" // for ParallelUtils #include "Ioss_PropertyManager.h" // for PropertyManager -#include -#include // for size_t, nullptr -#include // for int64_t - #include "Ioss_CodeTypes.h" #include "Ioss_Utils.h" #include "ioss_export.h" -#include // for ostream +#include // for size_t, nullptr +#include // for int64_t +#include #include #include // for string, operator< -#include namespace Ioss { class Region; @@ -111,7 +108,7 @@ namespace Ioss { DynamicTopologyNotifier *m_notifier{nullptr}; - void check_region() const; + void verify_region_is_registered() const; IOSS_NODISCARD const ParallelUtils &util() const; void synchronize_topology_modified_flags(); @@ -230,6 +227,10 @@ namespace Ioss { static std::string get_internal_file_change_set_name(unsigned int step); + unsigned int get_topology_change_count() const { return m_dbChangeCount; } + unsigned int get_file_cyclic_count() const { return m_fileCyclicCount; } + IfDatabaseExistsBehavior get_if_database_exists_behavior() const { return m_ifDatabaseExists; } + private: Region *m_region{nullptr}; std::string m_ioDB; @@ -238,8 +239,8 @@ namespace Ioss { PropertyManager m_properties; unsigned int m_fileCyclicCount; - IfDatabaseExistsBehavior &m_ifDatabaseExists; - unsigned int &m_dbChangeCount; + IfDatabaseExistsBehavior m_ifDatabaseExists; + unsigned int m_dbChangeCount; IOSS_NODISCARD const ParallelUtils &util() const; diff --git a/packages/seacas/libraries/ioss/src/Ioss_Region.C b/packages/seacas/libraries/ioss/src/Ioss_Region.C index 305c94dbf5..71c6da0840 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Region.C +++ b/packages/seacas/libraries/ioss/src/Ioss_Region.C @@ -2900,6 +2900,10 @@ namespace Ioss { DynamicTopologyFileControl fileControl(this, fileCyclicCount, ifDatabaseExists, dbChangeCount); fileControl.add_output_database_change_set(state); + + // Reset based on fileControl values + dbChangeCount = fileControl.get_topology_change_count(); + ifDatabaseExists = fileControl.get_if_database_exists_behavior(); } } @@ -2939,6 +2943,10 @@ namespace Ioss { DynamicTopologyFileControl fileControl(this, fileCyclicCount, ifDatabaseExists, dbChangeCount); fileControl.clone_and_replace_output_database(state); + + // Reset based on fileControl values + dbChangeCount = fileControl.get_topology_change_count(); + ifDatabaseExists = fileControl.get_if_database_exists_behavior(); } } @@ -3048,11 +3056,9 @@ namespace Ioss { std::tuple Region::locate_db_state(double targetTime) const { - IfDatabaseExistsBehavior ifDatabaseExists{Ioss::DB_OVERWRITE}; - unsigned int dbChangeCount{1}; - - DynamicTopologyFileControl fileControl(const_cast(this), get_file_cyclic_count(), - ifDatabaseExists, dbChangeCount); + auto *cregion = const_cast(this); + DynamicTopologyFileControl fileControl(cregion, get_file_cyclic_count(), + cregion->ifDatabaseExists, cregion->dbChangeCount); return fileControl.locate_db_state(targetTime); } @@ -3065,11 +3071,9 @@ namespace Ioss { return std::make_tuple(get_internal_change_set_name(), currentState, stateTimes[0]); } - IfDatabaseExistsBehavior ifDatabaseExists{Ioss::DB_OVERWRITE}; - unsigned int dbChangeCount{1}; - - DynamicTopologyFileControl fileControl(const_cast(this), get_file_cyclic_count(), - ifDatabaseExists, dbChangeCount); + auto *cregion = const_cast(this); + DynamicTopologyFileControl fileControl(cregion, get_file_cyclic_count(), + cregion->ifDatabaseExists, cregion->dbChangeCount); return fileControl.get_db_max_time(); } @@ -3082,11 +3086,9 @@ namespace Ioss { return std::make_tuple(get_internal_change_set_name(), currentState, stateTimes[0]); } - IfDatabaseExistsBehavior ifDatabaseExists{Ioss::DB_OVERWRITE}; - unsigned int dbChangeCount{1}; - - DynamicTopologyFileControl fileControl(const_cast(this), get_file_cyclic_count(), - ifDatabaseExists, dbChangeCount); + auto *cregion = const_cast(this); + DynamicTopologyFileControl fileControl(cregion, get_file_cyclic_count(), + cregion->ifDatabaseExists, cregion->dbChangeCount); return fileControl.get_db_min_time(); } diff --git a/packages/seacas/libraries/ioss/src/unit_tests/UnitTestDynamicTopology.C b/packages/seacas/libraries/ioss/src/unit_tests/UnitTestDynamicTopology.C index 846244eec7..e9dba09306 100644 --- a/packages/seacas/libraries/ioss/src/unit_tests/UnitTestDynamicTopology.C +++ b/packages/seacas/libraries/ioss/src/unit_tests/UnitTestDynamicTopology.C @@ -91,8 +91,6 @@ void define_model(const Ioss::Region &i_region, Ioss::Region &o_region) o_region.begin_mode(Ioss::STATE_DEFINE_MODEL); - auto& nodeblocks = o_region.get_node_blocks(); - Ioss::NodeBlock *i_nb = i_region.get_node_blocks()[0]; int64_t spatial_dim = 3; int64_t num_nodes = i_nb->entity_count(); @@ -138,7 +136,7 @@ void write_model(const Ioss::Region &i_region, Ioss::Region &o_region) o_region.end_mode(Ioss::STATE_MODEL); } -void define_transient(const Ioss::Region &i_region, Ioss::Region &o_region, +void define_transient(Ioss::Region &o_region, const std::string &elemFieldName) { o_region.begin_mode(Ioss::STATE_DEFINE_TRANSIENT); @@ -206,7 +204,7 @@ public: void define_transient() override { - ::define_transient(inputRegion, *get_region(), elemFieldName); + ::define_transient(*get_region(), elemFieldName); } Ioss::FileControlOption get_control_option() const @@ -238,7 +236,7 @@ struct OutputParams { ASSERT_EQ(output_times_.size(), modification_steps_.size()); size_t numSteps = output_times_.size(); - for(auto i=1; i output_times_[i-1]); } @@ -332,14 +330,13 @@ void run_topology_change(const Ioss::Region& i_region, define_model(i_region, o_region); write_model(i_region, o_region); - define_transient(i_region, o_region, params.elemFieldName); + define_transient(o_region, params.elemFieldName); auto numSteps = params.output_steps.size(); int maxStep = 1; double minTime = numSteps > 0 ? params.output_times[0] : 0.0; - double maxTime = numSteps > 0 ? params.output_times[0] : 0.0; bool doneOutputAfterModification = true; @@ -437,7 +434,7 @@ void cleanup_cyclic_multi_files(const std::string &outFile, unsigned cyclicCount { Ioss::ParallelUtils util(Ioss::ParallelUtils::comm_world()); - for(int i=1; i<=cyclicCount; i++) { + for(unsigned i=1; i<=cyclicCount; i++) { std::string baseFile = Ioss::DynamicTopologyFileControl::get_cyclic_database_filename(outFile, cyclicCount, i); std::string parallelFile = Ioss::Utils::decode_filename(baseFile, util.parallel_rank(), util.parallel_size()); unlink(parallelFile.c_str()); @@ -804,11 +801,11 @@ void run_topology_change_with_multiple_output(const Ioss::Region& i_region, define_model(i_region, o_region1); write_model(i_region, o_region1); - define_transient(i_region, o_region1, params1.elemFieldName); + define_transient(o_region1, params1.elemFieldName); define_model(i_region, o_region2); write_model(i_region, o_region2); - define_transient(i_region, o_region2, params2.elemFieldName); + define_transient(o_region2, params2.elemFieldName); auto numSteps = params1.output_steps.size(); @@ -1118,7 +1115,6 @@ std::tuple read_and_locate_db_state(const OutputParams } void run_single_file_locate_db_time_state(const std::string& outFile, - const std::string& elemFieldName, const OutputParams& params, double targetTime, const std::string& goldSet, @@ -1161,7 +1157,7 @@ TEST(TestDynamicRead, single_file_locate_db_time_state) int goldState = 1; double goldTime = 3.0; - run_single_file_locate_db_time_state(outFile, elemFieldName, params, targetTime, goldSet, goldState, goldTime); + run_single_file_locate_db_time_state(outFile, params, targetTime, goldSet, goldState, goldTime); } TEST(TestDynamicRead, single_file_locate_db_time_state_all_negative_time) @@ -1184,11 +1180,10 @@ TEST(TestDynamicRead, single_file_locate_db_time_state_all_negative_time) int goldState = 1; double goldTime = -1.0; - run_single_file_locate_db_time_state(outFile, elemFieldName, params, targetTime, goldSet, goldState, goldTime); + run_single_file_locate_db_time_state(outFile, params, targetTime, goldSet, goldState, goldTime); } void run_multi_file_locate_db_time_state(const std::string& outFile, - const std::string& elemFieldName, const OutputParams& params, double targetTime, const std::string& goldFile, @@ -1240,7 +1235,7 @@ TEST(TestDynamicRead, linear_multi_file_locate_db_time_state) int goldState = 1; double goldTime = 3.0; - run_multi_file_locate_db_time_state(outFile, elemFieldName, params, targetTime, goldFile, goldState, goldTime); + run_multi_file_locate_db_time_state(outFile, params, targetTime, goldFile, goldState, goldTime); } TEST(TestDynamicRead, cyclic_multi_file_locate_db_time_state) @@ -1264,7 +1259,7 @@ TEST(TestDynamicRead, cyclic_multi_file_locate_db_time_state) int goldState = 1; double goldTime = 2.0; - run_multi_file_locate_db_time_state(outFile, elemFieldName, params, targetTime, goldFile, goldState, goldTime); + run_multi_file_locate_db_time_state(outFile, params, targetTime, goldFile, goldState, goldTime); } std::tuple read_and_locate_db_max_time(const OutputParams& params) @@ -1506,11 +1501,11 @@ TEST(TestDynamicRead, cyclic_multi_file_locate_db_min_time) cleanup_cyclic_multi_files(outFile, params.cyclicCount); } -int get_num_change_sets(const OutputParams& params) +unsigned get_num_change_sets(const OutputParams& params) { auto numSteps = params.output_steps.size(); - int numMods = 0; + unsigned numMods = 0; int numModInc = 0; int currentModStep = -1; @@ -1545,7 +1540,7 @@ void read_and_test_single_file_topology_change_set(const OutputParams& params) std::vector gold_names; std::vector gold_full_names; - int numMods = get_num_change_sets(params); + unsigned numMods = get_num_change_sets(params); fill_internal_file_change_set_gold_names(numMods, gold_names, gold_full_names); @@ -1586,12 +1581,12 @@ void read_and_test_cyclic_multi_file_topology_change_set(const OutputParams& par std::vector gold_names; - int numMods = get_num_change_sets(params); + unsigned numMods = get_num_change_sets(params); if(numMods > params.cyclicCount) { numMods = params.cyclicCount; } - for(int i=1; i<=numMods; i++) { + for(unsigned i=1; i<=numMods; i++) { gold_names.push_back(Ioss::DynamicTopologyFileControl::get_cyclic_database_filename(params.outFile, params.cyclicCount, i)); } @@ -1634,9 +1629,9 @@ void read_and_test_linear_multi_file_topology_change_set(const OutputParams& par std::vector gold_names; - int numMods = get_num_change_sets(params); + unsigned numMods = get_num_change_sets(params); - for(int i=1; i<=numMods; i++) { + for(unsigned i=1; i<=numMods; i++) { gold_names.push_back(Ioss::DynamicTopologyFileControl::get_linear_database_filename(params.outFile, i)); } diff --git a/packages/seacas/libraries/ioss/src/unit_tests/UnitTestElementBlockBatchRead.C b/packages/seacas/libraries/ioss/src/unit_tests/UnitTestElementBlockBatchRead.C index cb90ab20fa..5052ae3ecc 100644 --- a/packages/seacas/libraries/ioss/src/unit_tests/UnitTestElementBlockBatchRead.C +++ b/packages/seacas/libraries/ioss/src/unit_tests/UnitTestElementBlockBatchRead.C @@ -135,7 +135,7 @@ namespace { o_region.end_mode(Ioss::STATE_MODEL); } - void define_transient(const Ioss::Region &i_region, Ioss::Region &o_region, + void define_transient(Ioss::Region &o_region, const std::string &elemFieldName) { o_region.begin_mode(Ioss::STATE_DEFINE_TRANSIENT); @@ -205,7 +205,7 @@ namespace { define_model(i_region, o_region); write_model(i_region, o_region); - define_transient(i_region, o_region, elemFieldName); + define_transient(o_region, elemFieldName); write_transient(o_region, elemFieldName); o_database->finalize_database(); diff --git a/packages/seacas/libraries/ioss/src/unit_tests/UnitTestIotmDatabaseIO.C b/packages/seacas/libraries/ioss/src/unit_tests/UnitTestIotmDatabaseIO.C index 248bc0c92e..69b90cf833 100644 --- a/packages/seacas/libraries/ioss/src/unit_tests/UnitTestIotmDatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/unit_tests/UnitTestIotmDatabaseIO.C @@ -50,20 +50,6 @@ namespace { return db_io; } - Iotm::DatabaseIO *create_output_db_io(const std::string &filename) - { - Ioss::Init::Initializer init_db; - Ioss::DatabaseUsage db_usage = Ioss::WRITE_RESULTS; - Ioss::PropertyManager properties; - - properties.add(Ioss::Property("INTEGER_SIZE_DB", 8)); - properties.add(Ioss::Property("INTEGER_SIZE_API", 8)); - - auto *db_io = new Iotm::DatabaseIO(nullptr, filename, db_usage, - Ioss::ParallelUtils::comm_world(), properties); - return db_io; - } - int get_parallel_size() { return Ioss::ParallelUtils(Ioss::ParallelUtils::comm_world()).parallel_size();