Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4bf7163
Added cmesh fortran test
Davknapp Aug 4, 2025
6712f03
Add function that tests the interface call to set_join_by_vertices
Davknapp Aug 5, 2025
f42f4f0
fix names
Davknapp Aug 8, 2025
f6d6754
fix memory leaks
Davknapp Aug 8, 2025
5a7dda4
Add new test
Davknapp Aug 8, 2025
a3def71
output not working
Davknapp Aug 8, 2025
a36d049
Merge remote-tracking branch 'origin/main' into increase
spenke91 Feb 2, 2026
85b140c
Remove duplicated section in t8_test_mpi_init.f90
spenke91 Feb 2, 2026
caced0f
Correct years of new files in Copyright statement
spenke91 Feb 2, 2026
2d94381
Merge branch 'main' into increase
spenke91 Feb 2, 2026
442b815
Try to add FORTRAN interface to code coverage
spenke91 Feb 2, 2026
e8b5538
Merge remote-tracking branch 'origin/main' into increase
spenke91 Feb 3, 2026
664e856
Added tests for all fortran interface functions except iterate_replace
spenke91 Feb 5, 2026
9e1477e
Unified upper- and lowercase of t8_fortran_interface_mod.f90
spenke91 Feb 5, 2026
1849916
Remove incomplete version of t8_forest_iterate_replace_f from Fortran…
spenke91 Feb 5, 2026
e688e8f
Merge remote-tracking branch 'origin/main' into increase
spenke91 Feb 5, 2026
84be940
Clean up cmake/CodeCoverage.cmake
spenke91 Feb 5, 2026
3cbc593
Add Fortran Flags to code_coverage.yml
spenke91 Feb 5, 2026
3a2ed56
Try fortran code coverage
spenke91 Feb 5, 2026
5d16a6d
Try code coverage again
spenke91 Feb 5, 2026
9faa0e3
Fix issues with vtk header and C usability
spenke91 Feb 5, 2026
c834cc7
Make code coverage workflow include Fortran interface
spenke91 Feb 5, 2026
3fe9734
Do not set Fortran compiler manually in code coverage workflow
spenke91 Feb 5, 2026
5227703
Merge remote-tracking branch 'origin/main' into increase
spenke91 Feb 5, 2026
72c1e7c
Indentation
spenke91 Feb 5, 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
5 changes: 3 additions & 2 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ jobs:
&& echo CONFIG_OPTIONS="$CONFIG_OPTIONS" >> $GITHUB_ENV
# cmake
- name: echo cmake line
run: echo cmake ../ $CONFIG_OPTIONS
run: echo cmake ../ $CONFIG_OPTIONS -DCMAKE_Fortran_FLAGS="-fprofile-arcs -ftest-coverage"
# Note: Adding DCMAKE_Fortran_FLAGS here is a workaround because the blank space between the compiler flags causes trouble otherwise.
- name: cmake
run: mkdir build && cd build && cmake ../ $CONFIG_OPTIONS
run: mkdir build && cd build && cmake ../ $CONFIG_OPTIONS -DCMAKE_Fortran_FLAGS="-fprofile-arcs -ftest-coverage"
- name: OnFailUploadLog
if: failure()
uses: actions/upload-artifact@v6
Expand Down
2 changes: 1 addition & 1 deletion api/t8_fortran_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Link in C-Fortran interface file into libt8.
target_sources( T8 PRIVATE t8_fortran_interface.c )
target_sources( T8 PRIVATE t8_fortran_interface_mod.f90 )
target_sources( T8 PRIVATE t8_fortran_interface_mod.f90 t8_fortran_example_adapt_mod.f90 )


# Add this directory to header search path.
Expand Down
48 changes: 48 additions & 0 deletions api/t8_fortran_interface/t8_fortran_example_adapt_mod.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
! 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.

! This file contains a module with an example callback of the Fortran interface
! that refines and coarsenes some elements based on their centroids' coordinates.
module t8_fortran_example_adapt_mod
use t8_fortran_interface_mod

contains

! Example callback for adapting based on the centroid coordinates x, y, z.
function example_fortran_adapt_by_coordinates_callback(x, y, z, is_family) &
& result(ret) bind(c, name="example_fortran_adapt_by_coordinates_callback")
use, intrinsic :: ISO_C_BINDING, only: c_int, c_double
real(c_double), value :: x
real(c_double), value :: y
real(c_double), value :: z
integer(c_int), value :: is_family
integer(c_int) :: ret
ret = 0
if(x < 0.5d0 .and. y < 0.5d0 .and. z < 0.5d0) then
ret = 1
elseif(x > 0.5d0 .and. y > 0.5d0) then
if(is_family.ne.0) then
ret = -1
endif
endif

end function example_fortran_adapt_by_coordinates_callback

end module t8_fortran_example_adapt_mod
29 changes: 12 additions & 17 deletions api/t8_fortran_interface/t8_fortran_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
*/

