Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
220 commits
Select commit Hold shift + click to select a range
6cc10ee
proper abort message when using lfn with unbalanced forest
holke Nov 13, 2024
a390ed6
change leaf parameter name. Add ghost todo comments
holke Nov 13, 2024
a12e38e
adapt iterate face example
holke Nov 14, 2024
413b23d
fix deleted bracket
holke Nov 14, 2024
0d5fe2a
use RAII where possible
holke Nov 14, 2024
e6969d5
update iterate face example to ghost face iterate
holke Nov 14, 2024
3257123
more const for split_array functions
holke Nov 14, 2024
8118b95
add ghost check functionality to t8_forest_element_is_leaf
holke Nov 14, 2024
6c331bd
comment and remove empty lines
holke Nov 14, 2024
6f2b7b7
iterate faces now supports ghosts
holke Nov 14, 2024
8f1b4d0
debug guards around check used only in debug mode
holke Nov 14, 2024
6cf5c42
Merge branch 'feature-more_const' into feature-extend_lfn_to_ghosts
holke Nov 14, 2024
07d250b
Merge branch 'feature-element_is_ghost' into feature-extend_lfn_to_gh…
holke Nov 14, 2024
1734d0f
make comment of bin search clearer
holke Nov 15, 2024
26a28a3
start with lfn extension for ghost, have structure done and know what…
holke Nov 15, 2024
6ee399a
remove TODO comment
holke Nov 15, 2024
abdff17
todo comments
holke Nov 21, 2024
be072c0
Add face iterate callback to leaf face neighbor
holke Nov 21, 2024
716097d
is_leaf_or_ghost correct assertion
holke Nov 21, 2024
d8bdecc
adaptations in face iterate callback
holke Dec 3, 2024
554ab7b
add ghost support to t8_forest_element_neighbor_eclass
holke Dec 3, 2024
39a9bf0
final extensions of lfn to ghost elements
holke Dec 3, 2024
1a39eb8
t8_forest_element_neighbor_eclass adaptation to declaration
holke Dec 3, 2024
7e9c27e
user data parameter handling for iterate faces
holke Dec 3, 2024
2f68110
Remove is_balanced parameter from lfn function since no longer required.
holke Dec 3, 2024
58369cb
improve function documentation
holke Dec 3, 2024
17c869b
fix abort if incomplete forest
holke Dec 3, 2024
f4d50df
return when no neighbors are found
holke Dec 3, 2024
dce66ae
only compute ghost tree if ghosts exists
holke Dec 3, 2024
591d2ff
skip if case when no neighbors found in search
holke Dec 3, 2024
731c062
comments
holke Dec 3, 2024
86bcfdd
fix wrongly placed brace
holke Dec 3, 2024
6b61f19
add first test case
holke Dec 3, 2024
b0d73ba
only do face neighbors when default quad or hex
holke Dec 5, 2024
b9a6eea
fix user data pointer in callback
holke Dec 5, 2024
e009667
fix memory counting and handling for computed neighbors
holke Dec 5, 2024
963c4d2
face iterate use is leaf check
holke Dec 5, 2024
59533d9
adjustments to face neighbor computation
holke Dec 11, 2024
c7654ea
extend lfn test
holke Dec 11, 2024
7d9a6a9
comments
holke Jan 15, 2025
7e7dd6b
Face iteration requires view into partial leaf array
holke Jan 15, 2025
13cf0a5
store local or ghost tree info with leaf arrays for face iteration
holke Jan 15, 2025
cd7ac01
extend forest_element_face_neighbor to ghosts
holke Jan 27, 2025
b3c19d7
extend leaf_face_neighbors_iterate to ghosts
holke Jan 27, 2025
3c53f03
new check elements for ancestor function
holke Jan 27, 2025
f584941
In face neighbor computation check whether neighbors would exist befo…
holke Jan 27, 2025
b5ec551
more output in test
holke Jan 27, 2025
35843c5
indent
holke Jan 27, 2025
841e3ce
index checks in face neighbor test
holke Jan 27, 2025
f9a5f17
Add own test file for reusable adapt callbacks
holke Jan 28, 2025
d96348d
add testing of adapted forest to face neighbor test
holke Jan 28, 2025
9ab0b11
clean up custom assertion test header
holke Jan 28, 2025
8d751e2
fix pointer arithmetic
holke Jan 28, 2025
13ec5ca
extend checks in test for adaptive forest
holke Jan 28, 2025
eab1b42
temporarily skip adapted forest in test
holke Jan 31, 2025
60e84ad
debugging output
holke Jan 31, 2025
b2f45d2
proper conversion of pointer output
holke Jan 31, 2025
d5eeb2f
comment
holke Jan 31, 2025
0ff6b4e
Merge branch 'main' into feature-extend_lfn_to_ghosts
lukasdreyer Feb 7, 2025
5033098
leafs -> leaves
lukasdreyer Feb 7, 2025
06de973
fix CI
lukasdreyer Feb 7, 2025
7412720
adapt test parameter
lukasdreyer Feb 7, 2025
de40d50
Merge branch 'main' into feature-extend_lfn_to_ghosts
lukasdreyer Feb 13, 2025
cccd74b
indent
lukasdreyer Feb 13, 2025
4184f91
Merge branch 'feature-extend_lfn_to_ghosts' of github.com:DLR-AMR/t8c…
lukasdreyer Feb 13, 2025
6644a45
Merge branch 'main' into feature-extend_lfn_to_ghosts
sandro-elsweijer Feb 17, 2025
62da259
Merge remote-tracking branch 'origin/feature-extend_lfn_to_ghosts' in…
holke Mar 17, 2025
456764f
Merge remote-tracking branch 'origin/main' into feature-extend_lfn_to…
holke Mar 17, 2025
a7c83c6
merge updates from fix-forest_leave_face_neigh
holke Mar 17, 2025
f66fa5c
update test file from fix-forest_leave_face_neigh branch
holke Mar 17, 2025
dc3105b
add same level face neigh to header
holke Mar 17, 2025
9e42acf
Move element_find_owner to public interface
lukasdreyer Feb 28, 2025
424e918
Add TODO comment for adaptive bug and how to solve it
holke Mar 18, 2025
97300de
update todo comment
holke Mar 21, 2025
2d32642
Merge remote-tracking branch 'origin/main' into feature-extend_lfn_to…
holke May 16, 2025
05951a0
change ifdef to if
holke May 16, 2025
8bcdd2f
Merge branch 'feature-geometry_improved_hashes' into feature-extend_l…
holke May 16, 2025
fe80541
Merge remote-tracking branch 'origin/main' into feature-extend_lfn_to…
holke Jun 5, 2025
6c8241b
update element/leaf function calls
holke Jun 5, 2025
f6c0f4d
Merge remote-tracking branch 'origin/feature-element_is_ghost' into f…
holke Jun 5, 2025
504ade7
repair merge, is_leaf test reduce cmeshes
holke Jun 5, 2025
b78f5ea
improve comments
holke Jun 6, 2025
fa49f00
Change TODO comment to updated strategy - i am very sure that this wi…
holke Jun 6, 2025
357331c
update lfn computation to new strategy via same level neighbor. Now o…
holke Jun 6, 2025
52eafd4
indent
holke Jun 6, 2025
3943b65
Change parameter of iterate_faces to const*const
holke Jun 6, 2025
c51508c
Merge branch 'feature-ancestor_search' into feature-extend_lfn_to_ghosts
holke Jun 6, 2025
8941057
Merge branch 'feature-ancestor_search' into feature-extend_lfn_to_ghosts
holke Jun 6, 2025
9920bb8
remove old elements_are_ancestor
holke Jun 6, 2025
8d7112e
Add new lfn computation via first descendant of same level neighbor
holke Jun 6, 2025
fa981d3
docstring
holke Jun 6, 2025
d43ed6e
t8_forest_bin_search_first_descendant_ancenstor fix parameter
holke Jun 6, 2025
3ca4e23
restrict search to the descendant of the neighbor element
holke Jun 10, 2025
3d1016d
Merge remote-tracking branch 'origin/main' into feature-extend_lfn_to…
holke Jul 2, 2025
0b3c46f
typo
holke Jul 2, 2025
56b3e51
Add debug output to remove later
holke Jul 2, 2025
132a09c
rename face neighbor test t8 t8_gtest_leaf_face_neighbors
holke Jul 2, 2025
7e4090a
Set no neighbors found return values in separate function
holke Jul 2, 2025
220f246
only compute level if elements exist
holke Jul 2, 2025
60e0a32
Correct off by one error
holke Jul 2, 2025
2e4039f
debug out
holke Jul 2, 2025
50a6d66
Edit docstring for t8_forest_iterate_faces
holke Jul 2, 2025
3a69df1
Add adapt_callback linkage to t8_gtest_element_is_leaf_serial test
holke Jul 2, 2025
2d44b82
Merge remote-tracking branch 'origin/feature-ancestor_search' into fe…
holke Jul 3, 2025
83c39ac
Fix search range computation by computing last element
holke Jul 4, 2025
8bc7c1e
only reallocate memory if neighbors are found
holke Jul 4, 2025
00ac942
additional debug check that all leafs to search for are descendants o…
holke Jul 4, 2025
e4a9fb2
Simplify the search for the last element in search range
holke Jul 4, 2025
71a5a99
remove old code
holke Jul 4, 2025
c2a2270
indent
holke Jul 4, 2025
c3bd2b3
fix debug out file format warnings
holke Jul 4, 2025
3fc80e6
Add unused parameter flag
holke Jul 4, 2025
fc749fa
add unused flags to adapt callback
holke Jul 4, 2025
e5b68b7
typos
holke Jul 4, 2025
9676881
typos
holke Jul 4, 2025
d1c8bd9
add unused flag
holke Jul 4, 2025
a79ac31
In leaf face neighbor the succesor now is only computed if it exists.
holke Jul 29, 2025
fa4f3b8
Leaf face neighbor make neighbor_leave pointer to const element and r…
holke Jul 29, 2025
b927985
fix wrong class in debug print
holke Jul 29, 2025
c75f9ac
indent step6
holke Jul 29, 2025
ed72f26
Add t8_cmesh_get_tree_face_neighbor_eclass function to compute the ec…
holke Jul 30, 2025
192de69
Adapt t8_forest_element_neighbor_eclass
holke Jul 30, 2025
2eefe97
Use neighbor eclass INVALID argument to exclude computing the face ne…
holke Jul 30, 2025
ee0e88d
extend forest element face neighbor to ghost input
holke Oct 23, 2025
78b7f83
string for invalid eclass
holke Oct 28, 2025
5ea9552
bugfix element_face_neighbor ghost extension
holke Oct 28, 2025
76c3d5a
minor edit
holke Oct 28, 2025
e8ca951
Use loop over levels to compute dual face of possible neighbor
holke Oct 29, 2025
09a341a
Improve element_face_neighbor
holke Nov 7, 2025
f207641
Fix t8_forest_element_neighbor_eclass, wrong face passed to cmesh
holke Nov 7, 2025
5f8c8e4
activate face neighbor computation for all shapes. Still buggy in par…
holke Nov 7, 2025
0e402dc
drastically simplify t8_forest_element_face_neighbor
holke Nov 10, 2025
8a07d6a
skim down lfn neighbor search user data struct
holke Nov 11, 2025
4bb6d1b
remove old code comment
holke Nov 11, 2025
a815e41
remove unneeded eclass var
holke Nov 11, 2025
8ea3c90
Merge remote-tracking branch 'origin/main' into feature-extend_lfn_to…
holke Nov 11, 2025
ad60ded
Merge remote-tracking branch 'origin/fix-1951_half_face_neighbor_orde…
holke Nov 12, 2025
39fed67
use ECLASS_INVALID in half neighbor test
holke Nov 12, 2025
1ddccc0
correct typos
holke Nov 12, 2025
84b73e8
Merge branch 'fix-vtk_dontcomputeboundsforemptyproc' into feature-ext…
holke Nov 12, 2025
835b26e
Merge branch 'feature-ancestor_face' into feature-extend_lfn_to_ghosts
holke Nov 12, 2025
7a4aaed
use new ancestor face function
holke Nov 12, 2025
eec8b63
more const params
holke Nov 17, 2025
ab3ae97
Merge branch 'feature-face_iterate_const' into feature-extend_lfn_to_…
holke Nov 17, 2025
9da2cba
const function callback params
holke Nov 17, 2025
bf34673
remove unneeded debug code that skipped cmeshes in testing
holke Nov 17, 2025
f521498
bugfix order of parameters in function call
holke Nov 18, 2025
8ea1d96
remove test code that was left over from debugging and did nothing
holke Nov 18, 2025
37d0fe1
protect debugging code in debugging macros
holke Nov 18, 2025
530cd58
rename parameter to satisfy typo script
holke Nov 18, 2025
bcd7ab4
element maybe unused in iterate callback
holke Nov 18, 2025
15dbc35
Its now possible to call leaf face neighbor if forest does not have g…
holke Nov 18, 2025
77bf79e
Improve docu
holke Nov 18, 2025
360e65f
maybe unused params for adapt callback
holke Nov 18, 2025
bdab737
Merge branch 'main' into feature-extend_lfn_to_ghosts
holke Nov 24, 2025
65bed2d
Merge remote-tracking branch 'origin/main' into feature-extend_lfn_to…
holke Dec 1, 2025
0431d2d
Merge remote-tracking branch 'origin/feature-extend_lfn_to_ghosts' in…
holke Dec 1, 2025
07581ee
change include paths
holke Dec 1, 2025
30b8b4c
Merge branch 'main' into feature-extend_lfn_to_ghosts
Davknapp Dec 18, 2025
df6adc8
Merge remote-tracking branch 'origin/feature-ancestor_face' into feat…
holke Jan 15, 2026
93c7d2b
Merge remote-tracking branch 'origin/feature-ancestor_search' into fe…
holke Jan 15, 2026
e6fdb60
Fix linker issue since helper file was not compiled for test
holke Jan 15, 2026
64e5ed7
Fix memory error, neighbor element was not destroyed
holke Jan 15, 2026
2551707
Fix documentation
holke Jan 15, 2026
e4141c7
Adapt mesh handle to new face neighbor interface
holke Jan 15, 2026
a0bef83
Merge remote-tracking branch 'origin/main' into feature-extend_lfn_to…
holke Jan 27, 2026
681986e
indent
holke Jan 27, 2026
d69d6bb
Activate lfn test. No idea why it was not active before
holke Feb 26, 2026
93fa059
Add specific lfn test case with 2 square twisted mesh file
holke Feb 26, 2026
e437acf
Add NEWS.md text
holke Mar 3, 2026
633d3c9
Merge remote-tracking branch 'origin/main' into feature-extend_lfn_to…
holke Mar 3, 2026
f240d50
Merge branch 'main' into feature-extend_lfn_to_ghosts
holke Mar 4, 2026
586d427
Document adapt callback
holke Mar 4, 2026
1d7b4cc
fix merge
holke Mar 4, 2026
d615562
remove blank space
holke Mar 4, 2026
8e868df
adapt path to new testfile path
holke Mar 4, 2026
3eb024a
remove lambda left over from merge
holke Mar 4, 2026
c4dfd94
reduce test levels
holke Mar 4, 2026
ad5e807
change how we get the element
holke Mar 4, 2026
3d47ae0
Merge branch 'main' into feature-extend_lfn_to_ghosts
Davknapp Mar 4, 2026
6169b2c
revert change how we get element. Need to access array since it could…
holke Mar 5, 2026
cac5e1a
Merge remote-tracking branch 'origin/feature-extend_lfn_to_ghosts' in…
holke Mar 5, 2026
a356d82
Try fixing mesh file path
holke Mar 5, 2026
ba4f56d
Merge remote-tracking branch 'origin/main' into feature-extend_lfn_to…
holke Mar 5, 2026
77f1394
Add more tests in msh file example and add comment
holke Mar 5, 2026
c01f3dc
Merge branch 'main' into feature-extend_lfn_to_ghosts
Davknapp Mar 16, 2026
f2ca5c0
Merge with main
holke Mar 19, 2026
a96ab65
indent
holke Mar 19, 2026
f686d6d
Merge with main
holke Mar 19, 2026
7e62fa1
Merge with main
holke Mar 19, 2026
77caff0
Merge with main
holke Mar 19, 2026
e01ad05
Merge branch 'main' into feature-extend_lfn_to_ghosts
holke Mar 19, 2026
908c892
typo
holke Mar 19, 2026
2ce33d3
use new test data dir to locate test file
holke Mar 20, 2026
bd72a1b
Update date in copyright info
holke Mar 20, 2026
dcfba26
user better varname uniform_level in test
holke Mar 20, 2026
01f2940
change ?: operator logic to make code more readable
holke Mar 20, 2026
0601cc0
check element index if it is a ghost - part 1
holke Mar 20, 2026
310168b
Merge remote-tracking branch 'origin/feature-extend_lfn_to_ghosts' in…
holke Mar 20, 2026
bc0a583
fix wrong index
holke Mar 20, 2026
cf7cd10
unify element index verification in neighbor and neighbor neighbor case.
holke Mar 20, 2026
98cbd6a
remove old fflush
holke Mar 20, 2026
a5944bc
Typo
holke Mar 24, 2026
493252d
rearrange ternary operator logic
holke Mar 24, 2026
f4f2a59
More const.
holke Mar 24, 2026
fdd4f6b
reorder ternary operator
holke Mar 24, 2026
0b24eea
Apply suggestion from @Davknapp
holke Mar 24, 2026
37893c3
Add a comment on T8_FREE usage in test
holke Mar 24, 2026
bfff90a
indent
holke Mar 24, 2026
6dec6ed
Merge remote-tracking branch 'origin/feature-extend_lfn_to_ghosts' in…
holke Mar 24, 2026
04ff6ff
Specify neighbor face in comment
holke Mar 24, 2026
79ddd70
Add a comment referring a TODO to an issue
holke Mar 24, 2026
bdaa3e8
Change variable name for better readability
holke Mar 24, 2026
b619b61
Change ternary operator logic
holke Mar 24, 2026
e6a16c2
Change if else evaluation logic
holke Mar 24, 2026
72f3822
Add comment to t8_forest_leaf_face_neighbors_set_no_neighbor_return_v…
holke Mar 24, 2026
2ffc7f8
remove done TODO comment
holke Mar 24, 2026
422c1f8
Merge remote-tracking branch 'origin/feature-extend_lfn_to_ghosts' in…
holke Mar 24, 2026
4cec37d
Change TODO comment and need to investigate
holke Mar 24, 2026
741e8ad
indent
holke Mar 24, 2026
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
18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ No! If your code is only a couple of lines long AND has very little impact on th

