Repository navigation
Feature: SFC-Based Tree Indexing #2324
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
Open
tunxu
wants to merge
32
commits into
main
Choose a base branch
from
feature-tree_reindexing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+749
−1
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
fdea0bf
initial Commit
tunxu 0ab2e07
Create a cmesh from bounding box around given cmesh
tunxu 2c69750
Added check for required refinement level
tunxu a480c71
working test
tunxu 06be9b5
Zwischencommit zum Umwechseln
tunxu 82e1524
Fixed some issues
54bfb09
Reindex performed on stash
03d22ae
Working test
e68eb53
deleted vtk file writes
25114ab
removed old assertion
47bb76b
Iterating through list of vertices once now
98aa58a
Merge branch 'main' into feature-tree_reindexing
2775f8b
Commit in between
eba4e31
Added flag into t8_cmesh_types, reindexing now during commit activatable
d1159ca
Merge branch 'main' into feature-tree_reindexing
180d2a8
Added flag to the cmesh
2425890
Merge main
tunxu 50b2dde
Clean up of code, with some comments
2cb21a9
Added docstrings in .h-file
c54385c
Fixed Merging issues
a22865b
Test Precommit [run ci]
b055340
Fixed Test
0c634e2
Fixed Docstrings
a8ed3f7
Merge branch 'main' into feature-tree_reindexing
f05db75
Removed t8_config.h
f29fc87
Fixed indentation t8_cmesh.cxx
02d4060
Trigger CI [run ci]
a5af226
rewritten code, so no std::span is used [run ci]
45303af
Merge branch 'main' into feature-tree_reindexing
tunxu 3a6d72a
Resolved first review
67f539c
Fixed one Assertion
095a340
Removed t8_cmesh_get_num_trees() call as cmesh is not committed
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| #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> | ||
|
|
||
| /** | ||
| * A struct to hold the information about a ghost facejoin. | ||
|
|
@@ -148,6 +149,10 @@ 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) { | ||
| t8_cmesh_tree_perform_reindex_inplace (stash, t8_cmesh_reindex_tree (cmesh)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With one function I meant more like |
||
| } | ||
|
|
||
| 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 */ | ||
|
|
||
399 changes: 399 additions & 0 deletions
399
src/t8_cmesh/t8_cmesh_internal/t8_cmesh_tree_reindex.cxx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| This file is part of t8code. | ||
| t8code is a C library to manage a collection (a forest) of multiple | ||
| connected adaptive space-trees of general element classes in parallel. | ||
|
|
||
| Copyright (C) 2026 the developers | ||
|
|
||
| t8code is free software; you can redistribute it and/or modify | ||
| it under the terms of the GNU General Public License as published by | ||
| the Free Software Foundation; either version 2 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| t8code is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU General Public License | ||
| along with t8code; if not, write to the Free Software Foundation, Inc., | ||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| */ | ||
|
|
||
| #ifndef T8_CMESH_REINDEX_TREES_H | ||
| #define T8_CMESH_REINDEX_TREES_H | ||
|
|
||
| #include <t8.h> | ||
| #include <t8_cmesh/t8_cmesh.h> | ||
| #include <t8_cmesh/t8_cmesh_internal/t8_cmesh_types.h> | ||
| #include <map> | ||
|
|
||
| /** | ||
| * Compute a spatially coherent reindexing of the coarse mesh trees. | ||
| * | ||
| * Constructs an auxiliary bounding box forest containing the centers of the | ||
| * original coarse mesh trees. The forest is adaptively refined until each | ||
| * leaf element contains at most one tree center. The leaves are then traversed | ||
| * in SFC order to assign new indices to the original trees. | ||
| * | ||
| * \param [in] cmesh The original coarse mesh whose trees are to be reindexed. | ||
| * \param [in] comm MPI communicator used to construct the auxiliary forest. | ||
| * | ||
| * \return A map from the original global tree IDs to their new SFC-based indices. | ||
| * | ||
| * \note This function only computes the reindexing and does not modify the | ||
| * original coarse mesh. | ||
| */ | ||
|
|
||
| std::map<t8_gloidx_t, t8_gloidx_t> | ||
| t8_cmesh_reindex_tree (t8_cmesh_t cmesh, sc_MPI_Comm comm = sc_MPI_COMM_SELF); | ||
|
|
||
| /** | ||
| * Apply a tree reindexing to the coarse mesh stash in place. | ||
| * | ||
| * Updates the tree IDs stored in the stash according to the given mapping, | ||
| * allowing the coarse mesh to use the newly computed tree ordering. | ||
| * | ||
| * \param [in,out] stash The coarse mesh stash to be modified. | ||
| * \param [in] tree_reindex Mapping from original global tree IDs to | ||
| * their new indices. | ||
| */ | ||
| void | ||
| t8_cmesh_tree_perform_reindex_inplace (t8_stash_t &stash, const std::map<t8_gloidx_t, t8_gloidx_t> &tree_reindex); | ||
|
|
||
| #endif /* !T8_CMESH_REINDEX_TREES_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice to have a second parameter and getter to retrieve the reindex map. The user could have data linked to the trees and reordering would mix that up.
so maybe something like
void t8_cmesh_enable_tree_reordering (t8_cmesh_t cmesh, int keep_reindex_map);and
map_type t8_ cmesh_get_reindex_map (t8_cmesh_t cmesh);The reindex map would be saved in an additional pointer inside the cmesh and xould be retrieved using the
cmesh_get_reindex_mapfunction.