From d4b7a7e68546fd1a33c913fe2d711d8c2c36f01f Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 31 Jul 2024 09:11:50 -0600 Subject: [PATCH] IOSS: clang-format --- .../libraries/ioss/src/Ioss_ChainGenerator.C | 4 +- .../seacas/libraries/ioss/src/Ioss_Compare.C | 4 +- .../libraries/ioss/src/Ioss_DatabaseIO.h | 5 +- .../libraries/ioss/src/Ioss_Decomposition.C | 4 +- .../ioss/src/Ioss_DecompositionUtils.C | 28 +- .../libraries/ioss/src/Ioss_DynamicTopology.C | 851 +++++++++--------- .../libraries/ioss/src/Ioss_DynamicTopology.h | 100 +- .../libraries/ioss/src/Ioss_FaceGenerator.h | 15 +- .../libraries/ioss/src/Ioss_IOFactory.C | 2 +- .../seacas/libraries/ioss/src/Ioss_Region.h | 33 +- 10 files changed, 515 insertions(+), 531 deletions(-) diff --git a/packages/seacas/libraries/ioss/src/Ioss_ChainGenerator.C b/packages/seacas/libraries/ioss/src/Ioss_ChainGenerator.C index 27bb94759e..07c9ca156d 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_ChainGenerator.C +++ b/packages/seacas/libraries/ioss/src/Ioss_ChainGenerator.C @@ -195,8 +195,8 @@ namespace Ioss { { region.get_database()->progress(__func__); - debug = debug_level; - size_t numel = region.get_property("element_count").get_int(); + debug = debug_level; + size_t numel = region.get_property("element_count").get_int(); // Determine which element block(s) are adjacent to the faceset specifying "lines" // The `adjacent_blocks` contains the names of all element blocks that are adjacent to the diff --git a/packages/seacas/libraries/ioss/src/Ioss_Compare.C b/packages/seacas/libraries/ioss/src/Ioss_Compare.C index 3a1155de56..440622159d 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Compare.C +++ b/packages/seacas/libraries/ioss/src/Ioss_Compare.C @@ -960,8 +960,8 @@ namespace { continue; } if (property == "base_filename") { - // IGNORE the base_filename. This is generally the base portion of the filename; we don't care whether - // the filenames match. + // IGNORE the base_filename. This is generally the base portion of the filename; we don't + // care whether the filenames match. continue; } diff --git a/packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.h b/packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.h index 5d193ed64f..3ef175acba 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.h +++ b/packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.h @@ -781,7 +781,10 @@ namespace Ioss { virtual bool open_root_group_nl() { return false; } virtual bool open_group_nl(const std::string & /* group_name */) { return false; } virtual bool create_subgroup_nl(const std::string & /* group_name */) { return false; } - virtual Ioss::NameList groups_describe_nl(bool /* return_full_names */) { return Ioss::NameList(); } + virtual Ioss::NameList groups_describe_nl(bool /* return_full_names */) + { + return Ioss::NameList(); + } virtual bool begin_nl(Ioss::State state) = 0; virtual bool end_nl(Ioss::State state) = 0; diff --git a/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C b/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C index 1deac79a93..95abfa049e 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C +++ b/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C @@ -427,9 +427,9 @@ namespace Ioss { m_method, fmt::group_digits(m_globalElementCount), m_processorCount); if (!m_decompExtra.empty()) { - fmt::print(Ioss::OUTPUT(), "\tDecomposition extra data: '{}'.\n", m_decompExtra); + fmt::print(Ioss::OUTPUT(), "\tDecomposition extra data: '{}'.\n", m_decompExtra); } - + if ((size_t)m_processorCount > m_globalElementCount) { fmt::print(Ioss::WarnOut(), "Decomposing {} elements across {} mpi ranks will " diff --git a/packages/seacas/libraries/ioss/src/Ioss_DecompositionUtils.C b/packages/seacas/libraries/ioss/src/Ioss_DecompositionUtils.C index e71168c72e..d6d5fdd097 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DecompositionUtils.C +++ b/packages/seacas/libraries/ioss/src/Ioss_DecompositionUtils.C @@ -337,9 +337,9 @@ namespace Ioss { } template - void DecompUtils::line_decompose(Region ®ion, size_t num_ranks, const std::string &method, - const std::string &surface_list, - std::vector &element_to_proc, INT dummy) + void DecompUtils::line_decompose(Region ®ion, size_t num_ranks, const std::string &method, + const std::string &surface_list, + std::vector &element_to_proc, INT dummy) { Ioss::chain_t element_chains = @@ -362,15 +362,15 @@ namespace Ioss { } template IOSS_EXPORT void DecompUtils::line_decompose(Region ®ion, size_t num_ranks, - const std::string &method, - const std::string &surface_list, - std::vector &element_to_proc, - int dummy); + const std::string &method, + const std::string &surface_list, + std::vector &element_to_proc, + int dummy); template IOSS_EXPORT void DecompUtils::line_decompose(Region ®ion, size_t num_ranks, - const std::string &method, - const std::string &surface_list, - std::vector &element_to_proc, - int64_t dummy); + const std::string &method, + const std::string &surface_list, + std::vector &element_to_proc, + int64_t dummy); template std::vector DecompUtils::line_decomp_weights(const Ioss::chain_t &element_chains, @@ -464,7 +464,7 @@ namespace Ioss { std::vector &elem_to_proc, int proc_count); void DecompUtils::output_decomposition_statistics(const std::vector &elem_to_proc, - int proc_count) + int proc_count) { // Output histogram of elements / rank... std::vector elem_per_rank(proc_count); @@ -473,8 +473,8 @@ namespace Ioss { } size_t number_elements = elem_to_proc.size(); - size_t proc_width = Ioss::Utils::number_width(proc_count, false); - size_t work_width = Ioss::Utils::number_width(number_elements, true); + size_t proc_width = Ioss::Utils::number_width(proc_count, false); + size_t work_width = Ioss::Utils::number_width(number_elements, true); auto min_work = *std::min_element(elem_per_rank.begin(), elem_per_rank.end()); auto max_work = *std::max_element(elem_per_rank.begin(), elem_per_rank.end()); diff --git a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.C b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.C index ac5af4849e..4bb8390e3f 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.C +++ b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.C @@ -37,518 +37,491 @@ #include #include +#include +#include #include #include -#include -#include #include "Ioss_ParallelUtils.h" namespace Ioss { -void DynamicTopologyObserver::check_region() const -{ - if(nullptr == m_region) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: A region has not been registered with the " - "Dynamic Topology Observer.\n\n"); - IOSS_ERROR(errmsg); + void DynamicTopologyObserver::check_region() const + { + if (nullptr == m_region) { + std::ostringstream errmsg; + fmt::print(errmsg, "ERROR: A region has not been registered with the " + "Dynamic Topology Observer.\n\n"); + IOSS_ERROR(errmsg); + } } -} - -void DynamicTopologyObserver::register_region(Region *region) -{ - if(nullptr != m_region && region != m_region) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Attempt to re-register different region on " - "Dynamic Topology Observer.\n\n"); - IOSS_ERROR(errmsg); + + void DynamicTopologyObserver::register_region(Region *region) + { + if (nullptr != m_region && region != m_region) { + std::ostringstream errmsg; + fmt::print(errmsg, "ERROR: Attempt to re-register different region on " + "Dynamic Topology Observer.\n\n"); + IOSS_ERROR(errmsg); + } + + m_region = region; } - m_region = region; -} - -void DynamicTopologyObserver::set_cumulative_topology_modification(unsigned int type) -{ m_cumulativeTopologyModification = type; } - -unsigned int DynamicTopologyObserver::get_cumulative_topology_modification() const -{ return m_cumulativeTopologyModification; } - -unsigned int DynamicTopologyObserver::get_topology_modification() const -{ return m_topologyModification; } - -void DynamicTopologyObserver::set_topology_modification(unsigned int type) -{ - m_topologyModification |= type; - m_cumulativeTopologyModification |= type; -} - -void DynamicTopologyObserver::reset_topology_modification() -{ - m_topologyModification = TOPOLOGY_SAME; -} - -bool DynamicTopologyObserver::is_topology_modified() const -{ return m_topologyModification != 0; } - -const ParallelUtils &DynamicTopologyObserver::util() const -{ - check_region(); - return m_region->get_database()->util(); -} - -void DynamicTopologyObserver::synchronize_topology_modified_flags() -{ - check_region(); - int num_processors = m_region->get_database()->parallel_size(); - // Synchronize the topology flags between all processors in case - // it has not been set consistently. - if (num_processors > 1) { - static unsigned int buffer[2]; - buffer[0] = m_cumulativeTopologyModification; - buffer[1] = m_topologyModification; - - util().attribute_reduction(2*sizeof(unsigned int), reinterpret_cast(buffer)); - - m_cumulativeTopologyModification = buffer[0]; - m_topologyModification = buffer[1]; + void DynamicTopologyObserver::set_cumulative_topology_modification(unsigned int type) + { + m_cumulativeTopologyModification = type; } -} - -int DynamicTopologyObserver::get_cumulative_topology_modification_field() -{ - check_region(); - const std::string variable_name = topology_modification_change_name(); - - int ivalue = 0; - - if (m_region->field_exists(variable_name)) { - Field topo_field = m_region->get_field(variable_name); - if (topo_field.get_type() == Field::INTEGER) { - m_region->get_field_data(variable_name, &ivalue, sizeof(int)); - } else { - double value; - m_region->get_field_data(variable_name, &value, sizeof(double)); - ivalue = (int)value; - } + + unsigned int DynamicTopologyObserver::get_cumulative_topology_modification() const + { + return m_cumulativeTopologyModification; + } + + unsigned int DynamicTopologyObserver::get_topology_modification() const + { + return m_topologyModification; + } + + void DynamicTopologyObserver::set_topology_modification(unsigned int type) + { + m_topologyModification |= type; + m_cumulativeTopologyModification |= type; } - int num_processors = m_region->get_database()->parallel_size(); - // Synchronize the value between all processors in case - // it has not been set consistently. - if (num_processors > 1) { - unsigned int buffer[1]; - buffer[0] = ivalue; + void DynamicTopologyObserver::reset_topology_modification() + { + m_topologyModification = TOPOLOGY_SAME; + } - util().attribute_reduction(sizeof(unsigned int), reinterpret_cast(buffer)); + bool DynamicTopologyObserver::is_topology_modified() const { return m_topologyModification != 0; } - ivalue = (int)buffer[0]; + const ParallelUtils &DynamicTopologyObserver::util() const + { + check_region(); + return m_region->get_database()->util(); } - m_cumulativeTopologyModification = ivalue; + void DynamicTopologyObserver::synchronize_topology_modified_flags() + { + check_region(); + int num_processors = m_region->get_database()->parallel_size(); + // Synchronize the topology flags between all processors in case + // it has not been set consistently. + if (num_processors > 1) { + static unsigned int buffer[2]; + buffer[0] = m_cumulativeTopologyModification; + buffer[1] = m_topologyModification; + + util().attribute_reduction(2 * sizeof(unsigned int), reinterpret_cast(buffer)); + + m_cumulativeTopologyModification = buffer[0]; + m_topologyModification = buffer[1]; + } + } - return ivalue; -} + int DynamicTopologyObserver::get_cumulative_topology_modification_field() + { + check_region(); + const std::string variable_name = topology_modification_change_name(); -void DynamicTopologyObserver::define_model(IOSS_MAYBE_UNUSED Region& region) -{ + int ivalue = 0; -} + if (m_region->field_exists(variable_name)) { + Field topo_field = m_region->get_field(variable_name); + if (topo_field.get_type() == Field::INTEGER) { + m_region->get_field_data(variable_name, &ivalue, sizeof(int)); + } + else { + double value; + m_region->get_field_data(variable_name, &value, sizeof(double)); + ivalue = (int)value; + } + } -void DynamicTopologyObserver::write_model(IOSS_MAYBE_UNUSED Region& region) -{ + int num_processors = m_region->get_database()->parallel_size(); + // Synchronize the value between all processors in case + // it has not been set consistently. + if (num_processors > 1) { + unsigned int buffer[1]; + buffer[0] = ivalue; -} + util().attribute_reduction(sizeof(unsigned int), reinterpret_cast(buffer)); -void DynamicTopologyObserver::define_transient(IOSS_MAYBE_UNUSED Region& region) -{ + ivalue = (int)buffer[0]; + } -} + m_cumulativeTopologyModification = ivalue; -DynamicTopologyFileControl::DynamicTopologyFileControl(Region *region, unsigned int fileCyclicCount, - IfDatabaseExistsBehavior &ifDatabaseExists, - unsigned int &dbChangeCount) - : m_region(region) - , m_fileCyclicCount(fileCyclicCount) - , m_ifDatabaseExists(ifDatabaseExists) - , m_dbChangeCount(dbChangeCount) -{ - if(nullptr == region) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: null region passed in as argument to DynamicTopologyFileControl"); - IOSS_ERROR(errmsg); + return ivalue; } - m_ioDB = region->get_property("base_filename").get_string(); - m_dbType = region->get_property("database_type").get_string(); -} - -const ParallelUtils &DynamicTopologyFileControl::util() const -{ - return m_region->get_database()->util(); -} - -bool DynamicTopologyFileControl::file_exists(const std::string &filename, - const std::string &db_type, - Ioss::DatabaseUsage db_usage) -{ - bool exists = false; - int par_size = m_region->get_database()->parallel_size(); - int par_rank = m_region->get_database()->parallel_rank(); - bool is_parallel = par_size > 1; - std::string full_filename = filename; - if (is_parallel && db_type == "exodusII" && db_usage != Ioss::WRITE_HISTORY) { - full_filename = Ioss::Utils::decode_filename(filename, par_rank, par_size); - } + void DynamicTopologyObserver::define_model(IOSS_MAYBE_UNUSED Region ®ion) {} - 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(); - } + void DynamicTopologyObserver::write_model(IOSS_MAYBE_UNUSED Region ®ion) {} - if (is_parallel) { - int iexists = exists ? 1 : 0; - util().broadcast(iexists, 0); - exists = iexists == 1; - } - return exists; -} - -std::string DynamicTopologyFileControl::get_unique_filename(Ioss::DatabaseUsage db_usage) -{ - std::string filename = m_ioDB; - - do { - // Run this loop at least once for all files. If this is an automatic - // restart, then make sure that the generated file does not already exist, - // so keep running the loop until we generate a filename that doesn't exist... - std::ostringstream tmp_filename; - tmp_filename << m_ioDB; - - // Don't append the "-s000X" the first time in case the base filename doesn't - // exist -- we want write to the name specified by the user if at all possible and - // once that exists, then start adding on the suffix... - if (m_dbChangeCount > 1) { - tmp_filename << "-s" << std::setw(4) << std::setfill('0') << m_dbChangeCount; - } - filename = tmp_filename.str(); - ++m_dbChangeCount; - } while(file_exists(filename, m_dbType, db_usage)); - --m_dbChangeCount; - return filename; -} - -std::string DynamicTopologyFileControl::construct_database_filename(int& step, Ioss::DatabaseUsage db_usage) -{ - // Filename will be of the form -- ioDB-sxxxx where xxxx is step - // number. Assume maximum of 9999 steps (will do more, but won't have - // good lineup of step numbers. - // Check database for validity (filename and a type) - if(m_ioDB.empty() || m_dbType.empty()) - { - std::string error_message; - if(m_dbType.empty()) - error_message += "The database TYPE has not been defined\n"; + void DynamicTopologyObserver::define_transient(IOSS_MAYBE_UNUSED Region ®ion) {} - if(m_ioDB.empty()) - { - error_message += "The database FILENAME has not been defined\n"; + DynamicTopologyFileControl::DynamicTopologyFileControl(Region *region, + unsigned int fileCyclicCount, + IfDatabaseExistsBehavior &ifDatabaseExists, + unsigned int &dbChangeCount) + : m_region(region), m_fileCyclicCount(fileCyclicCount), m_ifDatabaseExists(ifDatabaseExists), + m_dbChangeCount(dbChangeCount) + { + if (nullptr == region) { + std::ostringstream errmsg; + fmt::print(errmsg, "ERROR: null region passed in as argument to DynamicTopologyFileControl"); + IOSS_ERROR(errmsg); } - std::ostringstream errmsg; - fmt::print(errmsg, error_message); - IOSS_ERROR(errmsg); + + m_ioDB = region->get_property("base_filename").get_string(); + m_dbType = region->get_property("database_type").get_string(); } - assert(!m_ioDB.empty()); - assert(!m_dbType.empty()); - std::string filename = m_ioDB; - if(m_fileCyclicCount > 0) + + const ParallelUtils &DynamicTopologyFileControl::util() const { - // In this mode, we close the old file and open a new file - // every time this is called. The file suffix cycles through - // the first fileCyclicCount'th entries in A,B,C,D,E,F,... - if(step == 0) - step++; - - static std::string suffix = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - std::string tmp = "-" + suffix.substr((step - 1) % m_fileCyclicCount, 1); - filename += tmp; - m_properties.add(Ioss::Property("APPEND_OUTPUT", Ioss::DB_OVERWRITE)); + return m_region->get_database()->util(); } - else + + bool DynamicTopologyFileControl::file_exists(const std::string &filename, + const std::string &db_type, + Ioss::DatabaseUsage db_usage) { - if(m_region->model_is_written()) - { - // After the initial open, we want to add suffix if the topology changes - // during the run - m_ifDatabaseExists = Ioss::DB_ADD_SUFFIX_OVERWRITE; + bool exists = false; + int par_size = m_region->get_database()->parallel_size(); + int par_rank = m_region->get_database()->parallel_rank(); + bool is_parallel = par_size > 1; + std::string full_filename = filename; + if (is_parallel && db_type == "exodusII" && db_usage != Ioss::WRITE_HISTORY) { + 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(); } - // Handle complications of DB_APPEND mode... - // If in DB_APPEND mode, then we don't output metadata - // information, so some knowledge is needed at this level if - // we are appending. If user specified APPEND, but the file - // doesn't yet exist OR it does exist and we are not - // restarting, change the mode to OVERWRITE. - // 0. Must be restarting; either manual or automatic. - std::shared_ptr observer = m_region->get_mesh_modification_observer(); - - if(m_ifDatabaseExists == Ioss::DB_APPEND) - { - if(!observer->is_restart_requested()) - { - // Not restarting - m_ifDatabaseExists = Ioss::DB_OVERWRITE; + if (is_parallel) { + int iexists = exists ? 1 : 0; + util().broadcast(iexists, 0); + exists = iexists == 1; + } + return exists; + } + + std::string DynamicTopologyFileControl::get_unique_filename(Ioss::DatabaseUsage db_usage) + { + std::string filename = m_ioDB; + + do { + // Run this loop at least once for all files. If this is an automatic + // restart, then make sure that the generated file does not already exist, + // so keep running the loop until we generate a filename that doesn't exist... + std::ostringstream tmp_filename; + tmp_filename << m_ioDB; + + // Don't append the "-s000X" the first time in case the base filename doesn't + // exist -- we want write to the name specified by the user if at all possible and + // once that exists, then start adding on the suffix... + if (m_dbChangeCount > 1) { + tmp_filename << "-s" << std::setw(4) << std::setfill('0') << m_dbChangeCount; } - else if(!file_exists(m_ioDB, m_dbType, db_usage)) - { - m_ifDatabaseExists = Ioss::DB_OVERWRITE; + filename = tmp_filename.str(); + ++m_dbChangeCount; + } while (file_exists(filename, m_dbType, db_usage)); + --m_dbChangeCount; + return filename; + } + + std::string DynamicTopologyFileControl::construct_database_filename(int &step, + Ioss::DatabaseUsage db_usage) + { + // Filename will be of the form -- ioDB-sxxxx where xxxx is step + // number. Assume maximum of 9999 steps (will do more, but won't have + // good lineup of step numbers. + // Check database for validity (filename and a type) + if (m_ioDB.empty() || m_dbType.empty()) { + std::string error_message; + if (m_dbType.empty()) + error_message += "The database TYPE has not been defined\n"; + + if (m_ioDB.empty()) { + error_message += "The database FILENAME has not been defined\n"; } + std::ostringstream errmsg; + fmt::print(errmsg, error_message); + IOSS_ERROR(errmsg); } - if(step > 1 || (m_dbChangeCount > 1)) - { - // Use the !is_input_event test since restart input files already have the - // -s000x extension... - if(m_ifDatabaseExists == Ioss::DB_APPEND) - { - std::ostringstream tmp_filename; - tmp_filename << m_ioDB; - filename = m_ioDB; - if(m_dbChangeCount > 1) - { - tmp_filename << "-s" << std::setw(4) << std::setfill('0') << m_dbChangeCount; - } - size_t inc = 0; - while(file_exists(tmp_filename.str(), m_dbType, db_usage)) - { - filename = tmp_filename.str(); - tmp_filename.clear(); - tmp_filename.str(""); - tmp_filename << m_ioDB << "-s" << std::setw(4) << std::setfill('0') << m_dbChangeCount + (++inc); - } - if(inc > 0) - { - m_dbChangeCount += (inc - 1); + assert(!m_ioDB.empty()); + assert(!m_dbType.empty()); + std::string filename = m_ioDB; + if (m_fileCyclicCount > 0) { + // In this mode, we close the old file and open a new file + // every time this is called. The file suffix cycles through + // the first fileCyclicCount'th entries in A,B,C,D,E,F,... + if (step == 0) + step++; + + static std::string suffix = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + std::string tmp = "-" + suffix.substr((step - 1) % m_fileCyclicCount, 1); + filename += tmp; + m_properties.add(Ioss::Property("APPEND_OUTPUT", Ioss::DB_OVERWRITE)); + } + else { + if (m_region->model_is_written()) { + // After the initial open, we want to add suffix if the topology changes + // during the run + m_ifDatabaseExists = Ioss::DB_ADD_SUFFIX_OVERWRITE; + } + + // Handle complications of DB_APPEND mode... + // If in DB_APPEND mode, then we don't output metadata + // information, so some knowledge is needed at this level if + // we are appending. If user specified APPEND, but the file + // doesn't yet exist OR it does exist and we are not + // restarting, change the mode to OVERWRITE. + // 0. Must be restarting; either manual or automatic. + std::shared_ptr observer = + m_region->get_mesh_modification_observer(); + + if (m_ifDatabaseExists == Ioss::DB_APPEND) { + if (!observer->is_restart_requested()) { + // Not restarting + m_ifDatabaseExists = Ioss::DB_OVERWRITE; } - else - { + else if (!file_exists(m_ioDB, m_dbType, db_usage)) { m_ifDatabaseExists = Ioss::DB_OVERWRITE; } } - else if(m_ifDatabaseExists == Ioss::DB_ADD_SUFFIX) - { - filename = get_unique_filename(db_usage); - } - else if(m_ifDatabaseExists == Ioss::DB_ADD_SUFFIX_OVERWRITE) - { - if(m_dbChangeCount > 0) - { + if (step > 1 || (m_dbChangeCount > 1)) { + // Use the !is_input_event test since restart input files already have the + // -s000x extension... + if (m_ifDatabaseExists == Ioss::DB_APPEND) { std::ostringstream tmp_filename; - tmp_filename << m_ioDB << "-s" << std::setw(4) << std::setfill('0') << ++m_dbChangeCount; - filename = tmp_filename.str(); + tmp_filename << m_ioDB; + filename = m_ioDB; + if (m_dbChangeCount > 1) { + tmp_filename << "-s" << std::setw(4) << std::setfill('0') << m_dbChangeCount; + } + size_t inc = 0; + while (file_exists(tmp_filename.str(), m_dbType, db_usage)) { + filename = tmp_filename.str(); + tmp_filename.clear(); + tmp_filename.str(""); + tmp_filename << m_ioDB << "-s" << std::setw(4) << std::setfill('0') + << m_dbChangeCount + (++inc); + } + if (inc > 0) { + m_dbChangeCount += (inc - 1); + } + else { + m_ifDatabaseExists = Ioss::DB_OVERWRITE; + } + } + else if (m_ifDatabaseExists == Ioss::DB_ADD_SUFFIX) { + filename = get_unique_filename(db_usage); } - else - { + else if (m_ifDatabaseExists == Ioss::DB_ADD_SUFFIX_OVERWRITE) { + if (m_dbChangeCount > 0) { + std::ostringstream tmp_filename; + tmp_filename << m_ioDB << "-s" << std::setw(4) << std::setfill('0') + << ++m_dbChangeCount; + filename = tmp_filename.str(); + } + else { + filename = m_ioDB; + } + } + else { filename = m_ioDB; } } - else - { + else if (m_ifDatabaseExists == Ioss::DB_ADD_SUFFIX) { + filename = get_unique_filename(db_usage); + } + else { filename = m_ioDB; } - } - else if(m_ifDatabaseExists == Ioss::DB_ADD_SUFFIX) - { - filename = get_unique_filename(db_usage); - } - else - { - filename = m_ioDB; - } - m_properties.add(Ioss::Property("APPEND_OUTPUT", m_ifDatabaseExists)); - // A little complicated on deciding whether we are actually - // overwriting the database. The 'validate' routine for Results and - // History will call create_database once the parser block is - // ended. This routine will then create the database and the - // ioRegion_. However, the database will not really be opened or - // written to at this time. If the code is auto-restarting, then it will - // detect that the database exists and create a database with the - // -s000x extension. - // At this point, we need to skip the 'abort_if_exists' test if we - // are in this routine from the 'validate' and we are restarting - // since we won't really write to the file. So, the cases where we - // *don't* check are: - // -- is_input_event(db_usage) - // -- ifExists_ == DB_OVERWRITE || DB_ADD_SUFFIX_OVERWRITE || DB_APPEND - // -- is_automatic_restart() && step == 0 (coming from validate) - if(m_ifDatabaseExists != DB_OVERWRITE && - m_ifDatabaseExists != DB_APPEND && - m_ifDatabaseExists != DB_ADD_SUFFIX_OVERWRITE && - !(step == 0 && observer->is_automatic_restart())) - { - abort_if_exists(filename, m_dbType, db_usage); + m_properties.add(Ioss::Property("APPEND_OUTPUT", m_ifDatabaseExists)); + // A little complicated on deciding whether we are actually + // overwriting the database. The 'validate' routine for Results and + // History will call create_database once the parser block is + // ended. This routine will then create the database and the + // ioRegion_. However, the database will not really be opened or + // written to at this time. If the code is auto-restarting, then it will + // detect that the database exists and create a database with the + // -s000x extension. + // At this point, we need to skip the 'abort_if_exists' test if we + // are in this routine from the 'validate' and we are restarting + // since we won't really write to the file. So, the cases where we + // *don't* check are: + // -- is_input_event(db_usage) + // -- ifExists_ == DB_OVERWRITE || DB_ADD_SUFFIX_OVERWRITE || DB_APPEND + // -- is_automatic_restart() && step == 0 (coming from validate) + if (m_ifDatabaseExists != DB_OVERWRITE && m_ifDatabaseExists != DB_APPEND && + m_ifDatabaseExists != DB_ADD_SUFFIX_OVERWRITE && + !(step == 0 && observer->is_automatic_restart())) { + abort_if_exists(filename, m_dbType, db_usage); + } } + return filename; } - return filename; -} - -bool DynamicTopologyFileControl::abort_if_exists(const std::string &filename, - const std::string &db_type, - Ioss::DatabaseUsage db_usage) -{ - // Check whether file with same name as database already exists. If so, - // print error message and stop... - // At the current time, only check on processor 0 and assume if it doesn't exist - // there, then it doesn't exist on other processors. Or, if it doesn't exist on - // processor 0, then it doesn't matter if it doesn't exist on other processors - // since we don't have all pieces... - - bool exists = file_exists(filename, db_type, db_usage); - if (exists) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: The database file named '{} exists" - "and would be overwritten if the code continued.\n\n" - "Input options specified that this file *not* be overwritten,\n" - "\tso you must rename or remove this file and restart the code.\n", - filename); - IOSS_ERROR(errmsg); - } - return exists; -} - -Ioss::DatabaseIO * DynamicTopologyFileControl::clone_output_database(int steps) -{ - auto current_db = m_region->get_database(); - if (current_db->is_input()) - return nullptr; - - const Ioss::PropertyManager& current_properties = current_db->get_property_manager(); - Ioss::NameList names; - current_properties.describe(&names); - - // Iterate through properties and transfer to new output database... - Ioss::NameList::const_iterator I; - for (I = names.begin(); I != names.end(); ++I) { - if (!current_properties.exists(*I)) - m_properties.add(current_properties.get(*I)); + bool DynamicTopologyFileControl::abort_if_exists(const std::string &filename, + const std::string &db_type, + Ioss::DatabaseUsage db_usage) + { + // Check whether file with same name as database already exists. If so, + // print error message and stop... + // At the current time, only check on processor 0 and assume if it doesn't exist + // there, then it doesn't exist on other processors. Or, if it doesn't exist on + // processor 0, then it doesn't matter if it doesn't exist on other processors + // since we don't have all pieces... + + bool exists = file_exists(filename, db_type, db_usage); + if (exists) { + std::ostringstream errmsg; + fmt::print(errmsg, + "ERROR: The database file named '{} exists" + "and would be overwritten if the code continued.\n\n" + "Input options specified that this file *not* be overwritten,\n" + "\tso you must rename or remove this file and restart the code.\n", + filename); + IOSS_ERROR(errmsg); + } + return exists; } - auto db_usage = current_db->usage(); - - std::string filename = construct_database_filename(steps, db_usage); - - Ioss::DatabaseIO *db = Ioss::IOFactory::create(m_dbType, filename, db_usage, - current_db->util().communicator(), - m_properties); + Ioss::DatabaseIO *DynamicTopologyFileControl::clone_output_database(int steps) + { + auto current_db = m_region->get_database(); - if (nullptr == db) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: unable to create output database named '{}'" - " of type '{}'", filename, m_dbType); - IOSS_ERROR(errmsg); - } + if (current_db->is_input()) + return nullptr; - assert(db != nullptr); - if(!db->ok(true)) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: unable to validate output database named '{}'" - " of type '{}'", filename, m_dbType); - IOSS_ERROR(errmsg); - } + const Ioss::PropertyManager ¤t_properties = current_db->get_property_manager(); + Ioss::NameList names; + current_properties.describe(&names); - db->set_field_separator(current_db->get_field_separator()); - db->set_surface_split_type(current_db->get_surface_split_type()); - db->set_maximum_symbol_length(current_db->maximum_symbol_length()); - db->set_int_byte_size_api(current_db->int_byte_size_data_size()); - - return db; -} - -template -void update_database_for_grouping_entities(const T& container, Ioss::DatabaseIO *db) -{ - for(auto * entity : container) { - Ioss::GroupingEntity* ge = dynamic_cast(entity); - assert(ge != nullptr); - - if(ge->type() == Ioss::SIDESET) { - Ioss::SideSet *sset = dynamic_cast(ge); - assert(sset != nullptr); - - sset->reset_database(db); - const auto &sblocks = sset->get_side_blocks(); - for (const auto &sblock : sblocks) { - sblock->reset_database(db); - } - } else { - ge->reset_database(db); + // Iterate through properties and transfer to new output database... + Ioss::NameList::const_iterator I; + for (I = names.begin(); I != names.end(); ++I) { + if (!current_properties.exists(*I)) + m_properties.add(current_properties.get(*I)); } - } -} - -bool DynamicTopologyFileControl::replace_output_database(Ioss::DatabaseIO *db) -{ - auto current_db = m_region->get_database(); - if (current_db->is_input()) - return false; + auto db_usage = current_db->usage(); - current_db->finalize_database(); - current_db->closeDatabase(); - delete current_db; + std::string filename = construct_database_filename(steps, db_usage); - m_region->reset_database(db); - db->set_region(m_region); + Ioss::DatabaseIO *db = Ioss::IOFactory::create(m_dbType, filename, db_usage, + current_db->util().communicator(), m_properties); - update_database_for_grouping_entities(m_region->get_node_blocks(), db); - update_database_for_grouping_entities(m_region->get_edge_blocks(), db); - update_database_for_grouping_entities(m_region->get_face_blocks(), db); - update_database_for_grouping_entities(m_region->get_element_blocks(), db); - update_database_for_grouping_entities(m_region->get_sidesets(), db); - update_database_for_grouping_entities(m_region->get_nodesets(), db); - update_database_for_grouping_entities(m_region->get_edgesets(), db); - update_database_for_grouping_entities(m_region->get_facesets(), db); - update_database_for_grouping_entities(m_region->get_elementsets(), db); - update_database_for_grouping_entities(m_region->get_commsets(), db); - update_database_for_grouping_entities(m_region->get_structured_blocks(), db); - update_database_for_grouping_entities(m_region->get_assemblies(), db); - update_database_for_grouping_entities(m_region->get_blobs(), db); + if (nullptr == db) { + std::ostringstream errmsg; + fmt::print(errmsg, + "ERROR: unable to create output database named '{}'" + " of type '{}'", + filename, m_dbType); + IOSS_ERROR(errmsg); + } - return true; -} + assert(db != nullptr); + if (!db->ok(true)) { + std::ostringstream errmsg; + fmt::print(errmsg, + "ERROR: unable to validate output database named '{}'" + " of type '{}'", + filename, m_dbType); + IOSS_ERROR(errmsg); + } -void DynamicTopologyFileControl::clone_and_replace_output_database(int steps) -{ - auto db = clone_output_database(steps); + db->set_field_separator(current_db->get_field_separator()); + db->set_surface_split_type(current_db->get_surface_split_type()); + db->set_maximum_symbol_length(current_db->maximum_symbol_length()); + db->set_int_byte_size_api(current_db->int_byte_size_data_size()); - if(nullptr != db) - replace_output_database(db); -} + return db; + } -void DynamicTopologyFileControl::add_output_database_group(int steps) -{ - auto current_db = m_region->get_database(); + template + void update_database_for_grouping_entities(const T &container, Ioss::DatabaseIO *db) + { + for (auto *entity : container) { + Ioss::GroupingEntity *ge = dynamic_cast(entity); + assert(ge != nullptr); + + if (ge->type() == Ioss::SIDESET) { + Ioss::SideSet *sset = dynamic_cast(ge); + assert(sset != nullptr); + + sset->reset_database(db); + const auto &sblocks = sset->get_side_blocks(); + for (const auto &sblock : sblocks) { + sblock->reset_database(db); + } + } + else { + ge->reset_database(db); + } + } + } - std::ostringstream oss; - oss << "STEP-"; - oss << steps; + bool DynamicTopologyFileControl::replace_output_database(Ioss::DatabaseIO *db) + { + auto current_db = m_region->get_database(); + + if (current_db->is_input()) + return false; + + current_db->finalize_database(); + current_db->closeDatabase(); + delete current_db; + + m_region->reset_database(db); + db->set_region(m_region); + + update_database_for_grouping_entities(m_region->get_node_blocks(), db); + update_database_for_grouping_entities(m_region->get_edge_blocks(), db); + update_database_for_grouping_entities(m_region->get_face_blocks(), db); + update_database_for_grouping_entities(m_region->get_element_blocks(), db); + update_database_for_grouping_entities(m_region->get_sidesets(), db); + update_database_for_grouping_entities(m_region->get_nodesets(), db); + update_database_for_grouping_entities(m_region->get_edgesets(), db); + update_database_for_grouping_entities(m_region->get_facesets(), db); + update_database_for_grouping_entities(m_region->get_elementsets(), db); + update_database_for_grouping_entities(m_region->get_commsets(), db); + update_database_for_grouping_entities(m_region->get_structured_blocks(), db); + update_database_for_grouping_entities(m_region->get_assemblies(), db); + update_database_for_grouping_entities(m_region->get_blobs(), db); + + return true; + } - current_db->release_memory(); - current_db->open_root_group(); - current_db->create_subgroup(oss.str()); -} + void DynamicTopologyFileControl::clone_and_replace_output_database(int steps) + { + auto db = clone_output_database(steps); -} + if (nullptr != db) + replace_output_database(db); + } + void DynamicTopologyFileControl::add_output_database_group(int steps) + { + auto current_db = m_region->get_database(); + std::ostringstream oss; + oss << "STEP-"; + oss << steps; + current_db->release_memory(); + current_db->open_root_group(); + current_db->create_subgroup(oss.str()); + } +} // namespace Ioss diff --git a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h index be25390e3c..40e93ec3dc 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h +++ b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h @@ -6,8 +6,8 @@ #pragma once -#include "Ioss_DatabaseIO.h" // for DatabaseIO #include "Ioss_DBUsage.h" +#include "Ioss_DatabaseIO.h" // for DatabaseIO #include "Ioss_ParallelUtils.h" // for ParallelUtils #include "Ioss_PropertyManager.h" // for PropertyManager #include @@ -18,9 +18,9 @@ #include "Ioss_Utils.h" #include "ioss_export.h" -#include // for ostream +#include // for ostream #include -#include // for string, operator< +#include // for string, operator< namespace Ioss { class Region; @@ -42,41 +42,38 @@ namespace Ioss { * - TOPOLOGY_UNKNOWN: Something else, catchall option. */ enum TopologyModified { - TOPOLOGY_SAME = ( 0), //!< No change, also used for initialization - TOPOLOGY_REORDER = (1U << 0), //!< Data structures reordered on processor, no change between procs. - TOPOLOGY_SHUFFLE = (1U << 1), //!< Globally the same, data moved among processors. - TOPOLOGY_HADAPT = (1U << 2), //!< Elements split/combined; not moved cross-proc - TOPOLOGY_GHOST = (1U << 3), //!< Ghost entities created/destroyed - TOPOLOGY_GEOMETRY = (1U << 4), //!< Geometry (mesh coordinates) modified. Restart needs to know this. - TOPOLOGY_CREATEFACE = (1U << 5), //!< Face/Edge are created/deleted. - TOPOLOGY_CREATEELEM = (1U << 6), //!< Elements are created/deleted. - TOPOLOGY_CREATENODE = (1U << 7), //!< Nodes are created/deleted. - TOPOLOGY_UNKNOWN = (1U << 8), //!< Unknown change, recreate from scratch. - TOPOLOGY_AUXILIARY = (1U << 9), //!< An AUXILIARY relation was created/modified. - TOPOLOGY_CONSTRAINT = (1U << 10) //!< Contact constraints + TOPOLOGY_SAME = (0), //!< No change, also used for initialization + TOPOLOGY_REORDER = + (1U << 0), //!< Data structures reordered on processor, no change between procs. + TOPOLOGY_SHUFFLE = (1U << 1), //!< Globally the same, data moved among processors. + TOPOLOGY_HADAPT = (1U << 2), //!< Elements split/combined; not moved cross-proc + TOPOLOGY_GHOST = (1U << 3), //!< Ghost entities created/destroyed + TOPOLOGY_GEOMETRY = + (1U << 4), //!< Geometry (mesh coordinates) modified. Restart needs to know this. + TOPOLOGY_CREATEFACE = (1U << 5), //!< Face/Edge are created/deleted. + TOPOLOGY_CREATEELEM = (1U << 6), //!< Elements are created/deleted. + TOPOLOGY_CREATENODE = (1U << 7), //!< Nodes are created/deleted. + TOPOLOGY_UNKNOWN = (1U << 8), //!< Unknown change, recreate from scratch. + TOPOLOGY_AUXILIARY = (1U << 9), //!< An AUXILIARY relation was created/modified. + TOPOLOGY_CONSTRAINT = (1U << 10) //!< Contact constraints }; - enum class FileControlOption { - CONTROL_NONE, - CONTROL_AUTO_MULTI_FILE, - CONTROL_AUTO_SINGLE_FILE - }; + enum class FileControlOption { CONTROL_NONE, CONTROL_AUTO_MULTI_FILE, CONTROL_AUTO_SINGLE_FILE }; class IOSS_EXPORT DynamicTopologyObserver { public: - DynamicTopologyObserver(Region *region) - : m_region(region) {} + DynamicTopologyObserver(Region *region) : m_region(region) {} DynamicTopologyObserver() {} virtual ~DynamicTopologyObserver() {} - virtual void reset_topology_modification(); - virtual void set_topology_modification(unsigned int type); + virtual void reset_topology_modification(); + virtual void set_topology_modification(unsigned int type); virtual unsigned int get_topology_modification() const; virtual unsigned int get_cumulative_topology_modification() const; - virtual void set_cumulative_topology_modification(unsigned int type); + virtual void set_cumulative_topology_modification(unsigned int type); int get_cumulative_topology_modification_field(); @@ -84,28 +81,34 @@ namespace Ioss { virtual bool is_automatic_restart() const { return false; } virtual bool is_restart_requested() const { return false; } - static const std::string topology_modification_change_name() {return std::string("CUMULATIVE_TOPOLOGY_MODIFICATION");} + static const std::string topology_modification_change_name() + { + return std::string("CUMULATIVE_TOPOLOGY_MODIFICATION"); + } - void register_region(Region *region); - Region* get_region() const { return m_region; } + void register_region(Region *region); + Region *get_region() const { return m_region; } - virtual void define_model(Region& region); - virtual void write_model(Region& region); - virtual void define_transient(Region& region); + virtual void define_model(Region ®ion); + virtual void write_model(Region ®ion); + virtual void define_transient(Region ®ion); - virtual FileControlOption get_control_option() const { return FileControlOption::CONTROL_AUTO_MULTI_FILE; } + virtual FileControlOption get_control_option() const + { + return FileControlOption::CONTROL_AUTO_MULTI_FILE; + } protected: - Region *m_region{nullptr}; + Region *m_region{nullptr}; unsigned int m_topologyModification{TOPOLOGY_SAME}; unsigned int m_cumulativeTopologyModification{TOPOLOGY_SAME}; bool m_automaticRestart{false}; bool m_restartRequested{false}; - void check_region() const; + void check_region() const; IOSS_NODISCARD const ParallelUtils &util() const; - void synchronize_topology_modified_flags(); + void synchronize_topology_modified_flags(); }; class IOSS_EXPORT DynamicTopologyFileControl @@ -113,32 +116,33 @@ namespace Ioss { public: DynamicTopologyFileControl(Region *region, unsigned int fileCyclicCount, IfDatabaseExistsBehavior &ifDatabaseExists, - unsigned int &dbChangeCount); + unsigned int &dbChangeCount); - void clone_and_replace_output_database(int steps=0); - void add_output_database_group(int steps=0); + void clone_and_replace_output_database(int steps = 0); + void add_output_database_group(int steps = 0); private: - Region *m_region{nullptr}; + Region *m_region{nullptr}; std::string m_ioDB; std::string m_dbType; PropertyManager m_properties; - unsigned int m_fileCyclicCount; + unsigned int m_fileCyclicCount; IfDatabaseExistsBehavior &m_ifDatabaseExists; - unsigned int &m_dbChangeCount; + unsigned int &m_dbChangeCount; IOSS_NODISCARD const ParallelUtils &util() const; std::string get_unique_filename(DatabaseUsage db_usage); - std::string construct_database_filename(int& step, DatabaseUsage db_usage); - bool file_exists(const std::string &filename, const std::string &db_type, DatabaseUsage db_usage); - bool abort_if_exists(const std::string &filename, const std::string &db_type, - DatabaseUsage db_usage); - - DatabaseIO * clone_output_database(int steps); - bool replace_output_database(DatabaseIO *db); + std::string construct_database_filename(int &step, DatabaseUsage db_usage); + bool file_exists(const std::string &filename, const std::string &db_type, + DatabaseUsage db_usage); + bool abort_if_exists(const std::string &filename, const std::string &db_type, + DatabaseUsage db_usage); + + DatabaseIO *clone_output_database(int steps); + bool replace_output_database(DatabaseIO *db); }; } // namespace Ioss diff --git a/packages/seacas/libraries/ioss/src/Ioss_FaceGenerator.h b/packages/seacas/libraries/ioss/src/Ioss_FaceGenerator.h index 84f1e328e8..b658e66cd5 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_FaceGenerator.h +++ b/packages/seacas/libraries/ioss/src/Ioss_FaceGenerator.h @@ -41,20 +41,17 @@ namespace Ioss { { assert(element_id != 0); if (element[0] == 0) { - element[0] = element_id; + element[0] = element_id; } else if (element[1] == 0) { - element[1] = element_id; + element[1] = element_id; } else { face_element_error(element_id); } } - int element_count() const - { - return (element[0] != 0) + (element[1] != 0); - } + int element_count() const { return (element[0] != 0) + (element[1] != 0); } void add_element(size_t element_id, size_t face_ordinal) const { @@ -116,7 +113,7 @@ namespace Ioss { #if defined FG_USE_STD using FaceUnorderedSet = std::unordered_set; #elif defined FG_USE_HOPSCOTCH - //using FaceUnorderedSet = tsl::hopscotch_set; + // using FaceUnorderedSet = tsl::hopscotch_set; using FaceUnorderedSet = tsl::hopscotch_pg_set; #elif defined FG_USE_ROBIN // using FaceUnorderedSet = tsl::robin_set; @@ -138,7 +135,7 @@ namespace Ioss { FaceUnorderedSet &faces(const std::string &name = "ALL") { return faces_[name]; } FaceUnorderedSet &faces(const ElementBlock *block); - void clear(const std::string &name) {faces_[name].clear();} + void clear(const std::string &name) { faces_[name].clear(); } void clear(const ElementBlock *block); //! Given a local node id (0-based), return the hashed value. @@ -148,7 +145,7 @@ namespace Ioss { private: template void hash_node_ids(const std::vector &node_ids); - void hash_local_node_ids(size_t count); + void hash_local_node_ids(size_t count); template void generate_model_faces(INT /*dummy*/, bool local_ids); Ioss::Region ®ion_; diff --git a/packages/seacas/libraries/ioss/src/Ioss_IOFactory.C b/packages/seacas/libraries/ioss/src/Ioss_IOFactory.C index 463040ed0f..80d30ac63c 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_IOFactory.C +++ b/packages/seacas/libraries/ioss/src/Ioss_IOFactory.C @@ -93,7 +93,7 @@ Ioss::DatabaseIO *Ioss::IOFactory::create(const std::string &type, const std::st } } else { - auto my_props(properties); + auto my_props(properties); my_props.add(Property("database_type", type)); Ioss::ParallelUtils pu(communicator); diff --git a/packages/seacas/libraries/ioss/src/Ioss_Region.h b/packages/seacas/libraries/ioss/src/Ioss_Region.h index 9a7f27754b..5e62bab876 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Region.h +++ b/packages/seacas/libraries/ioss/src/Ioss_Region.h @@ -7,10 +7,10 @@ #pragma once #include "Ioss_CoordinateFrame.h" // for CoordinateFrame -#include "Ioss_DatabaseIO.h" // for DatabaseIO #include "Ioss_DBUsage.h" +#include "Ioss_DatabaseIO.h" // for DatabaseIO #include "Ioss_DynamicTopology.h" -#include "Ioss_EntityType.h" // for EntityType, etc +#include "Ioss_EntityType.h" // for EntityType, etc #include "Ioss_Field.h" #include "Ioss_GroupingEntity.h" // for GroupingEntity #include "Ioss_MeshType.h" @@ -285,17 +285,23 @@ namespace Ioss { std::vector &field_data) const; void register_mesh_modification_observer(std::shared_ptr observer); - std::shared_ptr get_mesh_modification_observer() const { return topologyObserver; } + std::shared_ptr get_mesh_modification_observer() const + { + return topologyObserver; + } - void start_new_output_database_entry(int steps=0); + void start_new_output_database_entry(int steps = 0); - void set_topology_change_count(unsigned int new_count) {dbChangeCount = new_count;} - unsigned int get_topology_change_count() {return dbChangeCount;} + void set_topology_change_count(unsigned int new_count) { dbChangeCount = new_count; } + unsigned int get_topology_change_count() { return dbChangeCount; } - void set_file_cyclic_count(unsigned int new_count) {fileCyclicCount = new_count;} - unsigned int get_file_cyclic_count() {return fileCyclicCount;} + void set_file_cyclic_count(unsigned int new_count) { fileCyclicCount = new_count; } + unsigned int get_file_cyclic_count() { return fileCyclicCount; } - void set_if_database_exists_behavior(IfDatabaseExistsBehavior if_exists) {ifDatabaseExists = if_exists;} + void set_if_database_exists_behavior(IfDatabaseExistsBehavior if_exists) + { + ifDatabaseExists = if_exists; + } bool model_is_written() const { return modelWritten; } bool transient_is_written() const { return transientWritten; } @@ -303,8 +309,8 @@ namespace Ioss { bool load_group_mesh(const std::string &group_name); protected: - void clone_and_replace_output_database(int steps=0); - void add_output_database_group(int steps=0, bool force_addition=false); + void clone_and_replace_output_database(int steps = 0); + void add_output_database_group(int steps = 0, bool force_addition = false); int64_t internal_get_field_data(const Field &field, void *data, size_t data_size = 0) const override; @@ -361,8 +367,9 @@ namespace Ioss { std::shared_ptr topologyObserver; - unsigned int dbChangeCount{1}; //!< Used to track number of topology changes. - unsigned int fileCyclicCount{0}; //!< For cycling file-A, file-B, file-C, ..., File-A, typically restart only. + unsigned int dbChangeCount{1}; //!< Used to track number of topology changes. + unsigned int fileCyclicCount{ + 0}; //!< For cycling file-A, file-B, file-C, ..., File-A, typically restart only. IfDatabaseExistsBehavior ifDatabaseExists{DB_OVERWRITE}; bool modelWritten{false};