diff --git a/.typos.toml b/.typos.toml index 4b06a8a..1cb9f7a 100644 --- a/.typos.toml +++ b/.typos.toml @@ -2,3 +2,4 @@ consistend = "consistend" # is used in API function names... Inout = "Inout" leafs = "leafs" +packageid = "packageid" diff --git a/Project.toml b/Project.toml index 9976aee..c524d5c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "T8code" uuid = "d0cc0030-9a40-4274-8435-baadcfd54fa1" authors = ["Johannes Markert "] -version = "0.6.0" +version = "0.7.0" [deps] CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" @@ -22,4 +22,4 @@ Preferences = "1.2" Reexport = "0.2, 1.0" UUIDs = "1" julia = "1.6" -t8code_jll = "=2.0.0" +t8code_jll = "=3.0.0" diff --git a/dev/Artifacts.toml b/dev/Artifacts.toml index 5806075..edeed17 100644 --- a/dev/Artifacts.toml +++ b/dev/Artifacts.toml @@ -1,11 +1,11 @@ [[t8code]] arch = "x86_64" -git-tree-sha1 = "949a37adddb13d16a4bee2acb0e4ed5e185470ed" +git-tree-sha1 = "593b8ed41f90aa10d015d6ef2032441fda382f32" lazy = true libc = "glibc" mpi = "mpich" os = "linux" [[t8code.download]] - sha256 = "02effe7949703a11a0754c44a4b0a20c6b693f69209076380a31cbad68c02181" - url = "https://github.com/JuliaBinaryWrappers/t8code_jll.jl/releases/download/t8code-v2.0.0+0/t8code.v2.0.0.x86_64-linux-gnu-mpi+mpich.tar.gz" + sha256 = "8312b69121c52550f0ee074189b02e231a13324e2d4536a64a362ce9be9eddeb" + url = "https://github.com/JuliaBinaryWrappers/t8code_jll.jl/releases/download/t8code-v3.0.0+0/t8code.v3.0.0.x86_64-linux-gnu-mpi+mpich.tar.gz" diff --git a/dev/fixes.sh b/dev/fixes.sh index c6b7bdf..f1f3a8c 100755 --- a/dev/fixes.sh +++ b/dev/fixes.sh @@ -105,3 +105,27 @@ sed -i "/= MPI_File_/d" "${LIB_JL}" sed -i "s/= MPI_/= MPI./" "${LIB_JL}" sed -i "s/packageid/package_id/" "${LIB_JL}" + +cat << EOT >&2 + +# !!!!!! # +# !!!!!! # + +# Manual fix. # + +Additionally, comment out + + struct t8_forest + [...] + end + +and add + + mutable struct t8_forest end + +in order to avoid error output due to +circular dependency of 't8_forest_t'. + +# !!!!!! # +# !!!!!! # +EOT diff --git a/src/Libt8.jl b/src/Libt8.jl index beeac1e..5f16f5e 100644 --- a/src/Libt8.jl +++ b/src/Libt8.jl @@ -41,7 +41,7 @@ end const ptrdiff_t = Cptrdiff_t # Definitions used from MPI.jl -using MPI: MPI, MPI_Datatype, MPI_Comm, MPI_File +using MPI: MPI, MPI_Datatype, MPI_Comm, MPI_Group, MPI_File const MPI_COMM_WORLD = MPI.COMM_WORLD const MPI_COMM_SELF = MPI.COMM_SELF @@ -3343,7 +3343,7 @@ This struct is used to profile cmesh algorithms. The cmesh struct stores a point | 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*. | +| 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). | @@ -3531,6 +3531,23 @@ 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 +""" + t8_cmesh_new() + +Allocate a new un-committed cmesh. + +# Returns +A pointer to an un-committed [`t8_cmesh`](@ref) structure. +### Prototype +```c +t8_cmesh_t t8_cmesh_new (); +``` +""" +function t8_cmesh_new() + @ccall libt8.t8_cmesh_new()::t8_cmesh_t +end + """ t8_cmesh_is_initialized(cmesh) @@ -3577,7 +3594,7 @@ Given a set of vertex coordinates for a tree of a given eclass. Query whether th * `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. Fals otherwise. Returns true if a tree of the given eclass with the given vertex coordinates does have negative volume. +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 int t8_cmesh_tree_vertices_negative_volume (const t8_eclass_t eclass, const double *vertices, const int num_vertices); @@ -3662,7 +3679,7 @@ end """ t8_cmesh_set_partition_uniform(cmesh, element_level, ts) -Declare if the cmesh is understood as a partitioned cmesh where the partition table is derived from an assumed uniform refinement of a given level. This call is only valid when the cmesh is not yet committed via a call to t8_cmesh_commit. +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. @@ -3936,11 +3953,11 @@ If no geometry is registered and cmesh is modified from another cmesh then the o * `geometry`:\\[in\\] The geometry to register. ### Prototype ```c -void t8_cmesh_register_geometry (t8_cmesh_t cmesh, t8_geometry_c **geometry); +void t8_cmesh_register_geometry (t8_cmesh_t cmesh, t8_geometry_c *geometry); ``` """ function t8_cmesh_register_geometry(cmesh, geometry) - @ccall libt8.t8_cmesh_register_geometry(cmesh::t8_cmesh_t, geometry::Ptr{Ptr{t8_geometry_c}})::Cvoid + @ccall libt8.t8_cmesh_register_geometry(cmesh::t8_cmesh_t, geometry::Ptr{t8_geometry_c})::Cvoid end """ @@ -4062,6 +4079,22 @@ function t8_cmesh_is_partitioned(cmesh) @ccall libt8.t8_cmesh_is_partitioned(cmesh::t8_cmesh_t)::Cint end +""" + t8_cmesh_get_dimension(cmesh) + +Get the dimension of a cmesh. + +# Arguments +* `cmesh`:\\[in\\] The cmesh. *cmesh* must be committed before calling this function. +### Prototype +```c +int t8_cmesh_get_dimension (const t8_cmesh_t cmesh); +``` +""" +function t8_cmesh_get_dimension(cmesh) + @ccall libt8.t8_cmesh_get_dimension(cmesh::t8_cmesh_t)::Cint +end + """ t8_cmesh_get_num_trees(cmesh) @@ -4532,7 +4565,7 @@ Calculate the section of a uniform forest for the current rank. * `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 (t8_cmesh_t cmesh, int level, 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 (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(cmesh, level, ts, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) @@ -4632,7 +4665,7 @@ Compute y = x + translate on an array of doubles, interpreting each 3 as one ve * `translate`:\\[in\\] Translation of the vectors. ### Prototype ```c -void t8_cmesh_translate_coordinates (const double *coords_in, double *coords_out, int num_vertices, double translate[3]); +void t8_cmesh_translate_coordinates (const double *coords_in, double *coords_out, const int num_vertices, const double translate[3]); ``` """ function t8_cmesh_translate_coordinates(coords_in, coords_out, num_vertices, translate) @@ -6013,18 +6046,6 @@ 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 -""" - t8_cmesh_vtk_write_file(cmesh, fileprefix) - -### Prototype -```c -int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); -``` -""" -function t8_cmesh_vtk_write_file(cmesh, fileprefix) - @ccall libt8.t8_cmesh_vtk_write_file(cmesh::t8_cmesh_t, fileprefix::Cstring)::Cint -end - """ t8_eclass_count_boundary(theclass, min_dim, per_eclass) @@ -7222,8104 +7243,9428 @@ 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 -# typedef double ( * t8_example_level_set_fn ) ( const double [ 3 ] , double , void * ) -"""A levelset function in 3+1 space dimensions.""" -const t8_example_level_set_fn = Ptr{Cvoid} - -""" - t8_example_level_set_struct_t - -Struct to handle refinement around a level-set function. - -| Field | Note | -| :----------- | :----------------------------------------------------------------------------- | -| L | The level set function. | -| udata | Data pointer that is passed to L | -| band\\_width | Width of max\\_level elements around the zero-level set | -| t | Time value passed to levelset function | -| min\\_level | The minimal refinement level. Elements with this level will not be coarsened. | -| max\\_level | The maximum refinement level. Elements with this level will not be refined. | """ -struct t8_example_level_set_struct_t - L::t8_example_level_set_fn - udata::Ptr{Cvoid} - band_width::Cdouble - t::Cdouble - min_level::Cint - max_level::Cint -end - -# typedef double ( * t8_scalar_function_1d_fn ) ( double x , double t ) -"""Function pointer for real valued functions from d+1 space dimensions functions f: R^d x R -> R""" -const t8_scalar_function_1d_fn = Ptr{Cvoid} - -# typedef double ( * t8_scalar_function_2d_fn ) ( const double x [ 2 ] , double t ) -const t8_scalar_function_2d_fn = Ptr{Cvoid} - -# typedef double ( * t8_scalar_function_3d_fn ) ( const double x [ 3 ] , double t ) -const t8_scalar_function_3d_fn = Ptr{Cvoid} - -# typedef void ( * t8_flow_function_3d_fn ) ( const double x_in [ 3 ] , double t , double x_out [ 3 ] ) -"""Function pointer for a vector valued function f: R^3 x R -> R""" -const t8_flow_function_3d_fn = Ptr{Cvoid} - + t8_forest + +| 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. | +""" +# struct t8_forest +# rc::t8_refcount_t +# set_level::Cint +# set_for_coarsening::Cint +# mpicomm::MPI_Comm +# cmesh::t8_cmesh_t +# scheme_cxx::Ptr{t8_scheme_cxx_t} +# maxlevel::Cint +# maxlevel_existing::Cint +# do_dup::Cint +# dimension::Cint +# incomplete_trees::Cint +# set_from::t8_forest_t +# from_method::t8_forest_from_t +# set_adapt_fn::t8_forest_adapt_t +# set_adapt_recursive::Cint +# set_balance::Cint +# do_ghost::Cint +# ghost_type::t8_ghost_type_t +# ghost_algorithm::Cint +# user_data::Ptr{Cvoid} +# user_function::Ptr{Cvoid} +# t8code_data::Ptr{Cvoid} +# committed::Cint +# mpisize::Cint +# mpirank::Cint +# first_local_tree::t8_gloidx_t +# last_local_tree::t8_gloidx_t +# global_num_trees::t8_gloidx_t +# trees::Ptr{sc_array_t} +# ghosts::t8_forest_ghost_t +# element_offsets::t8_shmem_array_t +# global_first_desc::t8_shmem_array_t +# tree_offsets::t8_shmem_array_t +# local_num_elements::t8_locidx_t +# global_num_elements::t8_gloidx_t +# profile::Ptr{t8_profile_t} +# stats::NTuple{14, sc_statinfo_t} +# stats_computed::Cint +# end + +# 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_common_within_levelset(forest, ltreeid, element, ts, levelset, band_width, t, udata) - -Query whether a given element is within a prescribed distance to the zero level-set of a level-set function. + t8_forest_write_netcdf(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm) -# Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] A local tree in *forest*. -* `element`:\\[in\\] An element of tree *ltreeid* in *forest*. -* `ts`:\\[in\\] The scheme for *element*. -* `levelset`:\\[in\\] The level-set function. -* `band_width`:\\[in\\] Check whether the element is within a band of *band_width* many elements of its size. -* `t`:\\[in\\] Time value passed to *levelset*. -* `udata`:\\[in\\] User data passed to *levelset*. -# Returns -True if the absolute value of *levelset* at *element*'s midpoint is smaller than *band_width* * *element*'s diameter. False otherwise. If *band_width* = 0 then the return value is true if and only if the zero level-set passes through *element*. ### Prototype ```c -int t8_common_within_levelset (t8_forest_t forest, t8_locidx_t ltreeid, t8_element_t *element, t8_eclass_scheme_c *ts, t8_example_level_set_fn levelset, double band_width, double t, void *udata); +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); ``` """ -function t8_common_within_levelset(forest, ltreeid, element, ts, levelset, band_width, t, udata) - @ccall libt8.t8_common_within_levelset(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ts::Ptr{t8_eclass_scheme_c}, levelset::t8_example_level_set_fn, band_width::Cdouble, t::Cdouble, udata::Ptr{Cvoid})::Cint +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 """ - t8_common_adapt_balance(forest, forest_from, which_tree, lelement_id, ts, is_family, num_elements, elements) - -Adapt a forest such that always the second child of the first tree is refined and no other elements. This results in a highly imbalanced forest. + 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) ### Prototype ```c -int t8_common_adapt_balance (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[]); +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); ``` """ -function t8_common_adapt_balance(forest, forest_from, which_tree, lelement_id, ts, is_family, num_elements, elements) - @ccall libt8.t8_common_adapt_balance(forest::t8_forest_t, forest_from::t8_forest_t, which_tree::t8_locidx_t, lelement_id::t8_locidx_t, ts::Ptr{t8_eclass_scheme_c}, is_family::Cint, num_elements::Cint, elements::Ptr{Ptr{t8_element_t}})::Cint +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 """ - t8_common_adapt_level_set(forest, forest_from, which_tree, lelement_id, ts, is_family, num_elements, elements) + t8_mat_init_xrot(mat, angle) -Adapt a forest along a given level-set function. The user data of forest must be a pointer to a [`t8_example_level_set_struct_t`](@ref). An element in the forest is refined, if it is in a band of *band_with* many *max_level* elements around the zero level-set Gamma = { x | L(x) = 0} +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 -int t8_common_adapt_level_set (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[]); +static inline void t8_mat_init_xrot (double mat[3][3], const double angle); ``` """ -function t8_common_adapt_level_set(forest, forest_from, which_tree, lelement_id, ts, is_family, num_elements, elements) - @ccall libt8.t8_common_adapt_level_set(forest::t8_forest_t, forest_from::t8_forest_t, which_tree::t8_locidx_t, lelement_id::t8_locidx_t, ts::Ptr{t8_eclass_scheme_c}, is_family::Cint, num_elements::Cint, elements::Ptr{Ptr{t8_element_t}})::Cint +function t8_mat_init_xrot(mat, angle) + @ccall libt8.t8_mat_init_xrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid end """ - t8_levelset_sphere_data_t + t8_mat_init_yrot(mat, angle) -Real valued functions defined in t8\\_example\\_common\\_functions.h +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); +``` """ -struct t8_levelset_sphere_data_t - M::NTuple{3, Cdouble} - radius::Cdouble +function t8_mat_init_yrot(mat, angle) + @ccall libt8.t8_mat_init_yrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid end """ - t8_levelset_sphere(x, t, data) + t8_mat_init_zrot(mat, angle) -Distance to a sphere with given midpoint and radius. data is interpreted as [`t8_levelset_sphere_data_t`](@ref). +Initialize given 3x3 matrix as rotation matrix around the z-axis with given angle. -# Returns -dist (x,data->M) - data->radius +# Arguments +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. ### Prototype ```c -double t8_levelset_sphere (const double x[3], double t, void *data); +static inline void t8_mat_init_zrot (double mat[3][3], const double angle); ``` """ -function t8_levelset_sphere(x, t, data) - @ccall libt8.t8_levelset_sphere(x::Ptr{Cdouble}, t::Cdouble, data::Ptr{Cvoid})::Cdouble +function t8_mat_init_zrot(mat, angle) + @ccall libt8.t8_mat_init_zrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid end """ - t8_scalar3d_constant_one(x, t) + t8_mat_mult_vec(mat, a, b) -Returns always 1. +Apply matrix-matrix multiplication: b = M*a. -# Returns -1 +# Arguments +* `mat`:\\[in\\] 3x3-matrix. +* `a`:\\[in\\] 3-vector. +* `b`:\\[in,out\\] 3-vector. ### Prototype ```c -double t8_scalar3d_constant_one (const double x[3], double t); +static inline void t8_mat_mult_vec (const double mat[3][3], const double a[3], double b[3]); ``` """ -function t8_scalar3d_constant_one(x, t) - @ccall libt8.t8_scalar3d_constant_one(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +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_scalar3d_constant_zero(x, t) + t8_mat_mult_mat(A, B, C) -Returns always 0. +Apply matrix-matrix multiplication: C = A*B. -# Returns -0 +# Arguments +* `A`:\\[in\\] 3x3-matrix. +* `B`:\\[in\\] 3x3-matrix. +* `C`:\\[in\\] 3x3-matrix. ### Prototype ```c -double t8_scalar3d_constant_zero (const double x[3], double t); +static inline void t8_mat_mult_mat (const double A[3][3], const double B[3][3], double C[3][3]); ``` """ -function t8_scalar3d_constant_zero(x, t) - @ccall libt8.t8_scalar3d_constant_zero(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +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 + """ - t8_scalar3d_project_x(x, t) + t8_mesh_new(dimension, Kglobal, Klocal) -Return the x-coordinate of the input. +*********************** preallocate ************************* -# Returns -x[0] ### Prototype ```c -double t8_scalar3d_project_x (const double x[3], double t); +t8_mesh_t * t8_mesh_new (int dimension, t8_gloidx_t Kglobal, t8_locidx_t Klocal); ``` """ -function t8_scalar3d_project_x(x, t) - @ccall libt8.t8_scalar3d_project_x(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +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 """ - t8_scalar3d_step_function(x, t) + t8_mesh_new_unitcube(theclass) -This function is =1 if the 0.25 <= x <= 0.75 and 0 else. +*********** all-in-one convenience constructors ************* ### Prototype ```c -double t8_scalar3d_step_function (const double x[3], double t); +t8_mesh_t * t8_mesh_new_unitcube (t8_eclass_t theclass); ``` """ -function t8_scalar3d_step_function(x, t) - @ccall libt8.t8_scalar3d_step_function(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +function t8_mesh_new_unitcube(theclass) + @ccall libt8.t8_mesh_new_unitcube(theclass::t8_eclass_t)::Ptr{t8_mesh_t} end """ - t8_scalar3d_almost_step_function(x, t) - -This function is =1 if 0.25 <= x <= 0.75, it is 0 outside of 0.25-eps and 0.75+eps, it interpolates linearly in between. eps = 0.1 * + t8_mesh_set_comm(mesh, comm) ### Prototype ```c -double t8_scalar3d_almost_step_function (const double x[3], double t); +void t8_mesh_set_comm (t8_mesh_t *mesh, sc_MPI_Comm comm); ``` """ -function t8_scalar3d_almost_step_function(x, t) - @ccall libt8.t8_scalar3d_almost_step_function(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +function t8_mesh_set_comm(mesh, comm) + @ccall libt8.t8_mesh_set_comm(mesh::Ptr{t8_mesh_t}, comm::MPI_Comm)::Cvoid end """ - t8_scalar3d_exp_distribution(x, t) + t8_mesh_set_partition(mesh, enable) -A 1-d Bell-curve centered around 0.5 +Determine whether we partition in t8_mesh_build. Default true. ### Prototype ```c -double t8_scalar3d_exp_distribution (const double x[3], double t); +void t8_mesh_set_partition (t8_mesh_t *mesh, int enable); ``` """ -function t8_scalar3d_exp_distribution(x, t) - @ccall libt8.t8_scalar3d_exp_distribution(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +function t8_mesh_set_partition(mesh, enable) + @ccall libt8.t8_mesh_set_partition(mesh::Ptr{t8_mesh_t}, enable::Cint)::Cvoid end """ - t8_scalar3d_sinx(x, t) - -Sinus of 2pi x\\_0 + t8_mesh_set_element(mesh, theclass, gloid, locid) -# Returns -sin (2pi x[0]) ### Prototype ```c -double t8_scalar3d_sinx (const double x[3], double t); +void t8_mesh_set_element (t8_mesh_t *mesh, t8_eclass_t theclass, t8_gloidx_t gloid, t8_locidx_t locid); ``` """ -function t8_scalar3d_sinx(x, t) - @ccall libt8.t8_scalar3d_sinx(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +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 """ - t8_scalar3d_sinx_cosy(x, t) - -Sinus of x times cosinus of y + t8_mesh_set_local_to_global(mesh, ltog_length, ltog) -# Returns -sin (2pi x[0]) * cos (2pi x[1]) ### Prototype ```c -double t8_scalar3d_sinx_cosy (const double x[3], double t); +void t8_mesh_set_local_to_global (t8_mesh_t *mesh, t8_locidx_t ltog_length, const t8_gloidx_t *ltog); ``` """ -function t8_scalar3d_sinx_cosy(x, t) - @ccall libt8.t8_scalar3d_sinx_cosy(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +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 """ - t8_scalar3d_sinx_cosy_z(x, t) - -Sinus of 10 * x times cosinus of y times z + t8_mesh_set_face(mesh, locid1, face1, locid2, face2, orientation) -# Returns -10 * sin (2pi x[0]) * cos (2pi x[1]) * x[3] ### Prototype ```c -double t8_scalar3d_sinx_cosy_z (const double x[3], double t); +void t8_mesh_set_face (t8_mesh_t *mesh, t8_locidx_t locid1, int face1, t8_locidx_t locid2, int face2, int orientation); ``` """ -function t8_scalar3d_sinx_cosy_z(x, t) - @ccall libt8.t8_scalar3d_sinx_cosy_z(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +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 """ - t8_scalar3d_sint(x, t) - -Sinus of t + t8_mesh_set_element_vertices(mesh, locid, vids_length, vids) -# Returns -sin (2pi t) ### Prototype ```c -double t8_scalar3d_sint (const double x[3], double t); +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 t8_scalar3d_sint(x, t) - @ccall libt8.t8_scalar3d_sint(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +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 """ - t8_scalar3d_sphere_75_radius(x, t) + t8_mesh_build(mesh) -Level-set function of a sphere around origin with radius 0.75 +Setup a mesh and turn it into a usable object. -# Returns -|x| - 0.75 ### Prototype ```c -double t8_scalar3d_sphere_75_radius (const double x[3], double t); +void t8_mesh_build (t8_mesh_t *mesh); ``` """ -function t8_scalar3d_sphere_75_radius(x, t) - @ccall libt8.t8_scalar3d_sphere_75_radius(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +function t8_mesh_build(mesh) + @ccall libt8.t8_mesh_build(mesh::Ptr{t8_mesh_t})::Cvoid end """ - t8_scalar3d_sphere_05_midpoint_375_radius(x, t) - -Level-set function of a sphere around M = (0.5,0.5,0.5) with radius 0.375 + t8_mesh_get_comm(mesh) -# Returns -|x - M| - 0.375 ### Prototype ```c -double t8_scalar3d_sphere_05_midpoint_375_radius (const double x[3], double t); +sc_MPI_Comm t8_mesh_get_comm (t8_mesh_t *mesh); ``` """ -function t8_scalar3d_sphere_05_midpoint_375_radius(x, t) - @ccall libt8.t8_scalar3d_sphere_05_midpoint_375_radius(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +function t8_mesh_get_comm(mesh) + @ccall libt8.t8_mesh_get_comm(mesh::Ptr{t8_mesh_t})::Cint end """ - t8_scalar3d_sphere_03_midpoint_25_radius(x, t) - -Level-set function of a sphere around M = (0.3,0.3,0.3) with radius 0.25 + t8_mesh_get_element_count(mesh, theclass) -# Returns -|x - M| - 0.25 ### Prototype ```c -double t8_scalar3d_sphere_03_midpoint_25_radius (const double x[3], double t); +t8_locidx_t t8_mesh_get_element_count (t8_mesh_t *mesh, t8_eclass_t theclass); ``` """ -function t8_scalar3d_sphere_03_midpoint_25_radius(x, t) - @ccall libt8.t8_scalar3d_sphere_03_midpoint_25_radius(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +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 """ - t8_scalar3d_sphere_05_0z_midpoint_375_radius(x, t) - -Level-set function of a sphere around M = (0.5,0.5,0) with radius 0.375 + t8_mesh_get_element_class(mesh, locid) -# Returns -|x - M| - 0.375 +# 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 -double t8_scalar3d_sphere_05_0z_midpoint_375_radius (const double x[3], double t); +t8_locidx_t t8_mesh_get_element_class (t8_mesh_t *mesh, t8_locidx_t locid); ``` """ -function t8_scalar3d_sphere_05_0z_midpoint_375_radius(x, t) - @ccall libt8.t8_scalar3d_sphere_05_0z_midpoint_375_radius(x::Ptr{Cdouble}, t::Cdouble)::Cdouble +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 """ - t8_flow_constant_one_vec(x, t, x_out) - -Returns always 1 in each coordinate. + t8_mesh_get_element_locid(mesh, gloid) ### Prototype ```c -void t8_flow_constant_one_vec (const double x[3], double t, double x_out[3]); +t8_locidx_t t8_mesh_get_element_locid (t8_mesh_t *mesh, t8_gloidx_t gloid); ``` """ -function t8_flow_constant_one_vec(x, t, x_out) - @ccall libt8.t8_flow_constant_one_vec(x::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::Cvoid +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 """ - t8_flow_constant_one_x_vec(x, t, x_out) - -Sets the first coordinate to 1, all other to 0. + t8_mesh_get_element_gloid(mesh, locid) ### Prototype ```c -void t8_flow_constant_one_x_vec (const double x[3], double t, double x_out[3]); +t8_gloidx_t t8_mesh_get_element_gloid (t8_mesh_t *mesh, t8_locidx_t locid); ``` """ -function t8_flow_constant_one_x_vec(x, t, x_out) - @ccall libt8.t8_flow_constant_one_x_vec(x::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::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 """ - t8_flow_constant_one_xy_vec(x, t, x_out) - -Sets the first and second coordinate to 1, the third to 0. + t8_mesh_get_element(mesh, locid) ### Prototype ```c -void t8_flow_constant_one_xy_vec (const double x[3], double t, double x_out[3]); +t8_element_t t8_mesh_get_element (t8_mesh_t *mesh, t8_locidx_t locid); ``` """ -function t8_flow_constant_one_xy_vec(x, t, x_out) - @ccall libt8.t8_flow_constant_one_xy_vec(x::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::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 """ - t8_flow_constant_one_xyz_vec(x, t, x_out) - -Sets all coordinates to a nonzero constant. + t8_mesh_get_element_boundary(mesh, locid, length_boundary, elemid, orientation) ### Prototype ```c -void t8_flow_constant_one_xyz_vec (const double x[3], double t, double x_out[3]); +void t8_mesh_get_element_boundary (t8_mesh_t *mesh, t8_locidx_t locid, int length_boundary, t8_locidx_t *elemid, int *orientation); ``` """ -function t8_flow_constant_one_xyz_vec(x, t, x_out) - @ccall libt8.t8_flow_constant_one_xyz_vec(x::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::Cvoid +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 """ - t8_flow_rotation_2d(x, t, x_out) + t8_mesh_get_maximum_support(mesh) -Transform the unit square to [-0.5,0.5]^2 and computes x = 2pi*y, y = -2pi*x +Return the maximum of the length of the support of any local element. ### Prototype ```c -void t8_flow_rotation_2d (const double x[3], double t, double x_out[3]); +int t8_mesh_get_maximum_support (t8_mesh_t *mesh); ``` """ -function t8_flow_rotation_2d(x, t, x_out) - @ccall libt8.t8_flow_rotation_2d(x::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::Cvoid +function t8_mesh_get_maximum_support(mesh) + @ccall libt8.t8_mesh_get_maximum_support(mesh::Ptr{t8_mesh_t})::Cint end """ - t8_flow_compressible(x_in, t, x_out) + t8_mesh_get_element_support(mesh, locid, length_support, elemid, orientation) +# Arguments +* `length_support`:\\[in,out\\] ### Prototype ```c -void t8_flow_compressible (const double x_in[3], double t, double x_out[3]); +void t8_mesh_get_element_support (t8_mesh_t *mesh, t8_locidx_t locid, int *length_support, t8_locidx_t *elemid, int *orientation); ``` """ -function t8_flow_compressible(x_in, t, x_out) - @ccall libt8.t8_flow_compressible(x_in::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::Cvoid +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 """ - t8_flow_incomp_cube_flow(x, t, x_out) + t8_mesh_destroy(mesh) -Incompressible flow in unit cube +*************************** destruct ************************ ### Prototype ```c -void t8_flow_incomp_cube_flow (const double x[3], double t, double x_out[3]); +void t8_mesh_destroy (t8_mesh_t *mesh); ``` """ -function t8_flow_incomp_cube_flow(x, t, x_out) - @ccall libt8.t8_flow_incomp_cube_flow(x::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::Cvoid +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 + """ - t8_flow_around_circle(x, t, x_out) + t8_netcdf_create_var(var_type, var_name, var_long_name, var_unit, var_data) -2d flow around a circle with radius R = 1 and constant inflow with x-speed U = 1. See https://doi.org/10.13140/RG.2.2.34714.11203 +Create an extern double variable which additionally should be put out to the NetCDF File +# 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 -void t8_flow_around_circle (const double x[3], double t, double x_out[3]); +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 t8_flow_around_circle(x, t, x_out) - @ccall libt8.t8_flow_around_circle(x::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::Cvoid +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 """ - t8_flow_stokes_flow_sphere_shell(x, t, x_out) + t8_netcdf_create_integer_var(var_name, var_long_name, var_unit, var_data) +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 +* `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 -void t8_flow_stokes_flow_sphere_shell (const double x[3], double t, double x_out[3]); +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 t8_flow_stokes_flow_sphere_shell(x, t, x_out) - @ccall libt8.t8_flow_stokes_flow_sphere_shell(x::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::Cvoid +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 """ - t8_flow_around_circle_with_angular_velocity(x, t, x_out) + t8_netcdf_create_double_var(var_name, var_long_name, var_unit, var_data) +Create an extern double variable which additionally should be put out to the NetCDF File + +# 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). ### Prototype ```c -void t8_flow_around_circle_with_angular_velocity (const double x[3], double t, double x_out[]); +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 t8_flow_around_circle_with_angular_velocity(x, t, x_out) - @ccall libt8.t8_flow_around_circle_with_angular_velocity(x::Ptr{Cdouble}, t::Cdouble, x_out::Ptr{Cdouble})::Cvoid +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 """ - t8_forest_write_netcdf(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm) + t8_netcdf_variable_destroy(var_destroy) + +Free the allocated memory of the a [`t8_netcdf_variable_t`](@ref) +# Arguments +* `var_destroy`:\\[in\\] A t8\\_netcdf\\_t variable whose allocated memory should be freed. ### 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); +void t8_netcdf_variable_destroy (t8_netcdf_variable_t *var_destroy); ``` """ -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 +function t8_netcdf_variable_destroy(var_destroy) + @ccall libt8.t8_netcdf_variable_destroy(var_destroy::Ptr{t8_netcdf_variable_t})::Cvoid end """ - 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) + 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_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); +void t8_refcount_init (t8_refcount_t *rc); ``` """ -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 +function t8_refcount_init(rc) + @ccall libt8.t8_refcount_init(rc::Ptr{t8_refcount_t})::Cvoid end """ - t8_mat_init_xrot(mat, angle) + t8_refcount_new() -Initialize given 3x3 matrix as rotation matrix around the x-axis with given angle. +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. -# Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. +# Returns +An allocated reference counter whose count has been set to one. ### Prototype ```c -static inline void t8_mat_init_xrot (double mat[3][3], const double angle); +t8_refcount_t * t8_refcount_new (void); ``` """ -function t8_mat_init_xrot(mat, angle) - @ccall libt8.t8_mat_init_xrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function t8_refcount_new() + @ccall libt8.t8_refcount_new()::Ptr{t8_refcount_t} end """ - t8_mat_init_yrot(mat, angle) + t8_refcount_destroy(rc) -Initialize given 3x3 matrix as rotation matrix around the y-axis with given angle. +Destroy a reference counter that we allocated with t8_refcount_new. Its reference count must have decreased to zero. # Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. +* `rc`:\\[in,out\\] Allocated, formerly valid reference counter. ### Prototype ```c -static inline void t8_mat_init_yrot (double mat[3][3], const double angle); +void t8_refcount_destroy (t8_refcount_t *rc); ``` """ -function t8_mat_init_yrot(mat, angle) - @ccall libt8.t8_mat_init_yrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function t8_refcount_destroy(rc) + @ccall libt8.t8_refcount_destroy(rc::Ptr{t8_refcount_t})::Cvoid end """ - t8_mat_init_zrot(mat, angle) + t8_vec_norm(vec) -Initialize given 3x3 matrix as rotation matrix around the z-axis with given angle. +Vector norm. # Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. +* `vec`:\\[in\\] A 3D vector. +# Returns +The norm of *vec*. ### Prototype ```c -static inline void t8_mat_init_zrot (double mat[3][3], const double angle); +static inline double t8_vec_norm (const double vec[3]); ``` """ -function t8_mat_init_zrot(mat, angle) - @ccall libt8.t8_mat_init_zrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function t8_vec_norm(vec) + @ccall libt8.t8_vec_norm(vec::Ptr{Cdouble})::Cdouble end """ - t8_mat_mult_vec(mat, a, b) + t8_vec_normalize(vec) -Apply matrix-matrix multiplication: b = M*a. +Normalize a vector. # Arguments -* `mat`:\\[in\\] 3x3-matrix. -* `a`:\\[in\\] 3-vector. -* `b`:\\[in,out\\] 3-vector. +* `vec`:\\[in,out\\] A 3D vector. ### Prototype ```c -static inline void t8_mat_mult_vec (const double mat[3][3], const double a[3], double b[3]); +static inline void t8_vec_normalize (double vec[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 +function t8_vec_normalize(vec) + @ccall libt8.t8_vec_normalize(vec::Ptr{Cdouble})::Cvoid end """ - t8_mat_mult_mat(A, B, C) + t8_vec_copy(vec_in, vec_out) -Apply matrix-matrix multiplication: C = A*B. +Make a copy of a vector. # Arguments -* `A`:\\[in\\] 3x3-matrix. -* `B`:\\[in\\] 3x3-matrix. -* `C`:\\[in\\] 3x3-matrix. +* `vec_in`:\\[in\\] +* `vec_out`:\\[out\\] ### Prototype ```c -static inline void t8_mat_mult_mat (const double A[3][3], const double B[3][3], double C[3][3]); +static inline void t8_vec_copy (const double vec_in[3], double vec_out[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 +function t8_vec_copy(vec_in, vec_out) + @ccall libt8.t8_vec_copy(vec_in::Ptr{Cdouble}, vec_out::Ptr{Cdouble})::Cvoid end -mutable struct t8_mesh end - -const t8_mesh_t = t8_mesh - """ - t8_mesh_new(dimension, Kglobal, Klocal) + t8_vec_dist(vec_x, vec_y) -*********************** preallocate ************************* +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 -t8_mesh_t * t8_mesh_new (int dimension, t8_gloidx_t Kglobal, t8_locidx_t Klocal); +static inline double t8_vec_dist (const double vec_x[3], const double vec_y[3]); ``` """ -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} +function t8_vec_dist(vec_x, vec_y) + @ccall libt8.t8_vec_dist(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble end """ - t8_mesh_new_unitcube(theclass) + t8_vec_ax(vec_x, alpha) -*********** all-in-one convenience constructors ************* +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 -t8_mesh_t * t8_mesh_new_unitcube (t8_eclass_t theclass); +static inline void t8_vec_ax (double vec_x[3], const double alpha); ``` """ -function t8_mesh_new_unitcube(theclass) - @ccall libt8.t8_mesh_new_unitcube(theclass::t8_eclass_t)::Ptr{t8_mesh_t} +function t8_vec_ax(vec_x, alpha) + @ccall libt8.t8_vec_ax(vec_x::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - t8_mesh_set_comm(mesh, comm) + t8_vec_axy(vec_x, vec_y, alpha) + +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 -void t8_mesh_set_comm (t8_mesh_t *mesh, sc_MPI_Comm comm); +static inline void t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha); ``` """ -function t8_mesh_set_comm(mesh, comm) - @ccall libt8.t8_mesh_set_comm(mesh::Ptr{t8_mesh_t}, comm::MPI_Comm)::Cvoid +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 """ - t8_mesh_set_partition(mesh, enable) + t8_vec_axb(vec_x, vec_y, alpha, b) -Determine whether we partition in t8_mesh_build. Default true. +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_mesh_set_partition (t8_mesh_t *mesh, int enable); +static inline void t8_vec_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b); ``` """ -function t8_mesh_set_partition(mesh, enable) - @ccall libt8.t8_mesh_set_partition(mesh::Ptr{t8_mesh_t}, enable::Cint)::Cvoid +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 """ - t8_mesh_set_element(mesh, theclass, gloid, locid) + t8_vec_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 -void t8_mesh_set_element (t8_mesh_t *mesh, t8_eclass_t theclass, t8_gloidx_t gloid, t8_locidx_t locid); +static inline void t8_vec_axpy (const double vec_x[3], double vec_y[3], const double alpha); ``` """ -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 +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 """ - t8_mesh_set_local_to_global(mesh, ltog_length, ltog) + t8_vec_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* ### Prototype ```c -void t8_mesh_set_local_to_global (t8_mesh_t *mesh, t8_locidx_t ltog_length, const t8_gloidx_t *ltog); +static inline void t8_vec_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], const double alpha); ``` """ -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 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 """ - t8_mesh_set_face(mesh, locid1, face1, locid2, face2, orientation) + t8_vec_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 -void t8_mesh_set_face (t8_mesh_t *mesh, t8_locidx_t locid1, int face1, t8_locidx_t locid2, int face2, int orientation); +static inline double t8_vec_dot (const double vec_x[3], const double vec_y[3]); ``` """ -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 t8_vec_dot(vec_x, vec_y) + @ccall libt8.t8_vec_dot(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble end """ - t8_mesh_set_element_vertices(mesh, locid, vids_length, vids) + t8_vec_cross(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 -void t8_mesh_set_element_vertices (t8_mesh_t *mesh, t8_locidx_t locid, t8_locidx_t vids_length, const t8_locidx_t *vids); +static inline void t8_vec_cross (const double vec_x[3], const double vec_y[3], double cross[3]); ``` """ -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 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 """ - t8_mesh_build(mesh) + t8_vec_diff(vec_x, vec_y, diff) -Setup a mesh and turn it into a usable object. +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 -void t8_mesh_build (t8_mesh_t *mesh); +static inline void t8_vec_diff (const double vec_x[3], const double vec_y[3], double diff[3]); ``` """ -function t8_mesh_build(mesh) - @ccall libt8.t8_mesh_build(mesh::Ptr{t8_mesh_t})::Cvoid +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 """ - t8_mesh_get_comm(mesh) + t8_vec_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 -sc_MPI_Comm t8_mesh_get_comm (t8_mesh_t *mesh); +static inline int t8_vec_eq (const double vec_x[3], const double vec_y[3], const double tol); ``` """ -function t8_mesh_get_comm(mesh) - @ccall libt8.t8_mesh_get_comm(mesh::Ptr{t8_mesh_t})::Cint +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 """ - t8_mesh_get_element_count(mesh, theclass) + t8_vec_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 -t8_locidx_t t8_mesh_get_element_count (t8_mesh_t *mesh, t8_eclass_t theclass); +static inline void t8_vec_rescale (double vec[3], const double new_length); ``` """ -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 t8_vec_rescale(vec, new_length) + @ccall libt8.t8_vec_rescale(vec::Ptr{Cdouble}, new_length::Cdouble)::Cvoid end """ - t8_mesh_get_element_class(mesh, locid) + t8_vec_tri_normal(p1, p2, p3, normal) + +Compute the normal of a triangle given by its three vertices. # 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. +* `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 -t8_locidx_t t8_mesh_get_element_class (t8_mesh_t *mesh, t8_locidx_t locid); +static inline void t8_vec_tri_normal (const double p1[3], const double p2[3], const double p3[3], double normal[3]); ``` """ -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 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 """ - t8_mesh_get_element_locid(mesh, gloid) + t8_vec_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 -t8_locidx_t t8_mesh_get_element_locid (t8_mesh_t *mesh, t8_gloidx_t gloid); +static inline void t8_vec_orthogonal_tripod (const double v1[3], double v2[3], double v3[3]); ``` """ -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 t8_vec_orthogonal_tripod(v1, v2, v3) + @ccall libt8.t8_vec_orthogonal_tripod(v1::Ptr{Cdouble}, v2::Ptr{Cdouble}, v3::Ptr{Cdouble})::Cvoid end """ - t8_mesh_get_element_gloid(mesh, locid) + t8_vec_swap(p1, p2) + +Swap the components of two vectors. +# Arguments +* `p1`:\\[in,out\\] A 3D vector. +* `p2`:\\[in,out\\] A 3D vector. ### Prototype ```c -t8_gloidx_t t8_mesh_get_element_gloid (t8_mesh_t *mesh, t8_locidx_t locid); +static inline void t8_vec_swap (double p1[3], double p2[3]); ``` """ -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 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 """ - t8_mesh_get_element(mesh, locid) + t8_get_package_string() + +Return the package string of t8code. This string has the format "t8 version\\_number". +# Returns +The version string of t8code. ### Prototype ```c -t8_element_t t8_mesh_get_element (t8_mesh_t *mesh, t8_locidx_t locid); +const char* t8_get_package_string (); ``` """ -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 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 """ - t8_mesh_get_element_boundary(mesh, locid, length_boundary, elemid, orientation) + t8_get_version_number() + +Return the version number of t8code as a string. +# Returns +The version number of t8code as a string. ### 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); +const char* t8_get_version_number (); ``` """ -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 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 """ - t8_mesh_get_maximum_support(mesh) + t8_get_version_point_string() -Return the maximum of the length of the support of any local element. +Return the version point string. +# Returns +The version point point string. ### Prototype ```c -int t8_mesh_get_maximum_support (t8_mesh_t *mesh); +const char* t8_get_version_point_string (); ``` """ -function t8_mesh_get_maximum_support(mesh) - @ccall libt8.t8_mesh_get_maximum_support(mesh::Ptr{t8_mesh_t})::Cint +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 """ - t8_mesh_get_element_support(mesh, locid, length_support, elemid, orientation) + t8_get_version_major() -# Arguments -* `length_support`:\\[in,out\\] +Return the major version number of t8code. + +# Returns +The major version number of t8code. ### 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); +int t8_get_version_major (); ``` """ -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 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 """ - t8_mesh_destroy(mesh) + t8_get_version_minor() -*************************** destruct ************************ +Return the minor version number of t8code. +# Returns +The minor version number of t8code. ### Prototype ```c -void t8_mesh_destroy (t8_mesh_t *mesh); +int t8_get_version_minor (); ``` """ -function t8_mesh_destroy(mesh) - @ccall libt8.t8_mesh_destroy(mesh::Ptr{t8_mesh_t})::Cvoid +function t8_get_version_minor() + @ccall libt8.t8_get_version_minor()::Cint end -const t8_nc_int64_t = Int64 +# no prototype is found for this function at t8_version.h:104:1, please use with caution +""" + t8_get_version_patch() -const t8_nc_int32_t = Int32 +Return the patch version number of t8code. -""" - t8_netcdf_create_var(var_type, var_name, var_long_name, var_unit, var_data) +!!! note -Create an extern double variable which additionally should be put out to the NetCDF File -# 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). +# Returns +The patch version unmber of t8code. negative on error. ### 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); +int t8_get_version_patch (); ``` """ -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 t8_get_version_patch() + @ccall libt8.t8_get_version_patch()::Cint end -""" - t8_netcdf_create_integer_var(var_name, var_long_name, var_unit, var_data) +@cenum t8_vtk_data_type_t::UInt32 begin + T8_VTK_SCALAR = 0 + T8_VTK_VECTOR = 1 +end -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)) +""" + t8_vtk_data_field_t -# 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). -### 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); -``` +| Field | Note | +| :---------- | :----------------------------------------- | +| type | Describes of which type the data array is | +| description | String that describes the data. | """ -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} +struct t8_vtk_data_field_t + type::t8_vtk_data_type_t + description::NTuple{8192, Cchar} + data::Ptr{Cdouble} end """ - t8_netcdf_create_double_var(var_name, var_long_name, var_unit, var_data) - -Create an extern double variable which additionally should be put out to the NetCDF File + t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) -# 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). ### 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); +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_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 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_netcdf_variable_destroy(var_destroy) + getdelim(lineptr, n, delimiter, stream) -Free the allocated memory of the a [`t8_netcdf_variable_t`](@ref) - -# Arguments -* `var_destroy`:\\[in\\] A t8\\_netcdf\\_t variable whose allocated memory should be freed. ### Prototype ```c -void t8_netcdf_variable_destroy (t8_netcdf_variable_t *var_destroy); +static ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream); ``` """ -function t8_netcdf_variable_destroy(var_destroy) - @ccall libt8.t8_netcdf_variable_destroy(var_destroy::Ptr{t8_netcdf_variable_t})::Cvoid +function getdelim(lineptr, n, delimiter, stream) + @ccall libt8.getdelim(lineptr::Ptr{Cstring}, n::Ptr{Cint}, delimiter::Cint, stream::Ptr{Cint})::Cint end """ - t8_refcount_init(rc) + getline(lineptr, n, stream) -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); +static ssize_t getline (char **lineptr, size_t *n, FILE *stream); ``` """ -function t8_refcount_init(rc) - @ccall libt8.t8_refcount_init(rc::Ptr{t8_refcount_t})::Cvoid +function getline(lineptr, n, stream) + @ccall libt8.getline(lineptr::Ptr{Cstring}, n::Ptr{Cint}, stream::Ptr{Cint})::Cint end """ - t8_refcount_new() + strsep(stringp, delim) -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. +Extract token from string up to a given delimiter. + +For a full description see https://linux.die.net/man/3/[`strsep`](@ref) -# Returns -An allocated reference counter whose count has been set to one. ### Prototype ```c -t8_refcount_t * t8_refcount_new (void); +static char * strsep (char **stringp, const char *delim); ``` """ -function t8_refcount_new() - @ccall libt8.t8_refcount_new()::Ptr{t8_refcount_t} +function strsep(stringp, delim) + @ccall libt8.strsep(stringp::Ptr{Cstring}, delim::Cstring)::Cstring end """ - t8_refcount_destroy(rc) + t8_cmesh_copy(cmesh, cmesh_from, comm) -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); +void t8_cmesh_copy (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, sc_MPI_Comm comm); ``` """ -function t8_refcount_destroy(rc) - @ccall libt8.t8_refcount_destroy(rc::Ptr{t8_refcount_t})::Cvoid +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 """ - t8_step3_main(argc, argv) - -This is the main program of this example. It creates a coarse mesh and a forest, adapts the forest and writes some output. + sc_io_read(mpifile, ptr, zcount, t, errmsg) ### Prototype ```c -int t8_step3_main (int argc, char **argv); +void sc_io_read (sc_MPI_File mpifile, void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); ``` """ -function t8_step3_main(argc, argv) - @ccall libt8.t8_step3_main(argc::Cint, argv::Ptr{Cstring})::Cint +function sc_io_read(mpifile, ptr, zcount, t, errmsg) + @ccall libsc.sc_io_read(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::MPI_Datatype, errmsg::Cstring)::Cvoid end """ - t8_step3_print_forest_information(forest) - -Print the local and global number of elements of a forest. + sc_io_write(mpifile, ptr, zcount, t, errmsg) ### Prototype ```c -void t8_step3_print_forest_information (t8_forest_t forest); +void sc_io_write (sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); ``` """ -function t8_step3_print_forest_information(forest) - @ccall libt8.t8_step3_print_forest_information(forest::t8_forest_t)::Cvoid +function sc_io_write(mpifile, ptr, zcount, t, errmsg) + @ccall libsc.sc_io_write(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::MPI_Datatype, errmsg::Cstring)::Cvoid end -struct t8_step3_adapt_data - midpoint::NTuple{3, Cdouble} - refine_if_inside_radius::Cdouble - coarsen_if_outside_radius::Cdouble -end +"""Typedef for quadrant coordinates.""" +const p4est_qcoord_t = Int32 -""" - t8_step3_adapt_forest(forest) +"""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 -Adapt a forest according to our [`t8_step3_adapt_callback`](@ref) function. Thus, the input forest will get refined inside a sphere of radius 0.2 around (0.5, 0.5, 0.5) and coarsened outside of radius 0.4. +"""Typedef for globally unique indexing of quadrants.""" +const p4est_gloidx_t = Int64 -# Arguments -* `forest`:\\[in\\] A committed forest. -# Returns -A new forest that arises from the input *forest* via adaptation. -### Prototype -```c -t8_forest_t t8_step3_adapt_forest (t8_forest_t forest); -``` """ -function t8_step3_adapt_forest(forest) - @ccall libt8.t8_step3_adapt_forest(forest::t8_forest_t)::t8_forest_t -end + sc_io_error_t -""" - t8_step3_adapt_callback(forest, forest_from, which_tree, lelement_id, ts, is_family, num_elements, elements) +Error values for io. -### Prototype -```c -int t8_step3_adapt_callback (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[]); -``` +| 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 t8_step3_adapt_callback(forest, forest_from, which_tree, lelement_id, ts, is_family, num_elements, elements) - @ccall libt8.t8_step3_adapt_callback(forest::t8_forest_t, forest_from::t8_forest_t, which_tree::t8_locidx_t, lelement_id::t8_locidx_t, ts::Ptr{t8_eclass_scheme_c}, is_family::Cint, num_elements::Cint, elements::Ptr{Ptr{t8_element_t}})::Cint +@cenum sc_io_error_t::Int32 begin + SC_IO_ERROR_NONE = 0 + SC_IO_ERROR_FATAL = -1 + SC_IO_ERROR_AGAIN = -2 end """ - t8_step4_main(argc, argv) + sc_io_mode_t -This is the main program of this example. +The I/O mode for writing using sc_io_sink. -### Prototype -```c -int t8_step4_main (int argc, char **argv); -``` -""" -function t8_step4_main(argc, argv) - @ccall libt8.t8_step4_main(argc::Cint, argv::Ptr{Cstring})::Cint -end +| 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 """ - t8_step5_main(argc, argv) + sc_io_encode_t -This is the main program of this example. +Enum to specify encoding for sc_io_sink and sc_io_source. -### Prototype -```c -int t8_step5_main (int argc, char **argv); -``` +| Enumerator | Note | +| :---------------------- | :--------------------------- | +| SC\\_IO\\_ENCODE\\_NONE | No encoding | +| SC\\_IO\\_ENCODE\\_LAST | Invalid entry to close list | """ -function t8_step5_main(argc, argv) - @ccall libt8.t8_step5_main(argc::Cint, argv::Ptr{Cstring})::Cint +@cenum sc_io_encode_t::UInt32 begin + SC_IO_ENCODE_NONE = 0 + SC_IO_ENCODE_LAST = 1 end """ - t8_step6_main(argc, argv) + sc_io_type_t -This is the main program of this example. +The type of I/O operation sc_io_sink and sc_io_source. -### Prototype -```c -int t8_step6_main (int argc, char **argv); -``` +| 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 t8_step6_main(argc, argv) - @ccall libt8.t8_step6_main(argc::Cint, argv::Ptr{Cstring})::Cint +@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 """ - t8_step7_main(argc, argv) + sc_io_sink -This is the main program of this example. +A generic data sink. -### Prototype -```c -int t8_step7_main (int argc, char **argv); -``` +| 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 t8_step7_main(argc, argv) - @ccall libt8.t8_step7_main(argc::Cint, argv::Ptr{Cstring})::Cint +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 + """ - t8_tutorial_build_cmesh_main(argc, argv) + sc_io_source -This is the main program of this example. +A generic data source. -### Prototype -```c -int t8_tutorial_build_cmesh_main (int argc, char **argv); -``` +| 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 | """ -function t8_tutorial_build_cmesh_main(argc, argv) - @ccall libt8.t8_tutorial_build_cmesh_main(argc::Cint, argv::Ptr{Cstring})::Cint +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 + """ - t8_vec_norm(vec) + sc_io_open_mode_t -Vector norm. +Open modes for sc_io_open -# Arguments -* `vec`:\\[in\\] A 3D vector. -# Returns -The norm of *vec*. -### Prototype -```c -static inline double t8_vec_norm (const double vec[3]); -``` +| 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 | """ -function t8_vec_norm(vec) - @ccall libt8.t8_vec_norm(vec::Ptr{Cdouble})::Cdouble +@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 + """ - t8_vec_normalize(vec) + sc_io_sink_destroy(sink) -Normalize a vector. +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 -* `vec`:\\[in,out\\] A 3D vector. +* `sink`:\\[in,out\\] The sink object to complete and free. +# Returns +0 on success, nonzero on error. ### Prototype ```c -static inline void t8_vec_normalize (double vec[3]); +int sc_io_sink_destroy (sc_io_sink_t * sink); ``` """ -function t8_vec_normalize(vec) - @ccall libt8.t8_vec_normalize(vec::Ptr{Cdouble})::Cvoid +function sc_io_sink_destroy(sink) + @ccall libsc.sc_io_sink_destroy(sink::Ptr{sc_io_sink_t})::Cint end """ - t8_vec_copy(vec_in, vec_out) + sc_io_sink_destroy_null(sink) -Make a copy of a vector. +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 -* `vec_in`:\\[in\\] -* `vec_out`:\\[out\\] +* `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 -static inline void t8_vec_copy (const double vec_in[3], double vec_out[3]); +int sc_io_sink_destroy_null (sc_io_sink_t ** sink); ``` """ -function t8_vec_copy(vec_in, vec_out) - @ccall libt8.t8_vec_copy(vec_in::Ptr{Cdouble}, vec_out::Ptr{Cdouble})::Cvoid +function sc_io_sink_destroy_null(sink) + @ccall libsc.sc_io_sink_destroy_null(sink::Ptr{Ptr{sc_io_sink_t}})::Cint end """ - t8_vec_dist(vec_x, vec_y) + sc_io_sink_write(sink, data, bytes_avail) -Euclidean distance of X and Y. +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 -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. +* `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 -The euclidean distance. Equivalent to norm (X-Y). +0 on success, nonzero on error. ### Prototype ```c -static inline double t8_vec_dist (const double vec_x[3], const double vec_y[3]); +int sc_io_sink_write (sc_io_sink_t * sink, const void *data, size_t bytes_avail); ``` """ -function t8_vec_dist(vec_x, vec_y) - @ccall libt8.t8_vec_dist(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +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 """ - t8_vec_ax(vec_x, alpha) + sc_io_sink_complete(sink, bytes_in, bytes_out) -Compute X = alpha * X +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 -* `vec_x`:\\[in,out\\] A 3D vector. On output set to *alpha* * *vec_x*. -* `alpha`:\\[in\\] A factor. +* `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 -static inline void t8_vec_ax (double vec_x[3], const double alpha); +int sc_io_sink_complete (sc_io_sink_t * sink, size_t *bytes_in, size_t *bytes_out); ``` """ -function t8_vec_ax(vec_x, alpha) - @ccall libt8.t8_vec_ax(vec_x::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +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 """ - t8_vec_axy(vec_x, vec_y, alpha) + sc_io_sink_align(sink, bytes_align) -Compute Y = alpha * X +Align sink to a byte boundary by writing zeros. # Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_z`:\\[out\\] On output set to *alpha* * *vec_x*. -* `alpha`:\\[in\\] A factor. +* `sink`:\\[in,out\\] The sink object to align. +* `bytes_align`:\\[in\\] Byte boundary. +# Returns +0 on success, nonzero on error. ### Prototype ```c -static inline void t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha); +int sc_io_sink_align (sc_io_sink_t * sink, size_t bytes_align); ``` """ -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 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 -""" - t8_vec_axb(vec_x, vec_y, alpha, b) - -Y = alpha * X + b +# 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 -!!! note +""" + sc_io_source_destroy(source) - It is possible that vec\\_x = vec\\_y on input to overwrite x +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 -* `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. +* `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 -static inline void t8_vec_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b); +int sc_io_source_destroy (sc_io_source_t * source); ``` """ -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 sc_io_source_destroy(source) + @ccall libsc.sc_io_source_destroy(source::Ptr{sc_io_source_t})::Cint end """ - t8_vec_axpy(vec_x, vec_y, alpha) + sc_io_source_destroy_null(source) -Y = Y + alpha * X +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 -* `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. +* `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 -static inline void t8_vec_axpy (const double vec_x[3], double vec_y[3], const double alpha); +int sc_io_source_destroy_null (sc_io_source_t ** source); ``` """ -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 sc_io_source_destroy_null(source) + @ccall libsc.sc_io_source_destroy_null(source::Ptr{Ptr{sc_io_source_t}})::Cint end """ - t8_vec_axpyz(vec_x, vec_y, vec_z, alpha) + sc_io_source_read(source, data, bytes_avail, bytes_out) -Z = Y + alpha * X +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 -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -* `vec_z`:\\[out\\] On output set *to* vec\\_y + *alpha* * *vec_x* +* `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 -static inline void t8_vec_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], const double alpha); +int sc_io_source_read (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); ``` """ -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 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 """ - t8_vec_dot(vec_x, vec_y) + sc_io_source_complete(source, bytes_in, bytes_out) -Dot product of X and Y. +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 -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. +* `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 -The dot product *vec_x* * *vec_y* +SC\\_IO\\_ERROR\\_AGAIN if buffered data remaining. Otherwise return ERROR\\_NONE and reset counters. ### Prototype ```c -static inline double t8_vec_dot (const double vec_x[3], const double vec_y[3]); +int sc_io_source_complete (sc_io_source_t * source, size_t *bytes_in, size_t *bytes_out); ``` """ -function t8_vec_dot(vec_x, vec_y) - @ccall libt8.t8_vec_dot(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +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 """ - t8_vec_cross(vec_x, vec_y, cross) + sc_io_source_align(source, bytes_align) -Cross product of X and Y +Align source to a byte boundary by skipping. # 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*. +* `source`:\\[in,out\\] The source object to align. +* `bytes_align`:\\[in\\] Byte boundary. +# Returns +0 on success, nonzero on error. ### Prototype ```c -static inline void t8_vec_cross (const double vec_x[3], const double vec_y[3], double cross[3]); +int sc_io_source_align (sc_io_source_t * source, size_t bytes_align); ``` """ -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 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 """ - t8_vec_diff(vec_x, vec_y, diff) + sc_io_source_activate_mirror(source) -Compute the difference of two vectors. +Activate a buffer that mirrors (i.e., stores) the data that was read. # 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*. +* `source`:\\[in,out\\] The source object to activate mirror in. +# Returns +0 on success, nonzero on error. ### Prototype ```c -static inline void t8_vec_diff (const double vec_x[3], const double vec_y[3], double diff[3]); +int sc_io_source_activate_mirror (sc_io_source_t * source); ``` """ -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 sc_io_source_activate_mirror(source) + @ccall libsc.sc_io_source_activate_mirror(source::Ptr{sc_io_source_t})::Cint end """ - t8_vec_eq(vec_x, vec_y, tol) + sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) -Check the equality of two vectors elementwise +Read data from the source's mirror. Same behaviour as [`sc_io_source_read`](@ref). # Arguments -* `vec_x`:\\[in\\] -* `vec_y`:\\[in\\] -* `tol`:\\[in\\] +* `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 -true, if the vectors are equal up to *tol* +0 on success, nonzero on error. ### Prototype ```c -static inline int t8_vec_eq (const double vec_x[3], const double vec_y[3], const double tol); +int sc_io_source_read_mirror (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); ``` """ -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 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 """ - t8_vec_rescale(vec, new_length) + sc_io_file_save(filename, buffer) -Rescale a vector to a new length. +Save a buffer to a file in one call. This function performs error checking and always returns cleanly. # Arguments -* `vec`:\\[in,out\\] A 3D vector. -* `new_length`:\\[in\\] New length of the vector. +* `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 -static inline void t8_vec_rescale (double vec[3], const double new_length); +int sc_io_file_save (const char *filename, sc_array_t * buffer); ``` """ -function t8_vec_rescale(vec, new_length) - @ccall libt8.t8_vec_rescale(vec::Ptr{Cdouble}, new_length::Cdouble)::Cvoid +function sc_io_file_save(filename, buffer) + @ccall libsc.sc_io_file_save(filename::Cstring, buffer::Ptr{sc_array_t})::Cint end """ - t8_vec_tri_normal(p1, p2, p3, normal) + sc_io_file_load(filename, buffer) -Compute the normal of a triangle given by its three vertices. +Read a file into a buffer in one call. This function performs error checking and always returns cleanly. # 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!) +* `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 -static inline void t8_vec_tri_normal (const double p1[3], const double p2[3], const double p3[3], double normal[3]); +int sc_io_file_load (const char *filename, sc_array_t * buffer); ``` """ -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 sc_io_file_load(filename, buffer) + @ccall libsc.sc_io_file_load(filename::Cstring, buffer::Ptr{sc_array_t})::Cint end """ - t8_vec_swap(p1, p2) + sc_io_encode(data, out) -Swap the components of two vectors. +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 -* `p1`:\\[in,out\\] A 3D vector. -* `p2`:\\[in,out\\] A 3D vector. +* `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 -static inline void t8_vec_swap (double p1[3], double p2[3]); +void sc_io_encode (sc_array_t *data, sc_array_t *out); ``` """ -function t8_vec_swap(p1, p2) - @ccall libt8.t8_vec_swap(p1::Ptr{Cdouble}, p2::Ptr{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 -# no prototype is found for this function at t8_version.h:70:1, please use with caution """ - t8_get_package_string() + sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) -Return the package string of t8code. This string has the format "t8 version\\_number". +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. -# Returns -The version string of t8code. +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 -const char* t8_get_package_string (); +void sc_io_encode_zlib (sc_array_t *data, sc_array_t *out, int zlib_compression_level, int line_break_character); ``` """ -function t8_get_package_string() - @ccall libt8.t8_get_package_string()::Cstring +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 -# no prototype is found for this function at t8_version.h:76:1, please use with caution """ - t8_get_version_number() + sc_io_decode_info(data, original_size, format_char, re) -Return the version number of t8code as a string. +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 -The version number of t8code as a string. +0 on success, negative value on error. ### Prototype ```c -const char* t8_get_version_number (); +int sc_io_decode_info (sc_array_t *data, size_t *original_size, char *format_char, void *re); ``` """ -function t8_get_version_number() - @ccall libt8.t8_get_version_number()::Cstring +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 -# no prototype is found for this function at t8_version.h:82:1, please use with caution """ - t8_get_version_point_string() + sc_io_decode(data, out, max_original_size, re) -Return the version point string. +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 -The version point point string. +0 on success, negative on malformed input data or insufficient output space. ### Prototype ```c -const char* t8_get_version_point_string (); +int sc_io_decode (sc_array_t *data, sc_array_t *out, size_t max_original_size, void *re); ``` """ -function t8_get_version_point_string() - @ccall libt8.t8_get_version_point_string()::Cstring +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 -# no prototype is found for this function at t8_version.h:88:1, please use with caution """ - t8_get_version_major() + sc_vtk_write_binary(vtkfile, numeric_data, byte_length) -Return the major version number of t8code. +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 -The major version number of t8code. +Returns 0 on success, -1 on file error. ### Prototype ```c -int t8_get_version_major (); +int sc_vtk_write_binary (FILE * vtkfile, char *numeric_data, size_t byte_length); ``` """ -function t8_get_version_major() - @ccall libt8.t8_get_version_major()::Cint +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 -# no prototype is found for this function at t8_version.h:94:1, please use with caution """ - t8_get_version_minor() + sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) -Return the minor version number of t8code. +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 -The minor version number of t8code. +Returns 0 on success, -1 on file error. ### Prototype ```c -int t8_get_version_minor (); +int sc_vtk_write_compressed (FILE * vtkfile, char *numeric_data, size_t byte_length); ``` """ -function t8_get_version_minor() - @ccall libt8.t8_get_version_minor()::Cint +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 -# 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 + sc_fopen(filename, mode, errmsg) +Wrapper for fopen(3). We provide an additional argument that contains the error message. -# Returns -The patch version unmber of t8code. negative on error. ### Prototype ```c -int t8_get_version_patch (); +FILE *sc_fopen (const char *filename, const char *mode, const char *errmsg); ``` """ -function t8_get_version_patch() - @ccall libt8.t8_get_version_patch()::Cint +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`. +### 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`. +### 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::MPI_Datatype, 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::MPI_Datatype, 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::MPI_Datatype, 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::MPI_Datatype, 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`, 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 +end + +""" + p4est_connectivity_is_valid(connectivity) + +Examine a connectivity structure. + +# Returns +Returns true if structure is valid, false otherwise. +### Prototype +```c +int p4est_connectivity_is_valid (p4est_connectivity_t * connectivity); +``` +""" +function p4est_connectivity_is_valid(connectivity) + @ccall libp4est.p4est_connectivity_is_valid(connectivity::Ptr{p4est_connectivity_t})::Cint +end + +""" + p4est_connectivity_is_equal(conn1, conn2) + +Check two connectivity structures for equality. + +# Returns +Returns true if structures are equal, false otherwise. +### Prototype +```c +int p4est_connectivity_is_equal (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); +``` +""" +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 + +""" + 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 +int p4est_connectivity_sink (p4est_connectivity_t * conn, sc_io_sink_t * sink); +``` +""" +function p4est_connectivity_sink(conn, sink) + @ccall libp4est.p4est_connectivity_sink(conn::Ptr{p4est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint +end + +""" + 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 +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 + +""" + 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 +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 + +""" + 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 +p4est_connectivity_t *p4est_connectivity_source (sc_io_source_t * source); +``` +""" +function p4est_connectivity_source(source) + @ccall libp4est.p4est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p4est_connectivity_t} +end + +""" + 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 +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 + +""" + 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 +p4est_connectivity_t *p4est_connectivity_load (const char *filename, size_t *bytes); +``` +""" +function p4est_connectivity_load(filename, bytes) + @ccall libp4est.p4est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p4est_connectivity_t} +end + +""" + p4est_connectivity_new_unitsquare() + +Create a connectivity structure for the unit square. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_unitsquare (void); +``` +""" +function p4est_connectivity_new_unitsquare() + @ccall libp4est.p4est_connectivity_new_unitsquare()::Ptr{p4est_connectivity_t} +end + +""" + p4est_connectivity_new_periodic() + +Create a connectivity structure for an all-periodic unit square. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_periodic (void); +``` +""" +function p4est_connectivity_new_periodic() + @ccall libp4est.p4est_connectivity_new_periodic()::Ptr{p4est_connectivity_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. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_rotwrap (void); +``` +""" +function p4est_connectivity_new_rotwrap() + @ccall libp4est.p4est_connectivity_new_rotwrap()::Ptr{p4est_connectivity_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. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_circle (void); +``` +""" +function p4est_connectivity_new_circle() + @ccall libp4est.p4est_connectivity_new_circle()::Ptr{p4est_connectivity_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. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_drop (void); +``` +""" +function p4est_connectivity_new_drop() + @ccall libp4est.p4est_connectivity_new_drop()::Ptr{p4est_connectivity_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 + +# 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); +``` +""" +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 + +""" + p4est_connectivity_new_corner() + +Create a connectivity structure for a three-tree mesh around a corner. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_corner (void); +``` +""" +function p4est_connectivity_new_corner() + @ccall libp4est.p4est_connectivity_new_corner()::Ptr{p4est_connectivity_t} end -@cenum t8_vtk_data_type_t::UInt32 begin - T8_VTK_SCALAR = 0 - T8_VTK_VECTOR = 1 +""" + p4est_connectivity_new_pillow() + +Create a connectivity structure for two trees on top of each other. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_pillow (void); +``` +""" +function p4est_connectivity_new_pillow() + @ccall libp4est.p4est_connectivity_new_pillow()::Ptr{p4est_connectivity_t} end """ - t8_vtk_data_field_t + p4est_connectivity_new_moebius() -| Field | Note | -| :---------- | :----------------------------------------- | -| type | Describes of which type the data array is | -| description | String that describes the data. | +Create a connectivity structure for a five-tree moebius band. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_moebius (void); +``` """ -struct t8_vtk_data_field_t - type::t8_vtk_data_type_t - description::NTuple{8192, Cchar} - data::Ptr{Cdouble} +function p4est_connectivity_new_moebius() + @ccall libp4est.p4est_connectivity_new_moebius()::Ptr{p4est_connectivity_t} end """ - t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) + p4est_connectivity_new_star() + +Create a connectivity structure for a six-tree star. ### 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); +p4est_connectivity_t *p4est_connectivity_new_star (void); ``` """ -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 p4est_connectivity_new_star() + @ccall libp4est.p4est_connectivity_new_star()::Ptr{p4est_connectivity_t} end """ - sc_io_read(mpifile, ptr, zcount, t, errmsg) + 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 -void sc_io_read (sc_MPI_File mpifile, void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); +p4est_connectivity_t *p4est_connectivity_new_cubed (void); ``` """ -function sc_io_read(mpifile, ptr, zcount, t, errmsg) - @ccall libsc.sc_io_read(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::MPI_Datatype, errmsg::Cstring)::Cvoid +function p4est_connectivity_new_cubed() + @ccall libp4est.p4est_connectivity_new_cubed()::Ptr{p4est_connectivity_t} end """ - sc_io_write(mpifile, ptr, zcount, t, errmsg) + 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 -void sc_io_write (sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); +p4est_connectivity_t *p4est_connectivity_new_disk_nonperiodic (void); ``` """ -function sc_io_write(mpifile, ptr, zcount, t, errmsg) - @ccall libsc.sc_io_write(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::MPI_Datatype, errmsg::Cstring)::Cvoid +function p4est_connectivity_new_disk_nonperiodic() + @ccall libp4est.p4est_connectivity_new_disk_nonperiodic()::Ptr{p4est_connectivity_t} end -"""Typedef for quadrant coordinates.""" -const p4est_qcoord_t = Int32 +""" + p4est_connectivity_new_disk(periodic_a, periodic_b) -"""Typedef for counting topological entities (trees, tree vertices).""" -const p4est_topidx_t = Int32 +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. -"""Typedef for processor-local indexing of quadrants and nodes.""" -const p4est_locidx_t = Int32 +!!! note -"""Typedef for globally unique indexing of quadrants.""" -const p4est_gloidx_t = Int64 + 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 +p4est_connectivity_t *p4est_connectivity_new_disk (int periodic_a, int periodic_b); +``` """ - sc_io_error_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 -Error values for io. +""" + p4est_connectivity_new_icosahedron() -| 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. | +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 +p4est_connectivity_t *p4est_connectivity_new_icosahedron (void); +``` """ -@cenum sc_io_error_t::Int32 begin - SC_IO_ERROR_NONE = 0 - SC_IO_ERROR_FATAL = -1 - SC_IO_ERROR_AGAIN = -2 +function p4est_connectivity_new_icosahedron() + @ccall libp4est.p4est_connectivity_new_icosahedron()::Ptr{p4est_connectivity_t} end """ - sc_io_mode_t + p4est_connectivity_new_shell2d() -The I/O mode for writing using sc_io_sink. +Create a connectivity structure that builds a 2d spherical shell. p8est_connectivity_new_shell -| 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 +p4est_connectivity_t *p4est_connectivity_new_shell2d (void); +``` """ -@cenum sc_io_mode_t::UInt32 begin - SC_IO_MODE_WRITE = 0 - SC_IO_MODE_APPEND = 1 - SC_IO_MODE_LAST = 2 +function p4est_connectivity_new_shell2d() + @ccall libp4est.p4est_connectivity_new_shell2d()::Ptr{p4est_connectivity_t} end """ - sc_io_encode_t + p4est_connectivity_new_disk2d() -Enum to specify encoding for sc_io_sink and sc_io_source. +Create a connectivity structure that maps a 2d disk. -| Enumerator | Note | -| :---------------------- | :--------------------------- | -| SC\\_IO\\_ENCODE\\_NONE | No encoding | -| SC\\_IO\\_ENCODE\\_LAST | Invalid entry to close list | +This is a 5 trees connectivity meant to be used together with p4est_geometry_new_disk2d to map the disk. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_disk2d (void); +``` """ -@cenum sc_io_encode_t::UInt32 begin - SC_IO_ENCODE_NONE = 0 - SC_IO_ENCODE_LAST = 1 +function p4est_connectivity_new_disk2d() + @ccall libp4est.p4est_connectivity_new_disk2d()::Ptr{p4est_connectivity_t} end """ - sc_io_type_t + p4est_connectivity_new_bowtie() -The type of I/O operation sc_io_sink and sc_io_source. +Create a connectivity structure that maps a 2d bowtie structure. -| 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 | +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 +p4est_connectivity_t *p4est_connectivity_new_bowtie (void); +``` """ -@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 p4est_connectivity_new_bowtie() + @ccall libp4est.p4est_connectivity_new_bowtie()::Ptr{p4est_connectivity_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. + +### Prototype +```c +p4est_connectivity_t *p4est_connectivity_new_brick (int mi, int ni, int periodic_a, int periodic_b); +``` +""" +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 + +""" + 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 +p4est_connectivity_t *p4est_connectivity_new_byname (const char *name); +``` +""" +function p4est_connectivity_new_byname(name) + @ccall libp4est.p4est_connectivity_new_byname(name::Cstring)::Ptr{p4est_connectivity_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. + +# 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); +``` +""" +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 """ - sc_io_sink + p4est_expand_face_transform(iface, nface, ftransform) -A generic data sink. +Fill an array with the axis combination of a face neighbor transform. -| 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 +* `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[]); +``` """ -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 p4est_expand_face_transform(iface, nface, ftransform) + @ccall libp4est.p4est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid end -"""A generic data sink.""" -const sc_io_sink_t = sc_io_sink - """ - sc_io_source + p4est_find_face_transform(connectivity, itree, iface, ftransform) -A generic data source. +Fill an array with the axis combinations of a tree neighbor transform. -| 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 | +# 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 +p4est_topidx_t p4est_find_face_transform (p4est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); +``` """ -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 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 -"""A generic data source.""" -const sc_io_source_t = sc_io_source - """ - sc_io_open_mode_t + p4est_find_corner_transform(connectivity, itree, icorner, ci) -Open modes for sc_io_open +Fills an array with information about corner neighbors. -| 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 | +# 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` 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); +``` """ -@cenum sc_io_open_mode_t::UInt32 begin - SC_IO_READ = 0 - SC_IO_WRITE_CREATE = 1 - SC_IO_WRITE_APPEND = 2 +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 -# 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) + p4est_connectivity_complete(conn) -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. +Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. # Arguments -* `sink`:\\[in,out\\] The sink object to complete and free. -# Returns -0 on success, nonzero on error. +* `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 -int sc_io_sink_destroy (sc_io_sink_t * sink); +void p4est_connectivity_complete (p4est_connectivity_t * conn); ``` """ -function sc_io_sink_destroy(sink) - @ccall libsc.sc_io_sink_destroy(sink::Ptr{sc_io_sink_t})::Cint +function p4est_connectivity_complete(conn) + @ccall libp4est.p4est_connectivity_complete(conn::Ptr{p4est_connectivity_t})::Cvoid end """ - sc_io_sink_destroy_null(sink) + p4est_connectivity_reduce(conn) -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. +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 -* `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. +* `conn`:\\[in,out\\] The connectivity to be reduced. ### Prototype ```c -int sc_io_sink_destroy_null (sc_io_sink_t ** sink); +void p4est_connectivity_reduce (p4est_connectivity_t * conn); ``` """ -function sc_io_sink_destroy_null(sink) - @ccall libsc.sc_io_sink_destroy_null(sink::Ptr{Ptr{sc_io_sink_t}})::Cint +function p4est_connectivity_reduce(conn) + @ccall libp4est.p4est_connectivity_reduce(conn::Ptr{p4est_connectivity_t})::Cvoid end """ - sc_io_sink_write(sink, data, bytes_avail) + p4est_connectivity_permute(conn, perm, is_current_to_new) -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. +[`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 -* `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. +* `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 sc_io_sink_write (sc_io_sink_t * sink, const void *data, size_t bytes_avail); +void p4est_connectivity_permute (p4est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); ``` """ -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 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 """ - sc_io_sink_complete(sink, bytes_in, bytes_out) + p4est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) -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. +[`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 -* `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. +* `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 -int sc_io_sink_complete (sc_io_sink_t * sink, size_t *bytes_in, size_t *bytes_out); +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 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 +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 """ - sc_io_sink_align(sink, bytes_align) + p4est_connectivity_is_equivalent(conn1, conn2) -Align sink to a byte boundary by writing zeros. +[`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 -* `sink`:\\[in,out\\] The sink object to align. -* `bytes_align`:\\[in\\] Byte boundary. -# Returns -0 on success, nonzero on error. +* `conn1`:\\[in\\] a valid connectivity +* `conn2`:\\[out\\] a valid connectivity ### Prototype ```c -int sc_io_sink_align (sc_io_sink_t * sink, size_t bytes_align); +int p4est_connectivity_is_equivalent (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); ``` """ -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 p4est_connectivity_is_equivalent(conn1, conn2) + @ccall libp4est.p4est_connectivity_is_equivalent(conn1::Ptr{p4est_connectivity_t}, conn2::Ptr{p4est_connectivity_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. + p4est_corner_array_index(array, it) -# 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); +static inline p4est_corner_transform_t * p4est_corner_array_index (sc_array_t * array, size_t it); ``` """ -function sc_io_source_destroy(source) - @ccall libsc.sc_io_source_destroy(source::Ptr{sc_io_source_t})::Cint +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 """ - sc_io_source_destroy_null(source) + p4est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) -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. +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, 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 -* `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. +* `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 on success, nonzero on error. +0 if successful and nonzero if not ### Prototype ```c -int sc_io_source_destroy_null (sc_io_source_t ** source); +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 sc_io_source_destroy_null(source) - @ccall libsc.sc_io_source_destroy_null(source::Ptr{Ptr{sc_io_source_t}})::Cint +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 """ - sc_io_source_read(source, data, bytes_avail, bytes_out) + p4est_connectivity_read_inp(filename) -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. +Create a p4est connectivity from an ABAQUS input file. -# 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 +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. -""" - sc_io_source_complete(source, bytes_in, bytes_out) +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: -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. +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, 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 -* `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. +* `filename`:\\[in\\] file to read the connectivity from # Returns -SC\\_IO\\_ERROR\\_AGAIN if buffered data remaining. Otherwise return ERROR\\_NONE and reset counters. +an allocated connectivity associated with the mesh in *filename* or NULL if an error occurred. ### Prototype ```c -int sc_io_source_complete (sc_io_source_t * source, size_t *bytes_in, size_t *bytes_out); +p4est_connectivity_t *p4est_connectivity_read_inp (const char *filename); ``` """ -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 p4est_connectivity_read_inp(filename) + @ccall libp4est.p4est_connectivity_read_inp(filename::Cstring)::Ptr{p4est_connectivity_t} end """ - sc_io_source_align(source, bytes_align) + p8est_connect_type_t -Align source to a byte boundary by skipping. +Characterize a type of adjacency. -# 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); -``` +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. + +| 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. | """ -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 +@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 """ - sc_io_source_activate_mirror(source) + p8est_connectivity_encode_t -Activate a buffer that mirrors (i.e., stores) the data that was read. +Typedef for serialization method. -# 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); -``` +| Enumerator | Note | +| :--------------------------- | :-------------------------------- | +| P8EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | """ -function sc_io_source_activate_mirror(source) - @ccall libsc.sc_io_source_activate_mirror(source::Ptr{sc_io_source_t})::Cint +@cenum p8est_connectivity_encode_t::UInt32 begin + P8EST_CONN_ENCODE_NONE = 0 + P8EST_CONN_ENCODE_LAST = 1 end """ - sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) + p8est_connect_type_int(btype) -Read data from the source's mirror. Same behaviour as [`sc_io_source_read`](@ref). +Convert the [`p8est_connect_type_t`](@ref) into a number. # 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. +* `btype`:\\[in\\] The balance type to convert. # Returns -0 on success, nonzero on error. +Returns 1, 2 or 3. ### Prototype ```c -int sc_io_source_read_mirror (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); +int p8est_connect_type_int (p8est_connect_type_t btype); ``` """ -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 p8est_connect_type_int(btype) + @ccall libp4est.p8est_connect_type_int(btype::p8est_connect_type_t)::Cint end """ - sc_io_file_save(filename, buffer) + p8est_connect_type_string(btype) -Save a buffer to a file in one call. This function performs error checking and always returns cleanly. +Convert the [`p8est_connect_type_t`](@ref) into a const string. # 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. +* `btype`:\\[in\\] The balance type to convert. # Returns -0 on success, -1 on error. +Returns a pointer to a constant string. ### Prototype ```c -int sc_io_file_save (const char *filename, sc_array_t * buffer); +const char *p8est_connect_type_string (p8est_connect_type_t btype); ``` """ -function sc_io_file_save(filename, buffer) - @ccall libsc.sc_io_file_save(filename::Cstring, buffer::Ptr{sc_array_t})::Cint +function p8est_connect_type_string(btype) + @ccall libp4est.p8est_connect_type_string(btype::p8est_connect_type_t)::Cstring end """ - sc_io_file_load(filename, buffer) + p8est_connectivity -Read a file into a buffer in one call. This function performs error checking and always returns cleanly. +This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible. -# 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); -``` +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 sc_io_file_load(filename, buffer) - @ccall libsc.sc_io_file_load(filename::Cstring, buffer::Ptr{sc_array_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 """ - sc_io_encode(data, out) +This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible. -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. +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]. -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 *\\_to\\_attr arrays may have arbitrary contents defined by the user. -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. +!!! note -# 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); -``` + 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 sc_io_encode(data, out) - @ccall libsc.sc_io_encode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t})::Cvoid -end +const p8est_connectivity_t = p8est_connectivity """ - 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. + p8est_connectivity_memory_used(conn) -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. +Calculate memory usage of a connectivity structure. # 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 ''. +* `conn`:\\[in\\] Connectivity structure. +# Returns +Memory used in bytes. ### Prototype ```c -void sc_io_encode_zlib (sc_array_t *data, sc_array_t *out, int zlib_compression_level, int line_break_character); +size_t p8est_connectivity_memory_used (p8est_connectivity_t * conn); ``` """ -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 p8est_connectivity_memory_used(conn) + @ccall libp4est.p8est_connectivity_memory_used(conn::Ptr{p8est_connectivity_t})::Csize_t 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. + p8est_edge_transform_t -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. +Generic interface for transformations between a tree and any of its edge -# 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); -``` +| 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 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 +struct p8est_edge_transform_t + ntree::p4est_topidx_t + nedge::Int8 + naxis::NTuple{3, Int8} + nflip::Int8 + corners::Int8 end """ - sc_io_decode(data, out, max_original_size, re) + p8est_edge_info_t -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. +Information about the neighbors of an edge -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. +| Field | Note | +| :---------------- | :---------------------------------------------- | +| iedge | The information of the edge | +| edge\\_transforms | The array of neighbors of the originating edge | +""" +struct p8est_edge_info_t + iedge::Int8 + edge_transforms::sc_array_t +end -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. +""" + p8est_corner_transform_t -Any error condition is indicated by a negative return value. Possible causes for error are: +Generic interface for transformations between a tree and any of its corner -- 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 +| Field | Note | +| :------ | :------------------------ | +| ntree | The number of the tree | +| ncorner | The number of the corner | +""" +struct p8est_corner_transform_t + ntree::p4est_topidx_t + ncorner::Int8 +end -We also error out if the data requires a compression dictionary, which would be a violation of above encode format specification. +""" + p8est_corner_info_t -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. +Information about the neighbors of a corner -# 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); -``` +| Field | Note | +| :------------------ | :------------------------------------------------ | +| icorner | The number of the originating corner | +| corner\\_transforms | The array of neighbors of the originating corner | """ -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 +struct p8est_corner_info_t + icorner::p4est_topidx_t + corner_transforms::sc_array_t end """ - sc_vtk_write_binary(vtkfile, numeric_data, byte_length) + p8est_neighbor_transform_t -This function writes numeric binary data in VTK base64 encoding. +Generic interface for transformations between a tree and any of its neighbors -# 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 | +| :---------------- | :-------------------------------------------------------------------------- | +| 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 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 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 """ - sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) + p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) -This function writes numeric binary data in VTK compressed format. +Transform from self's coordinate system to neighbor's coordinate system. # 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. +* `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_vtk_write_compressed (FILE * vtkfile, char *numeric_data, size_t byte_length); +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 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 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 """ - sc_fopen(filename, mode, errmsg) + p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) -Wrapper for fopen(3). We provide an additional argument that contains the error message. +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 -FILE *sc_fopen (const char *filename, const char *mode, const char *errmsg); +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 sc_fopen(filename, mode, errmsg) - @ccall libsc.sc_fopen(filename::Cstring, mode::Cstring, errmsg::Cstring)::Ptr{Libc.FILE} +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 """ - sc_fwrite(ptr, size, nmemb, file, errmsg) - -Write memory content to a file. - -!!! note + p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) - This function aborts on file errors. +Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects # 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`. +* `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 sc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); +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 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 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 """ - sc_fread(ptr, size, nmemb, file, errmsg) - -Read file content into memory. - -!!! note + p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) - This function aborts on file errors. +Transform a corner across one of the adjacent faces into a neighbor tree. It expects a face permutation index that has been precomputed. # 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`. +* `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 sc_fread (void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); +int p8est_connectivity_face_neighbor_corner_set (int c, int f, int nf, int set); ``` """ -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 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 """ - sc_fflush_fsync_fclose(file) + p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) -Best effort to flush a file's data to disc and close it. +Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. # Arguments -* `file`:\\[in,out\\] File open for writing. +* `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 sc_fflush_fsync_fclose (FILE * file); +int p8est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); ``` """ -function sc_fflush_fsync_fclose(file) - @ccall libsc.sc_fflush_fsync_fclose(file::Ptr{Libc.FILE})::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 """ - sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) + p8est_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..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 sc_io_open (sc_MPI_Comm mpicomm, const char *filename, sc_io_open_mode_t amode, sc_MPI_Info mpiinfo, sc_MPI_File * mpifile); +int p8est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); ``` """ -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 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 """ - sc_io_read_at(mpifile, offset, ptr, count, t, ocount) + 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 -int sc_io_read_at (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); +int p8est_connectivity_face_neighbor_face_edge (int fe, int f, int nf, int o); ``` """ -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::MPI_Datatype, ocount::Ptr{Cint})::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 """ - sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) + 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 -int sc_io_read_at_all (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); +int p8est_connectivity_face_neighbor_edge (int e, int f, int nf, int o); ``` """ -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::MPI_Datatype, ocount::Ptr{Cint})::Cint +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 """ - sc_io_write_at(mpifile, offset, ptr, count, t, ocount) + p8est_connectivity_edge_neighbor_edge_corner(ec, o) + +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 sc_io_write_at (sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount); +int p8est_connectivity_edge_neighbor_edge_corner (int ec, int o); ``` """ -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::MPI_Datatype, ocount::Ptr{Cint})::Cint +function p8est_connectivity_edge_neighbor_edge_corner(ec, o) + @ccall libp4est.p8est_connectivity_edge_neighbor_edge_corner(ec::Cint, o::Cint)::Cint end """ - sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) + 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 -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); +int p8est_connectivity_edge_neighbor_corner (int c, int e, int ne, int o); ``` """ -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::MPI_Datatype, ocount::Ptr{Cint})::Cint +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 """ - sc_io_close(file) + 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 -int sc_io_close (sc_MPI_File * file); +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 sc_io_close(file) - @ccall libsc.sc_io_close(file::Ptr{Cint})::Cint +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 """ - 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 + p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) -""" - p4est_log_indent_push() +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 -static inline void p4est_log_indent_push (void); +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 p4est_log_indent_push() - @ccall libp4est.p4est_log_indent_push()::Cvoid +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 """ - p4est_log_indent_pop() + p8est_connectivity_bcast(conn_in, root, comm) ### Prototype ```c -static inline void p4est_log_indent_pop (void); +p8est_connectivity_t *p8est_connectivity_bcast (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); ``` """ -function p4est_log_indent_pop() - @ccall libp4est.p4est_log_indent_pop()::Cvoid +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 """ - p4est_init(log_handler, log_threshold) + p8est_connectivity_destroy(connectivity) -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`, the default SC log threshold will be used. The default SC log settings can be changed with [`sc_set_log_defaults`](@ref) (). +Destroy a connectivity structure. Also destroy all attributes. ### Prototype ```c -void p4est_init (sc_log_handler_t log_handler, int log_threshold); +void p8est_connectivity_destroy (p8est_connectivity_t * connectivity); ``` """ -function p4est_init(log_handler, log_threshold) - @ccall libp4est.p4est_init(log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid +function p8est_connectivity_destroy(connectivity) + @ccall libp4est.p8est_connectivity_destroy(connectivity::Ptr{p8est_connectivity_t})::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. + p8est_connectivity_set_attr(conn, bytes_per_tree) -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. +Allocate or free the attribute fields in a connectivity. -# Returns -True if p4est has been initialized with a call to p4est_init and false otherwise. +# 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 -int p4est_is_initialized (void); +void p8est_connectivity_set_attr (p8est_connectivity_t * conn, size_t bytes_per_tree); ``` """ -function p4est_is_initialized() - @ccall libp4est.p4est_is_initialized()::Cint +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 """ - p4est_have_zlib() + p8est_connectivity_is_valid(connectivity) -Check for a sufficiently recent zlib installation. +Examine a connectivity structure. # Returns -True if zlib is detected in both sc and p4est. +Returns true if structure is valid, false otherwise. ### Prototype ```c -int p4est_have_zlib (void); +int p8est_connectivity_is_valid (p8est_connectivity_t * connectivity); ``` """ -function p4est_have_zlib() - @ccall libp4est.p4est_have_zlib()::Cint +function p8est_connectivity_is_valid(connectivity) + @ccall libp4est.p8est_connectivity_is_valid(connectivity::Ptr{p8est_connectivity_t})::Cint end """ - p4est_get_package_id() + p8est_connectivity_is_equal(conn1, conn2) -Query the package identity as registered in libsc. +Check two connectivity structures for equality. # Returns -This is -1 before p4est_init has been called and a proper package identifier (>= 0) afterwards. +Returns true if structures are equal, false otherwise. ### Prototype ```c -int p4est_get_package_id (void); +int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); ``` """ -function p4est_get_package_id() - @ccall libp4est.p4est_get_package_id()::Cint +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 """ - 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 + p8est_connectivity_sink(conn, sink) -""" - p4est_topidx_hash3(tt) +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 -static inline unsigned p4est_topidx_hash3 (const p4est_topidx_t * tt); +int p8est_connectivity_sink (p8est_connectivity_t * conn, sc_io_sink_t * sink); ``` """ -function p4est_topidx_hash3(tt) - @ccall libp4est.p4est_topidx_hash3(tt::Ptr{p4est_topidx_t})::Cuint +function p8est_connectivity_sink(conn, sink) + @ccall libp4est.p8est_connectivity_sink(conn::Ptr{p8est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint end """ - p4est_topidx_hash4(tt) + 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 -static inline unsigned p4est_topidx_hash4 (const p4est_topidx_t * tt); +sc_array_t *p8est_connectivity_deflate (p8est_connectivity_t * conn, p8est_connectivity_encode_t code); ``` """ -function p4est_topidx_hash4(tt) - @ccall libp4est.p4est_topidx_hash4(tt::Ptr{p4est_topidx_t})::Cuint +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 """ - p4est_topidx_is_sorted(t, length) + p8est_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 -static inline int p4est_topidx_is_sorted (p4est_topidx_t * t, int length); +int p8est_connectivity_save (const char *filename, p8est_connectivity_t * connectivity); ``` """ -function p4est_topidx_is_sorted(t, length) - @ccall libp4est.p4est_topidx_is_sorted(t::Ptr{p4est_topidx_t}, length::Cint)::Cint +function p8est_connectivity_save(filename, connectivity) + @ccall libp4est.p8est_connectivity_save(filename::Cstring, connectivity::Ptr{p8est_connectivity_t})::Cint end """ - p4est_topidx_bsort(t, length) + p8est_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 -static inline void p4est_topidx_bsort (p4est_topidx_t * t, int length); +p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source); ``` """ -function p4est_topidx_bsort(t, length) - @ccall libp4est.p4est_topidx_bsort(t::Ptr{p4est_topidx_t}, length::Cint)::Cvoid +function p8est_connectivity_source(source) + @ccall libp4est.p8est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p8est_connectivity_t} end """ - p4est_partition_cut_uint64(global_num, p, num_procs) + p8est_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 -static inline uint64_t p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs); +p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer); ``` """ -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 p8est_connectivity_inflate(buffer) + @ccall libp4est.p8est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p8est_connectivity_t} end """ - p4est_partition_cut_gloidx(global_num, p, num_procs) + p8est_connectivity_load(filename, bytes) + +Load a connectivity structure from disk. +# 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 -static inline p4est_gloidx_t p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs); +p8est_connectivity_t *p8est_connectivity_load (const char *filename, size_t *bytes); ``` """ -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 p8est_connectivity_load(filename, bytes) + @ccall libp4est.p8est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p8est_connectivity_t} end """ - p4est_version() + p8est_connectivity_new_unitcube() -Return the full version of p4est. +Create a connectivity structure for the unit cube. -# 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); +p8est_connectivity_t *p8est_connectivity_new_unitcube (void); ``` """ -function p4est_version() - @ccall libp4est.p4est_version()::Cstring +function p8est_connectivity_new_unitcube() + @ccall libp4est.p8est_connectivity_new_unitcube()::Ptr{p8est_connectivity_t} end """ - p4est_version_major() + p8est_connectivity_new_periodic() -Return the major version of p4est. +Create a connectivity structure for an all-periodic unit cube. -# Returns -Return the major version of p4est. ### Prototype ```c -int p4est_version_major (void); +p8est_connectivity_t *p8est_connectivity_new_periodic (void); ``` """ -function p4est_version_major() - @ccall libp4est.p4est_version_major()::Cint +function p8est_connectivity_new_periodic() + @ccall libp4est.p8est_connectivity_new_periodic()::Ptr{p8est_connectivity_t} end """ - p4est_version_minor() + p8est_connectivity_new_rotwrap() -Return the minor version of p4est. +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. -# Returns -Return the minor version of p4est. ### Prototype ```c -int p4est_version_minor (void); +p8est_connectivity_t *p8est_connectivity_new_rotwrap (void); ``` """ -function p4est_version_minor() - @ccall libp4est.p4est_version_minor()::Cint +function p8est_connectivity_new_rotwrap() + @ccall libp4est.p8est_connectivity_new_rotwrap()::Ptr{p8est_connectivity_t} end """ - p4est_connect_type_t - -Characterize a type of adjacency. + p8est_connectivity_new_drop() -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. +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. -| 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. | +### Prototype +```c +p8est_connectivity_t *p8est_connectivity_new_drop (void); +``` """ -@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 p8est_connectivity_new_drop() + @ccall libp4est.p8est_connectivity_new_drop()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_encode_t + p8est_connectivity_new_twocubes() -Typedef for serialization method. +Create a connectivity structure that contains two cubes. -| Enumerator | Note | -| :--------------------------- | :-------------------------------- | -| P4EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | +### Prototype +```c +p8est_connectivity_t *p8est_connectivity_new_twocubes (void); +``` """ -@cenum p4est_connectivity_encode_t::UInt32 begin - P4EST_CONN_ENCODE_NONE = 0 - P4EST_CONN_ENCODE_LAST = 1 +function p8est_connectivity_new_twocubes() + @ccall libp4est.p8est_connectivity_new_twocubes()::Ptr{p8est_connectivity_t} end """ - p4est_connect_type_int(btype) + p8est_connectivity_new_twotrees(l_face, r_face, orientation) -Convert the [`p4est_connect_type_t`](@ref) into a number. +Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way. # Arguments -* `btype`:\\[in\\] The balance type to convert. -# Returns -Returns 1 or 2. +* `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 -int p4est_connect_type_int (p4est_connect_type_t btype); +p8est_connectivity_t *p8est_connectivity_new_twotrees (int l_face, int r_face, int orientation); ``` """ -function p4est_connect_type_int(btype) - @ccall libp4est.p4est_connect_type_int(btype::p4est_connect_type_t)::Cint +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 """ - p4est_connect_type_string(btype) + p8est_connectivity_new_twowrap() -Convert the [`p4est_connect_type_t`](@ref) into a const string. +Create a connectivity structure that contains two cubes where the two far ends are identified periodically. -# 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); +p8est_connectivity_t *p8est_connectivity_new_twowrap (void); ``` """ -function p4est_connect_type_string(btype) - @ccall libp4est.p4est_connect_type_string(btype::p4est_connect_type_t)::Cstring +function p8est_connectivity_new_twowrap() + @ccall libp4est.p8est_connectivity_new_twowrap()::Ptr{p8est_connectivity_t} 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 + p8est_connectivity_new_rotcubes() - 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. +Create a connectivity structure that contains a few cubes. These are rotated against each other to stress the topology routines. -| 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 | +### Prototype +```c +p8est_connectivity_t *p8est_connectivity_new_rotcubes (void); +``` """ -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 p8est_connectivity_new_rotcubes() + @ccall libp4est.p8est_connectivity_new_rotcubes()::Ptr{p8est_connectivity_t} 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. + p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) -!!! note +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. - 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. +### Prototype +```c +p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c); +``` """ -const p4est_connectivity_t = p4est_connectivity +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 """ - p4est_connectivity_memory_used(conn) + p8est_connectivity_new_shell() -Calculate memory usage of a connectivity structure. +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 -* `conn`:\\[in\\] Connectivity structure. -# Returns -Memory used in bytes. ### Prototype ```c -size_t p4est_connectivity_memory_used (p4est_connectivity_t * conn); +p8est_connectivity_t *p8est_connectivity_new_shell (void); ``` """ -function p4est_connectivity_memory_used(conn) - @ccall libp4est.p4est_connectivity_memory_used(conn::Ptr{p4est_connectivity_t})::Csize_t +function p8est_connectivity_new_shell() + @ccall libp4est.p8est_connectivity_new_shell()::Ptr{p8est_connectivity_t} end """ - p4est_corner_transform_t + p8est_connectivity_new_sphere() -Generic interface for transformations between a tree and any of its corner +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). -| Field | Note | -| :------ | :------------------------ | -| ntree | The number of the tree | -| ncorner | The number of the corner | +### Prototype +```c +p8est_connectivity_t *p8est_connectivity_new_sphere (void); +``` """ -struct p4est_corner_transform_t - ntree::p4est_topidx_t - ncorner::Int8 +function p8est_connectivity_new_sphere() + @ccall libp4est.p8est_connectivity_new_sphere()::Ptr{p8est_connectivity_t} end """ - p4est_corner_info_t + p8est_connectivity_new_torus(nSegments) -Information about the neighbors of a corner +Create a connectivity structure that builds a revolution torus. -| Field | Note | -| :------------------ | :------------------------------------------------ | -| icorner | The number of the originating corner | -| corner\\_transforms | The array of neighbors of the originating corner | +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 +* `nSegments`:\\[in\\] number of trees along the great circle +### Prototype +```c +p8est_connectivity_t *p8est_connectivity_new_torus (int nSegments); +``` """ -struct p4est_corner_info_t - icorner::p4est_topidx_t - corner_transforms::sc_array_t +function p8est_connectivity_new_torus(nSegments) + @ccall libp4est.p8est_connectivity_new_torus(nSegments::Cint)::Ptr{p8est_connectivity_t} end """ - p4est_neighbor_transform_t + p8est_connectivity_new_byname(name) -Generic interface for transformations between a tree and any of its neighbors +Create connectivity structure from predefined catalogue. -| 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 +* `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. +### Prototype +```c +p8est_connectivity_t *p8est_connectivity_new_byname (const char *name); +``` """ -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 p8est_connectivity_new_byname(name) + @ccall libp4est.p8est_connectivity_new_byname(name::Cstring)::Ptr{p8est_connectivity_t} end """ - p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + p8est_connectivity_refine(conn, num_per_dim) -Transform from self's coordinate system to neighbor's coordinate system. +Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `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 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]); +p8est_connectivity_t *p8est_connectivity_refine (p8est_connectivity_t * conn, int num_per_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 +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 """ - p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + p8est_expand_face_transform(iface, nface, ftransform) -Transform from neighbor's coordinate system to self's coordinate system. +Fill an array with the axis combination of a face neighbor transform. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `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 -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]); +void p8est_expand_face_transform (int iface, int nface, int ftransform[]); ``` """ -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 p8est_expand_face_transform(iface, nface, ftransform) + @ccall libp4est.p8est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid end """ - p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + p8est_find_face_transform(connectivity, itree, iface, ftransform) -Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects +Fill an array with the axis combination of a face neighbor transform. # 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. +* `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). + ### 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); +p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); ``` """ -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 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 """ - p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + p8est_find_edge_transform(connectivity, itree, iedge, ei) -Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Fills an array with information about edge neighbors. # 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. +* `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` structure with initialized array. ### Prototype ```c -int p4est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); +void p8est_find_edge_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t * ei); ``` """ -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 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 """ - p4est_connectivity_face_neighbor_corner(c, f, nf, o) + p8est_find_corner_transform(connectivity, itree, icorner, ci) -Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Fills an array with information about corner neighbors. # 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. +* `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` structure with initialized array. ### Prototype ```c -int p4est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); +void p8est_find_corner_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t * ci); ``` """ -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 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 """ - p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) + p8est_connectivity_complete(conn) -Allocate a connectivity structure. The attribute fields are initialized to NULL. +Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. # 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. +* `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 -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); +void p8est_connectivity_complete (p8est_connectivity_t * conn); ``` """ -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 p8est_connectivity_complete(conn) + @ccall libp4est.p8est_connectivity_complete(conn::Ptr{p8est_connectivity_t})::Cvoid end """ - p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) + p8est_connectivity_reduce(conn) -Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. +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 -* `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. +* `conn`:\\[in,out\\] The connectivity to be reduced. ### 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); +void p8est_connectivity_reduce (p8est_connectivity_t * conn); ``` """ -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 p8est_connectivity_reduce(conn) + @ccall libp4est.p8est_connectivity_reduce(conn::Ptr{p8est_connectivity_t})::Cvoid end """ - p4est_connectivity_bcast(conn_in, root, comm) + 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 -p4est_connectivity_t *p4est_connectivity_bcast (p4est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +void p8est_connectivity_permute (p8est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); ``` """ -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 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 """ - p4est_connectivity_destroy(connectivity) + p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) -Destroy a connectivity structure. Also destroy all attributes. +[`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 -void p4est_connectivity_destroy (p4est_connectivity_t * connectivity); +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 p4est_connectivity_destroy(connectivity) - @ccall libp4est.p4est_connectivity_destroy(connectivity::Ptr{p4est_connectivity_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_set_attr(conn, bytes_per_tree) + p8est_connectivity_is_equivalent(conn1, conn2) -Allocate or free the attribute fields in a connectivity. +[`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 -* `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. +* `conn1`:\\[in\\] a valid connectivity +* `conn2`:\\[out\\] a valid connectivity ### Prototype ```c -void p4est_connectivity_set_attr (p4est_connectivity_t * conn, size_t bytes_per_tree); +int p8est_connectivity_is_equivalent (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); ``` """ -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_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_valid(connectivity) - -Examine a connectivity structure. + p8est_edge_array_index(array, it) -# Returns -Returns true if structure is valid, false otherwise. ### Prototype ```c -int p4est_connectivity_is_valid (p4est_connectivity_t * connectivity); +static inline p8est_edge_transform_t * p8est_edge_array_index (sc_array_t * array, size_t it); ``` """ -function p4est_connectivity_is_valid(connectivity) - @ccall libp4est.p4est_connectivity_is_valid(connectivity::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_is_equal(conn1, conn2) - -Check two connectivity structures for equality. + p8est_corner_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_corner_transform_t * p8est_corner_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_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_sink(conn, sink) + p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) -Write connectivity to a sink object. +Read an ABAQUS input file from a file stream. -# 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); -``` -""" -function p4est_connectivity_sink(conn, sink) - @ccall libp4est.p4est_connectivity_sink(conn::Ptr{p4est_connectivity_t}, sink::Ptr{sc_io_sink_t})::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. -""" - p4est_connectivity_deflate(conn, code) +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: -Allocate memory and store the connectivity information there. +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 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 -* `conn`:\\[in\\] The connectivity structure to be exported to memory. -* `code`:\\[in\\] Encoding and compression method for serialization. +* `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 -Newly created array that contains the information. +0 if successful and nonzero if not ### Prototype ```c -sc_array_t *p4est_connectivity_deflate (p4est_connectivity_t * conn, p4est_connectivity_encode_t code); +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_deflate(conn, code) - @ccall libp4est.p4est_connectivity_deflate(conn::Ptr{p4est_connectivity_t}, code::p4est_connectivity_encode_t)::Ptr{sc_array_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_save(filename, connectivity) + p8est_connectivity_read_inp(filename) -Save a connectivity structure to disk. +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 +``` + +This function reads a mesh from *filename* and returns an associated p4est connectivity. # Arguments -* `filename`:\\[in\\] Name of the file to write. -* `connectivity`:\\[in\\] Valid connectivity structure. +* `filename`:\\[in\\] file to read the connectivity from # Returns -Returns 0 on success, nonzero on file error. +an allocated connectivity associated with the mesh in *filename* ### Prototype ```c -int p4est_connectivity_save (const char *filename, p4est_connectivity_t * connectivity); +p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename); ``` """ -function p4est_connectivity_save(filename, connectivity) - @ccall libp4est.p4est_connectivity_save(filename::Cstring, connectivity::Ptr{p4est_connectivity_t})::Cint +function p8est_connectivity_read_inp(filename) + @ccall libp4est.p8est_connectivity_read_inp(filename::Cstring)::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_source(source) - -Read connectivity from a source object. + t8_cmesh_new_from_p4est(conn, comm, do_partition) -# Arguments -* `source`:\\[in,out\\] The connectivity is read from this source. -# Returns -The newly created connectivity, or NULL on error. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_source (sc_io_source_t * source); +t8_cmesh_t t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); ``` """ -function p4est_connectivity_source(source) - @ccall libp4est.p4est_connectivity_source(source::Ptr{sc_io_source_t})::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_inflate(buffer) - -Create new connectivity from a memory buffer. This function aborts on malloc errors. + t8_cmesh_new_from_p8est(conn, comm, do_partition) -# 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); +t8_cmesh_t t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); ``` """ -function p4est_connectivity_inflate(buffer) - @ccall libp4est.p4est_connectivity_inflate(buffer::Ptr{sc_array_t})::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_load(filename, bytes) - -Load a connectivity structure from disk. + t8_cmesh_new_empty(comm, do_partition, dimension) -# 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 -p4est_connectivity_t *p4est_connectivity_load (const char *filename, size_t *bytes); +t8_cmesh_t t8_cmesh_new_empty (sc_MPI_Comm comm, const int do_partition, const int dimension); ``` """ -function p4est_connectivity_load(filename, bytes) - @ccall libp4est.p4est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::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_unitsquare() - -Create a connectivity structure for the unit square. + t8_cmesh_new_from_class(eclass, comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_unitsquare (void); +t8_cmesh_t t8_cmesh_new_from_class (t8_eclass_t eclass, sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_unitsquare() - @ccall libp4est.p4est_connectivity_new_unitsquare()::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_periodic() - -Create a connectivity structure for an all-periodic unit square. + t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_periodic (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_periodic() - @ccall libp4est.p4est_connectivity_new_periodic()::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_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_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_rotwrap (void); +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_rotwrap() - @ccall libp4est.p4est_connectivity_new_rotwrap()::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_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_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_circle (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_circle() - @ccall libp4est.p4est_connectivity_new_circle()::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_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_hybrid(comm, do_partition, periodic) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_drop (void); +t8_cmesh_t t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, 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_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_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_periodic(comm, dim) -# 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_periodic (sc_MPI_Comm comm, int dim); ``` """ -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_periodic(comm, dim) + @ccall libt8.t8_cmesh_new_periodic(comm::MPI_Comm, dim::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_corner() - -Create a connectivity structure for a three-tree mesh around a corner. + t8_cmesh_new_periodic_tri(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_corner (void); +t8_cmesh_t t8_cmesh_new_periodic_tri (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_corner() - @ccall libp4est.p4est_connectivity_new_corner()::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_pillow() - -Create a connectivity structure for two trees on top of each other. + t8_cmesh_new_periodic_hybrid(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_pillow (void); +t8_cmesh_t t8_cmesh_new_periodic_hybrid (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_pillow() - @ccall libp4est.p4est_connectivity_new_pillow()::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_moebius() - -Create a connectivity structure for a five-tree moebius band. + t8_cmesh_new_periodic_line_more_trees(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_moebius (void); +t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_moebius() - @ccall libp4est.p4est_connectivity_new_moebius()::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_star() - -Create a connectivity structure for a six-tree star. + t8_cmesh_new_bigmesh(eclass, num_trees, comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_star (void); +t8_cmesh_t t8_cmesh_new_bigmesh (t8_eclass_t eclass, int num_trees, sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_star() - @ccall libp4est.p4est_connectivity_new_star()::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_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_line_zigzag(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_cubed (void); +t8_cmesh_t t8_cmesh_new_line_zigzag (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_cubed() - @ccall libp4est.p4est_connectivity_new_cubed()::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_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_prism_cake(comm, num_of_prisms) -# Returns -Initialized and usable connectivity. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk_nonperiodic (void); +t8_cmesh_t t8_cmesh_new_prism_cake (sc_MPI_Comm comm, int num_of_prisms); ``` """ -function p4est_connectivity_new_disk_nonperiodic() - @ccall libp4est.p4est_connectivity_new_disk_nonperiodic()::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_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_prism_deformed(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_prism_deformed (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_prism_deformed(comm) + @ccall libt8.t8_cmesh_new_prism_deformed(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_pyramid_deformed(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_icosahedron (void); +t8_cmesh_t t8_cmesh_new_pyramid_deformed (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_icosahedron() - @ccall libp4est.p4est_connectivity_new_icosahedron()::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_shell2d() - -Create a connectivity structure that builds a 2d spherical shell. p8est_connectivity_new_shell + t8_cmesh_new_prism_cake_funny_oriented(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_shell2d (void); +t8_cmesh_t t8_cmesh_new_prism_cake_funny_oriented (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_shell2d() - @ccall libp4est.p4est_connectivity_new_shell2d()::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_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_geometry(comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk2d (void); +t8_cmesh_t t8_cmesh_new_prism_geometry (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_new_disk2d() - @ccall libp4est.p4est_connectivity_new_disk2d()::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_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_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_bowtie (void); +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_new_bowtie() - @ccall libp4est.p4est_connectivity_new_bowtie()::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_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_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, 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_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_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_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_connectivity_new_byname(name) - -Create connectivity structure from predefined catalogue. + t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, 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_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 p4est_connectivity_new_byname(name) - @ccall libp4est.p4est_connectivity_new_byname(name::Cstring)::Ptr{p4est_connectivity_t} +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 """ - 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_tet_orientation_test(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_tet_orientation_test (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_tet_orientation_test(comm) + @ccall libt8.t8_cmesh_new_tet_orientation_test(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_hybrid_gate(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_hybrid_gate (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_hybrid_gate(comm) + @ccall libt8.t8_cmesh_new_hybrid_gate(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. - -# 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). + t8_cmesh_new_hybrid_gate_deformed(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_hybrid_gate_deformed (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_hybrid_gate_deformed(comm) + @ccall libt8.t8_cmesh_new_hybrid_gate_deformed(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_full_hybrid(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` 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_full_hybrid (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_full_hybrid(comm) + @ccall libt8.t8_cmesh_new_full_hybrid(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_pyramid_cake(comm, num_of_pyra) -# 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_pyramid_cake (sc_MPI_Comm comm, int num_of_pyra); ``` """ -function p4est_connectivity_complete(conn) - @ccall libp4est.p4est_connectivity_complete(conn::Ptr{p4est_connectivity_t})::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_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_long_brick_pyramid(comm, num_cubes) -# 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_long_brick_pyramid (sc_MPI_Comm comm, int num_cubes); ``` """ -function p4est_connectivity_reduce(conn) - @ccall libp4est.p4est_connectivity_reduce(conn::Ptr{p4est_connectivity_t})::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_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_row_of_cubes(num_trees, set_attributes, do_partition, comm) -# 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_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, const int do_partition, sc_MPI_Comm comm); ``` """ -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_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 """ - 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_quadrangulated_disk(radius, comm) -# 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_quadrangulated_disk (const double radius, sc_MPI_Comm comm); ``` """ -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_quadrangulated_disk(radius, comm) + @ccall libt8.t8_cmesh_new_quadrangulated_disk(radius::Cdouble, comm::MPI_Comm)::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_triangulated_spherical_surface_octahedron(radius, comm) -# 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_triangulated_spherical_surface_octahedron (const double radius, sc_MPI_Comm comm); ``` """ -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_triangulated_spherical_surface_octahedron(radius, comm) + @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_octahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - p4est_corner_array_index(array, it) + t8_cmesh_new_triangulated_spherical_surface_icosahedron(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_triangulated_spherical_surface_icosahedron (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_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_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, 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`. + t8_cmesh_new_triangulated_spherical_surface_cube(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_cube (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_cube(radius, comm) + @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_cube(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_quadrangulated_spherical_surface(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_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm); ``` +""" +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 -This function reads a mesh from *filename* and returns an associated p4est connectivity. +""" + t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, 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_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 p4est_connectivity_read_inp(filename) - @ccall libp4est.p4est_connectivity_read_inp(filename::Cstring)::Ptr{p4est_connectivity_t} +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_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_icosahedron(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_icosahedron (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_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_connectivity_encode_t - -Typedef for serialization method. + t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) -| Enumerator | Note | -| :--------------------------- | :-------------------------------- | -| P8EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | +### 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); +``` """ -@cenum p8est_connectivity_encode_t::UInt32 begin - P8EST_CONN_ENCODE_NONE = 0 - P8EST_CONN_ENCODE_LAST = 1 +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_int(btype) - -Convert the [`p8est_connect_type_t`](@ref) into a number. + t8_cmesh_new_cubed_sphere(radius, 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_sphere (const double radius, 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_sphere(radius, comm) + @ccall libt8.t8_cmesh_new_cubed_sphere(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - p8est_connect_type_string(btype) + t8_cmesh_get_tree_geom_hash(cmesh, gtreeid) -Convert the [`p8est_connect_type_t`](@ref) into a const string. +Get the hash of the geometry stored for a tree in a cmesh. # Arguments -* `btype`:\\[in\\] The balance type to convert. +* `cmesh`:\\[in\\] A committed cmesh. +* `gtreeid`:\\[in\\] A global tree in *cmesh*. # Returns -Returns a pointer to a constant string. +The hash of the tree's geometry or if only one geometry exists, its hash. ### Prototype ```c -const char *p8est_connect_type_string (p8est_connect_type_t btype); +size_t t8_cmesh_get_tree_geom_hash (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); ``` """ -function p8est_connect_type_string(btype) - @ccall libp4est.p8est_connect_type_string(btype::p8est_connect_type_t)::Cstring +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 """ - p8est_connectivity - -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_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) -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. +Sets the face connectivity information of an un-committed based on a list of tree vertices. -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]. +!!! warning -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. + 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\\] 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); +``` """ -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_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 """ -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_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) -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. +Sets the face connectivity information of an un-committed based on the cmesh stash. -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]. +!!! warning -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. + 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. + +# 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); +``` """ -const p8est_connectivity_t = p8est_connectivity +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 """ - p8est_connectivity_memory_used(conn) + t8_offset_first(proc, offset) -Calculate memory usage of a connectivity structure. +Return the global id of the first local tree of a given process in a partition. # Arguments -* `conn`:\\[in\\] Connectivity structure. +* `proc`:\\[in\\] The rank of the process. +* `offset`:\\[in\\] The partition table. # Returns -Memory used in bytes. +The global id of the first local tree of *proc* in the partition *offset*. ### Prototype ```c -size_t p8est_connectivity_memory_used (p8est_connectivity_t * conn); +t8_gloidx_t t8_offset_first (const int proc, const t8_gloidx_t *offset); ``` """ -function p8est_connectivity_memory_used(conn) - @ccall libp4est.p8est_connectivity_memory_used(conn::Ptr{p8est_connectivity_t})::Csize_t +function t8_offset_first(proc, offset) + @ccall libt8.t8_offset_first(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t end """ - p8est_edge_transform_t + t8_offset_first_tree_to_entry(first_tree, shared) -Generic interface for transformations between a tree and any of its edge +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. -| 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 +* `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); +``` """ -struct p8est_edge_transform_t - ntree::p4est_topidx_t - nedge::Int8 - naxis::NTuple{3, Int8} - nflip::Int8 - corners::Int8 +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 """ - p8est_edge_info_t + t8_offset_num_trees(proc, offset) -Information about the neighbors of an edge +The number of trees of a given process in a partition. -| Field | Note | -| :---------------- | :---------------------------------------------- | -| iedge | The information of the edge | -| edge\\_transforms | The array of neighbors of the originating edge | +# 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); +``` """ -struct p8est_edge_info_t - iedge::Int8 - edge_transforms::sc_array_t +function t8_offset_num_trees(proc, offset) + @ccall libt8.t8_offset_num_trees(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t end """ - p8est_corner_transform_t + t8_offset_last(proc, offset) -Generic interface for transformations between a tree and any of its corner +Return the last local tree of a given process in a partition. -| Field | Note | -| :------ | :------------------------ | -| ntree | The number of the tree | -| ncorner | The number of the corner | +# 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); +``` """ -struct p8est_corner_transform_t - ntree::p4est_topidx_t - ncorner::Int8 +function t8_offset_last(proc, offset) + @ccall libt8.t8_offset_last(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t end """ - p8est_corner_info_t + t8_offset_empty(proc, offset) -Information about the neighbors of a corner +Check whether a given process has no local trees in a given partition. -| Field | Note | -| :------------------ | :------------------------------------------------ | -| icorner | The number of the originating corner | -| corner\\_transforms | The array of neighbors of the originating corner | +# 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); +``` """ -struct p8est_corner_info_t - icorner::p4est_topidx_t - corner_transforms::sc_array_t +function t8_offset_empty(proc, offset) + @ccall libt8.t8_offset_empty(proc::Cint, offset::Ptr{t8_gloidx_t})::Cint end """ - p8est_neighbor_transform_t + t8_offset_next_nonempty_rank(rank, mpisize, offset) -Generic interface for transformations between a tree and any of its neighbors +Find the next higher rank that is not empty. returns mpisize if this rank does not exist. -| 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 +* `proc`:\\[in\\] An MPI rank. +* `mpisize`:\\[in\\] The number of total MPI ranks. +* `offset`:\\[in\\] An array with at least *mpisize* + 1 entries. +# 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); +``` """ -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_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 """ - p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + t8_offset_in_range(tree_id, proc, offset) -Transform from self's coordinate system to neighbor's coordinate system. +Determine whether a given global tree id is a local tree of a given process in a certain partition. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `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 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]); +int t8_offset_in_range (const t8_gloidx_t tree_id, const int proc, const t8_gloidx_t *offset); ``` """ -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_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 """ - p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + t8_offset_any_owner_of_tree(mpisize, gtree, offset) -Transform from neighbor's coordinate system to self's coordinate system. +Find any process that has a given tree as local tree. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `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 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]); +int t8_offset_any_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset); ``` """ -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_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 """ - p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + t8_offset_any_owner_of_tree_ext(mpisize, start_proc, gtree, offset) -Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects +Find any process that has a given tree as local tree. # 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. +* `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 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); +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 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_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 """ - p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) + t8_offset_first_owner_of_tree(mpisize, gtree, offset, some_owner) -Transform a corner across one of the adjacent faces into a neighbor tree. It expects a face permutation index that has been precomputed. +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 -* `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]; +* `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 corner number in 0..7 seen from the other face. +The smallest rank that has *gtree* as a local tree. ### Prototype ```c -int p8est_connectivity_face_neighbor_corner_set (int c, int f, int nf, int set); +int t8_offset_first_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner); ``` """ -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_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 """ - p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + t8_offset_last_owner_of_tree(mpisize, gtree, offset, some_owner) -Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +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 -* `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*. +* `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 face corner number relative to the neighbor's face. +The biggest rank that has *gtree* as a local tree. ### Prototype ```c -int p8est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); +int t8_offset_last_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner); ``` """ -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_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 """ - p8est_connectivity_face_neighbor_corner(c, f, nf, o) + t8_offset_next_owner_of_tree(mpisize, gtree, offset, current_owner) -Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +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 -* `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*. +* `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 number of the corner seen from the neighbor tree. +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 p8est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); +int t8_offset_next_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int current_owner); ``` """ -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_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 """ - p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) + t8_offset_prev_owner_of_tree(mpisize, gtree, offset, current_owner) -Transform a face-edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +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 -* `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*. +* `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 face edge number seen from the neighbor tree. +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 -int p8est_connectivity_face_neighbor_face_edge (int fe, int f, int nf, int o); +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 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_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 """ - p8est_connectivity_face_neighbor_edge(e, f, nf, o) + t8_offset_all_owners_of_tree(mpisize, gtree, offset, owners) -Transform an edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Compute a list of all processes that own a specific tree.n *offset* minus 1. # 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. +* `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 -int p8est_connectivity_face_neighbor_edge (int e, int f, int nf, int o); +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 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_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 """ - p8est_connectivity_edge_neighbor_edge_corner(ec, o) + t8_offset_nosend(proc, mpisize, offset_from, offset_to) -Transform an edge corner across one of the adjacent edges into a neighbor tree. +Query whether in a repartition setting a given process does send any of its local trees to any other process (including itself) # Arguments -* `ec`:\\[in\\] An edge corner number in 0..1. -* `o`:\\[in\\] The orientation of a tree boundary edge connection. +* `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 -The edge corner number seen from the other tree. +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 -int p8est_connectivity_edge_neighbor_edge_corner (int ec, int o); +int t8_offset_nosend (int proc, int mpisize, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); ``` """ -function p8est_connectivity_edge_neighbor_edge_corner(ec, o) - @ccall libp4est.p8est_connectivity_edge_neighbor_edge_corner(ec::Cint, o::Cint)::Cint +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 """ - p8est_connectivity_edge_neighbor_corner(c, e, ne, o) + t8_offset_sendsto(proca, procb, t8_offset_from, t8_offset_to) -Transform a corner across one of the adjacent edges into a neighbor tree. This version expects the neighbor edge and orientation separately. +Query whether in a repartitioning setting, a given process sends local trees (and then possibly ghosts) to a given other process. # 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*. +* `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 -Corner number seen from the neighbor. +nonzero if *proca* does send local trees to *procb* when we repartition from *offset_from* to *offset_to*. 0 else. ### Prototype ```c -int p8est_connectivity_edge_neighbor_corner (int c, int e, int ne, int o); +int t8_offset_sendsto (int proca, int procb, const t8_gloidx_t *t8_offset_from, const t8_gloidx_t *t8_offset_to); ``` """ -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_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 """ - p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) + t8_offset_sendstree(proc_send, proc_to, gtree, offset_from, offset_to) -Allocate a connectivity structure. The attribute fields are initialized to NULL. +Query whether in a repartitioning setting, a given process sends a given tree to a second process. # 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. +* `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 -A connectivity structure with allocated arrays. +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 -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); +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 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_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 """ - 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_offset_range_send(start, _end, mpirank, offset_from, offset_to) -Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. +Count the number of processes in a given range [a,b] that send to a given other process in a repartitioning setting. # 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. +* `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 connectivity is checked for validity. +The number of processes p, such that *start* <= p <= *end* and p does send local trees (and possibly ghosts) to *mpirank*. ### 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); +int t8_offset_range_send (int start, int end, int mpirank, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); ``` """ -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_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 """ - p8est_connectivity_bcast(conn_in, root, comm) + t8_offset_print(offset, comm) ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_bcast (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +void t8_offset_print (t8_shmem_array_t offset, sc_MPI_Comm comm); ``` """ -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_offset_print(offset, comm) + @ccall libt8.t8_offset_print(offset::t8_shmem_array_t, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_destroy(connectivity) - -Destroy a connectivity structure. Also destroy all attributes. + t8_cmesh_partition(cmesh, comm) ### Prototype ```c -void p8est_connectivity_destroy (p8est_connectivity_t * connectivity); +void t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_destroy(connectivity) - @ccall libp4est.p8est_connectivity_destroy(connectivity::Ptr{p8est_connectivity_t})::Cvoid +function t8_cmesh_partition(cmesh, comm) + @ccall libt8.t8_cmesh_partition(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_set_attr(conn, bytes_per_tree) - -Allocate or free the attribute fields in a connectivity. + t8_cmesh_gather_trees_per_eclass(cmesh, comm) -# 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); +void t8_cmesh_gather_trees_per_eclass (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -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_cmesh_gather_trees_per_eclass(cmesh, comm) + @ccall libt8.t8_cmesh_gather_trees_per_eclass(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_is_valid(connectivity) - -Examine a connectivity structure. + t8_cmesh_gather_treecount(cmesh, comm) -# Returns -Returns true if structure is valid, false otherwise. ### Prototype ```c -int p8est_connectivity_is_valid (p8est_connectivity_t * connectivity); +void t8_cmesh_gather_treecount (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_is_valid(connectivity) - @ccall libp4est.p8est_connectivity_is_valid(connectivity::Ptr{p8est_connectivity_t})::Cint +function t8_cmesh_gather_treecount(cmesh, comm) + @ccall libt8.t8_cmesh_gather_treecount(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_is_equal(conn1, conn2) - -Check two connectivity structures for equality. + t8_cmesh_gather_treecount_nocommit(cmesh, comm) -# Returns -Returns true if structures are equal, false otherwise. ### Prototype ```c -int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); +void t8_cmesh_gather_treecount_nocommit (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -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_cmesh_gather_treecount_nocommit(cmesh, comm) + @ccall libt8.t8_cmesh_gather_treecount_nocommit(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_sink(conn, sink) - -Write connectivity to a sink object. + t8_cmesh_offset_print(cmesh, comm) -# 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 p8est_connectivity_sink (p8est_connectivity_t * conn, sc_io_sink_t * sink); +void t8_cmesh_offset_print (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -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_cmesh_offset_print(cmesh, comm) + @ccall libt8.t8_cmesh_offset_print(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_deflate(conn, code) + t8_cmesh_offset_concentrate(proc, comm, num_trees) -Allocate memory and store the connectivity information there. +### Prototype +```c +t8_shmem_array_t t8_cmesh_offset_concentrate (int proc, sc_MPI_Comm comm, t8_gloidx_t num_trees); +``` +""" +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_cmesh_offset_random(comm, num_trees, shared, seed) -# 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); +t8_shmem_array_t t8_cmesh_offset_random (sc_MPI_Comm comm, t8_gloidx_t num_trees, int shared, unsigned seed); ``` """ -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_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 """ - p8est_connectivity_save(filename, connectivity) + t8_cmesh_offset_half(cmesh, comm) -Save a connectivity structure to disk. +### Prototype +```c +t8_shmem_array_t t8_cmesh_offset_half (t8_cmesh_t cmesh, sc_MPI_Comm comm); +``` +""" +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_cmesh_offset_percent(cmesh, comm, percent) -# 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); +t8_shmem_array_t t8_cmesh_offset_percent (t8_cmesh_t cmesh, sc_MPI_Comm comm, int percent); ``` """ -function p8est_connectivity_save(filename, connectivity) - @ccall libp4est.p8est_connectivity_save(filename::Cstring, connectivity::Ptr{p8est_connectivity_t})::Cint +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 """ - p8est_connectivity_source(source) + t8_stash_class -Read connectivity from a source object. +The eclass information that is stored before a cmesh is committed. + +| Field | Note | +| :----- | :----------------------- | +| id | The global tree id | +| eclass | The eclass of that tree | +""" +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_stash_attribute + +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 -* `source`:\\[in,out\\] The connectivity is read from this source. -# Returns -The newly created connectivity, or NULL on error. +* `pstash`:\\[in,out\\] A pointer to the stash to be initialized. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source); +void t8_stash_init (t8_stash_t *pstash); ``` """ -function p8est_connectivity_source(source) - @ccall libp4est.p8est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p8est_connectivity_t} +function t8_stash_init(pstash) + @ccall libt8.t8_stash_init(pstash::Ptr{t8_stash_t})::Cvoid end """ - p8est_connectivity_inflate(buffer) + t8_stash_destroy(pstash) -Create new connectivity from a memory buffer. This function aborts on malloc errors. +Free all memory associated in a stash structure. -# 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. +# Arguments +* `pstash`:\\[in,out\\] A pointer to the stash to be destroyed. The pointer is set to NULL after the function call. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer); +void t8_stash_destroy (t8_stash_t *pstash); ``` """ -function p8est_connectivity_inflate(buffer) - @ccall libp4est.p8est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p8est_connectivity_t} +function t8_stash_destroy(pstash) + @ccall libt8.t8_stash_destroy(pstash::Ptr{t8_stash_t})::Cvoid end """ - p8est_connectivity_load(filename, bytes) + t8_stash_add_class(stash, id, eclass) -Load a connectivity structure from disk. +Set the eclass of a tree. # 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. +* `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 -p8est_connectivity_t *p8est_connectivity_load (const char *filename, size_t *bytes); +void t8_stash_add_class (t8_stash_t stash, t8_gloidx_t id, t8_eclass_t eclass); ``` """ -function p8est_connectivity_load(filename, bytes) - @ccall libp4est.p8est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p8est_connectivity_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 """ - p8est_connectivity_new_unitcube() + t8_stash_add_facejoin(stash, gid1, gid2, face1, face2, orientation) -Create a connectivity structure for the unit cube. +Add a face connection to a stash. +# 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. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_unitcube (void); +void t8_stash_add_facejoin (t8_stash_t stash, t8_gloidx_t gid1, t8_gloidx_t gid2, int face1, int face2, int orientation); ``` """ -function p8est_connectivity_new_unitcube() - @ccall libp4est.p8est_connectivity_new_unitcube()::Ptr{p8est_connectivity_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 """ - p8est_connectivity_new_periodic() + t8_stash_class_sort(stash) -Create a connectivity structure for an all-periodic unit cube. +Sort the entries in the class array by the order given in the enum definition of [`t8_eclass`](@ref). +# Arguments +* `stash`:\\[in,out\\] The stash whose class array is sorted. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_periodic (void); +void t8_stash_class_sort (t8_stash_t stash); ``` """ -function p8est_connectivity_new_periodic() - @ccall libp4est.p8est_connectivity_new_periodic()::Ptr{p8est_connectivity_t} +function t8_stash_class_sort(stash) + @ccall libt8.t8_stash_class_sort(stash::t8_stash_t)::Cvoid end """ - p8est_connectivity_new_rotwrap() + t8_stash_class_bsearch(stash, tree_id) -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. +Search for an entry with a given tree index in the class-stash. The stash must be sorted beforehand. +# Arguments +* `stash`:\\[in\\] The stash to be searched for. +* `tree_id`:\\[in\\] The global tree id. +# Returns +The index of an element in the classes array of *stash* corresponding to *tree_id*. -1 if not found. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_rotwrap (void); +ssize_t t8_stash_class_bsearch (t8_stash_t stash, t8_gloidx_t tree_id); ``` """ -function p8est_connectivity_new_rotwrap() - @ccall libp4est.p8est_connectivity_new_rotwrap()::Ptr{p8est_connectivity_t} +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 """ - p8est_connectivity_new_drop() + t8_stash_joinface_sort(stash) -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. +Sort then entries in the facejoin array in order of the first treeid. +# Arguments +* `stash`:\\[in,out\\] The stash whose facejoin array is sorted. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_drop (void); +void t8_stash_joinface_sort (t8_stash_t stash); ``` """ -function p8est_connectivity_new_drop() - @ccall libp4est.p8est_connectivity_new_drop()::Ptr{p8est_connectivity_t} +function t8_stash_joinface_sort(stash) + @ccall libt8.t8_stash_joinface_sort(stash::t8_stash_t)::Cvoid end """ - p8est_connectivity_new_twocubes() + t8_stash_add_attribute(stash, id, package_id, key, size, attr, copy) -Create a connectivity structure that contains two cubes. +Add an attribute to a tree. +# 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). ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twocubes (void); +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 p8est_connectivity_new_twocubes() - @ccall libp4est.p8est_connectivity_new_twocubes()::Ptr{p8est_connectivity_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 """ - p8est_connectivity_new_twotrees(l_face, r_face, orientation) + t8_stash_get_attribute_size(stash, index) -Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way. +Return the size (in bytes) of an attribute in the stash. # 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 +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +# Returns +The size in bytes of the attribute. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twotrees (int l_face, int r_face, int orientation); +size_t t8_stash_get_attribute_size (t8_stash_t stash, size_t index); ``` """ -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_stash_get_attribute_size(stash, index) + @ccall libt8.t8_stash_get_attribute_size(stash::t8_stash_t, index::Csize_t)::Csize_t end """ - p8est_connectivity_new_twowrap() + t8_stash_get_attribute(stash, index) -Create a connectivity structure that contains two cubes where the two far ends are identified periodically. +Return the pointer to an attribute in the stash. +# Arguments +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +# Returns +A void pointer to the memory region where the attribute is stored. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twowrap (void); +void * t8_stash_get_attribute (t8_stash_t stash, size_t index); ``` """ -function p8est_connectivity_new_twowrap() - @ccall libp4est.p8est_connectivity_new_twowrap()::Ptr{p8est_connectivity_t} +function t8_stash_get_attribute(stash, index) + @ccall libt8.t8_stash_get_attribute(stash::t8_stash_t, index::Csize_t)::Ptr{Cvoid} end """ - p8est_connectivity_new_rotcubes() + t8_stash_get_attribute_tree_id(stash, index) -Create a connectivity structure that contains a few cubes. These are rotated against each other to stress the topology routines. +Return the id of the tree a given attribute belongs to. +# Arguments +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +# Returns +The tree id. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_rotcubes (void); +t8_gloidx_t t8_stash_get_attribute_tree_id (t8_stash_t stash, size_t index); ``` """ -function p8est_connectivity_new_rotcubes() - @ccall libp4est.p8est_connectivity_new_rotcubes()::Ptr{p8est_connectivity_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 """ - p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) + t8_stash_get_attribute_key(stash, index) -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. +Return the key of a given attribute. +# Arguments +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +# Returns +The attribute's key. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c); +int t8_stash_get_attribute_key (t8_stash_t stash, size_t index); ``` """ -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_stash_get_attribute_key(stash, index) + @ccall libt8.t8_stash_get_attribute_key(stash::t8_stash_t, index::Csize_t)::Cint end """ - p8est_connectivity_new_shell() + t8_stash_get_attribute_id(stash, index) -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). +Return the package\\_id of a given attribute. +# Arguments +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +# Returns +The attribute's package\\_id. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_shell (void); +int t8_stash_get_attribute_id (t8_stash_t stash, size_t index); ``` """ -function p8est_connectivity_new_shell() - @ccall libp4est.p8est_connectivity_new_shell()::Ptr{p8est_connectivity_t} +function t8_stash_get_attribute_id(stash, index) + @ccall libt8.t8_stash_get_attribute_id(stash::t8_stash_t, index::Csize_t)::Cint end """ - p8est_connectivity_new_sphere() + t8_stash_attribute_is_owned(stash, index) -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 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 +* `stash`:\\[in\\] The stash to be considered. +* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +# Returns +True of false. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_sphere (void); +int t8_stash_attribute_is_owned (t8_stash_t stash, size_t index); ``` """ -function p8est_connectivity_new_sphere() - @ccall libp4est.p8est_connectivity_new_sphere()::Ptr{p8est_connectivity_t} +function t8_stash_attribute_is_owned(stash, index) + @ccall libt8.t8_stash_attribute_is_owned(stash::t8_stash_t, index::Csize_t)::Cint 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_stash_attribute_sort(stash) -This connectivity is meant to be used with p8est_geometry_new_torus +Sort the attributes array of a stash in the order (treeid, packageid, key) * # Arguments -* `nSegments`:\\[in\\] number of trees along the great circle +* `stash`:\\[in,out\\] The stash to be considered. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_torus (int nSegments); +void t8_stash_attribute_sort (t8_stash_t stash); ``` """ -function p8est_connectivity_new_torus(nSegments) - @ccall libp4est.p8est_connectivity_new_torus(nSegments::Cint)::Ptr{p8est_connectivity_t} +function t8_stash_attribute_sort(stash) + @ccall libt8.t8_stash_attribute_sort(stash::t8_stash_t)::Cvoid end """ - p8est_connectivity_new_byname(name) - -Create connectivity structure from predefined catalogue. + t8_stash_bcast(stash, root, comm, elem_counts) -# 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. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_byname (const char *name); +t8_stash_t t8_stash_bcast (t8_stash_t stash, int root, sc_MPI_Comm comm, const size_t elem_counts[3]); ``` """ -function p8est_connectivity_new_byname(name) - @ccall libp4est.p8est_connectivity_new_byname(name::Cstring)::Ptr{p8est_connectivity_t} +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 """ - p8est_connectivity_refine(conn, num_per_dim) + t8_stash_is_equal(stash_a, stash_b) -Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. +Check two stashes for equal content and return true if so. # 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. +* `stash_a`:\\[in\\] The first stash to be considered. +* `stash_b`:\\[in\\] The first stash to be considered. # Returns -a refined connectivity. +True if both stashes hold copies of the same data. False otherwise. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_refine (p8est_connectivity_t * conn, int num_per_dim); +int t8_stash_is_equal (t8_stash_t stash_a, t8_stash_t stash_b); ``` """ -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_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 """ - p8est_expand_face_transform(iface, nface, ftransform) + t8_attribute_info -Fill an array with the axis combination of a face neighbor transform. +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 -* `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 -void p8est_expand_face_transform (int iface, int nface, int ftransform[]); -``` +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 p8est_expand_face_transform(iface, nface, ftransform) - @ccall libp4est.p8est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid +struct t8_attribute_info + package_id::Cint + key::Cint + attribute_offset::Csize_t + attribute_size::Csize_t end """ - p8est_find_face_transform(connectivity, itree, iface, ftransform) +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. -Fill an array with the axis combination of a face neighbor transform. +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 -# 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). +""" + t8_trees_glo_lo_hash_t -### Prototype -```c -p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); -``` +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 | """ -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 +struct t8_trees_glo_lo_hash_t + global_id::t8_gloidx_t + local_id::t8_locidx_t end """ - p8est_find_edge_transform(connectivity, itree, iedge, ei) + t8_cmesh_trees_init(ptrees, num_procs, num_trees, num_ghosts) -Fills an array with information about edge neighbors. +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 -* `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` structure with initialized array. +* `[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 p8est_find_edge_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t * ei); +void t8_cmesh_trees_init (t8_cmesh_trees_t *ptrees, int num_procs, t8_locidx_t num_trees, t8_locidx_t num_ghosts); ``` """ -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_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 -""" - p8est_find_corner_transform(connectivity, itree, icorner, ci) +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 -Fills an array with information about corner neighbors. +""" +` t8_cmesh_types.h` -# 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` structure with initialized array. -### Prototype -```c -void p8est_find_corner_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t * ci); -``` +We define here the datatypes needed for internal cmesh routines. """ -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 +const t8_part_tree_t = Ptr{t8_part_tree} """ - p8est_connectivity_complete(conn) + t8_cmesh_trees_get_part(trees, proc) -Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. +Return one part of a specified tree array. # 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. +* `trees`:\\[in\\] The tree array to be queried +* `proc`:\\[in\\] An index specifying the part to be returned. +# Returns +The part number *proc* of *trees*. ### Prototype ```c -void p8est_connectivity_complete (p8est_connectivity_t * conn); +t8_part_tree_t t8_cmesh_trees_get_part (const t8_cmesh_trees_t trees, const int proc); ``` """ -function p8est_connectivity_complete(conn) - @ccall libp4est.p8est_connectivity_complete(conn::Ptr{p8est_connectivity_t})::Cvoid +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 """ - p8est_connectivity_reduce(conn) + t8_cmesh_trees_start_part(trees, proc, lfirst_tree, num_trees, lfirst_ghost, num_ghosts, alloc) -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). +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 -* `conn`:\\[in,out\\] The connectivity to be reduced. +* `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 -void p8est_connectivity_reduce (p8est_connectivity_t * conn); +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 p8est_connectivity_reduce(conn) - @ccall libp4est.p8est_connectivity_reduce(conn::Ptr{p8est_connectivity_t})::Cvoid +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 """ - p8est_connectivity_permute(conn, perm, is_current_to_new) + t8_cmesh_trees_finish_part(trees, proc) -[`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. +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 -* `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. +* `trees`:\\[in,out\\] The trees structure to be updated. +* `proc`:\\[in\\] The number of the part to be finished. ### Prototype ```c -void p8est_connectivity_permute (p8est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); +void t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc); ``` """ -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_cmesh_trees_finish_part(trees, proc) + @ccall libt8.t8_cmesh_trees_finish_part(trees::t8_cmesh_trees_t, proc::Cint)::Cvoid end """ - p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + t8_cmesh_trees_copy_toproc(trees_dest, trees_src, lnum_trees, lnum_ghosts) -[`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. +Copy the tree\\_to\\_proc and ghost\\_to\\_proc arrays of one tree structure to another one. # 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). +* `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 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); +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 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_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 """ - p8est_connectivity_is_equivalent(conn1, conn2) + t8_cmesh_trees_copy_part(trees_dest, part_dest, trees_src, part_src) -[`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. +Copy the trees array from one part to another. # Arguments -* `conn1`:\\[in\\] a valid connectivity -* `conn2`:\\[out\\] a valid connectivity +* `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 -int p8est_connectivity_is_equivalent (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); +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 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_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 """ - p8est_edge_array_index(array, it) + t8_cmesh_trees_add_tree(trees, ltree_id, proc, eclass) +Add a tree to a trees structure. + +# 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 -static inline p8est_edge_transform_t * p8est_edge_array_index (sc_array_t * array, size_t it); +void t8_cmesh_trees_add_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, int proc, t8_eclass_t eclass); ``` """ -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_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 """ - p8est_corner_array_index(array, it) + t8_cmesh_trees_add_ghost(trees, lghost_index, gtree_id, proc, eclass, num_local_trees) +Add a ghost to a trees structure. + +# 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. ### Prototype ```c -static inline p8est_corner_transform_t * p8est_corner_array_index (sc_array_t * array, size_t it); +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 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_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 """ - 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_cmesh_trees_set_all_boundary(cmesh, trees) -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`. +Set all neighbor fields of all local trees and ghosts to boundary. # 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 +* `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 -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); +void t8_cmesh_trees_set_all_boundary (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); ``` """ -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_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 """ - 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 -``` - -This function reads a mesh from *filename* and returns an associated p4est connectivity. + t8_cmesh_trees_get_part_data(trees, proc, first_tree, num_trees, first_ghost, num_ghosts) -# 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 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 p8est_connectivity_read_inp(filename) - @ccall libp4est.p8est_connectivity_read_inp(filename::Cstring)::Ptr{p8est_connectivity_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_cmesh_new_from_p4est(conn, comm, do_partition) + t8_cmesh_trees_get_tree(trees, ltree) +Return a pointer to a specific tree in a trees struct. + +# Arguments +* `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 tree with local id *tree*. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); +t8_ctree_t t8_cmesh_trees_get_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree); ``` """ -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_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_cmesh_new_from_p8est(conn, comm, do_partition) + t8_cmesh_trees_get_tree_ext(trees, ltree_id, face_neigh, ttf) + +Return a pointer to a specific tree in a trees struct plus pointers to its face\\_neighbor and tree\\_to\\_face arrays. +# 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. +# Returns +A pointer to the tree with local id *tree*. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); +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_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_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_cmesh_new_empty(comm, do_partition, dimension) + t8_cmesh_trees_get_face_info(trees, ltreeid, face, ttf) + +Return the face neighbor of a tree at a given face and return the tree\\_to\\_face info +# 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. +# Returns +The face neighbor that is stored for this face ### Prototype ```c -t8_cmesh_t t8_cmesh_new_empty (sc_MPI_Comm comm, const int do_partition, const int dimension); +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_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_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_cmesh_new_from_class(eclass, comm) + t8_cmesh_trees_get_face_neighbor(tree, face) +Given a coarse tree and a face number, return the local id of the neighbor tree. + +# Arguments +* `tree.`:\\[in\\] The coarse tree. +* `face.`:\\[in\\] The face number. +# Returns +The local id of the neighbor tree. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_class (t8_eclass_t eclass, sc_MPI_Comm comm); +t8_locidx_t t8_cmesh_trees_get_face_neighbor (const t8_ctree_t tree, const int face); ``` """ -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 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_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) + t8_cmesh_trees_get_face_neighbor_ext(tree, face, ttf) + +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\\] 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 local id of the neighbor tree. ### 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); +t8_locidx_t t8_cmesh_trees_get_face_neighbor_ext (const t8_ctree_t tree, const int face, int8_t *ttf); ``` """ -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 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_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) + t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost, face, ttf) +Given a coarse ghost and a face number, return the local id of the neighbor tree together with its tree-to-face info. + +# 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. +# Returns +The global id of the neighbor tree. ### 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); +t8_gloidx_t t8_cmesh_trees_get_ghost_face_neighbor_ext (const t8_cghost_t ghost, const int face, int8_t *ttf); ``` """ -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 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_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) + t8_cmesh_trees_get_ghost(trees, lghost) + +Return a pointer to a specific ghost in a trees struct. +# Arguments +* `trees`:\\[in\\] The tress structure where the tree is to be looked up. +* `lghost`:\\[in\\] The local id of the ghost. +# Returns +A pointer to the ghost with local id *ghost*. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, int do_partition, int periodic); +t8_cghost_t t8_cmesh_trees_get_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost); ``` """ -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 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_cmesh_new_periodic(comm, dim) + t8_cmesh_trees_get_ghost_ext(trees, lghost_id, face_neigh, ttf) +Return a pointer to a specific ghost in a trees struct plus pointers to its face\\_neighbor and tree\\_to\\_face arrays. + +# 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. +# Returns +A pointer to the tree with local id *tree*. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic (sc_MPI_Comm comm, int dim); +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_cmesh_new_periodic(comm, dim) - @ccall libt8.t8_cmesh_new_periodic(comm::MPI_Comm, dim::Cint)::t8_cmesh_t +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_cmesh_new_periodic_tri(comm) + t8_cmesh_trees_get_ghost_local_id(trees, global_id) + +Given the global tree id of a ghost tree in a trees structure, return its local ghost id. +# Arguments +* `trees`:\\[in\\] The trees structure. +* `global_id`:\\[in\\] A global tree id. +# 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 ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_tri (sc_MPI_Comm comm); +t8_locidx_t t8_cmesh_trees_get_ghost_local_id (t8_cmesh_trees_t trees, t8_gloidx_t global_id); ``` """ -function t8_cmesh_new_periodic_tri(comm) - @ccall libt8.t8_cmesh_new_periodic_tri(comm::MPI_Comm)::t8_cmesh_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_cmesh_new_periodic_hybrid(comm) + t8_cmesh_trees_size(trees) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_hybrid (sc_MPI_Comm comm); +size_t t8_cmesh_trees_size (t8_cmesh_trees_t trees); ``` """ -function t8_cmesh_new_periodic_hybrid(comm) - @ccall libt8.t8_cmesh_new_periodic_hybrid(comm::MPI_Comm)::t8_cmesh_t +function t8_cmesh_trees_size(trees) + @ccall libt8.t8_cmesh_trees_size(trees::t8_cmesh_trees_t)::Csize_t end """ - t8_cmesh_new_periodic_line_more_trees(comm) + t8_cmesh_trees_init_attributes(trees, ltree_id, num_attributes, attr_bytes) + +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 +* `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 -t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm); +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_cmesh_new_periodic_line_more_trees(comm) - @ccall libt8.t8_cmesh_new_periodic_line_more_trees(comm::MPI_Comm)::t8_cmesh_t +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_cmesh_new_bigmesh(eclass, num_trees, comm) + t8_cmesh_trees_get_attribute(trees, ltree_id, package_id, key, size, is_ghost) + +Return an attribute that is stored at 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. +# Returns +A pointer to the queried attribute, NULL if the attribute does not exist. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_bigmesh (t8_eclass_t eclass, int num_trees, sc_MPI_Comm comm); +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_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 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_cmesh_new_line_zigzag(comm) + t8_cmesh_trees_attribute_size(tree) +Return the total size of all attributes stored at a specified tree. + +# Arguments +* `tree`:\\[in\\] A tree structure. +# Returns +The total size (in bytes) of the attributes of *tree*. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_line_zigzag (sc_MPI_Comm comm); +size_t t8_cmesh_trees_attribute_size (t8_ctree_t tree); ``` """ -function t8_cmesh_new_line_zigzag(comm) - @ccall libt8.t8_cmesh_new_line_zigzag(comm::MPI_Comm)::t8_cmesh_t +function t8_cmesh_trees_attribute_size(tree) + @ccall libt8.t8_cmesh_trees_attribute_size(tree::t8_ctree_t)::Csize_t end """ - t8_cmesh_new_prism_cake(comm, num_of_prisms) + 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_cmesh_t t8_cmesh_new_prism_cake (sc_MPI_Comm comm, int num_of_prisms); +size_t t8_cmesh_trees_ghost_attribute_size (t8_cghost_t ghost); ``` """ -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 t8_cmesh_trees_ghost_attribute_size(ghost) + @ccall libt8.t8_cmesh_trees_ghost_attribute_size(ghost::t8_cghost_t)::Csize_t end """ - t8_cmesh_new_prism_deformed(comm) + t8_cmesh_trees_add_attribute(trees, proc, attr, tree_id, index) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_deformed (sc_MPI_Comm comm); +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_cmesh_new_prism_deformed(comm) - @ccall libt8.t8_cmesh_new_prism_deformed(comm::MPI_Comm)::t8_cmesh_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_cmesh_new_pyramid_deformed(comm) + t8_cmesh_trees_add_ghost_attribute(trees, attr, local_ghost_id, ghosts_inserted, index) +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 +* `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 -t8_cmesh_t t8_cmesh_new_pyramid_deformed (sc_MPI_Comm comm); +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_cmesh_new_pyramid_deformed(comm) - @ccall libt8.t8_cmesh_new_pyramid_deformed(comm::MPI_Comm)::t8_cmesh_t +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_cmesh_new_prism_cake_funny_oriented(comm) + t8_cmesh_trees_get_numproc(trees) +Return the number of parts of a trees structure. + +# Arguments +* `trees`:\\[in\\] The trees structure. +# Returns +The number of parts in *trees*. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_cake_funny_oriented (sc_MPI_Comm comm); +size_t t8_cmesh_trees_get_numproc (const t8_cmesh_trees_t trees); ``` """ -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 t8_cmesh_trees_get_numproc(trees) + @ccall libt8.t8_cmesh_trees_get_numproc(trees::t8_cmesh_trees_t)::Csize_t end """ - t8_cmesh_new_prism_geometry(comm) + 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 -t8_cmesh_t t8_cmesh_new_prism_geometry (sc_MPI_Comm comm); +int8_t t8_cmesh_tree_to_face_encode (const int dimension, const t8_locidx_t face, const int orientation); ``` """ -function t8_cmesh_new_prism_geometry(comm) - @ccall libt8.t8_cmesh_new_prism_geometry(comm::MPI_Comm)::t8_cmesh_t +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_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + 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 -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 t8_cmesh_tree_to_face_decode (const int dimension, const int8_t tree_to_face, int *face, int *orientation); ``` """ -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 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_cmesh_new_tet_orientation_test(comm) + 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 -t8_cmesh_t t8_cmesh_new_tet_orientation_test (sc_MPI_Comm comm); +void t8_cmesh_trees_print (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); ``` """ -function t8_cmesh_new_tet_orientation_test(comm) - @ccall libt8.t8_cmesh_new_tet_orientation_test(comm::MPI_Comm)::t8_cmesh_t +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_cmesh_new_hybrid_gate(comm) + t8_cmesh_trees_bcast(cmesh_in, root, comm) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hybrid_gate (sc_MPI_Comm comm); +void t8_cmesh_trees_bcast (t8_cmesh_t cmesh_in, int root, sc_MPI_Comm comm); ``` """ -function t8_cmesh_new_hybrid_gate(comm) - @ccall libt8.t8_cmesh_new_hybrid_gate(comm::MPI_Comm)::t8_cmesh_t +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_cmesh_new_hybrid_gate_deformed(comm) + 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 -t8_cmesh_t t8_cmesh_new_hybrid_gate_deformed (sc_MPI_Comm comm); +int t8_cmesh_trees_is_face_consistent (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); ``` """ -function t8_cmesh_new_hybrid_gate_deformed(comm) - @ccall libt8.t8_cmesh_new_hybrid_gate_deformed(comm::MPI_Comm)::t8_cmesh_t +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_new_full_hybrid(comm) + t8_cmesh_trees_is_equal(cmesh, trees_a, trees_b) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_full_hybrid (sc_MPI_Comm comm); +int t8_cmesh_trees_is_equal (t8_cmesh_t cmesh, t8_cmesh_trees_t trees_a, t8_cmesh_trees_t trees_b); ``` """ -function t8_cmesh_new_full_hybrid(comm) - @ccall libt8.t8_cmesh_new_full_hybrid(comm::MPI_Comm)::t8_cmesh_t +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_cmesh_new_pyramid_cake(comm, num_of_pyra) + 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 -t8_cmesh_t t8_cmesh_new_pyramid_cake (sc_MPI_Comm comm, int num_of_pyra); +void t8_cmesh_trees_destroy (t8_cmesh_trees_t *trees); ``` """ -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 t8_cmesh_trees_destroy(trees) + @ccall libt8.t8_cmesh_trees_destroy(trees::Ptr{t8_cmesh_trees_t})::Cvoid end """ - t8_cmesh_new_long_brick_pyramid(comm, num_cubes) +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 -t8_cmesh_t t8_cmesh_new_long_brick_pyramid (sc_MPI_Comm comm, int num_cubes); -``` +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_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 +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_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm) + 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 -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); +t8_element_array_t * t8_element_array_new (t8_eclass_scheme_c *scheme); ``` """ -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 t8_element_array_new(scheme) + @ccall libt8.t8_element_array_new(scheme::Ptr{t8_eclass_scheme_c})::Ptr{t8_element_array_t} end """ - t8_cmesh_new_quadrangulated_disk(radius, comm) + 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 -t8_cmesh_t t8_cmesh_new_quadrangulated_disk (const double radius, sc_MPI_Comm comm); +t8_element_array_t * t8_element_array_new_count (t8_eclass_scheme_c *scheme, size_t num_elements); ``` """ -function t8_cmesh_new_quadrangulated_disk(radius, comm) - @ccall libt8.t8_cmesh_new_quadrangulated_disk(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +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 """ - t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) + t8_element_array_init(element_array, scheme) + +Initializes an already allocated (or static) array structure. +# Arguments +* `element_array`:\\[in,out\\] Array structure to be initialized. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_MPI_Comm comm); +void t8_element_array_init (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme); ``` """ -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 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 """ - t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) + 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. +# 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 -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc_MPI_Comm comm); +void t8_element_array_init_size (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, size_t num_elements); ``` """ -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 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_cmesh_new_quadrangulated_spherical_surface(radius, comm) + 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). +# 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 -t8_cmesh_t t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm); +void t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, size_t offset, size_t length); ``` """ -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 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_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + 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). + +# 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 -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 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_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 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_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + 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. +# 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 -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 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_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 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_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_levels, num_layers, comm) + 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. +# 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 -t8_cmesh_t t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); +void t8_element_array_resize (t8_element_array_t *element_array, size_t new_count); ``` """ -function t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_levels, num_layers, comm) - @ccall libt8.t8_cmesh_new_cubed_spherical_shell(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_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_cmesh_new_cubed_sphere(radius, comm) + t8_element_array_copy(dest, src) + +Copy the contents of an array into another. Both arrays must have the same eclass\\_scheme. +# 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 -t8_cmesh_t t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm); +void t8_element_array_copy (t8_element_array_t *dest, const t8_element_array_t *src); ``` """ -function t8_cmesh_new_cubed_sphere(radius, comm) - @ccall libt8.t8_cmesh_new_cubed_sphere(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_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_cmesh_get_tree_geom_hash(cmesh, gtreeid) + t8_element_array_push(element_array) -Get the hash of the geometry stored for a tree in a cmesh. +Enlarge an array by one element. # Arguments -* `cmesh`:\\[in\\] A committed cmesh. -* `gtreeid`:\\[in\\] A global tree in *cmesh*. +* `element_array`:\\[in\\] Array structure to be modified. # Returns -The hash of the tree's geometry or if only one geometry exists, its hash. +Returns a pointer to a newly added element for which t8_element_init was called. ### Prototype ```c -size_t t8_cmesh_get_tree_geom_hash (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); +t8_element_t * t8_element_array_push (t8_element_array_t *element_array); ``` """ -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 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_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 + t8_element_array_push_count(element_array, count) - This routine does not detect periodic boundaries. +Enlarge an array by a number of elements. # 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. +* `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 -void t8_cmesh_set_join_by_vertices (t8_cmesh_t cmesh, const int ntrees, const t8_eclass_t *eclasses, const double *vertices, int **connectivity, const int do_both_directions); +t8_element_t * t8_element_array_push_count (t8_element_array_t *element_array, size_t count); ``` """ -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::Cint, eclasses::Ptr{t8_eclass_t}, vertices::Ptr{Cdouble}, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid +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_stash_class + t8_element_array_index_locidx(element_array, index) -The eclass information that is stored before a cmesh is committed. +Return a given element in an array. Const version. -| Field | Note | -| :----- | :----------------------- | -| id | The global tree id | -| eclass | The eclass of that tree | +# 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); +``` """ -struct t8_stash_class - id::t8_gloidx_t - eclass::t8_eclass_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 -"""The eclass information that is stored before a cmesh is committed.""" -const t8_stash_class_struct_t = t8_stash_class - """ - t8_stash_joinface + t8_element_array_index_int(element_array, index) -The face-connection information that is stored before a cmesh is committed. +Return a given element in an array. Const version. -| 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. | +# 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); +``` """ -struct t8_stash_joinface - id1::t8_gloidx_t - id2::t8_gloidx_t - face1::Cint - face2::Cint - orientation::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 -"""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_element_array_index_locidx_mutable(element_array, index) -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. +Return a given element in an array. Mutable version. -| 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. | +# 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); +``` """ -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_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 -"""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_element_array_index_int_mutable(element_array, index) -Initialize a stash data structure. +Return a given element in an array. Mutable version. # Arguments -* `pstash`:\\[in,out\\] A pointer to the stash to be initialized. +* `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 -void t8_stash_init (t8_stash_t *pstash); +t8_element_t * t8_element_array_index_int_mutable (t8_element_array_t *element_array, int index); ``` """ -function t8_stash_init(pstash) - @ccall libt8.t8_stash_init(pstash::Ptr{t8_stash_t})::Cvoid +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_stash_destroy(pstash) + t8_element_array_get_scheme(element_array) -Free all memory associated in a stash structure. +Return the eclass scheme associated to a t8\\_element\\_array. # Arguments -* `pstash`:\\[in,out\\] A pointer to the stash to be destroyed. The pointer is set to NULL after the function call. +* `element_array`:\\[in\\] Array of elements. +# Returns +The eclass scheme stored at *element_array*. ### Prototype ```c -void t8_stash_destroy (t8_stash_t *pstash); +const t8_eclass_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array); ``` """ -function t8_stash_destroy(pstash) - @ccall libt8.t8_stash_destroy(pstash::Ptr{t8_stash_t})::Cvoid +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_stash_add_class(stash, id, eclass) + t8_element_array_get_count(element_array) -Set the eclass of a tree. +Return the number of elements stored in a [`t8_element_array_t`](@ref). # 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*. +* `element_array`:\\[in\\] Array structure. +# Returns +The number of elements stored in *element_array*. ### Prototype ```c -void t8_stash_add_class (t8_stash_t stash, t8_gloidx_t id, t8_eclass_t eclass); +size_t t8_element_array_get_count (const t8_element_array_t *element_array); ``` """ -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_element_array_get_count(element_array) + @ccall libt8.t8_element_array_get_count(element_array::Ptr{t8_element_array_t})::Csize_t end """ - t8_stash_add_facejoin(stash, gid1, gid2, face1, face2, orientation) + t8_element_array_get_size(element_array) -Add a face connection to a stash. +Return the data size of elements stored in a [`t8_element_array_t`](@ref). # 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. +* `element_array`:\\[in\\] Array structure. +# Returns +The size (in bytes) of a single element in *element_array*. ### 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); +size_t t8_element_array_get_size (const t8_element_array_t *element_array); ``` """ -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_element_array_get_size(element_array) + @ccall libt8.t8_element_array_get_size(element_array::Ptr{t8_element_array_t})::Csize_t end """ - t8_stash_class_sort(stash) + t8_element_array_get_data(element_array) -Sort the entries in the class array by the order given in the enum definition of [`t8_eclass`](@ref). +Return a const pointer to the real data array stored in a t8\\_element\\_array. # Arguments -* `stash`:\\[in,out\\] The stash whose class array is sorted. +* `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_stash_class_sort (t8_stash_t stash); +const t8_element_t * t8_element_array_get_data (const t8_element_array_t *element_array); ``` """ -function t8_stash_class_sort(stash) - @ccall libt8.t8_stash_class_sort(stash::t8_stash_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_stash_class_bsearch(stash, tree_id) + t8_element_array_get_data_mutable(element_array) -Search for an entry with a given tree index in the class-stash. The stash must be sorted beforehand. +Return a pointer to the real data array stored in a t8\\_element\\_array. # Arguments -* `stash`:\\[in\\] The stash to be searched for. -* `tree_id`:\\[in\\] The global tree id. +* `element_array`:\\[in\\] Array structure. # Returns -The index of an element in the classes array of *stash* corresponding to *tree_id*. -1 if not found. +A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. ### Prototype ```c -ssize_t t8_stash_class_bsearch (t8_stash_t stash, t8_gloidx_t tree_id); +t8_element_t * t8_element_array_get_data_mutable (t8_element_array_t *element_array); ``` """ -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_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_stash_joinface_sort(stash) + t8_element_array_get_array(element_array) -Sort then entries in the facejoin array in order of the first treeid. +Return a const pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. + +!!! note + + The data cannot be modified. # Arguments -* `stash`:\\[in,out\\] The stash whose facejoin array is sorted. +* `element_array`:\\[in\\] Array structure. +# Returns +A const pointer to the [`sc_array`](@ref) storing the data. ### Prototype ```c -void t8_stash_joinface_sort (t8_stash_t stash); +const sc_array_t * t8_element_array_get_array (const t8_element_array_t *element_array); ``` """ -function t8_stash_joinface_sort(stash) - @ccall libt8.t8_stash_joinface_sort(stash::t8_stash_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_stash_add_attribute(stash, id, package_id, key, size, attr, copy) + t8_element_array_get_array_mutable(element_array) -Add an attribute to a tree. +Return a mutable pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. + +!!! note + + The data can be modified. # 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). +* `element_array`:\\[in\\] Array structure. +# Returns +A pointer to the [`sc_array`](@ref) storing the data. ### Prototype ```c -void t8_stash_add_attribute (t8_stash_t stash, t8_gloidx_t id, int package_id, int key, size_t size, void *attr, int copy); +sc_array_t * t8_element_array_get_array_mutable (t8_element_array_t *element_array); ``` """ -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_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_stash_get_attribute_size(stash, index) + t8_element_array_reset(element_array) -Return the size (in bytes) of an attribute in the stash. +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 -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. -# Returns -The size in bytes of the attribute. +* `element_array`:\\[in,out\\] Array structure to be reset. ### Prototype ```c -size_t t8_stash_get_attribute_size (t8_stash_t stash, size_t index); +void t8_element_array_reset (t8_element_array_t *element_array); ``` """ -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_element_array_reset(element_array) + @ccall libt8.t8_element_array_reset(element_array::Ptr{t8_element_array_t})::Cvoid end """ - t8_stash_get_attribute(stash, index) + t8_element_array_truncate(element_array) -Return the pointer to an attribute in the stash. +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 -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. -# Returns -A void pointer to the memory region where the attribute is stored. +* `element_array`:\\[in,out\\] Element array structure to be truncated. ### Prototype ```c -void * t8_stash_get_attribute (t8_stash_t stash, size_t index); +void t8_element_array_truncate (t8_element_array_t *element_array); ``` """ -function t8_stash_get_attribute(stash, index) - @ccall libt8.t8_stash_get_attribute(stash::t8_stash_t, index::Csize_t)::Ptr{Cvoid} +function t8_element_array_truncate(element_array) + @ccall libt8.t8_element_array_truncate(element_array::Ptr{t8_element_array_t})::Cvoid end """ - t8_stash_get_attribute_tree_id(stash, index) - -Return the id of the tree a given attribute belongs to. + t8_shmem_init(comm) -# Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. -# Returns -The tree id. ### Prototype ```c -t8_gloidx_t t8_stash_get_attribute_tree_id (t8_stash_t stash, size_t index); +void t8_shmem_init (sc_MPI_Comm comm); ``` """ -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_shmem_init(comm) + @ccall libt8.t8_shmem_init(comm::MPI_Comm)::Cvoid end """ - t8_stash_get_attribute_key(stash, index) - -Return the key of a given attribute. + t8_shmem_finalize(comm) -# Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. -# Returns -The attribute's key. ### Prototype ```c -int t8_stash_get_attribute_key (t8_stash_t stash, size_t index); +void t8_shmem_finalize (sc_MPI_Comm comm); ``` """ -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_shmem_finalize(comm) + @ccall libt8.t8_shmem_finalize(comm::MPI_Comm)::Cvoid end """ - t8_stash_get_attribute_id(stash, index) - -Return the package\\_id of a given attribute. + t8_shmem_set_type(comm, type) -# Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. -# Returns -The attribute's package\\_id. ### Prototype ```c -int t8_stash_get_attribute_id (t8_stash_t stash, size_t index); +void t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); ``` """ -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_shmem_set_type(comm, type) + @ccall libt8.t8_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid end """ - t8_stash_attribute_is_owned(stash, index) - -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. + t8_shmem_array_init(parray, elem_size, elem_count, comm) -# Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. -# Returns -True of false. ### Prototype ```c -int t8_stash_attribute_is_owned (t8_stash_t stash, size_t index); +void t8_shmem_array_init (t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm); ``` """ -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_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 """ - t8_stash_attribute_sort(stash) + t8_shmem_array_start_writing(array) -Sort the attributes array of a stash in the order (treeid, package_id, key) * +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 + + This function is MPI collective. # Arguments -* `stash`:\\[in,out\\] The stash to be considered. +* `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_stash_attribute_sort (t8_stash_t stash); +int t8_shmem_array_start_writing (t8_shmem_array_t array); ``` """ -function t8_stash_attribute_sort(stash) - @ccall libt8.t8_stash_attribute_sort(stash::t8_stash_t)::Cvoid +function t8_shmem_array_start_writing(array) + @ccall libt8.t8_shmem_array_start_writing(array::t8_shmem_array_t)::Cint end """ - t8_stash_bcast(stash, root, comm, elem_counts) + t8_shmem_array_end_writing(array) + +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 -t8_stash_t t8_stash_bcast (t8_stash_t stash, int root, sc_MPI_Comm comm, size_t elem_counts[3]); +void t8_shmem_array_end_writing (t8_shmem_array_t array); ``` """ -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_shmem_array_end_writing(array) + @ccall libt8.t8_shmem_array_end_writing(array::t8_shmem_array_t)::Cvoid end """ - t8_stash_is_equal(stash_a, stash_b) + t8_shmem_array_set_gloidx(array, index, value) -Check two stashes for equal content and return true if so. +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 -* `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. +* `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 -int t8_stash_is_equal (t8_stash_t stash_a, t8_stash_t stash_b); +void t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value); ``` """ -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 - -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_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_cmesh_types.h` + t8_shmem_array_copy(dest, source) -We define here the datatypes needed for internal cmesh routines. -""" -const t8_part_tree_t = Ptr{t8_part_tree} +Copy the contents of one t8\\_shmem array into another. -""" -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. +!!! note -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. + *dest* must be initialized and match in element size and element count to *source*. -Each tree stores information about its face-neighbours in an array of t8_ctree_fneighbor. +!!! note -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. + *dest* must have writing mode disabled. -# See also -t8\\_ctree\\_fneighbor +# Arguments +* `dest`:\\[in,out\\] The array in which *source* should be copied. +* `source`:\\[in\\] The array to copy. +### Prototype +```c +void t8_shmem_array_copy (t8_shmem_array_t dest, t8_shmem_array_t source); +``` """ -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 +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_attribute_info - -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. + t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) -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. +### 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); +``` """ -struct t8_attribute_info - package_id::Cint - key::Cint - attribute_offset::Csize_t - attribute_size::Csize_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 """ -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. + t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) -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. +### 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); +``` """ -const t8_attribute_info_struct_t = t8_attribute_info - -const t8_cmesh_trees_struct_t = t8_cmesh_trees - -const t8_part_tree_struct_t = t8_part_tree +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 """ -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. + t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) -# See also -[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) +### 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); +``` """ -const t8_cprofile_struct_t = t8_cprofile +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_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_shmem_array_get_comm(array) -| Field | Note | -| :----- | :--------------------------------------------------- | -| scheme | An eclass scheme of which elements should be stored | -| array | The array in which the elements are stored | +### Prototype +```c +sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array); +``` """ -struct t8_element_array_t - scheme::Ptr{t8_eclass_scheme_c} - array::sc_array_t +function t8_shmem_array_get_comm(array) + @ccall libt8.t8_shmem_array_get_comm(array::t8_shmem_array_t)::Cint end """ - t8_element_array_new(scheme) + t8_shmem_array_get_elem_size(array) -Creates a new array structure with 0 elements. +Get the element size of a [`t8_shmem_array`](@ref) # Arguments -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `array`:\\[in\\] The array. # Returns -Return an allocated array of zero length. +The element size of *array*'s elements. ### Prototype ```c -t8_element_array_t * t8_element_array_new (t8_eclass_scheme_c *scheme); +size_t t8_shmem_array_get_elem_size (t8_shmem_array_t array); ``` """ -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_shmem_array_get_elem_size(array) + @ccall libt8.t8_shmem_array_get_elem_size(array::t8_shmem_array_t)::Csize_t end """ - t8_element_array_new_count(scheme, num_elements) + t8_shmem_array_get_elem_count(array) -Creates a new array structure with a given length (number of elements) and calls t8_element_new for those elements. +Get the number of elements of a [`t8_shmem_array`](@ref) # Arguments -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `num_elements`:\\[in\\] Initial number of array elements. +* `array`:\\[in\\] The array. # Returns -Return an allocated array with allocated and initialized elements for which t8_element_new was called. +The number of elements in *array*. ### Prototype ```c -t8_element_array_t * t8_element_array_new_count (t8_eclass_scheme_c *scheme, size_t num_elements); +size_t t8_shmem_array_get_elem_count (t8_shmem_array_t array); ``` """ -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_shmem_array_get_elem_count(array) + @ccall libt8.t8_shmem_array_get_elem_count(array::t8_shmem_array_t)::Csize_t end """ - t8_element_array_init(element_array, scheme) + t8_shmem_array_get_gloidx_array(array) -Initializes an already allocated (or static) array structure. +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 -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +# Returns +The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -void t8_element_array_init (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme); +const t8_gloidx_t * t8_shmem_array_get_gloidx_array (t8_shmem_array_t array); ``` """ -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_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_element_array_init_size(element_array, scheme, num_elements) + t8_shmem_array_get_gloidx_array_for_writing(array) -Initializes an already allocated (or static) array structure and allocates a given number of elements and initializes them with t8_element_init. +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 -* `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. +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +# Returns +The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -void t8_element_array_init_size (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, size_t num_elements); +t8_gloidx_t * t8_shmem_array_get_gloidx_array_for_writing (t8_shmem_array_t array); ``` """ -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_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_element_array_init_view(view, array, offset, length) + t8_shmem_array_get_gloidx(array, index) -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). +Return an entry of a shared memory array that stores [`t8_gloidx_t`](@ref). + +!!! note + + Writing mode must be disabled for *array*. # 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. +* `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_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, size_t offset, size_t length); +t8_gloidx_t t8_shmem_array_get_gloidx (t8_shmem_array_t array, int index); ``` """ -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_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_element_array_init_data(view, base, scheme, elem_count) + t8_shmem_array_get_array(array) -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). +Return a pointer to the data array of a [`t8_shmem_array`](@ref). + +!!! note + + Writing mode must be disabled for *array*. # 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. +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). +# Returns +A pointer to the data array of *array*. ### 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); +const void * t8_shmem_array_get_array (t8_shmem_array_t array); ``` """ -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_shmem_array_get_array(array) + @ccall libt8.t8_shmem_array_get_array(array::t8_shmem_array_t)::Ptr{Cvoid} end """ - t8_element_array_init_copy(element_array, scheme, data, num_elements) + t8_shmem_array_index(array, index) -Initializes an already allocated (or static) array structure and copy an existing array of [`t8_element_t`](@ref) into it. +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 -* `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. +* `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_element_array_init_copy (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, t8_element_t *data, size_t num_elements); +const void * t8_shmem_array_index (t8_shmem_array_t array, size_t index); ``` """ -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_shmem_array_index(array, index) + @ccall libt8.t8_shmem_array_index(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} end """ - t8_element_array_resize(element_array, new_count) + t8_shmem_array_index_for_writing(array, index) -Change the number of elements stored in an element array. +Return a pointer to an element in a [`t8_shmem_array`](@ref) in writing mode. !!! 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. + You can modify the value before the next call to t8_shmem_array_end_writing. + +!!! note + + Writing mode must be enabled for *array*. # 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. +* `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_element_array_resize (t8_element_array_t *element_array, size_t new_count); +void * t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index); ``` """ -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_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_element_array_copy(dest, src) - -Copy the contents of an array into another. Both arrays must have the same eclass\\_scheme. + t8_shmem_array_is_equal(array_a, array_b) -# 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, t8_element_array_t *src); +int t8_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b); ``` """ -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_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_element_array_push(element_array) + t8_shmem_array_destroy(parray) -Enlarge an array by one element. +Free all memory associated with a [`t8_shmem_array`](@ref). # 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. +* `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 -t8_element_t * t8_element_array_push (t8_element_array_t *element_array); +void t8_shmem_array_destroy (t8_shmem_array_t *parray); ``` """ -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_shmem_array_destroy(parray) + @ccall libt8.t8_shmem_array_destroy(parray::Ptr{t8_shmem_array_t})::Cvoid end """ - t8_element_array_push_count(element_array, count) - -Enlarge an array by a number of elements. + t8_forest_adapt(forest) -# 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); +void t8_forest_adapt (t8_forest_t forest); ``` """ -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_adapt(forest) + @ccall libt8.t8_forest_adapt(forest::t8_forest_t)::Cvoid end """ - t8_element_array_index_locidx(element_array, index) + t8_forest_balance(forest, repartition) + +### Prototype +```c +void t8_forest_balance (t8_forest_t forest, int repartition); +``` +""" +function t8_forest_balance(forest, repartition) + @ccall libt8.t8_forest_balance(forest::t8_forest_t, repartition::Cint)::Cvoid +end -Return a given element in an array. +""" + t8_forest_is_balanced(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*. ### Prototype ```c -t8_element_t * t8_element_array_index_locidx (t8_element_array_t *element_array, t8_locidx_t index); +int t8_forest_is_balanced (t8_forest_t forest); ``` """ -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_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 +end + +const t8_tree_t = Ptr{t8_tree} + +""" + t8_ghost_type_t + +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. | +""" +@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_element_array_index_int(element_array, index) - -Return a given element in an array. +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. -# 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_int (t8_element_array_t *element_array, int index); -``` +# See also +[`t8_forest_get_user_function`](@ref). """ -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 +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 ) """ - t8_element_array_get_scheme(element_array) +Callback function prototype to replace one set of elements with another. -Return the eclass scheme associated to a t8\\_element\\_array. +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 -* `element_array`:\\[in\\] Array of elements. -# Returns -The eclass scheme stored at *element_array*. -### Prototype -```c -t8_eclass_scheme_c * t8_element_array_get_scheme (t8_element_array_t *element_array); -``` +* `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) """ -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 +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 [ ] ) """ - t8_element_array_get_count(element_array) - -Return the number of elements stored in a [`t8_element_array_t`](@ref). +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 -* `element_array`:\\[in\\] Array structure. +* `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 -The number of elements stored in *element_array*. -### Prototype -```c -size_t t8_element_array_get_count (const t8_element_array_t *element_array); -``` +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_element_array_get_count(element_array) - @ccall libt8.t8_element_array_get_count(element_array::Ptr{t8_element_array_t})::Csize_t -end +const t8_forest_adapt_t = Ptr{Cvoid} """ - t8_element_array_get_size(element_array) + t8_forest_init(pforest) -Return the data size of elements stored in a [`t8_element_array_t`](@ref). +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 -* `element_array`:\\[in\\] Array structure. -# Returns -The size (in bytes) of a single element in *element_array*. +* `pforest`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new forest. ### Prototype ```c -size_t t8_element_array_get_size (t8_element_array_t *element_array); +void t8_forest_init (t8_forest_t *pforest); ``` """ -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_init(pforest) + @ccall libt8.t8_forest_init(pforest::Ptr{t8_forest_t})::Cvoid end """ - t8_element_array_get_data(element_array) + t8_forest_is_initialized(forest) -Return a pointer to the real data array stored in a t8\\_element\\_array. +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 -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] This forest is examined. May be NULL. # Returns -A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. +True if forest is not NULL, t8_forest_init has been called on it, but not t8_forest_commit. False otherwise. ### Prototype ```c -t8_element_t * t8_element_array_get_data (t8_element_array_t *element_array); +int t8_forest_is_initialized (t8_forest_t forest); ``` """ -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_is_initialized(forest) + @ccall libt8.t8_forest_is_initialized(forest::t8_forest_t)::Cint end """ - t8_element_array_get_array(element_array) + t8_forest_is_committed(forest) -Return a pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. +Check whether a forest is not NULL, initialized and committed. In addition, it asserts that the forest is consistent as much as possible. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] This forest is examined. May be NULL. # Returns -A pointer to the [`sc_array`](@ref) storing the data. +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 -sc_array_t * t8_element_array_get_array (t8_element_array_t *element_array); +int t8_forest_is_committed (t8_forest_t forest); ``` """ -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_is_committed(forest) + @ccall libt8.t8_forest_is_committed(forest::t8_forest_t)::Cint end """ - t8_element_array_reset(element_array) + t8_forest_no_overlap(forest) -Sets the array count to zero and frees all elements. +Check whether the forest has local overlapping elements. !!! note - Calling [`t8_element_array_init`](@ref), then any array operations, then [`t8_element_array_reset`](@ref) is memory neutral. + This function is collective, but only checks local overlapping on each process. # Arguments -* `element_array`:\\[in,out\\] Array structure to be reset. +* `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. + ### Prototype ```c -void t8_element_array_reset (t8_element_array_t *element_array); +int t8_forest_no_overlap (t8_forest_t forest); ``` """ -function t8_element_array_reset(element_array) - @ccall libt8.t8_element_array_reset(element_array::Ptr{t8_element_array_t})::Cvoid +function t8_forest_no_overlap(forest) + @ccall libt8.t8_forest_no_overlap(forest::t8_forest_t)::Cint end """ - t8_element_array_truncate(element_array) + t8_forest_is_equal(forest_a, forest_b) -Sets the array count to zero, but does not free elements. +Check whether two committed forests have the same local 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. + This function is not collective. It only returns the state on the current rank. # Arguments -* `element_array`:\\[in,out\\] Element array structure to be truncated. -### Prototype -```c -void t8_element_array_truncate (t8_element_array_t *element_array); -``` -""" -function t8_element_array_truncate(element_array) - @ccall libt8.t8_element_array_truncate(element_array::Ptr{t8_element_array_t})::Cvoid -end - -""" - t8_shmem_init(comm) - +* `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 -void t8_shmem_init (sc_MPI_Comm comm); +int t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b); ``` """ -function t8_shmem_init(comm) - @ccall libt8.t8_shmem_init(comm::MPI_Comm)::Cvoid +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_shmem_finalize(comm) + t8_forest_set_cmesh(forest, cmesh, comm) ### Prototype ```c -void t8_shmem_finalize (sc_MPI_Comm comm); +void t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function t8_shmem_finalize(comm) - @ccall libt8.t8_shmem_finalize(comm::MPI_Comm)::Cvoid +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_shmem_set_type(comm, type) - -### Prototype -```c -void t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); -``` -""" -function t8_shmem_set_type(comm, type) - @ccall libt8.t8_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid -end + t8_forest_set_scheme(forest, scheme) -""" - t8_shmem_array_init(parray, elem_size, elem_count, comm) +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 +* `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_shmem_array_init (t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm); +void t8_forest_set_scheme (t8_forest_t forest, t8_scheme_cxx_t *scheme); ``` """ -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_set_scheme(forest, scheme) + @ccall libt8.t8_forest_set_scheme(forest::t8_forest_t, scheme::Ptr{t8_scheme_cxx_t})::Cvoid end """ - t8_shmem_array_start_writing(array) + t8_forest_set_level(forest, level) -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. +Set the initial refinement level to be used when **forest** is committed. !!! note - This function is MPI collective. + 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 -* `array`:\\[in,out\\] Initialized array. Writing will be enabled on certain processes. -# Returns -True if the calling process can write into the array. +* `forest`:\\[in,out\\] The forest whose level will be set. +* `level`:\\[in\\] The initial refinement level of **forest**, when it is committed. ### Prototype ```c -int t8_shmem_array_start_writing (t8_shmem_array_t array); +void t8_forest_set_level (t8_forest_t forest, int level); ``` """ -function t8_shmem_array_start_writing(array) - @ccall libt8.t8_shmem_array_start_writing(array::t8_shmem_array_t)::Cint +function t8_forest_set_level(forest, level) + @ccall libt8.t8_forest_set_level(forest::t8_forest_t, level::Cint)::Cvoid end """ - t8_shmem_array_end_writing(array) + t8_forest_set_copy(forest, from) -Disable writing mode for a shmem array. +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 is MPI collective. - -# Arguments -* `array`:\\[in,out\\] Initialized with writing mode enabled. -# See also -[`t8_shmem_array_start_writing`](@ref). - -### Prototype -```c -void t8_shmem_array_end_writing (t8_shmem_array_t array); -``` -""" -function t8_shmem_array_end_writing(array) - @ccall libt8.t8_shmem_array_end_writing(array::t8_shmem_array_t)::Cvoid -end - -""" - t8_shmem_array_set_gloidx(array, index, value) - -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. + This setting cannot be combined with t8_forest_set_adapt, t8_forest_set_partition, or t8_forest_set_balance and overwrites these settings. # 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. +* `from`:\\[in\\] A second forest from which *forest* will be copied in t8_forest_commit. ### Prototype ```c -void t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value); +void t8_forest_set_copy (t8_forest_t forest, const t8_forest_t from); ``` """ -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_set_copy(forest, from) + @ccall libt8.t8_forest_set_copy(forest::t8_forest_t, from::t8_forest_t)::Cvoid end """ - t8_shmem_array_copy(dest, source) + t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) -Copy the contents of one t8\\_shmem array into another. +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 - *dest* must be initialized and match in element size and element count to *source*. + 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 - *dest* must have writing mode disabled. + This setting may not be combined with t8_forest_set_copy and overwrites this setting. # Arguments -* `dest`:\\[in,out\\] The array in which *source* should be copied. -* `source`:\\[in\\] The array to copy. +* `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_shmem_array_copy (t8_shmem_array_t dest, t8_shmem_array_t source); +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_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_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_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) + t8_forest_set_user_data(forest, data) -### 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); -``` -""" -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 +Set the user data of a forest. This can i.e. be used to pass user defined arguments to the adapt routine. -""" - t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) +# 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) ### 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_set_user_data (t8_forest_t forest, void *data); ``` """ -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_set_user_data(forest, data) + @ccall libt8.t8_forest_set_user_data(forest::t8_forest_t, data::Ptr{Cvoid})::Cvoid end """ - t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) + t8_forest_get_user_data(forest) + +Return the user data pointer associated with a forest. + +# 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_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); +void * t8_forest_get_user_data (const t8_forest_t forest); ``` """ -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 t8_forest_get_user_data(forest) + @ccall libt8.t8_forest_get_user_data(forest::t8_forest_t)::Ptr{Cvoid} end """ - t8_shmem_array_get_comm(array) + 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 -sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array); +void t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer function); ``` """ -function t8_shmem_array_get_comm(array) - @ccall libt8.t8_shmem_array_get_comm(array::t8_shmem_array_t)::Cint +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_shmem_array_get_elem_size(array) + t8_forest_get_user_function(forest) -Get the element size of a [`t8_shmem_array`](@ref) +Return the user function pointer associated with a forest. # Arguments -* `array`:\\[in\\] The array. +* `forest`:\\[in\\] The forest. # Returns -The element size of *array*'s elements. +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 -size_t t8_shmem_array_get_elem_size (t8_shmem_array_t array); +t8_generic_function_pointer t8_forest_get_user_function (const t8_forest_t forest); ``` """ -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_get_user_function(forest) + @ccall libt8.t8_forest_get_user_function(forest::t8_forest_t)::t8_generic_function_pointer end """ - t8_shmem_array_get_elem_count(array) + t8_forest_set_partition(forest, set_from, set_for_coarsening) -Get the number of elements of a [`t8_shmem_array`](@ref) +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 -* `array`:\\[in\\] The array. -# Returns -The number of elements in *array*. +* `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 -size_t t8_shmem_array_get_elem_count (t8_shmem_array_t array); +void t8_forest_set_partition (t8_forest_t forest, const t8_forest_t set_from, int set_for_coarsening); ``` """ -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_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_shmem_array_get_gloidx_array(array) + t8_forest_set_balance(forest, set_from, no_repartition) -Return a read-only pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. +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 - Writing mode must be disabled for *array*. + 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 -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) -# Returns -The data of *array* as [`t8_gloidx_t`](@ref) pointer. +* `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 -const t8_gloidx_t * t8_shmem_array_get_gloidx_array (t8_shmem_array_t array); +void t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_repartition); ``` """ -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 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_shmem_array_get_gloidx_array_for_writing(array) + t8_forest_set_ghost(forest, do_ghost, ghost_type) -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. +Enable or disable the creation of a layer of ghost elements. On default no ghosts are created. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) -# Returns -The data of *array* as [`t8_gloidx_t`](@ref) pointer. +* `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 -t8_gloidx_t * t8_shmem_array_get_gloidx_array_for_writing (t8_shmem_array_t array); +void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type); ``` """ -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 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_shmem_array_get_gloidx(array, index) - -Return an entry of a shared memory array that stores [`t8_gloidx_t`](@ref). - -!!! note + t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) - Writing mode must be disabled for *array*. +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 -* `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). +* `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 -t8_gloidx_t t8_shmem_array_get_gloidx (t8_shmem_array_t array, int index); +void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); ``` """ -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_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_shmem_array_get_array(array) - -Return a pointer to the data array of a [`t8_shmem_array`](@ref). - -!!! note - - Writing mode must be disabled for *array*. + t8_forest_set_load(forest, filename) -# 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); +void t8_forest_set_load (t8_forest_t forest, const char *filename); ``` """ -function t8_shmem_array_get_array(array) - @ccall libt8.t8_shmem_array_get_array(array::t8_shmem_array_t)::Ptr{Cvoid} +function t8_forest_set_load(forest, filename) + @ccall libt8.t8_forest_set_load(forest::t8_forest_t, filename::Cstring)::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_comm_global_num_elements(forest) - Writing mode must be disabled for *array*. +Compute the global number of elements in a forest as the sum of the local element counts. # 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. ### Prototype ```c -const void * t8_shmem_array_index (t8_shmem_array_t array, size_t index); +void t8_forest_comm_global_num_elements (t8_forest_t forest); ``` """ -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_comm_global_num_elements(forest) + @ccall libt8.t8_forest_comm_global_num_elements(forest::t8_forest_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 - - You can modify the value before the next call to t8_shmem_array_end_writing. - -!!! note + t8_forest_commit(forest) - Writing mode must be enabled for *array*. +After allocating and adding properties to a forest, commit the changes. This call sets up the internal state of the forest. # 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,out\\] Must be created with t8_forest_init and specialized with t8\\_forest\\_set\\_* calls first. ### Prototype ```c -void * t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index); +void t8_forest_commit (t8_forest_t forest); ``` """ -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_commit(forest) + @ccall libt8.t8_forest_commit(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_is_equal(array_a, array_b) + t8_forest_get_maxlevel(forest) + +Return the maximum allowed refinement level for any element in a forest. +# 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_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b); +int t8_forest_get_maxlevel (const t8_forest_t forest); ``` """ -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_get_maxlevel(forest) + @ccall libt8.t8_forest_get_maxlevel(forest::t8_forest_t)::Cint end """ - t8_shmem_array_destroy(parray) + t8_forest_get_local_num_elements(forest) -Free all memory associated with a [`t8_shmem_array`](@ref). +Return the number of process local elements in the forest. # 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\\] A forest. +# Returns +The number of elements on this process in *forest*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_shmem_array_destroy (t8_shmem_array_t *parray); +t8_locidx_t t8_forest_get_local_num_elements (const 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_get_local_num_elements(forest) + @ccall libt8.t8_forest_get_local_num_elements(forest::t8_forest_t)::t8_locidx_t end """ - t8_forest_adapt(forest) + t8_forest_get_global_num_elements(forest) + +Return the number of global elements in the forest. +# Arguments +* `forest`:\\[in\\] A forest. +# Returns +The number of elements (summed over all processes) in *forest*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_forest_adapt (t8_forest_t forest); +t8_gloidx_t t8_forest_get_global_num_elements (const t8_forest_t forest); ``` """ -function t8_forest_adapt(forest) - @ccall libt8.t8_forest_adapt(forest::t8_forest_t)::Cvoid +function t8_forest_get_global_num_elements(forest) + @ccall libt8.t8_forest_get_global_num_elements(forest::t8_forest_t)::t8_gloidx_t end -mutable struct t8_tree end - -const t8_tree_t = Ptr{t8_tree} - -""" - t8_ghost_type_t - -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. | """ -@cenum t8_ghost_type_t::UInt32 begin - T8_GHOST_NONE = 0 - T8_GHOST_FACES = 1 - T8_GHOST_EDGES = 2 - T8_GHOST_VERTICES = 3 -end + t8_forest_get_num_ghosts(forest) -# 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. +Return the number of ghost elements of a forest. +# 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_get_user_function`](@ref). -""" -const t8_generic_function_pointer = Ptr{Cvoid} +[`t8_forest_set_ghost`](@ref) *forest* must be committed before calling this function. -# 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 ) +### Prototype +```c +t8_locidx_t t8_forest_get_num_ghosts (const t8_forest_t forest); +``` """ -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. +function t8_forest_get_num_ghosts(forest) + @ccall libt8.t8_forest_get_num_ghosts(forest::t8_forest_t)::t8_locidx_t +end -# 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_get_eclass(forest, ltreeid) -# 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. +Return the element class of a forest local tree. # 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. +* `ltreeid`:\\[in\\] The local id of a tree in *forest*. # 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 element class of the tree *ltreeid*. *forest* must be committed before calling this function. +### Prototype +```c +t8_eclass_t t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid); +``` """ -const t8_forest_adapt_t = Ptr{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_forest_init(pforest) + t8_forest_tree_is_local(forest, local_tree) -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. +Check whether a given tree id belongs to a local tree in a forest. # Arguments -* `pforest`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new forest. +* `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_forest_init (t8_forest_t *pforest); +int t8_forest_tree_is_local (const t8_forest_t forest, const t8_locidx_t local_tree); ``` """ -function t8_forest_init(pforest) - @ccall libt8.t8_forest_init(pforest::Ptr{t8_forest_t})::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_forest_is_initialized(forest) + t8_forest_get_local_id(forest, gtreeid) -Check whether a forest is not NULL, initialized and not committed. In addition, it asserts that the forest is consistent as much as possible. +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 -* `forest`:\\[in\\] This forest is examined. May be NULL. +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of a tree. # Returns -True if forest is not NULL, t8_forest_init has been called on it, but not t8_forest_commit. False 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_forest_is_initialized (t8_forest_t forest); +t8_locidx_t t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); ``` """ -function t8_forest_is_initialized(forest) - @ccall libt8.t8_forest_is_initialized(forest::t8_forest_t)::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_forest_is_committed(forest) + t8_forest_get_local_or_ghost_id(forest, gtreeid) -Check whether a forest is not NULL, initialized and committed. In addition, it asserts that the forest is consistent as much as possible. +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 -* `forest`:\\[in\\] This forest is examined. May be NULL. +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of a tree. # 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 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 -int t8_forest_is_committed (t8_forest_t forest); +t8_locidx_t t8_forest_get_local_or_ghost_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); ``` """ -function t8_forest_is_committed(forest) - @ccall libt8.t8_forest_is_committed(forest::t8_forest_t)::Cint +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_forest_no_overlap(forest) + t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) -Check whether the forest has local overlapping elements. +Given the local id of a tree in a forest, compute the tree's local id in the associated cmesh. !!! note - This function is collective, but only checks local overlapping on each process. + For forest local trees, this is the inverse function of t8_forest_cmesh_ltreeid_to_ltreeid. # Arguments -* `forest`:\\[in\\] The forest to consider. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree or ghost in the forest. # Returns -True if *forest* has no elements which are inside each other. +The local id of the tree in the cmesh associated with the forest. *forest* must be committed before calling this function. # See also -[`t8_forest_partition_test_boundary_element`](@ref) if you also want to test for global overlap across the process boundaries. +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. ### Prototype ```c -int t8_forest_no_overlap (t8_forest_t forest); +t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_forest_no_overlap(forest) - @ccall libt8.t8_forest_no_overlap(forest::t8_forest_t)::Cint +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_forest_is_equal(forest_a, forest_b) + t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) -Check whether two committed forests have the same local elements. +Given the local id of a tree in the coarse mesh of a forest, compute the tree's local id in the forest. !!! note - This function is not collective. It only returns the state on the current rank. + For forest local trees, this is the inverse function of t8_forest_ltreeid_to_cmesh_ltreeid. # Arguments -* `forest_a`:\\[in\\] The first forest. -* `forest_b`:\\[in\\] The second forest. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree in the coarse mesh of *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*. +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_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b); +t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, t8_locidx_t lctreeid); ``` """ -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_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_forest_set_cmesh(forest, cmesh, comm) + t8_forest_get_coarse_tree(forest, ltreeid) +Given the local id of a tree in a forest, return the coarse tree of the cmesh that corresponds to this tree. + +# Arguments +* `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 -void t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); +t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -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_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_forest_set_scheme(forest, scheme) + t8_forest_element_is_leaf(forest, element, 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. +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 -* `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**. +* `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 -void t8_forest_set_scheme (t8_forest_t forest, t8_scheme_cxx_t *scheme); +int t8_forest_element_is_leaf (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t local_tree); ``` """ -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_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_forest_set_level(forest, level) - -Set the initial refinement level to be used when **forest** is committed. + t8_forest_leaf_face_orientation(forest, ltreeid, ts, leaf, face) -!!! note +Compute the leaf face orientation at given face in a forest. - 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). +For more information about the encoding of face orientation refer to t8_cmesh_get_face_neighbor. # Arguments -* `forest`:\\[in,out\\] The forest whose level will be set. -* `level`:\\[in\\] The initial refinement level of **forest**, when it is committed. +* `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 -void t8_forest_set_level (t8_forest_t forest, int level); +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_forest_set_level(forest, level) - @ccall libt8.t8_forest_set_level(forest::t8_forest_t, level::Cint)::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_forest_set_copy(forest, from) + 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. -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 + + *forest* must be committed before calling 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. + 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,out\\] The forest. -* `from`:\\[in\\] A second forest from which *forest* will be copied in t8_forest_commit. +* `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_forest_set_copy (t8_forest_t forest, const t8_forest_t from); +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_forest_set_copy(forest, from) - @ccall libt8.t8_forest_set_copy(forest::t8_forest_t, from::t8_forest_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_forest_set_adapt(forest, set_from, adapt_fn, recursive) + 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) -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. +Like t8_forest_leaf_face_neighbors but also provides information about the global neighbors and the orientation. !!! 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 + If there are no face neighbors, then *neighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. !!! 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\\] 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); -``` -""" -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_forest_set_user_data(forest, data) + Currently *forest* must be balanced. -Set the user data of a forest. This can i.e. be used to pass user defined arguments to the adapt routine. +!!! note -# 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) + *forest* must be committed before calling this function. -### Prototype -```c -void t8_forest_set_user_data (t8_forest_t forest, void *data); -``` -""" -function t8_forest_set_user_data(forest, data) - @ccall libt8.t8_forest_set_user_data(forest::t8_forest_t, data::Ptr{Cvoid})::Cvoid -end +!!! note -""" - t8_forest_get_user_data(forest) + Important! This routine allocates memory which must be freed. Do it like this: -Return the user data pointer associated with a forest. +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. -# 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) - +* `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 -void * t8_forest_get_user_data (const t8_forest_t forest); +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_forest_get_user_data(forest) - @ccall libt8.t8_forest_get_user_data(forest::t8_forest_t)::Ptr{Cvoid} +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_forest_set_user_function(forest, _function) + t8_forest_ghost_exchange_data(forest, element_data) -Set the user function pointer of a forest. This can i.e. be used to pass user defined functions to the adapt routine. +Exchange ghost information of user defined element data. !!! 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. + This function is collective and hence must be called by all processes in the forest's MPI Communicator. # 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) - +* `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_set_user_function (t8_forest_t forest, t8_generic_function_pointer function); +void t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data); ``` """ -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_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_forest_get_user_function(forest) - -Return the user function pointer associated with a forest. + t8_forest_ghost_print(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) +Print the ghost structure of a forest. Only used for debugging. ### Prototype ```c -t8_generic_function_pointer t8_forest_get_user_function (const t8_forest_t forest); +void t8_forest_ghost_print (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_ghost_print(forest) + @ccall libt8.t8_forest_ghost_print(forest::t8_forest_t)::Cvoid end """ - 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) 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. + t8_forest_partition_cmesh(forest, comm, set_profiling) -# 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); +void t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profiling); ``` """ -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_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_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_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. + t8_forest_get_mpicomm(forest) -# 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); +sc_MPI_Comm t8_forest_get_mpicomm (const t8_forest_t forest); ``` """ -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_forest_get_mpicomm(forest) + @ccall libt8.t8_forest_get_mpicomm(forest::t8_forest_t)::Cint end """ - t8_forest_set_ghost(forest, do_ghost, ghost_type) + t8_forest_get_first_local_tree_id(forest) -Enable or disable the creation of a layer of ghost elements. On default no ghosts are created. +Return the global id of the first local tree of a forest. # 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. +# Returns +The global id of the first local tree in *forest*. ### Prototype ```c -void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type); +t8_gloidx_t t8_forest_get_first_local_tree_id (const t8_forest_t forest); ``` """ -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_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_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) + t8_forest_get_num_local_trees(forest) -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. +Return the number of local trees of a given forest. # 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) - +* `forest`:\\[in\\] The forest. +# Returns +The number of local trees of that forest. ### 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_locidx_t t8_forest_get_num_local_trees (const t8_forest_t forest); ``` """ -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_forest_get_num_local_trees(forest) + @ccall libt8.t8_forest_get_num_local_trees(forest::t8_forest_t)::t8_locidx_t end """ - t8_forest_set_load(forest, filename) + 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_forest_set_load (t8_forest_t forest, const char *filename); +t8_locidx_t t8_forest_get_num_ghost_trees (const t8_forest_t forest); ``` """ -function t8_forest_set_load(forest, filename) - @ccall libt8.t8_forest_set_load(forest::t8_forest_t, filename::Cstring)::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_forest_comm_global_num_elements(forest) + t8_forest_get_num_global_trees(forest) -Compute the global number of elements in a forest as the sum of the local element counts. +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 -void t8_forest_comm_global_num_elements (t8_forest_t forest); +t8_gloidx_t t8_forest_get_num_global_trees (const t8_forest_t forest); ``` """ -function t8_forest_comm_global_num_elements(forest) - @ccall libt8.t8_forest_comm_global_num_elements(forest::t8_forest_t)::Cvoid +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_forest_commit(forest) + t8_forest_global_tree_id(forest, ltreeid) -After allocating and adding properties to a forest, commit the changes. This call sets up the internal state of the forest. +Return the global id of a local tree or a ghost tree. # Arguments -* `forest`:\\[in,out\\] Must be created with t8_forest_init and specialized with t8\\_forest\\_set\\_* calls first. +* `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 -void t8_forest_commit (t8_forest_t forest); +t8_gloidx_t t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_forest_commit(forest) - @ccall libt8.t8_forest_commit(forest::t8_forest_t)::Cvoid +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_forest_get_maxlevel(forest) + t8_forest_get_tree(forest, ltree_id) -Return the maximum allowed refinement level for any element in a forest. +Return a pointer to a tree in a forest. # Arguments -* `forest`:\\[in\\] A forest. +* `forest`:\\[in\\] The forest. +* `ltree_id`:\\[in\\] The local id of the tree. # 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. +A pointer to the tree with local id *ltree_id*. *forest* must be committed before calling this function. ### Prototype ```c -int t8_forest_get_maxlevel (const t8_forest_t forest); +t8_tree_t t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id); ``` """ -function t8_forest_get_maxlevel(forest) - @ccall libt8.t8_forest_get_maxlevel(forest::t8_forest_t)::Cint +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_forest_get_local_num_elements(forest) + t8_forest_get_tree_vertices(forest, ltreeid) -Return the number of process local elements in the forest. +Return a pointer to the vertex coordinates of a tree. # Arguments -* `forest`:\\[in\\] A forest. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The id of a local tree. # Returns -The number of elements on this process in *forest*. *forest* must be committed before calling this function. +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_forest_get_local_num_elements (const t8_forest_t forest); +double * t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -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_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_forest_get_global_num_elements(forest) + t8_forest_tree_get_leaves(forest, ltree_id) -Return the number of global elements in the forest. +Return the array of leaf elements of a local tree in a forest. # Arguments -* `forest`:\\[in\\] A forest. +* `forest`:\\[in\\] The forest. +* `ltree_id`:\\[in\\] The local id of a local tree of *forest*. # Returns -The number of elements (summed over all processes) in *forest*. *forest* must be committed before calling this function. +An array of [`t8_element_t`](@ref) * storing all leaf elements of this tree. ### Prototype ```c -t8_gloidx_t t8_forest_get_global_num_elements (const t8_forest_t forest); +t8_element_array_t * t8_forest_tree_get_leaves (const t8_forest_t forest, const t8_locidx_t ltree_id); ``` """ -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_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_forest_get_num_ghosts(forest) + t8_forest_get_cmesh(forest) -Return the number of ghost elements of a forest. +Return a cmesh associated to a forest. # 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. - +The cmesh associated to the forest. ### Prototype ```c -t8_locidx_t t8_forest_get_num_ghosts (const t8_forest_t forest); +t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); ``` """ -function t8_forest_get_num_ghosts(forest) - @ccall libt8.t8_forest_get_num_ghosts(forest::t8_forest_t)::t8_locidx_t +function t8_forest_get_cmesh(forest) + @ccall libt8.t8_forest_get_cmesh(forest::t8_forest_t)::t8_cmesh_t end """ - t8_forest_get_eclass(forest, ltreeid) + t8_forest_get_element(forest, lelement_id, ltreeid) -Return the element class of a forest local tree. +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. -* `ltreeid`:\\[in\\] The local id of a tree in *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 -The element class of the tree *ltreeid*. *forest* must be committed before calling this function. +A pointer to the element. NULL if this element does not exist. ### Prototype ```c -t8_eclass_t t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid); +t8_element_t * t8_forest_get_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_locidx_t *ltreeid); ``` """ -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_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_forest_get_local_id(forest, gtreeid) + t8_forest_get_element_in_tree(forest, ltreeid, leid_in_tree) -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. +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 * `forest`:\\[in\\] The forest. -* `gtreeid`:\\[in\\] The global id of a tree. +* `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 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. - +A pointer to the element. ### Prototype ```c -t8_locidx_t t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); +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_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_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_forest_get_local_or_ghost_id(forest, gtreeid) + t8_forest_get_tree_num_elements(forest, ltreeid) -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. +Return the number of elements of a tree. # Arguments * `forest`:\\[in\\] The forest. -* `gtreeid`:\\[in\\] The global id of a tree. +* `ltreeid`:\\[in\\] A local 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. - +The number of elements in the local tree *ltreeid*. ### Prototype ```c -t8_locidx_t t8_forest_get_local_or_ghost_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); +t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -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_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_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) + t8_forest_get_tree_element_offset(forest, ltreeid) -Given the local id of a tree in a forest, compute the tree's local id in the associated cmesh. +Return the element offset of a local tree, that is the number of elements in all trees with smaller local treeid. !!! note - For forest local trees, this is the inverse function of t8_forest_cmesh_ltreeid_to_ltreeid. + *forest* must be committed before calling this function. # Arguments * `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree or ghost in the forest. +* `ltreeid`:\\[in\\] A local id of a tree. # 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 number of leaf elements on all local tree with id < *ltreeid*. ### Prototype ```c -t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, t8_locidx_t ltreeid); +t8_locidx_t t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -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_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_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_forest_get_tree_element_count(tree) - For forest local trees, this is the inverse function of t8_forest_ltreeid_to_cmesh_ltreeid. +Return the number of elements of a tree. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in the coarse mesh of *forest*. +* `tree`:\\[in\\] A tree in a 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. - +The number of elements of that tree. ### Prototype ```c -t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, t8_locidx_t lctreeid); +t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); ``` """ -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_forest_get_tree_element_count(tree) + @ccall libt8.t8_forest_get_tree_element_count(tree::t8_tree_t)::t8_locidx_t end """ - t8_forest_get_coarse_tree(forest, ltreeid) + t8_forest_get_tree_class(forest, ltreeid) -Given the local id of a tree in a forest, return the coarse tree of the cmesh that corresponds to this tree. +Return the eclass of a tree in a forest. # Arguments * `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in the forest. +* `ltreeid`:\\[in\\] The local id of a tree (local or ghost) in *forest*. # Returns -The coarse tree that matches the forest tree with local id *ltreeid*. +The element class of the tree with local id *ltreeid*. ### Prototype ```c -t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid); +t8_eclass_t t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -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_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_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 + t8_forest_get_first_local_element_id(forest) - *forest* must be committed before calling this function. +Compute the global index of the first local element of a forest. This function is collective. # 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*. -* `neighbor_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_face`:\\[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. +* `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. ### 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); +t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); ``` """ -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_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_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced, gneigh_tree) + 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_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); +t8_scheme_cxx_t * t8_forest_get_scheme (const t8_forest_t forest); ``` """ -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) - @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})::Cvoid +function t8_forest_get_scheme(forest) + @ccall libt8.t8_forest_get_scheme(forest::t8_forest_t)::Ptr{t8_scheme_cxx_t} end """ - t8_forest_ghost_exchange_data(forest, element_data) + t8_forest_get_eclass_scheme(forest, eclass) -Exchange ghost information of user defined element data. +Return the eclass scheme of a given element class associated to a forest. !!! note - This function is collective and hence must be called by all processes in the forest's MPI Communicator. + The forest is not required to have trees of class *eclass*. # 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. +* `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) + ### Prototype ```c -void t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data); +t8_eclass_scheme_c * t8_forest_get_eclass_scheme (t8_forest_t forest, t8_eclass_t eclass); ``` """ -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_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_forest_ghost_print(forest) + t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) -Print the ghost structure of a forest. Only used for debugging. +Return the eclass of the tree in which a face neighbor of a given element lies. +# 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*. +# Returns +The local tree id of the tree in which the face neighbor of *elem* across *face* lies. ### Prototype ```c -void t8_forest_ghost_print (t8_forest_t forest); +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_forest_ghost_print(forest) - @ccall libt8.t8_forest_ghost_print(forest::t8_forest_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_forest_partition_cmesh(forest, comm, set_profiling) + t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_scheme, 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. + +# 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*. +# Returns +The global tree-id of the tree in which *neigh* is in. -1 if there exists no neighbor across that face. ### Prototype ```c -void t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profiling); +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_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_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_forest_get_mpicomm(forest) + t8_forest_iterate(forest) ### Prototype ```c -sc_MPI_Comm t8_forest_get_mpicomm (const t8_forest_t forest); +void t8_forest_iterate (t8_forest_t forest); ``` """ -function t8_forest_get_mpicomm(forest) - @ccall libt8.t8_forest_get_mpicomm(forest::t8_forest_t)::Cint +function t8_forest_iterate(forest) + @ccall libt8.t8_forest_iterate(forest::t8_forest_t)::Cvoid end """ - t8_forest_get_first_local_tree_id(forest) + t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) -Return the global id of the first local tree of a forest. +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 * `forest`:\\[in\\] The forest. -# Returns -The global id of the first local tree in *forest*. +* `ltree_id`:\\[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 -t8_gloidx_t t8_forest_get_first_local_tree_id (const t8_forest_t forest); +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_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_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_forest_get_num_local_trees(forest) - -Return the number of local trees of a given forest. + t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) -# Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of local trees of that forest. ### Prototype ```c -t8_locidx_t t8_forest_get_num_local_trees (const t8_forest_t forest); +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_forest_get_num_local_trees(forest) - @ccall libt8.t8_forest_get_num_local_trees(forest::t8_forest_t)::t8_locidx_t +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_forest_get_num_ghost_trees(forest) + t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) -Return the number of ghost trees of a given forest. +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 # Arguments -* `forest`:\\[in\\] The forest. +* `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 number of ghost trees of that forest. +A new forest that is adapted from *forest_from*. ### Prototype ```c -t8_locidx_t t8_forest_get_num_ghost_trees (const t8_forest_t forest); +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_forest_get_num_ghost_trees(forest) - @ccall libt8.t8_forest_get_num_ghost_trees(forest::t8_forest_t)::t8_locidx_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_forest_get_num_global_trees(forest) + t8_forest_ref(forest) -Return the number of global trees of a given forest. +Increase the reference counter of a forest. # Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of global trees of that forest. +* `forest`:\\[in,out\\] On input, this forest must exist with positive reference count. It may be in any state. ### Prototype ```c -t8_gloidx_t t8_forest_get_num_global_trees (const t8_forest_t forest); +void t8_forest_ref (t8_forest_t forest); ``` """ -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_forest_ref(forest) + @ccall libt8.t8_forest_ref(forest::t8_forest_t)::Cvoid end """ - t8_forest_global_tree_id(forest, ltreeid) + t8_forest_unref(pforest) -Return the global id of a local tree or a ghost tree. +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 -* `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. - +* `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 -t8_gloidx_t t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid); +void t8_forest_unref (t8_forest_t *pforest); ``` """ -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_forest_unref(pforest) + @ccall libt8.t8_forest_unref(pforest::Ptr{t8_forest_t})::Cvoid end """ - t8_forest_get_tree(forest, ltree_id) + t8_forest_get_dimension(forest) -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 -t8_tree_t t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id); +int t8_forest_get_dimension (const t8_forest_t forest); ``` """ -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_forest_get_dimension(forest) + @ccall libt8.t8_forest_get_dimension(forest::t8_forest_t)::Cint end """ - t8_forest_get_tree_vertices(forest, ltreeid) - -Return a pointer to the vertex coordinates of a tree. + t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) -# 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. ### Prototype ```c -double * t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid); +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_get_tree_vertices(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_vertices(forest::t8_forest_t, ltreeid::t8_locidx_t)::Ptr{Cdouble} +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_forest_tree_get_leaves(forest, ltree_id) - -Return the array of leaf elements of a local tree in a forest. + t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) -# 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. ### Prototype ```c -t8_element_array_t * t8_forest_tree_get_leaves (const t8_forest_t forest, const t8_locidx_t ltree_id); +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_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_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_forest_get_cmesh(forest) - -Return a cmesh associated to a forest. + t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) -# 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_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_forest_get_cmesh(forest) - @ccall libt8.t8_forest_get_cmesh(forest::t8_forest_t)::t8_cmesh_t +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_forest_get_element(forest, lelement_id, ltreeid) - -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. + t8_forest_element_centroid(forest, ltreeid, element, coordinates) -# 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 -t8_element_t * t8_forest_get_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_locidx_t *ltreeid); +void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); ``` """ -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_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_forest_get_element_in_tree(forest, ltreeid, leid_in_tree) - -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. + t8_forest_element_diam(forest, ltreeid, 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. -# Returns -A pointer to the 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); +double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, 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_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_forest_get_tree_num_elements(forest, ltreeid) - -Return the number of elements of a tree. + t8_forest_element_volume(forest, ltreeid, element) -# Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] A local id of a tree. -# Returns -The number of elements in the local tree *ltreeid*. ### Prototype ```c -t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, t8_locidx_t ltreeid); +double t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); ``` """ -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_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_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 - - *forest* must be committed before calling this function. + t8_forest_element_face_area(forest, ltreeid, element, face) -# Arguments -* `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 -t8_locidx_t t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid); +double t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, 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_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_forest_get_tree_element_count(tree) - -Return the number of elements of a tree. + t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) -# Arguments -* `tree`:\\[in\\] A tree in a forest. -# Returns -The number of elements of that tree. ### Prototype ```c -t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); +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_forest_get_tree_element_count(tree) - @ccall libt8.t8_forest_get_tree_element_count(tree::t8_tree_t)::t8_locidx_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_forest_get_tree_class(forest, ltreeid) - -Return the eclass of a tree in a forest. + t8_forest_element_face_normal(forest, ltreeid, element, face, normal) -# Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree (local or ghost) in *forest*. -# Returns -The element class of the tree with local id *ltreeid*. ### Prototype ```c -t8_eclass_t t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid); +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_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_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_forest_get_first_local_element_id(forest) + t8_forest_ghost -Compute the global index of the first local element of a forest. This function is collective. +| 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 + +const t8_forest_ghost_t = Ptr{t8_forest_ghost} + +""" + t8_forest_ghost_init(pghost, ghost_type) -# 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. ### Prototype ```c -t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); +void t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type); ``` """ -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_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_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) + t8_forest_ghost_num_trees(forest) ### Prototype ```c -t8_scheme_cxx_t * t8_forest_get_scheme (const t8_forest_t forest); +t8_locidx_t t8_forest_ghost_num_trees (const t8_forest_t forest); ``` """ -function t8_forest_get_scheme(forest) - @ccall libt8.t8_forest_get_scheme(forest::t8_forest_t)::Ptr{t8_scheme_cxx_t} +function t8_forest_ghost_num_trees(forest) + @ccall libt8.t8_forest_ghost_num_trees(forest::t8_forest_t)::t8_locidx_t end """ - t8_forest_get_eclass_scheme(forest, eclass) + t8_forest_ghost_get_tree_element_offset(forest, lghost_tree) -Return the eclass scheme of a given element class associated to a forest. +Return the element offset of a ghost tree. !!! note - The forest is not required to have trees of class *eclass*. + forest must be committed before calling this function. # Arguments -* `forest.`:\\[in\\] A committed forest. -* `eclass.`:\\[in\\] An element class. +* `forest`:\\[in\\] The forest with constructed ghost layer. +* `lghost_tree`:\\[in\\] A local ghost id of a ghost tree. # Returns -The eclass scheme of *eclass* associated to forest. -# See also -[`t8_forest_set_scheme`](@ref) +The element offset of this ghost tree. +### Prototype +```c +t8_locidx_t t8_forest_ghost_get_tree_element_offset (t8_forest_t forest, t8_locidx_t lghost_tree); +``` +""" +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_forest_ghost_tree_num_elements(forest, lghost_tree) ### Prototype ```c -t8_eclass_scheme_c * t8_forest_get_eclass_scheme (t8_forest_t forest, t8_eclass_t eclass); +t8_locidx_t t8_forest_ghost_tree_num_elements (t8_forest_t forest, t8_locidx_t lghost_tree); ``` """ -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_forest_ghost_tree_num_elements(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_tree_num_elements(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_locidx_t end """ - t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) + t8_forest_ghost_get_tree_elements(forest, lghost_tree) -Return the eclass of the tree in which a face neighbor of a given element lies. +Get a pointer to the ghost element array of a ghost tree. # 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*. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. # Returns -The local tree id of the tree in which the face neighbor of *elem* across *face* lies. +A pointer to the array of ghost elements of the tree. *forest* must be committed before calling this function. ### 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); +t8_element_array_t * t8_forest_ghost_get_tree_elements (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -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_forest_ghost_get_tree_elements(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_tree_elements(forest::t8_forest_t, lghost_tree::t8_locidx_t)::Ptr{t8_element_array_t} end """ - t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_scheme, face, neigh_face) + t8_forest_ghost_get_ghost_treeid(forest, gtreeid) -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. +Given a global tree compute the ghost local tree id of it. # 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*. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `gtreeid`:\\[in\\] A global tree in *forest*. # Returns -The global tree-id of the tree in which *neigh* is in. -1 if there exists no neighbor across that face. +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_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); +t8_locidx_t t8_forest_ghost_get_ghost_treeid (t8_forest_t forest, t8_gloidx_t gtreeid); ``` """ -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_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_forest_iterate(forest) + t8_forest_ghost_get_tree_class(forest, lghost_tree) ### Prototype ```c -void t8_forest_iterate (t8_forest_t forest); +t8_eclass_t t8_forest_ghost_get_tree_class (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -function t8_forest_iterate(forest) - @ccall libt8.t8_forest_iterate(forest::t8_forest_t)::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_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_forest_ghost_get_global_treeid(forest, lghost_tree) - 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. +Given a local ghost tree compute the global tree id of it. # Arguments -* `forest`:\\[in\\] The forest. -* `ltree_id`:\\[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. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. +# 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. + ### 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); +t8_gloidx_t t8_forest_ghost_get_global_treeid (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -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_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_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) + t8_forest_ghost_get_element(forest, lghost_tree, lelement) ### 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); +t8_element_t * t8_forest_ghost_get_element (t8_forest_t forest, t8_locidx_t lghost_tree, t8_locidx_t lelement); ``` """ -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_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_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) - -Build a adapted forest from another forest. - -!!! note + t8_forest_ghost_get_remotes(forest, num_remotes) - This is equivalent to calling t8_forest_init, t8_forest_set_adapt, t8_forest_set_ghost, and t8_forest_commit +Return the array of remote ranks. # 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. +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `num_remotes`:\\[in,out\\] On output the number of remote ranks is stored here. # Returns -A new forest that is adapted from *forest_from*. +The array of remote ranks in ascending order. ### 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_forest_ghost_get_remotes (t8_forest_t forest, int *num_remotes); ``` """ -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_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_forest_ref(forest) + t8_forest_ghost_remote_first_tree(forest, remote) -Increase the reference counter of a forest. +Return the first local ghost tree of a remote rank. # Arguments -* `forest`:\\[in,out\\] On input, this forest must exist with positive reference count. It may be in any state. +* `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_forest_ref (t8_forest_t forest); +t8_locidx_t t8_forest_ghost_remote_first_tree (t8_forest_t forest, int remote); ``` """ -function t8_forest_ref(forest) - @ccall libt8.t8_forest_ref(forest::t8_forest_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_forest_unref(pforest) + t8_forest_ghost_remote_first_elem(forest, remote) -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 local index of the first ghost element that belongs to a given remote rank. # 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. +* `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_forest_unref (t8_forest_t *pforest); +t8_locidx_t t8_forest_ghost_remote_first_elem (t8_forest_t forest, int remote); ``` """ -function t8_forest_unref(pforest) - @ccall libt8.t8_forest_unref(pforest::Ptr{t8_forest_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_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) - -### 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 + t8_forest_ghost_ref(ghost) -""" - t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) +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_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_forest_ghost_ref (t8_forest_ghost_t ghost); ``` """ -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_forest_ghost_ref(ghost) + @ccall libt8.t8_forest_ghost_ref(ghost::t8_forest_ghost_t)::Cvoid end """ - t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) + t8_forest_ghost_unref(pghost) +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 +* `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_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_forest_ghost_unref (t8_forest_ghost_t *pghost); ``` """ -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_forest_ghost_unref(pghost) + @ccall libt8.t8_forest_ghost_unref(pghost::Ptr{t8_forest_ghost_t})::Cvoid end """ - t8_forest_element_centroid(forest, ltreeid, element, coordinates) + t8_forest_ghost_destroy(pghost) +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 +* `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_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); +void t8_forest_ghost_destroy (t8_forest_ghost_t *pghost); ``` """ -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_forest_ghost_destroy(pghost) + @ccall libt8.t8_forest_ghost_destroy(pghost::Ptr{t8_forest_ghost_t})::Cvoid end """ - t8_forest_element_diam(forest, ltreeid, element) + t8_forest_ghost_create(forest) -### Prototype -```c -double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); -``` -""" -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 +Create one layer of ghost elements for a forest. -""" - t8_forest_element_volume(forest, ltreeid, element) +# Arguments +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +# See also +[`t8_forest_set_ghost`](@ref) ### Prototype ```c -double t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); +void t8_forest_ghost_create (t8_forest_t forest); ``` """ -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_forest_ghost_create(forest) + @ccall libt8.t8_forest_ghost_create(forest::t8_forest_t)::Cvoid end """ - t8_forest_element_face_area(forest, ltreeid, element, face) + t8_forest_ghost_create_balanced_only(forest) -### Prototype -```c -double t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, 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 -end +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 -""" - t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) +!!! note + + The user should prefer t8_forest_ghost_create even for balanced forests. +# Arguments +* `forest`:\\[in,out\\] The balanced forest/ *forest* must be committed before calling this function. ### 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_forest_ghost_create_balanced_only (t8_forest_t forest); ``` """ -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_forest_ghost_create_balanced_only(forest) + @ccall libt8.t8_forest_ghost_create_balanced_only(forest::t8_forest_t)::Cvoid end """ - t8_forest_element_face_normal(forest, ltreeid, element, face, normal) + t8_forest_ghost_create_topdown(forest) ### 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]); +void t8_forest_ghost_create_topdown (t8_forest_t forest); ``` """ -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_forest_ghost_create_topdown(forest) + @ccall libt8.t8_forest_ghost_create_topdown(forest::t8_forest_t)::Cvoid end """ @@ -15361,8 +16706,39 @@ 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_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 , void * query , sc_array_t * query_indices , int * query_matches , const size_t num_active_queries ) -const t8_forest_search_query_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*. + +# 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} """ t8_forest_split_array(element, leaf_elements, offsets) @@ -15393,11 +16769,11 @@ end ### Prototype ```c -void t8_forest_search (t8_forest_t forest, t8_forest_search_query_fn search_fn, t8_forest_search_query_fn query_fn, sc_array_t *queries); +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_forest_search(forest, search_fn, query_fn, queries) - @ccall libt8.t8_forest_search(forest::t8_forest_t, search_fn::t8_forest_search_query_fn, query_fn::t8_forest_search_query_fn, queries::Ptr{sc_array_t})::Cvoid + @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 """ @@ -15504,6 +16880,17 @@ end """ t8_forest_partition_data(forest_from, forest_to, data_in, data_out) +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_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 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); @@ -15694,70 +17081,65 @@ end ### 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 - -""" - 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. - -!!! note - - If t8code was not configured with vtk, use t8_forest_vtk_write_file - -# 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). -### 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); -``` -""" -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_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, 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 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 -* `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 -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); +double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest); ``` """ -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_profile_get_ghostexchange_waittime(forest) + @ccall libt8.t8_forest_profile_get_ghostexchange_waittime(forest::t8_forest_t)::Cdouble +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 + +const t8_forest_ghost_struct_t = t8_forest_ghost + """ t8_geometry_type @@ -15866,24 +17248,6 @@ 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_geom_get_dimension(geom) - -Get the dimension of a geometry. - -# Arguments -* `geom`:\\[in\\] A geometry. -# Returns -The dimension of *geom*. -### Prototype -```c -int t8_geom_get_dimension (const t8_geometry_c *geom); -``` -""" -function t8_geom_get_dimension(geom) - @ccall libt8.t8_geom_get_dimension(geom::Ptr{t8_geometry_c})::Cint -end - """ t8_geom_get_name(geom) @@ -15967,10 +17331,10 @@ 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 barycentric coordinates. +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 used for the interpolation +* `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) @@ -16083,6 +17447,45 @@ function t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersec @ccall libt8.t8_geom_get_tet_face_intersection(face_index::Cint, ref_coords::Ptr{Cdouble}, face_intersection::Ptr{Cdouble})::Cvoid end +""" + t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) + +Calculates the scaling factor for the displacement of an edge over a face of a prism element. + +# 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. +### Prototype +```c +double t8_geom_get_scaling_factor_of_edge_on_face_prism (int edge_index, int face_index, const double *ref_coords); +``` +""" +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_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) + +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 +double t8_geom_get_scaling_factor_face_through_volume_prism (const int face, const double *ref_coords); +``` +""" +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_vertex_point_inside(vertex_coords, point, tolerance) @@ -16211,6 +17614,94 @@ 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. + +!!! note + + If t8code was not configured with vtk, use t8_forest_vtk_write_file + +# 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). +### 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); +``` +""" +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_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, 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 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 +* `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 +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_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_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) + +### Prototype +```c +int t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm); +``` +""" +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_cmesh_vtk_write_file(cmesh, fileprefix) + +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 +* `cmesh`:\\[in\\] The cmesh +* `fileprefix`:\\[in\\] The prefix of the output files +# Returns +int +### Prototype +```c +int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); +``` +""" +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 ) """ Definition of an analytic geometry function. This function maps reference coordinates to physical coordinates. @@ -16242,6 +17733,12 @@ Definition for the jacobian of an analytic geometry function. . +```c++ + \\mathrm{dim} +``` + +to map. + ```c++ \\mathrm{dim} \\cdot 3 ``` @@ -16287,8 +17784,8 @@ is # Arguments * `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 points in -* `num_coords`:\\[in\\] Amount of points of /f\$ {dim} /f\$ to map. +* `ref_coords`:\\[in\\] Array of tree dimension x *num_coords* many entries, specifying points in +* `num_coords`:\\[in\\] Amount of points of * `jacobian`:\\[out\\] The jacobian at *ref_coords*. Array of size * `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. @@ -16310,6 +17807,10 @@ const t8_geom_load_tree_data_fn = Ptr{Cvoid} """Definition for the negative volume function.""" const t8_geom_tree_negative_volume_fn = Ptr{Cvoid} +# typedef int ( * t8_geom_tree_compatible_fn ) ( ) +"""Definition for the tree compatible function.""" +const t8_geom_tree_compatible_fn = Ptr{Cvoid} + """ t8_geometry_analytic_destroy(geom) @@ -16323,15 +17824,15 @@ function t8_geometry_analytic_destroy(geom) end """ - t8_geometry_analytic_new(dim, name, analytical, jacobian, load_tree_data, tree_negative_volume, user_data) + t8_geometry_analytic_new(name, analytical, jacobian, load_tree_data, tree_negative_volume, tree_compatible, user_data) ### Prototype ```c -t8_geometry_c * t8_geometry_analytic_new (int dim, 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, const void *user_data); +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(dim, name, analytical, jacobian, load_tree_data, tree_negative_volume, user_data) - @ccall libt8.t8_geometry_analytic_new(dim::Cint, 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, user_data::Ptr{Cvoid})::Ptr{Cint} +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} end """ @@ -16398,19 +17899,19 @@ end # no prototype is found for this function at t8_geometry_examples.h:57:1, please use with caution """ - t8_geometry_quadrangulated_spherical_surface_new() + t8_geometry_tessellated_spherical_surface_new() -Create a new quadrangulated\\_spherical\\_surface geometry. +Create a new tessellated\\_spherical\\_surface geometry. # Returns A pointer to an allocated geometry struct. ### Prototype ```c -t8_geometry_c * t8_geometry_quadrangulated_spherical_surface_new (); +t8_geometry_c * t8_geometry_tessellated_spherical_surface_new (); ``` """ -function t8_geometry_quadrangulated_spherical_surface_new() - @ccall libt8.t8_geometry_quadrangulated_spherical_surface_new()::Ptr{t8_geometry_c} +function t8_geometry_tessellated_spherical_surface_new() + @ccall libt8.t8_geometry_tessellated_spherical_surface_new()::Ptr{t8_geometry_c} end # no prototype is found for this function at t8_geometry_examples.h:63:1, please use with caution @@ -16464,22 +17965,21 @@ function t8_geometry_cubed_sphere_new() @ccall libt8.t8_geometry_cubed_sphere_new()::Ptr{t8_geometry_c} end +# no prototype is found for this function at t8_geometry_lagrange.h:47:1, please use with caution """ - t8_geometry_lagrange_new(dim) + t8_geometry_lagrange_new() -Create a new Lagrange geometry of a given dimension. The geometry is compatible with all tree types and uses as many vertices as the number of Lagrange basis functions used for the mapping. The vertices are saved via the t8_cmesh_set_tree_vertices function. Sets the dimension and the name to "t8\\_geom\\_lagrange\\_{dim}" +Create a new Lagrange geometry of a given dimension. The geometry is compatible with all tree types and uses as many vertices as the number of Lagrange basis functions used for the mapping. The vertices are saved via the t8_cmesh_set_tree_vertices function. Sets the name to "t8\\_geom\\_lagrange" -# Arguments -* `dim`:\\[in\\] 0 <= *dimension* <= 3. The dimension. # Returns -A pointer to an allocated t8\\_geometry\\_lagrange struct, as if the t8_geometry_lagrange (int dim) constructor was called. +A pointer to an allocated t8\\_geometry\\_lagrange struct, as if the t8_geometry_lagrange () constructor was called. ### Prototype ```c -t8_geometry_c * t8_geometry_lagrange_new (int dim); +t8_geometry_c * t8_geometry_lagrange_new (); ``` """ -function t8_geometry_lagrange_new(dim) - @ccall libt8.t8_geometry_lagrange_new(dim::Cint)::Ptr{t8_geometry_c} +function t8_geometry_lagrange_new() + @ccall libt8.t8_geometry_lagrange_new()::Ptr{t8_geometry_c} end """ @@ -16498,22 +17998,21 @@ function t8_geometry_lagrange_destroy(geom) @ccall libt8.t8_geometry_lagrange_destroy(geom::Ptr{Ptr{t8_geometry_c}})::Cvoid end +# no prototype is found for this function at t8_geometry_linear.h:45:1, please use with caution """ - t8_geometry_linear_new(dim) + t8_geometry_linear_new() -Create a new linear geometry of a given dimension. The geometry is only all tree types and as many vertices as the tree type has. The vertices are saved via the t8_cmesh_set_tree_vertices function. Sets the dimension and the name to "t8\\_geom\\_linear\\_{dim}" +Create a new linear geometry. The geometry is only all tree types and as many vertices as the tree type has. The vertices are saved via the t8_cmesh_set_tree_vertices function. Sets the dimension and the name to "t8\\_geom\\_linear" -# Arguments -* `dim`:\\[in\\] 0 <= *dimension* <= 3. The dimension. # Returns -A pointer to an allocated t8\\_geometry\\_linear struct, as if the t8_geometry_linear (int dim) constructor was called. +A pointer to an allocated t8\\_geometry\\_linear struct, as if the t8_geometry_linear () constructor was called. ### Prototype ```c -t8_geometry_c * t8_geometry_linear_new (int dim); +t8_geometry_c * t8_geometry_linear_new (); ``` """ -function t8_geometry_linear_new(dim) - @ccall libt8.t8_geometry_linear_new(dim::Cint)::Ptr{t8_geometry_c} +function t8_geometry_linear_new() + @ccall libt8.t8_geometry_linear_new()::Ptr{t8_geometry_c} end """ @@ -16532,22 +18031,21 @@ function t8_geometry_linear_destroy(geom) @ccall libt8.t8_geometry_linear_destroy(geom::Ptr{Ptr{t8_geometry_c}})::Cvoid end +# no prototype is found for this function at t8_geometry_linear_axis_aligned.h:47:1, please use with caution """ - t8_geometry_linear_axis_aligned_new(dim) + t8_geometry_linear_axis_aligned_new() Create a new linear, axis-aligned geometry of a given dimension. The geometry is only viable for line/quad/hex elements and uses two vertices (min and max coords) per tree. The vertices are saved via the t8_cmesh_set_tree_vertices function. -# Arguments -* `dim`:\\[in\\] 0 <= *dimension* <= 3. The dimension. # Returns -A pointer to an allocated t8\\_geometry\\_linear\\_axis\\_aligned struct, as if the t8\\_geometry\\_linear\\_axis\\_aligned (int dimension) constructor was called. +A pointer to an allocated t8\\_geometry\\_linear\\_axis\\_aligned struct, as if the t8\\_geometry\\_linear\\_axis\\_aligned () constructor was called. ### Prototype ```c -t8_geometry_c * t8_geometry_linear_axis_aligned_new (int dim); +t8_geometry_c * t8_geometry_linear_axis_aligned_new (); ``` """ -function t8_geometry_linear_axis_aligned_new(dim) - @ccall libt8.t8_geometry_linear_axis_aligned_new(dim::Cint)::Ptr{t8_geometry_c} +function t8_geometry_linear_axis_aligned_new() + @ccall libt8.t8_geometry_linear_axis_aligned_new()::Ptr{t8_geometry_c} end """ @@ -16566,22 +18064,21 @@ function t8_geometry_linear_axis_aligned_destroy(geom) @ccall libt8.t8_geometry_linear_axis_aligned_destroy(geom::Ptr{Ptr{t8_geometry_c}})::Cvoid end +# no prototype is found for this function at t8_geometry_zero.h:45:1, please use with caution """ - t8_geometry_zero_new(dim) + t8_geometry_zero_new() -Create a new zero geometry of a given dimension. The geometry is only all tree types and as many vertices as the tree type has. The vertices are saved via the t8_cmesh_set_tree_vertices function. Sets the dimension and the name to "t8\\_geom\\_zero\\_{dim}" +Create a new zero geometry. The geometry is only all tree types and as many vertices as the tree type has. The vertices are saved via the t8_cmesh_set_tree_vertices function. Sets the dimension and the name to "t8\\_geom\\_zero\\_" -# Arguments -* `dim`:\\[in\\] 0 <= *dimension* <= 3. The dimension. # Returns -A pointer to an allocated t8\\_geometry\\_zero struct, as if the t8_geometry_zero (int dim) constructor was called. +A pointer to an allocated t8\\_geometry\\_zero struct, as if the t8_geometry_zero () constructor was called. ### Prototype ```c -t8_geometry_c * t8_geometry_zero_new (int dim); +t8_geometry_c * t8_geometry_zero_new (); ``` """ -function t8_geometry_zero_new(dim) - @ccall libt8.t8_geometry_zero_new(dim::Cint)::Ptr{t8_geometry_c} +function t8_geometry_zero_new() + @ccall libt8.t8_geometry_zero_new()::Ptr{t8_geometry_c} end """ @@ -16617,7 +18114,7 @@ end """ t8_eclass_scheme_is_default(ts) -Check whether a given eclass\\_scheme is on of the default schemes. +Check whether a given eclass\\_scheme is one of the default schemes. # Arguments * `ts`:\\[in\\] A (pointer to a) scheme @@ -16632,13 +18129,17 @@ 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 = "mpicc" +const SC_CC = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc" -const SC_CFLAGS = "-O3" +const SC_CFLAGS = " " -const SC_CPP = "mpicc -E" +const SC_CPP = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc -E" -const SC_CPPFLAGS = "-I/workspace/destdir/include" +const SC_CPPFLAGS = "" + +const SC_HAVE_ZLIB = 1 + +const SC_ENABLE_PTHREAD = 1 const SC_ENABLE_MEMALIGN = 1 @@ -16648,8 +18149,6 @@ const SC_ENABLE_MPICOMMSHARED = 1 const SC_ENABLE_MPIIO = 1 -const SC_ENABLE_MPISHARED = 1 - const SC_ENABLE_MPITHREAD = 1 const SC_ENABLE_MPIWINSHARED = 1 @@ -16660,51 +18159,29 @@ 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_BASENAME = 1 - -const SC_HAVE_DIRNAME = 1 - const SC_HAVE_FSYNC = 1 -const SC_HAVE_GETTIMEOFDAY = 1 - -const SC_HAVE_GNU_QSORT_R = 1 - -const SC_HAVE_MATH = 1 - -const SC_HAVE_POSIX_MEMALIGN = 1 +const SC_HAVE_FABS = 1 const SC_HAVE_QSORT_R = 1 -const SC_HAVE_STRTOK_R = 1 - -const SC_HAVE_STRTOL = 1 +const SC_HAVE_GNU_QSORT_R = 1 const SC_HAVE_STRTOLL = 1 -const SC_HAVE_ZLIB = 1 - -const SC_LDFLAGS = "-L/workspace/destdir/lib" - -const SC_LIBS = "-lz -lm " - -const SC_LT_OBJDIR = ".libs/" - -const SC_MEMALIGN = 1 +const SC_HAVE_GETTIMEOFDAY = 1 const SC_SIZEOF_VOID_P = 8 const SC_MEMALIGN_BYTES = SC_SIZEOF_VOID_P -const SC_MPI = 1 +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_MPIIO = 1 +const SC_LIBS = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/lib/libz.so m" const SC_PACKAGE = "libsc" @@ -16712,39 +18189,31 @@ const SC_PACKAGE_BUGREPORT = "p4est@ins.uni-bonn.de" const SC_PACKAGE_NAME = "libsc" -const SC_PACKAGE_STRING = "libsc 2.8.5.406-2b20" +const SC_PACKAGE_STRING = "libsc 0.0.0" const SC_PACKAGE_TARNAME = "libsc" const SC_PACKAGE_URL = "" -const SC_PACKAGE_VERSION = "2.8.5.406-2b20" +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_INT = 4 - const SC_SIZEOF_UNSIGNED_LONG = 8 const SC_SIZEOF_UNSIGNED_LONG_LONG = 8 -const SC_STDC_HEADERS = 1 +const SC_VERSION = "0.0.0" -const SC_USE_COUNTERS = 1 +const SC_VERSION_MAJOR = 0 -const SC_USE_REALLOC = 1 - -const SC_USING_AUTOCONF = 1 - -const SC_VERSION = "2.8.5.406-2b20" - -const SC_VERSION_MAJOR = 2 - -const SC_VERSION_MINOR = 8 +const SC_VERSION_MINOR = 0 @@ -16894,87 +18363,6 @@ const T8_PRECISION_SQRT_EPS = sqrt(T8_PRECISION_EPS) const T8_CMESH_N_SUPPORTED_MSH_FILE_VERSIONS = 2 -const T8_CC = "mpicc" - -const T8_CFLAGS = "-O3" - -const T8_CPP = "mpicc -E" - -const T8_CPPFLAGS = "-I/workspace/destdir/include" - -const T8_CPPSTD = 1 - -const T8_ENABLE_CPPSTD = 1 - -const T8_ENABLE_MEMALIGN = 1 - -const T8_ENABLE_MPI = 1 - -const T8_ENABLE_MPICOMMSHARED = 1 - -const T8_ENABLE_MPIIO = 1 - -const T8_ENABLE_MPISHARED = 1 - -const T8_ENABLE_MPITHREAD = 1 - -const T8_ENABLE_MPIWINSHARED = 1 - -const T8_HAVE_ALIGNED_ALLOC = 1 - -const T8_HAVE_CXX17 = 1 - -const T8_HAVE_GNU_QSORT_R = 1 - -const T8_HAVE_MATH = 1 - -const T8_HAVE_POSIX_MEMALIGN = 1 - -const T8_HAVE_ZLIB = 1 - -const T8_LDFLAGS = "-L/workspace/destdir/lib" - -const T8_LIBS = "-lz -lm -lstdc++" - -const T8_LT_OBJDIR = ".libs/" - -const T8_MEMALIGN = 1 - -const T8_SIZEOF_VOID_P = 8 - -const T8_MEMALIGN_BYTES = T8_SIZEOF_VOID_P - -const T8_MPI = 1 - -const T8_MPIIO = 1 - -const T8_PACKAGE = "t8" - -const T8_PACKAGE_BUGREPORT = "https://github.com/dlr-amr/t8code" - -const T8_PACKAGE_NAME = "t8" - -const T8_PACKAGE_STRING = "t8 2.0.0" - -const T8_PACKAGE_TARNAME = "t8" - -const T8_PACKAGE_URL = "" - -const T8_PACKAGE_VERSION = "2.0.0" - -const T8_STDC_HEADERS = 1 - -const T8_USING_AUTOCONF = 1 - -const T8_VERSION = "2.0.0" - -const T8_VERSION_MAJOR = 2 - -const T8_VERSION_MINOR = 0 - - -const T8_WITH_NETCDF_PAR = 0 - # Skipping MacroDefinition: T8_MPI_ECLASS_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_eclass_t ) ) , sc_MPI_INT ) const T8_ECLASS_MAX_FACES = 6 @@ -17010,19 +18398,13 @@ const sc_mpi_read = sc_io_read const sc_mpi_write = sc_io_write -const P4EST_BUILD_2D = 1 - -const P4EST_BUILD_3D = 1 - -const P4EST_BUILD_P6EST = 1 - -const P4EST_CC = "mpicc" +const P4EST_CC = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc" -const P4EST_CFLAGS = "-O3" +const P4EST_CFLAGS = " " -const P4EST_CPP = "mpicc -E" +const P4EST_CPP = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc -E" -const P4EST_CPPFLAGS = "-I/workspace/destdir/include" +const P4EST_CPPFLAGS = "" const P4EST_ENABLE_BUILD_2D = 1 @@ -17038,8 +18420,6 @@ const P4EST_ENABLE_MPICOMMSHARED = 1 const P4EST_ENABLE_MPIIO = 1 -const P4EST_ENABLE_MPISHARED = 1 - const P4EST_ENABLE_MPITHREAD = 1 const P4EST_ENABLE_MPIWINSHARED = 1 @@ -17048,31 +18428,13 @@ const P4EST_ENABLE_VTK_BINARY = 1 const P4EST_ENABLE_VTK_COMPRESSION = 1 -const P4EST_HAVE_ALIGNED_ALLOC = 1 - -const P4EST_HAVE_GNU_QSORT_R = 1 - -const P4EST_HAVE_MATH = 1 - -const P4EST_HAVE_POSIX_MEMALIGN = 1 +const P4EST_HAVE_FSYNC = 1 const P4EST_HAVE_ZLIB = 1 -const P4EST_LDFLAGS = "-L/workspace/destdir/lib" - -const P4EST_LIBS = "-lz -lm " - -const P4EST_LT_OBJDIR = ".libs/" - -const P4EST_MEMALIGN = 1 - -const P4EST_SIZEOF_VOID_P = 8 +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_MEMALIGN_BYTES = P4EST_SIZEOF_VOID_P - -const P4EST_MPI = 1 - -const P4EST_MPIIO = 1 +const P4EST_LIBS = " m" const P4EST_PACKAGE = "p4est" @@ -17080,29 +18442,21 @@ const P4EST_PACKAGE_BUGREPORT = "p4est@ins.uni-bonn.de" const P4EST_PACKAGE_NAME = "p4est" -const P4EST_PACKAGE_STRING = "p4est 2.8.5.367-931f" +const P4EST_PACKAGE_STRING = "p4est 0.0.0" const P4EST_PACKAGE_TARNAME = "p4est" const P4EST_PACKAGE_URL = "" -const P4EST_PACKAGE_VERSION = "2.8.5.367-931f" - -const P4EST_STDC_HEADERS = 1 - -const P4EST_USING_AUTOCONF = 1 +const P4EST_PACKAGE_VERSION = "0.0.0" -const P4EST_VERSION = "2.8.5.367-931f" +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_VTK_BINARY = 1 - -const P4EST_VTK_COMPRESSION = 1 - const p4est_qcoord_compare = sc_int32_compare const P4EST_QCOORD_BITS = 32 @@ -17217,14 +18571,34 @@ const T8_CMESH_CAD_FACE_ATTRIBUTE_KEY = T8_CMESH_CAD_EDGE_PARAMETERS_ATTRIBUTE_K const T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY = T8_CMESH_CAD_FACE_ATTRIBUTE_KEY + 1 -const T8_CMESH_LAGRANGE_POLY_DEGREE = T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_FACES +const T8_CMESH_LAGRANGE_POLY_DEGREE_KEY = T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_FACES -const T8_CMESH_NEXT_POSSIBLE_KEY = T8_CMESH_LAGRANGE_POLY_DEGREE + 1 +const T8_CMESH_NEXT_POSSIBLE_KEY = T8_CMESH_LAGRANGE_POLY_DEGREE_KEY + 1 const T8_CPROFILE_NUM_STATS = 11 const T8_SHMEM_BEST_TYPE = SC_SHMEM_WINDOW +const T8_FOREST_FROM_FIRST = 0 + +const T8_FOREST_FROM_COPY = 0 + +const T8_FOREST_FROM_ADAPT = 0x01 + +const T8_FOREST_FROM_PARTITION = 0x02 + +const T8_FOREST_FROM_BALANCE = 0x04 + +const T8_FOREST_FROM_NONE = 0x08 + +const T8_FOREST_FROM_LAST = T8_FOREST_FROM_NONE + +const T8_FOREST_BALANCE_REPART = 1 + +const T8_FOREST_BALANCE_NO_REPART = 2 + +const T8_PROFILE_NUM_STATS = 14 + # exports diff --git a/src/T8code.jl b/src/T8code.jl index f3f73ba..1edce31 100644 --- a/src/T8code.jl +++ b/src/T8code.jl @@ -34,9 +34,9 @@ export t8_hex_len Is intended to return `true`` if the `t8code` library was compiled with MPI enabled. Since T8code.jl currently only supports `t8code` with MPI enabled, -this may always return `true`. +this always returns `true`. """ -uses_mpi() = T8_ENABLE_MPI == 1 +uses_mpi() = true """ T8code.version()