# User Updates for the upcoming t8code release (February 2026 - version format unclear)

## Updates to t8_forest_leaf_face_neighbors

The t8_forest_leaf_face_neighbors and t8_forest_leaf_face_neighbors_ext functions (see t8_forest_general.h) have undergone a major update.

- The forest does not need to be balanced anymore to compute the leaf face neighbors. Thus, there can be any arbitrary number of leaf face neighbors for a given element.
The last argument (forest_is_balanced) was removed.

- The allocation behaviour changed. element_destroy should not be called anymore.
The function now returns pointers to t8code internal elements in the neighbor_leaves array.
To free the memory use
```C++
if (num_neighbors > 0) {
T8_FREE (pneighbor_leaves);
T8_FREE (pelement_indices);
T8_FREE (dual_faces);
}
```

## Using structs instead of classes

We decided to use `struct` instead of `class` throughout the entire codebase.
Expand Down
11 changes: 4 additions & 7 deletions example/advect/t8_advection.cxx
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adapted this example to the new face neighbor function.

Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ t8_advect_problem_init_elements (t8_advect_problem_t *problem)
{
t8_locidx_t itree, ielement, idata;
t8_locidx_t num_trees, num_elems_in_tree;
t8_element_t **neighbors;
const t8_element_t **neighbors;
int iface, ineigh;
t8_advect_element_data_t *elem_data;
const t8_scheme *scheme = t8_forest_get_scheme (problem->forest);
Expand Down Expand Up @@ -1035,13 +1035,12 @@ t8_advect_problem_init_elements (t8_advect_problem_t *problem)

t8_forest_leaf_face_neighbors (problem->forest, itree, element, &neighbors, iface,
&elem_data->dual_faces[iface], &elem_data->num_neighbors[iface],
&elem_data->neighs[iface], &neigh_eclass, 1);
&elem_data->neighs[iface], &neigh_eclass);
for (ineigh = 0; ineigh < elem_data->num_neighbors[iface]; ineigh++) {
elem_data->neigh_level[iface] = scheme->element_get_level (neigh_eclass, neighbors[ineigh]);
}

