| 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_DBUsage.h" |
| 10 |
#include "Ioss_DatabaseIO.h" |
| 11 |
#include "Ioss_ParallelUtils.h" |
| 12 |
#include "Ioss_PropertyManager.h" |
| 13 |
#include "Ioss_Region.h" |
| 14 |
|
| 15 |
#include <cstddef> |
| 16 |
#include <functional> |
| 17 |
#include <sstream> |
| 18 |
#include <string> |
| 19 |
#include <utility> |
| 20 |
|
| 21 |
namespace Ioss { |
| 22 |
|
| 23 |
using FileNameGenerator = |
| 24 |
std::function<std::string(const std::string &baseFileName, unsigned step)>; |
| 25 |
|
| 26 |
enum ChangeSetFormat { |
| 27 |
CHANGE_SET_NONE = (0), |
| 28 |
CHANGE_SET_INTERNAL_FILES = (1U << 0), |
| 29 |
CHANGE_SET_LINEAR_MULTI_FILES = (1U << 1), |
| 30 |
CHANGE_SET_CYCLIC_MULTI_FILES = (1U << 2) |
| 31 |
}; |
| 32 |
|
| 33 |
std::pair<std::string, Ioss::DatabaseIO *> |
| 34 |
expand_topology_files(FileNameGenerator generator, const Ioss::ParallelUtils &util, |
| 35 |
const std::string &basename, const std::string &db_type, |
| 36 |
const Ioss::PropertyManager &properties, Ioss::DatabaseUsage usage, |
| 37 |
int step); |
| 38 |
|
| 39 |
std::string expand_topology_files(FileNameGenerator generator, const Ioss::ParallelUtils &util, |
| 40 |
const std::string &basename, |
| 41 |
const Ioss::PropertyManager &properties, |
| 42 |
Ioss::DatabaseUsage usage, int step); |
| 43 |
|
| 44 |
FileNameGenerator construct_cyclic_filename_generator(unsigned cyclicCount); |
| 45 |
FileNameGenerator construct_linear_filename_generator(); |
| 46 |
|
| 47 |
class IOSS_EXPORT ChangeSet |
| 48 |
{ |
| 49 |
public: |
| 50 |
explicit ChangeSet(Ioss::Region *region); |
| 51 |
ChangeSet(Ioss::DatabaseIO *db, const std::string &dbName, const std::string &dbType, |
| 52 |
unsigned fileCyclicCount); |
| 53 |
|
| 54 |
virtual ~ChangeSet(); |
| 55 |
ChangeSet() = delete; |
| 56 |
ChangeSet(const ChangeSet &) = delete; |
| 57 |
|
| 58 |
IOSS_NODISCARD unsigned supported_formats() const { return m_supportedFormats; } |
| 59 |
IOSS_NODISCARD unsigned database_format() const { return m_databaseFormat; } |
| 60 |
|
| 61 |
virtual void populate_change_sets(bool loadAllFiles = true); |
| 62 |
|
| 63 |
IOSS_NODISCARD virtual DatabaseIO *open_change_set(unsigned index, Ioss::DatabaseUsage usage); |
| 64 |
virtual void close_change_set(unsigned index); |
| 65 |
|
| 66 |
IOSS_NODISCARD size_t size() const { return m_changeSetNames.size(); } |
| 67 |
IOSS_NODISCARD const std::vector<std::string> &names() const { return m_changeSetNames; } |
| 68 |
IOSS_NODISCARD std::string get_change_set_name(unsigned index) const; |
| 69 |
|
| 70 |
IOSS_NODISCARD unsigned get_file_cyclic_count() const { return m_fileCyclicCount; } |
| 71 |
|
| 72 |
static std::string get_cyclic_database_filename(const std::string &baseFileName, |
| 73 |
unsigned int fileCyclicCount, |
| 74 |
unsigned int step); |
| 75 |
|
| 76 |
static std::string get_linear_database_filename(const std::string &baseFileName, |
| 77 |
unsigned int step); |
| 78 |
|
| 79 |
private: |
| 80 |
std::vector<DatabaseIO *> m_changeSetDatabases; |
| 81 |
|
| 82 |
protected: |
| 83 |
void get_cyclic_multi_file_change_sets(); |
| 84 |
void get_linear_multi_file_change_sets(); |
| 85 |
|
| 86 |
void verify_change_set_index(unsigned index) const; |
| 87 |
|
| 88 |
virtual void clear_change_sets(); |
| 89 |
|
| 90 |
DatabaseIO *get_database() const; |
| 91 |
IOSS_NODISCARD const ParallelUtils &util() const; |
| 92 |
|
| 93 |
Ioss::DatabaseIO *m_database{nullptr}; |
| 94 |
std::string m_ioDB; |
| 95 |
std::string m_dbType; |
| 96 |
unsigned m_fileCyclicCount{0}; |
| 97 |
|
| 98 |
unsigned m_supportedFormats{CHANGE_SET_LINEAR_MULTI_FILES | CHANGE_SET_CYCLIC_MULTI_FILES}; |
| 99 |
unsigned m_databaseFormat{CHANGE_SET_NONE}; |
| 100 |
|
| 101 |
std::vector<std::string> m_changeSetNames; |
| 102 |
}; |
| 103 |
|
| 104 |
} // namespace Ioss |