| 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 |
|
| 28 |
class IOSS_EXPORT DynamicTopologyStateLocator |
| 29 |
{ |
| 30 |
public: |
| 31 |
DynamicTopologyStateLocator(Region *region, bool loadAllFiles = true); |
| 32 |
DynamicTopologyStateLocator(Ioss::DatabaseIO *db, const std::string &dbName, |
| 33 |
const std::string &dbType, unsigned fileCyclicCount = 0, |
| 34 |
bool loadAllFiles = true); |
| 35 |
DynamicTopologyStateLocator(Ioss::DatabaseIO *db, unsigned fileCyclicCount = 0, |
| 36 |
bool loadAllFiles = true); |
| 37 |
|
| 38 |
virtual ~DynamicTopologyStateLocator(); |
| 39 |
DynamicTopologyStateLocator() = delete; |
| 40 |
DynamicTopologyStateLocator(const DynamicTopologyStateLocator &) = delete; |
| 41 |
|
| 42 |
DatabaseIO *get_database() const; |
| 43 |
|
| 44 |
std::tuple<std::string, int, double> locate_db_state(double targetTime) const; |
| 45 |
std::tuple<std::string, int, double> get_db_min_time() const; |
| 46 |
std::tuple<std::string, int, double> get_db_max_time() const; |
| 47 |
|
| 48 |
private: |
| 49 |
struct DatabaseState |
| 50 |
{ |
| 51 |
explicit DatabaseState(Ioss::DatabaseIO *db) |
| 52 |
{ |
| 53 |
if (!db->supports_internal_change_set()) { |
| 54 |
changeSet = db->get_filename(); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
std::string changeSet{"/"}; |
| 59 |
int state{-1}; |
| 60 |
double time{-std::numeric_limits<double>::max()}; |
| 61 |
}; |
| 62 |
|
| 63 |
using StateLocatorCompare = std::function<bool(double, double)>; |
| 64 |
|
| 65 |
void locate_state_impl(Ioss::DatabaseIO *db, double targetTime, StateLocatorCompare comparator, |
| 66 |
DatabaseState &loc) const; |
| 67 |
|
| 68 |
void locate_state(Ioss::DatabaseIO *db, double targetTime, DatabaseState &loc) const; |
| 69 |
|
| 70 |
void locate_db_state_impl(double targetTime, DatabaseState &loc) const; |
| 71 |
|
| 72 |
void get_db_time_impl(double init_time, StateLocatorCompare comparator, |
| 73 |
DatabaseState &loc) const; |
| 74 |
|
| 75 |
IOSS_NODISCARD const ParallelUtils &util() const; |
| 76 |
|
| 77 |
Ioss::DatabaseIO *m_database{nullptr}; |
| 78 |
std::string m_ioDB; |
| 79 |
std::string m_dbType; |
| 80 |
unsigned m_fileCyclicCount{0}; |
| 81 |
bool m_loadAllFiles{true}; |
| 82 |
}; |
| 83 |
|
| 84 |
} // namespace Ioss |