Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 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
6226b68
add ghost check functionality to t8_forest_element_is_leaf
holke Nov 14, 2024
0fa3f7b
comment and remove empty lines
holke Nov 14, 2024
108664c
extend is leaf test to ghosts
holke Nov 14, 2024
9402ee6
activate parallel testing for is leaf check
holke Nov 14, 2024
8f1b4d0
debug guards around check used only in debug mode
holke Nov 14, 2024
562cd4a
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
e97696a
typo
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
a3e7ec2
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
a933650
Merge remote-tracking branch 'origin/main' into feature-element_is_ghost
holke May 14, 2025
d74c678
Update is_ghost test to recent scheme changes
holke May 14, 2025
5c58879
New element_find function for element_array
holke May 14, 2025
daf5783
use element_array_find in is_leaf_or_ghost
holke May 14, 2025
d7f533d
Merge branch 'feature-move_bin_search_to_forest_private' into feature…
holke May 14, 2025
98a4bdd
Merge branch 'feature-move_bin_search_to_forest_private' into feature…
holke May 14, 2025
be41896
Merge branch 'feature-move_bin_search_to_forest_private' into feature…
holke May 14, 2025
2286282
add forest_private include
holke May 14, 2025
bd2dba3
remove duplicate scheme creation
holke May 14, 2025
fd4329f
Merge branch 'main' into feature-element_is_ghost
holke May 14, 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
3223c63
Add a comment to bin_search
holke Jun 6, 2025
a3422fc
Implement t8_forest_bin_search_upper
holke Jun 6, 2025
5584c0f
Implement t8_forest_element_is_ancestor
holke Jun 6, 2025
5d1564a
Add t8_forest_bin_search_first_descendant_ancenstor
holke Jun 6, 2025
ca8989e
fix bin_search_upper
holke Jun 6, 2025
d50a3d8
fix element_is_ancestor
holke Jun 6, 2025
c51508c
Merge branch 'feature-ancestor_search' into feature-extend_lfn_to_ghosts
holke Jun 6, 2025
b700bd7
document bin_search_lower
holke Jun 6, 2025
b28d548
document bin_search_upper
holke Jun 6, 2025
67d6265
Add declaration of +t8_forest_bin_search_first_descendant_ancenstor. …
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
fb0cc9e
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
f168141
Documentation
holke Jun 23, 2025
ecd65df
Merge remote-tracking branch 'origin/main' into feature-ancestor_search
holke Jun 23, 2025
511cbef
typo
holke Jun 23, 2025
8f9b60e
Merge remote-tracking branch 'origin/main' into feature-ancestor_search
holke Jun 23, 2025
488a6bb
Change docstring
holke Jul 2, 2025
30bbb69
Add const to parameter
holke Jul 2, 2025
fd182a2
Merge branch 'main' into feature-ancestor_search
holke Jul 2, 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
70f4a37
Add element_is_ancestor function to the scheme interface and the defa…
holke Jul 2, 2025
f758a8b
Add a non-implementation i.e. abort of element_is_ancestor to the sta…
holke Jul 2, 2025
18fe45a
Implement standalone version of is_ancestor
holke Jul 3, 2025
0d8b09a
Add an is_ancestor test
holke Jul 3, 2025
9acef23
Add an is_ancestor assertion to nca computation
holke Jul 3, 2025
f6c751b
Add is_ancestor check to nca unit test
holke Jul 3, 2025
35402c7
typos
holke Jul 3, 2025
9361571
Merge remote-tracking branch 'origin/main' into feature-ancestor_search
holke Jul 3, 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
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
4 changes: 2 additions & 2 deletions example/advect/t8_advection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ 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]);
}
Expand Down Expand Up @@ -1292,7 +1292,7 @@ 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]);
}
Expand Down
54 changes: 33 additions & 21 deletions example/forest/t8_test_face_iterate.cxx
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.h>
#include <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_tree_get_leaf_elements (forest, itree)
: t8_forest_ghost_get_tree_leaf_elements (forest, ghost_tree_id);
// 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
34 changes: 34 additions & 0 deletions src/t8_data/t8_containers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <sc_containers.h>
#include <t8_data/t8_containers.h>
#include <t8_schemes/t8_scheme.hxx>
#include <t8_forest/t8_forest_private.h>

T8_EXTERN_C_BEGIN ();

Expand Down Expand Up @@ -326,6 +327,39 @@ t8_element_array_get_array_mutable (t8_element_array_t *element_array)
return &element_array->array;
}

t8_locidx_t
t8_element_array_find (const t8_element_array_t *element_array, const t8_element_t *element)
{
/* In order to find the element, we need to compute its linear id.
* To do so, we need the scheme and the level of the element. */
const t8_scheme *scheme = t8_element_array_get_scheme (element_array);
const t8_eclass_t tree_class = t8_element_array_get_tree_class (element_array);
const int element_level = scheme->element_get_level (tree_class, element);
/* Compute the linear id. */
const t8_linearidx_t element_id = scheme->element_get_linear_id (tree_class, element, element_level);
/* Search for the element.
* The search returns the largest index i,
* such that the element at position i has a smaller id than the given one.
* If no such i exists, it returns -1. */
const t8_locidx_t search_result = t8_forest_bin_search_lower (element_array, element_id, element_level);
if (search_result < 0) {
// The element was not found, we return -1. */
return -1;
}
/* An element was found but it may not be the candidate element.
* To identify whether the element was found, we compare these two. */
const t8_element_t *check_element = t8_element_array_index_locidx (element_array, search_result);
T8_ASSERT (check_element != NULL);
if (scheme->element_is_equal (tree_class, element, check_element)) {
// The element was found at position search_result. We return it.
return search_result;
}
else {
// The element was not found, we return -1. */
return -1;
}
}

void
t8_element_array_reset (t8_element_array_t *element_array)
{
Expand Down
10 changes: 10 additions & 0 deletions src/t8_data/t8_containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ t8_element_array_get_array (const t8_element_array_t *element_array);
sc_array_t *
t8_element_array_get_array_mutable (t8_element_array_t *element_array);

/** Search for an element in an array.
* \param [in] element_array Array structure.
* \param [in] element Element to be found in \a element_array.
* The element must have been created with the scheme used in \a element_array.
* \return If \a element was found in \a element_array then the position in the array is returned.
* If the element is not found, -1 is returned.
*/
t8_locidx_t
t8_element_array_find (const t8_element_array_t *element_array, const t8_element_t *element);

/** Sets the array count to zero and frees all elements.
* \param [in,out] element_array Array structure to be reset.
* \note Calling t8_element_array_init, then any array operations,
Expand Down
Loading
Loading