if (elem_data->num_neighbors[iface] > 0) {
scheme->element_destroy (neigh_eclass, elem_data->num_neighbors[iface], neighbors);
T8_FREE (neighbors);
//t8_global_essentialf("alloc face %i of elem %i\n", iface, ielement);
elem_data->fluxes[iface] = T8_ALLOC (double, elem_data->num_neighbors[iface]);
Expand Down Expand Up @@ -1197,7 +1196,7 @@ t8_advect_solve (t8_cmesh_t cmesh, t8_flow_function_3d_fn u, t8_example_level_se
int done = 0;
int adapted_or_partitioned = 0;
int dual_face;
t8_element_t **neighs;
const t8_element_t **neighs;
t8_eclass_t neigh_eclass;
double total_time, solve_time = 0;
double ghost_exchange_time, ghost_waittime, neighbor_time, flux_time;
Expand Down Expand Up @@ -1291,15 +1290,13 @@ t8_advect_solve (t8_cmesh_t cmesh, t8_flow_function_3d_fn u, t8_example_level_se
neighbor_time = -sc_MPI_Wtime ();
t8_forest_leaf_face_neighbors (problem->forest, itree, elem, &neighs, iface,
&elem_data->dual_faces[iface], &elem_data->num_neighbors[iface],
&elem_data->neighs[iface], &neigh_eclass, 1);
&elem_data->neighs[iface], &neigh_eclass);
for (ineigh = 0; ineigh < elem_data->num_neighbors[iface]; ineigh++) {
elem_data->neigh_level[iface] = scheme->element_get_level (neigh_eclass, neighs[ineigh]);
}

T8_ASSERT (neighs != NULL || elem_data->num_neighbors[iface] == 0);
if (neighs != NULL) {
scheme->element_destroy (neigh_eclass, elem_data->num_neighbors[iface], neighs);

T8_FREE (neighs);
}

Expand Down
54 changes: 33 additions & 21 deletions example/forest/t8_test_face_iterate.cxx
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure why i edited this and what i did here.
Its too long ago.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <t8_forest/t8_forest_general.h>
#include <t8_forest/t8_forest_io.h>
#include <t8_forest/t8_forest_geometrical.h>
#include <t8_forest/t8_forest_ghost.h>
#include <t8_cmesh/t8_cmesh.h>
#include <t8_cmesh/t8_cmesh_io/t8_cmesh_readmshfile.h>
#include <t8_cmesh/t8_cmesh_examples.h>
Expand All @@ -41,17 +42,17 @@ typedef struct
} t8_test_fiterate_udata_t;

static int
t8_test_fiterate_callback (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face,
void *user_data, t8_locidx_t leaf_index)
t8_test_fiterate_callback (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, int is_leaf,
[[maybe_unused]] const t8_element_array_t *leaf_elements, t8_locidx_t leaf_index,
void *user_data)
{
double *coords;

if (leaf_index >= 0) {
coords = ((t8_test_fiterate_udata_t *) user_data)->coords;
if (is_leaf) {
t8_test_fiterate_udata_t *test_user_data = (t8_test_fiterate_udata_t *) user_data;
double *coords = test_user_data->coords;
t8_forest_element_coordinate (forest, ltreeid, element, 0, coords);
t8_debugf ("Leaf element in tree %i at face %i, tree local index %i has corner 0 coords %lf %lf %lf\n", ltreeid,
face, (int) leaf_index, coords[0], coords[1], coords[2]);
((t8_test_fiterate_udata_t *) user_data)->count++;
test_user_data->count++;
}
return 1;
}
Expand All @@ -75,27 +76,37 @@ t8_basic_adapt ([[maybe_unused]] t8_forest_t forest, [[maybe_unused]] t8_forest_
static void
t8_test_fiterate (t8_forest_t forest)
{
t8_locidx_t itree, num_trees;
t8_eclass_t eclass;
const t8_scheme *scheme = t8_forest_get_scheme (forest);
t8_element_t *nca;
t8_element_array_t *leaf_elements;
t8_test_fiterate_udata_t udata;
int iface;

num_trees = t8_forest_get_num_local_trees (forest);
for (itree = 0; itree < num_trees; itree++) {
eclass = t8_forest_get_tree_class (forest, itree);
const t8_element_t *first_el = t8_forest_get_leaf_element_in_tree (forest, itree, 0);
t8_forest_set_user_data (forest, &udata);
const t8_locidx_t num_local_trees = t8_forest_get_num_local_trees (forest);
const t8_locidx_t num_trees = num_local_trees + t8_forest_get_num_ghost_trees (forest);
for (t8_locidx_t itree = 0; itree < num_trees; itree++) {
const t8_eclass_t eclass = t8_forest_get_tree_class (forest, itree);
const t8_scheme *scheme = t8_forest_get_scheme (forest);
// Query whether this tree is a ghost and compute its ghost tree id.
const bool is_ghost = itree >= num_local_trees;
const t8_locidx_t ghost_tree_id = is_ghost ? itree - num_local_trees : -1;
// Get the number of elements or ghosts in this tree
const t8_locidx_t num_tree_elements = is_ghost ? t8_forest_ghost_tree_num_leaf_elements (forest, ghost_tree_id)
: t8_forest_get_tree_num_leaf_elements (forest, itree);
// Get all leaf elements
const t8_element_array_t *leaf_elements = is_ghost
? t8_forest_ghost_get_tree_leaf_elements (forest, ghost_tree_id)
: t8_forest_tree_get_leaf_elements (forest, itree);
// Get the first and last element
const t8_element_t *first_el = (const t8_element_t *) t8_element_array_index_locidx (leaf_elements, 0);
const t8_element_t *last_el
= t8_forest_get_leaf_element_in_tree (forest, itree, t8_forest_get_tree_num_leaf_elements (forest, itree) - 1);
= (const t8_element_t *) t8_element_array_index_locidx (leaf_elements, num_tree_elements - 1);

t8_element_t *nca;
scheme->element_new (eclass, 1, &nca);
scheme->element_get_nca (eclass, first_el, last_el, nca);
leaf_elements = t8_forest_tree_get_leaf_elements (forest, itree);

for (iface = 0; iface < scheme->element_get_num_faces (eclass, nca); iface++) {
//
for (int iface = 0; iface < scheme->element_get_num_faces (eclass, nca); iface++) {
udata.count = 0;
t8_forest_iterate_faces (forest, itree, nca, iface, leaf_elements, &udata, 0, t8_test_fiterate_callback);
t8_forest_iterate_faces (forest, itree, nca, iface, leaf_elements, 0, t8_test_fiterate_callback, &udata);
t8_debugf ("Leaf elements at face %i:\t%i\n", iface, udata.count);
}
scheme->element_destroy (eclass, 1, &nca);
Expand Down Expand Up @@ -139,6 +150,7 @@ t8_test_fiterate_refine_and_partition (t8_cmesh_t cmesh, int level, sc_MPI_Comm
/* partition the adapted forest */
t8_forest_init (&forest_partition);
t8_forest_set_partition (forest_partition, forest_adapt, 0);
t8_forest_set_ghost (forest_partition, 1, T8_GHOST_FACES);
t8_forest_commit (forest_partition);
t8_debugf ("Created ghost structure with %li ghost elements.\n", (long) t8_forest_get_num_ghosts (forest_partition));
if (!no_vtk) {
Expand Down
14 changes: 6 additions & 8 deletions mesh_handle/element.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,14 @@ class element: public TCompetences<element<TMeshClass, TCompetences...>>... {
return this->m_neighbors[face];
}
}

t8_element_t** neighbors; /**< Neighboring elements. */
int* dual_faces_internal; /**< Face indices of the neighbor elements. */
int num_neighbors; /**< Number of neighboring elements. */
t8_locidx_t* neighids; /**< Neighboring elements ids. */
t8_eclass_t neigh_class; /**< Neighboring elements tree class. */
const t8_element_t** neighbors; /**< Neighboring elements. */
int* dual_faces_internal; /**< Face indices of the neighbor elements. */
int num_neighbors; /**< Number of neighboring elements. */
t8_locidx_t* neighids; /**< Neighboring elements ids. */
t8_eclass_t neigh_class; /**< Neighboring elements tree class. */

t8_forest_leaf_face_neighbors (m_mesh->m_forest, m_tree_id, m_element, &neighbors, face, &dual_faces_internal,
&num_neighbors, &neighids, &neigh_class, t8_forest_is_balanced (m_mesh->m_forest));
&num_neighbors, &neighids, &neigh_class);
if (dual_faces) {
dual_faces->get ().assign (dual_faces_internal, dual_faces_internal + num_neighbors);
}
Expand All @@ -369,7 +368,6 @@ class element: public TCompetences<element<TMeshClass, TCompetences...>>... {
}
if (num_neighbors > 0) {
// Free allocated memory.
t8_forest_get_scheme (m_mesh->m_forest)->element_destroy (get_tree_class (), num_neighbors, neighbors);
T8_FREE (neighbors);
T8_FREE (dual_faces_internal);
T8_FREE (neighids);
Expand Down
Loading