Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ target_sources( T8 PRIVATE
t8_cmesh/t8_cmesh_internal/t8_cmesh_partition.cxx
t8_cmesh/t8_cmesh_internal/t8_cmesh_stash.c
t8_cmesh/t8_cmesh_internal/t8_cmesh_trees.cxx
t8_cmesh/t8_cmesh_internal/t8_cmesh_tree_reindex.cxx
t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_tree_to_vertex.cxx
t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_vertex_to_tree.cxx
t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_connectivity.cxx
Expand Down
11 changes: 9 additions & 2 deletions src/t8_cmesh/t8_cmesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ t8_cmesh_disable_negative_volume_check ([[maybe_unused]] t8_cmesh_t cmesh)
#endif
}

void
t8_cmesh_enable_tree_reordering (t8_cmesh_t cmesh)
{
cmesh->reindex_trees = 1;
}

#if T8_ENABLE_DEBUG
int
t8_cmesh_validate_geometry (const t8_cmesh_t cmesh, const int check_for_negative_volume)
Expand Down Expand Up @@ -239,6 +245,7 @@ t8_cmesh_init (t8_cmesh_t *pcmesh)
#if T8_ENABLE_DEBUG
cmesh->negative_volume_check = 1;
#endif /* T8_ENABLE_DEBUG */
cmesh->reindex_trees = 0;

T8_ASSERT (t8_cmesh_is_initialized (cmesh));
}
Expand Down Expand Up @@ -2254,8 +2261,8 @@ t8_cmesh_uniform_bounds_from_partition (const t8_cmesh_t cmesh, const t8_gloidx_
#endif

} /* End sending of end message */
} /* End loop over processes */
} /* if (num_pure_local_trees > 0) */
} /* End loop over processes */
} /* if (num_pure_local_trees > 0) */

if (this_proc_is_empty) {
/* If this proc is empty, we only expect a start message.
Expand Down
8 changes: 7 additions & 1 deletion src/t8_cmesh/t8_cmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ t8_cmesh_stash_is_empty (const t8_cmesh_t cmesh);
void
t8_cmesh_disable_negative_volume_check (t8_cmesh_t cmesh);

/**
* Enable localitly based indexing of trees during \ref t8_cmesh_commit.
* \param [in, out] cmesh
*/
void
t8_cmesh_enable_tree_reordering (t8_cmesh_t cmesh);

#if T8_ENABLE_DEBUG
/** Check the geometry of the mesh for validity, this means checking if trees and their geometries
* are compatible and if they have negative volume.
Expand All @@ -140,7 +147,6 @@ t8_cmesh_disable_negative_volume_check (t8_cmesh_t cmesh);
* \return True if the geometry of the cmesh is valid.
*/
int

t8_cmesh_validate_geometry (const t8_cmesh_t cmesh, const int check_for_negative_volume);
#endif

Expand Down
12 changes: 12 additions & 0 deletions src/t8_cmesh/t8_cmesh_internal/t8_cmesh_commit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include <t8_cmesh/t8_cmesh_geometry.hxx>
#include <t8_geometry/t8_geometry_handler.hxx>
#include <t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_connectivity.hxx>
#include <t8_cmesh/t8_cmesh_internal/t8_cmesh_tree_reindex.hxx>
#include <chrono>

/**
* A struct to hold the information about a ghost facejoin.
Expand Down Expand Up @@ -148,6 +150,16 @@ t8_cmesh_commit_replicated_new (t8_cmesh_t cmesh)
t8_stash_class_struct_t *entry;
t8_locidx_t num_trees = class_entries->elem_count, ltree;

if (cmesh->reindex_trees) {
auto start = std::chrono::high_resolution_clock::now ();
std::map<t8_gloidx_t, t8_gloidx_t> reindexing_map = t8_cmesh_reindex_tree (cmesh);

t8_cmesh_tree_perform_reindex_inplace (stash, reindexing_map);
auto stop = std::chrono::high_resolution_clock::now ();
auto duration = duration_cast<std::chrono::microseconds> (stop - start);
t8_productionf ("Time taken: %lims\n", duration.count ());
}

t8_cmesh_trees_init (&cmesh->trees, 1, num_trees, 0);
t8_cmesh_trees_start_part (cmesh->trees, 0, 0, num_trees, 0, 0, 1);
/* set tree classes */
Expand Down
Loading
Loading