Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic topology phase IV #481

Merged
merged 47 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
feb7c5a
IOSS: More changes to support Dynamic Topology
tokusanya Aug 15, 2024
ef77556
Merge remote-tracking branch 'upstream/master' into DynamicTopology-P…
tokusanya Aug 15, 2024
f273e85
IOSS: Dynamic Topology changes based on code review
tokusanya Aug 16, 2024
9f82422
IOSS:: More functonality to support Dynamic Topology
tokusanya Aug 18, 2024
779e765
IOSS: Attempt to provide "change set" concept instead of "groups"
tokusanya Aug 20, 2024
e7c1db2
Merge remote-tracking branch 'upstream/master' into DynamicTopology-P…
tokusanya Aug 20, 2024
d1b1732
IOSS: Fix compiler errors
tokusanya Aug 21, 2024
14aef54
Merge remote-tracking branch 'upstream/master' into DynamicTopology-P…
tokusanya Aug 21, 2024
90f97ec
IOSS: Refactoring and unit test fix
tokusanya Aug 21, 2024
14be761
IOSS: Introduce concept of Change Sets
tokusanya Sep 2, 2024
4c21e0b
Merge remote-tracking branch 'upstream/master' into DynamicTopology-P…
tokusanya Sep 3, 2024
2c71918
Hush compiler issues
tokusanya Sep 3, 2024
2791f05
Fix for Dynamic Topology unit test
tokusanya Sep 3, 2024
61236e4
Merge branch 'master' into DynamicTopology-PhaseIV
tokusanya Sep 7, 2024
2794a19
Hush more compiler warnings and address some review comments
tokusanya Sep 11, 2024
2fa97fc
Bump step-security/harden-runner from 2.9.1 to 2.10.0 (#492)
dependabot[bot] Sep 10, 2024
963c159
Lossy compression (#464)
gsjaardema Sep 11, 2024
1351b3c
Merge branch 'master' into DynamicTopology-PhaseIV
tokusanya Sep 11, 2024
bd521ac
Merge branch 'master' into DynamicTopology-PhaseIV
tokusanya Sep 23, 2024
9665d13
Bug fixes and some more refactoring
tokusanya Sep 25, 2024
dfa841c
Merge remote-tracking branch 'upstream/master' into DynamicTopology-P…
tokusanya Sep 25, 2024
3474237
Add more functionality to support app-side DTIO
tokusanya Sep 26, 2024
4620253
Merge remote-tracking branch 'upstream/master' into DynamicTopology-P…
tokusanya Sep 26, 2024
e0de79e
More fixes based on review comments
tokusanya Oct 3, 2024
b37d602
Merge remote-tracking branch 'upstream/master' into DynamicTopology-P…
tokusanya Oct 3, 2024
c198bc2
Merge branch 'master' into DynamicTopology-PhaseIV
gsjaardema Oct 3, 2024
4b104fd
Fix typo from previous merge
gsjaardema Oct 4, 2024
311ad5d
Fix issue with invalid exodus file pointer
gsjaardema Oct 8, 2024
0e574e4
IOSS: Remove commented out code
gsjaardema Oct 9, 2024
c258074
Merge branch 'master' into DynamicTopology-PhaseIV
gsjaardema Oct 9, 2024
2eb8964
Merge branch 'master' into DynamicTopology-PhaseIV
gsjaardema Oct 14, 2024
e289e04
Committing clang-format changes
github-actions[bot] Oct 14, 2024
ddf0161
Update io_shell.C from groups to change sets
gsjaardema Oct 14, 2024
a8f2539
Committing clang-format changes
github-actions[bot] Oct 14, 2024
73b4918
Update io_shell_ts.C
gsjaardema Oct 14, 2024
62828ef
DTIO: More fixes to support app usage
tokusanya Oct 16, 2024
523c2ef
Bump sphinx from 8.1.1 to 8.1.3 in /cmake/tribits/doc/sphinx (#523)
dependabot[bot] Oct 14, 2024
8401ace
Bump github/codeql-action from 3.26.12 to 3.26.13 (#524)
dependabot[bot] Oct 14, 2024
6eb2c06
Bump ubuntu from `b359f10` to `ab64a83` in /docker/seacas (#525)
dependabot[bot] Oct 14, 2024
915851b
Bump ubuntu from `b359f10` to `ab64a83` in /docker/exodus (#526)
dependabot[bot] Oct 14, 2024
19db1ff
CI: Add harden runner to clang-format
gdsjaar Oct 15, 2024
697207b
CI: Try different trailing whitespace [ci skip]
gdsjaar Oct 16, 2024
9d55a3f
Merge branch 'master' into DynamicTopology-PhaseIV
gsjaardema Oct 16, 2024
550a642
Committing clang-format changes
github-actions[bot] Oct 16, 2024
5eb0fb5
DTIO: Fix for bad merge and compiler complaints
tokusanya Oct 16, 2024
4626efd
DTIO: Split files into individual classes
tokusanya Oct 16, 2024
a37070b
Committing clang-format changes
github-actions[bot] Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ namespace Ioss {
return groups_describe_nl(return_full_names);
}

IOSS_NODISCARD virtual std::string get_group_name() const { return "/"; }

/** \brief Set the database to the given State.
*
* All transitions must begin from the 'STATE_CLOSED' state or be to
Expand Down Expand Up @@ -356,7 +358,13 @@ namespace Ioss {
void get_step_times()
{
IOSS_FUNC_ENTER(m_);
return get_step_times_nl();
get_step_times_nl();
}

std::vector<double> get_db_step_times()
gsjaardema marked this conversation as resolved.
Show resolved Hide resolved
{
IOSS_FUNC_ENTER(m_);
return get_db_step_times_nl();
}

IOSS_NODISCARD virtual bool internal_edges_available() const { return false; }
Expand Down Expand Up @@ -805,6 +813,7 @@ namespace Ioss {

virtual void read_meta_data_nl() = 0;
virtual void get_step_times_nl() {}
virtual std::vector<double> get_db_step_times_nl() { return std::vector<double>(); }

virtual bool begin_state_nl(int state, double time);
virtual bool end_state_nl(int state, double time);
Expand Down
74 changes: 74 additions & 0 deletions packages/seacas/libraries/ioss/src/Ioss_Region.C
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,56 @@ namespace {
entity->field_erase(role);
}
}

struct NearestGroupState
{
std::string group{"/"};
int nearestState{-1};
double nearestTime{-std::numeric_limits<double>::max()};
};

void get_state_time_round_down(Ioss::DatabaseIO *db, const double targetTime, NearestGroupState& loc)
{
gsjaardema marked this conversation as resolved.
Show resolved Hide resolved
std::vector<double> timesteps = db->get_db_step_times();
int stepCount = timesteps.size();

double minTimeDiff = loc.nearestState < 0 ? std::numeric_limits<double>::max() : std::abs(loc.nearestTime - targetTime);

for(int istep = 1; istep <= stepCount; istep++) {
double stateTime = timesteps[istep-1];
double stepTimeDiff = std::abs(stateTime - targetTime);
if(stepTimeDiff <= minTimeDiff) {
minTimeDiff = stepTimeDiff;
loc.nearestTime = stateTime;
loc.nearestState = istep;
loc.group = db->get_group_name();
}
}
}

void locate_state(Ioss::DatabaseIO *db, const double targetTime, NearestGroupState& loc)
{
// Get state count and all states...
std::vector<double> timesteps = db->get_db_step_times();
int stepCount = timesteps.size();

if(targetTime < 0.0) {
gsjaardema marked this conversation as resolved.
Show resolved Hide resolved
get_state_time_round_down(db, targetTime, loc);
}
else {
double minTimeDiff = loc.nearestState < 0 ? std::numeric_limits<double>::max() : std::fabs(targetTime - loc.nearestTime);
for(int istep = 1; istep <= stepCount; istep++) {
double stateTime = timesteps[istep-1];
double stepTimeDiff = std::fabs(targetTime - stateTime);
gsjaardema marked this conversation as resolved.
Show resolved Hide resolved
if(stepTimeDiff < minTimeDiff) {
minTimeDiff = stepTimeDiff;
loc.nearestTime = stateTime;
loc.nearestState = istep;
loc.group = db->get_group_name();
}
}
}
}
} // namespace

namespace Ioss {
Expand Down Expand Up @@ -3055,4 +3105,28 @@ namespace Ioss {
topologyObserver->reset_topology_modification();
}
}

std::string Region::get_group_name() const
gsjaardema marked this conversation as resolved.
Show resolved Hide resolved
{
return get_database()->get_group_name();
}

std::tuple<std::string, int, double> Region::locate_db_state(const double targetTime)
gsjaardema marked this conversation as resolved.
Show resolved Hide resolved
{
NearestGroupState loc;

auto db = get_database();
std::string currentGroup = db->get_group_name();

for(int i=0; i<db->num_child_group(); i++) {
db->open_root_group();
db->open_child_group(i);
locate_state(db, targetTime, loc);
}

db->open_root_group();
db->open_group(currentGroup);

return std::make_tuple(loc.group, loc.nearestState, loc.nearestTime);
}
} // namespace Ioss
5 changes: 5 additions & 0 deletions packages/seacas/libraries/ioss/src/Ioss_Region.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <memory>
#include <sstream>
#include <string> // for string, operator<
#include <tuple>
#include <utility> // for pair
#include <vector> // for vector

Expand Down Expand Up @@ -313,6 +314,10 @@ namespace Ioss {
bool load_group_mesh(const std::string &child_group_name);
bool load_group_mesh(const int child_group_index);

std::string get_group_name() const;

IOSS_NODISCARD std::tuple<std::string, int, double> locate_db_state(const double targetTime);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some compilers/analyzers will warn/complain about value parameters with const since it doesn't matter if it is const or not at this level since a copy is being passed and not the address of the clients value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can change that programming style then ... I'm used to the idea of making sure that all possible arguments that can be const should be const


protected:
void update_dynamic_topology();
void clone_and_replace_output_database(int steps = 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,16 @@ namespace Iocatalyst {
return true;
}

std::vector<double> getTime()
{
std::vector<double> times;
auto &node = this->DBNode;
if (node.has_path(getTimePath())) {
times.push_back(node[getTimePath()].as_float64());
}
return times;
}

int64_t putField(const std::string &containerName, const Ioss::GroupingEntity *entityGroup,
const Ioss::Field &field, void *data, size_t data_size, bool deep_copy)
{
Expand Down Expand Up @@ -1426,6 +1436,12 @@ namespace Iocatalyst {
impl.readTime(region);
}

std::vector<double> DatabaseIO::get_db_step_times_nl()
{
auto &impl = (*this->Impl.get());
return impl.getTime();
}

void *DatabaseIO::get_catalyst_conduit_node()
{
auto &impl = (*this->Impl.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace Iocatalyst {

void read_meta_data_nl() override;
void get_step_times_nl() override;
std::vector<double> get_db_step_times_nl() override;

bool begin_state_nl(int state, double time) override;
bool end_state_nl(int state, double time) override;
Expand Down
10 changes: 10 additions & 0 deletions packages/seacas/libraries/ioss/src/cgns/Iocgns_DatabaseIO.C
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,16 @@ namespace Iocgns {
myProcessor);
}

std::vector<double> DatabaseIO::get_db_step_times_nl()
{
std::vector<double> timesteps;

Utils::get_step_times(get_file_pointer(), timesteps, nullptr, timeScaleFactor,
myProcessor);

return timesteps;
}

void DatabaseIO::write_adjacency_data()
{
// Determine adjacency information between unstructured blocks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ namespace Iocgns {
size_t finalize_structured_blocks();
void finalize_database() const override;
void get_step_times_nl() override;
std::vector<double> get_db_step_times_nl() override;

void create_unstructured_block(int base, int zone, size_t &num_node);
void write_adjacency_data();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,16 @@ namespace Iocgns {
myProcessor);
}

std::vector<double> ParallelDatabaseIO::get_db_step_times_nl()
{
std::vector<double> timesteps;

Utils::get_step_times(get_file_pointer(), timesteps, nullptr, timeScaleFactor,
myProcessor);

return timesteps;
}

void ParallelDatabaseIO::write_adjacency_data()
{
// Determine adjacency information between unstructured blocks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ namespace Iocgns {
int64_t handle_node_ids(void *ids, int64_t num_to_get) const;
void finalize_database() const override;
void get_step_times_nl() override;
std::vector<double> get_db_step_times_nl() override;
void write_adjacency_data();

int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
Expand Down
4 changes: 3 additions & 1 deletion packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,9 @@ int Iocgns::Utils::get_step_times(int cgns_file_ptr, std::vector<double> &timest

timesteps.reserve(num_timesteps);
for (int i = 0; i < num_timesteps; i++) {
region->add_state(times[i] * timeScaleFactor);
if(nullptr != region) {
region->add_state(times[i] * timeScaleFactor);
}
timesteps.push_back(times[i]);
}
return num_timesteps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ namespace Ioex {
// database supports that type (e.g. return_value & Ioss::FACESET)
IOSS_NODISCARD unsigned entity_field_support() const override;

IOSS_NODISCARD std::string get_group_name() const override { return m_groupName; }

protected:
// Check to see if database state is ok...
// If 'write_message' true, then output a warning message indicating the problem.
Expand Down
Loading
Loading