From f231c85ab45780f984c604eabdbaa28f8e2177d3 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Wed, 24 Jun 2026 16:45:52 +0200 Subject: [PATCH 01/12] try reading the platform BUFSIZ from t8_vtk_data_field_t --- examples/t8_brick_partition_balance_ghost.jl | 202 +++++++++++++++++++ examples/t8_step5_element_data.jl | 14 +- examples/t8_step6_stencil.jl | 12 +- src/T8code.jl | 3 + 4 files changed, 217 insertions(+), 14 deletions(-) create mode 100644 examples/t8_brick_partition_balance_ghost.jl diff --git a/examples/t8_brick_partition_balance_ghost.jl b/examples/t8_brick_partition_balance_ghost.jl new file mode 100644 index 0000000..f41ae32 --- /dev/null +++ b/examples/t8_brick_partition_balance_ghost.jl @@ -0,0 +1,202 @@ +using MPI +using T8code +using T8code.Libt8: sc_init +using T8code.Libt8: sc_finalize +using T8code.Libt8: SC_LP_ESSENTIAL +using T8code.Libt8: SC_LP_PRODUCTION + + +# Print the local and global number of elements of a forest. +function t8_step3_print_forest_information(forest) + # Check that forest is a committed, that is valid and usable, forest. + @T8_ASSERT(t8_forest_is_committed(forest)==1) + + # Get the local number of elements. + local_num_elements = t8_forest_get_local_num_leaf_elements(forest) + # Get the global number of elements. + global_num_elements = t8_forest_get_global_num_leaf_elements(forest) + + t8_global_productionf(" [step3] Local number of elements:\t\t%i\n", local_num_elements) + t8_global_productionf(" [step3] Global number of elements:\t%li\n", global_num_elements) +end + + +# Gather the 3x3 stencil for each element and compute finite difference approximations +# for schlieren and curvature of the stored heights in the elements. +function t8_traverse_forest(forest, comm) + # Check that forest is a committed, that is valid and usable, forest. + @T8_ASSERT(t8_forest_is_committed(forest)==1) + + # Get the number of trees that have elements of this process. + num_local_trees = t8_forest_get_num_local_trees(forest) + + scheme = t8_forest_get_scheme(forest) + + # Loop over all local trees in the forest. + for itree in 0:(num_local_trees - 1) + tree_class = t8_forest_get_tree_class(forest, itree) + num_elements_in_tree = t8_forest_get_tree_num_leaf_elements(forest, itree) + + # Loop over all local elements in the tree. + for ielement in 0:(num_elements_in_tree - 1) + + element = t8_forest_get_leaf_element_in_tree(forest, itree, ielement) + + level = t8_element_get_level(scheme, tree_class, element) + + # Loop over all faces of an element. + num_faces = t8_element_get_num_faces(scheme, tree_class, element) + for iface in 1:num_faces + neighids_ref = Ref{Ptr{t8_locidx_t}}() + neighbors_ref = Ref{Ptr{Ptr{t8_element}}}() + neigh_scheme_ref = Ref{t8_eclass_t}() + + dual_faces_ref = Ref{Ptr{Cint}}() + num_neighbors_ref = Ref{Cint}() + + t8_forest_leaf_face_neighbors(forest, itree, element, + neighbors_ref, iface - 1, dual_faces_ref, + num_neighbors_ref, + neighids_ref, neigh_scheme_ref) + + num_neighbors = num_neighbors_ref[] + dual_faces = 1 .+ unsafe_wrap(Array, dual_faces_ref[], num_neighbors) + neighids = 1 .+ unsafe_wrap(Array, neighids_ref[], num_neighbors) + neighbors = unsafe_wrap(Array, neighbors_ref[], num_neighbors) + neigh_scheme = neigh_scheme_ref[] + + if num_neighbors > 0 + neighbor_level = t8_element_get_level(scheme, neigh_scheme, + neighbors[1]) + @info MPI.Comm_rank(comm), itree, ielement, iface, level, neighbor_level + end + + # Free allocated memory. + t8_free(dual_faces_ref[]) + t8_free(neighbors_ref[]) + t8_free(neighids_ref[]) + end + end + end +end + + +# In this function we create a new forest that repartitions a given forest +# and has a layer of ghost elements. +function t8_step4_partition_ghost(forest) + # Check that forest is a committed, that is a valid and usable, forest. + @T8_ASSERT(t8_forest_is_committed(forest)==1) + + # Initialize. + new_forest_ref = Ref(t8_forest_t()) + t8_forest_init(new_forest_ref) + new_forest = new_forest_ref[] + + # Tell the new_forest that is should partition the existing forest. + # This will change the distribution of the forest elements among the processes + # in such a way that afterwards each process has the same number of elements + # (+- 1 if the number of elements is not divisible by the number of processes). + # + # The third 0 argument is the flag 'partition_for_coarsening' which is currently not + # implemented. Once it is, this will ensure that a family of elements will not be split + # across multiple processes and thus one level coarsening is always possible (see also the + # comments on coarsening in t8_step3). + t8_forest_set_partition(new_forest, forest, 1) + + # Tell the new_forest to create a ghost layer. + # This will gather those face neighbor elements of process local element that reside + # on a different process. + # + # We currently support ghost mode T8_GHOST_FACES that creates face neighbor ghost elements + # and will in future also support other modes for edge/vertex neighbor ghost elements. + t8_forest_set_ghost(new_forest, 1, T8_GHOST_FACES) + + # Commit the forest, this step will perform the partitioning and ghost layer creation. + t8_forest_commit(new_forest) + + return new_forest +end + +# In this function we adapt a forest as in step3 and balance it. In our main +# program the input forest is already adapted and then the resulting twice +# adapted forest will be unbalanced. +function t8_step4_balance(forest) + + # Initialize new forest. + balanced_forest_ref = Ref(t8_forest_t()) + t8_forest_init(balanced_forest_ref) + balanced_forest = balanced_forest_ref[] + + # Specify that this forest should result from balancing unbalanced_forest. + # The last argument is the flag 'no_repartition'. + # Since balancing will refine elements, the load-balance will be broken afterwards. + # Setting this flag to false (no_repartition = false -> yes repartition) will repartition + # the forest after balance, such that every process has the same number of elements afterwards. + t8_forest_set_balance(balanced_forest, forest, 1) + t8_forest_set_ghost(balanced_forest, 1, T8_GHOST_FACES) + + # Commit the forest. + t8_forest_commit(balanced_forest) + + return balanced_forest +end + +#include("t8_step3_common.jl") + + + + +# The uniform refinement level of the forest. +level = 0 + +# Initialize MPI. This has to happen before we initialize sc or t8code. +mpiret = MPI.Init() + +# We will use MPI_COMM_WORLD as a communicator. +comm = MPI.COMM_WORLD + +# Initialize the sc library, has to happen before we initialize t8code. +sc_init(comm, 0, 1, C_NULL, SC_LP_ESSENTIAL) + +# Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. +t8_init(SC_LP_PRODUCTION) + + +# Build a cube cmesh with tet, hex, and prism trees. +cmesh = t8_cmesh_new_brick_2d(3, 7, 0, 0, comm) +t8_global_productionf(" [step4] Created coarse mesh.\n") + +forest = t8_forest_new_uniform(cmesh, t8_scheme_new_default(), level, 1, comm) + +# Print information of the forest. +t8_step3_print_forest_information(forest); + + + +# +# Balance +# +forest = t8_step4_balance(forest) +t8_global_productionf(" [step4] Balanced forest.\n") +t8_step3_print_forest_information(forest) + + +# +# Partition and create ghost elements. +# +forest = t8_step4_partition_ghost(forest) + +t8_global_productionf(" [step4] Repartitioned forest and built ghost layer.\n") +t8_step3_print_forest_information(forest) + + +t8_traverse_forest(forest, comm) + +# +# clean-up +# + +# Destroy the forest. +t8_forest_unref(Ref(forest)) + +sc_finalize() diff --git a/examples/t8_step5_element_data.jl b/examples/t8_step5_element_data.jl index 526ecb9..2b5092d 100644 --- a/examples/t8_step5_element_data.jl +++ b/examples/t8_step5_element_data.jl @@ -194,8 +194,10 @@ function t8_step5_output_data_to_vtu(forest, element_data, prefix) # WARNING: This code hangs for Julia v1.8.* or older. Use at least Julia v1.9. # For each user defined data field we need one t8_vtk_data_field_t variable. - vtk_data = t8_vtk_data_field_t(T8_VTK_SCALAR, # Set the type of this variable. Since we have one value per element, we pick T8_VTK_SCALAR. - NTuple{8192, Cchar}(rpad("Element volume\0", 8192, ' ')), # The name of the field as should be written to the file. + vtk_data = t8_vtk_data_field_t(T8_VTK_SCALAR, + # Sets the type of this variable. Since we have one value per element, we pick T8_VTK_SCALAR. + NTuple{T8code.T8_BUFSIZ, Cchar}(rpad("Element volume\0", T8code.T8_BUFSIZ, ' ')), + # The name of the field as should be written to the file. pointer(element_volumes)) # To write user defined data, we need to extended output function @@ -277,11 +279,9 @@ if t8_forest_get_num_ghosts(forest) > 0 end # Output the volume data to vtu. -if !(CI_ON_WINDOWS || CI_ON_MACOS) - t8_step5_output_data_to_vtu(forest, element_data, prefix_forest_with_data) - t8_global_productionf(" [step5] Wrote forest and volume data to %s*.\n", - prefix_forest_with_data) -end +t8_step5_output_data_to_vtu(forest, element_data, prefix_forest_with_data) +t8_global_productionf(" [step5] Wrote forest and volume data to %s*.\n", + prefix_forest_with_data) # # Clean-up. diff --git a/examples/t8_step6_stencil.jl b/examples/t8_step6_stencil.jl index 6d3f338..6a72465 100644 --- a/examples/t8_step6_stencil.jl +++ b/examples/t8_step6_stencil.jl @@ -339,13 +339,13 @@ function t8_step6_output_data_to_vtu(forest, element_data, prefix) # WARNING: This code hangs for Julia v1.8.* or older. Use at least Julia v1.9. vtk_data = [ t8_vtk_data_field_t(T8_VTK_SCALAR, - NTuple{8192, Cchar}(rpad("height\0", 8192, ' ')), + NTuple{T8code.T8_BUFSIZ, Cchar}(rpad("height\0", T8code.T8_BUFSIZ, ' ')), pointer(heights)), t8_vtk_data_field_t(T8_VTK_SCALAR, - NTuple{8192, Cchar}(rpad("schlieren\0", 8192, ' ')), + NTuple{T8code.T8_BUFSIZ, Cchar}(rpad("schlieren\0", T8code.T8_BUFSIZ, ' ')), pointer(schlieren)), t8_vtk_data_field_t(T8_VTK_SCALAR, - NTuple{8192, Cchar}(rpad("curvature\0", 8192, ' ')), + NTuple{T8code.T8_BUFSIZ, Cchar}(rpad("curvature\0", T8code.T8_BUFSIZ, ' ')), pointer(curvature)) ] @@ -402,10 +402,8 @@ t8_step6_exchange_ghost_data(forest, element_data) t8_step6_compute_stencil(forest, element_data) # Output the data to vtu files. -if !(CI_ON_WINDOWS || CI_ON_MACOS) - t8_step6_output_data_to_vtu(forest, element_data, prefix_forest_with_data) - t8_global_productionf(" Wrote forest and data to %s*.\n", prefix_forest_with_data) -end +t8_step6_output_data_to_vtu(forest, element_data, prefix_forest_with_data) +t8_global_productionf(" Wrote forest and data to %s*.\n", prefix_forest_with_data) # # Clean-up diff --git a/src/T8code.jl b/src/T8code.jl index 1075d53..3af3e90 100644 --- a/src/T8code.jl +++ b/src/T8code.jl @@ -258,6 +258,9 @@ macro T8_ASSERT(q) :($(esc(q)) ? nothing : throw(AssertionError($(string(q))))) end +# platform specific BUFSIZ used in t8_vtk_data_field_t +const T8_BUFSIZ = sizeof(t8_vtk_data_field_t.types[2]) + function t8_free(ptr) Libt8.sc_free(t8_get_package_id(), ptr) end From 9bfeb0d6e614b670fb6bcc0a180ad7e871dcd4f7 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Wed, 24 Jun 2026 16:46:59 +0200 Subject: [PATCH 02/12] remove CI check for Apple or Windows --- test/test_all.jl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/test_all.jl b/test/test_all.jl index cfc21da..db46548 100644 --- a/test/test_all.jl +++ b/test/test_all.jl @@ -12,11 +12,6 @@ MPI.Init() comm = MPI.COMM_WORLD -# Check whether we run CI in the cloud with Windows or Mac, see also -# https://docs.github.com/en/actions/learn-github-actions/environment-variables -CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() -CI_ON_MACOS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.isapple() - @testset "init" begin include("test_init.jl") end From 0ac5cadfb7a09eb88bd143824d08cb55c4194efa Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Wed, 1 Jul 2026 10:25:19 +0200 Subject: [PATCH 03/12] fix type of scheme --- dev/fixes.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dev/fixes.sh b/dev/fixes.sh index 770ad32..313b9e8 100755 --- a/dev/fixes.sh +++ b/dev/fixes.sh @@ -37,5 +37,9 @@ sed -i -z 's/\nstruct t8_forest.*stats_computed::Cint\nend/\n# This struct is no # Fix forest type sed -i "s/forest::Cint/forest::t8_forest_t/" "${LIB_JL}" +# Fix scheme type +sed -i "s/scheme::Ptr{Cint}/scheme::Ptr{t8_scheme_c}/" "${LIB_JL}" +sed -i "s/t8_scheme_new_default()::Ptr{Cint}/t8_scheme_new_default()::Ptr{t8_scheme_c}/" "${LIB_JL}" + # Rename remaining MPI macros sed -i "s/= MPI_/= MPI./" "${LIB_JL}" From e88355df59be32d2e4b15fcce14d894b75885814 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Wed, 1 Jul 2026 10:25:35 +0200 Subject: [PATCH 04/12] t8code July release --- src/Libt8.jl | 14498 +++++++++++++++++++++++++++---------------------- 1 file changed, 7902 insertions(+), 6596 deletions(-) diff --git a/src/Libt8.jl b/src/Libt8.jl index 1f7aab6..0d7362b 100644 --- a/src/Libt8.jl +++ b/src/Libt8.jl @@ -68,21 +68,19 @@ const INT64_MAX = typemax(Clonglong) """ - sc_extern_c_hack_1() - -We want to export the whole implementation to be callable from "C". + sc_extern_c_hack_3() ### Prototype ```c SC_EXTERN_C_BEGIN; ``` """ -function sc_extern_c_hack_1() - @ccall libsc.sc_extern_c_hack_1()::Cvoid +function sc_extern_c_hack_3() + @ccall libsc.sc_extern_c_hack_3()::Cvoid end """ - sc_extern_c_hack_2() + sc_extern_c_hack_4() ` ` @@ -91,8 +89,8 @@ end SC_EXTERN_C_END; ``` """ -function sc_extern_c_hack_2() - @ccall libsc.sc_extern_c_hack_2()::Cvoid +function sc_extern_c_hack_4() + @ccall libsc.sc_extern_c_hack_4()::Cvoid end """ @@ -180,12 +178,9 @@ end The central log function to be called by all packages. Dispatches the log calls by package and filters by category and priority. # Arguments -* `filename`:\\[in\\] Usually used with a \\_\\_FILE\\_\\_ argument. -* `lineno`:\\[in\\] Usually used with a \\_\\_LINE\\_\\_ argument. * `package`:\\[in\\] Must be a registered package id or -1. * `category`:\\[in\\] Must be [`SC_LC_NORMAL`](@ref) or [`SC_LC_GLOBAL`](@ref). * `priority`:\\[in\\] Must be > [`SC_LP_ALWAYS`](@ref) and < [`SC_LP_SILENT`](@ref). -* `msg`:\\[in\\] Nul-terminated string to print. ### Prototype ```c void sc_log (const char *filename, int lineno, int package, int category, int priority, const char *msg); @@ -311,38 +306,6 @@ function sc_shmem_free(package, array, comm) @ccall libsc.sc_shmem_free(package::Cint, array::Ptr{Cvoid}, comm::MPI_Comm)::Cvoid end -""" - sc_mpi_is_enabled() - -Return whether MPI is configured. - -# Returns -Boolean corresponding to define [`SC_ENABLE_MPI`](@ref). -### Prototype -```c -int sc_mpi_is_enabled (void); -``` -""" -function sc_mpi_is_enabled() - @ccall libsc.sc_mpi_is_enabled()::Cint -end - -""" - sc_mpi_is_shared() - -Return whether MPI supports type split and shared windows. - -# Returns -Boolean corresponding to #define [`SC_ENABLE_MPISHARED`](@ref). -### Prototype -```c -int sc_mpi_is_shared (void); -``` -""" -function sc_mpi_is_shared() - @ccall libsc.sc_mpi_is_shared()::Cint -end - """ sc_tag_t @@ -507,8 +470,10 @@ function sc_mpi_comm_get_and_attach(comm) @ccall libsc.sc_mpi_comm_get_and_attach(comm::MPI_Comm)::Cint end +# typedef void ( * sc_handler_t ) ( void * data ) +const sc_handler_t = Ptr{Cvoid} + # typedef void ( * sc_log_handler_t ) ( FILE * log_stream , const char * filename , int lineno , int package , int category , int priority , const char * msg ) -"""Type of the log handler function.""" const sc_log_handler_t = Ptr{Cvoid} # typedef void ( * sc_abort_handler_t ) ( void ) @@ -828,7 +793,6 @@ Set the logging verbosity of a registered package. This can be called at any poi # Arguments * `package_id`:\\[in\\] Must be a registered package identifier. -* `log_priority`:\\[in\\] The minimum priority required to output. ### Prototype ```c void sc_package_set_verbosity (int package_id, int log_priority); @@ -1056,22 +1020,6 @@ function sc_version_minor() @ccall libsc.sc_version_minor()::Cint end -""" - sc_is_littleendian() - -Perform a runtime check for the integer endian convention. - -# Returns -True if byte order is little endian, false otherwise. -### Prototype -```c -int sc_is_littleendian (void); -``` -""" -function sc_is_littleendian() - @ccall libsc.sc_is_littleendian()::Cint -end - """ sc_have_zlib() @@ -1104,22 +1052,6 @@ function sc_have_json() @ccall libsc.sc_have_json()::Cint end -""" - sc_sleep(milliseconds) - -Portable function to sleep a prescribed amount of milliseconds. - -# Arguments -* `milliseconds`:\\[in\\] The number of milliseconds to sleep. -### Prototype -```c -void sc_sleep (unsigned milliseconds); -``` -""" -function sc_sleep(milliseconds) - @ccall libsc.sc_sleep(milliseconds::Cuint)::Cvoid -end - # typedef unsigned int ( * sc_hash_function_t ) ( const void * v , const void * u ) """ Function to compute a hash value of an object. @@ -2963,9 +2895,6 @@ function sc_recycle_array_remove(rec_array, position) @ccall libsc.sc_recycle_array_remove(rec_array::Ptr{sc_recycle_array_t}, position::Csize_t)::Ptr{Cvoid} end -"""A type for holding process ids.""" -const t8_procidx_t = Cint - """A type for storing SFC indices""" const t8_linearidx_t = UInt64 @@ -2974,18 +2903,13 @@ const t8_linearidx_t = UInt64 Communication tags used internal to t8code. -| Enumerator | Note | -| :------------------------------------------ | :------------------------------------------------------- | -| T8\\_MPI\\_TAG\\_FIRST | Dummy first MPT tag. | -| T8\\_MPI\\_PARTITION\\_CMESH | Used for coarse mesh partitioning | -| T8\\_MPI\\_PARTITION\\_FOREST | Used for forest partitioning | -| T8\\_MPI\\_GHOST\\_FOREST | Used for for ghost layer creation | -| T8\\_MPI\\_GHOST\\_EXC\\_FOREST | Used for ghost data exchange | -| T8\\_MPI\\_CMESH\\_UNIFORM\\_BOUNDS\\_START | Used for cmesh uniform bounds computation. | -| T8\\_MPI\\_CMESH\\_UNIFORM\\_BOUNDS\\_END | | -| T8\\_MPI\\_TEST\\_ELEMENT\\_PACK\\_TAG | Used for testing mpi pack and unpack functionality | -| T8\\_MPI\\_PFC\\_TAG | Used for data exchange during partition for coarsening. | -| T8\\_MPI\\_TAG\\_LAST | Dummy last MPI tag. | +| Enumerator | Note | +| :------------------------------------- | :-------------------------------------------------- | +| T8\\_MPI\\_PARTITION\\_CMESH | Used for coarse mesh partitioning | +| T8\\_MPI\\_PARTITION\\_FOREST | Used for forest partitioning | +| T8\\_MPI\\_GHOST\\_FOREST | Used for for ghost layer creation | +| T8\\_MPI\\_GHOST\\_EXC\\_FOREST | Used for ghost data exchange | +| T8\\_MPI\\_TEST\\_ELEMENT\\_PACK\\_TAG | Used for testing mpi pack and unpack functionality | """ @cenum t8_MPI_tag_t::UInt32 begin T8_MPI_TAG_FIRST = 214 @@ -2993,11 +2917,8 @@ Communication tags used internal to t8code. T8_MPI_PARTITION_FOREST = 296 T8_MPI_GHOST_FOREST = 297 T8_MPI_GHOST_EXC_FOREST = 298 - T8_MPI_CMESH_UNIFORM_BOUNDS_START = 299 - T8_MPI_CMESH_UNIFORM_BOUNDS_END = 300 - T8_MPI_TEST_ELEMENT_PACK_TAG = 301 - T8_MPI_PFC_TAG = 302 - T8_MPI_TAG_LAST = 303 + T8_MPI_TEST_ELEMENT_PACK_TAG = 299 + T8_MPI_TAG_LAST = 300 end # automatic type deduction for variadic arguments may not be what you want, please use with caution @@ -3073,22 +2994,6 @@ end :(@ccall(libt8.t8_errorf(fmt::Cstring; $(to_c_type_pairs(va_list)...))::Cvoid)) end -""" - t8_set_external_log_fcn(log_fcn) - -Set a custom logging function to be used by t8code. When setting a custom logging function, the t8code internal logging function will be ignored. - -# Arguments -* `log_fcn`:\\[in\\] A function pointer to a logging function -### Prototype -```c -void t8_set_external_log_fcn (void (*log_fcn) (int category, int priority, const char *msg)); -``` -""" -function t8_set_external_log_fcn(log_fcn) - @ccall libt8.t8_set_external_log_fcn(log_fcn::Ptr{Cvoid})::Cvoid -end - """ t8_init(log_threshold) @@ -3106,22 +3011,21 @@ function t8_init(log_threshold) end """ - t8_sc_array_index_locidx(array, index) + t8_sc_array_index_locidx(array, it) Return a pointer to an array element indexed by a [`t8_locidx_t`](@ref). # Arguments -* `array`:\\[in\\] The array of elements. * `index`:\\[in\\] needs to be in [0]..[elem\\_count-1]. # Returns -A void * pointing to entry *index* in *array*. +A void * pointing to entry *it* in *array*. ### Prototype ```c -void * t8_sc_array_index_locidx (const sc_array_t *array, const t8_locidx_t index); +void * t8_sc_array_index_locidx (const sc_array_t *array, const t8_locidx_t it); ``` """ -function t8_sc_array_index_locidx(array, index) - @ccall libt8.t8_sc_array_index_locidx(array::Ptr{sc_array_t}, index::t8_locidx_t)::Ptr{Cvoid} +function t8_sc_array_index_locidx(array, it) + @ccall libt8.t8_sc_array_index_locidx(array::Ptr{sc_array_t}, it::t8_locidx_t)::Ptr{Cvoid} end """ @@ -3229,35 +3133,6 @@ function sc_shmem_prefix(sendbuf, recvbuf, count, type, op, comm) @ccall libsc.sc_shmem_prefix(sendbuf::Ptr{Cvoid}, recvbuf::Ptr{Cvoid}, count::Cint, type::Cint, op::Cint, comm::MPI_Comm)::Cvoid end -""" - t8_load_mode - -This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data. - -| Enumerator | Note | -| :----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| T8\\_LOAD\\_FIRST | First mode. | -| T8\\_LOAD\\_SIMPLE | In simple mode, the first n processes load the file | -| T8\\_LOAD\\_BGQ | In BGQ mode, the file is loaded on n nodes and from one process of each node. This needs MPI Version 3.1 or higher. | -| T8\\_LOAD\\_STRIDE | Every n-th process loads a file. Handle with care, we introduce it, since on Juqueen MPI-3 was not available. The parameter n has to be passed as an extra parameter. # See also [`t8_cmesh_load_and_distribute`](@ref) | -| T8\\_LOAD\\_COUNT | Number of modes in which we can open a saved cmesh. | -""" -@cenum t8_load_mode::UInt32 begin - T8_LOAD_FIRST = 0 - T8_LOAD_SIMPLE = 0 - T8_LOAD_BGQ = 1 - T8_LOAD_STRIDE = 2 - T8_LOAD_COUNT = 3 -end - -"""This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data.""" -const t8_load_mode_t = t8_load_mode - -mutable struct t8_cmesh end - -"""Forward pointer reference to hidden cmesh implementation. This reference needs to be known by [`t8_geometry`](@ref), hence we put it before the include.""" -const t8_cmesh_t = Ptr{t8_cmesh} - """ sc_refcount @@ -3416,14 +3291,254 @@ function sc_refcount_is_last(rc) @ccall libsc.sc_refcount_is_last(rc::Ptr{sc_refcount_t})::Cint end -mutable struct t8_ctree end +mutable struct t8_eclass_scheme end + +"""This typedef holds virtual functions for a particular element class.""" +const t8_eclass_scheme_c = t8_eclass_scheme + +""" + t8_scheme_cxx + +The scheme holds implementations for one or more element classes. + +| Field | Note | +| :--------------- | :----------------------------------------------------- | +| rc | Reference counter for this scheme. | +| eclass\\_schemes | This array holds one virtual table per element class. | +""" +struct t8_scheme_cxx + rc::sc_refcount_t + eclass_schemes::NTuple{8, Ptr{t8_eclass_scheme_c}} +end + +"""The scheme holds implementations for one or more element classes.""" +const t8_scheme_cxx_t = t8_scheme_cxx + +"""We can reuse the reference counter type from libsc.""" +const t8_refcount_t = sc_refcount_t + +struct t8_cmesh_trees + from_proc::Ptr{sc_array_t} + tree_to_proc::Ptr{Cint} + ghost_to_proc::Ptr{Cint} + ghost_globalid_to_local_id::Ptr{sc_hash_t} + global_local_mempool::Ptr{sc_mempool_t} +end + +const t8_cmesh_trees_t = Ptr{t8_cmesh_trees} + +mutable struct t8_shmem_array end + +const t8_shmem_array_t = Ptr{t8_shmem_array} + +mutable struct t8_geometry_handler end + +"""This typedef holds virtual functions for the geometry handler. We need it so that we can use [`t8_geometry_handler_c`](@ref) pointers in .c files without them seeing the actual C++ code (and then not compiling) TODO: Delete this when the cmesh is a proper cpp class.""" +const t8_geometry_handler_c = t8_geometry_handler + +""" + t8_stash + +The stash data structure is used to store information about the cmesh before it is committed. In particular we store the eclasses of the trees, the face-connections and the tree attributes. Using the stash structure allows us to have a very flexible interface. When constructing a new mesh, the user can specify all these mesh entities in arbitrary order. As soon as the cmesh is committed the information is copied from the stash to the cmesh in an order mannered. + +| Field | Note | +| :--------- | :---------------------------------------------------------------------- | +| classes | Stores the eclasses of the trees. # See also [`t8_stash_class`](@ref) | +| joinfaces | Stores the face-connections. # See also [`t8_stash_joinface`](@ref) | +| attributes | Stores the attributes. # See also [`t8_stash_attribute`](@ref) | +""" +struct t8_stash + classes::sc_array_t + joinfaces::sc_array_t + attributes::sc_array_t +end + +const t8_stash_t = Ptr{t8_stash} + +""" + t8_cprofile + +This struct is used to profile cmesh algorithms. The cmesh struct stores a pointer to a profile struct, and if it is nonzero, various runtimes and data measurements are stored here. + +| Field | Note | +| :-------------------------------- | :------------------------------------------------------------------------------------------------------------ | +| partition\\_trees\\_shipped | The number of trees this process has sent to other in the last partition call. | +| partition\\_ghosts\\_shipped | The number of ghosts this process has sent to other in the last partition call. | +| partition\\_trees\\_recv | The number of trees this process has received from other in the last partition call. | +| partition\\_ghosts\\_recv | The number of ghosts this process has received from other in the last partition call. | +| partition\\_bytes\\_sent | The total number of bytes sent to other processes in the last partition call. | +| partition\\_procs\\_sent | The number of different processes this process has send local trees or ghosts to in the last partition call. | +| first\\_tree\\_shared | 1 if this processes' first tree is shared. 0 if not. | +| partition\\_runtime | The runtime of the last call to [`t8_cmesh_partition`](@ref). | +| commit\\_runtime | The runtime of the last call to [`t8_cmesh_commit`](@ref). | +| geometry\\_evaluate\\_num\\_calls | The number of calls to [`t8_geometry_evaluate`](@ref). | +| geometry\\_evaluate\\_runtime | The accumulated runtime of calls to [`t8_geometry_evaluate`](@ref). | +# See also +[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) +""" +struct t8_cprofile + partition_trees_shipped::t8_locidx_t + partition_ghosts_shipped::t8_locidx_t + partition_trees_recv::t8_locidx_t + partition_ghosts_recv::t8_locidx_t + partition_bytes_sent::Csize_t + partition_procs_sent::Cint + first_tree_shared::Cint + partition_runtime::Cdouble + commit_runtime::Cdouble + geometry_evaluate_num_calls::Cdouble + geometry_evaluate_runtime::Cdouble +end + +""" +This struct is used to profile cmesh algorithms. The cmesh struct stores a pointer to a profile struct, and if it is nonzero, various runtimes and data measurements are stored here. + +# See also +[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) +""" +const t8_cprofile_t = t8_cprofile + +""" + t8_cmesh + +This structure holds the connectivity data of the coarse mesh. It can either be replicated, then each process stores a copy of the whole mesh, or partitioned. In the latter case, each process only stores a local portion of the mesh plus information about ghost elements. + +The coarse mesh is a collection of coarse trees that can be identified along faces. TODO: this description is outdated. rewrite it. The array ctrees stores these coarse trees sorted by their (global) tree\\_id. If the mesh if partitioned it is partitioned according to an (possible only virtually existing) underlying fine mesh. Therefore the ctrees array can store duplicated trees on different processes, if each of these processes owns elements of the same tree in the fine mesh. + +Each tree stores information about its face-neighbours in an array of t8_ctree_fneighbor. + +If partitioned the ghost trees are stored in a hash table that is backed up by an array. The hash value of a ghost tree is its tree\\_id modulo the number of ghosts on this process. + +| Field | Note | +| :--------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| committed | Flag that specifies whether the cmesh is committed or not. t8_cmesh_commit | +| dimension | The dimension of the cmesh. It is set when the first tree is inserted. | +| set\\_partition | If nonzero the cmesh is partitioned. If zero each process has the whole cmesh. | +| face\\_knowledge | If partitioned the level of face knowledge that is expected. t8_mesh_set_partitioned; see t8_cmesh_set_partition. | +| set\\_partition\\_scheme | If the cmesh is to be partitioned according to a uniform level, the scheme that describes the refinement pattern. See t8_cmesh_set_partition. | +| set\\_partition\\_level | Non-negative if the cmesh should be partitioned from an already existing cmesh with an assumed *level* uniform mesh underneath. | +| set\\_from | If this cmesh shall be derived from an existing cmesh by copy or more elaborate modification, we store a pointer to this other cmesh here. | +| mpirank | Number of this MPI process. | +| mpisize | Number of MPI processes. | +| rc | The reference count of the cmesh. | +| num\\_trees | The global number of trees | +| num\\_local\\_trees | If partitioned the number of trees on this process. Otherwise the global number of trees. | +| num\\_ghosts | If partitioned the number of neighbor trees owned by different processes. | +| num\\_local\\_trees\\_per\\_eclass | After commit the number of local trees for each eclass. Stores the same entries as *num_trees_per_eclass*, if the cmesh is replicated. | +| num\\_trees\\_per\\_eclass | After commit the number of global trees for each eclass. | +| trees | structure that holds all local trees and ghosts | +| first\\_tree | The global index of the first local tree on this process. Zero if the cmesh is not partitioned. -1 if this processor is empty. See also https://github.com/DLR-AMR/t8code/wiki/Tree-indexing | +| first\\_tree\\_shared | If partitioned true if the first tree on this process is also the last tree on the next process. Always zero if num\\_local\\_trees = 0 | +| tree\\_offsets | If partitioned for each process the global index of its first local tree or -(first local tree) - 1 if the first tree on that process is shared. Since this is very memory consuming we only fill it when needed. | +| geometry\\_handler | Handles all geometries that are used by trees in this cmesh. | +| stash | Used as temporary storage for the trees before commit. | +| profile | Used to measure runtimes and statistics of the cmesh algorithms. | +# See also +t8\\_ctree\\_fneighbor +""" +struct t8_cmesh + committed::Cint + dimension::Cint + set_partition::Cint + face_knowledge::Cint + set_partition_scheme::Ptr{t8_scheme_cxx_t} + set_partition_level::Int8 + set_from::Ptr{t8_cmesh} + mpirank::Cint + mpisize::Cint + rc::t8_refcount_t + num_trees::t8_gloidx_t + num_local_trees::t8_locidx_t + num_ghosts::t8_locidx_t + num_local_trees_per_eclass::NTuple{8, t8_locidx_t} + num_trees_per_eclass::NTuple{8, t8_gloidx_t} + trees::t8_cmesh_trees_t + first_tree::t8_gloidx_t + first_tree_shared::Int8 + tree_offsets::t8_shmem_array_t + geometry_handler::Ptr{t8_geometry_handler_c} + stash::t8_stash_t + profile::Ptr{t8_cprofile_t} +end + +const t8_cmesh_t = Ptr{t8_cmesh} + +""" + t8_eclass + +This enumeration contains all possible element classes. + +| Enumerator | Note | +| :--------------------- | :----------------------------------------------------------------------------------------------------------------- | +| T8\\_ECLASS\\_VERTEX | The vertex is the only zero-dimensional element class. | +| T8\\_ECLASS\\_LINE | The line is the only one-dimensional element class. | +| T8\\_ECLASS\\_QUAD | The quadrilateral is one of two element classes in two dimensions. | +| T8\\_ECLASS\\_TRIANGLE | The element class for a triangle. | +| T8\\_ECLASS\\_HEX | The hexahedron is one three-dimensional element class. | +| T8\\_ECLASS\\_TET | The tetrahedron is another three-dimensional element class. | +| T8\\_ECLASS\\_PRISM | The prism has five sides: two opposing triangles joined by three quadrilaterals. | +| T8\\_ECLASS\\_PYRAMID | The pyramid has a quadrilateral as base and four triangles as sides. | +| T8\\_ECLASS\\_COUNT | This is no element class but can be used as the number of element classes. | +| T8\\_ECLASS\\_INVALID | This is no element class but can be used for the case a class of a third party library is not supported by t8code | +""" +@cenum t8_eclass::UInt32 begin + T8_ECLASS_ZERO = 0 + T8_ECLASS_VERTEX = 0 + T8_ECLASS_LINE = 1 + T8_ECLASS_QUAD = 2 + T8_ECLASS_TRIANGLE = 3 + T8_ECLASS_HEX = 4 + T8_ECLASS_TET = 5 + T8_ECLASS_PRISM = 6 + T8_ECLASS_PYRAMID = 7 + T8_ECLASS_COUNT = 8 + T8_ECLASS_INVALID = 9 +end + +"""This enumeration contains all possible element classes.""" +const t8_eclass_t = t8_eclass + +""" + t8_ctree + +This structure holds the data of a local tree including the information about face neighbors. For those the tree\\_to\\_face index is computed as follows. Let F be the maximal number of faces of any eclass of the cmesh's dimension, then ttf % F is the face number and ttf / F is the orientation. (t8_eclass_max_num_faces) The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees. We chose a main\\_face from them as follows: Either both trees have the same element class, then the face with the lower face number is the main\\_face or the trees belong to different classes in which case the face belonging to the tree with the lower class according to the ordering triangle < square, hex < tet < prism < pyramid, is the main\\_face. Then face corner 0 of the main\\_face connects to a face corner k in the other face. The face orientation is defined as the number k. If the classes are equal and my\\_face == other\\_face, treating either of both faces as the main\\_face leads to the same result. See https://arxiv.org/pdf/1611.02929.pdf for more details. + +| Field | Note | +| :--------------- | :------------------------------------------------------------------------------------------ | +| treeid | The local number of this tree. | +| eclass | The eclass of this tree. | +| neigh\\_offset | Adding this offset to the address of the tree yields the array of face\\_neighbor entries | +| att\\_offset | Adding this offset to the address of the tree yields the array of attribute\\_info entries | +| num\\_attributes | The number of attributes at this tree | +""" +struct t8_ctree + treeid::t8_locidx_t + eclass::t8_eclass_t + neigh_offset::Csize_t + att_offset::Csize_t + num_attributes::Cint +end -"""Forward pointer references to hidden implementations of tree.""" const t8_ctree_t = Ptr{t8_ctree} -mutable struct t8_cghost end +""" + t8_cghost + +| Field | Note | +| :--------------- | :------------------------------------------------------------------------------------------- | +| treeid | The global number of this ghost. | +| eclass | The eclass of this ghost. | +| att\\_offset | Adding this offset to the address of the ghost yields the array of attribute\\_info entries | +| num\\_attributes | The number of attributes at this ghost | +""" +struct t8_cghost + treeid::t8_gloidx_t + eclass::t8_eclass_t + neigh_offset::Csize_t + att_offset::Csize_t + num_attributes::Cint +end -"""Forward pointer references to hidden implementations of ghost tree.""" const t8_cghost_t = Ptr{t8_cghost} """ @@ -3442,7 +3557,7 @@ function t8_cmesh_init(pcmesh) @ccall libt8.t8_cmesh_init(pcmesh::Ptr{t8_cmesh_t})::Cvoid end -# no prototype is found for this function at t8_cmesh.h:79:1, please use with caution +# no prototype is found for this function at t8_cmesh.h:76:1, please use with caution """ t8_cmesh_new() @@ -3496,19 +3611,23 @@ function t8_cmesh_is_committed(cmesh) end """ - t8_cmesh_disable_negative_volume_check(cmesh) + t8_cmesh_tree_vertices_negative_volume(eclass, vertices, num_vertices) -Disable the debug check for negative volumes in trees during t8_cmesh_commit. Does nothing outside of debug mode. +Given a set of vertex coordinates for a tree of a given eclass. Query whether the geometric volume of the tree with this coordinates would be negative. # Arguments -* `cmesh`:\\[in,out\\] +* `eclass`:\\[in\\] The eclass of a tree. +* `vertices`:\\[in\\] The coordinates of the tree's vertices. +* `num_vertices`:\\[in\\] The number of vertices. *vertices* must hold 3 * *num_vertices* many doubles. *num_vertices* must match t8_eclass_num_vertices[*eclass*] +# Returns +True if the geometric volume describe by *vertices* is negative. False otherwise. Returns true if a tree of the given eclass with the given vertex coordinates does have negative volume. ### Prototype ```c -void t8_cmesh_disable_negative_volume_check (t8_cmesh_t cmesh); +int t8_cmesh_tree_vertices_negative_volume (const t8_eclass_t eclass, const double *vertices, const int num_vertices); ``` """ -function t8_cmesh_disable_negative_volume_check(cmesh) - @ccall libt8.t8_cmesh_disable_negative_volume_check(cmesh::t8_cmesh_t)::Cvoid +function t8_cmesh_tree_vertices_negative_volume(eclass, vertices, num_vertices) + @ccall libt8.t8_cmesh_tree_vertices_negative_volume(eclass::t8_eclass_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cint end """ @@ -3528,10 +3647,6 @@ function t8_cmesh_set_derive(cmesh, set_from) @ccall libt8.t8_cmesh_set_derive(cmesh::t8_cmesh_t, set_from::t8_cmesh_t)::Cvoid end -mutable struct t8_shmem_array end - -const t8_shmem_array_t = Ptr{t8_shmem_array} - """ t8_cmesh_alloc_offsets(mpisize, comm) @@ -3587,27 +3702,22 @@ function t8_cmesh_set_partition_offsets(cmesh, tree_offsets) @ccall libt8.t8_cmesh_set_partition_offsets(cmesh::t8_cmesh_t, tree_offsets::t8_shmem_array_t)::Cvoid end -mutable struct t8_scheme end - -"""The scheme holds implementations for one or more element classes. Opaque pointer for C interface. Detailed documentation at t8_scheme.""" -const t8_scheme_c = t8_scheme - """ - t8_cmesh_set_partition_uniform(cmesh, element_level, scheme) + t8_cmesh_set_partition_uniform(cmesh, element_level, ts) Declare if a derived cmesh should be partitioned according to a uniform refinement of a given level for the provided scheme. This call is only valid when the cmesh is not yet committed via a call to t8_cmesh_commit and when the cmesh will be derived. # Arguments * `cmesh`:\\[in,out\\] The cmesh to be updated. * `element_level`:\\[in\\] The refinement\\_level. -* `scheme`:\\[in\\] The element scheme describing the refinement pattern. We take ownership. This can be prevented by referencing **scheme** before calling this function. +* `ts`:\\[in\\] The element scheme describing the refinement pattern. We take ownership. This can be prevented by referencing **ts** before calling this function. ### Prototype ```c -void t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, const int element_level, const t8_scheme_c *scheme); +void t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, int element_level, t8_scheme_cxx_t *ts); ``` """ -function t8_cmesh_set_partition_uniform(cmesh, element_level, scheme) - @ccall libt8.t8_cmesh_set_partition_uniform(cmesh::t8_cmesh_t, element_level::Cint, scheme::Ptr{t8_scheme_c})::Cvoid +function t8_cmesh_set_partition_uniform(cmesh, element_level, ts) + @ccall libt8.t8_cmesh_set_partition_uniform(cmesh::t8_cmesh_t, element_level::Cint, ts::Ptr{t8_scheme_cxx_t})::Cvoid end """ @@ -3617,11 +3727,11 @@ Refine the cmesh to a given level. Thus split each tree into x^level subtrees TO ### Prototype ```c -void t8_cmesh_set_refine (t8_cmesh_t cmesh, const int level, const t8_scheme_c *scheme); +void t8_cmesh_set_refine (t8_cmesh_t cmesh, int level, t8_scheme_cxx_t *scheme); ``` """ function t8_cmesh_set_refine(cmesh, level, scheme) - @ccall libt8.t8_cmesh_set_refine(cmesh::t8_cmesh_t, level::Cint, scheme::Ptr{t8_scheme_c})::Cvoid + @ccall libt8.t8_cmesh_set_refine(cmesh::t8_cmesh_t, level::Cint, scheme::Ptr{t8_scheme_cxx_t})::Cvoid end """ @@ -3641,42 +3751,6 @@ function t8_cmesh_set_dimension(cmesh, dim) @ccall libt8.t8_cmesh_set_dimension(cmesh::t8_cmesh_t, dim::Cint)::Cvoid end -""" - t8_eclass - -This enumeration contains all possible element classes. - -| Enumerator | Note | -| :--------------------- | :----------------------------------------------------------------------------------------------------------------- | -| T8\\_ECLASS\\_ZERO | Zero-dimensional element class. | -| T8\\_ECLASS\\_VERTEX | The vertex is the only zero-dimensional element class. | -| T8\\_ECLASS\\_LINE | The line is the only one-dimensional element class. | -| T8\\_ECLASS\\_QUAD | The quadrilateral is one of two element classes in two dimensions. | -| T8\\_ECLASS\\_TRIANGLE | The element class for a triangle. | -| T8\\_ECLASS\\_HEX | The hexahedron is one three-dimensional element class. | -| T8\\_ECLASS\\_TET | The tetrahedron is another three-dimensional element class. | -| T8\\_ECLASS\\_PRISM | The prism has five sides: two opposing triangles joined by three quadrilaterals. | -| T8\\_ECLASS\\_PYRAMID | The pyramid has a quadrilateral as base and four triangles as sides. | -| T8\\_ECLASS\\_COUNT | This is no element class but can be used as the number of element classes. | -| T8\\_ECLASS\\_INVALID | This is no element class but can be used for the case a class of a third party library is not supported by t8code | -""" -@cenum t8_eclass::UInt32 begin - T8_ECLASS_ZERO = 0 - T8_ECLASS_VERTEX = 0 - T8_ECLASS_LINE = 1 - T8_ECLASS_QUAD = 2 - T8_ECLASS_TRIANGLE = 3 - T8_ECLASS_HEX = 4 - T8_ECLASS_TET = 5 - T8_ECLASS_PRISM = 6 - T8_ECLASS_PYRAMID = 7 - T8_ECLASS_COUNT = 8 - T8_ECLASS_INVALID = 9 -end - -"""This enumeration contains all possible element classes.""" -const t8_eclass_t = t8_eclass - """ t8_cmesh_set_tree_class(cmesh, gtree_id, tree_class) @@ -3684,7 +3758,7 @@ Set the class of a tree in the cmesh. It is not allowed to call this function af # Arguments * `cmesh`:\\[in,out\\] The cmesh to be updated. -* `gtree_id`:\\[in\\] The global number of the tree. +* `tree_id`:\\[in\\] The global number of the tree. * `tree_class`:\\[in\\] The element class of this tree. ### Prototype ```c @@ -3797,17 +3871,13 @@ end Insert a face-connection between two trees in a cmesh. -!!! note - - The orientation is defined as: Let my\\_face and other\\_face be the two face numbers of the connecting trees. We chose a main\\_face from them as follows: Either both trees have the same element class, then the face with the lower face number is the main\\_face or the trees belong to different classes in which case the face belonging to the tree with the lower class according to the ordering triangle < quad, hex < tet < prism < pyramid, is the main\\_face. Then face corner 0 of the main\\_face connects to a face corner k in the other face. The face orientation is defined as the number k. If the classes are equal and my\\_face == other\\_face, treating either of both faces as the main\\_face leads to the same result. See https://arxiv.org/pdf/1611.02929.pdf for more details. - # Arguments * `cmesh`:\\[in,out\\] The cmesh to be updated. -* `gtree1`:\\[in\\] The tree id of the first of the two trees. -* `gtree2`:\\[in\\] The tree id of the second of the two trees. +* `tree1`:\\[in\\] The tree id of the first of the two trees. +* `tree2`:\\[in\\] The tree id of the second of the two trees. * `face1`:\\[in\\] The face number of the first tree. * `face2`:\\[in\\] The face number of the second tree. -* `orientation`:\\[in\\] Specify how face1 and face2 are oriented to each other +* `orientation`:\\[in\\] Specify how face1 and face2 are oriented to each other TODO: orientation needs to be carefully defined for all element classes. TODO: document orientation ### Prototype ```c void t8_cmesh_set_join (t8_cmesh_t cmesh, t8_gloidx_t gtree1, t8_gloidx_t gtree2, int face1, int face2, int orientation); @@ -3949,19 +4019,6 @@ end """ t8_cmesh_save(cmesh, fileprefix) -Save the cmesh to a file with the given fileprefix. - -!!! note - - IMPORTANT: Currently, this functionality is deactivated, because it is outdated. Calling it will thus result in an error. - -!!! note - - So far, it was only legal to save cmeshes that use the linear geometry. - -# Arguments -* `cmesh`:\\[in\\] The cmesh to save. -* `fileprefix`:\\[in\\] The prefix of the file to save the cmesh to. ### Prototype ```c int t8_cmesh_save (t8_cmesh_t cmesh, const char *fileprefix); @@ -3983,6 +4040,29 @@ function t8_cmesh_load(filename, comm) @ccall libt8.t8_cmesh_load(filename::Cstring, comm::MPI_Comm)::t8_cmesh_t end +""" + t8_load_mode + +This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data. + +| Enumerator | Note | +| :----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| T8\\_LOAD\\_SIMPLE | In simple mode, the first n processes load the file | +| T8\\_LOAD\\_BGQ | In BGQ mode, the file is loaded on n nodes and from one process of each node. This needs MPI Version 3.1 or higher. | +| T8\\_LOAD\\_STRIDE | Every n-th process loads a file. Handle with care, we introduce it, since on Juqueen MPI-3 was not available. The parameter n has to be passed as an extra parameter. # See also [`t8_cmesh_load_and_distribute`](@ref) | +| T8\\_LOAD\\_COUNT | | +""" +@cenum t8_load_mode::UInt32 begin + T8_LOAD_FIRST = 0 + T8_LOAD_SIMPLE = 0 + T8_LOAD_BGQ = 1 + T8_LOAD_STRIDE = 2 + T8_LOAD_COUNT = 3 +end + +"""This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data.""" +const t8_load_mode_t = t8_load_mode + """ t8_cmesh_load_and_distribute(fileprefix, num_files, comm, mode, procs_per_node) @@ -4252,7 +4332,7 @@ Return the eclass of a given local tree. TODO: Should we refer to indices or con # Arguments * `cmesh`:\\[in\\] The cmesh to be considered. -* `ltree_id`:\\[in\\] The local id of the tree whose eclass will be returned. +* `tree_id`:\\[in\\] The local id of the tree whose eclass will be returned. # Returns The eclass of the given tree. TODO: Call tree ids ltree\\_id or gtree\\_id etc. instead of tree\\_id. *cmesh* must be committed before calling this function. ### Prototype @@ -4291,7 +4371,7 @@ Return the eclass of a given local ghost. TODO: Should we refer to indices or co # Arguments * `cmesh`:\\[in\\] The cmesh to be considered. -* `lghost_id`:\\[in\\] The local id of the ghost whose eclass will be returned. 0 <= *tree_id* < cmesh.num\\_ghosts. +* `ghost_id`:\\[in\\] The local id of the ghost whose eclass will be returned. 0 <= *tree_id* < cmesh.num\\_ghosts. # Returns The eclass of the given ghost. *cmesh* must be committed before calling this function. ### Prototype @@ -4377,31 +4457,11 @@ function t8_cmesh_get_face_neighbor(cmesh, ltreeid, face, dual_face, orientation end """ - t8_cmesh_get_tree_face_neighbor_eclass(cmesh, ltreeid, face) + t8_cmesh_print_profile(cmesh) -Given a local tree id (of a local tree or ghost tree) and a face compute the eclass of the tree's face neighbor. - -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `ltreeid`:\\[in\\] The local id of a tree or a ghost. -* `face`:\\[in\\] A face number of the tree/ghost. -# Returns -The eclass of a neighbor tree of *ltreeid* across *face*. T8\\_ECLASS\\_INVALID if no neighbor exists. -### Prototype -```c -t8_eclass_t t8_cmesh_get_tree_face_neighbor_eclass (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid, const int face); -``` -""" -function t8_cmesh_get_tree_face_neighbor_eclass(cmesh, ltreeid, face) - @ccall libt8.t8_cmesh_get_tree_face_neighbor_eclass(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t, face::Cint)::t8_eclass_t -end - -""" - t8_cmesh_print_profile(cmesh) - -Print the collected statistics from a cmesh profile. - -*cmesh* must be committed before calling this function. +Print the collected statistics from a cmesh profile. + +*cmesh* must be committed before calling this function. # Arguments * `cmesh`:\\[in\\] The cmesh. @@ -4449,7 +4509,7 @@ Return the attribute pointer of a tree. * `cmesh`:\\[in\\] The cmesh. * `package_id`:\\[in\\] The identifier of a valid software package. * `key`:\\[in\\] A key used to identify the attribute under all attributes of this tree with the same *package_id*. -* `ltree_id`:\\[in\\] The local number of the tree. +* `tree_id`:\\[in\\] The local number of the tree. # Returns The attribute pointer of the tree *ltree_id* or NULL if the attribute is not found. # See also @@ -4482,7 +4542,7 @@ Return the attribute pointer of a tree for a gloidx\\_t array. * `package_id`:\\[in\\] The identifier of a valid software package. * `key`:\\[in\\] A key used to identify the attribute under all attributes of this tree with the same *package_id*. * `ltree_id`:\\[in\\] The local number of the tree. -* `data_count`:\\[in\\] The number of entries in the array that are requested. This must be smaller or equal to the *data_count* parameter of the corresponding call to t8_cmesh_set_attribute_gloidx_array +* `data_count`:\\[in\\] The number of entries in the array that are requested. This must be smaller or equal to the *data_count* parameter of the corresponding call to t8_cmesh_set_attribute_gloidx_array # Returns The attribute pointer of the tree *ltree_id* or NULL if the attribute is not found. # See also @@ -4516,38 +4576,26 @@ function t8_cmesh_get_partition_table(cmesh) end """ - t8_cmesh_uniform_bounds_equal_element_count(cmesh, level, tree_scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) + t8_cmesh_uniform_bounds(cmesh, level, ts, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) Calculate the section of a uniform forest for the current rank. # Arguments * `cmesh`:\\[in\\] The cmesh to be considered. * `level`:\\[in\\] The uniform refinement level to be created. -* `tree_scheme`:\\[in\\] The element scheme for which to compute the bounds. +* `ts`:\\[in\\] The element scheme for which to compute the bounds. * `first_local_tree`:\\[out\\] The first tree that contains elements belonging to the calling processor. -* `child_in_tree_begin`:\\[out\\] The tree-local index of the first element belonging to the calling processor. Not computed if NULL. +* `child_in_tree_begin`:\\[out\\] The global index of the first element belonging to the calling processor. Not computed if NULL. * `last_local_tree`:\\[out\\] The last tree that contains elements belonging to the calling processor. -* `child_in_tree_end`:\\[out\\] The tree-local index of the first element that does not belonging to the calling processor anymore. Not computed if NULL. -* `first_tree_shared`:\\[out\\] If not NULL, 1 or 0 is stored here depending on whether *first_local_tree* is the same as *last_local_tree* on the previous process. *cmesh* must be committed before calling this function. -### Prototype -```c -void t8_cmesh_uniform_bounds_equal_element_count (t8_cmesh_t cmesh, const int level, const t8_scheme_c *tree_scheme, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared); -``` -""" -function t8_cmesh_uniform_bounds_equal_element_count(cmesh, level, tree_scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) - @ccall libt8.t8_cmesh_uniform_bounds_equal_element_count(cmesh::t8_cmesh_t, level::Cint, tree_scheme::Ptr{t8_scheme_c}, first_local_tree::Ptr{t8_gloidx_t}, child_in_tree_begin::Ptr{t8_gloidx_t}, last_local_tree::Ptr{t8_gloidx_t}, child_in_tree_end::Ptr{t8_gloidx_t}, first_tree_shared::Ptr{Int8})::Cvoid -end - -""" - t8_cmesh_uniform_bounds_for_irregular_refinement(cmesh, level, scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared, comm) - +* `child_in_tree_end`:\\[out\\] The global index of the first element that does not belonging to the calling processor anymore. Not computed if NULL. +* `first_tree_shared`:\\[out\\] If not NULL, 1 or 0 is stored here depending on whether *first_local_tree* is the same as *last_local_tree* on the next process. *cmesh* must be committed before calling this function. * ### Prototype ```c -void t8_cmesh_uniform_bounds_for_irregular_refinement (const t8_cmesh_t cmesh, const int level, const t8_scheme_c *scheme, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared, sc_MPI_Comm comm); +void t8_cmesh_uniform_bounds (t8_cmesh_t cmesh, int level, const t8_scheme_cxx_t *ts, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared); ``` """ -function t8_cmesh_uniform_bounds_for_irregular_refinement(cmesh, level, scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared, comm) - @ccall libt8.t8_cmesh_uniform_bounds_for_irregular_refinement(cmesh::t8_cmesh_t, level::Cint, scheme::Ptr{t8_scheme_c}, first_local_tree::Ptr{t8_gloidx_t}, child_in_tree_begin::Ptr{t8_gloidx_t}, last_local_tree::Ptr{t8_gloidx_t}, child_in_tree_end::Ptr{t8_gloidx_t}, first_tree_shared::Ptr{Int8}, comm::MPI_Comm)::Cvoid +function t8_cmesh_uniform_bounds(cmesh, level, ts, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) + @ccall libt8.t8_cmesh_uniform_bounds(cmesh::t8_cmesh_t, level::Cint, ts::Ptr{t8_scheme_cxx_t}, first_local_tree::Ptr{t8_gloidx_t}, child_in_tree_begin::Ptr{t8_gloidx_t}, last_local_tree::Ptr{t8_gloidx_t}, child_in_tree_end::Ptr{t8_gloidx_t}, first_tree_shared::Ptr{Int8})::Cvoid end """ @@ -4589,6 +4637,7 @@ Verify that a coarse mesh has only one reference left and destroy it. This funct # Arguments * `pcmesh`:\\[in,out\\] This cmesh must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_cmesh_unref. +* `comm`:\\[in\\] A mpi communicator that is valid with *cmesh*. ### Prototype ```c void t8_cmesh_destroy (t8_cmesh_t *pcmesh); @@ -4598,6 +4647,18 @@ function t8_cmesh_destroy(pcmesh) @ccall libt8.t8_cmesh_destroy(pcmesh::Ptr{t8_cmesh_t})::Cvoid end +""" + t8_cmesh_new_testhybrid(comm) + +### Prototype +```c +t8_cmesh_t t8_cmesh_new_testhybrid (sc_MPI_Comm comm); +``` +""" +function t8_cmesh_new_testhybrid(comm) + @ccall libt8.t8_cmesh_new_testhybrid(comm::MPI_Comm)::t8_cmesh_t +end + """ t8_cmesh_coords_axb(coords_in, coords_out, num_vertices, alpha, b) @@ -4621,7 +4682,7 @@ end """ t8_cmesh_translate_coordinates(coords_in, coords_out, num_vertices, translate) -Compute y = x + translate on an array of doubles, interpreting each 3 as one vector x +Compute y = x + translate on an array of doubles, interpreting each 3 as one vector x # Arguments * `coords_in`:\\[in\\] The incoming coordinates of the vectors @@ -4664,11737 +4725,13000 @@ function t8_cmesh_debug_print_trees(cmesh, comm) end """ - t8_cmesh_get_local_bounding_box(cmesh, bounds) + t8_netcdf_variable_type -Compute the process local bounding box of the cmesh. The bounding box is stored in the array *bounds* in the following order: bounds[0] = x\\_min bounds[1] = x\\_max bounds[2] = y\\_min bounds[3] = y\\_max bounds[4] = z\\_min bounds[5] = z\\_max +This enumeration contains all possible netCDF variable datatypes (int, int64, double). -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `bounds`:\\[out\\] The bounding box of the cmesh. If the box is flat (for quads for example, z\\_min == z\\_max) -# Returns -True if the computation was successful, false if the cmesh is empty. -### Prototype -```c -int t8_cmesh_get_local_bounding_box (const t8_cmesh_t cmesh, double bounds[6]); -``` +| Enumerator | Note | +| :------------------- | :------------------------------------------------------------------- | +| T8\\_NETCDF\\_INT | Symbolizes netCDF variable datatype which holds 32-bit integer data | +| T8\\_NETCDF\\_INT64 | Symbolizes netCDF variable datatype which holds 64-bit integer data | +| T8\\_NETCDF\\_DOUBLE | Symbolizes netCDF variable datatype which holds double data | """ -function t8_cmesh_get_local_bounding_box(cmesh, bounds) - @ccall libt8.t8_cmesh_get_local_bounding_box(cmesh::t8_cmesh_t, bounds::Ptr{Cdouble})::Cint +@cenum t8_netcdf_variable_type::UInt32 begin + T8_NETCDF_INT = 0 + T8_NETCDF_INT64 = 1 + T8_NETCDF_DOUBLE = 2 +end + +"""This enumeration contains all possible netCDF variable datatypes (int, int64, double).""" +const t8_netcdf_variable_type_t = t8_netcdf_variable_type + +struct t8_netcdf_variable_t + variable_name::Cstring + variable_long_name::Cstring + variable_units::Cstring + datatype::t8_netcdf_variable_type_t + var_user_dimid::Cint + var_user_data::Ptr{sc_array_t} end """ - sc_io_read(mpifile, ptr, zcount, t, errmsg) + t8_cmesh_write_netcdf(cmesh, file_prefix, file_title, dim, num_extern_netcdf_vars, variables, comm) ### Prototype ```c -void sc_io_read (sc_MPI_File mpifile, void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); +void t8_cmesh_write_netcdf (t8_cmesh_t cmesh, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, t8_netcdf_variable_t *variables[], sc_MPI_Comm comm); ``` """ -function sc_io_read(mpifile, ptr, zcount, t, errmsg) - @ccall libsc.sc_io_read(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid +function t8_cmesh_write_netcdf(cmesh, file_prefix, file_title, dim, num_extern_netcdf_vars, variables, comm) + @ccall libt8.t8_cmesh_write_netcdf(cmesh::t8_cmesh_t, file_prefix::Cstring, file_title::Cstring, dim::Cint, num_extern_netcdf_vars::Cint, variables::Ptr{Ptr{t8_netcdf_variable_t}}, comm::MPI_Comm)::Cvoid +end + +struct t8_msh_file_node_t + index::t8_locidx_t + coordinates::NTuple{3, Cdouble} +end + +struct t8_msh_file_node_parametric_t + index::t8_locidx_t + coordinates::NTuple{3, Cdouble} + parameters::NTuple{2, Cdouble} + parametric::Cint + entity_dim::Cint + entity_tag::t8_locidx_t end """ - sc_io_write(mpifile, ptr, zcount, t, errmsg) + t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) ### Prototype ```c -void sc_io_write (sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); +t8_cmesh_t t8_cmesh_from_msh_file (const char *fileprefix, int partition, sc_MPI_Comm comm, int dim, int master, int use_cad_geometry); ``` """ -function sc_io_write(mpifile, ptr, zcount, t, errmsg) - @ccall libsc.sc_io_write(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid +function t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) + @ccall libt8.t8_cmesh_from_msh_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, dim::Cint, master::Cint, use_cad_geometry::Cint)::t8_cmesh_t end -"""Typedef for quadrant coordinates.""" -const p4est_qcoord_t = Int32 - -"""Typedef for counting topological entities (trees, tree vertices).""" -const p4est_topidx_t = Int32 - -"""Typedef for processor-local indexing of quadrants and nodes.""" -const p4est_locidx_t = Int32 +struct sc_stats + mpicomm::MPI_Comm + kv::Ptr{sc_keyvalue_t} + sarray::Ptr{sc_array_t} +end -"""Typedef for globally unique indexing of quadrants.""" -const p4est_gloidx_t = Int64 +"""The statistics container allows dynamically adding random variables.""" +const sc_statistics_t = sc_stats """ - sc_io_error_t + sc_statistics_has(stats, name) -Error values for io. +Returns true if the stats include a variable with the given name -| Enumerator | Note | -| :---------------------- | :--------------------------------------------------------------------------- | -| SC\\_IO\\_ERROR\\_NONE | The value of zero means no error. | -| SC\\_IO\\_ERROR\\_FATAL | The io object is now dysfunctional. | -| SC\\_IO\\_ERROR\\_AGAIN | Another io operation may resolve it. The function just returned was a noop. | +### Prototype +```c +int sc_statistics_has (sc_statistics_t * stats, const char *name); +``` """ -@cenum sc_io_error_t::Int32 begin - SC_IO_ERROR_NONE = 0 - SC_IO_ERROR_FATAL = -1 - SC_IO_ERROR_AGAIN = -2 +function sc_statistics_has(stats, name) + @ccall libsc.sc_statistics_has(stats::Ptr{sc_statistics_t}, name::Cstring)::Cint end """ - sc_io_mode_t + sc_statistics_add_empty(stats, name) -The I/O mode for writing using sc_io_sink. +Register a statistics variable by name and set its count to 0. This variable must not exist already. -| Enumerator | Note | -| :---------------------- | :--------------------------- | -| SC\\_IO\\_MODE\\_WRITE | Semantics as "w" in fopen. | -| SC\\_IO\\_MODE\\_APPEND | Semantics as "a" in fopen. | -| SC\\_IO\\_MODE\\_LAST | Invalid entry to close list | +### Prototype +```c +void sc_statistics_add_empty (sc_statistics_t * stats, const char *name); +``` """ -@cenum sc_io_mode_t::UInt32 begin - SC_IO_MODE_WRITE = 0 - SC_IO_MODE_APPEND = 1 - SC_IO_MODE_LAST = 2 +function sc_statistics_add_empty(stats, name) + @ccall libsc.sc_statistics_add_empty(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid end -""" - sc_io_encode_t - -Enum to specify encoding for sc_io_sink and sc_io_source. - -| Enumerator | Note | -| :---------------------- | :--------------------------- | -| SC\\_IO\\_ENCODE\\_NONE | No encoding | -| SC\\_IO\\_ENCODE\\_LAST | Invalid entry to close list | -""" -@cenum sc_io_encode_t::UInt32 begin - SC_IO_ENCODE_NONE = 0 - SC_IO_ENCODE_LAST = 1 +struct sc_flopinfo + seconds::Cdouble + cwtime::Cdouble + crtime::Cfloat + cptime::Cfloat + cflpops::Clonglong + iwtime::Cdouble + irtime::Cfloat + iptime::Cfloat + iflpops::Clonglong + mflops::Cfloat + use_papi::Cint end +const sc_flopinfo_t = sc_flopinfo + """ - sc_io_type_t + sc_flops_snap(fi, snapshot) -The type of I/O operation sc_io_sink and sc_io_source. +Call [`sc_flops_count`](@ref) (fi) and copies fi into snapshot. -| Enumerator | Note | -| :------------------------ | :------------------------------- | -| SC\\_IO\\_TYPE\\_BUFFER | Write to a buffer | -| SC\\_IO\\_TYPE\\_FILENAME | Write to a file to be opened | -| SC\\_IO\\_TYPE\\_FILEFILE | Write to an already opened file | -| SC\\_IO\\_TYPE\\_LAST | Invalid entry to close list | +# Arguments +* `fi`:\\[in,out\\] Members will be updated. +* `snapshot`:\\[out\\] On output is a copy of fi. +### Prototype +```c +void sc_flops_snap (sc_flopinfo_t * fi, sc_flopinfo_t * snapshot); +``` """ -@cenum sc_io_type_t::UInt32 begin - SC_IO_TYPE_BUFFER = 0 - SC_IO_TYPE_FILENAME = 1 - SC_IO_TYPE_FILEFILE = 2 - SC_IO_TYPE_LAST = 3 +function sc_flops_snap(fi, snapshot) + @ccall libsc.sc_flops_snap(fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t})::Cvoid end """ - sc_io_sink + sc_flops_shot(fi, snapshot) -A generic data sink. +Call [`sc_flops_count`](@ref) (fi) and override snapshot interval timings with the differences since the previous call to [`sc_flops_snap`](@ref). The interval mflop rate is computed by iflpops / 1e6 / irtime. The cumulative timings in snapshot are copied form fi. -| Field | Note | -| :------------- | :---------------------------------------------------- | -| iotype | type of the I/O operation | -| mode | write semantics | -| encode | encoding of data | -| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | -| buffer\\_bytes | distinguish from array elements | -| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | -| bytes\\_in | input bytes count | -| bytes\\_out | written bytes count | -| is\\_eof | Have we reached the end of file? | +# Arguments +* `fi`:\\[in,out\\] Members will be updated. +* `snapshot`:\\[in,out\\] Interval timings measured since [`sc_flops_snap`](@ref). +### Prototype +```c +void sc_flops_shot (sc_flopinfo_t * fi, sc_flopinfo_t * snapshot); +``` """ -struct sc_io_sink - iotype::sc_io_type_t - mode::sc_io_mode_t - encode::sc_io_encode_t - buffer::Ptr{sc_array_t} - buffer_bytes::Csize_t - file::Ptr{Libc.FILE} - bytes_in::Csize_t - bytes_out::Csize_t - is_eof::Cint +function sc_flops_shot(fi, snapshot) + @ccall libsc.sc_flops_shot(fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t})::Cvoid end -"""A generic data sink.""" -const sc_io_sink_t = sc_io_sink - """ - sc_io_source + sc_statistics_accumulate(stats, name, value) -A generic data source. +Add an instance of a statistics variable, see [`sc_stats_accumulate`](@ref) The variable must previously be added with [`sc_statistics_add_empty`](@ref). -| Field | Note | -| :-------------- | :---------------------------------------------------- | -| iotype | type of the I/O operation | -| encode | encoding of data | -| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | -| buffer\\_bytes | distinguish from array elements | -| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | -| bytes\\_in | input bytes count | -| bytes\\_out | read bytes count | -| is\\_eof | Have we reached the end of file? | -| mirror | if activated, a sink to store the data | -| mirror\\_buffer | if activated, the buffer for the mirror | +### Prototype +```c +void sc_statistics_accumulate (sc_statistics_t * stats, const char *name, double value); +``` """ -struct sc_io_source - iotype::sc_io_type_t - encode::sc_io_encode_t - buffer::Ptr{sc_array_t} - buffer_bytes::Csize_t - file::Ptr{Libc.FILE} - bytes_in::Csize_t - bytes_out::Csize_t - is_eof::Cint - mirror::Ptr{sc_io_sink_t} - mirror_buffer::Ptr{sc_array_t} +function sc_statistics_accumulate(stats, name, value) + @ccall libsc.sc_statistics_accumulate(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid end -"""A generic data source.""" -const sc_io_source_t = sc_io_source - """ - sc_io_open_mode_t + sc_flops_papi(rtime, ptime, flpops, mflops) -Open modes for sc_io_open +Calls PAPI\\_flops. Aborts on PAPI error. The first call sets up the performance counters. Subsequent calls return cumulative real and process times, cumulative floating point operations and the flop rate since the last call. This is a compatibility wrapper: users should only need to use the [`sc_flopinfo_t`](@ref) interface functions below. -| Enumerator | Note | -| :----------------------- | :------------------------------------------------------------------------------------------------------------------ | -| SC\\_IO\\_READ | open a file in read-only mode | -| SC\\_IO\\_WRITE\\_CREATE | open a file in write-only mode; if the file exists, the file will be truncated to length zero and then overwritten | -| SC\\_IO\\_WRITE\\_APPEND | append to an already existing file | +### Prototype +```c +void sc_flops_papi (float *rtime, float *ptime, long long *flpops, float *mflops); +``` """ -@cenum sc_io_open_mode_t::UInt32 begin - SC_IO_READ = 0 - SC_IO_WRITE_CREATE = 1 - SC_IO_WRITE_APPEND = 2 +function sc_flops_papi(rtime, ptime, flpops, mflops) + @ccall libsc.sc_flops_papi(rtime::Ptr{Cfloat}, ptime::Ptr{Cfloat}, flpops::Ptr{Clonglong}, mflops::Ptr{Cfloat})::Cvoid end -# automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_io_sink_new(iotype, iomode, ioencode, va_list...) - :(@ccall(libsc.sc_io_sink_new(iotype::Cint, iomode::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_sink_t})) - end - """ - sc_io_sink_destroy(sink) + sc_flops_start(fi) -Free data sink. Calls [`sc_io_sink_complete`](@ref) and discards the final counts. Errors from complete lead to SC\\_IO\\_ERROR\\_FATAL returned from this function. Call [`sc_io_sink_complete`](@ref) yourself if bytes\\_out is of interest. +Prepare [`sc_flopinfo_t`](@ref) structure and start flop counters. Must only be called once during the program run. This function calls [`sc_flops_papi`](@ref). # Arguments -* `sink`:\\[in,out\\] The sink object to complete and free. -# Returns -0 on success, nonzero on error. +* `fi`:\\[out\\] Members will be initialized. ### Prototype ```c -int sc_io_sink_destroy (sc_io_sink_t * sink); +void sc_flops_start (sc_flopinfo_t * fi); ``` """ -function sc_io_sink_destroy(sink) - @ccall libsc.sc_io_sink_destroy(sink::Ptr{sc_io_sink_t})::Cint +function sc_flops_start(fi) + @ccall libsc.sc_flops_start(fi::Ptr{sc_flopinfo_t})::Cvoid end """ - sc_io_sink_destroy_null(sink) + sc_flops_start_nopapi(fi) -Free data sink and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_sink_destroy. +Prepare [`sc_flopinfo_t`](@ref) structure and ignore the flop counters. This [`sc_flopinfo_t`](@ref) does not call PAPI\\_flops() in this function or in [`sc_flops_count`](@ref)(). # Arguments -* `sink`:\\[in,out\\] Non-NULL pointer to sink pointer. The sink pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_sink, which is passed to sc_io_sink_destroy, and the sink pointer is set to NULL afterwards. -# Returns -0 on success, nonzero on error. +* `fi`:\\[out\\] Members will be initialized. ### Prototype ```c -int sc_io_sink_destroy_null (sc_io_sink_t ** sink); +void sc_flops_start_nopapi (sc_flopinfo_t * fi); ``` """ -function sc_io_sink_destroy_null(sink) - @ccall libsc.sc_io_sink_destroy_null(sink::Ptr{Ptr{sc_io_sink_t}})::Cint +function sc_flops_start_nopapi(fi) + @ccall libsc.sc_flops_start_nopapi(fi::Ptr{sc_flopinfo_t})::Cvoid end """ - sc_io_sink_write(sink, data, bytes_avail) + sc_flops_count(fi) -Write data to a sink. Data may be buffered and sunk in a later call. The internal counters sink->bytes\\_in and sink->bytes\\_out are updated. +Update [`sc_flopinfo_t`](@ref) structure with current measurement. Must only be called after [`sc_flops_start`](@ref). Can be called any number of times. This function calls [`sc_flops_papi`](@ref). # Arguments -* `sink`:\\[in,out\\] The sink object to write to. -* `data`:\\[in\\] Data passed into sink must be non-NULL. -* `bytes_avail`:\\[in\\] Number of data bytes passed in. -# Returns -0 on success, nonzero on error. +* `fi`:\\[in,out\\] Members will be updated. ### Prototype ```c -int sc_io_sink_write (sc_io_sink_t * sink, const void *data, size_t bytes_avail); +void sc_flops_count (sc_flopinfo_t * fi); ``` """ -function sc_io_sink_write(sink, data, bytes_avail) - @ccall libsc.sc_io_sink_write(sink::Ptr{sc_io_sink_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t)::Cint +function sc_flops_count(fi) + @ccall libsc.sc_flops_count(fi::Ptr{sc_flopinfo_t})::Cvoid end +# automatic type deduction for variadic arguments may not be what you want, please use with caution +@generated function sc_flops_shotv(fi, va_list...) + :(@ccall(libsc.sc_flops_shotv(fi::Ptr{sc_flopinfo_t}; $(to_c_type_pairs(va_list)...))::Cvoid)) + end + """ - sc_io_sink_complete(sink, bytes_in, bytes_out) + sc_keyvalue_entry_type_t -Flush all buffered output data to sink. This function may return SC\\_IO\\_ERROR\\_AGAIN if another write is required. Currently this may happen if BUFFER requires an integer multiple of bytes. If successful, the updated value of bytes read and written is returned in bytes\\_in/out, and the sink status is reset as if the sink had just been created. In particular, the bytes counters are reset to zero. The internal state of the sink is not changed otherwise. It is legal to continue writing to the sink hereafter. The sink actions taken depend on its type. BUFFER, FILEFILE: none. FILENAME: call fclose on sink->file. +The values can have different types. -# Arguments -* `sink`:\\[in,out\\] The sink object to write to. -* `bytes_in`:\\[in,out\\] Bytes received since the last new or complete call. May be NULL. -* `bytes_out`:\\[in,out\\] Bytes written since the last new or complete call. May be NULL. -# Returns -0 if completed, nonzero on error. -### Prototype -```c -int sc_io_sink_complete (sc_io_sink_t * sink, size_t *bytes_in, size_t *bytes_out); -``` +| Enumerator | Note | +| :------------------------------ | :------------------------------------------ | +| SC\\_KEYVALUE\\_ENTRY\\_NONE | Designate an invalid situation. | +| SC\\_KEYVALUE\\_ENTRY\\_INT | Used for values of type int. | +| SC\\_KEYVALUE\\_ENTRY\\_DOUBLE | Used for values of type double. | +| SC\\_KEYVALUE\\_ENTRY\\_STRING | Used for values of type const char *. | +| SC\\_KEYVALUE\\_ENTRY\\_POINTER | Used for values of anonymous pointer type. | """ -function sc_io_sink_complete(sink, bytes_in, bytes_out) - @ccall libsc.sc_io_sink_complete(sink::Ptr{sc_io_sink_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint +@cenum sc_keyvalue_entry_type_t::UInt32 begin + SC_KEYVALUE_ENTRY_NONE = 0 + SC_KEYVALUE_ENTRY_INT = 1 + SC_KEYVALUE_ENTRY_DOUBLE = 2 + SC_KEYVALUE_ENTRY_STRING = 3 + SC_KEYVALUE_ENTRY_POINTER = 4 end +mutable struct sc_keyvalue end + +"""The key-value container is an opaque structure.""" +const sc_keyvalue_t = sc_keyvalue + +# no prototype is found for this function at sc_keyvalue.h:54:21, please use with caution """ - sc_io_sink_align(sink, bytes_align) + sc_keyvalue_new() -Align sink to a byte boundary by writing zeros. +Create a new key-value container. -# Arguments -* `sink`:\\[in,out\\] The sink object to align. -* `bytes_align`:\\[in\\] Byte boundary. # Returns -0 on success, nonzero on error. +The container is ready to use. ### Prototype ```c -int sc_io_sink_align (sc_io_sink_t * sink, size_t bytes_align); +sc_keyvalue_t *sc_keyvalue_new (); ``` """ -function sc_io_sink_align(sink, bytes_align) - @ccall libsc.sc_io_sink_align(sink::Ptr{sc_io_sink_t}, bytes_align::Csize_t)::Cint +function sc_keyvalue_new() + @ccall libsc.sc_keyvalue_new()::Ptr{sc_keyvalue_t} end # automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_io_source_new(iotype, ioencode, va_list...) - :(@ccall(libsc.sc_io_source_new(iotype::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_source_t})) +@generated function sc_keyvalue_newf(dummy, va_list...) + :(@ccall(libsc.sc_keyvalue_newf(dummy::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_keyvalue_t})) end """ - sc_io_source_destroy(source) + sc_keyvalue_destroy(kv) -Free data source. Calls [`sc_io_source_complete`](@ref) and requires it to return no error. This is to avoid discarding buffered data that has not been passed to read. +Free a key-value container and all internal memory for key storage. # Arguments -* `source`:\\[in,out\\] The source object to free. -# Returns -0 on success. Nonzero if an error is encountered or is\\_complete returns one. +* `kv`:\\[in,out\\] The key-value container is invalidated by this call. ### Prototype ```c -int sc_io_source_destroy (sc_io_source_t * source); +void sc_keyvalue_destroy (sc_keyvalue_t * kv); ``` """ -function sc_io_source_destroy(source) - @ccall libsc.sc_io_source_destroy(source::Ptr{sc_io_source_t})::Cint +function sc_keyvalue_destroy(kv) + @ccall libsc.sc_keyvalue_destroy(kv::Ptr{sc_keyvalue_t})::Cvoid end """ - sc_io_source_destroy_null(source) + sc_keyvalue_exists(kv, key) -Free data source and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_source_destroy. +Routine to check existence of an entry. # Arguments -* `source`:\\[in,out\\] Non-NULL pointer to source pointer. The source pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_source, which is passed to sc_io_source_destroy, and the source pointer is set to NULL afterwards. +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key to query. # Returns -0 on success, nonzero on error. +The entry's type if found and SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. ### Prototype ```c -int sc_io_source_destroy_null (sc_io_source_t ** source); +sc_keyvalue_entry_type_t sc_keyvalue_exists (sc_keyvalue_t * kv, const char *key); ``` """ -function sc_io_source_destroy_null(source) - @ccall libsc.sc_io_source_destroy_null(source::Ptr{Ptr{sc_io_source_t}})::Cint +function sc_keyvalue_exists(kv, key) + @ccall libsc.sc_keyvalue_exists(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t end """ - sc_io_source_read(source, data, bytes_avail, bytes_out) + sc_keyvalue_unset(kv, key) -Read data from a source. The internal counters source->bytes\\_in and source->bytes\\_out are updated. Data is read until the data buffer has not enough room anymore, or source becomes empty. It is possible that data already read internally remains in the source object for the next call. Call [`sc_io_source_complete`](@ref) and check its return value to find out. Returns an error if bytes\\_out is NULL and less than bytes\\_avail are read. +Routine to remove an entry. # Arguments -* `source`:\\[in,out\\] The source object to read from. -* `data`:\\[in\\] Data buffer for reading from source. If NULL the output data will be ignored and we seek forward in the input. -* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. -* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. If this condition is not met, return an error. +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key to remove if it exists. # Returns -0 on success, nonzero on error. +The entry's type if found and removed, SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. ### Prototype ```c -int sc_io_source_read (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); +sc_keyvalue_entry_type_t sc_keyvalue_unset (sc_keyvalue_t * kv, const char *key); ``` """ -function sc_io_source_read(source, data, bytes_avail, bytes_out) - @ccall libsc.sc_io_source_read(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint +function sc_keyvalue_unset(kv, key) + @ccall libsc.sc_keyvalue_unset(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t end """ - sc_io_source_complete(source, bytes_in, bytes_out) + sc_keyvalue_get_int(kv, key, dvalue) -Determine whether all data buffered from source has been returned by read. If it returns SC\\_IO\\_ERROR\\_AGAIN, another [`sc_io_source_read`](@ref) is required. If the call returns no error, the internal counters source->bytes\\_in and source->bytes\\_out are returned to the caller if requested, and reset to 0. The internal state of the source is not changed otherwise. It is legal to continue reading from the source hereafter. +Routines to retrieve an integer value by its key. This function asserts that the key, if existing, points to the correct type. # Arguments -* `source`:\\[in,out\\] The source object to read from. -* `bytes_in`:\\[in,out\\] If not NULL and true is returned, the total size of the data sourced. -* `bytes_out`:\\[in,out\\] If not NULL and true is returned, total bytes passed out by source\\_read. +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. # Returns -SC\\_IO\\_ERROR\\_AGAIN if buffered data remaining. Otherwise return ERROR\\_NONE and reset counters. +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -int sc_io_source_complete (sc_io_source_t * source, size_t *bytes_in, size_t *bytes_out); +int sc_keyvalue_get_int (sc_keyvalue_t * kv, const char *key, int dvalue); ``` """ -function sc_io_source_complete(source, bytes_in, bytes_out) - @ccall libsc.sc_io_source_complete(source::Ptr{sc_io_source_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint +function sc_keyvalue_get_int(kv, key, dvalue) + @ccall libsc.sc_keyvalue_get_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cint)::Cint end """ - sc_io_source_align(source, bytes_align) + sc_keyvalue_get_double(kv, key, dvalue) -Align source to a byte boundary by skipping. +Retrieve a double value by its key. This function asserts that the key, if existing, points to the correct type. # Arguments -* `source`:\\[in,out\\] The source object to align. -* `bytes_align`:\\[in\\] Byte boundary. +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. # Returns -0 on success, nonzero on error. +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -int sc_io_source_align (sc_io_source_t * source, size_t bytes_align); +double sc_keyvalue_get_double (sc_keyvalue_t * kv, const char *key, double dvalue); ``` """ -function sc_io_source_align(source, bytes_align) - @ccall libsc.sc_io_source_align(source::Ptr{sc_io_source_t}, bytes_align::Csize_t)::Cint +function sc_keyvalue_get_double(kv, key, dvalue) + @ccall libsc.sc_keyvalue_get_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cdouble)::Cdouble end """ - sc_io_source_activate_mirror(source) + sc_keyvalue_get_string(kv, key, dvalue) -Activate a buffer that mirrors (i.e., stores) the data that was read. +Retrieve a string value by its key. This function asserts that the key, if existing, points to the correct type. # Arguments -* `source`:\\[in,out\\] The source object to activate mirror in. +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. # Returns -0 on success, nonzero on error. +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -int sc_io_source_activate_mirror (sc_io_source_t * source); +const char *sc_keyvalue_get_string (sc_keyvalue_t * kv, const char *key, const char *dvalue); ``` """ -function sc_io_source_activate_mirror(source) - @ccall libsc.sc_io_source_activate_mirror(source::Ptr{sc_io_source_t})::Cint +function sc_keyvalue_get_string(kv, key, dvalue) + @ccall libsc.sc_keyvalue_get_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cstring)::Cstring end """ - sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) + sc_keyvalue_get_pointer(kv, key, dvalue) -Read data from the source's mirror. Same behaviour as [`sc_io_source_read`](@ref). +Retrieve a pointer value by its key. This function asserts that the key, if existing, points to the correct type. # Arguments -* `source`:\\[in,out\\] The source object to read mirror data from. -* `data`:\\[in\\] Data buffer for reading from source's mirror. If NULL the output data will be thrown away. -* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. -* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. # Returns -0 on success, nonzero on error. +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -int sc_io_source_read_mirror (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); +void *sc_keyvalue_get_pointer (sc_keyvalue_t * kv, const char *key, void *dvalue); ``` """ -function sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) - @ccall libsc.sc_io_source_read_mirror(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint +function sc_keyvalue_get_pointer(kv, key, dvalue) + @ccall libsc.sc_keyvalue_get_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Ptr{Cvoid})::Ptr{Cvoid} end """ - sc_io_file_save(filename, buffer) + sc_keyvalue_get_int_check(kv, key, status) -Save a buffer to a file in one call. This function performs error checking and always returns cleanly. +Query an integer key with error checking. We check whether the key is not found or it is of the wrong type. A default value to be returned on error can be passed in as *status. If status is NULL, then the result on error is undefined. # Arguments -* `filename`:\\[in\\] Name of the file to save. -* `buffer`:\\[in\\] An array of element size 1 and arbitrary contents, which are written to the file. +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key string. +* `status`:\\[in,out\\] If not NULL, set to 0 if there is no error, 1 if the key is not found, 2 if a value is found but its type is not integer, and return the input value *status on error. # Returns -0 on success, -1 on error. +On error we return *status if status is not NULL, and else an undefined value backed by an assertion. Without error, return the result of the lookup. ### Prototype ```c -int sc_io_file_save (const char *filename, sc_array_t * buffer); +int sc_keyvalue_get_int_check (sc_keyvalue_t * kv, const char *key, int *status); ``` """ -function sc_io_file_save(filename, buffer) - @ccall libsc.sc_io_file_save(filename::Cstring, buffer::Ptr{sc_array_t})::Cint +function sc_keyvalue_get_int_check(kv, key, status) + @ccall libsc.sc_keyvalue_get_int_check(kv::Ptr{sc_keyvalue_t}, key::Cstring, status::Ptr{Cint})::Cint end """ - sc_io_file_load(filename, buffer) + sc_keyvalue_set_int(kv, key, newvalue) -Read a file into a buffer in one call. This function performs error checking and always returns cleanly. +Routine to set an integer value for a given key. # Arguments -* `filename`:\\[in\\] Name of the file to load. -* `buffer`:\\[in,out\\] On input, an array (not a view) of element size 1 and arbitrary contents. On output and success, the complete file contents. On error, contents are undefined. -# Returns -0 on success, -1 on error. +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type integer. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -int sc_io_file_load (const char *filename, sc_array_t * buffer); +void sc_keyvalue_set_int (sc_keyvalue_t * kv, const char *key, int newvalue); ``` """ -function sc_io_file_load(filename, buffer) - @ccall libsc.sc_io_file_load(filename::Cstring, buffer::Ptr{sc_array_t})::Cint +function sc_keyvalue_set_int(kv, key, newvalue) + @ccall libsc.sc_keyvalue_set_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cint)::Cvoid end """ - sc_io_encode(data, out) - -Encode a block of arbitrary data with the default sc\\_io format. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. - -Currently this function calls sc_io_encode_zlib with compression level Z\\_BEST\\_COMPRESSION (subject to change). Without zlib configured that function works uncompressed. + sc_keyvalue_set_double(kv, key, newvalue) -The encoding method and input data size can be retrieved, optionally, from the encoded data by sc_io_decode_info. This function decodes the method as a character, which is 'z' for sc_io_encode_zlib. We reserve the characters A-C, d-z indefinitely. +Routine to set a double value for a given key. # Arguments -* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. -* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type double. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -void sc_io_encode (sc_array_t *data, sc_array_t *out); +void sc_keyvalue_set_double (sc_keyvalue_t * kv, const char *key, double newvalue); ``` """ -function sc_io_encode(data, out) - @ccall libsc.sc_io_encode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t})::Cvoid +function sc_keyvalue_set_double(kv, key, newvalue) + @ccall libsc.sc_keyvalue_set_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cdouble)::Cvoid end """ - sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) - -Encode a block of arbitrary data, compressed, into an ASCII string. This is a two-stage process: zlib compress and then encode to base 64. The output is a NUL-terminated string of printable characters. - -We first compress the data into the zlib deflate format (RFC 1951). The compressor must use no preset dictionary (this is the default). If zlib is detected on configuration, we compress with the given level. If zlib is not detected, we write data equivalent to Z\\_NO\\_COMPRESSION. The status of zlib detection can be queried at compile time using #ifdef [`SC_HAVE_ZLIB`](@ref) or at run time using sc_have_zlib. Both types of result are readable by a standard zlib uncompress call. - -Secondly, we process the input data size as an 8-byte big-endian number, then the letter 'z', and then the zlib compressed data, concatenated, with a base 64 encoder. We break lines after 76 code characters. Each line break consists of two configurable but arbitrary bytes. The line breaks are considered part of the output data specification. The last line is terminated with the same line break and then a NUL. + sc_keyvalue_set_string(kv, key, newvalue) -This routine can work in place or write to an output array. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. +Routine to set a string value for a given key. # Arguments -* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. -* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. -* `zlib_compression_level`:\\[in\\] Compression level between 0 (no compression) and 9 (best compression). The value -1 indicates some default level. -* `line_break_character`:\\[in\\] This character is arbitrary and specifies the first of two line break bytes. The second byte is always ''. +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type string. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -void sc_io_encode_zlib (sc_array_t *data, sc_array_t *out, int zlib_compression_level, int line_break_character); +void sc_keyvalue_set_string (sc_keyvalue_t * kv, const char *key, const char *newvalue); ``` """ -function sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) - @ccall libsc.sc_io_encode_zlib(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, zlib_compression_level::Cint, line_break_character::Cint)::Cvoid +function sc_keyvalue_set_string(kv, key, newvalue) + @ccall libsc.sc_keyvalue_set_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cstring)::Cvoid end """ - sc_io_decode_info(data, original_size, format_char, re) - -Decode length and format of original input from encoded data. We expect at least 12 bytes of the format produced by sc_io_encode. No matter how much data has been encoded by it, this much is available. We decode the original data size and the character indicating the format. + sc_keyvalue_set_pointer(kv, key, newvalue) -This function does not require zlib. It works with any well-defined data. - -Note that this function is not required before sc_io_decode. Calling this function on any result produced by sc_io_encode will succeed and report a legal format. This function cannot crash. +Routine to set a pointer value for a given key. # Arguments -* `data`:\\[in\\] This must be an array with element size 1. If it contains less than 12 code bytes we error out. It its first 12 bytes do not base 64 decode to 9 bytes we error out. We generally ignore the remaining data. -* `original_size`:\\[out\\] If not NULL and we do not error out, set to the original size as encoded in the data. -* `format_char`:\\[out\\] If not NULL and we do not error out, the ninth character of decoded data indicating the format. -* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. -# Returns -0 on success, negative value on error. +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type pointer. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -int sc_io_decode_info (sc_array_t *data, size_t *original_size, char *format_char, void *re); +void sc_keyvalue_set_pointer (sc_keyvalue_t * kv, const char *key, void *newvalue); ``` """ -function sc_io_decode_info(data, original_size, format_char, re) - @ccall libsc.sc_io_decode_info(data::Ptr{sc_array_t}, original_size::Ptr{Csize_t}, format_char::Cstring, re::Ptr{Cvoid})::Cint +function sc_keyvalue_set_pointer(kv, key, newvalue) + @ccall libsc.sc_keyvalue_set_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Ptr{Cvoid})::Cvoid end +# typedef int ( * sc_keyvalue_foreach_t ) ( const char * key , const sc_keyvalue_entry_type_t type , void * entry , const void * u ) """ - sc_io_decode(data, out, max_original_size, re) - -Decode a block of base 64 encoded compressed data. The base 64 data must contain two arbitrary bytes after every 76 code characters and also at the end of the last line if it is short, and then a final NUL character. This function does not require zlib but benefits for speed. - -This is a two-stage process: we decode the input from base 64 first. Then we extract the 8-byte big-endian original data size, the character 'z', and execute a zlib decompression on the remaining decoded data. This function detects malformed input by erroring out. - -If we should add another format in the future, the format character may be something else than 'z', as permitted by our specification. To this end, we reserve the characters A-C and d-z indefinitely. - -Any error condition is indicated by a negative return value. Possible causes for error are: +Function to call on every key value pair -- the input data string is not NUL-terminated - the first 12 characters of input do not decode properly - the input data is corrupt for decoding or decompression - the output data array has non-unit element size and the length of the output data is not divisible by the size - the output data would exceed the specified threshold - the output array is a view of insufficient length +# Arguments +* `key`:\\[in\\] The key for this pair +* `type`:\\[in\\] The type of entry +* `entry`:\\[in\\] Pointer to the entry +* `u`:\\[in\\] Arbitrary user data. +# Returns +Return true if the traversal should continue, false to stop. +""" +const sc_keyvalue_foreach_t = Ptr{Cvoid} -We also error out if the data requires a compression dictionary, which would be a violation of above encode format specification. +""" + sc_keyvalue_foreach(kv, fn, user_data) -The corresponding encode function is sc_io_encode. When passing an array as output, we resize it properly. This function cannot crash unless out of memory. +Iterate through all stored key-value pairs. # Arguments -* `data`:\\[in,out\\] If *out* is NULL, we work in place. In that case, output is written into this array after a suitable resize. Either way, we expect a NUL-terminated base 64 encoded string on input that has in turn been obtained by zlib compression. It must be in the exact format produced by sc_io_encode; please see documentation. The element size of the input array must be 1. -* `out`:\\[in,out\\] If not NULL, a valid array (may be a view). If NULL, the input array becomes the output. If the output array is a view and the output data larger than its view size, we error out. We expect commensurable element and data size and resize the output to fit exactly, which restores the original input passed to encoding. An output view array of matching size may be constructed using sc_io_decode_info. -* `max_original_size`:\\[in\\] If nonzero, this is the maximal data size that we will accept after uncompression. If exceeded, return a negative value. -* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. -# Returns -0 on success, negative on malformed input data or insufficient output space. +* `kv`:\\[in\\] Valid key-value container. +* `fn`:\\[in\\] Function to call on each key-value pair. +* `user_data`:\\[in,out\\] This pointer is passed through to **fn**. ### Prototype ```c -int sc_io_decode (sc_array_t *data, sc_array_t *out, size_t max_original_size, void *re); +void sc_keyvalue_foreach (sc_keyvalue_t * kv, sc_keyvalue_foreach_t fn, void *user_data); ``` """ -function sc_io_decode(data, out, max_original_size, re) - @ccall libsc.sc_io_decode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, max_original_size::Csize_t, re::Ptr{Cvoid})::Cint +function sc_keyvalue_foreach(kv, fn, user_data) + @ccall libsc.sc_keyvalue_foreach(kv::Ptr{sc_keyvalue_t}, fn::sc_keyvalue_foreach_t, user_data::Ptr{Cvoid})::Cvoid end """ - sc_vtk_write_binary(vtkfile, numeric_data, byte_length) + sc_statinfo -This function writes numeric binary data in VTK base64 encoding. +Store information of one random variable. -# Arguments -* `vtkfile`: Stream opened for writing. -* `numeric_data`: A pointer to a numeric data array. -* `byte_length`: The length of the data array in bytes. -# Returns -Returns 0 on success, -1 on file error. -### Prototype -```c -int sc_vtk_write_binary (FILE * vtkfile, char *numeric_data, size_t byte_length); -``` +| Field | Note | +| :--------------- | :--------------------------------------- | +| dirty | Only update stats if this is true. | +| count | Inout; global count is 52 bit accurate. | +| sum\\_values | Inout; global sum of values. | +| sum\\_squares | Inout; global sum of squares. | +| min | Inout; minimum over values. | +| max | Inout; maximum over values. | +| variable | Name of the variable for output. | +| variable\\_owned | NULL or deep copy of variable. | +| group | Grouping identifier. | +| prio | Priority identifier. | """ -function sc_vtk_write_binary(vtkfile, numeric_data, byte_length) - @ccall libsc.sc_vtk_write_binary(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint +struct sc_statinfo + dirty::Cint + count::Clong + sum_values::Cdouble + sum_squares::Cdouble + min::Cdouble + max::Cdouble + min_at_rank::Cint + max_at_rank::Cint + average::Cdouble + variance::Cdouble + standev::Cdouble + variance_mean::Cdouble + standev_mean::Cdouble + variable::Cstring + variable_owned::Cstring + group::Cint + prio::Cint end +"""Store information of one random variable.""" +const sc_statinfo_t = sc_statinfo + """ - sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) + sc_stats_set1(stats, value, variable) -This function writes numeric binary data in VTK compressed format. +Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. We set sc_stats_group_all and sc_stats_prio_all internally. # Arguments -* `vtkfile`: Stream opened for writing. -* `numeric_data`: A pointer to a numeric data array. -* `byte_length`: The length of the data array in bytes. -# Returns -Returns 0 on success, -1 on file error. +* `stats`:\\[out\\] Will be filled with count=1 and the value. +* `value`:\\[in\\] Value used to fill statistics information. +* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. ### Prototype ```c -int sc_vtk_write_compressed (FILE * vtkfile, char *numeric_data, size_t byte_length); +void sc_stats_set1 (sc_statinfo_t * stats, double value, const char *variable); ``` """ -function sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) - @ccall libsc.sc_vtk_write_compressed(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint +function sc_stats_set1(stats, value, variable) + @ccall libsc.sc_stats_set1(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring)::Cvoid end """ - sc_fopen(filename, mode, errmsg) + sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) -Wrapper for fopen(3). We provide an additional argument that contains the error message. +Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. +# Arguments +* `stats`:\\[out\\] Will be filled with count=1 and the value. +* `value`:\\[in\\] Value used to fill statistics information. +* `variable`:\\[in\\] String to be reported by sc_stats_print. +* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. +* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. +* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. ### Prototype ```c -FILE *sc_fopen (const char *filename, const char *mode, const char *errmsg); +void sc_stats_set1_ext (sc_statinfo_t * stats, double value, const char *variable, int copy_variable, int stats_group, int stats_prio); ``` """ -function sc_fopen(filename, mode, errmsg) - @ccall libsc.sc_fopen(filename::Cstring, mode::Cstring, errmsg::Cstring)::Ptr{Libc.FILE} +function sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) + @ccall libsc.sc_stats_set1_ext(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid end """ - sc_fwrite(ptr, size, nmemb, file, errmsg) - -Write memory content to a file. - -!!! note + sc_stats_init(stats, variable) - This function aborts on file errors. +Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. We set sc_stats_group_all and sc_stats_prio_all internally. # Arguments -* `ptr`:\\[in\\] Data array to write to disk. -* `size`:\\[in\\] Size of one array member. -* `nmemb`:\\[in\\] Number of array members. -* `file`:\\[in,out\\] File pointer, must be opened for writing. -* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). +* `stats`:\\[out\\] Will be filled with count 0 and values of 0. +* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. ### Prototype ```c -void sc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); +void sc_stats_init (sc_statinfo_t * stats, const char *variable); ``` """ -function sc_fwrite(ptr, size, nmemb, file, errmsg) - @ccall libsc.sc_fwrite(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid +function sc_stats_init(stats, variable) + @ccall libsc.sc_stats_init(stats::Ptr{sc_statinfo_t}, variable::Cstring)::Cvoid end """ - sc_fread(ptr, size, nmemb, file, errmsg) - -Read file content into memory. - -!!! note + sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) - This function aborts on file errors. +Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. # Arguments -* `ptr`:\\[out\\] Data array to read from disk. -* `size`:\\[in\\] Size of one array member. -* `nmemb`:\\[in\\] Number of array members. -* `file`:\\[in,out\\] File pointer, must be opened for reading. -* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). +* `stats`:\\[out\\] Will be filled with count 0 and values of 0. +* `variable`:\\[in\\] String to be reported by sc_stats_print. +* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. +* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. +* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. ### Prototype ```c -void sc_fread (void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); +void sc_stats_init_ext (sc_statinfo_t * stats, const char *variable, int copy_variable, int stats_group, int stats_prio); ``` """ -function sc_fread(ptr, size, nmemb, file, errmsg) - @ccall libsc.sc_fread(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid +function sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) + @ccall libsc.sc_stats_init_ext(stats::Ptr{sc_statinfo_t}, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid end """ - sc_fflush_fsync_fclose(file) + sc_stats_reset(stats, reset_vgp) -Best effort to flush a file's data to disc and close it. +Reset all values to zero, optionally unassign name, group, and priority. # Arguments -* `file`:\\[in,out\\] File open for writing. +* `stats`:\\[in,out\\] Variables are zeroed. They can be set again by set1 or accumulate. +* `reset_vgp`:\\[in\\] If true, the variable name string is zeroed and if we did a copy, the copy is freed. If true, group and priority are set to all. If false, we don't touch any of the above. ### Prototype ```c -void sc_fflush_fsync_fclose (FILE * file); +void sc_stats_reset (sc_statinfo_t * stats, int reset_vgp); ``` """ -function sc_fflush_fsync_fclose(file) - @ccall libsc.sc_fflush_fsync_fclose(file::Ptr{Libc.FILE})::Cvoid +function sc_stats_reset(stats, reset_vgp) + @ccall libsc.sc_stats_reset(stats::Ptr{sc_statinfo_t}, reset_vgp::Cint)::Cvoid end """ - sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) + sc_stats_set_group_prio(stats, stats_group, stats_prio) + +Set/update the group and priority information for a stats item. +# Arguments +* `stats`:\\[out\\] Only group and stats entries are updated. +* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. +* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. ### Prototype ```c -int sc_io_open (sc_MPI_Comm mpicomm, const char *filename, sc_io_open_mode_t amode, sc_MPI_Info mpiinfo, sc_MPI_File * mpifile); +void sc_stats_set_group_prio (sc_statinfo_t * stats, int stats_group, int stats_prio); ``` """ -function sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) - @ccall libsc.sc_io_open(mpicomm::MPI_Comm, filename::Cstring, amode::sc_io_open_mode_t, mpiinfo::Cint, mpifile::Ptr{Cint})::Cint +function sc_stats_set_group_prio(stats, stats_group, stats_prio) + @ccall libsc.sc_stats_set_group_prio(stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint)::Cvoid end """ - sc_io_read_at(mpifile, offset, ptr, count, t, ocount) + sc_stats_accumulate(stats, value) +Add an instance of the random variable. The counter of the variable is increased by one. The value is added into the present values of the variable. + +# Arguments +* `stats`:\\[out\\] Must be dirty. We bump count and values. +* `value`:\\[in\\] Value used to update statistics information. ### Prototype ```c -int sc_io_read_at (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); +void sc_stats_accumulate (sc_statinfo_t * stats, double value); ``` """ -function sc_io_read_at(mpifile, offset, ptr, count, t, ocount) - @ccall libsc.sc_io_read_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint +function sc_stats_accumulate(stats, value) + @ccall libsc.sc_stats_accumulate(stats::Ptr{sc_statinfo_t}, value::Cdouble)::Cvoid end """ - sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) + sc_stats_compute(mpicomm, nvars, stats) ### Prototype ```c -int sc_io_read_at_all (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); +void sc_stats_compute (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); ``` """ -function sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) - @ccall libsc.sc_io_read_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint +function sc_stats_compute(mpicomm, nvars, stats) + @ccall libsc.sc_stats_compute(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid end """ - sc_io_write_at(mpifile, offset, ptr, count, t, ocount) + sc_stats_compute1(mpicomm, nvars, stats) ### Prototype ```c -int sc_io_write_at (sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount); +void sc_stats_compute1 (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); ``` """ -function sc_io_write_at(mpifile, offset, ptr, count, t, ocount) - @ccall libsc.sc_io_write_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint +function sc_stats_compute1(mpicomm, nvars, stats) + @ccall libsc.sc_stats_compute1(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid end """ - sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) + sc_stats_print(package_id, log_priority, nvars, stats, full, summary) + +Print measured statistics. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. All groups and priorities are printed. +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Log priority for output according to sc.h. +* `nvars`:\\[in\\] Number of stats items in input array. +* `stats`:\\[in\\] Input array of stats variable items. +* `full`:\\[in\\] Print full information for every variable. +* `summary`:\\[in\\] Print summary information all on 1 line. ### Prototype ```c -int sc_io_write_at_all (sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount); +void sc_stats_print (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int full, int summary); ``` """ -function sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) - @ccall libsc.sc_io_write_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint +function sc_stats_print(package_id, log_priority, nvars, stats, full, summary) + @ccall libsc.sc_stats_print(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, full::Cint, summary::Cint)::Cvoid end """ - sc_io_close(file) + sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) + +Print measured statistics, filter by group and/or priority. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Log priority for output according to sc.h. +* `nvars`:\\[in\\] Number of stats items in input array. +* `stats`:\\[in\\] Input array of stats variable items. +* `stats_group`:\\[in\\] Print only this group. Non-negative or sc_stats_group_all. We skip printing a variable if neither this parameter nor the item's group is all and if the item's group does not match this. +* `stats_prio`:\\[in\\] Print this and higher priorities. Non-negative or sc_stats_prio_all. We skip printing a variable if neither this parameter nor the item's prio is all and if the item's prio is less than this. +* `full`:\\[in\\] Print full information for every variable. This produces multiple lines including minimum, maximum, and standard deviation. If this is false, print one line per variable. +* `summary`:\\[in\\] Print summary information all on 1 line. This always contains all variables. Not affected by stats\\_group and stats\\_prio. ### Prototype ```c -int sc_io_close (sc_MPI_File * file); +void sc_stats_print_ext (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int stats_group, int stats_prio, int full, int summary); ``` """ -function sc_io_close(file) - @ccall libsc.sc_io_close(file::Ptr{Cint})::Cint +function sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) + @ccall libsc.sc_stats_print_ext(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint, full::Cint, summary::Cint)::Cvoid end """ - p4est_comm_tag + sc_statistics_new(mpicomm) -Tags for MPI messages +### Prototype +```c +sc_statistics_t *sc_statistics_new (sc_MPI_Comm mpicomm); +``` """ -@cenum p4est_comm_tag::UInt32 begin - P4EST_COMM_TAG_FIRST = 214 - P4EST_COMM_COUNT_PERTREE = 295 - P4EST_COMM_BALANCE_FIRST_COUNT = 296 - P4EST_COMM_BALANCE_FIRST_LOAD = 297 - P4EST_COMM_BALANCE_SECOND_COUNT = 298 - P4EST_COMM_BALANCE_SECOND_LOAD = 299 - P4EST_COMM_PARTITION_GIVEN = 300 - P4EST_COMM_PARTITION_WEIGHTED_LOW = 301 - P4EST_COMM_PARTITION_WEIGHTED_HIGH = 302 - P4EST_COMM_PARTITION_CORRECTION = 303 - P4EST_COMM_GHOST_COUNT = 304 - P4EST_COMM_GHOST_LOAD = 305 - P4EST_COMM_GHOST_EXCHANGE = 306 - P4EST_COMM_GHOST_EXPAND_COUNT = 307 - P4EST_COMM_GHOST_EXPAND_LOAD = 308 - P4EST_COMM_GHOST_SUPPORT_COUNT = 309 - P4EST_COMM_GHOST_SUPPORT_LOAD = 310 - P4EST_COMM_GHOST_CHECKSUM = 311 - P4EST_COMM_NODES_QUERY = 312 - P4EST_COMM_NODES_REPLY = 313 - P4EST_COMM_SAVE = 314 - P4EST_COMM_LNODES_TEST = 315 - P4EST_COMM_LNODES_PASS = 316 - P4EST_COMM_LNODES_OWNED = 317 - P4EST_COMM_LNODES_ALL = 318 - P4EST_COMM_TAG_LAST = 319 +function sc_statistics_new(mpicomm) + @ccall libsc.sc_statistics_new(mpicomm::MPI_Comm)::Ptr{sc_statistics_t} end -"""Tags for MPI messages""" -const p4est_comm_tag_t = p4est_comm_tag - """ - p4est_log_indent_push() + sc_statistics_destroy(stats) +Destroy a statistics structure. + +# Arguments +* `stats`:\\[in,out\\] Valid object is invalidated. ### Prototype ```c -static inline void p4est_log_indent_push (void); +void sc_statistics_destroy (sc_statistics_t * stats); ``` """ -function p4est_log_indent_push() - @ccall libp4est.p4est_log_indent_push()::Cvoid +function sc_statistics_destroy(stats) + @ccall libsc.sc_statistics_destroy(stats::Ptr{sc_statistics_t})::Cvoid end """ - p4est_log_indent_pop() + sc_statistics_add(stats, name) + +Register a statistics variable by name and set its value to 0. This variable must not exist already. ### Prototype ```c -static inline void p4est_log_indent_pop (void); +void sc_statistics_add (sc_statistics_t * stats, const char *name); ``` """ -function p4est_log_indent_pop() - @ccall libp4est.p4est_log_indent_pop()::Cvoid +function sc_statistics_add(stats, name) + @ccall libsc.sc_statistics_add(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid end """ - p4est_init(log_handler, log_threshold) + sc_statistics_set(stats, name, value) -Registers p4est with the SC Library and sets the logging behavior. This function is optional. This function must only be called before additional threads are created. If this function is not called or called with log\\_handler == NULL, the default SC log handler will be used. If this function is not called or called with log\\_threshold == [`SC_LP_DEFAULT`](@ref), the default SC log threshold will be used. The default SC log settings can be changed with [`sc_set_log_defaults`](@ref) (). +Set the value of a statistics variable, see [`sc_stats_set1`](@ref). The variable must previously be added with [`sc_statistics_add`](@ref). This assumes count=1 as in the [`sc_stats_set1`](@ref) function above. ### Prototype ```c -void p4est_init (sc_log_handler_t log_handler, int log_threshold); +void sc_statistics_set (sc_statistics_t * stats, const char *name, double value); ``` """ -function p4est_init(log_handler, log_threshold) - @ccall libp4est.p4est_init(log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid +function sc_statistics_set(stats, name, value) + @ccall libsc.sc_statistics_set(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid end """ - p4est_is_initialized() - -Return whether p4est has been initialized or not. Keep in mind that p4est_init is an optional function but it helps with proper parallel logging. + sc_statistics_compute(stats) -Currently there is no inverse to p4est_init, and no way to deinit it. This is ok since initialization generally does no harm. Just do not call libsc's finalize function while p4est is still in use. +Compute statistics for all variables, see [`sc_stats_compute`](@ref). -# Returns -True if p4est has been initialized with a call to p4est_init and false otherwise. ### Prototype ```c -int p4est_is_initialized (void); +void sc_statistics_compute (sc_statistics_t * stats); ``` """ -function p4est_is_initialized() - @ccall libp4est.p4est_is_initialized()::Cint +function sc_statistics_compute(stats) + @ccall libsc.sc_statistics_compute(stats::Ptr{sc_statistics_t})::Cvoid end """ - p4est_have_zlib() + sc_statistics_print(stats, package_id, log_priority, full, summary) -Check for a sufficiently recent zlib installation. +Print all statistics variables, see [`sc_stats_print`](@ref). -# Returns -True if zlib is detected in both sc and p4est. ### Prototype ```c -int p4est_have_zlib (void); +void sc_statistics_print (sc_statistics_t * stats, int package_id, int log_priority, int full, int summary); ``` """ -function p4est_have_zlib() - @ccall libp4est.p4est_have_zlib()::Cint +function sc_statistics_print(stats, package_id, log_priority, full, summary) + @ccall libsc.sc_statistics_print(stats::Ptr{sc_statistics_t}, package_id::Cint, log_priority::Cint, full::Cint, summary::Cint)::Cvoid end +mutable struct sc_options end + +"""The options data structure is opaque.""" +const sc_options_t = sc_options + +# typedef int ( * sc_options_callback_t ) ( sc_options_t * opt , const char * opt_arg , void * data ) """ - p4est_get_package_id() +This callback can be invoked with sc_options_parse. -Query the package identity as registered in libsc. +# Arguments +* `opt`:\\[in\\] Valid options data structure. This is passed as a matter of principle. +* `opt_arg`:\\[in\\] The option argument or NULL if there is none. This variable is internal. Do not store pointer. +* `data`:\\[in\\] User-defined data passed to [`sc_options_add_callback`](@ref). +# Returns +Return 0 if successful, -1 to indicate a parse error. +""" +const sc_options_callback_t = Ptr{Cvoid} + +""" + sc_options_new(program_path) + +Create an empty options structure. +# Arguments +* `program_path`:\\[in\\] Name or path name of the program to display. Usually argv[0] is fine. # Returns -This is -1 before p4est_init has been called and a proper package identifier (>= 0) afterwards. +A valid and empty options structure. ### Prototype ```c -int p4est_get_package_id (void); +sc_options_t *sc_options_new (const char *program_path); ``` """ -function p4est_get_package_id() - @ccall libp4est.p4est_get_package_id()::Cint +function sc_options_new(program_path) + @ccall libsc.sc_options_new(program_path::Cstring)::Ptr{sc_options_t} end """ - p4est_topidx_hash2(tt) + sc_options_destroy_deep(opt) +Destroy the options structure and all allocated structures contained. The keyvalue structure passed into sc\\_keyvalue\\_add is destroyed. + +!!! compat "Deprecated" + + This function is kept for backwards compatibility. It is best to destroy any key-value container outside of the lifetime of the options object. + +# Arguments +* `opt`:\\[in,out\\] This options structure is deallocated, including all key-value containers referenced. ### Prototype ```c -static inline unsigned p4est_topidx_hash2 (const p4est_topidx_t * tt); +void sc_options_destroy_deep (sc_options_t * opt); ``` """ -function p4est_topidx_hash2(tt) - @ccall libp4est.p4est_topidx_hash2(tt::Ptr{p4est_topidx_t})::Cuint +function sc_options_destroy_deep(opt) + @ccall libsc.sc_options_destroy_deep(opt::Ptr{sc_options_t})::Cvoid end """ - p4est_topidx_hash3(tt) + sc_options_destroy(opt) +Destroy the options structure. Whatever has been passed into sc\\_keyvalue\\_add is left alone. + +# Arguments +* `opt`:\\[in,out\\] This options structure is deallocated. ### Prototype ```c -static inline unsigned p4est_topidx_hash3 (const p4est_topidx_t * tt); +void sc_options_destroy (sc_options_t * opt); ``` """ -function p4est_topidx_hash3(tt) - @ccall libp4est.p4est_topidx_hash3(tt::Ptr{p4est_topidx_t})::Cuint +function sc_options_destroy(opt) + @ccall libsc.sc_options_destroy(opt::Ptr{sc_options_t})::Cvoid end """ - p4est_topidx_hash4(tt) + sc_options_set_spacing(opt, space_type, space_help) +Set the spacing for sc_options_print_summary. There are two values to be set: the spacing from the beginning of the printed line to the type of the option variable, and from the beginning of the printed line to the help string. + +# Arguments +* `opt`:\\[in,out\\] Valid options structure. +* `space_type`:\\[in\\] Number of spaces to the type display, for example , , etc. Setting this negative sets the default 20. +* `space_help`:\\[in\\] Number of space to the help string. Setting this negative sets the default 32. ### Prototype ```c -static inline unsigned p4est_topidx_hash4 (const p4est_topidx_t * tt); +void sc_options_set_spacing (sc_options_t * opt, int space_type, int space_help); ``` """ -function p4est_topidx_hash4(tt) - @ccall libp4est.p4est_topidx_hash4(tt::Ptr{p4est_topidx_t})::Cuint +function sc_options_set_spacing(opt, space_type, space_help) + @ccall libsc.sc_options_set_spacing(opt::Ptr{sc_options_t}, space_type::Cint, space_help::Cint)::Cvoid end """ - p4est_topidx_is_sorted(t, length) + sc_options_add_switch(opt, opt_char, opt_name, variable, help_string) +Add a switch option. This option is used without option arguments. Every use increments the variable by one. Its initial value is 0. Either opt\\_char or opt\\_name must be valid, that is, not '\\0'/NULL. + +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -static inline int p4est_topidx_is_sorted (p4est_topidx_t * t, int length); +void sc_options_add_switch (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, const char *help_string); ``` """ -function p4est_topidx_is_sorted(t, length) - @ccall libp4est.p4est_topidx_is_sorted(t::Ptr{p4est_topidx_t}, length::Cint)::Cint +function sc_options_add_switch(opt, opt_char, opt_name, variable, help_string) + @ccall libsc.sc_options_add_switch(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, help_string::Cstring)::Cvoid end """ - p4est_topidx_bsort(t, length) + sc_options_add_bool(opt, opt_char, opt_name, variable, init_value, help_string) +Add a boolean option. It can be initialized to true or false in the C sense. Specifying it on the command line without argument sets the option to true. The argument 0/f/F/n/N sets it to false (0). The argument 1/t/T/y/Y sets it to true (nonzero). + +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] Initial value to set the option, read as true or false. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -static inline void p4est_topidx_bsort (p4est_topidx_t * t, int length); +void sc_options_add_bool (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string); ``` """ -function p4est_topidx_bsort(t, length) - @ccall libp4est.p4est_topidx_bsort(t::Ptr{p4est_topidx_t}, length::Cint)::Cvoid +function sc_options_add_bool(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libsc.sc_options_add_bool(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cint, help_string::Cstring)::Cvoid end """ - p4est_partition_cut_uint64(global_num, p, num_procs) + sc_options_add_int(opt, opt_char, opt_name, variable, init_value, help_string) +Add an option that takes an integer argument. + +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] The initial value of the option variable. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -static inline uint64_t p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs); +void sc_options_add_int (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string); ``` """ -function p4est_partition_cut_uint64(global_num, p, num_procs) - @ccall libp4est.p4est_partition_cut_uint64(global_num::UInt64, p::Cint, num_procs::Cint)::UInt64 +function sc_options_add_int(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libsc.sc_options_add_int(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cint, help_string::Cstring)::Cvoid end """ - p4est_partition_cut_gloidx(global_num, p, num_procs) + sc_options_add_size_t(opt, opt_char, opt_name, variable, init_value, help_string) +Add an option that takes a size\\_t argument. The value of the size\\_t variable must not be greater than LLONG\\_MAX. + +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] The initial value of the option variable. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -static inline p4est_gloidx_t p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs); +void sc_options_add_size_t (sc_options_t * opt, int opt_char, const char *opt_name, size_t *variable, size_t init_value, const char *help_string); ``` """ -function p4est_partition_cut_gloidx(global_num, p, num_procs) - @ccall libp4est.p4est_partition_cut_gloidx(global_num::p4est_gloidx_t, p::Cint, num_procs::Cint)::p4est_gloidx_t +function sc_options_add_size_t(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libsc.sc_options_add_size_t(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Csize_t}, init_value::Csize_t, help_string::Cstring)::Cvoid end """ - p4est_version() + sc_options_add_double(opt, opt_char, opt_name, variable, init_value, help_string) -Return the full version of p4est. +Add an option that takes a double argument. The double must be in the legal range. "inf" and "nan" are legal too. -# Returns -Return the version of p4est using the format `VERSION\\_MAJOR.VERSION\\_MINOR.VERSION\\_POINT`, where `VERSION_POINT` can contain dots and characters, e.g. to indicate the additional number of commits and a git commit hash. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] The initial value of the option variable. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -const char *p4est_version (void); +void sc_options_add_double (sc_options_t * opt, int opt_char, const char *opt_name, double *variable, double init_value, const char *help_string); ``` """ -function p4est_version() - @ccall libp4est.p4est_version()::Cstring +function sc_options_add_double(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libsc.sc_options_add_double(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cdouble}, init_value::Cdouble, help_string::Cstring)::Cvoid end """ - p4est_version_major() + sc_options_add_string(opt, opt_char, opt_name, variable, init_value, help_string) -Return the major version of p4est. +Add a string option. -# Returns -Return the major version of p4est. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] This default value of the option may be NULL. If not NULL, the value is copied to internal storage. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -int p4est_version_major (void); +void sc_options_add_string (sc_options_t * opt, int opt_char, const char *opt_name, const char **variable, const char *init_value, const char *help_string); ``` """ -function p4est_version_major() - @ccall libp4est.p4est_version_major()::Cint +function sc_options_add_string(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libsc.sc_options_add_string(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cstring}, init_value::Cstring, help_string::Cstring)::Cvoid end """ - p4est_version_minor() + sc_options_add_inifile(opt, opt_char, opt_name, help_string) -Return the minor version of p4est. +Add an option to read in a file in `.ini` format. The argument to this option must be a filename. On parsing the specified file is read to set known option variables. It does not have an associated option variable itself. -# Returns -Return the minor version of p4est. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -int p4est_version_minor (void); +void sc_options_add_inifile (sc_options_t * opt, int opt_char, const char *opt_name, const char *help_string); ``` """ -function p4est_version_minor() - @ccall libp4est.p4est_version_minor()::Cint +function sc_options_add_inifile(opt, opt_char, opt_name, help_string) + @ccall libsc.sc_options_add_inifile(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, help_string::Cstring)::Cvoid end """ - p4est_connect_type_t + sc_options_add_jsonfile(opt, opt_char, opt_name, help_string) -Characterize a type of adjacency. +Add an option to read in a file in JSON format. The argument to this option must be a filename. On parsing the specified file is read to set known option variables. It does not have an associated option variable itself. -Several functions involve relationships between neighboring trees and/or quadrants, and their behavior depends on how one defines adjacency: 1) entities are adjacent if they share a face, or 2) entities are adjacent if they share a face or corner. [`p4est_connect_type_t`](@ref) is used to choose the desired behavior. This enum must fit into an int8\\_t. +This functionality is only active when sc_have_json returns true, equivalent to the define SC\\_HAVE\\_JSON existing, and ignored otherwise. -| Enumerator | Note | -| :----------------------- | :--------------------------------- | -| P4EST\\_CONNECT\\_SELF | No balance whatsoever. | -| P4EST\\_CONNECT\\_FACE | Balance across faces only. | -| P4EST\\_CONNECT\\_ALMOST | = CORNER - 1. | -| P4EST\\_CONNECT\\_CORNER | Balance across faces and corners. | -| P4EST\\_CONNECT\\_FULL | = CORNER. | +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. +### Prototype +```c +void sc_options_add_jsonfile (sc_options_t * opt, int opt_char, const char *opt_name, const char *help_string); +``` """ -@cenum p4est_connect_type_t::UInt32 begin - P4EST_CONNECT_SELF = 20 - P4EST_CONNECT_FACE = 21 - P4EST_CONNECT_ALMOST = 21 - P4EST_CONNECT_CORNER = 22 - P4EST_CONNECT_FULL = 22 +function sc_options_add_jsonfile(opt, opt_char, opt_name, help_string) + @ccall libsc.sc_options_add_jsonfile(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, help_string::Cstring)::Cvoid end """ - p4est_connectivity_encode_t + sc_options_add_callback(opt, opt_char, opt_name, has_arg, fn, data, help_string) -Typedef for serialization method. +Add an option that calls a user-defined function when parsed. The callback function should be implemented to allow multiple calls. The callback may be used to set multiple option variables in bulk that would otherwise require an inconvenient number of individual options. This option is not loaded from or saved to files. -| Enumerator | Note | -| :--------------------------- | :-------------------------------- | -| P4EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `has_arg`:\\[in\\] Specify whether the option needs an option argument. This can be 0 for none, 1 for a required argument, and 2 for an optional argument; see getopt\\_long (3). +* `fn`:\\[in\\] Function to call when this option is encountered. +* `data`:\\[in\\] User-defined data passed to the callback. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. +### Prototype +```c +void sc_options_add_callback (sc_options_t * opt, int opt_char, const char *opt_name, int has_arg, sc_options_callback_t fn, void *data, const char *help_string); +``` """ -@cenum p4est_connectivity_encode_t::UInt32 begin - P4EST_CONN_ENCODE_NONE = 0 - P4EST_CONN_ENCODE_LAST = 1 +function sc_options_add_callback(opt, opt_char, opt_name, has_arg, fn, data, help_string) + @ccall libsc.sc_options_add_callback(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, has_arg::Cint, fn::sc_options_callback_t, data::Ptr{Cvoid}, help_string::Cstring)::Cvoid end """ - p4est_connect_type_int(btype) + sc_options_add_keyvalue(opt, opt_char, opt_name, variable, init_value, keyvalue, help_string) -Convert the [`p4est_connect_type_t`](@ref) into a number. +Add an option that takes string keys into a lookup table of integers. On calling this function, it must be certain that the initial value exists. # Arguments -* `btype`:\\[in\\] The balance type to convert. -# Returns -Returns 1 or 2. +* `opt`:\\[in\\] Initialized options structure. +* `opt_char`:\\[in\\] Option character for command line, or 0. +* `opt_name`:\\[in\\] Name of the long option, or NULL. +* `variable`:\\[in\\] Address of an existing integer that holds the value of this option parameter. +* `init_value`:\\[in\\] The key that is looked up for the initial value. It must be certain that the key exists and its value is of type integer. +* `keyvalue`:\\[in\\] A valid key-value structure where the values must be integers. If a key is asked for that does not exist, we will produce an option error. This structure must stay alive as long as opt. +* `help_string`:\\[in\\] Instructive one-line string to explain the option. ### Prototype ```c -int p4est_connect_type_int (p4est_connect_type_t btype); +void sc_options_add_keyvalue (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, const char *init_value, sc_keyvalue_t * keyvalue, const char *help_string); ``` """ -function p4est_connect_type_int(btype) - @ccall libp4est.p4est_connect_type_int(btype::p4est_connect_type_t)::Cint +function sc_options_add_keyvalue(opt, opt_char, opt_name, variable, init_value, keyvalue, help_string) + @ccall libsc.sc_options_add_keyvalue(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cstring, keyvalue::Ptr{sc_keyvalue_t}, help_string::Cstring)::Cvoid end """ - p4est_connect_type_string(btype) + sc_options_add_suboptions(opt, subopt, prefix) -Convert the [`p4est_connect_type_t`](@ref) into a const string. +Copy one set of options to another as a subset, with a prefix. The variables referenced by the options and the suboptions are the same. # Arguments -* `btype`:\\[in\\] The balance type to convert. -# Returns -Returns a pointer to a constant string. +* `opt`:\\[in,out\\] A set of options. +* `subopt`:\\[in\\] Another set of options to be copied. +* `prefix`:\\[in\\] The prefix to add to option names as they are copied. If an option has a long name "name" in subopt, its name in opt is "prefix:name"; if an option only has a character 'c' in subopt, its name in opt is "prefix:-c". ### Prototype ```c -const char *p4est_connect_type_string (p4est_connect_type_t btype); +void sc_options_add_suboptions (sc_options_t * opt, sc_options_t * subopt, const char *prefix); ``` """ -function p4est_connect_type_string(btype) - @ccall libp4est.p4est_connect_type_string(btype::p4est_connect_type_t)::Cstring +function sc_options_add_suboptions(opt, subopt, prefix) + @ccall libsc.sc_options_add_suboptions(opt::Ptr{sc_options_t}, subopt::Ptr{sc_options_t}, prefix::Cstring)::Cvoid end """ - p4est_connectivity + sc_options_print_usage(package_id, log_priority, opt, arg_usage) -This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible. - -The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is given by the normal directions -x +x -y +y. Each face has a natural direction by increasing face corner number. Face connections are allocated [0][0]..[0][3]..[num\\_trees-1][0]..[num\\_trees-1][3]. If a face is on the physical boundary it must connect to itself. +Print a usage message. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. -The values for tree\\_to\\_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for faces that are mutually direction-aligned and 1 for faces that are running in opposite directions. - -It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. - -The corners are stored when they connect trees that are not already face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. - -The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. - -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. We do not interpret them. - -!!! note - - If a connectivity implies natural connections between trees that are corner neighbors without being face neighbors, these corners shall be encoded explicitly in the connectivity. - -| Field | Note | -| :------------------- | :----------------------------------------------------------------------------------- | -| num\\_vertices | the number of vertices that define the *embedding* of the forest (not the topology) | -| num\\_trees | the number of trees | -| num\\_corners | the number of corners that help define topology | -| vertices | an array of size (3 * *num_vertices*) | -| tree\\_to\\_vertex | embed each tree into ```c++ R^3 ``` for e.g. visualization (see p4est\\_vtk.h) | -| tree\\_attr\\_bytes | bytes per tree in tree\\_to\\_attr | -| tree\\_to\\_attr | not touched by p4est | -| tree\\_to\\_tree | (4 * *num_trees*) neighbors across faces | -| tree\\_to\\_face | (4 * *num_trees*) face to face+orientation (see description) | -| tree\\_to\\_corner | (4 * *num_trees*) or NULL (see description) | -| ctt\\_offset | corner to offset in *corner_to_tree* and *corner_to_corner* | -| corner\\_to\\_tree | list of trees that meet at a corner | -| corner\\_to\\_corner | list of tree-corners that meet at a corner | +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Priority for output according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `arg_usage`:\\[in\\] If not NULL, an string is appended to the usage line. If the string is non-empty, it will be printed after the option summary and an "ARGUMENTS:\\n" title line. Line breaks are identified by strtok(3) and honored. +### Prototype +```c +void sc_options_print_usage (int package_id, int log_priority, sc_options_t * opt, const char *arg_usage); +``` """ -struct p4est_connectivity - num_vertices::p4est_topidx_t - num_trees::p4est_topidx_t - num_corners::p4est_topidx_t - vertices::Ptr{Cdouble} - tree_to_vertex::Ptr{p4est_topidx_t} - tree_attr_bytes::Csize_t - tree_to_attr::Cstring - tree_to_tree::Ptr{p4est_topidx_t} - tree_to_face::Ptr{Int8} - tree_to_corner::Ptr{p4est_topidx_t} - ctt_offset::Ptr{p4est_topidx_t} - corner_to_tree::Ptr{p4est_topidx_t} - corner_to_corner::Ptr{Int8} +function sc_options_print_usage(package_id, log_priority, opt, arg_usage) + @ccall libsc.sc_options_print_usage(package_id::Cint, log_priority::Cint, opt::Ptr{sc_options_t}, arg_usage::Cstring)::Cvoid end """ -This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible. - -The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is given by the normal directions -x +x -y +y. Each face has a natural direction by increasing face corner number. Face connections are allocated [0][0]..[0][3]..[num\\_trees-1][0]..[num\\_trees-1][3]. If a face is on the physical boundary it must connect to itself. - -The values for tree\\_to\\_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for faces that are mutually direction-aligned and 1 for faces that are running in opposite directions. - -It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. - -The corners are stored when they connect trees that are not already face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. - -The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. - -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. We do not interpret them. - -!!! note - - If a connectivity implies natural connections between trees that are corner neighbors without being face neighbors, these corners shall be encoded explicitly in the connectivity. -""" -const p4est_connectivity_t = p4est_connectivity + sc_options_print_summary(package_id, log_priority, opt) -""" - p4est_connectivity_shared +Print a summary of all option values. Prints the title "Options:" and a line for every option, then the title "Arguments:" and a line for every argument. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. -| Field | Note | -| :---- | :--------------------------------------------------------- | -| conn | The members of this connectivity are MPI3 shared windows. | +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Priority for output according to sc_logprios. +* `opt`:\\[in\\] The option structure. +### Prototype +```c +void sc_options_print_summary (int package_id, int log_priority, sc_options_t * opt); +``` """ -struct p4est_connectivity_shared - conn::Ptr{p4est_connectivity_t} - win_vertices::Cint - win_tree_to_vertex::Cint - win_tree_to_attr::Cint - win_tree_to_tree::Cint - win_tree_to_face::Cint - win_tree_to_corner::Cint - win_ctt_offset::Cint - win_corner_to_tree::Cint - win_corner_to_corner::Cint +function sc_options_print_summary(package_id, log_priority, opt) + @ccall libsc.sc_options_print_summary(package_id::Cint, log_priority::Cint, opt::Ptr{sc_options_t})::Cvoid end -"""Management information for a connectivity shared by MPI3.""" -const p4est_connectivity_shared_t = p4est_connectivity_shared - """ - p4est_connectivity_memory_used(conn) + sc_options_load(package_id, err_priority, opt, file) -Calculate memory usage of a connectivity structure. +Load a file in the default format and update option values. The default is a file in the `.ini` format; see sc_options_load_ini. # Arguments -* `conn`:\\[in\\] Connectivity structure. +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `file`:\\[in\\] Filename of the file to load. # Returns -Memory used in bytes. +Returns 0 on success, -1 on failure. ### Prototype ```c -size_t p4est_connectivity_memory_used (p4est_connectivity_t * conn); +int sc_options_load (int package_id, int err_priority, sc_options_t * opt, const char *file); ``` """ -function p4est_connectivity_memory_used(conn) - @ccall libp4est.p4est_connectivity_memory_used(conn::Ptr{p4est_connectivity_t})::Csize_t +function sc_options_load(package_id, err_priority, opt, file) + @ccall libsc.sc_options_load(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, file::Cstring)::Cint end """ - p4est_corner_transform_t + sc_options_load_ini(package_id, err_priority, opt, inifile, re) -Generic interface for transformations between a tree and any of its corner +Load a file in `.ini` format and update entries found under [Options]. An option whose name contains a colon such as "prefix:basename" will be updated by a "basename =" entry in a [prefix] section. -| Field | Note | -| :------ | :------------------------ | -| ntree | The number of the tree | -| ncorner | The number of the corner | +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `inifile`:\\[in\\] Filename of the ini file to load. +* `re`:\\[in,out\\] Provisioned for runtime error checking implementation; currently must be NULL. +# Returns +Returns 0 on success, -1 on failure. +### Prototype +```c +int sc_options_load_ini (int package_id, int err_priority, sc_options_t * opt, const char *inifile, void *re); +``` """ -struct p4est_corner_transform_t - ntree::p4est_topidx_t - ncorner::Int8 +function sc_options_load_ini(package_id, err_priority, opt, inifile, re) + @ccall libsc.sc_options_load_ini(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring, re::Ptr{Cvoid})::Cint end """ - p4est_corner_info_t + sc_options_load_json(package_id, err_priority, opt, jsonfile, re) -Information about the neighbors of a corner +Load a file in JSON format and update entries from object "Options". An option whose name contains a colon such as "Prefix:basename" will be updated by a "basename :" entry in a "Prefix" nested object. -| Field | Note | -| :------------------ | :------------------------------------------------ | -| icorner | The number of the originating corner | -| corner\\_transforms | The array of neighbors of the originating corner | +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `jsonfile`:\\[in\\] Filename of the JSON file to load. +* `re`:\\[in,out\\] Provisioned for runtime error checking implementation; currently must be NULL. +# Returns +Returns 0 on success, -1 on failure. +### Prototype +```c +int sc_options_load_json (int package_id, int err_priority, sc_options_t * opt, const char *jsonfile, void *re); +``` """ -struct p4est_corner_info_t - icorner::p4est_topidx_t - corner_transforms::sc_array_t +function sc_options_load_json(package_id, err_priority, opt, jsonfile, re) + @ccall libsc.sc_options_load_json(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, jsonfile::Cstring, re::Ptr{Cvoid})::Cint end """ - p4est_neighbor_transform_t + sc_options_save(package_id, err_priority, opt, inifile) -Generic interface for transformations between a tree and any of its neighbors +Save all options and arguments to a file in `.ini` format. This function must only be called after successful option parsing. This function should only be called on rank 0. This function will log errors with category [`SC_LC_GLOBAL`](@ref). An options whose name contains a colon such as "Prefix:basename" will be written in a section titled [Prefix] as "basename =". -| Field | Note | -| :---------------- | :-------------------------------------------------------------------------- | -| neighbor\\_type | type of connection to neighbor | -| neighbor | neighbor tree index | -| index\\_self | index of interface from self's perspective | -| index\\_neighbor | index of interface from neighbor's perspective | -| perm | permutation of dimensions when transforming self coords to neighbor coords | -| sign | sign changes when transforming self coords to neighbor coords | -| origin\\_self | point on the interface from self's perspective | -| origin\\_neighbor | point on the interface from neighbor's perspective | +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `inifile`:\\[in\\] Filename of the ini file to save. +# Returns +Returns 0 on success, -1 on failure. +### Prototype +```c +int sc_options_save (int package_id, int err_priority, sc_options_t * opt, const char *inifile); +``` """ -struct p4est_neighbor_transform_t - neighbor_type::p4est_connect_type_t - neighbor::p4est_topidx_t - index_self::Int8 - index_neighbor::Int8 - perm::NTuple{2, Int8} - sign::NTuple{2, Int8} - origin_self::NTuple{2, p4est_qcoord_t} - origin_neighbor::NTuple{2, p4est_qcoord_t} +function sc_options_save(package_id, err_priority, opt, inifile) + @ccall libsc.sc_options_save(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring)::Cint end """ - p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + sc_options_load_args(package_id, err_priority, opt, inifile) -Transform from self's coordinate system to neighbor's coordinate system. +Load a file in `.ini` format and update entries found under [Arguments]. There needs to be a key Arguments.count specifying the number. Then as many integer keys starting with 0 need to be present. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The args are stored in this option structure. +* `inifile`:\\[in\\] Filename of the ini file to load. +# Returns +Returns 0 on success, -1 on failure. ### Prototype ```c -void p4est_neighbor_transform_coordinates (const p4est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P4EST_DIM], p4est_qcoord_t neigh_coords[P4EST_DIM]); +int sc_options_load_args (int package_id, int err_priority, sc_options_t * opt, const char *inifile); ``` """ -function p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) - @ccall libp4est.p4est_neighbor_transform_coordinates(nt::Ptr{p4est_neighbor_transform_t}, self_coords::Ptr{p4est_qcoord_t}, neigh_coords::Ptr{p4est_qcoord_t})::Cvoid +function sc_options_load_args(package_id, err_priority, opt, inifile) + @ccall libsc.sc_options_load_args(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring)::Cint end """ - p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + sc_options_parse(package_id, err_priority, opt, argc, argv) -Transform from neighbor's coordinate system to self's coordinate system. +Parse command line options. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `argc`:\\[in\\] Length of argument list. +* `argv`:\\[in,out\\] Argument list may be permuted. +# Returns +Returns -1 on an invalid option, otherwise the position of the first non-option argument. ### Prototype ```c -void p4est_neighbor_transform_coordinates_reverse (const p4est_neighbor_transform_t * nt, const p4est_qcoord_t neigh_coords[P4EST_DIM], p4est_qcoord_t self_coords[P4EST_DIM]); +int sc_options_parse (int package_id, int err_priority, sc_options_t * opt, int argc, char **argv); ``` """ -function p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) - @ccall libp4est.p4est_neighbor_transform_coordinates_reverse(nt::Ptr{p4est_neighbor_transform_t}, neigh_coords::Ptr{p4est_qcoord_t}, self_coords::Ptr{p4est_qcoord_t})::Cvoid +function sc_options_parse(package_id, err_priority, opt, argc, argv) + @ccall libsc.sc_options_parse(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, argc::Cint, argv::Ptr{Cstring})::Cint end """ - p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) - -Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects + t8_cmesh_from_tetgen_file(fileprefix, partition, comm, do_dup) -# Arguments -* `conn`:\\[in\\] Connectivity structure. -* `tree_id`:\\[in\\] The number of the tree. -* `boundary_type`:\\[in\\] The type of the boundary connection (self, face, corner). -* `boundary_index`:\\[in\\] The index of the boundary. -* `neighbor_transform_array`:\\[in,out\\] Array of the neighbor transforms. ### Prototype ```c -void p4est_connectivity_get_neighbor_transforms (p4est_connectivity_t *conn, p4est_topidx_t tree_id, p4est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array); +t8_cmesh_t t8_cmesh_from_tetgen_file (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup); ``` """ -function p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) - @ccall libp4est.p4est_connectivity_get_neighbor_transforms(conn::Ptr{p4est_connectivity_t}, tree_id::p4est_topidx_t, boundary_type::p4est_connect_type_t, boundary_index::Cint, neighbor_transform_array::Ptr{sc_array_t})::Cvoid +function t8_cmesh_from_tetgen_file(fileprefix, partition, comm, do_dup) + @ccall libt8.t8_cmesh_from_tetgen_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint)::t8_cmesh_t end """ - p4est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) - -Determine the owning tree for a coordinate and transform it there. - -On a boundary between trees, different coordinate systems meet. A coordinate on a tree boundary face or corner generated from the perspective of a specific tree may be transformed into any other touching tree's coordinate system and still refer to the same point in the mesh. + t8_cmesh_from_tetgen_file_time(fileprefix, partition, comm, do_dup, fi, snapshot, stats, statentry) -To uniquely identify a coordinate, this function identifies the lowest numbered tree touching this coordinate and transforms the coordinates into that system. The result can be used e. g. in topology hash tables. - -# Arguments -* `conn`:\\[in\\] A valid connectivity. -* `treeid`:\\[in\\] The original tree index for this coordinate tuple. -* `coords`:\\[in\\] A valid coordinate 2-tuple relative to *treeid*. -* `treeid_out`:\\[out\\] The lowest tree index touching the coordinate. -* `coords_out`:\\[out\\] The input coordinates, if necessary after transformation into the system of the lowest numbered tree, returned in *treeid_out*. ### Prototype ```c -void p4est_connectivity_coordinates_canonicalize (p4est_connectivity_t *conn, p4est_topidx_t treeid, const p4est_qcoord_t coords[], p4est_topidx_t *treeid_out, p4est_qcoord_t coords_out[]); +t8_cmesh_t t8_cmesh_from_tetgen_file_time (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup, sc_flopinfo_t *fi, sc_flopinfo_t *snapshot, sc_statinfo_t *stats, int statentry); ``` """ -function p4est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) - @ccall libp4est.p4est_connectivity_coordinates_canonicalize(conn::Ptr{p4est_connectivity_t}, treeid::p4est_topidx_t, coords::Ptr{p4est_qcoord_t}, treeid_out::Ptr{p4est_topidx_t}, coords_out::Ptr{p4est_qcoord_t})::Cvoid +function t8_cmesh_from_tetgen_file_time(fileprefix, partition, comm, do_dup, fi, snapshot, stats, statentry) + @ccall libt8.t8_cmesh_from_tetgen_file_time(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint, fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t}, stats::Ptr{sc_statinfo_t}, statentry::Cint)::t8_cmesh_t end """ - p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) - -Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. + t8_cmesh_from_triangle_file(fileprefix, partition, comm, do_dup) -# Arguments -* `fc`:\\[in\\] A face corner number in 0..1. -* `f`:\\[in\\] A face that the face corner number *fc* is relative to. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. -# Returns -The face corner number relative to the neighbor's face. ### Prototype ```c -int p4est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); +t8_cmesh_t t8_cmesh_from_triangle_file (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup); ``` """ -function p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) - @ccall libp4est.p4est_connectivity_face_neighbor_face_corner(fc::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_cmesh_from_triangle_file(fileprefix, partition, comm, do_dup) + @ccall libt8.t8_cmesh_from_triangle_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint)::t8_cmesh_t end """ - p4est_connectivity_face_neighbor_corner(c, f, nf, o) + t8_eclass_count_boundary(theclass, min_dim, per_eclass) -Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Query the element class and count of boundary points. # Arguments -* `c`:\\[in\\] A corner number in 0..3. -* `f`:\\[in\\] A face number that touches the corner *c*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +* `theclass`:\\[in\\] We query a point of this element class. +* `min_dim`:\\[in\\] Ignore boundary points of lesser dimension. The ignored points get a count value of 0. +* `per_eclass`:\\[out\\] Array of length T8\\_ECLASS\\_COUNT to be filled with the count of the boundary objects, counted per each of the element classes. # Returns -The number of the corner seen from the neighbor tree. +The count over all boundary points. ### Prototype ```c -int p4est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); +int t8_eclass_count_boundary (t8_eclass_t theclass, int min_dim, int *per_eclass); ``` """ -function p4est_connectivity_face_neighbor_corner(c, f, nf, o) - @ccall libp4est.p4est_connectivity_face_neighbor_corner(c::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_eclass_count_boundary(theclass, min_dim, per_eclass) + @ccall libt8.t8_eclass_count_boundary(theclass::t8_eclass_t, min_dim::Cint, per_eclass::Ptr{Cint})::Cint end """ - p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) + t8_eclass_compare(eclass1, eclass2) -Allocate a connectivity structure. The attribute fields are initialized to NULL. +Compare two eclasses of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. # Arguments -* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). -* `num_trees`:\\[in\\] Number of trees in the forest. -* `num_corners`:\\[in\\] Number of tree-connecting corners. -* `num_ctt`:\\[in\\] Number of total trees in corner\\_to\\_tree array. +* `eclass1`:\\[in\\] The first eclass to compare. +* `eclass2`:\\[in\\] The second eclass to compare. # Returns -A connectivity structure with allocated arrays. +0 if the eclasses are equal, 1 if eclass1 > eclass2 and -1 if eclass1 < eclass2 ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, p4est_topidx_t num_ctt); +int t8_eclass_compare (t8_eclass_t eclass1, t8_eclass_t eclass2); ``` """ -function p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) - @ccall libp4est.p4est_connectivity_new(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_corners::p4est_topidx_t, num_ctt::p4est_topidx_t)::Ptr{p4est_connectivity_t} +function t8_eclass_compare(eclass1, eclass2) + @ccall libt8.t8_eclass_compare(eclass1::t8_eclass_t, eclass2::t8_eclass_t)::Cint end """ - p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) + t8_eclass_is_valid(eclass) -Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. +Check whether a class is a valid class. Returns non-zero if it is a valid class, returns zero, if the class is equal to T8\\_ECLASS\\_INVALID. # Arguments -* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). -* `num_trees`:\\[in\\] Number of trees in the forest. -* `num_corners`:\\[in\\] Number of tree-connecting corners. -* `vertices`:\\[in\\] Coordinates of the vertices of the trees. -* `ttv`:\\[in\\] The tree-to-vertex array. -* `ttt`:\\[in\\] The tree-to-tree array. -* `ttf`:\\[in\\] The tree-to-face array (int8\\_t). -* `ttc`:\\[in\\] The tree-to-corner array. -* `coff`:\\[in\\] Corner-to-tree offsets (num\\_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. -* `ctt`:\\[in\\] The corner-to-tree array. -* `ctc`:\\[in\\] The corner-to-corner array. +* `eclass`:\\[in\\] The eclass to check. # Returns -The connectivity is checked for validity. +Non-zero if *eclass* is valid, zero otherwise. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc); +int t8_eclass_is_valid (t8_eclass_t eclass); ``` """ -function p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) - @ccall libp4est.p4est_connectivity_new_copy(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_corners::p4est_topidx_t, vertices::Ptr{Cdouble}, ttv::Ptr{p4est_topidx_t}, ttt::Ptr{p4est_topidx_t}, ttf::Ptr{Int8}, ttc::Ptr{p4est_topidx_t}, coff::Ptr{p4est_topidx_t}, ctt::Ptr{p4est_topidx_t}, ctc::Ptr{Int8})::Ptr{p4est_connectivity_t} +function t8_eclass_is_valid(eclass) + @ccall libt8.t8_eclass_is_valid(eclass::t8_eclass_t)::Cint end +mutable struct t8_element end + +"""Opaque structure for a generic element, only used as pointer. Implementations are free to cast it to their internal data structure.""" +const t8_element_t = t8_element + """ - p4est_connectivity_copy(input, copy_attr) + t8_scheme_cxx_ref(scheme) -Deep copy a connectivity structure. +Increase the reference counter of a scheme. # Arguments -* `input`:\\[in\\] Valid connectivity. -* `copy_attr`:\\[in\\] If true, we copy the tree attribute data. Otherwise, the result has empty attributes. -# Returns -A connectivity equal to the first one except, depending on *copy_attry*, for its attributes. +* `scheme`:\\[in,out\\] On input, this scheme must be alive, that is, exist with positive reference count. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_copy (p4est_connectivity_t *input, int copy_attr); +void t8_scheme_cxx_ref (t8_scheme_cxx_t *scheme); ``` """ -function p4est_connectivity_copy(input, copy_attr) - @ccall libp4est.p4est_connectivity_copy(input::Ptr{p4est_connectivity_t}, copy_attr::Cint)::Ptr{p4est_connectivity_t} +function t8_scheme_cxx_ref(scheme) + @ccall libt8.t8_scheme_cxx_ref(scheme::Ptr{t8_scheme_cxx_t})::Cvoid end """ - p4est_connectivity_bcast(conn_in, root, comm) + t8_scheme_cxx_unref(pscheme) + +Decrease the reference counter of a scheme. If the counter reaches zero, this scheme is destroyed. +# Arguments +* `pscheme`:\\[in,out\\] On input, the scheme pointed to must exist with positive reference count. If the reference count reaches zero, the scheme is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the scheme is not modified in other ways. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_bcast (p4est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +void t8_scheme_cxx_unref (t8_scheme_cxx_t **pscheme); ``` """ -function p4est_connectivity_bcast(conn_in, root, comm) - @ccall libp4est.p4est_connectivity_bcast(conn_in::Ptr{p4est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p4est_connectivity_t} +function t8_scheme_cxx_unref(pscheme) + @ccall libt8.t8_scheme_cxx_unref(pscheme::Ptr{Ptr{t8_scheme_cxx_t}})::Cvoid end """ - p4est_connectivity_destroy(connectivity) - -Destroy a connectivity structure. Also destroy all attributes. + t8_scheme_cxx_destroy(s) ### Prototype ```c -void p4est_connectivity_destroy (p4est_connectivity_t * connectivity); +extern void t8_scheme_cxx_destroy (t8_scheme_cxx_t *s); ``` """ -function p4est_connectivity_destroy(connectivity) - @ccall libp4est.p4est_connectivity_destroy(connectivity::Ptr{p4est_connectivity_t})::Cvoid +function t8_scheme_cxx_destroy(s) + @ccall libt8.t8_scheme_cxx_destroy(s::Ptr{t8_scheme_cxx_t})::Cvoid end """ - p4est_connectivity_share(conn_in, root, comm) + t8_element_size(ts) + +Return the size of any element of a given class. +# Returns +The size of an element of class **ts**. We provide a default implementation of this routine that should suffice for most use cases. ### Prototype ```c -p4est_connectivity_shared_t *p4est_connectivity_share (p4est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +size_t t8_element_size (const t8_eclass_scheme_c *ts); ``` """ -function p4est_connectivity_share(conn_in, root, comm) - @ccall libp4est.p4est_connectivity_share(conn_in::Ptr{p4est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p4est_connectivity_shared_t} +function t8_element_size(ts) + @ccall libt8.t8_element_size(ts::Ptr{t8_eclass_scheme_c})::Csize_t end """ - p4est_connectivity_mission(conn_in, split_type, world_comm) + t8_element_refines_irregular(ts) + +Returns true, if there is one element in the tree, that does not refine into 2^dim children. Returns false otherwise. ### Prototype ```c -p4est_connectivity_shared_t * p4est_connectivity_mission (p4est_connectivity_t *conn_in, int split_type, sc_MPI_Comm world_comm); +int t8_element_refines_irregular (const t8_eclass_scheme_c *ts); ``` """ -function p4est_connectivity_mission(conn_in, split_type, world_comm) - @ccall libp4est.p4est_connectivity_mission(conn_in::Ptr{p4est_connectivity_t}, split_type::Cint, world_comm::Cint)::Ptr{p4est_connectivity_shared_t} +function t8_element_refines_irregular(ts) + @ccall libt8.t8_element_refines_irregular(ts::Ptr{t8_eclass_scheme_c})::Cint end """ - p4est_connectivity_shared_destroy(cshare) + t8_element_maxlevel(ts) -Destroy a shared connectivity structure. Call this eventually on the result of p4est_connectivity_share or p4est_connectivity_mission (which calls the former internally). +Return the maximum allowed level for any element of a given class. # Arguments -* `cshare`:\\[in\\] Valid shared connectivity structure; cf. p4est_connectivity_share. +* `ts`:\\[in\\] Implementation of a class scheme. +# Returns +The maximum allowed level for elements of class **ts**. ### Prototype ```c -void p4est_connectivity_shared_destroy (p4est_connectivity_shared_t *cshare); +int t8_element_maxlevel (const t8_eclass_scheme_c *ts); ``` """ -function p4est_connectivity_shared_destroy(cshare) - @ccall libp4est.p4est_connectivity_shared_destroy(cshare::Ptr{p4est_connectivity_shared_t})::Cvoid +function t8_element_maxlevel(ts) + @ccall libt8.t8_element_maxlevel(ts::Ptr{t8_eclass_scheme_c})::Cint end """ - p4est_connectivity_set_attr(conn, bytes_per_tree) + t8_element_level(ts, elem) -Allocate or free the attribute fields in a connectivity. - -# Arguments -* `conn`:\\[in,out\\] The conn->*\\_to\\_attr fields must either be NULL or previously be allocated by this function. -* `bytes_per_tree`:\\[in\\] If 0, tree\\_to\\_attr is freed (being NULL is ok). If positive, requested space is allocated. ### Prototype ```c -void p4est_connectivity_set_attr (p4est_connectivity_t * conn, size_t bytes_per_tree); +int t8_element_level (const t8_eclass_scheme_c *ts, const t8_element_t *elem); ``` """ -function p4est_connectivity_set_attr(conn, bytes_per_tree) - @ccall libp4est.p4est_connectivity_set_attr(conn::Ptr{p4est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid +function t8_element_level(ts, elem) + @ccall libt8.t8_element_level(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint end """ - p4est_connectivity_is_valid(connectivity) + t8_element_copy(ts, source, dest) -Examine a connectivity structure. +Copy all entries of **source** to **dest**. **dest** must be an existing element. No memory is allocated by this function. -# Returns -Returns true if structure is valid, false otherwise. +!!! note + + *source* and *dest* may point to the same element. + +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `source`:\\[in\\] The element whose entries will be copied to **dest**. +* `dest`:\\[in,out\\] This element's entries will be overwritten with the entries of **source**. ### Prototype ```c -int p4est_connectivity_is_valid (p4est_connectivity_t * connectivity); +void t8_element_copy (const t8_eclass_scheme_c *ts, const t8_element_t *source, t8_element_t *dest); ``` """ -function p4est_connectivity_is_valid(connectivity) - @ccall libp4est.p4est_connectivity_is_valid(connectivity::Ptr{p4est_connectivity_t})::Cint +function t8_element_copy(ts, source, dest) + @ccall libt8.t8_element_copy(ts::Ptr{t8_eclass_scheme_c}, source::Ptr{t8_element_t}, dest::Ptr{t8_element_t})::Cvoid end """ - p4est_connectivity_is_equal(conn1, conn2) + t8_element_compare(ts, elem1, elem2) -Check two connectivity structures for equality. +Compare two elements with respect to the scheme. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem1`:\\[in\\] The first element. +* `elem2`:\\[in\\] The second element. # Returns -Returns true if structures are equal, false otherwise. +negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. If elem2 is a copy of elem1 then the elements are equal. ### Prototype ```c -int p4est_connectivity_is_equal (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); +int t8_element_compare (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2); ``` """ -function p4est_connectivity_is_equal(conn1, conn2) - @ccall libp4est.p4est_connectivity_is_equal(conn1::Ptr{p4est_connectivity_t}, conn2::Ptr{p4est_connectivity_t})::Cint +function t8_element_compare(ts, elem1, elem2) + @ccall libt8.t8_element_compare(ts::Ptr{t8_eclass_scheme_c}, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint end """ - p4est_connectivity_sink(conn, sink) + t8_element_equal(ts, elem1, elem2) -Write connectivity to a sink object. +Check if two elements are equal. # Arguments -* `conn`:\\[in\\] The connectivity to be written. -* `sink`:\\[in,out\\] The connectivity is written into this sink. +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem1`:\\[in\\] The first element. +* `elem2`:\\[in\\] The second element. # Returns -0 on success, nonzero on error. +1 if the elements are equal, 0 if they are not equal ### Prototype ```c -int p4est_connectivity_sink (p4est_connectivity_t * conn, sc_io_sink_t * sink); +int t8_element_equal (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2); ``` """ -function p4est_connectivity_sink(conn, sink) - @ccall libp4est.p4est_connectivity_sink(conn::Ptr{p4est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint +function t8_element_equal(ts, elem1, elem2) + @ccall libt8.t8_element_equal(ts::Ptr{t8_eclass_scheme_c}, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint end """ - p4est_connectivity_deflate(conn, code) + t8_element_parent(ts, elem, parent) -Allocate memory and store the connectivity information there. +Compute the parent of a given element **elem** and store it in **parent**. **parent** needs to be an existing element. No memory is allocated by this function. **elem** and **parent** can point to the same element, then the entries of **elem** are overwritten by the ones of its parent. # Arguments -* `conn`:\\[in\\] The connectivity structure to be exported to memory. -* `code`:\\[in\\] Encoding and compression method for serialization. -# Returns -Newly created array that contains the information. +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element whose parent will be computed. +* `parent`:\\[in,out\\] This element's entries will be overwritten by those of **elem**'s parent. The storage for this element must exist and match the element class of the parent. ### Prototype ```c -sc_array_t *p4est_connectivity_deflate (p4est_connectivity_t * conn, p4est_connectivity_encode_t code); +void t8_element_parent (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *parent); ``` """ -function p4est_connectivity_deflate(conn, code) - @ccall libp4est.p4est_connectivity_deflate(conn::Ptr{p4est_connectivity_t}, code::p4est_connectivity_encode_t)::Ptr{sc_array_t} +function t8_element_parent(ts, elem, parent) + @ccall libt8.t8_element_parent(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, parent::Ptr{t8_element_t})::Cvoid end """ - p4est_connectivity_save(filename, connectivity) + t8_element_num_siblings(ts, elem) -Save a connectivity structure to disk. +Compute the number of siblings of an element. That is the number of Children of its parent. # Arguments -* `filename`:\\[in\\] Name of the file to write. -* `connectivity`:\\[in\\] Valid connectivity structure. +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. # Returns -Returns 0 on success, nonzero on file error. +The number of siblings of *element*. Note that this number is >= 1, since we count the element itself as a sibling. ### Prototype ```c -int p4est_connectivity_save (const char *filename, p4est_connectivity_t * connectivity); +int t8_element_num_siblings (const t8_eclass_scheme_c *ts, const t8_element_t *elem); ``` """ -function p4est_connectivity_save(filename, connectivity) - @ccall libp4est.p4est_connectivity_save(filename::Cstring, connectivity::Ptr{p4est_connectivity_t})::Cint +function t8_element_num_siblings(ts, elem) + @ccall libt8.t8_element_num_siblings(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint end """ - p4est_connectivity_source(source) + t8_element_sibling(ts, elem, sibid, sibling) -Read connectivity from a source object. +Compute a specific sibling of a given element **elem** and store it in **sibling**. **sibling** needs to be an existing element. No memory is allocated by this function. **elem** and **sibling** can point to the same element, then the entries of **elem** are overwritten by the ones of its i-th sibling. # Arguments -* `source`:\\[in,out\\] The connectivity is read from this source. -# Returns -The newly created connectivity, or NULL on error. +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element whose sibling will be computed. +* `sibid`:\\[in\\] The id of the sibling computed. +* `sibling`:\\[in,out\\] This element's entries will be overwritten by those of **elem**'s sibid-th sibling. The storage for this element must exist and match the element class of the sibling. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_source (sc_io_source_t * source); +void t8_element_sibling (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int sibid, t8_element_t *sibling); ``` """ -function p4est_connectivity_source(source) - @ccall libp4est.p4est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p4est_connectivity_t} +function t8_element_sibling(ts, elem, sibid, sibling) + @ccall libt8.t8_element_sibling(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, sibid::Cint, sibling::Ptr{t8_element_t})::Cvoid end """ - p4est_connectivity_inflate(buffer) + t8_element_num_corners(ts, elem) -Create new connectivity from a memory buffer. This function aborts on malloc errors. +Compute the number of corners of an element. # Arguments -* `buffer`:\\[in\\] The connectivity is created from this memory buffer. +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. # Returns -The newly created connectivity, or NULL on format error of the buffered connectivity data. +The number of corners of *element*. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_inflate (sc_array_t * buffer); +int t8_element_num_corners (const t8_eclass_scheme_c *ts, const t8_element_t *elem); ``` """ -function p4est_connectivity_inflate(buffer) - @ccall libp4est.p4est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p4est_connectivity_t} +function t8_element_num_corners(ts, elem) + @ccall libt8.t8_element_num_corners(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint end """ - p4est_connectivity_load(filename, bytes) + t8_element_num_faces(ts, elem) -Load a connectivity structure from disk. +Compute the number of faces of an element. # Arguments -* `filename`:\\[in\\] Name of the file to read. -* `bytes`:\\[in,out\\] Size in bytes of connectivity on disk or NULL. +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. # Returns -Returns valid connectivity, or NULL on file error. +The number of faces of *element*. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_load (const char *filename, size_t *bytes); +int t8_element_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem); ``` """ -function p4est_connectivity_load(filename, bytes) - @ccall libp4est.p4est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p4est_connectivity_t} +function t8_element_num_faces(ts, elem) + @ccall libt8.t8_element_num_faces(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint end """ - p4est_connectivity_new_unitsquare() + t8_element_max_num_faces(ts, elem) -Create a connectivity structure for the unit square. +Compute the maximum number of faces of a given element and all of its descendants. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. +# Returns +The number of faces of *element*. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_unitsquare (void); +int t8_element_max_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem); ``` """ -function p4est_connectivity_new_unitsquare() - @ccall libp4est.p4est_connectivity_new_unitsquare()::Ptr{p4est_connectivity_t} +function t8_element_max_num_faces(ts, elem) + @ccall libt8.t8_element_max_num_faces(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint end """ - p4est_connectivity_new_periodic() + t8_element_num_children(ts, elem) -Create a connectivity structure for an all-periodic unit square. +Compute the number of children of an element when it is refined. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. +# Returns +The number of children of *element*. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_periodic (void); +int t8_element_num_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem); ``` """ -function p4est_connectivity_new_periodic() - @ccall libp4est.p4est_connectivity_new_periodic()::Ptr{p4est_connectivity_t} +function t8_element_num_children(ts, elem) + @ccall libt8.t8_element_num_children(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint end """ - p4est_connectivity_new_rotwrap() + t8_element_num_face_children(ts, elem, face) -Create a connectivity structure for a periodic unit square. The left and right faces are identified, and bottom and top opposite. +Compute the number of children of an element's face when the element is refined. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. +* `face`:\\[in\\] A face of *elem*. +# Returns +The number of children of *face* if *elem* is to be refined. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_rotwrap (void); +int t8_element_num_face_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); ``` """ -function p4est_connectivity_new_rotwrap() - @ccall libp4est.p4est_connectivity_new_rotwrap()::Ptr{p4est_connectivity_t} +function t8_element_num_face_children(ts, elem, face) + @ccall libt8.t8_element_num_face_children(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::Cint end """ - p4est_connectivity_new_circle() + t8_element_get_face_corner(ts, elem, face, corner) -Create a connectivity structure for an donut-like circle. The circle consists of 6 trees connecting each other by their faces. The trees are laid out as a hexagon between [-2, 2] in the y direction and [-sqrt(3), sqrt(3)] in the x direction. The hexagon has flat sides along the y direction and pointy ends in x. +Return the corner number of an element's face corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 Thus for face = 1 the output is: corner=0 : 1, corner=1: 3 + +The order in which the corners must be given is determined by the eclass of *element*: LINE/QUAD/TRIANGLE: No specific order. HEX : In Z-order of the face starting with the lowest corner number. TET : Starting with the lowest corner number counterclockwise as seen from 'outside' of the element. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] A face index for *element*. +* `corner`:\\[in\\] A corner index for the face 0 <= *corner* < num\\_face\\_corners. +# Returns +The corner number of the *corner*-th vertex of *face*. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_circle (void); +int t8_element_get_face_corner (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int corner); ``` """ -function p4est_connectivity_new_circle() - @ccall libp4est.p4est_connectivity_new_circle()::Ptr{p4est_connectivity_t} +function t8_element_get_face_corner(ts, elem, face, corner) + @ccall libt8.t8_element_get_face_corner(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint, corner::Cint)::Cint end """ - p4est_connectivity_new_drop() + t8_element_get_corner_face(ts, elem, corner, face) -Create a connectivity structure for a five-trees geometry with a hole. The geometry covers the square [0, 3]**2, where the hole is [1, 2]**2. +Compute the face numbers of the faces sharing an element's corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 face 2 Thus for corner = 1 the output is: face=0 : 2, face=1: 1 +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `element`:\\[in\\] The element. +* `corner`:\\[in\\] A corner index for the face. +* `face`:\\[in\\] A face index for *corner*. +# Returns +The face number of the *face*-th face at *corner*. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_drop (void); +int t8_element_get_corner_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int corner, int face); ``` """ -function p4est_connectivity_new_drop() - @ccall libp4est.p4est_connectivity_new_drop()::Ptr{p4est_connectivity_t} +function t8_element_get_corner_face(ts, elem, corner, face) + @ccall libt8.t8_element_get_corner_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, corner::Cint, face::Cint)::Cint end """ - p4est_connectivity_new_twotrees(l_face, r_face, orientation) + t8_element_child(ts, elem, childid, child) -Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way +Construct the child element of a given number. # Arguments -* `l_face`:\\[in\\] index of left face -* `r_face`:\\[in\\] index of right face -* `orientation`:\\[in\\] orientation of trees w.r.t. each other +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] This must be a valid element, bigger than maxlevel. +* `childid`:\\[in\\] The number of the child to construct. +* `child`:\\[in,out\\] The storage for this element must exist. On output, a valid element. It is valid to call this function with elem = child. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_twotrees (int l_face, int r_face, int orientation); +void t8_element_child (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int childid, t8_element_t *child); ``` """ -function p4est_connectivity_new_twotrees(l_face, r_face, orientation) - @ccall libp4est.p4est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p4est_connectivity_t} +function t8_element_child(ts, elem, childid, child) + @ccall libt8.t8_element_child(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, childid::Cint, child::Ptr{t8_element_t})::Cvoid end """ - p4est_connectivity_new_corner() + t8_element_children(ts, elem, length, c) -Create a connectivity structure for a three-tree mesh around a corner. +Construct all children of a given element. + +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] This must be a valid element, bigger than maxlevel. +* `length`:\\[in\\] The length of the output array *c* must match the number of children. +* `c`:\\[in,out\\] The storage for these *length* elements must exist and match the element class in the children's ordering. On output, all children are valid. It is valid to call this function with elem = c[0]. +# See also +[`t8_element_num_children`](@ref) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_corner (void); +void t8_element_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int length, t8_element_t *c[]); ``` """ -function p4est_connectivity_new_corner() - @ccall libp4est.p4est_connectivity_new_corner()::Ptr{p4est_connectivity_t} +function t8_element_children(ts, elem, length, c) + @ccall libt8.t8_element_children(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, length::Cint, c::Ptr{Ptr{t8_element_t}})::Cvoid end """ - p4est_connectivity_new_pillow() + t8_element_child_id(ts, elem) -Create a connectivity structure for two trees on top of each other. +Compute the child id of an element. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] This must be a valid element. +# Returns +The child id of elem. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_pillow (void); +int t8_element_child_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem); ``` """ -function p4est_connectivity_new_pillow() - @ccall libp4est.p4est_connectivity_new_pillow()::Ptr{p4est_connectivity_t} +function t8_element_child_id(ts, elem) + @ccall libt8.t8_element_child_id(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint end """ - p4est_connectivity_new_moebius() + t8_element_ancestor_id(ts, elem, level) -Create a connectivity structure for a five-tree moebius band. +Compute the ancestor id of an element, that is the child id at a given level. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] This must be a valid element. +* `level`:\\[in\\] A refinement level. Must satisfy *level* < elem.level +# Returns +The child\\_id of *elem* in regard to its *level* ancestor. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_moebius (void); +int t8_element_ancestor_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int level); ``` """ -function p4est_connectivity_new_moebius() - @ccall libp4est.p4est_connectivity_new_moebius()::Ptr{p4est_connectivity_t} +function t8_element_ancestor_id(ts, elem, level) + @ccall libt8.t8_element_ancestor_id(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, level::Cint)::Cint end """ - p4est_connectivity_new_star() + t8_element_is_family(ts, fam) -Create a connectivity structure for a six-tree star. +Query whether a given set of elements is a family or not. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `fam`:\\[in\\] An array of as many elements as an element of class **ts** has children. +# Returns +Zero if **fam** is not a family, nonzero if it is. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_star (void); +int t8_element_is_family (const t8_eclass_scheme_c *ts, t8_element_t *const *fam); ``` """ -function p4est_connectivity_new_star() - @ccall libp4est.p4est_connectivity_new_star()::Ptr{p4est_connectivity_t} +function t8_element_is_family(ts, fam) + @ccall libt8.t8_element_is_family(ts::Ptr{t8_eclass_scheme_c}, fam::Ptr{Ptr{t8_element_t}})::Cint end """ - p4est_connectivity_new_cubed() + t8_element_nca(ts, elem1, elem2, nca) -Create a connectivity structure for the six sides of a unit cube. The ordering of the trees is as follows: - -0 1 2 3 <-- 3: axis-aligned top side 4 5 - -This choice has been made for maximum symmetry (see tree\\_to\\_* in .c file). +Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both given elements as descendants. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem1`:\\[in\\] The first of the two input elements. +* `elem2`:\\[in\\] The second of the two input elements. +* `nca`:\\[in,out\\] The storage for this element must exist and match the element class of the child. On output the unique nearest common ancestor of **elem1** and **elem2**. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_cubed (void); +void t8_element_nca (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca); ``` """ -function p4est_connectivity_new_cubed() - @ccall libp4est.p4est_connectivity_new_cubed()::Ptr{p4est_connectivity_t} +function t8_element_nca(ts, elem1, elem2, nca) + @ccall libt8.t8_element_nca(ts::Ptr{t8_eclass_scheme_c}, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t}, nca::Ptr{t8_element_t})::Cvoid end +"""Type definition for the geometric shape of an element. Currently the possible shapes are the same as the possible element classes. I.e. T8\\_ECLASS\\_VERTEX, T8\\_ECLASS\\_TET, etc...""" +const t8_element_shape_t = t8_eclass_t + """ - p4est_connectivity_new_disk_nonperiodic() + t8_element_face_shape(ts, elem, face) -Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2. +Compute the shape of the face of an element. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. +* `face`:\\[in\\] A face of *elem*. # Returns -Initialized and usable connectivity. +The element shape of the face. I.e. T8\\_ECLASS\\_LINE for quads, T8\\_ECLASS\\_TRIANGLE for tets and depending on the face number either T8\\_ECLASS\\_QUAD or T8\\_ECLASS\\_TRIANGLE for prisms. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk_nonperiodic (void); +t8_element_shape_t t8_element_face_shape (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); ``` """ -function p4est_connectivity_new_disk_nonperiodic() - @ccall libp4est.p4est_connectivity_new_disk_nonperiodic()::Ptr{p4est_connectivity_t} +function t8_element_face_shape(ts, elem, face) + @ccall libt8.t8_element_face_shape(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::t8_element_shape_t end """ - p4est_connectivity_new_disk(periodic_a, periodic_b) + t8_element_children_at_face(ts, elem, face, children, num_children, child_indices) -Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2. +Given an element and a face of the element, compute all children of the element that touch the face. -!!! note +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. +* `face`:\\[in\\] A face of *elem*. +* `children`:\\[in,out\\] Allocated elements, in which the children of *elem* that share a face with *face* are stored. They will be stored in order of their linear id. +* `num_children`:\\[in\\] The number of elements in *children*. Must match the number of children that touch *face*. t8_element_num_face_children +* `child_indices`:\\[in,out\\] If not NULL, an array of num\\_children integers must be given, on output its i-th entry is the child\\_id of the i-th face\\_child. It is valid to call this function with elem = children[0]. +### Prototype +```c +void t8_element_children_at_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, t8_element_t *children[], int num_children, int *child_indices); +``` +""" +function t8_element_children_at_face(ts, elem, face, children, num_children, child_indices) + @ccall libt8.t8_element_children_at_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint, children::Ptr{Ptr{t8_element_t}}, num_children::Cint, child_indices::Ptr{Cint})::Cvoid +end - The API of this function has changed to accept two arguments. You can query the P4EST_CONN_DISK_PERIODIC to check whether the new version with the argument is in effect. +""" + t8_element_face_child_face(ts, elem, face, face_child) -The ordering of the trees is as follows: +Given a face of an element and a child number of a child of that face, return the face number of the child of the element that matches the child face. -4 1 2 3 0 +```c++ + x ---- x x x x ---- x + | | | | | | | <-- f + | | | x | x--x + | | | | | + x ---- x x x ---- x + elem face face_child Returns the face number f +``` -The outside x faces may be identified topologically. The outside y faces may be identified topologically. Both identifications may be specified simultaneously. The general shape and periodicity are the same as those obtained with p4est_connectivity_new_brick (1, 1, periodic\\_a, periodic\\_b). +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. +* `face`:\\[in\\] Then number of the face. +* `face_child`:\\[in\\] A number 0 <= *face_child* < num\\_face\\_children, specifying a child of *elem* that shares a face with *face*. These children are counted in linear order. This coincides with the order of children from a call to t8_element_children_at_face. +# Returns +The face number of the face of a child of *elem* that coincides with *face_child*. +### Prototype +```c +int t8_element_face_child_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int face_child); +``` +""" +function t8_element_face_child_face(ts, elem, face, face_child) + @ccall libt8.t8_element_face_child_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint, face_child::Cint)::Cint +end -When setting *periodic_a* and *periodic_b* to false, the result is the same as that of p4est_connectivity_new_disk_nonperiodic. +""" + t8_element_face_parent_face(ts, elem, face) + +Given a face of an element return the face number of the parent of the element that matches the element's face. Or return -1 if no face of the parent matches the face. + +!!! note + + For the root element this function always returns *face*. # Arguments -* `periodic_a`:\\[in\\] Bool to make disk periodic in x direction. -* `periodic_b`:\\[in\\] Bool to make disk periodic in y direction. +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. +* `face`:\\[in\\] Then number of the face. # Returns -Initialized and usable connectivity. +If *face* of *elem* is also a face of *elem*'s parent, the face number of this face. Otherwise -1. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk (int periodic_a, int periodic_b); +int t8_element_face_parent_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); ``` """ -function p4est_connectivity_new_disk(periodic_a, periodic_b) - @ccall libp4est.p4est_connectivity_new_disk(periodic_a::Cint, periodic_b::Cint)::Ptr{p4est_connectivity_t} +function t8_element_face_parent_face(ts, elem, face) + @ccall libt8.t8_element_face_parent_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::Cint end """ - p4est_connectivity_new_icosahedron() + t8_element_tree_face(ts, elem, face) -Create a connectivity for mapping the sphere using an icosahedron. - -The regular icosadron is a polyhedron with 20 faces, each of which is an equilateral triangle. To build the p4est connectivity, we group faces 2 by 2 to from 10 quadrangles, and thus 10 trees. +Given an element and a face of this element. If the face lies on the tree boundary, return the face number of the tree face. If not the return value is arbitrary. -This connectivity is meant to be used together with p4est_geometry_new_icosahedron to map the sphere. +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem`:\\[in\\] The element. +* `face`:\\[in\\] The index of a face of *elem*. +# Returns +The index of the tree face that *face* is a subface of, if *face* is on a tree boundary. Any arbitrary integer if *is* not at a tree boundary. +### Prototype +```c +int t8_element_tree_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +``` +""" +function t8_element_tree_face(ts, elem, face) + @ccall libt8.t8_element_tree_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::Cint +end -The flat connectivity looks like that. Vextex numbering: +""" + t8_element_transform_face(ts, elem1, elem2, orientation, sign, is_smaller_face) -A00 A01 A02 A03 A04 / \\ / \\ / \\ / \\ / \\ A05---A06---A07---A08---A09---A10 \\ / \\ / \\ / \\ / \\ / \\ A11---A12---A13---A14---A15---A16 \\ / \\ / \\ / \\ / \\ / A17 A18 A19 A20 A21 +Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the trees and given the orientation of the tree connection, construct the face element of the respective tree neighbor that logically coincides with e but lies in the coordinate system of the neighbor tree. -Origin in A05. +!!! note -Tree numbering: + *elem1* and *elem2* may point to the same element. -0 2 4 6 8 1 3 5 7 9 +# Arguments +* `ts`:\\[in\\] Implementation of a class scheme. +* `elem1`:\\[in\\] The face element. +* `elem2`:\\[in,out\\] On return the face element *elem1* with respect to the coordinate system of the other tree. +* `orientation`:\\[in\\] The orientation of the tree-tree connection. +* `sign`:\\[in\\] Depending on the topological orientation of the two tree faces, either 0 (both faces have opposite orientation) or 1 (both faces have the same top. orientattion). t8_eclass_face_orientation +* `is_smaller_face`:\\[in\\] Flag to declare whether *elem1* belongs to the smaller face. A face f of tree T is smaller than f' of T' if either the eclass of T is smaller or if the classes are equal and f element\\_shape2 and -1 if element\\_shape1 < element\\_shape2 +### Prototype +```c +int t8_element_shape_compare (t8_element_shape_t element_shape1, t8_element_shape_t element_shape2); +``` """ -struct p8est_corner_transform_t - ntree::p4est_topidx_t - ncorner::Int8 +function t8_element_shape_compare(element_shape1, element_shape2) + @ccall libt8.t8_element_shape_compare(element_shape1::t8_element_shape_t, element_shape2::t8_element_shape_t)::Cint end """ - p8est_corner_info_t + t8_forest -Information about the neighbors of a corner +| Field | Note | +| :---------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| rc | Reference counter. | +| set\\_level | Level to use in new construction. | +| set\\_for\\_coarsening | Change partition to allow for one round of coarsening | +| cmesh | Coarse mesh to use. | +| scheme\\_cxx | Scheme for element types. | +| maxlevel | The maximum allowed refinement level for elements in this forest. | +| maxlevel\\_existing | If >= 0, the maximum occurring refinemnent level of a forest element. | +| do\\_dup | Communicator shall be duped. | +| dimension | Dimension inferred from **cmesh**. | +| incomplete\\_trees | Flag to check whether the forest has (potential) incomplete trees. A tree is incomplete if an element has been removed from it. Once an element got removed, the flag sets to 1 (true) and stays. For a committed forest this flag is either true on all ranks or false on all ranks. | +| set\\_from | Temporarily store source forest. | +| from\\_method | Method to derive from **set_from**. | +| set\\_adapt\\_fn | refinement and coarsen function. Called when **from_method** is set to [`T8_FOREST_FROM_ADAPT`](@ref). | +| set\\_adapt\\_recursive | Flag to decide whether coarsen and refine are carried out recursive | +| set\\_balance | Flag to decide whether to forest will be balance in t8_forest_commit. See t8_forest_set_balance. If 0, no balance. If 1 balance with repartitioning, if 2 balance without repartitioning, # See also [`t8_forest_balance`](@ref) | +| do\\_ghost | If True, a ghost layer will be created when the forest is committed. | +| ghost\\_type | If a ghost layer will be created, the type of neighbors that count as ghost. | +| ghost\\_algorithm | Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced 3 = top-down search and unbalanced. | +| user\\_data | Pointer for arbitrary user data. # See also [`t8_forest_set_user_data`](@ref). | +| user\\_function | Pointer for arbitrary user function. # See also [`t8_forest_set_user_function`](@ref). | +| t8code\\_data | Pointer for arbitrary data that is used internally. | +| committed | t8_forest_commit called? | +| mpisize | Number of MPI processes. | +| mpirank | Number of this MPI process. | +| first\\_local\\_tree | The global index of the first local tree on this process. If first\\_local\\_tree is larger than last\\_local\\_tree then this processor/forest is empty. See https://github.com/DLR-AMR/t8code/wiki/Tree-indexing | +| last\\_local\\_tree | The global index of the last local tree on this process. -1 if this processor is empty. | +| global\\_num\\_trees | The total number of global trees | +| ghosts | If not NULL, the ghost elements. # See also [`t8_forest_ghost`](@ref).h | +| element\\_offsets | If partitioned, for each process the global index of its first element. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | +| global\\_first\\_desc | If partitioned, for each process the linear id (at maxlevel) of its first element's first descendant. t8_element_set_linear_id. Stores 0 for empty processes. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | +| tree\\_offsets | If partitioned for each process the global index of its first local tree or -(first local tree) - 1 if the first tree on that process is shared. Since this is memory consuming we only construct it when needed. This array follows the same logic as *tree_offsets* in [`t8_cmesh_t`](@ref) | +| local\\_num\\_elements | Number of elements on this processor. | +| global\\_num\\_elements | Number of elements on all processors. | +| profile | If not NULL, runtimes and statistics about forest\\_commit are stored here. | +""" +# This struct is not supposed to be read and modified directly. +# Besides, there is a circular dependency with `t8_forest_t` +# leading to an error output by Julia. +mutable struct t8_forest end + +"""Opaque pointer to a forest implementation.""" +const t8_forest_t = Ptr{t8_forest} -| Field | Note | -| :------------------ | :------------------------------------------------ | -| icorner | The number of the originating corner | -| corner\\_transforms | The array of neighbors of the originating corner | """ -struct p8est_corner_info_t - icorner::p4est_topidx_t - corner_transforms::sc_array_t -end + t8_forest_write_netcdf(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm) +### Prototype +```c +void t8_forest_write_netcdf (t8_forest_t forest, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm); +``` """ - p8est_neighbor_transform_t +function t8_forest_write_netcdf(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm) + @ccall libt8.t8_forest_write_netcdf(forest::t8_forest_t, file_prefix::Cstring, file_title::Cstring, dim::Cint, num_extern_netcdf_vars::Cint, ext_variables::Ptr{Ptr{t8_netcdf_variable_t}}, comm::MPI_Comm)::Cvoid +end -Generic interface for transformations between a tree and any of its neighbors +""" + t8_forest_write_netcdf_ext(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm, netcdf_var_storage_mode, netcdf_var_mpi_access) -| Field | Note | -| :---------------- | :-------------------------------------------------------------------------- | -| neighbor\\_type | type of connection to neighbor | -| neighbor | neighbor tree index | -| index\\_self | index of interface from self's perspective | -| index\\_neighbor | index of interface from neighbor's perspective | -| perm | permutation of dimensions when transforming self coords to neighbor coords | -| sign | sign changes when transforming self coords to neighbor coords | -| origin\\_self | point on the interface from self's perspective | -| origin\\_neighbor | point on the interface from neighbor's perspective | +### Prototype +```c +void t8_forest_write_netcdf_ext (t8_forest_t forest, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm, int netcdf_var_storage_mode, int netcdf_var_mpi_access); +``` """ -struct p8est_neighbor_transform_t - neighbor_type::p8est_connect_type_t - neighbor::p4est_topidx_t - index_self::Int8 - index_neighbor::Int8 - perm::NTuple{3, Int8} - sign::NTuple{3, Int8} - origin_self::NTuple{3, p4est_qcoord_t} - origin_neighbor::NTuple{3, p4est_qcoord_t} +function t8_forest_write_netcdf_ext(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm, netcdf_var_storage_mode, netcdf_var_mpi_access) + @ccall libt8.t8_forest_write_netcdf_ext(forest::t8_forest_t, file_prefix::Cstring, file_title::Cstring, dim::Cint, num_extern_netcdf_vars::Cint, ext_variables::Ptr{Ptr{t8_netcdf_variable_t}}, comm::MPI_Comm, netcdf_var_storage_mode::Cint, netcdf_var_mpi_access::Cint)::Cvoid end """ - p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + t8_mat_init_xrot(mat, angle) -Transform from self's coordinate system to neighbor's coordinate system. +Initialize given 3x3 matrix as rotation matrix around the x-axis with given angle. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. ### Prototype ```c -void p8est_neighbor_transform_coordinates (const p8est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P8EST_DIM], p4est_qcoord_t neigh_coords[P8EST_DIM]); +static inline void t8_mat_init_xrot (double mat[3][3], const double angle); ``` """ -function p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) - @ccall libp4est.p8est_neighbor_transform_coordinates(nt::Ptr{p8est_neighbor_transform_t}, self_coords::Ptr{p4est_qcoord_t}, neigh_coords::Ptr{p4est_qcoord_t})::Cvoid +function t8_mat_init_xrot(mat, angle) + @ccall libt8.t8_mat_init_xrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid end """ - p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + t8_mat_init_yrot(mat, angle) -Transform from neighbor's coordinate system to self's coordinate system. +Initialize given 3x3 matrix as rotation matrix around the y-axis with given angle. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. ### Prototype ```c -void p8est_neighbor_transform_coordinates_reverse (const p8est_neighbor_transform_t * nt, const p4est_qcoord_t neigh_coords[P8EST_DIM], p4est_qcoord_t self_coords[P8EST_DIM]); +static inline void t8_mat_init_yrot (double mat[3][3], const double angle); ``` """ -function p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) - @ccall libp4est.p8est_neighbor_transform_coordinates_reverse(nt::Ptr{p8est_neighbor_transform_t}, neigh_coords::Ptr{p4est_qcoord_t}, self_coords::Ptr{p4est_qcoord_t})::Cvoid +function t8_mat_init_yrot(mat, angle) + @ccall libt8.t8_mat_init_yrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid end """ - p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + t8_mat_init_zrot(mat, angle) -Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects +Initialize given 3x3 matrix as rotation matrix around the z-axis with given angle. # Arguments -* `conn`:\\[in\\] Connectivity structure. -* `tree_id`:\\[in\\] The number of the tree. -* `boundary_type`:\\[in\\] Type of boundary connection (self, face, edge, corner). -* `boundary_index`:\\[in\\] The index of the boundary. -* `neighbor_transform_array`:\\[in,out\\] Array of the neighbor transforms. +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. ### Prototype ```c -void p8est_connectivity_get_neighbor_transforms (p8est_connectivity_t *conn, p4est_topidx_t tree_id, p8est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array); +static inline void t8_mat_init_zrot (double mat[3][3], const double angle); ``` """ -function p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) - @ccall libp4est.p8est_connectivity_get_neighbor_transforms(conn::Ptr{p8est_connectivity_t}, tree_id::p4est_topidx_t, boundary_type::p8est_connect_type_t, boundary_index::Cint, neighbor_transform_array::Ptr{sc_array_t})::Cvoid +function t8_mat_init_zrot(mat, angle) + @ccall libt8.t8_mat_init_zrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid end """ - p8est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) - -Determine the owning tree for a coordinate and transform it there. - -On a boundary between trees, different coordinate systems meet. A coordinate on a tree boundary face, edge, or corner generated from the perspective of a specific tree may be transformed into any other touching tree's coordinate system and still refer to the same point in the mesh. + t8_mat_mult_vec(mat, a, b) -To uniquely identify a coordinate, this function identifies the lowest numbered tree touching this coordinate and transforms the coordinate into that system. The result can be used e. g. in topology hash tables. +Apply matrix-matrix multiplication: b = M*a. # Arguments -* `conn`:\\[in\\] A valid connectivity. -* `treeid`:\\[in\\] The original tree index for this coordinate tuple. -* `coords`:\\[in\\] A valid coordinate 2-tuple relative to *treeid*. -* `treeid_out`:\\[out\\] The lowest tree index touching the coordinate. -* `coords_out`:\\[out\\] The input coordinates, if necessary after transformation into the system of the lowest numbered tree, returned in *treeid_out*. +* `mat`:\\[in\\] 3x3-matrix. +* `a`:\\[in\\] 3-vector. +* `b`:\\[in,out\\] 3-vector. ### Prototype ```c -void p8est_connectivity_coordinates_canonicalize (p8est_connectivity_t *conn, p4est_topidx_t treeid, const p4est_qcoord_t coords[], p4est_topidx_t *treeid_out, p4est_qcoord_t coords_out[]); +static inline void t8_mat_mult_vec (const double mat[3][3], const double a[3], double b[3]); ``` """ -function p8est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) - @ccall libp4est.p8est_connectivity_coordinates_canonicalize(conn::Ptr{p8est_connectivity_t}, treeid::p4est_topidx_t, coords::Ptr{p4est_qcoord_t}, treeid_out::Ptr{p4est_topidx_t}, coords_out::Ptr{p4est_qcoord_t})::Cvoid +function t8_mat_mult_vec(mat, a, b) + @ccall libt8.t8_mat_mult_vec(mat::Ptr{NTuple{3, Cdouble}}, a::Ptr{Cdouble}, b::Ptr{Cdouble})::Cvoid end """ - p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) + t8_mat_mult_mat(A, B, C) -Transform a corner across one of the adjacent faces into a neighbor tree. It expects a face permutation index that has been precomputed. +Apply matrix-matrix multiplication: C = A*B. # Arguments -* `c`:\\[in\\] A corner number in 0..7. -* `f`:\\[in\\] A face number that touches the corner *c*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `set`:\\[in\\] A value from *p8est_face_permutation_sets* that is obtained using *f*, *nf*, and a valid orientation: ref = p8est\\_face\\_permutation\\_refs[f][nf]; set = p8est\\_face\\_permutation\\_sets[ref][orientation]; -# Returns -The corner number in 0..7 seen from the other face. +* `A`:\\[in\\] 3x3-matrix. +* `B`:\\[in\\] 3x3-matrix. +* `C`:\\[in\\] 3x3-matrix. ### Prototype ```c -int p8est_connectivity_face_neighbor_corner_set (int c, int f, int nf, int set); +static inline void t8_mat_mult_mat (const double A[3][3], const double B[3][3], double C[3][3]); ``` """ -function p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) - @ccall libp4est.p8est_connectivity_face_neighbor_corner_set(c::Cint, f::Cint, nf::Cint, set::Cint)::Cint +function t8_mat_mult_mat(A, B, C) + @ccall libt8.t8_mat_mult_mat(A::Ptr{NTuple{3, Cdouble}}, B::Ptr{NTuple{3, Cdouble}}, C::Ptr{NTuple{3, Cdouble}})::Cvoid end +mutable struct t8_mesh end + +const t8_mesh_t = t8_mesh + """ - p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + t8_mesh_new(dimension, Kglobal, Klocal) -Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +*********************** preallocate ************************* -# Arguments -* `fc`:\\[in\\] A face corner number in 0..3. -* `f`:\\[in\\] A face that the face corner *fc* is relative to. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. -# Returns -The face corner number relative to the neighbor's face. ### Prototype ```c -int p8est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); +t8_mesh_t * t8_mesh_new (int dimension, t8_gloidx_t Kglobal, t8_locidx_t Klocal); ``` """ -function p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_face_corner(fc::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_mesh_new(dimension, Kglobal, Klocal) + @ccall libt8.t8_mesh_new(dimension::Cint, Kglobal::t8_gloidx_t, Klocal::t8_locidx_t)::Ptr{t8_mesh_t} end """ - p8est_connectivity_face_neighbor_corner(c, f, nf, o) + t8_mesh_new_unitcube(theclass) -Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +*********** all-in-one convenience constructors ************* -# Arguments -* `c`:\\[in\\] A corner number in 0..7. -* `f`:\\[in\\] A face number that touches the corner *c*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. -# Returns -The number of the corner seen from the neighbor tree. ### Prototype ```c -int p8est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); +t8_mesh_t * t8_mesh_new_unitcube (t8_eclass_t theclass); ``` """ -function p8est_connectivity_face_neighbor_corner(c, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_corner(c::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_mesh_new_unitcube(theclass) + @ccall libt8.t8_mesh_new_unitcube(theclass::t8_eclass_t)::Ptr{t8_mesh_t} end """ - p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) - -Transform a face-edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. + t8_mesh_set_comm(mesh, comm) -# Arguments -* `fe`:\\[in\\] A face edge number in 0..3. -* `f`:\\[in\\] A face number that touches the edge *e*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. -# Returns -The face edge number seen from the neighbor tree. ### Prototype ```c -int p8est_connectivity_face_neighbor_face_edge (int fe, int f, int nf, int o); +void t8_mesh_set_comm (t8_mesh_t *mesh, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_face_edge(fe::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_mesh_set_comm(mesh, comm) + @ccall libt8.t8_mesh_set_comm(mesh::Ptr{t8_mesh_t}, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_face_neighbor_edge(e, f, nf, o) + t8_mesh_set_partition(mesh, enable) -Transform an edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Determine whether we partition in t8_mesh_build. Default true. -# Arguments -* `e`:\\[in\\] A edge number in 0..11. -* `f`:\\[in\\] A face 0..5 that touches the edge *e*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. -# Returns -The edge's number seen from the neighbor. ### Prototype ```c -int p8est_connectivity_face_neighbor_edge (int e, int f, int nf, int o); +void t8_mesh_set_partition (t8_mesh_t *mesh, int enable); ``` """ -function p8est_connectivity_face_neighbor_edge(e, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_edge(e::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_mesh_set_partition(mesh, enable) + @ccall libt8.t8_mesh_set_partition(mesh::Ptr{t8_mesh_t}, enable::Cint)::Cvoid end """ - p8est_connectivity_edge_neighbor_edge_corner(ec, o) + t8_mesh_set_element(mesh, theclass, gloid, locid) -Transform an edge corner across one of the adjacent edges into a neighbor tree. - -# Arguments -* `ec`:\\[in\\] An edge corner number in 0..1. -* `o`:\\[in\\] The orientation of a tree boundary edge connection. -# Returns -The edge corner number seen from the other tree. ### Prototype ```c -int p8est_connectivity_edge_neighbor_edge_corner (int ec, int o); +void t8_mesh_set_element (t8_mesh_t *mesh, t8_eclass_t theclass, t8_gloidx_t gloid, t8_locidx_t locid); ``` """ -function p8est_connectivity_edge_neighbor_edge_corner(ec, o) - @ccall libp4est.p8est_connectivity_edge_neighbor_edge_corner(ec::Cint, o::Cint)::Cint +function t8_mesh_set_element(mesh, theclass, gloid, locid) + @ccall libt8.t8_mesh_set_element(mesh::Ptr{t8_mesh_t}, theclass::t8_eclass_t, gloid::t8_gloidx_t, locid::t8_locidx_t)::Cvoid end """ - p8est_connectivity_edge_neighbor_corner(c, e, ne, o) - -Transform a corner across one of the adjacent edges into a neighbor tree. This version expects the neighbor edge and orientation separately. + t8_mesh_set_local_to_global(mesh, ltog_length, ltog) -# Arguments -* `c`:\\[in\\] A corner number in 0..7. -* `e`:\\[in\\] An edge 0..11 that touches the corner *c*. -* `ne`:\\[in\\] A neighbor edge that is on the other side of *e*. -* `o`:\\[in\\] The orientation between tree boundary edges *e* and *ne*. -# Returns -Corner number seen from the neighbor. ### Prototype ```c -int p8est_connectivity_edge_neighbor_corner (int c, int e, int ne, int o); +void t8_mesh_set_local_to_global (t8_mesh_t *mesh, t8_locidx_t ltog_length, const t8_gloidx_t *ltog); ``` """ -function p8est_connectivity_edge_neighbor_corner(c, e, ne, o) - @ccall libp4est.p8est_connectivity_edge_neighbor_corner(c::Cint, e::Cint, ne::Cint, o::Cint)::Cint +function t8_mesh_set_local_to_global(mesh, ltog_length, ltog) + @ccall libt8.t8_mesh_set_local_to_global(mesh::Ptr{t8_mesh_t}, ltog_length::t8_locidx_t, ltog::Ptr{t8_gloidx_t})::Cvoid end """ - p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) + t8_mesh_set_face(mesh, locid1, face1, locid2, face2, orientation) -Allocate a connectivity structure. The attribute fields are initialized to NULL. - -# Arguments -* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). -* `num_trees`:\\[in\\] Number of trees in the forest. -* `num_edges`:\\[in\\] Number of tree-connecting edges. -* `num_ett`:\\[in\\] Number of total trees in edge\\_to\\_tree array. -* `num_corners`:\\[in\\] Number of tree-connecting corners. -* `num_ctt`:\\[in\\] Number of total trees in corner\\_to\\_tree array. -# Returns -A connectivity structure with allocated arrays. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_ett, p4est_topidx_t num_corners, p4est_topidx_t num_ctt); +void t8_mesh_set_face (t8_mesh_t *mesh, t8_locidx_t locid1, int face1, t8_locidx_t locid2, int face2, int orientation); ``` """ -function p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) - @ccall libp4est.p8est_connectivity_new(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_ett::p4est_topidx_t, num_corners::p4est_topidx_t, num_ctt::p4est_topidx_t)::Ptr{p8est_connectivity_t} +function t8_mesh_set_face(mesh, locid1, face1, locid2, face2, orientation) + @ccall libt8.t8_mesh_set_face(mesh::Ptr{t8_mesh_t}, locid1::t8_locidx_t, face1::Cint, locid2::t8_locidx_t, face2::Cint, orientation::Cint)::Cvoid end """ - p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) - -Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. + t8_mesh_set_element_vertices(mesh, locid, vids_length, vids) -# Arguments -* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). -* `num_trees`:\\[in\\] Number of trees in the forest. -* `num_edges`:\\[in\\] Number of tree-connecting edges. -* `num_corners`:\\[in\\] Number of tree-connecting corners. -* `vertices`:\\[in\\] Coordinates of the vertices of the trees. -* `ttv`:\\[in\\] The tree-to-vertex array. -* `ttt`:\\[in\\] The tree-to-tree array. -* `ttf`:\\[in\\] The tree-to-face array (int8\\_t). -* `tte`:\\[in\\] The tree-to-edge array. -* `eoff`:\\[in\\] Edge-to-tree offsets (num\\_edges + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. -* `ett`:\\[in\\] The edge-to-tree array. -* `ete`:\\[in\\] The edge-to-edge array. -* `ttc`:\\[in\\] The tree-to-corner array. -* `coff`:\\[in\\] Corner-to-tree offsets (num\\_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. -* `ctt`:\\[in\\] The corner-to-tree array. -* `ctc`:\\[in\\] The corner-to-corner array. -# Returns -The connectivity is checked for validity. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * tte, const p4est_topidx_t * eoff, const p4est_topidx_t * ett, const int8_t * ete, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc); +void t8_mesh_set_element_vertices (t8_mesh_t *mesh, t8_locidx_t locid, t8_locidx_t vids_length, const t8_locidx_t *vids); ``` """ -function p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) - @ccall libp4est.p8est_connectivity_new_copy(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_corners::p4est_topidx_t, vertices::Ptr{Cdouble}, ttv::Ptr{p4est_topidx_t}, ttt::Ptr{p4est_topidx_t}, ttf::Ptr{Int8}, tte::Ptr{p4est_topidx_t}, eoff::Ptr{p4est_topidx_t}, ett::Ptr{p4est_topidx_t}, ete::Ptr{Int8}, ttc::Ptr{p4est_topidx_t}, coff::Ptr{p4est_topidx_t}, ctt::Ptr{p4est_topidx_t}, ctc::Ptr{Int8})::Ptr{p8est_connectivity_t} +function t8_mesh_set_element_vertices(mesh, locid, vids_length, vids) + @ccall libt8.t8_mesh_set_element_vertices(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t, vids_length::t8_locidx_t, vids::Ptr{t8_locidx_t})::Cvoid end """ - p8est_connectivity_copy(input, copy_attr) + t8_mesh_build(mesh) -Deep copy a connectivity structure. +Setup a mesh and turn it into a usable object. -# Arguments -* `input`:\\[in\\] Valid connectivity. -* `copy_attr`:\\[in\\] If true, we copy the tree attribute data. Otherwise, the result has empty attributes. -# Returns -A connectivity equal to the first one except, depending on *copy_attry*, for its attributes. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_copy (p8est_connectivity_t *input, int copy_attr); +void t8_mesh_build (t8_mesh_t *mesh); ``` """ -function p8est_connectivity_copy(input, copy_attr) - @ccall libp4est.p8est_connectivity_copy(input::Ptr{p8est_connectivity_t}, copy_attr::Cint)::Ptr{p8est_connectivity_t} +function t8_mesh_build(mesh) + @ccall libt8.t8_mesh_build(mesh::Ptr{t8_mesh_t})::Cvoid end """ - p8est_connectivity_bcast(conn_in, root, comm) + t8_mesh_get_comm(mesh) ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_bcast (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +sc_MPI_Comm t8_mesh_get_comm (t8_mesh_t *mesh); ``` """ -function p8est_connectivity_bcast(conn_in, root, comm) - @ccall libp4est.p8est_connectivity_bcast(conn_in::Ptr{p8est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p8est_connectivity_t} +function t8_mesh_get_comm(mesh) + @ccall libt8.t8_mesh_get_comm(mesh::Ptr{t8_mesh_t})::Cint end """ - p8est_connectivity_destroy(connectivity) - -Destroy a connectivity structure. Also destroy all attributes. + t8_mesh_get_element_count(mesh, theclass) ### Prototype ```c -void p8est_connectivity_destroy (p8est_connectivity_t * connectivity); +t8_locidx_t t8_mesh_get_element_count (t8_mesh_t *mesh, t8_eclass_t theclass); ``` """ -function p8est_connectivity_destroy(connectivity) - @ccall libp4est.p8est_connectivity_destroy(connectivity::Ptr{p8est_connectivity_t})::Cvoid +function t8_mesh_get_element_count(mesh, theclass) + @ccall libt8.t8_mesh_get_element_count(mesh::Ptr{t8_mesh_t}, theclass::t8_eclass_t)::t8_locidx_t end """ - p8est_connectivity_share(conn_in, root, comm) + t8_mesh_get_element_class(mesh, locid) +# Arguments +* `locid`:\\[in\\] The local number can specify a point of any dimension that is locally relevant. The points are ordered in reverse to the element classes in t8_eclass_t. The local index is cumulative in this order. ### Prototype ```c -p8est_connectivity_shared_t *p8est_connectivity_share (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +t8_locidx_t t8_mesh_get_element_class (t8_mesh_t *mesh, t8_locidx_t locid); ``` """ -function p8est_connectivity_share(conn_in, root, comm) - @ccall libp4est.p8est_connectivity_share(conn_in::Ptr{p8est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p8est_connectivity_shared_t} +function t8_mesh_get_element_class(mesh, locid) + @ccall libt8.t8_mesh_get_element_class(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t)::t8_locidx_t end """ - p8est_connectivity_mission(conn_in, split_type, world_comm) + t8_mesh_get_element_locid(mesh, gloid) ### Prototype ```c -p8est_connectivity_shared_t * p8est_connectivity_mission (p8est_connectivity_t *conn_in, int split_type, sc_MPI_Comm world_comm); +t8_locidx_t t8_mesh_get_element_locid (t8_mesh_t *mesh, t8_gloidx_t gloid); ``` """ -function p8est_connectivity_mission(conn_in, split_type, world_comm) - @ccall libp4est.p8est_connectivity_mission(conn_in::Ptr{p8est_connectivity_t}, split_type::Cint, world_comm::Cint)::Ptr{p8est_connectivity_shared_t} +function t8_mesh_get_element_locid(mesh, gloid) + @ccall libt8.t8_mesh_get_element_locid(mesh::Ptr{t8_mesh_t}, gloid::t8_gloidx_t)::t8_locidx_t end """ - p8est_connectivity_shared_destroy(cshare) + t8_mesh_get_element_gloid(mesh, locid) -Destroy a shared connectivity structure. Call this eventually on the result of p8est_connectivity_share or p8est_connectivity_mission (which calls the former internally). - -# Arguments -* `cshare`:\\[in\\] Valid shared connectivity structure; cf. p8est_connectivity_share. ### Prototype ```c -void p8est_connectivity_shared_destroy (p8est_connectivity_shared_t *cshare); +t8_gloidx_t t8_mesh_get_element_gloid (t8_mesh_t *mesh, t8_locidx_t locid); ``` """ -function p8est_connectivity_shared_destroy(cshare) - @ccall libp4est.p8est_connectivity_shared_destroy(cshare::Ptr{p8est_connectivity_shared_t})::Cvoid +function t8_mesh_get_element_gloid(mesh, locid) + @ccall libt8.t8_mesh_get_element_gloid(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t)::t8_gloidx_t end """ - p8est_connectivity_set_attr(conn, bytes_per_tree) - -Allocate or free the attribute fields in a connectivity. + t8_mesh_get_element(mesh, locid) -# Arguments -* `conn`:\\[in,out\\] The conn->*\\_to\\_attr fields must either be NULL or previously be allocated by this function. -* `bytes_per_tree`:\\[in\\] If 0, tree\\_to\\_attr is freed (being NULL is ok). If positive, requested space is allocated. ### Prototype ```c -void p8est_connectivity_set_attr (p8est_connectivity_t * conn, size_t bytes_per_tree); +t8_element_t t8_mesh_get_element (t8_mesh_t *mesh, t8_locidx_t locid); ``` """ -function p8est_connectivity_set_attr(conn, bytes_per_tree) - @ccall libp4est.p8est_connectivity_set_attr(conn::Ptr{p8est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid +function t8_mesh_get_element(mesh, locid) + @ccall libt8.t8_mesh_get_element(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t)::t8_element_t end """ - p8est_connectivity_is_valid(connectivity) + t8_mesh_get_element_boundary(mesh, locid, length_boundary, elemid, orientation) -Examine a connectivity structure. - -# Returns -Returns true if structure is valid, false otherwise. ### Prototype ```c -int p8est_connectivity_is_valid (p8est_connectivity_t * connectivity); +void t8_mesh_get_element_boundary (t8_mesh_t *mesh, t8_locidx_t locid, int length_boundary, t8_locidx_t *elemid, int *orientation); ``` """ -function p8est_connectivity_is_valid(connectivity) - @ccall libp4est.p8est_connectivity_is_valid(connectivity::Ptr{p8est_connectivity_t})::Cint +function t8_mesh_get_element_boundary(mesh, locid, length_boundary, elemid, orientation) + @ccall libt8.t8_mesh_get_element_boundary(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t, length_boundary::Cint, elemid::Ptr{t8_locidx_t}, orientation::Ptr{Cint})::Cvoid end """ - p8est_connectivity_is_equal(conn1, conn2) + t8_mesh_get_maximum_support(mesh) -Check two connectivity structures for equality. +Return the maximum of the length of the support of any local element. -# Returns -Returns true if structures are equal, false otherwise. ### Prototype ```c -int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); +int t8_mesh_get_maximum_support (t8_mesh_t *mesh); ``` """ -function p8est_connectivity_is_equal(conn1, conn2) - @ccall libp4est.p8est_connectivity_is_equal(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint +function t8_mesh_get_maximum_support(mesh) + @ccall libt8.t8_mesh_get_maximum_support(mesh::Ptr{t8_mesh_t})::Cint end """ - p8est_connectivity_sink(conn, sink) - -Write connectivity to a sink object. + t8_mesh_get_element_support(mesh, locid, length_support, elemid, orientation) # Arguments -* `conn`:\\[in\\] The connectivity to be written. -* `sink`:\\[in,out\\] The connectivity is written into this sink. -# Returns -0 on success, nonzero on error. +* `length_support`:\\[in,out\\] ### Prototype ```c -int p8est_connectivity_sink (p8est_connectivity_t * conn, sc_io_sink_t * sink); +void t8_mesh_get_element_support (t8_mesh_t *mesh, t8_locidx_t locid, int *length_support, t8_locidx_t *elemid, int *orientation); ``` """ -function p8est_connectivity_sink(conn, sink) - @ccall libp4est.p8est_connectivity_sink(conn::Ptr{p8est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint +function t8_mesh_get_element_support(mesh, locid, length_support, elemid, orientation) + @ccall libt8.t8_mesh_get_element_support(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t, length_support::Ptr{Cint}, elemid::Ptr{t8_locidx_t}, orientation::Ptr{Cint})::Cvoid end """ - p8est_connectivity_deflate(conn, code) + t8_mesh_destroy(mesh) -Allocate memory and store the connectivity information there. +*************************** destruct ************************ -# Arguments -* `conn`:\\[in\\] The connectivity structure to be exported to memory. -* `code`:\\[in\\] Encoding and compression method for serialization. -# Returns -Newly created array that contains the information. ### Prototype ```c -sc_array_t *p8est_connectivity_deflate (p8est_connectivity_t * conn, p8est_connectivity_encode_t code); +void t8_mesh_destroy (t8_mesh_t *mesh); ``` """ -function p8est_connectivity_deflate(conn, code) - @ccall libp4est.p8est_connectivity_deflate(conn::Ptr{p8est_connectivity_t}, code::p8est_connectivity_encode_t)::Ptr{sc_array_t} +function t8_mesh_destroy(mesh) + @ccall libt8.t8_mesh_destroy(mesh::Ptr{t8_mesh_t})::Cvoid end +const t8_nc_int64_t = Int64 + +const t8_nc_int32_t = Int32 + """ - p8est_connectivity_save(filename, connectivity) + t8_netcdf_create_var(var_type, var_name, var_long_name, var_unit, var_data) -Save a connectivity structure to disk. +Create an extern double variable which additionally should be put out to the NetCDF File # Arguments -* `filename`:\\[in\\] Name of the file to write. -* `connectivity`:\\[in\\] Valid connectivity structure. -# Returns -Returns 0 on success, nonzero on file error. +* `var_type`:\\[in\\] Defines the datatype of the variable, either T8\\_NETCDF\\_INT, T8\\_NETCDF\\_INT64 or T8\\_NETCDF\\_DOUBLE. +* `var_name`:\\[in\\] A String which will be the name of the created variable. +* `var_long_name`:\\[in\\] A string describing the variable a bit more and what it is about. +* `var_unit`:\\[in\\] The units in which the data is provided. +* `var_data`:\\[in\\] A [`sc_array_t`](@ref) holding the elementwise data of the variable. +* `num_extern_netcdf_vars`:\\[in\\] The number of extern user-defined variables which hold elementwise data (if none, set it to 0). ### Prototype ```c -int p8est_connectivity_save (const char *filename, p8est_connectivity_t * connectivity); +t8_netcdf_variable_t * t8_netcdf_create_var (t8_netcdf_variable_type_t var_type, const char *var_name, const char *var_long_name, const char *var_unit, sc_array_t *var_data); ``` """ -function p8est_connectivity_save(filename, connectivity) - @ccall libp4est.p8est_connectivity_save(filename::Cstring, connectivity::Ptr{p8est_connectivity_t})::Cint +function t8_netcdf_create_var(var_type, var_name, var_long_name, var_unit, var_data) + @ccall libt8.t8_netcdf_create_var(var_type::t8_netcdf_variable_type_t, var_name::Cstring, var_long_name::Cstring, var_unit::Cstring, var_data::Ptr{sc_array_t})::Ptr{t8_netcdf_variable_t} end """ - p8est_connectivity_source(source) + t8_netcdf_create_integer_var(var_name, var_long_name, var_unit, var_data) -Read connectivity from a source object. +Create an extern integer variable which additionally should be put out to the NetCDF File (The distinction if it will be a NC\\_INT or NC\\_INT64 variable is based on the elementsize of the given [`sc_array_t`](@ref)) # Arguments -* `source`:\\[in,out\\] The connectivity is read from this source. -# Returns -The newly created connectivity, or NULL on error. +* `var_name`:\\[in\\] A String which will be the name of the created variable. +* `var_long_name`:\\[in\\] A string describing the variable a bit more and what it is about. +* `var_unit`:\\[in\\] The units in which the data is provided. +* `var_data`:\\[in\\] A [`sc_array_t`](@ref) holding the elementwise data of the variable. +* `num_extern_netcdf_vars`:\\[in\\] The number of extern user-defined variables which hold elementwise data (if none, set it to 0). ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source); +t8_netcdf_variable_t * t8_netcdf_create_integer_var (const char *var_name, const char *var_long_name, const char *var_unit, sc_array_t *var_data); ``` """ -function p8est_connectivity_source(source) - @ccall libp4est.p8est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p8est_connectivity_t} +function t8_netcdf_create_integer_var(var_name, var_long_name, var_unit, var_data) + @ccall libt8.t8_netcdf_create_integer_var(var_name::Cstring, var_long_name::Cstring, var_unit::Cstring, var_data::Ptr{sc_array_t})::Ptr{t8_netcdf_variable_t} end """ - p8est_connectivity_inflate(buffer) + t8_netcdf_create_double_var(var_name, var_long_name, var_unit, var_data) -Create new connectivity from a memory buffer. This function aborts on malloc errors. +Create an extern double variable which additionally should be put out to the NetCDF File # Arguments -* `buffer`:\\[in\\] The connectivity is created from this memory buffer. -# Returns -The newly created connectivity, or NULL on format error of the buffered connectivity data. +* `var_name`:\\[in\\] A String which will be the name of the created variable. +* `var_long_name`:\\[in\\] A string describing the variable a bit more and what it is about. +* `var_unit`:\\[in\\] The units in which the data is provided. +* `var_data`:\\[in\\] A [`sc_array_t`](@ref) holding the elementwise data of the variable. +* `num_extern_netcdf_vars`:\\[in\\] The number of extern user-defined variables which hold elementwise data (if none, set it to 0). ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer); +t8_netcdf_variable_t * t8_netcdf_create_double_var (const char *var_name, const char *var_long_name, const char *var_unit, sc_array_t *var_data); ``` """ -function p8est_connectivity_inflate(buffer) - @ccall libp4est.p8est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p8est_connectivity_t} +function t8_netcdf_create_double_var(var_name, var_long_name, var_unit, var_data) + @ccall libt8.t8_netcdf_create_double_var(var_name::Cstring, var_long_name::Cstring, var_unit::Cstring, var_data::Ptr{sc_array_t})::Ptr{t8_netcdf_variable_t} end """ - p8est_connectivity_load(filename, bytes) + t8_netcdf_variable_destroy(var_destroy) -Load a connectivity structure from disk. +Free the allocated memory of the a [`t8_netcdf_variable_t`](@ref) # Arguments -* `filename`:\\[in\\] Name of the file to read. -* `bytes`:\\[out\\] Size in bytes of connectivity on disk or NULL. -# Returns -Returns valid connectivity, or NULL on file error. +* `var_destroy`:\\[in\\] A t8\\_netcdf\\_t variable whose allocated memory should be freed. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_load (const char *filename, size_t *bytes); +void t8_netcdf_variable_destroy (t8_netcdf_variable_t *var_destroy); ``` """ -function p8est_connectivity_load(filename, bytes) - @ccall libp4est.p8est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p8est_connectivity_t} +function t8_netcdf_variable_destroy(var_destroy) + @ccall libt8.t8_netcdf_variable_destroy(var_destroy::Ptr{t8_netcdf_variable_t})::Cvoid end """ - p8est_connectivity_new_unitcube() + t8_refcount_init(rc) -Create a connectivity structure for the unit cube. +Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. +# Arguments +* `rc`:\\[out\\] The reference counter is set to one by this call. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_unitcube (void); +void t8_refcount_init (t8_refcount_t *rc); ``` """ -function p8est_connectivity_new_unitcube() - @ccall libp4est.p8est_connectivity_new_unitcube()::Ptr{p8est_connectivity_t} +function t8_refcount_init(rc) + @ccall libt8.t8_refcount_init(rc::Ptr{t8_refcount_t})::Cvoid end """ - p8est_connectivity_new_periodic() + t8_refcount_new() -Create a connectivity structure for an all-periodic unit cube. +Create a new reference counter with count initialized to 1. Equivalent to calling [`t8_refcount_init`](@ref) on a newly allocated refcount\\_t. It is mandatory to free this with t8_refcount_destroy. +# Returns +An allocated reference counter whose count has been set to one. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_periodic (void); +t8_refcount_t * t8_refcount_new (void); ``` """ -function p8est_connectivity_new_periodic() - @ccall libp4est.p8est_connectivity_new_periodic()::Ptr{p8est_connectivity_t} +function t8_refcount_new() + @ccall libt8.t8_refcount_new()::Ptr{t8_refcount_t} end """ - p8est_connectivity_new_rotwrap() + t8_refcount_destroy(rc) -Create a connectivity structure for a mostly periodic unit cube. The left and right faces are identified, and bottom and top rotated. Front and back are not identified. +Destroy a reference counter that we allocated with t8_refcount_new. Its reference count must have decreased to zero. +# Arguments +* `rc`:\\[in,out\\] Allocated, formerly valid reference counter. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_rotwrap (void); +void t8_refcount_destroy (t8_refcount_t *rc); ``` """ -function p8est_connectivity_new_rotwrap() - @ccall libp4est.p8est_connectivity_new_rotwrap()::Ptr{p8est_connectivity_t} +function t8_refcount_destroy(rc) + @ccall libt8.t8_refcount_destroy(rc::Ptr{t8_refcount_t})::Cvoid end """ - p8est_connectivity_new_drop() + t8_vec_norm(vec) -Create a connectivity structure for a five-trees geometry with a hole. The geometry is a 3D extrusion of the two drop example, and covers [0, 3]*[0, 2]*[0, 3]. The additional dimension is Y. +Vector norm. +# Arguments +* `vec`:\\[in\\] A 3D vector. +# Returns +The norm of *vec*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_drop (void); +static inline double t8_vec_norm (const double vec[3]); ``` """ -function p8est_connectivity_new_drop() - @ccall libp4est.p8est_connectivity_new_drop()::Ptr{p8est_connectivity_t} +function t8_vec_norm(vec) + @ccall libt8.t8_vec_norm(vec::Ptr{Cdouble})::Cdouble end """ - p8est_connectivity_new_twocubes() + t8_vec_normalize(vec) -Create a connectivity structure that contains two cubes. +Normalize a vector. +# Arguments +* `vec`:\\[in,out\\] A 3D vector. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twocubes (void); +static inline void t8_vec_normalize (double vec[3]); ``` """ -function p8est_connectivity_new_twocubes() - @ccall libp4est.p8est_connectivity_new_twocubes()::Ptr{p8est_connectivity_t} +function t8_vec_normalize(vec) + @ccall libt8.t8_vec_normalize(vec::Ptr{Cdouble})::Cvoid end """ - p8est_connectivity_new_twotrees(l_face, r_face, orientation) + t8_vec_copy(vec_in, vec_out) -Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way. +Make a copy of a vector. # Arguments -* `l_face`:\\[in\\] index of left face -* `r_face`:\\[in\\] index of right face -* `orientation`:\\[in\\] orientation of trees w.r.t. each other +* `vec_in`:\\[in\\] +* `vec_out`:\\[out\\] ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twotrees (int l_face, int r_face, int orientation); +static inline void t8_vec_copy (const double vec_in[3], double vec_out[3]); ``` """ -function p8est_connectivity_new_twotrees(l_face, r_face, orientation) - @ccall libp4est.p8est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p8est_connectivity_t} +function t8_vec_copy(vec_in, vec_out) + @ccall libt8.t8_vec_copy(vec_in::Ptr{Cdouble}, vec_out::Ptr{Cdouble})::Cvoid end """ - p8est_connectivity_new_twowrap() + t8_vec_dist(vec_x, vec_y) -Create a connectivity structure that contains two cubes where the two far ends are identified periodically. +Euclidean distance of X and Y. +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +# Returns +The euclidean distance. Equivalent to norm (X-Y). ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twowrap (void); +static inline double t8_vec_dist (const double vec_x[3], const double vec_y[3]); ``` """ -function p8est_connectivity_new_twowrap() - @ccall libp4est.p8est_connectivity_new_twowrap()::Ptr{p8est_connectivity_t} +function t8_vec_dist(vec_x, vec_y) + @ccall libt8.t8_vec_dist(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble end """ - p8est_connectivity_new_rotcubes() + t8_vec_ax(vec_x, alpha) -Create a connectivity structure that contains a few cubes. These are rotated against each other to stress the topology routines. +Compute X = alpha * X +# Arguments +* `vec_x`:\\[in,out\\] A 3D vector. On output set to *alpha* * *vec_x*. +* `alpha`:\\[in\\] A factor. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_rotcubes (void); +static inline void t8_vec_ax (double vec_x[3], const double alpha); ``` """ -function p8est_connectivity_new_rotcubes() - @ccall libp4est.p8est_connectivity_new_rotcubes()::Ptr{p8est_connectivity_t} +function t8_vec_ax(vec_x, alpha) + @ccall libt8.t8_vec_ax(vec_x::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - p8est_connectivity_new_pillow() + t8_vec_axy(vec_x, vec_y, alpha) -Create a connectivity structure for two trees on top of each other. This connectivity is meant to be used with p8est_geometry_new_pillow to map a spherical shell. +Compute Y = alpha * X +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_z`:\\[out\\] On output set to *alpha* * *vec_x*. +* `alpha`:\\[in\\] A factor. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_pillow (void); +static inline void t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha); ``` """ -function p8est_connectivity_new_pillow() - @ccall libp4est.p8est_connectivity_new_pillow()::Ptr{p8est_connectivity_t} +function t8_vec_axy(vec_x, vec_y, alpha) + @ccall libt8.t8_vec_axy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) + t8_vec_axb(vec_x, vec_y, alpha, b) -An m by n by p array with periodicity in x, y, and z if periodic\\_a, periodic\\_b, and periodic\\_c are true, respectively. +Y = alpha * X + b + +!!! note + + It is possible that vec\\_x = vec\\_y on input to overwrite x +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[out\\] On input, a 3D vector. On output set to *alpha* * *vec_x* + *b*. +* `alpha`:\\[in\\] A factor. +* `b`:\\[in\\] An offset. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c); +static inline void t8_vec_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b); ``` """ -function p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) - @ccall libp4est.p8est_connectivity_new_brick(m::Cint, n::Cint, p::Cint, periodic_a::Cint, periodic_b::Cint, periodic_c::Cint)::Ptr{p8est_connectivity_t} +function t8_vec_axb(vec_x, vec_y, alpha, b) + @ccall libt8.t8_vec_axb(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble, b::Cdouble)::Cvoid end """ - p8est_connectivity_new_shell() + t8_vec_axpy(vec_x, vec_y, alpha) -Create a connectivity structure that builds a spherical shell. It is made up of six connected parts [-1,1]x[-1,1]x[1,2]. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). +Y = Y + alpha * X +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in,out\\] On input, a 3D vector. On output set *to* vec\\_y + *alpha* * *vec_x* +* `alpha`:\\[in\\] A factor. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_shell (void); +static inline void t8_vec_axpy (const double vec_x[3], double vec_y[3], const double alpha); ``` """ -function p8est_connectivity_new_shell() - @ccall libp4est.p8est_connectivity_new_shell()::Ptr{p8est_connectivity_t} +function t8_vec_axpy(vec_x, vec_y, alpha) + @ccall libt8.t8_vec_axpy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - p8est_connectivity_new_sphere() + t8_vec_axpyz(vec_x, vec_y, vec_z, alpha) -Create a connectivity structure that builds a solid sphere. It is made up of two layers and a cube in the center. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). +Z = Y + alpha * X +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +* `vec_z`:\\[out\\] On output set *to* vec\\_y + *alpha* * *vec_x* ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_sphere (void); +static inline void t8_vec_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], const double alpha); ``` """ -function p8est_connectivity_new_sphere() - @ccall libp4est.p8est_connectivity_new_sphere()::Ptr{p8est_connectivity_t} +function t8_vec_axpyz(vec_x, vec_y, vec_z, alpha) + @ccall libt8.t8_vec_axpyz(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, vec_z::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - p8est_connectivity_new_torus(nSegments) + t8_vec_dot(vec_x, vec_y) -Create a connectivity structure that builds a revolution torus. - -This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). +Dot product of X and Y. -This connectivity reuses ideas from disk2d connectivity. More precisely the torus is divided into segments around the revolution axis, each segments is made of 5 trees (à la disk2d). The total number of trees if 5 times the number of segments. +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +# Returns +The dot product *vec_x* * *vec_y* +### Prototype +```c +static inline double t8_vec_dot (const double vec_x[3], const double vec_y[3]); +``` +""" +function t8_vec_dot(vec_x, vec_y) + @ccall libt8.t8_vec_dot(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +end -This connectivity is meant to be used with p8est_geometry_new_torus +""" + t8_vec_cross(vec_x, vec_y, cross) + +Cross product of X and Y # Arguments -* `nSegments`:\\[in\\] number of trees along the great circle +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +* `cross`:\\[out\\] On output, the cross product of *vec_x* and *vec_y*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_torus (int nSegments); +static inline void t8_vec_cross (const double vec_x[3], const double vec_y[3], double cross[3]); ``` """ -function p8est_connectivity_new_torus(nSegments) - @ccall libp4est.p8est_connectivity_new_torus(nSegments::Cint)::Ptr{p8est_connectivity_t} +function t8_vec_cross(vec_x, vec_y, cross) + @ccall libt8.t8_vec_cross(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, cross::Ptr{Cdouble})::Cvoid end """ - p8est_connectivity_new_byname(name) + t8_vec_diff(vec_x, vec_y, diff) -Create connectivity structure from predefined catalogue. +Compute the difference of two vectors. # Arguments -* `name`:\\[in\\] Invokes connectivity\\_new\\_* function. brick235 brick (2, 3, 5, 0, 0, 0) periodic periodic rotcubes rotcubes rotwrap rotwrap shell shell sphere sphere twocubes twocubes twowrap twowrap unit unitcube -# Returns -An initialized connectivity if name is defined, NULL else. +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +* `diff`:\\[out\\] On output, the difference of *vec_x* and *vec_y*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_byname (const char *name); +static inline void t8_vec_diff (const double vec_x[3], const double vec_y[3], double diff[3]); ``` """ -function p8est_connectivity_new_byname(name) - @ccall libp4est.p8est_connectivity_new_byname(name::Cstring)::Ptr{p8est_connectivity_t} +function t8_vec_diff(vec_x, vec_y, diff) + @ccall libt8.t8_vec_diff(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, diff::Ptr{Cdouble})::Cvoid end """ - p8est_connectivity_refine(conn, num_per_dim) + t8_vec_eq(vec_x, vec_y, tol) -Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. +Check the equality of two vectors elementwise # Arguments -* `conn`:\\[in\\] A valid connectivity -* `num_per_dim`:\\[in\\] The number of new trees in each direction. Must use no more than P8EST_OLD_QMAXLEVEL bits. +* `vec_x`:\\[in\\] +* `vec_y`:\\[in\\] +* `tol`:\\[in\\] # Returns -a refined connectivity. +true, if the vectors are equal up to *tol* ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_refine (p8est_connectivity_t * conn, int num_per_dim); +static inline int t8_vec_eq (const double vec_x[3], const double vec_y[3], const double tol); ``` """ -function p8est_connectivity_refine(conn, num_per_dim) - @ccall libp4est.p8est_connectivity_refine(conn::Ptr{p8est_connectivity_t}, num_per_dim::Cint)::Ptr{p8est_connectivity_t} +function t8_vec_eq(vec_x, vec_y, tol) + @ccall libt8.t8_vec_eq(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, tol::Cdouble)::Cint end """ - p8est_expand_face_transform(iface, nface, ftransform) + t8_vec_rescale(vec, new_length) -Fill an array with the axis combination of a face neighbor transform. +Rescale a vector to a new length. # Arguments -* `iface`:\\[in\\] The number of the originating face. -* `nface`:\\[in\\] Encoded as nface = r * 6 + nf, where nf = 0..5 is the neigbbor's connecting face number and r = 0..3 is the relative orientation to the neighbor's face. This encoding matches [`p8est_connectivity_t`](@ref). -* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face, the first two referring to the tangentials and the third to the normal. A permutation of (0, 1, 2). [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flags for tangential axes (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q +* `vec`:\\[in,out\\] A 3D vector. +* `new_length`:\\[in\\] New length of the vector. ### Prototype ```c -void p8est_expand_face_transform (int iface, int nface, int ftransform[]); +static inline void t8_vec_rescale (double vec[3], const double new_length); ``` """ -function p8est_expand_face_transform(iface, nface, ftransform) - @ccall libp4est.p8est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid +function t8_vec_rescale(vec, new_length) + @ccall libt8.t8_vec_rescale(vec::Ptr{Cdouble}, new_length::Cdouble)::Cvoid end """ - p8est_find_face_transform(connectivity, itree, iface, ftransform) + t8_vec_tri_normal(p1, p2, p3, normal) -Fill an array with the axis combination of a face neighbor transform. +Compute the normal of a triangle given by its three vertices. # Arguments -* `connectivity`:\\[in\\] Connectivity structure. -* `itree`:\\[in\\] The number of the originating tree. -* `iface`:\\[in\\] The number of the originating tree's face. -* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face. [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flag for axes t1, t2; face code for n; -# Returns -The face neighbor tree if it exists, -1 otherwise. -# See also -[`p8est_expand_face_transform`](@ref). - +* `p1`:\\[in\\] A 3D vector. +* `p2`:\\[in\\] A 3D vector. +* `p3`:\\[in\\] A 3D vector. +* `Normal`:\\[out\\] vector of the triangle. (Not necessarily of length 1!) ### Prototype ```c -p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); +static inline void t8_vec_tri_normal (const double p1[3], const double p2[3], const double p3[3], double normal[3]); ``` """ -function p8est_find_face_transform(connectivity, itree, iface, ftransform) - @ccall libp4est.p8est_find_face_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iface::Cint, ftransform::Ptr{Cint})::p4est_topidx_t +function t8_vec_tri_normal(p1, p2, p3, normal) + @ccall libt8.t8_vec_tri_normal(p1::Ptr{Cdouble}, p2::Ptr{Cdouble}, p3::Ptr{Cdouble}, normal::Ptr{Cdouble})::Cvoid end """ - p8est_find_edge_transform(connectivity, itree, iedge, ei) + t8_vec_orthogonal_tripod(v1, v2, v3) -Fills an array with information about edge neighbors. +Compute an orthogonal coordinate system from a given vector. # Arguments -* `connectivity`:\\[in\\] Connectivity structure. -* `itree`:\\[in\\] The number of the originating tree. -* `iedge`:\\[in\\] The number of the originating edge. -* `ei`:\\[in,out\\] A [`p8est_edge_info_t`](@ref) structure with initialized array. +* `v1`:\\[in\\] 3D vector. +* `v2`:\\[out\\] 3D vector. +* `v3`:\\[out\\] 3D vector. ### Prototype ```c -void p8est_find_edge_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t * ei); +static inline void t8_vec_orthogonal_tripod (const double v1[3], double v2[3], double v3[3]); ``` """ -function p8est_find_edge_transform(connectivity, itree, iedge, ei) - @ccall libp4est.p8est_find_edge_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iedge::Cint, ei::Ptr{p8est_edge_info_t})::Cvoid +function t8_vec_orthogonal_tripod(v1, v2, v3) + @ccall libt8.t8_vec_orthogonal_tripod(v1::Ptr{Cdouble}, v2::Ptr{Cdouble}, v3::Ptr{Cdouble})::Cvoid end """ - p8est_find_corner_transform(connectivity, itree, icorner, ci) + t8_vec_swap(p1, p2) -Fills an array with information about corner neighbors. +Swap the components of two vectors. # Arguments -* `connectivity`:\\[in\\] Connectivity structure. -* `itree`:\\[in\\] The number of the originating tree. -* `icorner`:\\[in\\] The number of the originating corner. -* `ci`:\\[in,out\\] A [`p8est_corner_info_t`](@ref) structure with initialized array. +* `p1`:\\[in,out\\] A 3D vector. +* `p2`:\\[in,out\\] A 3D vector. ### Prototype ```c -void p8est_find_corner_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t * ci); +static inline void t8_vec_swap (double p1[3], double p2[3]); ``` """ -function p8est_find_corner_transform(connectivity, itree, icorner, ci) - @ccall libp4est.p8est_find_corner_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, icorner::Cint, ci::Ptr{p8est_corner_info_t})::Cvoid +function t8_vec_swap(p1, p2) + @ccall libt8.t8_vec_swap(p1::Ptr{Cdouble}, p2::Ptr{Cdouble})::Cvoid end +# no prototype is found for this function at t8_version.h:70:1, please use with caution """ - p8est_connectivity_complete(conn) + t8_get_package_string() -Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. +Return the package string of t8code. This string has the format "t8 version\\_number". -# Arguments -* `conn`:\\[in,out\\] The connectivity needs to have proper vertices and tree\\_to\\_vertex fields. The tree\\_to\\_tree and tree\\_to\\_face fields must be allocated and satisfy [`p8est_connectivity_is_valid`](@ref) (conn) but will be overwritten. The edge and corner fields will be freed and allocated anew. +# Returns +The version string of t8code. ### Prototype ```c -void p8est_connectivity_complete (p8est_connectivity_t * conn); +const char* t8_get_package_string (); ``` """ -function p8est_connectivity_complete(conn) - @ccall libp4est.p8est_connectivity_complete(conn::Ptr{p8est_connectivity_t})::Cvoid +function t8_get_package_string() + @ccall libt8.t8_get_package_string()::Cstring end +# no prototype is found for this function at t8_version.h:76:1, please use with caution """ - p8est_connectivity_reduce(conn) + t8_get_version_number() -Removes corner and edge information of a connectivity such that enough information is left to run [`p8est_connectivity_complete`](@ref) successfully. The reduced connectivity still passes [`p8est_connectivity_is_valid`](@ref). +Return the version number of t8code as a string. -# Arguments -* `conn`:\\[in,out\\] The connectivity to be reduced. +# Returns +The version number of t8code as a string. ### Prototype ```c -void p8est_connectivity_reduce (p8est_connectivity_t * conn); +const char* t8_get_version_number (); ``` """ -function p8est_connectivity_reduce(conn) - @ccall libp4est.p8est_connectivity_reduce(conn::Ptr{p8est_connectivity_t})::Cvoid +function t8_get_version_number() + @ccall libt8.t8_get_version_number()::Cstring end +# no prototype is found for this function at t8_version.h:82:1, please use with caution """ - p8est_connectivity_permute(conn, perm, is_current_to_new) + t8_get_version_point_string() -[`p8est_connectivity_permute`](@ref) Given a permutation *perm* of the trees in a connectivity *conn*, permute the trees of *conn* in place and update *conn* to match. +Return the version point string. -# Arguments -* `conn`:\\[in,out\\] The connectivity whose trees are permuted. -* `perm`:\\[in\\] A permutation array, whose elements are size\\_t's. -* `is_current_to_new`:\\[in\\] if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation. +# Returns +The version point point string. ### Prototype ```c -void p8est_connectivity_permute (p8est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); +const char* t8_get_version_point_string (); ``` """ -function p8est_connectivity_permute(conn, perm, is_current_to_new) - @ccall libp4est.p8est_connectivity_permute(conn::Ptr{p8est_connectivity_t}, perm::Ptr{sc_array_t}, is_current_to_new::Cint)::Cvoid +function t8_get_version_point_string() + @ccall libt8.t8_get_version_point_string()::Cstring end +# no prototype is found for this function at t8_version.h:88:1, please use with caution """ - p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + t8_get_version_major() -[`p8est_connectivity_join_faces`](@ref) This function takes an existing valid connectivity *conn* and modifies it by joining two tree faces that are currently boundary faces. +Return the major version number of t8code. -# Arguments -* `conn`:\\[in,out\\] connectivity that will be altered. -* `tree_left`:\\[in\\] tree that will be on the left side of the joined faces. -* `tree_right`:\\[in\\] tree that will be on the right side of the joined faces. -* `face_left`:\\[in\\] face of *tree_left* that will be joined. -* `face_right`:\\[in\\] face of *tree_right* that will be joined. -* `orientation`:\\[in\\] the orientation of *face_left* and *face_right* once joined (see the description of [`p8est_connectivity_t`](@ref) to understand orientation). +# Returns +The major version number of t8code. ### Prototype ```c -void p8est_connectivity_join_faces (p8est_connectivity_t * conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation); +int t8_get_version_major (); ``` """ -function p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) - @ccall libp4est.p8est_connectivity_join_faces(conn::Ptr{p8est_connectivity_t}, tree_left::p4est_topidx_t, tree_right::p4est_topidx_t, face_left::Cint, face_right::Cint, orientation::Cint)::Cvoid +function t8_get_version_major() + @ccall libt8.t8_get_version_major()::Cint end +# no prototype is found for this function at t8_version.h:94:1, please use with caution """ - p8est_connectivity_is_equivalent(conn1, conn2) + t8_get_version_minor() -[`p8est_connectivity_is_equivalent`](@ref) This function compares two connectivities for equivalence: it returns *true* if they are the same connectivity, or if they have the same topology. The definition of topological sameness is strict: there is no attempt made to determine whether permutation and/or rotation of the trees makes the connectivities equivalent. +Return the minor version number of t8code. -# Arguments -* `conn1`:\\[in\\] a valid connectivity -* `conn2`:\\[out\\] a valid connectivity +# Returns +The minor version number of t8code. ### Prototype ```c -int p8est_connectivity_is_equivalent (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); +int t8_get_version_minor (); ``` """ -function p8est_connectivity_is_equivalent(conn1, conn2) - @ccall libp4est.p8est_connectivity_is_equivalent(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint +function t8_get_version_minor() + @ccall libt8.t8_get_version_minor()::Cint end +# no prototype is found for this function at t8_version.h:104:1, please use with caution """ - p8est_edge_array_index(array, it) + t8_get_version_patch() + +Return the patch version number of t8code. + +!!! note + + In contrast to t8_get_version_major and t8_get_version_minor the patch version number must be computed from *T8_VERSION_POINT* This computation may result in an error or an invalid patch number. In that case a negative patch version is returned. +# Returns +The patch version unmber of t8code. negative on error. ### Prototype ```c -static inline p8est_edge_transform_t * p8est_edge_array_index (sc_array_t *array, size_t it); +int t8_get_version_patch (); ``` """ -function p8est_edge_array_index(array, it) - @ccall libp4est.p8est_edge_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_edge_transform_t} +function t8_get_version_patch() + @ccall libt8.t8_get_version_patch()::Cint +end + +@cenum t8_vtk_data_type_t::UInt32 begin + T8_VTK_SCALAR = 0 + T8_VTK_VECTOR = 1 end """ - p8est_corner_array_index(array, it) + t8_vtk_data_field_t + +| Field | Note | +| :---------- | :----------------------------------------- | +| type | Describes of which type the data array is | +| description | String that describes the data. | +""" +struct t8_vtk_data_field_t + type::t8_vtk_data_type_t + description::NTuple{8192, Cchar} + data::Ptr{Cdouble} +end + +""" + t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) ### Prototype ```c -static inline p8est_corner_transform_t * p8est_corner_array_index (sc_array_t *array, size_t it); +int t8_write_pvtu (const char *filename, int num_procs, int write_tree, int write_rank, int write_level, int write_id, int num_data, t8_vtk_data_field_t *data); ``` """ -function p8est_corner_array_index(array, it) - @ccall libp4est.p8est_corner_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_corner_transform_t} +function t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) + @ccall libt8.t8_write_pvtu(filename::Cstring, num_procs::Cint, write_tree::Cint, write_rank::Cint, write_level::Cint, write_id::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) + getdelim(lineptr, n, delimiter, stream) -Read an ABAQUS input file from a file stream. +### Prototype +```c +static ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream); +``` +""" +function getdelim(lineptr, n, delimiter, stream) + @ccall libt8.getdelim(lineptr::Ptr{Cstring}, n::Ptr{Cint}, delimiter::Cint, stream::Ptr{Cint})::Cint +end -This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. +""" + getline(lineptr, n, stream) -A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: +### Prototype +```c +static ssize_t getline (char **lineptr, size_t *n, FILE *stream); +``` +""" +function getline(lineptr, n, stream) + @ccall libt8.getline(lineptr::Ptr{Cstring}, n::Ptr{Cint}, stream::Ptr{Cint})::Cint +end -4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 +""" + strsep(stringp, delim) -and in 3D they are given as: +Extract token from string up to a given delimiter. -8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 +For a full description see https://linux.die.net/man/3/[`strsep`](@ref) -```c++ - *Heading - box.inp - *Node - 1, 5, -5, 5 - 2, 5, 5, 5 - 3, 5, 0, 5 - 4, -5, 5, 5 - 5, 0, 5, 5 - 6, -5, -5, 5 - 7, -5, 0, 5 - 8, 0, -5, 5 - 9, 0, 0, 5 - 10, 5, 5, -5 - 11, 5, -5, -5 - 12, 5, 0, -5 - 13, -5, -5, -5 - 14, 0, -5, -5 - 15, -5, 5, -5 - 16, -5, 0, -5 - 17, 0, 5, -5 - 18, 0, 0, -5 - 19, -5, -5, 0 - 20, 5, -5, 0 - 21, 0, -5, 0 - 22, -5, 5, 0 - 23, -5, 0, 0 - 24, 5, 5, 0 - 25, 0, 5, 0 - 26, 5, 0, 0 - 27, 0, 0, 0 - *Element, type=C3D8, ELSET=EB1 - 1, 6, 19, 23, 7, 8, 21, 27, 9 - 2, 19, 13, 16, 23, 21, 14, 18, 27 - 3, 7, 23, 22, 4, 9, 27, 25, 5 - 4, 23, 16, 15, 22, 27, 18, 17, 25 - 5, 8, 21, 27, 9, 1, 20, 26, 3 - 6, 21, 14, 18, 27, 20, 11, 12, 26 - 7, 9, 27, 25, 5, 3, 26, 24, 2 - 8, 27, 18, 17, 25, 26, 12, 10, 24 +### Prototype +```c +static char * strsep (char **stringp, const char *delim); +``` +""" +function strsep(stringp, delim) + @ccall libt8.strsep(stringp::Ptr{Cstring}, delim::Cstring)::Cstring +end + +""" + t8_cmesh_copy(cmesh, cmesh_from, comm) + +### Prototype +```c +void t8_cmesh_copy (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, sc_MPI_Comm comm); +``` +""" +function t8_cmesh_copy(cmesh, cmesh_from, comm) + @ccall libt8.t8_cmesh_copy(cmesh::t8_cmesh_t, cmesh_from::t8_cmesh_t, comm::MPI_Comm)::Cvoid +end + +""" + sc_io_read(mpifile, ptr, zcount, t, errmsg) + +### Prototype +```c +void sc_io_read (sc_MPI_File mpifile, void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); +``` +""" +function sc_io_read(mpifile, ptr, zcount, t, errmsg) + @ccall libsc.sc_io_read(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid +end + +""" + sc_io_write(mpifile, ptr, zcount, t, errmsg) + +### Prototype +```c +void sc_io_write (sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); +``` +""" +function sc_io_write(mpifile, ptr, zcount, t, errmsg) + @ccall libsc.sc_io_write(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid +end + +"""Typedef for quadrant coordinates.""" +const p4est_qcoord_t = Int32 + +"""Typedef for counting topological entities (trees, tree vertices).""" +const p4est_topidx_t = Int32 + +"""Typedef for processor-local indexing of quadrants and nodes.""" +const p4est_locidx_t = Int32 + +"""Typedef for globally unique indexing of quadrants.""" +const p4est_gloidx_t = Int64 + +""" + sc_io_error_t + +Error values for io. + +| Enumerator | Note | +| :---------------------- | :--------------------------------------------------------------------------- | +| SC\\_IO\\_ERROR\\_NONE | The value of zero means no error. | +| SC\\_IO\\_ERROR\\_FATAL | The io object is now dysfunctional. | +| SC\\_IO\\_ERROR\\_AGAIN | Another io operation may resolve it. The function just returned was a noop. | +""" +@cenum sc_io_error_t::Int32 begin + SC_IO_ERROR_NONE = 0 + SC_IO_ERROR_FATAL = -1 + SC_IO_ERROR_AGAIN = -2 +end + +""" + sc_io_mode_t + +The I/O mode for writing using sc_io_sink. + +| Enumerator | Note | +| :---------------------- | :--------------------------- | +| SC\\_IO\\_MODE\\_WRITE | Semantics as "w" in fopen. | +| SC\\_IO\\_MODE\\_APPEND | Semantics as "a" in fopen. | +| SC\\_IO\\_MODE\\_LAST | Invalid entry to close list | +""" +@cenum sc_io_mode_t::UInt32 begin + SC_IO_MODE_WRITE = 0 + SC_IO_MODE_APPEND = 1 + SC_IO_MODE_LAST = 2 +end + +""" + sc_io_encode_t + +Enum to specify encoding for sc_io_sink and sc_io_source. + +| Enumerator | Note | +| :---------------------- | :--------------------------- | +| SC\\_IO\\_ENCODE\\_NONE | No encoding | +| SC\\_IO\\_ENCODE\\_LAST | Invalid entry to close list | +""" +@cenum sc_io_encode_t::UInt32 begin + SC_IO_ENCODE_NONE = 0 + SC_IO_ENCODE_LAST = 1 +end + +""" + sc_io_type_t + +The type of I/O operation sc_io_sink and sc_io_source. + +| Enumerator | Note | +| :------------------------ | :------------------------------- | +| SC\\_IO\\_TYPE\\_BUFFER | Write to a buffer | +| SC\\_IO\\_TYPE\\_FILENAME | Write to a file to be opened | +| SC\\_IO\\_TYPE\\_FILEFILE | Write to an already opened file | +| SC\\_IO\\_TYPE\\_LAST | Invalid entry to close list | +""" +@cenum sc_io_type_t::UInt32 begin + SC_IO_TYPE_BUFFER = 0 + SC_IO_TYPE_FILENAME = 1 + SC_IO_TYPE_FILEFILE = 2 + SC_IO_TYPE_LAST = 3 +end + +""" + sc_io_sink + +A generic data sink. + +| Field | Note | +| :------------- | :---------------------------------------------------- | +| iotype | type of the I/O operation | +| mode | write semantics | +| encode | encoding of data | +| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | +| buffer\\_bytes | distinguish from array elements | +| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | +| bytes\\_in | input bytes count | +| bytes\\_out | written bytes count | +| is\\_eof | Have we reached the end of file? | +""" +struct sc_io_sink + iotype::sc_io_type_t + mode::sc_io_mode_t + encode::sc_io_encode_t + buffer::Ptr{sc_array_t} + buffer_bytes::Csize_t + file::Ptr{Libc.FILE} + bytes_in::Csize_t + bytes_out::Csize_t + is_eof::Cint +end + +"""A generic data sink.""" +const sc_io_sink_t = sc_io_sink + +""" + sc_io_source + +A generic data source. + +| Field | Note | +| :-------------- | :---------------------------------------------------- | +| iotype | type of the I/O operation | +| encode | encoding of data | +| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | +| buffer\\_bytes | distinguish from array elements | +| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | +| bytes\\_in | input bytes count | +| bytes\\_out | read bytes count | +| is\\_eof | Have we reached the end of file? | +| mirror | if activated, a sink to store the data | +| mirror\\_buffer | if activated, the buffer for the mirror | +""" +struct sc_io_source + iotype::sc_io_type_t + encode::sc_io_encode_t + buffer::Ptr{sc_array_t} + buffer_bytes::Csize_t + file::Ptr{Libc.FILE} + bytes_in::Csize_t + bytes_out::Csize_t + is_eof::Cint + mirror::Ptr{sc_io_sink_t} + mirror_buffer::Ptr{sc_array_t} +end + +"""A generic data source.""" +const sc_io_source_t = sc_io_source + +""" + sc_io_open_mode_t + +Open modes for sc_io_open + +| Enumerator | Note | +| :----------------------- | :------------------------------------------------------------------------------------------------------------------ | +| SC\\_IO\\_READ | open a file in read-only mode | +| SC\\_IO\\_WRITE\\_CREATE | open a file in write-only mode; if the file exists, the file will be truncated to length zero and then overwritten | +| SC\\_IO\\_WRITE\\_APPEND | append to an already existing file | +""" +@cenum sc_io_open_mode_t::UInt32 begin + SC_IO_READ = 0 + SC_IO_WRITE_CREATE = 1 + SC_IO_WRITE_APPEND = 2 +end + +# automatic type deduction for variadic arguments may not be what you want, please use with caution +@generated function sc_io_sink_new(iotype, iomode, ioencode, va_list...) + :(@ccall(libsc.sc_io_sink_new(iotype::Cint, iomode::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_sink_t})) + end + +""" + sc_io_sink_destroy(sink) + +Free data sink. Calls [`sc_io_sink_complete`](@ref) and discards the final counts. Errors from complete lead to SC\\_IO\\_ERROR\\_FATAL returned from this function. Call [`sc_io_sink_complete`](@ref) yourself if bytes\\_out is of interest. + +# Arguments +* `sink`:\\[in,out\\] The sink object to complete and free. +# Returns +0 on success, nonzero on error. +### Prototype +```c +int sc_io_sink_destroy (sc_io_sink_t * sink); +``` +""" +function sc_io_sink_destroy(sink) + @ccall libsc.sc_io_sink_destroy(sink::Ptr{sc_io_sink_t})::Cint +end + +""" + sc_io_sink_destroy_null(sink) + +Free data sink and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_sink_destroy. + +# Arguments +* `sink`:\\[in,out\\] Non-NULL pointer to sink pointer. The sink pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_sink, which is passed to sc_io_sink_destroy, and the sink pointer is set to NULL afterwards. +# Returns +0 on success, nonzero on error. +### Prototype +```c +int sc_io_sink_destroy_null (sc_io_sink_t ** sink); +``` +""" +function sc_io_sink_destroy_null(sink) + @ccall libsc.sc_io_sink_destroy_null(sink::Ptr{Ptr{sc_io_sink_t}})::Cint +end + +""" + sc_io_sink_write(sink, data, bytes_avail) + +Write data to a sink. Data may be buffered and sunk in a later call. The internal counters sink->bytes\\_in and sink->bytes\\_out are updated. + +# Arguments +* `sink`:\\[in,out\\] The sink object to write to. +* `data`:\\[in\\] Data passed into sink must be non-NULL. +* `bytes_avail`:\\[in\\] Number of data bytes passed in. +# Returns +0 on success, nonzero on error. +### Prototype +```c +int sc_io_sink_write (sc_io_sink_t * sink, const void *data, size_t bytes_avail); +``` +""" +function sc_io_sink_write(sink, data, bytes_avail) + @ccall libsc.sc_io_sink_write(sink::Ptr{sc_io_sink_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t)::Cint +end + +""" + sc_io_sink_complete(sink, bytes_in, bytes_out) + +Flush all buffered output data to sink. This function may return SC\\_IO\\_ERROR\\_AGAIN if another write is required. Currently this may happen if BUFFER requires an integer multiple of bytes. If successful, the updated value of bytes read and written is returned in bytes\\_in/out, and the sink status is reset as if the sink had just been created. In particular, the bytes counters are reset to zero. The internal state of the sink is not changed otherwise. It is legal to continue writing to the sink hereafter. The sink actions taken depend on its type. BUFFER, FILEFILE: none. FILENAME: call fclose on sink->file. + +# Arguments +* `sink`:\\[in,out\\] The sink object to write to. +* `bytes_in`:\\[in,out\\] Bytes received since the last new or complete call. May be NULL. +* `bytes_out`:\\[in,out\\] Bytes written since the last new or complete call. May be NULL. +# Returns +0 if completed, nonzero on error. +### Prototype +```c +int sc_io_sink_complete (sc_io_sink_t * sink, size_t *bytes_in, size_t *bytes_out); +``` +""" +function sc_io_sink_complete(sink, bytes_in, bytes_out) + @ccall libsc.sc_io_sink_complete(sink::Ptr{sc_io_sink_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint +end + +""" + sc_io_sink_align(sink, bytes_align) + +Align sink to a byte boundary by writing zeros. + +# Arguments +* `sink`:\\[in,out\\] The sink object to align. +* `bytes_align`:\\[in\\] Byte boundary. +# Returns +0 on success, nonzero on error. +### Prototype +```c +int sc_io_sink_align (sc_io_sink_t * sink, size_t bytes_align); +``` +""" +function sc_io_sink_align(sink, bytes_align) + @ccall libsc.sc_io_sink_align(sink::Ptr{sc_io_sink_t}, bytes_align::Csize_t)::Cint +end + +# automatic type deduction for variadic arguments may not be what you want, please use with caution +@generated function sc_io_source_new(iotype, ioencode, va_list...) + :(@ccall(libsc.sc_io_source_new(iotype::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_source_t})) + end + +""" + sc_io_source_destroy(source) + +Free data source. Calls [`sc_io_source_complete`](@ref) and requires it to return no error. This is to avoid discarding buffered data that has not been passed to read. + +# Arguments +* `source`:\\[in,out\\] The source object to free. +# Returns +0 on success. Nonzero if an error is encountered or is\\_complete returns one. +### Prototype +```c +int sc_io_source_destroy (sc_io_source_t * source); +``` +""" +function sc_io_source_destroy(source) + @ccall libsc.sc_io_source_destroy(source::Ptr{sc_io_source_t})::Cint +end + +""" + sc_io_source_destroy_null(source) + +Free data source and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_source_destroy. + +# Arguments +* `source`:\\[in,out\\] Non-NULL pointer to source pointer. The source pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_source, which is passed to sc_io_source_destroy, and the source pointer is set to NULL afterwards. +# Returns +0 on success, nonzero on error. +### Prototype +```c +int sc_io_source_destroy_null (sc_io_source_t ** source); +``` +""" +function sc_io_source_destroy_null(source) + @ccall libsc.sc_io_source_destroy_null(source::Ptr{Ptr{sc_io_source_t}})::Cint +end + +""" + sc_io_source_read(source, data, bytes_avail, bytes_out) + +Read data from a source. The internal counters source->bytes\\_in and source->bytes\\_out are updated. Data is read until the data buffer has not enough room anymore, or source becomes empty. It is possible that data already read internally remains in the source object for the next call. Call [`sc_io_source_complete`](@ref) and check its return value to find out. Returns an error if bytes\\_out is NULL and less than bytes\\_avail are read. + +# Arguments +* `source`:\\[in,out\\] The source object to read from. +* `data`:\\[in\\] Data buffer for reading from source. If NULL the output data will be ignored and we seek forward in the input. +* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. +* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. If this condition is not met, return an error. +# Returns +0 on success, nonzero on error. +### Prototype +```c +int sc_io_source_read (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); +``` +""" +function sc_io_source_read(source, data, bytes_avail, bytes_out) + @ccall libsc.sc_io_source_read(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint +end + +""" + sc_io_source_complete(source, bytes_in, bytes_out) + +Determine whether all data buffered from source has been returned by read. If it returns SC\\_IO\\_ERROR\\_AGAIN, another [`sc_io_source_read`](@ref) is required. If the call returns no error, the internal counters source->bytes\\_in and source->bytes\\_out are returned to the caller if requested, and reset to 0. The internal state of the source is not changed otherwise. It is legal to continue reading from the source hereafter. + +# Arguments +* `source`:\\[in,out\\] The source object to read from. +* `bytes_in`:\\[in,out\\] If not NULL and true is returned, the total size of the data sourced. +* `bytes_out`:\\[in,out\\] If not NULL and true is returned, total bytes passed out by source\\_read. +# Returns +SC\\_IO\\_ERROR\\_AGAIN if buffered data remaining. Otherwise return ERROR\\_NONE and reset counters. +### Prototype +```c +int sc_io_source_complete (sc_io_source_t * source, size_t *bytes_in, size_t *bytes_out); +``` +""" +function sc_io_source_complete(source, bytes_in, bytes_out) + @ccall libsc.sc_io_source_complete(source::Ptr{sc_io_source_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint +end + +""" + sc_io_source_align(source, bytes_align) + +Align source to a byte boundary by skipping. + +# Arguments +* `source`:\\[in,out\\] The source object to align. +* `bytes_align`:\\[in\\] Byte boundary. +# Returns +0 on success, nonzero on error. +### Prototype +```c +int sc_io_source_align (sc_io_source_t * source, size_t bytes_align); +``` +""" +function sc_io_source_align(source, bytes_align) + @ccall libsc.sc_io_source_align(source::Ptr{sc_io_source_t}, bytes_align::Csize_t)::Cint +end + +""" + sc_io_source_activate_mirror(source) + +Activate a buffer that mirrors (i.e., stores) the data that was read. + +# Arguments +* `source`:\\[in,out\\] The source object to activate mirror in. +# Returns +0 on success, nonzero on error. +### Prototype +```c +int sc_io_source_activate_mirror (sc_io_source_t * source); +``` +""" +function sc_io_source_activate_mirror(source) + @ccall libsc.sc_io_source_activate_mirror(source::Ptr{sc_io_source_t})::Cint +end + +""" + sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) + +Read data from the source's mirror. Same behaviour as [`sc_io_source_read`](@ref). + +# Arguments +* `source`:\\[in,out\\] The source object to read mirror data from. +* `data`:\\[in\\] Data buffer for reading from source's mirror. If NULL the output data will be thrown away. +* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. +* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. +# Returns +0 on success, nonzero on error. +### Prototype +```c +int sc_io_source_read_mirror (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); +``` +""" +function sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) + @ccall libsc.sc_io_source_read_mirror(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint +end + +""" + sc_io_file_save(filename, buffer) + +Save a buffer to a file in one call. This function performs error checking and always returns cleanly. + +# Arguments +* `filename`:\\[in\\] Name of the file to save. +* `buffer`:\\[in\\] An array of element size 1 and arbitrary contents, which are written to the file. +# Returns +0 on success, -1 on error. +### Prototype +```c +int sc_io_file_save (const char *filename, sc_array_t * buffer); +``` +""" +function sc_io_file_save(filename, buffer) + @ccall libsc.sc_io_file_save(filename::Cstring, buffer::Ptr{sc_array_t})::Cint +end + +""" + sc_io_file_load(filename, buffer) + +Read a file into a buffer in one call. This function performs error checking and always returns cleanly. + +# Arguments +* `filename`:\\[in\\] Name of the file to load. +* `buffer`:\\[in,out\\] On input, an array (not a view) of element size 1 and arbitrary contents. On output and success, the complete file contents. On error, contents are undefined. +# Returns +0 on success, -1 on error. +### Prototype +```c +int sc_io_file_load (const char *filename, sc_array_t * buffer); +``` +""" +function sc_io_file_load(filename, buffer) + @ccall libsc.sc_io_file_load(filename::Cstring, buffer::Ptr{sc_array_t})::Cint +end + +""" + sc_io_encode(data, out) + +Encode a block of arbitrary data with the default sc\\_io format. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. + +Currently this function calls sc_io_encode_zlib with compression level Z\\_BEST\\_COMPRESSION (subject to change). Without zlib configured that function works uncompressed. + +The encoding method and input data size can be retrieved, optionally, from the encoded data by sc_io_decode_info. This function decodes the method as a character, which is 'z' for sc_io_encode_zlib. We reserve the characters A-C, d-z indefinitely. + +# Arguments +* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. +* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. +### Prototype +```c +void sc_io_encode (sc_array_t *data, sc_array_t *out); +``` +""" +function sc_io_encode(data, out) + @ccall libsc.sc_io_encode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t})::Cvoid +end + +""" + sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) + +Encode a block of arbitrary data, compressed, into an ASCII string. This is a two-stage process: zlib compress and then encode to base 64. The output is a NUL-terminated string of printable characters. + +We first compress the data into the zlib deflate format (RFC 1951). The compressor must use no preset dictionary (this is the default). If zlib is detected on configuration, we compress with the given level. If zlib is not detected, we write data equivalent to Z\\_NO\\_COMPRESSION. The status of zlib detection can be queried at compile time using #ifdef [`SC_HAVE_ZLIB`](@ref) or at run time using sc_have_zlib. Both types of result are readable by a standard zlib uncompress call. + +Secondly, we process the input data size as an 8-byte big-endian number, then the letter 'z', and then the zlib compressed data, concatenated, with a base 64 encoder. We break lines after 76 code characters. Each line break consists of two configurable but arbitrary bytes. The line breaks are considered part of the output data specification. The last line is terminated with the same line break and then a NUL. + +This routine can work in place or write to an output array. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. + +# Arguments +* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. +* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. +* `zlib_compression_level`:\\[in\\] Compression level between 0 (no compression) and 9 (best compression). The value -1 indicates some default level. +* `line_break_character`:\\[in\\] This character is arbitrary and specifies the first of two line break bytes. The second byte is always ''. +### Prototype +```c +void sc_io_encode_zlib (sc_array_t *data, sc_array_t *out, int zlib_compression_level, int line_break_character); +``` +""" +function sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) + @ccall libsc.sc_io_encode_zlib(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, zlib_compression_level::Cint, line_break_character::Cint)::Cvoid +end + +""" + sc_io_decode_info(data, original_size, format_char, re) + +Decode length and format of original input from encoded data. We expect at least 12 bytes of the format produced by sc_io_encode. No matter how much data has been encoded by it, this much is available. We decode the original data size and the character indicating the format. + +This function does not require zlib. It works with any well-defined data. + +Note that this function is not required before sc_io_decode. Calling this function on any result produced by sc_io_encode will succeed and report a legal format. This function cannot crash. + +# Arguments +* `data`:\\[in\\] This must be an array with element size 1. If it contains less than 12 code bytes we error out. It its first 12 bytes do not base 64 decode to 9 bytes we error out. We generally ignore the remaining data. +* `original_size`:\\[out\\] If not NULL and we do not error out, set to the original size as encoded in the data. +* `format_char`:\\[out\\] If not NULL and we do not error out, the ninth character of decoded data indicating the format. +* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. +# Returns +0 on success, negative value on error. +### Prototype +```c +int sc_io_decode_info (sc_array_t *data, size_t *original_size, char *format_char, void *re); +``` +""" +function sc_io_decode_info(data, original_size, format_char, re) + @ccall libsc.sc_io_decode_info(data::Ptr{sc_array_t}, original_size::Ptr{Csize_t}, format_char::Cstring, re::Ptr{Cvoid})::Cint +end + +""" + sc_io_decode(data, out, max_original_size, re) + +Decode a block of base 64 encoded compressed data. The base 64 data must contain two arbitrary bytes after every 76 code characters and also at the end of the last line if it is short, and then a final NUL character. This function does not require zlib but benefits for speed. + +This is a two-stage process: we decode the input from base 64 first. Then we extract the 8-byte big-endian original data size, the character 'z', and execute a zlib decompression on the remaining decoded data. This function detects malformed input by erroring out. + +If we should add another format in the future, the format character may be something else than 'z', as permitted by our specification. To this end, we reserve the characters A-C and d-z indefinitely. + +Any error condition is indicated by a negative return value. Possible causes for error are: + +- the input data string is not NUL-terminated - the first 12 characters of input do not decode properly - the input data is corrupt for decoding or decompression - the output data array has non-unit element size and the length of the output data is not divisible by the size - the output data would exceed the specified threshold - the output array is a view of insufficient length + +We also error out if the data requires a compression dictionary, which would be a violation of above encode format specification. + +The corresponding encode function is sc_io_encode. When passing an array as output, we resize it properly. This function cannot crash unless out of memory. + +# Arguments +* `data`:\\[in,out\\] If *out* is NULL, we work in place. In that case, output is written into this array after a suitable resize. Either way, we expect a NUL-terminated base 64 encoded string on input that has in turn been obtained by zlib compression. It must be in the exact format produced by sc_io_encode; please see documentation. The element size of the input array must be 1. +* `out`:\\[in,out\\] If not NULL, a valid array (may be a view). If NULL, the input array becomes the output. If the output array is a view and the output data larger than its view size, we error out. We expect commensurable element and data size and resize the output to fit exactly, which restores the original input passed to encoding. An output view array of matching size may be constructed using sc_io_decode_info. +* `max_original_size`:\\[in\\] If nonzero, this is the maximal data size that we will accept after uncompression. If exceeded, return a negative value. +* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. +# Returns +0 on success, negative on malformed input data or insufficient output space. +### Prototype +```c +int sc_io_decode (sc_array_t *data, sc_array_t *out, size_t max_original_size, void *re); +``` +""" +function sc_io_decode(data, out, max_original_size, re) + @ccall libsc.sc_io_decode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, max_original_size::Csize_t, re::Ptr{Cvoid})::Cint +end + +""" + sc_vtk_write_binary(vtkfile, numeric_data, byte_length) + +This function writes numeric binary data in VTK base64 encoding. + +# Arguments +* `vtkfile`: Stream opened for writing. +* `numeric_data`: A pointer to a numeric data array. +* `byte_length`: The length of the data array in bytes. +# Returns +Returns 0 on success, -1 on file error. +### Prototype +```c +int sc_vtk_write_binary (FILE * vtkfile, char *numeric_data, size_t byte_length); +``` +""" +function sc_vtk_write_binary(vtkfile, numeric_data, byte_length) + @ccall libsc.sc_vtk_write_binary(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint +end + +""" + sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) + +This function writes numeric binary data in VTK compressed format. + +# Arguments +* `vtkfile`: Stream opened for writing. +* `numeric_data`: A pointer to a numeric data array. +* `byte_length`: The length of the data array in bytes. +# Returns +Returns 0 on success, -1 on file error. +### Prototype +```c +int sc_vtk_write_compressed (FILE * vtkfile, char *numeric_data, size_t byte_length); +``` +""" +function sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) + @ccall libsc.sc_vtk_write_compressed(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint +end + +""" + sc_fopen(filename, mode, errmsg) + +Wrapper for fopen(3). We provide an additional argument that contains the error message. + +### Prototype +```c +FILE *sc_fopen (const char *filename, const char *mode, const char *errmsg); +``` +""" +function sc_fopen(filename, mode, errmsg) + @ccall libsc.sc_fopen(filename::Cstring, mode::Cstring, errmsg::Cstring)::Ptr{Libc.FILE} +end + +""" + sc_fwrite(ptr, size, nmemb, file, errmsg) + +Write memory content to a file. + +!!! note + + This function aborts on file errors. + +# Arguments +* `ptr`:\\[in\\] Data array to write to disk. +* `size`:\\[in\\] Size of one array member. +* `nmemb`:\\[in\\] Number of array members. +* `file`:\\[in,out\\] File pointer, must be opened for writing. +* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). +### Prototype +```c +void sc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); +``` +""" +function sc_fwrite(ptr, size, nmemb, file, errmsg) + @ccall libsc.sc_fwrite(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid +end + +""" + sc_fread(ptr, size, nmemb, file, errmsg) + +Read file content into memory. + +!!! note + + This function aborts on file errors. + +# Arguments +* `ptr`:\\[out\\] Data array to read from disk. +* `size`:\\[in\\] Size of one array member. +* `nmemb`:\\[in\\] Number of array members. +* `file`:\\[in,out\\] File pointer, must be opened for reading. +* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). +### Prototype +```c +void sc_fread (void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); +``` +""" +function sc_fread(ptr, size, nmemb, file, errmsg) + @ccall libsc.sc_fread(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid +end + +""" + sc_fflush_fsync_fclose(file) + +Best effort to flush a file's data to disc and close it. + +# Arguments +* `file`:\\[in,out\\] File open for writing. +### Prototype +```c +void sc_fflush_fsync_fclose (FILE * file); +``` +""" +function sc_fflush_fsync_fclose(file) + @ccall libsc.sc_fflush_fsync_fclose(file::Ptr{Libc.FILE})::Cvoid +end + +""" + sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) + +### Prototype +```c +int sc_io_open (sc_MPI_Comm mpicomm, const char *filename, sc_io_open_mode_t amode, sc_MPI_Info mpiinfo, sc_MPI_File * mpifile); +``` +""" +function sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) + @ccall libsc.sc_io_open(mpicomm::MPI_Comm, filename::Cstring, amode::sc_io_open_mode_t, mpiinfo::Cint, mpifile::Ptr{Cint})::Cint +end + +""" + sc_io_read_at(mpifile, offset, ptr, count, t, ocount) + +### Prototype +```c +int sc_io_read_at (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); +``` +""" +function sc_io_read_at(mpifile, offset, ptr, count, t, ocount) + @ccall libsc.sc_io_read_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint +end + +""" + sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) + +### Prototype +```c +int sc_io_read_at_all (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); +``` +""" +function sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) + @ccall libsc.sc_io_read_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint +end + +""" + sc_io_write_at(mpifile, offset, ptr, count, t, ocount) + +### Prototype +```c +int sc_io_write_at (sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount); +``` +""" +function sc_io_write_at(mpifile, offset, ptr, count, t, ocount) + @ccall libsc.sc_io_write_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint +end + +""" + sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) + +### Prototype +```c +int sc_io_write_at_all (sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount); +``` +""" +function sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) + @ccall libsc.sc_io_write_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint +end + +""" + sc_io_close(file) + +### Prototype +```c +int sc_io_close (sc_MPI_File * file); +``` +""" +function sc_io_close(file) + @ccall libsc.sc_io_close(file::Ptr{Cint})::Cint +end + +""" + p4est_comm_tag + +Tags for MPI messages +""" +@cenum p4est_comm_tag::UInt32 begin + P4EST_COMM_TAG_FIRST = 214 + P4EST_COMM_COUNT_PERTREE = 295 + P4EST_COMM_BALANCE_FIRST_COUNT = 296 + P4EST_COMM_BALANCE_FIRST_LOAD = 297 + P4EST_COMM_BALANCE_SECOND_COUNT = 298 + P4EST_COMM_BALANCE_SECOND_LOAD = 299 + P4EST_COMM_PARTITION_GIVEN = 300 + P4EST_COMM_PARTITION_WEIGHTED_LOW = 301 + P4EST_COMM_PARTITION_WEIGHTED_HIGH = 302 + P4EST_COMM_PARTITION_CORRECTION = 303 + P4EST_COMM_GHOST_COUNT = 304 + P4EST_COMM_GHOST_LOAD = 305 + P4EST_COMM_GHOST_EXCHANGE = 306 + P4EST_COMM_GHOST_EXPAND_COUNT = 307 + P4EST_COMM_GHOST_EXPAND_LOAD = 308 + P4EST_COMM_GHOST_SUPPORT_COUNT = 309 + P4EST_COMM_GHOST_SUPPORT_LOAD = 310 + P4EST_COMM_GHOST_CHECKSUM = 311 + P4EST_COMM_NODES_QUERY = 312 + P4EST_COMM_NODES_REPLY = 313 + P4EST_COMM_SAVE = 314 + P4EST_COMM_LNODES_TEST = 315 + P4EST_COMM_LNODES_PASS = 316 + P4EST_COMM_LNODES_OWNED = 317 + P4EST_COMM_LNODES_ALL = 318 + P4EST_COMM_TAG_LAST = 319 +end + +"""Tags for MPI messages""" +const p4est_comm_tag_t = p4est_comm_tag + +""" + p4est_log_indent_push() + +### Prototype +```c +static inline void p4est_log_indent_push (void); +``` +""" +function p4est_log_indent_push() + @ccall libp4est.p4est_log_indent_push()::Cvoid +end + +""" + p4est_log_indent_pop() + +### Prototype +```c +static inline void p4est_log_indent_pop (void); +``` +""" +function p4est_log_indent_pop() + @ccall libp4est.p4est_log_indent_pop()::Cvoid +end + +""" + p4est_init(log_handler, log_threshold) + +Registers p4est with the SC Library and sets the logging behavior. This function is optional. This function must only be called before additional threads are created. If this function is not called or called with log\\_handler == NULL, the default SC log handler will be used. If this function is not called or called with log\\_threshold == [`SC_LP_DEFAULT`](@ref), the default SC log threshold will be used. The default SC log settings can be changed with [`sc_set_log_defaults`](@ref) (). + +### Prototype +```c +void p4est_init (sc_log_handler_t log_handler, int log_threshold); +``` +""" +function p4est_init(log_handler, log_threshold) + @ccall libp4est.p4est_init(log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid +end + +""" + p4est_is_initialized() + +Return whether p4est has been initialized or not. Keep in mind that p4est_init is an optional function but it helps with proper parallel logging. + +Currently there is no inverse to p4est_init, and no way to deinit it. This is ok since initialization generally does no harm. Just do not call libsc's finalize function while p4est is still in use. + +# Returns +True if p4est has been initialized with a call to p4est_init and false otherwise. +### Prototype +```c +int p4est_is_initialized (void); +``` +""" +function p4est_is_initialized() + @ccall libp4est.p4est_is_initialized()::Cint +end + +""" + p4est_have_zlib() + +Check for a sufficiently recent zlib installation. + +# Returns +True if zlib is detected in both sc and p4est. +### Prototype +```c +int p4est_have_zlib (void); +``` +""" +function p4est_have_zlib() + @ccall libp4est.p4est_have_zlib()::Cint +end + +""" + p4est_get_package_id() + +Query the package identity as registered in libsc. + +# Returns +This is -1 before p4est_init has been called and a proper package identifier (>= 0) afterwards. +### Prototype +```c +int p4est_get_package_id (void); +``` +""" +function p4est_get_package_id() + @ccall libp4est.p4est_get_package_id()::Cint +end + +""" + p4est_topidx_hash2(tt) + +### Prototype +```c +static inline unsigned p4est_topidx_hash2 (const p4est_topidx_t * tt); +``` +""" +function p4est_topidx_hash2(tt) + @ccall libp4est.p4est_topidx_hash2(tt::Ptr{p4est_topidx_t})::Cuint +end + +""" + p4est_topidx_hash3(tt) + +### Prototype +```c +static inline unsigned p4est_topidx_hash3 (const p4est_topidx_t * tt); +``` +""" +function p4est_topidx_hash3(tt) + @ccall libp4est.p4est_topidx_hash3(tt::Ptr{p4est_topidx_t})::Cuint +end + +""" + p4est_topidx_hash4(tt) + +### Prototype +```c +static inline unsigned p4est_topidx_hash4 (const p4est_topidx_t * tt); +``` +""" +function p4est_topidx_hash4(tt) + @ccall libp4est.p4est_topidx_hash4(tt::Ptr{p4est_topidx_t})::Cuint +end + +""" + p4est_topidx_is_sorted(t, length) + +### Prototype +```c +static inline int p4est_topidx_is_sorted (p4est_topidx_t * t, int length); +``` +""" +function p4est_topidx_is_sorted(t, length) + @ccall libp4est.p4est_topidx_is_sorted(t::Ptr{p4est_topidx_t}, length::Cint)::Cint +end + +""" + p4est_topidx_bsort(t, length) + +### Prototype +```c +static inline void p4est_topidx_bsort (p4est_topidx_t * t, int length); +``` +""" +function p4est_topidx_bsort(t, length) + @ccall libp4est.p4est_topidx_bsort(t::Ptr{p4est_topidx_t}, length::Cint)::Cvoid +end + +""" + p4est_partition_cut_uint64(global_num, p, num_procs) + +### Prototype +```c +static inline uint64_t p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs); +``` +""" +function p4est_partition_cut_uint64(global_num, p, num_procs) + @ccall libp4est.p4est_partition_cut_uint64(global_num::UInt64, p::Cint, num_procs::Cint)::UInt64 +end + +""" + p4est_partition_cut_gloidx(global_num, p, num_procs) + +### Prototype +```c +static inline p4est_gloidx_t p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs); +``` +""" +function p4est_partition_cut_gloidx(global_num, p, num_procs) + @ccall libp4est.p4est_partition_cut_gloidx(global_num::p4est_gloidx_t, p::Cint, num_procs::Cint)::p4est_gloidx_t +end + +""" + p4est_version() + +Return the full version of p4est. + +# Returns +Return the version of p4est using the format `VERSION\\_MAJOR.VERSION\\_MINOR.VERSION\\_POINT`, where `VERSION_POINT` can contain dots and characters, e.g. to indicate the additional number of commits and a git commit hash. +### Prototype +```c +const char *p4est_version (void); +``` +""" +function p4est_version() + @ccall libp4est.p4est_version()::Cstring +end + +""" + p4est_version_major() + +Return the major version of p4est. + +# Returns +Return the major version of p4est. +### Prototype +```c +int p4est_version_major (void); +``` +""" +function p4est_version_major() + @ccall libp4est.p4est_version_major()::Cint +end + +""" + p4est_version_minor() + +Return the minor version of p4est. + +# Returns +Return the minor version of p4est. +### Prototype +```c +int p4est_version_minor (void); +``` +""" +function p4est_version_minor() + @ccall libp4est.p4est_version_minor()::Cint +end + +""" + p4est_connect_type_t + +Characterize a type of adjacency. + +Several functions involve relationships between neighboring trees and/or quadrants, and their behavior depends on how one defines adjacency: 1) entities are adjacent if they share a face, or 2) entities are adjacent if they share a face or corner. [`p4est_connect_type_t`](@ref) is used to choose the desired behavior. This enum must fit into an int8\\_t. + +| Enumerator | Note | +| :----------------------- | :--------------------------------- | +| P4EST\\_CONNECT\\_SELF | No balance whatsoever. | +| P4EST\\_CONNECT\\_FACE | Balance across faces only. | +| P4EST\\_CONNECT\\_ALMOST | = CORNER - 1. | +| P4EST\\_CONNECT\\_CORNER | Balance across faces and corners. | +| P4EST\\_CONNECT\\_FULL | = CORNER. | +""" +@cenum p4est_connect_type_t::UInt32 begin + P4EST_CONNECT_SELF = 20 + P4EST_CONNECT_FACE = 21 + P4EST_CONNECT_ALMOST = 21 + P4EST_CONNECT_CORNER = 22 + P4EST_CONNECT_FULL = 22 +end + +""" + p4est_connectivity_encode_t + +Typedef for serialization method. + +| Enumerator | Note | +| :--------------------------- | :-------------------------------- | +| P4EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | +""" +@cenum p4est_connectivity_encode_t::UInt32 begin + P4EST_CONN_ENCODE_NONE = 0 + P4EST_CONN_ENCODE_LAST = 1 +end + +""" + p4est_connect_type_int(btype) + +Convert the [`p4est_connect_type_t`](@ref) into a number. + +# Arguments +* `btype`:\\[in\\] The balance type to convert. +# Returns +Returns 1 or 2. +### Prototype +```c +int p4est_connect_type_int (p4est_connect_type_t btype); +``` +""" +function p4est_connect_type_int(btype) + @ccall libp4est.p4est_connect_type_int(btype::p4est_connect_type_t)::Cint +end + +""" + p4est_connect_type_string(btype) + +Convert the [`p4est_connect_type_t`](@ref) into a const string. + +# Arguments +* `btype`:\\[in\\] The balance type to convert. +# Returns +Returns a pointer to a constant string. +### Prototype +```c +const char *p4est_connect_type_string (p4est_connect_type_t btype); +``` +""" +function p4est_connect_type_string(btype) + @ccall libp4est.p4est_connect_type_string(btype::p4est_connect_type_t)::Cstring +end + +""" + p4est_connectivity + +This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible. + +The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is given by the normal directions -x +x -y +y. Each face has a natural direction by increasing face corner number. Face connections are allocated [0][0]..[0][3]..[num\\_trees-1][0]..[num\\_trees-1][3]. If a face is on the physical boundary it must connect to itself. + +The values for tree\\_to\\_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for faces that are mutually direction-aligned and 1 for faces that are running in opposite directions. + +It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. + +The corners are stored when they connect trees that are not already face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. + +The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. + +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. We do not interpret them. + +!!! note + + If a connectivity implies natural connections between trees that are corner neighbors without being face neighbors, these corners shall be encoded explicitly in the connectivity. + +| Field | Note | +| :------------------- | :----------------------------------------------------------------------------------- | +| num\\_vertices | the number of vertices that define the *embedding* of the forest (not the topology) | +| num\\_trees | the number of trees | +| num\\_corners | the number of corners that help define topology | +| vertices | an array of size (3 * *num_vertices*) | +| tree\\_to\\_vertex | embed each tree into ```c++ R^3 ``` for e.g. visualization (see p4est\\_vtk.h) | +| tree\\_attr\\_bytes | bytes per tree in tree\\_to\\_attr | +| tree\\_to\\_attr | not touched by p4est | +| tree\\_to\\_tree | (4 * *num_trees*) neighbors across faces | +| tree\\_to\\_face | (4 * *num_trees*) face to face+orientation (see description) | +| tree\\_to\\_corner | (4 * *num_trees*) or NULL (see description) | +| ctt\\_offset | corner to offset in *corner_to_tree* and *corner_to_corner* | +| corner\\_to\\_tree | list of trees that meet at a corner | +| corner\\_to\\_corner | list of tree-corners that meet at a corner | +""" +struct p4est_connectivity + num_vertices::p4est_topidx_t + num_trees::p4est_topidx_t + num_corners::p4est_topidx_t + vertices::Ptr{Cdouble} + tree_to_vertex::Ptr{p4est_topidx_t} + tree_attr_bytes::Csize_t + tree_to_attr::Cstring + tree_to_tree::Ptr{p4est_topidx_t} + tree_to_face::Ptr{Int8} + tree_to_corner::Ptr{p4est_topidx_t} + ctt_offset::Ptr{p4est_topidx_t} + corner_to_tree::Ptr{p4est_topidx_t} + corner_to_corner::Ptr{Int8} +end + +""" +This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible. + +The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is given by the normal directions -x +x -y +y. Each face has a natural direction by increasing face corner number. Face connections are allocated [0][0]..[0][3]..[num\\_trees-1][0]..[num\\_trees-1][3]. If a face is on the physical boundary it must connect to itself. + +The values for tree\\_to\\_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for faces that are mutually direction-aligned and 1 for faces that are running in opposite directions. + +It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. + +The corners are stored when they connect trees that are not already face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. + +The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. + +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. We do not interpret them. + +!!! note + + If a connectivity implies natural connections between trees that are corner neighbors without being face neighbors, these corners shall be encoded explicitly in the connectivity. +""" +const p4est_connectivity_t = p4est_connectivity + +""" + p4est_connectivity_memory_used(conn) + +Calculate memory usage of a connectivity structure. + +# Arguments +* `conn`:\\[in\\] Connectivity structure. +# Returns +Memory used in bytes. +### Prototype +```c +size_t p4est_connectivity_memory_used (p4est_connectivity_t * conn); +``` +""" +function p4est_connectivity_memory_used(conn) + @ccall libp4est.p4est_connectivity_memory_used(conn::Ptr{p4est_connectivity_t})::Csize_t +end + +""" + p4est_corner_transform_t + +Generic interface for transformations between a tree and any of its corner + +| Field | Note | +| :------ | :------------------------ | +| ntree | The number of the tree | +| ncorner | The number of the corner | +""" +struct p4est_corner_transform_t + ntree::p4est_topidx_t + ncorner::Int8 +end + +""" + p4est_corner_info_t + +Information about the neighbors of a corner + +| Field | Note | +| :------------------ | :------------------------------------------------ | +| icorner | The number of the originating corner | +| corner\\_transforms | The array of neighbors of the originating corner | +""" +struct p4est_corner_info_t + icorner::p4est_topidx_t + corner_transforms::sc_array_t +end + +""" + p4est_neighbor_transform_t + +Generic interface for transformations between a tree and any of its neighbors + +| Field | Note | +| :---------------- | :-------------------------------------------------------------------------- | +| neighbor\\_type | type of connection to neighbor | +| neighbor | neighbor tree index | +| index\\_self | index of interface from self's perspective | +| index\\_neighbor | index of interface from neighbor's perspective | +| perm | permutation of dimensions when transforming self coords to neighbor coords | +| sign | sign changes when transforming self coords to neighbor coords | +| origin\\_self | point on the interface from self's perspective | +| origin\\_neighbor | point on the interface from neighbor's perspective | +""" +struct p4est_neighbor_transform_t + neighbor_type::p4est_connect_type_t + neighbor::p4est_topidx_t + index_self::Int8 + index_neighbor::Int8 + perm::NTuple{2, Int8} + sign::NTuple{2, Int8} + origin_self::NTuple{2, p4est_qcoord_t} + origin_neighbor::NTuple{2, p4est_qcoord_t} +end + +""" + p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + +Transform from self's coordinate system to neighbor's coordinate system. + +# Arguments +* `nt`:\\[in\\] A neighbor transform. +* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. +* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +### Prototype +```c +void p4est_neighbor_transform_coordinates (const p4est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P4EST_DIM], p4est_qcoord_t neigh_coords[P4EST_DIM]); +``` +""" +function p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + @ccall libp4est.p4est_neighbor_transform_coordinates(nt::Ptr{p4est_neighbor_transform_t}, self_coords::Ptr{p4est_qcoord_t}, neigh_coords::Ptr{p4est_qcoord_t})::Cvoid +end + +""" + p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + +Transform from neighbor's coordinate system to self's coordinate system. + +# Arguments +* `nt`:\\[in\\] A neighbor transform. +* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. +* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +### Prototype +```c +void p4est_neighbor_transform_coordinates_reverse (const p4est_neighbor_transform_t * nt, const p4est_qcoord_t neigh_coords[P4EST_DIM], p4est_qcoord_t self_coords[P4EST_DIM]); +``` +""" +function p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + @ccall libp4est.p4est_neighbor_transform_coordinates_reverse(nt::Ptr{p4est_neighbor_transform_t}, neigh_coords::Ptr{p4est_qcoord_t}, self_coords::Ptr{p4est_qcoord_t})::Cvoid +end + +""" + p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + +Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects + +# Arguments +* `conn`:\\[in\\] Connectivity structure. +* `tree_id`:\\[in\\] The number of the tree. +* `boundary_type`:\\[in\\] The type of the boundary connection (self, face, corner). +* `boundary_index`:\\[in\\] The index of the boundary. +* `neighbor_transform_array`:\\[in,out\\] Array of the neighbor transforms. +### Prototype +```c +void p4est_connectivity_get_neighbor_transforms (p4est_connectivity_t *conn, p4est_topidx_t tree_id, p4est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array); +``` +""" +function p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + @ccall libp4est.p4est_connectivity_get_neighbor_transforms(conn::Ptr{p4est_connectivity_t}, tree_id::p4est_topidx_t, boundary_type::p4est_connect_type_t, boundary_index::Cint, neighbor_transform_array::Ptr{sc_array_t})::Cvoid +end + +""" + p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + +Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. + +# Arguments +* `fc`:\\[in\\] A face corner number in 0..1. +* `f`:\\[in\\] A face that the face corner number *fc* is relative to. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +# Returns +The face corner number relative to the neighbor's face. +### Prototype +```c +int p4est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); ``` +""" +function p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + @ccall libp4est.p4est_connectivity_face_neighbor_face_corner(fc::Cint, f::Cint, nf::Cint, o::Cint)::Cint +end -This code can be called two ways. The first, when `vertex`==NULL and `tree_to_vertex`==NULL, is used to count the number of trees and vertices in the connectivity to be generated by the `.inp` mesh in the *stream*. The second, when `vertices`!=NULL and `tree_to_vertex`!=NULL, fill `vertices` and `tree_to_vertex`. In this case `num_vertices` and `num_trees` need to be set to the maximum number of entries allocated in `vertices` and `tree_to_vertex`. +""" + p4est_connectivity_face_neighbor_corner(c, f, nf, o) + +Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. # Arguments -* `stream`:\\[in,out\\] file stream to read the connectivity from -* `num_vertices`:\\[in,out\\] the number of vertices in the connectivity -* `num_trees`:\\[in,out\\] the number of trees in the connectivity -* `vertices`:\\[out\\] the list of `vertices` of the connectivity -* `tree_to_vertex`:\\[out\\] the `tree_to_vertex` map of the connectivity +* `c`:\\[in\\] A corner number in 0..3. +* `f`:\\[in\\] A face number that touches the corner *c*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. # Returns -0 if successful and nonzero if not +The number of the corner seen from the neighbor tree. ### Prototype ```c -int p8est_connectivity_read_inp_stream (FILE * stream, p4est_topidx_t * num_vertices, p4est_topidx_t * num_trees, double *vertices, p4est_topidx_t * tree_to_vertex); +int p4est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); ``` """ -function p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) - @ccall libp4est.p8est_connectivity_read_inp_stream(stream::Ptr{Libc.FILE}, num_vertices::Ptr{p4est_topidx_t}, num_trees::Ptr{p4est_topidx_t}, vertices::Ptr{Cdouble}, tree_to_vertex::Ptr{p4est_topidx_t})::Cint +function p4est_connectivity_face_neighbor_corner(c, f, nf, o) + @ccall libp4est.p4est_connectivity_face_neighbor_corner(c::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - p8est_connectivity_read_inp(filename) + p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) -Create a p4est connectivity from an ABAQUS input file. +Allocate a connectivity structure. The attribute fields are initialized to NULL. -This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. +# Arguments +* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). +* `num_trees`:\\[in\\] Number of trees in the forest. +* `num_corners`:\\[in\\] Number of tree-connecting corners. +* `num_ctt`:\\[in\\] Number of total trees in corner\\_to\\_tree array. +# Returns +A connectivity structure with allocated arrays. +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, p4est_topidx_t num_ctt); +``` +""" +function p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) + @ccall libp4est.p4est_connectivity_new(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_corners::p4est_topidx_t, num_ctt::p4est_topidx_t)::Ptr{p4est_connectivity_t} +end -A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: +""" + p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) -4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 +Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. -and in 3D they are given as: +# Arguments +* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). +* `num_trees`:\\[in\\] Number of trees in the forest. +* `num_corners`:\\[in\\] Number of tree-connecting corners. +* `vertices`:\\[in\\] Coordinates of the vertices of the trees. +* `ttv`:\\[in\\] The tree-to-vertex array. +* `ttt`:\\[in\\] The tree-to-tree array. +* `ttf`:\\[in\\] The tree-to-face array (int8\\_t). +* `ttc`:\\[in\\] The tree-to-corner array. +* `coff`:\\[in\\] Corner-to-tree offsets (num\\_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. +* `ctt`:\\[in\\] The corner-to-tree array. +* `ctc`:\\[in\\] The corner-to-corner array. +# Returns +The connectivity is checked for validity. +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc); +``` +""" +function p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) + @ccall libp4est.p4est_connectivity_new_copy(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_corners::p4est_topidx_t, vertices::Ptr{Cdouble}, ttv::Ptr{p4est_topidx_t}, ttt::Ptr{p4est_topidx_t}, ttf::Ptr{Int8}, ttc::Ptr{p4est_topidx_t}, coff::Ptr{p4est_topidx_t}, ctt::Ptr{p4est_topidx_t}, ctc::Ptr{Int8})::Ptr{p4est_connectivity_t} +end -8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 +""" + p4est_connectivity_bcast(conn_in, root, comm) -```c++ - *Heading - box.inp - *Node - 1, 5, -5, 5 - 2, 5, 5, 5 - 3, 5, 0, 5 - 4, -5, 5, 5 - 5, 0, 5, 5 - 6, -5, -5, 5 - 7, -5, 0, 5 - 8, 0, -5, 5 - 9, 0, 0, 5 - 10, 5, 5, -5 - 11, 5, -5, -5 - 12, 5, 0, -5 - 13, -5, -5, -5 - 14, 0, -5, -5 - 15, -5, 5, -5 - 16, -5, 0, -5 - 17, 0, 5, -5 - 18, 0, 0, -5 - 19, -5, -5, 0 - 20, 5, -5, 0 - 21, 0, -5, 0 - 22, -5, 5, 0 - 23, -5, 0, 0 - 24, 5, 5, 0 - 25, 0, 5, 0 - 26, 5, 0, 0 - 27, 0, 0, 0 - *Element, type=C3D8, ELSET=EB1 - 1, 6, 19, 23, 7, 8, 21, 27, 9 - 2, 19, 13, 16, 23, 21, 14, 18, 27 - 3, 7, 23, 22, 4, 9, 27, 25, 5 - 4, 23, 16, 15, 22, 27, 18, 17, 25 - 5, 8, 21, 27, 9, 1, 20, 26, 3 - 6, 21, 14, 18, 27, 20, 11, 12, 26 - 7, 9, 27, 25, 5, 3, 26, 24, 2 - 8, 27, 18, 17, 25, 26, 12, 10, 24 +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_bcast (p4est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); ``` +""" +function p4est_connectivity_bcast(conn_in, root, comm) + @ccall libp4est.p4est_connectivity_bcast(conn_in::Ptr{p4est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p4est_connectivity_t} +end -This function reads a mesh from *filename* and returns an associated p4est connectivity. +""" + p4est_connectivity_destroy(connectivity) + +Destroy a connectivity structure. Also destroy all attributes. -# Arguments -* `filename`:\\[in\\] file to read the connectivity from -# Returns -an allocated connectivity associated with the mesh in *filename* ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename); +void p4est_connectivity_destroy (p4est_connectivity_t * connectivity); ``` """ -function p8est_connectivity_read_inp(filename) - @ccall libp4est.p8est_connectivity_read_inp(filename::Cstring)::Ptr{p8est_connectivity_t} +function p4est_connectivity_destroy(connectivity) + @ccall libp4est.p4est_connectivity_destroy(connectivity::Ptr{p4est_connectivity_t})::Cvoid end """ - t8_cmesh_new_from_p4est(conn, comm, do_partition) + p4est_connectivity_set_attr(conn, bytes_per_tree) + +Allocate or free the attribute fields in a connectivity. +# Arguments +* `conn`:\\[in,out\\] The conn->*\\_to\\_attr fields must either be NULL or previously be allocated by this function. +* `bytes_per_tree`:\\[in\\] If 0, tree\\_to\\_attr is freed (being NULL is ok). If positive, requested space is allocated. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); +void p4est_connectivity_set_attr (p4est_connectivity_t * conn, size_t bytes_per_tree); ``` """ -function t8_cmesh_new_from_p4est(conn, comm, do_partition) - @ccall libt8.t8_cmesh_new_from_p4est(conn::Ptr{p4est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t +function p4est_connectivity_set_attr(conn, bytes_per_tree) + @ccall libp4est.p4est_connectivity_set_attr(conn::Ptr{p4est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid end """ - t8_cmesh_new_from_p8est(conn, comm, do_partition) + p4est_connectivity_is_valid(connectivity) +Examine a connectivity structure. + +# Returns +Returns true if structure is valid, false otherwise. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); +int p4est_connectivity_is_valid (p4est_connectivity_t * connectivity); ``` """ -function t8_cmesh_new_from_p8est(conn, comm, do_partition) - @ccall libt8.t8_cmesh_new_from_p8est(conn::Ptr{p8est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t +function p4est_connectivity_is_valid(connectivity) + @ccall libp4est.p4est_connectivity_is_valid(connectivity::Ptr{p4est_connectivity_t})::Cint end """ - t8_cmesh_new_empty(comm, do_partition, dimension) + p4est_connectivity_is_equal(conn1, conn2) +Check two connectivity structures for equality. + +# Returns +Returns true if structures are equal, false otherwise. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_empty (sc_MPI_Comm comm, const int do_partition, const int dimension); +int p4est_connectivity_is_equal (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); ``` """ -function t8_cmesh_new_empty(comm, do_partition, dimension) - @ccall libt8.t8_cmesh_new_empty(comm::MPI_Comm, do_partition::Cint, dimension::Cint)::t8_cmesh_t +function p4est_connectivity_is_equal(conn1, conn2) + @ccall libp4est.p4est_connectivity_is_equal(conn1::Ptr{p4est_connectivity_t}, conn2::Ptr{p4est_connectivity_t})::Cint end """ - t8_cmesh_new_from_class(eclass, comm) + p4est_connectivity_sink(conn, sink) +Write connectivity to a sink object. + +# Arguments +* `conn`:\\[in\\] The connectivity to be written. +* `sink`:\\[in,out\\] The connectivity is written into this sink. +# Returns +0 on success, nonzero on error. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_class (t8_eclass_t eclass, sc_MPI_Comm comm); +int p4est_connectivity_sink (p4est_connectivity_t * conn, sc_io_sink_t * sink); ``` """ -function t8_cmesh_new_from_class(eclass, comm) - @ccall libt8.t8_cmesh_new_from_class(eclass::t8_eclass_t, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_sink(conn, sink) + @ccall libp4est.p4est_connectivity_sink(conn::Ptr{p4est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint end """ - t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) + p4est_connectivity_deflate(conn, code) + +Allocate memory and store the connectivity information there. +# Arguments +* `conn`:\\[in\\] The connectivity structure to be exported to memory. +* `code`:\\[in\\] Encoding and compression method for serialization. +# Returns +Newly created array that contains the information. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int do_partition, int periodic); +sc_array_t *p4est_connectivity_deflate (p4est_connectivity_t * conn, p4est_connectivity_encode_t code); ``` """ -function t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) - @ccall libt8.t8_cmesh_new_hypercube(eclass::t8_eclass_t, comm::MPI_Comm, do_bcast::Cint, do_partition::Cint, periodic::Cint)::t8_cmesh_t +function p4est_connectivity_deflate(conn, code) + @ccall libp4est.p4est_connectivity_deflate(conn::Ptr{p4est_connectivity_t}, code::p4est_connectivity_encode_t)::Ptr{sc_array_t} end """ - t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) + p4est_connectivity_save(filename, connectivity) + +Save a connectivity structure to disk. +# Arguments +* `filename`:\\[in\\] Name of the file to write. +* `connectivity`:\\[in\\] Valid connectivity structure. +# Returns +Returns 0 on success, nonzero on file error. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned); +int p4est_connectivity_save (const char *filename, p4est_connectivity_t * connectivity); ``` """ -function t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) - @ccall libt8.t8_cmesh_new_hypercube_pad(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, use_axis_aligned::Cint)::t8_cmesh_t +function p4est_connectivity_save(filename, connectivity) + @ccall libp4est.p4est_connectivity_save(filename::Cstring, connectivity::Ptr{p4est_connectivity_t})::Cint end """ - t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) + p4est_connectivity_source(source) + +Read connectivity from a source object. +# Arguments +* `source`:\\[in,out\\] The connectivity is read from this source. +# Returns +The newly created connectivity, or NULL on error. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube_pad_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int periodic_x, const int periodic_y, const int periodic_z, const int use_axis_aligned, const int set_partition, t8_gloidx_t offset); +p4est_connectivity_t *p4est_connectivity_source (sc_io_source_t * source); ``` """ -function t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) - @ccall libt8.t8_cmesh_new_hypercube_pad_ext(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, periodic_x::Cint, periodic_y::Cint, periodic_z::Cint, use_axis_aligned::Cint, set_partition::Cint, offset::t8_gloidx_t)::t8_cmesh_t +function p4est_connectivity_source(source) + @ccall libp4est.p4est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) + p4est_connectivity_inflate(buffer) + +Create new connectivity from a memory buffer. This function aborts on malloc errors. +# Arguments +* `buffer`:\\[in\\] The connectivity is created from this memory buffer. +# Returns +The newly created connectivity, or NULL on format error of the buffered connectivity data. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, int do_partition, int periodic); +p4est_connectivity_t *p4est_connectivity_inflate (sc_array_t * buffer); ``` """ -function t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) - @ccall libt8.t8_cmesh_new_hypercube_hybrid(comm::MPI_Comm, do_partition::Cint, periodic::Cint)::t8_cmesh_t +function p4est_connectivity_inflate(buffer) + @ccall libp4est.p4est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_periodic(comm, dim) + p4est_connectivity_load(filename, bytes) + +Load a connectivity structure from disk. +# Arguments +* `filename`:\\[in\\] Name of the file to read. +* `bytes`:\\[in,out\\] Size in bytes of connectivity on disk or NULL. +# Returns +Returns valid connectivity, or NULL on file error. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic (sc_MPI_Comm comm, int dim); +p4est_connectivity_t *p4est_connectivity_load (const char *filename, size_t *bytes); ``` """ -function t8_cmesh_new_periodic(comm, dim) - @ccall libt8.t8_cmesh_new_periodic(comm::MPI_Comm, dim::Cint)::t8_cmesh_t +function p4est_connectivity_load(filename, bytes) + @ccall libp4est.p4est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_periodic_tri(comm) + p4est_connectivity_new_unitsquare() + +Create a connectivity structure for the unit square. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_tri (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_unitsquare (void); ``` """ -function t8_cmesh_new_periodic_tri(comm) - @ccall libt8.t8_cmesh_new_periodic_tri(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_unitsquare() + @ccall libp4est.p4est_connectivity_new_unitsquare()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_periodic_hybrid(comm) + p4est_connectivity_new_periodic() + +Create a connectivity structure for an all-periodic unit square. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_hybrid (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_periodic (void); ``` """ -function t8_cmesh_new_periodic_hybrid(comm) - @ccall libt8.t8_cmesh_new_periodic_hybrid(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_periodic() + @ccall libp4est.p4est_connectivity_new_periodic()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_periodic_line_more_trees(comm) + p4est_connectivity_new_rotwrap() + +Create a connectivity structure for a periodic unit square. The left and right faces are identified, and bottom and top opposite. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_rotwrap (void); ``` """ -function t8_cmesh_new_periodic_line_more_trees(comm) - @ccall libt8.t8_cmesh_new_periodic_line_more_trees(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_rotwrap() + @ccall libp4est.p4est_connectivity_new_rotwrap()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_bigmesh(eclass, num_trees, comm) + p4est_connectivity_new_circle() + +Create a connectivity structure for an donut-like circle. The circle consists of 6 trees connecting each other by their faces. The trees are laid out as a hexagon between [-2, 2] in the y direction and [-sqrt(3), sqrt(3)] in the x direction. The hexagon has flat sides along the y direction and pointy ends in x. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_bigmesh (t8_eclass_t eclass, int num_trees, sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_circle (void); ``` """ -function t8_cmesh_new_bigmesh(eclass, num_trees, comm) - @ccall libt8.t8_cmesh_new_bigmesh(eclass::t8_eclass_t, num_trees::Cint, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_circle() + @ccall libp4est.p4est_connectivity_new_circle()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_line_zigzag(comm) + p4est_connectivity_new_drop() + +Create a connectivity structure for a five-trees geometry with a hole. The geometry covers the square [0, 3]**2, where the hole is [1, 2]**2. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_line_zigzag (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_drop (void); ``` """ -function t8_cmesh_new_line_zigzag(comm) - @ccall libt8.t8_cmesh_new_line_zigzag(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_drop() + @ccall libp4est.p4est_connectivity_new_drop()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_prism_cake(comm, num_of_prisms) + p4est_connectivity_new_twotrees(l_face, r_face, orientation) + +Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way +# Arguments +* `l_face`:\\[in\\] index of left face +* `r_face`:\\[in\\] index of right face +* `orientation`:\\[in\\] orientation of trees w.r.t. each other ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_cake (sc_MPI_Comm comm, int num_of_prisms); +p4est_connectivity_t *p4est_connectivity_new_twotrees (int l_face, int r_face, int orientation); ``` """ -function t8_cmesh_new_prism_cake(comm, num_of_prisms) - @ccall libt8.t8_cmesh_new_prism_cake(comm::MPI_Comm, num_of_prisms::Cint)::t8_cmesh_t +function p4est_connectivity_new_twotrees(l_face, r_face, orientation) + @ccall libp4est.p4est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_prism_deformed(comm) + p4est_connectivity_new_corner() + +Create a connectivity structure for a three-tree mesh around a corner. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_deformed (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_corner (void); ``` """ -function t8_cmesh_new_prism_deformed(comm) - @ccall libt8.t8_cmesh_new_prism_deformed(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_corner() + @ccall libp4est.p4est_connectivity_new_corner()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_pyramid_deformed(comm) + p4est_connectivity_new_pillow() + +Create a connectivity structure for two trees on top of each other. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_pyramid_deformed (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_pillow (void); ``` """ -function t8_cmesh_new_pyramid_deformed(comm) - @ccall libt8.t8_cmesh_new_pyramid_deformed(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_pillow() + @ccall libp4est.p4est_connectivity_new_pillow()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_prism_cake_funny_oriented(comm) + p4est_connectivity_new_moebius() + +Create a connectivity structure for a five-tree moebius band. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_cake_funny_oriented (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_moebius (void); ``` """ -function t8_cmesh_new_prism_cake_funny_oriented(comm) - @ccall libt8.t8_cmesh_new_prism_cake_funny_oriented(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_moebius() + @ccall libp4est.p4est_connectivity_new_moebius()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_prism_geometry(comm) + p4est_connectivity_new_star() + +Create a connectivity structure for a six-tree star. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_geometry (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_star (void); ``` """ -function t8_cmesh_new_prism_geometry(comm) - @ccall libt8.t8_cmesh_new_prism_geometry(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_star() + @ccall libp4est.p4est_connectivity_new_star()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) + p4est_connectivity_new_cubed() + +Create a connectivity structure for the six sides of a unit cube. The ordering of the trees is as follows: + +0 1 2 3 <-- 3: axis-aligned top side 4 5 + +This choice has been made for maximum symmetry (see tree\\_to\\_* in .c file). ### Prototype ```c -t8_cmesh_t t8_cmesh_new_brick_2d (t8_gloidx_t num_x, t8_gloidx_t num_y, int x_periodic, int y_periodic, sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_cubed (void); ``` """ -function t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) - @ccall libt8.t8_cmesh_new_brick_2d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_cubed() + @ccall libp4est.p4est_connectivity_new_cubed()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + p4est_connectivity_new_disk_nonperiodic() + +Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2. +# Returns +Initialized and usable connectivity. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_brick_3d (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_disk_nonperiodic (void); ``` """ -function t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) - @ccall libt8.t8_cmesh_new_brick_3d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_disk_nonperiodic() + @ccall libp4est.p4est_connectivity_new_disk_nonperiodic()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + p4est_connectivity_new_disk(periodic_a, periodic_b) + +Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2. +!!! note + + The API of this function has changed to accept two arguments. You can query the P4EST_CONN_DISK_PERIODIC to check whether the new version with the argument is in effect. + +The ordering of the trees is as follows: + +4 1 2 3 0 + +The outside x faces may be identified topologically. The outside y faces may be identified topologically. Both identifications may be specified simultaneously. The general shape and periodicity are the same as those obtained with p4est_connectivity_new_brick (1, 1, periodic\\_a, periodic\\_b). + +When setting *periodic_a* and *periodic_b* to false, the result is the same as that of p4est_connectivity_new_disk_nonperiodic. + +# Arguments +* `periodic_a`:\\[in\\] Bool to make disk periodic in x direction. +* `periodic_b`:\\[in\\] Bool to make disk periodic in y direction. +# Returns +Initialized and usable connectivity. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_disjoint_bricks (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_disk (int periodic_a, int periodic_b); ``` """ -function t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) - @ccall libt8.t8_cmesh_new_disjoint_bricks(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_disk(periodic_a, periodic_b) + @ccall libp4est.p4est_connectivity_new_disk(periodic_a::Cint, periodic_b::Cint)::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_tet_orientation_test(comm) + p4est_connectivity_new_icosahedron() + +Create a connectivity for mapping the sphere using an icosahedron. + +The regular icosadron is a polyhedron with 20 faces, each of which is an equilateral triangle. To build the p4est connectivity, we group faces 2 by 2 to from 10 quadrangles, and thus 10 trees. + +This connectivity is meant to be used together with p4est_geometry_new_icosahedron to map the sphere. + +The flat connectivity looks like that. Vextex numbering: + +A00 A01 A02 A03 A04 / \\ / \\ / \\ / \\ / \\ A05---A06---A07---A08---A09---A10 \\ / \\ / \\ / \\ / \\ / \\ A11---A12---A13---A14---A15---A16 \\ / \\ / \\ / \\ / \\ / A17 A18 A19 A20 A21 + +Origin in A05. + +Tree numbering: + +0 2 4 6 8 1 3 5 7 9 ### Prototype ```c -t8_cmesh_t t8_cmesh_new_tet_orientation_test (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_icosahedron (void); ``` """ -function t8_cmesh_new_tet_orientation_test(comm) - @ccall libt8.t8_cmesh_new_tet_orientation_test(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_icosahedron() + @ccall libp4est.p4est_connectivity_new_icosahedron()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_hybrid_gate(comm) + p4est_connectivity_new_shell2d() + +Create a connectivity structure that builds a 2d spherical shell. p8est_connectivity_new_shell ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hybrid_gate (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_shell2d (void); ``` """ -function t8_cmesh_new_hybrid_gate(comm) - @ccall libt8.t8_cmesh_new_hybrid_gate(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_shell2d() + @ccall libp4est.p4est_connectivity_new_shell2d()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_hybrid_gate_deformed(comm) + p4est_connectivity_new_disk2d() + +Create a connectivity structure that maps a 2d disk. + +This is a 5 trees connectivity meant to be used together with p4est_geometry_new_disk2d to map the disk. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hybrid_gate_deformed (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_disk2d (void); ``` """ -function t8_cmesh_new_hybrid_gate_deformed(comm) - @ccall libt8.t8_cmesh_new_hybrid_gate_deformed(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_disk2d() + @ccall libp4est.p4est_connectivity_new_disk2d()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_full_hybrid(comm) + p4est_connectivity_new_bowtie() + +Create a connectivity structure that maps a 2d bowtie structure. + +The 2 trees are connected by a corner connection at node A3 (0, 0). the nodes are given as: + +A00 A01 / \\ / \\ A02 A03 A04 \\ / \\ / A05 A06 ### Prototype ```c -t8_cmesh_t t8_cmesh_new_full_hybrid (sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_new_bowtie (void); ``` """ -function t8_cmesh_new_full_hybrid(comm) - @ccall libt8.t8_cmesh_new_full_hybrid(comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_new_bowtie() + @ccall libp4est.p4est_connectivity_new_bowtie()::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_pyramid_cake(comm, num_of_pyra) + p4est_connectivity_new_brick(mi, ni, periodic_a, periodic_b) + +A rectangular m by n array of trees with configurable periodicity. The brick is periodic in x and y if periodic\\_a and periodic\\_b are true, respectively. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_pyramid_cake (sc_MPI_Comm comm, int num_of_pyra); +p4est_connectivity_t *p4est_connectivity_new_brick (int mi, int ni, int periodic_a, int periodic_b); ``` """ -function t8_cmesh_new_pyramid_cake(comm, num_of_pyra) - @ccall libt8.t8_cmesh_new_pyramid_cake(comm::MPI_Comm, num_of_pyra::Cint)::t8_cmesh_t +function p4est_connectivity_new_brick(mi, ni, periodic_a, periodic_b) + @ccall libp4est.p4est_connectivity_new_brick(mi::Cint, ni::Cint, periodic_a::Cint, periodic_b::Cint)::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_long_brick_pyramid(comm, num_cubes) + p4est_connectivity_new_byname(name) + +Create connectivity structure from predefined catalogue. +# Arguments +* `name`:\\[in\\] Invokes connectivity\\_new\\_* function. brick23 brick (2, 3, 0, 0) corner corner cubed cubed disk disk moebius moebius periodic periodic pillow pillow rotwrap rotwrap star star unit unitsquare +# Returns +An initialized connectivity if name is defined, NULL else. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_long_brick_pyramid (sc_MPI_Comm comm, int num_cubes); +p4est_connectivity_t *p4est_connectivity_new_byname (const char *name); ``` """ -function t8_cmesh_new_long_brick_pyramid(comm, num_cubes) - @ccall libt8.t8_cmesh_new_long_brick_pyramid(comm::MPI_Comm, num_cubes::Cint)::t8_cmesh_t +function p4est_connectivity_new_byname(name) + @ccall libp4est.p4est_connectivity_new_byname(name::Cstring)::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm, package_id) + p4est_connectivity_refine(conn, num_per_dim) +Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. + +# Arguments +* `conn`:\\[in\\] A valid connectivity +* `num_per_dim`:\\[in\\] The number of new trees in each direction. Must use no more than P4EST_OLD_QMAXLEVEL bits. +# Returns +a refined connectivity. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, const int do_partition, sc_MPI_Comm comm, const int package_id); +p4est_connectivity_t *p4est_connectivity_refine (p4est_connectivity_t * conn, int num_per_dim); ``` """ -function t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm, package_id) - @ccall libt8.t8_cmesh_new_row_of_cubes(num_trees::t8_locidx_t, set_attributes::Cint, do_partition::Cint, comm::MPI_Comm, package_id::Cint)::t8_cmesh_t +function p4est_connectivity_refine(conn, num_per_dim) + @ccall libp4est.p4est_connectivity_refine(conn::Ptr{p4est_connectivity_t}, num_per_dim::Cint)::Ptr{p4est_connectivity_t} end """ - t8_cmesh_new_quadrangulated_disk(radius, comm) + p4est_expand_face_transform(iface, nface, ftransform) +Fill an array with the axis combination of a face neighbor transform. + +# Arguments +* `iface`:\\[in\\] The number of the originating face. +* `nface`:\\[in\\] Encoded as nface = r * 4 + nf, where nf = 0..3 is the neigbbor's connecting face number and r = 0..1 is the relative orientation to the neighbor's face. This encoding matches [`p4est_connectivity_t`](@ref). +* `ftransform`:\\[out\\] This array holds 9 integers. [0,2] The coordinate axis sequence of the origin face, the first referring to the tangential and the second to the normal. A permutation of (0, 1). [3,5] The coordinate axis sequence of the target face. [6,8] Face reversal flag for tangential axis (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q [1,4,7] 0 (unused for compatibility with 3D). ### Prototype ```c -t8_cmesh_t t8_cmesh_new_quadrangulated_disk (const double radius, sc_MPI_Comm comm); +void p4est_expand_face_transform (int iface, int nface, int ftransform[]); ``` """ -function t8_cmesh_new_quadrangulated_disk(radius, comm) - @ccall libt8.t8_cmesh_new_quadrangulated_disk(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function p4est_expand_face_transform(iface, nface, ftransform) + @ccall libp4est.p4est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid end """ - t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) + p4est_find_face_transform(connectivity, itree, iface, ftransform) + +Fill an array with the axis combinations of a tree neighbor transform. + +# Arguments +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `iface`:\\[in\\] The number of the originating tree's face. +* `ftransform`:\\[out\\] This array holds 9 integers. [0,2] The coordinate axis sequence of the origin face. [3,5] The coordinate axis sequence of the target face. [6,8] Face reversal flag for axis t; face code for axis n. +# Returns +The face neighbor tree if it exists, -1 otherwise. +# See also +[`p4est_expand_face_transform`](@ref). [1,4,7] 0 (unused for compatibility with 3D). ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_MPI_Comm comm); +p4est_topidx_t p4est_find_face_transform (p4est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); ``` """ -function t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) - @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_octahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function p4est_find_face_transform(connectivity, itree, iface, ftransform) + @ccall libp4est.p4est_find_face_transform(connectivity::Ptr{p4est_connectivity_t}, itree::p4est_topidx_t, iface::Cint, ftransform::Ptr{Cint})::p4est_topidx_t end """ - t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) + p4est_find_corner_transform(connectivity, itree, icorner, ci) + +Fills an array with information about corner neighbors. +# Arguments +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `icorner`:\\[in\\] The number of the originating corner. +* `ci`:\\[in,out\\] A [`p4est_corner_info_t`](@ref) structure with initialized array. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc_MPI_Comm comm); +void p4est_find_corner_transform (p4est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p4est_corner_info_t * ci); ``` """ -function t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) - @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function p4est_find_corner_transform(connectivity, itree, icorner, ci) + @ccall libp4est.p4est_find_corner_transform(connectivity::Ptr{p4est_connectivity_t}, itree::p4est_topidx_t, icorner::Cint, ci::Ptr{p4est_corner_info_t})::Cvoid end """ - t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) + p4est_connectivity_complete(conn) + +Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. +# Arguments +* `conn`:\\[in,out\\] The connectivity needs to have proper vertices and tree\\_to\\_vertex fields. The tree\\_to\\_tree and tree\\_to\\_face fields must be allocated and satisfy [`p4est_connectivity_is_valid`](@ref) (conn) but will be overwritten. The corner fields will be freed and allocated anew. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Comm comm); +void p4est_connectivity_complete (p4est_connectivity_t * conn); ``` """ -function t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) - @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_cube(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_complete(conn) + @ccall libp4est.p4est_connectivity_complete(conn::Ptr{p4est_connectivity_t})::Cvoid end """ - t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) + p4est_connectivity_reduce(conn) + +Removes corner information of a connectivity such that enough information is left to run [`p4est_connectivity_complete`](@ref) successfully. The reduced connectivity still passes [`p4est_connectivity_is_valid`](@ref). +# Arguments +* `conn`:\\[in,out\\] The connectivity to be reduced. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm); +void p4est_connectivity_reduce (p4est_connectivity_t * conn); ``` """ -function t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) - @ccall libt8.t8_cmesh_new_quadrangulated_spherical_surface(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_reduce(conn) + @ccall libp4est.p4est_connectivity_reduce(conn::Ptr{p4est_connectivity_t})::Cvoid end """ - t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + p4est_connectivity_permute(conn, perm, is_current_to_new) + +[`p4est_connectivity_permute`](@ref) Given a permutation *perm* of the trees in a connectivity *conn*, permute the trees of *conn* in place and update *conn* to match. +# Arguments +* `conn`:\\[in,out\\] The connectivity whose trees are permuted. +* `perm`:\\[in\\] A permutation array, whose elements are size\\_t's. +* `is_current_to_new`:\\[in\\] if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_octahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); +void p4est_connectivity_permute (p4est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); ``` """ -function t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) - @ccall libt8.t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_permute(conn, perm, is_current_to_new) + @ccall libp4est.p4est_connectivity_permute(conn::Ptr{p4est_connectivity_t}, perm::Ptr{sc_array_t}, is_current_to_new::Cint)::Cvoid end """ - t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + p4est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + +[`p4est_connectivity_join_faces`](@ref) This function takes an existing valid connectivity *conn* and modifies it by joining two tree faces that are currently boundary faces. +# Arguments +* `conn`:\\[in,out\\] connectivity that will be altered. +* `tree_left`:\\[in\\] tree that will be on the left side of the joined faces. +* `tree_right`:\\[in\\] tree that will be on the right side of the joined faces. +* `face_left`:\\[in\\] face of *tree_left* that will be joined. +* `face_right`:\\[in\\] face of *tree_right* that will be joined. +* `orientation`:\\[in\\] the orientation of *face_left* and *face_right* once joined (see the description of [`p4est_connectivity_t`](@ref) to understand orientation). ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_icosahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); +void p4est_connectivity_join_faces (p4est_connectivity_t * conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation); ``` """ -function t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) - @ccall libt8.t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + @ccall libp4est.p4est_connectivity_join_faces(conn::Ptr{p4est_connectivity_t}, tree_left::p4est_topidx_t, tree_right::p4est_topidx_t, face_left::Cint, face_right::Cint, orientation::Cint)::Cvoid end """ - t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) + p4est_connectivity_is_equivalent(conn1, conn2) +[`p4est_connectivity_is_equivalent`](@ref) This function compares two connectivities for equivalence: it returns *true* if they are the same connectivity, or if they have the same topology. The definition of topological sameness is strict: there is no attempt made to determine whether permutation and/or rotation of the trees makes the connectivities equivalent. + +# Arguments +* `conn1`:\\[in\\] a valid connectivity +* `conn2`:\\[out\\] a valid connectivity ### Prototype ```c -t8_cmesh_t t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_trees, const int num_layers, sc_MPI_Comm comm); +int p4est_connectivity_is_equivalent (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); ``` """ -function t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) - @ccall libt8.t8_cmesh_new_cubed_spherical_shell(inner_radius::Cdouble, shell_thickness::Cdouble, num_trees::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t +function p4est_connectivity_is_equivalent(conn1, conn2) + @ccall libp4est.p4est_connectivity_is_equivalent(conn1::Ptr{p4est_connectivity_t}, conn2::Ptr{p4est_connectivity_t})::Cint end """ - t8_cmesh_new_cubed_sphere(radius, comm) + p4est_corner_array_index(array, it) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm); +static inline p4est_corner_transform_t * p4est_corner_array_index (sc_array_t * array, size_t it); ``` """ -function t8_cmesh_new_cubed_sphere(radius, comm) - @ccall libt8.t8_cmesh_new_cubed_sphere(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function p4est_corner_array_index(array, it) + @ccall libp4est.p4est_corner_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p4est_corner_transform_t} end """ - t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) + p4est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) -Sets the face connectivity information of an un-committed cmesh based on a list of tree vertices. +Read an ABAQUS input file from a file stream. -!!! warning +This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. - This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. +A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: -!!! note +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 - This routine does not detect periodic boundaries. +and in 3D they are given as: + +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 + +```c++ + *Heading + box.inp + *Node + 1, -5, -5, 0 + 2, 5, -5, 0 + 3, 5, 5, 0 + 4, -5, 5, 0 + 5, 0, -5, 0 + 6, 5, 0, 0 + 7, 0, 5, 0 + 8, -5, 0, 0 + 9, 1, -1, 0 + 10, 0, 0, 0 + 11, -2, 1, 0 + *Element, type=CPS4, ELSET=Surface1 + 1, 1, 10, 11, 8 + 2, 3, 10, 9, 6 + 3, 9, 10, 1, 5 + 4, 7, 4, 8, 11 + 5, 11, 10, 3, 7 + 6, 2, 6, 9, 5 +``` + +This code can be called two ways. The first, when `vertex`==NULL and `tree_to_vertex`==NULL, is used to count the number of trees and vertices in the connectivity to be generated by the `.inp` mesh in the *stream*. The second, when `vertices`!=NULL and `tree_to_vertex`!=NULL, fill `vertices` and `tree_to_vertex`. In this case `num_vertices` and `num_trees` need to be set to the maximum number of entries allocated in `vertices` and `tree_to_vertex`. # Arguments -* `cmesh`:\\[in,out\\] Pointer to a t8code cmesh object. If set to NULL this argument is ignored. -* `ntrees`:\\[in\\] Number of coarse mesh elements resp. trees. -* `vertices`:\\[in\\] List of per element vertices with dimensions [ntrees,[`T8_ECLASS_MAX_CORNERS`](@ref),[`T8_ECLASS_MAX_DIM`](@ref)]. -* `eclasses`:\\[in\\] List of element classes of length [ntrees]. -* `connectivity`:\\[in,out\\] If connectivity is not NULL the variable is filled with a pointer to an allocated face connectivity array. The ownership of this array goes to the caller. This argument is mainly used for debugging and testing purposes. The dimension of *connectivity* are [ntrees,[`T8_ECLASS_MAX_FACES`](@ref),3]. For each element and each face the following is stored: neighbor\\_tree\\_id, neighbor\\_dual\\_face\\_id, orientation -* `do_both_directions`:\\[in\\] Compute the connectivity from both neighboring sides. Takes much longer to compute. +* `stream`:\\[in,out\\] file stream to read the connectivity from +* `num_vertices`:\\[in,out\\] the number of vertices in the connectivity +* `num_trees`:\\[in,out\\] the number of trees in the connectivity +* `vertices`:\\[out\\] the list of `vertices` of the connectivity +* `tree_to_vertex`:\\[out\\] the `tree_to_vertex` map of the connectivity +# Returns +0 if successful and nonzero if not ### Prototype ```c -void t8_cmesh_set_join_by_vertices (t8_cmesh_t cmesh, const t8_gloidx_t ntrees, const t8_eclass_t *eclasses, const double *vertices, int **connectivity, const int do_both_directions); +int p4est_connectivity_read_inp_stream (FILE * stream, p4est_topidx_t * num_vertices, p4est_topidx_t * num_trees, double *vertices, p4est_topidx_t * tree_to_vertex); ``` """ -function t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) - @ccall libt8.t8_cmesh_set_join_by_vertices(cmesh::t8_cmesh_t, ntrees::t8_gloidx_t, eclasses::Ptr{t8_eclass_t}, vertices::Ptr{Cdouble}, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid +function p4est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) + @ccall libp4est.p4est_connectivity_read_inp_stream(stream::Ptr{Libc.FILE}, num_vertices::Ptr{p4est_topidx_t}, num_trees::Ptr{p4est_topidx_t}, vertices::Ptr{Cdouble}, tree_to_vertex::Ptr{p4est_topidx_t})::Cint end """ - t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) + p4est_connectivity_read_inp(filename) + +Create a p4est connectivity from an ABAQUS input file. -Sets the face connectivity information of an un-committed cmesh based on the cmesh stash. +This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. -!!! warning +A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: - This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 -!!! note +and in 3D they are given as: - This routine does not detect periodic boundaries. +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 + +```c++ + *Heading + box.inp + *Node + 1, -5, -5, 0 + 2, 5, -5, 0 + 3, 5, 5, 0 + 4, -5, 5, 0 + 5, 0, -5, 0 + 6, 5, 0, 0 + 7, 0, 5, 0 + 8, -5, 0, 0 + 9, 1, -1, 0 + 10, 0, 0, 0 + 11, -2, 1, 0 + *Element, type=CPS4, ELSET=Surface1 + 1, 1, 10, 11, 8 + 2, 3, 10, 9, 6 + 3, 9, 10, 1, 5 + 4, 7, 4, 8, 11 + 5, 11, 10, 3, 7 + 6, 2, 6, 9, 5 +``` + +This function reads a mesh from *filename* and returns an associated p4est connectivity. # Arguments -* `cmesh`:\\[in,out\\] An uncommitted cmesh. The trees eclasses and vertices do need to be set. -* `connectivity`:\\[in,out\\] If connectivity is not NULL the variable is filled with a pointer to an allocated face connectivity array. The ownership of this array goes to the caller. This argument is mainly used for debugging and testing purposes. The dimension of *connectivity* are [ntrees,[`T8_ECLASS_MAX_FACES`](@ref),3]. For each element and each face the following is stored: neighbor\\_tree\\_id, neighbor\\_dual\\_face\\_id, orientation -* `do_both_directions`:\\[in\\] Compute the connectivity from both neighboring sides. Takes much longer to compute. +* `filename`:\\[in\\] file to read the connectivity from +# Returns +an allocated connectivity associated with the mesh in *filename* or NULL if an error occurred. ### Prototype ```c -void t8_cmesh_set_join_by_stash (t8_cmesh_t cmesh, int **connectivity, const int do_both_directions); +p4est_connectivity_t *p4est_connectivity_read_inp (const char *filename); ``` """ -function t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) - @ccall libt8.t8_cmesh_set_join_by_stash(cmesh::t8_cmesh_t, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid +function p4est_connectivity_read_inp(filename) + @ccall libp4est.p4est_connectivity_read_inp(filename::Cstring)::Ptr{p4est_connectivity_t} end """ - t8_element_array_t + p8est_connect_type_t + +Characterize a type of adjacency. -The [`t8_element_array_t`](@ref) is an array to store [`t8_element_t`](@ref) * of a given eclass\\_scheme implementation. It is a wrapper around [`sc_array_t`](@ref). Each time, a new element is created by the functions for t8_element_array_t, the eclass function either t8_element_new or t8_element_init is called for the element. Thus, each element in a t8_element_array_t is automatically initialized properly. +Several functions involve relationships between neighboring trees and/or quadrants, and their behavior depends on how one defines adjacency: 1) entities are adjacent if they share a face, or 2) entities are adjacent if they share a face or corner, or 3) entities are adjacent if they share a face, corner or edge. [`p8est_connect_type_t`](@ref) is used to choose the desired behavior. This enum must fit into an int8\\_t. -| Field | Note | -| :----------- | :----------------------------------------------------- | -| scheme | The scheme of which elements should be stored. | -| tree\\_class | !< A scheme of which elements should be stored | -| array | !< The tree class of the elements stored in the array | +| Enumerator | Note | +| :----------------------- | :------------------------------- | +| P8EST\\_CONNECT\\_SELF | No balance whatsoever. | +| P8EST\\_CONNECT\\_FACE | Balance across faces only. | +| P8EST\\_CONNECT\\_EDGE | Balance across faces and edges. | +| P8EST\\_CONNECT\\_ALMOST | = CORNER - 1. | +| P8EST\\_CONNECT\\_CORNER | Balance faces, edges, corners. | +| P8EST\\_CONNECT\\_FULL | = CORNER. | """ -struct t8_element_array_t - scheme::Ptr{t8_scheme_c} - tree_class::t8_eclass_t - array::sc_array_t +@cenum p8est_connect_type_t::UInt32 begin + P8EST_CONNECT_SELF = 30 + P8EST_CONNECT_FACE = 31 + P8EST_CONNECT_EDGE = 32 + P8EST_CONNECT_ALMOST = 32 + P8EST_CONNECT_CORNER = 33 + P8EST_CONNECT_FULL = 33 end """ - t8_element_array_new(scheme, tree_class) + p8est_connectivity_encode_t -Creates a new array structure with 0 elements. +Typedef for serialization method. -# Arguments -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `tree_class`:\\[in\\] The tree class of the elements stored in the array. -# Returns -Return an allocated array of zero length. -### Prototype -```c -t8_element_array_t * t8_element_array_new (const t8_scheme_c *scheme, const t8_eclass_t tree_class); -``` +| Enumerator | Note | +| :--------------------------- | :-------------------------------- | +| P8EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | """ -function t8_element_array_new(scheme, tree_class) - @ccall libt8.t8_element_array_new(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Ptr{t8_element_array_t} +@cenum p8est_connectivity_encode_t::UInt32 begin + P8EST_CONN_ENCODE_NONE = 0 + P8EST_CONN_ENCODE_LAST = 1 end """ - t8_element_array_new_count(scheme, tree_class, num_elements) + p8est_connect_type_int(btype) -Creates a new array structure with a given length (number of elements) and calls t8_element_new for those elements. +Convert the [`p8est_connect_type_t`](@ref) into a number. # Arguments -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `tree_class`:\\[in\\] The tree class of the elements stored in the array. -* `num_elements`:\\[in\\] Initial number of array elements. +* `btype`:\\[in\\] The balance type to convert. # Returns -Return an allocated array with allocated and initialized elements for which t8_element_new was called. +Returns 1, 2 or 3. ### Prototype ```c -t8_element_array_t * t8_element_array_new_count (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t num_elements); +int p8est_connect_type_int (p8est_connect_type_t btype); ``` """ -function t8_element_array_new_count(scheme, tree_class, num_elements) - @ccall libt8.t8_element_array_new_count(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, num_elements::Csize_t)::Ptr{t8_element_array_t} +function p8est_connect_type_int(btype) + @ccall libp4est.p8est_connect_type_int(btype::p8est_connect_type_t)::Cint end """ - t8_element_array_init(element_array, scheme, tree_class) + p8est_connect_type_string(btype) -Initializes an already allocated (or static) array structure. +Convert the [`p8est_connect_type_t`](@ref) into a const string. # Arguments -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `tree_class`:\\[in\\] The tree class of the elements stored in the array. +* `btype`:\\[in\\] The balance type to convert. +# Returns +Returns a pointer to a constant string. ### Prototype ```c -void t8_element_array_init (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class); +const char *p8est_connect_type_string (p8est_connect_type_t btype); ``` """ -function t8_element_array_init(element_array, scheme, tree_class) - @ccall libt8.t8_element_array_init(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cvoid +function p8est_connect_type_string(btype) + @ccall libp4est.p8est_connect_type_string(btype::p8est_connect_type_t)::Cstring end """ - t8_element_array_init_size(element_array, scheme, tree_class, num_elements) + p8est_connectivity -Initializes an already allocated (or static) array structure and allocates a given number of elements and initializes them with t8_element_init. +This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible. -# Arguments -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `tree_class`:\\[in\\] The tree class of the elements stored in the array. -* `num_elements`:\\[in\\] Number of initial array elements. -### Prototype -```c -void t8_element_array_init_size (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t num_elements); -``` +The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. zyx is 000 001 010 011 100 101 110 111. For faces the order is -x +x -y +y -z +z. They are allocated [0][0]..[0][N-1]..[num\\_trees-1][0]..[num\\_trees-1][N-1]. where N is 6 for tree and face, 8 for corner, 12 for edge. If a face is on the physical boundary it must connect to itself. + +The values for tree\\_to\\_face are in 0..23 where ttf % 6 gives the face number and ttf / 6 the face orientation code. The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees in 0..5. Then the first face corner of the lower of my\\_face and other\\_face connects to a face corner numbered 0..3 in the higher of my\\_face and other\\_face. The face orientation is defined as this number. If my\\_face == other\\_face, treating either of both faces as the lower one leads to the same result. + +It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. + +The edges are stored when they connect trees that are not already face neighbors at that specific edge. In this case tree\\_to\\_edge indexes into *ett_offset*. Otherwise the tree\\_to\\_edge entry must be -1 and this edge is ignored. If num\\_edges == 0, tree\\_to\\_edge and edge\\_to\\_* arrays are set to NULL. + +The arrays edge\\_to\\_* store a variable number of entries per edge. For edge e these are at position [ett\\_offset[e]]..[ett\\_offset[e+1]-1]. Their number for edge e is ett\\_offset[e+1] - ett\\_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge\\_to\\_* arrays is num\\_ett = ett\\_offset[num\\_edges]. The edge\\_to\\_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation. + +The corners are stored when they connect trees that are not already edge or face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. + +The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. + +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. + +!!! note + + If a connectivity implies natural connections between trees that are edge neighbors without being face neighbors, these edges shall be encoded explicitly in the connectivity. If a connectivity implies natural connections between trees that are corner neighbors without being edge or face neighbors, these corners shall be encoded explicitly in the connectivity. + +| Field | Note | +| :------------------- | :----------------------------------------------------------------------------------- | +| num\\_vertices | the number of vertices that define the *embedding* of the forest (not the topology) | +| num\\_trees | the number of trees | +| num\\_edges | the number of edges that help define the topology | +| num\\_corners | the number of corners that help define the topology | +| vertices | an array of size (3 * *num_vertices*) | +| tree\\_to\\_vertex | embed each tree into ```c++ R^3 ``` for e.g. visualization (see p8est\\_vtk.h) | +| tree\\_attr\\_bytes | bytes per tree in tree\\_to\\_attr | +| tree\\_to\\_attr | not touched by p4est | +| tree\\_to\\_tree | (6 * *num_trees*) neighbors across faces | +| tree\\_to\\_face | (6 * *num_trees*) face to face+orientation (see description) | +| tree\\_to\\_edge | (12 * *num_trees*) or NULL (see description) | +| ett\\_offset | edge to offset in *edge_to_tree* and *edge_to_edge* | +| edge\\_to\\_tree | list of trees that meet at an edge | +| edge\\_to\\_edge | list of tree-edges+orientations that meet at an edge (see description) | +| tree\\_to\\_corner | (8 * *num_trees*) or NULL (see description) | +| ctt\\_offset | corner to offset in *corner_to_tree* and *corner_to_corner* | +| corner\\_to\\_tree | list of trees that meet at a corner | +| corner\\_to\\_corner | list of tree-corners that meet at a corner | """ -function t8_element_array_init_size(element_array, scheme, tree_class, num_elements) - @ccall libt8.t8_element_array_init_size(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, num_elements::Csize_t)::Cvoid +struct p8est_connectivity + num_vertices::p4est_topidx_t + num_trees::p4est_topidx_t + num_edges::p4est_topidx_t + num_corners::p4est_topidx_t + vertices::Ptr{Cdouble} + tree_to_vertex::Ptr{p4est_topidx_t} + tree_attr_bytes::Csize_t + tree_to_attr::Cstring + tree_to_tree::Ptr{p4est_topidx_t} + tree_to_face::Ptr{Int8} + tree_to_edge::Ptr{p4est_topidx_t} + ett_offset::Ptr{p4est_topidx_t} + edge_to_tree::Ptr{p4est_topidx_t} + edge_to_edge::Ptr{Int8} + tree_to_corner::Ptr{p4est_topidx_t} + ctt_offset::Ptr{p4est_topidx_t} + corner_to_tree::Ptr{p4est_topidx_t} + corner_to_corner::Ptr{Int8} end """ - t8_element_array_init_view(view, array, offset, length) +This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible. -Initializes an already allocated (or static) view from existing t8\\_element\\_array. The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). +The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. zyx is 000 001 010 011 100 101 110 111. For faces the order is -x +x -y +y -z +z. They are allocated [0][0]..[0][N-1]..[num\\_trees-1][0]..[num\\_trees-1][N-1]. where N is 6 for tree and face, 8 for corner, 12 for edge. If a face is on the physical boundary it must connect to itself. -# Arguments -* `view`:\\[in,out\\] Array structure to be initialized. -* `array`:\\[in\\] The array must not be resized while view is alive. -* `offset`:\\[in\\] The offset of the viewed section in element units. This offset cannot be changed until the view is reset. -* `length`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`sc_array_reset`](@ref) later. -### Prototype -```c -void t8_element_array_init_view (t8_element_array_t *view, const t8_element_array_t *array, const size_t offset, const size_t length); -``` -""" -function t8_element_array_init_view(view, array, offset, length) - @ccall libt8.t8_element_array_init_view(view::Ptr{t8_element_array_t}, array::Ptr{t8_element_array_t}, offset::Csize_t, length::Csize_t)::Cvoid -end +The values for tree\\_to\\_face are in 0..23 where ttf % 6 gives the face number and ttf / 6 the face orientation code. The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees in 0..5. Then the first face corner of the lower of my\\_face and other\\_face connects to a face corner numbered 0..3 in the higher of my\\_face and other\\_face. The face orientation is defined as this number. If my\\_face == other\\_face, treating either of both faces as the lower one leads to the same result. -mutable struct t8_element end +It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. -"""Opaque structure for a generic element, only used as pointer. Implementations are free to cast it to their internal data structure.""" -const t8_element_t = t8_element +The edges are stored when they connect trees that are not already face neighbors at that specific edge. In this case tree\\_to\\_edge indexes into *ett_offset*. Otherwise the tree\\_to\\_edge entry must be -1 and this edge is ignored. If num\\_edges == 0, tree\\_to\\_edge and edge\\_to\\_* arrays are set to NULL. -""" - t8_element_array_init_data(view, base, scheme, tree_class, elem_count) +The arrays edge\\_to\\_* store a variable number of entries per edge. For edge e these are at position [ett\\_offset[e]]..[ett\\_offset[e+1]-1]. Their number for edge e is ett\\_offset[e+1] - ett\\_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge\\_to\\_* arrays is num\\_ett = ett\\_offset[num\\_edges]. The edge\\_to\\_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation. -Initializes an already allocated (or static) view from given plain C data (array of [`t8_element_t`](@ref)). The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). +The corners are stored when they connect trees that are not already edge or face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. -# Arguments -* `view`:\\[in,out\\] Array structure to be initialized. -* `base`:\\[in\\] The data must not be moved while view is alive. Must be an array of [`t8_element_t`](@ref) corresponding to *scheme*. -* `scheme`:\\[in\\] The scheme of the elements stored in *base*. -* `tree_class`:\\[in\\] The tree class of the elements stored in *base*. -* `elem_count`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`t8_element_array_reset`](@ref) later. -### Prototype -```c -void t8_element_array_init_data (t8_element_array_t *view, const t8_element_t *base, const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t elem_count); -``` +The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. + +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. + +!!! note + + If a connectivity implies natural connections between trees that are edge neighbors without being face neighbors, these edges shall be encoded explicitly in the connectivity. If a connectivity implies natural connections between trees that are corner neighbors without being edge or face neighbors, these corners shall be encoded explicitly in the connectivity. """ -function t8_element_array_init_data(view, base, scheme, tree_class, elem_count) - @ccall libt8.t8_element_array_init_data(view::Ptr{t8_element_array_t}, base::Ptr{t8_element_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem_count::Csize_t)::Cvoid -end +const p8est_connectivity_t = p8est_connectivity """ - t8_element_array_init_copy(element_array, scheme, tree_class, data, num_elements) + p8est_connectivity_memory_used(conn) -Initializes an already allocated (or static) array structure and copy an existing array of [`t8_element_t`](@ref) into it. +Calculate memory usage of a connectivity structure. # Arguments -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `tree_class`:\\[in\\] The tree class of the elements stored in the array. -* `data`:\\[in\\] An array of [`t8_element_t`](@ref) which will be copied into *element_array*. The elements in *data* must belong to *scheme* and must be properly initialized with either t8_element_new or t8_element_init. -* `num_elements`:\\[in\\] Number of elements in *data* to be copied. +* `conn`:\\[in\\] Connectivity structure. +# Returns +Memory used in bytes. ### Prototype ```c -void t8_element_array_init_copy (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *data, const size_t num_elements); +size_t p8est_connectivity_memory_used (p8est_connectivity_t * conn); ``` """ -function t8_element_array_init_copy(element_array, scheme, tree_class, data, num_elements) - @ccall libt8.t8_element_array_init_copy(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, data::Ptr{t8_element_t}, num_elements::Csize_t)::Cvoid +function p8est_connectivity_memory_used(conn) + @ccall libp4est.p8est_connectivity_memory_used(conn::Ptr{p8est_connectivity_t})::Csize_t end """ - t8_element_array_resize(element_array, new_count) + p8est_edge_transform_t -Change the number of elements stored in an element array. +Generic interface for transformations between a tree and any of its edge -!!! note +| Field | Note | +| :------ | :--------------------------------- | +| ntree | The number of the tree | +| nedge | The number of the edge | +| naxis | The 3 edge coordinate axes | +| nflip | The orientation of the edge | +| corners | The corners connected to the edge | +""" +struct p8est_edge_transform_t + ntree::p4est_topidx_t + nedge::Int8 + naxis::NTuple{3, Int8} + nflip::Int8 + corners::Int8 +end - If *new_count* is larger than the number of current elements on *element_array*, then t8_element_init is called for the new elements. +""" + p8est_edge_info_t -# Arguments -* `element_array`:\\[in,out\\] The element array to be modified. -* `new_count`:\\[in\\] The new element count of the array. If it is zero the effect equals t8_element_array_reset. -### Prototype -```c -void t8_element_array_resize (t8_element_array_t *element_array, const size_t new_count); -``` +Information about the neighbors of an edge + +| Field | Note | +| :---------------- | :---------------------------------------------- | +| iedge | The information of the edge | +| edge\\_transforms | The array of neighbors of the originating edge | """ -function t8_element_array_resize(element_array, new_count) - @ccall libt8.t8_element_array_resize(element_array::Ptr{t8_element_array_t}, new_count::Csize_t)::Cvoid +struct p8est_edge_info_t + iedge::Int8 + edge_transforms::sc_array_t end """ - t8_element_array_copy(dest, src) + p8est_corner_transform_t -Copy the contents of an array into another. Both arrays must have the same eclass\\_scheme. +Generic interface for transformations between a tree and any of its corner -# Arguments -* `dest`:\\[in\\] Array will be resized and get new data. -* `src`:\\[in\\] Array used as source of new data, will not be changed. -### Prototype -```c -void t8_element_array_copy (t8_element_array_t *dest, const t8_element_array_t *src); -``` +| Field | Note | +| :------ | :------------------------ | +| ntree | The number of the tree | +| ncorner | The number of the corner | """ -function t8_element_array_copy(dest, src) - @ccall libt8.t8_element_array_copy(dest::Ptr{t8_element_array_t}, src::Ptr{t8_element_array_t})::Cvoid +struct p8est_corner_transform_t + ntree::p4est_topidx_t + ncorner::Int8 end """ - t8_element_array_push(element_array) - -Enlarge an array by one element. + p8est_corner_info_t -# Arguments -* `element_array`:\\[in,out\\] Array structure to be modified. -# Returns -Returns a pointer to a newly added element for which t8_element_init was called. -### Prototype -```c -t8_element_t * t8_element_array_push (t8_element_array_t *element_array); -``` +Information about the neighbors of a corner + +| Field | Note | +| :------------------ | :------------------------------------------------ | +| icorner | The number of the originating corner | +| corner\\_transforms | The array of neighbors of the originating corner | """ -function t8_element_array_push(element_array) - @ccall libt8.t8_element_array_push(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} +struct p8est_corner_info_t + icorner::p4est_topidx_t + corner_transforms::sc_array_t end """ - t8_element_array_push_count(element_array, count) + p8est_neighbor_transform_t -Enlarge an array by a number of elements. +Generic interface for transformations between a tree and any of its neighbors -# Arguments -* `element_array`:\\[in,out\\] Array structure to be modified. -* `count`:\\[in\\] The number of elements to add. -# Returns -Returns a pointer to the newly added elements for which t8_element_init was called. -### Prototype -```c -t8_element_t * t8_element_array_push_count (t8_element_array_t *element_array, size_t count); -``` +| Field | Note | +| :---------------- | :-------------------------------------------------------------------------- | +| neighbor\\_type | type of connection to neighbor | +| neighbor | neighbor tree index | +| index\\_self | index of interface from self's perspective | +| index\\_neighbor | index of interface from neighbor's perspective | +| perm | permutation of dimensions when transforming self coords to neighbor coords | +| sign | sign changes when transforming self coords to neighbor coords | +| origin\\_self | point on the interface from self's perspective | +| origin\\_neighbor | point on the interface from neighbor's perspective | """ -function t8_element_array_push_count(element_array, count) - @ccall libt8.t8_element_array_push_count(element_array::Ptr{t8_element_array_t}, count::Csize_t)::Ptr{t8_element_t} +struct p8est_neighbor_transform_t + neighbor_type::p8est_connect_type_t + neighbor::p4est_topidx_t + index_self::Int8 + index_neighbor::Int8 + perm::NTuple{3, Int8} + sign::NTuple{3, Int8} + origin_self::NTuple{3, p4est_qcoord_t} + origin_neighbor::NTuple{3, p4est_qcoord_t} end """ - t8_element_array_index_locidx(element_array, index) + p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) -Return a given element in an array. Const version. +Transform from self's coordinate system to neighbor's coordinate system. # Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. -# Returns -A pointer to the element stored at position *index* in *element_array*. +* `nt`:\\[in\\] A neighbor transform. +* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. +* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. ### Prototype ```c -const t8_element_t * t8_element_array_index_locidx (const t8_element_array_t *element_array, const t8_locidx_t index); +void p8est_neighbor_transform_coordinates (const p8est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P8EST_DIM], p4est_qcoord_t neigh_coords[P8EST_DIM]); ``` """ -function t8_element_array_index_locidx(element_array, index) - @ccall libt8.t8_element_array_index_locidx(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} +function p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + @ccall libp4est.p8est_neighbor_transform_coordinates(nt::Ptr{p8est_neighbor_transform_t}, self_coords::Ptr{p4est_qcoord_t}, neigh_coords::Ptr{p4est_qcoord_t})::Cvoid end """ - t8_element_array_index_int(element_array, index) + p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) -Return a given element in an array. Const version. +Transform from neighbor's coordinate system to self's coordinate system. # Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. -# Returns -A pointer to the element stored at position *index* in *element_array*. +* `nt`:\\[in\\] A neighbor transform. +* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. +* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. ### Prototype ```c -const t8_element_t * t8_element_array_index_int (const t8_element_array_t *element_array, const int index); +void p8est_neighbor_transform_coordinates_reverse (const p8est_neighbor_transform_t * nt, const p4est_qcoord_t neigh_coords[P8EST_DIM], p4est_qcoord_t self_coords[P8EST_DIM]); ``` """ -function t8_element_array_index_int(element_array, index) - @ccall libt8.t8_element_array_index_int(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} +function p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + @ccall libp4est.p8est_neighbor_transform_coordinates_reverse(nt::Ptr{p8est_neighbor_transform_t}, neigh_coords::Ptr{p4est_qcoord_t}, self_coords::Ptr{p4est_qcoord_t})::Cvoid end """ - t8_element_array_index_locidx_mutable(element_array, index) + p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) -Return a given element in an array. Mutable version. +Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects # Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. -# Returns -A pointer to the element stored at position *index* in *element_array*. +* `conn`:\\[in\\] Connectivity structure. +* `tree_id`:\\[in\\] The number of the tree. +* `boundary_type`:\\[in\\] Type of boundary connection (self, face, edge, corner). +* `boundary_index`:\\[in\\] The index of the boundary. +* `neighbor_transform_array`:\\[in,out\\] Array of the neighbor transforms. ### Prototype ```c -t8_element_t * t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, const t8_locidx_t index); +void p8est_connectivity_get_neighbor_transforms (p8est_connectivity_t *conn, p4est_topidx_t tree_id, p8est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array); ``` """ -function t8_element_array_index_locidx_mutable(element_array, index) - @ccall libt8.t8_element_array_index_locidx_mutable(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} +function p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + @ccall libp4est.p8est_connectivity_get_neighbor_transforms(conn::Ptr{p8est_connectivity_t}, tree_id::p4est_topidx_t, boundary_type::p8est_connect_type_t, boundary_index::Cint, neighbor_transform_array::Ptr{sc_array_t})::Cvoid end """ - t8_element_array_index_int_mutable(element_array, index) + p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) -Return a given element in an array. Mutable version. +Transform a corner across one of the adjacent faces into a neighbor tree. It expects a face permutation index that has been precomputed. # Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. +* `c`:\\[in\\] A corner number in 0..7. +* `f`:\\[in\\] A face number that touches the corner *c*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `set`:\\[in\\] A value from *p8est_face_permutation_sets* that is obtained using *f*, *nf*, and a valid orientation: ref = p8est\\_face\\_permutation\\_refs[f][nf]; set = p8est\\_face\\_permutation\\_sets[ref][orientation]; # Returns -A pointer to the element stored at position *index* in *element_array*. +The corner number in 0..7 seen from the other face. ### Prototype ```c -t8_element_t * t8_element_array_index_int_mutable (t8_element_array_t *element_array, const int index); +int p8est_connectivity_face_neighbor_corner_set (int c, int f, int nf, int set); ``` """ -function t8_element_array_index_int_mutable(element_array, index) - @ccall libt8.t8_element_array_index_int_mutable(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} +function p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) + @ccall libp4est.p8est_connectivity_face_neighbor_corner_set(c::Cint, f::Cint, nf::Cint, set::Cint)::Cint end """ - t8_element_array_get_scheme(element_array) + p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) -Return the eclass scheme associated to a t8\\_element\\_array. +Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. # Arguments -* `element_array`:\\[in\\] Array of elements. +* `fc`:\\[in\\] A face corner number in 0..3. +* `f`:\\[in\\] A face that the face corner *fc* is relative to. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. # Returns -The eclass scheme stored at *element_array*. +The face corner number relative to the neighbor's face. ### Prototype ```c -const t8_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array); +int p8est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); ``` """ -function t8_element_array_get_scheme(element_array) - @ccall libt8.t8_element_array_get_scheme(element_array::Ptr{t8_element_array_t})::Ptr{t8_scheme_c} +function p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + @ccall libp4est.p8est_connectivity_face_neighbor_face_corner(fc::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_element_array_get_tree_class(element_array) + p8est_connectivity_face_neighbor_corner(c, f, nf, o) -Return the tree class of the t8\\_element\\_array . +Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. # Arguments -* `element_array`:\\[in\\] Array of elements. +* `c`:\\[in\\] A corner number in 0..7. +* `f`:\\[in\\] A face number that touches the corner *c*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. # Returns -The tree class stored at *element_array*. +The number of the corner seen from the neighbor tree. ### Prototype ```c -t8_eclass_t t8_element_array_get_tree_class (const t8_element_array_t *element_array); +int p8est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); ``` """ -function t8_element_array_get_tree_class(element_array) - @ccall libt8.t8_element_array_get_tree_class(element_array::Ptr{t8_element_array_t})::t8_eclass_t +function p8est_connectivity_face_neighbor_corner(c, f, nf, o) + @ccall libp4est.p8est_connectivity_face_neighbor_corner(c::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_element_array_get_count(element_array) + p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) -Return the number of elements stored in a [`t8_element_array_t`](@ref). +Transform a face-edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. # Arguments -* `element_array`:\\[in\\] Array structure. +* `fe`:\\[in\\] A face edge number in 0..3. +* `f`:\\[in\\] A face number that touches the edge *e*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. # Returns -The number of elements stored in *element_array*. +The face edge number seen from the neighbor tree. ### Prototype ```c -size_t t8_element_array_get_count (const t8_element_array_t *element_array); +int p8est_connectivity_face_neighbor_face_edge (int fe, int f, int nf, int o); ``` """ -function t8_element_array_get_count(element_array) - @ccall libt8.t8_element_array_get_count(element_array::Ptr{t8_element_array_t})::Csize_t +function p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) + @ccall libp4est.p8est_connectivity_face_neighbor_face_edge(fe::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_element_array_get_size(element_array) + p8est_connectivity_face_neighbor_edge(e, f, nf, o) -Return the data size of elements stored in a [`t8_element_array_t`](@ref). +Transform an edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. # Arguments -* `element_array`:\\[in\\] Array structure. +* `e`:\\[in\\] A edge number in 0..11. +* `f`:\\[in\\] A face 0..5 that touches the edge *e*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. # Returns -The size (in bytes) of a single element in *element_array*. +The edge's number seen from the neighbor. ### Prototype ```c -size_t t8_element_array_get_size (const t8_element_array_t *element_array); +int p8est_connectivity_face_neighbor_edge (int e, int f, int nf, int o); ``` """ -function t8_element_array_get_size(element_array) - @ccall libt8.t8_element_array_get_size(element_array::Ptr{t8_element_array_t})::Csize_t +function p8est_connectivity_face_neighbor_edge(e, f, nf, o) + @ccall libp4est.p8est_connectivity_face_neighbor_edge(e::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_element_array_get_data(element_array) + p8est_connectivity_edge_neighbor_edge_corner(ec, o) -Return a const pointer to the real data array stored in a t8\\_element\\_array. +Transform an edge corner across one of the adjacent edges into a neighbor tree. # Arguments -* `element_array`:\\[in\\] Array structure. +* `ec`:\\[in\\] An edge corner number in 0..1. +* `o`:\\[in\\] The orientation of a tree boundary edge connection. # Returns -A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. +The edge corner number seen from the other tree. ### Prototype ```c -const t8_element_t * t8_element_array_get_data (const t8_element_array_t *element_array); +int p8est_connectivity_edge_neighbor_edge_corner (int ec, int o); ``` """ -function t8_element_array_get_data(element_array) - @ccall libt8.t8_element_array_get_data(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} +function p8est_connectivity_edge_neighbor_edge_corner(ec, o) + @ccall libp4est.p8est_connectivity_edge_neighbor_edge_corner(ec::Cint, o::Cint)::Cint end """ - t8_element_array_get_data_mutable(element_array) + p8est_connectivity_edge_neighbor_corner(c, e, ne, o) -Return a pointer to the real data array stored in a t8\\_element\\_array. +Transform a corner across one of the adjacent edges into a neighbor tree. This version expects the neighbor edge and orientation separately. # Arguments -* `element_array`:\\[in\\] Array structure. +* `c`:\\[in\\] A corner number in 0..7. +* `e`:\\[in\\] An edge 0..11 that touches the corner *c*. +* `ne`:\\[in\\] A neighbor edge that is on the other side of *e*. +* `o`:\\[in\\] The orientation between tree boundary edges *e* and *ne*. # Returns -A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. +Corner number seen from the neighbor. ### Prototype ```c -t8_element_t * t8_element_array_get_data_mutable (t8_element_array_t *element_array); +int p8est_connectivity_edge_neighbor_corner (int c, int e, int ne, int o); ``` """ -function t8_element_array_get_data_mutable(element_array) - @ccall libt8.t8_element_array_get_data_mutable(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} +function p8est_connectivity_edge_neighbor_corner(c, e, ne, o) + @ccall libp4est.p8est_connectivity_edge_neighbor_corner(c::Cint, e::Cint, ne::Cint, o::Cint)::Cint end """ - t8_element_array_get_array(element_array) - -Return a const pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. - -!!! note + p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) - The data cannot be modified. +Allocate a connectivity structure. The attribute fields are initialized to NULL. # Arguments -* `element_array`:\\[in\\] Array structure. +* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). +* `num_trees`:\\[in\\] Number of trees in the forest. +* `num_edges`:\\[in\\] Number of tree-connecting edges. +* `num_ett`:\\[in\\] Number of total trees in edge\\_to\\_tree array. +* `num_corners`:\\[in\\] Number of tree-connecting corners. +* `num_ctt`:\\[in\\] Number of total trees in corner\\_to\\_tree array. # Returns -A const pointer to the [`sc_array`](@ref) storing the data. +A connectivity structure with allocated arrays. ### Prototype ```c -const sc_array_t * t8_element_array_get_array (const t8_element_array_t *element_array); +p8est_connectivity_t *p8est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_ett, p4est_topidx_t num_corners, p4est_topidx_t num_ctt); ``` """ -function t8_element_array_get_array(element_array) - @ccall libt8.t8_element_array_get_array(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} +function p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) + @ccall libp4est.p8est_connectivity_new(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_ett::p4est_topidx_t, num_corners::p4est_topidx_t, num_ctt::p4est_topidx_t)::Ptr{p8est_connectivity_t} end """ - t8_element_array_get_array_mutable(element_array) - -Return a mutable pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. - -!!! note + p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) - The data can be modified. +Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. # Arguments -* `element_array`:\\[in\\] Array structure. +* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). +* `num_trees`:\\[in\\] Number of trees in the forest. +* `num_edges`:\\[in\\] Number of tree-connecting edges. +* `num_corners`:\\[in\\] Number of tree-connecting corners. +* `vertices`:\\[in\\] Coordinates of the vertices of the trees. +* `ttv`:\\[in\\] The tree-to-vertex array. +* `ttt`:\\[in\\] The tree-to-tree array. +* `ttf`:\\[in\\] The tree-to-face array (int8\\_t). +* `tte`:\\[in\\] The tree-to-edge array. +* `eoff`:\\[in\\] Edge-to-tree offsets (num\\_edges + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. +* `ett`:\\[in\\] The edge-to-tree array. +* `ete`:\\[in\\] The edge-to-edge array. +* `ttc`:\\[in\\] The tree-to-corner array. +* `coff`:\\[in\\] Corner-to-tree offsets (num\\_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. +* `ctt`:\\[in\\] The corner-to-tree array. +* `ctc`:\\[in\\] The corner-to-corner array. # Returns -A pointer to the [`sc_array`](@ref) storing the data. +The connectivity is checked for validity. ### Prototype ```c -sc_array_t * t8_element_array_get_array_mutable (t8_element_array_t *element_array); +p8est_connectivity_t *p8est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * tte, const p4est_topidx_t * eoff, const p4est_topidx_t * ett, const int8_t * ete, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc); ``` """ -function t8_element_array_get_array_mutable(element_array) - @ccall libt8.t8_element_array_get_array_mutable(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} +function p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) + @ccall libp4est.p8est_connectivity_new_copy(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_corners::p4est_topidx_t, vertices::Ptr{Cdouble}, ttv::Ptr{p4est_topidx_t}, ttt::Ptr{p4est_topidx_t}, ttf::Ptr{Int8}, tte::Ptr{p4est_topidx_t}, eoff::Ptr{p4est_topidx_t}, ett::Ptr{p4est_topidx_t}, ete::Ptr{Int8}, ttc::Ptr{p4est_topidx_t}, coff::Ptr{p4est_topidx_t}, ctt::Ptr{p4est_topidx_t}, ctc::Ptr{Int8})::Ptr{p8est_connectivity_t} end """ - t8_element_array_find(element_array, element) - -Search for an element in an array. + p8est_connectivity_bcast(conn_in, root, comm) -# Arguments -* `element_array`:\\[in\\] Array structure. -* `element`:\\[in\\] Element to be found in *element_array*. The element must have been created with the scheme used in *element_array*. -# Returns -If *element* was found in *element_array* then the position in the array is returned. If the element is not found, -1 is returned. ### Prototype ```c -t8_locidx_t t8_element_array_find (const t8_element_array_t *element_array, const t8_element_t *element); +p8est_connectivity_t *p8est_connectivity_bcast (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); ``` """ -function t8_element_array_find(element_array, element) - @ccall libt8.t8_element_array_find(element_array::Ptr{t8_element_array_t}, element::Ptr{t8_element_t})::t8_locidx_t +function p8est_connectivity_bcast(conn_in, root, comm) + @ccall libp4est.p8est_connectivity_bcast(conn_in::Ptr{p8est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p8est_connectivity_t} end """ - t8_element_array_reset(element_array) - -Sets the array count to zero and frees all elements. - -!!! note + p8est_connectivity_destroy(connectivity) - Calling [`t8_element_array_init`](@ref), then any array operations, then [`t8_element_array_reset`](@ref) is memory neutral. +Destroy a connectivity structure. Also destroy all attributes. -# Arguments -* `element_array`:\\[in,out\\] Array structure to be reset. ### Prototype ```c -void t8_element_array_reset (t8_element_array_t *element_array); +void p8est_connectivity_destroy (p8est_connectivity_t * connectivity); ``` """ -function t8_element_array_reset(element_array) - @ccall libt8.t8_element_array_reset(element_array::Ptr{t8_element_array_t})::Cvoid +function p8est_connectivity_destroy(connectivity) + @ccall libp4est.p8est_connectivity_destroy(connectivity::Ptr{p8est_connectivity_t})::Cvoid end """ - t8_element_array_truncate(element_array) - -Sets the array count to zero, but does not free elements. - -!!! note + p8est_connectivity_set_attr(conn, bytes_per_tree) - This is intended to allow an t8\\_element\\_array to be used as a reusable buffer, where the "high water mark" of the buffer is preserved, so that O(log (max n)) reallocs occur over the life of the buffer. +Allocate or free the attribute fields in a connectivity. # Arguments -* `element_array`:\\[in,out\\] Element array structure to be truncated. +* `conn`:\\[in,out\\] The conn->*\\_to\\_attr fields must either be NULL or previously be allocated by this function. +* `bytes_per_tree`:\\[in\\] If 0, tree\\_to\\_attr is freed (being NULL is ok). If positive, requested space is allocated. ### Prototype ```c -void t8_element_array_truncate (t8_element_array_t *element_array); +void p8est_connectivity_set_attr (p8est_connectivity_t * conn, size_t bytes_per_tree); ``` """ -function t8_element_array_truncate(element_array) - @ccall libt8.t8_element_array_truncate(element_array::Ptr{t8_element_array_t})::Cvoid +function p8est_connectivity_set_attr(conn, bytes_per_tree) + @ccall libp4est.p8est_connectivity_set_attr(conn::Ptr{p8est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid end """ - t8_shmem_init(comm) + p8est_connectivity_is_valid(connectivity) + +Examine a connectivity structure. +# Returns +Returns true if structure is valid, false otherwise. ### Prototype ```c -int t8_shmem_init (sc_MPI_Comm comm); +int p8est_connectivity_is_valid (p8est_connectivity_t * connectivity); ``` """ -function t8_shmem_init(comm) - @ccall libt8.t8_shmem_init(comm::MPI_Comm)::Cint +function p8est_connectivity_is_valid(connectivity) + @ccall libp4est.p8est_connectivity_is_valid(connectivity::Ptr{p8est_connectivity_t})::Cint end """ - t8_shmem_finalize(comm) + p8est_connectivity_is_equal(conn1, conn2) + +Check two connectivity structures for equality. +# Returns +Returns true if structures are equal, false otherwise. ### Prototype ```c -void t8_shmem_finalize (sc_MPI_Comm comm); +int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); ``` """ -function t8_shmem_finalize(comm) - @ccall libt8.t8_shmem_finalize(comm::MPI_Comm)::Cvoid +function p8est_connectivity_is_equal(conn1, conn2) + @ccall libp4est.p8est_connectivity_is_equal(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint end """ - t8_shmem_set_type(comm, type) + p8est_connectivity_sink(conn, sink) + +Write connectivity to a sink object. +# Arguments +* `conn`:\\[in\\] The connectivity to be written. +* `sink`:\\[in,out\\] The connectivity is written into this sink. +# Returns +0 on success, nonzero on error. ### Prototype ```c -void t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); +int p8est_connectivity_sink (p8est_connectivity_t * conn, sc_io_sink_t * sink); ``` """ -function t8_shmem_set_type(comm, type) - @ccall libt8.t8_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid +function p8est_connectivity_sink(conn, sink) + @ccall libp4est.p8est_connectivity_sink(conn::Ptr{p8est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint end """ - t8_shmem_array_init(parray, elem_size, elem_count, comm) + p8est_connectivity_deflate(conn, code) + +Allocate memory and store the connectivity information there. +# Arguments +* `conn`:\\[in\\] The connectivity structure to be exported to memory. +* `code`:\\[in\\] Encoding and compression method for serialization. +# Returns +Newly created array that contains the information. ### Prototype ```c -void t8_shmem_array_init (t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm); +sc_array_t *p8est_connectivity_deflate (p8est_connectivity_t * conn, p8est_connectivity_encode_t code); ``` """ -function t8_shmem_array_init(parray, elem_size, elem_count, comm) - @ccall libt8.t8_shmem_array_init(parray::Ptr{t8_shmem_array_t}, elem_size::Csize_t, elem_count::Csize_t, comm::MPI_Comm)::Cvoid +function p8est_connectivity_deflate(conn, code) + @ccall libp4est.p8est_connectivity_deflate(conn::Ptr{p8est_connectivity_t}, code::p8est_connectivity_encode_t)::Ptr{sc_array_t} end """ - t8_shmem_array_start_writing(array) - -Enable writing mode for a shmem array. Only some processes may be allowed to write into the array, which is indicated by the return value being non-zero. The shared memory is managed via inter- and intranode communicators. Only rank 0 of the intranode communicator will be allowed to write into the array. - -!!! note + p8est_connectivity_save(filename, connectivity) - This function is MPI collective. +Save a connectivity structure to disk. # Arguments -* `array`:\\[in,out\\] Initialized array. Writing will be enabled on certain processes. +* `filename`:\\[in\\] Name of the file to write. +* `connectivity`:\\[in\\] Valid connectivity structure. # Returns -True if the calling process can write into the array. +Returns 0 on success, nonzero on file error. ### Prototype ```c -int t8_shmem_array_start_writing (t8_shmem_array_t array); +int p8est_connectivity_save (const char *filename, p8est_connectivity_t * connectivity); ``` """ -function t8_shmem_array_start_writing(array) - @ccall libt8.t8_shmem_array_start_writing(array::t8_shmem_array_t)::Cint +function p8est_connectivity_save(filename, connectivity) + @ccall libp4est.p8est_connectivity_save(filename::Cstring, connectivity::Ptr{p8est_connectivity_t})::Cint end """ - t8_shmem_array_end_writing(array) - -Disable writing mode for a shmem array. - -!!! note + p8est_connectivity_source(source) - This function is MPI collective. +Read connectivity from a source object. # Arguments -* `array`:\\[in,out\\] Initialized with writing mode enabled. -# See also -[`t8_shmem_array_start_writing`](@ref). - +* `source`:\\[in,out\\] The connectivity is read from this source. +# Returns +The newly created connectivity, or NULL on error. ### Prototype ```c -void t8_shmem_array_end_writing (t8_shmem_array_t array); +p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source); ``` """ -function t8_shmem_array_end_writing(array) - @ccall libt8.t8_shmem_array_end_writing(array::t8_shmem_array_t)::Cvoid +function p8est_connectivity_source(source) + @ccall libp4est.p8est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_set_gloidx(array, index, value) + p8est_connectivity_inflate(buffer) -Set an entry of a t8\\_shmem array that is used to store [`t8_gloidx_t`](@ref). The array must have writing mode enabled t8_shmem_array_start_writing. +Create new connectivity from a memory buffer. This function aborts on malloc errors. # Arguments -* `array`:\\[in,out\\] The array to be modified. -* `index`:\\[in\\] The array entry to be modified. -* `value`:\\[in\\] The new value to be set. +* `buffer`:\\[in\\] The connectivity is created from this memory buffer. +# Returns +The newly created connectivity, or NULL on format error of the buffered connectivity data. ### Prototype ```c -void t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value); +p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer); ``` """ -function t8_shmem_array_set_gloidx(array, index, value) - @ccall libt8.t8_shmem_array_set_gloidx(array::t8_shmem_array_t, index::Cint, value::t8_gloidx_t)::Cvoid +function p8est_connectivity_inflate(buffer) + @ccall libp4est.p8est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_copy(dest, source) - -Copy the contents of one t8\\_shmem array into another. - -!!! note - - *dest* must be initialized and match in element size and element count to *source*. - -!!! note + p8est_connectivity_load(filename, bytes) - *dest* must have writing mode disabled. +Load a connectivity structure from disk. # Arguments -* `dest`:\\[in,out\\] The array in which *source* should be copied. -* `source`:\\[in\\] The array to copy. +* `filename`:\\[in\\] Name of the file to read. +* `bytes`:\\[out\\] Size in bytes of connectivity on disk or NULL. +# Returns +Returns valid connectivity, or NULL on file error. ### Prototype ```c -void t8_shmem_array_copy (t8_shmem_array_t dest, t8_shmem_array_t source); +p8est_connectivity_t *p8est_connectivity_load (const char *filename, size_t *bytes); ``` """ -function t8_shmem_array_copy(dest, source) - @ccall libt8.t8_shmem_array_copy(dest::t8_shmem_array_t, source::t8_shmem_array_t)::Cvoid +function p8est_connectivity_load(filename, bytes) + @ccall libp4est.p8est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) + p8est_connectivity_new_unitcube() + +Create a connectivity structure for the unit cube. ### Prototype ```c -void t8_shmem_array_allgather (const void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, int recvcount, sc_MPI_Datatype recvtype); +p8est_connectivity_t *p8est_connectivity_new_unitcube (void); ``` """ -function t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) - @ccall libt8.t8_shmem_array_allgather(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvcount::Cint, recvtype::Cint)::Cvoid +function p8est_connectivity_new_unitcube() + @ccall libp4est.p8est_connectivity_new_unitcube()::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) + p8est_connectivity_new_periodic() + +Create a connectivity structure for an all-periodic unit cube. ### Prototype ```c -void t8_shmem_array_allgatherv (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, sc_MPI_Datatype recvtype, sc_MPI_Comm comm); +p8est_connectivity_t *p8est_connectivity_new_periodic (void); ``` """ -function t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) - @ccall libt8.t8_shmem_array_allgatherv(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvtype::Cint, comm::MPI_Comm)::Cvoid +function p8est_connectivity_new_periodic() + @ccall libp4est.p8est_connectivity_new_periodic()::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) + p8est_connectivity_new_rotwrap() + +Create a connectivity structure for a mostly periodic unit cube. The left and right faces are identified, and bottom and top rotated. Front and back are not identified. ### Prototype ```c -void t8_shmem_array_prefix (const void *sendbuf, t8_shmem_array_t recvarray, const int count, sc_MPI_Datatype type, sc_MPI_Op op, sc_MPI_Comm comm); +p8est_connectivity_t *p8est_connectivity_new_rotwrap (void); ``` """ -function t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) - @ccall libt8.t8_shmem_array_prefix(sendbuf::Ptr{Cvoid}, recvarray::t8_shmem_array_t, count::Cint, type::Cint, op::Cint, comm::MPI_Comm)::Cvoid +function p8est_connectivity_new_rotwrap() + @ccall libp4est.p8est_connectivity_new_rotwrap()::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_get_comm(array) + p8est_connectivity_new_drop() + +Create a connectivity structure for a five-trees geometry with a hole. The geometry is a 3D extrusion of the two drop example, and covers [0, 3]*[0, 2]*[0, 3]. The additional dimension is Y. ### Prototype ```c -sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array); +p8est_connectivity_t *p8est_connectivity_new_drop (void); ``` """ -function t8_shmem_array_get_comm(array) - @ccall libt8.t8_shmem_array_get_comm(array::t8_shmem_array_t)::Cint +function p8est_connectivity_new_drop() + @ccall libp4est.p8est_connectivity_new_drop()::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_get_elem_size(array) + p8est_connectivity_new_twocubes() -Get the element size of a [`t8_shmem_array`](@ref) +Create a connectivity structure that contains two cubes. -# Arguments -* `array`:\\[in\\] The array. -# Returns -The element size of *array*'s elements. ### Prototype ```c -size_t t8_shmem_array_get_elem_size (t8_shmem_array_t array); +p8est_connectivity_t *p8est_connectivity_new_twocubes (void); ``` """ -function t8_shmem_array_get_elem_size(array) - @ccall libt8.t8_shmem_array_get_elem_size(array::t8_shmem_array_t)::Csize_t +function p8est_connectivity_new_twocubes() + @ccall libp4est.p8est_connectivity_new_twocubes()::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_get_elem_count(array) + p8est_connectivity_new_twotrees(l_face, r_face, orientation) -Get the number of elements of a [`t8_shmem_array`](@ref) +Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way. # Arguments -* `array`:\\[in\\] The array. -# Returns -The number of elements in *array*. +* `l_face`:\\[in\\] index of left face +* `r_face`:\\[in\\] index of right face +* `orientation`:\\[in\\] orientation of trees w.r.t. each other ### Prototype ```c -size_t t8_shmem_array_get_elem_count (t8_shmem_array_t array); +p8est_connectivity_t *p8est_connectivity_new_twotrees (int l_face, int r_face, int orientation); ``` """ -function t8_shmem_array_get_elem_count(array) - @ccall libt8.t8_shmem_array_get_elem_count(array::t8_shmem_array_t)::Csize_t +function p8est_connectivity_new_twotrees(l_face, r_face, orientation) + @ccall libp4est.p8est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_get_gloidx_array(array) - -Return a read-only pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. - -!!! note + p8est_connectivity_new_twowrap() - Writing mode must be disabled for *array*. +Create a connectivity structure that contains two cubes where the two far ends are identified periodically. -# Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) -# Returns -The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -const t8_gloidx_t * t8_shmem_array_get_gloidx_array (t8_shmem_array_t array); +p8est_connectivity_t *p8est_connectivity_new_twowrap (void); ``` """ -function t8_shmem_array_get_gloidx_array(array) - @ccall libt8.t8_shmem_array_get_gloidx_array(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} +function p8est_connectivity_new_twowrap() + @ccall libp4est.p8est_connectivity_new_twowrap()::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_get_gloidx_array_for_writing(array) + p8est_connectivity_new_rotcubes() -Return a pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. The array must have writing enabled t8_shmem_array_start_writing and you should not write into the memory after t8_shmem_array_end_writing was called. +Create a connectivity structure that contains a few cubes. These are rotated against each other to stress the topology routines. -# Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) -# Returns -The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -t8_gloidx_t * t8_shmem_array_get_gloidx_array_for_writing (t8_shmem_array_t array); +p8est_connectivity_t *p8est_connectivity_new_rotcubes (void); ``` """ -function t8_shmem_array_get_gloidx_array_for_writing(array) - @ccall libt8.t8_shmem_array_get_gloidx_array_for_writing(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} +function p8est_connectivity_new_rotcubes() + @ccall libp4est.p8est_connectivity_new_rotcubes()::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_get_gloidx(array, index) - -Return an entry of a shared memory array that stores [`t8_gloidx_t`](@ref). - -!!! note + p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) - Writing mode must be disabled for *array*. +An m by n by p array with periodicity in x, y, and z if periodic\\_a, periodic\\_b, and periodic\\_c are true, respectively. -# Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) -* `index`:\\[in\\] The index of the entry to be queried. -# Returns -The *index*-th entry of *array* as [`t8_gloidx_t`](@ref). ### Prototype ```c -t8_gloidx_t t8_shmem_array_get_gloidx (t8_shmem_array_t array, int index); +p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c); ``` """ -function t8_shmem_array_get_gloidx(array, index) - @ccall libt8.t8_shmem_array_get_gloidx(array::t8_shmem_array_t, index::Cint)::t8_gloidx_t +function p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) + @ccall libp4est.p8est_connectivity_new_brick(m::Cint, n::Cint, p::Cint, periodic_a::Cint, periodic_b::Cint, periodic_c::Cint)::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_get_array(array) - -Return a pointer to the data array of a [`t8_shmem_array`](@ref). - -!!! note + p8est_connectivity_new_shell() - Writing mode must be disabled for *array*. +Create a connectivity structure that builds a spherical shell. It is made up of six connected parts [-1,1]x[-1,1]x[1,2]. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). -# Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref). -# Returns -A pointer to the data array of *array*. ### Prototype ```c -const void * t8_shmem_array_get_array (t8_shmem_array_t array); +p8est_connectivity_t *p8est_connectivity_new_shell (void); ``` """ -function t8_shmem_array_get_array(array) - @ccall libt8.t8_shmem_array_get_array(array::t8_shmem_array_t)::Ptr{Cvoid} +function p8est_connectivity_new_shell() + @ccall libp4est.p8est_connectivity_new_shell()::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_index(array, index) - -Return a read-only pointer to an element in a [`t8_shmem_array`](@ref). - -!!! note - - You should not modify the value. - -!!! note + p8est_connectivity_new_sphere() - Writing mode must be disabled for *array*. +Create a connectivity structure that builds a solid sphere. It is made up of two layers and a cube in the center. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). -# Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref). -* `index`:\\[in\\] The index of an element. -# Returns -A pointer to the element at *index* in *array*. ### Prototype ```c -const void * t8_shmem_array_index (t8_shmem_array_t array, size_t index); +p8est_connectivity_t *p8est_connectivity_new_sphere (void); ``` """ -function t8_shmem_array_index(array, index) - @ccall libt8.t8_shmem_array_index(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} +function p8est_connectivity_new_sphere() + @ccall libp4est.p8est_connectivity_new_sphere()::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_index_for_writing(array, index) - -Return a pointer to an element in a [`t8_shmem_array`](@ref) in writing mode. + p8est_connectivity_new_torus(nSegments) -!!! note +Create a connectivity structure that builds a revolution torus. - You can modify the value before the next call to t8_shmem_array_end_writing. +This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). -!!! note +This connectivity reuses ideas from disk2d connectivity. More precisely the torus is divided into segments around the revolution axis, each segments is made of 5 trees (à la disk2d). The total number of trees if 5 times the number of segments. - Writing mode must be enabled for *array*. +This connectivity is meant to be used with p8est_geometry_new_torus # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref). -* `index`:\\[in\\] The index of an element. -# Returns -A pointer to the element at *index* in *array*. +* `nSegments`:\\[in\\] number of trees along the great circle ### Prototype ```c -void * t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index); +p8est_connectivity_t *p8est_connectivity_new_torus (int nSegments); ``` """ -function t8_shmem_array_index_for_writing(array, index) - @ccall libt8.t8_shmem_array_index_for_writing(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} +function p8est_connectivity_new_torus(nSegments) + @ccall libp4est.p8est_connectivity_new_torus(nSegments::Cint)::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_is_equal(array_a, array_b) - -Check if two t8\\_shmem arrays are equal. - -!!! note + p8est_connectivity_new_byname(name) - Writing mode must be disabled for *array_a* and *array_b*. +Create connectivity structure from predefined catalogue. # Arguments -* `array_a`:\\[in\\] The first [`t8_shmem_array`](@ref) to compare. -* `array_b`:\\[in\\] The second [`t8_shmem_array`](@ref) to compare. +* `name`:\\[in\\] Invokes connectivity\\_new\\_* function. brick235 brick (2, 3, 5, 0, 0, 0) periodic periodic rotcubes rotcubes rotwrap rotwrap shell shell sphere sphere twocubes twocubes twowrap twowrap unit unitcube # Returns -1 if the arrays are equal, 0 otherwise. +An initialized connectivity if name is defined, NULL else. ### Prototype ```c -int t8_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b); +p8est_connectivity_t *p8est_connectivity_new_byname (const char *name); ``` """ -function t8_shmem_array_is_equal(array_a, array_b) - @ccall libt8.t8_shmem_array_is_equal(array_a::t8_shmem_array_t, array_b::t8_shmem_array_t)::Cint +function p8est_connectivity_new_byname(name) + @ccall libp4est.p8est_connectivity_new_byname(name::Cstring)::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_destroy(parray) + p8est_connectivity_refine(conn, num_per_dim) -Free all memory associated with a [`t8_shmem_array`](@ref). +Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. # Arguments -* `parray`:\\[in,out\\] On input a pointer to a valid [`t8_shmem_array`](@ref). This array is freed and *parray* is set to NULL on return. +* `conn`:\\[in\\] A valid connectivity +* `num_per_dim`:\\[in\\] The number of new trees in each direction. Must use no more than P8EST_OLD_QMAXLEVEL bits. +# Returns +a refined connectivity. ### Prototype ```c -void t8_shmem_array_destroy (t8_shmem_array_t *parray); +p8est_connectivity_t *p8est_connectivity_refine (p8est_connectivity_t * conn, int num_per_dim); ``` """ -function t8_shmem_array_destroy(parray) - @ccall libt8.t8_shmem_array_destroy(parray::Ptr{t8_shmem_array_t})::Cvoid +function p8est_connectivity_refine(conn, num_per_dim) + @ccall libp4est.p8est_connectivity_refine(conn::Ptr{p8est_connectivity_t}, num_per_dim::Cint)::Ptr{p8est_connectivity_t} end """ - t8_shmem_array_binary_search(array, value, size, compare) + p8est_expand_face_transform(iface, nface, ftransform) -Perform a binary search in a [`t8_shmem_array`](@ref). +Fill an array with the axis combination of a face neighbor transform. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) to search in. -* `value`:\\[in\\] The value to search for. -* `size`:\\[in\\] The number of elements in the array. -* `compare`:\\[in\\] A function that compares an element of the array with the value. -# Returns -The index of the element in *array* that matches *value*. +* `iface`:\\[in\\] The number of the originating face. +* `nface`:\\[in\\] Encoded as nface = r * 6 + nf, where nf = 0..5 is the neigbbor's connecting face number and r = 0..3 is the relative orientation to the neighbor's face. This encoding matches [`p8est_connectivity_t`](@ref). +* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face, the first two referring to the tangentials and the third to the normal. A permutation of (0, 1, 2). [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flags for tangential axes (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q ### Prototype ```c -int t8_shmem_array_binary_search (t8_shmem_array_t array, const t8_gloidx_t value, const int size, int (*compare) (t8_shmem_array_t, const int, const t8_gloidx_t)); +void p8est_expand_face_transform (int iface, int nface, int ftransform[]); ``` """ -function t8_shmem_array_binary_search(array, value, size, compare) - @ccall libt8.t8_shmem_array_binary_search(array::t8_shmem_array_t, value::t8_gloidx_t, size::Cint, compare::Ptr{Cvoid})::Cint +function p8est_expand_face_transform(iface, nface, ftransform) + @ccall libp4est.p8est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid end """ - t8_eclass_count_boundary(theclass, min_dim, per_eclass) + p8est_find_face_transform(connectivity, itree, iface, ftransform) -Query the element class and count of boundary points. +Fill an array with the axis combination of a face neighbor transform. # Arguments -* `theclass`:\\[in\\] We query a point of this element class. -* `min_dim`:\\[in\\] Ignore boundary points of lesser dimension. The ignored points get a count value of 0. -* `per_eclass`:\\[out\\] Array of length T8\\_ECLASS\\_COUNT to be filled with the count of the boundary objects, counted per each of the element classes. +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `iface`:\\[in\\] The number of the originating tree's face. +* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face. [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flag for axes t1, t2; face code for n; # Returns -The count over all boundary points. +The face neighbor tree if it exists, -1 otherwise. +# See also +[`p8est_expand_face_transform`](@ref). + ### Prototype ```c -int t8_eclass_count_boundary (t8_eclass_t theclass, int min_dim, int *per_eclass); +p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); ``` """ -function t8_eclass_count_boundary(theclass, min_dim, per_eclass) - @ccall libt8.t8_eclass_count_boundary(theclass::t8_eclass_t, min_dim::Cint, per_eclass::Ptr{Cint})::Cint +function p8est_find_face_transform(connectivity, itree, iface, ftransform) + @ccall libp4est.p8est_find_face_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iface::Cint, ftransform::Ptr{Cint})::p4est_topidx_t end """ - t8_eclass_compare(eclass1, eclass2) + p8est_find_edge_transform(connectivity, itree, iedge, ei) -Compare two eclasses of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. +Fills an array with information about edge neighbors. # Arguments -* `eclass1`:\\[in\\] The first eclass to compare. -* `eclass2`:\\[in\\] The second eclass to compare. -# Returns -0 if the eclasses are equal, 1 if eclass1 > eclass2 and -1 if eclass1 < eclass2 +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `iedge`:\\[in\\] The number of the originating edge. +* `ei`:\\[in,out\\] A [`p8est_edge_info_t`](@ref) structure with initialized array. ### Prototype ```c -int t8_eclass_compare (t8_eclass_t eclass1, t8_eclass_t eclass2); +void p8est_find_edge_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t * ei); ``` """ -function t8_eclass_compare(eclass1, eclass2) - @ccall libt8.t8_eclass_compare(eclass1::t8_eclass_t, eclass2::t8_eclass_t)::Cint +function p8est_find_edge_transform(connectivity, itree, iedge, ei) + @ccall libp4est.p8est_find_edge_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iedge::Cint, ei::Ptr{p8est_edge_info_t})::Cvoid end """ - t8_eclass_is_valid(eclass) + p8est_find_corner_transform(connectivity, itree, icorner, ci) -Check whether a class is a valid class. Returns non-zero if it is a valid class, returns zero, if the class is equal to T8\\_ECLASS\\_INVALID. +Fills an array with information about corner neighbors. # Arguments -* `eclass`:\\[in\\] The eclass to check. -# Returns -Non-zero if *eclass* is valid, zero otherwise. +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `icorner`:\\[in\\] The number of the originating corner. +* `ci`:\\[in,out\\] A [`p8est_corner_info_t`](@ref) structure with initialized array. ### Prototype ```c -int t8_eclass_is_valid (t8_eclass_t eclass); +void p8est_find_corner_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t * ci); ``` """ -function t8_eclass_is_valid(eclass) - @ccall libt8.t8_eclass_is_valid(eclass::t8_eclass_t)::Cint +function p8est_find_corner_transform(connectivity, itree, icorner, ci) + @ccall libp4est.p8est_find_corner_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, icorner::Cint, ci::Ptr{p8est_corner_info_t})::Cvoid end -"""Type definition for the geometric shape of an element. Currently the possible shapes are the same as the possible element classes. I.e. T8\\_ECLASS\\_VERTEX, T8\\_ECLASS\\_TET, etc...""" -const t8_element_shape_t = t8_eclass_t - """ - t8_element_shape_num_faces(element_shape) + p8est_connectivity_complete(conn) -The number of codimension-one boundaries of an element class. +Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. +# Arguments +* `conn`:\\[in,out\\] The connectivity needs to have proper vertices and tree\\_to\\_vertex fields. The tree\\_to\\_tree and tree\\_to\\_face fields must be allocated and satisfy [`p8est_connectivity_is_valid`](@ref) (conn) but will be overwritten. The edge and corner fields will be freed and allocated anew. ### Prototype ```c -int t8_element_shape_num_faces (int element_shape); +void p8est_connectivity_complete (p8est_connectivity_t * conn); ``` """ -function t8_element_shape_num_faces(element_shape) - @ccall libt8.t8_element_shape_num_faces(element_shape::Cint)::Cint +function p8est_connectivity_complete(conn) + @ccall libp4est.p8est_connectivity_complete(conn::Ptr{p8est_connectivity_t})::Cvoid end """ - t8_element_shape_max_num_faces(element_shape) + p8est_connectivity_reduce(conn) -For each dimension the maximum possible number of faces of an element\\_shape of that dimension. +Removes corner and edge information of a connectivity such that enough information is left to run [`p8est_connectivity_complete`](@ref) successfully. The reduced connectivity still passes [`p8est_connectivity_is_valid`](@ref). +# Arguments +* `conn`:\\[in,out\\] The connectivity to be reduced. ### Prototype ```c -int t8_element_shape_max_num_faces (int element_shape); +void p8est_connectivity_reduce (p8est_connectivity_t * conn); ``` """ -function t8_element_shape_max_num_faces(element_shape) - @ccall libt8.t8_element_shape_max_num_faces(element_shape::Cint)::Cint +function p8est_connectivity_reduce(conn) + @ccall libp4est.p8est_connectivity_reduce(conn::Ptr{p8est_connectivity_t})::Cvoid end """ - t8_element_shape_num_vertices(element_shape) + p8est_connectivity_permute(conn, perm, is_current_to_new) -The number of vertices of an element class. +[`p8est_connectivity_permute`](@ref) Given a permutation *perm* of the trees in a connectivity *conn*, permute the trees of *conn* in place and update *conn* to match. +# Arguments +* `conn`:\\[in,out\\] The connectivity whose trees are permuted. +* `perm`:\\[in\\] A permutation array, whose elements are size\\_t's. +* `is_current_to_new`:\\[in\\] if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation. ### Prototype ```c -int t8_element_shape_num_vertices (int element_shape); +void p8est_connectivity_permute (p8est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); ``` """ -function t8_element_shape_num_vertices(element_shape) - @ccall libt8.t8_element_shape_num_vertices(element_shape::Cint)::Cint +function p8est_connectivity_permute(conn, perm, is_current_to_new) + @ccall libp4est.p8est_connectivity_permute(conn::Ptr{p8est_connectivity_t}, perm::Ptr{sc_array_t}, is_current_to_new::Cint)::Cvoid end """ - t8_element_shape_vtk_type(element_shape) + p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) -The vtk cell type for the element\\_shape +[`p8est_connectivity_join_faces`](@ref) This function takes an existing valid connectivity *conn* and modifies it by joining two tree faces that are currently boundary faces. +# Arguments +* `conn`:\\[in,out\\] connectivity that will be altered. +* `tree_left`:\\[in\\] tree that will be on the left side of the joined faces. +* `tree_right`:\\[in\\] tree that will be on the right side of the joined faces. +* `face_left`:\\[in\\] face of *tree_left* that will be joined. +* `face_right`:\\[in\\] face of *tree_right* that will be joined. +* `orientation`:\\[in\\] the orientation of *face_left* and *face_right* once joined (see the description of [`p8est_connectivity_t`](@ref) to understand orientation). ### Prototype ```c -int t8_element_shape_vtk_type (int element_shape); +void p8est_connectivity_join_faces (p8est_connectivity_t * conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation); ``` """ -function t8_element_shape_vtk_type(element_shape) - @ccall libt8.t8_element_shape_vtk_type(element_shape::Cint)::Cint +function p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + @ccall libp4est.p8est_connectivity_join_faces(conn::Ptr{p8est_connectivity_t}, tree_left::p4est_topidx_t, tree_right::p4est_topidx_t, face_left::Cint, face_right::Cint, orientation::Cint)::Cvoid end """ - t8_element_shape_t8_to_vtk_corner_number(element_shape, index) + p8est_connectivity_is_equivalent(conn1, conn2) -Maps the t8code corner number of the element to the vtk corner number +[`p8est_connectivity_is_equivalent`](@ref) This function compares two connectivities for equivalence: it returns *true* if they are the same connectivity, or if they have the same topology. The definition of topological sameness is strict: there is no attempt made to determine whether permutation and/or rotation of the trees makes the connectivities equivalent. # Arguments -* `element_shape`:\\[in\\] The shape of the element. -* `index`:\\[in\\] The index of the corner in z-order (t8code numeration). -# Returns -The corresponding vtk index. +* `conn1`:\\[in\\] a valid connectivity +* `conn2`:\\[out\\] a valid connectivity ### Prototype ```c -int t8_element_shape_t8_to_vtk_corner_number (int element_shape, int index); +int p8est_connectivity_is_equivalent (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); ``` """ -function t8_element_shape_t8_to_vtk_corner_number(element_shape, index) - @ccall libt8.t8_element_shape_t8_to_vtk_corner_number(element_shape::Cint, index::Cint)::Cint +function p8est_connectivity_is_equivalent(conn1, conn2) + @ccall libp4est.p8est_connectivity_is_equivalent(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint end """ - t8_element_shape_t8_corner_number(element_shape, index) - -Maps the vtk corner number of the element to the t8code corner number + p8est_edge_array_index(array, it) -# Arguments -* `element_shape`:\\[in\\] The shape of the element. -* `index`:\\[in\\] The index of the corner in vtk ordering. -# Returns -The corresponding t8code index. ### Prototype ```c -int t8_element_shape_t8_corner_number (int element_shape, int index); +static inline p8est_edge_transform_t * p8est_edge_array_index (sc_array_t * array, size_t it); ``` """ -function t8_element_shape_t8_corner_number(element_shape, index) - @ccall libt8.t8_element_shape_t8_corner_number(element_shape::Cint, index::Cint)::Cint +function p8est_edge_array_index(array, it) + @ccall libp4est.p8est_edge_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_edge_transform_t} end """ - t8_element_shape_to_string(element_shape) - -For each element\\_shape, the name of this class as a string + p8est_corner_array_index(array, it) ### Prototype ```c -const char* t8_element_shape_to_string (int element_shape); +static inline p8est_corner_transform_t * p8est_corner_array_index (sc_array_t * array, size_t it); ``` """ -function t8_element_shape_to_string(element_shape) - @ccall libt8.t8_element_shape_to_string(element_shape::Cint)::Cstring +function p8est_corner_array_index(array, it) + @ccall libp4est.p8est_corner_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_corner_transform_t} end """ - t8_element_shape_compare(element_shape1, element_shape2) + p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) + +Read an ABAQUS input file from a file stream. + +This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. + +A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: + +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 + +and in 3D they are given as: + +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 + +```c++ + *Heading + box.inp + *Node + 1, 5, -5, 5 + 2, 5, 5, 5 + 3, 5, 0, 5 + 4, -5, 5, 5 + 5, 0, 5, 5 + 6, -5, -5, 5 + 7, -5, 0, 5 + 8, 0, -5, 5 + 9, 0, 0, 5 + 10, 5, 5, -5 + 11, 5, -5, -5 + 12, 5, 0, -5 + 13, -5, -5, -5 + 14, 0, -5, -5 + 15, -5, 5, -5 + 16, -5, 0, -5 + 17, 0, 5, -5 + 18, 0, 0, -5 + 19, -5, -5, 0 + 20, 5, -5, 0 + 21, 0, -5, 0 + 22, -5, 5, 0 + 23, -5, 0, 0 + 24, 5, 5, 0 + 25, 0, 5, 0 + 26, 5, 0, 0 + 27, 0, 0, 0 + *Element, type=C3D8, ELSET=EB1 + 1, 6, 19, 23, 7, 8, 21, 27, 9 + 2, 19, 13, 16, 23, 21, 14, 18, 27 + 3, 7, 23, 22, 4, 9, 27, 25, 5 + 4, 23, 16, 15, 22, 27, 18, 17, 25 + 5, 8, 21, 27, 9, 1, 20, 26, 3 + 6, 21, 14, 18, 27, 20, 11, 12, 26 + 7, 9, 27, 25, 5, 3, 26, 24, 2 + 8, 27, 18, 17, 25, 26, 12, 10, 24 +``` -Compare two element\\_shapes of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. +This code can be called two ways. The first, when `vertex`==NULL and `tree_to_vertex`==NULL, is used to count the number of trees and vertices in the connectivity to be generated by the `.inp` mesh in the *stream*. The second, when `vertices`!=NULL and `tree_to_vertex`!=NULL, fill `vertices` and `tree_to_vertex`. In this case `num_vertices` and `num_trees` need to be set to the maximum number of entries allocated in `vertices` and `tree_to_vertex`. # Arguments -* `element_shape1`:\\[in\\] The first element\\_shape to compare. -* `element_shape2`:\\[in\\] The second element\\_shape to compare. +* `stream`:\\[in,out\\] file stream to read the connectivity from +* `num_vertices`:\\[in,out\\] the number of vertices in the connectivity +* `num_trees`:\\[in,out\\] the number of trees in the connectivity +* `vertices`:\\[out\\] the list of `vertices` of the connectivity +* `tree_to_vertex`:\\[out\\] the `tree_to_vertex` map of the connectivity # Returns -0 if the element\\_shapes are equal, 1 if element\\_shape1 > element\\_shape2 and -1 if element\\_shape1 < element\\_shape2 +0 if successful and nonzero if not ### Prototype ```c -int t8_element_shape_compare (t8_element_shape_t element_shape1, t8_element_shape_t element_shape2); +int p8est_connectivity_read_inp_stream (FILE * stream, p4est_topidx_t * num_vertices, p4est_topidx_t * num_trees, double *vertices, p4est_topidx_t * tree_to_vertex); ``` """ -function t8_element_shape_compare(element_shape1, element_shape2) - @ccall libt8.t8_element_shape_compare(element_shape1::t8_element_shape_t, element_shape2::t8_element_shape_t)::Cint +function p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) + @ccall libp4est.p8est_connectivity_read_inp_stream(stream::Ptr{Libc.FILE}, num_vertices::Ptr{p4est_topidx_t}, num_trees::Ptr{p4est_topidx_t}, vertices::Ptr{Cdouble}, tree_to_vertex::Ptr{p4est_topidx_t})::Cint end """ - sc_keyvalue_entry_type_t + p8est_connectivity_read_inp(filename) -The values can have different types. +Create a p4est connectivity from an ABAQUS input file. -| Enumerator | Note | -| :------------------------------ | :------------------------------------------ | -| SC\\_KEYVALUE\\_ENTRY\\_NONE | Designate an invalid situation. | -| SC\\_KEYVALUE\\_ENTRY\\_INT | Used for values of type int. | -| SC\\_KEYVALUE\\_ENTRY\\_DOUBLE | Used for values of type double. | -| SC\\_KEYVALUE\\_ENTRY\\_STRING | Used for values of type const char *. | -| SC\\_KEYVALUE\\_ENTRY\\_POINTER | Used for values of anonymous pointer type. | -""" -@cenum sc_keyvalue_entry_type_t::UInt32 begin - SC_KEYVALUE_ENTRY_NONE = 0 - SC_KEYVALUE_ENTRY_INT = 1 - SC_KEYVALUE_ENTRY_DOUBLE = 2 - SC_KEYVALUE_ENTRY_STRING = 3 - SC_KEYVALUE_ENTRY_POINTER = 4 -end +This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. -mutable struct sc_keyvalue end +A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: -"""The key-value container is an opaque structure.""" -const sc_keyvalue_t = sc_keyvalue +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 -# no prototype is found for this function at sc_keyvalue.h:54:21, please use with caution -""" - sc_keyvalue_new() +and in 3D they are given as: -Create a new key-value container. +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 + +```c++ + *Heading + box.inp + *Node + 1, 5, -5, 5 + 2, 5, 5, 5 + 3, 5, 0, 5 + 4, -5, 5, 5 + 5, 0, 5, 5 + 6, -5, -5, 5 + 7, -5, 0, 5 + 8, 0, -5, 5 + 9, 0, 0, 5 + 10, 5, 5, -5 + 11, 5, -5, -5 + 12, 5, 0, -5 + 13, -5, -5, -5 + 14, 0, -5, -5 + 15, -5, 5, -5 + 16, -5, 0, -5 + 17, 0, 5, -5 + 18, 0, 0, -5 + 19, -5, -5, 0 + 20, 5, -5, 0 + 21, 0, -5, 0 + 22, -5, 5, 0 + 23, -5, 0, 0 + 24, 5, 5, 0 + 25, 0, 5, 0 + 26, 5, 0, 0 + 27, 0, 0, 0 + *Element, type=C3D8, ELSET=EB1 + 1, 6, 19, 23, 7, 8, 21, 27, 9 + 2, 19, 13, 16, 23, 21, 14, 18, 27 + 3, 7, 23, 22, 4, 9, 27, 25, 5 + 4, 23, 16, 15, 22, 27, 18, 17, 25 + 5, 8, 21, 27, 9, 1, 20, 26, 3 + 6, 21, 14, 18, 27, 20, 11, 12, 26 + 7, 9, 27, 25, 5, 3, 26, 24, 2 + 8, 27, 18, 17, 25, 26, 12, 10, 24 +``` +This function reads a mesh from *filename* and returns an associated p4est connectivity. + +# Arguments +* `filename`:\\[in\\] file to read the connectivity from # Returns -The container is ready to use. +an allocated connectivity associated with the mesh in *filename* ### Prototype ```c -sc_keyvalue_t *sc_keyvalue_new (); +p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename); ``` """ -function sc_keyvalue_new() - @ccall libsc.sc_keyvalue_new()::Ptr{sc_keyvalue_t} +function p8est_connectivity_read_inp(filename) + @ccall libp4est.p8est_connectivity_read_inp(filename::Cstring)::Ptr{p8est_connectivity_t} end -# automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_keyvalue_newf(dummy, va_list...) - :(@ccall(libsc.sc_keyvalue_newf(dummy::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_keyvalue_t})) - end +""" + t8_cmesh_new_from_p4est(conn, comm, do_partition) +### Prototype +```c +t8_cmesh_t t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); +``` """ - sc_keyvalue_destroy(kv) +function t8_cmesh_new_from_p4est(conn, comm, do_partition) + @ccall libt8.t8_cmesh_new_from_p4est(conn::Ptr{p4est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t +end -Free a key-value container and all internal memory for key storage. +""" + t8_cmesh_new_from_p8est(conn, comm, do_partition) -# Arguments -* `kv`:\\[in,out\\] The key-value container is invalidated by this call. ### Prototype ```c -void sc_keyvalue_destroy (sc_keyvalue_t * kv); +t8_cmesh_t t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); ``` """ -function sc_keyvalue_destroy(kv) - @ccall libsc.sc_keyvalue_destroy(kv::Ptr{sc_keyvalue_t})::Cvoid +function t8_cmesh_new_from_p8est(conn, comm, do_partition) + @ccall libt8.t8_cmesh_new_from_p8est(conn::Ptr{p8est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t end """ - sc_keyvalue_exists(kv, key) - -Routine to check existence of an entry. + t8_cmesh_new_empty(comm, do_partition, dimension) -# Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key to query. -# Returns -The entry's type if found and SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. ### Prototype ```c -sc_keyvalue_entry_type_t sc_keyvalue_exists (sc_keyvalue_t * kv, const char *key); +t8_cmesh_t t8_cmesh_new_empty (sc_MPI_Comm comm, const int do_partition, const int dimension); ``` """ -function sc_keyvalue_exists(kv, key) - @ccall libsc.sc_keyvalue_exists(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t +function t8_cmesh_new_empty(comm, do_partition, dimension) + @ccall libt8.t8_cmesh_new_empty(comm::MPI_Comm, do_partition::Cint, dimension::Cint)::t8_cmesh_t end """ - sc_keyvalue_unset(kv, key) - -Routine to remove an entry. + t8_cmesh_new_from_class(eclass, comm) -# Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key to remove if it exists. -# Returns -The entry's type if found and removed, SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. ### Prototype ```c -sc_keyvalue_entry_type_t sc_keyvalue_unset (sc_keyvalue_t * kv, const char *key); +t8_cmesh_t t8_cmesh_new_from_class (t8_eclass_t eclass, sc_MPI_Comm comm); ``` """ -function sc_keyvalue_unset(kv, key) - @ccall libsc.sc_keyvalue_unset(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t +function t8_cmesh_new_from_class(eclass, comm) + @ccall libt8.t8_cmesh_new_from_class(eclass::t8_eclass_t, comm::MPI_Comm)::t8_cmesh_t end """ - sc_keyvalue_get_int(kv, key, dvalue) + t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) -Routines to retrieve an integer value by its key. This function asserts that the key, if existing, points to the correct type. +### Prototype +```c +t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int do_partition, int periodic); +``` +""" +function t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) + @ccall libt8.t8_cmesh_new_hypercube(eclass::t8_eclass_t, comm::MPI_Comm, do_bcast::Cint, do_partition::Cint, periodic::Cint)::t8_cmesh_t +end + +""" + t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) -# Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. -# Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -int sc_keyvalue_get_int (sc_keyvalue_t * kv, const char *key, int dvalue); +t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned); ``` """ -function sc_keyvalue_get_int(kv, key, dvalue) - @ccall libsc.sc_keyvalue_get_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cint)::Cint +function t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) + @ccall libt8.t8_cmesh_new_hypercube_pad(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, use_axis_aligned::Cint)::t8_cmesh_t end """ - sc_keyvalue_get_double(kv, key, dvalue) - -Retrieve a double value by its key. This function asserts that the key, if existing, points to the correct type. + t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) -# Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. -# Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -double sc_keyvalue_get_double (sc_keyvalue_t * kv, const char *key, double dvalue); +t8_cmesh_t t8_cmesh_new_hypercube_pad_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int periodic_x, const int periodic_y, const int periodic_z, const int use_axis_aligned, const int set_partition, t8_gloidx_t offset); ``` """ -function sc_keyvalue_get_double(kv, key, dvalue) - @ccall libsc.sc_keyvalue_get_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cdouble)::Cdouble +function t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) + @ccall libt8.t8_cmesh_new_hypercube_pad_ext(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, periodic_x::Cint, periodic_y::Cint, periodic_z::Cint, use_axis_aligned::Cint, set_partition::Cint, offset::t8_gloidx_t)::t8_cmesh_t end """ - sc_keyvalue_get_string(kv, key, dvalue) - -Retrieve a string value by its key. This function asserts that the key, if existing, points to the correct type. + t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) -# Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. -# Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -const char *sc_keyvalue_get_string (sc_keyvalue_t * kv, const char *key, const char *dvalue); +t8_cmesh_t t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, int do_partition, int periodic); ``` """ -function sc_keyvalue_get_string(kv, key, dvalue) - @ccall libsc.sc_keyvalue_get_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cstring)::Cstring +function t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) + @ccall libt8.t8_cmesh_new_hypercube_hybrid(comm::MPI_Comm, do_partition::Cint, periodic::Cint)::t8_cmesh_t end """ - sc_keyvalue_get_pointer(kv, key, dvalue) - -Retrieve a pointer value by its key. This function asserts that the key, if existing, points to the correct type. + t8_cmesh_new_periodic(comm, dim) -# Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. -# Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -void *sc_keyvalue_get_pointer (sc_keyvalue_t * kv, const char *key, void *dvalue); +t8_cmesh_t t8_cmesh_new_periodic (sc_MPI_Comm comm, int dim); ``` """ -function sc_keyvalue_get_pointer(kv, key, dvalue) - @ccall libsc.sc_keyvalue_get_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Ptr{Cvoid})::Ptr{Cvoid} +function t8_cmesh_new_periodic(comm, dim) + @ccall libt8.t8_cmesh_new_periodic(comm::MPI_Comm, dim::Cint)::t8_cmesh_t end """ - sc_keyvalue_get_int_check(kv, key, status) - -Query an integer key with error checking. We check whether the key is not found or it is of the wrong type. A default value to be returned on error can be passed in as *status. If status is NULL, then the result on error is undefined. + t8_cmesh_new_periodic_tri(comm) -# Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key string. -* `status`:\\[in,out\\] If not NULL, set to 0 if there is no error, 1 if the key is not found, 2 if a value is found but its type is not integer, and return the input value *status on error. -# Returns -On error we return *status if status is not NULL, and else an undefined value backed by an assertion. Without error, return the result of the lookup. ### Prototype ```c -int sc_keyvalue_get_int_check (sc_keyvalue_t * kv, const char *key, int *status); +t8_cmesh_t t8_cmesh_new_periodic_tri (sc_MPI_Comm comm); ``` """ -function sc_keyvalue_get_int_check(kv, key, status) - @ccall libsc.sc_keyvalue_get_int_check(kv::Ptr{sc_keyvalue_t}, key::Cstring, status::Ptr{Cint})::Cint +function t8_cmesh_new_periodic_tri(comm) + @ccall libt8.t8_cmesh_new_periodic_tri(comm::MPI_Comm)::t8_cmesh_t end """ - sc_keyvalue_set_int(kv, key, newvalue) - -Routine to set an integer value for a given key. + t8_cmesh_new_periodic_hybrid(comm) -# Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type integer. -* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -void sc_keyvalue_set_int (sc_keyvalue_t * kv, const char *key, int newvalue); +t8_cmesh_t t8_cmesh_new_periodic_hybrid (sc_MPI_Comm comm); ``` """ -function sc_keyvalue_set_int(kv, key, newvalue) - @ccall libsc.sc_keyvalue_set_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cint)::Cvoid +function t8_cmesh_new_periodic_hybrid(comm) + @ccall libt8.t8_cmesh_new_periodic_hybrid(comm::MPI_Comm)::t8_cmesh_t end """ - sc_keyvalue_set_double(kv, key, newvalue) - -Routine to set a double value for a given key. + t8_cmesh_new_periodic_line_more_trees(comm) -# Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type double. -* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -void sc_keyvalue_set_double (sc_keyvalue_t * kv, const char *key, double newvalue); +t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm); ``` """ -function sc_keyvalue_set_double(kv, key, newvalue) - @ccall libsc.sc_keyvalue_set_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cdouble)::Cvoid +function t8_cmesh_new_periodic_line_more_trees(comm) + @ccall libt8.t8_cmesh_new_periodic_line_more_trees(comm::MPI_Comm)::t8_cmesh_t end """ - sc_keyvalue_set_string(kv, key, newvalue) - -Routine to set a string value for a given key. + t8_cmesh_new_bigmesh(eclass, num_trees, comm) -# Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type string. -* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -void sc_keyvalue_set_string (sc_keyvalue_t * kv, const char *key, const char *newvalue); +t8_cmesh_t t8_cmesh_new_bigmesh (t8_eclass_t eclass, int num_trees, sc_MPI_Comm comm); ``` """ -function sc_keyvalue_set_string(kv, key, newvalue) - @ccall libsc.sc_keyvalue_set_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cstring)::Cvoid +function t8_cmesh_new_bigmesh(eclass, num_trees, comm) + @ccall libt8.t8_cmesh_new_bigmesh(eclass::t8_eclass_t, num_trees::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - sc_keyvalue_set_pointer(kv, key, newvalue) - -Routine to set a pointer value for a given key. + t8_cmesh_new_line_zigzag(comm) -# Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type pointer. -* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -void sc_keyvalue_set_pointer (sc_keyvalue_t * kv, const char *key, void *newvalue); +t8_cmesh_t t8_cmesh_new_line_zigzag (sc_MPI_Comm comm); ``` """ -function sc_keyvalue_set_pointer(kv, key, newvalue) - @ccall libsc.sc_keyvalue_set_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Ptr{Cvoid})::Cvoid +function t8_cmesh_new_line_zigzag(comm) + @ccall libt8.t8_cmesh_new_line_zigzag(comm::MPI_Comm)::t8_cmesh_t end -# typedef int ( * sc_keyvalue_foreach_t ) ( const char * key , const sc_keyvalue_entry_type_t type , void * entry , const void * u ) """ -Function to call on every key value pair + t8_cmesh_new_prism_cake(comm, num_of_prisms) -# Arguments -* `key`:\\[in\\] The key for this pair -* `type`:\\[in\\] The type of entry -* `entry`:\\[in\\] Pointer to the entry -* `u`:\\[in\\] Arbitrary user data. -# Returns -Return true if the traversal should continue, false to stop. +### Prototype +```c +t8_cmesh_t t8_cmesh_new_prism_cake (sc_MPI_Comm comm, int num_of_prisms); +``` """ -const sc_keyvalue_foreach_t = Ptr{Cvoid} +function t8_cmesh_new_prism_cake(comm, num_of_prisms) + @ccall libt8.t8_cmesh_new_prism_cake(comm::MPI_Comm, num_of_prisms::Cint)::t8_cmesh_t +end """ - sc_keyvalue_foreach(kv, fn, user_data) - -Iterate through all stored key-value pairs. + t8_cmesh_new_prism_deformed(comm) -# Arguments -* `kv`:\\[in\\] Valid key-value container. -* `fn`:\\[in\\] Function to call on each key-value pair. -* `user_data`:\\[in,out\\] This pointer is passed through to **fn**. ### Prototype ```c -void sc_keyvalue_foreach (sc_keyvalue_t * kv, sc_keyvalue_foreach_t fn, void *user_data); +t8_cmesh_t t8_cmesh_new_prism_deformed (sc_MPI_Comm comm); ``` """ -function sc_keyvalue_foreach(kv, fn, user_data) - @ccall libsc.sc_keyvalue_foreach(kv::Ptr{sc_keyvalue_t}, fn::sc_keyvalue_foreach_t, user_data::Ptr{Cvoid})::Cvoid +function t8_cmesh_new_prism_deformed(comm) + @ccall libt8.t8_cmesh_new_prism_deformed(comm::MPI_Comm)::t8_cmesh_t end """ - sc_statinfo - -Store information of one random variable. + t8_cmesh_new_pyramid_deformed(comm) -| Field | Note | -| :--------------- | :--------------------------------------- | -| dirty | Only update stats if this is true. | -| count | Inout; global count is 52 bit accurate. | -| sum\\_values | Inout; global sum of values. | -| sum\\_squares | Inout; global sum of squares. | -| min | Inout; minimum over values. | -| max | Inout; maximum over values. | -| variable | Name of the variable for output. | -| variable\\_owned | NULL or deep copy of variable. | -| group | Grouping identifier. | -| prio | Priority identifier. | +### Prototype +```c +t8_cmesh_t t8_cmesh_new_pyramid_deformed (sc_MPI_Comm comm); +``` """ -struct sc_statinfo - dirty::Cint - count::Clong - sum_values::Cdouble - sum_squares::Cdouble - min::Cdouble - max::Cdouble - min_at_rank::Cint - max_at_rank::Cint - average::Cdouble - variance::Cdouble - standev::Cdouble - variance_mean::Cdouble - standev_mean::Cdouble - variable::Cstring - variable_owned::Cstring - group::Cint - prio::Cint -end - -"""Store information of one random variable.""" -const sc_statinfo_t = sc_statinfo - -struct sc_stats - mpicomm::MPI_Comm - kv::Ptr{sc_keyvalue_t} - sarray::Ptr{sc_array_t} +function t8_cmesh_new_pyramid_deformed(comm) + @ccall libt8.t8_cmesh_new_pyramid_deformed(comm::MPI_Comm)::t8_cmesh_t end -"""The statistics container allows dynamically adding random variables.""" -const sc_statistics_t = sc_stats - """ - sc_stats_set1(stats, value, variable) - -Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. We set sc_stats_group_all and sc_stats_prio_all internally. + t8_cmesh_new_prism_cake_funny_oriented(comm) -# Arguments -* `stats`:\\[out\\] Will be filled with count=1 and the value. -* `value`:\\[in\\] Value used to fill statistics information. -* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. ### Prototype ```c -void sc_stats_set1 (sc_statinfo_t * stats, double value, const char *variable); +t8_cmesh_t t8_cmesh_new_prism_cake_funny_oriented (sc_MPI_Comm comm); ``` """ -function sc_stats_set1(stats, value, variable) - @ccall libsc.sc_stats_set1(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring)::Cvoid +function t8_cmesh_new_prism_cake_funny_oriented(comm) + @ccall libt8.t8_cmesh_new_prism_cake_funny_oriented(comm::MPI_Comm)::t8_cmesh_t end """ - sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) - -Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. + t8_cmesh_new_prism_geometry(comm) -# Arguments -* `stats`:\\[out\\] Will be filled with count=1 and the value. -* `value`:\\[in\\] Value used to fill statistics information. -* `variable`:\\[in\\] String to be reported by sc_stats_print. -* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. -* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. -* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. ### Prototype ```c -void sc_stats_set1_ext (sc_statinfo_t * stats, double value, const char *variable, int copy_variable, int stats_group, int stats_prio); +t8_cmesh_t t8_cmesh_new_prism_geometry (sc_MPI_Comm comm); ``` """ -function sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) - @ccall libsc.sc_stats_set1_ext(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid +function t8_cmesh_new_prism_geometry(comm) + @ccall libt8.t8_cmesh_new_prism_geometry(comm::MPI_Comm)::t8_cmesh_t end """ - sc_stats_init(stats, variable) - -Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. We set sc_stats_group_all and sc_stats_prio_all internally. + t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) -# Arguments -* `stats`:\\[out\\] Will be filled with count 0 and values of 0. -* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. ### Prototype ```c -void sc_stats_init (sc_statinfo_t * stats, const char *variable); +t8_cmesh_t t8_cmesh_new_brick_2d (t8_gloidx_t num_x, t8_gloidx_t num_y, int x_periodic, int y_periodic, sc_MPI_Comm comm); ``` """ -function sc_stats_init(stats, variable) - @ccall libsc.sc_stats_init(stats::Ptr{sc_statinfo_t}, variable::Cstring)::Cvoid +function t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) + @ccall libt8.t8_cmesh_new_brick_2d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t end -""" - sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) - -Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. +""" + t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) -# Arguments -* `stats`:\\[out\\] Will be filled with count 0 and values of 0. -* `variable`:\\[in\\] String to be reported by sc_stats_print. -* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. -* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. -* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. ### Prototype ```c -void sc_stats_init_ext (sc_statinfo_t * stats, const char *variable, int copy_variable, int stats_group, int stats_prio); +t8_cmesh_t t8_cmesh_new_brick_3d (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); ``` """ -function sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) - @ccall libsc.sc_stats_init_ext(stats::Ptr{sc_statinfo_t}, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid +function t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + @ccall libt8.t8_cmesh_new_brick_3d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - sc_stats_reset(stats, reset_vgp) - -Reset all values to zero, optionally unassign name, group, and priority. + t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) -# Arguments -* `stats`:\\[in,out\\] Variables are zeroed. They can be set again by set1 or accumulate. -* `reset_vgp`:\\[in\\] If true, the variable name string is zeroed and if we did a copy, the copy is freed. If true, group and priority are set to all. If false, we don't touch any of the above. ### Prototype ```c -void sc_stats_reset (sc_statinfo_t * stats, int reset_vgp); +t8_cmesh_t t8_cmesh_new_disjoint_bricks (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); ``` """ -function sc_stats_reset(stats, reset_vgp) - @ccall libsc.sc_stats_reset(stats::Ptr{sc_statinfo_t}, reset_vgp::Cint)::Cvoid +function t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + @ccall libt8.t8_cmesh_new_disjoint_bricks(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - sc_stats_set_group_prio(stats, stats_group, stats_prio) - -Set/update the group and priority information for a stats item. + t8_cmesh_new_tet_orientation_test(comm) -# Arguments -* `stats`:\\[out\\] Only group and stats entries are updated. -* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. -* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. ### Prototype ```c -void sc_stats_set_group_prio (sc_statinfo_t * stats, int stats_group, int stats_prio); +t8_cmesh_t t8_cmesh_new_tet_orientation_test (sc_MPI_Comm comm); ``` """ -function sc_stats_set_group_prio(stats, stats_group, stats_prio) - @ccall libsc.sc_stats_set_group_prio(stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint)::Cvoid +function t8_cmesh_new_tet_orientation_test(comm) + @ccall libt8.t8_cmesh_new_tet_orientation_test(comm::MPI_Comm)::t8_cmesh_t end """ - sc_stats_accumulate(stats, value) - -Add an instance of the random variable. The counter of the variable is increased by one. The value is added into the present values of the variable. + t8_cmesh_new_hybrid_gate(comm) -# Arguments -* `stats`:\\[out\\] Must be dirty. We bump count and values. -* `value`:\\[in\\] Value used to update statistics information. ### Prototype ```c -void sc_stats_accumulate (sc_statinfo_t * stats, double value); +t8_cmesh_t t8_cmesh_new_hybrid_gate (sc_MPI_Comm comm); ``` """ -function sc_stats_accumulate(stats, value) - @ccall libsc.sc_stats_accumulate(stats::Ptr{sc_statinfo_t}, value::Cdouble)::Cvoid +function t8_cmesh_new_hybrid_gate(comm) + @ccall libt8.t8_cmesh_new_hybrid_gate(comm::MPI_Comm)::t8_cmesh_t end """ - sc_stats_compute(mpicomm, nvars, stats) + t8_cmesh_new_hybrid_gate_deformed(comm) ### Prototype ```c -void sc_stats_compute (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); +t8_cmesh_t t8_cmesh_new_hybrid_gate_deformed (sc_MPI_Comm comm); ``` """ -function sc_stats_compute(mpicomm, nvars, stats) - @ccall libsc.sc_stats_compute(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid +function t8_cmesh_new_hybrid_gate_deformed(comm) + @ccall libt8.t8_cmesh_new_hybrid_gate_deformed(comm::MPI_Comm)::t8_cmesh_t end """ - sc_stats_compute1(mpicomm, nvars, stats) + t8_cmesh_new_full_hybrid(comm) ### Prototype ```c -void sc_stats_compute1 (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); +t8_cmesh_t t8_cmesh_new_full_hybrid (sc_MPI_Comm comm); ``` """ -function sc_stats_compute1(mpicomm, nvars, stats) - @ccall libsc.sc_stats_compute1(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid +function t8_cmesh_new_full_hybrid(comm) + @ccall libt8.t8_cmesh_new_full_hybrid(comm::MPI_Comm)::t8_cmesh_t end """ - sc_stats_print(package_id, log_priority, nvars, stats, full, summary) - -Print measured statistics. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. All groups and priorities are printed. + t8_cmesh_new_pyramid_cake(comm, num_of_pyra) -# Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Log priority for output according to sc.h. -* `nvars`:\\[in\\] Number of stats items in input array. -* `stats`:\\[in\\] Input array of stats variable items. -* `full`:\\[in\\] Print full information for every variable. -* `summary`:\\[in\\] Print summary information all on 1 line. ### Prototype ```c -void sc_stats_print (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int full, int summary); +t8_cmesh_t t8_cmesh_new_pyramid_cake (sc_MPI_Comm comm, int num_of_pyra); ``` """ -function sc_stats_print(package_id, log_priority, nvars, stats, full, summary) - @ccall libsc.sc_stats_print(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, full::Cint, summary::Cint)::Cvoid +function t8_cmesh_new_pyramid_cake(comm, num_of_pyra) + @ccall libt8.t8_cmesh_new_pyramid_cake(comm::MPI_Comm, num_of_pyra::Cint)::t8_cmesh_t end """ - sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) - -Print measured statistics, filter by group and/or priority. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. + t8_cmesh_new_long_brick_pyramid(comm, num_cubes) -# Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Log priority for output according to sc.h. -* `nvars`:\\[in\\] Number of stats items in input array. -* `stats`:\\[in\\] Input array of stats variable items. -* `stats_group`:\\[in\\] Print only this group. Non-negative or sc_stats_group_all. We skip printing a variable if neither this parameter nor the item's group is all and if the item's group does not match this. -* `stats_prio`:\\[in\\] Print this and higher priorities. Non-negative or sc_stats_prio_all. We skip printing a variable if neither this parameter nor the item's prio is all and if the item's prio is less than this. -* `full`:\\[in\\] Print full information for every variable. This produces multiple lines including minimum, maximum, and standard deviation. If this is false, print one line per variable. -* `summary`:\\[in\\] Print summary information all on 1 line. This always contains all variables. Not affected by stats\\_group and stats\\_prio. ### Prototype ```c -void sc_stats_print_ext (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int stats_group, int stats_prio, int full, int summary); +t8_cmesh_t t8_cmesh_new_long_brick_pyramid (sc_MPI_Comm comm, int num_cubes); ``` """ -function sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) - @ccall libsc.sc_stats_print_ext(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint, full::Cint, summary::Cint)::Cvoid +function t8_cmesh_new_long_brick_pyramid(comm, num_cubes) + @ccall libt8.t8_cmesh_new_long_brick_pyramid(comm::MPI_Comm, num_cubes::Cint)::t8_cmesh_t end """ - sc_statistics_new(mpicomm) + t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm) ### Prototype ```c -sc_statistics_t *sc_statistics_new (sc_MPI_Comm mpicomm); +t8_cmesh_t t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, const int do_partition, sc_MPI_Comm comm); ``` """ -function sc_statistics_new(mpicomm) - @ccall libsc.sc_statistics_new(mpicomm::MPI_Comm)::Ptr{sc_statistics_t} +function t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm) + @ccall libt8.t8_cmesh_new_row_of_cubes(num_trees::t8_locidx_t, set_attributes::Cint, do_partition::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - sc_statistics_destroy(stats) - -Destroy a statistics structure. + t8_cmesh_new_quadrangulated_disk(radius, comm) -# Arguments -* `stats`:\\[in,out\\] Valid object is invalidated. ### Prototype ```c -void sc_statistics_destroy (sc_statistics_t * stats); +t8_cmesh_t t8_cmesh_new_quadrangulated_disk (const double radius, sc_MPI_Comm comm); ``` """ -function sc_statistics_destroy(stats) - @ccall libsc.sc_statistics_destroy(stats::Ptr{sc_statistics_t})::Cvoid +function t8_cmesh_new_quadrangulated_disk(radius, comm) + @ccall libt8.t8_cmesh_new_quadrangulated_disk(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - sc_statistics_add(stats, name) - -Register a statistics variable by name and set its value to 0. This variable must not exist already. + t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) ### Prototype ```c -void sc_statistics_add (sc_statistics_t * stats, const char *name); +t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_MPI_Comm comm); ``` """ -function sc_statistics_add(stats, name) - @ccall libsc.sc_statistics_add(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid +function t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) + @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_octahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - sc_statistics_add_empty(stats, name) - -Register a statistics variable by name and set its count to 0. This variable must not exist already. + t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) ### Prototype ```c -void sc_statistics_add_empty (sc_statistics_t * stats, const char *name); +t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc_MPI_Comm comm); ``` """ -function sc_statistics_add_empty(stats, name) - @ccall libsc.sc_statistics_add_empty(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid +function t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) + @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - sc_statistics_has(stats, name) - -Returns true if the stats include a variable with the given name + t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) ### Prototype ```c -int sc_statistics_has (sc_statistics_t * stats, const char *name); +t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Comm comm); ``` """ -function sc_statistics_has(stats, name) - @ccall libsc.sc_statistics_has(stats::Ptr{sc_statistics_t}, name::Cstring)::Cint +function t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) + @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_cube(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - sc_statistics_set(stats, name, value) - -Set the value of a statistics variable, see [`sc_stats_set1`](@ref). The variable must previously be added with [`sc_statistics_add`](@ref). This assumes count=1 as in the [`sc_stats_set1`](@ref) function above. + t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) ### Prototype ```c -void sc_statistics_set (sc_statistics_t * stats, const char *name, double value); +t8_cmesh_t t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm); ``` """ -function sc_statistics_set(stats, name, value) - @ccall libsc.sc_statistics_set(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid +function t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) + @ccall libt8.t8_cmesh_new_quadrangulated_spherical_surface(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - sc_statistics_accumulate(stats, name, value) - -Add an instance of a statistics variable, see [`sc_stats_accumulate`](@ref) The variable must previously be added with [`sc_statistics_add_empty`](@ref). + t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) ### Prototype ```c -void sc_statistics_accumulate (sc_statistics_t * stats, const char *name, double value); +t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_octahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); ``` """ -function sc_statistics_accumulate(stats, name, value) - @ccall libsc.sc_statistics_accumulate(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid +function t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + @ccall libt8.t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - sc_statistics_compute(stats) - -Compute statistics for all variables, see [`sc_stats_compute`](@ref). + t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) ### Prototype ```c -void sc_statistics_compute (sc_statistics_t * stats); +t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_icosahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); ``` """ -function sc_statistics_compute(stats) - @ccall libsc.sc_statistics_compute(stats::Ptr{sc_statistics_t})::Cvoid +function t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + @ccall libt8.t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - sc_statistics_print(stats, package_id, log_priority, full, summary) - -Print all statistics variables, see [`sc_stats_print`](@ref). + t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) ### Prototype ```c -void sc_statistics_print (sc_statistics_t * stats, int package_id, int log_priority, int full, int summary); +t8_cmesh_t t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_trees, const int num_layers, sc_MPI_Comm comm); ``` """ -function sc_statistics_print(stats, package_id, log_priority, full, summary) - @ccall libsc.sc_statistics_print(stats::Ptr{sc_statistics_t}, package_id::Cint, log_priority::Cint, full::Cint, summary::Cint)::Cvoid +function t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) + @ccall libt8.t8_cmesh_new_cubed_spherical_shell(inner_radius::Cdouble, shell_thickness::Cdouble, num_trees::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - t8_forest + t8_cmesh_new_cubed_sphere(radius, comm) -| Field | Note | -| :----------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| rc | Reference counter. | -| set\\_partition\\_offset | Flag indicating whether the partition range was set manually. | -| set\\_first\\_global\\_element | If set\\_partition\\_offset is true, the global ID of the first local element after partitioning. | -| set\\_level | Level to use in new construction. | -| set\\_for\\_coarsening | Change partition to allow for one round of coarsening | -| weight\\_function | Pointer to user defined element weight function. Nullptr for standard, element-based partitioning. | -| cmesh | Coarse mesh to use. | -| scheme | Scheme for element types. | -| maxlevel | The maximum allowed refinement level for elements in this forest. | -| maxlevel\\_existing | If >= 0, the maximum occurring refinement level of a forest element. | -| do\\_dup | Communicator shall be duped. | -| dimension | Dimension inferred from **cmesh**. | -| incomplete\\_trees | Flag to check whether the forest has (potential) incomplete trees. A tree is incomplete if an element has been removed from it. Once an element got removed, the flag sets to 1 (true) and stays. For a committed forest this flag is either true on all ranks or false on all ranks. | -| set\\_from | Temporarily store source forest. | -| from\\_method | Method to derive from **set_from**. | -| set\\_adapt\\_fn | refinement and coarsen function. Called when **from_method** is set to [`T8_FOREST_FROM_ADAPT`](@ref). | -| set\\_adapt\\_recursive | Flag to decide whether coarsen and refine are carried out recursive | -| set\\_balance | Flag to decide whether to forest will be balance in t8_forest_commit. See t8_forest_set_balance. If 0, no balance. If 1 balance with repartitioning, if 2 balance without repartitioning, # See also t8\\_forest\\_balance | -| do\\_ghost | If True, a ghost layer will be created when the forest is committed. | -| ghost\\_type | If a ghost layer will be created, the type of neighbors that count as ghost. | -| ghost\\_algorithm | Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced 3 = top-down search and unbalanced. | -| user\\_data | Pointer for arbitrary user data. # See also [`t8_forest_set_user_data`](@ref). | -| user\\_function | Pointer for arbitrary user function. # See also [`t8_forest_set_user_function`](@ref). | -| t8code\\_data | Pointer for arbitrary data that is used internally. | -| committed | t8_forest_commit called? | -| mpisize | Number of MPI processes. | -| mpirank | Number of this MPI process. | -| first\\_local\\_tree | The global index of the first local tree on this process. If first\\_local\\_tree is larger than last\\_local\\_tree then this processor/forest is empty. See https://github.com/DLR-AMR/t8code/wiki/Tree-indexing | -| last\\_local\\_tree | The global index of the last local tree on this process. -1 if this processor is empty. | -| global\\_num\\_trees | The total number of global trees. | -| trees | The array of trees. | -| ghosts | If not NULL, the ghost elements. # See also [`t8_forest_ghost`](@ref).h | -| element\\_offsets | If partitioned, for each process the global index of its first element. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | -| global\\_first\\_desc | If partitioned, for each process the linear id (at maxlevel) of its first element's first descendant. t8_element_set_linear_id. Stores 0 for empty processes. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | -| tree\\_offsets | If partitioned for each process the global index of its first local tree or -(first local tree) - 1 if the first tree on that process is shared. Since this is memory consuming we only construct it when needed. This array follows the same logic as *tree_offsets* in [`t8_cmesh_t`](@ref) | -| local\\_num\\_leaf\\_elements | Number of leaf elements on this processor. | -| global\\_num\\_leaf\\_elements | Number of leaf elements on all processors. | -| profile | If not NULL, runtimes and statistics about forest\\_commit are stored here. | -| stats | The SC profiling stats of the forest. | -| stats\\_computed | Switch indicating whether the profiling stats have been compute (1) or not (0) | +### Prototype +```c +t8_cmesh_t t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm); +``` """ -# This struct is not supposed to be read and modified directly. -# Besides, there is a circular dependency with `t8_forest_t` -# leading to an error output by Julia. -mutable struct t8_forest end - -"""Opaque pointer to a forest implementation.""" -const t8_forest_t = Ptr{t8_forest} +function t8_cmesh_new_cubed_sphere(radius, comm) + @ccall libt8.t8_cmesh_new_cubed_sphere(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +end """ - t8_forest_adapt(forest) + t8_cmesh_get_tree_geom_hash(cmesh, gtreeid) -Adapt a forest. +Get the hash of the geometry stored for a tree in a cmesh. # Arguments -* `forest`:\\[in,out\\] The forest to be adapted +* `cmesh`:\\[in\\] A committed cmesh. +* `gtreeid`:\\[in\\] A global tree in *cmesh*. +# Returns +The hash of the tree's geometry or if only one geometry exists, its hash. ### Prototype ```c -void t8_forest_adapt (t8_forest_t forest); +size_t t8_cmesh_get_tree_geom_hash (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); ``` """ -function t8_forest_adapt(forest) - @ccall libt8.t8_forest_adapt(forest::t8_forest_t)::Cvoid +function t8_cmesh_get_tree_geom_hash(cmesh, gtreeid) + @ccall libt8.t8_cmesh_get_tree_geom_hash(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Csize_t end """ - t8_tree + t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) -The t8 tree datatype +Sets the face connectivity information of an un-committed based on a list of tree vertices. -| Field | Note | -| :---------------- | :----------------------------------------------------------------- | -| leaf\\_elements | locally stored leaf elements | -| eclass | The element class of this tree | -| first\\_desc | first local descendant | -| last\\_desc | last local descendant | -| elements\\_offset | cumulative sum over earlier trees on this processor (locals only) | -""" -struct t8_tree - leaf_elements::t8_element_array_t - eclass::t8_eclass_t - first_desc::Ptr{t8_element_t} - last_desc::Ptr{t8_element_t} - elements_offset::t8_locidx_t -end +!!! warning -"""Opaque pointer to a tree implementation.""" -const t8_tree_t = Ptr{t8_tree} + This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. -""" - t8_ghost_type_t +!!! note -This type controls, which neighbors count as ghost elements. Currently, we support face-neighbors. Vertex and edge neighbors will eventually be added. + This routine does not detect periodic boundaries. -| Enumerator | Note | -| :-------------------- | :---------------------------------------------------------------- | -| T8\\_GHOST\\_NONE | Do not create ghost layer. | -| T8\\_GHOST\\_FACES | Consider all face (codimension 1) neighbors. | -| T8\\_GHOST\\_EDGES | Consider all edge (codimension 2) and face neighbors. | -| T8\\_GHOST\\_VERTICES | Consider all vertex (codimension 3) and edge and face neighbors. | +# Arguments +* `cmesh`:\\[in,out\\] Pointer to a t8code cmesh object. If set to NULL this argument is ignored. +* `ntrees`:\\[in\\] Number of coarse mesh elements resp. trees. +* `vertices`:\\[in\\] List of per element vertices with dimensions [ntrees,[`T8_ECLASS_MAX_CORNERS`](@ref),[`T8_ECLASS_MAX_DIM`](@ref)]. +* `eclasses`:\\[in\\] List of element classes of length [ntrees]. +* `connectivity`:\\[in,out\\] If connectivity is not NULL the variable is filled with a pointer to an allocated face connectivity array. The ownership of this array goes to the caller. This argument is mainly used for debugging and testing purposes. The dimension of *connectivity* are [ntrees,[`T8_ECLASS_MAX_FACES`](@ref),3]. For each element and each face the following is stored: neighbor\\_tree\\_id, neighbor\\_dual\\_face\\_id, orientation +* `do_both_directions`:\\[in\\] Compute the connectivity from both neighboring sides. Takes much longer to compute. +### Prototype +```c +void t8_cmesh_set_join_by_vertices (t8_cmesh_t cmesh, const t8_gloidx_t ntrees, const t8_eclass_t *eclasses, const double *vertices, int **connectivity, const int do_both_directions); +``` """ -@cenum t8_ghost_type_t::UInt32 begin - T8_GHOST_NONE = 0 - T8_GHOST_FACES = 1 - T8_GHOST_EDGES = 2 - T8_GHOST_VERTICES = 3 +function t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) + @ccall libt8.t8_cmesh_set_join_by_vertices(cmesh::t8_cmesh_t, ntrees::t8_gloidx_t, eclasses::Ptr{t8_eclass_t}, vertices::Ptr{Cdouble}, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid end -# typedef void ( * t8_generic_function_pointer ) ( void ) """ -This typedef is needed as a helper construct to properly be able to define a function that returns a pointer to a void fun(void) function. + t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) -# See also -[`t8_forest_get_user_function`](@ref). -""" -const t8_generic_function_pointer = Ptr{Cvoid} +Sets the face connectivity information of an un-committed based on the cmesh stash. -# typedef double ( t8_weight_fcn_t ) ( t8_forest_t , t8_locidx_t , t8_locidx_t ) -"""The prototype of a weight function for the partition algorithm. The function should be pure, and return a positive weight given a forest, a local tree index and an element index within the local tree""" -const t8_weight_fcn_t = Cvoid +!!! warning -# typedef void ( * t8_forest_replace_t ) ( t8_forest_t forest_old , t8_forest_t forest_new , t8_locidx_t which_tree , const t8_eclass_t tree_class , const t8_scheme_c * scheme , const int refine , const int num_outgoing , const t8_locidx_t first_outgoing , const int num_incoming , const t8_locidx_t first_incoming ) -""" -Callback function prototype to replace one set of elements with another. + This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. -This is used by the replace routine which can be called after adapt, when the elements of an existing, valid forest are changed. The callback allows the user to make changes to the elements of the new forest that are either refined, coarsened or the same as elements in the old forest. +!!! note -If an element is being refined, *refine* and *num_outgoing* will be 1 and *num_incoming* will be the number of children. If a family is being coarsened, *refine* will be -1, *num_outgoing* will be the number of family members and *num_incoming* will be 1. If an element is being removed, *refine* and *num_outgoing* will be 1 and *num_incoming* will be 0. Else *refine* will be 0 and *num_outgoing* and *num_incoming* will both be 1. + This routine does not detect periodic boundaries. # Arguments -* `forest_old`:\\[in\\] The forest that is adapted -* `forest_new`:\\[in,out\\] The forest that is newly constructed from *forest_old* -* `which_tree`:\\[in\\] The local tree containing *first_outgoing* and *first_incoming* -* `tree_class`:\\[in\\] The eclass of the local tree containing *first_outgoing* and *first_incoming* -* `scheme`:\\[in\\] The scheme of the forest -* `refine`:\\[in\\] -1 if family in *forest_old* got coarsened, 0 if element has not been touched, 1 if element got refined and -2 if element got removed. See return of [`t8_forest_adapt_t`](@ref). -* `num_outgoing`:\\[in\\] The number of outgoing elements. -* `first_outgoing`:\\[in\\] The tree local index of the first outgoing element. 0 <= first\\_outgoing < which\\_tree->num\\_elements -* `num_incoming`:\\[in\\] The number of incoming elements. -* `first_incoming`:\\[in\\] The tree local index of the first incoming element. 0 <= first\\_incom < new\\_which\\_tree->num\\_elements -# See also -[`t8_forest_iterate_replace`](@ref) +* `cmesh`:\\[in,out\\] An uncommitted cmesh. The trees eclasses and vertices do need to be set. +* `connectivity`:\\[in,out\\] If connectivity is not NULL the variable is filled with a pointer to an allocated face connectivity array. The ownership of this array goes to the caller. This argument is mainly used for debugging and testing purposes. The dimension of *connectivity* are [ntrees,[`T8_ECLASS_MAX_FACES`](@ref),3]. For each element and each face the following is stored: neighbor\\_tree\\_id, neighbor\\_dual\\_face\\_id, orientation +* `do_both_directions`:\\[in\\] Compute the connectivity from both neighboring sides. Takes much longer to compute. +### Prototype +```c +void t8_cmesh_set_join_by_stash (t8_cmesh_t cmesh, int **connectivity, const int do_both_directions); +``` """ -const t8_forest_replace_t = Ptr{Cvoid} +function t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) + @ccall libt8.t8_cmesh_set_join_by_stash(cmesh::t8_cmesh_t, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid +end -# typedef int ( * t8_forest_adapt_t ) ( t8_forest_t forest , t8_forest_t forest_from , t8_locidx_t which_tree , const t8_eclass_t tree_class , t8_locidx_t lelement_id , const t8_scheme_c * scheme , const int is_family , const int num_elements , t8_element_t * elements [ ] ) """ -Callback function prototype to decide for refining and coarsening. If *is_family* equals 1, the first *num_elements* in *elements* form a family and we decide whether this family should be coarsened or only the first element should be refined. Otherwise *is_family* must equal zero and we consider the first entry of the element array for refinement. Entries of the element array beyond the first *num_elements* are undefined. + t8_offset_first(proc, offset) + +Return the global id of the first local tree of a given process in a partition. # Arguments -* `forest`:\\[in\\] The forest to which the new elements belong. -* `forest_from`:\\[in\\] The forest that is adapted. -* `which_tree`:\\[in\\] The local tree containing *elements*. -* `tree_class`:\\[in\\] The eclass of *which_tree*. -* `lelement_id`:\\[in\\] The local element id in *forest_from* in the tree of the current element. -* `scheme`:\\[in\\] The scheme of the forest. -* `is_family`:\\[in\\] If 1, the first *num_elements* entries in *elements* form a family. If 0, they do not. -* `num_elements`:\\[in\\] The number of entries in *elements* that are defined -* `elements`:\\[in\\] Pointers to a family or, if *is_family* is zero, pointer to one element. +* `proc`:\\[in\\] The rank of the process. +* `offset`:\\[in\\] The partition table. # Returns -1 if the first entry in *elements* should be refined, -1 if the family *elements* shall be coarsened, -2 if the first entry in *elements* should be removed, 0 else. +The global id of the first local tree of *proc* in the partition *offset*. +### Prototype +```c +t8_gloidx_t t8_offset_first (const int proc, const t8_gloidx_t *offset); +``` """ -const t8_forest_adapt_t = Ptr{Cvoid} +function t8_offset_first(proc, offset) + @ccall libt8.t8_offset_first(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t +end """ - t8_forest_init(pforest) + t8_offset_first_tree_to_entry(first_tree, shared) -Create a new forest with reference count one. This forest needs to be specialized with the t8\\_forest\\_set\\_* calls. Currently it is mandatory to either call the functions +Given the global tree id of the first local tree of a process and the flag whether it is shared or not, compute the entry in the offset array. This entry is the first\\_tree if it is not shared and -first\\_tree - 1 if it is shared. # Arguments -* `pforest`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new forest. -# See also -t8\\_forest\\_set\\_mpicomm, t8_forest_set_cmesh, and t8_forest_set_scheme, or to call one of t8_forest_set_copy, t8_forest_set_adapt, or t8_forest_set_partition. It is illegal to mix these calls, or to call more than one of the three latter functions Then it needs to be set up with t8_forest_commit. - +* `first_tree`:\\[in\\] The global tree id of a process's first tree. +* `shared`:\\[in\\] 0 if *first_tree* is not shared with a smaller rank, 1 if it is. +# Returns +The entry that represents the process in an offset array. *first_tree* if *shared* == 0 - *first_tree* - 1 if *shared* != 0 ### Prototype ```c -void t8_forest_init (t8_forest_t *pforest); +t8_gloidx_t t8_offset_first_tree_to_entry (const t8_gloidx_t first_tree, const int shared); ``` """ -function t8_forest_init(pforest) - @ccall libt8.t8_forest_init(pforest::Ptr{t8_forest_t})::Cvoid +function t8_offset_first_tree_to_entry(first_tree, shared) + @ccall libt8.t8_offset_first_tree_to_entry(first_tree::t8_gloidx_t, shared::Cint)::t8_gloidx_t end """ - t8_forest_is_initialized(forest) + t8_offset_num_trees(proc, offset) -Check whether a forest is not NULL, initialized and not committed. In addition, it asserts that the forest is consistent as much as possible. +The number of trees of a given process in a partition. # Arguments -* `forest`:\\[in\\] This forest is examined. May be NULL. +* `proc`:\\[in\\] A mpi rank. +* `offset`:\\[in\\] A partition table. # Returns -True if forest is not NULL, t8_forest_init has been called on it, but not t8_forest_commit. False otherwise. +The number of local trees of *proc* in the partition *offset*. ### Prototype ```c -int t8_forest_is_initialized (t8_forest_t forest); +t8_gloidx_t t8_offset_num_trees (const int proc, const t8_gloidx_t *offset); ``` """ -function t8_forest_is_initialized(forest) - @ccall libt8.t8_forest_is_initialized(forest::t8_forest_t)::Cint +function t8_offset_num_trees(proc, offset) + @ccall libt8.t8_offset_num_trees(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t end """ - t8_forest_is_committed(forest) + t8_offset_last(proc, offset) -Check whether a forest is not NULL, initialized and committed. In addition, it asserts that the forest is consistent as much as possible. +Return the last local tree of a given process in a partition. # Arguments -* `forest`:\\[in\\] This forest is examined. May be NULL. +* `proc`:\\[in\\] A mpi rank. +* `offset`:\\[in\\] A partition table. # Returns -True if forest is not NULL and t8_forest_init has been called on it as well as t8_forest_commit. False otherwise. +The global tree id of the last local tree of *proc* in *offset*. ### Prototype ```c -int t8_forest_is_committed (t8_forest_t forest); +t8_gloidx_t t8_offset_last (const int proc, const t8_gloidx_t *offset); ``` """ -function t8_forest_is_committed(forest) - @ccall libt8.t8_forest_is_committed(forest::t8_forest_t)::Cint +function t8_offset_last(proc, offset) + @ccall libt8.t8_offset_last(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t end """ - t8_forest_no_overlap(forest) - -Check whether the forest has local overlapping elements. - -!!! note + t8_offset_empty(proc, offset) - This function is collective, but only checks local overlapping on each process. +Check whether a given process has no local trees in a given partition. # Arguments -* `forest`:\\[in\\] The forest to consider. +* `proc`:\\[in\\] A mpi rank. +* `offset`:\\[in\\] A partition table. # Returns -True if *forest* has no elements which are inside each other. -# See also -[`t8_forest_partition_test_boundary_element`](@ref) if you also want to test for global overlap across the process boundaries. - +nonzero if *proc* does not have local trees in *offset*. 0 otherwise. ### Prototype ```c -int t8_forest_no_overlap (t8_forest_t forest); +int t8_offset_empty (const int proc, const t8_gloidx_t *offset); ``` """ -function t8_forest_no_overlap(forest) - @ccall libt8.t8_forest_no_overlap(forest::t8_forest_t)::Cint +function t8_offset_empty(proc, offset) + @ccall libt8.t8_offset_empty(proc::Cint, offset::Ptr{t8_gloidx_t})::Cint end """ - t8_forest_is_equal(forest_a, forest_b) - -Check whether two committed forests have the same local elements. - -!!! note + t8_offset_next_nonempty_rank(rank, mpisize, offset) - This function is not collective. It only returns the state on the current rank. +Find the next higher rank that is not empty. returns mpisize if this rank does not exist. # Arguments -* `forest_a`:\\[in\\] The first forest. -* `forest_b`:\\[in\\] The second forest. +* `proc`:\\[in\\] An MPI rank. +* `mpisize`:\\[in\\] The number of total MPI ranks. +* `offset`:\\[in\\] An array with at least *mpisize* + 1 entries. # Returns -True if *forest_a* and *forest_b* do have the same number of local trees and each local tree has the same elements, that is t8_element_is_equal returns true for each pair of elements of *forest_a* and *forest_b*. +A rank *p* such that *p* > *rank* and [`t8_offset_empty`](@ref) (*p*, *offset*) is True and [`t8_offset_empty`](@ref) (*q*, *offset*) is False for all *rank* < *q* < *p*. If no such *q* exists, *mpisize* is returned. ### Prototype ```c -int t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b); +int t8_offset_next_nonempty_rank (const int rank, const int mpisize, const t8_gloidx_t *offset); ``` """ -function t8_forest_is_equal(forest_a, forest_b) - @ccall libt8.t8_forest_is_equal(forest_a::t8_forest_t, forest_b::t8_forest_t)::Cint +function t8_offset_next_nonempty_rank(rank, mpisize, offset) + @ccall libt8.t8_offset_next_nonempty_rank(rank::Cint, mpisize::Cint, offset::Ptr{t8_gloidx_t})::Cint end """ - t8_forest_set_cmesh(forest, cmesh, comm) + t8_offset_in_range(tree_id, proc, offset) + +Determine whether a given global tree id is a local tree of a given process in a certain partition. +# Arguments +* `tree_id`:\\[in\\] A global tree id. +* `proc`:\\[in\\] A mpi rank. +* `offset`:\\[in\\] A partition table. +# Returns +nonzero if *tree_id* is a local tree of *proc* in *offset*. 0 if it is not. ### Prototype ```c -void t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); +int t8_offset_in_range (const t8_gloidx_t tree_id, const int proc, const t8_gloidx_t *offset); ``` """ -function t8_forest_set_cmesh(forest, cmesh, comm) - @ccall libt8.t8_forest_set_cmesh(forest::t8_forest_t, cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_offset_in_range(tree_id, proc, offset) + @ccall libt8.t8_offset_in_range(tree_id::t8_gloidx_t, proc::Cint, offset::Ptr{t8_gloidx_t})::Cint end """ - t8_forest_set_scheme(forest, scheme) + t8_offset_any_owner_of_tree(mpisize, gtree, offset) -Set the element scheme associated to a forest. By default, the forest takes ownership of the scheme such that it will be destroyed when the forest is destroyed. To keep ownership of the scheme, call t8_scheme_ref before passing it to t8_forest_set_scheme. This means that it is ILLEGAL to continue using scheme or dereferencing it UNLESS it is referenced directly before passing it into this function. +Find any process that has a given tree as local tree. # Arguments -* `forest`:\\[in,out\\] The forest whose scheme variable will be set. -* `scheme`:\\[in\\] The scheme to be set. We take ownership. This can be prevented by referencing **scheme**. +* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. +* `gtree`:\\[in\\] The global id of a tree. +* `offset`:\\[in\\] The partition to be considered. +# Returns +An MPI rank that has *gtree* as a local tree. ### Prototype ```c -void t8_forest_set_scheme (t8_forest_t forest, const t8_scheme_c *scheme); +int t8_offset_any_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset); ``` """ -function t8_forest_set_scheme(forest, scheme) - @ccall libt8.t8_forest_set_scheme(forest::t8_forest_t, scheme::Ptr{t8_scheme_c})::Cvoid +function t8_offset_any_owner_of_tree(mpisize, gtree, offset) + @ccall libt8.t8_offset_any_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t})::Cint end """ - t8_forest_set_level(forest, level) - -Set the initial refinement level to be used when **forest** is committed. - -!!! note + t8_offset_any_owner_of_tree_ext(mpisize, start_proc, gtree, offset) - This setting cannot be combined with any of the derived forest methods (t8_forest_set_copy, t8_forest_set_adapt, t8_forest_set_partition, and t8_forest_set_balance) and overwrites any of these settings. If this function is used, then the forest is created from scratch as a uniform refinement of the specified cmesh (t8_forest_set_cmesh, t8_forest_set_scheme). +Find any process that has a given tree as local tree. # Arguments -* `forest`:\\[in,out\\] The forest whose level will be set. -* `level`:\\[in\\] The initial refinement level of **forest**, when it is committed. +* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. +* `start_proc`:\\[in\\] The mpirank to start the search with. +* `gtree`:\\[in\\] The global id of a tree. +* `offset`:\\[in\\] The partition to be considered. +# Returns +An MPI rank that has *gtree* as a local tree. ### Prototype ```c -void t8_forest_set_level (t8_forest_t forest, int level); +int t8_offset_any_owner_of_tree_ext (const int mpisize, const int start_proc, const t8_gloidx_t gtree, const t8_gloidx_t *offset); ``` """ -function t8_forest_set_level(forest, level) - @ccall libt8.t8_forest_set_level(forest::t8_forest_t, level::Cint)::Cvoid +function t8_offset_any_owner_of_tree_ext(mpisize, start_proc, gtree, offset) + @ccall libt8.t8_offset_any_owner_of_tree_ext(mpisize::Cint, start_proc::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t})::Cint end """ - t8_forest_set_copy(forest, from) + t8_offset_first_owner_of_tree(mpisize, gtree, offset, some_owner) -Set a forest as source for copying on committing. By default, the forest takes ownership of the source **from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **from** or dereferencing it UNLESS it is referenced directly before passing it into this function. - -!!! note - - This setting cannot be combined with t8_forest_set_adapt, t8_forest_set_partition, or t8_forest_set_balance and overwrites these settings. +Find the smallest process that has a given tree as local tree. To increase the runtime, an arbitrary process having this tree as local tree can be passed as an argument. Otherwise, such an owner is computed during the call. # Arguments -* `forest`:\\[in,out\\] The forest. -* `from`:\\[in\\] A second forest from which *forest* will be copied in t8_forest_commit. +* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. +* `gtree`:\\[in\\] The global id of a tree. +* `offset`:\\[in\\] The partition to be considered. +* `some_owner`:\\[in\\] If >= 0 considered as input: a process that has *gtree* as local tree. If < 0 on output a process that has *gtree* as local tree. Specifying *some_owner* increases the runtime from O(log mpisize) to O(n), where n is the number of owners of the tree. +# Returns +The smallest rank that has *gtree* as a local tree. ### Prototype ```c -void t8_forest_set_copy (t8_forest_t forest, const t8_forest_t from); +int t8_offset_first_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner); ``` """ -function t8_forest_set_copy(forest, from) - @ccall libt8.t8_forest_set_copy(forest::t8_forest_t, from::t8_forest_t)::Cvoid +function t8_offset_first_owner_of_tree(mpisize, gtree, offset, some_owner) + @ccall libt8.t8_offset_first_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, some_owner::Ptr{Cint})::Cint end """ - t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) - -Set a source forest with an adapt function to be adapted on committing. By default, the forest takes ownership of the source **set_from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **set_from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **set_from** or dereferencing it UNLESS it is referenced directly before passing it into this function. - -!!! note + t8_offset_last_owner_of_tree(mpisize, gtree, offset, some_owner) - This setting can be combined with t8_forest_set_partition and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance. - -!!! note - - This setting may not be combined with t8_forest_set_copy and overwrites this setting. +Find the biggest process that has a given tree as local tree. To increase the runtime, an arbitrary process having this tree as local tree can be passed as an argument. Otherwise, such an owner is computed during the call. # Arguments -* `forest`:\\[in,out\\] The forest -* `set_from`:\\[in\\] The source forest from which **forest** will be adapted. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_partition, t8_forest_set_balance). -* `adapt_fn`:\\[in\\] The adapt function used on committing. -* `recursive`:\\[in\\] A flag specifying whether adaptation is to be done recursively or not. If the value is zero, adaptation is not recursive and it is recursive otherwise. +* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. +* `gtree`:\\[in\\] The global id of a tree. +* `offset`:\\[in\\] The partition to be considered. +* `some_owner`:\\[in,out\\] If >= 0 considered as input: a process that has *gtree* as local tree. If < 0 on output a process that has *gtree* as local tree. Specifying *some_owner* increases the runtime from O(log mpisize) to O(n), where n is the number of owners of the tree. +# Returns +The biggest rank that has *gtree* as a local tree. ### Prototype ```c -void t8_forest_set_adapt (t8_forest_t forest, const t8_forest_t set_from, t8_forest_adapt_t adapt_fn, const int recursive); +int t8_offset_last_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner); ``` """ -function t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) - @ccall libt8.t8_forest_set_adapt(forest::t8_forest_t, set_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint)::Cvoid +function t8_offset_last_owner_of_tree(mpisize, gtree, offset, some_owner) + @ccall libt8.t8_offset_last_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, some_owner::Ptr{Cint})::Cint end """ - t8_forest_set_user_data(forest, data) + t8_offset_next_owner_of_tree(mpisize, gtree, offset, current_owner) -Set the user data of a forest. This can i.e. be used to pass user defined arguments to the adapt routine. +Given a process current\\_owner that has the tree gtree as local tree, find the next bigger rank that also has this tree as local tree. # Arguments -* `forest`:\\[in,out\\] The forest -* `data`:\\[in\\] A pointer to user data. t8code will never touch the data. The forest does not need be committed before calling this function. -# See also -[`t8_forest_get_user_data`](@ref) - +* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. +* `gtree`:\\[in\\] The global id of a tree. +* `offset`:\\[in\\] The partition to be considered. +* `current_owner`:\\[in\\] A process that has *gtree* as local tree. +# Returns +The MPI rank of the next bigger rank than *current_owner* that has *gtree* as local tree. -1 if non such rank exists. ### Prototype ```c -void t8_forest_set_user_data (t8_forest_t forest, void *data); +int t8_offset_next_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int current_owner); ``` """ -function t8_forest_set_user_data(forest, data) - @ccall libt8.t8_forest_set_user_data(forest::t8_forest_t, data::Ptr{Cvoid})::Cvoid +function t8_offset_next_owner_of_tree(mpisize, gtree, offset, current_owner) + @ccall libt8.t8_offset_next_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, current_owner::Cint)::Cint end """ - t8_forest_get_user_data(forest) + t8_offset_prev_owner_of_tree(mpisize, gtree, offset, current_owner) -Return the user data pointer associated with a forest. +Given a process current\\_owner that has the tree gtree as local tree, find the next smaller rank that also has this tree as local tree. # Arguments -* `forest`:\\[in\\] The forest. +* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. +* `gtree`:\\[in\\] The global id of a tree. +* `offset`:\\[in\\] The partition to be considered. +* `current_owner`:\\[in\\] A process that has *gtree* as local tree. # Returns -The user data pointer of *forest*. The forest does not need be committed before calling this function. -# See also -[`t8_forest_set_user_data`](@ref) - +The MPI rank of the next smaller rank than *current_owner* that has *gtree* as local tree. -1 if non such rank exists. ### Prototype ```c -void * t8_forest_get_user_data (const t8_forest_t forest); +int t8_offset_prev_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, const int current_owner); ``` """ -function t8_forest_get_user_data(forest) - @ccall libt8.t8_forest_get_user_data(forest::t8_forest_t)::Ptr{Cvoid} +function t8_offset_prev_owner_of_tree(mpisize, gtree, offset, current_owner) + @ccall libt8.t8_offset_prev_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, current_owner::Cint)::Cint end """ - t8_forest_set_user_function(forest, _function) + t8_offset_all_owners_of_tree(mpisize, gtree, offset, owners) -Set the user function pointer of a forest. This can i.e. be used to pass user defined functions to the adapt routine. +Compute a list of all processes that own a specific tree.n *offset* minus 1. -!!! note +# Arguments +* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. +* `gtree`:\\[in\\] The global index of a tree. +* `offset`:\\[in\\] The partition to be considered. +* `owners`:\\[in,out\\] On input an initialized [`sc_array`](@ref) with integer entries and zero elements. On output a sorted list of all MPI ranks that have *gtree* as a local tree in *offset*. +### Prototype +```c +void t8_offset_all_owners_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, sc_array_t *owners); +``` +""" +function t8_offset_all_owners_of_tree(mpisize, gtree, offset, owners) + @ccall libt8.t8_offset_all_owners_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, owners::Ptr{sc_array_t})::Cvoid +end - *function* can be an arbitrary function with return value and parameters of your choice. When accessing it with t8_forest_get_user_function you should cast it into the proper type. +""" + t8_offset_nosend(proc, mpisize, offset_from, offset_to) -# Arguments -* `forest`:\\[in,out\\] The forest -* `function`:\\[in\\] A pointer to a user defined function. t8code will never touch the function. The forest does not need be committed before calling this function. -# See also -[`t8_forest_get_user_function`](@ref) +Query whether in a repartition setting a given process does send any of its local trees to any other process (including itself) +# Arguments +* `proc`:\\[in\\] A mpi rank. +* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. +* `offset_from`:\\[in\\] The partition table of the current partition. +* `offset_to`:\\[in\\] The partition table of the next partition. +# Returns +nonzero if *proc* will not send any local trees if we repartition from *offset_from* to *offset_to* 0 if it does send local trees. ### Prototype ```c -void t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer function); +int t8_offset_nosend (int proc, int mpisize, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); ``` """ -function t8_forest_set_user_function(forest, _function) - @ccall libt8.t8_forest_set_user_function(forest::t8_forest_t, _function::t8_generic_function_pointer)::Cvoid +function t8_offset_nosend(proc, mpisize, offset_from, offset_to) + @ccall libt8.t8_offset_nosend(proc::Cint, mpisize::Cint, offset_from::Ptr{t8_gloidx_t}, offset_to::Ptr{t8_gloidx_t})::Cint end """ - t8_forest_get_user_function(forest) + t8_offset_sendsto(proca, procb, t8_offset_from, t8_offset_to) -Return the user function pointer associated with a forest. +Query whether in a repartitioning setting, a given process sends local trees (and then possibly ghosts) to a given other process. # Arguments -* `forest`:\\[in\\] The forest. +* `proca`:\\[in\\] Mpi rank of the possible sending process. +* `procb`:\\[in\\] Mpi rank of the possible receiver. +* `offset_from`:\\[in\\] The partition table of the current partition. +* `offset_to`:\\[in\\] The partition table of the next partition. # Returns -The user function pointer of *forest*. The forest does not need be committed before calling this function. -# See also -[`t8_forest_set_user_function`](@ref) - +nonzero if *proca* does send local trees to *procb* when we repartition from *offset_from* to *offset_to*. 0 else. ### Prototype ```c -t8_generic_function_pointer t8_forest_get_user_function (const t8_forest_t forest); +int t8_offset_sendsto (int proca, int procb, const t8_gloidx_t *t8_offset_from, const t8_gloidx_t *t8_offset_to); ``` """ -function t8_forest_get_user_function(forest) - @ccall libt8.t8_forest_get_user_function(forest::t8_forest_t)::t8_generic_function_pointer +function t8_offset_sendsto(proca, procb, t8_offset_from, t8_offset_to) + @ccall libt8.t8_offset_sendsto(proca::Cint, procb::Cint, t8_offset_from::Ptr{t8_gloidx_t}, t8_offset_to::Ptr{t8_gloidx_t})::Cint end """ - t8_forest_set_partition(forest, set_from, set_for_coarsening) + t8_offset_sendstree(proc_send, proc_to, gtree, offset_from, offset_to) -Set a source forest to be partitioned during commit. The partitioning is done according to the SFC and each rank is assigned the same (maybe +1) number of elements. - -!!! note +Query whether in a repartitioning setting, a given process sends a given tree to a second process. - This setting can be combined with t8_forest_set_adapt and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance. If t8_forest_set_balance is called with the *no_repartition* parameter set as false, it is not necessary to call t8_forest_set_partition additionally. +# Arguments +* `proc_send`:\\[in\\] Mpi rank of the possible sending process. +* `proc_recv`:\\[in\\] Mpi rank of the possible receiver. +* `gtree`:\\[in\\] A global tree id. +* `offset_from`:\\[in\\] The partition table of the current partition. +* `offset_to`:\\[in\\] The partition table of the next partition. +# Returns +nonzero if *proc_send* will send the tree *gtree* to *proc_recv*. 0 else. When calling, *gtree* must not be a local tree of *proc_send* in *offset_from*. In this case, 0 is always returned. +### Prototype +```c +int t8_offset_sendstree (int proc_send, int proc_to, t8_gloidx_t gtree, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); +``` +""" +function t8_offset_sendstree(proc_send, proc_to, gtree, offset_from, offset_to) + @ccall libt8.t8_offset_sendstree(proc_send::Cint, proc_to::Cint, gtree::t8_gloidx_t, offset_from::Ptr{t8_gloidx_t}, offset_to::Ptr{t8_gloidx_t})::Cint +end -!!! note +""" + t8_offset_range_send(start, _end, mpirank, offset_from, offset_to) - This setting may not be combined with t8_forest_set_copy and overwrites this setting. +Count the number of processes in a given range [a,b] that send to a given other process in a repartitioning setting. # Arguments -* `forest`:\\[in,out\\] The forest. -* `set_from`:\\[in\\] A second forest that should be partitioned. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_balance). -* `set_for_coarsening`:\\[in\\] If true, the partition will be such that coarsening a family of elements into their parent once is a process-local operation. This is ensured by a post-processing step that slightly shifts the newly determined process boundaries such that no full family of (same-level) siblings is split between processes. +* `start`:\\[in\\] The first mpi rank to be considered as sender. +* `end`:\\[in\\] The last mpi rank to be considered as sender. +* `mpirank`:\\[in\\] The mpirank to be considered as receiver. +* `offset_from`:\\[in\\] The partition table of the current partition. +* `offset_to`:\\[in\\] The partition table of the next partition. +# Returns +The number of processes p, such that *start* <= p <= *end* and p does send local trees (and possibly ghosts) to *mpirank*. ### Prototype ```c -void t8_forest_set_partition (t8_forest_t forest, const t8_forest_t set_from, int set_for_coarsening); +int t8_offset_range_send (int start, int end, int mpirank, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); ``` """ -function t8_forest_set_partition(forest, set_from, set_for_coarsening) - @ccall libt8.t8_forest_set_partition(forest::t8_forest_t, set_from::t8_forest_t, set_for_coarsening::Cint)::Cvoid +function t8_offset_range_send(start, _end, mpirank, offset_from, offset_to) + @ccall libt8.t8_offset_range_send(start::Cint, _end::Cint, mpirank::Cint, offset_from::Ptr{t8_gloidx_t}, offset_to::Ptr{t8_gloidx_t})::Cint end """ - t8_forest_set_partition_weight_function(forest, weight_callback) + t8_offset_print(offset, comm) -Set a user-defined weight function to guide the partitioning. +### Prototype +```c +void t8_offset_print (t8_shmem_array_t offset, sc_MPI_Comm comm); +``` +""" +function t8_offset_print(offset, comm) + @ccall libt8.t8_offset_print(offset::t8_shmem_array_t, comm::MPI_Comm)::Cvoid +end -\\pre *weight_callback* must be free of side effects (like changing the forest, some global state, etc.), the behavior is undefined otherwise. +""" + t8_cmesh_partition(cmesh, comm) -!!! note +### Prototype +```c +void t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm); +``` +""" +function t8_cmesh_partition(cmesh, comm) + @ccall libt8.t8_cmesh_partition(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +end - If *weight_callback* is null, then all the elements are assumed to have the same weight +""" + t8_cmesh_gather_trees_per_eclass(cmesh, comm) -# Arguments -* `forest`:\\[in,out\\] The forest. -* `weight_callback`:\\[in\\] A callback function defining element weights for the partitioning. ### Prototype ```c -void t8_forest_set_partition_weight_function (t8_forest_t forest, t8_weight_fcn_t *weight_callback); +void t8_cmesh_gather_trees_per_eclass (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function t8_forest_set_partition_weight_function(forest, weight_callback) - @ccall libt8.t8_forest_set_partition_weight_function(forest::t8_forest_t, weight_callback::Ptr{t8_weight_fcn_t})::Cvoid +function t8_cmesh_gather_trees_per_eclass(cmesh, comm) + @ccall libt8.t8_cmesh_gather_trees_per_eclass(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - t8_forest_set_balance(forest, set_from, no_repartition) - -Set a source forest to be balanced during commit. A forest is said to be balanced if each element has face neighbors of level at most +1 or -1 of the element's level. + t8_cmesh_gather_treecount(cmesh, comm) -!!! note +### Prototype +```c +void t8_cmesh_gather_treecount (t8_cmesh_t cmesh, sc_MPI_Comm comm); +``` +""" +function t8_cmesh_gather_treecount(cmesh, comm) + @ccall libt8.t8_cmesh_gather_treecount(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +end - This setting can be combined with t8_forest_set_adapt and t8_forest_set_partition. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance. +""" + t8_cmesh_gather_treecount_nocommit(cmesh, comm) -!!! note +### Prototype +```c +void t8_cmesh_gather_treecount_nocommit (t8_cmesh_t cmesh, sc_MPI_Comm comm); +``` +""" +function t8_cmesh_gather_treecount_nocommit(cmesh, comm) + @ccall libt8.t8_cmesh_gather_treecount_nocommit(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +end - This setting may not be combined with t8_forest_set_copy and overwrites this setting. +""" + t8_cmesh_offset_print(cmesh, comm) -# Arguments -* `forest`:\\[in,out\\] The forest. -* `set_from`:\\[in\\] A second forest that should be balanced. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_partition) -* `no_repartition`:\\[in\\] Balance constructs several intermediate forest that are refined from each other. In order to maintain a balanced load these forest are repartitioned in each round and the resulting forest is load-balanced per default. If this behaviour is not desired, *no_repartition* should be set to true. If *no_repartition* is false, an additional call of t8_forest_set_partition is not necessary. ### Prototype ```c -void t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_repartition); +void t8_cmesh_offset_print (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function t8_forest_set_balance(forest, set_from, no_repartition) - @ccall libt8.t8_forest_set_balance(forest::t8_forest_t, set_from::t8_forest_t, no_repartition::Cint)::Cvoid +function t8_cmesh_offset_print(cmesh, comm) + @ccall libt8.t8_cmesh_offset_print(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - t8_forest_set_ghost(forest, do_ghost, ghost_type) + t8_cmesh_offset_concentrate(proc, comm, num_trees) -Enable or disable the creation of a layer of ghost elements. On default no ghosts are created. - -# Arguments -* `forest`:\\[in\\] The forest. -* `do_ghost`:\\[in\\] If non-zero a ghost layer will be created. -* `ghost_type`:\\[in\\] Controls which neighbors count as ghost elements, currently only T8\\_GHOST\\_FACES is supported. This value is ignored if *do_ghost* = 0. ### Prototype ```c -void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type); +t8_shmem_array_t t8_cmesh_offset_concentrate (int proc, sc_MPI_Comm comm, t8_gloidx_t num_trees); ``` """ -function t8_forest_set_ghost(forest, do_ghost, ghost_type) - @ccall libt8.t8_forest_set_ghost(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t)::Cvoid +function t8_cmesh_offset_concentrate(proc, comm, num_trees) + @ccall libt8.t8_cmesh_offset_concentrate(proc::Cint, comm::MPI_Comm, num_trees::t8_gloidx_t)::t8_shmem_array_t end """ - t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) - -Like t8_forest_set_ghost but with the additional options to change the ghost algorithm. This is used for debugging and timing the algorithm. An application should almost always use t8_forest_set_ghost. - -# Arguments -* `forest`:\\[in\\] The forest. -* `do_ghost`:\\[in\\] If non-zero a ghost layer will be created. -* `ghost_type`:\\[in\\] Controls which neighbors count as ghost elements, currently only T8\\_GHOST\\_FACES is supported. This value is ignored if *do_ghost* = 0. -* `ghost_version`:\\[in\\] If 1, the iterative ghost algorithm for balanced forests is used. If 2, the iterative algorithm for unbalanced forests. If 3, the top-down search algorithm for unbalanced forests. -# See also -[`t8_forest_set_ghost`](@ref) + t8_cmesh_offset_random(comm, num_trees, shared, seed) ### Prototype ```c -void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); +t8_shmem_array_t t8_cmesh_offset_random (sc_MPI_Comm comm, t8_gloidx_t num_trees, int shared, unsigned seed); ``` """ -function t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) - @ccall libt8.t8_forest_set_ghost_ext(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t, ghost_version::Cint)::Cvoid +function t8_cmesh_offset_random(comm, num_trees, shared, seed) + @ccall libt8.t8_cmesh_offset_random(comm::MPI_Comm, num_trees::t8_gloidx_t, shared::Cint, seed::Cuint)::t8_shmem_array_t end """ - t8_forest_set_load(forest, filename) - -Use assertions and document that the forest\\_set (..., from) and set\\_load are mutually exclusive. - -TODO: Unused function -> remove? + t8_cmesh_offset_half(cmesh, comm) ### Prototype ```c -void t8_forest_set_load (t8_forest_t forest, const char *filename); +t8_shmem_array_t t8_cmesh_offset_half (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function t8_forest_set_load(forest, filename) - @ccall libt8.t8_forest_set_load(forest::t8_forest_t, filename::Cstring)::Cvoid +function t8_cmesh_offset_half(cmesh, comm) + @ccall libt8.t8_cmesh_offset_half(cmesh::t8_cmesh_t, comm::MPI_Comm)::t8_shmem_array_t end """ - t8_forest_comm_global_num_leaf_elements(forest) - -Compute the global number of leaf elements in a forest as the sum of the local leaf element counts. + t8_cmesh_offset_percent(cmesh, comm, percent) -# Arguments -* `forest`:\\[in\\] The forest. ### Prototype ```c -void t8_forest_comm_global_num_leaf_elements (t8_forest_t forest); +t8_shmem_array_t t8_cmesh_offset_percent (t8_cmesh_t cmesh, sc_MPI_Comm comm, int percent); ``` """ -function t8_forest_comm_global_num_leaf_elements(forest) - @ccall libt8.t8_forest_comm_global_num_leaf_elements(forest::t8_forest_t)::Cvoid +function t8_cmesh_offset_percent(cmesh, comm, percent) + @ccall libt8.t8_cmesh_offset_percent(cmesh::t8_cmesh_t, comm::MPI_Comm, percent::Cint)::t8_shmem_array_t end """ - t8_forest_commit(forest) + t8_stash_class -After allocating and adding properties to a forest, commit the changes. This call sets up the internal state of the forest. +The eclass information that is stored before a cmesh is committed. -# Arguments -* `forest`:\\[in,out\\] Must be created with t8_forest_init and specialized with t8\\_forest\\_set\\_* calls first. -### Prototype -```c -void t8_forest_commit (t8_forest_t forest); -``` +| Field | Note | +| :----- | :----------------------- | +| id | The global tree id | +| eclass | The eclass of that tree | """ -function t8_forest_commit(forest) - @ccall libt8.t8_forest_commit(forest::t8_forest_t)::Cvoid +struct t8_stash_class + id::t8_gloidx_t + eclass::t8_eclass_t +end + +"""The eclass information that is stored before a cmesh is committed.""" +const t8_stash_class_struct_t = t8_stash_class + +""" + t8_stash_joinface + +The face-connection information that is stored before a cmesh is committed. + +| Field | Note | +| :---------- | :------------------------------------------------------------------------- | +| id1 | The global tree id of the first tree in the connection. | +| id2 | The global tree id of the second tree. We ensure id1<=id2. | +| face1 | The face number of the first of the connected faces. | +| face2 | The face number of the second face. | +| orientation | The orientation of the face connection. # See also t8\\_cmesh\\_types.h. | +""" +struct t8_stash_joinface + id1::t8_gloidx_t + id2::t8_gloidx_t + face1::Cint + face2::Cint + orientation::Cint end +"""The face-connection information that is stored before a cmesh is committed.""" +const t8_stash_joinface_struct_t = t8_stash_joinface + """ - t8_forest_get_maxlevel(forest) + t8_stash_attribute -Return the maximum allowed refinement level for any element in a forest. +The attribute information that is stored before a cmesh is committed. The pair (package\\_id, key) serves as a lookup key to identify the data. + +| Field | Note | +| :----------- | :---------------------------------------------------------------------- | +| id | The global tree id | +| attr\\_size | The size (in bytes) of this attribute | +| attr\\_data | Array of *size* bytes storing the attributes data. | +| is\\_owned | True if the data was copied, false if the data is still owned by user. | +| package\\_id | The id of the package that set this attribute. | +| key | The key used by the package to identify this attribute. | +""" +struct t8_stash_attribute + id::t8_gloidx_t + attr_size::Csize_t + attr_data::Ptr{Cvoid} + is_owned::Cint + package_id::Cint + key::Cint +end + +"""The attribute information that is stored before a cmesh is committed. The pair (package\\_id, key) serves as a lookup key to identify the data.""" +const t8_stash_attribute_struct_t = t8_stash_attribute + +"""The stash data structure is used to store information about the cmesh before it is committed. In particular we store the eclasses of the trees, the face-connections and the tree attributes. Using the stash structure allows us to have a very flexible interface. When constructing a new mesh, the user can specify all these mesh entities in arbitrary order. As soon as the cmesh is committed the information is copied from the stash to the cmesh in an order mannered.""" +const t8_stash_struct_t = t8_stash + +""" + t8_stash_init(pstash) + +Initialize a stash data structure. # Arguments -* `forest`:\\[in\\] A forest. -# Returns -The maximum level of refinement that is allowed for an element in this forest. It is guaranteed that any tree in *forest* can be refined this many times and it is not allowed to refine further. *forest* must be committed before calling this function. For forest with a single element class (non-hybrid) maxlevel is the maximum refinement level of this element class, whilst for hybrid forests the maxlevel is the minimum of all maxlevels of the element classes in this forest. +* `pstash`:\\[in,out\\] A pointer to the stash to be initialized. ### Prototype ```c -int t8_forest_get_maxlevel (const t8_forest_t forest); +void t8_stash_init (t8_stash_t *pstash); ``` """ -function t8_forest_get_maxlevel(forest) - @ccall libt8.t8_forest_get_maxlevel(forest::t8_forest_t)::Cint +function t8_stash_init(pstash) + @ccall libt8.t8_stash_init(pstash::Ptr{t8_stash_t})::Cvoid end """ - t8_forest_get_local_num_leaf_elements(forest) + t8_stash_destroy(pstash) -Return the number of process local leaf elements in the forest. +Free all memory associated in a stash structure. # Arguments -* `forest`:\\[in\\] A forest. -# Returns -The number of leaf elements on this process in *forest*. *forest* must be committed before calling this function. +* `pstash`:\\[in,out\\] A pointer to the stash to be destroyed. The pointer is set to NULL after the function call. ### Prototype ```c -t8_locidx_t t8_forest_get_local_num_leaf_elements (const t8_forest_t forest); +void t8_stash_destroy (t8_stash_t *pstash); ``` """ -function t8_forest_get_local_num_leaf_elements(forest) - @ccall libt8.t8_forest_get_local_num_leaf_elements(forest::t8_forest_t)::t8_locidx_t +function t8_stash_destroy(pstash) + @ccall libt8.t8_stash_destroy(pstash::Ptr{t8_stash_t})::Cvoid end """ - t8_forest_get_global_num_leaf_elements(forest) + t8_stash_add_class(stash, id, eclass) -Return the number of global leaf elements in the forest. +Set the eclass of a tree. # Arguments -* `forest`:\\[in\\] A forest. -# Returns -The number of leaf elements (summed over all processes) in *forest*. *forest* must be committed before calling this function. +* `stash`:\\[in,out\\] The stash to be updated. +* `id`:\\[in\\] The global id of the tree whose eclass should be set. +* `eclass`:\\[in\\] The eclass of tree with id *id*. ### Prototype ```c -t8_gloidx_t t8_forest_get_global_num_leaf_elements (const t8_forest_t forest); +void t8_stash_add_class (t8_stash_t stash, t8_gloidx_t id, t8_eclass_t eclass); ``` """ -function t8_forest_get_global_num_leaf_elements(forest) - @ccall libt8.t8_forest_get_global_num_leaf_elements(forest::t8_forest_t)::t8_gloidx_t +function t8_stash_add_class(stash, id, eclass) + @ccall libt8.t8_stash_add_class(stash::t8_stash_t, id::t8_gloidx_t, eclass::t8_eclass_t)::Cvoid end """ - t8_forest_get_num_ghosts(forest) + t8_stash_add_facejoin(stash, gid1, gid2, face1, face2, orientation) -Return the number of ghost elements of a forest. +Add a face connection to a stash. # Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of ghost elements stored in the ghost structure of *forest*. 0 if no ghosts were constructed. -# See also -[`t8_forest_set_ghost`](@ref) *forest* must be committed before calling this function. - +* `stash`:\\[in,out\\] The stash to be updated. +* `id1`:\\[in\\] The global id of the first tree. +* `id2`:\\[in\\] The global id of the second tree, +* `face1`:\\[in\\] The face number of the face of the first tree. +* `face2`:\\[in\\] The face number of the face of the second tree. +* `orientation`:\\[in\\] The orientation of the faces to each other. ### Prototype ```c -t8_locidx_t t8_forest_get_num_ghosts (const t8_forest_t forest); +void t8_stash_add_facejoin (t8_stash_t stash, t8_gloidx_t gid1, t8_gloidx_t gid2, int face1, int face2, int orientation); ``` """ -function t8_forest_get_num_ghosts(forest) - @ccall libt8.t8_forest_get_num_ghosts(forest::t8_forest_t)::t8_locidx_t +function t8_stash_add_facejoin(stash, gid1, gid2, face1, face2, orientation) + @ccall libt8.t8_stash_add_facejoin(stash::t8_stash_t, gid1::t8_gloidx_t, gid2::t8_gloidx_t, face1::Cint, face2::Cint, orientation::Cint)::Cvoid end """ - t8_forest_get_eclass(forest, ltreeid) + t8_stash_class_sort(stash) -Return the element class of a forest local tree. +Sort the entries in the class array by the order given in the enum definition of [`t8_eclass`](@ref). # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in *forest*. -# Returns -The element class of the tree *ltreeid*. *forest* must be committed before calling this function. +* `stash`:\\[in,out\\] The stash whose class array is sorted. ### Prototype ```c -t8_eclass_t t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid); +void t8_stash_class_sort (t8_stash_t stash); ``` """ -function t8_forest_get_eclass(forest, ltreeid) - @ccall libt8.t8_forest_get_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t +function t8_stash_class_sort(stash) + @ccall libt8.t8_stash_class_sort(stash::t8_stash_t)::Cvoid end """ - t8_forest_tree_is_local(forest, local_tree) + t8_stash_class_bsearch(stash, tree_id) -Check whether a given tree id belongs to a local tree in a forest. +Search for an entry with a given tree index in the class-stash. The stash must be sorted beforehand. # Arguments -* `forest`:\\[in\\] The forest. -* `local_tree`:\\[in\\] A tree id. +* `stash`:\\[in\\] The stash to be searched for. +* `tree_id`:\\[in\\] The global tree id. # Returns -True if and only if the id *local_tree* belongs to a local tree of *forest*. *forest* must be committed before calling this function. +The index of an element in the classes array of *stash* corresponding to *tree_id*. -1 if not found. ### Prototype ```c -int t8_forest_tree_is_local (const t8_forest_t forest, const t8_locidx_t local_tree); +ssize_t t8_stash_class_bsearch (t8_stash_t stash, t8_gloidx_t tree_id); ``` """ -function t8_forest_tree_is_local(forest, local_tree) - @ccall libt8.t8_forest_tree_is_local(forest::t8_forest_t, local_tree::t8_locidx_t)::Cint +function t8_stash_class_bsearch(stash, tree_id) + @ccall libt8.t8_stash_class_bsearch(stash::t8_stash_t, tree_id::t8_gloidx_t)::Cssize_t end """ - t8_forest_get_local_id(forest, gtreeid) + t8_stash_joinface_sort(stash) -Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is not a local tree, a negative number is returned. +Sort then entries in the facejoin array in order of the first treeid. # Arguments -* `forest`:\\[in\\] The forest. -* `gtreeid`:\\[in\\] The global id of a tree. -# Returns -The tree's local id in *forest*, if it is a local tree. A negative number if not. Ghosts trees are not considered as local. -# See also -[`t8_forest_get_local_or_ghost_id`](@ref) for ghost trees., https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +* `stash`:\\[in,out\\] The stash whose facejoin array is sorted. ### Prototype ```c -t8_locidx_t t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); +void t8_stash_joinface_sort (t8_stash_t stash); ``` """ -function t8_forest_get_local_id(forest, gtreeid) - @ccall libt8.t8_forest_get_local_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t +function t8_stash_joinface_sort(stash) + @ccall libt8.t8_stash_joinface_sort(stash::t8_stash_t)::Cvoid end """ - t8_forest_get_local_or_ghost_id(forest, gtreeid) + t8_stash_add_attribute(stash, id, package_id, key, size, attr, copy) -Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is a ghost, then the local id is between num\\_local\\_trees and num\\_local\\_trees + num\\_ghost\\_trees. If the tree is neither a local tree nor a ghost tree, a negative number is returned. +Add an attribute to a tree. # Arguments -* `forest`:\\[in\\] The forest. -* `gtreeid`:\\[in\\] The global id of a tree. -# Returns -The tree's local id in *forest*, if it is a local tree. num\\_local\\_trees + the ghosts id, if it is a ghost tree. A negative number if not. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing - +* `stash`:\\[in\\] The stash structure to be modified. +* `id`:\\[in\\] The global index of the tree to which the attribute is added. +* `package_id`:\\[in\\] The unique id of the current package. +* `key`:\\[in\\] An integer value used to identify this attribute. +* `size`:\\[in\\] The size (in bytes) of the attribute. +* `attr`:\\[in\\] Points to *size* bytes of memory that should be stored as the attribute. +* `copy`:\\[in\\] If true the attribute data is copied from *attr* to an internal storage. If false only the pointer *attr* is stored and the data is only copied if the cmesh is committed. (More memory efficient). ### Prototype ```c -t8_locidx_t t8_forest_get_local_or_ghost_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); +void t8_stash_add_attribute (t8_stash_t stash, t8_gloidx_t id, int package_id, int key, size_t size, void *const attr, int copy); ``` """ -function t8_forest_get_local_or_ghost_id(forest, gtreeid) - @ccall libt8.t8_forest_get_local_or_ghost_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t +function t8_stash_add_attribute(stash, id, package_id, key, size, attr, copy) + @ccall libt8.t8_stash_add_attribute(stash::t8_stash_t, id::t8_gloidx_t, package_id::Cint, key::Cint, size::Csize_t, attr::Ptr{Cvoid}, copy::Cint)::Cvoid end """ - t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) - -Given the local id of a tree in a forest, compute the tree's local id in the associated cmesh. + t8_stash_get_attribute_size(stash, index) -!!! note - - For forest local trees, this is the inverse function of t8_forest_cmesh_ltreeid_to_ltreeid. +Return the size (in bytes) of an attribute in the stash. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree or ghost in the forest. +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. # Returns -The local id of the tree in the cmesh associated with the forest. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +The size in bytes of the attribute. ### Prototype ```c -t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, t8_locidx_t ltreeid); +size_t t8_stash_get_attribute_size (t8_stash_t stash, size_t index); ``` """ -function t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) - @ccall libt8.t8_forest_ltreeid_to_cmesh_ltreeid(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t +function t8_stash_get_attribute_size(stash, index) + @ccall libt8.t8_stash_get_attribute_size(stash::t8_stash_t, index::Csize_t)::Csize_t end """ - t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) - -Given the local id of a tree in the coarse mesh of a forest, compute the tree's local id in the forest. - -!!! note + t8_stash_get_attribute(stash, index) - For forest local trees, this is the inverse function of t8_forest_ltreeid_to_cmesh_ltreeid. +Return the pointer to an attribute in the stash. # Arguments -* `forest`:\\[in\\] The forest. -* `lctreeid`:\\[in\\] The local id of a tree in the coarse mesh of *forest*. +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. # Returns -The local id of the tree in the forest. -1 if the tree is not forest local. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +A void pointer to the memory region where the attribute is stored. ### Prototype ```c -t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, t8_locidx_t lctreeid); +void * t8_stash_get_attribute (t8_stash_t stash, size_t index); ``` """ -function t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) - @ccall libt8.t8_forest_cmesh_ltreeid_to_ltreeid(forest::t8_forest_t, lctreeid::t8_locidx_t)::t8_locidx_t +function t8_stash_get_attribute(stash, index) + @ccall libt8.t8_stash_get_attribute(stash::t8_stash_t, index::Csize_t)::Ptr{Cvoid} end """ - t8_forest_get_coarse_tree(forest, ltreeid) + t8_stash_get_attribute_tree_id(stash, index) -Given the local id of a tree in a forest, return the coarse tree of the cmesh that corresponds to this tree. +Return the id of the tree a given attribute belongs to. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in the forest. +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. # Returns -The coarse tree that matches the forest tree with local id *ltreeid*. +The tree id. ### Prototype ```c -t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid); +t8_gloidx_t t8_stash_get_attribute_tree_id (t8_stash_t stash, size_t index); ``` """ -function t8_forest_get_coarse_tree(forest, ltreeid) - @ccall libt8.t8_forest_get_coarse_tree(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_ctree_t +function t8_stash_get_attribute_tree_id(stash, index) + @ccall libt8.t8_stash_get_attribute_tree_id(stash::t8_stash_t, index::Csize_t)::t8_gloidx_t end """ - t8_forest_element_is_leaf(forest, element, local_tree) - -Query whether a given element is a leaf in a forest. - -!!! note - - This does not query for ghost leaves. - -!!! note + t8_stash_get_attribute_key(stash, index) - *forest* must be committed before calling this function. +Return the key of a given attribute. # Arguments -* `forest`:\\[in\\] The forest. -* `element`:\\[in\\] An element of a local tree in *forest*. -* `local_tree`:\\[in\\] A local tree id of *forest*. +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. # Returns -True (non-zero) if and only if *element* is a leaf in *local_tree* of *forest*. +The attribute's key. ### Prototype ```c -int t8_forest_element_is_leaf (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t local_tree); +int t8_stash_get_attribute_key (t8_stash_t stash, size_t index); ``` """ -function t8_forest_element_is_leaf(forest, element, local_tree) - @ccall libt8.t8_forest_element_is_leaf(forest::t8_forest_t, element::Ptr{t8_element_t}, local_tree::t8_locidx_t)::Cint +function t8_stash_get_attribute_key(stash, index) + @ccall libt8.t8_stash_get_attribute_key(stash::t8_stash_t, index::Csize_t)::Cint end """ - t8_forest_element_is_leaf_or_ghost(forest, element, local_tree, check_ghost) - -Query whether a given element or a ghost is a leaf of a local or ghost tree in a forest. + t8_stash_get_attribute_id(stash, index) -!!! note - - *forest* must be committed before calling this function. t8_forest_element_is_leaf t8_forest_element_is_ghost +Return the package\\_id of a given attribute. # Arguments -* `forest`:\\[in\\] The forest. -* `element`:\\[in\\] An element of a local tree in *forest*. -* `local_tree`:\\[in\\] A local tree id of *forest* or a ghost tree id -* `check_ghost`:\\[in\\] If true *element* is interpreted as a ghost element and *local_tree* as the id of a ghost tree (0 <= *local_tree* < num\\_ghost\\_trees). If false *element* is interpreted as an element and *local_tree* as the id of a local tree (0 <= *local_tree* < num\\_local\\_trees). +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. # Returns -True (non-zero) if and only if *element* is a leaf (or ghost) in *local_tree* of *forest*. +The attribute's package\\_id. ### Prototype ```c -int t8_forest_element_is_leaf_or_ghost (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t local_tree, const int check_ghost); +int t8_stash_get_attribute_id (t8_stash_t stash, size_t index); ``` """ -function t8_forest_element_is_leaf_or_ghost(forest, element, local_tree, check_ghost) - @ccall libt8.t8_forest_element_is_leaf_or_ghost(forest::t8_forest_t, element::Ptr{t8_element_t}, local_tree::t8_locidx_t, check_ghost::Cint)::Cint +function t8_stash_get_attribute_id(stash, index) + @ccall libt8.t8_stash_get_attribute_id(stash::t8_stash_t, index::Csize_t)::Cint end """ - t8_forest_leaf_face_orientation(forest, ltreeid, scheme, leaf, face) + t8_stash_attribute_is_owned(stash, index) -Compute the leaf face orientation at given face in a forest. - -For more information about the encoding of face orientation refer to t8_cmesh_get_face_neighbor. +Return true if an attribute in the stash is owned by the stash, that is, it was copied in the call to [`t8_stash_add_attribute`](@ref). Returns false if the attribute is not owned by the stash. # Arguments -* `forest`:\\[in\\] The forest. Must have a valid ghost layer. -* `ltreeid`:\\[in\\] A local tree id. -* `scheme`:\\[in\\] The eclass scheme of the element. -* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. -* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. # Returns -Face orientation encoded as integer. +True of false. ### Prototype ```c -int t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_scheme_c *scheme, const t8_element_t *leaf, const int face); +int t8_stash_attribute_is_owned (t8_stash_t stash, size_t index); ``` """ -function t8_forest_leaf_face_orientation(forest, ltreeid, scheme, leaf, face) - @ccall libt8.t8_forest_leaf_face_orientation(forest::t8_forest_t, ltreeid::t8_locidx_t, scheme::Ptr{t8_scheme_c}, leaf::Ptr{t8_element_t}, face::Cint)::Cint +function t8_stash_attribute_is_owned(stash, index) + @ccall libt8.t8_stash_attribute_is_owned(stash::t8_stash_t, index::Csize_t)::Cint end """ - t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass) + t8_stash_attribute_sort(stash) -Compute the leaf face neighbors of a forest leaf element or ghost leaf. - -!!! note - - If there are no face neighbors, then *pneighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. - -!!! note - - *forest* must be committed before calling this function. - -!!! note - - If *forest* does not have a ghost layer then leaf elements at the process boundaries have 0 neighbors along the boundary face. (The function output for leaf elements then depends on the parallel partition.) - -!!! note - - Important! This routine allocates memory which must be freed. Do it like this: - -if (num\\_neighbors > 0) { [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } +Sort the attributes array of a stash in the order (treeid, packageid, key) * # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] A local tree id (could also be a ghost tree). 0 <= *ltreeid* < num\\_local trees+num\\_ghost\\_trees -* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. -* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. -* `face`:\\[in\\] The index of the face across which the face neighbors are searched. -* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. -* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. -* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. -* `pneigh_eclass`:\\[out\\] On output the eclass of the neighbor elements. +* `stash`:\\[in,out\\] The stash to be considered. ### Prototype ```c -void t8_forest_leaf_face_neighbors (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *leaf, const t8_element_t **pneighbor_leaves[], const int face, int *dual_faces[], int *num_neighbors, t8_locidx_t **pelement_indices, t8_eclass_t *pneigh_eclass); +void t8_stash_attribute_sort (t8_stash_t stash); ``` """ -function t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass) - @ccall libt8.t8_forest_leaf_face_neighbors(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf::Ptr{t8_element_t}, pneighbor_leaves::Ptr{Ptr{Ptr{t8_element_t}}}, face::Cint, dual_faces::Ptr{Ptr{Cint}}, num_neighbors::Ptr{Cint}, pelement_indices::Ptr{Ptr{t8_locidx_t}}, pneigh_eclass::Ptr{t8_eclass_t})::Cvoid +function t8_stash_attribute_sort(stash) + @ccall libt8.t8_stash_attribute_sort(stash::t8_stash_t)::Cvoid end """ - t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf_or_ghost, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass, gneigh_tree, orientation) - -Like t8_forest_leaf_face_neighbors but also provides information about the global neighbors and the orientation. - -!!! note - - If there are no face neighbors, then *pneighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. - -!!! note - - *forest* must be committed before calling this function. - -!!! note - - Important! This routine allocates memory which must be freed. Do it like this: - -if (num\\_neighbors > 0) { [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } + t8_stash_bcast(stash, root, comm, elem_counts) -# Arguments -* `forest`:\\[in\\] The forest. Must have a valid ghost layer. -* `ltreeid`:\\[in\\] A local tree id (could also be a ghost tree). 0 <= *ltreeid* < num\\_local trees+num\\_ghost\\_trees -* `leaf_or_ghost`:\\[in\\] A leaf or ghost leaf element in tree *ltreeid* of *forest*. -* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. -* `face`:\\[in\\] The index of the face across which the face neighbors are searched. -* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. -* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. -* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. -* `pneigh_eclass`:\\[out\\] On output the eclass of the neighbor elements. -* `gneigh_tree`:\\[out\\] The global tree IDs of the neighbor trees. -* `orientation`:\\[out\\] If not NULL on input, the face orientation is computed and stored here. Thus, if the face connection is an inter-tree connection the orientation of the tree-to-tree connection is stored. Otherwise, the value 0 is stored. All other parameters and behavior are identical to t8_forest_leaf_face_neighbors. ### Prototype ```c -void t8_forest_leaf_face_neighbors_ext (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *leaf_or_ghost, const t8_element_t **pneighbor_leaves[], const int face, int *dual_faces[], int *num_neighbors, t8_locidx_t **pelement_indices, t8_eclass_t *pneigh_eclass, t8_gloidx_t *gneigh_tree, int *orientation); +t8_stash_t t8_stash_bcast (t8_stash_t stash, int root, sc_MPI_Comm comm, const size_t elem_counts[3]); ``` """ -function t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf_or_ghost, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass, gneigh_tree, orientation) - @ccall libt8.t8_forest_leaf_face_neighbors_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf_or_ghost::Ptr{t8_element_t}, pneighbor_leaves::Ptr{Ptr{Ptr{t8_element_t}}}, face::Cint, dual_faces::Ptr{Ptr{Cint}}, num_neighbors::Ptr{Cint}, pelement_indices::Ptr{Ptr{t8_locidx_t}}, pneigh_eclass::Ptr{t8_eclass_t}, gneigh_tree::Ptr{t8_gloidx_t}, orientation::Ptr{Cint})::Cvoid +function t8_stash_bcast(stash, root, comm, elem_counts) + @ccall libt8.t8_stash_bcast(stash::t8_stash_t, root::Cint, comm::MPI_Comm, elem_counts::Ptr{Csize_t})::t8_stash_t end """ - t8_forest_same_level_leaf_face_neighbor_index(forest, element_index, face_index, global_treeid, dual_face) + t8_stash_is_equal(stash_a, stash_b) -Given a leaf element or ghost index in "all local elements + ghosts" enumeration compute the index of the face neighbor of the element - provided that only one or no face neighbors exists. HANDLE WITH CARE. DO NOT CALL IF THE FOREST IS NOT UNIFORM. - -!!! note - - Do not call if you are unsure about the number of face neighbors. In particular if the forest is not uniform. +Check two stashes for equal content and return true if so. # Arguments -* `forest`:\\[in\\] The forest. Must be committed. -* `element_index`:\\[in\\] Index of an element in *forest*. Must have only one or no facen neighbors across the given face. 0 <= *element_index* < num\\_local\\_elements + num\\_ghosts -* `face_index`:\\[in\\] Index of a face of *element*. -* `global_treeid`:\\[in\\] Global index of the tree that contains *element*. -* `dual_face`:\\[out\\] Return value, the dual\\_face index of the face neighbor. +* `stash_a`:\\[in\\] The first stash to be considered. +* `stash_b`:\\[in\\] The first stash to be considered. # Returns -The index of the face neighbor leaf (local element or ghost). +True if both stashes hold copies of the same data. False otherwise. ### Prototype ```c -t8_locidx_t t8_forest_same_level_leaf_face_neighbor_index (const t8_forest_t forest, const t8_locidx_t element_index, const int face_index, const t8_gloidx_t global_treeid, int *dual_face); +int t8_stash_is_equal (t8_stash_t stash_a, t8_stash_t stash_b); ``` """ -function t8_forest_same_level_leaf_face_neighbor_index(forest, element_index, face_index, global_treeid, dual_face) - @ccall libt8.t8_forest_same_level_leaf_face_neighbor_index(forest::t8_forest_t, element_index::t8_locidx_t, face_index::Cint, global_treeid::t8_gloidx_t, dual_face::Ptr{Cint})::t8_locidx_t +function t8_stash_is_equal(stash_a, stash_b) + @ccall libt8.t8_stash_is_equal(stash_a::t8_stash_t, stash_b::t8_stash_t)::Cint end """ - t8_forest_ghost_exchange_data(forest, element_data) - -Exchange ghost information of user defined element data. - -!!! note + t8_attribute_info - This function is collective and hence must be called by all processes in the forest's MPI Communicator. +This structure holds the information associated to an attribute of a tree. The attributes of each are stored in a key-value storage, where the key consists of the two entries (package\\_id,key) both being integers. The package\\_id serves to identify the application layer that added the attribute and the key identifies the attribute within that application layer. -# Arguments -* `forest`:\\[in\\] The forest. Must be committed. -* `element_data`:\\[in\\] An array of length num\\_local\\_elements + num\\_ghosts storing one value for each local element and ghost in *forest*. After calling this function the entries for the ghost elements are update with the entries in the *element_data* array of the corresponding owning process. -### Prototype -```c -void t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data); -``` +All attribute info objects of one tree are stored in an array and adding a tree's att\\_offset entry to the tree's address yields this array. The attributes themselves are stored in an array directly behind the array of the attribute infos. """ -function t8_forest_ghost_exchange_data(forest, element_data) - @ccall libt8.t8_forest_ghost_exchange_data(forest::t8_forest_t, element_data::Ptr{sc_array_t})::Cvoid +struct t8_attribute_info + package_id::Cint + key::Cint + attribute_offset::Csize_t + attribute_size::Csize_t end """ - t8_forest_ghost_print(forest) +This structure holds the information associated to an attribute of a tree. The attributes of each are stored in a key-value storage, where the key consists of the two entries (package\\_id,key) both being integers. The package\\_id serves to identify the application layer that added the attribute and the key identifies the attribute within that application layer. -Print the ghost structure of a forest. Only used for debugging. +All attribute info objects of one tree are stored in an array and adding a tree's att\\_offset entry to the tree's address yields this array. The attributes themselves are stored in an array directly behind the array of the attribute infos. +""" +const t8_attribute_info_struct_t = t8_attribute_info -### Prototype -```c -void t8_forest_ghost_print (t8_forest_t forest); -``` """ -function t8_forest_ghost_print(forest) - @ccall libt8.t8_forest_ghost_print(forest::t8_forest_t)::Cvoid + t8_trees_glo_lo_hash_t + +This struct is an entry of the trees global\\_id to local\\_id hash table for ghost trees. + +| Field | Note | +| :---------- | :------------- | +| global\\_id | The global id | +| local\\_id | The local id | +""" +struct t8_trees_glo_lo_hash_t + global_id::t8_gloidx_t + local_id::t8_locidx_t end """ - t8_forest_partition_cmesh(forest, comm, set_profiling) + t8_cmesh_trees_init(ptrees, num_procs, num_trees, num_ghosts) + +Initialize a trees structure and allocate its parts. This function allocates the from\\_procs array without filling it, it also allocates the tree\\_to\\_proc and ghost\\_to\\_proc arrays. No memory for trees or ghosts is allocated. +# Arguments +* `[in,ou`: ptrees The trees structure to be initialized. +* `num_procs`:\\[in\\] The number of entries of its from\\_proc array (can be different for each process). +* `num_trees`:\\[in\\] The number of trees that will be stored in this structure. +* `num_ghosts`:\\[in\\] The number of ghosts that will be stored in this structure. ### Prototype ```c -void t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profiling); +void t8_cmesh_trees_init (t8_cmesh_trees_t *ptrees, int num_procs, t8_locidx_t num_trees, t8_locidx_t num_ghosts); ``` """ -function t8_forest_partition_cmesh(forest, comm, set_profiling) - @ccall libt8.t8_forest_partition_cmesh(forest::t8_forest_t, comm::MPI_Comm, set_profiling::Cint)::Cvoid +function t8_cmesh_trees_init(ptrees, num_procs, num_trees, num_ghosts) + @ccall libt8.t8_cmesh_trees_init(ptrees::Ptr{t8_cmesh_trees_t}, num_procs::Cint, num_trees::t8_locidx_t, num_ghosts::t8_locidx_t)::Cvoid +end + +struct t8_part_tree + first_tree::Cstring + first_tree_id::t8_locidx_t + first_ghost_id::t8_locidx_t + num_trees::t8_locidx_t + num_ghosts::t8_locidx_t end """ - t8_forest_get_mpicomm(forest) +` t8_cmesh_types.h` -### Prototype -```c -sc_MPI_Comm t8_forest_get_mpicomm (const t8_forest_t forest); -``` +We define here the datatypes needed for internal cmesh routines. """ -function t8_forest_get_mpicomm(forest) - @ccall libt8.t8_forest_get_mpicomm(forest::t8_forest_t)::MPI_Comm -end +const t8_part_tree_t = Ptr{t8_part_tree} """ - t8_forest_get_first_local_tree_id(forest) + t8_cmesh_trees_get_part(trees, proc) -Return the global id of the first local tree of a forest. +Return one part of a specified tree array. # Arguments -* `forest`:\\[in\\] The forest. +* `trees`:\\[in\\] The tree array to be queried +* `proc`:\\[in\\] An index specifying the part to be returned. # Returns -The global id of the first local tree in *forest*. +The part number *proc* of *trees*. ### Prototype ```c -t8_gloidx_t t8_forest_get_first_local_tree_id (const t8_forest_t forest); +t8_part_tree_t t8_cmesh_trees_get_part (const t8_cmesh_trees_t trees, const int proc); ``` """ -function t8_forest_get_first_local_tree_id(forest) - @ccall libt8.t8_forest_get_first_local_tree_id(forest::t8_forest_t)::t8_gloidx_t +function t8_cmesh_trees_get_part(trees, proc) + @ccall libt8.t8_cmesh_trees_get_part(trees::t8_cmesh_trees_t, proc::Cint)::t8_part_tree_t end """ - t8_forest_get_num_local_trees(forest) + t8_cmesh_trees_start_part(trees, proc, lfirst_tree, num_trees, lfirst_ghost, num_ghosts, alloc) -Return the number of local trees of a given forest. +Allocate the first\\_tree array of a given tree\\_part in a tree struct with a given number of trees and ghosts. This function allocates the memory for the trees and the ghosts but not for their face neighbor entries or attributes. These must be allocated later when the eclasses of the trees and ghosts are known t8_cmesh_trees_finish_part. # Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of local trees of that forest. +* `trees`:\\[in,out\\] The trees structure to be updated. +* `proc`:\\[in\\] The index of the part to be updated. +* `lfirst_tree`:\\[in\\] The local id of the first tree of that part. +* `num_trees`:\\[in\\] The number of trees of that part. +* `lfirst_ghost`:\\[in\\] The local id of the first ghost of that part. +* `num_ghosts`:\\[in\\] The number of ghosts of that part. +* `alloc`:\\[in\\] If true then the first\\_tree array is allocated for the number of trees and ghosts. When a cmesh is copied we do not want this, so in we pass alloc = 0 then. ### Prototype ```c -t8_locidx_t t8_forest_get_num_local_trees (const t8_forest_t forest); +void t8_cmesh_trees_start_part (t8_cmesh_trees_t trees, int proc, t8_locidx_t lfirst_tree, t8_locidx_t num_trees, t8_locidx_t lfirst_ghost, t8_locidx_t num_ghosts, int alloc); ``` """ -function t8_forest_get_num_local_trees(forest) - @ccall libt8.t8_forest_get_num_local_trees(forest::t8_forest_t)::t8_locidx_t +function t8_cmesh_trees_start_part(trees, proc, lfirst_tree, num_trees, lfirst_ghost, num_ghosts, alloc) + @ccall libt8.t8_cmesh_trees_start_part(trees::t8_cmesh_trees_t, proc::Cint, lfirst_tree::t8_locidx_t, num_trees::t8_locidx_t, lfirst_ghost::t8_locidx_t, num_ghosts::t8_locidx_t, alloc::Cint)::Cvoid end """ - t8_forest_get_num_ghost_trees(forest) + t8_cmesh_trees_finish_part(trees, proc) -Return the number of ghost trees of a given forest. +After all classes of trees and ghosts have been set and after the number of tree attributes was set and their total size (per tree) stored temporarily in the att\\_offset variable we grow the part array by the needed amount of memory and set the offsets appropriately. The workflow should be: call t8_cmesh_trees_start_part, set tree and ghost classes maually via t8_cmesh_trees_add_tree and t8_cmesh_trees_add_ghost, call t8_cmesh_trees_init_attributes, then call this function. Afterwards successively call t8_cmesh_trees_add_attribute for each attribute and also set all face neighbors (TODO: write function). # Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of ghost trees of that forest. +* `trees`:\\[in,out\\] The trees structure to be updated. +* `proc`:\\[in\\] The number of the part to be finished. ### Prototype ```c -t8_locidx_t t8_forest_get_num_ghost_trees (const t8_forest_t forest); +void t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc); ``` """ -function t8_forest_get_num_ghost_trees(forest) - @ccall libt8.t8_forest_get_num_ghost_trees(forest::t8_forest_t)::t8_locidx_t +function t8_cmesh_trees_finish_part(trees, proc) + @ccall libt8.t8_cmesh_trees_finish_part(trees::t8_cmesh_trees_t, proc::Cint)::Cvoid end """ - t8_forest_get_num_global_trees(forest) + t8_cmesh_trees_copy_toproc(trees_dest, trees_src, lnum_trees, lnum_ghosts) -Return the number of global trees of a given forest. +Copy the tree\\_to\\_proc and ghost\\_to\\_proc arrays of one tree structure to another one. # Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of global trees of that forest. +* `trees_dest`:\\[in,out\\] The destination trees structure. +* `trees_src`:\\[in\\] The source trees structure. +* `lnum_trees`:\\[in\\] The total number of trees stored in *trees_src*. +* `lnum_ghosts`:\\[in\\] The total number of ghosts stored in *trees_src*. ### Prototype ```c -t8_gloidx_t t8_forest_get_num_global_trees (const t8_forest_t forest); +void t8_cmesh_trees_copy_toproc (t8_cmesh_trees_t trees_dest, t8_cmesh_trees_t trees_src, t8_locidx_t lnum_trees, t8_locidx_t lnum_ghosts); ``` """ -function t8_forest_get_num_global_trees(forest) - @ccall libt8.t8_forest_get_num_global_trees(forest::t8_forest_t)::t8_gloidx_t +function t8_cmesh_trees_copy_toproc(trees_dest, trees_src, lnum_trees, lnum_ghosts) + @ccall libt8.t8_cmesh_trees_copy_toproc(trees_dest::t8_cmesh_trees_t, trees_src::t8_cmesh_trees_t, lnum_trees::t8_locidx_t, lnum_ghosts::t8_locidx_t)::Cvoid end """ - t8_forest_global_tree_id(forest, ltreeid) + t8_cmesh_trees_copy_part(trees_dest, part_dest, trees_src, part_src) -Return the global id of a local tree or a ghost tree. +Copy the trees array from one part to another. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] An id 0 <= *ltreeid* < num\\_local\\_trees + num\\_ghosts specifying a local tree or ghost tree. -# Returns -The global id corresponding to the tree with local id *ltreeid*. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +* `trees_dest`:\\[in,out\\] The trees struct of the destination part. +* `part_dest`:\\[in\\] The index of the destination part. Must be initialized by t8_cmesh_trees_start_part with alloc = 0. +* `trees_src`:\\[in\\] The trees struct of the source part. +* `part_src`:\\[in\\] The index of the destination part. Must be a valid part, thus t8_cmesh_trees_finish_part must have been called. ### Prototype ```c -t8_gloidx_t t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid); +void t8_cmesh_trees_copy_part (t8_cmesh_trees_t trees_dest, int part_dest, t8_cmesh_trees_t trees_src, int part_src); ``` """ -function t8_forest_global_tree_id(forest, ltreeid) - @ccall libt8.t8_forest_global_tree_id(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_gloidx_t +function t8_cmesh_trees_copy_part(trees_dest, part_dest, trees_src, part_src) + @ccall libt8.t8_cmesh_trees_copy_part(trees_dest::t8_cmesh_trees_t, part_dest::Cint, trees_src::t8_cmesh_trees_t, part_src::Cint)::Cvoid end """ - t8_forest_get_tree(forest, ltree_id) + t8_cmesh_trees_add_tree(trees, ltree_id, proc, eclass) -Return a pointer to a tree in a forest. +Add a tree to a trees structure. # Arguments -* `forest`:\\[in\\] The forest. -* `ltree_id`:\\[in\\] The local id of the tree. -# Returns -A pointer to the tree with local id *ltree_id*. *forest* must be committed before calling this function. +* `trees`:\\[in,out\\] The trees structure to be updated. +* `tree_id`:\\[in\\] The local id of the tree to be inserted. +* `proc`:\\[in\\] The mpirank of the process from which the tree was received. +* `eclass`:\\[in\\] The tree's element class. ### Prototype ```c -t8_tree_t t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id); +void t8_cmesh_trees_add_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, int proc, t8_eclass_t eclass); ``` """ -function t8_forest_get_tree(forest, ltree_id) - @ccall libt8.t8_forest_get_tree(forest::t8_forest_t, ltree_id::t8_locidx_t)::t8_tree_t +function t8_cmesh_trees_add_tree(trees, ltree_id, proc, eclass) + @ccall libt8.t8_cmesh_trees_add_tree(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, proc::Cint, eclass::t8_eclass_t)::Cvoid end """ - t8_forest_get_tree_vertices(forest, ltreeid) + t8_cmesh_trees_add_ghost(trees, lghost_index, gtree_id, proc, eclass, num_local_trees) -Return a pointer to the vertex coordinates of a tree. +Add a ghost to a trees structure. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The id of a local tree. -# Returns -If stored, a pointer to the vertex coordinates of *tree*. If no coordinates for this tree are found, NULL. +* `trees`:\\[in,out\\] The trees structure to be updated. +* `ghost_index`:\\[in\\] The index in the part array of the ghost to be inserted. +* `tree_id`:\\[in\\] The global index of the ghost. +* `proc`:\\[in\\] The mpirank of the process from which the ghost was received. +* `eclass`:\\[in\\] The ghost's element class. +* `num_local_trees`:\\[in\\] The number of local trees in the cmesh. ### Prototype ```c -double * t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid); +void t8_cmesh_trees_add_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost_index, t8_gloidx_t gtree_id, int proc, t8_eclass_t eclass, t8_locidx_t num_local_trees); ``` """ -function t8_forest_get_tree_vertices(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_vertices(forest::t8_forest_t, ltreeid::t8_locidx_t)::Ptr{Cdouble} +function t8_cmesh_trees_add_ghost(trees, lghost_index, gtree_id, proc, eclass, num_local_trees) + @ccall libt8.t8_cmesh_trees_add_ghost(trees::t8_cmesh_trees_t, lghost_index::t8_locidx_t, gtree_id::t8_gloidx_t, proc::Cint, eclass::t8_eclass_t, num_local_trees::t8_locidx_t)::Cvoid end """ - t8_forest_tree_get_leaf_elements(forest, ltree_id) + t8_cmesh_trees_set_all_boundary(cmesh, trees) -Return the array of leaf elements of a local tree in a forest. +Set all neighbor fields of all local trees and ghosts to boundary. # Arguments -* `forest`:\\[in\\] The forest. -* `ltree_id`:\\[in\\] The local id of a local tree of *forest*. -# Returns -An array of [`t8_element_t`](@ref) * storing all leaf elements of this tree. +* `cmesh,`:\\[in,out\\] The associated cmesh. +* `trees,`:\\[in,out\\] The trees structure. A face f of tree t counts as boundary if the face-neighbor is also t at face f. ### Prototype ```c -t8_element_array_t * t8_forest_tree_get_leaf_elements (const t8_forest_t forest, const t8_locidx_t ltree_id); +void t8_cmesh_trees_set_all_boundary (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); ``` """ -function t8_forest_tree_get_leaf_elements(forest, ltree_id) - @ccall libt8.t8_forest_tree_get_leaf_elements(forest::t8_forest_t, ltree_id::t8_locidx_t)::Ptr{t8_element_array_t} +function t8_cmesh_trees_set_all_boundary(cmesh, trees) + @ccall libt8.t8_cmesh_trees_set_all_boundary(cmesh::t8_cmesh_t, trees::t8_cmesh_trees_t)::Cvoid end """ - t8_forest_get_cmesh(forest) - -Return a cmesh associated to a forest. + t8_cmesh_trees_get_part_data(trees, proc, first_tree, num_trees, first_ghost, num_ghosts) -# Arguments -* `forest`:\\[in\\] The forest. -# Returns -The cmesh associated to the forest. ### Prototype ```c -t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); +void t8_cmesh_trees_get_part_data (t8_cmesh_trees_t trees, int proc, t8_locidx_t *first_tree, t8_locidx_t *num_trees, t8_locidx_t *first_ghost, t8_locidx_t *num_ghosts); ``` """ -function t8_forest_get_cmesh(forest) - @ccall libt8.t8_forest_get_cmesh(forest::t8_forest_t)::t8_cmesh_t +function t8_cmesh_trees_get_part_data(trees, proc, first_tree, num_trees, first_ghost, num_ghosts) + @ccall libt8.t8_cmesh_trees_get_part_data(trees::t8_cmesh_trees_t, proc::Cint, first_tree::Ptr{t8_locidx_t}, num_trees::Ptr{t8_locidx_t}, first_ghost::Ptr{t8_locidx_t}, num_ghosts::Ptr{t8_locidx_t})::Cvoid end """ - t8_forest_get_leaf_element(forest, lelement_id, ltreeid) + t8_cmesh_trees_get_tree(trees, ltree) -Return a leaf element of the forest. - -!!! note - - This function performs a binary search. For constant access, use t8_forest_get_leaf_element_in_tree *forest* must be committed before calling this function. +Return a pointer to a specific tree in a trees struct. # Arguments -* `forest`:\\[in\\] The forest. -* `lelement_id`:\\[in\\] The local id of a leaf element in *forest*. -* `ltreeid`:\\[out\\] If not NULL, on output the local tree id of the tree in which the leaf element lies in. +* `trees`:\\[in\\] The tress structure where the tree is to be looked up. +* `ltree`:\\[in\\] The local id of the tree. # Returns -A pointer to the leaf element. NULL if this element does not exist. Ghost elements are not considered as local. -# See also -[`t8_forest_ghost_get_leaf_element`](@ref) to access ghost leaf elements. - +A pointer to the tree with local id *tree*. ### Prototype ```c -t8_element_t * t8_forest_get_leaf_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_locidx_t *ltreeid); +t8_ctree_t t8_cmesh_trees_get_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree); ``` """ -function t8_forest_get_leaf_element(forest, lelement_id, ltreeid) - @ccall libt8.t8_forest_get_leaf_element(forest::t8_forest_t, lelement_id::t8_locidx_t, ltreeid::Ptr{t8_locidx_t})::Ptr{t8_element_t} +function t8_cmesh_trees_get_tree(trees, ltree) + @ccall libt8.t8_cmesh_trees_get_tree(trees::t8_cmesh_trees_t, ltree::t8_locidx_t)::t8_ctree_t end """ - t8_forest_get_leaf_element_in_tree(forest, ltreeid, leid_in_tree) - -Return a leaf element of a local tree in a forest. - -!!! note + t8_cmesh_trees_get_tree_ext(trees, ltree_id, face_neigh, ttf) - If the tree id is know, this function should be preferred over t8_forest_get_leaf_element. *forest* must be committed before calling this function. +Return a pointer to a specific tree in a trees struct plus pointers to its face\\_neighbor and tree\\_to\\_face arrays. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] An id of a local tree in the forest. Ghost trees are not considered local. -* `leid_in_tree`:\\[in\\] The index of a leaf element in the tree. +* `trees`:\\[in\\] The trees structure where the tree is to be looked up. +* `ltree_id`:\\[in\\] The local id of the tree. +* `face_neigh`:\\[out\\] If not NULL a pointer to the trees face\\_neighbor array is stored here on return. +* `ttf`:\\[out\\] If not NULL a pointer to the trees tree\\_to\\_face array is stored here on return. # Returns -A pointer to the leaf element. -# See also -t8\\_forest\\_ghost\\_get\\_leaf\\_element\\_in\\_tree to access ghost leaf elements. - +A pointer to the tree with local id *tree*. ### Prototype ```c -const t8_element_t * t8_forest_get_leaf_element_in_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t leid_in_tree); +t8_ctree_t t8_cmesh_trees_get_tree_ext (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, t8_locidx_t **face_neigh, int8_t **ttf); ``` """ -function t8_forest_get_leaf_element_in_tree(forest, ltreeid, leid_in_tree) - @ccall libt8.t8_forest_get_leaf_element_in_tree(forest::t8_forest_t, ltreeid::t8_locidx_t, leid_in_tree::t8_locidx_t)::Ptr{t8_element_t} +function t8_cmesh_trees_get_tree_ext(trees, ltree_id, face_neigh, ttf) + @ccall libt8.t8_cmesh_trees_get_tree_ext(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, face_neigh::Ptr{Ptr{t8_locidx_t}}, ttf::Ptr{Ptr{Int8}})::t8_ctree_t end """ - t8_forest_get_tree_num_leaf_elements(forest, ltreeid) + t8_cmesh_trees_get_face_info(trees, ltreeid, face, ttf) -Return the number of leaf elements of a tree. +Return the face neighbor of a tree at a given face and return the tree\\_to\\_face info # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] A local id of a tree. +* `trees`:\\[in\\] The trees structure where the tree is to be looked up. +* `ltreeid`:\\[in\\] The local id of the tree. +* `face`:\\[in\\] A face of the tree. +* `ttf`:\\[out\\] If not NULL the tree\\_to\\_face value of the face connection. # Returns -The number of leaf elements in the local tree *ltreeid*. +The face neighbor that is stored for this face ### Prototype ```c -t8_locidx_t t8_forest_get_tree_num_leaf_elements (t8_forest_t forest, t8_locidx_t ltreeid); +t8_locidx_t t8_cmesh_trees_get_face_info (t8_cmesh_trees_t trees, t8_locidx_t ltreeid, int face, int8_t *ttf); ``` """ -function t8_forest_get_tree_num_leaf_elements(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_num_leaf_elements(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t +function t8_cmesh_trees_get_face_info(trees, ltreeid, face, ttf) + @ccall libt8.t8_cmesh_trees_get_face_info(trees::t8_cmesh_trees_t, ltreeid::t8_locidx_t, face::Cint, ttf::Ptr{Int8})::t8_locidx_t end """ - t8_forest_get_tree_element_offset(forest, ltreeid) + t8_cmesh_trees_get_face_neighbor(tree, face) -Return the element offset of a local tree, that is the number of leaf elements in all trees with smaller local treeid. - -!!! note - - *forest* must be committed before calling this function. +Given a coarse tree and a face number, return the local id of the neighbor tree. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] A local id of a tree. +* `tree.`:\\[in\\] The coarse tree. +* `face.`:\\[in\\] The face number. # Returns -The number of leaf elements on all local tree with id < *ltreeid*. +The local id of the neighbor tree. ### Prototype ```c -t8_locidx_t t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid); +t8_locidx_t t8_cmesh_trees_get_face_neighbor (const t8_ctree_t tree, const int face); ``` """ -function t8_forest_get_tree_element_offset(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_element_offset(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t +function t8_cmesh_trees_get_face_neighbor(tree, face) + @ccall libt8.t8_cmesh_trees_get_face_neighbor(tree::t8_ctree_t, face::Cint)::t8_locidx_t end """ - t8_forest_get_tree_leaf_element_count(tree) + t8_cmesh_trees_get_face_neighbor_ext(tree, face, ttf) -Return the number of leaf elements of a tree. +Given a coarse tree and a face number, return the local id of the neighbor tree together with its tree-to-face info. # Arguments -* `tree`:\\[in\\] A tree in a forest. +* `tree`:\\[in\\] The coarse tree. +* `face`:\\[in\\] The face number. +* `ttf`:\\[out\\] If not NULL it is filled with the tree-to-face value for this face. # Returns -The number of leaf elements of that tree. +The local id of the neighbor tree. ### Prototype ```c -t8_locidx_t t8_forest_get_tree_leaf_element_count (t8_tree_t tree); +t8_locidx_t t8_cmesh_trees_get_face_neighbor_ext (const t8_ctree_t tree, const int face, int8_t *ttf); ``` """ -function t8_forest_get_tree_leaf_element_count(tree) - @ccall libt8.t8_forest_get_tree_leaf_element_count(tree::t8_tree_t)::t8_locidx_t +function t8_cmesh_trees_get_face_neighbor_ext(tree, face, ttf) + @ccall libt8.t8_cmesh_trees_get_face_neighbor_ext(tree::t8_ctree_t, face::Cint, ttf::Ptr{Int8})::t8_locidx_t end """ - t8_forest_get_tree_class(forest, ltreeid) + t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost, face, ttf) -Return the eclass of a tree in a forest. +Given a coarse ghost and a face number, return the local id of the neighbor tree together with its tree-to-face info. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree (local or ghost) in *forest*. +* `ghost`:\\[in\\] The coarse ghost. +* `face`:\\[in\\] The face number. +* `ttf`:\\[out\\] If not NULL it is filled with the tree-to-face value for this face. # Returns -The element class of the tree with local id *ltreeid*. +The global id of the neighbor tree. ### Prototype ```c -t8_eclass_t t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid); +t8_gloidx_t t8_cmesh_trees_get_ghost_face_neighbor_ext (const t8_cghost_t ghost, const int face, int8_t *ttf); ``` """ -function t8_forest_get_tree_class(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_class(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t +function t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost, face, ttf) + @ccall libt8.t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost::t8_cghost_t, face::Cint, ttf::Ptr{Int8})::t8_gloidx_t end """ - t8_forest_get_first_local_leaf_element_id(forest) + t8_cmesh_trees_get_ghost(trees, lghost) -Compute the global index of the first local leaf element of a forest. This function is collective. +Return a pointer to a specific ghost in a trees struct. # Arguments -* `forest`:\\[in\\] A committed forest, whose first leaf element's index is computed. +* `trees`:\\[in\\] The tress structure where the tree is to be looked up. +* `lghost`:\\[in\\] The local id of the ghost. # Returns -The global index of *forest*'s first local leaf element. Forest must be committed when calling this function. This function is collective and must be called on each process. +A pointer to the ghost with local id *ghost*. ### Prototype ```c -t8_gloidx_t t8_forest_get_first_local_leaf_element_id (t8_forest_t forest); +t8_cghost_t t8_cmesh_trees_get_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost); ``` """ -function t8_forest_get_first_local_leaf_element_id(forest) - @ccall libt8.t8_forest_get_first_local_leaf_element_id(forest::t8_forest_t)::t8_gloidx_t +function t8_cmesh_trees_get_ghost(trees, lghost) + @ccall libt8.t8_cmesh_trees_get_ghost(trees::t8_cmesh_trees_t, lghost::t8_locidx_t)::t8_cghost_t end """ - t8_forest_get_scheme(forest) + t8_cmesh_trees_get_ghost_ext(trees, lghost_id, face_neigh, ttf) -Return the element scheme associated to a forest. +Return a pointer to a specific ghost in a trees struct plus pointers to its face\\_neighbor and tree\\_to\\_face arrays. # Arguments -* `forest`:\\[in\\] A committed forest. +* `trees`:\\[in\\] The trees structure where the ghost is to be looked up. +* `lghost_id`:\\[in\\] The local id of the ghost. +* `face_neigh`:\\[out\\] If not NULL a pointer to the ghosts face\\_neighbor array is stored here on return. +* `ttf`:\\[out\\] If not NULL a pointer to the ghosts tree\\_to\\_face array is stored here on return. # Returns -The element scheme of the forest. -# See also -[`t8_forest_set_scheme`](@ref) - +A pointer to the tree with local id *tree*. ### Prototype ```c -const t8_scheme_c * t8_forest_get_scheme (const t8_forest_t forest); +t8_cghost_t t8_cmesh_trees_get_ghost_ext (t8_cmesh_trees_t trees, t8_locidx_t lghost_id, t8_gloidx_t **face_neigh, int8_t **ttf); ``` """ -function t8_forest_get_scheme(forest) - @ccall libt8.t8_forest_get_scheme(forest::t8_forest_t)::Ptr{t8_scheme_c} +function t8_cmesh_trees_get_ghost_ext(trees, lghost_id, face_neigh, ttf) + @ccall libt8.t8_cmesh_trees_get_ghost_ext(trees::t8_cmesh_trees_t, lghost_id::t8_locidx_t, face_neigh::Ptr{Ptr{t8_gloidx_t}}, ttf::Ptr{Ptr{Int8}})::t8_cghost_t end """ - t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) + t8_cmesh_trees_get_ghost_local_id(trees, global_id) -Return the eclass of the tree in which a face neighbor of a given element or ghost lies. +Given the global tree id of a ghost tree in a trees structure, return its local ghost id. # Arguments -* `forest`:\\[in\\] A committed forest. -* `ltreeid`:\\[in\\] The local tree or ghost tree in which the element lies. 0 <= *ltreeid* < num\\_local\\_trees + num\\_ghost\\_trees -* `elem`:\\[in\\] An element or ghost in the tree *ltreeid*. -* `face`:\\[in\\] A face number of *elem*. +* `trees`:\\[in\\] The trees structure. +* `global_id`:\\[in\\] A global tree id. # Returns -The eclass of the local tree or ghost tree that is face neighbor of *elem* across *face*. T8\\_ECLASS\\_INVALID if no neighbor exists. +The local id of the tree *global_id* if it is a ghost in *trees*. A negative number if it isn't. The local id is a number l with num\\_local\\_trees <= *l* < num\\_local\\_trees + num\\_ghosts ### Prototype ```c -t8_eclass_t t8_forest_element_neighbor_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *elem, const int face); +t8_locidx_t t8_cmesh_trees_get_ghost_local_id (t8_cmesh_trees_t trees, t8_gloidx_t global_id); ``` """ -function t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) - @ccall libt8.t8_forest_element_neighbor_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, face::Cint)::t8_eclass_t +function t8_cmesh_trees_get_ghost_local_id(trees, global_id) + @ccall libt8.t8_cmesh_trees_get_ghost_local_id(trees::t8_cmesh_trees_t, global_id::t8_gloidx_t)::t8_locidx_t end """ - t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_eclass, face, neigh_face) - -Construct the face neighbor of an element, possibly across tree boundaries. Returns the global tree-id of the tree in which the neighbor element lies in. + t8_cmesh_trees_size(trees) -# Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local tree in which the element lies. -* `elem`:\\[in\\] The element to be considered. -* `neigh`:\\[in,out\\] On input an allocated element of the scheme of the face\\_neighbors eclass. On output, this element's data is filled with the data of the face neighbor. If the neighbor does not exist the data could be modified arbitrarily. -* `neigh_eclass`:\\[in\\] The eclass of *neigh*. -* `face`:\\[in\\] The number of the face along which the neighbor should be constructed. -* `neigh_face`:\\[out\\] The number of the face viewed from perspective of *neigh*. Can be nullptr, in which case the output is discarded. -# Returns -The global tree-id of the tree in which *neigh* is in. -1 if there exists no neighbor across that face. Domain boundary. -2 if the neighbor is not in a local tree or ghost tree. Process/Ghost boundary. ### Prototype ```c -t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, const t8_eclass_t neigh_eclass, int face, int *neigh_face); +size_t t8_cmesh_trees_size (t8_cmesh_trees_t trees); ``` """ -function t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_eclass, face, neigh_face) - @ccall libt8.t8_forest_element_face_neighbor(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, neigh::Ptr{t8_element_t}, neigh_eclass::t8_eclass_t, face::Cint, neigh_face::Ptr{Cint})::t8_gloidx_t +function t8_cmesh_trees_size(trees) + @ccall libt8.t8_cmesh_trees_size(trees::t8_cmesh_trees_t)::Csize_t end """ - t8_forest_iterate(forest) + t8_cmesh_trees_init_attributes(trees, ltree_id, num_attributes, attr_bytes) -TODO: Can be removed since it is unused. +For one tree in a trees structure set the number of attributes and temporarily store the total size of all of this tree's attributes. This temporary value is used in t8_cmesh_trees_finish_part. # Arguments -* `forest`:\\[in\\] The forest. +* `trees`:\\[in,out\\] The trees structure to be updated. +* `ltree_id`:\\[in\\] The local id of one tree in *trees*. +* `num_attributes`:\\[in\\] The number of attributes of this tree. +* `attr_bytes`:\\[in\\] The total number of bytes of all attributes of this tree. ### Prototype ```c -void t8_forest_iterate (t8_forest_t forest); +void t8_cmesh_trees_init_attributes (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, size_t num_attributes, size_t attr_bytes); ``` """ -function t8_forest_iterate(forest) - @ccall libt8.t8_forest_iterate(forest::t8_forest_t)::Cvoid +function t8_cmesh_trees_init_attributes(trees, ltree_id, num_attributes, attr_bytes) + @ccall libt8.t8_cmesh_trees_init_attributes(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, num_attributes::Csize_t, attr_bytes::Csize_t)::Cvoid end """ - t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) - -Query whether a batch of points lies inside an element. For bilinearly interpolated elements. - -!!! note + t8_cmesh_trees_get_attribute(trees, ltree_id, package_id, key, size, is_ghost) - For 2D quadrilateral elements this function is only an approximation. It is correct if the four vertices lie in the same plane, but it may produce only approximate results if the vertices do not lie in the same plane. +Return an attribute that is stored at a tree. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The forest local id of the tree in which the element is. -* `element`:\\[in\\] The element. -* `points`:\\[in\\] 3-dimensional coordinates of the points to check -* `num_points`:\\[in\\] The number of points to check -* `is_inside`:\\[in,out\\] An array of length *num_points*, filled with 0/1 on output. True (non-zero) if a *point* lies within an *element*, false otherwise. The return value is also true if the point lies on the element boundary. Thus, this function may return true for different leaf elements, if they are neighbors and the point lies on the common boundary. -* `tolerance`:\\[in\\] Tolerance that we allow the point to not exactly match the element. If this value is larger we detect more points. If it is zero we probably do not detect points even if they are inside due to rounding errors. +* `trees`:\\[in\\] The trees structure. +* `ltree_id`:\\[in\\] The local id of the tree whose attribute is querid. +* `package_id`:\\[in\\] The package identifier of the attribute. +* `key`:\\[in\\] The key of the attribute within all attributes of the same package identifier. +* `size`:\\[out\\] If not NULL, the size (in bytes) of the attribute will be stored here. +* `is_ghost`:\\[in\\] If true, then *ltree_id* is interpreted as the local\\_id of a ghost. +# Returns +A pointer to the queried attribute, NULL if the attribute does not exist. ### Prototype ```c -void t8_forest_element_points_inside (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, int num_points, int *is_inside, const double tolerance); +void * t8_cmesh_trees_get_attribute (const t8_cmesh_trees_t trees, const t8_locidx_t ltree_id, const int package_id, const int key, size_t *size, int is_ghost); ``` """ -function t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) - @ccall libt8.t8_forest_element_points_inside(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, points::Ptr{Cdouble}, num_points::Cint, is_inside::Ptr{Cint}, tolerance::Cdouble)::Cvoid +function t8_cmesh_trees_get_attribute(trees, ltree_id, package_id, key, size, is_ghost) + @ccall libt8.t8_cmesh_trees_get_attribute(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, package_id::Cint, key::Cint, size::Ptr{Csize_t}, is_ghost::Cint)::Ptr{Cvoid} end """ - t8_forest_element_find_owner(forest, gtreeid, element, eclass) - -Find the owner process of a given element. - -!!! note + t8_cmesh_trees_attribute_size(tree) - The element must not exist in the forest, but an ancestor of its first descendant has to. If the element's owner is not unique, the owner of the element's first descendant is returned. - -!!! note - - *forest* must be committed before calling this function. +Return the total size of all attributes stored at a specified tree. # Arguments -* `forest`:\\[in\\] The forest. -* `gtreeid`:\\[in\\] The global id of the tree in which the element lies. -* `element`:\\[in\\] The element to look for. -* `eclass`:\\[in\\] The element class of the tree *gtreeid*. +* `tree`:\\[in\\] A tree structure. # Returns -The mpirank of the process that owns *element*. -# See also -t8\\_forest\\_element\\_find\\_owner\\_ext, t8\\_forest\\_element\\_owners\\_bounds - +The total size (in bytes) of the attributes of *tree*. ### Prototype ```c -int t8_forest_element_find_owner (t8_forest_t forest, t8_gloidx_t gtreeid, t8_element_t *element, t8_eclass_t eclass); +size_t t8_cmesh_trees_attribute_size (t8_ctree_t tree); ``` """ -function t8_forest_element_find_owner(forest, gtreeid, element, eclass) - @ccall libt8.t8_forest_element_find_owner(forest::t8_forest_t, gtreeid::t8_gloidx_t, element::Ptr{t8_element_t}, eclass::t8_eclass_t)::Cint +function t8_cmesh_trees_attribute_size(tree) + @ccall libt8.t8_cmesh_trees_attribute_size(tree::t8_ctree_t)::Csize_t end """ - t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) + t8_cmesh_trees_ghost_attribute_size(ghost) +Return the total size of all attributes stored at a specified ghost. + +# Arguments +* `ghost`:\\[in\\] A ghost structure. +# Returns +The total size (in bytes) of the attributes of *ghost*. ### Prototype ```c -t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, const t8_scheme_c *scheme, const int level, const int do_face_ghost, sc_MPI_Comm comm); +size_t t8_cmesh_trees_ghost_attribute_size (t8_cghost_t ghost); ``` """ -function t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) - @ccall libt8.t8_forest_new_uniform(cmesh::t8_cmesh_t, scheme::Ptr{t8_scheme_c}, level::Cint, do_face_ghost::Cint, comm::MPI_Comm)::t8_forest_t +function t8_cmesh_trees_ghost_attribute_size(ghost) + @ccall libt8.t8_cmesh_trees_ghost_attribute_size(ghost::t8_cghost_t)::Csize_t end """ - t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) - -Build a adapted forest from another forest. - -!!! note - - This is equivalent to calling t8_forest_init, t8_forest_set_adapt, t8_forest_set_ghost, and t8_forest_commit + t8_cmesh_trees_add_attribute(trees, proc, attr, tree_id, index) -# Arguments -* `forest_from`:\\[in\\] The forest to refine -* `adapt_fn`:\\[in\\] Adapt function to use -* `recursive`:\\[in\\] If true adaptation is recursive -* `do_face_ghost`:\\[in\\] If true, a layer of ghost elements is created for the forest. -* `user_data`:\\[in\\] If not NULL, the user data pointer of the forest is set to this value. -# Returns -A new forest that is adapted from *forest_from*. ### Prototype ```c -t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, int recursive, int do_face_ghost, void *user_data); +void t8_cmesh_trees_add_attribute (const t8_cmesh_trees_t trees, int proc, const t8_stash_attribute_struct_t *attr, t8_locidx_t tree_id, size_t index); ``` """ -function t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) - @ccall libt8.t8_forest_new_adapt(forest_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint, do_face_ghost::Cint, user_data::Ptr{Cvoid})::t8_forest_t +function t8_cmesh_trees_add_attribute(trees, proc, attr, tree_id, index) + @ccall libt8.t8_cmesh_trees_add_attribute(trees::t8_cmesh_trees_t, proc::Cint, attr::Ptr{t8_stash_attribute_struct_t}, tree_id::t8_locidx_t, index::Csize_t)::Cvoid end """ - t8_forest_ref(forest) + t8_cmesh_trees_add_ghost_attribute(trees, attr, local_ghost_id, ghosts_inserted, index) -Increase the reference counter of a forest. +Add the next ghost attribute from stash to the correct position in the char pointer structure Since it is created from stash, all attributes are added to part 0. The following attribute offset gets updated already. # Arguments -* `forest`:\\[in,out\\] On input, this forest must exist with positive reference count. It may be in any state. +* `trees`:\\[in,out\\] The trees structure, whose char array is updated. +* `attr`:\\[in\\] The stash attribute that is added. +* `local_ghost_id`:\\[in\\] The local ghost id. +* `ghosts_inserted`:\\[in\\] The number of ghost that were already inserted, so that we do not write over the end. +* `index`:\\[in\\] The attribute index of the attribute to be added. ### Prototype ```c -void t8_forest_ref (t8_forest_t forest); +void t8_cmesh_trees_add_ghost_attribute (const t8_cmesh_trees_t trees, const t8_stash_attribute_struct_t *attr, t8_locidx_t local_ghost_id, t8_locidx_t ghosts_inserted, size_t index); ``` """ -function t8_forest_ref(forest) - @ccall libt8.t8_forest_ref(forest::t8_forest_t)::Cvoid +function t8_cmesh_trees_add_ghost_attribute(trees, attr, local_ghost_id, ghosts_inserted, index) + @ccall libt8.t8_cmesh_trees_add_ghost_attribute(trees::t8_cmesh_trees_t, attr::Ptr{t8_stash_attribute_struct_t}, local_ghost_id::t8_locidx_t, ghosts_inserted::t8_locidx_t, index::Csize_t)::Cvoid end """ - t8_forest_unref(pforest) + t8_cmesh_trees_get_numproc(trees) -Decrease the reference counter of a forest. If the counter reaches zero, this forest is destroyed. In this case, the forest dereferences its cmesh and scheme members. +Return the number of parts of a trees structure. # Arguments -* `pforest`:\\[in,out\\] On input, the forest pointed to must exist with positive reference count. It may be in any state. If the reference count reaches zero, the forest is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the forest is not modified in other ways. +* `trees`:\\[in\\] The trees structure. +# Returns +The number of parts in *trees*. ### Prototype ```c -void t8_forest_unref (t8_forest_t *pforest); +size_t t8_cmesh_trees_get_numproc (const t8_cmesh_trees_t trees); ``` """ -function t8_forest_unref(pforest) - @ccall libt8.t8_forest_unref(pforest::Ptr{t8_forest_t})::Cvoid +function t8_cmesh_trees_get_numproc(trees) + @ccall libt8.t8_cmesh_trees_get_numproc(trees::t8_cmesh_trees_t)::Csize_t end """ - t8_forest_get_dimension(forest) + t8_cmesh_tree_to_face_encode(dimension, face, orientation) + +Compute the tree-to-face information given a face and orientation value of a face connection. +# Arguments +* `dimension`:\\[in\\] The dimension of the corresponding eclasses. +* `face`:\\[in\\] A face number +* `orientation`:\\[in\\] A face-to-face orientation. +# Returns +The tree-to-face entry corresponding to the face/orientation combination. It is computed as t8\\_eclass\\_max\\_num\\_faces[dimension] * orientation + face ### Prototype ```c -int t8_forest_get_dimension (const t8_forest_t forest); +int8_t t8_cmesh_tree_to_face_encode (const int dimension, const t8_locidx_t face, const int orientation); ``` """ -function t8_forest_get_dimension(forest) - @ccall libt8.t8_forest_get_dimension(forest::t8_forest_t)::Cint +function t8_cmesh_tree_to_face_encode(dimension, face, orientation) + @ccall libt8.t8_cmesh_tree_to_face_encode(dimension::Cint, face::t8_locidx_t, orientation::Cint)::Int8 end """ - t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) + t8_cmesh_tree_to_face_decode(dimension, tree_to_face, face, orientation) + +Given a tree-to-face value, get its encoded face number and orientation. + +!!! note + + This function is the inverse operation of t8_cmesh_tree_to_face_encode If F = t8\\_eclass\\_max\\_num\\_faces[dimension], we get orientation = tree\\_to\\_face / F face = tree\\_to\\_face % F +# Arguments +* `dimension`:\\[in\\] The dimension of the corresponding eclasses. +* `tree_to_face`:\\[in\\] A tree-to-face value +* `face`:\\[out\\] On output filled with the stored face value. +* `orientation`:\\[out\\] On output filled with the stored orientation value. ### Prototype ```c -void t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8_element_t *element, int corner_number, double *coordinates); +void t8_cmesh_tree_to_face_decode (const int dimension, const int8_t tree_to_face, int *face, int *orientation); ``` """ -function t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) - @ccall libt8.t8_forest_element_coordinate(forest::t8_forest_t, ltree_id::t8_locidx_t, element::Ptr{t8_element_t}, corner_number::Cint, coordinates::Ptr{Cdouble})::Cvoid +function t8_cmesh_tree_to_face_decode(dimension, tree_to_face, face, orientation) + @ccall libt8.t8_cmesh_tree_to_face_decode(dimension::Cint, tree_to_face::Int8, face::Ptr{Cint}, orientation::Ptr{Cint})::Cvoid end """ - t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) + t8_cmesh_trees_print(cmesh, trees) + +Print the trees,ghosts and their neighbors in ASCII format t stdout. This function is used for debugging purposes. +# Arguments +* `cmesh`:\\[in\\] A coarse mesh structure that must be committed. +* `trees`:\\[in\\] The trees structure of *cmesh*. ### Prototype ```c -void t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out, const double *stretch_factors); +void t8_cmesh_trees_print (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); ``` """ -function t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) - @ccall libt8.t8_forest_element_from_ref_coords_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble}, stretch_factors::Ptr{Cdouble})::Cvoid +function t8_cmesh_trees_print(cmesh, trees) + @ccall libt8.t8_cmesh_trees_print(cmesh::t8_cmesh_t, trees::t8_cmesh_trees_t)::Cvoid end """ - t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) + t8_cmesh_trees_bcast(cmesh_in, root, comm) ### Prototype ```c -void t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out); +void t8_cmesh_trees_bcast (t8_cmesh_t cmesh_in, int root, sc_MPI_Comm comm); ``` """ -function t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) - @ccall libt8.t8_forest_element_from_ref_coords(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble})::Cvoid +function t8_cmesh_trees_bcast(cmesh_in, root, comm) + @ccall libt8.t8_cmesh_trees_bcast(cmesh_in::t8_cmesh_t, root::Cint, comm::MPI_Comm)::Cvoid end """ - t8_forest_element_centroid(forest, ltreeid, element, coordinates) + t8_cmesh_trees_is_face_consistent(cmesh, trees) + +Check whether the face connection of a trees structure are consistent. That is if tree1 lists tree2 as neighbor at face i with ttf entries (or,face j), then tree2 must list tree1 as neighbor at face j with ttf entries (or, face i). +# Arguments +* `cmesh`:\\[in\\] A cmesh structure to be checked. +* `trees`:\\[in\\] The cmesh's trees struct. +# Returns +True if the face connections are consistent, False if not. ### Prototype ```c -void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); +int t8_cmesh_trees_is_face_consistent (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); ``` -""" -function t8_forest_element_centroid(forest, ltreeid, element, coordinates) - @ccall libt8.t8_forest_element_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, coordinates::Ptr{Cdouble})::Cvoid +""" +function t8_cmesh_trees_is_face_consistent(cmesh, trees) + @ccall libt8.t8_cmesh_trees_is_face_consistent(cmesh::t8_cmesh_t, trees::t8_cmesh_trees_t)::Cint end """ - t8_forest_element_diam(forest, ltreeid, element) + t8_cmesh_trees_is_equal(cmesh, trees_a, trees_b) ### Prototype ```c -double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); +int t8_cmesh_trees_is_equal (t8_cmesh_t cmesh, t8_cmesh_trees_t trees_a, t8_cmesh_trees_t trees_b); ``` """ -function t8_forest_element_diam(forest, ltreeid, element) - @ccall libt8.t8_forest_element_diam(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble +function t8_cmesh_trees_is_equal(cmesh, trees_a, trees_b) + @ccall libt8.t8_cmesh_trees_is_equal(cmesh::t8_cmesh_t, trees_a::t8_cmesh_trees_t, trees_b::t8_cmesh_trees_t)::Cint end """ - t8_forest_element_volume(forest, ltreeid, element) + t8_cmesh_trees_destroy(trees) +Free all memory allocated with a trees structure. This means that all coarse trees and ghosts, their face neighbor entries and attributes and the additional structures of trees are freed. + +# Arguments +* `trees`:\\[in,out\\] The tree structure to be destroyed. Set to NULL on output. ### Prototype ```c -double t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); +void t8_cmesh_trees_destroy (t8_cmesh_trees_t *trees); ``` """ -function t8_forest_element_volume(forest, ltreeid, element) - @ccall libt8.t8_forest_element_volume(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble +function t8_cmesh_trees_destroy(trees) + @ccall libt8.t8_cmesh_trees_destroy(trees::Ptr{t8_cmesh_trees_t})::Cvoid end """ - t8_forest_element_face_area(forest, ltreeid, element, face) +This structure holds the connectivity data of the coarse mesh. It can either be replicated, then each process stores a copy of the whole mesh, or partitioned. In the latter case, each process only stores a local portion of the mesh plus information about ghost elements. -### Prototype -```c -double t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face); -``` +The coarse mesh is a collection of coarse trees that can be identified along faces. TODO: this description is outdated. rewrite it. The array ctrees stores these coarse trees sorted by their (global) tree\\_id. If the mesh if partitioned it is partitioned according to an (possible only virtually existing) underlying fine mesh. Therefore the ctrees array can store duplicated trees on different processes, if each of these processes owns elements of the same tree in the fine mesh. + +Each tree stores information about its face-neighbours in an array of t8_ctree_fneighbor. + +If partitioned the ghost trees are stored in a hash table that is backed up by an array. The hash value of a ghost tree is its tree\\_id modulo the number of ghosts on this process. + +# See also +t8\\_ctree\\_fneighbor """ -function t8_forest_element_face_area(forest, ltreeid, element, face) - @ccall libt8.t8_forest_element_face_area(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint)::Cdouble +const t8_cmesh_struct_t = t8_cmesh + +const t8_cghost_struct_t = t8_cghost + +"""This structure holds the data of a local tree including the information about face neighbors. For those the tree\\_to\\_face index is computed as follows. Let F be the maximal number of faces of any eclass of the cmesh's dimension, then ttf % F is the face number and ttf / F is the orientation. (t8_eclass_max_num_faces) The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees. We chose a main\\_face from them as follows: Either both trees have the same element class, then the face with the lower face number is the main\\_face or the trees belong to different classes in which case the face belonging to the tree with the lower class according to the ordering triangle < square, hex < tet < prism < pyramid, is the main\\_face. Then face corner 0 of the main\\_face connects to a face corner k in the other face. The face orientation is defined as the number k. If the classes are equal and my\\_face == other\\_face, treating either of both faces as the main\\_face leads to the same result. See https://arxiv.org/pdf/1611.02929.pdf for more details.""" +const t8_ctree_struct_t = t8_ctree + +const t8_cmesh_trees_struct_t = t8_cmesh_trees + +const t8_part_tree_struct_t = t8_part_tree + +""" +This struct is used to profile cmesh algorithms. The cmesh struct stores a pointer to a profile struct, and if it is nonzero, various runtimes and data measurements are stored here. + +# See also +[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) +""" +const t8_cprofile_struct_t = t8_cprofile + +""" + t8_element_array_t + +The [`t8_element_array_t`](@ref) is an array to store [`t8_element_t`](@ref) * of a given eclass\\_scheme implementation. It is a wrapper around sc_array_t. Each time, a new element is created by the functions for t8_element_array_t, the eclass function either t8_element_new or t8_element_init is called for the element. Thus, each element in a t8_element_array_t is automatically initialized properly. + +| Field | Note | +| :----- | :--------------------------------------------------- | +| scheme | An eclass scheme of which elements should be stored | +| array | The array in which the elements are stored | +""" +struct t8_element_array_t + scheme::Ptr{t8_eclass_scheme_c} + array::sc_array_t end """ - t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) + t8_element_array_new(scheme) +Creates a new array structure with 0 elements. + +# Arguments +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +# Returns +Return an allocated array of zero length. ### Prototype ```c -void t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double centroid[3]); +t8_element_array_t * t8_element_array_new (t8_eclass_scheme_c *scheme); ``` """ -function t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) - @ccall libt8.t8_forest_element_face_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, centroid::Ptr{Cdouble})::Cvoid +function t8_element_array_new(scheme) + @ccall libt8.t8_element_array_new(scheme::Ptr{t8_eclass_scheme_c})::Ptr{t8_element_array_t} end """ - t8_forest_element_face_normal(forest, ltreeid, element, face, normal) + t8_element_array_new_count(scheme, num_elements) + +Creates a new array structure with a given length (number of elements) and calls t8_element_new for those elements. +# Arguments +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `num_elements`:\\[in\\] Initial number of array elements. +# Returns +Return an allocated array with allocated and initialized elements for which t8_element_new was called. ### Prototype ```c -void t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double normal[3]); +t8_element_array_t * t8_element_array_new_count (t8_eclass_scheme_c *scheme, size_t num_elements); ``` """ -function t8_forest_element_face_normal(forest, ltreeid, element, face, normal) - @ccall libt8.t8_forest_element_face_normal(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, normal::Ptr{Cdouble})::Cvoid +function t8_element_array_new_count(scheme, num_elements) + @ccall libt8.t8_element_array_new_count(scheme::Ptr{t8_eclass_scheme_c}, num_elements::Csize_t)::Ptr{t8_element_array_t} end -"""We can reuse the reference counter type from libsc.""" -const t8_refcount_t = sc_refcount_t - """ - t8_forest_ghost + t8_element_array_init(element_array, scheme) -This struct stores various information about a forest's ghost elements and ghost trees. +Initializes an already allocated (or static) array structure. -| Field | Note | -| :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| rc | The reference counter. | -| num\\_ghosts\\_elements | The count of non-local ghost leaf elements | -| num\\_remote\\_elements | The count of local leaf elements that are ghost to another process. | -| ghost\\_type | Describes which neighbors are considered ghosts. | -| ghost\\_trees | ghost tree data: global\\_id. eclass. elements. In linear id order | -| global\\_tree\\_to\\_ghost\\_tree | Indexes into ghost\\_trees. Given a global tree id I give the index i such that the tree is in ghost\\_trees[i] | -| process\\_offsets | Given a process, return the first ghost tree and within it the first element of that process. | -| remote\\_ghosts | array of local trees that have ghost elements for another process. for each tree an array of [`t8_element_t`](@ref) * of the local ghost elements. Also an array of [`t8_locidx_t`](@ref) of the local indices of these elements within the tree. It is a hash table, hashed with the rank of a remote process. Sorted within each process by linear id. | -| remote\\_processes | The ranks of the processes for which local elements are ghost. Array of int's. | -| glo\\_tree\\_mempool | The global tree memory pool. | -| proc\\_offset\\_mempool | The process offset memory pool. | +# Arguments +* `element_array`:\\[in,out\\] Array structure to be initialized. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +### Prototype +```c +void t8_element_array_init (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme); +``` """ -struct t8_forest_ghost - rc::t8_refcount_t - num_ghosts_elements::t8_locidx_t - num_remote_elements::t8_locidx_t - ghost_type::t8_ghost_type_t - ghost_trees::Ptr{sc_array_t} - global_tree_to_ghost_tree::Ptr{sc_hash_t} - process_offsets::Ptr{sc_hash_t} - remote_ghosts::Ptr{sc_hash_array_t} - remote_processes::Ptr{sc_array_t} - glo_tree_mempool::Ptr{sc_mempool_t} - proc_offset_mempool::Ptr{sc_mempool_t} +function t8_element_array_init(element_array, scheme) + @ccall libt8.t8_element_array_init(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_eclass_scheme_c})::Cvoid end -const t8_forest_ghost_t = Ptr{t8_forest_ghost} - """ - t8_forest_ghost_init(pghost, ghost_type) + t8_element_array_init_size(element_array, scheme, num_elements) -Initialize a ghost type of a forest. +Initializes an already allocated (or static) array structure and allocates a given number of elements and initializes them with t8_element_init. # Arguments -* `pghost`:\\[out\\] Pointer to the forest's ghost. -* `ghost_type`:\\[in\\] The type of the ghost elements, -# See also -[`t8_ghost_type_t`](@ref). - +* `element_array`:\\[in,out\\] Array structure to be initialized. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `num_elements`:\\[in\\] Number of initial array elements. ### Prototype ```c -void t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type); +void t8_element_array_init_size (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, size_t num_elements); ``` """ -function t8_forest_ghost_init(pghost, ghost_type) - @ccall libt8.t8_forest_ghost_init(pghost::Ptr{t8_forest_ghost_t}, ghost_type::t8_ghost_type_t)::Cvoid +function t8_element_array_init_size(element_array, scheme, num_elements) + @ccall libt8.t8_element_array_init_size(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_eclass_scheme_c}, num_elements::Csize_t)::Cvoid end """ - t8_forest_ghost_num_trees(forest) + t8_element_array_init_view(view, array, offset, length) -Return the number of trees in a ghost. +Initializes an already allocated (or static) view from existing t8\\_element\\_array. The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). # Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of trees in the forest's ghost (or 0 if ghost structure does not exist). +* `view`:\\[in,out\\] Array structure to be initialized. +* `array`:\\[in\\] The array must not be resized while view is alive. +* `offset`:\\[in\\] The offset of the viewed section in element units. This offset cannot be changed until the view is reset. +* `length`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`sc_array_reset`](@ref) later. ### Prototype ```c -t8_locidx_t t8_forest_ghost_num_trees (const t8_forest_t forest); +void t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, size_t offset, size_t length); ``` """ -function t8_forest_ghost_num_trees(forest) - @ccall libt8.t8_forest_ghost_num_trees(forest::t8_forest_t)::t8_locidx_t +function t8_element_array_init_view(view, array, offset, length) + @ccall libt8.t8_element_array_init_view(view::Ptr{t8_element_array_t}, array::Ptr{t8_element_array_t}, offset::Csize_t, length::Csize_t)::Cvoid end """ - t8_forest_ghost_get_tree_element_offset(forest, lghost_tree) - -Return the element offset of a ghost tree. - -!!! note + t8_element_array_init_data(view, base, scheme, elem_count) - forest must be committed before calling this function. +Initializes an already allocated (or static) view from given plain C data (array of [`t8_element_t`](@ref)). The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). # Arguments -* `forest`:\\[in\\] The forest with constructed ghost layer. -* `lghost_tree`:\\[in\\] A local ghost id of a ghost tree. -# Returns -The element offset of this ghost tree within the set of local ghost elements. +* `view`:\\[in,out\\] Array structure to be initialized. +* `base`:\\[in\\] The data must not be moved while view is alive. Must be an array of [`t8_element_t`](@ref) corresponding to *scheme*. +* `scheme`:\\[in\\] The eclass scheme of the elements stored in *base*. +* `elem_count`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`t8_element_array_reset`](@ref) later. ### Prototype ```c -t8_locidx_t t8_forest_ghost_get_tree_element_offset (t8_forest_t forest, t8_locidx_t lghost_tree); +void t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_eclass_scheme_c *scheme, size_t elem_count); ``` """ -function t8_forest_ghost_get_tree_element_offset(forest, lghost_tree) - @ccall libt8.t8_forest_ghost_get_tree_element_offset(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_locidx_t +function t8_element_array_init_data(view, base, scheme, elem_count) + @ccall libt8.t8_element_array_init_data(view::Ptr{t8_element_array_t}, base::Ptr{t8_element_t}, scheme::Ptr{t8_eclass_scheme_c}, elem_count::Csize_t)::Cvoid end """ - t8_forest_ghost_tree_num_leaf_elements(forest, lghost_tree) + t8_element_array_init_copy(element_array, scheme, data, num_elements) -Given an index in the ghost\\_tree array, return this tree's number of leaf elements +Initializes an already allocated (or static) array structure and copy an existing array of [`t8_element_t`](@ref) into it. # Arguments -* `forest`:\\[in\\] The *forest*. Ghost layer must exist. -* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. -# Returns -The number of ghost leaf elements of the tree. *forest* must be committed before calling this function. +* `element_array`:\\[in,out\\] Array structure to be initialized. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `data`:\\[in\\] An array of [`t8_element_t`](@ref) which will be copied into *element_array*. The elements in *data* must belong to *scheme* and must be properly initialized with either t8_element_new or t8_element_init. +* `num_elements`:\\[in\\] Number of elements in *data* to be copied. ### Prototype ```c -t8_locidx_t t8_forest_ghost_tree_num_leaf_elements (t8_forest_t forest, t8_locidx_t lghost_tree); +void t8_element_array_init_copy (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, t8_element_t *data, size_t num_elements); ``` """ -function t8_forest_ghost_tree_num_leaf_elements(forest, lghost_tree) - @ccall libt8.t8_forest_ghost_tree_num_leaf_elements(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_locidx_t +function t8_element_array_init_copy(element_array, scheme, data, num_elements) + @ccall libt8.t8_element_array_init_copy(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_eclass_scheme_c}, data::Ptr{t8_element_t}, num_elements::Csize_t)::Cvoid end """ - t8_forest_ghost_get_tree_leaf_elements(forest, lghost_tree) + t8_element_array_resize(element_array, new_count) + +Change the number of elements stored in an element array. -Get a pointer to the ghost leaf element array of a ghost tree. +!!! note + + If *new_count* is larger than the number of current elements on *element_array*, then t8_element_init is called for the new elements. # Arguments -* `forest`:\\[in\\] The forest. Ghost layer must exist. -* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. 0 <= *lghost_tree* < num\\_ghost\\_trees -# Returns -A pointer to the array of ghost leaf elements of the tree. *forest* must be committed before calling this function. +* `element_array`:\\[in,out\\] The element array to be modified. +* `new_count`:\\[in\\] The new element count of the array. If it is zero the effect equals t8_element_array_reset. ### Prototype ```c -t8_element_array_t * t8_forest_ghost_get_tree_leaf_elements (const t8_forest_t forest, const t8_locidx_t lghost_tree); +void t8_element_array_resize (t8_element_array_t *element_array, size_t new_count); ``` """ -function t8_forest_ghost_get_tree_leaf_elements(forest, lghost_tree) - @ccall libt8.t8_forest_ghost_get_tree_leaf_elements(forest::t8_forest_t, lghost_tree::t8_locidx_t)::Ptr{t8_element_array_t} +function t8_element_array_resize(element_array, new_count) + @ccall libt8.t8_element_array_resize(element_array::Ptr{t8_element_array_t}, new_count::Csize_t)::Cvoid end """ - t8_forest_ghost_get_ghost_treeid(forest, gtreeid) + t8_element_array_copy(dest, src) -Given a global tree compute the ghost local tree id of it. +Copy the contents of an array into another. Both arrays must have the same eclass\\_scheme. # Arguments -* `forest`:\\[in\\] The forest. Ghost layer must exist. -* `gtreeid`:\\[in\\] A global tree in *forest*. -# Returns -If *gtreeid* is also a ghost tree, the index in the ghost->ghost\\_trees array of the tree. Otherwise a negative number. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +* `dest`:\\[in\\] Array will be resized and get new data. +* `src`:\\[in\\] Array used as source of new data, will not be changed. ### Prototype ```c -t8_locidx_t t8_forest_ghost_get_ghost_treeid (t8_forest_t forest, t8_gloidx_t gtreeid); +void t8_element_array_copy (t8_element_array_t *dest, const t8_element_array_t *src); ``` """ -function t8_forest_ghost_get_ghost_treeid(forest, gtreeid) - @ccall libt8.t8_forest_ghost_get_ghost_treeid(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t +function t8_element_array_copy(dest, src) + @ccall libt8.t8_element_array_copy(dest::Ptr{t8_element_array_t}, src::Ptr{t8_element_array_t})::Cvoid end """ - t8_forest_ghost_get_tree_class(forest, lghost_tree) + t8_element_array_push(element_array) -Given an index in the ghost\\_tree array, return this tree's element class. +Enlarge an array by one element. # Arguments -* `forest`:\\[in\\] A committed forest. -* `lghost_tree`:\\[in\\] The tree's local index in the ghost\\_tree array. +* `element_array`:\\[in\\] Array structure to be modified. # Returns -The element class of the given tree. +Returns a pointer to a newly added element for which t8_element_init was called. ### Prototype ```c -t8_eclass_t t8_forest_ghost_get_tree_class (const t8_forest_t forest, const t8_locidx_t lghost_tree); +t8_element_t * t8_element_array_push (t8_element_array_t *element_array); ``` """ -function t8_forest_ghost_get_tree_class(forest, lghost_tree) - @ccall libt8.t8_forest_ghost_get_tree_class(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_eclass_t +function t8_element_array_push(element_array) + @ccall libt8.t8_element_array_push(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} end """ - t8_forest_ghost_get_global_treeid(forest, lghost_tree) + t8_element_array_push_count(element_array, count) -Given a local ghost tree compute the global tree id of it. +Enlarge an array by a number of elements. # Arguments -* `forest`:\\[in\\] The forest. Ghost layer must exist. -* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. (0 <= *lghost_tree* < num\\_ghost\\_trees) +* `element_array`:\\[in\\] Array structure to be modified. +* `count`:\\[in\\] The number of elements to add. # Returns -The global id of the local ghost tree *lghost_tree*. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +Returns a pointer to the newly added elements for which t8_element_init was called. ### Prototype ```c -t8_gloidx_t t8_forest_ghost_get_global_treeid (const t8_forest_t forest, const t8_locidx_t lghost_tree); +t8_element_t * t8_element_array_push_count (t8_element_array_t *element_array, size_t count); ``` """ -function t8_forest_ghost_get_global_treeid(forest, lghost_tree) - @ccall libt8.t8_forest_ghost_get_global_treeid(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_gloidx_t +function t8_element_array_push_count(element_array, count) + @ccall libt8.t8_element_array_push_count(element_array::Ptr{t8_element_array_t}, count::Csize_t)::Ptr{t8_element_t} end """ - t8_forest_ghost_get_leaf_element(forest, lghost_tree, lelement) + t8_element_array_index_locidx(element_array, index) -Given an index into the ghost\\_trees array and for that tree an element index, return the corresponding element. +Return a given element in an array. Const version. # Arguments -* `forest`:\\[in\\] The *forest*. Ghost layer must exist. -* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. -* `lelement`:\\[in\\] The local id of the ghost leaf element considered. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -A pointer to the ghost leaf element. *forest* must be committed before calling this function. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -t8_element_t * t8_forest_ghost_get_leaf_element (t8_forest_t forest, t8_locidx_t lghost_tree, t8_locidx_t lelement); +const t8_element_t * t8_element_array_index_locidx (const t8_element_array_t *element_array, t8_locidx_t index); ``` """ -function t8_forest_ghost_get_leaf_element(forest, lghost_tree, lelement) - @ccall libt8.t8_forest_ghost_get_leaf_element(forest::t8_forest_t, lghost_tree::t8_locidx_t, lelement::t8_locidx_t)::Ptr{t8_element_t} +function t8_element_array_index_locidx(element_array, index) + @ccall libt8.t8_element_array_index_locidx(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} end """ - t8_forest_element_is_ghost(forest, element, lghost_tree) - -Query whether a given element is a ghost of a certrain tree in a forest. - -!!! note + t8_element_array_index_int(element_array, index) - *forest* must be committed before calling this function. +Return a given element in an array. Const version. # Arguments -* `forest`:\\[in\\] The forest. -* `element`:\\[in\\] An element of a ghost tree in *forest*. -* `lghost_tree`:\\[in\\] A local ghost tree id of *forest*. (0 <= *lghost_tree* < num\\_ghost\\_trees) +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -True (non-zero) if and only if *element* is a ghost in *lghost_tree* of *forest*. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -int t8_forest_element_is_ghost (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t lghost_tree); +const t8_element_t * t8_element_array_index_int (const t8_element_array_t *element_array, int index); ``` """ -function t8_forest_element_is_ghost(forest, element, lghost_tree) - @ccall libt8.t8_forest_element_is_ghost(forest::t8_forest_t, element::Ptr{t8_element_t}, lghost_tree::t8_locidx_t)::Cint +function t8_element_array_index_int(element_array, index) + @ccall libt8.t8_element_array_index_int(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} end """ - t8_forest_ghost_get_remotes(forest, num_remotes) + t8_element_array_index_locidx_mutable(element_array, index) -Return the array of remote ranks. +Return a given element in an array. Mutable version. # Arguments -* `forest`:\\[in\\] A forest with constructed ghost layer. -* `num_remotes`:\\[in,out\\] On output the number of remote ranks is stored here. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -The array of remote ranks in ascending order. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -int * t8_forest_ghost_get_remotes (t8_forest_t forest, int *num_remotes); +t8_element_t * t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, t8_locidx_t index); ``` """ -function t8_forest_ghost_get_remotes(forest, num_remotes) - @ccall libt8.t8_forest_ghost_get_remotes(forest::t8_forest_t, num_remotes::Ptr{Cint})::Ptr{Cint} +function t8_element_array_index_locidx_mutable(element_array, index) + @ccall libt8.t8_element_array_index_locidx_mutable(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} end """ - t8_forest_ghost_remote_first_tree(forest, remote) + t8_element_array_index_int_mutable(element_array, index) -Return the first local ghost tree of a remote rank. +Return a given element in an array. Mutable version. # Arguments -* `forest`:\\[in\\] A forest with constructed ghost layer. -* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -The ghost tree id of the first ghost tree that stores ghost elements of *remote*. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -t8_locidx_t t8_forest_ghost_remote_first_tree (t8_forest_t forest, int remote); +t8_element_t * t8_element_array_index_int_mutable (t8_element_array_t *element_array, int index); ``` """ -function t8_forest_ghost_remote_first_tree(forest, remote) - @ccall libt8.t8_forest_ghost_remote_first_tree(forest::t8_forest_t, remote::Cint)::t8_locidx_t +function t8_element_array_index_int_mutable(element_array, index) + @ccall libt8.t8_element_array_index_int_mutable(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} end """ - t8_forest_ghost_remote_first_elem(forest, remote) + t8_element_array_get_scheme(element_array) -Return the local index of the first ghost element that belongs to a given remote rank. +Return the eclass scheme associated to a t8\\_element\\_array. # Arguments -* `forest`:\\[in\\] A forest with constructed ghost layer. -* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. +* `element_array`:\\[in\\] Array of elements. # Returns -The index i in the ghost elements of the first element of rank *remote* +The eclass scheme stored at *element_array*. ### Prototype ```c -t8_locidx_t t8_forest_ghost_remote_first_elem (t8_forest_t forest, int remote); +const t8_eclass_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array); ``` """ -function t8_forest_ghost_remote_first_elem(forest, remote) - @ccall libt8.t8_forest_ghost_remote_first_elem(forest::t8_forest_t, remote::Cint)::t8_locidx_t +function t8_element_array_get_scheme(element_array) + @ccall libt8.t8_element_array_get_scheme(element_array::Ptr{t8_element_array_t})::Ptr{t8_eclass_scheme_c} end """ - t8_forest_ghost_ref(ghost) + t8_element_array_get_count(element_array) -Increase the reference count of a ghost structure. +Return the number of elements stored in a [`t8_element_array_t`](@ref). # Arguments -* `ghost`:\\[in,out\\] On input, this ghost structure must exist with positive reference count. +* `element_array`:\\[in\\] Array structure. +# Returns +The number of elements stored in *element_array*. ### Prototype ```c -void t8_forest_ghost_ref (t8_forest_ghost_t ghost); +size_t t8_element_array_get_count (const t8_element_array_t *element_array); ``` """ -function t8_forest_ghost_ref(ghost) - @ccall libt8.t8_forest_ghost_ref(ghost::t8_forest_ghost_t)::Cvoid +function t8_element_array_get_count(element_array) + @ccall libt8.t8_element_array_get_count(element_array::Ptr{t8_element_array_t})::Csize_t end """ - t8_forest_ghost_unref(pghost) + t8_element_array_get_size(element_array) -Decrease the reference count of a ghost structure. If the counter reaches zero, the ghost structure is destroyed. See also t8_forest_ghost_destroy, which is to be preferred when it is known that the last reference to a cmesh is deleted. +Return the data size of elements stored in a [`t8_element_array_t`](@ref). # Arguments -* `pghost`:\\[in,out\\] On input, the ghost structure pointed to must exist with positive reference count. If the reference count reaches zero, the ghost structure is destroyed and this pointer is set to NULL. Otherwise, the pointer is not changed. +* `element_array`:\\[in\\] Array structure. +# Returns +The size (in bytes) of a single element in *element_array*. ### Prototype ```c -void t8_forest_ghost_unref (t8_forest_ghost_t *pghost); +size_t t8_element_array_get_size (const t8_element_array_t *element_array); ``` """ -function t8_forest_ghost_unref(pghost) - @ccall libt8.t8_forest_ghost_unref(pghost::Ptr{t8_forest_ghost_t})::Cvoid +function t8_element_array_get_size(element_array) + @ccall libt8.t8_element_array_get_size(element_array::Ptr{t8_element_array_t})::Csize_t end """ - t8_forest_ghost_destroy(pghost) + t8_element_array_get_data(element_array) -Verify that a ghost structure has only one reference left and destroy it. This function is preferred over t8_forest_ghost_unref when it is known that the last reference is to be deleted. +Return a const pointer to the real data array stored in a t8\\_element\\_array. # Arguments -* `pghost`:\\[in,out\\] This ghost structure must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_forest_ghost_unref. +* `element_array`:\\[in\\] Array structure. +# Returns +A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. ### Prototype ```c -void t8_forest_ghost_destroy (t8_forest_ghost_t *pghost); +const t8_element_t * t8_element_array_get_data (const t8_element_array_t *element_array); ``` """ -function t8_forest_ghost_destroy(pghost) - @ccall libt8.t8_forest_ghost_destroy(pghost::Ptr{t8_forest_ghost_t})::Cvoid +function t8_element_array_get_data(element_array) + @ccall libt8.t8_element_array_get_data(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} end """ - t8_forest_ghost_create(forest) + t8_element_array_get_data_mutable(element_array) -Create one layer of ghost elements for a forest. +Return a pointer to the real data array stored in a t8\\_element\\_array. # Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. -# See also -[`t8_forest_set_ghost`](@ref) - +* `element_array`:\\[in\\] Array structure. +# Returns +A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. ### Prototype ```c -void t8_forest_ghost_create (t8_forest_t forest); +t8_element_t * t8_element_array_get_data_mutable (t8_element_array_t *element_array); ``` """ -function t8_forest_ghost_create(forest) - @ccall libt8.t8_forest_ghost_create(forest::t8_forest_t)::Cvoid +function t8_element_array_get_data_mutable(element_array) + @ccall libt8.t8_element_array_get_data_mutable(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} end """ - t8_forest_ghost_create_balanced_only(forest) + t8_element_array_get_array(element_array) -Create one layer of ghost elements for a forest. This version only works with balanced forests and is the original algorithm from p4est: Scalable Algorithms For Parallel Adaptive Mesh Refinement On Forests of Octrees +Return a const pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. !!! note - The user should prefer t8_forest_ghost_create even for balanced forests. + The data cannot be modified. # Arguments -* `forest`:\\[in,out\\] The balanced forest/ *forest* must be committed before calling this function. +* `element_array`:\\[in\\] Array structure. +# Returns +A const pointer to the [`sc_array`](@ref) storing the data. ### Prototype ```c -void t8_forest_ghost_create_balanced_only (t8_forest_t forest); +const sc_array_t * t8_element_array_get_array (const t8_element_array_t *element_array); ``` """ -function t8_forest_ghost_create_balanced_only(forest) - @ccall libt8.t8_forest_ghost_create_balanced_only(forest::t8_forest_t)::Cvoid +function t8_element_array_get_array(element_array) + @ccall libt8.t8_element_array_get_array(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} end """ - t8_forest_ghost_create_topdown(forest) + t8_element_array_get_array_mutable(element_array) + +Return a mutable pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. -Experimental version of t8_forest_ghost_create using the ghost\\_v3 algorithm +!!! note + + The data can be modified. +# Arguments +* `element_array`:\\[in\\] Array structure. +# Returns +A pointer to the [`sc_array`](@ref) storing the data. ### Prototype ```c -void t8_forest_ghost_create_topdown (t8_forest_t forest); +sc_array_t * t8_element_array_get_array_mutable (t8_element_array_t *element_array); ``` """ -function t8_forest_ghost_create_topdown(forest) - @ccall libt8.t8_forest_ghost_create_topdown(forest::t8_forest_t)::Cvoid +function t8_element_array_get_array_mutable(element_array) + @ccall libt8.t8_element_array_get_array_mutable(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} end """ - t8_forest_save(forest) + t8_element_array_reset(element_array) + +Sets the array count to zero and frees all elements. + +!!! note + + Calling [`t8_element_array_init`](@ref), then any array operations, then [`t8_element_array_reset`](@ref) is memory neutral. +# Arguments +* `element_array`:\\[in,out\\] Array structure to be reset. ### Prototype ```c -void t8_forest_save (t8_forest_t forest); +void t8_element_array_reset (t8_element_array_t *element_array); ``` """ -function t8_forest_save(forest) - @ccall libt8.t8_forest_save(forest::t8_forest_t)::Cvoid +function t8_element_array_reset(element_array) + @ccall libt8.t8_element_array_reset(element_array::Ptr{t8_element_array_t})::Cvoid end """ - t8_vtk_data_type_t - -TODO: Add support for integer data type. + t8_element_array_truncate(element_array) -| Enumerator | Note | -| :---------------- | :---------------------------- | -| T8\\_VTK\\_SCALAR | One double value per element | -| T8\\_VTK\\_VECTOR | 3 double values per element | -""" -@cenum t8_vtk_data_type_t::UInt32 begin - T8_VTK_SCALAR = 0 - T8_VTK_VECTOR = 1 -end +Sets the array count to zero, but does not free elements. -""" - t8_vtk_data_field_t +!!! note -A data field for VTK output. This struct is used to store data that is written to the VTK files. It contains the type of the data, a description, and the actual data array. + This is intended to allow an t8\\_element\\_array to be used as a reusable buffer, where the "high water mark" of the buffer is preserved, so that O(log (max n)) reallocs occur over the life of the buffer. -| Field | Note | -| :---------- | :----------------------------------------- | -| type | Describes of which type the data array is | -| description | String that describes the data. | +# Arguments +* `element_array`:\\[in,out\\] Element array structure to be truncated. +### Prototype +```c +void t8_element_array_truncate (t8_element_array_t *element_array); +``` """ -struct t8_vtk_data_field_t - type::t8_vtk_data_type_t - description::NTuple{8192, Cchar} - data::Ptr{Cdouble} +function t8_element_array_truncate(element_array) + @ccall libt8.t8_element_array_truncate(element_array::Ptr{t8_element_array_t})::Cvoid end """ - t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) + t8_shmem_init(comm) ### Prototype ```c -int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, const int write_curved, int do_not_use_API, const int num_data, t8_vtk_data_field_t *data); +void t8_shmem_init (sc_MPI_Comm comm); ``` """ -function t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) - @ccall libt8.t8_forest_write_vtk_ext(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, write_curved::Cint, do_not_use_API::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_shmem_init(comm) + @ccall libt8.t8_shmem_init(comm::MPI_Comm)::Cvoid end """ - t8_forest_write_vtk(forest, fileprefix) + t8_shmem_finalize(comm) ### Prototype ```c -int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix); +void t8_shmem_finalize (sc_MPI_Comm comm); ``` """ -function t8_forest_write_vtk(forest, fileprefix) - @ccall libt8.t8_forest_write_vtk(forest::t8_forest_t, fileprefix::Cstring)::Cint +function t8_shmem_finalize(comm) + @ccall libt8.t8_shmem_finalize(comm::MPI_Comm)::Cvoid end -# typedef int ( * t8_forest_iterate_face_fn ) ( const t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int face , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , void * user_data ) -""" -Callback function used in - -# Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] Local index of the tree containing the *element*. -* `element`:\\[in\\] The considered element. -* `face`:\\[in\\] The integer index of the considered face of *element*. -* `is_leaf`:\\[in\\] True if and only if the currently considered element is a leaf element. -* `leaf_elements`:\\[in\\] The array of leaf elements that are descendants of *element*. Sorted by linear index. -* `tree_leaf_index`:\\[in\\] Tree-local index of the first leaf. -* `user_data`:\\[in\\] Some user-defined data, as void pointer. -# Returns -Nonzero if the element may touch the face and the top-down search shall be continued, zero otherwise. -# See also -[`t8_forest_iterate_faces`](@ref). -""" -const t8_forest_iterate_face_fn = Ptr{Cvoid} - -# typedef int ( * t8_forest_search_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index ) -""" -A call-back function used by t8_forest_search describing a search-criterion. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. - -# Arguments -* `forest`:\\[in\\] the forest -* `ltreeid`:\\[in\\] the local tree id of the current tree -* `element`:\\[in\\] the element for which the search criterion is checked. -* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element -* `leaf_elements`:\\[in\\] the leaf elements in *forest* that are descendants of *element* (or the element itself if *is_leaf* is true) -* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* -# Returns -non-zero if the search criterion is met, zero otherwise. -""" -const t8_forest_search_fn = Ptr{Cvoid} - -# typedef void ( * t8_forest_query_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , sc_array_t * queries , sc_array_t * query_indices , int * query_matches , const size_t num_active_queries ) """ -A call-back function used by t8_forest_search for queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. + t8_shmem_set_type(comm, type) -# Arguments -* `forest`:\\[in\\] the forest -* `ltreeid`:\\[in\\] the local tree id of the current tree -* `element`:\\[in\\] the element for which the queries are executed -* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element -* `leaf_elements`:\\[in\\] the leaf elements in *forest* that are descendants of *element* (or the element itself if *is_leaf* is true) -* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* -* `queries`:\\[in\\] An array of queries that are checked by the function -* `query_indices`:\\[in\\] An array of size\\_t entries, where each entry is an index of a query in *queries*. -* `query_matches`:\\[in,out\\] An array of length *num_active_queries*. If the element is not a leave must be set to true or false at the i-th index for each query, specifying whether the element 'matches' the query of the i-th query index or not. When the element is a leaf we can return before all entries are set. -* `num_active_queries`:\\[in\\] The number of currently active queries (equals the number of entries of *query_matches* and entries of *query_indices*). +### Prototype +```c +void t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); +``` """ -const t8_forest_query_fn = Ptr{Cvoid} +function t8_shmem_set_type(comm, type) + @ccall libt8.t8_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid +end -# typedef int ( * t8_forest_partition_search_fn ) ( const t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int pfirst , const int plast ) """ -A call-back function used by t8_forest_search_partition describing a search-criterion. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. + t8_shmem_array_init(parray, elem_size, elem_count, comm) -# Arguments -* `forest`:\\[in\\] the forest -* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. Since the cmesh has to be replicated, it coincides with the global tree id. -* `element`:\\[in\\] the element for which the search criterion is checked -* `pfirst`:\\[in\\] the first processor that owns part of *element*. Guaranteed to be non-empty. -* `plast`:\\[in\\] the last processor that owns part of *element*. Guaranteed to be non-empty. -# Returns -non-zero if the search criterion is met, zero otherwise. +### Prototype +```c +void t8_shmem_array_init (t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm); +``` """ -const t8_forest_partition_search_fn = Ptr{Cvoid} +function t8_shmem_array_init(parray, elem_size, elem_count, comm) + @ccall libt8.t8_shmem_array_init(parray::Ptr{t8_shmem_array_t}, elem_size::Csize_t, elem_count::Csize_t, comm::MPI_Comm)::Cvoid +end -# typedef void ( * t8_forest_partition_query_fn ) ( const t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int pfirst , const int plast , void * queries , sc_array_t * query_indices , int * query_matches , const size_t num_active_queries ) """ -A call-back function used by t8_forest_search_partition for queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element. The results of the check are stored in *query_matches*. + t8_shmem_array_start_writing(array) -# Arguments -* `forest`:\\[in\\] the forest -* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. Since the cmesh has to be replicated, it coincides with the global tree id. -* `element`:\\[in\\] the element for which the query is executed -* `pfirst`:\\[in\\] the first processor that owns part of *element*. Guaranteed to be non-empty. -* `plast`:\\[in\\] the last processor that owns part of *element*. Guaranteed to be non-empty. if this is equal to *pfirst*, then the recursion will stop for *element*'s branch after this function returns. -* `queries`:\\[in\\] an array of queries that are checked by the function -* `query_indices`:\\[in\\] an array of size\\_t entries, where each entry is an index of a query in *queries*. -* `query_matches`:\\[in,out\\] an array of length *num_active_queries*. If the element is not a leaf must be set to true or false at the i-th index for each query, specifying whether the element 'matches' the query of the i-th query index or not. When the element is a leaf we can return before all entries are set. -* `num_active_queries`:\\[in\\] The number of currently active queries (equals the number of entries of *query_matches* and entries of *query_indices*). -""" -const t8_forest_partition_query_fn = Ptr{Cvoid} +Enable writing mode for a shmem array. Only some processes may be allowed to write into the array, which is indicated by the return value being non-zero. -""" - t8_forest_split_array(element, leaf_elements, offsets) +!!! note -Split an array of elements according to the children of a given element E. In other words for each child C of E, find the index i, j, such that all descendants of C are elements[i], ..., elements[j-1]. + This function is MPI collective. # Arguments -* `element`:\\[in\\] An element. -* `leaf_elements`:\\[in\\] An array of leaf elements of *element*. Thus, all elements must be descendants. Sorted by linear index. -* `offsets`:\\[in,out\\] On input an allocated array of *num_children_of_E* + 1 entries. On output entry i indicates the position in *leaf_elements* where the descandents of the i-th child of E start. +* `array`:\\[in,out\\] Initialized array. Writing will be enabled on certain processes. +# Returns +True if the calling process can write into the array. ### Prototype ```c -void t8_forest_split_array (const t8_element_t *element, const t8_element_array_t *leaf_elements, size_t *offsets); +int t8_shmem_array_start_writing (t8_shmem_array_t array); ``` """ -function t8_forest_split_array(element, leaf_elements, offsets) - @ccall libt8.t8_forest_split_array(element::Ptr{t8_element_t}, leaf_elements::Ptr{t8_element_array_t}, offsets::Ptr{Csize_t})::Cvoid +function t8_shmem_array_start_writing(array) + @ccall libt8.t8_shmem_array_start_writing(array::t8_shmem_array_t)::Cint end """ - t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, tree_lindex_of_first_leaf, callback, user_data) + t8_shmem_array_end_writing(array) -Iterate over all leaves of an element that touch a given face of the element. Callback is called in each recursive step with element as input. leaf\\_index is only not negative if element is a leaf, in which case it indicates the index of the leaf in the leaves of the tree. If it is negative, it is - (index + 1) Top-down iteration and callback is called on each intermediate level. If it returns false, the current element is not traversed further +Disable writing mode for a shmem array. !!! note - *tree_lindex_of_first_leaf* is not an index in *leaf_elements*. *leaf_elements* may only be a part of the tree's leaves. + This function is MPI collective. # Arguments -* `forest`:\\[in\\] A committed forest. -* `ltreeid`:\\[in\\] Local index of the tree containing the *element*. -* `element`:\\[in\\] The considered element. -* `face`:\\[in\\] The integer index of the considered face of *element*. -* `leaf_elements`:\\[in\\] The array of leaf elements that are descendants of *element*. Sorted by linear index. -* `tree_lindex_of_first_leaf`:\\[in\\] Index of the first leaf of *element* in the tree's leaves. The corresponding leaf does not necessarily lie on the face of *element*. -* `callback`:\\[in\\] The callback function. -* `user_data`:\\[in\\] The user data passed to the *callback* function. +* `array`:\\[in,out\\] Initialized with writing mode enabled. +# See also +[`t8_shmem_array_start_writing`](@ref). + ### Prototype ```c -void t8_forest_iterate_faces (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int face, const t8_element_array_t *const leaf_elements, const t8_locidx_t tree_lindex_of_first_leaf, const t8_forest_iterate_face_fn callback, void *user_data); +void t8_shmem_array_end_writing (t8_shmem_array_t array); ``` """ -function t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, tree_lindex_of_first_leaf, callback, user_data) - @ccall libt8.t8_forest_iterate_faces(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, leaf_elements::Ptr{t8_element_array_t}, tree_lindex_of_first_leaf::t8_locidx_t, callback::t8_forest_iterate_face_fn, user_data::Ptr{Cvoid})::Cvoid +function t8_shmem_array_end_writing(array) + @ccall libt8.t8_shmem_array_end_writing(array::t8_shmem_array_t)::Cvoid end """ - t8_forest_search(forest, search_fn, query_fn, queries) + t8_shmem_array_set_gloidx(array, index, value) -Perform a top-down search of the forest, executing a callback on each intermediate element. The search will enter each tree at least once. If the callback returns false for an element, its descendants are not further searched. To pass user data to the search\\_fn function use t8_forest_set_user_data. +Set an entry of a t8\\_shmem array that is used to store [`t8_gloidx_t`](@ref). The array must have writing mode enabled t8_shmem_array_start_writing. # Arguments -* `forest`:\\[in\\] The forest. -* `search_fn`:\\[in\\] The callback function describing the search criterion. -* `query_fn`:\\[in\\] The query function. -* `queries`:\\[in\\] The array of queries. +* `array`:\\[in,out\\] The array to be modified. +* `index`:\\[in\\] The array entry to be modified. +* `value`:\\[in\\] The new value to be set. ### Prototype ```c -void t8_forest_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries); +void t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value); ``` """ -function t8_forest_search(forest, search_fn, query_fn, queries) - @ccall libt8.t8_forest_search(forest::t8_forest_t, search_fn::t8_forest_search_fn, query_fn::t8_forest_query_fn, queries::Ptr{sc_array_t})::Cvoid +function t8_shmem_array_set_gloidx(array, index, value) + @ccall libt8.t8_shmem_array_set_gloidx(array::t8_shmem_array_t, index::Cint, value::t8_gloidx_t)::Cvoid end """ - t8_forest_iterate_replace(forest_new, forest_old, replace_fn) + t8_shmem_array_copy(dest, source) + +Copy the contents of one t8\\_shmem array into another. + +!!! note -Given two forest where the elements in one forest are either direct children or parents of the elements in the other forest compare the two forests and for each refined element or coarsened family in the old one, call a callback function providing the local indices of the old and new elements. + *dest* must be initialized and match in element size and element count to *source*. !!! note - To pass a user pointer to *replace_fn* use t8_forest_set_user_data and t8_forest_get_user_data. + *dest* must have writing mode disabled. # Arguments -* `forest_new`:\\[in\\] A forest, each element is a parent or child of an element in *forest_old*. -* `forest_old`:\\[in\\] The initial forest. -* `replace_fn`:\\[in\\] A replace callback function. +* `dest`:\\[in,out\\] The array in which *source* should be copied. +* `source`:\\[in\\] The array to copy. ### Prototype ```c -void t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_forest_replace_t replace_fn); +void t8_shmem_array_copy (t8_shmem_array_t dest, t8_shmem_array_t source); ``` """ -function t8_forest_iterate_replace(forest_new, forest_old, replace_fn) - @ccall libt8.t8_forest_iterate_replace(forest_new::t8_forest_t, forest_old::t8_forest_t, replace_fn::t8_forest_replace_t)::Cvoid +function t8_shmem_array_copy(dest, source) + @ccall libt8.t8_shmem_array_copy(dest::t8_shmem_array_t, source::t8_shmem_array_t)::Cvoid end """ - t8_forest_search_partition(forest, search_fn, query_fn, queries) - -Perform a top-down search of the global partition, executing a callback on each intermediate element. The search will enter each tree at least once. The recursion will only go down branches that are split between multiple processors. This is not a collective function. It does not communicate. The function expects the coarse mesh to be replicated. If the callback returns false for an element, its descendants are not further searched. To pass user data to **search_fn** function use t8_forest_set_user_data + t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) -# Arguments -* `forest`:\\[in\\] the forest to be searched -* `search_fn`:\\[in\\] a search callback function called on elements -* `query_fn`:\\[in\\] a query callback function called for all active queries of an element -* `queries`:\\[in,out\\] an array of queries that are checked by the function ### Prototype ```c -void t8_forest_search_partition (const t8_forest_t forest, t8_forest_partition_search_fn search_fn, t8_forest_partition_query_fn query_fn, sc_array_t *queries); +void t8_shmem_array_allgather (const void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, int recvcount, sc_MPI_Datatype recvtype); ``` """ -function t8_forest_search_partition(forest, search_fn, query_fn, queries) - @ccall libt8.t8_forest_search_partition(forest::t8_forest_t, search_fn::t8_forest_partition_search_fn, query_fn::t8_forest_partition_query_fn, queries::Ptr{sc_array_t})::Cvoid +function t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) + @ccall libt8.t8_shmem_array_allgather(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvcount::Cint, recvtype::Cint)::Cvoid end """ - t8_forest_partition(forest) - -Populate a forest with the partitioned elements of forest->set\\_from. + t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) -# Arguments -* `forest`:\\[in,out\\] The forest. ### Prototype ```c -void t8_forest_partition (t8_forest_t forest); +void t8_shmem_array_allgatherv (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, sc_MPI_Datatype recvtype, sc_MPI_Comm comm); ``` """ -function t8_forest_partition(forest) - @ccall libt8.t8_forest_partition(forest::t8_forest_t)::Cvoid +function t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) + @ccall libt8.t8_shmem_array_allgatherv(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvtype::Cint, comm::MPI_Comm)::Cvoid end """ - t8_forest_new_gather(forest_from, gather_rank) - -Create a new forest that gathers a given forest on one process. - -This functionality is mostly required for comparison purposes and sanity checks within the testing framework. + t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) -# Arguments -* `forest_from`:\\[in\\] the forest that should be gathered on one rank -* `gather_rank`:\\[in\\] the rank of the process the forest will be gathered on -# Returns -The gathered forest: The same as *forest_from*, but all elements are on rank *gather_rank*. ### Prototype ```c -t8_forest_t t8_forest_new_gather (const t8_forest_t forest_from, const int gather_rank); +void t8_shmem_array_prefix (const void *sendbuf, t8_shmem_array_t recvarray, const int count, sc_MPI_Datatype type, sc_MPI_Op op, sc_MPI_Comm comm); ``` """ -function t8_forest_new_gather(forest_from, gather_rank) - @ccall libt8.t8_forest_new_gather(forest_from::t8_forest_t, gather_rank::Cint)::t8_forest_t +function t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) + @ccall libt8.t8_shmem_array_prefix(sendbuf::Ptr{Cvoid}, recvarray::t8_shmem_array_t, count::Cint, type::Cint, op::Cint, comm::MPI_Comm)::Cvoid end """ - t8_forest_set_partition_offset(forest, first_global_element) - -Manually set the partition offset of the current process. - -If set, the next partitioning of the forest will use the manually defined element offsets. + t8_shmem_array_get_comm(array) -# Arguments -* `forest`:\\[in,out\\] the considered forest -* `first_global_element`:\\[in\\] the global ID that will become the first local element ### Prototype ```c -void t8_forest_set_partition_offset (t8_forest_t forest, const t8_gloidx_t first_global_element); +sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array); ``` """ -function t8_forest_set_partition_offset(forest, first_global_element) - @ccall libt8.t8_forest_set_partition_offset(forest::t8_forest_t, first_global_element::t8_gloidx_t)::Cvoid +function t8_shmem_array_get_comm(array) + @ccall libt8.t8_shmem_array_get_comm(array::t8_shmem_array_t)::Cint end """ - t8_forest_partition_create_offsets(forest) + t8_shmem_array_get_elem_size(array) -Create the element\\_offset array of a partitioned forest. +Get the element size of a [`t8_shmem_array`](@ref) # Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +* `array`:\\[in\\] The array. +# Returns +The element size of *array*'s elements. ### Prototype ```c -void t8_forest_partition_create_offsets (t8_forest_t forest); +size_t t8_shmem_array_get_elem_size (t8_shmem_array_t array); ``` """ -function t8_forest_partition_create_offsets(forest) - @ccall libt8.t8_forest_partition_create_offsets(forest::t8_forest_t)::Cvoid +function t8_shmem_array_get_elem_size(array) + @ccall libt8.t8_shmem_array_get_elem_size(array::t8_shmem_array_t)::Csize_t end """ - t8_forest_partition_next_nonempty_rank(forest, rank) + t8_shmem_array_get_elem_count(array) -If t8_forest_partition_create_offsets was already called, compute for a given rank the next greater rank that is not empty. +Get the number of elements of a [`t8_shmem_array`](@ref) # Arguments -* `forest`:\\[in\\] The forest. -* `rank`:\\[in\\] An MPI rank. +* `array`:\\[in\\] The array. # Returns -A rank q > *rank* such that the forest has elements on *q*. If such a *q* does not exist, returns mpisize. +The number of elements in *array*. ### Prototype ```c -int t8_forest_partition_next_nonempty_rank (t8_forest_t forest, int rank); +size_t t8_shmem_array_get_elem_count (t8_shmem_array_t array); ``` """ -function t8_forest_partition_next_nonempty_rank(forest, rank) - @ccall libt8.t8_forest_partition_next_nonempty_rank(forest::t8_forest_t, rank::Cint)::Cint +function t8_shmem_array_get_elem_count(array) + @ccall libt8.t8_shmem_array_get_elem_count(array::t8_shmem_array_t)::Csize_t end """ - t8_forest_partition_create_first_desc(forest) + t8_shmem_array_get_gloidx_array(array) -Create the array of global\\_first\\_descendant ids of a partitioned forest. +Return a read-only pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. + +!!! note + + Writing mode must be disabled for *array*. # Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +# Returns +The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -void t8_forest_partition_create_first_desc (t8_forest_t forest); +const t8_gloidx_t * t8_shmem_array_get_gloidx_array (t8_shmem_array_t array); ``` """ -function t8_forest_partition_create_first_desc(forest) - @ccall libt8.t8_forest_partition_create_first_desc(forest::t8_forest_t)::Cvoid +function t8_shmem_array_get_gloidx_array(array) + @ccall libt8.t8_shmem_array_get_gloidx_array(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} end """ - t8_forest_partition_create_tree_offsets(forest) + t8_shmem_array_get_gloidx_array_for_writing(array) -Create the array tree offsets of a partitioned forest. This arrays stores at position p the global id of the first tree of this process. Or if this tree is shared, it stores -(global\\_id) - 1. +Return a pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. The array must have writing enabled t8_shmem_array_start_writing and you should not write into the memory after t8_shmem_array_end_writing was called. # Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +# Returns +The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -void t8_forest_partition_create_tree_offsets (t8_forest_t forest); +t8_gloidx_t * t8_shmem_array_get_gloidx_array_for_writing (t8_shmem_array_t array); ``` """ -function t8_forest_partition_create_tree_offsets(forest) - @ccall libt8.t8_forest_partition_create_tree_offsets(forest::t8_forest_t)::Cvoid +function t8_shmem_array_get_gloidx_array_for_writing(array) + @ccall libt8.t8_shmem_array_get_gloidx_array_for_writing(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} end """ - t8_forest_partition_data(forest_from, forest_to, data_in, data_out) + t8_shmem_array_get_gloidx(array, index) -Re-Partition an array accordingly to a partitioned forest. +Return an entry of a shared memory array that stores [`t8_gloidx_t`](@ref). !!! note - *data_in* has to be of size equal to the number of local elements of *forest_from* *data_out* has to be already allocated and has to be of size equal to the number of local elements of *forest_to*. + Writing mode must be disabled for *array*. # Arguments -* `forest_from`:\\[in\\] The forest before the partitioning step. -* `forest_to`:\\[in\\] The partitioned forest of *forest_from*. -* `data_in`:\\[in\\] A pointer to an [`sc_array_t`](@ref) holding data (one value per element) accordingly to *forest_from*. -* `data_out`:\\[in,out\\] A pointer to an already allocated [`sc_array_t`](@ref) capable of holding data accordingly to *forest_to*. +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +* `index`:\\[in\\] The index of the entry to be queried. +# Returns +The *index*-th entry of *array* as [`t8_gloidx_t`](@ref). ### Prototype ```c -void t8_forest_partition_data (t8_forest_t forest_from, t8_forest_t forest_to, const sc_array_t *data_in, sc_array_t *data_out); +t8_gloidx_t t8_shmem_array_get_gloidx (t8_shmem_array_t array, int index); ``` """ -function t8_forest_partition_data(forest_from, forest_to, data_in, data_out) - @ccall libt8.t8_forest_partition_data(forest_from::t8_forest_t, forest_to::t8_forest_t, data_in::Ptr{sc_array_t}, data_out::Ptr{sc_array_t})::Cvoid +function t8_shmem_array_get_gloidx(array, index) + @ccall libt8.t8_shmem_array_get_gloidx(array::t8_shmem_array_t, index::Cint)::t8_gloidx_t end """ - t8_forest_partition_test_boundary_element(forest) + t8_shmem_array_get_array(array) -Test if the last descendant of the last element of current rank has a smaller linear id than the stored first descendant of rank+1. If this is not the case, elements overlap. +Return a pointer to the data array of a [`t8_shmem_array`](@ref). !!! note - *forest* must be committed before calling this function. + Writing mode must be disabled for *array*. # Arguments -* `forest`:\\[in\\] The forest. +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). +# Returns +A pointer to the data array of *array*. ### Prototype ```c -void t8_forest_partition_test_boundary_element (const t8_forest_t forest); +const void * t8_shmem_array_get_array (t8_shmem_array_t array); ``` """ -function t8_forest_partition_test_boundary_element(forest) - @ccall libt8.t8_forest_partition_test_boundary_element(forest::t8_forest_t)::Cvoid +function t8_shmem_array_get_array(array) + @ccall libt8.t8_shmem_array_get_array(array::t8_shmem_array_t)::Ptr{Cvoid} end """ - t8_forest_pfc_correction_offsets(forest) - -Correct the partitioning if element families are split across process boundaries. + t8_shmem_array_index(array, index) -The default partitioning distributes the elements into equally-sized partitions. For coarsening, however, all elements of a family have to be on the same process in order to be coarsened into their parent element. This function corrects the partitioning such that no families are split across process boundaries. The price to be paid is a slight deviation from the optimal balance of elements among processors. +Return a read-only pointer to an element in a [`t8_shmem_array`](@ref). -# Arguments -* `forest`:\\[in,out\\] the forest. On input, it has been partitioned into equally-sized element partitions. On output, the partitioning has been adjusted such that no element families are split across the process boundaries. -### Prototype -```c -void t8_forest_pfc_correction_offsets (t8_forest_t forest); -``` -""" -function t8_forest_pfc_correction_offsets(forest) - @ccall libt8.t8_forest_pfc_correction_offsets(forest::t8_forest_t)::Cvoid -end +!!! note -""" - t8_forest_set_profiling(forest, set_profiling) + You should not modify the value. -### Prototype -```c -void t8_forest_set_profiling (t8_forest_t forest, int set_profiling); -``` -""" -function t8_forest_set_profiling(forest, set_profiling) - @ccall libt8.t8_forest_set_profiling(forest::t8_forest_t, set_profiling::Cint)::Cvoid -end +!!! note -""" - t8_forest_compute_profile(forest) + Writing mode must be disabled for *array*. +# Arguments +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). +* `index`:\\[in\\] The index of an element. +# Returns +A pointer to the element at *index* in *array*. ### Prototype ```c -void t8_forest_compute_profile (t8_forest_t forest); +const void * t8_shmem_array_index (t8_shmem_array_t array, size_t index); ``` """ -function t8_forest_compute_profile(forest) - @ccall libt8.t8_forest_compute_profile(forest::t8_forest_t)::Cvoid +function t8_shmem_array_index(array, index) + @ccall libt8.t8_shmem_array_index(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} end """ - t8_forest_profile_get_adapt_stats(forest) - -### Prototype -```c -const sc_statinfo_t * t8_forest_profile_get_adapt_stats (t8_forest_t forest); -``` -""" -function t8_forest_profile_get_adapt_stats(forest) - @ccall libt8.t8_forest_profile_get_adapt_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} -end + t8_shmem_array_index_for_writing(array, index) -""" - t8_forest_profile_get_ghost_stats(forest) +Return a pointer to an element in a [`t8_shmem_array`](@ref) in writing mode. -### Prototype -```c -const sc_statinfo_t * t8_forest_profile_get_ghost_stats (t8_forest_t forest); -``` -""" -function t8_forest_profile_get_ghost_stats(forest) - @ccall libt8.t8_forest_profile_get_ghost_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} -end +!!! note -""" - t8_forest_profile_get_partition_stats(forest) + You can modify the value before the next call to t8_shmem_array_end_writing. -### Prototype -```c -const sc_statinfo_t * t8_forest_profile_get_partition_stats (t8_forest_t forest); -``` -""" -function t8_forest_profile_get_partition_stats(forest) - @ccall libt8.t8_forest_profile_get_partition_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} -end +!!! note -""" - t8_forest_profile_get_commit_stats(forest) + Writing mode must be enabled for *array*. +# Arguments +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). +* `index`:\\[in\\] The index of an element. +# Returns +A pointer to the element at *index* in *array*. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_commit_stats (t8_forest_t forest); +void * t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index); ``` """ -function t8_forest_profile_get_commit_stats(forest) - @ccall libt8.t8_forest_profile_get_commit_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function t8_shmem_array_index_for_writing(array, index) + @ccall libt8.t8_shmem_array_index_for_writing(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} end """ - t8_forest_profile_get_balance_stats(forest) + t8_shmem_array_is_equal(array_a, array_b) ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_balance_stats (t8_forest_t forest); +int t8_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b); ``` """ -function t8_forest_profile_get_balance_stats(forest) - @ccall libt8.t8_forest_profile_get_balance_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function t8_shmem_array_is_equal(array_a, array_b) + @ccall libt8.t8_shmem_array_is_equal(array_a::t8_shmem_array_t, array_b::t8_shmem_array_t)::Cint end """ - t8_forest_profile_get_balance_rounds_stats(forest) + t8_shmem_array_destroy(parray) + +Free all memory associated with a [`t8_shmem_array`](@ref). +# Arguments +* `parray`:\\[in,out\\] On input a pointer to a valid [`t8_shmem_array`](@ref). This array is freed and *parray* is set to NULL on return. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); +void t8_shmem_array_destroy (t8_shmem_array_t *parray); ``` """ -function t8_forest_profile_get_balance_rounds_stats(forest) - @ccall libt8.t8_forest_profile_get_balance_rounds_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function t8_shmem_array_destroy(parray) + @ccall libt8.t8_shmem_array_destroy(parray::Ptr{t8_shmem_array_t})::Cvoid end """ - t8_forest_print_profile(forest) + t8_forest_adapt(forest) ### Prototype ```c -void t8_forest_print_profile (t8_forest_t forest); +void t8_forest_adapt (t8_forest_t forest); ``` """ -function t8_forest_print_profile(forest) - @ccall libt8.t8_forest_print_profile(forest::t8_forest_t)::Cvoid +function t8_forest_adapt(forest) + @ccall libt8.t8_forest_adapt(forest::t8_forest_t)::Cvoid end """ - t8_forest_profile_get_adapt_time(forest) + t8_forest_balance(forest, repartition) ### Prototype ```c -double t8_forest_profile_get_adapt_time (t8_forest_t forest); +void t8_forest_balance (t8_forest_t forest, int repartition); ``` """ -function t8_forest_profile_get_adapt_time(forest) - @ccall libt8.t8_forest_profile_get_adapt_time(forest::t8_forest_t)::Cdouble +function t8_forest_balance(forest, repartition) + @ccall libt8.t8_forest_balance(forest::t8_forest_t, repartition::Cint)::Cvoid end """ - t8_forest_profile_get_partition_time(forest, procs_sent) + t8_forest_is_balanced(forest) ### Prototype ```c -double t8_forest_profile_get_partition_time (t8_forest_t forest, int *procs_sent); +int t8_forest_is_balanced (t8_forest_t forest); ``` """ -function t8_forest_profile_get_partition_time(forest, procs_sent) - @ccall libt8.t8_forest_profile_get_partition_time(forest::t8_forest_t, procs_sent::Ptr{Cint})::Cdouble +function t8_forest_is_balanced(forest) + @ccall libt8.t8_forest_is_balanced(forest::t8_forest_t)::Cint end """ - t8_forest_profile_get_balance_time(forest, balance_rounds) + t8_tree -### Prototype -```c -double t8_forest_profile_get_balance_time (t8_forest_t forest, int *balance_rounds); -``` +The t8 tree datatype + +| Field | Note | +| :---------------- | :----------------------------------------------------------------- | +| elements | locally stored elements | +| eclass | The element class of this tree | +| first\\_desc | first local descendant | +| last\\_desc | last local descendant | +| elements\\_offset | cumulative sum over earlier trees on this processor (locals only) | """ -function t8_forest_profile_get_balance_time(forest, balance_rounds) - @ccall libt8.t8_forest_profile_get_balance_time(forest::t8_forest_t, balance_rounds::Ptr{Cint})::Cdouble +struct t8_tree + elements::t8_element_array_t + eclass::t8_eclass_t + first_desc::Ptr{t8_element_t} + last_desc::Ptr{t8_element_t} + elements_offset::t8_locidx_t end +const t8_tree_t = Ptr{t8_tree} + """ - t8_forest_profile_get_ghost_time(forest, ghosts_sent) + t8_ghost_type_t -### Prototype -```c -double t8_forest_profile_get_ghost_time (t8_forest_t forest, t8_locidx_t *ghosts_sent); -``` +This type controls, which neighbors count as ghost elements. Currently, we support face-neighbors. Vertex and edge neighbors will eventually be added. + +| Enumerator | Note | +| :-------------------- | :---------------------------------------------------------------- | +| T8\\_GHOST\\_NONE | Do not create ghost layer. | +| T8\\_GHOST\\_FACES | Consider all face (codimension 1) neighbors. | +| T8\\_GHOST\\_EDGES | Consider all edge (codimension 2) and face neighbors. | +| T8\\_GHOST\\_VERTICES | Consider all vertex (codimension 3) and edge and face neighbors. | """ -function t8_forest_profile_get_ghost_time(forest, ghosts_sent) - @ccall libt8.t8_forest_profile_get_ghost_time(forest::t8_forest_t, ghosts_sent::Ptr{Cint})::Cdouble +@cenum t8_ghost_type_t::UInt32 begin + T8_GHOST_NONE = 0 + T8_GHOST_FACES = 1 + T8_GHOST_EDGES = 2 + T8_GHOST_VERTICES = 3 end +# typedef void ( * t8_generic_function_pointer ) ( void ) """ - t8_forest_profile_get_ghostexchange_waittime(forest) +This typedef is needed as a helper construct to properly be able to define a function that returns a pointer to a void fun(void) function. -### Prototype -```c -double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest); -``` +# See also +[`t8_forest_get_user_function`](@ref). """ -function t8_forest_profile_get_ghostexchange_waittime(forest) - @ccall libt8.t8_forest_profile_get_ghostexchange_waittime(forest::t8_forest_t)::Cdouble -end +const t8_generic_function_pointer = Ptr{Cvoid} + +# typedef void ( * t8_forest_replace_t ) ( t8_forest_t forest_old , t8_forest_t forest_new , t8_locidx_t which_tree , t8_eclass_scheme_c * ts , const int refine , const int num_outgoing , const t8_locidx_t first_outgoing , const int num_incoming , const t8_locidx_t first_incoming ) +""" +Callback function prototype to replace one set of elements with another. + +This is used by the replace routine which can be called after adapt, when the elements of an existing, valid forest are changed. The callback allows the user to make changes to the elements of the new forest that are either refined, coarsened or the same as elements in the old forest. + +If an element is being refined, *refine* and *num_outgoing* will be 1 and *num_incoming* will be the number of children. If a family is being coarsened, *refine* will be -1, *num_outgoing* will be the number of family members and *num_incoming* will be 1. If an element is being removed, *refine* and *num_outgoing* will be 1 and *num_incoming* will be 0. Else *refine* will be 0 and *num_outgoing* and *num_incoming* will both be 1. + +# Arguments +* `forest_old`:\\[in\\] The forest that is adapted +* `forest_new`:\\[in\\] The forest that is newly constructed from *forest_old* +* `which_tree`:\\[in\\] The local tree containing *first_outgoing* and *first_incoming* +* `ts`:\\[in\\] The eclass scheme of the tree +* `refine`:\\[in\\] -1 if family in *forest_old* got coarsened, 0 if element has not been touched, 1 if element got refined and -2 if element got removed. See return of [`t8_forest_adapt_t`](@ref). +* `num_outgoing`:\\[in\\] The number of outgoing elements. +* `first_outgoing`:\\[in\\] The tree local index of the first outgoing element. 0 <= first\\_outgoing < which\\_tree->num\\_elements +* `num_incoming`:\\[in\\] The number of incoming elements. +* `first_incoming`:\\[in\\] The tree local index of the first incoming element. 0 <= first\\_incom < new\\_which\\_tree->num\\_elements +# See also +[`t8_forest_iterate_replace`](@ref) +""" +const t8_forest_replace_t = Ptr{Cvoid} + +# typedef int ( * t8_forest_adapt_t ) ( t8_forest_t forest , t8_forest_t forest_from , t8_locidx_t which_tree , t8_locidx_t lelement_id , t8_eclass_scheme_c * ts , const int is_family , const int num_elements , t8_element_t * elements [ ] ) +""" +Callback function prototype to decide for refining and coarsening. If *is_family* equals 1, the first *num_elements* in *elements* form a family and we decide whether this family should be coarsened or only the first element should be refined. Otherwise *is_family* must equal zero and we consider the first entry of the element array for refinement. Entries of the element array beyond the first *num_elements* are undefined. + +# Arguments +* `forest`:\\[in\\] the forest to which the new elements belong +* `forest_from`:\\[in\\] the forest that is adapted. +* `which_tree`:\\[in\\] the local tree containing *elements* +* `lelement_id`:\\[in\\] the local element id in *forest_old* in the tree of the current element +* `ts`:\\[in\\] the eclass scheme of the tree +* `is_family`:\\[in\\] if 1, the first *num_elements* entries in *elements* form a family. If 0, they do not. +* `num_elements`:\\[in\\] the number of entries in *elements* that are defined +* `elements`:\\[in\\] Pointers to a family or, if *is_family* is zero, pointer to one element. +# Returns +1 if the first entry in *elements* should be refined, -1 if the family *elements* shall be coarsened, -2 if the first entry in *elements* should be removed, 0 else. +""" +const t8_forest_adapt_t = Ptr{Cvoid} """ - t8_forest_profile_get_cmesh_offsets_runtime(forest) + t8_forest_init(pforest) +Create a new forest with reference count one. This forest needs to be specialized with the t8\\_forest\\_set\\_* calls. Currently it is manatory to either call the functions t8_forest_set_mpicomm, t8_forest_set_cmesh, and t8_forest_set_scheme, or to call one of t8_forest_set_copy, t8_forest_set_adapt, or t8_forest_set_partition. It is illegal to mix these calls, or to call more than one of the three latter functions Then it needs to be set up with t8_forest_commit. + +# Arguments +* `pforest`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new forest. ### Prototype ```c -double t8_forest_profile_get_cmesh_offsets_runtime (t8_forest_t forest); +void t8_forest_init (t8_forest_t *pforest); ``` """ -function t8_forest_profile_get_cmesh_offsets_runtime(forest) - @ccall libt8.t8_forest_profile_get_cmesh_offsets_runtime(forest::t8_forest_t)::Cdouble +function t8_forest_init(pforest) + @ccall libt8.t8_forest_init(pforest::Ptr{t8_forest_t})::Cvoid end """ - t8_forest_profile_get_forest_offsets_runtime(forest) + t8_forest_is_initialized(forest) + +Check whether a forest is not NULL, initialized and not committed. In addition, it asserts that the forest is consistent as much as possible. +# Arguments +* `forest`:\\[in\\] This forest is examined. May be NULL. +# Returns +True if forest is not NULL, t8_forest_init has been called on it, but not t8_forest_commit. False otherwise. ### Prototype ```c -double t8_forest_profile_get_forest_offsets_runtime (t8_forest_t forest); +int t8_forest_is_initialized (t8_forest_t forest); ``` """ -function t8_forest_profile_get_forest_offsets_runtime(forest) - @ccall libt8.t8_forest_profile_get_forest_offsets_runtime(forest::t8_forest_t)::Cdouble +function t8_forest_is_initialized(forest) + @ccall libt8.t8_forest_is_initialized(forest::t8_forest_t)::Cint end """ - t8_forest_profile_get_first_descendant_runtime(forest) + t8_forest_is_committed(forest) + +Check whether a forest is not NULL, initialized and committed. In addition, it asserts that the forest is consistent as much as possible. +# Arguments +* `forest`:\\[in\\] This forest is examined. May be NULL. +# Returns +True if forest is not NULL and t8_forest_init has been called on it as well as t8_forest_commit. False otherwise. ### Prototype ```c -double t8_forest_profile_get_first_descendant_runtime (t8_forest_t forest); +int t8_forest_is_committed (t8_forest_t forest); ``` """ -function t8_forest_profile_get_first_descendant_runtime(forest) - @ccall libt8.t8_forest_profile_get_first_descendant_runtime(forest::t8_forest_t)::Cdouble +function t8_forest_is_committed(forest) + @ccall libt8.t8_forest_is_committed(forest::t8_forest_t)::Cint end """ - t8_profile + t8_forest_no_overlap(forest) -This struct holds profiling information, such as timings or statistics about communication. - -| Field | Note | -| :----------------------------- | :------------------------------------------------------------------------------------------------------------- | -| partition\\_elements\\_shipped | The number of elements this process has sent to other in the last partition call. | -| partition\\_elements\\_recv | The number of elements this process has received from other in the last partition call. | -| partition\\_bytes\\_sent | The total number of bytes sent to other processes in the last partition call. | -| partition\\_procs\\_sent | The number of different processes this process has send local elements to in the last partition call. | -| ghosts\\_shipped | The number of ghost elements this process has sent to other processes. | -| ghosts\\_received | The number of ghost elements this process has received from other processes. | -| ghosts\\_remotes | The number of processes this process have sent ghost elements to (and received from). | -| balance\\_rounds | The number of iterations during balance. | -| adapt\\_runtime | The runtime of the last call to [`t8_forest_adapt`](@ref) (not counting adaptation in t8\\_forest\\_balance). | -| partition\\_runtime | The runtime of the last call to *t8_cmesh_partition* (not count in partition in t8\\_forest\\_balance). | -| ghost\\_runtime | The runtime of the last call to [`t8_forest_ghost_create`](@ref). | -| ghost\\_waittime | Amount of synchronisation time in ghost. | -| balance\\_runtime | The runtime of the last call to *t8_forest_balance*. | -| commit\\_runtime | The runtime of the last call to [`t8_cmesh_commit`](@ref). | -| cmesh\\_offsets\\_runtime | The runtime of the last call to [`t8_forest_partition_create_tree_offsets`](@ref). | -| forest\\_offsets\\_runtime | The runtime of the last call to [`t8_forest_partition_create_offsets`](@ref). | -| first\\_descendant\\_runtime | The runtime of the last call to [`t8_forest_partition_create_first_desc`](@ref). | -""" -struct t8_profile - partition_elements_shipped::t8_locidx_t - partition_elements_recv::t8_locidx_t - partition_bytes_sent::Csize_t - partition_procs_sent::Cint - ghosts_shipped::t8_locidx_t - ghosts_received::t8_locidx_t - ghosts_remotes::Cint - balance_rounds::Cint - adapt_runtime::Cdouble - partition_runtime::Cdouble - ghost_runtime::Cdouble - ghost_waittime::Cdouble - balance_runtime::Cdouble - commit_runtime::Cdouble - cmesh_offsets_runtime::Cdouble - forest_offsets_runtime::Cdouble - first_descendant_runtime::Cdouble -end +Check whether the forest has local overlapping elements. -"""This struct holds profiling information, such as timings or statistics about communication.""" -const t8_profile_t = t8_profile +!!! note -"""If a forest is to be derived from another forest, there are different possibilities how the original forest is modified. Currently we support: Copying, adapting, partitioning, and balancing a forest. The latter 3 can be combined, in which case the order is 1. Adapt, 2. Partition, 3. Balance. We store the methods in an int8\\_t and use these defines to distinguish between them.""" -const t8_forest_from_t = Int8 + This function is collective, but only checks local overlapping on each process. -"""This structure is private to the implementation.""" -const t8_forest_struct_t = t8_forest +# Arguments +* `forest`:\\[in\\] The forest to consider. +# Returns +True if *forest* has no elements which are inside each other. +# See also +[`t8_forest_partition_test_boundary_element`](@ref) if you also want to test for global overlap across the process boundaries. -"""The t8 tree datatype""" -const t8_tree_struct_t = t8_tree +### Prototype +```c +int t8_forest_no_overlap (t8_forest_t forest); +``` +""" +function t8_forest_no_overlap(forest) + @ccall libt8.t8_forest_no_overlap(forest::t8_forest_t)::Cint +end -"""This struct holds profiling information, such as timings or statistics about communication.""" -const t8_profile_struct_t = t8_profile +""" + t8_forest_is_equal(forest_a, forest_b) -"""This struct stores various information about a forest's ghost elements and ghost trees.""" -const t8_forest_ghost_struct_t = t8_forest_ghost +Check whether two committed forests have the same local elements. -""" - t8_geometry_type +!!! note -This enumeration contains all possible geometries. + This function is not collective. It only returns the state on the current rank. -| Enumerator | Note | -| :--------------------------------------------- | :----------------------------------------------------------------------------------------------- | -| T8\\_GEOMETRY\\_TYPE\\_ZERO | The zero geometry maps all points to zero. | -| T8\\_GEOMETRY\\_TYPE\\_LINEAR | The linear geometry uses linear interpolations to interpolate between the tree vertices. | -| T8\\_GEOMETRY\\_TYPE\\_LINEAR\\_AXIS\\_ALIGNED | The linear, axis aligned geometry uses only 2 vertices, since it is axis aligned. | -| T8\\_GEOMETRY\\_TYPE\\_LAGRANGE | The Lagrange geometry uses a mapping with Lagrange polynomials to approximate curved elements . | -| T8\\_GEOMETRY\\_TYPE\\_ANALYTIC | The analytic geometry uses a user-defined analytic function to map into the physical domain. | -| T8\\_GEOMETRY\\_TYPE\\_CAD | The opencascade geometry uses CAD shapes to map trees exactly to the underlying CAD model. | -| T8\\_GEOMETRY\\_TYPE\\_COUNT | This is no geometry type but can be used as the number of geometry types. | -| T8\\_GEOMETRY\\_TYPE\\_INVALID | This is no geometry type but is used as error type to describe invalid geometries | -| T8\\_GEOMETRY\\_TYPE\\_UNDEFINED | This is no geometry type but is used for every geometry, where no type is defined | +# Arguments +* `forest_a`:\\[in\\] The first forest. +* `forest_b`:\\[in\\] The second forest. +# Returns +True if *forest_a* and *forest_b* do have the same number of local trees and each local tree has the same elements, that is t8_element_equal returns true for each pair of elements of *forest_a* and *forest_b*. +### Prototype +```c +int t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b); +``` """ -@cenum t8_geometry_type::UInt32 begin - T8_GEOMETRY_TYPE_ZERO = 0 - T8_GEOMETRY_TYPE_LINEAR = 1 - T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED = 2 - T8_GEOMETRY_TYPE_LAGRANGE = 3 - T8_GEOMETRY_TYPE_ANALYTIC = 4 - T8_GEOMETRY_TYPE_CAD = 5 - T8_GEOMETRY_TYPE_COUNT = 6 - T8_GEOMETRY_TYPE_INVALID = 7 - T8_GEOMETRY_TYPE_UNDEFINED = 8 +function t8_forest_is_equal(forest_a, forest_b) + @ccall libt8.t8_forest_is_equal(forest_a::t8_forest_t, forest_b::t8_forest_t)::Cint end -"""This enumeration contains all possible geometries.""" -const t8_geometry_type_t = t8_geometry_type - -mutable struct t8_geometry_handler end +""" + t8_forest_set_cmesh(forest, cmesh, comm) -"""This typedef holds virtual functions for the geometry handler. We need it so that we can use [`t8_geometry_handler_c`](@ref) pointers in .c files without them seeing the actual C++ code (and then not compiling) TODO: Delete this when the cmesh is a proper cpp class.""" -const t8_geometry_handler_c = t8_geometry_handler +### Prototype +```c +void t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); +``` +""" +function t8_forest_set_cmesh(forest, cmesh, comm) + @ccall libt8.t8_forest_set_cmesh(forest::t8_forest_t, cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +end """ - t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) + t8_forest_set_scheme(forest, scheme) -Evaluates the geometry of a tree at a given reference point. +Set the element scheme associated to a forest. By default, the forest takes ownership of the scheme such that it will be destroyed when the forest is destroyed. To keep ownership of the scheme, call t8_scheme_ref before passing it to t8_forest_set_scheme. This means that it is ILLEGAL to continue using scheme or dereferencing it UNLESS it is referenced directly before passing it into this function. # Arguments -* `cmesh`:\\[in\\] The cmesh -* `gtreeid`:\\[in\\] The global id of the tree -* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the geometry -* `num_coords`:\\[in\\] The number of reference coordinates -* `out_coords`:\\[out\\] The evaluated coordinates +* `forest`:\\[in,out\\] The forest whose scheme variable will be set. +* `scheme`:\\[in\\] The scheme to be set. We take ownership. This can be prevented by referencing **scheme**. ### Prototype ```c -void t8_geometry_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords); +void t8_forest_set_scheme (t8_forest_t forest, t8_scheme_cxx_t *scheme); ``` """ -function t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) - @ccall libt8.t8_geometry_evaluate(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function t8_forest_set_scheme(forest, scheme) + @ccall libt8.t8_forest_set_scheme(forest::t8_forest_t, scheme::Ptr{t8_scheme_cxx_t})::Cvoid end """ - t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) + t8_forest_set_level(forest, level) -Evaluates the jacobian of a tree at a given reference point. +Set the initial refinement level to be used when **forest** is committed. + +!!! note + + This setting cannot be combined with any of the derived forest methods (t8_forest_set_copy, t8_forest_set_adapt, t8_forest_set_partition, and t8_forest_set_balance) and overwrites any of these settings. If this function is used, then the forest is created from scratch as a uniform refinement of the specified cmesh (t8_forest_set_cmesh, t8_forest_set_scheme). # Arguments -* `cmesh`:\\[in\\] The cmesh -* `gtreeid`:\\[in\\] The global id of the tree -* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the jacobian -* `num_coords`:\\[in\\] The number of reference coordinates -* `jacobian`:\\[out\\] The jacobian at the reference coordinates +* `forest`:\\[in,out\\] The forest whose level will be set. +* `level`:\\[in\\] The initial refinement level of **forest**, when it is committed. ### Prototype ```c -void t8_geometry_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *jacobian); +void t8_forest_set_level (t8_forest_t forest, int level); ``` """ -function t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) - @ccall libt8.t8_geometry_jacobian(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, jacobian::Ptr{Cdouble})::Cvoid +function t8_forest_set_level(forest, level) + @ccall libt8.t8_forest_set_level(forest::t8_forest_t, level::Cint)::Cvoid end -""" - t8_geometry_get_type(cmesh, gtreeid) +""" + t8_forest_set_copy(forest, from) + +Set a forest as source for copying on committing. By default, the forest takes ownership of the source **from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **from** or dereferencing it UNLESS it is referenced directly before passing it into this function. + +!!! note -This function returns the geometry type of a tree. + This setting cannot be combined with t8_forest_set_adapt, t8_forest_set_partition, or t8_forest_set_balance and overwrites these settings. # Arguments -* `cmesh`:\\[in\\] The cmesh -* `gtreeid`:\\[in\\] The global id of the tree -# Returns -The geometry type of the tree with id *gtreeid* +* `forest`:\\[in,out\\] The forest. +* `from`:\\[in\\] A second forest from which *forest* will be copied in t8_forest_commit. ### Prototype ```c -t8_geometry_type_t t8_geometry_get_type (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); +void t8_forest_set_copy (t8_forest_t forest, const t8_forest_t from); ``` """ -function t8_geometry_get_type(cmesh, gtreeid) - @ccall libt8.t8_geometry_get_type(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::t8_geometry_type_t +function t8_forest_set_copy(forest, from) + @ccall libt8.t8_forest_set_copy(forest::t8_forest_t, from::t8_forest_t)::Cvoid end """ - t8_geometry_tree_negative_volume(cmesh, gtreeid) + t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) -Check if a tree has a negative volume +Set a source forest with an adapt function to be adapted on committing. By default, the forest takes ownership of the source **set_from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **set_from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **set_from** or dereferencing it UNLESS it is referenced directly before passing it into this function. + +!!! note + + This setting can be combined with t8_forest_set_partition and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Balance 3) Partition + +!!! note + + This setting may not be combined with t8_forest_set_copy and overwrites this setting. # Arguments -* `cmesh`:\\[in\\] The cmesh to check -* `gtreeid`:\\[in\\] The global id of the tree -# Returns -True if the tree with id *gtreeid* has a negative volume. False otherwise. +* `forest`:\\[in,out\\] The forest +* `set_from`:\\[in\\] The source forest from which **forest** will be adapted. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_partition, t8_forest_set_balance). +* `adapt_fn`:\\[in\\] The adapt function used on committing. +* `recursive`:\\[in\\] A flag specifying whether adaptation is to be done recursively or not. If the value is zero, adaptation is not recursive and it is recursive otherwise. ### Prototype ```c -int t8_geometry_tree_negative_volume (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid); +void t8_forest_set_adapt (t8_forest_t forest, const t8_forest_t set_from, t8_forest_adapt_t adapt_fn, int recursive); ``` """ -function t8_geometry_tree_negative_volume(cmesh, gtreeid) - @ccall libt8.t8_geometry_tree_negative_volume(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Cint +function t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) + @ccall libt8.t8_forest_set_adapt(forest::t8_forest_t, set_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint)::Cvoid end """ - t8_geom_get_name(geom) + t8_forest_set_user_data(forest, data) -Get the name of a geometry. +Set the user data of a forest. This can i.e. be used to pass user defined arguments to the adapt routine. # Arguments -* `geom`:\\[in\\] A geometry. -# Returns -The name of *geom*. +* `forest`:\\[in,out\\] The forest +* `data`:\\[in\\] A pointer to user data. t8code will never touch the data. The forest does not need be committed before calling this function. +# See also +[`t8_forest_get_user_data`](@ref) + ### Prototype ```c -const char * t8_geom_get_name (const t8_geometry_c *geom); +void t8_forest_set_user_data (t8_forest_t forest, void *data); ``` """ -function t8_geom_get_name(geom) - @ccall libt8.t8_geom_get_name(geom::Ptr{t8_geometry_c})::Cstring +function t8_forest_set_user_data(forest, data) + @ccall libt8.t8_forest_set_user_data(forest::t8_forest_t, data::Ptr{Cvoid})::Cvoid end """ - t8_geom_get_type(geom) + t8_forest_get_user_data(forest) -Get the type of a geometry. +Return the user data pointer associated with a forest. # Arguments -* `geom`:\\[in\\] A geometry. +* `forest`:\\[in\\] The forest. # Returns -The type of *geom*. +The user data pointer of *forest*. The forest does not need be committed before calling this function. +# See also +[`t8_forest_set_user_data`](@ref) + ### Prototype ```c -t8_geometry_type_t t8_geom_get_type (const t8_geometry_c *geom); +void * t8_forest_get_user_data (const t8_forest_t forest); ``` """ -function t8_geom_get_type(geom) - @ccall libt8.t8_geom_get_type(geom::Ptr{t8_geometry_c})::t8_geometry_type_t +function t8_forest_get_user_data(forest) + @ccall libt8.t8_forest_get_user_data(forest::t8_forest_t)::Ptr{Cvoid} end """ - t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + t8_forest_set_user_function(forest, _function) + +Set the user function pointer of a forest. This can i.e. be used to pass user defined functions to the adapt routine. + +!!! note + + *function* can be an arbitrary function with return value and parameters of your choice. When accessing it with t8_forest_get_user_function you should cast it into the proper type. + +# Arguments +* `forest`:\\[in,out\\] The forest +* `function`:\\[in\\] A pointer to a user defined function. t8code will never touch the function. The forest does not need be committed before calling this function. +# See also +[`t8_forest_get_user_function`](@ref) ### Prototype ```c -void t8_geom_compute_linear_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); +void t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer function); ``` """ -function t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) - @ccall libt8.t8_geom_compute_linear_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function t8_forest_set_user_function(forest, _function) + @ccall libt8.t8_forest_set_user_function(forest::t8_forest_t, _function::t8_generic_function_pointer)::Cvoid end """ - t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + t8_forest_get_user_function(forest) + +Return the user function pointer associated with a forest. + +# Arguments +* `forest`:\\[in\\] The forest. +# Returns +The user function pointer of *forest*. The forest does not need be committed before calling this function. +# See also +[`t8_forest_set_user_function`](@ref) ### Prototype ```c -void t8_geom_compute_linear_axis_aligned_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); +t8_generic_function_pointer t8_forest_get_user_function (const t8_forest_t forest); ``` """ -function t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) - @ccall libt8.t8_geom_compute_linear_axis_aligned_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function t8_forest_get_user_function(forest) + @ccall libt8.t8_forest_get_user_function(forest::t8_forest_t)::t8_generic_function_pointer end """ - t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + t8_forest_set_partition(forest, set_from, set_for_coarsening) -Interpolates linearly between 2, bilinearly between 4 or trilineraly between 8 points. +Set a source forest to be partitioned during commit. The partitioning is done according to the SFC and each rank is assigned the same (maybe +1) number of elements. + +!!! note + + This setting can be combined with t8_forest_set_adapt and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Balance 3) Partition If t8_forest_set_balance is called with the *no_repartition* parameter set as false, it is not necessary to call t8_forest_set_partition additionally. + +!!! note + + This setting may not be combined with t8_forest_set_copy and overwrites this setting. # Arguments -* `coefficients`:\\[in\\] An array of size at least dim giving the coefficients used for the interpolation -* `corner_values`:\\[in\\] An array of size 2^dim * 3, giving for each corner (in zorder) of the unit square/cube its function values in space. -* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. -* `interpolation_dim`:\\[in\\] The dimension of the interpolation (1 for linear, 2 for bilinear, 3 for trilinear) -* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. +* `forest`:\\[in,out\\] The forest. +* `set_from`:\\[in\\] A second forest that should be partitioned. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_balance). +* `set_for_coarsening`:\\[in\\] CURRENTLY DISABLED. If true, then the partitions are choose such that coarsening an element once is a process local operation. ### Prototype ```c -void t8_geom_linear_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); +void t8_forest_set_partition (t8_forest_t forest, const t8_forest_t set_from, int set_for_coarsening); ``` """ -function t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) - @ccall libt8.t8_geom_linear_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid +function t8_forest_set_partition(forest, set_from, set_for_coarsening) + @ccall libt8.t8_forest_set_partition(forest::t8_forest_t, set_from::t8_forest_t, set_for_coarsening::Cint)::Cvoid end """ - t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + t8_forest_set_balance(forest, set_from, no_repartition) -Triangular interpolation between 3 points (triangle) or 4 points (tetrahedron) using cartesian coordinates. The input coefficients have to be given as coordinates in the reference triangle (interpolation\\_dim = 2) with points (0,0) (1,0) (1,1) or the reference tet (interpolation\\_dim = 3) with points (0,0,0) (1,0,0) (1,1,0) (1,1,1). +Set a source forest to be balanced during commit. A forest is said to be balanced if each element has face neighbors of level at most +1 or -1 of the element's level. + +!!! note + + This setting can be combined with t8_forest_set_adapt and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Balance 3) Partition. + +!!! note + + This setting may not be combined with t8_forest_set_copy and overwrites this setting. # Arguments -* `coefficients`:\\[in\\] An array of size *interpolation_dim* giving the coefficients in the reference triangle/tet used for the interpolation -* `corner_values`:\\[in\\] An array of size 3 * *corner_value_dim* for *interpolation_dim* == 2 or 4 * *corner_value_dim* for *interpolation_dim* == 3, giving the function values of the triangle/tetrahedron for each corner (in zorder) -* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. -* `interpolation_dim`:\\[in\\] The dimension of the interpolation (2 for triangle, 3 for tetrahedron) -* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. +* `forest`:\\[in,out\\] The forest. +* `set_from`:\\[in\\] A second forest that should be balanced. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_partition) +* `no_repartition`:\\[in\\] Balance constructs several intermediate forest that are refined from each other. In order to maintain a balanced load these forest are repartitioned in each round and the resulting forest is load-balanced per default. If this behaviour is not desired, *no_repartition* should be set to true. If *no_repartition* is false, an additional call of t8_forest_set_partition is not necessary. ### Prototype ```c -void t8_geom_triangular_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); +void t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_repartition); ``` """ -function t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) - @ccall libt8.t8_geom_triangular_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid +function t8_forest_set_balance(forest, set_from, no_repartition) + @ccall libt8.t8_forest_set_balance(forest::t8_forest_t, set_from::t8_forest_t, no_repartition::Cint)::Cvoid end """ - t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) + t8_forest_set_ghost(forest, do_ghost, ghost_type) + +Enable or disable the creation of a layer of ghost elements. On default no ghosts are created. +# Arguments +* `forest`:\\[in\\] The forest. +* `do_ghost`:\\[in\\] If non-zero a ghost layer will be created. +* `ghost_type`:\\[in\\] Controls which neighbors count as ghost elements, currently only T8\\_GHOST\\_FACES is supported. This value is ignored if *do_ghost* = 0. ### Prototype ```c -void t8_geom_get_face_vertices (t8_eclass_t tree_class, const double *tree_vertices, int face_index, int dim, double *face_vertices); +void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type); ``` """ -function t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) - @ccall libt8.t8_geom_get_face_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, face_index::Cint, dim::Cint, face_vertices::Ptr{Cdouble})::Cvoid +function t8_forest_set_ghost(forest, do_ghost, ghost_type) + @ccall libt8.t8_forest_set_ghost(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t)::Cvoid end """ - t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) + t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) + +Like t8_forest_set_ghost but with the additional options to change the ghost algorithm. This is used for debugging and timing the algorithm. An application should almost always use t8_forest_set_ghost. + +# Arguments +* `ghost_version`:\\[in\\] If 1, the iterative ghost algorithm for balanced forests is used. If 2, the iterative algorithm for unbalanced forests. If 3, the top-down search algorithm for unbalanced forests. +# See also +[`t8_forest_set_ghost`](@ref) ### Prototype ```c -void t8_geom_get_edge_vertices (t8_eclass_t tree_class, const double *tree_vertices, int edge_index, int dim, double *edge_vertices); +void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); ``` """ -function t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) - @ccall libt8.t8_geom_get_edge_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, edge_index::Cint, dim::Cint, edge_vertices::Ptr{Cdouble})::Cvoid +function t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) + @ccall libt8.t8_forest_set_ghost_ext(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t, ghost_version::Cint)::Cvoid end """ - t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) - -Calculates a point of intersection in a triangular reference space. The intersection is the extension of a straight line passing through a reference point and the opposite vertex of the edge. /|\\ / | \\ o -> reference point / o \\ x -> intersection point / | \\ /\\_\\_\\_\\_x\\_\\_\\_\\_\\ + t8_forest_set_load(forest, filename) -# Arguments -* `edge_index`:\\[in\\] Index of the edge, the intersection lies on. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -* `ref_intersection`:\\[out\\] Coordinates of the intersection point. ### Prototype ```c -void t8_geom_get_ref_intersection (int edge_index, const double *ref_coords, double ref_intersection[2]); +void t8_forest_set_load (t8_forest_t forest, const char *filename); ``` """ -function t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) - @ccall libt8.t8_geom_get_ref_intersection(edge_index::Cint, ref_coords::Ptr{Cdouble}, ref_intersection::Ptr{Cdouble})::Cvoid +function t8_forest_set_load(forest, filename) + @ccall libt8.t8_forest_set_load(forest::t8_forest_t, filename::Cstring)::Cvoid end """ - t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) + t8_forest_comm_global_num_elements(forest) -Calculates the scaling factor for edge displacement along a triangular tree face depending on the position of the global reference point. +Compute the global number of elements in a forest as the sum of the local element counts. # Arguments -* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. -* `tree_vertices`:\\[in\\] Array with the tree vertex coordinates. -* `glob_intersection`:\\[in\\] Array containing the coordinates of the intersection point of a line drawn from the opposite vertex through the glob\\_ref\\_point onto the edge with edge\\_index. -* `glob_ref_point`:\\[in\\] Array containing the coordinates of the reference point mapped into the global space. +* `forest`:\\[in\\] The forest. ### Prototype ```c -double t8_geom_get_triangle_scaling_factor (int edge_index, const double *tree_vertices, const double *glob_intersection, const double *glob_ref_point); +void t8_forest_comm_global_num_elements (t8_forest_t forest); ``` """ -function t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) - @ccall libt8.t8_geom_get_triangle_scaling_factor(edge_index::Cint, tree_vertices::Ptr{Cdouble}, glob_intersection::Ptr{Cdouble}, glob_ref_point::Ptr{Cdouble})::Cdouble +function t8_forest_comm_global_num_elements(forest) + @ccall libt8.t8_forest_comm_global_num_elements(forest::t8_forest_t)::Cvoid end """ - t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) + t8_forest_commit(forest) -Calculates the scaling factor for the displacement of an edge over a face of a tetrahedral element. +After allocating and adding properties to a forest, commit the changes. This call sets up the internal state of the forest. # Arguments -* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. -* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -# Returns -The scaling factor of the edge displacement on the face at the point of the reference coordinates. +* `forest`:\\[in,out\\] Must be created with t8_forest_init and specialized with t8\\_forest\\_set\\_* calls first. ### Prototype ```c -double t8_geom_get_scaling_factor_of_edge_on_face_tet (int edge_index, int face_index, const double *ref_coords); +void t8_forest_commit (t8_forest_t forest); ``` """ -function t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) - @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble +function t8_forest_commit(forest) + @ccall libt8.t8_forest_commit(forest::t8_forest_t)::Cvoid end """ - t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) + t8_forest_get_maxlevel(forest) -Calculates the face intersection of a ray passing trough the reference coordinates and the opposite vertex of that face for a tetrahedron. The coordinates of the face intersection are reference coordinates: [0,1]^3. +Return the maximum allowed refinement level for any element in a forest. # Arguments -* `face_index`:\\[in\\] Index of the face, on which the intersection should be calculated. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -* `face_intersection`:\\[out\\] Three dimensional array containing the intersection point on the face in reference space. +* `forest`:\\[in\\] A forest. +# Returns +The maximum level of refinement that is allowed for an element in this forest. It is guaranteed that any tree in *forest* can be refined this many times and it is not allowed to refine further. *forest* must be committed before calling this function. For forest with a single element class (non-hybrid) maxlevel is the maximum refinement level of this element class, whilst for hybrid forests the maxlevel is the minimum of all maxlevels of the element classes in this forest. ### Prototype ```c -void t8_geom_get_tet_face_intersection (const int face_index, const double *ref_coords, double face_intersection[3]); +int t8_forest_get_maxlevel (const t8_forest_t forest); ``` """ -function t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) - @ccall libt8.t8_geom_get_tet_face_intersection(face_index::Cint, ref_coords::Ptr{Cdouble}, face_intersection::Ptr{Cdouble})::Cvoid +function t8_forest_get_maxlevel(forest) + @ccall libt8.t8_forest_get_maxlevel(forest::t8_forest_t)::Cint end """ - t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) + t8_forest_get_local_num_elements(forest) -Calculates the scaling factor for the displacement of an edge over a face of a prism element. +Return the number of process local elements in the forest. # Arguments -* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. -* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +* `forest`:\\[in\\] A forest. # Returns -The scaling factor of the edge displacement on the face at the point of the reference coordinates. +The number of elements on this process in *forest*. *forest* must be committed before calling this function. ### Prototype ```c -double t8_geom_get_scaling_factor_of_edge_on_face_prism (int edge_index, int face_index, const double *ref_coords); +t8_locidx_t t8_forest_get_local_num_elements (const t8_forest_t forest); ``` """ -function t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) - @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble +function t8_forest_get_local_num_elements(forest) + @ccall libt8.t8_forest_get_local_num_elements(forest::t8_forest_t)::t8_locidx_t end """ - t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) + t8_forest_get_global_num_elements(forest) -Calculates the scaling factor for the displacement of an face through the volume of a prism element. +Return the number of global elements in the forest. # Arguments -* `face`:\\[in\\] Index of the displaced face. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +* `forest`:\\[in\\] A forest. # Returns -The scaling factor of the face displacement at the point of the reference coordinates inside the prism volume. +The number of elements (summed over all processes) in *forest*. *forest* must be committed before calling this function. ### Prototype ```c -double t8_geom_get_scaling_factor_face_through_volume_prism (const int face, const double *ref_coords); +t8_gloidx_t t8_forest_get_global_num_elements (const t8_forest_t forest); ``` """ -function t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) - @ccall libt8.t8_geom_get_scaling_factor_face_through_volume_prism(face::Cint, ref_coords::Ptr{Cdouble})::Cdouble +function t8_forest_get_global_num_elements(forest) + @ccall libt8.t8_forest_get_global_num_elements(forest::t8_forest_t)::t8_gloidx_t end """ - t8_vertex_point_inside(vertex_coords, point, tolerance) + t8_forest_get_num_ghosts(forest) -Check if a point lies inside a vertex +Return the number of ghost elements of a forest. # Arguments -* `vertex_coords`:\\[in\\] The coordinates of the vertex -* `point`:\\[in\\] The coordinates of the point to check -* `tolerance`:\\[in\\] A double > 0 defining the tolerance +* `forest`:\\[in\\] The forest. # Returns -0 if the point is outside, 1 otherwise. +The number of ghost elements stored in the ghost structure of *forest*. 0 if no ghosts were constructed. +# See also +[`t8_forest_set_ghost`](@ref) *forest* must be committed before calling this function. + ### Prototype ```c -int t8_vertex_point_inside (const double vertex_coords[3], const double point[3], const double tolerance); +t8_locidx_t t8_forest_get_num_ghosts (const t8_forest_t forest); ``` """ -function t8_vertex_point_inside(vertex_coords, point, tolerance) - @ccall libt8.t8_vertex_point_inside(vertex_coords::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint +function t8_forest_get_num_ghosts(forest) + @ccall libt8.t8_forest_get_num_ghosts(forest::t8_forest_t)::t8_locidx_t end """ - t8_line_point_inside(p_0, vec, point, tolerance) + t8_forest_get_eclass(forest, ltreeid) -Check if a point is inside a line that is defined by a starting point *p_0* and a vector *vec* +Return the element class of a forest local tree. # Arguments -* `p_0`:\\[in\\] Starting point of the line -* `vec`:\\[in\\] Direction of the line (not normalized) -* `point`:\\[in\\] The coordinates of the point to check -* `tolerance`:\\[in\\] A double > 0 defining the tolerance +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree in *forest*. # Returns -0 if the point is outside, 1 otherwise. +The element class of the tree *ltreeid*. *forest* must be committed before calling this function. ### Prototype ```c -int t8_line_point_inside (const double *p_0, const double *vec, const double *point, const double tolerance); +t8_eclass_t t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_line_point_inside(p_0, vec, point, tolerance) - @ccall libt8.t8_line_point_inside(p_0::Ptr{Cdouble}, vec::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint +function t8_forest_get_eclass(forest, ltreeid) + @ccall libt8.t8_forest_get_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t end """ - t8_triangle_point_inside(p_0, v, w, point, tolerance) + t8_forest_tree_is_local(forest, local_tree) -Check if a point is inside of a triangle described by a point *p_0* and two vectors *v* and *w*. +Check whether a given tree id belongs to a local tree in a forest. # Arguments -* `p_0`:\\[in\\] The first vertex of a triangle -* `v`:\\[in\\] The vector from p\\_0 to p\\_1 (second vertex in the triangle) -* `w`:\\[in\\] The vector from p\\_0 to p\\_2 (third vertex in the triangle) -* `point`:\\[in\\] The coordinates of the point to check -* `tolerance`:\\[in\\] A double > 0 defining the tolerance +* `forest`:\\[in\\] The forest. +* `local_tree`:\\[in\\] A tree id. # Returns -0 if the point is outside, 1 otherwise. +True if and only if the id *local_tree* belongs to a local tree of *forest*. *forest* must be committed before calling this function. ### Prototype ```c -int t8_triangle_point_inside (const double p_0[3], const double v[3], const double w[3], const double point[3], const double tolerance); +int t8_forest_tree_is_local (const t8_forest_t forest, const t8_locidx_t local_tree); ``` """ -function t8_triangle_point_inside(p_0, v, w, point, tolerance) - @ccall libt8.t8_triangle_point_inside(p_0::Ptr{Cdouble}, v::Ptr{Cdouble}, w::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint +function t8_forest_tree_is_local(forest, local_tree) + @ccall libt8.t8_forest_tree_is_local(forest::t8_forest_t, local_tree::t8_locidx_t)::Cint end """ - t8_plane_point_inside(point_on_face, face_normal, point) + t8_forest_get_local_id(forest, gtreeid) -Check if a point lays on the inner side of a plane of a bilinearly interpolated volume element. the plane is described by a point and the normal of the face. +Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is not a local tree, a negative number is returned. # Arguments -* `point_on_face`:\\[in\\] A point on the plane -* `face_normal`:\\[in\\] The normal of the face -* `point`:\\[in\\] The point to check +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of a tree. # Returns -0 if the point is outside, 1 otherwise. +The tree's local id in *forest*, if it is a local tree. A negative number if not. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -int t8_plane_point_inside (const double point_on_face[3], const double face_normal[3], const double point[3]); +t8_locidx_t t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); ``` """ -function t8_plane_point_inside(point_on_face, face_normal, point) - @ccall libt8.t8_plane_point_inside(point_on_face::Ptr{Cdouble}, face_normal::Ptr{Cdouble}, point::Ptr{Cdouble})::Cint +function t8_forest_get_local_id(forest, gtreeid) + @ccall libt8.t8_forest_get_local_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t end """ - t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) + t8_forest_get_local_or_ghost_id(forest, gtreeid) -Set the vertex coordinates of a tree in the cmesh. This is currently inefficient, since the vertices are duplicated for each tree. Eventually this function will be replaced by a more efficient one. It is not allowed to call this function after t8_cmesh_commit. The eclass of the tree has to be set before calling this function. +Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is a ghost, then the local id is between num\\_local\\_trees and num\\_local\\_trees + num\\_ghost\\_trees. If the tree is neither a local tree nor a ghost tree, a negative number is returned. # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `gtree_id`:\\[in\\] The global number of the tree. -* `vertices`:\\[in\\] An array of 3 doubles per tree vertex. -* `num_vertices`:\\[in\\] The number of verticess in *vertices*. Must match the number of corners of the tree. +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of a tree. +# Returns +The tree's local id in *forest*, if it is a local tree. num\\_local\\_trees + the ghosts id, if it is a ghost tree. A negative number if not. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -void t8_cmesh_set_tree_vertices (t8_cmesh_t cmesh, const t8_gloidx_t gtree_id, const double *vertices, const int num_vertices); +t8_locidx_t t8_forest_get_local_or_ghost_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); ``` """ -function t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) - @ccall libt8.t8_cmesh_set_tree_vertices(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cvoid +function t8_forest_get_local_or_ghost_id(forest, gtreeid) + @ccall libt8.t8_forest_get_local_or_ghost_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t end """ - t8_mat_init_xrot(mat, angle) + t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) -Initialize given 3x3 matrix as rotation matrix around the x-axis with given angle. +Given the local id of a tree in a forest, compute the tree's local id in the associated cmesh. + +!!! note + + For forest local trees, this is the inverse function of t8_forest_cmesh_ltreeid_to_ltreeid. # Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree or ghost in the forest. +# Returns +The local id of the tree in the cmesh associated with the forest. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -static inline void t8_mat_init_xrot (double mat[3][3], const double angle); +t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_mat_init_xrot(mat, angle) - @ccall libt8.t8_mat_init_xrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) + @ccall libt8.t8_forest_ltreeid_to_cmesh_ltreeid(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - t8_mat_init_yrot(mat, angle) + t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) -Initialize given 3x3 matrix as rotation matrix around the y-axis with given angle. +Given the local id of a tree in the coarse mesh of a forest, compute the tree's local id in the forest. + +!!! note + + For forest local trees, this is the inverse function of t8_forest_ltreeid_to_cmesh_ltreeid. # Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree in the coarse mesh of *forest*. +# Returns +The local id of the tree in the forest. -1 if the tree is not forest local. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -static inline void t8_mat_init_yrot (double mat[3][3], const double angle); +t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, t8_locidx_t lctreeid); ``` """ -function t8_mat_init_yrot(mat, angle) - @ccall libt8.t8_mat_init_yrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) + @ccall libt8.t8_forest_cmesh_ltreeid_to_ltreeid(forest::t8_forest_t, lctreeid::t8_locidx_t)::t8_locidx_t end """ - t8_mat_init_zrot(mat, angle) + t8_forest_get_coarse_tree(forest, ltreeid) -Initialize given 3x3 matrix as rotation matrix around the z-axis with given angle. +Given the local id of a tree in a forest, return the coarse tree of the cmesh that corresponds to this tree. # Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree in the forest. +# Returns +The coarse tree that matches the forest tree with local id *ltreeid*. ### Prototype ```c -static inline void t8_mat_init_zrot (double mat[3][3], const double angle); +t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_mat_init_zrot(mat, angle) - @ccall libt8.t8_mat_init_zrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function t8_forest_get_coarse_tree(forest, ltreeid) + @ccall libt8.t8_forest_get_coarse_tree(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_ctree_t end """ - t8_mat_mult_vec(mat, a, b) + t8_forest_element_is_leaf(forest, element, local_tree) -Apply matrix-matrix multiplication: b = M*a. +Query whether a given element is a leaf in a forest. + +!!! note + + This does not query for ghost leaves. + +!!! note + + *forest* must be committed before calling this function. # Arguments -* `mat`:\\[in\\] 3x3-matrix. -* `a`:\\[in\\] 3-vector. -* `b`:\\[in,out\\] 3-vector. +* `forest`:\\[in\\] The forest. +* `element`:\\[in\\] An element of a local tree in *forest*. +* `local_tree`:\\[in\\] A local tree id of *forest*. +# Returns +True (non-zero) if and only if *element* is a leaf in *local_tree* of *forest*. ### Prototype ```c -static inline void t8_mat_mult_vec (const double mat[3][3], const double a[3], double b[3]); +int t8_forest_element_is_leaf (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t local_tree); ``` """ -function t8_mat_mult_vec(mat, a, b) - @ccall libt8.t8_mat_mult_vec(mat::Ptr{NTuple{3, Cdouble}}, a::Ptr{Cdouble}, b::Ptr{Cdouble})::Cvoid +function t8_forest_element_is_leaf(forest, element, local_tree) + @ccall libt8.t8_forest_element_is_leaf(forest::t8_forest_t, element::Ptr{t8_element_t}, local_tree::t8_locidx_t)::Cint end """ - t8_mat_mult_mat(A, B, C) + t8_forest_leaf_face_orientation(forest, ltreeid, ts, leaf, face) -Apply matrix-matrix multiplication: C = A*B. +Compute the leaf face orientation at given face in a forest. + +For more information about the encoding of face orientation refer to t8_cmesh_get_face_neighbor. # Arguments -* `A`:\\[in\\] 3x3-matrix. -* `B`:\\[in\\] 3x3-matrix. -* `C`:\\[in,out\\] 3x3-matrix. +* `forest`:\\[in\\] The forest. Must have a valid ghost layer. +* `ltreeid`:\\[in\\] A local tree id. +* `ts`:\\[in\\] The eclass scheme of the element. +* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. +* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +# Returns +Face orientation encoded as integer. ### Prototype ```c -static inline void t8_mat_mult_mat (const double A[3][3], const double B[3][3], double C[3][3]); +int t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_eclass_scheme_c *ts, const t8_element_t *leaf, int face); ``` """ -function t8_mat_mult_mat(A, B, C) - @ccall libt8.t8_mat_mult_mat(A::Ptr{NTuple{3, Cdouble}}, B::Ptr{NTuple{3, Cdouble}}, C::Ptr{NTuple{3, Cdouble}})::Cvoid +function t8_forest_leaf_face_orientation(forest, ltreeid, ts, leaf, face) + @ccall libt8.t8_forest_leaf_face_orientation(forest::t8_forest_t, ltreeid::t8_locidx_t, ts::Ptr{t8_eclass_scheme_c}, leaf::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_refcount_init(rc) + t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced) -Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. +Compute the leaf face neighbors of a forest. + +!!! note + + If there are no face neighbors, then *neighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. + +!!! note + + Currently *forest* must be balanced. + +!!! note + + *forest* must be committed before calling this function. + +!!! note + + Important! This routine allocates memory which must be freed. Do it like this: + +if (num\\_neighbors > 0) { eclass\\_scheme->[`t8_element_destroy`](@ref) (num\\_neighbors, neighbors); [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } # Arguments -* `rc`:\\[out\\] The reference counter is set to one by this call. +* `forest`:\\[in\\] The forest. Must have a valid ghost layer. +* `ltreeid`:\\[in\\] A local tree id. +* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. +* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. +* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. +* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. +* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. +* `pneigh_scheme`:\\[out\\] On output the eclass scheme of the neighbor elements. +* `forest_is_balanced`:\\[in\\] True if we know that *forest* is balanced, false otherwise. ### Prototype ```c -void t8_refcount_init (t8_refcount_t *rc); +void t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, t8_locidx_t **pelement_indices, t8_eclass_scheme_c **pneigh_scheme, int forest_is_balanced); ``` """ -function t8_refcount_init(rc) - @ccall libt8.t8_refcount_init(rc::Ptr{t8_refcount_t})::Cvoid +function t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced) + @ccall libt8.t8_forest_leaf_face_neighbors(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf::Ptr{t8_element_t}, pneighbor_leaves::Ptr{Ptr{Ptr{t8_element_t}}}, face::Cint, dual_faces::Ptr{Ptr{Cint}}, num_neighbors::Ptr{Cint}, pelement_indices::Ptr{Ptr{t8_locidx_t}}, pneigh_scheme::Ptr{Ptr{t8_eclass_scheme_c}}, forest_is_balanced::Cint)::Cvoid end """ - t8_refcount_new() + t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced, gneigh_tree, orientation) -Create a new reference counter with count initialized to 1. Equivalent to calling [`t8_refcount_init`](@ref) on a newly allocated refcount\\_t. It is mandatory to free this with t8_refcount_destroy. +Like t8_forest_leaf_face_neighbors but also provides information about the global neighbors and the orientation. -# Returns -An allocated reference counter whose count has been set to one. +!!! note + + If there are no face neighbors, then *neighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. + +!!! note + + Currently *forest* must be balanced. + +!!! note + + *forest* must be committed before calling this function. + +!!! note + + Important! This routine allocates memory which must be freed. Do it like this: + +if (num\\_neighbors > 0) { eclass\\_scheme->[`t8_element_destroy`](@ref) (num\\_neighbors, neighbors); [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } + +# Arguments +* `forest`:\\[in\\] The forest. Must have a valid ghost layer. +* `ltreeid`:\\[in\\] A local tree id. +* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. +* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. +* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. +* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. +* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. +* `pneigh_scheme`:\\[out\\] On output the eclass scheme of the neighbor elements. +* `forest_is_balanced`:\\[in\\] True if we know that *forest* is balanced, false otherwise. +* `gneigh_tree`:\\[out\\] The global tree IDs of the neighbor trees. +* `orientation`:\\[out\\] If not NULL on input, the face orientation is computed and stored here. Thus, if the face connection is an inter-tree connection the orientation of the tree-to-tree connection is stored. Otherwise, the value 0 is stored. All other parameters and behavior are identical to `t8_forest_leaf_face_neighbors`. ### Prototype ```c -t8_refcount_t * t8_refcount_new (void); +void t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, t8_locidx_t **pelement_indices, t8_eclass_scheme_c **pneigh_scheme, int forest_is_balanced, t8_gloidx_t *gneigh_tree, int *orientation); ``` """ -function t8_refcount_new() - @ccall libt8.t8_refcount_new()::Ptr{t8_refcount_t} +function t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced, gneigh_tree, orientation) + @ccall libt8.t8_forest_leaf_face_neighbors_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf::Ptr{t8_element_t}, pneighbor_leaves::Ptr{Ptr{Ptr{t8_element_t}}}, face::Cint, dual_faces::Ptr{Ptr{Cint}}, num_neighbors::Ptr{Cint}, pelement_indices::Ptr{Ptr{t8_locidx_t}}, pneigh_scheme::Ptr{Ptr{t8_eclass_scheme_c}}, forest_is_balanced::Cint, gneigh_tree::Ptr{t8_gloidx_t}, orientation::Ptr{Cint})::Cvoid end """ - t8_refcount_destroy(rc) + t8_forest_ghost_exchange_data(forest, element_data) -Destroy a reference counter that we allocated with t8_refcount_new. Its reference count must have decreased to zero. +Exchange ghost information of user defined element data. + +!!! note + + This function is collective and hence must be called by all processes in the forest's MPI Communicator. # Arguments -* `rc`:\\[in,out\\] Allocated, formerly valid reference counter. +* `forest`:\\[in\\] The forest. Must be committed. +* `element_data`:\\[in\\] An array of length num\\_local\\_elements + num\\_ghosts storing one value for each local element and ghost in *forest*. After calling this function the entries for the ghost elements are update with the entries in the *element_data* array of the corresponding owning process. ### Prototype ```c -void t8_refcount_destroy (t8_refcount_t *rc); +void t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data); ``` """ -function t8_refcount_destroy(rc) - @ccall libt8.t8_refcount_destroy(rc::Ptr{t8_refcount_t})::Cvoid +function t8_forest_ghost_exchange_data(forest, element_data) + @ccall libt8.t8_forest_ghost_exchange_data(forest::t8_forest_t, element_data::Ptr{sc_array_t})::Cvoid end -# no prototype is found for this function at t8_version.h:67:1, please use with caution """ - t8_get_package_string() + t8_forest_ghost_print(forest) -Return the package string of t8code. This string has the format "t8 version\\_number". +Print the ghost structure of a forest. Only used for debugging. -# Returns -The version string of t8code. ### Prototype ```c -const char* t8_get_package_string (); +void t8_forest_ghost_print (t8_forest_t forest); ``` """ -function t8_get_package_string() - @ccall libt8.t8_get_package_string()::Cstring +function t8_forest_ghost_print(forest) + @ccall libt8.t8_forest_ghost_print(forest::t8_forest_t)::Cvoid end -# no prototype is found for this function at t8_version.h:73:1, please use with caution """ - t8_get_version_number() - -Return the version number of t8code as a string. + t8_forest_partition_cmesh(forest, comm, set_profiling) -# Returns -The version number of t8code as a string. ### Prototype ```c -const char* t8_get_version_number (); +void t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profiling); ``` """ -function t8_get_version_number() - @ccall libt8.t8_get_version_number()::Cstring +function t8_forest_partition_cmesh(forest, comm, set_profiling) + @ccall libt8.t8_forest_partition_cmesh(forest::t8_forest_t, comm::MPI_Comm, set_profiling::Cint)::Cvoid end -# no prototype is found for this function at t8_version.h:79:1, please use with caution """ - t8_get_version_point_string() - -Return the version point string. + t8_forest_get_mpicomm(forest) -# Returns -The version point point string. ### Prototype ```c -const char* t8_get_version_point_string (); +sc_MPI_Comm t8_forest_get_mpicomm (const t8_forest_t forest); ``` """ -function t8_get_version_point_string() - @ccall libt8.t8_get_version_point_string()::Cstring +function t8_forest_get_mpicomm(forest) + @ccall libt8.t8_forest_get_mpicomm(forest::t8_forest_t)::MPI_Comm end -# no prototype is found for this function at t8_version.h:85:1, please use with caution """ - t8_get_version_major() + t8_forest_get_first_local_tree_id(forest) -Return the major version number of t8code. +Return the global id of the first local tree of a forest. +# Arguments +* `forest`:\\[in\\] The forest. # Returns -The major version number of t8code. +The global id of the first local tree in *forest*. ### Prototype ```c -int t8_get_version_major (); +t8_gloidx_t t8_forest_get_first_local_tree_id (const t8_forest_t forest); ``` """ -function t8_get_version_major() - @ccall libt8.t8_get_version_major()::Cint +function t8_forest_get_first_local_tree_id(forest) + @ccall libt8.t8_forest_get_first_local_tree_id(forest::t8_forest_t)::t8_gloidx_t end -# no prototype is found for this function at t8_version.h:91:1, please use with caution """ - t8_get_version_minor() + t8_forest_get_num_local_trees(forest) -Return the minor version number of t8code. +Return the number of local trees of a given forest. +# Arguments +* `forest`:\\[in\\] The forest. # Returns -The minor version number of t8code. +The number of local trees of that forest. ### Prototype ```c -int t8_get_version_minor (); +t8_locidx_t t8_forest_get_num_local_trees (const t8_forest_t forest); ``` """ -function t8_get_version_minor() - @ccall libt8.t8_get_version_minor()::Cint +function t8_forest_get_num_local_trees(forest) + @ccall libt8.t8_forest_get_num_local_trees(forest::t8_forest_t)::t8_locidx_t end -# no prototype is found for this function at t8_version.h:97:1, please use with caution """ - t8_get_version_patch() + t8_forest_get_num_ghost_trees(forest) -Return the patch version number of t8code. +Return the number of ghost trees of a given forest. +# Arguments +* `forest`:\\[in\\] The forest. # Returns -The patch version number of t8code. +The number of ghost trees of that forest. ### Prototype ```c -int t8_get_version_patch (); +t8_locidx_t t8_forest_get_num_ghost_trees (const t8_forest_t forest); ``` """ -function t8_get_version_patch() - @ccall libt8.t8_get_version_patch()::Cint +function t8_forest_get_num_ghost_trees(forest) + @ccall libt8.t8_forest_get_num_ghost_trees(forest::t8_forest_t)::t8_locidx_t end """ - getdelim(lineptr, n, delimiter, stream) + t8_forest_get_num_global_trees(forest) + +Return the number of global trees of a given forest. +# Arguments +* `forest`:\\[in\\] The forest. +# Returns +The number of global trees of that forest. ### Prototype ```c -static ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream); +t8_gloidx_t t8_forest_get_num_global_trees (const t8_forest_t forest); ``` """ -function getdelim(lineptr, n, delimiter, stream) - @ccall libt8.getdelim(lineptr::Ptr{Cstring}, n::Ptr{Cint}, delimiter::Cint, stream::Ptr{Cint})::Cint +function t8_forest_get_num_global_trees(forest) + @ccall libt8.t8_forest_get_num_global_trees(forest::t8_forest_t)::t8_gloidx_t end """ - getline(lineptr, n, stream) + t8_forest_global_tree_id(forest, ltreeid) + +Return the global id of a local tree or a ghost tree. + +# Arguments +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] An id 0 <= *ltreeid* < num\\_local\\_trees + num\\_ghosts specifying a local tree or ghost tree. +# Returns +The global id corresponding to the tree with local id *ltreeid*. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. ### Prototype ```c -static ssize_t getline (char **lineptr, size_t *n, FILE *stream); +t8_gloidx_t t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function getline(lineptr, n, stream) - @ccall libt8.getline(lineptr::Ptr{Cstring}, n::Ptr{Cint}, stream::Ptr{Cint})::Cint +function t8_forest_global_tree_id(forest, ltreeid) + @ccall libt8.t8_forest_global_tree_id(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_gloidx_t end """ - strsep(stringp, delim) - -Extract token from string up to a given delimiter. + t8_forest_get_tree(forest, ltree_id) -For a full description see https://linux.die.net/man/3/[`strsep`](@ref) +Return a pointer to a tree in a forest. +# Arguments +* `forest`:\\[in\\] The forest. +* `ltree_id`:\\[in\\] The local id of the tree. +# Returns +A pointer to the tree with local id *ltree_id*. *forest* must be committed before calling this function. ### Prototype ```c -static char * strsep (char **stringp, const char *delim); +t8_tree_t t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id); ``` """ -function strsep(stringp, delim) - @ccall libt8.strsep(stringp::Ptr{Cstring}, delim::Cstring)::Cstring +function t8_forest_get_tree(forest, ltree_id) + @ccall libt8.t8_forest_get_tree(forest::t8_forest_t, ltree_id::t8_locidx_t)::t8_tree_t end """ - t8_scheme_ref(scheme) + t8_forest_get_tree_vertices(forest, ltreeid) -Increase the reference counter of a scheme. +Return a pointer to the vertex coordinates of a tree. # Arguments -* `scheme`:\\[in,out\\] On input, this scheme must be alive, that is, exist with positive reference count. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The id of a local tree. +# Returns +If stored, a pointer to the vertex coordinates of *tree*. If no coordinates for this tree are found, NULL. ### Prototype ```c -void t8_scheme_ref (t8_scheme_c *scheme); +double * t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_scheme_ref(scheme) - @ccall libt8.t8_scheme_ref(scheme::Ptr{t8_scheme_c})::Cvoid +function t8_forest_get_tree_vertices(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_vertices(forest::t8_forest_t, ltreeid::t8_locidx_t)::Ptr{Cdouble} end """ - t8_scheme_unref(pscheme) + t8_forest_tree_get_leaves(forest, ltree_id) -Decrease the reference counter of a scheme. If the counter reaches zero, this scheme is destroyed. +Return the array of leaf elements of a local tree in a forest. # Arguments -* `pscheme`:\\[in,out\\] On input, the scheme pointed to must exist with positive reference count. If the reference count reaches zero, the scheme is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the scheme is not modified in other ways. +* `forest`:\\[in\\] The forest. +* `ltree_id`:\\[in\\] The local id of a local tree of *forest*. +# Returns +An array of [`t8_element_t`](@ref) * storing all leaf elements of this tree. ### Prototype ```c -void t8_scheme_unref (t8_scheme_c **pscheme); +t8_element_array_t * t8_forest_tree_get_leaves (const t8_forest_t forest, const t8_locidx_t ltree_id); ``` """ -function t8_scheme_unref(pscheme) - @ccall libt8.t8_scheme_unref(pscheme::Ptr{Ptr{t8_scheme_c}})::Cvoid +function t8_forest_tree_get_leaves(forest, ltree_id) + @ccall libt8.t8_forest_tree_get_leaves(forest::t8_forest_t, ltree_id::t8_locidx_t)::Ptr{t8_element_array_t} end """ - t8_element_get_element_size(scheme, tree_class) + t8_forest_get_cmesh(forest) -Return the size of any element of a given class. +Return a cmesh associated to a forest. +# Arguments +* `forest`:\\[in\\] The forest. # Returns -The size of an element of class **ts**. We provide a default implementation of this routine that should suffice for most use cases. +The cmesh associated to the forest. ### Prototype ```c -size_t t8_element_get_element_size (const t8_scheme_c *scheme, const t8_eclass_t tree_class); +t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); ``` """ -function t8_element_get_element_size(scheme, tree_class) - @ccall libt8.t8_element_get_element_size(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Csize_t +function t8_forest_get_cmesh(forest) + @ccall libt8.t8_forest_get_cmesh(forest::t8_forest_t)::t8_cmesh_t end """ - t8_element_refines_irregular(scheme, tree_class) + t8_forest_get_element(forest, lelement_id, ltreeid) -Returns true, if there is one element in the tree, that does not refine into 2^dim children. Returns false otherwise. +Return an element of the forest. + +!!! note + + This function performs a binary search. For constant access, use t8_forest_get_element_in_tree *forest* must be committed before calling this function. +# Arguments +* `forest`:\\[in\\] The forest. +* `lelement_id`:\\[in\\] The local id of an element in *forest*. +* `ltreeid`:\\[out\\] If not NULL, on output the local tree id of the tree in which the element lies in. +# Returns +A pointer to the element. NULL if this element does not exist. ### Prototype ```c -int t8_element_refines_irregular (const t8_scheme_c *scheme, const t8_eclass_t tree_class); +t8_element_t * t8_forest_get_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_locidx_t *ltreeid); ``` """ -function t8_element_refines_irregular(scheme, tree_class) - @ccall libt8.t8_element_refines_irregular(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cint +function t8_forest_get_element(forest, lelement_id, ltreeid) + @ccall libt8.t8_forest_get_element(forest::t8_forest_t, lelement_id::t8_locidx_t, ltreeid::Ptr{t8_locidx_t})::Ptr{t8_element_t} end """ - t8_element_get_maxlevel(scheme, tree_class) + t8_forest_get_element_in_tree(forest, ltreeid, leid_in_tree) -Return the maximum allowed level for any element of a given class. +Return an element of a local tree in a forest. + +!!! note + + If the tree id is know, this function should be preferred over t8_forest_get_element. *forest* must be committed before calling this function. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] An id of a local tree in the forest. +* `leid_in_tree`:\\[in\\] The index of an element in the tree. # Returns -The maximum allowed level for elements of class **ts**. +A pointer to the element. ### Prototype ```c -int t8_element_get_maxlevel (const t8_scheme_c *scheme, const t8_eclass_t tree_class); +const t8_element_t * t8_forest_get_element_in_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t leid_in_tree); ``` """ -function t8_element_get_maxlevel(scheme, tree_class) - @ccall libt8.t8_element_get_maxlevel(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cint +function t8_forest_get_element_in_tree(forest, ltreeid, leid_in_tree) + @ccall libt8.t8_forest_get_element_in_tree(forest::t8_forest_t, ltreeid::t8_locidx_t, leid_in_tree::t8_locidx_t)::Ptr{t8_element_t} end """ - t8_element_get_level(scheme, tree_class, element) + t8_forest_get_tree_num_elements(forest, ltreeid) -Return the level of an element. +Return the number of elements of a tree. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] A local id of a tree. # Returns -The level of *element*. +The number of elements in the local tree *ltreeid*. ### Prototype ```c -int t8_element_get_level (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); +t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_element_get_level(scheme, tree_class, element) - @ccall libt8.t8_element_get_level(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint +function t8_forest_get_tree_num_elements(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_num_elements(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - t8_element_copy(scheme, tree_class, source, dest) + t8_forest_get_tree_element_offset(forest, ltreeid) -Copy all entries of **source** to **dest**. **dest** must be an existing element. No memory is allocated by this function. +Return the element offset of a local tree, that is the number of elements in all trees with smaller local treeid. !!! note - *source* and *dest* may point to the same element. + *forest* must be committed before calling this function. # Arguments -* `scheme`:\\[in\\] Implementation of a class scheme. -* `tree_class`:\\[in\\] The eclass of the current tree. -* `source`:\\[in\\] The element whose entries will be copied to **dest**. -* `dest`:\\[in,out\\] This element's entries will be overwritten with the entries of **source**. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] A local id of a tree. +# Returns +The number of leaf elements on all local tree with id < *ltreeid*. ### Prototype ```c -void t8_element_copy (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *source, t8_element_t *dest); +t8_locidx_t t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_element_copy(scheme, tree_class, source, dest) - @ccall libt8.t8_element_copy(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, source::Ptr{t8_element_t}, dest::Ptr{t8_element_t})::Cvoid +function t8_forest_get_tree_element_offset(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_element_offset(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - t8_element_compare(scheme, tree_class, elem1, elem2) + t8_forest_get_tree_element_count(tree) -Compare two elements with respect to the scheme. +Return the number of elements of a tree. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `elem1`:\\[in\\] The first element. -* `elem2`:\\[in\\] The second element. +* `tree`:\\[in\\] A tree in a forest. # Returns -negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. If elem2 is a copy of elem1 then the elements are equal. +The number of elements of that tree. ### Prototype ```c -int t8_element_compare (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2); +t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); ``` """ -function t8_element_compare(scheme, tree_class, elem1, elem2) - @ccall libt8.t8_element_compare(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint +function t8_forest_get_tree_element_count(tree) + @ccall libt8.t8_forest_get_tree_element_count(tree::t8_tree_t)::t8_locidx_t end """ - t8_element_is_equal(scheme, tree_class, elem1, elem2) + t8_forest_get_tree_class(forest, ltreeid) -Check if two elements are equal. +Return the eclass of a tree in a forest. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `elem1`:\\[in\\] The first element. -* `elem2`:\\[in\\] The second element. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree (local or ghost) in *forest*. # Returns -1 if the elements are equal, 0 if they are not equal +The element class of the tree with local id *ltreeid*. ### Prototype ```c -int t8_element_is_equal (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2); +t8_eclass_t t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_element_is_equal(scheme, tree_class, elem1, elem2) - @ccall libt8.t8_element_is_equal(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint +function t8_forest_get_tree_class(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_class(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t end """ - element_is_refinable(scheme, tree_class, element) + t8_forest_get_first_local_element_id(forest) -Indicates if an element is refinable. Possible reasons for being not refinable could be that the element has reached its max level. +Compute the global index of the first local element of a forest. This function is collective. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element to check. +* `forest`:\\[in\\] A committed forest, whose first element's index is computed. # Returns -1 if the element is refinable, 0 otherwise. +The global index of *forest*'s first local element. Forest must be committed when calling this function. This function is collective and must be called on each process. ### Prototype ```c -int element_is_refinable (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); +t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); ``` """ -function element_is_refinable(scheme, tree_class, element) - @ccall libt8.element_is_refinable(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint +function t8_forest_get_first_local_element_id(forest) + @ccall libt8.t8_forest_get_first_local_element_id(forest::t8_forest_t)::t8_gloidx_t end """ - t8_element_get_parent(scheme, tree_class, element, parent) + t8_forest_get_scheme(forest) -Compute the parent of a given element **element** and store it in **parent**. **parent** needs to be an existing element. No memory is allocated by this function. **element** and **parent** can point to the same element, then the entries of **element** are overwritten by the ones of its parent. +Return the element scheme associated to a forest. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element whose parent will be computed. -* `parent`:\\[in,out\\] This element's entries will be overwritten by those of **element**'s parent. The storage for this element must exist and match the element class of the parent. +* `forest.`:\\[in\\] A committed forest. +# Returns +The element scheme of the forest. +# See also +[`t8_forest_set_scheme`](@ref) + ### Prototype ```c -void t8_element_get_parent (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *parent); +t8_scheme_cxx_t * t8_forest_get_scheme (const t8_forest_t forest); ``` """ -function t8_element_get_parent(scheme, tree_class, element, parent) - @ccall libt8.t8_element_get_parent(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, parent::Ptr{t8_element_t})::Cvoid +function t8_forest_get_scheme(forest) + @ccall libt8.t8_forest_get_scheme(forest::t8_forest_t)::Ptr{t8_scheme_cxx_t} end """ - t8_element_get_num_siblings(scheme, tree_class, element) + t8_forest_get_eclass_scheme(forest, eclass) -Compute the number of siblings of an element. That is the number of Children of its parent. +Return the eclass scheme of a given element class associated to a forest. + +!!! note + + The forest is not required to have trees of class *eclass*. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. +* `forest.`:\\[in\\] A committed forest. +* `eclass.`:\\[in\\] An element class. # Returns -The number of siblings of *element*. Note that this number is >= 1, since we count the element itself as a sibling. +The eclass scheme of *eclass* associated to forest. +# See also +[`t8_forest_set_scheme`](@ref) + ### Prototype ```c -int t8_element_get_num_siblings (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); +t8_eclass_scheme_c * t8_forest_get_eclass_scheme (t8_forest_t forest, t8_eclass_t eclass); ``` """ -function t8_element_get_num_siblings(scheme, tree_class, element) - @ccall libt8.t8_element_get_num_siblings(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint +function t8_forest_get_eclass_scheme(forest, eclass) + @ccall libt8.t8_forest_get_eclass_scheme(forest::t8_forest_t, eclass::t8_eclass_t)::Ptr{t8_eclass_scheme_c} end """ - t8_element_get_sibling(scheme, tree_class, elem, sibid, sibling) + t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) -Compute a specific sibling of a given element **element** and store it in **sibling**. **sibling** needs to be an existing element. No memory is allocated by this function. **element** and **sibling** can point to the same element, then the entries of **element** are overwritten by the ones of its i-th sibling. +Return the eclass of the tree in which a face neighbor of a given element lies. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `elem`:\\[in\\] The element whose sibling will be computed. -* `sibid`:\\[in\\] The id of the sibling computed. -* `sibling`:\\[in,out\\] This element's entries will be overwritten by those of **element**'s sibid-th sibling. The storage for this element must exist and match the element class of the sibling. +* `forest.`:\\[in\\] A committed forest. +* `ltreeid.`:\\[in\\] The local tree in which the element lies. +* `elem.`:\\[in\\] An element in the tree *ltreeid*. +* `face.`:\\[in\\] A face number of *elem*. +# Returns +The local tree id of the tree in which the face neighbor of *elem* across *face* lies. ### Prototype ```c -void t8_element_get_sibling (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem, const int sibid, t8_element_t *sibling); +t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, int face); ``` """ -function t8_element_get_sibling(scheme, tree_class, elem, sibid, sibling) - @ccall libt8.t8_element_get_sibling(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem::Ptr{t8_element_t}, sibid::Cint, sibling::Ptr{t8_element_t})::Cvoid +function t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) + @ccall libt8.t8_forest_element_neighbor_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, face::Cint)::t8_eclass_t end """ - t8_element_get_num_corners(scheme, tree_class, element) + t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_scheme, face, neigh_face) -Compute the number of corners of an element. +Construct the face neighbor of an element, possibly across tree boundaries. Returns the global tree-id of the tree in which the neighbor element lies in. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. +* `elem`:\\[in\\] The element to be considered. +* `neigh`:\\[in,out\\] On input an allocated element of the scheme of the face\\_neighbors eclass. On output, this element's data is filled with the data of the face neighbor. If the neighbor does not exist the data could be modified arbitrarily. +* `neigh_scheme`:\\[in\\] The eclass scheme of *neigh*. +* `face`:\\[in\\] The number of the face along which the neighbor should be constructed. +* `neigh_face`:\\[out\\] The number of the face viewed from perspective of *neigh*. # Returns -The number of corners of *element*. +The global tree-id of the tree in which *neigh* is in. -1 if there exists no neighbor across that face. ### Prototype ```c -int t8_element_get_num_corners (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); +t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, t8_eclass_scheme_c *neigh_scheme, int face, int *neigh_face); ``` """ -function t8_element_get_num_corners(scheme, tree_class, element) - @ccall libt8.t8_element_get_num_corners(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint +function t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_scheme, face, neigh_face) + @ccall libt8.t8_forest_element_face_neighbor(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, neigh::Ptr{t8_element_t}, neigh_scheme::Ptr{t8_eclass_scheme_c}, face::Cint, neigh_face::Ptr{Cint})::t8_gloidx_t end """ - t8_element_get_num_faces(scheme, tree_class, element) - -Compute the number of faces of an element. + t8_forest_iterate(forest) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -# Returns -The number of faces of *element*. ### Prototype ```c -int t8_element_get_num_faces (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); +void t8_forest_iterate (t8_forest_t forest); ``` """ -function t8_element_get_num_faces(scheme, tree_class, element) - @ccall libt8.t8_element_get_num_faces(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint +function t8_forest_iterate(forest) + @ccall libt8.t8_forest_iterate(forest::t8_forest_t)::Cvoid end """ - t8_element_get_max_num_faces(scheme, tree_class, element) + t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) -Compute the maximum number of faces of a given element and all of its descendants. +Query whether a batch of points lies inside an element. For bilinearly interpolated elements. + +!!! note + + For 2D quadrilateral elements this function is only an approximation. It is correct if the four vertices lie in the same plane, but it may produce only approximate results if the vertices do not lie in the same plane. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `forest`:\\[in\\] The forest. +* `ltree_id`:\\[in\\] The forest local id of the tree in which the element is. * `element`:\\[in\\] The element. -# Returns -The number of faces of *element*. +* `points`:\\[in\\] 3-dimensional coordinates of the points to check +* `num_points`:\\[in\\] The number of points to check +* `is_inside`:\\[in,out\\] An array of length *num_points*, filled with 0/1 on output. True (non-zero) if a *point* lies within an *element*, false otherwise. The return value is also true if the point lies on the element boundary. Thus, this function may return true for different leaf elements, if they are neighbors and the point lies on the common boundary. +* `tolerance`:\\[in\\] Tolerance that we allow the point to not exactly match the element. If this value is larger we detect more points. If it is zero we probably do not detect points even if they are inside due to rounding errors. ### Prototype ```c -int t8_element_get_max_num_faces (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); +void t8_forest_element_points_inside (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, int num_points, int *is_inside, const double tolerance); ``` """ -function t8_element_get_max_num_faces(scheme, tree_class, element) - @ccall libt8.t8_element_get_max_num_faces(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint +function t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) + @ccall libt8.t8_forest_element_points_inside(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, points::Ptr{Cdouble}, num_points::Cint, is_inside::Ptr{Cint}, tolerance::Cdouble)::Cvoid end """ - t8_element_get_num_children(scheme, tree_class, element) - -Compute the number of children of an element when it is refined. + t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -# Returns -The number of children of *element*. ### Prototype ```c -int t8_element_get_num_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); +t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, t8_scheme_cxx_t *scheme, const int level, const int do_face_ghost, sc_MPI_Comm comm); ``` """ -function t8_element_get_num_children(scheme, tree_class, element) - @ccall libt8.t8_element_get_num_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint +function t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) + @ccall libt8.t8_forest_new_uniform(cmesh::t8_cmesh_t, scheme::Ptr{t8_scheme_cxx_t}, level::Cint, do_face_ghost::Cint, comm::MPI_Comm)::t8_forest_t end """ - t8_get_max_num_children(scheme, tree_class) + t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) + +Build a adapted forest from another forest. + +!!! note -Return the max number of children of an eclass. + This is equivalent to calling t8_forest_init, t8_forest_set_adapt, t8_forest_set_ghost, and t8_forest_commit # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `forest_from`:\\[in\\] The forest to refine +* `adapt_fn`:\\[in\\] Adapt function to use +* `replace_fn`:\\[in\\] Replace function to use +* `recursive`:\\[in\\] If true adptation is recursive +* `do_face_ghost`:\\[in\\] If true, a layer of ghost elements is created for the forest. +* `user_data`:\\[in\\] If not NULL, the user data pointer of the forest is set to this value. # Returns -The max number of children of *element*. +A new forest that is adapted from *forest_from*. ### Prototype ```c -int t8_get_max_num_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class); +t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, int recursive, int do_face_ghost, void *user_data); ``` """ -function t8_get_max_num_children(scheme, tree_class) - @ccall libt8.t8_get_max_num_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cint +function t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) + @ccall libt8.t8_forest_new_adapt(forest_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint, do_face_ghost::Cint, user_data::Ptr{Cvoid})::t8_forest_t end """ - t8_element_get_num_face_children(scheme, tree_class, element, face) + t8_forest_ref(forest) -Compute the number of children of an element's face when the element is refined. +Increase the reference counter of a forest. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -* `face`:\\[in\\] A face of *element*. -# Returns -The number of children of *face* if *element* is to be refined. +* `forest`:\\[in,out\\] On input, this forest must exist with positive reference count. It may be in any state. ### Prototype ```c -int t8_element_get_num_face_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); +void t8_forest_ref (t8_forest_t forest); ``` """ -function t8_element_get_num_face_children(scheme, tree_class, element, face) - @ccall libt8.t8_element_get_num_face_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint +function t8_forest_ref(forest) + @ccall libt8.t8_forest_ref(forest::t8_forest_t)::Cvoid end """ - t8_element_get_face_corner(scheme, tree_class, element, face, corner) - -Return the corner number of an element's face corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 Thus for face = 1 the output is: corner=0 : 1, corner=1: 3 + t8_forest_unref(pforest) -The order in which the corners must be given is determined by the eclass of *element*: LINE/QUAD/TRIANGLE: No specific order. HEX : In Z-order of the face starting with the lowest corner number. TET : Starting with the lowest corner number counterclockwise as seen from 'outside' of the element. +Decrease the reference counter of a forest. If the counter reaches zero, this forest is destroyed. In this case, the forest dereferences its cmesh and scheme members. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -* `face`:\\[in\\] A face index for *element*. -* `corner`:\\[in\\] A corner index for the face 0 <= *corner* < num\\_face\\_corners. -# Returns -The corner number of the *corner*-th vertex of *face*. +* `pforest`:\\[in,out\\] On input, the forest pointed to must exist with positive reference count. It may be in any state. If the reference count reaches zero, the forest is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the forest is not modified in other ways. ### Prototype ```c -int t8_element_get_face_corner (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, const int corner); +void t8_forest_unref (t8_forest_t *pforest); ``` """ -function t8_element_get_face_corner(scheme, tree_class, element, face, corner) - @ccall libt8.t8_element_get_face_corner(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, corner::Cint)::Cint +function t8_forest_unref(pforest) + @ccall libt8.t8_forest_unref(pforest::Ptr{t8_forest_t})::Cvoid end """ - t8_element_get_corner_face(scheme, tree_class, element, corner, face) - -Compute the face numbers of the faces sharing an element's corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 face 2 Thus for corner = 1 the output is: face=0 : 2, face=1: 1 + t8_forest_get_dimension(forest) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -* `corner`:\\[in\\] A corner index for the face. -* `face`:\\[in\\] A face index for *corner*. -# Returns -The face number of the *face*-th face at *corner*. ### Prototype ```c -int t8_element_get_corner_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int corner, const int face); +int t8_forest_get_dimension (const t8_forest_t forest); ``` """ -function t8_element_get_corner_face(scheme, tree_class, element, corner, face) - @ccall libt8.t8_element_get_corner_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, corner::Cint, face::Cint)::Cint +function t8_forest_get_dimension(forest) + @ccall libt8.t8_forest_get_dimension(forest::t8_forest_t)::Cint end """ - t8_element_get_child(scheme, tree_class, element, childid, child) - -Construct the child element of a given number. + t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] This must be a valid element, bigger than maxlevel. -* `childid`:\\[in\\] The number of the child to construct. -* `child`:\\[in,out\\] The storage for this element must exist. On output, a valid element. It is valid to call this function with element = child. ### Prototype ```c -void t8_element_get_child (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int childid, t8_element_t *child); +void t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8_element_t *element, int corner_number, double *coordinates); ``` """ -function t8_element_get_child(scheme, tree_class, element, childid, child) - @ccall libt8.t8_element_get_child(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, childid::Cint, child::Ptr{t8_element_t})::Cvoid +function t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) + @ccall libt8.t8_forest_element_coordinate(forest::t8_forest_t, ltree_id::t8_locidx_t, element::Ptr{t8_element_t}, corner_number::Cint, coordinates::Ptr{Cdouble})::Cvoid end """ - t8_element_get_children(scheme, tree_class, element, length, c) - -Construct all children of a given element. - -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] This must be a valid element, bigger than maxlevel. -* `length`:\\[in\\] The length of the output array *c* must match the number of children. -* `c`:\\[in,out\\] The storage for these *length* elements must exist and match the element class in the children's ordering. On output, all children are valid. It is valid to call this function with element = c[0]. -# See also -t8\\_element\\_num\\_children + t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) ### Prototype ```c -void t8_element_get_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int length, t8_element_t *c[]); +void t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out, const double *stretch_factors); ``` """ -function t8_element_get_children(scheme, tree_class, element, length, c) - @ccall libt8.t8_element_get_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, length::Cint, c::Ptr{Ptr{t8_element_t}})::Cvoid +function t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) + @ccall libt8.t8_forest_element_from_ref_coords_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble}, stretch_factors::Ptr{Cdouble})::Cvoid end """ - t8_element_get_child_id(scheme, tree_class, element) - -Compute the child id of an element. + t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] This must be a valid element. -# Returns -The child id of element. ### Prototype ```c -int t8_element_get_child_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); +void t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out); ``` """ -function t8_element_get_child_id(scheme, tree_class, element) - @ccall libt8.t8_element_get_child_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint +function t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) + @ccall libt8.t8_forest_element_from_ref_coords(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble})::Cvoid end """ - t8_element_get_ancestor_id(scheme, tree_class, element, level) - -Compute the ancestor id of an element, that is the child id at a given level. + t8_forest_element_centroid(forest, ltreeid, element, coordinates) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] This must be a valid element. -* `level`:\\[in\\] A refinement level. Must satisfy *level* < element.level -# Returns -The child\\_id of *element* in regard to its *level* ancestor. ### Prototype ```c -int t8_element_get_ancestor_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int level); +void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); ``` """ -function t8_element_get_ancestor_id(scheme, tree_class, element, level) - @ccall libt8.t8_element_get_ancestor_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint)::Cint +function t8_forest_element_centroid(forest, ltreeid, element, coordinates) + @ccall libt8.t8_forest_element_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, coordinates::Ptr{Cdouble})::Cvoid end """ - t8_elements_are_family(scheme, tree_class, fam) - -Query whether a given set of elements is a family or not. + t8_forest_element_diam(forest, ltreeid, element) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `fam`:\\[in\\] An array of as many elements as an element of class **scheme** has children. -# Returns -Zero if **fam** is not a family, nonzero if it is. ### Prototype ```c -int t8_elements_are_family (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t *const *fam); +double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); ``` """ -function t8_elements_are_family(scheme, tree_class, fam) - @ccall libt8.t8_elements_are_family(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, fam::Ptr{Ptr{t8_element_t}})::Cint +function t8_forest_element_diam(forest, ltreeid, element) + @ccall libt8.t8_forest_element_diam(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble end """ - t8_element_get_nca(scheme, tree_class, elem1, elem2, nca) - -Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both given elements as descendants. + t8_forest_element_volume(forest, ltreeid, element) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `elem1`:\\[in\\] The first of the two input elements. -* `elem2`:\\[in\\] The second of the two input elements. -* `nca`:\\[in,out\\] The storage for this element must exist and match the element class of the child. On output the unique nearest common ancestor of **elem1** and **elem2**. ### Prototype ```c -void t8_element_get_nca (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca); +double t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); ``` """ -function t8_element_get_nca(scheme, tree_class, elem1, elem2, nca) - @ccall libt8.t8_element_get_nca(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t}, nca::Ptr{t8_element_t})::Cvoid +function t8_forest_element_volume(forest, ltreeid, element) + @ccall libt8.t8_forest_element_volume(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble end """ - t8_element_get_face_shape(scheme, tree_class, element, face) - -Compute the shape of the face of an element. + t8_forest_element_face_area(forest, ltreeid, element, face) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -* `face`:\\[in\\] A face of *element*. -# Returns -The element shape of the face. I.e. T8\\_ECLASS\\_LINE for quads, T8\\_ECLASS\\_TRIANGLE for tets and depending on the face number either T8\\_ECLASS\\_QUAD or T8\\_ECLASS\\_TRIANGLE for prisms. ### Prototype ```c -t8_element_shape_t t8_element_get_face_shape (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); +double t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face); ``` """ -function t8_element_get_face_shape(scheme, tree_class, element, face) - @ccall libt8.t8_element_get_face_shape(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::t8_element_shape_t +function t8_forest_element_face_area(forest, ltreeid, element, face) + @ccall libt8.t8_forest_element_face_area(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint)::Cdouble end """ - t8_element_get_children_at_face(scheme, tree_class, element, face, children, num_children, child_indices) - -Given an element and a face of the element, compute all children of the element that touch the face. + t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -* `face`:\\[in\\] A face of *element*. -* `children`:\\[in,out\\] Allocated elements, in which the children of *element* that share a face with *face* are stored. They will be stored in order of their linear id. -* `num_children`:\\[in\\] The number of elements in *children*. Must match the number of children that touch *face*. t8_scheme::element_get_num_face_children -* `child_indices`:\\[in,out\\] If not NULL, an array of num\\_children integers must be given, on output its i-th entry is the child\\_id of the i-th face\\_child. It is valid to call this function with element = children[0]. ### Prototype ```c -void t8_element_get_children_at_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, t8_element_t *children[], const int num_children, int *child_indices); +void t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double centroid[3]); ``` """ -function t8_element_get_children_at_face(scheme, tree_class, element, face, children, num_children, child_indices) - @ccall libt8.t8_element_get_children_at_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, children::Ptr{Ptr{t8_element_t}}, num_children::Cint, child_indices::Ptr{Cint})::Cvoid +function t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) + @ccall libt8.t8_forest_element_face_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, centroid::Ptr{Cdouble})::Cvoid end """ - t8_element_face_get_child_face(scheme, tree_class, element, face, face_child) - -Given a face of an element and a child number of a child of that face, return the face number of the child of the element that matches the child face. - -```c++ - x ---- x x x x ---- x - | | | | | | | <-- f - | | | x | x--x - | | | | | - x ---- x x x ---- x - element face face_child Returns the face number f -``` + t8_forest_element_face_normal(forest, ltreeid, element, face, normal) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -* `face`:\\[in\\] Then number of the face. -* `face_child`:\\[in\\] A number 0 <= *face_child* < num\\_face\\_children, specifying a child of *element* that shares a face with *face*. These children are counted in linear order. This coincides with the order of children from a call to t8_scheme::element_get_children_at_face. -# Returns -The face number of the face of a child of *element* that coincides with *face_child*. ### Prototype ```c -int t8_element_face_get_child_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, const int face_child); +void t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double normal[3]); ``` """ -function t8_element_face_get_child_face(scheme, tree_class, element, face, face_child) - @ccall libt8.t8_element_face_get_child_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, face_child::Cint)::Cint +function t8_forest_element_face_normal(forest, ltreeid, element, face, normal) + @ccall libt8.t8_forest_element_face_normal(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, normal::Ptr{Cdouble})::Cvoid end """ - t8_element_face_get_parent_face(scheme, tree_class, element, face) + t8_forest_ghost -Given a face of an element return the face number of the parent of the element that matches the element's face. Or return -1 if no face of the parent matches the face. +| Field | Note | +| :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| rc | The reference counter. | +| num\\_ghosts\\_elements | The count of non-local ghost elements | +| num\\_remote\\_elements | The count of local elements that are ghost to another process. | +| ghost\\_type | Describes which neighbors are considered ghosts. | +| ghost\\_trees | ghost tree data: global\\_id. eclass. elements. In linear id order | +| global\\_tree\\_to\\_ghost\\_tree | Indexes into ghost\\_trees. Given a global tree id I give the index i such that the tree is in ghost\\_trees[i] | +| process\\_offsets | Given a process, return the first ghost tree and within it the first element of that process. | +| remote\\_ghosts | array of local trees that have ghost elements for another process. for each tree an array of [`t8_element_t`](@ref) * of the local ghost elements. Also an array of [`t8_locidx_t`](@ref) of the local indices of these elements within the tree. It is a hash table, hashed with the rank of a remote process. Sorted within each process by linear id. | +| remote\\_processes | The ranks of the processes for which local elements are ghost. Array of int's. | +""" +struct t8_forest_ghost + rc::t8_refcount_t + num_ghosts_elements::t8_locidx_t + num_remote_elements::t8_locidx_t + ghost_type::t8_ghost_type_t + ghost_trees::Ptr{sc_array_t} + global_tree_to_ghost_tree::Ptr{sc_hash_t} + process_offsets::Ptr{sc_hash_t} + remote_ghosts::Ptr{sc_hash_array_t} + remote_processes::Ptr{sc_array_t} + glo_tree_mempool::Ptr{sc_mempool_t} + proc_offset_mempool::Ptr{sc_mempool_t} +end -!!! note +const t8_forest_ghost_t = Ptr{t8_forest_ghost} - For the root element this function always returns *face*. +""" + t8_forest_ghost_init(pghost, ghost_type) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -* `face`:\\[in\\] Then number of the face. -# Returns -If *face* of *element* is also a face of *element*'s parent, the face number of this face. Otherwise -1. ### Prototype ```c -int t8_element_face_get_parent_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); +void t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type); ``` """ -function t8_element_face_get_parent_face(scheme, tree_class, element, face) - @ccall libt8.t8_element_face_get_parent_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint +function t8_forest_ghost_init(pghost, ghost_type) + @ccall libt8.t8_forest_ghost_init(pghost::Ptr{t8_forest_ghost_t}, ghost_type::t8_ghost_type_t)::Cvoid end """ - t8_element_get_tree_face(scheme, tree_class, element, face) - -Given an element and a face of this element. If the face lies on the tree boundary, return the face number of the tree face. If not the return value is arbitrary. + t8_forest_ghost_num_trees(forest) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element. -* `face`:\\[in\\] The index of a face of *element*. -# Returns -The index of the tree face that *face* is a subface of, if *face* is on a tree boundary. Any arbitrary integer if *is* not at a tree boundary. ### Prototype ```c -int t8_element_get_tree_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); +t8_locidx_t t8_forest_ghost_num_trees (const t8_forest_t forest); ``` """ -function t8_element_get_tree_face(scheme, tree_class, element, face) - @ccall libt8.t8_element_get_tree_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint +function t8_forest_ghost_num_trees(forest) + @ccall libt8.t8_forest_ghost_num_trees(forest::t8_forest_t)::t8_locidx_t end """ - t8_element_transform_face(scheme, tree_class, elem1, elem2, orientation, sign, is_smaller_face) + t8_forest_ghost_get_tree_element_offset(forest, lghost_tree) -Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the trees and given the orientation of the tree connection, construct the face element of the respective tree neighbor that logically coincides with e but lies in the coordinate system of the neighbor tree. +Return the element offset of a ghost tree. !!! note - *elem1* and *elem2* may point to the same element. + forest must be committed before calling this function. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `elem1`:\\[in\\] The face element. -* `elem2`:\\[in,out\\] On return the face element *elem1* with respect to the coordinate system of the other tree. -* `orientation`:\\[in\\] The orientation of the tree-tree connection. -* `sign`:\\[in\\] Depending on the topological orientation of the two tree faces, either 0 (both faces have opposite orientation) or 1 (both faces have the same top. orientation). t8_eclass_face_orientation -* `is_smaller_face`:\\[in\\] Flag to declare whether *elem1* belongs to the smaller face. A face f of tree T is smaller than f' of T' if either the eclass of T is smaller or if the classes are equal and fghost\\_trees array of the tree. Otherwise a negative number. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The input element. -* `face`:\\[in\\] A face of *element*. -* `first_desc`:\\[in,out\\] An allocated element. This element's data will be filled with the data of the first descendant of *element* that shares a face with *face*. -* `level`:\\[in\\] The level, at which the first descendant is constructed ### Prototype ```c -void t8_element_get_first_descendant_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, t8_element_t *first_desc, const int level); +t8_locidx_t t8_forest_ghost_get_ghost_treeid (t8_forest_t forest, t8_gloidx_t gtreeid); ``` """ -function t8_element_get_first_descendant_face(scheme, tree_class, element, face, first_desc, level) - @ccall libt8.t8_element_get_first_descendant_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, first_desc::Ptr{t8_element_t}, level::Cint)::Cvoid +function t8_forest_ghost_get_ghost_treeid(forest, gtreeid) + @ccall libt8.t8_forest_ghost_get_ghost_treeid(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t end """ - t8_element_get_last_descendant_face(scheme, tree_class, element, face, last_desc, level) - -Construct the last descendant of an element at a given level that touches a given face. + t8_forest_ghost_get_tree_class(forest, lghost_tree) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The input element. -* `face`:\\[in\\] A face of *element*. -* `last_desc`:\\[in,out\\] An allocated element. This element's data will be filled with the data of the last descendant of *element* that shares a face with *face*. -* `level`:\\[in\\] The level, at which the last descendant is constructed ### Prototype ```c -void t8_element_get_last_descendant_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, t8_element_t *last_desc, const int level); +t8_eclass_t t8_forest_ghost_get_tree_class (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -function t8_element_get_last_descendant_face(scheme, tree_class, element, face, last_desc, level) - @ccall libt8.t8_element_get_last_descendant_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, last_desc::Ptr{t8_element_t}, level::Cint)::Cvoid +function t8_forest_ghost_get_tree_class(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_tree_class(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_eclass_t end """ - t8_element_is_root_boundary(scheme, tree_class, element, face) + t8_forest_ghost_get_global_treeid(forest, lghost_tree) -Compute whether a given element shares a given face with its root tree. +Given a local ghost tree compute the global tree id of it. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The input element. -* `face`:\\[in\\] A face of *element*. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. # Returns -True if *face* is a subface of the element's root element. +The global id of the local ghost tree *lghost_tree*. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -int t8_element_is_root_boundary (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); +t8_gloidx_t t8_forest_ghost_get_global_treeid (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -function t8_element_is_root_boundary(scheme, tree_class, element, face) - @ccall libt8.t8_element_is_root_boundary(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint +function t8_forest_ghost_get_global_treeid(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_global_treeid(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_gloidx_t end """ - t8_element_get_face_neighbor_inside(scheme, tree_class, element, neigh, face, neigh_face) - -Construct the face neighbor of a given element if this face neighbor is inside the root tree. Return 0 otherwise. + t8_forest_ghost_get_element(forest, lghost_tree, lelement) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element to be considered. -* `neigh`:\\[in,out\\] If the face neighbor of *element* along *face* is inside the root tree, this element's data is filled with the data of the face neighbor. Otherwise the data can be modified arbitrarily. -* `face`:\\[in\\] The number of the face along which the neighbor should be constructed. -* `neigh_face`:\\[out\\] The number of *face* as viewed from *neigh*. An arbitrary value, if the neighbor is not inside the root tree. -# Returns -True if *neigh* is inside the root tree. False if not. In this case *neigh*'s data can be arbitrary on output. ### Prototype ```c -int t8_element_get_face_neighbor_inside (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *neigh, const int face, int *neigh_face); +t8_element_t * t8_forest_ghost_get_element (t8_forest_t forest, t8_locidx_t lghost_tree, t8_locidx_t lelement); ``` """ -function t8_element_get_face_neighbor_inside(scheme, tree_class, element, neigh, face, neigh_face) - @ccall libt8.t8_element_get_face_neighbor_inside(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, neigh::Ptr{t8_element_t}, face::Cint, neigh_face::Ptr{Cint})::Cint +function t8_forest_ghost_get_element(forest, lghost_tree, lelement) + @ccall libt8.t8_forest_ghost_get_element(forest::t8_forest_t, lghost_tree::t8_locidx_t, lelement::t8_locidx_t)::Ptr{t8_element_t} end """ - t8_element_get_shape(scheme, tree_class, element) + t8_forest_ghost_get_remotes(forest, num_remotes) -Return the shape of an allocated element according its type. For example, a child of an element can be an element of a different shape and has to be handled differently - according to its shape. +Return the array of remote ranks. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element to be considered +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `num_remotes`:\\[in,out\\] On output the number of remote ranks is stored here. # Returns -The shape of the element as an eclass +The array of remote ranks in ascending order. ### Prototype ```c -t8_element_shape_t t8_element_get_shape (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); +int * t8_forest_ghost_get_remotes (t8_forest_t forest, int *num_remotes); ``` """ -function t8_element_get_shape(scheme, tree_class, element) - @ccall libt8.t8_element_get_shape(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::t8_element_shape_t +function t8_forest_ghost_get_remotes(forest, num_remotes) + @ccall libt8.t8_forest_ghost_get_remotes(forest::t8_forest_t, num_remotes::Ptr{Cint})::Ptr{Cint} end """ - t8_element_set_linear_id(scheme, tree_class, element, level, id) + t8_forest_ghost_remote_first_tree(forest, remote) -Initialize the entries of an allocated element according to a given linear id in a uniform refinement. +Return the first local ghost tree of a remote rank. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in,out\\] The element whose entries will be set. -* `level`:\\[in\\] The level of the uniform refinement to consider. -* `id`:\\[in\\] The linear id. id must fulfil 0 <= id < 'number of leaves in the uniform refinement' +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. +# Returns +The ghost tree id of the first ghost tree that stores ghost elements of *remote*. ### Prototype ```c -void t8_element_set_linear_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t *element, const int level, const t8_linearidx_t id); +t8_locidx_t t8_forest_ghost_remote_first_tree (t8_forest_t forest, int remote); ``` """ -function t8_element_set_linear_id(scheme, tree_class, element, level, id) - @ccall libt8.t8_element_set_linear_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint, id::t8_linearidx_t)::Cvoid +function t8_forest_ghost_remote_first_tree(forest, remote) + @ccall libt8.t8_forest_ghost_remote_first_tree(forest::t8_forest_t, remote::Cint)::t8_locidx_t end """ - t8_element_get_linear_id(scheme, tree_class, element, level) + t8_forest_ghost_remote_first_elem(forest, remote) -Compute the linear id of a given element in a hypothetical uniform refinement of a given level. +Return the local index of the first ghost element that belongs to a given remote rank. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element whose id we compute. -* `level`:\\[in\\] The level of the uniform refinement to consider. +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. # Returns -The linear id of the element. +The index i in the ghost elements of the first element of rank *remote* ### Prototype ```c -t8_linearidx_t t8_element_get_linear_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int level); +t8_locidx_t t8_forest_ghost_remote_first_elem (t8_forest_t forest, int remote); ``` """ -function t8_element_get_linear_id(scheme, tree_class, element, level) - @ccall libt8.t8_element_get_linear_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint)::t8_linearidx_t +function t8_forest_ghost_remote_first_elem(forest, remote) + @ccall libt8.t8_forest_ghost_remote_first_elem(forest::t8_forest_t, remote::Cint)::t8_locidx_t end """ - t8_element_get_first_descendant(scheme, tree_class, element, desc, level) + t8_forest_ghost_ref(ghost) -Compute the first descendant of a given element. +Increase the reference count of a ghost structure. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element whose descendant is computed. -* `desc`:\\[out\\] The first element in a uniform refinement of *element* at level *level*. -* `level`:\\[in\\] The uniform refinement level at which the descendant is computed. *level* must be greater or equal to the level of *element*. +* `ghost`:\\[in,out\\] On input, this ghost structure must exist with positive reference count. ### Prototype ```c -void t8_element_get_first_descendant (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *desc, const int level); +void t8_forest_ghost_ref (t8_forest_ghost_t ghost); ``` """ -function t8_element_get_first_descendant(scheme, tree_class, element, desc, level) - @ccall libt8.t8_element_get_first_descendant(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, desc::Ptr{t8_element_t}, level::Cint)::Cvoid +function t8_forest_ghost_ref(ghost) + @ccall libt8.t8_forest_ghost_ref(ghost::t8_forest_ghost_t)::Cvoid end """ - t8_element_get_last_descendant(scheme, tree_class, element, desc, level) + t8_forest_ghost_unref(pghost) -Compute the last descendant of a given element. +Decrease the reference count of a ghost structure. If the counter reaches zero, the ghost structure is destroyed. See also t8_forest_ghost_destroy, which is to be preferred when it is known that the last reference to a cmesh is deleted. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element whose descendant is computed. -* `desc`:\\[out\\] The last element in a uniform refinement of *element* of the maximum possible level. -* `level`:\\[in\\] The uniform refinement level at which the descendant is computed. *level* must be greater or equal to the level of *element*. +* `pghost`:\\[in,out\\] On input, the ghost structure pointed to must exist with positive reference count. If the reference count reaches zero, the ghost structure is destroyed and this pointer is set to NULL. Otherwise, the pointer is not changed. ### Prototype ```c -void t8_element_get_last_descendant (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *desc, const int level); +void t8_forest_ghost_unref (t8_forest_ghost_t *pghost); ``` """ -function t8_element_get_last_descendant(scheme, tree_class, element, desc, level) - @ccall libt8.t8_element_get_last_descendant(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, desc::Ptr{t8_element_t}, level::Cint)::Cvoid +function t8_forest_ghost_unref(pghost) + @ccall libt8.t8_forest_ghost_unref(pghost::Ptr{t8_forest_ghost_t})::Cvoid end """ - t8_element_get_successor(scheme, tree_class, elem1, elem2) + t8_forest_ghost_destroy(pghost) -Construct the successor in a uniform refinement of a given element. +Verify that a ghost structure has only one reference left and destroy it. This function is preferred over t8_ghost_unref when it is known that the last reference is to be deleted. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `elem1`:\\[in\\] The element whose successor should be constructed. -* `elem2`:\\[in,out\\] The element whose entries will be set. +* `pghost`:\\[in,out\\] This ghost structure must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_forest_ghost_unref. ### Prototype ```c -void t8_element_get_successor (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, t8_element_t *elem2); +void t8_forest_ghost_destroy (t8_forest_ghost_t *pghost); ``` """ -function t8_element_get_successor(scheme, tree_class, elem1, elem2) - @ccall libt8.t8_element_get_successor(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cvoid +function t8_forest_ghost_destroy(pghost) + @ccall libt8.t8_forest_ghost_destroy(pghost::Ptr{t8_forest_ghost_t})::Cvoid end """ - t8_element_get_vertex_reference_coords(scheme, tree_class, element, vertex, coords) - -Compute the coordinates of a given element vertex inside a reference tree that is embedded into [0,1]^d (d = dimension). - -!!! warning + t8_forest_ghost_create(forest) - coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere all coords might be used. +Create one layer of ghost elements for a forest. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element to be considered. -* `vertex`:\\[in\\] The id of the vertex whose coordinates shall be computed. -* `coords`:\\[out\\] An array of at least as many doubles as the element's dimension whose entries will be filled with the coordinates of *vertex*. +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +# See also +[`t8_forest_set_ghost`](@ref) + ### Prototype ```c -void t8_element_get_vertex_reference_coords (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int vertex, double coords[]); +void t8_forest_ghost_create (t8_forest_t forest); ``` """ -function t8_element_get_vertex_reference_coords(scheme, tree_class, element, vertex, coords) - @ccall libt8.t8_element_get_vertex_reference_coords(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, vertex::Cint, coords::Ptr{Cdouble})::Cvoid +function t8_forest_ghost_create(forest) + @ccall libt8.t8_forest_ghost_create(forest::t8_forest_t)::Cvoid end """ - t8_element_get_reference_coords(scheme, tree_class, element, ref_coords, num_coords, out_coords) - -Convert points in the reference space of an element to points in the reference space of the tree. - -```c++ - [0,1]^\\mathrm{dim} -``` + t8_forest_ghost_create_balanced_only(forest) -of the point in the reference space of the element. +Create one layer of ghost elements for a forest. This version only works with balanced forests and is the original algorithm from p4est: Scalable Algorithms For Parallel Adaptive Mesh Refinement On Forests of Octrees -```c++ - dim -``` +!!! note --sized coordinates to evaluate. + The user should prefer t8_forest_ghost_create even for balanced forests. # Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of the current tree. -* `element`:\\[in\\] The element. -* `ref_coords`:\\[in\\] The coordinates -* `num_coords`:\\[in\\] Number of -* `out_coords`:\\[out\\] The coordinates of the points in the reference space of the tree. +* `forest`:\\[in,out\\] The balanced forest/ *forest* must be committed before calling this function. ### Prototype ```c -void t8_element_get_reference_coords (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double out_coords[]); +void t8_forest_ghost_create_balanced_only (t8_forest_t forest); ``` """ -function t8_element_get_reference_coords(scheme, tree_class, element, ref_coords, num_coords, out_coords) - @ccall libt8.t8_element_get_reference_coords(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function t8_forest_ghost_create_balanced_only(forest) + @ccall libt8.t8_forest_ghost_create_balanced_only(forest::t8_forest_t)::Cvoid end """ - t8_element_count_leaves(scheme, tree_class, element, level) - -Count how many leaf descendants of a given uniform level an element would produce. - -Example: If *element* is a line element that refines into 2 line elements on each level, then the return value is max(0, 2^{*level* - level(*t*)}). Thus, if *element*'s level is 0, and *level* = 3, the return value is 2^3 = 8. + t8_forest_ghost_create_topdown(forest) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in\\] The element to be checked. -* `level`:\\[in\\] A refinement level. -# Returns -Suppose *element* is uniformly refined up to level *level*. The return value is the resulting number of elements (of the given level). If *level* < [`t8_element_get_level`](@ref)(element), the return value should be 0. ### Prototype ```c -t8_gloidx_t t8_element_count_leaves (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int level); +void t8_forest_ghost_create_topdown (t8_forest_t forest); ``` """ -function t8_element_count_leaves(scheme, tree_class, element, level) - @ccall libt8.t8_element_count_leaves(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint)::t8_gloidx_t +function t8_forest_ghost_create_topdown(forest) + @ccall libt8.t8_forest_ghost_create_topdown(forest::t8_forest_t)::Cvoid end """ - t8_element_count_leaves_from_root(scheme, tree_class, level) - -Count how many leaf descendants of a given uniform level the root element will produce. - -This is a convenience function, and can be implemented via t8_element_count_leaves. + t8_forest_save(forest) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `level`:\\[in\\] A refinement level. -# Returns -The value of t8_element_count_leaves if the input element is the root (level 0) element. ### Prototype ```c -t8_gloidx_t t8_element_count_leaves_from_root (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int level); +void t8_forest_save (t8_forest_t forest); ``` """ -function t8_element_count_leaves_from_root(scheme, tree_class, level) - @ccall libt8.t8_element_count_leaves_from_root(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, level::Cint)::t8_gloidx_t +function t8_forest_save(forest) + @ccall libt8.t8_forest_save(forest::t8_forest_t)::Cvoid end """ - t8_element_to_string(scheme, tree_class, element, debug_string, string_size) - -Fill a string with readable information about the element + t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of the current tree. -* `element`:\\[in\\] The element to translate into human-readable information. -* `debug_string`:\\[in,out\\] The string to fill. -* `string_size`:\\[in\\] The length of *debug_string*. ### Prototype ```c -void t8_element_to_string (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, char *debug_string, const int string_size); +int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, const int write_curved, int do_not_use_API, const int num_data, t8_vtk_data_field_t *data); ``` """ -function t8_element_to_string(scheme, tree_class, element, debug_string, string_size) - @ccall libt8.t8_element_to_string(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, debug_string::Cstring, string_size::Cint)::Cvoid +function t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) + @ccall libt8.t8_forest_write_vtk_ext(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, write_curved::Cint, do_not_use_API::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_element_new(scheme, tree_class, length, elems) - -Allocate memory for an array of elements of a given class and initialize them. - -!!! note - - Not every element that is created in t8code will be created by a call to this function. However, if an element is not created using t8_element_new, then it is guaranteed that t8_scheme::element_init is called on it. - -!!! note - - In debugging mode, an element that was created with t8_element_new must pass t8_element_is_valid. - -!!! note - - If an element was created by t8_element_new then t8_scheme::element_init may not be called for it. Thus, t8_element_new should initialize an element in the same way as a call to t8_scheme::element_init would. - -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `length`:\\[in\\] The number of elements to be allocated. -* `elems`:\\[in,out\\] On input an array of **length** many unallocated element pointers. On output all these pointers will point to an allocated and initialized element. -# See also -[`t8_element_init`](@ref), element\\_is\\_valid + t8_forest_write_vtk(forest, fileprefix) ### Prototype ```c -void t8_element_new (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t **elems); +int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix); ``` """ -function t8_element_new(scheme, tree_class, length, elems) - @ccall libt8.t8_element_new(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elems::Ptr{Ptr{t8_element_t}})::Cvoid +function t8_forest_write_vtk(forest, fileprefix) + @ccall libt8.t8_forest_write_vtk(forest::t8_forest_t, fileprefix::Cstring)::Cint end -""" - t8_element_init(scheme, tree_class, length, elem) - -Initialize an array of allocated elements. - -!!! note - - In debugging mode, an element that was passed to t8_element_init must pass t8_element_is_valid. - -!!! note - - If an element was created by t8_element_new then t8_element_init may not be called for it. Thus, t8_element_init should initialize an element in the same way as a call to t8_element_new would. - -!!! note +# typedef int ( * t8_forest_iterate_face_fn ) ( t8_forest_t forest , t8_locidx_t ltreeid , const t8_element_t * element , int face , void * user_data , t8_locidx_t tree_leaf_index ) +const t8_forest_iterate_face_fn = Ptr{Cvoid} - Every call to +# typedef int ( * t8_forest_search_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index ) +""" +A call-back function used by t8_forest_search describing a search-criterion. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. # Arguments -* `scheme`:\\[in\\] The scheme to use. -* `tree_class`:\\[in\\] The eclass of the current tree. -* `length`:\\[in\\] The number of elements to be initialized. -* `elem`:\\[in,out\\] On input an array of *length* many allocated elements. -# See also -[`t8_element_init`](@ref) must be matched by a call to, [`t8_element_deinit`](@ref), [`t8_element_deinit`](@ref), [`t8_element_new`](@ref), t8\\_element\\_is\\_valid - -### Prototype -```c -void t8_element_init (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t *elem); -``` +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree +* `element`:\\[in\\] the element for which the search criterion is checked. +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* that are descendants of *element* (or the element itself if *is_leaf* is true) +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* +# Returns +non-zero if the search criterion is met, zero otherwise. """ -function t8_element_init(scheme, tree_class, length, elem) - @ccall libt8.t8_element_init(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elem::Ptr{t8_element_t})::Cvoid -end +const t8_forest_search_fn = Ptr{Cvoid} +# typedef void ( * t8_forest_query_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , sc_array_t * queries , sc_array_t * query_indices , int * query_matches , const size_t num_active_queries ) """ - t8_element_deinit(scheme, tree_class, length, elems) - -Deinitialize an array of allocated elements. - -!!! note - - Call this function if you called t8_element_init on the element pointers. +A call-back function used by t8_forest_search for queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. # Arguments -* `scheme`:\\[in\\] The scheme to use. -* `tree_class`:\\[in\\] The eclass of the current tree. -* `length`:\\[in\\] The number of elements to be deinitialized. -* `elems`:\\[in,out\\] On input an array of *length* many allocated and initialized elements, on output an array of *length* many allocated, but not initialized elements. -# See also -[`t8_element_init`](@ref) +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree +* `element`:\\[in\\] the element for which the queries are executed +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* that are descendants of *element* (or the element itself if *is_leaf* is true) +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* +* `queries`:\\[in\\] An array of queries that are checked by the function +* `query_indices`:\\[in\\] An array of size\\_t entries, where each entry is an index of a query in queries. +* `query_matches`:\\[in,out\\] An array of length *num_active_queries*. If the element is not a leave must be set to true or false at the i-th index for each query, specifying whether the element 'matches' the query of the i-th query index or not. When the element is a leaf we can return before all entries are set. +* `num_active_queries`:\\[in\\] The number of currently active queries (equals the number of entries of *query_matches* and entries of *query_indices*). +""" +const t8_forest_query_fn = Ptr{Cvoid} + +""" + t8_forest_split_array(element, leaf_elements, offsets) ### Prototype ```c -void t8_element_deinit (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t *elems); +void t8_forest_split_array (const t8_element_t *element, t8_element_array_t *leaf_elements, size_t *offsets); ``` """ -function t8_element_deinit(scheme, tree_class, length, elems) - @ccall libt8.t8_element_deinit(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elems::Ptr{t8_element_t})::Cvoid +function t8_forest_split_array(element, leaf_elements, offsets) + @ccall libt8.t8_forest_split_array(element::Ptr{t8_element_t}, leaf_elements::Ptr{t8_element_array_t}, offsets::Ptr{Csize_t})::Cvoid end """ - t8_element_destroy(scheme, tree_class, length, elems) - -Deallocate an array of elements. + t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, user_data, tree_lindex_of_first_leaf, callback) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `length`:\\[in\\] The number of elements in the array. -* `elems`:\\[in,out\\] On input an array of **length** many allocated element pointers. On output all these pointers will be freed. **element** itself will not be freed by this function. ### Prototype ```c -void t8_element_destroy (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t **elems); +void t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, t8_element_array_t *leaf_elements, void *user_data, t8_locidx_t tree_lindex_of_first_leaf, t8_forest_iterate_face_fn callback); ``` """ -function t8_element_destroy(scheme, tree_class, length, elems) - @ccall libt8.t8_element_destroy(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elems::Ptr{Ptr{t8_element_t}})::Cvoid +function t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, user_data, tree_lindex_of_first_leaf, callback) + @ccall libt8.t8_forest_iterate_faces(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, leaf_elements::Ptr{t8_element_array_t}, user_data::Ptr{Cvoid}, tree_lindex_of_first_leaf::t8_locidx_t, callback::t8_forest_iterate_face_fn)::Cvoid end """ - t8_element_set_to_root(scheme, tree_class, element) - -Fills an element with the root element. + t8_forest_search(forest, search_fn, query_fn, queries) -# Arguments -* `scheme`:\\[in\\] The scheme of the forest. -* `tree_class`:\\[in\\] The eclass of tree the elements are part of. -* `element`:\\[in,out\\] The element to be filled with root. ### Prototype ```c -void t8_element_set_to_root (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t *element); +void t8_forest_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries); ``` """ -function t8_element_set_to_root(scheme, tree_class, element) - @ccall libt8.t8_element_set_to_root(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cvoid +function t8_forest_search(forest, search_fn, query_fn, queries) + @ccall libt8.t8_forest_search(forest::t8_forest_t, search_fn::t8_forest_search_fn, query_fn::t8_forest_query_fn, queries::Ptr{sc_array_t})::Cvoid end """ - t8_element_MPI_Pack(scheme, tree_class, elements, count, send_buffer, buffer_size, position, comm) + t8_forest_iterate_replace(forest_new, forest_old, replace_fn) + +Given two forest where the elements in one forest are either direct children or parents of the elements in the other forest compare the two forests and for each refined element or coarsened family in the old one, call a callback function providing the local indices of the old and new elements. + +!!! note + + To pass a user pointer to *replace_fn* use t8_forest_set_user_data and t8_forest_get_user_data. +# Arguments +* `forest_new`:\\[in\\] A forest, each element is a parent or child of an element in *forest_old*. +* `forest_old`:\\[in\\] The initial forest. +* `replace_fn`:\\[in\\] A replace callback function. ### Prototype ```c -void t8_element_MPI_Pack (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t **const elements, const unsigned int count, void *send_buffer, const int buffer_size, int *position, sc_MPI_Comm comm); +void t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_forest_replace_t replace_fn); ``` """ -function t8_element_MPI_Pack(scheme, tree_class, elements, count, send_buffer, buffer_size, position, comm) - @ccall libt8.t8_element_MPI_Pack(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elements::Ptr{Ptr{t8_element_t}}, count::Cuint, send_buffer::Ptr{Cvoid}, buffer_size::Cint, position::Ptr{Cint}, comm::MPI_Comm)::Cvoid +function t8_forest_iterate_replace(forest_new, forest_old, replace_fn) + @ccall libt8.t8_forest_iterate_replace(forest_new::t8_forest_t, forest_old::t8_forest_t, replace_fn::t8_forest_replace_t)::Cvoid end """ - t8_element_MPI_Pack_size(scheme, tree_class, count, comm, pack_size) + t8_forest_partition(forest) ### Prototype ```c -void t8_element_MPI_Pack_size (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const unsigned int count, sc_MPI_Comm comm, int *pack_size); +void t8_forest_partition (t8_forest_t forest); ``` """ -function t8_element_MPI_Pack_size(scheme, tree_class, count, comm, pack_size) - @ccall libt8.t8_element_MPI_Pack_size(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, count::Cuint, comm::MPI_Comm, pack_size::Ptr{Cint})::Cvoid +function t8_forest_partition(forest) + @ccall libt8.t8_forest_partition(forest::t8_forest_t)::Cvoid end """ - t8_element_MPI_Unpack(scheme, tree_class, recvbuf, buffer_size, position, elements, count, comm) + t8_forest_partition_create_offsets(forest) + +Create the element\\_offset array of a partitioned forest. +# Arguments +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -void t8_element_MPI_Unpack (const t8_scheme_c *scheme, const t8_eclass_t tree_class, void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm); +void t8_forest_partition_create_offsets (t8_forest_t forest); ``` """ -function t8_element_MPI_Unpack(scheme, tree_class, recvbuf, buffer_size, position, elements, count, comm) - @ccall libt8.t8_element_MPI_Unpack(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, recvbuf::Ptr{Cvoid}, buffer_size::Cint, position::Ptr{Cint}, elements::Ptr{Ptr{t8_element_t}}, count::Cuint, comm::MPI_Comm)::Cvoid +function t8_forest_partition_create_offsets(forest) + @ccall libt8.t8_forest_partition_create_offsets(forest::t8_forest_t)::Cvoid end """ - t8_norm(vec) + t8_forest_partition_next_nonempty_rank(forest, rank) -Vector norm. +If t8_forest_partition_create_offsets was already called, compute for a given rank the next greater rank that is not empty. # Arguments -* `vec`:\\[in\\] A 3D vector. +* `forest`:\\[in\\] The forest. +* `rank`:\\[in\\] An MPI rank. # Returns -The norm of *vec*. +A rank q > *rank* such that the forest has elements on *q*. If such a *q* does not exist, returns mpisize. ### Prototype ```c -double t8_norm (const double vec[3]); +int t8_forest_partition_next_nonempty_rank (t8_forest_t forest, int rank); ``` """ -function t8_norm(vec) - @ccall libt8.t8_norm(vec::Ptr{Cdouble})::Cdouble +function t8_forest_partition_next_nonempty_rank(forest, rank) + @ccall libt8.t8_forest_partition_next_nonempty_rank(forest::t8_forest_t, rank::Cint)::Cint end """ - t8_normalize(vec) + t8_forest_partition_create_first_desc(forest) -Normalize a vector. +Create the array of global\\_first\\_descendant ids of a partitioned forest. # Arguments -* `vec`:\\[in,out\\] A 3D vector. +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -void t8_normalize (double vec[3]); +void t8_forest_partition_create_first_desc (t8_forest_t forest); ``` """ -function t8_normalize(vec) - @ccall libt8.t8_normalize(vec::Ptr{Cdouble})::Cvoid +function t8_forest_partition_create_first_desc(forest) + @ccall libt8.t8_forest_partition_create_first_desc(forest::t8_forest_t)::Cvoid end """ - t8_copy(dimensional_in, dimensional_out) + t8_forest_partition_create_tree_offsets(forest) -Make a copy of a dimensional object. +Create the array tree offsets of a partitioned forest. This arrays stores at position p the global id of the first tree of this process. Or if this tree is shared, it stores -(global\\_id) - 1. # Arguments -* `dimensional_in`:\\[in\\] -* `dimensional_out`:\\[out\\] +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -void t8_copy (const double dimensional_in[3], double dimensional_out[3]); +void t8_forest_partition_create_tree_offsets (t8_forest_t forest); ``` """ -function t8_copy(dimensional_in, dimensional_out) - @ccall libt8.t8_copy(dimensional_in::Ptr{Cdouble}, dimensional_out::Ptr{Cdouble})::Cvoid +function t8_forest_partition_create_tree_offsets(forest) + @ccall libt8.t8_forest_partition_create_tree_offsets(forest::t8_forest_t)::Cvoid end """ - t8_dist(vec_x, vec_y) + t8_forest_partition_data(forest_from, forest_to, data_in, data_out) -Euclidean distance of X and Y. +Re-Partition an array accordingly to a partitioned forest. + +!!! note + + *data_in* has to be of size equal to the number of local elements of *forest_from* *data_out* has to be already allocated and has to be of size equal to the number of local elements of *forest_to*. # Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -# Returns -The euclidean distance. Equivalent to norm (X-Y). +* `forest_form`:\\[in\\] The forest before the partitioning step. +* `forest_to`:\\[in\\] The partitioned forest of *forest_from*. +* `data_in`:\\[in\\] A pointer to an [`sc_array_t`](@ref) holding data (one value per element) accordingly to *forest_from*. +* `data_out`:\\[in,out\\] A pointer to an already allocated [`sc_array_t`](@ref) capable of holding data accordingly to *forest_to*. ### Prototype ```c -double t8_dist (const double vec_x[3], const double vec_y[3]); +void t8_forest_partition_data (t8_forest_t forest_from, t8_forest_t forest_to, const sc_array_t *data_in, sc_array_t *data_out); ``` """ -function t8_dist(vec_x, vec_y) - @ccall libt8.t8_dist(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +function t8_forest_partition_data(forest_from, forest_to, data_in, data_out) + @ccall libt8.t8_forest_partition_data(forest_from::t8_forest_t, forest_to::t8_forest_t, data_in::Ptr{sc_array_t}, data_out::Ptr{sc_array_t})::Cvoid end """ - t8_ax(vec_x, alpha) + t8_forest_partition_test_boundary_element(forest) -Compute X = alpha * X +Test if the last descendant of the last element of current rank has a smaller linear id than the stored first descendant of rank+1. If this is not the case, elements overlap. + +!!! note + + *forest* must be committed before calling this function. # Arguments -* `vec_x`:\\[in,out\\] A 3D vector. On output set to *alpha* * *vec_x*. -* `alpha`:\\[in\\] A factor. +* `forest`:\\[in\\] The forest. ### Prototype ```c -void t8_ax (double vec_x[3], const double alpha); +void t8_forest_partition_test_boundary_element (const t8_forest_t forest); ``` """ -function t8_ax(vec_x, alpha) - @ccall libt8.t8_ax(vec_x::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +function t8_forest_partition_test_boundary_element(forest) + @ccall libt8.t8_forest_partition_test_boundary_element(forest::t8_forest_t)::Cvoid end """ - t8_axy(vec_x, vec_y, alpha) - -Compute Y = alpha * X + t8_forest_set_profiling(forest, set_profiling) -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[out\\] On output set to *alpha* * *vec_x*. -* `alpha`:\\[in\\] A factor. ### Prototype ```c -void t8_axy (const double vec_x[3], double vec_y[3], const double alpha); +void t8_forest_set_profiling (t8_forest_t forest, int set_profiling); ``` """ -function t8_axy(vec_x, vec_y, alpha) - @ccall libt8.t8_axy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +function t8_forest_set_profiling(forest, set_profiling) + @ccall libt8.t8_forest_set_profiling(forest::t8_forest_t, set_profiling::Cint)::Cvoid end """ - t8_axb(vec_x, vec_y, alpha, b) - -Y = alpha * X + b - -!!! note - - It is possible that vec\\_x = vec\\_y on input to overwrite x + t8_forest_compute_profile(forest) -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[out\\] On input, a 3D vector. On output set to *alpha* * *vec_x* + *b*. -* `alpha`:\\[in\\] A factor. -* `b`:\\[in\\] An offset. ### Prototype ```c -void t8_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b); +void t8_forest_compute_profile (t8_forest_t forest); ``` """ -function t8_axb(vec_x, vec_y, alpha, b) - @ccall libt8.t8_axb(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble, b::Cdouble)::Cvoid +function t8_forest_compute_profile(forest) + @ccall libt8.t8_forest_compute_profile(forest::t8_forest_t)::Cvoid end """ - t8_axpy(vec_x, vec_y, alpha) - -Y = Y + alpha * X + t8_forest_profile_get_adapt_stats(forest) -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in,out\\] On input, a 3D vector. On output set *to* vec\\_y + *alpha* * *vec_x* -* `alpha`:\\[in\\] A factor. ### Prototype ```c -void t8_axpy (const double vec_x[3], double vec_y[3], const double alpha); +const sc_statinfo_t * t8_forest_profile_get_adapt_stats (t8_forest_t forest); ``` """ -function t8_axpy(vec_x, vec_y, alpha) - @ccall libt8.t8_axpy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +function t8_forest_profile_get_adapt_stats(forest) + @ccall libt8.t8_forest_profile_get_adapt_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_axpyz(vec_x, vec_y, vec_z, alpha) - -Z = Y + alpha * X + t8_forest_profile_get_ghost_stats(forest) -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -* `vec_z`:\\[out\\] On output set *to* vec\\_y + *alpha* * *vec_x* -* `alpha`:\\[in\\] A factor for the multiplication of *vec_x*. ### Prototype ```c -void t8_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], const double alpha); +const sc_statinfo_t * t8_forest_profile_get_ghost_stats (t8_forest_t forest); ``` """ -function t8_axpyz(vec_x, vec_y, vec_z, alpha) - @ccall libt8.t8_axpyz(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, vec_z::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +function t8_forest_profile_get_ghost_stats(forest) + @ccall libt8.t8_forest_profile_get_ghost_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_dot(vec_x, vec_y) - -Dot product of X and Y. + t8_forest_profile_get_partition_stats(forest) -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -# Returns -The dot product *vec_x* * *vec_y* ### Prototype ```c -double t8_dot (const double vec_x[3], const double vec_y[3]); +const sc_statinfo_t * t8_forest_profile_get_partition_stats (t8_forest_t forest); ``` """ -function t8_dot(vec_x, vec_y) - @ccall libt8.t8_dot(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +function t8_forest_profile_get_partition_stats(forest) + @ccall libt8.t8_forest_profile_get_partition_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_cross_3D(vec_x, vec_y, cross) - -Cross product of X and Y + t8_forest_profile_get_commit_stats(forest) -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -* `cross`:\\[out\\] On output, the cross product of *vec_x* and *vec_y*. ### Prototype ```c -void t8_cross_3D (const double vec_x[3], const double vec_y[3], double cross[3]); +const sc_statinfo_t * t8_forest_profile_get_commit_stats (t8_forest_t forest); ``` """ -function t8_cross_3D(vec_x, vec_y, cross) - @ccall libt8.t8_cross_3D(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, cross::Ptr{Cdouble})::Cvoid +function t8_forest_profile_get_commit_stats(forest) + @ccall libt8.t8_forest_profile_get_commit_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_cross_2D(vec_x, vec_y) - -Cross product of X and Y + t8_forest_profile_get_balance_stats(forest) -# Arguments -* `vec_x`:\\[in\\] A 2D vector. -* `vec_y`:\\[in\\] A 2D vector. -# Returns -The cross product of *vec_x* and *vec_y*. ### Prototype ```c -double t8_cross_2D (const double vec_x[2], const double vec_y[2]); +const sc_statinfo_t * t8_forest_profile_get_balance_stats (t8_forest_t forest); ``` """ -function t8_cross_2D(vec_x, vec_y) - @ccall libt8.t8_cross_2D(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +function t8_forest_profile_get_balance_stats(forest) + @ccall libt8.t8_forest_profile_get_balance_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_diff(vec_x, vec_y, diff) - -Compute the difference of two vectors. + t8_forest_profile_get_balance_rounds_stats(forest) -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -* `diff`:\\[out\\] On output, the difference of *vec_x* and *vec_y*. ### Prototype ```c -void t8_diff (const double vec_x[3], const double vec_y[3], double diff[3]); +const sc_statinfo_t * t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); ``` """ -function t8_diff(vec_x, vec_y, diff) - @ccall libt8.t8_diff(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, diff::Ptr{Cdouble})::Cvoid +function t8_forest_profile_get_balance_rounds_stats(forest) + @ccall libt8.t8_forest_profile_get_balance_rounds_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_eq(vec_x, vec_y, tol) - -Check the equality of two vectors elementwise + t8_forest_print_profile(forest) -# Arguments -* `vec_x`:\\[in\\] -* `vec_y`:\\[in\\] -* `tol`:\\[in\\] -# Returns -true, if the vectors are equal up to *tol* ### Prototype ```c -int t8_eq (const double vec_x[3], const double vec_y[3], const double tol); +void t8_forest_print_profile (t8_forest_t forest); ``` """ -function t8_eq(vec_x, vec_y, tol) - @ccall libt8.t8_eq(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, tol::Cdouble)::Cint +function t8_forest_print_profile(forest) + @ccall libt8.t8_forest_print_profile(forest::t8_forest_t)::Cvoid end """ - t8_rescale(vec, new_length) - -Rescale a vector to a new length. + t8_forest_profile_get_adapt_time(forest) -# Arguments -* `vec`:\\[in,out\\] A 3D vector. -* `new_length`:\\[in\\] New length of the vector. ### Prototype ```c -void t8_rescale (double vec[3], const double new_length); +double t8_forest_profile_get_adapt_time (t8_forest_t forest); ``` """ -function t8_rescale(vec, new_length) - @ccall libt8.t8_rescale(vec::Ptr{Cdouble}, new_length::Cdouble)::Cvoid +function t8_forest_profile_get_adapt_time(forest) + @ccall libt8.t8_forest_profile_get_adapt_time(forest::t8_forest_t)::Cdouble end """ - t8_normal_of_tri(p1, p2, p3, normal) - -Compute the normal of a triangle given by its three vertices. + t8_forest_profile_get_partition_time(forest, procs_sent) -# Arguments -* `p1`:\\[in\\] A 3D vector. -* `p2`:\\[in\\] A 3D vector. -* `p3`:\\[in\\] A 3D vector. -* `normal`:\\[out\\] vector of the triangle. (Not necessarily of length 1!) ### Prototype ```c -void t8_normal_of_tri (const double p1[3], const double p2[3], const double p3[3], double normal[3]); +double t8_forest_profile_get_partition_time (t8_forest_t forest, int *procs_sent); ``` """ -function t8_normal_of_tri(p1, p2, p3, normal) - @ccall libt8.t8_normal_of_tri(p1::Ptr{Cdouble}, p2::Ptr{Cdouble}, p3::Ptr{Cdouble}, normal::Ptr{Cdouble})::Cvoid +function t8_forest_profile_get_partition_time(forest, procs_sent) + @ccall libt8.t8_forest_profile_get_partition_time(forest::t8_forest_t, procs_sent::Ptr{Cint})::Cdouble end """ - t8_orthogonal_tripod(v1, v2, v3) - -Compute an orthogonal coordinate system from a given vector. + t8_forest_profile_get_balance_time(forest, balance_rounds) -# Arguments -* `v1`:\\[in\\] 3D vector. -* `v2`:\\[out\\] 3D vector. -* `v3`:\\[out\\] 3D vector. ### Prototype ```c -void t8_orthogonal_tripod (const double v1[3], double v2[3], double v3[3]); +double t8_forest_profile_get_balance_time (t8_forest_t forest, int *balance_rounds); ``` """ -function t8_orthogonal_tripod(v1, v2, v3) - @ccall libt8.t8_orthogonal_tripod(v1::Ptr{Cdouble}, v2::Ptr{Cdouble}, v3::Ptr{Cdouble})::Cvoid +function t8_forest_profile_get_balance_time(forest, balance_rounds) + @ccall libt8.t8_forest_profile_get_balance_time(forest::t8_forest_t, balance_rounds::Ptr{Cint})::Cdouble end """ - t8_swap(p1, p2) - -Swap the components of two vectors. + t8_forest_profile_get_ghost_time(forest, ghosts_sent) -# Arguments -* `p1`:\\[in,out\\] A 3D vector. -* `p2`:\\[in,out\\] A 3D vector. ### Prototype ```c -void t8_swap (double p1[3], double p2[3]); +double t8_forest_profile_get_ghost_time (t8_forest_t forest, t8_locidx_t *ghosts_sent); ``` """ -function t8_swap(p1, p2) - @ccall libt8.t8_swap(p1::Ptr{Cdouble}, p2::Ptr{Cdouble})::Cvoid +function t8_forest_profile_get_ghost_time(forest, ghosts_sent) + @ccall libt8.t8_forest_profile_get_ghost_time(forest::t8_forest_t, ghosts_sent::Ptr{Cint})::Cdouble end """ - t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) - -Writes the pvtu header file that links to the processor local files. It is used by the cmesh and forest vtk routines. This function should only be called by one process. Return 0 on success. + t8_forest_profile_get_ghostexchange_waittime(forest) ### Prototype ```c -int t8_write_pvtu (const char *filename, int num_procs, int write_tree, int write_rank, int write_level, int write_id, int num_data, t8_vtk_data_field_t *data); +double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest); ``` """ -function t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) - @ccall libt8.t8_write_pvtu(filename::Cstring, num_procs::Cint, write_tree::Cint, write_rank::Cint, write_level::Cint, write_id::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_forest_profile_get_ghostexchange_waittime(forest) + @ccall libt8.t8_forest_profile_get_ghostexchange_waittime(forest::t8_forest_t)::Cdouble end """ - vtk_file_type - -Enumerator for all types of files readable by t8code. + t8_profile -| Enumerator | Note | -| :----------------------------------- | :--------------------------------------------- | -| VTK\\_FILE\\_ERROR | For Testing purpose. | -| VTK\\_SERIAL\\_FILE | VTK file type of serial files. | -| VTK\\_UNSTRUCTURED\\_FILE | Unstructured file type is the same as serial. | -| VTK\\_POLYDATA\\_FILE | VTK polydata file type. | -| VTK\\_PARALLEL\\_FILE | VTK file type of parallel files. | -| VTK\\_PARALLEL\\_UNSTRUCTURED\\_FILE | For parallel unstructured files. | -| VTK\\_PARALLEL\\_POLYDATA\\_FILE | VTK polydata parallel file type. | -| VTK\\_NUM\\_TYPES | Number of different vtk file types supported. | +| Field | Note | +| :----------------------------- | :--------------------------------------------------------------------------------------------------------------------- | +| partition\\_elements\\_shipped | The number of elements this process has sent to other in the last partition call. | +| partition\\_elements\\_recv | The number of elements this process has received from other in the last partition call. | +| partition\\_bytes\\_sent | The total number of bytes sent to other processes in the last partition call. | +| partition\\_procs\\_sent | The number of different processes this process has send local elements to in the last partition call. | +| ghosts\\_shipped | The number of ghost elements this process has sent to other processes. | +| ghosts\\_received | The number of ghost elements this process has received from other processes. | +| ghosts\\_remotes | The number of processes this process have sent ghost elements to (and received from). | +| balance\\_rounds | The number of iterations during balance. | +| adapt\\_runtime | The runtime of the last call to [`t8_forest_adapt`](@ref) (not counting adaptation in [`t8_forest_balance`](@ref)). | +| partition\\_runtime | The runtime of the last call to [`t8_cmesh_partition`](@ref) (not count in partition in [`t8_forest_balance`](@ref)). | +| ghost\\_runtime | The runtime of the last call to [`t8_forest_ghost_create`](@ref). | +| ghost\\_waittime | Amount of synchronisation time in ghost. | +| balance\\_runtime | The runtime of the last call to [`t8_forest_balance`](@ref). | +| commit\\_runtime | The runtime of the last call to [`t8_cmesh_commit`](@ref). | """ -@cenum vtk_file_type::Int32 begin - VTK_FILE_ERROR = -1 - VTK_SERIAL_FILE = 8 - VTK_UNSTRUCTURED_FILE = 8 - VTK_POLYDATA_FILE = 9 - VTK_PARALLEL_FILE = 16 - VTK_PARALLEL_UNSTRUCTURED_FILE = 16 - VTK_PARALLEL_POLYDATA_FILE = 17 - VTK_NUM_TYPES = 5 +struct t8_profile + partition_elements_shipped::t8_locidx_t + partition_elements_recv::t8_locidx_t + partition_bytes_sent::Csize_t + partition_procs_sent::Cint + ghosts_shipped::t8_locidx_t + ghosts_received::t8_locidx_t + ghosts_remotes::Cint + balance_rounds::Cint + adapt_runtime::Cdouble + partition_runtime::Cdouble + ghost_runtime::Cdouble + ghost_waittime::Cdouble + balance_runtime::Cdouble + commit_runtime::Cdouble end -"""Enumerator for all types of files readable by t8code.""" -const vtk_file_type_t = vtk_file_type +const t8_profile_t = t8_profile + +"""If a forest is to be derived from another forest, there are different possibilities how the original forest is modified. Currently we support: Copying, adapting, partitioning, and balancing a forest. The latter 3 can be combined, in which case the order is 1. Adapt, 2. Partition, 3. Balance. We store the methods in an int8\\_t and use these defines to distinguish between them.""" +const t8_forest_from_t = Int8 + +"""This structure is private to the implementation.""" +const t8_forest_struct_t = t8_forest + +"""The t8 tree datatype""" +const t8_tree_struct_t = t8_tree + +const t8_profile_struct_t = t8_profile + +const t8_forest_ghost_struct_t = t8_forest_ghost """ - vtk_read_success + t8_geometry_type -Enumerator for the success of reading a vtk file. This is used to indicate whether the reading was successful or not. +This enumeration contains all possible geometries. -| Enumerator | Note | -| :------------- | :----------------------------------------------- | -| read\\_failure | Indicates that file reading was not successful. | -| read\\_success | Indicates that file reading was successful. | +| Enumerator | Note | +| :--------------------------------------------- | :----------------------------------------------------------------------------------------------- | +| T8\\_GEOMETRY\\_TYPE\\_ZERO | The zero geometry maps all points to zero. | +| T8\\_GEOMETRY\\_TYPE\\_LINEAR | The linear geometry uses linear interpolations to interpolate between the tree vertices. | +| T8\\_GEOMETRY\\_TYPE\\_LINEAR\\_AXIS\\_ALIGNED | The linear, axis aligned geometry uses only 2 vertices, since it is axis aligned. | +| T8\\_GEOMETRY\\_TYPE\\_LAGRANGE | The Lagrange geometry uses a mapping with Lagrange polynomials to approximate curved elements . | +| T8\\_GEOMETRY\\_TYPE\\_ANALYTIC | The analytic geometry uses a user-defined analytic function to map into the physical domain. | +| T8\\_GEOMETRY\\_TYPE\\_CAD | The opencascade geometry uses CAD shapes to map trees exactly to the underlying CAD model. | +| T8\\_GEOMETRY\\_TYPE\\_COUNT | This is no geometry type but can be used as the number of geometry types. | +| T8\\_GEOMETRY\\_TYPE\\_UNDEFINED | This is no geometry type but is used for every geometry, where no type is defined | """ -@cenum vtk_read_success::UInt32 begin - read_failure = 0 - read_success = 1 +@cenum t8_geometry_type::UInt32 begin + T8_GEOMETRY_TYPE_ZERO = 0 + T8_GEOMETRY_TYPE_LINEAR = 1 + T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED = 2 + T8_GEOMETRY_TYPE_LAGRANGE = 3 + T8_GEOMETRY_TYPE_ANALYTIC = 4 + T8_GEOMETRY_TYPE_CAD = 5 + T8_GEOMETRY_TYPE_COUNT = 6 + T8_GEOMETRY_TYPE_UNDEFINED = 7 end -"""Enumerator for the success of reading a vtk file. This is used to indicate whether the reading was successful or not.""" -const vtk_read_success_t = vtk_read_success +"""This enumeration contains all possible geometries.""" +const t8_geometry_type_t = t8_geometry_type """ - t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) - -Write the forest in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function uses the vtk library. t8code must be configured with "-DT8CODE\\_ENABLE\\_VTK=ON" in order to use it. Currently does not support pyramid elements. - -!!! note + t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) - If t8code was not configured with vtk, use t8_forest_vtk_write_file +Evaluates the geometry of a tree at a given reference point. # Arguments -* `forest`:\\[in\\] The forest. -* `fileprefix`:\\[in\\] The prefix of the output files. The meta file will be named *fileprefix*.pvtu . -* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. -* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. -* `write_level`:\\[in\\] If true, the refinement level is written for each element. -* `write_element_id`:\\[in\\] If true, the global element id is written for each element. -* `curved_flag`:\\[in\\] If true, write the elements as curved element types from vtk. -* `write_ghosts`:\\[in\\] If true, write out ghost elements as well. -* `num_data`:\\[in\\] Number of user defined double valued data fields to write. -* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the user defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. -# Returns -True if successful, false if not (process local). +* `cmesh`:\\[in\\] The cmesh +* `gtreeid`:\\[in\\] The global id of the tree +* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the geometry +* `num_coords`:\\[in\\] The number of reference coordinates +* `out_coords`:\\[out\\] The evaluated coordinates ### Prototype ```c -int t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int curved_flag, const int write_ghosts, const int num_data, t8_vtk_data_field_t *data); +void t8_geometry_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords); ``` """ -function t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) - @ccall libt8.t8_forest_vtk_write_file_via_API(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, curved_flag::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) + @ccall libt8.t8_geometry_evaluate(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid end """ - t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) + t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) -Write the forest in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configured with "-DT8CODE\\_ENABLE\\_VTK=ON" and t8_forest_vtk_write_file_via_API is not available. +Evaluates the jacobian of a tree at a given reference point. # Arguments -* `forest`:\\[in\\] The forest. -* `fileprefix`:\\[in\\] The prefix of the output files. -* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. -* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. -* `write_level`:\\[in\\] If true, the refinement level is written for each element. -* `write_element_id`:\\[in\\] If true, the global element id is written for each element. -* `write_ghosts`:\\[in\\] If true, each process additionally writes its ghost elements. For ghost element the treeid is -1. -* `num_data`:\\[in\\] Number of user defined double valued data fields to write. -* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the used defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. -# Returns -True if successful, false if not (process local). +* `cmesh`:\\[in\\] The cmesh +* `gtreeid`:\\[in\\] The global id of the tree +* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the jacobian +* `num_coords`:\\[in\\] The number of reference coordinates +* `jacobian`:\\[out\\] The jacobian at the reference coordinates ### Prototype ```c -int t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data); +void t8_geometry_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *jacobian); ``` """ -function t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) - @ccall libt8.t8_forest_vtk_write_file(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) + @ccall libt8.t8_geometry_jacobian(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, jacobian::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) + t8_geometry_get_type(cmesh, gtreeid) + +This function returns the geometry type of a tree. +# Arguments +* `cmesh`:\\[in\\] The cmesh +* `gtreeid`:\\[in\\] The global id of the tree +# Returns +The geometry type of the tree with id gtreeid ### Prototype ```c -int t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm); +t8_geometry_type_t t8_geometry_get_type (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); ``` """ -function t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) - @ccall libt8.t8_cmesh_vtk_write_file_via_API(cmesh::t8_cmesh_t, fileprefix::Cstring, comm::MPI_Comm)::Cint +function t8_geometry_get_type(cmesh, gtreeid) + @ccall libt8.t8_geometry_get_type(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::t8_geometry_type_t end """ - t8_cmesh_vtk_write_file(cmesh, fileprefix) + t8_geometry_tree_negative_volume(cmesh, gtreeid) -Write the cmesh in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configured with "-DT8CODE\\_ENABLE\\_VTK=ON" and t8_cmesh_vtk_write_file_via_API is not available. +Check if a tree has a negative volume # Arguments -* `cmesh`:\\[in\\] The cmesh -* `fileprefix`:\\[in\\] The prefix of the output files +* `cmesh`:\\[in\\] The cmesh to check +* `gtreeid`:\\[in\\] The global id of the tree # Returns -True (nonzero) if successful, false (zero) otherwise +True if the tree with id gtreeid has a negative volume. False otherwise. ### Prototype ```c -int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); +int t8_geometry_tree_negative_volume (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid); ``` """ -function t8_cmesh_vtk_write_file(cmesh, fileprefix) - @ccall libt8.t8_cmesh_vtk_write_file(cmesh::t8_cmesh_t, fileprefix::Cstring)::Cint +function t8_geometry_tree_negative_volume(cmesh, gtreeid) + @ccall libt8.t8_geometry_tree_negative_volume(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Cint end """ - t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) + t8_geom_get_name(geom) + +Get the name of a geometry. +# Arguments +* `geom`:\\[in\\] A geometry. +# Returns +The name of *geom*. ### Prototype ```c -t8_cmesh_t t8_cmesh_from_msh_file (const char *fileprefix, int partition, sc_MPI_Comm comm, int dim, int master, int use_cad_geometry); +const char * t8_geom_get_name (const t8_geometry_c *geom); ``` """ -function t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) - @ccall libt8.t8_cmesh_from_msh_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, dim::Cint, master::Cint, use_cad_geometry::Cint)::t8_cmesh_t +function t8_geom_get_name(geom) + @ccall libt8.t8_geom_get_name(geom::Ptr{t8_geometry_c})::Cstring end -mutable struct t8_cmesh_vertex_connectivity end - -""" -[`t8_cmesh_vertex_connectivity_c`](@ref) - -Opaque pointer to the cmesh vertex connectivity structure. """ -const t8_cmesh_vertex_connectivity_c = Ptr{t8_cmesh_vertex_connectivity} + t8_geom_get_type(geom) -""" - t8_cmesh_set_global_vertices_of_tree(cmesh, global_tree, global_tree_vertices, num_vertices) +Get the type of a geometry. +# Arguments +* `geom`:\\[in\\] A geometry. +# Returns +The type of *geom*. ### Prototype ```c -void t8_cmesh_set_global_vertices_of_tree (const t8_cmesh_t cmesh, const t8_gloidx_t global_tree, const t8_gloidx_t *global_tree_vertices, const int num_vertices); +t8_geometry_type_t t8_geom_get_type (const t8_geometry_c *geom); ``` """ -function t8_cmesh_set_global_vertices_of_tree(cmesh, global_tree, global_tree_vertices, num_vertices) - @ccall libt8.t8_cmesh_set_global_vertices_of_tree(cmesh::Cint, global_tree::Cint, global_tree_vertices::Ptr{Cint}, num_vertices::Cint)::Cvoid +function t8_geom_get_type(geom) + @ccall libt8.t8_geom_get_type(geom::Ptr{t8_geometry_c})::t8_geometry_type_t end """ - t8_cmesh_get_num_global_vertices(cmesh) + t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) ### Prototype ```c -t8_gloidx_t t8_cmesh_get_num_global_vertices (const t8_cmesh_t cmesh); +void t8_geom_compute_linear_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); ``` """ -function t8_cmesh_get_num_global_vertices(cmesh) - @ccall libt8.t8_cmesh_get_num_global_vertices(cmesh::Cint)::Cint +function t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + @ccall libt8.t8_geom_compute_linear_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_get_num_local_vertices(cmesh) + t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) ### Prototype ```c -t8_locidx_t t8_cmesh_get_num_local_vertices (const t8_cmesh_t cmesh); +void t8_geom_compute_linear_axis_aligned_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); ``` """ -function t8_cmesh_get_num_local_vertices(cmesh) - @ccall libt8.t8_cmesh_get_num_local_vertices(cmesh::Cint)::Cint +function t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + @ccall libt8.t8_geom_compute_linear_axis_aligned_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_get_global_vertices_of_tree(cmesh, local_tree, num_vertices) + t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + +Interpolates linearly between 2, bilinearly between 4 or trilineraly between 8 points. +# Arguments +* `coefficients`:\\[in\\] An array of size at least dim giving the coefficients used for the interpolation +* `corner_values`:\\[in\\] An array of size 2^dim * 3, giving for each corner (in zorder) of the unit square/cube its function values in space. +* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. +* `interpolation_dim`:\\[in\\] The dimension of the interpolation (1 for linear, 2 for bilinear, 3 for trilinear) +* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -const t8_gloidx_t * t8_cmesh_get_global_vertices_of_tree (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, int *num_vertices); +void t8_geom_linear_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); ``` """ -function t8_cmesh_get_global_vertices_of_tree(cmesh, local_tree, num_vertices) - @ccall libt8.t8_cmesh_get_global_vertices_of_tree(cmesh::Cint, local_tree::Cint, num_vertices::Ptr{Cint})::Ptr{Cint} +function t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + @ccall libt8.t8_geom_linear_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_get_global_vertex_of_tree(cmesh, local_tree, local_tree_vertex) + t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + +Triangular interpolation between 3 points (triangle) or 4 points (tetrahedron) using cartesian coordinates. The input coefficients have to be given as coordinates in the reference triangle (interpolation\\_dim = 2) with points (0,0) (1,0) (1,1) or the reference tet (interpolation\\_dim = 3) with points (0,0,0) (1,0,0) (1,1,0) (1,1,1). +# Arguments +* `coefficients`:\\[in\\] An array of size *interpolation_dim* giving the coefficients in the reference triangle/tet used for the interpolation +* `corner_values`:\\[in\\] An array of size 3 * *corner_value_dim* for *interpolation_dim* == 2 or 4 * *corner_value_dim* for *interpolation_dim* == 3, giving the function values of the triangle/tetrahedron for each corner (in zorder) +* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. +* `interpolation_dim`:\\[in\\] The dimension of the interpolation (2 for triangle, 3 for tetrahedron) +* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -t8_gloidx_t t8_cmesh_get_global_vertex_of_tree (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, const int local_tree_vertex); +void t8_geom_triangular_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); ``` """ -function t8_cmesh_get_global_vertex_of_tree(cmesh, local_tree, local_tree_vertex) - @ccall libt8.t8_cmesh_get_global_vertex_of_tree(cmesh::Cint, local_tree::Cint, local_tree_vertex::Cint)::Cint +function t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + @ccall libt8.t8_geom_triangular_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_get_num_trees_at_vertex(cmesh, global_vertex) + t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) ### Prototype ```c -int t8_cmesh_get_num_trees_at_vertex (const t8_cmesh_t cmesh, t8_gloidx_t global_vertex); +void t8_geom_get_face_vertices (t8_eclass_t tree_class, const double *tree_vertices, int face_index, int dim, double *face_vertices); ``` """ -function t8_cmesh_get_num_trees_at_vertex(cmesh, global_vertex) - @ccall libt8.t8_cmesh_get_num_trees_at_vertex(cmesh::Cint, global_vertex::Cint)::Cint +function t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) + @ccall libt8.t8_geom_get_face_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, face_index::Cint, dim::Cint, face_vertices::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_uses_vertex_connectivity(cmesh) + t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) ### Prototype ```c -int t8_cmesh_uses_vertex_connectivity (const t8_cmesh_t cmesh); +void t8_geom_get_edge_vertices (t8_eclass_t tree_class, const double *tree_vertices, int edge_index, int dim, double *edge_vertices); ``` """ -function t8_cmesh_uses_vertex_connectivity(cmesh) - @ccall libt8.t8_cmesh_uses_vertex_connectivity(cmesh::Cint)::Cint +function t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) + @ccall libt8.t8_geom_get_edge_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, edge_index::Cint, dim::Cint, edge_vertices::Ptr{Cdouble})::Cvoid end -# typedef int ( * t8_search_element_callback_c_wrapper ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , void * user_data ) -""" -A call-back function used by t8_forest_init_search for searching elements. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. - -# Arguments -* `forest`:\\[in\\] the forest -* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. -* `element`:\\[in\\] the element for which the search criterion is checked -* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element -* `leaf_elements`:\\[in\\] the leaf elements in *forest* -* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* -* `user_data`:\\[in\\] a user data pointer that can be set by the user -# Returns -non-zero if the search criterion is met, zero otherwise. -""" -const t8_search_element_callback_c_wrapper = Ptr{Cvoid} - -# typedef int ( * t8_search_queries_callback_c_wrapper ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , void * queries , void * user_data ) -""" -A call-back function used by t8_forest_init_search_with_queries for searching elements and executing queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. - -# Arguments -* `forest`:\\[in\\] the forest -* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. -* `element`:\\[in\\] the element for which the search criterion is checked -* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element -* `leaf_elements`:\\[in\\] the leaf elements in *forest* -* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* -* `queries`:\\[in\\] a pointer to an array of queries -* `user_data`:\\[in\\] a user data pointer that can be set by the user """ -const t8_search_queries_callback_c_wrapper = Ptr{Cvoid} + t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) -# typedef void ( * t8_search_batched_queries_callback_c_wrapper ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , const void * queries , const size_t * active_query_indices , int * query_matches , void * user_data ) -""" -A call-back function used by t8_forest_init_search_with_batched_queries for searching elements and executing batched queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. +Calculates a point of intersection in a triangular reference space. The intersection is the extension of a straight line passing through a reference point and the opposite vertex of the edge. /|\\ / | \\ o -> reference point / o \\ x -> intersection point / | \\ /\\_\\_\\_\\_x\\_\\_\\_\\_\\ # Arguments -* `forest`:\\[in\\] the forest -* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. -* `element`:\\[in\\] the element for which the search criterion is checked -* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element -* `leaf_elements`:\\[in\\] the leaf elements in *forest* -* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* -* `queries`:\\[in\\] a pointer to an array of queries -* `active_query_indices`:\\[in\\] a pointer to an array of indices of active queries in *queries* -* `query_matches`:\\[in,out\\] a pointer to an array of length *num_active_queries*. If query\\_matches[i] is true, then the element 'matches' the query of the active query with index active\\_query\\_indices[i]. -* `user_data`:\\[in\\] a user data pointer that can be set by the user -""" -const t8_search_batched_queries_callback_c_wrapper = Ptr{Cvoid} - -mutable struct t8_forest_c_search end - -"""A wrapper around the forest search context""" -const t8_forest_search_c_wrapper = Ptr{t8_forest_c_search} - -""" - t8_forest_init_search(search, element_callback, forest) - +* `edge_index`:\\[in\\] Index of the edge, the intersection lies on. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +* `ref_intersection`:\\[out\\] Coordinates of the intersection point. ### Prototype ```c -void t8_forest_init_search (t8_forest_search_c_wrapper search, t8_search_element_callback_c_wrapper element_callback, const t8_forest_t forest); +void t8_geom_get_ref_intersection (int edge_index, const double *ref_coords, double ref_intersection[2]); ``` """ -function t8_forest_init_search(search, element_callback, forest) - @ccall libt8.t8_forest_init_search(search::t8_forest_search_c_wrapper, element_callback::t8_search_element_callback_c_wrapper, forest::t8_forest_t)::Cvoid +function t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) + @ccall libt8.t8_geom_get_ref_intersection(edge_index::Cint, ref_coords::Ptr{Cdouble}, ref_intersection::Ptr{Cdouble})::Cvoid end """ - t8_forest_search_update_forest(search, forest) + t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) +Calculates the scaling factor for edge displacement along a triangular tree face depending on the position of the global reference point. + +# Arguments +* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. +* `tree_vertices`:\\[in\\] Array with the tree vertex coordinates. +* `glob_intersection`:\\[in\\] Array containing the coordinates of the intersection point of a line drawn from the opposite vertex through the glob\\_ref\\_point onto the edge with edge\\_index. +* `glob_ref_point`:\\[in\\] Array containing the coordinates of the reference point mapped into the global space. ### Prototype ```c -void t8_forest_search_update_forest (t8_forest_search_c_wrapper search, const t8_forest_t forest); +double t8_geom_get_triangle_scaling_factor (int edge_index, const double *tree_vertices, const double *glob_intersection, const double *glob_ref_point); ``` """ -function t8_forest_search_update_forest(search, forest) - @ccall libt8.t8_forest_search_update_forest(search::t8_forest_search_c_wrapper, forest::t8_forest_t)::Cvoid +function t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) + @ccall libt8.t8_geom_get_triangle_scaling_factor(edge_index::Cint, tree_vertices::Ptr{Cdouble}, glob_intersection::Ptr{Cdouble}, glob_ref_point::Ptr{Cdouble})::Cdouble end """ - t8_forest_search_update_user_data(search, udata) + t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) -Update the user data pointer in the search context +Calculates the scaling factor for the displacement of an edge over a face of a tetrahedral element. # Arguments -* `search`:\\[in,out\\] the search context to update -* `udata`:\\[in\\] the new user data pointer to use +* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. +* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +# Returns +The scaling factor of the edge displacement on the face at the point of the reference coordinates. ### Prototype ```c -void t8_forest_search_update_user_data (t8_forest_search_c_wrapper search, void *udata); +double t8_geom_get_scaling_factor_of_edge_on_face_tet (int edge_index, int face_index, const double *ref_coords); ``` """ -function t8_forest_search_update_user_data(search, udata) - @ccall libt8.t8_forest_search_update_user_data(search::t8_forest_search_c_wrapper, udata::Ptr{Cvoid})::Cvoid +function t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) + @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble end """ - t8_forest_search_do_search(search) + t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) -Perform the search +Calculates the face intersection of a ray passing trough the reference coordinates and the opposite vertex of that face for a tetrahedron. The coordinates of the face intersection are reference coordinates: [0,1]^3. # Arguments -* `search`:\\[in,out\\] the search context to use +* `face_index`:\\[in\\] Index of the face, on which the intersection should be calculated. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +* `face_intersection`:\\[out\\] Three dimensional array containing the intersection point on the face in reference space. ### Prototype ```c -void t8_forest_search_do_search (t8_forest_search_c_wrapper search); +void t8_geom_get_tet_face_intersection (const int face_index, const double *ref_coords, double face_intersection[3]); ``` """ -function t8_forest_search_do_search(search) - @ccall libt8.t8_forest_search_do_search(search::t8_forest_search_c_wrapper)::Cvoid +function t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) + @ccall libt8.t8_geom_get_tet_face_intersection(face_index::Cint, ref_coords::Ptr{Cdouble}, face_intersection::Ptr{Cdouble})::Cvoid end """ - t8_forest_search_destroy(search) + t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) -Destroy the search context +Calculates the scaling factor for the displacement of an edge over a face of a prism element. # Arguments -* `search`:\\[in,out\\] the search context to destroy +* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. +* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +# Returns +The scaling factor of the edge displacement on the face at the point of the reference coordinates. ### Prototype ```c -void t8_forest_search_destroy (t8_forest_search_c_wrapper search); +double t8_geom_get_scaling_factor_of_edge_on_face_prism (int edge_index, int face_index, const double *ref_coords); ``` """ -function t8_forest_search_destroy(search) - @ccall libt8.t8_forest_search_destroy(search::t8_forest_search_c_wrapper)::Cvoid +function t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) + @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble end -mutable struct t8_forest_search_with_queries end - -"""A wrapper around the forest search with queries context""" -const t8_forest_search_with_queries_c_wrapper = Ptr{t8_forest_search_with_queries} - """ - t8_forest_init_search_with_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) - -### Prototype -```c -void t8_forest_init_search_with_queries (t8_forest_search_with_queries_c_wrapper search_with_queries, t8_search_element_callback_c_wrapper element_callback, t8_search_queries_callback_c_wrapper queries_callback, void **queries, const size_t num_queries, const t8_forest_t forest); -``` -""" -function t8_forest_init_search_with_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) - @ccall libt8.t8_forest_init_search_with_queries(search_with_queries::t8_forest_search_with_queries_c_wrapper, element_callback::t8_search_element_callback_c_wrapper, queries_callback::t8_search_queries_callback_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t, forest::t8_forest_t)::Cvoid -end + t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) -""" - t8_forest_search_with_queries_update_forest(search_with_queries, forest) +Calculates the scaling factor for the displacement of an face through the volume of a prism element. +# Arguments +* `face_index`:\\[in\\] Index of the displaced face. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +# Returns +The scaling factor of the face displacement at the point of the reference coordinates inside the prism volume. ### Prototype ```c -void t8_forest_search_with_queries_update_forest (t8_forest_search_with_queries_c_wrapper search_with_queries, const t8_forest_t forest); +double t8_geom_get_scaling_factor_face_through_volume_prism (const int face, const double *ref_coords); ``` """ -function t8_forest_search_with_queries_update_forest(search_with_queries, forest) - @ccall libt8.t8_forest_search_with_queries_update_forest(search_with_queries::t8_forest_search_with_queries_c_wrapper, forest::t8_forest_t)::Cvoid +function t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) + @ccall libt8.t8_geom_get_scaling_factor_face_through_volume_prism(face::Cint, ref_coords::Ptr{Cdouble})::Cdouble end """ - t8_forest_search_with_queries_update_user_data(search_with_queries, udata) + t8_vertex_point_inside(vertex_coords, point, tolerance) -Update the user data pointer in the search with queries context +Check if a point lies inside a vertex # Arguments -* `search_with_queries`:\\[in,out\\] the search with queries context to update -* `udata`:\\[in\\] the new user data pointer to use +* `vertex_coords`:\\[in\\] The coordinates of the vertex +* `point`:\\[in\\] The coordinates of the point to check +* `tolerance`:\\[in\\] A double > 0 defining the tolerance +# Returns +0 if the point is outside, 1 otherwise. ### Prototype ```c -void t8_forest_search_with_queries_update_user_data (t8_forest_search_with_queries_c_wrapper search_with_queries, void *udata); +int t8_vertex_point_inside (const double vertex_coords[3], const double point[3], const double tolerance); ``` """ -function t8_forest_search_with_queries_update_user_data(search_with_queries, udata) - @ccall libt8.t8_forest_search_with_queries_update_user_data(search_with_queries::t8_forest_search_with_queries_c_wrapper, udata::Ptr{Cvoid})::Cvoid +function t8_vertex_point_inside(vertex_coords, point, tolerance) + @ccall libt8.t8_vertex_point_inside(vertex_coords::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint end """ - t8_forest_search_with_queries_update_queries(search_with_queries, queries, num_queries) + t8_line_point_inside(p_0, vec, point, tolerance) -Update the queries in the search with queries context +Check if a point is inside a line that is defined by a starting point *p_0* and a vector *vec* # Arguments -* `search_with_queries`:\\[in,out\\] the search with queries context to update -* `queries`:\\[in\\] a pointer to an array of queries -* `num_queries`:\\[in\\] the number of queries in the array +* `p_0`:\\[in\\] Starting point of the line +* `vec`:\\[in\\] Direction of the line (not normalized) +* `point`:\\[in\\] The coordinates of the point to check +* `tolerance`:\\[in\\] A double > 0 defining the tolerance +# Returns +0 if the point is outside, 1 otherwise. ### Prototype ```c -void t8_forest_search_with_queries_update_queries (t8_forest_search_with_queries_c_wrapper search_with_queries, void **queries, const size_t num_queries); +int t8_line_point_inside (const double *p_0, const double *vec, const double *point, const double tolerance); ``` """ -function t8_forest_search_with_queries_update_queries(search_with_queries, queries, num_queries) - @ccall libt8.t8_forest_search_with_queries_update_queries(search_with_queries::t8_forest_search_with_queries_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t)::Cvoid +function t8_line_point_inside(p_0, vec, point, tolerance) + @ccall libt8.t8_line_point_inside(p_0::Ptr{Cdouble}, vec::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint end """ - t8_forest_search_with_queries_destroy(search) + t8_triangle_point_inside(p_0, v, w, point, tolerance) -Destroy the search with queries context +Check if a point is inside of a triangle described by a point *p_0* and two vectors *v* and *w*. # Arguments -* `search`:\\[in,out\\] the search with queries context to destroy +* `p_0`:\\[in\\] The first vertex of a triangle +* `v`:\\[in\\] The vector from p\\_0 to p\\_1 (second vertex in the triangle) +* `w`:\\[in\\] The vector from p\\_0 to p\\_2 (third vertex in the triangle) +* `point`:\\[in\\] The coordinates of the point to check +* `tolerance`:\\[in\\] A double > 0 defining the tolerance +# Returns +0 if the point is outside, 1 otherwise. ### Prototype ```c -void t8_forest_search_with_queries_destroy (t8_forest_search_with_queries_c_wrapper search); +int t8_triangle_point_inside (const double p_0[3], const double v[3], const double w[3], const double point[3], const double tolerance); ``` """ -function t8_forest_search_with_queries_destroy(search) - @ccall libt8.t8_forest_search_with_queries_destroy(search::t8_forest_search_with_queries_c_wrapper)::Cvoid +function t8_triangle_point_inside(p_0, v, w, point, tolerance) + @ccall libt8.t8_triangle_point_inside(p_0::Ptr{Cdouble}, v::Ptr{Cdouble}, w::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint end """ - t8_forest_search_with_queries_do_search(search) + t8_plane_point_inside(point_on_face, face_normal, point) -Perform the search with queries +Check if a point lays on the inner side of a plane of a bilinearly interpolated volume element. the plane is described by a point and the normal of the face. # Arguments -* `search`:\\[in,out\\] the search with queries context to use +* `point_on_face`:\\[in\\] A point on the plane +* `face_normal`:\\[in\\] The normal of the face +* `point`:\\[in\\] The point to check +# Returns +0 if the point is outside, 1 otherwise. ### Prototype ```c -void t8_forest_search_with_queries_do_search (t8_forest_search_with_queries_c_wrapper search); +int t8_plane_point_inside (const double point_on_face[3], const double face_normal[3], const double point[3]); ``` """ -function t8_forest_search_with_queries_do_search(search) - @ccall libt8.t8_forest_search_with_queries_do_search(search::t8_forest_search_with_queries_c_wrapper)::Cvoid +function t8_plane_point_inside(point_on_face, face_normal, point) + @ccall libt8.t8_plane_point_inside(point_on_face::Ptr{Cdouble}, face_normal::Ptr{Cdouble}, point::Ptr{Cdouble})::Cint end -mutable struct t8_forest_search_with_batched_queries end - -"""A wrapper around the forest search with batched queries context""" -const t8_forest_search_with_batched_queries_c_wrapper = Ptr{t8_forest_search_with_batched_queries} - """ - t8_forest_init_search_with_batched_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) + t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) + +Set the vertex coordinates of a tree in the cmesh. This is currently inefficient, since the vertices are duplicated for each tree. Eventually this function will be replaced by a more efficient one. It is not allowed to call this function after t8_cmesh_commit. The eclass of the tree has to be set before calling this function. +# Arguments +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `gtree_id`:\\[in\\] The global number of the tree. +* `vertices`:\\[in\\] An array of 3 doubles per tree vertex. +* `num_vertices`:\\[in\\] The number of verticess in *vertices*. Must match the number of corners of the tree. ### Prototype ```c -void t8_forest_init_search_with_batched_queries (t8_forest_search_with_batched_queries_c_wrapper search_with_queries, t8_search_element_callback_c_wrapper element_callback, t8_search_batched_queries_callback_c_wrapper queries_callback, void **queries, const size_t num_queries, const t8_forest_t forest); +void t8_cmesh_set_tree_vertices (t8_cmesh_t cmesh, const t8_gloidx_t gtree_id, const double *vertices, const int num_vertices); ``` """ -function t8_forest_init_search_with_batched_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) - @ccall libt8.t8_forest_init_search_with_batched_queries(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, element_callback::t8_search_element_callback_c_wrapper, queries_callback::t8_search_batched_queries_callback_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t, forest::t8_forest_t)::Cvoid +function t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) + @ccall libt8.t8_cmesh_set_tree_vertices(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cvoid end """ - t8_forest_search_with_batched_queries_update_forest(search_with_queries, forest) + vtk_file_type -### Prototype -```c -void t8_forest_search_with_batched_queries_update_forest ( t8_forest_search_with_batched_queries_c_wrapper search_with_queries, const t8_forest_t forest); -``` +Enumerator for all types of files readable by t8code. """ -function t8_forest_search_with_batched_queries_update_forest(search_with_queries, forest) - @ccall libt8.t8_forest_search_with_batched_queries_update_forest(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, forest::t8_forest_t)::Cvoid +@cenum vtk_file_type::Int32 begin + VTK_FILE_ERROR = -1 + VTK_SERIAL_FILE = 8 + VTK_UNSTRUCTURED_FILE = 8 + VTK_POLYDATA_FILE = 9 + VTK_PARALLEL_FILE = 16 + VTK_PARALLEL_UNSTRUCTURED_FILE = 16 + VTK_PARALLEL_POLYDATA_FILE = 17 + VTK_NUM_TYPES = 5 +end + +"""Enumerator for all types of files readable by t8code.""" +const vtk_file_type_t = vtk_file_type + +@cenum vtk_read_success::UInt32 begin + read_failure = 0 + read_success = 1 end +const vtk_read_success_t = vtk_read_success + """ - t8_forest_search_with_batched_queries_update_user_data(search_with_queries, udata) + t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) -Update the user data pointer in the search with batched queries context +Write the forest in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function uses the vtk library. t8code must be configured with "--with-vtk" in order to use it. Currently does not support pyramid elements. + +!!! note + + If t8code was not configured with vtk, use t8_forest_vtk_write_file # Arguments -* `search_with_queries`:\\[in,out\\] the search with batched queries context to update -* `udata`:\\[in\\] the new user data pointer to use +* `forest`:\\[in\\] The forest. +* `fileprefix`:\\[in\\] The prefix of the output files. The meta file will be named *fileprefix*.pvtu . +* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. +* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. +* `write_level`:\\[in\\] If true, the refinement level is written for each element. +* `write_element_id`:\\[in\\] If true, the global element id is written for each element. +* `curved_flag`:\\[in\\] If true, write the elements as curved element types from vtk. +* `write_ghosts`:\\[in\\] If true, write out ghost elements as well. +* `num_data`:\\[in\\] Number of user defined double valued data fields to write. +* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the user defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. +# Returns +True if successful, false if not (process local). ### Prototype ```c -void t8_forest_search_with_batched_queries_update_user_data ( t8_forest_search_with_batched_queries_c_wrapper search_with_queries, void *udata); +int t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int curved_flag, const int write_ghosts, const int num_data, t8_vtk_data_field_t *data); ``` """ -function t8_forest_search_with_batched_queries_update_user_data(search_with_queries, udata) - @ccall libt8.t8_forest_search_with_batched_queries_update_user_data(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, udata::Ptr{Cvoid})::Cvoid +function t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) + @ccall libt8.t8_forest_vtk_write_file_via_API(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, curved_flag::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_forest_search_with_batched_queries_update_queries(search_with_queries, queries, num_queries) + t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) -Update the queries in the search with batched queries context +Write the forest in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configure with "--with-vtk" and t8_forest_vtk_write_file_via_API is not available. # Arguments -* `search_with_queries`:\\[in,out\\] the search with batched queries context to update -* `queries`:\\[in\\] a pointer to an array of queries -* `num_queries`:\\[in\\] the number of queries in the array +* `forest`:\\[in\\] The forest. +* `fileprefix`:\\[in\\] The prefix of the output files. +* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. +* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. +* `write_level`:\\[in\\] If true, the refinement level is written for each element. +* `write_element_id`:\\[in\\] If true, the global element id is written for each element. +* `write_ghosts`:\\[in\\] If true, each process additionally writes its ghost elements. For ghost element the treeid is -1. +* `num_data`:\\[in\\] Number of user defined double valued data fields to write. +* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the used defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. +# Returns +True if successful, false if not (process local). ### Prototype ```c -void t8_forest_search_with_batched_queries_update_queries ( t8_forest_search_with_batched_queries_c_wrapper search_with_queries, void **queries, const size_t num_queries); +int t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data); ``` """ -function t8_forest_search_with_batched_queries_update_queries(search_with_queries, queries, num_queries) - @ccall libt8.t8_forest_search_with_batched_queries_update_queries(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t)::Cvoid +function t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) + @ccall libt8.t8_forest_vtk_write_file(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_forest_search_with_batched_queries_destroy(search) - -Destroy the search with batched queries context + t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) -# Arguments -* `search`:\\[in,out\\] the search with batched queries context to destroy ### Prototype ```c -void t8_forest_search_with_batched_queries_destroy (t8_forest_search_with_batched_queries_c_wrapper search); +int t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm); ``` """ -function t8_forest_search_with_batched_queries_destroy(search) - @ccall libt8.t8_forest_search_with_batched_queries_destroy(search::t8_forest_search_with_batched_queries_c_wrapper)::Cvoid +function t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) + @ccall libt8.t8_cmesh_vtk_write_file_via_API(cmesh::t8_cmesh_t, fileprefix::Cstring, comm::MPI_Comm)::Cint end """ - t8_forest_search_with_batched_queries_do_search(search) + t8_cmesh_vtk_write_file(cmesh, fileprefix) -Perform the search with batched queries +Write the cmesh in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configure with "--with-vtk" and t8_cmesh_vtk_write_file_via_API is not available. # Arguments -* `search`:\\[in,out\\] the search with batched queries context to use +* `cmesh`:\\[in\\] The cmesh +* `fileprefix`:\\[in\\] The prefix of the output files +# Returns +int ### Prototype ```c -void t8_forest_search_with_batched_queries_do_search (t8_forest_search_with_batched_queries_c_wrapper search); +int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); ``` """ -function t8_forest_search_with_batched_queries_do_search(search) - @ccall libt8.t8_forest_search_with_batched_queries_do_search(search::t8_forest_search_with_batched_queries_c_wrapper)::Cvoid +function t8_cmesh_vtk_write_file(cmesh, fileprefix) + @ccall libt8.t8_cmesh_vtk_write_file(cmesh::t8_cmesh_t, fileprefix::Cstring)::Cint end # typedef void ( * t8_geom_analytic_fn ) ( t8_cmesh_t cmesh , t8_gloidx_t gtreeid , const double * ref_coords , const size_t num_coords , double * out_coords , const void * tree_data , const void * user_data ) @@ -16411,7 +17735,7 @@ Definition of an analytic geometry function. This function maps reference coordi * `cmesh`:\\[in\\] The cmesh. * `gtreeid`:\\[in\\] The global tree (of the cmesh) in which the reference point is. * `ref_coords`:\\[in\\] Array of dimension x *num_coords* many entries, specifying a point in -* `num_coords`:\\[in\\] The number of coordinates in *ref_coords*. +* `num_coords`:\\[in\\] * `out_coords`:\\[out\\] The mapped coordinates in physical space of *ref_coords*. The length is *num_coords* * 3. * `tree_data`:\\[in\\] The data of the current tree as loaded by a t8_geom_load_tree_data_fn. * `user_data`:\\[in\\] The user data pointer stored in the geometry. @@ -16509,59 +17833,37 @@ const t8_geom_tree_compatible_fn = Ptr{Cvoid} """ t8_geometry_analytic_destroy(geom) -Destroy a geometry analytic object. - -# Arguments -* `geom`:\\[in,out\\] A pointer to a geometry object. Set to NULL on output. ### Prototype ```c void t8_geometry_analytic_destroy (t8_geometry_c **geom); ``` """ function t8_geometry_analytic_destroy(geom) - @ccall libt8.t8_geometry_analytic_destroy(geom::Ptr{Ptr{t8_geometry_c}})::Cvoid + @ccall libt8.t8_geometry_analytic_destroy(geom::Ptr{Ptr{Cint}})::Cvoid end """ t8_geometry_analytic_new(name, analytical, jacobian, load_tree_data, tree_negative_volume, tree_compatible, user_data) -Create a new analytic geometry. The geometry is viable with all tree types and uses a user-provided analytic and jacobian function. The actual mappings are done by these functions. - -# Arguments -* `name`:\\[in\\] The name to give this geometry. -* `analytical`:\\[in\\] The analytical function to use for this geometry. -* `jacobian`:\\[in\\] The jacobian of *analytical*. -* `load_tree_data`:\\[in\\] The function that is used to load a tree's data. -* `tree_negative_volume`:\\[in\\] The function that is used to compute if a trees volume is negative. -* `tree_compatible`:\\[in\\] The function that is used to check if a tree is compatible with the geometry. -* `user_data`:\\[in\\] Additional user data which the geometry can use. -# Returns -A pointer to an allocated geometry struct. ### Prototype ```c t8_geometry_c * t8_geometry_analytic_new (const char *name, t8_geom_analytic_fn analytical, t8_geom_analytic_jacobian_fn jacobian, t8_geom_load_tree_data_fn load_tree_data, t8_geom_tree_negative_volume_fn tree_negative_volume, t8_geom_tree_compatible_fn tree_compatible, const void *user_data); ``` """ function t8_geometry_analytic_new(name, analytical, jacobian, load_tree_data, tree_negative_volume, tree_compatible, user_data) - @ccall libt8.t8_geometry_analytic_new(name::Cstring, analytical::t8_geom_analytic_fn, jacobian::t8_geom_analytic_jacobian_fn, load_tree_data::t8_geom_load_tree_data_fn, tree_negative_volume::t8_geom_tree_negative_volume_fn, tree_compatible::t8_geom_tree_compatible_fn, user_data::Ptr{Cvoid})::Ptr{t8_geometry_c} + @ccall libt8.t8_geometry_analytic_new(name::Cstring, analytical::t8_geom_analytic_fn, jacobian::t8_geom_analytic_jacobian_fn, load_tree_data::t8_geom_load_tree_data_fn, tree_negative_volume::t8_geom_tree_negative_volume_fn, tree_compatible::t8_geom_tree_compatible_fn, user_data::Ptr{Cvoid})::Ptr{Cint} end """ t8_geom_load_tree_data_vertices(cmesh, gtreeid, user_data) -Load vertex data from given tree. - -# Arguments -* `cmesh`:\\[in\\] The cmesh. -* `gtreeid`:\\[in\\] The global tree id (in the cmesh). -* `user_data`:\\[out\\] The load tree vertices. ### Prototype ```c void t8_geom_load_tree_data_vertices (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const void **user_data); ``` """ function t8_geom_load_tree_data_vertices(cmesh, gtreeid, user_data) - @ccall libt8.t8_geom_load_tree_data_vertices(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, user_data::Ptr{Ptr{Cvoid}})::Cvoid + @ccall libt8.t8_geom_load_tree_data_vertices(cmesh::Cint, gtreeid::Cint, user_data::Ptr{Ptr{Cvoid}})::Cvoid end """ @@ -16815,29 +18117,45 @@ function t8_geometry_zero_destroy(geom) end """ - t8_scheme_new_default() + t8_scheme_new_default_cxx() + +Return the default element implementation of t8code. ### Prototype ```c -const t8_scheme_c * t8_scheme_new_default (void); +t8_scheme_cxx_t * t8_scheme_new_default_cxx (void); ``` """ -function t8_scheme_new_default() - @ccall libt8.t8_scheme_new_default()::Ptr{Cint} +function t8_scheme_new_default_cxx() + @ccall libt8.t8_scheme_new_default_cxx()::Ptr{t8_scheme_cxx_t} end """ - t8_eclass_scheme_is_default(scheme, eclass) + t8_eclass_scheme_is_default(ts) +Check whether a given eclass\\_scheme is one of the default schemes. + +# Arguments +* `ts`:\\[in\\] A (pointer to a) scheme +# Returns +True (non-zero) if *ts* is one of the default schemes, false (zero) otherwise. ### Prototype ```c -int t8_eclass_scheme_is_default (const t8_scheme_c *scheme, const t8_eclass_t eclass); +int t8_eclass_scheme_is_default (t8_eclass_scheme_c *ts); ``` """ -function t8_eclass_scheme_is_default(scheme, eclass) - @ccall libt8.t8_eclass_scheme_is_default(scheme::Ptr{Cint}, eclass::t8_eclass_t)::Cint +function t8_eclass_scheme_is_default(ts) + @ccall libt8.t8_eclass_scheme_is_default(ts::Ptr{t8_eclass_scheme_c})::Cint end +const SC_CC = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc" + +const SC_CFLAGS = " " + +const SC_CPP = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc -E" + +const SC_CPPFLAGS = "" + const SC_HAVE_ZLIB = 1 const SC_ENABLE_PTHREAD = 1 @@ -16850,38 +18168,22 @@ const SC_ENABLE_MPICOMMSHARED = 1 const SC_ENABLE_MPIIO = 1 -const SC_ENABLE_FILE_CHECKS = 1 - -const SC_HAVE_AINT_DIFF = 1 - -const SC_HAVE_MPI_UNSIGNED_LONG_LONG = 1 - -const SC_HAVE_MPI_SIGNED_CHAR = 1 - -const SC_HAVE_MPI_INT8_T = 1 - const SC_ENABLE_MPITHREAD = 1 const SC_ENABLE_MPIWINSHARED = 1 -const SC_ENABLE_MPISHARED = 1 - const SC_ENABLE_USE_COUNTERS = 1 const SC_ENABLE_USE_REALLOC = 1 const SC_ENABLE_V4L2 = 1 -const SC_HAVE_ALIGNED_ALLOC = 1 - const SC_HAVE_BACKTRACE = 1 const SC_HAVE_BACKTRACE_SYMBOLS = 1 const SC_HAVE_FSYNC = 1 -const SC_HAVE_POSIX_MEMALIGN = 1 - const SC_HAVE_FABS = 1 const SC_HAVE_QSORT_R = 1 @@ -16892,7 +18194,13 @@ const SC_HAVE_STRTOLL = 1 const SC_HAVE_GETTIMEOFDAY = 1 -const SC_MEMALIGN_BYTES = 8 +const SC_SIZEOF_VOID_P = 8 + +const SC_MEMALIGN_BYTES = SC_SIZEOF_VOID_P + +const SC_LDFLAGS = "-Wl,-rpath -Wl,/workspace/destdir/lib -Wl,--enable-new-dtags -L/workspace/x86_64-linux-gnu-libgfortran5-cxx11-mpi+mpich/destdir/lib" + +const SC_LIBS = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/lib/libz.so m" const SC_PACKAGE = "libsc" @@ -16900,56 +18208,66 @@ const SC_PACKAGE_BUGREPORT = "p4est@ins.uni-bonn.de" const SC_PACKAGE_NAME = "libsc" -const SC_PACKAGE_STRING = "libsc 2.8.7" +const SC_PACKAGE_STRING = "libsc 0.0.0" const SC_PACKAGE_TARNAME = "libsc" const SC_PACKAGE_URL = "" -const SC_PACKAGE_VERSION = "2.8.7" +const SC_PACKAGE_VERSION = "0.0.0" -const SC_VERSION = "2.8.7" +const SC_SIZEOF_INT = 4 -const SC_VERSION_MAJOR = 2 +const SC_SIZEOF_UNSIGNED_INT = 4 -const SC_VERSION_MINOR = 8 +const SC_SIZEOF_LONG = 8 -const SC_VERSION_POINT = 7 +const SC_SIZEOF_LONG_LONG = 8 -# Skipping MacroDefinition: _sc_const const +const SC_SIZEOF_UNSIGNED_LONG = 8 + +const SC_SIZEOF_UNSIGNED_LONG_LONG = 8 + +const SC_VERSION = "0.0.0" + +const SC_VERSION_MAJOR = 0 -# Skipping MacroDefinition: SC_DLL_PUBLIC __attribute__ ( ( visibility ( "default" ) ) ) +const SC_VERSION_MINOR = 0 + +const SC_VERSION_POINT = 0 + +# Skipping MacroDefinition: _sc_const const const sc_MPI_COMM_WORLD = MPI.COMM_WORLD const sc_MPI_COMM_SELF = MPI.COMM_SELF -const sc_MPI_BYTE = MPI.BYTE - const sc_MPI_CHAR = MPI.CHAR +const sc_MPI_SIGNED_CHAR = MPI.SIGNED_CHAR + const sc_MPI_UNSIGNED_CHAR = MPI.UNSIGNED_CHAR +const sc_MPI_BYTE = MPI.BYTE + const sc_MPI_SHORT = MPI.SHORT const sc_MPI_UNSIGNED_SHORT = MPI.UNSIGNED_SHORT const sc_MPI_INT = MPI.INT +const sc_MPI_INT8_T = MPI.INT8_T + const sc_MPI_UNSIGNED = MPI.UNSIGNED const sc_MPI_LONG = MPI.LONG const sc_MPI_UNSIGNED_LONG = MPI.UNSIGNED_LONG -const sc_MPI_UNSIGNED_LONG_LONG = MPI.UNSIGNED_LONG_LONG - -const sc_MPI_SIGNED_CHAR = MPI.SIGNED_CHAR - -const sc_MPI_INT8_T = MPI.INT8_T - const sc_MPI_LONG_LONG_INT = MPI.LONG_LONG_INT +const sc_MPI_UNSIGNED_LONG_LONG = MPI.UNSIGNED_LONG_LONG + const sc_MPI_FLOAT = MPI.FLOAT const sc_MPI_DOUBLE = MPI.DOUBLE @@ -16998,16 +18316,12 @@ const SC_LP_SILENT = 9 const SC_LP_THRESHOLD = SC_LP_INFO -const SC_LP_APPLICATION = SC_LP_STATISTICS - const T8_MPI_LOCIDX = sc_MPI_INT const T8_LOCIDX_MAX = INT32_MAX const T8_MPI_GLOIDX = sc_MPI_LONG_LONG_INT -const T8_GLOIDX_MAX = INT64_MAX - const T8_MPI_LINEARIDX = sc_MPI_UNSIGNED_LONG_LONG # Skipping MacroDefinition: T8_PADDING_SIZE ( sizeof ( void * ) ) @@ -17016,12 +18330,50 @@ const T8_PRECISION_EPS = SC_EPS const T8_PRECISION_SQRT_EPS = sqrt(T8_PRECISION_EPS) -const T8_CMESH_FORMAT = 0x0002 +const T8_CMESH_N_SUPPORTED_MSH_FILE_VERSIONS = 2 + +# Skipping MacroDefinition: T8_MPI_ECLASS_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_eclass_t ) ) , sc_MPI_INT ) + +const T8_ECLASS_MAX_FACES = 6 + +const T8_ECLASS_MAX_EDGES = 12 + +const T8_ECLASS_MAX_EDGES_2D = 4 + +const T8_ECLASS_MAX_CORNERS_2D = 4 + +const T8_ECLASS_MAX_CORNERS = 8 + +const T8_ECLASS_MAX_DIM = 3 + +# Skipping MacroDefinition: T8_MPI_ELEMENT_SHAPE_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_element_shape_t ) ) , sc_MPI_INT ) + +const T8_ELEMENT_SHAPE_MAX_FACES = 6 + +const T8_ELEMENT_SHAPE_MAX_CORNERS = 8 + +const T8_VTK_LOCIDX = "Int32" + +const T8_VTK_GLOIDX = "Int32" + +const T8_VTK_FLOAT_NAME = "Float32" + +const T8_VTK_FLOAT_TYPE = Float32 + +const T8_VTK_FORMAT_STRING = "ascii" const sc_mpi_read = sc_io_read const sc_mpi_write = sc_io_write +const P4EST_CC = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc" + +const P4EST_CFLAGS = " " + +const P4EST_CPP = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc -E" + +const P4EST_CPPFLAGS = "" + const P4EST_ENABLE_BUILD_2D = 1 const P4EST_ENABLE_BUILD_3D = 1 @@ -17032,8 +18384,6 @@ const P4EST_ENABLE_MEMALIGN = 1 const P4EST_ENABLE_MPI = 1 -const P4EST_ENABLE_FILE_CHECKS = 1 - const P4EST_ENABLE_MPICOMMSHARED = 1 const P4EST_ENABLE_MPIIO = 1 @@ -17048,31 +18398,33 @@ const P4EST_ENABLE_VTK_COMPRESSION = 1 const P4EST_HAVE_FSYNC = 1 -const P4EST_HAVE_POSIX_MEMALIGN = 1 - const P4EST_HAVE_ZLIB = 1 +const P4EST_LDFLAGS = "-Wl,-rpath -Wl,/workspace/destdir/lib -Wl,--enable-new-dtags -L/workspace/x86_64-linux-gnu-libgfortran5-cxx11-mpi+mpich/destdir/lib" + +const P4EST_LIBS = " m" + const P4EST_PACKAGE = "p4est" const P4EST_PACKAGE_BUGREPORT = "p4est@ins.uni-bonn.de" const P4EST_PACKAGE_NAME = "p4est" -const P4EST_PACKAGE_STRING = "p4est 2.8.7" +const P4EST_PACKAGE_STRING = "p4est 0.0.0" const P4EST_PACKAGE_TARNAME = "p4est" const P4EST_PACKAGE_URL = "" -const P4EST_PACKAGE_VERSION = "2.8.7" +const P4EST_PACKAGE_VERSION = "0.0.0" -const P4EST_VERSION = "2.8.7" +const P4EST_VERSION = "0.0.0" -const P4EST_VERSION_MAJOR = 2 +const P4EST_VERSION_MAJOR = 0 -const P4EST_VERSION_MINOR = 8 +const P4EST_VERSION_MINOR = 0 -const P4EST_VERSION_POINT = 7 +const P4EST_VERSION_POINT = 0 const p4est_qcoord_compare = sc_int32_compare @@ -17166,59 +18518,27 @@ const P8EST_STRING = "p8est" const P8EST_ONDISK_FORMAT = 0x03000009 -const T8_SHMEM_BEST_TYPE = SC_SHMEM_WINDOW - -# Skipping MacroDefinition: T8_MPI_ECLASS_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_eclass_t ) ) , sc_MPI_INT ) - -const T8_ECLASS_MAX_FACES = 6 - -const T8_ECLASS_MAX_EDGES = 12 - -const T8_ECLASS_MAX_EDGES_2D = 4 - -const T8_ECLASS_MAX_CORNERS_2D = 4 - -const T8_ECLASS_MAX_CORNERS = 8 - -const T8_ECLASS_MAX_DIM = 3 - -const T8_ECLASS_MAX_CHILDREN = 10 - -# Skipping MacroDefinition: T8_FACE_VERTEX_TO_TREE_VERTEX_VALUES { { { - 1 } } , /* vertex */ { { 0 } , { 1 } } , /* line */ { { 0 , 2 } , { 1 , 3 } , { 0 , 1 } , { 2 , 3 } } , /* quad */ { { 1 , 2 } , { 0 , 2 } , { 0 , 1 } } , /* triangle */ { { 0 , 2 , 4 , 6 } , { 1 , 3 , 5 , 7 } , { 0 , 1 , 4 , 5 } , { 2 , 3 , 6 , 7 } , { 0 , 1 , 2 , 3 } , { 4 , 5 , 6 , 7 } } , /* hex */ { { 1 , 2 , 3 } , { 0 , 2 , 3 } , { 0 , 1 , 3 } , { 0 , 1 , 2 } } , /* tet */ { { 1 , 2 , 4 , 5 } , { 0 , 2 , 3 , 5 } , { 0 , 1 , 3 , 4 } , { 0 , 1 , 2 } , { 3 , 4 , 5 } } , /* prism */ { { 0 , 2 , 4 } , { 1 , 3 , 4 } , { 0 , 1 , 4 } , { 2 , 3 , 4 } , { 0 , 1 , 2 , 3 } } /* pyramid */ \ -#} - -# Skipping MacroDefinition: T8_FACE_EDGE_TO_TREE_EDGE_VALUES { { { - 1 } } , /* vertex */ { { 0 } } , /* line */ { { 0 } , { 1 } , { 2 } , { 3 } } , /* quad */ { { 0 } , { 1 } , { 2 } } , /* triangle */ { { 8 , 10 , 4 , 6 } , { 9 , 11 , 5 , 7 } , { 8 , 9 , 0 , 2 } , { 10 , 11 , 1 , 3 } , { 4 , 5 , 0 , 1 } , { 6 , 7 , 2 , 3 } } , /* hex */ { { 3 , 4 , 5 } , { 1 , 2 , 5 } , { 0 , 2 , 4 } , { 0 , 1 , 3 } } , /* tet */ { { 0 , 7 , 3 , 6 } , { 1 , 8 , 4 , 7 } , { 2 , 6 , 5 , 8 } , { 0 , 1 , 2 } , { 3 , 4 , 5 } } , /* prism */ { { - 1 } } , /* pyramid */ \ -#} - -# Skipping MacroDefinition: T8_FACE_TO_EDGE_NEIGHBOR_VALUES { { { - 1 } } , /* vertex */ { { - 1 } } , /* line */ { { 2 , 3 } , { 2 , 3 } , { 0 , 1 } , { 0 , 1 } } , /* quad */ { { 2 , 1 } , { 2 , 0 } , { 1 , 0 } } , /* triangle */ { { 0 , 1 , 2 , 3 } , { 0 , 1 , 2 , 3 } , { 4 , 5 , 6 , 7 } , { 4 , 5 , 6 , 7 } , { 8 , 9 , 10 , 11 } , { 8 , 9 , 10 , 11 } } , /* hex */ { { 0 , 1 , 2 } , { 0 , 3 , 4 } , { 1 , 3 , 5 } , { 2 , 4 , 5 } } , /* tet */ { { 1 , 2 , 4 , 5 } , { 0 , 2 , 3 , 5 } , { 0 , 1 , 3 , 4 } , { 6 , 7 , 8 } , { 6 , 7 , 8 } } , /* prism */ { { - 1 } } , /* pyramid */ \ -#} +const T8_CMESH_FORMAT = 0x0002 -# Skipping MacroDefinition: T8_EDGE_VERTEX_TO_TREE_VERTEX_VALUES { { { - 1 } } , /* vertex */ { { 0 } , { 1 } } , /* line */ { { 0 , 2 } , { 1 , 3 } , { 0 , 1 } , { 2 , 3 } } , /* quad */ { { 1 , 2 } , { 0 , 2 } , { 0 , 1 } } , /* triangle */ { { 0 , 1 } , { 2 , 3 } , { 4 , 5 } , { 6 , 7 } , { 0 , 2 } , { 1 , 3 } , { 4 , 6 } , { 5 , 7 } , { 0 , 4 } , { 1 , 5 } , { 2 , 6 } , { 3 , 7 } } , /* hex */ { { 0 , 1 } , { 0 , 2 } , { 0 , 3 } , { 1 , 2 } , { 1 , 3 } , { 2 , 3 } } , /* tet */ { { 1 , 2 } , { 0 , 2 } , { 0 , 1 } , { 4 , 5 } , { 3 , 5 } , { 3 , 4 } , { 1 , 4 } , { 2 , 5 } , { 0 , 3 } } , /* prism */ { { - 1 } } , /* pyramid */ \ -#} +const T8_CMESH_VERTICES_ATTRIBUTE_KEY = 0 -# Skipping MacroDefinition: T8_EDGE_TO_FACE_VALUES { { { - 1 } } , /* vertex */ { { 0 } } , /* line */ { { 0 } , { 1 } , { 2 } , { 3 } } , /* quad */ { { 0 } , { 1 } , { 2 } } , /* triangle */ { { 2 , 4 } , { 3 , 4 } , { 2 , 5 } , { 3 , 5 } , { 0 , 4 } , { 1 , 4 } , { 0 , 5 } , { 1 , 5 } , { 0 , 2 } , { 1 , 2 } , { 0 , 3 } , { 1 , 3 } } , /* hex */ { { 2 , 3 } , { 1 , 3 } , { 1 , 2 } , { 0 , 3 } , { 0 , 2 } , { 0 , 1 } } , /* tet */ { { 0 , 3 } , { 1 , 3 } , { 2 , 3 } , { 0 , 4 } , { 1 , 4 } , { 2 , 4 } , { 0 , 2 } , { 0 , 1 } , { 1 , 2 } } , /* prism */ { { - 1 } } , /* pyramid */ \ -#} +const T8_CMESH_GEOMETRY_ATTRIBUTE_KEY = 1 -# Skipping MacroDefinition: T8_ECLASS_FACE_ORIENTATION_VALUES { { 0 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 0 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 0 , 0 , 0 , 0 , - 1 , - 1 } , /* quad */ { 0 , 0 , 0 , - 1 , - 1 , - 1 } , /* triangle */ { 0 , 1 , 1 , 0 , 0 , 1 } , /* hex */ { 0 , 1 , 0 , 1 , - 1 , - 1 } , /* tet */ { 1 , 0 , 1 , 0 , 1 , - 1 } , /* prism */ { 0 , 1 , 1 , 0 , 0 , - 1 } /* pyramid */ \ -#} +const T8_CMESH_CAD_EDGE_ATTRIBUTE_KEY = 2 -# Skipping MacroDefinition: T8_ECLASS_VTK_TO_T8_CORNER_NUMBER_VALUES { { 0 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 0 , 1 , 3 , 2 , - 1 , - 1 , - 1 , - 1 } , /* quad */ { 0 , 1 , 2 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* triangle */ { 0 , 1 , 3 , 2 , 4 , 5 , 7 , 6 } , /* hex */ { 0 , 2 , 1 , 3 , - 1 , - 1 , - 1 , - 1 } , /* tet */ { 0 , 2 , 1 , 3 , 5 , 4 , - 1 , - 1 } , /* prism */ { 0 , 1 , 3 , 2 , 4 , - 1 , - 1 , - 1 } /* pyramid */ \ -#} +const T8_CMESH_CAD_EDGE_PARAMETERS_ATTRIBUTE_KEY = 3 -# Skipping MacroDefinition: T8_ECLASS_T8_TO_VTK_CORNER_NUMBER_VALUES { { 0 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 0 , 1 , 3 , 2 , - 1 , - 1 , - 1 , - 1 } , /* quad */ { 0 , 1 , 2 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* triangle */ { 0 , 1 , 3 , 2 , 4 , 5 , 7 , 6 } , /* hex */ { 0 , 2 , 1 , 3 , - 1 , - 1 , - 1 , - 1 } , /* tet */ { 0 , 2 , 1 , 3 , 5 , 4 , - 1 , - 1 } , /* prism */ { 0 , 1 , 3 , 2 , 4 , - 1 , - 1 , - 1 } /* pyramid */ \ -#} +const T8_CMESH_CAD_FACE_ATTRIBUTE_KEY = T8_CMESH_CAD_EDGE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_EDGES -# Skipping MacroDefinition: T8_ECLASS_FACE_TYPES_VALUES { { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 0 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 1 , 1 , 1 , 1 , - 1 , - 1 } , /* quad */ { 1 , 1 , 1 , - 1 , - 1 , - 1 } , /* triangle */ { 2 , 2 , 2 , 2 , 2 , 2 } , /* hex */ { 3 , 3 , 3 , 3 , - 1 , - 1 } , /* tet */ { 2 , 2 , 2 , 3 , 3 , - 1 } , /* prism */ { 3 , 3 , 3 , 3 , 2 , - 1 } /* pyramid */ \ -#} +const T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY = T8_CMESH_CAD_FACE_ATTRIBUTE_KEY + 1 -# Skipping MacroDefinition: T8_ECLASS_BOUNDARY_COUNT_VALUES { { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , /* vertex */ { 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , /* line */ { 4 , 4 , 0 , 0 , 0 , 0 , 0 , 0 } , /* quad */ { 3 , 3 , 0 , 0 , 0 , 0 , 0 , 0 } , /* triangle */ { 8 , 12 , 6 , 0 , 0 , 0 , 0 , 0 } , /* hex */ { 4 , 6 , 0 , 4 , 0 , 0 , 0 , 0 } , /* tet */ { 6 , 9 , 3 , 2 , 0 , 0 , 0 , 0 } , /* prism */ { 5 , 8 , 1 , 4 , 0 , 0 , 0 , 0 } /* pyramid */ \ -#} +const T8_CMESH_LAGRANGE_POLY_DEGREE_KEY = T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_FACES -# Skipping MacroDefinition: T8_MPI_ELEMENT_SHAPE_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_element_shape_t ) ) , sc_MPI_INT ) +const T8_CMESH_NEXT_POSSIBLE_KEY = T8_CMESH_LAGRANGE_POLY_DEGREE_KEY + 1 -const T8_ELEMENT_SHAPE_MAX_FACES = 6 +const T8_CPROFILE_NUM_STATS = 11 -const T8_ELEMENT_SHAPE_MAX_CORNERS = 8 +const T8_SHMEM_BEST_TYPE = SC_SHMEM_WINDOW const T8_FOREST_FROM_FIRST = 0 @@ -17238,21 +18558,7 @@ const T8_FOREST_BALANCE_REPART = 1 const T8_FOREST_BALANCE_NO_REPART = 2 -const T8_PROFILE_NUM_STATS = 17 - -# Skipping MacroDefinition: T8_THROW_ERROR_WITH @ "Invalid usage of T8_WITH_*. Use T8_ENABLE_* instead." - -const T8_VTK_LOCIDX = "Int32" - -const T8_VTK_GLOIDX = "Int32" - -const T8_VTK_FLOAT_NAME = "Float32" - -const T8_VTK_FLOAT_TYPE = Float32 - -const T8_VTK_FORMAT_STRING = "ascii" - -const T8_CMESH_N_SUPPORTED_MSH_FILE_VERSIONS = 1 +const T8_PROFILE_NUM_STATS = 14 # exports const PREFIXES = ["t8_", "T8_"] From 0675b3eb89c77063e166dfc461febcdf5ebd3be1 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Wed, 1 Jul 2026 10:26:51 +0200 Subject: [PATCH 05/12] bump version --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 4928151..77f1318 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "T8code" uuid = "d0cc0030-9a40-4274-8435-baadcfd54fa1" authors = ["Johannes Markert "] -version = "0.9.1" +version = "0.9.2" [deps] CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" @@ -22,4 +22,4 @@ Preferences = "1.2.1" Reexport = "0.2, 1.0" UUIDs = "1" julia = "1.10" -t8code_jll = "=4.0.6" +t8code_jll = "=4.0.7" From bbe80ec9c90929bd798b201d6c9131b49165f8c1 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 7 Jul 2026 11:01:36 +0200 Subject: [PATCH 06/12] artifact used when generating --- dev/Artifacts.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/Artifacts.toml b/dev/Artifacts.toml index 4b3f888..e00551f 100644 --- a/dev/Artifacts.toml +++ b/dev/Artifacts.toml @@ -7,5 +7,5 @@ mpi = "mpich" os = "linux" [[t8code.download]] - sha256 = "0413dac63e9bba5c9b27c9a7850377b7946860956db538290849c47acd3a130d" - url = "https://github.com/JuliaBinaryWrappers/t8code_jll.jl/releases/download/t8code-v3.0.1+0/t8code.v3.0.1.x86_64-linux-gnu-mpi+mpich.tar.gz" + sha256 = "a1f03e34fccbdda56e381bc3bb5c52b7917a4aae2afeb68777906f4ccac28ef6" + url = "https://github.com/JuliaBinaryWrappers/t8code_jll.jl/releases/download/t8code-v4.0.7%2B0/t8code-logs.v4.0.7.x86_64-linux-gnu-mpi+mpich.tar.gz" From ead26b655d850f3d8b55dc27b8e50242464aa083 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 7 Jul 2026 11:05:59 +0200 Subject: [PATCH 07/12] rm accidentally added file --- examples/t8_brick_partition_balance_ghost.jl | 202 ------------------- 1 file changed, 202 deletions(-) delete mode 100644 examples/t8_brick_partition_balance_ghost.jl diff --git a/examples/t8_brick_partition_balance_ghost.jl b/examples/t8_brick_partition_balance_ghost.jl deleted file mode 100644 index f41ae32..0000000 --- a/examples/t8_brick_partition_balance_ghost.jl +++ /dev/null @@ -1,202 +0,0 @@ -using MPI -using T8code -using T8code.Libt8: sc_init -using T8code.Libt8: sc_finalize -using T8code.Libt8: SC_LP_ESSENTIAL -using T8code.Libt8: SC_LP_PRODUCTION - - -# Print the local and global number of elements of a forest. -function t8_step3_print_forest_information(forest) - # Check that forest is a committed, that is valid and usable, forest. - @T8_ASSERT(t8_forest_is_committed(forest)==1) - - # Get the local number of elements. - local_num_elements = t8_forest_get_local_num_leaf_elements(forest) - # Get the global number of elements. - global_num_elements = t8_forest_get_global_num_leaf_elements(forest) - - t8_global_productionf(" [step3] Local number of elements:\t\t%i\n", local_num_elements) - t8_global_productionf(" [step3] Global number of elements:\t%li\n", global_num_elements) -end - - -# Gather the 3x3 stencil for each element and compute finite difference approximations -# for schlieren and curvature of the stored heights in the elements. -function t8_traverse_forest(forest, comm) - # Check that forest is a committed, that is valid and usable, forest. - @T8_ASSERT(t8_forest_is_committed(forest)==1) - - # Get the number of trees that have elements of this process. - num_local_trees = t8_forest_get_num_local_trees(forest) - - scheme = t8_forest_get_scheme(forest) - - # Loop over all local trees in the forest. - for itree in 0:(num_local_trees - 1) - tree_class = t8_forest_get_tree_class(forest, itree) - num_elements_in_tree = t8_forest_get_tree_num_leaf_elements(forest, itree) - - # Loop over all local elements in the tree. - for ielement in 0:(num_elements_in_tree - 1) - - element = t8_forest_get_leaf_element_in_tree(forest, itree, ielement) - - level = t8_element_get_level(scheme, tree_class, element) - - # Loop over all faces of an element. - num_faces = t8_element_get_num_faces(scheme, tree_class, element) - for iface in 1:num_faces - neighids_ref = Ref{Ptr{t8_locidx_t}}() - neighbors_ref = Ref{Ptr{Ptr{t8_element}}}() - neigh_scheme_ref = Ref{t8_eclass_t}() - - dual_faces_ref = Ref{Ptr{Cint}}() - num_neighbors_ref = Ref{Cint}() - - t8_forest_leaf_face_neighbors(forest, itree, element, - neighbors_ref, iface - 1, dual_faces_ref, - num_neighbors_ref, - neighids_ref, neigh_scheme_ref) - - num_neighbors = num_neighbors_ref[] - dual_faces = 1 .+ unsafe_wrap(Array, dual_faces_ref[], num_neighbors) - neighids = 1 .+ unsafe_wrap(Array, neighids_ref[], num_neighbors) - neighbors = unsafe_wrap(Array, neighbors_ref[], num_neighbors) - neigh_scheme = neigh_scheme_ref[] - - if num_neighbors > 0 - neighbor_level = t8_element_get_level(scheme, neigh_scheme, - neighbors[1]) - @info MPI.Comm_rank(comm), itree, ielement, iface, level, neighbor_level - end - - # Free allocated memory. - t8_free(dual_faces_ref[]) - t8_free(neighbors_ref[]) - t8_free(neighids_ref[]) - end - end - end -end - - -# In this function we create a new forest that repartitions a given forest -# and has a layer of ghost elements. -function t8_step4_partition_ghost(forest) - # Check that forest is a committed, that is a valid and usable, forest. - @T8_ASSERT(t8_forest_is_committed(forest)==1) - - # Initialize. - new_forest_ref = Ref(t8_forest_t()) - t8_forest_init(new_forest_ref) - new_forest = new_forest_ref[] - - # Tell the new_forest that is should partition the existing forest. - # This will change the distribution of the forest elements among the processes - # in such a way that afterwards each process has the same number of elements - # (+- 1 if the number of elements is not divisible by the number of processes). - # - # The third 0 argument is the flag 'partition_for_coarsening' which is currently not - # implemented. Once it is, this will ensure that a family of elements will not be split - # across multiple processes and thus one level coarsening is always possible (see also the - # comments on coarsening in t8_step3). - t8_forest_set_partition(new_forest, forest, 1) - - # Tell the new_forest to create a ghost layer. - # This will gather those face neighbor elements of process local element that reside - # on a different process. - # - # We currently support ghost mode T8_GHOST_FACES that creates face neighbor ghost elements - # and will in future also support other modes for edge/vertex neighbor ghost elements. - t8_forest_set_ghost(new_forest, 1, T8_GHOST_FACES) - - # Commit the forest, this step will perform the partitioning and ghost layer creation. - t8_forest_commit(new_forest) - - return new_forest -end - -# In this function we adapt a forest as in step3 and balance it. In our main -# program the input forest is already adapted and then the resulting twice -# adapted forest will be unbalanced. -function t8_step4_balance(forest) - - # Initialize new forest. - balanced_forest_ref = Ref(t8_forest_t()) - t8_forest_init(balanced_forest_ref) - balanced_forest = balanced_forest_ref[] - - # Specify that this forest should result from balancing unbalanced_forest. - # The last argument is the flag 'no_repartition'. - # Since balancing will refine elements, the load-balance will be broken afterwards. - # Setting this flag to false (no_repartition = false -> yes repartition) will repartition - # the forest after balance, such that every process has the same number of elements afterwards. - t8_forest_set_balance(balanced_forest, forest, 1) - t8_forest_set_ghost(balanced_forest, 1, T8_GHOST_FACES) - - # Commit the forest. - t8_forest_commit(balanced_forest) - - return balanced_forest -end - -#include("t8_step3_common.jl") - - - - -# The uniform refinement level of the forest. -level = 0 - -# Initialize MPI. This has to happen before we initialize sc or t8code. -mpiret = MPI.Init() - -# We will use MPI_COMM_WORLD as a communicator. -comm = MPI.COMM_WORLD - -# Initialize the sc library, has to happen before we initialize t8code. -sc_init(comm, 0, 1, C_NULL, SC_LP_ESSENTIAL) - -# Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. -t8_init(SC_LP_PRODUCTION) - - -# Build a cube cmesh with tet, hex, and prism trees. -cmesh = t8_cmesh_new_brick_2d(3, 7, 0, 0, comm) -t8_global_productionf(" [step4] Created coarse mesh.\n") - -forest = t8_forest_new_uniform(cmesh, t8_scheme_new_default(), level, 1, comm) - -# Print information of the forest. -t8_step3_print_forest_information(forest); - - - -# -# Balance -# -forest = t8_step4_balance(forest) -t8_global_productionf(" [step4] Balanced forest.\n") -t8_step3_print_forest_information(forest) - - -# -# Partition and create ghost elements. -# -forest = t8_step4_partition_ghost(forest) - -t8_global_productionf(" [step4] Repartitioned forest and built ghost layer.\n") -t8_step3_print_forest_information(forest) - - -t8_traverse_forest(forest, comm) - -# -# clean-up -# - -# Destroy the forest. -t8_forest_unref(Ref(forest)) - -sc_finalize() From 57a99079aaa2fef1ad33f4f90eaa3f43cdd6d579 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 7 Jul 2026 11:10:28 +0200 Subject: [PATCH 08/12] Revert "try reading the platform BUFSIZ from t8_vtk_data_field_t" This reverts commit f231c85ab45780f984c604eabdbaa28f8e2177d3. --- examples/t8_step5_element_data.jl | 14 +++++++------- examples/t8_step6_stencil.jl | 12 +++++++----- src/T8code.jl | 3 --- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/examples/t8_step5_element_data.jl b/examples/t8_step5_element_data.jl index 2b5092d..526ecb9 100644 --- a/examples/t8_step5_element_data.jl +++ b/examples/t8_step5_element_data.jl @@ -194,10 +194,8 @@ function t8_step5_output_data_to_vtu(forest, element_data, prefix) # WARNING: This code hangs for Julia v1.8.* or older. Use at least Julia v1.9. # For each user defined data field we need one t8_vtk_data_field_t variable. - vtk_data = t8_vtk_data_field_t(T8_VTK_SCALAR, - # Sets the type of this variable. Since we have one value per element, we pick T8_VTK_SCALAR. - NTuple{T8code.T8_BUFSIZ, Cchar}(rpad("Element volume\0", T8code.T8_BUFSIZ, ' ')), - # The name of the field as should be written to the file. + vtk_data = t8_vtk_data_field_t(T8_VTK_SCALAR, # Set the type of this variable. Since we have one value per element, we pick T8_VTK_SCALAR. + NTuple{8192, Cchar}(rpad("Element volume\0", 8192, ' ')), # The name of the field as should be written to the file. pointer(element_volumes)) # To write user defined data, we need to extended output function @@ -279,9 +277,11 @@ if t8_forest_get_num_ghosts(forest) > 0 end # Output the volume data to vtu. -t8_step5_output_data_to_vtu(forest, element_data, prefix_forest_with_data) -t8_global_productionf(" [step5] Wrote forest and volume data to %s*.\n", - prefix_forest_with_data) +if !(CI_ON_WINDOWS || CI_ON_MACOS) + t8_step5_output_data_to_vtu(forest, element_data, prefix_forest_with_data) + t8_global_productionf(" [step5] Wrote forest and volume data to %s*.\n", + prefix_forest_with_data) +end # # Clean-up. diff --git a/examples/t8_step6_stencil.jl b/examples/t8_step6_stencil.jl index 6a72465..6d3f338 100644 --- a/examples/t8_step6_stencil.jl +++ b/examples/t8_step6_stencil.jl @@ -339,13 +339,13 @@ function t8_step6_output_data_to_vtu(forest, element_data, prefix) # WARNING: This code hangs for Julia v1.8.* or older. Use at least Julia v1.9. vtk_data = [ t8_vtk_data_field_t(T8_VTK_SCALAR, - NTuple{T8code.T8_BUFSIZ, Cchar}(rpad("height\0", T8code.T8_BUFSIZ, ' ')), + NTuple{8192, Cchar}(rpad("height\0", 8192, ' ')), pointer(heights)), t8_vtk_data_field_t(T8_VTK_SCALAR, - NTuple{T8code.T8_BUFSIZ, Cchar}(rpad("schlieren\0", T8code.T8_BUFSIZ, ' ')), + NTuple{8192, Cchar}(rpad("schlieren\0", 8192, ' ')), pointer(schlieren)), t8_vtk_data_field_t(T8_VTK_SCALAR, - NTuple{T8code.T8_BUFSIZ, Cchar}(rpad("curvature\0", T8code.T8_BUFSIZ, ' ')), + NTuple{8192, Cchar}(rpad("curvature\0", 8192, ' ')), pointer(curvature)) ] @@ -402,8 +402,10 @@ t8_step6_exchange_ghost_data(forest, element_data) t8_step6_compute_stencil(forest, element_data) # Output the data to vtu files. -t8_step6_output_data_to_vtu(forest, element_data, prefix_forest_with_data) -t8_global_productionf(" Wrote forest and data to %s*.\n", prefix_forest_with_data) +if !(CI_ON_WINDOWS || CI_ON_MACOS) + t8_step6_output_data_to_vtu(forest, element_data, prefix_forest_with_data) + t8_global_productionf(" Wrote forest and data to %s*.\n", prefix_forest_with_data) +end # # Clean-up diff --git a/src/T8code.jl b/src/T8code.jl index 6736716..10fc3ee 100644 --- a/src/T8code.jl +++ b/src/T8code.jl @@ -250,9 +250,6 @@ macro T8_ASSERT(q) :($(esc(q)) ? nothing : throw(AssertionError($(string(q))))) end -# platform specific BUFSIZ used in t8_vtk_data_field_t -const T8_BUFSIZ = sizeof(t8_vtk_data_field_t.types[2]) - function t8_free(ptr) Libt8.sc_free(t8_get_package_id(), ptr) end From 86d7415818a7966acd6e9c46ed3f80dc5a0c16e1 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 7 Jul 2026 11:12:04 +0200 Subject: [PATCH 09/12] Revert "remove CI check for Apple or Windows" This reverts commit 9bfeb0d6e614b670fb6bcc0a180ad7e871dcd4f7. --- test/test_all.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test_all.jl b/test/test_all.jl index db46548..cfc21da 100644 --- a/test/test_all.jl +++ b/test/test_all.jl @@ -12,6 +12,11 @@ MPI.Init() comm = MPI.COMM_WORLD +# Check whether we run CI in the cloud with Windows or Mac, see also +# https://docs.github.com/en/actions/learn-github-actions/environment-variables +CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() +CI_ON_MACOS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.isapple() + @testset "init" begin include("test_init.jl") end From faaab3bd323560e5bcdf28c06e2458673b4a3eb5 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 7 Jul 2026 11:18:53 +0200 Subject: [PATCH 10/12] move sc_keyval_t declaration in front of sc_stats --- src/Libt8.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Libt8.jl b/src/Libt8.jl index 0d7362b..e4e3644 100644 --- a/src/Libt8.jl +++ b/src/Libt8.jl @@ -4791,6 +4791,11 @@ function t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_ca @ccall libt8.t8_cmesh_from_msh_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, dim::Cint, master::Cint, use_cad_geometry::Cint)::t8_cmesh_t end +mutable struct sc_keyvalue end + +"""The key-value container is an opaque structure.""" +const sc_keyvalue_t = sc_keyvalue + struct sc_stats mpicomm::MPI_Comm kv::Ptr{sc_keyvalue_t} @@ -4980,11 +4985,6 @@ The values can have different types. SC_KEYVALUE_ENTRY_POINTER = 4 end -mutable struct sc_keyvalue end - -"""The key-value container is an opaque structure.""" -const sc_keyvalue_t = sc_keyvalue - # no prototype is found for this function at sc_keyvalue.h:54:21, please use with caution """ sc_keyvalue_new() From 99c7decd26228b950a9dabe74f54f7102d9b0a93 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 7 Jul 2026 11:46:51 +0200 Subject: [PATCH 11/12] correct artifact --- dev/Artifacts.toml | 6 +- src/Libt8.jl | 14734 +++++++++++++++++++------------------------ 2 files changed, 6589 insertions(+), 8151 deletions(-) diff --git a/dev/Artifacts.toml b/dev/Artifacts.toml index e00551f..1acacf3 100644 --- a/dev/Artifacts.toml +++ b/dev/Artifacts.toml @@ -1,11 +1,11 @@ [[t8code]] arch = "x86_64" -git-tree-sha1 = "593b8ed41f90aa10d015d6ef2032441fda382f32" +git-tree-sha1 = "22c9c74032be408f80b485c3a7aee80dfe69b777" lazy = true libc = "glibc" mpi = "mpich" os = "linux" [[t8code.download]] - sha256 = "a1f03e34fccbdda56e381bc3bb5c52b7917a4aae2afeb68777906f4ccac28ef6" - url = "https://github.com/JuliaBinaryWrappers/t8code_jll.jl/releases/download/t8code-v4.0.7%2B0/t8code-logs.v4.0.7.x86_64-linux-gnu-mpi+mpich.tar.gz" + sha256 = "111c1ed11d8cced1b9a620630d270201b2a0a0a08d4e9fff14205bd758311b98" + url = "https://github.com/JuliaBinaryWrappers/t8code_jll.jl/releases/download/t8code-v4.0.7+0/t8code.v4.0.7.x86_64-linux-gnu-mpi+mpich.tar.gz" diff --git a/src/Libt8.jl b/src/Libt8.jl index e4e3644..44ee4ca 100644 --- a/src/Libt8.jl +++ b/src/Libt8.jl @@ -68,19 +68,21 @@ const INT64_MAX = typemax(Clonglong) """ - sc_extern_c_hack_3() + sc_extern_c_hack_1() + +We want to export the whole implementation to be callable from "C". ### Prototype ```c SC_EXTERN_C_BEGIN; ``` """ -function sc_extern_c_hack_3() - @ccall libsc.sc_extern_c_hack_3()::Cvoid +function sc_extern_c_hack_1() + @ccall libsc.sc_extern_c_hack_1()::Cvoid end """ - sc_extern_c_hack_4() + sc_extern_c_hack_2() ` ` @@ -89,8 +91,8 @@ end SC_EXTERN_C_END; ``` """ -function sc_extern_c_hack_4() - @ccall libsc.sc_extern_c_hack_4()::Cvoid +function sc_extern_c_hack_2() + @ccall libsc.sc_extern_c_hack_2()::Cvoid end """ @@ -178,9 +180,12 @@ end The central log function to be called by all packages. Dispatches the log calls by package and filters by category and priority. # Arguments +* `filename`:\\[in\\] Usually used with a \\_\\_FILE\\_\\_ argument. +* `lineno`:\\[in\\] Usually used with a \\_\\_LINE\\_\\_ argument. * `package`:\\[in\\] Must be a registered package id or -1. * `category`:\\[in\\] Must be [`SC_LC_NORMAL`](@ref) or [`SC_LC_GLOBAL`](@ref). * `priority`:\\[in\\] Must be > [`SC_LP_ALWAYS`](@ref) and < [`SC_LP_SILENT`](@ref). +* `msg`:\\[in\\] Nul-terminated string to print. ### Prototype ```c void sc_log (const char *filename, int lineno, int package, int category, int priority, const char *msg); @@ -306,6 +311,38 @@ function sc_shmem_free(package, array, comm) @ccall libsc.sc_shmem_free(package::Cint, array::Ptr{Cvoid}, comm::MPI_Comm)::Cvoid end +""" + sc_mpi_is_enabled() + +Return whether MPI is configured. + +# Returns +Boolean corresponding to define [`SC_ENABLE_MPI`](@ref). +### Prototype +```c +int sc_mpi_is_enabled (void); +``` +""" +function sc_mpi_is_enabled() + @ccall libsc.sc_mpi_is_enabled()::Cint +end + +""" + sc_mpi_is_shared() + +Return whether MPI supports type split and shared windows. + +# Returns +Boolean corresponding to #define [`SC_ENABLE_MPISHARED`](@ref). +### Prototype +```c +int sc_mpi_is_shared (void); +``` +""" +function sc_mpi_is_shared() + @ccall libsc.sc_mpi_is_shared()::Cint +end + """ sc_tag_t @@ -470,10 +507,8 @@ function sc_mpi_comm_get_and_attach(comm) @ccall libsc.sc_mpi_comm_get_and_attach(comm::MPI_Comm)::Cint end -# typedef void ( * sc_handler_t ) ( void * data ) -const sc_handler_t = Ptr{Cvoid} - # typedef void ( * sc_log_handler_t ) ( FILE * log_stream , const char * filename , int lineno , int package , int category , int priority , const char * msg ) +"""Type of the log handler function.""" const sc_log_handler_t = Ptr{Cvoid} # typedef void ( * sc_abort_handler_t ) ( void ) @@ -793,6 +828,7 @@ Set the logging verbosity of a registered package. This can be called at any poi # Arguments * `package_id`:\\[in\\] Must be a registered package identifier. +* `log_priority`:\\[in\\] The minimum priority required to output. ### Prototype ```c void sc_package_set_verbosity (int package_id, int log_priority); @@ -1020,6 +1056,22 @@ function sc_version_minor() @ccall libsc.sc_version_minor()::Cint end +""" + sc_is_littleendian() + +Perform a runtime check for the integer endian convention. + +# Returns +True if byte order is little endian, false otherwise. +### Prototype +```c +int sc_is_littleendian (void); +``` +""" +function sc_is_littleendian() + @ccall libsc.sc_is_littleendian()::Cint +end + """ sc_have_zlib() @@ -1052,6 +1104,22 @@ function sc_have_json() @ccall libsc.sc_have_json()::Cint end +""" + sc_sleep(milliseconds) + +Portable function to sleep a prescribed amount of milliseconds. + +# Arguments +* `milliseconds`:\\[in\\] The number of milliseconds to sleep. +### Prototype +```c +void sc_sleep (unsigned milliseconds); +``` +""" +function sc_sleep(milliseconds) + @ccall libsc.sc_sleep(milliseconds::Cuint)::Cvoid +end + # typedef unsigned int ( * sc_hash_function_t ) ( const void * v , const void * u ) """ Function to compute a hash value of an object. @@ -2895,6 +2963,9 @@ function sc_recycle_array_remove(rec_array, position) @ccall libsc.sc_recycle_array_remove(rec_array::Ptr{sc_recycle_array_t}, position::Csize_t)::Ptr{Cvoid} end +"""A type for holding process ids.""" +const t8_procidx_t = Cint + """A type for storing SFC indices""" const t8_linearidx_t = UInt64 @@ -2903,13 +2974,18 @@ const t8_linearidx_t = UInt64 Communication tags used internal to t8code. -| Enumerator | Note | -| :------------------------------------- | :-------------------------------------------------- | -| T8\\_MPI\\_PARTITION\\_CMESH | Used for coarse mesh partitioning | -| T8\\_MPI\\_PARTITION\\_FOREST | Used for forest partitioning | -| T8\\_MPI\\_GHOST\\_FOREST | Used for for ghost layer creation | -| T8\\_MPI\\_GHOST\\_EXC\\_FOREST | Used for ghost data exchange | -| T8\\_MPI\\_TEST\\_ELEMENT\\_PACK\\_TAG | Used for testing mpi pack and unpack functionality | +| Enumerator | Note | +| :------------------------------------------ | :------------------------------------------------------- | +| T8\\_MPI\\_TAG\\_FIRST | Dummy first MPT tag. | +| T8\\_MPI\\_PARTITION\\_CMESH | Used for coarse mesh partitioning | +| T8\\_MPI\\_PARTITION\\_FOREST | Used for forest partitioning | +| T8\\_MPI\\_GHOST\\_FOREST | Used for for ghost layer creation | +| T8\\_MPI\\_GHOST\\_EXC\\_FOREST | Used for ghost data exchange | +| T8\\_MPI\\_CMESH\\_UNIFORM\\_BOUNDS\\_START | Used for cmesh uniform bounds computation. | +| T8\\_MPI\\_CMESH\\_UNIFORM\\_BOUNDS\\_END | | +| T8\\_MPI\\_TEST\\_ELEMENT\\_PACK\\_TAG | Used for testing mpi pack and unpack functionality | +| T8\\_MPI\\_PFC\\_TAG | Used for data exchange during partition for coarsening. | +| T8\\_MPI\\_TAG\\_LAST | Dummy last MPI tag. | """ @cenum t8_MPI_tag_t::UInt32 begin T8_MPI_TAG_FIRST = 214 @@ -2917,8 +2993,11 @@ Communication tags used internal to t8code. T8_MPI_PARTITION_FOREST = 296 T8_MPI_GHOST_FOREST = 297 T8_MPI_GHOST_EXC_FOREST = 298 - T8_MPI_TEST_ELEMENT_PACK_TAG = 299 - T8_MPI_TAG_LAST = 300 + T8_MPI_CMESH_UNIFORM_BOUNDS_START = 299 + T8_MPI_CMESH_UNIFORM_BOUNDS_END = 300 + T8_MPI_TEST_ELEMENT_PACK_TAG = 301 + T8_MPI_PFC_TAG = 302 + T8_MPI_TAG_LAST = 303 end # automatic type deduction for variadic arguments may not be what you want, please use with caution @@ -2994,6 +3073,22 @@ end :(@ccall(libt8.t8_errorf(fmt::Cstring; $(to_c_type_pairs(va_list)...))::Cvoid)) end +""" + t8_set_external_log_fcn(log_fcn) + +Set a custom logging function to be used by t8code. When setting a custom logging function, the t8code internal logging function will be ignored. + +# Arguments +* `log_fcn`:\\[in\\] A function pointer to a logging function +### Prototype +```c +void t8_set_external_log_fcn (void (*log_fcn) (int category, int priority, const char *msg)); +``` +""" +function t8_set_external_log_fcn(log_fcn) + @ccall libt8.t8_set_external_log_fcn(log_fcn::Ptr{Cvoid})::Cvoid +end + """ t8_init(log_threshold) @@ -3011,21 +3106,22 @@ function t8_init(log_threshold) end """ - t8_sc_array_index_locidx(array, it) + t8_sc_array_index_locidx(array, index) Return a pointer to an array element indexed by a [`t8_locidx_t`](@ref). # Arguments +* `array`:\\[in\\] The array of elements. * `index`:\\[in\\] needs to be in [0]..[elem\\_count-1]. # Returns -A void * pointing to entry *it* in *array*. +A void * pointing to entry *index* in *array*. ### Prototype ```c -void * t8_sc_array_index_locidx (const sc_array_t *array, const t8_locidx_t it); +void * t8_sc_array_index_locidx (const sc_array_t *array, const t8_locidx_t index); ``` """ -function t8_sc_array_index_locidx(array, it) - @ccall libt8.t8_sc_array_index_locidx(array::Ptr{sc_array_t}, it::t8_locidx_t)::Ptr{Cvoid} +function t8_sc_array_index_locidx(array, index) + @ccall libt8.t8_sc_array_index_locidx(array::Ptr{sc_array_t}, index::t8_locidx_t)::Ptr{Cvoid} end """ @@ -3134,411 +3230,42 @@ function sc_shmem_prefix(sendbuf, recvbuf, count, type, op, comm) end """ - sc_refcount - -The refcount structure is declared in public so its size is known. Its members should really never be accessed directly. - -| Field | Note | -| :----------- | :----------------------------------------------------------- | -| package\\_id | The sc package that uses this reference counter. | -| refcount | The reference count is always positive for a valid counter. | -""" -struct sc_refcount - package_id::Cint - refcount::Cint -end - -"""The refcount structure is declared in public so its size is known. Its members should really never be accessed directly.""" -const sc_refcount_t = sc_refcount - -""" - sc_refcount_init_invalid(rc) - -Initialize a well-defined but unusable reference counter. Specifically, we set its package identifier and reference count to -1. To make this reference counter usable, call sc_refcount_init. - -# Arguments -* `rc`:\\[out\\] This reference counter is defined as invalid. It will return false on both sc_refcount_is_active and sc_refcount_is_last. It can be made valid by calling sc_refcount_init. No other functions must be called on it. -### Prototype -```c -void sc_refcount_init_invalid (sc_refcount_t * rc); -``` -""" -function sc_refcount_init_invalid(rc) - @ccall libsc.sc_refcount_init_invalid(rc::Ptr{sc_refcount_t})::Cvoid -end - -""" - sc_refcount_init(rc, package_id) - -Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. - -# Arguments -* `rc`:\\[out\\] This reference counter is initialized to one. The object's contents may be undefined on input. -* `package_id`:\\[in\\] Either -1 or a package registered to libsc. -### Prototype -```c -void sc_refcount_init (sc_refcount_t * rc, int package_id); -``` -""" -function sc_refcount_init(rc, package_id) - @ccall libsc.sc_refcount_init(rc::Ptr{sc_refcount_t}, package_id::Cint)::Cvoid -end - -""" - sc_refcount_new(package_id) - -Create a new reference counter with count initialized to 1. Equivalent to calling sc_refcount_init on a newly allocated rc object. - -# Arguments -* `package_id`:\\[in\\] Either -1 or a package registered to libsc. -# Returns -A reference counter with count one. -### Prototype -```c -sc_refcount_t *sc_refcount_new (int package_id); -``` -""" -function sc_refcount_new(package_id) - @ccall libsc.sc_refcount_new(package_id::Cint)::Ptr{sc_refcount_t} -end - -""" - sc_refcount_destroy(rc) - -Destroy a reference counter. It must have been counted down to zero before, thus reached an inactive state. - -# Arguments -* `rc`:\\[in,out\\] This reference counter must have reached count zero. -### Prototype -```c -void sc_refcount_destroy (sc_refcount_t * rc); -``` -""" -function sc_refcount_destroy(rc) - @ccall libsc.sc_refcount_destroy(rc::Ptr{sc_refcount_t})::Cvoid -end - -""" - sc_refcount_ref(rc) - -Increase a reference counter. The counter must be active, that is, have a value greater than zero. - -# Arguments -* `rc`:\\[in,out\\] This reference counter must be valid (greater zero). Its count is increased by one. -### Prototype -```c -void sc_refcount_ref (sc_refcount_t * rc); -``` -""" -function sc_refcount_ref(rc) - @ccall libsc.sc_refcount_ref(rc::Ptr{sc_refcount_t})::Cvoid -end - -""" - sc_refcount_unref(rc) - -Decrease the reference counter and notify when it reaches zero. The count must be greater zero on input. If the reference count reaches zero, which is indicated by the return value, the counter may not be used further with sc_refcount_ref or - -# Arguments -* `rc`:\\[in,out\\] This reference counter must be valid (greater zero). Its count is decreased by one. -# Returns -True if the count has reached zero, false otherwise. -# See also -[`sc_refcount_unref`](@ref). It is legal, however, to reactivate it later by calling, [`sc_refcount_init`](@ref). - -### Prototype -```c -int sc_refcount_unref (sc_refcount_t * rc); -``` -""" -function sc_refcount_unref(rc) - @ccall libsc.sc_refcount_unref(rc::Ptr{sc_refcount_t})::Cint -end - -""" - sc_refcount_is_active(rc) - -Check whether a reference counter has a positive value. This means that the reference counter is in use and corresponds to a live object. - -# Arguments -* `rc`:\\[in\\] A reference counter. -# Returns -True if the count is greater zero, false otherwise. -### Prototype -```c -int sc_refcount_is_active (const sc_refcount_t * rc); -``` -""" -function sc_refcount_is_active(rc) - @ccall libsc.sc_refcount_is_active(rc::Ptr{sc_refcount_t})::Cint -end - -""" - sc_refcount_is_last(rc) - -Check whether a reference counter has value one. This means that this counter is the last of its kind, which we may optimize for. - -# Arguments -* `rc`:\\[in\\] A reference counter. -# Returns -True if the count is exactly one. -### Prototype -```c -int sc_refcount_is_last (const sc_refcount_t * rc); -``` -""" -function sc_refcount_is_last(rc) - @ccall libsc.sc_refcount_is_last(rc::Ptr{sc_refcount_t})::Cint -end - -mutable struct t8_eclass_scheme end - -"""This typedef holds virtual functions for a particular element class.""" -const t8_eclass_scheme_c = t8_eclass_scheme - -""" - t8_scheme_cxx - -The scheme holds implementations for one or more element classes. - -| Field | Note | -| :--------------- | :----------------------------------------------------- | -| rc | Reference counter for this scheme. | -| eclass\\_schemes | This array holds one virtual table per element class. | -""" -struct t8_scheme_cxx - rc::sc_refcount_t - eclass_schemes::NTuple{8, Ptr{t8_eclass_scheme_c}} -end - -"""The scheme holds implementations for one or more element classes.""" -const t8_scheme_cxx_t = t8_scheme_cxx - -"""We can reuse the reference counter type from libsc.""" -const t8_refcount_t = sc_refcount_t - -struct t8_cmesh_trees - from_proc::Ptr{sc_array_t} - tree_to_proc::Ptr{Cint} - ghost_to_proc::Ptr{Cint} - ghost_globalid_to_local_id::Ptr{sc_hash_t} - global_local_mempool::Ptr{sc_mempool_t} -end - -const t8_cmesh_trees_t = Ptr{t8_cmesh_trees} - -mutable struct t8_shmem_array end - -const t8_shmem_array_t = Ptr{t8_shmem_array} - -mutable struct t8_geometry_handler end - -"""This typedef holds virtual functions for the geometry handler. We need it so that we can use [`t8_geometry_handler_c`](@ref) pointers in .c files without them seeing the actual C++ code (and then not compiling) TODO: Delete this when the cmesh is a proper cpp class.""" -const t8_geometry_handler_c = t8_geometry_handler - -""" - t8_stash - -The stash data structure is used to store information about the cmesh before it is committed. In particular we store the eclasses of the trees, the face-connections and the tree attributes. Using the stash structure allows us to have a very flexible interface. When constructing a new mesh, the user can specify all these mesh entities in arbitrary order. As soon as the cmesh is committed the information is copied from the stash to the cmesh in an order mannered. - -| Field | Note | -| :--------- | :---------------------------------------------------------------------- | -| classes | Stores the eclasses of the trees. # See also [`t8_stash_class`](@ref) | -| joinfaces | Stores the face-connections. # See also [`t8_stash_joinface`](@ref) | -| attributes | Stores the attributes. # See also [`t8_stash_attribute`](@ref) | -""" -struct t8_stash - classes::sc_array_t - joinfaces::sc_array_t - attributes::sc_array_t -end - -const t8_stash_t = Ptr{t8_stash} - -""" - t8_cprofile + t8_load_mode -This struct is used to profile cmesh algorithms. The cmesh struct stores a pointer to a profile struct, and if it is nonzero, various runtimes and data measurements are stored here. +This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data. -| Field | Note | -| :-------------------------------- | :------------------------------------------------------------------------------------------------------------ | -| partition\\_trees\\_shipped | The number of trees this process has sent to other in the last partition call. | -| partition\\_ghosts\\_shipped | The number of ghosts this process has sent to other in the last partition call. | -| partition\\_trees\\_recv | The number of trees this process has received from other in the last partition call. | -| partition\\_ghosts\\_recv | The number of ghosts this process has received from other in the last partition call. | -| partition\\_bytes\\_sent | The total number of bytes sent to other processes in the last partition call. | -| partition\\_procs\\_sent | The number of different processes this process has send local trees or ghosts to in the last partition call. | -| first\\_tree\\_shared | 1 if this processes' first tree is shared. 0 if not. | -| partition\\_runtime | The runtime of the last call to [`t8_cmesh_partition`](@ref). | -| commit\\_runtime | The runtime of the last call to [`t8_cmesh_commit`](@ref). | -| geometry\\_evaluate\\_num\\_calls | The number of calls to [`t8_geometry_evaluate`](@ref). | -| geometry\\_evaluate\\_runtime | The accumulated runtime of calls to [`t8_geometry_evaluate`](@ref). | -# See also -[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) +| Enumerator | Note | +| :----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| T8\\_LOAD\\_FIRST | First mode. | +| T8\\_LOAD\\_SIMPLE | In simple mode, the first n processes load the file | +| T8\\_LOAD\\_BGQ | In BGQ mode, the file is loaded on n nodes and from one process of each node. This needs MPI Version 3.1 or higher. | +| T8\\_LOAD\\_STRIDE | Every n-th process loads a file. Handle with care, we introduce it, since on Juqueen MPI-3 was not available. The parameter n has to be passed as an extra parameter. # See also [`t8_cmesh_load_and_distribute`](@ref) | +| T8\\_LOAD\\_COUNT | Number of modes in which we can open a saved cmesh. | """ -struct t8_cprofile - partition_trees_shipped::t8_locidx_t - partition_ghosts_shipped::t8_locidx_t - partition_trees_recv::t8_locidx_t - partition_ghosts_recv::t8_locidx_t - partition_bytes_sent::Csize_t - partition_procs_sent::Cint - first_tree_shared::Cint - partition_runtime::Cdouble - commit_runtime::Cdouble - geometry_evaluate_num_calls::Cdouble - geometry_evaluate_runtime::Cdouble +@cenum t8_load_mode::UInt32 begin + T8_LOAD_FIRST = 0 + T8_LOAD_SIMPLE = 0 + T8_LOAD_BGQ = 1 + T8_LOAD_STRIDE = 2 + T8_LOAD_COUNT = 3 end -""" -This struct is used to profile cmesh algorithms. The cmesh struct stores a pointer to a profile struct, and if it is nonzero, various runtimes and data measurements are stored here. +"""This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data.""" +const t8_load_mode_t = t8_load_mode -# See also -[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) -""" -const t8_cprofile_t = t8_cprofile - -""" - t8_cmesh - -This structure holds the connectivity data of the coarse mesh. It can either be replicated, then each process stores a copy of the whole mesh, or partitioned. In the latter case, each process only stores a local portion of the mesh plus information about ghost elements. - -The coarse mesh is a collection of coarse trees that can be identified along faces. TODO: this description is outdated. rewrite it. The array ctrees stores these coarse trees sorted by their (global) tree\\_id. If the mesh if partitioned it is partitioned according to an (possible only virtually existing) underlying fine mesh. Therefore the ctrees array can store duplicated trees on different processes, if each of these processes owns elements of the same tree in the fine mesh. - -Each tree stores information about its face-neighbours in an array of t8_ctree_fneighbor. - -If partitioned the ghost trees are stored in a hash table that is backed up by an array. The hash value of a ghost tree is its tree\\_id modulo the number of ghosts on this process. - -| Field | Note | -| :--------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| committed | Flag that specifies whether the cmesh is committed or not. t8_cmesh_commit | -| dimension | The dimension of the cmesh. It is set when the first tree is inserted. | -| set\\_partition | If nonzero the cmesh is partitioned. If zero each process has the whole cmesh. | -| face\\_knowledge | If partitioned the level of face knowledge that is expected. t8_mesh_set_partitioned; see t8_cmesh_set_partition. | -| set\\_partition\\_scheme | If the cmesh is to be partitioned according to a uniform level, the scheme that describes the refinement pattern. See t8_cmesh_set_partition. | -| set\\_partition\\_level | Non-negative if the cmesh should be partitioned from an already existing cmesh with an assumed *level* uniform mesh underneath. | -| set\\_from | If this cmesh shall be derived from an existing cmesh by copy or more elaborate modification, we store a pointer to this other cmesh here. | -| mpirank | Number of this MPI process. | -| mpisize | Number of MPI processes. | -| rc | The reference count of the cmesh. | -| num\\_trees | The global number of trees | -| num\\_local\\_trees | If partitioned the number of trees on this process. Otherwise the global number of trees. | -| num\\_ghosts | If partitioned the number of neighbor trees owned by different processes. | -| num\\_local\\_trees\\_per\\_eclass | After commit the number of local trees for each eclass. Stores the same entries as *num_trees_per_eclass*, if the cmesh is replicated. | -| num\\_trees\\_per\\_eclass | After commit the number of global trees for each eclass. | -| trees | structure that holds all local trees and ghosts | -| first\\_tree | The global index of the first local tree on this process. Zero if the cmesh is not partitioned. -1 if this processor is empty. See also https://github.com/DLR-AMR/t8code/wiki/Tree-indexing | -| first\\_tree\\_shared | If partitioned true if the first tree on this process is also the last tree on the next process. Always zero if num\\_local\\_trees = 0 | -| tree\\_offsets | If partitioned for each process the global index of its first local tree or -(first local tree) - 1 if the first tree on that process is shared. Since this is very memory consuming we only fill it when needed. | -| geometry\\_handler | Handles all geometries that are used by trees in this cmesh. | -| stash | Used as temporary storage for the trees before commit. | -| profile | Used to measure runtimes and statistics of the cmesh algorithms. | -# See also -t8\\_ctree\\_fneighbor -""" -struct t8_cmesh - committed::Cint - dimension::Cint - set_partition::Cint - face_knowledge::Cint - set_partition_scheme::Ptr{t8_scheme_cxx_t} - set_partition_level::Int8 - set_from::Ptr{t8_cmesh} - mpirank::Cint - mpisize::Cint - rc::t8_refcount_t - num_trees::t8_gloidx_t - num_local_trees::t8_locidx_t - num_ghosts::t8_locidx_t - num_local_trees_per_eclass::NTuple{8, t8_locidx_t} - num_trees_per_eclass::NTuple{8, t8_gloidx_t} - trees::t8_cmesh_trees_t - first_tree::t8_gloidx_t - first_tree_shared::Int8 - tree_offsets::t8_shmem_array_t - geometry_handler::Ptr{t8_geometry_handler_c} - stash::t8_stash_t - profile::Ptr{t8_cprofile_t} -end +mutable struct t8_cmesh end +"""Forward pointer reference to hidden cmesh implementation. This reference needs to be known by [`t8_geometry`](@ref), hence we put it before the include.""" const t8_cmesh_t = Ptr{t8_cmesh} -""" - t8_eclass - -This enumeration contains all possible element classes. - -| Enumerator | Note | -| :--------------------- | :----------------------------------------------------------------------------------------------------------------- | -| T8\\_ECLASS\\_VERTEX | The vertex is the only zero-dimensional element class. | -| T8\\_ECLASS\\_LINE | The line is the only one-dimensional element class. | -| T8\\_ECLASS\\_QUAD | The quadrilateral is one of two element classes in two dimensions. | -| T8\\_ECLASS\\_TRIANGLE | The element class for a triangle. | -| T8\\_ECLASS\\_HEX | The hexahedron is one three-dimensional element class. | -| T8\\_ECLASS\\_TET | The tetrahedron is another three-dimensional element class. | -| T8\\_ECLASS\\_PRISM | The prism has five sides: two opposing triangles joined by three quadrilaterals. | -| T8\\_ECLASS\\_PYRAMID | The pyramid has a quadrilateral as base and four triangles as sides. | -| T8\\_ECLASS\\_COUNT | This is no element class but can be used as the number of element classes. | -| T8\\_ECLASS\\_INVALID | This is no element class but can be used for the case a class of a third party library is not supported by t8code | -""" -@cenum t8_eclass::UInt32 begin - T8_ECLASS_ZERO = 0 - T8_ECLASS_VERTEX = 0 - T8_ECLASS_LINE = 1 - T8_ECLASS_QUAD = 2 - T8_ECLASS_TRIANGLE = 3 - T8_ECLASS_HEX = 4 - T8_ECLASS_TET = 5 - T8_ECLASS_PRISM = 6 - T8_ECLASS_PYRAMID = 7 - T8_ECLASS_COUNT = 8 - T8_ECLASS_INVALID = 9 -end - -"""This enumeration contains all possible element classes.""" -const t8_eclass_t = t8_eclass - -""" - t8_ctree - -This structure holds the data of a local tree including the information about face neighbors. For those the tree\\_to\\_face index is computed as follows. Let F be the maximal number of faces of any eclass of the cmesh's dimension, then ttf % F is the face number and ttf / F is the orientation. (t8_eclass_max_num_faces) The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees. We chose a main\\_face from them as follows: Either both trees have the same element class, then the face with the lower face number is the main\\_face or the trees belong to different classes in which case the face belonging to the tree with the lower class according to the ordering triangle < square, hex < tet < prism < pyramid, is the main\\_face. Then face corner 0 of the main\\_face connects to a face corner k in the other face. The face orientation is defined as the number k. If the classes are equal and my\\_face == other\\_face, treating either of both faces as the main\\_face leads to the same result. See https://arxiv.org/pdf/1611.02929.pdf for more details. - -| Field | Note | -| :--------------- | :------------------------------------------------------------------------------------------ | -| treeid | The local number of this tree. | -| eclass | The eclass of this tree. | -| neigh\\_offset | Adding this offset to the address of the tree yields the array of face\\_neighbor entries | -| att\\_offset | Adding this offset to the address of the tree yields the array of attribute\\_info entries | -| num\\_attributes | The number of attributes at this tree | -""" -struct t8_ctree - treeid::t8_locidx_t - eclass::t8_eclass_t - neigh_offset::Csize_t - att_offset::Csize_t - num_attributes::Cint -end +mutable struct t8_ctree end +"""Forward pointer references to hidden implementations of tree.""" const t8_ctree_t = Ptr{t8_ctree} -""" - t8_cghost - -| Field | Note | -| :--------------- | :------------------------------------------------------------------------------------------- | -| treeid | The global number of this ghost. | -| eclass | The eclass of this ghost. | -| att\\_offset | Adding this offset to the address of the ghost yields the array of attribute\\_info entries | -| num\\_attributes | The number of attributes at this ghost | -""" -struct t8_cghost - treeid::t8_gloidx_t - eclass::t8_eclass_t - neigh_offset::Csize_t - att_offset::Csize_t - num_attributes::Cint -end +mutable struct t8_cghost end +"""Forward pointer references to hidden implementations of ghost tree.""" const t8_cghost_t = Ptr{t8_cghost} """ @@ -3557,7 +3284,7 @@ function t8_cmesh_init(pcmesh) @ccall libt8.t8_cmesh_init(pcmesh::Ptr{t8_cmesh_t})::Cvoid end -# no prototype is found for this function at t8_cmesh.h:76:1, please use with caution +# no prototype is found for this function at t8_cmesh.h:79:1, please use with caution """ t8_cmesh_new() @@ -3611,23 +3338,19 @@ function t8_cmesh_is_committed(cmesh) end """ - t8_cmesh_tree_vertices_negative_volume(eclass, vertices, num_vertices) + t8_cmesh_disable_negative_volume_check(cmesh) -Given a set of vertex coordinates for a tree of a given eclass. Query whether the geometric volume of the tree with this coordinates would be negative. +Disable the debug check for negative volumes in trees during t8_cmesh_commit. Does nothing outside of debug mode. # Arguments -* `eclass`:\\[in\\] The eclass of a tree. -* `vertices`:\\[in\\] The coordinates of the tree's vertices. -* `num_vertices`:\\[in\\] The number of vertices. *vertices* must hold 3 * *num_vertices* many doubles. *num_vertices* must match t8_eclass_num_vertices[*eclass*] -# Returns -True if the geometric volume describe by *vertices* is negative. False otherwise. Returns true if a tree of the given eclass with the given vertex coordinates does have negative volume. +* `cmesh`:\\[in,out\\] ### Prototype ```c -int t8_cmesh_tree_vertices_negative_volume (const t8_eclass_t eclass, const double *vertices, const int num_vertices); +void t8_cmesh_disable_negative_volume_check (t8_cmesh_t cmesh); ``` """ -function t8_cmesh_tree_vertices_negative_volume(eclass, vertices, num_vertices) - @ccall libt8.t8_cmesh_tree_vertices_negative_volume(eclass::t8_eclass_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cint +function t8_cmesh_disable_negative_volume_check(cmesh) + @ccall libt8.t8_cmesh_disable_negative_volume_check(cmesh::t8_cmesh_t)::Cvoid end """ @@ -3647,6 +3370,10 @@ function t8_cmesh_set_derive(cmesh, set_from) @ccall libt8.t8_cmesh_set_derive(cmesh::t8_cmesh_t, set_from::t8_cmesh_t)::Cvoid end +mutable struct t8_shmem_array end + +const t8_shmem_array_t = Ptr{t8_shmem_array} + """ t8_cmesh_alloc_offsets(mpisize, comm) @@ -3702,22 +3429,27 @@ function t8_cmesh_set_partition_offsets(cmesh, tree_offsets) @ccall libt8.t8_cmesh_set_partition_offsets(cmesh::t8_cmesh_t, tree_offsets::t8_shmem_array_t)::Cvoid end +mutable struct t8_scheme end + +"""The scheme holds implementations for one or more element classes. Opaque pointer for C interface. Detailed documentation at t8_scheme.""" +const t8_scheme_c = t8_scheme + """ - t8_cmesh_set_partition_uniform(cmesh, element_level, ts) + t8_cmesh_set_partition_uniform(cmesh, element_level, scheme) Declare if a derived cmesh should be partitioned according to a uniform refinement of a given level for the provided scheme. This call is only valid when the cmesh is not yet committed via a call to t8_cmesh_commit and when the cmesh will be derived. # Arguments * `cmesh`:\\[in,out\\] The cmesh to be updated. * `element_level`:\\[in\\] The refinement\\_level. -* `ts`:\\[in\\] The element scheme describing the refinement pattern. We take ownership. This can be prevented by referencing **ts** before calling this function. +* `scheme`:\\[in\\] The element scheme describing the refinement pattern. We take ownership. This can be prevented by referencing **scheme** before calling this function. ### Prototype ```c -void t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, int element_level, t8_scheme_cxx_t *ts); +void t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, const int element_level, const t8_scheme_c *scheme); ``` """ -function t8_cmesh_set_partition_uniform(cmesh, element_level, ts) - @ccall libt8.t8_cmesh_set_partition_uniform(cmesh::t8_cmesh_t, element_level::Cint, ts::Ptr{t8_scheme_cxx_t})::Cvoid +function t8_cmesh_set_partition_uniform(cmesh, element_level, scheme) + @ccall libt8.t8_cmesh_set_partition_uniform(cmesh::t8_cmesh_t, element_level::Cint, scheme::Ptr{t8_scheme_c})::Cvoid end """ @@ -3727,11 +3459,11 @@ Refine the cmesh to a given level. Thus split each tree into x^level subtrees TO ### Prototype ```c -void t8_cmesh_set_refine (t8_cmesh_t cmesh, int level, t8_scheme_cxx_t *scheme); +void t8_cmesh_set_refine (t8_cmesh_t cmesh, const int level, const t8_scheme_c *scheme); ``` """ function t8_cmesh_set_refine(cmesh, level, scheme) - @ccall libt8.t8_cmesh_set_refine(cmesh::t8_cmesh_t, level::Cint, scheme::Ptr{t8_scheme_cxx_t})::Cvoid + @ccall libt8.t8_cmesh_set_refine(cmesh::t8_cmesh_t, level::Cint, scheme::Ptr{t8_scheme_c})::Cvoid end """ @@ -3752,13 +3484,49 @@ function t8_cmesh_set_dimension(cmesh, dim) end """ - t8_cmesh_set_tree_class(cmesh, gtree_id, tree_class) + t8_eclass -Set the class of a tree in the cmesh. It is not allowed to call this function after t8_cmesh_commit. It is not allowed to call this function multiple times for the same tree. +This enumeration contains all possible element classes. + +| Enumerator | Note | +| :--------------------- | :----------------------------------------------------------------------------------------------------------------- | +| T8\\_ECLASS\\_ZERO | Zero-dimensional element class. | +| T8\\_ECLASS\\_VERTEX | The vertex is the only zero-dimensional element class. | +| T8\\_ECLASS\\_LINE | The line is the only one-dimensional element class. | +| T8\\_ECLASS\\_QUAD | The quadrilateral is one of two element classes in two dimensions. | +| T8\\_ECLASS\\_TRIANGLE | The element class for a triangle. | +| T8\\_ECLASS\\_HEX | The hexahedron is one three-dimensional element class. | +| T8\\_ECLASS\\_TET | The tetrahedron is another three-dimensional element class. | +| T8\\_ECLASS\\_PRISM | The prism has five sides: two opposing triangles joined by three quadrilaterals. | +| T8\\_ECLASS\\_PYRAMID | The pyramid has a quadrilateral as base and four triangles as sides. | +| T8\\_ECLASS\\_COUNT | This is no element class but can be used as the number of element classes. | +| T8\\_ECLASS\\_INVALID | This is no element class but can be used for the case a class of a third party library is not supported by t8code | +""" +@cenum t8_eclass::UInt32 begin + T8_ECLASS_ZERO = 0 + T8_ECLASS_VERTEX = 0 + T8_ECLASS_LINE = 1 + T8_ECLASS_QUAD = 2 + T8_ECLASS_TRIANGLE = 3 + T8_ECLASS_HEX = 4 + T8_ECLASS_TET = 5 + T8_ECLASS_PRISM = 6 + T8_ECLASS_PYRAMID = 7 + T8_ECLASS_COUNT = 8 + T8_ECLASS_INVALID = 9 +end + +"""This enumeration contains all possible element classes.""" +const t8_eclass_t = t8_eclass + +""" + t8_cmesh_set_tree_class(cmesh, gtree_id, tree_class) + +Set the class of a tree in the cmesh. It is not allowed to call this function after t8_cmesh_commit. It is not allowed to call this function multiple times for the same tree. # Arguments * `cmesh`:\\[in,out\\] The cmesh to be updated. -* `tree_id`:\\[in\\] The global number of the tree. +* `gtree_id`:\\[in\\] The global number of the tree. * `tree_class`:\\[in\\] The element class of this tree. ### Prototype ```c @@ -3871,13 +3639,17 @@ end Insert a face-connection between two trees in a cmesh. +!!! note + + The orientation is defined as: Let my\\_face and other\\_face be the two face numbers of the connecting trees. We chose a main\\_face from them as follows: Either both trees have the same element class, then the face with the lower face number is the main\\_face or the trees belong to different classes in which case the face belonging to the tree with the lower class according to the ordering triangle < quad, hex < tet < prism < pyramid, is the main\\_face. Then face corner 0 of the main\\_face connects to a face corner k in the other face. The face orientation is defined as the number k. If the classes are equal and my\\_face == other\\_face, treating either of both faces as the main\\_face leads to the same result. See https://arxiv.org/pdf/1611.02929.pdf for more details. + # Arguments * `cmesh`:\\[in,out\\] The cmesh to be updated. -* `tree1`:\\[in\\] The tree id of the first of the two trees. -* `tree2`:\\[in\\] The tree id of the second of the two trees. +* `gtree1`:\\[in\\] The tree id of the first of the two trees. +* `gtree2`:\\[in\\] The tree id of the second of the two trees. * `face1`:\\[in\\] The face number of the first tree. * `face2`:\\[in\\] The face number of the second tree. -* `orientation`:\\[in\\] Specify how face1 and face2 are oriented to each other TODO: orientation needs to be carefully defined for all element classes. TODO: document orientation +* `orientation`:\\[in\\] Specify how face1 and face2 are oriented to each other ### Prototype ```c void t8_cmesh_set_join (t8_cmesh_t cmesh, t8_gloidx_t gtree1, t8_gloidx_t gtree2, int face1, int face2, int orientation); @@ -4019,6 +3791,19 @@ end """ t8_cmesh_save(cmesh, fileprefix) +Save the cmesh to a file with the given fileprefix. + +!!! note + + IMPORTANT: Currently, this functionality is deactivated, because it is outdated. Calling it will thus result in an error. + +!!! note + + So far, it was only legal to save cmeshes that use the linear geometry. + +# Arguments +* `cmesh`:\\[in\\] The cmesh to save. +* `fileprefix`:\\[in\\] The prefix of the file to save the cmesh to. ### Prototype ```c int t8_cmesh_save (t8_cmesh_t cmesh, const char *fileprefix); @@ -4040,29 +3825,6 @@ function t8_cmesh_load(filename, comm) @ccall libt8.t8_cmesh_load(filename::Cstring, comm::MPI_Comm)::t8_cmesh_t end -""" - t8_load_mode - -This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data. - -| Enumerator | Note | -| :----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| T8\\_LOAD\\_SIMPLE | In simple mode, the first n processes load the file | -| T8\\_LOAD\\_BGQ | In BGQ mode, the file is loaded on n nodes and from one process of each node. This needs MPI Version 3.1 or higher. | -| T8\\_LOAD\\_STRIDE | Every n-th process loads a file. Handle with care, we introduce it, since on Juqueen MPI-3 was not available. The parameter n has to be passed as an extra parameter. # See also [`t8_cmesh_load_and_distribute`](@ref) | -| T8\\_LOAD\\_COUNT | | -""" -@cenum t8_load_mode::UInt32 begin - T8_LOAD_FIRST = 0 - T8_LOAD_SIMPLE = 0 - T8_LOAD_BGQ = 1 - T8_LOAD_STRIDE = 2 - T8_LOAD_COUNT = 3 -end - -"""This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data.""" -const t8_load_mode_t = t8_load_mode - """ t8_cmesh_load_and_distribute(fileprefix, num_files, comm, mode, procs_per_node) @@ -4332,7 +4094,7 @@ Return the eclass of a given local tree. TODO: Should we refer to indices or con # Arguments * `cmesh`:\\[in\\] The cmesh to be considered. -* `tree_id`:\\[in\\] The local id of the tree whose eclass will be returned. +* `ltree_id`:\\[in\\] The local id of the tree whose eclass will be returned. # Returns The eclass of the given tree. TODO: Call tree ids ltree\\_id or gtree\\_id etc. instead of tree\\_id. *cmesh* must be committed before calling this function. ### Prototype @@ -4371,7 +4133,7 @@ Return the eclass of a given local ghost. TODO: Should we refer to indices or co # Arguments * `cmesh`:\\[in\\] The cmesh to be considered. -* `ghost_id`:\\[in\\] The local id of the ghost whose eclass will be returned. 0 <= *tree_id* < cmesh.num\\_ghosts. +* `lghost_id`:\\[in\\] The local id of the ghost whose eclass will be returned. 0 <= *tree_id* < cmesh.num\\_ghosts. # Returns The eclass of the given ghost. *cmesh* must be committed before calling this function. ### Prototype @@ -4456,6 +4218,26 @@ function t8_cmesh_get_face_neighbor(cmesh, ltreeid, face, dual_face, orientation @ccall libt8.t8_cmesh_get_face_neighbor(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t, face::Cint, dual_face::Ptr{Cint}, orientation::Ptr{Cint})::t8_locidx_t end +""" + t8_cmesh_get_tree_face_neighbor_eclass(cmesh, ltreeid, face) + +Given a local tree id (of a local tree or ghost tree) and a face compute the eclass of the tree's face neighbor. + +# Arguments +* `cmesh`:\\[in\\] The cmesh to be considered. +* `ltreeid`:\\[in\\] The local id of a tree or a ghost. +* `face`:\\[in\\] A face number of the tree/ghost. +# Returns +The eclass of a neighbor tree of *ltreeid* across *face*. T8\\_ECLASS\\_INVALID if no neighbor exists. +### Prototype +```c +t8_eclass_t t8_cmesh_get_tree_face_neighbor_eclass (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid, const int face); +``` +""" +function t8_cmesh_get_tree_face_neighbor_eclass(cmesh, ltreeid, face) + @ccall libt8.t8_cmesh_get_tree_face_neighbor_eclass(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t, face::Cint)::t8_eclass_t +end + """ t8_cmesh_print_profile(cmesh) @@ -4509,7 +4291,7 @@ Return the attribute pointer of a tree. * `cmesh`:\\[in\\] The cmesh. * `package_id`:\\[in\\] The identifier of a valid software package. * `key`:\\[in\\] A key used to identify the attribute under all attributes of this tree with the same *package_id*. -* `tree_id`:\\[in\\] The local number of the tree. +* `ltree_id`:\\[in\\] The local number of the tree. # Returns The attribute pointer of the tree *ltree_id* or NULL if the attribute is not found. # See also @@ -4542,7 +4324,7 @@ Return the attribute pointer of a tree for a gloidx\\_t array. * `package_id`:\\[in\\] The identifier of a valid software package. * `key`:\\[in\\] A key used to identify the attribute under all attributes of this tree with the same *package_id*. * `ltree_id`:\\[in\\] The local number of the tree. -* `data_count`:\\[in\\] The number of entries in the array that are requested. This must be smaller or equal to the *data_count* parameter of the corresponding call to t8_cmesh_set_attribute_gloidx_array +* `data_count`:\\[in\\] The number of entries in the array that are requested. This must be smaller or equal to the *data_count* parameter of the corresponding call to t8_cmesh_set_attribute_gloidx_array # Returns The attribute pointer of the tree *ltree_id* or NULL if the attribute is not found. # See also @@ -4576,26 +4358,38 @@ function t8_cmesh_get_partition_table(cmesh) end """ - t8_cmesh_uniform_bounds(cmesh, level, ts, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) + t8_cmesh_uniform_bounds_equal_element_count(cmesh, level, tree_scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) Calculate the section of a uniform forest for the current rank. # Arguments * `cmesh`:\\[in\\] The cmesh to be considered. * `level`:\\[in\\] The uniform refinement level to be created. -* `ts`:\\[in\\] The element scheme for which to compute the bounds. +* `tree_scheme`:\\[in\\] The element scheme for which to compute the bounds. * `first_local_tree`:\\[out\\] The first tree that contains elements belonging to the calling processor. -* `child_in_tree_begin`:\\[out\\] The global index of the first element belonging to the calling processor. Not computed if NULL. +* `child_in_tree_begin`:\\[out\\] The tree-local index of the first element belonging to the calling processor. Not computed if NULL. * `last_local_tree`:\\[out\\] The last tree that contains elements belonging to the calling processor. -* `child_in_tree_end`:\\[out\\] The global index of the first element that does not belonging to the calling processor anymore. Not computed if NULL. -* `first_tree_shared`:\\[out\\] If not NULL, 1 or 0 is stored here depending on whether *first_local_tree* is the same as *last_local_tree* on the next process. *cmesh* must be committed before calling this function. * +* `child_in_tree_end`:\\[out\\] The tree-local index of the first element that does not belonging to the calling processor anymore. Not computed if NULL. +* `first_tree_shared`:\\[out\\] If not NULL, 1 or 0 is stored here depending on whether *first_local_tree* is the same as *last_local_tree* on the previous process. *cmesh* must be committed before calling this function. +### Prototype +```c +void t8_cmesh_uniform_bounds_equal_element_count (t8_cmesh_t cmesh, const int level, const t8_scheme_c *tree_scheme, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared); +``` +""" +function t8_cmesh_uniform_bounds_equal_element_count(cmesh, level, tree_scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) + @ccall libt8.t8_cmesh_uniform_bounds_equal_element_count(cmesh::t8_cmesh_t, level::Cint, tree_scheme::Ptr{t8_scheme_c}, first_local_tree::Ptr{t8_gloidx_t}, child_in_tree_begin::Ptr{t8_gloidx_t}, last_local_tree::Ptr{t8_gloidx_t}, child_in_tree_end::Ptr{t8_gloidx_t}, first_tree_shared::Ptr{Int8})::Cvoid +end + +""" + t8_cmesh_uniform_bounds_for_irregular_refinement(cmesh, level, scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared, comm) + ### Prototype ```c -void t8_cmesh_uniform_bounds (t8_cmesh_t cmesh, int level, const t8_scheme_cxx_t *ts, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared); +void t8_cmesh_uniform_bounds_for_irregular_refinement (const t8_cmesh_t cmesh, const int level, const t8_scheme_c *scheme, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared, sc_MPI_Comm comm); ``` """ -function t8_cmesh_uniform_bounds(cmesh, level, ts, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) - @ccall libt8.t8_cmesh_uniform_bounds(cmesh::t8_cmesh_t, level::Cint, ts::Ptr{t8_scheme_cxx_t}, first_local_tree::Ptr{t8_gloidx_t}, child_in_tree_begin::Ptr{t8_gloidx_t}, last_local_tree::Ptr{t8_gloidx_t}, child_in_tree_end::Ptr{t8_gloidx_t}, first_tree_shared::Ptr{Int8})::Cvoid +function t8_cmesh_uniform_bounds_for_irregular_refinement(cmesh, level, scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared, comm) + @ccall libt8.t8_cmesh_uniform_bounds_for_irregular_refinement(cmesh::t8_cmesh_t, level::Cint, scheme::Ptr{t8_scheme_c}, first_local_tree::Ptr{t8_gloidx_t}, child_in_tree_begin::Ptr{t8_gloidx_t}, last_local_tree::Ptr{t8_gloidx_t}, child_in_tree_end::Ptr{t8_gloidx_t}, first_tree_shared::Ptr{Int8}, comm::MPI_Comm)::Cvoid end """ @@ -4637,7 +4431,6 @@ Verify that a coarse mesh has only one reference left and destroy it. This funct # Arguments * `pcmesh`:\\[in,out\\] This cmesh must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_cmesh_unref. -* `comm`:\\[in\\] A mpi communicator that is valid with *cmesh*. ### Prototype ```c void t8_cmesh_destroy (t8_cmesh_t *pcmesh); @@ -4647,18 +4440,6 @@ function t8_cmesh_destroy(pcmesh) @ccall libt8.t8_cmesh_destroy(pcmesh::Ptr{t8_cmesh_t})::Cvoid end -""" - t8_cmesh_new_testhybrid(comm) - -### Prototype -```c -t8_cmesh_t t8_cmesh_new_testhybrid (sc_MPI_Comm comm); -``` -""" -function t8_cmesh_new_testhybrid(comm) - @ccall libt8.t8_cmesh_new_testhybrid(comm::MPI_Comm)::t8_cmesh_t -end - """ t8_cmesh_coords_axb(coords_in, coords_out, num_vertices, alpha, b) @@ -4682,7 +4463,7 @@ end """ t8_cmesh_translate_coordinates(coords_in, coords_out, num_vertices, translate) -Compute y = x + translate on an array of doubles, interpreting each 3 as one vector x +Compute y = x + translate on an array of doubles, interpreting each 3 as one vector x # Arguments * `coords_in`:\\[in\\] The incoming coordinates of the vectors @@ -4725,13000 +4506,11637 @@ function t8_cmesh_debug_print_trees(cmesh, comm) end """ - t8_netcdf_variable_type + t8_cmesh_get_local_bounding_box(cmesh, bounds) -This enumeration contains all possible netCDF variable datatypes (int, int64, double). +Compute the process local bounding box of the cmesh. The bounding box is stored in the array *bounds* in the following order: bounds[0] = x\\_min bounds[1] = x\\_max bounds[2] = y\\_min bounds[3] = y\\_max bounds[4] = z\\_min bounds[5] = z\\_max -| Enumerator | Note | -| :------------------- | :------------------------------------------------------------------- | -| T8\\_NETCDF\\_INT | Symbolizes netCDF variable datatype which holds 32-bit integer data | -| T8\\_NETCDF\\_INT64 | Symbolizes netCDF variable datatype which holds 64-bit integer data | -| T8\\_NETCDF\\_DOUBLE | Symbolizes netCDF variable datatype which holds double data | +# Arguments +* `cmesh`:\\[in\\] The cmesh to be considered. +* `bounds`:\\[out\\] The bounding box of the cmesh. If the box is flat (for quads for example, z\\_min == z\\_max) +# Returns +True if the computation was successful, false if the cmesh is empty. +### Prototype +```c +int t8_cmesh_get_local_bounding_box (const t8_cmesh_t cmesh, double bounds[6]); +``` """ -@cenum t8_netcdf_variable_type::UInt32 begin - T8_NETCDF_INT = 0 - T8_NETCDF_INT64 = 1 - T8_NETCDF_DOUBLE = 2 -end - -"""This enumeration contains all possible netCDF variable datatypes (int, int64, double).""" -const t8_netcdf_variable_type_t = t8_netcdf_variable_type - -struct t8_netcdf_variable_t - variable_name::Cstring - variable_long_name::Cstring - variable_units::Cstring - datatype::t8_netcdf_variable_type_t - var_user_dimid::Cint - var_user_data::Ptr{sc_array_t} +function t8_cmesh_get_local_bounding_box(cmesh, bounds) + @ccall libt8.t8_cmesh_get_local_bounding_box(cmesh::t8_cmesh_t, bounds::Ptr{Cdouble})::Cint end """ - t8_cmesh_write_netcdf(cmesh, file_prefix, file_title, dim, num_extern_netcdf_vars, variables, comm) + sc_io_read(mpifile, ptr, zcount, t, errmsg) ### Prototype ```c -void t8_cmesh_write_netcdf (t8_cmesh_t cmesh, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, t8_netcdf_variable_t *variables[], sc_MPI_Comm comm); +void sc_io_read (sc_MPI_File mpifile, void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); ``` """ -function t8_cmesh_write_netcdf(cmesh, file_prefix, file_title, dim, num_extern_netcdf_vars, variables, comm) - @ccall libt8.t8_cmesh_write_netcdf(cmesh::t8_cmesh_t, file_prefix::Cstring, file_title::Cstring, dim::Cint, num_extern_netcdf_vars::Cint, variables::Ptr{Ptr{t8_netcdf_variable_t}}, comm::MPI_Comm)::Cvoid -end - -struct t8_msh_file_node_t - index::t8_locidx_t - coordinates::NTuple{3, Cdouble} -end - -struct t8_msh_file_node_parametric_t - index::t8_locidx_t - coordinates::NTuple{3, Cdouble} - parameters::NTuple{2, Cdouble} - parametric::Cint - entity_dim::Cint - entity_tag::t8_locidx_t +function sc_io_read(mpifile, ptr, zcount, t, errmsg) + @ccall libsc.sc_io_read(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid end """ - t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) + sc_io_write(mpifile, ptr, zcount, t, errmsg) ### Prototype ```c -t8_cmesh_t t8_cmesh_from_msh_file (const char *fileprefix, int partition, sc_MPI_Comm comm, int dim, int master, int use_cad_geometry); +void sc_io_write (sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); ``` """ -function t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) - @ccall libt8.t8_cmesh_from_msh_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, dim::Cint, master::Cint, use_cad_geometry::Cint)::t8_cmesh_t +function sc_io_write(mpifile, ptr, zcount, t, errmsg) + @ccall libsc.sc_io_write(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid end -mutable struct sc_keyvalue end +"""Typedef for quadrant coordinates.""" +const p4est_qcoord_t = Int32 -"""The key-value container is an opaque structure.""" -const sc_keyvalue_t = sc_keyvalue +"""Typedef for counting topological entities (trees, tree vertices).""" +const p4est_topidx_t = Int32 -struct sc_stats - mpicomm::MPI_Comm - kv::Ptr{sc_keyvalue_t} - sarray::Ptr{sc_array_t} -end +"""Typedef for processor-local indexing of quadrants and nodes.""" +const p4est_locidx_t = Int32 -"""The statistics container allows dynamically adding random variables.""" -const sc_statistics_t = sc_stats +"""Typedef for globally unique indexing of quadrants.""" +const p4est_gloidx_t = Int64 """ - sc_statistics_has(stats, name) + sc_io_error_t -Returns true if the stats include a variable with the given name +Error values for io. -### Prototype -```c -int sc_statistics_has (sc_statistics_t * stats, const char *name); -``` +| Enumerator | Note | +| :---------------------- | :--------------------------------------------------------------------------- | +| SC\\_IO\\_ERROR\\_NONE | The value of zero means no error. | +| SC\\_IO\\_ERROR\\_FATAL | The io object is now dysfunctional. | +| SC\\_IO\\_ERROR\\_AGAIN | Another io operation may resolve it. The function just returned was a noop. | """ -function sc_statistics_has(stats, name) - @ccall libsc.sc_statistics_has(stats::Ptr{sc_statistics_t}, name::Cstring)::Cint +@cenum sc_io_error_t::Int32 begin + SC_IO_ERROR_NONE = 0 + SC_IO_ERROR_FATAL = -1 + SC_IO_ERROR_AGAIN = -2 end """ - sc_statistics_add_empty(stats, name) + sc_io_mode_t -Register a statistics variable by name and set its count to 0. This variable must not exist already. +The I/O mode for writing using sc_io_sink. -### Prototype -```c -void sc_statistics_add_empty (sc_statistics_t * stats, const char *name); -``` +| Enumerator | Note | +| :---------------------- | :--------------------------- | +| SC\\_IO\\_MODE\\_WRITE | Semantics as "w" in fopen. | +| SC\\_IO\\_MODE\\_APPEND | Semantics as "a" in fopen. | +| SC\\_IO\\_MODE\\_LAST | Invalid entry to close list | """ -function sc_statistics_add_empty(stats, name) - @ccall libsc.sc_statistics_add_empty(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid -end - -struct sc_flopinfo - seconds::Cdouble - cwtime::Cdouble - crtime::Cfloat - cptime::Cfloat - cflpops::Clonglong - iwtime::Cdouble - irtime::Cfloat - iptime::Cfloat - iflpops::Clonglong - mflops::Cfloat - use_papi::Cint +@cenum sc_io_mode_t::UInt32 begin + SC_IO_MODE_WRITE = 0 + SC_IO_MODE_APPEND = 1 + SC_IO_MODE_LAST = 2 end -const sc_flopinfo_t = sc_flopinfo - """ - sc_flops_snap(fi, snapshot) + sc_io_encode_t -Call [`sc_flops_count`](@ref) (fi) and copies fi into snapshot. +Enum to specify encoding for sc_io_sink and sc_io_source. -# Arguments -* `fi`:\\[in,out\\] Members will be updated. -* `snapshot`:\\[out\\] On output is a copy of fi. -### Prototype -```c -void sc_flops_snap (sc_flopinfo_t * fi, sc_flopinfo_t * snapshot); -``` +| Enumerator | Note | +| :---------------------- | :--------------------------- | +| SC\\_IO\\_ENCODE\\_NONE | No encoding | +| SC\\_IO\\_ENCODE\\_LAST | Invalid entry to close list | """ -function sc_flops_snap(fi, snapshot) - @ccall libsc.sc_flops_snap(fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t})::Cvoid +@cenum sc_io_encode_t::UInt32 begin + SC_IO_ENCODE_NONE = 0 + SC_IO_ENCODE_LAST = 1 end """ - sc_flops_shot(fi, snapshot) + sc_io_type_t -Call [`sc_flops_count`](@ref) (fi) and override snapshot interval timings with the differences since the previous call to [`sc_flops_snap`](@ref). The interval mflop rate is computed by iflpops / 1e6 / irtime. The cumulative timings in snapshot are copied form fi. +The type of I/O operation sc_io_sink and sc_io_source. -# Arguments -* `fi`:\\[in,out\\] Members will be updated. -* `snapshot`:\\[in,out\\] Interval timings measured since [`sc_flops_snap`](@ref). -### Prototype -```c -void sc_flops_shot (sc_flopinfo_t * fi, sc_flopinfo_t * snapshot); -``` +| Enumerator | Note | +| :------------------------ | :------------------------------- | +| SC\\_IO\\_TYPE\\_BUFFER | Write to a buffer | +| SC\\_IO\\_TYPE\\_FILENAME | Write to a file to be opened | +| SC\\_IO\\_TYPE\\_FILEFILE | Write to an already opened file | +| SC\\_IO\\_TYPE\\_LAST | Invalid entry to close list | """ -function sc_flops_shot(fi, snapshot) - @ccall libsc.sc_flops_shot(fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t})::Cvoid +@cenum sc_io_type_t::UInt32 begin + SC_IO_TYPE_BUFFER = 0 + SC_IO_TYPE_FILENAME = 1 + SC_IO_TYPE_FILEFILE = 2 + SC_IO_TYPE_LAST = 3 end """ - sc_statistics_accumulate(stats, name, value) + sc_io_sink -Add an instance of a statistics variable, see [`sc_stats_accumulate`](@ref) The variable must previously be added with [`sc_statistics_add_empty`](@ref). +A generic data sink. -### Prototype -```c -void sc_statistics_accumulate (sc_statistics_t * stats, const char *name, double value); -``` +| Field | Note | +| :------------- | :---------------------------------------------------- | +| iotype | type of the I/O operation | +| mode | write semantics | +| encode | encoding of data | +| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | +| buffer\\_bytes | distinguish from array elements | +| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | +| bytes\\_in | input bytes count | +| bytes\\_out | written bytes count | +| is\\_eof | Have we reached the end of file? | """ -function sc_statistics_accumulate(stats, name, value) - @ccall libsc.sc_statistics_accumulate(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid +struct sc_io_sink + iotype::sc_io_type_t + mode::sc_io_mode_t + encode::sc_io_encode_t + buffer::Ptr{sc_array_t} + buffer_bytes::Csize_t + file::Ptr{Libc.FILE} + bytes_in::Csize_t + bytes_out::Csize_t + is_eof::Cint end -""" - sc_flops_papi(rtime, ptime, flpops, mflops) - -Calls PAPI\\_flops. Aborts on PAPI error. The first call sets up the performance counters. Subsequent calls return cumulative real and process times, cumulative floating point operations and the flop rate since the last call. This is a compatibility wrapper: users should only need to use the [`sc_flopinfo_t`](@ref) interface functions below. +"""A generic data sink.""" +const sc_io_sink_t = sc_io_sink -### Prototype -```c -void sc_flops_papi (float *rtime, float *ptime, long long *flpops, float *mflops); -``` """ -function sc_flops_papi(rtime, ptime, flpops, mflops) - @ccall libsc.sc_flops_papi(rtime::Ptr{Cfloat}, ptime::Ptr{Cfloat}, flpops::Ptr{Clonglong}, mflops::Ptr{Cfloat})::Cvoid -end + sc_io_source -""" - sc_flops_start(fi) +A generic data source. -Prepare [`sc_flopinfo_t`](@ref) structure and start flop counters. Must only be called once during the program run. This function calls [`sc_flops_papi`](@ref). +| Field | Note | +| :-------------- | :---------------------------------------------------- | +| iotype | type of the I/O operation | +| encode | encoding of data | +| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | +| buffer\\_bytes | distinguish from array elements | +| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | +| bytes\\_in | input bytes count | +| bytes\\_out | read bytes count | +| is\\_eof | Have we reached the end of file? | +| mirror | if activated, a sink to store the data | +| mirror\\_buffer | if activated, the buffer for the mirror | +""" +struct sc_io_source + iotype::sc_io_type_t + encode::sc_io_encode_t + buffer::Ptr{sc_array_t} + buffer_bytes::Csize_t + file::Ptr{Libc.FILE} + bytes_in::Csize_t + bytes_out::Csize_t + is_eof::Cint + mirror::Ptr{sc_io_sink_t} + mirror_buffer::Ptr{sc_array_t} +end + +"""A generic data source.""" +const sc_io_source_t = sc_io_source + +""" + sc_io_open_mode_t + +Open modes for sc_io_open + +| Enumerator | Note | +| :----------------------- | :------------------------------------------------------------------------------------------------------------------ | +| SC\\_IO\\_READ | open a file in read-only mode | +| SC\\_IO\\_WRITE\\_CREATE | open a file in write-only mode; if the file exists, the file will be truncated to length zero and then overwritten | +| SC\\_IO\\_WRITE\\_APPEND | append to an already existing file | +""" +@cenum sc_io_open_mode_t::UInt32 begin + SC_IO_READ = 0 + SC_IO_WRITE_CREATE = 1 + SC_IO_WRITE_APPEND = 2 +end + +# automatic type deduction for variadic arguments may not be what you want, please use with caution +@generated function sc_io_sink_new(iotype, iomode, ioencode, va_list...) + :(@ccall(libsc.sc_io_sink_new(iotype::Cint, iomode::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_sink_t})) + end + +""" + sc_io_sink_destroy(sink) + +Free data sink. Calls [`sc_io_sink_complete`](@ref) and discards the final counts. Errors from complete lead to SC\\_IO\\_ERROR\\_FATAL returned from this function. Call [`sc_io_sink_complete`](@ref) yourself if bytes\\_out is of interest. # Arguments -* `fi`:\\[out\\] Members will be initialized. +* `sink`:\\[in,out\\] The sink object to complete and free. +# Returns +0 on success, nonzero on error. ### Prototype ```c -void sc_flops_start (sc_flopinfo_t * fi); +int sc_io_sink_destroy (sc_io_sink_t * sink); ``` """ -function sc_flops_start(fi) - @ccall libsc.sc_flops_start(fi::Ptr{sc_flopinfo_t})::Cvoid +function sc_io_sink_destroy(sink) + @ccall libsc.sc_io_sink_destroy(sink::Ptr{sc_io_sink_t})::Cint end """ - sc_flops_start_nopapi(fi) + sc_io_sink_destroy_null(sink) -Prepare [`sc_flopinfo_t`](@ref) structure and ignore the flop counters. This [`sc_flopinfo_t`](@ref) does not call PAPI\\_flops() in this function or in [`sc_flops_count`](@ref)(). +Free data sink and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_sink_destroy. # Arguments -* `fi`:\\[out\\] Members will be initialized. +* `sink`:\\[in,out\\] Non-NULL pointer to sink pointer. The sink pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_sink, which is passed to sc_io_sink_destroy, and the sink pointer is set to NULL afterwards. +# Returns +0 on success, nonzero on error. ### Prototype ```c -void sc_flops_start_nopapi (sc_flopinfo_t * fi); +int sc_io_sink_destroy_null (sc_io_sink_t ** sink); ``` """ -function sc_flops_start_nopapi(fi) - @ccall libsc.sc_flops_start_nopapi(fi::Ptr{sc_flopinfo_t})::Cvoid +function sc_io_sink_destroy_null(sink) + @ccall libsc.sc_io_sink_destroy_null(sink::Ptr{Ptr{sc_io_sink_t}})::Cint end """ - sc_flops_count(fi) + sc_io_sink_write(sink, data, bytes_avail) -Update [`sc_flopinfo_t`](@ref) structure with current measurement. Must only be called after [`sc_flops_start`](@ref). Can be called any number of times. This function calls [`sc_flops_papi`](@ref). +Write data to a sink. Data may be buffered and sunk in a later call. The internal counters sink->bytes\\_in and sink->bytes\\_out are updated. # Arguments -* `fi`:\\[in,out\\] Members will be updated. +* `sink`:\\[in,out\\] The sink object to write to. +* `data`:\\[in\\] Data passed into sink must be non-NULL. +* `bytes_avail`:\\[in\\] Number of data bytes passed in. +# Returns +0 on success, nonzero on error. ### Prototype ```c -void sc_flops_count (sc_flopinfo_t * fi); +int sc_io_sink_write (sc_io_sink_t * sink, const void *data, size_t bytes_avail); ``` """ -function sc_flops_count(fi) - @ccall libsc.sc_flops_count(fi::Ptr{sc_flopinfo_t})::Cvoid +function sc_io_sink_write(sink, data, bytes_avail) + @ccall libsc.sc_io_sink_write(sink::Ptr{sc_io_sink_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t)::Cint end -# automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_flops_shotv(fi, va_list...) - :(@ccall(libsc.sc_flops_shotv(fi::Ptr{sc_flopinfo_t}; $(to_c_type_pairs(va_list)...))::Cvoid)) - end - """ - sc_keyvalue_entry_type_t + sc_io_sink_complete(sink, bytes_in, bytes_out) -The values can have different types. +Flush all buffered output data to sink. This function may return SC\\_IO\\_ERROR\\_AGAIN if another write is required. Currently this may happen if BUFFER requires an integer multiple of bytes. If successful, the updated value of bytes read and written is returned in bytes\\_in/out, and the sink status is reset as if the sink had just been created. In particular, the bytes counters are reset to zero. The internal state of the sink is not changed otherwise. It is legal to continue writing to the sink hereafter. The sink actions taken depend on its type. BUFFER, FILEFILE: none. FILENAME: call fclose on sink->file. -| Enumerator | Note | -| :------------------------------ | :------------------------------------------ | -| SC\\_KEYVALUE\\_ENTRY\\_NONE | Designate an invalid situation. | -| SC\\_KEYVALUE\\_ENTRY\\_INT | Used for values of type int. | -| SC\\_KEYVALUE\\_ENTRY\\_DOUBLE | Used for values of type double. | -| SC\\_KEYVALUE\\_ENTRY\\_STRING | Used for values of type const char *. | -| SC\\_KEYVALUE\\_ENTRY\\_POINTER | Used for values of anonymous pointer type. | +# Arguments +* `sink`:\\[in,out\\] The sink object to write to. +* `bytes_in`:\\[in,out\\] Bytes received since the last new or complete call. May be NULL. +* `bytes_out`:\\[in,out\\] Bytes written since the last new or complete call. May be NULL. +# Returns +0 if completed, nonzero on error. +### Prototype +```c +int sc_io_sink_complete (sc_io_sink_t * sink, size_t *bytes_in, size_t *bytes_out); +``` """ -@cenum sc_keyvalue_entry_type_t::UInt32 begin - SC_KEYVALUE_ENTRY_NONE = 0 - SC_KEYVALUE_ENTRY_INT = 1 - SC_KEYVALUE_ENTRY_DOUBLE = 2 - SC_KEYVALUE_ENTRY_STRING = 3 - SC_KEYVALUE_ENTRY_POINTER = 4 +function sc_io_sink_complete(sink, bytes_in, bytes_out) + @ccall libsc.sc_io_sink_complete(sink::Ptr{sc_io_sink_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint end -# no prototype is found for this function at sc_keyvalue.h:54:21, please use with caution """ - sc_keyvalue_new() + sc_io_sink_align(sink, bytes_align) -Create a new key-value container. +Align sink to a byte boundary by writing zeros. +# Arguments +* `sink`:\\[in,out\\] The sink object to align. +* `bytes_align`:\\[in\\] Byte boundary. # Returns -The container is ready to use. +0 on success, nonzero on error. ### Prototype ```c -sc_keyvalue_t *sc_keyvalue_new (); +int sc_io_sink_align (sc_io_sink_t * sink, size_t bytes_align); ``` """ -function sc_keyvalue_new() - @ccall libsc.sc_keyvalue_new()::Ptr{sc_keyvalue_t} +function sc_io_sink_align(sink, bytes_align) + @ccall libsc.sc_io_sink_align(sink::Ptr{sc_io_sink_t}, bytes_align::Csize_t)::Cint end # automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_keyvalue_newf(dummy, va_list...) - :(@ccall(libsc.sc_keyvalue_newf(dummy::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_keyvalue_t})) +@generated function sc_io_source_new(iotype, ioencode, va_list...) + :(@ccall(libsc.sc_io_source_new(iotype::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_source_t})) end """ - sc_keyvalue_destroy(kv) + sc_io_source_destroy(source) -Free a key-value container and all internal memory for key storage. +Free data source. Calls [`sc_io_source_complete`](@ref) and requires it to return no error. This is to avoid discarding buffered data that has not been passed to read. # Arguments -* `kv`:\\[in,out\\] The key-value container is invalidated by this call. +* `source`:\\[in,out\\] The source object to free. +# Returns +0 on success. Nonzero if an error is encountered or is\\_complete returns one. ### Prototype ```c -void sc_keyvalue_destroy (sc_keyvalue_t * kv); +int sc_io_source_destroy (sc_io_source_t * source); ``` """ -function sc_keyvalue_destroy(kv) - @ccall libsc.sc_keyvalue_destroy(kv::Ptr{sc_keyvalue_t})::Cvoid +function sc_io_source_destroy(source) + @ccall libsc.sc_io_source_destroy(source::Ptr{sc_io_source_t})::Cint end """ - sc_keyvalue_exists(kv, key) + sc_io_source_destroy_null(source) -Routine to check existence of an entry. +Free data source and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_source_destroy. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key to query. +* `source`:\\[in,out\\] Non-NULL pointer to source pointer. The source pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_source, which is passed to sc_io_source_destroy, and the source pointer is set to NULL afterwards. # Returns -The entry's type if found and SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. +0 on success, nonzero on error. ### Prototype ```c -sc_keyvalue_entry_type_t sc_keyvalue_exists (sc_keyvalue_t * kv, const char *key); +int sc_io_source_destroy_null (sc_io_source_t ** source); ``` """ -function sc_keyvalue_exists(kv, key) - @ccall libsc.sc_keyvalue_exists(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t +function sc_io_source_destroy_null(source) + @ccall libsc.sc_io_source_destroy_null(source::Ptr{Ptr{sc_io_source_t}})::Cint end """ - sc_keyvalue_unset(kv, key) + sc_io_source_read(source, data, bytes_avail, bytes_out) -Routine to remove an entry. +Read data from a source. The internal counters source->bytes\\_in and source->bytes\\_out are updated. Data is read until the data buffer has not enough room anymore, or source becomes empty. It is possible that data already read internally remains in the source object for the next call. Call [`sc_io_source_complete`](@ref) and check its return value to find out. Returns an error if bytes\\_out is NULL and less than bytes\\_avail are read. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key to remove if it exists. +* `source`:\\[in,out\\] The source object to read from. +* `data`:\\[in\\] Data buffer for reading from source. If NULL the output data will be ignored and we seek forward in the input. +* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. +* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. If this condition is not met, return an error. # Returns -The entry's type if found and removed, SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. +0 on success, nonzero on error. ### Prototype ```c -sc_keyvalue_entry_type_t sc_keyvalue_unset (sc_keyvalue_t * kv, const char *key); +int sc_io_source_read (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); ``` """ -function sc_keyvalue_unset(kv, key) - @ccall libsc.sc_keyvalue_unset(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t +function sc_io_source_read(source, data, bytes_avail, bytes_out) + @ccall libsc.sc_io_source_read(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint end """ - sc_keyvalue_get_int(kv, key, dvalue) + sc_io_source_complete(source, bytes_in, bytes_out) -Routines to retrieve an integer value by its key. This function asserts that the key, if existing, points to the correct type. +Determine whether all data buffered from source has been returned by read. If it returns SC\\_IO\\_ERROR\\_AGAIN, another [`sc_io_source_read`](@ref) is required. If the call returns no error, the internal counters source->bytes\\_in and source->bytes\\_out are returned to the caller if requested, and reset to 0. The internal state of the source is not changed otherwise. It is legal to continue reading from the source hereafter. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. +* `source`:\\[in,out\\] The source object to read from. +* `bytes_in`:\\[in,out\\] If not NULL and true is returned, the total size of the data sourced. +* `bytes_out`:\\[in,out\\] If not NULL and true is returned, total bytes passed out by source\\_read. # Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. +SC\\_IO\\_ERROR\\_AGAIN if buffered data remaining. Otherwise return ERROR\\_NONE and reset counters. ### Prototype ```c -int sc_keyvalue_get_int (sc_keyvalue_t * kv, const char *key, int dvalue); +int sc_io_source_complete (sc_io_source_t * source, size_t *bytes_in, size_t *bytes_out); ``` """ -function sc_keyvalue_get_int(kv, key, dvalue) - @ccall libsc.sc_keyvalue_get_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cint)::Cint +function sc_io_source_complete(source, bytes_in, bytes_out) + @ccall libsc.sc_io_source_complete(source::Ptr{sc_io_source_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint end """ - sc_keyvalue_get_double(kv, key, dvalue) + sc_io_source_align(source, bytes_align) -Retrieve a double value by its key. This function asserts that the key, if existing, points to the correct type. +Align source to a byte boundary by skipping. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. +* `source`:\\[in,out\\] The source object to align. +* `bytes_align`:\\[in\\] Byte boundary. # Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. +0 on success, nonzero on error. ### Prototype ```c -double sc_keyvalue_get_double (sc_keyvalue_t * kv, const char *key, double dvalue); +int sc_io_source_align (sc_io_source_t * source, size_t bytes_align); ``` """ -function sc_keyvalue_get_double(kv, key, dvalue) - @ccall libsc.sc_keyvalue_get_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cdouble)::Cdouble +function sc_io_source_align(source, bytes_align) + @ccall libsc.sc_io_source_align(source::Ptr{sc_io_source_t}, bytes_align::Csize_t)::Cint end """ - sc_keyvalue_get_string(kv, key, dvalue) + sc_io_source_activate_mirror(source) -Retrieve a string value by its key. This function asserts that the key, if existing, points to the correct type. +Activate a buffer that mirrors (i.e., stores) the data that was read. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. +* `source`:\\[in,out\\] The source object to activate mirror in. # Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. +0 on success, nonzero on error. ### Prototype ```c -const char *sc_keyvalue_get_string (sc_keyvalue_t * kv, const char *key, const char *dvalue); +int sc_io_source_activate_mirror (sc_io_source_t * source); ``` """ -function sc_keyvalue_get_string(kv, key, dvalue) - @ccall libsc.sc_keyvalue_get_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cstring)::Cstring +function sc_io_source_activate_mirror(source) + @ccall libsc.sc_io_source_activate_mirror(source::Ptr{sc_io_source_t})::Cint end """ - sc_keyvalue_get_pointer(kv, key, dvalue) + sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) -Retrieve a pointer value by its key. This function asserts that the key, if existing, points to the correct type. +Read data from the source's mirror. Same behaviour as [`sc_io_source_read`](@ref). # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. +* `source`:\\[in,out\\] The source object to read mirror data from. +* `data`:\\[in\\] Data buffer for reading from source's mirror. If NULL the output data will be thrown away. +* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. +* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. # Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. +0 on success, nonzero on error. ### Prototype ```c -void *sc_keyvalue_get_pointer (sc_keyvalue_t * kv, const char *key, void *dvalue); +int sc_io_source_read_mirror (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); ``` """ -function sc_keyvalue_get_pointer(kv, key, dvalue) - @ccall libsc.sc_keyvalue_get_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Ptr{Cvoid})::Ptr{Cvoid} +function sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) + @ccall libsc.sc_io_source_read_mirror(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint end """ - sc_keyvalue_get_int_check(kv, key, status) + sc_io_file_save(filename, buffer) -Query an integer key with error checking. We check whether the key is not found or it is of the wrong type. A default value to be returned on error can be passed in as *status. If status is NULL, then the result on error is undefined. +Save a buffer to a file in one call. This function performs error checking and always returns cleanly. # Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key string. -* `status`:\\[in,out\\] If not NULL, set to 0 if there is no error, 1 if the key is not found, 2 if a value is found but its type is not integer, and return the input value *status on error. -# Returns -On error we return *status if status is not NULL, and else an undefined value backed by an assertion. Without error, return the result of the lookup. +* `filename`:\\[in\\] Name of the file to save. +* `buffer`:\\[in\\] An array of element size 1 and arbitrary contents, which are written to the file. +# Returns +0 on success, -1 on error. ### Prototype ```c -int sc_keyvalue_get_int_check (sc_keyvalue_t * kv, const char *key, int *status); +int sc_io_file_save (const char *filename, sc_array_t * buffer); ``` """ -function sc_keyvalue_get_int_check(kv, key, status) - @ccall libsc.sc_keyvalue_get_int_check(kv::Ptr{sc_keyvalue_t}, key::Cstring, status::Ptr{Cint})::Cint +function sc_io_file_save(filename, buffer) + @ccall libsc.sc_io_file_save(filename::Cstring, buffer::Ptr{sc_array_t})::Cint end """ - sc_keyvalue_set_int(kv, key, newvalue) + sc_io_file_load(filename, buffer) -Routine to set an integer value for a given key. +Read a file into a buffer in one call. This function performs error checking and always returns cleanly. # Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type integer. -* `newvalue`:\\[in\\] New value will be stored under key. +* `filename`:\\[in\\] Name of the file to load. +* `buffer`:\\[in,out\\] On input, an array (not a view) of element size 1 and arbitrary contents. On output and success, the complete file contents. On error, contents are undefined. +# Returns +0 on success, -1 on error. ### Prototype ```c -void sc_keyvalue_set_int (sc_keyvalue_t * kv, const char *key, int newvalue); +int sc_io_file_load (const char *filename, sc_array_t * buffer); ``` """ -function sc_keyvalue_set_int(kv, key, newvalue) - @ccall libsc.sc_keyvalue_set_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cint)::Cvoid +function sc_io_file_load(filename, buffer) + @ccall libsc.sc_io_file_load(filename::Cstring, buffer::Ptr{sc_array_t})::Cint end """ - sc_keyvalue_set_double(kv, key, newvalue) + sc_io_encode(data, out) -Routine to set a double value for a given key. +Encode a block of arbitrary data with the default sc\\_io format. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. + +Currently this function calls sc_io_encode_zlib with compression level Z\\_BEST\\_COMPRESSION (subject to change). Without zlib configured that function works uncompressed. + +The encoding method and input data size can be retrieved, optionally, from the encoded data by sc_io_decode_info. This function decodes the method as a character, which is 'z' for sc_io_encode_zlib. We reserve the characters A-C, d-z indefinitely. # Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type double. -* `newvalue`:\\[in\\] New value will be stored under key. +* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. +* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. ### Prototype ```c -void sc_keyvalue_set_double (sc_keyvalue_t * kv, const char *key, double newvalue); +void sc_io_encode (sc_array_t *data, sc_array_t *out); ``` """ -function sc_keyvalue_set_double(kv, key, newvalue) - @ccall libsc.sc_keyvalue_set_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cdouble)::Cvoid +function sc_io_encode(data, out) + @ccall libsc.sc_io_encode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t})::Cvoid end """ - sc_keyvalue_set_string(kv, key, newvalue) + sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) -Routine to set a string value for a given key. +Encode a block of arbitrary data, compressed, into an ASCII string. This is a two-stage process: zlib compress and then encode to base 64. The output is a NUL-terminated string of printable characters. -# Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type string. -* `newvalue`:\\[in\\] New value will be stored under key. -### Prototype -```c -void sc_keyvalue_set_string (sc_keyvalue_t * kv, const char *key, const char *newvalue); -``` -""" -function sc_keyvalue_set_string(kv, key, newvalue) - @ccall libsc.sc_keyvalue_set_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cstring)::Cvoid -end +We first compress the data into the zlib deflate format (RFC 1951). The compressor must use no preset dictionary (this is the default). If zlib is detected on configuration, we compress with the given level. If zlib is not detected, we write data equivalent to Z\\_NO\\_COMPRESSION. The status of zlib detection can be queried at compile time using #ifdef [`SC_HAVE_ZLIB`](@ref) or at run time using sc_have_zlib. Both types of result are readable by a standard zlib uncompress call. -""" - sc_keyvalue_set_pointer(kv, key, newvalue) +Secondly, we process the input data size as an 8-byte big-endian number, then the letter 'z', and then the zlib compressed data, concatenated, with a base 64 encoder. We break lines after 76 code characters. Each line break consists of two configurable but arbitrary bytes. The line breaks are considered part of the output data specification. The last line is terminated with the same line break and then a NUL. -Routine to set a pointer value for a given key. +This routine can work in place or write to an output array. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. # Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type pointer. -* `newvalue`:\\[in\\] New value will be stored under key. +* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. +* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. +* `zlib_compression_level`:\\[in\\] Compression level between 0 (no compression) and 9 (best compression). The value -1 indicates some default level. +* `line_break_character`:\\[in\\] This character is arbitrary and specifies the first of two line break bytes. The second byte is always ''. ### Prototype ```c -void sc_keyvalue_set_pointer (sc_keyvalue_t * kv, const char *key, void *newvalue); +void sc_io_encode_zlib (sc_array_t *data, sc_array_t *out, int zlib_compression_level, int line_break_character); ``` """ -function sc_keyvalue_set_pointer(kv, key, newvalue) - @ccall libsc.sc_keyvalue_set_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Ptr{Cvoid})::Cvoid +function sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) + @ccall libsc.sc_io_encode_zlib(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, zlib_compression_level::Cint, line_break_character::Cint)::Cvoid end -# typedef int ( * sc_keyvalue_foreach_t ) ( const char * key , const sc_keyvalue_entry_type_t type , void * entry , const void * u ) """ -Function to call on every key value pair + sc_io_decode_info(data, original_size, format_char, re) -# Arguments -* `key`:\\[in\\] The key for this pair -* `type`:\\[in\\] The type of entry -* `entry`:\\[in\\] Pointer to the entry -* `u`:\\[in\\] Arbitrary user data. -# Returns -Return true if the traversal should continue, false to stop. -""" -const sc_keyvalue_foreach_t = Ptr{Cvoid} +Decode length and format of original input from encoded data. We expect at least 12 bytes of the format produced by sc_io_encode. No matter how much data has been encoded by it, this much is available. We decode the original data size and the character indicating the format. -""" - sc_keyvalue_foreach(kv, fn, user_data) +This function does not require zlib. It works with any well-defined data. -Iterate through all stored key-value pairs. +Note that this function is not required before sc_io_decode. Calling this function on any result produced by sc_io_encode will succeed and report a legal format. This function cannot crash. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `fn`:\\[in\\] Function to call on each key-value pair. -* `user_data`:\\[in,out\\] This pointer is passed through to **fn**. +* `data`:\\[in\\] This must be an array with element size 1. If it contains less than 12 code bytes we error out. It its first 12 bytes do not base 64 decode to 9 bytes we error out. We generally ignore the remaining data. +* `original_size`:\\[out\\] If not NULL and we do not error out, set to the original size as encoded in the data. +* `format_char`:\\[out\\] If not NULL and we do not error out, the ninth character of decoded data indicating the format. +* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. +# Returns +0 on success, negative value on error. ### Prototype ```c -void sc_keyvalue_foreach (sc_keyvalue_t * kv, sc_keyvalue_foreach_t fn, void *user_data); +int sc_io_decode_info (sc_array_t *data, size_t *original_size, char *format_char, void *re); ``` """ -function sc_keyvalue_foreach(kv, fn, user_data) - @ccall libsc.sc_keyvalue_foreach(kv::Ptr{sc_keyvalue_t}, fn::sc_keyvalue_foreach_t, user_data::Ptr{Cvoid})::Cvoid +function sc_io_decode_info(data, original_size, format_char, re) + @ccall libsc.sc_io_decode_info(data::Ptr{sc_array_t}, original_size::Ptr{Csize_t}, format_char::Cstring, re::Ptr{Cvoid})::Cint end """ - sc_statinfo + sc_io_decode(data, out, max_original_size, re) -Store information of one random variable. +Decode a block of base 64 encoded compressed data. The base 64 data must contain two arbitrary bytes after every 76 code characters and also at the end of the last line if it is short, and then a final NUL character. This function does not require zlib but benefits for speed. -| Field | Note | -| :--------------- | :--------------------------------------- | -| dirty | Only update stats if this is true. | -| count | Inout; global count is 52 bit accurate. | -| sum\\_values | Inout; global sum of values. | -| sum\\_squares | Inout; global sum of squares. | -| min | Inout; minimum over values. | -| max | Inout; maximum over values. | -| variable | Name of the variable for output. | -| variable\\_owned | NULL or deep copy of variable. | -| group | Grouping identifier. | -| prio | Priority identifier. | -""" -struct sc_statinfo - dirty::Cint - count::Clong - sum_values::Cdouble - sum_squares::Cdouble - min::Cdouble - max::Cdouble - min_at_rank::Cint - max_at_rank::Cint - average::Cdouble - variance::Cdouble - standev::Cdouble - variance_mean::Cdouble - standev_mean::Cdouble - variable::Cstring - variable_owned::Cstring - group::Cint - prio::Cint -end +This is a two-stage process: we decode the input from base 64 first. Then we extract the 8-byte big-endian original data size, the character 'z', and execute a zlib decompression on the remaining decoded data. This function detects malformed input by erroring out. -"""Store information of one random variable.""" -const sc_statinfo_t = sc_statinfo +If we should add another format in the future, the format character may be something else than 'z', as permitted by our specification. To this end, we reserve the characters A-C and d-z indefinitely. -""" - sc_stats_set1(stats, value, variable) +Any error condition is indicated by a negative return value. Possible causes for error are: -Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. We set sc_stats_group_all and sc_stats_prio_all internally. +- the input data string is not NUL-terminated - the first 12 characters of input do not decode properly - the input data is corrupt for decoding or decompression - the output data array has non-unit element size and the length of the output data is not divisible by the size - the output data would exceed the specified threshold - the output array is a view of insufficient length + +We also error out if the data requires a compression dictionary, which would be a violation of above encode format specification. + +The corresponding encode function is sc_io_encode. When passing an array as output, we resize it properly. This function cannot crash unless out of memory. # Arguments -* `stats`:\\[out\\] Will be filled with count=1 and the value. -* `value`:\\[in\\] Value used to fill statistics information. -* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. +* `data`:\\[in,out\\] If *out* is NULL, we work in place. In that case, output is written into this array after a suitable resize. Either way, we expect a NUL-terminated base 64 encoded string on input that has in turn been obtained by zlib compression. It must be in the exact format produced by sc_io_encode; please see documentation. The element size of the input array must be 1. +* `out`:\\[in,out\\] If not NULL, a valid array (may be a view). If NULL, the input array becomes the output. If the output array is a view and the output data larger than its view size, we error out. We expect commensurable element and data size and resize the output to fit exactly, which restores the original input passed to encoding. An output view array of matching size may be constructed using sc_io_decode_info. +* `max_original_size`:\\[in\\] If nonzero, this is the maximal data size that we will accept after uncompression. If exceeded, return a negative value. +* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. +# Returns +0 on success, negative on malformed input data or insufficient output space. ### Prototype ```c -void sc_stats_set1 (sc_statinfo_t * stats, double value, const char *variable); +int sc_io_decode (sc_array_t *data, sc_array_t *out, size_t max_original_size, void *re); ``` """ -function sc_stats_set1(stats, value, variable) - @ccall libsc.sc_stats_set1(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring)::Cvoid +function sc_io_decode(data, out, max_original_size, re) + @ccall libsc.sc_io_decode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, max_original_size::Csize_t, re::Ptr{Cvoid})::Cint end """ - sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) + sc_vtk_write_binary(vtkfile, numeric_data, byte_length) -Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. +This function writes numeric binary data in VTK base64 encoding. # Arguments -* `stats`:\\[out\\] Will be filled with count=1 and the value. -* `value`:\\[in\\] Value used to fill statistics information. -* `variable`:\\[in\\] String to be reported by sc_stats_print. -* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. -* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. -* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. +* `vtkfile`: Stream opened for writing. +* `numeric_data`: A pointer to a numeric data array. +* `byte_length`: The length of the data array in bytes. +# Returns +Returns 0 on success, -1 on file error. ### Prototype ```c -void sc_stats_set1_ext (sc_statinfo_t * stats, double value, const char *variable, int copy_variable, int stats_group, int stats_prio); +int sc_vtk_write_binary (FILE * vtkfile, char *numeric_data, size_t byte_length); ``` """ -function sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) - @ccall libsc.sc_stats_set1_ext(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid +function sc_vtk_write_binary(vtkfile, numeric_data, byte_length) + @ccall libsc.sc_vtk_write_binary(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint end """ - sc_stats_init(stats, variable) + sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) -Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. We set sc_stats_group_all and sc_stats_prio_all internally. +This function writes numeric binary data in VTK compressed format. # Arguments -* `stats`:\\[out\\] Will be filled with count 0 and values of 0. -* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. +* `vtkfile`: Stream opened for writing. +* `numeric_data`: A pointer to a numeric data array. +* `byte_length`: The length of the data array in bytes. +# Returns +Returns 0 on success, -1 on file error. ### Prototype ```c -void sc_stats_init (sc_statinfo_t * stats, const char *variable); +int sc_vtk_write_compressed (FILE * vtkfile, char *numeric_data, size_t byte_length); ``` """ -function sc_stats_init(stats, variable) - @ccall libsc.sc_stats_init(stats::Ptr{sc_statinfo_t}, variable::Cstring)::Cvoid +function sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) + @ccall libsc.sc_vtk_write_compressed(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint end """ - sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) + sc_fopen(filename, mode, errmsg) -Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. +Wrapper for fopen(3). We provide an additional argument that contains the error message. -# Arguments -* `stats`:\\[out\\] Will be filled with count 0 and values of 0. -* `variable`:\\[in\\] String to be reported by sc_stats_print. -* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. -* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. -* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. ### Prototype ```c -void sc_stats_init_ext (sc_statinfo_t * stats, const char *variable, int copy_variable, int stats_group, int stats_prio); +FILE *sc_fopen (const char *filename, const char *mode, const char *errmsg); ``` """ -function sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) - @ccall libsc.sc_stats_init_ext(stats::Ptr{sc_statinfo_t}, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid +function sc_fopen(filename, mode, errmsg) + @ccall libsc.sc_fopen(filename::Cstring, mode::Cstring, errmsg::Cstring)::Ptr{Libc.FILE} end """ - sc_stats_reset(stats, reset_vgp) + sc_fwrite(ptr, size, nmemb, file, errmsg) -Reset all values to zero, optionally unassign name, group, and priority. +Write memory content to a file. + +!!! note + + This function aborts on file errors. # Arguments -* `stats`:\\[in,out\\] Variables are zeroed. They can be set again by set1 or accumulate. -* `reset_vgp`:\\[in\\] If true, the variable name string is zeroed and if we did a copy, the copy is freed. If true, group and priority are set to all. If false, we don't touch any of the above. +* `ptr`:\\[in\\] Data array to write to disk. +* `size`:\\[in\\] Size of one array member. +* `nmemb`:\\[in\\] Number of array members. +* `file`:\\[in,out\\] File pointer, must be opened for writing. +* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). ### Prototype ```c -void sc_stats_reset (sc_statinfo_t * stats, int reset_vgp); +void sc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); ``` """ -function sc_stats_reset(stats, reset_vgp) - @ccall libsc.sc_stats_reset(stats::Ptr{sc_statinfo_t}, reset_vgp::Cint)::Cvoid +function sc_fwrite(ptr, size, nmemb, file, errmsg) + @ccall libsc.sc_fwrite(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid end """ - sc_stats_set_group_prio(stats, stats_group, stats_prio) + sc_fread(ptr, size, nmemb, file, errmsg) -Set/update the group and priority information for a stats item. +Read file content into memory. + +!!! note + + This function aborts on file errors. # Arguments -* `stats`:\\[out\\] Only group and stats entries are updated. -* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. -* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. +* `ptr`:\\[out\\] Data array to read from disk. +* `size`:\\[in\\] Size of one array member. +* `nmemb`:\\[in\\] Number of array members. +* `file`:\\[in,out\\] File pointer, must be opened for reading. +* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). ### Prototype ```c -void sc_stats_set_group_prio (sc_statinfo_t * stats, int stats_group, int stats_prio); +void sc_fread (void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); ``` """ -function sc_stats_set_group_prio(stats, stats_group, stats_prio) - @ccall libsc.sc_stats_set_group_prio(stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint)::Cvoid +function sc_fread(ptr, size, nmemb, file, errmsg) + @ccall libsc.sc_fread(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid end """ - sc_stats_accumulate(stats, value) + sc_fflush_fsync_fclose(file) -Add an instance of the random variable. The counter of the variable is increased by one. The value is added into the present values of the variable. +Best effort to flush a file's data to disc and close it. # Arguments -* `stats`:\\[out\\] Must be dirty. We bump count and values. -* `value`:\\[in\\] Value used to update statistics information. +* `file`:\\[in,out\\] File open for writing. ### Prototype ```c -void sc_stats_accumulate (sc_statinfo_t * stats, double value); +void sc_fflush_fsync_fclose (FILE * file); ``` """ -function sc_stats_accumulate(stats, value) - @ccall libsc.sc_stats_accumulate(stats::Ptr{sc_statinfo_t}, value::Cdouble)::Cvoid +function sc_fflush_fsync_fclose(file) + @ccall libsc.sc_fflush_fsync_fclose(file::Ptr{Libc.FILE})::Cvoid end """ - sc_stats_compute(mpicomm, nvars, stats) + sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) ### Prototype ```c -void sc_stats_compute (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); +int sc_io_open (sc_MPI_Comm mpicomm, const char *filename, sc_io_open_mode_t amode, sc_MPI_Info mpiinfo, sc_MPI_File * mpifile); ``` """ -function sc_stats_compute(mpicomm, nvars, stats) - @ccall libsc.sc_stats_compute(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid +function sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) + @ccall libsc.sc_io_open(mpicomm::MPI_Comm, filename::Cstring, amode::sc_io_open_mode_t, mpiinfo::Cint, mpifile::Ptr{Cint})::Cint end """ - sc_stats_compute1(mpicomm, nvars, stats) + sc_io_read_at(mpifile, offset, ptr, count, t, ocount) ### Prototype ```c -void sc_stats_compute1 (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); +int sc_io_read_at (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); ``` """ -function sc_stats_compute1(mpicomm, nvars, stats) - @ccall libsc.sc_stats_compute1(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid +function sc_io_read_at(mpifile, offset, ptr, count, t, ocount) + @ccall libsc.sc_io_read_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint end """ - sc_stats_print(package_id, log_priority, nvars, stats, full, summary) - -Print measured statistics. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. All groups and priorities are printed. + sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) -# Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Log priority for output according to sc.h. -* `nvars`:\\[in\\] Number of stats items in input array. -* `stats`:\\[in\\] Input array of stats variable items. -* `full`:\\[in\\] Print full information for every variable. -* `summary`:\\[in\\] Print summary information all on 1 line. ### Prototype ```c -void sc_stats_print (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int full, int summary); +int sc_io_read_at_all (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); ``` """ -function sc_stats_print(package_id, log_priority, nvars, stats, full, summary) - @ccall libsc.sc_stats_print(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, full::Cint, summary::Cint)::Cvoid +function sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) + @ccall libsc.sc_io_read_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint end """ - sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) - -Print measured statistics, filter by group and/or priority. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. + sc_io_write_at(mpifile, offset, ptr, count, t, ocount) -# Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Log priority for output according to sc.h. -* `nvars`:\\[in\\] Number of stats items in input array. -* `stats`:\\[in\\] Input array of stats variable items. -* `stats_group`:\\[in\\] Print only this group. Non-negative or sc_stats_group_all. We skip printing a variable if neither this parameter nor the item's group is all and if the item's group does not match this. -* `stats_prio`:\\[in\\] Print this and higher priorities. Non-negative or sc_stats_prio_all. We skip printing a variable if neither this parameter nor the item's prio is all and if the item's prio is less than this. -* `full`:\\[in\\] Print full information for every variable. This produces multiple lines including minimum, maximum, and standard deviation. If this is false, print one line per variable. -* `summary`:\\[in\\] Print summary information all on 1 line. This always contains all variables. Not affected by stats\\_group and stats\\_prio. ### Prototype ```c -void sc_stats_print_ext (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int stats_group, int stats_prio, int full, int summary); +int sc_io_write_at (sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount); ``` """ -function sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) - @ccall libsc.sc_stats_print_ext(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint, full::Cint, summary::Cint)::Cvoid +function sc_io_write_at(mpifile, offset, ptr, count, t, ocount) + @ccall libsc.sc_io_write_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint end """ - sc_statistics_new(mpicomm) + sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) ### Prototype ```c -sc_statistics_t *sc_statistics_new (sc_MPI_Comm mpicomm); +int sc_io_write_at_all (sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount); ``` """ -function sc_statistics_new(mpicomm) - @ccall libsc.sc_statistics_new(mpicomm::MPI_Comm)::Ptr{sc_statistics_t} +function sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) + @ccall libsc.sc_io_write_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint end """ - sc_statistics_destroy(stats) - -Destroy a statistics structure. + sc_io_close(file) -# Arguments -* `stats`:\\[in,out\\] Valid object is invalidated. ### Prototype ```c -void sc_statistics_destroy (sc_statistics_t * stats); +int sc_io_close (sc_MPI_File * file); ``` """ -function sc_statistics_destroy(stats) - @ccall libsc.sc_statistics_destroy(stats::Ptr{sc_statistics_t})::Cvoid +function sc_io_close(file) + @ccall libsc.sc_io_close(file::Ptr{Cint})::Cint end """ - sc_statistics_add(stats, name) - -Register a statistics variable by name and set its value to 0. This variable must not exist already. + p4est_comm_tag -### Prototype -```c -void sc_statistics_add (sc_statistics_t * stats, const char *name); -``` +Tags for MPI messages """ -function sc_statistics_add(stats, name) - @ccall libsc.sc_statistics_add(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid +@cenum p4est_comm_tag::UInt32 begin + P4EST_COMM_TAG_FIRST = 214 + P4EST_COMM_COUNT_PERTREE = 295 + P4EST_COMM_BALANCE_FIRST_COUNT = 296 + P4EST_COMM_BALANCE_FIRST_LOAD = 297 + P4EST_COMM_BALANCE_SECOND_COUNT = 298 + P4EST_COMM_BALANCE_SECOND_LOAD = 299 + P4EST_COMM_PARTITION_GIVEN = 300 + P4EST_COMM_PARTITION_WEIGHTED_LOW = 301 + P4EST_COMM_PARTITION_WEIGHTED_HIGH = 302 + P4EST_COMM_PARTITION_CORRECTION = 303 + P4EST_COMM_GHOST_COUNT = 304 + P4EST_COMM_GHOST_LOAD = 305 + P4EST_COMM_GHOST_EXCHANGE = 306 + P4EST_COMM_GHOST_EXPAND_COUNT = 307 + P4EST_COMM_GHOST_EXPAND_LOAD = 308 + P4EST_COMM_GHOST_SUPPORT_COUNT = 309 + P4EST_COMM_GHOST_SUPPORT_LOAD = 310 + P4EST_COMM_GHOST_CHECKSUM = 311 + P4EST_COMM_NODES_QUERY = 312 + P4EST_COMM_NODES_REPLY = 313 + P4EST_COMM_SAVE = 314 + P4EST_COMM_LNODES_TEST = 315 + P4EST_COMM_LNODES_PASS = 316 + P4EST_COMM_LNODES_OWNED = 317 + P4EST_COMM_LNODES_ALL = 318 + P4EST_COMM_TAG_LAST = 319 end -""" - sc_statistics_set(stats, name, value) +"""Tags for MPI messages""" +const p4est_comm_tag_t = p4est_comm_tag -Set the value of a statistics variable, see [`sc_stats_set1`](@ref). The variable must previously be added with [`sc_statistics_add`](@ref). This assumes count=1 as in the [`sc_stats_set1`](@ref) function above. +""" + p4est_log_indent_push() ### Prototype ```c -void sc_statistics_set (sc_statistics_t * stats, const char *name, double value); +static inline void p4est_log_indent_push (void); ``` """ -function sc_statistics_set(stats, name, value) - @ccall libsc.sc_statistics_set(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid +function p4est_log_indent_push() + @ccall libp4est.p4est_log_indent_push()::Cvoid end """ - sc_statistics_compute(stats) - -Compute statistics for all variables, see [`sc_stats_compute`](@ref). + p4est_log_indent_pop() ### Prototype ```c -void sc_statistics_compute (sc_statistics_t * stats); +static inline void p4est_log_indent_pop (void); ``` """ -function sc_statistics_compute(stats) - @ccall libsc.sc_statistics_compute(stats::Ptr{sc_statistics_t})::Cvoid +function p4est_log_indent_pop() + @ccall libp4est.p4est_log_indent_pop()::Cvoid end """ - sc_statistics_print(stats, package_id, log_priority, full, summary) + p4est_init(log_handler, log_threshold) -Print all statistics variables, see [`sc_stats_print`](@ref). +Registers p4est with the SC Library and sets the logging behavior. This function is optional. This function must only be called before additional threads are created. If this function is not called or called with log\\_handler == NULL, the default SC log handler will be used. If this function is not called or called with log\\_threshold == [`SC_LP_DEFAULT`](@ref), the default SC log threshold will be used. The default SC log settings can be changed with [`sc_set_log_defaults`](@ref) (). ### Prototype ```c -void sc_statistics_print (sc_statistics_t * stats, int package_id, int log_priority, int full, int summary); +void p4est_init (sc_log_handler_t log_handler, int log_threshold); ``` """ -function sc_statistics_print(stats, package_id, log_priority, full, summary) - @ccall libsc.sc_statistics_print(stats::Ptr{sc_statistics_t}, package_id::Cint, log_priority::Cint, full::Cint, summary::Cint)::Cvoid +function p4est_init(log_handler, log_threshold) + @ccall libp4est.p4est_init(log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid end -mutable struct sc_options end - -"""The options data structure is opaque.""" -const sc_options_t = sc_options - -# typedef int ( * sc_options_callback_t ) ( sc_options_t * opt , const char * opt_arg , void * data ) -""" -This callback can be invoked with sc_options_parse. - -# Arguments -* `opt`:\\[in\\] Valid options data structure. This is passed as a matter of principle. -* `opt_arg`:\\[in\\] The option argument or NULL if there is none. This variable is internal. Do not store pointer. -* `data`:\\[in\\] User-defined data passed to [`sc_options_add_callback`](@ref). -# Returns -Return 0 if successful, -1 to indicate a parse error. """ -const sc_options_callback_t = Ptr{Cvoid} + p4est_is_initialized() -""" - sc_options_new(program_path) +Return whether p4est has been initialized or not. Keep in mind that p4est_init is an optional function but it helps with proper parallel logging. -Create an empty options structure. +Currently there is no inverse to p4est_init, and no way to deinit it. This is ok since initialization generally does no harm. Just do not call libsc's finalize function while p4est is still in use. -# Arguments -* `program_path`:\\[in\\] Name or path name of the program to display. Usually argv[0] is fine. # Returns -A valid and empty options structure. +True if p4est has been initialized with a call to p4est_init and false otherwise. ### Prototype ```c -sc_options_t *sc_options_new (const char *program_path); +int p4est_is_initialized (void); ``` """ -function sc_options_new(program_path) - @ccall libsc.sc_options_new(program_path::Cstring)::Ptr{sc_options_t} +function p4est_is_initialized() + @ccall libp4est.p4est_is_initialized()::Cint end """ - sc_options_destroy_deep(opt) - -Destroy the options structure and all allocated structures contained. The keyvalue structure passed into sc\\_keyvalue\\_add is destroyed. - -!!! compat "Deprecated" + p4est_have_zlib() - This function is kept for backwards compatibility. It is best to destroy any key-value container outside of the lifetime of the options object. +Check for a sufficiently recent zlib installation. -# Arguments -* `opt`:\\[in,out\\] This options structure is deallocated, including all key-value containers referenced. +# Returns +True if zlib is detected in both sc and p4est. ### Prototype ```c -void sc_options_destroy_deep (sc_options_t * opt); +int p4est_have_zlib (void); ``` """ -function sc_options_destroy_deep(opt) - @ccall libsc.sc_options_destroy_deep(opt::Ptr{sc_options_t})::Cvoid +function p4est_have_zlib() + @ccall libp4est.p4est_have_zlib()::Cint end """ - sc_options_destroy(opt) + p4est_get_package_id() -Destroy the options structure. Whatever has been passed into sc\\_keyvalue\\_add is left alone. +Query the package identity as registered in libsc. -# Arguments -* `opt`:\\[in,out\\] This options structure is deallocated. +# Returns +This is -1 before p4est_init has been called and a proper package identifier (>= 0) afterwards. ### Prototype ```c -void sc_options_destroy (sc_options_t * opt); +int p4est_get_package_id (void); ``` """ -function sc_options_destroy(opt) - @ccall libsc.sc_options_destroy(opt::Ptr{sc_options_t})::Cvoid +function p4est_get_package_id() + @ccall libp4est.p4est_get_package_id()::Cint end """ - sc_options_set_spacing(opt, space_type, space_help) - -Set the spacing for sc_options_print_summary. There are two values to be set: the spacing from the beginning of the printed line to the type of the option variable, and from the beginning of the printed line to the help string. + p4est_topidx_hash2(tt) -# Arguments -* `opt`:\\[in,out\\] Valid options structure. -* `space_type`:\\[in\\] Number of spaces to the type display, for example , , etc. Setting this negative sets the default 20. -* `space_help`:\\[in\\] Number of space to the help string. Setting this negative sets the default 32. ### Prototype ```c -void sc_options_set_spacing (sc_options_t * opt, int space_type, int space_help); +static inline unsigned p4est_topidx_hash2 (const p4est_topidx_t * tt); ``` """ -function sc_options_set_spacing(opt, space_type, space_help) - @ccall libsc.sc_options_set_spacing(opt::Ptr{sc_options_t}, space_type::Cint, space_help::Cint)::Cvoid +function p4est_topidx_hash2(tt) + @ccall libp4est.p4est_topidx_hash2(tt::Ptr{p4est_topidx_t})::Cuint end """ - sc_options_add_switch(opt, opt_char, opt_name, variable, help_string) - -Add a switch option. This option is used without option arguments. Every use increments the variable by one. Its initial value is 0. Either opt\\_char or opt\\_name must be valid, that is, not '\\0'/NULL. + p4est_topidx_hash3(tt) -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -void sc_options_add_switch (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, const char *help_string); +static inline unsigned p4est_topidx_hash3 (const p4est_topidx_t * tt); ``` """ -function sc_options_add_switch(opt, opt_char, opt_name, variable, help_string) - @ccall libsc.sc_options_add_switch(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, help_string::Cstring)::Cvoid +function p4est_topidx_hash3(tt) + @ccall libp4est.p4est_topidx_hash3(tt::Ptr{p4est_topidx_t})::Cuint end """ - sc_options_add_bool(opt, opt_char, opt_name, variable, init_value, help_string) - -Add a boolean option. It can be initialized to true or false in the C sense. Specifying it on the command line without argument sets the option to true. The argument 0/f/F/n/N sets it to false (0). The argument 1/t/T/y/Y sets it to true (nonzero). + p4est_topidx_hash4(tt) -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] Initial value to set the option, read as true or false. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -void sc_options_add_bool (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string); +static inline unsigned p4est_topidx_hash4 (const p4est_topidx_t * tt); ``` """ -function sc_options_add_bool(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_bool(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cint, help_string::Cstring)::Cvoid +function p4est_topidx_hash4(tt) + @ccall libp4est.p4est_topidx_hash4(tt::Ptr{p4est_topidx_t})::Cuint end """ - sc_options_add_int(opt, opt_char, opt_name, variable, init_value, help_string) - -Add an option that takes an integer argument. + p4est_topidx_is_sorted(t, length) -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] The initial value of the option variable. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -void sc_options_add_int (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string); +static inline int p4est_topidx_is_sorted (p4est_topidx_t * t, int length); ``` """ -function sc_options_add_int(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_int(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cint, help_string::Cstring)::Cvoid +function p4est_topidx_is_sorted(t, length) + @ccall libp4est.p4est_topidx_is_sorted(t::Ptr{p4est_topidx_t}, length::Cint)::Cint end """ - sc_options_add_size_t(opt, opt_char, opt_name, variable, init_value, help_string) - -Add an option that takes a size\\_t argument. The value of the size\\_t variable must not be greater than LLONG\\_MAX. + p4est_topidx_bsort(t, length) -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] The initial value of the option variable. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -void sc_options_add_size_t (sc_options_t * opt, int opt_char, const char *opt_name, size_t *variable, size_t init_value, const char *help_string); +static inline void p4est_topidx_bsort (p4est_topidx_t * t, int length); ``` """ -function sc_options_add_size_t(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_size_t(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Csize_t}, init_value::Csize_t, help_string::Cstring)::Cvoid +function p4est_topidx_bsort(t, length) + @ccall libp4est.p4est_topidx_bsort(t::Ptr{p4est_topidx_t}, length::Cint)::Cvoid end """ - sc_options_add_double(opt, opt_char, opt_name, variable, init_value, help_string) - -Add an option that takes a double argument. The double must be in the legal range. "inf" and "nan" are legal too. + p4est_partition_cut_uint64(global_num, p, num_procs) -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] The initial value of the option variable. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -void sc_options_add_double (sc_options_t * opt, int opt_char, const char *opt_name, double *variable, double init_value, const char *help_string); +static inline uint64_t p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs); ``` """ -function sc_options_add_double(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_double(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cdouble}, init_value::Cdouble, help_string::Cstring)::Cvoid +function p4est_partition_cut_uint64(global_num, p, num_procs) + @ccall libp4est.p4est_partition_cut_uint64(global_num::UInt64, p::Cint, num_procs::Cint)::UInt64 end """ - sc_options_add_string(opt, opt_char, opt_name, variable, init_value, help_string) - -Add a string option. + p4est_partition_cut_gloidx(global_num, p, num_procs) -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] This default value of the option may be NULL. If not NULL, the value is copied to internal storage. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -void sc_options_add_string (sc_options_t * opt, int opt_char, const char *opt_name, const char **variable, const char *init_value, const char *help_string); +static inline p4est_gloidx_t p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs); ``` """ -function sc_options_add_string(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_string(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cstring}, init_value::Cstring, help_string::Cstring)::Cvoid +function p4est_partition_cut_gloidx(global_num, p, num_procs) + @ccall libp4est.p4est_partition_cut_gloidx(global_num::p4est_gloidx_t, p::Cint, num_procs::Cint)::p4est_gloidx_t end """ - sc_options_add_inifile(opt, opt_char, opt_name, help_string) + p4est_version() -Add an option to read in a file in `.ini` format. The argument to this option must be a filename. On parsing the specified file is read to set known option variables. It does not have an associated option variable itself. +Return the full version of p4est. -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. +# Returns +Return the version of p4est using the format `VERSION\\_MAJOR.VERSION\\_MINOR.VERSION\\_POINT`, where `VERSION_POINT` can contain dots and characters, e.g. to indicate the additional number of commits and a git commit hash. ### Prototype ```c -void sc_options_add_inifile (sc_options_t * opt, int opt_char, const char *opt_name, const char *help_string); +const char *p4est_version (void); ``` """ -function sc_options_add_inifile(opt, opt_char, opt_name, help_string) - @ccall libsc.sc_options_add_inifile(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, help_string::Cstring)::Cvoid +function p4est_version() + @ccall libp4est.p4est_version()::Cstring end """ - sc_options_add_jsonfile(opt, opt_char, opt_name, help_string) - -Add an option to read in a file in JSON format. The argument to this option must be a filename. On parsing the specified file is read to set known option variables. It does not have an associated option variable itself. + p4est_version_major() -This functionality is only active when sc_have_json returns true, equivalent to the define SC\\_HAVE\\_JSON existing, and ignored otherwise. +Return the major version of p4est. -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. +# Returns +Return the major version of p4est. ### Prototype ```c -void sc_options_add_jsonfile (sc_options_t * opt, int opt_char, const char *opt_name, const char *help_string); +int p4est_version_major (void); ``` """ -function sc_options_add_jsonfile(opt, opt_char, opt_name, help_string) - @ccall libsc.sc_options_add_jsonfile(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, help_string::Cstring)::Cvoid +function p4est_version_major() + @ccall libp4est.p4est_version_major()::Cint end """ - sc_options_add_callback(opt, opt_char, opt_name, has_arg, fn, data, help_string) + p4est_version_minor() -Add an option that calls a user-defined function when parsed. The callback function should be implemented to allow multiple calls. The callback may be used to set multiple option variables in bulk that would otherwise require an inconvenient number of individual options. This option is not loaded from or saved to files. +Return the minor version of p4est. -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `has_arg`:\\[in\\] Specify whether the option needs an option argument. This can be 0 for none, 1 for a required argument, and 2 for an optional argument; see getopt\\_long (3). -* `fn`:\\[in\\] Function to call when this option is encountered. -* `data`:\\[in\\] User-defined data passed to the callback. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. +# Returns +Return the minor version of p4est. ### Prototype ```c -void sc_options_add_callback (sc_options_t * opt, int opt_char, const char *opt_name, int has_arg, sc_options_callback_t fn, void *data, const char *help_string); +int p4est_version_minor (void); ``` """ -function sc_options_add_callback(opt, opt_char, opt_name, has_arg, fn, data, help_string) - @ccall libsc.sc_options_add_callback(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, has_arg::Cint, fn::sc_options_callback_t, data::Ptr{Cvoid}, help_string::Cstring)::Cvoid +function p4est_version_minor() + @ccall libp4est.p4est_version_minor()::Cint end """ - sc_options_add_keyvalue(opt, opt_char, opt_name, variable, init_value, keyvalue, help_string) + p4est_connect_type_t -Add an option that takes string keys into a lookup table of integers. On calling this function, it must be certain that the initial value exists. +Characterize a type of adjacency. -# Arguments -* `opt`:\\[in\\] Initialized options structure. -* `opt_char`:\\[in\\] Option character for command line, or 0. -* `opt_name`:\\[in\\] Name of the long option, or NULL. -* `variable`:\\[in\\] Address of an existing integer that holds the value of this option parameter. -* `init_value`:\\[in\\] The key that is looked up for the initial value. It must be certain that the key exists and its value is of type integer. -* `keyvalue`:\\[in\\] A valid key-value structure where the values must be integers. If a key is asked for that does not exist, we will produce an option error. This structure must stay alive as long as opt. -* `help_string`:\\[in\\] Instructive one-line string to explain the option. -### Prototype -```c -void sc_options_add_keyvalue (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, const char *init_value, sc_keyvalue_t * keyvalue, const char *help_string); -``` +Several functions involve relationships between neighboring trees and/or quadrants, and their behavior depends on how one defines adjacency: 1) entities are adjacent if they share a face, or 2) entities are adjacent if they share a face or corner. [`p4est_connect_type_t`](@ref) is used to choose the desired behavior. This enum must fit into an int8\\_t. + +| Enumerator | Note | +| :----------------------- | :--------------------------------- | +| P4EST\\_CONNECT\\_SELF | No balance whatsoever. | +| P4EST\\_CONNECT\\_FACE | Balance across faces only. | +| P4EST\\_CONNECT\\_ALMOST | = CORNER - 1. | +| P4EST\\_CONNECT\\_CORNER | Balance across faces and corners. | +| P4EST\\_CONNECT\\_FULL | = CORNER. | """ -function sc_options_add_keyvalue(opt, opt_char, opt_name, variable, init_value, keyvalue, help_string) - @ccall libsc.sc_options_add_keyvalue(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cstring, keyvalue::Ptr{sc_keyvalue_t}, help_string::Cstring)::Cvoid +@cenum p4est_connect_type_t::UInt32 begin + P4EST_CONNECT_SELF = 20 + P4EST_CONNECT_FACE = 21 + P4EST_CONNECT_ALMOST = 21 + P4EST_CONNECT_CORNER = 22 + P4EST_CONNECT_FULL = 22 end """ - sc_options_add_suboptions(opt, subopt, prefix) + p4est_connectivity_encode_t -Copy one set of options to another as a subset, with a prefix. The variables referenced by the options and the suboptions are the same. +Typedef for serialization method. -# Arguments -* `opt`:\\[in,out\\] A set of options. -* `subopt`:\\[in\\] Another set of options to be copied. -* `prefix`:\\[in\\] The prefix to add to option names as they are copied. If an option has a long name "name" in subopt, its name in opt is "prefix:name"; if an option only has a character 'c' in subopt, its name in opt is "prefix:-c". -### Prototype -```c -void sc_options_add_suboptions (sc_options_t * opt, sc_options_t * subopt, const char *prefix); -``` +| Enumerator | Note | +| :--------------------------- | :-------------------------------- | +| P4EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | """ -function sc_options_add_suboptions(opt, subopt, prefix) - @ccall libsc.sc_options_add_suboptions(opt::Ptr{sc_options_t}, subopt::Ptr{sc_options_t}, prefix::Cstring)::Cvoid +@cenum p4est_connectivity_encode_t::UInt32 begin + P4EST_CONN_ENCODE_NONE = 0 + P4EST_CONN_ENCODE_LAST = 1 end """ - sc_options_print_usage(package_id, log_priority, opt, arg_usage) + p4est_connect_type_int(btype) -Print a usage message. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. +Convert the [`p4est_connect_type_t`](@ref) into a number. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Priority for output according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `arg_usage`:\\[in\\] If not NULL, an string is appended to the usage line. If the string is non-empty, it will be printed after the option summary and an "ARGUMENTS:\\n" title line. Line breaks are identified by strtok(3) and honored. +* `btype`:\\[in\\] The balance type to convert. +# Returns +Returns 1 or 2. ### Prototype ```c -void sc_options_print_usage (int package_id, int log_priority, sc_options_t * opt, const char *arg_usage); +int p4est_connect_type_int (p4est_connect_type_t btype); ``` """ -function sc_options_print_usage(package_id, log_priority, opt, arg_usage) - @ccall libsc.sc_options_print_usage(package_id::Cint, log_priority::Cint, opt::Ptr{sc_options_t}, arg_usage::Cstring)::Cvoid +function p4est_connect_type_int(btype) + @ccall libp4est.p4est_connect_type_int(btype::p4est_connect_type_t)::Cint end """ - sc_options_print_summary(package_id, log_priority, opt) + p4est_connect_type_string(btype) -Print a summary of all option values. Prints the title "Options:" and a line for every option, then the title "Arguments:" and a line for every argument. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. +Convert the [`p4est_connect_type_t`](@ref) into a const string. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Priority for output according to sc_logprios. -* `opt`:\\[in\\] The option structure. +* `btype`:\\[in\\] The balance type to convert. +# Returns +Returns a pointer to a constant string. ### Prototype ```c -void sc_options_print_summary (int package_id, int log_priority, sc_options_t * opt); +const char *p4est_connect_type_string (p4est_connect_type_t btype); ``` """ -function sc_options_print_summary(package_id, log_priority, opt) - @ccall libsc.sc_options_print_summary(package_id::Cint, log_priority::Cint, opt::Ptr{sc_options_t})::Cvoid +function p4est_connect_type_string(btype) + @ccall libp4est.p4est_connect_type_string(btype::p4est_connect_type_t)::Cstring end """ - sc_options_load(package_id, err_priority, opt, file) + p4est_connectivity -Load a file in the default format and update option values. The default is a file in the `.ini` format; see sc_options_load_ini. +This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible. -# Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `file`:\\[in\\] Filename of the file to load. -# Returns -Returns 0 on success, -1 on failure. -### Prototype -```c -int sc_options_load (int package_id, int err_priority, sc_options_t * opt, const char *file); -``` +The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is given by the normal directions -x +x -y +y. Each face has a natural direction by increasing face corner number. Face connections are allocated [0][0]..[0][3]..[num\\_trees-1][0]..[num\\_trees-1][3]. If a face is on the physical boundary it must connect to itself. + +The values for tree\\_to\\_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for faces that are mutually direction-aligned and 1 for faces that are running in opposite directions. + +It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. + +The corners are stored when they connect trees that are not already face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. + +The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. + +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. We do not interpret them. + +!!! note + + If a connectivity implies natural connections between trees that are corner neighbors without being face neighbors, these corners shall be encoded explicitly in the connectivity. + +| Field | Note | +| :------------------- | :----------------------------------------------------------------------------------- | +| num\\_vertices | the number of vertices that define the *embedding* of the forest (not the topology) | +| num\\_trees | the number of trees | +| num\\_corners | the number of corners that help define topology | +| vertices | an array of size (3 * *num_vertices*) | +| tree\\_to\\_vertex | embed each tree into ```c++ R^3 ``` for e.g. visualization (see p4est\\_vtk.h) | +| tree\\_attr\\_bytes | bytes per tree in tree\\_to\\_attr | +| tree\\_to\\_attr | not touched by p4est | +| tree\\_to\\_tree | (4 * *num_trees*) neighbors across faces | +| tree\\_to\\_face | (4 * *num_trees*) face to face+orientation (see description) | +| tree\\_to\\_corner | (4 * *num_trees*) or NULL (see description) | +| ctt\\_offset | corner to offset in *corner_to_tree* and *corner_to_corner* | +| corner\\_to\\_tree | list of trees that meet at a corner | +| corner\\_to\\_corner | list of tree-corners that meet at a corner | """ -function sc_options_load(package_id, err_priority, opt, file) - @ccall libsc.sc_options_load(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, file::Cstring)::Cint +struct p4est_connectivity + num_vertices::p4est_topidx_t + num_trees::p4est_topidx_t + num_corners::p4est_topidx_t + vertices::Ptr{Cdouble} + tree_to_vertex::Ptr{p4est_topidx_t} + tree_attr_bytes::Csize_t + tree_to_attr::Cstring + tree_to_tree::Ptr{p4est_topidx_t} + tree_to_face::Ptr{Int8} + tree_to_corner::Ptr{p4est_topidx_t} + ctt_offset::Ptr{p4est_topidx_t} + corner_to_tree::Ptr{p4est_topidx_t} + corner_to_corner::Ptr{Int8} end """ - sc_options_load_ini(package_id, err_priority, opt, inifile, re) +This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible. -Load a file in `.ini` format and update entries found under [Options]. An option whose name contains a colon such as "prefix:basename" will be updated by a "basename =" entry in a [prefix] section. +The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is given by the normal directions -x +x -y +y. Each face has a natural direction by increasing face corner number. Face connections are allocated [0][0]..[0][3]..[num\\_trees-1][0]..[num\\_trees-1][3]. If a face is on the physical boundary it must connect to itself. + +The values for tree\\_to\\_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for faces that are mutually direction-aligned and 1 for faces that are running in opposite directions. + +It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. + +The corners are stored when they connect trees that are not already face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. + +The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. + +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. We do not interpret them. + +!!! note + + If a connectivity implies natural connections between trees that are corner neighbors without being face neighbors, these corners shall be encoded explicitly in the connectivity. +""" +const p4est_connectivity_t = p4est_connectivity -# Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `inifile`:\\[in\\] Filename of the ini file to load. -* `re`:\\[in,out\\] Provisioned for runtime error checking implementation; currently must be NULL. -# Returns -Returns 0 on success, -1 on failure. -### Prototype -```c -int sc_options_load_ini (int package_id, int err_priority, sc_options_t * opt, const char *inifile, void *re); -``` """ -function sc_options_load_ini(package_id, err_priority, opt, inifile, re) - @ccall libsc.sc_options_load_ini(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring, re::Ptr{Cvoid})::Cint + p4est_connectivity_shared + +| Field | Note | +| :---- | :--------------------------------------------------------- | +| conn | The members of this connectivity are MPI3 shared windows. | +""" +struct p4est_connectivity_shared + conn::Ptr{p4est_connectivity_t} + win_vertices::Cint + win_tree_to_vertex::Cint + win_tree_to_attr::Cint + win_tree_to_tree::Cint + win_tree_to_face::Cint + win_tree_to_corner::Cint + win_ctt_offset::Cint + win_corner_to_tree::Cint + win_corner_to_corner::Cint end +"""Management information for a connectivity shared by MPI3.""" +const p4est_connectivity_shared_t = p4est_connectivity_shared + """ - sc_options_load_json(package_id, err_priority, opt, jsonfile, re) + p4est_connectivity_memory_used(conn) -Load a file in JSON format and update entries from object "Options". An option whose name contains a colon such as "Prefix:basename" will be updated by a "basename :" entry in a "Prefix" nested object. +Calculate memory usage of a connectivity structure. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `jsonfile`:\\[in\\] Filename of the JSON file to load. -* `re`:\\[in,out\\] Provisioned for runtime error checking implementation; currently must be NULL. +* `conn`:\\[in\\] Connectivity structure. # Returns -Returns 0 on success, -1 on failure. +Memory used in bytes. ### Prototype ```c -int sc_options_load_json (int package_id, int err_priority, sc_options_t * opt, const char *jsonfile, void *re); +size_t p4est_connectivity_memory_used (p4est_connectivity_t * conn); ``` """ -function sc_options_load_json(package_id, err_priority, opt, jsonfile, re) - @ccall libsc.sc_options_load_json(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, jsonfile::Cstring, re::Ptr{Cvoid})::Cint +function p4est_connectivity_memory_used(conn) + @ccall libp4est.p4est_connectivity_memory_used(conn::Ptr{p4est_connectivity_t})::Csize_t end """ - sc_options_save(package_id, err_priority, opt, inifile) + p4est_corner_transform_t -Save all options and arguments to a file in `.ini` format. This function must only be called after successful option parsing. This function should only be called on rank 0. This function will log errors with category [`SC_LC_GLOBAL`](@ref). An options whose name contains a colon such as "Prefix:basename" will be written in a section titled [Prefix] as "basename =". +Generic interface for transformations between a tree and any of its corner -# Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `inifile`:\\[in\\] Filename of the ini file to save. -# Returns -Returns 0 on success, -1 on failure. -### Prototype -```c -int sc_options_save (int package_id, int err_priority, sc_options_t * opt, const char *inifile); -``` +| Field | Note | +| :------ | :------------------------ | +| ntree | The number of the tree | +| ncorner | The number of the corner | """ -function sc_options_save(package_id, err_priority, opt, inifile) - @ccall libsc.sc_options_save(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring)::Cint +struct p4est_corner_transform_t + ntree::p4est_topidx_t + ncorner::Int8 end """ - sc_options_load_args(package_id, err_priority, opt, inifile) + p4est_corner_info_t + +Information about the neighbors of a corner -Load a file in `.ini` format and update entries found under [Arguments]. There needs to be a key Arguments.count specifying the number. Then as many integer keys starting with 0 need to be present. +| Field | Note | +| :------------------ | :------------------------------------------------ | +| icorner | The number of the originating corner | +| corner\\_transforms | The array of neighbors of the originating corner | +""" +struct p4est_corner_info_t + icorner::p4est_topidx_t + corner_transforms::sc_array_t +end -# Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The args are stored in this option structure. -* `inifile`:\\[in\\] Filename of the ini file to load. -# Returns -Returns 0 on success, -1 on failure. -### Prototype -```c -int sc_options_load_args (int package_id, int err_priority, sc_options_t * opt, const char *inifile); -``` """ -function sc_options_load_args(package_id, err_priority, opt, inifile) - @ccall libsc.sc_options_load_args(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring)::Cint + p4est_neighbor_transform_t + +Generic interface for transformations between a tree and any of its neighbors + +| Field | Note | +| :---------------- | :-------------------------------------------------------------------------- | +| neighbor\\_type | type of connection to neighbor | +| neighbor | neighbor tree index | +| index\\_self | index of interface from self's perspective | +| index\\_neighbor | index of interface from neighbor's perspective | +| perm | permutation of dimensions when transforming self coords to neighbor coords | +| sign | sign changes when transforming self coords to neighbor coords | +| origin\\_self | point on the interface from self's perspective | +| origin\\_neighbor | point on the interface from neighbor's perspective | +""" +struct p4est_neighbor_transform_t + neighbor_type::p4est_connect_type_t + neighbor::p4est_topidx_t + index_self::Int8 + index_neighbor::Int8 + perm::NTuple{2, Int8} + sign::NTuple{2, Int8} + origin_self::NTuple{2, p4est_qcoord_t} + origin_neighbor::NTuple{2, p4est_qcoord_t} end """ - sc_options_parse(package_id, err_priority, opt, argc, argv) + p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) -Parse command line options. +Transform from self's coordinate system to neighbor's coordinate system. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `argc`:\\[in\\] Length of argument list. -* `argv`:\\[in,out\\] Argument list may be permuted. -# Returns -Returns -1 on an invalid option, otherwise the position of the first non-option argument. +* `nt`:\\[in\\] A neighbor transform. +* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. +* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. ### Prototype ```c -int sc_options_parse (int package_id, int err_priority, sc_options_t * opt, int argc, char **argv); +void p4est_neighbor_transform_coordinates (const p4est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P4EST_DIM], p4est_qcoord_t neigh_coords[P4EST_DIM]); ``` """ -function sc_options_parse(package_id, err_priority, opt, argc, argv) - @ccall libsc.sc_options_parse(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, argc::Cint, argv::Ptr{Cstring})::Cint +function p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + @ccall libp4est.p4est_neighbor_transform_coordinates(nt::Ptr{p4est_neighbor_transform_t}, self_coords::Ptr{p4est_qcoord_t}, neigh_coords::Ptr{p4est_qcoord_t})::Cvoid end """ - t8_cmesh_from_tetgen_file(fileprefix, partition, comm, do_dup) + p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + +Transform from neighbor's coordinate system to self's coordinate system. +# Arguments +* `nt`:\\[in\\] A neighbor transform. +* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. +* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. ### Prototype ```c -t8_cmesh_t t8_cmesh_from_tetgen_file (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup); +void p4est_neighbor_transform_coordinates_reverse (const p4est_neighbor_transform_t * nt, const p4est_qcoord_t neigh_coords[P4EST_DIM], p4est_qcoord_t self_coords[P4EST_DIM]); ``` """ -function t8_cmesh_from_tetgen_file(fileprefix, partition, comm, do_dup) - @ccall libt8.t8_cmesh_from_tetgen_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint)::t8_cmesh_t +function p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + @ccall libp4est.p4est_neighbor_transform_coordinates_reverse(nt::Ptr{p4est_neighbor_transform_t}, neigh_coords::Ptr{p4est_qcoord_t}, self_coords::Ptr{p4est_qcoord_t})::Cvoid end """ - t8_cmesh_from_tetgen_file_time(fileprefix, partition, comm, do_dup, fi, snapshot, stats, statentry) + p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + +Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects +# Arguments +* `conn`:\\[in\\] Connectivity structure. +* `tree_id`:\\[in\\] The number of the tree. +* `boundary_type`:\\[in\\] The type of the boundary connection (self, face, corner). +* `boundary_index`:\\[in\\] The index of the boundary. +* `neighbor_transform_array`:\\[in,out\\] Array of the neighbor transforms. ### Prototype ```c -t8_cmesh_t t8_cmesh_from_tetgen_file_time (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup, sc_flopinfo_t *fi, sc_flopinfo_t *snapshot, sc_statinfo_t *stats, int statentry); +void p4est_connectivity_get_neighbor_transforms (p4est_connectivity_t *conn, p4est_topidx_t tree_id, p4est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array); ``` """ -function t8_cmesh_from_tetgen_file_time(fileprefix, partition, comm, do_dup, fi, snapshot, stats, statentry) - @ccall libt8.t8_cmesh_from_tetgen_file_time(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint, fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t}, stats::Ptr{sc_statinfo_t}, statentry::Cint)::t8_cmesh_t +function p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + @ccall libp4est.p4est_connectivity_get_neighbor_transforms(conn::Ptr{p4est_connectivity_t}, tree_id::p4est_topidx_t, boundary_type::p4est_connect_type_t, boundary_index::Cint, neighbor_transform_array::Ptr{sc_array_t})::Cvoid end """ - t8_cmesh_from_triangle_file(fileprefix, partition, comm, do_dup) + p4est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) +Determine the owning tree for a coordinate and transform it there. + +On a boundary between trees, different coordinate systems meet. A coordinate on a tree boundary face or corner generated from the perspective of a specific tree may be transformed into any other touching tree's coordinate system and still refer to the same point in the mesh. + +To uniquely identify a coordinate, this function identifies the lowest numbered tree touching this coordinate and transforms the coordinates into that system. The result can be used e. g. in topology hash tables. + +# Arguments +* `conn`:\\[in\\] A valid connectivity. +* `treeid`:\\[in\\] The original tree index for this coordinate tuple. +* `coords`:\\[in\\] A valid coordinate 2-tuple relative to *treeid*. +* `treeid_out`:\\[out\\] The lowest tree index touching the coordinate. +* `coords_out`:\\[out\\] The input coordinates, if necessary after transformation into the system of the lowest numbered tree, returned in *treeid_out*. ### Prototype ```c -t8_cmesh_t t8_cmesh_from_triangle_file (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup); +void p4est_connectivity_coordinates_canonicalize (p4est_connectivity_t *conn, p4est_topidx_t treeid, const p4est_qcoord_t coords[], p4est_topidx_t *treeid_out, p4est_qcoord_t coords_out[]); ``` """ -function t8_cmesh_from_triangle_file(fileprefix, partition, comm, do_dup) - @ccall libt8.t8_cmesh_from_triangle_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint)::t8_cmesh_t +function p4est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) + @ccall libp4est.p4est_connectivity_coordinates_canonicalize(conn::Ptr{p4est_connectivity_t}, treeid::p4est_topidx_t, coords::Ptr{p4est_qcoord_t}, treeid_out::Ptr{p4est_topidx_t}, coords_out::Ptr{p4est_qcoord_t})::Cvoid end """ - t8_eclass_count_boundary(theclass, min_dim, per_eclass) + p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) -Query the element class and count of boundary points. +Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. # Arguments -* `theclass`:\\[in\\] We query a point of this element class. -* `min_dim`:\\[in\\] Ignore boundary points of lesser dimension. The ignored points get a count value of 0. -* `per_eclass`:\\[out\\] Array of length T8\\_ECLASS\\_COUNT to be filled with the count of the boundary objects, counted per each of the element classes. +* `fc`:\\[in\\] A face corner number in 0..1. +* `f`:\\[in\\] A face that the face corner number *fc* is relative to. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. # Returns -The count over all boundary points. +The face corner number relative to the neighbor's face. ### Prototype ```c -int t8_eclass_count_boundary (t8_eclass_t theclass, int min_dim, int *per_eclass); +int p4est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); ``` """ -function t8_eclass_count_boundary(theclass, min_dim, per_eclass) - @ccall libt8.t8_eclass_count_boundary(theclass::t8_eclass_t, min_dim::Cint, per_eclass::Ptr{Cint})::Cint +function p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + @ccall libp4est.p4est_connectivity_face_neighbor_face_corner(fc::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_eclass_compare(eclass1, eclass2) + p4est_connectivity_face_neighbor_corner(c, f, nf, o) -Compare two eclasses of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. +Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. # Arguments -* `eclass1`:\\[in\\] The first eclass to compare. -* `eclass2`:\\[in\\] The second eclass to compare. +* `c`:\\[in\\] A corner number in 0..3. +* `f`:\\[in\\] A face number that touches the corner *c*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. # Returns -0 if the eclasses are equal, 1 if eclass1 > eclass2 and -1 if eclass1 < eclass2 +The number of the corner seen from the neighbor tree. ### Prototype ```c -int t8_eclass_compare (t8_eclass_t eclass1, t8_eclass_t eclass2); +int p4est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); ``` """ -function t8_eclass_compare(eclass1, eclass2) - @ccall libt8.t8_eclass_compare(eclass1::t8_eclass_t, eclass2::t8_eclass_t)::Cint +function p4est_connectivity_face_neighbor_corner(c, f, nf, o) + @ccall libp4est.p4est_connectivity_face_neighbor_corner(c::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_eclass_is_valid(eclass) + p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) -Check whether a class is a valid class. Returns non-zero if it is a valid class, returns zero, if the class is equal to T8\\_ECLASS\\_INVALID. +Allocate a connectivity structure. The attribute fields are initialized to NULL. # Arguments -* `eclass`:\\[in\\] The eclass to check. +* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). +* `num_trees`:\\[in\\] Number of trees in the forest. +* `num_corners`:\\[in\\] Number of tree-connecting corners. +* `num_ctt`:\\[in\\] Number of total trees in corner\\_to\\_tree array. # Returns -Non-zero if *eclass* is valid, zero otherwise. +A connectivity structure with allocated arrays. ### Prototype ```c -int t8_eclass_is_valid (t8_eclass_t eclass); +p4est_connectivity_t *p4est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, p4est_topidx_t num_ctt); ``` """ -function t8_eclass_is_valid(eclass) - @ccall libt8.t8_eclass_is_valid(eclass::t8_eclass_t)::Cint +function p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) + @ccall libp4est.p4est_connectivity_new(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_corners::p4est_topidx_t, num_ctt::p4est_topidx_t)::Ptr{p4est_connectivity_t} end -mutable struct t8_element end - -"""Opaque structure for a generic element, only used as pointer. Implementations are free to cast it to their internal data structure.""" -const t8_element_t = t8_element - """ - t8_scheme_cxx_ref(scheme) + p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) -Increase the reference counter of a scheme. +Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. # Arguments -* `scheme`:\\[in,out\\] On input, this scheme must be alive, that is, exist with positive reference count. +* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). +* `num_trees`:\\[in\\] Number of trees in the forest. +* `num_corners`:\\[in\\] Number of tree-connecting corners. +* `vertices`:\\[in\\] Coordinates of the vertices of the trees. +* `ttv`:\\[in\\] The tree-to-vertex array. +* `ttt`:\\[in\\] The tree-to-tree array. +* `ttf`:\\[in\\] The tree-to-face array (int8\\_t). +* `ttc`:\\[in\\] The tree-to-corner array. +* `coff`:\\[in\\] Corner-to-tree offsets (num\\_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. +* `ctt`:\\[in\\] The corner-to-tree array. +* `ctc`:\\[in\\] The corner-to-corner array. +# Returns +The connectivity is checked for validity. ### Prototype ```c -void t8_scheme_cxx_ref (t8_scheme_cxx_t *scheme); +p4est_connectivity_t *p4est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc); ``` """ -function t8_scheme_cxx_ref(scheme) - @ccall libt8.t8_scheme_cxx_ref(scheme::Ptr{t8_scheme_cxx_t})::Cvoid +function p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) + @ccall libp4est.p4est_connectivity_new_copy(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_corners::p4est_topidx_t, vertices::Ptr{Cdouble}, ttv::Ptr{p4est_topidx_t}, ttt::Ptr{p4est_topidx_t}, ttf::Ptr{Int8}, ttc::Ptr{p4est_topidx_t}, coff::Ptr{p4est_topidx_t}, ctt::Ptr{p4est_topidx_t}, ctc::Ptr{Int8})::Ptr{p4est_connectivity_t} end """ - t8_scheme_cxx_unref(pscheme) + p4est_connectivity_copy(input, copy_attr) -Decrease the reference counter of a scheme. If the counter reaches zero, this scheme is destroyed. +Deep copy a connectivity structure. # Arguments -* `pscheme`:\\[in,out\\] On input, the scheme pointed to must exist with positive reference count. If the reference count reaches zero, the scheme is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the scheme is not modified in other ways. +* `input`:\\[in\\] Valid connectivity. +* `copy_attr`:\\[in\\] If true, we copy the tree attribute data. Otherwise, the result has empty attributes. +# Returns +A connectivity equal to the first one except, depending on *copy_attry*, for its attributes. ### Prototype ```c -void t8_scheme_cxx_unref (t8_scheme_cxx_t **pscheme); +p4est_connectivity_t *p4est_connectivity_copy (p4est_connectivity_t *input, int copy_attr); ``` """ -function t8_scheme_cxx_unref(pscheme) - @ccall libt8.t8_scheme_cxx_unref(pscheme::Ptr{Ptr{t8_scheme_cxx_t}})::Cvoid +function p4est_connectivity_copy(input, copy_attr) + @ccall libp4est.p4est_connectivity_copy(input::Ptr{p4est_connectivity_t}, copy_attr::Cint)::Ptr{p4est_connectivity_t} end """ - t8_scheme_cxx_destroy(s) + p4est_connectivity_bcast(conn_in, root, comm) ### Prototype ```c -extern void t8_scheme_cxx_destroy (t8_scheme_cxx_t *s); +p4est_connectivity_t *p4est_connectivity_bcast (p4est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); ``` """ -function t8_scheme_cxx_destroy(s) - @ccall libt8.t8_scheme_cxx_destroy(s::Ptr{t8_scheme_cxx_t})::Cvoid +function p4est_connectivity_bcast(conn_in, root, comm) + @ccall libp4est.p4est_connectivity_bcast(conn_in::Ptr{p4est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p4est_connectivity_t} end """ - t8_element_size(ts) + p4est_connectivity_destroy(connectivity) -Return the size of any element of a given class. +Destroy a connectivity structure. Also destroy all attributes. -# Returns -The size of an element of class **ts**. We provide a default implementation of this routine that should suffice for most use cases. ### Prototype ```c -size_t t8_element_size (const t8_eclass_scheme_c *ts); +void p4est_connectivity_destroy (p4est_connectivity_t * connectivity); ``` """ -function t8_element_size(ts) - @ccall libt8.t8_element_size(ts::Ptr{t8_eclass_scheme_c})::Csize_t +function p4est_connectivity_destroy(connectivity) + @ccall libp4est.p4est_connectivity_destroy(connectivity::Ptr{p4est_connectivity_t})::Cvoid end """ - t8_element_refines_irregular(ts) - -Returns true, if there is one element in the tree, that does not refine into 2^dim children. Returns false otherwise. + p4est_connectivity_share(conn_in, root, comm) ### Prototype ```c -int t8_element_refines_irregular (const t8_eclass_scheme_c *ts); +p4est_connectivity_shared_t *p4est_connectivity_share (p4est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); ``` """ -function t8_element_refines_irregular(ts) - @ccall libt8.t8_element_refines_irregular(ts::Ptr{t8_eclass_scheme_c})::Cint +function p4est_connectivity_share(conn_in, root, comm) + @ccall libp4est.p4est_connectivity_share(conn_in::Ptr{p4est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p4est_connectivity_shared_t} end """ - t8_element_maxlevel(ts) + p4est_connectivity_mission(conn_in, split_type, world_comm) -Return the maximum allowed level for any element of a given class. - -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -# Returns -The maximum allowed level for elements of class **ts**. ### Prototype ```c -int t8_element_maxlevel (const t8_eclass_scheme_c *ts); +p4est_connectivity_shared_t * p4est_connectivity_mission (p4est_connectivity_t *conn_in, int split_type, sc_MPI_Comm world_comm); ``` """ -function t8_element_maxlevel(ts) - @ccall libt8.t8_element_maxlevel(ts::Ptr{t8_eclass_scheme_c})::Cint +function p4est_connectivity_mission(conn_in, split_type, world_comm) + @ccall libp4est.p4est_connectivity_mission(conn_in::Ptr{p4est_connectivity_t}, split_type::Cint, world_comm::Cint)::Ptr{p4est_connectivity_shared_t} end """ - t8_element_level(ts, elem) + p4est_connectivity_shared_destroy(cshare) + +Destroy a shared connectivity structure. Call this eventually on the result of p4est_connectivity_share or p4est_connectivity_mission (which calls the former internally). +# Arguments +* `cshare`:\\[in\\] Valid shared connectivity structure; cf. p4est_connectivity_share. ### Prototype ```c -int t8_element_level (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +void p4est_connectivity_shared_destroy (p4est_connectivity_shared_t *cshare); ``` """ -function t8_element_level(ts, elem) - @ccall libt8.t8_element_level(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_connectivity_shared_destroy(cshare) + @ccall libp4est.p4est_connectivity_shared_destroy(cshare::Ptr{p4est_connectivity_shared_t})::Cvoid end """ - t8_element_copy(ts, source, dest) - -Copy all entries of **source** to **dest**. **dest** must be an existing element. No memory is allocated by this function. - -!!! note + p4est_connectivity_set_attr(conn, bytes_per_tree) - *source* and *dest* may point to the same element. +Allocate or free the attribute fields in a connectivity. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `source`:\\[in\\] The element whose entries will be copied to **dest**. -* `dest`:\\[in,out\\] This element's entries will be overwritten with the entries of **source**. +* `conn`:\\[in,out\\] The conn->*\\_to\\_attr fields must either be NULL or previously be allocated by this function. +* `bytes_per_tree`:\\[in\\] If 0, tree\\_to\\_attr is freed (being NULL is ok). If positive, requested space is allocated. ### Prototype ```c -void t8_element_copy (const t8_eclass_scheme_c *ts, const t8_element_t *source, t8_element_t *dest); +void p4est_connectivity_set_attr (p4est_connectivity_t * conn, size_t bytes_per_tree); ``` """ -function t8_element_copy(ts, source, dest) - @ccall libt8.t8_element_copy(ts::Ptr{t8_eclass_scheme_c}, source::Ptr{t8_element_t}, dest::Ptr{t8_element_t})::Cvoid +function p4est_connectivity_set_attr(conn, bytes_per_tree) + @ccall libp4est.p4est_connectivity_set_attr(conn::Ptr{p4est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid end """ - t8_element_compare(ts, elem1, elem2) + p4est_connectivity_is_valid(connectivity) -Compare two elements with respect to the scheme. +Examine a connectivity structure. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem1`:\\[in\\] The first element. -* `elem2`:\\[in\\] The second element. # Returns -negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. If elem2 is a copy of elem1 then the elements are equal. +Returns true if structure is valid, false otherwise. ### Prototype ```c -int t8_element_compare (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2); +int p4est_connectivity_is_valid (p4est_connectivity_t * connectivity); ``` """ -function t8_element_compare(ts, elem1, elem2) - @ccall libt8.t8_element_compare(ts::Ptr{t8_eclass_scheme_c}, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint +function p4est_connectivity_is_valid(connectivity) + @ccall libp4est.p4est_connectivity_is_valid(connectivity::Ptr{p4est_connectivity_t})::Cint end """ - t8_element_equal(ts, elem1, elem2) + p4est_connectivity_is_equal(conn1, conn2) -Check if two elements are equal. +Check two connectivity structures for equality. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem1`:\\[in\\] The first element. -* `elem2`:\\[in\\] The second element. # Returns -1 if the elements are equal, 0 if they are not equal +Returns true if structures are equal, false otherwise. ### Prototype ```c -int t8_element_equal (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2); +int p4est_connectivity_is_equal (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); ``` """ -function t8_element_equal(ts, elem1, elem2) - @ccall libt8.t8_element_equal(ts::Ptr{t8_eclass_scheme_c}, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint +function p4est_connectivity_is_equal(conn1, conn2) + @ccall libp4est.p4est_connectivity_is_equal(conn1::Ptr{p4est_connectivity_t}, conn2::Ptr{p4est_connectivity_t})::Cint end """ - t8_element_parent(ts, elem, parent) + p4est_connectivity_sink(conn, sink) -Compute the parent of a given element **elem** and store it in **parent**. **parent** needs to be an existing element. No memory is allocated by this function. **elem** and **parent** can point to the same element, then the entries of **elem** are overwritten by the ones of its parent. +Write connectivity to a sink object. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element whose parent will be computed. -* `parent`:\\[in,out\\] This element's entries will be overwritten by those of **elem**'s parent. The storage for this element must exist and match the element class of the parent. +* `conn`:\\[in\\] The connectivity to be written. +* `sink`:\\[in,out\\] The connectivity is written into this sink. +# Returns +0 on success, nonzero on error. ### Prototype ```c -void t8_element_parent (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *parent); +int p4est_connectivity_sink (p4est_connectivity_t * conn, sc_io_sink_t * sink); ``` """ -function t8_element_parent(ts, elem, parent) - @ccall libt8.t8_element_parent(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, parent::Ptr{t8_element_t})::Cvoid +function p4est_connectivity_sink(conn, sink) + @ccall libp4est.p4est_connectivity_sink(conn::Ptr{p4est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint end """ - t8_element_num_siblings(ts, elem) + p4est_connectivity_deflate(conn, code) -Compute the number of siblings of an element. That is the number of Children of its parent. +Allocate memory and store the connectivity information there. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. +* `conn`:\\[in\\] The connectivity structure to be exported to memory. +* `code`:\\[in\\] Encoding and compression method for serialization. # Returns -The number of siblings of *element*. Note that this number is >= 1, since we count the element itself as a sibling. +Newly created array that contains the information. ### Prototype ```c -int t8_element_num_siblings (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +sc_array_t *p4est_connectivity_deflate (p4est_connectivity_t * conn, p4est_connectivity_encode_t code); ``` """ -function t8_element_num_siblings(ts, elem) - @ccall libt8.t8_element_num_siblings(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_connectivity_deflate(conn, code) + @ccall libp4est.p4est_connectivity_deflate(conn::Ptr{p4est_connectivity_t}, code::p4est_connectivity_encode_t)::Ptr{sc_array_t} end """ - t8_element_sibling(ts, elem, sibid, sibling) + p4est_connectivity_save(filename, connectivity) -Compute a specific sibling of a given element **elem** and store it in **sibling**. **sibling** needs to be an existing element. No memory is allocated by this function. **elem** and **sibling** can point to the same element, then the entries of **elem** are overwritten by the ones of its i-th sibling. +Save a connectivity structure to disk. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element whose sibling will be computed. -* `sibid`:\\[in\\] The id of the sibling computed. -* `sibling`:\\[in,out\\] This element's entries will be overwritten by those of **elem**'s sibid-th sibling. The storage for this element must exist and match the element class of the sibling. +* `filename`:\\[in\\] Name of the file to write. +* `connectivity`:\\[in\\] Valid connectivity structure. +# Returns +Returns 0 on success, nonzero on file error. ### Prototype ```c -void t8_element_sibling (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int sibid, t8_element_t *sibling); +int p4est_connectivity_save (const char *filename, p4est_connectivity_t * connectivity); ``` """ -function t8_element_sibling(ts, elem, sibid, sibling) - @ccall libt8.t8_element_sibling(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, sibid::Cint, sibling::Ptr{t8_element_t})::Cvoid +function p4est_connectivity_save(filename, connectivity) + @ccall libp4est.p4est_connectivity_save(filename::Cstring, connectivity::Ptr{p4est_connectivity_t})::Cint end """ - t8_element_num_corners(ts, elem) + p4est_connectivity_source(source) -Compute the number of corners of an element. +Read connectivity from a source object. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. +* `source`:\\[in,out\\] The connectivity is read from this source. # Returns -The number of corners of *element*. +The newly created connectivity, or NULL on error. ### Prototype ```c -int t8_element_num_corners (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +p4est_connectivity_t *p4est_connectivity_source (sc_io_source_t * source); ``` """ -function t8_element_num_corners(ts, elem) - @ccall libt8.t8_element_num_corners(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_connectivity_source(source) + @ccall libp4est.p4est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p4est_connectivity_t} end """ - t8_element_num_faces(ts, elem) + p4est_connectivity_inflate(buffer) -Compute the number of faces of an element. +Create new connectivity from a memory buffer. This function aborts on malloc errors. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. +* `buffer`:\\[in\\] The connectivity is created from this memory buffer. # Returns -The number of faces of *element*. +The newly created connectivity, or NULL on format error of the buffered connectivity data. ### Prototype ```c -int t8_element_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +p4est_connectivity_t *p4est_connectivity_inflate (sc_array_t * buffer); ``` """ -function t8_element_num_faces(ts, elem) - @ccall libt8.t8_element_num_faces(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_connectivity_inflate(buffer) + @ccall libp4est.p4est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p4est_connectivity_t} end """ - t8_element_max_num_faces(ts, elem) + p4est_connectivity_load(filename, bytes) -Compute the maximum number of faces of a given element and all of its descendants. +Load a connectivity structure from disk. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. +* `filename`:\\[in\\] Name of the file to read. +* `bytes`:\\[in,out\\] Size in bytes of connectivity on disk or NULL. # Returns -The number of faces of *element*. +Returns valid connectivity, or NULL on file error. ### Prototype ```c -int t8_element_max_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +p4est_connectivity_t *p4est_connectivity_load (const char *filename, size_t *bytes); ``` """ -function t8_element_max_num_faces(ts, elem) - @ccall libt8.t8_element_max_num_faces(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_connectivity_load(filename, bytes) + @ccall libp4est.p4est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p4est_connectivity_t} end """ - t8_element_num_children(ts, elem) + p4est_connectivity_new_unitsquare() -Compute the number of children of an element when it is refined. +Create a connectivity structure for the unit square. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -# Returns -The number of children of *element*. ### Prototype ```c -int t8_element_num_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +p4est_connectivity_t *p4est_connectivity_new_unitsquare (void); ``` """ -function t8_element_num_children(ts, elem) - @ccall libt8.t8_element_num_children(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_connectivity_new_unitsquare() + @ccall libp4est.p4est_connectivity_new_unitsquare()::Ptr{p4est_connectivity_t} end """ - t8_element_num_face_children(ts, elem, face) + p4est_connectivity_new_periodic() -Compute the number of children of an element's face when the element is refined. +Create a connectivity structure for an all-periodic unit square. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] A face of *elem*. -# Returns -The number of children of *face* if *elem* is to be refined. ### Prototype ```c -int t8_element_num_face_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +p4est_connectivity_t *p4est_connectivity_new_periodic (void); ``` """ -function t8_element_num_face_children(ts, elem, face) - @ccall libt8.t8_element_num_face_children(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::Cint +function p4est_connectivity_new_periodic() + @ccall libp4est.p4est_connectivity_new_periodic()::Ptr{p4est_connectivity_t} end """ - t8_element_get_face_corner(ts, elem, face, corner) - -Return the corner number of an element's face corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 Thus for face = 1 the output is: corner=0 : 1, corner=1: 3 + p4est_connectivity_new_rotwrap() -The order in which the corners must be given is determined by the eclass of *element*: LINE/QUAD/TRIANGLE: No specific order. HEX : In Z-order of the face starting with the lowest corner number. TET : Starting with the lowest corner number counterclockwise as seen from 'outside' of the element. +Create a connectivity structure for a periodic unit square. The left and right faces are identified, and bottom and top opposite. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `element`:\\[in\\] The element. -* `face`:\\[in\\] A face index for *element*. -* `corner`:\\[in\\] A corner index for the face 0 <= *corner* < num\\_face\\_corners. -# Returns -The corner number of the *corner*-th vertex of *face*. ### Prototype ```c -int t8_element_get_face_corner (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int corner); +p4est_connectivity_t *p4est_connectivity_new_rotwrap (void); ``` """ -function t8_element_get_face_corner(ts, elem, face, corner) - @ccall libt8.t8_element_get_face_corner(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint, corner::Cint)::Cint +function p4est_connectivity_new_rotwrap() + @ccall libp4est.p4est_connectivity_new_rotwrap()::Ptr{p4est_connectivity_t} end """ - t8_element_get_corner_face(ts, elem, corner, face) + p4est_connectivity_new_circle() -Compute the face numbers of the faces sharing an element's corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 face 2 Thus for corner = 1 the output is: face=0 : 2, face=1: 1 +Create a connectivity structure for an donut-like circle. The circle consists of 6 trees connecting each other by their faces. The trees are laid out as a hexagon between [-2, 2] in the y direction and [-sqrt(3), sqrt(3)] in the x direction. The hexagon has flat sides along the y direction and pointy ends in x. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `element`:\\[in\\] The element. -* `corner`:\\[in\\] A corner index for the face. -* `face`:\\[in\\] A face index for *corner*. -# Returns -The face number of the *face*-th face at *corner*. ### Prototype ```c -int t8_element_get_corner_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int corner, int face); +p4est_connectivity_t *p4est_connectivity_new_circle (void); ``` """ -function t8_element_get_corner_face(ts, elem, corner, face) - @ccall libt8.t8_element_get_corner_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, corner::Cint, face::Cint)::Cint +function p4est_connectivity_new_circle() + @ccall libp4est.p4est_connectivity_new_circle()::Ptr{p4est_connectivity_t} end """ - t8_element_child(ts, elem, childid, child) + p4est_connectivity_new_drop() -Construct the child element of a given number. +Create a connectivity structure for a five-trees geometry with a hole. The geometry covers the square [0, 3]**2, where the hole is [1, 2]**2. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] This must be a valid element, bigger than maxlevel. -* `childid`:\\[in\\] The number of the child to construct. -* `child`:\\[in,out\\] The storage for this element must exist. On output, a valid element. It is valid to call this function with elem = child. ### Prototype ```c -void t8_element_child (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int childid, t8_element_t *child); +p4est_connectivity_t *p4est_connectivity_new_drop (void); ``` """ -function t8_element_child(ts, elem, childid, child) - @ccall libt8.t8_element_child(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, childid::Cint, child::Ptr{t8_element_t})::Cvoid +function p4est_connectivity_new_drop() + @ccall libp4est.p4est_connectivity_new_drop()::Ptr{p4est_connectivity_t} end """ - t8_element_children(ts, elem, length, c) + p4est_connectivity_new_twotrees(l_face, r_face, orientation) -Construct all children of a given element. +Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] This must be a valid element, bigger than maxlevel. -* `length`:\\[in\\] The length of the output array *c* must match the number of children. -* `c`:\\[in,out\\] The storage for these *length* elements must exist and match the element class in the children's ordering. On output, all children are valid. It is valid to call this function with elem = c[0]. -# See also -[`t8_element_num_children`](@ref) - +* `l_face`:\\[in\\] index of left face +* `r_face`:\\[in\\] index of right face +* `orientation`:\\[in\\] orientation of trees w.r.t. each other ### Prototype ```c -void t8_element_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int length, t8_element_t *c[]); +p4est_connectivity_t *p4est_connectivity_new_twotrees (int l_face, int r_face, int orientation); ``` """ -function t8_element_children(ts, elem, length, c) - @ccall libt8.t8_element_children(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, length::Cint, c::Ptr{Ptr{t8_element_t}})::Cvoid +function p4est_connectivity_new_twotrees(l_face, r_face, orientation) + @ccall libp4est.p4est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p4est_connectivity_t} end """ - t8_element_child_id(ts, elem) + p4est_connectivity_new_corner() -Compute the child id of an element. +Create a connectivity structure for a three-tree mesh around a corner. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] This must be a valid element. -# Returns -The child id of elem. ### Prototype ```c -int t8_element_child_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +p4est_connectivity_t *p4est_connectivity_new_corner (void); ``` """ -function t8_element_child_id(ts, elem) - @ccall libt8.t8_element_child_id(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_connectivity_new_corner() + @ccall libp4est.p4est_connectivity_new_corner()::Ptr{p4est_connectivity_t} end """ - t8_element_ancestor_id(ts, elem, level) + p4est_connectivity_new_pillow() -Compute the ancestor id of an element, that is the child id at a given level. +Create a connectivity structure for two trees on top of each other. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] This must be a valid element. -* `level`:\\[in\\] A refinement level. Must satisfy *level* < elem.level -# Returns -The child\\_id of *elem* in regard to its *level* ancestor. ### Prototype ```c -int t8_element_ancestor_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int level); +p4est_connectivity_t *p4est_connectivity_new_pillow (void); ``` """ -function t8_element_ancestor_id(ts, elem, level) - @ccall libt8.t8_element_ancestor_id(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, level::Cint)::Cint +function p4est_connectivity_new_pillow() + @ccall libp4est.p4est_connectivity_new_pillow()::Ptr{p4est_connectivity_t} end """ - t8_element_is_family(ts, fam) + p4est_connectivity_new_moebius() -Query whether a given set of elements is a family or not. +Create a connectivity structure for a five-tree moebius band. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `fam`:\\[in\\] An array of as many elements as an element of class **ts** has children. -# Returns -Zero if **fam** is not a family, nonzero if it is. ### Prototype ```c -int t8_element_is_family (const t8_eclass_scheme_c *ts, t8_element_t *const *fam); +p4est_connectivity_t *p4est_connectivity_new_moebius (void); ``` """ -function t8_element_is_family(ts, fam) - @ccall libt8.t8_element_is_family(ts::Ptr{t8_eclass_scheme_c}, fam::Ptr{Ptr{t8_element_t}})::Cint +function p4est_connectivity_new_moebius() + @ccall libp4est.p4est_connectivity_new_moebius()::Ptr{p4est_connectivity_t} end """ - t8_element_nca(ts, elem1, elem2, nca) + p4est_connectivity_new_star() -Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both given elements as descendants. +Create a connectivity structure for a six-tree star. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem1`:\\[in\\] The first of the two input elements. -* `elem2`:\\[in\\] The second of the two input elements. -* `nca`:\\[in,out\\] The storage for this element must exist and match the element class of the child. On output the unique nearest common ancestor of **elem1** and **elem2**. ### Prototype ```c -void t8_element_nca (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca); +p4est_connectivity_t *p4est_connectivity_new_star (void); ``` """ -function t8_element_nca(ts, elem1, elem2, nca) - @ccall libt8.t8_element_nca(ts::Ptr{t8_eclass_scheme_c}, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t}, nca::Ptr{t8_element_t})::Cvoid +function p4est_connectivity_new_star() + @ccall libp4est.p4est_connectivity_new_star()::Ptr{p4est_connectivity_t} end -"""Type definition for the geometric shape of an element. Currently the possible shapes are the same as the possible element classes. I.e. T8\\_ECLASS\\_VERTEX, T8\\_ECLASS\\_TET, etc...""" -const t8_element_shape_t = t8_eclass_t - """ - t8_element_face_shape(ts, elem, face) - -Compute the shape of the face of an element. + p4est_connectivity_new_cubed() -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] A face of *elem*. -# Returns -The element shape of the face. I.e. T8\\_ECLASS\\_LINE for quads, T8\\_ECLASS\\_TRIANGLE for tets and depending on the face number either T8\\_ECLASS\\_QUAD or T8\\_ECLASS\\_TRIANGLE for prisms. -### Prototype -```c -t8_element_shape_t t8_element_face_shape (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); -``` -""" -function t8_element_face_shape(ts, elem, face) - @ccall libt8.t8_element_face_shape(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::t8_element_shape_t -end +Create a connectivity structure for the six sides of a unit cube. The ordering of the trees is as follows: -""" - t8_element_children_at_face(ts, elem, face, children, num_children, child_indices) +0 1 2 3 <-- 3: axis-aligned top side 4 5 -Given an element and a face of the element, compute all children of the element that touch the face. +This choice has been made for maximum symmetry (see tree\\_to\\_* in .c file). -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] A face of *elem*. -* `children`:\\[in,out\\] Allocated elements, in which the children of *elem* that share a face with *face* are stored. They will be stored in order of their linear id. -* `num_children`:\\[in\\] The number of elements in *children*. Must match the number of children that touch *face*. t8_element_num_face_children -* `child_indices`:\\[in,out\\] If not NULL, an array of num\\_children integers must be given, on output its i-th entry is the child\\_id of the i-th face\\_child. It is valid to call this function with elem = children[0]. ### Prototype ```c -void t8_element_children_at_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, t8_element_t *children[], int num_children, int *child_indices); +p4est_connectivity_t *p4est_connectivity_new_cubed (void); ``` """ -function t8_element_children_at_face(ts, elem, face, children, num_children, child_indices) - @ccall libt8.t8_element_children_at_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint, children::Ptr{Ptr{t8_element_t}}, num_children::Cint, child_indices::Ptr{Cint})::Cvoid +function p4est_connectivity_new_cubed() + @ccall libp4est.p4est_connectivity_new_cubed()::Ptr{p4est_connectivity_t} end """ - t8_element_face_child_face(ts, elem, face, face_child) - -Given a face of an element and a child number of a child of that face, return the face number of the child of the element that matches the child face. + p4est_connectivity_new_disk_nonperiodic() -```c++ - x ---- x x x x ---- x - | | | | | | | <-- f - | | | x | x--x - | | | | | - x ---- x x x ---- x - elem face face_child Returns the face number f -``` +Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] Then number of the face. -* `face_child`:\\[in\\] A number 0 <= *face_child* < num\\_face\\_children, specifying a child of *elem* that shares a face with *face*. These children are counted in linear order. This coincides with the order of children from a call to t8_element_children_at_face. # Returns -The face number of the face of a child of *elem* that coincides with *face_child*. +Initialized and usable connectivity. ### Prototype ```c -int t8_element_face_child_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int face_child); +p4est_connectivity_t *p4est_connectivity_new_disk_nonperiodic (void); ``` """ -function t8_element_face_child_face(ts, elem, face, face_child) - @ccall libt8.t8_element_face_child_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint, face_child::Cint)::Cint +function p4est_connectivity_new_disk_nonperiodic() + @ccall libp4est.p4est_connectivity_new_disk_nonperiodic()::Ptr{p4est_connectivity_t} end """ - t8_element_face_parent_face(ts, elem, face) + p4est_connectivity_new_disk(periodic_a, periodic_b) -Given a face of an element return the face number of the parent of the element that matches the element's face. Or return -1 if no face of the parent matches the face. +Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2. !!! note - For the root element this function always returns *face*. + The API of this function has changed to accept two arguments. You can query the P4EST_CONN_DISK_PERIODIC to check whether the new version with the argument is in effect. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] Then number of the face. -# Returns -If *face* of *elem* is also a face of *elem*'s parent, the face number of this face. Otherwise -1. -### Prototype -```c -int t8_element_face_parent_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); -``` -""" -function t8_element_face_parent_face(ts, elem, face) - @ccall libt8.t8_element_face_parent_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::Cint -end +The ordering of the trees is as follows: -""" - t8_element_tree_face(ts, elem, face) +4 1 2 3 0 -Given an element and a face of this element. If the face lies on the tree boundary, return the face number of the tree face. If not the return value is arbitrary. +The outside x faces may be identified topologically. The outside y faces may be identified topologically. Both identifications may be specified simultaneously. The general shape and periodicity are the same as those obtained with p4est_connectivity_new_brick (1, 1, periodic\\_a, periodic\\_b). + +When setting *periodic_a* and *periodic_b* to false, the result is the same as that of p4est_connectivity_new_disk_nonperiodic. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] The index of a face of *elem*. +* `periodic_a`:\\[in\\] Bool to make disk periodic in x direction. +* `periodic_b`:\\[in\\] Bool to make disk periodic in y direction. # Returns -The index of the tree face that *face* is a subface of, if *face* is on a tree boundary. Any arbitrary integer if *is* not at a tree boundary. +Initialized and usable connectivity. ### Prototype ```c -int t8_element_tree_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +p4est_connectivity_t *p4est_connectivity_new_disk (int periodic_a, int periodic_b); ``` """ -function t8_element_tree_face(ts, elem, face) - @ccall libt8.t8_element_tree_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::Cint +function p4est_connectivity_new_disk(periodic_a, periodic_b) + @ccall libp4est.p4est_connectivity_new_disk(periodic_a::Cint, periodic_b::Cint)::Ptr{p4est_connectivity_t} end """ - t8_element_transform_face(ts, elem1, elem2, orientation, sign, is_smaller_face) + p4est_connectivity_new_icosahedron() -Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the trees and given the orientation of the tree connection, construct the face element of the respective tree neighbor that logically coincides with e but lies in the coordinate system of the neighbor tree. +Create a connectivity for mapping the sphere using an icosahedron. -!!! note +The regular icosadron is a polyhedron with 20 faces, each of which is an equilateral triangle. To build the p4est connectivity, we group faces 2 by 2 to from 10 quadrangles, and thus 10 trees. - *elem1* and *elem2* may point to the same element. +This connectivity is meant to be used together with p4est_geometry_new_icosahedron to map the sphere. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem1`:\\[in\\] The face element. -* `elem2`:\\[in,out\\] On return the face element *elem1* with respect to the coordinate system of the other tree. -* `orientation`:\\[in\\] The orientation of the tree-tree connection. -* `sign`:\\[in\\] Depending on the topological orientation of the two tree faces, either 0 (both faces have opposite orientation) or 1 (both faces have the same top. orientattion). t8_eclass_face_orientation -* `is_smaller_face`:\\[in\\] Flag to declare whether *elem1* belongs to the smaller face. A face f of tree T is smaller than f' of T' if either the eclass of T is smaller or if the classes are equal and f element\\_shape2 and -1 if element\\_shape1 < element\\_shape2 -### Prototype -```c -int t8_element_shape_compare (t8_element_shape_t element_shape1, t8_element_shape_t element_shape2); -``` +The edges are stored when they connect trees that are not already face neighbors at that specific edge. In this case tree\\_to\\_edge indexes into *ett_offset*. Otherwise the tree\\_to\\_edge entry must be -1 and this edge is ignored. If num\\_edges == 0, tree\\_to\\_edge and edge\\_to\\_* arrays are set to NULL. + +The arrays edge\\_to\\_* store a variable number of entries per edge. For edge e these are at position [ett\\_offset[e]]..[ett\\_offset[e+1]-1]. Their number for edge e is ett\\_offset[e+1] - ett\\_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge\\_to\\_* arrays is num\\_ett = ett\\_offset[num\\_edges]. The edge\\_to\\_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation. + +The corners are stored when they connect trees that are not already edge or face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. + +The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. + +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. + +!!! note + + If a connectivity implies natural connections between trees that are edge neighbors without being face neighbors, these edges shall be encoded explicitly in the connectivity. If a connectivity implies natural connections between trees that are corner neighbors without being edge or face neighbors, these corners shall be encoded explicitly in the connectivity. + +| Field | Note | +| :------------------- | :----------------------------------------------------------------------------------- | +| num\\_vertices | the number of vertices that define the *embedding* of the forest (not the topology) | +| num\\_trees | the number of trees | +| num\\_edges | the number of edges that help define the topology | +| num\\_corners | the number of corners that help define the topology | +| vertices | an array of size (3 * *num_vertices*) | +| tree\\_to\\_vertex | embed each tree into ```c++ R^3 ``` for e.g. visualization (see p8est\\_vtk.h) | +| tree\\_attr\\_bytes | bytes per tree in tree\\_to\\_attr | +| tree\\_to\\_attr | not touched by p4est | +| tree\\_to\\_tree | (6 * *num_trees*) neighbors across faces | +| tree\\_to\\_face | (6 * *num_trees*) face to face+orientation (see description) | +| tree\\_to\\_edge | (12 * *num_trees*) or NULL (see description) | +| ett\\_offset | edge to offset in *edge_to_tree* and *edge_to_edge* | +| edge\\_to\\_tree | list of trees that meet at an edge | +| edge\\_to\\_edge | list of tree-edges+orientations that meet at an edge (see description) | +| tree\\_to\\_corner | (8 * *num_trees*) or NULL (see description) | +| ctt\\_offset | corner to offset in *corner_to_tree* and *corner_to_corner* | +| corner\\_to\\_tree | list of trees that meet at a corner | +| corner\\_to\\_corner | list of tree-corners that meet at a corner | """ -function t8_element_shape_compare(element_shape1, element_shape2) - @ccall libt8.t8_element_shape_compare(element_shape1::t8_element_shape_t, element_shape2::t8_element_shape_t)::Cint +struct p8est_connectivity + num_vertices::p4est_topidx_t + num_trees::p4est_topidx_t + num_edges::p4est_topidx_t + num_corners::p4est_topidx_t + vertices::Ptr{Cdouble} + tree_to_vertex::Ptr{p4est_topidx_t} + tree_attr_bytes::Csize_t + tree_to_attr::Cstring + tree_to_tree::Ptr{p4est_topidx_t} + tree_to_face::Ptr{Int8} + tree_to_edge::Ptr{p4est_topidx_t} + ett_offset::Ptr{p4est_topidx_t} + edge_to_tree::Ptr{p4est_topidx_t} + edge_to_edge::Ptr{Int8} + tree_to_corner::Ptr{p4est_topidx_t} + ctt_offset::Ptr{p4est_topidx_t} + corner_to_tree::Ptr{p4est_topidx_t} + corner_to_corner::Ptr{Int8} end """ - t8_forest +This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible. -| Field | Note | -| :---------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| rc | Reference counter. | -| set\\_level | Level to use in new construction. | -| set\\_for\\_coarsening | Change partition to allow for one round of coarsening | -| cmesh | Coarse mesh to use. | -| scheme\\_cxx | Scheme for element types. | -| maxlevel | The maximum allowed refinement level for elements in this forest. | -| maxlevel\\_existing | If >= 0, the maximum occurring refinemnent level of a forest element. | -| do\\_dup | Communicator shall be duped. | -| dimension | Dimension inferred from **cmesh**. | -| incomplete\\_trees | Flag to check whether the forest has (potential) incomplete trees. A tree is incomplete if an element has been removed from it. Once an element got removed, the flag sets to 1 (true) and stays. For a committed forest this flag is either true on all ranks or false on all ranks. | -| set\\_from | Temporarily store source forest. | -| from\\_method | Method to derive from **set_from**. | -| set\\_adapt\\_fn | refinement and coarsen function. Called when **from_method** is set to [`T8_FOREST_FROM_ADAPT`](@ref). | -| set\\_adapt\\_recursive | Flag to decide whether coarsen and refine are carried out recursive | -| set\\_balance | Flag to decide whether to forest will be balance in t8_forest_commit. See t8_forest_set_balance. If 0, no balance. If 1 balance with repartitioning, if 2 balance without repartitioning, # See also [`t8_forest_balance`](@ref) | -| do\\_ghost | If True, a ghost layer will be created when the forest is committed. | -| ghost\\_type | If a ghost layer will be created, the type of neighbors that count as ghost. | -| ghost\\_algorithm | Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced 3 = top-down search and unbalanced. | -| user\\_data | Pointer for arbitrary user data. # See also [`t8_forest_set_user_data`](@ref). | -| user\\_function | Pointer for arbitrary user function. # See also [`t8_forest_set_user_function`](@ref). | -| t8code\\_data | Pointer for arbitrary data that is used internally. | -| committed | t8_forest_commit called? | -| mpisize | Number of MPI processes. | -| mpirank | Number of this MPI process. | -| first\\_local\\_tree | The global index of the first local tree on this process. If first\\_local\\_tree is larger than last\\_local\\_tree then this processor/forest is empty. See https://github.com/DLR-AMR/t8code/wiki/Tree-indexing | -| last\\_local\\_tree | The global index of the last local tree on this process. -1 if this processor is empty. | -| global\\_num\\_trees | The total number of global trees | -| ghosts | If not NULL, the ghost elements. # See also [`t8_forest_ghost`](@ref).h | -| element\\_offsets | If partitioned, for each process the global index of its first element. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | -| global\\_first\\_desc | If partitioned, for each process the linear id (at maxlevel) of its first element's first descendant. t8_element_set_linear_id. Stores 0 for empty processes. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | -| tree\\_offsets | If partitioned for each process the global index of its first local tree or -(first local tree) - 1 if the first tree on that process is shared. Since this is memory consuming we only construct it when needed. This array follows the same logic as *tree_offsets* in [`t8_cmesh_t`](@ref) | -| local\\_num\\_elements | Number of elements on this processor. | -| global\\_num\\_elements | Number of elements on all processors. | -| profile | If not NULL, runtimes and statistics about forest\\_commit are stored here. | -""" -# This struct is not supposed to be read and modified directly. -# Besides, there is a circular dependency with `t8_forest_t` -# leading to an error output by Julia. -mutable struct t8_forest end +The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. zyx is 000 001 010 011 100 101 110 111. For faces the order is -x +x -y +y -z +z. They are allocated [0][0]..[0][N-1]..[num\\_trees-1][0]..[num\\_trees-1][N-1]. where N is 6 for tree and face, 8 for corner, 12 for edge. If a face is on the physical boundary it must connect to itself. -"""Opaque pointer to a forest implementation.""" -const t8_forest_t = Ptr{t8_forest} +The values for tree\\_to\\_face are in 0..23 where ttf % 6 gives the face number and ttf / 6 the face orientation code. The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees in 0..5. Then the first face corner of the lower of my\\_face and other\\_face connects to a face corner numbered 0..3 in the higher of my\\_face and other\\_face. The face orientation is defined as this number. If my\\_face == other\\_face, treating either of both faces as the lower one leads to the same result. -""" - t8_forest_write_netcdf(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm) +It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. -### Prototype -```c -void t8_forest_write_netcdf (t8_forest_t forest, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm); -``` +The edges are stored when they connect trees that are not already face neighbors at that specific edge. In this case tree\\_to\\_edge indexes into *ett_offset*. Otherwise the tree\\_to\\_edge entry must be -1 and this edge is ignored. If num\\_edges == 0, tree\\_to\\_edge and edge\\_to\\_* arrays are set to NULL. + +The arrays edge\\_to\\_* store a variable number of entries per edge. For edge e these are at position [ett\\_offset[e]]..[ett\\_offset[e+1]-1]. Their number for edge e is ett\\_offset[e+1] - ett\\_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge\\_to\\_* arrays is num\\_ett = ett\\_offset[num\\_edges]. The edge\\_to\\_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation. + +The corners are stored when they connect trees that are not already edge or face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. + +The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. + +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. + +!!! note + + If a connectivity implies natural connections between trees that are edge neighbors without being face neighbors, these edges shall be encoded explicitly in the connectivity. If a connectivity implies natural connections between trees that are corner neighbors without being edge or face neighbors, these corners shall be encoded explicitly in the connectivity. """ -function t8_forest_write_netcdf(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm) - @ccall libt8.t8_forest_write_netcdf(forest::t8_forest_t, file_prefix::Cstring, file_title::Cstring, dim::Cint, num_extern_netcdf_vars::Cint, ext_variables::Ptr{Ptr{t8_netcdf_variable_t}}, comm::MPI_Comm)::Cvoid -end +const p8est_connectivity_t = p8est_connectivity """ - t8_forest_write_netcdf_ext(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm, netcdf_var_storage_mode, netcdf_var_mpi_access) + p8est_connectivity_shared -### Prototype -```c -void t8_forest_write_netcdf_ext (t8_forest_t forest, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm, int netcdf_var_storage_mode, int netcdf_var_mpi_access); -``` +| Field | Note | +| :---- | :--------------------------------------------------------- | +| conn | The members of this connectivity are MPI3 shared windows. | """ -function t8_forest_write_netcdf_ext(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm, netcdf_var_storage_mode, netcdf_var_mpi_access) - @ccall libt8.t8_forest_write_netcdf_ext(forest::t8_forest_t, file_prefix::Cstring, file_title::Cstring, dim::Cint, num_extern_netcdf_vars::Cint, ext_variables::Ptr{Ptr{t8_netcdf_variable_t}}, comm::MPI_Comm, netcdf_var_storage_mode::Cint, netcdf_var_mpi_access::Cint)::Cvoid +struct p8est_connectivity_shared + conn::Ptr{p8est_connectivity_t} + win_vertices::Cint + win_tree_to_vertex::Cint + win_tree_to_attr::Cint + win_tree_to_tree::Cint + win_tree_to_face::Cint + win_tree_to_edge::Cint + win_ett_offset::Cint + win_edge_to_tree::Cint + win_edge_to_edge::Cint + win_tree_to_corner::Cint + win_ctt_offset::Cint + win_corner_to_tree::Cint + win_corner_to_corner::Cint end +"""Management information for a connectivity shared by MPI3.""" +const p8est_connectivity_shared_t = p8est_connectivity_shared + """ - t8_mat_init_xrot(mat, angle) + p8est_connectivity_memory_used(conn) -Initialize given 3x3 matrix as rotation matrix around the x-axis with given angle. +Calculate memory usage of a connectivity structure. # Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. +* `conn`:\\[in\\] Connectivity structure. +# Returns +Memory used in bytes. ### Prototype ```c -static inline void t8_mat_init_xrot (double mat[3][3], const double angle); +size_t p8est_connectivity_memory_used (p8est_connectivity_t * conn); ``` """ -function t8_mat_init_xrot(mat, angle) - @ccall libt8.t8_mat_init_xrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function p8est_connectivity_memory_used(conn) + @ccall libp4est.p8est_connectivity_memory_used(conn::Ptr{p8est_connectivity_t})::Csize_t end """ - t8_mat_init_yrot(mat, angle) + p8est_edge_transform_t -Initialize given 3x3 matrix as rotation matrix around the y-axis with given angle. +Generic interface for transformations between a tree and any of its edge -# Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. -### Prototype -```c -static inline void t8_mat_init_yrot (double mat[3][3], const double angle); -``` +| Field | Note | +| :------ | :--------------------------------- | +| ntree | The number of the tree | +| nedge | The number of the edge | +| naxis | The 3 edge coordinate axes | +| nflip | The orientation of the edge | +| corners | The corners connected to the edge | """ -function t8_mat_init_yrot(mat, angle) - @ccall libt8.t8_mat_init_yrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +struct p8est_edge_transform_t + ntree::p4est_topidx_t + nedge::Int8 + naxis::NTuple{3, Int8} + nflip::Int8 + corners::Int8 end """ - t8_mat_init_zrot(mat, angle) + p8est_edge_info_t -Initialize given 3x3 matrix as rotation matrix around the z-axis with given angle. +Information about the neighbors of an edge -# Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. -### Prototype -```c -static inline void t8_mat_init_zrot (double mat[3][3], const double angle); -``` +| Field | Note | +| :---------------- | :---------------------------------------------- | +| iedge | The information of the edge | +| edge\\_transforms | The array of neighbors of the originating edge | """ -function t8_mat_init_zrot(mat, angle) - @ccall libt8.t8_mat_init_zrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +struct p8est_edge_info_t + iedge::Int8 + edge_transforms::sc_array_t end """ - t8_mat_mult_vec(mat, a, b) + p8est_corner_transform_t -Apply matrix-matrix multiplication: b = M*a. +Generic interface for transformations between a tree and any of its corner -# Arguments -* `mat`:\\[in\\] 3x3-matrix. -* `a`:\\[in\\] 3-vector. -* `b`:\\[in,out\\] 3-vector. -### Prototype -```c -static inline void t8_mat_mult_vec (const double mat[3][3], const double a[3], double b[3]); -``` +| Field | Note | +| :------ | :------------------------ | +| ntree | The number of the tree | +| ncorner | The number of the corner | """ -function t8_mat_mult_vec(mat, a, b) - @ccall libt8.t8_mat_mult_vec(mat::Ptr{NTuple{3, Cdouble}}, a::Ptr{Cdouble}, b::Ptr{Cdouble})::Cvoid +struct p8est_corner_transform_t + ntree::p4est_topidx_t + ncorner::Int8 end """ - t8_mat_mult_mat(A, B, C) + p8est_corner_info_t -Apply matrix-matrix multiplication: C = A*B. +Information about the neighbors of a corner -# Arguments -* `A`:\\[in\\] 3x3-matrix. -* `B`:\\[in\\] 3x3-matrix. -* `C`:\\[in\\] 3x3-matrix. -### Prototype -```c -static inline void t8_mat_mult_mat (const double A[3][3], const double B[3][3], double C[3][3]); -``` +| Field | Note | +| :------------------ | :------------------------------------------------ | +| icorner | The number of the originating corner | +| corner\\_transforms | The array of neighbors of the originating corner | """ -function t8_mat_mult_mat(A, B, C) - @ccall libt8.t8_mat_mult_mat(A::Ptr{NTuple{3, Cdouble}}, B::Ptr{NTuple{3, Cdouble}}, C::Ptr{NTuple{3, Cdouble}})::Cvoid +struct p8est_corner_info_t + icorner::p4est_topidx_t + corner_transforms::sc_array_t end -mutable struct t8_mesh end - -const t8_mesh_t = t8_mesh - """ - t8_mesh_new(dimension, Kglobal, Klocal) + p8est_neighbor_transform_t -*********************** preallocate ************************* +Generic interface for transformations between a tree and any of its neighbors -### Prototype -```c -t8_mesh_t * t8_mesh_new (int dimension, t8_gloidx_t Kglobal, t8_locidx_t Klocal); -``` +| Field | Note | +| :---------------- | :-------------------------------------------------------------------------- | +| neighbor\\_type | type of connection to neighbor | +| neighbor | neighbor tree index | +| index\\_self | index of interface from self's perspective | +| index\\_neighbor | index of interface from neighbor's perspective | +| perm | permutation of dimensions when transforming self coords to neighbor coords | +| sign | sign changes when transforming self coords to neighbor coords | +| origin\\_self | point on the interface from self's perspective | +| origin\\_neighbor | point on the interface from neighbor's perspective | """ -function t8_mesh_new(dimension, Kglobal, Klocal) - @ccall libt8.t8_mesh_new(dimension::Cint, Kglobal::t8_gloidx_t, Klocal::t8_locidx_t)::Ptr{t8_mesh_t} +struct p8est_neighbor_transform_t + neighbor_type::p8est_connect_type_t + neighbor::p4est_topidx_t + index_self::Int8 + index_neighbor::Int8 + perm::NTuple{3, Int8} + sign::NTuple{3, Int8} + origin_self::NTuple{3, p4est_qcoord_t} + origin_neighbor::NTuple{3, p4est_qcoord_t} end """ - t8_mesh_new_unitcube(theclass) + p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) -*********** all-in-one convenience constructors ************* +Transform from self's coordinate system to neighbor's coordinate system. +# Arguments +* `nt`:\\[in\\] A neighbor transform. +* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. +* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. ### Prototype ```c -t8_mesh_t * t8_mesh_new_unitcube (t8_eclass_t theclass); +void p8est_neighbor_transform_coordinates (const p8est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P8EST_DIM], p4est_qcoord_t neigh_coords[P8EST_DIM]); ``` """ -function t8_mesh_new_unitcube(theclass) - @ccall libt8.t8_mesh_new_unitcube(theclass::t8_eclass_t)::Ptr{t8_mesh_t} +function p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + @ccall libp4est.p8est_neighbor_transform_coordinates(nt::Ptr{p8est_neighbor_transform_t}, self_coords::Ptr{p4est_qcoord_t}, neigh_coords::Ptr{p4est_qcoord_t})::Cvoid end """ - t8_mesh_set_comm(mesh, comm) + p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) +Transform from neighbor's coordinate system to self's coordinate system. + +# Arguments +* `nt`:\\[in\\] A neighbor transform. +* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. +* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. ### Prototype ```c -void t8_mesh_set_comm (t8_mesh_t *mesh, sc_MPI_Comm comm); +void p8est_neighbor_transform_coordinates_reverse (const p8est_neighbor_transform_t * nt, const p4est_qcoord_t neigh_coords[P8EST_DIM], p4est_qcoord_t self_coords[P8EST_DIM]); ``` """ -function t8_mesh_set_comm(mesh, comm) - @ccall libt8.t8_mesh_set_comm(mesh::Ptr{t8_mesh_t}, comm::MPI_Comm)::Cvoid +function p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + @ccall libp4est.p8est_neighbor_transform_coordinates_reverse(nt::Ptr{p8est_neighbor_transform_t}, neigh_coords::Ptr{p4est_qcoord_t}, self_coords::Ptr{p4est_qcoord_t})::Cvoid end """ - t8_mesh_set_partition(mesh, enable) + p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) -Determine whether we partition in t8_mesh_build. Default true. +Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects +# Arguments +* `conn`:\\[in\\] Connectivity structure. +* `tree_id`:\\[in\\] The number of the tree. +* `boundary_type`:\\[in\\] Type of boundary connection (self, face, edge, corner). +* `boundary_index`:\\[in\\] The index of the boundary. +* `neighbor_transform_array`:\\[in,out\\] Array of the neighbor transforms. ### Prototype ```c -void t8_mesh_set_partition (t8_mesh_t *mesh, int enable); +void p8est_connectivity_get_neighbor_transforms (p8est_connectivity_t *conn, p4est_topidx_t tree_id, p8est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array); ``` """ -function t8_mesh_set_partition(mesh, enable) - @ccall libt8.t8_mesh_set_partition(mesh::Ptr{t8_mesh_t}, enable::Cint)::Cvoid +function p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + @ccall libp4est.p8est_connectivity_get_neighbor_transforms(conn::Ptr{p8est_connectivity_t}, tree_id::p4est_topidx_t, boundary_type::p8est_connect_type_t, boundary_index::Cint, neighbor_transform_array::Ptr{sc_array_t})::Cvoid end """ - t8_mesh_set_element(mesh, theclass, gloid, locid) + p8est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) -### Prototype -```c -void t8_mesh_set_element (t8_mesh_t *mesh, t8_eclass_t theclass, t8_gloidx_t gloid, t8_locidx_t locid); -``` -""" -function t8_mesh_set_element(mesh, theclass, gloid, locid) - @ccall libt8.t8_mesh_set_element(mesh::Ptr{t8_mesh_t}, theclass::t8_eclass_t, gloid::t8_gloidx_t, locid::t8_locidx_t)::Cvoid -end +Determine the owning tree for a coordinate and transform it there. -""" - t8_mesh_set_local_to_global(mesh, ltog_length, ltog) +On a boundary between trees, different coordinate systems meet. A coordinate on a tree boundary face, edge, or corner generated from the perspective of a specific tree may be transformed into any other touching tree's coordinate system and still refer to the same point in the mesh. +To uniquely identify a coordinate, this function identifies the lowest numbered tree touching this coordinate and transforms the coordinate into that system. The result can be used e. g. in topology hash tables. + +# Arguments +* `conn`:\\[in\\] A valid connectivity. +* `treeid`:\\[in\\] The original tree index for this coordinate tuple. +* `coords`:\\[in\\] A valid coordinate 2-tuple relative to *treeid*. +* `treeid_out`:\\[out\\] The lowest tree index touching the coordinate. +* `coords_out`:\\[out\\] The input coordinates, if necessary after transformation into the system of the lowest numbered tree, returned in *treeid_out*. ### Prototype ```c -void t8_mesh_set_local_to_global (t8_mesh_t *mesh, t8_locidx_t ltog_length, const t8_gloidx_t *ltog); +void p8est_connectivity_coordinates_canonicalize (p8est_connectivity_t *conn, p4est_topidx_t treeid, const p4est_qcoord_t coords[], p4est_topidx_t *treeid_out, p4est_qcoord_t coords_out[]); ``` """ -function t8_mesh_set_local_to_global(mesh, ltog_length, ltog) - @ccall libt8.t8_mesh_set_local_to_global(mesh::Ptr{t8_mesh_t}, ltog_length::t8_locidx_t, ltog::Ptr{t8_gloidx_t})::Cvoid +function p8est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) + @ccall libp4est.p8est_connectivity_coordinates_canonicalize(conn::Ptr{p8est_connectivity_t}, treeid::p4est_topidx_t, coords::Ptr{p4est_qcoord_t}, treeid_out::Ptr{p4est_topidx_t}, coords_out::Ptr{p4est_qcoord_t})::Cvoid end """ - t8_mesh_set_face(mesh, locid1, face1, locid2, face2, orientation) + p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) + +Transform a corner across one of the adjacent faces into a neighbor tree. It expects a face permutation index that has been precomputed. +# Arguments +* `c`:\\[in\\] A corner number in 0..7. +* `f`:\\[in\\] A face number that touches the corner *c*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `set`:\\[in\\] A value from *p8est_face_permutation_sets* that is obtained using *f*, *nf*, and a valid orientation: ref = p8est\\_face\\_permutation\\_refs[f][nf]; set = p8est\\_face\\_permutation\\_sets[ref][orientation]; +# Returns +The corner number in 0..7 seen from the other face. ### Prototype ```c -void t8_mesh_set_face (t8_mesh_t *mesh, t8_locidx_t locid1, int face1, t8_locidx_t locid2, int face2, int orientation); +int p8est_connectivity_face_neighbor_corner_set (int c, int f, int nf, int set); ``` """ -function t8_mesh_set_face(mesh, locid1, face1, locid2, face2, orientation) - @ccall libt8.t8_mesh_set_face(mesh::Ptr{t8_mesh_t}, locid1::t8_locidx_t, face1::Cint, locid2::t8_locidx_t, face2::Cint, orientation::Cint)::Cvoid +function p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) + @ccall libp4est.p8est_connectivity_face_neighbor_corner_set(c::Cint, f::Cint, nf::Cint, set::Cint)::Cint end """ - t8_mesh_set_element_vertices(mesh, locid, vids_length, vids) + p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + +Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +# Arguments +* `fc`:\\[in\\] A face corner number in 0..3. +* `f`:\\[in\\] A face that the face corner *fc* is relative to. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +# Returns +The face corner number relative to the neighbor's face. ### Prototype ```c -void t8_mesh_set_element_vertices (t8_mesh_t *mesh, t8_locidx_t locid, t8_locidx_t vids_length, const t8_locidx_t *vids); +int p8est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); ``` """ -function t8_mesh_set_element_vertices(mesh, locid, vids_length, vids) - @ccall libt8.t8_mesh_set_element_vertices(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t, vids_length::t8_locidx_t, vids::Ptr{t8_locidx_t})::Cvoid +function p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + @ccall libp4est.p8est_connectivity_face_neighbor_face_corner(fc::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_mesh_build(mesh) + p8est_connectivity_face_neighbor_corner(c, f, nf, o) -Setup a mesh and turn it into a usable object. +Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +# Arguments +* `c`:\\[in\\] A corner number in 0..7. +* `f`:\\[in\\] A face number that touches the corner *c*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +# Returns +The number of the corner seen from the neighbor tree. ### Prototype ```c -void t8_mesh_build (t8_mesh_t *mesh); +int p8est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); ``` """ -function t8_mesh_build(mesh) - @ccall libt8.t8_mesh_build(mesh::Ptr{t8_mesh_t})::Cvoid +function p8est_connectivity_face_neighbor_corner(c, f, nf, o) + @ccall libp4est.p8est_connectivity_face_neighbor_corner(c::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_mesh_get_comm(mesh) + p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) + +Transform a face-edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +# Arguments +* `fe`:\\[in\\] A face edge number in 0..3. +* `f`:\\[in\\] A face number that touches the edge *e*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +# Returns +The face edge number seen from the neighbor tree. ### Prototype ```c -sc_MPI_Comm t8_mesh_get_comm (t8_mesh_t *mesh); +int p8est_connectivity_face_neighbor_face_edge (int fe, int f, int nf, int o); ``` """ -function t8_mesh_get_comm(mesh) - @ccall libt8.t8_mesh_get_comm(mesh::Ptr{t8_mesh_t})::Cint +function p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) + @ccall libp4est.p8est_connectivity_face_neighbor_face_edge(fe::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_mesh_get_element_count(mesh, theclass) + p8est_connectivity_face_neighbor_edge(e, f, nf, o) +Transform an edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. + +# Arguments +* `e`:\\[in\\] A edge number in 0..11. +* `f`:\\[in\\] A face 0..5 that touches the edge *e*. +* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. +* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +# Returns +The edge's number seen from the neighbor. ### Prototype ```c -t8_locidx_t t8_mesh_get_element_count (t8_mesh_t *mesh, t8_eclass_t theclass); +int p8est_connectivity_face_neighbor_edge (int e, int f, int nf, int o); ``` """ -function t8_mesh_get_element_count(mesh, theclass) - @ccall libt8.t8_mesh_get_element_count(mesh::Ptr{t8_mesh_t}, theclass::t8_eclass_t)::t8_locidx_t +function p8est_connectivity_face_neighbor_edge(e, f, nf, o) + @ccall libp4est.p8est_connectivity_face_neighbor_edge(e::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - t8_mesh_get_element_class(mesh, locid) + p8est_connectivity_edge_neighbor_edge_corner(ec, o) + +Transform an edge corner across one of the adjacent edges into a neighbor tree. # Arguments -* `locid`:\\[in\\] The local number can specify a point of any dimension that is locally relevant. The points are ordered in reverse to the element classes in t8_eclass_t. The local index is cumulative in this order. +* `ec`:\\[in\\] An edge corner number in 0..1. +* `o`:\\[in\\] The orientation of a tree boundary edge connection. +# Returns +The edge corner number seen from the other tree. ### Prototype ```c -t8_locidx_t t8_mesh_get_element_class (t8_mesh_t *mesh, t8_locidx_t locid); +int p8est_connectivity_edge_neighbor_edge_corner (int ec, int o); ``` """ -function t8_mesh_get_element_class(mesh, locid) - @ccall libt8.t8_mesh_get_element_class(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t)::t8_locidx_t +function p8est_connectivity_edge_neighbor_edge_corner(ec, o) + @ccall libp4est.p8est_connectivity_edge_neighbor_edge_corner(ec::Cint, o::Cint)::Cint end """ - t8_mesh_get_element_locid(mesh, gloid) + p8est_connectivity_edge_neighbor_corner(c, e, ne, o) + +Transform a corner across one of the adjacent edges into a neighbor tree. This version expects the neighbor edge and orientation separately. +# Arguments +* `c`:\\[in\\] A corner number in 0..7. +* `e`:\\[in\\] An edge 0..11 that touches the corner *c*. +* `ne`:\\[in\\] A neighbor edge that is on the other side of *e*. +* `o`:\\[in\\] The orientation between tree boundary edges *e* and *ne*. +# Returns +Corner number seen from the neighbor. ### Prototype ```c -t8_locidx_t t8_mesh_get_element_locid (t8_mesh_t *mesh, t8_gloidx_t gloid); +int p8est_connectivity_edge_neighbor_corner (int c, int e, int ne, int o); ``` """ -function t8_mesh_get_element_locid(mesh, gloid) - @ccall libt8.t8_mesh_get_element_locid(mesh::Ptr{t8_mesh_t}, gloid::t8_gloidx_t)::t8_locidx_t +function p8est_connectivity_edge_neighbor_corner(c, e, ne, o) + @ccall libp4est.p8est_connectivity_edge_neighbor_corner(c::Cint, e::Cint, ne::Cint, o::Cint)::Cint end """ - t8_mesh_get_element_gloid(mesh, locid) + p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) +Allocate a connectivity structure. The attribute fields are initialized to NULL. + +# Arguments +* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). +* `num_trees`:\\[in\\] Number of trees in the forest. +* `num_edges`:\\[in\\] Number of tree-connecting edges. +* `num_ett`:\\[in\\] Number of total trees in edge\\_to\\_tree array. +* `num_corners`:\\[in\\] Number of tree-connecting corners. +* `num_ctt`:\\[in\\] Number of total trees in corner\\_to\\_tree array. +# Returns +A connectivity structure with allocated arrays. ### Prototype ```c -t8_gloidx_t t8_mesh_get_element_gloid (t8_mesh_t *mesh, t8_locidx_t locid); +p8est_connectivity_t *p8est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_ett, p4est_topidx_t num_corners, p4est_topidx_t num_ctt); ``` """ -function t8_mesh_get_element_gloid(mesh, locid) - @ccall libt8.t8_mesh_get_element_gloid(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t)::t8_gloidx_t +function p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) + @ccall libp4est.p8est_connectivity_new(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_ett::p4est_topidx_t, num_corners::p4est_topidx_t, num_ctt::p4est_topidx_t)::Ptr{p8est_connectivity_t} end """ - t8_mesh_get_element(mesh, locid) + p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) + +Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. +# Arguments +* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). +* `num_trees`:\\[in\\] Number of trees in the forest. +* `num_edges`:\\[in\\] Number of tree-connecting edges. +* `num_corners`:\\[in\\] Number of tree-connecting corners. +* `vertices`:\\[in\\] Coordinates of the vertices of the trees. +* `ttv`:\\[in\\] The tree-to-vertex array. +* `ttt`:\\[in\\] The tree-to-tree array. +* `ttf`:\\[in\\] The tree-to-face array (int8\\_t). +* `tte`:\\[in\\] The tree-to-edge array. +* `eoff`:\\[in\\] Edge-to-tree offsets (num\\_edges + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. +* `ett`:\\[in\\] The edge-to-tree array. +* `ete`:\\[in\\] The edge-to-edge array. +* `ttc`:\\[in\\] The tree-to-corner array. +* `coff`:\\[in\\] Corner-to-tree offsets (num\\_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. +* `ctt`:\\[in\\] The corner-to-tree array. +* `ctc`:\\[in\\] The corner-to-corner array. +# Returns +The connectivity is checked for validity. ### Prototype ```c -t8_element_t t8_mesh_get_element (t8_mesh_t *mesh, t8_locidx_t locid); +p8est_connectivity_t *p8est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * tte, const p4est_topidx_t * eoff, const p4est_topidx_t * ett, const int8_t * ete, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc); ``` """ -function t8_mesh_get_element(mesh, locid) - @ccall libt8.t8_mesh_get_element(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t)::t8_element_t +function p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) + @ccall libp4est.p8est_connectivity_new_copy(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_corners::p4est_topidx_t, vertices::Ptr{Cdouble}, ttv::Ptr{p4est_topidx_t}, ttt::Ptr{p4est_topidx_t}, ttf::Ptr{Int8}, tte::Ptr{p4est_topidx_t}, eoff::Ptr{p4est_topidx_t}, ett::Ptr{p4est_topidx_t}, ete::Ptr{Int8}, ttc::Ptr{p4est_topidx_t}, coff::Ptr{p4est_topidx_t}, ctt::Ptr{p4est_topidx_t}, ctc::Ptr{Int8})::Ptr{p8est_connectivity_t} end """ - t8_mesh_get_element_boundary(mesh, locid, length_boundary, elemid, orientation) + p8est_connectivity_copy(input, copy_attr) + +Deep copy a connectivity structure. +# Arguments +* `input`:\\[in\\] Valid connectivity. +* `copy_attr`:\\[in\\] If true, we copy the tree attribute data. Otherwise, the result has empty attributes. +# Returns +A connectivity equal to the first one except, depending on *copy_attry*, for its attributes. ### Prototype ```c -void t8_mesh_get_element_boundary (t8_mesh_t *mesh, t8_locidx_t locid, int length_boundary, t8_locidx_t *elemid, int *orientation); +p8est_connectivity_t *p8est_connectivity_copy (p8est_connectivity_t *input, int copy_attr); ``` """ -function t8_mesh_get_element_boundary(mesh, locid, length_boundary, elemid, orientation) - @ccall libt8.t8_mesh_get_element_boundary(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t, length_boundary::Cint, elemid::Ptr{t8_locidx_t}, orientation::Ptr{Cint})::Cvoid +function p8est_connectivity_copy(input, copy_attr) + @ccall libp4est.p8est_connectivity_copy(input::Ptr{p8est_connectivity_t}, copy_attr::Cint)::Ptr{p8est_connectivity_t} end """ - t8_mesh_get_maximum_support(mesh) - -Return the maximum of the length of the support of any local element. + p8est_connectivity_bcast(conn_in, root, comm) ### Prototype ```c -int t8_mesh_get_maximum_support (t8_mesh_t *mesh); +p8est_connectivity_t *p8est_connectivity_bcast (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); ``` """ -function t8_mesh_get_maximum_support(mesh) - @ccall libt8.t8_mesh_get_maximum_support(mesh::Ptr{t8_mesh_t})::Cint +function p8est_connectivity_bcast(conn_in, root, comm) + @ccall libp4est.p8est_connectivity_bcast(conn_in::Ptr{p8est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p8est_connectivity_t} end """ - t8_mesh_get_element_support(mesh, locid, length_support, elemid, orientation) + p8est_connectivity_destroy(connectivity) + +Destroy a connectivity structure. Also destroy all attributes. -# Arguments -* `length_support`:\\[in,out\\] ### Prototype ```c -void t8_mesh_get_element_support (t8_mesh_t *mesh, t8_locidx_t locid, int *length_support, t8_locidx_t *elemid, int *orientation); +void p8est_connectivity_destroy (p8est_connectivity_t * connectivity); ``` """ -function t8_mesh_get_element_support(mesh, locid, length_support, elemid, orientation) - @ccall libt8.t8_mesh_get_element_support(mesh::Ptr{t8_mesh_t}, locid::t8_locidx_t, length_support::Ptr{Cint}, elemid::Ptr{t8_locidx_t}, orientation::Ptr{Cint})::Cvoid +function p8est_connectivity_destroy(connectivity) + @ccall libp4est.p8est_connectivity_destroy(connectivity::Ptr{p8est_connectivity_t})::Cvoid end """ - t8_mesh_destroy(mesh) - -*************************** destruct ************************ + p8est_connectivity_share(conn_in, root, comm) ### Prototype ```c -void t8_mesh_destroy (t8_mesh_t *mesh); +p8est_connectivity_shared_t *p8est_connectivity_share (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); ``` """ -function t8_mesh_destroy(mesh) - @ccall libt8.t8_mesh_destroy(mesh::Ptr{t8_mesh_t})::Cvoid +function p8est_connectivity_share(conn_in, root, comm) + @ccall libp4est.p8est_connectivity_share(conn_in::Ptr{p8est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p8est_connectivity_shared_t} end -const t8_nc_int64_t = Int64 - -const t8_nc_int32_t = Int32 - """ - t8_netcdf_create_var(var_type, var_name, var_long_name, var_unit, var_data) - -Create an extern double variable which additionally should be put out to the NetCDF File + p8est_connectivity_mission(conn_in, split_type, world_comm) -# Arguments -* `var_type`:\\[in\\] Defines the datatype of the variable, either T8\\_NETCDF\\_INT, T8\\_NETCDF\\_INT64 or T8\\_NETCDF\\_DOUBLE. -* `var_name`:\\[in\\] A String which will be the name of the created variable. -* `var_long_name`:\\[in\\] A string describing the variable a bit more and what it is about. -* `var_unit`:\\[in\\] The units in which the data is provided. -* `var_data`:\\[in\\] A [`sc_array_t`](@ref) holding the elementwise data of the variable. -* `num_extern_netcdf_vars`:\\[in\\] The number of extern user-defined variables which hold elementwise data (if none, set it to 0). ### Prototype ```c -t8_netcdf_variable_t * t8_netcdf_create_var (t8_netcdf_variable_type_t var_type, const char *var_name, const char *var_long_name, const char *var_unit, sc_array_t *var_data); +p8est_connectivity_shared_t * p8est_connectivity_mission (p8est_connectivity_t *conn_in, int split_type, sc_MPI_Comm world_comm); ``` """ -function t8_netcdf_create_var(var_type, var_name, var_long_name, var_unit, var_data) - @ccall libt8.t8_netcdf_create_var(var_type::t8_netcdf_variable_type_t, var_name::Cstring, var_long_name::Cstring, var_unit::Cstring, var_data::Ptr{sc_array_t})::Ptr{t8_netcdf_variable_t} +function p8est_connectivity_mission(conn_in, split_type, world_comm) + @ccall libp4est.p8est_connectivity_mission(conn_in::Ptr{p8est_connectivity_t}, split_type::Cint, world_comm::Cint)::Ptr{p8est_connectivity_shared_t} end """ - t8_netcdf_create_integer_var(var_name, var_long_name, var_unit, var_data) + p8est_connectivity_shared_destroy(cshare) -Create an extern integer variable which additionally should be put out to the NetCDF File (The distinction if it will be a NC\\_INT or NC\\_INT64 variable is based on the elementsize of the given [`sc_array_t`](@ref)) +Destroy a shared connectivity structure. Call this eventually on the result of p8est_connectivity_share or p8est_connectivity_mission (which calls the former internally). # Arguments -* `var_name`:\\[in\\] A String which will be the name of the created variable. -* `var_long_name`:\\[in\\] A string describing the variable a bit more and what it is about. -* `var_unit`:\\[in\\] The units in which the data is provided. -* `var_data`:\\[in\\] A [`sc_array_t`](@ref) holding the elementwise data of the variable. -* `num_extern_netcdf_vars`:\\[in\\] The number of extern user-defined variables which hold elementwise data (if none, set it to 0). +* `cshare`:\\[in\\] Valid shared connectivity structure; cf. p8est_connectivity_share. ### Prototype ```c -t8_netcdf_variable_t * t8_netcdf_create_integer_var (const char *var_name, const char *var_long_name, const char *var_unit, sc_array_t *var_data); +void p8est_connectivity_shared_destroy (p8est_connectivity_shared_t *cshare); ``` """ -function t8_netcdf_create_integer_var(var_name, var_long_name, var_unit, var_data) - @ccall libt8.t8_netcdf_create_integer_var(var_name::Cstring, var_long_name::Cstring, var_unit::Cstring, var_data::Ptr{sc_array_t})::Ptr{t8_netcdf_variable_t} +function p8est_connectivity_shared_destroy(cshare) + @ccall libp4est.p8est_connectivity_shared_destroy(cshare::Ptr{p8est_connectivity_shared_t})::Cvoid end """ - t8_netcdf_create_double_var(var_name, var_long_name, var_unit, var_data) + p8est_connectivity_set_attr(conn, bytes_per_tree) -Create an extern double variable which additionally should be put out to the NetCDF File +Allocate or free the attribute fields in a connectivity. # Arguments -* `var_name`:\\[in\\] A String which will be the name of the created variable. -* `var_long_name`:\\[in\\] A string describing the variable a bit more and what it is about. -* `var_unit`:\\[in\\] The units in which the data is provided. -* `var_data`:\\[in\\] A [`sc_array_t`](@ref) holding the elementwise data of the variable. -* `num_extern_netcdf_vars`:\\[in\\] The number of extern user-defined variables which hold elementwise data (if none, set it to 0). +* `conn`:\\[in,out\\] The conn->*\\_to\\_attr fields must either be NULL or previously be allocated by this function. +* `bytes_per_tree`:\\[in\\] If 0, tree\\_to\\_attr is freed (being NULL is ok). If positive, requested space is allocated. ### Prototype ```c -t8_netcdf_variable_t * t8_netcdf_create_double_var (const char *var_name, const char *var_long_name, const char *var_unit, sc_array_t *var_data); +void p8est_connectivity_set_attr (p8est_connectivity_t * conn, size_t bytes_per_tree); ``` """ -function t8_netcdf_create_double_var(var_name, var_long_name, var_unit, var_data) - @ccall libt8.t8_netcdf_create_double_var(var_name::Cstring, var_long_name::Cstring, var_unit::Cstring, var_data::Ptr{sc_array_t})::Ptr{t8_netcdf_variable_t} +function p8est_connectivity_set_attr(conn, bytes_per_tree) + @ccall libp4est.p8est_connectivity_set_attr(conn::Ptr{p8est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid end """ - t8_netcdf_variable_destroy(var_destroy) + p8est_connectivity_is_valid(connectivity) -Free the allocated memory of the a [`t8_netcdf_variable_t`](@ref) +Examine a connectivity structure. -# Arguments -* `var_destroy`:\\[in\\] A t8\\_netcdf\\_t variable whose allocated memory should be freed. +# Returns +Returns true if structure is valid, false otherwise. ### Prototype ```c -void t8_netcdf_variable_destroy (t8_netcdf_variable_t *var_destroy); +int p8est_connectivity_is_valid (p8est_connectivity_t * connectivity); ``` """ -function t8_netcdf_variable_destroy(var_destroy) - @ccall libt8.t8_netcdf_variable_destroy(var_destroy::Ptr{t8_netcdf_variable_t})::Cvoid +function p8est_connectivity_is_valid(connectivity) + @ccall libp4est.p8est_connectivity_is_valid(connectivity::Ptr{p8est_connectivity_t})::Cint end """ - t8_refcount_init(rc) + p8est_connectivity_is_equal(conn1, conn2) -Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. +Check two connectivity structures for equality. -# Arguments -* `rc`:\\[out\\] The reference counter is set to one by this call. +# Returns +Returns true if structures are equal, false otherwise. ### Prototype ```c -void t8_refcount_init (t8_refcount_t *rc); +int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); ``` """ -function t8_refcount_init(rc) - @ccall libt8.t8_refcount_init(rc::Ptr{t8_refcount_t})::Cvoid +function p8est_connectivity_is_equal(conn1, conn2) + @ccall libp4est.p8est_connectivity_is_equal(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint end """ - t8_refcount_new() + p8est_connectivity_sink(conn, sink) -Create a new reference counter with count initialized to 1. Equivalent to calling [`t8_refcount_init`](@ref) on a newly allocated refcount\\_t. It is mandatory to free this with t8_refcount_destroy. +Write connectivity to a sink object. +# Arguments +* `conn`:\\[in\\] The connectivity to be written. +* `sink`:\\[in,out\\] The connectivity is written into this sink. # Returns -An allocated reference counter whose count has been set to one. +0 on success, nonzero on error. ### Prototype ```c -t8_refcount_t * t8_refcount_new (void); +int p8est_connectivity_sink (p8est_connectivity_t * conn, sc_io_sink_t * sink); ``` """ -function t8_refcount_new() - @ccall libt8.t8_refcount_new()::Ptr{t8_refcount_t} +function p8est_connectivity_sink(conn, sink) + @ccall libp4est.p8est_connectivity_sink(conn::Ptr{p8est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint end """ - t8_refcount_destroy(rc) + p8est_connectivity_deflate(conn, code) -Destroy a reference counter that we allocated with t8_refcount_new. Its reference count must have decreased to zero. +Allocate memory and store the connectivity information there. # Arguments -* `rc`:\\[in,out\\] Allocated, formerly valid reference counter. +* `conn`:\\[in\\] The connectivity structure to be exported to memory. +* `code`:\\[in\\] Encoding and compression method for serialization. +# Returns +Newly created array that contains the information. ### Prototype ```c -void t8_refcount_destroy (t8_refcount_t *rc); +sc_array_t *p8est_connectivity_deflate (p8est_connectivity_t * conn, p8est_connectivity_encode_t code); ``` """ -function t8_refcount_destroy(rc) - @ccall libt8.t8_refcount_destroy(rc::Ptr{t8_refcount_t})::Cvoid +function p8est_connectivity_deflate(conn, code) + @ccall libp4est.p8est_connectivity_deflate(conn::Ptr{p8est_connectivity_t}, code::p8est_connectivity_encode_t)::Ptr{sc_array_t} end """ - t8_vec_norm(vec) + p8est_connectivity_save(filename, connectivity) -Vector norm. +Save a connectivity structure to disk. # Arguments -* `vec`:\\[in\\] A 3D vector. +* `filename`:\\[in\\] Name of the file to write. +* `connectivity`:\\[in\\] Valid connectivity structure. # Returns -The norm of *vec*. +Returns 0 on success, nonzero on file error. ### Prototype ```c -static inline double t8_vec_norm (const double vec[3]); +int p8est_connectivity_save (const char *filename, p8est_connectivity_t * connectivity); ``` """ -function t8_vec_norm(vec) - @ccall libt8.t8_vec_norm(vec::Ptr{Cdouble})::Cdouble +function p8est_connectivity_save(filename, connectivity) + @ccall libp4est.p8est_connectivity_save(filename::Cstring, connectivity::Ptr{p8est_connectivity_t})::Cint end """ - t8_vec_normalize(vec) + p8est_connectivity_source(source) -Normalize a vector. +Read connectivity from a source object. # Arguments -* `vec`:\\[in,out\\] A 3D vector. +* `source`:\\[in,out\\] The connectivity is read from this source. +# Returns +The newly created connectivity, or NULL on error. ### Prototype ```c -static inline void t8_vec_normalize (double vec[3]); +p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source); ``` """ -function t8_vec_normalize(vec) - @ccall libt8.t8_vec_normalize(vec::Ptr{Cdouble})::Cvoid +function p8est_connectivity_source(source) + @ccall libp4est.p8est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p8est_connectivity_t} end """ - t8_vec_copy(vec_in, vec_out) + p8est_connectivity_inflate(buffer) -Make a copy of a vector. +Create new connectivity from a memory buffer. This function aborts on malloc errors. # Arguments -* `vec_in`:\\[in\\] -* `vec_out`:\\[out\\] +* `buffer`:\\[in\\] The connectivity is created from this memory buffer. +# Returns +The newly created connectivity, or NULL on format error of the buffered connectivity data. ### Prototype ```c -static inline void t8_vec_copy (const double vec_in[3], double vec_out[3]); +p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer); ``` """ -function t8_vec_copy(vec_in, vec_out) - @ccall libt8.t8_vec_copy(vec_in::Ptr{Cdouble}, vec_out::Ptr{Cdouble})::Cvoid +function p8est_connectivity_inflate(buffer) + @ccall libp4est.p8est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p8est_connectivity_t} end """ - t8_vec_dist(vec_x, vec_y) + p8est_connectivity_load(filename, bytes) -Euclidean distance of X and Y. +Load a connectivity structure from disk. # Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. +* `filename`:\\[in\\] Name of the file to read. +* `bytes`:\\[out\\] Size in bytes of connectivity on disk or NULL. # Returns -The euclidean distance. Equivalent to norm (X-Y). +Returns valid connectivity, or NULL on file error. ### Prototype ```c -static inline double t8_vec_dist (const double vec_x[3], const double vec_y[3]); +p8est_connectivity_t *p8est_connectivity_load (const char *filename, size_t *bytes); ``` """ -function t8_vec_dist(vec_x, vec_y) - @ccall libt8.t8_vec_dist(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +function p8est_connectivity_load(filename, bytes) + @ccall libp4est.p8est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p8est_connectivity_t} end """ - t8_vec_ax(vec_x, alpha) + p8est_connectivity_new_unitcube() -Compute X = alpha * X +Create a connectivity structure for the unit cube. -# Arguments -* `vec_x`:\\[in,out\\] A 3D vector. On output set to *alpha* * *vec_x*. -* `alpha`:\\[in\\] A factor. ### Prototype ```c -static inline void t8_vec_ax (double vec_x[3], const double alpha); +p8est_connectivity_t *p8est_connectivity_new_unitcube (void); ``` """ -function t8_vec_ax(vec_x, alpha) - @ccall libt8.t8_vec_ax(vec_x::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +function p8est_connectivity_new_unitcube() + @ccall libp4est.p8est_connectivity_new_unitcube()::Ptr{p8est_connectivity_t} end """ - t8_vec_axy(vec_x, vec_y, alpha) + p8est_connectivity_new_periodic() -Compute Y = alpha * X +Create a connectivity structure for an all-periodic unit cube. -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_z`:\\[out\\] On output set to *alpha* * *vec_x*. -* `alpha`:\\[in\\] A factor. ### Prototype ```c -static inline void t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha); +p8est_connectivity_t *p8est_connectivity_new_periodic (void); ``` """ -function t8_vec_axy(vec_x, vec_y, alpha) - @ccall libt8.t8_vec_axy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +function p8est_connectivity_new_periodic() + @ccall libp4est.p8est_connectivity_new_periodic()::Ptr{p8est_connectivity_t} end """ - t8_vec_axb(vec_x, vec_y, alpha, b) - -Y = alpha * X + b - -!!! note + p8est_connectivity_new_rotwrap() - It is possible that vec\\_x = vec\\_y on input to overwrite x +Create a connectivity structure for a mostly periodic unit cube. The left and right faces are identified, and bottom and top rotated. Front and back are not identified. -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[out\\] On input, a 3D vector. On output set to *alpha* * *vec_x* + *b*. -* `alpha`:\\[in\\] A factor. -* `b`:\\[in\\] An offset. ### Prototype ```c -static inline void t8_vec_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b); +p8est_connectivity_t *p8est_connectivity_new_rotwrap (void); ``` """ -function t8_vec_axb(vec_x, vec_y, alpha, b) - @ccall libt8.t8_vec_axb(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble, b::Cdouble)::Cvoid +function p8est_connectivity_new_rotwrap() + @ccall libp4est.p8est_connectivity_new_rotwrap()::Ptr{p8est_connectivity_t} end """ - t8_vec_axpy(vec_x, vec_y, alpha) + p8est_connectivity_new_drop() -Y = Y + alpha * X +Create a connectivity structure for a five-trees geometry with a hole. The geometry is a 3D extrusion of the two drop example, and covers [0, 3]*[0, 2]*[0, 3]. The additional dimension is Y. -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in,out\\] On input, a 3D vector. On output set *to* vec\\_y + *alpha* * *vec_x* -* `alpha`:\\[in\\] A factor. ### Prototype ```c -static inline void t8_vec_axpy (const double vec_x[3], double vec_y[3], const double alpha); +p8est_connectivity_t *p8est_connectivity_new_drop (void); ``` """ -function t8_vec_axpy(vec_x, vec_y, alpha) - @ccall libt8.t8_vec_axpy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +function p8est_connectivity_new_drop() + @ccall libp4est.p8est_connectivity_new_drop()::Ptr{p8est_connectivity_t} end """ - t8_vec_axpyz(vec_x, vec_y, vec_z, alpha) + p8est_connectivity_new_twocubes() -Z = Y + alpha * X +Create a connectivity structure that contains two cubes. -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -* `vec_z`:\\[out\\] On output set *to* vec\\_y + *alpha* * *vec_x* ### Prototype ```c -static inline void t8_vec_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], const double alpha); +p8est_connectivity_t *p8est_connectivity_new_twocubes (void); ``` """ -function t8_vec_axpyz(vec_x, vec_y, vec_z, alpha) - @ccall libt8.t8_vec_axpyz(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, vec_z::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +function p8est_connectivity_new_twocubes() + @ccall libp4est.p8est_connectivity_new_twocubes()::Ptr{p8est_connectivity_t} end """ - t8_vec_dot(vec_x, vec_y) + p8est_connectivity_new_twotrees(l_face, r_face, orientation) -Dot product of X and Y. +Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way. # Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -# Returns -The dot product *vec_x* * *vec_y* +* `l_face`:\\[in\\] index of left face +* `r_face`:\\[in\\] index of right face +* `orientation`:\\[in\\] orientation of trees w.r.t. each other ### Prototype ```c -static inline double t8_vec_dot (const double vec_x[3], const double vec_y[3]); +p8est_connectivity_t *p8est_connectivity_new_twotrees (int l_face, int r_face, int orientation); ``` """ -function t8_vec_dot(vec_x, vec_y) - @ccall libt8.t8_vec_dot(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +function p8est_connectivity_new_twotrees(l_face, r_face, orientation) + @ccall libp4est.p8est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p8est_connectivity_t} end """ - t8_vec_cross(vec_x, vec_y, cross) + p8est_connectivity_new_twowrap() -Cross product of X and Y +Create a connectivity structure that contains two cubes where the two far ends are identified periodically. -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -* `cross`:\\[out\\] On output, the cross product of *vec_x* and *vec_y*. ### Prototype ```c -static inline void t8_vec_cross (const double vec_x[3], const double vec_y[3], double cross[3]); +p8est_connectivity_t *p8est_connectivity_new_twowrap (void); ``` """ -function t8_vec_cross(vec_x, vec_y, cross) - @ccall libt8.t8_vec_cross(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, cross::Ptr{Cdouble})::Cvoid +function p8est_connectivity_new_twowrap() + @ccall libp4est.p8est_connectivity_new_twowrap()::Ptr{p8est_connectivity_t} end """ - t8_vec_diff(vec_x, vec_y, diff) + p8est_connectivity_new_rotcubes() -Compute the difference of two vectors. +Create a connectivity structure that contains a few cubes. These are rotated against each other to stress the topology routines. -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -* `diff`:\\[out\\] On output, the difference of *vec_x* and *vec_y*. ### Prototype ```c -static inline void t8_vec_diff (const double vec_x[3], const double vec_y[3], double diff[3]); +p8est_connectivity_t *p8est_connectivity_new_rotcubes (void); ``` """ -function t8_vec_diff(vec_x, vec_y, diff) - @ccall libt8.t8_vec_diff(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, diff::Ptr{Cdouble})::Cvoid +function p8est_connectivity_new_rotcubes() + @ccall libp4est.p8est_connectivity_new_rotcubes()::Ptr{p8est_connectivity_t} end """ - t8_vec_eq(vec_x, vec_y, tol) + p8est_connectivity_new_pillow() -Check the equality of two vectors elementwise +Create a connectivity structure for two trees on top of each other. This connectivity is meant to be used with p8est_geometry_new_pillow to map a spherical shell. -# Arguments -* `vec_x`:\\[in\\] -* `vec_y`:\\[in\\] -* `tol`:\\[in\\] -# Returns -true, if the vectors are equal up to *tol* ### Prototype ```c -static inline int t8_vec_eq (const double vec_x[3], const double vec_y[3], const double tol); +p8est_connectivity_t *p8est_connectivity_new_pillow (void); ``` """ -function t8_vec_eq(vec_x, vec_y, tol) - @ccall libt8.t8_vec_eq(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, tol::Cdouble)::Cint +function p8est_connectivity_new_pillow() + @ccall libp4est.p8est_connectivity_new_pillow()::Ptr{p8est_connectivity_t} end """ - t8_vec_rescale(vec, new_length) + p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) -Rescale a vector to a new length. +An m by n by p array with periodicity in x, y, and z if periodic\\_a, periodic\\_b, and periodic\\_c are true, respectively. -# Arguments -* `vec`:\\[in,out\\] A 3D vector. -* `new_length`:\\[in\\] New length of the vector. ### Prototype ```c -static inline void t8_vec_rescale (double vec[3], const double new_length); +p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c); ``` """ -function t8_vec_rescale(vec, new_length) - @ccall libt8.t8_vec_rescale(vec::Ptr{Cdouble}, new_length::Cdouble)::Cvoid +function p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) + @ccall libp4est.p8est_connectivity_new_brick(m::Cint, n::Cint, p::Cint, periodic_a::Cint, periodic_b::Cint, periodic_c::Cint)::Ptr{p8est_connectivity_t} end """ - t8_vec_tri_normal(p1, p2, p3, normal) + p8est_connectivity_new_shell() -Compute the normal of a triangle given by its three vertices. +Create a connectivity structure that builds a spherical shell. It is made up of six connected parts [-1,1]x[-1,1]x[1,2]. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). -# Arguments -* `p1`:\\[in\\] A 3D vector. -* `p2`:\\[in\\] A 3D vector. -* `p3`:\\[in\\] A 3D vector. -* `Normal`:\\[out\\] vector of the triangle. (Not necessarily of length 1!) ### Prototype ```c -static inline void t8_vec_tri_normal (const double p1[3], const double p2[3], const double p3[3], double normal[3]); +p8est_connectivity_t *p8est_connectivity_new_shell (void); ``` """ -function t8_vec_tri_normal(p1, p2, p3, normal) - @ccall libt8.t8_vec_tri_normal(p1::Ptr{Cdouble}, p2::Ptr{Cdouble}, p3::Ptr{Cdouble}, normal::Ptr{Cdouble})::Cvoid +function p8est_connectivity_new_shell() + @ccall libp4est.p8est_connectivity_new_shell()::Ptr{p8est_connectivity_t} end """ - t8_vec_orthogonal_tripod(v1, v2, v3) + p8est_connectivity_new_sphere() -Compute an orthogonal coordinate system from a given vector. +Create a connectivity structure that builds a solid sphere. It is made up of two layers and a cube in the center. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). -# Arguments -* `v1`:\\[in\\] 3D vector. -* `v2`:\\[out\\] 3D vector. -* `v3`:\\[out\\] 3D vector. ### Prototype ```c -static inline void t8_vec_orthogonal_tripod (const double v1[3], double v2[3], double v3[3]); +p8est_connectivity_t *p8est_connectivity_new_sphere (void); ``` """ -function t8_vec_orthogonal_tripod(v1, v2, v3) - @ccall libt8.t8_vec_orthogonal_tripod(v1::Ptr{Cdouble}, v2::Ptr{Cdouble}, v3::Ptr{Cdouble})::Cvoid +function p8est_connectivity_new_sphere() + @ccall libp4est.p8est_connectivity_new_sphere()::Ptr{p8est_connectivity_t} end """ - t8_vec_swap(p1, p2) + p8est_connectivity_new_torus(nSegments) -Swap the components of two vectors. +Create a connectivity structure that builds a revolution torus. + +This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). + +This connectivity reuses ideas from disk2d connectivity. More precisely the torus is divided into segments around the revolution axis, each segments is made of 5 trees (à la disk2d). The total number of trees if 5 times the number of segments. + +This connectivity is meant to be used with p8est_geometry_new_torus # Arguments -* `p1`:\\[in,out\\] A 3D vector. -* `p2`:\\[in,out\\] A 3D vector. +* `nSegments`:\\[in\\] number of trees along the great circle ### Prototype ```c -static inline void t8_vec_swap (double p1[3], double p2[3]); +p8est_connectivity_t *p8est_connectivity_new_torus (int nSegments); ``` """ -function t8_vec_swap(p1, p2) - @ccall libt8.t8_vec_swap(p1::Ptr{Cdouble}, p2::Ptr{Cdouble})::Cvoid +function p8est_connectivity_new_torus(nSegments) + @ccall libp4est.p8est_connectivity_new_torus(nSegments::Cint)::Ptr{p8est_connectivity_t} end -# no prototype is found for this function at t8_version.h:70:1, please use with caution """ - t8_get_package_string() + p8est_connectivity_new_byname(name) -Return the package string of t8code. This string has the format "t8 version\\_number". +Create connectivity structure from predefined catalogue. +# Arguments +* `name`:\\[in\\] Invokes connectivity\\_new\\_* function. brick235 brick (2, 3, 5, 0, 0, 0) periodic periodic rotcubes rotcubes rotwrap rotwrap shell shell sphere sphere twocubes twocubes twowrap twowrap unit unitcube # Returns -The version string of t8code. +An initialized connectivity if name is defined, NULL else. ### Prototype ```c -const char* t8_get_package_string (); +p8est_connectivity_t *p8est_connectivity_new_byname (const char *name); ``` """ -function t8_get_package_string() - @ccall libt8.t8_get_package_string()::Cstring +function p8est_connectivity_new_byname(name) + @ccall libp4est.p8est_connectivity_new_byname(name::Cstring)::Ptr{p8est_connectivity_t} end -# no prototype is found for this function at t8_version.h:76:1, please use with caution """ - t8_get_version_number() + p8est_connectivity_refine(conn, num_per_dim) -Return the version number of t8code as a string. +Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. +# Arguments +* `conn`:\\[in\\] A valid connectivity +* `num_per_dim`:\\[in\\] The number of new trees in each direction. Must use no more than P8EST_OLD_QMAXLEVEL bits. # Returns -The version number of t8code as a string. +a refined connectivity. ### Prototype ```c -const char* t8_get_version_number (); +p8est_connectivity_t *p8est_connectivity_refine (p8est_connectivity_t * conn, int num_per_dim); ``` """ -function t8_get_version_number() - @ccall libt8.t8_get_version_number()::Cstring +function p8est_connectivity_refine(conn, num_per_dim) + @ccall libp4est.p8est_connectivity_refine(conn::Ptr{p8est_connectivity_t}, num_per_dim::Cint)::Ptr{p8est_connectivity_t} end -# no prototype is found for this function at t8_version.h:82:1, please use with caution """ - t8_get_version_point_string() + p8est_expand_face_transform(iface, nface, ftransform) -Return the version point string. +Fill an array with the axis combination of a face neighbor transform. -# Returns -The version point point string. +# Arguments +* `iface`:\\[in\\] The number of the originating face. +* `nface`:\\[in\\] Encoded as nface = r * 6 + nf, where nf = 0..5 is the neigbbor's connecting face number and r = 0..3 is the relative orientation to the neighbor's face. This encoding matches [`p8est_connectivity_t`](@ref). +* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face, the first two referring to the tangentials and the third to the normal. A permutation of (0, 1, 2). [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flags for tangential axes (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q ### Prototype ```c -const char* t8_get_version_point_string (); +void p8est_expand_face_transform (int iface, int nface, int ftransform[]); ``` """ -function t8_get_version_point_string() - @ccall libt8.t8_get_version_point_string()::Cstring +function p8est_expand_face_transform(iface, nface, ftransform) + @ccall libp4est.p8est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid end -# no prototype is found for this function at t8_version.h:88:1, please use with caution """ - t8_get_version_major() + p8est_find_face_transform(connectivity, itree, iface, ftransform) -Return the major version number of t8code. +Fill an array with the axis combination of a face neighbor transform. +# Arguments +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `iface`:\\[in\\] The number of the originating tree's face. +* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face. [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flag for axes t1, t2; face code for n; # Returns -The major version number of t8code. +The face neighbor tree if it exists, -1 otherwise. +# See also +[`p8est_expand_face_transform`](@ref). + ### Prototype ```c -int t8_get_version_major (); +p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); ``` """ -function t8_get_version_major() - @ccall libt8.t8_get_version_major()::Cint +function p8est_find_face_transform(connectivity, itree, iface, ftransform) + @ccall libp4est.p8est_find_face_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iface::Cint, ftransform::Ptr{Cint})::p4est_topidx_t end -# no prototype is found for this function at t8_version.h:94:1, please use with caution """ - t8_get_version_minor() + p8est_find_edge_transform(connectivity, itree, iedge, ei) -Return the minor version number of t8code. +Fills an array with information about edge neighbors. -# Returns -The minor version number of t8code. +# Arguments +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `iedge`:\\[in\\] The number of the originating edge. +* `ei`:\\[in,out\\] A [`p8est_edge_info_t`](@ref) structure with initialized array. ### Prototype ```c -int t8_get_version_minor (); +void p8est_find_edge_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t * ei); ``` """ -function t8_get_version_minor() - @ccall libt8.t8_get_version_minor()::Cint +function p8est_find_edge_transform(connectivity, itree, iedge, ei) + @ccall libp4est.p8est_find_edge_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iedge::Cint, ei::Ptr{p8est_edge_info_t})::Cvoid end -# no prototype is found for this function at t8_version.h:104:1, please use with caution """ - t8_get_version_patch() - -Return the patch version number of t8code. - -!!! note + p8est_find_corner_transform(connectivity, itree, icorner, ci) - In contrast to t8_get_version_major and t8_get_version_minor the patch version number must be computed from *T8_VERSION_POINT* This computation may result in an error or an invalid patch number. In that case a negative patch version is returned. +Fills an array with information about corner neighbors. -# Returns -The patch version unmber of t8code. negative on error. +# Arguments +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `icorner`:\\[in\\] The number of the originating corner. +* `ci`:\\[in,out\\] A [`p8est_corner_info_t`](@ref) structure with initialized array. ### Prototype ```c -int t8_get_version_patch (); +void p8est_find_corner_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t * ci); ``` """ -function t8_get_version_patch() - @ccall libt8.t8_get_version_patch()::Cint -end - -@cenum t8_vtk_data_type_t::UInt32 begin - T8_VTK_SCALAR = 0 - T8_VTK_VECTOR = 1 +function p8est_find_corner_transform(connectivity, itree, icorner, ci) + @ccall libp4est.p8est_find_corner_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, icorner::Cint, ci::Ptr{p8est_corner_info_t})::Cvoid end """ - t8_vtk_data_field_t - -| Field | Note | -| :---------- | :----------------------------------------- | -| type | Describes of which type the data array is | -| description | String that describes the data. | -""" -struct t8_vtk_data_field_t - type::t8_vtk_data_type_t - description::NTuple{8192, Cchar} - data::Ptr{Cdouble} -end + p8est_connectivity_complete(conn) -""" - t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) +Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. +# Arguments +* `conn`:\\[in,out\\] The connectivity needs to have proper vertices and tree\\_to\\_vertex fields. The tree\\_to\\_tree and tree\\_to\\_face fields must be allocated and satisfy [`p8est_connectivity_is_valid`](@ref) (conn) but will be overwritten. The edge and corner fields will be freed and allocated anew. ### Prototype ```c -int t8_write_pvtu (const char *filename, int num_procs, int write_tree, int write_rank, int write_level, int write_id, int num_data, t8_vtk_data_field_t *data); +void p8est_connectivity_complete (p8est_connectivity_t * conn); ``` """ -function t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) - @ccall libt8.t8_write_pvtu(filename::Cstring, num_procs::Cint, write_tree::Cint, write_rank::Cint, write_level::Cint, write_id::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function p8est_connectivity_complete(conn) + @ccall libp4est.p8est_connectivity_complete(conn::Ptr{p8est_connectivity_t})::Cvoid end """ - getdelim(lineptr, n, delimiter, stream) + p8est_connectivity_reduce(conn) + +Removes corner and edge information of a connectivity such that enough information is left to run [`p8est_connectivity_complete`](@ref) successfully. The reduced connectivity still passes [`p8est_connectivity_is_valid`](@ref). +# Arguments +* `conn`:\\[in,out\\] The connectivity to be reduced. ### Prototype ```c -static ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream); +void p8est_connectivity_reduce (p8est_connectivity_t * conn); ``` """ -function getdelim(lineptr, n, delimiter, stream) - @ccall libt8.getdelim(lineptr::Ptr{Cstring}, n::Ptr{Cint}, delimiter::Cint, stream::Ptr{Cint})::Cint +function p8est_connectivity_reduce(conn) + @ccall libp4est.p8est_connectivity_reduce(conn::Ptr{p8est_connectivity_t})::Cvoid end """ - getline(lineptr, n, stream) + p8est_connectivity_permute(conn, perm, is_current_to_new) + +[`p8est_connectivity_permute`](@ref) Given a permutation *perm* of the trees in a connectivity *conn*, permute the trees of *conn* in place and update *conn* to match. +# Arguments +* `conn`:\\[in,out\\] The connectivity whose trees are permuted. +* `perm`:\\[in\\] A permutation array, whose elements are size\\_t's. +* `is_current_to_new`:\\[in\\] if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation. ### Prototype ```c -static ssize_t getline (char **lineptr, size_t *n, FILE *stream); +void p8est_connectivity_permute (p8est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); ``` """ -function getline(lineptr, n, stream) - @ccall libt8.getline(lineptr::Ptr{Cstring}, n::Ptr{Cint}, stream::Ptr{Cint})::Cint +function p8est_connectivity_permute(conn, perm, is_current_to_new) + @ccall libp4est.p8est_connectivity_permute(conn::Ptr{p8est_connectivity_t}, perm::Ptr{sc_array_t}, is_current_to_new::Cint)::Cvoid end """ - strsep(stringp, delim) - -Extract token from string up to a given delimiter. + p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) -For a full description see https://linux.die.net/man/3/[`strsep`](@ref) +[`p8est_connectivity_join_faces`](@ref) This function takes an existing valid connectivity *conn* and modifies it by joining two tree faces that are currently boundary faces. +# Arguments +* `conn`:\\[in,out\\] connectivity that will be altered. +* `tree_left`:\\[in\\] tree that will be on the left side of the joined faces. +* `tree_right`:\\[in\\] tree that will be on the right side of the joined faces. +* `face_left`:\\[in\\] face of *tree_left* that will be joined. +* `face_right`:\\[in\\] face of *tree_right* that will be joined. +* `orientation`:\\[in\\] the orientation of *face_left* and *face_right* once joined (see the description of [`p8est_connectivity_t`](@ref) to understand orientation). ### Prototype ```c -static char * strsep (char **stringp, const char *delim); +void p8est_connectivity_join_faces (p8est_connectivity_t * conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation); ``` """ -function strsep(stringp, delim) - @ccall libt8.strsep(stringp::Ptr{Cstring}, delim::Cstring)::Cstring -end - -""" - t8_cmesh_copy(cmesh, cmesh_from, comm) - -### Prototype -```c -void t8_cmesh_copy (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, sc_MPI_Comm comm); -``` -""" -function t8_cmesh_copy(cmesh, cmesh_from, comm) - @ccall libt8.t8_cmesh_copy(cmesh::t8_cmesh_t, cmesh_from::t8_cmesh_t, comm::MPI_Comm)::Cvoid -end - -""" - sc_io_read(mpifile, ptr, zcount, t, errmsg) - -### Prototype -```c -void sc_io_read (sc_MPI_File mpifile, void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); -``` -""" -function sc_io_read(mpifile, ptr, zcount, t, errmsg) - @ccall libsc.sc_io_read(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid -end - -""" - sc_io_write(mpifile, ptr, zcount, t, errmsg) - -### Prototype -```c -void sc_io_write (sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); -``` -""" -function sc_io_write(mpifile, ptr, zcount, t, errmsg) - @ccall libsc.sc_io_write(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid -end - -"""Typedef for quadrant coordinates.""" -const p4est_qcoord_t = Int32 - -"""Typedef for counting topological entities (trees, tree vertices).""" -const p4est_topidx_t = Int32 - -"""Typedef for processor-local indexing of quadrants and nodes.""" -const p4est_locidx_t = Int32 - -"""Typedef for globally unique indexing of quadrants.""" -const p4est_gloidx_t = Int64 - -""" - sc_io_error_t - -Error values for io. - -| Enumerator | Note | -| :---------------------- | :--------------------------------------------------------------------------- | -| SC\\_IO\\_ERROR\\_NONE | The value of zero means no error. | -| SC\\_IO\\_ERROR\\_FATAL | The io object is now dysfunctional. | -| SC\\_IO\\_ERROR\\_AGAIN | Another io operation may resolve it. The function just returned was a noop. | -""" -@cenum sc_io_error_t::Int32 begin - SC_IO_ERROR_NONE = 0 - SC_IO_ERROR_FATAL = -1 - SC_IO_ERROR_AGAIN = -2 -end - -""" - sc_io_mode_t - -The I/O mode for writing using sc_io_sink. - -| Enumerator | Note | -| :---------------------- | :--------------------------- | -| SC\\_IO\\_MODE\\_WRITE | Semantics as "w" in fopen. | -| SC\\_IO\\_MODE\\_APPEND | Semantics as "a" in fopen. | -| SC\\_IO\\_MODE\\_LAST | Invalid entry to close list | -""" -@cenum sc_io_mode_t::UInt32 begin - SC_IO_MODE_WRITE = 0 - SC_IO_MODE_APPEND = 1 - SC_IO_MODE_LAST = 2 -end - -""" - sc_io_encode_t - -Enum to specify encoding for sc_io_sink and sc_io_source. - -| Enumerator | Note | -| :---------------------- | :--------------------------- | -| SC\\_IO\\_ENCODE\\_NONE | No encoding | -| SC\\_IO\\_ENCODE\\_LAST | Invalid entry to close list | -""" -@cenum sc_io_encode_t::UInt32 begin - SC_IO_ENCODE_NONE = 0 - SC_IO_ENCODE_LAST = 1 -end - -""" - sc_io_type_t - -The type of I/O operation sc_io_sink and sc_io_source. - -| Enumerator | Note | -| :------------------------ | :------------------------------- | -| SC\\_IO\\_TYPE\\_BUFFER | Write to a buffer | -| SC\\_IO\\_TYPE\\_FILENAME | Write to a file to be opened | -| SC\\_IO\\_TYPE\\_FILEFILE | Write to an already opened file | -| SC\\_IO\\_TYPE\\_LAST | Invalid entry to close list | -""" -@cenum sc_io_type_t::UInt32 begin - SC_IO_TYPE_BUFFER = 0 - SC_IO_TYPE_FILENAME = 1 - SC_IO_TYPE_FILEFILE = 2 - SC_IO_TYPE_LAST = 3 -end - -""" - sc_io_sink - -A generic data sink. - -| Field | Note | -| :------------- | :---------------------------------------------------- | -| iotype | type of the I/O operation | -| mode | write semantics | -| encode | encoding of data | -| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | -| buffer\\_bytes | distinguish from array elements | -| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | -| bytes\\_in | input bytes count | -| bytes\\_out | written bytes count | -| is\\_eof | Have we reached the end of file? | -""" -struct sc_io_sink - iotype::sc_io_type_t - mode::sc_io_mode_t - encode::sc_io_encode_t - buffer::Ptr{sc_array_t} - buffer_bytes::Csize_t - file::Ptr{Libc.FILE} - bytes_in::Csize_t - bytes_out::Csize_t - is_eof::Cint -end - -"""A generic data sink.""" -const sc_io_sink_t = sc_io_sink - -""" - sc_io_source - -A generic data source. - -| Field | Note | -| :-------------- | :---------------------------------------------------- | -| iotype | type of the I/O operation | -| encode | encoding of data | -| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | -| buffer\\_bytes | distinguish from array elements | -| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | -| bytes\\_in | input bytes count | -| bytes\\_out | read bytes count | -| is\\_eof | Have we reached the end of file? | -| mirror | if activated, a sink to store the data | -| mirror\\_buffer | if activated, the buffer for the mirror | -""" -struct sc_io_source - iotype::sc_io_type_t - encode::sc_io_encode_t - buffer::Ptr{sc_array_t} - buffer_bytes::Csize_t - file::Ptr{Libc.FILE} - bytes_in::Csize_t - bytes_out::Csize_t - is_eof::Cint - mirror::Ptr{sc_io_sink_t} - mirror_buffer::Ptr{sc_array_t} -end - -"""A generic data source.""" -const sc_io_source_t = sc_io_source - -""" - sc_io_open_mode_t - -Open modes for sc_io_open - -| Enumerator | Note | -| :----------------------- | :------------------------------------------------------------------------------------------------------------------ | -| SC\\_IO\\_READ | open a file in read-only mode | -| SC\\_IO\\_WRITE\\_CREATE | open a file in write-only mode; if the file exists, the file will be truncated to length zero and then overwritten | -| SC\\_IO\\_WRITE\\_APPEND | append to an already existing file | -""" -@cenum sc_io_open_mode_t::UInt32 begin - SC_IO_READ = 0 - SC_IO_WRITE_CREATE = 1 - SC_IO_WRITE_APPEND = 2 -end - -# automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_io_sink_new(iotype, iomode, ioencode, va_list...) - :(@ccall(libsc.sc_io_sink_new(iotype::Cint, iomode::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_sink_t})) - end - -""" - sc_io_sink_destroy(sink) - -Free data sink. Calls [`sc_io_sink_complete`](@ref) and discards the final counts. Errors from complete lead to SC\\_IO\\_ERROR\\_FATAL returned from this function. Call [`sc_io_sink_complete`](@ref) yourself if bytes\\_out is of interest. - -# Arguments -* `sink`:\\[in,out\\] The sink object to complete and free. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_sink_destroy (sc_io_sink_t * sink); -``` -""" -function sc_io_sink_destroy(sink) - @ccall libsc.sc_io_sink_destroy(sink::Ptr{sc_io_sink_t})::Cint -end - -""" - sc_io_sink_destroy_null(sink) - -Free data sink and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_sink_destroy. - -# Arguments -* `sink`:\\[in,out\\] Non-NULL pointer to sink pointer. The sink pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_sink, which is passed to sc_io_sink_destroy, and the sink pointer is set to NULL afterwards. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_sink_destroy_null (sc_io_sink_t ** sink); -``` -""" -function sc_io_sink_destroy_null(sink) - @ccall libsc.sc_io_sink_destroy_null(sink::Ptr{Ptr{sc_io_sink_t}})::Cint -end - -""" - sc_io_sink_write(sink, data, bytes_avail) - -Write data to a sink. Data may be buffered and sunk in a later call. The internal counters sink->bytes\\_in and sink->bytes\\_out are updated. - -# Arguments -* `sink`:\\[in,out\\] The sink object to write to. -* `data`:\\[in\\] Data passed into sink must be non-NULL. -* `bytes_avail`:\\[in\\] Number of data bytes passed in. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_sink_write (sc_io_sink_t * sink, const void *data, size_t bytes_avail); -``` -""" -function sc_io_sink_write(sink, data, bytes_avail) - @ccall libsc.sc_io_sink_write(sink::Ptr{sc_io_sink_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t)::Cint -end - -""" - sc_io_sink_complete(sink, bytes_in, bytes_out) - -Flush all buffered output data to sink. This function may return SC\\_IO\\_ERROR\\_AGAIN if another write is required. Currently this may happen if BUFFER requires an integer multiple of bytes. If successful, the updated value of bytes read and written is returned in bytes\\_in/out, and the sink status is reset as if the sink had just been created. In particular, the bytes counters are reset to zero. The internal state of the sink is not changed otherwise. It is legal to continue writing to the sink hereafter. The sink actions taken depend on its type. BUFFER, FILEFILE: none. FILENAME: call fclose on sink->file. - -# Arguments -* `sink`:\\[in,out\\] The sink object to write to. -* `bytes_in`:\\[in,out\\] Bytes received since the last new or complete call. May be NULL. -* `bytes_out`:\\[in,out\\] Bytes written since the last new or complete call. May be NULL. -# Returns -0 if completed, nonzero on error. -### Prototype -```c -int sc_io_sink_complete (sc_io_sink_t * sink, size_t *bytes_in, size_t *bytes_out); -``` -""" -function sc_io_sink_complete(sink, bytes_in, bytes_out) - @ccall libsc.sc_io_sink_complete(sink::Ptr{sc_io_sink_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint -end - -""" - sc_io_sink_align(sink, bytes_align) - -Align sink to a byte boundary by writing zeros. - -# Arguments -* `sink`:\\[in,out\\] The sink object to align. -* `bytes_align`:\\[in\\] Byte boundary. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_sink_align (sc_io_sink_t * sink, size_t bytes_align); -``` -""" -function sc_io_sink_align(sink, bytes_align) - @ccall libsc.sc_io_sink_align(sink::Ptr{sc_io_sink_t}, bytes_align::Csize_t)::Cint -end - -# automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_io_source_new(iotype, ioencode, va_list...) - :(@ccall(libsc.sc_io_source_new(iotype::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_source_t})) - end - -""" - sc_io_source_destroy(source) - -Free data source. Calls [`sc_io_source_complete`](@ref) and requires it to return no error. This is to avoid discarding buffered data that has not been passed to read. - -# Arguments -* `source`:\\[in,out\\] The source object to free. -# Returns -0 on success. Nonzero if an error is encountered or is\\_complete returns one. -### Prototype -```c -int sc_io_source_destroy (sc_io_source_t * source); -``` -""" -function sc_io_source_destroy(source) - @ccall libsc.sc_io_source_destroy(source::Ptr{sc_io_source_t})::Cint -end - -""" - sc_io_source_destroy_null(source) - -Free data source and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_source_destroy. - -# Arguments -* `source`:\\[in,out\\] Non-NULL pointer to source pointer. The source pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_source, which is passed to sc_io_source_destroy, and the source pointer is set to NULL afterwards. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_destroy_null (sc_io_source_t ** source); -``` -""" -function sc_io_source_destroy_null(source) - @ccall libsc.sc_io_source_destroy_null(source::Ptr{Ptr{sc_io_source_t}})::Cint -end - -""" - sc_io_source_read(source, data, bytes_avail, bytes_out) - -Read data from a source. The internal counters source->bytes\\_in and source->bytes\\_out are updated. Data is read until the data buffer has not enough room anymore, or source becomes empty. It is possible that data already read internally remains in the source object for the next call. Call [`sc_io_source_complete`](@ref) and check its return value to find out. Returns an error if bytes\\_out is NULL and less than bytes\\_avail are read. - -# Arguments -* `source`:\\[in,out\\] The source object to read from. -* `data`:\\[in\\] Data buffer for reading from source. If NULL the output data will be ignored and we seek forward in the input. -* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. -* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. If this condition is not met, return an error. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_read (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); -``` -""" -function sc_io_source_read(source, data, bytes_avail, bytes_out) - @ccall libsc.sc_io_source_read(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint -end - -""" - sc_io_source_complete(source, bytes_in, bytes_out) - -Determine whether all data buffered from source has been returned by read. If it returns SC\\_IO\\_ERROR\\_AGAIN, another [`sc_io_source_read`](@ref) is required. If the call returns no error, the internal counters source->bytes\\_in and source->bytes\\_out are returned to the caller if requested, and reset to 0. The internal state of the source is not changed otherwise. It is legal to continue reading from the source hereafter. - -# Arguments -* `source`:\\[in,out\\] The source object to read from. -* `bytes_in`:\\[in,out\\] If not NULL and true is returned, the total size of the data sourced. -* `bytes_out`:\\[in,out\\] If not NULL and true is returned, total bytes passed out by source\\_read. -# Returns -SC\\_IO\\_ERROR\\_AGAIN if buffered data remaining. Otherwise return ERROR\\_NONE and reset counters. -### Prototype -```c -int sc_io_source_complete (sc_io_source_t * source, size_t *bytes_in, size_t *bytes_out); -``` -""" -function sc_io_source_complete(source, bytes_in, bytes_out) - @ccall libsc.sc_io_source_complete(source::Ptr{sc_io_source_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint -end - -""" - sc_io_source_align(source, bytes_align) - -Align source to a byte boundary by skipping. - -# Arguments -* `source`:\\[in,out\\] The source object to align. -* `bytes_align`:\\[in\\] Byte boundary. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_align (sc_io_source_t * source, size_t bytes_align); -``` -""" -function sc_io_source_align(source, bytes_align) - @ccall libsc.sc_io_source_align(source::Ptr{sc_io_source_t}, bytes_align::Csize_t)::Cint -end - -""" - sc_io_source_activate_mirror(source) - -Activate a buffer that mirrors (i.e., stores) the data that was read. - -# Arguments -* `source`:\\[in,out\\] The source object to activate mirror in. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_activate_mirror (sc_io_source_t * source); -``` -""" -function sc_io_source_activate_mirror(source) - @ccall libsc.sc_io_source_activate_mirror(source::Ptr{sc_io_source_t})::Cint -end - -""" - sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) - -Read data from the source's mirror. Same behaviour as [`sc_io_source_read`](@ref). - -# Arguments -* `source`:\\[in,out\\] The source object to read mirror data from. -* `data`:\\[in\\] Data buffer for reading from source's mirror. If NULL the output data will be thrown away. -* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. -* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_read_mirror (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); -``` -""" -function sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) - @ccall libsc.sc_io_source_read_mirror(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint -end - -""" - sc_io_file_save(filename, buffer) - -Save a buffer to a file in one call. This function performs error checking and always returns cleanly. - -# Arguments -* `filename`:\\[in\\] Name of the file to save. -* `buffer`:\\[in\\] An array of element size 1 and arbitrary contents, which are written to the file. -# Returns -0 on success, -1 on error. -### Prototype -```c -int sc_io_file_save (const char *filename, sc_array_t * buffer); -``` -""" -function sc_io_file_save(filename, buffer) - @ccall libsc.sc_io_file_save(filename::Cstring, buffer::Ptr{sc_array_t})::Cint -end - -""" - sc_io_file_load(filename, buffer) - -Read a file into a buffer in one call. This function performs error checking and always returns cleanly. - -# Arguments -* `filename`:\\[in\\] Name of the file to load. -* `buffer`:\\[in,out\\] On input, an array (not a view) of element size 1 and arbitrary contents. On output and success, the complete file contents. On error, contents are undefined. -# Returns -0 on success, -1 on error. -### Prototype -```c -int sc_io_file_load (const char *filename, sc_array_t * buffer); -``` -""" -function sc_io_file_load(filename, buffer) - @ccall libsc.sc_io_file_load(filename::Cstring, buffer::Ptr{sc_array_t})::Cint -end - -""" - sc_io_encode(data, out) - -Encode a block of arbitrary data with the default sc\\_io format. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. - -Currently this function calls sc_io_encode_zlib with compression level Z\\_BEST\\_COMPRESSION (subject to change). Without zlib configured that function works uncompressed. - -The encoding method and input data size can be retrieved, optionally, from the encoded data by sc_io_decode_info. This function decodes the method as a character, which is 'z' for sc_io_encode_zlib. We reserve the characters A-C, d-z indefinitely. - -# Arguments -* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. -* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. -### Prototype -```c -void sc_io_encode (sc_array_t *data, sc_array_t *out); -``` -""" -function sc_io_encode(data, out) - @ccall libsc.sc_io_encode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t})::Cvoid -end - -""" - sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) - -Encode a block of arbitrary data, compressed, into an ASCII string. This is a two-stage process: zlib compress and then encode to base 64. The output is a NUL-terminated string of printable characters. - -We first compress the data into the zlib deflate format (RFC 1951). The compressor must use no preset dictionary (this is the default). If zlib is detected on configuration, we compress with the given level. If zlib is not detected, we write data equivalent to Z\\_NO\\_COMPRESSION. The status of zlib detection can be queried at compile time using #ifdef [`SC_HAVE_ZLIB`](@ref) or at run time using sc_have_zlib. Both types of result are readable by a standard zlib uncompress call. - -Secondly, we process the input data size as an 8-byte big-endian number, then the letter 'z', and then the zlib compressed data, concatenated, with a base 64 encoder. We break lines after 76 code characters. Each line break consists of two configurable but arbitrary bytes. The line breaks are considered part of the output data specification. The last line is terminated with the same line break and then a NUL. - -This routine can work in place or write to an output array. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. - -# Arguments -* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. -* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. -* `zlib_compression_level`:\\[in\\] Compression level between 0 (no compression) and 9 (best compression). The value -1 indicates some default level. -* `line_break_character`:\\[in\\] This character is arbitrary and specifies the first of two line break bytes. The second byte is always ''. -### Prototype -```c -void sc_io_encode_zlib (sc_array_t *data, sc_array_t *out, int zlib_compression_level, int line_break_character); -``` -""" -function sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) - @ccall libsc.sc_io_encode_zlib(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, zlib_compression_level::Cint, line_break_character::Cint)::Cvoid -end - -""" - sc_io_decode_info(data, original_size, format_char, re) - -Decode length and format of original input from encoded data. We expect at least 12 bytes of the format produced by sc_io_encode. No matter how much data has been encoded by it, this much is available. We decode the original data size and the character indicating the format. - -This function does not require zlib. It works with any well-defined data. - -Note that this function is not required before sc_io_decode. Calling this function on any result produced by sc_io_encode will succeed and report a legal format. This function cannot crash. - -# Arguments -* `data`:\\[in\\] This must be an array with element size 1. If it contains less than 12 code bytes we error out. It its first 12 bytes do not base 64 decode to 9 bytes we error out. We generally ignore the remaining data. -* `original_size`:\\[out\\] If not NULL and we do not error out, set to the original size as encoded in the data. -* `format_char`:\\[out\\] If not NULL and we do not error out, the ninth character of decoded data indicating the format. -* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. -# Returns -0 on success, negative value on error. -### Prototype -```c -int sc_io_decode_info (sc_array_t *data, size_t *original_size, char *format_char, void *re); -``` -""" -function sc_io_decode_info(data, original_size, format_char, re) - @ccall libsc.sc_io_decode_info(data::Ptr{sc_array_t}, original_size::Ptr{Csize_t}, format_char::Cstring, re::Ptr{Cvoid})::Cint -end - -""" - sc_io_decode(data, out, max_original_size, re) - -Decode a block of base 64 encoded compressed data. The base 64 data must contain two arbitrary bytes after every 76 code characters and also at the end of the last line if it is short, and then a final NUL character. This function does not require zlib but benefits for speed. - -This is a two-stage process: we decode the input from base 64 first. Then we extract the 8-byte big-endian original data size, the character 'z', and execute a zlib decompression on the remaining decoded data. This function detects malformed input by erroring out. - -If we should add another format in the future, the format character may be something else than 'z', as permitted by our specification. To this end, we reserve the characters A-C and d-z indefinitely. - -Any error condition is indicated by a negative return value. Possible causes for error are: - -- the input data string is not NUL-terminated - the first 12 characters of input do not decode properly - the input data is corrupt for decoding or decompression - the output data array has non-unit element size and the length of the output data is not divisible by the size - the output data would exceed the specified threshold - the output array is a view of insufficient length - -We also error out if the data requires a compression dictionary, which would be a violation of above encode format specification. - -The corresponding encode function is sc_io_encode. When passing an array as output, we resize it properly. This function cannot crash unless out of memory. - -# Arguments -* `data`:\\[in,out\\] If *out* is NULL, we work in place. In that case, output is written into this array after a suitable resize. Either way, we expect a NUL-terminated base 64 encoded string on input that has in turn been obtained by zlib compression. It must be in the exact format produced by sc_io_encode; please see documentation. The element size of the input array must be 1. -* `out`:\\[in,out\\] If not NULL, a valid array (may be a view). If NULL, the input array becomes the output. If the output array is a view and the output data larger than its view size, we error out. We expect commensurable element and data size and resize the output to fit exactly, which restores the original input passed to encoding. An output view array of matching size may be constructed using sc_io_decode_info. -* `max_original_size`:\\[in\\] If nonzero, this is the maximal data size that we will accept after uncompression. If exceeded, return a negative value. -* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. -# Returns -0 on success, negative on malformed input data or insufficient output space. -### Prototype -```c -int sc_io_decode (sc_array_t *data, sc_array_t *out, size_t max_original_size, void *re); -``` -""" -function sc_io_decode(data, out, max_original_size, re) - @ccall libsc.sc_io_decode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, max_original_size::Csize_t, re::Ptr{Cvoid})::Cint -end - -""" - sc_vtk_write_binary(vtkfile, numeric_data, byte_length) - -This function writes numeric binary data in VTK base64 encoding. - -# Arguments -* `vtkfile`: Stream opened for writing. -* `numeric_data`: A pointer to a numeric data array. -* `byte_length`: The length of the data array in bytes. -# Returns -Returns 0 on success, -1 on file error. -### Prototype -```c -int sc_vtk_write_binary (FILE * vtkfile, char *numeric_data, size_t byte_length); -``` -""" -function sc_vtk_write_binary(vtkfile, numeric_data, byte_length) - @ccall libsc.sc_vtk_write_binary(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint -end - -""" - sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) - -This function writes numeric binary data in VTK compressed format. - -# Arguments -* `vtkfile`: Stream opened for writing. -* `numeric_data`: A pointer to a numeric data array. -* `byte_length`: The length of the data array in bytes. -# Returns -Returns 0 on success, -1 on file error. -### Prototype -```c -int sc_vtk_write_compressed (FILE * vtkfile, char *numeric_data, size_t byte_length); -``` -""" -function sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) - @ccall libsc.sc_vtk_write_compressed(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint -end - -""" - sc_fopen(filename, mode, errmsg) - -Wrapper for fopen(3). We provide an additional argument that contains the error message. - -### Prototype -```c -FILE *sc_fopen (const char *filename, const char *mode, const char *errmsg); -``` -""" -function sc_fopen(filename, mode, errmsg) - @ccall libsc.sc_fopen(filename::Cstring, mode::Cstring, errmsg::Cstring)::Ptr{Libc.FILE} -end - -""" - sc_fwrite(ptr, size, nmemb, file, errmsg) - -Write memory content to a file. - -!!! note - - This function aborts on file errors. - -# Arguments -* `ptr`:\\[in\\] Data array to write to disk. -* `size`:\\[in\\] Size of one array member. -* `nmemb`:\\[in\\] Number of array members. -* `file`:\\[in,out\\] File pointer, must be opened for writing. -* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). -### Prototype -```c -void sc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); -``` -""" -function sc_fwrite(ptr, size, nmemb, file, errmsg) - @ccall libsc.sc_fwrite(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid -end - -""" - sc_fread(ptr, size, nmemb, file, errmsg) - -Read file content into memory. - -!!! note - - This function aborts on file errors. - -# Arguments -* `ptr`:\\[out\\] Data array to read from disk. -* `size`:\\[in\\] Size of one array member. -* `nmemb`:\\[in\\] Number of array members. -* `file`:\\[in,out\\] File pointer, must be opened for reading. -* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). -### Prototype -```c -void sc_fread (void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); -``` -""" -function sc_fread(ptr, size, nmemb, file, errmsg) - @ccall libsc.sc_fread(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid -end - -""" - sc_fflush_fsync_fclose(file) - -Best effort to flush a file's data to disc and close it. - -# Arguments -* `file`:\\[in,out\\] File open for writing. -### Prototype -```c -void sc_fflush_fsync_fclose (FILE * file); -``` -""" -function sc_fflush_fsync_fclose(file) - @ccall libsc.sc_fflush_fsync_fclose(file::Ptr{Libc.FILE})::Cvoid -end - -""" - sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) - -### Prototype -```c -int sc_io_open (sc_MPI_Comm mpicomm, const char *filename, sc_io_open_mode_t amode, sc_MPI_Info mpiinfo, sc_MPI_File * mpifile); -``` -""" -function sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) - @ccall libsc.sc_io_open(mpicomm::MPI_Comm, filename::Cstring, amode::sc_io_open_mode_t, mpiinfo::Cint, mpifile::Ptr{Cint})::Cint -end - -""" - sc_io_read_at(mpifile, offset, ptr, count, t, ocount) - -### Prototype -```c -int sc_io_read_at (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); -``` -""" -function sc_io_read_at(mpifile, offset, ptr, count, t, ocount) - @ccall libsc.sc_io_read_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint -end - -""" - sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) - -### Prototype -```c -int sc_io_read_at_all (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); -``` -""" -function sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) - @ccall libsc.sc_io_read_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint -end - -""" - sc_io_write_at(mpifile, offset, ptr, count, t, ocount) - -### Prototype -```c -int sc_io_write_at (sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount); -``` -""" -function sc_io_write_at(mpifile, offset, ptr, count, t, ocount) - @ccall libsc.sc_io_write_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint -end - -""" - sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) - -### Prototype -```c -int sc_io_write_at_all (sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount); -``` -""" -function sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) - @ccall libsc.sc_io_write_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint -end - -""" - sc_io_close(file) - -### Prototype -```c -int sc_io_close (sc_MPI_File * file); -``` -""" -function sc_io_close(file) - @ccall libsc.sc_io_close(file::Ptr{Cint})::Cint -end - -""" - p4est_comm_tag - -Tags for MPI messages -""" -@cenum p4est_comm_tag::UInt32 begin - P4EST_COMM_TAG_FIRST = 214 - P4EST_COMM_COUNT_PERTREE = 295 - P4EST_COMM_BALANCE_FIRST_COUNT = 296 - P4EST_COMM_BALANCE_FIRST_LOAD = 297 - P4EST_COMM_BALANCE_SECOND_COUNT = 298 - P4EST_COMM_BALANCE_SECOND_LOAD = 299 - P4EST_COMM_PARTITION_GIVEN = 300 - P4EST_COMM_PARTITION_WEIGHTED_LOW = 301 - P4EST_COMM_PARTITION_WEIGHTED_HIGH = 302 - P4EST_COMM_PARTITION_CORRECTION = 303 - P4EST_COMM_GHOST_COUNT = 304 - P4EST_COMM_GHOST_LOAD = 305 - P4EST_COMM_GHOST_EXCHANGE = 306 - P4EST_COMM_GHOST_EXPAND_COUNT = 307 - P4EST_COMM_GHOST_EXPAND_LOAD = 308 - P4EST_COMM_GHOST_SUPPORT_COUNT = 309 - P4EST_COMM_GHOST_SUPPORT_LOAD = 310 - P4EST_COMM_GHOST_CHECKSUM = 311 - P4EST_COMM_NODES_QUERY = 312 - P4EST_COMM_NODES_REPLY = 313 - P4EST_COMM_SAVE = 314 - P4EST_COMM_LNODES_TEST = 315 - P4EST_COMM_LNODES_PASS = 316 - P4EST_COMM_LNODES_OWNED = 317 - P4EST_COMM_LNODES_ALL = 318 - P4EST_COMM_TAG_LAST = 319 -end - -"""Tags for MPI messages""" -const p4est_comm_tag_t = p4est_comm_tag - -""" - p4est_log_indent_push() - -### Prototype -```c -static inline void p4est_log_indent_push (void); -``` -""" -function p4est_log_indent_push() - @ccall libp4est.p4est_log_indent_push()::Cvoid -end - -""" - p4est_log_indent_pop() - -### Prototype -```c -static inline void p4est_log_indent_pop (void); -``` -""" -function p4est_log_indent_pop() - @ccall libp4est.p4est_log_indent_pop()::Cvoid -end - -""" - p4est_init(log_handler, log_threshold) - -Registers p4est with the SC Library and sets the logging behavior. This function is optional. This function must only be called before additional threads are created. If this function is not called or called with log\\_handler == NULL, the default SC log handler will be used. If this function is not called or called with log\\_threshold == [`SC_LP_DEFAULT`](@ref), the default SC log threshold will be used. The default SC log settings can be changed with [`sc_set_log_defaults`](@ref) (). - -### Prototype -```c -void p4est_init (sc_log_handler_t log_handler, int log_threshold); -``` -""" -function p4est_init(log_handler, log_threshold) - @ccall libp4est.p4est_init(log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid -end - -""" - p4est_is_initialized() - -Return whether p4est has been initialized or not. Keep in mind that p4est_init is an optional function but it helps with proper parallel logging. - -Currently there is no inverse to p4est_init, and no way to deinit it. This is ok since initialization generally does no harm. Just do not call libsc's finalize function while p4est is still in use. - -# Returns -True if p4est has been initialized with a call to p4est_init and false otherwise. -### Prototype -```c -int p4est_is_initialized (void); -``` -""" -function p4est_is_initialized() - @ccall libp4est.p4est_is_initialized()::Cint -end - -""" - p4est_have_zlib() - -Check for a sufficiently recent zlib installation. - -# Returns -True if zlib is detected in both sc and p4est. -### Prototype -```c -int p4est_have_zlib (void); -``` -""" -function p4est_have_zlib() - @ccall libp4est.p4est_have_zlib()::Cint -end - -""" - p4est_get_package_id() - -Query the package identity as registered in libsc. - -# Returns -This is -1 before p4est_init has been called and a proper package identifier (>= 0) afterwards. -### Prototype -```c -int p4est_get_package_id (void); -``` -""" -function p4est_get_package_id() - @ccall libp4est.p4est_get_package_id()::Cint -end - -""" - p4est_topidx_hash2(tt) - -### Prototype -```c -static inline unsigned p4est_topidx_hash2 (const p4est_topidx_t * tt); -``` -""" -function p4est_topidx_hash2(tt) - @ccall libp4est.p4est_topidx_hash2(tt::Ptr{p4est_topidx_t})::Cuint -end - -""" - p4est_topidx_hash3(tt) - -### Prototype -```c -static inline unsigned p4est_topidx_hash3 (const p4est_topidx_t * tt); -``` -""" -function p4est_topidx_hash3(tt) - @ccall libp4est.p4est_topidx_hash3(tt::Ptr{p4est_topidx_t})::Cuint -end - -""" - p4est_topidx_hash4(tt) - -### Prototype -```c -static inline unsigned p4est_topidx_hash4 (const p4est_topidx_t * tt); -``` -""" -function p4est_topidx_hash4(tt) - @ccall libp4est.p4est_topidx_hash4(tt::Ptr{p4est_topidx_t})::Cuint -end - -""" - p4est_topidx_is_sorted(t, length) - -### Prototype -```c -static inline int p4est_topidx_is_sorted (p4est_topidx_t * t, int length); -``` -""" -function p4est_topidx_is_sorted(t, length) - @ccall libp4est.p4est_topidx_is_sorted(t::Ptr{p4est_topidx_t}, length::Cint)::Cint -end - -""" - p4est_topidx_bsort(t, length) - -### Prototype -```c -static inline void p4est_topidx_bsort (p4est_topidx_t * t, int length); -``` -""" -function p4est_topidx_bsort(t, length) - @ccall libp4est.p4est_topidx_bsort(t::Ptr{p4est_topidx_t}, length::Cint)::Cvoid -end - -""" - p4est_partition_cut_uint64(global_num, p, num_procs) - -### Prototype -```c -static inline uint64_t p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs); -``` -""" -function p4est_partition_cut_uint64(global_num, p, num_procs) - @ccall libp4est.p4est_partition_cut_uint64(global_num::UInt64, p::Cint, num_procs::Cint)::UInt64 -end - -""" - p4est_partition_cut_gloidx(global_num, p, num_procs) - -### Prototype -```c -static inline p4est_gloidx_t p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs); -``` -""" -function p4est_partition_cut_gloidx(global_num, p, num_procs) - @ccall libp4est.p4est_partition_cut_gloidx(global_num::p4est_gloidx_t, p::Cint, num_procs::Cint)::p4est_gloidx_t -end - -""" - p4est_version() - -Return the full version of p4est. - -# Returns -Return the version of p4est using the format `VERSION\\_MAJOR.VERSION\\_MINOR.VERSION\\_POINT`, where `VERSION_POINT` can contain dots and characters, e.g. to indicate the additional number of commits and a git commit hash. -### Prototype -```c -const char *p4est_version (void); -``` -""" -function p4est_version() - @ccall libp4est.p4est_version()::Cstring -end - -""" - p4est_version_major() - -Return the major version of p4est. - -# Returns -Return the major version of p4est. -### Prototype -```c -int p4est_version_major (void); -``` -""" -function p4est_version_major() - @ccall libp4est.p4est_version_major()::Cint -end - -""" - p4est_version_minor() - -Return the minor version of p4est. - -# Returns -Return the minor version of p4est. -### Prototype -```c -int p4est_version_minor (void); -``` -""" -function p4est_version_minor() - @ccall libp4est.p4est_version_minor()::Cint -end - -""" - p4est_connect_type_t - -Characterize a type of adjacency. - -Several functions involve relationships between neighboring trees and/or quadrants, and their behavior depends on how one defines adjacency: 1) entities are adjacent if they share a face, or 2) entities are adjacent if they share a face or corner. [`p4est_connect_type_t`](@ref) is used to choose the desired behavior. This enum must fit into an int8\\_t. - -| Enumerator | Note | -| :----------------------- | :--------------------------------- | -| P4EST\\_CONNECT\\_SELF | No balance whatsoever. | -| P4EST\\_CONNECT\\_FACE | Balance across faces only. | -| P4EST\\_CONNECT\\_ALMOST | = CORNER - 1. | -| P4EST\\_CONNECT\\_CORNER | Balance across faces and corners. | -| P4EST\\_CONNECT\\_FULL | = CORNER. | -""" -@cenum p4est_connect_type_t::UInt32 begin - P4EST_CONNECT_SELF = 20 - P4EST_CONNECT_FACE = 21 - P4EST_CONNECT_ALMOST = 21 - P4EST_CONNECT_CORNER = 22 - P4EST_CONNECT_FULL = 22 -end - -""" - p4est_connectivity_encode_t - -Typedef for serialization method. - -| Enumerator | Note | -| :--------------------------- | :-------------------------------- | -| P4EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | -""" -@cenum p4est_connectivity_encode_t::UInt32 begin - P4EST_CONN_ENCODE_NONE = 0 - P4EST_CONN_ENCODE_LAST = 1 -end - -""" - p4est_connect_type_int(btype) - -Convert the [`p4est_connect_type_t`](@ref) into a number. - -# Arguments -* `btype`:\\[in\\] The balance type to convert. -# Returns -Returns 1 or 2. -### Prototype -```c -int p4est_connect_type_int (p4est_connect_type_t btype); -``` -""" -function p4est_connect_type_int(btype) - @ccall libp4est.p4est_connect_type_int(btype::p4est_connect_type_t)::Cint -end - -""" - p4est_connect_type_string(btype) - -Convert the [`p4est_connect_type_t`](@ref) into a const string. - -# Arguments -* `btype`:\\[in\\] The balance type to convert. -# Returns -Returns a pointer to a constant string. -### Prototype -```c -const char *p4est_connect_type_string (p4est_connect_type_t btype); -``` -""" -function p4est_connect_type_string(btype) - @ccall libp4est.p4est_connect_type_string(btype::p4est_connect_type_t)::Cstring -end - -""" - p4est_connectivity - -This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible. - -The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is given by the normal directions -x +x -y +y. Each face has a natural direction by increasing face corner number. Face connections are allocated [0][0]..[0][3]..[num\\_trees-1][0]..[num\\_trees-1][3]. If a face is on the physical boundary it must connect to itself. - -The values for tree\\_to\\_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for faces that are mutually direction-aligned and 1 for faces that are running in opposite directions. - -It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. - -The corners are stored when they connect trees that are not already face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. - -The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. - -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. We do not interpret them. - -!!! note - - If a connectivity implies natural connections between trees that are corner neighbors without being face neighbors, these corners shall be encoded explicitly in the connectivity. - -| Field | Note | -| :------------------- | :----------------------------------------------------------------------------------- | -| num\\_vertices | the number of vertices that define the *embedding* of the forest (not the topology) | -| num\\_trees | the number of trees | -| num\\_corners | the number of corners that help define topology | -| vertices | an array of size (3 * *num_vertices*) | -| tree\\_to\\_vertex | embed each tree into ```c++ R^3 ``` for e.g. visualization (see p4est\\_vtk.h) | -| tree\\_attr\\_bytes | bytes per tree in tree\\_to\\_attr | -| tree\\_to\\_attr | not touched by p4est | -| tree\\_to\\_tree | (4 * *num_trees*) neighbors across faces | -| tree\\_to\\_face | (4 * *num_trees*) face to face+orientation (see description) | -| tree\\_to\\_corner | (4 * *num_trees*) or NULL (see description) | -| ctt\\_offset | corner to offset in *corner_to_tree* and *corner_to_corner* | -| corner\\_to\\_tree | list of trees that meet at a corner | -| corner\\_to\\_corner | list of tree-corners that meet at a corner | -""" -struct p4est_connectivity - num_vertices::p4est_topidx_t - num_trees::p4est_topidx_t - num_corners::p4est_topidx_t - vertices::Ptr{Cdouble} - tree_to_vertex::Ptr{p4est_topidx_t} - tree_attr_bytes::Csize_t - tree_to_attr::Cstring - tree_to_tree::Ptr{p4est_topidx_t} - tree_to_face::Ptr{Int8} - tree_to_corner::Ptr{p4est_topidx_t} - ctt_offset::Ptr{p4est_topidx_t} - corner_to_tree::Ptr{p4est_topidx_t} - corner_to_corner::Ptr{Int8} -end - -""" -This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible. - -The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. yx is 00 01 10 11. For faces the order is given by the normal directions -x +x -y +y. Each face has a natural direction by increasing face corner number. Face connections are allocated [0][0]..[0][3]..[num\\_trees-1][0]..[num\\_trees-1][3]. If a face is on the physical boundary it must connect to itself. - -The values for tree\\_to\\_face are 0..7 where ttf % 4 gives the face number and ttf / 4 the face orientation code. The orientation is 0 for faces that are mutually direction-aligned and 1 for faces that are running in opposite directions. - -It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. - -The corners are stored when they connect trees that are not already face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. - -The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. - -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. We do not interpret them. - -!!! note - - If a connectivity implies natural connections between trees that are corner neighbors without being face neighbors, these corners shall be encoded explicitly in the connectivity. -""" -const p4est_connectivity_t = p4est_connectivity - -""" - p4est_connectivity_memory_used(conn) - -Calculate memory usage of a connectivity structure. - -# Arguments -* `conn`:\\[in\\] Connectivity structure. -# Returns -Memory used in bytes. -### Prototype -```c -size_t p4est_connectivity_memory_used (p4est_connectivity_t * conn); -``` -""" -function p4est_connectivity_memory_used(conn) - @ccall libp4est.p4est_connectivity_memory_used(conn::Ptr{p4est_connectivity_t})::Csize_t -end - -""" - p4est_corner_transform_t - -Generic interface for transformations between a tree and any of its corner - -| Field | Note | -| :------ | :------------------------ | -| ntree | The number of the tree | -| ncorner | The number of the corner | -""" -struct p4est_corner_transform_t - ntree::p4est_topidx_t - ncorner::Int8 -end - -""" - p4est_corner_info_t - -Information about the neighbors of a corner - -| Field | Note | -| :------------------ | :------------------------------------------------ | -| icorner | The number of the originating corner | -| corner\\_transforms | The array of neighbors of the originating corner | -""" -struct p4est_corner_info_t - icorner::p4est_topidx_t - corner_transforms::sc_array_t -end - -""" - p4est_neighbor_transform_t - -Generic interface for transformations between a tree and any of its neighbors - -| Field | Note | -| :---------------- | :-------------------------------------------------------------------------- | -| neighbor\\_type | type of connection to neighbor | -| neighbor | neighbor tree index | -| index\\_self | index of interface from self's perspective | -| index\\_neighbor | index of interface from neighbor's perspective | -| perm | permutation of dimensions when transforming self coords to neighbor coords | -| sign | sign changes when transforming self coords to neighbor coords | -| origin\\_self | point on the interface from self's perspective | -| origin\\_neighbor | point on the interface from neighbor's perspective | -""" -struct p4est_neighbor_transform_t - neighbor_type::p4est_connect_type_t - neighbor::p4est_topidx_t - index_self::Int8 - index_neighbor::Int8 - perm::NTuple{2, Int8} - sign::NTuple{2, Int8} - origin_self::NTuple{2, p4est_qcoord_t} - origin_neighbor::NTuple{2, p4est_qcoord_t} -end - -""" - p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) - -Transform from self's coordinate system to neighbor's coordinate system. - -# Arguments -* `nt`:\\[in\\] A neighbor transform. -* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. -### Prototype -```c -void p4est_neighbor_transform_coordinates (const p4est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P4EST_DIM], p4est_qcoord_t neigh_coords[P4EST_DIM]); -``` -""" -function p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) - @ccall libp4est.p4est_neighbor_transform_coordinates(nt::Ptr{p4est_neighbor_transform_t}, self_coords::Ptr{p4est_qcoord_t}, neigh_coords::Ptr{p4est_qcoord_t})::Cvoid -end - -""" - p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) - -Transform from neighbor's coordinate system to self's coordinate system. - -# Arguments -* `nt`:\\[in\\] A neighbor transform. -* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. -### Prototype -```c -void p4est_neighbor_transform_coordinates_reverse (const p4est_neighbor_transform_t * nt, const p4est_qcoord_t neigh_coords[P4EST_DIM], p4est_qcoord_t self_coords[P4EST_DIM]); -``` -""" -function p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) - @ccall libp4est.p4est_neighbor_transform_coordinates_reverse(nt::Ptr{p4est_neighbor_transform_t}, neigh_coords::Ptr{p4est_qcoord_t}, self_coords::Ptr{p4est_qcoord_t})::Cvoid -end - -""" - p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) - -Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects - -# Arguments -* `conn`:\\[in\\] Connectivity structure. -* `tree_id`:\\[in\\] The number of the tree. -* `boundary_type`:\\[in\\] The type of the boundary connection (self, face, corner). -* `boundary_index`:\\[in\\] The index of the boundary. -* `neighbor_transform_array`:\\[in,out\\] Array of the neighbor transforms. -### Prototype -```c -void p4est_connectivity_get_neighbor_transforms (p4est_connectivity_t *conn, p4est_topidx_t tree_id, p4est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array); -``` -""" -function p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) - @ccall libp4est.p4est_connectivity_get_neighbor_transforms(conn::Ptr{p4est_connectivity_t}, tree_id::p4est_topidx_t, boundary_type::p4est_connect_type_t, boundary_index::Cint, neighbor_transform_array::Ptr{sc_array_t})::Cvoid -end - -""" - p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) - -Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. - -# Arguments -* `fc`:\\[in\\] A face corner number in 0..1. -* `f`:\\[in\\] A face that the face corner number *fc* is relative to. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. -# Returns -The face corner number relative to the neighbor's face. -### Prototype -```c -int p4est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); -``` -""" -function p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) - @ccall libp4est.p4est_connectivity_face_neighbor_face_corner(fc::Cint, f::Cint, nf::Cint, o::Cint)::Cint -end - -""" - p4est_connectivity_face_neighbor_corner(c, f, nf, o) - -Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. - -# Arguments -* `c`:\\[in\\] A corner number in 0..3. -* `f`:\\[in\\] A face number that touches the corner *c*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. -# Returns -The number of the corner seen from the neighbor tree. -### Prototype -```c -int p4est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); -``` -""" -function p4est_connectivity_face_neighbor_corner(c, f, nf, o) - @ccall libp4est.p4est_connectivity_face_neighbor_corner(c::Cint, f::Cint, nf::Cint, o::Cint)::Cint -end - -""" - p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) - -Allocate a connectivity structure. The attribute fields are initialized to NULL. - -# Arguments -* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). -* `num_trees`:\\[in\\] Number of trees in the forest. -* `num_corners`:\\[in\\] Number of tree-connecting corners. -* `num_ctt`:\\[in\\] Number of total trees in corner\\_to\\_tree array. -# Returns -A connectivity structure with allocated arrays. -### Prototype -```c -p4est_connectivity_t *p4est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, p4est_topidx_t num_ctt); -``` -""" -function p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) - @ccall libp4est.p4est_connectivity_new(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_corners::p4est_topidx_t, num_ctt::p4est_topidx_t)::Ptr{p4est_connectivity_t} -end - -""" - p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) - -Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. - -# Arguments -* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). -* `num_trees`:\\[in\\] Number of trees in the forest. -* `num_corners`:\\[in\\] Number of tree-connecting corners. -* `vertices`:\\[in\\] Coordinates of the vertices of the trees. -* `ttv`:\\[in\\] The tree-to-vertex array. -* `ttt`:\\[in\\] The tree-to-tree array. -* `ttf`:\\[in\\] The tree-to-face array (int8\\_t). -* `ttc`:\\[in\\] The tree-to-corner array. -* `coff`:\\[in\\] Corner-to-tree offsets (num\\_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. -* `ctt`:\\[in\\] The corner-to-tree array. -* `ctc`:\\[in\\] The corner-to-corner array. -# Returns -The connectivity is checked for validity. -### Prototype -```c -p4est_connectivity_t *p4est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc); -``` -""" -function p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) - @ccall libp4est.p4est_connectivity_new_copy(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_corners::p4est_topidx_t, vertices::Ptr{Cdouble}, ttv::Ptr{p4est_topidx_t}, ttt::Ptr{p4est_topidx_t}, ttf::Ptr{Int8}, ttc::Ptr{p4est_topidx_t}, coff::Ptr{p4est_topidx_t}, ctt::Ptr{p4est_topidx_t}, ctc::Ptr{Int8})::Ptr{p4est_connectivity_t} -end - -""" - p4est_connectivity_bcast(conn_in, root, comm) - -### Prototype -```c -p4est_connectivity_t *p4est_connectivity_bcast (p4est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); -``` -""" -function p4est_connectivity_bcast(conn_in, root, comm) - @ccall libp4est.p4est_connectivity_bcast(conn_in::Ptr{p4est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p4est_connectivity_t} -end - -""" - p4est_connectivity_destroy(connectivity) - -Destroy a connectivity structure. Also destroy all attributes. - -### Prototype -```c -void p4est_connectivity_destroy (p4est_connectivity_t * connectivity); -``` -""" -function p4est_connectivity_destroy(connectivity) - @ccall libp4est.p4est_connectivity_destroy(connectivity::Ptr{p4est_connectivity_t})::Cvoid -end - -""" - p4est_connectivity_set_attr(conn, bytes_per_tree) - -Allocate or free the attribute fields in a connectivity. - -# Arguments -* `conn`:\\[in,out\\] The conn->*\\_to\\_attr fields must either be NULL or previously be allocated by this function. -* `bytes_per_tree`:\\[in\\] If 0, tree\\_to\\_attr is freed (being NULL is ok). If positive, requested space is allocated. -### Prototype -```c -void p4est_connectivity_set_attr (p4est_connectivity_t * conn, size_t bytes_per_tree); -``` -""" -function p4est_connectivity_set_attr(conn, bytes_per_tree) - @ccall libp4est.p4est_connectivity_set_attr(conn::Ptr{p4est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid +function p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + @ccall libp4est.p8est_connectivity_join_faces(conn::Ptr{p8est_connectivity_t}, tree_left::p4est_topidx_t, tree_right::p4est_topidx_t, face_left::Cint, face_right::Cint, orientation::Cint)::Cvoid end """ - p4est_connectivity_is_valid(connectivity) + p8est_connectivity_is_equivalent(conn1, conn2) -Examine a connectivity structure. +[`p8est_connectivity_is_equivalent`](@ref) This function compares two connectivities for equivalence: it returns *true* if they are the same connectivity, or if they have the same topology. The definition of topological sameness is strict: there is no attempt made to determine whether permutation and/or rotation of the trees makes the connectivities equivalent. -# Returns -Returns true if structure is valid, false otherwise. +# Arguments +* `conn1`:\\[in\\] a valid connectivity +* `conn2`:\\[out\\] a valid connectivity ### Prototype ```c -int p4est_connectivity_is_valid (p4est_connectivity_t * connectivity); +int p8est_connectivity_is_equivalent (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); ``` """ -function p4est_connectivity_is_valid(connectivity) - @ccall libp4est.p4est_connectivity_is_valid(connectivity::Ptr{p4est_connectivity_t})::Cint +function p8est_connectivity_is_equivalent(conn1, conn2) + @ccall libp4est.p8est_connectivity_is_equivalent(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint end """ - p4est_connectivity_is_equal(conn1, conn2) - -Check two connectivity structures for equality. + p8est_edge_array_index(array, it) -# Returns -Returns true if structures are equal, false otherwise. ### Prototype ```c -int p4est_connectivity_is_equal (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); +static inline p8est_edge_transform_t * p8est_edge_array_index (sc_array_t *array, size_t it); ``` """ -function p4est_connectivity_is_equal(conn1, conn2) - @ccall libp4est.p4est_connectivity_is_equal(conn1::Ptr{p4est_connectivity_t}, conn2::Ptr{p4est_connectivity_t})::Cint +function p8est_edge_array_index(array, it) + @ccall libp4est.p8est_edge_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_edge_transform_t} end """ - p4est_connectivity_sink(conn, sink) - -Write connectivity to a sink object. + p8est_corner_array_index(array, it) -# Arguments -* `conn`:\\[in\\] The connectivity to be written. -* `sink`:\\[in,out\\] The connectivity is written into this sink. -# Returns -0 on success, nonzero on error. ### Prototype ```c -int p4est_connectivity_sink (p4est_connectivity_t * conn, sc_io_sink_t * sink); +static inline p8est_corner_transform_t * p8est_corner_array_index (sc_array_t *array, size_t it); ``` """ -function p4est_connectivity_sink(conn, sink) - @ccall libp4est.p4est_connectivity_sink(conn::Ptr{p4est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint +function p8est_corner_array_index(array, it) + @ccall libp4est.p8est_corner_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_corner_transform_t} end """ - p4est_connectivity_deflate(conn, code) + p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) -Allocate memory and store the connectivity information there. +Read an ABAQUS input file from a file stream. -# Arguments -* `conn`:\\[in\\] The connectivity structure to be exported to memory. -* `code`:\\[in\\] Encoding and compression method for serialization. -# Returns -Newly created array that contains the information. -### Prototype -```c -sc_array_t *p4est_connectivity_deflate (p4est_connectivity_t * conn, p4est_connectivity_encode_t code); -``` -""" -function p4est_connectivity_deflate(conn, code) - @ccall libp4est.p4est_connectivity_deflate(conn::Ptr{p4est_connectivity_t}, code::p4est_connectivity_encode_t)::Ptr{sc_array_t} -end +This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. -""" - p4est_connectivity_save(filename, connectivity) +A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: -Save a connectivity structure to disk. +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 -# Arguments -* `filename`:\\[in\\] Name of the file to write. -* `connectivity`:\\[in\\] Valid connectivity structure. -# Returns -Returns 0 on success, nonzero on file error. -### Prototype -```c -int p4est_connectivity_save (const char *filename, p4est_connectivity_t * connectivity); -``` -""" -function p4est_connectivity_save(filename, connectivity) - @ccall libp4est.p4est_connectivity_save(filename::Cstring, connectivity::Ptr{p4est_connectivity_t})::Cint -end +and in 3D they are given as: -""" - p4est_connectivity_source(source) +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 -Read connectivity from a source object. +```c++ + *Heading + box.inp + *Node + 1, 5, -5, 5 + 2, 5, 5, 5 + 3, 5, 0, 5 + 4, -5, 5, 5 + 5, 0, 5, 5 + 6, -5, -5, 5 + 7, -5, 0, 5 + 8, 0, -5, 5 + 9, 0, 0, 5 + 10, 5, 5, -5 + 11, 5, -5, -5 + 12, 5, 0, -5 + 13, -5, -5, -5 + 14, 0, -5, -5 + 15, -5, 5, -5 + 16, -5, 0, -5 + 17, 0, 5, -5 + 18, 0, 0, -5 + 19, -5, -5, 0 + 20, 5, -5, 0 + 21, 0, -5, 0 + 22, -5, 5, 0 + 23, -5, 0, 0 + 24, 5, 5, 0 + 25, 0, 5, 0 + 26, 5, 0, 0 + 27, 0, 0, 0 + *Element, type=C3D8, ELSET=EB1 + 1, 6, 19, 23, 7, 8, 21, 27, 9 + 2, 19, 13, 16, 23, 21, 14, 18, 27 + 3, 7, 23, 22, 4, 9, 27, 25, 5 + 4, 23, 16, 15, 22, 27, 18, 17, 25 + 5, 8, 21, 27, 9, 1, 20, 26, 3 + 6, 21, 14, 18, 27, 20, 11, 12, 26 + 7, 9, 27, 25, 5, 3, 26, 24, 2 + 8, 27, 18, 17, 25, 26, 12, 10, 24 +``` + +This code can be called two ways. The first, when `vertex`==NULL and `tree_to_vertex`==NULL, is used to count the number of trees and vertices in the connectivity to be generated by the `.inp` mesh in the *stream*. The second, when `vertices`!=NULL and `tree_to_vertex`!=NULL, fill `vertices` and `tree_to_vertex`. In this case `num_vertices` and `num_trees` need to be set to the maximum number of entries allocated in `vertices` and `tree_to_vertex`. # Arguments -* `source`:\\[in,out\\] The connectivity is read from this source. +* `stream`:\\[in,out\\] file stream to read the connectivity from +* `num_vertices`:\\[in,out\\] the number of vertices in the connectivity +* `num_trees`:\\[in,out\\] the number of trees in the connectivity +* `vertices`:\\[out\\] the list of `vertices` of the connectivity +* `tree_to_vertex`:\\[out\\] the `tree_to_vertex` map of the connectivity # Returns -The newly created connectivity, or NULL on error. +0 if successful and nonzero if not ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_source (sc_io_source_t * source); +int p8est_connectivity_read_inp_stream (FILE * stream, p4est_topidx_t * num_vertices, p4est_topidx_t * num_trees, double *vertices, p4est_topidx_t * tree_to_vertex); ``` """ -function p4est_connectivity_source(source) - @ccall libp4est.p4est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p4est_connectivity_t} +function p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) + @ccall libp4est.p8est_connectivity_read_inp_stream(stream::Ptr{Libc.FILE}, num_vertices::Ptr{p4est_topidx_t}, num_trees::Ptr{p4est_topidx_t}, vertices::Ptr{Cdouble}, tree_to_vertex::Ptr{p4est_topidx_t})::Cint end """ - p4est_connectivity_inflate(buffer) + p8est_connectivity_read_inp(filename) -Create new connectivity from a memory buffer. This function aborts on malloc errors. +Create a p4est connectivity from an ABAQUS input file. -# Arguments -* `buffer`:\\[in\\] The connectivity is created from this memory buffer. -# Returns -The newly created connectivity, or NULL on format error of the buffered connectivity data. -### Prototype -```c -p4est_connectivity_t *p4est_connectivity_inflate (sc_array_t * buffer); -``` -""" -function p4est_connectivity_inflate(buffer) - @ccall libp4est.p4est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p4est_connectivity_t} -end +This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. -""" - p4est_connectivity_load(filename, bytes) +A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: -Load a connectivity structure from disk. +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 + +and in 3D they are given as: + +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 + +```c++ + *Heading + box.inp + *Node + 1, 5, -5, 5 + 2, 5, 5, 5 + 3, 5, 0, 5 + 4, -5, 5, 5 + 5, 0, 5, 5 + 6, -5, -5, 5 + 7, -5, 0, 5 + 8, 0, -5, 5 + 9, 0, 0, 5 + 10, 5, 5, -5 + 11, 5, -5, -5 + 12, 5, 0, -5 + 13, -5, -5, -5 + 14, 0, -5, -5 + 15, -5, 5, -5 + 16, -5, 0, -5 + 17, 0, 5, -5 + 18, 0, 0, -5 + 19, -5, -5, 0 + 20, 5, -5, 0 + 21, 0, -5, 0 + 22, -5, 5, 0 + 23, -5, 0, 0 + 24, 5, 5, 0 + 25, 0, 5, 0 + 26, 5, 0, 0 + 27, 0, 0, 0 + *Element, type=C3D8, ELSET=EB1 + 1, 6, 19, 23, 7, 8, 21, 27, 9 + 2, 19, 13, 16, 23, 21, 14, 18, 27 + 3, 7, 23, 22, 4, 9, 27, 25, 5 + 4, 23, 16, 15, 22, 27, 18, 17, 25 + 5, 8, 21, 27, 9, 1, 20, 26, 3 + 6, 21, 14, 18, 27, 20, 11, 12, 26 + 7, 9, 27, 25, 5, 3, 26, 24, 2 + 8, 27, 18, 17, 25, 26, 12, 10, 24 +``` + +This function reads a mesh from *filename* and returns an associated p4est connectivity. # Arguments -* `filename`:\\[in\\] Name of the file to read. -* `bytes`:\\[in,out\\] Size in bytes of connectivity on disk or NULL. +* `filename`:\\[in\\] file to read the connectivity from # Returns -Returns valid connectivity, or NULL on file error. +an allocated connectivity associated with the mesh in *filename* ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_load (const char *filename, size_t *bytes); +p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename); ``` """ -function p4est_connectivity_load(filename, bytes) - @ccall libp4est.p4est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p4est_connectivity_t} +function p8est_connectivity_read_inp(filename) + @ccall libp4est.p8est_connectivity_read_inp(filename::Cstring)::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_new_unitsquare() - -Create a connectivity structure for the unit square. + t8_cmesh_new_from_p4est(conn, comm, do_partition) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_unitsquare (void); +t8_cmesh_t t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); ``` """ -function p4est_connectivity_new_unitsquare() - @ccall libp4est.p4est_connectivity_new_unitsquare()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_from_p4est(conn, comm, do_partition) + @ccall libt8.t8_cmesh_new_from_p4est(conn::Ptr{p4est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_periodic() - -Create a connectivity structure for an all-periodic unit square. + t8_cmesh_new_from_p8est(conn, comm, do_partition) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_periodic (void); +t8_cmesh_t t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); ``` """ -function p4est_connectivity_new_periodic() - @ccall libp4est.p4est_connectivity_new_periodic()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_from_p8est(conn, comm, do_partition) + @ccall libt8.t8_cmesh_new_from_p8est(conn::Ptr{p8est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_rotwrap() - -Create a connectivity structure for a periodic unit square. The left and right faces are identified, and bottom and top opposite. + t8_cmesh_new_empty(comm, do_partition, dimension) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_rotwrap (void); +t8_cmesh_t t8_cmesh_new_empty (sc_MPI_Comm comm, const int do_partition, const int dimension); ``` """ -function p4est_connectivity_new_rotwrap() - @ccall libp4est.p4est_connectivity_new_rotwrap()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_empty(comm, do_partition, dimension) + @ccall libt8.t8_cmesh_new_empty(comm::MPI_Comm, do_partition::Cint, dimension::Cint)::t8_cmesh_t end -""" - p4est_connectivity_new_circle() - -Create a connectivity structure for an donut-like circle. The circle consists of 6 trees connecting each other by their faces. The trees are laid out as a hexagon between [-2, 2] in the y direction and [-sqrt(3), sqrt(3)] in the x direction. The hexagon has flat sides along the y direction and pointy ends in x. +""" + t8_cmesh_new_from_class(eclass, comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_circle (void); +t8_cmesh_t t8_cmesh_new_from_class (t8_eclass_t eclass, sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_circle() - @ccall libp4est.p4est_connectivity_new_circle()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_from_class(eclass, comm) + @ccall libt8.t8_cmesh_new_from_class(eclass::t8_eclass_t, comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_new_drop() - -Create a connectivity structure for a five-trees geometry with a hole. The geometry covers the square [0, 3]**2, where the hole is [1, 2]**2. + t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_drop (void); +t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int do_partition, int periodic); ``` """ -function p4est_connectivity_new_drop() - @ccall libp4est.p4est_connectivity_new_drop()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) + @ccall libt8.t8_cmesh_new_hypercube(eclass::t8_eclass_t, comm::MPI_Comm, do_bcast::Cint, do_partition::Cint, periodic::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_twotrees(l_face, r_face, orientation) - -Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way + t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) -# Arguments -* `l_face`:\\[in\\] index of left face -* `r_face`:\\[in\\] index of right face -* `orientation`:\\[in\\] orientation of trees w.r.t. each other ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_twotrees (int l_face, int r_face, int orientation); +t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned); ``` """ -function p4est_connectivity_new_twotrees(l_face, r_face, orientation) - @ccall libp4est.p4est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p4est_connectivity_t} +function t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) + @ccall libt8.t8_cmesh_new_hypercube_pad(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, use_axis_aligned::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_corner() - -Create a connectivity structure for a three-tree mesh around a corner. + t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_corner (void); +t8_cmesh_t t8_cmesh_new_hypercube_pad_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int periodic_x, const int periodic_y, const int periodic_z, const int use_axis_aligned, const int set_partition, t8_gloidx_t offset); ``` """ -function p4est_connectivity_new_corner() - @ccall libp4est.p4est_connectivity_new_corner()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) + @ccall libt8.t8_cmesh_new_hypercube_pad_ext(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, periodic_x::Cint, periodic_y::Cint, periodic_z::Cint, use_axis_aligned::Cint, set_partition::Cint, offset::t8_gloidx_t)::t8_cmesh_t end """ - p4est_connectivity_new_pillow() - -Create a connectivity structure for two trees on top of each other. + t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_pillow (void); +t8_cmesh_t t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, int do_partition, int periodic); ``` """ -function p4est_connectivity_new_pillow() - @ccall libp4est.p4est_connectivity_new_pillow()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) + @ccall libt8.t8_cmesh_new_hypercube_hybrid(comm::MPI_Comm, do_partition::Cint, periodic::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_moebius() - -Create a connectivity structure for a five-tree moebius band. + t8_cmesh_new_periodic(comm, dim) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_moebius (void); +t8_cmesh_t t8_cmesh_new_periodic (sc_MPI_Comm comm, int dim); ``` """ -function p4est_connectivity_new_moebius() - @ccall libp4est.p4est_connectivity_new_moebius()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_periodic(comm, dim) + @ccall libt8.t8_cmesh_new_periodic(comm::MPI_Comm, dim::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_star() - -Create a connectivity structure for a six-tree star. + t8_cmesh_new_periodic_tri(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_star (void); +t8_cmesh_t t8_cmesh_new_periodic_tri (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_star() - @ccall libp4est.p4est_connectivity_new_star()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_periodic_tri(comm) + @ccall libt8.t8_cmesh_new_periodic_tri(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_new_cubed() - -Create a connectivity structure for the six sides of a unit cube. The ordering of the trees is as follows: - -0 1 2 3 <-- 3: axis-aligned top side 4 5 - -This choice has been made for maximum symmetry (see tree\\_to\\_* in .c file). + t8_cmesh_new_periodic_hybrid(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_cubed (void); +t8_cmesh_t t8_cmesh_new_periodic_hybrid (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_cubed() - @ccall libp4est.p4est_connectivity_new_cubed()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_periodic_hybrid(comm) + @ccall libt8.t8_cmesh_new_periodic_hybrid(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_new_disk_nonperiodic() - -Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2. + t8_cmesh_new_periodic_line_more_trees(comm) -# Returns -Initialized and usable connectivity. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk_nonperiodic (void); +t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_disk_nonperiodic() - @ccall libp4est.p4est_connectivity_new_disk_nonperiodic()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_periodic_line_more_trees(comm) + @ccall libt8.t8_cmesh_new_periodic_line_more_trees(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_new_disk(periodic_a, periodic_b) - -Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2. - -!!! note - - The API of this function has changed to accept two arguments. You can query the P4EST_CONN_DISK_PERIODIC to check whether the new version with the argument is in effect. - -The ordering of the trees is as follows: - -4 1 2 3 0 - -The outside x faces may be identified topologically. The outside y faces may be identified topologically. Both identifications may be specified simultaneously. The general shape and periodicity are the same as those obtained with p4est_connectivity_new_brick (1, 1, periodic\\_a, periodic\\_b). - -When setting *periodic_a* and *periodic_b* to false, the result is the same as that of p4est_connectivity_new_disk_nonperiodic. + t8_cmesh_new_bigmesh(eclass, num_trees, comm) -# Arguments -* `periodic_a`:\\[in\\] Bool to make disk periodic in x direction. -* `periodic_b`:\\[in\\] Bool to make disk periodic in y direction. -# Returns -Initialized and usable connectivity. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk (int periodic_a, int periodic_b); +t8_cmesh_t t8_cmesh_new_bigmesh (t8_eclass_t eclass, int num_trees, sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_disk(periodic_a, periodic_b) - @ccall libp4est.p4est_connectivity_new_disk(periodic_a::Cint, periodic_b::Cint)::Ptr{p4est_connectivity_t} +function t8_cmesh_new_bigmesh(eclass, num_trees, comm) + @ccall libt8.t8_cmesh_new_bigmesh(eclass::t8_eclass_t, num_trees::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_new_icosahedron() - -Create a connectivity for mapping the sphere using an icosahedron. - -The regular icosadron is a polyhedron with 20 faces, each of which is an equilateral triangle. To build the p4est connectivity, we group faces 2 by 2 to from 10 quadrangles, and thus 10 trees. - -This connectivity is meant to be used together with p4est_geometry_new_icosahedron to map the sphere. - -The flat connectivity looks like that. Vextex numbering: - -A00 A01 A02 A03 A04 / \\ / \\ / \\ / \\ / \\ A05---A06---A07---A08---A09---A10 \\ / \\ / \\ / \\ / \\ / \\ A11---A12---A13---A14---A15---A16 \\ / \\ / \\ / \\ / \\ / A17 A18 A19 A20 A21 - -Origin in A05. - -Tree numbering: - -0 2 4 6 8 1 3 5 7 9 + t8_cmesh_new_line_zigzag(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_icosahedron (void); +t8_cmesh_t t8_cmesh_new_line_zigzag (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_icosahedron() - @ccall libp4est.p4est_connectivity_new_icosahedron()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_line_zigzag(comm) + @ccall libt8.t8_cmesh_new_line_zigzag(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_new_shell2d() - -Create a connectivity structure that builds a 2d spherical shell. p8est_connectivity_new_shell + t8_cmesh_new_prism_cake(comm, num_of_prisms) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_shell2d (void); +t8_cmesh_t t8_cmesh_new_prism_cake (sc_MPI_Comm comm, int num_of_prisms); ``` """ -function p4est_connectivity_new_shell2d() - @ccall libp4est.p4est_connectivity_new_shell2d()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_prism_cake(comm, num_of_prisms) + @ccall libt8.t8_cmesh_new_prism_cake(comm::MPI_Comm, num_of_prisms::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_disk2d() - -Create a connectivity structure that maps a 2d disk. - -This is a 5 trees connectivity meant to be used together with p4est_geometry_new_disk2d to map the disk. + t8_cmesh_new_prism_deformed(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk2d (void); +t8_cmesh_t t8_cmesh_new_prism_deformed (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_disk2d() - @ccall libp4est.p4est_connectivity_new_disk2d()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_prism_deformed(comm) + @ccall libt8.t8_cmesh_new_prism_deformed(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_new_bowtie() - -Create a connectivity structure that maps a 2d bowtie structure. - -The 2 trees are connected by a corner connection at node A3 (0, 0). the nodes are given as: - -A00 A01 / \\ / \\ A02 A03 A04 \\ / \\ / A05 A06 + t8_cmesh_new_pyramid_deformed(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_bowtie (void); +t8_cmesh_t t8_cmesh_new_pyramid_deformed (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_bowtie() - @ccall libp4est.p4est_connectivity_new_bowtie()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_pyramid_deformed(comm) + @ccall libt8.t8_cmesh_new_pyramid_deformed(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_new_brick(mi, ni, periodic_a, periodic_b) - -A rectangular m by n array of trees with configurable periodicity. The brick is periodic in x and y if periodic\\_a and periodic\\_b are true, respectively. + t8_cmesh_new_prism_cake_funny_oriented(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_brick (int mi, int ni, int periodic_a, int periodic_b); +t8_cmesh_t t8_cmesh_new_prism_cake_funny_oriented (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_brick(mi, ni, periodic_a, periodic_b) - @ccall libp4est.p4est_connectivity_new_brick(mi::Cint, ni::Cint, periodic_a::Cint, periodic_b::Cint)::Ptr{p4est_connectivity_t} +function t8_cmesh_new_prism_cake_funny_oriented(comm) + @ccall libt8.t8_cmesh_new_prism_cake_funny_oriented(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_new_byname(name) - -Create connectivity structure from predefined catalogue. + t8_cmesh_new_prism_geometry(comm) -# Arguments -* `name`:\\[in\\] Invokes connectivity\\_new\\_* function. brick23 brick (2, 3, 0, 0) corner corner cubed cubed disk disk moebius moebius periodic periodic pillow pillow rotwrap rotwrap star star unit unitsquare -# Returns -An initialized connectivity if name is defined, NULL else. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_byname (const char *name); +t8_cmesh_t t8_cmesh_new_prism_geometry (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_byname(name) - @ccall libp4est.p4est_connectivity_new_byname(name::Cstring)::Ptr{p4est_connectivity_t} +function t8_cmesh_new_prism_geometry(comm) + @ccall libt8.t8_cmesh_new_prism_geometry(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_refine(conn, num_per_dim) - -Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. + t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) -# Arguments -* `conn`:\\[in\\] A valid connectivity -* `num_per_dim`:\\[in\\] The number of new trees in each direction. Must use no more than P4EST_OLD_QMAXLEVEL bits. -# Returns -a refined connectivity. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_refine (p4est_connectivity_t * conn, int num_per_dim); +t8_cmesh_t t8_cmesh_new_brick_2d (t8_gloidx_t num_x, t8_gloidx_t num_y, int x_periodic, int y_periodic, sc_MPI_Comm comm); ``` """ -function p4est_connectivity_refine(conn, num_per_dim) - @ccall libp4est.p4est_connectivity_refine(conn::Ptr{p4est_connectivity_t}, num_per_dim::Cint)::Ptr{p4est_connectivity_t} +function t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) + @ccall libt8.t8_cmesh_new_brick_2d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - p4est_expand_face_transform(iface, nface, ftransform) - -Fill an array with the axis combination of a face neighbor transform. + t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) -# Arguments -* `iface`:\\[in\\] The number of the originating face. -* `nface`:\\[in\\] Encoded as nface = r * 4 + nf, where nf = 0..3 is the neigbbor's connecting face number and r = 0..1 is the relative orientation to the neighbor's face. This encoding matches [`p4est_connectivity_t`](@ref). -* `ftransform`:\\[out\\] This array holds 9 integers. [0,2] The coordinate axis sequence of the origin face, the first referring to the tangential and the second to the normal. A permutation of (0, 1). [3,5] The coordinate axis sequence of the target face. [6,8] Face reversal flag for tangential axis (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q [1,4,7] 0 (unused for compatibility with 3D). ### Prototype ```c -void p4est_expand_face_transform (int iface, int nface, int ftransform[]); +t8_cmesh_t t8_cmesh_new_brick_3d (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); ``` """ -function p4est_expand_face_transform(iface, nface, ftransform) - @ccall libp4est.p4est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid +function t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + @ccall libt8.t8_cmesh_new_brick_3d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - p4est_find_face_transform(connectivity, itree, iface, ftransform) - -Fill an array with the axis combinations of a tree neighbor transform. + t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) -# Arguments -* `connectivity`:\\[in\\] Connectivity structure. -* `itree`:\\[in\\] The number of the originating tree. -* `iface`:\\[in\\] The number of the originating tree's face. -* `ftransform`:\\[out\\] This array holds 9 integers. [0,2] The coordinate axis sequence of the origin face. [3,5] The coordinate axis sequence of the target face. [6,8] Face reversal flag for axis t; face code for axis n. -# Returns -The face neighbor tree if it exists, -1 otherwise. -# See also -[`p4est_expand_face_transform`](@ref). [1,4,7] 0 (unused for compatibility with 3D). +### Prototype +```c +t8_cmesh_t t8_cmesh_new_disjoint_bricks (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); +``` +""" +function t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + @ccall libt8.t8_cmesh_new_disjoint_bricks(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +end + +""" + t8_cmesh_new_tet_orientation_test(comm) ### Prototype ```c -p4est_topidx_t p4est_find_face_transform (p4est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); +t8_cmesh_t t8_cmesh_new_tet_orientation_test (sc_MPI_Comm comm); ``` """ -function p4est_find_face_transform(connectivity, itree, iface, ftransform) - @ccall libp4est.p4est_find_face_transform(connectivity::Ptr{p4est_connectivity_t}, itree::p4est_topidx_t, iface::Cint, ftransform::Ptr{Cint})::p4est_topidx_t +function t8_cmesh_new_tet_orientation_test(comm) + @ccall libt8.t8_cmesh_new_tet_orientation_test(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_find_corner_transform(connectivity, itree, icorner, ci) - -Fills an array with information about corner neighbors. + t8_cmesh_new_hybrid_gate(comm) -# Arguments -* `connectivity`:\\[in\\] Connectivity structure. -* `itree`:\\[in\\] The number of the originating tree. -* `icorner`:\\[in\\] The number of the originating corner. -* `ci`:\\[in,out\\] A [`p4est_corner_info_t`](@ref) structure with initialized array. ### Prototype ```c -void p4est_find_corner_transform (p4est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p4est_corner_info_t * ci); +t8_cmesh_t t8_cmesh_new_hybrid_gate (sc_MPI_Comm comm); ``` """ -function p4est_find_corner_transform(connectivity, itree, icorner, ci) - @ccall libp4est.p4est_find_corner_transform(connectivity::Ptr{p4est_connectivity_t}, itree::p4est_topidx_t, icorner::Cint, ci::Ptr{p4est_corner_info_t})::Cvoid +function t8_cmesh_new_hybrid_gate(comm) + @ccall libt8.t8_cmesh_new_hybrid_gate(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_complete(conn) - -Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. + t8_cmesh_new_hybrid_gate_deformed(comm) -# Arguments -* `conn`:\\[in,out\\] The connectivity needs to have proper vertices and tree\\_to\\_vertex fields. The tree\\_to\\_tree and tree\\_to\\_face fields must be allocated and satisfy [`p4est_connectivity_is_valid`](@ref) (conn) but will be overwritten. The corner fields will be freed and allocated anew. ### Prototype ```c -void p4est_connectivity_complete (p4est_connectivity_t * conn); +t8_cmesh_t t8_cmesh_new_hybrid_gate_deformed (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_complete(conn) - @ccall libp4est.p4est_connectivity_complete(conn::Ptr{p4est_connectivity_t})::Cvoid +function t8_cmesh_new_hybrid_gate_deformed(comm) + @ccall libt8.t8_cmesh_new_hybrid_gate_deformed(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_reduce(conn) - -Removes corner information of a connectivity such that enough information is left to run [`p4est_connectivity_complete`](@ref) successfully. The reduced connectivity still passes [`p4est_connectivity_is_valid`](@ref). + t8_cmesh_new_full_hybrid(comm) -# Arguments -* `conn`:\\[in,out\\] The connectivity to be reduced. ### Prototype ```c -void p4est_connectivity_reduce (p4est_connectivity_t * conn); +t8_cmesh_t t8_cmesh_new_full_hybrid (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_reduce(conn) - @ccall libp4est.p4est_connectivity_reduce(conn::Ptr{p4est_connectivity_t})::Cvoid +function t8_cmesh_new_full_hybrid(comm) + @ccall libt8.t8_cmesh_new_full_hybrid(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_permute(conn, perm, is_current_to_new) - -[`p4est_connectivity_permute`](@ref) Given a permutation *perm* of the trees in a connectivity *conn*, permute the trees of *conn* in place and update *conn* to match. + t8_cmesh_new_pyramid_cake(comm, num_of_pyra) -# Arguments -* `conn`:\\[in,out\\] The connectivity whose trees are permuted. -* `perm`:\\[in\\] A permutation array, whose elements are size\\_t's. -* `is_current_to_new`:\\[in\\] if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation. ### Prototype ```c -void p4est_connectivity_permute (p4est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); +t8_cmesh_t t8_cmesh_new_pyramid_cake (sc_MPI_Comm comm, int num_of_pyra); ``` """ -function p4est_connectivity_permute(conn, perm, is_current_to_new) - @ccall libp4est.p4est_connectivity_permute(conn::Ptr{p4est_connectivity_t}, perm::Ptr{sc_array_t}, is_current_to_new::Cint)::Cvoid +function t8_cmesh_new_pyramid_cake(comm, num_of_pyra) + @ccall libt8.t8_cmesh_new_pyramid_cake(comm::MPI_Comm, num_of_pyra::Cint)::t8_cmesh_t end """ - p4est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) - -[`p4est_connectivity_join_faces`](@ref) This function takes an existing valid connectivity *conn* and modifies it by joining two tree faces that are currently boundary faces. + t8_cmesh_new_long_brick_pyramid(comm, num_cubes) -# Arguments -* `conn`:\\[in,out\\] connectivity that will be altered. -* `tree_left`:\\[in\\] tree that will be on the left side of the joined faces. -* `tree_right`:\\[in\\] tree that will be on the right side of the joined faces. -* `face_left`:\\[in\\] face of *tree_left* that will be joined. -* `face_right`:\\[in\\] face of *tree_right* that will be joined. -* `orientation`:\\[in\\] the orientation of *face_left* and *face_right* once joined (see the description of [`p4est_connectivity_t`](@ref) to understand orientation). ### Prototype ```c -void p4est_connectivity_join_faces (p4est_connectivity_t * conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation); +t8_cmesh_t t8_cmesh_new_long_brick_pyramid (sc_MPI_Comm comm, int num_cubes); ``` """ -function p4est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) - @ccall libp4est.p4est_connectivity_join_faces(conn::Ptr{p4est_connectivity_t}, tree_left::p4est_topidx_t, tree_right::p4est_topidx_t, face_left::Cint, face_right::Cint, orientation::Cint)::Cvoid +function t8_cmesh_new_long_brick_pyramid(comm, num_cubes) + @ccall libt8.t8_cmesh_new_long_brick_pyramid(comm::MPI_Comm, num_cubes::Cint)::t8_cmesh_t end """ - p4est_connectivity_is_equivalent(conn1, conn2) - -[`p4est_connectivity_is_equivalent`](@ref) This function compares two connectivities for equivalence: it returns *true* if they are the same connectivity, or if they have the same topology. The definition of topological sameness is strict: there is no attempt made to determine whether permutation and/or rotation of the trees makes the connectivities equivalent. + t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm, package_id) -# Arguments -* `conn1`:\\[in\\] a valid connectivity -* `conn2`:\\[out\\] a valid connectivity ### Prototype ```c -int p4est_connectivity_is_equivalent (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); +t8_cmesh_t t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, const int do_partition, sc_MPI_Comm comm, const int package_id); ``` """ -function p4est_connectivity_is_equivalent(conn1, conn2) - @ccall libp4est.p4est_connectivity_is_equivalent(conn1::Ptr{p4est_connectivity_t}, conn2::Ptr{p4est_connectivity_t})::Cint +function t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm, package_id) + @ccall libt8.t8_cmesh_new_row_of_cubes(num_trees::t8_locidx_t, set_attributes::Cint, do_partition::Cint, comm::MPI_Comm, package_id::Cint)::t8_cmesh_t end """ - p4est_corner_array_index(array, it) + t8_cmesh_new_quadrangulated_disk(radius, comm) ### Prototype ```c -static inline p4est_corner_transform_t * p4est_corner_array_index (sc_array_t * array, size_t it); +t8_cmesh_t t8_cmesh_new_quadrangulated_disk (const double radius, sc_MPI_Comm comm); ``` """ -function p4est_corner_array_index(array, it) - @ccall libp4est.p4est_corner_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p4est_corner_transform_t} +function t8_cmesh_new_quadrangulated_disk(radius, comm) + @ccall libt8.t8_cmesh_new_quadrangulated_disk(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) - -Read an ABAQUS input file from a file stream. - -This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. - -A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: - -4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 - -and in 3D they are given as: - -8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 + t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) -```c++ - *Heading - box.inp - *Node - 1, -5, -5, 0 - 2, 5, -5, 0 - 3, 5, 5, 0 - 4, -5, 5, 0 - 5, 0, -5, 0 - 6, 5, 0, 0 - 7, 0, 5, 0 - 8, -5, 0, 0 - 9, 1, -1, 0 - 10, 0, 0, 0 - 11, -2, 1, 0 - *Element, type=CPS4, ELSET=Surface1 - 1, 1, 10, 11, 8 - 2, 3, 10, 9, 6 - 3, 9, 10, 1, 5 - 4, 7, 4, 8, 11 - 5, 11, 10, 3, 7 - 6, 2, 6, 9, 5 +### Prototype +```c +t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_MPI_Comm comm); ``` +""" +function t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) + @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_octahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +end -This code can be called two ways. The first, when `vertex`==NULL and `tree_to_vertex`==NULL, is used to count the number of trees and vertices in the connectivity to be generated by the `.inp` mesh in the *stream*. The second, when `vertices`!=NULL and `tree_to_vertex`!=NULL, fill `vertices` and `tree_to_vertex`. In this case `num_vertices` and `num_trees` need to be set to the maximum number of entries allocated in `vertices` and `tree_to_vertex`. +""" + t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) -# Arguments -* `stream`:\\[in,out\\] file stream to read the connectivity from -* `num_vertices`:\\[in,out\\] the number of vertices in the connectivity -* `num_trees`:\\[in,out\\] the number of trees in the connectivity -* `vertices`:\\[out\\] the list of `vertices` of the connectivity -* `tree_to_vertex`:\\[out\\] the `tree_to_vertex` map of the connectivity -# Returns -0 if successful and nonzero if not ### Prototype ```c -int p4est_connectivity_read_inp_stream (FILE * stream, p4est_topidx_t * num_vertices, p4est_topidx_t * num_trees, double *vertices, p4est_topidx_t * tree_to_vertex); +t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc_MPI_Comm comm); ``` """ -function p4est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) - @ccall libp4est.p4est_connectivity_read_inp_stream(stream::Ptr{Libc.FILE}, num_vertices::Ptr{p4est_topidx_t}, num_trees::Ptr{p4est_topidx_t}, vertices::Ptr{Cdouble}, tree_to_vertex::Ptr{p4est_topidx_t})::Cint +function t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) + @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_read_inp(filename) - -Create a p4est connectivity from an ABAQUS input file. - -This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. - -A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: - -4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 - -and in 3D they are given as: - -8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 + t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) -```c++ - *Heading - box.inp - *Node - 1, -5, -5, 0 - 2, 5, -5, 0 - 3, 5, 5, 0 - 4, -5, 5, 0 - 5, 0, -5, 0 - 6, 5, 0, 0 - 7, 0, 5, 0 - 8, -5, 0, 0 - 9, 1, -1, 0 - 10, 0, 0, 0 - 11, -2, 1, 0 - *Element, type=CPS4, ELSET=Surface1 - 1, 1, 10, 11, 8 - 2, 3, 10, 9, 6 - 3, 9, 10, 1, 5 - 4, 7, 4, 8, 11 - 5, 11, 10, 3, 7 - 6, 2, 6, 9, 5 +### Prototype +```c +t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Comm comm); ``` +""" +function t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) + @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_cube(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +end -This function reads a mesh from *filename* and returns an associated p4est connectivity. +""" + t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) -# Arguments -* `filename`:\\[in\\] file to read the connectivity from -# Returns -an allocated connectivity associated with the mesh in *filename* or NULL if an error occurred. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_read_inp (const char *filename); +t8_cmesh_t t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm); ``` """ -function p4est_connectivity_read_inp(filename) - @ccall libp4est.p4est_connectivity_read_inp(filename::Cstring)::Ptr{p4est_connectivity_t} +function t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) + @ccall libt8.t8_cmesh_new_quadrangulated_spherical_surface(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - p8est_connect_type_t - -Characterize a type of adjacency. - -Several functions involve relationships between neighboring trees and/or quadrants, and their behavior depends on how one defines adjacency: 1) entities are adjacent if they share a face, or 2) entities are adjacent if they share a face or corner, or 3) entities are adjacent if they share a face, corner or edge. [`p8est_connect_type_t`](@ref) is used to choose the desired behavior. This enum must fit into an int8\\_t. + t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) -| Enumerator | Note | -| :----------------------- | :------------------------------- | -| P8EST\\_CONNECT\\_SELF | No balance whatsoever. | -| P8EST\\_CONNECT\\_FACE | Balance across faces only. | -| P8EST\\_CONNECT\\_EDGE | Balance across faces and edges. | -| P8EST\\_CONNECT\\_ALMOST | = CORNER - 1. | -| P8EST\\_CONNECT\\_CORNER | Balance faces, edges, corners. | -| P8EST\\_CONNECT\\_FULL | = CORNER. | +### Prototype +```c +t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_octahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); +``` """ -@cenum p8est_connect_type_t::UInt32 begin - P8EST_CONNECT_SELF = 30 - P8EST_CONNECT_FACE = 31 - P8EST_CONNECT_EDGE = 32 - P8EST_CONNECT_ALMOST = 32 - P8EST_CONNECT_CORNER = 33 - P8EST_CONNECT_FULL = 33 +function t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + @ccall libt8.t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - p8est_connectivity_encode_t - -Typedef for serialization method. + t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) -| Enumerator | Note | -| :--------------------------- | :-------------------------------- | -| P8EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | +### Prototype +```c +t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_icosahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); +``` """ -@cenum p8est_connectivity_encode_t::UInt32 begin - P8EST_CONN_ENCODE_NONE = 0 - P8EST_CONN_ENCODE_LAST = 1 +function t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + @ccall libt8.t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - p8est_connect_type_int(btype) - -Convert the [`p8est_connect_type_t`](@ref) into a number. + t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) -# Arguments -* `btype`:\\[in\\] The balance type to convert. -# Returns -Returns 1, 2 or 3. ### Prototype ```c -int p8est_connect_type_int (p8est_connect_type_t btype); +t8_cmesh_t t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_trees, const int num_layers, sc_MPI_Comm comm); ``` """ -function p8est_connect_type_int(btype) - @ccall libp4est.p8est_connect_type_int(btype::p8est_connect_type_t)::Cint +function t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) + @ccall libt8.t8_cmesh_new_cubed_spherical_shell(inner_radius::Cdouble, shell_thickness::Cdouble, num_trees::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t end """ - p8est_connect_type_string(btype) - -Convert the [`p8est_connect_type_t`](@ref) into a const string. + t8_cmesh_new_cubed_sphere(radius, comm) -# Arguments -* `btype`:\\[in\\] The balance type to convert. -# Returns -Returns a pointer to a constant string. ### Prototype ```c -const char *p8est_connect_type_string (p8est_connect_type_t btype); +t8_cmesh_t t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm); ``` """ -function p8est_connect_type_string(btype) - @ccall libp4est.p8est_connect_type_string(btype::p8est_connect_type_t)::Cstring +function t8_cmesh_new_cubed_sphere(radius, comm) + @ccall libt8.t8_cmesh_new_cubed_sphere(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - p8est_connectivity + t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) -This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible. +Sets the face connectivity information of an un-committed cmesh based on a list of tree vertices. -The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. zyx is 000 001 010 011 100 101 110 111. For faces the order is -x +x -y +y -z +z. They are allocated [0][0]..[0][N-1]..[num\\_trees-1][0]..[num\\_trees-1][N-1]. where N is 6 for tree and face, 8 for corner, 12 for edge. If a face is on the physical boundary it must connect to itself. +!!! warning -The values for tree\\_to\\_face are in 0..23 where ttf % 6 gives the face number and ttf / 6 the face orientation code. The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees in 0..5. Then the first face corner of the lower of my\\_face and other\\_face connects to a face corner numbered 0..3 in the higher of my\\_face and other\\_face. The face orientation is defined as this number. If my\\_face == other\\_face, treating either of both faces as the lower one leads to the same result. + This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. -It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. +!!! note -The edges are stored when they connect trees that are not already face neighbors at that specific edge. In this case tree\\_to\\_edge indexes into *ett_offset*. Otherwise the tree\\_to\\_edge entry must be -1 and this edge is ignored. If num\\_edges == 0, tree\\_to\\_edge and edge\\_to\\_* arrays are set to NULL. + This routine does not detect periodic boundaries. -The arrays edge\\_to\\_* store a variable number of entries per edge. For edge e these are at position [ett\\_offset[e]]..[ett\\_offset[e+1]-1]. Their number for edge e is ett\\_offset[e+1] - ett\\_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge\\_to\\_* arrays is num\\_ett = ett\\_offset[num\\_edges]. The edge\\_to\\_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation. +# Arguments +* `cmesh`:\\[in,out\\] Pointer to a t8code cmesh object. If set to NULL this argument is ignored. +* `ntrees`:\\[in\\] Number of coarse mesh elements resp. trees. +* `vertices`:\\[in\\] List of per element vertices with dimensions [ntrees,[`T8_ECLASS_MAX_CORNERS`](@ref),[`T8_ECLASS_MAX_DIM`](@ref)]. +* `eclasses`:\\[in\\] List of element classes of length [ntrees]. +* `connectivity`:\\[in,out\\] If connectivity is not NULL the variable is filled with a pointer to an allocated face connectivity array. The ownership of this array goes to the caller. This argument is mainly used for debugging and testing purposes. The dimension of *connectivity* are [ntrees,[`T8_ECLASS_MAX_FACES`](@ref),3]. For each element and each face the following is stored: neighbor\\_tree\\_id, neighbor\\_dual\\_face\\_id, orientation +* `do_both_directions`:\\[in\\] Compute the connectivity from both neighboring sides. Takes much longer to compute. +### Prototype +```c +void t8_cmesh_set_join_by_vertices (t8_cmesh_t cmesh, const t8_gloidx_t ntrees, const t8_eclass_t *eclasses, const double *vertices, int **connectivity, const int do_both_directions); +``` +""" +function t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) + @ccall libt8.t8_cmesh_set_join_by_vertices(cmesh::t8_cmesh_t, ntrees::t8_gloidx_t, eclasses::Ptr{t8_eclass_t}, vertices::Ptr{Cdouble}, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid +end -The corners are stored when they connect trees that are not already edge or face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. +""" + t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) -The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. +Sets the face connectivity information of an un-committed cmesh based on the cmesh stash. -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. +!!! warning + + This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. !!! note - If a connectivity implies natural connections between trees that are edge neighbors without being face neighbors, these edges shall be encoded explicitly in the connectivity. If a connectivity implies natural connections between trees that are corner neighbors without being edge or face neighbors, these corners shall be encoded explicitly in the connectivity. + This routine does not detect periodic boundaries. -| Field | Note | -| :------------------- | :----------------------------------------------------------------------------------- | -| num\\_vertices | the number of vertices that define the *embedding* of the forest (not the topology) | -| num\\_trees | the number of trees | -| num\\_edges | the number of edges that help define the topology | -| num\\_corners | the number of corners that help define the topology | -| vertices | an array of size (3 * *num_vertices*) | -| tree\\_to\\_vertex | embed each tree into ```c++ R^3 ``` for e.g. visualization (see p8est\\_vtk.h) | -| tree\\_attr\\_bytes | bytes per tree in tree\\_to\\_attr | -| tree\\_to\\_attr | not touched by p4est | -| tree\\_to\\_tree | (6 * *num_trees*) neighbors across faces | -| tree\\_to\\_face | (6 * *num_trees*) face to face+orientation (see description) | -| tree\\_to\\_edge | (12 * *num_trees*) or NULL (see description) | -| ett\\_offset | edge to offset in *edge_to_tree* and *edge_to_edge* | -| edge\\_to\\_tree | list of trees that meet at an edge | -| edge\\_to\\_edge | list of tree-edges+orientations that meet at an edge (see description) | -| tree\\_to\\_corner | (8 * *num_trees*) or NULL (see description) | -| ctt\\_offset | corner to offset in *corner_to_tree* and *corner_to_corner* | -| corner\\_to\\_tree | list of trees that meet at a corner | -| corner\\_to\\_corner | list of tree-corners that meet at a corner | +# Arguments +* `cmesh`:\\[in,out\\] An uncommitted cmesh. The trees eclasses and vertices do need to be set. +* `connectivity`:\\[in,out\\] If connectivity is not NULL the variable is filled with a pointer to an allocated face connectivity array. The ownership of this array goes to the caller. This argument is mainly used for debugging and testing purposes. The dimension of *connectivity* are [ntrees,[`T8_ECLASS_MAX_FACES`](@ref),3]. For each element and each face the following is stored: neighbor\\_tree\\_id, neighbor\\_dual\\_face\\_id, orientation +* `do_both_directions`:\\[in\\] Compute the connectivity from both neighboring sides. Takes much longer to compute. +### Prototype +```c +void t8_cmesh_set_join_by_stash (t8_cmesh_t cmesh, int **connectivity, const int do_both_directions); +``` """ -struct p8est_connectivity - num_vertices::p4est_topidx_t - num_trees::p4est_topidx_t - num_edges::p4est_topidx_t - num_corners::p4est_topidx_t - vertices::Ptr{Cdouble} - tree_to_vertex::Ptr{p4est_topidx_t} - tree_attr_bytes::Csize_t - tree_to_attr::Cstring - tree_to_tree::Ptr{p4est_topidx_t} - tree_to_face::Ptr{Int8} - tree_to_edge::Ptr{p4est_topidx_t} - ett_offset::Ptr{p4est_topidx_t} - edge_to_tree::Ptr{p4est_topidx_t} - edge_to_edge::Ptr{Int8} - tree_to_corner::Ptr{p4est_topidx_t} - ctt_offset::Ptr{p4est_topidx_t} - corner_to_tree::Ptr{p4est_topidx_t} - corner_to_corner::Ptr{Int8} +function t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) + @ccall libt8.t8_cmesh_set_join_by_stash(cmesh::t8_cmesh_t, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid end """ -This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible. - -The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. zyx is 000 001 010 011 100 101 110 111. For faces the order is -x +x -y +y -z +z. They are allocated [0][0]..[0][N-1]..[num\\_trees-1][0]..[num\\_trees-1][N-1]. where N is 6 for tree and face, 8 for corner, 12 for edge. If a face is on the physical boundary it must connect to itself. - -The values for tree\\_to\\_face are in 0..23 where ttf % 6 gives the face number and ttf / 6 the face orientation code. The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees in 0..5. Then the first face corner of the lower of my\\_face and other\\_face connects to a face corner numbered 0..3 in the higher of my\\_face and other\\_face. The face orientation is defined as this number. If my\\_face == other\\_face, treating either of both faces as the lower one leads to the same result. - -It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. - -The edges are stored when they connect trees that are not already face neighbors at that specific edge. In this case tree\\_to\\_edge indexes into *ett_offset*. Otherwise the tree\\_to\\_edge entry must be -1 and this edge is ignored. If num\\_edges == 0, tree\\_to\\_edge and edge\\_to\\_* arrays are set to NULL. - -The arrays edge\\_to\\_* store a variable number of entries per edge. For edge e these are at position [ett\\_offset[e]]..[ett\\_offset[e+1]-1]. Their number for edge e is ett\\_offset[e+1] - ett\\_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge\\_to\\_* arrays is num\\_ett = ett\\_offset[num\\_edges]. The edge\\_to\\_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation. + t8_element_array_t -The corners are stored when they connect trees that are not already edge or face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. +The [`t8_element_array_t`](@ref) is an array to store [`t8_element_t`](@ref) * of a given eclass\\_scheme implementation. It is a wrapper around [`sc_array_t`](@ref). Each time, a new element is created by the functions for t8_element_array_t, the eclass function either t8_element_new or t8_element_init is called for the element. Thus, each element in a t8_element_array_t is automatically initialized properly. -The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. +| Field | Note | +| :----------- | :----------------------------------------------------- | +| scheme | The scheme of which elements should be stored. | +| tree\\_class | !< A scheme of which elements should be stored | +| array | !< The tree class of the elements stored in the array | +""" +struct t8_element_array_t + scheme::Ptr{t8_scheme_c} + tree_class::t8_eclass_t + array::sc_array_t +end -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. +""" + t8_element_array_new(scheme, tree_class) -!!! note +Creates a new array structure with 0 elements. - If a connectivity implies natural connections between trees that are edge neighbors without being face neighbors, these edges shall be encoded explicitly in the connectivity. If a connectivity implies natural connections between trees that are corner neighbors without being edge or face neighbors, these corners shall be encoded explicitly in the connectivity. +# Arguments +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. +# Returns +Return an allocated array of zero length. +### Prototype +```c +t8_element_array_t * t8_element_array_new (const t8_scheme_c *scheme, const t8_eclass_t tree_class); +``` """ -const p8est_connectivity_t = p8est_connectivity +function t8_element_array_new(scheme, tree_class) + @ccall libt8.t8_element_array_new(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Ptr{t8_element_array_t} +end """ - p8est_connectivity_memory_used(conn) + t8_element_array_new_count(scheme, tree_class, num_elements) -Calculate memory usage of a connectivity structure. +Creates a new array structure with a given length (number of elements) and calls t8_element_new for those elements. # Arguments -* `conn`:\\[in\\] Connectivity structure. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. +* `num_elements`:\\[in\\] Initial number of array elements. # Returns -Memory used in bytes. +Return an allocated array with allocated and initialized elements for which t8_element_new was called. ### Prototype ```c -size_t p8est_connectivity_memory_used (p8est_connectivity_t * conn); +t8_element_array_t * t8_element_array_new_count (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t num_elements); ``` """ -function p8est_connectivity_memory_used(conn) - @ccall libp4est.p8est_connectivity_memory_used(conn::Ptr{p8est_connectivity_t})::Csize_t +function t8_element_array_new_count(scheme, tree_class, num_elements) + @ccall libt8.t8_element_array_new_count(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, num_elements::Csize_t)::Ptr{t8_element_array_t} end """ - p8est_edge_transform_t + t8_element_array_init(element_array, scheme, tree_class) -Generic interface for transformations between a tree and any of its edge +Initializes an already allocated (or static) array structure. -| Field | Note | -| :------ | :--------------------------------- | -| ntree | The number of the tree | -| nedge | The number of the edge | -| naxis | The 3 edge coordinate axes | -| nflip | The orientation of the edge | -| corners | The corners connected to the edge | +# Arguments +* `element_array`:\\[in,out\\] Array structure to be initialized. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. +### Prototype +```c +void t8_element_array_init (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class); +``` """ -struct p8est_edge_transform_t - ntree::p4est_topidx_t - nedge::Int8 - naxis::NTuple{3, Int8} - nflip::Int8 - corners::Int8 +function t8_element_array_init(element_array, scheme, tree_class) + @ccall libt8.t8_element_array_init(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cvoid end """ - p8est_edge_info_t + t8_element_array_init_size(element_array, scheme, tree_class, num_elements) -Information about the neighbors of an edge +Initializes an already allocated (or static) array structure and allocates a given number of elements and initializes them with t8_element_init. -| Field | Note | -| :---------------- | :---------------------------------------------- | -| iedge | The information of the edge | -| edge\\_transforms | The array of neighbors of the originating edge | +# Arguments +* `element_array`:\\[in,out\\] Array structure to be initialized. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. +* `num_elements`:\\[in\\] Number of initial array elements. +### Prototype +```c +void t8_element_array_init_size (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t num_elements); +``` """ -struct p8est_edge_info_t - iedge::Int8 - edge_transforms::sc_array_t +function t8_element_array_init_size(element_array, scheme, tree_class, num_elements) + @ccall libt8.t8_element_array_init_size(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, num_elements::Csize_t)::Cvoid end """ - p8est_corner_transform_t + t8_element_array_init_view(view, array, offset, length) -Generic interface for transformations between a tree and any of its corner +Initializes an already allocated (or static) view from existing t8\\_element\\_array. The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). -| Field | Note | -| :------ | :------------------------ | -| ntree | The number of the tree | -| ncorner | The number of the corner | +# Arguments +* `view`:\\[in,out\\] Array structure to be initialized. +* `array`:\\[in\\] The array must not be resized while view is alive. +* `offset`:\\[in\\] The offset of the viewed section in element units. This offset cannot be changed until the view is reset. +* `length`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`sc_array_reset`](@ref) later. +### Prototype +```c +void t8_element_array_init_view (t8_element_array_t *view, const t8_element_array_t *array, const size_t offset, const size_t length); +``` """ -struct p8est_corner_transform_t - ntree::p4est_topidx_t - ncorner::Int8 +function t8_element_array_init_view(view, array, offset, length) + @ccall libt8.t8_element_array_init_view(view::Ptr{t8_element_array_t}, array::Ptr{t8_element_array_t}, offset::Csize_t, length::Csize_t)::Cvoid end +mutable struct t8_element end + +"""Opaque structure for a generic element, only used as pointer. Implementations are free to cast it to their internal data structure.""" +const t8_element_t = t8_element + """ - p8est_corner_info_t + t8_element_array_init_data(view, base, scheme, tree_class, elem_count) -Information about the neighbors of a corner +Initializes an already allocated (or static) view from given plain C data (array of [`t8_element_t`](@ref)). The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). -| Field | Note | -| :------------------ | :------------------------------------------------ | -| icorner | The number of the originating corner | -| corner\\_transforms | The array of neighbors of the originating corner | +# Arguments +* `view`:\\[in,out\\] Array structure to be initialized. +* `base`:\\[in\\] The data must not be moved while view is alive. Must be an array of [`t8_element_t`](@ref) corresponding to *scheme*. +* `scheme`:\\[in\\] The scheme of the elements stored in *base*. +* `tree_class`:\\[in\\] The tree class of the elements stored in *base*. +* `elem_count`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`t8_element_array_reset`](@ref) later. +### Prototype +```c +void t8_element_array_init_data (t8_element_array_t *view, const t8_element_t *base, const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t elem_count); +``` """ -struct p8est_corner_info_t - icorner::p4est_topidx_t - corner_transforms::sc_array_t +function t8_element_array_init_data(view, base, scheme, tree_class, elem_count) + @ccall libt8.t8_element_array_init_data(view::Ptr{t8_element_array_t}, base::Ptr{t8_element_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem_count::Csize_t)::Cvoid end """ - p8est_neighbor_transform_t + t8_element_array_init_copy(element_array, scheme, tree_class, data, num_elements) -Generic interface for transformations between a tree and any of its neighbors +Initializes an already allocated (or static) array structure and copy an existing array of [`t8_element_t`](@ref) into it. -| Field | Note | -| :---------------- | :-------------------------------------------------------------------------- | -| neighbor\\_type | type of connection to neighbor | -| neighbor | neighbor tree index | -| index\\_self | index of interface from self's perspective | -| index\\_neighbor | index of interface from neighbor's perspective | -| perm | permutation of dimensions when transforming self coords to neighbor coords | -| sign | sign changes when transforming self coords to neighbor coords | -| origin\\_self | point on the interface from self's perspective | -| origin\\_neighbor | point on the interface from neighbor's perspective | +# Arguments +* `element_array`:\\[in,out\\] Array structure to be initialized. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. +* `data`:\\[in\\] An array of [`t8_element_t`](@ref) which will be copied into *element_array*. The elements in *data* must belong to *scheme* and must be properly initialized with either t8_element_new or t8_element_init. +* `num_elements`:\\[in\\] Number of elements in *data* to be copied. +### Prototype +```c +void t8_element_array_init_copy (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *data, const size_t num_elements); +``` """ -struct p8est_neighbor_transform_t - neighbor_type::p8est_connect_type_t - neighbor::p4est_topidx_t - index_self::Int8 - index_neighbor::Int8 - perm::NTuple{3, Int8} - sign::NTuple{3, Int8} - origin_self::NTuple{3, p4est_qcoord_t} - origin_neighbor::NTuple{3, p4est_qcoord_t} +function t8_element_array_init_copy(element_array, scheme, tree_class, data, num_elements) + @ccall libt8.t8_element_array_init_copy(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, data::Ptr{t8_element_t}, num_elements::Csize_t)::Cvoid end """ - p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + t8_element_array_resize(element_array, new_count) -Transform from self's coordinate system to neighbor's coordinate system. +Change the number of elements stored in an element array. + +!!! note + + If *new_count* is larger than the number of current elements on *element_array*, then t8_element_init is called for the new elements. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `element_array`:\\[in,out\\] The element array to be modified. +* `new_count`:\\[in\\] The new element count of the array. If it is zero the effect equals t8_element_array_reset. ### Prototype ```c -void p8est_neighbor_transform_coordinates (const p8est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P8EST_DIM], p4est_qcoord_t neigh_coords[P8EST_DIM]); +void t8_element_array_resize (t8_element_array_t *element_array, const size_t new_count); ``` """ -function p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) - @ccall libp4est.p8est_neighbor_transform_coordinates(nt::Ptr{p8est_neighbor_transform_t}, self_coords::Ptr{p4est_qcoord_t}, neigh_coords::Ptr{p4est_qcoord_t})::Cvoid +function t8_element_array_resize(element_array, new_count) + @ccall libt8.t8_element_array_resize(element_array::Ptr{t8_element_array_t}, new_count::Csize_t)::Cvoid end """ - p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + t8_element_array_copy(dest, src) -Transform from neighbor's coordinate system to self's coordinate system. +Copy the contents of an array into another. Both arrays must have the same eclass\\_scheme. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `dest`:\\[in\\] Array will be resized and get new data. +* `src`:\\[in\\] Array used as source of new data, will not be changed. ### Prototype ```c -void p8est_neighbor_transform_coordinates_reverse (const p8est_neighbor_transform_t * nt, const p4est_qcoord_t neigh_coords[P8EST_DIM], p4est_qcoord_t self_coords[P8EST_DIM]); +void t8_element_array_copy (t8_element_array_t *dest, const t8_element_array_t *src); ``` """ -function p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) - @ccall libp4est.p8est_neighbor_transform_coordinates_reverse(nt::Ptr{p8est_neighbor_transform_t}, neigh_coords::Ptr{p4est_qcoord_t}, self_coords::Ptr{p4est_qcoord_t})::Cvoid +function t8_element_array_copy(dest, src) + @ccall libt8.t8_element_array_copy(dest::Ptr{t8_element_array_t}, src::Ptr{t8_element_array_t})::Cvoid end """ - p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + t8_element_array_push(element_array) -Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects +Enlarge an array by one element. # Arguments -* `conn`:\\[in\\] Connectivity structure. -* `tree_id`:\\[in\\] The number of the tree. -* `boundary_type`:\\[in\\] Type of boundary connection (self, face, edge, corner). -* `boundary_index`:\\[in\\] The index of the boundary. -* `neighbor_transform_array`:\\[in,out\\] Array of the neighbor transforms. +* `element_array`:\\[in,out\\] Array structure to be modified. +# Returns +Returns a pointer to a newly added element for which t8_element_init was called. ### Prototype ```c -void p8est_connectivity_get_neighbor_transforms (p8est_connectivity_t *conn, p4est_topidx_t tree_id, p8est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array); +t8_element_t * t8_element_array_push (t8_element_array_t *element_array); ``` """ -function p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) - @ccall libp4est.p8est_connectivity_get_neighbor_transforms(conn::Ptr{p8est_connectivity_t}, tree_id::p4est_topidx_t, boundary_type::p8est_connect_type_t, boundary_index::Cint, neighbor_transform_array::Ptr{sc_array_t})::Cvoid +function t8_element_array_push(element_array) + @ccall libt8.t8_element_array_push(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} end """ - p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) + t8_element_array_push_count(element_array, count) -Transform a corner across one of the adjacent faces into a neighbor tree. It expects a face permutation index that has been precomputed. +Enlarge an array by a number of elements. # Arguments -* `c`:\\[in\\] A corner number in 0..7. -* `f`:\\[in\\] A face number that touches the corner *c*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `set`:\\[in\\] A value from *p8est_face_permutation_sets* that is obtained using *f*, *nf*, and a valid orientation: ref = p8est\\_face\\_permutation\\_refs[f][nf]; set = p8est\\_face\\_permutation\\_sets[ref][orientation]; +* `element_array`:\\[in,out\\] Array structure to be modified. +* `count`:\\[in\\] The number of elements to add. # Returns -The corner number in 0..7 seen from the other face. +Returns a pointer to the newly added elements for which t8_element_init was called. ### Prototype ```c -int p8est_connectivity_face_neighbor_corner_set (int c, int f, int nf, int set); +t8_element_t * t8_element_array_push_count (t8_element_array_t *element_array, size_t count); ``` """ -function p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) - @ccall libp4est.p8est_connectivity_face_neighbor_corner_set(c::Cint, f::Cint, nf::Cint, set::Cint)::Cint +function t8_element_array_push_count(element_array, count) + @ccall libt8.t8_element_array_push_count(element_array::Ptr{t8_element_array_t}, count::Csize_t)::Ptr{t8_element_t} end """ - p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + t8_element_array_index_locidx(element_array, index) -Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Return a given element in an array. Const version. # Arguments -* `fc`:\\[in\\] A face corner number in 0..3. -* `f`:\\[in\\] A face that the face corner *fc* is relative to. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -The face corner number relative to the neighbor's face. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -int p8est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); +const t8_element_t * t8_element_array_index_locidx (const t8_element_array_t *element_array, const t8_locidx_t index); ``` """ -function p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_face_corner(fc::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_element_array_index_locidx(element_array, index) + @ccall libt8.t8_element_array_index_locidx(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} end """ - p8est_connectivity_face_neighbor_corner(c, f, nf, o) + t8_element_array_index_int(element_array, index) -Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Return a given element in an array. Const version. # Arguments -* `c`:\\[in\\] A corner number in 0..7. -* `f`:\\[in\\] A face number that touches the corner *c*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -The number of the corner seen from the neighbor tree. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -int p8est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); +const t8_element_t * t8_element_array_index_int (const t8_element_array_t *element_array, const int index); ``` """ -function p8est_connectivity_face_neighbor_corner(c, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_corner(c::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_element_array_index_int(element_array, index) + @ccall libt8.t8_element_array_index_int(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} end """ - p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) + t8_element_array_index_locidx_mutable(element_array, index) -Transform a face-edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Return a given element in an array. Mutable version. # Arguments -* `fe`:\\[in\\] A face edge number in 0..3. -* `f`:\\[in\\] A face number that touches the edge *e*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -The face edge number seen from the neighbor tree. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -int p8est_connectivity_face_neighbor_face_edge (int fe, int f, int nf, int o); +t8_element_t * t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, const t8_locidx_t index); ``` """ -function p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_face_edge(fe::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_element_array_index_locidx_mutable(element_array, index) + @ccall libt8.t8_element_array_index_locidx_mutable(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} end """ - p8est_connectivity_face_neighbor_edge(e, f, nf, o) + t8_element_array_index_int_mutable(element_array, index) -Transform an edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Return a given element in an array. Mutable version. # Arguments -* `e`:\\[in\\] A edge number in 0..11. -* `f`:\\[in\\] A face 0..5 that touches the edge *e*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -The edge's number seen from the neighbor. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -int p8est_connectivity_face_neighbor_edge (int e, int f, int nf, int o); +t8_element_t * t8_element_array_index_int_mutable (t8_element_array_t *element_array, const int index); ``` """ -function p8est_connectivity_face_neighbor_edge(e, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_edge(e::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_element_array_index_int_mutable(element_array, index) + @ccall libt8.t8_element_array_index_int_mutable(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} end """ - p8est_connectivity_edge_neighbor_edge_corner(ec, o) + t8_element_array_get_scheme(element_array) -Transform an edge corner across one of the adjacent edges into a neighbor tree. +Return the eclass scheme associated to a t8\\_element\\_array. # Arguments -* `ec`:\\[in\\] An edge corner number in 0..1. -* `o`:\\[in\\] The orientation of a tree boundary edge connection. +* `element_array`:\\[in\\] Array of elements. # Returns -The edge corner number seen from the other tree. +The eclass scheme stored at *element_array*. ### Prototype ```c -int p8est_connectivity_edge_neighbor_edge_corner (int ec, int o); +const t8_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_edge_neighbor_edge_corner(ec, o) - @ccall libp4est.p8est_connectivity_edge_neighbor_edge_corner(ec::Cint, o::Cint)::Cint +function t8_element_array_get_scheme(element_array) + @ccall libt8.t8_element_array_get_scheme(element_array::Ptr{t8_element_array_t})::Ptr{t8_scheme_c} end """ - p8est_connectivity_edge_neighbor_corner(c, e, ne, o) + t8_element_array_get_tree_class(element_array) -Transform a corner across one of the adjacent edges into a neighbor tree. This version expects the neighbor edge and orientation separately. +Return the tree class of the t8\\_element\\_array . # Arguments -* `c`:\\[in\\] A corner number in 0..7. -* `e`:\\[in\\] An edge 0..11 that touches the corner *c*. -* `ne`:\\[in\\] A neighbor edge that is on the other side of *e*. -* `o`:\\[in\\] The orientation between tree boundary edges *e* and *ne*. +* `element_array`:\\[in\\] Array of elements. # Returns -Corner number seen from the neighbor. +The tree class stored at *element_array*. ### Prototype ```c -int p8est_connectivity_edge_neighbor_corner (int c, int e, int ne, int o); +t8_eclass_t t8_element_array_get_tree_class (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_edge_neighbor_corner(c, e, ne, o) - @ccall libp4est.p8est_connectivity_edge_neighbor_corner(c::Cint, e::Cint, ne::Cint, o::Cint)::Cint +function t8_element_array_get_tree_class(element_array) + @ccall libt8.t8_element_array_get_tree_class(element_array::Ptr{t8_element_array_t})::t8_eclass_t end """ - p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) + t8_element_array_get_count(element_array) -Allocate a connectivity structure. The attribute fields are initialized to NULL. +Return the number of elements stored in a [`t8_element_array_t`](@ref). # Arguments -* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). -* `num_trees`:\\[in\\] Number of trees in the forest. -* `num_edges`:\\[in\\] Number of tree-connecting edges. -* `num_ett`:\\[in\\] Number of total trees in edge\\_to\\_tree array. -* `num_corners`:\\[in\\] Number of tree-connecting corners. -* `num_ctt`:\\[in\\] Number of total trees in corner\\_to\\_tree array. +* `element_array`:\\[in\\] Array structure. # Returns -A connectivity structure with allocated arrays. +The number of elements stored in *element_array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_ett, p4est_topidx_t num_corners, p4est_topidx_t num_ctt); +size_t t8_element_array_get_count (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) - @ccall libp4est.p8est_connectivity_new(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_ett::p4est_topidx_t, num_corners::p4est_topidx_t, num_ctt::p4est_topidx_t)::Ptr{p8est_connectivity_t} +function t8_element_array_get_count(element_array) + @ccall libt8.t8_element_array_get_count(element_array::Ptr{t8_element_array_t})::Csize_t end """ - p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) + t8_element_array_get_size(element_array) -Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. +Return the data size of elements stored in a [`t8_element_array_t`](@ref). # Arguments -* `num_vertices`:\\[in\\] Number of total vertices (i.e. geometric points). -* `num_trees`:\\[in\\] Number of trees in the forest. -* `num_edges`:\\[in\\] Number of tree-connecting edges. -* `num_corners`:\\[in\\] Number of tree-connecting corners. -* `vertices`:\\[in\\] Coordinates of the vertices of the trees. -* `ttv`:\\[in\\] The tree-to-vertex array. -* `ttt`:\\[in\\] The tree-to-tree array. -* `ttf`:\\[in\\] The tree-to-face array (int8\\_t). -* `tte`:\\[in\\] The tree-to-edge array. -* `eoff`:\\[in\\] Edge-to-tree offsets (num\\_edges + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. -* `ett`:\\[in\\] The edge-to-tree array. -* `ete`:\\[in\\] The edge-to-edge array. -* `ttc`:\\[in\\] The tree-to-corner array. -* `coff`:\\[in\\] Corner-to-tree offsets (num\\_corners + 1 values). This must always be non-NULL; in trivial cases it is just a pointer to a p4est\\_topix value of 0. -* `ctt`:\\[in\\] The corner-to-tree array. -* `ctc`:\\[in\\] The corner-to-corner array. +* `element_array`:\\[in\\] Array structure. # Returns -The connectivity is checked for validity. +The size (in bytes) of a single element in *element_array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * tte, const p4est_topidx_t * eoff, const p4est_topidx_t * ett, const int8_t * ete, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc); +size_t t8_element_array_get_size (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) - @ccall libp4est.p8est_connectivity_new_copy(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_corners::p4est_topidx_t, vertices::Ptr{Cdouble}, ttv::Ptr{p4est_topidx_t}, ttt::Ptr{p4est_topidx_t}, ttf::Ptr{Int8}, tte::Ptr{p4est_topidx_t}, eoff::Ptr{p4est_topidx_t}, ett::Ptr{p4est_topidx_t}, ete::Ptr{Int8}, ttc::Ptr{p4est_topidx_t}, coff::Ptr{p4est_topidx_t}, ctt::Ptr{p4est_topidx_t}, ctc::Ptr{Int8})::Ptr{p8est_connectivity_t} +function t8_element_array_get_size(element_array) + @ccall libt8.t8_element_array_get_size(element_array::Ptr{t8_element_array_t})::Csize_t end """ - p8est_connectivity_bcast(conn_in, root, comm) + t8_element_array_get_data(element_array) +Return a const pointer to the real data array stored in a t8\\_element\\_array. + +# Arguments +* `element_array`:\\[in\\] Array structure. +# Returns +A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_bcast (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +const t8_element_t * t8_element_array_get_data (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_bcast(conn_in, root, comm) - @ccall libp4est.p8est_connectivity_bcast(conn_in::Ptr{p8est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p8est_connectivity_t} +function t8_element_array_get_data(element_array) + @ccall libt8.t8_element_array_get_data(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} end """ - p8est_connectivity_destroy(connectivity) + t8_element_array_get_data_mutable(element_array) -Destroy a connectivity structure. Also destroy all attributes. +Return a pointer to the real data array stored in a t8\\_element\\_array. +# Arguments +* `element_array`:\\[in\\] Array structure. +# Returns +A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. ### Prototype ```c -void p8est_connectivity_destroy (p8est_connectivity_t * connectivity); +t8_element_t * t8_element_array_get_data_mutable (t8_element_array_t *element_array); ``` """ -function p8est_connectivity_destroy(connectivity) - @ccall libp4est.p8est_connectivity_destroy(connectivity::Ptr{p8est_connectivity_t})::Cvoid +function t8_element_array_get_data_mutable(element_array) + @ccall libt8.t8_element_array_get_data_mutable(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} end """ - p8est_connectivity_set_attr(conn, bytes_per_tree) + t8_element_array_get_array(element_array) + +Return a const pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. + +!!! note -Allocate or free the attribute fields in a connectivity. + The data cannot be modified. # Arguments -* `conn`:\\[in,out\\] The conn->*\\_to\\_attr fields must either be NULL or previously be allocated by this function. -* `bytes_per_tree`:\\[in\\] If 0, tree\\_to\\_attr is freed (being NULL is ok). If positive, requested space is allocated. +* `element_array`:\\[in\\] Array structure. +# Returns +A const pointer to the [`sc_array`](@ref) storing the data. ### Prototype ```c -void p8est_connectivity_set_attr (p8est_connectivity_t * conn, size_t bytes_per_tree); +const sc_array_t * t8_element_array_get_array (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_set_attr(conn, bytes_per_tree) - @ccall libp4est.p8est_connectivity_set_attr(conn::Ptr{p8est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid +function t8_element_array_get_array(element_array) + @ccall libt8.t8_element_array_get_array(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} end """ - p8est_connectivity_is_valid(connectivity) + t8_element_array_get_array_mutable(element_array) -Examine a connectivity structure. +Return a mutable pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. + +!!! note + + The data can be modified. +# Arguments +* `element_array`:\\[in\\] Array structure. # Returns -Returns true if structure is valid, false otherwise. +A pointer to the [`sc_array`](@ref) storing the data. ### Prototype ```c -int p8est_connectivity_is_valid (p8est_connectivity_t * connectivity); +sc_array_t * t8_element_array_get_array_mutable (t8_element_array_t *element_array); ``` """ -function p8est_connectivity_is_valid(connectivity) - @ccall libp4est.p8est_connectivity_is_valid(connectivity::Ptr{p8est_connectivity_t})::Cint +function t8_element_array_get_array_mutable(element_array) + @ccall libt8.t8_element_array_get_array_mutable(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} end """ - p8est_connectivity_is_equal(conn1, conn2) + t8_element_array_find(element_array, element) -Check two connectivity structures for equality. +Search for an element in an array. +# Arguments +* `element_array`:\\[in\\] Array structure. +* `element`:\\[in\\] Element to be found in *element_array*. The element must have been created with the scheme used in *element_array*. # Returns -Returns true if structures are equal, false otherwise. +If *element* was found in *element_array* then the position in the array is returned. If the element is not found, -1 is returned. ### Prototype ```c -int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); +t8_locidx_t t8_element_array_find (const t8_element_array_t *element_array, const t8_element_t *element); ``` """ -function p8est_connectivity_is_equal(conn1, conn2) - @ccall libp4est.p8est_connectivity_is_equal(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint +function t8_element_array_find(element_array, element) + @ccall libt8.t8_element_array_find(element_array::Ptr{t8_element_array_t}, element::Ptr{t8_element_t})::t8_locidx_t end """ - p8est_connectivity_sink(conn, sink) + t8_element_array_reset(element_array) -Write connectivity to a sink object. +Sets the array count to zero and frees all elements. + +!!! note + + Calling [`t8_element_array_init`](@ref), then any array operations, then [`t8_element_array_reset`](@ref) is memory neutral. # Arguments -* `conn`:\\[in\\] The connectivity to be written. -* `sink`:\\[in,out\\] The connectivity is written into this sink. -# Returns -0 on success, nonzero on error. +* `element_array`:\\[in,out\\] Array structure to be reset. ### Prototype ```c -int p8est_connectivity_sink (p8est_connectivity_t * conn, sc_io_sink_t * sink); +void t8_element_array_reset (t8_element_array_t *element_array); ``` """ -function p8est_connectivity_sink(conn, sink) - @ccall libp4est.p8est_connectivity_sink(conn::Ptr{p8est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint +function t8_element_array_reset(element_array) + @ccall libt8.t8_element_array_reset(element_array::Ptr{t8_element_array_t})::Cvoid end """ - p8est_connectivity_deflate(conn, code) + t8_element_array_truncate(element_array) -Allocate memory and store the connectivity information there. +Sets the array count to zero, but does not free elements. + +!!! note + + This is intended to allow an t8\\_element\\_array to be used as a reusable buffer, where the "high water mark" of the buffer is preserved, so that O(log (max n)) reallocs occur over the life of the buffer. # Arguments -* `conn`:\\[in\\] The connectivity structure to be exported to memory. -* `code`:\\[in\\] Encoding and compression method for serialization. -# Returns -Newly created array that contains the information. +* `element_array`:\\[in,out\\] Element array structure to be truncated. ### Prototype ```c -sc_array_t *p8est_connectivity_deflate (p8est_connectivity_t * conn, p8est_connectivity_encode_t code); +void t8_element_array_truncate (t8_element_array_t *element_array); ``` """ -function p8est_connectivity_deflate(conn, code) - @ccall libp4est.p8est_connectivity_deflate(conn::Ptr{p8est_connectivity_t}, code::p8est_connectivity_encode_t)::Ptr{sc_array_t} +function t8_element_array_truncate(element_array) + @ccall libt8.t8_element_array_truncate(element_array::Ptr{t8_element_array_t})::Cvoid end """ - p8est_connectivity_save(filename, connectivity) - -Save a connectivity structure to disk. + t8_shmem_init(comm) -# Arguments -* `filename`:\\[in\\] Name of the file to write. -* `connectivity`:\\[in\\] Valid connectivity structure. -# Returns -Returns 0 on success, nonzero on file error. ### Prototype ```c -int p8est_connectivity_save (const char *filename, p8est_connectivity_t * connectivity); +int t8_shmem_init (sc_MPI_Comm comm); ``` """ -function p8est_connectivity_save(filename, connectivity) - @ccall libp4est.p8est_connectivity_save(filename::Cstring, connectivity::Ptr{p8est_connectivity_t})::Cint +function t8_shmem_init(comm) + @ccall libt8.t8_shmem_init(comm::MPI_Comm)::Cint end """ - p8est_connectivity_source(source) - -Read connectivity from a source object. + t8_shmem_finalize(comm) -# Arguments -* `source`:\\[in,out\\] The connectivity is read from this source. -# Returns -The newly created connectivity, or NULL on error. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source); +void t8_shmem_finalize (sc_MPI_Comm comm); ``` """ -function p8est_connectivity_source(source) - @ccall libp4est.p8est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p8est_connectivity_t} +function t8_shmem_finalize(comm) + @ccall libt8.t8_shmem_finalize(comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_inflate(buffer) - -Create new connectivity from a memory buffer. This function aborts on malloc errors. + t8_shmem_set_type(comm, type) -# Arguments -* `buffer`:\\[in\\] The connectivity is created from this memory buffer. -# Returns -The newly created connectivity, or NULL on format error of the buffered connectivity data. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer); +void t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); ``` """ -function p8est_connectivity_inflate(buffer) - @ccall libp4est.p8est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p8est_connectivity_t} +function t8_shmem_set_type(comm, type) + @ccall libt8.t8_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid end """ - p8est_connectivity_load(filename, bytes) - -Load a connectivity structure from disk. + t8_shmem_array_init(parray, elem_size, elem_count, comm) -# Arguments -* `filename`:\\[in\\] Name of the file to read. -* `bytes`:\\[out\\] Size in bytes of connectivity on disk or NULL. -# Returns -Returns valid connectivity, or NULL on file error. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_load (const char *filename, size_t *bytes); +void t8_shmem_array_init (t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_load(filename, bytes) - @ccall libp4est.p8est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p8est_connectivity_t} +function t8_shmem_array_init(parray, elem_size, elem_count, comm) + @ccall libt8.t8_shmem_array_init(parray::Ptr{t8_shmem_array_t}, elem_size::Csize_t, elem_count::Csize_t, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_new_unitcube() + t8_shmem_array_start_writing(array) -Create a connectivity structure for the unit cube. +Enable writing mode for a shmem array. Only some processes may be allowed to write into the array, which is indicated by the return value being non-zero. The shared memory is managed via inter- and intranode communicators. Only rank 0 of the intranode communicator will be allowed to write into the array. +!!! note + + This function is MPI collective. + +# Arguments +* `array`:\\[in,out\\] Initialized array. Writing will be enabled on certain processes. +# Returns +True if the calling process can write into the array. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_unitcube (void); +int t8_shmem_array_start_writing (t8_shmem_array_t array); ``` """ -function p8est_connectivity_new_unitcube() - @ccall libp4est.p8est_connectivity_new_unitcube()::Ptr{p8est_connectivity_t} +function t8_shmem_array_start_writing(array) + @ccall libt8.t8_shmem_array_start_writing(array::t8_shmem_array_t)::Cint end """ - p8est_connectivity_new_periodic() + t8_shmem_array_end_writing(array) -Create a connectivity structure for an all-periodic unit cube. +Disable writing mode for a shmem array. + +!!! note + + This function is MPI collective. + +# Arguments +* `array`:\\[in,out\\] Initialized with writing mode enabled. +# See also +[`t8_shmem_array_start_writing`](@ref). ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_periodic (void); +void t8_shmem_array_end_writing (t8_shmem_array_t array); ``` """ -function p8est_connectivity_new_periodic() - @ccall libp4est.p8est_connectivity_new_periodic()::Ptr{p8est_connectivity_t} +function t8_shmem_array_end_writing(array) + @ccall libt8.t8_shmem_array_end_writing(array::t8_shmem_array_t)::Cvoid end """ - p8est_connectivity_new_rotwrap() + t8_shmem_array_set_gloidx(array, index, value) -Create a connectivity structure for a mostly periodic unit cube. The left and right faces are identified, and bottom and top rotated. Front and back are not identified. +Set an entry of a t8\\_shmem array that is used to store [`t8_gloidx_t`](@ref). The array must have writing mode enabled t8_shmem_array_start_writing. +# Arguments +* `array`:\\[in,out\\] The array to be modified. +* `index`:\\[in\\] The array entry to be modified. +* `value`:\\[in\\] The new value to be set. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_rotwrap (void); +void t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value); ``` """ -function p8est_connectivity_new_rotwrap() - @ccall libp4est.p8est_connectivity_new_rotwrap()::Ptr{p8est_connectivity_t} +function t8_shmem_array_set_gloidx(array, index, value) + @ccall libt8.t8_shmem_array_set_gloidx(array::t8_shmem_array_t, index::Cint, value::t8_gloidx_t)::Cvoid end """ - p8est_connectivity_new_drop() + t8_shmem_array_copy(dest, source) -Create a connectivity structure for a five-trees geometry with a hole. The geometry is a 3D extrusion of the two drop example, and covers [0, 3]*[0, 2]*[0, 3]. The additional dimension is Y. +Copy the contents of one t8\\_shmem array into another. + +!!! note + + *dest* must be initialized and match in element size and element count to *source*. + +!!! note + + *dest* must have writing mode disabled. +# Arguments +* `dest`:\\[in,out\\] The array in which *source* should be copied. +* `source`:\\[in\\] The array to copy. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_drop (void); +void t8_shmem_array_copy (t8_shmem_array_t dest, t8_shmem_array_t source); ``` """ -function p8est_connectivity_new_drop() - @ccall libp4est.p8est_connectivity_new_drop()::Ptr{p8est_connectivity_t} +function t8_shmem_array_copy(dest, source) + @ccall libt8.t8_shmem_array_copy(dest::t8_shmem_array_t, source::t8_shmem_array_t)::Cvoid end """ - p8est_connectivity_new_twocubes() - -Create a connectivity structure that contains two cubes. + t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twocubes (void); +void t8_shmem_array_allgather (const void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, int recvcount, sc_MPI_Datatype recvtype); ``` """ -function p8est_connectivity_new_twocubes() - @ccall libp4est.p8est_connectivity_new_twocubes()::Ptr{p8est_connectivity_t} +function t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) + @ccall libt8.t8_shmem_array_allgather(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvcount::Cint, recvtype::Cint)::Cvoid end """ - p8est_connectivity_new_twotrees(l_face, r_face, orientation) - -Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way. + t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) -# Arguments -* `l_face`:\\[in\\] index of left face -* `r_face`:\\[in\\] index of right face -* `orientation`:\\[in\\] orientation of trees w.r.t. each other ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twotrees (int l_face, int r_face, int orientation); +void t8_shmem_array_allgatherv (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, sc_MPI_Datatype recvtype, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_new_twotrees(l_face, r_face, orientation) - @ccall libp4est.p8est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p8est_connectivity_t} +function t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) + @ccall libt8.t8_shmem_array_allgatherv(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvtype::Cint, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_new_twowrap() - -Create a connectivity structure that contains two cubes where the two far ends are identified periodically. + t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twowrap (void); +void t8_shmem_array_prefix (const void *sendbuf, t8_shmem_array_t recvarray, const int count, sc_MPI_Datatype type, sc_MPI_Op op, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_new_twowrap() - @ccall libp4est.p8est_connectivity_new_twowrap()::Ptr{p8est_connectivity_t} +function t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) + @ccall libt8.t8_shmem_array_prefix(sendbuf::Ptr{Cvoid}, recvarray::t8_shmem_array_t, count::Cint, type::Cint, op::Cint, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_new_rotcubes() - -Create a connectivity structure that contains a few cubes. These are rotated against each other to stress the topology routines. + t8_shmem_array_get_comm(array) ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_rotcubes (void); +sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array); ``` """ -function p8est_connectivity_new_rotcubes() - @ccall libp4est.p8est_connectivity_new_rotcubes()::Ptr{p8est_connectivity_t} +function t8_shmem_array_get_comm(array) + @ccall libt8.t8_shmem_array_get_comm(array::t8_shmem_array_t)::Cint end """ - p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) + t8_shmem_array_get_elem_size(array) -An m by n by p array with periodicity in x, y, and z if periodic\\_a, periodic\\_b, and periodic\\_c are true, respectively. +Get the element size of a [`t8_shmem_array`](@ref) +# Arguments +* `array`:\\[in\\] The array. +# Returns +The element size of *array*'s elements. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c); +size_t t8_shmem_array_get_elem_size (t8_shmem_array_t array); ``` """ -function p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) - @ccall libp4est.p8est_connectivity_new_brick(m::Cint, n::Cint, p::Cint, periodic_a::Cint, periodic_b::Cint, periodic_c::Cint)::Ptr{p8est_connectivity_t} +function t8_shmem_array_get_elem_size(array) + @ccall libt8.t8_shmem_array_get_elem_size(array::t8_shmem_array_t)::Csize_t end """ - p8est_connectivity_new_shell() + t8_shmem_array_get_elem_count(array) -Create a connectivity structure that builds a spherical shell. It is made up of six connected parts [-1,1]x[-1,1]x[1,2]. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). +Get the number of elements of a [`t8_shmem_array`](@ref) +# Arguments +* `array`:\\[in\\] The array. +# Returns +The number of elements in *array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_shell (void); +size_t t8_shmem_array_get_elem_count (t8_shmem_array_t array); ``` """ -function p8est_connectivity_new_shell() - @ccall libp4est.p8est_connectivity_new_shell()::Ptr{p8est_connectivity_t} +function t8_shmem_array_get_elem_count(array) + @ccall libt8.t8_shmem_array_get_elem_count(array::t8_shmem_array_t)::Csize_t end """ - p8est_connectivity_new_sphere() + t8_shmem_array_get_gloidx_array(array) -Create a connectivity structure that builds a solid sphere. It is made up of two layers and a cube in the center. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). +Return a read-only pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. +!!! note + + Writing mode must be disabled for *array*. + +# Arguments +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +# Returns +The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_sphere (void); +const t8_gloidx_t * t8_shmem_array_get_gloidx_array (t8_shmem_array_t array); ``` """ -function p8est_connectivity_new_sphere() - @ccall libp4est.p8est_connectivity_new_sphere()::Ptr{p8est_connectivity_t} +function t8_shmem_array_get_gloidx_array(array) + @ccall libt8.t8_shmem_array_get_gloidx_array(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} end """ - p8est_connectivity_new_torus(nSegments) - -Create a connectivity structure that builds a revolution torus. - -This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). - -This connectivity reuses ideas from disk2d connectivity. More precisely the torus is divided into segments around the revolution axis, each segments is made of 5 trees (à la disk2d). The total number of trees if 5 times the number of segments. + t8_shmem_array_get_gloidx_array_for_writing(array) -This connectivity is meant to be used with p8est_geometry_new_torus +Return a pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. The array must have writing enabled t8_shmem_array_start_writing and you should not write into the memory after t8_shmem_array_end_writing was called. # Arguments -* `nSegments`:\\[in\\] number of trees along the great circle +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +# Returns +The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_torus (int nSegments); +t8_gloidx_t * t8_shmem_array_get_gloidx_array_for_writing (t8_shmem_array_t array); ``` """ -function p8est_connectivity_new_torus(nSegments) - @ccall libp4est.p8est_connectivity_new_torus(nSegments::Cint)::Ptr{p8est_connectivity_t} +function t8_shmem_array_get_gloidx_array_for_writing(array) + @ccall libt8.t8_shmem_array_get_gloidx_array_for_writing(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} end """ - p8est_connectivity_new_byname(name) + t8_shmem_array_get_gloidx(array, index) -Create connectivity structure from predefined catalogue. +Return an entry of a shared memory array that stores [`t8_gloidx_t`](@ref). + +!!! note + + Writing mode must be disabled for *array*. # Arguments -* `name`:\\[in\\] Invokes connectivity\\_new\\_* function. brick235 brick (2, 3, 5, 0, 0, 0) periodic periodic rotcubes rotcubes rotwrap rotwrap shell shell sphere sphere twocubes twocubes twowrap twowrap unit unitcube +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +* `index`:\\[in\\] The index of the entry to be queried. # Returns -An initialized connectivity if name is defined, NULL else. +The *index*-th entry of *array* as [`t8_gloidx_t`](@ref). ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_byname (const char *name); +t8_gloidx_t t8_shmem_array_get_gloidx (t8_shmem_array_t array, int index); ``` """ -function p8est_connectivity_new_byname(name) - @ccall libp4est.p8est_connectivity_new_byname(name::Cstring)::Ptr{p8est_connectivity_t} +function t8_shmem_array_get_gloidx(array, index) + @ccall libt8.t8_shmem_array_get_gloidx(array::t8_shmem_array_t, index::Cint)::t8_gloidx_t end """ - p8est_connectivity_refine(conn, num_per_dim) + t8_shmem_array_get_array(array) -Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. +Return a pointer to the data array of a [`t8_shmem_array`](@ref). + +!!! note + + Writing mode must be disabled for *array*. # Arguments -* `conn`:\\[in\\] A valid connectivity -* `num_per_dim`:\\[in\\] The number of new trees in each direction. Must use no more than P8EST_OLD_QMAXLEVEL bits. +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). # Returns -a refined connectivity. +A pointer to the data array of *array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_refine (p8est_connectivity_t * conn, int num_per_dim); +const void * t8_shmem_array_get_array (t8_shmem_array_t array); ``` """ -function p8est_connectivity_refine(conn, num_per_dim) - @ccall libp4est.p8est_connectivity_refine(conn::Ptr{p8est_connectivity_t}, num_per_dim::Cint)::Ptr{p8est_connectivity_t} +function t8_shmem_array_get_array(array) + @ccall libt8.t8_shmem_array_get_array(array::t8_shmem_array_t)::Ptr{Cvoid} end """ - p8est_expand_face_transform(iface, nface, ftransform) + t8_shmem_array_index(array, index) -Fill an array with the axis combination of a face neighbor transform. +Return a read-only pointer to an element in a [`t8_shmem_array`](@ref). + +!!! note + + You should not modify the value. + +!!! note + + Writing mode must be disabled for *array*. # Arguments -* `iface`:\\[in\\] The number of the originating face. -* `nface`:\\[in\\] Encoded as nface = r * 6 + nf, where nf = 0..5 is the neigbbor's connecting face number and r = 0..3 is the relative orientation to the neighbor's face. This encoding matches [`p8est_connectivity_t`](@ref). -* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face, the first two referring to the tangentials and the third to the normal. A permutation of (0, 1, 2). [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flags for tangential axes (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). +* `index`:\\[in\\] The index of an element. +# Returns +A pointer to the element at *index* in *array*. ### Prototype ```c -void p8est_expand_face_transform (int iface, int nface, int ftransform[]); +const void * t8_shmem_array_index (t8_shmem_array_t array, size_t index); ``` """ -function p8est_expand_face_transform(iface, nface, ftransform) - @ccall libp4est.p8est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid +function t8_shmem_array_index(array, index) + @ccall libt8.t8_shmem_array_index(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} end """ - p8est_find_face_transform(connectivity, itree, iface, ftransform) + t8_shmem_array_index_for_writing(array, index) -Fill an array with the axis combination of a face neighbor transform. +Return a pointer to an element in a [`t8_shmem_array`](@ref) in writing mode. + +!!! note + + You can modify the value before the next call to t8_shmem_array_end_writing. + +!!! note + + Writing mode must be enabled for *array*. # Arguments -* `connectivity`:\\[in\\] Connectivity structure. -* `itree`:\\[in\\] The number of the originating tree. -* `iface`:\\[in\\] The number of the originating tree's face. -* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face. [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flag for axes t1, t2; face code for n; +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). +* `index`:\\[in\\] The index of an element. # Returns -The face neighbor tree if it exists, -1 otherwise. -# See also -[`p8est_expand_face_transform`](@ref). - +A pointer to the element at *index* in *array*. ### Prototype ```c -p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); +void * t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index); ``` """ -function p8est_find_face_transform(connectivity, itree, iface, ftransform) - @ccall libp4est.p8est_find_face_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iface::Cint, ftransform::Ptr{Cint})::p4est_topidx_t +function t8_shmem_array_index_for_writing(array, index) + @ccall libt8.t8_shmem_array_index_for_writing(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} end """ - p8est_find_edge_transform(connectivity, itree, iedge, ei) + t8_shmem_array_is_equal(array_a, array_b) -Fills an array with information about edge neighbors. +Check if two t8\\_shmem arrays are equal. + +!!! note + + Writing mode must be disabled for *array_a* and *array_b*. # Arguments -* `connectivity`:\\[in\\] Connectivity structure. -* `itree`:\\[in\\] The number of the originating tree. -* `iedge`:\\[in\\] The number of the originating edge. -* `ei`:\\[in,out\\] A [`p8est_edge_info_t`](@ref) structure with initialized array. +* `array_a`:\\[in\\] The first [`t8_shmem_array`](@ref) to compare. +* `array_b`:\\[in\\] The second [`t8_shmem_array`](@ref) to compare. +# Returns +1 if the arrays are equal, 0 otherwise. ### Prototype ```c -void p8est_find_edge_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t * ei); +int t8_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b); ``` """ -function p8est_find_edge_transform(connectivity, itree, iedge, ei) - @ccall libp4est.p8est_find_edge_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iedge::Cint, ei::Ptr{p8est_edge_info_t})::Cvoid +function t8_shmem_array_is_equal(array_a, array_b) + @ccall libt8.t8_shmem_array_is_equal(array_a::t8_shmem_array_t, array_b::t8_shmem_array_t)::Cint end """ - p8est_find_corner_transform(connectivity, itree, icorner, ci) + t8_shmem_array_destroy(parray) -Fills an array with information about corner neighbors. +Free all memory associated with a [`t8_shmem_array`](@ref). # Arguments -* `connectivity`:\\[in\\] Connectivity structure. -* `itree`:\\[in\\] The number of the originating tree. -* `icorner`:\\[in\\] The number of the originating corner. -* `ci`:\\[in,out\\] A [`p8est_corner_info_t`](@ref) structure with initialized array. +* `parray`:\\[in,out\\] On input a pointer to a valid [`t8_shmem_array`](@ref). This array is freed and *parray* is set to NULL on return. ### Prototype ```c -void p8est_find_corner_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t * ci); +void t8_shmem_array_destroy (t8_shmem_array_t *parray); ``` """ -function p8est_find_corner_transform(connectivity, itree, icorner, ci) - @ccall libp4est.p8est_find_corner_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, icorner::Cint, ci::Ptr{p8est_corner_info_t})::Cvoid +function t8_shmem_array_destroy(parray) + @ccall libt8.t8_shmem_array_destroy(parray::Ptr{t8_shmem_array_t})::Cvoid end """ - p8est_connectivity_complete(conn) + t8_shmem_array_binary_search(array, value, size, compare) -Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. +Perform a binary search in a [`t8_shmem_array`](@ref). # Arguments -* `conn`:\\[in,out\\] The connectivity needs to have proper vertices and tree\\_to\\_vertex fields. The tree\\_to\\_tree and tree\\_to\\_face fields must be allocated and satisfy [`p8est_connectivity_is_valid`](@ref) (conn) but will be overwritten. The edge and corner fields will be freed and allocated anew. +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) to search in. +* `value`:\\[in\\] The value to search for. +* `size`:\\[in\\] The number of elements in the array. +* `compare`:\\[in\\] A function that compares an element of the array with the value. +# Returns +The index of the element in *array* that matches *value*. ### Prototype ```c -void p8est_connectivity_complete (p8est_connectivity_t * conn); +int t8_shmem_array_binary_search (t8_shmem_array_t array, const t8_gloidx_t value, const int size, int (*compare) (t8_shmem_array_t, const int, const t8_gloidx_t)); ``` """ -function p8est_connectivity_complete(conn) - @ccall libp4est.p8est_connectivity_complete(conn::Ptr{p8est_connectivity_t})::Cvoid +function t8_shmem_array_binary_search(array, value, size, compare) + @ccall libt8.t8_shmem_array_binary_search(array::t8_shmem_array_t, value::t8_gloidx_t, size::Cint, compare::Ptr{Cvoid})::Cint end """ - p8est_connectivity_reduce(conn) + t8_eclass_count_boundary(theclass, min_dim, per_eclass) -Removes corner and edge information of a connectivity such that enough information is left to run [`p8est_connectivity_complete`](@ref) successfully. The reduced connectivity still passes [`p8est_connectivity_is_valid`](@ref). +Query the element class and count of boundary points. # Arguments -* `conn`:\\[in,out\\] The connectivity to be reduced. +* `theclass`:\\[in\\] We query a point of this element class. +* `min_dim`:\\[in\\] Ignore boundary points of lesser dimension. The ignored points get a count value of 0. +* `per_eclass`:\\[out\\] Array of length T8\\_ECLASS\\_COUNT to be filled with the count of the boundary objects, counted per each of the element classes. +# Returns +The count over all boundary points. ### Prototype ```c -void p8est_connectivity_reduce (p8est_connectivity_t * conn); +int t8_eclass_count_boundary (t8_eclass_t theclass, int min_dim, int *per_eclass); ``` """ -function p8est_connectivity_reduce(conn) - @ccall libp4est.p8est_connectivity_reduce(conn::Ptr{p8est_connectivity_t})::Cvoid +function t8_eclass_count_boundary(theclass, min_dim, per_eclass) + @ccall libt8.t8_eclass_count_boundary(theclass::t8_eclass_t, min_dim::Cint, per_eclass::Ptr{Cint})::Cint end """ - p8est_connectivity_permute(conn, perm, is_current_to_new) + t8_eclass_compare(eclass1, eclass2) -[`p8est_connectivity_permute`](@ref) Given a permutation *perm* of the trees in a connectivity *conn*, permute the trees of *conn* in place and update *conn* to match. +Compare two eclasses of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. # Arguments -* `conn`:\\[in,out\\] The connectivity whose trees are permuted. -* `perm`:\\[in\\] A permutation array, whose elements are size\\_t's. -* `is_current_to_new`:\\[in\\] if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation. +* `eclass1`:\\[in\\] The first eclass to compare. +* `eclass2`:\\[in\\] The second eclass to compare. +# Returns +0 if the eclasses are equal, 1 if eclass1 > eclass2 and -1 if eclass1 < eclass2 ### Prototype ```c -void p8est_connectivity_permute (p8est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); +int t8_eclass_compare (t8_eclass_t eclass1, t8_eclass_t eclass2); ``` """ -function p8est_connectivity_permute(conn, perm, is_current_to_new) - @ccall libp4est.p8est_connectivity_permute(conn::Ptr{p8est_connectivity_t}, perm::Ptr{sc_array_t}, is_current_to_new::Cint)::Cvoid +function t8_eclass_compare(eclass1, eclass2) + @ccall libt8.t8_eclass_compare(eclass1::t8_eclass_t, eclass2::t8_eclass_t)::Cint end """ - p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + t8_eclass_is_valid(eclass) -[`p8est_connectivity_join_faces`](@ref) This function takes an existing valid connectivity *conn* and modifies it by joining two tree faces that are currently boundary faces. +Check whether a class is a valid class. Returns non-zero if it is a valid class, returns zero, if the class is equal to T8\\_ECLASS\\_INVALID. # Arguments -* `conn`:\\[in,out\\] connectivity that will be altered. -* `tree_left`:\\[in\\] tree that will be on the left side of the joined faces. -* `tree_right`:\\[in\\] tree that will be on the right side of the joined faces. -* `face_left`:\\[in\\] face of *tree_left* that will be joined. -* `face_right`:\\[in\\] face of *tree_right* that will be joined. -* `orientation`:\\[in\\] the orientation of *face_left* and *face_right* once joined (see the description of [`p8est_connectivity_t`](@ref) to understand orientation). +* `eclass`:\\[in\\] The eclass to check. +# Returns +Non-zero if *eclass* is valid, zero otherwise. ### Prototype ```c -void p8est_connectivity_join_faces (p8est_connectivity_t * conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation); +int t8_eclass_is_valid (t8_eclass_t eclass); ``` """ -function p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) - @ccall libp4est.p8est_connectivity_join_faces(conn::Ptr{p8est_connectivity_t}, tree_left::p4est_topidx_t, tree_right::p4est_topidx_t, face_left::Cint, face_right::Cint, orientation::Cint)::Cvoid +function t8_eclass_is_valid(eclass) + @ccall libt8.t8_eclass_is_valid(eclass::t8_eclass_t)::Cint end +"""Type definition for the geometric shape of an element. Currently the possible shapes are the same as the possible element classes. I.e. T8\\_ECLASS\\_VERTEX, T8\\_ECLASS\\_TET, etc...""" +const t8_element_shape_t = t8_eclass_t + """ - p8est_connectivity_is_equivalent(conn1, conn2) + t8_element_shape_num_faces(element_shape) -[`p8est_connectivity_is_equivalent`](@ref) This function compares two connectivities for equivalence: it returns *true* if they are the same connectivity, or if they have the same topology. The definition of topological sameness is strict: there is no attempt made to determine whether permutation and/or rotation of the trees makes the connectivities equivalent. +The number of codimension-one boundaries of an element class. -# Arguments -* `conn1`:\\[in\\] a valid connectivity -* `conn2`:\\[out\\] a valid connectivity ### Prototype ```c -int p8est_connectivity_is_equivalent (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); +int t8_element_shape_num_faces (int element_shape); ``` """ -function p8est_connectivity_is_equivalent(conn1, conn2) - @ccall libp4est.p8est_connectivity_is_equivalent(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint +function t8_element_shape_num_faces(element_shape) + @ccall libt8.t8_element_shape_num_faces(element_shape::Cint)::Cint end """ - p8est_edge_array_index(array, it) + t8_element_shape_max_num_faces(element_shape) + +For each dimension the maximum possible number of faces of an element\\_shape of that dimension. ### Prototype ```c -static inline p8est_edge_transform_t * p8est_edge_array_index (sc_array_t * array, size_t it); +int t8_element_shape_max_num_faces (int element_shape); ``` """ -function p8est_edge_array_index(array, it) - @ccall libp4est.p8est_edge_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_edge_transform_t} +function t8_element_shape_max_num_faces(element_shape) + @ccall libt8.t8_element_shape_max_num_faces(element_shape::Cint)::Cint end """ - p8est_corner_array_index(array, it) + t8_element_shape_num_vertices(element_shape) + +The number of vertices of an element class. ### Prototype ```c -static inline p8est_corner_transform_t * p8est_corner_array_index (sc_array_t * array, size_t it); +int t8_element_shape_num_vertices (int element_shape); ``` """ -function p8est_corner_array_index(array, it) - @ccall libp4est.p8est_corner_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_corner_transform_t} +function t8_element_shape_num_vertices(element_shape) + @ccall libt8.t8_element_shape_num_vertices(element_shape::Cint)::Cint end """ - p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) - -Read an ABAQUS input file from a file stream. - -This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. - -A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: - -4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 - -and in 3D they are given as: - -8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 - -```c++ - *Heading - box.inp - *Node - 1, 5, -5, 5 - 2, 5, 5, 5 - 3, 5, 0, 5 - 4, -5, 5, 5 - 5, 0, 5, 5 - 6, -5, -5, 5 - 7, -5, 0, 5 - 8, 0, -5, 5 - 9, 0, 0, 5 - 10, 5, 5, -5 - 11, 5, -5, -5 - 12, 5, 0, -5 - 13, -5, -5, -5 - 14, 0, -5, -5 - 15, -5, 5, -5 - 16, -5, 0, -5 - 17, 0, 5, -5 - 18, 0, 0, -5 - 19, -5, -5, 0 - 20, 5, -5, 0 - 21, 0, -5, 0 - 22, -5, 5, 0 - 23, -5, 0, 0 - 24, 5, 5, 0 - 25, 0, 5, 0 - 26, 5, 0, 0 - 27, 0, 0, 0 - *Element, type=C3D8, ELSET=EB1 - 1, 6, 19, 23, 7, 8, 21, 27, 9 - 2, 19, 13, 16, 23, 21, 14, 18, 27 - 3, 7, 23, 22, 4, 9, 27, 25, 5 - 4, 23, 16, 15, 22, 27, 18, 17, 25 - 5, 8, 21, 27, 9, 1, 20, 26, 3 - 6, 21, 14, 18, 27, 20, 11, 12, 26 - 7, 9, 27, 25, 5, 3, 26, 24, 2 - 8, 27, 18, 17, 25, 26, 12, 10, 24 -``` + t8_element_shape_vtk_type(element_shape) -This code can be called two ways. The first, when `vertex`==NULL and `tree_to_vertex`==NULL, is used to count the number of trees and vertices in the connectivity to be generated by the `.inp` mesh in the *stream*. The second, when `vertices`!=NULL and `tree_to_vertex`!=NULL, fill `vertices` and `tree_to_vertex`. In this case `num_vertices` and `num_trees` need to be set to the maximum number of entries allocated in `vertices` and `tree_to_vertex`. +The vtk cell type for the element\\_shape -# Arguments -* `stream`:\\[in,out\\] file stream to read the connectivity from -* `num_vertices`:\\[in,out\\] the number of vertices in the connectivity -* `num_trees`:\\[in,out\\] the number of trees in the connectivity -* `vertices`:\\[out\\] the list of `vertices` of the connectivity -* `tree_to_vertex`:\\[out\\] the `tree_to_vertex` map of the connectivity -# Returns -0 if successful and nonzero if not ### Prototype ```c -int p8est_connectivity_read_inp_stream (FILE * stream, p4est_topidx_t * num_vertices, p4est_topidx_t * num_trees, double *vertices, p4est_topidx_t * tree_to_vertex); +int t8_element_shape_vtk_type (int element_shape); ``` """ -function p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) - @ccall libp4est.p8est_connectivity_read_inp_stream(stream::Ptr{Libc.FILE}, num_vertices::Ptr{p4est_topidx_t}, num_trees::Ptr{p4est_topidx_t}, vertices::Ptr{Cdouble}, tree_to_vertex::Ptr{p4est_topidx_t})::Cint +function t8_element_shape_vtk_type(element_shape) + @ccall libt8.t8_element_shape_vtk_type(element_shape::Cint)::Cint end """ - p8est_connectivity_read_inp(filename) - -Create a p4est connectivity from an ABAQUS input file. - -This utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. - -A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: - -4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 - -and in 3D they are given as: - -8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 - -```c++ - *Heading - box.inp - *Node - 1, 5, -5, 5 - 2, 5, 5, 5 - 3, 5, 0, 5 - 4, -5, 5, 5 - 5, 0, 5, 5 - 6, -5, -5, 5 - 7, -5, 0, 5 - 8, 0, -5, 5 - 9, 0, 0, 5 - 10, 5, 5, -5 - 11, 5, -5, -5 - 12, 5, 0, -5 - 13, -5, -5, -5 - 14, 0, -5, -5 - 15, -5, 5, -5 - 16, -5, 0, -5 - 17, 0, 5, -5 - 18, 0, 0, -5 - 19, -5, -5, 0 - 20, 5, -5, 0 - 21, 0, -5, 0 - 22, -5, 5, 0 - 23, -5, 0, 0 - 24, 5, 5, 0 - 25, 0, 5, 0 - 26, 5, 0, 0 - 27, 0, 0, 0 - *Element, type=C3D8, ELSET=EB1 - 1, 6, 19, 23, 7, 8, 21, 27, 9 - 2, 19, 13, 16, 23, 21, 14, 18, 27 - 3, 7, 23, 22, 4, 9, 27, 25, 5 - 4, 23, 16, 15, 22, 27, 18, 17, 25 - 5, 8, 21, 27, 9, 1, 20, 26, 3 - 6, 21, 14, 18, 27, 20, 11, 12, 26 - 7, 9, 27, 25, 5, 3, 26, 24, 2 - 8, 27, 18, 17, 25, 26, 12, 10, 24 -``` + t8_element_shape_t8_to_vtk_corner_number(element_shape, index) -This function reads a mesh from *filename* and returns an associated p4est connectivity. +Maps the t8code corner number of the element to the vtk corner number # Arguments -* `filename`:\\[in\\] file to read the connectivity from +* `element_shape`:\\[in\\] The shape of the element. +* `index`:\\[in\\] The index of the corner in z-order (t8code numeration). # Returns -an allocated connectivity associated with the mesh in *filename* +The corresponding vtk index. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename); +int t8_element_shape_t8_to_vtk_corner_number (int element_shape, int index); ``` """ -function p8est_connectivity_read_inp(filename) - @ccall libp4est.p8est_connectivity_read_inp(filename::Cstring)::Ptr{p8est_connectivity_t} +function t8_element_shape_t8_to_vtk_corner_number(element_shape, index) + @ccall libt8.t8_element_shape_t8_to_vtk_corner_number(element_shape::Cint, index::Cint)::Cint end """ - t8_cmesh_new_from_p4est(conn, comm, do_partition) + t8_element_shape_t8_corner_number(element_shape, index) +Maps the vtk corner number of the element to the t8code corner number + +# Arguments +* `element_shape`:\\[in\\] The shape of the element. +* `index`:\\[in\\] The index of the corner in vtk ordering. +# Returns +The corresponding t8code index. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); +int t8_element_shape_t8_corner_number (int element_shape, int index); ``` """ -function t8_cmesh_new_from_p4est(conn, comm, do_partition) - @ccall libt8.t8_cmesh_new_from_p4est(conn::Ptr{p4est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t +function t8_element_shape_t8_corner_number(element_shape, index) + @ccall libt8.t8_element_shape_t8_corner_number(element_shape::Cint, index::Cint)::Cint end """ - t8_cmesh_new_from_p8est(conn, comm, do_partition) + t8_element_shape_to_string(element_shape) + +For each element\\_shape, the name of this class as a string ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); +const char* t8_element_shape_to_string (int element_shape); ``` """ -function t8_cmesh_new_from_p8est(conn, comm, do_partition) - @ccall libt8.t8_cmesh_new_from_p8est(conn::Ptr{p8est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t +function t8_element_shape_to_string(element_shape) + @ccall libt8.t8_element_shape_to_string(element_shape::Cint)::Cstring end """ - t8_cmesh_new_empty(comm, do_partition, dimension) + t8_element_shape_compare(element_shape1, element_shape2) +Compare two element\\_shapes of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. + +# Arguments +* `element_shape1`:\\[in\\] The first element\\_shape to compare. +* `element_shape2`:\\[in\\] The second element\\_shape to compare. +# Returns +0 if the element\\_shapes are equal, 1 if element\\_shape1 > element\\_shape2 and -1 if element\\_shape1 < element\\_shape2 ### Prototype ```c -t8_cmesh_t t8_cmesh_new_empty (sc_MPI_Comm comm, const int do_partition, const int dimension); +int t8_element_shape_compare (t8_element_shape_t element_shape1, t8_element_shape_t element_shape2); ``` """ -function t8_cmesh_new_empty(comm, do_partition, dimension) - @ccall libt8.t8_cmesh_new_empty(comm::MPI_Comm, do_partition::Cint, dimension::Cint)::t8_cmesh_t +function t8_element_shape_compare(element_shape1, element_shape2) + @ccall libt8.t8_element_shape_compare(element_shape1::t8_element_shape_t, element_shape2::t8_element_shape_t)::Cint end """ - t8_cmesh_new_from_class(eclass, comm) + sc_keyvalue_entry_type_t -### Prototype -```c -t8_cmesh_t t8_cmesh_new_from_class (t8_eclass_t eclass, sc_MPI_Comm comm); -``` +The values can have different types. + +| Enumerator | Note | +| :------------------------------ | :------------------------------------------ | +| SC\\_KEYVALUE\\_ENTRY\\_NONE | Designate an invalid situation. | +| SC\\_KEYVALUE\\_ENTRY\\_INT | Used for values of type int. | +| SC\\_KEYVALUE\\_ENTRY\\_DOUBLE | Used for values of type double. | +| SC\\_KEYVALUE\\_ENTRY\\_STRING | Used for values of type const char *. | +| SC\\_KEYVALUE\\_ENTRY\\_POINTER | Used for values of anonymous pointer type. | """ -function t8_cmesh_new_from_class(eclass, comm) - @ccall libt8.t8_cmesh_new_from_class(eclass::t8_eclass_t, comm::MPI_Comm)::t8_cmesh_t +@cenum sc_keyvalue_entry_type_t::UInt32 begin + SC_KEYVALUE_ENTRY_NONE = 0 + SC_KEYVALUE_ENTRY_INT = 1 + SC_KEYVALUE_ENTRY_DOUBLE = 2 + SC_KEYVALUE_ENTRY_STRING = 3 + SC_KEYVALUE_ENTRY_POINTER = 4 end -""" - t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) +mutable struct sc_keyvalue end -### Prototype -```c -t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int do_partition, int periodic); -``` -""" -function t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) - @ccall libt8.t8_cmesh_new_hypercube(eclass::t8_eclass_t, comm::MPI_Comm, do_bcast::Cint, do_partition::Cint, periodic::Cint)::t8_cmesh_t -end +"""The key-value container is an opaque structure.""" +const sc_keyvalue_t = sc_keyvalue +# no prototype is found for this function at sc_keyvalue.h:54:21, please use with caution """ - t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) + sc_keyvalue_new() + +Create a new key-value container. +# Returns +The container is ready to use. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned); +sc_keyvalue_t *sc_keyvalue_new (); ``` """ -function t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) - @ccall libt8.t8_cmesh_new_hypercube_pad(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, use_axis_aligned::Cint)::t8_cmesh_t +function sc_keyvalue_new() + @ccall libsc.sc_keyvalue_new()::Ptr{sc_keyvalue_t} end +# automatic type deduction for variadic arguments may not be what you want, please use with caution +@generated function sc_keyvalue_newf(dummy, va_list...) + :(@ccall(libsc.sc_keyvalue_newf(dummy::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_keyvalue_t})) + end + """ - t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) + sc_keyvalue_destroy(kv) + +Free a key-value container and all internal memory for key storage. +# Arguments +* `kv`:\\[in,out\\] The key-value container is invalidated by this call. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube_pad_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int periodic_x, const int periodic_y, const int periodic_z, const int use_axis_aligned, const int set_partition, t8_gloidx_t offset); +void sc_keyvalue_destroy (sc_keyvalue_t * kv); ``` """ -function t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) - @ccall libt8.t8_cmesh_new_hypercube_pad_ext(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, periodic_x::Cint, periodic_y::Cint, periodic_z::Cint, use_axis_aligned::Cint, set_partition::Cint, offset::t8_gloidx_t)::t8_cmesh_t +function sc_keyvalue_destroy(kv) + @ccall libsc.sc_keyvalue_destroy(kv::Ptr{sc_keyvalue_t})::Cvoid end """ - t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) + sc_keyvalue_exists(kv, key) + +Routine to check existence of an entry. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key to query. +# Returns +The entry's type if found and SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, int do_partition, int periodic); +sc_keyvalue_entry_type_t sc_keyvalue_exists (sc_keyvalue_t * kv, const char *key); ``` """ -function t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) - @ccall libt8.t8_cmesh_new_hypercube_hybrid(comm::MPI_Comm, do_partition::Cint, periodic::Cint)::t8_cmesh_t +function sc_keyvalue_exists(kv, key) + @ccall libsc.sc_keyvalue_exists(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t end """ - t8_cmesh_new_periodic(comm, dim) + sc_keyvalue_unset(kv, key) + +Routine to remove an entry. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key to remove if it exists. +# Returns +The entry's type if found and removed, SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic (sc_MPI_Comm comm, int dim); +sc_keyvalue_entry_type_t sc_keyvalue_unset (sc_keyvalue_t * kv, const char *key); ``` """ -function t8_cmesh_new_periodic(comm, dim) - @ccall libt8.t8_cmesh_new_periodic(comm::MPI_Comm, dim::Cint)::t8_cmesh_t +function sc_keyvalue_unset(kv, key) + @ccall libsc.sc_keyvalue_unset(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t end """ - t8_cmesh_new_periodic_tri(comm) + sc_keyvalue_get_int(kv, key, dvalue) + +Routines to retrieve an integer value by its key. This function asserts that the key, if existing, points to the correct type. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. +# Returns +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_tri (sc_MPI_Comm comm); +int sc_keyvalue_get_int (sc_keyvalue_t * kv, const char *key, int dvalue); ``` """ -function t8_cmesh_new_periodic_tri(comm) - @ccall libt8.t8_cmesh_new_periodic_tri(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_get_int(kv, key, dvalue) + @ccall libsc.sc_keyvalue_get_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cint)::Cint end """ - t8_cmesh_new_periodic_hybrid(comm) + sc_keyvalue_get_double(kv, key, dvalue) + +Retrieve a double value by its key. This function asserts that the key, if existing, points to the correct type. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. +# Returns +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_hybrid (sc_MPI_Comm comm); +double sc_keyvalue_get_double (sc_keyvalue_t * kv, const char *key, double dvalue); ``` """ -function t8_cmesh_new_periodic_hybrid(comm) - @ccall libt8.t8_cmesh_new_periodic_hybrid(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_get_double(kv, key, dvalue) + @ccall libsc.sc_keyvalue_get_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cdouble)::Cdouble end """ - t8_cmesh_new_periodic_line_more_trees(comm) + sc_keyvalue_get_string(kv, key, dvalue) + +Retrieve a string value by its key. This function asserts that the key, if existing, points to the correct type. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. +# Returns +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm); +const char *sc_keyvalue_get_string (sc_keyvalue_t * kv, const char *key, const char *dvalue); ``` """ -function t8_cmesh_new_periodic_line_more_trees(comm) - @ccall libt8.t8_cmesh_new_periodic_line_more_trees(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_get_string(kv, key, dvalue) + @ccall libsc.sc_keyvalue_get_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cstring)::Cstring end """ - t8_cmesh_new_bigmesh(eclass, num_trees, comm) + sc_keyvalue_get_pointer(kv, key, dvalue) + +Retrieve a pointer value by its key. This function asserts that the key, if existing, points to the correct type. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. +# Returns +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_bigmesh (t8_eclass_t eclass, int num_trees, sc_MPI_Comm comm); +void *sc_keyvalue_get_pointer (sc_keyvalue_t * kv, const char *key, void *dvalue); ``` """ -function t8_cmesh_new_bigmesh(eclass, num_trees, comm) - @ccall libt8.t8_cmesh_new_bigmesh(eclass::t8_eclass_t, num_trees::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_get_pointer(kv, key, dvalue) + @ccall libsc.sc_keyvalue_get_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Ptr{Cvoid})::Ptr{Cvoid} end """ - t8_cmesh_new_line_zigzag(comm) + sc_keyvalue_get_int_check(kv, key, status) + +Query an integer key with error checking. We check whether the key is not found or it is of the wrong type. A default value to be returned on error can be passed in as *status. If status is NULL, then the result on error is undefined. +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key string. +* `status`:\\[in,out\\] If not NULL, set to 0 if there is no error, 1 if the key is not found, 2 if a value is found but its type is not integer, and return the input value *status on error. +# Returns +On error we return *status if status is not NULL, and else an undefined value backed by an assertion. Without error, return the result of the lookup. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_line_zigzag (sc_MPI_Comm comm); +int sc_keyvalue_get_int_check (sc_keyvalue_t * kv, const char *key, int *status); ``` """ -function t8_cmesh_new_line_zigzag(comm) - @ccall libt8.t8_cmesh_new_line_zigzag(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_get_int_check(kv, key, status) + @ccall libsc.sc_keyvalue_get_int_check(kv::Ptr{sc_keyvalue_t}, key::Cstring, status::Ptr{Cint})::Cint end """ - t8_cmesh_new_prism_cake(comm, num_of_prisms) + sc_keyvalue_set_int(kv, key, newvalue) + +Routine to set an integer value for a given key. +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type integer. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_cake (sc_MPI_Comm comm, int num_of_prisms); +void sc_keyvalue_set_int (sc_keyvalue_t * kv, const char *key, int newvalue); ``` """ -function t8_cmesh_new_prism_cake(comm, num_of_prisms) - @ccall libt8.t8_cmesh_new_prism_cake(comm::MPI_Comm, num_of_prisms::Cint)::t8_cmesh_t +function sc_keyvalue_set_int(kv, key, newvalue) + @ccall libsc.sc_keyvalue_set_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cint)::Cvoid end """ - t8_cmesh_new_prism_deformed(comm) + sc_keyvalue_set_double(kv, key, newvalue) + +Routine to set a double value for a given key. +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type double. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_deformed (sc_MPI_Comm comm); +void sc_keyvalue_set_double (sc_keyvalue_t * kv, const char *key, double newvalue); ``` """ -function t8_cmesh_new_prism_deformed(comm) - @ccall libt8.t8_cmesh_new_prism_deformed(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_set_double(kv, key, newvalue) + @ccall libsc.sc_keyvalue_set_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cdouble)::Cvoid end """ - t8_cmesh_new_pyramid_deformed(comm) + sc_keyvalue_set_string(kv, key, newvalue) + +Routine to set a string value for a given key. +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type string. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_pyramid_deformed (sc_MPI_Comm comm); +void sc_keyvalue_set_string (sc_keyvalue_t * kv, const char *key, const char *newvalue); ``` """ -function t8_cmesh_new_pyramid_deformed(comm) - @ccall libt8.t8_cmesh_new_pyramid_deformed(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_set_string(kv, key, newvalue) + @ccall libsc.sc_keyvalue_set_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cstring)::Cvoid end """ - t8_cmesh_new_prism_cake_funny_oriented(comm) + sc_keyvalue_set_pointer(kv, key, newvalue) + +Routine to set a pointer value for a given key. +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type pointer. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_cake_funny_oriented (sc_MPI_Comm comm); +void sc_keyvalue_set_pointer (sc_keyvalue_t * kv, const char *key, void *newvalue); ``` """ -function t8_cmesh_new_prism_cake_funny_oriented(comm) - @ccall libt8.t8_cmesh_new_prism_cake_funny_oriented(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_set_pointer(kv, key, newvalue) + @ccall libsc.sc_keyvalue_set_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Ptr{Cvoid})::Cvoid end +# typedef int ( * sc_keyvalue_foreach_t ) ( const char * key , const sc_keyvalue_entry_type_t type , void * entry , const void * u ) """ - t8_cmesh_new_prism_geometry(comm) +Function to call on every key value pair -### Prototype -```c -t8_cmesh_t t8_cmesh_new_prism_geometry (sc_MPI_Comm comm); -``` +# Arguments +* `key`:\\[in\\] The key for this pair +* `type`:\\[in\\] The type of entry +* `entry`:\\[in\\] Pointer to the entry +* `u`:\\[in\\] Arbitrary user data. +# Returns +Return true if the traversal should continue, false to stop. """ -function t8_cmesh_new_prism_geometry(comm) - @ccall libt8.t8_cmesh_new_prism_geometry(comm::MPI_Comm)::t8_cmesh_t -end +const sc_keyvalue_foreach_t = Ptr{Cvoid} """ - t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) + sc_keyvalue_foreach(kv, fn, user_data) + +Iterate through all stored key-value pairs. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `fn`:\\[in\\] Function to call on each key-value pair. +* `user_data`:\\[in,out\\] This pointer is passed through to **fn**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_brick_2d (t8_gloidx_t num_x, t8_gloidx_t num_y, int x_periodic, int y_periodic, sc_MPI_Comm comm); +void sc_keyvalue_foreach (sc_keyvalue_t * kv, sc_keyvalue_foreach_t fn, void *user_data); ``` """ -function t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) - @ccall libt8.t8_cmesh_new_brick_2d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_foreach(kv, fn, user_data) + @ccall libsc.sc_keyvalue_foreach(kv::Ptr{sc_keyvalue_t}, fn::sc_keyvalue_foreach_t, user_data::Ptr{Cvoid})::Cvoid end """ - t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + sc_statinfo -### Prototype -```c -t8_cmesh_t t8_cmesh_new_brick_3d (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); -``` +Store information of one random variable. + +| Field | Note | +| :--------------- | :--------------------------------------- | +| dirty | Only update stats if this is true. | +| count | Inout; global count is 52 bit accurate. | +| sum\\_values | Inout; global sum of values. | +| sum\\_squares | Inout; global sum of squares. | +| min | Inout; minimum over values. | +| max | Inout; maximum over values. | +| variable | Name of the variable for output. | +| variable\\_owned | NULL or deep copy of variable. | +| group | Grouping identifier. | +| prio | Priority identifier. | """ -function t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) - @ccall libt8.t8_cmesh_new_brick_3d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +struct sc_statinfo + dirty::Cint + count::Clong + sum_values::Cdouble + sum_squares::Cdouble + min::Cdouble + max::Cdouble + min_at_rank::Cint + max_at_rank::Cint + average::Cdouble + variance::Cdouble + standev::Cdouble + variance_mean::Cdouble + standev_mean::Cdouble + variable::Cstring + variable_owned::Cstring + group::Cint + prio::Cint +end + +"""Store information of one random variable.""" +const sc_statinfo_t = sc_statinfo + +struct sc_stats + mpicomm::MPI_Comm + kv::Ptr{sc_keyvalue_t} + sarray::Ptr{sc_array_t} end +"""The statistics container allows dynamically adding random variables.""" +const sc_statistics_t = sc_stats + """ - t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + sc_stats_set1(stats, value, variable) + +Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. We set sc_stats_group_all and sc_stats_prio_all internally. +# Arguments +* `stats`:\\[out\\] Will be filled with count=1 and the value. +* `value`:\\[in\\] Value used to fill statistics information. +* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_disjoint_bricks (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); +void sc_stats_set1 (sc_statinfo_t * stats, double value, const char *variable); ``` -""" -function t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) - @ccall libt8.t8_cmesh_new_disjoint_bricks(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +""" +function sc_stats_set1(stats, value, variable) + @ccall libsc.sc_stats_set1(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring)::Cvoid end """ - t8_cmesh_new_tet_orientation_test(comm) + sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) + +Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. +# Arguments +* `stats`:\\[out\\] Will be filled with count=1 and the value. +* `value`:\\[in\\] Value used to fill statistics information. +* `variable`:\\[in\\] String to be reported by sc_stats_print. +* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. +* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. +* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_tet_orientation_test (sc_MPI_Comm comm); +void sc_stats_set1_ext (sc_statinfo_t * stats, double value, const char *variable, int copy_variable, int stats_group, int stats_prio); ``` """ -function t8_cmesh_new_tet_orientation_test(comm) - @ccall libt8.t8_cmesh_new_tet_orientation_test(comm::MPI_Comm)::t8_cmesh_t +function sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) + @ccall libsc.sc_stats_set1_ext(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid end """ - t8_cmesh_new_hybrid_gate(comm) + sc_stats_init(stats, variable) + +Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. We set sc_stats_group_all and sc_stats_prio_all internally. +# Arguments +* `stats`:\\[out\\] Will be filled with count 0 and values of 0. +* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hybrid_gate (sc_MPI_Comm comm); +void sc_stats_init (sc_statinfo_t * stats, const char *variable); ``` """ -function t8_cmesh_new_hybrid_gate(comm) - @ccall libt8.t8_cmesh_new_hybrid_gate(comm::MPI_Comm)::t8_cmesh_t +function sc_stats_init(stats, variable) + @ccall libsc.sc_stats_init(stats::Ptr{sc_statinfo_t}, variable::Cstring)::Cvoid end """ - t8_cmesh_new_hybrid_gate_deformed(comm) + sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) + +Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. +# Arguments +* `stats`:\\[out\\] Will be filled with count 0 and values of 0. +* `variable`:\\[in\\] String to be reported by sc_stats_print. +* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. +* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. +* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hybrid_gate_deformed (sc_MPI_Comm comm); +void sc_stats_init_ext (sc_statinfo_t * stats, const char *variable, int copy_variable, int stats_group, int stats_prio); ``` """ -function t8_cmesh_new_hybrid_gate_deformed(comm) - @ccall libt8.t8_cmesh_new_hybrid_gate_deformed(comm::MPI_Comm)::t8_cmesh_t +function sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) + @ccall libsc.sc_stats_init_ext(stats::Ptr{sc_statinfo_t}, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid end """ - t8_cmesh_new_full_hybrid(comm) + sc_stats_reset(stats, reset_vgp) + +Reset all values to zero, optionally unassign name, group, and priority. +# Arguments +* `stats`:\\[in,out\\] Variables are zeroed. They can be set again by set1 or accumulate. +* `reset_vgp`:\\[in\\] If true, the variable name string is zeroed and if we did a copy, the copy is freed. If true, group and priority are set to all. If false, we don't touch any of the above. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_full_hybrid (sc_MPI_Comm comm); +void sc_stats_reset (sc_statinfo_t * stats, int reset_vgp); ``` """ -function t8_cmesh_new_full_hybrid(comm) - @ccall libt8.t8_cmesh_new_full_hybrid(comm::MPI_Comm)::t8_cmesh_t +function sc_stats_reset(stats, reset_vgp) + @ccall libsc.sc_stats_reset(stats::Ptr{sc_statinfo_t}, reset_vgp::Cint)::Cvoid end """ - t8_cmesh_new_pyramid_cake(comm, num_of_pyra) + sc_stats_set_group_prio(stats, stats_group, stats_prio) +Set/update the group and priority information for a stats item. + +# Arguments +* `stats`:\\[out\\] Only group and stats entries are updated. +* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. +* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_pyramid_cake (sc_MPI_Comm comm, int num_of_pyra); +void sc_stats_set_group_prio (sc_statinfo_t * stats, int stats_group, int stats_prio); ``` """ -function t8_cmesh_new_pyramid_cake(comm, num_of_pyra) - @ccall libt8.t8_cmesh_new_pyramid_cake(comm::MPI_Comm, num_of_pyra::Cint)::t8_cmesh_t +function sc_stats_set_group_prio(stats, stats_group, stats_prio) + @ccall libsc.sc_stats_set_group_prio(stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint)::Cvoid end """ - t8_cmesh_new_long_brick_pyramid(comm, num_cubes) + sc_stats_accumulate(stats, value) + +Add an instance of the random variable. The counter of the variable is increased by one. The value is added into the present values of the variable. +# Arguments +* `stats`:\\[out\\] Must be dirty. We bump count and values. +* `value`:\\[in\\] Value used to update statistics information. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_long_brick_pyramid (sc_MPI_Comm comm, int num_cubes); +void sc_stats_accumulate (sc_statinfo_t * stats, double value); ``` """ -function t8_cmesh_new_long_brick_pyramid(comm, num_cubes) - @ccall libt8.t8_cmesh_new_long_brick_pyramid(comm::MPI_Comm, num_cubes::Cint)::t8_cmesh_t +function sc_stats_accumulate(stats, value) + @ccall libsc.sc_stats_accumulate(stats::Ptr{sc_statinfo_t}, value::Cdouble)::Cvoid end """ - t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm) + sc_stats_compute(mpicomm, nvars, stats) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, const int do_partition, sc_MPI_Comm comm); +void sc_stats_compute (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); ``` """ -function t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm) - @ccall libt8.t8_cmesh_new_row_of_cubes(num_trees::t8_locidx_t, set_attributes::Cint, do_partition::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_stats_compute(mpicomm, nvars, stats) + @ccall libsc.sc_stats_compute(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid end """ - t8_cmesh_new_quadrangulated_disk(radius, comm) + sc_stats_compute1(mpicomm, nvars, stats) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_quadrangulated_disk (const double radius, sc_MPI_Comm comm); +void sc_stats_compute1 (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); ``` """ -function t8_cmesh_new_quadrangulated_disk(radius, comm) - @ccall libt8.t8_cmesh_new_quadrangulated_disk(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_stats_compute1(mpicomm, nvars, stats) + @ccall libsc.sc_stats_compute1(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid end """ - t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) + sc_stats_print(package_id, log_priority, nvars, stats, full, summary) + +Print measured statistics. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. All groups and priorities are printed. +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Log priority for output according to sc.h. +* `nvars`:\\[in\\] Number of stats items in input array. +* `stats`:\\[in\\] Input array of stats variable items. +* `full`:\\[in\\] Print full information for every variable. +* `summary`:\\[in\\] Print summary information all on 1 line. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_MPI_Comm comm); +void sc_stats_print (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int full, int summary); ``` """ -function t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) - @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_octahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_stats_print(package_id, log_priority, nvars, stats, full, summary) + @ccall libsc.sc_stats_print(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, full::Cint, summary::Cint)::Cvoid end """ - t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) + sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) +Print measured statistics, filter by group and/or priority. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. + +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Log priority for output according to sc.h. +* `nvars`:\\[in\\] Number of stats items in input array. +* `stats`:\\[in\\] Input array of stats variable items. +* `stats_group`:\\[in\\] Print only this group. Non-negative or sc_stats_group_all. We skip printing a variable if neither this parameter nor the item's group is all and if the item's group does not match this. +* `stats_prio`:\\[in\\] Print this and higher priorities. Non-negative or sc_stats_prio_all. We skip printing a variable if neither this parameter nor the item's prio is all and if the item's prio is less than this. +* `full`:\\[in\\] Print full information for every variable. This produces multiple lines including minimum, maximum, and standard deviation. If this is false, print one line per variable. +* `summary`:\\[in\\] Print summary information all on 1 line. This always contains all variables. Not affected by stats\\_group and stats\\_prio. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc_MPI_Comm comm); +void sc_stats_print_ext (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int stats_group, int stats_prio, int full, int summary); ``` """ -function t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) - @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) + @ccall libsc.sc_stats_print_ext(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint, full::Cint, summary::Cint)::Cvoid end """ - t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) + sc_statistics_new(mpicomm) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Comm comm); +sc_statistics_t *sc_statistics_new (sc_MPI_Comm mpicomm); ``` """ -function t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) - @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_cube(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_new(mpicomm) + @ccall libsc.sc_statistics_new(mpicomm::MPI_Comm)::Ptr{sc_statistics_t} end """ - t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) + sc_statistics_destroy(stats) + +Destroy a statistics structure. +# Arguments +* `stats`:\\[in,out\\] Valid object is invalidated. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm); +void sc_statistics_destroy (sc_statistics_t * stats); ``` """ -function t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) - @ccall libt8.t8_cmesh_new_quadrangulated_spherical_surface(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_destroy(stats) + @ccall libsc.sc_statistics_destroy(stats::Ptr{sc_statistics_t})::Cvoid end """ - t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + sc_statistics_add(stats, name) + +Register a statistics variable by name and set its value to 0. This variable must not exist already. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_octahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); +void sc_statistics_add (sc_statistics_t * stats, const char *name); ``` """ -function t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) - @ccall libt8.t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_add(stats, name) + @ccall libsc.sc_statistics_add(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid end """ - t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + sc_statistics_add_empty(stats, name) + +Register a statistics variable by name and set its count to 0. This variable must not exist already. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_icosahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); +void sc_statistics_add_empty (sc_statistics_t * stats, const char *name); ``` """ -function t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) - @ccall libt8.t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_add_empty(stats, name) + @ccall libsc.sc_statistics_add_empty(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid end """ - t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) + sc_statistics_has(stats, name) + +Returns true if the stats include a variable with the given name ### Prototype ```c -t8_cmesh_t t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_trees, const int num_layers, sc_MPI_Comm comm); +int sc_statistics_has (sc_statistics_t * stats, const char *name); ``` """ -function t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) - @ccall libt8.t8_cmesh_new_cubed_spherical_shell(inner_radius::Cdouble, shell_thickness::Cdouble, num_trees::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_has(stats, name) + @ccall libsc.sc_statistics_has(stats::Ptr{sc_statistics_t}, name::Cstring)::Cint end """ - t8_cmesh_new_cubed_sphere(radius, comm) + sc_statistics_set(stats, name, value) + +Set the value of a statistics variable, see [`sc_stats_set1`](@ref). The variable must previously be added with [`sc_statistics_add`](@ref). This assumes count=1 as in the [`sc_stats_set1`](@ref) function above. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm); +void sc_statistics_set (sc_statistics_t * stats, const char *name, double value); ``` """ -function t8_cmesh_new_cubed_sphere(radius, comm) - @ccall libt8.t8_cmesh_new_cubed_sphere(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_set(stats, name, value) + @ccall libsc.sc_statistics_set(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid end """ - t8_cmesh_get_tree_geom_hash(cmesh, gtreeid) + sc_statistics_accumulate(stats, name, value) -Get the hash of the geometry stored for a tree in a cmesh. +Add an instance of a statistics variable, see [`sc_stats_accumulate`](@ref) The variable must previously be added with [`sc_statistics_add_empty`](@ref). -# Arguments -* `cmesh`:\\[in\\] A committed cmesh. -* `gtreeid`:\\[in\\] A global tree in *cmesh*. -# Returns -The hash of the tree's geometry or if only one geometry exists, its hash. ### Prototype ```c -size_t t8_cmesh_get_tree_geom_hash (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); +void sc_statistics_accumulate (sc_statistics_t * stats, const char *name, double value); ``` """ -function t8_cmesh_get_tree_geom_hash(cmesh, gtreeid) - @ccall libt8.t8_cmesh_get_tree_geom_hash(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Csize_t +function sc_statistics_accumulate(stats, name, value) + @ccall libsc.sc_statistics_accumulate(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid end """ - t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) - -Sets the face connectivity information of an un-committed based on a list of tree vertices. - -!!! warning - - This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. - -!!! note + sc_statistics_compute(stats) - This routine does not detect periodic boundaries. +Compute statistics for all variables, see [`sc_stats_compute`](@ref). -# Arguments -* `cmesh`:\\[in,out\\] Pointer to a t8code cmesh object. If set to NULL this argument is ignored. -* `ntrees`:\\[in\\] Number of coarse mesh elements resp. trees. -* `vertices`:\\[in\\] List of per element vertices with dimensions [ntrees,[`T8_ECLASS_MAX_CORNERS`](@ref),[`T8_ECLASS_MAX_DIM`](@ref)]. -* `eclasses`:\\[in\\] List of element classes of length [ntrees]. -* `connectivity`:\\[in,out\\] If connectivity is not NULL the variable is filled with a pointer to an allocated face connectivity array. The ownership of this array goes to the caller. This argument is mainly used for debugging and testing purposes. The dimension of *connectivity* are [ntrees,[`T8_ECLASS_MAX_FACES`](@ref),3]. For each element and each face the following is stored: neighbor\\_tree\\_id, neighbor\\_dual\\_face\\_id, orientation -* `do_both_directions`:\\[in\\] Compute the connectivity from both neighboring sides. Takes much longer to compute. ### Prototype ```c -void t8_cmesh_set_join_by_vertices (t8_cmesh_t cmesh, const t8_gloidx_t ntrees, const t8_eclass_t *eclasses, const double *vertices, int **connectivity, const int do_both_directions); +void sc_statistics_compute (sc_statistics_t * stats); ``` """ -function t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) - @ccall libt8.t8_cmesh_set_join_by_vertices(cmesh::t8_cmesh_t, ntrees::t8_gloidx_t, eclasses::Ptr{t8_eclass_t}, vertices::Ptr{Cdouble}, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid +function sc_statistics_compute(stats) + @ccall libsc.sc_statistics_compute(stats::Ptr{sc_statistics_t})::Cvoid end """ - t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) - -Sets the face connectivity information of an un-committed based on the cmesh stash. - -!!! warning - - This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. - -!!! note + sc_statistics_print(stats, package_id, log_priority, full, summary) - This routine does not detect periodic boundaries. +Print all statistics variables, see [`sc_stats_print`](@ref). -# Arguments -* `cmesh`:\\[in,out\\] An uncommitted cmesh. The trees eclasses and vertices do need to be set. -* `connectivity`:\\[in,out\\] If connectivity is not NULL the variable is filled with a pointer to an allocated face connectivity array. The ownership of this array goes to the caller. This argument is mainly used for debugging and testing purposes. The dimension of *connectivity* are [ntrees,[`T8_ECLASS_MAX_FACES`](@ref),3]. For each element and each face the following is stored: neighbor\\_tree\\_id, neighbor\\_dual\\_face\\_id, orientation -* `do_both_directions`:\\[in\\] Compute the connectivity from both neighboring sides. Takes much longer to compute. ### Prototype ```c -void t8_cmesh_set_join_by_stash (t8_cmesh_t cmesh, int **connectivity, const int do_both_directions); +void sc_statistics_print (sc_statistics_t * stats, int package_id, int log_priority, int full, int summary); ``` """ -function t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) - @ccall libt8.t8_cmesh_set_join_by_stash(cmesh::t8_cmesh_t, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid +function sc_statistics_print(stats, package_id, log_priority, full, summary) + @ccall libsc.sc_statistics_print(stats::Ptr{sc_statistics_t}, package_id::Cint, log_priority::Cint, full::Cint, summary::Cint)::Cvoid end """ - t8_offset_first(proc, offset) + t8_forest + +| Field | Note | +| :----------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| set\\_partition\\_offset | Flag indicating whether the partition range was set manually. | +| set\\_first\\_global\\_element | If set\\_partition\\_offset is true, the global ID of the first local element after partitioning. | +| set\\_level | Level to use in new construction. | +| set\\_for\\_coarsening | Change partition to allow for one round of coarsening | +| weight\\_function | Pointer to user defined element weight function. Nullptr for standard, element-based partitioning. | +| cmesh | Coarse mesh to use. | +| scheme | Scheme for element types. | +| maxlevel | The maximum allowed refinement level for elements in this forest. | +| maxlevel\\_existing | If >= 0, the maximum occurring refinement level of a forest element. | +| do\\_dup | Communicator shall be duped. | +| dimension | Dimension inferred from **cmesh**. | +| incomplete\\_trees | Flag to check whether the forest has (potential) incomplete trees. A tree is incomplete if an element has been removed from it. Once an element got removed, the flag sets to 1 (true) and stays. For a committed forest this flag is either true on all ranks or false on all ranks. | +| set\\_from | Temporarily store source forest. | +| from\\_method | Method to derive from **set_from**. | +| set\\_adapt\\_fn | refinement and coarsen function. Called when **from_method** is set to [`T8_FOREST_FROM_ADAPT`](@ref). | +| set\\_adapt\\_recursive | Flag to decide whether coarsen and refine are carried out recursive | +| set\\_balance | Flag to decide whether to forest will be balance in t8_forest_commit. See t8_forest_set_balance. If 0, no balance. If 1 balance with repartitioning, if 2 balance without repartitioning, # See also t8\\_forest\\_balance | +| do\\_ghost | If True, a ghost layer will be created when the forest is committed. | +| ghost\\_type | If a ghost layer will be created, the type of neighbors that count as ghost. | +| ghost\\_algorithm | Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced 3 = top-down search and unbalanced. | +| user\\_data | Pointer for arbitrary user data. # See also [`t8_forest_set_user_data`](@ref). | +| user\\_function | Pointer for arbitrary user function. # See also [`t8_forest_set_user_function`](@ref). | +| t8code\\_data | Pointer for arbitrary data that is used internally. | +| committed | t8_forest_commit called? | +| mpisize | Number of MPI processes. | +| mpirank | Number of this MPI process. | +| first\\_local\\_tree | The global index of the first local tree on this process. If first\\_local\\_tree is larger than last\\_local\\_tree then this processor/forest is empty. See https://github.com/DLR-AMR/t8code/wiki/Tree-indexing | +| last\\_local\\_tree | The global index of the last local tree on this process. -1 if this processor is empty. | +| global\\_num\\_trees | The total number of global trees. | +| trees | The array of trees. | +| ghosts | If not NULL, the ghost elements. # See also [`t8_forest_ghost`](@ref).h | +| element\\_offsets | If partitioned, for each process the global index of its first element. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | +| global\\_first\\_desc | If partitioned, for each process the linear id (at maxlevel) of its first element's first descendant. t8_element_set_linear_id. Stores 0 for empty processes. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | +| tree\\_offsets | If partitioned for each process the global index of its first local tree or -(first local tree) - 1 if the first tree on that process is shared. Since this is memory consuming we only construct it when needed. This array follows the same logic as *tree_offsets* in [`t8_cmesh_t`](@ref) | +| local\\_num\\_leaf\\_elements | Number of leaf elements on this processor. | +| global\\_num\\_leaf\\_elements | Number of leaf elements on all processors. | +| profile | If not NULL, runtimes and statistics about forest\\_commit are stored here. | +| stats | The SC profiling stats of the forest. | +| stats\\_computed | Switch indicating whether the profiling stats have been compute (1) or not (0) | +""" +# This struct is not supposed to be read and modified directly. +# Besides, there is a circular dependency with `t8_forest_t` +# leading to an error output by Julia. +mutable struct t8_forest end + +"""Opaque pointer to a forest implementation.""" +const t8_forest_t = Ptr{t8_forest} + +""" + t8_forest_adapt(forest) -Return the global id of the first local tree of a given process in a partition. +Adapt a forest. # Arguments -* `proc`:\\[in\\] The rank of the process. -* `offset`:\\[in\\] The partition table. -# Returns -The global id of the first local tree of *proc* in the partition *offset*. +* `forest`:\\[in,out\\] The forest to be adapted ### Prototype ```c -t8_gloidx_t t8_offset_first (const int proc, const t8_gloidx_t *offset); +void t8_forest_adapt (t8_forest_t forest); ``` """ -function t8_offset_first(proc, offset) - @ccall libt8.t8_offset_first(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t +function t8_forest_adapt(forest) + @ccall libt8.t8_forest_adapt(forest::t8_forest_t)::Cvoid end """ - t8_offset_first_tree_to_entry(first_tree, shared) + t8_tree -Given the global tree id of the first local tree of a process and the flag whether it is shared or not, compute the entry in the offset array. This entry is the first\\_tree if it is not shared and -first\\_tree - 1 if it is shared. +The t8 tree datatype -# Arguments -* `first_tree`:\\[in\\] The global tree id of a process's first tree. -* `shared`:\\[in\\] 0 if *first_tree* is not shared with a smaller rank, 1 if it is. -# Returns -The entry that represents the process in an offset array. *first_tree* if *shared* == 0 - *first_tree* - 1 if *shared* != 0 -### Prototype -```c -t8_gloidx_t t8_offset_first_tree_to_entry (const t8_gloidx_t first_tree, const int shared); -``` +| Field | Note | +| :---------------- | :----------------------------------------------------------------- | +| leaf\\_elements | locally stored leaf elements | +| eclass | The element class of this tree | +| first\\_desc | first local descendant | +| last\\_desc | last local descendant | +| elements\\_offset | cumulative sum over earlier trees on this processor (locals only) | """ -function t8_offset_first_tree_to_entry(first_tree, shared) - @ccall libt8.t8_offset_first_tree_to_entry(first_tree::t8_gloidx_t, shared::Cint)::t8_gloidx_t +struct t8_tree + leaf_elements::t8_element_array_t + eclass::t8_eclass_t + first_desc::Ptr{t8_element_t} + last_desc::Ptr{t8_element_t} + elements_offset::t8_locidx_t end +"""Opaque pointer to a tree implementation.""" +const t8_tree_t = Ptr{t8_tree} + """ - t8_offset_num_trees(proc, offset) + t8_ghost_type_t -The number of trees of a given process in a partition. +This type controls, which neighbors count as ghost elements. Currently, we support face-neighbors. Vertex and edge neighbors will eventually be added. -# Arguments -* `proc`:\\[in\\] A mpi rank. -* `offset`:\\[in\\] A partition table. -# Returns -The number of local trees of *proc* in the partition *offset*. -### Prototype -```c -t8_gloidx_t t8_offset_num_trees (const int proc, const t8_gloidx_t *offset); -``` +| Enumerator | Note | +| :-------------------- | :---------------------------------------------------------------- | +| T8\\_GHOST\\_NONE | Do not create ghost layer. | +| T8\\_GHOST\\_FACES | Consider all face (codimension 1) neighbors. | +| T8\\_GHOST\\_EDGES | Consider all edge (codimension 2) and face neighbors. | +| T8\\_GHOST\\_VERTICES | Consider all vertex (codimension 3) and edge and face neighbors. | """ -function t8_offset_num_trees(proc, offset) - @ccall libt8.t8_offset_num_trees(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t +@cenum t8_ghost_type_t::UInt32 begin + T8_GHOST_NONE = 0 + T8_GHOST_FACES = 1 + T8_GHOST_EDGES = 2 + T8_GHOST_VERTICES = 3 end +# typedef void ( * t8_generic_function_pointer ) ( void ) """ - t8_offset_last(proc, offset) +This typedef is needed as a helper construct to properly be able to define a function that returns a pointer to a void fun(void) function. -Return the last local tree of a given process in a partition. - -# Arguments -* `proc`:\\[in\\] A mpi rank. -* `offset`:\\[in\\] A partition table. -# Returns -The global tree id of the last local tree of *proc* in *offset*. -### Prototype -```c -t8_gloidx_t t8_offset_last (const int proc, const t8_gloidx_t *offset); -``` +# See also +[`t8_forest_get_user_function`](@ref). """ -function t8_offset_last(proc, offset) - @ccall libt8.t8_offset_last(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t -end +const t8_generic_function_pointer = Ptr{Cvoid} +# typedef double ( t8_weight_fcn_t ) ( t8_forest_t , t8_locidx_t , t8_locidx_t ) +"""The prototype of a weight function for the partition algorithm. The function should be pure, and return a positive weight given a forest, a local tree index and an element index within the local tree""" +const t8_weight_fcn_t = Cvoid + +# typedef void ( * t8_forest_replace_t ) ( t8_forest_t forest_old , t8_forest_t forest_new , t8_locidx_t which_tree , const t8_eclass_t tree_class , const t8_scheme_c * scheme , const int refine , const int num_outgoing , const t8_locidx_t first_outgoing , const int num_incoming , const t8_locidx_t first_incoming ) """ - t8_offset_empty(proc, offset) +Callback function prototype to replace one set of elements with another. + +This is used by the replace routine which can be called after adapt, when the elements of an existing, valid forest are changed. The callback allows the user to make changes to the elements of the new forest that are either refined, coarsened or the same as elements in the old forest. -Check whether a given process has no local trees in a given partition. +If an element is being refined, *refine* and *num_outgoing* will be 1 and *num_incoming* will be the number of children. If a family is being coarsened, *refine* will be -1, *num_outgoing* will be the number of family members and *num_incoming* will be 1. If an element is being removed, *refine* and *num_outgoing* will be 1 and *num_incoming* will be 0. Else *refine* will be 0 and *num_outgoing* and *num_incoming* will both be 1. # Arguments -* `proc`:\\[in\\] A mpi rank. -* `offset`:\\[in\\] A partition table. -# Returns -nonzero if *proc* does not have local trees in *offset*. 0 otherwise. -### Prototype -```c -int t8_offset_empty (const int proc, const t8_gloidx_t *offset); -``` +* `forest_old`:\\[in\\] The forest that is adapted +* `forest_new`:\\[in,out\\] The forest that is newly constructed from *forest_old* +* `which_tree`:\\[in\\] The local tree containing *first_outgoing* and *first_incoming* +* `tree_class`:\\[in\\] The eclass of the local tree containing *first_outgoing* and *first_incoming* +* `scheme`:\\[in\\] The scheme of the forest +* `refine`:\\[in\\] -1 if family in *forest_old* got coarsened, 0 if element has not been touched, 1 if element got refined and -2 if element got removed. See return of [`t8_forest_adapt_t`](@ref). +* `num_outgoing`:\\[in\\] The number of outgoing elements. +* `first_outgoing`:\\[in\\] The tree local index of the first outgoing element. 0 <= first\\_outgoing < which\\_tree->num\\_elements +* `num_incoming`:\\[in\\] The number of incoming elements. +* `first_incoming`:\\[in\\] The tree local index of the first incoming element. 0 <= first\\_incom < new\\_which\\_tree->num\\_elements +# See also +[`t8_forest_iterate_replace`](@ref) """ -function t8_offset_empty(proc, offset) - @ccall libt8.t8_offset_empty(proc::Cint, offset::Ptr{t8_gloidx_t})::Cint -end +const t8_forest_replace_t = Ptr{Cvoid} +# typedef int ( * t8_forest_adapt_t ) ( t8_forest_t forest , t8_forest_t forest_from , t8_locidx_t which_tree , const t8_eclass_t tree_class , t8_locidx_t lelement_id , const t8_scheme_c * scheme , const int is_family , const int num_elements , t8_element_t * elements [ ] ) """ - t8_offset_next_nonempty_rank(rank, mpisize, offset) - -Find the next higher rank that is not empty. returns mpisize if this rank does not exist. +Callback function prototype to decide for refining and coarsening. If *is_family* equals 1, the first *num_elements* in *elements* form a family and we decide whether this family should be coarsened or only the first element should be refined. Otherwise *is_family* must equal zero and we consider the first entry of the element array for refinement. Entries of the element array beyond the first *num_elements* are undefined. # Arguments -* `proc`:\\[in\\] An MPI rank. -* `mpisize`:\\[in\\] The number of total MPI ranks. -* `offset`:\\[in\\] An array with at least *mpisize* + 1 entries. +* `forest`:\\[in\\] The forest to which the new elements belong. +* `forest_from`:\\[in\\] The forest that is adapted. +* `which_tree`:\\[in\\] The local tree containing *elements*. +* `tree_class`:\\[in\\] The eclass of *which_tree*. +* `lelement_id`:\\[in\\] The local element id in *forest_from* in the tree of the current element. +* `scheme`:\\[in\\] The scheme of the forest. +* `is_family`:\\[in\\] If 1, the first *num_elements* entries in *elements* form a family. If 0, they do not. +* `num_elements`:\\[in\\] The number of entries in *elements* that are defined +* `elements`:\\[in\\] Pointers to a family or, if *is_family* is zero, pointer to one element. # Returns -A rank *p* such that *p* > *rank* and [`t8_offset_empty`](@ref) (*p*, *offset*) is True and [`t8_offset_empty`](@ref) (*q*, *offset*) is False for all *rank* < *q* < *p*. If no such *q* exists, *mpisize* is returned. -### Prototype -```c -int t8_offset_next_nonempty_rank (const int rank, const int mpisize, const t8_gloidx_t *offset); -``` +1 if the first entry in *elements* should be refined, -1 if the family *elements* shall be coarsened, -2 if the first entry in *elements* should be removed, 0 else. """ -function t8_offset_next_nonempty_rank(rank, mpisize, offset) - @ccall libt8.t8_offset_next_nonempty_rank(rank::Cint, mpisize::Cint, offset::Ptr{t8_gloidx_t})::Cint -end +const t8_forest_adapt_t = Ptr{Cvoid} """ - t8_offset_in_range(tree_id, proc, offset) + t8_forest_init(pforest) -Determine whether a given global tree id is a local tree of a given process in a certain partition. +Create a new forest with reference count one. This forest needs to be specialized with the t8\\_forest\\_set\\_* calls. Currently it is mandatory to either call the functions # Arguments -* `tree_id`:\\[in\\] A global tree id. -* `proc`:\\[in\\] A mpi rank. -* `offset`:\\[in\\] A partition table. -# Returns -nonzero if *tree_id* is a local tree of *proc* in *offset*. 0 if it is not. +* `pforest`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new forest. +# See also +t8\\_forest\\_set\\_mpicomm, t8_forest_set_cmesh, and t8_forest_set_scheme, or to call one of t8_forest_set_copy, t8_forest_set_adapt, or t8_forest_set_partition. It is illegal to mix these calls, or to call more than one of the three latter functions Then it needs to be set up with t8_forest_commit. + ### Prototype ```c -int t8_offset_in_range (const t8_gloidx_t tree_id, const int proc, const t8_gloidx_t *offset); +void t8_forest_init (t8_forest_t *pforest); ``` """ -function t8_offset_in_range(tree_id, proc, offset) - @ccall libt8.t8_offset_in_range(tree_id::t8_gloidx_t, proc::Cint, offset::Ptr{t8_gloidx_t})::Cint +function t8_forest_init(pforest) + @ccall libt8.t8_forest_init(pforest::Ptr{t8_forest_t})::Cvoid end """ - t8_offset_any_owner_of_tree(mpisize, gtree, offset) + t8_forest_is_initialized(forest) -Find any process that has a given tree as local tree. +Check whether a forest is not NULL, initialized and not committed. In addition, it asserts that the forest is consistent as much as possible. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. +* `forest`:\\[in\\] This forest is examined. May be NULL. # Returns -An MPI rank that has *gtree* as a local tree. +True if forest is not NULL, t8_forest_init has been called on it, but not t8_forest_commit. False otherwise. ### Prototype ```c -int t8_offset_any_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset); +int t8_forest_is_initialized (t8_forest_t forest); ``` """ -function t8_offset_any_owner_of_tree(mpisize, gtree, offset) - @ccall libt8.t8_offset_any_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t})::Cint +function t8_forest_is_initialized(forest) + @ccall libt8.t8_forest_is_initialized(forest::t8_forest_t)::Cint end """ - t8_offset_any_owner_of_tree_ext(mpisize, start_proc, gtree, offset) + t8_forest_is_committed(forest) -Find any process that has a given tree as local tree. +Check whether a forest is not NULL, initialized and committed. In addition, it asserts that the forest is consistent as much as possible. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `start_proc`:\\[in\\] The mpirank to start the search with. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. +* `forest`:\\[in\\] This forest is examined. May be NULL. # Returns -An MPI rank that has *gtree* as a local tree. +True if forest is not NULL and t8_forest_init has been called on it as well as t8_forest_commit. False otherwise. ### Prototype ```c -int t8_offset_any_owner_of_tree_ext (const int mpisize, const int start_proc, const t8_gloidx_t gtree, const t8_gloidx_t *offset); +int t8_forest_is_committed (t8_forest_t forest); ``` """ -function t8_offset_any_owner_of_tree_ext(mpisize, start_proc, gtree, offset) - @ccall libt8.t8_offset_any_owner_of_tree_ext(mpisize::Cint, start_proc::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t})::Cint +function t8_forest_is_committed(forest) + @ccall libt8.t8_forest_is_committed(forest::t8_forest_t)::Cint end """ - t8_offset_first_owner_of_tree(mpisize, gtree, offset, some_owner) + t8_forest_no_overlap(forest) + +Check whether the forest has local overlapping elements. -Find the smallest process that has a given tree as local tree. To increase the runtime, an arbitrary process having this tree as local tree can be passed as an argument. Otherwise, such an owner is computed during the call. +!!! note + + This function is collective, but only checks local overlapping on each process. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `some_owner`:\\[in\\] If >= 0 considered as input: a process that has *gtree* as local tree. If < 0 on output a process that has *gtree* as local tree. Specifying *some_owner* increases the runtime from O(log mpisize) to O(n), where n is the number of owners of the tree. +* `forest`:\\[in\\] The forest to consider. # Returns -The smallest rank that has *gtree* as a local tree. +True if *forest* has no elements which are inside each other. +# See also +[`t8_forest_partition_test_boundary_element`](@ref) if you also want to test for global overlap across the process boundaries. + ### Prototype ```c -int t8_offset_first_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner); +int t8_forest_no_overlap (t8_forest_t forest); ``` """ -function t8_offset_first_owner_of_tree(mpisize, gtree, offset, some_owner) - @ccall libt8.t8_offset_first_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, some_owner::Ptr{Cint})::Cint +function t8_forest_no_overlap(forest) + @ccall libt8.t8_forest_no_overlap(forest::t8_forest_t)::Cint end """ - t8_offset_last_owner_of_tree(mpisize, gtree, offset, some_owner) + t8_forest_is_equal(forest_a, forest_b) + +Check whether two committed forests have the same local elements. + +!!! note -Find the biggest process that has a given tree as local tree. To increase the runtime, an arbitrary process having this tree as local tree can be passed as an argument. Otherwise, such an owner is computed during the call. + This function is not collective. It only returns the state on the current rank. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `some_owner`:\\[in,out\\] If >= 0 considered as input: a process that has *gtree* as local tree. If < 0 on output a process that has *gtree* as local tree. Specifying *some_owner* increases the runtime from O(log mpisize) to O(n), where n is the number of owners of the tree. +* `forest_a`:\\[in\\] The first forest. +* `forest_b`:\\[in\\] The second forest. # Returns -The biggest rank that has *gtree* as a local tree. +True if *forest_a* and *forest_b* do have the same number of local trees and each local tree has the same elements, that is t8_element_is_equal returns true for each pair of elements of *forest_a* and *forest_b*. ### Prototype ```c -int t8_offset_last_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner); +int t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b); ``` """ -function t8_offset_last_owner_of_tree(mpisize, gtree, offset, some_owner) - @ccall libt8.t8_offset_last_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, some_owner::Ptr{Cint})::Cint +function t8_forest_is_equal(forest_a, forest_b) + @ccall libt8.t8_forest_is_equal(forest_a::t8_forest_t, forest_b::t8_forest_t)::Cint end """ - t8_offset_next_owner_of_tree(mpisize, gtree, offset, current_owner) - -Given a process current\\_owner that has the tree gtree as local tree, find the next bigger rank that also has this tree as local tree. + t8_forest_set_cmesh(forest, cmesh, comm) -# Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `current_owner`:\\[in\\] A process that has *gtree* as local tree. -# Returns -The MPI rank of the next bigger rank than *current_owner* that has *gtree* as local tree. -1 if non such rank exists. ### Prototype ```c -int t8_offset_next_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int current_owner); +void t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function t8_offset_next_owner_of_tree(mpisize, gtree, offset, current_owner) - @ccall libt8.t8_offset_next_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, current_owner::Cint)::Cint +function t8_forest_set_cmesh(forest, cmesh, comm) + @ccall libt8.t8_forest_set_cmesh(forest::t8_forest_t, cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - t8_offset_prev_owner_of_tree(mpisize, gtree, offset, current_owner) + t8_forest_set_scheme(forest, scheme) -Given a process current\\_owner that has the tree gtree as local tree, find the next smaller rank that also has this tree as local tree. +Set the element scheme associated to a forest. By default, the forest takes ownership of the scheme such that it will be destroyed when the forest is destroyed. To keep ownership of the scheme, call t8_scheme_ref before passing it to t8_forest_set_scheme. This means that it is ILLEGAL to continue using scheme or dereferencing it UNLESS it is referenced directly before passing it into this function. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `current_owner`:\\[in\\] A process that has *gtree* as local tree. -# Returns -The MPI rank of the next smaller rank than *current_owner* that has *gtree* as local tree. -1 if non such rank exists. +* `forest`:\\[in,out\\] The forest whose scheme variable will be set. +* `scheme`:\\[in\\] The scheme to be set. We take ownership. This can be prevented by referencing **scheme**. ### Prototype ```c -int t8_offset_prev_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, const int current_owner); +void t8_forest_set_scheme (t8_forest_t forest, const t8_scheme_c *scheme); ``` """ -function t8_offset_prev_owner_of_tree(mpisize, gtree, offset, current_owner) - @ccall libt8.t8_offset_prev_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, current_owner::Cint)::Cint +function t8_forest_set_scheme(forest, scheme) + @ccall libt8.t8_forest_set_scheme(forest::t8_forest_t, scheme::Ptr{t8_scheme_c})::Cvoid end """ - t8_offset_all_owners_of_tree(mpisize, gtree, offset, owners) + t8_forest_set_level(forest, level) + +Set the initial refinement level to be used when **forest** is committed. + +!!! note -Compute a list of all processes that own a specific tree.n *offset* minus 1. + This setting cannot be combined with any of the derived forest methods (t8_forest_set_copy, t8_forest_set_adapt, t8_forest_set_partition, and t8_forest_set_balance) and overwrites any of these settings. If this function is used, then the forest is created from scratch as a uniform refinement of the specified cmesh (t8_forest_set_cmesh, t8_forest_set_scheme). # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global index of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `owners`:\\[in,out\\] On input an initialized [`sc_array`](@ref) with integer entries and zero elements. On output a sorted list of all MPI ranks that have *gtree* as a local tree in *offset*. +* `forest`:\\[in,out\\] The forest whose level will be set. +* `level`:\\[in\\] The initial refinement level of **forest**, when it is committed. ### Prototype ```c -void t8_offset_all_owners_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, sc_array_t *owners); +void t8_forest_set_level (t8_forest_t forest, int level); ``` """ -function t8_offset_all_owners_of_tree(mpisize, gtree, offset, owners) - @ccall libt8.t8_offset_all_owners_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, owners::Ptr{sc_array_t})::Cvoid +function t8_forest_set_level(forest, level) + @ccall libt8.t8_forest_set_level(forest::t8_forest_t, level::Cint)::Cvoid end """ - t8_offset_nosend(proc, mpisize, offset_from, offset_to) + t8_forest_set_copy(forest, from) + +Set a forest as source for copying on committing. By default, the forest takes ownership of the source **from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **from** or dereferencing it UNLESS it is referenced directly before passing it into this function. -Query whether in a repartition setting a given process does send any of its local trees to any other process (including itself) +!!! note + + This setting cannot be combined with t8_forest_set_adapt, t8_forest_set_partition, or t8_forest_set_balance and overwrites these settings. # Arguments -* `proc`:\\[in\\] A mpi rank. -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `offset_from`:\\[in\\] The partition table of the current partition. -* `offset_to`:\\[in\\] The partition table of the next partition. -# Returns -nonzero if *proc* will not send any local trees if we repartition from *offset_from* to *offset_to* 0 if it does send local trees. +* `forest`:\\[in,out\\] The forest. +* `from`:\\[in\\] A second forest from which *forest* will be copied in t8_forest_commit. ### Prototype ```c -int t8_offset_nosend (int proc, int mpisize, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); +void t8_forest_set_copy (t8_forest_t forest, const t8_forest_t from); ``` """ -function t8_offset_nosend(proc, mpisize, offset_from, offset_to) - @ccall libt8.t8_offset_nosend(proc::Cint, mpisize::Cint, offset_from::Ptr{t8_gloidx_t}, offset_to::Ptr{t8_gloidx_t})::Cint +function t8_forest_set_copy(forest, from) + @ccall libt8.t8_forest_set_copy(forest::t8_forest_t, from::t8_forest_t)::Cvoid end """ - t8_offset_sendsto(proca, procb, t8_offset_from, t8_offset_to) + t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) -Query whether in a repartitioning setting, a given process sends local trees (and then possibly ghosts) to a given other process. +Set a source forest with an adapt function to be adapted on committing. By default, the forest takes ownership of the source **set_from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **set_from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **set_from** or dereferencing it UNLESS it is referenced directly before passing it into this function. -# Arguments -* `proca`:\\[in\\] Mpi rank of the possible sending process. -* `procb`:\\[in\\] Mpi rank of the possible receiver. -* `offset_from`:\\[in\\] The partition table of the current partition. -* `offset_to`:\\[in\\] The partition table of the next partition. -# Returns -nonzero if *proca* does send local trees to *procb* when we repartition from *offset_from* to *offset_to*. 0 else. -### Prototype -```c -int t8_offset_sendsto (int proca, int procb, const t8_gloidx_t *t8_offset_from, const t8_gloidx_t *t8_offset_to); -``` -""" -function t8_offset_sendsto(proca, procb, t8_offset_from, t8_offset_to) - @ccall libt8.t8_offset_sendsto(proca::Cint, procb::Cint, t8_offset_from::Ptr{t8_gloidx_t}, t8_offset_to::Ptr{t8_gloidx_t})::Cint -end +!!! note -""" - t8_offset_sendstree(proc_send, proc_to, gtree, offset_from, offset_to) + This setting can be combined with t8_forest_set_partition and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance. -Query whether in a repartitioning setting, a given process sends a given tree to a second process. +!!! note + + This setting may not be combined with t8_forest_set_copy and overwrites this setting. # Arguments -* `proc_send`:\\[in\\] Mpi rank of the possible sending process. -* `proc_recv`:\\[in\\] Mpi rank of the possible receiver. -* `gtree`:\\[in\\] A global tree id. -* `offset_from`:\\[in\\] The partition table of the current partition. -* `offset_to`:\\[in\\] The partition table of the next partition. -# Returns -nonzero if *proc_send* will send the tree *gtree* to *proc_recv*. 0 else. When calling, *gtree* must not be a local tree of *proc_send* in *offset_from*. In this case, 0 is always returned. +* `forest`:\\[in,out\\] The forest +* `set_from`:\\[in\\] The source forest from which **forest** will be adapted. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_partition, t8_forest_set_balance). +* `adapt_fn`:\\[in\\] The adapt function used on committing. +* `recursive`:\\[in\\] A flag specifying whether adaptation is to be done recursively or not. If the value is zero, adaptation is not recursive and it is recursive otherwise. ### Prototype ```c -int t8_offset_sendstree (int proc_send, int proc_to, t8_gloidx_t gtree, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); +void t8_forest_set_adapt (t8_forest_t forest, const t8_forest_t set_from, t8_forest_adapt_t adapt_fn, const int recursive); ``` """ -function t8_offset_sendstree(proc_send, proc_to, gtree, offset_from, offset_to) - @ccall libt8.t8_offset_sendstree(proc_send::Cint, proc_to::Cint, gtree::t8_gloidx_t, offset_from::Ptr{t8_gloidx_t}, offset_to::Ptr{t8_gloidx_t})::Cint +function t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) + @ccall libt8.t8_forest_set_adapt(forest::t8_forest_t, set_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint)::Cvoid end """ - t8_offset_range_send(start, _end, mpirank, offset_from, offset_to) + t8_forest_set_user_data(forest, data) -Count the number of processes in a given range [a,b] that send to a given other process in a repartitioning setting. +Set the user data of a forest. This can i.e. be used to pass user defined arguments to the adapt routine. # Arguments -* `start`:\\[in\\] The first mpi rank to be considered as sender. -* `end`:\\[in\\] The last mpi rank to be considered as sender. -* `mpirank`:\\[in\\] The mpirank to be considered as receiver. -* `offset_from`:\\[in\\] The partition table of the current partition. -* `offset_to`:\\[in\\] The partition table of the next partition. -# Returns -The number of processes p, such that *start* <= p <= *end* and p does send local trees (and possibly ghosts) to *mpirank*. +* `forest`:\\[in,out\\] The forest +* `data`:\\[in\\] A pointer to user data. t8code will never touch the data. The forest does not need be committed before calling this function. +# See also +[`t8_forest_get_user_data`](@ref) + ### Prototype ```c -int t8_offset_range_send (int start, int end, int mpirank, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); +void t8_forest_set_user_data (t8_forest_t forest, void *data); ``` """ -function t8_offset_range_send(start, _end, mpirank, offset_from, offset_to) - @ccall libt8.t8_offset_range_send(start::Cint, _end::Cint, mpirank::Cint, offset_from::Ptr{t8_gloidx_t}, offset_to::Ptr{t8_gloidx_t})::Cint +function t8_forest_set_user_data(forest, data) + @ccall libt8.t8_forest_set_user_data(forest::t8_forest_t, data::Ptr{Cvoid})::Cvoid end """ - t8_offset_print(offset, comm) + t8_forest_get_user_data(forest) -### Prototype -```c -void t8_offset_print (t8_shmem_array_t offset, sc_MPI_Comm comm); -``` -""" -function t8_offset_print(offset, comm) - @ccall libt8.t8_offset_print(offset::t8_shmem_array_t, comm::MPI_Comm)::Cvoid -end +Return the user data pointer associated with a forest. -""" - t8_cmesh_partition(cmesh, comm) +# Arguments +* `forest`:\\[in\\] The forest. +# Returns +The user data pointer of *forest*. The forest does not need be committed before calling this function. +# See also +[`t8_forest_set_user_data`](@ref) ### Prototype ```c -void t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm); +void * t8_forest_get_user_data (const t8_forest_t forest); ``` """ -function t8_cmesh_partition(cmesh, comm) - @ccall libt8.t8_cmesh_partition(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_forest_get_user_data(forest) + @ccall libt8.t8_forest_get_user_data(forest::t8_forest_t)::Ptr{Cvoid} end """ - t8_cmesh_gather_trees_per_eclass(cmesh, comm) + t8_forest_set_user_function(forest, _function) -### Prototype -```c -void t8_cmesh_gather_trees_per_eclass (t8_cmesh_t cmesh, sc_MPI_Comm comm); -``` -""" -function t8_cmesh_gather_trees_per_eclass(cmesh, comm) - @ccall libt8.t8_cmesh_gather_trees_per_eclass(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid -end +Set the user function pointer of a forest. This can i.e. be used to pass user defined functions to the adapt routine. -""" - t8_cmesh_gather_treecount(cmesh, comm) +!!! note -### Prototype -```c -void t8_cmesh_gather_treecount (t8_cmesh_t cmesh, sc_MPI_Comm comm); -``` -""" -function t8_cmesh_gather_treecount(cmesh, comm) - @ccall libt8.t8_cmesh_gather_treecount(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid -end + *function* can be an arbitrary function with return value and parameters of your choice. When accessing it with t8_forest_get_user_function you should cast it into the proper type. -""" - t8_cmesh_gather_treecount_nocommit(cmesh, comm) +# Arguments +* `forest`:\\[in,out\\] The forest +* `function`:\\[in\\] A pointer to a user defined function. t8code will never touch the function. The forest does not need be committed before calling this function. +# See also +[`t8_forest_get_user_function`](@ref) ### Prototype ```c -void t8_cmesh_gather_treecount_nocommit (t8_cmesh_t cmesh, sc_MPI_Comm comm); +void t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer function); ``` """ -function t8_cmesh_gather_treecount_nocommit(cmesh, comm) - @ccall libt8.t8_cmesh_gather_treecount_nocommit(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_forest_set_user_function(forest, _function) + @ccall libt8.t8_forest_set_user_function(forest::t8_forest_t, _function::t8_generic_function_pointer)::Cvoid end """ - t8_cmesh_offset_print(cmesh, comm) + t8_forest_get_user_function(forest) -### Prototype -```c -void t8_cmesh_offset_print (t8_cmesh_t cmesh, sc_MPI_Comm comm); -``` -""" -function t8_cmesh_offset_print(cmesh, comm) - @ccall libt8.t8_cmesh_offset_print(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid -end +Return the user function pointer associated with a forest. -""" - t8_cmesh_offset_concentrate(proc, comm, num_trees) +# Arguments +* `forest`:\\[in\\] The forest. +# Returns +The user function pointer of *forest*. The forest does not need be committed before calling this function. +# See also +[`t8_forest_set_user_function`](@ref) ### Prototype ```c -t8_shmem_array_t t8_cmesh_offset_concentrate (int proc, sc_MPI_Comm comm, t8_gloidx_t num_trees); +t8_generic_function_pointer t8_forest_get_user_function (const t8_forest_t forest); ``` """ -function t8_cmesh_offset_concentrate(proc, comm, num_trees) - @ccall libt8.t8_cmesh_offset_concentrate(proc::Cint, comm::MPI_Comm, num_trees::t8_gloidx_t)::t8_shmem_array_t +function t8_forest_get_user_function(forest) + @ccall libt8.t8_forest_get_user_function(forest::t8_forest_t)::t8_generic_function_pointer end """ - t8_cmesh_offset_random(comm, num_trees, shared, seed) + t8_forest_set_partition(forest, set_from, set_for_coarsening) + +Set a source forest to be partitioned during commit. The partitioning is done according to the SFC and each rank is assigned the same (maybe +1) number of elements. + +!!! note + This setting can be combined with t8_forest_set_adapt and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance. If t8_forest_set_balance is called with the *no_repartition* parameter set as false, it is not necessary to call t8_forest_set_partition additionally. + +!!! note + + This setting may not be combined with t8_forest_set_copy and overwrites this setting. + +# Arguments +* `forest`:\\[in,out\\] The forest. +* `set_from`:\\[in\\] A second forest that should be partitioned. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_balance). +* `set_for_coarsening`:\\[in\\] If true, the partition will be such that coarsening a family of elements into their parent once is a process-local operation. This is ensured by a post-processing step that slightly shifts the newly determined process boundaries such that no full family of (same-level) siblings is split between processes. ### Prototype ```c -t8_shmem_array_t t8_cmesh_offset_random (sc_MPI_Comm comm, t8_gloidx_t num_trees, int shared, unsigned seed); +void t8_forest_set_partition (t8_forest_t forest, const t8_forest_t set_from, int set_for_coarsening); ``` """ -function t8_cmesh_offset_random(comm, num_trees, shared, seed) - @ccall libt8.t8_cmesh_offset_random(comm::MPI_Comm, num_trees::t8_gloidx_t, shared::Cint, seed::Cuint)::t8_shmem_array_t +function t8_forest_set_partition(forest, set_from, set_for_coarsening) + @ccall libt8.t8_forest_set_partition(forest::t8_forest_t, set_from::t8_forest_t, set_for_coarsening::Cint)::Cvoid end """ - t8_cmesh_offset_half(cmesh, comm) + t8_forest_set_partition_weight_function(forest, weight_callback) + +Set a user-defined weight function to guide the partitioning. + +\\pre *weight_callback* must be free of side effects (like changing the forest, some global state, etc.), the behavior is undefined otherwise. + +!!! note + + If *weight_callback* is null, then all the elements are assumed to have the same weight +# Arguments +* `forest`:\\[in,out\\] The forest. +* `weight_callback`:\\[in\\] A callback function defining element weights for the partitioning. ### Prototype ```c -t8_shmem_array_t t8_cmesh_offset_half (t8_cmesh_t cmesh, sc_MPI_Comm comm); +void t8_forest_set_partition_weight_function (t8_forest_t forest, t8_weight_fcn_t *weight_callback); ``` """ -function t8_cmesh_offset_half(cmesh, comm) - @ccall libt8.t8_cmesh_offset_half(cmesh::t8_cmesh_t, comm::MPI_Comm)::t8_shmem_array_t +function t8_forest_set_partition_weight_function(forest, weight_callback) + @ccall libt8.t8_forest_set_partition_weight_function(forest::t8_forest_t, weight_callback::Ptr{t8_weight_fcn_t})::Cvoid end """ - t8_cmesh_offset_percent(cmesh, comm, percent) + t8_forest_set_balance(forest, set_from, no_repartition) + +Set a source forest to be balanced during commit. A forest is said to be balanced if each element has face neighbors of level at most +1 or -1 of the element's level. + +!!! note + + This setting can be combined with t8_forest_set_adapt and t8_forest_set_partition. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance. +!!! note + + This setting may not be combined with t8_forest_set_copy and overwrites this setting. + +# Arguments +* `forest`:\\[in,out\\] The forest. +* `set_from`:\\[in\\] A second forest that should be balanced. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_partition) +* `no_repartition`:\\[in\\] Balance constructs several intermediate forest that are refined from each other. In order to maintain a balanced load these forest are repartitioned in each round and the resulting forest is load-balanced per default. If this behaviour is not desired, *no_repartition* should be set to true. If *no_repartition* is false, an additional call of t8_forest_set_partition is not necessary. ### Prototype ```c -t8_shmem_array_t t8_cmesh_offset_percent (t8_cmesh_t cmesh, sc_MPI_Comm comm, int percent); +void t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_repartition); ``` """ -function t8_cmesh_offset_percent(cmesh, comm, percent) - @ccall libt8.t8_cmesh_offset_percent(cmesh::t8_cmesh_t, comm::MPI_Comm, percent::Cint)::t8_shmem_array_t +function t8_forest_set_balance(forest, set_from, no_repartition) + @ccall libt8.t8_forest_set_balance(forest::t8_forest_t, set_from::t8_forest_t, no_repartition::Cint)::Cvoid end """ - t8_stash_class + t8_forest_set_ghost(forest, do_ghost, ghost_type) -The eclass information that is stored before a cmesh is committed. +Enable or disable the creation of a layer of ghost elements. On default no ghosts are created. -| Field | Note | -| :----- | :----------------------- | -| id | The global tree id | -| eclass | The eclass of that tree | +# Arguments +* `forest`:\\[in\\] The forest. +* `do_ghost`:\\[in\\] If non-zero a ghost layer will be created. +* `ghost_type`:\\[in\\] Controls which neighbors count as ghost elements, currently only T8\\_GHOST\\_FACES is supported. This value is ignored if *do_ghost* = 0. +### Prototype +```c +void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type); +``` """ -struct t8_stash_class - id::t8_gloidx_t - eclass::t8_eclass_t +function t8_forest_set_ghost(forest, do_ghost, ghost_type) + @ccall libt8.t8_forest_set_ghost(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t)::Cvoid end -"""The eclass information that is stored before a cmesh is committed.""" -const t8_stash_class_struct_t = t8_stash_class - """ - t8_stash_joinface + t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) + +Like t8_forest_set_ghost but with the additional options to change the ghost algorithm. This is used for debugging and timing the algorithm. An application should almost always use t8_forest_set_ghost. -The face-connection information that is stored before a cmesh is committed. +# Arguments +* `forest`:\\[in\\] The forest. +* `do_ghost`:\\[in\\] If non-zero a ghost layer will be created. +* `ghost_type`:\\[in\\] Controls which neighbors count as ghost elements, currently only T8\\_GHOST\\_FACES is supported. This value is ignored if *do_ghost* = 0. +* `ghost_version`:\\[in\\] If 1, the iterative ghost algorithm for balanced forests is used. If 2, the iterative algorithm for unbalanced forests. If 3, the top-down search algorithm for unbalanced forests. +# See also +[`t8_forest_set_ghost`](@ref) -| Field | Note | -| :---------- | :------------------------------------------------------------------------- | -| id1 | The global tree id of the first tree in the connection. | -| id2 | The global tree id of the second tree. We ensure id1<=id2. | -| face1 | The face number of the first of the connected faces. | -| face2 | The face number of the second face. | -| orientation | The orientation of the face connection. # See also t8\\_cmesh\\_types.h. | +### Prototype +```c +void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); +``` """ -struct t8_stash_joinface - id1::t8_gloidx_t - id2::t8_gloidx_t - face1::Cint - face2::Cint - orientation::Cint +function t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) + @ccall libt8.t8_forest_set_ghost_ext(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t, ghost_version::Cint)::Cvoid end -"""The face-connection information that is stored before a cmesh is committed.""" -const t8_stash_joinface_struct_t = t8_stash_joinface - """ - t8_stash_attribute + t8_forest_set_load(forest, filename) + +Use assertions and document that the forest\\_set (..., from) and set\\_load are mutually exclusive. -The attribute information that is stored before a cmesh is committed. The pair (package\\_id, key) serves as a lookup key to identify the data. +TODO: Unused function -> remove? -| Field | Note | -| :----------- | :---------------------------------------------------------------------- | -| id | The global tree id | -| attr\\_size | The size (in bytes) of this attribute | -| attr\\_data | Array of *size* bytes storing the attributes data. | -| is\\_owned | True if the data was copied, false if the data is still owned by user. | -| package\\_id | The id of the package that set this attribute. | -| key | The key used by the package to identify this attribute. | +### Prototype +```c +void t8_forest_set_load (t8_forest_t forest, const char *filename); +``` """ -struct t8_stash_attribute - id::t8_gloidx_t - attr_size::Csize_t - attr_data::Ptr{Cvoid} - is_owned::Cint - package_id::Cint - key::Cint +function t8_forest_set_load(forest, filename) + @ccall libt8.t8_forest_set_load(forest::t8_forest_t, filename::Cstring)::Cvoid end -"""The attribute information that is stored before a cmesh is committed. The pair (package\\_id, key) serves as a lookup key to identify the data.""" -const t8_stash_attribute_struct_t = t8_stash_attribute - -"""The stash data structure is used to store information about the cmesh before it is committed. In particular we store the eclasses of the trees, the face-connections and the tree attributes. Using the stash structure allows us to have a very flexible interface. When constructing a new mesh, the user can specify all these mesh entities in arbitrary order. As soon as the cmesh is committed the information is copied from the stash to the cmesh in an order mannered.""" -const t8_stash_struct_t = t8_stash - """ - t8_stash_init(pstash) + t8_forest_comm_global_num_leaf_elements(forest) -Initialize a stash data structure. +Compute the global number of leaf elements in a forest as the sum of the local leaf element counts. # Arguments -* `pstash`:\\[in,out\\] A pointer to the stash to be initialized. +* `forest`:\\[in\\] The forest. ### Prototype ```c -void t8_stash_init (t8_stash_t *pstash); +void t8_forest_comm_global_num_leaf_elements (t8_forest_t forest); ``` """ -function t8_stash_init(pstash) - @ccall libt8.t8_stash_init(pstash::Ptr{t8_stash_t})::Cvoid +function t8_forest_comm_global_num_leaf_elements(forest) + @ccall libt8.t8_forest_comm_global_num_leaf_elements(forest::t8_forest_t)::Cvoid end """ - t8_stash_destroy(pstash) + t8_forest_commit(forest) -Free all memory associated in a stash structure. +After allocating and adding properties to a forest, commit the changes. This call sets up the internal state of the forest. # Arguments -* `pstash`:\\[in,out\\] A pointer to the stash to be destroyed. The pointer is set to NULL after the function call. +* `forest`:\\[in,out\\] Must be created with t8_forest_init and specialized with t8\\_forest\\_set\\_* calls first. ### Prototype ```c -void t8_stash_destroy (t8_stash_t *pstash); +void t8_forest_commit (t8_forest_t forest); ``` """ -function t8_stash_destroy(pstash) - @ccall libt8.t8_stash_destroy(pstash::Ptr{t8_stash_t})::Cvoid +function t8_forest_commit(forest) + @ccall libt8.t8_forest_commit(forest::t8_forest_t)::Cvoid end """ - t8_stash_add_class(stash, id, eclass) + t8_forest_get_maxlevel(forest) -Set the eclass of a tree. +Return the maximum allowed refinement level for any element in a forest. # Arguments -* `stash`:\\[in,out\\] The stash to be updated. -* `id`:\\[in\\] The global id of the tree whose eclass should be set. -* `eclass`:\\[in\\] The eclass of tree with id *id*. +* `forest`:\\[in\\] A forest. +# Returns +The maximum level of refinement that is allowed for an element in this forest. It is guaranteed that any tree in *forest* can be refined this many times and it is not allowed to refine further. *forest* must be committed before calling this function. For forest with a single element class (non-hybrid) maxlevel is the maximum refinement level of this element class, whilst for hybrid forests the maxlevel is the minimum of all maxlevels of the element classes in this forest. ### Prototype ```c -void t8_stash_add_class (t8_stash_t stash, t8_gloidx_t id, t8_eclass_t eclass); +int t8_forest_get_maxlevel (const t8_forest_t forest); ``` """ -function t8_stash_add_class(stash, id, eclass) - @ccall libt8.t8_stash_add_class(stash::t8_stash_t, id::t8_gloidx_t, eclass::t8_eclass_t)::Cvoid +function t8_forest_get_maxlevel(forest) + @ccall libt8.t8_forest_get_maxlevel(forest::t8_forest_t)::Cint end """ - t8_stash_add_facejoin(stash, gid1, gid2, face1, face2, orientation) + t8_forest_get_local_num_leaf_elements(forest) -Add a face connection to a stash. +Return the number of process local leaf elements in the forest. # Arguments -* `stash`:\\[in,out\\] The stash to be updated. -* `id1`:\\[in\\] The global id of the first tree. -* `id2`:\\[in\\] The global id of the second tree, -* `face1`:\\[in\\] The face number of the face of the first tree. -* `face2`:\\[in\\] The face number of the face of the second tree. -* `orientation`:\\[in\\] The orientation of the faces to each other. +* `forest`:\\[in\\] A forest. +# Returns +The number of leaf elements on this process in *forest*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_stash_add_facejoin (t8_stash_t stash, t8_gloidx_t gid1, t8_gloidx_t gid2, int face1, int face2, int orientation); +t8_locidx_t t8_forest_get_local_num_leaf_elements (const t8_forest_t forest); ``` """ -function t8_stash_add_facejoin(stash, gid1, gid2, face1, face2, orientation) - @ccall libt8.t8_stash_add_facejoin(stash::t8_stash_t, gid1::t8_gloidx_t, gid2::t8_gloidx_t, face1::Cint, face2::Cint, orientation::Cint)::Cvoid +function t8_forest_get_local_num_leaf_elements(forest) + @ccall libt8.t8_forest_get_local_num_leaf_elements(forest::t8_forest_t)::t8_locidx_t end """ - t8_stash_class_sort(stash) + t8_forest_get_global_num_leaf_elements(forest) -Sort the entries in the class array by the order given in the enum definition of [`t8_eclass`](@ref). +Return the number of global leaf elements in the forest. # Arguments -* `stash`:\\[in,out\\] The stash whose class array is sorted. +* `forest`:\\[in\\] A forest. +# Returns +The number of leaf elements (summed over all processes) in *forest*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_stash_class_sort (t8_stash_t stash); +t8_gloidx_t t8_forest_get_global_num_leaf_elements (const t8_forest_t forest); ``` """ -function t8_stash_class_sort(stash) - @ccall libt8.t8_stash_class_sort(stash::t8_stash_t)::Cvoid +function t8_forest_get_global_num_leaf_elements(forest) + @ccall libt8.t8_forest_get_global_num_leaf_elements(forest::t8_forest_t)::t8_gloidx_t end """ - t8_stash_class_bsearch(stash, tree_id) + t8_forest_get_num_ghosts(forest) -Search for an entry with a given tree index in the class-stash. The stash must be sorted beforehand. +Return the number of ghost elements of a forest. # Arguments -* `stash`:\\[in\\] The stash to be searched for. -* `tree_id`:\\[in\\] The global tree id. +* `forest`:\\[in\\] The forest. # Returns -The index of an element in the classes array of *stash* corresponding to *tree_id*. -1 if not found. +The number of ghost elements stored in the ghost structure of *forest*. 0 if no ghosts were constructed. +# See also +[`t8_forest_set_ghost`](@ref) *forest* must be committed before calling this function. + ### Prototype ```c -ssize_t t8_stash_class_bsearch (t8_stash_t stash, t8_gloidx_t tree_id); +t8_locidx_t t8_forest_get_num_ghosts (const t8_forest_t forest); ``` """ -function t8_stash_class_bsearch(stash, tree_id) - @ccall libt8.t8_stash_class_bsearch(stash::t8_stash_t, tree_id::t8_gloidx_t)::Cssize_t +function t8_forest_get_num_ghosts(forest) + @ccall libt8.t8_forest_get_num_ghosts(forest::t8_forest_t)::t8_locidx_t end """ - t8_stash_joinface_sort(stash) + t8_forest_get_eclass(forest, ltreeid) -Sort then entries in the facejoin array in order of the first treeid. +Return the element class of a forest local tree. # Arguments -* `stash`:\\[in,out\\] The stash whose facejoin array is sorted. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree in *forest*. +# Returns +The element class of the tree *ltreeid*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_stash_joinface_sort (t8_stash_t stash); +t8_eclass_t t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_stash_joinface_sort(stash) - @ccall libt8.t8_stash_joinface_sort(stash::t8_stash_t)::Cvoid +function t8_forest_get_eclass(forest, ltreeid) + @ccall libt8.t8_forest_get_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t end """ - t8_stash_add_attribute(stash, id, package_id, key, size, attr, copy) + t8_forest_tree_is_local(forest, local_tree) -Add an attribute to a tree. +Check whether a given tree id belongs to a local tree in a forest. # Arguments -* `stash`:\\[in\\] The stash structure to be modified. -* `id`:\\[in\\] The global index of the tree to which the attribute is added. -* `package_id`:\\[in\\] The unique id of the current package. -* `key`:\\[in\\] An integer value used to identify this attribute. -* `size`:\\[in\\] The size (in bytes) of the attribute. -* `attr`:\\[in\\] Points to *size* bytes of memory that should be stored as the attribute. -* `copy`:\\[in\\] If true the attribute data is copied from *attr* to an internal storage. If false only the pointer *attr* is stored and the data is only copied if the cmesh is committed. (More memory efficient). +* `forest`:\\[in\\] The forest. +* `local_tree`:\\[in\\] A tree id. +# Returns +True if and only if the id *local_tree* belongs to a local tree of *forest*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_stash_add_attribute (t8_stash_t stash, t8_gloidx_t id, int package_id, int key, size_t size, void *const attr, int copy); +int t8_forest_tree_is_local (const t8_forest_t forest, const t8_locidx_t local_tree); ``` """ -function t8_stash_add_attribute(stash, id, package_id, key, size, attr, copy) - @ccall libt8.t8_stash_add_attribute(stash::t8_stash_t, id::t8_gloidx_t, package_id::Cint, key::Cint, size::Csize_t, attr::Ptr{Cvoid}, copy::Cint)::Cvoid +function t8_forest_tree_is_local(forest, local_tree) + @ccall libt8.t8_forest_tree_is_local(forest::t8_forest_t, local_tree::t8_locidx_t)::Cint end """ - t8_stash_get_attribute_size(stash, index) + t8_forest_get_local_id(forest, gtreeid) -Return the size (in bytes) of an attribute in the stash. +Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is not a local tree, a negative number is returned. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of a tree. # Returns -The size in bytes of the attribute. +The tree's local id in *forest*, if it is a local tree. A negative number if not. Ghosts trees are not considered as local. +# See also +[`t8_forest_get_local_or_ghost_id`](@ref) for ghost trees., https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -size_t t8_stash_get_attribute_size (t8_stash_t stash, size_t index); +t8_locidx_t t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); ``` """ -function t8_stash_get_attribute_size(stash, index) - @ccall libt8.t8_stash_get_attribute_size(stash::t8_stash_t, index::Csize_t)::Csize_t +function t8_forest_get_local_id(forest, gtreeid) + @ccall libt8.t8_forest_get_local_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t end """ - t8_stash_get_attribute(stash, index) + t8_forest_get_local_or_ghost_id(forest, gtreeid) -Return the pointer to an attribute in the stash. +Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is a ghost, then the local id is between num\\_local\\_trees and num\\_local\\_trees + num\\_ghost\\_trees. If the tree is neither a local tree nor a ghost tree, a negative number is returned. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of a tree. # Returns -A void pointer to the memory region where the attribute is stored. +The tree's local id in *forest*, if it is a local tree. num\\_local\\_trees + the ghosts id, if it is a ghost tree. A negative number if not. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing + ### Prototype ```c -void * t8_stash_get_attribute (t8_stash_t stash, size_t index); +t8_locidx_t t8_forest_get_local_or_ghost_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); ``` """ -function t8_stash_get_attribute(stash, index) - @ccall libt8.t8_stash_get_attribute(stash::t8_stash_t, index::Csize_t)::Ptr{Cvoid} +function t8_forest_get_local_or_ghost_id(forest, gtreeid) + @ccall libt8.t8_forest_get_local_or_ghost_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t end """ - t8_stash_get_attribute_tree_id(stash, index) + t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) + +Given the local id of a tree in a forest, compute the tree's local id in the associated cmesh. + +!!! note -Return the id of the tree a given attribute belongs to. + For forest local trees, this is the inverse function of t8_forest_cmesh_ltreeid_to_ltreeid. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree or ghost in the forest. # Returns -The tree id. +The local id of the tree in the cmesh associated with the forest. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -t8_gloidx_t t8_stash_get_attribute_tree_id (t8_stash_t stash, size_t index); +t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_stash_get_attribute_tree_id(stash, index) - @ccall libt8.t8_stash_get_attribute_tree_id(stash::t8_stash_t, index::Csize_t)::t8_gloidx_t +function t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) + @ccall libt8.t8_forest_ltreeid_to_cmesh_ltreeid(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - t8_stash_get_attribute_key(stash, index) + t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) + +Given the local id of a tree in the coarse mesh of a forest, compute the tree's local id in the forest. -Return the key of a given attribute. +!!! note + + For forest local trees, this is the inverse function of t8_forest_ltreeid_to_cmesh_ltreeid. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `lctreeid`:\\[in\\] The local id of a tree in the coarse mesh of *forest*. # Returns -The attribute's key. +The local id of the tree in the forest. -1 if the tree is not forest local. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -int t8_stash_get_attribute_key (t8_stash_t stash, size_t index); +t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, t8_locidx_t lctreeid); ``` """ -function t8_stash_get_attribute_key(stash, index) - @ccall libt8.t8_stash_get_attribute_key(stash::t8_stash_t, index::Csize_t)::Cint +function t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) + @ccall libt8.t8_forest_cmesh_ltreeid_to_ltreeid(forest::t8_forest_t, lctreeid::t8_locidx_t)::t8_locidx_t end """ - t8_stash_get_attribute_id(stash, index) + t8_forest_get_coarse_tree(forest, ltreeid) -Return the package\\_id of a given attribute. +Given the local id of a tree in a forest, return the coarse tree of the cmesh that corresponds to this tree. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree in the forest. # Returns -The attribute's package\\_id. +The coarse tree that matches the forest tree with local id *ltreeid*. ### Prototype ```c -int t8_stash_get_attribute_id (t8_stash_t stash, size_t index); +t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_stash_get_attribute_id(stash, index) - @ccall libt8.t8_stash_get_attribute_id(stash::t8_stash_t, index::Csize_t)::Cint +function t8_forest_get_coarse_tree(forest, ltreeid) + @ccall libt8.t8_forest_get_coarse_tree(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_ctree_t end """ - t8_stash_attribute_is_owned(stash, index) + t8_forest_element_is_leaf(forest, element, local_tree) + +Query whether a given element is a leaf in a forest. + +!!! note -Return true if an attribute in the stash is owned by the stash, that is, it was copied in the call to [`t8_stash_add_attribute`](@ref). Returns false if the attribute is not owned by the stash. + This does not query for ghost leaves. + +!!! note + + *forest* must be committed before calling this function. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `element`:\\[in\\] An element of a local tree in *forest*. +* `local_tree`:\\[in\\] A local tree id of *forest*. # Returns -True of false. +True (non-zero) if and only if *element* is a leaf in *local_tree* of *forest*. ### Prototype ```c -int t8_stash_attribute_is_owned (t8_stash_t stash, size_t index); +int t8_forest_element_is_leaf (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t local_tree); ``` """ -function t8_stash_attribute_is_owned(stash, index) - @ccall libt8.t8_stash_attribute_is_owned(stash::t8_stash_t, index::Csize_t)::Cint +function t8_forest_element_is_leaf(forest, element, local_tree) + @ccall libt8.t8_forest_element_is_leaf(forest::t8_forest_t, element::Ptr{t8_element_t}, local_tree::t8_locidx_t)::Cint end """ - t8_stash_attribute_sort(stash) + t8_forest_element_is_leaf_or_ghost(forest, element, local_tree, check_ghost) -Sort the attributes array of a stash in the order (treeid, packageid, key) * +Query whether a given element or a ghost is a leaf of a local or ghost tree in a forest. + +!!! note + + *forest* must be committed before calling this function. t8_forest_element_is_leaf t8_forest_element_is_ghost # Arguments -* `stash`:\\[in,out\\] The stash to be considered. +* `forest`:\\[in\\] The forest. +* `element`:\\[in\\] An element of a local tree in *forest*. +* `local_tree`:\\[in\\] A local tree id of *forest* or a ghost tree id +* `check_ghost`:\\[in\\] If true *element* is interpreted as a ghost element and *local_tree* as the id of a ghost tree (0 <= *local_tree* < num\\_ghost\\_trees). If false *element* is interpreted as an element and *local_tree* as the id of a local tree (0 <= *local_tree* < num\\_local\\_trees). +# Returns +True (non-zero) if and only if *element* is a leaf (or ghost) in *local_tree* of *forest*. ### Prototype ```c -void t8_stash_attribute_sort (t8_stash_t stash); +int t8_forest_element_is_leaf_or_ghost (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t local_tree, const int check_ghost); ``` """ -function t8_stash_attribute_sort(stash) - @ccall libt8.t8_stash_attribute_sort(stash::t8_stash_t)::Cvoid +function t8_forest_element_is_leaf_or_ghost(forest, element, local_tree, check_ghost) + @ccall libt8.t8_forest_element_is_leaf_or_ghost(forest::t8_forest_t, element::Ptr{t8_element_t}, local_tree::t8_locidx_t, check_ghost::Cint)::Cint end """ - t8_stash_bcast(stash, root, comm, elem_counts) + t8_forest_leaf_face_orientation(forest, ltreeid, scheme, leaf, face) + +Compute the leaf face orientation at given face in a forest. +For more information about the encoding of face orientation refer to t8_cmesh_get_face_neighbor. + +# Arguments +* `forest`:\\[in\\] The forest. Must have a valid ghost layer. +* `ltreeid`:\\[in\\] A local tree id. +* `scheme`:\\[in\\] The eclass scheme of the element. +* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. +* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +# Returns +Face orientation encoded as integer. ### Prototype ```c -t8_stash_t t8_stash_bcast (t8_stash_t stash, int root, sc_MPI_Comm comm, const size_t elem_counts[3]); +int t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_scheme_c *scheme, const t8_element_t *leaf, const int face); ``` """ -function t8_stash_bcast(stash, root, comm, elem_counts) - @ccall libt8.t8_stash_bcast(stash::t8_stash_t, root::Cint, comm::MPI_Comm, elem_counts::Ptr{Csize_t})::t8_stash_t +function t8_forest_leaf_face_orientation(forest, ltreeid, scheme, leaf, face) + @ccall libt8.t8_forest_leaf_face_orientation(forest::t8_forest_t, ltreeid::t8_locidx_t, scheme::Ptr{t8_scheme_c}, leaf::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_stash_is_equal(stash_a, stash_b) + t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass) + +Compute the leaf face neighbors of a forest leaf element or ghost leaf. + +!!! note -Check two stashes for equal content and return true if so. + If there are no face neighbors, then *pneighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. + +!!! note + + *forest* must be committed before calling this function. + +!!! note + + If *forest* does not have a ghost layer then leaf elements at the process boundaries have 0 neighbors along the boundary face. (The function output for leaf elements then depends on the parallel partition.) + +!!! note + + Important! This routine allocates memory which must be freed. Do it like this: + +if (num\\_neighbors > 0) { [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } # Arguments -* `stash_a`:\\[in\\] The first stash to be considered. -* `stash_b`:\\[in\\] The first stash to be considered. -# Returns -True if both stashes hold copies of the same data. False otherwise. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] A local tree id (could also be a ghost tree). 0 <= *ltreeid* < num\\_local trees+num\\_ghost\\_trees +* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. +* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. +* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. +* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. +* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. +* `pneigh_eclass`:\\[out\\] On output the eclass of the neighbor elements. ### Prototype ```c -int t8_stash_is_equal (t8_stash_t stash_a, t8_stash_t stash_b); +void t8_forest_leaf_face_neighbors (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *leaf, const t8_element_t **pneighbor_leaves[], const int face, int *dual_faces[], int *num_neighbors, t8_locidx_t **pelement_indices, t8_eclass_t *pneigh_eclass); ``` """ -function t8_stash_is_equal(stash_a, stash_b) - @ccall libt8.t8_stash_is_equal(stash_a::t8_stash_t, stash_b::t8_stash_t)::Cint +function t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass) + @ccall libt8.t8_forest_leaf_face_neighbors(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf::Ptr{t8_element_t}, pneighbor_leaves::Ptr{Ptr{Ptr{t8_element_t}}}, face::Cint, dual_faces::Ptr{Ptr{Cint}}, num_neighbors::Ptr{Cint}, pelement_indices::Ptr{Ptr{t8_locidx_t}}, pneigh_eclass::Ptr{t8_eclass_t})::Cvoid end """ - t8_attribute_info + t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf_or_ghost, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass, gneigh_tree, orientation) -This structure holds the information associated to an attribute of a tree. The attributes of each are stored in a key-value storage, where the key consists of the two entries (package\\_id,key) both being integers. The package\\_id serves to identify the application layer that added the attribute and the key identifies the attribute within that application layer. - -All attribute info objects of one tree are stored in an array and adding a tree's att\\_offset entry to the tree's address yields this array. The attributes themselves are stored in an array directly behind the array of the attribute infos. -""" -struct t8_attribute_info - package_id::Cint - key::Cint - attribute_offset::Csize_t - attribute_size::Csize_t -end +Like t8_forest_leaf_face_neighbors but also provides information about the global neighbors and the orientation. -""" -This structure holds the information associated to an attribute of a tree. The attributes of each are stored in a key-value storage, where the key consists of the two entries (package\\_id,key) both being integers. The package\\_id serves to identify the application layer that added the attribute and the key identifies the attribute within that application layer. +!!! note -All attribute info objects of one tree are stored in an array and adding a tree's att\\_offset entry to the tree's address yields this array. The attributes themselves are stored in an array directly behind the array of the attribute infos. -""" -const t8_attribute_info_struct_t = t8_attribute_info + If there are no face neighbors, then *pneighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. -""" - t8_trees_glo_lo_hash_t +!!! note -This struct is an entry of the trees global\\_id to local\\_id hash table for ghost trees. + *forest* must be committed before calling this function. -| Field | Note | -| :---------- | :------------- | -| global\\_id | The global id | -| local\\_id | The local id | -""" -struct t8_trees_glo_lo_hash_t - global_id::t8_gloidx_t - local_id::t8_locidx_t -end +!!! note -""" - t8_cmesh_trees_init(ptrees, num_procs, num_trees, num_ghosts) + Important! This routine allocates memory which must be freed. Do it like this: -Initialize a trees structure and allocate its parts. This function allocates the from\\_procs array without filling it, it also allocates the tree\\_to\\_proc and ghost\\_to\\_proc arrays. No memory for trees or ghosts is allocated. +if (num\\_neighbors > 0) { [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } # Arguments -* `[in,ou`: ptrees The trees structure to be initialized. -* `num_procs`:\\[in\\] The number of entries of its from\\_proc array (can be different for each process). -* `num_trees`:\\[in\\] The number of trees that will be stored in this structure. -* `num_ghosts`:\\[in\\] The number of ghosts that will be stored in this structure. +* `forest`:\\[in\\] The forest. Must have a valid ghost layer. +* `ltreeid`:\\[in\\] A local tree id (could also be a ghost tree). 0 <= *ltreeid* < num\\_local trees+num\\_ghost\\_trees +* `leaf_or_ghost`:\\[in\\] A leaf or ghost leaf element in tree *ltreeid* of *forest*. +* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. +* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. +* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. +* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. +* `pneigh_eclass`:\\[out\\] On output the eclass of the neighbor elements. +* `gneigh_tree`:\\[out\\] The global tree IDs of the neighbor trees. +* `orientation`:\\[out\\] If not NULL on input, the face orientation is computed and stored here. Thus, if the face connection is an inter-tree connection the orientation of the tree-to-tree connection is stored. Otherwise, the value 0 is stored. All other parameters and behavior are identical to t8_forest_leaf_face_neighbors. ### Prototype ```c -void t8_cmesh_trees_init (t8_cmesh_trees_t *ptrees, int num_procs, t8_locidx_t num_trees, t8_locidx_t num_ghosts); +void t8_forest_leaf_face_neighbors_ext (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *leaf_or_ghost, const t8_element_t **pneighbor_leaves[], const int face, int *dual_faces[], int *num_neighbors, t8_locidx_t **pelement_indices, t8_eclass_t *pneigh_eclass, t8_gloidx_t *gneigh_tree, int *orientation); ``` """ -function t8_cmesh_trees_init(ptrees, num_procs, num_trees, num_ghosts) - @ccall libt8.t8_cmesh_trees_init(ptrees::Ptr{t8_cmesh_trees_t}, num_procs::Cint, num_trees::t8_locidx_t, num_ghosts::t8_locidx_t)::Cvoid -end - -struct t8_part_tree - first_tree::Cstring - first_tree_id::t8_locidx_t - first_ghost_id::t8_locidx_t - num_trees::t8_locidx_t - num_ghosts::t8_locidx_t +function t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf_or_ghost, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass, gneigh_tree, orientation) + @ccall libt8.t8_forest_leaf_face_neighbors_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf_or_ghost::Ptr{t8_element_t}, pneighbor_leaves::Ptr{Ptr{Ptr{t8_element_t}}}, face::Cint, dual_faces::Ptr{Ptr{Cint}}, num_neighbors::Ptr{Cint}, pelement_indices::Ptr{Ptr{t8_locidx_t}}, pneigh_eclass::Ptr{t8_eclass_t}, gneigh_tree::Ptr{t8_gloidx_t}, orientation::Ptr{Cint})::Cvoid end """ -` t8_cmesh_types.h` + t8_forest_same_level_leaf_face_neighbor_index(forest, element_index, face_index, global_treeid, dual_face) -We define here the datatypes needed for internal cmesh routines. -""" -const t8_part_tree_t = Ptr{t8_part_tree} +Given a leaf element or ghost index in "all local elements + ghosts" enumeration compute the index of the face neighbor of the element - provided that only one or no face neighbors exists. HANDLE WITH CARE. DO NOT CALL IF THE FOREST IS NOT UNIFORM. -""" - t8_cmesh_trees_get_part(trees, proc) +!!! note -Return one part of a specified tree array. + Do not call if you are unsure about the number of face neighbors. In particular if the forest is not uniform. # Arguments -* `trees`:\\[in\\] The tree array to be queried -* `proc`:\\[in\\] An index specifying the part to be returned. +* `forest`:\\[in\\] The forest. Must be committed. +* `element_index`:\\[in\\] Index of an element in *forest*. Must have only one or no facen neighbors across the given face. 0 <= *element_index* < num\\_local\\_elements + num\\_ghosts +* `face_index`:\\[in\\] Index of a face of *element*. +* `global_treeid`:\\[in\\] Global index of the tree that contains *element*. +* `dual_face`:\\[out\\] Return value, the dual\\_face index of the face neighbor. # Returns -The part number *proc* of *trees*. +The index of the face neighbor leaf (local element or ghost). ### Prototype ```c -t8_part_tree_t t8_cmesh_trees_get_part (const t8_cmesh_trees_t trees, const int proc); +t8_locidx_t t8_forest_same_level_leaf_face_neighbor_index (const t8_forest_t forest, const t8_locidx_t element_index, const int face_index, const t8_gloidx_t global_treeid, int *dual_face); ``` """ -function t8_cmesh_trees_get_part(trees, proc) - @ccall libt8.t8_cmesh_trees_get_part(trees::t8_cmesh_trees_t, proc::Cint)::t8_part_tree_t +function t8_forest_same_level_leaf_face_neighbor_index(forest, element_index, face_index, global_treeid, dual_face) + @ccall libt8.t8_forest_same_level_leaf_face_neighbor_index(forest::t8_forest_t, element_index::t8_locidx_t, face_index::Cint, global_treeid::t8_gloidx_t, dual_face::Ptr{Cint})::t8_locidx_t end """ - t8_cmesh_trees_start_part(trees, proc, lfirst_tree, num_trees, lfirst_ghost, num_ghosts, alloc) + t8_forest_leaf_neighbor_subface(forest, ltreeid, leaf, face, neighbor_tree_class, neighbor_leaf, neighbor_face) -Allocate the first\\_tree array of a given tree\\_part in a tree struct with a given number of trees and ghosts. This function allocates the memory for the trees and the ghosts but not for their face neighbor entries or attributes. These must be allocated later when the eclasses of the trees and ghosts are known t8_cmesh_trees_finish_part. +Compute the subface index for a coarser neighbor + +\\pre *leaf* and *neighbor_leaf* must be a face neighbors. The common face must correspond to *face* for *leaf* and *neighbor_face* for *neighbor_leaf* respectively. *neighbor_leaf* must be one level coarser than *leaf*. Otherwise the behavior is undefined. + +!!! note + + This function is designed to be called after t8_forest_leaf_face_neighbors_ext to complement its output. It is primarily intended for balanced forests, but can be used on any committed forest as long as the preconditions hold (i.e. the forest must be ''locally balanced''). # Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `proc`:\\[in\\] The index of the part to be updated. -* `lfirst_tree`:\\[in\\] The local id of the first tree of that part. -* `num_trees`:\\[in\\] The number of trees of that part. -* `lfirst_ghost`:\\[in\\] The local id of the first ghost of that part. -* `num_ghosts`:\\[in\\] The number of ghosts of that part. -* `alloc`:\\[in\\] If true then the first\\_tree array is allocated for the number of trees and ghosts. When a cmesh is copied we do not want this, so in we pass alloc = 0 then. +* `forest`:\\[in\\] The forest. Must be committed. +* `ltreeid`:\\[in\\] A local tree id. +* `leaf`:\\[in\\] A leaf in *ltreeid*. +* `face`:\\[in\\] The face index of *leaf* to consider. +* `neighbor_tree_class`:\\[in\\] The eclass of the neighbor element. +* `neighbor_leaf`:\\[in\\] The leaf of *forest* on the other side of the face of index *face* of element *leaf*. +* `neighbor_face`:\\[in\\] The face index of *neighbor_leaf* (i.e. the dual face of *face*). +# Returns +The index of the subface of *neighbor_face* which corresponds to *face*. ### Prototype ```c -void t8_cmesh_trees_start_part (t8_cmesh_trees_t trees, int proc, t8_locidx_t lfirst_tree, t8_locidx_t num_trees, t8_locidx_t lfirst_ghost, t8_locidx_t num_ghosts, int alloc); +int t8_forest_leaf_neighbor_subface (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, int face, t8_eclass_t neighbor_tree_class, const t8_element_t *neighbor_leaf, int neighbor_face); ``` """ -function t8_cmesh_trees_start_part(trees, proc, lfirst_tree, num_trees, lfirst_ghost, num_ghosts, alloc) - @ccall libt8.t8_cmesh_trees_start_part(trees::t8_cmesh_trees_t, proc::Cint, lfirst_tree::t8_locidx_t, num_trees::t8_locidx_t, lfirst_ghost::t8_locidx_t, num_ghosts::t8_locidx_t, alloc::Cint)::Cvoid +function t8_forest_leaf_neighbor_subface(forest, ltreeid, leaf, face, neighbor_tree_class, neighbor_leaf, neighbor_face) + @ccall libt8.t8_forest_leaf_neighbor_subface(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf::Ptr{t8_element_t}, face::Cint, neighbor_tree_class::t8_eclass_t, neighbor_leaf::Ptr{t8_element_t}, neighbor_face::Cint)::Cint end """ - t8_cmesh_trees_finish_part(trees, proc) + t8_forest_ghost_exchange_data(forest, element_data) -After all classes of trees and ghosts have been set and after the number of tree attributes was set and their total size (per tree) stored temporarily in the att\\_offset variable we grow the part array by the needed amount of memory and set the offsets appropriately. The workflow should be: call t8_cmesh_trees_start_part, set tree and ghost classes maually via t8_cmesh_trees_add_tree and t8_cmesh_trees_add_ghost, call t8_cmesh_trees_init_attributes, then call this function. Afterwards successively call t8_cmesh_trees_add_attribute for each attribute and also set all face neighbors (TODO: write function). +Exchange ghost information of user defined element data. + +!!! note + + This function is collective and hence must be called by all processes in the forest's MPI Communicator. # Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `proc`:\\[in\\] The number of the part to be finished. +* `forest`:\\[in\\] The forest. Must be committed. +* `element_data`:\\[in\\] An array of length num\\_local\\_elements + num\\_ghosts storing one value for each local element and ghost in *forest*. After calling this function the entries for the ghost elements are update with the entries in the *element_data* array of the corresponding owning process. ### Prototype ```c -void t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc); +void t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data); ``` """ -function t8_cmesh_trees_finish_part(trees, proc) - @ccall libt8.t8_cmesh_trees_finish_part(trees::t8_cmesh_trees_t, proc::Cint)::Cvoid +function t8_forest_ghost_exchange_data(forest, element_data) + @ccall libt8.t8_forest_ghost_exchange_data(forest::t8_forest_t, element_data::Ptr{sc_array_t})::Cvoid end """ - t8_cmesh_trees_copy_toproc(trees_dest, trees_src, lnum_trees, lnum_ghosts) + t8_forest_ghost_print(forest) -Copy the tree\\_to\\_proc and ghost\\_to\\_proc arrays of one tree structure to another one. +Print the ghost structure of a forest. Only used for debugging. -# Arguments -* `trees_dest`:\\[in,out\\] The destination trees structure. -* `trees_src`:\\[in\\] The source trees structure. -* `lnum_trees`:\\[in\\] The total number of trees stored in *trees_src*. -* `lnum_ghosts`:\\[in\\] The total number of ghosts stored in *trees_src*. ### Prototype ```c -void t8_cmesh_trees_copy_toproc (t8_cmesh_trees_t trees_dest, t8_cmesh_trees_t trees_src, t8_locidx_t lnum_trees, t8_locidx_t lnum_ghosts); +void t8_forest_ghost_print (t8_forest_t forest); ``` """ -function t8_cmesh_trees_copy_toproc(trees_dest, trees_src, lnum_trees, lnum_ghosts) - @ccall libt8.t8_cmesh_trees_copy_toproc(trees_dest::t8_cmesh_trees_t, trees_src::t8_cmesh_trees_t, lnum_trees::t8_locidx_t, lnum_ghosts::t8_locidx_t)::Cvoid +function t8_forest_ghost_print(forest) + @ccall libt8.t8_forest_ghost_print(forest::t8_forest_t)::Cvoid end """ - t8_cmesh_trees_copy_part(trees_dest, part_dest, trees_src, part_src) - -Copy the trees array from one part to another. + t8_forest_partition_cmesh(forest, comm, set_profiling) -# Arguments -* `trees_dest`:\\[in,out\\] The trees struct of the destination part. -* `part_dest`:\\[in\\] The index of the destination part. Must be initialized by t8_cmesh_trees_start_part with alloc = 0. -* `trees_src`:\\[in\\] The trees struct of the source part. -* `part_src`:\\[in\\] The index of the destination part. Must be a valid part, thus t8_cmesh_trees_finish_part must have been called. ### Prototype ```c -void t8_cmesh_trees_copy_part (t8_cmesh_trees_t trees_dest, int part_dest, t8_cmesh_trees_t trees_src, int part_src); +void t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profiling); ``` """ -function t8_cmesh_trees_copy_part(trees_dest, part_dest, trees_src, part_src) - @ccall libt8.t8_cmesh_trees_copy_part(trees_dest::t8_cmesh_trees_t, part_dest::Cint, trees_src::t8_cmesh_trees_t, part_src::Cint)::Cvoid +function t8_forest_partition_cmesh(forest, comm, set_profiling) + @ccall libt8.t8_forest_partition_cmesh(forest::t8_forest_t, comm::MPI_Comm, set_profiling::Cint)::Cvoid end """ - t8_cmesh_trees_add_tree(trees, ltree_id, proc, eclass) - -Add a tree to a trees structure. + t8_forest_get_mpicomm(forest) -# Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `tree_id`:\\[in\\] The local id of the tree to be inserted. -* `proc`:\\[in\\] The mpirank of the process from which the tree was received. -* `eclass`:\\[in\\] The tree's element class. ### Prototype ```c -void t8_cmesh_trees_add_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, int proc, t8_eclass_t eclass); +sc_MPI_Comm t8_forest_get_mpicomm (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_add_tree(trees, ltree_id, proc, eclass) - @ccall libt8.t8_cmesh_trees_add_tree(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, proc::Cint, eclass::t8_eclass_t)::Cvoid +function t8_forest_get_mpicomm(forest) + @ccall libt8.t8_forest_get_mpicomm(forest::t8_forest_t)::MPI_Comm end """ - t8_cmesh_trees_add_ghost(trees, lghost_index, gtree_id, proc, eclass, num_local_trees) + t8_forest_get_first_local_tree_id(forest) -Add a ghost to a trees structure. +Return the global id of the first local tree of a forest. # Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `ghost_index`:\\[in\\] The index in the part array of the ghost to be inserted. -* `tree_id`:\\[in\\] The global index of the ghost. -* `proc`:\\[in\\] The mpirank of the process from which the ghost was received. -* `eclass`:\\[in\\] The ghost's element class. -* `num_local_trees`:\\[in\\] The number of local trees in the cmesh. +* `forest`:\\[in\\] The forest. +# Returns +The global id of the first local tree in *forest*. ### Prototype ```c -void t8_cmesh_trees_add_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost_index, t8_gloidx_t gtree_id, int proc, t8_eclass_t eclass, t8_locidx_t num_local_trees); +t8_gloidx_t t8_forest_get_first_local_tree_id (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_add_ghost(trees, lghost_index, gtree_id, proc, eclass, num_local_trees) - @ccall libt8.t8_cmesh_trees_add_ghost(trees::t8_cmesh_trees_t, lghost_index::t8_locidx_t, gtree_id::t8_gloidx_t, proc::Cint, eclass::t8_eclass_t, num_local_trees::t8_locidx_t)::Cvoid +function t8_forest_get_first_local_tree_id(forest) + @ccall libt8.t8_forest_get_first_local_tree_id(forest::t8_forest_t)::t8_gloidx_t end """ - t8_cmesh_trees_set_all_boundary(cmesh, trees) + t8_forest_get_num_local_trees(forest) -Set all neighbor fields of all local trees and ghosts to boundary. +Return the number of local trees of a given forest. # Arguments -* `cmesh,`:\\[in,out\\] The associated cmesh. -* `trees,`:\\[in,out\\] The trees structure. A face f of tree t counts as boundary if the face-neighbor is also t at face f. +* `forest`:\\[in\\] The forest. +# Returns +The number of local trees of that forest. ### Prototype ```c -void t8_cmesh_trees_set_all_boundary (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); +t8_locidx_t t8_forest_get_num_local_trees (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_set_all_boundary(cmesh, trees) - @ccall libt8.t8_cmesh_trees_set_all_boundary(cmesh::t8_cmesh_t, trees::t8_cmesh_trees_t)::Cvoid +function t8_forest_get_num_local_trees(forest) + @ccall libt8.t8_forest_get_num_local_trees(forest::t8_forest_t)::t8_locidx_t end """ - t8_cmesh_trees_get_part_data(trees, proc, first_tree, num_trees, first_ghost, num_ghosts) + t8_forest_get_num_ghost_trees(forest) + +Return the number of ghost trees of a given forest. +# Arguments +* `forest`:\\[in\\] The forest. +# Returns +The number of ghost trees of that forest. ### Prototype ```c -void t8_cmesh_trees_get_part_data (t8_cmesh_trees_t trees, int proc, t8_locidx_t *first_tree, t8_locidx_t *num_trees, t8_locidx_t *first_ghost, t8_locidx_t *num_ghosts); +t8_locidx_t t8_forest_get_num_ghost_trees (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_get_part_data(trees, proc, first_tree, num_trees, first_ghost, num_ghosts) - @ccall libt8.t8_cmesh_trees_get_part_data(trees::t8_cmesh_trees_t, proc::Cint, first_tree::Ptr{t8_locidx_t}, num_trees::Ptr{t8_locidx_t}, first_ghost::Ptr{t8_locidx_t}, num_ghosts::Ptr{t8_locidx_t})::Cvoid +function t8_forest_get_num_ghost_trees(forest) + @ccall libt8.t8_forest_get_num_ghost_trees(forest::t8_forest_t)::t8_locidx_t end """ - t8_cmesh_trees_get_tree(trees, ltree) + t8_forest_get_num_global_trees(forest) -Return a pointer to a specific tree in a trees struct. +Return the number of global trees of a given forest. # Arguments -* `trees`:\\[in\\] The tress structure where the tree is to be looked up. -* `ltree`:\\[in\\] The local id of the tree. +* `forest`:\\[in\\] The forest. # Returns -A pointer to the tree with local id *tree*. +The number of global trees of that forest. ### Prototype ```c -t8_ctree_t t8_cmesh_trees_get_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree); +t8_gloidx_t t8_forest_get_num_global_trees (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_get_tree(trees, ltree) - @ccall libt8.t8_cmesh_trees_get_tree(trees::t8_cmesh_trees_t, ltree::t8_locidx_t)::t8_ctree_t +function t8_forest_get_num_global_trees(forest) + @ccall libt8.t8_forest_get_num_global_trees(forest::t8_forest_t)::t8_gloidx_t end """ - t8_cmesh_trees_get_tree_ext(trees, ltree_id, face_neigh, ttf) + t8_forest_global_tree_id(forest, ltreeid) -Return a pointer to a specific tree in a trees struct plus pointers to its face\\_neighbor and tree\\_to\\_face arrays. +Return the global id of a local tree or a ghost tree. # Arguments -* `trees`:\\[in\\] The trees structure where the tree is to be looked up. -* `ltree_id`:\\[in\\] The local id of the tree. -* `face_neigh`:\\[out\\] If not NULL a pointer to the trees face\\_neighbor array is stored here on return. -* `ttf`:\\[out\\] If not NULL a pointer to the trees tree\\_to\\_face array is stored here on return. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] An id 0 <= *ltreeid* < num\\_local\\_trees + num\\_ghosts specifying a local tree or ghost tree. # Returns -A pointer to the tree with local id *tree*. +The global id corresponding to the tree with local id *ltreeid*. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -t8_ctree_t t8_cmesh_trees_get_tree_ext (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, t8_locidx_t **face_neigh, int8_t **ttf); +t8_gloidx_t t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_get_tree_ext(trees, ltree_id, face_neigh, ttf) - @ccall libt8.t8_cmesh_trees_get_tree_ext(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, face_neigh::Ptr{Ptr{t8_locidx_t}}, ttf::Ptr{Ptr{Int8}})::t8_ctree_t +function t8_forest_global_tree_id(forest, ltreeid) + @ccall libt8.t8_forest_global_tree_id(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_gloidx_t end """ - t8_cmesh_trees_get_face_info(trees, ltreeid, face, ttf) + t8_forest_get_tree(forest, ltree_id) -Return the face neighbor of a tree at a given face and return the tree\\_to\\_face info +Return a pointer to a tree in a forest. # Arguments -* `trees`:\\[in\\] The trees structure where the tree is to be looked up. -* `ltreeid`:\\[in\\] The local id of the tree. -* `face`:\\[in\\] A face of the tree. -* `ttf`:\\[out\\] If not NULL the tree\\_to\\_face value of the face connection. +* `forest`:\\[in\\] The forest. +* `ltree_id`:\\[in\\] The local id of the tree. # Returns -The face neighbor that is stored for this face +A pointer to the tree with local id *ltree_id*. *forest* must be committed before calling this function. ### Prototype ```c -t8_locidx_t t8_cmesh_trees_get_face_info (t8_cmesh_trees_t trees, t8_locidx_t ltreeid, int face, int8_t *ttf); +t8_tree_t t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id); ``` """ -function t8_cmesh_trees_get_face_info(trees, ltreeid, face, ttf) - @ccall libt8.t8_cmesh_trees_get_face_info(trees::t8_cmesh_trees_t, ltreeid::t8_locidx_t, face::Cint, ttf::Ptr{Int8})::t8_locidx_t +function t8_forest_get_tree(forest, ltree_id) + @ccall libt8.t8_forest_get_tree(forest::t8_forest_t, ltree_id::t8_locidx_t)::t8_tree_t end """ - t8_cmesh_trees_get_face_neighbor(tree, face) + t8_forest_get_tree_vertices(forest, ltreeid) -Given a coarse tree and a face number, return the local id of the neighbor tree. +Return a pointer to the vertex coordinates of a tree. # Arguments -* `tree.`:\\[in\\] The coarse tree. -* `face.`:\\[in\\] The face number. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The id of a local tree. # Returns -The local id of the neighbor tree. +If stored, a pointer to the vertex coordinates of *tree*. If no coordinates for this tree are found, NULL. ### Prototype ```c -t8_locidx_t t8_cmesh_trees_get_face_neighbor (const t8_ctree_t tree, const int face); +double * t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_get_face_neighbor(tree, face) - @ccall libt8.t8_cmesh_trees_get_face_neighbor(tree::t8_ctree_t, face::Cint)::t8_locidx_t +function t8_forest_get_tree_vertices(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_vertices(forest::t8_forest_t, ltreeid::t8_locidx_t)::Ptr{Cdouble} end """ - t8_cmesh_trees_get_face_neighbor_ext(tree, face, ttf) + t8_forest_tree_get_leaf_elements(forest, ltree_id) -Given a coarse tree and a face number, return the local id of the neighbor tree together with its tree-to-face info. +Return the array of leaf elements of a local tree in a forest. # Arguments -* `tree`:\\[in\\] The coarse tree. -* `face`:\\[in\\] The face number. -* `ttf`:\\[out\\] If not NULL it is filled with the tree-to-face value for this face. +* `forest`:\\[in\\] The forest. +* `ltree_id`:\\[in\\] The local id of a local tree of *forest*. # Returns -The local id of the neighbor tree. +An array of [`t8_element_t`](@ref) * storing all leaf elements of this tree. ### Prototype ```c -t8_locidx_t t8_cmesh_trees_get_face_neighbor_ext (const t8_ctree_t tree, const int face, int8_t *ttf); +t8_element_array_t * t8_forest_tree_get_leaf_elements (const t8_forest_t forest, const t8_locidx_t ltree_id); ``` """ -function t8_cmesh_trees_get_face_neighbor_ext(tree, face, ttf) - @ccall libt8.t8_cmesh_trees_get_face_neighbor_ext(tree::t8_ctree_t, face::Cint, ttf::Ptr{Int8})::t8_locidx_t +function t8_forest_tree_get_leaf_elements(forest, ltree_id) + @ccall libt8.t8_forest_tree_get_leaf_elements(forest::t8_forest_t, ltree_id::t8_locidx_t)::Ptr{t8_element_array_t} end """ - t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost, face, ttf) + t8_forest_get_cmesh(forest) -Given a coarse ghost and a face number, return the local id of the neighbor tree together with its tree-to-face info. +Return a cmesh associated to a forest. # Arguments -* `ghost`:\\[in\\] The coarse ghost. -* `face`:\\[in\\] The face number. -* `ttf`:\\[out\\] If not NULL it is filled with the tree-to-face value for this face. +* `forest`:\\[in\\] The forest. # Returns -The global id of the neighbor tree. +The cmesh associated to the forest. ### Prototype ```c -t8_gloidx_t t8_cmesh_trees_get_ghost_face_neighbor_ext (const t8_cghost_t ghost, const int face, int8_t *ttf); +t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); ``` """ -function t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost, face, ttf) - @ccall libt8.t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost::t8_cghost_t, face::Cint, ttf::Ptr{Int8})::t8_gloidx_t +function t8_forest_get_cmesh(forest) + @ccall libt8.t8_forest_get_cmesh(forest::t8_forest_t)::t8_cmesh_t end """ - t8_cmesh_trees_get_ghost(trees, lghost) + t8_forest_get_leaf_element(forest, lelement_id, ltreeid) -Return a pointer to a specific ghost in a trees struct. +Return a leaf element of the forest. + +!!! note + + This function performs a binary search. For constant access, use t8_forest_get_leaf_element_in_tree *forest* must be committed before calling this function. # Arguments -* `trees`:\\[in\\] The tress structure where the tree is to be looked up. -* `lghost`:\\[in\\] The local id of the ghost. +* `forest`:\\[in\\] The forest. +* `lelement_id`:\\[in\\] The local id of a leaf element in *forest*. +* `ltreeid`:\\[out\\] If not NULL, on output the local tree id of the tree in which the leaf element lies in. # Returns -A pointer to the ghost with local id *ghost*. +A pointer to the leaf element. NULL if this element does not exist. Ghost elements are not considered as local. +# See also +[`t8_forest_ghost_get_leaf_element`](@ref) to access ghost leaf elements. + ### Prototype ```c -t8_cghost_t t8_cmesh_trees_get_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost); +t8_element_t * t8_forest_get_leaf_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_locidx_t *ltreeid); ``` """ -function t8_cmesh_trees_get_ghost(trees, lghost) - @ccall libt8.t8_cmesh_trees_get_ghost(trees::t8_cmesh_trees_t, lghost::t8_locidx_t)::t8_cghost_t +function t8_forest_get_leaf_element(forest, lelement_id, ltreeid) + @ccall libt8.t8_forest_get_leaf_element(forest::t8_forest_t, lelement_id::t8_locidx_t, ltreeid::Ptr{t8_locidx_t})::Ptr{t8_element_t} end """ - t8_cmesh_trees_get_ghost_ext(trees, lghost_id, face_neigh, ttf) + t8_forest_get_leaf_element_in_tree(forest, ltreeid, leid_in_tree) + +Return a leaf element of a local tree in a forest. + +!!! note -Return a pointer to a specific ghost in a trees struct plus pointers to its face\\_neighbor and tree\\_to\\_face arrays. + If the tree id is know, this function should be preferred over t8_forest_get_leaf_element. *forest* must be committed before calling this function. # Arguments -* `trees`:\\[in\\] The trees structure where the ghost is to be looked up. -* `lghost_id`:\\[in\\] The local id of the ghost. -* `face_neigh`:\\[out\\] If not NULL a pointer to the ghosts face\\_neighbor array is stored here on return. -* `ttf`:\\[out\\] If not NULL a pointer to the ghosts tree\\_to\\_face array is stored here on return. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] An id of a local tree in the forest. Ghost trees are not considered local. +* `leid_in_tree`:\\[in\\] The index of a leaf element in the tree. # Returns -A pointer to the tree with local id *tree*. +A pointer to the leaf element. +# See also +t8\\_forest\\_ghost\\_get\\_leaf\\_element\\_in\\_tree to access ghost leaf elements. + ### Prototype ```c -t8_cghost_t t8_cmesh_trees_get_ghost_ext (t8_cmesh_trees_t trees, t8_locidx_t lghost_id, t8_gloidx_t **face_neigh, int8_t **ttf); +const t8_element_t * t8_forest_get_leaf_element_in_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t leid_in_tree); ``` """ -function t8_cmesh_trees_get_ghost_ext(trees, lghost_id, face_neigh, ttf) - @ccall libt8.t8_cmesh_trees_get_ghost_ext(trees::t8_cmesh_trees_t, lghost_id::t8_locidx_t, face_neigh::Ptr{Ptr{t8_gloidx_t}}, ttf::Ptr{Ptr{Int8}})::t8_cghost_t +function t8_forest_get_leaf_element_in_tree(forest, ltreeid, leid_in_tree) + @ccall libt8.t8_forest_get_leaf_element_in_tree(forest::t8_forest_t, ltreeid::t8_locidx_t, leid_in_tree::t8_locidx_t)::Ptr{t8_element_t} end """ - t8_cmesh_trees_get_ghost_local_id(trees, global_id) + t8_forest_get_tree_num_leaf_elements(forest, ltreeid) -Given the global tree id of a ghost tree in a trees structure, return its local ghost id. +Return the number of leaf elements of a tree. # Arguments -* `trees`:\\[in\\] The trees structure. -* `global_id`:\\[in\\] A global tree id. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] A local id of a tree. # Returns -The local id of the tree *global_id* if it is a ghost in *trees*. A negative number if it isn't. The local id is a number l with num\\_local\\_trees <= *l* < num\\_local\\_trees + num\\_ghosts +The number of leaf elements in the local tree *ltreeid*. ### Prototype ```c -t8_locidx_t t8_cmesh_trees_get_ghost_local_id (t8_cmesh_trees_t trees, t8_gloidx_t global_id); +t8_locidx_t t8_forest_get_tree_num_leaf_elements (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_get_ghost_local_id(trees, global_id) - @ccall libt8.t8_cmesh_trees_get_ghost_local_id(trees::t8_cmesh_trees_t, global_id::t8_gloidx_t)::t8_locidx_t +function t8_forest_get_tree_num_leaf_elements(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_num_leaf_elements(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - t8_cmesh_trees_size(trees) + t8_forest_get_tree_element_offset(forest, ltreeid) -### Prototype -```c -size_t t8_cmesh_trees_size (t8_cmesh_trees_t trees); -``` -""" -function t8_cmesh_trees_size(trees) - @ccall libt8.t8_cmesh_trees_size(trees::t8_cmesh_trees_t)::Csize_t -end +Return the element offset of a local tree, that is the number of leaf elements in all trees with smaller local treeid. -""" - t8_cmesh_trees_init_attributes(trees, ltree_id, num_attributes, attr_bytes) +!!! note -For one tree in a trees structure set the number of attributes and temporarily store the total size of all of this tree's attributes. This temporary value is used in t8_cmesh_trees_finish_part. + *forest* must be committed before calling this function. # Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `ltree_id`:\\[in\\] The local id of one tree in *trees*. -* `num_attributes`:\\[in\\] The number of attributes of this tree. -* `attr_bytes`:\\[in\\] The total number of bytes of all attributes of this tree. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] A local id of a tree. +# Returns +The number of leaf elements on all local tree with id < *ltreeid*. ### Prototype ```c -void t8_cmesh_trees_init_attributes (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, size_t num_attributes, size_t attr_bytes); +t8_locidx_t t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_init_attributes(trees, ltree_id, num_attributes, attr_bytes) - @ccall libt8.t8_cmesh_trees_init_attributes(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, num_attributes::Csize_t, attr_bytes::Csize_t)::Cvoid +function t8_forest_get_tree_element_offset(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_element_offset(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - t8_cmesh_trees_get_attribute(trees, ltree_id, package_id, key, size, is_ghost) + t8_forest_get_tree_leaf_element_count(tree) -Return an attribute that is stored at a tree. +Return the number of leaf elements of a tree. # Arguments -* `trees`:\\[in\\] The trees structure. -* `ltree_id`:\\[in\\] The local id of the tree whose attribute is querid. -* `package_id`:\\[in\\] The package identifier of the attribute. -* `key`:\\[in\\] The key of the attribute within all attributes of the same package identifier. -* `size`:\\[out\\] If not NULL, the size (in bytes) of the attribute will be stored here. -* `is_ghost`:\\[in\\] If true, then *ltree_id* is interpreted as the local\\_id of a ghost. +* `tree`:\\[in\\] A tree in a forest. # Returns -A pointer to the queried attribute, NULL if the attribute does not exist. +The number of leaf elements of that tree. ### Prototype ```c -void * t8_cmesh_trees_get_attribute (const t8_cmesh_trees_t trees, const t8_locidx_t ltree_id, const int package_id, const int key, size_t *size, int is_ghost); +t8_locidx_t t8_forest_get_tree_leaf_element_count (t8_tree_t tree); ``` """ -function t8_cmesh_trees_get_attribute(trees, ltree_id, package_id, key, size, is_ghost) - @ccall libt8.t8_cmesh_trees_get_attribute(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, package_id::Cint, key::Cint, size::Ptr{Csize_t}, is_ghost::Cint)::Ptr{Cvoid} +function t8_forest_get_tree_leaf_element_count(tree) + @ccall libt8.t8_forest_get_tree_leaf_element_count(tree::t8_tree_t)::t8_locidx_t end """ - t8_cmesh_trees_attribute_size(tree) + t8_forest_get_tree_class(forest, ltreeid) -Return the total size of all attributes stored at a specified tree. +Return the eclass of a tree in a forest. # Arguments -* `tree`:\\[in\\] A tree structure. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree (local or ghost) in *forest*. # Returns -The total size (in bytes) of the attributes of *tree*. +The element class of the tree with local id *ltreeid*. ### Prototype ```c -size_t t8_cmesh_trees_attribute_size (t8_ctree_t tree); +t8_eclass_t t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_attribute_size(tree) - @ccall libt8.t8_cmesh_trees_attribute_size(tree::t8_ctree_t)::Csize_t +function t8_forest_get_tree_class(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_class(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t end """ - t8_cmesh_trees_ghost_attribute_size(ghost) + t8_forest_get_first_local_leaf_element_id(forest) -Return the total size of all attributes stored at a specified ghost. +Compute the global index of the first local leaf element of a forest. This function is collective. # Arguments -* `ghost`:\\[in\\] A ghost structure. +* `forest`:\\[in\\] A committed forest, whose first leaf element's index is computed. # Returns -The total size (in bytes) of the attributes of *ghost*. +The global index of *forest*'s first local leaf element. Forest must be committed when calling this function. This function is collective and must be called on each process. ### Prototype ```c -size_t t8_cmesh_trees_ghost_attribute_size (t8_cghost_t ghost); +t8_gloidx_t t8_forest_get_first_local_leaf_element_id (t8_forest_t forest); ``` """ -function t8_cmesh_trees_ghost_attribute_size(ghost) - @ccall libt8.t8_cmesh_trees_ghost_attribute_size(ghost::t8_cghost_t)::Csize_t +function t8_forest_get_first_local_leaf_element_id(forest) + @ccall libt8.t8_forest_get_first_local_leaf_element_id(forest::t8_forest_t)::t8_gloidx_t end """ - t8_cmesh_trees_add_attribute(trees, proc, attr, tree_id, index) + t8_forest_get_scheme(forest) + +Return the element scheme associated to a forest. + +# Arguments +* `forest`:\\[in\\] A committed forest. +# Returns +The element scheme of the forest. +# See also +[`t8_forest_set_scheme`](@ref) ### Prototype ```c -void t8_cmesh_trees_add_attribute (const t8_cmesh_trees_t trees, int proc, const t8_stash_attribute_struct_t *attr, t8_locidx_t tree_id, size_t index); +const t8_scheme_c * t8_forest_get_scheme (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_add_attribute(trees, proc, attr, tree_id, index) - @ccall libt8.t8_cmesh_trees_add_attribute(trees::t8_cmesh_trees_t, proc::Cint, attr::Ptr{t8_stash_attribute_struct_t}, tree_id::t8_locidx_t, index::Csize_t)::Cvoid +function t8_forest_get_scheme(forest) + @ccall libt8.t8_forest_get_scheme(forest::t8_forest_t)::Ptr{t8_scheme_c} end """ - t8_cmesh_trees_add_ghost_attribute(trees, attr, local_ghost_id, ghosts_inserted, index) + t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) -Add the next ghost attribute from stash to the correct position in the char pointer structure Since it is created from stash, all attributes are added to part 0. The following attribute offset gets updated already. +Return the eclass of the tree in which a face neighbor of a given element or ghost lies. # Arguments -* `trees`:\\[in,out\\] The trees structure, whose char array is updated. -* `attr`:\\[in\\] The stash attribute that is added. -* `local_ghost_id`:\\[in\\] The local ghost id. -* `ghosts_inserted`:\\[in\\] The number of ghost that were already inserted, so that we do not write over the end. -* `index`:\\[in\\] The attribute index of the attribute to be added. +* `forest`:\\[in\\] A committed forest. +* `ltreeid`:\\[in\\] The local tree or ghost tree in which the element lies. 0 <= *ltreeid* < num\\_local\\_trees + num\\_ghost\\_trees +* `elem`:\\[in\\] An element or ghost in the tree *ltreeid*. +* `face`:\\[in\\] A face number of *elem*. +# Returns +The eclass of the local tree or ghost tree that is face neighbor of *elem* across *face*. T8\\_ECLASS\\_INVALID if no neighbor exists. ### Prototype ```c -void t8_cmesh_trees_add_ghost_attribute (const t8_cmesh_trees_t trees, const t8_stash_attribute_struct_t *attr, t8_locidx_t local_ghost_id, t8_locidx_t ghosts_inserted, size_t index); +t8_eclass_t t8_forest_element_neighbor_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *elem, const int face); ``` """ -function t8_cmesh_trees_add_ghost_attribute(trees, attr, local_ghost_id, ghosts_inserted, index) - @ccall libt8.t8_cmesh_trees_add_ghost_attribute(trees::t8_cmesh_trees_t, attr::Ptr{t8_stash_attribute_struct_t}, local_ghost_id::t8_locidx_t, ghosts_inserted::t8_locidx_t, index::Csize_t)::Cvoid +function t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) + @ccall libt8.t8_forest_element_neighbor_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, face::Cint)::t8_eclass_t end """ - t8_cmesh_trees_get_numproc(trees) + t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_eclass, face, neigh_face) -Return the number of parts of a trees structure. +Construct the face neighbor of an element, possibly across tree boundaries. Returns the global tree-id of the tree in which the neighbor element lies in. # Arguments -* `trees`:\\[in\\] The trees structure. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local tree in which the element lies. +* `elem`:\\[in\\] The element to be considered. +* `neigh`:\\[in,out\\] On input an allocated element of the scheme of the face\\_neighbors eclass. On output, this element's data is filled with the data of the face neighbor. If the neighbor does not exist the data could be modified arbitrarily. +* `neigh_eclass`:\\[in\\] The eclass of *neigh*. +* `face`:\\[in\\] The number of the face along which the neighbor should be constructed. +* `neigh_face`:\\[out\\] The number of the face viewed from perspective of *neigh*. Can be nullptr, in which case the output is discarded. # Returns -The number of parts in *trees*. +The global tree-id of the tree in which *neigh* is in. -1 if there exists no neighbor across that face. Domain boundary. -2 if the neighbor is not in a local tree or ghost tree. Process/Ghost boundary. ### Prototype ```c -size_t t8_cmesh_trees_get_numproc (const t8_cmesh_trees_t trees); +t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, const t8_eclass_t neigh_eclass, int face, int *neigh_face); ``` """ -function t8_cmesh_trees_get_numproc(trees) - @ccall libt8.t8_cmesh_trees_get_numproc(trees::t8_cmesh_trees_t)::Csize_t +function t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_eclass, face, neigh_face) + @ccall libt8.t8_forest_element_face_neighbor(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, neigh::Ptr{t8_element_t}, neigh_eclass::t8_eclass_t, face::Cint, neigh_face::Ptr{Cint})::t8_gloidx_t end """ - t8_cmesh_tree_to_face_encode(dimension, face, orientation) + t8_forest_iterate(forest) -Compute the tree-to-face information given a face and orientation value of a face connection. +TODO: Can be removed since it is unused. # Arguments -* `dimension`:\\[in\\] The dimension of the corresponding eclasses. -* `face`:\\[in\\] A face number -* `orientation`:\\[in\\] A face-to-face orientation. -# Returns -The tree-to-face entry corresponding to the face/orientation combination. It is computed as t8\\_eclass\\_max\\_num\\_faces[dimension] * orientation + face +* `forest`:\\[in\\] The forest. ### Prototype ```c -int8_t t8_cmesh_tree_to_face_encode (const int dimension, const t8_locidx_t face, const int orientation); +void t8_forest_iterate (t8_forest_t forest); ``` """ -function t8_cmesh_tree_to_face_encode(dimension, face, orientation) - @ccall libt8.t8_cmesh_tree_to_face_encode(dimension::Cint, face::t8_locidx_t, orientation::Cint)::Int8 +function t8_forest_iterate(forest) + @ccall libt8.t8_forest_iterate(forest::t8_forest_t)::Cvoid end """ - t8_cmesh_tree_to_face_decode(dimension, tree_to_face, face, orientation) + t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) -Given a tree-to-face value, get its encoded face number and orientation. +Query whether a batch of points lies inside an element. For bilinearly interpolated elements. !!! note - This function is the inverse operation of t8_cmesh_tree_to_face_encode If F = t8\\_eclass\\_max\\_num\\_faces[dimension], we get orientation = tree\\_to\\_face / F face = tree\\_to\\_face % F + For 2D quadrilateral elements this function is only an approximation. It is correct if the four vertices lie in the same plane, but it may produce only approximate results if the vertices do not lie in the same plane. # Arguments -* `dimension`:\\[in\\] The dimension of the corresponding eclasses. -* `tree_to_face`:\\[in\\] A tree-to-face value -* `face`:\\[out\\] On output filled with the stored face value. -* `orientation`:\\[out\\] On output filled with the stored orientation value. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The forest local id of the tree in which the element is. +* `element`:\\[in\\] The element. +* `points`:\\[in\\] 3-dimensional coordinates of the points to check +* `num_points`:\\[in\\] The number of points to check +* `is_inside`:\\[in,out\\] An array of length *num_points*, filled with 0/1 on output. True (non-zero) if a *point* lies within an *element*, false otherwise. The return value is also true if the point lies on the element boundary. Thus, this function may return true for different leaf elements, if they are neighbors and the point lies on the common boundary. +* `tolerance`:\\[in\\] Tolerance that we allow the point to not exactly match the element. If this value is larger we detect more points. If it is zero we probably do not detect points even if they are inside due to rounding errors. ### Prototype ```c -void t8_cmesh_tree_to_face_decode (const int dimension, const int8_t tree_to_face, int *face, int *orientation); +void t8_forest_element_points_inside (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, int num_points, int *is_inside, const double tolerance); ``` """ -function t8_cmesh_tree_to_face_decode(dimension, tree_to_face, face, orientation) - @ccall libt8.t8_cmesh_tree_to_face_decode(dimension::Cint, tree_to_face::Int8, face::Ptr{Cint}, orientation::Ptr{Cint})::Cvoid +function t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) + @ccall libt8.t8_forest_element_points_inside(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, points::Ptr{Cdouble}, num_points::Cint, is_inside::Ptr{Cint}, tolerance::Cdouble)::Cvoid end """ - t8_cmesh_trees_print(cmesh, trees) - -Print the trees,ghosts and their neighbors in ASCII format t stdout. This function is used for debugging purposes. + t8_forest_element_find_owner(forest, gtreeid, element, eclass) -# Arguments -* `cmesh`:\\[in\\] A coarse mesh structure that must be committed. -* `trees`:\\[in\\] The trees structure of *cmesh*. -### Prototype -```c -void t8_cmesh_trees_print (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); -``` -""" -function t8_cmesh_trees_print(cmesh, trees) - @ccall libt8.t8_cmesh_trees_print(cmesh::t8_cmesh_t, trees::t8_cmesh_trees_t)::Cvoid -end +Find the owner process of a given element. -""" - t8_cmesh_trees_bcast(cmesh_in, root, comm) +!!! note -### Prototype -```c -void t8_cmesh_trees_bcast (t8_cmesh_t cmesh_in, int root, sc_MPI_Comm comm); -``` -""" -function t8_cmesh_trees_bcast(cmesh_in, root, comm) - @ccall libt8.t8_cmesh_trees_bcast(cmesh_in::t8_cmesh_t, root::Cint, comm::MPI_Comm)::Cvoid -end + The element must not exist in the forest, but an ancestor of its first descendant has to. If the element's owner is not unique, the owner of the element's first descendant is returned. -""" - t8_cmesh_trees_is_face_consistent(cmesh, trees) +!!! note -Check whether the face connection of a trees structure are consistent. That is if tree1 lists tree2 as neighbor at face i with ttf entries (or,face j), then tree2 must list tree1 as neighbor at face j with ttf entries (or, face i). + *forest* must be committed before calling this function. # Arguments -* `cmesh`:\\[in\\] A cmesh structure to be checked. -* `trees`:\\[in\\] The cmesh's trees struct. +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of the tree in which the element lies. +* `element`:\\[in\\] The element to look for. +* `eclass`:\\[in\\] The element class of the tree *gtreeid*. # Returns -True if the face connections are consistent, False if not. -### Prototype -```c -int t8_cmesh_trees_is_face_consistent (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); -``` -""" -function t8_cmesh_trees_is_face_consistent(cmesh, trees) - @ccall libt8.t8_cmesh_trees_is_face_consistent(cmesh::t8_cmesh_t, trees::t8_cmesh_trees_t)::Cint -end - -""" - t8_cmesh_trees_is_equal(cmesh, trees_a, trees_b) +The mpirank of the process that owns *element*. +# See also +t8\\_forest\\_element\\_find\\_owner\\_ext, t8\\_forest\\_element\\_owners\\_bounds ### Prototype ```c -int t8_cmesh_trees_is_equal (t8_cmesh_t cmesh, t8_cmesh_trees_t trees_a, t8_cmesh_trees_t trees_b); +int t8_forest_element_find_owner (t8_forest_t forest, t8_gloidx_t gtreeid, t8_element_t *element, t8_eclass_t eclass); ``` """ -function t8_cmesh_trees_is_equal(cmesh, trees_a, trees_b) - @ccall libt8.t8_cmesh_trees_is_equal(cmesh::t8_cmesh_t, trees_a::t8_cmesh_trees_t, trees_b::t8_cmesh_trees_t)::Cint +function t8_forest_element_find_owner(forest, gtreeid, element, eclass) + @ccall libt8.t8_forest_element_find_owner(forest::t8_forest_t, gtreeid::t8_gloidx_t, element::Ptr{t8_element_t}, eclass::t8_eclass_t)::Cint end """ - t8_cmesh_trees_destroy(trees) - -Free all memory allocated with a trees structure. This means that all coarse trees and ghosts, their face neighbor entries and attributes and the additional structures of trees are freed. + t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) -# Arguments -* `trees`:\\[in,out\\] The tree structure to be destroyed. Set to NULL on output. ### Prototype ```c -void t8_cmesh_trees_destroy (t8_cmesh_trees_t *trees); +t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, const t8_scheme_c *scheme, const int level, const int do_face_ghost, sc_MPI_Comm comm); ``` """ -function t8_cmesh_trees_destroy(trees) - @ccall libt8.t8_cmesh_trees_destroy(trees::Ptr{t8_cmesh_trees_t})::Cvoid +function t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) + @ccall libt8.t8_forest_new_uniform(cmesh::t8_cmesh_t, scheme::Ptr{t8_scheme_c}, level::Cint, do_face_ghost::Cint, comm::MPI_Comm)::t8_forest_t end """ -This structure holds the connectivity data of the coarse mesh. It can either be replicated, then each process stores a copy of the whole mesh, or partitioned. In the latter case, each process only stores a local portion of the mesh plus information about ghost elements. - -The coarse mesh is a collection of coarse trees that can be identified along faces. TODO: this description is outdated. rewrite it. The array ctrees stores these coarse trees sorted by their (global) tree\\_id. If the mesh if partitioned it is partitioned according to an (possible only virtually existing) underlying fine mesh. Therefore the ctrees array can store duplicated trees on different processes, if each of these processes owns elements of the same tree in the fine mesh. - -Each tree stores information about its face-neighbours in an array of t8_ctree_fneighbor. - -If partitioned the ghost trees are stored in a hash table that is backed up by an array. The hash value of a ghost tree is its tree\\_id modulo the number of ghosts on this process. - -# See also -t8\\_ctree\\_fneighbor -""" -const t8_cmesh_struct_t = t8_cmesh - -const t8_cghost_struct_t = t8_cghost - -"""This structure holds the data of a local tree including the information about face neighbors. For those the tree\\_to\\_face index is computed as follows. Let F be the maximal number of faces of any eclass of the cmesh's dimension, then ttf % F is the face number and ttf / F is the orientation. (t8_eclass_max_num_faces) The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees. We chose a main\\_face from them as follows: Either both trees have the same element class, then the face with the lower face number is the main\\_face or the trees belong to different classes in which case the face belonging to the tree with the lower class according to the ordering triangle < square, hex < tet < prism < pyramid, is the main\\_face. Then face corner 0 of the main\\_face connects to a face corner k in the other face. The face orientation is defined as the number k. If the classes are equal and my\\_face == other\\_face, treating either of both faces as the main\\_face leads to the same result. See https://arxiv.org/pdf/1611.02929.pdf for more details.""" -const t8_ctree_struct_t = t8_ctree - -const t8_cmesh_trees_struct_t = t8_cmesh_trees - -const t8_part_tree_struct_t = t8_part_tree - -""" -This struct is used to profile cmesh algorithms. The cmesh struct stores a pointer to a profile struct, and if it is nonzero, various runtimes and data measurements are stored here. - -# See also -[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) -""" -const t8_cprofile_struct_t = t8_cprofile - -""" - t8_element_array_t - -The [`t8_element_array_t`](@ref) is an array to store [`t8_element_t`](@ref) * of a given eclass\\_scheme implementation. It is a wrapper around sc_array_t. Each time, a new element is created by the functions for t8_element_array_t, the eclass function either t8_element_new or t8_element_init is called for the element. Thus, each element in a t8_element_array_t is automatically initialized properly. + t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) -| Field | Note | -| :----- | :--------------------------------------------------- | -| scheme | An eclass scheme of which elements should be stored | -| array | The array in which the elements are stored | -""" -struct t8_element_array_t - scheme::Ptr{t8_eclass_scheme_c} - array::sc_array_t -end +Build a adapted forest from another forest. -""" - t8_element_array_new(scheme) +!!! note -Creates a new array structure with 0 elements. + This is equivalent to calling t8_forest_init, t8_forest_set_adapt, t8_forest_set_ghost, and t8_forest_commit # Arguments -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `forest_from`:\\[in\\] The forest to refine +* `adapt_fn`:\\[in\\] Adapt function to use +* `recursive`:\\[in\\] If true adaptation is recursive +* `do_face_ghost`:\\[in\\] If true, a layer of ghost elements is created for the forest. +* `user_data`:\\[in\\] If not NULL, the user data pointer of the forest is set to this value. # Returns -Return an allocated array of zero length. +A new forest that is adapted from *forest_from*. ### Prototype ```c -t8_element_array_t * t8_element_array_new (t8_eclass_scheme_c *scheme); +t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, int recursive, int do_face_ghost, void *user_data); ``` """ -function t8_element_array_new(scheme) - @ccall libt8.t8_element_array_new(scheme::Ptr{t8_eclass_scheme_c})::Ptr{t8_element_array_t} +function t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) + @ccall libt8.t8_forest_new_adapt(forest_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint, do_face_ghost::Cint, user_data::Ptr{Cvoid})::t8_forest_t end """ - t8_element_array_new_count(scheme, num_elements) + t8_forest_ref(forest) -Creates a new array structure with a given length (number of elements) and calls t8_element_new for those elements. +Increase the reference counter of a forest. # Arguments -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `num_elements`:\\[in\\] Initial number of array elements. -# Returns -Return an allocated array with allocated and initialized elements for which t8_element_new was called. +* `forest`:\\[in,out\\] On input, this forest must exist with positive reference count. It may be in any state. ### Prototype ```c -t8_element_array_t * t8_element_array_new_count (t8_eclass_scheme_c *scheme, size_t num_elements); +void t8_forest_ref (t8_forest_t forest); ``` """ -function t8_element_array_new_count(scheme, num_elements) - @ccall libt8.t8_element_array_new_count(scheme::Ptr{t8_eclass_scheme_c}, num_elements::Csize_t)::Ptr{t8_element_array_t} +function t8_forest_ref(forest) + @ccall libt8.t8_forest_ref(forest::t8_forest_t)::Cvoid end """ - t8_element_array_init(element_array, scheme) + t8_forest_unref(pforest) -Initializes an already allocated (or static) array structure. +Decrease the reference counter of a forest. If the counter reaches zero, this forest is destroyed. In this case, the forest dereferences its cmesh and scheme members. # Arguments -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `pforest`:\\[in,out\\] On input, the forest pointed to must exist with positive reference count. It may be in any state. If the reference count reaches zero, the forest is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the forest is not modified in other ways. ### Prototype ```c -void t8_element_array_init (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme); +void t8_forest_unref (t8_forest_t *pforest); ``` """ -function t8_element_array_init(element_array, scheme) - @ccall libt8.t8_element_array_init(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_eclass_scheme_c})::Cvoid +function t8_forest_unref(pforest) + @ccall libt8.t8_forest_unref(pforest::Ptr{t8_forest_t})::Cvoid end """ - t8_element_array_init_size(element_array, scheme, num_elements) - -Initializes an already allocated (or static) array structure and allocates a given number of elements and initializes them with t8_element_init. + t8_forest_get_dimension(forest) -# Arguments -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `num_elements`:\\[in\\] Number of initial array elements. ### Prototype ```c -void t8_element_array_init_size (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, size_t num_elements); +int t8_forest_get_dimension (const t8_forest_t forest); ``` """ -function t8_element_array_init_size(element_array, scheme, num_elements) - @ccall libt8.t8_element_array_init_size(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_eclass_scheme_c}, num_elements::Csize_t)::Cvoid +function t8_forest_get_dimension(forest) + @ccall libt8.t8_forest_get_dimension(forest::t8_forest_t)::Cint end """ - t8_element_array_init_view(view, array, offset, length) - -Initializes an already allocated (or static) view from existing t8\\_element\\_array. The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). + t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) -# Arguments -* `view`:\\[in,out\\] Array structure to be initialized. -* `array`:\\[in\\] The array must not be resized while view is alive. -* `offset`:\\[in\\] The offset of the viewed section in element units. This offset cannot be changed until the view is reset. -* `length`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`sc_array_reset`](@ref) later. ### Prototype ```c -void t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, size_t offset, size_t length); +void t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8_element_t *element, int corner_number, double *coordinates); ``` """ -function t8_element_array_init_view(view, array, offset, length) - @ccall libt8.t8_element_array_init_view(view::Ptr{t8_element_array_t}, array::Ptr{t8_element_array_t}, offset::Csize_t, length::Csize_t)::Cvoid +function t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) + @ccall libt8.t8_forest_element_coordinate(forest::t8_forest_t, ltree_id::t8_locidx_t, element::Ptr{t8_element_t}, corner_number::Cint, coordinates::Ptr{Cdouble})::Cvoid end """ - t8_element_array_init_data(view, base, scheme, elem_count) - -Initializes an already allocated (or static) view from given plain C data (array of [`t8_element_t`](@ref)). The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). + t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) -# Arguments -* `view`:\\[in,out\\] Array structure to be initialized. -* `base`:\\[in\\] The data must not be moved while view is alive. Must be an array of [`t8_element_t`](@ref) corresponding to *scheme*. -* `scheme`:\\[in\\] The eclass scheme of the elements stored in *base*. -* `elem_count`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`t8_element_array_reset`](@ref) later. ### Prototype ```c -void t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_eclass_scheme_c *scheme, size_t elem_count); +void t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out, const double *stretch_factors); ``` """ -function t8_element_array_init_data(view, base, scheme, elem_count) - @ccall libt8.t8_element_array_init_data(view::Ptr{t8_element_array_t}, base::Ptr{t8_element_t}, scheme::Ptr{t8_eclass_scheme_c}, elem_count::Csize_t)::Cvoid +function t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) + @ccall libt8.t8_forest_element_from_ref_coords_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble}, stretch_factors::Ptr{Cdouble})::Cvoid end """ - t8_element_array_init_copy(element_array, scheme, data, num_elements) - -Initializes an already allocated (or static) array structure and copy an existing array of [`t8_element_t`](@ref) into it. + t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) -# Arguments -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `data`:\\[in\\] An array of [`t8_element_t`](@ref) which will be copied into *element_array*. The elements in *data* must belong to *scheme* and must be properly initialized with either t8_element_new or t8_element_init. -* `num_elements`:\\[in\\] Number of elements in *data* to be copied. ### Prototype ```c -void t8_element_array_init_copy (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, t8_element_t *data, size_t num_elements); +void t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out); ``` """ -function t8_element_array_init_copy(element_array, scheme, data, num_elements) - @ccall libt8.t8_element_array_init_copy(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_eclass_scheme_c}, data::Ptr{t8_element_t}, num_elements::Csize_t)::Cvoid +function t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) + @ccall libt8.t8_forest_element_from_ref_coords(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble})::Cvoid end """ - t8_element_array_resize(element_array, new_count) - -Change the number of elements stored in an element array. - -!!! note - - If *new_count* is larger than the number of current elements on *element_array*, then t8_element_init is called for the new elements. + t8_forest_element_centroid(forest, ltreeid, element, coordinates) -# Arguments -* `element_array`:\\[in,out\\] The element array to be modified. -* `new_count`:\\[in\\] The new element count of the array. If it is zero the effect equals t8_element_array_reset. ### Prototype ```c -void t8_element_array_resize (t8_element_array_t *element_array, size_t new_count); +void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); ``` """ -function t8_element_array_resize(element_array, new_count) - @ccall libt8.t8_element_array_resize(element_array::Ptr{t8_element_array_t}, new_count::Csize_t)::Cvoid +function t8_forest_element_centroid(forest, ltreeid, element, coordinates) + @ccall libt8.t8_forest_element_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, coordinates::Ptr{Cdouble})::Cvoid end """ - t8_element_array_copy(dest, src) - -Copy the contents of an array into another. Both arrays must have the same eclass\\_scheme. + t8_forest_element_linear_centroid(forest, ltreeid, element, coordinates) -# Arguments -* `dest`:\\[in\\] Array will be resized and get new data. -* `src`:\\[in\\] Array used as source of new data, will not be changed. ### Prototype ```c -void t8_element_array_copy (t8_element_array_t *dest, const t8_element_array_t *src); +void t8_forest_element_linear_centroid (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); ``` """ -function t8_element_array_copy(dest, src) - @ccall libt8.t8_element_array_copy(dest::Ptr{t8_element_array_t}, src::Ptr{t8_element_array_t})::Cvoid +function t8_forest_element_linear_centroid(forest, ltreeid, element, coordinates) + @ccall libt8.t8_forest_element_linear_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, coordinates::Ptr{Cdouble})::Cvoid end """ - t8_element_array_push(element_array) - -Enlarge an array by one element. + t8_forest_element_diam(forest, ltreeid, element) -# Arguments -* `element_array`:\\[in\\] Array structure to be modified. -# Returns -Returns a pointer to a newly added element for which t8_element_init was called. ### Prototype ```c -t8_element_t * t8_element_array_push (t8_element_array_t *element_array); +double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); ``` """ -function t8_element_array_push(element_array) - @ccall libt8.t8_element_array_push(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} +function t8_forest_element_diam(forest, ltreeid, element) + @ccall libt8.t8_forest_element_diam(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble end """ - t8_element_array_push_count(element_array, count) - -Enlarge an array by a number of elements. + t8_forest_element_volume(forest, ltreeid, element) -# Arguments -* `element_array`:\\[in\\] Array structure to be modified. -* `count`:\\[in\\] The number of elements to add. -# Returns -Returns a pointer to the newly added elements for which t8_element_init was called. ### Prototype ```c -t8_element_t * t8_element_array_push_count (t8_element_array_t *element_array, size_t count); +double t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); ``` """ -function t8_element_array_push_count(element_array, count) - @ccall libt8.t8_element_array_push_count(element_array::Ptr{t8_element_array_t}, count::Csize_t)::Ptr{t8_element_t} +function t8_forest_element_volume(forest, ltreeid, element) + @ccall libt8.t8_forest_element_volume(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble end """ - t8_element_array_index_locidx(element_array, index) - -Return a given element in an array. Const version. + t8_forest_element_face_area(forest, ltreeid, element, face) -# Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. -# Returns -A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -const t8_element_t * t8_element_array_index_locidx (const t8_element_array_t *element_array, t8_locidx_t index); +double t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face); ``` """ -function t8_element_array_index_locidx(element_array, index) - @ccall libt8.t8_element_array_index_locidx(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} +function t8_forest_element_face_area(forest, ltreeid, element, face) + @ccall libt8.t8_forest_element_face_area(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint)::Cdouble end """ - t8_element_array_index_int(element_array, index) - -Return a given element in an array. Const version. + t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) -# Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. -# Returns -A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -const t8_element_t * t8_element_array_index_int (const t8_element_array_t *element_array, int index); +void t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double centroid[3]); ``` """ -function t8_element_array_index_int(element_array, index) - @ccall libt8.t8_element_array_index_int(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} +function t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) + @ccall libt8.t8_forest_element_face_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, centroid::Ptr{Cdouble})::Cvoid end """ - t8_element_array_index_locidx_mutable(element_array, index) - -Return a given element in an array. Mutable version. + t8_forest_element_face_normal(forest, ltreeid, element, face, normal) -# Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. -# Returns -A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -t8_element_t * t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, t8_locidx_t index); +void t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double normal[3]); ``` """ -function t8_element_array_index_locidx_mutable(element_array, index) - @ccall libt8.t8_element_array_index_locidx_mutable(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} +function t8_forest_element_face_normal(forest, ltreeid, element, face, normal) + @ccall libt8.t8_forest_element_face_normal(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, normal::Ptr{Cdouble})::Cvoid end """ - t8_element_array_index_int_mutable(element_array, index) + t8_forest_ghost -Return a given element in an array. Mutable version. +| Field | Note | +| :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| num\\_ghosts\\_elements | The count of non-local ghost leaf elements | +| num\\_remote\\_elements | The count of local leaf elements that are ghost to another process. | +| ghost\\_type | Describes which neighbors are considered ghosts. | +| ghost\\_trees | ghost tree data: global\\_id. eclass. elements. In linear id order | +| global\\_tree\\_to\\_ghost\\_tree | Indexes into ghost\\_trees. Given a global tree id I give the index i such that the tree is in ghost\\_trees[i] | +| process\\_offsets | Given a process, return the first ghost tree and within it the first element of that process. | +| remote\\_ghosts | array of local trees that have ghost elements for another process. for each tree an array of [`t8_element_t`](@ref) * of the local ghost elements. Also an array of [`t8_locidx_t`](@ref) of the local indices of these elements within the tree. It is a hash table, hashed with the rank of a remote process. Sorted within each process by linear id. | +| remote\\_processes | The ranks of the processes for which local elements are ghost. Array of int's. | +| glo\\_tree\\_mempool | The global tree memory pool. | +| proc\\_offset\\_mempool | The process offset memory pool. | +""" +struct t8_forest_ghost + rc::Cint + num_ghosts_elements::t8_locidx_t + num_remote_elements::t8_locidx_t + ghost_type::t8_ghost_type_t + ghost_trees::Ptr{sc_array_t} + global_tree_to_ghost_tree::Ptr{sc_hash_t} + process_offsets::Ptr{sc_hash_t} + remote_ghosts::Ptr{sc_hash_array_t} + remote_processes::Ptr{sc_array_t} + glo_tree_mempool::Ptr{sc_mempool_t} + proc_offset_mempool::Ptr{sc_mempool_t} +end + +const t8_forest_ghost_t = Ptr{t8_forest_ghost} + +""" + t8_forest_ghost_init(pghost, ghost_type) + +Initialize a ghost type of a forest. # Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. -# Returns -A pointer to the element stored at position *index* in *element_array*. +* `pghost`:\\[out\\] Pointer to the forest's ghost. +* `ghost_type`:\\[in\\] The type of the ghost elements, +# See also +[`t8_ghost_type_t`](@ref). + ### Prototype ```c -t8_element_t * t8_element_array_index_int_mutable (t8_element_array_t *element_array, int index); +void t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type); ``` """ -function t8_element_array_index_int_mutable(element_array, index) - @ccall libt8.t8_element_array_index_int_mutable(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} +function t8_forest_ghost_init(pghost, ghost_type) + @ccall libt8.t8_forest_ghost_init(pghost::Ptr{t8_forest_ghost_t}, ghost_type::t8_ghost_type_t)::Cvoid end """ - t8_element_array_get_scheme(element_array) + t8_forest_ghost_num_trees(forest) -Return the eclass scheme associated to a t8\\_element\\_array. +Return the number of trees in a ghost. # Arguments -* `element_array`:\\[in\\] Array of elements. +* `forest`:\\[in\\] The forest. # Returns -The eclass scheme stored at *element_array*. +The number of trees in the forest's ghost (or 0 if ghost structure does not exist). ### Prototype ```c -const t8_eclass_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array); +t8_locidx_t t8_forest_ghost_num_trees (const t8_forest_t forest); ``` """ -function t8_element_array_get_scheme(element_array) - @ccall libt8.t8_element_array_get_scheme(element_array::Ptr{t8_element_array_t})::Ptr{t8_eclass_scheme_c} +function t8_forest_ghost_num_trees(forest) + @ccall libt8.t8_forest_ghost_num_trees(forest::t8_forest_t)::t8_locidx_t end """ - t8_element_array_get_count(element_array) + t8_forest_ghost_get_tree_element_offset(forest, lghost_tree) -Return the number of elements stored in a [`t8_element_array_t`](@ref). +Return the element offset of a ghost tree. + +!!! note + + forest must be committed before calling this function. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] The forest with constructed ghost layer. +* `lghost_tree`:\\[in\\] A local ghost id of a ghost tree. # Returns -The number of elements stored in *element_array*. +The element offset of this ghost tree within the set of local ghost elements. ### Prototype ```c -size_t t8_element_array_get_count (const t8_element_array_t *element_array); +t8_locidx_t t8_forest_ghost_get_tree_element_offset (t8_forest_t forest, t8_locidx_t lghost_tree); ``` """ -function t8_element_array_get_count(element_array) - @ccall libt8.t8_element_array_get_count(element_array::Ptr{t8_element_array_t})::Csize_t +function t8_forest_ghost_get_tree_element_offset(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_tree_element_offset(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_locidx_t end """ - t8_element_array_get_size(element_array) + t8_forest_ghost_tree_num_leaf_elements(forest, lghost_tree) -Return the data size of elements stored in a [`t8_element_array_t`](@ref). +Given an index in the ghost\\_tree array, return this tree's number of leaf elements # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] The *forest*. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. # Returns -The size (in bytes) of a single element in *element_array*. +The number of ghost leaf elements of the tree. *forest* must be committed before calling this function. ### Prototype ```c -size_t t8_element_array_get_size (const t8_element_array_t *element_array); +t8_locidx_t t8_forest_ghost_tree_num_leaf_elements (t8_forest_t forest, t8_locidx_t lghost_tree); ``` """ -function t8_element_array_get_size(element_array) - @ccall libt8.t8_element_array_get_size(element_array::Ptr{t8_element_array_t})::Csize_t +function t8_forest_ghost_tree_num_leaf_elements(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_tree_num_leaf_elements(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_locidx_t end """ - t8_element_array_get_data(element_array) + t8_forest_ghost_get_tree_leaf_elements(forest, lghost_tree) -Return a const pointer to the real data array stored in a t8\\_element\\_array. +Get a pointer to the ghost leaf element array of a ghost tree. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. 0 <= *lghost_tree* < num\\_ghost\\_trees # Returns -A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. +A pointer to the array of ghost leaf elements of the tree. *forest* must be committed before calling this function. ### Prototype ```c -const t8_element_t * t8_element_array_get_data (const t8_element_array_t *element_array); +t8_element_array_t * t8_forest_ghost_get_tree_leaf_elements (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -function t8_element_array_get_data(element_array) - @ccall libt8.t8_element_array_get_data(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} +function t8_forest_ghost_get_tree_leaf_elements(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_tree_leaf_elements(forest::t8_forest_t, lghost_tree::t8_locidx_t)::Ptr{t8_element_array_t} end """ - t8_element_array_get_data_mutable(element_array) + t8_forest_ghost_get_ghost_treeid(forest, gtreeid) -Return a pointer to the real data array stored in a t8\\_element\\_array. +Given a global tree compute the ghost local tree id of it. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `gtreeid`:\\[in\\] A global tree in *forest*. # Returns -A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. +If *gtreeid* is also a ghost tree, the index in the ghost->ghost\\_trees array of the tree. Otherwise a negative number. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -t8_element_t * t8_element_array_get_data_mutable (t8_element_array_t *element_array); +t8_locidx_t t8_forest_ghost_get_ghost_treeid (t8_forest_t forest, t8_gloidx_t gtreeid); ``` """ -function t8_element_array_get_data_mutable(element_array) - @ccall libt8.t8_element_array_get_data_mutable(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} +function t8_forest_ghost_get_ghost_treeid(forest, gtreeid) + @ccall libt8.t8_forest_ghost_get_ghost_treeid(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t end """ - t8_element_array_get_array(element_array) - -Return a const pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. - -!!! note + t8_forest_ghost_get_tree_class(forest, lghost_tree) - The data cannot be modified. +Given an index in the ghost\\_tree array, return this tree's element class. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] A committed forest. +* `lghost_tree`:\\[in\\] The tree's local index in the ghost\\_tree array. # Returns -A const pointer to the [`sc_array`](@ref) storing the data. +The element class of the given tree. ### Prototype ```c -const sc_array_t * t8_element_array_get_array (const t8_element_array_t *element_array); +t8_eclass_t t8_forest_ghost_get_tree_class (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -function t8_element_array_get_array(element_array) - @ccall libt8.t8_element_array_get_array(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} +function t8_forest_ghost_get_tree_class(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_tree_class(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_eclass_t end """ - t8_element_array_get_array_mutable(element_array) - -Return a mutable pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. - -!!! note + t8_forest_ghost_get_global_treeid(forest, lghost_tree) - The data can be modified. +Given a local ghost tree compute the global tree id of it. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. (0 <= *lghost_tree* < num\\_ghost\\_trees) # Returns -A pointer to the [`sc_array`](@ref) storing the data. +The global id of the local ghost tree *lghost_tree*. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -sc_array_t * t8_element_array_get_array_mutable (t8_element_array_t *element_array); +t8_gloidx_t t8_forest_ghost_get_global_treeid (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -function t8_element_array_get_array_mutable(element_array) - @ccall libt8.t8_element_array_get_array_mutable(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} +function t8_forest_ghost_get_global_treeid(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_global_treeid(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_gloidx_t end """ - t8_element_array_reset(element_array) - -Sets the array count to zero and frees all elements. - -!!! note + t8_forest_ghost_get_leaf_element(forest, lghost_tree, lelement) - Calling [`t8_element_array_init`](@ref), then any array operations, then [`t8_element_array_reset`](@ref) is memory neutral. +Given an index into the ghost\\_trees array and for that tree an element index, return the corresponding element. # Arguments -* `element_array`:\\[in,out\\] Array structure to be reset. +* `forest`:\\[in\\] The *forest*. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. +* `lelement`:\\[in\\] The local id of the ghost leaf element considered. +# Returns +A pointer to the ghost leaf element. *forest* must be committed before calling this function. ### Prototype ```c -void t8_element_array_reset (t8_element_array_t *element_array); +t8_element_t * t8_forest_ghost_get_leaf_element (t8_forest_t forest, t8_locidx_t lghost_tree, t8_locidx_t lelement); ``` """ -function t8_element_array_reset(element_array) - @ccall libt8.t8_element_array_reset(element_array::Ptr{t8_element_array_t})::Cvoid +function t8_forest_ghost_get_leaf_element(forest, lghost_tree, lelement) + @ccall libt8.t8_forest_ghost_get_leaf_element(forest::t8_forest_t, lghost_tree::t8_locidx_t, lelement::t8_locidx_t)::Ptr{t8_element_t} end """ - t8_element_array_truncate(element_array) + t8_forest_element_is_ghost(forest, element, lghost_tree) -Sets the array count to zero, but does not free elements. +Query whether a given element is a ghost of a certrain tree in a forest. !!! note - This is intended to allow an t8\\_element\\_array to be used as a reusable buffer, where the "high water mark" of the buffer is preserved, so that O(log (max n)) reallocs occur over the life of the buffer. + *forest* must be committed before calling this function. # Arguments -* `element_array`:\\[in,out\\] Element array structure to be truncated. +* `forest`:\\[in\\] The forest. +* `element`:\\[in\\] An element of a ghost tree in *forest*. +* `lghost_tree`:\\[in\\] A local ghost tree id of *forest*. (0 <= *lghost_tree* < num\\_ghost\\_trees) +# Returns +True (non-zero) if and only if *element* is a ghost in *lghost_tree* of *forest*. ### Prototype ```c -void t8_element_array_truncate (t8_element_array_t *element_array); +int t8_forest_element_is_ghost (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t lghost_tree); ``` """ -function t8_element_array_truncate(element_array) - @ccall libt8.t8_element_array_truncate(element_array::Ptr{t8_element_array_t})::Cvoid +function t8_forest_element_is_ghost(forest, element, lghost_tree) + @ccall libt8.t8_forest_element_is_ghost(forest::t8_forest_t, element::Ptr{t8_element_t}, lghost_tree::t8_locidx_t)::Cint end """ - t8_shmem_init(comm) + t8_forest_ghost_get_remotes(forest, num_remotes) + +Return the array of remote ranks. +# Arguments +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `num_remotes`:\\[in,out\\] On output the number of remote ranks is stored here. +# Returns +The array of remote ranks in ascending order. ### Prototype ```c -void t8_shmem_init (sc_MPI_Comm comm); +int * t8_forest_ghost_get_remotes (t8_forest_t forest, int *num_remotes); ``` """ -function t8_shmem_init(comm) - @ccall libt8.t8_shmem_init(comm::MPI_Comm)::Cvoid +function t8_forest_ghost_get_remotes(forest, num_remotes) + @ccall libt8.t8_forest_ghost_get_remotes(forest::t8_forest_t, num_remotes::Ptr{Cint})::Ptr{Cint} end """ - t8_shmem_finalize(comm) + t8_forest_ghost_remote_first_tree(forest, remote) + +Return the first local ghost tree of a remote rank. +# Arguments +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. +# Returns +The ghost tree id of the first ghost tree that stores ghost elements of *remote*. ### Prototype ```c -void t8_shmem_finalize (sc_MPI_Comm comm); +t8_locidx_t t8_forest_ghost_remote_first_tree (t8_forest_t forest, int remote); ``` """ -function t8_shmem_finalize(comm) - @ccall libt8.t8_shmem_finalize(comm::MPI_Comm)::Cvoid +function t8_forest_ghost_remote_first_tree(forest, remote) + @ccall libt8.t8_forest_ghost_remote_first_tree(forest::t8_forest_t, remote::Cint)::t8_locidx_t end """ - t8_shmem_set_type(comm, type) + t8_forest_ghost_remote_first_elem(forest, remote) + +Return the local index of the first ghost element that belongs to a given remote rank. +# Arguments +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. +# Returns +The index i in the ghost elements of the first element of rank *remote* ### Prototype ```c -void t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); +t8_locidx_t t8_forest_ghost_remote_first_elem (t8_forest_t forest, int remote); ``` """ -function t8_shmem_set_type(comm, type) - @ccall libt8.t8_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid +function t8_forest_ghost_remote_first_elem(forest, remote) + @ccall libt8.t8_forest_ghost_remote_first_elem(forest::t8_forest_t, remote::Cint)::t8_locidx_t end """ - t8_shmem_array_init(parray, elem_size, elem_count, comm) + t8_forest_ghost_ref(ghost) + +Increase the reference count of a ghost structure. +# Arguments +* `ghost`:\\[in,out\\] On input, this ghost structure must exist with positive reference count. ### Prototype ```c -void t8_shmem_array_init (t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm); +void t8_forest_ghost_ref (t8_forest_ghost_t ghost); ``` """ -function t8_shmem_array_init(parray, elem_size, elem_count, comm) - @ccall libt8.t8_shmem_array_init(parray::Ptr{t8_shmem_array_t}, elem_size::Csize_t, elem_count::Csize_t, comm::MPI_Comm)::Cvoid +function t8_forest_ghost_ref(ghost) + @ccall libt8.t8_forest_ghost_ref(ghost::t8_forest_ghost_t)::Cvoid end """ - t8_shmem_array_start_writing(array) - -Enable writing mode for a shmem array. Only some processes may be allowed to write into the array, which is indicated by the return value being non-zero. - -!!! note + t8_forest_ghost_unref(pghost) - This function is MPI collective. +Decrease the reference count of a ghost structure. If the counter reaches zero, the ghost structure is destroyed. See also t8_forest_ghost_destroy, which is to be preferred when it is known that the last reference to a cmesh is deleted. # Arguments -* `array`:\\[in,out\\] Initialized array. Writing will be enabled on certain processes. -# Returns -True if the calling process can write into the array. +* `pghost`:\\[in,out\\] On input, the ghost structure pointed to must exist with positive reference count. If the reference count reaches zero, the ghost structure is destroyed and this pointer is set to NULL. Otherwise, the pointer is not changed. ### Prototype ```c -int t8_shmem_array_start_writing (t8_shmem_array_t array); +void t8_forest_ghost_unref (t8_forest_ghost_t *pghost); ``` """ -function t8_shmem_array_start_writing(array) - @ccall libt8.t8_shmem_array_start_writing(array::t8_shmem_array_t)::Cint +function t8_forest_ghost_unref(pghost) + @ccall libt8.t8_forest_ghost_unref(pghost::Ptr{t8_forest_ghost_t})::Cvoid end """ - t8_shmem_array_end_writing(array) - -Disable writing mode for a shmem array. - -!!! note + t8_forest_ghost_destroy(pghost) - This function is MPI collective. +Verify that a ghost structure has only one reference left and destroy it. This function is preferred over t8_forest_ghost_unref when it is known that the last reference is to be deleted. # Arguments -* `array`:\\[in,out\\] Initialized with writing mode enabled. -# See also -[`t8_shmem_array_start_writing`](@ref). - +* `pghost`:\\[in,out\\] This ghost structure must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_forest_ghost_unref. ### Prototype ```c -void t8_shmem_array_end_writing (t8_shmem_array_t array); +void t8_forest_ghost_destroy (t8_forest_ghost_t *pghost); ``` """ -function t8_shmem_array_end_writing(array) - @ccall libt8.t8_shmem_array_end_writing(array::t8_shmem_array_t)::Cvoid +function t8_forest_ghost_destroy(pghost) + @ccall libt8.t8_forest_ghost_destroy(pghost::Ptr{t8_forest_ghost_t})::Cvoid end """ - t8_shmem_array_set_gloidx(array, index, value) + t8_forest_ghost_create(forest) -Set an entry of a t8\\_shmem array that is used to store [`t8_gloidx_t`](@ref). The array must have writing mode enabled t8_shmem_array_start_writing. +Create one layer of ghost elements for a forest. # Arguments -* `array`:\\[in,out\\] The array to be modified. -* `index`:\\[in\\] The array entry to be modified. -* `value`:\\[in\\] The new value to be set. +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +# See also +[`t8_forest_set_ghost`](@ref) + ### Prototype ```c -void t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value); +void t8_forest_ghost_create (t8_forest_t forest); ``` """ -function t8_shmem_array_set_gloidx(array, index, value) - @ccall libt8.t8_shmem_array_set_gloidx(array::t8_shmem_array_t, index::Cint, value::t8_gloidx_t)::Cvoid +function t8_forest_ghost_create(forest) + @ccall libt8.t8_forest_ghost_create(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_copy(dest, source) - -Copy the contents of one t8\\_shmem array into another. - -!!! note + t8_forest_ghost_create_balanced_only(forest) - *dest* must be initialized and match in element size and element count to *source*. +Create one layer of ghost elements for a forest. This version only works with balanced forests and is the original algorithm from p4est: Scalable Algorithms For Parallel Adaptive Mesh Refinement On Forests of Octrees !!! note - *dest* must have writing mode disabled. + The user should prefer t8_forest_ghost_create even for balanced forests. # Arguments -* `dest`:\\[in,out\\] The array in which *source* should be copied. -* `source`:\\[in\\] The array to copy. +* `forest`:\\[in,out\\] The balanced forest/ *forest* must be committed before calling this function. ### Prototype ```c -void t8_shmem_array_copy (t8_shmem_array_t dest, t8_shmem_array_t source); +void t8_forest_ghost_create_balanced_only (t8_forest_t forest); ``` """ -function t8_shmem_array_copy(dest, source) - @ccall libt8.t8_shmem_array_copy(dest::t8_shmem_array_t, source::t8_shmem_array_t)::Cvoid +function t8_forest_ghost_create_balanced_only(forest) + @ccall libt8.t8_forest_ghost_create_balanced_only(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) + t8_forest_ghost_create_topdown(forest) + +Experimental version of t8_forest_ghost_create using the ghost\\_v3 algorithm ### Prototype ```c -void t8_shmem_array_allgather (const void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, int recvcount, sc_MPI_Datatype recvtype); +void t8_forest_ghost_create_topdown (t8_forest_t forest); ``` """ -function t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) - @ccall libt8.t8_shmem_array_allgather(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvcount::Cint, recvtype::Cint)::Cvoid +function t8_forest_ghost_create_topdown(forest) + @ccall libt8.t8_forest_ghost_create_topdown(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) + t8_forest_save(forest) ### Prototype ```c -void t8_shmem_array_allgatherv (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, sc_MPI_Datatype recvtype, sc_MPI_Comm comm); +void t8_forest_save (t8_forest_t forest); ``` """ -function t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) - @ccall libt8.t8_shmem_array_allgatherv(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvtype::Cint, comm::MPI_Comm)::Cvoid +function t8_forest_save(forest) + @ccall libt8.t8_forest_save(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) + t8_vtk_data_type_t -### Prototype -```c -void t8_shmem_array_prefix (const void *sendbuf, t8_shmem_array_t recvarray, const int count, sc_MPI_Datatype type, sc_MPI_Op op, sc_MPI_Comm comm); -``` +TODO: Add support for integer data type. + +| Enumerator | Note | +| :---------------- | :---------------------------- | +| T8\\_VTK\\_SCALAR | One double value per element | +| T8\\_VTK\\_VECTOR | 3 double values per element | """ -function t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) - @ccall libt8.t8_shmem_array_prefix(sendbuf::Ptr{Cvoid}, recvarray::t8_shmem_array_t, count::Cint, type::Cint, op::Cint, comm::MPI_Comm)::Cvoid +@cenum t8_vtk_data_type_t::UInt32 begin + T8_VTK_SCALAR = 0 + T8_VTK_VECTOR = 1 end """ - t8_shmem_array_get_comm(array) + t8_vtk_data_field_t -### Prototype -```c -sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array); -``` -""" -function t8_shmem_array_get_comm(array) - @ccall libt8.t8_shmem_array_get_comm(array::t8_shmem_array_t)::Cint -end +A data field for VTK output. This struct is used to store data that is written to the VTK files. It contains the type of the data, a description, and the actual data array. +| Field | Note | +| :---------- | :----------------------------------------- | +| type | Describes of which type the data array is | +| description | String that describes the data. | """ - t8_shmem_array_get_elem_size(array) - -Get the element size of a [`t8_shmem_array`](@ref) +struct t8_vtk_data_field_t + type::t8_vtk_data_type_t + description::NTuple{8192, Cchar} + data::Ptr{Cdouble} +end + +""" + t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) -# Arguments -* `array`:\\[in\\] The array. -# Returns -The element size of *array*'s elements. ### Prototype ```c -size_t t8_shmem_array_get_elem_size (t8_shmem_array_t array); +int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, const int write_curved, int do_not_use_API, const int num_data, t8_vtk_data_field_t *data); ``` """ -function t8_shmem_array_get_elem_size(array) - @ccall libt8.t8_shmem_array_get_elem_size(array::t8_shmem_array_t)::Csize_t +function t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) + @ccall libt8.t8_forest_write_vtk_ext(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, write_curved::Cint, do_not_use_API::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_shmem_array_get_elem_count(array) - -Get the number of elements of a [`t8_shmem_array`](@ref) + t8_forest_write_vtk(forest, fileprefix) -# Arguments -* `array`:\\[in\\] The array. -# Returns -The number of elements in *array*. ### Prototype ```c -size_t t8_shmem_array_get_elem_count (t8_shmem_array_t array); +int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix); ``` """ -function t8_shmem_array_get_elem_count(array) - @ccall libt8.t8_shmem_array_get_elem_count(array::t8_shmem_array_t)::Csize_t +function t8_forest_write_vtk(forest, fileprefix) + @ccall libt8.t8_forest_write_vtk(forest::t8_forest_t, fileprefix::Cstring)::Cint end +# typedef int ( * t8_forest_iterate_face_fn ) ( const t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int face , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , void * user_data ) """ - t8_shmem_array_get_gloidx_array(array) +Callback function used in -Return a read-only pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. - -!!! note +# Arguments +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] Local index of the tree containing the *element*. +* `element`:\\[in\\] The considered element. +* `face`:\\[in\\] The integer index of the considered face of *element*. +* `is_leaf`:\\[in\\] True if and only if the currently considered element is a leaf element. +* `leaf_elements`:\\[in\\] The array of leaf elements that are descendants of *element*. Sorted by linear index. +* `tree_leaf_index`:\\[in\\] Tree-local index of the first leaf. +* `user_data`:\\[in\\] Some user-defined data, as void pointer. +# Returns +Nonzero if the element may touch the face and the top-down search shall be continued, zero otherwise. +# See also +[`t8_forest_iterate_faces`](@ref). +""" +const t8_forest_iterate_face_fn = Ptr{Cvoid} - Writing mode must be disabled for *array*. +# typedef int ( * t8_forest_search_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index ) +""" +A call-back function used by t8_forest_search describing a search-criterion. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree +* `element`:\\[in\\] the element for which the search criterion is checked. +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* that are descendants of *element* (or the element itself if *is_leaf* is true) +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* # Returns -The data of *array* as [`t8_gloidx_t`](@ref) pointer. -### Prototype -```c -const t8_gloidx_t * t8_shmem_array_get_gloidx_array (t8_shmem_array_t array); -``` +non-zero if the search criterion is met, zero otherwise. """ -function t8_shmem_array_get_gloidx_array(array) - @ccall libt8.t8_shmem_array_get_gloidx_array(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} -end +const t8_forest_search_fn = Ptr{Cvoid} +# typedef void ( * t8_forest_query_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , sc_array_t * queries , sc_array_t * query_indices , int * query_matches , const size_t num_active_queries ) """ - t8_shmem_array_get_gloidx_array_for_writing(array) +A call-back function used by t8_forest_search for queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. -Return a pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. The array must have writing enabled t8_shmem_array_start_writing and you should not write into the memory after t8_shmem_array_end_writing was called. +# Arguments +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree +* `element`:\\[in\\] the element for which the queries are executed +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* that are descendants of *element* (or the element itself if *is_leaf* is true) +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* +* `queries`:\\[in\\] An array of queries that are checked by the function +* `query_indices`:\\[in\\] An array of size\\_t entries, where each entry is an index of a query in *queries*. +* `query_matches`:\\[in,out\\] An array of length *num_active_queries*. If the element is not a leave must be set to true or false at the i-th index for each query, specifying whether the element 'matches' the query of the i-th query index or not. When the element is a leaf we can return before all entries are set. +* `num_active_queries`:\\[in\\] The number of currently active queries (equals the number of entries of *query_matches* and entries of *query_indices*). +""" +const t8_forest_query_fn = Ptr{Cvoid} + +# typedef int ( * t8_forest_partition_search_fn ) ( const t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int pfirst , const int plast ) +""" +A call-back function used by t8_forest_search_partition describing a search-criterion. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. Since the cmesh has to be replicated, it coincides with the global tree id. +* `element`:\\[in\\] the element for which the search criterion is checked +* `pfirst`:\\[in\\] the first processor that owns part of *element*. Guaranteed to be non-empty. +* `plast`:\\[in\\] the last processor that owns part of *element*. Guaranteed to be non-empty. # Returns -The data of *array* as [`t8_gloidx_t`](@ref) pointer. -### Prototype -```c -t8_gloidx_t * t8_shmem_array_get_gloidx_array_for_writing (t8_shmem_array_t array); -``` +non-zero if the search criterion is met, zero otherwise. """ -function t8_shmem_array_get_gloidx_array_for_writing(array) - @ccall libt8.t8_shmem_array_get_gloidx_array_for_writing(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} -end +const t8_forest_partition_search_fn = Ptr{Cvoid} +# typedef void ( * t8_forest_partition_query_fn ) ( const t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int pfirst , const int plast , void * queries , sc_array_t * query_indices , int * query_matches , const size_t num_active_queries ) """ - t8_shmem_array_get_gloidx(array, index) +A call-back function used by t8_forest_search_partition for queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element. The results of the check are stored in *query_matches*. -Return an entry of a shared memory array that stores [`t8_gloidx_t`](@ref). +# Arguments +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. Since the cmesh has to be replicated, it coincides with the global tree id. +* `element`:\\[in\\] the element for which the query is executed +* `pfirst`:\\[in\\] the first processor that owns part of *element*. Guaranteed to be non-empty. +* `plast`:\\[in\\] the last processor that owns part of *element*. Guaranteed to be non-empty. if this is equal to *pfirst*, then the recursion will stop for *element*'s branch after this function returns. +* `queries`:\\[in\\] an array of queries that are checked by the function +* `query_indices`:\\[in\\] an array of size\\_t entries, where each entry is an index of a query in *queries*. +* `query_matches`:\\[in,out\\] an array of length *num_active_queries*. If the element is not a leaf must be set to true or false at the i-th index for each query, specifying whether the element 'matches' the query of the i-th query index or not. When the element is a leaf we can return before all entries are set. +* `num_active_queries`:\\[in\\] The number of currently active queries (equals the number of entries of *query_matches* and entries of *query_indices*). +""" +const t8_forest_partition_query_fn = Ptr{Cvoid} -!!! note +""" + t8_forest_split_array(element, leaf_elements, offsets) - Writing mode must be disabled for *array*. +Split an array of elements according to the children of a given element E. In other words for each child C of E, find the index i, j, such that all descendants of C are elements[i], ..., elements[j-1]. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) -* `index`:\\[in\\] The index of the entry to be queried. -# Returns -The *index*-th entry of *array* as [`t8_gloidx_t`](@ref). +* `element`:\\[in\\] An element. +* `leaf_elements`:\\[in\\] An array of leaf elements of *element*. Thus, all elements must be descendants. Sorted by linear index. +* `offsets`:\\[in,out\\] On input an allocated array of *num_children_of_E* + 1 entries. On output entry i indicates the position in *leaf_elements* where the descandents of the i-th child of E start. ### Prototype ```c -t8_gloidx_t t8_shmem_array_get_gloidx (t8_shmem_array_t array, int index); +void t8_forest_split_array (const t8_element_t *element, const t8_element_array_t *leaf_elements, size_t *offsets); ``` """ -function t8_shmem_array_get_gloidx(array, index) - @ccall libt8.t8_shmem_array_get_gloidx(array::t8_shmem_array_t, index::Cint)::t8_gloidx_t +function t8_forest_split_array(element, leaf_elements, offsets) + @ccall libt8.t8_forest_split_array(element::Ptr{t8_element_t}, leaf_elements::Ptr{t8_element_array_t}, offsets::Ptr{Csize_t})::Cvoid end """ - t8_shmem_array_get_array(array) + t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, tree_lindex_of_first_leaf, callback, user_data) -Return a pointer to the data array of a [`t8_shmem_array`](@ref). +Iterate over all leaves of an element that touch a given face of the element. Callback is called in each recursive step with element as input. leaf\\_index is only not negative if element is a leaf, in which case it indicates the index of the leaf in the leaves of the tree. If it is negative, it is - (index + 1) Top-down iteration and callback is called on each intermediate level. If it returns false, the current element is not traversed further !!! note - Writing mode must be disabled for *array*. + *tree_lindex_of_first_leaf* is not an index in *leaf_elements*. *leaf_elements* may only be a part of the tree's leaves. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref). -# Returns -A pointer to the data array of *array*. +* `forest`:\\[in\\] A committed forest. +* `ltreeid`:\\[in\\] Local index of the tree containing the *element*. +* `element`:\\[in\\] The considered element. +* `face`:\\[in\\] The integer index of the considered face of *element*. +* `leaf_elements`:\\[in\\] The array of leaf elements that are descendants of *element*. Sorted by linear index. +* `tree_lindex_of_first_leaf`:\\[in\\] Index of the first leaf of *element* in the tree's leaves. The corresponding leaf does not necessarily lie on the face of *element*. +* `callback`:\\[in\\] The callback function. +* `user_data`:\\[in\\] The user data passed to the *callback* function. ### Prototype ```c -const void * t8_shmem_array_get_array (t8_shmem_array_t array); +void t8_forest_iterate_faces (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int face, const t8_element_array_t *const leaf_elements, const t8_locidx_t tree_lindex_of_first_leaf, const t8_forest_iterate_face_fn callback, void *user_data); ``` """ -function t8_shmem_array_get_array(array) - @ccall libt8.t8_shmem_array_get_array(array::t8_shmem_array_t)::Ptr{Cvoid} +function t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, tree_lindex_of_first_leaf, callback, user_data) + @ccall libt8.t8_forest_iterate_faces(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, leaf_elements::Ptr{t8_element_array_t}, tree_lindex_of_first_leaf::t8_locidx_t, callback::t8_forest_iterate_face_fn, user_data::Ptr{Cvoid})::Cvoid end """ - t8_shmem_array_index(array, index) - -Return a read-only pointer to an element in a [`t8_shmem_array`](@ref). - -!!! note - - You should not modify the value. - -!!! note + t8_forest_search(forest, search_fn, query_fn, queries) - Writing mode must be disabled for *array*. +Perform a top-down search of the forest, executing a callback on each intermediate element. The search will enter each tree at least once. If the callback returns false for an element, its descendants are not further searched. To pass user data to the search\\_fn function use t8_forest_set_user_data. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref). -* `index`:\\[in\\] The index of an element. -# Returns -A pointer to the element at *index* in *array*. +* `forest`:\\[in\\] The forest. +* `search_fn`:\\[in\\] The callback function describing the search criterion. +* `query_fn`:\\[in\\] The query function. +* `queries`:\\[in\\] The array of queries. ### Prototype ```c -const void * t8_shmem_array_index (t8_shmem_array_t array, size_t index); +void t8_forest_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries); ``` """ -function t8_shmem_array_index(array, index) - @ccall libt8.t8_shmem_array_index(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} +function t8_forest_search(forest, search_fn, query_fn, queries) + @ccall libt8.t8_forest_search(forest::t8_forest_t, search_fn::t8_forest_search_fn, query_fn::t8_forest_query_fn, queries::Ptr{sc_array_t})::Cvoid end """ - t8_shmem_array_index_for_writing(array, index) - -Return a pointer to an element in a [`t8_shmem_array`](@ref) in writing mode. - -!!! note + t8_forest_iterate_replace(forest_new, forest_old, replace_fn) - You can modify the value before the next call to t8_shmem_array_end_writing. +Given two forest where the elements in one forest are either direct children or parents of the elements in the other forest compare the two forests and for each refined element or coarsened family in the old one, call a callback function providing the local indices of the old and new elements. !!! note - Writing mode must be enabled for *array*. + To pass a user pointer to *replace_fn* use t8_forest_set_user_data and t8_forest_get_user_data. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref). -* `index`:\\[in\\] The index of an element. -# Returns -A pointer to the element at *index* in *array*. +* `forest_new`:\\[in\\] A forest, each element is a parent or child of an element in *forest_old*. +* `forest_old`:\\[in\\] The initial forest. +* `replace_fn`:\\[in\\] A replace callback function. ### Prototype ```c -void * t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index); +void t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_forest_replace_t replace_fn); ``` """ -function t8_shmem_array_index_for_writing(array, index) - @ccall libt8.t8_shmem_array_index_for_writing(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} +function t8_forest_iterate_replace(forest_new, forest_old, replace_fn) + @ccall libt8.t8_forest_iterate_replace(forest_new::t8_forest_t, forest_old::t8_forest_t, replace_fn::t8_forest_replace_t)::Cvoid end """ - t8_shmem_array_is_equal(array_a, array_b) + t8_forest_search_partition(forest, search_fn, query_fn, queries) + +Perform a top-down search of the global partition, executing a callback on each intermediate element. The search will enter each tree at least once. The recursion will only go down branches that are split between multiple processors. This is not a collective function. It does not communicate. The function expects the coarse mesh to be replicated. If the callback returns false for an element, its descendants are not further searched. To pass user data to **search_fn** function use t8_forest_set_user_data +# Arguments +* `forest`:\\[in\\] the forest to be searched +* `search_fn`:\\[in\\] a search callback function called on elements +* `query_fn`:\\[in\\] a query callback function called for all active queries of an element +* `queries`:\\[in,out\\] an array of queries that are checked by the function ### Prototype ```c -int t8_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b); +void t8_forest_search_partition (const t8_forest_t forest, t8_forest_partition_search_fn search_fn, t8_forest_partition_query_fn query_fn, sc_array_t *queries); ``` """ -function t8_shmem_array_is_equal(array_a, array_b) - @ccall libt8.t8_shmem_array_is_equal(array_a::t8_shmem_array_t, array_b::t8_shmem_array_t)::Cint +function t8_forest_search_partition(forest, search_fn, query_fn, queries) + @ccall libt8.t8_forest_search_partition(forest::t8_forest_t, search_fn::t8_forest_partition_search_fn, query_fn::t8_forest_partition_query_fn, queries::Ptr{sc_array_t})::Cvoid end """ - t8_shmem_array_destroy(parray) + t8_forest_partition(forest) -Free all memory associated with a [`t8_shmem_array`](@ref). +Populate a forest with the partitioned elements of forest->set\\_from. # Arguments -* `parray`:\\[in,out\\] On input a pointer to a valid [`t8_shmem_array`](@ref). This array is freed and *parray* is set to NULL on return. +* `forest`:\\[in,out\\] The forest. ### Prototype ```c -void t8_shmem_array_destroy (t8_shmem_array_t *parray); +void t8_forest_partition (t8_forest_t forest); ``` """ -function t8_shmem_array_destroy(parray) - @ccall libt8.t8_shmem_array_destroy(parray::Ptr{t8_shmem_array_t})::Cvoid +function t8_forest_partition(forest) + @ccall libt8.t8_forest_partition(forest::t8_forest_t)::Cvoid end """ - t8_forest_adapt(forest) + t8_forest_new_gather(forest_from, gather_rank) -### Prototype -```c -void t8_forest_adapt (t8_forest_t forest); -``` -""" -function t8_forest_adapt(forest) - @ccall libt8.t8_forest_adapt(forest::t8_forest_t)::Cvoid -end +Create a new forest that gathers a given forest on one process. -""" - t8_forest_balance(forest, repartition) +This functionality is mostly required for comparison purposes and sanity checks within the testing framework. +# Arguments +* `forest_from`:\\[in\\] the forest that should be gathered on one rank +* `gather_rank`:\\[in\\] the rank of the process the forest will be gathered on +# Returns +The gathered forest: The same as *forest_from*, but all elements are on rank *gather_rank*. ### Prototype ```c -void t8_forest_balance (t8_forest_t forest, int repartition); +t8_forest_t t8_forest_new_gather (const t8_forest_t forest_from, const int gather_rank); ``` """ -function t8_forest_balance(forest, repartition) - @ccall libt8.t8_forest_balance(forest::t8_forest_t, repartition::Cint)::Cvoid +function t8_forest_new_gather(forest_from, gather_rank) + @ccall libt8.t8_forest_new_gather(forest_from::t8_forest_t, gather_rank::Cint)::t8_forest_t end """ - t8_forest_is_balanced(forest) + t8_forest_set_partition_offset(forest, first_global_element) + +Manually set the partition offset of the current process. +If set, the next partitioning of the forest will use the manually defined element offsets. + +# Arguments +* `forest`:\\[in,out\\] the considered forest +* `first_global_element`:\\[in\\] the global ID that will become the first local element ### Prototype ```c -int t8_forest_is_balanced (t8_forest_t forest); +void t8_forest_set_partition_offset (t8_forest_t forest, const t8_gloidx_t first_global_element); ``` """ -function t8_forest_is_balanced(forest) - @ccall libt8.t8_forest_is_balanced(forest::t8_forest_t)::Cint -end - -""" - t8_tree - -The t8 tree datatype - -| Field | Note | -| :---------------- | :----------------------------------------------------------------- | -| elements | locally stored elements | -| eclass | The element class of this tree | -| first\\_desc | first local descendant | -| last\\_desc | last local descendant | -| elements\\_offset | cumulative sum over earlier trees on this processor (locals only) | -""" -struct t8_tree - elements::t8_element_array_t - eclass::t8_eclass_t - first_desc::Ptr{t8_element_t} - last_desc::Ptr{t8_element_t} - elements_offset::t8_locidx_t +function t8_forest_set_partition_offset(forest, first_global_element) + @ccall libt8.t8_forest_set_partition_offset(forest::t8_forest_t, first_global_element::t8_gloidx_t)::Cvoid end -const t8_tree_t = Ptr{t8_tree} - """ - t8_ghost_type_t + t8_forest_partition_create_offsets(forest) -This type controls, which neighbors count as ghost elements. Currently, we support face-neighbors. Vertex and edge neighbors will eventually be added. +Create the element\\_offset array of a partitioned forest. -| Enumerator | Note | -| :-------------------- | :---------------------------------------------------------------- | -| T8\\_GHOST\\_NONE | Do not create ghost layer. | -| T8\\_GHOST\\_FACES | Consider all face (codimension 1) neighbors. | -| T8\\_GHOST\\_EDGES | Consider all edge (codimension 2) and face neighbors. | -| T8\\_GHOST\\_VERTICES | Consider all vertex (codimension 3) and edge and face neighbors. | +# Arguments +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +### Prototype +```c +void t8_forest_partition_create_offsets (t8_forest_t forest); +``` """ -@cenum t8_ghost_type_t::UInt32 begin - T8_GHOST_NONE = 0 - T8_GHOST_FACES = 1 - T8_GHOST_EDGES = 2 - T8_GHOST_VERTICES = 3 +function t8_forest_partition_create_offsets(forest) + @ccall libt8.t8_forest_partition_create_offsets(forest::t8_forest_t)::Cvoid end -# typedef void ( * t8_generic_function_pointer ) ( void ) -""" -This typedef is needed as a helper construct to properly be able to define a function that returns a pointer to a void fun(void) function. - -# See also -[`t8_forest_get_user_function`](@ref). -""" -const t8_generic_function_pointer = Ptr{Cvoid} - -# typedef void ( * t8_forest_replace_t ) ( t8_forest_t forest_old , t8_forest_t forest_new , t8_locidx_t which_tree , t8_eclass_scheme_c * ts , const int refine , const int num_outgoing , const t8_locidx_t first_outgoing , const int num_incoming , const t8_locidx_t first_incoming ) -""" -Callback function prototype to replace one set of elements with another. - -This is used by the replace routine which can be called after adapt, when the elements of an existing, valid forest are changed. The callback allows the user to make changes to the elements of the new forest that are either refined, coarsened or the same as elements in the old forest. - -If an element is being refined, *refine* and *num_outgoing* will be 1 and *num_incoming* will be the number of children. If a family is being coarsened, *refine* will be -1, *num_outgoing* will be the number of family members and *num_incoming* will be 1. If an element is being removed, *refine* and *num_outgoing* will be 1 and *num_incoming* will be 0. Else *refine* will be 0 and *num_outgoing* and *num_incoming* will both be 1. - -# Arguments -* `forest_old`:\\[in\\] The forest that is adapted -* `forest_new`:\\[in\\] The forest that is newly constructed from *forest_old* -* `which_tree`:\\[in\\] The local tree containing *first_outgoing* and *first_incoming* -* `ts`:\\[in\\] The eclass scheme of the tree -* `refine`:\\[in\\] -1 if family in *forest_old* got coarsened, 0 if element has not been touched, 1 if element got refined and -2 if element got removed. See return of [`t8_forest_adapt_t`](@ref). -* `num_outgoing`:\\[in\\] The number of outgoing elements. -* `first_outgoing`:\\[in\\] The tree local index of the first outgoing element. 0 <= first\\_outgoing < which\\_tree->num\\_elements -* `num_incoming`:\\[in\\] The number of incoming elements. -* `first_incoming`:\\[in\\] The tree local index of the first incoming element. 0 <= first\\_incom < new\\_which\\_tree->num\\_elements -# See also -[`t8_forest_iterate_replace`](@ref) """ -const t8_forest_replace_t = Ptr{Cvoid} + t8_forest_partition_next_nonempty_rank(forest, rank) -# typedef int ( * t8_forest_adapt_t ) ( t8_forest_t forest , t8_forest_t forest_from , t8_locidx_t which_tree , t8_locidx_t lelement_id , t8_eclass_scheme_c * ts , const int is_family , const int num_elements , t8_element_t * elements [ ] ) -""" -Callback function prototype to decide for refining and coarsening. If *is_family* equals 1, the first *num_elements* in *elements* form a family and we decide whether this family should be coarsened or only the first element should be refined. Otherwise *is_family* must equal zero and we consider the first entry of the element array for refinement. Entries of the element array beyond the first *num_elements* are undefined. +If t8_forest_partition_create_offsets was already called, compute for a given rank the next greater rank that is not empty. # Arguments -* `forest`:\\[in\\] the forest to which the new elements belong -* `forest_from`:\\[in\\] the forest that is adapted. -* `which_tree`:\\[in\\] the local tree containing *elements* -* `lelement_id`:\\[in\\] the local element id in *forest_old* in the tree of the current element -* `ts`:\\[in\\] the eclass scheme of the tree -* `is_family`:\\[in\\] if 1, the first *num_elements* entries in *elements* form a family. If 0, they do not. -* `num_elements`:\\[in\\] the number of entries in *elements* that are defined -* `elements`:\\[in\\] Pointers to a family or, if *is_family* is zero, pointer to one element. +* `forest`:\\[in\\] The forest. +* `rank`:\\[in\\] An MPI rank. # Returns -1 if the first entry in *elements* should be refined, -1 if the family *elements* shall be coarsened, -2 if the first entry in *elements* should be removed, 0 else. +A rank q > *rank* such that the forest has elements on *q*. If such a *q* does not exist, returns mpisize. +### Prototype +```c +int t8_forest_partition_next_nonempty_rank (t8_forest_t forest, int rank); +``` """ -const t8_forest_adapt_t = Ptr{Cvoid} +function t8_forest_partition_next_nonempty_rank(forest, rank) + @ccall libt8.t8_forest_partition_next_nonempty_rank(forest::t8_forest_t, rank::Cint)::Cint +end """ - t8_forest_init(pforest) + t8_forest_partition_create_first_desc(forest) -Create a new forest with reference count one. This forest needs to be specialized with the t8\\_forest\\_set\\_* calls. Currently it is manatory to either call the functions t8_forest_set_mpicomm, t8_forest_set_cmesh, and t8_forest_set_scheme, or to call one of t8_forest_set_copy, t8_forest_set_adapt, or t8_forest_set_partition. It is illegal to mix these calls, or to call more than one of the three latter functions Then it needs to be set up with t8_forest_commit. +Create the array of global\\_first\\_descendant ids of a partitioned forest. # Arguments -* `pforest`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new forest. +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -void t8_forest_init (t8_forest_t *pforest); +void t8_forest_partition_create_first_desc (t8_forest_t forest); ``` """ -function t8_forest_init(pforest) - @ccall libt8.t8_forest_init(pforest::Ptr{t8_forest_t})::Cvoid +function t8_forest_partition_create_first_desc(forest) + @ccall libt8.t8_forest_partition_create_first_desc(forest::t8_forest_t)::Cvoid end """ - t8_forest_is_initialized(forest) + t8_forest_partition_create_tree_offsets(forest) -Check whether a forest is not NULL, initialized and not committed. In addition, it asserts that the forest is consistent as much as possible. +Create the array tree offsets of a partitioned forest. This arrays stores at position p the global id of the first tree of this process. Or if this tree is shared, it stores -(global\\_id) - 1. # Arguments -* `forest`:\\[in\\] This forest is examined. May be NULL. -# Returns -True if forest is not NULL, t8_forest_init has been called on it, but not t8_forest_commit. False otherwise. +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -int t8_forest_is_initialized (t8_forest_t forest); +void t8_forest_partition_create_tree_offsets (t8_forest_t forest); ``` """ -function t8_forest_is_initialized(forest) - @ccall libt8.t8_forest_is_initialized(forest::t8_forest_t)::Cint +function t8_forest_partition_create_tree_offsets(forest) + @ccall libt8.t8_forest_partition_create_tree_offsets(forest::t8_forest_t)::Cvoid end """ - t8_forest_is_committed(forest) + t8_forest_partition_data(forest_from, forest_to, data_in, data_out) -Check whether a forest is not NULL, initialized and committed. In addition, it asserts that the forest is consistent as much as possible. +Re-Partition an array accordingly to a partitioned forest. + +!!! note + + *data_in* has to be of size equal to the number of local elements of *forest_from* *data_out* has to be already allocated and has to be of size equal to the number of local elements of *forest_to*. # Arguments -* `forest`:\\[in\\] This forest is examined. May be NULL. -# Returns -True if forest is not NULL and t8_forest_init has been called on it as well as t8_forest_commit. False otherwise. +* `forest_from`:\\[in\\] The forest before the partitioning step. +* `forest_to`:\\[in\\] The partitioned forest of *forest_from*. +* `data_in`:\\[in\\] A pointer to an [`sc_array_t`](@ref) holding data (one value per element) accordingly to *forest_from*. +* `data_out`:\\[in,out\\] A pointer to an already allocated [`sc_array_t`](@ref) capable of holding data accordingly to *forest_to*. ### Prototype ```c -int t8_forest_is_committed (t8_forest_t forest); +void t8_forest_partition_data (t8_forest_t forest_from, t8_forest_t forest_to, const sc_array_t *data_in, sc_array_t *data_out); ``` """ -function t8_forest_is_committed(forest) - @ccall libt8.t8_forest_is_committed(forest::t8_forest_t)::Cint +function t8_forest_partition_data(forest_from, forest_to, data_in, data_out) + @ccall libt8.t8_forest_partition_data(forest_from::t8_forest_t, forest_to::t8_forest_t, data_in::Ptr{sc_array_t}, data_out::Ptr{sc_array_t})::Cvoid end """ - t8_forest_no_overlap(forest) + t8_forest_partition_test_boundary_element(forest) -Check whether the forest has local overlapping elements. +Test if the last descendant of the last element of current rank has a smaller linear id than the stored first descendant of rank+1. If this is not the case, elements overlap. !!! note - This function is collective, but only checks local overlapping on each process. + *forest* must be committed before calling this function. # Arguments -* `forest`:\\[in\\] The forest to consider. -# Returns -True if *forest* has no elements which are inside each other. -# See also -[`t8_forest_partition_test_boundary_element`](@ref) if you also want to test for global overlap across the process boundaries. - +* `forest`:\\[in\\] The forest. ### Prototype ```c -int t8_forest_no_overlap (t8_forest_t forest); +void t8_forest_partition_test_boundary_element (const t8_forest_t forest); ``` """ -function t8_forest_no_overlap(forest) - @ccall libt8.t8_forest_no_overlap(forest::t8_forest_t)::Cint +function t8_forest_partition_test_boundary_element(forest) + @ccall libt8.t8_forest_partition_test_boundary_element(forest::t8_forest_t)::Cvoid end """ - t8_forest_is_equal(forest_a, forest_b) - -Check whether two committed forests have the same local elements. + t8_forest_pfc_correction_offsets(forest) -!!! note +Correct the partitioning if element families are split across process boundaries. - This function is not collective. It only returns the state on the current rank. +The default partitioning distributes the elements into equally-sized partitions. For coarsening, however, all elements of a family have to be on the same process in order to be coarsened into their parent element. This function corrects the partitioning such that no families are split across process boundaries. The price to be paid is a slight deviation from the optimal balance of elements among processors. # Arguments -* `forest_a`:\\[in\\] The first forest. -* `forest_b`:\\[in\\] The second forest. -# Returns -True if *forest_a* and *forest_b* do have the same number of local trees and each local tree has the same elements, that is t8_element_equal returns true for each pair of elements of *forest_a* and *forest_b*. +* `forest`:\\[in,out\\] the forest. On input, it has been partitioned into equally-sized element partitions. On output, the partitioning has been adjusted such that no element families are split across the process boundaries. ### Prototype ```c -int t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b); +void t8_forest_pfc_correction_offsets (t8_forest_t forest); ``` """ -function t8_forest_is_equal(forest_a, forest_b) - @ccall libt8.t8_forest_is_equal(forest_a::t8_forest_t, forest_b::t8_forest_t)::Cint +function t8_forest_pfc_correction_offsets(forest) + @ccall libt8.t8_forest_pfc_correction_offsets(forest::t8_forest_t)::Cvoid end """ - t8_forest_set_cmesh(forest, cmesh, comm) + t8_forest_set_profiling(forest, set_profiling) ### Prototype ```c -void t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); +void t8_forest_set_profiling (t8_forest_t forest, int set_profiling); ``` """ -function t8_forest_set_cmesh(forest, cmesh, comm) - @ccall libt8.t8_forest_set_cmesh(forest::t8_forest_t, cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_forest_set_profiling(forest, set_profiling) + @ccall libt8.t8_forest_set_profiling(forest::t8_forest_t, set_profiling::Cint)::Cvoid end """ - t8_forest_set_scheme(forest, scheme) - -Set the element scheme associated to a forest. By default, the forest takes ownership of the scheme such that it will be destroyed when the forest is destroyed. To keep ownership of the scheme, call t8_scheme_ref before passing it to t8_forest_set_scheme. This means that it is ILLEGAL to continue using scheme or dereferencing it UNLESS it is referenced directly before passing it into this function. + t8_forest_compute_profile(forest) -# Arguments -* `forest`:\\[in,out\\] The forest whose scheme variable will be set. -* `scheme`:\\[in\\] The scheme to be set. We take ownership. This can be prevented by referencing **scheme**. ### Prototype ```c -void t8_forest_set_scheme (t8_forest_t forest, t8_scheme_cxx_t *scheme); +void t8_forest_compute_profile (t8_forest_t forest); ``` """ -function t8_forest_set_scheme(forest, scheme) - @ccall libt8.t8_forest_set_scheme(forest::t8_forest_t, scheme::Ptr{t8_scheme_cxx_t})::Cvoid +function t8_forest_compute_profile(forest) + @ccall libt8.t8_forest_compute_profile(forest::t8_forest_t)::Cvoid end """ - t8_forest_set_level(forest, level) - -Set the initial refinement level to be used when **forest** is committed. + t8_forest_profile_get_adapt_stats(forest) -!!! note +### Prototype +```c +const sc_statinfo_t * t8_forest_profile_get_adapt_stats (t8_forest_t forest); +``` +""" +function t8_forest_profile_get_adapt_stats(forest) + @ccall libt8.t8_forest_profile_get_adapt_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +end - This setting cannot be combined with any of the derived forest methods (t8_forest_set_copy, t8_forest_set_adapt, t8_forest_set_partition, and t8_forest_set_balance) and overwrites any of these settings. If this function is used, then the forest is created from scratch as a uniform refinement of the specified cmesh (t8_forest_set_cmesh, t8_forest_set_scheme). +""" + t8_forest_profile_get_ghost_stats(forest) -# Arguments -* `forest`:\\[in,out\\] The forest whose level will be set. -* `level`:\\[in\\] The initial refinement level of **forest**, when it is committed. ### Prototype ```c -void t8_forest_set_level (t8_forest_t forest, int level); +const sc_statinfo_t * t8_forest_profile_get_ghost_stats (t8_forest_t forest); ``` """ -function t8_forest_set_level(forest, level) - @ccall libt8.t8_forest_set_level(forest::t8_forest_t, level::Cint)::Cvoid +function t8_forest_profile_get_ghost_stats(forest) + @ccall libt8.t8_forest_profile_get_ghost_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_forest_set_copy(forest, from) + t8_forest_profile_get_partition_stats(forest) -Set a forest as source for copying on committing. By default, the forest takes ownership of the source **from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **from** or dereferencing it UNLESS it is referenced directly before passing it into this function. +### Prototype +```c +const sc_statinfo_t * t8_forest_profile_get_partition_stats (t8_forest_t forest); +``` +""" +function t8_forest_profile_get_partition_stats(forest) + @ccall libt8.t8_forest_profile_get_partition_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +end -!!! note +""" + t8_forest_profile_get_commit_stats(forest) - This setting cannot be combined with t8_forest_set_adapt, t8_forest_set_partition, or t8_forest_set_balance and overwrites these settings. +### Prototype +```c +const sc_statinfo_t * t8_forest_profile_get_commit_stats (t8_forest_t forest); +``` +""" +function t8_forest_profile_get_commit_stats(forest) + @ccall libt8.t8_forest_profile_get_commit_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +end + +""" + t8_forest_profile_get_balance_stats(forest) -# Arguments -* `forest`:\\[in,out\\] The forest. -* `from`:\\[in\\] A second forest from which *forest* will be copied in t8_forest_commit. ### Prototype ```c -void t8_forest_set_copy (t8_forest_t forest, const t8_forest_t from); +const sc_statinfo_t * t8_forest_profile_get_balance_stats (t8_forest_t forest); ``` """ -function t8_forest_set_copy(forest, from) - @ccall libt8.t8_forest_set_copy(forest::t8_forest_t, from::t8_forest_t)::Cvoid +function t8_forest_profile_get_balance_stats(forest) + @ccall libt8.t8_forest_profile_get_balance_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) + t8_forest_profile_get_balance_rounds_stats(forest) -Set a source forest with an adapt function to be adapted on committing. By default, the forest takes ownership of the source **set_from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **set_from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **set_from** or dereferencing it UNLESS it is referenced directly before passing it into this function. +### Prototype +```c +const sc_statinfo_t * t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); +``` +""" +function t8_forest_profile_get_balance_rounds_stats(forest) + @ccall libt8.t8_forest_profile_get_balance_rounds_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +end -!!! note +""" + t8_forest_print_profile(forest) - This setting can be combined with t8_forest_set_partition and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Balance 3) Partition +### Prototype +```c +void t8_forest_print_profile (t8_forest_t forest); +``` +""" +function t8_forest_print_profile(forest) + @ccall libt8.t8_forest_print_profile(forest::t8_forest_t)::Cvoid +end -!!! note +""" + t8_forest_profile_get_adapt_time(forest) - This setting may not be combined with t8_forest_set_copy and overwrites this setting. +### Prototype +```c +double t8_forest_profile_get_adapt_time (t8_forest_t forest); +``` +""" +function t8_forest_profile_get_adapt_time(forest) + @ccall libt8.t8_forest_profile_get_adapt_time(forest::t8_forest_t)::Cdouble +end + +""" + t8_forest_profile_get_partition_time(forest, procs_sent) -# Arguments -* `forest`:\\[in,out\\] The forest -* `set_from`:\\[in\\] The source forest from which **forest** will be adapted. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_partition, t8_forest_set_balance). -* `adapt_fn`:\\[in\\] The adapt function used on committing. -* `recursive`:\\[in\\] A flag specifying whether adaptation is to be done recursively or not. If the value is zero, adaptation is not recursive and it is recursive otherwise. ### Prototype ```c -void t8_forest_set_adapt (t8_forest_t forest, const t8_forest_t set_from, t8_forest_adapt_t adapt_fn, int recursive); +double t8_forest_profile_get_partition_time (t8_forest_t forest, int *procs_sent); ``` """ -function t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) - @ccall libt8.t8_forest_set_adapt(forest::t8_forest_t, set_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint)::Cvoid +function t8_forest_profile_get_partition_time(forest, procs_sent) + @ccall libt8.t8_forest_profile_get_partition_time(forest::t8_forest_t, procs_sent::Ptr{Cint})::Cdouble end """ - t8_forest_set_user_data(forest, data) + t8_forest_profile_get_balance_time(forest, balance_rounds) -Set the user data of a forest. This can i.e. be used to pass user defined arguments to the adapt routine. +### Prototype +```c +double t8_forest_profile_get_balance_time (t8_forest_t forest, int *balance_rounds); +``` +""" +function t8_forest_profile_get_balance_time(forest, balance_rounds) + @ccall libt8.t8_forest_profile_get_balance_time(forest::t8_forest_t, balance_rounds::Ptr{Cint})::Cdouble +end -# Arguments -* `forest`:\\[in,out\\] The forest -* `data`:\\[in\\] A pointer to user data. t8code will never touch the data. The forest does not need be committed before calling this function. -# See also -[`t8_forest_get_user_data`](@ref) +""" + t8_forest_profile_get_ghost_time(forest, ghosts_sent) ### Prototype ```c -void t8_forest_set_user_data (t8_forest_t forest, void *data); +double t8_forest_profile_get_ghost_time (t8_forest_t forest, t8_locidx_t *ghosts_sent); ``` """ -function t8_forest_set_user_data(forest, data) - @ccall libt8.t8_forest_set_user_data(forest::t8_forest_t, data::Ptr{Cvoid})::Cvoid +function t8_forest_profile_get_ghost_time(forest, ghosts_sent) + @ccall libt8.t8_forest_profile_get_ghost_time(forest::t8_forest_t, ghosts_sent::Ptr{Cint})::Cdouble end """ - t8_forest_get_user_data(forest) + t8_forest_profile_get_ghostexchange_waittime(forest) -Return the user data pointer associated with a forest. +### Prototype +```c +double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest); +``` +""" +function t8_forest_profile_get_ghostexchange_waittime(forest) + @ccall libt8.t8_forest_profile_get_ghostexchange_waittime(forest::t8_forest_t)::Cdouble +end -# Arguments -* `forest`:\\[in\\] The forest. -# Returns -The user data pointer of *forest*. The forest does not need be committed before calling this function. -# See also -[`t8_forest_set_user_data`](@ref) +""" + t8_forest_profile_get_cmesh_offsets_runtime(forest) ### Prototype ```c -void * t8_forest_get_user_data (const t8_forest_t forest); +double t8_forest_profile_get_cmesh_offsets_runtime (t8_forest_t forest); ``` """ -function t8_forest_get_user_data(forest) - @ccall libt8.t8_forest_get_user_data(forest::t8_forest_t)::Ptr{Cvoid} +function t8_forest_profile_get_cmesh_offsets_runtime(forest) + @ccall libt8.t8_forest_profile_get_cmesh_offsets_runtime(forest::t8_forest_t)::Cdouble end """ - t8_forest_set_user_function(forest, _function) - -Set the user function pointer of a forest. This can i.e. be used to pass user defined functions to the adapt routine. - -!!! note - - *function* can be an arbitrary function with return value and parameters of your choice. When accessing it with t8_forest_get_user_function you should cast it into the proper type. - -# Arguments -* `forest`:\\[in,out\\] The forest -* `function`:\\[in\\] A pointer to a user defined function. t8code will never touch the function. The forest does not need be committed before calling this function. -# See also -[`t8_forest_get_user_function`](@ref) + t8_forest_profile_get_forest_offsets_runtime(forest) ### Prototype ```c -void t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer function); +double t8_forest_profile_get_forest_offsets_runtime (t8_forest_t forest); ``` """ -function t8_forest_set_user_function(forest, _function) - @ccall libt8.t8_forest_set_user_function(forest::t8_forest_t, _function::t8_generic_function_pointer)::Cvoid +function t8_forest_profile_get_forest_offsets_runtime(forest) + @ccall libt8.t8_forest_profile_get_forest_offsets_runtime(forest::t8_forest_t)::Cdouble end """ - t8_forest_get_user_function(forest) - -Return the user function pointer associated with a forest. - -# Arguments -* `forest`:\\[in\\] The forest. -# Returns -The user function pointer of *forest*. The forest does not need be committed before calling this function. -# See also -[`t8_forest_set_user_function`](@ref) + t8_forest_profile_get_first_descendant_runtime(forest) ### Prototype ```c -t8_generic_function_pointer t8_forest_get_user_function (const t8_forest_t forest); +double t8_forest_profile_get_first_descendant_runtime (t8_forest_t forest); ``` """ -function t8_forest_get_user_function(forest) - @ccall libt8.t8_forest_get_user_function(forest::t8_forest_t)::t8_generic_function_pointer +function t8_forest_profile_get_first_descendant_runtime(forest) + @ccall libt8.t8_forest_profile_get_first_descendant_runtime(forest::t8_forest_t)::Cdouble end """ - t8_forest_set_partition(forest, set_from, set_for_coarsening) + t8_profile -Set a source forest to be partitioned during commit. The partitioning is done according to the SFC and each rank is assigned the same (maybe +1) number of elements. +This struct holds profiling information, such as timings or statistics about communication. + +| Field | Note | +| :----------------------------- | :------------------------------------------------------------------------------------------------------------- | +| partition\\_elements\\_shipped | The number of elements this process has sent to other in the last partition call. | +| partition\\_elements\\_recv | The number of elements this process has received from other in the last partition call. | +| partition\\_bytes\\_sent | The total number of bytes sent to other processes in the last partition call. | +| partition\\_procs\\_sent | The number of different processes this process has send local elements to in the last partition call. | +| ghosts\\_shipped | The number of ghost elements this process has sent to other processes. | +| ghosts\\_received | The number of ghost elements this process has received from other processes. | +| ghosts\\_remotes | The number of processes this process have sent ghost elements to (and received from). | +| balance\\_rounds | The number of iterations during balance. | +| adapt\\_runtime | The runtime of the last call to [`t8_forest_adapt`](@ref) (not counting adaptation in t8\\_forest\\_balance). | +| partition\\_runtime | The runtime of the last call to *t8_cmesh_partition* (not count in partition in t8\\_forest\\_balance). | +| ghost\\_runtime | The runtime of the last call to [`t8_forest_ghost_create`](@ref). | +| ghost\\_waittime | Amount of synchronisation time in ghost. | +| balance\\_runtime | The runtime of the last call to *t8_forest_balance*. | +| commit\\_runtime | The runtime of the last call to [`t8_cmesh_commit`](@ref). | +| cmesh\\_offsets\\_runtime | The runtime of the last call to [`t8_forest_partition_create_tree_offsets`](@ref). | +| forest\\_offsets\\_runtime | The runtime of the last call to [`t8_forest_partition_create_offsets`](@ref). | +| first\\_descendant\\_runtime | The runtime of the last call to [`t8_forest_partition_create_first_desc`](@ref). | +""" +struct t8_profile + partition_elements_shipped::t8_locidx_t + partition_elements_recv::t8_locidx_t + partition_bytes_sent::Csize_t + partition_procs_sent::Cint + ghosts_shipped::t8_locidx_t + ghosts_received::t8_locidx_t + ghosts_remotes::Cint + balance_rounds::Cint + adapt_runtime::Cdouble + partition_runtime::Cdouble + ghost_runtime::Cdouble + ghost_waittime::Cdouble + balance_runtime::Cdouble + commit_runtime::Cdouble + cmesh_offsets_runtime::Cdouble + forest_offsets_runtime::Cdouble + first_descendant_runtime::Cdouble +end -!!! note +"""This struct holds profiling information, such as timings or statistics about communication.""" +const t8_profile_t = t8_profile - This setting can be combined with t8_forest_set_adapt and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Balance 3) Partition If t8_forest_set_balance is called with the *no_repartition* parameter set as false, it is not necessary to call t8_forest_set_partition additionally. +"""If a forest is to be derived from another forest, there are different possibilities how the original forest is modified. Currently we support: Copying, adapting, partitioning, and balancing a forest. The latter 3 can be combined, in which case the order is 1. Adapt, 2. Partition, 3. Balance. We store the methods in an int8\\_t and use these defines to distinguish between them.""" +const t8_forest_from_t = Int8 -!!! note +"""This structure is private to the implementation.""" +const t8_forest_struct_t = t8_forest - This setting may not be combined with t8_forest_set_copy and overwrites this setting. +"""The t8 tree datatype""" +const t8_tree_struct_t = t8_tree + +"""This struct holds profiling information, such as timings or statistics about communication.""" +const t8_profile_struct_t = t8_profile + +"""This struct stores various information about a forest's ghost elements and ghost trees.""" +const t8_forest_ghost_struct_t = t8_forest_ghost -# Arguments -* `forest`:\\[in,out\\] The forest. -* `set_from`:\\[in\\] A second forest that should be partitioned. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_balance). -* `set_for_coarsening`:\\[in\\] CURRENTLY DISABLED. If true, then the partitions are choose such that coarsening an element once is a process local operation. -### Prototype -```c -void t8_forest_set_partition (t8_forest_t forest, const t8_forest_t set_from, int set_for_coarsening); -``` """ -function t8_forest_set_partition(forest, set_from, set_for_coarsening) - @ccall libt8.t8_forest_set_partition(forest::t8_forest_t, set_from::t8_forest_t, set_for_coarsening::Cint)::Cvoid -end + t8_geometry_type + +This enumeration contains all possible geometries. +| Enumerator | Note | +| :--------------------------------------------- | :----------------------------------------------------------------------------------------------- | +| T8\\_GEOMETRY\\_TYPE\\_ZERO | The zero geometry maps all points to zero. | +| T8\\_GEOMETRY\\_TYPE\\_LINEAR | The linear geometry uses linear interpolations to interpolate between the tree vertices. | +| T8\\_GEOMETRY\\_TYPE\\_LINEAR\\_AXIS\\_ALIGNED | The linear, axis aligned geometry uses only 2 vertices, since it is axis aligned. | +| T8\\_GEOMETRY\\_TYPE\\_LAGRANGE | The Lagrange geometry uses a mapping with Lagrange polynomials to approximate curved elements . | +| T8\\_GEOMETRY\\_TYPE\\_ANALYTIC | The analytic geometry uses a user-defined analytic function to map into the physical domain. | +| T8\\_GEOMETRY\\_TYPE\\_CAD | The opencascade geometry uses CAD shapes to map trees exactly to the underlying CAD model. | +| T8\\_GEOMETRY\\_TYPE\\_COUNT | This is no geometry type but can be used as the number of geometry types. | +| T8\\_GEOMETRY\\_TYPE\\_INVALID | This is no geometry type but is used as error type to describe invalid geometries | +| T8\\_GEOMETRY\\_TYPE\\_UNDEFINED | This is no geometry type but is used for every geometry, where no type is defined | """ - t8_forest_set_balance(forest, set_from, no_repartition) +@cenum t8_geometry_type::UInt32 begin + T8_GEOMETRY_TYPE_ZERO = 0 + T8_GEOMETRY_TYPE_LINEAR = 1 + T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED = 2 + T8_GEOMETRY_TYPE_LAGRANGE = 3 + T8_GEOMETRY_TYPE_ANALYTIC = 4 + T8_GEOMETRY_TYPE_CAD = 5 + T8_GEOMETRY_TYPE_COUNT = 6 + T8_GEOMETRY_TYPE_INVALID = 7 + T8_GEOMETRY_TYPE_UNDEFINED = 8 +end -Set a source forest to be balanced during commit. A forest is said to be balanced if each element has face neighbors of level at most +1 or -1 of the element's level. +"""This enumeration contains all possible geometries.""" +const t8_geometry_type_t = t8_geometry_type -!!! note +mutable struct t8_geometry_handler end - This setting can be combined with t8_forest_set_adapt and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Balance 3) Partition. +"""This typedef holds virtual functions for the geometry handler. We need it so that we can use [`t8_geometry_handler_c`](@ref) pointers in .c files without them seeing the actual C++ code (and then not compiling) TODO: Delete this when the cmesh is a proper cpp class.""" +const t8_geometry_handler_c = t8_geometry_handler -!!! note +""" + t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) - This setting may not be combined with t8_forest_set_copy and overwrites this setting. +Evaluates the geometry of a tree at a given reference point. # Arguments -* `forest`:\\[in,out\\] The forest. -* `set_from`:\\[in\\] A second forest that should be balanced. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_partition) -* `no_repartition`:\\[in\\] Balance constructs several intermediate forest that are refined from each other. In order to maintain a balanced load these forest are repartitioned in each round and the resulting forest is load-balanced per default. If this behaviour is not desired, *no_repartition* should be set to true. If *no_repartition* is false, an additional call of t8_forest_set_partition is not necessary. +* `cmesh`:\\[in\\] The cmesh +* `gtreeid`:\\[in\\] The global id of the tree +* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the geometry +* `num_coords`:\\[in\\] The number of reference coordinates +* `out_coords`:\\[out\\] The evaluated coordinates ### Prototype ```c -void t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_repartition); +void t8_geometry_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords); ``` """ -function t8_forest_set_balance(forest, set_from, no_repartition) - @ccall libt8.t8_forest_set_balance(forest::t8_forest_t, set_from::t8_forest_t, no_repartition::Cint)::Cvoid +function t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) + @ccall libt8.t8_geometry_evaluate(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid end """ - t8_forest_set_ghost(forest, do_ghost, ghost_type) + t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) -Enable or disable the creation of a layer of ghost elements. On default no ghosts are created. +Evaluates the jacobian of a tree at a given reference point. # Arguments -* `forest`:\\[in\\] The forest. -* `do_ghost`:\\[in\\] If non-zero a ghost layer will be created. -* `ghost_type`:\\[in\\] Controls which neighbors count as ghost elements, currently only T8\\_GHOST\\_FACES is supported. This value is ignored if *do_ghost* = 0. +* `cmesh`:\\[in\\] The cmesh +* `gtreeid`:\\[in\\] The global id of the tree +* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the jacobian +* `num_coords`:\\[in\\] The number of reference coordinates +* `jacobian`:\\[out\\] The jacobian at the reference coordinates ### Prototype ```c -void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type); +void t8_geometry_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *jacobian); ``` """ -function t8_forest_set_ghost(forest, do_ghost, ghost_type) - @ccall libt8.t8_forest_set_ghost(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t)::Cvoid +function t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) + @ccall libt8.t8_geometry_jacobian(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, jacobian::Ptr{Cdouble})::Cvoid end """ - t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) + t8_geometry_get_type(cmesh, gtreeid) -Like t8_forest_set_ghost but with the additional options to change the ghost algorithm. This is used for debugging and timing the algorithm. An application should almost always use t8_forest_set_ghost. +This function returns the geometry type of a tree. # Arguments -* `ghost_version`:\\[in\\] If 1, the iterative ghost algorithm for balanced forests is used. If 2, the iterative algorithm for unbalanced forests. If 3, the top-down search algorithm for unbalanced forests. -# See also -[`t8_forest_set_ghost`](@ref) - +* `cmesh`:\\[in\\] The cmesh +* `gtreeid`:\\[in\\] The global id of the tree +# Returns +The geometry type of the tree with id *gtreeid* ### Prototype ```c -void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); +t8_geometry_type_t t8_geometry_get_type (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); ``` """ -function t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) - @ccall libt8.t8_forest_set_ghost_ext(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t, ghost_version::Cint)::Cvoid +function t8_geometry_get_type(cmesh, gtreeid) + @ccall libt8.t8_geometry_get_type(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::t8_geometry_type_t end """ - t8_forest_set_load(forest, filename) + t8_geometry_tree_negative_volume(cmesh, gtreeid) + +Check if a tree has a negative volume +# Arguments +* `cmesh`:\\[in\\] The cmesh to check +* `gtreeid`:\\[in\\] The global id of the tree +# Returns +True if the tree with id *gtreeid* has a negative volume. False otherwise. ### Prototype ```c -void t8_forest_set_load (t8_forest_t forest, const char *filename); +int t8_geometry_tree_negative_volume (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid); ``` """ -function t8_forest_set_load(forest, filename) - @ccall libt8.t8_forest_set_load(forest::t8_forest_t, filename::Cstring)::Cvoid +function t8_geometry_tree_negative_volume(cmesh, gtreeid) + @ccall libt8.t8_geometry_tree_negative_volume(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Cint end """ - t8_forest_comm_global_num_elements(forest) + t8_geom_get_name(geom) -Compute the global number of elements in a forest as the sum of the local element counts. +Get the name of a geometry. # Arguments -* `forest`:\\[in\\] The forest. +* `geom`:\\[in\\] A geometry. +# Returns +The name of *geom*. ### Prototype ```c -void t8_forest_comm_global_num_elements (t8_forest_t forest); +const char * t8_geom_get_name (const t8_geometry_c *geom); ``` """ -function t8_forest_comm_global_num_elements(forest) - @ccall libt8.t8_forest_comm_global_num_elements(forest::t8_forest_t)::Cvoid +function t8_geom_get_name(geom) + @ccall libt8.t8_geom_get_name(geom::Ptr{t8_geometry_c})::Cstring end """ - t8_forest_commit(forest) + t8_geom_get_type(geom) -After allocating and adding properties to a forest, commit the changes. This call sets up the internal state of the forest. +Get the type of a geometry. # Arguments -* `forest`:\\[in,out\\] Must be created with t8_forest_init and specialized with t8\\_forest\\_set\\_* calls first. +* `geom`:\\[in\\] A geometry. +# Returns +The type of *geom*. ### Prototype ```c -void t8_forest_commit (t8_forest_t forest); +t8_geometry_type_t t8_geom_get_type (const t8_geometry_c *geom); ``` """ -function t8_forest_commit(forest) - @ccall libt8.t8_forest_commit(forest::t8_forest_t)::Cvoid +function t8_geom_get_type(geom) + @ccall libt8.t8_geom_get_type(geom::Ptr{t8_geometry_c})::t8_geometry_type_t end """ - t8_forest_get_maxlevel(forest) + t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) -Return the maximum allowed refinement level for any element in a forest. +### Prototype +```c +void t8_geom_compute_linear_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); +``` +""" +function t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + @ccall libt8.t8_geom_compute_linear_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +end + +""" + t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) -# Arguments -* `forest`:\\[in\\] A forest. -# Returns -The maximum level of refinement that is allowed for an element in this forest. It is guaranteed that any tree in *forest* can be refined this many times and it is not allowed to refine further. *forest* must be committed before calling this function. For forest with a single element class (non-hybrid) maxlevel is the maximum refinement level of this element class, whilst for hybrid forests the maxlevel is the minimum of all maxlevels of the element classes in this forest. ### Prototype ```c -int t8_forest_get_maxlevel (const t8_forest_t forest); +void t8_geom_compute_linear_axis_aligned_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); ``` """ -function t8_forest_get_maxlevel(forest) - @ccall libt8.t8_forest_get_maxlevel(forest::t8_forest_t)::Cint +function t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + @ccall libt8.t8_geom_compute_linear_axis_aligned_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid end """ - t8_forest_get_local_num_elements(forest) + t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) -Return the number of process local elements in the forest. +Interpolates linearly between 2, bilinearly between 4 or trilineraly between 8 points. # Arguments -* `forest`:\\[in\\] A forest. -# Returns -The number of elements on this process in *forest*. *forest* must be committed before calling this function. +* `coefficients`:\\[in\\] An array of size at least dim giving the coefficients used for the interpolation +* `corner_values`:\\[in\\] An array of size 2^dim * 3, giving for each corner (in zorder) of the unit square/cube its function values in space. +* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. +* `interpolation_dim`:\\[in\\] The dimension of the interpolation (1 for linear, 2 for bilinear, 3 for trilinear) +* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -t8_locidx_t t8_forest_get_local_num_elements (const t8_forest_t forest); +void t8_geom_linear_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); ``` """ -function t8_forest_get_local_num_elements(forest) - @ccall libt8.t8_forest_get_local_num_elements(forest::t8_forest_t)::t8_locidx_t +function t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + @ccall libt8.t8_geom_linear_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid end """ - t8_forest_get_global_num_elements(forest) + t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) -Return the number of global elements in the forest. +Triangular interpolation between 3 points (triangle) or 4 points (tetrahedron) using cartesian coordinates. The input coefficients have to be given as coordinates in the reference triangle (interpolation\\_dim = 2) with points (0,0) (1,0) (1,1) or the reference tet (interpolation\\_dim = 3) with points (0,0,0) (1,0,0) (1,1,0) (1,1,1). # Arguments -* `forest`:\\[in\\] A forest. -# Returns -The number of elements (summed over all processes) in *forest*. *forest* must be committed before calling this function. +* `coefficients`:\\[in\\] An array of size *interpolation_dim* giving the coefficients in the reference triangle/tet used for the interpolation +* `corner_values`:\\[in\\] An array of size 3 * *corner_value_dim* for *interpolation_dim* == 2 or 4 * *corner_value_dim* for *interpolation_dim* == 3, giving the function values of the triangle/tetrahedron for each corner (in zorder) +* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. +* `interpolation_dim`:\\[in\\] The dimension of the interpolation (2 for triangle, 3 for tetrahedron) +* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -t8_gloidx_t t8_forest_get_global_num_elements (const t8_forest_t forest); +void t8_geom_triangular_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); ``` """ -function t8_forest_get_global_num_elements(forest) - @ccall libt8.t8_forest_get_global_num_elements(forest::t8_forest_t)::t8_gloidx_t +function t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + @ccall libt8.t8_geom_triangular_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid end """ - t8_forest_get_num_ghosts(forest) + t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) -Return the number of ghost elements of a forest. +### Prototype +```c +void t8_geom_get_face_vertices (t8_eclass_t tree_class, const double *tree_vertices, int face_index, int dim, double *face_vertices); +``` +""" +function t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) + @ccall libt8.t8_geom_get_face_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, face_index::Cint, dim::Cint, face_vertices::Ptr{Cdouble})::Cvoid +end -# Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of ghost elements stored in the ghost structure of *forest*. 0 if no ghosts were constructed. -# See also -[`t8_forest_set_ghost`](@ref) *forest* must be committed before calling this function. +""" + t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) ### Prototype ```c -t8_locidx_t t8_forest_get_num_ghosts (const t8_forest_t forest); +void t8_geom_get_edge_vertices (t8_eclass_t tree_class, const double *tree_vertices, int edge_index, int dim, double *edge_vertices); ``` """ -function t8_forest_get_num_ghosts(forest) - @ccall libt8.t8_forest_get_num_ghosts(forest::t8_forest_t)::t8_locidx_t +function t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) + @ccall libt8.t8_geom_get_edge_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, edge_index::Cint, dim::Cint, edge_vertices::Ptr{Cdouble})::Cvoid end """ - t8_forest_get_eclass(forest, ltreeid) + t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) -Return the element class of a forest local tree. +Calculates a point of intersection in a triangular reference space. The intersection is the extension of a straight line passing through a reference point and the opposite vertex of the edge. /|\\ / | \\ o -> reference point / o \\ x -> intersection point / | \\ /\\_\\_\\_\\_x\\_\\_\\_\\_\\ # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in *forest*. -# Returns -The element class of the tree *ltreeid*. *forest* must be committed before calling this function. +* `edge_index`:\\[in\\] Index of the edge, the intersection lies on. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +* `ref_intersection`:\\[out\\] Coordinates of the intersection point. ### Prototype ```c -t8_eclass_t t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid); +void t8_geom_get_ref_intersection (int edge_index, const double *ref_coords, double ref_intersection[2]); ``` """ -function t8_forest_get_eclass(forest, ltreeid) - @ccall libt8.t8_forest_get_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t +function t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) + @ccall libt8.t8_geom_get_ref_intersection(edge_index::Cint, ref_coords::Ptr{Cdouble}, ref_intersection::Ptr{Cdouble})::Cvoid end """ - t8_forest_tree_is_local(forest, local_tree) + t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) -Check whether a given tree id belongs to a local tree in a forest. +Calculates the scaling factor for edge displacement along a triangular tree face depending on the position of the global reference point. # Arguments -* `forest`:\\[in\\] The forest. -* `local_tree`:\\[in\\] A tree id. -# Returns -True if and only if the id *local_tree* belongs to a local tree of *forest*. *forest* must be committed before calling this function. +* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. +* `tree_vertices`:\\[in\\] Array with the tree vertex coordinates. +* `glob_intersection`:\\[in\\] Array containing the coordinates of the intersection point of a line drawn from the opposite vertex through the glob\\_ref\\_point onto the edge with edge\\_index. +* `glob_ref_point`:\\[in\\] Array containing the coordinates of the reference point mapped into the global space. ### Prototype ```c -int t8_forest_tree_is_local (const t8_forest_t forest, const t8_locidx_t local_tree); +double t8_geom_get_triangle_scaling_factor (int edge_index, const double *tree_vertices, const double *glob_intersection, const double *glob_ref_point); ``` """ -function t8_forest_tree_is_local(forest, local_tree) - @ccall libt8.t8_forest_tree_is_local(forest::t8_forest_t, local_tree::t8_locidx_t)::Cint +function t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) + @ccall libt8.t8_geom_get_triangle_scaling_factor(edge_index::Cint, tree_vertices::Ptr{Cdouble}, glob_intersection::Ptr{Cdouble}, glob_ref_point::Ptr{Cdouble})::Cdouble end """ - t8_forest_get_local_id(forest, gtreeid) + t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) -Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is not a local tree, a negative number is returned. +Calculates the scaling factor for the displacement of an edge over a face of a tetrahedral element. # Arguments -* `forest`:\\[in\\] The forest. -* `gtreeid`:\\[in\\] The global id of a tree. +* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. +* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. # Returns -The tree's local id in *forest*, if it is a local tree. A negative number if not. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +The scaling factor of the edge displacement on the face at the point of the reference coordinates. ### Prototype ```c -t8_locidx_t t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); +double t8_geom_get_scaling_factor_of_edge_on_face_tet (int edge_index, int face_index, const double *ref_coords); ``` """ -function t8_forest_get_local_id(forest, gtreeid) - @ccall libt8.t8_forest_get_local_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t +function t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) + @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble end """ - t8_forest_get_local_or_ghost_id(forest, gtreeid) + t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) -Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is a ghost, then the local id is between num\\_local\\_trees and num\\_local\\_trees + num\\_ghost\\_trees. If the tree is neither a local tree nor a ghost tree, a negative number is returned. +Calculates the face intersection of a ray passing trough the reference coordinates and the opposite vertex of that face for a tetrahedron. The coordinates of the face intersection are reference coordinates: [0,1]^3. # Arguments -* `forest`:\\[in\\] The forest. -* `gtreeid`:\\[in\\] The global id of a tree. -# Returns -The tree's local id in *forest*, if it is a local tree. num\\_local\\_trees + the ghosts id, if it is a ghost tree. A negative number if not. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +* `face_index`:\\[in\\] Index of the face, on which the intersection should be calculated. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +* `face_intersection`:\\[out\\] Three dimensional array containing the intersection point on the face in reference space. ### Prototype ```c -t8_locidx_t t8_forest_get_local_or_ghost_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); +void t8_geom_get_tet_face_intersection (const int face_index, const double *ref_coords, double face_intersection[3]); ``` """ -function t8_forest_get_local_or_ghost_id(forest, gtreeid) - @ccall libt8.t8_forest_get_local_or_ghost_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t +function t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) + @ccall libt8.t8_geom_get_tet_face_intersection(face_index::Cint, ref_coords::Ptr{Cdouble}, face_intersection::Ptr{Cdouble})::Cvoid end """ - t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) - -Given the local id of a tree in a forest, compute the tree's local id in the associated cmesh. - -!!! note + t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) - For forest local trees, this is the inverse function of t8_forest_cmesh_ltreeid_to_ltreeid. +Calculates the scaling factor for the displacement of an edge over a face of a prism element. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree or ghost in the forest. +* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. +* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. # Returns -The local id of the tree in the cmesh associated with the forest. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +The scaling factor of the edge displacement on the face at the point of the reference coordinates. ### Prototype ```c -t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, t8_locidx_t ltreeid); +double t8_geom_get_scaling_factor_of_edge_on_face_prism (int edge_index, int face_index, const double *ref_coords); ``` """ -function t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) - @ccall libt8.t8_forest_ltreeid_to_cmesh_ltreeid(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t +function t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) + @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble end """ - t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) - -Given the local id of a tree in the coarse mesh of a forest, compute the tree's local id in the forest. - -!!! note + t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) - For forest local trees, this is the inverse function of t8_forest_ltreeid_to_cmesh_ltreeid. +Calculates the scaling factor for the displacement of an face through the volume of a prism element. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in the coarse mesh of *forest*. +* `face`:\\[in\\] Index of the displaced face. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. # Returns -The local id of the tree in the forest. -1 if the tree is not forest local. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +The scaling factor of the face displacement at the point of the reference coordinates inside the prism volume. ### Prototype ```c -t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, t8_locidx_t lctreeid); +double t8_geom_get_scaling_factor_face_through_volume_prism (const int face, const double *ref_coords); ``` """ -function t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) - @ccall libt8.t8_forest_cmesh_ltreeid_to_ltreeid(forest::t8_forest_t, lctreeid::t8_locidx_t)::t8_locidx_t +function t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) + @ccall libt8.t8_geom_get_scaling_factor_face_through_volume_prism(face::Cint, ref_coords::Ptr{Cdouble})::Cdouble end """ - t8_forest_get_coarse_tree(forest, ltreeid) + t8_vertex_point_inside(vertex_coords, point, tolerance) -Given the local id of a tree in a forest, return the coarse tree of the cmesh that corresponds to this tree. +Check if a point lies inside a vertex # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in the forest. +* `vertex_coords`:\\[in\\] The coordinates of the vertex +* `point`:\\[in\\] The coordinates of the point to check +* `tolerance`:\\[in\\] A double > 0 defining the tolerance # Returns -The coarse tree that matches the forest tree with local id *ltreeid*. +0 if the point is outside, 1 otherwise. ### Prototype ```c -t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid); +int t8_vertex_point_inside (const double vertex_coords[3], const double point[3], const double tolerance); ``` """ -function t8_forest_get_coarse_tree(forest, ltreeid) - @ccall libt8.t8_forest_get_coarse_tree(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_ctree_t +function t8_vertex_point_inside(vertex_coords, point, tolerance) + @ccall libt8.t8_vertex_point_inside(vertex_coords::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint end """ - t8_forest_element_is_leaf(forest, element, local_tree) - -Query whether a given element is a leaf in a forest. - -!!! note - - This does not query for ghost leaves. - -!!! note + t8_line_point_inside(p_0, vec, point, tolerance) - *forest* must be committed before calling this function. +Check if a point is inside a line that is defined by a starting point *p_0* and a vector *vec* # Arguments -* `forest`:\\[in\\] The forest. -* `element`:\\[in\\] An element of a local tree in *forest*. -* `local_tree`:\\[in\\] A local tree id of *forest*. +* `p_0`:\\[in\\] Starting point of the line +* `vec`:\\[in\\] Direction of the line (not normalized) +* `point`:\\[in\\] The coordinates of the point to check +* `tolerance`:\\[in\\] A double > 0 defining the tolerance # Returns -True (non-zero) if and only if *element* is a leaf in *local_tree* of *forest*. +0 if the point is outside, 1 otherwise. ### Prototype ```c -int t8_forest_element_is_leaf (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t local_tree); +int t8_line_point_inside (const double *p_0, const double *vec, const double *point, const double tolerance); ``` """ -function t8_forest_element_is_leaf(forest, element, local_tree) - @ccall libt8.t8_forest_element_is_leaf(forest::t8_forest_t, element::Ptr{t8_element_t}, local_tree::t8_locidx_t)::Cint +function t8_line_point_inside(p_0, vec, point, tolerance) + @ccall libt8.t8_line_point_inside(p_0::Ptr{Cdouble}, vec::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint end """ - t8_forest_leaf_face_orientation(forest, ltreeid, ts, leaf, face) - -Compute the leaf face orientation at given face in a forest. + t8_triangle_point_inside(p_0, v, w, point, tolerance) -For more information about the encoding of face orientation refer to t8_cmesh_get_face_neighbor. +Check if a point is inside of a triangle described by a point *p_0* and two vectors *v* and *w*. # Arguments -* `forest`:\\[in\\] The forest. Must have a valid ghost layer. -* `ltreeid`:\\[in\\] A local tree id. -* `ts`:\\[in\\] The eclass scheme of the element. -* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. -* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +* `p_0`:\\[in\\] The first vertex of a triangle +* `v`:\\[in\\] The vector from p\\_0 to p\\_1 (second vertex in the triangle) +* `w`:\\[in\\] The vector from p\\_0 to p\\_2 (third vertex in the triangle) +* `point`:\\[in\\] The coordinates of the point to check +* `tolerance`:\\[in\\] A double > 0 defining the tolerance # Returns -Face orientation encoded as integer. +0 if the point is outside, 1 otherwise. ### Prototype ```c -int t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_eclass_scheme_c *ts, const t8_element_t *leaf, int face); +int t8_triangle_point_inside (const double p_0[3], const double v[3], const double w[3], const double point[3], const double tolerance); ``` """ -function t8_forest_leaf_face_orientation(forest, ltreeid, ts, leaf, face) - @ccall libt8.t8_forest_leaf_face_orientation(forest::t8_forest_t, ltreeid::t8_locidx_t, ts::Ptr{t8_eclass_scheme_c}, leaf::Ptr{t8_element_t}, face::Cint)::Cint +function t8_triangle_point_inside(p_0, v, w, point, tolerance) + @ccall libt8.t8_triangle_point_inside(p_0::Ptr{Cdouble}, v::Ptr{Cdouble}, w::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint end """ - t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced) - -Compute the leaf face neighbors of a forest. - -!!! note - - If there are no face neighbors, then *neighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. - -!!! note - - Currently *forest* must be balanced. - -!!! note - - *forest* must be committed before calling this function. - -!!! note - - Important! This routine allocates memory which must be freed. Do it like this: + t8_plane_point_inside(point_on_face, face_normal, point) -if (num\\_neighbors > 0) { eclass\\_scheme->[`t8_element_destroy`](@ref) (num\\_neighbors, neighbors); [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } +Check if a point lays on the inner side of a plane of a bilinearly interpolated volume element. the plane is described by a point and the normal of the face. # Arguments -* `forest`:\\[in\\] The forest. Must have a valid ghost layer. -* `ltreeid`:\\[in\\] A local tree id. -* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. -* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. -* `face`:\\[in\\] The index of the face across which the face neighbors are searched. -* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. -* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. -* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. -* `pneigh_scheme`:\\[out\\] On output the eclass scheme of the neighbor elements. -* `forest_is_balanced`:\\[in\\] True if we know that *forest* is balanced, false otherwise. +* `point_on_face`:\\[in\\] A point on the plane +* `face_normal`:\\[in\\] The normal of the face +* `point`:\\[in\\] The point to check +# Returns +0 if the point is outside, 1 otherwise. ### Prototype ```c -void t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, t8_locidx_t **pelement_indices, t8_eclass_scheme_c **pneigh_scheme, int forest_is_balanced); +int t8_plane_point_inside (const double point_on_face[3], const double face_normal[3], const double point[3]); ``` """ -function t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced) - @ccall libt8.t8_forest_leaf_face_neighbors(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf::Ptr{t8_element_t}, pneighbor_leaves::Ptr{Ptr{Ptr{t8_element_t}}}, face::Cint, dual_faces::Ptr{Ptr{Cint}}, num_neighbors::Ptr{Cint}, pelement_indices::Ptr{Ptr{t8_locidx_t}}, pneigh_scheme::Ptr{Ptr{t8_eclass_scheme_c}}, forest_is_balanced::Cint)::Cvoid +function t8_plane_point_inside(point_on_face, face_normal, point) + @ccall libt8.t8_plane_point_inside(point_on_face::Ptr{Cdouble}, face_normal::Ptr{Cdouble}, point::Ptr{Cdouble})::Cint end """ - t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced, gneigh_tree, orientation) - -Like t8_forest_leaf_face_neighbors but also provides information about the global neighbors and the orientation. - -!!! note - - If there are no face neighbors, then *neighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. - -!!! note - - Currently *forest* must be balanced. - -!!! note - - *forest* must be committed before calling this function. - -!!! note - - Important! This routine allocates memory which must be freed. Do it like this: + t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) -if (num\\_neighbors > 0) { eclass\\_scheme->[`t8_element_destroy`](@ref) (num\\_neighbors, neighbors); [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } +Set the vertex coordinates of a tree in the cmesh. This is currently inefficient, since the vertices are duplicated for each tree. Eventually this function will be replaced by a more efficient one. It is not allowed to call this function after t8_cmesh_commit. The eclass of the tree has to be set before calling this function. -# Arguments -* `forest`:\\[in\\] The forest. Must have a valid ghost layer. -* `ltreeid`:\\[in\\] A local tree id. -* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. -* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. -* `face`:\\[in\\] The index of the face across which the face neighbors are searched. -* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. -* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. -* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. -* `pneigh_scheme`:\\[out\\] On output the eclass scheme of the neighbor elements. -* `forest_is_balanced`:\\[in\\] True if we know that *forest* is balanced, false otherwise. -* `gneigh_tree`:\\[out\\] The global tree IDs of the neighbor trees. -* `orientation`:\\[out\\] If not NULL on input, the face orientation is computed and stored here. Thus, if the face connection is an inter-tree connection the orientation of the tree-to-tree connection is stored. Otherwise, the value 0 is stored. All other parameters and behavior are identical to `t8_forest_leaf_face_neighbors`. +# Arguments +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `gtree_id`:\\[in\\] The global number of the tree. +* `vertices`:\\[in\\] An array of 3 doubles per tree vertex. +* `num_vertices`:\\[in\\] The number of verticess in *vertices*. Must match the number of corners of the tree. ### Prototype ```c -void t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, t8_locidx_t **pelement_indices, t8_eclass_scheme_c **pneigh_scheme, int forest_is_balanced, t8_gloidx_t *gneigh_tree, int *orientation); +void t8_cmesh_set_tree_vertices (t8_cmesh_t cmesh, const t8_gloidx_t gtree_id, const double *vertices, const int num_vertices); ``` """ -function t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced, gneigh_tree, orientation) - @ccall libt8.t8_forest_leaf_face_neighbors_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf::Ptr{t8_element_t}, pneighbor_leaves::Ptr{Ptr{Ptr{t8_element_t}}}, face::Cint, dual_faces::Ptr{Ptr{Cint}}, num_neighbors::Ptr{Cint}, pelement_indices::Ptr{Ptr{t8_locidx_t}}, pneigh_scheme::Ptr{Ptr{t8_eclass_scheme_c}}, forest_is_balanced::Cint, gneigh_tree::Ptr{t8_gloidx_t}, orientation::Ptr{Cint})::Cvoid +function t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) + @ccall libt8.t8_cmesh_set_tree_vertices(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cvoid end +# no prototype is found for this function at t8_version.h:67:1, please use with caution """ - t8_forest_ghost_exchange_data(forest, element_data) - -Exchange ghost information of user defined element data. - -!!! note + t8_get_package_string() - This function is collective and hence must be called by all processes in the forest's MPI Communicator. +Return the package string of t8code. This string has the format "t8 version\\_number". -# Arguments -* `forest`:\\[in\\] The forest. Must be committed. -* `element_data`:\\[in\\] An array of length num\\_local\\_elements + num\\_ghosts storing one value for each local element and ghost in *forest*. After calling this function the entries for the ghost elements are update with the entries in the *element_data* array of the corresponding owning process. +# Returns +The version string of t8code. ### Prototype ```c -void t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data); +const char* t8_get_package_string (); ``` """ -function t8_forest_ghost_exchange_data(forest, element_data) - @ccall libt8.t8_forest_ghost_exchange_data(forest::t8_forest_t, element_data::Ptr{sc_array_t})::Cvoid +function t8_get_package_string() + @ccall libt8.t8_get_package_string()::Cstring end +# no prototype is found for this function at t8_version.h:73:1, please use with caution """ - t8_forest_ghost_print(forest) + t8_get_version_number() -Print the ghost structure of a forest. Only used for debugging. +Return the version number of t8code as a string. +# Returns +The version number of t8code as a string. ### Prototype ```c -void t8_forest_ghost_print (t8_forest_t forest); +const char* t8_get_version_number (); ``` """ -function t8_forest_ghost_print(forest) - @ccall libt8.t8_forest_ghost_print(forest::t8_forest_t)::Cvoid +function t8_get_version_number() + @ccall libt8.t8_get_version_number()::Cstring end +# no prototype is found for this function at t8_version.h:79:1, please use with caution """ - t8_forest_partition_cmesh(forest, comm, set_profiling) + t8_get_version_point_string() + +Return the version point string. +# Returns +The version point point string. ### Prototype ```c -void t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profiling); +const char* t8_get_version_point_string (); ``` """ -function t8_forest_partition_cmesh(forest, comm, set_profiling) - @ccall libt8.t8_forest_partition_cmesh(forest::t8_forest_t, comm::MPI_Comm, set_profiling::Cint)::Cvoid +function t8_get_version_point_string() + @ccall libt8.t8_get_version_point_string()::Cstring end +# no prototype is found for this function at t8_version.h:85:1, please use with caution """ - t8_forest_get_mpicomm(forest) + t8_get_version_major() + +Return the major version number of t8code. +# Returns +The major version number of t8code. ### Prototype ```c -sc_MPI_Comm t8_forest_get_mpicomm (const t8_forest_t forest); +int t8_get_version_major (); ``` """ -function t8_forest_get_mpicomm(forest) - @ccall libt8.t8_forest_get_mpicomm(forest::t8_forest_t)::MPI_Comm +function t8_get_version_major() + @ccall libt8.t8_get_version_major()::Cint end +# no prototype is found for this function at t8_version.h:91:1, please use with caution """ - t8_forest_get_first_local_tree_id(forest) + t8_get_version_minor() -Return the global id of the first local tree of a forest. +Return the minor version number of t8code. -# Arguments -* `forest`:\\[in\\] The forest. # Returns -The global id of the first local tree in *forest*. +The minor version number of t8code. ### Prototype ```c -t8_gloidx_t t8_forest_get_first_local_tree_id (const t8_forest_t forest); +int t8_get_version_minor (); ``` """ -function t8_forest_get_first_local_tree_id(forest) - @ccall libt8.t8_forest_get_first_local_tree_id(forest::t8_forest_t)::t8_gloidx_t +function t8_get_version_minor() + @ccall libt8.t8_get_version_minor()::Cint end +# no prototype is found for this function at t8_version.h:97:1, please use with caution """ - t8_forest_get_num_local_trees(forest) + t8_get_version_patch() -Return the number of local trees of a given forest. +Return the patch version number of t8code. -# Arguments -* `forest`:\\[in\\] The forest. # Returns -The number of local trees of that forest. +The patch version number of t8code. ### Prototype ```c -t8_locidx_t t8_forest_get_num_local_trees (const t8_forest_t forest); +int t8_get_version_patch (); ``` """ -function t8_forest_get_num_local_trees(forest) - @ccall libt8.t8_forest_get_num_local_trees(forest::t8_forest_t)::t8_locidx_t +function t8_get_version_patch() + @ccall libt8.t8_get_version_patch()::Cint end """ - t8_forest_get_num_ghost_trees(forest) - -Return the number of ghost trees of a given forest. + getdelim(lineptr, n, delimiter, stream) -# Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of ghost trees of that forest. ### Prototype ```c -t8_locidx_t t8_forest_get_num_ghost_trees (const t8_forest_t forest); +static ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream); ``` """ -function t8_forest_get_num_ghost_trees(forest) - @ccall libt8.t8_forest_get_num_ghost_trees(forest::t8_forest_t)::t8_locidx_t +function getdelim(lineptr, n, delimiter, stream) + @ccall libt8.getdelim(lineptr::Ptr{Cstring}, n::Ptr{Cint}, delimiter::Cint, stream::Ptr{Cint})::Cint end """ - t8_forest_get_num_global_trees(forest) - -Return the number of global trees of a given forest. + getline(lineptr, n, stream) -# Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of global trees of that forest. ### Prototype ```c -t8_gloidx_t t8_forest_get_num_global_trees (const t8_forest_t forest); +static ssize_t getline (char **lineptr, size_t *n, FILE *stream); ``` """ -function t8_forest_get_num_global_trees(forest) - @ccall libt8.t8_forest_get_num_global_trees(forest::t8_forest_t)::t8_gloidx_t +function getline(lineptr, n, stream) + @ccall libt8.getline(lineptr::Ptr{Cstring}, n::Ptr{Cint}, stream::Ptr{Cint})::Cint end """ - t8_forest_global_tree_id(forest, ltreeid) + strsep(stringp, delim) -Return the global id of a local tree or a ghost tree. +Extract token from string up to a given delimiter. -# Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] An id 0 <= *ltreeid* < num\\_local\\_trees + num\\_ghosts specifying a local tree or ghost tree. -# Returns -The global id corresponding to the tree with local id *ltreeid*. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. +For a full description see https://linux.die.net/man/3/[`strsep`](@ref) ### Prototype ```c -t8_gloidx_t t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid); +static char * strsep (char **stringp, const char *delim); ``` """ -function t8_forest_global_tree_id(forest, ltreeid) - @ccall libt8.t8_forest_global_tree_id(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_gloidx_t +function strsep(stringp, delim) + @ccall libt8.strsep(stringp::Ptr{Cstring}, delim::Cstring)::Cstring end """ - t8_forest_get_tree(forest, ltree_id) + t8_scheme_ref(scheme) -Return a pointer to a tree in a forest. +Increase the reference counter of a scheme. # Arguments -* `forest`:\\[in\\] The forest. -* `ltree_id`:\\[in\\] The local id of the tree. -# Returns -A pointer to the tree with local id *ltree_id*. *forest* must be committed before calling this function. +* `scheme`:\\[in,out\\] On input, this scheme must be alive, that is, exist with positive reference count. ### Prototype ```c -t8_tree_t t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id); +void t8_scheme_ref (t8_scheme_c *scheme); ``` """ -function t8_forest_get_tree(forest, ltree_id) - @ccall libt8.t8_forest_get_tree(forest::t8_forest_t, ltree_id::t8_locidx_t)::t8_tree_t +function t8_scheme_ref(scheme) + @ccall libt8.t8_scheme_ref(scheme::Ptr{t8_scheme_c})::Cvoid end """ - t8_forest_get_tree_vertices(forest, ltreeid) + t8_scheme_unref(pscheme) -Return a pointer to the vertex coordinates of a tree. +Decrease the reference counter of a scheme. If the counter reaches zero, this scheme is destroyed. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The id of a local tree. -# Returns -If stored, a pointer to the vertex coordinates of *tree*. If no coordinates for this tree are found, NULL. +* `pscheme`:\\[in,out\\] On input, the scheme pointed to must exist with positive reference count. If the reference count reaches zero, the scheme is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the scheme is not modified in other ways. ### Prototype ```c -double * t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid); +void t8_scheme_unref (t8_scheme_c **pscheme); ``` """ -function t8_forest_get_tree_vertices(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_vertices(forest::t8_forest_t, ltreeid::t8_locidx_t)::Ptr{Cdouble} +function t8_scheme_unref(pscheme) + @ccall libt8.t8_scheme_unref(pscheme::Ptr{Ptr{t8_scheme_c}})::Cvoid end """ - t8_forest_tree_get_leaves(forest, ltree_id) + t8_element_get_element_size(scheme, tree_class) -Return the array of leaf elements of a local tree in a forest. +Return the size of any element of a given class. -# Arguments -* `forest`:\\[in\\] The forest. -* `ltree_id`:\\[in\\] The local id of a local tree of *forest*. # Returns -An array of [`t8_element_t`](@ref) * storing all leaf elements of this tree. +The size of an element of class **ts**. We provide a default implementation of this routine that should suffice for most use cases. ### Prototype ```c -t8_element_array_t * t8_forest_tree_get_leaves (const t8_forest_t forest, const t8_locidx_t ltree_id); +size_t t8_element_get_element_size (const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -function t8_forest_tree_get_leaves(forest, ltree_id) - @ccall libt8.t8_forest_tree_get_leaves(forest::t8_forest_t, ltree_id::t8_locidx_t)::Ptr{t8_element_array_t} +function t8_element_get_element_size(scheme, tree_class) + @ccall libt8.t8_element_get_element_size(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Csize_t end """ - t8_forest_get_cmesh(forest) + t8_element_refines_irregular(scheme, tree_class) -Return a cmesh associated to a forest. +Returns true, if there is one element in the tree, that does not refine into 2^dim children. Returns false otherwise. -# Arguments -* `forest`:\\[in\\] The forest. -# Returns -The cmesh associated to the forest. ### Prototype ```c -t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); +int t8_element_refines_irregular (const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -function t8_forest_get_cmesh(forest) - @ccall libt8.t8_forest_get_cmesh(forest::t8_forest_t)::t8_cmesh_t +function t8_element_refines_irregular(scheme, tree_class) + @ccall libt8.t8_element_refines_irregular(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cint end """ - t8_forest_get_element(forest, lelement_id, ltreeid) - -Return an element of the forest. + t8_element_get_maxlevel(scheme, tree_class) -!!! note - - This function performs a binary search. For constant access, use t8_forest_get_element_in_tree *forest* must be committed before calling this function. +Return the maximum allowed level for any element of a given class. # Arguments -* `forest`:\\[in\\] The forest. -* `lelement_id`:\\[in\\] The local id of an element in *forest*. -* `ltreeid`:\\[out\\] If not NULL, on output the local tree id of the tree in which the element lies in. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. # Returns -A pointer to the element. NULL if this element does not exist. +The maximum allowed level for elements of class **ts**. ### Prototype ```c -t8_element_t * t8_forest_get_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_locidx_t *ltreeid); +int t8_element_get_maxlevel (const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -function t8_forest_get_element(forest, lelement_id, ltreeid) - @ccall libt8.t8_forest_get_element(forest::t8_forest_t, lelement_id::t8_locidx_t, ltreeid::Ptr{t8_locidx_t})::Ptr{t8_element_t} +function t8_element_get_maxlevel(scheme, tree_class) + @ccall libt8.t8_element_get_maxlevel(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cint end """ - t8_forest_get_element_in_tree(forest, ltreeid, leid_in_tree) - -Return an element of a local tree in a forest. - -!!! note + t8_element_get_level(scheme, tree_class, element) - If the tree id is know, this function should be preferred over t8_forest_get_element. *forest* must be committed before calling this function. +Return the level of an element. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] An id of a local tree in the forest. -* `leid_in_tree`:\\[in\\] The index of an element in the tree. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -A pointer to the element. +The level of *element*. ### Prototype ```c -const t8_element_t * t8_forest_get_element_in_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t leid_in_tree); +int t8_element_get_level (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_get_element_in_tree(forest, ltreeid, leid_in_tree) - @ccall libt8.t8_forest_get_element_in_tree(forest::t8_forest_t, ltreeid::t8_locidx_t, leid_in_tree::t8_locidx_t)::Ptr{t8_element_t} +function t8_element_get_level(scheme, tree_class, element) + @ccall libt8.t8_element_get_level(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_tree_num_elements(forest, ltreeid) + t8_element_copy(scheme, tree_class, source, dest) + +Copy all entries of **source** to **dest**. **dest** must be an existing element. No memory is allocated by this function. -Return the number of elements of a tree. +!!! note + + *source* and *dest* may point to the same element. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] A local id of a tree. -# Returns -The number of elements in the local tree *ltreeid*. +* `scheme`:\\[in\\] Implementation of a class scheme. +* `tree_class`:\\[in\\] The eclass of the current tree. +* `source`:\\[in\\] The element whose entries will be copied to **dest**. +* `dest`:\\[in,out\\] This element's entries will be overwritten with the entries of **source**. ### Prototype ```c -t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, t8_locidx_t ltreeid); +void t8_element_copy (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *source, t8_element_t *dest); ``` """ -function t8_forest_get_tree_num_elements(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_num_elements(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t +function t8_element_copy(scheme, tree_class, source, dest) + @ccall libt8.t8_element_copy(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, source::Ptr{t8_element_t}, dest::Ptr{t8_element_t})::Cvoid end """ - t8_forest_get_tree_element_offset(forest, ltreeid) - -Return the element offset of a local tree, that is the number of elements in all trees with smaller local treeid. - -!!! note + t8_element_compare(scheme, tree_class, elem1, elem2) - *forest* must be committed before calling this function. +Compare two elements with respect to the scheme. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] A local id of a tree. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The first element. +* `elem2`:\\[in\\] The second element. # Returns -The number of leaf elements on all local tree with id < *ltreeid*. +negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. If elem2 is a copy of elem1 then the elements are equal. ### Prototype ```c -t8_locidx_t t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid); +int t8_element_compare (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2); ``` """ -function t8_forest_get_tree_element_offset(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_element_offset(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t +function t8_element_compare(scheme, tree_class, elem1, elem2) + @ccall libt8.t8_element_compare(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint end """ - t8_forest_get_tree_element_count(tree) + t8_element_is_equal(scheme, tree_class, elem1, elem2) -Return the number of elements of a tree. +Check if two elements are equal. # Arguments -* `tree`:\\[in\\] A tree in a forest. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The first element. +* `elem2`:\\[in\\] The second element. # Returns -The number of elements of that tree. +1 if the elements are equal, 0 if they are not equal ### Prototype ```c -t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); +int t8_element_is_equal (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2); ``` """ -function t8_forest_get_tree_element_count(tree) - @ccall libt8.t8_forest_get_tree_element_count(tree::t8_tree_t)::t8_locidx_t +function t8_element_is_equal(scheme, tree_class, elem1, elem2) + @ccall libt8.t8_element_is_equal(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint end """ - t8_forest_get_tree_class(forest, ltreeid) + element_is_refinable(scheme, tree_class, element) -Return the eclass of a tree in a forest. +Indicates if an element is refinable. Possible reasons for being not refinable could be that the element has reached its max level. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree (local or ghost) in *forest*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element to check. # Returns -The element class of the tree with local id *ltreeid*. +1 if the element is refinable, 0 otherwise. ### Prototype ```c -t8_eclass_t t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid); +int element_is_refinable (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_get_tree_class(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_class(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t +function element_is_refinable(scheme, tree_class, element) + @ccall libt8.element_is_refinable(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_first_local_element_id(forest) + t8_element_get_parent(scheme, tree_class, element, parent) -Compute the global index of the first local element of a forest. This function is collective. +Compute the parent of a given element **element** and store it in **parent**. **parent** needs to be an existing element. No memory is allocated by this function. **element** and **parent** can point to the same element, then the entries of **element** are overwritten by the ones of its parent. # Arguments -* `forest`:\\[in\\] A committed forest, whose first element's index is computed. -# Returns -The global index of *forest*'s first local element. Forest must be committed when calling this function. This function is collective and must be called on each process. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element whose parent will be computed. +* `parent`:\\[in,out\\] This element's entries will be overwritten by those of **element**'s parent. The storage for this element must exist and match the element class of the parent. ### Prototype ```c -t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); +void t8_element_get_parent (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *parent); ``` """ -function t8_forest_get_first_local_element_id(forest) - @ccall libt8.t8_forest_get_first_local_element_id(forest::t8_forest_t)::t8_gloidx_t +function t8_element_get_parent(scheme, tree_class, element, parent) + @ccall libt8.t8_element_get_parent(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, parent::Ptr{t8_element_t})::Cvoid end """ - t8_forest_get_scheme(forest) + t8_element_get_num_siblings(scheme, tree_class, element) -Return the element scheme associated to a forest. +Compute the number of siblings of an element. That is the number of Children of its parent. # Arguments -* `forest.`:\\[in\\] A committed forest. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -The element scheme of the forest. -# See also -[`t8_forest_set_scheme`](@ref) - +The number of siblings of *element*. Note that this number is >= 1, since we count the element itself as a sibling. ### Prototype ```c -t8_scheme_cxx_t * t8_forest_get_scheme (const t8_forest_t forest); +int t8_element_get_num_siblings (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_get_scheme(forest) - @ccall libt8.t8_forest_get_scheme(forest::t8_forest_t)::Ptr{t8_scheme_cxx_t} +function t8_element_get_num_siblings(scheme, tree_class, element) + @ccall libt8.t8_element_get_num_siblings(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_eclass_scheme(forest, eclass) - -Return the eclass scheme of a given element class associated to a forest. + t8_element_get_sibling(scheme, tree_class, elem, sibid, sibling) -!!! note - - The forest is not required to have trees of class *eclass*. +Compute a specific sibling of a given element **element** and store it in **sibling**. **sibling** needs to be an existing element. No memory is allocated by this function. **element** and **sibling** can point to the same element, then the entries of **element** are overwritten by the ones of its i-th sibling. # Arguments -* `forest.`:\\[in\\] A committed forest. -* `eclass.`:\\[in\\] An element class. -# Returns -The eclass scheme of *eclass* associated to forest. -# See also -[`t8_forest_set_scheme`](@ref) - +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem`:\\[in\\] The element whose sibling will be computed. +* `sibid`:\\[in\\] The id of the sibling computed. +* `sibling`:\\[in,out\\] This element's entries will be overwritten by those of **element**'s sibid-th sibling. The storage for this element must exist and match the element class of the sibling. ### Prototype ```c -t8_eclass_scheme_c * t8_forest_get_eclass_scheme (t8_forest_t forest, t8_eclass_t eclass); +void t8_element_get_sibling (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem, const int sibid, t8_element_t *sibling); ``` """ -function t8_forest_get_eclass_scheme(forest, eclass) - @ccall libt8.t8_forest_get_eclass_scheme(forest::t8_forest_t, eclass::t8_eclass_t)::Ptr{t8_eclass_scheme_c} +function t8_element_get_sibling(scheme, tree_class, elem, sibid, sibling) + @ccall libt8.t8_element_get_sibling(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem::Ptr{t8_element_t}, sibid::Cint, sibling::Ptr{t8_element_t})::Cvoid end """ - t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) + t8_element_get_num_corners(scheme, tree_class, element) -Return the eclass of the tree in which a face neighbor of a given element lies. +Compute the number of corners of an element. # Arguments -* `forest.`:\\[in\\] A committed forest. -* `ltreeid.`:\\[in\\] The local tree in which the element lies. -* `elem.`:\\[in\\] An element in the tree *ltreeid*. -* `face.`:\\[in\\] A face number of *elem*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -The local tree id of the tree in which the face neighbor of *elem* across *face* lies. +The number of corners of *element*. ### Prototype ```c -t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, int face); +int t8_element_get_num_corners (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) - @ccall libt8.t8_forest_element_neighbor_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, face::Cint)::t8_eclass_t +function t8_element_get_num_corners(scheme, tree_class, element) + @ccall libt8.t8_element_get_num_corners(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_scheme, face, neigh_face) + t8_element_get_num_faces(scheme, tree_class, element) -Construct the face neighbor of an element, possibly across tree boundaries. Returns the global tree-id of the tree in which the neighbor element lies in. +Compute the number of faces of an element. # Arguments -* `elem`:\\[in\\] The element to be considered. -* `neigh`:\\[in,out\\] On input an allocated element of the scheme of the face\\_neighbors eclass. On output, this element's data is filled with the data of the face neighbor. If the neighbor does not exist the data could be modified arbitrarily. -* `neigh_scheme`:\\[in\\] The eclass scheme of *neigh*. -* `face`:\\[in\\] The number of the face along which the neighbor should be constructed. -* `neigh_face`:\\[out\\] The number of the face viewed from perspective of *neigh*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -The global tree-id of the tree in which *neigh* is in. -1 if there exists no neighbor across that face. +The number of faces of *element*. ### Prototype ```c -t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, t8_eclass_scheme_c *neigh_scheme, int face, int *neigh_face); +int t8_element_get_num_faces (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_scheme, face, neigh_face) - @ccall libt8.t8_forest_element_face_neighbor(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, neigh::Ptr{t8_element_t}, neigh_scheme::Ptr{t8_eclass_scheme_c}, face::Cint, neigh_face::Ptr{Cint})::t8_gloidx_t +function t8_element_get_num_faces(scheme, tree_class, element) + @ccall libt8.t8_element_get_num_faces(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_iterate(forest) + t8_element_get_max_num_faces(scheme, tree_class, element) + +Compute the maximum number of faces of a given element and all of its descendants. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +# Returns +The number of faces of *element*. ### Prototype ```c -void t8_forest_iterate (t8_forest_t forest); +int t8_element_get_max_num_faces (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_iterate(forest) - @ccall libt8.t8_forest_iterate(forest::t8_forest_t)::Cvoid +function t8_element_get_max_num_faces(scheme, tree_class, element) + @ccall libt8.t8_element_get_max_num_faces(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) - -Query whether a batch of points lies inside an element. For bilinearly interpolated elements. - -!!! note + t8_element_get_num_children(scheme, tree_class, element) - For 2D quadrilateral elements this function is only an approximation. It is correct if the four vertices lie in the same plane, but it may produce only approximate results if the vertices do not lie in the same plane. +Compute the number of children of an element when it is refined. # Arguments -* `forest`:\\[in\\] The forest. -* `ltree_id`:\\[in\\] The forest local id of the tree in which the element is. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. * `element`:\\[in\\] The element. -* `points`:\\[in\\] 3-dimensional coordinates of the points to check -* `num_points`:\\[in\\] The number of points to check -* `is_inside`:\\[in,out\\] An array of length *num_points*, filled with 0/1 on output. True (non-zero) if a *point* lies within an *element*, false otherwise. The return value is also true if the point lies on the element boundary. Thus, this function may return true for different leaf elements, if they are neighbors and the point lies on the common boundary. -* `tolerance`:\\[in\\] Tolerance that we allow the point to not exactly match the element. If this value is larger we detect more points. If it is zero we probably do not detect points even if they are inside due to rounding errors. +# Returns +The number of children of *element*. ### Prototype ```c -void t8_forest_element_points_inside (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, int num_points, int *is_inside, const double tolerance); +int t8_element_get_num_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) - @ccall libt8.t8_forest_element_points_inside(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, points::Ptr{Cdouble}, num_points::Cint, is_inside::Ptr{Cint}, tolerance::Cdouble)::Cvoid +function t8_element_get_num_children(scheme, tree_class, element) + @ccall libt8.t8_element_get_num_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) + t8_get_max_num_children(scheme, tree_class) + +Return the max number of children of an eclass. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +# Returns +The max number of children of *element*. ### Prototype ```c -t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, t8_scheme_cxx_t *scheme, const int level, const int do_face_ghost, sc_MPI_Comm comm); +int t8_get_max_num_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -function t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) - @ccall libt8.t8_forest_new_uniform(cmesh::t8_cmesh_t, scheme::Ptr{t8_scheme_cxx_t}, level::Cint, do_face_ghost::Cint, comm::MPI_Comm)::t8_forest_t +function t8_get_max_num_children(scheme, tree_class) + @ccall libt8.t8_get_max_num_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cint end """ - t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) + t8_element_get_num_face_children(scheme, tree_class, element, face) -Build a adapted forest from another forest. - -!!! note - - This is equivalent to calling t8_forest_init, t8_forest_set_adapt, t8_forest_set_ghost, and t8_forest_commit +Compute the number of children of an element's face when the element is refined. # Arguments -* `forest_from`:\\[in\\] The forest to refine -* `adapt_fn`:\\[in\\] Adapt function to use -* `replace_fn`:\\[in\\] Replace function to use -* `recursive`:\\[in\\] If true adptation is recursive -* `do_face_ghost`:\\[in\\] If true, a layer of ghost elements is created for the forest. -* `user_data`:\\[in\\] If not NULL, the user data pointer of the forest is set to this value. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] A face of *element*. # Returns -A new forest that is adapted from *forest_from*. +The number of children of *face* if *element* is to be refined. ### Prototype ```c -t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, int recursive, int do_face_ghost, void *user_data); +int t8_element_get_num_face_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); ``` """ -function t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) - @ccall libt8.t8_forest_new_adapt(forest_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint, do_face_ghost::Cint, user_data::Ptr{Cvoid})::t8_forest_t +function t8_element_get_num_face_children(scheme, tree_class, element, face) + @ccall libt8.t8_element_get_num_face_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_forest_ref(forest) + t8_element_get_face_corner(scheme, tree_class, element, face, corner) -Increase the reference counter of a forest. +Return the corner number of an element's face corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 Thus for face = 1 the output is: corner=0 : 1, corner=1: 3 + +The order in which the corners must be given is determined by the eclass of *element*: LINE/QUAD/TRIANGLE: No specific order. HEX : In Z-order of the face starting with the lowest corner number. TET : Starting with the lowest corner number counterclockwise as seen from 'outside' of the element. # Arguments -* `forest`:\\[in,out\\] On input, this forest must exist with positive reference count. It may be in any state. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] A face index for *element*. +* `corner`:\\[in\\] A corner index for the face 0 <= *corner* < num\\_face\\_corners. +# Returns +The corner number of the *corner*-th vertex of *face*. ### Prototype ```c -void t8_forest_ref (t8_forest_t forest); +int t8_element_get_face_corner (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, const int corner); ``` """ -function t8_forest_ref(forest) - @ccall libt8.t8_forest_ref(forest::t8_forest_t)::Cvoid +function t8_element_get_face_corner(scheme, tree_class, element, face, corner) + @ccall libt8.t8_element_get_face_corner(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, corner::Cint)::Cint end """ - t8_forest_unref(pforest) + t8_element_get_corner_face(scheme, tree_class, element, corner, face) -Decrease the reference counter of a forest. If the counter reaches zero, this forest is destroyed. In this case, the forest dereferences its cmesh and scheme members. +Compute the face numbers of the faces sharing an element's corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 face 2 Thus for corner = 1 the output is: face=0 : 2, face=1: 1 # Arguments -* `pforest`:\\[in,out\\] On input, the forest pointed to must exist with positive reference count. It may be in any state. If the reference count reaches zero, the forest is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the forest is not modified in other ways. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `corner`:\\[in\\] A corner index for the face. +* `face`:\\[in\\] A face index for *corner*. +# Returns +The face number of the *face*-th face at *corner*. ### Prototype ```c -void t8_forest_unref (t8_forest_t *pforest); +int t8_element_get_corner_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int corner, const int face); ``` """ -function t8_forest_unref(pforest) - @ccall libt8.t8_forest_unref(pforest::Ptr{t8_forest_t})::Cvoid +function t8_element_get_corner_face(scheme, tree_class, element, corner, face) + @ccall libt8.t8_element_get_corner_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, corner::Cint, face::Cint)::Cint end """ - t8_forest_get_dimension(forest) + t8_element_get_child(scheme, tree_class, element, childid, child) + +Construct the child element of a given number. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] This must be a valid element, bigger than maxlevel. +* `childid`:\\[in\\] The number of the child to construct. +* `child`:\\[in,out\\] The storage for this element must exist. On output, a valid element. It is valid to call this function with element = child. ### Prototype ```c -int t8_forest_get_dimension (const t8_forest_t forest); +void t8_element_get_child (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int childid, t8_element_t *child); ``` """ -function t8_forest_get_dimension(forest) - @ccall libt8.t8_forest_get_dimension(forest::t8_forest_t)::Cint +function t8_element_get_child(scheme, tree_class, element, childid, child) + @ccall libt8.t8_element_get_child(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, childid::Cint, child::Ptr{t8_element_t})::Cvoid end """ - t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) + t8_element_get_children(scheme, tree_class, element, length, c) -### Prototype -```c -void t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8_element_t *element, int corner_number, double *coordinates); -``` -""" -function t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) - @ccall libt8.t8_forest_element_coordinate(forest::t8_forest_t, ltree_id::t8_locidx_t, element::Ptr{t8_element_t}, corner_number::Cint, coordinates::Ptr{Cdouble})::Cvoid -end +Construct all children of a given element. -""" - t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] This must be a valid element, bigger than maxlevel. +* `length`:\\[in\\] The length of the output array *c* must match the number of children. +* `c`:\\[in,out\\] The storage for these *length* elements must exist and match the element class in the children's ordering. On output, all children are valid. It is valid to call this function with element = c[0]. +# See also +t8\\_element\\_num\\_children ### Prototype ```c -void t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out, const double *stretch_factors); +void t8_element_get_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int length, t8_element_t *c[]); ``` """ -function t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) - @ccall libt8.t8_forest_element_from_ref_coords_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble}, stretch_factors::Ptr{Cdouble})::Cvoid +function t8_element_get_children(scheme, tree_class, element, length, c) + @ccall libt8.t8_element_get_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, length::Cint, c::Ptr{Ptr{t8_element_t}})::Cvoid end """ - t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) + t8_element_get_child_id(scheme, tree_class, element) +Compute the child id of an element. + +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] This must be a valid element. +# Returns +The child id of element. ### Prototype ```c -void t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out); +int t8_element_get_child_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) - @ccall libt8.t8_forest_element_from_ref_coords(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble})::Cvoid +function t8_element_get_child_id(scheme, tree_class, element) + @ccall libt8.t8_element_get_child_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_element_centroid(forest, ltreeid, element, coordinates) + t8_element_get_ancestor_id(scheme, tree_class, element, level) +Compute the ancestor id of an element, that is the child id at a given level. + +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] This must be a valid element. +* `level`:\\[in\\] A refinement level. Must satisfy *level* < element.level +# Returns +The child\\_id of *element* in regard to its *level* ancestor. ### Prototype ```c -void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); +int t8_element_get_ancestor_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int level); ``` """ -function t8_forest_element_centroid(forest, ltreeid, element, coordinates) - @ccall libt8.t8_forest_element_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, coordinates::Ptr{Cdouble})::Cvoid +function t8_element_get_ancestor_id(scheme, tree_class, element, level) + @ccall libt8.t8_element_get_ancestor_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint)::Cint end """ - t8_forest_element_diam(forest, ltreeid, element) + t8_elements_are_family(scheme, tree_class, fam) +Query whether a given set of elements is a family or not. + +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `fam`:\\[in\\] An array of as many elements as an element of class **scheme** has children. +# Returns +Zero if **fam** is not a family, nonzero if it is. ### Prototype ```c -double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); +int t8_elements_are_family (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t *const *fam); ``` """ -function t8_forest_element_diam(forest, ltreeid, element) - @ccall libt8.t8_forest_element_diam(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble +function t8_elements_are_family(scheme, tree_class, fam) + @ccall libt8.t8_elements_are_family(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, fam::Ptr{Ptr{t8_element_t}})::Cint end """ - t8_forest_element_volume(forest, ltreeid, element) + t8_element_get_nca(scheme, tree_class, elem1, elem2, nca) + +Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both given elements as descendants. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The first of the two input elements. +* `elem2`:\\[in\\] The second of the two input elements. +* `nca`:\\[in,out\\] The storage for this element must exist and match the element class of the child. On output the unique nearest common ancestor of **elem1** and **elem2**. ### Prototype ```c -double t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); +void t8_element_get_nca (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca); ``` """ -function t8_forest_element_volume(forest, ltreeid, element) - @ccall libt8.t8_forest_element_volume(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble +function t8_element_get_nca(scheme, tree_class, elem1, elem2, nca) + @ccall libt8.t8_element_get_nca(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t}, nca::Ptr{t8_element_t})::Cvoid end """ - t8_forest_element_face_area(forest, ltreeid, element, face) + t8_element_get_face_shape(scheme, tree_class, element, face) + +Compute the shape of the face of an element. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] A face of *element*. +# Returns +The element shape of the face. I.e. T8\\_ECLASS\\_LINE for quads, T8\\_ECLASS\\_TRIANGLE for tets and depending on the face number either T8\\_ECLASS\\_QUAD or T8\\_ECLASS\\_TRIANGLE for prisms. ### Prototype ```c -double t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face); +t8_element_shape_t t8_element_get_face_shape (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); ``` """ -function t8_forest_element_face_area(forest, ltreeid, element, face) - @ccall libt8.t8_forest_element_face_area(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint)::Cdouble +function t8_element_get_face_shape(scheme, tree_class, element, face) + @ccall libt8.t8_element_get_face_shape(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::t8_element_shape_t end """ - t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) + t8_element_get_children_at_face(scheme, tree_class, element, face, children, num_children, child_indices) + +Given an element and a face of the element, compute all children of the element that touch the face. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] A face of *element*. +* `children`:\\[in,out\\] Allocated elements, in which the children of *element* that share a face with *face* are stored. They will be stored in order of their linear id. +* `num_children`:\\[in\\] The number of elements in *children*. Must match the number of children that touch *face*. t8_scheme::element_get_num_face_children +* `child_indices`:\\[in,out\\] If not NULL, an array of num\\_children integers must be given, on output its i-th entry is the child\\_id of the i-th face\\_child. It is valid to call this function with element = children[0]. ### Prototype ```c -void t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double centroid[3]); +void t8_element_get_children_at_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, t8_element_t *children[], const int num_children, int *child_indices); ``` """ -function t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) - @ccall libt8.t8_forest_element_face_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, centroid::Ptr{Cdouble})::Cvoid +function t8_element_get_children_at_face(scheme, tree_class, element, face, children, num_children, child_indices) + @ccall libt8.t8_element_get_children_at_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, children::Ptr{Ptr{t8_element_t}}, num_children::Cint, child_indices::Ptr{Cint})::Cvoid end """ - t8_forest_element_face_normal(forest, ltreeid, element, face, normal) + t8_element_face_get_child_face(scheme, tree_class, element, face, face_child) + +Given a face of an element and a child number of a child of that face, return the face number of the child of the element that matches the child face. + +```c++ + x ---- x x x x ---- x + | | | | | | | <-- f + | | | x | x--x + | | | | | + x ---- x x x ---- x + element face face_child Returns the face number f +``` +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] Then number of the face. +* `face_child`:\\[in\\] A number 0 <= *face_child* < num\\_face\\_children, specifying a child of *element* that shares a face with *face*. These children are counted in linear order. This coincides with the order of children from a call to t8_scheme::element_get_children_at_face. +# Returns +The face number of the face of a child of *element* that coincides with *face_child*. ### Prototype ```c -void t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double normal[3]); +int t8_element_face_get_child_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, const int face_child); ``` """ -function t8_forest_element_face_normal(forest, ltreeid, element, face, normal) - @ccall libt8.t8_forest_element_face_normal(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, normal::Ptr{Cdouble})::Cvoid +function t8_element_face_get_child_face(scheme, tree_class, element, face, face_child) + @ccall libt8.t8_element_face_get_child_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, face_child::Cint)::Cint end """ - t8_forest_ghost + t8_element_face_get_parent_face(scheme, tree_class, element, face) -| Field | Note | -| :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| rc | The reference counter. | -| num\\_ghosts\\_elements | The count of non-local ghost elements | -| num\\_remote\\_elements | The count of local elements that are ghost to another process. | -| ghost\\_type | Describes which neighbors are considered ghosts. | -| ghost\\_trees | ghost tree data: global\\_id. eclass. elements. In linear id order | -| global\\_tree\\_to\\_ghost\\_tree | Indexes into ghost\\_trees. Given a global tree id I give the index i such that the tree is in ghost\\_trees[i] | -| process\\_offsets | Given a process, return the first ghost tree and within it the first element of that process. | -| remote\\_ghosts | array of local trees that have ghost elements for another process. for each tree an array of [`t8_element_t`](@ref) * of the local ghost elements. Also an array of [`t8_locidx_t`](@ref) of the local indices of these elements within the tree. It is a hash table, hashed with the rank of a remote process. Sorted within each process by linear id. | -| remote\\_processes | The ranks of the processes for which local elements are ghost. Array of int's. | -""" -struct t8_forest_ghost - rc::t8_refcount_t - num_ghosts_elements::t8_locidx_t - num_remote_elements::t8_locidx_t - ghost_type::t8_ghost_type_t - ghost_trees::Ptr{sc_array_t} - global_tree_to_ghost_tree::Ptr{sc_hash_t} - process_offsets::Ptr{sc_hash_t} - remote_ghosts::Ptr{sc_hash_array_t} - remote_processes::Ptr{sc_array_t} - glo_tree_mempool::Ptr{sc_mempool_t} - proc_offset_mempool::Ptr{sc_mempool_t} -end +Given a face of an element return the face number of the parent of the element that matches the element's face. Or return -1 if no face of the parent matches the face. -const t8_forest_ghost_t = Ptr{t8_forest_ghost} +!!! note -""" - t8_forest_ghost_init(pghost, ghost_type) + For the root element this function always returns *face*. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] Then number of the face. +# Returns +If *face* of *element* is also a face of *element*'s parent, the face number of this face. Otherwise -1. ### Prototype ```c -void t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type); +int t8_element_face_get_parent_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); ``` """ -function t8_forest_ghost_init(pghost, ghost_type) - @ccall libt8.t8_forest_ghost_init(pghost::Ptr{t8_forest_ghost_t}, ghost_type::t8_ghost_type_t)::Cvoid +function t8_element_face_get_parent_face(scheme, tree_class, element, face) + @ccall libt8.t8_element_face_get_parent_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_forest_ghost_num_trees(forest) + t8_element_get_tree_face(scheme, tree_class, element, face) + +Given an element and a face of this element. If the face lies on the tree boundary, return the face number of the tree face. If not the return value is arbitrary. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] The index of a face of *element*. +# Returns +The index of the tree face that *face* is a subface of, if *face* is on a tree boundary. Any arbitrary integer if *is* not at a tree boundary. ### Prototype ```c -t8_locidx_t t8_forest_ghost_num_trees (const t8_forest_t forest); +int t8_element_get_tree_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); ``` """ -function t8_forest_ghost_num_trees(forest) - @ccall libt8.t8_forest_ghost_num_trees(forest::t8_forest_t)::t8_locidx_t +function t8_element_get_tree_face(scheme, tree_class, element, face) + @ccall libt8.t8_element_get_tree_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_forest_ghost_get_tree_element_offset(forest, lghost_tree) + t8_element_transform_face(scheme, tree_class, elem1, elem2, orientation, sign, is_smaller_face) -Return the element offset of a ghost tree. +Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the trees and given the orientation of the tree connection, construct the face element of the respective tree neighbor that logically coincides with e but lies in the coordinate system of the neighbor tree. !!! note - forest must be committed before calling this function. + *elem1* and *elem2* may point to the same element. # Arguments -* `forest`:\\[in\\] The forest with constructed ghost layer. -* `lghost_tree`:\\[in\\] A local ghost id of a ghost tree. -# Returns -The element offset of this ghost tree. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The face element. +* `elem2`:\\[in,out\\] On return the face element *elem1* with respect to the coordinate system of the other tree. +* `orientation`:\\[in\\] The orientation of the tree-tree connection. +* `sign`:\\[in\\] Depending on the topological orientation of the two tree faces, either 0 (both faces have opposite orientation) or 1 (both faces have the same top. orientation). t8_eclass_face_orientation +* `is_smaller_face`:\\[in\\] Flag to declare whether *elem1* belongs to the smaller face. A face f of tree T is smaller than f' of T' if either the eclass of T is smaller or if the classes are equal and fghost\\_trees array of the tree. Otherwise a negative number. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The input element. +* `face`:\\[in\\] A face of *element*. +* `first_desc`:\\[in,out\\] An allocated element. This element's data will be filled with the data of the first descendant of *element* that shares a face with *face*. +* `level`:\\[in\\] The level, at which the first descendant is constructed ### Prototype ```c -t8_locidx_t t8_forest_ghost_get_ghost_treeid (t8_forest_t forest, t8_gloidx_t gtreeid); +void t8_element_get_first_descendant_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, t8_element_t *first_desc, const int level); ``` """ -function t8_forest_ghost_get_ghost_treeid(forest, gtreeid) - @ccall libt8.t8_forest_ghost_get_ghost_treeid(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t +function t8_element_get_first_descendant_face(scheme, tree_class, element, face, first_desc, level) + @ccall libt8.t8_element_get_first_descendant_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, first_desc::Ptr{t8_element_t}, level::Cint)::Cvoid end """ - t8_forest_ghost_get_tree_class(forest, lghost_tree) + t8_element_get_last_descendant_face(scheme, tree_class, element, face, last_desc, level) + +Construct the last descendant of an element at a given level that touches a given face. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The input element. +* `face`:\\[in\\] A face of *element*. +* `last_desc`:\\[in,out\\] An allocated element. This element's data will be filled with the data of the last descendant of *element* that shares a face with *face*. +* `level`:\\[in\\] The level, at which the last descendant is constructed ### Prototype ```c -t8_eclass_t t8_forest_ghost_get_tree_class (const t8_forest_t forest, const t8_locidx_t lghost_tree); +void t8_element_get_last_descendant_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, t8_element_t *last_desc, const int level); ``` """ -function t8_forest_ghost_get_tree_class(forest, lghost_tree) - @ccall libt8.t8_forest_ghost_get_tree_class(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_eclass_t +function t8_element_get_last_descendant_face(scheme, tree_class, element, face, last_desc, level) + @ccall libt8.t8_element_get_last_descendant_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, last_desc::Ptr{t8_element_t}, level::Cint)::Cvoid end """ - t8_forest_ghost_get_global_treeid(forest, lghost_tree) + t8_element_is_root_boundary(scheme, tree_class, element, face) -Given a local ghost tree compute the global tree id of it. +Compute whether a given element shares a given face with its root tree. # Arguments -* `forest`:\\[in\\] The forest. Ghost layer must exist. -* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The input element. +* `face`:\\[in\\] A face of *element*. # Returns -The global id of the local ghost tree *lghost_tree*. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +True if *face* is a subface of the element's root element. ### Prototype ```c -t8_gloidx_t t8_forest_ghost_get_global_treeid (const t8_forest_t forest, const t8_locidx_t lghost_tree); +int t8_element_is_root_boundary (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); ``` """ -function t8_forest_ghost_get_global_treeid(forest, lghost_tree) - @ccall libt8.t8_forest_ghost_get_global_treeid(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_gloidx_t +function t8_element_is_root_boundary(scheme, tree_class, element, face) + @ccall libt8.t8_element_is_root_boundary(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_forest_ghost_get_element(forest, lghost_tree, lelement) + t8_element_get_face_neighbor_inside(scheme, tree_class, element, neigh, face, neigh_face) + +Construct the face neighbor of a given element if this face neighbor is inside the root tree. Return 0 otherwise. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element to be considered. +* `neigh`:\\[in,out\\] If the face neighbor of *element* along *face* is inside the root tree, this element's data is filled with the data of the face neighbor. Otherwise the data can be modified arbitrarily. +* `face`:\\[in\\] The number of the face along which the neighbor should be constructed. +* `neigh_face`:\\[out\\] The number of *face* as viewed from *neigh*. An arbitrary value, if the neighbor is not inside the root tree. +# Returns +True if *neigh* is inside the root tree. False if not. In this case *neigh*'s data can be arbitrary on output. ### Prototype ```c -t8_element_t * t8_forest_ghost_get_element (t8_forest_t forest, t8_locidx_t lghost_tree, t8_locidx_t lelement); +int t8_element_get_face_neighbor_inside (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *neigh, const int face, int *neigh_face); ``` """ -function t8_forest_ghost_get_element(forest, lghost_tree, lelement) - @ccall libt8.t8_forest_ghost_get_element(forest::t8_forest_t, lghost_tree::t8_locidx_t, lelement::t8_locidx_t)::Ptr{t8_element_t} +function t8_element_get_face_neighbor_inside(scheme, tree_class, element, neigh, face, neigh_face) + @ccall libt8.t8_element_get_face_neighbor_inside(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, neigh::Ptr{t8_element_t}, face::Cint, neigh_face::Ptr{Cint})::Cint end """ - t8_forest_ghost_get_remotes(forest, num_remotes) + t8_element_get_shape(scheme, tree_class, element) -Return the array of remote ranks. +Return the shape of an allocated element according its type. For example, a child of an element can be an element of a different shape and has to be handled differently - according to its shape. # Arguments -* `forest`:\\[in\\] A forest with constructed ghost layer. -* `num_remotes`:\\[in,out\\] On output the number of remote ranks is stored here. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element to be considered # Returns -The array of remote ranks in ascending order. +The shape of the element as an eclass ### Prototype ```c -int * t8_forest_ghost_get_remotes (t8_forest_t forest, int *num_remotes); +t8_element_shape_t t8_element_get_shape (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_ghost_get_remotes(forest, num_remotes) - @ccall libt8.t8_forest_ghost_get_remotes(forest::t8_forest_t, num_remotes::Ptr{Cint})::Ptr{Cint} +function t8_element_get_shape(scheme, tree_class, element) + @ccall libt8.t8_element_get_shape(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::t8_element_shape_t end """ - t8_forest_ghost_remote_first_tree(forest, remote) + t8_element_set_linear_id(scheme, tree_class, element, level, id) -Return the first local ghost tree of a remote rank. +Initialize the entries of an allocated element according to a given linear id in a uniform refinement. # Arguments -* `forest`:\\[in\\] A forest with constructed ghost layer. -* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. -# Returns -The ghost tree id of the first ghost tree that stores ghost elements of *remote*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in,out\\] The element whose entries will be set. +* `level`:\\[in\\] The level of the uniform refinement to consider. +* `id`:\\[in\\] The linear id. id must fulfil 0 <= id < 'number of leaves in the uniform refinement' ### Prototype ```c -t8_locidx_t t8_forest_ghost_remote_first_tree (t8_forest_t forest, int remote); +void t8_element_set_linear_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t *element, const int level, const t8_linearidx_t id); ``` """ -function t8_forest_ghost_remote_first_tree(forest, remote) - @ccall libt8.t8_forest_ghost_remote_first_tree(forest::t8_forest_t, remote::Cint)::t8_locidx_t +function t8_element_set_linear_id(scheme, tree_class, element, level, id) + @ccall libt8.t8_element_set_linear_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint, id::t8_linearidx_t)::Cvoid end """ - t8_forest_ghost_remote_first_elem(forest, remote) + t8_element_get_linear_id(scheme, tree_class, element, level) -Return the local index of the first ghost element that belongs to a given remote rank. +Compute the linear id of a given element in a hypothetical uniform refinement of a given level. # Arguments -* `forest`:\\[in\\] A forest with constructed ghost layer. -* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element whose id we compute. +* `level`:\\[in\\] The level of the uniform refinement to consider. # Returns -The index i in the ghost elements of the first element of rank *remote* +The linear id of the element. ### Prototype ```c -t8_locidx_t t8_forest_ghost_remote_first_elem (t8_forest_t forest, int remote); +t8_linearidx_t t8_element_get_linear_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int level); ``` """ -function t8_forest_ghost_remote_first_elem(forest, remote) - @ccall libt8.t8_forest_ghost_remote_first_elem(forest::t8_forest_t, remote::Cint)::t8_locidx_t +function t8_element_get_linear_id(scheme, tree_class, element, level) + @ccall libt8.t8_element_get_linear_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint)::t8_linearidx_t end """ - t8_forest_ghost_ref(ghost) + t8_element_get_first_descendant(scheme, tree_class, element, desc, level) -Increase the reference count of a ghost structure. +Compute the first descendant of a given element. # Arguments -* `ghost`:\\[in,out\\] On input, this ghost structure must exist with positive reference count. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element whose descendant is computed. +* `desc`:\\[out\\] The first element in a uniform refinement of *element* at level *level*. +* `level`:\\[in\\] The uniform refinement level at which the descendant is computed. *level* must be greater or equal to the level of *element*. ### Prototype ```c -void t8_forest_ghost_ref (t8_forest_ghost_t ghost); +void t8_element_get_first_descendant (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *desc, const int level); ``` """ -function t8_forest_ghost_ref(ghost) - @ccall libt8.t8_forest_ghost_ref(ghost::t8_forest_ghost_t)::Cvoid +function t8_element_get_first_descendant(scheme, tree_class, element, desc, level) + @ccall libt8.t8_element_get_first_descendant(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, desc::Ptr{t8_element_t}, level::Cint)::Cvoid end """ - t8_forest_ghost_unref(pghost) + t8_element_get_last_descendant(scheme, tree_class, element, desc, level) -Decrease the reference count of a ghost structure. If the counter reaches zero, the ghost structure is destroyed. See also t8_forest_ghost_destroy, which is to be preferred when it is known that the last reference to a cmesh is deleted. +Compute the last descendant of a given element. # Arguments -* `pghost`:\\[in,out\\] On input, the ghost structure pointed to must exist with positive reference count. If the reference count reaches zero, the ghost structure is destroyed and this pointer is set to NULL. Otherwise, the pointer is not changed. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element whose descendant is computed. +* `desc`:\\[out\\] The last element in a uniform refinement of *element* of the maximum possible level. +* `level`:\\[in\\] The uniform refinement level at which the descendant is computed. *level* must be greater or equal to the level of *element*. ### Prototype ```c -void t8_forest_ghost_unref (t8_forest_ghost_t *pghost); +void t8_element_get_last_descendant (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *desc, const int level); ``` """ -function t8_forest_ghost_unref(pghost) - @ccall libt8.t8_forest_ghost_unref(pghost::Ptr{t8_forest_ghost_t})::Cvoid +function t8_element_get_last_descendant(scheme, tree_class, element, desc, level) + @ccall libt8.t8_element_get_last_descendant(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, desc::Ptr{t8_element_t}, level::Cint)::Cvoid end """ - t8_forest_ghost_destroy(pghost) + t8_element_get_successor(scheme, tree_class, elem1, elem2) -Verify that a ghost structure has only one reference left and destroy it. This function is preferred over t8_ghost_unref when it is known that the last reference is to be deleted. +Construct the successor in a uniform refinement of a given element. # Arguments -* `pghost`:\\[in,out\\] This ghost structure must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_forest_ghost_unref. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The element whose successor should be constructed. +* `elem2`:\\[in,out\\] The element whose entries will be set. ### Prototype ```c -void t8_forest_ghost_destroy (t8_forest_ghost_t *pghost); +void t8_element_get_successor (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, t8_element_t *elem2); ``` """ -function t8_forest_ghost_destroy(pghost) - @ccall libt8.t8_forest_ghost_destroy(pghost::Ptr{t8_forest_ghost_t})::Cvoid +function t8_element_get_successor(scheme, tree_class, elem1, elem2) + @ccall libt8.t8_element_get_successor(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cvoid end """ - t8_forest_ghost_create(forest) + t8_element_get_vertex_reference_coords(scheme, tree_class, element, vertex, coords) -Create one layer of ghost elements for a forest. +Compute the coordinates of a given element vertex inside a reference tree that is embedded into [0,1]^d (d = dimension). -# Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. -# See also -[`t8_forest_set_ghost`](@ref) +!!! warning + + coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere all coords might be used. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element to be considered. +* `vertex`:\\[in\\] The id of the vertex whose coordinates shall be computed. +* `coords`:\\[out\\] An array of at least as many doubles as the element's dimension whose entries will be filled with the coordinates of *vertex*. ### Prototype ```c -void t8_forest_ghost_create (t8_forest_t forest); +void t8_element_get_vertex_reference_coords (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int vertex, double coords[]); ``` """ -function t8_forest_ghost_create(forest) - @ccall libt8.t8_forest_ghost_create(forest::t8_forest_t)::Cvoid +function t8_element_get_vertex_reference_coords(scheme, tree_class, element, vertex, coords) + @ccall libt8.t8_element_get_vertex_reference_coords(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, vertex::Cint, coords::Ptr{Cdouble})::Cvoid end """ - t8_forest_ghost_create_balanced_only(forest) + t8_element_get_reference_coords(scheme, tree_class, element, ref_coords, num_coords, out_coords) -Create one layer of ghost elements for a forest. This version only works with balanced forests and is the original algorithm from p4est: Scalable Algorithms For Parallel Adaptive Mesh Refinement On Forests of Octrees +Convert points in the reference space of an element to points in the reference space of the tree. -!!! note +```c++ + [0,1]^\\mathrm{dim} +``` - The user should prefer t8_forest_ghost_create even for balanced forests. +of the point in the reference space of the element. + +```c++ + dim +``` + +-sized coordinates to evaluate. # Arguments -* `forest`:\\[in,out\\] The balanced forest/ *forest* must be committed before calling this function. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of the current tree. +* `element`:\\[in\\] The element. +* `ref_coords`:\\[in\\] The coordinates +* `num_coords`:\\[in\\] Number of +* `out_coords`:\\[out\\] The coordinates of the points in the reference space of the tree. ### Prototype ```c -void t8_forest_ghost_create_balanced_only (t8_forest_t forest); +void t8_element_get_reference_coords (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double out_coords[]); ``` """ -function t8_forest_ghost_create_balanced_only(forest) - @ccall libt8.t8_forest_ghost_create_balanced_only(forest::t8_forest_t)::Cvoid +function t8_element_get_reference_coords(scheme, tree_class, element, ref_coords, num_coords, out_coords) + @ccall libt8.t8_element_get_reference_coords(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid end """ - t8_forest_ghost_create_topdown(forest) + t8_element_count_leaves(scheme, tree_class, element, level) + +Count how many leaf descendants of a given uniform level an element would produce. +Example: If *element* is a line element that refines into 2 line elements on each level, then the return value is max(0, 2^{*level* - level(*t*)}). Thus, if *element*'s level is 0, and *level* = 3, the return value is 2^3 = 8. + +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element to be checked. +* `level`:\\[in\\] A refinement level. +# Returns +Suppose *element* is uniformly refined up to level *level*. The return value is the resulting number of elements (of the given level). If *level* < [`t8_element_get_level`](@ref)(element), the return value should be 0. ### Prototype ```c -void t8_forest_ghost_create_topdown (t8_forest_t forest); +t8_gloidx_t t8_element_count_leaves (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int level); ``` """ -function t8_forest_ghost_create_topdown(forest) - @ccall libt8.t8_forest_ghost_create_topdown(forest::t8_forest_t)::Cvoid +function t8_element_count_leaves(scheme, tree_class, element, level) + @ccall libt8.t8_element_count_leaves(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint)::t8_gloidx_t end """ - t8_forest_save(forest) + t8_element_count_leaves_from_root(scheme, tree_class, level) +Count how many leaf descendants of a given uniform level the root element will produce. + +This is a convenience function, and can be implemented via t8_element_count_leaves. + +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `level`:\\[in\\] A refinement level. +# Returns +The value of t8_element_count_leaves if the input element is the root (level 0) element. ### Prototype ```c -void t8_forest_save (t8_forest_t forest); +t8_gloidx_t t8_element_count_leaves_from_root (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int level); ``` """ -function t8_forest_save(forest) - @ccall libt8.t8_forest_save(forest::t8_forest_t)::Cvoid +function t8_element_count_leaves_from_root(scheme, tree_class, level) + @ccall libt8.t8_element_count_leaves_from_root(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, level::Cint)::t8_gloidx_t end """ - t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) + t8_element_to_string(scheme, tree_class, element, debug_string, string_size) +Fill a string with readable information about the element + +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of the current tree. +* `element`:\\[in\\] The element to translate into human-readable information. +* `debug_string`:\\[in,out\\] The string to fill. +* `string_size`:\\[in\\] The length of *debug_string*. ### Prototype ```c -int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, const int write_curved, int do_not_use_API, const int num_data, t8_vtk_data_field_t *data); +void t8_element_to_string (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, char *debug_string, const int string_size); ``` """ -function t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) - @ccall libt8.t8_forest_write_vtk_ext(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, write_curved::Cint, do_not_use_API::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_element_to_string(scheme, tree_class, element, debug_string, string_size) + @ccall libt8.t8_element_to_string(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, debug_string::Cstring, string_size::Cint)::Cvoid end """ - t8_forest_write_vtk(forest, fileprefix) + t8_element_new(scheme, tree_class, length, elems) + +Allocate memory for an array of elements of a given class and initialize them. + +!!! note + + Not every element that is created in t8code will be created by a call to this function. However, if an element is not created using t8_element_new, then it is guaranteed that t8_scheme::element_init is called on it. + +!!! note + + In debugging mode, an element that was created with t8_element_new must pass t8_element_is_valid. + +!!! note + + If an element was created by t8_element_new then t8_scheme::element_init may not be called for it. Thus, t8_element_new should initialize an element in the same way as a call to t8_scheme::element_init would. + +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `length`:\\[in\\] The number of elements to be allocated. +* `elems`:\\[in,out\\] On input an array of **length** many unallocated element pointers. On output all these pointers will point to an allocated and initialized element. +# See also +[`t8_element_init`](@ref), element\\_is\\_valid ### Prototype ```c -int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix); +void t8_element_new (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t **elems); ``` """ -function t8_forest_write_vtk(forest, fileprefix) - @ccall libt8.t8_forest_write_vtk(forest::t8_forest_t, fileprefix::Cstring)::Cint +function t8_element_new(scheme, tree_class, length, elems) + @ccall libt8.t8_element_new(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elems::Ptr{Ptr{t8_element_t}})::Cvoid end -# typedef int ( * t8_forest_iterate_face_fn ) ( t8_forest_t forest , t8_locidx_t ltreeid , const t8_element_t * element , int face , void * user_data , t8_locidx_t tree_leaf_index ) -const t8_forest_iterate_face_fn = Ptr{Cvoid} - -# typedef int ( * t8_forest_search_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index ) """ -A call-back function used by t8_forest_search describing a search-criterion. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. + t8_element_init(scheme, tree_class, length, elem) -# Arguments -* `forest`:\\[in\\] the forest -* `ltreeid`:\\[in\\] the local tree id of the current tree -* `element`:\\[in\\] the element for which the search criterion is checked. -* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element -* `leaf_elements`:\\[in\\] the leaf elements in *forest* that are descendants of *element* (or the element itself if *is_leaf* is true) -* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* -# Returns -non-zero if the search criterion is met, zero otherwise. -""" -const t8_forest_search_fn = Ptr{Cvoid} +Initialize an array of allocated elements. -# typedef void ( * t8_forest_query_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , sc_array_t * queries , sc_array_t * query_indices , int * query_matches , const size_t num_active_queries ) -""" -A call-back function used by t8_forest_search for queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. +!!! note -# Arguments -* `forest`:\\[in\\] the forest -* `ltreeid`:\\[in\\] the local tree id of the current tree -* `element`:\\[in\\] the element for which the queries are executed -* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element -* `leaf_elements`:\\[in\\] the leaf elements in *forest* that are descendants of *element* (or the element itself if *is_leaf* is true) -* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* -* `queries`:\\[in\\] An array of queries that are checked by the function -* `query_indices`:\\[in\\] An array of size\\_t entries, where each entry is an index of a query in queries. -* `query_matches`:\\[in,out\\] An array of length *num_active_queries*. If the element is not a leave must be set to true or false at the i-th index for each query, specifying whether the element 'matches' the query of the i-th query index or not. When the element is a leaf we can return before all entries are set. -* `num_active_queries`:\\[in\\] The number of currently active queries (equals the number of entries of *query_matches* and entries of *query_indices*). -""" -const t8_forest_query_fn = Ptr{Cvoid} + In debugging mode, an element that was passed to t8_element_init must pass t8_element_is_valid. -""" - t8_forest_split_array(element, leaf_elements, offsets) +!!! note + + If an element was created by t8_element_new then t8_element_init may not be called for it. Thus, t8_element_init should initialize an element in the same way as a call to t8_element_new would. + +!!! note + + Every call to + +# Arguments +* `scheme`:\\[in\\] The scheme to use. +* `tree_class`:\\[in\\] The eclass of the current tree. +* `length`:\\[in\\] The number of elements to be initialized. +* `elem`:\\[in,out\\] On input an array of *length* many allocated elements. +# See also +[`t8_element_init`](@ref) must be matched by a call to, [`t8_element_deinit`](@ref), [`t8_element_deinit`](@ref), [`t8_element_new`](@ref), t8\\_element\\_is\\_valid ### Prototype ```c -void t8_forest_split_array (const t8_element_t *element, t8_element_array_t *leaf_elements, size_t *offsets); +void t8_element_init (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t *elem); ``` """ -function t8_forest_split_array(element, leaf_elements, offsets) - @ccall libt8.t8_forest_split_array(element::Ptr{t8_element_t}, leaf_elements::Ptr{t8_element_array_t}, offsets::Ptr{Csize_t})::Cvoid +function t8_element_init(scheme, tree_class, length, elem) + @ccall libt8.t8_element_init(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elem::Ptr{t8_element_t})::Cvoid end """ - t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, user_data, tree_lindex_of_first_leaf, callback) + t8_element_deinit(scheme, tree_class, length, elems) + +Deinitialize an array of allocated elements. + +!!! note + + Call this function if you called t8_element_init on the element pointers. + +# Arguments +* `scheme`:\\[in\\] The scheme to use. +* `tree_class`:\\[in\\] The eclass of the current tree. +* `length`:\\[in\\] The number of elements to be deinitialized. +* `elems`:\\[in,out\\] On input an array of *length* many allocated and initialized elements, on output an array of *length* many allocated, but not initialized elements. +# See also +[`t8_element_init`](@ref) ### Prototype ```c -void t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, t8_element_array_t *leaf_elements, void *user_data, t8_locidx_t tree_lindex_of_first_leaf, t8_forest_iterate_face_fn callback); +void t8_element_deinit (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t *elems); ``` """ -function t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, user_data, tree_lindex_of_first_leaf, callback) - @ccall libt8.t8_forest_iterate_faces(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, leaf_elements::Ptr{t8_element_array_t}, user_data::Ptr{Cvoid}, tree_lindex_of_first_leaf::t8_locidx_t, callback::t8_forest_iterate_face_fn)::Cvoid +function t8_element_deinit(scheme, tree_class, length, elems) + @ccall libt8.t8_element_deinit(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elems::Ptr{t8_element_t})::Cvoid end """ - t8_forest_search(forest, search_fn, query_fn, queries) + t8_element_destroy(scheme, tree_class, length, elems) + +Deallocate an array of elements. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `length`:\\[in\\] The number of elements in the array. +* `elems`:\\[in,out\\] On input an array of **length** many allocated element pointers. On output all these pointers will be freed. **element** itself will not be freed by this function. ### Prototype ```c -void t8_forest_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries); +void t8_element_destroy (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t **elems); ``` """ -function t8_forest_search(forest, search_fn, query_fn, queries) - @ccall libt8.t8_forest_search(forest::t8_forest_t, search_fn::t8_forest_search_fn, query_fn::t8_forest_query_fn, queries::Ptr{sc_array_t})::Cvoid +function t8_element_destroy(scheme, tree_class, length, elems) + @ccall libt8.t8_element_destroy(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elems::Ptr{Ptr{t8_element_t}})::Cvoid end """ - t8_forest_iterate_replace(forest_new, forest_old, replace_fn) - -Given two forest where the elements in one forest are either direct children or parents of the elements in the other forest compare the two forests and for each refined element or coarsened family in the old one, call a callback function providing the local indices of the old and new elements. - -!!! note + t8_element_set_to_root(scheme, tree_class, element) - To pass a user pointer to *replace_fn* use t8_forest_set_user_data and t8_forest_get_user_data. +Fills an element with the root element. # Arguments -* `forest_new`:\\[in\\] A forest, each element is a parent or child of an element in *forest_old*. -* `forest_old`:\\[in\\] The initial forest. -* `replace_fn`:\\[in\\] A replace callback function. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in,out\\] The element to be filled with root. ### Prototype ```c -void t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_forest_replace_t replace_fn); +void t8_element_set_to_root (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t *element); ``` """ -function t8_forest_iterate_replace(forest_new, forest_old, replace_fn) - @ccall libt8.t8_forest_iterate_replace(forest_new::t8_forest_t, forest_old::t8_forest_t, replace_fn::t8_forest_replace_t)::Cvoid +function t8_element_set_to_root(scheme, tree_class, element) + @ccall libt8.t8_element_set_to_root(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cvoid end """ - t8_forest_partition(forest) + t8_element_MPI_Pack(scheme, tree_class, elements, count, send_buffer, buffer_size, position, comm) ### Prototype ```c -void t8_forest_partition (t8_forest_t forest); +void t8_element_MPI_Pack (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t **const elements, const unsigned int count, void *send_buffer, const int buffer_size, int *position, sc_MPI_Comm comm); ``` """ -function t8_forest_partition(forest) - @ccall libt8.t8_forest_partition(forest::t8_forest_t)::Cvoid +function t8_element_MPI_Pack(scheme, tree_class, elements, count, send_buffer, buffer_size, position, comm) + @ccall libt8.t8_element_MPI_Pack(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elements::Ptr{Ptr{t8_element_t}}, count::Cuint, send_buffer::Ptr{Cvoid}, buffer_size::Cint, position::Ptr{Cint}, comm::MPI_Comm)::Cvoid end """ - t8_forest_partition_create_offsets(forest) - -Create the element\\_offset array of a partitioned forest. + t8_element_MPI_Pack_size(scheme, tree_class, count, comm, pack_size) -# Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -void t8_forest_partition_create_offsets (t8_forest_t forest); +void t8_element_MPI_Pack_size (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const unsigned int count, sc_MPI_Comm comm, int *pack_size); ``` """ -function t8_forest_partition_create_offsets(forest) - @ccall libt8.t8_forest_partition_create_offsets(forest::t8_forest_t)::Cvoid +function t8_element_MPI_Pack_size(scheme, tree_class, count, comm, pack_size) + @ccall libt8.t8_element_MPI_Pack_size(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, count::Cuint, comm::MPI_Comm, pack_size::Ptr{Cint})::Cvoid +end + +""" + t8_element_MPI_Unpack(scheme, tree_class, recvbuf, buffer_size, position, elements, count, comm) + +### Prototype +```c +void t8_element_MPI_Unpack (const t8_scheme_c *scheme, const t8_eclass_t tree_class, void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm); +``` +""" +function t8_element_MPI_Unpack(scheme, tree_class, recvbuf, buffer_size, position, elements, count, comm) + @ccall libt8.t8_element_MPI_Unpack(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, recvbuf::Ptr{Cvoid}, buffer_size::Cint, position::Ptr{Cint}, elements::Ptr{Ptr{t8_element_t}}, count::Cuint, comm::MPI_Comm)::Cvoid end """ - t8_forest_partition_next_nonempty_rank(forest, rank) + t8_norm(vec) -If t8_forest_partition_create_offsets was already called, compute for a given rank the next greater rank that is not empty. +Vector norm. # Arguments -* `forest`:\\[in\\] The forest. -* `rank`:\\[in\\] An MPI rank. +* `vec`:\\[in\\] A 3D vector. # Returns -A rank q > *rank* such that the forest has elements on *q*. If such a *q* does not exist, returns mpisize. +The norm of *vec*. ### Prototype ```c -int t8_forest_partition_next_nonempty_rank (t8_forest_t forest, int rank); +double t8_norm (const double vec[3]); ``` """ -function t8_forest_partition_next_nonempty_rank(forest, rank) - @ccall libt8.t8_forest_partition_next_nonempty_rank(forest::t8_forest_t, rank::Cint)::Cint +function t8_norm(vec) + @ccall libt8.t8_norm(vec::Ptr{Cdouble})::Cdouble end """ - t8_forest_partition_create_first_desc(forest) + t8_normalize(vec) -Create the array of global\\_first\\_descendant ids of a partitioned forest. +Normalize a vector. # Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +* `vec`:\\[in,out\\] A 3D vector. ### Prototype ```c -void t8_forest_partition_create_first_desc (t8_forest_t forest); +void t8_normalize (double vec[3]); ``` """ -function t8_forest_partition_create_first_desc(forest) - @ccall libt8.t8_forest_partition_create_first_desc(forest::t8_forest_t)::Cvoid +function t8_normalize(vec) + @ccall libt8.t8_normalize(vec::Ptr{Cdouble})::Cvoid end """ - t8_forest_partition_create_tree_offsets(forest) + t8_copy(dimensional_in, dimensional_out) -Create the array tree offsets of a partitioned forest. This arrays stores at position p the global id of the first tree of this process. Or if this tree is shared, it stores -(global\\_id) - 1. +Make a copy of a dimensional object. # Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +* `dimensional_in`:\\[in\\] +* `dimensional_out`:\\[out\\] ### Prototype ```c -void t8_forest_partition_create_tree_offsets (t8_forest_t forest); +void t8_copy (const double dimensional_in[3], double dimensional_out[3]); ``` """ -function t8_forest_partition_create_tree_offsets(forest) - @ccall libt8.t8_forest_partition_create_tree_offsets(forest::t8_forest_t)::Cvoid +function t8_copy(dimensional_in, dimensional_out) + @ccall libt8.t8_copy(dimensional_in::Ptr{Cdouble}, dimensional_out::Ptr{Cdouble})::Cvoid end """ - t8_forest_partition_data(forest_from, forest_to, data_in, data_out) - -Re-Partition an array accordingly to a partitioned forest. - -!!! note + t8_dist(vec_x, vec_y) - *data_in* has to be of size equal to the number of local elements of *forest_from* *data_out* has to be already allocated and has to be of size equal to the number of local elements of *forest_to*. +Euclidean distance of X and Y. # Arguments -* `forest_form`:\\[in\\] The forest before the partitioning step. -* `forest_to`:\\[in\\] The partitioned forest of *forest_from*. -* `data_in`:\\[in\\] A pointer to an [`sc_array_t`](@ref) holding data (one value per element) accordingly to *forest_from*. -* `data_out`:\\[in,out\\] A pointer to an already allocated [`sc_array_t`](@ref) capable of holding data accordingly to *forest_to*. +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +# Returns +The euclidean distance. Equivalent to norm (X-Y). ### Prototype ```c -void t8_forest_partition_data (t8_forest_t forest_from, t8_forest_t forest_to, const sc_array_t *data_in, sc_array_t *data_out); +double t8_dist (const double vec_x[3], const double vec_y[3]); ``` """ -function t8_forest_partition_data(forest_from, forest_to, data_in, data_out) - @ccall libt8.t8_forest_partition_data(forest_from::t8_forest_t, forest_to::t8_forest_t, data_in::Ptr{sc_array_t}, data_out::Ptr{sc_array_t})::Cvoid +function t8_dist(vec_x, vec_y) + @ccall libt8.t8_dist(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble end """ - t8_forest_partition_test_boundary_element(forest) - -Test if the last descendant of the last element of current rank has a smaller linear id than the stored first descendant of rank+1. If this is not the case, elements overlap. - -!!! note + t8_ax(vec_x, alpha) - *forest* must be committed before calling this function. +Compute X = alpha * X # Arguments -* `forest`:\\[in\\] The forest. +* `vec_x`:\\[in,out\\] A 3D vector. On output set to *alpha* * *vec_x*. +* `alpha`:\\[in\\] A factor. ### Prototype ```c -void t8_forest_partition_test_boundary_element (const t8_forest_t forest); +void t8_ax (double vec_x[3], const double alpha); ``` """ -function t8_forest_partition_test_boundary_element(forest) - @ccall libt8.t8_forest_partition_test_boundary_element(forest::t8_forest_t)::Cvoid +function t8_ax(vec_x, alpha) + @ccall libt8.t8_ax(vec_x::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - t8_forest_set_profiling(forest, set_profiling) + t8_axy(vec_x, vec_y, alpha) + +Compute Y = alpha * X +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[out\\] On output set to *alpha* * *vec_x*. +* `alpha`:\\[in\\] A factor. ### Prototype ```c -void t8_forest_set_profiling (t8_forest_t forest, int set_profiling); +void t8_axy (const double vec_x[3], double vec_y[3], const double alpha); ``` """ -function t8_forest_set_profiling(forest, set_profiling) - @ccall libt8.t8_forest_set_profiling(forest::t8_forest_t, set_profiling::Cint)::Cvoid +function t8_axy(vec_x, vec_y, alpha) + @ccall libt8.t8_axy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - t8_forest_compute_profile(forest) + t8_axb(vec_x, vec_y, alpha, b) + +Y = alpha * X + b + +!!! note + + It is possible that vec\\_x = vec\\_y on input to overwrite x +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[out\\] On input, a 3D vector. On output set to *alpha* * *vec_x* + *b*. +* `alpha`:\\[in\\] A factor. +* `b`:\\[in\\] An offset. ### Prototype ```c -void t8_forest_compute_profile (t8_forest_t forest); +void t8_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b); ``` """ -function t8_forest_compute_profile(forest) - @ccall libt8.t8_forest_compute_profile(forest::t8_forest_t)::Cvoid +function t8_axb(vec_x, vec_y, alpha, b) + @ccall libt8.t8_axb(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble, b::Cdouble)::Cvoid end """ - t8_forest_profile_get_adapt_stats(forest) + t8_axpy(vec_x, vec_y, alpha) + +Y = Y + alpha * X +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in,out\\] On input, a 3D vector. On output set *to* vec\\_y + *alpha* * *vec_x* +* `alpha`:\\[in\\] A factor. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_adapt_stats (t8_forest_t forest); +void t8_axpy (const double vec_x[3], double vec_y[3], const double alpha); ``` """ -function t8_forest_profile_get_adapt_stats(forest) - @ccall libt8.t8_forest_profile_get_adapt_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function t8_axpy(vec_x, vec_y, alpha) + @ccall libt8.t8_axpy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - t8_forest_profile_get_ghost_stats(forest) + t8_axpyz(vec_x, vec_y, vec_z, alpha) + +Z = Y + alpha * X +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +* `vec_z`:\\[out\\] On output set *to* vec\\_y + *alpha* * *vec_x* +* `alpha`:\\[in\\] A factor for the multiplication of *vec_x*. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_ghost_stats (t8_forest_t forest); +void t8_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], const double alpha); ``` """ -function t8_forest_profile_get_ghost_stats(forest) - @ccall libt8.t8_forest_profile_get_ghost_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function t8_axpyz(vec_x, vec_y, vec_z, alpha) + @ccall libt8.t8_axpyz(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, vec_z::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - t8_forest_profile_get_partition_stats(forest) + t8_dot(vec_x, vec_y) + +Dot product of X and Y. +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +# Returns +The dot product *vec_x* * *vec_y* ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_partition_stats (t8_forest_t forest); +double t8_dot (const double vec_x[3], const double vec_y[3]); ``` """ -function t8_forest_profile_get_partition_stats(forest) - @ccall libt8.t8_forest_profile_get_partition_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function t8_dot(vec_x, vec_y) + @ccall libt8.t8_dot(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble end """ - t8_forest_profile_get_commit_stats(forest) + t8_cross_3D(vec_x, vec_y, cross) +Cross product of X and Y + +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +* `cross`:\\[out\\] On output, the cross product of *vec_x* and *vec_y*. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_commit_stats (t8_forest_t forest); +void t8_cross_3D (const double vec_x[3], const double vec_y[3], double cross[3]); ``` """ -function t8_forest_profile_get_commit_stats(forest) - @ccall libt8.t8_forest_profile_get_commit_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function t8_cross_3D(vec_x, vec_y, cross) + @ccall libt8.t8_cross_3D(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, cross::Ptr{Cdouble})::Cvoid end """ - t8_forest_profile_get_balance_stats(forest) + t8_cross_2D(vec_x, vec_y) + +Cross product of X and Y +# Arguments +* `vec_x`:\\[in\\] A 2D vector. +* `vec_y`:\\[in\\] A 2D vector. +# Returns +The cross product of *vec_x* and *vec_y*. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_balance_stats (t8_forest_t forest); +double t8_cross_2D (const double vec_x[2], const double vec_y[2]); ``` """ -function t8_forest_profile_get_balance_stats(forest) - @ccall libt8.t8_forest_profile_get_balance_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function t8_cross_2D(vec_x, vec_y) + @ccall libt8.t8_cross_2D(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble end """ - t8_forest_profile_get_balance_rounds_stats(forest) + t8_diff(vec_x, vec_y, diff) + +Compute the difference of two vectors. +# Arguments +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +* `diff`:\\[out\\] On output, the difference of *vec_x* and *vec_y*. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); +void t8_diff (const double vec_x[3], const double vec_y[3], double diff[3]); ``` """ -function t8_forest_profile_get_balance_rounds_stats(forest) - @ccall libt8.t8_forest_profile_get_balance_rounds_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function t8_diff(vec_x, vec_y, diff) + @ccall libt8.t8_diff(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, diff::Ptr{Cdouble})::Cvoid end """ - t8_forest_print_profile(forest) + t8_eq(vec_x, vec_y, tol) +Check the equality of two vectors elementwise + +# Arguments +* `vec_x`:\\[in\\] +* `vec_y`:\\[in\\] +* `tol`:\\[in\\] +# Returns +true, if the vectors are equal up to *tol* ### Prototype ```c -void t8_forest_print_profile (t8_forest_t forest); +int t8_eq (const double vec_x[3], const double vec_y[3], const double tol); ``` """ -function t8_forest_print_profile(forest) - @ccall libt8.t8_forest_print_profile(forest::t8_forest_t)::Cvoid +function t8_eq(vec_x, vec_y, tol) + @ccall libt8.t8_eq(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, tol::Cdouble)::Cint end """ - t8_forest_profile_get_adapt_time(forest) + t8_rescale(vec, new_length) +Rescale a vector to a new length. + +# Arguments +* `vec`:\\[in,out\\] A 3D vector. +* `new_length`:\\[in\\] New length of the vector. ### Prototype ```c -double t8_forest_profile_get_adapt_time (t8_forest_t forest); +void t8_rescale (double vec[3], const double new_length); ``` """ -function t8_forest_profile_get_adapt_time(forest) - @ccall libt8.t8_forest_profile_get_adapt_time(forest::t8_forest_t)::Cdouble +function t8_rescale(vec, new_length) + @ccall libt8.t8_rescale(vec::Ptr{Cdouble}, new_length::Cdouble)::Cvoid end """ - t8_forest_profile_get_partition_time(forest, procs_sent) + t8_normal_of_tri(p1, p2, p3, normal) + +Compute the normal of a triangle given by its three vertices. +# Arguments +* `p1`:\\[in\\] A 3D vector. +* `p2`:\\[in\\] A 3D vector. +* `p3`:\\[in\\] A 3D vector. +* `normal`:\\[out\\] vector of the triangle. (Not necessarily of length 1!) ### Prototype ```c -double t8_forest_profile_get_partition_time (t8_forest_t forest, int *procs_sent); +void t8_normal_of_tri (const double p1[3], const double p2[3], const double p3[3], double normal[3]); ``` """ -function t8_forest_profile_get_partition_time(forest, procs_sent) - @ccall libt8.t8_forest_profile_get_partition_time(forest::t8_forest_t, procs_sent::Ptr{Cint})::Cdouble +function t8_normal_of_tri(p1, p2, p3, normal) + @ccall libt8.t8_normal_of_tri(p1::Ptr{Cdouble}, p2::Ptr{Cdouble}, p3::Ptr{Cdouble}, normal::Ptr{Cdouble})::Cvoid end """ - t8_forest_profile_get_balance_time(forest, balance_rounds) + t8_orthogonal_tripod(v1, v2, v3) + +Compute an orthogonal coordinate system from a given vector. +# Arguments +* `v1`:\\[in\\] 3D vector. +* `v2`:\\[out\\] 3D vector. +* `v3`:\\[out\\] 3D vector. ### Prototype ```c -double t8_forest_profile_get_balance_time (t8_forest_t forest, int *balance_rounds); +void t8_orthogonal_tripod (const double v1[3], double v2[3], double v3[3]); ``` """ -function t8_forest_profile_get_balance_time(forest, balance_rounds) - @ccall libt8.t8_forest_profile_get_balance_time(forest::t8_forest_t, balance_rounds::Ptr{Cint})::Cdouble +function t8_orthogonal_tripod(v1, v2, v3) + @ccall libt8.t8_orthogonal_tripod(v1::Ptr{Cdouble}, v2::Ptr{Cdouble}, v3::Ptr{Cdouble})::Cvoid end """ - t8_forest_profile_get_ghost_time(forest, ghosts_sent) + t8_swap(p1, p2) + +Swap the components of two vectors. +# Arguments +* `p1`:\\[in,out\\] A 3D vector. +* `p2`:\\[in,out\\] A 3D vector. ### Prototype ```c -double t8_forest_profile_get_ghost_time (t8_forest_t forest, t8_locidx_t *ghosts_sent); +void t8_swap (double p1[3], double p2[3]); ``` """ -function t8_forest_profile_get_ghost_time(forest, ghosts_sent) - @ccall libt8.t8_forest_profile_get_ghost_time(forest::t8_forest_t, ghosts_sent::Ptr{Cint})::Cdouble +function t8_swap(p1, p2) + @ccall libt8.t8_swap(p1::Ptr{Cdouble}, p2::Ptr{Cdouble})::Cvoid end """ - t8_forest_profile_get_ghostexchange_waittime(forest) + t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) + +Writes the pvtu header file that links to the processor local files. It is used by the cmesh and forest vtk routines. This function should only be called by one process. Return 0 on success. ### Prototype ```c -double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest); +int t8_write_pvtu (const char *filename, int num_procs, int write_tree, int write_rank, int write_level, int write_id, int num_data, t8_vtk_data_field_t *data); ``` """ -function t8_forest_profile_get_ghostexchange_waittime(forest) - @ccall libt8.t8_forest_profile_get_ghostexchange_waittime(forest::t8_forest_t)::Cdouble +function t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) + @ccall libt8.t8_write_pvtu(filename::Cstring, num_procs::Cint, write_tree::Cint, write_rank::Cint, write_level::Cint, write_id::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_profile - -| Field | Note | -| :----------------------------- | :--------------------------------------------------------------------------------------------------------------------- | -| partition\\_elements\\_shipped | The number of elements this process has sent to other in the last partition call. | -| partition\\_elements\\_recv | The number of elements this process has received from other in the last partition call. | -| partition\\_bytes\\_sent | The total number of bytes sent to other processes in the last partition call. | -| partition\\_procs\\_sent | The number of different processes this process has send local elements to in the last partition call. | -| ghosts\\_shipped | The number of ghost elements this process has sent to other processes. | -| ghosts\\_received | The number of ghost elements this process has received from other processes. | -| ghosts\\_remotes | The number of processes this process have sent ghost elements to (and received from). | -| balance\\_rounds | The number of iterations during balance. | -| adapt\\_runtime | The runtime of the last call to [`t8_forest_adapt`](@ref) (not counting adaptation in [`t8_forest_balance`](@ref)). | -| partition\\_runtime | The runtime of the last call to [`t8_cmesh_partition`](@ref) (not count in partition in [`t8_forest_balance`](@ref)). | -| ghost\\_runtime | The runtime of the last call to [`t8_forest_ghost_create`](@ref). | -| ghost\\_waittime | Amount of synchronisation time in ghost. | -| balance\\_runtime | The runtime of the last call to [`t8_forest_balance`](@ref). | -| commit\\_runtime | The runtime of the last call to [`t8_cmesh_commit`](@ref). | -""" -struct t8_profile - partition_elements_shipped::t8_locidx_t - partition_elements_recv::t8_locidx_t - partition_bytes_sent::Csize_t - partition_procs_sent::Cint - ghosts_shipped::t8_locidx_t - ghosts_received::t8_locidx_t - ghosts_remotes::Cint - balance_rounds::Cint - adapt_runtime::Cdouble - partition_runtime::Cdouble - ghost_runtime::Cdouble - ghost_waittime::Cdouble - balance_runtime::Cdouble - commit_runtime::Cdouble -end - -const t8_profile_t = t8_profile - -"""If a forest is to be derived from another forest, there are different possibilities how the original forest is modified. Currently we support: Copying, adapting, partitioning, and balancing a forest. The latter 3 can be combined, in which case the order is 1. Adapt, 2. Partition, 3. Balance. We store the methods in an int8\\_t and use these defines to distinguish between them.""" -const t8_forest_from_t = Int8 - -"""This structure is private to the implementation.""" -const t8_forest_struct_t = t8_forest - -"""The t8 tree datatype""" -const t8_tree_struct_t = t8_tree - -const t8_profile_struct_t = t8_profile + vtk_file_type -const t8_forest_ghost_struct_t = t8_forest_ghost +Enumerator for all types of files readable by t8code. +| Enumerator | Note | +| :----------------------------------- | :--------------------------------------------- | +| VTK\\_FILE\\_ERROR | For Testing purpose. | +| VTK\\_SERIAL\\_FILE | VTK file type of serial files. | +| VTK\\_UNSTRUCTURED\\_FILE | Unstructured file type is the same as serial. | +| VTK\\_POLYDATA\\_FILE | VTK polydata file type. | +| VTK\\_PARALLEL\\_FILE | VTK file type of parallel files. | +| VTK\\_PARALLEL\\_UNSTRUCTURED\\_FILE | For parallel unstructured files. | +| VTK\\_PARALLEL\\_POLYDATA\\_FILE | VTK polydata parallel file type. | +| VTK\\_NUM\\_TYPES | Number of different vtk file types supported. | """ - t8_geometry_type - -This enumeration contains all possible geometries. +@cenum vtk_file_type::Int32 begin + VTK_FILE_ERROR = -1 + VTK_SERIAL_FILE = 8 + VTK_UNSTRUCTURED_FILE = 8 + VTK_POLYDATA_FILE = 9 + VTK_PARALLEL_FILE = 16 + VTK_PARALLEL_UNSTRUCTURED_FILE = 16 + VTK_PARALLEL_POLYDATA_FILE = 17 + VTK_NUM_TYPES = 5 +end + +"""Enumerator for all types of files readable by t8code.""" +const vtk_file_type_t = vtk_file_type -| Enumerator | Note | -| :--------------------------------------------- | :----------------------------------------------------------------------------------------------- | -| T8\\_GEOMETRY\\_TYPE\\_ZERO | The zero geometry maps all points to zero. | -| T8\\_GEOMETRY\\_TYPE\\_LINEAR | The linear geometry uses linear interpolations to interpolate between the tree vertices. | -| T8\\_GEOMETRY\\_TYPE\\_LINEAR\\_AXIS\\_ALIGNED | The linear, axis aligned geometry uses only 2 vertices, since it is axis aligned. | -| T8\\_GEOMETRY\\_TYPE\\_LAGRANGE | The Lagrange geometry uses a mapping with Lagrange polynomials to approximate curved elements . | -| T8\\_GEOMETRY\\_TYPE\\_ANALYTIC | The analytic geometry uses a user-defined analytic function to map into the physical domain. | -| T8\\_GEOMETRY\\_TYPE\\_CAD | The opencascade geometry uses CAD shapes to map trees exactly to the underlying CAD model. | -| T8\\_GEOMETRY\\_TYPE\\_COUNT | This is no geometry type but can be used as the number of geometry types. | -| T8\\_GEOMETRY\\_TYPE\\_UNDEFINED | This is no geometry type but is used for every geometry, where no type is defined | """ -@cenum t8_geometry_type::UInt32 begin - T8_GEOMETRY_TYPE_ZERO = 0 - T8_GEOMETRY_TYPE_LINEAR = 1 - T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED = 2 - T8_GEOMETRY_TYPE_LAGRANGE = 3 - T8_GEOMETRY_TYPE_ANALYTIC = 4 - T8_GEOMETRY_TYPE_CAD = 5 - T8_GEOMETRY_TYPE_COUNT = 6 - T8_GEOMETRY_TYPE_UNDEFINED = 7 + vtk_read_success + +Enumerator for the success of reading a vtk file. This is used to indicate whether the reading was successful or not. + +| Enumerator | Note | +| :------------- | :----------------------------------------------- | +| read\\_failure | Indicates that file reading was not successful. | +| read\\_success | Indicates that file reading was successful. | +""" +@cenum vtk_read_success::UInt32 begin + read_failure = 0 + read_success = 1 end -"""This enumeration contains all possible geometries.""" -const t8_geometry_type_t = t8_geometry_type +"""Enumerator for the success of reading a vtk file. This is used to indicate whether the reading was successful or not.""" +const vtk_read_success_t = vtk_read_success """ - t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) + t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) -Evaluates the geometry of a tree at a given reference point. +Write the forest in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function uses the vtk library. t8code must be configured with "-DT8CODE\\_ENABLE\\_VTK=ON" in order to use it. Currently does not support pyramid elements. + +!!! note + + If t8code was not configured with vtk, use t8_forest_vtk_write_file # Arguments -* `cmesh`:\\[in\\] The cmesh -* `gtreeid`:\\[in\\] The global id of the tree -* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the geometry -* `num_coords`:\\[in\\] The number of reference coordinates -* `out_coords`:\\[out\\] The evaluated coordinates +* `forest`:\\[in\\] The forest. +* `fileprefix`:\\[in\\] The prefix of the output files. The meta file will be named *fileprefix*.pvtu . +* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. +* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. +* `write_level`:\\[in\\] If true, the refinement level is written for each element. +* `write_element_id`:\\[in\\] If true, the global element id is written for each element. +* `curved_flag`:\\[in\\] If true, write the elements as curved element types from vtk. +* `write_ghosts`:\\[in\\] If true, write out ghost elements as well. +* `num_data`:\\[in\\] Number of user defined double valued data fields to write. +* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the user defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. +# Returns +True if successful, false if not (process local). ### Prototype ```c -void t8_geometry_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords); +int t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int curved_flag, const int write_ghosts, const int num_data, t8_vtk_data_field_t *data); ``` """ -function t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) - @ccall libt8.t8_geometry_evaluate(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) + @ccall libt8.t8_forest_vtk_write_file_via_API(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, curved_flag::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) + t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) -Evaluates the jacobian of a tree at a given reference point. +Write the forest in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configured with "-DT8CODE\\_ENABLE\\_VTK=ON" and t8_forest_vtk_write_file_via_API is not available. # Arguments -* `cmesh`:\\[in\\] The cmesh -* `gtreeid`:\\[in\\] The global id of the tree -* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the jacobian -* `num_coords`:\\[in\\] The number of reference coordinates -* `jacobian`:\\[out\\] The jacobian at the reference coordinates +* `forest`:\\[in\\] The forest. +* `fileprefix`:\\[in\\] The prefix of the output files. +* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. +* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. +* `write_level`:\\[in\\] If true, the refinement level is written for each element. +* `write_element_id`:\\[in\\] If true, the global element id is written for each element. +* `write_ghosts`:\\[in\\] If true, each process additionally writes its ghost elements. For ghost element the treeid is -1. +* `num_data`:\\[in\\] Number of user defined double valued data fields to write. +* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the used defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. +# Returns +True if successful, false if not (process local). ### Prototype ```c -void t8_geometry_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *jacobian); +int t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data); ``` """ -function t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) - @ccall libt8.t8_geometry_jacobian(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, jacobian::Ptr{Cdouble})::Cvoid +function t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) + @ccall libt8.t8_forest_vtk_write_file(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_geometry_get_type(cmesh, gtreeid) - -This function returns the geometry type of a tree. + t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh -* `gtreeid`:\\[in\\] The global id of the tree -# Returns -The geometry type of the tree with id gtreeid ### Prototype ```c -t8_geometry_type_t t8_geometry_get_type (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); +int t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm); ``` """ -function t8_geometry_get_type(cmesh, gtreeid) - @ccall libt8.t8_geometry_get_type(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::t8_geometry_type_t +function t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) + @ccall libt8.t8_cmesh_vtk_write_file_via_API(cmesh::t8_cmesh_t, fileprefix::Cstring, comm::MPI_Comm)::Cint end """ - t8_geometry_tree_negative_volume(cmesh, gtreeid) + t8_cmesh_vtk_write_file(cmesh, fileprefix) -Check if a tree has a negative volume +Write the cmesh in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configured with "-DT8CODE\\_ENABLE\\_VTK=ON" and t8_cmesh_vtk_write_file_via_API is not available. # Arguments -* `cmesh`:\\[in\\] The cmesh to check -* `gtreeid`:\\[in\\] The global id of the tree +* `cmesh`:\\[in\\] The cmesh +* `fileprefix`:\\[in\\] The prefix of the output files # Returns -True if the tree with id gtreeid has a negative volume. False otherwise. +True (nonzero) if successful, false (zero) otherwise ### Prototype ```c -int t8_geometry_tree_negative_volume (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid); +int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); ``` """ -function t8_geometry_tree_negative_volume(cmesh, gtreeid) - @ccall libt8.t8_geometry_tree_negative_volume(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Cint +function t8_cmesh_vtk_write_file(cmesh, fileprefix) + @ccall libt8.t8_cmesh_vtk_write_file(cmesh::t8_cmesh_t, fileprefix::Cstring)::Cint end """ - t8_geom_get_name(geom) - -Get the name of a geometry. + t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) -# Arguments -* `geom`:\\[in\\] A geometry. -# Returns -The name of *geom*. ### Prototype ```c -const char * t8_geom_get_name (const t8_geometry_c *geom); +t8_cmesh_t t8_cmesh_from_msh_file (const char *fileprefix, int partition, sc_MPI_Comm comm, int dim, int master, int use_cad_geometry); ``` """ -function t8_geom_get_name(geom) - @ccall libt8.t8_geom_get_name(geom::Ptr{t8_geometry_c})::Cstring +function t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) + @ccall libt8.t8_cmesh_from_msh_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, dim::Cint, master::Cint, use_cad_geometry::Cint)::t8_cmesh_t end +mutable struct t8_cmesh_vertex_connectivity end + """ - t8_geom_get_type(geom) +[`t8_cmesh_vertex_connectivity_c`](@ref) -Get the type of a geometry. +Opaque pointer to the cmesh vertex connectivity structure. +""" +const t8_cmesh_vertex_connectivity_c = Ptr{t8_cmesh_vertex_connectivity} + +""" + t8_cmesh_set_global_vertices_of_tree(cmesh, global_tree, global_tree_vertices, num_vertices) -# Arguments -* `geom`:\\[in\\] A geometry. -# Returns -The type of *geom*. ### Prototype ```c -t8_geometry_type_t t8_geom_get_type (const t8_geometry_c *geom); +void t8_cmesh_set_global_vertices_of_tree (const t8_cmesh_t cmesh, const t8_gloidx_t global_tree, const t8_gloidx_t *global_tree_vertices, const int num_vertices); ``` """ -function t8_geom_get_type(geom) - @ccall libt8.t8_geom_get_type(geom::Ptr{t8_geometry_c})::t8_geometry_type_t +function t8_cmesh_set_global_vertices_of_tree(cmesh, global_tree, global_tree_vertices, num_vertices) + @ccall libt8.t8_cmesh_set_global_vertices_of_tree(cmesh::Cint, global_tree::Cint, global_tree_vertices::Ptr{Cint}, num_vertices::Cint)::Cvoid end """ - t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + t8_cmesh_get_num_global_vertices(cmesh) ### Prototype ```c -void t8_geom_compute_linear_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); +t8_gloidx_t t8_cmesh_get_num_global_vertices (const t8_cmesh_t cmesh); ``` """ -function t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) - @ccall libt8.t8_geom_compute_linear_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function t8_cmesh_get_num_global_vertices(cmesh) + @ccall libt8.t8_cmesh_get_num_global_vertices(cmesh::Cint)::Cint end """ - t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + t8_cmesh_get_num_local_vertices(cmesh) ### Prototype ```c -void t8_geom_compute_linear_axis_aligned_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); +t8_locidx_t t8_cmesh_get_num_local_vertices (const t8_cmesh_t cmesh); ``` """ -function t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) - @ccall libt8.t8_geom_compute_linear_axis_aligned_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function t8_cmesh_get_num_local_vertices(cmesh) + @ccall libt8.t8_cmesh_get_num_local_vertices(cmesh::Cint)::Cint end """ - t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) - -Interpolates linearly between 2, bilinearly between 4 or trilineraly between 8 points. + t8_cmesh_get_global_vertices_of_tree(cmesh, local_tree, num_vertices) -# Arguments -* `coefficients`:\\[in\\] An array of size at least dim giving the coefficients used for the interpolation -* `corner_values`:\\[in\\] An array of size 2^dim * 3, giving for each corner (in zorder) of the unit square/cube its function values in space. -* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. -* `interpolation_dim`:\\[in\\] The dimension of the interpolation (1 for linear, 2 for bilinear, 3 for trilinear) -* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -void t8_geom_linear_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); +const t8_gloidx_t * t8_cmesh_get_global_vertices_of_tree (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, int *num_vertices); ``` """ -function t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) - @ccall libt8.t8_geom_linear_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid +function t8_cmesh_get_global_vertices_of_tree(cmesh, local_tree, num_vertices) + @ccall libt8.t8_cmesh_get_global_vertices_of_tree(cmesh::Cint, local_tree::Cint, num_vertices::Ptr{Cint})::Ptr{Cint} end """ - t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) - -Triangular interpolation between 3 points (triangle) or 4 points (tetrahedron) using cartesian coordinates. The input coefficients have to be given as coordinates in the reference triangle (interpolation\\_dim = 2) with points (0,0) (1,0) (1,1) or the reference tet (interpolation\\_dim = 3) with points (0,0,0) (1,0,0) (1,1,0) (1,1,1). + t8_cmesh_get_global_vertex_of_tree(cmesh, local_tree, local_tree_vertex) -# Arguments -* `coefficients`:\\[in\\] An array of size *interpolation_dim* giving the coefficients in the reference triangle/tet used for the interpolation -* `corner_values`:\\[in\\] An array of size 3 * *corner_value_dim* for *interpolation_dim* == 2 or 4 * *corner_value_dim* for *interpolation_dim* == 3, giving the function values of the triangle/tetrahedron for each corner (in zorder) -* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. -* `interpolation_dim`:\\[in\\] The dimension of the interpolation (2 for triangle, 3 for tetrahedron) -* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -void t8_geom_triangular_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); +t8_gloidx_t t8_cmesh_get_global_vertex_of_tree (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, const int local_tree_vertex); ``` """ -function t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) - @ccall libt8.t8_geom_triangular_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid +function t8_cmesh_get_global_vertex_of_tree(cmesh, local_tree, local_tree_vertex) + @ccall libt8.t8_cmesh_get_global_vertex_of_tree(cmesh::Cint, local_tree::Cint, local_tree_vertex::Cint)::Cint end """ - t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) + t8_cmesh_get_num_trees_at_vertex(cmesh, global_vertex) ### Prototype ```c -void t8_geom_get_face_vertices (t8_eclass_t tree_class, const double *tree_vertices, int face_index, int dim, double *face_vertices); +int t8_cmesh_get_num_trees_at_vertex (const t8_cmesh_t cmesh, t8_gloidx_t global_vertex); ``` """ -function t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) - @ccall libt8.t8_geom_get_face_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, face_index::Cint, dim::Cint, face_vertices::Ptr{Cdouble})::Cvoid +function t8_cmesh_get_num_trees_at_vertex(cmesh, global_vertex) + @ccall libt8.t8_cmesh_get_num_trees_at_vertex(cmesh::Cint, global_vertex::Cint)::Cint end """ - t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) + t8_cmesh_uses_vertex_connectivity(cmesh) ### Prototype ```c -void t8_geom_get_edge_vertices (t8_eclass_t tree_class, const double *tree_vertices, int edge_index, int dim, double *edge_vertices); +int t8_cmesh_uses_vertex_connectivity (const t8_cmesh_t cmesh); ``` """ -function t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) - @ccall libt8.t8_geom_get_edge_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, edge_index::Cint, dim::Cint, edge_vertices::Ptr{Cdouble})::Cvoid +function t8_cmesh_uses_vertex_connectivity(cmesh) + @ccall libt8.t8_cmesh_uses_vertex_connectivity(cmesh::Cint)::Cint end +# typedef int ( * t8_search_element_callback_c_wrapper ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , void * user_data ) """ - t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) +A call-back function used by t8_forest_init_search for searching elements. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. -Calculates a point of intersection in a triangular reference space. The intersection is the extension of a straight line passing through a reference point and the opposite vertex of the edge. /|\\ / | \\ o -> reference point / o \\ x -> intersection point / | \\ /\\_\\_\\_\\_x\\_\\_\\_\\_\\ +# Arguments +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. +* `element`:\\[in\\] the element for which the search criterion is checked +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* +* `user_data`:\\[in\\] a user data pointer that can be set by the user +# Returns +non-zero if the search criterion is met, zero otherwise. +""" +const t8_search_element_callback_c_wrapper = Ptr{Cvoid} + +# typedef int ( * t8_search_queries_callback_c_wrapper ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , void * queries , void * user_data ) +""" +A call-back function used by t8_forest_init_search_with_queries for searching elements and executing queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. # Arguments -* `edge_index`:\\[in\\] Index of the edge, the intersection lies on. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -* `ref_intersection`:\\[out\\] Coordinates of the intersection point. +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. +* `element`:\\[in\\] the element for which the search criterion is checked +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* +* `queries`:\\[in\\] a pointer to an array of queries +* `user_data`:\\[in\\] a user data pointer that can be set by the user +""" +const t8_search_queries_callback_c_wrapper = Ptr{Cvoid} + +# typedef void ( * t8_search_batched_queries_callback_c_wrapper ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , const void * queries , const size_t * active_query_indices , int * query_matches , void * user_data ) +""" +A call-back function used by t8_forest_init_search_with_batched_queries for searching elements and executing batched queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. + +# Arguments +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. +* `element`:\\[in\\] the element for which the search criterion is checked +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* +* `queries`:\\[in\\] a pointer to an array of queries +* `active_query_indices`:\\[in\\] a pointer to an array of indices of active queries in *queries* +* `query_matches`:\\[in,out\\] a pointer to an array of length *num_active_queries*. If query\\_matches[i] is true, then the element 'matches' the query of the active query with index active\\_query\\_indices[i]. +* `user_data`:\\[in\\] a user data pointer that can be set by the user +""" +const t8_search_batched_queries_callback_c_wrapper = Ptr{Cvoid} + +mutable struct t8_forest_c_search end + +"""A wrapper around the forest search context""" +const t8_forest_search_c_wrapper = Ptr{t8_forest_c_search} + +""" + t8_forest_init_search(search, element_callback, forest) + ### Prototype ```c -void t8_geom_get_ref_intersection (int edge_index, const double *ref_coords, double ref_intersection[2]); +void t8_forest_init_search (t8_forest_search_c_wrapper search, t8_search_element_callback_c_wrapper element_callback, const t8_forest_t forest); ``` """ -function t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) - @ccall libt8.t8_geom_get_ref_intersection(edge_index::Cint, ref_coords::Ptr{Cdouble}, ref_intersection::Ptr{Cdouble})::Cvoid +function t8_forest_init_search(search, element_callback, forest) + @ccall libt8.t8_forest_init_search(search::t8_forest_search_c_wrapper, element_callback::t8_search_element_callback_c_wrapper, forest::t8_forest_t)::Cvoid end """ - t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) - -Calculates the scaling factor for edge displacement along a triangular tree face depending on the position of the global reference point. + t8_forest_search_update_forest(search, forest) -# Arguments -* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. -* `tree_vertices`:\\[in\\] Array with the tree vertex coordinates. -* `glob_intersection`:\\[in\\] Array containing the coordinates of the intersection point of a line drawn from the opposite vertex through the glob\\_ref\\_point onto the edge with edge\\_index. -* `glob_ref_point`:\\[in\\] Array containing the coordinates of the reference point mapped into the global space. ### Prototype ```c -double t8_geom_get_triangle_scaling_factor (int edge_index, const double *tree_vertices, const double *glob_intersection, const double *glob_ref_point); +void t8_forest_search_update_forest (t8_forest_search_c_wrapper search, const t8_forest_t forest); ``` """ -function t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) - @ccall libt8.t8_geom_get_triangle_scaling_factor(edge_index::Cint, tree_vertices::Ptr{Cdouble}, glob_intersection::Ptr{Cdouble}, glob_ref_point::Ptr{Cdouble})::Cdouble +function t8_forest_search_update_forest(search, forest) + @ccall libt8.t8_forest_search_update_forest(search::t8_forest_search_c_wrapper, forest::t8_forest_t)::Cvoid end """ - t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) + t8_forest_search_update_user_data(search, udata) -Calculates the scaling factor for the displacement of an edge over a face of a tetrahedral element. +Update the user data pointer in the search context # Arguments -* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. -* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -# Returns -The scaling factor of the edge displacement on the face at the point of the reference coordinates. +* `search`:\\[in,out\\] the search context to update +* `udata`:\\[in\\] the new user data pointer to use ### Prototype ```c -double t8_geom_get_scaling_factor_of_edge_on_face_tet (int edge_index, int face_index, const double *ref_coords); +void t8_forest_search_update_user_data (t8_forest_search_c_wrapper search, void *udata); ``` """ -function t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) - @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble +function t8_forest_search_update_user_data(search, udata) + @ccall libt8.t8_forest_search_update_user_data(search::t8_forest_search_c_wrapper, udata::Ptr{Cvoid})::Cvoid end """ - t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) + t8_forest_search_do_search(search) -Calculates the face intersection of a ray passing trough the reference coordinates and the opposite vertex of that face for a tetrahedron. The coordinates of the face intersection are reference coordinates: [0,1]^3. +Perform the search # Arguments -* `face_index`:\\[in\\] Index of the face, on which the intersection should be calculated. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -* `face_intersection`:\\[out\\] Three dimensional array containing the intersection point on the face in reference space. +* `search`:\\[in,out\\] the search context to use ### Prototype ```c -void t8_geom_get_tet_face_intersection (const int face_index, const double *ref_coords, double face_intersection[3]); +void t8_forest_search_do_search (t8_forest_search_c_wrapper search); ``` """ -function t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) - @ccall libt8.t8_geom_get_tet_face_intersection(face_index::Cint, ref_coords::Ptr{Cdouble}, face_intersection::Ptr{Cdouble})::Cvoid +function t8_forest_search_do_search(search) + @ccall libt8.t8_forest_search_do_search(search::t8_forest_search_c_wrapper)::Cvoid end """ - t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) + t8_forest_search_destroy(search) -Calculates the scaling factor for the displacement of an edge over a face of a prism element. +Destroy the search context # Arguments -* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. -* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -# Returns -The scaling factor of the edge displacement on the face at the point of the reference coordinates. +* `search`:\\[in,out\\] the search context to destroy ### Prototype ```c -double t8_geom_get_scaling_factor_of_edge_on_face_prism (int edge_index, int face_index, const double *ref_coords); +void t8_forest_search_destroy (t8_forest_search_c_wrapper search); ``` """ -function t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) - @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble +function t8_forest_search_destroy(search) + @ccall libt8.t8_forest_search_destroy(search::t8_forest_search_c_wrapper)::Cvoid end -""" - t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) +mutable struct t8_forest_search_with_queries end -Calculates the scaling factor for the displacement of an face through the volume of a prism element. +"""A wrapper around the forest search with queries context""" +const t8_forest_search_with_queries_c_wrapper = Ptr{t8_forest_search_with_queries} + +""" + t8_forest_init_search_with_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) -# Arguments -* `face_index`:\\[in\\] Index of the displaced face. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -# Returns -The scaling factor of the face displacement at the point of the reference coordinates inside the prism volume. ### Prototype ```c -double t8_geom_get_scaling_factor_face_through_volume_prism (const int face, const double *ref_coords); +void t8_forest_init_search_with_queries (t8_forest_search_with_queries_c_wrapper search_with_queries, t8_search_element_callback_c_wrapper element_callback, t8_search_queries_callback_c_wrapper queries_callback, void **queries, const size_t num_queries, const t8_forest_t forest); ``` """ -function t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) - @ccall libt8.t8_geom_get_scaling_factor_face_through_volume_prism(face::Cint, ref_coords::Ptr{Cdouble})::Cdouble +function t8_forest_init_search_with_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) + @ccall libt8.t8_forest_init_search_with_queries(search_with_queries::t8_forest_search_with_queries_c_wrapper, element_callback::t8_search_element_callback_c_wrapper, queries_callback::t8_search_queries_callback_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t, forest::t8_forest_t)::Cvoid end """ - t8_vertex_point_inside(vertex_coords, point, tolerance) - -Check if a point lies inside a vertex + t8_forest_search_with_queries_update_forest(search_with_queries, forest) -# Arguments -* `vertex_coords`:\\[in\\] The coordinates of the vertex -* `point`:\\[in\\] The coordinates of the point to check -* `tolerance`:\\[in\\] A double > 0 defining the tolerance -# Returns -0 if the point is outside, 1 otherwise. ### Prototype ```c -int t8_vertex_point_inside (const double vertex_coords[3], const double point[3], const double tolerance); +void t8_forest_search_with_queries_update_forest (t8_forest_search_with_queries_c_wrapper search_with_queries, const t8_forest_t forest); ``` """ -function t8_vertex_point_inside(vertex_coords, point, tolerance) - @ccall libt8.t8_vertex_point_inside(vertex_coords::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint +function t8_forest_search_with_queries_update_forest(search_with_queries, forest) + @ccall libt8.t8_forest_search_with_queries_update_forest(search_with_queries::t8_forest_search_with_queries_c_wrapper, forest::t8_forest_t)::Cvoid end """ - t8_line_point_inside(p_0, vec, point, tolerance) + t8_forest_search_with_queries_update_user_data(search_with_queries, udata) -Check if a point is inside a line that is defined by a starting point *p_0* and a vector *vec* +Update the user data pointer in the search with queries context # Arguments -* `p_0`:\\[in\\] Starting point of the line -* `vec`:\\[in\\] Direction of the line (not normalized) -* `point`:\\[in\\] The coordinates of the point to check -* `tolerance`:\\[in\\] A double > 0 defining the tolerance -# Returns -0 if the point is outside, 1 otherwise. +* `search_with_queries`:\\[in,out\\] the search with queries context to update +* `udata`:\\[in\\] the new user data pointer to use ### Prototype ```c -int t8_line_point_inside (const double *p_0, const double *vec, const double *point, const double tolerance); +void t8_forest_search_with_queries_update_user_data (t8_forest_search_with_queries_c_wrapper search_with_queries, void *udata); ``` """ -function t8_line_point_inside(p_0, vec, point, tolerance) - @ccall libt8.t8_line_point_inside(p_0::Ptr{Cdouble}, vec::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint +function t8_forest_search_with_queries_update_user_data(search_with_queries, udata) + @ccall libt8.t8_forest_search_with_queries_update_user_data(search_with_queries::t8_forest_search_with_queries_c_wrapper, udata::Ptr{Cvoid})::Cvoid end """ - t8_triangle_point_inside(p_0, v, w, point, tolerance) + t8_forest_search_with_queries_update_queries(search_with_queries, queries, num_queries) -Check if a point is inside of a triangle described by a point *p_0* and two vectors *v* and *w*. +Update the queries in the search with queries context # Arguments -* `p_0`:\\[in\\] The first vertex of a triangle -* `v`:\\[in\\] The vector from p\\_0 to p\\_1 (second vertex in the triangle) -* `w`:\\[in\\] The vector from p\\_0 to p\\_2 (third vertex in the triangle) -* `point`:\\[in\\] The coordinates of the point to check -* `tolerance`:\\[in\\] A double > 0 defining the tolerance -# Returns -0 if the point is outside, 1 otherwise. +* `search_with_queries`:\\[in,out\\] the search with queries context to update +* `queries`:\\[in\\] a pointer to an array of queries +* `num_queries`:\\[in\\] the number of queries in the array ### Prototype ```c -int t8_triangle_point_inside (const double p_0[3], const double v[3], const double w[3], const double point[3], const double tolerance); +void t8_forest_search_with_queries_update_queries (t8_forest_search_with_queries_c_wrapper search_with_queries, void **queries, const size_t num_queries); ``` """ -function t8_triangle_point_inside(p_0, v, w, point, tolerance) - @ccall libt8.t8_triangle_point_inside(p_0::Ptr{Cdouble}, v::Ptr{Cdouble}, w::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint +function t8_forest_search_with_queries_update_queries(search_with_queries, queries, num_queries) + @ccall libt8.t8_forest_search_with_queries_update_queries(search_with_queries::t8_forest_search_with_queries_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t)::Cvoid end """ - t8_plane_point_inside(point_on_face, face_normal, point) + t8_forest_search_with_queries_destroy(search) -Check if a point lays on the inner side of a plane of a bilinearly interpolated volume element. the plane is described by a point and the normal of the face. +Destroy the search with queries context # Arguments -* `point_on_face`:\\[in\\] A point on the plane -* `face_normal`:\\[in\\] The normal of the face -* `point`:\\[in\\] The point to check -# Returns -0 if the point is outside, 1 otherwise. +* `search`:\\[in,out\\] the search with queries context to destroy ### Prototype ```c -int t8_plane_point_inside (const double point_on_face[3], const double face_normal[3], const double point[3]); +void t8_forest_search_with_queries_destroy (t8_forest_search_with_queries_c_wrapper search); ``` """ -function t8_plane_point_inside(point_on_face, face_normal, point) - @ccall libt8.t8_plane_point_inside(point_on_face::Ptr{Cdouble}, face_normal::Ptr{Cdouble}, point::Ptr{Cdouble})::Cint +function t8_forest_search_with_queries_destroy(search) + @ccall libt8.t8_forest_search_with_queries_destroy(search::t8_forest_search_with_queries_c_wrapper)::Cvoid end """ - t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) + t8_forest_search_with_queries_do_search(search) -Set the vertex coordinates of a tree in the cmesh. This is currently inefficient, since the vertices are duplicated for each tree. Eventually this function will be replaced by a more efficient one. It is not allowed to call this function after t8_cmesh_commit. The eclass of the tree has to be set before calling this function. +Perform the search with queries # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `gtree_id`:\\[in\\] The global number of the tree. -* `vertices`:\\[in\\] An array of 3 doubles per tree vertex. -* `num_vertices`:\\[in\\] The number of verticess in *vertices*. Must match the number of corners of the tree. +* `search`:\\[in,out\\] the search with queries context to use ### Prototype ```c -void t8_cmesh_set_tree_vertices (t8_cmesh_t cmesh, const t8_gloidx_t gtree_id, const double *vertices, const int num_vertices); +void t8_forest_search_with_queries_do_search (t8_forest_search_with_queries_c_wrapper search); ``` """ -function t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) - @ccall libt8.t8_cmesh_set_tree_vertices(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cvoid +function t8_forest_search_with_queries_do_search(search) + @ccall libt8.t8_forest_search_with_queries_do_search(search::t8_forest_search_with_queries_c_wrapper)::Cvoid end +mutable struct t8_forest_search_with_batched_queries end + +"""A wrapper around the forest search with batched queries context""" +const t8_forest_search_with_batched_queries_c_wrapper = Ptr{t8_forest_search_with_batched_queries} + """ - vtk_file_type + t8_forest_init_search_with_batched_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) -Enumerator for all types of files readable by t8code. +### Prototype +```c +void t8_forest_init_search_with_batched_queries (t8_forest_search_with_batched_queries_c_wrapper search_with_queries, t8_search_element_callback_c_wrapper element_callback, t8_search_batched_queries_callback_c_wrapper queries_callback, void **queries, const size_t num_queries, const t8_forest_t forest); +``` """ -@cenum vtk_file_type::Int32 begin - VTK_FILE_ERROR = -1 - VTK_SERIAL_FILE = 8 - VTK_UNSTRUCTURED_FILE = 8 - VTK_POLYDATA_FILE = 9 - VTK_PARALLEL_FILE = 16 - VTK_PARALLEL_UNSTRUCTURED_FILE = 16 - VTK_PARALLEL_POLYDATA_FILE = 17 - VTK_NUM_TYPES = 5 +function t8_forest_init_search_with_batched_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) + @ccall libt8.t8_forest_init_search_with_batched_queries(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, element_callback::t8_search_element_callback_c_wrapper, queries_callback::t8_search_batched_queries_callback_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t, forest::t8_forest_t)::Cvoid end -"""Enumerator for all types of files readable by t8code.""" -const vtk_file_type_t = vtk_file_type +""" + t8_forest_search_with_batched_queries_update_forest(search_with_queries, forest) -@cenum vtk_read_success::UInt32 begin - read_failure = 0 - read_success = 1 +### Prototype +```c +void t8_forest_search_with_batched_queries_update_forest ( t8_forest_search_with_batched_queries_c_wrapper search_with_queries, const t8_forest_t forest); +``` +""" +function t8_forest_search_with_batched_queries_update_forest(search_with_queries, forest) + @ccall libt8.t8_forest_search_with_batched_queries_update_forest(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, forest::t8_forest_t)::Cvoid end -const vtk_read_success_t = vtk_read_success - """ - t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) - -Write the forest in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function uses the vtk library. t8code must be configured with "--with-vtk" in order to use it. Currently does not support pyramid elements. + t8_forest_search_with_batched_queries_update_user_data(search_with_queries, udata) -!!! note - - If t8code was not configured with vtk, use t8_forest_vtk_write_file +Update the user data pointer in the search with batched queries context # Arguments -* `forest`:\\[in\\] The forest. -* `fileprefix`:\\[in\\] The prefix of the output files. The meta file will be named *fileprefix*.pvtu . -* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. -* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. -* `write_level`:\\[in\\] If true, the refinement level is written for each element. -* `write_element_id`:\\[in\\] If true, the global element id is written for each element. -* `curved_flag`:\\[in\\] If true, write the elements as curved element types from vtk. -* `write_ghosts`:\\[in\\] If true, write out ghost elements as well. -* `num_data`:\\[in\\] Number of user defined double valued data fields to write. -* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the user defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. -# Returns -True if successful, false if not (process local). +* `search_with_queries`:\\[in,out\\] the search with batched queries context to update +* `udata`:\\[in\\] the new user data pointer to use ### Prototype ```c -int t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int curved_flag, const int write_ghosts, const int num_data, t8_vtk_data_field_t *data); +void t8_forest_search_with_batched_queries_update_user_data ( t8_forest_search_with_batched_queries_c_wrapper search_with_queries, void *udata); ``` """ -function t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) - @ccall libt8.t8_forest_vtk_write_file_via_API(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, curved_flag::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_forest_search_with_batched_queries_update_user_data(search_with_queries, udata) + @ccall libt8.t8_forest_search_with_batched_queries_update_user_data(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, udata::Ptr{Cvoid})::Cvoid end """ - t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) + t8_forest_search_with_batched_queries_update_queries(search_with_queries, queries, num_queries) -Write the forest in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configure with "--with-vtk" and t8_forest_vtk_write_file_via_API is not available. +Update the queries in the search with batched queries context # Arguments -* `forest`:\\[in\\] The forest. -* `fileprefix`:\\[in\\] The prefix of the output files. -* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. -* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. -* `write_level`:\\[in\\] If true, the refinement level is written for each element. -* `write_element_id`:\\[in\\] If true, the global element id is written for each element. -* `write_ghosts`:\\[in\\] If true, each process additionally writes its ghost elements. For ghost element the treeid is -1. -* `num_data`:\\[in\\] Number of user defined double valued data fields to write. -* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the used defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. -# Returns -True if successful, false if not (process local). +* `search_with_queries`:\\[in,out\\] the search with batched queries context to update +* `queries`:\\[in\\] a pointer to an array of queries +* `num_queries`:\\[in\\] the number of queries in the array ### Prototype ```c -int t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data); +void t8_forest_search_with_batched_queries_update_queries ( t8_forest_search_with_batched_queries_c_wrapper search_with_queries, void **queries, const size_t num_queries); ``` """ -function t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) - @ccall libt8.t8_forest_vtk_write_file(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_forest_search_with_batched_queries_update_queries(search_with_queries, queries, num_queries) + @ccall libt8.t8_forest_search_with_batched_queries_update_queries(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t)::Cvoid end """ - t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) + t8_forest_search_with_batched_queries_destroy(search) +Destroy the search with batched queries context + +# Arguments +* `search`:\\[in,out\\] the search with batched queries context to destroy ### Prototype ```c -int t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm); +void t8_forest_search_with_batched_queries_destroy (t8_forest_search_with_batched_queries_c_wrapper search); ``` """ -function t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) - @ccall libt8.t8_cmesh_vtk_write_file_via_API(cmesh::t8_cmesh_t, fileprefix::Cstring, comm::MPI_Comm)::Cint +function t8_forest_search_with_batched_queries_destroy(search) + @ccall libt8.t8_forest_search_with_batched_queries_destroy(search::t8_forest_search_with_batched_queries_c_wrapper)::Cvoid end """ - t8_cmesh_vtk_write_file(cmesh, fileprefix) + t8_forest_search_with_batched_queries_do_search(search) -Write the cmesh in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configure with "--with-vtk" and t8_cmesh_vtk_write_file_via_API is not available. +Perform the search with batched queries # Arguments -* `cmesh`:\\[in\\] The cmesh -* `fileprefix`:\\[in\\] The prefix of the output files -# Returns -int +* `search`:\\[in,out\\] the search with batched queries context to use ### Prototype ```c -int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); +void t8_forest_search_with_batched_queries_do_search (t8_forest_search_with_batched_queries_c_wrapper search); ``` """ -function t8_cmesh_vtk_write_file(cmesh, fileprefix) - @ccall libt8.t8_cmesh_vtk_write_file(cmesh::t8_cmesh_t, fileprefix::Cstring)::Cint +function t8_forest_search_with_batched_queries_do_search(search) + @ccall libt8.t8_forest_search_with_batched_queries_do_search(search::t8_forest_search_with_batched_queries_c_wrapper)::Cvoid end # typedef void ( * t8_geom_analytic_fn ) ( t8_cmesh_t cmesh , t8_gloidx_t gtreeid , const double * ref_coords , const size_t num_coords , double * out_coords , const void * tree_data , const void * user_data ) @@ -17735,7 +16153,7 @@ Definition of an analytic geometry function. This function maps reference coordi * `cmesh`:\\[in\\] The cmesh. * `gtreeid`:\\[in\\] The global tree (of the cmesh) in which the reference point is. * `ref_coords`:\\[in\\] Array of dimension x *num_coords* many entries, specifying a point in -* `num_coords`:\\[in\\] +* `num_coords`:\\[in\\] The number of coordinates in *ref_coords*. * `out_coords`:\\[out\\] The mapped coordinates in physical space of *ref_coords*. The length is *num_coords* * 3. * `tree_data`:\\[in\\] The data of the current tree as loaded by a t8_geom_load_tree_data_fn. * `user_data`:\\[in\\] The user data pointer stored in the geometry. @@ -17833,37 +16251,59 @@ const t8_geom_tree_compatible_fn = Ptr{Cvoid} """ t8_geometry_analytic_destroy(geom) +Destroy a geometry analytic object. + +# Arguments +* `geom`:\\[in,out\\] A pointer to a geometry object. Set to NULL on output. ### Prototype ```c void t8_geometry_analytic_destroy (t8_geometry_c **geom); ``` """ function t8_geometry_analytic_destroy(geom) - @ccall libt8.t8_geometry_analytic_destroy(geom::Ptr{Ptr{Cint}})::Cvoid + @ccall libt8.t8_geometry_analytic_destroy(geom::Ptr{Ptr{t8_geometry_c}})::Cvoid end """ t8_geometry_analytic_new(name, analytical, jacobian, load_tree_data, tree_negative_volume, tree_compatible, user_data) +Create a new analytic geometry. The geometry is viable with all tree types and uses a user-provided analytic and jacobian function. The actual mappings are done by these functions. + +# Arguments +* `name`:\\[in\\] The name to give this geometry. +* `analytical`:\\[in\\] The analytical function to use for this geometry. +* `jacobian`:\\[in\\] The jacobian of *analytical*. +* `load_tree_data`:\\[in\\] The function that is used to load a tree's data. +* `tree_negative_volume`:\\[in\\] The function that is used to compute if a trees volume is negative. +* `tree_compatible`:\\[in\\] The function that is used to check if a tree is compatible with the geometry. +* `user_data`:\\[in\\] Additional user data which the geometry can use. +# Returns +A pointer to an allocated geometry struct. ### Prototype ```c t8_geometry_c * t8_geometry_analytic_new (const char *name, t8_geom_analytic_fn analytical, t8_geom_analytic_jacobian_fn jacobian, t8_geom_load_tree_data_fn load_tree_data, t8_geom_tree_negative_volume_fn tree_negative_volume, t8_geom_tree_compatible_fn tree_compatible, const void *user_data); ``` """ function t8_geometry_analytic_new(name, analytical, jacobian, load_tree_data, tree_negative_volume, tree_compatible, user_data) - @ccall libt8.t8_geometry_analytic_new(name::Cstring, analytical::t8_geom_analytic_fn, jacobian::t8_geom_analytic_jacobian_fn, load_tree_data::t8_geom_load_tree_data_fn, tree_negative_volume::t8_geom_tree_negative_volume_fn, tree_compatible::t8_geom_tree_compatible_fn, user_data::Ptr{Cvoid})::Ptr{Cint} + @ccall libt8.t8_geometry_analytic_new(name::Cstring, analytical::t8_geom_analytic_fn, jacobian::t8_geom_analytic_jacobian_fn, load_tree_data::t8_geom_load_tree_data_fn, tree_negative_volume::t8_geom_tree_negative_volume_fn, tree_compatible::t8_geom_tree_compatible_fn, user_data::Ptr{Cvoid})::Ptr{t8_geometry_c} end """ t8_geom_load_tree_data_vertices(cmesh, gtreeid, user_data) +Load vertex data from given tree. + +# Arguments +* `cmesh`:\\[in\\] The cmesh. +* `gtreeid`:\\[in\\] The global tree id (in the cmesh). +* `user_data`:\\[out\\] The load tree vertices. ### Prototype ```c void t8_geom_load_tree_data_vertices (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const void **user_data); ``` """ function t8_geom_load_tree_data_vertices(cmesh, gtreeid, user_data) - @ccall libt8.t8_geom_load_tree_data_vertices(cmesh::Cint, gtreeid::Cint, user_data::Ptr{Ptr{Cvoid}})::Cvoid + @ccall libt8.t8_geom_load_tree_data_vertices(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, user_data::Ptr{Ptr{Cvoid}})::Cvoid end """ @@ -18117,45 +16557,29 @@ function t8_geometry_zero_destroy(geom) end """ - t8_scheme_new_default_cxx() - -Return the default element implementation of t8code. + t8_scheme_new_default() ### Prototype ```c -t8_scheme_cxx_t * t8_scheme_new_default_cxx (void); +const t8_scheme_c * t8_scheme_new_default (void); ``` """ -function t8_scheme_new_default_cxx() - @ccall libt8.t8_scheme_new_default_cxx()::Ptr{t8_scheme_cxx_t} +function t8_scheme_new_default() + @ccall libt8.t8_scheme_new_default()::Ptr{t8_scheme_c} end """ - t8_eclass_scheme_is_default(ts) - -Check whether a given eclass\\_scheme is one of the default schemes. + t8_eclass_scheme_is_default(scheme, eclass) -# Arguments -* `ts`:\\[in\\] A (pointer to a) scheme -# Returns -True (non-zero) if *ts* is one of the default schemes, false (zero) otherwise. ### Prototype ```c -int t8_eclass_scheme_is_default (t8_eclass_scheme_c *ts); +int t8_eclass_scheme_is_default (const t8_scheme_c *scheme, const t8_eclass_t eclass); ``` """ -function t8_eclass_scheme_is_default(ts) - @ccall libt8.t8_eclass_scheme_is_default(ts::Ptr{t8_eclass_scheme_c})::Cint +function t8_eclass_scheme_is_default(scheme, eclass) + @ccall libt8.t8_eclass_scheme_is_default(scheme::Ptr{t8_scheme_c}, eclass::t8_eclass_t)::Cint end -const SC_CC = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc" - -const SC_CFLAGS = " " - -const SC_CPP = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc -E" - -const SC_CPPFLAGS = "" - const SC_HAVE_ZLIB = 1 const SC_ENABLE_PTHREAD = 1 @@ -18168,22 +16592,38 @@ const SC_ENABLE_MPICOMMSHARED = 1 const SC_ENABLE_MPIIO = 1 +const SC_ENABLE_FILE_CHECKS = 1 + +const SC_HAVE_AINT_DIFF = 1 + +const SC_HAVE_MPI_UNSIGNED_LONG_LONG = 1 + +const SC_HAVE_MPI_SIGNED_CHAR = 1 + +const SC_HAVE_MPI_INT8_T = 1 + const SC_ENABLE_MPITHREAD = 1 const SC_ENABLE_MPIWINSHARED = 1 +const SC_ENABLE_MPISHARED = 1 + const SC_ENABLE_USE_COUNTERS = 1 const SC_ENABLE_USE_REALLOC = 1 const SC_ENABLE_V4L2 = 1 +const SC_HAVE_ALIGNED_ALLOC = 1 + const SC_HAVE_BACKTRACE = 1 const SC_HAVE_BACKTRACE_SYMBOLS = 1 const SC_HAVE_FSYNC = 1 +const SC_HAVE_POSIX_MEMALIGN = 1 + const SC_HAVE_FABS = 1 const SC_HAVE_QSORT_R = 1 @@ -18194,13 +16634,7 @@ const SC_HAVE_STRTOLL = 1 const SC_HAVE_GETTIMEOFDAY = 1 -const SC_SIZEOF_VOID_P = 8 - -const SC_MEMALIGN_BYTES = SC_SIZEOF_VOID_P - -const SC_LDFLAGS = "-Wl,-rpath -Wl,/workspace/destdir/lib -Wl,--enable-new-dtags -L/workspace/x86_64-linux-gnu-libgfortran5-cxx11-mpi+mpich/destdir/lib" - -const SC_LIBS = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/lib/libz.so m" +const SC_MEMALIGN_BYTES = 8 const SC_PACKAGE = "libsc" @@ -18208,66 +16642,56 @@ const SC_PACKAGE_BUGREPORT = "p4est@ins.uni-bonn.de" const SC_PACKAGE_NAME = "libsc" -const SC_PACKAGE_STRING = "libsc 0.0.0" +const SC_PACKAGE_STRING = "libsc 2.8.7" const SC_PACKAGE_TARNAME = "libsc" const SC_PACKAGE_URL = "" -const SC_PACKAGE_VERSION = "0.0.0" - -const SC_SIZEOF_INT = 4 - -const SC_SIZEOF_UNSIGNED_INT = 4 - -const SC_SIZEOF_LONG = 8 - -const SC_SIZEOF_LONG_LONG = 8 - -const SC_SIZEOF_UNSIGNED_LONG = 8 +const SC_PACKAGE_VERSION = "2.8.7" -const SC_SIZEOF_UNSIGNED_LONG_LONG = 8 +const SC_VERSION = "2.8.7" -const SC_VERSION = "0.0.0" +const SC_VERSION_MAJOR = 2 -const SC_VERSION_MAJOR = 0 +const SC_VERSION_MINOR = 8 -const SC_VERSION_MINOR = 0 - -const SC_VERSION_POINT = 0 +const SC_VERSION_POINT = 7 # Skipping MacroDefinition: _sc_const const +# Skipping MacroDefinition: SC_DLL_PUBLIC __attribute__ ( ( visibility ( "default" ) ) ) + const sc_MPI_COMM_WORLD = MPI.COMM_WORLD const sc_MPI_COMM_SELF = MPI.COMM_SELF -const sc_MPI_CHAR = MPI.CHAR +const sc_MPI_BYTE = MPI.BYTE -const sc_MPI_SIGNED_CHAR = MPI.SIGNED_CHAR +const sc_MPI_CHAR = MPI.CHAR const sc_MPI_UNSIGNED_CHAR = MPI.UNSIGNED_CHAR -const sc_MPI_BYTE = MPI.BYTE - const sc_MPI_SHORT = MPI.SHORT const sc_MPI_UNSIGNED_SHORT = MPI.UNSIGNED_SHORT const sc_MPI_INT = MPI.INT -const sc_MPI_INT8_T = MPI.INT8_T - const sc_MPI_UNSIGNED = MPI.UNSIGNED const sc_MPI_LONG = MPI.LONG const sc_MPI_UNSIGNED_LONG = MPI.UNSIGNED_LONG -const sc_MPI_LONG_LONG_INT = MPI.LONG_LONG_INT - const sc_MPI_UNSIGNED_LONG_LONG = MPI.UNSIGNED_LONG_LONG +const sc_MPI_SIGNED_CHAR = MPI.SIGNED_CHAR + +const sc_MPI_INT8_T = MPI.INT8_T + +const sc_MPI_LONG_LONG_INT = MPI.LONG_LONG_INT + const sc_MPI_FLOAT = MPI.FLOAT const sc_MPI_DOUBLE = MPI.DOUBLE @@ -18316,12 +16740,16 @@ const SC_LP_SILENT = 9 const SC_LP_THRESHOLD = SC_LP_INFO +const SC_LP_APPLICATION = SC_LP_STATISTICS + const T8_MPI_LOCIDX = sc_MPI_INT const T8_LOCIDX_MAX = INT32_MAX const T8_MPI_GLOIDX = sc_MPI_LONG_LONG_INT +const T8_GLOIDX_MAX = INT64_MAX + const T8_MPI_LINEARIDX = sc_MPI_UNSIGNED_LONG_LONG # Skipping MacroDefinition: T8_PADDING_SIZE ( sizeof ( void * ) ) @@ -18330,50 +16758,12 @@ const T8_PRECISION_EPS = SC_EPS const T8_PRECISION_SQRT_EPS = sqrt(T8_PRECISION_EPS) -const T8_CMESH_N_SUPPORTED_MSH_FILE_VERSIONS = 2 - -# Skipping MacroDefinition: T8_MPI_ECLASS_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_eclass_t ) ) , sc_MPI_INT ) - -const T8_ECLASS_MAX_FACES = 6 - -const T8_ECLASS_MAX_EDGES = 12 - -const T8_ECLASS_MAX_EDGES_2D = 4 - -const T8_ECLASS_MAX_CORNERS_2D = 4 - -const T8_ECLASS_MAX_CORNERS = 8 - -const T8_ECLASS_MAX_DIM = 3 - -# Skipping MacroDefinition: T8_MPI_ELEMENT_SHAPE_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_element_shape_t ) ) , sc_MPI_INT ) - -const T8_ELEMENT_SHAPE_MAX_FACES = 6 - -const T8_ELEMENT_SHAPE_MAX_CORNERS = 8 - -const T8_VTK_LOCIDX = "Int32" - -const T8_VTK_GLOIDX = "Int32" - -const T8_VTK_FLOAT_NAME = "Float32" - -const T8_VTK_FLOAT_TYPE = Float32 - -const T8_VTK_FORMAT_STRING = "ascii" +const T8_CMESH_FORMAT = 0x0002 const sc_mpi_read = sc_io_read const sc_mpi_write = sc_io_write -const P4EST_CC = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc" - -const P4EST_CFLAGS = " " - -const P4EST_CPP = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc -E" - -const P4EST_CPPFLAGS = "" - const P4EST_ENABLE_BUILD_2D = 1 const P4EST_ENABLE_BUILD_3D = 1 @@ -18384,6 +16774,8 @@ const P4EST_ENABLE_MEMALIGN = 1 const P4EST_ENABLE_MPI = 1 +const P4EST_ENABLE_FILE_CHECKS = 1 + const P4EST_ENABLE_MPICOMMSHARED = 1 const P4EST_ENABLE_MPIIO = 1 @@ -18398,11 +16790,9 @@ const P4EST_ENABLE_VTK_COMPRESSION = 1 const P4EST_HAVE_FSYNC = 1 -const P4EST_HAVE_ZLIB = 1 - -const P4EST_LDFLAGS = "-Wl,-rpath -Wl,/workspace/destdir/lib -Wl,--enable-new-dtags -L/workspace/x86_64-linux-gnu-libgfortran5-cxx11-mpi+mpich/destdir/lib" +const P4EST_HAVE_POSIX_MEMALIGN = 1 -const P4EST_LIBS = " m" +const P4EST_HAVE_ZLIB = 1 const P4EST_PACKAGE = "p4est" @@ -18410,21 +16800,21 @@ const P4EST_PACKAGE_BUGREPORT = "p4est@ins.uni-bonn.de" const P4EST_PACKAGE_NAME = "p4est" -const P4EST_PACKAGE_STRING = "p4est 0.0.0" +const P4EST_PACKAGE_STRING = "p4est 2.8.7" const P4EST_PACKAGE_TARNAME = "p4est" const P4EST_PACKAGE_URL = "" -const P4EST_PACKAGE_VERSION = "0.0.0" +const P4EST_PACKAGE_VERSION = "2.8.7" -const P4EST_VERSION = "0.0.0" +const P4EST_VERSION = "2.8.7" -const P4EST_VERSION_MAJOR = 0 +const P4EST_VERSION_MAJOR = 2 -const P4EST_VERSION_MINOR = 0 +const P4EST_VERSION_MINOR = 8 -const P4EST_VERSION_POINT = 0 +const P4EST_VERSION_POINT = 7 const p4est_qcoord_compare = sc_int32_compare @@ -18518,27 +16908,61 @@ const P8EST_STRING = "p8est" const P8EST_ONDISK_FORMAT = 0x03000009 -const T8_CMESH_FORMAT = 0x0002 +const T8_SHMEM_BEST_TYPE = SC_SHMEM_WINDOW + +# Skipping MacroDefinition: T8_MPI_ECLASS_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_eclass_t ) ) , sc_MPI_INT ) + +const T8_ECLASS_MAX_FACES = 6 + +const T8_ECLASS_MAX_EDGES = 12 -const T8_CMESH_VERTICES_ATTRIBUTE_KEY = 0 +const T8_ECLASS_MAX_EDGES_2D = 4 -const T8_CMESH_GEOMETRY_ATTRIBUTE_KEY = 1 +const T8_ECLASS_MAX_CORNERS_2D = 4 -const T8_CMESH_CAD_EDGE_ATTRIBUTE_KEY = 2 +const T8_ECLASS_MAX_CORNERS = 8 -const T8_CMESH_CAD_EDGE_PARAMETERS_ATTRIBUTE_KEY = 3 +const T8_ECLASS_MAX_DIM = 3 -const T8_CMESH_CAD_FACE_ATTRIBUTE_KEY = T8_CMESH_CAD_EDGE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_EDGES +const T8_ECLASS_MAX_CHILDREN = 10 -const T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY = T8_CMESH_CAD_FACE_ATTRIBUTE_KEY + 1 +const T8_ECLASS_MAX_FACE_CHILDREN = 4 -const T8_CMESH_LAGRANGE_POLY_DEGREE_KEY = T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_FACES +# Skipping MacroDefinition: T8_FACE_VERTEX_TO_TREE_VERTEX_VALUES { { { - 1 } } , /* vertex */ { { 0 } , { 1 } } , /* line */ { { 0 , 2 } , { 1 , 3 } , { 0 , 1 } , { 2 , 3 } } , /* quad */ { { 1 , 2 } , { 0 , 2 } , { 0 , 1 } } , /* triangle */ { { 0 , 2 , 4 , 6 } , { 1 , 3 , 5 , 7 } , { 0 , 1 , 4 , 5 } , { 2 , 3 , 6 , 7 } , { 0 , 1 , 2 , 3 } , { 4 , 5 , 6 , 7 } } , /* hex */ { { 1 , 2 , 3 } , { 0 , 2 , 3 } , { 0 , 1 , 3 } , { 0 , 1 , 2 } } , /* tet */ { { 1 , 2 , 4 , 5 } , { 0 , 2 , 3 , 5 } , { 0 , 1 , 3 , 4 } , { 0 , 1 , 2 } , { 3 , 4 , 5 } } , /* prism */ { { 0 , 2 , 4 } , { 1 , 3 , 4 } , { 0 , 1 , 4 } , { 2 , 3 , 4 } , { 0 , 1 , 2 , 3 } } /* pyramid */ \ +#} -const T8_CMESH_NEXT_POSSIBLE_KEY = T8_CMESH_LAGRANGE_POLY_DEGREE_KEY + 1 +# Skipping MacroDefinition: T8_FACE_EDGE_TO_TREE_EDGE_VALUES { { { - 1 } } , /* vertex */ { { 0 } } , /* line */ { { 0 } , { 1 } , { 2 } , { 3 } } , /* quad */ { { 0 } , { 1 } , { 2 } } , /* triangle */ { { 8 , 10 , 4 , 6 } , { 9 , 11 , 5 , 7 } , { 8 , 9 , 0 , 2 } , { 10 , 11 , 1 , 3 } , { 4 , 5 , 0 , 1 } , { 6 , 7 , 2 , 3 } } , /* hex */ { { 3 , 4 , 5 } , { 1 , 2 , 5 } , { 0 , 2 , 4 } , { 0 , 1 , 3 } } , /* tet */ { { 0 , 7 , 3 , 6 } , { 1 , 8 , 4 , 7 } , { 2 , 6 , 5 , 8 } , { 0 , 1 , 2 } , { 3 , 4 , 5 } } , /* prism */ { { - 1 } } , /* pyramid */ \ +#} -const T8_CPROFILE_NUM_STATS = 11 +# Skipping MacroDefinition: T8_FACE_TO_EDGE_NEIGHBOR_VALUES { { { - 1 } } , /* vertex */ { { - 1 } } , /* line */ { { 2 , 3 } , { 2 , 3 } , { 0 , 1 } , { 0 , 1 } } , /* quad */ { { 2 , 1 } , { 2 , 0 } , { 1 , 0 } } , /* triangle */ { { 0 , 1 , 2 , 3 } , { 0 , 1 , 2 , 3 } , { 4 , 5 , 6 , 7 } , { 4 , 5 , 6 , 7 } , { 8 , 9 , 10 , 11 } , { 8 , 9 , 10 , 11 } } , /* hex */ { { 0 , 1 , 2 } , { 0 , 3 , 4 } , { 1 , 3 , 5 } , { 2 , 4 , 5 } } , /* tet */ { { 1 , 2 , 4 , 5 } , { 0 , 2 , 3 , 5 } , { 0 , 1 , 3 , 4 } , { 6 , 7 , 8 } , { 6 , 7 , 8 } } , /* prism */ { { - 1 } } , /* pyramid */ \ +#} -const T8_SHMEM_BEST_TYPE = SC_SHMEM_WINDOW +# Skipping MacroDefinition: T8_EDGE_VERTEX_TO_TREE_VERTEX_VALUES { { { - 1 } } , /* vertex */ { { 0 } , { 1 } } , /* line */ { { 0 , 2 } , { 1 , 3 } , { 0 , 1 } , { 2 , 3 } } , /* quad */ { { 1 , 2 } , { 0 , 2 } , { 0 , 1 } } , /* triangle */ { { 0 , 1 } , { 2 , 3 } , { 4 , 5 } , { 6 , 7 } , { 0 , 2 } , { 1 , 3 } , { 4 , 6 } , { 5 , 7 } , { 0 , 4 } , { 1 , 5 } , { 2 , 6 } , { 3 , 7 } } , /* hex */ { { 0 , 1 } , { 0 , 2 } , { 0 , 3 } , { 1 , 2 } , { 1 , 3 } , { 2 , 3 } } , /* tet */ { { 1 , 2 } , { 0 , 2 } , { 0 , 1 } , { 4 , 5 } , { 3 , 5 } , { 3 , 4 } , { 1 , 4 } , { 2 , 5 } , { 0 , 3 } } , /* prism */ { { - 1 } } , /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_EDGE_TO_FACE_VALUES { { { - 1 } } , /* vertex */ { { 0 } } , /* line */ { { 0 } , { 1 } , { 2 } , { 3 } } , /* quad */ { { 0 } , { 1 } , { 2 } } , /* triangle */ { { 2 , 4 } , { 3 , 4 } , { 2 , 5 } , { 3 , 5 } , { 0 , 4 } , { 1 , 4 } , { 0 , 5 } , { 1 , 5 } , { 0 , 2 } , { 1 , 2 } , { 0 , 3 } , { 1 , 3 } } , /* hex */ { { 2 , 3 } , { 1 , 3 } , { 1 , 2 } , { 0 , 3 } , { 0 , 2 } , { 0 , 1 } } , /* tet */ { { 0 , 3 } , { 1 , 3 } , { 2 , 3 } , { 0 , 4 } , { 1 , 4 } , { 2 , 4 } , { 0 , 2 } , { 0 , 1 } , { 1 , 2 } } , /* prism */ { { - 1 } } , /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_FACE_ORIENTATION_VALUES { { 0 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 0 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 0 , 0 , 0 , 0 , - 1 , - 1 } , /* quad */ { 0 , 0 , 0 , - 1 , - 1 , - 1 } , /* triangle */ { 0 , 1 , 1 , 0 , 0 , 1 } , /* hex */ { 0 , 1 , 0 , 1 , - 1 , - 1 } , /* tet */ { 1 , 0 , 1 , 0 , 1 , - 1 } , /* prism */ { 0 , 1 , 1 , 0 , 0 , - 1 } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_VTK_TO_T8_CORNER_NUMBER_VALUES { { 0 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 0 , 1 , 3 , 2 , - 1 , - 1 , - 1 , - 1 } , /* quad */ { 0 , 1 , 2 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* triangle */ { 0 , 1 , 3 , 2 , 4 , 5 , 7 , 6 } , /* hex */ { 0 , 2 , 1 , 3 , - 1 , - 1 , - 1 , - 1 } , /* tet */ { 0 , 2 , 1 , 3 , 5 , 4 , - 1 , - 1 } , /* prism */ { 0 , 1 , 3 , 2 , 4 , - 1 , - 1 , - 1 } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_T8_TO_VTK_CORNER_NUMBER_VALUES { { 0 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 0 , 1 , 3 , 2 , - 1 , - 1 , - 1 , - 1 } , /* quad */ { 0 , 1 , 2 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* triangle */ { 0 , 1 , 3 , 2 , 4 , 5 , 7 , 6 } , /* hex */ { 0 , 2 , 1 , 3 , - 1 , - 1 , - 1 , - 1 } , /* tet */ { 0 , 2 , 1 , 3 , 5 , 4 , - 1 , - 1 } , /* prism */ { 0 , 1 , 3 , 2 , 4 , - 1 , - 1 , - 1 } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_FACE_TYPES_VALUES { { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 0 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 1 , 1 , 1 , 1 , - 1 , - 1 } , /* quad */ { 1 , 1 , 1 , - 1 , - 1 , - 1 } , /* triangle */ { 2 , 2 , 2 , 2 , 2 , 2 } , /* hex */ { 3 , 3 , 3 , 3 , - 1 , - 1 } , /* tet */ { 2 , 2 , 2 , 3 , 3 , - 1 } , /* prism */ { 3 , 3 , 3 , 3 , 2 , - 1 } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_BOUNDARY_COUNT_VALUES { { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , /* vertex */ { 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , /* line */ { 4 , 4 , 0 , 0 , 0 , 0 , 0 , 0 } , /* quad */ { 3 , 3 , 0 , 0 , 0 , 0 , 0 , 0 } , /* triangle */ { 8 , 12 , 6 , 0 , 0 , 0 , 0 , 0 } , /* hex */ { 4 , 6 , 0 , 4 , 0 , 0 , 0 , 0 } , /* tet */ { 6 , 9 , 3 , 2 , 0 , 0 , 0 , 0 } , /* prism */ { 5 , 8 , 1 , 4 , 0 , 0 , 0 , 0 } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_MPI_ELEMENT_SHAPE_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_element_shape_t ) ) , sc_MPI_INT ) + +const T8_ELEMENT_SHAPE_MAX_FACES = 6 + +const T8_ELEMENT_SHAPE_MAX_CORNERS = 8 const T8_FOREST_FROM_FIRST = 0 @@ -18558,7 +16982,21 @@ const T8_FOREST_BALANCE_REPART = 1 const T8_FOREST_BALANCE_NO_REPART = 2 -const T8_PROFILE_NUM_STATS = 14 +const T8_PROFILE_NUM_STATS = 17 + +# Skipping MacroDefinition: T8_THROW_ERROR_WITH @ "Invalid usage of T8_WITH_*. Use T8_ENABLE_* instead." + +const T8_VTK_LOCIDX = "Int32" + +const T8_VTK_GLOIDX = "Int32" + +const T8_VTK_FLOAT_NAME = "Float32" + +const T8_VTK_FLOAT_TYPE = Float32 + +const T8_VTK_FORMAT_STRING = "ascii" + +const T8_CMESH_N_SUPPORTED_MSH_FILE_VERSIONS = 1 # exports const PREFIXES = ["t8_", "T8_"] From 578d09d818b35c363d981ec5e4e901cf3522e98f Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 7 Jul 2026 12:08:40 +0200 Subject: [PATCH 12/12] fix with missing PRIVATE_HEADERS --- src/Libt8.jl | 302 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 301 insertions(+), 1 deletion(-) diff --git a/src/Libt8.jl b/src/Libt8.jl index 44ee4ca..a1b9f1a 100644 --- a/src/Libt8.jl +++ b/src/Libt8.jl @@ -3258,6 +3258,164 @@ mutable struct t8_cmesh end """Forward pointer reference to hidden cmesh implementation. This reference needs to be known by [`t8_geometry`](@ref), hence we put it before the include.""" const t8_cmesh_t = Ptr{t8_cmesh} +""" + sc_refcount + +The refcount structure is declared in public so its size is known. Its members should really never be accessed directly. + +| Field | Note | +| :----------- | :----------------------------------------------------------- | +| package\\_id | The sc package that uses this reference counter. | +| refcount | The reference count is always positive for a valid counter. | +""" +struct sc_refcount + package_id::Cint + refcount::Cint +end + +"""The refcount structure is declared in public so its size is known. Its members should really never be accessed directly.""" +const sc_refcount_t = sc_refcount + +""" + sc_refcount_init_invalid(rc) + +Initialize a well-defined but unusable reference counter. Specifically, we set its package identifier and reference count to -1. To make this reference counter usable, call sc_refcount_init. + +# Arguments +* `rc`:\\[out\\] This reference counter is defined as invalid. It will return false on both sc_refcount_is_active and sc_refcount_is_last. It can be made valid by calling sc_refcount_init. No other functions must be called on it. +### Prototype +```c +void sc_refcount_init_invalid (sc_refcount_t * rc); +``` +""" +function sc_refcount_init_invalid(rc) + @ccall libsc.sc_refcount_init_invalid(rc::Ptr{sc_refcount_t})::Cvoid +end + +""" + sc_refcount_init(rc, package_id) + +Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. + +# Arguments +* `rc`:\\[out\\] This reference counter is initialized to one. The object's contents may be undefined on input. +* `package_id`:\\[in\\] Either -1 or a package registered to libsc. +### Prototype +```c +void sc_refcount_init (sc_refcount_t * rc, int package_id); +``` +""" +function sc_refcount_init(rc, package_id) + @ccall libsc.sc_refcount_init(rc::Ptr{sc_refcount_t}, package_id::Cint)::Cvoid +end + +""" + sc_refcount_new(package_id) + +Create a new reference counter with count initialized to 1. Equivalent to calling sc_refcount_init on a newly allocated rc object. + +# Arguments +* `package_id`:\\[in\\] Either -1 or a package registered to libsc. +# Returns +A reference counter with count one. +### Prototype +```c +sc_refcount_t *sc_refcount_new (int package_id); +``` +""" +function sc_refcount_new(package_id) + @ccall libsc.sc_refcount_new(package_id::Cint)::Ptr{sc_refcount_t} +end + +""" + sc_refcount_destroy(rc) + +Destroy a reference counter. It must have been counted down to zero before, thus reached an inactive state. + +# Arguments +* `rc`:\\[in,out\\] This reference counter must have reached count zero. +### Prototype +```c +void sc_refcount_destroy (sc_refcount_t * rc); +``` +""" +function sc_refcount_destroy(rc) + @ccall libsc.sc_refcount_destroy(rc::Ptr{sc_refcount_t})::Cvoid +end + +""" + sc_refcount_ref(rc) + +Increase a reference counter. The counter must be active, that is, have a value greater than zero. + +# Arguments +* `rc`:\\[in,out\\] This reference counter must be valid (greater zero). Its count is increased by one. +### Prototype +```c +void sc_refcount_ref (sc_refcount_t * rc); +``` +""" +function sc_refcount_ref(rc) + @ccall libsc.sc_refcount_ref(rc::Ptr{sc_refcount_t})::Cvoid +end + +""" + sc_refcount_unref(rc) + +Decrease the reference counter and notify when it reaches zero. The count must be greater zero on input. If the reference count reaches zero, which is indicated by the return value, the counter may not be used further with sc_refcount_ref or + +# Arguments +* `rc`:\\[in,out\\] This reference counter must be valid (greater zero). Its count is decreased by one. +# Returns +True if the count has reached zero, false otherwise. +# See also +[`sc_refcount_unref`](@ref). It is legal, however, to reactivate it later by calling, [`sc_refcount_init`](@ref). + +### Prototype +```c +int sc_refcount_unref (sc_refcount_t * rc); +``` +""" +function sc_refcount_unref(rc) + @ccall libsc.sc_refcount_unref(rc::Ptr{sc_refcount_t})::Cint +end + +""" + sc_refcount_is_active(rc) + +Check whether a reference counter has a positive value. This means that the reference counter is in use and corresponds to a live object. + +# Arguments +* `rc`:\\[in\\] A reference counter. +# Returns +True if the count is greater zero, false otherwise. +### Prototype +```c +int sc_refcount_is_active (const sc_refcount_t * rc); +``` +""" +function sc_refcount_is_active(rc) + @ccall libsc.sc_refcount_is_active(rc::Ptr{sc_refcount_t})::Cint +end + +""" + sc_refcount_is_last(rc) + +Check whether a reference counter has value one. This means that this counter is the last of its kind, which we may optimize for. + +# Arguments +* `rc`:\\[in\\] A reference counter. +# Returns +True if the count is exactly one. +### Prototype +```c +int sc_refcount_is_last (const sc_refcount_t * rc); +``` +""" +function sc_refcount_is_last(rc) + @ccall libsc.sc_refcount_is_last(rc::Ptr{sc_refcount_t})::Cint +end + mutable struct t8_ctree end """Forward pointer references to hidden implementations of tree.""" @@ -10533,6 +10691,7 @@ end | Field | Note | | :----------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| rc | Reference counter. | | set\\_partition\\_offset | Flag indicating whether the partition range was set manually. | | set\\_first\\_global\\_element | If set\\_partition\\_offset is true, the global ID of the first local element after partitioning. | | set\\_level | Level to use in new construction. | @@ -12310,11 +12469,17 @@ function t8_forest_element_face_normal(forest, ltreeid, element, face, normal) @ccall libt8.t8_forest_element_face_normal(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, normal::Ptr{Cdouble})::Cvoid end +"""We can reuse the reference counter type from libsc.""" +const t8_refcount_t = sc_refcount_t + """ t8_forest_ghost +This struct stores various information about a forest's ghost elements and ghost trees. + | Field | Note | | :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| rc | The reference counter. | | num\\_ghosts\\_elements | The count of non-local ghost leaf elements | | num\\_remote\\_elements | The count of local leaf elements that are ghost to another process. | | ghost\\_type | Describes which neighbors are considered ghosts. | @@ -12327,7 +12492,7 @@ end | proc\\_offset\\_mempool | The process offset memory pool. | """ struct t8_forest_ghost - rc::Cint + rc::t8_refcount_t num_ghosts_elements::t8_locidx_t num_remote_elements::t8_locidx_t ghost_type::t8_ghost_type_t @@ -13870,6 +14035,141 @@ function t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) @ccall libt8.t8_cmesh_set_tree_vertices(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cvoid end +""" + t8_mat_init_xrot(mat, angle) + +Initialize given 3x3 matrix as rotation matrix around the x-axis with given angle. + +# Arguments +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. +### Prototype +```c +static inline void t8_mat_init_xrot (double mat[3][3], const double angle); +``` +""" +function t8_mat_init_xrot(mat, angle) + @ccall libt8.t8_mat_init_xrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +end + +""" + t8_mat_init_yrot(mat, angle) + +Initialize given 3x3 matrix as rotation matrix around the y-axis with given angle. + +# Arguments +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. +### Prototype +```c +static inline void t8_mat_init_yrot (double mat[3][3], const double angle); +``` +""" +function t8_mat_init_yrot(mat, angle) + @ccall libt8.t8_mat_init_yrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +end + +""" + t8_mat_init_zrot(mat, angle) + +Initialize given 3x3 matrix as rotation matrix around the z-axis with given angle. + +# Arguments +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. +### Prototype +```c +static inline void t8_mat_init_zrot (double mat[3][3], const double angle); +``` +""" +function t8_mat_init_zrot(mat, angle) + @ccall libt8.t8_mat_init_zrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +end + +""" + t8_mat_mult_vec(mat, a, b) + +Apply matrix-matrix multiplication: b = M*a. + +# Arguments +* `mat`:\\[in\\] 3x3-matrix. +* `a`:\\[in\\] 3-vector. +* `b`:\\[in,out\\] 3-vector. +### Prototype +```c +static inline void t8_mat_mult_vec (const double mat[3][3], const double a[3], double b[3]); +``` +""" +function t8_mat_mult_vec(mat, a, b) + @ccall libt8.t8_mat_mult_vec(mat::Ptr{NTuple{3, Cdouble}}, a::Ptr{Cdouble}, b::Ptr{Cdouble})::Cvoid +end + +""" + t8_mat_mult_mat(A, B, C) + +Apply matrix-matrix multiplication: C = A*B. + +# Arguments +* `A`:\\[in\\] 3x3-matrix. +* `B`:\\[in\\] 3x3-matrix. +* `C`:\\[in,out\\] 3x3-matrix. +### Prototype +```c +static inline void t8_mat_mult_mat (const double A[3][3], const double B[3][3], double C[3][3]); +``` +""" +function t8_mat_mult_mat(A, B, C) + @ccall libt8.t8_mat_mult_mat(A::Ptr{NTuple{3, Cdouble}}, B::Ptr{NTuple{3, Cdouble}}, C::Ptr{NTuple{3, Cdouble}})::Cvoid +end + +""" + t8_refcount_init(rc) + +Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. + +# Arguments +* `rc`:\\[out\\] The reference counter is set to one by this call. +### Prototype +```c +void t8_refcount_init (t8_refcount_t *rc); +``` +""" +function t8_refcount_init(rc) + @ccall libt8.t8_refcount_init(rc::Ptr{t8_refcount_t})::Cvoid +end + +""" + t8_refcount_new() + +Create a new reference counter with count initialized to 1. Equivalent to calling [`t8_refcount_init`](@ref) on a newly allocated refcount\\_t. It is mandatory to free this with t8_refcount_destroy. + +# Returns +An allocated reference counter whose count has been set to one. +### Prototype +```c +t8_refcount_t * t8_refcount_new (void); +``` +""" +function t8_refcount_new() + @ccall libt8.t8_refcount_new()::Ptr{t8_refcount_t} +end + +""" + t8_refcount_destroy(rc) + +Destroy a reference counter that we allocated with t8_refcount_new. Its reference count must have decreased to zero. + +# Arguments +* `rc`:\\[in,out\\] Allocated, formerly valid reference counter. +### Prototype +```c +void t8_refcount_destroy (t8_refcount_t *rc); +``` +""" +function t8_refcount_destroy(rc) + @ccall libt8.t8_refcount_destroy(rc::Ptr{t8_refcount_t})::Cvoid +end + # no prototype is found for this function at t8_version.h:67:1, please use with caution """ t8_get_package_string()