diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57e0934..7058936 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,8 +35,9 @@ jobs: test: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - julia-version: ['1.6', '1', 'nightly'] + julia-version: ['1.9', '1', 'nightly'] julia-arch: [x64, x86] os: [ubuntu-latest, windows-latest, macOS-latest] exclude: diff --git a/.typos.toml b/.typos.toml index 1cb9f7a..748e059 100644 --- a/.typos.toml +++ b/.typos.toml @@ -3,3 +3,4 @@ consistend = "consistend" # is used in API function names... Inout = "Inout" leafs = "leafs" packageid = "packageid" +WRONLY = "WRONLY" # used in "sc_MPI_MODE_WRONLY" diff --git a/Project.toml b/Project.toml index 005fdc3..345432c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "T8code" uuid = "d0cc0030-9a40-4274-8435-baadcfd54fa1" authors = ["Johannes Markert "] -version = "0.7.4" +version = "0.7.5-DEV" [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 = "=3.0.1" +t8code_jll = "=4.0.0" diff --git a/dev/README.md b/dev/README.md index c906bf7..bac11b7 100644 --- a/dev/README.md +++ b/dev/README.md @@ -1,21 +1,94 @@ -# Building Julia bindings of `t8code` with Clang.jl +# Generating Julia bindings of `t8code` with `Clang.jl` -The general process for creating bindings with Clang.jl is as follows: +Working with or deploying a new release of `T8code.jl` involves creating a new build of the +binary package `t8code_jll.jl`, and generating new bindings in `T8code.jl`. + + +## Updating `t8code_jll.jl` + +### For local development + +If you are developing `t8code`, you will probably want to use your locally compiled version +instead of `t8code_jll.jl`, as documented here: +https://github.com/DLR-AMR/T8code.jl?tab=readme-ov-file#using-a-custom-version-of-mpi-andor-t8code + + +### For deployment + +If you want to provide a new `t8code` release for the Julia community, you need to trigger a +new build of the `t8code_jll.jl` bindary package. Building the binaries happens via +BinaryBuilder, documented here: +https://docs.binarybuilder.org/stable/. +It boils down to checking out +https://github.com/JuliaPackaging/Yggdrasil/tree/master/T/t8code, +editing `build_tarballs.jl` to at least reflect the latest version, tarball URL, and hash, +committing, and opening a pull request. + +Even a draft PR will already trigger the buildkite +pipelines. Check the builds for any errors. Successful runs will produce the binary +packages as artifacts. You can find an URL to such an artifact in the buildkite output, +along with its tree hash and SHA256 hash, which can be used in `Artifacts.toml` described +below. + +If you instead want to run BinaryBuilder locally you can do so by executing + +```shell +julia +1.7 build_tarballs.jl --debug --verbose x86_64-linux-gnu --deploy=local +``` + +This requires a local Julia installation and Julia version 1.7. You can use any other +eligible platform triple instead of `x86_64-linux-gnu`. Adding `--deploy=local` will add +the created binaries to your local Julia artifacts folder. + + +## Updating `Tcode.jl` + +Bindings are created using `Clang.jl`. The general process is as follows: 1. Create a `generator.jl` file with the relevant Julia code (not a lot). 2. Create a corresponding `generator.toml` file with certain settings. -3. Run `julia generator.jl` to create new file `Libt8.jl`. +3. Run `julia generator.jl` to create a new file `Libt8.jl`. 4. Apply manual fixes using `./fixes.sh` 5. Run `julia Libt8.jl`. 6. Get error(s). -7. Try to finagle something with `generator.toml`, `prologue.jl`/`epilogue.jl`, +7. Try to finagle something with `generator.toml`, `prologue.jl`, `epilogue.jl`, or `fixes.sh`. 8. Go back to 3. -To generate new bindings, run +The crucial ingredients are the `t8code` header files, which are expected in a subdirectory +`t8code_include` of the folder of this README. You have the following options: +- If you are developing `t8code` locally, you can copy and rename `t8code`'s `include` + directory from its current prefix path. You will have to comment lines 5 and 6 (dealing with artifacts) in `generator.jl` then. +- If your pull request to Yggdrasil has already been merged, you can find the newly built + binary packages at https://github.com/JuliaBinaryWrappers/t8code_jll.jl/releases. Copy an + entry of https://github.com/JuliaBinaryWrappers/t8code_jll.jl/blob/main/Artifacts.toml to + the local `Artifacts.toml` file. The exact choice of the platform triplet should not + matter since we use only the header files which are the same on each system. However, + they may matter in the presence of MPI headers since we apply some custom `fixes.sh` + afterwards. +- If your pull request has not yet been accepted, you can instead use artifacts of the + buildkite pipeline, see above. +- If you ran BindaryBuilder locally, you can somehow use your local artifacts. But how? + +In any case run ```shell julia --project generator.jl && ./fixes.sh ``` -to create a new `Libt8.jl` file. +next. If all goes well, move the new `Libt8.jl` file to `src/` and adapt the compat entry +in `Project.toml` to reflect the new version of `t8code_jll.jl`. + +At this point you can test your new `T8code.jl` version locally, e.g. by creating a +subdirectory `run` at the `T8code.jl` root folder, and from there executing + +```shell +julia --project=. + +julia> using Pkg +julia> Pkg.develop(path="..") +julia> Pkg.test("T8code") +``` + +If actually all went well, go ahead and open a pull request. -More information can be found in https://github.com/trixi-framework/P4est.jl +Once this pull request has been merged, downstream packages can start adopting your new +t8code release! diff --git a/dev/epilogue.jl b/dev/epilogue.jl deleted file mode 100644 index e69de29..0000000 diff --git a/dev/fixes.sh b/dev/fixes.sh index fe4a032..84efb75 100755 --- a/dev/fixes.sh +++ b/dev/fixes.sh @@ -9,126 +9,20 @@ LIB_JL="Libt8.jl" set -euxo pipefail -sed -i "s/using CEnum/using CEnum: @cenum/g" "${LIB_JL}" - -# Remove Fortran macros -sed -i "/INTEGER(KIND/d" "${LIB_JL}" - -# Remove other probably unused macros -sed -i "/P4EST_NOTICE/d" "${LIB_JL}" -sed -i "/P4EST_GLOBAL_NOTICE/d" "${LIB_JL}" - # Fix MPI types that have been wrongly converted to Julia types sed -i "s/mpicomm::Cint/mpicomm::MPI_Comm/g" "${LIB_JL}" sed -i "s/\bcomm::Cint/comm::MPI_Comm/g" "${LIB_JL}" sed -i "s/\bintranode::Ptr{Cint}/intranode::Ptr{MPI_Comm}/g" "${LIB_JL}" sed -i "s/\binternode::Ptr{Cint}/internode::Ptr{MPI_Comm}/g" "${LIB_JL}" sed -i "s/mpifile::Cint/mpifile::MPI_File/g" "${LIB_JL}" -sed -i "s/mpidatatype::Cint/mpidatatype::MPI_Datatype/g" "${LIB_JL}" -sed -i "s/\bt::Cint/t::MPI_Datatype/g" "${LIB_JL}" - -sed -i "s/t8_forest_get_mpicomm\(forest::t8_forest_t\)::Cint/t8_forest_get_mpicomm(forest::t8_forest_t)::MPI_Comm/g" "${LIB_JL}" - -sed -i "s/forest::Cint/forest::t8_forest_t/" "${LIB_JL}" - -# Use libsc for `sc_*` functions -sed -i "s/libt8\.sc_/libsc.sc_/g" "${LIB_JL}" - -# Use libp4est for `p4est_*` functions -sed -i "s/libt8\.p4est_/libp4est.p4est_/g" "${LIB_JL}" - -# Use libp4est for `p6est_*` functions -sed -i "s/libt8\.p6est_/libp4est.p6est_/g" "${LIB_JL}" - -# Use libp4est for `p8est_*` functions -sed -i "s/libt8\.p8est_/libp4est.p8est_/g" "${LIB_JL}" - - -# Fix type of `sc_array` field `array` -sed -i "s/array::Cstring/array::Ptr{Int8}/g" "${LIB_JL}" - -# Remove cross references that are not found -sed -i "s/\[\`p4est\`](@ref)/\`p4est\`/g" "${LIB_JL}" -sed -i "s/\[\`p6est\`](@ref)/\`p6est\`/g" "${LIB_JL}" -sed -i "s/\[\`p8est\`](@ref)/\`p8est\`/g" "${LIB_JL}" -sed -i "s/\[\`P4EST_QMAXLEVEL\`](@ref)/\`P4EST_QMAXLEVEL\`/g" "${LIB_JL}" -sed -i "s/\[\`P8EST_QMAXLEVEL\`](@ref)/\`P8EST_QMAXLEVEL\`/g" "${LIB_JL}" -sed -i "s/\[\`P4EST_CONN_DISK_PERIODIC\`](@ref)/\`P4EST_CONN_DISK_PERIODIC\`/g" "${LIB_JL}" -sed -i "s/\[\`p8est_iter_corner_side_t\`](@ref)/\`p8est_iter_corner_side_t\`/g" "${LIB_JL}" -sed -i "s/\[\`p8est_iter_edge_side_t\`](@ref)/\`p8est_iter_edge_side_t\`/g" "${LIB_JL}" -sed -i "s/\[\`p4est_corner_info_t\`](@ref)/\`p4est_corner_info_t\`/g" "${LIB_JL}" -sed -i "s/\[\`p8est_corner_info_t\`](@ref)/\`p8est_corner_info_t\`/g" "${LIB_JL}" -sed -i "s/\[\`p8est_edge_info_t\`](@ref)/\`p8est_edge_info_t\`/g" "${LIB_JL}" -sed -i "s/\[\`sc_MPI_Barrier\`](@ref)/\`sc_MPI_Barrier\`/g" "${LIB_JL}" -sed -i "s/\[\`sc_MPI_COMM_NULL\`](@ref)/\`sc_MPI_COMM_NULL\`/g" "${LIB_JL}" -sed -i "s/\[\`SC_CHECK_ABORT\`](@ref)/\`SC_CHECK_ABORT\`/g" "${LIB_JL}" -sed -i "s/\[\`SC_LP_DEFAULT\`](@ref)/\`SC_LP_DEFAULT\`/g" "${LIB_JL}" -sed -i "s/\[\`SC_LC_NORMAL\`](@ref)/\`SC_LC_NORMAL\`/g" "${LIB_JL}" -sed -i "s/\[\`SC_LC_GLOBAL\`](@ref)/\`SC_LC_GLOBAL\`/g" "${LIB_JL}" -sed -i "s/\[\`SC_LP_ALWAYS\`](@ref)/\`SC_LP_ALWAYS\`/g" "${LIB_JL}" -sed -i "s/\[\`SC_LP_SILENT\`](@ref)/\`SC_LP_SILENT\`/g" "${LIB_JL}" -sed -i "s/\[\`SC_LP_THRESHOLD\`](@ref)/\`SC_LP_THRESHOLD\`/g" "${LIB_JL}" -sed -i "s/\[\`sc_logf\`](@ref)/\`sc_logf\`/g" "${LIB_JL}" - -# For nicer docstrings -sed -i "s/\`p4est\`.h/\`p4est.h\`/g" "${LIB_JL}" -sed -i "s/\`p8est\`.h/\`p8est.h\`/g" "${LIB_JL}" - -sed -i "/_sc_const/d" "${LIB_JL}" -sed -i "/_sc_restrict/d" "${LIB_JL}" -sed -i "/sc_keyvalue_t/d" "${LIB_JL}" -sed -i "/T8_VERSION_POINT/d" "${LIB_JL}" -sed -i "/P4EST_VERSION_POINT/d" "${LIB_JL}" +sed -i "s/t8_forest_get_mpicomm(forest::t8_forest_t)::Cint/t8_forest_get_mpicomm(forest::t8_forest_t)::MPI_Comm/g" "${LIB_JL}" -sed -i "/P4EST_GLOBAL_NOTICE/d" "${LIB_JL}" -sed -i "/P4EST_NOTICE/d" "${LIB_JL}" +# Remove struct t8_forest definition and replace by forward declaration +sed -i -z 's/\nstruct t8_forest.*stats_computed::Cint\nend/\n# This struct is not supposed to be read and modified directly.\n# Besides, there is a circular dependency with `t8_forest_t`\n# leading to an error output by Julia.\nmutable struct t8_forest end/g' "${LIB_JL}" -sed -i "/P4EST_F90_QCOORD/d" "${LIB_JL}" -sed -i "/P4EST_F90_TOPIDX/d" "${LIB_JL}" -sed -i "/P4EST_F90_LOCIDX/d" "${LIB_JL}" -sed -i "/P4EST_F90_GLOIDX/d" "${LIB_JL}" - -sed -i "/MPI_ERR_GROUP/d" "${LIB_JL}" - -sed -i "/SC_VERSION_POINT/d" "${LIB_JL}" - -sed -i "/sc_MPI_PACKED/d" "${LIB_JL}" -sed -i "/sc_MPI_Pack/d" "${LIB_JL}" -sed -i "/sc_MPI_Unpack/d" "${LIB_JL}" - -sed -i "/= MPI_MODE_/d" "${LIB_JL}" -sed -i "/= MPI_SEEK_/d" "${LIB_JL}" -sed -i "/= MPI_ERR_/d" "${LIB_JL}" -sed -i "/= MPI_MAX_/d" "${LIB_JL}" -sed -i "/= MPI_Type_/d" "${LIB_JL}" -sed -i "/= MPI_Offset/d" "${LIB_JL}" -sed -i "/= MPI_File_/d" "${LIB_JL}" +# Fix forest type +sed -i "s/forest::Cint/forest::t8_forest_t/" "${LIB_JL}" +# Rename remaining MPI macros 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/dev/generator.jl b/dev/generator.jl index 1565218..1726446 100644 --- a/dev/generator.jl +++ b/dev/generator.jl @@ -7,15 +7,8 @@ cp(joinpath(artifact"t8code", "include"), "t8code_include"; force = true) using Glob -# This loads the artifact described in `P4est/dev/Artifacts.toml`. -# When a new release of P4est_jll.jl is created and you would like to update -# the headers, you can copy one of the entries of -# https://github.com/JuliaBinaryWrappers/P4est_jll.jl/blob/main/Artifacts.toml -# to this file. Here, we chose the version -# linux - x86_64 - glibc - mpich -# The exact choice should not matter since we use only the header files which -# are the same on each system. However, they may matter in the presence of -# MPI headers since we apply some custom `fixes.sh` afterwards. +# This loads the artifact described in `Artifacts.toml`. +# See README.md for instructions on how to update. using Clang.Generators # using Clang.LibClang.Clang_jll # replace this with your jll package diff --git a/dev/generator.toml b/dev/generator.toml index 95edc31..a490602 100644 --- a/dev/generator.toml +++ b/dev/generator.toml @@ -29,14 +29,13 @@ module_name = "Libt8" # using jll_pkg_name # export jll_pkg_name # We do not set this option since we want to customize it in prologue.jl. -# jll_pkg_name = "P4est_jll" +# jll_pkg_name = "t8code_jll" jll_pkg_name = "" # for packages that have extra JLL package dependencies jll_pkg_extra = [] # identifiers that starts with the string listed in this entry will be exported. -# export_symbol_prefixes = ["t8_", "p4est_", "p6est_", "p8est_", "sc_", "T8_", "P4EST_", "P6EST_", "P8EST_", "SC_"] export_symbol_prefixes = ["t8_", "T8_"] # the code in the following file will be copy-pasted to `output_file_path` before the generated code. @@ -45,28 +44,42 @@ prologue_file_path = "./prologue.jl" # the code in the following file will be copy-pasted to `output_file_path` after the generated code. # this is often used for applying custom patches. -epilogue_file_path = "./epilogue.jl" +epilogue_file_path = "" # node with an id in the `output_ignorelist` will be ignored in the printing passes. # this is very useful for custom editing. output_ignorelist = [ "_sc_restrict", - "sc_extern_c_hack_3", - "sc_extern_c_hack_4", + "SC_GCC_VERSION", "SC_EXTERN_C_BEGIN", "SC_EXTERN_C_END", - "SC_GCC_VERSION", - "PLATFORM_COMPILER_VERSION", - "__PLATFORM_COMPILER_GNU_VERSION_STR", - "_p4est_const", - "sc_MPI_2INT", "sc_MPI_SUCCESS", + "sc_MPI_ERR_ARG", + "sc_MPI_ERR_COUNT", + "sc_MPI_ERR_UNKNOWN", "sc_MPI_ERR_OTHER", + "sc_MPI_ERR_NO_MEM", + "sc_MPI_MAX_ERROR_STRING", + "sc_MPI_ERR_FILE", + "sc_MPI_ERR_NOT_SAME", + "sc_MPI_ERR_AMODE", + "sc_MPI_ERR_UNSUPPORTED_DATAREP", + "sc_MPI_ERR_UNSUPPORTED_OPERATION", + "sc_MPI_ERR_NO_SUCH_FILE", + "sc_MPI_ERR_FILE_EXISTS", + "sc_MPI_ERR_BAD_FILE", + "sc_MPI_ERR_ACCESS", + "sc_MPI_ERR_NO_SPACE", + "sc_MPI_ERR_QUOTA", + "sc_MPI_ERR_READ_ONLY", + "sc_MPI_ERR_FILE_IN_USE", + "sc_MPI_ERR_DUP_DATAREP", + "sc_MPI_ERR_CONVERSION", + "sc_MPI_ERR_IO", + "sc_MPI_ERR_LASTCODE", + "sc_MPI_Aint", "sc_MPI_COMM_NULL", - # "sc_MPI_COMM_WORLD", - # "sc_MPI_COMM_SELF", "sc_MPI_COMM_TYPE_SHARED", - "sc_MPI_GROUP", "sc_MPI_GROUP_NULL", "sc_MPI_GROUP_EMPTY", "sc_MPI_IDENT", @@ -78,24 +91,11 @@ output_ignorelist = [ "sc_MPI_STATUS_IGNORE", "sc_MPI_STATUSES_IGNORE", "sc_MPI_REQUEST_NULL", - "sc_MPI_INFO_NULL", "sc_MPI_DATATYPE_NULL", - # "sc_MPI_CHAR", - # "sc_MPI_SIGNED_CHAR", - # "sc_MPI_UNSIGNED_CHAR", - # "sc_MPI_BYTE", - # "sc_MPI_SHORT", - # "sc_MPI_UNSIGNED_SHORT", - # "sc_MPI_INT", - # "sc_MPI_UNSIGNED", - # "sc_MPI_LONG", - # "sc_MPI_UNSIGNED_LONG", - # "sc_MPI_LONG_LONG_INT", - # "sc_MPI_UNSIGNED_LONG_LONG", - # "sc_MPI_FLOAT", - # "sc_MPI_DOUBLE", "sc_MPI_LONG_DOUBLE", - "sc_MPI_Op", + "sc_MPI_2INT", + "sc_MPI_DOUBLE_INT", + "sc_MPI_PACKED", "sc_MPI_OP_NULL", "sc_MPI_MAX", "sc_MPI_MIN", @@ -112,7 +112,10 @@ output_ignorelist = [ "sc_MPI_PROD", "sc_MPI_UNDEFINED", "sc_MPI_KEYVAL_INVALID", + "sc_MPI_Op", + "sc_MPI_Request", "sc_MPI_Status", + "sc_MPI_INFO_NULL", "sc_MPI_Init", "sc_MPI_Finalize", "sc_MPI_Abort", @@ -155,7 +158,6 @@ output_ignorelist = [ "sc_MPI_Allreduce", "sc_MPI_Scan", "sc_MPI_Exscan", - "sc_MPI_Request", "sc_MPI_Recv", "sc_MPI_Irecv", "sc_MPI_Send", @@ -167,11 +169,60 @@ output_ignorelist = [ "sc_MPI_Wait", "sc_MPI_Waitsome", "sc_MPI_Waitall", - "sc_MPI_Init_thread", + "sc_MPI_Type_size", + "sc_MPI_Pack", + "sc_MPI_Unpack", + "sc_MPI_Pack_size", + "sc_MPI_Aint_diff", "sc_MPI_THREAD_SINGLE", "sc_MPI_THREAD_FUNNELED", "sc_MPI_THREAD_SERIALIZED", "sc_MPI_THREAD_MULTIPLE", + "sc_MPI_Init_thread", + "sc_MPI_MODE_RDONLY", + "sc_MPI_MODE_RDWR", + "sc_MPI_MODE_WRONLY", + "sc_MPI_MODE_CREATE", + "sc_MPI_MODE_EXCL", + "sc_MPI_MODE_DELETE_ON_CLOSE", + "sc_MPI_MODE_UNIQUE_OPEN", + "sc_MPI_MODE_SEQUENTIAL", + "sc_MPI_MODE_APPEND", + "sc_MPI_SEEK_SET", + "sc_MPI_SEEK_CUR", + "sc_MPI_SEEK_END", + "sc_MPI_Offset", + "sc_MPI_File_open", + "sc_MPI_File_close", + "sc_MPI_File_get_view", + "sc_MPI_File_set_view", + "sc_MPI_File_write_all", + "sc_MPI_File_read_all", + "sc_MPI_File_write_at_all", + "sc_MPI_File_read_at_all", + "sc_MPI_File_get_size", + "sc_MPI_File_set_size", + "t8_const", + "t8_restrict", + "T8_ECLASS_TO_DIMENSION_VALUES", + "T8_ECLASS_NUM_FACES_VALUES", + "T8_ECLASS_MAX_NUM_FACES_VALUES", + "T8_ECLASS_MAX_NUM_CHILDREN_VALUES", + "T8_REFERENCE_FACE_NORMAL_TET_VALUES", + "T8_ECLASS_NUM_VERTICES_VALUES", + "T8_ECLASS_NUM_EDGES_VALUES", + "T8_ECLASS_VTK_TYPE_VALUES", + "T8_ECLASS_TO_STRING_VALUES", + "T8_VERSION_POINT_STRING", + "_p4est_const", + "P4EST_F90_QCOORD", + "P4EST_F90_TOPIDX", + "P4EST_F90_LOCIDX", + "P4EST_F90_GLOIDX", + "P4EST_GLOBAL_NOTICE", + "P4EST_GLOBAL_NOTICEF", + "P4EST_NOTICE", + "P4EST_NOTICEF", ] # Julia's `@enum` do not allow duplicated values, so by default, C enums are translated to @@ -195,6 +246,9 @@ use_deterministic_symbol = true # if you'd like to generate all of the symbols in the system headers, please set this option to false. is_local_header_only = true +# set this option to false if you'd like to ignore the symbols(even if necessary) in the system headers. +generate_isystem_symbols = true + # if this option is set to true, C code with a style of # ```c # typedef struct { @@ -216,6 +270,9 @@ is_local_header_only = true # ``` smart_de_anonymize = true +# if set to true, static functions will be ignored +skip_static_functions = false + # EXPERIMENTAL # if this option is set to true, those structs that are not necessary to be an # immutable struct will be generated as a mutable struct. @@ -242,8 +299,17 @@ auto_mutability_includelist = [] # note: by default, Clang only parses doxygen comment, pass `-fparse-all-comments` to Clang in order to parse non-doxygen comments. extract_c_comment_style = "doxygen" +# Pass a function to explicitly generate documentation. It will be called like +# `callback_documentation(node::ExprNode, doc::Vector{String})` if it is +# set. The `doc` argument will contain the docs parsed from the headers if +# `extract_c_comment_style` is set, otherwise it will be an empty vector. +# +# Do *not* set this in the TOML file, it should be set in the generator script +# to a function that takes in an ExprNode and returns a String[] (string +# vector). +# callback_documentation = "" + # if set to true, single line comment will be printed as """comment""" instead of """\ncomment\n""" -# fold_single_line_comment = false fold_single_line_comment = true # if set to "outofline", documentation of struct fields will be collected at the "Fields" section of the struct @@ -277,9 +343,14 @@ opaque_as_mutable_struct = true use_ccall_macro = true # if true, variadic functions are wrapped with `@ccall` macro. Otherwise variadic functions are ignored. +# needed e.g. for t8_global_productionf wrap_variadic_function = true -# generate getproperty/setproperty! methods for the types in the following list +# Generate getproperty/setproperty! methods for the types in the following list. +# Warning: the generated methods will only work on the architecture that they +# were generated on. i.e. if you generate them on a 64bit machine they are not +# guaranteed to work on 32bit machines. See +# https://github.com/JuliaInterop/Clang.jl/issues/512 for more details. field_access_method_list = [] # the generator will prefix the function argument names in the following list with a "_" to @@ -291,21 +362,13 @@ function_argument_conflict_symbols = [] add_record_constructors = [] [codegen.macro] -# it‘s highly recommended to set this entry to "basic". +# it's highly recommended to set this entry to "basic". # if you'd like to skip all of the macros, please set this entry to "disable". # if you'd like to translate function-like macros to Julia, please set this entry to "aggressive". macro_mode = "basic" # function-like macros in the following list will always be translated. -functionlike_macro_includelist = [ - "P4EST_QUADRANT_LEN", - "P4EST_QUADRANT_MASK", - "P4EST_LAST_OFFSET", - "P8EST_QUADRANT_LEN", - "P8EST_QUADRANT_MASK", - "P8EST_LAST_OFFSET" - # "CINDEX_VERSION_ENCODE", -] +functionlike_macro_includelist = [] # if true, the generator prints the following message as comments. # "# Skipping MacroDefinition: ..." diff --git a/examples/t8_step2_uniform_forest.jl b/examples/t8_step2_uniform_forest.jl index f50cd63..cfde830 100644 --- a/examples/t8_step2_uniform_forest.jl +++ b/examples/t8_step2_uniform_forest.jl @@ -71,7 +71,7 @@ end # partitioned across the processes in \a comm. function t8_step2_build_uniform_forest(comm, cmesh, level) # /* Create the refinement scheme. */ - scheme = t8_scheme_new_default_cxx() + scheme = t8_scheme_new_default() # /* Creat the uniform forest. */ forest = t8_forest_new_uniform(cmesh, scheme, level, 0, comm) @@ -127,9 +127,9 @@ cmesh = t8_step2_build_prismcube_coarse_mesh(mpicom) # Build the uniform forest, it is automatically partitioned among the processes. forest = t8_step2_build_uniform_forest(mpicom, cmesh, level) # Get the local number of elements. -local_num_elements = t8_forest_get_local_num_elements(forest) +local_num_elements = t8_forest_get_local_num_leaf_elements(forest) # Get the global number of elements. -global_num_elements = t8_forest_get_global_num_elements(forest) +global_num_elements = t8_forest_get_global_num_leaf_elements(forest) # Print information on the forest. t8_global_productionf(" [step2] Created uniform forest.\n") diff --git a/examples/t8_step3_adapt_forest.jl b/examples/t8_step3_adapt_forest.jl index d9e9bca..4c32b56 100644 --- a/examples/t8_step3_adapt_forest.jl +++ b/examples/t8_step3_adapt_forest.jl @@ -63,7 +63,7 @@ t8_global_productionf(" [step3] \n") # Build a cube cmesh with tet, hex, and prism trees. cmesh = t8_cmesh_new_hypercube_hybrid(comm, 0, 0) t8_global_productionf(" [step3] Created coarse mesh.\n") -forest = t8_forest_new_uniform(cmesh, t8_scheme_new_default_cxx(), level, 0, comm) +forest = t8_forest_new_uniform(cmesh, t8_scheme_new_default(), level, 0, comm) # Print information of the forest. t8_global_productionf(" [step3] Created uniform forest.\n") diff --git a/examples/t8_step3_common.jl b/examples/t8_step3_common.jl index bc263b6..abc5c23 100644 --- a/examples/t8_step3_common.jl +++ b/examples/t8_step3_common.jl @@ -16,17 +16,18 @@ end # return > 0 -> The first element should get refined. # return = 0 -> The first element should not get refined. # return < 0 -> The whole family should get coarsened. -# +# # \param [in] forest The current forest that is in construction. # \param [in] forest_from The forest from which we adapt the current forest (in our case, the uniform forest) # \param [in] which_tree The process local id of the current tree. +# \param [in] tree_class The eclass of \a which_tree. # \param [in] lelement_id The tree local index of the current element (or the first of the family). -# \param [in] ts The refinement scheme for this tree's element class. -# \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. +# \param [in] scheme The refinement scheme for this tree's element class. +# \param [in] is_family If 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. # \param [in] num_elements The number of entries in \a elements elements that are defined. # \param [in] elements The element or family of elements to consider for refinement/coarsening. -function t8_step3_adapt_callback(forest, forest_from, which_tree, lelement_id, - ts, is_family, num_elements, elements_ptr)::Cint +function t8_step3_adapt_callback(forest, forest_from, which_tree, tree_class, lelement_id, + scheme, is_family, num_elements, elements_ptr)::Cint # Our adaptation criterion is to look at the midpoint coordinates of the current element and if # they are inside a sphere around a given midpoint we refine, if they are outside, we coarsen. @@ -96,9 +97,9 @@ function t8_step3_print_forest_information(forest) @T8_ASSERT(t8_forest_is_committed(forest)==1) # Get the local number of elements. - local_num_elements = t8_forest_get_local_num_elements(forest) + local_num_elements = t8_forest_get_local_num_leaf_elements(forest) # Get the global number of elements. - global_num_elements = t8_forest_get_global_num_elements(forest) + global_num_elements = t8_forest_get_global_num_leaf_elements(forest) t8_global_productionf(" [step3] Local number of elements:\t\t%i\n", local_num_elements) t8_global_productionf(" [step3] Global number of elements:\t%li\n", global_num_elements) diff --git a/examples/t8_step4_partition_balance_ghost.jl b/examples/t8_step4_partition_balance_ghost.jl index c03b120..9108647 100644 --- a/examples/t8_step4_partition_balance_ghost.jl +++ b/examples/t8_step4_partition_balance_ghost.jl @@ -215,7 +215,7 @@ t8_global_productionf(" [step4] \n") # Build a cube cmesh with tet, hex, and prism trees. cmesh = t8_cmesh_new_hypercube_hybrid(comm, 0, 0) t8_global_productionf(" [step4] Created coarse mesh.\n") -forest = t8_forest_new_uniform(cmesh, t8_scheme_new_default_cxx(), level, 0, comm) +forest = t8_forest_new_uniform(cmesh, t8_scheme_new_default(), level, 0, comm) # Print information of the forest. t8_step3_print_forest_information(forest); diff --git a/examples/t8_step5_element_data.jl b/examples/t8_step5_element_data.jl index 5b54a07..ca27223 100644 --- a/examples/t8_step5_element_data.jl +++ b/examples/t8_step5_element_data.jl @@ -59,7 +59,7 @@ end function t8_step5_build_forest(comm, level) cmesh = t8_cmesh_new_hypercube_hybrid(comm, 0, 0) - scheme = t8_scheme_new_default_cxx() + scheme = t8_scheme_new_default() adapt_data = t8_step3_adapt_data_t((0.5, 0.5, 1.0), # Midpoints of the sphere. 0.2, # Refine if inside this radius. @@ -88,7 +88,7 @@ function t8_step5_create_element_data(forest) @T8_ASSERT(t8_forest_is_committed(forest)==1) # Get the number of local elements of forest. - num_local_elements = t8_forest_get_local_num_elements(forest) + num_local_elements = t8_forest_get_local_num_leaf_elements(forest) # Get the number of ghost elements of forest. num_ghost_elements = t8_forest_get_num_ghosts(forest) @@ -118,6 +118,8 @@ function t8_step5_create_element_data(forest) # Get the number of trees that have elements of this process. num_local_trees = t8_forest_get_num_local_trees(forest) + scheme = t8_forest_get_scheme(forest) + current_index = 0 for itree in 0:(num_local_trees - 1) # This loop iterates through all local trees in the forest. @@ -125,7 +127,6 @@ function t8_step5_create_element_data(forest) # also a different way to interpret its elements. In order to be able to handle elements # of a tree, we need to get its eclass_scheme, and in order to so we first get its eclass. tree_class = t8_forest_get_tree_class(forest, itree) - eclass_scheme = t8_forest_get_eclass_scheme(forest, tree_class) # Get the number of elements of this tree. num_elements_in_tree = t8_forest_get_tree_num_elements(forest, itree) @@ -141,7 +142,7 @@ function t8_step5_create_element_data(forest) # We want to store the elements level and its volume as data. We compute these # via the eclass_scheme and the forest_element interface. - level = t8_element_level(eclass_scheme, element) + level = t8_element_get_level(scheme, tree_class, element) volume = t8_forest_element_volume(forest, itree, element) element_data[current_index] = t8_step5_data_per_element_t(level, volume) @@ -178,7 +179,7 @@ end # We support two types: T8_VTK_SCALAR - One double per element # and T8_VTK_VECTOR - 3 doubles per element function t8_step5_output_data_to_vtu(forest, element_data, prefix) - num_elements = t8_forest_get_local_num_elements(forest) + num_elements = t8_forest_get_local_num_leaf_elements(forest) # We need to allocate a new array to store the volumes on their own. # This array has one entry per local element. */ element_volumes = Vector{Cdouble}(undef, num_elements) @@ -255,7 +256,7 @@ element_data = t8_step5_create_element_data(forest) t8_global_productionf(" [step5] Computed level and volume data for local elements.\n") -if t8_forest_get_local_num_elements(forest) > 0 +if t8_forest_get_local_num_leaf_elements(forest) > 0 # Output the stored data of the first local element (if it exists). t8_global_productionf(" [step5] Element 0 has level %i and volume %e.\n", element_data[1].level, element_data[1].volume) @@ -269,7 +270,7 @@ t8_global_productionf(" [step5] Exchanged ghost data.\n") if t8_forest_get_num_ghosts(forest) > 0 # Output the data of the first ghost element (if it exists). - first_ghost_index = t8_forest_get_local_num_elements(forest) + first_ghost_index = t8_forest_get_local_num_leaf_elements(forest) t8_global_productionf(" [step5] Ghost 0 has level %i and volume %e.\n", element_data[first_ghost_index + 1].level, element_data[first_ghost_index + 1].volume) diff --git a/examples/t8_step6_stencil.jl b/examples/t8_step6_stencil.jl index 771824d..8c9b6d4 100644 --- a/examples/t8_step6_stencil.jl +++ b/examples/t8_step6_stencil.jl @@ -78,7 +78,7 @@ end function t8_step6_build_forest(comm, dim, level) cmesh = t8_cmesh_new_periodic(comm, dim) - scheme = t8_scheme_new_default_cxx() + scheme = t8_scheme_new_default() adapt_data = t8_step3_adapt_data_t((0.0, 0.0, 0.0), # Midpoints of the sphere. 0.5, # Refine if inside this radius. @@ -111,7 +111,7 @@ function t8_step6_create_element_data(forest) @T8_ASSERT(t8_forest_is_committed(forest)==1) # Get the number of local elements of forest. - num_local_elements = t8_forest_get_local_num_elements(forest) + num_local_elements = t8_forest_get_local_num_leaf_elements(forest) # Get the number of ghost elements of forest. num_ghost_elements = t8_forest_get_num_ghosts(forest) @@ -130,11 +130,12 @@ function t8_step6_create_element_data(forest) # Element Midpoint midpoint = Vector{Cdouble}(undef, 3) + scheme = t8_forest_get_scheme(forest) + # Loop over all local trees in the forest. current_index = 0 for itree in 0:(num_local_trees - 1) tree_class = t8_forest_get_tree_class(forest, itree) - eclass_scheme = t8_forest_get_eclass_scheme(forest, tree_class) # Get the number of elements of this tree. num_elements_in_tree = t8_forest_get_tree_num_elements(forest, itree) @@ -145,17 +146,17 @@ function t8_step6_create_element_data(forest) element = t8_forest_get_element_in_tree(forest, itree, ielement) - level = t8_element_level(eclass_scheme, element) + level = t8_element_get_level(scheme, tree_class, element) volume = t8_forest_element_volume(forest, itree, element) t8_forest_element_centroid(forest, itree, element, pointer(midpoint)) - t8_element_vertex_reference_coords(eclass_scheme, element, 0, - @view(verts[:, 1])) - t8_element_vertex_reference_coords(eclass_scheme, element, 1, - @view(verts[:, 2])) - t8_element_vertex_reference_coords(eclass_scheme, element, 2, - @view(verts[:, 3])) + t8_element_get_vertex_reference_coords(scheme, tree_class, element, 0, + @view(verts[:, 1])) + t8_element_get_vertex_reference_coords(scheme, tree_class, element, 1, + @view(verts[:, 2])) + t8_element_get_vertex_reference_coords(scheme, tree_class, element, 2, + @view(verts[:, 3])) dx = verts[1, 2] - verts[1, 1] dy = verts[2, 3] - verts[2, 1] diff --git a/src/Libt8.jl b/src/Libt8.jl index 97b434f..498ccce 100644 --- a/src/Libt8.jl +++ b/src/Libt8.jl @@ -1,6 +1,6 @@ module Libt8 -using CEnum: @cenum +using CEnum: CEnum, @cenum to_c_type(t::Type) = t to_c_type_pairs(va_list) = map(enumerate(to_c_type.(va_list))) do (ind, type) @@ -67,6 +67,32 @@ const INT64_MIN = typemin(Clonglong) const INT64_MAX = typemax(Clonglong) +""" + sc_extern_c_hack_1() + +### Prototype +```c +SC_EXTERN_C_BEGIN; +``` +""" +function sc_extern_c_hack_1() + @ccall libt8.sc_extern_c_hack_1()::Cvoid +end + +""" + sc_extern_c_hack_2() + +` ` + +### Prototype +```c +SC_EXTERN_C_END; +``` +""" +function sc_extern_c_hack_2() + @ccall libt8.sc_extern_c_hack_2()::Cvoid +end + """ sc_abort_verbose(filename, lineno, msg) @@ -78,12 +104,12 @@ void sc_abort_verbose (const char *filename, int lineno, const char *msg) __attr ``` """ function sc_abort_verbose(filename, lineno, msg) - @ccall libsc.sc_abort_verbose(filename::Cstring, lineno::Cint, msg::Cstring)::Cvoid + @ccall libt8.sc_abort_verbose(filename::Cstring, lineno::Cint, msg::Cstring)::Cvoid end # automatic type deduction for variadic arguments may not be what you want, please use with caution @generated function sc_abort_verbosef(filename, lineno, fmt, va_list...) - :(@ccall(libsc.sc_abort_verbosef(filename::Cstring, lineno::Cint, fmt::Cstring; $(to_c_type_pairs(va_list)...))::Cvoid)) + :(@ccall(libt8.sc_abort_verbosef(filename::Cstring, lineno::Cint, fmt::Cstring; $(to_c_type_pairs(va_list)...))::Cvoid)) end """ @@ -95,7 +121,7 @@ void *sc_malloc (int package, size_t size); ``` """ function sc_malloc(package, size) - @ccall libsc.sc_malloc(package::Cint, size::Csize_t)::Ptr{Cvoid} + @ccall libt8.sc_malloc(package::Cint, size::Csize_t)::Ptr{Cvoid} end """ @@ -107,7 +133,7 @@ void *sc_calloc (int package, size_t nmemb, size_t size); ``` """ function sc_calloc(package, nmemb, size) - @ccall libsc.sc_calloc(package::Cint, nmemb::Csize_t, size::Csize_t)::Ptr{Cvoid} + @ccall libt8.sc_calloc(package::Cint, nmemb::Csize_t, size::Csize_t)::Ptr{Cvoid} end """ @@ -119,7 +145,7 @@ void *sc_realloc (int package, void *ptr, size_t size); ``` """ function sc_realloc(package, ptr, size) - @ccall libsc.sc_realloc(package::Cint, ptr::Ptr{Cvoid}, size::Csize_t)::Ptr{Cvoid} + @ccall libt8.sc_realloc(package::Cint, ptr::Ptr{Cvoid}, size::Csize_t)::Ptr{Cvoid} end """ @@ -131,7 +157,7 @@ char *sc_strdup (int package, const char *s); ``` """ function sc_strdup(package, s) - @ccall libsc.sc_strdup(package::Cint, s::Cstring)::Cstring + @ccall libt8.sc_strdup(package::Cint, s::Cstring)::Cstring end """ @@ -143,7 +169,7 @@ void sc_free (int package, void *ptr); ``` """ function sc_free(package, ptr) - @ccall libsc.sc_free(package::Cint, ptr::Ptr{Cvoid})::Cvoid + @ccall libt8.sc_free(package::Cint, ptr::Ptr{Cvoid})::Cvoid end """ @@ -153,20 +179,20 @@ The central log function to be called by all packages. Dispatches the log calls # Arguments * `package`:\\[in\\] Must be a registered package id or -1. -* `category`:\\[in\\] Must be `SC_LC_NORMAL` or `SC_LC_GLOBAL`. -* `priority`:\\[in\\] Must be > `SC_LP_ALWAYS` and < `SC_LP_SILENT`. +* `category`:\\[in\\] Must be [`SC_LC_NORMAL`](@ref) or [`SC_LC_GLOBAL`](@ref). +* `priority`:\\[in\\] Must be > [`SC_LP_ALWAYS`](@ref) and < [`SC_LP_SILENT`](@ref). ### Prototype ```c void sc_log (const char *filename, int lineno, int package, int category, int priority, const char *msg); ``` """ function sc_log(filename, lineno, package, category, priority, msg) - @ccall libsc.sc_log(filename::Cstring, lineno::Cint, package::Cint, category::Cint, priority::Cint, msg::Cstring)::Cvoid + @ccall libt8.sc_log(filename::Cstring, lineno::Cint, package::Cint, category::Cint, priority::Cint, msg::Cstring)::Cvoid end # automatic type deduction for variadic arguments may not be what you want, please use with caution @generated function sc_logf(filename, lineno, package, category, priority, fmt, va_list...) - :(@ccall(libsc.sc_logf(filename::Cstring, lineno::Cint, package::Cint, category::Cint, priority::Cint, fmt::Cstring; $(to_c_type_pairs(va_list)...))::Cvoid)) + :(@ccall(libt8.sc_logf(filename::Cstring, lineno::Cint, package::Cint, category::Cint, priority::Cint, fmt::Cstring; $(to_c_type_pairs(va_list)...))::Cvoid)) end """ @@ -185,7 +211,7 @@ struct sc_array elem_size::Csize_t elem_count::Csize_t byte_alloc::Cssize_t - array::Ptr{Int8} + array::Cstring end """The [`sc_array`](@ref) object provides a dynamic array of equal-size elements. Elements are accessed by their 0-based index. Their address may change. The number of elements (== elem\\_count) of the array can be changed by sc_array_resize and sc_array_rewind. Elements can be sorted with sc_array_sort. If the array is sorted, it can be searched with sc_array_bsearch. A priority queue is implemented with pqueue\\_add and pqueue\\_pop (untested).""" @@ -207,7 +233,7 @@ sc_array_t *sc_array_new_count (size_t elem_size, size_t elem_count); ``` """ function sc_array_new_count(elem_size, elem_count) - @ccall libsc.sc_array_new_count(elem_size::Csize_t, elem_count::Csize_t)::Ptr{sc_array_t} + @ccall libt8.sc_array_new_count(elem_size::Csize_t, elem_count::Csize_t)::Ptr{sc_array_t} end """ @@ -238,7 +264,7 @@ int sc_int32_compare (const void *v1, const void *v2); ``` """ function sc_int32_compare(v1, v2) - @ccall libsc.sc_int32_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint + @ccall libt8.sc_int32_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint end """A type for global indexing that holds really big numbers.""" @@ -253,33 +279,44 @@ int sc_int64_compare (const void *v1, const void *v2); ``` """ function sc_int64_compare(v1, v2) - @ccall libsc.sc_int64_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint + @ccall libt8.sc_int64_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint end """ - sc_shmem_malloc(package, elem_size, elem_count, comm) - -### Prototype -```c -void *sc_shmem_malloc (int package, size_t elem_size, size_t elem_count, sc_MPI_Comm comm); -``` -""" -function sc_shmem_malloc(package, elem_size, elem_count, comm) - @ccall libsc.sc_shmem_malloc(package::Cint, elem_size::Csize_t, elem_count::Csize_t, comm::MPI_Comm)::Ptr{Cvoid} -end + t8_eclass -""" - sc_shmem_free(package, array, comm) +This enumeration contains all possible element classes. -### Prototype -```c -void sc_shmem_free (int package, void *array, sc_MPI_Comm comm); -``` +| Enumerator | Note | +| :--------------------- | :----------------------------------------------------------------------------------------------------------------- | +| T8\\_ECLASS\\_VERTEX | The vertex is the only zero-dimensional element class. | +| T8\\_ECLASS\\_LINE | The line is the only one-dimensional element class. | +| T8\\_ECLASS\\_QUAD | The quadrilateral is one of two element classes in two dimensions. | +| T8\\_ECLASS\\_TRIANGLE | The element class for a triangle. | +| T8\\_ECLASS\\_HEX | The hexahedron is one three-dimensional element class. | +| T8\\_ECLASS\\_TET | The tetrahedron is another three-dimensional element class. | +| T8\\_ECLASS\\_PRISM | The prism has five sides: two opposing triangles joined by three quadrilaterals. | +| T8\\_ECLASS\\_PYRAMID | The pyramid has a quadrilateral as base and four triangles as sides. | +| T8\\_ECLASS\\_COUNT | This is no element class but can be used as the number of element classes. | +| T8\\_ECLASS\\_INVALID | This is no element class but can be used for the case a class of a third party library is not supported by t8code | """ -function sc_shmem_free(package, array, comm) - @ccall libsc.sc_shmem_free(package::Cint, array::Ptr{Cvoid}, comm::MPI_Comm)::Cvoid +@cenum t8_eclass::UInt32 begin + T8_ECLASS_ZERO = 0 + T8_ECLASS_VERTEX = 0 + T8_ECLASS_LINE = 1 + T8_ECLASS_QUAD = 2 + T8_ECLASS_TRIANGLE = 3 + T8_ECLASS_HEX = 4 + T8_ECLASS_TET = 5 + T8_ECLASS_PRISM = 6 + T8_ECLASS_PYRAMID = 7 + T8_ECLASS_COUNT = 8 + T8_ECLASS_INVALID = 9 end +"""This enumeration contains all possible element classes.""" +const t8_eclass_t = t8_eclass + """ sc_tag_t @@ -342,7 +379,7 @@ int sc_MPI_Testall (int, sc_MPI_Request *, int *, sc_MPI_Status *); ``` """ function sc_MPI_Testall(arg1, arg2, arg3, arg4) - @ccall libsc.sc_MPI_Testall(arg1::Cint, arg2::Ptr{Cint}, arg3::Ptr{Cint}, arg4::Ptr{Cint})::Cint + @ccall libt8.sc_MPI_Testall(arg1::Cint, arg2::Ptr{Cint}, arg3::Ptr{Cint}, arg4::Ptr{Cint})::Cint end """ @@ -361,7 +398,7 @@ int sc_MPI_Error_class (int errorcode, int *errorclass); ``` """ function sc_MPI_Error_class(errorcode, errorclass) - @ccall libsc.sc_MPI_Error_class(errorcode::Cint, errorclass::Ptr{Cint})::Cint + @ccall libt8.sc_MPI_Error_class(errorcode::Cint, errorclass::Ptr{Cint})::Cint end """ @@ -381,7 +418,7 @@ int sc_MPI_Error_string (int errorcode, char *string, int *resultlen); ``` """ function sc_MPI_Error_string(errorcode, string, resultlen) - @ccall libsc.sc_MPI_Error_string(errorcode::Cint, string::Cstring, resultlen::Ptr{Cint})::Cint + @ccall libt8.sc_MPI_Error_string(errorcode::Cint, string::Cstring, resultlen::Ptr{Cint})::Cint end """ @@ -393,7 +430,7 @@ size_t sc_mpi_sizeof (sc_MPI_Datatype t); ``` """ function sc_mpi_sizeof(t) - @ccall libsc.sc_mpi_sizeof(t::MPI_Datatype)::Csize_t + @ccall libt8.sc_mpi_sizeof(t::Cint)::Csize_t end """ @@ -405,7 +442,7 @@ void sc_mpi_comm_attach_node_comms (sc_MPI_Comm comm, int processes_per_node); ``` """ function sc_mpi_comm_attach_node_comms(comm, processes_per_node) - @ccall libsc.sc_mpi_comm_attach_node_comms(comm::MPI_Comm, processes_per_node::Cint)::Cvoid + @ccall libt8.sc_mpi_comm_attach_node_comms(comm::MPI_Comm, processes_per_node::Cint)::Cvoid end """ @@ -417,7 +454,7 @@ void sc_mpi_comm_detach_node_comms (sc_MPI_Comm comm); ``` """ function sc_mpi_comm_detach_node_comms(comm) - @ccall libsc.sc_mpi_comm_detach_node_comms(comm::MPI_Comm)::Cvoid + @ccall libt8.sc_mpi_comm_detach_node_comms(comm::MPI_Comm)::Cvoid end """ @@ -429,7 +466,7 @@ void sc_mpi_comm_get_node_comms (sc_MPI_Comm comm, sc_MPI_Comm * intranode, sc_M ``` """ function sc_mpi_comm_get_node_comms(comm, intranode, internode) - @ccall libsc.sc_mpi_comm_get_node_comms(comm::MPI_Comm, intranode::Ptr{MPI_Comm}, internode::Ptr{MPI_Comm})::Cvoid + @ccall libt8.sc_mpi_comm_get_node_comms(comm::MPI_Comm, intranode::Ptr{MPI_Comm}, internode::Ptr{MPI_Comm})::Cvoid end """ @@ -441,7 +478,7 @@ int sc_mpi_comm_get_and_attach (sc_MPI_Comm comm); ``` """ function sc_mpi_comm_get_and_attach(comm) - @ccall libsc.sc_mpi_comm_get_and_attach(comm::MPI_Comm)::Cint + @ccall libt8.sc_mpi_comm_get_and_attach(comm::MPI_Comm)::Cint end # typedef void ( * sc_handler_t ) ( void * data ) @@ -463,7 +500,7 @@ int sc_memory_status (int package); ``` """ function sc_memory_status(package) - @ccall libsc.sc_memory_status(package::Cint)::Cint + @ccall libt8.sc_memory_status(package::Cint)::Cint end """ @@ -475,7 +512,7 @@ void sc_memory_check (int package); ``` """ function sc_memory_check(package) - @ccall libsc.sc_memory_check(package::Cint)::Cvoid + @ccall libt8.sc_memory_check(package::Cint)::Cvoid end """ @@ -489,7 +526,7 @@ int sc_memory_check_noerr (int package); ``` """ function sc_memory_check_noerr(package) - @ccall libsc.sc_memory_check_noerr(package::Cint)::Cint + @ccall libt8.sc_memory_check_noerr(package::Cint)::Cint end """ @@ -501,7 +538,7 @@ int sc_int_compare (const void *v1, const void *v2); ``` """ function sc_int_compare(v1, v2) - @ccall libsc.sc_int_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint + @ccall libt8.sc_int_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint end """ @@ -513,7 +550,7 @@ int sc_int8_compare (const void *v1, const void *v2); ``` """ function sc_int8_compare(v1, v2) - @ccall libsc.sc_int8_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint + @ccall libt8.sc_int8_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint end """ @@ -525,7 +562,7 @@ int sc_int16_compare (const void *v1, const void *v2); ``` """ function sc_int16_compare(v1, v2) - @ccall libsc.sc_int16_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint + @ccall libt8.sc_int16_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint end """ @@ -537,7 +574,7 @@ int sc_double_compare (const void *v1, const void *v2); ``` """ function sc_double_compare(v1, v2) - @ccall libsc.sc_double_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint + @ccall libt8.sc_double_compare(v1::Ptr{Cvoid}, v2::Ptr{Cvoid})::Cint end """ @@ -555,7 +592,7 @@ int sc_atoi (const char *nptr); ``` """ function sc_atoi(nptr) - @ccall libsc.sc_atoi(nptr::Cstring)::Cint + @ccall libt8.sc_atoi(nptr::Cstring)::Cint end """ @@ -573,7 +610,7 @@ long sc_atol (const char *nptr); ``` """ function sc_atol(nptr) - @ccall libsc.sc_atol(nptr::Cstring)::Clong + @ccall libt8.sc_atol(nptr::Cstring)::Clong end """ @@ -582,16 +619,16 @@ end Controls the default SC log behavior. # Arguments -* `log_stream`:\\[in\\] Set stream to use by `sc_logf` (or NULL for stdout). +* `log_stream`:\\[in\\] Set stream to use by [`sc_logf`](@ref) (or NULL for stdout). * `log_handler`:\\[in\\] Set default SC log handler (NULL selects builtin). -* `log_threshold`:\\[in\\] Set default SC log threshold (or `SC_LP_DEFAULT`). May be `SC_LP_ALWAYS` or `SC_LP_SILENT`. +* `log_threshold`:\\[in\\] Set default SC log threshold (or [`SC_LP_DEFAULT`](@ref)). May be [`SC_LP_ALWAYS`](@ref) or [`SC_LP_SILENT`](@ref). ### Prototype ```c void sc_set_log_defaults (FILE * log_stream, sc_log_handler_t log_handler, int log_threshold); ``` """ function sc_set_log_defaults(log_stream, log_handler, log_threshold) - @ccall libsc.sc_set_log_defaults(log_stream::Ptr{Libc.FILE}, log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid + @ccall libt8.sc_set_log_defaults(log_stream::Ptr{Libc.FILE}, log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid end """ @@ -607,7 +644,7 @@ void sc_set_abort_handler (sc_abort_handler_t abort_handler); ``` """ function sc_set_abort_handler(abort_handler) - @ccall libsc.sc_set_abort_handler(abort_handler::sc_abort_handler_t)::Cvoid + @ccall libt8.sc_set_abort_handler(abort_handler::sc_abort_handler_t)::Cvoid end """ @@ -621,7 +658,7 @@ void sc_log_indent_push_count (int package, int count); ``` """ function sc_log_indent_push_count(package, count) - @ccall libsc.sc_log_indent_push_count(package::Cint, count::Cint)::Cvoid + @ccall libt8.sc_log_indent_push_count(package::Cint, count::Cint)::Cvoid end """ @@ -635,7 +672,7 @@ void sc_log_indent_pop_count (int package, int count); ``` """ function sc_log_indent_pop_count(package, count) - @ccall libsc.sc_log_indent_pop_count(package::Cint, count::Cint)::Cvoid + @ccall libt8.sc_log_indent_pop_count(package::Cint, count::Cint)::Cvoid end """ @@ -649,7 +686,7 @@ void sc_log_indent_push (void); ``` """ function sc_log_indent_push() - @ccall libsc.sc_log_indent_push()::Cvoid + @ccall libt8.sc_log_indent_push()::Cvoid end """ @@ -663,7 +700,7 @@ void sc_log_indent_pop (void); ``` """ function sc_log_indent_pop() - @ccall libsc.sc_log_indent_pop()::Cvoid + @ccall libt8.sc_log_indent_pop()::Cvoid end """ @@ -677,7 +714,7 @@ void sc_abort (void) __attribute__ ((noreturn)); ``` """ function sc_abort() - @ccall libsc.sc_abort()::Cvoid + @ccall libt8.sc_abort()::Cvoid end """ @@ -691,7 +728,7 @@ void sc_abort_collective (const char *msg) __attribute__ ((noreturn)); ``` """ function sc_abort_collective(msg) - @ccall libsc.sc_abort_collective(msg::Cstring)::Cvoid + @ccall libt8.sc_abort_collective(msg::Cstring)::Cvoid end """ @@ -707,7 +744,7 @@ int sc_package_register (sc_log_handler_t log_handler, int log_threshold, const ``` """ function sc_package_register(log_handler, log_threshold, name, full) - @ccall libsc.sc_package_register(log_handler::sc_log_handler_t, log_threshold::Cint, name::Cstring, full::Cstring)::Cint + @ccall libt8.sc_package_register(log_handler::sc_log_handler_t, log_threshold::Cint, name::Cstring, full::Cstring)::Cint end """ @@ -725,7 +762,7 @@ int sc_package_is_registered (int package_id); ``` """ function sc_package_is_registered(package_id) - @ccall libsc.sc_package_is_registered(package_id::Cint)::Cint + @ccall libt8.sc_package_is_registered(package_id::Cint)::Cint end """ @@ -741,7 +778,7 @@ void sc_package_lock (int package_id); ``` """ function sc_package_lock(package_id) - @ccall libsc.sc_package_lock(package_id::Cint)::Cvoid + @ccall libt8.sc_package_lock(package_id::Cint)::Cvoid end """ @@ -757,13 +794,13 @@ void sc_package_unlock (int package_id); ``` """ function sc_package_unlock(package_id) - @ccall libsc.sc_package_unlock(package_id::Cint)::Cvoid + @ccall libt8.sc_package_unlock(package_id::Cint)::Cvoid end """ sc_package_set_verbosity(package_id, log_priority) -Set the logging verbosity of a registered package. This can be called at any point in the program, any number of times. It can only lower the verbosity at and below the value of `SC_LP_THRESHOLD`. +Set the logging verbosity of a registered package. This can be called at any point in the program, any number of times. It can only lower the verbosity at and below the value of [`SC_LP_THRESHOLD`](@ref). # Arguments * `package_id`:\\[in\\] Must be a registered package identifier. @@ -773,7 +810,7 @@ void sc_package_set_verbosity (int package_id, int log_priority); ``` """ function sc_package_set_verbosity(package_id, log_priority) - @ccall libsc.sc_package_set_verbosity(package_id::Cint, log_priority::Cint)::Cvoid + @ccall libt8.sc_package_set_verbosity(package_id::Cint, log_priority::Cint)::Cvoid end """ @@ -790,7 +827,7 @@ void sc_package_set_abort_alloc_mismatch (int package_id, int set_abort); ``` """ function sc_package_set_abort_alloc_mismatch(package_id, set_abort) - @ccall libsc.sc_package_set_abort_alloc_mismatch(package_id::Cint, set_abort::Cint)::Cvoid + @ccall libt8.sc_package_set_abort_alloc_mismatch(package_id::Cint, set_abort::Cint)::Cvoid end """ @@ -804,13 +841,13 @@ void sc_package_unregister (int package_id); ``` """ function sc_package_unregister(package_id) - @ccall libsc.sc_package_unregister(package_id::Cint)::Cvoid + @ccall libt8.sc_package_unregister(package_id::Cint)::Cvoid end """ sc_package_print_summary(log_priority) -Print a summary of all packages registered with SC. Uses the `SC_LC_GLOBAL` log category which by default only prints on rank 0. +Print a summary of all packages registered with SC. Uses the [`SC_LC_GLOBAL`](@ref) log category which by default only prints on rank 0. # Arguments * `log_priority`:\\[in\\] Priority passed to sc log functions. @@ -820,7 +857,7 @@ void sc_package_print_summary (int log_priority); ``` """ function sc_package_print_summary(log_priority) - @ccall libsc.sc_package_print_summary(log_priority::Cint)::Cvoid + @ccall libt8.sc_package_print_summary(log_priority::Cint)::Cvoid end """ @@ -832,7 +869,7 @@ void sc_init (sc_MPI_Comm mpicomm, int catch_signals, int print_backtrace, sc_lo ``` """ function sc_init(mpicomm, catch_signals, print_backtrace, log_handler, log_threshold) - @ccall libsc.sc_init(mpicomm::MPI_Comm, catch_signals::Cint, print_backtrace::Cint, log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid + @ccall libt8.sc_init(mpicomm::MPI_Comm, catch_signals::Cint, print_backtrace::Cint, log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid end """ @@ -852,7 +889,7 @@ int sc_is_initialized (void); ``` """ function sc_is_initialized() - @ccall libsc.sc_is_initialized()::Cint + @ccall libt8.sc_is_initialized()::Cint end """ @@ -872,7 +909,7 @@ int sc_get_package_id (void); ``` """ function sc_get_package_id() - @ccall libsc.sc_get_package_id()::Cint + @ccall libt8.sc_get_package_id()::Cint end """ @@ -886,7 +923,7 @@ void sc_finalize (void); ``` """ function sc_finalize() - @ccall libsc.sc_finalize()::Cvoid + @ccall libt8.sc_finalize()::Cvoid end """ @@ -902,13 +939,13 @@ int sc_finalize_noabort (void); ``` """ function sc_finalize_noabort() - @ccall libsc.sc_finalize_noabort()::Cint + @ccall libt8.sc_finalize_noabort()::Cint end """ sc_is_root() -Identify the root process. Only meaningful between [`sc_init`](@ref) and [`sc_finalize`](@ref) and with a communicator that is not `sc_MPI_COMM_NULL` (otherwise always true). +Identify the root process. Only meaningful between [`sc_init`](@ref) and [`sc_finalize`](@ref) and with a communicator that is not [`sc_MPI_COMM_NULL`](@ref) (otherwise always true). # Returns Return true for the root process and false otherwise. @@ -918,7 +955,7 @@ int sc_is_root (void); ``` """ function sc_is_root() - @ccall libsc.sc_is_root()::Cint + @ccall libt8.sc_is_root()::Cint end """ @@ -938,12 +975,12 @@ void sc_strcopy (char *dest, size_t size, const char *src); ``` """ function sc_strcopy(dest, size, src) - @ccall libsc.sc_strcopy(dest::Cstring, size::Csize_t, src::Cstring)::Cvoid + @ccall libt8.sc_strcopy(dest::Cstring, size::Csize_t, src::Cstring)::Cvoid end # automatic type deduction for variadic arguments may not be what you want, please use with caution @generated function sc_snprintf(str, size, format, va_list...) - :(@ccall(libsc.sc_snprintf(str::Cstring, size::Csize_t, format::Cstring; $(to_c_type_pairs(va_list)...))::Cvoid)) + :(@ccall(libt8.sc_snprintf(str::Cstring, size::Csize_t, format::Cstring; $(to_c_type_pairs(va_list)...))::Cvoid)) end """ @@ -959,7 +996,7 @@ const char *sc_version (void); ``` """ function sc_version() - @ccall libsc.sc_version()::Cstring + @ccall libt8.sc_version()::Cstring end """ @@ -975,7 +1012,7 @@ int sc_version_major (void); ``` """ function sc_version_major() - @ccall libsc.sc_version_major()::Cint + @ccall libt8.sc_version_major()::Cint end """ @@ -991,7 +1028,7 @@ int sc_version_minor (void); ``` """ function sc_version_minor() - @ccall libsc.sc_version_minor()::Cint + @ccall libt8.sc_version_minor()::Cint end """ @@ -1007,7 +1044,7 @@ int sc_have_zlib (void); ``` """ function sc_have_zlib() - @ccall libsc.sc_have_zlib()::Cint + @ccall libt8.sc_have_zlib()::Cint end """ @@ -1023,7 +1060,7 @@ int sc_have_json (void); ``` """ function sc_have_json() - @ccall libsc.sc_have_json()::Cint + @ccall libt8.sc_have_json()::Cint end # typedef unsigned int ( * sc_hash_function_t ) ( const void * v , const void * u ) @@ -1079,7 +1116,7 @@ size_t sc_array_memory_used (sc_array_t * array, int is_dynamic); ``` """ function sc_array_memory_used(array, is_dynamic) - @ccall libsc.sc_array_memory_used(array::Ptr{sc_array_t}, is_dynamic::Cint)::Csize_t + @ccall libt8.sc_array_memory_used(array::Ptr{sc_array_t}, is_dynamic::Cint)::Csize_t end """ @@ -1097,7 +1134,7 @@ sc_array_t *sc_array_new (size_t elem_size); ``` """ function sc_array_new(elem_size) - @ccall libsc.sc_array_new(elem_size::Csize_t)::Ptr{sc_array_t} + @ccall libt8.sc_array_new(elem_size::Csize_t)::Ptr{sc_array_t} end """ @@ -1115,7 +1152,7 @@ sc_array_t *sc_array_new_view (sc_array_t * array, size_t offset, size_t length) ``` """ function sc_array_new_view(array, offset, length) - @ccall libsc.sc_array_new_view(array::Ptr{sc_array_t}, offset::Csize_t, length::Csize_t)::Ptr{sc_array_t} + @ccall libt8.sc_array_new_view(array::Ptr{sc_array_t}, offset::Csize_t, length::Csize_t)::Ptr{sc_array_t} end """ @@ -1133,7 +1170,7 @@ sc_array_t *sc_array_new_data (void *base, size_t elem_size, size_t elem_count); ``` """ function sc_array_new_data(base, elem_size, elem_count) - @ccall libsc.sc_array_new_data(base::Ptr{Cvoid}, elem_size::Csize_t, elem_count::Csize_t)::Ptr{sc_array_t} + @ccall libt8.sc_array_new_data(base::Ptr{Cvoid}, elem_size::Csize_t, elem_count::Csize_t)::Ptr{sc_array_t} end """ @@ -1149,7 +1186,7 @@ void sc_array_destroy (sc_array_t * array); ``` """ function sc_array_destroy(array) - @ccall libsc.sc_array_destroy(array::Ptr{sc_array_t})::Cvoid + @ccall libt8.sc_array_destroy(array::Ptr{sc_array_t})::Cvoid end """ @@ -1165,7 +1202,7 @@ void sc_array_destroy_null (sc_array_t ** parray); ``` """ function sc_array_destroy_null(parray) - @ccall libsc.sc_array_destroy_null(parray::Ptr{Ptr{sc_array_t}})::Cvoid + @ccall libt8.sc_array_destroy_null(parray::Ptr{Ptr{sc_array_t}})::Cvoid end """ @@ -1182,7 +1219,7 @@ void sc_array_init (sc_array_t * array, size_t elem_size); ``` """ function sc_array_init(array, elem_size) - @ccall libsc.sc_array_init(array::Ptr{sc_array_t}, elem_size::Csize_t)::Cvoid + @ccall libt8.sc_array_init(array::Ptr{sc_array_t}, elem_size::Csize_t)::Cvoid end """ @@ -1200,7 +1237,7 @@ void sc_array_init_size (sc_array_t * array, size_t elem_size, size_t elem_count ``` """ function sc_array_init_size(array, elem_size, elem_count) - @ccall libsc.sc_array_init_size(array::Ptr{sc_array_t}, elem_size::Csize_t, elem_count::Csize_t)::Cvoid + @ccall libt8.sc_array_init_size(array::Ptr{sc_array_t}, elem_size::Csize_t, elem_count::Csize_t)::Cvoid end """ @@ -1218,7 +1255,7 @@ void sc_array_init_count (sc_array_t * array, size_t elem_size, size_t elem_coun ``` """ function sc_array_init_count(array, elem_size, elem_count) - @ccall libsc.sc_array_init_count(array::Ptr{sc_array_t}, elem_size::Csize_t, elem_count::Csize_t)::Cvoid + @ccall libt8.sc_array_init_count(array::Ptr{sc_array_t}, elem_size::Csize_t, elem_count::Csize_t)::Cvoid end """ @@ -1237,7 +1274,7 @@ void sc_array_init_view (sc_array_t * view, sc_array_t * array, size_t offset, s ``` """ function sc_array_init_view(view, array, offset, length) - @ccall libsc.sc_array_init_view(view::Ptr{sc_array_t}, array::Ptr{sc_array_t}, offset::Csize_t, length::Csize_t)::Cvoid + @ccall libt8.sc_array_init_view(view::Ptr{sc_array_t}, array::Ptr{sc_array_t}, offset::Csize_t, length::Csize_t)::Cvoid end """ @@ -1256,7 +1293,7 @@ void sc_array_init_reshape (sc_array_t * view, sc_array_t * array, size_t elem_s ``` """ function sc_array_init_reshape(view, array, elem_size, elem_count) - @ccall libsc.sc_array_init_reshape(view::Ptr{sc_array_t}, array::Ptr{sc_array_t}, elem_size::Csize_t, elem_count::Csize_t)::Cvoid + @ccall libt8.sc_array_init_reshape(view::Ptr{sc_array_t}, array::Ptr{sc_array_t}, elem_size::Csize_t, elem_count::Csize_t)::Cvoid end """ @@ -1275,7 +1312,7 @@ void sc_array_init_data (sc_array_t * view, void *base, size_t elem_size, size_t ``` """ function sc_array_init_data(view, base, elem_size, elem_count) - @ccall libsc.sc_array_init_data(view::Ptr{sc_array_t}, base::Ptr{Cvoid}, elem_size::Csize_t, elem_count::Csize_t)::Cvoid + @ccall libt8.sc_array_init_data(view::Ptr{sc_array_t}, base::Ptr{Cvoid}, elem_size::Csize_t, elem_count::Csize_t)::Cvoid end """ @@ -1292,7 +1329,7 @@ void sc_array_memset (sc_array_t * array, int c); ``` """ function sc_array_memset(array, c) - @ccall libsc.sc_array_memset(array::Ptr{sc_array_t}, c::Cint)::Cvoid + @ccall libt8.sc_array_memset(array::Ptr{sc_array_t}, c::Cint)::Cvoid end """ @@ -1312,7 +1349,7 @@ void sc_array_reset (sc_array_t * array); ``` """ function sc_array_reset(array) - @ccall libsc.sc_array_reset(array::Ptr{sc_array_t})::Cvoid + @ccall libt8.sc_array_reset(array::Ptr{sc_array_t})::Cvoid end """ @@ -1332,7 +1369,7 @@ void sc_array_truncate (sc_array_t * array); ``` """ function sc_array_truncate(array) - @ccall libsc.sc_array_truncate(array::Ptr{sc_array_t})::Cvoid + @ccall libt8.sc_array_truncate(array::Ptr{sc_array_t})::Cvoid end """ @@ -1349,7 +1386,7 @@ void sc_array_rewind (sc_array_t * array, size_t new_count); ``` """ function sc_array_rewind(array, new_count) - @ccall libsc.sc_array_rewind(array::Ptr{sc_array_t}, new_count::Csize_t)::Cvoid + @ccall libt8.sc_array_rewind(array::Ptr{sc_array_t}, new_count::Csize_t)::Cvoid end """ @@ -1366,7 +1403,7 @@ void sc_array_resize (sc_array_t * array, size_t new_count); ``` """ function sc_array_resize(array, new_count) - @ccall libsc.sc_array_resize(array::Ptr{sc_array_t}, new_count::Csize_t)::Cvoid + @ccall libt8.sc_array_resize(array::Ptr{sc_array_t}, new_count::Csize_t)::Cvoid end """ @@ -1383,7 +1420,7 @@ void sc_array_copy (sc_array_t * dest, sc_array_t * src); ``` """ function sc_array_copy(dest, src) - @ccall libsc.sc_array_copy(dest::Ptr{sc_array_t}, src::Ptr{sc_array_t})::Cvoid + @ccall libt8.sc_array_copy(dest::Ptr{sc_array_t}, src::Ptr{sc_array_t})::Cvoid end """ @@ -1401,7 +1438,7 @@ void sc_array_copy_into (sc_array_t * dest, size_t dest_offset, sc_array_t * src ``` """ function sc_array_copy_into(dest, dest_offset, src) - @ccall libsc.sc_array_copy_into(dest::Ptr{sc_array_t}, dest_offset::Csize_t, src::Ptr{sc_array_t})::Cvoid + @ccall libt8.sc_array_copy_into(dest::Ptr{sc_array_t}, dest_offset::Csize_t, src::Ptr{sc_array_t})::Cvoid end """ @@ -1421,7 +1458,7 @@ void sc_array_move_part (sc_array_t * dest, size_t dest_offset, sc_array_t * src ``` """ function sc_array_move_part(dest, dest_offset, src, src_offset, count) - @ccall libsc.sc_array_move_part(dest::Ptr{sc_array_t}, dest_offset::Csize_t, src::Ptr{sc_array_t}, src_offset::Csize_t, count::Csize_t)::Cvoid + @ccall libt8.sc_array_move_part(dest::Ptr{sc_array_t}, dest_offset::Csize_t, src::Ptr{sc_array_t}, src_offset::Csize_t, count::Csize_t)::Cvoid end """ @@ -1438,7 +1475,7 @@ void sc_array_sort (sc_array_t * array, int (*compar) (const void *, const void ``` """ function sc_array_sort(array, compar) - @ccall libsc.sc_array_sort(array::Ptr{sc_array_t}, compar::Ptr{Cvoid})::Cvoid + @ccall libt8.sc_array_sort(array::Ptr{sc_array_t}, compar::Ptr{Cvoid})::Cvoid end """ @@ -1457,7 +1494,7 @@ int sc_array_is_sorted (sc_array_t * array, int (*compar) (const void *, const v ``` """ function sc_array_is_sorted(array, compar) - @ccall libsc.sc_array_is_sorted(array::Ptr{sc_array_t}, compar::Ptr{Cvoid})::Cint + @ccall libt8.sc_array_is_sorted(array::Ptr{sc_array_t}, compar::Ptr{Cvoid})::Cint end """ @@ -1476,7 +1513,7 @@ int sc_array_is_equal (sc_array_t * array, sc_array_t * other); ``` """ function sc_array_is_equal(array, other) - @ccall libsc.sc_array_is_equal(array::Ptr{sc_array_t}, other::Ptr{sc_array_t})::Cint + @ccall libt8.sc_array_is_equal(array::Ptr{sc_array_t}, other::Ptr{sc_array_t})::Cint end """ @@ -1493,7 +1530,7 @@ void sc_array_uniq (sc_array_t * array, int (*compar) (const void *, const void ``` """ function sc_array_uniq(array, compar) - @ccall libsc.sc_array_uniq(array::Ptr{sc_array_t}, compar::Ptr{Cvoid})::Cvoid + @ccall libt8.sc_array_uniq(array::Ptr{sc_array_t}, compar::Ptr{Cvoid})::Cvoid end """ @@ -1513,7 +1550,7 @@ ssize_t sc_array_bsearch (sc_array_t * array, const void *key, int (*compar) (co ``` """ function sc_array_bsearch(array, key, compar) - @ccall libsc.sc_array_bsearch(array::Ptr{sc_array_t}, key::Ptr{Cvoid}, compar::Ptr{Cvoid})::Cssize_t + @ccall libt8.sc_array_bsearch(array::Ptr{sc_array_t}, key::Ptr{Cvoid}, compar::Ptr{Cvoid})::Cssize_t end # typedef size_t ( * sc_array_type_t ) ( sc_array_t * array , size_t index , void * data ) @@ -1544,7 +1581,7 @@ void sc_array_split (sc_array_t * array, sc_array_t * offsets, size_t num_types, ``` """ function sc_array_split(array, offsets, num_types, type_fn, data) - @ccall libsc.sc_array_split(array::Ptr{sc_array_t}, offsets::Ptr{sc_array_t}, num_types::Csize_t, type_fn::sc_array_type_t, data::Ptr{Cvoid})::Cvoid + @ccall libt8.sc_array_split(array::Ptr{sc_array_t}, offsets::Ptr{sc_array_t}, num_types::Csize_t, type_fn::sc_array_type_t, data::Ptr{Cvoid})::Cvoid end """ @@ -1562,7 +1599,7 @@ int sc_array_is_permutation (sc_array_t * array); ``` """ function sc_array_is_permutation(array) - @ccall libsc.sc_array_is_permutation(array::Ptr{sc_array_t})::Cint + @ccall libt8.sc_array_is_permutation(array::Ptr{sc_array_t})::Cint end """ @@ -1580,7 +1617,7 @@ void sc_array_permute (sc_array_t * array, sc_array_t * newindices, int keepperm ``` """ function sc_array_permute(array, newindices, keepperm) - @ccall libsc.sc_array_permute(array::Ptr{sc_array_t}, newindices::Ptr{sc_array_t}, keepperm::Cint)::Cvoid + @ccall libt8.sc_array_permute(array::Ptr{sc_array_t}, newindices::Ptr{sc_array_t}, keepperm::Cint)::Cvoid end """ @@ -1594,7 +1631,7 @@ unsigned int sc_array_checksum (sc_array_t * array); ``` """ function sc_array_checksum(array) - @ccall libsc.sc_array_checksum(array::Ptr{sc_array_t})::Cuint + @ccall libt8.sc_array_checksum(array::Ptr{sc_array_t})::Cuint end """ @@ -1622,7 +1659,7 @@ size_t sc_array_pqueue_add (sc_array_t * array, void *temp, int (*compar) (const ``` """ function sc_array_pqueue_add(array, temp, compar) - @ccall libsc.sc_array_pqueue_add(array::Ptr{sc_array_t}, temp::Ptr{Cvoid}, compar::Ptr{Cvoid})::Csize_t + @ccall libt8.sc_array_pqueue_add(array::Ptr{sc_array_t}, temp::Ptr{Cvoid}, compar::Ptr{Cvoid})::Csize_t end """ @@ -1650,7 +1687,7 @@ size_t sc_array_pqueue_pop (sc_array_t * array, void *result, int (*compar) (con ``` """ function sc_array_pqueue_pop(array, result, compar) - @ccall libsc.sc_array_pqueue_pop(array::Ptr{sc_array_t}, result::Ptr{Cvoid}, compar::Ptr{Cvoid})::Csize_t + @ccall libt8.sc_array_pqueue_pop(array::Ptr{sc_array_t}, result::Ptr{Cvoid}, compar::Ptr{Cvoid})::Csize_t end """ @@ -1662,7 +1699,7 @@ static inline void * sc_array_index (sc_array_t * array, size_t iz); ``` """ function sc_array_index(array, iz) - @ccall libsc.sc_array_index(array::Ptr{sc_array_t}, iz::Csize_t)::Ptr{Cvoid} + @ccall libt8.sc_array_index(array::Ptr{sc_array_t}, iz::Csize_t)::Ptr{Cvoid} end """ @@ -1674,7 +1711,7 @@ static inline void * sc_array_index_null (sc_array_t * array, size_t iz); ``` """ function sc_array_index_null(array, iz) - @ccall libsc.sc_array_index_null(array::Ptr{sc_array_t}, iz::Csize_t)::Ptr{Cvoid} + @ccall libt8.sc_array_index_null(array::Ptr{sc_array_t}, iz::Csize_t)::Ptr{Cvoid} end """ @@ -1686,7 +1723,7 @@ static inline void * sc_array_index_int (sc_array_t * array, int i); ``` """ function sc_array_index_int(array, i) - @ccall libsc.sc_array_index_int(array::Ptr{sc_array_t}, i::Cint)::Ptr{Cvoid} + @ccall libt8.sc_array_index_int(array::Ptr{sc_array_t}, i::Cint)::Ptr{Cvoid} end """ @@ -1698,7 +1735,7 @@ static inline void * sc_array_index_long (sc_array_t * array, long l); ``` """ function sc_array_index_long(array, l) - @ccall libsc.sc_array_index_long(array::Ptr{sc_array_t}, l::Clong)::Ptr{Cvoid} + @ccall libt8.sc_array_index_long(array::Ptr{sc_array_t}, l::Clong)::Ptr{Cvoid} end """ @@ -1710,7 +1747,7 @@ static inline void * sc_array_index_ssize_t (sc_array_t * array, ssize_t is); ``` """ function sc_array_index_ssize_t(array, is) - @ccall libsc.sc_array_index_ssize_t(array::Ptr{sc_array_t}, is::Cssize_t)::Ptr{Cvoid} + @ccall libt8.sc_array_index_ssize_t(array::Ptr{sc_array_t}, is::Cssize_t)::Ptr{Cvoid} end """ @@ -1722,7 +1759,7 @@ static inline void * sc_array_index_int16 (sc_array_t * array, int16_t i16); ``` """ function sc_array_index_int16(array, i16) - @ccall libsc.sc_array_index_int16(array::Ptr{sc_array_t}, i16::Int16)::Ptr{Cvoid} + @ccall libt8.sc_array_index_int16(array::Ptr{sc_array_t}, i16::Int16)::Ptr{Cvoid} end """ @@ -1734,7 +1771,7 @@ static inline size_t sc_array_position (sc_array_t * array, void *element); ``` """ function sc_array_position(array, element) - @ccall libsc.sc_array_position(array::Ptr{sc_array_t}, element::Ptr{Cvoid})::Csize_t + @ccall libt8.sc_array_position(array::Ptr{sc_array_t}, element::Ptr{Cvoid})::Csize_t end """ @@ -1746,7 +1783,7 @@ static inline void * sc_array_pop (sc_array_t * array); ``` """ function sc_array_pop(array) - @ccall libsc.sc_array_pop(array::Ptr{sc_array_t})::Ptr{Cvoid} + @ccall libt8.sc_array_pop(array::Ptr{sc_array_t})::Ptr{Cvoid} end """ @@ -1758,7 +1795,7 @@ static inline void * sc_array_push_count (sc_array_t * array, size_t add_count); ``` """ function sc_array_push_count(array, add_count) - @ccall libsc.sc_array_push_count(array::Ptr{sc_array_t}, add_count::Csize_t)::Ptr{Cvoid} + @ccall libt8.sc_array_push_count(array::Ptr{sc_array_t}, add_count::Csize_t)::Ptr{Cvoid} end """ @@ -1770,7 +1807,7 @@ static inline void * sc_array_push (sc_array_t * array); ``` """ function sc_array_push(array) - @ccall libsc.sc_array_push(array::Ptr{sc_array_t})::Ptr{Cvoid} + @ccall libt8.sc_array_push(array::Ptr{sc_array_t})::Ptr{Cvoid} end """ @@ -1814,7 +1851,7 @@ void sc_mstamp_init (sc_mstamp_t * mst, size_t stamp_unit, size_t elem_size); ``` """ function sc_mstamp_init(mst, stamp_unit, elem_size) - @ccall libsc.sc_mstamp_init(mst::Ptr{sc_mstamp_t}, stamp_unit::Csize_t, elem_size::Csize_t)::Cvoid + @ccall libt8.sc_mstamp_init(mst::Ptr{sc_mstamp_t}, stamp_unit::Csize_t, elem_size::Csize_t)::Cvoid end """ @@ -1830,7 +1867,7 @@ void sc_mstamp_reset (sc_mstamp_t * mst); ``` """ function sc_mstamp_reset(mst) - @ccall libsc.sc_mstamp_reset(mst::Ptr{sc_mstamp_t})::Cvoid + @ccall libt8.sc_mstamp_reset(mst::Ptr{sc_mstamp_t})::Cvoid end """ @@ -1846,7 +1883,7 @@ void sc_mstamp_truncate (sc_mstamp_t * mst); ``` """ function sc_mstamp_truncate(mst) - @ccall libsc.sc_mstamp_truncate(mst::Ptr{sc_mstamp_t})::Cvoid + @ccall libt8.sc_mstamp_truncate(mst::Ptr{sc_mstamp_t})::Cvoid end """ @@ -1864,7 +1901,7 @@ void *sc_mstamp_alloc (sc_mstamp_t * mst); ``` """ function sc_mstamp_alloc(mst) - @ccall libsc.sc_mstamp_alloc(mst::Ptr{sc_mstamp_t})::Ptr{Cvoid} + @ccall libt8.sc_mstamp_alloc(mst::Ptr{sc_mstamp_t})::Ptr{Cvoid} end """ @@ -1882,7 +1919,7 @@ size_t sc_mstamp_memory_used (sc_mstamp_t * mst); ``` """ function sc_mstamp_memory_used(mst) - @ccall libsc.sc_mstamp_memory_used(mst::Ptr{sc_mstamp_t})::Csize_t + @ccall libt8.sc_mstamp_memory_used(mst::Ptr{sc_mstamp_t})::Csize_t end """ @@ -1924,7 +1961,7 @@ size_t sc_mempool_memory_used (sc_mempool_t * mempool); ``` """ function sc_mempool_memory_used(mempool) - @ccall libsc.sc_mempool_memory_used(mempool::Ptr{sc_mempool_t})::Csize_t + @ccall libt8.sc_mempool_memory_used(mempool::Ptr{sc_mempool_t})::Csize_t end """ @@ -1942,7 +1979,7 @@ sc_mempool_t *sc_mempool_new (size_t elem_size); ``` """ function sc_mempool_new(elem_size) - @ccall libsc.sc_mempool_new(elem_size::Csize_t)::Ptr{sc_mempool_t} + @ccall libt8.sc_mempool_new(elem_size::Csize_t)::Ptr{sc_mempool_t} end """ @@ -1960,7 +1997,7 @@ sc_mempool_t *sc_mempool_new_zero_and_persist (size_t elem_size); ``` """ function sc_mempool_new_zero_and_persist(elem_size) - @ccall libsc.sc_mempool_new_zero_and_persist(elem_size::Csize_t)::Ptr{sc_mempool_t} + @ccall libt8.sc_mempool_new_zero_and_persist(elem_size::Csize_t)::Ptr{sc_mempool_t} end """ @@ -1977,7 +2014,7 @@ void sc_mempool_init (sc_mempool_t * mempool, size_t elem_size); ``` """ function sc_mempool_init(mempool, elem_size) - @ccall libsc.sc_mempool_init(mempool::Ptr{sc_mempool_t}, elem_size::Csize_t)::Cvoid + @ccall libt8.sc_mempool_init(mempool::Ptr{sc_mempool_t}, elem_size::Csize_t)::Cvoid end """ @@ -1993,7 +2030,7 @@ void sc_mempool_destroy (sc_mempool_t * mempool); ``` """ function sc_mempool_destroy(mempool) - @ccall libsc.sc_mempool_destroy(mempool::Ptr{sc_mempool_t})::Cvoid + @ccall libt8.sc_mempool_destroy(mempool::Ptr{sc_mempool_t})::Cvoid end """ @@ -2009,7 +2046,7 @@ void sc_mempool_destroy_null (sc_mempool_t ** pmempool); ``` """ function sc_mempool_destroy_null(pmempool) - @ccall libsc.sc_mempool_destroy_null(pmempool::Ptr{Ptr{sc_mempool_t}})::Cvoid + @ccall libt8.sc_mempool_destroy_null(pmempool::Ptr{Ptr{sc_mempool_t}})::Cvoid end """ @@ -2025,7 +2062,7 @@ void sc_mempool_reset (sc_mempool_t * mempool); ``` """ function sc_mempool_reset(mempool) - @ccall libsc.sc_mempool_reset(mempool::Ptr{sc_mempool_t})::Cvoid + @ccall libt8.sc_mempool_reset(mempool::Ptr{sc_mempool_t})::Cvoid end """ @@ -2041,7 +2078,7 @@ void sc_mempool_truncate (sc_mempool_t * mempool); ``` """ function sc_mempool_truncate(mempool) - @ccall libsc.sc_mempool_truncate(mempool::Ptr{sc_mempool_t})::Cvoid + @ccall libt8.sc_mempool_truncate(mempool::Ptr{sc_mempool_t})::Cvoid end """ @@ -2053,7 +2090,7 @@ static inline void * sc_mempool_alloc (sc_mempool_t * mempool); ``` """ function sc_mempool_alloc(mempool) - @ccall libsc.sc_mempool_alloc(mempool::Ptr{sc_mempool_t})::Ptr{Cvoid} + @ccall libt8.sc_mempool_alloc(mempool::Ptr{sc_mempool_t})::Ptr{Cvoid} end """ @@ -2065,7 +2102,7 @@ static inline void sc_mempool_free (sc_mempool_t * mempool, void *elem); ``` """ function sc_mempool_free(mempool, elem) - @ccall libsc.sc_mempool_free(mempool::Ptr{sc_mempool_t}, elem::Ptr{Cvoid})::Cvoid + @ccall libt8.sc_mempool_free(mempool::Ptr{sc_mempool_t}, elem::Ptr{Cvoid})::Cvoid end """ @@ -2126,7 +2163,7 @@ size_t sc_list_memory_used (sc_list_t * list, int is_dynamic); ``` """ function sc_list_memory_used(list, is_dynamic) - @ccall libsc.sc_list_memory_used(list::Ptr{sc_list_t}, is_dynamic::Cint)::Csize_t + @ccall libt8.sc_list_memory_used(list::Ptr{sc_list_t}, is_dynamic::Cint)::Csize_t end """ @@ -2144,7 +2181,7 @@ sc_list_t *sc_list_new (sc_mempool_t * allocator); ``` """ function sc_list_new(allocator) - @ccall libsc.sc_list_new(allocator::Ptr{sc_mempool_t})::Ptr{sc_list_t} + @ccall libt8.sc_list_new(allocator::Ptr{sc_mempool_t})::Ptr{sc_list_t} end """ @@ -2164,7 +2201,7 @@ void sc_list_destroy (sc_list_t * list); ``` """ function sc_list_destroy(list) - @ccall libsc.sc_list_destroy(list::Ptr{sc_list_t})::Cvoid + @ccall libt8.sc_list_destroy(list::Ptr{sc_list_t})::Cvoid end """ @@ -2181,7 +2218,7 @@ void sc_list_init (sc_list_t * list, sc_mempool_t * allocator); ``` """ function sc_list_init(list, allocator) - @ccall libsc.sc_list_init(list::Ptr{sc_list_t}, allocator::Ptr{sc_mempool_t})::Cvoid + @ccall libt8.sc_list_init(list::Ptr{sc_list_t}, allocator::Ptr{sc_mempool_t})::Cvoid end """ @@ -2201,7 +2238,7 @@ void sc_list_reset (sc_list_t * list); ``` """ function sc_list_reset(list) - @ccall libsc.sc_list_reset(list::Ptr{sc_list_t})::Cvoid + @ccall libt8.sc_list_reset(list::Ptr{sc_list_t})::Cvoid end """ @@ -2217,7 +2254,7 @@ void sc_list_unlink (sc_list_t * list); ``` """ function sc_list_unlink(list) - @ccall libsc.sc_list_unlink(list::Ptr{sc_list_t})::Cvoid + @ccall libt8.sc_list_unlink(list::Ptr{sc_list_t})::Cvoid end """ @@ -2236,7 +2273,7 @@ sc_link_t *sc_list_prepend (sc_list_t * list, void *data); ``` """ function sc_list_prepend(list, data) - @ccall libsc.sc_list_prepend(list::Ptr{sc_list_t}, data::Ptr{Cvoid})::Ptr{sc_link_t} + @ccall libt8.sc_list_prepend(list::Ptr{sc_list_t}, data::Ptr{Cvoid})::Ptr{sc_link_t} end """ @@ -2255,7 +2292,7 @@ sc_link_t *sc_list_append (sc_list_t * list, void *data); ``` """ function sc_list_append(list, data) - @ccall libsc.sc_list_append(list::Ptr{sc_list_t}, data::Ptr{Cvoid})::Ptr{sc_link_t} + @ccall libt8.sc_list_append(list::Ptr{sc_list_t}, data::Ptr{Cvoid})::Ptr{sc_link_t} end """ @@ -2275,7 +2312,7 @@ sc_link_t *sc_list_insert (sc_list_t * list, sc_link_t * pred, void *data); ``` """ function sc_list_insert(list, pred, data) - @ccall libsc.sc_list_insert(list::Ptr{sc_list_t}, pred::Ptr{sc_link_t}, data::Ptr{Cvoid})::Ptr{sc_link_t} + @ccall libt8.sc_list_insert(list::Ptr{sc_list_t}, pred::Ptr{sc_link_t}, data::Ptr{Cvoid})::Ptr{sc_link_t} end """ @@ -2294,7 +2331,7 @@ void *sc_list_remove (sc_list_t * list, sc_link_t * pred); ``` """ function sc_list_remove(list, pred) - @ccall libsc.sc_list_remove(list::Ptr{sc_list_t}, pred::Ptr{sc_link_t})::Ptr{Cvoid} + @ccall libt8.sc_list_remove(list::Ptr{sc_list_t}, pred::Ptr{sc_link_t})::Ptr{Cvoid} end """ @@ -2312,7 +2349,7 @@ void *sc_list_pop (sc_list_t * list); ``` """ function sc_list_pop(list) - @ccall libsc.sc_list_pop(list::Ptr{sc_list_t})::Ptr{Cvoid} + @ccall libt8.sc_list_pop(list::Ptr{sc_list_t})::Ptr{Cvoid} end """ @@ -2363,7 +2400,7 @@ unsigned int sc_hash_function_string (const void *s, const void *u); ``` """ function sc_hash_function_string(s, u) - @ccall libsc.sc_hash_function_string(s::Ptr{Cvoid}, u::Ptr{Cvoid})::Cuint + @ccall libt8.sc_hash_function_string(s::Ptr{Cvoid}, u::Ptr{Cvoid})::Cuint end """ @@ -2381,7 +2418,7 @@ size_t sc_hash_memory_used (sc_hash_t * hash); ``` """ function sc_hash_memory_used(hash) - @ccall libsc.sc_hash_memory_used(hash::Ptr{sc_hash_t})::Csize_t + @ccall libt8.sc_hash_memory_used(hash::Ptr{sc_hash_t})::Csize_t end """ @@ -2400,7 +2437,7 @@ sc_hash_t *sc_hash_new (sc_hash_function_t hash_fn, sc_equal_function_t equal_fn ``` """ function sc_hash_new(hash_fn, equal_fn, user_data, allocator) - @ccall libsc.sc_hash_new(hash_fn::sc_hash_function_t, equal_fn::sc_equal_function_t, user_data::Ptr{Cvoid}, allocator::Ptr{sc_mempool_t})::Ptr{sc_hash_t} + @ccall libt8.sc_hash_new(hash_fn::sc_hash_function_t, equal_fn::sc_equal_function_t, user_data::Ptr{Cvoid}, allocator::Ptr{sc_mempool_t})::Ptr{sc_hash_t} end """ @@ -2420,7 +2457,7 @@ void sc_hash_destroy (sc_hash_t * hash); ``` """ function sc_hash_destroy(hash) - @ccall libsc.sc_hash_destroy(hash::Ptr{sc_hash_t})::Cvoid + @ccall libt8.sc_hash_destroy(hash::Ptr{sc_hash_t})::Cvoid end """ @@ -2436,7 +2473,7 @@ void sc_hash_destroy_null (sc_hash_t ** phash); ``` """ function sc_hash_destroy_null(phash) - @ccall libsc.sc_hash_destroy_null(phash::Ptr{Ptr{sc_hash_t}})::Cvoid + @ccall libt8.sc_hash_destroy_null(phash::Ptr{Ptr{sc_hash_t}})::Cvoid end """ @@ -2452,7 +2489,7 @@ void sc_hash_truncate (sc_hash_t * hash); ``` """ function sc_hash_truncate(hash) - @ccall libsc.sc_hash_truncate(hash::Ptr{sc_hash_t})::Cvoid + @ccall libt8.sc_hash_truncate(hash::Ptr{sc_hash_t})::Cvoid end """ @@ -2470,7 +2507,7 @@ void sc_hash_unlink (sc_hash_t * hash); ``` """ function sc_hash_unlink(hash) - @ccall libsc.sc_hash_unlink(hash::Ptr{sc_hash_t})::Cvoid + @ccall libt8.sc_hash_unlink(hash::Ptr{sc_hash_t})::Cvoid end """ @@ -2486,7 +2523,7 @@ void sc_hash_unlink_destroy (sc_hash_t * hash); ``` """ function sc_hash_unlink_destroy(hash) - @ccall libsc.sc_hash_unlink_destroy(hash::Ptr{sc_hash_t})::Cvoid + @ccall libt8.sc_hash_unlink_destroy(hash::Ptr{sc_hash_t})::Cvoid end """ @@ -2506,7 +2543,7 @@ int sc_hash_lookup (sc_hash_t * hash, void *v, void ***found); ``` """ function sc_hash_lookup(hash, v, found) - @ccall libsc.sc_hash_lookup(hash::Ptr{sc_hash_t}, v::Ptr{Cvoid}, found::Ptr{Ptr{Ptr{Cvoid}}})::Cint + @ccall libt8.sc_hash_lookup(hash::Ptr{sc_hash_t}, v::Ptr{Cvoid}, found::Ptr{Ptr{Ptr{Cvoid}}})::Cint end """ @@ -2526,7 +2563,7 @@ int sc_hash_insert_unique (sc_hash_t * hash, void *v, void ***found); ``` """ function sc_hash_insert_unique(hash, v, found) - @ccall libsc.sc_hash_insert_unique(hash::Ptr{sc_hash_t}, v::Ptr{Cvoid}, found::Ptr{Ptr{Ptr{Cvoid}}})::Cint + @ccall libt8.sc_hash_insert_unique(hash::Ptr{sc_hash_t}, v::Ptr{Cvoid}, found::Ptr{Ptr{Ptr{Cvoid}}})::Cint end """ @@ -2546,7 +2583,7 @@ int sc_hash_remove (sc_hash_t * hash, void *v, void **found); ``` """ function sc_hash_remove(hash, v, found) - @ccall libsc.sc_hash_remove(hash::Ptr{sc_hash_t}, v::Ptr{Cvoid}, found::Ptr{Ptr{Cvoid}})::Cint + @ccall libt8.sc_hash_remove(hash::Ptr{sc_hash_t}, v::Ptr{Cvoid}, found::Ptr{Ptr{Cvoid}})::Cint end """ @@ -2563,7 +2600,7 @@ void sc_hash_foreach (sc_hash_t * hash, sc_hash_foreach_t fn); ``` """ function sc_hash_foreach(hash, fn) - @ccall libsc.sc_hash_foreach(hash::Ptr{sc_hash_t}, fn::sc_hash_foreach_t)::Cvoid + @ccall libt8.sc_hash_foreach(hash::Ptr{sc_hash_t}, fn::sc_hash_foreach_t)::Cvoid end """ @@ -2581,7 +2618,7 @@ void sc_hash_print_statistics (int package_id, int log_priority, sc_hash_t * has ``` """ function sc_hash_print_statistics(package_id, log_priority, hash) - @ccall libsc.sc_hash_print_statistics(package_id::Cint, log_priority::Cint, hash::Ptr{sc_hash_t})::Cvoid + @ccall libt8.sc_hash_print_statistics(package_id::Cint, log_priority::Cint, hash::Ptr{sc_hash_t})::Cvoid end mutable struct sc_hash_array_data end @@ -2626,7 +2663,7 @@ size_t sc_hash_array_memory_used (sc_hash_array_t * ha); ``` """ function sc_hash_array_memory_used(ha) - @ccall libsc.sc_hash_array_memory_used(ha::Ptr{sc_hash_array_t})::Csize_t + @ccall libt8.sc_hash_array_memory_used(ha::Ptr{sc_hash_array_t})::Csize_t end """ @@ -2645,7 +2682,7 @@ sc_hash_array_t *sc_hash_array_new (size_t elem_size, sc_hash_function_t hash_fn ``` """ function sc_hash_array_new(elem_size, hash_fn, equal_fn, user_data) - @ccall libsc.sc_hash_array_new(elem_size::Csize_t, hash_fn::sc_hash_function_t, equal_fn::sc_equal_function_t, user_data::Ptr{Cvoid})::Ptr{sc_hash_array_t} + @ccall libt8.sc_hash_array_new(elem_size::Csize_t, hash_fn::sc_hash_function_t, equal_fn::sc_equal_function_t, user_data::Ptr{Cvoid})::Ptr{sc_hash_array_t} end """ @@ -2661,7 +2698,7 @@ void sc_hash_array_destroy (sc_hash_array_t * hash_array); ``` """ function sc_hash_array_destroy(hash_array) - @ccall libsc.sc_hash_array_destroy(hash_array::Ptr{sc_hash_array_t})::Cvoid + @ccall libt8.sc_hash_array_destroy(hash_array::Ptr{sc_hash_array_t})::Cvoid end """ @@ -2679,7 +2716,7 @@ int sc_hash_array_is_valid (sc_hash_array_t * hash_array); ``` """ function sc_hash_array_is_valid(hash_array) - @ccall libsc.sc_hash_array_is_valid(hash_array::Ptr{sc_hash_array_t})::Cint + @ccall libt8.sc_hash_array_is_valid(hash_array::Ptr{sc_hash_array_t})::Cint end """ @@ -2695,7 +2732,7 @@ void sc_hash_array_truncate (sc_hash_array_t * hash_array); ``` """ function sc_hash_array_truncate(hash_array) - @ccall libsc.sc_hash_array_truncate(hash_array::Ptr{sc_hash_array_t})::Cvoid + @ccall libt8.sc_hash_array_truncate(hash_array::Ptr{sc_hash_array_t})::Cvoid end """ @@ -2715,7 +2752,7 @@ int sc_hash_array_lookup (sc_hash_array_t * hash_array, void *v, size_t *positio ``` """ function sc_hash_array_lookup(hash_array, v, position) - @ccall libsc.sc_hash_array_lookup(hash_array::Ptr{sc_hash_array_t}, v::Ptr{Cvoid}, position::Ptr{Csize_t})::Cint + @ccall libt8.sc_hash_array_lookup(hash_array::Ptr{sc_hash_array_t}, v::Ptr{Cvoid}, position::Ptr{Csize_t})::Cint end """ @@ -2735,7 +2772,7 @@ void *sc_hash_array_insert_unique (sc_hash_array_t * hash_array, void *v, size_t ``` """ function sc_hash_array_insert_unique(hash_array, v, position) - @ccall libsc.sc_hash_array_insert_unique(hash_array::Ptr{sc_hash_array_t}, v::Ptr{Cvoid}, position::Ptr{Csize_t})::Ptr{Cvoid} + @ccall libt8.sc_hash_array_insert_unique(hash_array::Ptr{sc_hash_array_t}, v::Ptr{Cvoid}, position::Ptr{Csize_t})::Ptr{Cvoid} end """ @@ -2752,7 +2789,7 @@ void sc_hash_array_foreach (sc_hash_array_t * hash_array, sc_hash_foreach_t fn); ``` """ function sc_hash_array_foreach(hash_array, fn) - @ccall libsc.sc_hash_array_foreach(hash_array::Ptr{sc_hash_array_t}, fn::sc_hash_foreach_t)::Cvoid + @ccall libt8.sc_hash_array_foreach(hash_array::Ptr{sc_hash_array_t}, fn::sc_hash_foreach_t)::Cvoid end """ @@ -2769,7 +2806,7 @@ void sc_hash_array_rip (sc_hash_array_t * hash_array, sc_array_t * rip); ``` """ function sc_hash_array_rip(hash_array, rip) - @ccall libsc.sc_hash_array_rip(hash_array::Ptr{sc_hash_array_t}, rip::Ptr{sc_array_t})::Cvoid + @ccall libt8.sc_hash_array_rip(hash_array::Ptr{sc_hash_array_t}, rip::Ptr{sc_array_t})::Cvoid end """ @@ -2812,7 +2849,7 @@ void sc_recycle_array_init (sc_recycle_array_t * rec_array, size_t elem_size); ``` """ function sc_recycle_array_init(rec_array, elem_size) - @ccall libsc.sc_recycle_array_init(rec_array::Ptr{sc_recycle_array_t}, elem_size::Csize_t)::Cvoid + @ccall libt8.sc_recycle_array_init(rec_array::Ptr{sc_recycle_array_t}, elem_size::Csize_t)::Cvoid end """ @@ -2828,7 +2865,7 @@ void sc_recycle_array_reset (sc_recycle_array_t * rec_array); ``` """ function sc_recycle_array_reset(rec_array) - @ccall libsc.sc_recycle_array_reset(rec_array::Ptr{sc_recycle_array_t})::Cvoid + @ccall libt8.sc_recycle_array_reset(rec_array::Ptr{sc_recycle_array_t})::Cvoid end """ @@ -2847,7 +2884,7 @@ void *sc_recycle_array_insert (sc_recycle_array_t * rec_array, size_t *position) ``` """ function sc_recycle_array_insert(rec_array, position) - @ccall libsc.sc_recycle_array_insert(rec_array::Ptr{sc_recycle_array_t}, position::Ptr{Csize_t})::Ptr{Cvoid} + @ccall libt8.sc_recycle_array_insert(rec_array::Ptr{sc_recycle_array_t}, position::Ptr{Csize_t})::Ptr{Cvoid} end """ @@ -2866,7 +2903,7 @@ void *sc_recycle_array_remove (sc_recycle_array_t * rec_array, size_t position); ``` """ function sc_recycle_array_remove(rec_array, position) - @ccall libsc.sc_recycle_array_remove(rec_array::Ptr{sc_recycle_array_t}, position::Csize_t)::Ptr{Cvoid} + @ccall libt8.sc_recycle_array_remove(rec_array::Ptr{sc_recycle_array_t}, position::Csize_t)::Ptr{Cvoid} end """A type for storing SFC indices""" @@ -2877,13 +2914,15 @@ const t8_linearidx_t = UInt64 Communication tags used internal to t8code. -| Enumerator | Note | -| :------------------------------------- | :-------------------------------------------------- | -| T8\\_MPI\\_PARTITION\\_CMESH | Used for coarse mesh partitioning | -| T8\\_MPI\\_PARTITION\\_FOREST | Used for forest partitioning | -| T8\\_MPI\\_GHOST\\_FOREST | Used for for ghost layer creation | -| T8\\_MPI\\_GHOST\\_EXC\\_FOREST | Used for ghost data exchange | -| T8\\_MPI\\_TEST\\_ELEMENT\\_PACK\\_TAG | Used for testing mpi pack and unpack functionality | +| Enumerator | Note | +| :------------------------------------------ | :-------------------------------------------------- | +| T8\\_MPI\\_PARTITION\\_CMESH | Used for coarse mesh partitioning | +| T8\\_MPI\\_PARTITION\\_FOREST | Used for forest partitioning | +| T8\\_MPI\\_GHOST\\_FOREST | Used for for ghost layer creation | +| T8\\_MPI\\_GHOST\\_EXC\\_FOREST | Used for ghost data exchange | +| T8\\_MPI\\_CMESH\\_UNIFORM\\_BOUNDS\\_START | Used for cmesh uniform bounds computation. | +| T8\\_MPI\\_CMESH\\_UNIFORM\\_BOUNDS\\_END | | +| T8\\_MPI\\_TEST\\_ELEMENT\\_PACK\\_TAG | Used for testing mpi pack and unpack functionality | """ @cenum t8_MPI_tag_t::UInt32 begin T8_MPI_TAG_FIRST = 214 @@ -2891,8 +2930,10 @@ Communication tags used internal to t8code. T8_MPI_PARTITION_FOREST = 296 T8_MPI_GHOST_FOREST = 297 T8_MPI_GHOST_EXC_FOREST = 298 - T8_MPI_TEST_ELEMENT_PACK_TAG = 299 - T8_MPI_TAG_LAST = 300 + T8_MPI_CMESH_UNIFORM_BOUNDS_START = 299 + T8_MPI_CMESH_UNIFORM_BOUNDS_END = 300 + T8_MPI_TEST_ELEMENT_PACK_TAG = 301 + T8_MPI_TAG_LAST = 302 end # automatic type deduction for variadic arguments may not be what you want, please use with caution @@ -2968,13 +3009,29 @@ end :(@ccall(libt8.t8_errorf(fmt::Cstring; $(to_c_type_pairs(va_list)...))::Cvoid)) end +""" + t8_set_external_log_fcn(log_fcn) + +Set a custom logging function to be used by t8code. When setting a custom logging function, the t8code internal logging function will be ignored. + +# Arguments +* `log_fcn`:\\[in\\] A function pointer to a logging function +### Prototype +```c +void t8_set_external_log_fcn (void (*log_fcn) (int category, int priority, const char *msg)); +``` +""" +function t8_set_external_log_fcn(log_fcn) + @ccall libt8.t8_set_external_log_fcn(log_fcn::Ptr{Cvoid})::Cvoid +end + """ t8_init(log_threshold) Register t8code with libsc and print version and variable information. # Arguments -* `log_threshold`:\\[in\\] Declared in sc.h. `SC_LP_DEFAULT` is fine. You can also choose from log levels SC\\_LP\\_*. +* `log_threshold`:\\[in\\] Declared in sc.h. [`SC_LP_DEFAULT`](@ref) is fine. You can also choose from log levels SC\\_LP\\_*. ### Prototype ```c void t8_init (int log_threshold); @@ -2985,14721 +3042,13566 @@ function t8_init(log_threshold) end """ - t8_sc_array_index_locidx(array, it) + t8_sc_array_index_locidx(array, index) Return a pointer to an array element indexed by a [`t8_locidx_t`](@ref). # Arguments +* `array`:\\[in\\] The array of elements. * `index`:\\[in\\] needs to be in [0]..[elem\\_count-1]. # Returns -A void * pointing to entry *it* in *array*. +A void * pointing to entry *index* in *array*. ### Prototype ```c -void * t8_sc_array_index_locidx (const sc_array_t *array, const t8_locidx_t it); +void * t8_sc_array_index_locidx (const sc_array_t *array, const t8_locidx_t index); ``` """ -function t8_sc_array_index_locidx(array, it) - @ccall libt8.t8_sc_array_index_locidx(array::Ptr{sc_array_t}, it::t8_locidx_t)::Ptr{Cvoid} +function t8_sc_array_index_locidx(array, index) + @ccall libt8.t8_sc_array_index_locidx(array::Ptr{sc_array_t}, index::t8_locidx_t)::Ptr{Cvoid} end """ - sc_shmem_type_t - -` sc_shmem.h ` - -| Enumerator | Note | -| :---------------------------- | :------------------------------------------- | -| SC\\_SHMEM\\_BASIC | use allgathers, then sum to simulate scan | -| SC\\_SHMEM\\_PRESCAN | mpi\\_scan, then allgather | -| SC\\_SHMEM\\_WINDOW | MPI\\_Win (requires MPI 3) | -| SC\\_SHMEM\\_WINDOW\\_PRESCAN | mpi\\_scan, then MPI\\_Win (requires MPI 3) | -""" -@cenum sc_shmem_type_t::UInt32 begin - SC_SHMEM_BASIC = 0 - SC_SHMEM_PRESCAN = 1 - SC_SHMEM_WINDOW = 2 - SC_SHMEM_WINDOW_PRESCAN = 3 - SC_SHMEM_NUM_TYPES = 4 - SC_SHMEM_NOT_SET = 5 -end + t8_eclass_count_boundary(theclass, min_dim, per_eclass) -""" - sc_shmem_set_type(comm, type) +Query the element class and count of boundary points. +# Arguments +* `theclass`:\\[in\\] We query a point of this element class. +* `min_dim`:\\[in\\] Ignore boundary points of lesser dimension. The ignored points get a count value of 0. +* `per_eclass`:\\[out\\] Array of length T8\\_ECLASS\\_COUNT to be filled with the count of the boundary objects, counted per each of the element classes. +# Returns +The count over all boundary points. ### Prototype ```c -void sc_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); +int t8_eclass_count_boundary (t8_eclass_t theclass, int min_dim, int *per_eclass); ``` """ -function sc_shmem_set_type(comm, type) - @ccall libsc.sc_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid +function t8_eclass_count_boundary(theclass, min_dim, per_eclass) + @ccall libt8.t8_eclass_count_boundary(theclass::t8_eclass_t, min_dim::Cint, per_eclass::Ptr{Cint})::Cint end """ - sc_shmem_get_type(comm) + t8_eclass_compare(eclass1, eclass2) +Compare two eclasses of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. + +# Arguments +* `eclass1`:\\[in\\] The first eclass to compare. +* `eclass2`:\\[in\\] The second eclass to compare. +# Returns +0 if the eclasses are equal, 1 if eclass1 > eclass2 and -1 if eclass1 < eclass2 ### Prototype ```c -sc_shmem_type_t sc_shmem_get_type (sc_MPI_Comm comm); +int t8_eclass_compare (t8_eclass_t eclass1, t8_eclass_t eclass2); ``` """ -function sc_shmem_get_type(comm) - @ccall libsc.sc_shmem_get_type(comm::MPI_Comm)::sc_shmem_type_t +function t8_eclass_compare(eclass1, eclass2) + @ccall libt8.t8_eclass_compare(eclass1::t8_eclass_t, eclass2::t8_eclass_t)::Cint end """ - sc_shmem_write_start(array, comm) + t8_eclass_is_valid(eclass) + +Check whether a class is a valid class. Returns non-zero if it is a valid class, returns zero, if the class is equal to T8\\_ECLASS\\_INVALID. +# Arguments +* `eclass`:\\[in\\] The eclass to check. +# Returns +Non-zero if *eclass* is valid, zero otherwise. ### Prototype ```c -int sc_shmem_write_start (void *array, sc_MPI_Comm comm); +int t8_eclass_is_valid (t8_eclass_t eclass); ``` """ -function sc_shmem_write_start(array, comm) - @ccall libsc.sc_shmem_write_start(array::Ptr{Cvoid}, comm::MPI_Comm)::Cint +function t8_eclass_is_valid(eclass) + @ccall libt8.t8_eclass_is_valid(eclass::t8_eclass_t)::Cint end +mutable struct t8_element end + +"""Opaque structure for a generic element, only used as pointer. Implementations are free to cast it to their internal data structure.""" +const t8_element_t = t8_element + +"""Type definition for the geometric shape of an element. Currently the possible shapes are the same as the possible element classes. I.e. T8\\_ECLASS\\_VERTEX, T8\\_ECLASS\\_TET, etc...""" +const t8_element_shape_t = t8_eclass_t + """ - sc_shmem_write_end(array, comm) + t8_element_shape_num_faces(element_shape) + +The number of codimension-one boundaries of an element class. ### Prototype ```c -void sc_shmem_write_end (void *array, sc_MPI_Comm comm); +int t8_element_shape_num_faces (int element_shape); ``` """ -function sc_shmem_write_end(array, comm) - @ccall libsc.sc_shmem_write_end(array::Ptr{Cvoid}, comm::MPI_Comm)::Cvoid +function t8_element_shape_num_faces(element_shape) + @ccall libt8.t8_element_shape_num_faces(element_shape::Cint)::Cint end """ - sc_shmem_memcpy(destarray, srcarray, bytes, comm) + t8_element_shape_max_num_faces(element_shape) + +For each dimension the maximum possible number of faces of an element\\_shape of that dimension. ### Prototype ```c -void sc_shmem_memcpy (void *destarray, void *srcarray, size_t bytes, sc_MPI_Comm comm); +int t8_element_shape_max_num_faces (int element_shape); ``` """ -function sc_shmem_memcpy(destarray, srcarray, bytes, comm) - @ccall libsc.sc_shmem_memcpy(destarray::Ptr{Cvoid}, srcarray::Ptr{Cvoid}, bytes::Csize_t, comm::MPI_Comm)::Cvoid +function t8_element_shape_max_num_faces(element_shape) + @ccall libt8.t8_element_shape_max_num_faces(element_shape::Cint)::Cint end """ - sc_shmem_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm) + t8_element_shape_num_vertices(element_shape) + +The number of vertices of an element class. ### Prototype ```c -void sc_shmem_allgather (void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, void *recvbuf, int recvcount, sc_MPI_Datatype recvtype, sc_MPI_Comm comm); +int t8_element_shape_num_vertices (int element_shape); ``` """ -function sc_shmem_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm) - @ccall libsc.sc_shmem_allgather(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvbuf::Ptr{Cvoid}, recvcount::Cint, recvtype::Cint, comm::MPI_Comm)::Cvoid +function t8_element_shape_num_vertices(element_shape) + @ccall libt8.t8_element_shape_num_vertices(element_shape::Cint)::Cint end """ - sc_shmem_prefix(sendbuf, recvbuf, count, type, op, comm) + t8_element_shape_vtk_type(element_shape) + +The vtk cell type for the element\\_shape ### Prototype ```c -void sc_shmem_prefix (void *sendbuf, void *recvbuf, int count, sc_MPI_Datatype type, sc_MPI_Op op, sc_MPI_Comm comm); +int t8_element_shape_vtk_type (int element_shape); ``` """ -function sc_shmem_prefix(sendbuf, recvbuf, count, type, op, comm) - @ccall libsc.sc_shmem_prefix(sendbuf::Ptr{Cvoid}, recvbuf::Ptr{Cvoid}, count::Cint, type::Cint, op::Cint, comm::MPI_Comm)::Cvoid +function t8_element_shape_vtk_type(element_shape) + @ccall libt8.t8_element_shape_vtk_type(element_shape::Cint)::Cint end """ - sc_refcount + t8_element_shape_t8_to_vtk_corner_number(element_shape, index) -The refcount structure is declared in public so its size is known. Its members should really never be accessed directly. +Maps the t8code corner number of the element to the vtk corner number -| Field | Note | -| :----------- | :----------------------------------------------------------- | -| package\\_id | The sc package that uses this reference counter. | -| refcount | The reference count is always positive for a valid counter. | +# Arguments +* `element_shape`:\\[in\\] The shape of the element. +* `index`:\\[in\\] The index of the corner in z-order (t8code numeration). +# Returns +The corresponding vtk index. +### Prototype +```c +int t8_element_shape_t8_to_vtk_corner_number (int element_shape, int index); +``` """ -struct sc_refcount - package_id::Cint - refcount::Cint +function t8_element_shape_t8_to_vtk_corner_number(element_shape, index) + @ccall libt8.t8_element_shape_t8_to_vtk_corner_number(element_shape::Cint, index::Cint)::Cint end -"""The refcount structure is declared in public so its size is known. Its members should really never be accessed directly.""" -const sc_refcount_t = sc_refcount - """ - sc_refcount_init_invalid(rc) + t8_element_shape_t8_corner_number(element_shape, index) -Initialize a well-defined but unusable reference counter. Specifically, we set its package identifier and reference count to -1. To make this reference counter usable, call sc_refcount_init. +Maps the vtk corner number of the element to the t8code corner number # Arguments -* `rc`:\\[out\\] This reference counter is defined as invalid. It will return false on both sc_refcount_is_active and sc_refcount_is_last. It can be made valid by calling sc_refcount_init. No other functions must be called on it. +* `element_shape`:\\[in\\] The shape of the element. +* `index`:\\[in\\] The index of the corner in vtk ordering. +# Returns +The corresponding t8code index. ### Prototype ```c -void sc_refcount_init_invalid (sc_refcount_t * rc); +int t8_element_shape_t8_corner_number (int element_shape, int index); ``` """ -function sc_refcount_init_invalid(rc) - @ccall libsc.sc_refcount_init_invalid(rc::Ptr{sc_refcount_t})::Cvoid +function t8_element_shape_t8_corner_number(element_shape, index) + @ccall libt8.t8_element_shape_t8_corner_number(element_shape::Cint, index::Cint)::Cint end """ - sc_refcount_init(rc, package_id) + t8_element_shape_to_string(element_shape) -Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. +For each element\\_shape, the name of this class as a string -# Arguments -* `rc`:\\[out\\] This reference counter is initialized to one. The object's contents may be undefined on input. -* `package_id`:\\[in\\] Either -1 or a package registered to libsc. ### Prototype ```c -void sc_refcount_init (sc_refcount_t * rc, int package_id); +const char* t8_element_shape_to_string (int element_shape); ``` """ -function sc_refcount_init(rc, package_id) - @ccall libsc.sc_refcount_init(rc::Ptr{sc_refcount_t}, package_id::Cint)::Cvoid +function t8_element_shape_to_string(element_shape) + @ccall libt8.t8_element_shape_to_string(element_shape::Cint)::Cstring end """ - sc_refcount_new(package_id) + t8_element_shape_compare(element_shape1, element_shape2) -Create a new reference counter with count initialized to 1. Equivalent to calling sc_refcount_init on a newly allocated rc object. +Compare two element\\_shapes of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. # Arguments -* `package_id`:\\[in\\] Either -1 or a package registered to libsc. +* `element_shape1`:\\[in\\] The first element\\_shape to compare. +* `element_shape2`:\\[in\\] The second element\\_shape to compare. # Returns -A reference counter with count one. +0 if the element\\_shapes are equal, 1 if element\\_shape1 > element\\_shape2 and -1 if element\\_shape1 < element\\_shape2 ### Prototype ```c -sc_refcount_t *sc_refcount_new (int package_id); +int t8_element_shape_compare (t8_element_shape_t element_shape1, t8_element_shape_t element_shape2); ``` """ -function sc_refcount_new(package_id) - @ccall libsc.sc_refcount_new(package_id::Cint)::Ptr{sc_refcount_t} +function t8_element_shape_compare(element_shape1, element_shape2) + @ccall libt8.t8_element_shape_compare(element_shape1::t8_element_shape_t, element_shape2::t8_element_shape_t)::Cint end """ - sc_refcount_destroy(rc) + t8_mat_init_xrot(mat, angle) -Destroy a reference counter. It must have been counted down to zero before, thus reached an inactive state. +Initialize given 3x3 matrix as rotation matrix around the x-axis with given angle. # Arguments -* `rc`:\\[in,out\\] This reference counter must have reached count zero. +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. ### Prototype ```c -void sc_refcount_destroy (sc_refcount_t * rc); +static inline void t8_mat_init_xrot (double mat[3][3], const double angle); ``` """ -function sc_refcount_destroy(rc) - @ccall libsc.sc_refcount_destroy(rc::Ptr{sc_refcount_t})::Cvoid +function t8_mat_init_xrot(mat, angle) + @ccall libt8.t8_mat_init_xrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid end """ - sc_refcount_ref(rc) + t8_mat_init_yrot(mat, angle) -Increase a reference counter. The counter must be active, that is, have a value greater than zero. +Initialize given 3x3 matrix as rotation matrix around the y-axis with given angle. # Arguments -* `rc`:\\[in,out\\] This reference counter must be valid (greater zero). Its count is increased by one. +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. ### Prototype ```c -void sc_refcount_ref (sc_refcount_t * rc); +static inline void t8_mat_init_yrot (double mat[3][3], const double angle); ``` """ -function sc_refcount_ref(rc) - @ccall libsc.sc_refcount_ref(rc::Ptr{sc_refcount_t})::Cvoid +function t8_mat_init_yrot(mat, angle) + @ccall libt8.t8_mat_init_yrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid end """ - sc_refcount_unref(rc) + t8_mat_init_zrot(mat, angle) -Decrease the reference counter and notify when it reaches zero. The count must be greater zero on input. If the reference count reaches zero, which is indicated by the return value, the counter may not be used further with sc_refcount_ref or +Initialize given 3x3 matrix as rotation matrix around the z-axis with given angle. # Arguments -* `rc`:\\[in,out\\] This reference counter must be valid (greater zero). Its count is decreased by one. -# Returns -True if the count has reached zero, false otherwise. -# See also -[`sc_refcount_unref`](@ref). It is legal, however, to reactivate it later by calling, [`sc_refcount_init`](@ref). - +* `mat`:\\[in,out\\] 3x3-matrix. +* `angle`:\\[in\\] Rotation angle in radians. ### Prototype ```c -int sc_refcount_unref (sc_refcount_t * rc); +static inline void t8_mat_init_zrot (double mat[3][3], const double angle); ``` """ -function sc_refcount_unref(rc) - @ccall libsc.sc_refcount_unref(rc::Ptr{sc_refcount_t})::Cint +function t8_mat_init_zrot(mat, angle) + @ccall libt8.t8_mat_init_zrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid end """ - sc_refcount_is_active(rc) + t8_mat_mult_vec(mat, a, b) -Check whether a reference counter has a positive value. This means that the reference counter is in use and corresponds to a live object. +Apply matrix-matrix multiplication: b = M*a. # Arguments -* `rc`:\\[in\\] A reference counter. -# Returns -True if the count is greater zero, false otherwise. +* `mat`:\\[in\\] 3x3-matrix. +* `a`:\\[in\\] 3-vector. +* `b`:\\[in,out\\] 3-vector. ### Prototype ```c -int sc_refcount_is_active (const sc_refcount_t * rc); +static inline void t8_mat_mult_vec (const double mat[3][3], const double a[3], double b[3]); ``` """ -function sc_refcount_is_active(rc) - @ccall libsc.sc_refcount_is_active(rc::Ptr{sc_refcount_t})::Cint +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 """ - sc_refcount_is_last(rc) + t8_mat_mult_mat(A, B, C) -Check whether a reference counter has value one. This means that this counter is the last of its kind, which we may optimize for. +Apply matrix-matrix multiplication: C = A*B. # Arguments -* `rc`:\\[in\\] A reference counter. -# Returns -True if the count is exactly one. +* `A`:\\[in\\] 3x3-matrix. +* `B`:\\[in\\] 3x3-matrix. +* `C`:\\[in,out\\] 3x3-matrix. ### Prototype ```c -int sc_refcount_is_last (const sc_refcount_t * rc); +static inline void t8_mat_mult_mat (const double A[3][3], const double B[3][3], double C[3][3]); ``` """ -function sc_refcount_is_last(rc) - @ccall libsc.sc_refcount_is_last(rc::Ptr{sc_refcount_t})::Cint +function t8_mat_mult_mat(A, B, C) + @ccall libt8.t8_mat_mult_mat(A::Ptr{NTuple{3, Cdouble}}, B::Ptr{NTuple{3, Cdouble}}, C::Ptr{NTuple{3, Cdouble}})::Cvoid end -mutable struct t8_eclass_scheme end - -"""This typedef holds virtual functions for a particular element class.""" -const t8_eclass_scheme_c = t8_eclass_scheme - """ - t8_scheme_cxx + sc_refcount -The scheme holds implementations for one or more element classes. +The refcount structure is declared in public so its size is known. Its members should really never be accessed directly. -| Field | Note | -| :--------------- | :----------------------------------------------------- | -| rc | Reference counter for this scheme. | -| eclass\\_schemes | This array holds one virtual table per element class. | +| Field | Note | +| :----------- | :----------------------------------------------------------- | +| package\\_id | The sc package that uses this reference counter. | +| refcount | The reference count is always positive for a valid counter. | """ -struct t8_scheme_cxx - rc::sc_refcount_t - eclass_schemes::NTuple{8, Ptr{t8_eclass_scheme_c}} -end - -"""The scheme holds implementations for one or more element classes.""" -const t8_scheme_cxx_t = t8_scheme_cxx - -"""We can reuse the reference counter type from libsc.""" -const t8_refcount_t = sc_refcount_t - -struct t8_cmesh_trees - from_proc::Ptr{sc_array_t} - tree_to_proc::Ptr{Cint} - ghost_to_proc::Ptr{Cint} - ghost_globalid_to_local_id::Ptr{sc_hash_t} - global_local_mempool::Ptr{sc_mempool_t} +struct sc_refcount + package_id::Cint + refcount::Cint end -const t8_cmesh_trees_t = Ptr{t8_cmesh_trees} - -mutable struct t8_shmem_array end - -const t8_shmem_array_t = Ptr{t8_shmem_array} - -mutable struct t8_geometry_handler end - -"""This typedef holds virtual functions for the geometry handler. We need it so that we can use [`t8_geometry_handler_c`](@ref) pointers in .c files without them seeing the actual C++ code (and then not compiling) TODO: Delete this when the cmesh is a proper cpp class.""" -const t8_geometry_handler_c = t8_geometry_handler +"""The refcount structure is declared in public so its size is known. Its members should really never be accessed directly.""" +const sc_refcount_t = sc_refcount """ - t8_stash + sc_refcount_ref(rc) -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. +Increase a reference counter. The counter must be active, that is, have a value greater than zero. -| Field | Note | -| :--------- | :---------------------------------------------------------------------- | -| classes | Stores the eclasses of the trees. # See also [`t8_stash_class`](@ref) | -| joinfaces | Stores the face-connections. # See also [`t8_stash_joinface`](@ref) | -| attributes | Stores the attributes. # See also [`t8_stash_attribute`](@ref) | +# Arguments +* `rc`:\\[in,out\\] This reference counter must be valid (greater zero). Its count is increased by one. +### Prototype +```c +void sc_refcount_ref (sc_refcount_t * rc); +``` """ -struct t8_stash - classes::sc_array_t - joinfaces::sc_array_t - attributes::sc_array_t +function sc_refcount_ref(rc) + @ccall libt8.sc_refcount_ref(rc::Ptr{sc_refcount_t})::Cvoid end -const t8_stash_t = Ptr{t8_stash} - """ - t8_cprofile + sc_refcount_unref(rc) -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. +Decrease the reference counter and notify when it reaches zero. The count must be greater zero on input. If the reference count reaches zero, which is indicated by the return value, the counter may not be used further with sc_refcount_ref or -| Field | Note | -| :-------------------------------- | :------------------------------------------------------------------------------------------------------------ | -| partition\\_trees\\_shipped | The number of trees this process has sent to other in the last partition call. | -| partition\\_ghosts\\_shipped | The number of ghosts this process has sent to other in the last partition call. | -| partition\\_trees\\_recv | The number of trees this process has received from other in the last partition call. | -| partition\\_ghosts\\_recv | The number of ghosts this process has received from other in the last partition call. | -| partition\\_bytes\\_sent | The total number of bytes sent to other processes in the last partition call. | -| partition\\_procs\\_sent | The number of different processes this process has send local trees or ghosts to in the last partition call. | -| first\\_tree\\_shared | 1 if this processes' first tree is shared. 0 if not. | -| partition\\_runtime | The runtime of the last call to [`t8_cmesh_partition`](@ref). | -| commit\\_runtime | The runtime of the last call to [`t8_cmesh_commit`](@ref). | -| geometry\\_evaluate\\_num\\_calls | The number of calls to [`t8_geometry_evaluate`](@ref). | -| geometry\\_evaluate\\_runtime | The accumulated runtime of calls to [`t8_geometry_evaluate`](@ref). | +# Arguments +* `rc`:\\[in,out\\] This reference counter must be valid (greater zero). Its count is decreased by one. +# Returns +True if the count has reached zero, false otherwise. # See also -[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) -""" -struct t8_cprofile - partition_trees_shipped::t8_locidx_t - partition_ghosts_shipped::t8_locidx_t - partition_trees_recv::t8_locidx_t - partition_ghosts_recv::t8_locidx_t - partition_bytes_sent::Csize_t - partition_procs_sent::Cint - first_tree_shared::Cint - partition_runtime::Cdouble - commit_runtime::Cdouble - geometry_evaluate_num_calls::Cdouble - geometry_evaluate_runtime::Cdouble -end +[`sc_refcount_unref`](@ref). It is legal, however, to reactivate it later by calling, [`sc_refcount_init`](@ref). +### Prototype +```c +int sc_refcount_unref (sc_refcount_t * rc); +``` """ -This struct is used to profile cmesh algorithms. The cmesh struct stores a pointer to a profile struct, and if it is nonzero, various runtimes and data measurements are stored here. - -# See also -[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) -""" -const t8_cprofile_t = t8_cprofile - -""" - t8_cmesh - -This structure holds the connectivity data of the coarse mesh. It can either be replicated, then each process stores a copy of the whole mesh, or partitioned. In the latter case, each process only stores a local portion of the mesh plus information about ghost elements. - -The coarse mesh is a collection of coarse trees that can be identified along faces. TODO: this description is outdated. rewrite it. The array ctrees stores these coarse trees sorted by their (global) tree\\_id. If the mesh if partitioned it is partitioned according to an (possible only virtually existing) underlying fine mesh. Therefore the ctrees array can store duplicated trees on different processes, if each of these processes owns elements of the same tree in the fine mesh. - -Each tree stores information about its face-neighbours in an array of t8_ctree_fneighbor. - -If partitioned the ghost trees are stored in a hash table that is backed up by an array. The hash value of a ghost tree is its tree\\_id modulo the number of ghosts on this process. - -| Field | Note | -| :--------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| committed | Flag that specifies whether the cmesh is committed or not. t8_cmesh_commit | -| dimension | The dimension of the cmesh. It is set when the first tree is inserted. | -| set\\_partition | If nonzero the cmesh is partitioned. If zero each process has the whole cmesh. | -| face\\_knowledge | If partitioned the level of face knowledge that is expected. t8_mesh_set_partitioned; see t8_cmesh_set_partition. | -| set\\_partition\\_scheme | If the cmesh is to be partitioned according to a uniform level, the scheme that describes the refinement pattern. See t8_cmesh_set_partition. | -| set\\_partition\\_level | Non-negative if the cmesh should be partitioned from an already existing cmesh with an assumed *level* uniform mesh underneath. | -| set\\_from | If this cmesh shall be derived from an existing cmesh by copy or more elaborate modification, we store a pointer to this other cmesh here. | -| mpirank | Number of this MPI process. | -| mpisize | Number of MPI processes. | -| rc | The reference count of the cmesh. | -| num\\_trees | The global number of trees | -| num\\_local\\_trees | If partitioned the number of trees on this process. Otherwise the global number of trees. | -| num\\_ghosts | If partitioned the number of neighbor trees owned by different processes. | -| num\\_local\\_trees\\_per\\_eclass | After commit the number of local trees for each eclass. Stores the same entries as *num_trees_per_eclass*, if the cmesh is replicated. | -| num\\_trees\\_per\\_eclass | After commit the number of global trees for each eclass. | -| trees | structure that holds all local trees and ghosts | -| first\\_tree | The global index of the first local tree on this process. Zero if the cmesh is not partitioned. -1 if this processor is empty. See also https://github.com/DLR-AMR/t8code/wiki/Tree-indexing | -| first\\_tree\\_shared | If partitioned true if the first tree on this process is also the last tree on the next process. Always zero if num\\_local\\_trees = 0 | -| tree\\_offsets | If partitioned for each process the global index of its first local tree or -(first local tree) - 1 if the first tree on that process is shared. Since this is very memory consuming we only fill it when needed. | -| geometry\\_handler | Handles all geometries that are used by trees in this cmesh. | -| stash | Used as temporary storage for the trees before commit. | -| profile | Used to measure runtimes and statistics of the cmesh algorithms. | -# See also -t8\\_ctree\\_fneighbor -""" -struct t8_cmesh - committed::Cint - dimension::Cint - set_partition::Cint - face_knowledge::Cint - set_partition_scheme::Ptr{t8_scheme_cxx_t} - set_partition_level::Int8 - set_from::Ptr{t8_cmesh} - mpirank::Cint - mpisize::Cint - rc::t8_refcount_t - num_trees::t8_gloidx_t - num_local_trees::t8_locidx_t - num_ghosts::t8_locidx_t - num_local_trees_per_eclass::NTuple{8, t8_locidx_t} - num_trees_per_eclass::NTuple{8, t8_gloidx_t} - trees::t8_cmesh_trees_t - first_tree::t8_gloidx_t - first_tree_shared::Int8 - tree_offsets::t8_shmem_array_t - geometry_handler::Ptr{t8_geometry_handler_c} - stash::t8_stash_t - profile::Ptr{t8_cprofile_t} +function sc_refcount_unref(rc) + @ccall libt8.sc_refcount_unref(rc::Ptr{sc_refcount_t})::Cint end -const t8_cmesh_t = Ptr{t8_cmesh} - """ - t8_eclass + sc_refcount_is_active(rc) -This enumeration contains all possible element classes. +Check whether a reference counter has a positive value. This means that the reference counter is in use and corresponds to a live object. -| Enumerator | Note | -| :--------------------- | :----------------------------------------------------------------------------------------------------------------- | -| T8\\_ECLASS\\_VERTEX | The vertex is the only zero-dimensional element class. | -| T8\\_ECLASS\\_LINE | The line is the only one-dimensional element class. | -| T8\\_ECLASS\\_QUAD | The quadrilateral is one of two element classes in two dimensions. | -| T8\\_ECLASS\\_TRIANGLE | The element class for a triangle. | -| T8\\_ECLASS\\_HEX | The hexahedron is one three-dimensional element class. | -| T8\\_ECLASS\\_TET | The tetrahedron is another three-dimensional element class. | -| T8\\_ECLASS\\_PRISM | The prism has five sides: two opposing triangles joined by three quadrilaterals. | -| T8\\_ECLASS\\_PYRAMID | The pyramid has a quadrilateral as base and four triangles as sides. | -| T8\\_ECLASS\\_COUNT | This is no element class but can be used as the number of element classes. | -| T8\\_ECLASS\\_INVALID | This is no element class but can be used for the case a class of a third party library is not supported by t8code | +# Arguments +* `rc`:\\[in\\] A reference counter. +# Returns +True if the count is greater zero, false otherwise. +### Prototype +```c +int sc_refcount_is_active (const sc_refcount_t * rc); +``` """ -@cenum t8_eclass::UInt32 begin - T8_ECLASS_ZERO = 0 - T8_ECLASS_VERTEX = 0 - T8_ECLASS_LINE = 1 - T8_ECLASS_QUAD = 2 - T8_ECLASS_TRIANGLE = 3 - T8_ECLASS_HEX = 4 - T8_ECLASS_TET = 5 - T8_ECLASS_PRISM = 6 - T8_ECLASS_PYRAMID = 7 - T8_ECLASS_COUNT = 8 - T8_ECLASS_INVALID = 9 +function sc_refcount_is_active(rc) + @ccall libt8.sc_refcount_is_active(rc::Ptr{sc_refcount_t})::Cint end -"""This enumeration contains all possible element classes.""" -const t8_eclass_t = t8_eclass - """ - t8_ctree + sc_refcount_is_last(rc) -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. +Check whether a reference counter has value one. This means that this counter is the last of its kind, which we may optimize for. -| Field | Note | -| :--------------- | :------------------------------------------------------------------------------------------ | -| treeid | The local number of this tree. | -| eclass | The eclass of this tree. | -| neigh\\_offset | Adding this offset to the address of the tree yields the array of face\\_neighbor entries | -| att\\_offset | Adding this offset to the address of the tree yields the array of attribute\\_info entries | -| num\\_attributes | The number of attributes at this tree | +# Arguments +* `rc`:\\[in\\] A reference counter. +# Returns +True if the count is exactly one. +### Prototype +```c +int sc_refcount_is_last (const sc_refcount_t * rc); +``` """ -struct t8_ctree - treeid::t8_locidx_t - eclass::t8_eclass_t - neigh_offset::Csize_t - att_offset::Csize_t - num_attributes::Cint +function sc_refcount_is_last(rc) + @ccall libt8.sc_refcount_is_last(rc::Ptr{sc_refcount_t})::Cint end -const t8_ctree_t = Ptr{t8_ctree} - """ - t8_cghost + sc_refcount_init_invalid(rc) -| Field | Note | -| :--------------- | :------------------------------------------------------------------------------------------- | -| treeid | The global number of this ghost. | -| eclass | The eclass of this ghost. | -| att\\_offset | Adding this offset to the address of the ghost yields the array of attribute\\_info entries | -| num\\_attributes | The number of attributes at this ghost | +Initialize a well-defined but unusable reference counter. Specifically, we set its package identifier and reference count to -1. To make this reference counter usable, call sc_refcount_init. + +# Arguments +* `rc`:\\[out\\] This reference counter is defined as invalid. It will return false on both sc_refcount_is_active and sc_refcount_is_last. It can be made valid by calling sc_refcount_init. No other functions must be called on it. +### Prototype +```c +void sc_refcount_init_invalid (sc_refcount_t * rc); +``` """ -struct t8_cghost - treeid::t8_gloidx_t - eclass::t8_eclass_t - neigh_offset::Csize_t - att_offset::Csize_t - num_attributes::Cint +function sc_refcount_init_invalid(rc) + @ccall libt8.sc_refcount_init_invalid(rc::Ptr{sc_refcount_t})::Cvoid end -const t8_cghost_t = Ptr{t8_cghost} - """ - t8_cmesh_init(pcmesh) + sc_refcount_init(rc, package_id) -Create a new cmesh with reference count one. This cmesh needs to be specialized with the t8\\_cmesh\\_set\\_* calls. Then it needs to be set up with t8_cmesh_commit. +Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. # Arguments -* `pcmesh`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new cmesh. +* `rc`:\\[out\\] This reference counter is initialized to one. The object's contents may be undefined on input. +* `package_id`:\\[in\\] Either -1 or a package registered to libsc. ### Prototype ```c -void t8_cmesh_init (t8_cmesh_t *pcmesh); +void sc_refcount_init (sc_refcount_t * rc, int package_id); ``` """ -function t8_cmesh_init(pcmesh) - @ccall libt8.t8_cmesh_init(pcmesh::Ptr{t8_cmesh_t})::Cvoid +function sc_refcount_init(rc, package_id) + @ccall libt8.sc_refcount_init(rc::Ptr{sc_refcount_t}, package_id::Cint)::Cvoid end -# no prototype is found for this function at t8_cmesh.h:76:1, please use with caution """ - t8_cmesh_new() + sc_refcount_new(package_id) -Allocate a new un-committed cmesh. +Create a new reference counter with count initialized to 1. Equivalent to calling sc_refcount_init on a newly allocated rc object. +# Arguments +* `package_id`:\\[in\\] Either -1 or a package registered to libsc. # Returns -A pointer to an un-committed [`t8_cmesh`](@ref) structure. +A reference counter with count one. ### Prototype ```c -t8_cmesh_t t8_cmesh_new (); +sc_refcount_t *sc_refcount_new (int package_id); ``` """ -function t8_cmesh_new() - @ccall libt8.t8_cmesh_new()::t8_cmesh_t +function sc_refcount_new(package_id) + @ccall libt8.sc_refcount_new(package_id::Cint)::Ptr{sc_refcount_t} end """ - t8_cmesh_is_initialized(cmesh) + sc_refcount_destroy(rc) -Check whether a cmesh is not NULL, initialized and not committed. In addition, it asserts that the cmesh is consistent as much as possible. +Destroy a reference counter. It must have been counted down to zero before, thus reached an inactive state. # Arguments -* `cmesh`:\\[in\\] This cmesh is examined. May be NULL. -# Returns -True if cmesh is not NULL, t8_cmesh_init has been called on it, but not t8_cmesh_commit. False otherwise. +* `rc`:\\[in,out\\] This reference counter must have reached count zero. ### Prototype ```c -int t8_cmesh_is_initialized (t8_cmesh_t cmesh); +void sc_refcount_destroy (sc_refcount_t * rc); ``` """ -function t8_cmesh_is_initialized(cmesh) - @ccall libt8.t8_cmesh_is_initialized(cmesh::t8_cmesh_t)::Cint +function sc_refcount_destroy(rc) + @ccall libt8.sc_refcount_destroy(rc::Ptr{sc_refcount_t})::Cvoid end +"""We can reuse the reference counter type from libsc.""" +const t8_refcount_t = sc_refcount_t + """ - t8_cmesh_is_committed(cmesh) + t8_refcount_init(rc) -Check whether a cmesh is not NULL, initialized and committed. In addition, it asserts that the cmesh is consistent as much as possible. +Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. # Arguments -* `cmesh`:\\[in\\] This cmesh is examined. May be NULL. -# Returns -True if cmesh is not NULL and t8_cmesh_init has been called on it as well as t8_cmesh_commit. False otherwise. +* `rc`:\\[out\\] The reference counter is set to one by this call. ### Prototype ```c -int t8_cmesh_is_committed (const t8_cmesh_t cmesh); +void t8_refcount_init (t8_refcount_t *rc); ``` """ -function t8_cmesh_is_committed(cmesh) - @ccall libt8.t8_cmesh_is_committed(cmesh::t8_cmesh_t)::Cint +function t8_refcount_init(rc) + @ccall libt8.t8_refcount_init(rc::Ptr{t8_refcount_t})::Cvoid end """ - t8_cmesh_tree_vertices_negative_volume(eclass, vertices, num_vertices) + t8_refcount_new() -Given a set of vertex coordinates for a tree of a given eclass. Query whether the geometric volume of the tree with this coordinates would be negative. +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 -* `eclass`:\\[in\\] The eclass of a tree. -* `vertices`:\\[in\\] The coordinates of the tree's vertices. -* `num_vertices`:\\[in\\] The number of vertices. *vertices* must hold 3 * *num_vertices* many doubles. *num_vertices* must match t8_eclass_num_vertices[*eclass*] # Returns -True if the geometric volume describe by *vertices* is negative. False otherwise. Returns true if a tree of the given eclass with the given vertex coordinates does have negative volume. +An allocated reference counter whose count has been set to one. ### Prototype ```c -int t8_cmesh_tree_vertices_negative_volume (const t8_eclass_t eclass, const double *vertices, const int num_vertices); +t8_refcount_t * t8_refcount_new (void); ``` """ -function t8_cmesh_tree_vertices_negative_volume(eclass, vertices, num_vertices) - @ccall libt8.t8_cmesh_tree_vertices_negative_volume(eclass::t8_eclass_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cint +function t8_refcount_new() + @ccall libt8.t8_refcount_new()::Ptr{t8_refcount_t} end """ - t8_cmesh_set_derive(cmesh, set_from) + t8_refcount_destroy(rc) -This function sets a cmesh to be derived from. The default is to create a cmesh standalone by specifying all data manually. A coarse mesh can also be constructed by deriving it from an existing one. The derivation from another cmesh may optionally be combined with a repartition or uniform refinement of each tree. This function overrides a previously set cmesh to be derived from. +Destroy a reference counter that we allocated with t8_refcount_new. Its reference count must have decreased to zero. # Arguments -* `cmesh`:\\[in,out\\] Must be initialized, but not committed. May even be NULL to revert to standalone. -* `set_from`:\\[in,out\\] Reference counter on this cmesh is bumped. It will be unbumped by t8_cmesh_commit, after which *from* is no longer remembered. Other than that the from object is not changed. +* `rc`:\\[in,out\\] Allocated, formerly valid reference counter. ### Prototype ```c -void t8_cmesh_set_derive (t8_cmesh_t cmesh, t8_cmesh_t set_from); +void t8_refcount_destroy (t8_refcount_t *rc); ``` """ -function t8_cmesh_set_derive(cmesh, set_from) - @ccall libt8.t8_cmesh_set_derive(cmesh::t8_cmesh_t, set_from::t8_cmesh_t)::Cvoid +function t8_refcount_destroy(rc) + @ccall libt8.t8_refcount_destroy(rc::Ptr{t8_refcount_t})::Cvoid end """ - t8_cmesh_alloc_offsets(mpisize, comm) + t8_norm(vec) +Vector norm. + +# Arguments +* `vec`:\\[in\\] A 3D vector. +# Returns +The norm of *vec*. ### Prototype ```c -t8_shmem_array_t t8_cmesh_alloc_offsets (int mpisize, sc_MPI_Comm comm); +double t8_norm (const double vec[3]); ``` """ -function t8_cmesh_alloc_offsets(mpisize, comm) - @ccall libt8.t8_cmesh_alloc_offsets(mpisize::Cint, comm::MPI_Comm)::t8_shmem_array_t +function t8_norm(vec) + @ccall libt8.t8_norm(vec::Ptr{Cdouble})::Cdouble end """ - t8_cmesh_set_partition_range(cmesh, set_face_knowledge, first_local_tree, last_local_tree) + t8_normalize(vec) -Declare if the cmesh is understood as a partitioned cmesh and specify the processor local tree range. This function should be preferred over t8_cmesh_set_partition_offsets when the cmesh is not derived from another cmesh. This call is only valid when the cmesh is not yet committed via a call to t8_cmesh_commit. - -!!! note - - A value of *set_face_knowledge* other than -1 or 3 is not yet supported. +Normalize a vector. # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `set_face_knowledge`:\\[in\\] Several values are possible that define how much information is required on face connections, specified by t8_cmesh_set_join. 0: Expect face connection of local trees. 1: In addition, expect face connection from ghost trees to local trees. 2: In addition, expect face connection between ghost trees. 3: Expect face connection of local and ghost trees. Consistency of this requirement is checked on t8_cmesh_commit. -1: Do not change the face\\_knowledge level but keep any previously set ones. (Possibly by a previous call to t8_cmesh_set_partition_range) -* `first_local_tree`:\\[in\\] The global index ID of the first tree on this process. If this tree is also the last tree on the previous process, then the argument must be -ID - 1. -* `last_local_tree`:\\[in\\] The global index of the last tree on this process. If this process should be empty then *last_local_tree* must be strictly smaller than *first_local_tree*. -# See also -t8\\_cmesh\\_set\\_partition\\_offset, [`t8_cmesh_set_partition_uniform`](@ref) - +* `vec`:\\[in,out\\] A 3D vector. ### Prototype ```c -void t8_cmesh_set_partition_range (t8_cmesh_t cmesh, int set_face_knowledge, t8_gloidx_t first_local_tree, t8_gloidx_t last_local_tree); +void t8_normalize (double vec[3]); ``` """ -function t8_cmesh_set_partition_range(cmesh, set_face_knowledge, first_local_tree, last_local_tree) - @ccall libt8.t8_cmesh_set_partition_range(cmesh::t8_cmesh_t, set_face_knowledge::Cint, first_local_tree::t8_gloidx_t, last_local_tree::t8_gloidx_t)::Cvoid +function t8_normalize(vec) + @ccall libt8.t8_normalize(vec::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_set_partition_offsets(cmesh, tree_offsets) + t8_copy(dimensional_in, dimensional_out) -Declare if the cmesh is understood as a partitioned cmesh and specify the first local tree for each process. This call is only valid when the cmesh is not yet committed via a call to t8_cmesh_commit. If instead t8_cmesh_set_partition_range was called and the cmesh is derived then the offset array is constructed during commit. +Make a copy of a dimensional object. # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `tree_offsets`:\\[in\\] An array of global tree\\_id offsets for each process can be specified here. TODO: document flag for shared trees. +* `dimensional_in`:\\[in\\] +* `dimensional_out`:\\[out\\] ### Prototype ```c -void t8_cmesh_set_partition_offsets (t8_cmesh_t cmesh, t8_shmem_array_t tree_offsets); +void t8_copy (const double dimensional_in[3], double dimensional_out[3]); ``` """ -function t8_cmesh_set_partition_offsets(cmesh, tree_offsets) - @ccall libt8.t8_cmesh_set_partition_offsets(cmesh::t8_cmesh_t, tree_offsets::t8_shmem_array_t)::Cvoid +function t8_copy(dimensional_in, dimensional_out) + @ccall libt8.t8_copy(dimensional_in::Ptr{Cdouble}, dimensional_out::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_set_partition_uniform(cmesh, element_level, ts) + t8_dist(vec_x, vec_y) -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. +Euclidean distance of X and Y. # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `element_level`:\\[in\\] The refinement\\_level. -* `ts`:\\[in\\] The element scheme describing the refinement pattern. We take ownership. This can be prevented by referencing **ts** before calling this function. +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +# Returns +The euclidean distance. Equivalent to norm (X-Y). ### Prototype ```c -void t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, int element_level, t8_scheme_cxx_t *ts); +double t8_dist (const double vec_x[3], const double vec_y[3]); ``` """ -function t8_cmesh_set_partition_uniform(cmesh, element_level, ts) - @ccall libt8.t8_cmesh_set_partition_uniform(cmesh::t8_cmesh_t, element_level::Cint, ts::Ptr{t8_scheme_cxx_t})::Cvoid +function t8_dist(vec_x, vec_y) + @ccall libt8.t8_dist(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble end """ - t8_cmesh_set_refine(cmesh, level, scheme) + t8_ax(vec_x, alpha) -Refine the cmesh to a given level. Thus split each tree into x^level subtrees TODO: implement +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 -void t8_cmesh_set_refine (t8_cmesh_t cmesh, int level, t8_scheme_cxx_t *scheme); +void t8_ax (double vec_x[3], const double alpha); ``` """ -function t8_cmesh_set_refine(cmesh, level, scheme) - @ccall libt8.t8_cmesh_set_refine(cmesh::t8_cmesh_t, level::Cint, scheme::Ptr{t8_scheme_cxx_t})::Cvoid +function t8_ax(vec_x, alpha) + @ccall libt8.t8_ax(vec_x::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - t8_cmesh_set_dimension(cmesh, dim) + t8_axy(vec_x, vec_y, alpha) -Set the dimension of a cmesh. If any tree is inserted to the cmesh via [`t8_cmesh_set_tree_class`](@ref), then the dimension is set automatically to that of the inserted tree. However, if the cmesh is constructed partitioned and the part on this process is empty, it is necessary to set the dimension by hand. +Compute Y = alpha * X # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `dim`:\\[in\\] The dimension to be set. Must satisfy 0 <= dim <= 3. The cmesh must not be committed before calling this function. +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[out\\] On output set to *alpha* * *vec_x*. +* `alpha`:\\[in\\] A factor. ### Prototype ```c -void t8_cmesh_set_dimension (t8_cmesh_t cmesh, int dim); +void t8_axy (const double vec_x[3], double vec_y[3], const double alpha); ``` """ -function t8_cmesh_set_dimension(cmesh, dim) - @ccall libt8.t8_cmesh_set_dimension(cmesh::t8_cmesh_t, dim::Cint)::Cvoid +function t8_axy(vec_x, vec_y, alpha) + @ccall libt8.t8_axy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - t8_cmesh_set_tree_class(cmesh, gtree_id, tree_class) + t8_axb(vec_x, vec_y, alpha, b) -Set the class of a tree in the cmesh. It is not allowed to call this function after t8_cmesh_commit. It is not allowed to call this function multiple times for the same tree. +Y = alpha * X + b + +!!! note + + It is possible that vec\\_x = vec\\_y on input to overwrite x # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `tree_id`:\\[in\\] The global number of the tree. -* `tree_class`:\\[in\\] The element class of this tree. +* `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_cmesh_set_tree_class (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, t8_eclass_t tree_class); +void t8_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b); ``` """ -function t8_cmesh_set_tree_class(cmesh, gtree_id, tree_class) - @ccall libt8.t8_cmesh_set_tree_class(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, tree_class::t8_eclass_t)::Cvoid +function t8_axb(vec_x, vec_y, alpha, b) + @ccall libt8.t8_axb(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble, b::Cdouble)::Cvoid end """ - t8_cmesh_set_attribute(cmesh, gtree_id, package_id, key, data, data_size, data_persists) + t8_axpy(vec_x, vec_y, alpha) -Store an attribute at a tree in a cmesh. Attributes can be arbitrary data that is copied to an internal storage associated to the tree. Each application can set multiple attributes and attributes are distinguished by an integer key, where each application can use any integer as key. - -!!! note - - If an attribute with the given package\\_id and key already exists, then it will get overwritten. +Y = Y + alpha * X # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `gtree_id`:\\[in\\] The global id of the tree. -* `package_id`:\\[in\\] Unique identifier of a valid software package. -* `key`:\\[in\\] An integer key used to identify this attribute under all attributes with the same package\\_id. *key* must be a unique value for this tree and package\\_id. -* `data`:\\[in\\] A pointer to the attribute data. -* `data_size`:\\[in\\] The number of bytes of the attribute. -* `data_persists`:\\[in\\] This flag can be used to optimize memory. If true then t8code assumes that the attribute data is present at the memory that *data* points to when t8_cmesh_commit is called (This is more memory efficient). If the flag is false an internal copy of the data is created immediately and this copy is used at commit. In both cases a copy of the data is used by t8\\_code after [`t8_cmesh_commit`](@ref). -# See also -[`sc_package_register`](@ref) - +* `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_cmesh_set_attribute (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, int package_id, int key, void *data, size_t data_size, int data_persists); +void t8_axpy (const double vec_x[3], double vec_y[3], const double alpha); ``` """ -function t8_cmesh_set_attribute(cmesh, gtree_id, package_id, key, data, data_size, data_persists) - @ccall libt8.t8_cmesh_set_attribute(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, package_id::Cint, key::Cint, data::Ptr{Cvoid}, data_size::Csize_t, data_persists::Cint)::Cvoid +function t8_axpy(vec_x, vec_y, alpha) + @ccall libt8.t8_axpy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - t8_cmesh_set_attribute_string(cmesh, gtree_id, package_id, key, string) - -Store a string as an attribute at a tree in a cmesh. - -!!! note - - You can also use t8_cmesh_set_attribute, but we recommend using this specialized function for strings. - -!!! note + t8_axpyz(vec_x, vec_y, vec_z, alpha) - If an attribute with the given package\\_id and key already exists, then it will get overwritten. +Z = Y + alpha * X # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `gtree_id`:\\[in\\] The global id of the tree. -* `package_id`:\\[in\\] Unique identifier of a valid software package. -* `key`:\\[in\\] An integer key used to identify this attribute under all attributes with the same package\\_id. *key* must be a unique value for this tree and package\\_id. -* `string`:\\[in\\] The string to store as attribute. -# See also -[`sc_package_register`](@ref) - +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +* `vec_z`:\\[out\\] On output set *to* vec\\_y + *alpha* * *vec_x* +* `alpha`:\\[in\\] A factor for the multiplication of *vec_x*. ### Prototype ```c -void t8_cmesh_set_attribute_string (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, int package_id, int key, const char *string); +void t8_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], const double alpha); ``` """ -function t8_cmesh_set_attribute_string(cmesh, gtree_id, package_id, key, string) - @ccall libt8.t8_cmesh_set_attribute_string(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, package_id::Cint, key::Cint, string::Cstring)::Cvoid +function t8_axpyz(vec_x, vec_y, vec_z, alpha) + @ccall libt8.t8_axpyz(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, vec_z::Ptr{Cdouble}, alpha::Cdouble)::Cvoid end """ - t8_cmesh_set_attribute_gloidx_array(cmesh, gtree_id, package_id, key, data, data_count, data_persists) + t8_dot(vec_x, vec_y) -Store an array of [`t8_gloidx_t`](@ref) as an attribute at a tree in a cmesh. - -!!! note - - You can also use t8_cmesh_set_attribute, but we recommend using this specialized function for arrays. - -!!! note - - If an attribute with the given package\\_id and key already exists, then it will get overwritten. - -!!! note - - We do not store the number of data entries *data_count* of the attribute array. You can keep track of the data count yourself by using another attribute. +Dot product of X and Y. # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `gtree_id`:\\[in\\] The global id of the tree. -* `package_id`:\\[in\\] Unique identifier of a valid software package. -* `key`:\\[in\\] An integer key used to identify this attribute under all attributes with the same package\\_id. *key* must be a unique value for this tree and package\\_id. -* `data`:\\[in\\] The array to store as attribute. -* `data_count`:\\[in\\] The number of entries in *data*. -* `data_persists`:\\[in\\] This flag can be used to optimize memory. If true then t8code assumes that the attribute data is present at the memory that *data* points to when t8_cmesh_commit is called (This is more memory efficient). If the flag is false an internal copy of the data is created immediately and this copy is used at commit. In both cases a copy of the data is used by t8\\_code after [`t8_cmesh_commit`](@ref). -# See also -[`sc_package_register`](@ref) - +* `vec_x`:\\[in\\] A 3D vector. +* `vec_y`:\\[in\\] A 3D vector. +# Returns +The dot product *vec_x* * *vec_y* ### Prototype ```c -void t8_cmesh_set_attribute_gloidx_array (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, int package_id, int key, const t8_gloidx_t *data, const size_t data_count, int data_persists); +double t8_dot (const double vec_x[3], const double vec_y[3]); ``` """ -function t8_cmesh_set_attribute_gloidx_array(cmesh, gtree_id, package_id, key, data, data_count, data_persists) - @ccall libt8.t8_cmesh_set_attribute_gloidx_array(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, package_id::Cint, key::Cint, data::Ptr{t8_gloidx_t}, data_count::Csize_t, data_persists::Cint)::Cvoid +function t8_dot(vec_x, vec_y) + @ccall libt8.t8_dot(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble end """ - t8_cmesh_set_join(cmesh, gtree1, gtree2, face1, face2, orientation) + t8_cross_3D(vec_x, vec_y, cross) -Insert a face-connection between two trees in a cmesh. +Cross product of X and Y # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `tree1`:\\[in\\] The tree id of the first of the two trees. -* `tree2`:\\[in\\] The tree id of the second of the two trees. -* `face1`:\\[in\\] The face number of the first tree. -* `face2`:\\[in\\] The face number of the second tree. -* `orientation`:\\[in\\] Specify how face1 and face2 are oriented to each other TODO: orientation needs to be carefully defined for all element classes. TODO: document orientation +* `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_cmesh_set_join (t8_cmesh_t cmesh, t8_gloidx_t gtree1, t8_gloidx_t gtree2, int face1, int face2, int orientation); +void t8_cross_3D (const double vec_x[3], const double vec_y[3], double cross[3]); ``` """ -function t8_cmesh_set_join(cmesh, gtree1, gtree2, face1, face2, orientation) - @ccall libt8.t8_cmesh_set_join(cmesh::t8_cmesh_t, gtree1::t8_gloidx_t, gtree2::t8_gloidx_t, face1::Cint, face2::Cint, orientation::Cint)::Cvoid +function t8_cross_3D(vec_x, vec_y, cross) + @ccall libt8.t8_cross_3D(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, cross::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_set_profiling(cmesh, set_profiling) + t8_cross_2D(vec_x, vec_y) -Enable or disable profiling for a cmesh. If profiling is enabled, runtimes and statistics are collected during cmesh\\_commit. - -Profiling is disabled by default. The cmesh must not be committed before calling this function. +Cross product of X and Y # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `set_profiling`:\\[in\\] If true, profiling will be enabled, if false disabled. -# See also -[`t8_cmesh_print_profile`](@ref) - +* `vec_x`:\\[in\\] A 2D vector. +* `vec_y`:\\[in\\] A 2D vector. +# Returns +The cross product of *vec_x* and *vec_y*. ### Prototype ```c -void t8_cmesh_set_profiling (t8_cmesh_t cmesh, int set_profiling); +double t8_cross_2D (const double vec_x[2], const double vec_y[2]); ``` """ -function t8_cmesh_set_profiling(cmesh, set_profiling) - @ccall libt8.t8_cmesh_set_profiling(cmesh::t8_cmesh_t, set_profiling::Cint)::Cvoid +function t8_cross_2D(vec_x, vec_y) + @ccall libt8.t8_cross_2D(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble end """ - t8_cmesh_is_equal(cmesh_a, cmesh_b) + t8_diff(vec_x, vec_y, diff) -Check whether two given cmeshes carry the same information. +Compute the difference of two vectors. # Arguments -* `cmesh_a`:\\[in\\] The first of the two cmeshes to be checked. -* `cmesh_b`:\\[in\\] The second of the two cmeshes to be checked. -# Returns -True if both cmeshes carry the same information, false otherwise. TODO: define carefully. Orders, sequences, equivalences? This function works on committed and uncommitted cmeshes. +* `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 -int t8_cmesh_is_equal (t8_cmesh_t cmesh_a, t8_cmesh_t cmesh_b); +void t8_diff (const double vec_x[3], const double vec_y[3], double diff[3]); ``` """ -function t8_cmesh_is_equal(cmesh_a, cmesh_b) - @ccall libt8.t8_cmesh_is_equal(cmesh_a::t8_cmesh_t, cmesh_b::t8_cmesh_t)::Cint +function t8_diff(vec_x, vec_y, diff) + @ccall libt8.t8_diff(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, diff::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_is_empty(cmesh) + t8_eq(vec_x, vec_y, tol) -Check whether a cmesh is empty on all processes. +Check the equality of two vectors elementwise # Arguments -* `cmesh`:\\[in\\] A committed cmesh. +* `vec_x`:\\[in\\] +* `vec_y`:\\[in\\] +* `tol`:\\[in\\] # Returns -True (non-zero) if and only if the cmesh has trees at all. +true, if the vectors are equal up to *tol* ### Prototype ```c -int t8_cmesh_is_empty (t8_cmesh_t cmesh); +int t8_eq (const double vec_x[3], const double vec_y[3], const double tol); ``` """ -function t8_cmesh_is_empty(cmesh) - @ccall libt8.t8_cmesh_is_empty(cmesh::t8_cmesh_t)::Cint +function t8_eq(vec_x, vec_y, tol) + @ccall libt8.t8_eq(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, tol::Cdouble)::Cint end """ - t8_cmesh_bcast(cmesh_in, root, comm) + t8_rescale(vec, new_length) + +Rescale a vector to a new length. +# Arguments +* `vec`:\\[in,out\\] A 3D vector. +* `new_length`:\\[in\\] New length of the vector. ### Prototype ```c -t8_cmesh_t t8_cmesh_bcast (t8_cmesh_t cmesh_in, int root, sc_MPI_Comm comm); +void t8_rescale (double vec[3], const double new_length); ``` """ -function t8_cmesh_bcast(cmesh_in, root, comm) - @ccall libt8.t8_cmesh_bcast(cmesh_in::t8_cmesh_t, root::Cint, comm::MPI_Comm)::t8_cmesh_t +function t8_rescale(vec, new_length) + @ccall libt8.t8_rescale(vec::Ptr{Cdouble}, new_length::Cdouble)::Cvoid end -mutable struct t8_geometry end - -"""This typedef holds virtual functions for a particular geometry. We need it so that we can use [`t8_geometry_c`](@ref) pointers in .c files without them seeing the actual C++ code (and then not compiling)""" -const t8_geometry_c = t8_geometry - """ - t8_cmesh_register_geometry(cmesh, geometry) - -Register a geometry in the cmesh. The cmesh takes ownership of the geometry. - -If no geometry is registered and cmesh is modified from another cmesh then the other cmesh's geometries are used. - -!!! note + t8_normal_of_tri(p1, p2, p3, normal) - If you need to use t8_cmesh_bcast, then all geometries must be registered *after* the bcast operation, not before. +Compute the normal of a triangle given by its three vertices. # Arguments -* `cmesh`:\\[in,out\\] The cmesh. -* `geometry`:\\[in\\] The geometry to register. +* `p1`:\\[in\\] A 3D vector. +* `p2`:\\[in\\] A 3D vector. +* `p3`:\\[in\\] A 3D vector. +* `normal`:\\[out\\] vector of the triangle. (Not necessarily of length 1!) ### Prototype ```c -void t8_cmesh_register_geometry (t8_cmesh_t cmesh, t8_geometry_c *geometry); +void t8_normal_of_tri (const double p1[3], const double p2[3], const double p3[3], double normal[3]); ``` """ -function t8_cmesh_register_geometry(cmesh, geometry) - @ccall libt8.t8_cmesh_register_geometry(cmesh::t8_cmesh_t, geometry::Ptr{t8_geometry_c})::Cvoid +function t8_normal_of_tri(p1, p2, p3, normal) + @ccall libt8.t8_normal_of_tri(p1::Ptr{Cdouble}, p2::Ptr{Cdouble}, p3::Ptr{Cdouble}, normal::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_set_tree_geometry(cmesh, gtreeid, geom) + t8_orthogonal_tripod(v1, v2, v3) -Set the geometry for a tree, thus specify which geometry to use for this tree. +Compute an orthogonal coordinate system from a given vector. # Arguments -* `cmesh`:\\[in\\] A non-committed cmesh. -* `gtreeid`:\\[in\\] A global tree id in *cmesh*. -* `geom`:\\[in\\] The geometry to use for this tree. See also t8_cmesh_get_tree_geometry +* `v1`:\\[in\\] 3D vector. +* `v2`:\\[out\\] 3D vector. +* `v3`:\\[out\\] 3D vector. ### Prototype ```c -void t8_cmesh_set_tree_geometry (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const t8_geometry_c *geom); +void t8_orthogonal_tripod (const double v1[3], double v2[3], double v3[3]); ``` """ -function t8_cmesh_set_tree_geometry(cmesh, gtreeid, geom) - @ccall libt8.t8_cmesh_set_tree_geometry(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, geom::Ptr{t8_geometry_c})::Cvoid +function t8_orthogonal_tripod(v1, v2, v3) + @ccall libt8.t8_orthogonal_tripod(v1::Ptr{Cdouble}, v2::Ptr{Cdouble}, v3::Ptr{Cdouble})::Cvoid end """ - t8_cmesh_commit(cmesh, comm) + t8_swap(p1, p2) + +Swap the components of two vectors. +# Arguments +* `p1`:\\[in,out\\] A 3D vector. +* `p2`:\\[in,out\\] A 3D vector. ### Prototype ```c -void t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm); +void t8_swap (double p1[3], double p2[3]); ``` """ -function t8_cmesh_commit(cmesh, comm) - @ccall libt8.t8_cmesh_commit(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_swap(p1, p2) + @ccall libt8.t8_swap(p1::Ptr{Cdouble}, p2::Ptr{Cdouble})::Cvoid end +# no prototype is found for this function at t8_version.h:67:1, please use with caution """ - t8_cmesh_save(cmesh, fileprefix) + 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 -int t8_cmesh_save (t8_cmesh_t cmesh, const char *fileprefix); +const char* t8_get_package_string (); ``` """ -function t8_cmesh_save(cmesh, fileprefix) - @ccall libt8.t8_cmesh_save(cmesh::t8_cmesh_t, fileprefix::Cstring)::Cint +function t8_get_package_string() + @ccall libt8.t8_get_package_string()::Cstring end +# no prototype is found for this function at t8_version.h:73:1, please use with caution """ - t8_cmesh_load(filename, comm) + t8_get_version_number() +Return the version number of t8code as a string. + +# Returns +The version number of t8code as a string. ### Prototype ```c -t8_cmesh_t t8_cmesh_load (const char *filename, sc_MPI_Comm comm); +const char* t8_get_version_number (); ``` """ -function t8_cmesh_load(filename, comm) - @ccall libt8.t8_cmesh_load(filename::Cstring, comm::MPI_Comm)::t8_cmesh_t +function t8_get_version_number() + @ccall libt8.t8_get_version_number()::Cstring end +# no prototype is found for this function at t8_version.h:79:1, please use with caution """ - t8_load_mode + t8_get_version_point_string() -This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data. +Return the version point string. -| Enumerator | Note | -| :----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| T8\\_LOAD\\_SIMPLE | In simple mode, the first n processes load the file | -| T8\\_LOAD\\_BGQ | In BGQ mode, the file is loaded on n nodes and from one process of each node. This needs MPI Version 3.1 or higher. | -| T8\\_LOAD\\_STRIDE | Every n-th process loads a file. Handle with care, we introduce it, since on Juqueen MPI-3 was not available. The parameter n has to be passed as an extra parameter. # See also [`t8_cmesh_load_and_distribute`](@ref) | -| T8\\_LOAD\\_COUNT | | +# Returns +The version point point string. +### Prototype +```c +const char* t8_get_version_point_string (); +``` """ -@cenum t8_load_mode::UInt32 begin - T8_LOAD_FIRST = 0 - T8_LOAD_SIMPLE = 0 - T8_LOAD_BGQ = 1 - T8_LOAD_STRIDE = 2 - T8_LOAD_COUNT = 3 +function t8_get_version_point_string() + @ccall libt8.t8_get_version_point_string()::Cstring end -"""This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data.""" -const t8_load_mode_t = t8_load_mode - +# no prototype is found for this function at t8_version.h:85:1, please use with caution """ - t8_cmesh_load_and_distribute(fileprefix, num_files, comm, mode, procs_per_node) + t8_get_version_major() + +Return the major version number of t8code. +# Returns +The major version number of t8code. ### Prototype ```c -t8_cmesh_t t8_cmesh_load_and_distribute (const char *fileprefix, int num_files, sc_MPI_Comm comm, t8_load_mode_t mode, int procs_per_node); +int t8_get_version_major (); ``` """ -function t8_cmesh_load_and_distribute(fileprefix, num_files, comm, mode, procs_per_node) - @ccall libt8.t8_cmesh_load_and_distribute(fileprefix::Cstring, num_files::Cint, comm::MPI_Comm, mode::t8_load_mode_t, procs_per_node::Cint)::t8_cmesh_t +function t8_get_version_major() + @ccall libt8.t8_get_version_major()::Cint end +# no prototype is found for this function at t8_version.h:91:1, please use with caution """ - t8_cmesh_comm_is_valid(cmesh, comm) + t8_get_version_minor() + +Return the minor version number of t8code. +# Returns +The minor version number of t8code. ### Prototype ```c -int t8_cmesh_comm_is_valid (t8_cmesh_t cmesh, sc_MPI_Comm comm); +int t8_get_version_minor (); ``` """ -function t8_cmesh_comm_is_valid(cmesh, comm) - @ccall libt8.t8_cmesh_comm_is_valid(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cint +function t8_get_version_minor() + @ccall libt8.t8_get_version_minor()::Cint end +# no prototype is found for this function at t8_version.h:97:1, please use with caution """ - t8_cmesh_is_partitioned(cmesh) + t8_get_version_patch() -Query whether a committed cmesh is partitioned or replicated. +Return the patch version number of t8code. -# Arguments -* `cmesh`:\\[in\\] A committed cmesh. # Returns -True if *cmesh* is partitioned. False otherwise. *cmesh* must be committed before calling this function. +The patch version number of t8code. ### Prototype ```c -int t8_cmesh_is_partitioned (t8_cmesh_t cmesh); +int t8_get_version_patch (); ``` """ -function t8_cmesh_is_partitioned(cmesh) - @ccall libt8.t8_cmesh_is_partitioned(cmesh::t8_cmesh_t)::Cint +function t8_get_version_patch() + @ccall libt8.t8_get_version_patch()::Cint +end + +@cenum t8_vtk_data_type_t::UInt32 begin + T8_VTK_SCALAR = 0 + T8_VTK_VECTOR = 1 end """ - t8_cmesh_get_dimension(cmesh) + t8_vtk_data_field_t -Get the dimension of a cmesh. +A data field for VTK output. This struct is used to store data that is written to the VTK files. It contains the type of the data, a description, and the actual data array. -# 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); -``` +| Field | Note | +| :---------- | :----------------------------------------- | +| type | Describes of which type the data array is | +| description | String that describes the data. | """ -function t8_cmesh_get_dimension(cmesh) - @ccall libt8.t8_cmesh_get_dimension(cmesh::t8_cmesh_t)::Cint +struct t8_vtk_data_field_t + type::t8_vtk_data_type_t + description::NTuple{8192, Cchar} + data::Ptr{Cdouble} end """ - t8_cmesh_get_num_trees(cmesh) - -Return the global number of trees in a cmesh. + t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -# Returns -The number of trees associated to *cmesh*. *cmesh* must be committed before calling this function. ### Prototype ```c -t8_gloidx_t t8_cmesh_get_num_trees (t8_cmesh_t cmesh); +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_cmesh_get_num_trees(cmesh) - @ccall libt8.t8_cmesh_get_num_trees(cmesh::t8_cmesh_t)::t8_gloidx_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_cmesh_get_num_local_trees(cmesh) - -Return the number of local trees of a cmesh. If the cmesh is not partitioned this is equivalent to t8_cmesh_get_num_trees. + sc_shmem_malloc(package, elem_size, elem_count, comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -# Returns -The number of local trees of the cmesh. *cmesh* must be committed before calling this function. ### Prototype ```c -t8_locidx_t t8_cmesh_get_num_local_trees (t8_cmesh_t cmesh); +void *sc_shmem_malloc (int package, size_t elem_size, size_t elem_count, sc_MPI_Comm comm); ``` """ -function t8_cmesh_get_num_local_trees(cmesh) - @ccall libt8.t8_cmesh_get_num_local_trees(cmesh::t8_cmesh_t)::t8_locidx_t +function sc_shmem_malloc(package, elem_size, elem_count, comm) + @ccall libt8.sc_shmem_malloc(package::Cint, elem_size::Csize_t, elem_count::Csize_t, comm::MPI_Comm)::Ptr{Cvoid} end """ - t8_cmesh_get_num_ghosts(cmesh) - -Return the number of ghost trees of a cmesh. If the cmesh is not partitioned this is equivalent to t8_cmesh_get_num_trees. + sc_shmem_free(package, array, comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -# Returns -The number of ghost trees of the cmesh. *cmesh* must be committed before calling this function. ### Prototype ```c -t8_locidx_t t8_cmesh_get_num_ghosts (t8_cmesh_t cmesh); +void sc_shmem_free (int package, void *array, sc_MPI_Comm comm); ``` """ -function t8_cmesh_get_num_ghosts(cmesh) - @ccall libt8.t8_cmesh_get_num_ghosts(cmesh::t8_cmesh_t)::t8_locidx_t +function sc_shmem_free(package, array, comm) + @ccall libt8.sc_shmem_free(package::Cint, array::Ptr{Cvoid}, comm::MPI_Comm)::Cvoid end """ - t8_cmesh_get_first_treeid(cmesh) + sc_shmem_type_t -Return the global index of the first local tree of a cmesh. If the cmesh is not partitioned this is always 0. +` sc_shmem.h ` -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -# Returns -The global id of the first local tree in cmesh. *cmesh* must be committed before calling this function. -### Prototype -```c -t8_gloidx_t t8_cmesh_get_first_treeid (t8_cmesh_t cmesh); -``` +| Enumerator | Note | +| :---------------------------- | :------------------------------------------- | +| SC\\_SHMEM\\_BASIC | use allgathers, then sum to simulate scan | +| SC\\_SHMEM\\_PRESCAN | mpi\\_scan, then allgather | +| SC\\_SHMEM\\_WINDOW | MPI\\_Win (requires MPI 3) | +| SC\\_SHMEM\\_WINDOW\\_PRESCAN | mpi\\_scan, then MPI\\_Win (requires MPI 3) | """ -function t8_cmesh_get_first_treeid(cmesh) - @ccall libt8.t8_cmesh_get_first_treeid(cmesh::t8_cmesh_t)::t8_gloidx_t +@cenum sc_shmem_type_t::UInt32 begin + SC_SHMEM_BASIC = 0 + SC_SHMEM_PRESCAN = 1 + SC_SHMEM_WINDOW = 2 + SC_SHMEM_WINDOW_PRESCAN = 3 + SC_SHMEM_NUM_TYPES = 4 + SC_SHMEM_NOT_SET = 5 end """ - t8_cmesh_get_tree_geometry(cmesh, gtreeid) - -Get the geometry of a tree. + sc_shmem_set_type(comm, type) -# Arguments -* `cmesh`:\\[in\\] The cmesh. -* `gtreeid`:\\[in\\] The global tree id of the tree for which the geometry should be returned. -# Returns -The geometry of the tree. ### Prototype ```c -const t8_geometry_c * t8_cmesh_get_tree_geometry (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); +void sc_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); ``` """ -function t8_cmesh_get_tree_geometry(cmesh, gtreeid) - @ccall libt8.t8_cmesh_get_tree_geometry(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Ptr{t8_geometry_c} +function sc_shmem_set_type(comm, type) + @ccall libt8.sc_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid end """ - t8_cmesh_treeid_is_local_tree(cmesh, ltreeid) - -Query whether a given [`t8_locidx_t`](@ref) belongs to a local tree of a cmesh. + sc_shmem_get_type(comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `ltreeid`:\\[in\\] An (possible) tree index. -# Returns -True if *ltreeid* matches the range of local trees of *cmesh*. False if not. *cmesh* must be committed before calling this function. ### Prototype ```c -int t8_cmesh_treeid_is_local_tree (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid); +sc_shmem_type_t sc_shmem_get_type (sc_MPI_Comm comm); ``` """ -function t8_cmesh_treeid_is_local_tree(cmesh, ltreeid) - @ccall libt8.t8_cmesh_treeid_is_local_tree(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t)::Cint +function sc_shmem_get_type(comm) + @ccall libt8.sc_shmem_get_type(comm::MPI_Comm)::sc_shmem_type_t end """ - t8_cmesh_treeid_is_ghost(cmesh, ltreeid) - -Query whether a given [`t8_locidx_t`](@ref) belongs to a ghost of a cmesh. + sc_shmem_write_start(array, comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `ltreeid`:\\[in\\] An (possible) ghost index. -# Returns -True if *ltreeid* matches the range of ghost trees of *cmesh*. False if not. *cmesh* must be committed before calling this function. ### Prototype ```c -int t8_cmesh_treeid_is_ghost (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid); +int sc_shmem_write_start (void *array, sc_MPI_Comm comm); ``` """ -function t8_cmesh_treeid_is_ghost(cmesh, ltreeid) - @ccall libt8.t8_cmesh_treeid_is_ghost(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t)::Cint +function sc_shmem_write_start(array, comm) + @ccall libt8.sc_shmem_write_start(array::Ptr{Cvoid}, comm::MPI_Comm)::Cint end """ - t8_cmesh_ltreeid_to_ghostid(cmesh, ltreeid) - -Given a local tree id that belongs to a ghost, return the index of the ghost. + sc_shmem_write_end(array, comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `ltreeid`:\\[in\\] The local id of a ghost, satisfying t8_cmesh_treeid_is_ghost, thus num\\_trees <= *ltreeid* < num\\_trees + num\\_ghosts -# Returns -The index of the ghost within all ghosts, thus an index 0 <= index < num\\_ghosts *cmesh* must be committed before calling this function. ### Prototype ```c -t8_locidx_t t8_cmesh_ltreeid_to_ghostid (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid); +void sc_shmem_write_end (void *array, sc_MPI_Comm comm); ``` """ -function t8_cmesh_ltreeid_to_ghostid(cmesh, ltreeid) - @ccall libt8.t8_cmesh_ltreeid_to_ghostid(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t)::t8_locidx_t +function sc_shmem_write_end(array, comm) + @ccall libt8.sc_shmem_write_end(array::Ptr{Cvoid}, comm::MPI_Comm)::Cvoid end """ - t8_cmesh_get_first_tree(cmesh) - -Return a pointer to the first local tree in a cmesh. + sc_shmem_memcpy(destarray, srcarray, bytes, comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh to be queried. -# Returns -A pointer to the first local tree in *cmesh*. If *cmesh* has no local trees, NULL is returned. *cmesh* must be committed before calling this function. ### Prototype ```c -t8_ctree_t t8_cmesh_get_first_tree (t8_cmesh_t cmesh); +void sc_shmem_memcpy (void *destarray, void *srcarray, size_t bytes, sc_MPI_Comm comm); ``` """ -function t8_cmesh_get_first_tree(cmesh) - @ccall libt8.t8_cmesh_get_first_tree(cmesh::t8_cmesh_t)::t8_ctree_t +function sc_shmem_memcpy(destarray, srcarray, bytes, comm) + @ccall libt8.sc_shmem_memcpy(destarray::Ptr{Cvoid}, srcarray::Ptr{Cvoid}, bytes::Csize_t, comm::MPI_Comm)::Cvoid end """ - t8_cmesh_get_next_tree(cmesh, tree) - -Given a local tree in a cmesh return a pointer to the next local tree. + sc_shmem_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh to be queried. -* `tree`:\\[in\\] A local tree in *cmesh*. -# Returns -A pointer to the next local tree in *cmesh* after *tree*. If no such tree exists, NULL is returned. * *cmesh* must be committed before calling this function. TODO: If we run over tree numbers only, don't use ctree\\_t in API if possible. ### Prototype ```c -t8_ctree_t t8_cmesh_get_next_tree (t8_cmesh_t cmesh, t8_ctree_t tree); +void sc_shmem_allgather (void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, void *recvbuf, int recvcount, sc_MPI_Datatype recvtype, sc_MPI_Comm comm); ``` """ -function t8_cmesh_get_next_tree(cmesh, tree) - @ccall libt8.t8_cmesh_get_next_tree(cmesh::t8_cmesh_t, tree::t8_ctree_t)::t8_ctree_t +function sc_shmem_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm) + @ccall libt8.sc_shmem_allgather(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvbuf::Ptr{Cvoid}, recvcount::Cint, recvtype::Cint, comm::MPI_Comm)::Cvoid end """ - t8_cmesh_get_tree(cmesh, ltree_id) - -Return a pointer to a given local tree. + sc_shmem_prefix(sendbuf, recvbuf, count, type, op, comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh to be queried. -* `ltree_id`:\\[in\\] The local id of the tree that is asked for. -# Returns -A pointer to tree in *cmesh* with local id *ltree_id*. The cmesh must have at least *ltree_id* + 1 local trees when calling this function. *cmesh* must be committed before calling this function. ### Prototype ```c -t8_ctree_t t8_cmesh_get_tree (t8_cmesh_t cmesh, t8_locidx_t ltree_id); +void sc_shmem_prefix (void *sendbuf, void *recvbuf, int count, sc_MPI_Datatype type, sc_MPI_Op op, sc_MPI_Comm comm); ``` """ -function t8_cmesh_get_tree(cmesh, ltree_id) - @ccall libt8.t8_cmesh_get_tree(cmesh::t8_cmesh_t, ltree_id::t8_locidx_t)::t8_ctree_t +function sc_shmem_prefix(sendbuf, recvbuf, count, type, op, comm) + @ccall libt8.sc_shmem_prefix(sendbuf::Ptr{Cvoid}, recvbuf::Ptr{Cvoid}, count::Cint, type::Cint, op::Cint, comm::MPI_Comm)::Cvoid end -""" - t8_cmesh_get_tree_class(cmesh, ltree_id) +mutable struct t8_cmesh end -Return the eclass of a given local tree. TODO: Should we refer to indices or consequently use ctree\\_t? +"""Forward pointer reference to hidden cmesh implementation. This reference needs to be known by [`t8_geometry`](@ref), hence we put it before the include.""" +const t8_cmesh_t = Ptr{t8_cmesh} -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `tree_id`:\\[in\\] The local id of the tree whose eclass will be returned. -# Returns -The eclass of the given tree. TODO: Call tree ids ltree\\_id or gtree\\_id etc. instead of tree\\_id. *cmesh* must be committed before calling this function. -### Prototype -```c -t8_eclass_t t8_cmesh_get_tree_class (t8_cmesh_t cmesh, t8_locidx_t ltree_id); -``` -""" -function t8_cmesh_get_tree_class(cmesh, ltree_id) - @ccall libt8.t8_cmesh_get_tree_class(cmesh::t8_cmesh_t, ltree_id::t8_locidx_t)::t8_eclass_t -end +mutable struct t8_ctree end + +"""Forward pointer references to hidden implementations of tree.""" +const t8_ctree_t = Ptr{t8_ctree} + +mutable struct t8_cghost end + +"""Forward pointer references to hidden implementations of ghost tree.""" +const t8_cghost_t = Ptr{t8_cghost} """ - t8_cmesh_tree_face_is_boundary(cmesh, ltree_id, face) + t8_cmesh_init(pcmesh) -Query whether a face of a local tree or ghost is at the domain boundary. +Create a new cmesh with reference count one. This cmesh needs to be specialized with the t8\\_cmesh\\_set\\_* calls. Then it needs to be set up with t8_cmesh_commit. # Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `ltree_id`:\\[in\\] The local id of a tree. -* `face`:\\[in\\] The number of a face of the tree. -# Returns -True if the face is at the domain boundary. False otherwise. *cmesh* must be committed before calling this function. +* `pcmesh`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new cmesh. ### Prototype ```c -int t8_cmesh_tree_face_is_boundary (t8_cmesh_t cmesh, t8_locidx_t ltree_id, int face); +void t8_cmesh_init (t8_cmesh_t *pcmesh); ``` """ -function t8_cmesh_tree_face_is_boundary(cmesh, ltree_id, face) - @ccall libt8.t8_cmesh_tree_face_is_boundary(cmesh::t8_cmesh_t, ltree_id::t8_locidx_t, face::Cint)::Cint +function t8_cmesh_init(pcmesh) + @ccall libt8.t8_cmesh_init(pcmesh::Ptr{t8_cmesh_t})::Cvoid end +# no prototype is found for this function at t8_cmesh.h:79:1, please use with caution """ - t8_cmesh_get_ghost_class(cmesh, lghost_id) + t8_cmesh_new() -Return the eclass of a given local ghost. TODO: Should we refer to indices or consequently use cghost\\_t? +Allocate a new un-committed cmesh. -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `ghost_id`:\\[in\\] The local id of the ghost whose eclass will be returned. 0 <= *tree_id* < cmesh.num\\_ghosts. # Returns -The eclass of the given ghost. *cmesh* must be committed before calling this function. +A pointer to an un-committed [`t8_cmesh`](@ref) structure. ### Prototype ```c -t8_eclass_t t8_cmesh_get_ghost_class (t8_cmesh_t cmesh, t8_locidx_t lghost_id); +t8_cmesh_t t8_cmesh_new (); ``` """ -function t8_cmesh_get_ghost_class(cmesh, lghost_id) - @ccall libt8.t8_cmesh_get_ghost_class(cmesh::t8_cmesh_t, lghost_id::t8_locidx_t)::t8_eclass_t +function t8_cmesh_new() + @ccall libt8.t8_cmesh_new()::t8_cmesh_t end """ - t8_cmesh_get_global_id(cmesh, local_id) + t8_cmesh_is_initialized(cmesh) -Return the global id of a given local tree or ghost. +Check whether a cmesh is not NULL, initialized and not committed. In addition, it asserts that the cmesh is consistent as much as possible. # Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `local_id`:\\[in\\] The local id of a tree or a ghost. If *local_id* < cmesh.num\\_local\\_trees then it is a tree, otherwise a ghost. +* `cmesh`:\\[in\\] This cmesh is examined. May be NULL. # Returns -The global id of the tree/ghost. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +True if cmesh is not NULL, t8_cmesh_init has been called on it, but not t8_cmesh_commit. False otherwise. ### Prototype ```c -t8_gloidx_t t8_cmesh_get_global_id (t8_cmesh_t cmesh, t8_locidx_t local_id); +int t8_cmesh_is_initialized (t8_cmesh_t cmesh); ``` """ -function t8_cmesh_get_global_id(cmesh, local_id) - @ccall libt8.t8_cmesh_get_global_id(cmesh::t8_cmesh_t, local_id::t8_locidx_t)::t8_gloidx_t +function t8_cmesh_is_initialized(cmesh) + @ccall libt8.t8_cmesh_is_initialized(cmesh::t8_cmesh_t)::Cint end """ - t8_cmesh_get_local_id(cmesh, global_id) + t8_cmesh_is_committed(cmesh) -Return the local id of a give global tree. +Check whether a cmesh is not NULL, initialized and committed. In addition, it asserts that the cmesh is consistent as much as possible. # Arguments -* `cmesh`:\\[in\\] The cmesh. -* `global_id`:\\[in\\] A global tree id. +* `cmesh`:\\[in\\] This cmesh is examined. May be NULL. # Returns -Either a value l 0 <= *l* < num\\_local\\_trees if *global_id* corresponds to a local tree, or num\\_local\\_trees <= *l* < num\\_local\\_trees + num\\_ghosts if *global_id* corresponds to a ghost trees, or negative if *global_id* neither matches a local nor a ghost tree. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +True if cmesh is not NULL and t8_cmesh_init has been called on it as well as t8_cmesh_commit. False otherwise. ### Prototype ```c -t8_locidx_t t8_cmesh_get_local_id (t8_cmesh_t cmesh, t8_gloidx_t global_id); +int t8_cmesh_is_committed (const t8_cmesh_t cmesh); ``` """ -function t8_cmesh_get_local_id(cmesh, global_id) - @ccall libt8.t8_cmesh_get_local_id(cmesh::t8_cmesh_t, global_id::t8_gloidx_t)::t8_locidx_t +function t8_cmesh_is_committed(cmesh) + @ccall libt8.t8_cmesh_is_committed(cmesh::t8_cmesh_t)::Cint end """ - t8_cmesh_get_face_neighbor(cmesh, ltreeid, face, dual_face, orientation) - -Given a local tree id and a face number, get information about the face neighbor tree. + t8_cmesh_disable_negative_volume_check(cmesh) -!!! note - - If *ltreeid* is a ghost and it has a neighbor which is neither a local tree or ghost, then the return value will be negative. Thus, a negative return value does not necessarily mean that this is a domain boundary. To find out whether a tree is a domain boundary or not +Disable the debug check for negative volumes in trees during t8_cmesh_commit. Does nothing outside of debug mode. # Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `ltreeid`:\\[in\\] The local id of a tree or a ghost. -* `face`:\\[in\\] A face number of the tree/ghost. -* `dual_face`:\\[out\\] If not NULL, the face number of the neighbor tree at this connection. -* `orientation`:\\[out\\] If not NULL, the face orientation of the connection. -# Returns -If non-negative: The local id of the neighbor tree or ghost. If negative: There is no neighbor across this face. *dual_face* and *orientation* remain unchanged. -# See also -[`t8_cmesh_tree_face_is_boundary`](@ref). - +* `cmesh`:\\[in,out\\] ### Prototype ```c -t8_locidx_t t8_cmesh_get_face_neighbor (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid, const int face, int *dual_face, int *orientation); +void t8_cmesh_disable_negative_volume_check (t8_cmesh_t cmesh); ``` """ -function t8_cmesh_get_face_neighbor(cmesh, ltreeid, face, dual_face, orientation) - @ccall libt8.t8_cmesh_get_face_neighbor(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t, face::Cint, dual_face::Ptr{Cint}, orientation::Ptr{Cint})::t8_locidx_t +function t8_cmesh_disable_negative_volume_check(cmesh) + @ccall libt8.t8_cmesh_disable_negative_volume_check(cmesh::t8_cmesh_t)::Cvoid end """ - t8_cmesh_print_profile(cmesh) - -Print the collected statistics from a cmesh profile. + t8_cmesh_set_derive(cmesh, set_from) -*cmesh* must be committed before calling this function. +This function sets a cmesh to be derived from. The default is to create a cmesh standalone by specifying all data manually. A coarse mesh can also be constructed by deriving it from an existing one. The derivation from another cmesh may optionally be combined with a repartition or uniform refinement of each tree. This function overrides a previously set cmesh to be derived from. # Arguments -* `cmesh`:\\[in\\] The cmesh. -# See also -[`t8_cmesh_set_profiling`](@ref) - +* `cmesh`:\\[in,out\\] Must be initialized, but not committed. May even be NULL to revert to standalone. +* `set_from`:\\[in,out\\] Reference counter on this cmesh is bumped. It will be unbumped by t8_cmesh_commit, after which *from* is no longer remembered. Other than that the from object is not changed. ### Prototype ```c -void t8_cmesh_print_profile (t8_cmesh_t cmesh); +void t8_cmesh_set_derive (t8_cmesh_t cmesh, t8_cmesh_t set_from); ``` """ -function t8_cmesh_print_profile(cmesh) - @ccall libt8.t8_cmesh_print_profile(cmesh::t8_cmesh_t)::Cvoid +function t8_cmesh_set_derive(cmesh, set_from) + @ccall libt8.t8_cmesh_set_derive(cmesh::t8_cmesh_t, set_from::t8_cmesh_t)::Cvoid end -""" - t8_cmesh_get_tree_vertices(cmesh, ltreeid) +mutable struct t8_shmem_array end -Return a pointer to the vertex coordinates of a tree. +const t8_shmem_array_t = Ptr{t8_shmem_array} + +""" + t8_cmesh_alloc_offsets(mpisize, comm) -# Arguments -* `cmesh`:\\[in\\] The cmesh. -* `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_cmesh_get_tree_vertices (t8_cmesh_t cmesh, t8_locidx_t ltreeid); +t8_shmem_array_t t8_cmesh_alloc_offsets (int mpisize, sc_MPI_Comm comm); ``` """ -function t8_cmesh_get_tree_vertices(cmesh, ltreeid) - @ccall libt8.t8_cmesh_get_tree_vertices(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t)::Ptr{Cdouble} +function t8_cmesh_alloc_offsets(mpisize, comm) + @ccall libt8.t8_cmesh_alloc_offsets(mpisize::Cint, comm::MPI_Comm)::t8_shmem_array_t end """ - t8_cmesh_get_attribute(cmesh, package_id, key, ltree_id) + t8_cmesh_set_partition_range(cmesh, set_face_knowledge, first_local_tree, last_local_tree) -Return the attribute pointer of a tree. +Declare if the cmesh is understood as a partitioned cmesh and specify the processor local tree range. This function should be preferred over t8_cmesh_set_partition_offsets when the cmesh is not derived from another cmesh. This call is only valid when the cmesh is not yet committed via a call to t8_cmesh_commit. !!! note - *cmesh* must be committed before calling this function. + A value of *set_face_knowledge* other than -1 or 3 is not yet supported. # Arguments -* `cmesh`:\\[in\\] The cmesh. -* `package_id`:\\[in\\] The identifier of a valid software package. -* `key`:\\[in\\] A key used to identify the attribute under all attributes of this tree with the same *package_id*. -* `tree_id`:\\[in\\] The local number of the tree. -# Returns -The attribute pointer of the tree *ltree_id* or NULL if the attribute is not found. +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `set_face_knowledge`:\\[in\\] Several values are possible that define how much information is required on face connections, specified by t8_cmesh_set_join. 0: Expect face connection of local trees. 1: In addition, expect face connection from ghost trees to local trees. 2: In addition, expect face connection between ghost trees. 3: Expect face connection of local and ghost trees. Consistency of this requirement is checked on t8_cmesh_commit. -1: Do not change the face\\_knowledge level but keep any previously set ones. (Possibly by a previous call to t8_cmesh_set_partition_range) +* `first_local_tree`:\\[in\\] The global index ID of the first tree on this process. If this tree is also the last tree on the previous process, then the argument must be -ID - 1. +* `last_local_tree`:\\[in\\] The global index of the last tree on this process. If this process should be empty then *last_local_tree* must be strictly smaller than *first_local_tree*. # See also -[`sc_package_register`](@ref), [`t8_cmesh_set_attribute`](@ref) +t8\\_cmesh\\_set\\_partition\\_offset, [`t8_cmesh_set_partition_uniform`](@ref) ### Prototype ```c -void * t8_cmesh_get_attribute (const t8_cmesh_t cmesh, const int package_id, const int key, const t8_locidx_t ltree_id); +void t8_cmesh_set_partition_range (t8_cmesh_t cmesh, int set_face_knowledge, t8_gloidx_t first_local_tree, t8_gloidx_t last_local_tree); ``` """ -function t8_cmesh_get_attribute(cmesh, package_id, key, ltree_id) - @ccall libt8.t8_cmesh_get_attribute(cmesh::t8_cmesh_t, package_id::Cint, key::Cint, ltree_id::t8_locidx_t)::Ptr{Cvoid} +function t8_cmesh_set_partition_range(cmesh, set_face_knowledge, first_local_tree, last_local_tree) + @ccall libt8.t8_cmesh_set_partition_range(cmesh::t8_cmesh_t, set_face_knowledge::Cint, first_local_tree::t8_gloidx_t, last_local_tree::t8_gloidx_t)::Cvoid end """ - t8_cmesh_get_attribute_gloidx_array(cmesh, package_id, key, ltree_id, data_count) - -Return the attribute pointer of a tree for a gloidx\\_t array. - -!!! note - - *cmesh* must be committed before calling this function. - -!!! note + t8_cmesh_set_partition_offsets(cmesh, tree_offsets) - No check is performed whether the attribute actually stored *data_count* many entries since we do not store the number of data entries of the attribute array. You can keep track of the data count yourself by using another attribute. +Declare if the cmesh is understood as a partitioned cmesh and specify the first local tree for each process. This call is only valid when the cmesh is not yet committed via a call to t8_cmesh_commit. If instead t8_cmesh_set_partition_range was called and the cmesh is derived then the offset array is constructed during commit. # Arguments -* `cmesh`:\\[in\\] The cmesh. -* `package_id`:\\[in\\] The identifier of a valid software package. -* `key`:\\[in\\] A key used to identify the attribute under all attributes of this tree with the same *package_id*. -* `ltree_id`:\\[in\\] The local number of the tree. -* `data_count`:\\[in\\] The number of entries in the array that are requested. This must be smaller or equal to the *data_count* parameter of the corresponding call to t8_cmesh_set_attribute_gloidx_array -# Returns -The attribute pointer of the tree *ltree_id* or NULL if the attribute is not found. -# See also -[`sc_package_register`](@ref), [`t8_cmesh_set_attribute_gloidx_array`](@ref) - +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `tree_offsets`:\\[in\\] An array of global tree\\_id offsets for each process can be specified here. TODO: document flag for shared trees. ### Prototype ```c -t8_gloidx_t * t8_cmesh_get_attribute_gloidx_array (const t8_cmesh_t cmesh, const int package_id, const int key, const t8_locidx_t ltree_id, const size_t data_count); +void t8_cmesh_set_partition_offsets (t8_cmesh_t cmesh, t8_shmem_array_t tree_offsets); ``` """ -function t8_cmesh_get_attribute_gloidx_array(cmesh, package_id, key, ltree_id, data_count) - @ccall libt8.t8_cmesh_get_attribute_gloidx_array(cmesh::t8_cmesh_t, package_id::Cint, key::Cint, ltree_id::t8_locidx_t, data_count::Csize_t)::Ptr{t8_gloidx_t} +function t8_cmesh_set_partition_offsets(cmesh, tree_offsets) + @ccall libt8.t8_cmesh_set_partition_offsets(cmesh::t8_cmesh_t, tree_offsets::t8_shmem_array_t)::Cvoid end +mutable struct t8_scheme end + +"""The scheme holds implementations for one or more element classes. Opaque pointer for C interface. Detailed documentation at t8_scheme.""" +const t8_scheme_c = t8_scheme + """ - t8_cmesh_get_partition_table(cmesh) + t8_cmesh_set_partition_uniform(cmesh, element_level, scheme) -Return the shared memory array storing the partition table of a partitioned cmesh. +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\\] The cmesh. -# Returns -The partition array. NULL if the cmesh is not partitioned or the partition array is not stored in *cmesh*. *cmesh* must be committed before calling this function. +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `element_level`:\\[in\\] The refinement\\_level. +* `scheme`:\\[in\\] The element scheme describing the refinement pattern. We take ownership. This can be prevented by referencing **scheme** before calling this function. ### Prototype ```c -t8_shmem_array_t t8_cmesh_get_partition_table (t8_cmesh_t cmesh); +void t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, const int element_level, const t8_scheme_c *scheme); ``` """ -function t8_cmesh_get_partition_table(cmesh) - @ccall libt8.t8_cmesh_get_partition_table(cmesh::t8_cmesh_t)::t8_shmem_array_t +function t8_cmesh_set_partition_uniform(cmesh, element_level, scheme) + @ccall libt8.t8_cmesh_set_partition_uniform(cmesh::t8_cmesh_t, element_level::Cint, scheme::Ptr{t8_scheme_c})::Cvoid end """ - t8_cmesh_uniform_bounds(cmesh, level, ts, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) + t8_cmesh_set_refine(cmesh, level, scheme) -Calculate the section of a uniform forest for the current rank. +Refine the cmesh to a given level. Thus split each tree into x^level subtrees TODO: implement -# Arguments -* `cmesh`:\\[in\\] The cmesh to be considered. -* `level`:\\[in\\] The uniform refinement level to be created. -* `ts`:\\[in\\] The element scheme for which to compute the bounds. -* `first_local_tree`:\\[out\\] The first tree that contains elements belonging to the calling processor. -* `child_in_tree_begin`:\\[out\\] The global index of the first element belonging to the calling processor. Not computed if NULL. -* `last_local_tree`:\\[out\\] The last tree that contains elements belonging to the calling processor. -* `child_in_tree_end`:\\[out\\] The global index of the first element that does not belonging to the calling processor anymore. Not computed if NULL. -* `first_tree_shared`:\\[out\\] If not NULL, 1 or 0 is stored here depending on whether *first_local_tree* is the same as *last_local_tree* on the next process. *cmesh* must be committed before calling this function. * ### Prototype ```c -void t8_cmesh_uniform_bounds (t8_cmesh_t cmesh, int level, const t8_scheme_cxx_t *ts, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared); +void t8_cmesh_set_refine (t8_cmesh_t cmesh, const int level, const t8_scheme_c *scheme); ``` """ -function t8_cmesh_uniform_bounds(cmesh, level, ts, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) - @ccall libt8.t8_cmesh_uniform_bounds(cmesh::t8_cmesh_t, level::Cint, ts::Ptr{t8_scheme_cxx_t}, first_local_tree::Ptr{t8_gloidx_t}, child_in_tree_begin::Ptr{t8_gloidx_t}, last_local_tree::Ptr{t8_gloidx_t}, child_in_tree_end::Ptr{t8_gloidx_t}, first_tree_shared::Ptr{Int8})::Cvoid +function t8_cmesh_set_refine(cmesh, level, scheme) + @ccall libt8.t8_cmesh_set_refine(cmesh::t8_cmesh_t, level::Cint, scheme::Ptr{t8_scheme_c})::Cvoid end """ - t8_cmesh_ref(cmesh) + t8_cmesh_set_dimension(cmesh, dim) -Increase the reference counter of a cmesh. +Set the dimension of a cmesh. If any tree is inserted to the cmesh via [`t8_cmesh_set_tree_class`](@ref), then the dimension is set automatically to that of the inserted tree. However, if the cmesh is constructed partitioned and the part on this process is empty, it is necessary to set the dimension by hand. # Arguments -* `cmesh`:\\[in,out\\] On input, this cmesh must exist with positive reference count. It may be in any state. +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `dim`:\\[in\\] The dimension to be set. Must satisfy 0 <= dim <= 3. The cmesh must not be committed before calling this function. ### Prototype ```c -void t8_cmesh_ref (t8_cmesh_t cmesh); +void t8_cmesh_set_dimension (t8_cmesh_t cmesh, int dim); ``` """ -function t8_cmesh_ref(cmesh) - @ccall libt8.t8_cmesh_ref(cmesh::t8_cmesh_t)::Cvoid +function t8_cmesh_set_dimension(cmesh, dim) + @ccall libt8.t8_cmesh_set_dimension(cmesh::t8_cmesh_t, dim::Cint)::Cvoid end """ - t8_cmesh_unref(pcmesh) + t8_cmesh_set_tree_class(cmesh, gtree_id, tree_class) -Decrease the reference counter of a cmesh. If the counter reaches zero, this cmesh is destroyed. See also t8_cmesh_destroy, which is to be preferred when it is known that the last reference to a cmesh is deleted. +Set the class of a tree in the cmesh. It is not allowed to call this function after t8_cmesh_commit. It is not allowed to call this function multiple times for the same tree. # Arguments -* `pcmesh`:\\[in,out\\] On input, the cmesh pointed to must exist with positive reference count. It may be in any state. If the reference count reaches zero, the cmesh is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the cmesh is not modified in other ways. +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `gtree_id`:\\[in\\] The global number of the tree. +* `tree_class`:\\[in\\] The element class of this tree. ### Prototype ```c -void t8_cmesh_unref (t8_cmesh_t *pcmesh); +void t8_cmesh_set_tree_class (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, t8_eclass_t tree_class); ``` """ -function t8_cmesh_unref(pcmesh) - @ccall libt8.t8_cmesh_unref(pcmesh::Ptr{t8_cmesh_t})::Cvoid +function t8_cmesh_set_tree_class(cmesh, gtree_id, tree_class) + @ccall libt8.t8_cmesh_set_tree_class(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, tree_class::t8_eclass_t)::Cvoid end """ - t8_cmesh_destroy(pcmesh) + t8_cmesh_set_attribute(cmesh, gtree_id, package_id, key, data, data_size, data_persists) -Verify that a coarse mesh has only one reference left and destroy it. This function is preferred over t8_cmesh_unref when it is known that the last reference is to be deleted. +Store an attribute at a tree in a cmesh. Attributes can be arbitrary data that is copied to an internal storage associated to the tree. Each application can set multiple attributes and attributes are distinguished by an integer key, where each application can use any integer as key. + +!!! note + + If an attribute with the given package\\_id and key already exists, then it will get overwritten. # Arguments -* `pcmesh`:\\[in,out\\] This cmesh must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_cmesh_unref. -* `comm`:\\[in\\] A mpi communicator that is valid with *cmesh*. +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `gtree_id`:\\[in\\] The global id of the tree. +* `package_id`:\\[in\\] Unique identifier of a valid software package. +* `key`:\\[in\\] An integer key used to identify this attribute under all attributes with the same package\\_id. *key* must be a unique value for this tree and package\\_id. +* `data`:\\[in\\] A pointer to the attribute data. +* `data_size`:\\[in\\] The number of bytes of the attribute. +* `data_persists`:\\[in\\] This flag can be used to optimize memory. If true then t8code assumes that the attribute data is present at the memory that *data* points to when t8_cmesh_commit is called (This is more memory efficient). If the flag is false an internal copy of the data is created immediately and this copy is used at commit. In both cases a copy of the data is used by t8\\_code after [`t8_cmesh_commit`](@ref). +# See also +[`sc_package_register`](@ref) + ### Prototype ```c -void t8_cmesh_destroy (t8_cmesh_t *pcmesh); +void t8_cmesh_set_attribute (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, int package_id, int key, void *data, size_t data_size, int data_persists); ``` """ -function t8_cmesh_destroy(pcmesh) - @ccall libt8.t8_cmesh_destroy(pcmesh::Ptr{t8_cmesh_t})::Cvoid +function t8_cmesh_set_attribute(cmesh, gtree_id, package_id, key, data, data_size, data_persists) + @ccall libt8.t8_cmesh_set_attribute(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, package_id::Cint, key::Cint, data::Ptr{Cvoid}, data_size::Csize_t, data_persists::Cint)::Cvoid end """ - t8_cmesh_new_testhybrid(comm) + t8_cmesh_set_attribute_string(cmesh, gtree_id, package_id, key, string) + +Store a string as an attribute at a tree in a cmesh. + +!!! note + + You can also use t8_cmesh_set_attribute, but we recommend using this specialized function for strings. + +!!! note + + If an attribute with the given package\\_id and key already exists, then it will get overwritten. + +# Arguments +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `gtree_id`:\\[in\\] The global id of the tree. +* `package_id`:\\[in\\] Unique identifier of a valid software package. +* `key`:\\[in\\] An integer key used to identify this attribute under all attributes with the same package\\_id. *key* must be a unique value for this tree and package\\_id. +* `string`:\\[in\\] The string to store as attribute. +# See also +[`sc_package_register`](@ref) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_testhybrid (sc_MPI_Comm comm); +void t8_cmesh_set_attribute_string (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, int package_id, int key, const char *string); ``` """ -function t8_cmesh_new_testhybrid(comm) - @ccall libt8.t8_cmesh_new_testhybrid(comm::MPI_Comm)::t8_cmesh_t +function t8_cmesh_set_attribute_string(cmesh, gtree_id, package_id, key, string) + @ccall libt8.t8_cmesh_set_attribute_string(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, package_id::Cint, key::Cint, string::Cstring)::Cvoid end """ - t8_cmesh_coords_axb(coords_in, coords_out, num_vertices, alpha, b) + t8_cmesh_set_attribute_gloidx_array(cmesh, gtree_id, package_id, key, data, data_count, data_persists) -Compute y = ax + b on an array of doubles, interpreting each 3 as one vector x +Store an array of [`t8_gloidx_t`](@ref) as an attribute at a tree in a cmesh. + +!!! note + + You can also use t8_cmesh_set_attribute, but we recommend using this specialized function for arrays. + +!!! note + + If an attribute with the given package\\_id and key already exists, then it will get overwritten. + +!!! note + + We do not store the number of data entries *data_count* of the attribute array. You can keep track of the data count yourself by using another attribute. # Arguments -* `coords_in`:\\[in\\] The incoming coordinates of the vectors -* `coords_out`:\\[out\\] The computed coordinates of the vectors -* `num_vertices`:\\[in\\] The number of vertices/vectors -* `alpha`:\\[in\\] Scaling factor for the vectors -* `b`:\\[in\\] Translation of the vectors. +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `gtree_id`:\\[in\\] The global id of the tree. +* `package_id`:\\[in\\] Unique identifier of a valid software package. +* `key`:\\[in\\] An integer key used to identify this attribute under all attributes with the same package\\_id. *key* must be a unique value for this tree and package\\_id. +* `data`:\\[in\\] The array to store as attribute. +* `data_count`:\\[in\\] The number of entries in *data*. +* `data_persists`:\\[in\\] This flag can be used to optimize memory. If true then t8code assumes that the attribute data is present at the memory that *data* points to when t8_cmesh_commit is called (This is more memory efficient). If the flag is false an internal copy of the data is created immediately and this copy is used at commit. In both cases a copy of the data is used by t8\\_code after [`t8_cmesh_commit`](@ref). +# See also +[`sc_package_register`](@ref) + ### Prototype ```c -void t8_cmesh_coords_axb (const double *coords_in, double *coords_out, int num_vertices, double alpha, const double b[3]); +void t8_cmesh_set_attribute_gloidx_array (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, int package_id, int key, const t8_gloidx_t *data, const size_t data_count, int data_persists); ``` """ -function t8_cmesh_coords_axb(coords_in, coords_out, num_vertices, alpha, b) - @ccall libt8.t8_cmesh_coords_axb(coords_in::Ptr{Cdouble}, coords_out::Ptr{Cdouble}, num_vertices::Cint, alpha::Cdouble, b::Ptr{Cdouble})::Cvoid +function t8_cmesh_set_attribute_gloidx_array(cmesh, gtree_id, package_id, key, data, data_count, data_persists) + @ccall libt8.t8_cmesh_set_attribute_gloidx_array(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, package_id::Cint, key::Cint, data::Ptr{t8_gloidx_t}, data_count::Csize_t, data_persists::Cint)::Cvoid end """ - t8_cmesh_translate_coordinates(coords_in, coords_out, num_vertices, translate) + t8_cmesh_set_join(cmesh, gtree1, gtree2, face1, face2, orientation) + +Insert a face-connection between two trees in a cmesh. + +!!! note -Compute y = x + translate on an array of doubles, interpreting each 3 as one vector x + The orientation is defined as: Let my\\_face and other\\_face be the two face numbers of the connecting trees. We chose a main\\_face from them as follows: Either both trees have the same element class, then the face with the lower face number is the main\\_face or the trees belong to different classes in which case the face belonging to the tree with the lower class according to the ordering triangle < quad, hex < tet < prism < pyramid, is the main\\_face. Then face corner 0 of the main\\_face connects to a face corner k in the other face. The face orientation is defined as the number k. If the classes are equal and my\\_face == other\\_face, treating either of both faces as the main\\_face leads to the same result. See https://arxiv.org/pdf/1611.02929.pdf for more details. # Arguments -* `coords_in`:\\[in\\] The incoming coordinates of the vectors -* `coords_out`:\\[out\\] The computed coordinates of the vectors -* `num_vertices`:\\[in\\] The number of vertices/vectors -* `translate`:\\[in\\] Translation of the vectors. +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `gtree1`:\\[in\\] The tree id of the first of the two trees. +* `gtree2`:\\[in\\] The tree id of the second of the two trees. +* `face1`:\\[in\\] The face number of the first tree. +* `face2`:\\[in\\] The face number of the second tree. +* `orientation`:\\[in\\] Specify how face1 and face2 are oriented to each other ### Prototype ```c -void t8_cmesh_translate_coordinates (const double *coords_in, double *coords_out, const int num_vertices, const double translate[3]); +void t8_cmesh_set_join (t8_cmesh_t cmesh, t8_gloidx_t gtree1, t8_gloidx_t gtree2, int face1, int face2, int orientation); ``` """ -function t8_cmesh_translate_coordinates(coords_in, coords_out, num_vertices, translate) - @ccall libt8.t8_cmesh_translate_coordinates(coords_in::Ptr{Cdouble}, coords_out::Ptr{Cdouble}, num_vertices::Cint, translate::Ptr{Cdouble})::Cvoid +function t8_cmesh_set_join(cmesh, gtree1, gtree2, face1, face2, orientation) + @ccall libt8.t8_cmesh_set_join(cmesh::t8_cmesh_t, gtree1::t8_gloidx_t, gtree2::t8_gloidx_t, face1::Cint, face2::Cint, orientation::Cint)::Cvoid end """ - t8_cmesh_new_translate_vertices_to_attributes(tvertices, vertices, attr_vertices, num_vertices) + t8_cmesh_set_profiling(cmesh, set_profiling) -TODO: Add proper documentation +Enable or disable profiling for a cmesh. If profiling is enabled, runtimes and statistics are collected during cmesh\\_commit. + +Profiling is disabled by default. The cmesh must not be committed before calling this function. + +# Arguments +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `set_profiling`:\\[in\\] If true, profiling will be enabled, if false disabled. +# See also +[`t8_cmesh_print_profile`](@ref) ### Prototype ```c -void t8_cmesh_new_translate_vertices_to_attributes (const t8_locidx_t *tvertices, const double *vertices, double *attr_vertices, const int num_vertices); +void t8_cmesh_set_profiling (t8_cmesh_t cmesh, int set_profiling); ``` """ -function t8_cmesh_new_translate_vertices_to_attributes(tvertices, vertices, attr_vertices, num_vertices) - @ccall libt8.t8_cmesh_new_translate_vertices_to_attributes(tvertices::Ptr{t8_locidx_t}, vertices::Ptr{Cdouble}, attr_vertices::Ptr{Cdouble}, num_vertices::Cint)::Cvoid +function t8_cmesh_set_profiling(cmesh, set_profiling) + @ccall libt8.t8_cmesh_set_profiling(cmesh::t8_cmesh_t, set_profiling::Cint)::Cvoid end """ - t8_cmesh_debug_print_trees(cmesh, comm) + t8_cmesh_is_equal(cmesh_a, cmesh_b) + +Check whether two given cmeshes carry the same information. +# Arguments +* `cmesh_a`:\\[in\\] The first of the two cmeshes to be checked. +* `cmesh_b`:\\[in\\] The second of the two cmeshes to be checked. +# Returns +True if both cmeshes carry the same information, false otherwise. TODO: define carefully. Orders, sequences, equivalences? This function works on committed and uncommitted cmeshes. ### Prototype ```c -void t8_cmesh_debug_print_trees (const t8_cmesh_t cmesh, sc_MPI_Comm comm); +int t8_cmesh_is_equal (t8_cmesh_t cmesh_a, t8_cmesh_t cmesh_b); ``` """ -function t8_cmesh_debug_print_trees(cmesh, comm) - @ccall libt8.t8_cmesh_debug_print_trees(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_cmesh_is_equal(cmesh_a, cmesh_b) + @ccall libt8.t8_cmesh_is_equal(cmesh_a::t8_cmesh_t, cmesh_b::t8_cmesh_t)::Cint end """ - t8_netcdf_variable_type - -This enumeration contains all possible netCDF variable datatypes (int, int64, double). - -| Enumerator | Note | -| :------------------- | :------------------------------------------------------------------- | -| T8\\_NETCDF\\_INT | Symbolizes netCDF variable datatype which holds 32-bit integer data | -| T8\\_NETCDF\\_INT64 | Symbolizes netCDF variable datatype which holds 64-bit integer data | -| T8\\_NETCDF\\_DOUBLE | Symbolizes netCDF variable datatype which holds double data | -""" -@cenum t8_netcdf_variable_type::UInt32 begin - T8_NETCDF_INT = 0 - T8_NETCDF_INT64 = 1 - T8_NETCDF_DOUBLE = 2 -end - -"""This enumeration contains all possible netCDF variable datatypes (int, int64, double).""" -const t8_netcdf_variable_type_t = t8_netcdf_variable_type - -struct t8_netcdf_variable_t - variable_name::Cstring - variable_long_name::Cstring - variable_units::Cstring - datatype::t8_netcdf_variable_type_t - var_user_dimid::Cint - var_user_data::Ptr{sc_array_t} -end + t8_cmesh_is_empty(cmesh) -""" - t8_cmesh_write_netcdf(cmesh, file_prefix, file_title, dim, num_extern_netcdf_vars, variables, comm) +Check whether a cmesh is empty on all processes. +# Arguments +* `cmesh`:\\[in\\] A committed cmesh. +# Returns +True (non-zero) if and only if the cmesh has trees at all. ### Prototype ```c -void t8_cmesh_write_netcdf (t8_cmesh_t cmesh, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, t8_netcdf_variable_t *variables[], sc_MPI_Comm comm); +int t8_cmesh_is_empty (t8_cmesh_t cmesh); ``` """ -function t8_cmesh_write_netcdf(cmesh, file_prefix, file_title, dim, num_extern_netcdf_vars, variables, comm) - @ccall libt8.t8_cmesh_write_netcdf(cmesh::t8_cmesh_t, file_prefix::Cstring, file_title::Cstring, dim::Cint, num_extern_netcdf_vars::Cint, variables::Ptr{Ptr{t8_netcdf_variable_t}}, comm::MPI_Comm)::Cvoid -end - -struct t8_msh_file_node_t - index::t8_locidx_t - coordinates::NTuple{3, Cdouble} -end - -struct t8_msh_file_node_parametric_t - index::t8_locidx_t - coordinates::NTuple{3, Cdouble} - parameters::NTuple{2, Cdouble} - parametric::Cint - entity_dim::Cint - entity_tag::t8_locidx_t +function t8_cmesh_is_empty(cmesh) + @ccall libt8.t8_cmesh_is_empty(cmesh::t8_cmesh_t)::Cint end """ - t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) + t8_cmesh_bcast(cmesh_in, root, comm) ### Prototype ```c -t8_cmesh_t t8_cmesh_from_msh_file (const char *fileprefix, int partition, sc_MPI_Comm comm, int dim, int master, int use_cad_geometry); +t8_cmesh_t t8_cmesh_bcast (t8_cmesh_t cmesh_in, int root, sc_MPI_Comm comm); ``` """ -function t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) - @ccall libt8.t8_cmesh_from_msh_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, dim::Cint, master::Cint, use_cad_geometry::Cint)::t8_cmesh_t +function t8_cmesh_bcast(cmesh_in, root, comm) + @ccall libt8.t8_cmesh_bcast(cmesh_in::t8_cmesh_t, root::Cint, comm::MPI_Comm)::t8_cmesh_t end -struct sc_stats - mpicomm::MPI_Comm - sarray::Ptr{sc_array_t} -end +mutable struct t8_geometry end -"""The statistics container allows dynamically adding random variables.""" -const sc_statistics_t = sc_stats +"""This typedef holds virtual functions for a particular geometry. We need it so that we can use [`t8_geometry_c`](@ref) pointers in .c files without them seeing the actual C++ code (and then not compiling)""" +const t8_geometry_c = t8_geometry """ - sc_statistics_has(stats, name) + t8_cmesh_register_geometry(cmesh, geometry) -Returns true if the stats include a variable with the given name +Register a geometry in the cmesh. The cmesh takes ownership of the geometry. + +If no geometry is registered and cmesh is modified from another cmesh then the other cmesh's geometries are used. + +!!! note + + If you need to use t8_cmesh_bcast, then all geometries must be registered *after* the bcast operation, not before. +# Arguments +* `cmesh`:\\[in,out\\] The cmesh. +* `geometry`:\\[in\\] The geometry to register. ### Prototype ```c -int sc_statistics_has (sc_statistics_t * stats, const char *name); +void t8_cmesh_register_geometry (t8_cmesh_t cmesh, t8_geometry_c *geometry); ``` """ -function sc_statistics_has(stats, name) - @ccall libsc.sc_statistics_has(stats::Ptr{sc_statistics_t}, name::Cstring)::Cint +function t8_cmesh_register_geometry(cmesh, geometry) + @ccall libt8.t8_cmesh_register_geometry(cmesh::t8_cmesh_t, geometry::Ptr{t8_geometry_c})::Cvoid end """ - sc_statistics_add_empty(stats, name) + t8_cmesh_set_tree_geometry(cmesh, gtreeid, geom) -Register a statistics variable by name and set its count to 0. This variable must not exist already. +Set the geometry for a tree, thus specify which geometry to use for this tree. +# Arguments +* `cmesh`:\\[in\\] A non-committed cmesh. +* `gtreeid`:\\[in\\] A global tree id in *cmesh*. +* `geom`:\\[in\\] The geometry to use for this tree. See also t8_cmesh_get_tree_geometry ### Prototype ```c -void sc_statistics_add_empty (sc_statistics_t * stats, const char *name); +void t8_cmesh_set_tree_geometry (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const t8_geometry_c *geom); ``` """ -function sc_statistics_add_empty(stats, name) - @ccall libsc.sc_statistics_add_empty(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid -end - -struct sc_flopinfo - seconds::Cdouble - cwtime::Cdouble - crtime::Cfloat - cptime::Cfloat - cflpops::Clonglong - iwtime::Cdouble - irtime::Cfloat - iptime::Cfloat - iflpops::Clonglong - mflops::Cfloat - use_papi::Cint +function t8_cmesh_set_tree_geometry(cmesh, gtreeid, geom) + @ccall libt8.t8_cmesh_set_tree_geometry(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, geom::Ptr{t8_geometry_c})::Cvoid end -const sc_flopinfo_t = sc_flopinfo - """ - sc_flops_snap(fi, snapshot) - -Call [`sc_flops_count`](@ref) (fi) and copies fi into snapshot. + t8_cmesh_commit(cmesh, comm) -# Arguments -* `fi`:\\[in,out\\] Members will be updated. -* `snapshot`:\\[out\\] On output is a copy of fi. ### Prototype ```c -void sc_flops_snap (sc_flopinfo_t * fi, sc_flopinfo_t * snapshot); +void t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function sc_flops_snap(fi, snapshot) - @ccall libsc.sc_flops_snap(fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t})::Cvoid +function t8_cmesh_commit(cmesh, comm) + @ccall libt8.t8_cmesh_commit(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - sc_flops_shot(fi, snapshot) + t8_cmesh_save(cmesh, fileprefix) -Call [`sc_flops_count`](@ref) (fi) and override snapshot interval timings with the differences since the previous call to [`sc_flops_snap`](@ref). The interval mflop rate is computed by iflpops / 1e6 / irtime. The cumulative timings in snapshot are copied form fi. +Save the cmesh to a file with the given fileprefix. + +!!! note + + Currently, it is only legal to save cmeshes that use the linear geometry. # Arguments -* `fi`:\\[in,out\\] Members will be updated. -* `snapshot`:\\[in,out\\] Interval timings measured since [`sc_flops_snap`](@ref). +* `cmesh`:\\[in\\] The cmesh to save. +* `fileprefix`:\\[in\\] The prefix of the file to save the cmesh to. ### Prototype ```c -void sc_flops_shot (sc_flopinfo_t * fi, sc_flopinfo_t * snapshot); +int t8_cmesh_save (t8_cmesh_t cmesh, const char *fileprefix); ``` """ -function sc_flops_shot(fi, snapshot) - @ccall libsc.sc_flops_shot(fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t})::Cvoid +function t8_cmesh_save(cmesh, fileprefix) + @ccall libt8.t8_cmesh_save(cmesh::t8_cmesh_t, fileprefix::Cstring)::Cint end """ - sc_statistics_accumulate(stats, name, value) - -Add an instance of a statistics variable, see [`sc_stats_accumulate`](@ref) The variable must previously be added with [`sc_statistics_add_empty`](@ref). + t8_cmesh_load(filename, comm) ### Prototype ```c -void sc_statistics_accumulate (sc_statistics_t * stats, const char *name, double value); +t8_cmesh_t t8_cmesh_load (const char *filename, sc_MPI_Comm comm); ``` """ -function sc_statistics_accumulate(stats, name, value) - @ccall libsc.sc_statistics_accumulate(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid +function t8_cmesh_load(filename, comm) + @ccall libt8.t8_cmesh_load(filename::Cstring, comm::MPI_Comm)::t8_cmesh_t end """ - sc_flops_papi(rtime, ptime, flpops, mflops) + t8_load_mode -Calls PAPI\\_flops. Aborts on PAPI error. The first call sets up the performance counters. Subsequent calls return cumulative real and process times, cumulative floating point operations and the flop rate since the last call. This is a compatibility wrapper: users should only need to use the [`sc_flopinfo_t`](@ref) interface functions below. +This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data. -### Prototype -```c -void sc_flops_papi (float *rtime, float *ptime, long long *flpops, float *mflops); -``` +| Enumerator | Note | +| :----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| T8\\_LOAD\\_SIMPLE | In simple mode, the first n processes load the file | +| T8\\_LOAD\\_BGQ | In BGQ mode, the file is loaded on n nodes and from one process of each node. This needs MPI Version 3.1 or higher. | +| T8\\_LOAD\\_STRIDE | Every n-th process loads a file. Handle with care, we introduce it, since on Juqueen MPI-3 was not available. The parameter n has to be passed as an extra parameter. # See also [`t8_cmesh_load_and_distribute`](@ref) | +| T8\\_LOAD\\_COUNT | | """ -function sc_flops_papi(rtime, ptime, flpops, mflops) - @ccall libsc.sc_flops_papi(rtime::Ptr{Cfloat}, ptime::Ptr{Cfloat}, flpops::Ptr{Clonglong}, mflops::Ptr{Cfloat})::Cvoid +@cenum t8_load_mode::UInt32 begin + T8_LOAD_FIRST = 0 + T8_LOAD_SIMPLE = 0 + T8_LOAD_BGQ = 1 + T8_LOAD_STRIDE = 2 + T8_LOAD_COUNT = 3 end -""" - sc_flops_start(fi) +"""This enumeration contains all modes in which we can open a saved cmesh. The cmesh can be loaded with more processes than it was saved and the mode controls, which of the processes open files and distribute the data.""" +const t8_load_mode_t = t8_load_mode -Prepare [`sc_flopinfo_t`](@ref) structure and start flop counters. Must only be called once during the program run. This function calls [`sc_flops_papi`](@ref). +""" + t8_cmesh_load_and_distribute(fileprefix, num_files, comm, mode, procs_per_node) -# Arguments -* `fi`:\\[out\\] Members will be initialized. ### Prototype ```c -void sc_flops_start (sc_flopinfo_t * fi); +t8_cmesh_t t8_cmesh_load_and_distribute (const char *fileprefix, int num_files, sc_MPI_Comm comm, t8_load_mode_t mode, int procs_per_node); ``` """ -function sc_flops_start(fi) - @ccall libsc.sc_flops_start(fi::Ptr{sc_flopinfo_t})::Cvoid +function t8_cmesh_load_and_distribute(fileprefix, num_files, comm, mode, procs_per_node) + @ccall libt8.t8_cmesh_load_and_distribute(fileprefix::Cstring, num_files::Cint, comm::MPI_Comm, mode::t8_load_mode_t, procs_per_node::Cint)::t8_cmesh_t end """ - sc_flops_start_nopapi(fi) - -Prepare [`sc_flopinfo_t`](@ref) structure and ignore the flop counters. This [`sc_flopinfo_t`](@ref) does not call PAPI\\_flops() in this function or in [`sc_flops_count`](@ref)(). + t8_cmesh_comm_is_valid(cmesh, comm) -# Arguments -* `fi`:\\[out\\] Members will be initialized. ### Prototype ```c -void sc_flops_start_nopapi (sc_flopinfo_t * fi); +int t8_cmesh_comm_is_valid (t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function sc_flops_start_nopapi(fi) - @ccall libsc.sc_flops_start_nopapi(fi::Ptr{sc_flopinfo_t})::Cvoid +function t8_cmesh_comm_is_valid(cmesh, comm) + @ccall libt8.t8_cmesh_comm_is_valid(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cint end """ - sc_flops_count(fi) + t8_cmesh_is_partitioned(cmesh) -Update [`sc_flopinfo_t`](@ref) structure with current measurement. Must only be called after [`sc_flops_start`](@ref). Can be called any number of times. This function calls [`sc_flops_papi`](@ref). +Query whether a committed cmesh is partitioned or replicated. # Arguments -* `fi`:\\[in,out\\] Members will be updated. +* `cmesh`:\\[in\\] A committed cmesh. +# Returns +True if *cmesh* is partitioned. False otherwise. *cmesh* must be committed before calling this function. ### Prototype ```c -void sc_flops_count (sc_flopinfo_t * fi); +int t8_cmesh_is_partitioned (t8_cmesh_t cmesh); ``` """ -function sc_flops_count(fi) - @ccall libsc.sc_flops_count(fi::Ptr{sc_flopinfo_t})::Cvoid +function t8_cmesh_is_partitioned(cmesh) + @ccall libt8.t8_cmesh_is_partitioned(cmesh::t8_cmesh_t)::Cint end -# automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_flops_shotv(fi, va_list...) - :(@ccall(libsc.sc_flops_shotv(fi::Ptr{sc_flopinfo_t}; $(to_c_type_pairs(va_list)...))::Cvoid)) - end - """ - sc_keyvalue_entry_type_t + t8_cmesh_get_dimension(cmesh) -The values can have different types. +Get the dimension of a cmesh. -| Enumerator | Note | -| :------------------------------ | :------------------------------------------ | -| SC\\_KEYVALUE\\_ENTRY\\_NONE | Designate an invalid situation. | -| SC\\_KEYVALUE\\_ENTRY\\_INT | Used for values of type int. | -| SC\\_KEYVALUE\\_ENTRY\\_DOUBLE | Used for values of type double. | -| SC\\_KEYVALUE\\_ENTRY\\_STRING | Used for values of type const char *. | -| SC\\_KEYVALUE\\_ENTRY\\_POINTER | Used for values of anonymous pointer type. | +# Arguments +* `cmesh`:\\[in\\] The cmesh. *cmesh* must be committed before calling this function. +### Prototype +```c +int t8_cmesh_get_dimension (const t8_cmesh_t cmesh); +``` """ -@cenum sc_keyvalue_entry_type_t::UInt32 begin - SC_KEYVALUE_ENTRY_NONE = 0 - SC_KEYVALUE_ENTRY_INT = 1 - SC_KEYVALUE_ENTRY_DOUBLE = 2 - SC_KEYVALUE_ENTRY_STRING = 3 - SC_KEYVALUE_ENTRY_POINTER = 4 +function t8_cmesh_get_dimension(cmesh) + @ccall libt8.t8_cmesh_get_dimension(cmesh::t8_cmesh_t)::Cint end -mutable struct sc_keyvalue end - -"""The key-value container is an opaque structure.""" - -# no prototype is found for this function at sc_keyvalue.h:54:21, please use with caution """ - sc_keyvalue_new() + t8_cmesh_get_num_trees(cmesh) -Create a new key-value container. +Return the global number of trees in a cmesh. +# Arguments +* `cmesh`:\\[in\\] The cmesh to be considered. # Returns -The container is ready to use. +The number of trees associated to *cmesh*. *cmesh* must be committed before calling this function. ### Prototype ```c +t8_gloidx_t t8_cmesh_get_num_trees (t8_cmesh_t cmesh); ``` """ -function sc_keyvalue_new() +function t8_cmesh_get_num_trees(cmesh) + @ccall libt8.t8_cmesh_get_num_trees(cmesh::t8_cmesh_t)::t8_gloidx_t end -# automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_keyvalue_newf(dummy, va_list...) - end - """ - sc_keyvalue_destroy(kv) + t8_cmesh_get_num_local_trees(cmesh) -Free a key-value container and all internal memory for key storage. +Return the number of local trees of a cmesh. If the cmesh is not partitioned this is equivalent to t8_cmesh_get_num_trees. # Arguments -* `kv`:\\[in,out\\] The key-value container is invalidated by this call. +* `cmesh`:\\[in\\] The cmesh to be considered. +# Returns +The number of local trees of the cmesh. *cmesh* must be committed before calling this function. ### Prototype ```c +t8_locidx_t t8_cmesh_get_num_local_trees (t8_cmesh_t cmesh); ``` """ -function sc_keyvalue_destroy(kv) +function t8_cmesh_get_num_local_trees(cmesh) + @ccall libt8.t8_cmesh_get_num_local_trees(cmesh::t8_cmesh_t)::t8_locidx_t end """ - sc_keyvalue_exists(kv, key) + t8_cmesh_get_num_ghosts(cmesh) -Routine to check existence of an entry. +Return the number of ghost trees of a cmesh. If the cmesh is not partitioned this is equivalent to t8_cmesh_get_num_trees. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key to query. +* `cmesh`:\\[in\\] The cmesh to be considered. # Returns -The entry's type if found and SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. +The number of ghost trees of the cmesh. *cmesh* must be committed before calling this function. ### Prototype ```c +t8_locidx_t t8_cmesh_get_num_ghosts (t8_cmesh_t cmesh); ``` """ -function sc_keyvalue_exists(kv, key) +function t8_cmesh_get_num_ghosts(cmesh) + @ccall libt8.t8_cmesh_get_num_ghosts(cmesh::t8_cmesh_t)::t8_locidx_t end """ - sc_keyvalue_unset(kv, key) + t8_cmesh_get_first_treeid(cmesh) -Routine to remove an entry. +Return the global index of the first local tree of a cmesh. If the cmesh is not partitioned this is always 0. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key to remove if it exists. +* `cmesh`:\\[in\\] The cmesh to be considered. # Returns -The entry's type if found and removed, SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. +The global id of the first local tree in cmesh. *cmesh* must be committed before calling this function. ### Prototype ```c +t8_gloidx_t t8_cmesh_get_first_treeid (t8_cmesh_t cmesh); ``` """ -function sc_keyvalue_unset(kv, key) +function t8_cmesh_get_first_treeid(cmesh) + @ccall libt8.t8_cmesh_get_first_treeid(cmesh::t8_cmesh_t)::t8_gloidx_t end """ - sc_keyvalue_get_int(kv, key, dvalue) + t8_cmesh_get_tree_geometry(cmesh, gtreeid) -Routines to retrieve an integer value by its key. This function asserts that the key, if existing, points to the correct type. +Get the geometry of a tree. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. +* `cmesh`:\\[in\\] The cmesh. +* `gtreeid`:\\[in\\] The global tree id of the tree for which the geometry should be returned. # Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. +The geometry of the tree. ### Prototype ```c +const t8_geometry_c * t8_cmesh_get_tree_geometry (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); ``` """ -function sc_keyvalue_get_int(kv, key, dvalue) +function t8_cmesh_get_tree_geometry(cmesh, gtreeid) + @ccall libt8.t8_cmesh_get_tree_geometry(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Ptr{t8_geometry_c} end """ - sc_keyvalue_get_double(kv, key, dvalue) + t8_cmesh_treeid_is_local_tree(cmesh, ltreeid) -Retrieve a double value by its key. This function asserts that the key, if existing, points to the correct type. +Query whether a given [`t8_locidx_t`](@ref) belongs to a local tree of a cmesh. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. +* `cmesh`:\\[in\\] The cmesh to be considered. +* `ltreeid`:\\[in\\] An (possible) tree index. # Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. +True if *ltreeid* matches the range of local trees of *cmesh*. False if not. *cmesh* must be committed before calling this function. ### Prototype ```c +int t8_cmesh_treeid_is_local_tree (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid); ``` """ -function sc_keyvalue_get_double(kv, key, dvalue) +function t8_cmesh_treeid_is_local_tree(cmesh, ltreeid) + @ccall libt8.t8_cmesh_treeid_is_local_tree(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t)::Cint end """ - sc_keyvalue_get_string(kv, key, dvalue) + t8_cmesh_treeid_is_ghost(cmesh, ltreeid) -Retrieve a string value by its key. This function asserts that the key, if existing, points to the correct type. +Query whether a given [`t8_locidx_t`](@ref) belongs to a ghost of a cmesh. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. +* `cmesh`:\\[in\\] The cmesh to be considered. +* `ltreeid`:\\[in\\] An (possible) ghost index. # Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. +True if *ltreeid* matches the range of ghost trees of *cmesh*. False if not. *cmesh* must be committed before calling this function. ### Prototype ```c +int t8_cmesh_treeid_is_ghost (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid); ``` """ -function sc_keyvalue_get_string(kv, key, dvalue) +function t8_cmesh_treeid_is_ghost(cmesh, ltreeid) + @ccall libt8.t8_cmesh_treeid_is_ghost(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t)::Cint end """ - sc_keyvalue_get_pointer(kv, key, dvalue) + t8_cmesh_ltreeid_to_ghostid(cmesh, ltreeid) -Retrieve a pointer value by its key. This function asserts that the key, if existing, points to the correct type. +Given a local tree id that belongs to a ghost, return the index of the ghost. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `key`:\\[in\\] Lookup key, may or may not exist. -* `dvalue`:\\[in\\] Default value returned if key is not found. +* `cmesh`:\\[in\\] The cmesh to be considered. +* `ltreeid`:\\[in\\] The local id of a ghost, satisfying t8_cmesh_treeid_is_ghost, thus num\\_trees <= *ltreeid* < num\\_trees + num\\_ghosts # Returns -If key is not present then **dvalue** is returned, otherwise the value stored under **key**. +The index of the ghost within all ghosts, thus an index 0 <= index < num\\_ghosts *cmesh* must be committed before calling this function. ### Prototype ```c +t8_locidx_t t8_cmesh_ltreeid_to_ghostid (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid); ``` """ -function sc_keyvalue_get_pointer(kv, key, dvalue) +function t8_cmesh_ltreeid_to_ghostid(cmesh, ltreeid) + @ccall libt8.t8_cmesh_ltreeid_to_ghostid(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - sc_keyvalue_get_int_check(kv, key, status) + t8_cmesh_get_first_tree(cmesh) -Query an integer key with error checking. We check whether the key is not found or it is of the wrong type. A default value to be returned on error can be passed in as *status. If status is NULL, then the result on error is undefined. +Return a pointer to the first local tree in a cmesh. # Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key string. -* `status`:\\[in,out\\] If not NULL, set to 0 if there is no error, 1 if the key is not found, 2 if a value is found but its type is not integer, and return the input value *status on error. +* `cmesh`:\\[in\\] The cmesh to be queried. # Returns -On error we return *status if status is not NULL, and else an undefined value backed by an assertion. Without error, return the result of the lookup. +A pointer to the first local tree in *cmesh*. If *cmesh* has no local trees, NULL is returned. *cmesh* must be committed before calling this function. ### Prototype ```c +t8_ctree_t t8_cmesh_get_first_tree (t8_cmesh_t cmesh); ``` """ -function sc_keyvalue_get_int_check(kv, key, status) +function t8_cmesh_get_first_tree(cmesh) + @ccall libt8.t8_cmesh_get_first_tree(cmesh::t8_cmesh_t)::t8_ctree_t end """ - sc_keyvalue_set_int(kv, key, newvalue) + t8_cmesh_get_next_tree(cmesh, tree) -Routine to set an integer value for a given key. +Given a local tree in a cmesh return a pointer to the next local tree. # Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type integer. -* `newvalue`:\\[in\\] New value will be stored under key. +* `cmesh`:\\[in\\] The cmesh to be queried. +* `tree`:\\[in\\] A local tree in *cmesh*. +# Returns +A pointer to the next local tree in *cmesh* after *tree*. If no such tree exists, NULL is returned. * *cmesh* must be committed before calling this function. TODO: If we run over tree numbers only, don't use ctree\\_t in API if possible. ### Prototype ```c +t8_ctree_t t8_cmesh_get_next_tree (t8_cmesh_t cmesh, t8_ctree_t tree); ``` """ -function sc_keyvalue_set_int(kv, key, newvalue) +function t8_cmesh_get_next_tree(cmesh, tree) + @ccall libt8.t8_cmesh_get_next_tree(cmesh::t8_cmesh_t, tree::t8_ctree_t)::t8_ctree_t end """ - sc_keyvalue_set_double(kv, key, newvalue) + t8_cmesh_get_tree(cmesh, ltree_id) -Routine to set a double value for a given key. +Return a pointer to a given local tree. # Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type double. -* `newvalue`:\\[in\\] New value will be stored under key. +* `cmesh`:\\[in\\] The cmesh to be queried. +* `ltree_id`:\\[in\\] The local id of the tree that is asked for. +# Returns +A pointer to tree in *cmesh* with local id *ltree_id*. The cmesh must have at least *ltree_id* + 1 local trees when calling this function. *cmesh* must be committed before calling this function. ### Prototype ```c +t8_ctree_t t8_cmesh_get_tree (t8_cmesh_t cmesh, t8_locidx_t ltree_id); ``` """ -function sc_keyvalue_set_double(kv, key, newvalue) +function t8_cmesh_get_tree(cmesh, ltree_id) + @ccall libt8.t8_cmesh_get_tree(cmesh::t8_cmesh_t, ltree_id::t8_locidx_t)::t8_ctree_t end """ - sc_keyvalue_set_string(kv, key, newvalue) + t8_cmesh_get_tree_class(cmesh, ltree_id) -Routine to set a string value for a given key. +Return the eclass of a given local tree. TODO: Should we refer to indices or consequently use ctree\\_t? # Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type string. -* `newvalue`:\\[in\\] New value will be stored under key. +* `cmesh`:\\[in\\] The cmesh to be considered. +* `ltree_id`:\\[in\\] The local id of the tree whose eclass will be returned. +# Returns +The eclass of the given tree. TODO: Call tree ids ltree\\_id or gtree\\_id etc. instead of tree\\_id. *cmesh* must be committed before calling this function. ### Prototype ```c +t8_eclass_t t8_cmesh_get_tree_class (t8_cmesh_t cmesh, t8_locidx_t ltree_id); ``` """ -function sc_keyvalue_set_string(kv, key, newvalue) +function t8_cmesh_get_tree_class(cmesh, ltree_id) + @ccall libt8.t8_cmesh_get_tree_class(cmesh::t8_cmesh_t, ltree_id::t8_locidx_t)::t8_eclass_t end """ - sc_keyvalue_set_pointer(kv, key, newvalue) + t8_cmesh_tree_face_is_boundary(cmesh, ltree_id, face) -Routine to set a pointer value for a given key. +Query whether a face of a local tree or ghost is at the domain boundary. # Arguments -* `kv`:\\[in\\] Valid key-value table. -* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type pointer. -* `newvalue`:\\[in\\] New value will be stored under key. +* `cmesh`:\\[in\\] The cmesh to be considered. +* `ltree_id`:\\[in\\] The local id of a tree. +* `face`:\\[in\\] The number of a face of the tree. +# Returns +True if the face is at the domain boundary. False otherwise. *cmesh* must be committed before calling this function. ### Prototype ```c +int t8_cmesh_tree_face_is_boundary (t8_cmesh_t cmesh, t8_locidx_t ltree_id, int face); ``` """ -function sc_keyvalue_set_pointer(kv, key, newvalue) +function t8_cmesh_tree_face_is_boundary(cmesh, ltree_id, face) + @ccall libt8.t8_cmesh_tree_face_is_boundary(cmesh::t8_cmesh_t, ltree_id::t8_locidx_t, face::Cint)::Cint end -# typedef int ( * sc_keyvalue_foreach_t ) ( const char * key , const sc_keyvalue_entry_type_t type , void * entry , const void * u ) """ -Function to call on every key value pair + t8_cmesh_get_ghost_class(cmesh, lghost_id) + +Return the eclass of a given local ghost. TODO: Should we refer to indices or consequently use cghost\\_t? # Arguments -* `key`:\\[in\\] The key for this pair -* `type`:\\[in\\] The type of entry -* `entry`:\\[in\\] Pointer to the entry -* `u`:\\[in\\] Arbitrary user data. +* `cmesh`:\\[in\\] The cmesh to be considered. +* `lghost_id`:\\[in\\] The local id of the ghost whose eclass will be returned. 0 <= *tree_id* < cmesh.num\\_ghosts. # Returns -Return true if the traversal should continue, false to stop. +The eclass of the given ghost. *cmesh* must be committed before calling this function. +### Prototype +```c +t8_eclass_t t8_cmesh_get_ghost_class (t8_cmesh_t cmesh, t8_locidx_t lghost_id); +``` """ -const sc_keyvalue_foreach_t = Ptr{Cvoid} +function t8_cmesh_get_ghost_class(cmesh, lghost_id) + @ccall libt8.t8_cmesh_get_ghost_class(cmesh::t8_cmesh_t, lghost_id::t8_locidx_t)::t8_eclass_t +end """ - sc_keyvalue_foreach(kv, fn, user_data) + t8_cmesh_get_global_id(cmesh, local_id) -Iterate through all stored key-value pairs. +Return the global id of a given local tree or ghost. # Arguments -* `kv`:\\[in\\] Valid key-value container. -* `fn`:\\[in\\] Function to call on each key-value pair. -* `user_data`:\\[in,out\\] This pointer is passed through to **fn**. +* `cmesh`:\\[in\\] The cmesh to be considered. +* `local_id`:\\[in\\] The local id of a tree or a ghost. If *local_id* < cmesh.num\\_local\\_trees then it is a tree, otherwise a ghost. +# Returns +The global id of the tree/ghost. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c +t8_gloidx_t t8_cmesh_get_global_id (t8_cmesh_t cmesh, t8_locidx_t local_id); ``` """ -function sc_keyvalue_foreach(kv, fn, user_data) +function t8_cmesh_get_global_id(cmesh, local_id) + @ccall libt8.t8_cmesh_get_global_id(cmesh::t8_cmesh_t, local_id::t8_locidx_t)::t8_gloidx_t end """ - sc_statinfo + t8_cmesh_get_local_id(cmesh, global_id) -Store information of one random variable. +Return the local id of a give global tree. -| Field | Note | -| :--------------- | :--------------------------------------- | -| dirty | Only update stats if this is true. | -| count | Inout; global count is 52 bit accurate. | -| sum\\_values | Inout; global sum of values. | -| sum\\_squares | Inout; global sum of squares. | -| min | Inout; minimum over values. | -| max | Inout; maximum over values. | -| variable | Name of the variable for output. | -| variable\\_owned | NULL or deep copy of variable. | -| group | Grouping identifier. | -| prio | Priority identifier. | +# Arguments +* `cmesh`:\\[in\\] The cmesh. +* `global_id`:\\[in\\] A global tree id. +# Returns +Either a value l 0 <= *l* < num\\_local\\_trees if *global_id* corresponds to a local tree, or num\\_local\\_trees <= *l* < num\\_local\\_trees + num\\_ghosts if *global_id* corresponds to a ghost trees, or negative if *global_id* neither matches a local nor a ghost tree. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + +### Prototype +```c +t8_locidx_t t8_cmesh_get_local_id (t8_cmesh_t cmesh, t8_gloidx_t global_id); +``` """ -struct sc_statinfo - dirty::Cint - count::Clong - sum_values::Cdouble - sum_squares::Cdouble - min::Cdouble - max::Cdouble - min_at_rank::Cint - max_at_rank::Cint - average::Cdouble - variance::Cdouble - standev::Cdouble - variance_mean::Cdouble - standev_mean::Cdouble - variable::Cstring - variable_owned::Cstring - group::Cint - prio::Cint +function t8_cmesh_get_local_id(cmesh, global_id) + @ccall libt8.t8_cmesh_get_local_id(cmesh::t8_cmesh_t, global_id::t8_gloidx_t)::t8_locidx_t end -"""Store information of one random variable.""" -const sc_statinfo_t = sc_statinfo - """ - sc_stats_set1(stats, value, variable) + t8_cmesh_get_face_neighbor(cmesh, ltreeid, face, dual_face, orientation) -Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. We set sc_stats_group_all and sc_stats_prio_all internally. +Given a local tree id and a face number, get information about the face neighbor tree. + +!!! note + + If *ltreeid* is a ghost and it has a neighbor which is neither a local tree or ghost, then the return value will be negative. Thus, a negative return value does not necessarily mean that this is a domain boundary. To find out whether a tree is a domain boundary or not # Arguments -* `stats`:\\[out\\] Will be filled with count=1 and the value. -* `value`:\\[in\\] Value used to fill statistics information. -* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. +* `cmesh`:\\[in\\] The cmesh to be considered. +* `ltreeid`:\\[in\\] The local id of a tree or a ghost. +* `face`:\\[in\\] A face number of the tree/ghost. +* `dual_face`:\\[out\\] If not NULL, the face number of the neighbor tree at this connection. +* `orientation`:\\[out\\] If not NULL, the face orientation of the connection. +# Returns +If non-negative: The local id of the neighbor tree or ghost. If negative: There is no neighbor across this face. *dual_face* and *orientation* remain unchanged. +# See also +[`t8_cmesh_tree_face_is_boundary`](@ref). + ### Prototype ```c -void sc_stats_set1 (sc_statinfo_t * stats, double value, const char *variable); +t8_locidx_t t8_cmesh_get_face_neighbor (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid, const int face, int *dual_face, int *orientation); ``` """ -function sc_stats_set1(stats, value, variable) - @ccall libsc.sc_stats_set1(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring)::Cvoid +function t8_cmesh_get_face_neighbor(cmesh, ltreeid, face, dual_face, orientation) + @ccall libt8.t8_cmesh_get_face_neighbor(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t, face::Cint, dual_face::Ptr{Cint}, orientation::Ptr{Cint})::t8_locidx_t end """ - sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) + t8_cmesh_get_tree_face_neighbor_eclass(cmesh, ltreeid, face) -Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. +Given a local tree id (of a local tree or ghost tree) and a face compute the eclass of the tree's face neighbor. # Arguments -* `stats`:\\[out\\] Will be filled with count=1 and the value. -* `value`:\\[in\\] Value used to fill statistics information. -* `variable`:\\[in\\] String to be reported by sc_stats_print. -* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. -* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. -* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. +* `cmesh`:\\[in\\] The cmesh to be considered. +* `ltreeid`:\\[in\\] The local id of a tree or a ghost. +* `face`:\\[in\\] A face number of the tree/ghost. +# Returns +The eclass of a neighbor tree of *ltreeid* across *face*. T8\\_ECLASS\\_INVALID if no neighbor exists. ### Prototype ```c -void sc_stats_set1_ext (sc_statinfo_t * stats, double value, const char *variable, int copy_variable, int stats_group, int stats_prio); +t8_eclass_t t8_cmesh_get_tree_face_neighbor_eclass (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid, const int face); ``` """ -function sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) - @ccall libsc.sc_stats_set1_ext(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid +function t8_cmesh_get_tree_face_neighbor_eclass(cmesh, ltreeid, face) + @ccall libt8.t8_cmesh_get_tree_face_neighbor_eclass(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t, face::Cint)::t8_eclass_t end """ - sc_stats_init(stats, variable) + t8_cmesh_print_profile(cmesh) -Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. We set sc_stats_group_all and sc_stats_prio_all internally. +Print the collected statistics from a cmesh profile. + +*cmesh* must be committed before calling this function. # Arguments -* `stats`:\\[out\\] Will be filled with count 0 and values of 0. -* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. +* `cmesh`:\\[in\\] The cmesh. +# See also +[`t8_cmesh_set_profiling`](@ref) + ### Prototype ```c -void sc_stats_init (sc_statinfo_t * stats, const char *variable); +void t8_cmesh_print_profile (t8_cmesh_t cmesh); ``` """ -function sc_stats_init(stats, variable) - @ccall libsc.sc_stats_init(stats::Ptr{sc_statinfo_t}, variable::Cstring)::Cvoid +function t8_cmesh_print_profile(cmesh) + @ccall libt8.t8_cmesh_print_profile(cmesh::t8_cmesh_t)::Cvoid end """ - sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) + t8_cmesh_get_tree_vertices(cmesh, ltreeid) -Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. +Return a pointer to the vertex coordinates of a tree. # Arguments -* `stats`:\\[out\\] Will be filled with count 0 and values of 0. -* `variable`:\\[in\\] String to be reported by sc_stats_print. -* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. -* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. -* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. +* `cmesh`:\\[in\\] The cmesh. +* `ltreeid`:\\[in\\] The id of a local tree. +# Returns +If stored, a pointer to the vertex coordinates of *tree*. If no coordinates for this tree are found, NULL. ### Prototype ```c -void sc_stats_init_ext (sc_statinfo_t * stats, const char *variable, int copy_variable, int stats_group, int stats_prio); +double * t8_cmesh_get_tree_vertices (t8_cmesh_t cmesh, t8_locidx_t ltreeid); ``` """ -function sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) - @ccall libsc.sc_stats_init_ext(stats::Ptr{sc_statinfo_t}, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid +function t8_cmesh_get_tree_vertices(cmesh, ltreeid) + @ccall libt8.t8_cmesh_get_tree_vertices(cmesh::t8_cmesh_t, ltreeid::t8_locidx_t)::Ptr{Cdouble} end """ - sc_stats_reset(stats, reset_vgp) + t8_cmesh_get_attribute(cmesh, package_id, key, ltree_id) -Reset all values to zero, optionally unassign name, group, and priority. +Return the attribute pointer of a tree. + +!!! note + + *cmesh* must be committed before calling this function. # Arguments -* `stats`:\\[in,out\\] Variables are zeroed. They can be set again by set1 or accumulate. -* `reset_vgp`:\\[in\\] If true, the variable name string is zeroed and if we did a copy, the copy is freed. If true, group and priority are set to all. If false, we don't touch any of the above. +* `cmesh`:\\[in\\] The cmesh. +* `package_id`:\\[in\\] The identifier of a valid software package. +* `key`:\\[in\\] A key used to identify the attribute under all attributes of this tree with the same *package_id*. +* `ltree_id`:\\[in\\] The local number of the tree. +# Returns +The attribute pointer of the tree *ltree_id* or NULL if the attribute is not found. +# See also +[`sc_package_register`](@ref), [`t8_cmesh_set_attribute`](@ref) + ### Prototype ```c -void sc_stats_reset (sc_statinfo_t * stats, int reset_vgp); +void * t8_cmesh_get_attribute (const t8_cmesh_t cmesh, const int package_id, const int key, const t8_locidx_t ltree_id); ``` """ -function sc_stats_reset(stats, reset_vgp) - @ccall libsc.sc_stats_reset(stats::Ptr{sc_statinfo_t}, reset_vgp::Cint)::Cvoid +function t8_cmesh_get_attribute(cmesh, package_id, key, ltree_id) + @ccall libt8.t8_cmesh_get_attribute(cmesh::t8_cmesh_t, package_id::Cint, key::Cint, ltree_id::t8_locidx_t)::Ptr{Cvoid} end """ - sc_stats_set_group_prio(stats, stats_group, stats_prio) + t8_cmesh_get_attribute_gloidx_array(cmesh, package_id, key, ltree_id, data_count) -Set/update the group and priority information for a stats item. +Return the attribute pointer of a tree for a gloidx\\_t array. + +!!! note + + *cmesh* must be committed before calling this function. + +!!! note + + No check is performed whether the attribute actually stored *data_count* many entries since we do not store the number of data entries of the attribute array. You can keep track of the data count yourself by using another attribute. # Arguments -* `stats`:\\[out\\] Only group and stats entries are updated. -* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. -* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. +* `cmesh`:\\[in\\] The cmesh. +* `package_id`:\\[in\\] The identifier of a valid software package. +* `key`:\\[in\\] A key used to identify the attribute under all attributes of this tree with the same *package_id*. +* `ltree_id`:\\[in\\] The local number of the tree. +* `data_count`:\\[in\\] The number of entries in the array that are requested. This must be smaller or equal to the *data_count* parameter of the corresponding call to t8_cmesh_set_attribute_gloidx_array +# Returns +The attribute pointer of the tree *ltree_id* or NULL if the attribute is not found. +# See also +[`sc_package_register`](@ref), [`t8_cmesh_set_attribute_gloidx_array`](@ref) + ### Prototype ```c -void sc_stats_set_group_prio (sc_statinfo_t * stats, int stats_group, int stats_prio); +t8_gloidx_t * t8_cmesh_get_attribute_gloidx_array (const t8_cmesh_t cmesh, const int package_id, const int key, const t8_locidx_t ltree_id, const size_t data_count); ``` """ -function sc_stats_set_group_prio(stats, stats_group, stats_prio) - @ccall libsc.sc_stats_set_group_prio(stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint)::Cvoid +function t8_cmesh_get_attribute_gloidx_array(cmesh, package_id, key, ltree_id, data_count) + @ccall libt8.t8_cmesh_get_attribute_gloidx_array(cmesh::t8_cmesh_t, package_id::Cint, key::Cint, ltree_id::t8_locidx_t, data_count::Csize_t)::Ptr{t8_gloidx_t} end """ - sc_stats_accumulate(stats, value) + t8_cmesh_get_partition_table(cmesh) -Add an instance of the random variable. The counter of the variable is increased by one. The value is added into the present values of the variable. +Return the shared memory array storing the partition table of a partitioned cmesh. # Arguments -* `stats`:\\[out\\] Must be dirty. We bump count and values. -* `value`:\\[in\\] Value used to update statistics information. +* `cmesh`:\\[in\\] The cmesh. +# Returns +The partition array. NULL if the cmesh is not partitioned or the partition array is not stored in *cmesh*. *cmesh* must be committed before calling this function. ### Prototype ```c -void sc_stats_accumulate (sc_statinfo_t * stats, double value); +t8_shmem_array_t t8_cmesh_get_partition_table (t8_cmesh_t cmesh); ``` """ -function sc_stats_accumulate(stats, value) - @ccall libsc.sc_stats_accumulate(stats::Ptr{sc_statinfo_t}, value::Cdouble)::Cvoid +function t8_cmesh_get_partition_table(cmesh) + @ccall libt8.t8_cmesh_get_partition_table(cmesh::t8_cmesh_t)::t8_shmem_array_t end """ - sc_stats_compute(mpicomm, nvars, stats) + t8_cmesh_uniform_bounds_equal_element_count(cmesh, level, tree_scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) -### Prototype +Calculate the section of a uniform forest for the current rank. + +# Arguments +* `cmesh`:\\[in\\] The cmesh to be considered. +* `level`:\\[in\\] The uniform refinement level to be created. +* `tree_scheme`:\\[in\\] The element scheme for which to compute the bounds. +* `first_local_tree`:\\[out\\] The first tree that contains elements belonging to the calling processor. +* `child_in_tree_begin`:\\[out\\] The tree-local index of the first element belonging to the calling processor. Not computed if NULL. +* `last_local_tree`:\\[out\\] The last tree that contains elements belonging to the calling processor. +* `child_in_tree_end`:\\[out\\] The tree-local index of the first element that does not belonging to the calling processor anymore. Not computed if NULL. +* `first_tree_shared`:\\[out\\] If not NULL, 1 or 0 is stored here depending on whether *first_local_tree* is the same as *last_local_tree* on the previous process. *cmesh* must be committed before calling this function. +### Prototype ```c -void sc_stats_compute (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); +void t8_cmesh_uniform_bounds_equal_element_count (t8_cmesh_t cmesh, const int level, const t8_scheme_c *tree_scheme, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared); ``` """ -function sc_stats_compute(mpicomm, nvars, stats) - @ccall libsc.sc_stats_compute(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid +function t8_cmesh_uniform_bounds_equal_element_count(cmesh, level, tree_scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared) + @ccall libt8.t8_cmesh_uniform_bounds_equal_element_count(cmesh::t8_cmesh_t, level::Cint, tree_scheme::Ptr{t8_scheme_c}, first_local_tree::Ptr{t8_gloidx_t}, child_in_tree_begin::Ptr{t8_gloidx_t}, last_local_tree::Ptr{t8_gloidx_t}, child_in_tree_end::Ptr{t8_gloidx_t}, first_tree_shared::Ptr{Int8})::Cvoid end """ - sc_stats_compute1(mpicomm, nvars, stats) + t8_cmesh_uniform_bounds_for_irregular_refinement(cmesh, level, scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared, comm) ### Prototype ```c -void sc_stats_compute1 (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); +void t8_cmesh_uniform_bounds_for_irregular_refinement (const t8_cmesh_t cmesh, const int level, const t8_scheme_c *scheme, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared, sc_MPI_Comm comm); ``` """ -function sc_stats_compute1(mpicomm, nvars, stats) - @ccall libsc.sc_stats_compute1(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid +function t8_cmesh_uniform_bounds_for_irregular_refinement(cmesh, level, scheme, first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared, comm) + @ccall libt8.t8_cmesh_uniform_bounds_for_irregular_refinement(cmesh::t8_cmesh_t, level::Cint, scheme::Ptr{t8_scheme_c}, first_local_tree::Ptr{t8_gloidx_t}, child_in_tree_begin::Ptr{t8_gloidx_t}, last_local_tree::Ptr{t8_gloidx_t}, child_in_tree_end::Ptr{t8_gloidx_t}, first_tree_shared::Ptr{Int8}, comm::MPI_Comm)::Cvoid end """ - sc_stats_print(package_id, log_priority, nvars, stats, full, summary) + t8_cmesh_ref(cmesh) -Print measured statistics. This function uses the `SC_LC_GLOBAL` log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. All groups and priorities are printed. +Increase the reference counter of a cmesh. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Log priority for output according to sc.h. -* `nvars`:\\[in\\] Number of stats items in input array. -* `stats`:\\[in\\] Input array of stats variable items. -* `full`:\\[in\\] Print full information for every variable. -* `summary`:\\[in\\] Print summary information all on 1 line. +* `cmesh`:\\[in,out\\] On input, this cmesh must exist with positive reference count. It may be in any state. ### Prototype ```c -void sc_stats_print (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int full, int summary); +void t8_cmesh_ref (t8_cmesh_t cmesh); ``` """ -function sc_stats_print(package_id, log_priority, nvars, stats, full, summary) - @ccall libsc.sc_stats_print(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, full::Cint, summary::Cint)::Cvoid +function t8_cmesh_ref(cmesh) + @ccall libt8.t8_cmesh_ref(cmesh::t8_cmesh_t)::Cvoid end """ - sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) + t8_cmesh_unref(pcmesh) -Print measured statistics, filter by group and/or priority. This function uses the `SC_LC_GLOBAL` log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. +Decrease the reference counter of a cmesh. If the counter reaches zero, this cmesh is destroyed. See also t8_cmesh_destroy, which is to be preferred when it is known that the last reference to a cmesh is deleted. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Log priority for output according to sc.h. -* `nvars`:\\[in\\] Number of stats items in input array. -* `stats`:\\[in\\] Input array of stats variable items. -* `stats_group`:\\[in\\] Print only this group. Non-negative or sc_stats_group_all. We skip printing a variable if neither this parameter nor the item's group is all and if the item's group does not match this. -* `stats_prio`:\\[in\\] Print this and higher priorities. Non-negative or sc_stats_prio_all. We skip printing a variable if neither this parameter nor the item's prio is all and if the item's prio is less than this. -* `full`:\\[in\\] Print full information for every variable. This produces multiple lines including minimum, maximum, and standard deviation. If this is false, print one line per variable. -* `summary`:\\[in\\] Print summary information all on 1 line. This always contains all variables. Not affected by stats\\_group and stats\\_prio. +* `pcmesh`:\\[in,out\\] On input, the cmesh pointed to must exist with positive reference count. It may be in any state. If the reference count reaches zero, the cmesh is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the cmesh is not modified in other ways. ### Prototype ```c -void sc_stats_print_ext (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int stats_group, int stats_prio, int full, int summary); +void t8_cmesh_unref (t8_cmesh_t *pcmesh); ``` """ -function sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) - @ccall libsc.sc_stats_print_ext(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint, full::Cint, summary::Cint)::Cvoid +function t8_cmesh_unref(pcmesh) + @ccall libt8.t8_cmesh_unref(pcmesh::Ptr{t8_cmesh_t})::Cvoid end """ - sc_statistics_new(mpicomm) + t8_cmesh_destroy(pcmesh) + +Verify that a coarse mesh has only one reference left and destroy it. This function is preferred over t8_cmesh_unref when it is known that the last reference is to be deleted. +# Arguments +* `pcmesh`:\\[in,out\\] This cmesh must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_cmesh_unref. ### Prototype ```c -sc_statistics_t *sc_statistics_new (sc_MPI_Comm mpicomm); +void t8_cmesh_destroy (t8_cmesh_t *pcmesh); ``` """ -function sc_statistics_new(mpicomm) - @ccall libsc.sc_statistics_new(mpicomm::MPI_Comm)::Ptr{sc_statistics_t} +function t8_cmesh_destroy(pcmesh) + @ccall libt8.t8_cmesh_destroy(pcmesh::Ptr{t8_cmesh_t})::Cvoid end """ - sc_statistics_destroy(stats) + t8_cmesh_coords_axb(coords_in, coords_out, num_vertices, alpha, b) -Destroy a statistics structure. +Compute y = ax + b on an array of doubles, interpreting each 3 as one vector x # Arguments -* `stats`:\\[in,out\\] Valid object is invalidated. +* `coords_in`:\\[in\\] The incoming coordinates of the vectors +* `coords_out`:\\[out\\] The computed coordinates of the vectors +* `num_vertices`:\\[in\\] The number of vertices/vectors +* `alpha`:\\[in\\] Scaling factor for the vectors +* `b`:\\[in\\] Translation of the vectors. ### Prototype ```c -void sc_statistics_destroy (sc_statistics_t * stats); +void t8_cmesh_coords_axb (const double *coords_in, double *coords_out, int num_vertices, double alpha, const double b[3]); ``` """ -function sc_statistics_destroy(stats) - @ccall libsc.sc_statistics_destroy(stats::Ptr{sc_statistics_t})::Cvoid +function t8_cmesh_coords_axb(coords_in, coords_out, num_vertices, alpha, b) + @ccall libt8.t8_cmesh_coords_axb(coords_in::Ptr{Cdouble}, coords_out::Ptr{Cdouble}, num_vertices::Cint, alpha::Cdouble, b::Ptr{Cdouble})::Cvoid end """ - sc_statistics_add(stats, name) + t8_cmesh_translate_coordinates(coords_in, coords_out, num_vertices, translate) -Register a statistics variable by name and set its value to 0. This variable must not exist already. +Compute y = x + translate on an array of doubles, interpreting each 3 as one vector x +# Arguments +* `coords_in`:\\[in\\] The incoming coordinates of the vectors +* `coords_out`:\\[out\\] The computed coordinates of the vectors +* `num_vertices`:\\[in\\] The number of vertices/vectors +* `translate`:\\[in\\] Translation of the vectors. ### Prototype ```c -void sc_statistics_add (sc_statistics_t * stats, const char *name); +void t8_cmesh_translate_coordinates (const double *coords_in, double *coords_out, const int num_vertices, const double translate[3]); ``` """ -function sc_statistics_add(stats, name) - @ccall libsc.sc_statistics_add(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid +function t8_cmesh_translate_coordinates(coords_in, coords_out, num_vertices, translate) + @ccall libt8.t8_cmesh_translate_coordinates(coords_in::Ptr{Cdouble}, coords_out::Ptr{Cdouble}, num_vertices::Cint, translate::Ptr{Cdouble})::Cvoid end """ - sc_statistics_set(stats, name, value) + t8_cmesh_new_translate_vertices_to_attributes(tvertices, vertices, attr_vertices, num_vertices) -Set the value of a statistics variable, see [`sc_stats_set1`](@ref). The variable must previously be added with [`sc_statistics_add`](@ref). This assumes count=1 as in the [`sc_stats_set1`](@ref) function above. +TODO: Add proper documentation ### Prototype ```c -void sc_statistics_set (sc_statistics_t * stats, const char *name, double value); +void t8_cmesh_new_translate_vertices_to_attributes (const t8_locidx_t *tvertices, const double *vertices, double *attr_vertices, const int num_vertices); ``` """ -function sc_statistics_set(stats, name, value) - @ccall libsc.sc_statistics_set(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid +function t8_cmesh_new_translate_vertices_to_attributes(tvertices, vertices, attr_vertices, num_vertices) + @ccall libt8.t8_cmesh_new_translate_vertices_to_attributes(tvertices::Ptr{t8_locidx_t}, vertices::Ptr{Cdouble}, attr_vertices::Ptr{Cdouble}, num_vertices::Cint)::Cvoid end """ - sc_statistics_compute(stats) - -Compute statistics for all variables, see [`sc_stats_compute`](@ref). + t8_cmesh_debug_print_trees(cmesh, comm) ### Prototype ```c -void sc_statistics_compute (sc_statistics_t * stats); +void t8_cmesh_debug_print_trees (const t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function sc_statistics_compute(stats) - @ccall libsc.sc_statistics_compute(stats::Ptr{sc_statistics_t})::Cvoid +function t8_cmesh_debug_print_trees(cmesh, comm) + @ccall libt8.t8_cmesh_debug_print_trees(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - sc_statistics_print(stats, package_id, log_priority, full, summary) + t8_cmesh_get_local_bounding_box(cmesh, bounds) -Print all statistics variables, see [`sc_stats_print`](@ref). +Compute the process local bounding box of the cmesh. The bounding box is stored in the array *bounds* in the following order: bounds[0] = x\\_min bounds[1] = x\\_max bounds[2] = y\\_min bounds[3] = y\\_max bounds[4] = z\\_min bounds[5] = z\\_max +# Arguments +* `cmesh`:\\[in\\] The cmesh to be considered. +* `bounds`:\\[out\\] The bounding box of the cmesh. If the box is flat (for quads for example, z\\_min == z\\_max) +# Returns +True if the computation was successful, false if the cmesh is empty. ### Prototype ```c -void sc_statistics_print (sc_statistics_t * stats, int package_id, int log_priority, int full, int summary); +int t8_cmesh_get_local_bounding_box (const t8_cmesh_t cmesh, double bounds[6]); ``` """ -function sc_statistics_print(stats, package_id, log_priority, full, summary) - @ccall libsc.sc_statistics_print(stats::Ptr{sc_statistics_t}, package_id::Cint, log_priority::Cint, full::Cint, summary::Cint)::Cvoid +function t8_cmesh_get_local_bounding_box(cmesh, bounds) + @ccall libt8.t8_cmesh_get_local_bounding_box(cmesh::t8_cmesh_t, bounds::Ptr{Cdouble})::Cint end -mutable struct sc_options end - -"""The options data structure is opaque.""" -const sc_options_t = sc_options - -# typedef int ( * sc_options_callback_t ) ( sc_options_t * opt , const char * opt_arg , void * data ) -""" -This callback can be invoked with sc_options_parse. - -# Arguments -* `opt`:\\[in\\] Valid options data structure. This is passed as a matter of principle. -* `opt_arg`:\\[in\\] The option argument or NULL if there is none. This variable is internal. Do not store pointer. -* `data`:\\[in\\] User-defined data passed to [`sc_options_add_callback`](@ref). -# Returns -Return 0 if successful, -1 to indicate a parse error. -""" -const sc_options_callback_t = Ptr{Cvoid} - """ - sc_options_new(program_path) - -Create an empty options structure. + sc_io_read(mpifile, ptr, zcount, t, errmsg) -# Arguments -* `program_path`:\\[in\\] Name or path name of the program to display. Usually argv[0] is fine. -# Returns -A valid and empty options structure. ### Prototype ```c -sc_options_t *sc_options_new (const char *program_path); +void sc_io_read (sc_MPI_File mpifile, void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); ``` """ -function sc_options_new(program_path) - @ccall libsc.sc_options_new(program_path::Cstring)::Ptr{sc_options_t} +function sc_io_read(mpifile, ptr, zcount, t, errmsg) + @ccall libt8.sc_io_read(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid end """ - sc_options_destroy_deep(opt) - -Destroy the options structure and all allocated structures contained. The keyvalue structure passed into sc\\_keyvalue\\_add is destroyed. - -!!! compat "Deprecated" - - This function is kept for backwards compatibility. It is best to destroy any key-value container outside of the lifetime of the options object. + sc_io_write(mpifile, ptr, zcount, t, errmsg) -# Arguments -* `opt`:\\[in,out\\] This options structure is deallocated, including all key-value containers referenced. ### Prototype ```c -void sc_options_destroy_deep (sc_options_t * opt); +void sc_io_write (sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); ``` """ -function sc_options_destroy_deep(opt) - @ccall libsc.sc_options_destroy_deep(opt::Ptr{sc_options_t})::Cvoid +function sc_io_write(mpifile, ptr, zcount, t, errmsg) + @ccall libt8.sc_io_write(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::Cint, errmsg::Cstring)::Cvoid end +"""Typedef for quadrant coordinates.""" +const p4est_qcoord_t = Int32 + +"""Typedef for counting topological entities (trees, tree vertices).""" +const p4est_topidx_t = Int32 + +"""Typedef for processor-local indexing of quadrants and nodes.""" +const p4est_locidx_t = Int32 + +"""Typedef for globally unique indexing of quadrants.""" +const p4est_gloidx_t = Int64 + """ - sc_options_destroy(opt) + sc_io_error_t -Destroy the options structure. Whatever has been passed into sc\\_keyvalue\\_add is left alone. +Error values for io. -# Arguments -* `opt`:\\[in,out\\] This options structure is deallocated. -### Prototype -```c -void sc_options_destroy (sc_options_t * opt); -``` +| Enumerator | Note | +| :---------------------- | :--------------------------------------------------------------------------- | +| SC\\_IO\\_ERROR\\_NONE | The value of zero means no error. | +| SC\\_IO\\_ERROR\\_FATAL | The io object is now dysfunctional. | +| SC\\_IO\\_ERROR\\_AGAIN | Another io operation may resolve it. The function just returned was a noop. | """ -function sc_options_destroy(opt) - @ccall libsc.sc_options_destroy(opt::Ptr{sc_options_t})::Cvoid +@cenum sc_io_error_t::Int32 begin + SC_IO_ERROR_NONE = 0 + SC_IO_ERROR_FATAL = -1 + SC_IO_ERROR_AGAIN = -2 end """ - sc_options_set_spacing(opt, space_type, space_help) + sc_io_mode_t -Set the spacing for sc_options_print_summary. There are two values to be set: the spacing from the beginning of the printed line to the type of the option variable, and from the beginning of the printed line to the help string. +The I/O mode for writing using sc_io_sink. -# Arguments -* `opt`:\\[in,out\\] Valid options structure. -* `space_type`:\\[in\\] Number of spaces to the type display, for example , , etc. Setting this negative sets the default 20. -* `space_help`:\\[in\\] Number of space to the help string. Setting this negative sets the default 32. -### Prototype -```c -void sc_options_set_spacing (sc_options_t * opt, int space_type, int space_help); -``` +| Enumerator | Note | +| :---------------------- | :--------------------------- | +| SC\\_IO\\_MODE\\_WRITE | Semantics as "w" in fopen. | +| SC\\_IO\\_MODE\\_APPEND | Semantics as "a" in fopen. | +| SC\\_IO\\_MODE\\_LAST | Invalid entry to close list | """ -function sc_options_set_spacing(opt, space_type, space_help) - @ccall libsc.sc_options_set_spacing(opt::Ptr{sc_options_t}, space_type::Cint, space_help::Cint)::Cvoid +@cenum sc_io_mode_t::UInt32 begin + SC_IO_MODE_WRITE = 0 + SC_IO_MODE_APPEND = 1 + SC_IO_MODE_LAST = 2 end """ - sc_options_add_switch(opt, opt_char, opt_name, variable, help_string) + sc_io_encode_t -Add a switch option. This option is used without option arguments. Every use increments the variable by one. Its initial value is 0. Either opt\\_char or opt\\_name must be valid, that is, not '\\0'/NULL. +Enum to specify encoding for sc_io_sink and sc_io_source. -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. -### Prototype -```c -void sc_options_add_switch (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, const char *help_string); -``` +| Enumerator | Note | +| :---------------------- | :--------------------------- | +| SC\\_IO\\_ENCODE\\_NONE | No encoding | +| SC\\_IO\\_ENCODE\\_LAST | Invalid entry to close list | """ -function sc_options_add_switch(opt, opt_char, opt_name, variable, help_string) - @ccall libsc.sc_options_add_switch(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, help_string::Cstring)::Cvoid +@cenum sc_io_encode_t::UInt32 begin + SC_IO_ENCODE_NONE = 0 + SC_IO_ENCODE_LAST = 1 end """ - sc_options_add_bool(opt, opt_char, opt_name, variable, init_value, help_string) + sc_io_type_t -Add a boolean option. It can be initialized to true or false in the C sense. Specifying it on the command line without argument sets the option to true. The argument 0/f/F/n/N sets it to false (0). The argument 1/t/T/y/Y sets it to true (nonzero). +The type of I/O operation sc_io_sink and sc_io_source. -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] Initial value to set the option, read as true or false. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. -### Prototype -```c -void sc_options_add_bool (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string); -``` +| Enumerator | Note | +| :------------------------ | :------------------------------- | +| SC\\_IO\\_TYPE\\_BUFFER | Write to a buffer | +| SC\\_IO\\_TYPE\\_FILENAME | Write to a file to be opened | +| SC\\_IO\\_TYPE\\_FILEFILE | Write to an already opened file | +| SC\\_IO\\_TYPE\\_LAST | Invalid entry to close list | """ -function sc_options_add_bool(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_bool(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cint, help_string::Cstring)::Cvoid +@cenum sc_io_type_t::UInt32 begin + SC_IO_TYPE_BUFFER = 0 + SC_IO_TYPE_FILENAME = 1 + SC_IO_TYPE_FILEFILE = 2 + SC_IO_TYPE_LAST = 3 end """ - sc_options_add_int(opt, opt_char, opt_name, variable, init_value, help_string) + sc_io_sink -Add an option that takes an integer argument. +A generic data sink. -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] The initial value of the option variable. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. -### Prototype -```c -void sc_options_add_int (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string); -``` +| Field | Note | +| :------------- | :---------------------------------------------------- | +| iotype | type of the I/O operation | +| mode | write semantics | +| encode | encoding of data | +| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | +| buffer\\_bytes | distinguish from array elements | +| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | +| bytes\\_in | input bytes count | +| bytes\\_out | written bytes count | +| is\\_eof | Have we reached the end of file? | """ -function sc_options_add_int(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_int(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cint, help_string::Cstring)::Cvoid +struct sc_io_sink + iotype::sc_io_type_t + mode::sc_io_mode_t + encode::sc_io_encode_t + buffer::Ptr{sc_array_t} + buffer_bytes::Csize_t + file::Ptr{Libc.FILE} + bytes_in::Csize_t + bytes_out::Csize_t + is_eof::Cint end +"""A generic data sink.""" +const sc_io_sink_t = sc_io_sink + """ - sc_options_add_size_t(opt, opt_char, opt_name, variable, init_value, help_string) + sc_io_source -Add an option that takes a size\\_t argument. The value of the size\\_t variable must not be greater than LLONG\\_MAX. +A generic data source. -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] The initial value of the option variable. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. -### Prototype -```c -void sc_options_add_size_t (sc_options_t * opt, int opt_char, const char *opt_name, size_t *variable, size_t init_value, const char *help_string); -``` +| 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 sc_options_add_size_t(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_size_t(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Csize_t}, init_value::Csize_t, help_string::Cstring)::Cvoid +struct sc_io_source + iotype::sc_io_type_t + encode::sc_io_encode_t + buffer::Ptr{sc_array_t} + buffer_bytes::Csize_t + file::Ptr{Libc.FILE} + bytes_in::Csize_t + bytes_out::Csize_t + is_eof::Cint + mirror::Ptr{sc_io_sink_t} + mirror_buffer::Ptr{sc_array_t} end +"""A generic data source.""" +const sc_io_source_t = sc_io_source + """ - sc_options_add_double(opt, opt_char, opt_name, variable, init_value, help_string) + sc_io_open_mode_t -Add an option that takes a double argument. The double must be in the legal range. "inf" and "nan" are legal too. +Open modes for sc_io_open -# Arguments -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] The initial value of the option variable. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. -### Prototype -```c -void sc_options_add_double (sc_options_t * opt, int opt_char, const char *opt_name, double *variable, double init_value, const char *help_string); -``` +| 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 sc_options_add_double(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_double(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cdouble}, init_value::Cdouble, help_string::Cstring)::Cvoid +@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(libt8.sc_io_sink_new(iotype::Cint, iomode::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_sink_t})) + end + """ - sc_options_add_string(opt, opt_char, opt_name, variable, init_value, help_string) + sc_io_sink_destroy(sink) -Add a string option. +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 -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `variable`:\\[in\\] Address of the variable to store the option value. -* `init_value`:\\[in\\] This default value of the option may be NULL. If not NULL, the value is copied to internal storage. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. +* `sink`:\\[in,out\\] The sink object to complete and free. +# Returns +0 on success, nonzero on error. ### Prototype ```c -void sc_options_add_string (sc_options_t * opt, int opt_char, const char *opt_name, const char **variable, const char *init_value, const char *help_string); +int sc_io_sink_destroy (sc_io_sink_t * sink); ``` """ -function sc_options_add_string(opt, opt_char, opt_name, variable, init_value, help_string) - @ccall libsc.sc_options_add_string(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cstring}, init_value::Cstring, help_string::Cstring)::Cvoid +function sc_io_sink_destroy(sink) + @ccall libt8.sc_io_sink_destroy(sink::Ptr{sc_io_sink_t})::Cint end """ - sc_options_add_inifile(opt, opt_char, opt_name, help_string) + sc_io_sink_destroy_null(sink) -Add an option to read in a file in `.ini` format. The argument to this option must be a filename. On parsing the specified file is read to set known option variables. It does not have an associated option variable itself. +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 -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. +* `sink`:\\[in,out\\] Non-NULL pointer to sink pointer. The sink pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_sink, which is passed to sc_io_sink_destroy, and the sink pointer is set to NULL afterwards. +# Returns +0 on success, nonzero on error. ### Prototype ```c -void sc_options_add_inifile (sc_options_t * opt, int opt_char, const char *opt_name, const char *help_string); +int sc_io_sink_destroy_null (sc_io_sink_t ** sink); ``` """ -function sc_options_add_inifile(opt, opt_char, opt_name, help_string) - @ccall libsc.sc_options_add_inifile(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, help_string::Cstring)::Cvoid +function sc_io_sink_destroy_null(sink) + @ccall libt8.sc_io_sink_destroy_null(sink::Ptr{Ptr{sc_io_sink_t}})::Cint end """ - sc_options_add_jsonfile(opt, opt_char, opt_name, help_string) - -Add an option to read in a file in JSON format. The argument to this option must be a filename. On parsing the specified file is read to set known option variables. It does not have an associated option variable itself. + sc_io_sink_write(sink, data, bytes_avail) -This functionality is only active when sc_have_json returns true, equivalent to the define SC\\_HAVE\\_JSON existing, and ignored otherwise. +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 -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. +* `sink`:\\[in,out\\] The sink object to write to. +* `data`:\\[in\\] Data passed into sink must be non-NULL. +* `bytes_avail`:\\[in\\] Number of data bytes passed in. +# Returns +0 on success, nonzero on error. ### Prototype ```c -void sc_options_add_jsonfile (sc_options_t * opt, int opt_char, const char *opt_name, const char *help_string); +int sc_io_sink_write (sc_io_sink_t * sink, const void *data, size_t bytes_avail); ``` """ -function sc_options_add_jsonfile(opt, opt_char, opt_name, help_string) - @ccall libsc.sc_options_add_jsonfile(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, help_string::Cstring)::Cvoid +function sc_io_sink_write(sink, data, bytes_avail) + @ccall libt8.sc_io_sink_write(sink::Ptr{sc_io_sink_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t)::Cint end """ - sc_options_add_callback(opt, opt_char, opt_name, has_arg, fn, data, help_string) + sc_io_sink_complete(sink, bytes_in, bytes_out) -Add an option that calls a user-defined function when parsed. The callback function should be implemented to allow multiple calls. The callback may be used to set multiple option variables in bulk that would otherwise require an inconvenient number of individual options. This option is not loaded from or saved to files. +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 -* `opt`:\\[in,out\\] A valid options structure. -* `opt_char`:\\[in\\] Short option character, may be '\\0'. -* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. -* `has_arg`:\\[in\\] Specify whether the option needs an option argument. This can be 0 for none, 1 for a required argument, and 2 for an optional argument; see getopt\\_long (3). -* `fn`:\\[in\\] Function to call when this option is encountered. -* `data`:\\[in\\] User-defined data passed to the callback. -* `help_string`:\\[in\\] Help string for usage message, may be NULL. +* `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 -void sc_options_add_callback (sc_options_t * opt, int opt_char, const char *opt_name, int has_arg, sc_options_callback_t fn, void *data, const char *help_string); +int sc_io_sink_complete (sc_io_sink_t * sink, size_t *bytes_in, size_t *bytes_out); ``` """ -function sc_options_add_callback(opt, opt_char, opt_name, has_arg, fn, data, help_string) - @ccall libsc.sc_options_add_callback(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, has_arg::Cint, fn::sc_options_callback_t, data::Ptr{Cvoid}, help_string::Cstring)::Cvoid +function sc_io_sink_complete(sink, bytes_in, bytes_out) + @ccall libt8.sc_io_sink_complete(sink::Ptr{sc_io_sink_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint end """ - sc_options_add_keyvalue(opt, opt_char, opt_name, variable, init_value, keyvalue, help_string) + sc_io_sink_align(sink, bytes_align) -Add an option that takes string keys into a lookup table of integers. On calling this function, it must be certain that the initial value exists. +Align sink to a byte boundary by writing zeros. # Arguments -* `opt`:\\[in\\] Initialized options structure. -* `opt_char`:\\[in\\] Option character for command line, or 0. -* `opt_name`:\\[in\\] Name of the long option, or NULL. -* `variable`:\\[in\\] Address of an existing integer that holds the value of this option parameter. -* `init_value`:\\[in\\] The key that is looked up for the initial value. It must be certain that the key exists and its value is of type integer. -* `keyvalue`:\\[in\\] A valid key-value structure where the values must be integers. If a key is asked for that does not exist, we will produce an option error. This structure must stay alive as long as opt. -* `help_string`:\\[in\\] Instructive one-line string to explain the option. +* `sink`:\\[in,out\\] The sink object to align. +* `bytes_align`:\\[in\\] Byte boundary. +# Returns +0 on success, nonzero on error. ### Prototype ```c +int sc_io_sink_align (sc_io_sink_t * sink, size_t bytes_align); ``` """ -function sc_options_add_keyvalue(opt, opt_char, opt_name, variable, init_value, keyvalue, help_string) +function sc_io_sink_align(sink, bytes_align) + @ccall libt8.sc_io_sink_align(sink::Ptr{sc_io_sink_t}, bytes_align::Csize_t)::Cint end +# automatic type deduction for variadic arguments may not be what you want, please use with caution +@generated function sc_io_source_new(iotype, ioencode, va_list...) + :(@ccall(libt8.sc_io_source_new(iotype::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_source_t})) + end + """ - sc_options_add_suboptions(opt, subopt, prefix) + sc_io_source_destroy(source) -Copy one set of options to another as a subset, with a prefix. The variables referenced by the options and the suboptions are the same. +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 -* `opt`:\\[in,out\\] A set of options. -* `subopt`:\\[in\\] Another set of options to be copied. -* `prefix`:\\[in\\] The prefix to add to option names as they are copied. If an option has a long name "name" in subopt, its name in opt is "prefix:name"; if an option only has a character 'c' in subopt, its name in opt is "prefix:-c". +* `source`:\\[in,out\\] The source object to free. +# Returns +0 on success. Nonzero if an error is encountered or is\\_complete returns one. ### Prototype ```c -void sc_options_add_suboptions (sc_options_t * opt, sc_options_t * subopt, const char *prefix); +int sc_io_source_destroy (sc_io_source_t * source); ``` """ -function sc_options_add_suboptions(opt, subopt, prefix) - @ccall libsc.sc_options_add_suboptions(opt::Ptr{sc_options_t}, subopt::Ptr{sc_options_t}, prefix::Cstring)::Cvoid +function sc_io_source_destroy(source) + @ccall libt8.sc_io_source_destroy(source::Ptr{sc_io_source_t})::Cint end """ - sc_options_print_usage(package_id, log_priority, opt, arg_usage) + sc_io_source_destroy_null(source) -Print a usage message. This function uses the `SC_LC_GLOBAL` log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. +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 -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Priority for output according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `arg_usage`:\\[in\\] If not NULL, an string is appended to the usage line. If the string is non-empty, it will be printed after the option summary and an "ARGUMENTS:\\n" title line. Line breaks are identified by strtok(3) and honored. +* `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 -void sc_options_print_usage (int package_id, int log_priority, sc_options_t * opt, const char *arg_usage); +int sc_io_source_destroy_null (sc_io_source_t ** source); ``` """ -function sc_options_print_usage(package_id, log_priority, opt, arg_usage) - @ccall libsc.sc_options_print_usage(package_id::Cint, log_priority::Cint, opt::Ptr{sc_options_t}, arg_usage::Cstring)::Cvoid +function sc_io_source_destroy_null(source) + @ccall libt8.sc_io_source_destroy_null(source::Ptr{Ptr{sc_io_source_t}})::Cint end """ - sc_options_print_summary(package_id, log_priority, opt) + sc_io_source_read(source, data, bytes_avail, bytes_out) -Print a summary of all option values. Prints the title "Options:" and a line for every option, then the title "Arguments:" and a line for every argument. This function uses the `SC_LC_GLOBAL` log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. +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 -* `package_id`:\\[in\\] Registered package id or -1. -* `log_priority`:\\[in\\] Priority for output according to sc_logprios. -* `opt`:\\[in\\] The option structure. +* `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 -void sc_options_print_summary (int package_id, int log_priority, sc_options_t * opt); +int sc_io_source_read (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); ``` """ -function sc_options_print_summary(package_id, log_priority, opt) - @ccall libsc.sc_options_print_summary(package_id::Cint, log_priority::Cint, opt::Ptr{sc_options_t})::Cvoid +function sc_io_source_read(source, data, bytes_avail, bytes_out) + @ccall libt8.sc_io_source_read(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint end """ - sc_options_load(package_id, err_priority, opt, file) + sc_io_source_complete(source, bytes_in, bytes_out) -Load a file in the default format and update option values. The default is a file in the `.ini` format; see sc_options_load_ini. +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 -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `file`:\\[in\\] Filename of the file to load. +* `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 -Returns 0 on success, -1 on failure. +SC\\_IO\\_ERROR\\_AGAIN if buffered data remaining. Otherwise return ERROR\\_NONE and reset counters. ### Prototype ```c -int sc_options_load (int package_id, int err_priority, sc_options_t * opt, const char *file); +int sc_io_source_complete (sc_io_source_t * source, size_t *bytes_in, size_t *bytes_out); ``` """ -function sc_options_load(package_id, err_priority, opt, file) - @ccall libsc.sc_options_load(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, file::Cstring)::Cint +function sc_io_source_complete(source, bytes_in, bytes_out) + @ccall libt8.sc_io_source_complete(source::Ptr{sc_io_source_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint end """ - sc_options_load_ini(package_id, err_priority, opt, inifile, re) + sc_io_source_align(source, bytes_align) -Load a file in `.ini` format and update entries found under [Options]. An option whose name contains a colon such as "prefix:basename" will be updated by a "basename =" entry in a [prefix] section. +Align source to a byte boundary by skipping. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `inifile`:\\[in\\] Filename of the ini file to load. -* `re`:\\[in,out\\] Provisioned for runtime error checking implementation; currently must be NULL. +* `source`:\\[in,out\\] The source object to align. +* `bytes_align`:\\[in\\] Byte boundary. # Returns -Returns 0 on success, -1 on failure. +0 on success, nonzero on error. ### Prototype ```c -int sc_options_load_ini (int package_id, int err_priority, sc_options_t * opt, const char *inifile, void *re); +int sc_io_source_align (sc_io_source_t * source, size_t bytes_align); ``` """ -function sc_options_load_ini(package_id, err_priority, opt, inifile, re) - @ccall libsc.sc_options_load_ini(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring, re::Ptr{Cvoid})::Cint +function sc_io_source_align(source, bytes_align) + @ccall libt8.sc_io_source_align(source::Ptr{sc_io_source_t}, bytes_align::Csize_t)::Cint end """ - sc_options_load_json(package_id, err_priority, opt, jsonfile, re) + sc_io_source_activate_mirror(source) -Load a file in JSON format and update entries from object "Options". An option whose name contains a colon such as "Prefix:basename" will be updated by a "basename :" entry in a "Prefix" nested object. +Activate a buffer that mirrors (i.e., stores) the data that was read. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `jsonfile`:\\[in\\] Filename of the JSON file to load. -* `re`:\\[in,out\\] Provisioned for runtime error checking implementation; currently must be NULL. +* `source`:\\[in,out\\] The source object to activate mirror in. # Returns -Returns 0 on success, -1 on failure. +0 on success, nonzero on error. ### Prototype ```c -int sc_options_load_json (int package_id, int err_priority, sc_options_t * opt, const char *jsonfile, void *re); +int sc_io_source_activate_mirror (sc_io_source_t * source); ``` """ -function sc_options_load_json(package_id, err_priority, opt, jsonfile, re) - @ccall libsc.sc_options_load_json(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, jsonfile::Cstring, re::Ptr{Cvoid})::Cint +function sc_io_source_activate_mirror(source) + @ccall libt8.sc_io_source_activate_mirror(source::Ptr{sc_io_source_t})::Cint end """ - sc_options_save(package_id, err_priority, opt, inifile) + sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) -Save all options and arguments to a file in `.ini` format. This function must only be called after successful option parsing. This function should only be called on rank 0. This function will log errors with category `SC_LC_GLOBAL`. An options whose name contains a colon such as "Prefix:basename" will be written in a section titled [Prefix] as "basename =". +Read data from the source's mirror. Same behaviour as [`sc_io_source_read`](@ref). # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `inifile`:\\[in\\] Filename of the ini file to save. +* `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 -Returns 0 on success, -1 on failure. +0 on success, nonzero on error. ### Prototype ```c -int sc_options_save (int package_id, int err_priority, sc_options_t * opt, const char *inifile); +int sc_io_source_read_mirror (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); ``` """ -function sc_options_save(package_id, err_priority, opt, inifile) - @ccall libsc.sc_options_save(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring)::Cint +function sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) + @ccall libt8.sc_io_source_read_mirror(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint end """ - sc_options_load_args(package_id, err_priority, opt, inifile) + sc_io_file_save(filename, buffer) -Load a file in `.ini` format and update entries found under [Arguments]. There needs to be a key Arguments.count specifying the number. Then as many integer keys starting with 0 need to be present. +Save a buffer to a file in one call. This function performs error checking and always returns cleanly. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The args are stored in this option structure. -* `inifile`:\\[in\\] Filename of the ini file to load. +* `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 -Returns 0 on success, -1 on failure. +0 on success, -1 on error. ### Prototype ```c -int sc_options_load_args (int package_id, int err_priority, sc_options_t * opt, const char *inifile); +int sc_io_file_save (const char *filename, sc_array_t * buffer); ``` """ -function sc_options_load_args(package_id, err_priority, opt, inifile) - @ccall libsc.sc_options_load_args(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring)::Cint +function sc_io_file_save(filename, buffer) + @ccall libt8.sc_io_file_save(filename::Cstring, buffer::Ptr{sc_array_t})::Cint end """ - sc_options_parse(package_id, err_priority, opt, argc, argv) + sc_io_file_load(filename, buffer) -Parse command line options. +Read a file into a buffer in one call. This function performs error checking and always returns cleanly. # Arguments -* `package_id`:\\[in\\] Registered package id or -1. -* `err_priority`:\\[in\\] Error priority according to sc_logprios. -* `opt`:\\[in\\] The option structure. -* `argc`:\\[in\\] Length of argument list. -* `argv`:\\[in,out\\] Argument list may be permuted. +* `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 -Returns -1 on an invalid option, otherwise the position of the first non-option argument. +0 on success, -1 on error. ### Prototype ```c -int sc_options_parse (int package_id, int err_priority, sc_options_t * opt, int argc, char **argv); +int sc_io_file_load (const char *filename, sc_array_t * buffer); ``` """ -function sc_options_parse(package_id, err_priority, opt, argc, argv) - @ccall libsc.sc_options_parse(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, argc::Cint, argv::Ptr{Cstring})::Cint +function sc_io_file_load(filename, buffer) + @ccall libt8.sc_io_file_load(filename::Cstring, buffer::Ptr{sc_array_t})::Cint end """ - t8_cmesh_from_tetgen_file(fileprefix, partition, comm, do_dup) + sc_io_encode(data, out) -### Prototype -```c -t8_cmesh_t t8_cmesh_from_tetgen_file (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup); -``` -""" -function t8_cmesh_from_tetgen_file(fileprefix, partition, comm, do_dup) - @ccall libt8.t8_cmesh_from_tetgen_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint)::t8_cmesh_t -end +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. -""" - t8_cmesh_from_tetgen_file_time(fileprefix, partition, comm, do_dup, fi, snapshot, stats, statentry) +Currently this function calls sc_io_encode_zlib with compression level Z\\_BEST\\_COMPRESSION (subject to change). Without zlib configured that function works uncompressed. + +The encoding method and input data size can be retrieved, optionally, from the encoded data by sc_io_decode_info. This function decodes the method as a character, which is 'z' for sc_io_encode_zlib. We reserve the characters A-C, d-z indefinitely. +# Arguments +* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. +* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. ### Prototype ```c -t8_cmesh_t t8_cmesh_from_tetgen_file_time (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup, sc_flopinfo_t *fi, sc_flopinfo_t *snapshot, sc_statinfo_t *stats, int statentry); +void sc_io_encode (sc_array_t *data, sc_array_t *out); ``` """ -function t8_cmesh_from_tetgen_file_time(fileprefix, partition, comm, do_dup, fi, snapshot, stats, statentry) - @ccall libt8.t8_cmesh_from_tetgen_file_time(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint, fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t}, stats::Ptr{sc_statinfo_t}, statentry::Cint)::t8_cmesh_t +function sc_io_encode(data, out) + @ccall libt8.sc_io_encode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t})::Cvoid end """ - t8_cmesh_from_triangle_file(fileprefix, partition, comm, do_dup) + sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) + +Encode a block of arbitrary data, compressed, into an ASCII string. This is a two-stage process: zlib compress and then encode to base 64. The output is a NUL-terminated string of printable characters. +We first compress the data into the zlib deflate format (RFC 1951). The compressor must use no preset dictionary (this is the default). If zlib is detected on configuration, we compress with the given level. If zlib is not detected, we write data equivalent to Z\\_NO\\_COMPRESSION. The status of zlib detection can be queried at compile time using #ifdef [`SC_HAVE_ZLIB`](@ref) or at run time using sc_have_zlib. Both types of result are readable by a standard zlib uncompress call. + +Secondly, we process the input data size as an 8-byte big-endian number, then the letter 'z', and then the zlib compressed data, concatenated, with a base 64 encoder. We break lines after 76 code characters. Each line break consists of two configurable but arbitrary bytes. The line breaks are considered part of the output data specification. The last line is terminated with the same line break and then a NUL. + +This routine can work in place or write to an output array. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. + +# Arguments +* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. +* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. +* `zlib_compression_level`:\\[in\\] Compression level between 0 (no compression) and 9 (best compression). The value -1 indicates some default level. +* `line_break_character`:\\[in\\] This character is arbitrary and specifies the first of two line break bytes. The second byte is always ''. ### Prototype ```c -t8_cmesh_t t8_cmesh_from_triangle_file (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup); +void sc_io_encode_zlib (sc_array_t *data, sc_array_t *out, int zlib_compression_level, int line_break_character); ``` """ -function t8_cmesh_from_triangle_file(fileprefix, partition, comm, do_dup) - @ccall libt8.t8_cmesh_from_triangle_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint)::t8_cmesh_t +function sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) + @ccall libt8.sc_io_encode_zlib(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, zlib_compression_level::Cint, line_break_character::Cint)::Cvoid end """ - t8_eclass_count_boundary(theclass, min_dim, per_eclass) + sc_io_decode_info(data, original_size, format_char, re) -Query the element class and count of boundary points. +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 -* `theclass`:\\[in\\] We query a point of this element class. -* `min_dim`:\\[in\\] Ignore boundary points of lesser dimension. The ignored points get a count value of 0. -* `per_eclass`:\\[out\\] Array of length T8\\_ECLASS\\_COUNT to be filled with the count of the boundary objects, counted per each of the element classes. +* `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 count over all boundary points. +0 on success, negative value on error. ### Prototype ```c -int t8_eclass_count_boundary (t8_eclass_t theclass, int min_dim, int *per_eclass); +int sc_io_decode_info (sc_array_t *data, size_t *original_size, char *format_char, void *re); ``` """ -function t8_eclass_count_boundary(theclass, min_dim, per_eclass) - @ccall libt8.t8_eclass_count_boundary(theclass::t8_eclass_t, min_dim::Cint, per_eclass::Ptr{Cint})::Cint +function sc_io_decode_info(data, original_size, format_char, re) + @ccall libt8.sc_io_decode_info(data::Ptr{sc_array_t}, original_size::Ptr{Csize_t}, format_char::Cstring, re::Ptr{Cvoid})::Cint end """ - t8_eclass_compare(eclass1, eclass2) + sc_io_decode(data, out, max_original_size, re) -Compare two eclasses of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. +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 -* `eclass1`:\\[in\\] The first eclass to compare. -* `eclass2`:\\[in\\] The second eclass to compare. +* `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 if the eclasses are equal, 1 if eclass1 > eclass2 and -1 if eclass1 < eclass2 +0 on success, negative on malformed input data or insufficient output space. ### Prototype ```c -int t8_eclass_compare (t8_eclass_t eclass1, t8_eclass_t eclass2); +int sc_io_decode (sc_array_t *data, sc_array_t *out, size_t max_original_size, void *re); ``` """ -function t8_eclass_compare(eclass1, eclass2) - @ccall libt8.t8_eclass_compare(eclass1::t8_eclass_t, eclass2::t8_eclass_t)::Cint +function sc_io_decode(data, out, max_original_size, re) + @ccall libt8.sc_io_decode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, max_original_size::Csize_t, re::Ptr{Cvoid})::Cint end """ - t8_eclass_is_valid(eclass) + sc_vtk_write_binary(vtkfile, numeric_data, byte_length) -Check whether a class is a valid class. Returns non-zero if it is a valid class, returns zero, if the class is equal to T8\\_ECLASS\\_INVALID. +This function writes numeric binary data in VTK base64 encoding. # Arguments -* `eclass`:\\[in\\] The eclass to check. +* `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 -Non-zero if *eclass* is valid, zero otherwise. +Returns 0 on success, -1 on file error. ### Prototype ```c -int t8_eclass_is_valid (t8_eclass_t eclass); +int sc_vtk_write_binary (FILE * vtkfile, char *numeric_data, size_t byte_length); ``` """ -function t8_eclass_is_valid(eclass) - @ccall libt8.t8_eclass_is_valid(eclass::t8_eclass_t)::Cint +function sc_vtk_write_binary(vtkfile, numeric_data, byte_length) + @ccall libt8.sc_vtk_write_binary(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint end -mutable struct t8_element end - -"""Opaque structure for a generic element, only used as pointer. Implementations are free to cast it to their internal data structure.""" -const t8_element_t = t8_element - """ - t8_scheme_cxx_ref(scheme) + sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) -Increase the reference counter of a scheme. +This function writes numeric binary data in VTK compressed format. # Arguments -* `scheme`:\\[in,out\\] On input, this scheme must be alive, that is, exist with positive reference count. +* `vtkfile`: Stream opened for writing. +* `numeric_data`: A pointer to a numeric data array. +* `byte_length`: The length of the data array in bytes. +# Returns +Returns 0 on success, -1 on file error. ### Prototype ```c -void t8_scheme_cxx_ref (t8_scheme_cxx_t *scheme); +int sc_vtk_write_compressed (FILE * vtkfile, char *numeric_data, size_t byte_length); ``` """ -function t8_scheme_cxx_ref(scheme) - @ccall libt8.t8_scheme_cxx_ref(scheme::Ptr{t8_scheme_cxx_t})::Cvoid +function sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) + @ccall libt8.sc_vtk_write_compressed(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint end """ - t8_scheme_cxx_unref(pscheme) + sc_fopen(filename, mode, errmsg) -Decrease the reference counter of a scheme. If the counter reaches zero, this scheme is destroyed. +Wrapper for fopen(3). We provide an additional argument that contains the error message. -# Arguments -* `pscheme`:\\[in,out\\] On input, the scheme pointed to must exist with positive reference count. If the reference count reaches zero, the scheme is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the scheme is not modified in other ways. ### Prototype ```c -void t8_scheme_cxx_unref (t8_scheme_cxx_t **pscheme); +FILE *sc_fopen (const char *filename, const char *mode, const char *errmsg); ``` """ -function t8_scheme_cxx_unref(pscheme) - @ccall libt8.t8_scheme_cxx_unref(pscheme::Ptr{Ptr{t8_scheme_cxx_t}})::Cvoid +function sc_fopen(filename, mode, errmsg) + @ccall libt8.sc_fopen(filename::Cstring, mode::Cstring, errmsg::Cstring)::Ptr{Libc.FILE} end """ - t8_scheme_cxx_destroy(s) + sc_fwrite(ptr, size, nmemb, file, errmsg) + +Write memory content to a file. + +!!! note + + This function aborts on file errors. +# Arguments +* `ptr`:\\[in\\] Data array to write to disk. +* `size`:\\[in\\] Size of one array member. +* `nmemb`:\\[in\\] Number of array members. +* `file`:\\[in,out\\] File pointer, must be opened for writing. +* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). ### Prototype ```c -extern void t8_scheme_cxx_destroy (t8_scheme_cxx_t *s); +void sc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); ``` """ -function t8_scheme_cxx_destroy(s) - @ccall libt8.t8_scheme_cxx_destroy(s::Ptr{t8_scheme_cxx_t})::Cvoid +function sc_fwrite(ptr, size, nmemb, file, errmsg) + @ccall libt8.sc_fwrite(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid end """ - t8_element_size(ts) + sc_fread(ptr, size, nmemb, file, errmsg) -Return the size of any element of a given class. +Read file content into memory. -# Returns -The size of an element of class **ts**. We provide a default implementation of this routine that should suffice for most use cases. +!!! note + + This function aborts on file errors. + +# Arguments +* `ptr`:\\[out\\] Data array to read from disk. +* `size`:\\[in\\] Size of one array member. +* `nmemb`:\\[in\\] Number of array members. +* `file`:\\[in,out\\] File pointer, must be opened for reading. +* `errmsg`:\\[in\\] Error message passed to [`SC_CHECK_ABORT`](@ref). ### Prototype ```c -size_t t8_element_size (const t8_eclass_scheme_c *ts); +void sc_fread (void *ptr, size_t size, size_t nmemb, FILE * file, const char *errmsg); ``` """ -function t8_element_size(ts) - @ccall libt8.t8_element_size(ts::Ptr{t8_eclass_scheme_c})::Csize_t +function sc_fread(ptr, size, nmemb, file, errmsg) + @ccall libt8.sc_fread(ptr::Ptr{Cvoid}, size::Csize_t, nmemb::Csize_t, file::Ptr{Libc.FILE}, errmsg::Cstring)::Cvoid end """ - t8_element_refines_irregular(ts) + sc_fflush_fsync_fclose(file) -Returns true, if there is one element in the tree, that does not refine into 2^dim children. Returns false otherwise. - -### Prototype -```c -int t8_element_refines_irregular (const t8_eclass_scheme_c *ts); -``` -""" -function t8_element_refines_irregular(ts) - @ccall libt8.t8_element_refines_irregular(ts::Ptr{t8_eclass_scheme_c})::Cint -end - -""" - t8_element_maxlevel(ts) - -Return the maximum allowed level for any element of a given class. +Best effort to flush a file's data to disc and close it. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -# Returns -The maximum allowed level for elements of class **ts**. +* `file`:\\[in,out\\] File open for writing. ### Prototype ```c -int t8_element_maxlevel (const t8_eclass_scheme_c *ts); +void sc_fflush_fsync_fclose (FILE * file); ``` """ -function t8_element_maxlevel(ts) - @ccall libt8.t8_element_maxlevel(ts::Ptr{t8_eclass_scheme_c})::Cint +function sc_fflush_fsync_fclose(file) + @ccall libt8.sc_fflush_fsync_fclose(file::Ptr{Libc.FILE})::Cvoid end """ - t8_element_level(ts, elem) + sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) ### Prototype ```c -int t8_element_level (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +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 t8_element_level(ts, elem) - @ccall libt8.t8_element_level(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function sc_io_open(mpicomm, filename, amode, mpiinfo, mpifile) + @ccall libt8.sc_io_open(mpicomm::MPI_Comm, filename::Cstring, amode::sc_io_open_mode_t, mpiinfo::Cint, mpifile::Ptr{Cint})::Cint end """ - t8_element_copy(ts, source, dest) - -Copy all entries of **source** to **dest**. **dest** must be an existing element. No memory is allocated by this function. - -!!! note - - *source* and *dest* may point to the same element. + sc_io_read_at(mpifile, offset, ptr, count, t, ocount) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `source`:\\[in\\] The element whose entries will be copied to **dest**. -* `dest`:\\[in,out\\] This element's entries will be overwritten with the entries of **source**. ### Prototype ```c -void t8_element_copy (const t8_eclass_scheme_c *ts, const t8_element_t *source, t8_element_t *dest); +int sc_io_read_at (sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount); ``` """ -function t8_element_copy(ts, source, dest) - @ccall libt8.t8_element_copy(ts::Ptr{t8_eclass_scheme_c}, source::Ptr{t8_element_t}, dest::Ptr{t8_element_t})::Cvoid +function sc_io_read_at(mpifile, offset, ptr, count, t, ocount) + @ccall libt8.sc_io_read_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint end """ - t8_element_compare(ts, elem1, elem2) - -Compare two elements with respect to the scheme. + sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem1`:\\[in\\] The first element. -* `elem2`:\\[in\\] The second element. -# Returns -negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. If elem2 is a copy of elem1 then the elements are equal. ### Prototype ```c -int t8_element_compare (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2); +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 t8_element_compare(ts, elem1, elem2) - @ccall libt8.t8_element_compare(ts::Ptr{t8_eclass_scheme_c}, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint +function sc_io_read_at_all(mpifile, offset, ptr, count, t, ocount) + @ccall libt8.sc_io_read_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint end """ - t8_element_equal(ts, elem1, elem2) - -Check if two elements are equal. + sc_io_write_at(mpifile, offset, ptr, count, t, ocount) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem1`:\\[in\\] The first element. -* `elem2`:\\[in\\] The second element. -# Returns -1 if the elements are equal, 0 if they are not equal ### Prototype ```c -int t8_element_equal (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2); +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 t8_element_equal(ts, elem1, elem2) - @ccall libt8.t8_element_equal(ts::Ptr{t8_eclass_scheme_c}, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint +function sc_io_write_at(mpifile, offset, ptr, count, t, ocount) + @ccall libt8.sc_io_write_at(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint end """ - t8_element_parent(ts, elem, parent) - -Compute the parent of a given element **elem** and store it in **parent**. **parent** needs to be an existing element. No memory is allocated by this function. **elem** and **parent** can point to the same element, then the entries of **elem** are overwritten by the ones of its parent. + sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element whose parent will be computed. -* `parent`:\\[in,out\\] This element's entries will be overwritten by those of **elem**'s parent. The storage for this element must exist and match the element class of the parent. ### Prototype ```c -void t8_element_parent (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *parent); +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 t8_element_parent(ts, elem, parent) - @ccall libt8.t8_element_parent(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, parent::Ptr{t8_element_t})::Cvoid +function sc_io_write_at_all(mpifile, offset, ptr, count, t, ocount) + @ccall libt8.sc_io_write_at_all(mpifile::MPI_File, offset::Cint, ptr::Ptr{Cvoid}, count::Cint, t::Cint, ocount::Ptr{Cint})::Cint end """ - t8_element_num_siblings(ts, elem) - -Compute the number of siblings of an element. That is the number of Children of its parent. + sc_io_close(file) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -# Returns -The number of siblings of *element*. Note that this number is >= 1, since we count the element itself as a sibling. ### Prototype ```c -int t8_element_num_siblings (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +int sc_io_close (sc_MPI_File * file); ``` """ -function t8_element_num_siblings(ts, elem) - @ccall libt8.t8_element_num_siblings(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function sc_io_close(file) + @ccall libt8.sc_io_close(file::Ptr{Cint})::Cint end """ - t8_element_sibling(ts, elem, sibid, sibling) - -Compute a specific sibling of a given element **elem** and store it in **sibling**. **sibling** needs to be an existing element. No memory is allocated by this function. **elem** and **sibling** can point to the same element, then the entries of **elem** are overwritten by the ones of its i-th sibling. + p4est_comm_tag -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element whose sibling will be computed. -* `sibid`:\\[in\\] The id of the sibling computed. -* `sibling`:\\[in,out\\] This element's entries will be overwritten by those of **elem**'s sibid-th sibling. The storage for this element must exist and match the element class of the sibling. -### Prototype -```c -void t8_element_sibling (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int sibid, t8_element_t *sibling); -``` +Tags for MPI messages """ -function t8_element_sibling(ts, elem, sibid, sibling) - @ccall libt8.t8_element_sibling(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, sibid::Cint, sibling::Ptr{t8_element_t})::Cvoid +@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 -""" - t8_element_num_corners(ts, elem) +"""Tags for MPI messages""" +const p4est_comm_tag_t = p4est_comm_tag -Compute the number of corners of an element. +""" + p4est_log_indent_push() -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -# Returns -The number of corners of *element*. ### Prototype ```c -int t8_element_num_corners (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +static inline void p4est_log_indent_push (void); ``` """ -function t8_element_num_corners(ts, elem) - @ccall libt8.t8_element_num_corners(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_log_indent_push() + @ccall libt8.p4est_log_indent_push()::Cvoid end """ - t8_element_num_faces(ts, elem) - -Compute the number of faces of an element. + p4est_log_indent_pop() -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -# Returns -The number of faces of *element*. ### Prototype ```c -int t8_element_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +static inline void p4est_log_indent_pop (void); ``` """ -function t8_element_num_faces(ts, elem) - @ccall libt8.t8_element_num_faces(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_log_indent_pop() + @ccall libt8.p4est_log_indent_pop()::Cvoid end """ - t8_element_max_num_faces(ts, elem) + p4est_init(log_handler, log_threshold) -Compute the maximum number of faces of a given element and all of its descendants. +Registers p4est with the SC Library and sets the logging behavior. This function is optional. This function must only be called before additional threads are created. If this function is not called or called with log\\_handler == NULL, the default SC log handler will be used. If this function is not called or called with log\\_threshold == [`SC_LP_DEFAULT`](@ref), the default SC log threshold will be used. The default SC log settings can be changed with [`sc_set_log_defaults`](@ref) (). -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -# Returns -The number of faces of *element*. ### Prototype ```c -int t8_element_max_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +void p4est_init (sc_log_handler_t log_handler, int log_threshold); ``` """ -function t8_element_max_num_faces(ts, elem) - @ccall libt8.t8_element_max_num_faces(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_init(log_handler, log_threshold) + @ccall libt8.p4est_init(log_handler::sc_log_handler_t, log_threshold::Cint)::Cvoid end """ - t8_element_num_children(ts, elem) + p4est_is_initialized() -Compute the number of children of an element when it is refined. +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. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. # Returns -The number of children of *element*. +True if p4est has been initialized with a call to p4est_init and false otherwise. ### Prototype ```c -int t8_element_num_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +int p4est_is_initialized (void); ``` """ -function t8_element_num_children(ts, elem) - @ccall libt8.t8_element_num_children(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_is_initialized() + @ccall libt8.p4est_is_initialized()::Cint end """ - t8_element_num_face_children(ts, elem, face) + p4est_have_zlib() -Compute the number of children of an element's face when the element is refined. +Check for a sufficiently recent zlib installation. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] A face of *elem*. # Returns -The number of children of *face* if *elem* is to be refined. +True if zlib is detected in both sc and p4est. ### Prototype ```c -int t8_element_num_face_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +int p4est_have_zlib (void); ``` """ -function t8_element_num_face_children(ts, elem, face) - @ccall libt8.t8_element_num_face_children(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::Cint +function p4est_have_zlib() + @ccall libt8.p4est_have_zlib()::Cint end """ - t8_element_get_face_corner(ts, elem, face, corner) - -Return the corner number of an element's face corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 Thus for face = 1 the output is: corner=0 : 1, corner=1: 3 + p4est_get_package_id() -The order in which the corners must be given is determined by the eclass of *element*: LINE/QUAD/TRIANGLE: No specific order. HEX : In Z-order of the face starting with the lowest corner number. TET : Starting with the lowest corner number counterclockwise as seen from 'outside' of the element. +Query the package identity as registered in libsc. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `element`:\\[in\\] The element. -* `face`:\\[in\\] A face index for *element*. -* `corner`:\\[in\\] A corner index for the face 0 <= *corner* < num\\_face\\_corners. # Returns -The corner number of the *corner*-th vertex of *face*. +This is -1 before p4est_init has been called and a proper package identifier (>= 0) afterwards. ### Prototype ```c -int t8_element_get_face_corner (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int corner); +int p4est_get_package_id (void); ``` """ -function t8_element_get_face_corner(ts, elem, face, corner) - @ccall libt8.t8_element_get_face_corner(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint, corner::Cint)::Cint +function p4est_get_package_id() + @ccall libt8.p4est_get_package_id()::Cint end """ - t8_element_get_corner_face(ts, elem, corner, face) - -Compute the face numbers of the faces sharing an element's corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 face 2 Thus for corner = 1 the output is: face=0 : 2, face=1: 1 + p4est_topidx_hash2(tt) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `element`:\\[in\\] The element. -* `corner`:\\[in\\] A corner index for the face. -* `face`:\\[in\\] A face index for *corner*. -# Returns -The face number of the *face*-th face at *corner*. ### Prototype ```c -int t8_element_get_corner_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int corner, int face); +static inline unsigned p4est_topidx_hash2 (const p4est_topidx_t * tt); ``` """ -function t8_element_get_corner_face(ts, elem, corner, face) - @ccall libt8.t8_element_get_corner_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, corner::Cint, face::Cint)::Cint +function p4est_topidx_hash2(tt) + @ccall libt8.p4est_topidx_hash2(tt::Ptr{p4est_topidx_t})::Cuint end """ - t8_element_child(ts, elem, childid, child) - -Construct the child element of a given number. + p4est_topidx_hash3(tt) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] This must be a valid element, bigger than maxlevel. -* `childid`:\\[in\\] The number of the child to construct. -* `child`:\\[in,out\\] The storage for this element must exist. On output, a valid element. It is valid to call this function with elem = child. ### Prototype ```c -void t8_element_child (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int childid, t8_element_t *child); +static inline unsigned p4est_topidx_hash3 (const p4est_topidx_t * tt); ``` """ -function t8_element_child(ts, elem, childid, child) - @ccall libt8.t8_element_child(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, childid::Cint, child::Ptr{t8_element_t})::Cvoid +function p4est_topidx_hash3(tt) + @ccall libt8.p4est_topidx_hash3(tt::Ptr{p4est_topidx_t})::Cuint end """ - t8_element_children(ts, elem, length, c) - -Construct all children of a given element. - -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] This must be a valid element, bigger than maxlevel. -* `length`:\\[in\\] The length of the output array *c* must match the number of children. -* `c`:\\[in,out\\] The storage for these *length* elements must exist and match the element class in the children's ordering. On output, all children are valid. It is valid to call this function with elem = c[0]. -# See also -[`t8_element_num_children`](@ref) + p4est_topidx_hash4(tt) ### Prototype ```c -void t8_element_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int length, t8_element_t *c[]); +static inline unsigned p4est_topidx_hash4 (const p4est_topidx_t * tt); ``` """ -function t8_element_children(ts, elem, length, c) - @ccall libt8.t8_element_children(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, length::Cint, c::Ptr{Ptr{t8_element_t}})::Cvoid +function p4est_topidx_hash4(tt) + @ccall libt8.p4est_topidx_hash4(tt::Ptr{p4est_topidx_t})::Cuint end """ - t8_element_child_id(ts, elem) - -Compute the child id of an element. + p4est_topidx_is_sorted(t, length) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] This must be a valid element. -# Returns -The child id of elem. ### Prototype ```c -int t8_element_child_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +static inline int p4est_topidx_is_sorted (p4est_topidx_t * t, int length); ``` """ -function t8_element_child_id(ts, elem) - @ccall libt8.t8_element_child_id(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cint +function p4est_topidx_is_sorted(t, length) + @ccall libt8.p4est_topidx_is_sorted(t::Ptr{p4est_topidx_t}, length::Cint)::Cint end """ - t8_element_ancestor_id(ts, elem, level) - -Compute the ancestor id of an element, that is the child id at a given level. + p4est_topidx_bsort(t, length) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] This must be a valid element. -* `level`:\\[in\\] A refinement level. Must satisfy *level* < elem.level -# Returns -The child\\_id of *elem* in regard to its *level* ancestor. ### Prototype ```c -int t8_element_ancestor_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int level); +static inline void p4est_topidx_bsort (p4est_topidx_t * t, int length); ``` """ -function t8_element_ancestor_id(ts, elem, level) - @ccall libt8.t8_element_ancestor_id(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, level::Cint)::Cint +function p4est_topidx_bsort(t, length) + @ccall libt8.p4est_topidx_bsort(t::Ptr{p4est_topidx_t}, length::Cint)::Cvoid end """ - t8_element_is_family(ts, fam) - -Query whether a given set of elements is a family or not. + p4est_partition_cut_uint64(global_num, p, num_procs) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `fam`:\\[in\\] An array of as many elements as an element of class **ts** has children. -# Returns -Zero if **fam** is not a family, nonzero if it is. ### Prototype ```c -int t8_element_is_family (const t8_eclass_scheme_c *ts, t8_element_t *const *fam); +static inline uint64_t p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs); ``` """ -function t8_element_is_family(ts, fam) - @ccall libt8.t8_element_is_family(ts::Ptr{t8_eclass_scheme_c}, fam::Ptr{Ptr{t8_element_t}})::Cint +function p4est_partition_cut_uint64(global_num, p, num_procs) + @ccall libt8.p4est_partition_cut_uint64(global_num::UInt64, p::Cint, num_procs::Cint)::UInt64 end """ - t8_element_nca(ts, elem1, elem2, nca) - -Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both given elements as descendants. + p4est_partition_cut_gloidx(global_num, p, num_procs) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem1`:\\[in\\] The first of the two input elements. -* `elem2`:\\[in\\] The second of the two input elements. -* `nca`:\\[in,out\\] The storage for this element must exist and match the element class of the child. On output the unique nearest common ancestor of **elem1** and **elem2**. ### Prototype ```c -void t8_element_nca (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca); +static inline p4est_gloidx_t p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs); ``` """ -function t8_element_nca(ts, elem1, elem2, nca) - @ccall libt8.t8_element_nca(ts::Ptr{t8_eclass_scheme_c}, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t}, nca::Ptr{t8_element_t})::Cvoid +function p4est_partition_cut_gloidx(global_num, p, num_procs) + @ccall libt8.p4est_partition_cut_gloidx(global_num::p4est_gloidx_t, p::Cint, num_procs::Cint)::p4est_gloidx_t end -"""Type definition for the geometric shape of an element. Currently the possible shapes are the same as the possible element classes. I.e. T8\\_ECLASS\\_VERTEX, T8\\_ECLASS\\_TET, etc...""" -const t8_element_shape_t = t8_eclass_t - """ - t8_element_face_shape(ts, elem, face) + p4est_version() -Compute the shape of the face of an element. +Return the full version of p4est. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] A face of *elem*. # Returns -The element shape of the face. I.e. T8\\_ECLASS\\_LINE for quads, T8\\_ECLASS\\_TRIANGLE for tets and depending on the face number either T8\\_ECLASS\\_QUAD or T8\\_ECLASS\\_TRIANGLE for prisms. +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 -t8_element_shape_t t8_element_face_shape (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +const char *p4est_version (void); ``` """ -function t8_element_face_shape(ts, elem, face) - @ccall libt8.t8_element_face_shape(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::t8_element_shape_t +function p4est_version() + @ccall libt8.p4est_version()::Cstring end """ - t8_element_children_at_face(ts, elem, face, children, num_children, child_indices) + p4est_version_major() -Given an element and a face of the element, compute all children of the element that touch the face. +Return the major version of p4est. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] A face of *elem*. -* `children`:\\[in,out\\] Allocated elements, in which the children of *elem* that share a face with *face* are stored. They will be stored in order of their linear id. -* `num_children`:\\[in\\] The number of elements in *children*. Must match the number of children that touch *face*. t8_element_num_face_children -* `child_indices`:\\[in,out\\] If not NULL, an array of num\\_children integers must be given, on output its i-th entry is the child\\_id of the i-th face\\_child. It is valid to call this function with elem = children[0]. +# Returns +Return the major version of p4est. ### Prototype ```c -void t8_element_children_at_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, t8_element_t *children[], int num_children, int *child_indices); +int p4est_version_major (void); ``` """ -function t8_element_children_at_face(ts, elem, face, children, num_children, child_indices) - @ccall libt8.t8_element_children_at_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint, children::Ptr{Ptr{t8_element_t}}, num_children::Cint, child_indices::Ptr{Cint})::Cvoid +function p4est_version_major() + @ccall libt8.p4est_version_major()::Cint end """ - t8_element_face_child_face(ts, elem, face, face_child) - -Given a face of an element and a child number of a child of that face, return the face number of the child of the element that matches the child face. + p4est_version_minor() -```c++ - x ---- x x x x ---- x - | | | | | | | <-- f - | | | x | x--x - | | | | | - x ---- x x x ---- x - elem face face_child Returns the face number f -``` +Return the minor version of p4est. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] Then number of the face. -* `face_child`:\\[in\\] A number 0 <= *face_child* < num\\_face\\_children, specifying a child of *elem* that shares a face with *face*. These children are counted in linear order. This coincides with the order of children from a call to t8_element_children_at_face. # Returns -The face number of the face of a child of *elem* that coincides with *face_child*. +Return the minor version of p4est. ### Prototype ```c -int t8_element_face_child_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int face_child); +int p4est_version_minor (void); ``` """ -function t8_element_face_child_face(ts, elem, face, face_child) - @ccall libt8.t8_element_face_child_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint, face_child::Cint)::Cint +function p4est_version_minor() + @ccall libt8.p4est_version_minor()::Cint end """ - t8_element_face_parent_face(ts, elem, face) - -Given a face of an element return the face number of the parent of the element that matches the element's face. Or return -1 if no face of the parent matches the face. + p4est_connect_type_t -!!! note +Characterize a type of adjacency. - For the root element this function always returns *face*. +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 -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] Then number of the face. +* `btype`:\\[in\\] The balance type to convert. # Returns -If *face* of *elem* is also a face of *elem*'s parent, the face number of this face. Otherwise -1. +Returns 1 or 2. ### Prototype ```c -int t8_element_face_parent_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +int p4est_connect_type_int (p4est_connect_type_t btype); ``` """ -function t8_element_face_parent_face(ts, elem, face) - @ccall libt8.t8_element_face_parent_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::Cint +function p4est_connect_type_int(btype) + @ccall libt8.p4est_connect_type_int(btype::p4est_connect_type_t)::Cint end """ - t8_element_tree_face(ts, elem, face) + p4est_connect_type_string(btype) -Given an element and a face of this element. If the face lies on the tree boundary, return the face number of the tree face. If not the return value is arbitrary. +Convert the [`p4est_connect_type_t`](@ref) into a const string. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in\\] The element. -* `face`:\\[in\\] The index of a face of *elem*. +* `btype`:\\[in\\] The balance type to convert. # Returns -The index of the tree face that *face* is a subface of, if *face* is on a tree boundary. Any arbitrary integer if *is* not at a tree boundary. +Returns a pointer to a constant string. ### Prototype ```c -int t8_element_tree_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +const char *p4est_connect_type_string (p4est_connect_type_t btype); ``` """ -function t8_element_tree_face(ts, elem, face) - @ccall libt8.t8_element_tree_face(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t}, face::Cint)::Cint +function p4est_connect_type_string(btype) + @ccall libt8.p4est_connect_type_string(btype::p4est_connect_type_t)::Cstring end """ - t8_element_transform_face(ts, elem1, elem2, orientation, sign, is_smaller_face) + p4est_connectivity -Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the trees and given the orientation of the tree connection, construct the face element of the respective tree neighbor that logically coincides with e but lies in the coordinate system of the neighbor tree. +This structure holds the 2D inter-tree connectivity information. Identification of arbitrary faces and corners is possible. -!!! note +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. - *elem1* and *elem2* may point to the same element. +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. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem1`:\\[in\\] The face element. -* `elem2`:\\[in,out\\] On return the face element *elem1* with respect to the coordinate system of the other tree. -* `orientation`:\\[in\\] The orientation of the tree-tree connection. -* `sign`:\\[in\\] Depending on the topological orientation of the two tree faces, either 0 (both faces have opposite orientation) or 1 (both faces have the same top. orientattion). t8_eclass_face_orientation -* `is_smaller_face`:\\[in\\] Flag to declare whether *elem1* belongs to the smaller face. A face f of tree T is smaller than f' of T' if either the eclass of T is smaller or if the classes are equal and f*\\_to\\_attr fields must either be NULL or previously be allocated by this function. +* `bytes_per_tree`:\\[in\\] If 0, tree\\_to\\_attr is freed (being NULL is ok). If positive, requested space is allocated. ### Prototype ```c -t8_gloidx_t t8_element_count_leaves (const t8_eclass_scheme_c *ts, const t8_element_t *t, int level); +void p4est_connectivity_set_attr (p4est_connectivity_t * conn, size_t bytes_per_tree); ``` """ -function t8_element_count_leaves(ts, t, level) - @ccall libt8.t8_element_count_leaves(ts::Ptr{t8_eclass_scheme_c}, t::Ptr{t8_element_t}, level::Cint)::t8_gloidx_t +function p4est_connectivity_set_attr(conn, bytes_per_tree) + @ccall libt8.p4est_connectivity_set_attr(conn::Ptr{p4est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid end """ - t8_element_count_leaves_from_root(ts, level) - -Count how many leaf descendants of a given uniform level the root element will produce. + p4est_connectivity_is_valid(connectivity) -This is a convenience function, and can be implemented via t8_element_count_leaves. +Examine a connectivity structure. -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `level`:\\[in\\] A refinement level. # Returns -The value of t8_element_count_leaves if the input element is the root (level 0) element. +Returns true if structure is valid, false otherwise. ### Prototype ```c -t8_gloidx_t t8_element_count_leaves_from_root (const t8_eclass_scheme_c *ts, int level); +int p4est_connectivity_is_valid (p4est_connectivity_t * connectivity); ``` """ -function t8_element_count_leaves_from_root(ts, level) - @ccall libt8.t8_element_count_leaves_from_root(ts::Ptr{t8_eclass_scheme_c}, level::Cint)::t8_gloidx_t +function p4est_connectivity_is_valid(connectivity) + @ccall libt8.p4est_connectivity_is_valid(connectivity::Ptr{p4est_connectivity_t})::Cint end """ - t8_element_new(ts, length, elems) - -Allocate memory for an array of elements of a given class and initialize them. - -!!! note - - Not every element that is created in t8code will be created by a call to this function. However, if an element is not created using t8_element_new, then it is guaranteed that t8_element_init is called on it. - -!!! note - - In debugging mode, an element that was created with t8_element_new must pass t8_element_is_valid. - -!!! note - - If an element was created by t8_element_new then t8_element_init may not be called for it. Thus, t8_element_new should initialize an element in the same way as a call to t8_element_init would. + p4est_connectivity_is_equal(conn1, conn2) -# Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `length`:\\[in\\] The number of elements to be allocated. -* `elems`:\\[in,out\\] On input an array of **length** many unallocated element pointers. On output all these pointers will point to an allocated and initialized element. -# See also -t8\\_element\\_init, t8\\_element\\_is\\_valid +Check two connectivity structures for equality. +# Returns +Returns true if structures are equal, false otherwise. ### Prototype ```c -void t8_element_new (const t8_eclass_scheme_c *ts, int length, t8_element_t **elems); +int p4est_connectivity_is_equal (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); ``` """ -function t8_element_new(ts, length, elems) - @ccall libt8.t8_element_new(ts::Ptr{t8_eclass_scheme_c}, length::Cint, elems::Ptr{Ptr{t8_element_t}})::Cvoid +function p4est_connectivity_is_equal(conn1, conn2) + @ccall libt8.p4est_connectivity_is_equal(conn1::Ptr{p4est_connectivity_t}, conn2::Ptr{p4est_connectivity_t})::Cint end """ - t8_element_destroy(ts, length, elems) + p4est_connectivity_sink(conn, sink) -Deallocate an array of elements. +Write connectivity to a sink object. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `length`:\\[in\\] The number of elements in the array. -* `elems`:\\[in,out\\] On input an array of **length** many allocated element pointers. On output all these pointers will be freed. **elem** itself will not be freed by this function. +* `conn`:\\[in\\] The connectivity to be written. +* `sink`:\\[in,out\\] The connectivity is written into this sink. +# Returns +0 on success, nonzero on error. ### Prototype ```c -void t8_element_destroy (const t8_eclass_scheme_c *ts, int length, t8_element_t **elems); +int p4est_connectivity_sink (p4est_connectivity_t * conn, sc_io_sink_t * sink); ``` """ -function t8_element_destroy(ts, length, elems) - @ccall libt8.t8_element_destroy(ts::Ptr{t8_eclass_scheme_c}, length::Cint, elems::Ptr{Ptr{t8_element_t}})::Cvoid +function p4est_connectivity_sink(conn, sink) + @ccall libt8.p4est_connectivity_sink(conn::Ptr{p4est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint end """ - t8_element_root(ts, elem) + p4est_connectivity_deflate(conn, code) -Fills an element with the root element. +Allocate memory and store the connectivity information there. # Arguments -* `ts`:\\[in\\] Implementation of a class scheme. -* `elem`:\\[in,out\\] The element to be filled with root. +* `conn`:\\[in\\] The connectivity structure to be exported to memory. +* `code`:\\[in\\] Encoding and compression method for serialization. +# Returns +Newly created array that contains the information. ### Prototype ```c -void t8_element_root (const t8_eclass_scheme_c *ts, t8_element_t *elem); +sc_array_t *p4est_connectivity_deflate (p4est_connectivity_t * conn, p4est_connectivity_encode_t code); ``` """ -function t8_element_root(ts, elem) - @ccall libt8.t8_element_root(ts::Ptr{t8_eclass_scheme_c}, elem::Ptr{t8_element_t})::Cvoid +function p4est_connectivity_deflate(conn, code) + @ccall libt8.p4est_connectivity_deflate(conn::Ptr{p4est_connectivity_t}, code::p4est_connectivity_encode_t)::Ptr{sc_array_t} end """ - t8_element_MPI_Pack(ts, elements, count, send_buffer, buffer_size, position, comm) + 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 -void t8_element_MPI_Pack (const t8_eclass_scheme_c *ts, t8_element_t **const elements, const unsigned int count, void *send_buffer, const int buffer_size, int *position, sc_MPI_Comm comm); +int p4est_connectivity_save (const char *filename, p4est_connectivity_t * connectivity); ``` """ -function t8_element_MPI_Pack(ts, elements, count, send_buffer, buffer_size, position, comm) - @ccall libt8.t8_element_MPI_Pack(ts::Ptr{t8_eclass_scheme_c}, elements::Ptr{Ptr{t8_element_t}}, count::Cuint, send_buffer::Ptr{Cvoid}, buffer_size::Cint, position::Ptr{Cint}, comm::MPI_Comm)::Cvoid +function p4est_connectivity_save(filename, connectivity) + @ccall libt8.p4est_connectivity_save(filename::Cstring, connectivity::Ptr{p4est_connectivity_t})::Cint end """ - t8_element_MPI_Pack_size(ts, count, comm, pack_size) + 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 -void t8_element_MPI_Pack_size (const t8_eclass_scheme_c *ts, const unsigned int count, sc_MPI_Comm comm, int *pack_size); +p4est_connectivity_t *p4est_connectivity_source (sc_io_source_t * source); ``` """ -function t8_element_MPI_Pack_size(ts, count, comm, pack_size) - @ccall libt8.t8_element_MPI_Pack_size(ts::Ptr{t8_eclass_scheme_c}, count::Cuint, comm::MPI_Comm, pack_size::Ptr{Cint})::Cvoid +function p4est_connectivity_source(source) + @ccall libt8.p4est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p4est_connectivity_t} end """ - t8_element_MPI_Unpack(ts, recvbuf, buffer_size, position, elements, count, comm) + 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 -void t8_element_MPI_Unpack (const t8_eclass_scheme_c *ts, void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm); +p4est_connectivity_t *p4est_connectivity_inflate (sc_array_t * buffer); ``` """ -function t8_element_MPI_Unpack(ts, recvbuf, buffer_size, position, elements, count, comm) - @ccall libt8.t8_element_MPI_Unpack(ts::Ptr{t8_eclass_scheme_c}, recvbuf::Ptr{Cvoid}, buffer_size::Cint, position::Ptr{Cint}, elements::Ptr{Ptr{t8_element_t}}, count::Cuint, comm::MPI_Comm)::Cvoid +function p4est_connectivity_inflate(buffer) + @ccall libt8.p4est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p4est_connectivity_t} end """ - t8_element_shape_num_faces(element_shape) + p4est_connectivity_load(filename, bytes) -The number of codimension-one boundaries of an element class. +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 -int t8_element_shape_num_faces (int element_shape); +p4est_connectivity_t *p4est_connectivity_load (const char *filename, size_t *bytes); ``` """ -function t8_element_shape_num_faces(element_shape) - @ccall libt8.t8_element_shape_num_faces(element_shape::Cint)::Cint +function p4est_connectivity_load(filename, bytes) + @ccall libt8.p4est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p4est_connectivity_t} end """ - t8_element_shape_max_num_faces(element_shape) + p4est_connectivity_new_unitsquare() -For each dimension the maximum possible number of faces of an element\\_shape of that dimension. +Create a connectivity structure for the unit square. ### Prototype ```c -int t8_element_shape_max_num_faces (int element_shape); +p4est_connectivity_t *p4est_connectivity_new_unitsquare (void); ``` """ -function t8_element_shape_max_num_faces(element_shape) - @ccall libt8.t8_element_shape_max_num_faces(element_shape::Cint)::Cint +function p4est_connectivity_new_unitsquare() + @ccall libt8.p4est_connectivity_new_unitsquare()::Ptr{p4est_connectivity_t} end """ - t8_element_shape_num_vertices(element_shape) + p4est_connectivity_new_periodic() -The number of vertices of an element class. +Create a connectivity structure for an all-periodic unit square. ### Prototype ```c -int t8_element_shape_num_vertices (int element_shape); +p4est_connectivity_t *p4est_connectivity_new_periodic (void); ``` """ -function t8_element_shape_num_vertices(element_shape) - @ccall libt8.t8_element_shape_num_vertices(element_shape::Cint)::Cint +function p4est_connectivity_new_periodic() + @ccall libt8.p4est_connectivity_new_periodic()::Ptr{p4est_connectivity_t} end """ - t8_element_shape_vtk_type(element_shape) + p4est_connectivity_new_rotwrap() -The vtk cell type for the element\\_shape +Create a connectivity structure for a periodic unit square. The left and right faces are identified, and bottom and top opposite. ### Prototype ```c -int t8_element_shape_vtk_type (int element_shape); +p4est_connectivity_t *p4est_connectivity_new_rotwrap (void); ``` """ -function t8_element_shape_vtk_type(element_shape) - @ccall libt8.t8_element_shape_vtk_type(element_shape::Cint)::Cint +function p4est_connectivity_new_rotwrap() + @ccall libt8.p4est_connectivity_new_rotwrap()::Ptr{p4est_connectivity_t} end """ - t8_element_shape_vtk_corner_number(element_shape, index) + p4est_connectivity_new_circle() -Maps the t8code corner number of the element to the vtk corner number +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 -int t8_element_shape_vtk_corner_number (int element_shape, int index); +p4est_connectivity_t *p4est_connectivity_new_circle (void); ``` """ -function t8_element_shape_vtk_corner_number(element_shape, index) - @ccall libt8.t8_element_shape_vtk_corner_number(element_shape::Cint, index::Cint)::Cint +function p4est_connectivity_new_circle() + @ccall libt8.p4est_connectivity_new_circle()::Ptr{p4est_connectivity_t} end """ - t8_element_shape_to_string(element_shape) + p4est_connectivity_new_drop() -For each element\\_shape, the name of this class as a string +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 -const char* t8_element_shape_to_string (int element_shape); +p4est_connectivity_t *p4est_connectivity_new_drop (void); ``` """ -function t8_element_shape_to_string(element_shape) - @ccall libt8.t8_element_shape_to_string(element_shape::Cint)::Cstring +function p4est_connectivity_new_drop() + @ccall libt8.p4est_connectivity_new_drop()::Ptr{p4est_connectivity_t} end """ - t8_element_shape_compare(element_shape1, element_shape2) + p4est_connectivity_new_twotrees(l_face, r_face, orientation) -Compare two element\\_shapees of the same dimension as necessary for face neighbor orientation. The implemented order is Triangle < Square in 2D and Tet < Hex < Prism < Pyramid in 3D. +Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way # Arguments -* `element_shape1`:\\[in\\] The first element\\_shape to compare. -* `element_shape2`:\\[in\\] The second element\\_shape to compare. -# Returns -0 if the element\\_shapees are equal, 1 if element\\_shape1 > element\\_shape2 and -1 if element\\_shape1 < element\\_shape2 +* `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 t8_element_shape_compare (t8_element_shape_t element_shape1, t8_element_shape_t element_shape2); +p4est_connectivity_t *p4est_connectivity_new_twotrees (int l_face, int r_face, int orientation); ``` """ -function t8_element_shape_compare(element_shape1, element_shape2) - @ccall libt8.t8_element_shape_compare(element_shape1::t8_element_shape_t, element_shape2::t8_element_shape_t)::Cint +function p4est_connectivity_new_twotrees(l_face, r_face, orientation) + @ccall libt8.p4est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p4est_connectivity_t} end """ - 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} + p4est_connectivity_new_corner() -""" - t8_forest_write_netcdf(forest, file_prefix, file_title, dim, num_extern_netcdf_vars, ext_variables, comm) +Create a connectivity structure for a three-tree mesh around a corner. ### 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); +p4est_connectivity_t *p4est_connectivity_new_corner (void); ``` """ -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 p4est_connectivity_new_corner() + @ccall libt8.p4est_connectivity_new_corner()::Ptr{p4est_connectivity_t} 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) + p4est_connectivity_new_pillow() + +Create a connectivity structure for two trees on top of each other. ### 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); +p4est_connectivity_t *p4est_connectivity_new_pillow (void); ``` """ -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 p4est_connectivity_new_pillow() + @ccall libt8.p4est_connectivity_new_pillow()::Ptr{p4est_connectivity_t} end """ - t8_mat_init_xrot(mat, angle) + p4est_connectivity_new_moebius() -Initialize given 3x3 matrix as rotation matrix around the x-axis with given angle. +Create a connectivity structure for a five-tree moebius band. -# Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. ### Prototype ```c -static inline void t8_mat_init_xrot (double mat[3][3], const double angle); +p4est_connectivity_t *p4est_connectivity_new_moebius (void); ``` """ -function t8_mat_init_xrot(mat, angle) - @ccall libt8.t8_mat_init_xrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function p4est_connectivity_new_moebius() + @ccall libt8.p4est_connectivity_new_moebius()::Ptr{p4est_connectivity_t} end """ - t8_mat_init_yrot(mat, angle) + p4est_connectivity_new_star() -Initialize given 3x3 matrix as rotation matrix around the y-axis with given angle. +Create a connectivity structure for a six-tree star. -# 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); +p4est_connectivity_t *p4est_connectivity_new_star (void); ``` """ -function t8_mat_init_yrot(mat, angle) - @ccall libt8.t8_mat_init_yrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function p4est_connectivity_new_star() + @ccall libt8.p4est_connectivity_new_star()::Ptr{p4est_connectivity_t} end """ - t8_mat_init_zrot(mat, angle) + p4est_connectivity_new_cubed() -Initialize given 3x3 matrix as rotation matrix around the z-axis with given angle. +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). -# Arguments -* `mat`:\\[in,out\\] 3x3-matrix. -* `angle`:\\[in\\] Rotation angle in radians. ### Prototype ```c -static inline void t8_mat_init_zrot (double mat[3][3], const double angle); +p4est_connectivity_t *p4est_connectivity_new_cubed (void); ``` """ -function t8_mat_init_zrot(mat, angle) - @ccall libt8.t8_mat_init_zrot(mat::Ptr{NTuple{3, Cdouble}}, angle::Cdouble)::Cvoid +function p4est_connectivity_new_cubed() + @ccall libt8.p4est_connectivity_new_cubed()::Ptr{p4est_connectivity_t} end """ - t8_mat_mult_vec(mat, a, b) + p4est_connectivity_new_disk_nonperiodic() -Apply matrix-matrix multiplication: b = M*a. +Create a connectivity structure for a five-tree flat spherical disk. This disk can just as well be used as a square to test non-Cartesian maps. Without any mapping this connectivity covers the square [-3, 3]**2. -# Arguments -* `mat`:\\[in\\] 3x3-matrix. -* `a`:\\[in\\] 3-vector. -* `b`:\\[in,out\\] 3-vector. +# Returns +Initialized and usable connectivity. ### Prototype ```c -static inline void t8_mat_mult_vec (const double mat[3][3], const double a[3], double b[3]); +p4est_connectivity_t *p4est_connectivity_new_disk_nonperiodic (void); ``` """ -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 p4est_connectivity_new_disk_nonperiodic() + @ccall libt8.p4est_connectivity_new_disk_nonperiodic()::Ptr{p4est_connectivity_t} end """ - t8_mat_mult_mat(A, B, C) + p4est_connectivity_new_disk(periodic_a, periodic_b) -Apply matrix-matrix multiplication: C = A*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. -# Arguments -* `A`:\\[in\\] 3x3-matrix. -* `B`:\\[in\\] 3x3-matrix. -* `C`:\\[in\\] 3x3-matrix. -### Prototype -```c -static inline void t8_mat_mult_mat (const double A[3][3], const double B[3][3], double C[3][3]); -``` -""" -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 +!!! note -mutable struct t8_mesh end + The API of this function has changed to accept two arguments. You can query the P4EST_CONN_DISK_PERIODIC to check whether the new version with the argument is in effect. -const t8_mesh_t = t8_mesh +The ordering of the trees is as follows: -""" - t8_mesh_new(dimension, Kglobal, Klocal) +4 1 2 3 0 -*********************** preallocate ************************* +The outside x faces may be identified topologically. The outside y faces may be identified topologically. Both identifications may be specified simultaneously. The general shape and periodicity are the same as those obtained with p4est_connectivity_new_brick (1, 1, periodic\\_a, periodic\\_b). + +When setting *periodic_a* and *periodic_b* to false, the result is the same as that of p4est_connectivity_new_disk_nonperiodic. +# Arguments +* `periodic_a`:\\[in\\] Bool to make disk periodic in x direction. +* `periodic_b`:\\[in\\] Bool to make disk periodic in y direction. +# Returns +Initialized and usable connectivity. ### Prototype ```c -t8_mesh_t * t8_mesh_new (int dimension, t8_gloidx_t Kglobal, t8_locidx_t Klocal); +p4est_connectivity_t *p4est_connectivity_new_disk (int periodic_a, int periodic_b); ``` """ -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 p4est_connectivity_new_disk(periodic_a, periodic_b) + @ccall libt8.p4est_connectivity_new_disk(periodic_a::Cint, periodic_b::Cint)::Ptr{p4est_connectivity_t} end """ - t8_mesh_new_unitcube(theclass) + p4est_connectivity_new_icosahedron() -*********** all-in-one convenience constructors ************* +Create a connectivity for mapping the sphere using an icosahedron. -### Prototype -```c -t8_mesh_t * t8_mesh_new_unitcube (t8_eclass_t theclass); -``` -""" -function t8_mesh_new_unitcube(theclass) - @ccall libt8.t8_mesh_new_unitcube(theclass::t8_eclass_t)::Ptr{t8_mesh_t} -end +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. -""" - t8_mesh_set_comm(mesh, comm) +This connectivity is meant to be used together with p4est_geometry_new_icosahedron to map the sphere. -### Prototype -```c -void t8_mesh_set_comm (t8_mesh_t *mesh, sc_MPI_Comm comm); -``` -""" -function t8_mesh_set_comm(mesh, comm) - @ccall libt8.t8_mesh_set_comm(mesh::Ptr{t8_mesh_t}, comm::MPI_Comm)::Cvoid -end +The flat connectivity looks like that. Vextex numbering: -""" - t8_mesh_set_partition(mesh, enable) +A00 A01 A02 A03 A04 / \\ / \\ / \\ / \\ / \\ A05---A06---A07---A08---A09---A10 \\ / \\ / \\ / \\ / \\ / \\ A11---A12---A13---A14---A15---A16 \\ / \\ / \\ / \\ / \\ / A17 A18 A19 A20 A21 -Determine whether we partition in t8_mesh_build. Default true. +Origin in A05. -### Prototype -```c -void t8_mesh_set_partition (t8_mesh_t *mesh, int enable); -``` -""" -function t8_mesh_set_partition(mesh, enable) - @ccall libt8.t8_mesh_set_partition(mesh::Ptr{t8_mesh_t}, enable::Cint)::Cvoid -end +Tree numbering: -""" - t8_mesh_set_element(mesh, theclass, gloid, locid) +0 2 4 6 8 1 3 5 7 9 ### Prototype ```c -void t8_mesh_set_element (t8_mesh_t *mesh, t8_eclass_t theclass, t8_gloidx_t gloid, t8_locidx_t locid); +p4est_connectivity_t *p4est_connectivity_new_icosahedron (void); ``` """ -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 p4est_connectivity_new_icosahedron() + @ccall libt8.p4est_connectivity_new_icosahedron()::Ptr{p4est_connectivity_t} end """ - t8_mesh_set_local_to_global(mesh, ltog_length, ltog) + p4est_connectivity_new_shell2d() + +Create a connectivity structure that builds a 2d spherical shell. p8est_connectivity_new_shell ### Prototype ```c -void t8_mesh_set_local_to_global (t8_mesh_t *mesh, t8_locidx_t ltog_length, const t8_gloidx_t *ltog); +p4est_connectivity_t *p4est_connectivity_new_shell2d (void); ``` """ -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 p4est_connectivity_new_shell2d() + @ccall libt8.p4est_connectivity_new_shell2d()::Ptr{p4est_connectivity_t} end """ - t8_mesh_set_face(mesh, locid1, face1, locid2, face2, orientation) + p4est_connectivity_new_disk2d() -### 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); -``` -""" -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 +Create a connectivity structure that maps a 2d disk. -""" - t8_mesh_set_element_vertices(mesh, locid, vids_length, vids) +This is a 5 trees connectivity meant to be used together with p4est_geometry_new_disk2d to map the disk. ### 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); +p4est_connectivity_t *p4est_connectivity_new_disk2d (void); ``` """ -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 p4est_connectivity_new_disk2d() + @ccall libt8.p4est_connectivity_new_disk2d()::Ptr{p4est_connectivity_t} end """ - t8_mesh_build(mesh) + p4est_connectivity_new_bowtie() -Setup a mesh and turn it into a usable object. +Create a connectivity structure that maps a 2d bowtie structure. -### Prototype -```c -void t8_mesh_build (t8_mesh_t *mesh); -``` -""" -function t8_mesh_build(mesh) - @ccall libt8.t8_mesh_build(mesh::Ptr{t8_mesh_t})::Cvoid -end +The 2 trees are connected by a corner connection at node A3 (0, 0). the nodes are given as: -""" - t8_mesh_get_comm(mesh) +A00 A01 / \\ / \\ A02 A03 A04 \\ / \\ / A05 A06 ### Prototype ```c -sc_MPI_Comm t8_mesh_get_comm (t8_mesh_t *mesh); +p4est_connectivity_t *p4est_connectivity_new_bowtie (void); ``` """ -function t8_mesh_get_comm(mesh) - @ccall libt8.t8_mesh_get_comm(mesh::Ptr{t8_mesh_t})::Cint +function p4est_connectivity_new_bowtie() + @ccall libt8.p4est_connectivity_new_bowtie()::Ptr{p4est_connectivity_t} end """ - t8_mesh_get_element_count(mesh, theclass) - -### Prototype -```c -t8_locidx_t t8_mesh_get_element_count (t8_mesh_t *mesh, t8_eclass_t theclass); -``` -""" -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 + p4est_connectivity_new_brick(mi, ni, periodic_a, periodic_b) -""" - t8_mesh_get_element_class(mesh, locid) +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. -# 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 -t8_locidx_t t8_mesh_get_element_class (t8_mesh_t *mesh, t8_locidx_t locid); +p4est_connectivity_t *p4est_connectivity_new_brick (int mi, int ni, int periodic_a, int periodic_b); ``` """ -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 p4est_connectivity_new_brick(mi, ni, periodic_a, periodic_b) + @ccall libt8.p4est_connectivity_new_brick(mi::Cint, ni::Cint, periodic_a::Cint, periodic_b::Cint)::Ptr{p4est_connectivity_t} end """ - t8_mesh_get_element_locid(mesh, gloid) - -### Prototype -```c -t8_locidx_t t8_mesh_get_element_locid (t8_mesh_t *mesh, t8_gloidx_t gloid); -``` -""" -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 + p4est_connectivity_new_byname(name) -""" - t8_mesh_get_element_gloid(mesh, locid) +Create connectivity structure from predefined catalogue. +# Arguments +* `name`:\\[in\\] Invokes connectivity\\_new\\_* function. brick23 brick (2, 3, 0, 0) corner corner cubed cubed disk disk moebius moebius periodic periodic pillow pillow rotwrap rotwrap star star unit unitsquare +# Returns +An initialized connectivity if name is defined, NULL else. ### Prototype ```c -t8_gloidx_t t8_mesh_get_element_gloid (t8_mesh_t *mesh, t8_locidx_t locid); +p4est_connectivity_t *p4est_connectivity_new_byname (const char *name); ``` """ -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 p4est_connectivity_new_byname(name) + @ccall libt8.p4est_connectivity_new_byname(name::Cstring)::Ptr{p4est_connectivity_t} end """ - t8_mesh_get_element(mesh, locid) - -### Prototype -```c -t8_element_t t8_mesh_get_element (t8_mesh_t *mesh, t8_locidx_t locid); -``` -""" -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 + p4est_connectivity_refine(conn, num_per_dim) -""" - t8_mesh_get_element_boundary(mesh, locid, length_boundary, elemid, orientation) +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 -void t8_mesh_get_element_boundary (t8_mesh_t *mesh, t8_locidx_t locid, int length_boundary, t8_locidx_t *elemid, int *orientation); +p4est_connectivity_t *p4est_connectivity_refine (p4est_connectivity_t * conn, int num_per_dim); ``` """ -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 p4est_connectivity_refine(conn, num_per_dim) + @ccall libt8.p4est_connectivity_refine(conn::Ptr{p4est_connectivity_t}, num_per_dim::Cint)::Ptr{p4est_connectivity_t} end """ - t8_mesh_get_maximum_support(mesh) + p4est_expand_face_transform(iface, nface, ftransform) -Return the maximum of the length of the support of any local element. +Fill an array with the axis combination of a face neighbor transform. +# Arguments +* `iface`:\\[in\\] The number of the originating face. +* `nface`:\\[in\\] Encoded as nface = r * 4 + nf, where nf = 0..3 is the neigbbor's connecting face number and r = 0..1 is the relative orientation to the neighbor's face. This encoding matches [`p4est_connectivity_t`](@ref). +* `ftransform`:\\[out\\] This array holds 9 integers. [0,2] The coordinate axis sequence of the origin face, the first referring to the tangential and the second to the normal. A permutation of (0, 1). [3,5] The coordinate axis sequence of the target face. [6,8] Face reversal flag for tangential axis (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q [1,4,7] 0 (unused for compatibility with 3D). ### Prototype ```c -int t8_mesh_get_maximum_support (t8_mesh_t *mesh); +void p4est_expand_face_transform (int iface, int nface, int ftransform[]); ``` """ -function t8_mesh_get_maximum_support(mesh) - @ccall libt8.t8_mesh_get_maximum_support(mesh::Ptr{t8_mesh_t})::Cint +function p4est_expand_face_transform(iface, nface, ftransform) + @ccall libt8.p4est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid end """ - t8_mesh_get_element_support(mesh, locid, length_support, elemid, orientation) + p4est_find_face_transform(connectivity, itree, iface, ftransform) + +Fill an array with the axis combinations of a tree neighbor transform. # Arguments -* `length_support`:\\[in,out\\] +* `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 -void t8_mesh_get_element_support (t8_mesh_t *mesh, t8_locidx_t locid, int *length_support, t8_locidx_t *elemid, int *orientation); +p4est_topidx_t p4est_find_face_transform (p4est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); ``` """ -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 p4est_find_face_transform(connectivity, itree, iface, ftransform) + @ccall libt8.p4est_find_face_transform(connectivity::Ptr{p4est_connectivity_t}, itree::p4est_topidx_t, iface::Cint, ftransform::Ptr{Cint})::p4est_topidx_t end """ - t8_mesh_destroy(mesh) + p4est_find_corner_transform(connectivity, itree, icorner, ci) -*************************** destruct ************************ +Fills an array with information about corner neighbors. +# Arguments +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `icorner`:\\[in\\] The number of the originating corner. +* `ci`:\\[in,out\\] A [`p4est_corner_info_t`](@ref) structure with initialized array. ### Prototype ```c -void t8_mesh_destroy (t8_mesh_t *mesh); +void p4est_find_corner_transform (p4est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p4est_corner_info_t * ci); ``` """ -function t8_mesh_destroy(mesh) - @ccall libt8.t8_mesh_destroy(mesh::Ptr{t8_mesh_t})::Cvoid +function p4est_find_corner_transform(connectivity, itree, icorner, ci) + @ccall libt8.p4est_find_corner_transform(connectivity::Ptr{p4est_connectivity_t}, itree::p4est_topidx_t, icorner::Cint, ci::Ptr{p4est_corner_info_t})::Cvoid end -const t8_nc_int64_t = Int64 - -const t8_nc_int32_t = Int32 - """ - t8_netcdf_create_var(var_type, var_name, var_long_name, var_unit, var_data) + p4est_connectivity_complete(conn) -Create an extern double variable which additionally should be put out to the NetCDF File +Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. # 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). +* `conn`:\\[in,out\\] The connectivity needs to have proper vertices and tree\\_to\\_vertex fields. The tree\\_to\\_tree and tree\\_to\\_face fields must be allocated and satisfy [`p4est_connectivity_is_valid`](@ref) (conn) but will be overwritten. The corner fields will be freed and allocated anew. ### Prototype ```c -t8_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); +void p4est_connectivity_complete (p4est_connectivity_t * conn); ``` """ -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 p4est_connectivity_complete(conn) + @ccall libt8.p4est_connectivity_complete(conn::Ptr{p4est_connectivity_t})::Cvoid end """ - t8_netcdf_create_integer_var(var_name, var_long_name, var_unit, var_data) + p4est_connectivity_reduce(conn) -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)) +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 -* `var_name`:\\[in\\] A String which will be the name of the created variable. -* `var_long_name`:\\[in\\] A string describing the variable a bit more and what it is about. -* `var_unit`:\\[in\\] The units in which the data is provided. -* `var_data`:\\[in\\] A [`sc_array_t`](@ref) holding the elementwise data of the variable. -* `num_extern_netcdf_vars`:\\[in\\] The number of extern user-defined variables which hold elementwise data (if none, set it to 0). +* `conn`:\\[in,out\\] The connectivity to be reduced. ### Prototype ```c -t8_netcdf_variable_t * t8_netcdf_create_integer_var (const char *var_name, const char *var_long_name, const char *var_unit, sc_array_t *var_data); +void p4est_connectivity_reduce (p4est_connectivity_t * conn); ``` """ -function t8_netcdf_create_integer_var(var_name, var_long_name, var_unit, var_data) - @ccall libt8.t8_netcdf_create_integer_var(var_name::Cstring, var_long_name::Cstring, var_unit::Cstring, var_data::Ptr{sc_array_t})::Ptr{t8_netcdf_variable_t} +function p4est_connectivity_reduce(conn) + @ccall libt8.p4est_connectivity_reduce(conn::Ptr{p4est_connectivity_t})::Cvoid end """ - t8_netcdf_create_double_var(var_name, var_long_name, var_unit, var_data) + p4est_connectivity_permute(conn, perm, is_current_to_new) -Create an extern double variable which additionally should be put out to the NetCDF File +[`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 -* `var_name`:\\[in\\] A String which will be the name of the created variable. -* `var_long_name`:\\[in\\] A string describing the variable a bit more and what it is about. -* `var_unit`:\\[in\\] The units in which the data is provided. -* `var_data`:\\[in\\] A [`sc_array_t`](@ref) holding the elementwise data of the variable. -* `num_extern_netcdf_vars`:\\[in\\] The number of extern user-defined variables which hold elementwise data (if none, set it to 0). +* `conn`:\\[in,out\\] The connectivity whose trees are permuted. +* `perm`:\\[in\\] A permutation array, whose elements are size\\_t's. +* `is_current_to_new`:\\[in\\] if true, the jth entry of perm is the new index for the entry whose current index is j, otherwise the jth entry of perm is the current index of the tree whose index will be j after the permutation. ### Prototype ```c -t8_netcdf_variable_t * t8_netcdf_create_double_var (const char *var_name, const char *var_long_name, const char *var_unit, sc_array_t *var_data); +void p4est_connectivity_permute (p4est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); ``` """ -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 p4est_connectivity_permute(conn, perm, is_current_to_new) + @ccall libt8.p4est_connectivity_permute(conn::Ptr{p4est_connectivity_t}, perm::Ptr{sc_array_t}, is_current_to_new::Cint)::Cvoid end """ - t8_netcdf_variable_destroy(var_destroy) + p4est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) -Free the allocated memory of the a [`t8_netcdf_variable_t`](@ref) +[`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 -* `var_destroy`:\\[in\\] A t8\\_netcdf\\_t variable whose allocated memory should be freed. +* `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 t8_netcdf_variable_destroy (t8_netcdf_variable_t *var_destroy); +void p4est_connectivity_join_faces (p4est_connectivity_t * conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation); ``` """ -function t8_netcdf_variable_destroy(var_destroy) - @ccall libt8.t8_netcdf_variable_destroy(var_destroy::Ptr{t8_netcdf_variable_t})::Cvoid +function p4est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + @ccall libt8.p4est_connectivity_join_faces(conn::Ptr{p4est_connectivity_t}, tree_left::p4est_topidx_t, tree_right::p4est_topidx_t, face_left::Cint, face_right::Cint, orientation::Cint)::Cvoid end """ - t8_refcount_init(rc) + p4est_connectivity_is_equivalent(conn1, conn2) -Initialize a reference counter to 1. It is legal if its status prior to this call is undefined. +[`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 -* `rc`:\\[out\\] The reference counter is set to one by this call. +* `conn1`:\\[in\\] a valid connectivity +* `conn2`:\\[out\\] a valid connectivity ### Prototype ```c -void t8_refcount_init (t8_refcount_t *rc); +int p4est_connectivity_is_equivalent (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); ``` """ -function t8_refcount_init(rc) - @ccall libt8.t8_refcount_init(rc::Ptr{t8_refcount_t})::Cvoid +function p4est_connectivity_is_equivalent(conn1, conn2) + @ccall libt8.p4est_connectivity_is_equivalent(conn1::Ptr{p4est_connectivity_t}, conn2::Ptr{p4est_connectivity_t})::Cint end """ - t8_refcount_new() - -Create a new reference counter with count initialized to 1. Equivalent to calling [`t8_refcount_init`](@ref) on a newly allocated refcount\\_t. It is mandatory to free this with t8_refcount_destroy. + p4est_corner_array_index(array, it) -# Returns -An allocated reference counter whose count has been set to one. ### Prototype ```c -t8_refcount_t * t8_refcount_new (void); +static inline p4est_corner_transform_t * p4est_corner_array_index (sc_array_t * array, size_t it); ``` """ -function t8_refcount_new() - @ccall libt8.t8_refcount_new()::Ptr{t8_refcount_t} +function p4est_corner_array_index(array, it) + @ccall libt8.p4est_corner_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p4est_corner_transform_t} end """ - t8_refcount_destroy(rc) + p4est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) -Destroy a reference counter that we allocated with t8_refcount_new. Its reference count must have decreased to zero. +Read an ABAQUS input file from a file stream. -# Arguments -* `rc`:\\[in,out\\] Allocated, formerly valid reference counter. -### Prototype -```c -void t8_refcount_destroy (t8_refcount_t *rc); -``` -""" -function t8_refcount_destroy(rc) - @ccall libt8.t8_refcount_destroy(rc::Ptr{t8_refcount_t})::Cvoid -end +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. -""" - t8_vec_norm(vec) - -Vector norm. - -# Arguments -* `vec`:\\[in\\] A 3D vector. -# Returns -The norm of *vec*. -### Prototype -```c -static inline double t8_vec_norm (const double vec[3]); -``` -""" -function t8_vec_norm(vec) - @ccall libt8.t8_vec_norm(vec::Ptr{Cdouble})::Cdouble -end - -""" - t8_vec_normalize(vec) - -Normalize a vector. +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: -# Arguments -* `vec`:\\[in,out\\] A 3D vector. -### Prototype -```c -static inline void t8_vec_normalize (double vec[3]); -``` -""" -function t8_vec_normalize(vec) - @ccall libt8.t8_vec_normalize(vec::Ptr{Cdouble})::Cvoid -end +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 -""" - t8_vec_copy(vec_in, vec_out) +and in 3D they are given as: -Make a copy of a vector. +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 -# Arguments -* `vec_in`:\\[in\\] -* `vec_out`:\\[out\\] -### Prototype -```c -static inline void t8_vec_copy (const double vec_in[3], double vec_out[3]); +```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 ``` -""" -function t8_vec_copy(vec_in, vec_out) - @ccall libt8.t8_vec_copy(vec_in::Ptr{Cdouble}, vec_out::Ptr{Cdouble})::Cvoid -end - -""" - t8_vec_dist(vec_x, vec_y) -Euclidean distance of X and Y. +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 -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. +* `stream`:\\[in,out\\] file stream to read the connectivity from +* `num_vertices`:\\[in,out\\] the number of vertices in the connectivity +* `num_trees`:\\[in,out\\] the number of trees in the connectivity +* `vertices`:\\[out\\] the list of `vertices` of the connectivity +* `tree_to_vertex`:\\[out\\] the `tree_to_vertex` map of the connectivity # Returns -The euclidean distance. Equivalent to norm (X-Y). +0 if successful and nonzero if not ### Prototype ```c -static inline double t8_vec_dist (const double vec_x[3], const double vec_y[3]); +int p4est_connectivity_read_inp_stream (FILE * stream, p4est_topidx_t * num_vertices, p4est_topidx_t * num_trees, double *vertices, p4est_topidx_t * tree_to_vertex); ``` """ -function t8_vec_dist(vec_x, vec_y) - @ccall libt8.t8_vec_dist(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +function p4est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) + @ccall libt8.p4est_connectivity_read_inp_stream(stream::Ptr{Libc.FILE}, num_vertices::Ptr{p4est_topidx_t}, num_trees::Ptr{p4est_topidx_t}, vertices::Ptr{Cdouble}, tree_to_vertex::Ptr{p4est_topidx_t})::Cint end """ - t8_vec_ax(vec_x, alpha) - -Compute X = alpha * X + p4est_connectivity_read_inp(filename) -# Arguments -* `vec_x`:\\[in,out\\] A 3D vector. On output set to *alpha* * *vec_x*. -* `alpha`:\\[in\\] A factor. -### Prototype -```c -static inline void t8_vec_ax (double vec_x[3], const double alpha); -``` -""" -function t8_vec_ax(vec_x, alpha) - @ccall libt8.t8_vec_ax(vec_x::Ptr{Cdouble}, alpha::Cdouble)::Cvoid -end +Create a p4est connectivity from an ABAQUS input file. -""" - t8_vec_axy(vec_x, vec_y, alpha) +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. -Compute Y = alpha * X +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: -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_z`:\\[out\\] On output set to *alpha* * *vec_x*. -* `alpha`:\\[in\\] A factor. -### Prototype -```c -static inline void t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha); -``` -""" -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 +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 -""" - t8_vec_axb(vec_x, vec_y, alpha, b) +and in 3D they are given as: -Y = alpha * X + b +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 -!!! note +```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 +``` - It is possible that vec\\_x = vec\\_y on input to overwrite x +This function reads a mesh from *filename* and returns an associated p4est connectivity. # 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. +* `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 -static inline void t8_vec_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b); +p4est_connectivity_t *p4est_connectivity_read_inp (const char *filename); ``` """ -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 p4est_connectivity_read_inp(filename) + @ccall libt8.p4est_connectivity_read_inp(filename::Cstring)::Ptr{p4est_connectivity_t} end """ - t8_vec_axpy(vec_x, vec_y, alpha) + p8est_connect_type_t -Y = Y + alpha * X +Characterize a type of adjacency. -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in,out\\] On input, a 3D vector. On output set *to* vec\\_y + *alpha* * *vec_x* -* `alpha`:\\[in\\] A factor. -### Prototype -```c -static inline void t8_vec_axpy (const double vec_x[3], double vec_y[3], const double alpha); -``` +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 t8_vec_axpy(vec_x, vec_y, alpha) - @ccall libt8.t8_vec_axpy(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, alpha::Cdouble)::Cvoid +@cenum p8est_connect_type_t::UInt32 begin + P8EST_CONNECT_SELF = 30 + P8EST_CONNECT_FACE = 31 + P8EST_CONNECT_EDGE = 32 + P8EST_CONNECT_ALMOST = 32 + P8EST_CONNECT_CORNER = 33 + P8EST_CONNECT_FULL = 33 end """ - t8_vec_axpyz(vec_x, vec_y, vec_z, alpha) + p8est_connectivity_encode_t -Z = Y + alpha * X +Typedef for serialization method. -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -* `vec_z`:\\[out\\] On output set *to* vec\\_y + *alpha* * *vec_x* -### Prototype -```c -static inline void t8_vec_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], const double alpha); -``` +| Enumerator | Note | +| :--------------------------- | :-------------------------------- | +| P8EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | """ -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 +@cenum p8est_connectivity_encode_t::UInt32 begin + P8EST_CONN_ENCODE_NONE = 0 + P8EST_CONN_ENCODE_LAST = 1 end """ - t8_vec_dot(vec_x, vec_y) + p8est_connect_type_int(btype) -Dot product of X and Y. +Convert the [`p8est_connect_type_t`](@ref) into a number. # Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. +* `btype`:\\[in\\] The balance type to convert. # Returns -The dot product *vec_x* * *vec_y* +Returns 1, 2 or 3. ### Prototype ```c -static inline double t8_vec_dot (const double vec_x[3], const double vec_y[3]); +int p8est_connect_type_int (p8est_connect_type_t btype); ``` """ -function t8_vec_dot(vec_x, vec_y) - @ccall libt8.t8_vec_dot(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble})::Cdouble +function p8est_connect_type_int(btype) + @ccall libt8.p8est_connect_type_int(btype::p8est_connect_type_t)::Cint end """ - t8_vec_cross(vec_x, vec_y, cross) + p8est_connect_type_string(btype) -Cross product of X and Y +Convert the [`p8est_connect_type_t`](@ref) into a const string. # 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*. +* `btype`:\\[in\\] The balance type to convert. +# Returns +Returns a pointer to a constant string. ### Prototype ```c -static inline void t8_vec_cross (const double vec_x[3], const double vec_y[3], double cross[3]); +const char *p8est_connect_type_string (p8est_connect_type_t btype); ``` """ -function t8_vec_cross(vec_x, vec_y, cross) - @ccall libt8.t8_vec_cross(vec_x::Ptr{Cdouble}, vec_y::Ptr{Cdouble}, cross::Ptr{Cdouble})::Cvoid +function p8est_connect_type_string(btype) + @ccall libt8.p8est_connect_type_string(btype::p8est_connect_type_t)::Cstring end """ - t8_vec_diff(vec_x, vec_y, diff) - -Compute the difference of two vectors. + p8est_connectivity -# Arguments -* `vec_x`:\\[in\\] A 3D vector. -* `vec_y`:\\[in\\] A 3D vector. -* `diff`:\\[out\\] On output, the difference of *vec_x* and *vec_y*. -### Prototype -```c -static inline void t8_vec_diff (const double vec_x[3], const double vec_y[3], double diff[3]); -``` -""" -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 +This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible. -""" - t8_vec_eq(vec_x, vec_y, tol) +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. -Check the equality of two vectors elementwise +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. -# Arguments -* `vec_x`:\\[in\\] -* `vec_y`:\\[in\\] -* `tol`:\\[in\\] -# Returns -true, if the vectors are equal up to *tol* -### Prototype -```c -static inline int t8_vec_eq (const double vec_x[3], const double vec_y[3], const double tol); -``` -""" -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 +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. -""" - t8_vec_rescale(vec, new_length) +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. -Rescale a vector to a new length. +The arrays edge\\_to\\_* store a variable number of entries per edge. For edge e these are at position [ett\\_offset[e]]..[ett\\_offset[e+1]-1]. Their number for edge e is ett\\_offset[e+1] - ett\\_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge\\_to\\_* arrays is num\\_ett = ett\\_offset[num\\_edges]. The edge\\_to\\_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation. -# Arguments -* `vec`:\\[in,out\\] A 3D vector. -* `new_length`:\\[in\\] New length of the vector. -### Prototype -```c -static inline void t8_vec_rescale (double vec[3], const double new_length); -``` -""" -function t8_vec_rescale(vec, new_length) - @ccall libt8.t8_vec_rescale(vec::Ptr{Cdouble}, new_length::Cdouble)::Cvoid -end +The corners are stored when they connect trees that are not already edge or face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. -""" - t8_vec_tri_normal(p1, p2, p3, normal) +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]. -Compute the normal of a triangle given by its three vertices. +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. -# Arguments -* `p1`:\\[in\\] A 3D vector. -* `p2`:\\[in\\] A 3D vector. -* `p3`:\\[in\\] A 3D vector. -* `Normal`:\\[out\\] vector of the triangle. (Not necessarily of length 1!) -### Prototype -```c -static inline void t8_vec_tri_normal (const double p1[3], const double p2[3], const double p3[3], double normal[3]); -``` -""" -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 +!!! note -""" - t8_vec_orthogonal_tripod(v1, v2, v3) + 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. -Compute an orthogonal coordinate system from a given vector. - -# Arguments -* `v1`:\\[in\\] 3D vector. -* `v2`:\\[out\\] 3D vector. -* `v3`:\\[out\\] 3D vector. -### Prototype -```c -static inline void t8_vec_orthogonal_tripod (const double v1[3], double v2[3], double v3[3]); -``` +| Field | Note | +| :------------------- | :----------------------------------------------------------------------------------- | +| num\\_vertices | the number of vertices that define the *embedding* of the forest (not the topology) | +| num\\_trees | the number of trees | +| num\\_edges | the number of edges that help define the topology | +| num\\_corners | the number of corners that help define the topology | +| vertices | an array of size (3 * *num_vertices*) | +| tree\\_to\\_vertex | embed each tree into ```c++ R^3 ``` for e.g. visualization (see p8est\\_vtk.h) | +| tree\\_attr\\_bytes | bytes per tree in tree\\_to\\_attr | +| tree\\_to\\_attr | not touched by p4est | +| tree\\_to\\_tree | (6 * *num_trees*) neighbors across faces | +| tree\\_to\\_face | (6 * *num_trees*) face to face+orientation (see description) | +| tree\\_to\\_edge | (12 * *num_trees*) or NULL (see description) | +| ett\\_offset | edge to offset in *edge_to_tree* and *edge_to_edge* | +| edge\\_to\\_tree | list of trees that meet at an edge | +| edge\\_to\\_edge | list of tree-edges+orientations that meet at an edge (see description) | +| tree\\_to\\_corner | (8 * *num_trees*) or NULL (see description) | +| ctt\\_offset | corner to offset in *corner_to_tree* and *corner_to_corner* | +| corner\\_to\\_tree | list of trees that meet at a corner | +| corner\\_to\\_corner | list of tree-corners that meet at a corner | """ -function t8_vec_orthogonal_tripod(v1, v2, v3) - @ccall libt8.t8_vec_orthogonal_tripod(v1::Ptr{Cdouble}, v2::Ptr{Cdouble}, v3::Ptr{Cdouble})::Cvoid +struct p8est_connectivity + num_vertices::p4est_topidx_t + num_trees::p4est_topidx_t + num_edges::p4est_topidx_t + num_corners::p4est_topidx_t + vertices::Ptr{Cdouble} + tree_to_vertex::Ptr{p4est_topidx_t} + tree_attr_bytes::Csize_t + tree_to_attr::Cstring + tree_to_tree::Ptr{p4est_topidx_t} + tree_to_face::Ptr{Int8} + tree_to_edge::Ptr{p4est_topidx_t} + ett_offset::Ptr{p4est_topidx_t} + edge_to_tree::Ptr{p4est_topidx_t} + edge_to_edge::Ptr{Int8} + tree_to_corner::Ptr{p4est_topidx_t} + ctt_offset::Ptr{p4est_topidx_t} + corner_to_tree::Ptr{p4est_topidx_t} + corner_to_corner::Ptr{Int8} end """ - t8_vec_swap(p1, p2) +This structure holds the 3D inter-tree connectivity information. Identification of arbitrary faces, edges and corners is possible. -Swap the components of two vectors. +The arrays tree\\_to\\_* are stored in z ordering. For corners the order wrt. zyx is 000 001 010 011 100 101 110 111. For faces the order is -x +x -y +y -z +z. They are allocated [0][0]..[0][N-1]..[num\\_trees-1][0]..[num\\_trees-1][N-1]. where N is 6 for tree and face, 8 for corner, 12 for edge. If a face is on the physical boundary it must connect to itself. -# Arguments -* `p1`:\\[in,out\\] A 3D vector. -* `p2`:\\[in,out\\] A 3D vector. -### Prototype -```c -static inline void t8_vec_swap (double p1[3], double p2[3]); -``` -""" -function t8_vec_swap(p1, p2) - @ccall libt8.t8_vec_swap(p1::Ptr{Cdouble}, p2::Ptr{Cdouble})::Cvoid -end +The values for tree\\_to\\_face are in 0..23 where ttf % 6 gives the face number and ttf / 6 the face orientation code. The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees in 0..5. Then the first face corner of the lower of my\\_face and other\\_face connects to a face corner numbered 0..3 in the higher of my\\_face and other\\_face. The face orientation is defined as this number. If my\\_face == other\\_face, treating either of both faces as the lower one leads to the same result. -# no prototype is found for this function at t8_version.h:70:1, please use with caution -""" - t8_get_package_string() +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. -Return the package string of t8code. This string has the format "t8 version\\_number". +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. -# Returns -The version string of t8code. -### Prototype -```c -const char* t8_get_package_string (); -``` +The arrays edge\\_to\\_* store a variable number of entries per edge. For edge e these are at position [ett\\_offset[e]]..[ett\\_offset[e+1]-1]. Their number for edge e is ett\\_offset[e+1] - ett\\_offset[e]. The entries encode all trees adjacent to edge e. The size of the edge\\_to\\_* arrays is num\\_ett = ett\\_offset[num\\_edges]. The edge\\_to\\_edge array holds values in 0..23, where the lower 12 indicate one edge orientation and the higher 12 the opposite edge orientation. + +The corners are stored when they connect trees that are not already edge or face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. + +The arrays corner\\_to\\_* store a variable number of entries per corner. For corner c these are at position [ctt\\_offset[c]]..[ctt\\_offset[c+1]-1]. Their number for corner c is ctt\\_offset[c+1] - ctt\\_offset[c]. The entries encode all trees adjacent to corner c. The size of the corner\\_to\\_* arrays is num\\_ctt = ctt\\_offset[num\\_corners]. + +The *\\_to\\_attr arrays may have arbitrary contents defined by the user. + +!!! note + + If a connectivity implies natural connections between trees that are edge neighbors without being face neighbors, these edges shall be encoded explicitly in the connectivity. If a connectivity implies natural connections between trees that are corner neighbors without being edge or face neighbors, these corners shall be encoded explicitly in the connectivity. """ -function t8_get_package_string() - @ccall libt8.t8_get_package_string()::Cstring -end +const p8est_connectivity_t = p8est_connectivity -# no prototype is found for this function at t8_version.h:76:1, please use with caution """ - t8_get_version_number() + p8est_connectivity_memory_used(conn) -Return the version number of t8code as a string. +Calculate memory usage of a connectivity structure. +# Arguments +* `conn`:\\[in\\] Connectivity structure. # Returns -The version number of t8code as a string. +Memory used in bytes. ### Prototype ```c -const char* t8_get_version_number (); +size_t p8est_connectivity_memory_used (p8est_connectivity_t * conn); ``` """ -function t8_get_version_number() - @ccall libt8.t8_get_version_number()::Cstring +function p8est_connectivity_memory_used(conn) + @ccall libt8.p8est_connectivity_memory_used(conn::Ptr{p8est_connectivity_t})::Csize_t end -# no prototype is found for this function at t8_version.h:82:1, please use with caution """ - t8_get_version_point_string() + p8est_edge_transform_t -Return the version point string. +Generic interface for transformations between a tree and any of its edge -# Returns -The version point point string. -### Prototype -```c -const char* t8_get_version_point_string (); -``` +| Field | Note | +| :------ | :--------------------------------- | +| ntree | The number of the tree | +| nedge | The number of the edge | +| naxis | The 3 edge coordinate axes | +| nflip | The orientation of the edge | +| corners | The corners connected to the edge | """ -function t8_get_version_point_string() - @ccall libt8.t8_get_version_point_string()::Cstring +struct p8est_edge_transform_t + ntree::p4est_topidx_t + nedge::Int8 + naxis::NTuple{3, Int8} + nflip::Int8 + corners::Int8 end -# no prototype is found for this function at t8_version.h:88:1, please use with caution """ - t8_get_version_major() + p8est_edge_info_t -Return the major version number of t8code. +Information about the neighbors of an edge -# Returns -The major version number of t8code. -### Prototype -```c -int t8_get_version_major (); -``` +| Field | Note | +| :---------------- | :---------------------------------------------- | +| iedge | The information of the edge | +| edge\\_transforms | The array of neighbors of the originating edge | """ -function t8_get_version_major() - @ccall libt8.t8_get_version_major()::Cint +struct p8est_edge_info_t + iedge::Int8 + edge_transforms::sc_array_t end -# no prototype is found for this function at t8_version.h:94:1, please use with caution """ - t8_get_version_minor() + p8est_corner_transform_t -Return the minor version number of t8code. +Generic interface for transformations between a tree and any of its corner -# Returns -The minor version number of t8code. -### Prototype -```c -int t8_get_version_minor (); -``` +| Field | Note | +| :------ | :------------------------ | +| ntree | The number of the tree | +| ncorner | The number of the corner | """ -function t8_get_version_minor() - @ccall libt8.t8_get_version_minor()::Cint +struct p8est_corner_transform_t + ntree::p4est_topidx_t + ncorner::Int8 end -# no prototype is found for this function at t8_version.h:104:1, please use with caution """ - t8_get_version_patch() - -Return the patch version number of t8code. - -!!! note + p8est_corner_info_t +Information about the neighbors of a corner -# Returns -The patch version number of t8code. negative on error. -### Prototype -```c -int t8_get_version_patch (); -``` +| Field | Note | +| :------------------ | :------------------------------------------------ | +| icorner | The number of the originating corner | +| corner\\_transforms | The array of neighbors of the originating corner | """ -function t8_get_version_patch() - @ccall libt8.t8_get_version_patch()::Cint -end - -@cenum t8_vtk_data_type_t::UInt32 begin - T8_VTK_SCALAR = 0 - T8_VTK_VECTOR = 1 +struct p8est_corner_info_t + icorner::p4est_topidx_t + corner_transforms::sc_array_t end """ - t8_vtk_data_field_t + p8est_neighbor_transform_t -| Field | Note | -| :---------- | :----------------------------------------- | -| type | Describes of which type the data array is | -| description | String that describes the data. | +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 t8_vtk_data_field_t - type::t8_vtk_data_type_t - description::NTuple{8192, Cchar} - data::Ptr{Cdouble} +struct p8est_neighbor_transform_t + neighbor_type::p8est_connect_type_t + neighbor::p4est_topidx_t + index_self::Int8 + index_neighbor::Int8 + perm::NTuple{3, Int8} + sign::NTuple{3, Int8} + origin_self::NTuple{3, p4est_qcoord_t} + origin_neighbor::NTuple{3, p4est_qcoord_t} end """ - t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) + p8est_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 -int t8_write_pvtu (const char *filename, int num_procs, int write_tree, int write_rank, int write_level, int write_id, int num_data, t8_vtk_data_field_t *data); +void p8est_neighbor_transform_coordinates (const p8est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P8EST_DIM], p4est_qcoord_t neigh_coords[P8EST_DIM]); ``` """ -function t8_write_pvtu(filename, num_procs, write_tree, write_rank, write_level, write_id, num_data, data) - @ccall libt8.t8_write_pvtu(filename::Cstring, num_procs::Cint, write_tree::Cint, write_rank::Cint, write_level::Cint, write_id::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function p8est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + @ccall libt8.p8est_neighbor_transform_coordinates(nt::Ptr{p8est_neighbor_transform_t}, self_coords::Ptr{p4est_qcoord_t}, neigh_coords::Ptr{p4est_qcoord_t})::Cvoid end """ - getdelim(lineptr, n, delimiter, stream) + p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + +Transform from neighbor's coordinate system to self's coordinate system. +# Arguments +* `nt`:\\[in\\] A neighbor transform. +* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. +* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. ### Prototype ```c -static ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream); +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 getdelim(lineptr, n, delimiter, stream) - @ccall libt8.getdelim(lineptr::Ptr{Cstring}, n::Ptr{Cint}, delimiter::Cint, stream::Ptr{Cint})::Cint +function p8est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + @ccall libt8.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 """ - getline(lineptr, n, stream) + p8est_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\\] 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 -static ssize_t getline (char **lineptr, size_t *n, FILE *stream); +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 getline(lineptr, n, stream) - @ccall libt8.getline(lineptr::Ptr{Cstring}, n::Ptr{Cint}, stream::Ptr{Cint})::Cint +function p8est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + @ccall libt8.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 """ - strsep(stringp, delim) + p8est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) -Extract token from string up to a given delimiter. +Determine the owning tree for a coordinate and transform it there. -For a full description see https://linux.die.net/man/3/[`strsep`](@ref) +On a boundary between trees, different coordinate systems meet. A coordinate on a tree boundary face, edge, or corner generated from the perspective of a specific tree may be transformed into any other touching tree's coordinate system and still refer to the same point in the mesh. +To uniquely identify a coordinate, this function identifies the lowest numbered tree touching this coordinate and transforms the coordinate into that system. The result can be used e. g. in topology hash tables. + +# Arguments +* `conn`:\\[in\\] A valid connectivity. +* `treeid`:\\[in\\] The original tree index for this coordinate tuple. +* `coords`:\\[in\\] A valid coordinate 2-tuple relative to *treeid*. +* `treeid_out`:\\[out\\] The lowest tree index touching the coordinate. +* `coords_out`:\\[out\\] The input coordinates, if necessary after transformation into the system of the lowest numbered tree, returned in *treeid_out*. ### Prototype ```c -static char * strsep (char **stringp, const char *delim); +void p8est_connectivity_coordinates_canonicalize (p8est_connectivity_t *conn, p4est_topidx_t treeid, const p4est_qcoord_t coords[], p4est_topidx_t *treeid_out, p4est_qcoord_t coords_out[]); ``` """ -function strsep(stringp, delim) - @ccall libt8.strsep(stringp::Ptr{Cstring}, delim::Cstring)::Cstring +function p8est_connectivity_coordinates_canonicalize(conn, treeid, coords, treeid_out, coords_out) + @ccall libt8.p8est_connectivity_coordinates_canonicalize(conn::Ptr{p8est_connectivity_t}, treeid::p4est_topidx_t, coords::Ptr{p4est_qcoord_t}, treeid_out::Ptr{p4est_topidx_t}, coords_out::Ptr{p4est_qcoord_t})::Cvoid end """ - t8_cmesh_copy(cmesh, cmesh_from, comm) + p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) -### Prototype -```c -void t8_cmesh_copy (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, sc_MPI_Comm comm); -``` -""" -function t8_cmesh_copy(cmesh, cmesh_from, comm) - @ccall libt8.t8_cmesh_copy(cmesh::t8_cmesh_t, cmesh_from::t8_cmesh_t, comm::MPI_Comm)::Cvoid -end - -""" - sc_io_read(mpifile, ptr, zcount, t, errmsg) - -### Prototype -```c -void sc_io_read (sc_MPI_File mpifile, void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); -``` -""" -function sc_io_read(mpifile, ptr, zcount, t, errmsg) - @ccall libsc.sc_io_read(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::MPI_Datatype, errmsg::Cstring)::Cvoid -end - -""" - sc_io_write(mpifile, ptr, zcount, t, errmsg) - -### Prototype -```c -void sc_io_write (sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg); -``` -""" -function sc_io_write(mpifile, ptr, zcount, t, errmsg) - @ccall libsc.sc_io_write(mpifile::MPI_File, ptr::Ptr{Cvoid}, zcount::Csize_t, t::MPI_Datatype, errmsg::Cstring)::Cvoid -end - -"""Typedef for quadrant coordinates.""" -const p4est_qcoord_t = Int32 - -"""Typedef for counting topological entities (trees, tree vertices).""" -const p4est_topidx_t = Int32 - -"""Typedef for processor-local indexing of quadrants and nodes.""" -const p4est_locidx_t = Int32 - -"""Typedef for globally unique indexing of quadrants.""" -const p4est_gloidx_t = Int64 - -""" - sc_io_error_t - -Error values for io. - -| Enumerator | Note | -| :---------------------- | :--------------------------------------------------------------------------- | -| SC\\_IO\\_ERROR\\_NONE | The value of zero means no error. | -| SC\\_IO\\_ERROR\\_FATAL | The io object is now dysfunctional. | -| SC\\_IO\\_ERROR\\_AGAIN | Another io operation may resolve it. The function just returned was a noop. | -""" -@cenum sc_io_error_t::Int32 begin - SC_IO_ERROR_NONE = 0 - SC_IO_ERROR_FATAL = -1 - SC_IO_ERROR_AGAIN = -2 -end - -""" - sc_io_mode_t - -The I/O mode for writing using sc_io_sink. - -| Enumerator | Note | -| :---------------------- | :--------------------------- | -| SC\\_IO\\_MODE\\_WRITE | Semantics as "w" in fopen. | -| SC\\_IO\\_MODE\\_APPEND | Semantics as "a" in fopen. | -| SC\\_IO\\_MODE\\_LAST | Invalid entry to close list | -""" -@cenum sc_io_mode_t::UInt32 begin - SC_IO_MODE_WRITE = 0 - SC_IO_MODE_APPEND = 1 - SC_IO_MODE_LAST = 2 -end - -""" - sc_io_encode_t - -Enum to specify encoding for sc_io_sink and sc_io_source. - -| Enumerator | Note | -| :---------------------- | :--------------------------- | -| SC\\_IO\\_ENCODE\\_NONE | No encoding | -| SC\\_IO\\_ENCODE\\_LAST | Invalid entry to close list | -""" -@cenum sc_io_encode_t::UInt32 begin - SC_IO_ENCODE_NONE = 0 - SC_IO_ENCODE_LAST = 1 -end - -""" - sc_io_type_t - -The type of I/O operation sc_io_sink and sc_io_source. - -| Enumerator | Note | -| :------------------------ | :------------------------------- | -| SC\\_IO\\_TYPE\\_BUFFER | Write to a buffer | -| SC\\_IO\\_TYPE\\_FILENAME | Write to a file to be opened | -| SC\\_IO\\_TYPE\\_FILEFILE | Write to an already opened file | -| SC\\_IO\\_TYPE\\_LAST | Invalid entry to close list | -""" -@cenum sc_io_type_t::UInt32 begin - SC_IO_TYPE_BUFFER = 0 - SC_IO_TYPE_FILENAME = 1 - SC_IO_TYPE_FILEFILE = 2 - SC_IO_TYPE_LAST = 3 -end - -""" - sc_io_sink - -A generic data sink. - -| Field | Note | -| :------------- | :---------------------------------------------------- | -| iotype | type of the I/O operation | -| mode | write semantics | -| encode | encoding of data | -| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | -| buffer\\_bytes | distinguish from array elements | -| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | -| bytes\\_in | input bytes count | -| bytes\\_out | written bytes count | -| is\\_eof | Have we reached the end of file? | -""" -struct sc_io_sink - iotype::sc_io_type_t - mode::sc_io_mode_t - encode::sc_io_encode_t - buffer::Ptr{sc_array_t} - buffer_bytes::Csize_t - file::Ptr{Libc.FILE} - bytes_in::Csize_t - bytes_out::Csize_t - is_eof::Cint -end - -"""A generic data sink.""" -const sc_io_sink_t = sc_io_sink - -""" - sc_io_source - -A generic data source. - -| Field | Note | -| :-------------- | :---------------------------------------------------- | -| iotype | type of the I/O operation | -| encode | encoding of data | -| buffer | buffer for the iotype SC_IO_TYPE_BUFFER | -| buffer\\_bytes | distinguish from array elements | -| file | file pointer for iotype unequal to SC_IO_TYPE_BUFFER | -| bytes\\_in | input bytes count | -| bytes\\_out | read bytes count | -| is\\_eof | Have we reached the end of file? | -| mirror | if activated, a sink to store the data | -| mirror\\_buffer | if activated, the buffer for the mirror | -""" -struct sc_io_source - iotype::sc_io_type_t - encode::sc_io_encode_t - buffer::Ptr{sc_array_t} - buffer_bytes::Csize_t - file::Ptr{Libc.FILE} - bytes_in::Csize_t - bytes_out::Csize_t - is_eof::Cint - mirror::Ptr{sc_io_sink_t} - mirror_buffer::Ptr{sc_array_t} -end - -"""A generic data source.""" -const sc_io_source_t = sc_io_source - -""" - sc_io_open_mode_t - -Open modes for sc_io_open - -| Enumerator | Note | -| :----------------------- | :------------------------------------------------------------------------------------------------------------------ | -| SC\\_IO\\_READ | open a file in read-only mode | -| SC\\_IO\\_WRITE\\_CREATE | open a file in write-only mode; if the file exists, the file will be truncated to length zero and then overwritten | -| SC\\_IO\\_WRITE\\_APPEND | append to an already existing file | -""" -@cenum sc_io_open_mode_t::UInt32 begin - SC_IO_READ = 0 - SC_IO_WRITE_CREATE = 1 - SC_IO_WRITE_APPEND = 2 -end - -# automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_io_sink_new(iotype, iomode, ioencode, va_list...) - :(@ccall(libsc.sc_io_sink_new(iotype::Cint, iomode::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_sink_t})) - end - -""" - sc_io_sink_destroy(sink) - -Free data sink. Calls [`sc_io_sink_complete`](@ref) and discards the final counts. Errors from complete lead to SC\\_IO\\_ERROR\\_FATAL returned from this function. Call [`sc_io_sink_complete`](@ref) yourself if bytes\\_out is of interest. - -# Arguments -* `sink`:\\[in,out\\] The sink object to complete and free. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_sink_destroy (sc_io_sink_t * sink); -``` -""" -function sc_io_sink_destroy(sink) - @ccall libsc.sc_io_sink_destroy(sink::Ptr{sc_io_sink_t})::Cint -end - -""" - sc_io_sink_destroy_null(sink) - -Free data sink and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_sink_destroy. - -# Arguments -* `sink`:\\[in,out\\] Non-NULL pointer to sink pointer. The sink pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_sink, which is passed to sc_io_sink_destroy, and the sink pointer is set to NULL afterwards. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_sink_destroy_null (sc_io_sink_t ** sink); -``` -""" -function sc_io_sink_destroy_null(sink) - @ccall libsc.sc_io_sink_destroy_null(sink::Ptr{Ptr{sc_io_sink_t}})::Cint -end - -""" - sc_io_sink_write(sink, data, bytes_avail) - -Write data to a sink. Data may be buffered and sunk in a later call. The internal counters sink->bytes\\_in and sink->bytes\\_out are updated. +Transform a corner across one of the adjacent faces into a neighbor tree. It expects a face permutation index that has been precomputed. # 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. +* `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 -0 on success, nonzero on error. +The corner number in 0..7 seen from the other face. ### Prototype ```c -int sc_io_sink_write (sc_io_sink_t * sink, const void *data, size_t bytes_avail); +int p8est_connectivity_face_neighbor_corner_set (int c, int f, int nf, int set); ``` """ -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 p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) + @ccall libt8.p8est_connectivity_face_neighbor_corner_set(c::Cint, f::Cint, nf::Cint, set::Cint)::Cint end """ - sc_io_sink_complete(sink, bytes_in, bytes_out) + p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) -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. +Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. # Arguments -* `sink`:\\[in,out\\] The sink object to write to. -* `bytes_in`:\\[in,out\\] Bytes received since the last new or complete call. May be NULL. -* `bytes_out`:\\[in,out\\] Bytes written since the last new or complete call. May be NULL. -# Returns -0 if completed, nonzero on error. -### Prototype -```c -int sc_io_sink_complete (sc_io_sink_t * sink, size_t *bytes_in, size_t *bytes_out); -``` -""" -function sc_io_sink_complete(sink, bytes_in, bytes_out) - @ccall libsc.sc_io_sink_complete(sink::Ptr{sc_io_sink_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint -end - -""" - sc_io_sink_align(sink, bytes_align) - -Align sink to a byte boundary by writing zeros. - -# Arguments -* `sink`:\\[in,out\\] The sink object to align. -* `bytes_align`:\\[in\\] Byte boundary. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_sink_align (sc_io_sink_t * sink, size_t bytes_align); -``` -""" -function sc_io_sink_align(sink, bytes_align) - @ccall libsc.sc_io_sink_align(sink::Ptr{sc_io_sink_t}, bytes_align::Csize_t)::Cint -end - -# automatic type deduction for variadic arguments may not be what you want, please use with caution -@generated function sc_io_source_new(iotype, ioencode, va_list...) - :(@ccall(libsc.sc_io_source_new(iotype::Cint, ioencode::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_io_source_t})) - end - -""" - sc_io_source_destroy(source) - -Free data source. Calls [`sc_io_source_complete`](@ref) and requires it to return no error. This is to avoid discarding buffered data that has not been passed to read. - -# Arguments -* `source`:\\[in,out\\] The source object to free. -# Returns -0 on success. Nonzero if an error is encountered or is\\_complete returns one. -### Prototype -```c -int sc_io_source_destroy (sc_io_source_t * source); -``` -""" -function sc_io_source_destroy(source) - @ccall libsc.sc_io_source_destroy(source::Ptr{sc_io_source_t})::Cint -end - -""" - sc_io_source_destroy_null(source) - -Free data source and NULL the pointer to it. Except for the handling of the pointer argument, the behavior is the same as for sc_io_source_destroy. - -# Arguments -* `source`:\\[in,out\\] Non-NULL pointer to source pointer. The source pointer may be NULL, in which case this function does nothing successfully, or a valid sc_io_source, which is passed to sc_io_source_destroy, and the source pointer is set to NULL afterwards. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_destroy_null (sc_io_source_t ** source); -``` -""" -function sc_io_source_destroy_null(source) - @ccall libsc.sc_io_source_destroy_null(source::Ptr{Ptr{sc_io_source_t}})::Cint -end - -""" - sc_io_source_read(source, data, bytes_avail, bytes_out) - -Read data from a source. The internal counters source->bytes\\_in and source->bytes\\_out are updated. Data is read until the data buffer has not enough room anymore, or source becomes empty. It is possible that data already read internally remains in the source object for the next call. Call [`sc_io_source_complete`](@ref) and check its return value to find out. Returns an error if bytes\\_out is NULL and less than bytes\\_avail are read. - -# Arguments -* `source`:\\[in,out\\] The source object to read from. -* `data`:\\[in\\] Data buffer for reading from source. If NULL the output data will be ignored and we seek forward in the input. -* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. -* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. If this condition is not met, return an error. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_read (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); -``` -""" -function sc_io_source_read(source, data, bytes_avail, bytes_out) - @ccall libsc.sc_io_source_read(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint -end - -""" - sc_io_source_complete(source, bytes_in, bytes_out) - -Determine whether all data buffered from source has been returned by read. If it returns SC\\_IO\\_ERROR\\_AGAIN, another [`sc_io_source_read`](@ref) is required. If the call returns no error, the internal counters source->bytes\\_in and source->bytes\\_out are returned to the caller if requested, and reset to 0. The internal state of the source is not changed otherwise. It is legal to continue reading from the source hereafter. - -# Arguments -* `source`:\\[in,out\\] The source object to read from. -* `bytes_in`:\\[in,out\\] If not NULL and true is returned, the total size of the data sourced. -* `bytes_out`:\\[in,out\\] If not NULL and true is returned, total bytes passed out by source\\_read. -# Returns -SC\\_IO\\_ERROR\\_AGAIN if buffered data remaining. Otherwise return ERROR\\_NONE and reset counters. -### Prototype -```c -int sc_io_source_complete (sc_io_source_t * source, size_t *bytes_in, size_t *bytes_out); -``` -""" -function sc_io_source_complete(source, bytes_in, bytes_out) - @ccall libsc.sc_io_source_complete(source::Ptr{sc_io_source_t}, bytes_in::Ptr{Csize_t}, bytes_out::Ptr{Csize_t})::Cint -end - -""" - sc_io_source_align(source, bytes_align) - -Align source to a byte boundary by skipping. - -# Arguments -* `source`:\\[in,out\\] The source object to align. -* `bytes_align`:\\[in\\] Byte boundary. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_align (sc_io_source_t * source, size_t bytes_align); -``` -""" -function sc_io_source_align(source, bytes_align) - @ccall libsc.sc_io_source_align(source::Ptr{sc_io_source_t}, bytes_align::Csize_t)::Cint -end - -""" - sc_io_source_activate_mirror(source) - -Activate a buffer that mirrors (i.e., stores) the data that was read. - -# Arguments -* `source`:\\[in,out\\] The source object to activate mirror in. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_activate_mirror (sc_io_source_t * source); -``` -""" -function sc_io_source_activate_mirror(source) - @ccall libsc.sc_io_source_activate_mirror(source::Ptr{sc_io_source_t})::Cint -end - -""" - sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) - -Read data from the source's mirror. Same behaviour as [`sc_io_source_read`](@ref). - -# Arguments -* `source`:\\[in,out\\] The source object to read mirror data from. -* `data`:\\[in\\] Data buffer for reading from source's mirror. If NULL the output data will be thrown away. -* `bytes_avail`:\\[in\\] Number of bytes available in data buffer. -* `bytes_out`:\\[in,out\\] If not NULL, byte count read into data buffer. Otherwise, requires to read exactly bytes\\_avail. -# Returns -0 on success, nonzero on error. -### Prototype -```c -int sc_io_source_read_mirror (sc_io_source_t * source, void *data, size_t bytes_avail, size_t *bytes_out); -``` -""" -function sc_io_source_read_mirror(source, data, bytes_avail, bytes_out) - @ccall libsc.sc_io_source_read_mirror(source::Ptr{sc_io_source_t}, data::Ptr{Cvoid}, bytes_avail::Csize_t, bytes_out::Ptr{Csize_t})::Cint -end - -""" - sc_io_file_save(filename, buffer) - -Save a buffer to a file in one call. This function performs error checking and always returns cleanly. - -# Arguments -* `filename`:\\[in\\] Name of the file to save. -* `buffer`:\\[in\\] An array of element size 1 and arbitrary contents, which are written to the file. -# Returns -0 on success, -1 on error. -### Prototype -```c -int sc_io_file_save (const char *filename, sc_array_t * buffer); -``` -""" -function sc_io_file_save(filename, buffer) - @ccall libsc.sc_io_file_save(filename::Cstring, buffer::Ptr{sc_array_t})::Cint -end - -""" - sc_io_file_load(filename, buffer) - -Read a file into a buffer in one call. This function performs error checking and always returns cleanly. - -# Arguments -* `filename`:\\[in\\] Name of the file to load. -* `buffer`:\\[in,out\\] On input, an array (not a view) of element size 1 and arbitrary contents. On output and success, the complete file contents. On error, contents are undefined. -# Returns -0 on success, -1 on error. -### Prototype -```c -int sc_io_file_load (const char *filename, sc_array_t * buffer); -``` -""" -function sc_io_file_load(filename, buffer) - @ccall libsc.sc_io_file_load(filename::Cstring, buffer::Ptr{sc_array_t})::Cint -end - -""" - sc_io_encode(data, out) - -Encode a block of arbitrary data with the default sc\\_io format. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. - -Currently this function calls sc_io_encode_zlib with compression level Z\\_BEST\\_COMPRESSION (subject to change). Without zlib configured that function works uncompressed. - -The encoding method and input data size can be retrieved, optionally, from the encoded data by sc_io_decode_info. This function decodes the method as a character, which is 'z' for sc_io_encode_zlib. We reserve the characters A-C, d-z indefinitely. - -# Arguments -* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. -* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. -### Prototype -```c -void sc_io_encode (sc_array_t *data, sc_array_t *out); -``` -""" -function sc_io_encode(data, out) - @ccall libsc.sc_io_encode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t})::Cvoid -end - -""" - sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) - -Encode a block of arbitrary data, compressed, into an ASCII string. This is a two-stage process: zlib compress and then encode to base 64. The output is a NUL-terminated string of printable characters. - -We first compress the data into the zlib deflate format (RFC 1951). The compressor must use no preset dictionary (this is the default). If zlib is detected on configuration, we compress with the given level. If zlib is not detected, we write data equivalent to Z\\_NO\\_COMPRESSION. The status of zlib detection can be queried at compile time using #ifdef [`SC_HAVE_ZLIB`](@ref) or at run time using sc_have_zlib. Both types of result are readable by a standard zlib uncompress call. - -Secondly, we process the input data size as an 8-byte big-endian number, then the letter 'z', and then the zlib compressed data, concatenated, with a base 64 encoder. We break lines after 76 code characters. Each line break consists of two configurable but arbitrary bytes. The line breaks are considered part of the output data specification. The last line is terminated with the same line break and then a NUL. - -This routine can work in place or write to an output array. The corresponding decoder function is sc_io_decode. This function cannot crash unless out of memory. - -# Arguments -* `data`:\\[in,out\\] If *out* is NULL, we work in place. In this case, the array must on input have an element size of 1 byte, which is preserved. After reading all data from this array, it assumes the identity of the *out* argument below. Otherwise, this is a read-only argument that may have arbitrary element size. On input, all data in the array is used. -* `out`:\\[in,out\\] If not NULL, a valid array of element size 1. It must be resizable (not a view). We resize the array to the output data, which always includes a final terminating zero. -* `zlib_compression_level`:\\[in\\] Compression level between 0 (no compression) and 9 (best compression). The value -1 indicates some default level. -* `line_break_character`:\\[in\\] This character is arbitrary and specifies the first of two line break bytes. The second byte is always ''. -### Prototype -```c -void sc_io_encode_zlib (sc_array_t *data, sc_array_t *out, int zlib_compression_level, int line_break_character); -``` -""" -function sc_io_encode_zlib(data, out, zlib_compression_level, line_break_character) - @ccall libsc.sc_io_encode_zlib(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, zlib_compression_level::Cint, line_break_character::Cint)::Cvoid -end - -""" - sc_io_decode_info(data, original_size, format_char, re) - -Decode length and format of original input from encoded data. We expect at least 12 bytes of the format produced by sc_io_encode. No matter how much data has been encoded by it, this much is available. We decode the original data size and the character indicating the format. - -This function does not require zlib. It works with any well-defined data. - -Note that this function is not required before sc_io_decode. Calling this function on any result produced by sc_io_encode will succeed and report a legal format. This function cannot crash. - -# Arguments -* `data`:\\[in\\] This must be an array with element size 1. If it contains less than 12 code bytes we error out. It its first 12 bytes do not base 64 decode to 9 bytes we error out. We generally ignore the remaining data. -* `original_size`:\\[out\\] If not NULL and we do not error out, set to the original size as encoded in the data. -* `format_char`:\\[out\\] If not NULL and we do not error out, the ninth character of decoded data indicating the format. -* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. -# Returns -0 on success, negative value on error. -### Prototype -```c -int sc_io_decode_info (sc_array_t *data, size_t *original_size, char *format_char, void *re); -``` -""" -function sc_io_decode_info(data, original_size, format_char, re) - @ccall libsc.sc_io_decode_info(data::Ptr{sc_array_t}, original_size::Ptr{Csize_t}, format_char::Cstring, re::Ptr{Cvoid})::Cint -end - -""" - sc_io_decode(data, out, max_original_size, re) - -Decode a block of base 64 encoded compressed data. The base 64 data must contain two arbitrary bytes after every 76 code characters and also at the end of the last line if it is short, and then a final NUL character. This function does not require zlib but benefits for speed. - -This is a two-stage process: we decode the input from base 64 first. Then we extract the 8-byte big-endian original data size, the character 'z', and execute a zlib decompression on the remaining decoded data. This function detects malformed input by erroring out. - -If we should add another format in the future, the format character may be something else than 'z', as permitted by our specification. To this end, we reserve the characters A-C and d-z indefinitely. - -Any error condition is indicated by a negative return value. Possible causes for error are: - -- the input data string is not NUL-terminated - the first 12 characters of input do not decode properly - the input data is corrupt for decoding or decompression - the output data array has non-unit element size and the length of the output data is not divisible by the size - the output data would exceed the specified threshold - the output array is a view of insufficient length - -We also error out if the data requires a compression dictionary, which would be a violation of above encode format specification. - -The corresponding encode function is sc_io_encode. When passing an array as output, we resize it properly. This function cannot crash unless out of memory. - -# Arguments -* `data`:\\[in,out\\] If *out* is NULL, we work in place. In that case, output is written into this array after a suitable resize. Either way, we expect a NUL-terminated base 64 encoded string on input that has in turn been obtained by zlib compression. It must be in the exact format produced by sc_io_encode; please see documentation. The element size of the input array must be 1. -* `out`:\\[in,out\\] If not NULL, a valid array (may be a view). If NULL, the input array becomes the output. If the output array is a view and the output data larger than its view size, we error out. We expect commensurable element and data size and resize the output to fit exactly, which restores the original input passed to encoding. An output view array of matching size may be constructed using sc_io_decode_info. -* `max_original_size`:\\[in\\] If nonzero, this is the maximal data size that we will accept after uncompression. If exceeded, return a negative value. -* `re`:\\[in,out\\] Provided for error reporting, presently must be NULL. -# Returns -0 on success, negative on malformed input data or insufficient output space. -### Prototype -```c -int sc_io_decode (sc_array_t *data, sc_array_t *out, size_t max_original_size, void *re); -``` -""" -function sc_io_decode(data, out, max_original_size, re) - @ccall libsc.sc_io_decode(data::Ptr{sc_array_t}, out::Ptr{sc_array_t}, max_original_size::Csize_t, re::Ptr{Cvoid})::Cint -end - -""" - sc_vtk_write_binary(vtkfile, numeric_data, byte_length) - -This function writes numeric binary data in VTK base64 encoding. - -# Arguments -* `vtkfile`: Stream opened for writing. -* `numeric_data`: A pointer to a numeric data array. -* `byte_length`: The length of the data array in bytes. -# Returns -Returns 0 on success, -1 on file error. -### Prototype -```c -int sc_vtk_write_binary (FILE * vtkfile, char *numeric_data, size_t byte_length); -``` -""" -function sc_vtk_write_binary(vtkfile, numeric_data, byte_length) - @ccall libsc.sc_vtk_write_binary(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint -end - -""" - sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) - -This function writes numeric binary data in VTK compressed format. - -# Arguments -* `vtkfile`: Stream opened for writing. -* `numeric_data`: A pointer to a numeric data array. -* `byte_length`: The length of the data array in bytes. -# Returns -Returns 0 on success, -1 on file error. -### Prototype -```c -int sc_vtk_write_compressed (FILE * vtkfile, char *numeric_data, size_t byte_length); -``` -""" -function sc_vtk_write_compressed(vtkfile, numeric_data, byte_length) - @ccall libsc.sc_vtk_write_compressed(vtkfile::Ptr{Libc.FILE}, numeric_data::Cstring, byte_length::Csize_t)::Cint -end - -""" - sc_fopen(filename, mode, errmsg) - -Wrapper for fopen(3). We provide an additional argument that contains the error message. - -### Prototype -```c -FILE *sc_fopen (const char *filename, const char *mode, const char *errmsg); -``` -""" -function sc_fopen(filename, mode, errmsg) - @ccall libsc.sc_fopen(filename::Cstring, mode::Cstring, errmsg::Cstring)::Ptr{Libc.FILE} -end - -""" - sc_fwrite(ptr, size, nmemb, file, errmsg) - -Write memory content to a file. - -!!! note - - This function aborts on file errors. - -# Arguments -* `ptr`:\\[in\\] Data array to write to disk. -* `size`:\\[in\\] Size of one array member. -* `nmemb`:\\[in\\] Number of array members. -* `file`:\\[in,out\\] File pointer, must be opened for writing. -* `errmsg`:\\[in\\] Error message passed to `SC_CHECK_ABORT`. -### 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) - +* `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 -static inline p4est_gloidx_t p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs); +int p8est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); ``` """ -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_face_neighbor_face_corner(fc, f, nf, o) + @ccall libt8.p8est_connectivity_face_neighbor_face_corner(fc::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - p4est_version() + p8est_connectivity_face_neighbor_corner(c, f, nf, o) -Return the full version of p4est. +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 -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. +The number of the corner seen from the neighbor tree. ### Prototype ```c -const char *p4est_version (void); +int p8est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); ``` """ -function p4est_version() - @ccall libp4est.p4est_version()::Cstring +function p8est_connectivity_face_neighbor_corner(c, f, nf, o) + @ccall libt8.p8est_connectivity_face_neighbor_corner(c::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - p4est_version_major() + p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) -Return the major version of p4est. +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 -Return the major version of p4est. +The face edge number seen from the neighbor tree. ### Prototype ```c -int p4est_version_major (void); +int p8est_connectivity_face_neighbor_face_edge (int fe, int f, int nf, int o); ``` """ -function p4est_version_major() - @ccall libp4est.p4est_version_major()::Cint +function p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) + @ccall libt8.p8est_connectivity_face_neighbor_face_edge(fe::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - p4est_version_minor() + p8est_connectivity_face_neighbor_edge(e, f, nf, o) -Return the minor version of p4est. +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 -Return the minor version of p4est. +The edge's number seen from the neighbor. ### Prototype ```c -int p4est_version_minor (void); +int p8est_connectivity_face_neighbor_edge (int e, int f, int nf, int o); ``` """ -function p4est_version_minor() - @ccall libp4est.p4est_version_minor()::Cint +function p8est_connectivity_face_neighbor_edge(e, f, nf, o) + @ccall libt8.p8est_connectivity_face_neighbor_edge(e::Cint, f::Cint, nf::Cint, o::Cint)::Cint end """ - p4est_connect_type_t - -Characterize a type of adjacency. + p8est_connectivity_edge_neighbor_edge_corner(ec, o) -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. +Transform an edge corner across one of the adjacent edges into a neighbor tree. -| Enumerator | Note | -| :----------------------- | :--------------------------------- | -| P4EST\\_CONNECT\\_SELF | No balance whatsoever. | -| P4EST\\_CONNECT\\_FACE | Balance across faces only. | -| P4EST\\_CONNECT\\_ALMOST | = CORNER - 1. | -| P4EST\\_CONNECT\\_CORNER | Balance across faces and corners. | -| P4EST\\_CONNECT\\_FULL | = CORNER. | +# Arguments +* `ec`:\\[in\\] An edge corner number in 0..1. +* `o`:\\[in\\] The orientation of a tree boundary edge connection. +# Returns +The edge corner number seen from the other tree. +### Prototype +```c +int p8est_connectivity_edge_neighbor_edge_corner (int ec, int o); +``` """ -@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_edge_neighbor_edge_corner(ec, o) + @ccall libt8.p8est_connectivity_edge_neighbor_edge_corner(ec::Cint, o::Cint)::Cint end """ - p4est_connectivity_encode_t + p8est_connectivity_edge_neighbor_corner(c, e, ne, o) -Typedef for serialization method. +Transform a corner across one of the adjacent edges into a neighbor tree. This version expects the neighbor edge and orientation separately. -| Enumerator | Note | -| :--------------------------- | :-------------------------------- | -| P4EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | +# Arguments +* `c`:\\[in\\] A corner number in 0..7. +* `e`:\\[in\\] An edge 0..11 that touches the corner *c*. +* `ne`:\\[in\\] A neighbor edge that is on the other side of *e*. +* `o`:\\[in\\] The orientation between tree boundary edges *e* and *ne*. +# Returns +Corner number seen from the neighbor. +### Prototype +```c +int p8est_connectivity_edge_neighbor_corner (int c, int e, int ne, int o); +``` """ -@cenum p4est_connectivity_encode_t::UInt32 begin - P4EST_CONN_ENCODE_NONE = 0 - P4EST_CONN_ENCODE_LAST = 1 +function p8est_connectivity_edge_neighbor_corner(c, e, ne, o) + @ccall libt8.p8est_connectivity_edge_neighbor_corner(c::Cint, e::Cint, ne::Cint, o::Cint)::Cint end """ - p4est_connect_type_int(btype) + p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) -Convert the [`p4est_connect_type_t`](@ref) into a number. +Allocate a connectivity structure. The attribute fields are initialized to NULL. # Arguments -* `btype`:\\[in\\] The balance type to convert. +* `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 -Returns 1 or 2. +A connectivity structure with allocated arrays. ### Prototype ```c -int p4est_connect_type_int (p4est_connect_type_t btype); +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 p4est_connect_type_int(btype) - @ccall libp4est.p4est_connect_type_int(btype::p4est_connect_type_t)::Cint +function p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) + @ccall libt8.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_connect_type_string(btype) + p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) -Convert the [`p4est_connect_type_t`](@ref) into a const string. +Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. # Arguments -* `btype`:\\[in\\] The balance type to convert. +* `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 -Returns a pointer to a constant string. +The connectivity is checked for validity. ### Prototype ```c -const char *p4est_connect_type_string (p4est_connect_type_t btype); +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_connect_type_string(btype) - @ccall libp4est.p4est_connect_type_string(btype::p4est_connect_type_t)::Cstring +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 libt8.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_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. + p8est_connectivity_bcast(conn_in, root, comm) -| 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_bcast (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +``` """ -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_bcast(conn_in, root, comm) + @ccall libt8.p8est_connectivity_bcast(conn_in::Ptr{p8est_connectivity_t}, root::Cint, comm::MPI_Comm)::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. + p8est_connectivity_destroy(connectivity) -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. +Destroy a connectivity structure. Also destroy all attributes. -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]. +### Prototype +```c +void p8est_connectivity_destroy (p8est_connectivity_t * connectivity); +``` +""" +function p8est_connectivity_destroy(connectivity) + @ccall libt8.p8est_connectivity_destroy(connectivity::Ptr{p8est_connectivity_t})::Cvoid +end -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. We do not interpret them. +""" + p8est_connectivity_set_attr(conn, bytes_per_tree) -!!! note +Allocate or free the attribute fields in a connectivity. - 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. +# 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); +``` """ -const p4est_connectivity_t = p4est_connectivity +function p8est_connectivity_set_attr(conn, bytes_per_tree) + @ccall libt8.p8est_connectivity_set_attr(conn::Ptr{p8est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid +end """ - p4est_connectivity_memory_used(conn) + p8est_connectivity_is_valid(connectivity) -Calculate memory usage of a connectivity structure. +Examine a connectivity structure. -# Arguments -* `conn`:\\[in\\] Connectivity structure. # Returns -Memory used in bytes. +Returns true if structure is valid, false otherwise. ### Prototype ```c -size_t p4est_connectivity_memory_used (p4est_connectivity_t * conn); +int p8est_connectivity_is_valid (p8est_connectivity_t * connectivity); ``` """ -function p4est_connectivity_memory_used(conn) - @ccall libp4est.p4est_connectivity_memory_used(conn::Ptr{p4est_connectivity_t})::Csize_t +function p8est_connectivity_is_valid(connectivity) + @ccall libt8.p8est_connectivity_is_valid(connectivity::Ptr{p8est_connectivity_t})::Cint end """ - p4est_corner_transform_t + p8est_connectivity_is_equal(conn1, conn2) -Generic interface for transformations between a tree and any of its corner +Check two connectivity structures for equality. -| Field | Note | -| :------ | :------------------------ | -| ntree | The number of the tree | -| ncorner | The number of the corner | +# Returns +Returns true if structures are equal, false otherwise. +### Prototype +```c +int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); +``` """ -struct p4est_corner_transform_t - ntree::p4est_topidx_t - ncorner::Int8 +function p8est_connectivity_is_equal(conn1, conn2) + @ccall libt8.p8est_connectivity_is_equal(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint end """ - p4est_corner_info_t + p8est_connectivity_sink(conn, sink) -Information about the neighbors of a corner +Write connectivity to a sink object. -| Field | Note | -| :------------------ | :------------------------------------------------ | -| icorner | The number of the originating corner | -| corner\\_transforms | The array of neighbors of the originating corner | +# 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); +``` """ -struct p4est_corner_info_t - icorner::p4est_topidx_t - corner_transforms::sc_array_t +function p8est_connectivity_sink(conn, sink) + @ccall libt8.p8est_connectivity_sink(conn::Ptr{p8est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint end """ - p4est_neighbor_transform_t + p8est_connectivity_deflate(conn, code) -Generic interface for transformations between a tree and any of its neighbors +Allocate memory and store the connectivity information there. -| 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 +* `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); +``` """ -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_deflate(conn, code) + @ccall libt8.p8est_connectivity_deflate(conn::Ptr{p8est_connectivity_t}, code::p8est_connectivity_encode_t)::Ptr{sc_array_t} end """ - p4est_neighbor_transform_coordinates(nt, self_coords, neigh_coords) + p8est_connectivity_save(filename, connectivity) -Transform from self's coordinate system to neighbor's coordinate system. +Save a connectivity structure to disk. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `self_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `neigh_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `filename`:\\[in\\] Name of the file to write. +* `connectivity`:\\[in\\] Valid connectivity structure. +# Returns +Returns 0 on success, nonzero on file error. ### Prototype ```c -void p4est_neighbor_transform_coordinates (const p4est_neighbor_transform_t * nt, const p4est_qcoord_t self_coords[P4EST_DIM], p4est_qcoord_t neigh_coords[P4EST_DIM]); +int p8est_connectivity_save (const char *filename, p8est_connectivity_t * connectivity); ``` """ -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_save(filename, connectivity) + @ccall libt8.p8est_connectivity_save(filename::Cstring, connectivity::Ptr{p8est_connectivity_t})::Cint end """ - p4est_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) + p8est_connectivity_source(source) -Transform from neighbor's coordinate system to self's coordinate system. +Read connectivity from a source object. # Arguments -* `nt`:\\[in\\] A neighbor transform. -* `neigh_coords`:\\[in\\] Input quadrant coordinates in self coordinates. -* `self_coords`:\\[out\\] Coordinates transformed into neighbor coordinates. +* `source`:\\[in,out\\] The connectivity is read from this source. +# Returns +The newly created connectivity, or NULL on error. ### 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]); +p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source); ``` """ -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_connectivity_source(source) + @ccall libt8.p8est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) + p8est_connectivity_inflate(buffer) -Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects +Create new connectivity from a memory buffer. This function aborts on malloc errors. # 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. +* `buffer`:\\[in\\] The connectivity is created from this memory buffer. +# Returns +The newly created connectivity, or NULL on format error of the buffered connectivity data. ### Prototype ```c -void 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); +p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer); ``` """ -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_connectivity_inflate(buffer) + @ccall libt8.p8est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + p8est_connectivity_load(filename, bytes) -Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Load a connectivity structure from disk. # 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*. +* `filename`:\\[in\\] Name of the file to read. +* `bytes`:\\[out\\] Size in bytes of connectivity on disk or NULL. # Returns -The face corner number relative to the neighbor's face. +Returns valid connectivity, or NULL on file error. ### Prototype ```c -int p4est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); +p8est_connectivity_t *p8est_connectivity_load (const char *filename, size_t *bytes); ``` """ -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_connectivity_load(filename, bytes) + @ccall libt8.p8est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_face_neighbor_corner(c, f, nf, o) + p8est_connectivity_new_unitcube() -Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Create a connectivity structure for the unit cube. -# 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); +p8est_connectivity_t *p8est_connectivity_new_unitcube (void); ``` """ -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_connectivity_new_unitcube() + @ccall libt8.p8est_connectivity_new_unitcube()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_new(num_vertices, num_trees, num_corners, num_ctt) + p8est_connectivity_new_periodic() -Allocate a connectivity structure. The attribute fields are initialized to NULL. +Create a connectivity structure for an all-periodic unit cube. -# 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); +p8est_connectivity_t *p8est_connectivity_new_periodic (void); ``` """ -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_new_periodic() + @ccall libt8.p8est_connectivity_new_periodic()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_new_copy(num_vertices, num_trees, num_corners, vertices, ttv, ttt, ttf, ttc, coff, ctt, ctc) + p8est_connectivity_new_rotwrap() -Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. +Create a connectivity structure for a mostly periodic unit cube. The left and right faces are identified, and bottom and top rotated. Front and back are not identified. -# Arguments -* `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); +p8est_connectivity_t *p8est_connectivity_new_rotwrap (void); ``` """ -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_new_rotwrap() + @ccall libt8.p8est_connectivity_new_rotwrap()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_bcast(conn_in, root, comm) + p8est_connectivity_new_drop() + +Create a connectivity structure for a five-trees geometry with a hole. The geometry is a 3D extrusion of the two drop example, and covers [0, 3]*[0, 2]*[0, 3]. The additional dimension is Y. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_bcast (p4est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +p8est_connectivity_t *p8est_connectivity_new_drop (void); ``` """ -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_new_drop() + @ccall libt8.p8est_connectivity_new_drop()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_destroy(connectivity) + p8est_connectivity_new_twocubes() -Destroy a connectivity structure. Also destroy all attributes. +Create a connectivity structure that contains two cubes. ### Prototype ```c -void p4est_connectivity_destroy (p4est_connectivity_t * connectivity); +p8est_connectivity_t *p8est_connectivity_new_twocubes (void); ``` """ -function p4est_connectivity_destroy(connectivity) - @ccall libp4est.p4est_connectivity_destroy(connectivity::Ptr{p4est_connectivity_t})::Cvoid +function p8est_connectivity_new_twocubes() + @ccall libt8.p8est_connectivity_new_twocubes()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_set_attr(conn, bytes_per_tree) + p8est_connectivity_new_twotrees(l_face, r_face, orientation) -Allocate or free the attribute fields in a connectivity. +Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way. # 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. +* `l_face`:\\[in\\] index of left face +* `r_face`:\\[in\\] index of right face +* `orientation`:\\[in\\] orientation of trees w.r.t. each other ### Prototype ```c -void p4est_connectivity_set_attr (p4est_connectivity_t * conn, size_t bytes_per_tree); +p8est_connectivity_t *p8est_connectivity_new_twotrees (int l_face, int r_face, int orientation); ``` """ -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_new_twotrees(l_face, r_face, orientation) + @ccall libt8.p8est_connectivity_new_twotrees(l_face::Cint, r_face::Cint, orientation::Cint)::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_is_valid(connectivity) + p8est_connectivity_new_twowrap() -Examine a connectivity structure. +Create a connectivity structure that contains two cubes where the two far ends are identified periodically. -# Returns -Returns true if structure is valid, false otherwise. ### Prototype ```c -int p4est_connectivity_is_valid (p4est_connectivity_t * connectivity); +p8est_connectivity_t *p8est_connectivity_new_twowrap (void); ``` """ -function p4est_connectivity_is_valid(connectivity) - @ccall libp4est.p4est_connectivity_is_valid(connectivity::Ptr{p4est_connectivity_t})::Cint +function p8est_connectivity_new_twowrap() + @ccall libt8.p8est_connectivity_new_twowrap()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_is_equal(conn1, conn2) + p8est_connectivity_new_rotcubes() -Check two connectivity structures for equality. +Create a connectivity structure that contains a few cubes. These are rotated against each other to stress the topology routines. -# Returns -Returns true if structures are equal, false otherwise. ### Prototype ```c -int p4est_connectivity_is_equal (p4est_connectivity_t * conn1, p4est_connectivity_t * conn2); +p8est_connectivity_t *p8est_connectivity_new_rotcubes (void); ``` """ -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_connectivity_new_rotcubes() + @ccall libt8.p8est_connectivity_new_rotcubes()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_sink(conn, sink) + p8est_connectivity_new_pillow() -Write connectivity to a sink object. +Create a connectivity structure for two trees on top of each other. This connectivity is meant to be used with p8est_geometry_new_pillow to map a spherical shell. -# Arguments -* `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); +p8est_connectivity_t *p8est_connectivity_new_pillow (void); ``` """ -function p4est_connectivity_sink(conn, sink) - @ccall libp4est.p4est_connectivity_sink(conn::Ptr{p4est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint +function p8est_connectivity_new_pillow() + @ccall libt8.p8est_connectivity_new_pillow()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_deflate(conn, code) + p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) -Allocate memory and store the connectivity information there. +An m by n by p array with periodicity in x, y, and z if periodic\\_a, periodic\\_b, and periodic\\_c are true, respectively. -# Arguments -* `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); +p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c); ``` """ -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_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) + @ccall libt8.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_save(filename, connectivity) - -Save a connectivity structure to disk. + p8est_connectivity_new_shell() + +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 -* `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); +p8est_connectivity_t *p8est_connectivity_new_shell (void); ``` """ -function p4est_connectivity_save(filename, connectivity) - @ccall libp4est.p4est_connectivity_save(filename::Cstring, connectivity::Ptr{p4est_connectivity_t})::Cint +function p8est_connectivity_new_shell() + @ccall libt8.p8est_connectivity_new_shell()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_source(source) + p8est_connectivity_new_sphere() -Read connectivity from a source object. +Create a connectivity structure that builds a solid sphere. It is made up of two layers and a cube in the center. This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). -# Arguments -* `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); +p8est_connectivity_t *p8est_connectivity_new_sphere (void); ``` """ -function p4est_connectivity_source(source) - @ccall libp4est.p4est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p4est_connectivity_t} +function p8est_connectivity_new_sphere() + @ccall libt8.p8est_connectivity_new_sphere()::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_inflate(buffer) + p8est_connectivity_new_torus(nSegments) -Create new connectivity from a memory buffer. This function aborts on malloc errors. +Create a connectivity structure that builds a revolution torus. + +This connectivity reuses vertices and relies on a geometry transformation. It is thus not suitable for [`p8est_connectivity_complete`](@ref). + +This connectivity reuses ideas from disk2d connectivity. More precisely the torus is divided into segments around the revolution axis, each segments is made of 5 trees (Ă  la disk2d). The total number of trees if 5 times the number of segments. + +This connectivity is meant to be used with p8est_geometry_new_torus # Arguments -* `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. +* `nSegments`:\\[in\\] number of trees along the great circle ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_inflate (sc_array_t * buffer); +p8est_connectivity_t *p8est_connectivity_new_torus (int nSegments); ``` """ -function p4est_connectivity_inflate(buffer) - @ccall libp4est.p4est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p4est_connectivity_t} +function p8est_connectivity_new_torus(nSegments) + @ccall libt8.p8est_connectivity_new_torus(nSegments::Cint)::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_load(filename, bytes) + p8est_connectivity_new_byname(name) -Load a connectivity structure from disk. +Create connectivity structure from predefined catalogue. # Arguments -* `filename`:\\[in\\] Name of the file to read. -* `bytes`:\\[in,out\\] Size in bytes of connectivity on disk or NULL. +* `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 -Returns valid connectivity, or NULL on file error. +An initialized connectivity if name is defined, NULL else. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_load (const char *filename, size_t *bytes); +p8est_connectivity_t *p8est_connectivity_new_byname (const char *name); ``` """ -function p4est_connectivity_load(filename, bytes) - @ccall libp4est.p4est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p4est_connectivity_t} +function p8est_connectivity_new_byname(name) + @ccall libt8.p8est_connectivity_new_byname(name::Cstring)::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_new_unitsquare() + p8est_connectivity_refine(conn, num_per_dim) -Create a connectivity structure for the unit square. +Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. +# Arguments +* `conn`:\\[in\\] A valid connectivity +* `num_per_dim`:\\[in\\] The number of new trees in each direction. Must use no more than P8EST_OLD_QMAXLEVEL bits. +# Returns +a refined connectivity. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_unitsquare (void); +p8est_connectivity_t *p8est_connectivity_refine (p8est_connectivity_t * conn, int num_per_dim); ``` """ -function p4est_connectivity_new_unitsquare() - @ccall libp4est.p4est_connectivity_new_unitsquare()::Ptr{p4est_connectivity_t} +function p8est_connectivity_refine(conn, num_per_dim) + @ccall libt8.p8est_connectivity_refine(conn::Ptr{p8est_connectivity_t}, num_per_dim::Cint)::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_new_periodic() + p8est_expand_face_transform(iface, nface, ftransform) -Create a connectivity structure for an all-periodic unit square. +Fill an array with the axis combination of a face neighbor transform. +# Arguments +* `iface`:\\[in\\] The number of the originating face. +* `nface`:\\[in\\] Encoded as nface = r * 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 -p4est_connectivity_t *p4est_connectivity_new_periodic (void); +void p8est_expand_face_transform (int iface, int nface, int ftransform[]); ``` """ -function p4est_connectivity_new_periodic() - @ccall libp4est.p4est_connectivity_new_periodic()::Ptr{p4est_connectivity_t} +function p8est_expand_face_transform(iface, nface, ftransform) + @ccall libt8.p8est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid end """ - p4est_connectivity_new_rotwrap() + p8est_find_face_transform(connectivity, itree, iface, ftransform) -Create a connectivity structure for a periodic unit square. The left and right faces are identified, and bottom and top opposite. +Fill an array with the axis combination of a face neighbor transform. + +# Arguments +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `iface`:\\[in\\] The number of the originating tree's face. +* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face. [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flag for axes t1, t2; face code for n; +# Returns +The face neighbor tree if it exists, -1 otherwise. +# See also +[`p8est_expand_face_transform`](@ref). ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_rotwrap (void); +p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); ``` """ -function p4est_connectivity_new_rotwrap() - @ccall libp4est.p4est_connectivity_new_rotwrap()::Ptr{p4est_connectivity_t} +function p8est_find_face_transform(connectivity, itree, iface, ftransform) + @ccall libt8.p8est_find_face_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iface::Cint, ftransform::Ptr{Cint})::p4est_topidx_t end """ - p4est_connectivity_new_circle() + p8est_find_edge_transform(connectivity, itree, iedge, ei) -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. +Fills an array with information about edge neighbors. +# Arguments +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `iedge`:\\[in\\] The number of the originating edge. +* `ei`:\\[in,out\\] A [`p8est_edge_info_t`](@ref) structure with initialized array. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_circle (void); +void p8est_find_edge_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t * ei); ``` """ -function p4est_connectivity_new_circle() - @ccall libp4est.p4est_connectivity_new_circle()::Ptr{p4est_connectivity_t} +function p8est_find_edge_transform(connectivity, itree, iedge, ei) + @ccall libt8.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_new_drop() + p8est_find_corner_transform(connectivity, itree, icorner, ci) -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. +Fills an array with information about corner neighbors. +# Arguments +* `connectivity`:\\[in\\] Connectivity structure. +* `itree`:\\[in\\] The number of the originating tree. +* `icorner`:\\[in\\] The number of the originating corner. +* `ci`:\\[in,out\\] A [`p8est_corner_info_t`](@ref) structure with initialized array. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_drop (void); +void p8est_find_corner_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t * ci); ``` """ -function p4est_connectivity_new_drop() - @ccall libp4est.p4est_connectivity_new_drop()::Ptr{p4est_connectivity_t} +function p8est_find_corner_transform(connectivity, itree, icorner, ci) + @ccall libt8.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_twotrees(l_face, r_face, orientation) + p8est_connectivity_complete(conn) -Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way +Internally connect a connectivity based on tree\\_to\\_vertex information. Periodicity that is not inherent in the list of vertices will be lost. # 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 +* `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_twotrees (int l_face, int r_face, int orientation); +void p8est_connectivity_complete (p8est_connectivity_t * conn); ``` """ -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 p8est_connectivity_complete(conn) + @ccall libt8.p8est_connectivity_complete(conn::Ptr{p8est_connectivity_t})::Cvoid end """ - p4est_connectivity_new_corner() + p8est_connectivity_reduce(conn) -Create a connectivity structure for a three-tree mesh around a corner. +Removes corner and edge information of a connectivity such that enough information is left to run [`p8est_connectivity_complete`](@ref) successfully. The reduced connectivity still passes [`p8est_connectivity_is_valid`](@ref). +# Arguments +* `conn`:\\[in,out\\] The connectivity to be reduced. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_corner (void); +void p8est_connectivity_reduce (p8est_connectivity_t * conn); ``` """ -function p4est_connectivity_new_corner() - @ccall libp4est.p4est_connectivity_new_corner()::Ptr{p4est_connectivity_t} +function p8est_connectivity_reduce(conn) + @ccall libt8.p8est_connectivity_reduce(conn::Ptr{p8est_connectivity_t})::Cvoid end """ - p4est_connectivity_new_pillow() + p8est_connectivity_permute(conn, perm, is_current_to_new) -Create a connectivity structure for two trees on top of each other. +[`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_new_pillow (void); +void p8est_connectivity_permute (p8est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); ``` """ -function p4est_connectivity_new_pillow() - @ccall libp4est.p4est_connectivity_new_pillow()::Ptr{p4est_connectivity_t} +function p8est_connectivity_permute(conn, perm, is_current_to_new) + @ccall libt8.p8est_connectivity_permute(conn::Ptr{p8est_connectivity_t}, perm::Ptr{sc_array_t}, is_current_to_new::Cint)::Cvoid end """ - p4est_connectivity_new_moebius() + p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) -Create a connectivity structure for a five-tree moebius band. +[`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 -p4est_connectivity_t *p4est_connectivity_new_moebius (void); +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_new_moebius() - @ccall libp4est.p4est_connectivity_new_moebius()::Ptr{p4est_connectivity_t} +function p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + @ccall libt8.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_new_star() + p8est_connectivity_is_equivalent(conn1, conn2) -Create a connectivity structure for a six-tree star. +[`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 +* `conn1`:\\[in\\] a valid connectivity +* `conn2`:\\[out\\] a valid connectivity ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_star (void); +int p8est_connectivity_is_equivalent (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); ``` """ -function p4est_connectivity_new_star() - @ccall libp4est.p4est_connectivity_new_star()::Ptr{p4est_connectivity_t} +function p8est_connectivity_is_equivalent(conn1, conn2) + @ccall libt8.p8est_connectivity_is_equivalent(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint 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). + p8est_edge_array_index(array, it) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_cubed (void); +static inline p8est_edge_transform_t * p8est_edge_array_index (sc_array_t *array, size_t it); ``` """ -function p4est_connectivity_new_cubed() - @ccall libp4est.p4est_connectivity_new_cubed()::Ptr{p4est_connectivity_t} +function p8est_edge_array_index(array, it) + @ccall libt8.p8est_edge_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_edge_transform_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. + p8est_corner_array_index(array, it) -# Returns -Initialized and usable connectivity. ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk_nonperiodic (void); +static inline p8est_corner_transform_t * p8est_corner_array_index (sc_array_t *array, size_t it); ``` """ -function p4est_connectivity_new_disk_nonperiodic() - @ccall libp4est.p4est_connectivity_new_disk_nonperiodic()::Ptr{p4est_connectivity_t} +function p8est_corner_array_index(array, it) + @ccall libt8.p8est_corner_array_index(array::Ptr{sc_array_t}, it::Csize_t)::Ptr{p8est_corner_transform_t} end """ - p4est_connectivity_new_disk(periodic_a, periodic_b) + p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) -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. +Read an ABAQUS input file from a file stream. -!!! note +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. - 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. +A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: -The ordering of the trees is as follows: +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 -4 1 2 3 0 +and in 3D they are given as: -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). +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 -When setting *periodic_a* and *periodic_b* to false, the result is the same as that of p4est_connectivity_new_disk_nonperiodic. +```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 -* `periodic_a`:\\[in\\] Bool to make disk periodic in x direction. -* `periodic_b`:\\[in\\] Bool to make disk periodic in y direction. +* `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 -Initialized and usable connectivity. +0 if successful and nonzero if not ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk (int periodic_a, int periodic_b); +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_new_disk(periodic_a, periodic_b) - @ccall libp4est.p4est_connectivity_new_disk(periodic_a::Cint, periodic_b::Cint)::Ptr{p4est_connectivity_t} +function p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) + @ccall libt8.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_new_icosahedron() + p8est_connectivity_read_inp(filename) -Create a connectivity for mapping the sphere using an icosahedron. +Create a p4est connectivity from an ABAQUS input file. -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 utility function reads a basic ABAQUS file supporting element type with the prefix C2D4, CPS4, and S4 in 2D and of type C3D8 reading them as bilinear quadrilateral and trilinear hexahedral trees respectively. -This connectivity is meant to be used together with p4est_geometry_new_icosahedron to map the sphere. +A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: -The flat connectivity looks like that. Vextex numbering: +4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 -A00 A01 A02 A03 A04 / \\ / \\ / \\ / \\ / \\ A05---A06---A07---A08---A09---A10 \\ / \\ / \\ / \\ / \\ / \\ A11---A12---A13---A14---A15---A16 \\ / \\ / \\ / \\ / \\ / A17 A18 A19 A20 A21 +and in 3D they are given as: -Origin in A05. +8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 -Tree numbering: +```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 +``` -0 2 4 6 8 1 3 5 7 9 +This function reads a mesh from *filename* and returns an associated p4est connectivity. +# Arguments +* `filename`:\\[in\\] file to read the connectivity from +# Returns +an allocated connectivity associated with the mesh in *filename* ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_icosahedron (void); +p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename); ``` """ -function p4est_connectivity_new_icosahedron() - @ccall libp4est.p4est_connectivity_new_icosahedron()::Ptr{p4est_connectivity_t} +function p8est_connectivity_read_inp(filename) + @ccall libt8.p8est_connectivity_read_inp(filename::Cstring)::Ptr{p8est_connectivity_t} end """ - p4est_connectivity_new_shell2d() - -Create a connectivity structure that builds a 2d spherical shell. p8est_connectivity_new_shell + t8_cmesh_new_from_p4est(conn, comm, do_partition) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_shell2d (void); +t8_cmesh_t t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); ``` """ -function p4est_connectivity_new_shell2d() - @ccall libp4est.p4est_connectivity_new_shell2d()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_from_p4est(conn, comm, do_partition) + @ccall libt8.t8_cmesh_new_from_p4est(conn::Ptr{p4est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_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_from_p8est(conn, comm, do_partition) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_disk2d (void); +t8_cmesh_t t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); ``` """ -function p4est_connectivity_new_disk2d() - @ccall libp4est.p4est_connectivity_new_disk2d()::Ptr{p4est_connectivity_t} +function t8_cmesh_new_from_p8est(conn, comm, do_partition) + @ccall libt8.t8_cmesh_new_from_p8est(conn::Ptr{p8est_connectivity_t}, comm::MPI_Comm, do_partition::Cint)::t8_cmesh_t end """ - p4est_connectivity_new_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_empty(comm, do_partition, dimension) ### Prototype ```c -p4est_connectivity_t *p4est_connectivity_new_bowtie (void); +t8_cmesh_t t8_cmesh_new_empty (sc_MPI_Comm comm, const int do_partition, const int dimension); ``` """ -function p4est_connectivity_new_bowtie() - @ccall libp4est.p4est_connectivity_new_bowtie()::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_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_from_class(eclass, 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_from_class (t8_eclass_t eclass, 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_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_byname(name) - -Create connectivity structure from predefined catalogue. + t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) -# 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_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int do_partition, int periodic); ``` """ -function p4est_connectivity_new_byname(name) - @ccall libp4est.p4est_connectivity_new_byname(name::Cstring)::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_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_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) -# 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_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_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_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_expand_face_transform(iface, nface, ftransform) - -Fill an array with the axis combination of a face neighbor transform. + t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) -# Arguments -* `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_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_expand_face_transform(iface, nface, ftransform) - @ccall libp4est.p4est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid +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_find_face_transform(connectivity, itree, iface, ftransform) + t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) -Fill an array with the axis combinations of a tree neighbor transform. +### Prototype +```c +t8_cmesh_t t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, int do_partition, int periodic); +``` +""" +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 -# 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_periodic(comm, dim) ### 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_periodic (sc_MPI_Comm comm, int dim); ``` """ -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_periodic(comm, dim) + @ccall libt8.t8_cmesh_new_periodic(comm::MPI_Comm, dim::Cint)::t8_cmesh_t end """ - p4est_find_corner_transform(connectivity, itree, icorner, ci) - -Fills an array with information about corner neighbors. + t8_cmesh_new_periodic_tri(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_periodic_tri (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_periodic_tri(comm) + @ccall libt8.t8_cmesh_new_periodic_tri(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_periodic_hybrid(comm) -# Arguments -* `conn`:\\[in,out\\] The connectivity needs to have proper vertices and tree\\_to\\_vertex fields. The tree\\_to\\_tree and tree\\_to\\_face fields must be allocated and satisfy [`p4est_connectivity_is_valid`](@ref) (conn) but will be overwritten. The corner fields will be freed and allocated anew. ### Prototype ```c -void p4est_connectivity_complete (p4est_connectivity_t * conn); +t8_cmesh_t t8_cmesh_new_periodic_hybrid (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_complete(conn) - @ccall libp4est.p4est_connectivity_complete(conn::Ptr{p4est_connectivity_t})::Cvoid +function t8_cmesh_new_periodic_hybrid(comm) + @ccall libt8.t8_cmesh_new_periodic_hybrid(comm::MPI_Comm)::t8_cmesh_t end """ - p4est_connectivity_reduce(conn) - -Removes corner information of a connectivity such that enough information is left to run [`p4est_connectivity_complete`](@ref) successfully. The reduced connectivity still passes [`p4est_connectivity_is_valid`](@ref). + t8_cmesh_new_periodic_line_more_trees(comm) -# Arguments -* `conn`:\\[in,out\\] The connectivity to be reduced. ### Prototype ```c -void p4est_connectivity_reduce (p4est_connectivity_t * conn); +t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm); ``` """ -function p4est_connectivity_reduce(conn) - @ccall libp4est.p4est_connectivity_reduce(conn::Ptr{p4est_connectivity_t})::Cvoid +function t8_cmesh_new_periodic_line_more_trees(comm) + @ccall libt8.t8_cmesh_new_periodic_line_more_trees(comm::MPI_Comm)::t8_cmesh_t end """ - 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_bigmesh(eclass, num_trees, 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_bigmesh (t8_eclass_t eclass, int num_trees, 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_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_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_line_zigzag(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_line_zigzag (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_line_zigzag(comm) + @ccall libt8.t8_cmesh_new_line_zigzag(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_prism_cake(comm, num_of_prisms) -# 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_prism_cake (sc_MPI_Comm comm, int num_of_prisms); ``` """ -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_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_corner_array_index(array, it) + t8_cmesh_new_prism_deformed(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_prism_deformed (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_prism_deformed(comm) + @ccall libt8.t8_cmesh_new_prism_deformed(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_pyramid_deformed(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_pyramid_deformed (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_pyramid_deformed(comm) + @ccall libt8.t8_cmesh_new_pyramid_deformed(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_prism_cake_funny_oriented(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_prism_cake_funny_oriented (sc_MPI_Comm comm); ``` +""" +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 -This function reads a mesh from *filename* and returns an associated p4est connectivity. +""" + t8_cmesh_new_prism_geometry(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_prism_geometry (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_prism_geometry(comm) + @ccall libt8.t8_cmesh_new_prism_geometry(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_brick_2d(num_x, num_y, x_periodic, y_periodic, 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_brick_2d (t8_gloidx_t num_x, t8_gloidx_t num_y, int x_periodic, int y_periodic, 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_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 """ - p8est_connectivity_encode_t - -Typedef for serialization method. + t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) -| Enumerator | Note | -| :--------------------------- | :-------------------------------- | -| P8EST\\_CONN\\_ENCODE\\_LAST | Invalid entry to close the list. | +### Prototype +```c +t8_cmesh_t t8_cmesh_new_brick_3d (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); +``` """ -@cenum p8est_connectivity_encode_t::UInt32 begin - P8EST_CONN_ENCODE_NONE = 0 - P8EST_CONN_ENCODE_LAST = 1 +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 """ - p8est_connect_type_int(btype) - -Convert the [`p8est_connect_type_t`](@ref) into a number. + t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, 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_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 p8est_connect_type_int(btype) - @ccall libp4est.p8est_connect_type_int(btype::p8est_connect_type_t)::Cint +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 """ - p8est_connect_type_string(btype) - -Convert the [`p8est_connect_type_t`](@ref) into a const string. + t8_cmesh_new_tet_orientation_test(comm) -# Arguments -* `btype`:\\[in\\] The balance type to convert. -# Returns -Returns a pointer to a constant string. ### Prototype ```c -const char *p8est_connect_type_string (p8est_connect_type_t btype); +t8_cmesh_t t8_cmesh_new_tet_orientation_test (sc_MPI_Comm comm); ``` """ -function p8est_connect_type_string(btype) - @ccall libp4est.p8est_connect_type_string(btype::p8est_connect_type_t)::Cstring +function t8_cmesh_new_tet_orientation_test(comm) + @ccall libt8.t8_cmesh_new_tet_orientation_test(comm::MPI_Comm)::t8_cmesh_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. - -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. + t8_cmesh_new_hybrid_gate(comm) -| 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 | -""" -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} +### Prototype +```c +t8_cmesh_t t8_cmesh_new_hybrid_gate (sc_MPI_Comm comm); +``` +""" +function t8_cmesh_new_hybrid_gate(comm) + @ccall libt8.t8_cmesh_new_hybrid_gate(comm::MPI_Comm)::t8_cmesh_t 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. + t8_cmesh_new_hybrid_gate_deformed(comm) -It is valid to specify num\\_vertices as 0. In this case vertices and tree\\_to\\_vertex are set to NULL. Otherwise the vertex coordinates are stored in the array vertices as [0][0]..[0][2]..[num\\_vertices-1][0]..[num\\_vertices-1][2]. Vertex coordinates are optional and not used for inferring topology. +### Prototype +```c +t8_cmesh_t t8_cmesh_new_hybrid_gate_deformed (sc_MPI_Comm comm); +``` +""" +function t8_cmesh_new_hybrid_gate_deformed(comm) + @ccall libt8.t8_cmesh_new_hybrid_gate_deformed(comm::MPI_Comm)::t8_cmesh_t +end -The edges are stored when they connect trees that are not already face neighbors at that specific edge. In this case tree\\_to\\_edge indexes into *ett_offset*. Otherwise the tree\\_to\\_edge entry must be -1 and this edge is ignored. If num\\_edges == 0, tree\\_to\\_edge and edge\\_to\\_* arrays are set to NULL. +""" + t8_cmesh_new_full_hybrid(comm) -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. +### Prototype +```c +t8_cmesh_t t8_cmesh_new_full_hybrid (sc_MPI_Comm comm); +``` +""" +function t8_cmesh_new_full_hybrid(comm) + @ccall libt8.t8_cmesh_new_full_hybrid(comm::MPI_Comm)::t8_cmesh_t +end -The corners are stored when they connect trees that are not already edge or face neighbors at that specific corner. In this case tree\\_to\\_corner indexes into *ctt_offset*. Otherwise the tree\\_to\\_corner entry must be -1 and this corner is ignored. If num\\_corners == 0, tree\\_to\\_corner and corner\\_to\\_* arrays are set to NULL. +""" + t8_cmesh_new_pyramid_cake(comm, num_of_pyra) -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]. +### Prototype +```c +t8_cmesh_t t8_cmesh_new_pyramid_cake (sc_MPI_Comm comm, int num_of_pyra); +``` +""" +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 -The *\\_to\\_attr arrays may have arbitrary contents defined by the user. +""" + t8_cmesh_new_long_brick_pyramid(comm, num_cubes) -!!! note +### Prototype +```c +t8_cmesh_t t8_cmesh_new_long_brick_pyramid (sc_MPI_Comm comm, int num_cubes); +``` +""" +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 - 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. """ -const p8est_connectivity_t = p8est_connectivity + t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm, package_id) +### Prototype +```c +t8_cmesh_t t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, const int do_partition, sc_MPI_Comm comm, const int package_id); +``` """ - p8est_connectivity_memory_used(conn) +function t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm, package_id) + @ccall libt8.t8_cmesh_new_row_of_cubes(num_trees::t8_locidx_t, set_attributes::Cint, do_partition::Cint, comm::MPI_Comm, package_id::Cint)::t8_cmesh_t +end -Calculate memory usage of a connectivity structure. +""" + t8_cmesh_new_quadrangulated_disk(radius, comm) -# Arguments -* `conn`:\\[in\\] Connectivity structure. -# Returns -Memory used in bytes. ### Prototype ```c -size_t p8est_connectivity_memory_used (p8est_connectivity_t * conn); +t8_cmesh_t t8_cmesh_new_quadrangulated_disk (const double radius, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_memory_used(conn) - @ccall libp4est.p8est_connectivity_memory_used(conn::Ptr{p8est_connectivity_t})::Csize_t +function t8_cmesh_new_quadrangulated_disk(radius, comm) + @ccall libt8.t8_cmesh_new_quadrangulated_disk(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - p8est_edge_transform_t - -Generic interface for transformations between a tree and any of its edge + t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) -| 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 | +### Prototype +```c +t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_MPI_Comm comm); +``` """ -struct p8est_edge_transform_t - ntree::p4est_topidx_t - nedge::Int8 - naxis::NTuple{3, Int8} - nflip::Int8 - corners::Int8 +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 """ - p8est_edge_info_t - -Information about the neighbors of an edge + t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) -| Field | Note | -| :---------------- | :---------------------------------------------- | -| iedge | The information of the edge | -| edge\\_transforms | The array of neighbors of the originating edge | +### Prototype +```c +t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc_MPI_Comm comm); +``` """ -struct p8est_edge_info_t - iedge::Int8 - edge_transforms::sc_array_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 """ - p8est_corner_transform_t - -Generic interface for transformations between a tree and any of its corner + t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) -| Field | Note | -| :------ | :------------------------ | -| ntree | The number of the tree | -| ncorner | The number of the corner | +### Prototype +```c +t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Comm comm); +``` """ -struct p8est_corner_transform_t - ntree::p4est_topidx_t - ncorner::Int8 +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 """ - p8est_corner_info_t - -Information about the neighbors of a corner + t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) -| Field | Note | -| :------------------ | :------------------------------------------------ | -| icorner | The number of the originating corner | -| corner\\_transforms | The array of neighbors of the originating corner | +### Prototype +```c +t8_cmesh_t t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm); +``` """ -struct p8est_corner_info_t - icorner::p4est_topidx_t - corner_transforms::sc_array_t +function t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) + @ccall libt8.t8_cmesh_new_quadrangulated_spherical_surface(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - p8est_neighbor_transform_t - -Generic interface for transformations between a tree and any of its neighbors + t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) -| Field | Note | -| :---------------- | :-------------------------------------------------------------------------- | -| neighbor\\_type | type of connection to neighbor | -| neighbor | neighbor tree index | -| index\\_self | index of interface from self's perspective | -| index\\_neighbor | index of interface from neighbor's perspective | -| perm | permutation of dimensions when transforming self coords to neighbor coords | -| sign | sign changes when transforming self coords to neighbor coords | -| origin\\_self | point on the interface from self's perspective | -| origin\\_neighbor | point on the interface from neighbor's perspective | +### Prototype +```c +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); +``` """ -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_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_neighbor_transform_coordinates(nt, self_coords, neigh_coords) - -Transform from self's coordinate system to neighbor's coordinate system. + t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) -# 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 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]); +t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_icosahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); ``` """ -function 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_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_neighbor_transform_coordinates_reverse(nt, neigh_coords, self_coords) - -Transform from neighbor's coordinate system to self's coordinate system. + t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) -# 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 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]); +t8_cmesh_t t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_trees, const int num_layers, sc_MPI_Comm comm); ``` """ -function p8est_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_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_connectivity_get_neighbor_transforms(conn, tree_id, boundary_type, boundary_index, neighbor_transform_array) - -Fill an array with the neighbor transforms based on a specific boundary type. This function generalizes all other inter-tree transformation objects + t8_cmesh_new_cubed_sphere(radius, comm) -# Arguments -* `conn`:\\[in\\] Connectivity structure. -* `tree_id`:\\[in\\] The number of the tree. -* `boundary_type`:\\[in\\] Type of boundary connection (self, face, edge, corner). -* `boundary_index`:\\[in\\] The index of the boundary. -* `neighbor_transform_array`:\\[in,out\\] Array of the neighbor transforms. ### Prototype ```c -void p8est_connectivity_get_neighbor_transforms (p8est_connectivity_t *conn, p4est_topidx_t tree_id, p8est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array); +t8_cmesh_t t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm); ``` """ -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_cmesh_new_cubed_sphere(radius, comm) + @ccall libt8.t8_cmesh_new_cubed_sphere(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t end """ - p8est_connectivity_face_neighbor_corner_set(c, f, nf, set) + t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) -Transform a corner across one of the adjacent faces into a neighbor tree. It expects a face permutation index that has been precomputed. +Sets the face connectivity information of an un-committed cmesh 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 + + This routine does not detect periodic boundaries. # Arguments -* `c`:\\[in\\] A corner number in 0..7. -* `f`:\\[in\\] A face number that touches the corner *c*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `set`:\\[in\\] A value from *p8est_face_permutation_sets* that is obtained using *f*, *nf*, and a valid orientation: ref = p8est\\_face\\_permutation\\_refs[f][nf]; set = p8est\\_face\\_permutation\\_sets[ref][orientation]; -# Returns -The corner number in 0..7 seen from the other face. +* `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 -int p8est_connectivity_face_neighbor_corner_set (int c, int f, int nf, int set); +void t8_cmesh_set_join_by_vertices (t8_cmesh_t cmesh, const t8_gloidx_t ntrees, const t8_eclass_t *eclasses, const double *vertices, int **connectivity, const int do_both_directions); ``` """ -function 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_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 """ - p8est_connectivity_face_neighbor_face_corner(fc, f, nf, o) + t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) -Transform a face corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Sets the face connectivity information of an un-committed cmesh based on the cmesh stash. + +!!! warning + + This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. + +!!! note + + This routine does not detect periodic boundaries. # Arguments -* `fc`:\\[in\\] A face corner number in 0..3. -* `f`:\\[in\\] A face that the face corner *fc* is relative to. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. -# Returns -The face corner number relative to the neighbor's face. +* `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 -int p8est_connectivity_face_neighbor_face_corner (int fc, int f, int nf, int o); +void t8_cmesh_set_join_by_stash (t8_cmesh_t cmesh, int **connectivity, const int do_both_directions); ``` """ -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_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_face_neighbor_corner(c, f, nf, o) + t8_element_array_t -Transform a corner across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +The [`t8_element_array_t`](@ref) is an array to store [`t8_element_t`](@ref) * of a given eclass\\_scheme implementation. It is a wrapper around [`sc_array_t`](@ref). Each time, a new element is created by the functions for t8_element_array_t, the eclass function either t8_element_new or t8_element_init is called for the element. Thus, each element in a t8_element_array_t is automatically initialized properly. -# Arguments -* `c`:\\[in\\] A corner number in 0..7. -* `f`:\\[in\\] A face number that touches the corner *c*. -* `nf`:\\[in\\] A neighbor face that is on the other side of *f*. -* `o`:\\[in\\] The orientation between tree boundary faces *f* and *nf*. -# Returns -The number of the corner seen from the neighbor tree. -### Prototype -```c -int p8est_connectivity_face_neighbor_corner (int c, int f, int nf, int o); -``` +| Field | Note | +| :----------- | :----------------------------------------------------- | +| scheme | The scheme of which elements should be stored. | +| tree\\_class | !< A scheme of which elements should be stored | +| array | !< The tree class of the elements stored in the array | """ -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 +struct t8_element_array_t + scheme::Ptr{t8_scheme_c} + tree_class::t8_eclass_t + array::sc_array_t end """ - p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) + t8_element_array_new(scheme, tree_class) -Transform a face-edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Creates a new array structure with 0 elements. # 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*. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. # Returns -The face edge number seen from the neighbor tree. +Return an allocated array of zero length. ### Prototype ```c -int p8est_connectivity_face_neighbor_face_edge (int fe, int f, int nf, int o); +t8_element_array_t * t8_element_array_new (const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -function p8est_connectivity_face_neighbor_face_edge(fe, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_face_edge(fe::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_element_array_new(scheme, tree_class) + @ccall libt8.t8_element_array_new(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Ptr{t8_element_array_t} end """ - p8est_connectivity_face_neighbor_edge(e, f, nf, o) + t8_element_array_new_count(scheme, tree_class, num_elements) -Transform an edge across one of the adjacent faces into a neighbor tree. This version expects the neighbor face and orientation separately. +Creates a new array structure with a given length (number of elements) and calls t8_element_new for those elements. # 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*. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. +* `num_elements`:\\[in\\] Initial number of array elements. # Returns -The edge's number seen from the neighbor. +Return an allocated array with allocated and initialized elements for which t8_element_new was called. ### Prototype ```c -int p8est_connectivity_face_neighbor_edge (int e, int f, int nf, int o); +t8_element_array_t * t8_element_array_new_count (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t num_elements); ``` """ -function p8est_connectivity_face_neighbor_edge(e, f, nf, o) - @ccall libp4est.p8est_connectivity_face_neighbor_edge(e::Cint, f::Cint, nf::Cint, o::Cint)::Cint +function t8_element_array_new_count(scheme, tree_class, num_elements) + @ccall libt8.t8_element_array_new_count(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, num_elements::Csize_t)::Ptr{t8_element_array_t} end """ - p8est_connectivity_edge_neighbor_edge_corner(ec, o) + t8_element_array_init(element_array, scheme, tree_class) -Transform an edge corner across one of the adjacent edges into a neighbor tree. +Initializes an already allocated (or static) array structure. # 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. +* `element_array`:\\[in,out\\] Array structure to be initialized. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. ### Prototype ```c -int p8est_connectivity_edge_neighbor_edge_corner (int ec, int o); +void t8_element_array_init (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -function p8est_connectivity_edge_neighbor_edge_corner(ec, o) - @ccall libp4est.p8est_connectivity_edge_neighbor_edge_corner(ec::Cint, o::Cint)::Cint +function t8_element_array_init(element_array, scheme, tree_class) + @ccall libt8.t8_element_array_init(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cvoid end """ - p8est_connectivity_edge_neighbor_corner(c, e, ne, o) + t8_element_array_init_size(element_array, scheme, tree_class, num_elements) -Transform a corner across one of the adjacent edges into a neighbor tree. This version expects the neighbor edge and orientation separately. +Initializes an already allocated (or static) array structure and allocates a given number of elements and initializes them with t8_element_init. # 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. +* `element_array`:\\[in,out\\] Array structure to be initialized. +* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. +* `num_elements`:\\[in\\] Number of initial array elements. ### Prototype ```c -int p8est_connectivity_edge_neighbor_corner (int c, int e, int ne, int o); +void t8_element_array_init_size (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t num_elements); ``` """ -function p8est_connectivity_edge_neighbor_corner(c, e, ne, o) - @ccall libp4est.p8est_connectivity_edge_neighbor_corner(c::Cint, e::Cint, ne::Cint, o::Cint)::Cint +function t8_element_array_init_size(element_array, scheme, tree_class, num_elements) + @ccall libt8.t8_element_array_init_size(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, num_elements::Csize_t)::Cvoid end """ - p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) + t8_element_array_init_view(view, array, offset, length) -Allocate a connectivity structure. The attribute fields are initialized to NULL. +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 -* `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. +* `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 -p8est_connectivity_t *p8est_connectivity_new (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_ett, p4est_topidx_t num_corners, p4est_topidx_t num_ctt); +void t8_element_array_init_view (t8_element_array_t *view, const t8_element_array_t *array, const size_t offset, const size_t length); ``` """ -function p8est_connectivity_new(num_vertices, num_trees, num_edges, num_ett, num_corners, num_ctt) - @ccall libp4est.p8est_connectivity_new(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_ett::p4est_topidx_t, num_corners::p4est_topidx_t, num_ctt::p4est_topidx_t)::Ptr{p8est_connectivity_t} +function t8_element_array_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 """ - p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) + t8_element_array_init_data(view, base, scheme, tree_class, elem_count) -Allocate a connectivity structure and populate from constants. The attribute fields are initialized to NULL. +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 -* `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. +* `view`:\\[in,out\\] Array structure to be initialized. +* `base`:\\[in\\] The data must not be moved while view is alive. Must be an array of [`t8_element_t`](@ref) corresponding to *scheme*. +* `scheme`:\\[in\\] The scheme of the elements stored in *base*. +* `tree_class`:\\[in\\] The tree class of the elements stored in *base*. +* `elem_count`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`t8_element_array_reset`](@ref) later. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_copy (p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t * ttv, const p4est_topidx_t * ttt, const int8_t * ttf, const p4est_topidx_t * tte, const p4est_topidx_t * eoff, const p4est_topidx_t * ett, const int8_t * ete, const p4est_topidx_t * ttc, const p4est_topidx_t * coff, const p4est_topidx_t * ctt, const int8_t * ctc); +void t8_element_array_init_data (t8_element_array_t *view, const t8_element_t *base, const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t elem_count); ``` """ -function p8est_connectivity_new_copy(num_vertices, num_trees, num_edges, num_corners, vertices, ttv, ttt, ttf, tte, eoff, ett, ete, ttc, coff, ctt, ctc) - @ccall libp4est.p8est_connectivity_new_copy(num_vertices::p4est_topidx_t, num_trees::p4est_topidx_t, num_edges::p4est_topidx_t, num_corners::p4est_topidx_t, vertices::Ptr{Cdouble}, ttv::Ptr{p4est_topidx_t}, ttt::Ptr{p4est_topidx_t}, ttf::Ptr{Int8}, tte::Ptr{p4est_topidx_t}, eoff::Ptr{p4est_topidx_t}, ett::Ptr{p4est_topidx_t}, ete::Ptr{Int8}, ttc::Ptr{p4est_topidx_t}, coff::Ptr{p4est_topidx_t}, ctt::Ptr{p4est_topidx_t}, ctc::Ptr{Int8})::Ptr{p8est_connectivity_t} +function t8_element_array_init_data(view, base, scheme, tree_class, elem_count) + @ccall libt8.t8_element_array_init_data(view::Ptr{t8_element_array_t}, base::Ptr{t8_element_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem_count::Csize_t)::Cvoid end """ - p8est_connectivity_bcast(conn_in, root, comm) + t8_element_array_init_copy(element_array, scheme, tree_class, 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. +* `tree_class`:\\[in\\] The tree class of the elements stored in the array. +* `data`:\\[in\\] An array of [`t8_element_t`](@ref) which will be copied into *element_array*. The elements in *data* must belong to *scheme* and must be properly initialized with either t8_element_new or t8_element_init. +* `num_elements`:\\[in\\] Number of elements in *data* to be copied. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_bcast (p8est_connectivity_t * conn_in, int root, sc_MPI_Comm comm); +void t8_element_array_init_copy (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *data, const size_t num_elements); ``` """ -function p8est_connectivity_bcast(conn_in, root, comm) - @ccall libp4est.p8est_connectivity_bcast(conn_in::Ptr{p8est_connectivity_t}, root::Cint, comm::MPI_Comm)::Ptr{p8est_connectivity_t} +function t8_element_array_init_copy(element_array, scheme, tree_class, data, num_elements) + @ccall libt8.t8_element_array_init_copy(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, data::Ptr{t8_element_t}, num_elements::Csize_t)::Cvoid end """ - p8est_connectivity_destroy(connectivity) + t8_element_array_resize(element_array, new_count) -Destroy a connectivity structure. Also destroy all attributes. +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 -void p8est_connectivity_destroy (p8est_connectivity_t * connectivity); +void t8_element_array_resize (t8_element_array_t *element_array, const size_t new_count); ``` """ -function p8est_connectivity_destroy(connectivity) - @ccall libp4est.p8est_connectivity_destroy(connectivity::Ptr{p8est_connectivity_t})::Cvoid +function t8_element_array_resize(element_array, new_count) + @ccall libt8.t8_element_array_resize(element_array::Ptr{t8_element_array_t}, new_count::Csize_t)::Cvoid end """ - p8est_connectivity_set_attr(conn, bytes_per_tree) + t8_element_array_copy(dest, src) -Allocate or free the attribute fields in a connectivity. +Copy the contents of an array into another. Both arrays must have the same eclass\\_scheme. # 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. +* `dest`:\\[in\\] Array will be resized and get new data. +* `src`:\\[in\\] Array used as source of new data, will not be changed. ### Prototype ```c -void p8est_connectivity_set_attr (p8est_connectivity_t * conn, size_t bytes_per_tree); +void t8_element_array_copy (t8_element_array_t *dest, const t8_element_array_t *src); ``` """ -function p8est_connectivity_set_attr(conn, bytes_per_tree) - @ccall libp4est.p8est_connectivity_set_attr(conn::Ptr{p8est_connectivity_t}, bytes_per_tree::Csize_t)::Cvoid +function t8_element_array_copy(dest, src) + @ccall libt8.t8_element_array_copy(dest::Ptr{t8_element_array_t}, src::Ptr{t8_element_array_t})::Cvoid end """ - p8est_connectivity_is_valid(connectivity) + t8_element_array_push(element_array) -Examine a connectivity structure. +Enlarge an array by one element. +# Arguments +* `element_array`:\\[in,out\\] Array structure to be modified. # Returns -Returns true if structure is valid, false otherwise. +Returns a pointer to a newly added element for which t8_element_init was called. ### Prototype ```c -int p8est_connectivity_is_valid (p8est_connectivity_t * connectivity); +t8_element_t * t8_element_array_push (t8_element_array_t *element_array); ``` """ -function p8est_connectivity_is_valid(connectivity) - @ccall libp4est.p8est_connectivity_is_valid(connectivity::Ptr{p8est_connectivity_t})::Cint +function t8_element_array_push(element_array) + @ccall libt8.t8_element_array_push(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} end """ - p8est_connectivity_is_equal(conn1, conn2) + t8_element_array_push_count(element_array, count) -Check two connectivity structures for equality. +Enlarge an array by a number of elements. +# Arguments +* `element_array`:\\[in,out\\] Array structure to be modified. +* `count`:\\[in\\] The number of elements to add. # Returns -Returns true if structures are equal, false otherwise. +Returns a pointer to the newly added elements for which t8_element_init was called. ### Prototype ```c -int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); +t8_element_t * t8_element_array_push_count (t8_element_array_t *element_array, size_t count); ``` """ -function p8est_connectivity_is_equal(conn1, conn2) - @ccall libp4est.p8est_connectivity_is_equal(conn1::Ptr{p8est_connectivity_t}, conn2::Ptr{p8est_connectivity_t})::Cint +function t8_element_array_push_count(element_array, count) + @ccall libt8.t8_element_array_push_count(element_array::Ptr{t8_element_array_t}, count::Csize_t)::Ptr{t8_element_t} end """ - p8est_connectivity_sink(conn, sink) + t8_element_array_index_locidx(element_array, index) -Write connectivity to a sink object. +Return a given element in an array. Const version. # Arguments -* `conn`:\\[in\\] The connectivity to be written. -* `sink`:\\[in,out\\] The connectivity is written into this sink. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -0 on success, nonzero on error. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -int p8est_connectivity_sink (p8est_connectivity_t * conn, sc_io_sink_t * sink); +const t8_element_t * t8_element_array_index_locidx (const t8_element_array_t *element_array, const t8_locidx_t index); ``` """ -function p8est_connectivity_sink(conn, sink) - @ccall libp4est.p8est_connectivity_sink(conn::Ptr{p8est_connectivity_t}, sink::Ptr{sc_io_sink_t})::Cint +function t8_element_array_index_locidx(element_array, index) + @ccall libt8.t8_element_array_index_locidx(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} end """ - p8est_connectivity_deflate(conn, code) + t8_element_array_index_int(element_array, index) -Allocate memory and store the connectivity information there. +Return a given element in an array. Const version. # Arguments -* `conn`:\\[in\\] The connectivity structure to be exported to memory. -* `code`:\\[in\\] Encoding and compression method for serialization. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -Newly created array that contains the information. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -sc_array_t *p8est_connectivity_deflate (p8est_connectivity_t * conn, p8est_connectivity_encode_t code); +const t8_element_t * t8_element_array_index_int (const t8_element_array_t *element_array, const int index); ``` """ -function p8est_connectivity_deflate(conn, code) - @ccall libp4est.p8est_connectivity_deflate(conn::Ptr{p8est_connectivity_t}, code::p8est_connectivity_encode_t)::Ptr{sc_array_t} +function t8_element_array_index_int(element_array, index) + @ccall libt8.t8_element_array_index_int(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} end """ - p8est_connectivity_save(filename, connectivity) + t8_element_array_index_locidx_mutable(element_array, index) -Save a connectivity structure to disk. +Return a given element in an array. Mutable version. # Arguments -* `filename`:\\[in\\] Name of the file to write. -* `connectivity`:\\[in\\] Valid connectivity structure. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -Returns 0 on success, nonzero on file error. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -int p8est_connectivity_save (const char *filename, p8est_connectivity_t * connectivity); +t8_element_t * t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, const t8_locidx_t index); ``` """ -function p8est_connectivity_save(filename, connectivity) - @ccall libp4est.p8est_connectivity_save(filename::Cstring, connectivity::Ptr{p8est_connectivity_t})::Cint +function t8_element_array_index_locidx_mutable(element_array, index) + @ccall libt8.t8_element_array_index_locidx_mutable(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} end """ - p8est_connectivity_source(source) + t8_element_array_index_int_mutable(element_array, index) -Read connectivity from a source object. +Return a given element in an array. Mutable version. # Arguments -* `source`:\\[in,out\\] The connectivity is read from this source. +* `element_array`:\\[in\\] Array of elements. +* `index`:\\[in\\] The index of an element within the array. # Returns -The newly created connectivity, or NULL on error. +A pointer to the element stored at position *index* in *element_array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source); +t8_element_t * t8_element_array_index_int_mutable (t8_element_array_t *element_array, const int index); ``` """ -function p8est_connectivity_source(source) - @ccall libp4est.p8est_connectivity_source(source::Ptr{sc_io_source_t})::Ptr{p8est_connectivity_t} +function t8_element_array_index_int_mutable(element_array, index) + @ccall libt8.t8_element_array_index_int_mutable(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} end """ - p8est_connectivity_inflate(buffer) + t8_element_array_get_scheme(element_array) -Create new connectivity from a memory buffer. This function aborts on malloc errors. +Return the eclass scheme associated to a t8\\_element\\_array. # Arguments -* `buffer`:\\[in\\] The connectivity is created from this memory buffer. +* `element_array`:\\[in\\] Array of elements. # Returns -The newly created connectivity, or NULL on format error of the buffered connectivity data. +The eclass scheme stored at *element_array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer); +const t8_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_inflate(buffer) - @ccall libp4est.p8est_connectivity_inflate(buffer::Ptr{sc_array_t})::Ptr{p8est_connectivity_t} +function t8_element_array_get_scheme(element_array) + @ccall libt8.t8_element_array_get_scheme(element_array::Ptr{t8_element_array_t})::Ptr{t8_scheme_c} end """ - p8est_connectivity_load(filename, bytes) + t8_element_array_get_tree_class(element_array) -Load a connectivity structure from disk. +Return the tree class of the t8\\_element\\_array . # Arguments -* `filename`:\\[in\\] Name of the file to read. -* `bytes`:\\[out\\] Size in bytes of connectivity on disk or NULL. +* `element_array`:\\[in\\] Array of elements. # Returns -Returns valid connectivity, or NULL on file error. +The tree class stored at *element_array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_load (const char *filename, size_t *bytes); +t8_eclass_t t8_element_array_get_tree_class (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_load(filename, bytes) - @ccall libp4est.p8est_connectivity_load(filename::Cstring, bytes::Ptr{Csize_t})::Ptr{p8est_connectivity_t} +function t8_element_array_get_tree_class(element_array) + @ccall libt8.t8_element_array_get_tree_class(element_array::Ptr{t8_element_array_t})::t8_eclass_t end """ - p8est_connectivity_new_unitcube() + t8_element_array_get_count(element_array) -Create a connectivity structure for the unit cube. +Return the number of elements stored in a [`t8_element_array_t`](@ref). +# Arguments +* `element_array`:\\[in\\] Array structure. +# Returns +The number of elements stored in *element_array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_unitcube (void); +size_t t8_element_array_get_count (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_new_unitcube() - @ccall libp4est.p8est_connectivity_new_unitcube()::Ptr{p8est_connectivity_t} +function t8_element_array_get_count(element_array) + @ccall libt8.t8_element_array_get_count(element_array::Ptr{t8_element_array_t})::Csize_t end """ - p8est_connectivity_new_periodic() + t8_element_array_get_size(element_array) -Create a connectivity structure for an all-periodic unit cube. +Return the data size of elements stored in a [`t8_element_array_t`](@ref). +# Arguments +* `element_array`:\\[in\\] Array structure. +# Returns +The size (in bytes) of a single element in *element_array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_periodic (void); +size_t t8_element_array_get_size (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_new_periodic() - @ccall libp4est.p8est_connectivity_new_periodic()::Ptr{p8est_connectivity_t} +function t8_element_array_get_size(element_array) + @ccall libt8.t8_element_array_get_size(element_array::Ptr{t8_element_array_t})::Csize_t end """ - p8est_connectivity_new_rotwrap() + t8_element_array_get_data(element_array) -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. +Return a const pointer to the real data array stored in a t8\\_element\\_array. +# Arguments +* `element_array`:\\[in\\] Array structure. +# Returns +A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_rotwrap (void); +const t8_element_t * t8_element_array_get_data (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_new_rotwrap() - @ccall libp4est.p8est_connectivity_new_rotwrap()::Ptr{p8est_connectivity_t} +function t8_element_array_get_data(element_array) + @ccall libt8.t8_element_array_get_data(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} end """ - p8est_connectivity_new_drop() + t8_element_array_get_data_mutable(element_array) -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. +Return a pointer to the real data array stored in a t8\\_element\\_array. +# Arguments +* `element_array`:\\[in\\] Array structure. +# Returns +A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_drop (void); +t8_element_t * t8_element_array_get_data_mutable (t8_element_array_t *element_array); ``` """ -function p8est_connectivity_new_drop() - @ccall libp4est.p8est_connectivity_new_drop()::Ptr{p8est_connectivity_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 """ - p8est_connectivity_new_twocubes() + t8_element_array_get_array(element_array) -Create a connectivity structure that contains two cubes. +Return a const pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. + +!!! note + + The data cannot be modified. +# Arguments +* `element_array`:\\[in\\] Array structure. +# Returns +A const pointer to the [`sc_array`](@ref) storing the data. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twocubes (void); +const sc_array_t * t8_element_array_get_array (const t8_element_array_t *element_array); ``` """ -function p8est_connectivity_new_twocubes() - @ccall libp4est.p8est_connectivity_new_twocubes()::Ptr{p8est_connectivity_t} +function t8_element_array_get_array(element_array) + @ccall libt8.t8_element_array_get_array(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} end """ - p8est_connectivity_new_twotrees(l_face, r_face, orientation) + t8_element_array_get_array_mutable(element_array) -Create a connectivity structure for two trees being rotated w.r.t. each other in a user-defined way. +Return a mutable pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. + +!!! note + + The data can be modified. # 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 +* `element_array`:\\[in\\] Array structure. +# Returns +A pointer to the [`sc_array`](@ref) storing the data. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twotrees (int l_face, int r_face, int orientation); +sc_array_t * t8_element_array_get_array_mutable (t8_element_array_t *element_array); ``` """ -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_element_array_get_array_mutable(element_array) + @ccall libt8.t8_element_array_get_array_mutable(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} end """ - p8est_connectivity_new_twowrap() + t8_element_array_reset(element_array) -Create a connectivity structure that contains two cubes where the two far ends are identified periodically. +Sets the array count to zero and frees all elements. + +!!! note + + Calling [`t8_element_array_init`](@ref), then any array operations, then [`t8_element_array_reset`](@ref) is memory neutral. +# Arguments +* `element_array`:\\[in,out\\] Array structure to be reset. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_twowrap (void); +void t8_element_array_reset (t8_element_array_t *element_array); ``` """ -function p8est_connectivity_new_twowrap() - @ccall libp4est.p8est_connectivity_new_twowrap()::Ptr{p8est_connectivity_t} +function t8_element_array_reset(element_array) + @ccall libt8.t8_element_array_reset(element_array::Ptr{t8_element_array_t})::Cvoid end """ - p8est_connectivity_new_rotcubes() + t8_element_array_truncate(element_array) -Create a connectivity structure that contains a few cubes. These are rotated against each other to stress the topology routines. +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 +* `element_array`:\\[in,out\\] Element array structure to be truncated. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_rotcubes (void); +void t8_element_array_truncate (t8_element_array_t *element_array); ``` """ -function p8est_connectivity_new_rotcubes() - @ccall libp4est.p8est_connectivity_new_rotcubes()::Ptr{p8est_connectivity_t} +function t8_element_array_truncate(element_array) + @ccall libt8.t8_element_array_truncate(element_array::Ptr{t8_element_array_t})::Cvoid end """ - p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) - -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. + t8_shmem_init(comm) ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, int periodic_a, int periodic_b, int periodic_c); +void t8_shmem_init (sc_MPI_Comm comm); ``` """ -function p8est_connectivity_new_brick(m, n, p, periodic_a, periodic_b, periodic_c) - @ccall libp4est.p8est_connectivity_new_brick(m::Cint, n::Cint, p::Cint, periodic_a::Cint, periodic_b::Cint, periodic_c::Cint)::Ptr{p8est_connectivity_t} +function t8_shmem_init(comm) + @ccall libt8.t8_shmem_init(comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_new_shell() - -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). + t8_shmem_finalize(comm) ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_shell (void); +void t8_shmem_finalize (sc_MPI_Comm comm); ``` """ -function p8est_connectivity_new_shell() - @ccall libp4est.p8est_connectivity_new_shell()::Ptr{p8est_connectivity_t} +function t8_shmem_finalize(comm) + @ccall libt8.t8_shmem_finalize(comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_new_sphere() - -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). + t8_shmem_set_type(comm, type) ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_sphere (void); +void t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); ``` """ -function p8est_connectivity_new_sphere() - @ccall libp4est.p8est_connectivity_new_sphere()::Ptr{p8est_connectivity_t} +function t8_shmem_set_type(comm, type) + @ccall libt8.t8_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid end """ - p8est_connectivity_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. - -This connectivity is meant to be used with p8est_geometry_new_torus + t8_shmem_array_init(parray, elem_size, elem_count, comm) -# Arguments -* `nSegments`:\\[in\\] number of trees along the great circle ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_torus (int nSegments); +void t8_shmem_array_init (t8_shmem_array_t *parray, size_t elem_size, size_t elem_count, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_new_torus(nSegments) - @ccall libp4est.p8est_connectivity_new_torus(nSegments::Cint)::Ptr{p8est_connectivity_t} +function t8_shmem_array_init(parray, elem_size, elem_count, comm) + @ccall libt8.t8_shmem_array_init(parray::Ptr{t8_shmem_array_t}, elem_size::Csize_t, elem_count::Csize_t, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_new_byname(name) + t8_shmem_array_start_writing(array) -Create connectivity structure from predefined catalogue. +Enable writing mode for a shmem array. Only some processes may be allowed to write into the array, which is indicated by the return value being non-zero. The shared memory is managed via inter- and intranode communicators. Only rank 0 of the intranode communicator will be allowed to write into the array. + +!!! note + + This function is MPI collective. # Arguments -* `name`:\\[in\\] Invokes connectivity\\_new\\_* function. brick235 brick (2, 3, 5, 0, 0, 0) periodic periodic rotcubes rotcubes rotwrap rotwrap shell shell sphere sphere twocubes twocubes twowrap twowrap unit unitcube +* `array`:\\[in,out\\] Initialized array. Writing will be enabled on certain processes. # Returns -An initialized connectivity if name is defined, NULL else. +True if the calling process can write into the array. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_new_byname (const char *name); +int t8_shmem_array_start_writing (t8_shmem_array_t array); ``` """ -function p8est_connectivity_new_byname(name) - @ccall libp4est.p8est_connectivity_new_byname(name::Cstring)::Ptr{p8est_connectivity_t} +function t8_shmem_array_start_writing(array) + @ccall libt8.t8_shmem_array_start_writing(array::t8_shmem_array_t)::Cint end """ - p8est_connectivity_refine(conn, num_per_dim) + t8_shmem_array_end_writing(array) -Uniformly refine a connectivity. This is useful if you would like to uniformly refine by something other than a power of 2. +Disable writing mode for a shmem array. + +!!! note + + This function is MPI collective. # Arguments -* `conn`:\\[in\\] A valid connectivity -* `num_per_dim`:\\[in\\] The number of new trees in each direction. Must use no more than P8EST_OLD_QMAXLEVEL bits. -# Returns -a refined connectivity. +* `array`:\\[in,out\\] Initialized with writing mode enabled. +# See also +[`t8_shmem_array_start_writing`](@ref). + ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_refine (p8est_connectivity_t * conn, int num_per_dim); +void t8_shmem_array_end_writing (t8_shmem_array_t array); ``` """ -function p8est_connectivity_refine(conn, num_per_dim) - @ccall libp4est.p8est_connectivity_refine(conn::Ptr{p8est_connectivity_t}, num_per_dim::Cint)::Ptr{p8est_connectivity_t} +function t8_shmem_array_end_writing(array) + @ccall libt8.t8_shmem_array_end_writing(array::t8_shmem_array_t)::Cvoid end """ - p8est_expand_face_transform(iface, nface, ftransform) + t8_shmem_array_set_gloidx(array, index, value) -Fill an array with the axis combination of a face neighbor transform. +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 -* `iface`:\\[in\\] The number of the originating face. -* `nface`:\\[in\\] Encoded as nface = r * 6 + nf, where nf = 0..5 is the neigbbor's connecting face number and r = 0..3 is the relative orientation to the neighbor's face. This encoding matches [`p8est_connectivity_t`](@ref). -* `ftransform`:\\[out\\] This array holds 9 integers. [0]..[2] The coordinate axis sequence of the origin face, the first two referring to the tangentials and the third to the normal. A permutation of (0, 1, 2). [3]..[5] The coordinate axis sequence of the target face. [6]..[8] Edge reversal flags for tangential axes (boolean); face code in [0, 3] for the normal coordinate q: 0: q' = -q 1: q' = q + 1 2: q' = q - 1 3: q' = 2 - q +* `array`:\\[in,out\\] The array to be modified. +* `index`:\\[in\\] The array entry to be modified. +* `value`:\\[in\\] The new value to be set. ### Prototype ```c -void p8est_expand_face_transform (int iface, int nface, int ftransform[]); +void t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value); ``` """ -function p8est_expand_face_transform(iface, nface, ftransform) - @ccall libp4est.p8est_expand_face_transform(iface::Cint, nface::Cint, ftransform::Ptr{Cint})::Cvoid +function t8_shmem_array_set_gloidx(array, index, value) + @ccall libt8.t8_shmem_array_set_gloidx(array::t8_shmem_array_t, index::Cint, value::t8_gloidx_t)::Cvoid end """ - p8est_find_face_transform(connectivity, itree, iface, ftransform) + t8_shmem_array_copy(dest, source) -Fill an array with the axis combination of a face neighbor transform. +Copy the contents of one t8\\_shmem array into another. -# 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). +!!! note -### Prototype -```c -p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iface, int ftransform[]); -``` -""" -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 + *dest* must be initialized and match in element size and element count to *source*. -""" - p8est_find_edge_transform(connectivity, itree, iedge, ei) +!!! note -Fills an array with information about edge neighbors. + *dest* must have writing mode disabled. # 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. +* `dest`:\\[in,out\\] The array in which *source* should be copied. +* `source`:\\[in\\] The array to copy. ### Prototype ```c -void p8est_find_edge_transform (p8est_connectivity_t * connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t * ei); +void t8_shmem_array_copy (t8_shmem_array_t dest, t8_shmem_array_t source); ``` """ -function p8est_find_edge_transform(connectivity, itree, iedge, ei) - @ccall libp4est.p8est_find_edge_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, iedge::Cint, ei::Ptr{p8est_edge_info_t})::Cvoid +function t8_shmem_array_copy(dest, source) + @ccall libt8.t8_shmem_array_copy(dest::t8_shmem_array_t, source::t8_shmem_array_t)::Cvoid end """ - p8est_find_corner_transform(connectivity, itree, icorner, ci) - -Fills an array with information about corner neighbors. + t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) -# 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); +void t8_shmem_array_allgather (const void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, int recvcount, sc_MPI_Datatype recvtype); ``` """ -function p8est_find_corner_transform(connectivity, itree, icorner, ci) - @ccall libp4est.p8est_find_corner_transform(connectivity::Ptr{p8est_connectivity_t}, itree::p4est_topidx_t, icorner::Cint, ci::Ptr{p8est_corner_info_t})::Cvoid +function t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) + @ccall libt8.t8_shmem_array_allgather(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvcount::Cint, recvtype::Cint)::Cvoid end """ - p8est_connectivity_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_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) -# Arguments -* `conn`:\\[in,out\\] The connectivity needs to have proper vertices and tree\\_to\\_vertex fields. The tree\\_to\\_tree and tree\\_to\\_face fields must be allocated and satisfy [`p8est_connectivity_is_valid`](@ref) (conn) but will be overwritten. The edge and corner fields will be freed and allocated anew. ### Prototype ```c -void p8est_connectivity_complete (p8est_connectivity_t * conn); +void t8_shmem_array_allgatherv (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, sc_MPI_Datatype recvtype, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_complete(conn) - @ccall libp4est.p8est_connectivity_complete(conn::Ptr{p8est_connectivity_t})::Cvoid +function t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) + @ccall libt8.t8_shmem_array_allgatherv(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvtype::Cint, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_reduce(conn) - -Removes corner and edge information of a connectivity such that enough information is left to run [`p8est_connectivity_complete`](@ref) successfully. The reduced connectivity still passes [`p8est_connectivity_is_valid`](@ref). + t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) -# Arguments -* `conn`:\\[in,out\\] The connectivity to be reduced. ### Prototype ```c -void p8est_connectivity_reduce (p8est_connectivity_t * conn); +void t8_shmem_array_prefix (const void *sendbuf, t8_shmem_array_t recvarray, const int count, sc_MPI_Datatype type, sc_MPI_Op op, sc_MPI_Comm comm); ``` """ -function p8est_connectivity_reduce(conn) - @ccall libp4est.p8est_connectivity_reduce(conn::Ptr{p8est_connectivity_t})::Cvoid +function t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) + @ccall libt8.t8_shmem_array_prefix(sendbuf::Ptr{Cvoid}, recvarray::t8_shmem_array_t, count::Cint, type::Cint, op::Cint, comm::MPI_Comm)::Cvoid end """ - p8est_connectivity_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. + t8_shmem_array_get_comm(array) -# 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 p8est_connectivity_permute (p8est_connectivity_t * conn, sc_array_t * perm, int is_current_to_new); +sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array); ``` """ -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_shmem_array_get_comm(array) + @ccall libt8.t8_shmem_array_get_comm(array::t8_shmem_array_t)::Cint end """ - p8est_connectivity_join_faces(conn, tree_left, tree_right, face_left, face_right, orientation) + t8_shmem_array_get_elem_size(array) -[`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. +Get the element size of a [`t8_shmem_array`](@ref) # 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). +* `array`:\\[in\\] The array. +# Returns +The element size of *array*'s elements. ### 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); +size_t t8_shmem_array_get_elem_size (t8_shmem_array_t array); ``` """ -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_shmem_array_get_elem_size(array) + @ccall libt8.t8_shmem_array_get_elem_size(array::t8_shmem_array_t)::Csize_t end """ - p8est_connectivity_is_equivalent(conn1, conn2) + t8_shmem_array_get_elem_count(array) -[`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. +Get the number of elements of a [`t8_shmem_array`](@ref) # Arguments -* `conn1`:\\[in\\] a valid connectivity -* `conn2`:\\[out\\] a valid connectivity +* `array`:\\[in\\] The array. +# Returns +The number of elements in *array*. ### Prototype ```c -int p8est_connectivity_is_equivalent (p8est_connectivity_t * conn1, p8est_connectivity_t * conn2); +size_t t8_shmem_array_get_elem_count (t8_shmem_array_t array); ``` """ -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_shmem_array_get_elem_count(array) + @ccall libt8.t8_shmem_array_get_elem_count(array::t8_shmem_array_t)::Csize_t end """ - p8est_edge_array_index(array, it) + t8_shmem_array_get_gloidx_array(array) + +Return a read-only pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. +!!! note + + Writing mode must be disabled for *array*. + +# Arguments +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +# Returns +The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -static inline p8est_edge_transform_t * p8est_edge_array_index (sc_array_t * array, size_t it); +const t8_gloidx_t * t8_shmem_array_get_gloidx_array (t8_shmem_array_t array); ``` """ -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_shmem_array_get_gloidx_array(array) + @ccall libt8.t8_shmem_array_get_gloidx_array(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} end """ - p8est_corner_array_index(array, it) + t8_shmem_array_get_gloidx_array_for_writing(array) + +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 +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +# Returns +The data of *array* as [`t8_gloidx_t`](@ref) pointer. ### Prototype ```c -static inline p8est_corner_transform_t * p8est_corner_array_index (sc_array_t * array, size_t it); +t8_gloidx_t * t8_shmem_array_get_gloidx_array_for_writing (t8_shmem_array_t array); ``` """ -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_shmem_array_get_gloidx_array_for_writing(array) + @ccall libt8.t8_shmem_array_get_gloidx_array_for_writing(array::t8_shmem_array_t)::Ptr{t8_gloidx_t} end """ - p8est_connectivity_read_inp_stream(stream, num_vertices, num_trees, vertices, tree_to_vertex) + t8_shmem_array_get_gloidx(array, index) -Read an ABAQUS input file from a file stream. +Return an entry of a shared memory array that stores [`t8_gloidx_t`](@ref). -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. +!!! note -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: + Writing mode must be disabled for *array*. -4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 +# Arguments +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +* `index`:\\[in\\] The index of the entry to be queried. +# Returns +The *index*-th entry of *array* as [`t8_gloidx_t`](@ref). +### Prototype +```c +t8_gloidx_t t8_shmem_array_get_gloidx (t8_shmem_array_t array, int index); +``` +""" +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 -and in 3D they are given as: +""" + t8_shmem_array_get_array(array) -8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 +Return a pointer to the data array of a [`t8_shmem_array`](@ref). -```c++ - *Heading - box.inp - *Node - 1, 5, -5, 5 - 2, 5, 5, 5 - 3, 5, 0, 5 - 4, -5, 5, 5 - 5, 0, 5, 5 - 6, -5, -5, 5 - 7, -5, 0, 5 - 8, 0, -5, 5 - 9, 0, 0, 5 - 10, 5, 5, -5 - 11, 5, -5, -5 - 12, 5, 0, -5 - 13, -5, -5, -5 - 14, 0, -5, -5 - 15, -5, 5, -5 - 16, -5, 0, -5 - 17, 0, 5, -5 - 18, 0, 0, -5 - 19, -5, -5, 0 - 20, 5, -5, 0 - 21, 0, -5, 0 - 22, -5, 5, 0 - 23, -5, 0, 0 - 24, 5, 5, 0 - 25, 0, 5, 0 - 26, 5, 0, 0 - 27, 0, 0, 0 - *Element, type=C3D8, ELSET=EB1 - 1, 6, 19, 23, 7, 8, 21, 27, 9 - 2, 19, 13, 16, 23, 21, 14, 18, 27 - 3, 7, 23, 22, 4, 9, 27, 25, 5 - 4, 23, 16, 15, 22, 27, 18, 17, 25 - 5, 8, 21, 27, 9, 1, 20, 26, 3 - 6, 21, 14, 18, 27, 20, 11, 12, 26 - 7, 9, 27, 25, 5, 3, 26, 24, 2 - 8, 27, 18, 17, 25, 26, 12, 10, 24 -``` +!!! note -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`. + Writing mode must be disabled for *array*. # 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 +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). # Returns -0 if successful and nonzero if not +A pointer to the data array of *array*. ### 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); +const void * t8_shmem_array_get_array (t8_shmem_array_t array); ``` """ -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_shmem_array_get_array(array) + @ccall libt8.t8_shmem_array_get_array(array::t8_shmem_array_t)::Ptr{Cvoid} end """ - p8est_connectivity_read_inp(filename) - -Create a p4est connectivity from an ABAQUS input file. + t8_shmem_array_index(array, index) -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. +Return a read-only pointer to an element in a [`t8_shmem_array`](@ref). -A basic 2D mesh is given below. The `*Node` section gives the vertex number and x, y, and z components for each vertex. The `*Element` section gives the 4 vertices in 2D (8 vertices in 3D) of each element in counter clockwise order. So in 2D the nodes are given as: +!!! note -4 3 +-------------------+ | | | | | | | | | | | | +-------------------+ 1 2 + You should not modify the value. -and in 3D they are given as: +!!! note -8 7 +---------------------+ |\\ |\\ | \\ | \\ | \\ | \\ | \\ | \\ | 5+---------------------+6 | | | | +----|----------------+ | 4\\ | 3 \\ | \\ | \\ | \\ | \\ | \\| \\| +---------------------+ 1 2 + Writing mode must be disabled for *array*. -```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 +# Arguments +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). +* `index`:\\[in\\] The index of an element. +# Returns +A pointer to the element at *index* in *array*. +### Prototype +```c +const void * t8_shmem_array_index (t8_shmem_array_t array, size_t index); ``` +""" +function t8_shmem_array_index(array, index) + @ccall libt8.t8_shmem_array_index(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} +end -This function reads a mesh from *filename* and returns an associated p4est connectivity. +""" + 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 + + Writing mode must be enabled for *array*. # Arguments -* `filename`:\\[in\\] file to read the connectivity from +* `array`:\\[in\\] The [`t8_shmem_array`](@ref). +* `index`:\\[in\\] The index of an element. # Returns -an allocated connectivity associated with the mesh in *filename* +A pointer to the element at *index* in *array*. ### Prototype ```c -p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename); +void * t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index); ``` """ -function p8est_connectivity_read_inp(filename) - @ccall libp4est.p8est_connectivity_read_inp(filename::Cstring)::Ptr{p8est_connectivity_t} +function t8_shmem_array_index_for_writing(array, index) + @ccall libt8.t8_shmem_array_index_for_writing(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} end """ - t8_cmesh_new_from_p4est(conn, comm, do_partition) + t8_shmem_array_is_equal(array_a, array_b) + +Check if two t8\\_shmem arrays are equal. +!!! note + + Writing mode must be disabled for *array_a* and *array_b*. + +# Arguments +* `array_a`:\\[in\\] The first [`t8_shmem_array`](@ref) to compare. +* `array_b`:\\[in\\] The second [`t8_shmem_array`](@ref) to compare. +# Returns +1 if the arrays are equal, 0 otherwise. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); +int t8_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b); ``` """ -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_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_cmesh_new_from_p8est(conn, comm, do_partition) + t8_shmem_array_destroy(parray) + +Free all memory associated with a [`t8_shmem_array`](@ref). +# Arguments +* `parray`:\\[in,out\\] On input a pointer to a valid [`t8_shmem_array`](@ref). This array is freed and *parray* is set to NULL on return. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition); +void t8_shmem_array_destroy (t8_shmem_array_t *parray); ``` """ -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_shmem_array_destroy(parray) + @ccall libt8.t8_shmem_array_destroy(parray::Ptr{t8_shmem_array_t})::Cvoid end """ - t8_cmesh_new_empty(comm, do_partition, dimension) + t8_shmem_array_binary_search(array, value, size, compare) +Perform a binary search in a [`t8_shmem_array`](@ref). + +# Arguments +* `array`:\\[in\\] The [`t8_shmem_array`](@ref) to search in. +* `value`:\\[in\\] The value to search for. +* `size`:\\[in\\] The number of elements in the array. +* `compare`:\\[in\\] A function that compares an element of the array with the value. +# Returns +The index of the element in *array* that matches *value*. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_empty (sc_MPI_Comm comm, const int do_partition, const int dimension); +int t8_shmem_array_binary_search (t8_shmem_array_t array, const t8_gloidx_t value, const int size, int (*compare) (t8_shmem_array_t, const int, const t8_gloidx_t)); ``` """ -function 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_shmem_array_binary_search(array, value, size, compare) + @ccall libt8.t8_shmem_array_binary_search(array::t8_shmem_array_t, value::t8_gloidx_t, size::Cint, compare::Ptr{Cvoid})::Cint end """ - t8_cmesh_new_from_class(eclass, comm) + sc_keyvalue_entry_type_t +The values can have different types. + +| Enumerator | Note | +| :------------------------------ | :------------------------------------------ | +| SC\\_KEYVALUE\\_ENTRY\\_NONE | Designate an invalid situation. | +| SC\\_KEYVALUE\\_ENTRY\\_INT | Used for values of type int. | +| SC\\_KEYVALUE\\_ENTRY\\_DOUBLE | Used for values of type double. | +| SC\\_KEYVALUE\\_ENTRY\\_STRING | Used for values of type const char *. | +| SC\\_KEYVALUE\\_ENTRY\\_POINTER | Used for values of anonymous pointer type. | +""" +@cenum sc_keyvalue_entry_type_t::UInt32 begin + SC_KEYVALUE_ENTRY_NONE = 0 + SC_KEYVALUE_ENTRY_INT = 1 + SC_KEYVALUE_ENTRY_DOUBLE = 2 + SC_KEYVALUE_ENTRY_STRING = 3 + SC_KEYVALUE_ENTRY_POINTER = 4 +end + +mutable struct sc_keyvalue end + +"""The key-value container is an opaque structure.""" +const sc_keyvalue_t = sc_keyvalue + +# no prototype is found for this function at sc_keyvalue.h:54:21, please use with caution +""" + sc_keyvalue_new() + +Create a new key-value container. + +# Returns +The container is ready to use. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_from_class (t8_eclass_t eclass, sc_MPI_Comm comm); +sc_keyvalue_t *sc_keyvalue_new (); ``` """ -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 sc_keyvalue_new() + @ccall libt8.sc_keyvalue_new()::Ptr{sc_keyvalue_t} end +# automatic type deduction for variadic arguments may not be what you want, please use with caution +@generated function sc_keyvalue_newf(dummy, va_list...) + :(@ccall(libt8.sc_keyvalue_newf(dummy::Cint; $(to_c_type_pairs(va_list)...))::Ptr{sc_keyvalue_t})) + end + """ - t8_cmesh_new_hypercube(eclass, comm, do_bcast, do_partition, periodic) + sc_keyvalue_destroy(kv) +Free a key-value container and all internal memory for key storage. + +# Arguments +* `kv`:\\[in,out\\] The key-value container is invalidated by this call. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int do_partition, int periodic); +void sc_keyvalue_destroy (sc_keyvalue_t * kv); ``` """ -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 sc_keyvalue_destroy(kv) + @ccall libt8.sc_keyvalue_destroy(kv::Ptr{sc_keyvalue_t})::Cvoid end """ - t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) + sc_keyvalue_exists(kv, key) + +Routine to check existence of an entry. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key to query. +# Returns +The entry's type if found and SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned); +sc_keyvalue_entry_type_t sc_keyvalue_exists (sc_keyvalue_t * kv, const char *key); ``` """ -function t8_cmesh_new_hypercube_pad(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned) - @ccall libt8.t8_cmesh_new_hypercube_pad(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, use_axis_aligned::Cint)::t8_cmesh_t +function sc_keyvalue_exists(kv, key) + @ccall libt8.sc_keyvalue_exists(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t end """ - t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) + sc_keyvalue_unset(kv, key) + +Routine to remove an entry. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key to remove if it exists. +# Returns +The entry's type if found and removed, SC\\_KEYVALUE\\_ENTRY\\_NONE otherwise. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_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); +sc_keyvalue_entry_type_t sc_keyvalue_unset (sc_keyvalue_t * kv, const char *key); ``` """ -function t8_cmesh_new_hypercube_pad_ext(eclass, comm, boundary, polygons_x, polygons_y, polygons_z, periodic_x, periodic_y, periodic_z, use_axis_aligned, set_partition, offset) - @ccall libt8.t8_cmesh_new_hypercube_pad_ext(eclass::t8_eclass_t, comm::MPI_Comm, boundary::Ptr{Cdouble}, polygons_x::t8_locidx_t, polygons_y::t8_locidx_t, polygons_z::t8_locidx_t, periodic_x::Cint, periodic_y::Cint, periodic_z::Cint, use_axis_aligned::Cint, set_partition::Cint, offset::t8_gloidx_t)::t8_cmesh_t +function sc_keyvalue_unset(kv, key) + @ccall libt8.sc_keyvalue_unset(kv::Ptr{sc_keyvalue_t}, key::Cstring)::sc_keyvalue_entry_type_t end """ - t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) + sc_keyvalue_get_int(kv, key, dvalue) +Routines to retrieve an integer value by its key. This function asserts that the key, if existing, points to the correct type. + +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. +# Returns +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, int do_partition, int periodic); +int sc_keyvalue_get_int (sc_keyvalue_t * kv, const char *key, int dvalue); ``` """ -function t8_cmesh_new_hypercube_hybrid(comm, do_partition, periodic) - @ccall libt8.t8_cmesh_new_hypercube_hybrid(comm::MPI_Comm, do_partition::Cint, periodic::Cint)::t8_cmesh_t +function sc_keyvalue_get_int(kv, key, dvalue) + @ccall libt8.sc_keyvalue_get_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cint)::Cint end """ - t8_cmesh_new_periodic(comm, dim) + sc_keyvalue_get_double(kv, key, dvalue) + +Retrieve a double value by its key. This function asserts that the key, if existing, points to the correct type. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. +# Returns +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic (sc_MPI_Comm comm, int dim); +double sc_keyvalue_get_double (sc_keyvalue_t * kv, const char *key, double dvalue); ``` """ -function t8_cmesh_new_periodic(comm, dim) - @ccall libt8.t8_cmesh_new_periodic(comm::MPI_Comm, dim::Cint)::t8_cmesh_t +function sc_keyvalue_get_double(kv, key, dvalue) + @ccall libt8.sc_keyvalue_get_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cdouble)::Cdouble end """ - t8_cmesh_new_periodic_tri(comm) + sc_keyvalue_get_string(kv, key, dvalue) +Retrieve a string value by its key. This function asserts that the key, if existing, points to the correct type. + +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. +# Returns +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_tri (sc_MPI_Comm comm); +const char *sc_keyvalue_get_string (sc_keyvalue_t * kv, const char *key, const char *dvalue); ``` """ -function t8_cmesh_new_periodic_tri(comm) - @ccall libt8.t8_cmesh_new_periodic_tri(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_get_string(kv, key, dvalue) + @ccall libt8.sc_keyvalue_get_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Cstring)::Cstring end """ - t8_cmesh_new_periodic_hybrid(comm) + sc_keyvalue_get_pointer(kv, key, dvalue) + +Retrieve a pointer value by its key. This function asserts that the key, if existing, points to the correct type. +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `key`:\\[in\\] Lookup key, may or may not exist. +* `dvalue`:\\[in\\] Default value returned if key is not found. +# Returns +If key is not present then **dvalue** is returned, otherwise the value stored under **key**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_hybrid (sc_MPI_Comm comm); +void *sc_keyvalue_get_pointer (sc_keyvalue_t * kv, const char *key, void *dvalue); ``` """ -function t8_cmesh_new_periodic_hybrid(comm) - @ccall libt8.t8_cmesh_new_periodic_hybrid(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_get_pointer(kv, key, dvalue) + @ccall libt8.sc_keyvalue_get_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, dvalue::Ptr{Cvoid})::Ptr{Cvoid} end """ - t8_cmesh_new_periodic_line_more_trees(comm) + sc_keyvalue_get_int_check(kv, key, status) +Query an integer key with error checking. We check whether the key is not found or it is of the wrong type. A default value to be returned on error can be passed in as *status. If status is NULL, then the result on error is undefined. + +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key string. +* `status`:\\[in,out\\] If not NULL, set to 0 if there is no error, 1 if the key is not found, 2 if a value is found but its type is not integer, and return the input value *status on error. +# Returns +On error we return *status if status is not NULL, and else an undefined value backed by an assertion. Without error, return the result of the lookup. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm); +int sc_keyvalue_get_int_check (sc_keyvalue_t * kv, const char *key, int *status); ``` """ -function t8_cmesh_new_periodic_line_more_trees(comm) - @ccall libt8.t8_cmesh_new_periodic_line_more_trees(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_get_int_check(kv, key, status) + @ccall libt8.sc_keyvalue_get_int_check(kv::Ptr{sc_keyvalue_t}, key::Cstring, status::Ptr{Cint})::Cint end """ - t8_cmesh_new_bigmesh(eclass, num_trees, comm) + sc_keyvalue_set_int(kv, key, newvalue) + +Routine to set an integer value for a given key. +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type integer. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_bigmesh (t8_eclass_t eclass, int num_trees, sc_MPI_Comm comm); +void sc_keyvalue_set_int (sc_keyvalue_t * kv, const char *key, int newvalue); ``` """ -function t8_cmesh_new_bigmesh(eclass, num_trees, comm) - @ccall libt8.t8_cmesh_new_bigmesh(eclass::t8_eclass_t, num_trees::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_set_int(kv, key, newvalue) + @ccall libt8.sc_keyvalue_set_int(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cint)::Cvoid end """ - t8_cmesh_new_line_zigzag(comm) + sc_keyvalue_set_double(kv, key, newvalue) + +Routine to set a double value for a given key. +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type double. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_line_zigzag (sc_MPI_Comm comm); +void sc_keyvalue_set_double (sc_keyvalue_t * kv, const char *key, double newvalue); ``` """ -function t8_cmesh_new_line_zigzag(comm) - @ccall libt8.t8_cmesh_new_line_zigzag(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_set_double(kv, key, newvalue) + @ccall libt8.sc_keyvalue_set_double(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cdouble)::Cvoid end """ - t8_cmesh_new_prism_cake(comm, num_of_prisms) + sc_keyvalue_set_string(kv, key, newvalue) + +Routine to set a string value for a given key. + +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type string. +* `newvalue`:\\[in\\] New value will be stored under key. +### Prototype +```c +void sc_keyvalue_set_string (sc_keyvalue_t * kv, const char *key, const char *newvalue); +``` +""" +function sc_keyvalue_set_string(kv, key, newvalue) + @ccall libt8.sc_keyvalue_set_string(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Cstring)::Cvoid +end + +""" + sc_keyvalue_set_pointer(kv, key, newvalue) + +Routine to set a pointer value for a given key. +# Arguments +* `kv`:\\[in\\] Valid key-value table. +* `key`:\\[in\\] Non-NULL key to insert or replace. If it already exists, it must be of type pointer. +* `newvalue`:\\[in\\] New value will be stored under key. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prism_cake (sc_MPI_Comm comm, int num_of_prisms); +void sc_keyvalue_set_pointer (sc_keyvalue_t * kv, const char *key, void *newvalue); ``` """ -function t8_cmesh_new_prism_cake(comm, num_of_prisms) - @ccall libt8.t8_cmesh_new_prism_cake(comm::MPI_Comm, num_of_prisms::Cint)::t8_cmesh_t +function sc_keyvalue_set_pointer(kv, key, newvalue) + @ccall libt8.sc_keyvalue_set_pointer(kv::Ptr{sc_keyvalue_t}, key::Cstring, newvalue::Ptr{Cvoid})::Cvoid end +# typedef int ( * sc_keyvalue_foreach_t ) ( const char * key , const sc_keyvalue_entry_type_t type , void * entry , const void * u ) """ - t8_cmesh_new_prism_deformed(comm) +Function to call on every key value pair -### Prototype -```c -t8_cmesh_t t8_cmesh_new_prism_deformed (sc_MPI_Comm comm); -``` +# Arguments +* `key`:\\[in\\] The key for this pair +* `type`:\\[in\\] The type of entry +* `entry`:\\[in\\] Pointer to the entry +* `u`:\\[in\\] Arbitrary user data. +# Returns +Return true if the traversal should continue, false to stop. """ -function t8_cmesh_new_prism_deformed(comm) - @ccall libt8.t8_cmesh_new_prism_deformed(comm::MPI_Comm)::t8_cmesh_t -end +const sc_keyvalue_foreach_t = Ptr{Cvoid} """ - t8_cmesh_new_pyramid_deformed(comm) + sc_keyvalue_foreach(kv, fn, user_data) +Iterate through all stored key-value pairs. + +# Arguments +* `kv`:\\[in\\] Valid key-value container. +* `fn`:\\[in\\] Function to call on each key-value pair. +* `user_data`:\\[in,out\\] This pointer is passed through to **fn**. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_pyramid_deformed (sc_MPI_Comm comm); +void sc_keyvalue_foreach (sc_keyvalue_t * kv, sc_keyvalue_foreach_t fn, void *user_data); ``` """ -function t8_cmesh_new_pyramid_deformed(comm) - @ccall libt8.t8_cmesh_new_pyramid_deformed(comm::MPI_Comm)::t8_cmesh_t +function sc_keyvalue_foreach(kv, fn, user_data) + @ccall libt8.sc_keyvalue_foreach(kv::Ptr{sc_keyvalue_t}, fn::sc_keyvalue_foreach_t, user_data::Ptr{Cvoid})::Cvoid end """ - t8_cmesh_new_prism_cake_funny_oriented(comm) + sc_statinfo -### Prototype -```c -t8_cmesh_t t8_cmesh_new_prism_cake_funny_oriented (sc_MPI_Comm comm); -``` +Store information of one random variable. + +| Field | Note | +| :--------------- | :--------------------------------------- | +| dirty | Only update stats if this is true. | +| count | Inout; global count is 52 bit accurate. | +| sum\\_values | Inout; global sum of values. | +| sum\\_squares | Inout; global sum of squares. | +| min | Inout; minimum over values. | +| max | Inout; maximum over values. | +| variable | Name of the variable for output. | +| variable\\_owned | NULL or deep copy of variable. | +| group | Grouping identifier. | +| prio | Priority identifier. | """ -function t8_cmesh_new_prism_cake_funny_oriented(comm) - @ccall libt8.t8_cmesh_new_prism_cake_funny_oriented(comm::MPI_Comm)::t8_cmesh_t +struct sc_statinfo + dirty::Cint + count::Clong + sum_values::Cdouble + sum_squares::Cdouble + min::Cdouble + max::Cdouble + min_at_rank::Cint + max_at_rank::Cint + average::Cdouble + variance::Cdouble + standev::Cdouble + variance_mean::Cdouble + standev_mean::Cdouble + variable::Cstring + variable_owned::Cstring + group::Cint + prio::Cint end -""" - t8_cmesh_new_prism_geometry(comm) +"""Store information of one random variable.""" +const sc_statinfo_t = sc_statinfo -### Prototype -```c -t8_cmesh_t t8_cmesh_new_prism_geometry (sc_MPI_Comm comm); -``` -""" -function t8_cmesh_new_prism_geometry(comm) - @ccall libt8.t8_cmesh_new_prism_geometry(comm::MPI_Comm)::t8_cmesh_t +struct sc_stats + mpicomm::MPI_Comm + kv::Ptr{sc_keyvalue_t} + sarray::Ptr{sc_array_t} end +"""The statistics container allows dynamically adding random variables.""" +const sc_statistics_t = sc_stats + """ - t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) + sc_stats_set1(stats, value, variable) + +Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. We set sc_stats_group_all and sc_stats_prio_all internally. +# Arguments +* `stats`:\\[out\\] Will be filled with count=1 and the value. +* `value`:\\[in\\] Value used to fill statistics information. +* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_brick_2d (t8_gloidx_t num_x, t8_gloidx_t num_y, int x_periodic, int y_periodic, sc_MPI_Comm comm); +void sc_stats_set1 (sc_statinfo_t * stats, double value, const char *variable); ``` """ -function t8_cmesh_new_brick_2d(num_x, num_y, x_periodic, y_periodic, comm) - @ccall libt8.t8_cmesh_new_brick_2d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_stats_set1(stats, value, variable) + @ccall libt8.sc_stats_set1(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring)::Cvoid end """ - t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) + +Populate a [`sc_statinfo_t`](@ref) structure assuming count=1 and mark it dirty. +# Arguments +* `stats`:\\[out\\] Will be filled with count=1 and the value. +* `value`:\\[in\\] Value used to fill statistics information. +* `variable`:\\[in\\] String to be reported by sc_stats_print. +* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. +* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. +* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_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); +void sc_stats_set1_ext (sc_statinfo_t * stats, double value, const char *variable, int copy_variable, int stats_group, int stats_prio); ``` """ -function t8_cmesh_new_brick_3d(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) - @ccall libt8.t8_cmesh_new_brick_3d(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_stats_set1_ext(stats, value, variable, copy_variable, stats_group, stats_prio) + @ccall libt8.sc_stats_set1_ext(stats::Ptr{sc_statinfo_t}, value::Cdouble, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid end """ - t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) + sc_stats_init(stats, variable) + +Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. We set sc_stats_group_all and sc_stats_prio_all internally. +# Arguments +* `stats`:\\[out\\] Will be filled with count 0 and values of 0. +* `variable`:\\[in\\] String to be reported by sc_stats_print. This string is assigned by pointer, not copied. Thus, it must stay alive while stats is in use. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_disjoint_bricks (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic, int z_periodic, sc_MPI_Comm comm); +void sc_stats_init (sc_statinfo_t * stats, const char *variable); ``` """ -function t8_cmesh_new_disjoint_bricks(num_x, num_y, num_z, x_periodic, y_periodic, z_periodic, comm) - @ccall libt8.t8_cmesh_new_disjoint_bricks(num_x::t8_gloidx_t, num_y::t8_gloidx_t, num_z::t8_gloidx_t, x_periodic::Cint, y_periodic::Cint, z_periodic::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_stats_init(stats, variable) + @ccall libt8.sc_stats_init(stats::Ptr{sc_statinfo_t}, variable::Cstring)::Cvoid end """ - t8_cmesh_new_tet_orientation_test(comm) + sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) + +Initialize a [`sc_statinfo_t`](@ref) structure assuming count=0 and mark it dirty. This is useful if *stats* will be used to sc_stats_accumulate instances locally before global statistics are computed. +# Arguments +* `stats`:\\[out\\] Will be filled with count 0 and values of 0. +* `variable`:\\[in\\] String to be reported by sc_stats_print. +* `copy_variable`:\\[in\\] If true, make internal copy of variable. Otherwise just assign the pointer. +* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. +* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_tet_orientation_test (sc_MPI_Comm comm); +void sc_stats_init_ext (sc_statinfo_t * stats, const char *variable, int copy_variable, int stats_group, int stats_prio); ``` """ -function t8_cmesh_new_tet_orientation_test(comm) - @ccall libt8.t8_cmesh_new_tet_orientation_test(comm::MPI_Comm)::t8_cmesh_t +function sc_stats_init_ext(stats, variable, copy_variable, stats_group, stats_prio) + @ccall libt8.sc_stats_init_ext(stats::Ptr{sc_statinfo_t}, variable::Cstring, copy_variable::Cint, stats_group::Cint, stats_prio::Cint)::Cvoid end """ - t8_cmesh_new_hybrid_gate(comm) + sc_stats_reset(stats, reset_vgp) + +Reset all values to zero, optionally unassign name, group, and priority. +# Arguments +* `stats`:\\[in,out\\] Variables are zeroed. They can be set again by set1 or accumulate. +* `reset_vgp`:\\[in\\] If true, the variable name string is zeroed and if we did a copy, the copy is freed. If true, group and priority are set to all. If false, we don't touch any of the above. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hybrid_gate (sc_MPI_Comm comm); +void sc_stats_reset (sc_statinfo_t * stats, int reset_vgp); ``` """ -function t8_cmesh_new_hybrid_gate(comm) - @ccall libt8.t8_cmesh_new_hybrid_gate(comm::MPI_Comm)::t8_cmesh_t +function sc_stats_reset(stats, reset_vgp) + @ccall libt8.sc_stats_reset(stats::Ptr{sc_statinfo_t}, reset_vgp::Cint)::Cvoid end """ - t8_cmesh_new_hybrid_gate_deformed(comm) + sc_stats_set_group_prio(stats, stats_group, stats_prio) + +Set/update the group and priority information for a stats item. +# Arguments +* `stats`:\\[out\\] Only group and stats entries are updated. +* `stats_group`:\\[in\\] Non-negative number or sc_stats_group_all. +* `stats_prio`:\\[in\\] Non-negative number or sc_stats_prio_all. Values increase by importance. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_hybrid_gate_deformed (sc_MPI_Comm comm); +void sc_stats_set_group_prio (sc_statinfo_t * stats, int stats_group, int stats_prio); ``` """ -function t8_cmesh_new_hybrid_gate_deformed(comm) - @ccall libt8.t8_cmesh_new_hybrid_gate_deformed(comm::MPI_Comm)::t8_cmesh_t +function sc_stats_set_group_prio(stats, stats_group, stats_prio) + @ccall libt8.sc_stats_set_group_prio(stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint)::Cvoid end """ - t8_cmesh_new_full_hybrid(comm) + sc_stats_accumulate(stats, value) + +Add an instance of the random variable. The counter of the variable is increased by one. The value is added into the present values of the variable. +# Arguments +* `stats`:\\[out\\] Must be dirty. We bump count and values. +* `value`:\\[in\\] Value used to update statistics information. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_full_hybrid (sc_MPI_Comm comm); +void sc_stats_accumulate (sc_statinfo_t * stats, double value); ``` """ -function t8_cmesh_new_full_hybrid(comm) - @ccall libt8.t8_cmesh_new_full_hybrid(comm::MPI_Comm)::t8_cmesh_t +function sc_stats_accumulate(stats, value) + @ccall libt8.sc_stats_accumulate(stats::Ptr{sc_statinfo_t}, value::Cdouble)::Cvoid end """ - t8_cmesh_new_pyramid_cake(comm, num_of_pyra) + sc_stats_compute(mpicomm, nvars, stats) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_pyramid_cake (sc_MPI_Comm comm, int num_of_pyra); +void sc_stats_compute (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); ``` """ -function t8_cmesh_new_pyramid_cake(comm, num_of_pyra) - @ccall libt8.t8_cmesh_new_pyramid_cake(comm::MPI_Comm, num_of_pyra::Cint)::t8_cmesh_t +function sc_stats_compute(mpicomm, nvars, stats) + @ccall libt8.sc_stats_compute(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid end """ - t8_cmesh_new_long_brick_pyramid(comm, num_cubes) + sc_stats_compute1(mpicomm, nvars, stats) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_long_brick_pyramid (sc_MPI_Comm comm, int num_cubes); +void sc_stats_compute1 (sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t * stats); ``` """ -function t8_cmesh_new_long_brick_pyramid(comm, num_cubes) - @ccall libt8.t8_cmesh_new_long_brick_pyramid(comm::MPI_Comm, num_cubes::Cint)::t8_cmesh_t +function sc_stats_compute1(mpicomm, nvars, stats) + @ccall libt8.sc_stats_compute1(mpicomm::MPI_Comm, nvars::Cint, stats::Ptr{sc_statinfo_t})::Cvoid end """ - t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm) + sc_stats_print(package_id, log_priority, nvars, stats, full, summary) + +Print measured statistics. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. All groups and priorities are printed. +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Log priority for output according to sc.h. +* `nvars`:\\[in\\] Number of stats items in input array. +* `stats`:\\[in\\] Input array of stats variable items. +* `full`:\\[in\\] Print full information for every variable. +* `summary`:\\[in\\] Print summary information all on 1 line. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, const int do_partition, sc_MPI_Comm comm); +void sc_stats_print (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int full, int summary); ``` """ -function t8_cmesh_new_row_of_cubes(num_trees, set_attributes, do_partition, comm) - @ccall libt8.t8_cmesh_new_row_of_cubes(num_trees::t8_locidx_t, set_attributes::Cint, do_partition::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_stats_print(package_id, log_priority, nvars, stats, full, summary) + @ccall libt8.sc_stats_print(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, full::Cint, summary::Cint)::Cvoid end """ - t8_cmesh_new_quadrangulated_disk(radius, comm) + sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) + +Print measured statistics, filter by group and/or priority. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Log priority for output according to sc.h. +* `nvars`:\\[in\\] Number of stats items in input array. +* `stats`:\\[in\\] Input array of stats variable items. +* `stats_group`:\\[in\\] Print only this group. Non-negative or sc_stats_group_all. We skip printing a variable if neither this parameter nor the item's group is all and if the item's group does not match this. +* `stats_prio`:\\[in\\] Print this and higher priorities. Non-negative or sc_stats_prio_all. We skip printing a variable if neither this parameter nor the item's prio is all and if the item's prio is less than this. +* `full`:\\[in\\] Print full information for every variable. This produces multiple lines including minimum, maximum, and standard deviation. If this is false, print one line per variable. +* `summary`:\\[in\\] Print summary information all on 1 line. This always contains all variables. Not affected by stats\\_group and stats\\_prio. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_quadrangulated_disk (const double radius, sc_MPI_Comm comm); +void sc_stats_print_ext (int package_id, int log_priority, int nvars, sc_statinfo_t * stats, int stats_group, int stats_prio, int full, int summary); ``` """ -function t8_cmesh_new_quadrangulated_disk(radius, comm) - @ccall libt8.t8_cmesh_new_quadrangulated_disk(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_stats_print_ext(package_id, log_priority, nvars, stats, stats_group, stats_prio, full, summary) + @ccall libt8.sc_stats_print_ext(package_id::Cint, log_priority::Cint, nvars::Cint, stats::Ptr{sc_statinfo_t}, stats_group::Cint, stats_prio::Cint, full::Cint, summary::Cint)::Cvoid end """ - t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) + sc_statistics_new(mpicomm) ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_MPI_Comm comm); +sc_statistics_t *sc_statistics_new (sc_MPI_Comm mpicomm); ``` """ -function t8_cmesh_new_triangulated_spherical_surface_octahedron(radius, comm) - @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_octahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_new(mpicomm) + @ccall libt8.sc_statistics_new(mpicomm::MPI_Comm)::Ptr{sc_statistics_t} end """ - t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) + sc_statistics_destroy(stats) + +Destroy a statistics structure. +# Arguments +* `stats`:\\[in,out\\] Valid object is invalidated. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc_MPI_Comm comm); +void sc_statistics_destroy (sc_statistics_t * stats); ``` """ -function t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius, comm) - @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_icosahedron(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_destroy(stats) + @ccall libt8.sc_statistics_destroy(stats::Ptr{sc_statistics_t})::Cvoid end """ - t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) + sc_statistics_add(stats, name) + +Register a statistics variable by name and set its value to 0. This variable must not exist already. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Comm comm); +void sc_statistics_add (sc_statistics_t * stats, const char *name); ``` """ -function t8_cmesh_new_triangulated_spherical_surface_cube(radius, comm) - @ccall libt8.t8_cmesh_new_triangulated_spherical_surface_cube(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_add(stats, name) + @ccall libt8.sc_statistics_add(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid end -""" - t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) +""" + sc_statistics_add_empty(stats, name) + +Register a statistics variable by name and set its count to 0. This variable must not exist already. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm); +void sc_statistics_add_empty (sc_statistics_t * stats, const char *name); ``` """ -function t8_cmesh_new_quadrangulated_spherical_surface(radius, comm) - @ccall libt8.t8_cmesh_new_quadrangulated_spherical_surface(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_add_empty(stats, name) + @ccall libt8.sc_statistics_add_empty(stats::Ptr{sc_statistics_t}, name::Cstring)::Cvoid end """ - t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + sc_statistics_has(stats, name) + +Returns true if the stats include a variable with the given name ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_octahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); +int sc_statistics_has (sc_statistics_t * stats, const char *name); ``` """ -function t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) - @ccall libt8.t8_cmesh_new_prismed_spherical_shell_octahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_has(stats, name) + @ccall libt8.sc_statistics_has(stats::Ptr{sc_statistics_t}, name::Cstring)::Cint end """ - t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) + sc_statistics_set(stats, name, value) + +Set the value of a statistics variable, see [`sc_stats_set1`](@ref). The variable must previously be added with [`sc_statistics_add`](@ref). This assumes count=1 as in the [`sc_stats_set1`](@ref) function above. ### Prototype ```c -t8_cmesh_t t8_cmesh_new_prismed_spherical_shell_icosahedron (const double inner_radius, const double shell_thickness, const int num_levels, const int num_layers, sc_MPI_Comm comm); +void sc_statistics_set (sc_statistics_t * stats, const char *name, double value); ``` """ -function t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius, shell_thickness, num_levels, num_layers, comm) - @ccall libt8.t8_cmesh_new_prismed_spherical_shell_icosahedron(inner_radius::Cdouble, shell_thickness::Cdouble, num_levels::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_set(stats, name, value) + @ccall libt8.sc_statistics_set(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid end """ - t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) + sc_statistics_accumulate(stats, name, value) + +Add an instance of a statistics variable, see [`sc_stats_accumulate`](@ref) The variable must previously be added with [`sc_statistics_add_empty`](@ref). ### 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); +void sc_statistics_accumulate (sc_statistics_t * stats, const char *name, double value); ``` """ -function t8_cmesh_new_cubed_spherical_shell(inner_radius, shell_thickness, num_trees, num_layers, comm) - @ccall libt8.t8_cmesh_new_cubed_spherical_shell(inner_radius::Cdouble, shell_thickness::Cdouble, num_trees::Cint, num_layers::Cint, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_accumulate(stats, name, value) + @ccall libt8.sc_statistics_accumulate(stats::Ptr{sc_statistics_t}, name::Cstring, value::Cdouble)::Cvoid end """ - t8_cmesh_new_cubed_sphere(radius, comm) + sc_statistics_compute(stats) + +Compute statistics for all variables, see [`sc_stats_compute`](@ref). ### Prototype ```c -t8_cmesh_t t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm); +void sc_statistics_compute (sc_statistics_t * stats); ``` """ -function t8_cmesh_new_cubed_sphere(radius, comm) - @ccall libt8.t8_cmesh_new_cubed_sphere(radius::Cdouble, comm::MPI_Comm)::t8_cmesh_t +function sc_statistics_compute(stats) + @ccall libt8.sc_statistics_compute(stats::Ptr{sc_statistics_t})::Cvoid end """ - t8_cmesh_get_tree_geom_hash(cmesh, gtreeid) + sc_statistics_print(stats, package_id, log_priority, full, summary) -Get the hash of the geometry stored for a tree in a cmesh. +Print all statistics variables, see [`sc_stats_print`](@ref). -# Arguments -* `cmesh`:\\[in\\] A committed cmesh. -* `gtreeid`:\\[in\\] A global tree in *cmesh*. -# Returns -The hash of the tree's geometry or if only one geometry exists, its hash. ### Prototype ```c -size_t t8_cmesh_get_tree_geom_hash (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); +void sc_statistics_print (sc_statistics_t * stats, int package_id, int log_priority, int full, int summary); ``` """ -function t8_cmesh_get_tree_geom_hash(cmesh, gtreeid) - @ccall libt8.t8_cmesh_get_tree_geom_hash(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Csize_t +function sc_statistics_print(stats, package_id, log_priority, full, summary) + @ccall libt8.sc_statistics_print(stats::Ptr{sc_statistics_t}, package_id::Cint, log_priority::Cint, full::Cint, summary::Cint)::Cvoid end """ - t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) - -Sets the face connectivity information of an un-committed based on a list of tree vertices. + t8_forest -!!! warning +| 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 | 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 | +| do\\_ghost | If True, a ghost layer will be created when the forest is committed. | +| ghost\\_type | If a ghost layer will be created, the type of neighbors that count as ghost. | +| ghost\\_algorithm | Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced 3 = top-down search and unbalanced. | +| user\\_data | Pointer for arbitrary user data. # See also [`t8_forest_set_user_data`](@ref). | +| user\\_function | Pointer for arbitrary user function. # See also [`t8_forest_set_user_function`](@ref). | +| t8code\\_data | Pointer for arbitrary data that is used internally. | +| committed | t8_forest_commit called? | +| mpisize | Number of MPI processes. | +| mpirank | Number of this MPI process. | +| first\\_local\\_tree | The global index of the first local tree on this process. If first\\_local\\_tree is larger than last\\_local\\_tree then this processor/forest is empty. See https://github.com/DLR-AMR/t8code/wiki/Tree-indexing | +| last\\_local\\_tree | The global index of the last local tree on this process. -1 if this processor is empty. | +| global\\_num\\_trees | The total number of global trees. | +| trees | The array of trees. | +| ghosts | If not NULL, the ghost elements. # See also [`t8_forest_ghost`](@ref).h | +| element\\_offsets | If partitioned, for each process the global index of its first element. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | +| global\\_first\\_desc | If partitioned, for each process the linear id (at maxlevel) of its first element's first descendant. t8_element_set_linear_id. Stores 0 for empty processes. Since it is memory consuming, it is usually only constructed when needed and otherwise unallocated. | +| tree\\_offsets | If partitioned for each process the global index of its first local tree or -(first local tree) - 1 if the first tree on that process is shared. Since this is memory consuming we only construct it when needed. This array follows the same logic as *tree_offsets* in [`t8_cmesh_t`](@ref) | +| local\\_num\\_leaf\\_elements | Number of leaf elements on this processor. | +| global\\_num\\_leaf\\_elements | Number of leaf elements on all processors. | +| profile | If not NULL, runtimes and statistics about forest\\_commit are stored here. | +| stats | The SC profiling stats of the forest. | +| stats\\_computed | Switch indicating whether the profiling stats have been compute (1) or not (0) | +""" +# This struct is not supposed to be read and modified directly. +# Besides, there is a circular dependency with `t8_forest_t` +# leading to an error output by Julia. +mutable struct t8_forest end - This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. +"""Opaque pointer to a forest implementation.""" +const t8_forest_t = Ptr{t8_forest} -!!! note +""" + t8_forest_adapt(forest) - This routine does not detect periodic boundaries. +Adapt a forest. # 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. +* `forest`:\\[in,out\\] The forest to be adapted ### Prototype ```c -void t8_cmesh_set_join_by_vertices (t8_cmesh_t cmesh, const t8_gloidx_t ntrees, const t8_eclass_t *eclasses, const double *vertices, int **connectivity, const int do_both_directions); +void t8_forest_adapt (t8_forest_t forest); ``` """ -function t8_cmesh_set_join_by_vertices(cmesh, ntrees, eclasses, vertices, connectivity, do_both_directions) - @ccall libt8.t8_cmesh_set_join_by_vertices(cmesh::t8_cmesh_t, ntrees::t8_gloidx_t, eclasses::Ptr{t8_eclass_t}, vertices::Ptr{Cdouble}, connectivity::Ptr{Ptr{Cint}}, do_both_directions::Cint)::Cvoid +function t8_forest_adapt(forest) + @ccall libt8.t8_forest_adapt(forest::t8_forest_t)::Cvoid end """ - t8_cmesh_set_join_by_stash(cmesh, connectivity, do_both_directions) + t8_tree -Sets the face connectivity information of an un-committed based on the cmesh stash. +The t8 tree datatype -!!! warning +| Field | Note | +| :---------------- | :----------------------------------------------------------------- | +| leaf\\_elements | locally stored leaf elements | +| eclass | The element class of this tree | +| first\\_desc | first local descendant | +| last\\_desc | last local descendant | +| elements\\_offset | cumulative sum over earlier trees on this processor (locals only) | +""" +struct t8_tree + leaf_elements::t8_element_array_t + eclass::t8_eclass_t + first_desc::Ptr{t8_element_t} + last_desc::Ptr{t8_element_t} + elements_offset::t8_locidx_t +end - This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. +"""Opaque pointer to a tree implementation.""" +const t8_tree_t = Ptr{t8_tree} -!!! note +""" + t8_ghost_type_t - This routine does not detect periodic boundaries. +This type controls, which neighbors count as ghost elements. Currently, we support face-neighbors. Vertex and edge neighbors will eventually be added. -# 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); -``` +| Enumerator | Note | +| :-------------------- | :---------------------------------------------------------------- | +| T8\\_GHOST\\_NONE | Do not create ghost layer. | +| T8\\_GHOST\\_FACES | Consider all face (codimension 1) neighbors. | +| T8\\_GHOST\\_EDGES | Consider all edge (codimension 2) and face neighbors. | +| T8\\_GHOST\\_VERTICES | Consider all vertex (codimension 3) and edge and face neighbors. | """ -function t8_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 +@cenum t8_ghost_type_t::UInt32 begin + T8_GHOST_NONE = 0 + T8_GHOST_FACES = 1 + T8_GHOST_EDGES = 2 + T8_GHOST_VERTICES = 3 end +# typedef void ( * t8_generic_function_pointer ) ( void ) """ - t8_offset_first(proc, offset) - -Return the global id of the first local tree of a given process in a partition. +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 -* `proc`:\\[in\\] The rank of the process. -* `offset`:\\[in\\] The partition table. -# Returns -The global id of the first local tree of *proc* in the partition *offset*. -### Prototype -```c -t8_gloidx_t t8_offset_first (const int proc, const t8_gloidx_t *offset); -``` +# See also +[`t8_forest_get_user_function`](@ref). """ -function t8_offset_first(proc, offset) - @ccall libt8.t8_offset_first(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_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 , const t8_eclass_t tree_class , const t8_scheme_c * scheme , const int refine , const int num_outgoing , const t8_locidx_t first_outgoing , const int num_incoming , const t8_locidx_t first_incoming ) """ - t8_offset_first_tree_to_entry(first_tree, shared) +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. -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. +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 -* `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); -``` +* `forest_old`:\\[in\\] The forest that is adapted +* `forest_new`:\\[in,out\\] The forest that is newly constructed from *forest_old* +* `which_tree`:\\[in\\] The local tree containing *first_outgoing* and *first_incoming* +* `tree_class`:\\[in\\] The eclass of the local tree containing *first_outgoing* and *first_incoming* +* `scheme`:\\[in\\] The scheme of the forest +* `refine`:\\[in\\] -1 if family in *forest_old* got coarsened, 0 if element has not been touched, 1 if element got refined and -2 if element got removed. See return of [`t8_forest_adapt_t`](@ref). +* `num_outgoing`:\\[in\\] The number of outgoing elements. +* `first_outgoing`:\\[in\\] The tree local index of the first outgoing element. 0 <= first\\_outgoing < which\\_tree->num\\_elements +* `num_incoming`:\\[in\\] The number of incoming elements. +* `first_incoming`:\\[in\\] The tree local index of the first incoming element. 0 <= first\\_incom < new\\_which\\_tree->num\\_elements +# See also +[`t8_forest_iterate_replace`](@ref) """ -function t8_offset_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 +const t8_forest_replace_t = Ptr{Cvoid} +# typedef int ( * t8_forest_adapt_t ) ( t8_forest_t forest , t8_forest_t forest_from , t8_locidx_t which_tree , const t8_eclass_t tree_class , t8_locidx_t lelement_id , const t8_scheme_c * scheme , const int is_family , const int num_elements , t8_element_t * elements [ ] ) """ - t8_offset_num_trees(proc, offset) - -The number of trees of a given process in a partition. +Callback function prototype to decide for refining and coarsening. If *is_family* equals 1, the first *num_elements* in *elements* form a family and we decide whether this family should be coarsened or only the first element should be refined. Otherwise *is_family* must equal zero and we consider the first entry of the element array for refinement. Entries of the element array beyond the first *num_elements* are undefined. # Arguments -* `proc`:\\[in\\] A mpi rank. -* `offset`:\\[in\\] A partition table. +* `forest`:\\[in\\] The forest to which the new elements belong. +* `forest_from`:\\[in\\] The forest that is adapted. +* `which_tree`:\\[in\\] The local tree containing *elements*. +* `tree_class`:\\[in\\] The eclass of *which_tree*. +* `lelement_id`:\\[in\\] The local element id in *forest_old* in the tree of the current element. +* `scheme`:\\[in\\] The scheme of the forest. +* `is_family`:\\[in\\] If 1, the first *num_elements* entries in *elements* form a family. If 0, they do not. +* `num_elements`:\\[in\\] The number of entries in *elements* that are defined +* `elements`:\\[in\\] Pointers to a family or, if *is_family* is zero, pointer to one element. # Returns -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); -``` +1 if the first entry in *elements* should be refined, -1 if the family *elements* shall be coarsened, -2 if the first entry in *elements* should be removed, 0 else. """ -function t8_offset_num_trees(proc, offset) - @ccall libt8.t8_offset_num_trees(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t -end +const t8_forest_adapt_t = Ptr{Cvoid} """ - t8_offset_last(proc, offset) + t8_forest_init(pforest) -Return the last local tree of a given process in a partition. +Create a new forest with reference count one. This forest needs to be specialized with the t8\\_forest\\_set\\_* calls. Currently it is mandatory to either call the functions # Arguments -* `proc`:\\[in\\] A mpi rank. -* `offset`:\\[in\\] A partition table. -# Returns -The global tree id of the last local tree of *proc* in *offset*. +* `pforest`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new forest. +# See also +t8\\_forest\\_set\\_mpicomm, t8_forest_set_cmesh, and t8_forest_set_scheme, or to call one of t8_forest_set_copy, t8_forest_set_adapt, or t8_forest_set_partition. It is illegal to mix these calls, or to call more than one of the three latter functions Then it needs to be set up with t8_forest_commit. + ### Prototype ```c -t8_gloidx_t t8_offset_last (const int proc, const t8_gloidx_t *offset); +void t8_forest_init (t8_forest_t *pforest); ``` """ -function t8_offset_last(proc, offset) - @ccall libt8.t8_offset_last(proc::Cint, offset::Ptr{t8_gloidx_t})::t8_gloidx_t +function t8_forest_init(pforest) + @ccall libt8.t8_forest_init(pforest::Ptr{t8_forest_t})::Cvoid end """ - t8_offset_empty(proc, offset) + t8_forest_is_initialized(forest) -Check whether a given process has no local trees in a given partition. +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 -* `proc`:\\[in\\] A mpi rank. -* `offset`:\\[in\\] A partition table. +* `forest`:\\[in\\] This forest is examined. May be NULL. # Returns -nonzero if *proc* does not have local trees in *offset*. 0 otherwise. +True if forest is not NULL, t8_forest_init has been called on it, but not t8_forest_commit. False otherwise. ### Prototype ```c -int t8_offset_empty (const int proc, const t8_gloidx_t *offset); +int t8_forest_is_initialized (t8_forest_t forest); ``` """ -function t8_offset_empty(proc, offset) - @ccall libt8.t8_offset_empty(proc::Cint, offset::Ptr{t8_gloidx_t})::Cint +function t8_forest_is_initialized(forest) + @ccall libt8.t8_forest_is_initialized(forest::t8_forest_t)::Cint end """ - t8_offset_next_nonempty_rank(rank, mpisize, offset) + t8_forest_is_committed(forest) -Find the next higher rank that is not empty. returns mpisize if this rank does not exist. +Check whether a forest is not NULL, initialized and committed. In addition, it asserts that the forest is consistent as much as possible. # Arguments -* `proc`:\\[in\\] An MPI rank. -* `mpisize`:\\[in\\] The number of total MPI ranks. -* `offset`:\\[in\\] An array with at least *mpisize* + 1 entries. +* `forest`:\\[in\\] This forest is examined. May be NULL. # 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. +True if forest is not NULL and t8_forest_init has been called on it as well as t8_forest_commit. False otherwise. ### Prototype ```c -int t8_offset_next_nonempty_rank (const int rank, const int mpisize, const t8_gloidx_t *offset); +int t8_forest_is_committed (t8_forest_t forest); ``` """ -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 +function t8_forest_is_committed(forest) + @ccall libt8.t8_forest_is_committed(forest::t8_forest_t)::Cint end """ - t8_offset_in_range(tree_id, proc, offset) + t8_forest_no_overlap(forest) + +Check whether the forest has local overlapping elements. + +!!! note -Determine whether a given global tree id is a local tree of a given process in a certain partition. + This function is collective, but only checks local overlapping on each process. # Arguments -* `tree_id`:\\[in\\] A global tree id. -* `proc`:\\[in\\] A mpi rank. -* `offset`:\\[in\\] A partition table. +* `forest`:\\[in\\] The forest to consider. # Returns -nonzero if *tree_id* is a local tree of *proc* in *offset*. 0 if it is not. +True if *forest* has no elements which are inside each other. +# See also +[`t8_forest_partition_test_boundary_element`](@ref) if you also want to test for global overlap across the process boundaries. + ### Prototype ```c -int t8_offset_in_range (const t8_gloidx_t tree_id, const int proc, const t8_gloidx_t *offset); +int t8_forest_no_overlap (t8_forest_t forest); ``` """ -function t8_offset_in_range(tree_id, proc, offset) - @ccall libt8.t8_offset_in_range(tree_id::t8_gloidx_t, proc::Cint, offset::Ptr{t8_gloidx_t})::Cint +function t8_forest_no_overlap(forest) + @ccall libt8.t8_forest_no_overlap(forest::t8_forest_t)::Cint end """ - t8_offset_any_owner_of_tree(mpisize, gtree, offset) + t8_forest_is_equal(forest_a, forest_b) + +Check whether two committed forests have the same local elements. + +!!! note -Find any process that has a given tree as local tree. + This function is not collective. It only returns the state on the current rank. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. +* `forest_a`:\\[in\\] The first forest. +* `forest_b`:\\[in\\] The second forest. # Returns -An MPI rank that has *gtree* as a local tree. +True if *forest_a* and *forest_b* do have the same number of local trees and each local tree has the same elements, that is t8_element_is_equal returns true for each pair of elements of *forest_a* and *forest_b*. ### Prototype ```c -int t8_offset_any_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset); +int t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b); ``` """ -function t8_offset_any_owner_of_tree(mpisize, gtree, offset) - @ccall libt8.t8_offset_any_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t})::Cint +function t8_forest_is_equal(forest_a, forest_b) + @ccall libt8.t8_forest_is_equal(forest_a::t8_forest_t, forest_b::t8_forest_t)::Cint end """ - t8_offset_any_owner_of_tree_ext(mpisize, start_proc, gtree, offset) - -Find any process that has a given tree as local tree. + t8_forest_set_cmesh(forest, cmesh, comm) -# Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `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 -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); +void t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); ``` """ -function t8_offset_any_owner_of_tree_ext(mpisize, start_proc, gtree, offset) - @ccall libt8.t8_offset_any_owner_of_tree_ext(mpisize::Cint, start_proc::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t})::Cint +function t8_forest_set_cmesh(forest, cmesh, comm) + @ccall libt8.t8_forest_set_cmesh(forest::t8_forest_t, cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid end """ - t8_offset_first_owner_of_tree(mpisize, gtree, offset, some_owner) + t8_forest_set_scheme(forest, scheme) -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. +Set the element scheme associated to a forest. By default, the forest takes ownership of the scheme such that it will be destroyed when the forest is destroyed. To keep ownership of the scheme, call t8_scheme_ref before passing it to t8_forest_set_scheme. This means that it is ILLEGAL to continue using scheme or dereferencing it UNLESS it is referenced directly before passing it into this function. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `some_owner`:\\[in\\] If >= 0 considered as input: a process that has *gtree* as local tree. If < 0 on output a process that has *gtree* as local tree. Specifying *some_owner* increases the runtime from O(log mpisize) to O(n), where n is the number of owners of the tree. -# Returns -The smallest rank that has *gtree* as a local tree. +* `forest`:\\[in,out\\] The forest whose scheme variable will be set. +* `scheme`:\\[in\\] The scheme to be set. We take ownership. This can be prevented by referencing **scheme**. ### Prototype ```c -int t8_offset_first_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner); +void t8_forest_set_scheme (t8_forest_t forest, const t8_scheme_c *scheme); ``` """ -function t8_offset_first_owner_of_tree(mpisize, gtree, offset, some_owner) - @ccall libt8.t8_offset_first_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, some_owner::Ptr{Cint})::Cint +function t8_forest_set_scheme(forest, scheme) + @ccall libt8.t8_forest_set_scheme(forest::t8_forest_t, scheme::Ptr{t8_scheme_c})::Cvoid end """ - t8_offset_last_owner_of_tree(mpisize, gtree, offset, some_owner) + t8_forest_set_level(forest, level) + +Set the initial refinement level to be used when **forest** is committed. + +!!! note -Find the biggest process that has a given tree as local tree. To increase the runtime, an arbitrary process having this tree as local tree can be passed as an argument. Otherwise, such an owner is computed during the call. + This setting cannot be combined with any of the derived forest methods (t8_forest_set_copy, t8_forest_set_adapt, t8_forest_set_partition, and t8_forest_set_balance) and overwrites any of these settings. If this function is used, then the forest is created from scratch as a uniform refinement of the specified cmesh (t8_forest_set_cmesh, t8_forest_set_scheme). # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `some_owner`:\\[in,out\\] If >= 0 considered as input: a process that has *gtree* as local tree. If < 0 on output a process that has *gtree* as local tree. Specifying *some_owner* increases the runtime from O(log mpisize) to O(n), where n is the number of owners of the tree. -# Returns -The biggest rank that has *gtree* as a local tree. +* `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_offset_last_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int *some_owner); +void t8_forest_set_level (t8_forest_t forest, int level); ``` """ -function t8_offset_last_owner_of_tree(mpisize, gtree, offset, some_owner) - @ccall libt8.t8_offset_last_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, some_owner::Ptr{Cint})::Cint +function t8_forest_set_level(forest, level) + @ccall libt8.t8_forest_set_level(forest::t8_forest_t, level::Cint)::Cvoid end """ - t8_offset_next_owner_of_tree(mpisize, gtree, offset, current_owner) + t8_forest_set_copy(forest, from) + +Set a forest as source for copying on committing. By default, the forest takes ownership of the source **from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **from** or dereferencing it UNLESS it is referenced directly before passing it into this function. + +!!! note -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. + This setting cannot be combined with t8_forest_set_adapt, t8_forest_set_partition, or t8_forest_set_balance and overwrites these settings. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `current_owner`:\\[in\\] A process that has *gtree* as local tree. -# Returns -The MPI rank of the next bigger rank than *current_owner* that has *gtree* as local tree. -1 if non such rank exists. +* `forest`:\\[in,out\\] The forest. +* `from`:\\[in\\] A second forest from which *forest* will be copied in t8_forest_commit. ### Prototype ```c -int t8_offset_next_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, int current_owner); +void t8_forest_set_copy (t8_forest_t forest, const t8_forest_t from); ``` """ -function t8_offset_next_owner_of_tree(mpisize, gtree, offset, current_owner) - @ccall libt8.t8_offset_next_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, current_owner::Cint)::Cint +function t8_forest_set_copy(forest, from) + @ccall libt8.t8_forest_set_copy(forest::t8_forest_t, from::t8_forest_t)::Cvoid end -""" - t8_offset_prev_owner_of_tree(mpisize, gtree, offset, current_owner) +""" + t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) + +Set a source forest with an adapt function to be adapted on committing. By default, the forest takes ownership of the source **set_from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **set_from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **set_from** or dereferencing it UNLESS it is referenced directly before passing it into this function. + +!!! note + + This setting can be combined with t8_forest_set_partition and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance. + +!!! note -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. + This setting may not be combined with t8_forest_set_copy and overwrites this setting. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global id of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `current_owner`:\\[in\\] A process that has *gtree* as local tree. -# Returns -The MPI rank of the next smaller rank than *current_owner* that has *gtree* as local tree. -1 if non such rank exists. +* `forest`:\\[in,out\\] The forest +* `set_from`:\\[in\\] The source forest from which **forest** will be adapted. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_partition, t8_forest_set_balance). +* `adapt_fn`:\\[in\\] The adapt function used on committing. +* `recursive`:\\[in\\] A flag specifying whether adaptation is to be done recursively or not. If the value is zero, adaptation is not recursive and it is recursive otherwise. ### Prototype ```c -int t8_offset_prev_owner_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, const int current_owner); +void t8_forest_set_adapt (t8_forest_t forest, const t8_forest_t set_from, t8_forest_adapt_t adapt_fn, int recursive); ``` """ -function t8_offset_prev_owner_of_tree(mpisize, gtree, offset, current_owner) - @ccall libt8.t8_offset_prev_owner_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, current_owner::Cint)::Cint +function t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) + @ccall libt8.t8_forest_set_adapt(forest::t8_forest_t, set_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint)::Cvoid end """ - t8_offset_all_owners_of_tree(mpisize, gtree, offset, owners) + t8_forest_set_user_data(forest, data) -Compute a list of all processes that own a specific tree.n *offset* minus 1. +Set the user data of a forest. This can i.e. be used to pass user defined arguments to the adapt routine. # Arguments -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `gtree`:\\[in\\] The global index of a tree. -* `offset`:\\[in\\] The partition to be considered. -* `owners`:\\[in,out\\] On input an initialized [`sc_array`](@ref) with integer entries and zero elements. On output a sorted list of all MPI ranks that have *gtree* as a local tree in *offset*. +* `forest`:\\[in,out\\] The forest +* `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_offset_all_owners_of_tree (const int mpisize, const t8_gloidx_t gtree, const t8_gloidx_t *offset, sc_array_t *owners); +void t8_forest_set_user_data (t8_forest_t forest, void *data); ``` """ -function t8_offset_all_owners_of_tree(mpisize, gtree, offset, owners) - @ccall libt8.t8_offset_all_owners_of_tree(mpisize::Cint, gtree::t8_gloidx_t, offset::Ptr{t8_gloidx_t}, owners::Ptr{sc_array_t})::Cvoid +function t8_forest_set_user_data(forest, data) + @ccall libt8.t8_forest_set_user_data(forest::t8_forest_t, data::Ptr{Cvoid})::Cvoid end """ - t8_offset_nosend(proc, mpisize, offset_from, offset_to) + t8_forest_get_user_data(forest) -Query whether in a repartition setting a given process does send any of its local trees to any other process (including itself) +Return the user data pointer associated with a forest. # Arguments -* `proc`:\\[in\\] A mpi rank. -* `mpisize`:\\[in\\] The number of MPI ranks, also the number of entries in *offset* minus 1. -* `offset_from`:\\[in\\] The partition table of the current partition. -* `offset_to`:\\[in\\] The partition table of the next partition. +* `forest`:\\[in\\] The forest. # Returns -nonzero if *proc* will not send any local trees if we repartition from *offset_from* to *offset_to* 0 if it does send local trees. +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 -int t8_offset_nosend (int proc, int mpisize, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); +void * t8_forest_get_user_data (const t8_forest_t forest); ``` """ -function t8_offset_nosend(proc, mpisize, offset_from, offset_to) - @ccall libt8.t8_offset_nosend(proc::Cint, mpisize::Cint, offset_from::Ptr{t8_gloidx_t}, offset_to::Ptr{t8_gloidx_t})::Cint +function t8_forest_get_user_data(forest) + @ccall libt8.t8_forest_get_user_data(forest::t8_forest_t)::Ptr{Cvoid} end """ - t8_offset_sendsto(proca, procb, t8_offset_from, t8_offset_to) + t8_forest_set_user_function(forest, _function) -Query whether in a repartitioning setting, a given process sends local trees (and then possibly ghosts) to a given other process. +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 -* `proca`:\\[in\\] Mpi rank of the possible sending process. -* `procb`:\\[in\\] Mpi rank of the possible receiver. -* `offset_from`:\\[in\\] The partition table of the current partition. -* `offset_to`:\\[in\\] The partition table of the next partition. -# Returns -nonzero if *proca* does send local trees to *procb* when we repartition from *offset_from* to *offset_to*. 0 else. +* `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 -int t8_offset_sendsto (int proca, int procb, const t8_gloidx_t *t8_offset_from, const t8_gloidx_t *t8_offset_to); +void t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer function); ``` """ -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 +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_offset_sendstree(proc_send, proc_to, gtree, offset_from, offset_to) + t8_forest_get_user_function(forest) -Query whether in a repartitioning setting, a given process sends a given tree to a second process. +Return the user function pointer associated with a forest. # Arguments -* `proc_send`:\\[in\\] Mpi rank of the possible sending process. -* `proc_recv`:\\[in\\] Mpi rank of the possible receiver. -* `gtree`:\\[in\\] A global tree id. -* `offset_from`:\\[in\\] The partition table of the current partition. -* `offset_to`:\\[in\\] The partition table of the next partition. +* `forest`:\\[in\\] The forest. # Returns -nonzero if *proc_send* will send the tree *gtree* to *proc_recv*. 0 else. When calling, *gtree* must not be a local tree of *proc_send* in *offset_from*. In this case, 0 is always returned. +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 -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); +t8_generic_function_pointer t8_forest_get_user_function (const t8_forest_t forest); ``` """ -function t8_offset_sendstree(proc_send, proc_to, gtree, offset_from, offset_to) - @ccall libt8.t8_offset_sendstree(proc_send::Cint, proc_to::Cint, gtree::t8_gloidx_t, offset_from::Ptr{t8_gloidx_t}, offset_to::Ptr{t8_gloidx_t})::Cint +function t8_forest_get_user_function(forest) + @ccall libt8.t8_forest_get_user_function(forest::t8_forest_t)::t8_generic_function_pointer end """ - t8_offset_range_send(start, _end, mpirank, offset_from, offset_to) + t8_forest_set_partition(forest, set_from, set_for_coarsening) -Count the number of processes in a given range [a,b] that send to a given other process in a repartitioning setting. +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. -# Arguments -* `start`:\\[in\\] The first mpi rank to be considered as sender. -* `end`:\\[in\\] The last mpi rank to be considered as sender. -* `mpirank`:\\[in\\] The mpirank to be considered as receiver. -* `offset_from`:\\[in\\] The partition table of the current partition. -* `offset_to`:\\[in\\] The partition table of the next partition. -# Returns -The number of processes p, such that *start* <= p <= *end* and p does send local trees (and possibly ghosts) to *mpirank*. -### Prototype -```c -int t8_offset_range_send (int start, int end, int mpirank, const t8_gloidx_t *offset_from, const t8_gloidx_t *offset_to); -``` -""" -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 +!!! note -""" - t8_offset_print(offset, comm) + This setting can be combined with t8_forest_set_adapt and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance. If t8_forest_set_balance is called with the *no_repartition* parameter set as false, it is not necessary to call t8_forest_set_partition additionally. -### Prototype -```c -void t8_offset_print (t8_shmem_array_t offset, sc_MPI_Comm comm); -``` -""" -function t8_offset_print(offset, comm) - @ccall libt8.t8_offset_print(offset::t8_shmem_array_t, comm::MPI_Comm)::Cvoid -end +!!! note -""" - t8_cmesh_partition(cmesh, comm) + This setting may not be combined with t8_forest_set_copy and overwrites this setting. +# Arguments +* `forest`:\\[in,out\\] The forest. +* `set_from`:\\[in\\] A second forest that should be partitioned. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_balance). +* `set_for_coarsening`:\\[in\\] CURRENTLY DISABLED. If true, then the partitions are choose such that coarsening an element once is a process local operation. ### Prototype ```c -void t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm); +void t8_forest_set_partition (t8_forest_t forest, const t8_forest_t set_from, int set_for_coarsening); ``` """ -function t8_cmesh_partition(cmesh, comm) - @ccall libt8.t8_cmesh_partition(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_forest_set_partition(forest, set_from, set_for_coarsening) + @ccall libt8.t8_forest_set_partition(forest::t8_forest_t, set_from::t8_forest_t, set_for_coarsening::Cint)::Cvoid end """ - t8_cmesh_gather_trees_per_eclass(cmesh, comm) + t8_forest_set_balance(forest, set_from, no_repartition) -### Prototype -```c -void t8_cmesh_gather_trees_per_eclass (t8_cmesh_t cmesh, sc_MPI_Comm comm); -``` -""" -function t8_cmesh_gather_trees_per_eclass(cmesh, comm) - @ccall libt8.t8_cmesh_gather_trees_per_eclass(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid -end +Set a source forest to be balanced during commit. A forest is said to be balanced if each element has face neighbors of level at most +1 or -1 of the element's level. -""" - t8_cmesh_gather_treecount(cmesh, comm) +!!! note -### Prototype -```c -void t8_cmesh_gather_treecount (t8_cmesh_t cmesh, sc_MPI_Comm comm); -``` -""" -function t8_cmesh_gather_treecount(cmesh, comm) - @ccall libt8.t8_cmesh_gather_treecount(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid -end + This setting can be combined with t8_forest_set_adapt and t8_forest_set_partition. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance. -""" - t8_cmesh_gather_treecount_nocommit(cmesh, comm) +!!! note + + This setting may not be combined with t8_forest_set_copy and overwrites this setting. +# Arguments +* `forest`:\\[in,out\\] The forest. +* `set_from`:\\[in\\] A second forest that should be balanced. We take ownership. This can be prevented by referencing **set_from**. If NULL, a previously (or later) set forest will be taken (t8_forest_set_adapt, t8_forest_set_partition) +* `no_repartition`:\\[in\\] Balance constructs several intermediate forest that are refined from each other. In order to maintain a balanced load these forest are repartitioned in each round and the resulting forest is load-balanced per default. If this behaviour is not desired, *no_repartition* should be set to true. If *no_repartition* is false, an additional call of t8_forest_set_partition is not necessary. ### Prototype ```c -void t8_cmesh_gather_treecount_nocommit (t8_cmesh_t cmesh, sc_MPI_Comm comm); +void t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_repartition); ``` """ -function t8_cmesh_gather_treecount_nocommit(cmesh, comm) - @ccall libt8.t8_cmesh_gather_treecount_nocommit(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_forest_set_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_cmesh_offset_print(cmesh, comm) + t8_forest_set_ghost(forest, do_ghost, ghost_type) +Enable or disable the creation of a layer of ghost elements. On default no ghosts are created. + +# Arguments +* `forest`:\\[in\\] The forest. +* `do_ghost`:\\[in\\] If non-zero a ghost layer will be created. +* `ghost_type`:\\[in\\] Controls which neighbors count as ghost elements, currently only T8\\_GHOST\\_FACES is supported. This value is ignored if *do_ghost* = 0. ### Prototype ```c -void t8_cmesh_offset_print (t8_cmesh_t cmesh, sc_MPI_Comm comm); +void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type); ``` """ -function t8_cmesh_offset_print(cmesh, comm) - @ccall libt8.t8_cmesh_offset_print(cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_forest_set_ghost(forest, do_ghost, ghost_type) + @ccall libt8.t8_forest_set_ghost(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t)::Cvoid end """ - t8_cmesh_offset_concentrate(proc, comm, num_trees) + t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) -### 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 +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. -""" - t8_cmesh_offset_random(comm, num_trees, shared, seed) +# Arguments +* `forest`:\\[in\\] The forest. +* `do_ghost`:\\[in\\] If non-zero a ghost layer will be created. +* `ghost_type`:\\[in\\] Controls which neighbors count as ghost elements, currently only T8\\_GHOST\\_FACES is supported. This value is ignored if *do_ghost* = 0. +* `ghost_version`:\\[in\\] If 1, the iterative ghost algorithm for balanced forests is used. If 2, the iterative algorithm for unbalanced forests. If 3, the top-down search algorithm for unbalanced forests. +# See also +[`t8_forest_set_ghost`](@ref) ### Prototype ```c -t8_shmem_array_t t8_cmesh_offset_random (sc_MPI_Comm comm, t8_gloidx_t num_trees, int shared, unsigned seed); +void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); ``` """ -function t8_cmesh_offset_random(comm, num_trees, shared, seed) - @ccall libt8.t8_cmesh_offset_random(comm::MPI_Comm, num_trees::t8_gloidx_t, shared::Cint, seed::Cuint)::t8_shmem_array_t +function t8_forest_set_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_cmesh_offset_half(cmesh, comm) + t8_forest_set_load(forest, filename) -### 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 +Use assertions and document that the forest\\_set (..., from) and set\\_load are mutually exclusive. -""" - t8_cmesh_offset_percent(cmesh, comm, percent) +TODO: Unused function -> remove? ### Prototype ```c -t8_shmem_array_t t8_cmesh_offset_percent (t8_cmesh_t cmesh, sc_MPI_Comm comm, int percent); +void t8_forest_set_load (t8_forest_t forest, const char *filename); ``` """ -function t8_cmesh_offset_percent(cmesh, comm, percent) - @ccall libt8.t8_cmesh_offset_percent(cmesh::t8_cmesh_t, comm::MPI_Comm, percent::Cint)::t8_shmem_array_t -end - -""" - t8_stash_class - -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 +function t8_forest_set_load(forest, filename) + @ccall libt8.t8_forest_set_load(forest::t8_forest_t, filename::Cstring)::Cvoid end -"""The attribute information that is stored before a cmesh is committed. The pair (package\\_id, key) serves as a lookup key to identify the data.""" -const t8_stash_attribute_struct_t = t8_stash_attribute - -"""The stash data structure is used to store information about the cmesh before it is committed. In particular we store the eclasses of the trees, the face-connections and the tree attributes. Using the stash structure allows us to have a very flexible interface. When constructing a new mesh, the user can specify all these mesh entities in arbitrary order. As soon as the cmesh is committed the information is copied from the stash to the cmesh in an order mannered.""" -const t8_stash_struct_t = t8_stash - """ - t8_stash_init(pstash) + t8_forest_comm_global_num_leaf_elements(forest) -Initialize a stash data structure. +Compute the global number of leaf elements in a forest as the sum of the local leaf element counts. # Arguments -* `pstash`:\\[in,out\\] A pointer to the stash to be initialized. +* `forest`:\\[in\\] The forest. ### Prototype ```c -void t8_stash_init (t8_stash_t *pstash); +void t8_forest_comm_global_num_leaf_elements (t8_forest_t forest); ``` """ -function t8_stash_init(pstash) - @ccall libt8.t8_stash_init(pstash::Ptr{t8_stash_t})::Cvoid +function t8_forest_comm_global_num_leaf_elements(forest) + @ccall libt8.t8_forest_comm_global_num_leaf_elements(forest::t8_forest_t)::Cvoid end """ - t8_stash_destroy(pstash) + t8_forest_commit(forest) -Free all memory associated in a stash structure. +After allocating and adding properties to a forest, commit the changes. This call sets up the internal state of the forest. # Arguments -* `pstash`:\\[in,out\\] A pointer to the stash to be destroyed. The pointer is set to NULL after the function call. +* `forest`:\\[in,out\\] Must be created with t8_forest_init and specialized with t8\\_forest\\_set\\_* calls first. ### Prototype ```c -void t8_stash_destroy (t8_stash_t *pstash); +void t8_forest_commit (t8_forest_t forest); ``` """ -function t8_stash_destroy(pstash) - @ccall libt8.t8_stash_destroy(pstash::Ptr{t8_stash_t})::Cvoid +function t8_forest_commit(forest) + @ccall libt8.t8_forest_commit(forest::t8_forest_t)::Cvoid end """ - t8_stash_add_class(stash, id, eclass) + t8_forest_get_maxlevel(forest) -Set the eclass of a tree. +Return the maximum allowed refinement level for any element in a forest. # Arguments -* `stash`:\\[in,out\\] The stash to be updated. -* `id`:\\[in\\] The global id of the tree whose eclass should be set. -* `eclass`:\\[in\\] The eclass of tree with id *id*. +* `forest`:\\[in\\] A forest. +# Returns +The maximum level of refinement that is allowed for an element in this forest. It is guaranteed that any tree in *forest* can be refined this many times and it is not allowed to refine further. *forest* must be committed before calling this function. For forest with a single element class (non-hybrid) maxlevel is the maximum refinement level of this element class, whilst for hybrid forests the maxlevel is the minimum of all maxlevels of the element classes in this forest. ### Prototype ```c -void t8_stash_add_class (t8_stash_t stash, t8_gloidx_t id, t8_eclass_t eclass); +int t8_forest_get_maxlevel (const t8_forest_t forest); ``` """ -function t8_stash_add_class(stash, id, eclass) - @ccall libt8.t8_stash_add_class(stash::t8_stash_t, id::t8_gloidx_t, eclass::t8_eclass_t)::Cvoid +function t8_forest_get_maxlevel(forest) + @ccall libt8.t8_forest_get_maxlevel(forest::t8_forest_t)::Cint end """ - t8_stash_add_facejoin(stash, gid1, gid2, face1, face2, orientation) + t8_forest_get_local_num_leaf_elements(forest) -Add a face connection to a stash. +Return the number of process local leaf elements in the forest. # Arguments -* `stash`:\\[in,out\\] The stash to be updated. -* `id1`:\\[in\\] The global id of the first tree. -* `id2`:\\[in\\] The global id of the second tree, -* `face1`:\\[in\\] The face number of the face of the first tree. -* `face2`:\\[in\\] The face number of the face of the second tree. -* `orientation`:\\[in\\] The orientation of the faces to each other. +* `forest`:\\[in\\] A forest. +# Returns +The number of leaf elements on this process in *forest*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_stash_add_facejoin (t8_stash_t stash, t8_gloidx_t gid1, t8_gloidx_t gid2, int face1, int face2, int orientation); +t8_locidx_t t8_forest_get_local_num_leaf_elements (const t8_forest_t forest); ``` """ -function t8_stash_add_facejoin(stash, gid1, gid2, face1, face2, orientation) - @ccall libt8.t8_stash_add_facejoin(stash::t8_stash_t, gid1::t8_gloidx_t, gid2::t8_gloidx_t, face1::Cint, face2::Cint, orientation::Cint)::Cvoid +function t8_forest_get_local_num_leaf_elements(forest) + @ccall libt8.t8_forest_get_local_num_leaf_elements(forest::t8_forest_t)::t8_locidx_t end """ - t8_stash_class_sort(stash) + t8_forest_get_global_num_leaf_elements(forest) -Sort the entries in the class array by the order given in the enum definition of [`t8_eclass`](@ref). +Return the number of global leaf elements in the forest. # Arguments -* `stash`:\\[in,out\\] The stash whose class array is sorted. +* `forest`:\\[in\\] A forest. +# Returns +The number of leaf elements (summed over all processes) in *forest*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_stash_class_sort (t8_stash_t stash); +t8_gloidx_t t8_forest_get_global_num_leaf_elements (const t8_forest_t forest); ``` """ -function t8_stash_class_sort(stash) - @ccall libt8.t8_stash_class_sort(stash::t8_stash_t)::Cvoid +function t8_forest_get_global_num_leaf_elements(forest) + @ccall libt8.t8_forest_get_global_num_leaf_elements(forest::t8_forest_t)::t8_gloidx_t end """ - t8_stash_class_bsearch(stash, tree_id) + t8_forest_get_num_ghosts(forest) -Search for an entry with a given tree index in the class-stash. The stash must be sorted beforehand. +Return the number of ghost elements of a forest. # Arguments -* `stash`:\\[in\\] The stash to be searched for. -* `tree_id`:\\[in\\] The global tree id. +* `forest`:\\[in\\] The forest. # Returns -The index of an element in the classes array of *stash* corresponding to *tree_id*. -1 if not found. +The number of ghost elements stored in the ghost structure of *forest*. 0 if no ghosts were constructed. +# See also +[`t8_forest_set_ghost`](@ref) *forest* must be committed before calling this function. + ### Prototype ```c -ssize_t t8_stash_class_bsearch (t8_stash_t stash, t8_gloidx_t tree_id); +t8_locidx_t t8_forest_get_num_ghosts (const t8_forest_t forest); ``` """ -function t8_stash_class_bsearch(stash, tree_id) - @ccall libt8.t8_stash_class_bsearch(stash::t8_stash_t, tree_id::t8_gloidx_t)::Cssize_t +function t8_forest_get_num_ghosts(forest) + @ccall libt8.t8_forest_get_num_ghosts(forest::t8_forest_t)::t8_locidx_t end """ - t8_stash_joinface_sort(stash) + t8_forest_get_eclass(forest, ltreeid) -Sort then entries in the facejoin array in order of the first treeid. +Return the element class of a forest local tree. # Arguments -* `stash`:\\[in,out\\] The stash whose facejoin array is sorted. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree in *forest*. +# Returns +The element class of the tree *ltreeid*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_stash_joinface_sort (t8_stash_t stash); +t8_eclass_t t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_stash_joinface_sort(stash) - @ccall libt8.t8_stash_joinface_sort(stash::t8_stash_t)::Cvoid +function t8_forest_get_eclass(forest, ltreeid) + @ccall libt8.t8_forest_get_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t end """ - t8_stash_add_attribute(stash, id, package_id, key, size, attr, copy) + t8_forest_tree_is_local(forest, local_tree) -Add an attribute to a tree. +Check whether a given tree id belongs to a local tree in a forest. # Arguments -* `stash`:\\[in\\] The stash structure to be modified. -* `id`:\\[in\\] The global index of the tree to which the attribute is added. -* `package_id`:\\[in\\] The unique id of the current package. -* `key`:\\[in\\] An integer value used to identify this attribute. -* `size`:\\[in\\] The size (in bytes) of the attribute. -* `attr`:\\[in\\] Points to *size* bytes of memory that should be stored as the attribute. -* `copy`:\\[in\\] If true the attribute data is copied from *attr* to an internal storage. If false only the pointer *attr* is stored and the data is only copied if the cmesh is committed. (More memory efficient). +* `forest`:\\[in\\] The forest. +* `local_tree`:\\[in\\] A tree id. +# Returns +True if and only if the id *local_tree* belongs to a local tree of *forest*. *forest* must be committed before calling this function. ### Prototype ```c -void t8_stash_add_attribute (t8_stash_t stash, t8_gloidx_t id, int package_id, int key, size_t size, void *const attr, int copy); +int t8_forest_tree_is_local (const t8_forest_t forest, const t8_locidx_t local_tree); ``` """ -function t8_stash_add_attribute(stash, id, package_id, key, size, attr, copy) - @ccall libt8.t8_stash_add_attribute(stash::t8_stash_t, id::t8_gloidx_t, package_id::Cint, key::Cint, size::Csize_t, attr::Ptr{Cvoid}, copy::Cint)::Cvoid +function t8_forest_tree_is_local(forest, local_tree) + @ccall libt8.t8_forest_tree_is_local(forest::t8_forest_t, local_tree::t8_locidx_t)::Cint end """ - t8_stash_get_attribute_size(stash, index) + t8_forest_get_local_id(forest, gtreeid) -Return the size (in bytes) of an attribute in the stash. +Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is not a local tree, a negative number is returned. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of a tree. # Returns -The size in bytes of the attribute. +The tree's local id in *forest*, if it is a local tree. A negative number if not. Ghosts trees are not considered as local. +# See also +[`t8_forest_get_local_or_ghost_id`](@ref) for ghost trees., https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -size_t t8_stash_get_attribute_size (t8_stash_t stash, size_t index); +t8_locidx_t t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); ``` """ -function t8_stash_get_attribute_size(stash, index) - @ccall libt8.t8_stash_get_attribute_size(stash::t8_stash_t, index::Csize_t)::Csize_t +function t8_forest_get_local_id(forest, gtreeid) + @ccall libt8.t8_forest_get_local_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t end """ - t8_stash_get_attribute(stash, index) + t8_forest_get_local_or_ghost_id(forest, gtreeid) -Return the pointer to an attribute in the stash. +Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is a ghost, then the local id is between num\\_local\\_trees and num\\_local\\_trees + num\\_ghost\\_trees. If the tree is neither a local tree nor a ghost tree, a negative number is returned. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of a tree. # Returns -A void pointer to the memory region where the attribute is stored. +The tree's local id in *forest*, if it is a local tree. num\\_local\\_trees + the ghosts id, if it is a ghost tree. A negative number if not. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing + ### Prototype ```c -void * t8_stash_get_attribute (t8_stash_t stash, size_t index); +t8_locidx_t t8_forest_get_local_or_ghost_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); ``` """ -function t8_stash_get_attribute(stash, index) - @ccall libt8.t8_stash_get_attribute(stash::t8_stash_t, index::Csize_t)::Ptr{Cvoid} +function t8_forest_get_local_or_ghost_id(forest, gtreeid) + @ccall libt8.t8_forest_get_local_or_ghost_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t end """ - t8_stash_get_attribute_tree_id(stash, index) + t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) + +Given the local id of a tree in a forest, compute the tree's local id in the associated cmesh. + +!!! note -Return the id of the tree a given attribute belongs to. + For forest local trees, this is the inverse function of t8_forest_cmesh_ltreeid_to_ltreeid. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree or ghost in the forest. # Returns -The tree id. +The local id of the tree in the cmesh associated with the forest. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -t8_gloidx_t t8_stash_get_attribute_tree_id (t8_stash_t stash, size_t index); +t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_stash_get_attribute_tree_id(stash, index) - @ccall libt8.t8_stash_get_attribute_tree_id(stash::t8_stash_t, index::Csize_t)::t8_gloidx_t +function t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) + @ccall libt8.t8_forest_ltreeid_to_cmesh_ltreeid(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - t8_stash_get_attribute_key(stash, index) + t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) + +Given the local id of a tree in the coarse mesh of a forest, compute the tree's local id in the forest. + +!!! note -Return the key of a given attribute. + For forest local trees, this is the inverse function of t8_forest_ltreeid_to_cmesh_ltreeid. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `lctreeid`:\\[in\\] The local id of a tree in the coarse mesh of *forest*. # Returns -The attribute's key. +The local id of the tree in the forest. -1 if the tree is not forest local. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -int t8_stash_get_attribute_key (t8_stash_t stash, size_t index); +t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, t8_locidx_t lctreeid); ``` """ -function t8_stash_get_attribute_key(stash, index) - @ccall libt8.t8_stash_get_attribute_key(stash::t8_stash_t, index::Csize_t)::Cint +function t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) + @ccall libt8.t8_forest_cmesh_ltreeid_to_ltreeid(forest::t8_forest_t, lctreeid::t8_locidx_t)::t8_locidx_t end """ - t8_stash_get_attribute_id(stash, index) + t8_forest_get_coarse_tree(forest, ltreeid) -Return the package\\_id of a given attribute. +Given the local id of a tree in a forest, return the coarse tree of the cmesh that corresponds to this tree. # Arguments -* `stash`:\\[in\\] The stash to be considered. -* `index`:\\[in\\] The index of the attribute in the attribute array of *stash*. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree in the forest. # Returns -The attribute's package\\_id. +The coarse tree that matches the forest tree with local id *ltreeid*. ### Prototype ```c -int t8_stash_get_attribute_id (t8_stash_t stash, size_t index); +t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_stash_get_attribute_id(stash, index) - @ccall libt8.t8_stash_get_attribute_id(stash::t8_stash_t, index::Csize_t)::Cint +function t8_forest_get_coarse_tree(forest, ltreeid) + @ccall libt8.t8_forest_get_coarse_tree(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_ctree_t end """ - t8_stash_attribute_is_owned(stash, index) + t8_forest_element_is_leaf(forest, element, local_tree) -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. +Query whether a given element is a leaf in a forest. -# 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); -``` -""" -function t8_stash_attribute_is_owned(stash, index) - @ccall libt8.t8_stash_attribute_is_owned(stash::t8_stash_t, index::Csize_t)::Cint -end +!!! note -""" - t8_stash_attribute_sort(stash) + This does not query for ghost leaves. -Sort the attributes array of a stash in the order (treeid, package_id, key) * +!!! note + + *forest* must be committed before calling this function. # Arguments -* `stash`:\\[in,out\\] The stash to be considered. +* `forest`:\\[in\\] The forest. +* `element`:\\[in\\] An element of a local tree in *forest*. +* `local_tree`:\\[in\\] A local tree id of *forest*. +# Returns +True (non-zero) if and only if *element* is a leaf in *local_tree* of *forest*. ### Prototype ```c -void t8_stash_attribute_sort (t8_stash_t stash); +int t8_forest_element_is_leaf (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t local_tree); ``` """ -function t8_stash_attribute_sort(stash) - @ccall libt8.t8_stash_attribute_sort(stash::t8_stash_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_stash_bcast(stash, root, comm, elem_counts) - -### Prototype -```c -t8_stash_t t8_stash_bcast (t8_stash_t stash, int root, sc_MPI_Comm comm, const size_t elem_counts[3]); -``` -""" -function t8_stash_bcast(stash, root, comm, elem_counts) - @ccall libt8.t8_stash_bcast(stash::t8_stash_t, root::Cint, comm::MPI_Comm, elem_counts::Ptr{Csize_t})::t8_stash_t -end + t8_forest_leaf_face_orientation(forest, ltreeid, scheme, leaf, face) -""" - t8_stash_is_equal(stash_a, stash_b) +Compute the leaf face orientation at given face in a forest. -Check two stashes for equal content and return true if so. +For more information about the encoding of face orientation refer to t8_cmesh_get_face_neighbor. # Arguments -* `stash_a`:\\[in\\] The first stash to be considered. -* `stash_b`:\\[in\\] The first stash to be considered. +* `forest`:\\[in\\] The forest. Must have a valid ghost layer. +* `ltreeid`:\\[in\\] A local tree id. +* `scheme`:\\[in\\] The eclass scheme of the element. +* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. +* `face`:\\[in\\] The index of the face across which the face neighbors are searched. # Returns -True if both stashes hold copies of the same data. False otherwise. +Face orientation encoded as integer. ### Prototype ```c -int t8_stash_is_equal (t8_stash_t stash_a, t8_stash_t stash_b); +int t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_scheme_c *scheme, const t8_element_t *leaf, const int face); ``` """ -function t8_stash_is_equal(stash_a, stash_b) - @ccall libt8.t8_stash_is_equal(stash_a::t8_stash_t, stash_b::t8_stash_t)::Cint +function t8_forest_leaf_face_orientation(forest, ltreeid, scheme, leaf, face) + @ccall libt8.t8_forest_leaf_face_orientation(forest::t8_forest_t, ltreeid::t8_locidx_t, scheme::Ptr{t8_scheme_c}, leaf::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_attribute_info + t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass, forest_is_balanced) -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. +Compute the leaf face neighbors of a forest. -All attribute info objects of one tree are stored in an array and adding a tree's att\\_offset entry to the tree's address yields this array. The attributes themselves are stored in an array directly behind the array of the attribute infos. -""" -struct t8_attribute_info - package_id::Cint - key::Cint - attribute_offset::Csize_t - attribute_size::Csize_t -end +!!! note -""" -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. + If there are no face neighbors, then *neighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. -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 +!!! note -""" - t8_trees_glo_lo_hash_t + Currently *forest* must be balanced. -This struct is an entry of the trees global\\_id to local\\_id hash table for ghost trees. +!!! note -| Field | Note | -| :---------- | :------------- | -| global\\_id | The global id | -| local\\_id | The local id | -""" -struct t8_trees_glo_lo_hash_t - global_id::t8_gloidx_t - local_id::t8_locidx_t -end + *forest* must be committed before calling this function. -""" - t8_cmesh_trees_init(ptrees, num_procs, num_trees, num_ghosts) +!!! note + + Important! This routine allocates memory which must be freed. Do it like this: -Initialize a trees structure and allocate its parts. This function allocates the from\\_procs array without filling it, it also allocates the tree\\_to\\_proc and ghost\\_to\\_proc arrays. No memory for trees or ghosts is allocated. +if (num\\_neighbors > 0) { scheme->element\\_destroy (pneigh\\_eclass, num\\_neighbors, pneighbor\\_leaves); [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } # Arguments -* `[in,ou`: ptrees The trees structure to be initialized. -* `num_procs`:\\[in\\] The number of entries of its from\\_proc array (can be different for each process). -* `num_trees`:\\[in\\] The number of trees that will be stored in this structure. -* `num_ghosts`:\\[in\\] The number of ghosts that will be stored in this structure. +* `forest`:\\[in\\] The forest. Must have a valid ghost layer. +* `ltreeid`:\\[in\\] A local tree id. +* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. +* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. +* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. +* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. +* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. +* `pneigh_eclass`:\\[out\\] On output the eclass of the neighbor elements. +* `forest_is_balanced`:\\[in\\] True if we know that *forest* is balanced, false otherwise. ### Prototype ```c -void t8_cmesh_trees_init (t8_cmesh_trees_t *ptrees, int num_procs, t8_locidx_t num_trees, t8_locidx_t num_ghosts); +void t8_forest_leaf_face_neighbors (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_t *pneigh_eclass, int forest_is_balanced); ``` """ -function t8_cmesh_trees_init(ptrees, num_procs, num_trees, num_ghosts) - @ccall libt8.t8_cmesh_trees_init(ptrees::Ptr{t8_cmesh_trees_t}, num_procs::Cint, num_trees::t8_locidx_t, num_ghosts::t8_locidx_t)::Cvoid -end - -struct t8_part_tree - first_tree::Cstring - first_tree_id::t8_locidx_t - first_ghost_id::t8_locidx_t - num_trees::t8_locidx_t - num_ghosts::t8_locidx_t +function t8_forest_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass, 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_eclass::Ptr{t8_eclass_t}, forest_is_balanced::Cint)::Cvoid end """ -` t8_cmesh_types.h` + t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass, forest_is_balanced, gneigh_tree, orientation) -We define here the datatypes needed for internal cmesh routines. -""" -const t8_part_tree_t = Ptr{t8_part_tree} +Like t8_forest_leaf_face_neighbors but also provides information about the global neighbors and the orientation. -""" - t8_cmesh_trees_get_part(trees, proc) +!!! note -Return one part of a specified tree array. + If there are no face neighbors, then *neighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. -# Arguments -* `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 -t8_part_tree_t t8_cmesh_trees_get_part (const t8_cmesh_trees_t trees, const int proc); -``` -""" -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 +!!! note -""" - t8_cmesh_trees_start_part(trees, proc, lfirst_tree, num_trees, lfirst_ghost, num_ghosts, alloc) + Currently *forest* must be balanced. + +!!! note + + *forest* must be committed before calling this function. + +!!! note -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. + Important! This routine allocates memory which must be freed. Do it like this: + +if (num\\_neighbors > 0) { scheme->element\\_destroy (pneigh\\_eclass, num\\_neighbors, pneighbor\\_leaves); [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } # Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `proc`:\\[in\\] The index of the part to be updated. -* `lfirst_tree`:\\[in\\] The local id of the first tree of that part. -* `num_trees`:\\[in\\] The number of trees of that part. -* `lfirst_ghost`:\\[in\\] The local id of the first ghost of that part. -* `num_ghosts`:\\[in\\] The number of ghosts of that part. -* `alloc`:\\[in\\] If true then the first\\_tree array is allocated for the number of trees and ghosts. When a cmesh is copied we do not want this, so in we pass alloc = 0 then. +* `forest`:\\[in\\] The forest. Must 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_eclass`:\\[out\\] On output the eclass 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_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); +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_t *pneigh_eclass, int forest_is_balanced, t8_gloidx_t *gneigh_tree, int *orientation); ``` """ -function t8_cmesh_trees_start_part(trees, proc, lfirst_tree, num_trees, lfirst_ghost, num_ghosts, alloc) - @ccall libt8.t8_cmesh_trees_start_part(trees::t8_cmesh_trees_t, proc::Cint, lfirst_tree::t8_locidx_t, num_trees::t8_locidx_t, lfirst_ghost::t8_locidx_t, num_ghosts::t8_locidx_t, alloc::Cint)::Cvoid +function t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_eclass, 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_eclass::Ptr{t8_eclass_t}, forest_is_balanced::Cint, gneigh_tree::Ptr{t8_gloidx_t}, orientation::Ptr{Cint})::Cvoid end """ - t8_cmesh_trees_finish_part(trees, proc) + t8_forest_ghost_exchange_data(forest, element_data) + +Exchange ghost information of user defined element data. + +!!! note -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 manually 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). + This function is collective and hence must be called by all processes in the forest's MPI Communicator. # Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `proc`:\\[in\\] The number of the part to be finished. +* `forest`:\\[in\\] The forest. Must be committed. +* `element_data`:\\[in\\] An array of length num\\_local\\_elements + num\\_ghosts storing one value for each local element and ghost in *forest*. After calling this function the entries for the ghost elements are update with the entries in the *element_data* array of the corresponding owning process. ### Prototype ```c -void t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc); +void t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data); ``` """ -function t8_cmesh_trees_finish_part(trees, proc) - @ccall libt8.t8_cmesh_trees_finish_part(trees::t8_cmesh_trees_t, proc::Cint)::Cvoid +function t8_forest_ghost_exchange_data(forest, element_data) + @ccall libt8.t8_forest_ghost_exchange_data(forest::t8_forest_t, element_data::Ptr{sc_array_t})::Cvoid end """ - t8_cmesh_trees_copy_toproc(trees_dest, trees_src, lnum_trees, lnum_ghosts) + t8_forest_ghost_print(forest) -Copy the tree\\_to\\_proc and ghost\\_to\\_proc arrays of one tree structure to another one. +Print the ghost structure of a forest. Only used for debugging. -# Arguments -* `trees_dest`:\\[in,out\\] The destination trees structure. -* `trees_src`:\\[in\\] The source trees structure. -* `lnum_trees`:\\[in\\] The total number of trees stored in *trees_src*. -* `lnum_ghosts`:\\[in\\] The total number of ghosts stored in *trees_src*. ### Prototype ```c -void t8_cmesh_trees_copy_toproc (t8_cmesh_trees_t trees_dest, t8_cmesh_trees_t trees_src, t8_locidx_t lnum_trees, t8_locidx_t lnum_ghosts); +void t8_forest_ghost_print (t8_forest_t forest); ``` """ -function t8_cmesh_trees_copy_toproc(trees_dest, trees_src, lnum_trees, lnum_ghosts) - @ccall libt8.t8_cmesh_trees_copy_toproc(trees_dest::t8_cmesh_trees_t, trees_src::t8_cmesh_trees_t, lnum_trees::t8_locidx_t, lnum_ghosts::t8_locidx_t)::Cvoid +function t8_forest_ghost_print(forest) + @ccall libt8.t8_forest_ghost_print(forest::t8_forest_t)::Cvoid end """ - t8_cmesh_trees_copy_part(trees_dest, part_dest, trees_src, part_src) - -Copy the trees array from one part to another. + t8_forest_partition_cmesh(forest, comm, set_profiling) -# Arguments -* `trees_dest`:\\[in,out\\] The trees struct of the destination part. -* `part_dest`:\\[in\\] The index of the destination part. Must be initialized by t8_cmesh_trees_start_part with alloc = 0. -* `trees_src`:\\[in\\] The trees struct of the source part. -* `part_src`:\\[in\\] The index of the destination part. Must be a valid part, thus t8_cmesh_trees_finish_part must have been called. ### Prototype ```c -void t8_cmesh_trees_copy_part (t8_cmesh_trees_t trees_dest, int part_dest, t8_cmesh_trees_t trees_src, int part_src); +void t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profiling); ``` """ -function t8_cmesh_trees_copy_part(trees_dest, part_dest, trees_src, part_src) - @ccall libt8.t8_cmesh_trees_copy_part(trees_dest::t8_cmesh_trees_t, part_dest::Cint, trees_src::t8_cmesh_trees_t, part_src::Cint)::Cvoid +function t8_forest_partition_cmesh(forest, comm, set_profiling) + @ccall libt8.t8_forest_partition_cmesh(forest::t8_forest_t, comm::MPI_Comm, set_profiling::Cint)::Cvoid end """ - t8_cmesh_trees_add_tree(trees, ltree_id, proc, eclass) - -Add a tree to a trees structure. + t8_forest_get_mpicomm(forest) -# Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `tree_id`:\\[in\\] The local id of the tree to be inserted. -* `proc`:\\[in\\] The mpirank of the process from which the tree was received. -* `eclass`:\\[in\\] The tree's element class. ### Prototype ```c -void t8_cmesh_trees_add_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, int proc, t8_eclass_t eclass); +sc_MPI_Comm t8_forest_get_mpicomm (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_add_tree(trees, ltree_id, proc, eclass) - @ccall libt8.t8_cmesh_trees_add_tree(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, proc::Cint, eclass::t8_eclass_t)::Cvoid +function t8_forest_get_mpicomm(forest) + @ccall libt8.t8_forest_get_mpicomm(forest::t8_forest_t)::MPI_Comm end """ - t8_cmesh_trees_add_ghost(trees, lghost_index, gtree_id, proc, eclass, num_local_trees) + t8_forest_get_first_local_tree_id(forest) -Add a ghost to a trees structure. +Return the global id of the first local tree of a forest. # Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `ghost_index`:\\[in\\] The index in the part array of the ghost to be inserted. -* `tree_id`:\\[in\\] The global index of the ghost. -* `proc`:\\[in\\] The mpirank of the process from which the ghost was received. -* `eclass`:\\[in\\] The ghost's element class. -* `num_local_trees`:\\[in\\] The number of local trees in the cmesh. +* `forest`:\\[in\\] The forest. +# Returns +The global id of the first local tree in *forest*. ### Prototype ```c -void t8_cmesh_trees_add_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost_index, t8_gloidx_t gtree_id, int proc, t8_eclass_t eclass, t8_locidx_t num_local_trees); +t8_gloidx_t t8_forest_get_first_local_tree_id (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_add_ghost(trees, lghost_index, gtree_id, proc, eclass, num_local_trees) - @ccall libt8.t8_cmesh_trees_add_ghost(trees::t8_cmesh_trees_t, lghost_index::t8_locidx_t, gtree_id::t8_gloidx_t, proc::Cint, eclass::t8_eclass_t, num_local_trees::t8_locidx_t)::Cvoid +function t8_forest_get_first_local_tree_id(forest) + @ccall libt8.t8_forest_get_first_local_tree_id(forest::t8_forest_t)::t8_gloidx_t end """ - t8_cmesh_trees_set_all_boundary(cmesh, trees) + t8_forest_get_num_local_trees(forest) -Set all neighbor fields of all local trees and ghosts to boundary. +Return the number of local trees of a given forest. # Arguments -* `cmesh,`:\\[in,out\\] The associated cmesh. -* `trees,`:\\[in,out\\] The trees structure. A face f of tree t counts as boundary if the face-neighbor is also t at face f. +* `forest`:\\[in\\] The forest. +# Returns +The number of local trees of that forest. ### Prototype ```c -void t8_cmesh_trees_set_all_boundary (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); +t8_locidx_t t8_forest_get_num_local_trees (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_set_all_boundary(cmesh, trees) - @ccall libt8.t8_cmesh_trees_set_all_boundary(cmesh::t8_cmesh_t, trees::t8_cmesh_trees_t)::Cvoid +function t8_forest_get_num_local_trees(forest) + @ccall libt8.t8_forest_get_num_local_trees(forest::t8_forest_t)::t8_locidx_t end """ - t8_cmesh_trees_get_part_data(trees, proc, first_tree, num_trees, first_ghost, num_ghosts) + t8_forest_get_num_ghost_trees(forest) + +Return the number of ghost trees of a given forest. +# Arguments +* `forest`:\\[in\\] The forest. +# Returns +The number of ghost trees of that forest. ### Prototype ```c -void t8_cmesh_trees_get_part_data (t8_cmesh_trees_t trees, int proc, t8_locidx_t *first_tree, t8_locidx_t *num_trees, t8_locidx_t *first_ghost, t8_locidx_t *num_ghosts); +t8_locidx_t t8_forest_get_num_ghost_trees (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_get_part_data(trees, proc, first_tree, num_trees, first_ghost, num_ghosts) - @ccall libt8.t8_cmesh_trees_get_part_data(trees::t8_cmesh_trees_t, proc::Cint, first_tree::Ptr{t8_locidx_t}, num_trees::Ptr{t8_locidx_t}, first_ghost::Ptr{t8_locidx_t}, num_ghosts::Ptr{t8_locidx_t})::Cvoid +function t8_forest_get_num_ghost_trees(forest) + @ccall libt8.t8_forest_get_num_ghost_trees(forest::t8_forest_t)::t8_locidx_t end """ - t8_cmesh_trees_get_tree(trees, ltree) + t8_forest_get_num_global_trees(forest) -Return a pointer to a specific tree in a trees struct. +Return the number of global trees of a given forest. # Arguments -* `trees`:\\[in\\] The tress structure where the tree is to be looked up. -* `ltree`:\\[in\\] The local id of the tree. +* `forest`:\\[in\\] The forest. # Returns -A pointer to the tree with local id *tree*. +The number of global trees of that forest. ### Prototype ```c -t8_ctree_t t8_cmesh_trees_get_tree (t8_cmesh_trees_t trees, t8_locidx_t ltree); +t8_gloidx_t t8_forest_get_num_global_trees (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_get_tree(trees, ltree) - @ccall libt8.t8_cmesh_trees_get_tree(trees::t8_cmesh_trees_t, ltree::t8_locidx_t)::t8_ctree_t +function t8_forest_get_num_global_trees(forest) + @ccall libt8.t8_forest_get_num_global_trees(forest::t8_forest_t)::t8_gloidx_t end """ - t8_cmesh_trees_get_tree_ext(trees, ltree_id, face_neigh, ttf) + t8_forest_global_tree_id(forest, ltreeid) -Return a pointer to a specific tree in a trees struct plus pointers to its face\\_neighbor and tree\\_to\\_face arrays. +Return the global id of a local tree or a ghost tree. # Arguments -* `trees`:\\[in\\] The trees structure where the tree is to be looked up. -* `ltree_id`:\\[in\\] The local id of the tree. -* `face_neigh`:\\[out\\] If not NULL a pointer to the trees face\\_neighbor array is stored here on return. -* `ttf`:\\[out\\] If not NULL a pointer to the trees tree\\_to\\_face array is stored here on return. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] An id 0 <= *ltreeid* < num\\_local\\_trees + num\\_ghosts specifying a local tree or ghost tree. # Returns -A pointer to the tree with local id *tree*. +The global id corresponding to the tree with local id *ltreeid*. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -t8_ctree_t t8_cmesh_trees_get_tree_ext (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, t8_locidx_t **face_neigh, int8_t **ttf); +t8_gloidx_t t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_get_tree_ext(trees, ltree_id, face_neigh, ttf) - @ccall libt8.t8_cmesh_trees_get_tree_ext(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, face_neigh::Ptr{Ptr{t8_locidx_t}}, ttf::Ptr{Ptr{Int8}})::t8_ctree_t +function t8_forest_global_tree_id(forest, ltreeid) + @ccall libt8.t8_forest_global_tree_id(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_gloidx_t end """ - t8_cmesh_trees_get_face_info(trees, ltreeid, face, ttf) + t8_forest_get_tree(forest, ltree_id) -Return the face neighbor of a tree at a given face and return the tree\\_to\\_face info +Return a pointer to a tree in a forest. # Arguments -* `trees`:\\[in\\] The trees structure where the tree is to be looked up. -* `ltreeid`:\\[in\\] The local id of the tree. -* `face`:\\[in\\] A face of the tree. -* `ttf`:\\[out\\] If not NULL the tree\\_to\\_face value of the face connection. +* `forest`:\\[in\\] The forest. +* `ltree_id`:\\[in\\] The local id of the tree. # Returns -The face neighbor that is stored for this face +A pointer to the tree with local id *ltree_id*. *forest* must be committed before calling this function. ### Prototype ```c -t8_locidx_t t8_cmesh_trees_get_face_info (t8_cmesh_trees_t trees, t8_locidx_t ltreeid, int face, int8_t *ttf); +t8_tree_t t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id); ``` """ -function t8_cmesh_trees_get_face_info(trees, ltreeid, face, ttf) - @ccall libt8.t8_cmesh_trees_get_face_info(trees::t8_cmesh_trees_t, ltreeid::t8_locidx_t, face::Cint, ttf::Ptr{Int8})::t8_locidx_t +function t8_forest_get_tree(forest, ltree_id) + @ccall libt8.t8_forest_get_tree(forest::t8_forest_t, ltree_id::t8_locidx_t)::t8_tree_t end """ - t8_cmesh_trees_get_face_neighbor(tree, face) + t8_forest_get_tree_vertices(forest, ltreeid) -Given a coarse tree and a face number, return the local id of the neighbor tree. +Return a pointer to the vertex coordinates of a tree. # Arguments -* `tree.`:\\[in\\] The coarse tree. -* `face.`:\\[in\\] The face number. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The id of a local tree. # Returns -The local id of the neighbor tree. +If stored, a pointer to the vertex coordinates of *tree*. If no coordinates for this tree are found, NULL. ### Prototype ```c -t8_locidx_t t8_cmesh_trees_get_face_neighbor (const t8_ctree_t tree, const int face); +double * t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_get_face_neighbor(tree, face) - @ccall libt8.t8_cmesh_trees_get_face_neighbor(tree::t8_ctree_t, face::Cint)::t8_locidx_t +function t8_forest_get_tree_vertices(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_vertices(forest::t8_forest_t, ltreeid::t8_locidx_t)::Ptr{Cdouble} end """ - t8_cmesh_trees_get_face_neighbor_ext(tree, face, ttf) + t8_forest_tree_get_leaf_elements(forest, ltree_id) -Given a coarse tree and a face number, return the local id of the neighbor tree together with its tree-to-face info. +Return the array of leaf elements of a local tree in a forest. # Arguments -* `tree`:\\[in\\] The coarse tree. -* `face`:\\[in\\] The face number. -* `ttf`:\\[out\\] If not NULL it is filled with the tree-to-face value for this face. +* `forest`:\\[in\\] The forest. +* `ltree_id`:\\[in\\] The local id of a local tree of *forest*. # Returns -The local id of the neighbor tree. +An array of [`t8_element_t`](@ref) * storing all leaf elements of this tree. ### Prototype ```c -t8_locidx_t t8_cmesh_trees_get_face_neighbor_ext (const t8_ctree_t tree, const int face, int8_t *ttf); +t8_element_array_t * t8_forest_tree_get_leaf_elements (const t8_forest_t forest, const t8_locidx_t ltree_id); ``` """ -function t8_cmesh_trees_get_face_neighbor_ext(tree, face, ttf) - @ccall libt8.t8_cmesh_trees_get_face_neighbor_ext(tree::t8_ctree_t, face::Cint, ttf::Ptr{Int8})::t8_locidx_t +function t8_forest_tree_get_leaf_elements(forest, ltree_id) + @ccall libt8.t8_forest_tree_get_leaf_elements(forest::t8_forest_t, ltree_id::t8_locidx_t)::Ptr{t8_element_array_t} end """ - t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost, face, ttf) + t8_forest_get_cmesh(forest) -Given a coarse ghost and a face number, return the local id of the neighbor tree together with its tree-to-face info. +Return a cmesh associated to a forest. # Arguments -* `ghost`:\\[in\\] The coarse ghost. -* `face`:\\[in\\] The face number. -* `ttf`:\\[out\\] If not NULL it is filled with the tree-to-face value for this face. +* `forest`:\\[in\\] The forest. # Returns -The global id of the neighbor tree. +The cmesh associated to the forest. ### Prototype ```c -t8_gloidx_t t8_cmesh_trees_get_ghost_face_neighbor_ext (const t8_cghost_t ghost, const int face, int8_t *ttf); +t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); ``` """ -function t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost, face, ttf) - @ccall libt8.t8_cmesh_trees_get_ghost_face_neighbor_ext(ghost::t8_cghost_t, face::Cint, ttf::Ptr{Int8})::t8_gloidx_t +function t8_forest_get_cmesh(forest) + @ccall libt8.t8_forest_get_cmesh(forest::t8_forest_t)::t8_cmesh_t end """ - t8_cmesh_trees_get_ghost(trees, lghost) + t8_forest_get_leaf_element(forest, lelement_id, ltreeid) + +Return a leaf element of the forest. + +!!! note -Return a pointer to a specific ghost in a trees struct. + This function performs a binary search. For constant access, use t8_forest_get_leaf_element_in_tree *forest* must be committed before calling this function. # Arguments -* `trees`:\\[in\\] The tress structure where the tree is to be looked up. -* `lghost`:\\[in\\] The local id of the ghost. +* `forest`:\\[in\\] The forest. +* `lelement_id`:\\[in\\] The local id of a leaf element in *forest*. +* `ltreeid`:\\[out\\] If not NULL, on output the local tree id of the tree in which the leaf element lies in. # Returns -A pointer to the ghost with local id *ghost*. +A pointer to the leaf element. NULL if this element does not exist. Ghost elements are not considered as local. +# See also +[`t8_forest_ghost_get_leaf_element`](@ref) to access ghost leaf elements. + ### Prototype ```c -t8_cghost_t t8_cmesh_trees_get_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost); +t8_element_t * t8_forest_get_leaf_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_locidx_t *ltreeid); ``` """ -function t8_cmesh_trees_get_ghost(trees, lghost) - @ccall libt8.t8_cmesh_trees_get_ghost(trees::t8_cmesh_trees_t, lghost::t8_locidx_t)::t8_cghost_t +function t8_forest_get_leaf_element(forest, lelement_id, ltreeid) + @ccall libt8.t8_forest_get_leaf_element(forest::t8_forest_t, lelement_id::t8_locidx_t, ltreeid::Ptr{t8_locidx_t})::Ptr{t8_element_t} end """ - t8_cmesh_trees_get_ghost_ext(trees, lghost_id, face_neigh, ttf) + t8_forest_get_leaf_element_in_tree(forest, ltreeid, leid_in_tree) + +Return a leaf element of a local tree in a forest. -Return a pointer to a specific ghost in a trees struct plus pointers to its face\\_neighbor and tree\\_to\\_face arrays. +!!! note + + If the tree id is know, this function should be preferred over t8_forest_get_leaf_element. *forest* must be committed before calling this function. # Arguments -* `trees`:\\[in\\] The trees structure where the ghost is to be looked up. -* `lghost_id`:\\[in\\] The local id of the ghost. -* `face_neigh`:\\[out\\] If not NULL a pointer to the ghosts face\\_neighbor array is stored here on return. -* `ttf`:\\[out\\] If not NULL a pointer to the ghosts tree\\_to\\_face array is stored here on return. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] An id of a local tree in the forest. Ghost trees are not considered local. +* `leid_in_tree`:\\[in\\] The index of a leaf element in the tree. # Returns -A pointer to the tree with local id *tree*. +A pointer to the leaf element. +# See also +t8\\_forest\\_ghost\\_get\\_leaf\\_element\\_in\\_tree to access ghost leaf elements. + ### Prototype ```c -t8_cghost_t t8_cmesh_trees_get_ghost_ext (t8_cmesh_trees_t trees, t8_locidx_t lghost_id, t8_gloidx_t **face_neigh, int8_t **ttf); +const t8_element_t * t8_forest_get_leaf_element_in_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t leid_in_tree); ``` """ -function t8_cmesh_trees_get_ghost_ext(trees, lghost_id, face_neigh, ttf) - @ccall libt8.t8_cmesh_trees_get_ghost_ext(trees::t8_cmesh_trees_t, lghost_id::t8_locidx_t, face_neigh::Ptr{Ptr{t8_gloidx_t}}, ttf::Ptr{Ptr{Int8}})::t8_cghost_t +function t8_forest_get_leaf_element_in_tree(forest, ltreeid, leid_in_tree) + @ccall libt8.t8_forest_get_leaf_element_in_tree(forest::t8_forest_t, ltreeid::t8_locidx_t, leid_in_tree::t8_locidx_t)::Ptr{t8_element_t} end """ - t8_cmesh_trees_get_ghost_local_id(trees, global_id) + t8_forest_get_tree_num_leaf_elements(forest, ltreeid) -Given the global tree id of a ghost tree in a trees structure, return its local ghost id. +Return the number of leaf elements of a tree. # Arguments -* `trees`:\\[in\\] The trees structure. -* `global_id`:\\[in\\] A global tree id. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] A local id of a tree. # Returns -The local id of the tree *global_id* if it is a ghost in *trees*. A negative number if it isn't. The local id is a number l with num\\_local\\_trees <= *l* < num\\_local\\_trees + num\\_ghosts +The number of leaf elements in the local tree *ltreeid*. ### Prototype ```c -t8_locidx_t t8_cmesh_trees_get_ghost_local_id (t8_cmesh_trees_t trees, t8_gloidx_t global_id); +t8_locidx_t t8_forest_get_tree_num_leaf_elements (t8_forest_t forest, t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_get_ghost_local_id(trees, global_id) - @ccall libt8.t8_cmesh_trees_get_ghost_local_id(trees::t8_cmesh_trees_t, global_id::t8_gloidx_t)::t8_locidx_t +function t8_forest_get_tree_num_leaf_elements(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_num_leaf_elements(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - t8_cmesh_trees_size(trees) + t8_forest_get_tree_element_offset(forest, ltreeid) -### Prototype -```c -size_t t8_cmesh_trees_size (t8_cmesh_trees_t trees); -``` -""" -function t8_cmesh_trees_size(trees) - @ccall libt8.t8_cmesh_trees_size(trees::t8_cmesh_trees_t)::Csize_t -end +Return the element offset of a local tree, that is the number of leaf elements in all trees with smaller local treeid. -""" - t8_cmesh_trees_init_attributes(trees, ltree_id, num_attributes, attr_bytes) +!!! note -For one tree in a trees structure set the number of attributes and temporarily store the total size of all of this tree's attributes. This temporary value is used in t8_cmesh_trees_finish_part. + *forest* must be committed before calling this function. # Arguments -* `trees`:\\[in,out\\] The trees structure to be updated. -* `ltree_id`:\\[in\\] The local id of one tree in *trees*. -* `num_attributes`:\\[in\\] The number of attributes of this tree. -* `attr_bytes`:\\[in\\] The total number of bytes of all attributes of this tree. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] A local id of a tree. +# Returns +The number of leaf elements on all local tree with id < *ltreeid*. ### Prototype ```c -void t8_cmesh_trees_init_attributes (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, size_t num_attributes, size_t attr_bytes); +t8_locidx_t t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_init_attributes(trees, ltree_id, num_attributes, attr_bytes) - @ccall libt8.t8_cmesh_trees_init_attributes(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, num_attributes::Csize_t, attr_bytes::Csize_t)::Cvoid +function t8_forest_get_tree_element_offset(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_element_offset(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t end """ - t8_cmesh_trees_get_attribute(trees, ltree_id, package_id, key, size, is_ghost) + t8_forest_get_tree_leaf_element_count(tree) -Return an attribute that is stored at a tree. +Return the number of leaf elements of a tree. # Arguments -* `trees`:\\[in\\] The trees structure. -* `ltree_id`:\\[in\\] The local id of the tree whose attribute is querid. -* `package_id`:\\[in\\] The package identifier of the attribute. -* `key`:\\[in\\] The key of the attribute within all attributes of the same package identifier. -* `size`:\\[out\\] If not NULL, the size (in bytes) of the attribute will be stored here. -* `is_ghost`:\\[in\\] If true, then *ltree_id* is interpreted as the local\\_id of a ghost. +* `tree`:\\[in\\] A tree in a forest. # Returns -A pointer to the queried attribute, NULL if the attribute does not exist. +The number of leaf elements of that tree. ### Prototype ```c -void * t8_cmesh_trees_get_attribute (const t8_cmesh_trees_t trees, const t8_locidx_t ltree_id, const int package_id, const int key, size_t *size, int is_ghost); +t8_locidx_t t8_forest_get_tree_leaf_element_count (t8_tree_t tree); ``` """ -function t8_cmesh_trees_get_attribute(trees, ltree_id, package_id, key, size, is_ghost) - @ccall libt8.t8_cmesh_trees_get_attribute(trees::t8_cmesh_trees_t, ltree_id::t8_locidx_t, package_id::Cint, key::Cint, size::Ptr{Csize_t}, is_ghost::Cint)::Ptr{Cvoid} +function t8_forest_get_tree_leaf_element_count(tree) + @ccall libt8.t8_forest_get_tree_leaf_element_count(tree::t8_tree_t)::t8_locidx_t end """ - t8_cmesh_trees_attribute_size(tree) + t8_forest_get_tree_class(forest, ltreeid) -Return the total size of all attributes stored at a specified tree. +Return the eclass of a tree in a forest. # Arguments -* `tree`:\\[in\\] A tree structure. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local id of a tree (local or ghost) in *forest*. # Returns -The total size (in bytes) of the attributes of *tree*. +The element class of the tree with local id *ltreeid*. ### Prototype ```c -size_t t8_cmesh_trees_attribute_size (t8_ctree_t tree); +t8_eclass_t t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid); ``` """ -function t8_cmesh_trees_attribute_size(tree) - @ccall libt8.t8_cmesh_trees_attribute_size(tree::t8_ctree_t)::Csize_t +function t8_forest_get_tree_class(forest, ltreeid) + @ccall libt8.t8_forest_get_tree_class(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t end """ - t8_cmesh_trees_ghost_attribute_size(ghost) + t8_forest_get_first_local_leaf_element_id(forest) -Return the total size of all attributes stored at a specified ghost. +Compute the global index of the first local leaf element of a forest. This function is collective. # Arguments -* `ghost`:\\[in\\] A ghost structure. +* `forest`:\\[in\\] A committed forest, whose first leaf element's index is computed. # Returns -The total size (in bytes) of the attributes of *ghost*. +The global index of *forest*'s first local leaf element. Forest must be committed when calling this function. This function is collective and must be called on each process. ### Prototype ```c -size_t t8_cmesh_trees_ghost_attribute_size (t8_cghost_t ghost); +t8_gloidx_t t8_forest_get_first_local_leaf_element_id (t8_forest_t forest); ``` """ -function t8_cmesh_trees_ghost_attribute_size(ghost) - @ccall libt8.t8_cmesh_trees_ghost_attribute_size(ghost::t8_cghost_t)::Csize_t +function t8_forest_get_first_local_leaf_element_id(forest) + @ccall libt8.t8_forest_get_first_local_leaf_element_id(forest::t8_forest_t)::t8_gloidx_t end """ - t8_cmesh_trees_add_attribute(trees, proc, attr, tree_id, index) + t8_forest_get_scheme(forest) + +Return the element scheme associated to a forest. + +# Arguments +* `forest`:\\[in\\] A committed forest. +# Returns +The element scheme of the forest. +# See also +[`t8_forest_set_scheme`](@ref) ### Prototype ```c -void t8_cmesh_trees_add_attribute (const t8_cmesh_trees_t trees, int proc, const t8_stash_attribute_struct_t *attr, t8_locidx_t tree_id, size_t index); +const t8_scheme_c * t8_forest_get_scheme (const t8_forest_t forest); ``` """ -function t8_cmesh_trees_add_attribute(trees, proc, attr, tree_id, index) - @ccall libt8.t8_cmesh_trees_add_attribute(trees::t8_cmesh_trees_t, proc::Cint, attr::Ptr{t8_stash_attribute_struct_t}, tree_id::t8_locidx_t, index::Csize_t)::Cvoid +function t8_forest_get_scheme(forest) + @ccall libt8.t8_forest_get_scheme(forest::t8_forest_t)::Ptr{t8_scheme_c} end """ - t8_cmesh_trees_add_ghost_attribute(trees, attr, local_ghost_id, ghosts_inserted, index) + t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) -Add the next ghost attribute from stash to the correct position in the char pointer structure Since it is created from stash, all attributes are added to part 0. The following attribute offset gets updated already. +Return the eclass of the tree in which a face neighbor of a given element lies. # Arguments -* `trees`:\\[in,out\\] The trees structure, whose char array is updated. -* `attr`:\\[in\\] The stash attribute that is added. -* `local_ghost_id`:\\[in\\] The local ghost id. -* `ghosts_inserted`:\\[in\\] The number of ghost that were already inserted, so that we do not write over the end. -* `index`:\\[in\\] The attribute index of the attribute to be added. +* `forest`:\\[in\\] A committed forest. +* `ltreeid`:\\[in\\] The local tree 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_cmesh_trees_add_ghost_attribute (const t8_cmesh_trees_t trees, const t8_stash_attribute_struct_t *attr, t8_locidx_t local_ghost_id, t8_locidx_t ghosts_inserted, size_t index); +t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, int face); ``` """ -function t8_cmesh_trees_add_ghost_attribute(trees, attr, local_ghost_id, ghosts_inserted, index) - @ccall libt8.t8_cmesh_trees_add_ghost_attribute(trees::t8_cmesh_trees_t, attr::Ptr{t8_stash_attribute_struct_t}, local_ghost_id::t8_locidx_t, ghosts_inserted::t8_locidx_t, index::Csize_t)::Cvoid +function t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) + @ccall libt8.t8_forest_element_neighbor_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, face::Cint)::t8_eclass_t end """ - t8_cmesh_trees_get_numproc(trees) + t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_eclass, face, neigh_face) -Return the number of parts of a trees structure. +Construct the face neighbor of an element, possibly across tree boundaries. Returns the global tree-id of the tree in which the neighbor element lies in. # Arguments -* `trees`:\\[in\\] The trees structure. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The local tree in which the element lies. +* `elem`:\\[in\\] The element to be considered. +* `neigh`:\\[in,out\\] On input an allocated element of the scheme of the face\\_neighbors eclass. On output, this element's data is filled with the data of the face neighbor. If the neighbor does not exist the data could be modified arbitrarily. +* `neigh_eclass`:\\[in\\] The eclass of *neigh*. +* `face`:\\[in\\] The number of the face along which the neighbor should be constructed. +* `neigh_face`:\\[out\\] The number of the face viewed from perspective of *neigh*. # Returns -The number of parts in *trees*. +The global tree-id of the tree in which *neigh* is in. -1 if there exists no neighbor across that face. ### Prototype ```c -size_t t8_cmesh_trees_get_numproc (const t8_cmesh_trees_t trees); +t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, const t8_eclass_t neigh_eclass, int face, int *neigh_face); ``` """ -function t8_cmesh_trees_get_numproc(trees) - @ccall libt8.t8_cmesh_trees_get_numproc(trees::t8_cmesh_trees_t)::Csize_t +function t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_eclass, face, neigh_face) + @ccall libt8.t8_forest_element_face_neighbor(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, neigh::Ptr{t8_element_t}, neigh_eclass::t8_eclass_t, face::Cint, neigh_face::Ptr{Cint})::t8_gloidx_t end """ - t8_cmesh_tree_to_face_encode(dimension, face, orientation) + t8_forest_iterate(forest) -Compute the tree-to-face information given a face and orientation value of a face connection. +TODO: Can be removed since it is unused. # Arguments -* `dimension`:\\[in\\] The dimension of the corresponding eclasses. -* `face`:\\[in\\] A face number -* `orientation`:\\[in\\] A face-to-face orientation. -# Returns -The tree-to-face entry corresponding to the face/orientation combination. It is computed as t8\\_eclass\\_max\\_num\\_faces[dimension] * orientation + face +* `forest`:\\[in\\] The forest. ### Prototype ```c -int8_t t8_cmesh_tree_to_face_encode (const int dimension, const t8_locidx_t face, const int orientation); +void t8_forest_iterate (t8_forest_t forest); ``` """ -function t8_cmesh_tree_to_face_encode(dimension, face, orientation) - @ccall libt8.t8_cmesh_tree_to_face_encode(dimension::Cint, face::t8_locidx_t, orientation::Cint)::Int8 +function t8_forest_iterate(forest) + @ccall libt8.t8_forest_iterate(forest::t8_forest_t)::Cvoid end """ - t8_cmesh_tree_to_face_decode(dimension, tree_to_face, face, orientation) + t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) -Given a tree-to-face value, get its encoded face number and orientation. +Query whether a batch of points lies inside an element. For bilinearly interpolated elements. !!! note - This function is the inverse operation of t8_cmesh_tree_to_face_encode If F = t8\\_eclass\\_max\\_num\\_faces[dimension], we get orientation = tree\\_to\\_face / F face = tree\\_to\\_face % F + For 2D quadrilateral elements this function is only an approximation. It is correct if the four vertices lie in the same plane, but it may produce only approximate results if the vertices do not lie in the same plane. # Arguments -* `dimension`:\\[in\\] The dimension of the corresponding eclasses. -* `tree_to_face`:\\[in\\] A tree-to-face value -* `face`:\\[out\\] On output filled with the stored face value. -* `orientation`:\\[out\\] On output filled with the stored orientation value. +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] The forest local id of the tree in which the element is. +* `element`:\\[in\\] The element. +* `points`:\\[in\\] 3-dimensional coordinates of the points to check +* `num_points`:\\[in\\] The number of points to check +* `is_inside`:\\[in,out\\] An array of length *num_points*, filled with 0/1 on output. True (non-zero) if a *point* lies within an *element*, false otherwise. The return value is also true if the point lies on the element boundary. Thus, this function may return true for different leaf elements, if they are neighbors and the point lies on the common boundary. +* `tolerance`:\\[in\\] Tolerance that we allow the point to not exactly match the element. If this value is larger we detect more points. If it is zero we probably do not detect points even if they are inside due to rounding errors. ### Prototype ```c -void t8_cmesh_tree_to_face_decode (const int dimension, const int8_t tree_to_face, int *face, int *orientation); +void t8_forest_element_points_inside (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, int num_points, int *is_inside, const double tolerance); ``` """ -function t8_cmesh_tree_to_face_decode(dimension, tree_to_face, face, orientation) - @ccall libt8.t8_cmesh_tree_to_face_decode(dimension::Cint, tree_to_face::Int8, face::Ptr{Cint}, orientation::Ptr{Cint})::Cvoid +function t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) + @ccall libt8.t8_forest_element_points_inside(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, points::Ptr{Cdouble}, num_points::Cint, is_inside::Ptr{Cint}, tolerance::Cdouble)::Cvoid end """ - t8_cmesh_trees_print(cmesh, trees) + t8_forest_element_find_owner(forest, gtreeid, element, eclass) + +Find the owner process of a given element. + +!!! note + + The element must not exist in the forest, but an ancestor of its first descendant has to. If the element's owner is not unique, the owner of the element's first descendant is returned. + +!!! note -Print the trees,ghosts and their neighbors in ASCII format t stdout. This function is used for debugging purposes. + *forest* must be committed before calling this function. # Arguments -* `cmesh`:\\[in\\] A coarse mesh structure that must be committed. -* `trees`:\\[in\\] The trees structure of *cmesh*. +* `forest`:\\[in\\] The forest. +* `gtreeid`:\\[in\\] The global id of the tree in which the element lies. +* `element`:\\[in\\] The element to look for. +* `eclass`:\\[in\\] The element class of the tree *gtreeid*. +# Returns +The mpirank of the process that owns *element*. +# See also +t8\\_forest\\_element\\_find\\_owner\\_ext, t8\\_forest\\_element\\_owners\\_bounds + ### Prototype ```c -void t8_cmesh_trees_print (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); +int t8_forest_element_find_owner (t8_forest_t forest, t8_gloidx_t gtreeid, t8_element_t *element, t8_eclass_t eclass); ``` """ -function t8_cmesh_trees_print(cmesh, trees) - @ccall libt8.t8_cmesh_trees_print(cmesh::t8_cmesh_t, trees::t8_cmesh_trees_t)::Cvoid +function t8_forest_element_find_owner(forest, gtreeid, element, eclass) + @ccall libt8.t8_forest_element_find_owner(forest::t8_forest_t, gtreeid::t8_gloidx_t, element::Ptr{t8_element_t}, eclass::t8_eclass_t)::Cint end """ - t8_cmesh_trees_bcast(cmesh_in, root, comm) + t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) ### Prototype ```c -void t8_cmesh_trees_bcast (t8_cmesh_t cmesh_in, int root, sc_MPI_Comm comm); +t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, const t8_scheme_c *scheme, const int level, const int do_face_ghost, sc_MPI_Comm comm); ``` """ -function t8_cmesh_trees_bcast(cmesh_in, root, comm) - @ccall libt8.t8_cmesh_trees_bcast(cmesh_in::t8_cmesh_t, root::Cint, comm::MPI_Comm)::Cvoid +function t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) + @ccall libt8.t8_forest_new_uniform(cmesh::t8_cmesh_t, scheme::Ptr{t8_scheme_c}, level::Cint, do_face_ghost::Cint, comm::MPI_Comm)::t8_forest_t end """ - t8_cmesh_trees_is_face_consistent(cmesh, trees) + t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) + +Build a adapted forest from another forest. + +!!! note -Check whether the face connection of a trees structure are consistent. That is if tree1 lists tree2 as neighbor at face i with ttf entries (or,face j), then tree2 must list tree1 as neighbor at face j with ttf entries (or, face i). + This is equivalent to calling t8_forest_init, t8_forest_set_adapt, t8_forest_set_ghost, and t8_forest_commit # Arguments -* `cmesh`:\\[in\\] A cmesh structure to be checked. -* `trees`:\\[in\\] The cmesh's trees struct. +* `forest_from`:\\[in\\] The forest to refine +* `adapt_fn`:\\[in\\] Adapt function to use +* `recursive`:\\[in\\] If true adaptation is recursive +* `do_face_ghost`:\\[in\\] If true, a layer of ghost elements is created for the forest. +* `user_data`:\\[in\\] If not NULL, the user data pointer of the forest is set to this value. # Returns -True if the face connections are consistent, False if not. +A new forest that is adapted from *forest_from*. ### Prototype ```c -int t8_cmesh_trees_is_face_consistent (t8_cmesh_t cmesh, t8_cmesh_trees_t trees); +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_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 +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_cmesh_trees_is_equal(cmesh, trees_a, trees_b) + t8_forest_ref(forest) + +Increase the reference counter of a forest. +# Arguments +* `forest`:\\[in,out\\] On input, this forest must exist with positive reference count. It may be in any state. ### Prototype ```c -int t8_cmesh_trees_is_equal (t8_cmesh_t cmesh, t8_cmesh_trees_t trees_a, t8_cmesh_trees_t trees_b); +void t8_forest_ref (t8_forest_t forest); ``` """ -function t8_cmesh_trees_is_equal(cmesh, trees_a, trees_b) - @ccall libt8.t8_cmesh_trees_is_equal(cmesh::t8_cmesh_t, trees_a::t8_cmesh_trees_t, trees_b::t8_cmesh_trees_t)::Cint +function t8_forest_ref(forest) + @ccall libt8.t8_forest_ref(forest::t8_forest_t)::Cvoid end """ - t8_cmesh_trees_destroy(trees) + t8_forest_unref(pforest) -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. +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 -* `trees`:\\[in,out\\] The tree structure to be destroyed. Set to NULL on output. +* `pforest`:\\[in,out\\] On input, the forest pointed to must exist with positive reference count. It may be in any state. If the reference count reaches zero, the forest is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the forest is not modified in other ways. ### Prototype ```c -void t8_cmesh_trees_destroy (t8_cmesh_trees_t *trees); +void t8_forest_unref (t8_forest_t *pforest); ``` """ -function t8_cmesh_trees_destroy(trees) - @ccall libt8.t8_cmesh_trees_destroy(trees::Ptr{t8_cmesh_trees_t})::Cvoid +function t8_forest_unref(pforest) + @ccall libt8.t8_forest_unref(pforest::Ptr{t8_forest_t})::Cvoid end """ -This structure holds the connectivity data of the coarse mesh. It can either be replicated, then each process stores a copy of the whole mesh, or partitioned. In the latter case, each process only stores a local portion of the mesh plus information about ghost elements. - -The coarse mesh is a collection of coarse trees that can be identified along faces. TODO: this description is outdated. rewrite it. The array ctrees stores these coarse trees sorted by their (global) tree\\_id. If the mesh if partitioned it is partitioned according to an (possible only virtually existing) underlying fine mesh. Therefore the ctrees array can store duplicated trees on different processes, if each of these processes owns elements of the same tree in the fine mesh. - -Each tree stores information about its face-neighbours in an array of t8_ctree_fneighbor. - -If partitioned the ghost trees are stored in a hash table that is backed up by an array. The hash value of a ghost tree is its tree\\_id modulo the number of ghosts on this process. - -# See also -t8\\_ctree\\_fneighbor -""" -const t8_cmesh_struct_t = t8_cmesh - -const t8_cghost_struct_t = t8_cghost - -"""This structure holds the data of a local tree including the information about face neighbors. For those the tree\\_to\\_face index is computed as follows. Let F be the maximal number of faces of any eclass of the cmesh's dimension, then ttf % F is the face number and ttf / F is the orientation. (t8_eclass_max_num_faces) The orientation is determined as follows. Let my\\_face and other\\_face be the two face numbers of the connecting trees. We chose a main\\_face from them as follows: Either both trees have the same element class, then the face with the lower face number is the main\\_face or the trees belong to different classes in which case the face belonging to the tree with the lower class according to the ordering triangle < square, hex < tet < prism < pyramid, is the main\\_face. Then face corner 0 of the main\\_face connects to a face corner k in the other face. The face orientation is defined as the number k. If the classes are equal and my\\_face == other\\_face, treating either of both faces as the main\\_face leads to the same result. See https://arxiv.org/pdf/1611.02929.pdf for more details.""" -const t8_ctree_struct_t = t8_ctree - -const t8_cmesh_trees_struct_t = t8_cmesh_trees - -const t8_part_tree_struct_t = t8_part_tree - -""" -This struct is used to profile cmesh algorithms. The cmesh struct stores a pointer to a profile struct, and if it is nonzero, various runtimes and data measurements are stored here. + t8_forest_get_dimension(forest) -# See also -[`t8_cmesh_set_profiling`](@ref) and, [`t8_cmesh_print_profile`](@ref) +### Prototype +```c +int t8_forest_get_dimension (const t8_forest_t forest); +``` """ -const t8_cprofile_struct_t = t8_cprofile +function t8_forest_get_dimension(forest) + @ccall libt8.t8_forest_get_dimension(forest::t8_forest_t)::Cint +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_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) -| Field | Note | -| :----- | :--------------------------------------------------- | -| scheme | An eclass scheme of which elements should be stored | -| array | The array in which the elements are stored | +### 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); +``` """ -struct t8_element_array_t - scheme::Ptr{t8_eclass_scheme_c} - array::sc_array_t +function t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) + @ccall libt8.t8_forest_element_coordinate(forest::t8_forest_t, ltree_id::t8_locidx_t, element::Ptr{t8_element_t}, corner_number::Cint, coordinates::Ptr{Cdouble})::Cvoid end """ - t8_element_array_new(scheme) - -Creates a new array structure with 0 elements. + t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) -# Arguments -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -# Returns -Return an allocated array of zero length. ### Prototype ```c -t8_element_array_t * t8_element_array_new (t8_eclass_scheme_c *scheme); +void t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out, const double *stretch_factors); ``` """ -function t8_element_array_new(scheme) - @ccall libt8.t8_element_array_new(scheme::Ptr{t8_eclass_scheme_c})::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_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. + t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) -# 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_element_array_t * t8_element_array_new_count (t8_eclass_scheme_c *scheme, size_t num_elements); +void t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out); ``` """ -function t8_element_array_new_count(scheme, num_elements) - @ccall libt8.t8_element_array_new_count(scheme::Ptr{t8_eclass_scheme_c}, num_elements::Csize_t)::Ptr{t8_element_array_t} +function t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) + @ccall libt8.t8_forest_element_from_ref_coords(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble})::Cvoid end """ - t8_element_array_init(element_array, scheme) - -Initializes an already allocated (or static) array structure. + t8_forest_element_centroid(forest, ltreeid, element, coordinates) -# Arguments -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. ### Prototype ```c -void t8_element_array_init (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme); +void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); ``` """ -function t8_element_array_init(element_array, scheme) - @ccall libt8.t8_element_array_init(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_eclass_scheme_c})::Cvoid +function t8_forest_element_centroid(forest, ltreeid, element, coordinates) + @ccall libt8.t8_forest_element_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, coordinates::Ptr{Cdouble})::Cvoid end """ - t8_element_array_init_size(element_array, scheme, num_elements) - -Initializes an already allocated (or static) array structure and allocates a given number of elements and initializes them with t8_element_init. + t8_forest_element_diam(forest, ltreeid, element) -# Arguments -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `num_elements`:\\[in\\] Number of initial array elements. ### Prototype ```c -void t8_element_array_init_size (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, size_t num_elements); +double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); ``` """ -function t8_element_array_init_size(element_array, scheme, num_elements) - @ccall libt8.t8_element_array_init_size(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_eclass_scheme_c}, num_elements::Csize_t)::Cvoid +function t8_forest_element_diam(forest, ltreeid, element) + @ccall libt8.t8_forest_element_diam(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble end """ - t8_element_array_init_view(view, array, offset, length) - -Initializes an already allocated (or static) view from existing t8\\_element\\_array. The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). + t8_forest_element_volume(forest, ltreeid, element) -# Arguments -* `view`:\\[in,out\\] Array structure to be initialized. -* `array`:\\[in\\] The array must not be resized while view is alive. -* `offset`:\\[in\\] The offset of the viewed section in element units. This offset cannot be changed until the view is reset. -* `length`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`sc_array_reset`](@ref) later. ### Prototype ```c -void t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, size_t offset, size_t length); +double t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); ``` """ -function t8_element_array_init_view(view, array, offset, length) - @ccall libt8.t8_element_array_init_view(view::Ptr{t8_element_array_t}, array::Ptr{t8_element_array_t}, offset::Csize_t, length::Csize_t)::Cvoid +function t8_forest_element_volume(forest, ltreeid, element) + @ccall libt8.t8_forest_element_volume(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t})::Cdouble end """ - t8_element_array_init_data(view, base, scheme, elem_count) - -Initializes an already allocated (or static) view from given plain C data (array of [`t8_element_t`](@ref)). The array view returned does not require [`t8_element_array_reset`](@ref) (doesn't hurt though). + t8_forest_element_face_area(forest, ltreeid, element, face) -# Arguments -* `view`:\\[in,out\\] Array structure to be initialized. -* `base`:\\[in\\] The data must not be moved while view is alive. Must be an array of [`t8_element_t`](@ref) corresponding to *scheme*. -* `scheme`:\\[in\\] The eclass scheme of the elements stored in *base*. -* `elem_count`:\\[in\\] The length of the view in element units. The view cannot be resized to exceed this length. It is not necessary to call [`t8_element_array_reset`](@ref) later. ### Prototype ```c -void t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_eclass_scheme_c *scheme, size_t elem_count); +double t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face); ``` """ -function t8_element_array_init_data(view, base, scheme, elem_count) - @ccall libt8.t8_element_array_init_data(view::Ptr{t8_element_array_t}, base::Ptr{t8_element_t}, scheme::Ptr{t8_eclass_scheme_c}, elem_count::Csize_t)::Cvoid +function t8_forest_element_face_area(forest, ltreeid, element, face) + @ccall libt8.t8_forest_element_face_area(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint)::Cdouble end """ - t8_element_array_init_copy(element_array, scheme, data, num_elements) - -Initializes an already allocated (or static) array structure and copy an existing array of [`t8_element_t`](@ref) into it. + t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) -# Arguments -* `element_array`:\\[in,out\\] Array structure to be initialized. -* `scheme`:\\[in\\] The eclass scheme of which elements should be stored. -* `data`:\\[in\\] An array of [`t8_element_t`](@ref) which will be copied into *element_array*. The elements in *data* must belong to *scheme* and must be properly initialized with either t8_element_new or t8_element_init. -* `num_elements`:\\[in\\] Number of elements in *data* to be copied. ### Prototype ```c -void t8_element_array_init_copy (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, t8_element_t *data, size_t num_elements); +void t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double centroid[3]); ``` """ -function t8_element_array_init_copy(element_array, scheme, data, num_elements) - @ccall libt8.t8_element_array_init_copy(element_array::Ptr{t8_element_array_t}, scheme::Ptr{t8_eclass_scheme_c}, data::Ptr{t8_element_t}, num_elements::Csize_t)::Cvoid +function t8_forest_element_face_centroid(forest, ltreeid, element, face, centroid) + @ccall libt8.t8_forest_element_face_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, centroid::Ptr{Cdouble})::Cvoid end """ - t8_element_array_resize(element_array, new_count) - -Change the number of elements stored in an element array. - -!!! note - - If *new_count* is larger than the number of current elements on *element_array*, then t8_element_init is called for the new elements. + t8_forest_element_face_normal(forest, ltreeid, element, face, normal) -# Arguments -* `element_array`:\\[in,out\\] The element array to be modified. -* `new_count`:\\[in\\] The new element count of the array. If it is zero the effect equals t8_element_array_reset. ### Prototype ```c -void t8_element_array_resize (t8_element_array_t *element_array, size_t new_count); +void t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double normal[3]); ``` """ -function t8_element_array_resize(element_array, new_count) - @ccall libt8.t8_element_array_resize(element_array::Ptr{t8_element_array_t}, new_count::Csize_t)::Cvoid +function t8_forest_element_face_normal(forest, ltreeid, element, face, normal) + @ccall libt8.t8_forest_element_face_normal(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, normal::Ptr{Cdouble})::Cvoid end """ - t8_element_array_copy(dest, src) + t8_forest_ghost -Copy the contents of an array into another. Both arrays must have the same eclass\\_scheme. +This struct stores various information about a forest's ghost elements and ghost trees. -# Arguments -* `dest`:\\[in\\] Array will be resized and get new data. -* `src`:\\[in\\] Array used as source of new data, will not be changed. -### Prototype -```c -void t8_element_array_copy (t8_element_array_t *dest, const t8_element_array_t *src); -``` +| Field | Note | +| :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| rc | The reference counter. | +| num\\_ghosts\\_elements | The count of non-local ghost leaf elements | +| num\\_remote\\_elements | The count of local leaf elements that are ghost to another process. | +| ghost\\_type | Describes which neighbors are considered ghosts. | +| ghost\\_trees | ghost tree data: global\\_id. eclass. elements. In linear id order | +| global\\_tree\\_to\\_ghost\\_tree | Indexes into ghost\\_trees. Given a global tree id I give the index i such that the tree is in ghost\\_trees[i] | +| process\\_offsets | Given a process, return the first ghost tree and within it the first element of that process. | +| remote\\_ghosts | array of local trees that have ghost elements for another process. for each tree an array of [`t8_element_t`](@ref) * of the local ghost elements. Also an array of [`t8_locidx_t`](@ref) of the local indices of these elements within the tree. It is a hash table, hashed with the rank of a remote process. Sorted within each process by linear id. | +| remote\\_processes | The ranks of the processes for which local elements are ghost. Array of int's. | +| glo\\_tree\\_mempool | The global tree memory pool. | +| proc\\_offset\\_mempool | The process offset memory pool. | """ -function t8_element_array_copy(dest, src) - @ccall libt8.t8_element_array_copy(dest::Ptr{t8_element_array_t}, src::Ptr{t8_element_array_t})::Cvoid +struct 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_element_array_push(element_array) + t8_forest_ghost_init(pghost, ghost_type) -Enlarge an array by one element. +Initialize a ghost type of a forest. # 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. +* `pghost`:\\[out\\] Pointer to the forest's ghost. +* `ghost_type`:\\[in\\] The type of the ghost elements, +# See also +[`t8_ghost_type_t`](@ref). + ### Prototype ```c -t8_element_t * t8_element_array_push (t8_element_array_t *element_array); +void t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type); ``` """ -function t8_element_array_push(element_array) - @ccall libt8.t8_element_array_push(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} +function t8_forest_ghost_init(pghost, ghost_type) + @ccall libt8.t8_forest_ghost_init(pghost::Ptr{t8_forest_ghost_t}, ghost_type::t8_ghost_type_t)::Cvoid end """ - t8_element_array_push_count(element_array, count) + t8_forest_ghost_num_trees(forest) -Enlarge an array by a number of elements. +Return the number of trees in a ghost. # Arguments -* `element_array`:\\[in\\] Array structure to be modified. -* `count`:\\[in\\] The number of elements to add. +* `forest`:\\[in\\] The forest. # Returns -Returns a pointer to the newly added elements for which t8_element_init was called. +The number of trees in the forest's ghost (or 0 if ghost structure does not exist). ### Prototype ```c -t8_element_t * t8_element_array_push_count (t8_element_array_t *element_array, size_t count); +t8_locidx_t t8_forest_ghost_num_trees (const 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_ghost_num_trees(forest) + @ccall libt8.t8_forest_ghost_num_trees(forest::t8_forest_t)::t8_locidx_t end """ - t8_element_array_index_locidx(element_array, index) + t8_forest_ghost_get_tree_element_offset(forest, lghost_tree) -Return a given element in an array. Const version. +Return the element offset of a ghost tree. + +!!! note + + forest must be committed before calling this function. # Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. +* `forest`:\\[in\\] The forest with constructed ghost layer. +* `lghost_tree`:\\[in\\] A local ghost id of a ghost tree. # Returns -A pointer to the element stored at position *index* in *element_array*. +The element offset of this ghost tree within the set of local ghost elements. ### Prototype ```c -const t8_element_t * t8_element_array_index_locidx (const t8_element_array_t *element_array, t8_locidx_t index); +t8_locidx_t t8_forest_ghost_get_tree_element_offset (t8_forest_t forest, t8_locidx_t lghost_tree); ``` """ -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_ghost_get_tree_element_offset(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_tree_element_offset(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_locidx_t end """ - t8_element_array_index_int(element_array, index) + t8_forest_ghost_tree_num_leaf_elements(forest, lghost_tree) -Return a given element in an array. Const version. +Given an index in the ghost\\_tree array, return this tree's number of leaf elements # Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. +* `forest`:\\[in\\] The *forest*. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. # Returns -A pointer to the element stored at position *index* in *element_array*. +The number of ghost leaf elements of the tree. *forest* must be committed before calling this function. ### Prototype ```c -const t8_element_t * t8_element_array_index_int (const t8_element_array_t *element_array, int index); +t8_locidx_t t8_forest_ghost_tree_num_leaf_elements (t8_forest_t forest, t8_locidx_t lghost_tree); ``` """ -function t8_element_array_index_int(element_array, index) - @ccall libt8.t8_element_array_index_int(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} +function t8_forest_ghost_tree_num_leaf_elements(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_tree_num_leaf_elements(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_locidx_t end """ - t8_element_array_index_locidx_mutable(element_array, index) + t8_forest_ghost_get_tree_leaf_elements(forest, lghost_tree) -Return a given element in an array. Mutable version. +Get a pointer to the ghost leaf element array of a ghost tree. # Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. # Returns -A pointer to the element stored at position *index* in *element_array*. +A pointer to the array of ghost leaf elements of the tree. *forest* must be committed before calling this function. ### Prototype ```c -t8_element_t * t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, t8_locidx_t index); +t8_element_array_t * t8_forest_ghost_get_tree_leaf_elements (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -function t8_element_array_index_locidx_mutable(element_array, index) - @ccall libt8.t8_element_array_index_locidx_mutable(element_array::Ptr{t8_element_array_t}, index::t8_locidx_t)::Ptr{t8_element_t} +function t8_forest_ghost_get_tree_leaf_elements(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_tree_leaf_elements(forest::t8_forest_t, lghost_tree::t8_locidx_t)::Ptr{t8_element_array_t} end """ - t8_element_array_index_int_mutable(element_array, index) + t8_forest_ghost_get_ghost_treeid(forest, gtreeid) -Return a given element in an array. Mutable version. +Given a global tree compute the ghost local tree id of it. # Arguments -* `element_array`:\\[in\\] Array of elements. -* `index`:\\[in\\] The index of an element within the array. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `gtreeid`:\\[in\\] A global tree in *forest*. # Returns -A pointer to the element stored at position *index* in *element_array*. +If *gtreeid* is also a ghost tree, the index in the ghost->ghost\\_trees array of the tree. Otherwise a negative number. *forest* must be committed before calling this function. +# See also +https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + ### Prototype ```c -t8_element_t * t8_element_array_index_int_mutable (t8_element_array_t *element_array, int index); +t8_locidx_t t8_forest_ghost_get_ghost_treeid (t8_forest_t forest, t8_gloidx_t gtreeid); ``` """ -function t8_element_array_index_int_mutable(element_array, index) - @ccall libt8.t8_element_array_index_int_mutable(element_array::Ptr{t8_element_array_t}, index::Cint)::Ptr{t8_element_t} +function t8_forest_ghost_get_ghost_treeid(forest, gtreeid) + @ccall libt8.t8_forest_ghost_get_ghost_treeid(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t end """ - t8_element_array_get_scheme(element_array) + t8_forest_ghost_get_tree_class(forest, lghost_tree) -Return the eclass scheme associated to a t8\\_element\\_array. +Given an index in the ghost\\_tree array, return this tree's element class. # Arguments -* `element_array`:\\[in\\] Array of elements. +* `forest`:\\[in\\] A committed forest. +* `lghost_tree`:\\[in\\] The tree's local index in the ghost\\_tree array. # Returns -The eclass scheme stored at *element_array*. +The element class of the given tree. ### Prototype ```c -const t8_eclass_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array); +t8_eclass_t t8_forest_ghost_get_tree_class (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -function t8_element_array_get_scheme(element_array) - @ccall libt8.t8_element_array_get_scheme(element_array::Ptr{t8_element_array_t})::Ptr{t8_eclass_scheme_c} +function t8_forest_ghost_get_tree_class(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_tree_class(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_eclass_t end """ - t8_element_array_get_count(element_array) + t8_forest_ghost_get_global_treeid(forest, lghost_tree) -Return the number of elements stored in a [`t8_element_array_t`](@ref). +Given a local ghost tree compute the global tree id of it. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] The forest. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. # Returns -The number of elements stored in *element_array*. +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 -size_t t8_element_array_get_count (const t8_element_array_t *element_array); +t8_gloidx_t t8_forest_ghost_get_global_treeid (const t8_forest_t forest, const t8_locidx_t lghost_tree); ``` """ -function t8_element_array_get_count(element_array) - @ccall libt8.t8_element_array_get_count(element_array::Ptr{t8_element_array_t})::Csize_t +function t8_forest_ghost_get_global_treeid(forest, lghost_tree) + @ccall libt8.t8_forest_ghost_get_global_treeid(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_gloidx_t end """ - t8_element_array_get_size(element_array) + t8_forest_ghost_get_leaf_element(forest, lghost_tree, lelement) -Return the data size of elements stored in a [`t8_element_array_t`](@ref). +Given an index into the ghost\\_trees array and for that tree an element index, return the corresponding element. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] The *forest*. Ghost layer must exist. +* `lghost_tree`:\\[in\\] The ghost tree id of a ghost tree. +* `lelement`:\\[in\\] The local id of the ghost leaf element considered. # Returns -The size (in bytes) of a single element in *element_array*. +A pointer to the ghost leaf element. *forest* must be committed before calling this function. ### Prototype ```c -size_t t8_element_array_get_size (const t8_element_array_t *element_array); +t8_element_t * t8_forest_ghost_get_leaf_element (t8_forest_t forest, t8_locidx_t lghost_tree, t8_locidx_t lelement); ``` """ -function t8_element_array_get_size(element_array) - @ccall libt8.t8_element_array_get_size(element_array::Ptr{t8_element_array_t})::Csize_t +function t8_forest_ghost_get_leaf_element(forest, lghost_tree, lelement) + @ccall libt8.t8_forest_ghost_get_leaf_element(forest::t8_forest_t, lghost_tree::t8_locidx_t, lelement::t8_locidx_t)::Ptr{t8_element_t} end """ - t8_element_array_get_data(element_array) + t8_forest_ghost_get_remotes(forest, num_remotes) -Return a const pointer to the real data array stored in a t8\\_element\\_array. +Return the array of remote ranks. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `num_remotes`:\\[in,out\\] On output the number of remote ranks is stored here. # Returns -A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. +The array of remote ranks in ascending order. ### Prototype ```c -const t8_element_t * t8_element_array_get_data (const t8_element_array_t *element_array); +int * t8_forest_ghost_get_remotes (t8_forest_t forest, int *num_remotes); ``` """ -function t8_element_array_get_data(element_array) - @ccall libt8.t8_element_array_get_data(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} +function t8_forest_ghost_get_remotes(forest, num_remotes) + @ccall libt8.t8_forest_ghost_get_remotes(forest::t8_forest_t, num_remotes::Ptr{Cint})::Ptr{Cint} end """ - t8_element_array_get_data_mutable(element_array) + t8_forest_ghost_remote_first_tree(forest, remote) -Return a pointer to the real data array stored in a t8\\_element\\_array. +Return the first local ghost tree of a remote rank. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. # Returns -A pointer to the stored data. If the number of stored elements is 0, then NULL is returned. +The ghost tree id of the first ghost tree that stores ghost elements of *remote*. ### Prototype ```c -t8_element_t * t8_element_array_get_data_mutable (t8_element_array_t *element_array); +t8_locidx_t t8_forest_ghost_remote_first_tree (t8_forest_t forest, int remote); ``` """ -function t8_element_array_get_data_mutable(element_array) - @ccall libt8.t8_element_array_get_data_mutable(element_array::Ptr{t8_element_array_t})::Ptr{t8_element_t} +function t8_forest_ghost_remote_first_tree(forest, remote) + @ccall libt8.t8_forest_ghost_remote_first_tree(forest::t8_forest_t, remote::Cint)::t8_locidx_t end """ - t8_element_array_get_array(element_array) - -Return a const pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. - -!!! note + t8_forest_ghost_remote_first_elem(forest, remote) - The data cannot be modified. +Return the local index of the first ghost element that belongs to a given remote rank. # Arguments -* `element_array`:\\[in\\] Array structure. +* `forest`:\\[in\\] A forest with constructed ghost layer. +* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. # Returns -A const pointer to the [`sc_array`](@ref) storing the data. +The index i in the ghost elements of the first element of rank *remote* ### Prototype ```c -const sc_array_t * t8_element_array_get_array (const t8_element_array_t *element_array); +t8_locidx_t t8_forest_ghost_remote_first_elem (t8_forest_t forest, int remote); ``` """ -function t8_element_array_get_array(element_array) - @ccall libt8.t8_element_array_get_array(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} +function t8_forest_ghost_remote_first_elem(forest, remote) + @ccall libt8.t8_forest_ghost_remote_first_elem(forest::t8_forest_t, remote::Cint)::t8_locidx_t end """ - t8_element_array_get_array_mutable(element_array) - -Return a mutable pointer to the [`sc_array`](@ref) stored in a t8\\_element\\_array. - -!!! note + t8_forest_ghost_ref(ghost) - The data can be modified. +Increase the reference count of a ghost structure. # Arguments -* `element_array`:\\[in\\] Array structure. -# Returns -A pointer to the [`sc_array`](@ref) storing the data. +* `ghost`:\\[in,out\\] On input, this ghost structure must exist with positive reference count. ### Prototype ```c -sc_array_t * t8_element_array_get_array_mutable (t8_element_array_t *element_array); +void t8_forest_ghost_ref (t8_forest_ghost_t ghost); ``` """ -function t8_element_array_get_array_mutable(element_array) - @ccall libt8.t8_element_array_get_array_mutable(element_array::Ptr{t8_element_array_t})::Ptr{sc_array_t} +function t8_forest_ghost_ref(ghost) + @ccall libt8.t8_forest_ghost_ref(ghost::t8_forest_ghost_t)::Cvoid end """ - t8_element_array_reset(element_array) - -Sets the array count to zero and frees all elements. - -!!! note + t8_forest_ghost_unref(pghost) - Calling [`t8_element_array_init`](@ref), then any array operations, then [`t8_element_array_reset`](@ref) is memory neutral. +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 -* `element_array`:\\[in,out\\] Array structure to be reset. +* `pghost`:\\[in,out\\] On input, the ghost structure pointed to must exist with positive reference count. If the reference count reaches zero, the ghost structure is destroyed and this pointer is set to NULL. Otherwise, the pointer is not changed. ### Prototype ```c -void t8_element_array_reset (t8_element_array_t *element_array); +void t8_forest_ghost_unref (t8_forest_ghost_t *pghost); ``` """ -function t8_element_array_reset(element_array) - @ccall libt8.t8_element_array_reset(element_array::Ptr{t8_element_array_t})::Cvoid +function t8_forest_ghost_unref(pghost) + @ccall libt8.t8_forest_ghost_unref(pghost::Ptr{t8_forest_ghost_t})::Cvoid end """ - t8_element_array_truncate(element_array) - -Sets the array count to zero, but does not free elements. - -!!! note + t8_forest_ghost_destroy(pghost) - 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. +Verify that a ghost structure has only one reference left and destroy it. This function is preferred over t8_forest_ghost_unref when it is known that the last reference is to be deleted. # Arguments -* `element_array`:\\[in,out\\] Element array structure to be truncated. +* `pghost`:\\[in,out\\] This ghost structure must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_forest_ghost_unref. ### Prototype ```c -void t8_element_array_truncate (t8_element_array_t *element_array); +void t8_forest_ghost_destroy (t8_forest_ghost_t *pghost); ``` """ -function t8_element_array_truncate(element_array) - @ccall libt8.t8_element_array_truncate(element_array::Ptr{t8_element_array_t})::Cvoid +function t8_forest_ghost_destroy(pghost) + @ccall libt8.t8_forest_ghost_destroy(pghost::Ptr{t8_forest_ghost_t})::Cvoid end """ - t8_shmem_init(comm) + t8_forest_ghost_create(forest) + +Create one layer of ghost elements for a forest. + +# Arguments +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +# See also +[`t8_forest_set_ghost`](@ref) ### Prototype ```c -void t8_shmem_init (sc_MPI_Comm comm); +void t8_forest_ghost_create (t8_forest_t forest); ``` """ -function t8_shmem_init(comm) - @ccall libt8.t8_shmem_init(comm::MPI_Comm)::Cvoid +function t8_forest_ghost_create(forest) + @ccall libt8.t8_forest_ghost_create(forest::t8_forest_t)::Cvoid end """ - t8_shmem_finalize(comm) + t8_forest_ghost_create_balanced_only(forest) + +Create one layer of ghost elements for a forest. This version only works with balanced forests and is the original algorithm from p4est: Scalable Algorithms For Parallel Adaptive Mesh Refinement On Forests of Octrees +!!! note + + 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_shmem_finalize (sc_MPI_Comm comm); +void t8_forest_ghost_create_balanced_only (t8_forest_t forest); ``` """ -function t8_shmem_finalize(comm) - @ccall libt8.t8_shmem_finalize(comm::MPI_Comm)::Cvoid +function t8_forest_ghost_create_balanced_only(forest) + @ccall libt8.t8_forest_ghost_create_balanced_only(forest::t8_forest_t)::Cvoid end """ - t8_shmem_set_type(comm, type) + t8_forest_ghost_create_topdown(forest) + +Experimental version of t8_forest_ghost_create using the ghost\\_v3 algorithm ### Prototype ```c -void t8_shmem_set_type (sc_MPI_Comm comm, sc_shmem_type_t type); +void t8_forest_ghost_create_topdown (t8_forest_t forest); ``` """ -function t8_shmem_set_type(comm, type) - @ccall libt8.t8_shmem_set_type(comm::MPI_Comm, type::sc_shmem_type_t)::Cvoid +function t8_forest_ghost_create_topdown(forest) + @ccall libt8.t8_forest_ghost_create_topdown(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_init(parray, elem_size, elem_count, comm) + t8_forest_save(forest) ### 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_save (t8_forest_t forest); ``` """ -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_save(forest) + @ccall libt8.t8_forest_save(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_start_writing(array) - -Enable writing mode for a shmem array. Only some processes may be allowed to write into the array, which is indicated by the return value being non-zero. - -!!! note - - This function is MPI collective. - -# Arguments -* `array`:\\[in,out\\] Initialized array. Writing will be enabled on certain processes. -# Returns -True if the calling process can write into the array. + t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) + ### Prototype ```c -int t8_shmem_array_start_writing (t8_shmem_array_t array); +int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, const int write_curved, int do_not_use_API, const int num_data, t8_vtk_data_field_t *data); ``` """ -function t8_shmem_array_start_writing(array) - @ccall libt8.t8_shmem_array_start_writing(array::t8_shmem_array_t)::Cint +function t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) + @ccall libt8.t8_forest_write_vtk_ext(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, write_curved::Cint, do_not_use_API::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_shmem_array_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). + t8_forest_write_vtk(forest, fileprefix) ### Prototype ```c -void t8_shmem_array_end_writing (t8_shmem_array_t array); +int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix); ``` """ -function t8_shmem_array_end_writing(array) - @ccall libt8.t8_shmem_array_end_writing(array::t8_shmem_array_t)::Cvoid +function t8_forest_write_vtk(forest, fileprefix) + @ccall libt8.t8_forest_write_vtk(forest::t8_forest_t, fileprefix::Cstring)::Cint end +# typedef int ( * t8_forest_iterate_face_fn ) ( const t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int face , void * user_data , const t8_locidx_t tree_leaf_index ) """ - 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. +Callback function used in # Arguments -* `array`:\\[in,out\\] The array to be modified. -* `index`:\\[in\\] The array entry to be modified. -* `value`:\\[in\\] The new value to be set. -### Prototype -```c -void t8_shmem_array_set_gloidx (t8_shmem_array_t array, int index, t8_gloidx_t value); -``` +* `forest`:\\[in\\] The forest. +* `ltreeid`:\\[in\\] Local index of the tree containing the *element*. +* `element`:\\[in\\] The considered element. +* `face`:\\[in\\] The integer index of the considered face of *element*. +* `user_data`:\\[in\\] Some user-defined data, as void pointer. +* `tree_leaf_index`:\\[in\\] Tree-local index the first leaf. +# Returns +Nonzero if the element may touch the face and the top-down search shall be continued, zero otherwise. +# See also +[`t8_forest_iterate_faces`](@ref). """ -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 +const t8_forest_iterate_face_fn = Ptr{Cvoid} +# typedef int ( * t8_forest_search_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index ) """ - t8_shmem_array_copy(dest, source) +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. -Copy the contents of one t8\\_shmem array into another. +# 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} -!!! note +# 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*. - *dest* must be initialized and match in element size and element count to *source*. +# 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} -!!! note +# typedef int ( * t8_forest_partition_search_fn ) ( const t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int pfirst , const int plast ) +""" +A call-back function used by t8_forest_search_partition describing a search-criterion. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. - *dest* must have writing mode disabled. +# Arguments +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. Since the cmesh has to be replicated, it coincides with the global tree id. +* `element`:\\[in\\] the element for which the search criterion is checked +* `pfirst`:\\[in\\] the first processor that owns part of *element*. Guaranteed to be non-empty. +* `plast`:\\[in\\] the last processor that owns part of *element*. Guaranteed to be non-empty. +# Returns +non-zero if the search criterion is met, zero otherwise. +""" +const t8_forest_partition_search_fn = Ptr{Cvoid} + +# typedef void ( * t8_forest_partition_query_fn ) ( const t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int pfirst , const int plast , void * queries , sc_array_t * query_indices , int * query_matches , const size_t num_active_queries ) +""" +A call-back function used by t8_forest_search_partition for queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element. The results of the check are stored in *query_matches*. # 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); -``` +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. Since the cmesh has to be replicated, it coincides with the global tree id. +* `element`:\\[in\\] the element for which the query is executed +* `pfirst`:\\[in\\] the first processor that owns part of *element*. Guaranteed to be non-empty. +* `plast`:\\[in\\] the last processor that owns part of *element*. Guaranteed to be non-empty. if this is equal to *pfirst*, then the recursion will stop for *element*'s branch after this function returns. +* `queries`:\\[in\\] an array of queries that are checked by the function +* `query_indices`:\\[in\\] an array of size\\_t entries, where each entry is an index of a query in *queries*. +* `query_matches`:\\[in,out\\] an array of length *num_active_queries*. If the element is not a leaf must be set to true or false at the i-th index for each query, specifying whether the element 'matches' the query of the i-th query index or not. When the element is a leaf we can return before all entries are set. +* `num_active_queries`:\\[in\\] The number of currently active queries (equals the number of entries of *query_matches* and entries of *query_indices*). """ -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 +const t8_forest_partition_query_fn = Ptr{Cvoid} """ - t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) + t8_forest_split_array(element, leaf_elements, offsets) +Split an array of elements according to the children of a given element E. In other words for each child C of E, find the index i, j, such that all descendants of C are elements[i], ..., elements[j-1]. + +# Arguments +* `element`:\\[in\\] An element. +* `leaf_elements`:\\[in\\] An array of leaf elements of *element*. Thus, all elements must be descendants. Sorted by linear index. +* `offsets`:\\[in,out\\] On input an allocated array of *num_children_of_E* + 1 entries. On output entry i indicates the position in *leaf_elements* where the descandents of the i-th child of E start. ### Prototype ```c -void t8_shmem_array_allgather (const void *sendbuf, int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, int recvcount, sc_MPI_Datatype recvtype); +void t8_forest_split_array (const t8_element_t *element, const t8_element_array_t *leaf_elements, size_t *offsets); ``` """ -function t8_shmem_array_allgather(sendbuf, sendcount, sendtype, recvarray, recvcount, recvtype) - @ccall libt8.t8_shmem_array_allgather(sendbuf::Ptr{Cvoid}, sendcount::Cint, sendtype::Cint, recvarray::t8_shmem_array_t, recvcount::Cint, recvtype::Cint)::Cvoid +function t8_forest_split_array(element, leaf_elements, offsets) + @ccall libt8.t8_forest_split_array(element::Ptr{t8_element_t}, leaf_elements::Ptr{t8_element_array_t}, offsets::Ptr{Csize_t})::Cvoid end """ - t8_shmem_array_allgatherv(sendbuf, sendcount, sendtype, recvarray, recvtype, comm) + t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, user_data, tree_lindex_of_first_leaf, callback) + +Iterate over all leaves of an element that touch a given face of the element. Callback is called in each recursive step with element as input. leaf\\_index is only not negative if element is a leaf, in which case it indicates the index of the leaf in the leaves of the tree. If it is negative, it is - (index + 1) Top-down iteration and callback is called on each intermediate level. If it returns false, the current element is not traversed further +# Arguments +* `forest`:\\[in\\] A committed forest. +* `ltreeid`:\\[in\\] Local index of the tree containing the *element*. +* `element`:\\[in\\] The considered element. +* `face`:\\[in\\] The integer index of the considered face of *element*. +* `leaf_elements`:\\[in\\] The array of leaf elements that are descendants of *element*. Sorted by linear index. +* `user_data`:\\[in\\] The user data passed to the *callback* function. +* `tree_lindex_of_first_leaf`:\\[in\\] Tree-local index of the first leaf. +* `callback`:\\[in\\] The callback function. ### 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_iterate_faces (const t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int face, const t8_element_array_t *leaf_elements, void *user_data, const t8_locidx_t tree_lindex_of_first_leaf, const t8_forest_iterate_face_fn callback); ``` """ -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_iterate_faces(forest, ltreeid, element, face, leaf_elements, user_data, tree_lindex_of_first_leaf, callback) + @ccall libt8.t8_forest_iterate_faces(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, leaf_elements::Ptr{t8_element_array_t}, user_data::Ptr{Cvoid}, tree_lindex_of_first_leaf::t8_locidx_t, callback::t8_forest_iterate_face_fn)::Cvoid end """ - t8_shmem_array_prefix(sendbuf, recvarray, count, type, op, comm) + t8_forest_search(forest, search_fn, query_fn, queries) +Perform a top-down search of the forest, executing a callback on each intermediate element. The search will enter each tree at least once. If the callback returns false for an element, its descendants are not further searched. To pass user data to the search\\_fn function use t8_forest_set_user_data. + +# Arguments +* `forest`:\\[in\\] The forest. +* `search_fn`:\\[in\\] The callback function describing the search criterion. +* `query_fn`:\\[in\\] The query function. +* `queries`:\\[in\\] The array of queries. ### Prototype ```c -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_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries); ``` """ -function t8_shmem_array_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_search(forest, search_fn, query_fn, queries) + @ccall libt8.t8_forest_search(forest::t8_forest_t, search_fn::t8_forest_search_fn, query_fn::t8_forest_query_fn, queries::Ptr{sc_array_t})::Cvoid end """ - t8_shmem_array_get_comm(array) + t8_forest_iterate_replace(forest_new, forest_old, replace_fn) + +Given two forest where the elements in one forest are either direct children or parents of the elements in the other forest compare the two forests and for each refined element or coarsened family in the old one, call a callback function providing the local indices of the old and new elements. + +!!! note + + To pass a user pointer to *replace_fn* use t8_forest_set_user_data and t8_forest_get_user_data. +# Arguments +* `forest_new`:\\[in\\] A forest, each element is a parent or child of an element in *forest_old*. +* `forest_old`:\\[in\\] The initial forest. +* `replace_fn`:\\[in\\] A replace callback function. ### Prototype ```c -sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array); +void t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_forest_replace_t replace_fn); ``` """ -function t8_shmem_array_get_comm(array) - @ccall libt8.t8_shmem_array_get_comm(array::t8_shmem_array_t)::Cint +function t8_forest_iterate_replace(forest_new, forest_old, replace_fn) + @ccall libt8.t8_forest_iterate_replace(forest_new::t8_forest_t, forest_old::t8_forest_t, replace_fn::t8_forest_replace_t)::Cvoid end """ - t8_shmem_array_get_elem_size(array) + t8_forest_search_partition(forest, search_fn, query_fn, queries) -Get the element size of a [`t8_shmem_array`](@ref) +Perform a top-down search of the global partition, executing a callback on each intermediate element. The search will enter each tree at least once. The recursion will only go down branches that are split between multiple processors. This is not a collective function. It does not communicate. The function expects the coarse mesh to be replicated. If the callback returns false for an element, its descendants are not further searched. To pass user data to **search_fn** function use t8_forest_set_user_data # Arguments -* `array`:\\[in\\] The array. -# Returns -The element size of *array*'s elements. +* `forest`:\\[in\\] the forest to be searched +* `search_fn`:\\[in\\] a search callback function called on elements +* `query_fn`:\\[in\\] a query callback function called for all active queries of an element +* `queries`:\\[in,out\\] an array of queries that are checked by the function ### Prototype ```c -size_t t8_shmem_array_get_elem_size (t8_shmem_array_t array); +void t8_forest_search_partition (const t8_forest_t forest, t8_forest_partition_search_fn search_fn, t8_forest_partition_query_fn query_fn, sc_array_t *queries); ``` """ -function t8_shmem_array_get_elem_size(array) - @ccall libt8.t8_shmem_array_get_elem_size(array::t8_shmem_array_t)::Csize_t +function t8_forest_search_partition(forest, search_fn, query_fn, queries) + @ccall libt8.t8_forest_search_partition(forest::t8_forest_t, search_fn::t8_forest_partition_search_fn, query_fn::t8_forest_partition_query_fn, queries::Ptr{sc_array_t})::Cvoid end """ - t8_shmem_array_get_elem_count(array) + t8_forest_partition(forest) -Get the number of elements of a [`t8_shmem_array`](@ref) +Populate a forest with the partitioned elements of forest->set\\_from. Currently the elements are distributed evenly (each element has the same weight). # Arguments -* `array`:\\[in\\] The array. -# Returns -The number of elements in *array*. +* `forest`:\\[in,out\\] The forest. ### Prototype ```c -size_t t8_shmem_array_get_elem_count (t8_shmem_array_t array); +void t8_forest_partition (t8_forest_t forest); ``` """ -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_partition(forest) + @ccall libt8.t8_forest_partition(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_get_gloidx_array(array) - -Return a read-only pointer to the data of a shared memory array interpreted as an [`t8_gloidx_t`](@ref) array. - -!!! note + t8_forest_partition_create_offsets(forest) - Writing mode must be disabled for *array*. +Create the element\\_offset array of a partitioned forest. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) -# Returns -The data of *array* as [`t8_gloidx_t`](@ref) pointer. +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -const t8_gloidx_t * t8_shmem_array_get_gloidx_array (t8_shmem_array_t array); +void t8_forest_partition_create_offsets (t8_forest_t forest); ``` """ -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_partition_create_offsets(forest) + @ccall libt8.t8_forest_partition_create_offsets(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_get_gloidx_array_for_writing(array) + t8_forest_partition_next_nonempty_rank(forest, rank) -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. +If t8_forest_partition_create_offsets was already called, compute for a given rank the next greater rank that is not empty. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref) +* `forest`:\\[in\\] The forest. +* `rank`:\\[in\\] An MPI rank. # Returns -The data of *array* as [`t8_gloidx_t`](@ref) pointer. +A rank q > *rank* such that the forest has elements on *q*. If such a *q* does not exist, returns mpisize. ### Prototype ```c -t8_gloidx_t * t8_shmem_array_get_gloidx_array_for_writing (t8_shmem_array_t array); +int t8_forest_partition_next_nonempty_rank (t8_forest_t forest, int rank); ``` """ -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_partition_next_nonempty_rank(forest, rank) + @ccall libt8.t8_forest_partition_next_nonempty_rank(forest::t8_forest_t, rank::Cint)::Cint 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_partition_create_first_desc(forest) - Writing mode must be disabled for *array*. +Create the array of global\\_first\\_descendant ids of a partitioned forest. # 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). +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -t8_gloidx_t t8_shmem_array_get_gloidx (t8_shmem_array_t array, int index); +void t8_forest_partition_create_first_desc (t8_forest_t forest); ``` """ -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_partition_create_first_desc(forest) + @ccall libt8.t8_forest_partition_create_first_desc(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_get_array(array) - -Return a pointer to the data array of a [`t8_shmem_array`](@ref). - -!!! note + t8_forest_partition_create_tree_offsets(forest) - Writing mode must be disabled for *array*. +Create the array tree offsets of a partitioned forest. This arrays stores at position p the global id of the first tree of this process. Or if this tree is shared, it stores -(global\\_id) - 1. # Arguments -* `array`:\\[in\\] The [`t8_shmem_array`](@ref). -# Returns -A pointer to the data array of *array*. +* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -const void * t8_shmem_array_get_array (t8_shmem_array_t array); +void t8_forest_partition_create_tree_offsets (t8_forest_t forest); ``` """ -function t8_shmem_array_get_array(array) - @ccall libt8.t8_shmem_array_get_array(array::t8_shmem_array_t)::Ptr{Cvoid} +function t8_forest_partition_create_tree_offsets(forest) + @ccall libt8.t8_forest_partition_create_tree_offsets(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_index(array, index) - -Return a read-only pointer to an element in a [`t8_shmem_array`](@ref). - -!!! note + t8_forest_partition_data(forest_from, forest_to, data_in, data_out) - You should not modify the value. +Re-Partition an array accordingly to a partitioned forest. !!! note - Writing mode must be disabled for *array*. + *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 -* `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_from`:\\[in\\] The forest before the partitioning step. +* `forest_to`:\\[in\\] The partitioned forest of *forest_from*. +* `data_in`:\\[in\\] A pointer to an [`sc_array_t`](@ref) holding data (one value per element) accordingly to *forest_from*. +* `data_out`:\\[in,out\\] A pointer to an already allocated [`sc_array_t`](@ref) capable of holding data accordingly to *forest_to*. ### Prototype ```c -const void * t8_shmem_array_index (t8_shmem_array_t array, size_t index); +void t8_forest_partition_data (t8_forest_t forest_from, t8_forest_t forest_to, const sc_array_t *data_in, sc_array_t *data_out); ``` -""" -function t8_shmem_array_index(array, index) - @ccall libt8.t8_shmem_array_index(array::t8_shmem_array_t, index::Csize_t)::Ptr{Cvoid} +""" +function t8_forest_partition_data(forest_from, forest_to, data_in, data_out) + @ccall libt8.t8_forest_partition_data(forest_from::t8_forest_t, forest_to::t8_forest_t, data_in::Ptr{sc_array_t}, data_out::Ptr{sc_array_t})::Cvoid end """ - t8_shmem_array_index_for_writing(array, index) - -Return a pointer to an element in a [`t8_shmem_array`](@ref) in writing mode. - -!!! note + t8_forest_partition_test_boundary_element(forest) - You can modify the value before the next call to t8_shmem_array_end_writing. +Test if the last descendant of the last element of current rank has a smaller linear id than the stored first descendant of rank+1. If this is not the case, elements overlap. !!! note - Writing mode must be enabled for *array*. + *forest* must be committed before calling this function. # 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 -void * t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index); +void t8_forest_partition_test_boundary_element (const 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_partition_test_boundary_element(forest) + @ccall libt8.t8_forest_partition_test_boundary_element(forest::t8_forest_t)::Cvoid end """ - t8_shmem_array_is_equal(array_a, array_b) + t8_forest_set_profiling(forest, set_profiling) ### Prototype ```c -int t8_shmem_array_is_equal (t8_shmem_array_t array_a, t8_shmem_array_t array_b); +void t8_forest_set_profiling (t8_forest_t forest, int set_profiling); ``` """ -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_set_profiling(forest, set_profiling) + @ccall libt8.t8_forest_set_profiling(forest::t8_forest_t, set_profiling::Cint)::Cvoid end """ - t8_shmem_array_destroy(parray) - -Free all memory associated with a [`t8_shmem_array`](@ref). + t8_forest_compute_profile(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. ### Prototype ```c -void t8_shmem_array_destroy (t8_shmem_array_t *parray); +void t8_forest_compute_profile (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_compute_profile(forest) + @ccall libt8.t8_forest_compute_profile(forest::t8_forest_t)::Cvoid end """ - t8_forest_adapt(forest) + t8_forest_profile_get_adapt_stats(forest) ### Prototype ```c -void t8_forest_adapt (t8_forest_t forest); +const sc_statinfo_t * t8_forest_profile_get_adapt_stats (t8_forest_t forest); ``` """ -function t8_forest_adapt(forest) - @ccall libt8.t8_forest_adapt(forest::t8_forest_t)::Cvoid +function t8_forest_profile_get_adapt_stats(forest) + @ccall libt8.t8_forest_profile_get_adapt_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_forest_balance(forest, repartition) + t8_forest_profile_get_ghost_stats(forest) ### Prototype ```c -void t8_forest_balance (t8_forest_t forest, int repartition); +const sc_statinfo_t * t8_forest_profile_get_ghost_stats (t8_forest_t forest); ``` """ -function t8_forest_balance(forest, repartition) - @ccall libt8.t8_forest_balance(forest::t8_forest_t, repartition::Cint)::Cvoid +function t8_forest_profile_get_ghost_stats(forest) + @ccall libt8.t8_forest_profile_get_ghost_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_forest_is_balanced(forest) + t8_forest_profile_get_partition_stats(forest) ### Prototype ```c -int t8_forest_is_balanced (t8_forest_t forest); +const sc_statinfo_t * t8_forest_profile_get_partition_stats (t8_forest_t forest); ``` """ -function t8_forest_is_balanced(forest) - @ccall libt8.t8_forest_is_balanced(forest::t8_forest_t)::Cint +function t8_forest_profile_get_partition_stats(forest) + @ccall libt8.t8_forest_profile_get_partition_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end """ - t8_tree - -The t8 tree datatype + t8_forest_profile_get_commit_stats(forest) -| 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) | +### Prototype +```c +const sc_statinfo_t * t8_forest_profile_get_commit_stats (t8_forest_t forest); +``` """ -struct t8_tree - elements::t8_element_array_t - eclass::t8_eclass_t - first_desc::Ptr{t8_element_t} - last_desc::Ptr{t8_element_t} - elements_offset::t8_locidx_t +function t8_forest_profile_get_commit_stats(forest) + @ccall libt8.t8_forest_profile_get_commit_stats(forest::t8_forest_t)::Ptr{sc_statinfo_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. + t8_forest_profile_get_balance_stats(forest) -| Enumerator | Note | -| :-------------------- | :---------------------------------------------------------------- | -| T8\\_GHOST\\_NONE | Do not create ghost layer. | -| T8\\_GHOST\\_FACES | Consider all face (codimension 1) neighbors. | -| T8\\_GHOST\\_EDGES | Consider all edge (codimension 2) and face neighbors. | -| T8\\_GHOST\\_VERTICES | Consider all vertex (codimension 3) and edge and face neighbors. | +### Prototype +```c +const sc_statinfo_t * t8_forest_profile_get_balance_stats (t8_forest_t forest); +``` """ -@cenum t8_ghost_type_t::UInt32 begin - T8_GHOST_NONE = 0 - T8_GHOST_FACES = 1 - T8_GHOST_EDGES = 2 - T8_GHOST_VERTICES = 3 +function t8_forest_profile_get_balance_stats(forest) + @ccall libt8.t8_forest_profile_get_balance_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} end -# typedef void ( * t8_generic_function_pointer ) ( void ) """ -This typedef is needed as a helper construct to properly be able to define a function that returns a pointer to a void fun(void) function. + t8_forest_profile_get_balance_rounds_stats(forest) -# See also -[`t8_forest_get_user_function`](@ref). +### Prototype +```c +const sc_statinfo_t * t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); +``` """ -const t8_generic_function_pointer = Ptr{Cvoid} +function t8_forest_profile_get_balance_rounds_stats(forest) + @ccall libt8.t8_forest_profile_get_balance_rounds_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +end -# typedef void ( * t8_forest_replace_t ) ( t8_forest_t forest_old , t8_forest_t forest_new , t8_locidx_t which_tree , t8_eclass_scheme_c * ts , const int refine , const int num_outgoing , const t8_locidx_t first_outgoing , const int num_incoming , const t8_locidx_t first_incoming ) """ -Callback function prototype to replace one set of elements with another. - -This is used by the replace routine which can be called after adapt, when the elements of an existing, valid forest are changed. The callback allows the user to make changes to the elements of the new forest that are either refined, coarsened or the same as elements in the old forest. + t8_forest_print_profile(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. +### Prototype +```c +void t8_forest_print_profile (t8_forest_t forest); +``` +""" +function t8_forest_print_profile(forest) + @ccall libt8.t8_forest_print_profile(forest::t8_forest_t)::Cvoid +end -# 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_profile_get_adapt_time(forest) -# 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 [ ] ) +### Prototype +```c +double t8_forest_profile_get_adapt_time (t8_forest_t forest); +``` """ -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. +function t8_forest_profile_get_adapt_time(forest) + @ccall libt8.t8_forest_profile_get_adapt_time(forest::t8_forest_t)::Cdouble +end -# Arguments -* `forest`:\\[in\\] the forest to which the new elements belong -* `forest_from`:\\[in\\] the forest that is adapted. -* `which_tree`:\\[in\\] the local tree containing *elements* -* `lelement_id`:\\[in\\] the local element id in *forest_old* in the tree of the current element -* `ts`:\\[in\\] the eclass scheme of the tree -* `is_family`:\\[in\\] if 1, the first *num_elements* entries in *elements* form a family. If 0, they do not. -* `num_elements`:\\[in\\] the number of entries in *elements* that are defined -* `elements`:\\[in\\] Pointers to a family or, if *is_family* is zero, pointer to one element. -# Returns -1 if the first entry in *elements* should be refined, -1 if the family *elements* shall be coarsened, -2 if the first entry in *elements* should be removed, 0 else. """ -const t8_forest_adapt_t = Ptr{Cvoid} + t8_forest_profile_get_partition_time(forest, procs_sent) +### Prototype +```c +double t8_forest_profile_get_partition_time (t8_forest_t forest, int *procs_sent); +``` """ - t8_forest_init(pforest) +function t8_forest_profile_get_partition_time(forest, procs_sent) + @ccall libt8.t8_forest_profile_get_partition_time(forest::t8_forest_t, procs_sent::Ptr{Cint})::Cdouble +end -Create a new forest with reference count one. This forest needs to be specialized with the t8\\_forest\\_set\\_* calls. Currently it is mandatory to either call the functions 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. +""" + t8_forest_profile_get_balance_time(forest, balance_rounds) -# Arguments -* `pforest`:\\[in,out\\] On input, this pointer must be non-NULL. On return, this pointer set to the new forest. ### Prototype ```c -void t8_forest_init (t8_forest_t *pforest); +double t8_forest_profile_get_balance_time (t8_forest_t forest, int *balance_rounds); ``` """ -function t8_forest_init(pforest) - @ccall libt8.t8_forest_init(pforest::Ptr{t8_forest_t})::Cvoid +function t8_forest_profile_get_balance_time(forest, balance_rounds) + @ccall libt8.t8_forest_profile_get_balance_time(forest::t8_forest_t, balance_rounds::Ptr{Cint})::Cdouble end """ - t8_forest_is_initialized(forest) - -Check whether a forest is not NULL, initialized and not committed. In addition, it asserts that the forest is consistent as much as possible. + t8_forest_profile_get_ghost_time(forest, ghosts_sent) -# Arguments -* `forest`:\\[in\\] This forest is examined. May be NULL. -# Returns -True if forest is not NULL, t8_forest_init has been called on it, but not t8_forest_commit. False otherwise. ### Prototype ```c -int t8_forest_is_initialized (t8_forest_t forest); +double t8_forest_profile_get_ghost_time (t8_forest_t forest, t8_locidx_t *ghosts_sent); ``` """ -function t8_forest_is_initialized(forest) - @ccall libt8.t8_forest_is_initialized(forest::t8_forest_t)::Cint +function t8_forest_profile_get_ghost_time(forest, ghosts_sent) + @ccall libt8.t8_forest_profile_get_ghost_time(forest::t8_forest_t, ghosts_sent::Ptr{Cint})::Cdouble end """ - t8_forest_is_committed(forest) - -Check whether a forest is not NULL, initialized and committed. In addition, it asserts that the forest is consistent as much as possible. + t8_forest_profile_get_ghostexchange_waittime(forest) -# Arguments -* `forest`:\\[in\\] This forest is examined. May be NULL. -# Returns -True if forest is not NULL and t8_forest_init has been called on it as well as t8_forest_commit. False otherwise. ### Prototype ```c -int t8_forest_is_committed (t8_forest_t forest); +double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest); ``` """ -function t8_forest_is_committed(forest) - @ccall libt8.t8_forest_is_committed(forest::t8_forest_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_forest_no_overlap(forest) + t8_forest_profile_get_cmesh_offsets_runtime(forest) -Check whether the forest has local overlapping elements. +### Prototype +```c +double t8_forest_profile_get_cmesh_offsets_runtime (t8_forest_t forest); +``` +""" +function t8_forest_profile_get_cmesh_offsets_runtime(forest) + @ccall libt8.t8_forest_profile_get_cmesh_offsets_runtime(forest::t8_forest_t)::Cdouble +end -!!! note +""" + t8_forest_profile_get_forest_offsets_runtime(forest) - This function is collective, but only checks local overlapping on each process. +### Prototype +```c +double t8_forest_profile_get_forest_offsets_runtime (t8_forest_t forest); +``` +""" +function t8_forest_profile_get_forest_offsets_runtime(forest) + @ccall libt8.t8_forest_profile_get_forest_offsets_runtime(forest::t8_forest_t)::Cdouble +end -# Arguments -* `forest`:\\[in\\] The forest to consider. -# Returns -True if *forest* has no elements which are inside each other. -# See also -[`t8_forest_partition_test_boundary_element`](@ref) if you also want to test for global overlap across the process boundaries. +""" + t8_forest_profile_get_first_descendant_runtime(forest) ### Prototype ```c -int t8_forest_no_overlap (t8_forest_t forest); +double t8_forest_profile_get_first_descendant_runtime (t8_forest_t forest); ``` """ -function t8_forest_no_overlap(forest) - @ccall libt8.t8_forest_no_overlap(forest::t8_forest_t)::Cint +function t8_forest_profile_get_first_descendant_runtime(forest) + @ccall libt8.t8_forest_profile_get_first_descendant_runtime(forest::t8_forest_t)::Cdouble +end + +""" + t8_profile + +This struct holds profiling information, such as timings or statistics about communication. + +| Field | Note | +| :----------------------------- | :------------------------------------------------------------------------------------------------------------- | +| partition\\_elements\\_shipped | The number of elements this process has sent to other in the last partition call. | +| partition\\_elements\\_recv | The number of elements this process has received from other in the last partition call. | +| partition\\_bytes\\_sent | The total number of bytes sent to other processes in the last partition call. | +| partition\\_procs\\_sent | The number of different processes this process has send local elements to in the last partition call. | +| ghosts\\_shipped | The number of ghost elements this process has sent to other processes. | +| ghosts\\_received | The number of ghost elements this process has received from other processes. | +| ghosts\\_remotes | The number of processes this process have sent ghost elements to (and received from). | +| balance\\_rounds | The number of iterations during balance. | +| adapt\\_runtime | The runtime of the last call to [`t8_forest_adapt`](@ref) (not counting adaptation in t8\\_forest\\_balance). | +| partition\\_runtime | The runtime of the last call to *t8_cmesh_partition* (not count in partition in t8\\_forest\\_balance). | +| ghost\\_runtime | The runtime of the last call to [`t8_forest_ghost_create`](@ref). | +| ghost\\_waittime | Amount of synchronisation time in ghost. | +| balance\\_runtime | The runtime of the last call to *t8_forest_balance*. | +| commit\\_runtime | The runtime of the last call to [`t8_cmesh_commit`](@ref). | +| cmesh\\_offsets\\_runtime | The runtime of the last call to [`t8_forest_partition_create_tree_offsets`](@ref). | +| forest\\_offsets\\_runtime | The runtime of the last call to [`t8_forest_partition_create_offsets`](@ref). | +| first\\_descendant\\_runtime | The runtime of the last call to [`t8_forest_partition_create_first_desc`](@ref). | +""" +struct t8_profile + partition_elements_shipped::t8_locidx_t + partition_elements_recv::t8_locidx_t + partition_bytes_sent::Csize_t + partition_procs_sent::Cint + ghosts_shipped::t8_locidx_t + ghosts_received::t8_locidx_t + ghosts_remotes::Cint + balance_rounds::Cint + adapt_runtime::Cdouble + partition_runtime::Cdouble + ghost_runtime::Cdouble + ghost_waittime::Cdouble + balance_runtime::Cdouble + commit_runtime::Cdouble + cmesh_offsets_runtime::Cdouble + forest_offsets_runtime::Cdouble + first_descendant_runtime::Cdouble end -""" - t8_forest_is_equal(forest_a, forest_b) +"""This struct holds profiling information, such as timings or statistics about communication.""" +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 -Check whether two committed forests have the same local elements. +"""This struct holds profiling information, such as timings or statistics about communication.""" +const t8_profile_struct_t = t8_profile -!!! note +"""This struct stores various information about a forest's ghost elements and ghost trees.""" +const t8_forest_ghost_struct_t = t8_forest_ghost - This function is not collective. It only returns the state on the current rank. +# typedef int ( * t8_fortran_adapt_coordinate_callback ) ( double x , double y , double z , int is_family ) +const t8_fortran_adapt_coordinate_callback = Ptr{Cvoid} -# Arguments -* `forest_a`:\\[in\\] The first forest. -* `forest_b`:\\[in\\] The second forest. -# Returns -True if *forest_a* and *forest_b* do have the same number of local trees and each local tree has the same elements, that is t8_element_equal returns true for each pair of elements of *forest_a* and *forest_b*. -### Prototype -```c -int t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b); -``` -""" -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 +const MPI_T8_Fint = Cint """ - t8_forest_set_cmesh(forest, cmesh, comm) + t8_fortran_init_all(comm) ### Prototype ```c -void t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); +void t8_fortran_init_all (sc_MPI_Comm *comm); ``` """ -function t8_forest_set_cmesh(forest, cmesh, comm) - @ccall libt8.t8_forest_set_cmesh(forest::t8_forest_t, cmesh::t8_cmesh_t, comm::MPI_Comm)::Cvoid +function t8_fortran_init_all(comm) + @ccall libt8.t8_fortran_init_all(comm::Ptr{Cint})::Cvoid end +# no prototype is found for this function at t8_fortran_interface.h:67:1, please use with caution """ - t8_forest_set_scheme(forest, scheme) + t8_fortran_finalize() -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. +Finalize sc. This wraps [`sc_finalize`](@ref) in order to have consistent naming with [`t8_fortran_init_all`](@ref). -# Arguments -* `forest`:\\[in,out\\] The forest whose scheme variable will be set. -* `scheme`:\\[in\\] The scheme to be set. We take ownership. This can be prevented by referencing **scheme**. ### Prototype ```c -void t8_forest_set_scheme (t8_forest_t forest, t8_scheme_cxx_t *scheme); +void t8_fortran_finalize (); ``` """ -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_fortran_finalize() + @ccall libt8.t8_fortran_finalize()::Cvoid end """ - t8_forest_set_level(forest, level) + t8_fortran_cmesh_commit(cmesh, comm) -Set the initial refinement level to be used when **forest** is committed. - -!!! note - - This setting cannot be combined with any of the derived forest methods (t8_forest_set_copy, t8_forest_set_adapt, t8_forest_set_partition, and t8_forest_set_balance) and overwrites any of these settings. If this function is used, then the forest is created from scratch as a uniform refinement of the specified cmesh (t8_forest_set_cmesh, t8_forest_set_scheme). - -# Arguments -* `forest`:\\[in,out\\] The forest whose level will be set. -* `level`:\\[in\\] The initial refinement level of **forest**, when it is committed. ### Prototype ```c -void t8_forest_set_level (t8_forest_t forest, int level); +void t8_fortran_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm *comm); ``` """ -function t8_forest_set_level(forest, level) - @ccall libt8.t8_forest_set_level(forest::t8_forest_t, level::Cint)::Cvoid +function t8_fortran_cmesh_commit(cmesh, comm) + @ccall libt8.t8_fortran_cmesh_commit(cmesh::t8_cmesh_t, comm::Ptr{Cint})::Cvoid end """ - t8_forest_set_copy(forest, from) + t8_fortran_cmesh_set_join_by_stash_noConn(cmesh, do_both_directions) -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. +This function calls [`t8_cmesh_set_join_by_stash`](@ref) with connectivity = NULL. + +!!! warning + + This routine might be too expensive for very large meshes. In this case, consider to use a fully featured mesh generator. !!! note - This setting cannot be combined with t8_forest_set_adapt, t8_forest_set_partition, or t8_forest_set_balance and overwrites these settings. + This routine does not detect periodic boundaries. # Arguments -* `forest`:\\[in,out\\] The forest. -* `from`:\\[in\\] A second forest from which *forest* will be copied in t8_forest_commit. +* `cmesh`:\\[in,out\\] Pointer to a t8code cmesh object. If set to NULL this argument is ignored. +* `do_both_directions`:\\[in\\] Compute the connectivity from both neighboring sides. Takes much longer to compute. ### Prototype ```c -void t8_forest_set_copy (t8_forest_t forest, const t8_forest_t from); +void t8_fortran_cmesh_set_join_by_stash_noConn (t8_cmesh_t cmesh, const int do_both_directions); ``` """ -function t8_forest_set_copy(forest, from) - @ccall libt8.t8_forest_set_copy(forest::t8_forest_t, from::t8_forest_t)::Cvoid +function t8_fortran_cmesh_set_join_by_stash_noConn(cmesh, do_both_directions) + @ccall libt8.t8_fortran_cmesh_set_join_by_stash_noConn(cmesh::t8_cmesh_t, do_both_directions::Cint)::Cvoid end """ - t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) - -Set a source forest with an adapt function to be adapted on committing. By default, the forest takes ownership of the source **set_from** such that it will be destroyed on calling t8_forest_commit. To keep ownership of **set_from**, call t8_forest_ref before passing it into this function. This means that it is ILLEGAL to continue using **set_from** or dereferencing it UNLESS it is referenced directly before passing it into this function. - -!!! note + t8_fortran_MPI_Comm_new(Fcomm) - This setting can be combined with t8_forest_set_partition and t8_forest_set_balance. The order in which these operations are executed is always 1) Adapt 2) Balance 3) Partition - -!!! note - - This setting may not be combined with t8_forest_set_copy and overwrites this setting. - -# Arguments -* `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); +sc_MPI_Comm * t8_fortran_MPI_Comm_new (MPI_T8_Fint Fcomm); ``` """ -function t8_forest_set_adapt(forest, set_from, adapt_fn, recursive) - @ccall libt8.t8_forest_set_adapt(forest::t8_forest_t, set_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint)::Cvoid +function t8_fortran_MPI_Comm_new(Fcomm) + @ccall libt8.t8_fortran_MPI_Comm_new(Fcomm::MPI_T8_Fint)::Ptr{Cint} end """ - t8_forest_set_user_data(forest, data) - -Set the user data of a forest. This can i.e. be used to pass user defined arguments to the adapt routine. - -# Arguments -* `forest`:\\[in,out\\] The forest -* `data`:\\[in\\] A pointer to user data. t8code will never touch the data. The forest does not need be committed before calling this function. -# See also -[`t8_forest_get_user_data`](@ref) + t8_fortran_MPI_Comm_delete(Ccomm) ### Prototype ```c -void t8_forest_set_user_data (t8_forest_t forest, void *data); +void t8_fortran_MPI_Comm_delete (sc_MPI_Comm *Ccomm); ``` """ -function t8_forest_set_user_data(forest, data) - @ccall libt8.t8_forest_set_user_data(forest::t8_forest_t, data::Ptr{Cvoid})::Cvoid +function t8_fortran_MPI_Comm_delete(Ccomm) + @ccall libt8.t8_fortran_MPI_Comm_delete(Ccomm::Ptr{Cint})::Cvoid end """ - 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) + t8_cmesh_new_periodic_tri_wrap(Ccomm) ### Prototype ```c -void * t8_forest_get_user_data (const t8_forest_t forest); +t8_cmesh_t t8_cmesh_new_periodic_tri_wrap (sc_MPI_Comm *Ccomm); ``` """ -function t8_forest_get_user_data(forest) - @ccall libt8.t8_forest_get_user_data(forest::t8_forest_t)::Ptr{Cvoid} +function t8_cmesh_new_periodic_tri_wrap(Ccomm) + @ccall libt8.t8_cmesh_new_periodic_tri_wrap(Ccomm::Ptr{Cint})::t8_cmesh_t end """ - t8_forest_set_user_function(forest, _function) - -Set the user function pointer of a forest. This can i.e. be used to pass user defined functions to the adapt routine. - -!!! note - - *function* can be an arbitrary function with return value and parameters of your choice. When accessing it with t8_forest_get_user_function you should cast it into the proper type. - -# Arguments -* `forest`:\\[in,out\\] The forest -* `function`:\\[in\\] A pointer to a user defined function. t8code will never touch the function. The forest does not need be committed before calling this function. -# See also -[`t8_forest_get_user_function`](@ref) + t8_forest_new_uniform_default(cmesh, level, do_face_ghost, comm) ### Prototype ```c -void t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer function); +t8_forest_t t8_forest_new_uniform_default (t8_cmesh_t cmesh, int level, int do_face_ghost, sc_MPI_Comm *comm); ``` """ -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_new_uniform_default(cmesh, level, do_face_ghost, comm) + @ccall libt8.t8_forest_new_uniform_default(cmesh::t8_cmesh_t, level::Cint, do_face_ghost::Cint, comm::Ptr{Cint})::t8_forest_t end """ - t8_forest_get_user_function(forest) - -Return the user function pointer associated with a forest. + t8_forest_adapt_by_coordinates(forest, recursive, callback) # 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) - +* `forest`:\\[in,out\\] The forest +* `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. +* `callback`:\\[in\\] A pointer to a user defined function. t8code will never touch the function. ### Prototype ```c -t8_generic_function_pointer t8_forest_get_user_function (const t8_forest_t forest); +t8_forest_t t8_forest_adapt_by_coordinates (t8_forest_t forest, int recursive, t8_fortran_adapt_coordinate_callback callback); ``` """ -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_adapt_by_coordinates(forest, recursive, callback) + @ccall libt8.t8_forest_adapt_by_coordinates(forest::t8_forest_t, recursive::Cint, callback::t8_fortran_adapt_coordinate_callback)::t8_forest_t 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 + t8_global_productionf_noargs(string) - This setting may not be combined with t8_forest_set_copy and overwrites this setting. +Log a message on the root rank with priority [`SC_LP_PRODUCTION`](@ref). # 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. +* `string`:\\[in\\] String to log. ### Prototype ```c -void t8_forest_set_partition (t8_forest_t forest, const t8_forest_t set_from, int set_for_coarsening); +void t8_global_productionf_noargs (const char *string); ``` """ -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_global_productionf_noargs(string) + @ccall libt8.t8_global_productionf_noargs(string::Cstring)::Cvoid end """ - t8_forest_set_balance(forest, set_from, no_repartition) - -Set a source forest to be balanced during commit. A forest is said to be balanced if each element has face neighbors of level at most +1 or -1 of the element's level. + t8_geometry_type -!!! note +This enumeration contains all possible geometries. - 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. +| Enumerator | Note | +| :--------------------------------------------- | :----------------------------------------------------------------------------------------------- | +| T8\\_GEOMETRY\\_TYPE\\_ZERO | The zero geometry maps all points to zero. | +| T8\\_GEOMETRY\\_TYPE\\_LINEAR | The linear geometry uses linear interpolations to interpolate between the tree vertices. | +| T8\\_GEOMETRY\\_TYPE\\_LINEAR\\_AXIS\\_ALIGNED | The linear, axis aligned geometry uses only 2 vertices, since it is axis aligned. | +| T8\\_GEOMETRY\\_TYPE\\_LAGRANGE | The Lagrange geometry uses a mapping with Lagrange polynomials to approximate curved elements . | +| T8\\_GEOMETRY\\_TYPE\\_ANALYTIC | The analytic geometry uses a user-defined analytic function to map into the physical domain. | +| T8\\_GEOMETRY\\_TYPE\\_CAD | The opencascade geometry uses CAD shapes to map trees exactly to the underlying CAD model. | +| T8\\_GEOMETRY\\_TYPE\\_COUNT | This is no geometry type but can be used as the number of geometry types. | +| T8\\_GEOMETRY\\_TYPE\\_INVALID | This is no geometry type but is used as error type to describe invalid geometries | +| T8\\_GEOMETRY\\_TYPE\\_UNDEFINED | This is no geometry type but is used for every geometry, where no type is defined | +""" +@cenum t8_geometry_type::UInt32 begin + T8_GEOMETRY_TYPE_ZERO = 0 + T8_GEOMETRY_TYPE_LINEAR = 1 + T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED = 2 + T8_GEOMETRY_TYPE_LAGRANGE = 3 + T8_GEOMETRY_TYPE_ANALYTIC = 4 + T8_GEOMETRY_TYPE_CAD = 5 + T8_GEOMETRY_TYPE_COUNT = 6 + T8_GEOMETRY_TYPE_INVALID = 7 + T8_GEOMETRY_TYPE_UNDEFINED = 8 +end -!!! note +"""This enumeration contains all possible geometries.""" +const t8_geometry_type_t = t8_geometry_type - This setting may not be combined with t8_forest_set_copy and overwrites this setting. +mutable struct t8_geometry_handler end -# 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); -``` -""" -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 +"""This typedef holds virtual functions for the geometry handler. We need it so that we can use [`t8_geometry_handler_c`](@ref) pointers in .c files without them seeing the actual C++ code (and then not compiling) TODO: Delete this when the cmesh is a proper cpp class.""" +const t8_geometry_handler_c = t8_geometry_handler """ - t8_forest_set_ghost(forest, do_ghost, ghost_type) + t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) -Enable or disable the creation of a layer of ghost elements. On default no ghosts are created. +Evaluates the geometry of a tree at a given reference point. # Arguments -* `forest`:\\[in\\] The forest. -* `do_ghost`:\\[in\\] If non-zero a ghost layer will be created. -* `ghost_type`:\\[in\\] Controls which neighbors count as ghost elements, currently only T8\\_GHOST\\_FACES is supported. This value is ignored if *do_ghost* = 0. +* `cmesh`:\\[in\\] The cmesh +* `gtreeid`:\\[in\\] The global id of the tree +* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the geometry +* `num_coords`:\\[in\\] The number of reference coordinates +* `out_coords`:\\[out\\] The evaluated coordinates ### Prototype ```c -void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type); +void t8_geometry_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords); ``` """ -function t8_forest_set_ghost(forest, do_ghost, ghost_type) - @ccall libt8.t8_forest_set_ghost(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t)::Cvoid +function t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) + @ccall libt8.t8_geometry_evaluate(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid end """ - t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) + t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) -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. +Evaluates the jacobian of a tree at a given reference point. # Arguments -* `ghost_version`:\\[in\\] If 1, the iterative ghost algorithm for balanced forests is used. If 2, the iterative algorithm for unbalanced forests. If 3, the top-down search algorithm for unbalanced forests. -# See also -[`t8_forest_set_ghost`](@ref) - +* `cmesh`:\\[in\\] The cmesh +* `gtreeid`:\\[in\\] The global id of the tree +* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the jacobian +* `num_coords`:\\[in\\] The number of reference coordinates +* `jacobian`:\\[out\\] The jacobian at the reference coordinates ### Prototype ```c -void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); +void t8_geometry_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *jacobian); ``` """ -function t8_forest_set_ghost_ext(forest, do_ghost, ghost_type, ghost_version) - @ccall libt8.t8_forest_set_ghost_ext(forest::t8_forest_t, do_ghost::Cint, ghost_type::t8_ghost_type_t, ghost_version::Cint)::Cvoid +function t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) + @ccall libt8.t8_geometry_jacobian(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, jacobian::Ptr{Cdouble})::Cvoid end """ - t8_forest_set_load(forest, filename) + t8_geometry_get_type(cmesh, gtreeid) + +This function returns the geometry type of a tree. +# Arguments +* `cmesh`:\\[in\\] The cmesh +* `gtreeid`:\\[in\\] The global id of the tree +# Returns +The geometry type of the tree with id *gtreeid* ### Prototype ```c -void t8_forest_set_load (t8_forest_t forest, const char *filename); +t8_geometry_type_t t8_geometry_get_type (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); ``` """ -function t8_forest_set_load(forest, filename) - @ccall libt8.t8_forest_set_load(forest::t8_forest_t, filename::Cstring)::Cvoid +function t8_geometry_get_type(cmesh, gtreeid) + @ccall libt8.t8_geometry_get_type(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::t8_geometry_type_t end """ - t8_forest_comm_global_num_elements(forest) + t8_geometry_tree_negative_volume(cmesh, gtreeid) -Compute the global number of elements in a forest as the sum of the local element counts. +Check if a tree has a negative volume # Arguments -* `forest`:\\[in\\] The forest. +* `cmesh`:\\[in\\] The cmesh to check +* `gtreeid`:\\[in\\] The global id of the tree +# Returns +True if the tree with id *gtreeid* has a negative volume. False otherwise. ### Prototype ```c -void t8_forest_comm_global_num_elements (t8_forest_t forest); +int t8_geometry_tree_negative_volume (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid); ``` """ -function t8_forest_comm_global_num_elements(forest) - @ccall libt8.t8_forest_comm_global_num_elements(forest::t8_forest_t)::Cvoid +function t8_geometry_tree_negative_volume(cmesh, gtreeid) + @ccall libt8.t8_geometry_tree_negative_volume(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Cint end """ - t8_forest_commit(forest) + t8_geom_get_name(geom) -After allocating and adding properties to a forest, commit the changes. This call sets up the internal state of the forest. +Get the name of a geometry. # Arguments -* `forest`:\\[in,out\\] Must be created with t8_forest_init and specialized with t8\\_forest\\_set\\_* calls first. +* `geom`:\\[in\\] A geometry. +# Returns +The name of *geom*. ### Prototype ```c -void t8_forest_commit (t8_forest_t forest); +const char * t8_geom_get_name (const t8_geometry_c *geom); ``` """ -function t8_forest_commit(forest) - @ccall libt8.t8_forest_commit(forest::t8_forest_t)::Cvoid +function t8_geom_get_name(geom) + @ccall libt8.t8_geom_get_name(geom::Ptr{t8_geometry_c})::Cstring end """ - t8_forest_get_maxlevel(forest) + t8_geom_get_type(geom) -Return the maximum allowed refinement level for any element in a forest. +Get the type of a geometry. # Arguments -* `forest`:\\[in\\] A forest. +* `geom`:\\[in\\] A geometry. # 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. +The type of *geom*. ### Prototype ```c -int t8_forest_get_maxlevel (const t8_forest_t forest); +t8_geometry_type_t t8_geom_get_type (const t8_geometry_c *geom); ``` """ -function t8_forest_get_maxlevel(forest) - @ccall libt8.t8_forest_get_maxlevel(forest::t8_forest_t)::Cint +function t8_geom_get_type(geom) + @ccall libt8.t8_geom_get_type(geom::Ptr{t8_geometry_c})::t8_geometry_type_t end """ - t8_forest_get_local_num_elements(forest) - -Return the number of process local elements in the forest. + t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) -# Arguments -* `forest`:\\[in\\] A forest. -# Returns -The number of elements on this process in *forest*. *forest* must be committed before calling this function. ### Prototype ```c -t8_locidx_t t8_forest_get_local_num_elements (const t8_forest_t forest); +void t8_geom_compute_linear_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); ``` """ -function t8_forest_get_local_num_elements(forest) - @ccall libt8.t8_forest_get_local_num_elements(forest::t8_forest_t)::t8_locidx_t +function t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + @ccall libt8.t8_geom_compute_linear_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid end """ - t8_forest_get_global_num_elements(forest) - -Return the number of global elements in the forest. + t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) -# 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 -t8_gloidx_t t8_forest_get_global_num_elements (const t8_forest_t forest); +void t8_geom_compute_linear_axis_aligned_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); ``` """ -function t8_forest_get_global_num_elements(forest) - @ccall libt8.t8_forest_get_global_num_elements(forest::t8_forest_t)::t8_gloidx_t +function t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + @ccall libt8.t8_geom_compute_linear_axis_aligned_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid end """ - t8_forest_get_num_ghosts(forest) + t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) -Return the number of ghost elements of a forest. +Interpolates linearly between 2, bilinearly between 4 or trilineraly between 8 points. # 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. - +* `coefficients`:\\[in\\] An array of size at least dim giving the coefficients used for the interpolation +* `corner_values`:\\[in\\] An array of size 2^dim * 3, giving for each corner (in zorder) of the unit square/cube its function values in space. +* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. +* `interpolation_dim`:\\[in\\] The dimension of the interpolation (1 for linear, 2 for bilinear, 3 for trilinear) +* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -t8_locidx_t t8_forest_get_num_ghosts (const t8_forest_t forest); +void t8_geom_linear_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); ``` """ -function t8_forest_get_num_ghosts(forest) - @ccall libt8.t8_forest_get_num_ghosts(forest::t8_forest_t)::t8_locidx_t +function t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + @ccall libt8.t8_geom_linear_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid end """ - t8_forest_get_eclass(forest, ltreeid) + t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) -Return the element class of a forest local tree. +Triangular interpolation between 3 points (triangle) or 4 points (tetrahedron) using cartesian coordinates. The input coefficients have to be given as coordinates in the reference triangle (interpolation\\_dim = 2) with points (0,0) (1,0) (1,1) or the reference tet (interpolation\\_dim = 3) with points (0,0,0) (1,0,0) (1,1,0) (1,1,1). # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in *forest*. -# Returns -The element class of the tree *ltreeid*. *forest* must be committed before calling this function. +* `coefficients`:\\[in\\] An array of size *interpolation_dim* giving the coefficients in the reference triangle/tet used for the interpolation +* `corner_values`:\\[in\\] An array of size 3 * *corner_value_dim* for *interpolation_dim* == 2 or 4 * *corner_value_dim* for *interpolation_dim* == 3, giving the function values of the triangle/tetrahedron for each corner (in zorder) +* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. +* `interpolation_dim`:\\[in\\] The dimension of the interpolation (2 for triangle, 3 for tetrahedron) +* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -t8_eclass_t t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid); +void t8_geom_triangular_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); ``` """ -function t8_forest_get_eclass(forest, ltreeid) - @ccall libt8.t8_forest_get_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_eclass_t +function t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + @ccall libt8.t8_geom_triangular_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid end """ - t8_forest_tree_is_local(forest, local_tree) - -Check whether a given tree id belongs to a local tree in a forest. + t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) -# Arguments -* `forest`:\\[in\\] The forest. -* `local_tree`:\\[in\\] A tree id. -# Returns -True if and only if the id *local_tree* belongs to a local tree of *forest*. *forest* must be committed before calling this function. ### Prototype ```c -int t8_forest_tree_is_local (const t8_forest_t forest, const t8_locidx_t local_tree); +void t8_geom_get_face_vertices (t8_eclass_t tree_class, const double *tree_vertices, int face_index, int dim, double *face_vertices); ``` """ -function t8_forest_tree_is_local(forest, local_tree) - @ccall libt8.t8_forest_tree_is_local(forest::t8_forest_t, local_tree::t8_locidx_t)::Cint +function t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) + @ccall libt8.t8_geom_get_face_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, face_index::Cint, dim::Cint, face_vertices::Ptr{Cdouble})::Cvoid end """ - t8_forest_get_local_id(forest, gtreeid) - -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\\] The forest. -* `gtreeid`:\\[in\\] The global id of a tree. -# Returns -The tree's local id in *forest*, if it is a local tree. A negative number if not. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) ### Prototype ```c -t8_locidx_t t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); +void t8_geom_get_edge_vertices (t8_eclass_t tree_class, const double *tree_vertices, int edge_index, int dim, double *edge_vertices); ``` """ -function t8_forest_get_local_id(forest, gtreeid) - @ccall libt8.t8_forest_get_local_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t +function t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) + @ccall libt8.t8_geom_get_edge_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, edge_index::Cint, dim::Cint, edge_vertices::Ptr{Cdouble})::Cvoid end """ - t8_forest_get_local_or_ghost_id(forest, gtreeid) + t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) -Given a global tree id compute the forest local id of this tree. If the tree is a local tree, then the local id is between 0 and the number of local trees. If the tree is a ghost, then the local id is between num\\_local\\_trees and num\\_local\\_trees + num\\_ghost\\_trees. If the tree is neither a local tree nor a ghost tree, a negative number is returned. +Calculates a point of intersection in a triangular reference space. The intersection is the extension of a straight line passing through a reference point and the opposite vertex of the edge. /|\\ / | \\ o -> reference point / o \\ x -> intersection point / | \\ /\\_\\_\\_\\_x\\_\\_\\_\\_\\ # Arguments -* `forest`:\\[in\\] The forest. -* `gtreeid`:\\[in\\] The global id of a tree. -# Returns -The tree's local id in *forest*, if it is a local tree. num\\_local\\_trees + the ghosts id, if it is a ghost tree. A negative number if not. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +* `edge_index`:\\[in\\] Index of the edge, the intersection lies on. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +* `ref_intersection`:\\[out\\] Coordinates of the intersection point. ### Prototype ```c -t8_locidx_t t8_forest_get_local_or_ghost_id (const t8_forest_t forest, const t8_gloidx_t gtreeid); +void t8_geom_get_ref_intersection (int edge_index, const double *ref_coords, double ref_intersection[2]); ``` """ -function t8_forest_get_local_or_ghost_id(forest, gtreeid) - @ccall libt8.t8_forest_get_local_or_ghost_id(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t +function t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) + @ccall libt8.t8_geom_get_ref_intersection(edge_index::Cint, ref_coords::Ptr{Cdouble}, ref_intersection::Ptr{Cdouble})::Cvoid end """ - t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) - -Given the local id of a tree in a forest, compute the tree's local id in the associated cmesh. - -!!! note + t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) - For forest local trees, this is the inverse function of t8_forest_cmesh_ltreeid_to_ltreeid. +Calculates the scaling factor for edge displacement along a triangular tree face depending on the position of the global reference point. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree or ghost in the forest. -# Returns -The local id of the tree in the cmesh associated with the forest. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. +* `tree_vertices`:\\[in\\] Array with the tree vertex coordinates. +* `glob_intersection`:\\[in\\] Array containing the coordinates of the intersection point of a line drawn from the opposite vertex through the glob\\_ref\\_point onto the edge with edge\\_index. +* `glob_ref_point`:\\[in\\] Array containing the coordinates of the reference point mapped into the global space. ### Prototype ```c -t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, t8_locidx_t ltreeid); +double t8_geom_get_triangle_scaling_factor (int edge_index, const double *tree_vertices, const double *glob_intersection, const double *glob_ref_point); ``` """ -function t8_forest_ltreeid_to_cmesh_ltreeid(forest, ltreeid) - @ccall libt8.t8_forest_ltreeid_to_cmesh_ltreeid(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t +function t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) + @ccall libt8.t8_geom_get_triangle_scaling_factor(edge_index::Cint, tree_vertices::Ptr{Cdouble}, glob_intersection::Ptr{Cdouble}, glob_ref_point::Ptr{Cdouble})::Cdouble end """ - t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) - -Given the local id of a tree in the coarse mesh of a forest, compute the tree's local id in the forest. - -!!! note + t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) - For forest local trees, this is the inverse function of t8_forest_ltreeid_to_cmesh_ltreeid. +Calculates the scaling factor for the displacement of an edge over a face of a tetrahedral element. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in the coarse mesh of *forest*. +* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. +* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. # Returns -The local id of the tree in the forest. -1 if the tree is not forest local. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +The scaling factor of the edge displacement on the face at the point of the reference coordinates. ### Prototype ```c -t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, t8_locidx_t lctreeid); +double t8_geom_get_scaling_factor_of_edge_on_face_tet (int edge_index, int face_index, const double *ref_coords); ``` """ -function t8_forest_cmesh_ltreeid_to_ltreeid(forest, lctreeid) - @ccall libt8.t8_forest_cmesh_ltreeid_to_ltreeid(forest::t8_forest_t, lctreeid::t8_locidx_t)::t8_locidx_t +function t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) + @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble end """ - t8_forest_get_coarse_tree(forest, ltreeid) + t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) -Given the local id of a tree in a forest, return the coarse tree of the cmesh that corresponds to this tree. +Calculates the face intersection of a ray passing trough the reference coordinates and the opposite vertex of that face for a tetrahedron. The coordinates of the face intersection are reference coordinates: [0,1]^3. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree in the forest. -# Returns -The coarse tree that matches the forest tree with local id *ltreeid*. +* `face_index`:\\[in\\] Index of the face, on which the intersection should be calculated. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. +* `face_intersection`:\\[out\\] Three dimensional array containing the intersection point on the face in reference space. ### Prototype ```c -t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid); +void t8_geom_get_tet_face_intersection (const int face_index, const double *ref_coords, double face_intersection[3]); ``` """ -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_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) + @ccall libt8.t8_geom_get_tet_face_intersection(face_index::Cint, ref_coords::Ptr{Cdouble}, face_intersection::Ptr{Cdouble})::Cvoid end """ - t8_forest_element_is_leaf(forest, element, local_tree) - -Query whether a given element is a leaf in a forest. - -!!! note - - This does not query for ghost leaves. - -!!! note + t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) - *forest* must be committed before calling this function. +Calculates the scaling factor for the displacement of an edge over a face of a prism element. # Arguments -* `forest`:\\[in\\] The forest. -* `element`:\\[in\\] An element of a local tree in *forest*. -* `local_tree`:\\[in\\] A local tree id of *forest*. +* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. +* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. # Returns -True (non-zero) if and only if *element* is a leaf in *local_tree* of *forest*. +The scaling factor of the edge displacement on the face at the point of the reference coordinates. ### Prototype ```c -int t8_forest_element_is_leaf (const t8_forest_t forest, const t8_element_t *element, const t8_locidx_t local_tree); +double t8_geom_get_scaling_factor_of_edge_on_face_prism (int edge_index, int face_index, const double *ref_coords); ``` """ -function t8_forest_element_is_leaf(forest, element, local_tree) - @ccall libt8.t8_forest_element_is_leaf(forest::t8_forest_t, element::Ptr{t8_element_t}, local_tree::t8_locidx_t)::Cint +function t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) + @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble end """ - t8_forest_leaf_face_orientation(forest, ltreeid, ts, leaf, face) - -Compute the leaf face orientation at given face in a forest. + t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) -For more information about the encoding of face orientation refer to t8_cmesh_get_face_neighbor. +Calculates the scaling factor for the displacement of an face through the volume of a prism element. # Arguments -* `forest`:\\[in\\] The forest. Must have a valid ghost layer. -* `ltreeid`:\\[in\\] A local tree id. -* `ts`:\\[in\\] The eclass scheme of the element. -* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. -* `face`:\\[in\\] The index of the face across which the face neighbors are searched. +* `face`:\\[in\\] Index of the displaced face. +* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. # Returns -Face orientation encoded as integer. +The scaling factor of the face displacement at the point of the reference coordinates inside the prism volume. ### Prototype ```c -int t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_eclass_scheme_c *ts, const t8_element_t *leaf, int face); +double t8_geom_get_scaling_factor_face_through_volume_prism (const int face, const double *ref_coords); ``` """ -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_leaf_face_neighbors(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced) - -Compute the leaf face neighbors of a forest. - -!!! note - - If there are no face neighbors, then *neighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. - -!!! note - - Currently *forest* must be balanced. - -!!! note - - *forest* must be committed before calling this function. - -!!! note +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 - Important! This routine allocates memory which must be freed. Do it like this: +""" + t8_vertex_point_inside(vertex_coords, point, tolerance) -if (num\\_neighbors > 0) { eclass\\_scheme->[`t8_element_destroy`](@ref) (num\\_neighbors, neighbors); [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } +Check if a point lies inside a vertex # Arguments -* `forest`:\\[in\\] The forest. Must have a valid ghost layer. -* `ltreeid`:\\[in\\] A local tree id. -* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. -* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. -* `face`:\\[in\\] The index of the face across which the face neighbors are searched. -* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. -* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. -* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. -* `pneigh_scheme`:\\[out\\] On output the eclass scheme of the neighbor elements. -* `forest_is_balanced`:\\[in\\] True if we know that *forest* is balanced, false otherwise. +* `vertex_coords`:\\[in\\] The coordinates of the vertex +* `point`:\\[in\\] The coordinates of the point to check +* `tolerance`:\\[in\\] A double > 0 defining the tolerance +# Returns +0 if the point is outside, 1 otherwise. ### Prototype ```c -void t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, t8_locidx_t **pelement_indices, t8_eclass_scheme_c **pneigh_scheme, int forest_is_balanced); +int t8_vertex_point_inside (const double vertex_coords[3], const double point[3], const double tolerance); ``` """ -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_vertex_point_inside(vertex_coords, point, tolerance) + @ccall libt8.t8_vertex_point_inside(vertex_coords::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint end """ - t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced, gneigh_tree, orientation) - -Like t8_forest_leaf_face_neighbors but also provides information about the global neighbors and the orientation. - -!!! note - - If there are no face neighbors, then *neighbor\\_leaves = NULL, num\\_neighbors = 0, and *pelement\\_indices = NULL on output. - -!!! note - - Currently *forest* must be balanced. - -!!! note - - *forest* must be committed before calling this function. - -!!! note - - Important! This routine allocates memory which must be freed. Do it like this: + t8_line_point_inside(p_0, vec, point, tolerance) -if (num\\_neighbors > 0) { eclass\\_scheme->[`t8_element_destroy`](@ref) (num\\_neighbors, neighbors); [`T8_FREE`](@ref) (pneighbor\\_leaves); [`T8_FREE`](@ref) (pelement\\_indices); [`T8_FREE`](@ref) (dual\\_faces); } +Check if a point is inside a line that is defined by a starting point *p_0* and a vector *vec* # Arguments -* `forest`:\\[in\\] The forest. Must have a valid ghost layer. -* `ltreeid`:\\[in\\] A local tree id. -* `leaf`:\\[in\\] A leaf in tree *ltreeid* of *forest*. -* `pneighbor_leaves`:\\[out\\] Unallocated on input. On output the neighbor leaves are stored here. -* `face`:\\[in\\] The index of the face across which the face neighbors are searched. -* `dual_faces`:\\[out\\] On output the face id's of the neighboring elements' faces. -* `num_neighbors`:\\[out\\] On output the number of neighbor leaves. -* `pelement_indices`:\\[out\\] Unallocated on input. On output the element indices of the neighbor leaves are stored here. 0, 1, ... num\\_local\\_el - 1 for local leaves and num\\_local\\_el , ... , num\\_local\\_el + num\\_ghosts - 1 for ghosts. -* `pneigh_scheme`:\\[out\\] On output the eclass scheme of the neighbor elements. -* `forest_is_balanced`:\\[in\\] True if we know that *forest* is balanced, false otherwise. -* `gneigh_tree`:\\[out\\] The global tree IDs of the neighbor trees. -* `orientation`:\\[out\\] If not NULL on input, the face orientation is computed and stored here. Thus, if the face connection is an inter-tree connection the orientation of the tree-to-tree connection is stored. Otherwise, the value 0 is stored. All other parameters and behavior are identical to `t8_forest_leaf_face_neighbors`. +* `p_0`:\\[in\\] Starting point of the line +* `vec`:\\[in\\] Direction of the line (not normalized) +* `point`:\\[in\\] The coordinates of the point to check +* `tolerance`:\\[in\\] A double > 0 defining the tolerance +# Returns +0 if the point is outside, 1 otherwise. ### Prototype ```c -void t8_forest_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); +int t8_line_point_inside (const double *p_0, const double *vec, const double *point, const double tolerance); ``` """ -function t8_forest_leaf_face_neighbors_ext(forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced, gneigh_tree, orientation) - @ccall libt8.t8_forest_leaf_face_neighbors_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, leaf::Ptr{t8_element_t}, pneighbor_leaves::Ptr{Ptr{Ptr{t8_element_t}}}, face::Cint, dual_faces::Ptr{Ptr{Cint}}, num_neighbors::Ptr{Cint}, pelement_indices::Ptr{Ptr{t8_locidx_t}}, pneigh_scheme::Ptr{Ptr{t8_eclass_scheme_c}}, forest_is_balanced::Cint, gneigh_tree::Ptr{t8_gloidx_t}, orientation::Ptr{Cint})::Cvoid +function t8_line_point_inside(p_0, vec, point, tolerance) + @ccall libt8.t8_line_point_inside(p_0::Ptr{Cdouble}, vec::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint end """ - t8_forest_ghost_exchange_data(forest, element_data) - -Exchange ghost information of user defined element data. - -!!! note + t8_triangle_point_inside(p_0, v, w, point, tolerance) - This function is collective and hence must be called by all processes in the forest's MPI Communicator. +Check if a point is inside of a triangle described by a point *p_0* and two vectors *v* and *w*. # Arguments -* `forest`:\\[in\\] The forest. Must 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. +* `p_0`:\\[in\\] The first vertex of a triangle +* `v`:\\[in\\] The vector from p\\_0 to p\\_1 (second vertex in the triangle) +* `w`:\\[in\\] The vector from p\\_0 to p\\_2 (third vertex in the triangle) +* `point`:\\[in\\] The coordinates of the point to check +* `tolerance`:\\[in\\] A double > 0 defining the tolerance +# Returns +0 if the point is outside, 1 otherwise. ### Prototype ```c -void t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data); +int t8_triangle_point_inside (const double p_0[3], const double v[3], const double w[3], const double point[3], const double tolerance); ``` """ -function t8_forest_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_triangle_point_inside(p_0, v, w, point, tolerance) + @ccall libt8.t8_triangle_point_inside(p_0::Ptr{Cdouble}, v::Ptr{Cdouble}, w::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint end """ - t8_forest_ghost_print(forest) + t8_plane_point_inside(point_on_face, face_normal, point) -Print the ghost structure of a forest. Only used for debugging. +Check if a point lays on the inner side of a plane of a bilinearly interpolated volume element. the plane is described by a point and the normal of the face. +# Arguments +* `point_on_face`:\\[in\\] A point on the plane +* `face_normal`:\\[in\\] The normal of the face +* `point`:\\[in\\] The point to check +# Returns +0 if the point is outside, 1 otherwise. ### Prototype ```c -void t8_forest_ghost_print (t8_forest_t forest); +int t8_plane_point_inside (const double point_on_face[3], const double face_normal[3], const double point[3]); ``` """ -function t8_forest_ghost_print(forest) - @ccall libt8.t8_forest_ghost_print(forest::t8_forest_t)::Cvoid +function t8_plane_point_inside(point_on_face, face_normal, point) + @ccall libt8.t8_plane_point_inside(point_on_face::Ptr{Cdouble}, face_normal::Ptr{Cdouble}, point::Ptr{Cdouble})::Cint end """ - t8_forest_partition_cmesh(forest, comm, set_profiling) + t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) + +Set the vertex coordinates of a tree in the cmesh. This is currently inefficient, since the vertices are duplicated for each tree. Eventually this function will be replaced by a more efficient one. It is not allowed to call this function after t8_cmesh_commit. The eclass of the tree has to be set before calling this function. +# Arguments +* `cmesh`:\\[in,out\\] The cmesh to be updated. +* `gtree_id`:\\[in\\] The global number of the tree. +* `vertices`:\\[in\\] An array of 3 doubles per tree vertex. +* `num_vertices`:\\[in\\] The number of verticess in *vertices*. Must match the number of corners of the tree. ### Prototype ```c -void t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profiling); +void t8_cmesh_set_tree_vertices (t8_cmesh_t cmesh, const t8_gloidx_t gtree_id, const double *vertices, const int num_vertices); ``` """ -function t8_forest_partition_cmesh(forest, comm, set_profiling) - @ccall libt8.t8_forest_partition_cmesh(forest::t8_forest_t, comm::MPI_Comm, set_profiling::Cint)::Cvoid +function t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) + @ccall libt8.t8_cmesh_set_tree_vertices(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cvoid end """ - t8_forest_get_mpicomm(forest) + t8_scheme_ref(scheme) + +Increase the reference counter of a scheme. +# Arguments +* `scheme`:\\[in,out\\] On input, this scheme must be alive, that is, exist with positive reference count. ### Prototype ```c -sc_MPI_Comm t8_forest_get_mpicomm (const t8_forest_t forest); +void t8_scheme_ref (t8_scheme_c *scheme); ``` """ -function t8_forest_get_mpicomm(forest) - @ccall libt8.t8_forest_get_mpicomm(forest::t8_forest_t)::MPI_Comm +function t8_scheme_ref(scheme) + @ccall libt8.t8_scheme_ref(scheme::Ptr{t8_scheme_c})::Cvoid end """ - t8_forest_get_first_local_tree_id(forest) + t8_scheme_unref(pscheme) -Return the global id of the first local tree of a forest. +Decrease the reference counter of a scheme. If the counter reaches zero, this scheme is destroyed. # Arguments -* `forest`:\\[in\\] The forest. -# Returns -The global id of the first local tree in *forest*. +* `pscheme`:\\[in,out\\] On input, the scheme pointed to must exist with positive reference count. If the reference count reaches zero, the scheme is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the scheme is not modified in other ways. ### Prototype ```c -t8_gloidx_t t8_forest_get_first_local_tree_id (const t8_forest_t forest); +void t8_scheme_unref (t8_scheme_c **pscheme); ``` """ -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_scheme_unref(pscheme) + @ccall libt8.t8_scheme_unref(pscheme::Ptr{Ptr{t8_scheme_c}})::Cvoid end """ - t8_forest_get_num_local_trees(forest) + t8_element_get_element_size(scheme, tree_class) -Return the number of local trees of a given forest. +Return the size of any element of a given class. -# Arguments -* `forest`:\\[in\\] The forest. # Returns -The number of local trees of that forest. +The size of an element of class **ts**. We provide a default implementation of this routine that should suffice for most use cases. ### Prototype ```c -t8_locidx_t t8_forest_get_num_local_trees (const t8_forest_t forest); +size_t t8_element_get_element_size (const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -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_element_get_element_size(scheme, tree_class) + @ccall libt8.t8_element_get_element_size(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Csize_t end """ - t8_forest_get_num_ghost_trees(forest) + t8_element_refines_irregular(scheme, tree_class) -Return the number of ghost trees of a given forest. +Returns true, if there is one element in the tree, that does not refine into 2^dim children. Returns false otherwise. -# Arguments -* `forest`:\\[in\\] The forest. -# Returns -The number of ghost trees of that forest. ### Prototype ```c -t8_locidx_t t8_forest_get_num_ghost_trees (const t8_forest_t forest); +int t8_element_refines_irregular (const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -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_element_refines_irregular(scheme, tree_class) + @ccall libt8.t8_element_refines_irregular(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cint end """ - t8_forest_get_num_global_trees(forest) + t8_element_get_maxlevel(scheme, tree_class) -Return the number of global trees of a given forest. +Return the maximum allowed level for any element of a given class. # Arguments -* `forest`:\\[in\\] The forest. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. # Returns -The number of global trees of that forest. +The maximum allowed level for elements of class **ts**. ### Prototype ```c -t8_gloidx_t t8_forest_get_num_global_trees (const t8_forest_t forest); +int t8_element_get_maxlevel (const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -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_element_get_maxlevel(scheme, tree_class) + @ccall libt8.t8_element_get_maxlevel(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cint end """ - t8_forest_global_tree_id(forest, ltreeid) + t8_element_get_level(scheme, tree_class, element) -Return the global id of a local tree or a ghost tree. +Return the level of an element. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] An id 0 <= *ltreeid* < num\\_local\\_trees + num\\_ghosts specifying a local tree or ghost tree. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -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. - +The level of *element*. ### Prototype ```c -t8_gloidx_t t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid); +int t8_element_get_level (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -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_element_get_level(scheme, tree_class, element) + @ccall libt8.t8_element_get_level(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_tree(forest, ltree_id) + t8_element_copy(scheme, tree_class, source, dest) -Return a pointer to a tree in a forest. +Copy all entries of **source** to **dest**. **dest** must be an existing element. No memory is allocated by this function. + +!!! note + + *source* and *dest* may point to the same element. # Arguments -* `forest`:\\[in\\] The forest. -* `ltree_id`:\\[in\\] The local id of the tree. -# Returns -A pointer to the tree with local id *ltree_id*. *forest* must be committed before calling this function. +* `scheme`:\\[in\\] Implementation of a class scheme. +* `tree_class`:\\[in\\] The eclass of the current tree. +* `source`:\\[in\\] The element whose entries will be copied to **dest**. +* `dest`:\\[in,out\\] This element's entries will be overwritten with the entries of **source**. ### Prototype ```c -t8_tree_t t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id); +void t8_element_copy (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *source, t8_element_t *dest); ``` """ -function t8_forest_get_tree(forest, ltree_id) - @ccall libt8.t8_forest_get_tree(forest::t8_forest_t, ltree_id::t8_locidx_t)::t8_tree_t +function t8_element_copy(scheme, tree_class, source, dest) + @ccall libt8.t8_element_copy(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, source::Ptr{t8_element_t}, dest::Ptr{t8_element_t})::Cvoid end """ - t8_forest_get_tree_vertices(forest, ltreeid) + t8_element_compare(scheme, tree_class, elem1, elem2) -Return a pointer to the vertex coordinates of a tree. +Compare two elements with respect to the scheme. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The id of a local tree. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The first element. +* `elem2`:\\[in\\] The second element. # Returns -If stored, a pointer to the vertex coordinates of *tree*. If no coordinates for this tree are found, NULL. +negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. If elem2 is a copy of elem1 then the elements are equal. ### Prototype ```c -double * t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid); +int t8_element_compare (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2); ``` """ -function t8_forest_get_tree_vertices(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_vertices(forest::t8_forest_t, ltreeid::t8_locidx_t)::Ptr{Cdouble} +function t8_element_compare(scheme, tree_class, elem1, elem2) + @ccall libt8.t8_element_compare(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint end """ - t8_forest_tree_get_leaves(forest, ltree_id) + t8_element_is_equal(scheme, tree_class, elem1, elem2) -Return the array of leaf elements of a local tree in a forest. +Check if two elements are equal. # Arguments -* `forest`:\\[in\\] The forest. -* `ltree_id`:\\[in\\] The local id of a local tree of *forest*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The first element. +* `elem2`:\\[in\\] The second element. # Returns -An array of [`t8_element_t`](@ref) * storing all leaf elements of this tree. +1 if the elements are equal, 0 if they are not equal ### Prototype ```c -t8_element_array_t * t8_forest_tree_get_leaves (const t8_forest_t forest, const t8_locidx_t ltree_id); +int t8_element_is_equal (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2); ``` """ -function t8_forest_tree_get_leaves(forest, ltree_id) - @ccall libt8.t8_forest_tree_get_leaves(forest::t8_forest_t, ltree_id::t8_locidx_t)::Ptr{t8_element_array_t} +function t8_element_is_equal(scheme, tree_class, elem1, elem2) + @ccall libt8.t8_element_is_equal(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cint end """ - t8_forest_get_cmesh(forest) + element_is_refinable(scheme, tree_class, element) -Return a cmesh associated to a forest. +Indicates if an element is refinable. Possible reasons for being not refinable could be that the element has reached its max level. # Arguments -* `forest`:\\[in\\] The forest. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element to check. # Returns -The cmesh associated to the forest. +1 if the element is refinable, 0 otherwise. ### Prototype ```c -t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); +int element_is_refinable (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_get_cmesh(forest) - @ccall libt8.t8_forest_get_cmesh(forest::t8_forest_t)::t8_cmesh_t +function element_is_refinable(scheme, tree_class, element) + @ccall libt8.element_is_refinable(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_element(forest, lelement_id, ltreeid) + t8_element_get_parent(scheme, tree_class, element, parent) -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. +Compute the parent of a given element **element** and store it in **parent**. **parent** needs to be an existing element. No memory is allocated by this function. **element** and **parent** can point to the same element, then the entries of **element** are overwritten by the ones of its parent. # Arguments -* `forest`:\\[in\\] 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. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element whose parent will be computed. +* `parent`:\\[in,out\\] This element's entries will be overwritten by those of **element**'s parent. The storage for this element must exist and match the element class of the parent. ### Prototype ```c -t8_element_t * t8_forest_get_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_locidx_t *ltreeid); +void t8_element_get_parent (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *parent); ``` """ -function t8_forest_get_element(forest, lelement_id, ltreeid) - @ccall libt8.t8_forest_get_element(forest::t8_forest_t, lelement_id::t8_locidx_t, ltreeid::Ptr{t8_locidx_t})::Ptr{t8_element_t} +function t8_element_get_parent(scheme, tree_class, element, parent) + @ccall libt8.t8_element_get_parent(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, parent::Ptr{t8_element_t})::Cvoid end """ - t8_forest_get_element_in_tree(forest, ltreeid, leid_in_tree) - -Return an element of a local tree in a forest. - -!!! note + t8_element_get_num_siblings(scheme, tree_class, element) - If the tree id is know, this function should be preferred over t8_forest_get_element. *forest* must be committed before calling this function. +Compute the number of siblings of an element. That is the number of Children of its parent. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] An id of a local tree in the forest. -* `leid_in_tree`:\\[in\\] The index of an element in the tree. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -A pointer to the element. +The number of siblings of *element*. Note that this number is >= 1, since we count the element itself as a sibling. ### Prototype ```c -const t8_element_t * t8_forest_get_element_in_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t leid_in_tree); +int t8_element_get_num_siblings (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_get_element_in_tree(forest, ltreeid, leid_in_tree) - @ccall libt8.t8_forest_get_element_in_tree(forest::t8_forest_t, ltreeid::t8_locidx_t, leid_in_tree::t8_locidx_t)::Ptr{t8_element_t} +function t8_element_get_num_siblings(scheme, tree_class, element) + @ccall libt8.t8_element_get_num_siblings(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_tree_num_elements(forest, ltreeid) + t8_element_get_sibling(scheme, tree_class, element, sibid, sibling) -Return the number of elements of a tree. +Compute a specific sibling of a given element **element** and store it in **sibling**. **sibling** needs to be an existing element. No memory is allocated by this function. **element** and **sibling** can point to the same element, then the entries of **element** are overwritten by the ones of its i-th sibling. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] A local id of a tree. -# Returns -The number of elements in the local tree *ltreeid*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element whose sibling will be computed. +* `sibid`:\\[in\\] The id of the sibling computed. +* `sibling`:\\[in,out\\] This element's entries will be overwritten by those of **element**'s sibid-th sibling. The storage for this element must exist and match the element class of the sibling. ### Prototype ```c -t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, t8_locidx_t ltreeid); +void t8_element_get_sibling (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int sibid, t8_element_t *sibling); ``` """ -function t8_forest_get_tree_num_elements(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_num_elements(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t +function t8_element_get_sibling(scheme, tree_class, element, sibid, sibling) + @ccall libt8.t8_element_get_sibling(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, sibid::Cint, sibling::Ptr{t8_element_t})::Cvoid end """ - t8_forest_get_tree_element_offset(forest, ltreeid) - -Return the element offset of a local tree, that is the number of elements in all trees with smaller local treeid. - -!!! note + t8_element_get_num_corners(scheme, tree_class, element) - *forest* must be committed before calling this function. +Compute the number of corners of an element. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] A local id of a tree. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -The number of leaf elements on all local tree with id < *ltreeid*. +The number of corners of *element*. ### Prototype ```c -t8_locidx_t t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid); +int t8_element_get_num_corners (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_get_tree_element_offset(forest, ltreeid) - @ccall libt8.t8_forest_get_tree_element_offset(forest::t8_forest_t, ltreeid::t8_locidx_t)::t8_locidx_t +function t8_element_get_num_corners(scheme, tree_class, element) + @ccall libt8.t8_element_get_num_corners(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_tree_element_count(tree) + t8_element_get_num_faces(scheme, tree_class, element) -Return the number of elements of a tree. +Compute the number of faces of an element. # Arguments -* `tree`:\\[in\\] A tree in a forest. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -The number of elements of that tree. +The number of faces of *element*. ### Prototype ```c -t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); +int t8_element_get_num_faces (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_get_tree_element_count(tree) - @ccall libt8.t8_forest_get_tree_element_count(tree::t8_tree_t)::t8_locidx_t +function t8_element_get_num_faces(scheme, tree_class, element) + @ccall libt8.t8_element_get_num_faces(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_tree_class(forest, ltreeid) + t8_element_get_max_num_faces(scheme, tree_class, element) -Return the eclass of a tree in a forest. +Compute the maximum number of faces of a given element and all of its descendants. # Arguments -* `forest`:\\[in\\] The forest. -* `ltreeid`:\\[in\\] The local id of a tree (local or ghost) in *forest*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -The element class of the tree with local id *ltreeid*. +The number of faces of *element*. ### Prototype ```c -t8_eclass_t t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid); +int t8_element_get_max_num_faces (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_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_element_get_max_num_faces(scheme, tree_class, element) + @ccall libt8.t8_element_get_max_num_faces(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_first_local_element_id(forest) + t8_element_get_num_children(scheme, tree_class, element) -Compute the global index of the first local element of a forest. This function is collective. +Compute the number of children of an element when it is refined. # Arguments -* `forest`:\\[in\\] A committed forest, whose first element's index is computed. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. # Returns -The global 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. +The number of children of *element*. ### Prototype ```c -t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); +int t8_element_get_num_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -function t8_forest_get_first_local_element_id(forest) - @ccall libt8.t8_forest_get_first_local_element_id(forest::t8_forest_t)::t8_gloidx_t +function t8_element_get_num_children(scheme, tree_class, element) + @ccall libt8.t8_element_get_num_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_get_scheme(forest) + t8_get_max_num_children(scheme, tree_class) -Return the element scheme associated to a forest. +Return the max number of children of an eclass. # Arguments -* `forest.`:\\[in\\] A committed forest. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. # Returns -The element scheme of the forest. -# See also -[`t8_forest_set_scheme`](@ref) - +The max number of children of *element*. ### Prototype ```c -t8_scheme_cxx_t * t8_forest_get_scheme (const t8_forest_t forest); +int t8_get_max_num_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class); ``` """ -function t8_forest_get_scheme(forest) - @ccall libt8.t8_forest_get_scheme(forest::t8_forest_t)::Ptr{t8_scheme_cxx_t} +function t8_get_max_num_children(scheme, tree_class) + @ccall libt8.t8_get_max_num_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t)::Cint end """ - t8_forest_get_eclass_scheme(forest, eclass) - -Return the eclass scheme of a given element class associated to a forest. + t8_element_get_num_face_children(scheme, tree_class, element, face) -!!! note - - The forest is not required to have trees of class *eclass*. +Compute the number of children of an element's face when the element is refined. # Arguments -* `forest.`:\\[in\\] A committed forest. -* `eclass.`:\\[in\\] An element class. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] A face of *element*. # Returns -The eclass scheme of *eclass* associated to forest. -# See also -[`t8_forest_set_scheme`](@ref) - +The number of children of *face* if *element* is to be refined. ### Prototype ```c -t8_eclass_scheme_c * t8_forest_get_eclass_scheme (t8_forest_t forest, t8_eclass_t eclass); +int t8_element_get_num_face_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); ``` """ -function t8_forest_get_eclass_scheme(forest, eclass) - @ccall libt8.t8_forest_get_eclass_scheme(forest::t8_forest_t, eclass::t8_eclass_t)::Ptr{t8_eclass_scheme_c} +function t8_element_get_num_face_children(scheme, tree_class, element, face) + @ccall libt8.t8_element_get_num_face_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) + t8_element_get_face_corner(scheme, tree_class, element, face, corner) -Return the eclass of the tree in which a face neighbor of a given element lies. +Return the corner number of an element's face corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 Thus for face = 1 the output is: corner=0 : 1, corner=1: 3 + +The order in which the corners must be given is determined by the eclass of *element*: LINE/QUAD/TRIANGLE: No specific order. HEX : In Z-order of the face starting with the lowest corner number. TET : Starting with the lowest corner number counterclockwise as seen from 'outside' of the element. # Arguments -* `forest.`:\\[in\\] A committed forest. -* `ltreeid.`:\\[in\\] The local tree in which the element lies. -* `elem.`:\\[in\\] An element in the tree *ltreeid*. -* `face.`:\\[in\\] A face number of *elem*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] A face index for *element*. +* `corner`:\\[in\\] A corner index for the face 0 <= *corner* < num\\_face\\_corners. # Returns -The local tree id of the tree in which the face neighbor of *elem* across *face* lies. +The corner number of the *corner*-th vertex of *face*. ### Prototype ```c -t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, int face); +int t8_element_get_face_corner (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, const int corner); ``` """ -function t8_forest_element_neighbor_eclass(forest, ltreeid, elem, face) - @ccall libt8.t8_forest_element_neighbor_eclass(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, face::Cint)::t8_eclass_t +function t8_element_get_face_corner(scheme, tree_class, element, face, corner) + @ccall libt8.t8_element_get_face_corner(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, corner::Cint)::Cint end """ - t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_scheme, face, neigh_face) + t8_element_get_corner_face(scheme, tree_class, element, corner, 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. +Compute the face numbers of the faces sharing an element's corner. Example quad: 2 x --- x 3 | | | | face 1 0 x --- x 1 face 2 Thus for corner = 1 the output is: face=0 : 2, face=1: 1 # Arguments -* `elem`:\\[in\\] The element to be considered. -* `neigh`:\\[in,out\\] On input an allocated element of the scheme of the face\\_neighbors eclass. On output, this element's data is filled with the data of the face neighbor. If the neighbor does not exist the data could be modified arbitrarily. -* `neigh_scheme`:\\[in\\] The eclass scheme of *neigh*. -* `face`:\\[in\\] The number of the face along which the neighbor should be constructed. -* `neigh_face`:\\[out\\] The number of the face viewed from perspective of *neigh*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `corner`:\\[in\\] A corner index for the face. +* `face`:\\[in\\] A face index for *corner*. # Returns -The global tree-id of the tree in which *neigh* is in. -1 if there exists no neighbor across that face. +The face number of the *face*-th face at *corner*. ### Prototype ```c -t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, t8_eclass_scheme_c *neigh_scheme, int face, int *neigh_face); +int t8_element_get_corner_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int corner, const int face); ``` """ -function t8_forest_element_face_neighbor(forest, ltreeid, elem, neigh, neigh_scheme, face, neigh_face) - @ccall libt8.t8_forest_element_face_neighbor(forest::t8_forest_t, ltreeid::t8_locidx_t, elem::Ptr{t8_element_t}, neigh::Ptr{t8_element_t}, neigh_scheme::Ptr{t8_eclass_scheme_c}, face::Cint, neigh_face::Ptr{Cint})::t8_gloidx_t +function t8_element_get_corner_face(scheme, tree_class, element, corner, face) + @ccall libt8.t8_element_get_corner_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, corner::Cint, face::Cint)::Cint end """ - t8_forest_iterate(forest) + t8_element_get_child(scheme, tree_class, element, childid, child) +Construct the child element of a given number. + +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] This must be a valid element, bigger than maxlevel. +* `childid`:\\[in\\] The number of the child to construct. +* `child`:\\[in,out\\] The storage for this element must exist. On output, a valid element. It is valid to call this function with element = child. ### Prototype ```c -void t8_forest_iterate (t8_forest_t forest); +void t8_element_get_child (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int childid, t8_element_t *child); ``` """ -function t8_forest_iterate(forest) - @ccall libt8.t8_forest_iterate(forest::t8_forest_t)::Cvoid +function t8_element_get_child(scheme, tree_class, element, childid, child) + @ccall libt8.t8_element_get_child(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, childid::Cint, child::Ptr{t8_element_t})::Cvoid end """ - t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) + t8_element_get_children(scheme, tree_class, element, length, c) -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. +Construct all children of a given element. # 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. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] This must be a valid element, bigger than maxlevel. +* `length`:\\[in\\] The length of the output array *c* must match the number of children. +* `c`:\\[in,out\\] The storage for these *length* elements must exist and match the element class in the children's ordering. On output, all children are valid. It is valid to call this function with element = c[0]. +# See also +t8\\_element\\_num\\_children + ### Prototype ```c -void t8_forest_element_points_inside (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, int num_points, int *is_inside, const double tolerance); +void t8_element_get_children (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int length, t8_element_t *c[]); ``` """ -function t8_forest_element_points_inside(forest, ltreeid, element, points, num_points, is_inside, tolerance) - @ccall libt8.t8_forest_element_points_inside(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, points::Ptr{Cdouble}, num_points::Cint, is_inside::Ptr{Cint}, tolerance::Cdouble)::Cvoid +function t8_element_get_children(scheme, tree_class, element, length, c) + @ccall libt8.t8_element_get_children(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, length::Cint, c::Ptr{Ptr{t8_element_t}})::Cvoid end """ - t8_forest_new_uniform(cmesh, scheme, level, do_face_ghost, comm) + t8_element_get_child_id(scheme, tree_class, element) + +Compute the child id of an element. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] This must be a valid element. +# Returns +The child id of element. ### Prototype ```c -t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, t8_scheme_cxx_t *scheme, const int level, const int do_face_ghost, sc_MPI_Comm comm); +int t8_element_get_child_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element); ``` """ -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_element_get_child_id(scheme, tree_class, element) + @ccall libt8.t8_element_get_child_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cint end """ - t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) - -Build a adapted forest from another forest. - -!!! note + t8_element_get_ancestor_id(scheme, tree_class, element, level) - This is equivalent to calling t8_forest_init, t8_forest_set_adapt, t8_forest_set_ghost, and t8_forest_commit +Compute the ancestor id of an element, that is the child id at a given level. # Arguments -* `forest_from`:\\[in\\] The forest to refine -* `adapt_fn`:\\[in\\] Adapt function to use -* `replace_fn`:\\[in\\] Replace function to use -* `recursive`:\\[in\\] If true adptation is recursive -* `do_face_ghost`:\\[in\\] If true, a layer of ghost elements is created for the forest. -* `user_data`:\\[in\\] If not NULL, the user data pointer of the forest is set to this value. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] This must be a valid element. +* `level`:\\[in\\] A refinement level. Must satisfy *level* < element.level # Returns -A new forest that is adapted from *forest_from*. +The child\\_id of *element* in regard to its *level* ancestor. ### Prototype ```c -t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, int recursive, int do_face_ghost, void *user_data); +int t8_element_get_ancestor_id (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int level); ``` """ -function t8_forest_new_adapt(forest_from, adapt_fn, recursive, do_face_ghost, user_data) - @ccall libt8.t8_forest_new_adapt(forest_from::t8_forest_t, adapt_fn::t8_forest_adapt_t, recursive::Cint, do_face_ghost::Cint, user_data::Ptr{Cvoid})::t8_forest_t +function t8_element_get_ancestor_id(scheme, tree_class, element, level) + @ccall libt8.t8_element_get_ancestor_id(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint)::Cint end """ - t8_forest_ref(forest) + t8_elements_are_family(scheme, tree_class, fam) -Increase the reference counter of a forest. +Query whether a given set of elements is a family or not. # Arguments -* `forest`:\\[in,out\\] On input, this forest must exist with positive reference count. It may be in any state. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `fam`:\\[in\\] An array of as many elements as an element of class **scheme** has children. +# Returns +Zero if **fam** is not a family, nonzero if it is. ### Prototype ```c -void t8_forest_ref (t8_forest_t forest); +int t8_elements_are_family (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t *const *fam); ``` """ -function t8_forest_ref(forest) - @ccall libt8.t8_forest_ref(forest::t8_forest_t)::Cvoid +function t8_elements_are_family(scheme, tree_class, fam) + @ccall libt8.t8_elements_are_family(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, fam::Ptr{Ptr{t8_element_t}})::Cint end """ - t8_forest_unref(pforest) + t8_element_get_nca(scheme, tree_class, elem1, elem2, nca) -Decrease the reference counter of a forest. If the counter reaches zero, this forest is destroyed. In this case, the forest dereferences its cmesh and scheme members. +Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both given elements as descendants. # Arguments -* `pforest`:\\[in,out\\] On input, the forest pointed to must exist with positive reference count. It may be in any state. If the reference count reaches zero, the forest is destroyed and this pointer set to NULL. Otherwise, the pointer is not changed and the forest is not modified in other ways. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The first of the two input elements. +* `elem2`:\\[in\\] The second of the two input elements. +* `nca`:\\[in,out\\] The storage for this element must exist and match the element class of the child. On output the unique nearest common ancestor of **elem1** and **elem2**. ### Prototype ```c -void t8_forest_unref (t8_forest_t *pforest); +void t8_element_get_nca (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca); ``` """ -function t8_forest_unref(pforest) - @ccall libt8.t8_forest_unref(pforest::Ptr{t8_forest_t})::Cvoid +function t8_element_get_nca(scheme, tree_class, elem1, elem2, nca) + @ccall libt8.t8_element_get_nca(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t}, nca::Ptr{t8_element_t})::Cvoid end """ - t8_forest_get_dimension(forest) + t8_element_get_face_shape(scheme, tree_class, element, face) + +Compute the shape of the face of an element. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] A face of *element*. +# Returns +The element shape of the face. I.e. T8\\_ECLASS\\_LINE for quads, T8\\_ECLASS\\_TRIANGLE for tets and depending on the face number either T8\\_ECLASS\\_QUAD or T8\\_ECLASS\\_TRIANGLE for prisms. ### Prototype ```c -int t8_forest_get_dimension (const t8_forest_t forest); +t8_element_shape_t t8_element_get_face_shape (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); ``` """ -function t8_forest_get_dimension(forest) - @ccall libt8.t8_forest_get_dimension(forest::t8_forest_t)::Cint +function t8_element_get_face_shape(scheme, tree_class, element, face) + @ccall libt8.t8_element_get_face_shape(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::t8_element_shape_t end """ - t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) + t8_element_get_children_at_face(scheme, tree_class, element, face, children, num_children, child_indices) + +Given an element and a face of the element, compute all children of the element that touch the face. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] A face of *element*. +* `children`:\\[in,out\\] Allocated elements, in which the children of *element* that share a face with *face* are stored. They will be stored in order of their linear id. +* `num_children`:\\[in\\] The number of elements in *children*. Must match the number of children that touch *face*. t8_scheme::element_get_num_face_children +* `child_indices`:\\[in,out\\] If not NULL, an array of num\\_children integers must be given, on output its i-th entry is the child\\_id of the i-th face\\_child. It is valid to call this function with element = children[0]. ### Prototype ```c -void t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8_element_t *element, int corner_number, double *coordinates); +void t8_element_get_children_at_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, t8_element_t *children[], const int num_children, int *child_indices); ``` """ -function t8_forest_element_coordinate(forest, ltree_id, element, corner_number, coordinates) - @ccall libt8.t8_forest_element_coordinate(forest::t8_forest_t, ltree_id::t8_locidx_t, element::Ptr{t8_element_t}, corner_number::Cint, coordinates::Ptr{Cdouble})::Cvoid +function t8_element_get_children_at_face(scheme, tree_class, element, face, children, num_children, child_indices) + @ccall libt8.t8_element_get_children_at_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, children::Ptr{Ptr{t8_element_t}}, num_children::Cint, child_indices::Ptr{Cint})::Cvoid end """ - t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) + t8_element_face_get_child_face(scheme, tree_class, element, face, face_child) + +Given a face of an element and a child number of a child of that face, return the face number of the child of the element that matches the child face. + +```c++ + x ---- x x x x ---- x + | | | | | | | <-- f + | | | x | x--x + | | | | | + x ---- x x x ---- x + element face face_child Returns the face number f +``` +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] Then number of the face. +* `face_child`:\\[in\\] A number 0 <= *face_child* < num\\_face\\_children, specifying a child of *element* that shares a face with *face*. These children are counted in linear order. This coincides with the order of children from a call to t8_scheme::element_get_children_at_face. +# Returns +The face number of the face of a child of *element* that coincides with *face_child*. ### Prototype ```c -void t8_forest_element_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); +int t8_element_face_get_child_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face, const int face_child); ``` """ -function t8_forest_element_from_ref_coords_ext(forest, ltreeid, element, ref_coords, num_coords, coords_out, stretch_factors) - @ccall libt8.t8_forest_element_from_ref_coords_ext(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble}, stretch_factors::Ptr{Cdouble})::Cvoid +function t8_element_face_get_child_face(scheme, tree_class, element, face, face_child) + @ccall libt8.t8_element_face_get_child_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint, face_child::Cint)::Cint end """ - t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) + t8_element_face_get_parent_face(scheme, tree_class, element, face) + +Given a face of an element return the face number of the parent of the element that matches the element's face. Or return -1 if no face of the parent matches the face. + +!!! note + + For the root element this function always returns *face*. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] Then number of the face. +# Returns +If *face* of *element* is also a face of *element*'s parent, the face number of this face. Otherwise -1. ### Prototype ```c -void t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out); +int t8_element_face_get_parent_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); ``` """ -function t8_forest_element_from_ref_coords(forest, ltreeid, element, ref_coords, num_coords, coords_out) - @ccall libt8.t8_forest_element_from_ref_coords(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, coords_out::Ptr{Cdouble})::Cvoid +function t8_element_face_get_parent_face(scheme, tree_class, element, face) + @ccall libt8.t8_element_face_get_parent_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_forest_element_centroid(forest, ltreeid, element, coordinates) + t8_element_get_tree_face(scheme, tree_class, element, face) + +Given an element and a face of this element. If the face lies on the tree boundary, return the face number of the tree face. If not the return value is arbitrary. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element. +* `face`:\\[in\\] The index of a face of *element*. +# Returns +The index of the tree face that *face* is a subface of, if *face* is on a tree boundary. Any arbitrary integer if *is* not at a tree boundary. ### Prototype ```c -void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); +int t8_element_get_tree_face (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int face); ``` """ -function t8_forest_element_centroid(forest, ltreeid, element, coordinates) - @ccall libt8.t8_forest_element_centroid(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, coordinates::Ptr{Cdouble})::Cvoid +function t8_element_get_tree_face(scheme, tree_class, element, face) + @ccall libt8.t8_element_get_tree_face(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, face::Cint)::Cint end """ - t8_forest_element_diam(forest, ltreeid, element) + t8_element_transform_face(scheme, tree_class, elem1, elem2, orientation, sign, is_smaller_face) + +Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the trees and given the orientation of the tree connection, construct the face element of the respective tree neighbor that logically coincides with e but lies in the coordinate system of the neighbor tree. + +!!! note + + *elem1* and *elem2* may point to the same element. + +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The face element. +* `elem2`:\\[in,out\\] On return the face element *elem1* with respect to the coordinate system of the other tree. +* `orientation`:\\[in\\] The orientation of the tree-tree connection. +* `sign`:\\[in\\] Depending on the topological orientation of the two tree faces, either 0 (both faces have opposite orientation) or 1 (both faces have the same top. orientation). t8_eclass_face_orientation +* `is_smaller_face`:\\[in\\] Flag to declare whether *elem1* belongs to the smaller face. A face f of tree T is smaller than f' of T' if either the eclass of T is smaller or if the classes are equal and fghost\\_trees array of the tree. Otherwise a negative number. *forest* must be committed before calling this function. -# See also -https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element whose descendant is computed. +* `desc`:\\[out\\] The first element in a uniform refinement of *element* at level *level*. +* `level`:\\[in\\] The uniform refinement level at which the descendant is computed. *level* must be greater or equal to the level of *element*. ### Prototype ```c -t8_locidx_t t8_forest_ghost_get_ghost_treeid (t8_forest_t forest, t8_gloidx_t gtreeid); +void t8_element_get_first_descendant (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *desc, const int level); ``` """ -function t8_forest_ghost_get_ghost_treeid(forest, gtreeid) - @ccall libt8.t8_forest_ghost_get_ghost_treeid(forest::t8_forest_t, gtreeid::t8_gloidx_t)::t8_locidx_t +function t8_element_get_first_descendant(scheme, tree_class, element, desc, level) + @ccall libt8.t8_element_get_first_descendant(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, desc::Ptr{t8_element_t}, level::Cint)::Cvoid end """ - t8_forest_ghost_get_tree_class(forest, lghost_tree) + t8_element_get_last_descendant(scheme, tree_class, element, desc, level) + +Compute the last descendant of a given element. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element whose descendant is computed. +* `desc`:\\[out\\] The last element in a uniform refinement of *element* of the maximum possible level. +* `level`:\\[in\\] The uniform refinement level at which the descendant is computed. *level* must be greater or equal to the level of *element*. ### Prototype ```c -t8_eclass_t t8_forest_ghost_get_tree_class (const t8_forest_t forest, const t8_locidx_t lghost_tree); +void t8_element_get_last_descendant (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, t8_element_t *desc, const int level); ``` """ -function t8_forest_ghost_get_tree_class(forest, lghost_tree) - @ccall libt8.t8_forest_ghost_get_tree_class(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_eclass_t +function t8_element_get_last_descendant(scheme, tree_class, element, desc, level) + @ccall libt8.t8_element_get_last_descendant(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, desc::Ptr{t8_element_t}, level::Cint)::Cvoid end """ - t8_forest_ghost_get_global_treeid(forest, lghost_tree) + t8_element_get_successor(scheme, tree_class, elem1, elem2) -Given a local ghost tree compute the global tree id of it. +Construct the successor in a uniform refinement of a given element. # Arguments -* `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. - +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `elem1`:\\[in\\] The element whose successor should be constructed. +* `elem2`:\\[in,out\\] The element whose entries will be set. ### Prototype ```c -t8_gloidx_t t8_forest_ghost_get_global_treeid (const t8_forest_t forest, const t8_locidx_t lghost_tree); +void t8_element_get_successor (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *elem1, t8_element_t *elem2); ``` """ -function t8_forest_ghost_get_global_treeid(forest, lghost_tree) - @ccall libt8.t8_forest_ghost_get_global_treeid(forest::t8_forest_t, lghost_tree::t8_locidx_t)::t8_gloidx_t +function t8_element_get_successor(scheme, tree_class, elem1, elem2) + @ccall libt8.t8_element_get_successor(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elem1::Ptr{t8_element_t}, elem2::Ptr{t8_element_t})::Cvoid end """ - t8_forest_ghost_get_element(forest, lghost_tree, lelement) + t8_element_get_vertex_reference_coords(scheme, tree_class, element, vertex, coords) + +Compute the coordinates of a given element vertex inside a reference tree that is embedded into [0,1]^d (d = dimension). + +!!! warning + + coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere all coords might be used. +# Arguments +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element to be considered. +* `vertex`:\\[in\\] The id of the vertex whose coordinates shall be computed. +* `coords`:\\[out\\] An array of at least as many doubles as the element's dimension whose entries will be filled with the coordinates of *vertex*. ### Prototype ```c -t8_element_t * t8_forest_ghost_get_element (t8_forest_t forest, t8_locidx_t lghost_tree, t8_locidx_t lelement); +void t8_element_get_vertex_reference_coords (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int vertex, double coords[]); ``` """ -function t8_forest_ghost_get_element(forest, lghost_tree, lelement) - @ccall libt8.t8_forest_ghost_get_element(forest::t8_forest_t, lghost_tree::t8_locidx_t, lelement::t8_locidx_t)::Ptr{t8_element_t} +function t8_element_get_vertex_reference_coords(scheme, tree_class, element, vertex, coords) + @ccall libt8.t8_element_get_vertex_reference_coords(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, vertex::Cint, coords::Ptr{Cdouble})::Cvoid end """ - t8_forest_ghost_get_remotes(forest, num_remotes) + t8_element_count_leaves(scheme, tree_class, element, level) -Return the array of remote ranks. +Count how many leaf descendants of a given uniform level an element would produce. + +Example: If *element* is a line element that refines into 2 line elements on each level, then the return value is max(0, 2^{*level* - level(*t*)}). Thus, if *element*'s level is 0, and *level* = 3, the return value is 2^3 = 8. # Arguments -* `forest`:\\[in\\] A forest with constructed ghost layer. -* `num_remotes`:\\[in,out\\] On output the number of remote ranks is stored here. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in\\] The element to be checked. +* `level`:\\[in\\] A refinement level. # Returns -The array of remote ranks in ascending order. +Suppose *element* is uniformly refined up to level *level*. The return value is the resulting number of elements (of the given level). If *level* < [`t8_element_get_level`](@ref)(element), the return value should be 0. ### Prototype ```c -int * t8_forest_ghost_get_remotes (t8_forest_t forest, int *num_remotes); +t8_gloidx_t t8_element_count_leaves (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const t8_element_t *element, const int level); ``` """ -function t8_forest_ghost_get_remotes(forest, num_remotes) - @ccall libt8.t8_forest_ghost_get_remotes(forest::t8_forest_t, num_remotes::Ptr{Cint})::Ptr{Cint} +function t8_element_count_leaves(scheme, tree_class, element, level) + @ccall libt8.t8_element_count_leaves(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t}, level::Cint)::t8_gloidx_t end """ - t8_forest_ghost_remote_first_tree(forest, remote) + t8_element_count_leaves_from_root(scheme, tree_class, level) -Return the first local ghost tree of a remote rank. +Count how many leaf descendants of a given uniform level the root element will produce. + +This is a convenience function, and can be implemented via t8_element_count_leaves. # Arguments -* `forest`:\\[in\\] A forest with constructed ghost layer. -* `remote`:\\[in\\] A remote rank of the ghost layer in *forest*. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `level`:\\[in\\] A refinement level. # Returns -The ghost tree id of the first ghost tree that stores ghost elements of *remote*. +The value of t8_element_count_leaves if the input element is the root (level 0) element. ### Prototype ```c -t8_locidx_t t8_forest_ghost_remote_first_tree (t8_forest_t forest, int remote); +t8_gloidx_t t8_element_count_leaves_from_root (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int level); ``` """ -function t8_forest_ghost_remote_first_tree(forest, remote) - @ccall libt8.t8_forest_ghost_remote_first_tree(forest::t8_forest_t, remote::Cint)::t8_locidx_t +function t8_element_count_leaves_from_root(scheme, tree_class, level) + @ccall libt8.t8_element_count_leaves_from_root(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, level::Cint)::t8_gloidx_t end """ - t8_forest_ghost_remote_first_elem(forest, remote) + t8_element_new(scheme, tree_class, length, elems) -Return the local index of the first ghost element that belongs to a given remote rank. +Allocate memory for an array of elements of a given class and initialize them. + +!!! note + + Not every element that is created in t8code will be created by a call to this function. However, if an element is not created using t8_element_new, then it is guaranteed that t8_scheme::element_init is called on it. + +!!! note + + In debugging mode, an element that was created with t8_element_new must pass t8_element_is_valid. + +!!! note + + If an element was created by t8_element_new then t8_scheme::element_init may not be called for it. Thus, t8_element_new should initialize an element in the same way as a call to t8_scheme::element_init would. # Arguments -* `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* +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `length`:\\[in\\] The number of elements to be allocated. +* `elems`:\\[in,out\\] On input an array of **length** many unallocated element pointers. On output all these pointers will point to an allocated and initialized element. +# See also +[`t8_element_init`](@ref), element\\_is\\_valid + ### Prototype ```c -t8_locidx_t t8_forest_ghost_remote_first_elem (t8_forest_t forest, int remote); +void t8_element_new (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t **elems); ``` """ -function t8_forest_ghost_remote_first_elem(forest, remote) - @ccall libt8.t8_forest_ghost_remote_first_elem(forest::t8_forest_t, remote::Cint)::t8_locidx_t +function t8_element_new(scheme, tree_class, length, elems) + @ccall libt8.t8_element_new(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elems::Ptr{Ptr{t8_element_t}})::Cvoid end """ - t8_forest_ghost_ref(ghost) + t8_element_init(scheme, tree_class, length, elem) -Increase the reference count of a ghost structure. +Initialize an array of allocated elements. + +!!! note + + In debugging mode, an element that was passed to t8_element_init must pass t8_element_is_valid. + +!!! note + + If an element was created by t8_element_new then t8_element_init may not be called for it. Thus, t8_element_init should initialize an element in the same way as a call to t8_element_new would. + +!!! note + + Every call to # Arguments -* `ghost`:\\[in,out\\] On input, this ghost structure must exist with positive reference count. +* `scheme`:\\[in\\] The scheme to use. +* `tree_class`:\\[in\\] The eclass of the current tree. +* `length`:\\[in\\] The number of elements to be initialized. +* `elem`:\\[in,out\\] On input an array of *length* many allocated elements. +# See also +[`t8_element_init`](@ref) must be matched by a call to, t8\\_element\\_deinit, t8\\_element\\_deinit, [`t8_element_new`](@ref), t8\\_element\\_is\\_valid + ### Prototype ```c -void t8_forest_ghost_ref (t8_forest_ghost_t ghost); +void t8_element_init (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t *elem); ``` """ -function t8_forest_ghost_ref(ghost) - @ccall libt8.t8_forest_ghost_ref(ghost::t8_forest_ghost_t)::Cvoid +function t8_element_init(scheme, tree_class, length, elem) + @ccall libt8.t8_element_init(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elem::Ptr{t8_element_t})::Cvoid end """ - t8_forest_ghost_unref(pghost) + t8_element_destroy(scheme, tree_class, length, elems) -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. +Deallocate an array of elements. # Arguments -* `pghost`:\\[in,out\\] On input, the ghost structure pointed to must exist with positive reference count. If the reference count reaches zero, the ghost structure is destroyed and this pointer is set to NULL. Otherwise, the pointer is not changed. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `length`:\\[in\\] The number of elements in the array. +* `elems`:\\[in,out\\] On input an array of **length** many allocated element pointers. On output all these pointers will be freed. **element** itself will not be freed by this function. ### Prototype ```c -void t8_forest_ghost_unref (t8_forest_ghost_t *pghost); +void t8_element_destroy (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const int length, t8_element_t **elems); ``` """ -function t8_forest_ghost_unref(pghost) - @ccall libt8.t8_forest_ghost_unref(pghost::Ptr{t8_forest_ghost_t})::Cvoid +function t8_element_destroy(scheme, tree_class, length, elems) + @ccall libt8.t8_element_destroy(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, length::Cint, elems::Ptr{Ptr{t8_element_t}})::Cvoid end """ - t8_forest_ghost_destroy(pghost) + t8_element_set_to_root(scheme, tree_class, element) -Verify that a ghost structure has only one reference left and destroy it. This function is preferred over t8_ghost_unref when it is known that the last reference is to be deleted. +Fills an element with the root element. # Arguments -* `pghost`:\\[in,out\\] This ghost structure must have a reference count of one. It can be in any state (committed or not). Then it effectively calls t8_forest_ghost_unref. +* `scheme`:\\[in\\] The scheme of the forest. +* `tree_class`:\\[in\\] The eclass of tree the elements are part of. +* `element`:\\[in,out\\] The element to be filled with root. ### Prototype ```c -void t8_forest_ghost_destroy (t8_forest_ghost_t *pghost); +void t8_element_set_to_root (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t *element); ``` """ -function t8_forest_ghost_destroy(pghost) - @ccall libt8.t8_forest_ghost_destroy(pghost::Ptr{t8_forest_ghost_t})::Cvoid +function t8_element_set_to_root(scheme, tree_class, element) + @ccall libt8.t8_element_set_to_root(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, element::Ptr{t8_element_t})::Cvoid end """ - t8_forest_ghost_create(forest) - -Create one layer of ghost elements for a forest. - -# Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. -# See also -[`t8_forest_set_ghost`](@ref) + t8_element_MPI_Pack(scheme, tree_class, elements, count, send_buffer, buffer_size, position, comm) ### Prototype ```c -void t8_forest_ghost_create (t8_forest_t forest); +void t8_element_MPI_Pack (const t8_scheme_c *scheme, const t8_eclass_t tree_class, t8_element_t **const elements, const unsigned int count, void *send_buffer, const int buffer_size, int *position, sc_MPI_Comm comm); ``` """ -function t8_forest_ghost_create(forest) - @ccall libt8.t8_forest_ghost_create(forest::t8_forest_t)::Cvoid +function t8_element_MPI_Pack(scheme, tree_class, elements, count, send_buffer, buffer_size, position, comm) + @ccall libt8.t8_element_MPI_Pack(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, elements::Ptr{Ptr{t8_element_t}}, count::Cuint, send_buffer::Ptr{Cvoid}, buffer_size::Cint, position::Ptr{Cint}, comm::MPI_Comm)::Cvoid end """ - t8_forest_ghost_create_balanced_only(forest) - -Create one layer of ghost elements for a forest. This version only works with balanced forests and is the original algorithm from p4est: Scalable Algorithms For Parallel Adaptive Mesh Refinement On Forests of Octrees - -!!! note - - The user should prefer t8_forest_ghost_create even for balanced forests. + t8_element_MPI_Pack_size(scheme, tree_class, count, comm, pack_size) -# Arguments -* `forest`:\\[in,out\\] The balanced forest/ *forest* must be committed before calling this function. ### Prototype ```c -void t8_forest_ghost_create_balanced_only (t8_forest_t forest); +void t8_element_MPI_Pack_size (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const unsigned int count, sc_MPI_Comm comm, int *pack_size); ``` """ -function t8_forest_ghost_create_balanced_only(forest) - @ccall libt8.t8_forest_ghost_create_balanced_only(forest::t8_forest_t)::Cvoid +function t8_element_MPI_Pack_size(scheme, tree_class, count, comm, pack_size) + @ccall libt8.t8_element_MPI_Pack_size(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, count::Cuint, comm::MPI_Comm, pack_size::Ptr{Cint})::Cvoid end """ - t8_forest_ghost_create_topdown(forest) + t8_element_MPI_Unpack(scheme, tree_class, recvbuf, buffer_size, position, elements, count, comm) ### Prototype ```c -void t8_forest_ghost_create_topdown (t8_forest_t forest); +void t8_element_MPI_Unpack (const t8_scheme_c *scheme, const t8_eclass_t tree_class, void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm); ``` """ -function t8_forest_ghost_create_topdown(forest) - @ccall libt8.t8_forest_ghost_create_topdown(forest::t8_forest_t)::Cvoid +function t8_element_MPI_Unpack(scheme, tree_class, recvbuf, buffer_size, position, elements, count, comm) + @ccall libt8.t8_element_MPI_Unpack(scheme::Ptr{t8_scheme_c}, tree_class::t8_eclass_t, recvbuf::Ptr{Cvoid}, buffer_size::Cint, position::Ptr{Cint}, elements::Ptr{Ptr{t8_element_t}}, count::Cuint, comm::MPI_Comm)::Cvoid end """ - t8_forest_save(forest) + vtk_file_type +Enumerator for all types of files readable by t8code. +""" +@cenum vtk_file_type::Int32 begin + VTK_FILE_ERROR = -1 + VTK_SERIAL_FILE = 8 + VTK_UNSTRUCTURED_FILE = 8 + VTK_POLYDATA_FILE = 9 + VTK_PARALLEL_FILE = 16 + VTK_PARALLEL_UNSTRUCTURED_FILE = 16 + VTK_PARALLEL_POLYDATA_FILE = 17 + VTK_NUM_TYPES = 5 +end + +"""Enumerator for all types of files readable by t8code.""" +const vtk_file_type_t = vtk_file_type + +""" + vtk_read_success + +Enumerator for the success of reading a vtk file. This is used to indicate whether the reading was successful or not. +""" +@cenum vtk_read_success::UInt32 begin + read_failure = 0 + read_success = 1 +end + +"""Enumerator for the success of reading a vtk file. This is used to indicate whether the reading was successful or not.""" +const vtk_read_success_t = vtk_read_success + +""" + 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 "--enable-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 -void t8_forest_save (t8_forest_t forest); +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_save(forest) - @ccall libt8.t8_forest_save(forest::t8_forest_t)::Cvoid +function t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) + @ccall libt8.t8_forest_vtk_write_file_via_API(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, curved_flag::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_forest_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) + t8_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 "--enable-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_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, const int write_curved, int do_not_use_API, const int num_data, t8_vtk_data_field_t *data); +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_write_vtk_ext(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, do_not_use_API, num_data, data) - @ccall libt8.t8_forest_write_vtk_ext(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, write_curved::Cint, do_not_use_API::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) + @ccall libt8.t8_forest_vtk_write_file(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint end """ - t8_forest_write_vtk(forest, fileprefix) + t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) ### Prototype ```c -int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix); +int t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm); ``` """ -function t8_forest_write_vtk(forest, fileprefix) - @ccall libt8.t8_forest_write_vtk(forest::t8_forest_t, fileprefix::Cstring)::Cint +function t8_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 -# typedef int ( * t8_forest_iterate_face_fn ) ( t8_forest_t forest , t8_locidx_t ltreeid , const t8_element_t * element , int face , void * user_data , t8_locidx_t tree_leaf_index ) -const t8_forest_iterate_face_fn = Ptr{Cvoid} - -# typedef int ( * t8_forest_search_fn ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index ) -""" -A call-back function used by t8_forest_search describing a search-criterion. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. - -# 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} + t8_cmesh_vtk_write_file(cmesh, fileprefix) -# 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*. +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 "--enable-vtk" and t8_cmesh_vtk_write_file_via_API is not available. # 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) - +* `cmesh`:\\[in\\] The cmesh +* `fileprefix`:\\[in\\] The prefix of the output files +# Returns +int ### Prototype ```c -void t8_forest_split_array (const t8_element_t *element, t8_element_array_t *leaf_elements, size_t *offsets); +int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); ``` """ -function t8_forest_split_array(element, leaf_elements, offsets) - @ccall libt8.t8_forest_split_array(element::Ptr{t8_element_t}, leaf_elements::Ptr{t8_element_array_t}, offsets::Ptr{Csize_t})::Cvoid +function t8_cmesh_vtk_write_file(cmesh, fileprefix) + @ccall libt8.t8_cmesh_vtk_write_file(cmesh::t8_cmesh_t, fileprefix::Cstring)::Cint end """ - t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, user_data, tree_lindex_of_first_leaf, callback) + t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) ### Prototype ```c -void t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, t8_element_array_t *leaf_elements, void *user_data, t8_locidx_t tree_lindex_of_first_leaf, t8_forest_iterate_face_fn callback); +t8_cmesh_t t8_cmesh_from_msh_file (const char *fileprefix, int partition, sc_MPI_Comm comm, int dim, int master, int use_cad_geometry); ``` """ -function t8_forest_iterate_faces(forest, ltreeid, element, face, leaf_elements, user_data, tree_lindex_of_first_leaf, callback) - @ccall libt8.t8_forest_iterate_faces(forest::t8_forest_t, ltreeid::t8_locidx_t, element::Ptr{t8_element_t}, face::Cint, leaf_elements::Ptr{t8_element_array_t}, user_data::Ptr{Cvoid}, tree_lindex_of_first_leaf::t8_locidx_t, callback::t8_forest_iterate_face_fn)::Cvoid +function t8_cmesh_from_msh_file(fileprefix, partition, comm, dim, master, use_cad_geometry) + @ccall libt8.t8_cmesh_from_msh_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, dim::Cint, master::Cint, use_cad_geometry::Cint)::t8_cmesh_t end -""" - t8_forest_search(forest, search_fn, query_fn, queries) - -### Prototype -```c -void t8_forest_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries); -``` -""" -function t8_forest_search(forest, search_fn, query_fn, queries) - @ccall libt8.t8_forest_search(forest::t8_forest_t, search_fn::t8_forest_search_fn, query_fn::t8_forest_query_fn, queries::Ptr{sc_array_t})::Cvoid +struct sc_flopinfo + seconds::Cdouble + cwtime::Cdouble + crtime::Cfloat + cptime::Cfloat + cflpops::Clonglong + iwtime::Cdouble + irtime::Cfloat + iptime::Cfloat + iflpops::Clonglong + mflops::Cfloat + use_papi::Cint end -""" - t8_forest_iterate_replace(forest_new, forest_old, replace_fn) - -Given two forest where the elements in one forest are either direct children or parents of the elements in the other forest compare the two forests and for each refined element or coarsened family in the old one, call a callback function providing the local indices of the old and new elements. +const sc_flopinfo_t = sc_flopinfo -!!! note +""" + sc_flops_snap(fi, snapshot) - To pass a user pointer to *replace_fn* use t8_forest_set_user_data and t8_forest_get_user_data. +Call [`sc_flops_count`](@ref) (fi) and copies fi into snapshot. # Arguments -* `forest_new`:\\[in\\] A forest, each element is a parent or child of an element in *forest_old*. -* `forest_old`:\\[in\\] The initial forest. -* `replace_fn`:\\[in\\] A replace callback function. +* `fi`:\\[in,out\\] Members will be updated. +* `snapshot`:\\[out\\] On output is a copy of fi. ### Prototype ```c -void t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_forest_replace_t replace_fn); +void sc_flops_snap (sc_flopinfo_t * fi, sc_flopinfo_t * snapshot); ``` """ -function t8_forest_iterate_replace(forest_new, forest_old, replace_fn) - @ccall libt8.t8_forest_iterate_replace(forest_new::t8_forest_t, forest_old::t8_forest_t, replace_fn::t8_forest_replace_t)::Cvoid +function sc_flops_snap(fi, snapshot) + @ccall libt8.sc_flops_snap(fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t})::Cvoid end """ - t8_forest_partition(forest) + sc_flops_shot(fi, snapshot) + +Call [`sc_flops_count`](@ref) (fi) and override snapshot interval timings with the differences since the previous call to [`sc_flops_snap`](@ref). The interval mflop rate is computed by iflpops / 1e6 / irtime. The cumulative timings in snapshot are copied form fi. +# Arguments +* `fi`:\\[in,out\\] Members will be updated. +* `snapshot`:\\[in,out\\] Interval timings measured since [`sc_flops_snap`](@ref). ### Prototype ```c -void t8_forest_partition (t8_forest_t forest); +void sc_flops_shot (sc_flopinfo_t * fi, sc_flopinfo_t * snapshot); ``` """ -function t8_forest_partition(forest) - @ccall libt8.t8_forest_partition(forest::t8_forest_t)::Cvoid +function sc_flops_shot(fi, snapshot) + @ccall libt8.sc_flops_shot(fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t})::Cvoid end """ - t8_forest_partition_create_offsets(forest) + sc_flops_papi(rtime, ptime, flpops, mflops) -Create the element\\_offset array of a partitioned forest. +Calls PAPI\\_flops. Aborts on PAPI error. The first call sets up the performance counters. Subsequent calls return cumulative real and process times, cumulative floating point operations and the flop rate since the last call. This is a compatibility wrapper: users should only need to use the [`sc_flopinfo_t`](@ref) interface functions below. -# Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. ### Prototype ```c -void t8_forest_partition_create_offsets (t8_forest_t forest); +void sc_flops_papi (float *rtime, float *ptime, long long *flpops, float *mflops); ``` """ -function t8_forest_partition_create_offsets(forest) - @ccall libt8.t8_forest_partition_create_offsets(forest::t8_forest_t)::Cvoid +function sc_flops_papi(rtime, ptime, flpops, mflops) + @ccall libt8.sc_flops_papi(rtime::Ptr{Cfloat}, ptime::Ptr{Cfloat}, flpops::Ptr{Clonglong}, mflops::Ptr{Cfloat})::Cvoid end """ - t8_forest_partition_next_nonempty_rank(forest, rank) + sc_flops_start(fi) -If t8_forest_partition_create_offsets was already called, compute for a given rank the next greater rank that is not empty. +Prepare [`sc_flopinfo_t`](@ref) structure and start flop counters. Must only be called once during the program run. This function calls [`sc_flops_papi`](@ref). # Arguments -* `forest`:\\[in\\] The forest. -* `rank`:\\[in\\] An MPI rank. -# Returns -A rank q > *rank* such that the forest has elements on *q*. If such a *q* does not exist, returns mpisize. +* `fi`:\\[out\\] Members will be initialized. ### Prototype ```c -int t8_forest_partition_next_nonempty_rank (t8_forest_t forest, int rank); +void sc_flops_start (sc_flopinfo_t * fi); ``` """ -function t8_forest_partition_next_nonempty_rank(forest, rank) - @ccall libt8.t8_forest_partition_next_nonempty_rank(forest::t8_forest_t, rank::Cint)::Cint +function sc_flops_start(fi) + @ccall libt8.sc_flops_start(fi::Ptr{sc_flopinfo_t})::Cvoid end """ - t8_forest_partition_create_first_desc(forest) + sc_flops_start_nopapi(fi) -Create the array of global\\_first\\_descendant ids of a partitioned forest. +Prepare [`sc_flopinfo_t`](@ref) structure and ignore the flop counters. This [`sc_flopinfo_t`](@ref) does not call PAPI\\_flops() in this function or in [`sc_flops_count`](@ref)(). # Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +* `fi`:\\[out\\] Members will be initialized. ### Prototype ```c -void t8_forest_partition_create_first_desc (t8_forest_t forest); +void sc_flops_start_nopapi (sc_flopinfo_t * fi); ``` """ -function t8_forest_partition_create_first_desc(forest) - @ccall libt8.t8_forest_partition_create_first_desc(forest::t8_forest_t)::Cvoid +function sc_flops_start_nopapi(fi) + @ccall libt8.sc_flops_start_nopapi(fi::Ptr{sc_flopinfo_t})::Cvoid end """ - t8_forest_partition_create_tree_offsets(forest) + sc_flops_count(fi) -Create the array tree offsets of a partitioned forest. This arrays stores at position p the global id of the first tree of this process. Or if this tree is shared, it stores -(global\\_id) - 1. +Update [`sc_flopinfo_t`](@ref) structure with current measurement. Must only be called after [`sc_flops_start`](@ref). Can be called any number of times. This function calls [`sc_flops_papi`](@ref). # Arguments -* `forest`:\\[in,out\\] The forest. *forest* must be committed before calling this function. +* `fi`:\\[in,out\\] Members will be updated. ### Prototype ```c -void t8_forest_partition_create_tree_offsets (t8_forest_t forest); +void sc_flops_count (sc_flopinfo_t * fi); ``` """ -function t8_forest_partition_create_tree_offsets(forest) - @ccall libt8.t8_forest_partition_create_tree_offsets(forest::t8_forest_t)::Cvoid +function sc_flops_count(fi) + @ccall libt8.sc_flops_count(fi::Ptr{sc_flopinfo_t})::Cvoid end +# automatic type deduction for variadic arguments may not be what you want, please use with caution +@generated function sc_flops_shotv(fi, va_list...) + :(@ccall(libt8.sc_flops_shotv(fi::Ptr{sc_flopinfo_t}; $(to_c_type_pairs(va_list)...))::Cvoid)) + end + +mutable struct sc_options end + +"""The options data structure is opaque.""" +const sc_options_t = sc_options + +# typedef int ( * sc_options_callback_t ) ( sc_options_t * opt , const char * opt_arg , void * data ) """ - t8_forest_partition_data(forest_from, forest_to, data_in, data_out) +This callback can be invoked with sc_options_parse. -Re-Partition an array accordingly to a partitioned forest. +# Arguments +* `opt`:\\[in\\] Valid options data structure. This is passed as a matter of principle. +* `opt_arg`:\\[in\\] The option argument or NULL if there is none. This variable is internal. Do not store pointer. +* `data`:\\[in\\] User-defined data passed to [`sc_options_add_callback`](@ref). +# Returns +Return 0 if successful, -1 to indicate a parse error. +""" +const sc_options_callback_t = Ptr{Cvoid} -!!! note +""" + sc_options_new(program_path) - *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*. +Create an empty options structure. # 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*. +* `program_path`:\\[in\\] Name or path name of the program to display. Usually argv[0] is fine. +# Returns +A valid and empty options structure. ### 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); +sc_options_t *sc_options_new (const char *program_path); ``` """ -function t8_forest_partition_data(forest_from, forest_to, data_in, data_out) - @ccall libt8.t8_forest_partition_data(forest_from::t8_forest_t, forest_to::t8_forest_t, data_in::Ptr{sc_array_t}, data_out::Ptr{sc_array_t})::Cvoid +function sc_options_new(program_path) + @ccall libt8.sc_options_new(program_path::Cstring)::Ptr{sc_options_t} end """ - t8_forest_partition_test_boundary_element(forest) + sc_options_destroy_deep(opt) -Test if the last descendant of the last element of current rank has a smaller linear id than the stored first descendant of rank+1. If this is not the case, elements overlap. +Destroy the options structure and all allocated structures contained. The keyvalue structure passed into sc\\_keyvalue\\_add is destroyed. -!!! note +!!! compat "Deprecated" - *forest* must be committed before calling this function. + This function is kept for backwards compatibility. It is best to destroy any key-value container outside of the lifetime of the options object. # Arguments -* `forest`:\\[in\\] The forest. +* `opt`:\\[in,out\\] This options structure is deallocated, including all key-value containers referenced. ### Prototype ```c -void t8_forest_partition_test_boundary_element (const t8_forest_t forest); +void sc_options_destroy_deep (sc_options_t * opt); ``` """ -function t8_forest_partition_test_boundary_element(forest) - @ccall libt8.t8_forest_partition_test_boundary_element(forest::t8_forest_t)::Cvoid +function sc_options_destroy_deep(opt) + @ccall libt8.sc_options_destroy_deep(opt::Ptr{sc_options_t})::Cvoid end """ - t8_forest_set_profiling(forest, set_profiling) + sc_options_destroy(opt) +Destroy the options structure. Whatever has been passed into sc\\_keyvalue\\_add is left alone. + +# Arguments +* `opt`:\\[in,out\\] This options structure is deallocated. ### Prototype ```c -void t8_forest_set_profiling (t8_forest_t forest, int set_profiling); +void sc_options_destroy (sc_options_t * opt); ``` """ -function t8_forest_set_profiling(forest, set_profiling) - @ccall libt8.t8_forest_set_profiling(forest::t8_forest_t, set_profiling::Cint)::Cvoid +function sc_options_destroy(opt) + @ccall libt8.sc_options_destroy(opt::Ptr{sc_options_t})::Cvoid end """ - t8_forest_compute_profile(forest) + sc_options_set_spacing(opt, space_type, space_help) + +Set the spacing for sc_options_print_summary. There are two values to be set: the spacing from the beginning of the printed line to the type of the option variable, and from the beginning of the printed line to the help string. +# Arguments +* `opt`:\\[in,out\\] Valid options structure. +* `space_type`:\\[in\\] Number of spaces to the type display, for example , , etc. Setting this negative sets the default 20. +* `space_help`:\\[in\\] Number of space to the help string. Setting this negative sets the default 32. ### Prototype ```c -void t8_forest_compute_profile (t8_forest_t forest); +void sc_options_set_spacing (sc_options_t * opt, int space_type, int space_help); ``` """ -function t8_forest_compute_profile(forest) - @ccall libt8.t8_forest_compute_profile(forest::t8_forest_t)::Cvoid +function sc_options_set_spacing(opt, space_type, space_help) + @ccall libt8.sc_options_set_spacing(opt::Ptr{sc_options_t}, space_type::Cint, space_help::Cint)::Cvoid end """ - t8_forest_profile_get_adapt_stats(forest) + sc_options_add_switch(opt, opt_char, opt_name, variable, help_string) +Add a switch option. This option is used without option arguments. Every use increments the variable by one. Its initial value is 0. Either opt\\_char or opt\\_name must be valid, that is, not '\\0'/NULL. + +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_adapt_stats (t8_forest_t forest); +void sc_options_add_switch (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, const char *help_string); ``` """ -function t8_forest_profile_get_adapt_stats(forest) - @ccall libt8.t8_forest_profile_get_adapt_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function sc_options_add_switch(opt, opt_char, opt_name, variable, help_string) + @ccall libt8.sc_options_add_switch(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, help_string::Cstring)::Cvoid end """ - t8_forest_profile_get_ghost_stats(forest) + sc_options_add_bool(opt, opt_char, opt_name, variable, init_value, help_string) + +Add a boolean option. It can be initialized to true or false in the C sense. Specifying it on the command line without argument sets the option to true. The argument 0/f/F/n/N sets it to false (0). The argument 1/t/T/y/Y sets it to true (nonzero). +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] Initial value to set the option, read as true or false. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_ghost_stats (t8_forest_t forest); +void sc_options_add_bool (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string); ``` """ -function t8_forest_profile_get_ghost_stats(forest) - @ccall libt8.t8_forest_profile_get_ghost_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function sc_options_add_bool(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libt8.sc_options_add_bool(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cint, help_string::Cstring)::Cvoid end """ - t8_forest_profile_get_partition_stats(forest) + sc_options_add_int(opt, opt_char, opt_name, variable, init_value, help_string) + +Add an option that takes an integer argument. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] The initial value of the option variable. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_partition_stats (t8_forest_t forest); +void sc_options_add_int (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string); ``` """ -function t8_forest_profile_get_partition_stats(forest) - @ccall libt8.t8_forest_profile_get_partition_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function sc_options_add_int(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libt8.sc_options_add_int(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cint, help_string::Cstring)::Cvoid end """ - t8_forest_profile_get_commit_stats(forest) + sc_options_add_size_t(opt, opt_char, opt_name, variable, init_value, help_string) + +Add an option that takes a size\\_t argument. The value of the size\\_t variable must not be greater than LLONG\\_MAX. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] The initial value of the option variable. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_commit_stats (t8_forest_t forest); +void sc_options_add_size_t (sc_options_t * opt, int opt_char, const char *opt_name, size_t *variable, size_t init_value, const char *help_string); ``` """ -function t8_forest_profile_get_commit_stats(forest) - @ccall libt8.t8_forest_profile_get_commit_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function sc_options_add_size_t(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libt8.sc_options_add_size_t(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Csize_t}, init_value::Csize_t, help_string::Cstring)::Cvoid end """ - t8_forest_profile_get_balance_stats(forest) + sc_options_add_double(opt, opt_char, opt_name, variable, init_value, help_string) + +Add an option that takes a double argument. The double must be in the legal range. "inf" and "nan" are legal too. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] The initial value of the option variable. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_balance_stats (t8_forest_t forest); +void sc_options_add_double (sc_options_t * opt, int opt_char, const char *opt_name, double *variable, double init_value, const char *help_string); ``` """ -function t8_forest_profile_get_balance_stats(forest) - @ccall libt8.t8_forest_profile_get_balance_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function sc_options_add_double(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libt8.sc_options_add_double(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cdouble}, init_value::Cdouble, help_string::Cstring)::Cvoid end """ - t8_forest_profile_get_balance_rounds_stats(forest) + sc_options_add_string(opt, opt_char, opt_name, variable, init_value, help_string) + +Add a string option. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `variable`:\\[in\\] Address of the variable to store the option value. +* `init_value`:\\[in\\] This default value of the option may be NULL. If not NULL, the value is copied to internal storage. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -const sc_statinfo_t * t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); +void sc_options_add_string (sc_options_t * opt, int opt_char, const char *opt_name, const char **variable, const char *init_value, const char *help_string); ``` """ -function t8_forest_profile_get_balance_rounds_stats(forest) - @ccall libt8.t8_forest_profile_get_balance_rounds_stats(forest::t8_forest_t)::Ptr{sc_statinfo_t} +function sc_options_add_string(opt, opt_char, opt_name, variable, init_value, help_string) + @ccall libt8.sc_options_add_string(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cstring}, init_value::Cstring, help_string::Cstring)::Cvoid end """ - t8_forest_print_profile(forest) + sc_options_add_inifile(opt, opt_char, opt_name, help_string) + +Add an option to read in a file in `.ini` format. The argument to this option must be a filename. On parsing the specified file is read to set known option variables. It does not have an associated option variable itself. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -void t8_forest_print_profile (t8_forest_t forest); +void sc_options_add_inifile (sc_options_t * opt, int opt_char, const char *opt_name, const char *help_string); ``` """ -function t8_forest_print_profile(forest) - @ccall libt8.t8_forest_print_profile(forest::t8_forest_t)::Cvoid +function sc_options_add_inifile(opt, opt_char, opt_name, help_string) + @ccall libt8.sc_options_add_inifile(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, help_string::Cstring)::Cvoid end """ - t8_forest_profile_get_adapt_time(forest) + sc_options_add_jsonfile(opt, opt_char, opt_name, help_string) + +Add an option to read in a file in JSON format. The argument to this option must be a filename. On parsing the specified file is read to set known option variables. It does not have an associated option variable itself. + +This functionality is only active when sc_have_json returns true, equivalent to the define SC\\_HAVE\\_JSON existing, and ignored otherwise. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -double t8_forest_profile_get_adapt_time (t8_forest_t forest); +void sc_options_add_jsonfile (sc_options_t * opt, int opt_char, const char *opt_name, const char *help_string); ``` """ -function t8_forest_profile_get_adapt_time(forest) - @ccall libt8.t8_forest_profile_get_adapt_time(forest::t8_forest_t)::Cdouble +function sc_options_add_jsonfile(opt, opt_char, opt_name, help_string) + @ccall libt8.sc_options_add_jsonfile(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, help_string::Cstring)::Cvoid end """ - t8_forest_profile_get_partition_time(forest, procs_sent) + sc_options_add_callback(opt, opt_char, opt_name, has_arg, fn, data, help_string) + +Add an option that calls a user-defined function when parsed. The callback function should be implemented to allow multiple calls. The callback may be used to set multiple option variables in bulk that would otherwise require an inconvenient number of individual options. This option is not loaded from or saved to files. +# Arguments +* `opt`:\\[in,out\\] A valid options structure. +* `opt_char`:\\[in\\] Short option character, may be '\\0'. +* `opt_name`:\\[in\\] Long option name without initial dashes, may be NULL. +* `has_arg`:\\[in\\] Specify whether the option needs an option argument. This can be 0 for none, 1 for a required argument, and 2 for an optional argument; see getopt\\_long (3). +* `fn`:\\[in\\] Function to call when this option is encountered. +* `data`:\\[in\\] User-defined data passed to the callback. +* `help_string`:\\[in\\] Help string for usage message, may be NULL. ### Prototype ```c -double t8_forest_profile_get_partition_time (t8_forest_t forest, int *procs_sent); +void sc_options_add_callback (sc_options_t * opt, int opt_char, const char *opt_name, int has_arg, sc_options_callback_t fn, void *data, const char *help_string); ``` """ -function t8_forest_profile_get_partition_time(forest, procs_sent) - @ccall libt8.t8_forest_profile_get_partition_time(forest::t8_forest_t, procs_sent::Ptr{Cint})::Cdouble +function sc_options_add_callback(opt, opt_char, opt_name, has_arg, fn, data, help_string) + @ccall libt8.sc_options_add_callback(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, has_arg::Cint, fn::sc_options_callback_t, data::Ptr{Cvoid}, help_string::Cstring)::Cvoid end """ - t8_forest_profile_get_balance_time(forest, balance_rounds) + sc_options_add_keyvalue(opt, opt_char, opt_name, variable, init_value, keyvalue, help_string) + +Add an option that takes string keys into a lookup table of integers. On calling this function, it must be certain that the initial value exists. +# Arguments +* `opt`:\\[in\\] Initialized options structure. +* `opt_char`:\\[in\\] Option character for command line, or 0. +* `opt_name`:\\[in\\] Name of the long option, or NULL. +* `variable`:\\[in\\] Address of an existing integer that holds the value of this option parameter. +* `init_value`:\\[in\\] The key that is looked up for the initial value. It must be certain that the key exists and its value is of type integer. +* `keyvalue`:\\[in\\] A valid key-value structure where the values must be integers. If a key is asked for that does not exist, we will produce an option error. This structure must stay alive as long as opt. +* `help_string`:\\[in\\] Instructive one-line string to explain the option. ### Prototype ```c -double t8_forest_profile_get_balance_time (t8_forest_t forest, int *balance_rounds); +void sc_options_add_keyvalue (sc_options_t * opt, int opt_char, const char *opt_name, int *variable, const char *init_value, sc_keyvalue_t * keyvalue, const char *help_string); ``` """ -function t8_forest_profile_get_balance_time(forest, balance_rounds) - @ccall libt8.t8_forest_profile_get_balance_time(forest::t8_forest_t, balance_rounds::Ptr{Cint})::Cdouble +function sc_options_add_keyvalue(opt, opt_char, opt_name, variable, init_value, keyvalue, help_string) + @ccall libt8.sc_options_add_keyvalue(opt::Ptr{sc_options_t}, opt_char::Cint, opt_name::Cstring, variable::Ptr{Cint}, init_value::Cstring, keyvalue::Ptr{sc_keyvalue_t}, help_string::Cstring)::Cvoid end """ - t8_forest_profile_get_ghost_time(forest, ghosts_sent) + sc_options_add_suboptions(opt, subopt, prefix) + +Copy one set of options to another as a subset, with a prefix. The variables referenced by the options and the suboptions are the same. +# Arguments +* `opt`:\\[in,out\\] A set of options. +* `subopt`:\\[in\\] Another set of options to be copied. +* `prefix`:\\[in\\] The prefix to add to option names as they are copied. If an option has a long name "name" in subopt, its name in opt is "prefix:name"; if an option only has a character 'c' in subopt, its name in opt is "prefix:-c". ### Prototype ```c -double t8_forest_profile_get_ghost_time (t8_forest_t forest, t8_locidx_t *ghosts_sent); +void sc_options_add_suboptions (sc_options_t * opt, sc_options_t * subopt, const char *prefix); ``` """ -function t8_forest_profile_get_ghost_time(forest, ghosts_sent) - @ccall libt8.t8_forest_profile_get_ghost_time(forest::t8_forest_t, ghosts_sent::Ptr{Cint})::Cdouble +function sc_options_add_suboptions(opt, subopt, prefix) + @ccall libt8.sc_options_add_suboptions(opt::Ptr{sc_options_t}, subopt::Ptr{sc_options_t}, prefix::Cstring)::Cvoid end """ - t8_forest_profile_get_ghostexchange_waittime(forest) + sc_options_print_usage(package_id, log_priority, opt, arg_usage) + +Print a usage message. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Priority for output according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `arg_usage`:\\[in\\] If not NULL, an string is appended to the usage line. If the string is non-empty, it will be printed after the option summary and an "ARGUMENTS:\\n" title line. Line breaks are identified by strtok(3) and honored. ### Prototype ```c -double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest); +void sc_options_print_usage (int package_id, int log_priority, sc_options_t * opt, const char *arg_usage); ``` """ -function t8_forest_profile_get_ghostexchange_waittime(forest) - @ccall libt8.t8_forest_profile_get_ghostexchange_waittime(forest::t8_forest_t)::Cdouble +function sc_options_print_usage(package_id, log_priority, opt, arg_usage) + @ccall libt8.sc_options_print_usage(package_id::Cint, log_priority::Cint, opt::Ptr{sc_options_t}, arg_usage::Cstring)::Cvoid end """ - t8_profile + sc_options_print_summary(package_id, log_priority, opt) -| 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). | +Print a summary of all option values. Prints the title "Options:" and a line for every option, then the title "Arguments:" and a line for every argument. This function uses the [`SC_LC_GLOBAL`](@ref) log category. That means the default action is to print only on rank 0. Applications can change that by providing a user-defined log handler. + +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `log_priority`:\\[in\\] Priority for output according to sc_logprios. +* `opt`:\\[in\\] The option structure. +### Prototype +```c +void sc_options_print_summary (int package_id, int log_priority, sc_options_t * opt); +``` """ -struct 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 +function sc_options_print_summary(package_id, log_priority, opt) + @ccall libt8.sc_options_print_summary(package_id::Cint, log_priority::Cint, opt::Ptr{sc_options_t})::Cvoid 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 + sc_options_load(package_id, err_priority, opt, file) -This enumeration contains all possible geometries. +Load a file in the default format and update option values. The default is a file in the `.ini` format; see sc_options_load_ini. -| Enumerator | Note | -| :--------------------------------------------- | :----------------------------------------------------------------------------------------------- | -| T8\\_GEOMETRY\\_TYPE\\_ZERO | The zero geometry maps all points to zero. | -| T8\\_GEOMETRY\\_TYPE\\_LINEAR | The linear geometry uses linear interpolations to interpolate between the tree vertices. | -| T8\\_GEOMETRY\\_TYPE\\_LINEAR\\_AXIS\\_ALIGNED | The linear, axis aligned geometry uses only 2 vertices, since it is axis aligned. | -| T8\\_GEOMETRY\\_TYPE\\_LAGRANGE | The Lagrange geometry uses a mapping with Lagrange polynomials to approximate curved elements . | -| T8\\_GEOMETRY\\_TYPE\\_ANALYTIC | The analytic geometry uses a user-defined analytic function to map into the physical domain. | -| T8\\_GEOMETRY\\_TYPE\\_CAD | The opencascade geometry uses CAD shapes to map trees exactly to the underlying CAD model. | -| T8\\_GEOMETRY\\_TYPE\\_COUNT | This is no geometry type but can be used as the number of geometry types. | -| T8\\_GEOMETRY\\_TYPE\\_UNDEFINED | This is no geometry type but is used for every geometry, where no type is defined | +# Arguments +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `file`:\\[in\\] Filename of the file to load. +# Returns +Returns 0 on success, -1 on failure. +### Prototype +```c +int sc_options_load (int package_id, int err_priority, sc_options_t * opt, const char *file); +``` """ -@cenum t8_geometry_type::UInt32 begin - T8_GEOMETRY_TYPE_ZERO = 0 - T8_GEOMETRY_TYPE_LINEAR = 1 - T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED = 2 - T8_GEOMETRY_TYPE_LAGRANGE = 3 - T8_GEOMETRY_TYPE_ANALYTIC = 4 - T8_GEOMETRY_TYPE_CAD = 5 - T8_GEOMETRY_TYPE_COUNT = 6 - T8_GEOMETRY_TYPE_UNDEFINED = 7 +function sc_options_load(package_id, err_priority, opt, file) + @ccall libt8.sc_options_load(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, file::Cstring)::Cint end -"""This enumeration contains all possible geometries.""" -const t8_geometry_type_t = t8_geometry_type - """ - t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) + sc_options_load_ini(package_id, err_priority, opt, inifile, re) -Evaluates the geometry of a tree at a given reference point. +Load a file in `.ini` format and update entries found under [Options]. An option whose name contains a colon such as "prefix:basename" will be updated by a "basename =" entry in a [prefix] section. # Arguments -* `cmesh`:\\[in\\] The cmesh -* `gtreeid`:\\[in\\] The global id of the tree -* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the geometry -* `num_coords`:\\[in\\] The number of reference coordinates -* `out_coords`:\\[out\\] The evaluated coordinates +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `inifile`:\\[in\\] Filename of the ini file to load. +* `re`:\\[in,out\\] Provisioned for runtime error checking implementation; currently must be NULL. +# Returns +Returns 0 on success, -1 on failure. ### Prototype ```c -void t8_geometry_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords); +int sc_options_load_ini (int package_id, int err_priority, sc_options_t * opt, const char *inifile, void *re); ``` """ -function t8_geometry_evaluate(cmesh, gtreeid, ref_coords, num_coords, out_coords) - @ccall libt8.t8_geometry_evaluate(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function sc_options_load_ini(package_id, err_priority, opt, inifile, re) + @ccall libt8.sc_options_load_ini(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring, re::Ptr{Cvoid})::Cint end """ - t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) + sc_options_load_json(package_id, err_priority, opt, jsonfile, re) -Evaluates the jacobian of a tree at a given reference point. +Load a file in JSON format and update entries from object "Options". An option whose name contains a colon such as "Prefix:basename" will be updated by a "basename :" entry in a "Prefix" nested object. # Arguments -* `cmesh`:\\[in\\] The cmesh -* `gtreeid`:\\[in\\] The global id of the tree -* `ref_coords`:\\[in\\] The reference coordinates at which to evaluate the jacobian -* `num_coords`:\\[in\\] The number of reference coordinates -* `jacobian`:\\[out\\] The jacobian at the reference coordinates +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `jsonfile`:\\[in\\] Filename of the JSON file to load. +* `re`:\\[in,out\\] Provisioned for runtime error checking implementation; currently must be NULL. +# Returns +Returns 0 on success, -1 on failure. ### Prototype ```c -void t8_geometry_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *jacobian); +int sc_options_load_json (int package_id, int err_priority, sc_options_t * opt, const char *jsonfile, void *re); ``` """ -function t8_geometry_jacobian(cmesh, gtreeid, ref_coords, num_coords, jacobian) - @ccall libt8.t8_geometry_jacobian(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, jacobian::Ptr{Cdouble})::Cvoid +function sc_options_load_json(package_id, err_priority, opt, jsonfile, re) + @ccall libt8.sc_options_load_json(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, jsonfile::Cstring, re::Ptr{Cvoid})::Cint end """ - t8_geometry_get_type(cmesh, gtreeid) + sc_options_save(package_id, err_priority, opt, inifile) -This function returns the geometry type of a tree. +Save all options and arguments to a file in `.ini` format. This function must only be called after successful option parsing. This function should only be called on rank 0. This function will log errors with category [`SC_LC_GLOBAL`](@ref). An options whose name contains a colon such as "Prefix:basename" will be written in a section titled [Prefix] as "basename =". # Arguments -* `cmesh`:\\[in\\] The cmesh -* `gtreeid`:\\[in\\] The global id of the tree +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `inifile`:\\[in\\] Filename of the ini file to save. # Returns -The geometry type of the tree with id gtreeid +Returns 0 on success, -1 on failure. ### Prototype ```c -t8_geometry_type_t t8_geometry_get_type (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); +int sc_options_save (int package_id, int err_priority, sc_options_t * opt, const char *inifile); ``` """ -function t8_geometry_get_type(cmesh, gtreeid) - @ccall libt8.t8_geometry_get_type(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::t8_geometry_type_t +function sc_options_save(package_id, err_priority, opt, inifile) + @ccall libt8.sc_options_save(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring)::Cint end """ - t8_geometry_tree_negative_volume(cmesh, gtreeid) + sc_options_load_args(package_id, err_priority, opt, inifile) -Check if a tree has a negative volume +Load a file in `.ini` format and update entries found under [Arguments]. There needs to be a key Arguments.count specifying the number. Then as many integer keys starting with 0 need to be present. # Arguments -* `cmesh`:\\[in\\] The cmesh to check -* `gtreeid`:\\[in\\] The global id of the tree +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The args are stored in this option structure. +* `inifile`:\\[in\\] Filename of the ini file to load. # Returns -True if the tree with id gtreeid has a negative volume. False otherwise. +Returns 0 on success, -1 on failure. ### Prototype ```c -int t8_geometry_tree_negative_volume (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid); +int sc_options_load_args (int package_id, int err_priority, sc_options_t * opt, const char *inifile); ``` """ -function t8_geometry_tree_negative_volume(cmesh, gtreeid) - @ccall libt8.t8_geometry_tree_negative_volume(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t)::Cint +function sc_options_load_args(package_id, err_priority, opt, inifile) + @ccall libt8.sc_options_load_args(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, inifile::Cstring)::Cint end """ - t8_geom_get_name(geom) + sc_options_parse(package_id, err_priority, opt, argc, argv) -Get the name of a geometry. +Parse command line options. # Arguments -* `geom`:\\[in\\] A geometry. +* `package_id`:\\[in\\] Registered package id or -1. +* `err_priority`:\\[in\\] Error priority according to sc_logprios. +* `opt`:\\[in\\] The option structure. +* `argc`:\\[in\\] Length of argument list. +* `argv`:\\[in,out\\] Argument list may be permuted. # Returns -The name of *geom*. +Returns -1 on an invalid option, otherwise the position of the first non-option argument. ### Prototype ```c -const char * t8_geom_get_name (const t8_geometry_c *geom); +int sc_options_parse (int package_id, int err_priority, sc_options_t * opt, int argc, char **argv); ``` """ -function t8_geom_get_name(geom) - @ccall libt8.t8_geom_get_name(geom::Ptr{t8_geometry_c})::Cstring +function sc_options_parse(package_id, err_priority, opt, argc, argv) + @ccall libt8.sc_options_parse(package_id::Cint, err_priority::Cint, opt::Ptr{sc_options_t}, argc::Cint, argv::Ptr{Cstring})::Cint end """ - t8_geom_get_type(geom) - -Get the type of a geometry. + t8_cmesh_from_tetgen_file(fileprefix, partition, comm, do_dup) -# Arguments -* `geom`:\\[in\\] A geometry. -# Returns -The type of *geom*. ### Prototype ```c -t8_geometry_type_t t8_geom_get_type (const t8_geometry_c *geom); +t8_cmesh_t t8_cmesh_from_tetgen_file (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup); ``` """ -function t8_geom_get_type(geom) - @ccall libt8.t8_geom_get_type(geom::Ptr{t8_geometry_c})::t8_geometry_type_t +function t8_cmesh_from_tetgen_file(fileprefix, partition, comm, do_dup) + @ccall libt8.t8_cmesh_from_tetgen_file(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint)::t8_cmesh_t end """ - t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + t8_cmesh_from_tetgen_file_time(fileprefix, partition, comm, do_dup, fi, snapshot, stats, statentry) ### Prototype ```c -void t8_geom_compute_linear_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); +t8_cmesh_t t8_cmesh_from_tetgen_file_time (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup, sc_flopinfo_t *fi, sc_flopinfo_t *snapshot, sc_statinfo_t *stats, int statentry); ``` """ -function t8_geom_compute_linear_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) - @ccall libt8.t8_geom_compute_linear_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function t8_cmesh_from_tetgen_file_time(fileprefix, partition, comm, do_dup, fi, snapshot, stats, statentry) + @ccall libt8.t8_cmesh_from_tetgen_file_time(fileprefix::Cstring, partition::Cint, comm::MPI_Comm, do_dup::Cint, fi::Ptr{sc_flopinfo_t}, snapshot::Ptr{sc_flopinfo_t}, stats::Ptr{sc_statinfo_t}, statentry::Cint)::t8_cmesh_t end """ - t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) + t8_cmesh_from_triangle_file(fileprefix, partition, comm, do_dup) ### Prototype ```c -void t8_geom_compute_linear_axis_aligned_geometry (t8_eclass_t tree_class, const double *tree_vertices, const double *ref_coords, const size_t num_coords, double *out_coords); +t8_cmesh_t t8_cmesh_from_triangle_file (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup); ``` """ -function t8_geom_compute_linear_axis_aligned_geometry(tree_class, tree_vertices, ref_coords, num_coords, out_coords) - @ccall libt8.t8_geom_compute_linear_axis_aligned_geometry(tree_class::Cint, tree_vertices::Ptr{Cdouble}, ref_coords::Ptr{Cdouble}, num_coords::Csize_t, out_coords::Ptr{Cdouble})::Cvoid +function t8_cmesh_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 +mutable struct t8_cmesh_vertex_connectivity end + """ - t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) +[`t8_cmesh_vertex_connectivity_c`](@ref) -Interpolates linearly between 2, bilinearly between 4 or trilineraly between 8 points. +Opaque pointer to the cmesh vertex connectivity structure. +""" +const t8_cmesh_vertex_connectivity_c = Ptr{t8_cmesh_vertex_connectivity} + +""" + t8_cmesh_set_global_vertices_of_tree(cmesh, global_tree, global_tree_vertices, num_vertices) -# Arguments -* `coefficients`:\\[in\\] An array of size at least dim giving the coefficients used for the interpolation -* `corner_values`:\\[in\\] An array of size 2^dim * 3, giving for each corner (in zorder) of the unit square/cube its function values in space. -* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. -* `interpolation_dim`:\\[in\\] The dimension of the interpolation (1 for linear, 2 for bilinear, 3 for trilinear) -* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -void t8_geom_linear_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); +void t8_cmesh_set_global_vertices_of_tree (const t8_cmesh_t cmesh, const t8_gloidx_t global_tree, const t8_gloidx_t *global_tree_vertices, const int num_vertices); ``` """ -function t8_geom_linear_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) - @ccall libt8.t8_geom_linear_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid +function t8_cmesh_set_global_vertices_of_tree(cmesh, global_tree, global_tree_vertices, num_vertices) + @ccall libt8.t8_cmesh_set_global_vertices_of_tree(cmesh::Cint, global_tree::Cint, global_tree_vertices::Ptr{Cint}, num_vertices::Cint)::Cvoid end """ - t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) + t8_cmesh_get_num_global_vertices(cmesh) -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). +### Prototype +```c +t8_gloidx_t t8_cmesh_get_num_global_vertices (const t8_cmesh_t cmesh); +``` +""" +function t8_cmesh_get_num_global_vertices(cmesh) + @ccall libt8.t8_cmesh_get_num_global_vertices(cmesh::Cint)::Cint +end + +""" + t8_cmesh_get_num_local_vertices(cmesh) -# Arguments -* `coefficients`:\\[in\\] An array of size *interpolation_dim* giving the coefficients in the reference triangle/tet used for the interpolation -* `corner_values`:\\[in\\] An array of size 3 * *corner_value_dim* for *interpolation_dim* == 2 or 4 * *corner_value_dim* for *interpolation_dim* == 3, giving the function values of the triangle/tetrahedron for each corner (in zorder) -* `corner_value_dim`:\\[in\\] The dimension of the *corner_values*. -* `interpolation_dim`:\\[in\\] The dimension of the interpolation (2 for triangle, 3 for tetrahedron) -* `evaluated_function`:\\[out\\] An array of size *corner_value_dim*, on output the result of the interpolation. ### Prototype ```c -void t8_geom_triangular_interpolation (const double *coefficients, const double *corner_values, int corner_value_dim, int interpolation_dim, double *evaluated_function); +t8_locidx_t t8_cmesh_get_num_local_vertices (const t8_cmesh_t cmesh); ``` """ -function t8_geom_triangular_interpolation(coefficients, corner_values, corner_value_dim, interpolation_dim, evaluated_function) - @ccall libt8.t8_geom_triangular_interpolation(coefficients::Ptr{Cdouble}, corner_values::Ptr{Cdouble}, corner_value_dim::Cint, interpolation_dim::Cint, evaluated_function::Ptr{Cdouble})::Cvoid +function t8_cmesh_get_num_local_vertices(cmesh) + @ccall libt8.t8_cmesh_get_num_local_vertices(cmesh::Cint)::Cint end """ - t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) + t8_cmesh_get_global_vertices_of_tree(cmesh, local_tree, num_vertices) ### Prototype ```c -void t8_geom_get_face_vertices (t8_eclass_t tree_class, const double *tree_vertices, int face_index, int dim, double *face_vertices); +const t8_gloidx_t * t8_cmesh_get_global_vertices_of_tree (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, int *num_vertices); ``` """ -function t8_geom_get_face_vertices(tree_class, tree_vertices, face_index, dim, face_vertices) - @ccall libt8.t8_geom_get_face_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, face_index::Cint, dim::Cint, face_vertices::Ptr{Cdouble})::Cvoid +function t8_cmesh_get_global_vertices_of_tree(cmesh, local_tree, num_vertices) + @ccall libt8.t8_cmesh_get_global_vertices_of_tree(cmesh::Cint, local_tree::Cint, num_vertices::Ptr{Cint})::Ptr{Cint} end """ - t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) + t8_cmesh_get_global_vertex_of_tree(cmesh, local_tree, local_tree_vertex) ### Prototype ```c -void t8_geom_get_edge_vertices (t8_eclass_t tree_class, const double *tree_vertices, int edge_index, int dim, double *edge_vertices); +t8_gloidx_t t8_cmesh_get_global_vertex_of_tree (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, const int local_tree_vertex); ``` """ -function t8_geom_get_edge_vertices(tree_class, tree_vertices, edge_index, dim, edge_vertices) - @ccall libt8.t8_geom_get_edge_vertices(tree_class::Cint, tree_vertices::Ptr{Cdouble}, edge_index::Cint, dim::Cint, edge_vertices::Ptr{Cdouble})::Cvoid +function t8_cmesh_get_global_vertex_of_tree(cmesh, local_tree, local_tree_vertex) + @ccall libt8.t8_cmesh_get_global_vertex_of_tree(cmesh::Cint, local_tree::Cint, local_tree_vertex::Cint)::Cint end """ - t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) + t8_cmesh_get_num_trees_at_vertex(cmesh, global_vertex) -Calculates a point of intersection in a triangular reference space. The intersection is the extension of a straight line passing through a reference point and the opposite vertex of the edge. /|\\ / | \\ o -> reference point / o \\ x -> intersection point / | \\ /\\_\\_\\_\\_x\\_\\_\\_\\_\\ +### Prototype +```c +int t8_cmesh_get_num_trees_at_vertex (const t8_cmesh_t cmesh, t8_gloidx_t global_vertex); +``` +""" +function t8_cmesh_get_num_trees_at_vertex(cmesh, global_vertex) + @ccall libt8.t8_cmesh_get_num_trees_at_vertex(cmesh::Cint, global_vertex::Cint)::Cint +end + +""" + t8_cmesh_uses_vertex_connectivity(cmesh) -# Arguments -* `edge_index`:\\[in\\] Index of the edge, the intersection lies on. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -* `ref_intersection`:\\[out\\] Coordinates of the intersection point. ### Prototype ```c -void t8_geom_get_ref_intersection (int edge_index, const double *ref_coords, double ref_intersection[2]); +int t8_cmesh_uses_vertex_connectivity (const t8_cmesh_t cmesh); ``` """ -function t8_geom_get_ref_intersection(edge_index, ref_coords, ref_intersection) - @ccall libt8.t8_geom_get_ref_intersection(edge_index::Cint, ref_coords::Ptr{Cdouble}, ref_intersection::Ptr{Cdouble})::Cvoid +function t8_cmesh_uses_vertex_connectivity(cmesh) + @ccall libt8.t8_cmesh_uses_vertex_connectivity(cmesh::Cint)::Cint end +# typedef int ( * t8_search_element_callback_c_wrapper ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , void * user_data ) """ - t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) +A call-back function used by t8_forest_init_search for searching elements. Is called on an element and the search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. -Calculates the scaling factor for edge displacement along a triangular tree face depending on the position of the global reference point. +# Arguments +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. +* `element`:\\[in\\] the element for which the search criterion is checked +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* +* `user_data`:\\[in\\] a user data pointer that can be set by the user +# Returns +non-zero if the search criterion is met, zero otherwise. +""" +const t8_search_element_callback_c_wrapper = Ptr{Cvoid} + +# typedef int ( * t8_search_queries_callback_c_wrapper ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , void * queries , void * user_data ) +""" +A call-back function used by t8_forest_init_search_with_queries for searching elements and executing queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. # Arguments -* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. -* `tree_vertices`:\\[in\\] Array with the tree vertex coordinates. -* `glob_intersection`:\\[in\\] Array containing the coordinates of the intersection point of a line drawn from the opposite vertex through the glob\\_ref\\_point onto the edge with edge\\_index. -* `glob_ref_point`:\\[in\\] Array containing the coordinates of the reference point mapped into the global space. +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. +* `element`:\\[in\\] the element for which the search criterion is checked +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* +* `queries`:\\[in\\] a pointer to an array of queries +* `user_data`:\\[in\\] a user data pointer that can be set by the user +""" +const t8_search_queries_callback_c_wrapper = Ptr{Cvoid} + +# typedef void ( * t8_search_batched_queries_callback_c_wrapper ) ( t8_forest_t forest , const t8_locidx_t ltreeid , const t8_element_t * element , const int is_leaf , const t8_element_array_t * leaf_elements , const t8_locidx_t tree_leaf_index , const void * queries , const size_t * active_query_indices , int * query_matches , void * user_data ) +""" +A call-back function used by t8_forest_init_search_with_batched_queries for searching elements and executing batched queries. Is called on an element and all queries are checked on that element. All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check are stored in *query_matches*. + +# Arguments +* `forest`:\\[in\\] the forest +* `ltreeid`:\\[in\\] the local tree id of the current tree in the cmesh. +* `element`:\\[in\\] the element for which the search criterion is checked +* `is_leaf`:\\[in\\] true if and only if *element* is a leaf element +* `leaf_elements`:\\[in\\] the leaf elements in *forest* +* `tree_leaf_index`:\\[in\\] the local index of the first leaf in *leaf_elements* +* `queries`:\\[in\\] a pointer to an array of queries +* `active_query_indices`:\\[in\\] a pointer to an array of indices of active queries in *queries* +* `query_matches`:\\[in,out\\] a pointer to an array of length *num_active_queries*. If query\\_matches[i] is true, then the element 'matches' the query of the active query with index active\\_query\\_indices[i]. +* `user_data`:\\[in\\] a user data pointer that can be set by the user +""" +const t8_search_batched_queries_callback_c_wrapper = Ptr{Cvoid} + +mutable struct t8_forest_c_search end + +"""A wrapper around the forest search context""" +const t8_forest_search_c_wrapper = Ptr{t8_forest_c_search} + +""" + t8_forest_init_search(search, element_callback, forest) + ### Prototype ```c -double t8_geom_get_triangle_scaling_factor (int edge_index, const double *tree_vertices, const double *glob_intersection, const double *glob_ref_point); +void t8_forest_init_search (t8_forest_search_c_wrapper search, t8_search_element_callback_c_wrapper element_callback, const t8_forest_t forest); ``` """ -function t8_geom_get_triangle_scaling_factor(edge_index, tree_vertices, glob_intersection, glob_ref_point) - @ccall libt8.t8_geom_get_triangle_scaling_factor(edge_index::Cint, tree_vertices::Ptr{Cdouble}, glob_intersection::Ptr{Cdouble}, glob_ref_point::Ptr{Cdouble})::Cdouble +function t8_forest_init_search(search, element_callback, forest) + @ccall libt8.t8_forest_init_search(search::t8_forest_search_c_wrapper, element_callback::t8_search_element_callback_c_wrapper, forest::t8_forest_t)::Cvoid end """ - t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) - -Calculates the scaling factor for the displacement of an edge over a face of a tetrahedral element. + t8_forest_search_update_forest(search, forest) -# Arguments -* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. -* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -# Returns -The scaling factor of the edge displacement on the face at the point of the reference coordinates. ### Prototype ```c -double t8_geom_get_scaling_factor_of_edge_on_face_tet (int edge_index, int face_index, const double *ref_coords); +void t8_forest_search_update_forest (t8_forest_search_c_wrapper search, const t8_forest_t forest); ``` """ -function t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index, face_index, ref_coords) - @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_tet(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble +function t8_forest_search_update_forest(search, forest) + @ccall libt8.t8_forest_search_update_forest(search::t8_forest_search_c_wrapper, forest::t8_forest_t)::Cvoid end """ - t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) + t8_forest_search_update_user_data(search, udata) -Calculates the face intersection of a ray passing trough the reference coordinates and the opposite vertex of that face for a tetrahedron. The coordinates of the face intersection are reference coordinates: [0,1]^3. +Update the user data pointer in the search context # Arguments -* `face_index`:\\[in\\] Index of the face, on which the intersection should be calculated. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -* `face_intersection`:\\[out\\] Three dimensional array containing the intersection point on the face in reference space. +* `search`:\\[in,out\\] the search context to update +* `udata`:\\[in\\] the new user data pointer to use ### Prototype ```c -void t8_geom_get_tet_face_intersection (const int face_index, const double *ref_coords, double face_intersection[3]); +void t8_forest_search_update_user_data (t8_forest_search_c_wrapper search, void *udata); ``` """ -function t8_geom_get_tet_face_intersection(face_index, ref_coords, face_intersection) - @ccall libt8.t8_geom_get_tet_face_intersection(face_index::Cint, ref_coords::Ptr{Cdouble}, face_intersection::Ptr{Cdouble})::Cvoid +function t8_forest_search_update_user_data(search, udata) + @ccall libt8.t8_forest_search_update_user_data(search::t8_forest_search_c_wrapper, udata::Ptr{Cvoid})::Cvoid end """ - t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) + t8_forest_search_do_search(search) -Calculates the scaling factor for the displacement of an edge over a face of a prism element. +Perform the search # Arguments -* `edge_index`:\\[in\\] Index of the edge, whose displacement should be scaled. -* `face_index`:\\[in\\] Index of the face, the displacement should be scaled on. -* `ref_coords`:\\[in\\] Array containing the coordinates of the reference point. -# Returns -The scaling factor of the edge displacement on the face at the point of the reference coordinates. +* `search`:\\[in,out\\] the search context to use ### Prototype ```c -double t8_geom_get_scaling_factor_of_edge_on_face_prism (int edge_index, int face_index, const double *ref_coords); +void t8_forest_search_do_search (t8_forest_search_c_wrapper search); ``` """ -function t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index, face_index, ref_coords) - @ccall libt8.t8_geom_get_scaling_factor_of_edge_on_face_prism(edge_index::Cint, face_index::Cint, ref_coords::Ptr{Cdouble})::Cdouble +function t8_forest_search_do_search(search) + @ccall libt8.t8_forest_search_do_search(search::t8_forest_search_c_wrapper)::Cvoid end """ - t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) + t8_forest_search_destroy(search) -Calculates the scaling factor for the displacement of an face through the volume of a prism element. +Destroy the search context # 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. +* `search`:\\[in,out\\] the search context to destroy ### Prototype ```c -double t8_geom_get_scaling_factor_face_through_volume_prism (const int face, const double *ref_coords); +void t8_forest_search_destroy (t8_forest_search_c_wrapper search); ``` """ -function t8_geom_get_scaling_factor_face_through_volume_prism(face, ref_coords) - @ccall libt8.t8_geom_get_scaling_factor_face_through_volume_prism(face::Cint, ref_coords::Ptr{Cdouble})::Cdouble +function t8_forest_search_destroy(search) + @ccall libt8.t8_forest_search_destroy(search::t8_forest_search_c_wrapper)::Cvoid end +mutable struct t8_forest_search_with_queries end + +"""A wrapper around the forest search with queries context""" +const t8_forest_search_with_queries_c_wrapper = Ptr{t8_forest_search_with_queries} + """ - t8_vertex_point_inside(vertex_coords, point, tolerance) + t8_forest_init_search_with_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) -Check if a point lies inside a vertex +### Prototype +```c +void t8_forest_init_search_with_queries (t8_forest_search_with_queries_c_wrapper search_with_queries, t8_search_element_callback_c_wrapper element_callback, t8_search_queries_callback_c_wrapper queries_callback, void **queries, const size_t num_queries, const t8_forest_t forest); +``` +""" +function t8_forest_init_search_with_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) + @ccall libt8.t8_forest_init_search_with_queries(search_with_queries::t8_forest_search_with_queries_c_wrapper, element_callback::t8_search_element_callback_c_wrapper, queries_callback::t8_search_queries_callback_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t, forest::t8_forest_t)::Cvoid +end + +""" + t8_forest_search_with_queries_update_forest(search_with_queries, forest) -# Arguments -* `vertex_coords`:\\[in\\] The coordinates of the vertex -* `point`:\\[in\\] The coordinates of the point to check -* `tolerance`:\\[in\\] A double > 0 defining the tolerance -# Returns -0 if the point is outside, 1 otherwise. ### Prototype ```c -int t8_vertex_point_inside (const double vertex_coords[3], const double point[3], const double tolerance); +void t8_forest_search_with_queries_update_forest (t8_forest_search_with_queries_c_wrapper search_with_queries, const t8_forest_t forest); ``` """ -function t8_vertex_point_inside(vertex_coords, point, tolerance) - @ccall libt8.t8_vertex_point_inside(vertex_coords::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint +function t8_forest_search_with_queries_update_forest(search_with_queries, forest) + @ccall libt8.t8_forest_search_with_queries_update_forest(search_with_queries::t8_forest_search_with_queries_c_wrapper, forest::t8_forest_t)::Cvoid end """ - t8_line_point_inside(p_0, vec, point, tolerance) + t8_forest_search_with_queries_update_user_data(search_with_queries, udata) -Check if a point is inside a line that is defined by a starting point *p_0* and a vector *vec* +Update the user data pointer in the search with queries context # Arguments -* `p_0`:\\[in\\] Starting point of the line -* `vec`:\\[in\\] Direction of the line (not normalized) -* `point`:\\[in\\] The coordinates of the point to check -* `tolerance`:\\[in\\] A double > 0 defining the tolerance -# Returns -0 if the point is outside, 1 otherwise. +* `search_with_queries`:\\[in,out\\] the search with queries context to update +* `udata`:\\[in\\] the new user data pointer to use ### Prototype ```c -int t8_line_point_inside (const double *p_0, const double *vec, const double *point, const double tolerance); +void t8_forest_search_with_queries_update_user_data (t8_forest_search_with_queries_c_wrapper search_with_queries, void *udata); ``` """ -function t8_line_point_inside(p_0, vec, point, tolerance) - @ccall libt8.t8_line_point_inside(p_0::Ptr{Cdouble}, vec::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint +function t8_forest_search_with_queries_update_user_data(search_with_queries, udata) + @ccall libt8.t8_forest_search_with_queries_update_user_data(search_with_queries::t8_forest_search_with_queries_c_wrapper, udata::Ptr{Cvoid})::Cvoid end """ - t8_triangle_point_inside(p_0, v, w, point, tolerance) + t8_forest_search_with_queries_update_queries(search_with_queries, queries, num_queries) -Check if a point is inside of a triangle described by a point *p_0* and two vectors *v* and *w*. +Update the queries in the search with queries context # Arguments -* `p_0`:\\[in\\] The first vertex of a triangle -* `v`:\\[in\\] The vector from p\\_0 to p\\_1 (second vertex in the triangle) -* `w`:\\[in\\] The vector from p\\_0 to p\\_2 (third vertex in the triangle) -* `point`:\\[in\\] The coordinates of the point to check -* `tolerance`:\\[in\\] A double > 0 defining the tolerance -# Returns -0 if the point is outside, 1 otherwise. +* `search_with_queries`:\\[in,out\\] the search with queries context to update +* `queries`:\\[in\\] a pointer to an array of queries +* `num_queries`:\\[in\\] the number of queries in the array ### Prototype ```c -int t8_triangle_point_inside (const double p_0[3], const double v[3], const double w[3], const double point[3], const double tolerance); +void t8_forest_search_with_queries_update_queries (t8_forest_search_with_queries_c_wrapper search_with_queries, void **queries, const size_t num_queries); ``` """ -function t8_triangle_point_inside(p_0, v, w, point, tolerance) - @ccall libt8.t8_triangle_point_inside(p_0::Ptr{Cdouble}, v::Ptr{Cdouble}, w::Ptr{Cdouble}, point::Ptr{Cdouble}, tolerance::Cdouble)::Cint +function t8_forest_search_with_queries_update_queries(search_with_queries, queries, num_queries) + @ccall libt8.t8_forest_search_with_queries_update_queries(search_with_queries::t8_forest_search_with_queries_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t)::Cvoid end """ - t8_plane_point_inside(point_on_face, face_normal, point) + t8_forest_search_with_queries_destroy(search) -Check if a point lays on the inner side of a plane of a bilinearly interpolated volume element. the plane is described by a point and the normal of the face. +Destroy the search with queries context # Arguments -* `point_on_face`:\\[in\\] A point on the plane -* `face_normal`:\\[in\\] The normal of the face -* `point`:\\[in\\] The point to check -# Returns -0 if the point is outside, 1 otherwise. +* `search`:\\[in,out\\] the search with queries context to destroy ### Prototype ```c -int t8_plane_point_inside (const double point_on_face[3], const double face_normal[3], const double point[3]); +void t8_forest_search_with_queries_destroy (t8_forest_search_with_queries_c_wrapper search); ``` """ -function t8_plane_point_inside(point_on_face, face_normal, point) - @ccall libt8.t8_plane_point_inside(point_on_face::Ptr{Cdouble}, face_normal::Ptr{Cdouble}, point::Ptr{Cdouble})::Cint +function t8_forest_search_with_queries_destroy(search) + @ccall libt8.t8_forest_search_with_queries_destroy(search::t8_forest_search_with_queries_c_wrapper)::Cvoid end """ - t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) + t8_forest_search_with_queries_do_search(search) -Set the vertex coordinates of a tree in the cmesh. This is currently inefficient, since the vertices are duplicated for each tree. Eventually this function will be replaced by a more efficient one. It is not allowed to call this function after t8_cmesh_commit. The eclass of the tree has to be set before calling this function. +Perform the search with queries # Arguments -* `cmesh`:\\[in,out\\] The cmesh to be updated. -* `gtree_id`:\\[in\\] The global number of the tree. -* `vertices`:\\[in\\] An array of 3 doubles per tree vertex. -* `num_vertices`:\\[in\\] The number of verticess in *vertices*. Must match the number of corners of the tree. +* `search`:\\[in,out\\] the search with queries context to use ### Prototype ```c -void t8_cmesh_set_tree_vertices (t8_cmesh_t cmesh, const t8_gloidx_t gtree_id, const double *vertices, const int num_vertices); +void t8_forest_search_with_queries_do_search (t8_forest_search_with_queries_c_wrapper search); ``` """ -function t8_cmesh_set_tree_vertices(cmesh, gtree_id, vertices, num_vertices) - @ccall libt8.t8_cmesh_set_tree_vertices(cmesh::t8_cmesh_t, gtree_id::t8_gloidx_t, vertices::Ptr{Cdouble}, num_vertices::Cint)::Cvoid +function t8_forest_search_with_queries_do_search(search) + @ccall libt8.t8_forest_search_with_queries_do_search(search::t8_forest_search_with_queries_c_wrapper)::Cvoid end +mutable struct t8_forest_search_with_batched_queries end + +"""A wrapper around the forest search with batched queries context""" +const t8_forest_search_with_batched_queries_c_wrapper = Ptr{t8_forest_search_with_batched_queries} + """ - vtk_file_type + t8_forest_init_search_with_batched_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) -Enumerator for all types of files readable by t8code. +### Prototype +```c +void t8_forest_init_search_with_batched_queries (t8_forest_search_with_batched_queries_c_wrapper search_with_queries, t8_search_element_callback_c_wrapper element_callback, t8_search_batched_queries_callback_c_wrapper queries_callback, void **queries, const size_t num_queries, const t8_forest_t forest); +``` """ -@cenum vtk_file_type::Int32 begin - VTK_FILE_ERROR = -1 - VTK_SERIAL_FILE = 8 - VTK_UNSTRUCTURED_FILE = 8 - VTK_POLYDATA_FILE = 9 - VTK_PARALLEL_FILE = 16 - VTK_PARALLEL_UNSTRUCTURED_FILE = 16 - VTK_PARALLEL_POLYDATA_FILE = 17 - VTK_NUM_TYPES = 5 +function t8_forest_init_search_with_batched_queries(search_with_queries, element_callback, queries_callback, queries, num_queries, forest) + @ccall libt8.t8_forest_init_search_with_batched_queries(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, element_callback::t8_search_element_callback_c_wrapper, queries_callback::t8_search_batched_queries_callback_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t, forest::t8_forest_t)::Cvoid end -"""Enumerator for all types of files readable by t8code.""" -const vtk_file_type_t = vtk_file_type +""" + t8_forest_search_with_batched_queries_update_forest(search_with_queries, forest) -@cenum vtk_read_success::UInt32 begin - read_failure = 0 - read_success = 1 +### Prototype +```c +void t8_forest_search_with_batched_queries_update_forest ( t8_forest_search_with_batched_queries_c_wrapper search_with_queries, const t8_forest_t forest); +``` +""" +function t8_forest_search_with_batched_queries_update_forest(search_with_queries, forest) + @ccall libt8.t8_forest_search_with_batched_queries_update_forest(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, forest::t8_forest_t)::Cvoid end -const vtk_read_success_t = vtk_read_success - """ - t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) + t8_forest_search_with_batched_queries_update_user_data(search_with_queries, udata) -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 +Update the user data pointer in the search with batched queries context # Arguments -* `forest`:\\[in\\] The forest. -* `fileprefix`:\\[in\\] The prefix of the output files. The meta file will be named *fileprefix*.pvtu . -* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. -* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. -* `write_level`:\\[in\\] If true, the refinement level is written for each element. -* `write_element_id`:\\[in\\] If true, the global element id is written for each element. -* `curved_flag`:\\[in\\] If true, write the elements as curved element types from vtk. -* `write_ghosts`:\\[in\\] If true, write out ghost elements as well. -* `num_data`:\\[in\\] Number of user defined double valued data fields to write. -* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the user defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. -# Returns -True if successful, false if not (process local). +* `search_with_queries`:\\[in,out\\] the search with batched queries context to update +* `udata`:\\[in\\] the new user data pointer to use ### Prototype ```c -int t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int curved_flag, const int write_ghosts, const int num_data, t8_vtk_data_field_t *data); +void t8_forest_search_with_batched_queries_update_user_data ( t8_forest_search_with_batched_queries_c_wrapper search_with_queries, void *udata); ``` """ -function t8_forest_vtk_write_file_via_API(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, curved_flag, write_ghosts, num_data, data) - @ccall libt8.t8_forest_vtk_write_file_via_API(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, curved_flag::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_forest_search_with_batched_queries_update_user_data(search_with_queries, udata) + @ccall libt8.t8_forest_search_with_batched_queries_update_user_data(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, udata::Ptr{Cvoid})::Cvoid end """ - t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) + t8_forest_search_with_batched_queries_update_queries(search_with_queries, queries, num_queries) -Write the forest in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configure with "--with-vtk" and t8_forest_vtk_write_file_via_API is not available. +Update the queries in the search with batched queries context # Arguments -* `forest`:\\[in\\] The forest. -* `fileprefix`:\\[in\\] The prefix of the output files. -* `write_treeid`:\\[in\\] If true, the global tree id is written for each element. -* `write_mpirank`:\\[in\\] If true, the mpirank is written for each element. -* `write_level`:\\[in\\] If true, the refinement level is written for each element. -* `write_element_id`:\\[in\\] If true, the global element id is written for each element. -* `write_ghosts`:\\[in\\] If true, each process additionally writes its ghost elements. For ghost element the treeid is -1. -* `num_data`:\\[in\\] Number of user defined double valued data fields to write. -* `data`:\\[in\\] Array of [`t8_vtk_data_field_t`](@ref) of length *num_data* providing the used defined per element data. If scalar and vector fields are used, all scalar fields must come first in the array. -# Returns -True if successful, false if not (process local). +* `search_with_queries`:\\[in,out\\] the search with batched queries context to update +* `queries`:\\[in\\] a pointer to an array of queries +* `num_queries`:\\[in\\] the number of queries in the array ### Prototype ```c -int t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data); +void t8_forest_search_with_batched_queries_update_queries ( t8_forest_search_with_batched_queries_c_wrapper search_with_queries, void **queries, const size_t num_queries); ``` """ -function t8_forest_vtk_write_file(forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data) - @ccall libt8.t8_forest_vtk_write_file(forest::t8_forest_t, fileprefix::Cstring, write_treeid::Cint, write_mpirank::Cint, write_level::Cint, write_element_id::Cint, write_ghosts::Cint, num_data::Cint, data::Ptr{t8_vtk_data_field_t})::Cint +function t8_forest_search_with_batched_queries_update_queries(search_with_queries, queries, num_queries) + @ccall libt8.t8_forest_search_with_batched_queries_update_queries(search_with_queries::t8_forest_search_with_batched_queries_c_wrapper, queries::Ptr{Ptr{Cvoid}}, num_queries::Csize_t)::Cvoid end """ - t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) + t8_forest_search_with_batched_queries_destroy(search) + +Destroy the search with batched queries context +# Arguments +* `search`:\\[in,out\\] the search with batched queries context to destroy ### Prototype ```c -int t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm); +void t8_forest_search_with_batched_queries_destroy (t8_forest_search_with_batched_queries_c_wrapper search); ``` """ -function t8_cmesh_vtk_write_file_via_API(cmesh, fileprefix, comm) - @ccall libt8.t8_cmesh_vtk_write_file_via_API(cmesh::t8_cmesh_t, fileprefix::Cstring, comm::MPI_Comm)::Cint +function t8_forest_search_with_batched_queries_destroy(search) + @ccall libt8.t8_forest_search_with_batched_queries_destroy(search::t8_forest_search_with_batched_queries_c_wrapper)::Cvoid end """ - t8_cmesh_vtk_write_file(cmesh, fileprefix) + t8_forest_search_with_batched_queries_do_search(search) -Write the cmesh in .pvtu file format. Writes one .vtu file per process and a meta .pvtu file. This function writes ASCII files and can be used when t8code is not configure with "--with-vtk" and t8_cmesh_vtk_write_file_via_API is not available. +Perform the search with batched queries # Arguments -* `cmesh`:\\[in\\] The cmesh -* `fileprefix`:\\[in\\] The prefix of the output files -# Returns -int +* `search`:\\[in,out\\] the search with batched queries context to use ### Prototype ```c -int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); +void t8_forest_search_with_batched_queries_do_search (t8_forest_search_with_batched_queries_c_wrapper search); ``` """ -function t8_cmesh_vtk_write_file(cmesh, fileprefix) - @ccall libt8.t8_cmesh_vtk_write_file(cmesh::t8_cmesh_t, fileprefix::Cstring)::Cint +function t8_forest_search_with_batched_queries_do_search(search) + @ccall libt8.t8_forest_search_with_batched_queries_do_search(search::t8_forest_search_with_batched_queries_c_wrapper)::Cvoid end # typedef void ( * t8_geom_analytic_fn ) ( t8_cmesh_t cmesh , t8_gloidx_t gtreeid , const double * ref_coords , const size_t num_coords , double * out_coords , const void * tree_data , const void * user_data ) @@ -17707,7 +16609,7 @@ end Definition of an analytic geometry function. This function maps reference coordinates to physical coordinates. ```c++ - [0,1]^\\mathrm{dim} + [0,1]^\\mathrm{dim} ``` . @@ -17716,7 +16618,7 @@ Definition of an analytic geometry function. This function maps reference coordi * `cmesh`:\\[in\\] The cmesh. * `gtreeid`:\\[in\\] The global tree (of the cmesh) in which the reference point is. * `ref_coords`:\\[in\\] Array of dimension x *num_coords* many entries, specifying a point in -* `num_coords`:\\[in\\] +* `num_coords`:\\[in\\] The number of coordinates in *ref_coords*. * `out_coords`:\\[out\\] The mapped coordinates in physical space of *ref_coords*. The length is *num_coords* * 3. * `tree_data`:\\[in\\] The data of the current tree as loaded by a t8_geom_load_tree_data_fn. * `user_data`:\\[in\\] The user data pointer stored in the geometry. @@ -17728,19 +16630,19 @@ const t8_geom_analytic_fn = Ptr{Cvoid} Definition for the jacobian of an analytic geometry function. ```c++ - [0,1]^\\mathrm{dim} + [0,1]^\\mathrm{dim} ``` . ```c++ - \\mathrm{dim} + \\mathrm{dim} ``` to map. ```c++ - \\mathrm{dim} \\cdot 3 + \\mathrm{dim} \\cdot 3 ``` x *num_coords*. Indices @@ -17752,31 +16654,31 @@ x *num_coords*. Indices , ```c++ - 3 \\cdot i+1 + 3 \\cdot i+1 ``` , ```c++ - 3 \\cdot i+2 + 3 \\cdot i+2 ``` correspond to the ```c++ - i + i ``` -th column of the jacobian (Entry ```c++ - 3 \\cdot i + j + 3 \\cdot i + j ``` is ```c++ - \\frac{\\partial f_j}{\\partial x_i} + \\frac{\\partial f_j}{\\partial x_i} ``` ). @@ -17814,37 +16716,59 @@ const t8_geom_tree_compatible_fn = Ptr{Cvoid} """ t8_geometry_analytic_destroy(geom) +Destroy a geometry analytic object. + +# Arguments +* `geom`:\\[in,out\\] A pointer to a geometry object. Set to NULL on output. ### Prototype ```c void t8_geometry_analytic_destroy (t8_geometry_c **geom); ``` """ function t8_geometry_analytic_destroy(geom) - @ccall libt8.t8_geometry_analytic_destroy(geom::Ptr{Ptr{Cint}})::Cvoid + @ccall libt8.t8_geometry_analytic_destroy(geom::Ptr{Ptr{t8_geometry_c}})::Cvoid end """ t8_geometry_analytic_new(name, analytical, jacobian, load_tree_data, tree_negative_volume, tree_compatible, user_data) +Create a new analytic geometry. The geometry is viable with all tree types and uses a user-provided analytic and jacobian function. The actual mappings are done by these functions. + +# Arguments +* `name`:\\[in\\] The name to give this geometry. +* `analytical`:\\[in\\] The analytical function to use for this geometry. +* `jacobian`:\\[in\\] The jacobian of *analytical*. +* `load_tree_data`:\\[in\\] The function that is used to load a tree's data. +* `tree_negative_volume`:\\[in\\] The function that is used to compute if a trees volume is negative. +* `tree_compatible`:\\[in\\] The function that is used to check if a tree is compatible with the geometry. +* `user_data`:\\[in\\] Additional user data which the geometry can use. +# Returns +A pointer to an allocated geometry struct. ### Prototype ```c t8_geometry_c * t8_geometry_analytic_new (const char *name, t8_geom_analytic_fn analytical, t8_geom_analytic_jacobian_fn jacobian, t8_geom_load_tree_data_fn load_tree_data, t8_geom_tree_negative_volume_fn tree_negative_volume, t8_geom_tree_compatible_fn tree_compatible, const void *user_data); ``` """ function t8_geometry_analytic_new(name, analytical, jacobian, load_tree_data, tree_negative_volume, tree_compatible, user_data) - @ccall libt8.t8_geometry_analytic_new(name::Cstring, analytical::t8_geom_analytic_fn, jacobian::t8_geom_analytic_jacobian_fn, load_tree_data::t8_geom_load_tree_data_fn, tree_negative_volume::t8_geom_tree_negative_volume_fn, tree_compatible::t8_geom_tree_compatible_fn, user_data::Ptr{Cvoid})::Ptr{Cint} + @ccall libt8.t8_geometry_analytic_new(name::Cstring, analytical::t8_geom_analytic_fn, jacobian::t8_geom_analytic_jacobian_fn, load_tree_data::t8_geom_load_tree_data_fn, tree_negative_volume::t8_geom_tree_negative_volume_fn, tree_compatible::t8_geom_tree_compatible_fn, user_data::Ptr{Cvoid})::Ptr{t8_geometry_c} end """ t8_geom_load_tree_data_vertices(cmesh, gtreeid, user_data) +Load vertex data from given tree. + +# Arguments +* `cmesh`:\\[in\\] The cmesh. +* `gtreeid`:\\[in\\] The global tree id (in the cmesh). +* `user_data`:\\[out\\] The load tree vertices. ### Prototype ```c void t8_geom_load_tree_data_vertices (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const void **user_data); ``` """ function t8_geom_load_tree_data_vertices(cmesh, gtreeid, user_data) - @ccall libt8.t8_geom_load_tree_data_vertices(cmesh::t8_cmesh_t, gtreeid::Cint, user_data::Ptr{Ptr{Cvoid}})::Cvoid + @ccall libt8.t8_geom_load_tree_data_vertices(cmesh::t8_cmesh_t, gtreeid::t8_gloidx_t, user_data::Ptr{Ptr{Cvoid}})::Cvoid end """ @@ -18098,42 +17022,34 @@ function t8_geometry_zero_destroy(geom) end """ - t8_scheme_new_default_cxx() - -Return the default element implementation of t8code. + t8_scheme_new_default() ### Prototype ```c -t8_scheme_cxx_t * t8_scheme_new_default_cxx (void); +const t8_scheme_c * t8_scheme_new_default (void); ``` """ -function t8_scheme_new_default_cxx() - @ccall libt8.t8_scheme_new_default_cxx()::Ptr{t8_scheme_cxx_t} +function t8_scheme_new_default() + @ccall libt8.t8_scheme_new_default()::Ptr{Cint} end """ - t8_eclass_scheme_is_default(ts) - -Check whether a given eclass\\_scheme is one of the default schemes. + t8_eclass_scheme_is_default(scheme, eclass) -# Arguments -* `ts`:\\[in\\] A (pointer to a) scheme -# Returns -True (non-zero) if *ts* is one of the default schemes, false (zero) otherwise. ### Prototype ```c -int t8_eclass_scheme_is_default (t8_eclass_scheme_c *ts); +int t8_eclass_scheme_is_default (const t8_scheme_c *scheme, const t8_eclass_t eclass); ``` """ -function t8_eclass_scheme_is_default(ts) - @ccall libt8.t8_eclass_scheme_is_default(ts::Ptr{t8_eclass_scheme_c})::Cint +function t8_eclass_scheme_is_default(scheme, eclass) + @ccall libt8.t8_eclass_scheme_is_default(scheme::Ptr{Cint}, eclass::t8_eclass_t)::Cint end -const SC_CC = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc" +const SC_CC = "/opt/bin/x86_64-linux-gnu-libgfortran5-cxx11-mpi+mpich/x86_64-linux-gnu-gcc" const SC_CFLAGS = " " -const SC_CPP = "/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/bin/mpicc -E" +const SC_CPP = "/opt/bin/x86_64-linux-gnu-libgfortran5-cxx11-mpi+mpich/x86_64-linux-gnu-gcc -E" const SC_CPPFLAGS = "" @@ -18149,6 +17065,14 @@ const SC_ENABLE_MPICOMMSHARED = 1 const SC_ENABLE_MPIIO = 1 +const SC_HAVE_AINT_DIFF = 1 + +const SC_HAVE_MPI_UNSIGNED_LONG_LONG = 1 + +const SC_HAVE_MPI_SIGNED_CHAR = 1 + +const SC_HAVE_MPI_INT8_T = 1 + const SC_ENABLE_MPITHREAD = 1 const SC_ENABLE_MPIWINSHARED = 1 @@ -18159,12 +17083,16 @@ const SC_ENABLE_USE_REALLOC = 1 const SC_ENABLE_V4L2 = 1 +const SC_HAVE_ALIGNED_ALLOC = 1 + const SC_HAVE_BACKTRACE = 1 const SC_HAVE_BACKTRACE_SYMBOLS = 1 const SC_HAVE_FSYNC = 1 +const SC_HAVE_POSIX_MEMALIGN = 1 + const SC_HAVE_FABS = 1 const SC_HAVE_QSORT_R = 1 @@ -18203,11 +17131,9 @@ const SC_SIZEOF_UNSIGNED_INT = 4 const SC_SIZEOF_LONG = 8 -const SC_SIZEOF_LONG_LONG = 8 - const SC_SIZEOF_UNSIGNED_LONG = 8 -const SC_SIZEOF_UNSIGNED_LONG_LONG = 8 +const SC_SIZEOF_LONG_LONG = 8 const SC_VERSION = "0.0.0" @@ -18215,65 +17141,44 @@ const SC_VERSION_MAJOR = 0 const SC_VERSION_MINOR = 0 +const SC_VERSION_POINT = 0 - - - - - - - - - - - - - - - - - - - - - - +# Skipping MacroDefinition: _sc_const const const sc_MPI_COMM_WORLD = MPI.COMM_WORLD const sc_MPI_COMM_SELF = MPI.COMM_SELF -const sc_MPI_CHAR = MPI.CHAR +const sc_MPI_BYTE = MPI.BYTE -const sc_MPI_SIGNED_CHAR = MPI.SIGNED_CHAR +const sc_MPI_CHAR = MPI.CHAR const sc_MPI_UNSIGNED_CHAR = MPI.UNSIGNED_CHAR -const sc_MPI_BYTE = MPI.BYTE - const sc_MPI_SHORT = MPI.SHORT const sc_MPI_UNSIGNED_SHORT = MPI.UNSIGNED_SHORT const sc_MPI_INT = MPI.INT -const sc_MPI_INT8_T = MPI.INT8_T - const sc_MPI_UNSIGNED = MPI.UNSIGNED const sc_MPI_LONG = MPI.LONG const sc_MPI_UNSIGNED_LONG = MPI.UNSIGNED_LONG -const sc_MPI_LONG_LONG_INT = MPI.LONG_LONG_INT - const sc_MPI_UNSIGNED_LONG_LONG = MPI.UNSIGNED_LONG_LONG +const sc_MPI_SIGNED_CHAR = MPI.SIGNED_CHAR + +const sc_MPI_INT8_T = MPI.INT8_T + +const sc_MPI_LONG_LONG_INT = MPI.LONG_LONG_INT + const sc_MPI_FLOAT = MPI.FLOAT const sc_MPI_DOUBLE = MPI.DOUBLE - const sc_MPI_Comm = MPI.Comm const sc_MPI_Group = MPI.Group @@ -18282,37 +17187,10 @@ const sc_MPI_Datatype = MPI.Datatype const sc_MPI_Info = MPI.Info - - - - - - - - - - - - - - - - - const sc_MPI_File = MPI.File const sc_MPI_FILE_NULL = MPI.FILE_NULL - - - - - - - - - - const SC_EPS = 2.220446049250313e-16 const SC_1000_EPS = 1000.0 * 2.220446049250313e-16 @@ -18345,14 +17223,14 @@ const SC_LP_SILENT = 9 const SC_LP_THRESHOLD = SC_LP_INFO - - const T8_MPI_LOCIDX = sc_MPI_INT const T8_LOCIDX_MAX = INT32_MAX const T8_MPI_GLOIDX = sc_MPI_LONG_LONG_INT +const T8_GLOIDX_MAX = INT64_MAX + const T8_MPI_LINEARIDX = sc_MPI_UNSIGNED_LONG_LONG # Skipping MacroDefinition: T8_PADDING_SIZE ( sizeof ( void * ) ) @@ -18361,8 +17239,6 @@ const T8_PRECISION_EPS = SC_EPS const T8_PRECISION_SQRT_EPS = sqrt(T8_PRECISION_EPS) -const T8_CMESH_N_SUPPORTED_MSH_FILE_VERSIONS = 2 - # Skipping MacroDefinition: T8_MPI_ECLASS_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_eclass_t ) ) , sc_MPI_INT ) const T8_ECLASS_MAX_FACES = 6 @@ -18377,13 +17253,42 @@ const T8_ECLASS_MAX_CORNERS = 8 const T8_ECLASS_MAX_DIM = 3 +# Skipping MacroDefinition: T8_FACE_VERTEX_TO_TREE_VERTEX_VALUES { { { - 1 } } , /* vertex */ { { 0 } , { 1 } } , /* line */ { { 0 , 2 } , { 1 , 3 } , { 0 , 1 } , { 2 , 3 } } , /* quad */ { { 1 , 2 } , { 0 , 2 } , { 0 , 1 } } , /* triangle */ { { 0 , 2 , 4 , 6 } , { 1 , 3 , 5 , 7 } , { 0 , 1 , 4 , 5 } , { 2 , 3 , 6 , 7 } , { 0 , 1 , 2 , 3 } , { 4 , 5 , 6 , 7 } } , /* hex */ { { 1 , 2 , 3 } , { 0 , 2 , 3 } , { 0 , 1 , 3 } , { 0 , 1 , 2 } } , /* tet */ { { 1 , 2 , 4 , 5 } , { 0 , 2 , 3 , 5 } , { 0 , 1 , 3 , 4 } , { 0 , 1 , 2 } , { 3 , 4 , 5 } } , /* prism */ { { 0 , 2 , 4 } , { 1 , 3 , 4 } , { 0 , 1 , 4 } , { 2 , 3 , 4 } , { 0 , 1 , 2 , 3 } } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_FACE_EDGE_TO_TREE_EDGE_VALUES { { { - 1 } } , /* vertex */ { { 0 } } , /* line */ { { 0 } , { 1 } , { 2 } , { 3 } } , /* quad */ { { 0 } , { 1 } , { 2 } } , /* triangle */ { { 8 , 10 , 4 , 6 } , { 9 , 11 , 5 , 7 } , { 8 , 9 , 0 , 2 } , { 10 , 11 , 1 , 3 } , { 4 , 5 , 0 , 1 } , { 6 , 7 , 2 , 3 } } , /* hex */ { { 3 , 4 , 5 } , { 1 , 2 , 5 } , { 0 , 2 , 4 } , { 0 , 1 , 3 } } , /* tet */ { { 0 , 7 , 3 , 6 } , { 1 , 8 , 4 , 7 } , { 2 , 6 , 5 , 8 } , { 0 , 1 , 2 } , { 3 , 4 , 5 } } , /* prism */ { { - 1 } } , /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_FACE_TO_EDGE_NEIGHBOR_VALUES { { { - 1 } } , /* vertex */ { { - 1 } } , /* line */ { { 2 , 3 } , { 2 , 3 } , { 0 , 1 } , { 0 , 1 } } , /* quad */ { { 2 , 1 } , { 2 , 0 } , { 1 , 0 } } , /* triangle */ { { 0 , 1 , 2 , 3 } , { 0 , 1 , 2 , 3 } , { 4 , 5 , 6 , 7 } , { 4 , 5 , 6 , 7 } , { 8 , 9 , 10 , 11 } , { 8 , 9 , 10 , 11 } } , /* hex */ { { 0 , 1 , 2 } , { 0 , 3 , 4 } , { 1 , 3 , 5 } , { 2 , 4 , 5 } } , /* tet */ { { 1 , 2 , 4 , 5 } , { 0 , 2 , 3 , 5 } , { 0 , 1 , 3 , 4 } , { 6 , 7 , 8 } , { 6 , 7 , 8 } } , /* prism */ { { - 1 } } , /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_EDGE_VERTEX_TO_TREE_VERTEX_VALUES { { { - 1 } } , /* vertex */ { { 0 } , { 1 } } , /* line */ { { 0 , 2 } , { 1 , 3 } , { 0 , 1 } , { 2 , 3 } } , /* quad */ { { 1 , 2 } , { 0 , 2 } , { 0 , 1 } } , /* triangle */ { { 0 , 1 } , { 2 , 3 } , { 4 , 5 } , { 6 , 7 } , { 0 , 2 } , { 1 , 3 } , { 4 , 6 } , { 5 , 7 } , { 0 , 4 } , { 1 , 5 } , { 2 , 6 } , { 3 , 7 } } , /* hex */ { { 0 , 1 } , { 0 , 2 } , { 0 , 3 } , { 1 , 2 } , { 1 , 3 } , { 2 , 3 } } , /* tet */ { { 1 , 2 } , { 0 , 2 } , { 0 , 1 } , { 4 , 5 } , { 3 , 5 } , { 3 , 4 } , { 1 , 4 } , { 2 , 5 } , { 0 , 3 } } , /* prism */ { { - 1 } } , /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_EDGE_TO_FACE_VALUES { { { - 1 } } , /* vertex */ { { 0 } } , /* line */ { { 0 } , { 1 } , { 2 } , { 3 } } , /* quad */ { { 0 } , { 1 } , { 2 } } , /* triangle */ { { 2 , 4 } , { 3 , 4 } , { 2 , 5 } , { 3 , 5 } , { 0 , 4 } , { 1 , 4 } , { 0 , 5 } , { 1 , 5 } , { 0 , 2 } , { 1 , 2 } , { 0 , 3 } , { 1 , 3 } } , /* hex */ { { 2 , 3 } , { 1 , 3 } , { 1 , 2 } , { 0 , 3 } , { 0 , 2 } , { 0 , 1 } } , /* tet */ { { 0 , 3 } , { 1 , 3 } , { 2 , 3 } , { 0 , 4 } , { 1 , 4 } , { 2 , 4 } , { 0 , 2 } , { 0 , 1 } , { 1 , 2 } } , /* prism */ { { - 1 } } , /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_FACE_ORIENTATION_VALUES { { 0 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 0 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 0 , 0 , 0 , 0 , - 1 , - 1 } , /* quad */ { 0 , 0 , 0 , - 1 , - 1 , - 1 } , /* triangle */ { 0 , 1 , 1 , 0 , 0 , 1 } , /* hex */ { 0 , 1 , 0 , 1 , - 1 , - 1 } , /* tet */ { 1 , 0 , 1 , 0 , 1 , - 1 } , /* prism */ { 0 , 1 , 1 , 0 , 0 , - 1 } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_VTK_TO_T8_CORNER_NUMBER_VALUES { { 0 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 0 , 1 , 3 , 2 , - 1 , - 1 , - 1 , - 1 } , /* quad */ { 0 , 1 , 2 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* triangle */ { 0 , 1 , 3 , 2 , 4 , 5 , 7 , 6 } , /* hex */ { 0 , 2 , 1 , 3 , - 1 , - 1 , - 1 , - 1 } , /* tet */ { 0 , 2 , 1 , 3 , 5 , 4 , - 1 , - 1 } , /* prism */ { 0 , 1 , 3 , 2 , 4 , - 1 , - 1 , - 1 } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_T8_TO_VTK_CORNER_NUMBER_VALUES { { 0 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 0 , 1 , 3 , 2 , - 1 , - 1 , - 1 , - 1 } , /* quad */ { 0 , 1 , 2 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* triangle */ { 0 , 1 , 3 , 2 , 4 , 5 , 7 , 6 } , /* hex */ { 0 , 2 , 1 , 3 , - 1 , - 1 , - 1 , - 1 } , /* tet */ { 0 , 2 , 1 , 3 , 5 , 4 , - 1 , - 1 } , /* prism */ { 0 , 1 , 3 , 2 , 4 , - 1 , - 1 , - 1 } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_FACE_TYPES_VALUES { { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 } , /* vertex */ { 0 , 0 , - 1 , - 1 , - 1 , - 1 } , /* line */ { 1 , 1 , 1 , 1 , - 1 , - 1 } , /* quad */ { 1 , 1 , 1 , - 1 , - 1 , - 1 } , /* triangle */ { 2 , 2 , 2 , 2 , 2 , 2 } , /* hex */ { 3 , 3 , 3 , 3 , - 1 , - 1 } , /* tet */ { 2 , 2 , 2 , 3 , 3 , - 1 } , /* prism */ { 3 , 3 , 3 , 3 , 2 , - 1 } /* pyramid */ \ +#} + +# Skipping MacroDefinition: T8_ECLASS_BOUNDARY_COUNT_VALUES { { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , /* vertex */ { 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , /* line */ { 4 , 4 , 0 , 0 , 0 , 0 , 0 , 0 } , /* quad */ { 3 , 3 , 0 , 0 , 0 , 0 , 0 , 0 } , /* triangle */ { 8 , 12 , 6 , 0 , 0 , 0 , 0 , 0 } , /* hex */ { 4 , 6 , 0 , 4 , 0 , 0 , 0 , 0 } , /* tet */ { 6 , 9 , 3 , 2 , 0 , 0 , 0 , 0 } , /* prism */ { 5 , 8 , 1 , 4 , 0 , 0 , 0 , 0 } /* pyramid */ \ +#} + # Skipping MacroDefinition: T8_MPI_ELEMENT_SHAPE_TYPE ( T8_ASSERT ( sizeof ( int ) == sizeof ( t8_element_shape_t ) ) , sc_MPI_INT ) const T8_ELEMENT_SHAPE_MAX_FACES = 6 const T8_ELEMENT_SHAPE_MAX_CORNERS = 8 - const T8_VTK_LOCIDX = "Int32" const T8_VTK_GLOIDX = "Int32" @@ -18416,6 +17321,8 @@ const P4EST_ENABLE_MEMALIGN = 1 const P4EST_ENABLE_MPI = 1 +const P4EST_ENABLE_FILE_CHECKS = 1 + const P4EST_ENABLE_MPICOMMSHARED = 1 const P4EST_ENABLE_MPIIO = 1 @@ -18430,6 +17337,8 @@ const P4EST_ENABLE_VTK_COMPRESSION = 1 const P4EST_HAVE_FSYNC = 1 +const P4EST_HAVE_POSIX_MEMALIGN = 1 + const P4EST_HAVE_ZLIB = 1 const P4EST_LDFLAGS = "-Wl,-rpath -Wl,/workspace/destdir/lib -Wl,--enable-new-dtags -L/workspace/x86_64-linux-gnu-libgfortran5-cxx11-mpi+mpich/destdir/lib" @@ -18456,6 +17365,7 @@ const P4EST_VERSION_MAJOR = 0 const P4EST_VERSION_MINOR = 0 +const P4EST_VERSION_POINT = 0 const p4est_qcoord_compare = sc_int32_compare @@ -18465,7 +17375,6 @@ const P4EST_MPI_QCOORD = sc_MPI_INT const P4EST_VTK_QCOORD = "Int32" - const P4EST_QCOORD_MIN = INT32_MIN const P4EST_QCOORD_MAX = INT32_MAX @@ -18480,7 +17389,6 @@ const P4EST_MPI_TOPIDX = sc_MPI_INT const P4EST_VTK_TOPIDX = "Int32" - const P4EST_TOPIDX_MIN = INT32_MIN const P4EST_TOPIDX_MAX = INT32_MAX @@ -18497,7 +17405,6 @@ const P4EST_MPI_LOCIDX = sc_MPI_INT const P4EST_VTK_LOCIDX = "Int32" - const P4EST_LOCIDX_MIN = INT32_MIN const P4EST_LOCIDX_MAX = INT32_MAX @@ -18512,17 +17419,12 @@ const P4EST_MPI_GLOIDX = sc_MPI_LONG_LONG_INT const P4EST_VTK_GLOIDX = "Int64" - const P4EST_GLOIDX_MIN = INT64_MIN const P4EST_GLOIDX_MAX = INT64_MAX const P4EST_GLOIDX_1 = p4est_gloidx_t(1) - - - - const P4EST_DIM = 2 const P4EST_FACES = 2P4EST_DIM @@ -18557,26 +17459,6 @@ const P8EST_STRING = "p8est" const P8EST_ONDISK_FORMAT = 0x03000009 -const T8_CMESH_FORMAT = 0x0002 - -const T8_CMESH_VERTICES_ATTRIBUTE_KEY = 0 - -const T8_CMESH_GEOMETRY_ATTRIBUTE_KEY = 1 - -const T8_CMESH_CAD_EDGE_ATTRIBUTE_KEY = 2 - -const T8_CMESH_CAD_EDGE_PARAMETERS_ATTRIBUTE_KEY = 3 - -const T8_CMESH_CAD_FACE_ATTRIBUTE_KEY = T8_CMESH_CAD_EDGE_PARAMETERS_ATTRIBUTE_KEY + T8_ECLASS_MAX_EDGES - -const T8_CMESH_CAD_FACE_PARAMETERS_ATTRIBUTE_KEY = T8_CMESH_CAD_FACE_ATTRIBUTE_KEY + 1 - -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_KEY + 1 - -const T8_CPROFILE_NUM_STATS = 11 - const T8_SHMEM_BEST_TYPE = SC_SHMEM_WINDOW const T8_FOREST_FROM_FIRST = 0 @@ -18597,9 +17479,11 @@ const T8_FOREST_BALANCE_REPART = 1 const T8_FOREST_BALANCE_NO_REPART = 2 -const T8_PROFILE_NUM_STATS = 14 +const T8_PROFILE_NUM_STATS = 17 +const T8_CMESH_N_SUPPORTED_MSH_FILE_VERSIONS = 2 +const T8_CMESH_FORMAT = 0x0002 # exports const PREFIXES = ["t8_", "T8_"] diff --git a/src/T8code.jl b/src/T8code.jl index 87a8148..1075d53 100644 --- a/src/T8code.jl +++ b/src/T8code.jl @@ -262,14 +262,15 @@ function t8_free(ptr) Libt8.sc_free(t8_get_package_id(), ptr) end -# 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[]); +# typedef int (*t8_forest_adapt_t) (t8_forest_t forest, +# t8_forest_t forest_from, +# t8_locidx_t which_tree, +# const t8_eclass_t tree_class, +# t8_locidx_t lelement_id, +# const t8_scheme_c *scheme, +# const int is_family, +# const int num_elements, +# t8_element_t *elements[]); """ @t8_adapt_callback(callback) @@ -278,8 +279,8 @@ signature required for callback functions in [`t8_forest_adapt`](@ref). """ macro t8_adapt_callback(callback) :(@cfunction($callback, Cint, - (Ptr{t8_forest}, Ptr{t8_forest}, t8_locidx_t, t8_locidx_t, - Ptr{t8_eclass_scheme}, Cint, Cint, Ptr{Ptr{t8_element}}))) + (Ptr{t8_forest}, Ptr{t8_forest}, t8_locidx_t, t8_eclass_t, t8_locidx_t, + Ptr{t8_scheme}, Cint, Cint, Ptr{Ptr{t8_element}}))) end # typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, diff --git a/test/forest/test_element_volume.jl b/test/forest/test_element_volume.jl index 287ee63..0c51115 100644 --- a/test/forest/test_element_volume.jl +++ b/test/forest/test_element_volume.jl @@ -13,9 +13,10 @@ # elements and compute it element-specific. # \param[in] pyra A pyramid # \return The volume of the pyramid -function pyramid_control_volume(eclass_scheme::Ptr{t8_eclass_scheme}, +function pyramid_control_volume(scheme::Ptr{t8_scheme}, + tree_class::t8_eclass, pyra::Ptr{t8_element})::Cdouble - level = t8_element_level(eclass_scheme, pyra) + level = t8_element_get_level(scheme, tree_class, pyra) # Both pyramids and tets have 1/8th of the parents volume, if the shape does not switch. control_volume = 1.0 / 3.0 / (1 << (level * 3)) @@ -35,12 +36,12 @@ end for eclass in T8_ECLASS_ZERO:t8_eclass(T8_ECLASS_COUNT - 1) for level in 0:4 - scheme = t8_scheme_new_default_cxx() + scheme = t8_scheme_new_default() cmesh = t8_cmesh_new_hypercube(t8_eclass(eclass), comm, 0, 0, 0) forest = t8_forest_new_uniform(cmesh, scheme, level, 0, comm) # Compute the global number of elements. - global_num_elements = t8_forest_get_global_num_elements(forest) + global_num_elements = t8_forest_get_global_num_leaf_elements(forest) # Vertices have a volume of 0. control_volume = (eclass == T8_ECLASS_VERTEX) ? 0.0 : @@ -48,17 +49,18 @@ end local_num_trees = t8_forest_get_num_local_trees(forest) + # Get the scheme used by this forest + scheme = t8_forest_get_scheme(forest) + # Iterate over all elements. for itree in 0:(local_num_trees - 1) tree_class = t8_forest_get_tree_class(forest, itree) - eclass_scheme = t8_forest_get_eclass_scheme(forest, tree_class) - - tree_elements = t8_forest_get_tree_num_elements(forest, itree) + tree_elements = t8_forest_get_tree_num_leaf_elements(forest, itree) for ielement in 0:(tree_elements - 1) - element = t8_forest_get_element_in_tree(forest, itree, ielement) + element = t8_forest_get_leaf_element_in_tree(forest, itree, ielement) volume = t8_forest_element_volume(forest, itree, element) if eclass == T8_ECLASS_PYRAMID - shape_volume = pyramid_control_volume(eclass_scheme, element) + shape_volume = pyramid_control_volume(scheme, tree_class, element) # WORKAROUND: See `function pyramid_control_volume` for a comment # why the following test is split into two. @test abs(shape_volume - volume) <= epsilon || diff --git a/test/test_examples.jl b/test/test_examples.jl index 2610d74..6abc5af 100644 --- a/test/test_examples.jl +++ b/test/test_examples.jl @@ -1,4 +1,3 @@ - # This file makes sure to run all examples within the testing suite too. # It does not add extra sanity checks, assertions etc. to the examples, # but is intended to make sure the examples run without throwing errors. @@ -25,8 +24,9 @@ end # Unfortunately, step 5 and step 6 currently crash (1.) in Windows, (2.) in MacOS, # and (3.) with Julia older than 1.9, see related issues -# https://github.com/DLR-AMR/T8code.jl/issues/26, https://github.com/DLR-AMR/T8code.jl/issues/30, -# and https://github.com/DLR-AMR/T8code.jl/issues/104. +# https://github.com/DLR-AMR/T8code.jl/issues/26, +# https://github.com/DLR-AMR/T8code.jl/issues/30, +# https://github.com/DLR-AMR/T8code.jl/issues/104. # Until they are resolved, the two cases are skipped. # @testset "t8_step5_element_data" begin diff --git a/test/test_forestwrapper.jl b/test/test_forestwrapper.jl index a7ad48d..6249225 100644 --- a/test/test_forestwrapper.jl +++ b/test/test_forestwrapper.jl @@ -18,7 +18,7 @@ @test length(T8code.T8CODE_OBJECT_TRACKER) == 0 # Create a forest and wrap by `ForestWrapper` - scheme = t8_scheme_new_default_cxx() + scheme = t8_scheme_new_default() cmesh = t8_cmesh_new_hypercube(T8_ECLASS_QUAD, comm, 0, 0, 0) forest = t8_forest_new_uniform(cmesh, scheme, 0, 0, comm) wrapper_A = T8code.ForestWrapper(forest) @@ -26,7 +26,7 @@ @test length(T8code.T8CODE_OBJECT_TRACKER) == 1 # Create another forest and wrap by `ForestWrapper` - scheme = t8_scheme_new_default_cxx() + scheme = t8_scheme_new_default() cmesh = t8_cmesh_new_hypercube(T8_ECLASS_TRIANGLE, comm, 0, 0, 0) forest = t8_forest_new_uniform(cmesh, scheme, 0, 0, comm) wrapper_B = T8code.ForestWrapper(forest)