#include <t8_fortran_interface.h>
#include <t8_forest/t8_forest_general.h>
#include <t8_forest/t8_forest_geometrical.h>
#include <t8_cmesh/t8_cmesh_examples.h>
#include <t8_cmesh/t8_cmesh_helpers.h>
#include <t8_forest/t8_forest_general.h>
#include <t8_forest/t8_forest_geometrical.h>
#include <t8_forest/t8_forest_io.h>
#include <t8_schemes/t8_scheme.h>
#include <t8_schemes/t8_default/t8_default_c_interface.h>

Expand All @@ -51,12 +52,6 @@ t8_fortran_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm *comm)
t8_cmesh_commit (cmesh, *comm);
}

void
t8_fortran_cmesh_set_join_by_stash_noConn (t8_cmesh_t cmesh, const int do_both_directions)
{
t8_cmesh_set_join_by_stash (cmesh, NULL, do_both_directions);
}

void
t8_fortran_init_all (sc_MPI_Comm *comm)
{
Expand Down Expand Up @@ -127,16 +122,14 @@ int
t8_fortran_adapt_by_coordinates_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree,
const t8_eclass_t tree_class,
__attribute__ ((unused)) t8_locidx_t lelement_id, const t8_scheme_c *scheme,
const int is_family, const int num_elements, t8_element_t *elements[])
const int is_family, __attribute__ ((unused)) const int num_elements,
t8_element_t *elements[])
{
t8_fortran_adapt_coordinate_callback callback
= (t8_fortran_adapt_coordinate_callback) t8_forest_get_user_function (forest);
double midpoint[3];
t8_forest_element_centroid (forest_from, which_tree, elements[0], midpoint);
t8_debugf ("Coord: %.2f\n", midpoint[0]);
int ret = callback (midpoint[0], midpoint[1], midpoint[2], num_elements > 0);

/* Coarsen if a family was given and return value is negative. */
/* If a family was given, form parent first to feed its centroid into the callback. */
if (is_family) {
/* The elements form a family */
T8_ASSERT (t8_elements_are_family (scheme, tree_class, elements));
Expand All @@ -146,14 +139,16 @@ t8_fortran_adapt_by_coordinates_callback (t8_forest_t forest, t8_forest_t forest
t8_element_get_parent (scheme, tree_class, elements[0], parent);
/* Get the coordinates of the parent. */
t8_forest_element_centroid (forest_from, which_tree, parent, midpoint);

ret = callback (midpoint[0], midpoint[1], midpoint[2], 1);
/* Deallocate parent element to avoid memory leakage. */
t8_element_destroy (scheme, tree_class, 1, &parent);
}
else {
/* The elements do not form a family. */
/* Get the coordinates of the first element and call callback */
/* Get the coordinates of the first element.*/
t8_forest_element_centroid (forest_from, which_tree, elements[0], midpoint);
ret = callback (midpoint[0], midpoint[1], midpoint[2], 0);
}
int ret = callback (midpoint[0], midpoint[1], midpoint[2], is_family);
if (!is_family) {
T8_ASSERT (ret >= 0);
}
return ret;
Expand Down
19 changes: 3 additions & 16 deletions api/t8_fortran_interface/t8_fortran_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
*/

/** \file t8_fortran_interface.h
* In this file we provide a basic Fortran interface
* In this file we provide a basic Fortran interface
* for some functions of t8code.
* Mostly, the C functions here are wrappers around more complex
* t8code function.
* We only export a minimum of the actual t8code functionality
* We only export a minimum of the actual t8code functionality
* to Fortran.
*/

Expand Down Expand Up @@ -73,19 +73,6 @@ t8_fortran_finalize ();
void
t8_fortran_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm *comm);

/** This function calls t8_cmesh_set_join_by_stash with connectivity = NULL.
* \param[in,out] cmesh Pointer to a t8code cmesh object. If set to NULL this argument is ignored.
* \param[in] do_both_directions Compute the connectivity from both neighboring sides.
* Takes much longer to compute.
*
* \warning This routine might be too expensive for very large meshes. In this case,
* consider to use a fully featured mesh generator.
*
* \note This routine does not detect periodic boundaries.
*/
void
t8_fortran_cmesh_set_join_by_stash_noConn (t8_cmesh_t cmesh, const int do_both_directions);

/** Translate a fortran MPI communicator into a C MPI communicator
* and return a pointer to it.
* \param [in] Fcomm Fortran MPI Communicator
Expand Down Expand Up @@ -125,7 +112,7 @@ t8_cmesh_new_periodic_tri_wrap (sc_MPI_Comm *Ccomm);
t8_forest_t
t8_forest_new_uniform_default (t8_cmesh_t cmesh, int level, int do_face_ghost, sc_MPI_Comm *comm);

/**
/**
* \param [in, out] forest The forest
* \param [in] recursive A flag specifying whether adaptation is to be done recursively
* or not. If the value is zero, adaptation is not recursive
Expand Down
Loading