| 1 |
// Copyright(C) 2024 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 |
#pragma once |
| 8 |
|
| 9 |
#include "Ioss_DynamicTopology.h" |
| 10 |
|
| 11 |
#include "Ioss_CodeTypes.h" |
| 12 |
#include "Ioss_DBUsage.h" |
| 13 |
#include "Ioss_DatabaseIO.h" // for DatabaseIO |
| 14 |
#include "Ioss_ParallelUtils.h" // for ParallelUtils |
| 15 |
#include "Ioss_PropertyManager.h" // for PropertyManager |
| 16 |
#include "Ioss_Utils.h" |
| 17 |
#include "ioss_export.h" |
| 18 |
|
| 19 |
#include <cstddef> // for size_t, nullptr |
| 20 |
#include <cstdint> // for int64_t |
| 21 |
#include <iomanip> |
| 22 |
#include <sstream> |
| 23 |
#include <string> // for string, operator< |
| 24 |
|
| 25 |
namespace Ioss { |
| 26 |
class Region; |
| 27 |
class DynamicTopologyNotifier; |
| 28 |
|
| 29 |
class IOSS_EXPORT DynamicTopologyObserver |
| 30 |
{ |
| 31 |
public: |
| 32 |
explicit DynamicTopologyObserver(Region *region) : m_region(region) {} |
| 33 |
|
| 34 |
virtual ~DynamicTopologyObserver() = default; |
| 35 |
|
| 36 |
virtual void reset_topology_modification_all(); |
| 37 |
virtual void reset_topology_modification(); |
| 38 |
virtual void set_topology_modification(unsigned int type); |
| 39 |
virtual void sync_topology_modification(unsigned int modFlag, unsigned int cumulativeModFlag); |
| 40 |
virtual unsigned int get_topology_modification() const; |
| 41 |
|
| 42 |
virtual unsigned int get_cumulative_topology_modification() const; |
| 43 |
virtual void set_cumulative_topology_modification(unsigned int type); |
| 44 |
|
| 45 |
int get_cumulative_topology_modification_field(); |
| 46 |
|
| 47 |
virtual bool is_topology_modified() const; |
| 48 |
virtual bool is_automatic_restart() const { return m_automaticRestart; } |
| 49 |
virtual bool is_restart_requested() const { return m_restartRequested; } |
| 50 |
|
| 51 |
void set_automatic_restart(bool flag) { m_automaticRestart = flag; } |
| 52 |
void set_restart_requested(bool flag) { m_restartRequested = flag; } |
| 53 |
|
| 54 |
static std::string topology_modification_change_name() |
| 55 |
{ |
| 56 |
return std::string("CUMULATIVE_TOPOLOGY_MODIFICATION"); |
| 57 |
} |
| 58 |
|
| 59 |
void register_region(Region *region); |
| 60 |
Region *get_region() const { return m_region; } |
| 61 |
|
| 62 |
void register_notifier(DynamicTopologyNotifier *notifier); |
| 63 |
DynamicTopologyNotifier *get_notifier() const { return m_notifier; } |
| 64 |
|
| 65 |
virtual void define_model(); |
| 66 |
virtual void write_model(); |
| 67 |
virtual void define_transient(); |
| 68 |
|
| 69 |
virtual FileControlOption get_control_option() const { return FileControlOption::CONTROL_NONE; } |
| 70 |
|
| 71 |
virtual bool needs_new_output_file() const; |
| 72 |
|
| 73 |
virtual void initialize_region(); |
| 74 |
|
| 75 |
protected: |
| 76 |
Region *m_region{nullptr}; |
| 77 |
unsigned int m_topologyModification{TOPOLOGY_SAME}; |
| 78 |
unsigned int m_cumulativeTopologyModification{TOPOLOGY_SAME}; |
| 79 |
|
| 80 |
bool m_automaticRestart{false}; |
| 81 |
bool m_restartRequested{false}; |
| 82 |
|
| 83 |
DynamicTopologyNotifier *m_notifier{nullptr}; |
| 84 |
|
| 85 |
void verify_region_is_registered() const; |
| 86 |
IOSS_NODISCARD const ParallelUtils &util() const; |
| 87 |
void synchronize_topology_modified_flags(); |
| 88 |
|
| 89 |
void set_topology_modification_nl(unsigned int type); |
| 90 |
|
| 91 |
private: |
| 92 |
DynamicTopologyObserver(); |
| 93 |
}; |
| 94 |
|
| 95 |
} // namespace Ioss |