From e7a2b610c50a55370fdb29636a23ad62ee8f9c94 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 4 Aug 2021 10:52:51 -0700 Subject: [PATCH 01/53] Format doc string function --- src/PETSc.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PETSc.jl b/src/PETSc.jl index ba978d1c..d59392db 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -7,15 +7,15 @@ MPI.Initialized() || MPI.Init() using Libdl function _petsc_link(fname) -""" -[`$fname`](https://petsc.org/release/docs/manualpages/$fname.html) -""" + """ + [`$fname`](https://petsc.org/release/docs/manualpages/$fname.html) + """ end function _doc_external(fname) -""" -- PETSc Manual: $(_petsc_link(fname)) -""" + """ + - PETSc Manual: $(_petsc_link(fname)) + """ end include("const.jl") From 2336629bf6ab6a629f6523c857d4c4107e7115aa Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 19 Jul 2021 13:57:14 -0700 Subject: [PATCH 02/53] Start to rework using Clang.jl generated wrappers --- gen/Manifest.toml | 266 + gen/Project.toml | 7 + gen/generator.jl | 33 + gen/generator.toml | 434 + gen/prologue.jl | 25 + gen/wrap.jl | 172 + lib/petsc_library.jl | 70222 ++++++++++++++++++++++ src/LibPETSc.jl | 40 + src/LibPETSc_const.jl | 38 + src/{lib.jl => LibPETSc_lib.jl} | 40 +- src/{startup.jl => LibPETSc_startup.jl} | 22 +- src/PETSc.jl | 38 +- src/init.jl | 52 +- test/init.jl | 32 + test/runtests.jl | 35 +- 15 files changed, 71333 insertions(+), 123 deletions(-) create mode 100644 gen/Manifest.toml create mode 100644 gen/Project.toml create mode 100644 gen/generator.jl create mode 100644 gen/generator.toml create mode 100644 gen/prologue.jl create mode 100644 gen/wrap.jl create mode 100644 lib/petsc_library.jl create mode 100644 src/LibPETSc.jl create mode 100644 src/LibPETSc_const.jl rename src/{lib.jl => LibPETSc_lib.jl} (79%) rename src/{startup.jl => LibPETSc_startup.jl} (69%) create mode 100644 test/init.jl diff --git a/gen/Manifest.toml b/gen/Manifest.toml new file mode 100644 index 00000000..0b0ca431 --- /dev/null +++ b/gen/Manifest.toml @@ -0,0 +1,266 @@ +# This file is machine-generated - editing it directly is not advised + +[[ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" + +[[Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[CEnum]] +git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9" +uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" +version = "0.4.1" + +[[CSTParser]] +deps = ["Tokenize"] +git-tree-sha1 = "9723e1c07c1727082e169ca50789644a552fb023" +uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f" +version = "3.2.3" + +[[Clang]] +deps = ["CEnum", "Clang_jll", "Downloads", "Pkg", "TOML"] +git-tree-sha1 = "a546d217d3053b3a6422236edf2767e58041656e" +repo-rev = "master" +repo-url = "https://github.com/JuliaInterop/Clang.jl.git" +uuid = "40e3b903-d033-50b4-a0cc-940c62c95e31" +version = "0.14.0" + +[[Clang_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "libLLVM_jll"] +git-tree-sha1 = "a5923c06de3178dd755f4b9411ea8922a7ae6fb8" +uuid = "0ee61d77-7f21-5576-8119-9fcc46b10100" +version = "11.0.1+3" + +[[CommonMark]] +deps = ["Crayons", "JSON", "URIs"] +git-tree-sha1 = "1060c5023d2ac8210c73078cb7c0c567101d201c" +uuid = "a80b9123-70ca-4bc0-993e-6e3bcb318db6" +version = "0.8.2" + +[[Compat]] +deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] +git-tree-sha1 = "dc7dedc2c2aa9faf59a55c622760a25cbefbe941" +uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" +version = "3.31.0" + +[[CompilerSupportLibraries_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" + +[[Crayons]] +git-tree-sha1 = "3f71217b538d7aaee0b69ab47d9b7724ca8afa0d" +uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" +version = "4.0.4" + +[[DataStructures]] +deps = ["Compat", "InteractiveUtils", "OrderedCollections"] +git-tree-sha1 = "4437b64df1e0adccc3e5d1adbc3ac741095e4677" +uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +version = "0.18.9" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[DelimitedFiles]] +deps = ["Mmap"] +uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" + +[[Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" + +[[Downloads]] +deps = ["ArgTools", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[JLLWrappers]] +deps = ["Preferences"] +git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e" +uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" +version = "1.3.0" + +[[JSON]] +deps = ["Dates", "Mmap", "Parsers", "Unicode"] +git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "0.21.1" + +[[JuliaFormatter]] +deps = ["CSTParser", "CommonMark", "DataStructures", "Pkg", "Tokenize"] +git-tree-sha1 = "671676423c7c70673d4d2f03f2be2d6741c6884e" +uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899" +version = "0.15.1" + +[[LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" + +[[LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" + +[[LibGit2]] +deps = ["Base64", "NetworkOptions", "Printf", "SHA"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[LinearAlgebra]] +deps = ["Libdl"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[MPICH_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "c6cafe3f9747c0a0740611e2dffc4d37248fb691" +uuid = "7cb0a576-ebde-5e09-9194-50597f1243b4" +version = "3.4.2+0" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" + +[[MicrosoftMPI_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "e5c90234b3967684c9c6f87b4a54549b4ce21836" +uuid = "9237b28f-5490-5468-be7b-bb81f5f5e6cf" +version = "10.1.3+0" + +[[Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" + +[[NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" + +[[OpenBLAS32_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "ba4a8f683303c9082e84afba96f25af3c7fb2436" +uuid = "656ef2d0-ae68-5445-9ca0-591084a874a2" +version = "0.3.12+1" + +[[OrderedCollections]] +git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c" +uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +version = "1.4.1" + +[[PETSc_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "MPICH_jll", "MicrosoftMPI_jll", "OpenBLAS32_jll", "Pkg"] +git-tree-sha1 = "8384198eba24438cee406ec7ca8854acdcbbd2c8" +uuid = "8fa3689e-f0b9-5420-9873-adf6ccf46f2d" +version = "3.15.2+0" + +[[Parsers]] +deps = ["Dates"] +git-tree-sha1 = "c8abc88faa3f7a3950832ac5d6e690881590d6dc" +uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" +version = "1.1.0" + +[[Pkg]] +deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[Preferences]] +deps = ["TOML"] +git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a" +uuid = "21216c6a-2e73-6563-6e65-726566657250" +version = "1.2.2" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[SharedArrays]] +deps = ["Distributed", "Mmap", "Random", "Serialization"] +uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[SparseArrays]] +deps = ["LinearAlgebra", "Random"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + +[[Statistics]] +deps = ["LinearAlgebra", "SparseArrays"] +uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" + +[[TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" + +[[Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" + +[[Test]] +deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[Tokenize]] +git-tree-sha1 = "eee92eda3cc8e104b7e56ff4c1fcf0d78ca37c89" +uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624" +version = "0.5.18" + +[[URIs]] +git-tree-sha1 = "97bbe755a53fe859669cd907f2d96aee8d2c1355" +uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" +version = "1.3.0" + +[[UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" + +[[Zlib_jll]] +deps = ["Libdl"] +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" + +[[libLLVM_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8f36deef-c2a5-5394-99ed-8e07531fb29a" + +[[nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" + +[[p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" diff --git a/gen/Project.toml b/gen/Project.toml new file mode 100644 index 00000000..44889fef --- /dev/null +++ b/gen/Project.toml @@ -0,0 +1,7 @@ +[deps] +CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f" +Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31" +JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" +MPICH_jll = "7cb0a576-ebde-5e09-9194-50597f1243b4" +PETSc_jll = "8fa3689e-f0b9-5420-9873-adf6ccf46f2d" +Tokenize = "0796e94c-ce3b-5d07-9a54-7f471281c624" diff --git a/gen/generator.jl b/gen/generator.jl new file mode 100644 index 00000000..629a5f91 --- /dev/null +++ b/gen/generator.jl @@ -0,0 +1,33 @@ +#! /bin/bash julia --project generator.jl + +# This is modeled on: +# https://github.com/JuliaGPU/oneAPI.jl/blob/c040cba550659f82931ba054e6c321444e53c124/res/wrap.jl +# https://github.com/JuliaLang/SuiteSparse.jl/blob/76856153eef26c008f13520ffa12288e214fe02c/gen/generator.jl + +using Pkg +using Pkg.Artifacts +using PETSc_jll +using MPICH_jll + +include("wrap.jl") + +cd(@__DIR__) + +# headers +PETSc_toml = joinpath(dirname(pathof(PETSc_jll)), "..", "Artifacts.toml") +PETSc_dir = Pkg.Artifacts.ensure_artifact_installed("PETSc", PETSc_toml) + +MPICH_toml = joinpath(dirname(pathof(MPICH_jll)), "..", "Artifacts.toml") +MPICH_dir = Pkg.Artifacts.ensure_artifact_installed("MPICH", MPICH_toml) + +petsc_include_dir = joinpath(PETSc_dir, "include") |> normpath +petsc_h = joinpath(petsc_include_dir, "petsc.h") +@assert isfile(petsc_h) + +mpich_include_dir = joinpath(MPICH_dir, "include") |> normpath +mpi_h = joinpath(mpich_include_dir, "mpi.h") +@assert isfile(mpi_h) + +# run generator for all platforms +output_file = joinpath(@__DIR__, "..", "lib", "petsc_library.jl") +wrap(output_file, petsc_include_dir, mpich_include_dir) diff --git a/gen/generator.toml b/gen/generator.toml new file mode 100644 index 00000000..1c9b286f --- /dev/null +++ b/gen/generator.toml @@ -0,0 +1,434 @@ +[general] +library_name = "$petsc_library" + +use_julia_native_enum_type = true +use_deterministic_symbol = true +auto_mutability = true +prologue_file_path = "./prologue.jl" +# epilogue_file_path = "./epilogue.jl" + +printer_blacklist = [ +# +# Defined in the prologue +# + "PetscOptions", "_n_PetscOptions", + "PetscViewer", "_p_PetscViewer", + "PetscObject", "_p_PetscObject", + "Mat", "_p_Mat", +# +# Remove types defined in const.jl +# + "PetscErrorCode", + "PetscBool", + "PetscDataType", +# +# Remove types defined by $define +# + "PetscInt", + "PetscScalar", + "PetscReal", + "PetscComplex", +# +# Remove the stuff we get from MPI.jl +# + "MPI_Datatype", + "MPI_Comm", + "MPI_Win", + "MPI_File", + "MPI_Op", + "MPI_Info", + "MPI_Aint", + "MPI_Offset", + "MPI_Status", + "MPI_Request", + "MPI_Group", +# +# MPI_Status... Not handled currently in MPI.jl +# + "MPIU_File_write_all", + "MPIU_File_read_all", + "MPIU_File_write_at", + "MPIU_File_read_at", + "MPIU_File_write_at_all", + "MPIU_File_read_at_all", +# +# MPI_Request... Not handled currently in MPI.jl +# + "PetscPostIrecvInt", + "PetscPostIrecvScalar", + "PetscCommBuildTwoSidedFReq", +# +# MPI_Group... Not handled currently in MPI.jl +# + "PetscSFSetUpRanks", + "PetscSFGetGroups", +# +# Remove functions marked _Private +# + "PetscAbortFindSourceFile_Private", + "PetscObjectComposeFunction_Private", + "PetscOptionsBegin_Private", + "PetscObjectOptionsBegin_Private", + "PetscOptionsEnd_Private", + "PetscOptionsEnum_Private", + "PetscOptionsInt_Private", + "PetscOptionsReal_Private", + "PetscOptionsScalar_Private", + "PetscOptionsName_Private", + "PetscOptionsString_Private", + "PetscOptionsBool_Private", + "PetscOptionsBoolGroupBegin_Private", + "PetscOptionsBoolGroup_Private", + "PetscOptionsBoolGroupEnd_Private", + "PetscOptionsFList_Private", + "PetscOptionsEList_Private", + "PetscOptionsRealArray_Private", + "PetscOptionsScalarArray_Private", + "PetscOptionsIntArray_Private", + "PetscOptionsStringArray_Private", + "PetscOptionsBoolArray_Private", + "PetscOptionsEnumArray_Private", + "PetscOptionsDeprecated_Private", + "PetscObjectQueryFunction_Private", + "PetscFunctionListAdd_Private", + "PetscFunctionListFind_Private", + "PetscOptionsViewer_Private", +# +# Need PetscOptionItems to work with interpotated values +# + "_n_PetscOptionItem", + "_p_PetscOptionItems", + "PetscOptionItems", + "PetscOptionsHead", + "PetscObjectProcessOptionsHandlers", + "TSAdjointSetFromOptions", + "TSAdaptSetFromOptions", + "TSGLLEAdaptSetFromOptions", +# +# Need PetscTable to work with interpotated values +# + "_n_PetscTable", + "PetscTable", + "PetscTablePosition", + "PetscHash", + "PetscHashStep", + "PetscTableCreate", + "PetscTableCreateCopy", + "PetscTableDestroy", + "PetscTableGetCount", + "PetscTableIsEmpty", + "PetscTableAddExpand", + "PetscTableAddCountExpand", + "PetscTableGetHeadPosition", + "PetscTableGetNext", + "PetscTableRemoveAll", + "PetscTableAdd", + "PetscTableAddCount", + "PetscTableFind", +# +# Need PetscDrawViewPorts to work with interpotated values +# + "PetscDrawViewPorts", + "PetscDrawViewPortsCreate", + "PetscDrawViewPortsCreateRect", + "PetscDrawViewPortsDestroy", + "PetscDrawViewPortsSet", +# +# Need PetscSFNode to work with interpotated values +# + "PetscSFNode", + "PetscSFSetGraph", + "PetscSFGetGraph", +# +# Need PetscLayout to work with interpotated values +# + "_n_PetscLayout", + "PetscLayout", + "PetscLayoutFindOwner", + "PetscLayoutFindOwnerIndex", + "PetscLayoutCreate", + "PetscLayoutCreateFromSizes", + "PetscLayoutCreateFromRanges", + "PetscLayoutSetUp", + "PetscLayoutDestroy", + "PetscLayoutDuplicate", + "PetscLayoutReference", + "PetscLayoutSetLocalSize", + "PetscLayoutGetLocalSize", + "PetscLayoutSetSize", + "PetscLayoutGetSize", + "PetscLayoutSetBlockSize", + "PetscLayoutGetBlockSize", + "PetscLayoutGetRange", + "PetscLayoutGetRanges", + "PetscLayoutCompare", + "PetscLayoutSetISLocalToGlobalMapping", + "PetscLayoutMapLocal", + "PetscParallelSortInt", + "ISGetLayout", + "MatGetLayouts", + "MatSetLayouts", + "VecGetLayout", + "VecSetLayout", + "PetscSFSetGraphWithPattern", + "PetscSFSetGraphLayout", + "PetscSFCreateFromLayouts", + "PetscLayoutsCreateSF", + "PetscSFCreateByMatchingIndices", + "PetscSectionGetPointLayout", + "PetscSectionGetValueLayout", +# +# Need Vecs to work with interpotated values +# + "_n_Vecs", + "Vecs", + "VecsDestroy", + "VecsCreateSeq", + "VecsCreateSeqWithArray", + "VecsDuplicate", + "MatSolves", +# +# Need VecTaggerBox to work with interpotated values +# + "VecTaggerBox", + "VecTaggerComputeBoxes", + "VecTaggerAbsoluteSetBox", + "VecTaggerAbsoluteGetBox", + "VecTaggerRelativeSetBox", + "VecTaggerRelativeGetBox", + "VecTaggerCDFSetBox", + "VecTaggerCDFGetBox", +# +# Need MatStencil to work with interpotated values +# + "MatStencil", + "MatSetValuesStencil", + "MatSetValuesBlockedStencil", + "MatZeroRowsStencil", + "MatZeroRowsColumnsStencil", + "DMDACreatePatchIS", + "DMDAConvertToCell", + "DMDAConvertToCell", + "DMPatchZoom", + "DMPatchGetPatchSize", + "DMPatchSetPatchSize", + "DMPatchGetCommSize", + "DMPatchSetCommSize", + "DMPatchCreateGrid", +# +# Need MatFactorInfo to work with interpotated values +# + "MatFactorInfo", + "MatFactorInfoInitialize", + "MatCholeskyFactor", + "MatCholeskyFactorSymbolic", + "MatCholeskyFactorNumeric", + "MatLUFactor", + "MatILUFactor", + "MatLUFactorSymbolic", + "MatILUFactorSymbolic", + "MatICCFactorSymbolic", + "MatICCFactor", + "MatLUFactorNumeric", + "MatQRFactor", + "MatQRFactorSymbolic", + "MatQRFactorNumeric", +# +# Need PetscHashFormKey to work with interpotated values +# + "_PetscHashFormKey", + "PetscHashFormKey", + "PetscHashFormKeySort", + "PetscFEIntegrateResidual", + "PetscFEIntegrateHybridResidual", + "PetscFEIntegrateJacobian", +# +# Need DMInterpolationInfo to work with interpotated values +# + "_DMInterpolationInfo", + "DMInterpolationInfo", + "DMInterpolationCreate", + "DMInterpolationSetDim", + "DMInterpolationGetDim", + "DMInterpolationSetDof", + "DMInterpolationGetDof", + "DMInterpolationAddPoints", + "DMInterpolationSetUp", + "DMInterpolationGetCoordinates", + "DMInterpolationGetVector", + "DMInterpolationRestoreVector", + "DMInterpolationEvaluate", + "DMInterpolationDestroy", +# +# Need DMDALocalInfo to work with interpotated values +# + "DMDALocalInfo", + "DMDAGetLocalInfo", +# +# Need PetscTabulation to work with interpotated values +# + "_p_PetscTabulation", + "PetscTabulation", + "PetscFVGetCellTabulation", + "PetscFVCreateTabulation", + "PetscDSGetTabulation", + "PetscDSGetFaceTabulation", + "PetscFEGetCellTabulation", + "PetscFEGetFaceTabulation", + "PetscFEGetFaceCentroidTabulation", + "PetscFECreateTabulation", + "PetscFEComputeTabulation", + "PetscTabulationDestroy", +# +# Need PetscFEGeom to work with interpotated values +# + "_n_PetscFEGeom", + "PetscFEGeom", + "PetscDualSpaceTransform", + "PetscFECreateCellGeometry", + "DMFieldCreateFEGeom", + "PetscFEDestroyCellGeometry", + "PetscFEPushforward", + "PetscFEPushforwardGradient", + "PetscFEPushforwardHessian", + "PetscFEIntegrate", + "PetscFEIntegrateBd", + "PetscFEIntegrateBdResidual", + "PetscFEIntegrateBdJacobian", + "PetscFEIntegrateHybridJacobian", + "PetscDualSpaceTransformGradient", + "PetscDualSpaceTransformHessian", + "PetscDualSpacePullback", + "PetscDualSpacePushforward", + "PetscDualSpacePushforwardGradient", + "PetscDualSpacePushforwardHessian", + "PetscFEGeomCreate", + "PetscFEGeomGetChunk", + "PetscFEGeomRestoreChunk", + "PetscFEGeomComplete", + "PetscFEGeomDestroy", + "PetscDualSpaceApply", + "PetscDualSpaceApplyDefault", +# +# Need DMDACoor2d and DMDACoor3d to work with interpotated values +# + "DMDACoor2d", + "DMDACoor3d", +# +# Need PetscFVFaceGeom and PetscFVCellGeom to work with interpotated values +# + "PetscFVFaceGeom", + "PetscFVCellGeom", + "PetscDualSpaceApplyFVM", + "PetscFVIntegrateRHSFunction", + "DMPlexGetFaceGeometry", + "DMPlexRestoreFaceGeometry", + "PetscFVFaceGeom", + "PetscFVIntegrateRHSFunction", + "DMPlexGetFaceGeometry", + "DMPlexRestoreFaceGeometry", +# +# Need DMStagStencil to work with interpotated values +# + "DMStagStencil", + "DMStagMatGetValuesStencil", + "DMStagVecGetValuesStencil", + "DMStagVecSetValuesStencil", + "DMStagMatSetValuesStencil", +# +# Need TSMonitorLGCtxNetwork to work with interpotated values +# + "_n_TSMonitorLGCtxNetwork", + "TSMonitorLGCtxNetwork", + "TSMonitorLGCtxNetworkDestroy", + "TSMonitorLGCtxNetworkCreate", +# +# Other stuff we have to remove.... for now +# + "PETSC_MAX_INT", "PETSC_MIN_INT", # Windows failure + "petsc_mpiu_2scalar", + "petsc_mpiu_2int", + "MatScalar", + "MatReal", + "PetscFloat", + "PetscComplex", + "PETSC_RESTRICT", + "PETSC_C_RESTRICT", + "PETSC_CXX_RESTRICT", + "PETSC_FORTRAN_CHARLEN_T", + "IS_COLORING_MAX", + "PETSC_IS_COLORING_MAX", + "PETSC_IS_COLORING_VALUE_TYPE_F", + "PETSC_PREFETCH_HINT_NTA", + "PETSC_PREFETCH_HINT_T0", + "PETSC_PREFETCH_HINT_T1", + "PETSC_PREFETCH_HINT_T2", + "PETSC_UINTPTR_T", + "PETSC_UNUSED", + "PETSC_FUNCTION", + "CHKMEMA", + "PetscStackPop", + "PETSC_INLINE", + "PETSC_VISIBILITY_PUBLIC", + "PETSC_VERSION_", + "PC_MG_CASCADE", + "PetscDefined_arg_1", + "PetscDefined_arg_", + "TSEIMEXType", + "PETSC_FUNCTION_NAME", + "PetscInt64_FMT", + "PetscInt_FMT", + "MPIU_C_COMPLEX", + "MPIU_C_DOUBLE_COMPLEX", + "MPIU_COMPLEX", + "MPIU_SCALAR", + "MPIU_MATSCALAR", + "PETSC_PI", + "PETSC_PHI", + "PETSC_SQRT2", + "PETSC_IGNORE", + "PETSC_NULL", + "MPIU_2PETSCLOGDOUBLE", + "PETSC_BITS_PER_BYTE", + "PETSC_VIEWER_ASCII_VTK_ATTR", + "PETSC_VIEWER_ASCII_VTK_CELL_ATTR", + "PETSC_VIEWER_ASCII_VTK_COORDS_ATTR", + "PETSC_VIEWER_STDERR_SELF", + "PETSC_VIEWER_STDERR_WORLD", + "PETSC_VIEWER_STDOUT_WORLD", + "PETSC_VIEWER_STDOUT_SELF", + "PETSC_VIEWER_DRAW_WORLD", + "PETSC_VIEWER_DRAW_SELF", + "PETSC_VIEWER_SOCKET_WORLD", + "PETSC_VIEWER_SOCKET_SELF", + "PETSC_VIEWER_BINARY_WORLD", + "PETSC_VIEWER_BINARY_SELF", + "PETSC_VIEWER_MATLAB_WORLD", + "PETSC_VIEWER_MATLAB_SELF", + "PETSC_VIEWER_MATHEMATICA_WORLD", + "PETSC_MATLAB_ENGINE_WORLD", + "PETSC_MATLAB_ENGINE_SELF", + "MPIU_REPLACE", + "KSPCGNASH", + "KSPCGSTCG", + "KSPCGGLTR", + "PC_SIDE_MAX", + "KSP_NORM_MAX", + "KSP_DIVERGED_PCSETUP_FAILED_DEPRECATED", + "SNES_CONVERGED_TR_DELTA_DEPRECATED", + "KSPDefaultConverged", + "KSPDefaultConvergedDestroy", + "KSPDefaultConvergedCreate", + "KSPDefaultConvergedSetUIRNorm", + "KSPDefaultConvergedSetUMIRNorm", + "KSPSkipConverged", + "SNESSkipConverged", + ] + +[codegen] +use_ccall_macro = false +function_argument_conflict_symbols = ["__PETSC__"] + +[codegen.macro] +macro_mode = "basic" + diff --git a/gen/prologue.jl b/gen/prologue.jl new file mode 100644 index 00000000..f4e964f0 --- /dev/null +++ b/gen/prologue.jl @@ -0,0 +1,25 @@ +using MPI +const MPI_Comm = MPI.MPI_Comm +const MPI_Datatype = MPI.MPI_Datatype +const MPI_File = MPI.MPI_File +const MPI_Aint = MPI.MPI_Aint +const MPI_Info = MPI.MPI_Info +const MPI_Win = MPI.MPI_Win +const MPI_Offset = MPI.MPI_Offset +const MPI_Op = MPI.MPI_Op +const MPI_UNSIGNED_SHORT = MPI.MPI_UNSIGNED_SHORT +const MPI_INT64_T = MPI.MPI_INT64_T +const MPI_FLOAT = MPI.MPI_FLOAT +const MPI_COMM_SELF = MPI.MPI_COMM_SELF +const MPI_DOUBLE = MPI.MPI_DOUBLE +const MPI_SUM = MPI.MPI_SUM +const MPI_MAX = MPI.MPI_MAX +const MPI_MIN = MPI.MPI_MIN +const MPI_REPLACE = MPI.MPI_REPLACE + +# We know these will be Cvoid, so just set them to be that +const PetscOptions = Ptr{Cvoid} +const PetscViewer = Ptr{Cvoid} +const PetscObject = Ptr{Cvoid} +const Vec = Ptr{Cvoid} +const Mat = Ptr{Cvoid} diff --git a/gen/wrap.jl b/gen/wrap.jl new file mode 100644 index 00000000..f35921d3 --- /dev/null +++ b/gen/wrap.jl @@ -0,0 +1,172 @@ +using Clang.Generators +using Clang.Generators.JLLEnvs +using CSTParser +using JuliaFormatter + +## rewrite passes +struct Edit{T} + loc::T + text::String +end +mutable struct State + offset::Int + edits::Vector{Edit} +end + +function pass(x, state, f = (x, state) -> nothing) + f(x, state) + if length(x) > 0 + for a in x + pass(a, state, f) + end + else + state.offset += x.fullspan + end + state +end + +# insert `@chk` before each function with a `ccall` returning a checked type` +checked_types = ["PetscErrorCode"] +function add_chk(x, state) + if x isa CSTParser.EXPR && x.head == :function + _, def, body, _ = x + @assert body isa CSTParser.EXPR && body.head == :block + @assert length(body) == 1 + + # Clang.jl-generated ccalls should be directly part of a function definition + call = body.args[1] + if call isa CSTParser.EXPR && + call.head == :call && + call[1].val == "ccall" + + # get the ccall return type + rv = call[5] + + if rv.val in checked_types + push!( + state.edits, + Edit( + state.offset + x[1].span + 1 + x[2].span + 1 + 4, + "@chk ", + ), + ) + end + end + end +end + +# make every function have $UnionPetscLib as the first argument +function add_UnionPetscLib(x, state) + if x isa CSTParser.EXPR && x.head == :function + _, def, body, _ = x + @assert body isa CSTParser.EXPR && body.head == :block + @assert length(body) == 1 + + # Clang.jl-generated ccalls should be directly part of a function definition + call = body.args[1] + if call isa CSTParser.EXPR && + call.head == :call && + call[1].val == "ccall" + push!( + state.edits, + Edit( + state.offset + x[1].span + 1 + x[2][1].span + 1, + "::\$UnionPetscLib, ", + ), + ) + end + end +end + +# make every function have $UnionPetscLib as the first argument +function add_for_petsc(x, state) + if x isa CSTParser.EXPR && x.head == :function + _, def, body, _ = x + @assert body isa CSTParser.EXPR && body.head == :block + @assert length(body) == 1 + + # Clang.jl-generated ccalls should be directly part of a function definition + call = body.args[1] + if call isa CSTParser.EXPR && ( + (call.head == :call && call[1].val == "ccall") || + (call.head == :macrocall && call[1].val == "@chk") + ) + push!(state.edits, Edit(state.offset, "@for_petsc ")) + end + end +end + +# make every function have $UnionPetscLib as the first argument +function add_for_interpolate(x, state, val) + if x isa CSTParser.EXPR && x.head == :IDENTIFIER && x.val == val + push!(state.edits, Edit(state.offset, "\$")) + end +end + +# make petsc_library + +function apply(text, edit::Edit{Int}) + string(text[1:(edit.loc)], edit.text, text[nextind(text, edit.loc):end]) +end + +function mangle_functions(output_file) + let file = output_file + text = read(file, String) + + for mod in ( + add_UnionPetscLib, + add_chk, + add_for_petsc, + (x, s) -> add_for_interpolate(x, s, "PetscReal"), + (x, s) -> add_for_interpolate(x, s, "PetscInt"), + (x, s) -> add_for_interpolate(x, s, "PetscComplex"), + (x, s) -> add_for_interpolate(x, s, "PetscScalar"), + ) + state = State(0, Edit[]) + ast = CSTParser.parse(text, true) + + state.offset = 0 + pass(ast, state, mod) + + state.offset = 0 + sort!( + state.edits, + lt = (a, b) -> first(a.loc) < first(b.loc), + rev = true, + ) + + for i in 1:length(state.edits) + text = apply(text, state.edits[i]) + end + end + + write(output_file, text) + end +end + +function wrap(output_file, petsc_include_dir, mpi_include_dir) + petsc_h = joinpath(petsc_include_dir, "petsc.h") + @assert isfile(petsc_h) + + mpi_h = joinpath(mpi_include_dir, "mpi.h") + @assert isfile(mpi_h) + + options = load_options(joinpath(@__DIR__, "generator.toml")) + options["general"]["output_file_path"] = output_file + + args = get_default_args() + + push!(args, "-I$petsc_include_dir") + push!(args, "-isystem$mpi_include_dir") + + header_files = [petsc_h] + + ctx = create_context(header_files, args, options) + + build!(ctx) + + mangle_functions(output_file) + format(output_file) + + return output_file +end diff --git a/lib/petsc_library.jl b/lib/petsc_library.jl new file mode 100644 index 00000000..3e4556f8 --- /dev/null +++ b/lib/petsc_library.jl @@ -0,0 +1,70222 @@ +using MPI +const MPI_Comm = MPI.MPI_Comm +const MPI_Datatype = MPI.MPI_Datatype +const MPI_File = MPI.MPI_File +const MPI_Aint = MPI.MPI_Aint +const MPI_Info = MPI.MPI_Info +const MPI_Win = MPI.MPI_Win +const MPI_Offset = MPI.MPI_Offset +const MPI_Op = MPI.MPI_Op +const MPI_UNSIGNED_SHORT = MPI.MPI_UNSIGNED_SHORT +const MPI_INT64_T = MPI.MPI_INT64_T +const MPI_FLOAT = MPI.MPI_FLOAT +const MPI_COMM_SELF = MPI.MPI_COMM_SELF +const MPI_DOUBLE = MPI.MPI_DOUBLE +const MPI_SUM = MPI.MPI_SUM +const MPI_MAX = MPI.MPI_MAX +const MPI_MIN = MPI.MPI_MIN +const MPI_REPLACE = MPI.MPI_REPLACE + +# We know these will be Cvoid, so just set them to be that +const PetscOptions = Ptr{Cvoid} +const PetscViewer = Ptr{Cvoid} +const PetscObject = Ptr{Cvoid} +const Vec = Ptr{Cvoid} +const Mat = Ptr{Cvoid} +const PetscObject = Ptr{Cvoid} + +const __darwin_off_t = Int64 + +mutable struct ADIOI_FileD end + +const off_t = __darwin_off_t + +const PetscClassId = Cint + +const PetscMPIInt = Cint + +@enum PetscEnum::UInt32 begin + ENUM_DUMMY = 0 +end + +const PetscShort = Cshort + +const PetscChar = Cchar + +const PetscInt64 = Int64 + +const PetscBLASInt = Cint + +@enum PetscCopyMode::UInt32 begin + PETSC_COPY_VALUES = 0 + PETSC_OWN_POINTER = 1 + PETSC_USE_POINTER = 2 +end + +const PetscLogDouble = Cdouble + +mutable struct _p_PetscToken end + +const PetscToken = Ptr{_p_PetscToken} + +const PetscObjectId = PetscInt64 + +const PetscObjectState = PetscInt64 + +mutable struct _n_PetscFunctionList end + +const PetscFunctionList = Ptr{_n_PetscFunctionList} + +@enum PetscFileMode::Int32 begin + FILE_MODE_UNDEFINED = -1 + FILE_MODE_READ = 0 + FILE_MODE_WRITE = 1 + FILE_MODE_APPEND = 2 + FILE_MODE_UPDATE = 3 + FILE_MODE_APPEND_UPDATE = 4 +end + +const PetscDLHandle = Ptr{Cvoid} + +@enum PetscDLMode::UInt32 begin + PETSC_DL_DECIDE = 0 + PETSC_DL_NOW = 1 + PETSC_DL_LOCAL = 2 +end + +mutable struct _n_PetscObjectList end + +const PetscObjectList = Ptr{_n_PetscObjectList} + +mutable struct _n_PetscDLLibrary end + +const PetscDLLibrary = Ptr{_n_PetscDLLibrary} + +mutable struct _p_PetscContainer end + +const PetscContainer = Ptr{_p_PetscContainer} + +mutable struct _p_PetscRandom end + +const PetscRandom = Ptr{_p_PetscRandom} + +@enum PetscBinarySeekType::UInt32 begin + PETSC_BINARY_SEEK_SET = 0 + PETSC_BINARY_SEEK_CUR = 1 + PETSC_BINARY_SEEK_END = 2 +end + +@enum PetscBuildTwoSidedType::Int32 begin + PETSC_BUILDTWOSIDED_NOTSET = -1 + PETSC_BUILDTWOSIDED_ALLREDUCE = 0 + PETSC_BUILDTWOSIDED_IBARRIER = 1 + PETSC_BUILDTWOSIDED_REDSCATTER = 2 +end + +@enum InsertMode::UInt32 begin + NOT_SET_VALUES = 0 + INSERT_VALUES = 1 + ADD_VALUES = 2 + MAX_VALUES = 3 + MIN_VALUES = 4 + INSERT_ALL_VALUES = 5 + ADD_ALL_VALUES = 6 + INSERT_BC_VALUES = 7 + ADD_BC_VALUES = 8 +end + +@enum PetscSubcommType::UInt32 begin + PETSC_SUBCOMM_GENERAL = 0 + PETSC_SUBCOMM_CONTIGUOUS = 1 + PETSC_SUBCOMM_INTERLACED = 2 +end + +mutable struct _n_PetscSubcomm + parent::MPI_Comm + dupparent::MPI_Comm + child::MPI_Comm + n::PetscMPIInt + color::PetscMPIInt + subsize::Ptr{PetscMPIInt} + type::PetscSubcommType + subcommprefix::Ptr{Cchar} + _n_PetscSubcomm() = new() +end + +const PetscSubcomm = Ptr{_n_PetscSubcomm} + +mutable struct _PetscHeap end + +const PetscHeap = Ptr{_PetscHeap} + +mutable struct _n_PetscShmComm end + +const PetscShmComm = Ptr{_n_PetscShmComm} + +mutable struct _n_PetscOmpCtrl end + +const PetscOmpCtrl = Ptr{_n_PetscOmpCtrl} + +mutable struct _n_PetscSegBuffer end + +const PetscSegBuffer = Ptr{_n_PetscSegBuffer} + +mutable struct _n_PetscOptionsHelpPrinted end + +const PetscOptionsHelpPrinted = Ptr{_n_PetscOptionsHelpPrinted} + +@enum PetscMemType::UInt32 begin + PETSC_MEMTYPE_HOST = 0 + PETSC_MEMTYPE_DEVICE = 1 + # PETSC_MEMTYPE_CUDA = 1 + PETSC_MEMTYPE_NVSHMEM = 17 + PETSC_MEMTYPE_HIP = 3 +end + +@for_petsc function PetscSignReal(::$UnionPetscLib, a) + ccall((:PetscSignReal, $petsc_library), $PetscReal, ($PetscReal,), a) +end + +@for_petsc function PetscCMPLX(::$UnionPetscLib, x, y) + ccall( + (:PetscCMPLX, $petsc_library), + $PetscComplex, + ($PetscReal, $PetscReal), + x, + y, + ) +end + +@enum PetscScalarPrecision::UInt32 begin + PETSC_SCALAR_DOUBLE = 0 + PETSC_SCALAR_SINGLE = 1 + PETSC_SCALAR_LONG_DOUBLE = 2 + PETSC_SCALAR_HALF = 3 +end + +@for_petsc function PetscIsInfReal(::$UnionPetscLib, arg1) + ccall((:PetscIsInfReal, $petsc_library), PetscBool, ($PetscReal,), arg1) +end + +@for_petsc function PetscIsNanReal(::$UnionPetscLib, arg1) + ccall((:PetscIsNanReal, $petsc_library), PetscBool, ($PetscReal,), arg1) +end + +@for_petsc function PetscIsNormalReal(::$UnionPetscLib, arg1) + ccall((:PetscIsNormalReal, $petsc_library), PetscBool, ($PetscReal,), arg1) +end + +@for_petsc function PetscIsInfOrNanReal(::$UnionPetscLib, v) + ccall((:PetscIsInfOrNanReal, $petsc_library), PetscBool, ($PetscReal,), v) +end + +@for_petsc function PetscIsInfScalar(::$UnionPetscLib, v) + ccall((:PetscIsInfScalar, $petsc_library), PetscBool, ($PetscScalar,), v) +end + +@for_petsc function PetscIsNanScalar(::$UnionPetscLib, v) + ccall((:PetscIsNanScalar, $petsc_library), PetscBool, ($PetscScalar,), v) +end + +@for_petsc function PetscIsInfOrNanScalar(::$UnionPetscLib, v) + ccall( + (:PetscIsInfOrNanScalar, $petsc_library), + PetscBool, + ($PetscScalar,), + v, + ) +end + +@for_petsc function PetscIsNormalScalar(::$UnionPetscLib, v) + ccall((:PetscIsNormalScalar, $petsc_library), PetscBool, ($PetscScalar,), v) +end + +@for_petsc function PetscIsCloseAtTol(::$UnionPetscLib, arg1, arg2, arg3, arg4) + ccall( + (:PetscIsCloseAtTol, $petsc_library), + PetscBool, + ($PetscReal, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscEqualReal(::$UnionPetscLib, arg1, arg2) + ccall( + (:PetscEqualReal, $petsc_library), + PetscBool, + ($PetscReal, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PetscEqualScalar(::$UnionPetscLib, arg1, arg2) + ccall( + (:PetscEqualScalar, $petsc_library), + PetscBool, + ($PetscScalar, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function PetscPowInt(::$UnionPetscLib, base, power) + ccall( + (:PetscPowInt, $petsc_library), + $PetscInt, + ($PetscInt, $PetscInt), + base, + power, + ) +end + +@for_petsc function PetscPowInt64(::$UnionPetscLib, base, power) + ccall( + (:PetscPowInt64, $petsc_library), + PetscInt64, + ($PetscInt, $PetscInt), + base, + power, + ) +end + +@for_petsc function PetscPowRealInt(::$UnionPetscLib, base, power) + ccall( + (:PetscPowRealInt, $petsc_library), + $PetscReal, + ($PetscReal, $PetscInt), + base, + power, + ) +end + +@for_petsc function PetscPowScalarInt(::$UnionPetscLib, base, power) + ccall( + (:PetscPowScalarInt, $petsc_library), + $PetscScalar, + ($PetscScalar, $PetscInt), + base, + power, + ) +end + +@for_petsc function PetscPowScalarReal(::$UnionPetscLib, base, power) + ccall( + (:PetscPowScalarReal, $petsc_library), + $PetscScalar, + ($PetscScalar, $PetscReal), + base, + power, + ) +end + +@for_petsc function PetscLinearRegression( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscLinearRegression, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSetHelpVersionFunctions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSetHelpVersionFunctions, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscCommDuplicate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscCommDuplicate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{MPI_Comm}, Ptr{Cint}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscCommDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscCommDestroy, $petsc_library), + PetscErrorCode, + (Ptr{MPI_Comm},), + arg1, + ) +end + +@for_petsc function PetscMallocSetCoalesce(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocSetCoalesce, $petsc_library), + PetscErrorCode, + (PetscBool,), + arg1, + ) +end + +@for_petsc function PetscMallocSet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscMallocSet, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMallocClear(::$UnionPetscLib) + @chk ccall((:PetscMallocClear, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscMallocSetDRAM(::$UnionPetscLib) + @chk ccall((:PetscMallocSetDRAM, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscMallocResetDRAM(::$UnionPetscLib) + @chk ccall((:PetscMallocResetDRAM, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscMallocDump(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocDump, $petsc_library), + PetscErrorCode, + (Ptr{Libc.FILE},), + arg1, + ) +end + +@for_petsc function PetscMallocView(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocView, $petsc_library), + PetscErrorCode, + (Ptr{Libc.FILE},), + arg1, + ) +end + +@for_petsc function PetscMallocGetCurrentUsage(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocGetCurrentUsage, $petsc_library), + PetscErrorCode, + (Ptr{PetscLogDouble},), + arg1, + ) +end + +@for_petsc function PetscMallocGetMaximumUsage(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocGetMaximumUsage, $petsc_library), + PetscErrorCode, + (Ptr{PetscLogDouble},), + arg1, + ) +end + +@for_petsc function PetscMallocPushMaximumUsage(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocPushMaximumUsage, $petsc_library), + PetscErrorCode, + (Cint,), + arg1, + ) +end + +@for_petsc function PetscMallocPopMaximumUsage(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscMallocPopMaximumUsage, $petsc_library), + PetscErrorCode, + (Cint, Ptr{PetscLogDouble}), + arg1, + arg2, + ) +end + +@for_petsc function PetscMallocSetDebug(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscMallocSetDebug, $petsc_library), + PetscErrorCode, + (PetscBool, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscMallocGetDebug(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscMallocGetDebug, $petsc_library), + PetscErrorCode, + (Ptr{PetscBool}, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMallocValidate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscMallocValidate, $petsc_library), + PetscErrorCode, + (Cint, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMallocViewSet(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocViewSet, $petsc_library), + PetscErrorCode, + (PetscLogDouble,), + arg1, + ) +end + +@for_petsc function PetscMallocViewGet(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocViewGet, $petsc_library), + PetscErrorCode, + (Ptr{PetscBool},), + arg1, + ) +end + +@for_petsc function PetscMallocLogRequestedSizeSet(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocLogRequestedSizeSet, $petsc_library), + PetscErrorCode, + (PetscBool,), + arg1, + ) +end + +@for_petsc function PetscMallocLogRequestedSizeGet(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocLogRequestedSizeGet, $petsc_library), + PetscErrorCode, + (Ptr{PetscBool},), + arg1, + ) +end + +@for_petsc function PetscDataTypeToMPIDataType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDataTypeToMPIDataType, $petsc_library), + PetscErrorCode, + (PetscDataType, Ptr{MPI_Datatype}), + arg1, + arg2, + ) +end + +@for_petsc function PetscMPIDataTypeToPetscDataType( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscMPIDataTypeToPetscDataType, $petsc_library), + PetscErrorCode, + (MPI_Datatype, Ptr{PetscDataType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDataTypeGetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDataTypeGetSize, $petsc_library), + PetscErrorCode, + (PetscDataType, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDataTypeFromString(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDataTypeFromString, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscDataType}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMemcmp(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscMemcmp, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscStrlen(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStrlen, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStrToArray(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscStrToArray, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Cchar, Ptr{Cint}, Ptr{Ptr{Ptr{Cchar}}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscStrToArrayDestroy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStrToArrayDestroy, $petsc_library), + PetscErrorCode, + (Cint, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStrcmp(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrcmp, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrgrt(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrgrt, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrcasecmp(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrcasecmp, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrncmp(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscStrncmp, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Csize_t, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscStrcpy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStrcpy, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStrcat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStrcat, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStrlcat(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrlcat, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrncpy(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrncpy, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrchr(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrchr, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Cchar, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrtolower(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscStrtolower, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscStrtoupper(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscStrtoupper, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscStrrchr(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrrchr, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Cchar, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrstr(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrstr, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrrstr(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrrstr, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrendswith(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrendswith, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrbeginswith(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrbeginswith, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrendswithwhich(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrendswithwhich, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Ptr{Cchar}}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrallocpy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStrallocpy, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStrArrayallocpy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStrArrayallocpy, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cchar}}, Ptr{Ptr{Ptr{Cchar}}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStrArrayDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscStrArrayDestroy, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Ptr{Cchar}}},), + arg1, + ) +end + +@for_petsc function PetscStrNArrayallocpy(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscStrNArrayallocpy, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Ptr{Cchar}}, Ptr{Ptr{Ptr{Cchar}}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscStrNArrayDestroy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStrNArrayDestroy, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Ptr{Ptr{Cchar}}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStrreplace(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscStrreplace, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscStrcmpNoError(::$UnionPetscLib, arg1, arg2, arg3) + ccall( + (:PetscStrcmpNoError, $petsc_library), + Cvoid, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscTokenCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscTokenCreate, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Cchar, Ptr{PetscToken}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscTokenFind(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscTokenFind, $petsc_library), + PetscErrorCode, + (PetscToken, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscTokenDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscTokenDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscToken},), + arg1, + ) +end + +@for_petsc function PetscStrInList(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscStrInList, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Cchar, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscEListFind( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscEListFind, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{Ptr{Cchar}}, + Ptr{Cchar}, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscEnumFind(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscEnumFind, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cchar}}, Ptr{Cchar}, Ptr{PetscEnum}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscMaxSum(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscMaxSum, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MPIULong_Send( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MPIULong_Send, $petsc_library), + PetscErrorCode, + ( + Ptr{Cvoid}, + $PetscInt, + MPI_Datatype, + PetscMPIInt, + PetscMPIInt, + MPI_Comm, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MPIULong_Recv( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MPIULong_Recv, $petsc_library), + PetscErrorCode, + ( + Ptr{Cvoid}, + $PetscInt, + MPI_Datatype, + PetscMPIInt, + PetscMPIInt, + MPI_Comm, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@enum PetscErrorType::UInt32 begin + PETSC_ERROR_INITIAL = 0 + PETSC_ERROR_REPEAT = 1 + PETSC_ERROR_IN_CXX = 2 +end + +@for_petsc function PetscErrorPrintfInitialize(::$UnionPetscLib) + @chk ccall( + (:PetscErrorPrintfInitialize, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscErrorMessage(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscErrorMessage, $petsc_library), + PetscErrorCode, + (Cint, Ptr{Ptr{Cchar}}, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscTraceBackErrorHandler( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscTraceBackErrorHandler, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Cint, + Ptr{Cchar}, + Ptr{Cchar}, + PetscErrorCode, + PetscErrorType, + Ptr{Cchar}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscIgnoreErrorHandler( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscIgnoreErrorHandler, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Cint, + Ptr{Cchar}, + Ptr{Cchar}, + PetscErrorCode, + PetscErrorType, + Ptr{Cchar}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscEmacsClientErrorHandler( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscEmacsClientErrorHandler, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Cint, + Ptr{Cchar}, + Ptr{Cchar}, + PetscErrorCode, + PetscErrorType, + Ptr{Cchar}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscMPIAbortErrorHandler( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscMPIAbortErrorHandler, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Cint, + Ptr{Cchar}, + Ptr{Cchar}, + PetscErrorCode, + PetscErrorType, + Ptr{Cchar}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscAbortErrorHandler( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscAbortErrorHandler, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Cint, + Ptr{Cchar}, + Ptr{Cchar}, + PetscErrorCode, + PetscErrorType, + Ptr{Cchar}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscAttachDebuggerErrorHandler( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscAttachDebuggerErrorHandler, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Cint, + Ptr{Cchar}, + Ptr{Cchar}, + PetscErrorCode, + PetscErrorType, + Ptr{Cchar}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscReturnErrorHandler( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscReturnErrorHandler, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Cint, + Ptr{Cchar}, + Ptr{Cchar}, + PetscErrorCode, + PetscErrorType, + Ptr{Cchar}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscPushErrorHandler(::$UnionPetscLib, handler, arg2) + @chk ccall( + (:PetscPushErrorHandler, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Cvoid}), + handler, + arg2, + ) +end + +@for_petsc function PetscPopErrorHandler(::$UnionPetscLib) + @chk ccall((:PetscPopErrorHandler, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscSignalHandlerDefault(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSignalHandlerDefault, $petsc_library), + PetscErrorCode, + (Cint, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPushSignalHandler(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPushSignalHandler, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPopSignalHandler(::$UnionPetscLib) + @chk ccall((:PetscPopSignalHandler, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscCheckPointerSetIntensity(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscCheckPointerSetIntensity, $petsc_library), + PetscErrorCode, + ($PetscInt,), + arg1, + ) +end + +@for_petsc function PetscSignalSegvCheckPointerOrMpi(::$UnionPetscLib) + ccall((:PetscSignalSegvCheckPointerOrMpi, $petsc_library), Cvoid, ()) +end + +@for_petsc function PetscSignalSegvCheckPointer(::$UnionPetscLib) + ccall((:PetscSignalSegvCheckPointer, $petsc_library), Cvoid, ()) +end + +@enum PetscFPTrap::UInt32 begin + PETSC_FP_TRAP_OFF = 0 + PETSC_FP_TRAP_ON = 1 +end + +@for_petsc function PetscSetFPTrap(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSetFPTrap, $petsc_library), + PetscErrorCode, + (PetscFPTrap,), + arg1, + ) +end + +@for_petsc function PetscFPTrapPush(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFPTrapPush, $petsc_library), + PetscErrorCode, + (PetscFPTrap,), + arg1, + ) +end + +@for_petsc function PetscFPTrapPop(::$UnionPetscLib) + @chk ccall((:PetscFPTrapPop, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscDetermineInitialFPTrap(::$UnionPetscLib) + @chk ccall( + (:PetscDetermineInitialFPTrap, $petsc_library), + PetscErrorCode, + (), + ) +end + +mutable struct PetscStack + _function::NTuple{64, Ptr{Cchar}} + file::NTuple{64, Ptr{Cchar}} + line::NTuple{64, Cint} + petscroutine::NTuple{64, PetscBool} + currentsize::Cint + hotdepth::Cint + PetscStack() = new() +end + +@for_petsc function PetscStackCopy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStackCopy, $petsc_library), + PetscErrorCode, + (Ptr{PetscStack}, Ptr{PetscStack}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStackPrint(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStackPrint, $petsc_library), + PetscErrorCode, + (Ptr{PetscStack}, Ptr{Libc.FILE}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStackActive(::$UnionPetscLib) + ccall((:PetscStackActive, $petsc_library), PetscBool, ()) +end + +@for_petsc function PetscStackCreate(::$UnionPetscLib) + @chk ccall((:PetscStackCreate, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscStackView(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscStackView, $petsc_library), + PetscErrorCode, + (Ptr{Libc.FILE},), + arg1, + ) +end + +@for_petsc function PetscStackDestroy(::$UnionPetscLib) + @chk ccall((:PetscStackDestroy, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscClassIdRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscClassIdRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscClassId}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectGetId(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetId, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{PetscObjectId}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectCompareId(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscObjectCompareId, $petsc_library), + PetscErrorCode, + (PetscObject, PetscObjectId, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMemoryGetCurrentUsage(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMemoryGetCurrentUsage, $petsc_library), + PetscErrorCode, + (Ptr{PetscLogDouble},), + arg1, + ) +end + +@for_petsc function PetscMemoryGetMaximumUsage(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMemoryGetMaximumUsage, $petsc_library), + PetscErrorCode, + (Ptr{PetscLogDouble},), + arg1, + ) +end + +@for_petsc function PetscMemorySetGetMaximumUsage(::$UnionPetscLib) + @chk ccall( + (:PetscMemorySetGetMaximumUsage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscMemoryTrace(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMemoryTrace, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscSleep(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSleep, $petsc_library), + PetscErrorCode, + ($PetscReal,), + arg1, + ) +end + +@for_petsc function PetscInitialize(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscInitialize, $petsc_library), + PetscErrorCode, + (Ptr{Cint}, Ptr{Ptr{Ptr{Cchar}}}, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscInitializeNoPointers( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscInitializeNoPointers, $petsc_library), + PetscErrorCode, + (Cint, Ptr{Ptr{Cchar}}, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscInitializeNoArguments(::$UnionPetscLib) + @chk ccall( + (:PetscInitializeNoArguments, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscInitialized(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscInitialized, $petsc_library), + PetscErrorCode, + (Ptr{PetscBool},), + arg1, + ) +end + +@for_petsc function PetscFinalized(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFinalized, $petsc_library), + PetscErrorCode, + (Ptr{PetscBool},), + arg1, + ) +end + +@for_petsc function PetscFinalize(::$UnionPetscLib) + @chk ccall((:PetscFinalize, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscInitializeFortran(::$UnionPetscLib) + @chk ccall((:PetscInitializeFortran, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscGetArgs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetArgs, $petsc_library), + PetscErrorCode, + (Ptr{Cint}, Ptr{Ptr{Ptr{Cchar}}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscGetArguments(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscGetArguments, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Ptr{Cchar}}},), + arg1, + ) +end + +@for_petsc function PetscFreeArguments(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFreeArguments, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cchar}},), + arg1, + ) +end + +@for_petsc function PetscEnd(::$UnionPetscLib) + @chk ccall((:PetscEnd, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscSysInitializePackage(::$UnionPetscLib) + @chk ccall((:PetscSysInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscPythonInitialize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPythonInitialize, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPythonFinalize(::$UnionPetscLib) + @chk ccall((:PetscPythonFinalize, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscPythonPrintError(::$UnionPetscLib) + @chk ccall((:PetscPythonPrintError, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscPythonMonitorSet(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPythonMonitorSet, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscMonitorCompare( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscMonitorCompare, $petsc_library), + PetscErrorCode, + ( + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +# typedef void ( * * PetscVoidStarFunction ) ( void ) +const PetscVoidStarFunction = Ptr{Ptr{Cvoid}} + +# typedef void ( * PetscVoidFunction ) ( void ) +const PetscVoidFunction = Ptr{Cvoid} + +# typedef PetscErrorCode ( * PetscErrorCodeFunction ) ( void ) +const PetscErrorCodeFunction = Ptr{Cvoid} + +@for_petsc function PetscObjectDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscObject},), + arg1, + ) +end + +@for_petsc function PetscObjectGetComm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetComm, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{MPI_Comm}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectGetClassId(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetClassId, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{PetscClassId}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectGetClassName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetClassName, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectSetType, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetType, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectSetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectSetName, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectGetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetName, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectSetTabLevel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectSetTabLevel, $petsc_library), + PetscErrorCode, + (PetscObject, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectGetTabLevel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetTabLevel, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectIncrementTabLevel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscObjectIncrementTabLevel, $petsc_library), + PetscErrorCode, + (PetscObject, PetscObject, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscObjectReference(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectReference, $petsc_library), + PetscErrorCode, + (PetscObject,), + arg1, + ) +end + +@for_petsc function PetscObjectGetReference(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetReference, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectDereference(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectDereference, $petsc_library), + PetscErrorCode, + (PetscObject,), + arg1, + ) +end + +@for_petsc function PetscObjectGetNewTag(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetNewTag, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{PetscMPIInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectCompose(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscObjectCompose, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}, PetscObject), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscObjectRemoveReference(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectRemoveReference, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectQuery(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscObjectQuery, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}, Ptr{PetscObject}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscObjectSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscObject,), + arg1, + ) +end + +@for_petsc function PetscObjectSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectSetUp, $petsc_library), + PetscErrorCode, + (PetscObject,), + arg1, + ) +end + +@for_petsc function PetscObjectSetPrintedOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectSetPrintedOptions, $petsc_library), + PetscErrorCode, + (PetscObject,), + arg1, + ) +end + +@for_petsc function PetscObjectInheritPrintedOptions( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscObjectInheritPrintedOptions, $petsc_library), + PetscErrorCode, + (PetscObject, PetscObject), + arg1, + arg2, + ) +end + +@for_petsc function PetscCommGetNewTag(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscCommGetNewTag, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscMPIInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsCreate(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsCreate, $petsc_library), + PetscErrorCode, + (Ptr{PetscOptions},), + arg1, + ) +end + +@for_petsc function PetscOptionsPush(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsPush, $petsc_library), + PetscErrorCode, + (PetscOptions,), + arg1, + ) +end + +@for_petsc function PetscOptionsPop(::$UnionPetscLib) + @chk ccall((:PetscOptionsPop, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscOptionsDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscOptions},), + arg1, + ) +end + +@for_petsc function PetscOptionsCreateDefault(::$UnionPetscLib) + @chk ccall((:PetscOptionsCreateDefault, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscOptionsDestroyDefault(::$UnionPetscLib) + @chk ccall( + (:PetscOptionsDestroyDefault, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscOptionsHasHelp(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsHasHelp, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsHasName( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscOptionsHasName, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscOptionsGetBool( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscOptionsGetBool, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscOptionsGetInt( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscOptionsGetInt, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{Cchar}, Ptr{$PetscInt}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscOptionsGetEnum( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscOptionsGetEnum, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Ptr{Cchar}}, + Ptr{PetscEnum}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscOptionsGetEList( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscOptionsGetEList, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Ptr{Cchar}}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscOptionsGetReal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscOptionsGetReal, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{Cchar}, Ptr{$PetscReal}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscOptionsGetScalar( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscOptionsGetScalar, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{$PetscScalar}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscOptionsGetString( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscOptionsGetString, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Cchar}, + Csize_t, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscOptionsGetBoolArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscOptionsGetBoolArray, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{PetscBool}, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscOptionsGetEnumArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscOptionsGetEnumArray, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Ptr{Cchar}}, + Ptr{PetscEnum}, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscOptionsGetIntArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscOptionsGetIntArray, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscOptionsGetRealArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscOptionsGetRealArray, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{$PetscReal}, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscOptionsGetScalarArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscOptionsGetScalarArray, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{$PetscScalar}, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscOptionsGetStringArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscOptionsGetStringArray, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Ptr{Cchar}}, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscOptionsValidKey(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsValidKey, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsSetAlias(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscOptionsSetAlias, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscOptionsSetValue(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscOptionsSetValue, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscOptionsClearValue(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsClearValue, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsFindPair( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscOptionsFindPair, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{Cchar}, Ptr{Ptr{Cchar}}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscOptionsGetAll(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsGetAll, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsAllUsed(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsAllUsed, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsUsed(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscOptionsUsed, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscOptionsLeft(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsLeft, $petsc_library), + PetscErrorCode, + (PetscOptions,), + arg1, + ) +end + +@for_petsc function PetscOptionsLeftGet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscOptionsLeftGet, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cchar}}}, + Ptr{Ptr{Ptr{Cchar}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscOptionsLeftRestore( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscOptionsLeftRestore, $petsc_library), + PetscErrorCode, + ( + PetscOptions, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cchar}}}, + Ptr{Ptr{Ptr{Cchar}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscOptionsView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsView, $petsc_library), + PetscErrorCode, + (PetscOptions, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsReject(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscOptionsReject, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscOptionsInsert(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscOptionsInsert, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cint}, Ptr{Ptr{Ptr{Cchar}}}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscOptionsInsertFile( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscOptionsInsertFile, $petsc_library), + PetscErrorCode, + (MPI_Comm, PetscOptions, Ptr{Cchar}, PetscBool), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscOptionsInsertFileYAML( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscOptionsInsertFileYAML, $petsc_library), + PetscErrorCode, + (MPI_Comm, PetscOptions, Ptr{Cchar}, PetscBool), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscOptionsInsertString(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsInsertString, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsInsertStringYAML(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsInsertStringYAML, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsInsertArgs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscOptionsInsertArgs, $petsc_library), + PetscErrorCode, + (PetscOptions, Cint, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscOptionsClear(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsClear, $petsc_library), + PetscErrorCode, + (PetscOptions,), + arg1, + ) +end + +@for_petsc function PetscOptionsPrefixPush(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsPrefixPush, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsPrefixPop(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsPrefixPop, $petsc_library), + PetscErrorCode, + (PetscOptions,), + arg1, + ) +end + +@for_petsc function PetscOptionsGetenv( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscOptionsGetenv, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Csize_t, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscOptionsStringToBool(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsStringToBool, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsStringToInt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsStringToInt, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsStringToReal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsStringToReal, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsStringToScalar(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscOptionsStringToScalar, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsMonitorSet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscOptionsMonitorSet, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscOptionsMonitorDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscOptionsMonitorDefault, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscObjectSetOptions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectSetOptions, $petsc_library), + PetscErrorCode, + (PetscObject, PetscOptions), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectGetOptions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetOptions, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{PetscOptions}), + arg1, + arg2, + ) +end + +@enum PetscOptionType::UInt32 begin + OPTION_INT = 0 + OPTION_BOOL = 1 + OPTION_REAL = 2 + OPTION_FLIST = 3 + OPTION_STRING = 4 + OPTION_REAL_ARRAY = 5 + OPTION_SCALAR_ARRAY = 6 + OPTION_HEAD = 7 + OPTION_INT_ARRAY = 8 + OPTION_ELIST = 9 + OPTION_BOOL_ARRAY = 10 + OPTION_STRING_ARRAY = 11 +end + +mutable struct __JL__n_PetscOptionItem end + +function Base.unsafe_load(x::Ptr{__JL__n_PetscOptionItem}) + unsafe_load(Ptr{_n_PetscOptionItem}(x)) +end + +function Base.getproperty(x::Ptr{__JL__n_PetscOptionItem}, f::Symbol) + getproperty(Ptr{_n_PetscOptionItem}(x), f) +end + +function Base.setproperty!(x::Ptr{__JL__n_PetscOptionItem}, f::Symbol, v) + setproperty!(Ptr{_n_PetscOptionItem}(x), f, v) +end + +const PetscOptionItem = Ptr{__JL__n_PetscOptionItem} + +@for_petsc function PetscOptionsSAWsDestroy(::$UnionPetscLib) + @chk ccall((:PetscOptionsSAWsDestroy, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscObjectAddOptionsHandler( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscObjectAddOptionsHandler, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscObjectDestroyOptionsHandlers(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectDestroyOptionsHandlers, $petsc_library), + PetscErrorCode, + (PetscObject,), + arg1, + ) +end + +@for_petsc function PetscMallocTraceSet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscMallocTraceSet, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscBool, PetscLogDouble), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMallocTraceGet(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMallocTraceGet, $petsc_library), + PetscErrorCode, + (Ptr{PetscBool},), + arg1, + ) +end + +@for_petsc function PetscObjectsListGetGlobalNumbering( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscObjectsListGetGlobalNumbering, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{PetscObject}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscMemoryView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscMemoryView, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectPrintClassNamePrefixType( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscObjectPrintClassNamePrefixType, $petsc_library), + PetscErrorCode, + (PetscObject, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectView, $petsc_library), + PetscErrorCode, + (PetscObject, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectAppendOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectPrependOptionsPrefix( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscObjectPrependOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectGetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectChangeTypeName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectChangeTypeName, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectRegisterDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectRegisterDestroy, $petsc_library), + PetscErrorCode, + (PetscObject,), + arg1, + ) +end + +@for_petsc function PetscObjectRegisterDestroyAll(::$UnionPetscLib) + @chk ccall( + (:PetscObjectRegisterDestroyAll, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscObjectViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscObjectViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscObject, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscObjectName(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectName, $petsc_library), + PetscErrorCode, + (PetscObject,), + arg1, + ) +end + +@for_petsc function PetscObjectTypeCompare(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscObjectTypeCompare, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscObjectBaseTypeCompare( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscObjectBaseTypeCompare, $petsc_library), + PetscErrorCode, + (PetscObject, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscRegisterFinalize(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscRegisterFinalize, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid},), + arg1, + ) +end + +@for_petsc function PetscRegisterFinalizeAll(::$UnionPetscLib) + @chk ccall((:PetscRegisterFinalizeAll, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscDLOpen(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDLOpen, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, PetscDLMode, Ptr{PetscDLHandle}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDLClose(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDLClose, $petsc_library), + PetscErrorCode, + (Ptr{PetscDLHandle},), + arg1, + ) +end + +@for_petsc function PetscDLSym(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDLSym, $petsc_library), + PetscErrorCode, + (PetscDLHandle, Ptr{Cchar}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDLAddr(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDLAddr, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectsDump(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectsDump, $petsc_library), + PetscErrorCode, + (Ptr{Libc.FILE}, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectListDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscObjectListDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscObjectList},), + arg1, + ) +end + +@for_petsc function PetscObjectListFind(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscObjectListFind, $petsc_library), + PetscErrorCode, + (PetscObjectList, Ptr{Cchar}, Ptr{PetscObject}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscObjectListReverseFind( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscObjectListReverseFind, $petsc_library), + PetscErrorCode, + (PetscObjectList, PetscObject, Ptr{Ptr{Cchar}}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscObjectListAdd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscObjectListAdd, $petsc_library), + PetscErrorCode, + (Ptr{PetscObjectList}, Ptr{Cchar}, PetscObject), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscObjectListRemoveReference(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectListRemoveReference, $petsc_library), + PetscErrorCode, + (Ptr{PetscObjectList}, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscObjectListDuplicate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscObjectListDuplicate, $petsc_library), + PetscErrorCode, + (PetscObjectList, Ptr{PetscObjectList}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFunctionListDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFunctionListDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscFunctionList},), + arg1, + ) +end + +@for_petsc function PetscFunctionListPrintTypes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscFunctionListPrintTypes, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Libc.FILE}, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Cchar}, + PetscFunctionList, + Ptr{Cchar}, + Ptr{Cchar}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscFunctionListDuplicate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFunctionListDuplicate, $petsc_library), + PetscErrorCode, + (PetscFunctionList, Ptr{PetscFunctionList}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFunctionListView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFunctionListView, $petsc_library), + PetscErrorCode, + (PetscFunctionList, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscFunctionListGet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscFunctionListGet, $petsc_library), + PetscErrorCode, + (PetscFunctionList, Ptr{Ptr{Ptr{Cchar}}}, Ptr{Cint}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDLLibraryAppend(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDLLibraryAppend, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscDLLibrary}, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDLLibraryPrepend(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDLLibraryPrepend, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscDLLibrary}, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDLLibrarySym( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDLLibrarySym, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{PetscDLLibrary}, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDLLibraryPrintPath(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDLLibraryPrintPath, $petsc_library), + PetscErrorCode, + (PetscDLLibrary,), + arg1, + ) +end + +@for_petsc function PetscDLLibraryRetrieve( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDLLibraryRetrieve, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Csize_t, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDLLibraryOpen(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDLLibraryOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{PetscDLLibrary}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDLLibraryClose(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDLLibraryClose, $petsc_library), + PetscErrorCode, + (PetscDLLibrary,), + arg1, + ) +end + +@for_petsc function PetscSplitOwnership(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSplitOwnership, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSplitOwnershipBlock( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSplitOwnershipBlock, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSplitOwnershipEqual(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSplitOwnershipEqual, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSequentialPhaseBegin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSequentialPhaseBegin, $petsc_library), + PetscErrorCode, + (MPI_Comm, PetscMPIInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscSequentialPhaseEnd(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSequentialPhaseEnd, $petsc_library), + PetscErrorCode, + (MPI_Comm, PetscMPIInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscBarrier(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscBarrier, $petsc_library), + PetscErrorCode, + (PetscObject,), + arg1, + ) +end + +@for_petsc function PetscMPIDump(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMPIDump, $petsc_library), + PetscErrorCode, + (Ptr{Libc.FILE},), + arg1, + ) +end + +@for_petsc function PetscGlobalMinMaxInt(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscGlobalMinMaxInt, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscGlobalMinMaxReal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscGlobalMinMaxReal, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscGetCPUTime(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscGetCPUTime, $petsc_library), + PetscErrorCode, + (Ptr{PetscLogDouble},), + arg1, + ) +end + +@for_petsc function PetscTime(::$UnionPetscLib, v) + @chk ccall( + (:PetscTime, $petsc_library), + PetscErrorCode, + (Ptr{PetscLogDouble},), + v, + ) +end + +@for_petsc function PetscTimeSubtract(::$UnionPetscLib, v) + @chk ccall( + (:PetscTimeSubtract, $petsc_library), + PetscErrorCode, + (Ptr{PetscLogDouble},), + v, + ) +end + +@for_petsc function PetscTimeAdd(::$UnionPetscLib, v) + @chk ccall( + (:PetscTimeAdd, $petsc_library), + PetscErrorCode, + (Ptr{PetscLogDouble},), + v, + ) +end + +@enum PetscInfoCommFlag::Int32 begin + PETSC_INFO_COMM_ALL = -1 + PETSC_INFO_COMM_NO_SELF = 0 + PETSC_INFO_COMM_ONLY_SELF = 1 +end + +@for_petsc function PetscInfoDeactivateClass(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscInfoDeactivateClass, $petsc_library), + PetscErrorCode, + (PetscClassId,), + arg1, + ) +end + +@for_petsc function PetscInfoActivateClass(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscInfoActivateClass, $petsc_library), + PetscErrorCode, + (PetscClassId,), + arg1, + ) +end + +@for_petsc function PetscInfoEnabled(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscInfoEnabled, $petsc_library), + PetscErrorCode, + (PetscClassId, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscInfoAllow(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscInfoAllow, $petsc_library), + PetscErrorCode, + (PetscBool,), + arg1, + ) +end + +@for_petsc function PetscInfoSetFile(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscInfoSetFile, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscInfoGetFile(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscInfoGetFile, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cchar}}, Ptr{Ptr{Libc.FILE}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscInfoSetClasses(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscInfoSetClasses, $petsc_library), + PetscErrorCode, + (PetscBool, $PetscInt, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscInfoGetClass(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscInfoGetClass, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscInfoGetInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscInfoGetInfo, $petsc_library), + PetscErrorCode, + ( + Ptr{PetscBool}, + Ptr{PetscBool}, + Ptr{PetscBool}, + Ptr{PetscBool}, + Ptr{PetscInfoCommFlag}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscInfoProcessClass(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscInfoProcessClass, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, $PetscInt, Ptr{PetscClassId}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscInfoSetFilterCommSelf(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscInfoSetFilterCommSelf, $petsc_library), + PetscErrorCode, + (PetscInfoCommFlag,), + arg1, + ) +end + +@for_petsc function PetscInfoSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscInfoSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscOptions,), + arg1, + ) +end + +@for_petsc function PetscInfoDestroy(::$UnionPetscLib) + @chk ccall((:PetscInfoDestroy, $petsc_library), PetscErrorCode, ()) +end + +const PetscLogEvent = Cint + +const PetscLogStage = Cint + +mutable struct _n_PetscIntStack end + +const PetscIntStack = Ptr{_n_PetscIntStack} + +mutable struct PetscClassRegInfo + name::Ptr{Cchar} + classid::PetscClassId + PetscClassRegInfo() = new() +end + +mutable struct PetscClassPerfInfo + id::PetscClassId + creations::Cint + destructions::Cint + mem::PetscLogDouble + descMem::PetscLogDouble + PetscClassPerfInfo() = new() +end + +struct _n_PetscClassRegLog + numClasses::Cint + maxClasses::Cint + classInfo::Ptr{PetscClassRegInfo} +end + +const PetscClassRegLog = Ptr{_n_PetscClassRegLog} + +struct _n_PetscClassPerfLog + numClasses::Cint + maxClasses::Cint + classInfo::Ptr{PetscClassPerfInfo} +end + +const PetscClassPerfLog = Ptr{_n_PetscClassPerfLog} + +mutable struct PetscEventRegInfo + name::Ptr{Cchar} + classid::PetscClassId + collective::PetscBool + PetscEventRegInfo() = new() +end + +mutable struct PetscEventPerfInfo + id::Cint + active::PetscBool + visible::PetscBool + depth::Cint + count::Cint + flops::PetscLogDouble + flops2::PetscLogDouble + flopsTmp::PetscLogDouble + time::PetscLogDouble + time2::PetscLogDouble + timeTmp::PetscLogDouble + syncTime::PetscLogDouble + dof::NTuple{8, PetscLogDouble} + errors::NTuple{8, PetscLogDouble} + numMessages::PetscLogDouble + messageLength::PetscLogDouble + numReductions::PetscLogDouble + memIncrease::PetscLogDouble + mallocIncrease::PetscLogDouble + mallocSpace::PetscLogDouble + mallocIncreaseEvent::PetscLogDouble + PetscEventPerfInfo() = new() +end + +struct _n_PetscEventRegLog + numEvents::Cint + maxEvents::Cint + eventInfo::Ptr{PetscEventRegInfo} +end + +const PetscEventRegLog = Ptr{_n_PetscEventRegLog} + +struct _n_PetscEventPerfLog + numEvents::Cint + maxEvents::Cint + eventInfo::Ptr{PetscEventPerfInfo} +end + +const PetscEventPerfLog = Ptr{_n_PetscEventPerfLog} + +struct _PetscStageInfo + name::Ptr{Cchar} + used::PetscBool + perfInfo::PetscEventPerfInfo + eventLog::PetscEventPerfLog + classLog::PetscClassPerfLog +end + +const PetscStageInfo = _PetscStageInfo + +mutable struct _n_PetscStageLog + numStages::Cint + maxStages::Cint + stack::PetscIntStack + curStage::Cint + stageInfo::Ptr{PetscStageInfo} + eventLog::PetscEventRegLog + classLog::PetscClassRegLog + _n_PetscStageLog() = new() +end + +const PetscStageLog = Ptr{_n_PetscStageLog} + +@for_petsc function PetscLogObjectParent(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogObjectParent, $petsc_library), + PetscErrorCode, + (PetscObject, PetscObject), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogObjectMemory(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogObjectMemory, $petsc_library), + PetscErrorCode, + (PetscObject, PetscLogDouble), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogGetStageLog(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogGetStageLog, $petsc_library), + PetscErrorCode, + (Ptr{PetscStageLog},), + arg1, + ) +end + +@for_petsc function PetscStageLogGetCurrent(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscStageLogGetCurrent, $petsc_library), + PetscErrorCode, + (PetscStageLog, Ptr{Cint}), + arg1, + arg2, + ) +end + +@for_petsc function PetscStageLogGetEventPerfLog( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscStageLogGetEventPerfLog, $petsc_library), + PetscErrorCode, + (PetscStageLog, Cint, Ptr{PetscEventPerfLog}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscLogFlops(::$UnionPetscLib, n) + @chk ccall( + (:PetscLogFlops, $petsc_library), + PetscErrorCode, + (PetscLogDouble,), + n, + ) +end + +@for_petsc function PetscGetFlops(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscGetFlops, $petsc_library), + PetscErrorCode, + (Ptr{PetscLogDouble},), + arg1, + ) +end + +@for_petsc function PetscLogDefaultBegin(::$UnionPetscLib) + @chk ccall((:PetscLogDefaultBegin, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscLogAllBegin(::$UnionPetscLib) + @chk ccall((:PetscLogAllBegin, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscLogNestedBegin(::$UnionPetscLib) + @chk ccall((:PetscLogNestedBegin, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscLogTraceBegin(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogTraceBegin, $petsc_library), + PetscErrorCode, + (Ptr{Libc.FILE},), + arg1, + ) +end + +@for_petsc function PetscLogActions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogActions, $petsc_library), + PetscErrorCode, + (PetscBool,), + arg1, + ) +end + +@for_petsc function PetscLogObjects(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogObjects, $petsc_library), + PetscErrorCode, + (PetscBool,), + arg1, + ) +end + +@for_petsc function PetscLogSetThreshold(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogSetThreshold, $petsc_library), + PetscErrorCode, + (PetscLogDouble, Ptr{PetscLogDouble}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogSet(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogSet, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogView(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogView, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscLogViewFromOptions(::$UnionPetscLib) + @chk ccall((:PetscLogViewFromOptions, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscLogDump(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogDump, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscLogStageRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogStageRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscLogStage}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogStagePush(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogStagePush, $petsc_library), + PetscErrorCode, + (PetscLogStage,), + arg1, + ) +end + +@for_petsc function PetscLogStagePop(::$UnionPetscLib) + @chk ccall((:PetscLogStagePop, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscLogStageSetActive(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogStageSetActive, $petsc_library), + PetscErrorCode, + (PetscLogStage, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogStageGetActive(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogStageGetActive, $petsc_library), + PetscErrorCode, + (PetscLogStage, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogStageSetVisible(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogStageSetVisible, $petsc_library), + PetscErrorCode, + (PetscLogStage, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogStageGetVisible(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogStageGetVisible, $petsc_library), + PetscErrorCode, + (PetscLogStage, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogStageGetId(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogStageGetId, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscLogStage}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogEventRegister(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscLogEventRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, PetscClassId, Ptr{PetscLogEvent}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscLogEventSetCollective(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogEventSetCollective, $petsc_library), + PetscErrorCode, + (PetscLogEvent, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogEventIncludeClass(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogEventIncludeClass, $petsc_library), + PetscErrorCode, + (PetscClassId,), + arg1, + ) +end + +@for_petsc function PetscLogEventExcludeClass(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogEventExcludeClass, $petsc_library), + PetscErrorCode, + (PetscClassId,), + arg1, + ) +end + +@for_petsc function PetscLogEventActivate(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogEventActivate, $petsc_library), + PetscErrorCode, + (PetscLogEvent,), + arg1, + ) +end + +@for_petsc function PetscLogEventDeactivate(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogEventDeactivate, $petsc_library), + PetscErrorCode, + (PetscLogEvent,), + arg1, + ) +end + +@for_petsc function PetscLogEventDeactivatePush(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogEventDeactivatePush, $petsc_library), + PetscErrorCode, + (PetscLogEvent,), + arg1, + ) +end + +@for_petsc function PetscLogEventDeactivatePop(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogEventDeactivatePop, $petsc_library), + PetscErrorCode, + (PetscLogEvent,), + arg1, + ) +end + +@for_petsc function PetscLogEventSetActiveAll(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogEventSetActiveAll, $petsc_library), + PetscErrorCode, + (PetscLogEvent, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogEventActivateClass(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogEventActivateClass, $petsc_library), + PetscErrorCode, + (PetscClassId,), + arg1, + ) +end + +@for_petsc function PetscLogEventDeactivateClass(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogEventDeactivateClass, $petsc_library), + PetscErrorCode, + (PetscClassId,), + arg1, + ) +end + +@for_petsc function PetscLogEventGetId(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogEventGetId, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscLogEvent}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogEventGetPerfInfo(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscLogEventGetPerfInfo, $petsc_library), + PetscErrorCode, + (Cint, PetscLogEvent, Ptr{PetscEventPerfInfo}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscLogEventSetDof(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscLogEventSetDof, $petsc_library), + PetscErrorCode, + (PetscLogEvent, $PetscInt, PetscLogDouble), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscLogEventSetError(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscLogEventSetError, $petsc_library), + PetscErrorCode, + (PetscLogEvent, $PetscInt, PetscLogDouble), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscLogEventSynchronize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogEventSynchronize, $petsc_library), + PetscErrorCode, + (PetscLogEvent, MPI_Comm), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogEventGetFlops(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLogEventGetFlops, $petsc_library), + PetscErrorCode, + (PetscLogEvent, Ptr{PetscLogDouble}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLogEventZeroFlops(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLogEventZeroFlops, $petsc_library), + PetscErrorCode, + (PetscLogEvent,), + arg1, + ) +end + +@for_petsc function PetscMPITypeSize(::$UnionPetscLib, count, type, length) + @chk ccall( + (:PetscMPITypeSize, $petsc_library), + PetscErrorCode, + ($PetscInt, MPI_Datatype, Ptr{PetscLogDouble}), + count, + type, + length, + ) +end + +@for_petsc function PetscMPITypeSizeComm( + ::$UnionPetscLib, + comm, + counts, + type, + length, +) + @chk ccall( + (:PetscMPITypeSizeComm, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscMPIInt}, MPI_Datatype, Ptr{PetscLogDouble}), + comm, + counts, + type, + length, + ) +end + +@for_petsc function PetscMPITypeSizeCount( + ::$UnionPetscLib, + n, + counts, + type, + length, +) + @chk ccall( + (:PetscMPITypeSizeCount, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscMPIInt}, MPI_Datatype, Ptr{PetscLogDouble}), + n, + counts, + type, + length, + ) +end + +@for_petsc function PetscMPIParallelComm(::$UnionPetscLib, comm) + ccall((:PetscMPIParallelComm, $petsc_library), Cint, (MPI_Comm,), comm) +end + +@for_petsc function PetscFixFilename(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFixFilename, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFOpen(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscFOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Ptr{Ptr{Libc.FILE}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscFClose(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFClose, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Libc.FILE}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFormatRealArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscFormatRealArray, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t, Ptr{Cchar}, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscFormatConvertGetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFormatConvertGetSize, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFormatConvert(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFormatConvert, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPOpen(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:PetscPOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}, Ptr{Ptr{Libc.FILE}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscPClose(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPClose, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Libc.FILE}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPOpenSetMachine(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscPOpenSetMachine, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscSynchronizedFlush(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSynchronizedFlush, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Libc.FILE}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSynchronizedFGets( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSynchronizedFGets, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Libc.FILE}, Csize_t, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscStartMatlab(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscStartMatlab, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Ptr{Ptr{Libc.FILE}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscStartJava(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscStartJava, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Ptr{Ptr{Libc.FILE}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGetPetscDir(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscGetPetscDir, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cchar}},), + arg1, + ) +end + +@for_petsc function PetscContainerGetPointer(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscContainerGetPointer, $petsc_library), + PetscErrorCode, + (PetscContainer, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscContainerSetPointer(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscContainerSetPointer, $petsc_library), + PetscErrorCode, + (PetscContainer, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscContainerDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscContainerDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscContainer},), + arg1, + ) +end + +@for_petsc function PetscContainerCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscContainerCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscContainer}), + arg1, + arg2, + ) +end + +@for_petsc function PetscContainerSetUserDestroy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscContainerSetUserDestroy, $petsc_library), + PetscErrorCode, + (PetscContainer, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscContainerUserDestroyDefault(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscContainerUserDestroyDefault, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid},), + arg1, + ) +end + +@for_petsc function PetscIntView(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscIntView, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, PetscViewer), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscRealView(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscRealView, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscReal}, PetscViewer), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscScalarView(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscScalarView, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscScalar}, PetscViewer), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMemmove(::$UnionPetscLib, a, b, n) + @chk ccall( + (:PetscMemmove, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), + a, + b, + n, + ) +end + +@for_petsc function PetscMemcpy(::$UnionPetscLib, a, b, n) + @chk ccall( + (:PetscMemcpy, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), + a, + b, + n, + ) +end + +@for_petsc function PetscMemzero(::$UnionPetscLib, a, n) + @chk ccall( + (:PetscMemzero, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Csize_t), + a, + n, + ) +end + +@for_petsc function PetscIntCast(::$UnionPetscLib, a, b) + @chk ccall( + (:PetscIntCast, $petsc_library), + PetscErrorCode, + (PetscInt64, Ptr{$PetscInt}), + a, + b, + ) +end + +@for_petsc function PetscBLASIntCast(::$UnionPetscLib, a, b) + @chk ccall( + (:PetscBLASIntCast, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscBLASInt}), + a, + b, + ) +end + +@for_petsc function PetscMPIIntCast(::$UnionPetscLib, a, b) + @chk ccall( + (:PetscMPIIntCast, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscMPIInt}), + a, + b, + ) +end + +@for_petsc function PetscRealIntMultTruncate(::$UnionPetscLib, a, b) + ccall( + (:PetscRealIntMultTruncate, $petsc_library), + $PetscInt, + ($PetscReal, $PetscInt), + a, + b, + ) +end + +@for_petsc function PetscIntMultTruncate(::$UnionPetscLib, a, b) + ccall( + (:PetscIntMultTruncate, $petsc_library), + $PetscInt, + ($PetscInt, $PetscInt), + a, + b, + ) +end + +@for_petsc function PetscIntSumTruncate(::$UnionPetscLib, a, b) + ccall( + (:PetscIntSumTruncate, $petsc_library), + $PetscInt, + ($PetscInt, $PetscInt), + a, + b, + ) +end + +@for_petsc function PetscIntMultError(::$UnionPetscLib, a, b, result) + @chk ccall( + (:PetscIntMultError, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscInt}), + a, + b, + result, + ) +end + +@for_petsc function PetscIntSumError(::$UnionPetscLib, a, b, result) + @chk ccall( + (:PetscIntSumError, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscInt}), + a, + b, + result, + ) +end + +@for_petsc function PetscGetArchType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetArchType, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function PetscGetHostName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetHostName, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function PetscGetUserName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetUserName, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function PetscGetProgramName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetProgramName, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function PetscSetProgramName(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSetProgramName, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscGetDate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetDate, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function PetscGetVersion(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetVersion, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function PetscGetVersionNumber( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGetVersionNumber, $petsc_library), + PetscErrorCode, + (Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSortedInt(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSortedInt, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortedMPIInt(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSortedMPIInt, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscMPIInt}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortedReal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSortedReal, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscReal}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortInt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSortInt, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSortReverseInt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSortReverseInt, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSortedRemoveDupsInt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSortedRemoveDupsInt, $petsc_library), + PetscErrorCode, + (Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSortRemoveDupsInt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSortRemoveDupsInt, $petsc_library), + PetscErrorCode, + (Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscCheckDupsInt(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscCheckDupsInt, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFindInt(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscFindInt, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscFindMPIInt(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscFindMPIInt, $petsc_library), + PetscErrorCode, + (PetscMPIInt, $PetscInt, Ptr{PetscMPIInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSortIntWithPermutation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSortIntWithPermutation, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortStrWithPermutation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSortStrWithPermutation, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Ptr{Cchar}}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortIntWithArray(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSortIntWithArray, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortIntWithArrayPair( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSortIntWithArrayPair, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSortMPIInt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSortMPIInt, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscMPIInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSortRemoveDupsMPIInt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSortRemoveDupsMPIInt, $petsc_library), + PetscErrorCode, + (Ptr{$PetscInt}, Ptr{PetscMPIInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSortMPIIntWithArray(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSortMPIIntWithArray, $petsc_library), + PetscErrorCode, + (PetscMPIInt, Ptr{PetscMPIInt}, Ptr{PetscMPIInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortMPIIntWithIntArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSortMPIIntWithIntArray, $petsc_library), + PetscErrorCode, + (PetscMPIInt, Ptr{PetscMPIInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortIntWithScalarArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSortIntWithScalarArray, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortIntWithDataArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSortIntWithDataArray, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{Cvoid}, Csize_t, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSortReal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSortReal, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSortRealWithArrayInt( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSortRealWithArrayInt, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscReal}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortRealWithPermutation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSortRealWithPermutation, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscReal}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSortRemoveDupsReal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSortRemoveDupsReal, $petsc_library), + PetscErrorCode, + (Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFindReal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscFindReal, $petsc_library), + PetscErrorCode, + ($PetscReal, $PetscInt, Ptr{$PetscReal}, $PetscReal, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSortSplit(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscSortSplit, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSortSplitReal(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscSortSplitReal, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscProcessTree( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscProcessTree, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{PetscBool}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscMergeIntArrayPair( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscMergeIntArrayPair, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscMergeIntArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscMergeIntArray, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscMergeMPIIntArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscMergeMPIIntArray, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{PetscMPIInt}, + $PetscInt, + Ptr{PetscMPIInt}, + Ptr{$PetscInt}, + Ptr{Ptr{PetscMPIInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscParallelSortedInt( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscParallelSortedInt, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{$PetscInt}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscTimSort(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:PetscTimSort, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Cvoid}, Csize_t, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscIntSortSemiOrdered(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscIntSortSemiOrdered, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscMPIIntSortSemiOrdered(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscMPIIntSortSemiOrdered, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscMPIInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscRealSortSemiOrdered(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRealSortSemiOrdered, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PetscTimSortWithArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscTimSortWithArray, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{Cvoid}, + Csize_t, + Ptr{Cvoid}, + Csize_t, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscIntSortSemiOrderedWithArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscIntSortSemiOrderedWithArray, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMPIIntSortSemiOrderedWithArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscMPIIntSortSemiOrderedWithArray, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscMPIInt}, Ptr{PetscMPIInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscRealSortSemiOrderedWithArrayInt( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscRealSortSemiOrderedWithArrayInt, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscReal}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSetDisplay(::$UnionPetscLib) + @chk ccall((:PetscSetDisplay, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscGetDisplay(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetDisplay, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t), + arg1, + arg2, + ) +end + +const PetscRandomType = Ptr{Cchar} + +@for_petsc function PetscRandomInitializePackage(::$UnionPetscLib) + @chk ccall( + (:PetscRandomInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscRandomRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRandomRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscRandomSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRandomSetType, $petsc_library), + PetscErrorCode, + (PetscRandom, PetscRandomType), + arg1, + arg2, + ) +end + +@for_petsc function PetscRandomSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscRandomSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscRandom,), + arg1, + ) +end + +@for_petsc function PetscRandomGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRandomGetType, $petsc_library), + PetscErrorCode, + (PetscRandom, Ptr{PetscRandomType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscRandomViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscRandomViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscRandom, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscRandomView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRandomView, $petsc_library), + PetscErrorCode, + (PetscRandom, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscRandomCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRandomCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscRandom}), + arg1, + arg2, + ) +end + +@for_petsc function PetscRandomGetValue(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRandomGetValue, $petsc_library), + PetscErrorCode, + (PetscRandom, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscRandomGetValueReal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRandomGetValueReal, $petsc_library), + PetscErrorCode, + (PetscRandom, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PetscRandomGetValues(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscRandomGetValues, $petsc_library), + PetscErrorCode, + (PetscRandom, $PetscInt, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscRandomGetValuesReal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscRandomGetValuesReal, $petsc_library), + PetscErrorCode, + (PetscRandom, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscRandomGetInterval(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscRandomGetInterval, $petsc_library), + PetscErrorCode, + (PetscRandom, Ptr{$PetscScalar}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscRandomSetInterval(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscRandomSetInterval, $petsc_library), + PetscErrorCode, + (PetscRandom, $PetscScalar, $PetscScalar), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscRandomSetSeed(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRandomSetSeed, $petsc_library), + PetscErrorCode, + (PetscRandom, Culong), + arg1, + arg2, + ) +end + +@for_petsc function PetscRandomGetSeed(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscRandomGetSeed, $petsc_library), + PetscErrorCode, + (PetscRandom, Ptr{Culong}), + arg1, + arg2, + ) +end + +@for_petsc function PetscRandomSeed(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscRandomSeed, $petsc_library), + PetscErrorCode, + (PetscRandom,), + arg1, + ) +end + +@for_petsc function PetscRandomDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscRandomDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscRandom},), + arg1, + ) +end + +@for_petsc function PetscGetFullPath(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscGetFullPath, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscGetRelativePath(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscGetRelativePath, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscGetWorkingDirectory(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetWorkingDirectory, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function PetscGetRealPath(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetRealPath, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscGetHomeDirectory(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGetHomeDirectory, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function PetscTestFile(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscTestFile, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Cchar, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscTestDirectory(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscTestDirectory, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Cchar, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMkdir(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMkdir, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscMkdtemp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMkdtemp, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscRMTree(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscRMTree, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscBinaryBigEndian(::$UnionPetscLib) + ccall((:PetscBinaryBigEndian, $petsc_library), PetscBool, ()) +end + +@for_petsc function PetscBinaryRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBinaryRead, $petsc_library), + PetscErrorCode, + (Cint, Ptr{Cvoid}, $PetscInt, Ptr{$PetscInt}, PetscDataType), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBinarySynchronizedRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscBinarySynchronizedRead, $petsc_library), + PetscErrorCode, + (MPI_Comm, Cint, Ptr{Cvoid}, $PetscInt, Ptr{$PetscInt}, PetscDataType), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscBinaryWrite(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscBinaryWrite, $petsc_library), + PetscErrorCode, + (Cint, Ptr{Cvoid}, $PetscInt, PetscDataType), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscBinarySynchronizedWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBinarySynchronizedWrite, $petsc_library), + PetscErrorCode, + (MPI_Comm, Cint, Ptr{Cvoid}, $PetscInt, PetscDataType), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBinaryOpen(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscBinaryOpen, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, PetscFileMode, Ptr{Cint}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscBinaryClose(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscBinaryClose, $petsc_library), + PetscErrorCode, + (Cint,), + arg1, + ) +end + +@for_petsc function PetscSharedTmp(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSharedTmp, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSharedWorkingDirectory(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSharedWorkingDirectory, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscGetTmp(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscGetTmp, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFileRetrieve( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscFileRetrieve, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Csize_t, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscLs(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:PetscLs, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Csize_t, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscOpenSocket(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscOpenSocket, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Cint, Ptr{Cint}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscBinarySeek(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscBinarySeek, $petsc_library), + PetscErrorCode, + (Cint, off_t, PetscBinarySeekType, Ptr{off_t}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscBinarySynchronizedSeek( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBinarySynchronizedSeek, $petsc_library), + PetscErrorCode, + (MPI_Comm, Cint, off_t, PetscBinarySeekType, Ptr{off_t}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscByteSwap(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscByteSwap, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, PetscDataType, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSetDebugTerminal(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSetDebugTerminal, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscSetDebugger(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSetDebugger, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscSetDefaultDebugger(::$UnionPetscLib) + @chk ccall((:PetscSetDefaultDebugger, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscSetDebuggerFromString(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSetDebuggerFromString, $petsc_library), + PetscErrorCode, + (Ptr{Cchar},), + arg1, + ) +end + +@for_petsc function PetscAttachDebugger(::$UnionPetscLib) + @chk ccall((:PetscAttachDebugger, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscStopForDebugger(::$UnionPetscLib) + @chk ccall((:PetscStopForDebugger, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscWaitOnError(::$UnionPetscLib) + @chk ccall((:PetscWaitOnError, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscGatherNumberOfMessages( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGatherNumberOfMessages, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscMPIInt}, Ptr{PetscMPIInt}, Ptr{PetscMPIInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGatherMessageLengths( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscGatherMessageLengths, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + PetscMPIInt, + PetscMPIInt, + Ptr{PetscMPIInt}, + Ptr{Ptr{PetscMPIInt}}, + Ptr{Ptr{PetscMPIInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscGatherMessageLengths2( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscGatherMessageLengths2, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + PetscMPIInt, + PetscMPIInt, + Ptr{PetscMPIInt}, + Ptr{PetscMPIInt}, + Ptr{Ptr{PetscMPIInt}}, + Ptr{Ptr{PetscMPIInt}}, + Ptr{Ptr{PetscMPIInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscCommBuildTwoSided( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscCommBuildTwoSided, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + PetscMPIInt, + MPI_Datatype, + PetscMPIInt, + Ptr{PetscMPIInt}, + Ptr{Cvoid}, + Ptr{PetscMPIInt}, + Ptr{Ptr{PetscMPIInt}}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscCommBuildTwoSidedF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + send, + recv, + ctx, +) + @chk ccall( + (:PetscCommBuildTwoSidedF, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + PetscMPIInt, + MPI_Datatype, + PetscMPIInt, + Ptr{PetscMPIInt}, + Ptr{Cvoid}, + Ptr{PetscMPIInt}, + Ptr{Ptr{PetscMPIInt}}, + Ptr{Cvoid}, + PetscMPIInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + send, + recv, + ctx, + ) +end + +@for_petsc function PetscCommBuildTwoSidedSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscCommBuildTwoSidedSetType, $petsc_library), + PetscErrorCode, + (MPI_Comm, PetscBuildTwoSidedType), + arg1, + arg2, + ) +end + +@for_petsc function PetscCommBuildTwoSidedGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscCommBuildTwoSidedGetType, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscBuildTwoSidedType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSSEIsEnabled(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSSEIsEnabled, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscObjectComm(::$UnionPetscLib, arg1) + ccall((:PetscObjectComm, $petsc_library), MPI_Comm, (PetscObject,), arg1) +end + +@for_petsc function PetscSubcommParent(::$UnionPetscLib, scomm) + ccall( + (:PetscSubcommParent, $petsc_library), + MPI_Comm, + (PetscSubcomm,), + scomm, + ) +end + +@for_petsc function PetscSubcommChild(::$UnionPetscLib, scomm) + ccall( + (:PetscSubcommChild, $petsc_library), + MPI_Comm, + (PetscSubcomm,), + scomm, + ) +end + +@for_petsc function PetscSubcommContiguousParent(::$UnionPetscLib, scomm) + ccall( + (:PetscSubcommContiguousParent, $petsc_library), + MPI_Comm, + (PetscSubcomm,), + scomm, + ) +end + +@for_petsc function PetscSubcommCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSubcommCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscSubcomm}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSubcommDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSubcommDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscSubcomm},), + arg1, + ) +end + +@for_petsc function PetscSubcommSetNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSubcommSetNumber, $petsc_library), + PetscErrorCode, + (PetscSubcomm, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscSubcommSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSubcommSetType, $petsc_library), + PetscErrorCode, + (PetscSubcomm, PetscSubcommType), + arg1, + arg2, + ) +end + +@for_petsc function PetscSubcommSetTypeGeneral( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSubcommSetTypeGeneral, $petsc_library), + PetscErrorCode, + (PetscSubcomm, PetscMPIInt, PetscMPIInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSubcommView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSubcommView, $petsc_library), + PetscErrorCode, + (PetscSubcomm, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscSubcommSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSubcommSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscSubcomm,), + arg1, + ) +end + +@for_petsc function PetscSubcommSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSubcommSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscSubcomm, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSubcommGetParent(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSubcommGetParent, $petsc_library), + PetscErrorCode, + (PetscSubcomm, Ptr{MPI_Comm}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSubcommGetContiguousParent( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscSubcommGetContiguousParent, $petsc_library), + PetscErrorCode, + (PetscSubcomm, Ptr{MPI_Comm}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSubcommGetChild(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSubcommGetChild, $petsc_library), + PetscErrorCode, + (PetscSubcomm, Ptr{MPI_Comm}), + arg1, + arg2, + ) +end + +@for_petsc function PetscHeapCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscHeapCreate, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscHeap}), + arg1, + arg2, + ) +end + +@for_petsc function PetscHeapAdd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscHeapAdd, $petsc_library), + PetscErrorCode, + (PetscHeap, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscHeapPop(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscHeapPop, $petsc_library), + PetscErrorCode, + (PetscHeap, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscHeapPeek(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscHeapPeek, $petsc_library), + PetscErrorCode, + (PetscHeap, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscHeapStash(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscHeapStash, $petsc_library), + PetscErrorCode, + (PetscHeap, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscHeapUnstash(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscHeapUnstash, $petsc_library), + PetscErrorCode, + (PetscHeap,), + arg1, + ) +end + +@for_petsc function PetscHeapDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscHeapDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscHeap},), + arg1, + ) +end + +@for_petsc function PetscHeapView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscHeapView, $petsc_library), + PetscErrorCode, + (PetscHeap, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscProcessPlacementView(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscProcessPlacementView, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscShmCommGet(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscShmCommGet, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscShmComm}), + arg1, + arg2, + ) +end + +@for_petsc function PetscShmCommGlobalToLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscShmCommGlobalToLocal, $petsc_library), + PetscErrorCode, + (PetscShmComm, PetscMPIInt, Ptr{PetscMPIInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscShmCommLocalToGlobal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscShmCommLocalToGlobal, $petsc_library), + PetscErrorCode, + (PetscShmComm, PetscMPIInt, Ptr{PetscMPIInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscShmCommGetMpiShmComm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscShmCommGetMpiShmComm, $petsc_library), + PetscErrorCode, + (PetscShmComm, Ptr{MPI_Comm}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOmpCtrlCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscOmpCtrlCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{PetscOmpCtrl}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscOmpCtrlGetOmpComms( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscOmpCtrlGetOmpComms, $petsc_library), + PetscErrorCode, + (PetscOmpCtrl, Ptr{MPI_Comm}, Ptr{MPI_Comm}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscOmpCtrlDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOmpCtrlDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscOmpCtrl},), + arg1, + ) +end + +@for_petsc function PetscOmpCtrlBarrier(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOmpCtrlBarrier, $petsc_library), + PetscErrorCode, + (PetscOmpCtrl,), + arg1, + ) +end + +@for_petsc function PetscOmpCtrlOmpRegionOnMasterBegin(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOmpCtrlOmpRegionOnMasterBegin, $petsc_library), + PetscErrorCode, + (PetscOmpCtrl,), + arg1, + ) +end + +@for_petsc function PetscOmpCtrlOmpRegionOnMasterEnd(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOmpCtrlOmpRegionOnMasterEnd, $petsc_library), + PetscErrorCode, + (PetscOmpCtrl,), + arg1, + ) +end + +@for_petsc function PetscSegBufferCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSegBufferCreate, $petsc_library), + PetscErrorCode, + (Csize_t, Csize_t, Ptr{PetscSegBuffer}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSegBufferDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSegBufferDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscSegBuffer},), + arg1, + ) +end + +@for_petsc function PetscSegBufferGet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSegBufferGet, $petsc_library), + PetscErrorCode, + (PetscSegBuffer, Csize_t, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSegBufferExtractAlloc(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSegBufferExtractAlloc, $petsc_library), + PetscErrorCode, + (PetscSegBuffer, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSegBufferExtractTo(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSegBufferExtractTo, $petsc_library), + PetscErrorCode, + (PetscSegBuffer, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSegBufferExtractInPlace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSegBufferExtractInPlace, $petsc_library), + PetscErrorCode, + (PetscSegBuffer, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSegBufferGetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSegBufferGetSize, $petsc_library), + PetscErrorCode, + (PetscSegBuffer, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSegBufferUnuse(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSegBufferUnuse, $petsc_library), + PetscErrorCode, + (PetscSegBuffer, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function PetscSegBufferGetInts(::$UnionPetscLib, seg, count, slot) + @chk ccall( + (:PetscSegBufferGetInts, $petsc_library), + PetscErrorCode, + (PetscSegBuffer, Csize_t, Ptr{Ptr{$PetscInt}}), + seg, + count, + slot, + ) +end + +@for_petsc function PetscOptionsHelpPrintedDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsHelpPrintedDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscOptionsHelpPrinted},), + arg1, + ) +end + +@for_petsc function PetscOptionsHelpPrintedCreate(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsHelpPrintedCreate, $petsc_library), + PetscErrorCode, + (Ptr{PetscOptionsHelpPrinted},), + arg1, + ) +end + +@for_petsc function PetscOptionsHelpPrintedCheck( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscOptionsHelpPrintedCheck, $petsc_library), + PetscErrorCode, + (PetscOptionsHelpPrinted, Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscCitationsRegister(::$UnionPetscLib, cit, set) + @chk ccall( + (:PetscCitationsRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscBool}), + cit, + set, + ) +end + +@for_petsc function PetscURLShorten(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscURLShorten, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscGoogleDriveAuthorize( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGoogleDriveAuthorize, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGoogleDriveRefresh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGoogleDriveRefresh, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGoogleDriveUpload(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscGoogleDriveUpload, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscBoxAuthorize(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscBoxAuthorize, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscBoxRefresh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBoxRefresh, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscGlobusGetTransfers( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGlobusGetTransfers, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscTextBelt(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscTextBelt, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscTellMyCell(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscTellMyCell, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscPullJSONValue( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscPullJSONValue, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}, Csize_t, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscPushJSONValue(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscPushJSONValue, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MPIU_Win_allocate_shared( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MPIU_Win_allocate_shared, $petsc_library), + PetscErrorCode, + (MPI_Aint, PetscMPIInt, MPI_Info, MPI_Comm, Ptr{Cvoid}, Ptr{MPI_Win}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MPIU_Win_shared_query( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MPIU_Win_shared_query, $petsc_library), + PetscErrorCode, + (MPI_Win, PetscMPIInt, Ptr{MPI_Aint}, Ptr{PetscMPIInt}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscHasExternalPackage(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscHasExternalPackage, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +mutable struct _n_PetscBag end + +const PetscBag = Ptr{_n_PetscBag} + +mutable struct _n_PetscBagItem end + +const PetscBagItem = Ptr{_n_PetscBagItem} + +@for_petsc function PetscBagCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscBagCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Csize_t, Ptr{PetscBag}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscBagDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscBagDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscBag},), + arg1, + ) +end + +@for_petsc function PetscBagGetData(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscBagGetData, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscBagRegisterReal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBagRegisterReal, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}, $PetscReal, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBagRegisterRealArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBagRegisterRealArray, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}, $PetscInt, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBagRegisterString( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscBagRegisterString, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}, $PetscInt, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscBagRegisterScalar( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBagRegisterScalar, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}, $PetscScalar, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBagRegisterInt( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBagRegisterInt, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}, $PetscInt, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBagRegisterInt64( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBagRegisterInt64, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}, PetscInt64, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBagRegisterIntArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBagRegisterIntArray, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}, $PetscInt, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBagRegisterEnum( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscBagRegisterEnum, $petsc_library), + PetscErrorCode, + ( + PetscBag, + Ptr{Cvoid}, + Ptr{Ptr{Cchar}}, + PetscEnum, + Ptr{Cchar}, + Ptr{Cchar}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscBagRegisterBool( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBagRegisterBool, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}, PetscBool, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBagRegisterBoolArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscBagRegisterBoolArray, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}, $PetscInt, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscBagGetNames(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscBagGetNames, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscBagSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscBagSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscBag,), + arg1, + ) +end + +@for_petsc function PetscBagGetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscBagGetName, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscBagSetName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscBagSetName, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscBagSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscBagSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscBagView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscBagView, $petsc_library), + PetscErrorCode, + (PetscBag, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscBagLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscBagLoad, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscBag), + arg1, + arg2, + ) +end + +@for_petsc function PetscBagViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscBagViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscBag, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscBagSetViewer(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscBagSetViewer, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscBagSetLoader(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscBagSetLoader, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscBagSetDestroy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscBagSetDestroy, $petsc_library), + PetscErrorCode, + (PetscBag, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +const PetscDrawType = Ptr{Cchar} + +mutable struct _p_PetscDraw end + +const PetscDraw = Ptr{_p_PetscDraw} + +mutable struct _p_PetscDrawAxis end + +const PetscDrawAxis = Ptr{_p_PetscDrawAxis} + +mutable struct _p_PetscDrawLG end + +const PetscDrawLG = Ptr{_p_PetscDrawLG} + +mutable struct _p_PetscDrawSP end + +const PetscDrawSP = Ptr{_p_PetscDrawSP} + +mutable struct _p_PetscDrawHG end + +const PetscDrawHG = Ptr{_p_PetscDrawHG} + +mutable struct _p_PetscDrawBar end + +const PetscDrawBar = Ptr{_p_PetscDrawBar} + +const PetscViewerType = Ptr{Cchar} + +@for_petsc function PetscViewerInitializePackage(::$UnionPetscLib) + @chk ccall( + (:PetscViewerInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscViewerRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscViewer}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerASCIIOpenWithFILE( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerASCIIOpenWithFILE, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Libc.FILE}, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerASCIIOpen(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscViewerASCIIOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerASCIISetFILE(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerASCIISetFILE, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Libc.FILE}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryOpen( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscViewerBinaryOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscFileMode, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscViewerADIOSOpen( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscViewerADIOSOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscFileMode, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscViewerADIOS2Open( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscViewerADIOS2Open, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscFileMode, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscViewerBinaryGetFlowControl( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinaryGetFlowControl, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinarySetFlowControl( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinarySetFlowControl, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinarySetUseMPIIO(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerBinarySetUseMPIIO, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryGetUseMPIIO(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerBinaryGetUseMPIIO, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryGetMPIIODescriptor( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinaryGetMPIIODescriptor, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{MPI_File}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryGetMPIIOOffset( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinaryGetMPIIOOffset, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{MPI_Offset}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryAddMPIIOOffset( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinaryAddMPIIOOffset, $petsc_library), + PetscErrorCode, + (PetscViewer, MPI_Offset), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerSocketOpen( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscViewerSocketOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Cint, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscViewerStringOpen( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscViewerStringOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Csize_t, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscViewerDrawOpen( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscViewerDrawOpen, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Cchar}, + Ptr{Cchar}, + Cint, + Cint, + Cint, + Cint, + Ptr{PetscViewer}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscViewerDrawSetDrawType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawSetDrawType, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscDrawType), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawGetDrawType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawGetDrawType, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscDrawType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawSetTitle(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawSetTitle, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawGetTitle(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawGetTitle, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawGetDraw(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscViewerDrawGetDraw, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt, Ptr{PetscDraw}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerDrawBaseAdd(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawBaseAdd, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawBaseSet(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawBaseSet, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawGetDrawLG(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscViewerDrawGetDrawLG, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt, Ptr{PetscDrawLG}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerDrawGetDrawAxis( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerDrawGetDrawAxis, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt, Ptr{PetscDrawAxis}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerMathematicaOpen( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscViewerMathematicaOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Cint, Ptr{Cchar}, Ptr{Cchar}, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscViewerSiloOpen(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscViewerSiloOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerMatlabOpen( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscViewerMatlabOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscFileMode, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@enum PetscViewerGLVisType::UInt32 begin + PETSC_VIEWER_GLVIS_DUMP = 0 + PETSC_VIEWER_GLVIS_SOCKET = 1 +end + +@for_petsc function PetscViewerGLVisOpen( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscViewerGLVisOpen, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + PetscViewerGLVisType, + Ptr{Cchar}, + $PetscInt, + Ptr{PetscViewer}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscViewerGLVisSetPrecision(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerGLVisSetPrecision, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerGLVisSetSnapId(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerGLVisSetSnapId, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerGLVisSetFields( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscViewerGLVisSetFields, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + $PetscInt, + Ptr{Ptr{Cchar}}, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{PetscObject}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscViewerGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerGetType, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscViewerType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerSetType, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscViewerType), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscViewer},), + arg1, + ) +end + +@for_petsc function PetscViewerGetSubViewer(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscViewerGetSubViewer, $petsc_library), + PetscErrorCode, + (PetscViewer, MPI_Comm, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerRestoreSubViewer( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerRestoreSubViewer, $petsc_library), + PetscErrorCode, + (PetscViewer, MPI_Comm, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerSetUp, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerView, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerAppendOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerGetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerReadable(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerReadable, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerWritable(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerWritable, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerCheckReadable(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerCheckReadable, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerCheckWritable(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerCheckWritable, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@enum PetscViewerFormat::UInt32 begin + PETSC_VIEWER_DEFAULT = 0 + PETSC_VIEWER_ASCII_MATLAB = 1 + PETSC_VIEWER_ASCII_MATHEMATICA = 2 + PETSC_VIEWER_ASCII_IMPL = 3 + PETSC_VIEWER_ASCII_INFO = 4 + PETSC_VIEWER_ASCII_INFO_DETAIL = 5 + PETSC_VIEWER_ASCII_COMMON = 6 + PETSC_VIEWER_ASCII_SYMMODU = 7 + PETSC_VIEWER_ASCII_INDEX = 8 + PETSC_VIEWER_ASCII_DENSE = 9 + PETSC_VIEWER_ASCII_MATRIXMARKET = 10 + PETSC_VIEWER_ASCII_VTK_DEPRECATED = 11 + # PETSC_VIEWER_ASCII_VTK = 11 + PETSC_VIEWER_ASCII_VTK_CELL_DEPRECATED = 12 + # PETSC_VIEWER_ASCII_VTK_CELL = 12 + PETSC_VIEWER_ASCII_VTK_COORDS_DEPRECATED = 13 + # PETSC_VIEWER_ASCII_VTK_COORDS = 13 + PETSC_VIEWER_ASCII_PCICE = 14 + PETSC_VIEWER_ASCII_PYTHON = 15 + PETSC_VIEWER_ASCII_FACTOR_INFO = 16 + PETSC_VIEWER_ASCII_LATEX = 17 + PETSC_VIEWER_ASCII_XML = 18 + PETSC_VIEWER_ASCII_FLAMEGRAPH = 19 + PETSC_VIEWER_ASCII_GLVIS = 20 + PETSC_VIEWER_ASCII_CSV = 21 + PETSC_VIEWER_DRAW_BASIC = 22 + PETSC_VIEWER_DRAW_LG = 23 + PETSC_VIEWER_DRAW_LG_XRANGE = 24 + PETSC_VIEWER_DRAW_CONTOUR = 25 + PETSC_VIEWER_DRAW_PORTS = 26 + PETSC_VIEWER_VTK_VTS = 27 + PETSC_VIEWER_VTK_VTR = 28 + PETSC_VIEWER_VTK_VTU = 29 + PETSC_VIEWER_BINARY_MATLAB = 30 + PETSC_VIEWER_NATIVE = 31 + PETSC_VIEWER_HDF5_PETSC = 32 + PETSC_VIEWER_HDF5_VIZ = 33 + PETSC_VIEWER_HDF5_XDMF = 34 + PETSC_VIEWER_HDF5_MAT = 35 + PETSC_VIEWER_NOFORMAT = 36 + PETSC_VIEWER_LOAD_BALANCE = 37 + PETSC_VIEWER_FAILED = 38 +end + +@for_petsc function PetscViewerSetFormat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerSetFormat, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscViewerFormat), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerPushFormat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerPushFormat, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscViewerFormat), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerPopFormat(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerPopFormat, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerGetFormat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerGetFormat, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscViewerFormat}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerFlush(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerFlush, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscOptionsPushGetViewerOff(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsPushGetViewerOff, $petsc_library), + PetscErrorCode, + (PetscBool,), + arg1, + ) +end + +@for_petsc function PetscOptionsPopGetViewerOff(::$UnionPetscLib) + @chk ccall( + (:PetscOptionsPopGetViewerOff, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscOptionsGetViewerOff(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscOptionsGetViewerOff, $petsc_library), + PetscErrorCode, + (Ptr{PetscBool},), + arg1, + ) +end + +@for_petsc function PetscOptionsGetViewer( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscOptionsGetViewer, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + PetscOptions, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{PetscViewer}, + Ptr{PetscViewerFormat}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +mutable struct PetscViewerAndFormat + viewer::PetscViewer + format::PetscViewerFormat + lg::PetscDrawLG + data::Ptr{Cvoid} + PetscViewerAndFormat() = new() +end + +@for_petsc function PetscViewerAndFormatCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerAndFormatCreate, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscViewerFormat, Ptr{Ptr{PetscViewerAndFormat}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerAndFormatDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerAndFormatDestroy, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{PetscViewerAndFormat}},), + arg1, + ) +end + +@for_petsc function PetscViewerASCIIGetPointer(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerASCIIGetPointer, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Libc.FILE}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerFileGetMode(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerFileGetMode, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscFileMode}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerFileSetMode(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerFileSetMode, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscFileMode), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscViewerRead, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cvoid}, $PetscInt, Ptr{$PetscInt}, PetscDataType), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscViewerASCIIPushSynchronized(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerASCIIPushSynchronized, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerASCIIPopSynchronized(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerASCIIPopSynchronized, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerASCIIPushTab(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerASCIIPushTab, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerASCIIPopTab(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerASCIIPopTab, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerASCIIUseTabs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerASCIIUseTabs, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerASCIISetTab(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerASCIISetTab, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerASCIIGetTab(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerASCIIGetTab, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerASCIIAddTab(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerASCIIAddTab, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerASCIISubtractTab(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerASCIISubtractTab, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerASCIIRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscViewerASCIIRead, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cvoid}, $PetscInt, Ptr{$PetscInt}, PetscDataType), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscViewerBinaryGetDescriptor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerBinaryGetDescriptor, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cint}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryGetInfoPointer( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinaryGetInfoPointer, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Libc.FILE}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscViewerBinaryRead, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cvoid}, $PetscInt, Ptr{$PetscInt}, PetscDataType), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscViewerBinaryWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscViewerBinaryWrite, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cvoid}, $PetscInt, PetscDataType), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscViewerBinaryReadAll( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscViewerBinaryReadAll, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + Ptr{Cvoid}, + $PetscInt, + $PetscInt, + $PetscInt, + PetscDataType, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscViewerBinaryWriteAll( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscViewerBinaryWriteAll, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + Ptr{Cvoid}, + $PetscInt, + $PetscInt, + $PetscInt, + PetscDataType, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscViewerStringSetString( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerStringSetString, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerStringGetStringRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerStringGetStringRead, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Cchar}}, Ptr{Csize_t}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerStringSetOwnString(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerStringSetOwnString, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerDrawClear(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerDrawClear, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerDrawSetHold(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawSetHold, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawGetHold(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawGetHold, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawSetPause(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawSetPause, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawGetPause(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerDrawGetPause, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerDrawSetInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscViewerDrawSetInfo, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}, Ptr{Cchar}, Cint, Cint, Cint, Cint), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscViewerDrawResize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscViewerDrawResize, $petsc_library), + PetscErrorCode, + (PetscViewer, Cint, Cint), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerDrawSetBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscViewerDrawSetBounds, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerDrawGetBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscViewerDrawGetBounds, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{$PetscInt}, Ptr{Ptr{$PetscReal}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerSocketSetConnection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerSocketSetConnection, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}, Cint), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerBinarySkipInfo(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerBinarySkipInfo, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerBinarySetSkipInfo(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerBinarySetSkipInfo, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryGetSkipInfo(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerBinaryGetSkipInfo, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinarySetSkipOptions( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinarySetSkipOptions, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryGetSkipOptions( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinaryGetSkipOptions, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinarySetSkipHeader(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerBinarySetSkipHeader, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryGetSkipHeader(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerBinaryGetSkipHeader, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryReadStringArray( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinaryReadStringArray, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Ptr{Cchar}}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerBinaryWriteStringArray( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerBinaryWriteStringArray, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerFileSetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerFileSetName, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerFileGetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerFileGetName, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerVUGetPointer(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerVUGetPointer, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Libc.FILE}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerVUSetVecSeen(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerVUSetVecSeen, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerVUGetVecSeen(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerVUGetVecSeen, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerVUFlushDeferred(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerVUFlushDeferred, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerVUSetMode(::$UnionPetscLib, viewer, mode) + @chk ccall( + (:PetscViewerVUSetMode, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscFileMode), + viewer, + mode, + ) +end + +@for_petsc function PetscViewerMathematicaInitializePackage(::$UnionPetscLib) + @chk ccall( + (:PetscViewerMathematicaInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscViewerMathematicaFinalizePackage(::$UnionPetscLib) + @chk ccall( + (:PetscViewerMathematicaFinalizePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscViewerMathematicaGetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerMathematicaGetName, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerMathematicaSetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerMathematicaSetName, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerMathematicaClearName(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerMathematicaClearName, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerMathematicaSkipPackets( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerMathematicaSkipPackets, $petsc_library), + PetscErrorCode, + (PetscViewer, Cint), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerSiloGetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerSiloGetName, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerSiloSetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerSiloSetName, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerSiloClearName(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerSiloClearName, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@for_petsc function PetscViewerSiloGetMeshName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerSiloGetMeshName, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerSiloSetMeshName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerSiloSetMeshName, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerSiloClearMeshName(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewerSiloClearMeshName, $petsc_library), + PetscErrorCode, + (PetscViewer,), + arg1, + ) +end + +@enum PetscViewerVTKFieldType::UInt32 begin + PETSC_VTK_INVALID = 0 + PETSC_VTK_POINT_FIELD = 1 + PETSC_VTK_POINT_VECTOR_FIELD = 2 + PETSC_VTK_CELL_FIELD = 3 + PETSC_VTK_CELL_VECTOR_FIELD = 4 +end + +@for_petsc function PetscViewerVTKAddField( + ::$UnionPetscLib, + arg1, + arg2, + PetscViewerVTKWriteFunction, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscViewerVTKAddField, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + PetscObject, + Ptr{Cvoid}, + $PetscInt, + PetscViewerVTKFieldType, + PetscBool, + PetscObject, + ), + arg1, + arg2, + PetscViewerVTKWriteFunction, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscViewerVTKGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerVTKGetDM, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{PetscObject}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerVTKOpen(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscViewerVTKOpen, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscFileMode, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PETSC_VIEWER_STDOUT_(::$UnionPetscLib, arg1) + ccall( + (:PETSC_VIEWER_STDOUT_, $petsc_library), + PetscViewer, + (MPI_Comm,), + arg1, + ) +end + +@for_petsc function PetscViewerASCIIGetStdout(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerASCIIGetStdout, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscViewer}), + arg1, + arg2, + ) +end + +@for_petsc function PETSC_VIEWER_STDERR_(::$UnionPetscLib, arg1) + ccall( + (:PETSC_VIEWER_STDERR_, $petsc_library), + PetscViewer, + (MPI_Comm,), + arg1, + ) +end + +@for_petsc function PetscViewerASCIIGetStderr(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerASCIIGetStderr, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscViewer}), + arg1, + arg2, + ) +end + +@for_petsc function PETSC_VIEWER_DRAW_(::$UnionPetscLib, arg1) + ccall((:PETSC_VIEWER_DRAW_, $petsc_library), PetscViewer, (MPI_Comm,), arg1) +end + +@for_petsc function PETSC_VIEWER_SOCKET_(::$UnionPetscLib, arg1) + ccall( + (:PETSC_VIEWER_SOCKET_, $petsc_library), + PetscViewer, + (MPI_Comm,), + arg1, + ) +end + +@for_petsc function PETSC_VIEWER_BINARY_(::$UnionPetscLib, arg1) + ccall( + (:PETSC_VIEWER_BINARY_, $petsc_library), + PetscViewer, + (MPI_Comm,), + arg1, + ) +end + +@for_petsc function PETSC_VIEWER_MATLAB_(::$UnionPetscLib, arg1) + ccall( + (:PETSC_VIEWER_MATLAB_, $petsc_library), + PetscViewer, + (MPI_Comm,), + arg1, + ) +end + +@for_petsc function PETSC_VIEWER_HDF5_(::$UnionPetscLib, arg1) + ccall((:PETSC_VIEWER_HDF5_, $petsc_library), PetscViewer, (MPI_Comm,), arg1) +end + +@for_petsc function PETSC_VIEWER_GLVIS_(::$UnionPetscLib, arg1) + ccall( + (:PETSC_VIEWER_GLVIS_, $petsc_library), + PetscViewer, + (MPI_Comm,), + arg1, + ) +end + +@for_petsc function PETSC_VIEWER_EXODUSII_(::$UnionPetscLib, arg1) + ccall( + (:PETSC_VIEWER_EXODUSII_, $petsc_library), + PetscViewer, + (MPI_Comm,), + arg1, + ) +end + +@for_petsc function PetscViewerFlowControlStart( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerFlowControlStart, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerFlowControlStepMain( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscViewerFlowControlStepMain, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt, Ptr{$PetscInt}, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscViewerFlowControlEndMain(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerFlowControlEndMain, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerFlowControlStepWorker( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerFlowControlStepWorker, $petsc_library), + PetscErrorCode, + (PetscViewer, PetscMPIInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerFlowControlEndWorker( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerFlowControlEndWorker, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerFlowControlStepMaster( + ::$UnionPetscLib, + viewer, + i, + mcnt, + cnt, +) + @chk ccall( + (:PetscViewerFlowControlStepMaster, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt, Ptr{$PetscInt}, $PetscInt), + viewer, + i, + mcnt, + cnt, + ) +end + +@for_petsc function PetscViewerFlowControlEndMaster( + ::$UnionPetscLib, + viewer, + mcnt, +) + @chk ccall( + (:PetscViewerFlowControlEndMaster, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{$PetscInt}), + viewer, + mcnt, + ) +end + +@for_petsc function PetscViewerMatlabPutArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscViewerMatlabPutArray, $petsc_library), + PetscErrorCode, + (PetscViewer, Cint, Cint, Ptr{$PetscScalar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscViewerMatlabGetArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscViewerMatlabGetArray, $petsc_library), + PetscErrorCode, + (PetscViewer, Cint, Cint, Ptr{$PetscScalar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscViewerMatlabPutVariable( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscViewerMatlabPutVariable, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +mutable struct _n_PetscViewers end + +const PetscViewers = Ptr{_n_PetscViewers} + +@for_petsc function PetscViewersCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewersCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscViewers}), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewersDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscViewersDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscViewers},), + arg1, + ) +end + +@for_petsc function PetscViewersGetViewer(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscViewersGetViewer, $petsc_library), + PetscErrorCode, + (PetscViewers, $PetscInt, Ptr{PetscViewer}), + arg1, + arg2, + arg3, + ) +end + +const PetscBT = Ptr{Cchar} + +@for_petsc function PetscBTLength(::$UnionPetscLib, m) + ccall((:PetscBTLength, $petsc_library), $PetscInt, ($PetscInt,), m) +end + +@for_petsc function PetscBTMemzero(::$UnionPetscLib, m, array) + @chk ccall( + (:PetscBTMemzero, $petsc_library), + PetscErrorCode, + ($PetscInt, PetscBT), + m, + array, + ) +end + +@for_petsc function PetscBTDestroy(::$UnionPetscLib, array) + @chk ccall( + (:PetscBTDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscBT},), + array, + ) +end + +@for_petsc function PetscBTLookup(::$UnionPetscLib, array, index) + ccall( + (:PetscBTLookup, $petsc_library), + Cchar, + (PetscBT, $PetscInt), + array, + index, + ) +end + +@for_petsc function PetscBTView(::$UnionPetscLib, m, bt, viewer) + @chk ccall( + (:PetscBTView, $petsc_library), + PetscErrorCode, + ($PetscInt, PetscBT, PetscViewer), + m, + bt, + viewer, + ) +end + +@for_petsc function PetscBTCreate(::$UnionPetscLib, m, array) + @chk ccall( + (:PetscBTCreate, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscBT}), + m, + array, + ) +end + +@for_petsc function PetscBTLookupSet(::$UnionPetscLib, array, index) + ccall( + (:PetscBTLookupSet, $petsc_library), + Cchar, + (PetscBT, $PetscInt), + array, + index, + ) +end + +@for_petsc function PetscBTSet(::$UnionPetscLib, array, index) + @chk ccall( + (:PetscBTSet, $petsc_library), + PetscErrorCode, + (PetscBT, $PetscInt), + array, + index, + ) +end + +@for_petsc function PetscBTNegate(::$UnionPetscLib, array, index) + @chk ccall( + (:PetscBTNegate, $petsc_library), + PetscErrorCode, + (PetscBT, $PetscInt), + array, + index, + ) +end + +@for_petsc function PetscBTLookupClear(::$UnionPetscLib, array, index) + ccall( + (:PetscBTLookupClear, $petsc_library), + Cchar, + (PetscBT, $PetscInt), + array, + index, + ) +end + +@for_petsc function PetscBTClear(::$UnionPetscLib, array, index) + @chk ccall( + (:PetscBTClear, $petsc_library), + PetscErrorCode, + (PetscBT, $PetscInt), + array, + index, + ) +end + +mutable struct _p_PetscMatlabEngine end + +const PetscMatlabEngine = Ptr{_p_PetscMatlabEngine} + +@for_petsc function PetscMatlabEngineCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscMatlabEngineCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{PetscMatlabEngine}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscMatlabEngineDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscMatlabEngineDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscMatlabEngine},), + arg1, + ) +end + +@for_petsc function PetscMatlabEngineGetOutput(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscMatlabEngineGetOutput, $petsc_library), + PetscErrorCode, + (PetscMatlabEngine, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscMatlabEnginePrintOutput(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscMatlabEnginePrintOutput, $petsc_library), + PetscErrorCode, + (PetscMatlabEngine, Ptr{Libc.FILE}), + arg1, + arg2, + ) +end + +@for_petsc function PetscMatlabEnginePut(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscMatlabEnginePut, $petsc_library), + PetscErrorCode, + (PetscMatlabEngine, PetscObject), + arg1, + arg2, + ) +end + +@for_petsc function PetscMatlabEngineGet(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscMatlabEngineGet, $petsc_library), + PetscErrorCode, + (PetscMatlabEngine, PetscObject), + arg1, + arg2, + ) +end + +@for_petsc function PetscMatlabEnginePutArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscMatlabEnginePutArray, $petsc_library), + PetscErrorCode, + (PetscMatlabEngine, Cint, Cint, Ptr{$PetscScalar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscMatlabEngineGetArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscMatlabEngineGetArray, $petsc_library), + PetscErrorCode, + (PetscMatlabEngine, Cint, Cint, Ptr{$PetscScalar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PETSC_MATLAB_ENGINE_(::$UnionPetscLib, arg1) + ccall( + (:PETSC_MATLAB_ENGINE_, $petsc_library), + PetscMatlabEngine, + (MPI_Comm,), + arg1, + ) +end + +@for_petsc function PetscDrawInitializePackage(::$UnionPetscLib) + @chk ccall( + (:PetscDrawInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscDrawFinalizePackage(::$UnionPetscLib) + @chk ccall((:PetscDrawFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscDrawRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawGetType, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{PetscDrawType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSetType, $petsc_library), + PetscErrorCode, + (PetscDraw, PetscDrawType), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscDrawCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Cchar}, + Ptr{Cchar}, + Cint, + Cint, + Cint, + Cint, + Ptr{PetscDraw}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscDrawSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawSetSave(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSetSave, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawSetSaveMovie(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSetSaveMovie, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawSetSaveFinalImage(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSetSaveFinalImage, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawView, $petsc_library), + PetscErrorCode, + (PetscDraw, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscDraw, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawRealToColor(::$UnionPetscLib, value, min, max) + ccall( + (:PetscDrawRealToColor, $petsc_library), + Cint, + ($PetscReal, $PetscReal, $PetscReal), + value, + min, + max, + ) +end + +@for_petsc function PetscDrawOpenX( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscDrawOpenX, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Cchar}, + Ptr{Cchar}, + Cint, + Cint, + Cint, + Cint, + Ptr{PetscDraw}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscDrawOpenImage( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawOpenImage, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Cint, Cint, Ptr{PetscDraw}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawOpenNull(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawOpenNull, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscDraw}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscDraw},), + arg1, + ) +end + +@for_petsc function PetscDrawIsNull(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawIsNull, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawGetPopup(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawGetPopup, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{PetscDraw}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawScalePopup(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawScalePopup, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawCheckResizedWindow(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawCheckResizedWindow, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawResizeWindow(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawResizeWindow, $petsc_library), + PetscErrorCode, + (PetscDraw, Cint, Cint), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawGetWindowSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawGetWindowSize, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Cint}, Ptr{Cint}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawPixelToCoordinate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawPixelToCoordinate, $petsc_library), + PetscErrorCode, + (PetscDraw, Cint, Cint, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawCoordinateToPixel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawCoordinateToPixel, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, Ptr{Cint}, Ptr{Cint}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawIndicatorFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscDrawIndicatorFunction, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + Cint, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscDrawLine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDrawLine, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, $PetscReal, $PetscReal, Cint), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDrawArrow( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDrawArrow, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, $PetscReal, $PetscReal, Cint), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDrawLineSetWidth(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLineSetWidth, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLineGetWidth(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLineGetWidth, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@enum PetscDrawMarkerType::UInt32 begin + PETSC_DRAW_MARKER_CROSS = 0 + PETSC_DRAW_MARKER_POINT = 1 + PETSC_DRAW_MARKER_PLUS = 2 + PETSC_DRAW_MARKER_CIRCLE = 3 +end + +@for_petsc function PetscDrawMarker(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscDrawMarker, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, Cint), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDrawSetMarkerType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSetMarkerType, $petsc_library), + PetscErrorCode, + (PetscDraw, PetscDrawMarkerType), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawGetMarkerType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawGetMarkerType, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{PetscDrawMarkerType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawPoint(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscDrawPoint, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, Cint), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDrawPointPixel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDrawPointPixel, $petsc_library), + PetscErrorCode, + (PetscDraw, Cint, Cint, Cint), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDrawPointSetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawPointSetSize, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawRectangle( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscDrawRectangle, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + Cint, + Cint, + Cint, + Cint, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscDrawTriangle( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:PetscDrawTriangle, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + Cint, + Cint, + Cint, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function PetscDrawEllipse( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDrawEllipse, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, $PetscReal, $PetscReal, Cint), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDrawTensorContourPatch( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscDrawTensorContourPatch, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + Cint, + Cint, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + $PetscReal, + $PetscReal, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscDrawTensorContour( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDrawTensorContour, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + Cint, + Cint, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDrawString( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawString, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, Cint, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawStringCentered( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawStringCentered, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, Cint, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawStringBoxed( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscDrawStringBoxed, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + $PetscReal, + $PetscReal, + Cint, + Cint, + Ptr{Cchar}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscDrawStringVertical( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawStringVertical, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, Cint, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawStringSetSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawStringSetSize, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawStringGetSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawStringGetSize, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawSetViewPort( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawSetViewPort, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawGetViewPort( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawGetViewPort, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawSplitViewPort(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawSplitViewPort, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawSetCoordinates( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawSetCoordinates, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawGetCoordinates( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawGetCoordinates, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawSetTitle(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSetTitle, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawAppendTitle(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawAppendTitle, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawGetTitle(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawGetTitle, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawSetPause(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSetPause, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawGetPause(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawGetPause, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawPause(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawPause, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawSetDoubleBuffer(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawSetDoubleBuffer, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawClear(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawClear, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawFlush(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawFlush, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawSave(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawSave, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawSaveMovie(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawSaveMovie, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawBOP(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawBOP, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawEOP(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawEOP, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawSetDisplay(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSetDisplay, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawGetSingleton(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawGetSingleton, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{PetscDraw}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawRestoreSingleton(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawRestoreSingleton, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{PetscDraw}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawGetCurrentPoint(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawGetCurrentPoint, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawSetCurrentPoint(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawSetCurrentPoint, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawPushCurrentPoint( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDrawPushCurrentPoint, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawPopCurrentPoint(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawPopCurrentPoint, $petsc_library), + PetscErrorCode, + (PetscDraw,), + arg1, + ) +end + +@for_petsc function PetscDrawGetBoundingBox( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawGetBoundingBox, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@enum PetscDrawButton::UInt32 begin + PETSC_BUTTON_NONE = 0 + PETSC_BUTTON_LEFT = 1 + PETSC_BUTTON_CENTER = 2 + PETSC_BUTTON_RIGHT = 3 + PETSC_BUTTON_WHEEL_UP = 4 + PETSC_BUTTON_WHEEL_DOWN = 5 + PETSC_BUTTON_LEFT_SHIFT = 6 + PETSC_BUTTON_CENTER_SHIFT = 7 + PETSC_BUTTON_RIGHT_SHIFT = 8 +end + +@for_petsc function PetscDrawGetMouseButton( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDrawGetMouseButton, $petsc_library), + PetscErrorCode, + ( + PetscDraw, + Ptr{PetscDrawButton}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDrawZoom(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawZoom, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawAxisCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawAxisCreate, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{PetscDrawAxis}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawAxisDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawAxisDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscDrawAxis},), + arg1, + ) +end + +@for_petsc function PetscDrawAxisDraw(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawAxisDraw, $petsc_library), + PetscErrorCode, + (PetscDrawAxis,), + arg1, + ) +end + +@for_petsc function PetscDrawAxisSetLimits( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawAxisSetLimits, $petsc_library), + PetscErrorCode, + (PetscDrawAxis, $PetscReal, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawAxisGetLimits( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawAxisGetLimits, $petsc_library), + PetscErrorCode, + ( + PetscDrawAxis, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawAxisSetHoldLimits(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawAxisSetHoldLimits, $petsc_library), + PetscErrorCode, + (PetscDrawAxis, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawAxisSetColors( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDrawAxisSetColors, $petsc_library), + PetscErrorCode, + (PetscDrawAxis, Cint, Cint, Cint), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDrawAxisSetLabels( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDrawAxisSetLabels, $petsc_library), + PetscErrorCode, + (PetscDrawAxis, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDrawLGCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawLGCreate, $petsc_library), + PetscErrorCode, + (PetscDraw, $PetscInt, Ptr{PetscDrawLG}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawLGDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawLGDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscDrawLG},), + arg1, + ) +end + +@for_petsc function PetscDrawLGAddPoint(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawLGAddPoint, $petsc_library), + PetscErrorCode, + (PetscDrawLG, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawLGAddCommonPoint( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDrawLGAddCommonPoint, $petsc_library), + PetscErrorCode, + (PetscDrawLG, $PetscReal, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawLGAddPoints( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDrawLGAddPoints, $petsc_library), + PetscErrorCode, + (PetscDrawLG, $PetscInt, Ptr{Ptr{$PetscReal}}, Ptr{Ptr{$PetscReal}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDrawLGDraw(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawLGDraw, $petsc_library), + PetscErrorCode, + (PetscDrawLG,), + arg1, + ) +end + +@for_petsc function PetscDrawLGSave(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawLGSave, $petsc_library), + PetscErrorCode, + (PetscDrawLG,), + arg1, + ) +end + +@for_petsc function PetscDrawLGView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGView, $petsc_library), + PetscErrorCode, + (PetscDrawLG, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLGReset(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawLGReset, $petsc_library), + PetscErrorCode, + (PetscDrawLG,), + arg1, + ) +end + +@for_petsc function PetscDrawLGSetDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGSetDimension, $petsc_library), + PetscErrorCode, + (PetscDrawLG, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLGGetDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGGetDimension, $petsc_library), + PetscErrorCode, + (PetscDrawLG, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLGSetLegend(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGSetLegend, $petsc_library), + PetscErrorCode, + (PetscDrawLG, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLGGetAxis(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGGetAxis, $petsc_library), + PetscErrorCode, + (PetscDrawLG, Ptr{PetscDrawAxis}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLGGetDraw(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGGetDraw, $petsc_library), + PetscErrorCode, + (PetscDrawLG, Ptr{PetscDraw}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLGSetUseMarkers(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGSetUseMarkers, $petsc_library), + PetscErrorCode, + (PetscDrawLG, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLGSetLimits( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawLGSetLimits, $petsc_library), + PetscErrorCode, + (PetscDrawLG, $PetscReal, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawLGSetColors(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGSetColors, $petsc_library), + PetscErrorCode, + (PetscDrawLG, Ptr{Cint}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLGSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PetscDrawLG, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawLGSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawLGSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscDrawLG,), + arg1, + ) +end + +@for_petsc function PetscDrawSPCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawSPCreate, $petsc_library), + PetscErrorCode, + (PetscDraw, Cint, Ptr{PetscDrawSP}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawSPDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawSPDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscDrawSP},), + arg1, + ) +end + +@for_petsc function PetscDrawSPAddPoint(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawSPAddPoint, $petsc_library), + PetscErrorCode, + (PetscDrawSP, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawSPAddPoints( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDrawSPAddPoints, $petsc_library), + PetscErrorCode, + (PetscDrawSP, Cint, Ptr{Ptr{$PetscReal}}, Ptr{Ptr{$PetscReal}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDrawSPDraw(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSPDraw, $petsc_library), + PetscErrorCode, + (PetscDrawSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawSPSave(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawSPSave, $petsc_library), + PetscErrorCode, + (PetscDrawSP,), + arg1, + ) +end + +@for_petsc function PetscDrawSPReset(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawSPReset, $petsc_library), + PetscErrorCode, + (PetscDrawSP,), + arg1, + ) +end + +@for_petsc function PetscDrawSPSetDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSPSetDimension, $petsc_library), + PetscErrorCode, + (PetscDrawSP, Cint), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawSPGetAxis(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSPGetAxis, $petsc_library), + PetscErrorCode, + (PetscDrawSP, Ptr{PetscDrawAxis}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawSPGetDraw(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawSPGetDraw, $petsc_library), + PetscErrorCode, + (PetscDrawSP, Ptr{PetscDraw}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawSPSetLimits( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawSPSetLimits, $petsc_library), + PetscErrorCode, + (PetscDrawSP, $PetscReal, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawLGSPDraw(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawLGSPDraw, $petsc_library), + PetscErrorCode, + (PetscDrawLG, PetscDrawSP), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawHGCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawHGCreate, $petsc_library), + PetscErrorCode, + (PetscDraw, Cint, Ptr{PetscDrawHG}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawHGDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawHGDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscDrawHG},), + arg1, + ) +end + +@for_petsc function PetscDrawHGAddValue(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawHGAddValue, $petsc_library), + PetscErrorCode, + (PetscDrawHG, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawHGDraw(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawHGDraw, $petsc_library), + PetscErrorCode, + (PetscDrawHG,), + arg1, + ) +end + +@for_petsc function PetscDrawHGSave(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawHGSave, $petsc_library), + PetscErrorCode, + (PetscDrawHG,), + arg1, + ) +end + +@for_petsc function PetscDrawHGView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawHGView, $petsc_library), + PetscErrorCode, + (PetscDrawHG, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawHGReset(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawHGReset, $petsc_library), + PetscErrorCode, + (PetscDrawHG,), + arg1, + ) +end + +@for_petsc function PetscDrawHGGetAxis(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawHGGetAxis, $petsc_library), + PetscErrorCode, + (PetscDrawHG, Ptr{PetscDrawAxis}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawHGGetDraw(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawHGGetDraw, $petsc_library), + PetscErrorCode, + (PetscDrawHG, Ptr{PetscDraw}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawHGSetLimits( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawHGSetLimits, $petsc_library), + PetscErrorCode, + (PetscDrawHG, $PetscReal, $PetscReal, Cint, Cint), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawHGSetNumberBins(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawHGSetNumberBins, $petsc_library), + PetscErrorCode, + (PetscDrawHG, Cint), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawHGSetColor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawHGSetColor, $petsc_library), + PetscErrorCode, + (PetscDrawHG, Cint), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawHGCalcStats(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawHGCalcStats, $petsc_library), + PetscErrorCode, + (PetscDrawHG, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawHGIntegerBins(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawHGIntegerBins, $petsc_library), + PetscErrorCode, + (PetscDrawHG, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawBarCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawBarCreate, $petsc_library), + PetscErrorCode, + (PetscDraw, Ptr{PetscDrawBar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawBarSetData( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDrawBarSetData, $petsc_library), + PetscErrorCode, + (PetscDrawBar, $PetscInt, Ptr{$PetscReal}, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDrawBarDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawBarDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscDrawBar},), + arg1, + ) +end + +@for_petsc function PetscDrawBarDraw(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawBarDraw, $petsc_library), + PetscErrorCode, + (PetscDrawBar,), + arg1, + ) +end + +@for_petsc function PetscDrawBarSave(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawBarSave, $petsc_library), + PetscErrorCode, + (PetscDrawBar,), + arg1, + ) +end + +@for_petsc function PetscDrawBarSetColor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawBarSetColor, $petsc_library), + PetscErrorCode, + (PetscDrawBar, Cint), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawBarSetLimits(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawBarSetLimits, $petsc_library), + PetscErrorCode, + (PetscDrawBar, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawBarSort(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDrawBarSort, $petsc_library), + PetscErrorCode, + (PetscDrawBar, PetscBool, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDrawBarSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawBarSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscDrawBar,), + arg1, + ) +end + +@for_petsc function PetscDrawBarGetAxis(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawBarGetAxis, $petsc_library), + PetscErrorCode, + (PetscDrawBar, Ptr{PetscDrawAxis}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawBarGetDraw(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDrawBarGetDraw, $petsc_library), + PetscErrorCode, + (PetscDrawBar, Ptr{PetscDraw}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDrawUtilitySetCmap( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDrawUtilitySetCmap, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Cint, Ptr{Cuchar}, Ptr{Cuchar}, Ptr{Cuchar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDrawUtilitySetGamma(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDrawUtilitySetGamma, $petsc_library), + PetscErrorCode, + ($PetscReal,), + arg1, + ) +end + +mutable struct _p_PetscSF end + +const PetscSF = Ptr{_p_PetscSF} + +const PetscSFType = Ptr{Cchar} + +const VecScatter = PetscSF + +const VecScatterType = PetscSFType + +mutable struct _p_PetscSection end + +const PetscSection = Ptr{_p_PetscSection} + +mutable struct _p_PetscSectionSym end + +const PetscSectionSym = Ptr{_p_PetscSectionSym} + +const PetscSectionSymType = Ptr{Cchar} + +mutable struct _p_IS end + +const IS = Ptr{_p_IS} + +mutable struct _p_ISLocalToGlobalMapping end + +const ISLocalToGlobalMapping = Ptr{_p_ISLocalToGlobalMapping} + +mutable struct _n_ISColoring end + +const ISColoring = Ptr{_n_ISColoring} + +@for_petsc function ISInitializePackage(::$UnionPetscLib) + @chk ccall((:ISInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +const ISType = Ptr{Cchar} + +@for_petsc function ISSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISSetType, $petsc_library), + PetscErrorCode, + (IS, ISType), + arg1, + arg2, + ) +end + +@for_petsc function ISGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISGetType, $petsc_library), + PetscErrorCode, + (IS, Ptr{ISType}), + arg1, + arg2, + ) +end + +@for_petsc function ISRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function ISCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function ISCreateGeneral( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISCreateGeneral, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{$PetscInt}, PetscCopyMode, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISGeneralSetIndices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:ISGeneralSetIndices, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, Ptr{$PetscInt}, PetscCopyMode), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISCreateBlock( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:ISCreateBlock, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + PetscCopyMode, + Ptr{IS}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function ISBlockSetIndices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISBlockSetIndices, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, $PetscInt, Ptr{$PetscInt}, PetscCopyMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISCreateStride( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISCreateStride, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISStrideSetStride(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISStrideSetStride, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISDestroy(::$UnionPetscLib, arg1) + @chk ccall((:ISDestroy, $petsc_library), PetscErrorCode, (Ptr{IS},), arg1) +end + +@for_petsc function ISSetPermutation(::$UnionPetscLib, arg1) + @chk ccall((:ISSetPermutation, $petsc_library), PetscErrorCode, (IS,), arg1) +end + +@for_petsc function ISPermutation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISPermutation, $petsc_library), + PetscErrorCode, + (IS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function ISSetIdentity(::$UnionPetscLib, arg1) + @chk ccall((:ISSetIdentity, $petsc_library), PetscErrorCode, (IS,), arg1) +end + +@for_petsc function ISIdentity(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISIdentity, $petsc_library), + PetscErrorCode, + (IS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function ISContiguousLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISContiguousLocal, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@enum ISInfo::Int32 begin + IS_INFO_MIN = -1 + IS_SORTED = 0 + IS_UNIQUE = 1 + IS_PERMUTATION = 2 + IS_INTERVAL = 3 + IS_IDENTITY = 4 + IS_INFO_MAX = 5 +end + +@enum ISInfoType::UInt32 begin + IS_LOCAL = 0 + IS_GLOBAL = 1 +end + +@for_petsc function ISSetInfo(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:ISSetInfo, $petsc_library), + PetscErrorCode, + (IS, ISInfo, ISInfoType, PetscBool, PetscBool), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISGetInfo(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:ISGetInfo, $petsc_library), + PetscErrorCode, + (IS, ISInfo, ISInfoType, PetscBool, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISClearInfoCache(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISClearInfoCache, $petsc_library), + PetscErrorCode, + (IS, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function ISGetIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISGetIndices, $petsc_library), + PetscErrorCode, + (IS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISRestoreIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISRestoreIndices, $petsc_library), + PetscErrorCode, + (IS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISGetTotalIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISGetTotalIndices, $petsc_library), + PetscErrorCode, + (IS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISRestoreTotalIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISRestoreTotalIndices, $petsc_library), + PetscErrorCode, + (IS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISGetNonlocalIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISGetNonlocalIndices, $petsc_library), + PetscErrorCode, + (IS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISRestoreNonlocalIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISRestoreNonlocalIndices, $petsc_library), + PetscErrorCode, + (IS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISGetNonlocalIS(::$UnionPetscLib, arg1, is) + @chk ccall( + (:ISGetNonlocalIS, $petsc_library), + PetscErrorCode, + (IS, Ptr{IS}), + arg1, + is, + ) +end + +@for_petsc function ISRestoreNonlocalIS(::$UnionPetscLib, arg1, is) + @chk ccall( + (:ISRestoreNonlocalIS, $petsc_library), + PetscErrorCode, + (IS, Ptr{IS}), + arg1, + is, + ) +end + +@for_petsc function ISGetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISGetSize, $petsc_library), + PetscErrorCode, + (IS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function ISGetLocalSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISGetLocalSize, $petsc_library), + PetscErrorCode, + (IS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function ISInvertPermutation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISInvertPermutation, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISView, $petsc_library), + PetscErrorCode, + (IS, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function ISViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISViewFromOptions, $petsc_library), + PetscErrorCode, + (IS, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISLoad, $petsc_library), + PetscErrorCode, + (IS, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function ISEqual(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISEqual, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISEqualUnsorted(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISEqualUnsorted, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISSort(::$UnionPetscLib, arg1) + @chk ccall((:ISSort, $petsc_library), PetscErrorCode, (IS,), arg1) +end + +@for_petsc function ISSortRemoveDups(::$UnionPetscLib, arg1) + @chk ccall((:ISSortRemoveDups, $petsc_library), PetscErrorCode, (IS,), arg1) +end + +@for_petsc function ISSorted(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISSorted, $petsc_library), + PetscErrorCode, + (IS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function ISDifference(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISDifference, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISSum(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISSum, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISExpand(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISExpand, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISIntersect(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISIntersect, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISGetMinMax(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISGetMinMax, $petsc_library), + PetscErrorCode, + (IS, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISLocate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISLocate, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISGetPointRange(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISGetPointRange, $petsc_library), + PetscErrorCode, + (IS, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISRestorePointRange( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:ISRestorePointRange, $petsc_library), + PetscErrorCode, + (IS, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISGetPointSubrange(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISGetPointSubrange, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISBlockGetIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISBlockGetIndices, $petsc_library), + PetscErrorCode, + (IS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISBlockRestoreIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISBlockRestoreIndices, $petsc_library), + PetscErrorCode, + (IS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISBlockGetLocalSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISBlockGetLocalSize, $petsc_library), + PetscErrorCode, + (IS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function ISBlockGetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISBlockGetSize, $petsc_library), + PetscErrorCode, + (IS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function ISGetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISGetBlockSize, $petsc_library), + PetscErrorCode, + (IS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function ISSetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISSetBlockSize, $petsc_library), + PetscErrorCode, + (IS, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function ISStrideGetInfo(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISStrideGetInfo, $petsc_library), + PetscErrorCode, + (IS, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISToGeneral(::$UnionPetscLib, arg1) + @chk ccall((:ISToGeneral, $petsc_library), PetscErrorCode, (IS,), arg1) +end + +@for_petsc function ISDuplicate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISDuplicate, $petsc_library), + PetscErrorCode, + (IS, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function ISCopy(::$UnionPetscLib, arg1, arg2) + @chk ccall((:ISCopy, $petsc_library), PetscErrorCode, (IS, IS), arg1, arg2) +end + +@for_petsc function ISAllGather(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISAllGather, $petsc_library), + PetscErrorCode, + (IS, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function ISComplement(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISComplement, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISConcatenate(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISConcatenate, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISListToPair(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:ISListToPair, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{IS}, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISPairToList(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISPairToList, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{$PetscInt}, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISEmbed(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISEmbed, $petsc_library), + PetscErrorCode, + (IS, IS, PetscBool, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISSortPermutation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISSortPermutation, $petsc_library), + PetscErrorCode, + (IS, PetscBool, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISOnComm(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISOnComm, $petsc_library), + PetscErrorCode, + (IS, MPI_Comm, PetscCopyMode, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISRenumber(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISRenumber, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{$PetscInt}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISCreateSubIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISCreateSubIS, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISGeneralFilter(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISGeneralFilter, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@enum ISGlobalToLocalMappingMode::UInt32 begin + IS_GTOLM_MASK = 0 + IS_GTOLM_DROP = 1 +end + +const ISLocalToGlobalMappingType = Ptr{Cchar} + +@for_petsc function ISLocalToGlobalMappingSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISLocalToGlobalMappingSetType, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, ISLocalToGlobalMappingType), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISLocalToGlobalMappingRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingRegisterAll(::$UnionPetscLib) + @chk ccall( + (:ISLocalToGlobalMappingRegisterAll, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function ISLocalToGlobalMappingCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:ISLocalToGlobalMappingCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + PetscCopyMode, + Ptr{ISLocalToGlobalMapping}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function ISLocalToGlobalMappingCreateIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISLocalToGlobalMappingCreateIS, $petsc_library), + PetscErrorCode, + (IS, Ptr{ISLocalToGlobalMapping}), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingCreateSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:ISLocalToGlobalMappingCreateSF, $petsc_library), + PetscErrorCode, + (PetscSF, $PetscInt, Ptr{ISLocalToGlobalMapping}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISLocalToGlobalMappingSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:ISLocalToGlobalMappingSetFromOptions, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping,), + arg1, + ) +end + +@for_petsc function ISLocalToGlobalMappingSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:ISLocalToGlobalMappingSetUp, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping,), + arg1, + ) +end + +@for_petsc function ISLocalToGlobalMappingView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISLocalToGlobalMappingView, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:ISLocalToGlobalMappingViewFromOptions, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISLocalToGlobalMappingDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:ISLocalToGlobalMappingDestroy, $petsc_library), + PetscErrorCode, + (Ptr{ISLocalToGlobalMapping},), + arg1, + ) +end + +@for_petsc function ISLocalToGlobalMappingApply( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:ISLocalToGlobalMappingApply, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISLocalToGlobalMappingApplyBlock( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:ISLocalToGlobalMappingApplyBlock, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISLocalToGlobalMappingApplyIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:ISLocalToGlobalMappingApplyIS, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, IS, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISGlobalToLocalMappingApply( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:ISGlobalToLocalMappingApply, $petsc_library), + PetscErrorCode, + ( + ISLocalToGlobalMapping, + ISGlobalToLocalMappingMode, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function ISGlobalToLocalMappingApplyBlock( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:ISGlobalToLocalMappingApplyBlock, $petsc_library), + PetscErrorCode, + ( + ISLocalToGlobalMapping, + ISGlobalToLocalMappingMode, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function ISGlobalToLocalMappingApplyIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:ISGlobalToLocalMappingApplyIS, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, ISGlobalToLocalMappingMode, IS, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISLocalToGlobalMappingGetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISLocalToGlobalMappingGetSize, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingGetNodeInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:ISLocalToGlobalMappingGetNodeInfo, $petsc_library), + PetscErrorCode, + ( + ISLocalToGlobalMapping, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Ptr{$PetscInt}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISLocalToGlobalMappingRestoreNodeInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:ISLocalToGlobalMappingRestoreNodeInfo, $petsc_library), + PetscErrorCode, + ( + ISLocalToGlobalMapping, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Ptr{$PetscInt}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISLocalToGlobalMappingGetInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISLocalToGlobalMappingGetInfo, $petsc_library), + PetscErrorCode, + ( + ISLocalToGlobalMapping, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Ptr{$PetscInt}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISLocalToGlobalMappingRestoreInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISLocalToGlobalMappingRestoreInfo, $petsc_library), + PetscErrorCode, + ( + ISLocalToGlobalMapping, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Ptr{$PetscInt}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISLocalToGlobalMappingGetBlockInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISLocalToGlobalMappingGetBlockInfo, $petsc_library), + PetscErrorCode, + ( + ISLocalToGlobalMapping, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Ptr{$PetscInt}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISLocalToGlobalMappingRestoreBlockInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISLocalToGlobalMappingRestoreBlockInfo, $petsc_library), + PetscErrorCode, + ( + ISLocalToGlobalMapping, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Ptr{$PetscInt}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISLocalToGlobalMappingGetIndices( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:ISLocalToGlobalMappingGetIndices, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingRestoreIndices( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:ISLocalToGlobalMappingRestoreIndices, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingGetBlockIndices( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:ISLocalToGlobalMappingGetBlockIndices, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingRestoreBlockIndices( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:ISLocalToGlobalMappingRestoreBlockIndices, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingConcatenate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:ISLocalToGlobalMappingConcatenate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + Ptr{ISLocalToGlobalMapping}, + Ptr{ISLocalToGlobalMapping}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISLocalToGlobalMappingGetBlockSize( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:ISLocalToGlobalMappingGetBlockSize, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingSetBlockSize( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:ISLocalToGlobalMappingSetBlockSize, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function ISLocalToGlobalMappingDuplicate( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:ISLocalToGlobalMappingDuplicate, $petsc_library), + PetscErrorCode, + (ISLocalToGlobalMapping, Ptr{ISLocalToGlobalMapping}), + arg1, + arg2, + ) +end + +@enum ISColoringType::UInt32 begin + IS_COLORING_GLOBAL = 0 + IS_COLORING_LOCAL = 1 +end + +const ISColoringValue = Cushort + +@for_petsc function ISAllGatherColors( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISAllGatherColors, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + Ptr{ISColoringValue}, + Ptr{$PetscInt}, + Ptr{Ptr{ISColoringValue}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISColoringCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:ISColoringCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + Ptr{ISColoringValue}, + PetscCopyMode, + Ptr{ISColoring}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function ISColoringDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:ISColoringDestroy, $petsc_library), + PetscErrorCode, + (Ptr{ISColoring},), + arg1, + ) +end + +@for_petsc function ISColoringView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISColoringView, $petsc_library), + PetscErrorCode, + (ISColoring, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function ISColoringViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:ISColoringViewFromOptions, $petsc_library), + PetscErrorCode, + (ISColoring, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISColoringGetIS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:ISColoringGetIS, $petsc_library), + PetscErrorCode, + (ISColoring, PetscCopyMode, Ptr{$PetscInt}, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISColoringRestoreIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISColoringRestoreIS, $petsc_library), + PetscErrorCode, + (ISColoring, PetscCopyMode, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISColoringReference(::$UnionPetscLib, arg1) + @chk ccall( + (:ISColoringReference, $petsc_library), + PetscErrorCode, + (ISColoring,), + arg1, + ) +end + +@for_petsc function ISColoringSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISColoringSetType, $petsc_library), + PetscErrorCode, + (ISColoring, ISColoringType), + arg1, + arg2, + ) +end + +@for_petsc function ISColoringGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISColoringGetType, $petsc_library), + PetscErrorCode, + (ISColoring, Ptr{ISColoringType}), + arg1, + arg2, + ) +end + +@for_petsc function ISColoringGetColors( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:ISColoringGetColors, $petsc_library), + PetscErrorCode, + (ISColoring, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{ISColoringValue}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function ISBuildTwoSided(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISBuildTwoSided, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISPartitioningToNumbering(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:ISPartitioningToNumbering, $petsc_library), + PetscErrorCode, + (IS, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function ISPartitioningCount(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISPartitioningCount, $petsc_library), + PetscErrorCode, + (IS, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISCompressIndicesGeneral( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:ISCompressIndicesGeneral, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, $PetscInt, $PetscInt, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function ISCompressIndicesSorted( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:ISCompressIndicesSorted, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, $PetscInt, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function ISExpandIndicesGeneral( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:ISExpandIndicesGeneral, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, $PetscInt, $PetscInt, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@enum ScatterMode::UInt32 begin + SCATTER_FORWARD = 0 + SCATTER_REVERSE = 1 + SCATTER_FORWARD_LOCAL = 2 + SCATTER_REVERSE_LOCAL = 3 + # SCATTER_LOCAL = 2 +end + +const VecType = Ptr{Cchar} + +@for_petsc function VecScatterSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecScatterSetType, $petsc_library), + PetscErrorCode, + (VecScatter, VecScatterType), + arg1, + arg2, + ) +end + +@for_petsc function VecScatterGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecScatterGetType, $petsc_library), + PetscErrorCode, + (VecScatter, Ptr{VecScatterType}), + arg1, + arg2, + ) +end + +@for_petsc function VecScatterSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:VecScatterSetFromOptions, $petsc_library), + PetscErrorCode, + (VecScatter,), + arg1, + ) +end + +@for_petsc function VecScatterRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecScatterRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function VecScatterCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecScatterCreate, $petsc_library), + PetscErrorCode, + (Vec, IS, Vec, IS, Ptr{VecScatter}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecInitializePackage(::$UnionPetscLib) + @chk ccall((:VecInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function VecFinalizePackage(::$UnionPetscLib) + @chk ccall((:VecFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function VecCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function VecCreateSeq(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecCreateSeq, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecCreateMPI(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecCreateMPI, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecCreateSeqWithArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecCreateSeqWithArray, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecCreateMPIWithArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecCreateMPIWithArray, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscScalar}, + Ptr{Vec}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecCreateShared(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecCreateShared, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecCreateNode(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecCreateNode, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:VecSetFromOptions, $petsc_library), + PetscErrorCode, + (Vec,), + arg1, + ) +end + +@for_petsc function VecViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecViewFromOptions, $petsc_library), + PetscErrorCode, + (Vec, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecSetUp(::$UnionPetscLib, arg1) + @chk ccall((:VecSetUp, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecDestroy(::$UnionPetscLib, arg1) + @chk ccall((:VecDestroy, $petsc_library), PetscErrorCode, (Ptr{Vec},), arg1) +end + +@for_petsc function VecZeroEntries(::$UnionPetscLib, arg1) + @chk ccall((:VecZeroEntries, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function VecAppendOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecSetSizes(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecSetSizes, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecDotNorm2(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecDotNorm2, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscScalar}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecDot(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecDot, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecDotRealPart(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecDotRealPart, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecTDot(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecTDot, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecMDot(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecMDot, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{Vec}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecMTDot(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecMTDot, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{Vec}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecGetSubVector(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecGetSubVector, $petsc_library), + PetscErrorCode, + (Vec, IS, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecRestoreSubVector(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecRestoreSubVector, $petsc_library), + PetscErrorCode, + (Vec, IS, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecConcatenate(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecConcatenate, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Vec}, Ptr{Vec}, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@enum NormType::UInt32 begin + NORM_1 = 0 + NORM_2 = 1 + NORM_FROBENIUS = 2 + NORM_INFINITY = 3 + NORM_1_AND_2 = 4 +end + +@for_petsc function VecNorm(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecNorm, $petsc_library), + PetscErrorCode, + (Vec, NormType, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecNormAvailable(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecNormAvailable, $petsc_library), + PetscErrorCode, + (Vec, NormType, Ptr{PetscBool}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecNormalize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecNormalize, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function VecSum(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSum, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function VecMax(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecMax, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecMin(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecMin, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecScale, $petsc_library), + PetscErrorCode, + (Vec, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function VecCopy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCopy, $petsc_library), + PetscErrorCode, + (Vec, Vec), + arg1, + arg2, + ) +end + +@for_petsc function VecSetRandom(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSetRandom, $petsc_library), + PetscErrorCode, + (Vec, PetscRandom), + arg1, + arg2, + ) +end + +@for_petsc function VecSet(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSet, $petsc_library), + PetscErrorCode, + (Vec, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function VecSetInf(::$UnionPetscLib, arg1) + @chk ccall((:VecSetInf, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecSwap(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSwap, $petsc_library), + PetscErrorCode, + (Vec, Vec), + arg1, + arg2, + ) +end + +@for_petsc function VecAXPY(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecAXPY, $petsc_library), + PetscErrorCode, + (Vec, $PetscScalar, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecAXPBY(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecAXPBY, $petsc_library), + PetscErrorCode, + (Vec, $PetscScalar, $PetscScalar, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecMAXPY(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecMAXPY, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscScalar}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecAYPX(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecAYPX, $petsc_library), + PetscErrorCode, + (Vec, $PetscScalar, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecWAXPY(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecWAXPY, $petsc_library), + PetscErrorCode, + (Vec, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecAXPBYPCZ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecAXPBYPCZ, $petsc_library), + PetscErrorCode, + (Vec, $PetscScalar, $PetscScalar, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecPointwiseMax(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecPointwiseMax, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecPointwiseMaxAbs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecPointwiseMaxAbs, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecPointwiseMin(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecPointwiseMin, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecPointwiseMult(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecPointwiseMult, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecPointwiseDivide(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecPointwiseDivide, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecMaxPointwiseDivide(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecMaxPointwiseDivide, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecShift(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecShift, $petsc_library), + PetscErrorCode, + (Vec, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function VecReciprocal(::$UnionPetscLib, arg1) + @chk ccall((:VecReciprocal, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecPermute(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecPermute, $petsc_library), + PetscErrorCode, + (Vec, IS, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecSqrtAbs(::$UnionPetscLib, arg1) + @chk ccall((:VecSqrtAbs, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecLog(::$UnionPetscLib, arg1) + @chk ccall((:VecLog, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecExp(::$UnionPetscLib, arg1) + @chk ccall((:VecExp, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecAbs(::$UnionPetscLib, arg1) + @chk ccall((:VecAbs, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecDuplicate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecDuplicate, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function VecDuplicateVecs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecDuplicateVecs, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{Ptr{Vec}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecDestroyVecs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecDestroyVecs, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Ptr{Vec}}), + arg1, + arg2, + ) +end + +@for_petsc function VecStrideNormAll(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStrideNormAll, $petsc_library), + PetscErrorCode, + (Vec, NormType, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStrideMaxAll(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStrideMaxAll, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStrideMinAll(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStrideMinAll, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStrideScaleAll(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecStrideScaleAll, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function VecUniqueEntries(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecUniqueEntries, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStrideNorm(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecStrideNorm, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, NormType, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecStrideMax(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecStrideMax, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecStrideMin(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecStrideMin, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecStrideScale(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStrideScale, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscScalar), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStrideSet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStrideSet, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscScalar), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStrideGather(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecStrideGather, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Vec, InsertMode), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecStrideScatter(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecStrideScatter, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Vec, InsertMode), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecStrideGatherAll(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStrideGatherAll, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Vec}, InsertMode), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStrideScatterAll(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStrideScatterAll, $petsc_library), + PetscErrorCode, + (Ptr{Vec}, Vec, InsertMode), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStrideSubSetScatter( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecStrideSubSetScatter, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Vec, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecStrideSubSetGather( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecStrideSubSetGather, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Vec, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecSetValues(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:VecSetValues, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecGetValues(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecGetValues, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecAssemblyBegin(::$UnionPetscLib, arg1) + @chk ccall( + (:VecAssemblyBegin, $petsc_library), + PetscErrorCode, + (Vec,), + arg1, + ) +end + +@for_petsc function VecAssemblyEnd(::$UnionPetscLib, arg1) + @chk ccall((:VecAssemblyEnd, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecStashSetInitialSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStashSetInitialSize, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStashView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecStashView, $petsc_library), + PetscErrorCode, + (Vec, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function VecStashViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStashViewFromOptions, $petsc_library), + PetscErrorCode, + (Vec, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStashGetInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecStashGetInfo, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecSetValue(::$UnionPetscLib, v, i, va, mode) + @chk ccall( + (:VecSetValue, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscScalar, InsertMode), + v, + i, + va, + mode, + ) +end + +@for_petsc function VecSetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSetBlockSize, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function VecGetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetBlockSize, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function VecSetValuesBlocked( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecSetValuesBlocked, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSetType, $petsc_library), + PetscErrorCode, + (Vec, VecType), + arg1, + arg2, + ) +end + +@for_petsc function VecGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetType, $petsc_library), + PetscErrorCode, + (Vec, Ptr{VecType}), + arg1, + arg2, + ) +end + +@for_petsc function VecRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function VecScatterBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecScatterBegin, $petsc_library), + PetscErrorCode, + (VecScatter, Vec, Vec, InsertMode, ScatterMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecScatterEnd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecScatterEnd, $petsc_library), + PetscErrorCode, + (VecScatter, Vec, Vec, InsertMode, ScatterMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecScatterDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:VecScatterDestroy, $petsc_library), + PetscErrorCode, + (Ptr{VecScatter},), + arg1, + ) +end + +@for_petsc function VecScatterSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:VecScatterSetUp, $petsc_library), + PetscErrorCode, + (VecScatter,), + arg1, + ) +end + +@for_petsc function VecScatterCopy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecScatterCopy, $petsc_library), + PetscErrorCode, + (VecScatter, Ptr{VecScatter}), + arg1, + arg2, + ) +end + +@for_petsc function VecScatterView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecScatterView, $petsc_library), + PetscErrorCode, + (VecScatter, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function VecScatterViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:VecScatterViewFromOptions, $petsc_library), + PetscErrorCode, + (VecScatter, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecScatterRemap(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecScatterRemap, $petsc_library), + PetscErrorCode, + (VecScatter, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecScatterGetMerged(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecScatterGetMerged, $petsc_library), + PetscErrorCode, + (VecScatter, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetArray4d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:VecGetArray4d, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function VecRestoreArray4d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:VecRestoreArray4d, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function VecGetArray3d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:VecGetArray3d, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function VecRestoreArray3d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:VecRestoreArray3d, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function VecGetArray2d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecGetArray2d, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecRestoreArray2d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecRestoreArray2d, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecGetArray1d(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecGetArray1d, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscInt, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecRestoreArray1d(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecRestoreArray1d, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscInt, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecGetArray4dWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:VecGetArray4dWrite, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function VecRestoreArray4dWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:VecRestoreArray4dWrite, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function VecGetArray3dWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:VecGetArray3dWrite, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function VecRestoreArray3dWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:VecRestoreArray3dWrite, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function VecGetArray2dWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecGetArray2dWrite, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecRestoreArray2dWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecRestoreArray2dWrite, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecGetArray1dWrite(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecGetArray1dWrite, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscInt, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecRestoreArray1dWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:VecRestoreArray1dWrite, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscInt, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecGetArray4dRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:VecGetArray4dRead, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function VecRestoreArray4dRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:VecRestoreArray4dRead, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function VecGetArray3dRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:VecGetArray3dRead, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function VecRestoreArray3dRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:VecRestoreArray3dRead, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function VecGetArray2dRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecGetArray2dRead, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecRestoreArray2dRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecRestoreArray2dRead, $petsc_library), + PetscErrorCode, + ( + Vec, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecGetArray1dRead(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecGetArray1dRead, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscInt, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecRestoreArray1dRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:VecRestoreArray1dRead, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscInt, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecPlaceArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecPlaceArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function VecResetArray(::$UnionPetscLib, arg1) + @chk ccall((:VecResetArray, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecReplaceArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecReplaceArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetArrays(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecGetArrays, $petsc_library), + PetscErrorCode, + (Ptr{Vec}, $PetscInt, Ptr{Ptr{Ptr{$PetscScalar}}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecRestoreArrays(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecRestoreArrays, $petsc_library), + PetscErrorCode, + (Ptr{Vec}, $PetscInt, Ptr{Ptr{Ptr{$PetscScalar}}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecView, $petsc_library), + PetscErrorCode, + (Vec, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function VecEqual(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecEqual, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecLoad, $petsc_library), + PetscErrorCode, + (Vec, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function VecGetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetSize, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetLocalSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetLocalSize, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetOwnershipRange(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecGetOwnershipRange, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecGetOwnershipRanges(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetOwnershipRanges, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function VecSetLocalToGlobalMapping(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSetLocalToGlobalMapping, $petsc_library), + PetscErrorCode, + (Vec, ISLocalToGlobalMapping), + arg1, + arg2, + ) +end + +@for_petsc function VecSetValuesLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecSetValuesLocal, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecCUDAGetArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCUDAGetArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecCUDARestoreArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCUDARestoreArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecCUDAGetArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCUDAGetArrayRead, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecCUDARestoreArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCUDARestoreArrayRead, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecCUDAGetArrayWrite(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCUDAGetArrayWrite, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecCUDARestoreArrayWrite(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCUDARestoreArrayWrite, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecCUDAPlaceArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCUDAPlaceArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function VecCUDAReplaceArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecCUDAReplaceArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function VecCUDAResetArray(::$UnionPetscLib, arg1) + @chk ccall( + (:VecCUDAResetArray, $petsc_library), + PetscErrorCode, + (Vec,), + arg1, + ) +end + +@for_petsc function VecHIPGetArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecHIPGetArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecHIPRestoreArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecHIPRestoreArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecHIPGetArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecHIPGetArrayRead, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecHIPRestoreArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecHIPRestoreArrayRead, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecHIPGetArrayWrite(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecHIPGetArrayWrite, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecHIPRestoreArrayWrite(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecHIPRestoreArrayWrite, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecHIPPlaceArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecHIPPlaceArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function VecHIPReplaceArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecHIPReplaceArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function VecHIPResetArray(::$UnionPetscLib, arg1) + @chk ccall( + (:VecHIPResetArray, $petsc_library), + PetscErrorCode, + (Vec,), + arg1, + ) +end + +@for_petsc function VecViennaCLGetCLContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecViennaCLGetCLContext, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@for_petsc function VecViennaCLGetCLQueue(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecViennaCLGetCLQueue, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@for_petsc function VecViennaCLGetCLMemRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecViennaCLGetCLMemRead, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@for_petsc function VecViennaCLGetCLMemWrite(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecViennaCLGetCLMemWrite, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@for_petsc function VecViennaCLRestoreCLMemWrite(::$UnionPetscLib, arg1) + @chk ccall( + (:VecViennaCLRestoreCLMemWrite, $petsc_library), + PetscErrorCode, + (Vec,), + arg1, + ) +end + +@for_petsc function VecViennaCLGetCLMem(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecViennaCLGetCLMem, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@for_petsc function VecViennaCLRestoreCLMem(::$UnionPetscLib, arg1) + @chk ccall( + (:VecViennaCLRestoreCLMem, $petsc_library), + PetscErrorCode, + (Vec,), + arg1, + ) +end + +@for_petsc function VecSetValueLocal(::$UnionPetscLib, v, i, va, mode) + @chk ccall( + (:VecSetValueLocal, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, $PetscScalar, InsertMode), + v, + i, + va, + mode, + ) +end + +@for_petsc function VecSetValuesBlockedLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecSetValuesBlockedLocal, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecGetLocalToGlobalMapping(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetLocalToGlobalMapping, $petsc_library), + PetscErrorCode, + (Vec, Ptr{ISLocalToGlobalMapping}), + arg1, + arg2, + ) +end + +@for_petsc function VecDotBegin(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecDotBegin, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecDotEnd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecDotEnd, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecTDotBegin(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecTDotBegin, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecTDotEnd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecTDotEnd, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecNormBegin(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecNormBegin, $petsc_library), + PetscErrorCode, + (Vec, NormType, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecNormEnd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecNormEnd, $petsc_library), + PetscErrorCode, + (Vec, NormType, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecMDotBegin(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecMDotBegin, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{Vec}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecMDotEnd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecMDotEnd, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{Vec}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecMTDotBegin(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecMTDotBegin, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{Vec}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecMTDotEnd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecMTDotEnd, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{Vec}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscCommSplitReductionBegin(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscCommSplitReductionBegin, $petsc_library), + PetscErrorCode, + (MPI_Comm,), + arg1, + ) +end + +@for_petsc function VecBindToCPU(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecBindToCPU, $petsc_library), + PetscErrorCode, + (Vec, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function VecPinToCPU(::$UnionPetscLib, v, flg) + @chk ccall( + (:VecPinToCPU, $petsc_library), + PetscErrorCode, + (Vec, PetscBool), + v, + flg, + ) +end + +@for_petsc function VecSetPinnedMemoryMin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSetPinnedMemoryMin, $petsc_library), + PetscErrorCode, + (Vec, Csize_t), + arg1, + arg2, + ) +end + +@for_petsc function VecGetPinnedMemoryMin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetPinnedMemoryMin, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Csize_t}), + arg1, + arg2, + ) +end + +@enum PetscOffloadMask::UInt32 begin + PETSC_OFFLOAD_UNALLOCATED = 0 + PETSC_OFFLOAD_CPU = 1 + PETSC_OFFLOAD_GPU = 2 + PETSC_OFFLOAD_BOTH = 3 + PETSC_OFFLOAD_VECKOKKOS = 256 +end + +@for_petsc function VecGetOffloadMask(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetOffloadMask, $petsc_library), + PetscErrorCode, + (Vec, Ptr{PetscOffloadMask}), + arg1, + arg2, + ) +end + +@enum VecOption::UInt32 begin + VEC_IGNORE_OFF_PROC_ENTRIES = 0 + VEC_IGNORE_NEGATIVE_INDICES = 1 + VEC_SUBSET_OFF_PROC_ENTRIES = 2 +end + +@for_petsc function VecSetOption(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecSetOption, $petsc_library), + PetscErrorCode, + (Vec, VecOption, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecGetArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetArrayWrite(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetArrayWrite, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetArrayRead, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecRestoreArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecRestoreArray, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecRestoreArrayWrite(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecRestoreArrayWrite, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecRestoreArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecRestoreArrayRead, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetLocalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetLocalVector, $petsc_library), + PetscErrorCode, + (Vec, Vec), + arg1, + arg2, + ) +end + +@for_petsc function VecRestoreLocalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecRestoreLocalVector, $petsc_library), + PetscErrorCode, + (Vec, Vec), + arg1, + arg2, + ) +end + +@for_petsc function VecGetLocalVectorRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetLocalVectorRead, $petsc_library), + PetscErrorCode, + (Vec, Vec), + arg1, + arg2, + ) +end + +@for_petsc function VecRestoreLocalVectorRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecRestoreLocalVectorRead, $petsc_library), + PetscErrorCode, + (Vec, Vec), + arg1, + arg2, + ) +end + +@for_petsc function VecGetArrayAndMemType(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecGetArrayAndMemType, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}, Ptr{PetscMemType}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecRestoreArrayAndMemType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecRestoreArrayAndMemType, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetArrayReadAndMemType( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:VecGetArrayReadAndMemType, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}, Ptr{PetscMemType}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecRestoreArrayReadAndMemType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecRestoreArrayReadAndMemType, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function VecGetArrayPair(::$UnionPetscLib, x, y, xv, yv) + @chk ccall( + (:VecGetArrayPair, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{Ptr{$PetscScalar}}, Ptr{Ptr{$PetscScalar}}), + x, + y, + xv, + yv, + ) +end + +@for_petsc function VecRestoreArrayPair(::$UnionPetscLib, x, y, xv, yv) + @chk ccall( + (:VecRestoreArrayPair, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{Ptr{$PetscScalar}}, Ptr{Ptr{$PetscScalar}}), + x, + y, + xv, + yv, + ) +end + +@for_petsc function VecValidValues(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecValidValues, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@enum VecOperation::UInt32 begin + VECOP_DUPLICATE = 0 + VECOP_VIEW = 33 + VECOP_LOAD = 41 + VECOP_VIEWNATIVE = 68 + VECOP_LOADNATIVE = 69 +end + +@for_petsc function VecSetOperation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecSetOperation, $petsc_library), + PetscErrorCode, + (Vec, VecOperation, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecMPISetGhost(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecMPISetGhost, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecCreateGhost( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecCreateGhost, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecCreateGhostWithArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:VecCreateGhostWithArray, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Vec}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function VecCreateGhostBlock( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:VecCreateGhostBlock, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Vec}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function VecCreateGhostBlockWithArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:VecCreateGhostBlockWithArray, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Vec}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function VecGhostGetLocalForm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGhostGetLocalForm, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function VecGhostRestoreLocalForm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGhostRestoreLocalForm, $petsc_library), + PetscErrorCode, + (Vec, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function VecGhostIsLocalForm(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecGhostIsLocalForm, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecGhostUpdateBegin(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecGhostUpdateBegin, $petsc_library), + PetscErrorCode, + (Vec, InsertMode, ScatterMode), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecGhostUpdateEnd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecGhostUpdateEnd, $petsc_library), + PetscErrorCode, + (Vec, InsertMode, ScatterMode), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecConjugate(::$UnionPetscLib, arg1) + @chk ccall((:VecConjugate, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecImaginaryPart(::$UnionPetscLib, arg1) + @chk ccall( + (:VecImaginaryPart, $petsc_library), + PetscErrorCode, + (Vec,), + arg1, + ) +end + +@for_petsc function VecRealPart(::$UnionPetscLib, arg1) + @chk ccall((:VecRealPart, $petsc_library), PetscErrorCode, (Vec,), arg1) +end + +@for_petsc function VecScatterCreateToAll(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecScatterCreateToAll, $petsc_library), + PetscErrorCode, + (Vec, Ptr{VecScatter}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecScatterCreateToZero(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecScatterCreateToZero, $petsc_library), + PetscErrorCode, + (Vec, Ptr{VecScatter}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function ISComplementVec(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:ISComplementVec, $petsc_library), + PetscErrorCode, + (IS, Vec, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecPow(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecPow, $petsc_library), + PetscErrorCode, + (Vec, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function VecMedian(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecMedian, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecWhichInactive( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecWhichInactive, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec, Vec, PetscBool, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function VecWhichBetween(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecWhichBetween, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecWhichBetweenOrEqual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:VecWhichBetweenOrEqual, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecWhichGreaterThan(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecWhichGreaterThan, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecWhichLessThan(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecWhichLessThan, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecWhichEqual(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecWhichEqual, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecISAXPY(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecISAXPY, $petsc_library), + PetscErrorCode, + (Vec, IS, $PetscScalar, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecISCopy(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecISCopy, $petsc_library), + PetscErrorCode, + (Vec, IS, ScatterMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecISSet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecISSet, $petsc_library), + PetscErrorCode, + (Vec, IS, $PetscScalar), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecBoundGradientProjection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecBoundGradientProjection, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecStepBoundInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:VecStepBoundInfo, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec, Vec, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function VecStepMax(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecStepMax, $petsc_library), + PetscErrorCode, + (Vec, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecStepMaxBounded( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecStepMaxBounded, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscViewerMathematicaGetVector( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerMathematicaGetVector, $petsc_library), + PetscErrorCode, + (PetscViewer, Vec), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerMathematicaPutVector( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscViewerMathematicaPutVector, $petsc_library), + PetscErrorCode, + (PetscViewer, Vec), + arg1, + arg2, + ) +end + +@for_petsc function VecNestGetSubVecs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecNestGetSubVecs, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}, Ptr{Ptr{Vec}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecNestGetSubVec(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecNestGetSubVec, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecNestSetSubVecs(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecNestSetSubVecs, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Ptr{$PetscInt}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecNestSetSubVec(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecNestSetSubVec, $petsc_library), + PetscErrorCode, + (Vec, $PetscInt, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecCreateNest( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecCreateNest, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{IS}, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecNestGetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecNestGetSize, $petsc_library), + PetscErrorCode, + (Vec, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscOptionsGetVec( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscOptionsGetVec, $petsc_library), + PetscErrorCode, + (PetscOptions, Ptr{Cchar}, Ptr{Cchar}, Vec, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecChop(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecChop, $petsc_library), + PetscErrorCode, + (Vec, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionVecView(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionVecView, $petsc_library), + PetscErrorCode, + (PetscSection, Vec, PetscViewer), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecGetValuesSection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:VecGetValuesSection, $petsc_library), + PetscErrorCode, + (Vec, PetscSection, $PetscInt, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecSetValuesSection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:VecSetValuesSection, $petsc_library), + PetscErrorCode, + (Vec, PetscSection, $PetscInt, Ptr{$PetscScalar}, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSectionVecNorm( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSectionVecNorm, $petsc_library), + PetscErrorCode, + (PetscSection, PetscSection, Vec, NormType, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +mutable struct _p_VecTagger end + +const VecTagger = Ptr{_p_VecTagger} + +const VecTaggerType = Ptr{Cchar} + +@for_petsc function VecTaggerRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{VecTagger}), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerSetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerSetBlockSize, $petsc_library), + PetscErrorCode, + (VecTagger, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerGetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerGetBlockSize, $petsc_library), + PetscErrorCode, + (VecTagger, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerSetType, $petsc_library), + PetscErrorCode, + (VecTagger, VecTaggerType), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerGetType, $petsc_library), + PetscErrorCode, + (VecTagger, Ptr{VecTaggerType}), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerSetInvert(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerSetInvert, $petsc_library), + PetscErrorCode, + (VecTagger, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerGetInvert(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerGetInvert, $petsc_library), + PetscErrorCode, + (VecTagger, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:VecTaggerSetFromOptions, $petsc_library), + PetscErrorCode, + (VecTagger,), + arg1, + ) +end + +@for_petsc function VecTaggerSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:VecTaggerSetUp, $petsc_library), + PetscErrorCode, + (VecTagger,), + arg1, + ) +end + +@for_petsc function VecTaggerView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerView, $petsc_library), + PetscErrorCode, + (VecTagger, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerComputeIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecTaggerComputeIS, $petsc_library), + PetscErrorCode, + (VecTagger, Vec, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecTaggerDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:VecTaggerDestroy, $petsc_library), + PetscErrorCode, + (Ptr{VecTagger},), + arg1, + ) +end + +@enum VecTaggerCDFMethod::UInt32 begin + VECTAGGER_CDF_GATHER = 0 + VECTAGGER_CDF_ITERATIVE = 1 + VECTAGGER_CDF_NUM_METHODS = 2 +end + +@for_petsc function VecTaggerCDFSetMethod(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerCDFSetMethod, $petsc_library), + PetscErrorCode, + (VecTagger, VecTaggerCDFMethod), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerCDFGetMethod(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecTaggerCDFGetMethod, $petsc_library), + PetscErrorCode, + (VecTagger, Ptr{VecTaggerCDFMethod}), + arg1, + arg2, + ) +end + +@for_petsc function VecTaggerCDFIterativeSetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:VecTaggerCDFIterativeSetTolerances, $petsc_library), + PetscErrorCode, + (VecTagger, $PetscInt, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecTaggerCDFIterativeGetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:VecTaggerCDFIterativeGetTolerances, $petsc_library), + PetscErrorCode, + (VecTagger, Ptr{$PetscInt}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecTaggerOrSetSubs(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:VecTaggerOrSetSubs, $petsc_library), + PetscErrorCode, + (VecTagger, $PetscInt, Ptr{VecTagger}, PetscCopyMode), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecTaggerOrGetSubs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecTaggerOrGetSubs, $petsc_library), + PetscErrorCode, + (VecTagger, Ptr{$PetscInt}, Ptr{Ptr{VecTagger}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecTaggerAndSetSubs( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:VecTaggerAndSetSubs, $petsc_library), + PetscErrorCode, + (VecTagger, $PetscInt, Ptr{VecTagger}, PetscCopyMode), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function VecTaggerAndGetSubs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:VecTaggerAndGetSubs, $petsc_library), + PetscErrorCode, + (VecTagger, Ptr{$PetscInt}, Ptr{Ptr{VecTagger}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function VecTaggerInitializePackage(::$UnionPetscLib) + @chk ccall( + (:VecTaggerInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function VecTaggerFinalizePackage(::$UnionPetscLib) + @chk ccall((:VecTaggerFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@enum PetscSFPattern::UInt32 begin + PETSCSF_PATTERN_GENERAL = 0 + PETSCSF_PATTERN_ALLGATHER = 1 + PETSCSF_PATTERN_GATHER = 2 + PETSCSF_PATTERN_ALLTOALL = 3 +end + +@enum PetscSFWindowSyncType::UInt32 begin + PETSCSF_WINDOW_SYNC_FENCE = 0 + PETSCSF_WINDOW_SYNC_LOCK = 1 + PETSCSF_WINDOW_SYNC_ACTIVE = 2 +end + +@enum PetscSFWindowFlavorType::UInt32 begin + PETSCSF_WINDOW_FLAVOR_CREATE = 0 + PETSCSF_WINDOW_FLAVOR_DYNAMIC = 1 + PETSCSF_WINDOW_FLAVOR_ALLOCATE = 2 + PETSCSF_WINDOW_FLAVOR_SHARED = 3 +end + +@enum PetscSFDuplicateOption::UInt32 begin + PETSCSF_DUPLICATE_CONFONLY = 0 + PETSCSF_DUPLICATE_RANKS = 1 + PETSCSF_DUPLICATE_GRAPH = 2 +end + +@for_petsc function PetscSFRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFInitializePackage(::$UnionPetscLib) + @chk ccall((:PetscSFInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscSFFinalizePackage(::$UnionPetscLib) + @chk ccall((:PetscSFFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscSFCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscSF}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSFDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscSF},), + arg1, + ) +end + +@for_petsc function PetscSFSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFSetType, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSFType), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFGetType, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{PetscSFType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFView, $petsc_library), + PetscErrorCode, + (PetscSF, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSFViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscSF, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSFSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSFSetUp, $petsc_library), + PetscErrorCode, + (PetscSF,), + arg1, + ) +end + +@for_petsc function PetscSFSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSFSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscSF,), + arg1, + ) +end + +@for_petsc function PetscSFDuplicate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSFDuplicate, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSFDuplicateOption, Ptr{PetscSF}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSFWindowSetSyncType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFWindowSetSyncType, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSFWindowSyncType), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFWindowGetSyncType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFWindowGetSyncType, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{PetscSFWindowSyncType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFWindowSetFlavorType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFWindowSetFlavorType, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSFWindowFlavorType), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFWindowGetFlavorType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFWindowGetFlavorType, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{PetscSFWindowFlavorType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFWindowSetInfo(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFWindowSetInfo, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Info), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFWindowGetInfo(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFWindowGetInfo, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{MPI_Info}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFSetRankOrder(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFSetRankOrder, $petsc_library), + PetscErrorCode, + (PetscSF, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFGetLeafRange(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSFGetLeafRange, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSFCreateEmbeddedRootSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSFCreateEmbeddedRootSF, $petsc_library), + PetscErrorCode, + (PetscSF, $PetscInt, Ptr{$PetscInt}, Ptr{PetscSF}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSFCreateEmbeddedLeafSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSFCreateEmbeddedLeafSF, $petsc_library), + PetscErrorCode, + (PetscSF, $PetscInt, Ptr{$PetscInt}, Ptr{PetscSF}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSFReset(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSFReset, $petsc_library), + PetscErrorCode, + (PetscSF,), + arg1, + ) +end + +@for_petsc function PetscSFGetRootRanks( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscSFGetRootRanks, $petsc_library), + PetscErrorCode, + ( + PetscSF, + Ptr{$PetscInt}, + Ptr{Ptr{PetscMPIInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscSFGetLeafRanks( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSFGetLeafRanks, $petsc_library), + PetscErrorCode, + ( + PetscSF, + Ptr{$PetscInt}, + Ptr{Ptr{PetscMPIInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSFGetMultiSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFGetMultiSF, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{PetscSF}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFCreateInverseSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFCreateInverseSF, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{PetscSF}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFSetGraphSection(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSFSetGraphSection, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSection, PetscSection), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSFCreateRemoteOffsets( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSFCreateRemoteOffsets, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSection, PetscSection, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSFDistributeSection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSFDistributeSection, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSection, Ptr{Ptr{$PetscInt}}, PetscSection), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSFCreateSectionSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSFCreateSectionSF, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSection, Ptr{$PetscInt}, PetscSection, Ptr{PetscSF}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSFBcastBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSFBcastBegin, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}, MPI_Op), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSFBcastEnd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSFBcastEnd, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}, MPI_Op), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSFBcastWithMemTypeBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscSFBcastWithMemTypeBegin, $petsc_library), + PetscErrorCode, + ( + PetscSF, + MPI_Datatype, + PetscMemType, + Ptr{Cvoid}, + PetscMemType, + Ptr{Cvoid}, + MPI_Op, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscSFReduceBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSFReduceBegin, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}, MPI_Op), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSFReduceEnd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSFReduceEnd, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}, MPI_Op), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSFReduceWithMemTypeBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscSFReduceWithMemTypeBegin, $petsc_library), + PetscErrorCode, + ( + PetscSF, + MPI_Datatype, + PetscMemType, + Ptr{Cvoid}, + PetscMemType, + Ptr{Cvoid}, + MPI_Op, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscSFFetchAndOpBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscSFFetchAndOpBegin, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, MPI_Op), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscSFFetchAndOpEnd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscSFFetchAndOpEnd, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, MPI_Op), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscSFComputeDegreeBegin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFComputeDegreeBegin, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFComputeDegreeEnd(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSFComputeDegreeEnd, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSFComputeMultiRootOriginalNumbering( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSFComputeMultiRootOriginalNumbering, $petsc_library), + PetscErrorCode, + (PetscSF, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSFGatherBegin(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscSFGatherBegin, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSFGatherEnd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscSFGatherEnd, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSFScatterBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSFScatterBegin, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSFScatterEnd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscSFScatterEnd, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSFCompose(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSFCompose, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSF, Ptr{PetscSF}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSFComposeInverse(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSFComposeInverse, $petsc_library), + PetscErrorCode, + (PetscSF, PetscSF, Ptr{PetscSF}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSFGetRanks( + ::$UnionPetscLib, + sf, + nranks, + ranks, + roffset, + rmine, + rremote, +) + @chk ccall( + (:PetscSFGetRanks, $petsc_library), + PetscErrorCode, + ( + PetscSF, + Ptr{$PetscInt}, + Ptr{Ptr{PetscMPIInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + ), + sf, + nranks, + ranks, + roffset, + rmine, + rremote, + ) +end + +@for_petsc function PetscSFCreateEmbeddedSF( + ::$UnionPetscLib, + sf, + nselected, + selected, + esf, +) + @chk ccall( + (:PetscSFCreateEmbeddedSF, $petsc_library), + PetscErrorCode, + (PetscSF, $PetscInt, Ptr{$PetscInt}, Ptr{PetscSF}), + sf, + nselected, + selected, + esf, + ) +end + +@for_petsc function PetscSFBcastAndOpBegin( + ::$UnionPetscLib, + sf, + unit, + rootdata, + leafdata, + op, +) + @chk ccall( + (:PetscSFBcastAndOpBegin, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}, MPI_Op), + sf, + unit, + rootdata, + leafdata, + op, + ) +end + +@for_petsc function PetscSFBcastAndOpEnd( + ::$UnionPetscLib, + sf, + unit, + rootdata, + leafdata, + op, +) + @chk ccall( + (:PetscSFBcastAndOpEnd, $petsc_library), + PetscErrorCode, + (PetscSF, MPI_Datatype, Ptr{Cvoid}, Ptr{Cvoid}, MPI_Op), + sf, + unit, + rootdata, + leafdata, + op, + ) +end + +@for_petsc function PetscSFBcastAndOpWithMemtypeBegin( + ::$UnionPetscLib, + sf, + unit, + rootmtype, + rootdata, + leafmtype, + leafdata, + op, +) + @chk ccall( + (:PetscSFBcastAndOpWithMemtypeBegin, $petsc_library), + PetscErrorCode, + ( + PetscSF, + MPI_Datatype, + PetscMemType, + Ptr{Cvoid}, + PetscMemType, + Ptr{Cvoid}, + MPI_Op, + ), + sf, + unit, + rootmtype, + rootdata, + leafmtype, + leafdata, + op, + ) +end + +@for_petsc function PetscSectionCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionClone(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionClone, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSectionSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscSection,), + arg1, + ) +end + +@for_petsc function PetscSectionCopy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionCopy, $petsc_library), + PetscErrorCode, + (PetscSection, PetscSection), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionCompare(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionCompare, $petsc_library), + PetscErrorCode, + (PetscSection, PetscSection, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetNumFields(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionGetNumFields, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSetNumFields(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSetNumFields, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionGetFieldName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionGetFieldName, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionSetFieldName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionSetFieldName, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetComponentName( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionGetComponentName, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionSetComponentName( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionSetComponentName, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, Ptr{Cchar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionGetFieldComponents( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionGetFieldComponents, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionSetFieldComponents( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionSetFieldComponents, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetChart(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionGetChart, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionSetChart(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionSetChart, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetPermutation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionGetPermutation, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSetPermutation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSetPermutation, $petsc_library), + PetscErrorCode, + (PetscSection, IS), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionGetPointMajor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionGetPointMajor, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSetPointMajor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSetPointMajor, $petsc_library), + PetscErrorCode, + (PetscSection, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionGetDof(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionGetDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionSetDof(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionSetDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionAddDof(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionAddDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetFieldDof( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionGetFieldDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionSetFieldDof( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionSetFieldDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionAddFieldDof( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionAddFieldDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionHasConstraints(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionHasConstraints, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionGetConstraintDof( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionGetConstraintDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionSetConstraintDof( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionSetConstraintDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionAddConstraintDof( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionAddConstraintDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetFieldConstraintDof( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionGetFieldConstraintDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionSetFieldConstraintDof( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionSetFieldConstraintDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionAddFieldConstraintDof( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionAddFieldConstraintDof, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionGetConstraintIndices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionGetConstraintIndices, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionSetConstraintIndices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionSetConstraintIndices, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetFieldConstraintIndices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionGetFieldConstraintIndices, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionSetFieldConstraintIndices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionSetFieldConstraintIndices, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionSetUpBC(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSectionSetUpBC, $petsc_library), + PetscErrorCode, + (PetscSection,), + arg1, + ) +end + +@for_petsc function PetscSectionSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSectionSetUp, $petsc_library), + PetscErrorCode, + (PetscSection,), + arg1, + ) +end + +@for_petsc function PetscSectionGetMaxDof(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionGetMaxDof, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionGetStorageSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionGetStorageSize, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionGetConstrainedStorageSize( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscSectionGetConstrainedStorageSize, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionGetOffset(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionGetOffset, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionSetOffset(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionSetOffset, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetFieldOffset( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionGetFieldOffset, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionSetFieldOffset( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionSetFieldOffset, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionGetFieldPointOffset( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionGetFieldPointOffset, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionGetOffsetRange( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionGetOffsetRange, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionView, $petsc_library), + PetscErrorCode, + (PetscSection, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscSection, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionReset(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSectionReset, $petsc_library), + PetscErrorCode, + (PetscSection,), + arg1, + ) +end + +@for_petsc function PetscSectionDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSectionDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscSection},), + arg1, + ) +end + +@for_petsc function PetscSectionCreateGlobalSection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSectionCreateGlobalSection, $petsc_library), + PetscErrorCode, + (PetscSection, PetscSF, PetscBool, PetscBool, Ptr{PetscSection}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSectionCreateGlobalSectionCensored( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscSectionCreateGlobalSectionCensored, $petsc_library), + PetscErrorCode, + ( + PetscSection, + PetscSF, + PetscBool, + $PetscInt, + Ptr{$PetscInt}, + Ptr{PetscSection}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscSectionCreateSubsection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionCreateSubsection, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{$PetscInt}, Ptr{PetscSection}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionCreateSupersection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionCreateSupersection, $petsc_library), + PetscErrorCode, + (Ptr{PetscSection}, $PetscInt, Ptr{PetscSection}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionCreateSubmeshSection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionCreateSubmeshSection, $petsc_library), + PetscErrorCode, + (PetscSection, IS, Ptr{PetscSection}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionPermute(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionPermute, $petsc_library), + PetscErrorCode, + (PetscSection, IS, Ptr{PetscSection}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetField(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionGetField, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{PetscSection}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionSetUseFieldOffsets(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSetUseFieldOffsets, $petsc_library), + PetscErrorCode, + (PetscSection, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionGetUseFieldOffsets(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionGetUseFieldOffsets, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionExtractDofsFromArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscSectionExtractDofsFromArray, $petsc_library), + PetscErrorCode, + ( + PetscSection, + MPI_Datatype, + Ptr{Cvoid}, + IS, + Ptr{PetscSection}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscSectionSetClosureIndex( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionSetClosureIndex, $petsc_library), + PetscErrorCode, + (PetscSection, PetscObject, PetscSection, IS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionGetClosureIndex( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionGetClosureIndex, $petsc_library), + PetscErrorCode, + (PetscSection, PetscObject, Ptr{PetscSection}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionSetClosurePermutation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscSectionSetClosurePermutation, $petsc_library), + PetscErrorCode, + (PetscSection, PetscObject, $PetscInt, IS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscSectionGetClosurePermutation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSectionGetClosurePermutation, $petsc_library), + PetscErrorCode, + (PetscSection, PetscObject, $PetscInt, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSectionGetClosureInversePermutation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSectionGetClosureInversePermutation, $petsc_library), + PetscErrorCode, + (PetscSection, PetscObject, $PetscInt, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSectionSymSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSymSetType, $petsc_library), + PetscErrorCode, + (PetscSectionSym, PetscSectionSymType), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSymGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSymGetType, $petsc_library), + PetscErrorCode, + (PetscSectionSym, Ptr{PetscSectionSymType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSymRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSymRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSymCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSymCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscSectionSym}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSymDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSectionSymDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscSectionSym},), + arg1, + ) +end + +@for_petsc function PetscSectionSymView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSymView, $petsc_library), + PetscErrorCode, + (PetscSectionSym, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSetSym(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSetSym, $petsc_library), + PetscErrorCode, + (PetscSection, PetscSectionSym), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionGetSym(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionGetSym, $petsc_library), + PetscErrorCode, + (PetscSection, Ptr{PetscSectionSym}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSetFieldSym(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionSetFieldSym, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, PetscSectionSym), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetFieldSym(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSectionGetFieldSym, $petsc_library), + PetscErrorCode, + (PetscSection, $PetscInt, Ptr{PetscSectionSym}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionGetPointSyms( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSectionGetPointSyms, $petsc_library), + PetscErrorCode, + ( + PetscSection, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{$PetscInt}}}, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSectionRestorePointSyms( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscSectionRestorePointSyms, $petsc_library), + PetscErrorCode, + ( + PetscSection, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{$PetscInt}}}, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscSectionGetFieldPointSyms( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscSectionGetFieldPointSyms, $petsc_library), + PetscErrorCode, + ( + PetscSection, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{$PetscInt}}}, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscSectionRestoreFieldPointSyms( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscSectionRestoreFieldPointSyms, $petsc_library), + PetscErrorCode, + ( + PetscSection, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{$PetscInt}}}, + Ptr{Ptr{Ptr{$PetscScalar}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +const MatType = Ptr{Cchar} + +const MatSolverType = Ptr{Cchar} + +@enum MatFactorType::UInt32 begin + MAT_FACTOR_NONE = 0 + MAT_FACTOR_LU = 1 + MAT_FACTOR_CHOLESKY = 2 + MAT_FACTOR_ILU = 3 + MAT_FACTOR_ICC = 4 + MAT_FACTOR_ILUDT = 5 + MAT_FACTOR_QR = 6 + MAT_FACTOR_NUM_TYPES = 7 +end + +@for_petsc function MatGetFactor(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatGetFactor, $petsc_library), + PetscErrorCode, + (Mat, MatSolverType, MatFactorType, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatGetFactorAvailable( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatGetFactorAvailable, $petsc_library), + PetscErrorCode, + (Mat, MatSolverType, MatFactorType, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatFactorGetUseOrdering(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFactorGetUseOrdering, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function MatFactorGetSolverType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFactorGetSolverType, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatSolverType}), + arg1, + arg2, + ) +end + +@for_petsc function MatGetFactorType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetFactorType, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatFactorType}), + arg1, + arg2, + ) +end + +@for_petsc function MatSetFactorType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetFactorType, $petsc_library), + PetscErrorCode, + (Mat, MatFactorType), + arg1, + arg2, + ) +end + +# typedef PetscErrorCode ( * MatSolverFunction ) ( Mat , MatFactorType , Mat * ) +const MatSolverFunction = Ptr{Cvoid} + +@for_petsc function MatSolverTypeRegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatSolverTypeRegister, $petsc_library), + PetscErrorCode, + (MatSolverType, MatType, MatFactorType, MatSolverFunction), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSolverTypeGet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatSolverTypeGet, $petsc_library), + PetscErrorCode, + ( + MatSolverType, + MatType, + MatFactorType, + Ptr{PetscBool}, + Ptr{PetscBool}, + Ptr{MatSolverFunction}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +const MatSolverPackage = MatSolverType + +@for_petsc function MatSolverPackageRegister( + ::$UnionPetscLib, + stype, + mtype, + ftype, + f, +) + @chk ccall( + (:MatSolverPackageRegister, $petsc_library), + PetscErrorCode, + (MatSolverType, MatType, MatFactorType, MatSolverFunction), + stype, + mtype, + ftype, + f, + ) +end + +@for_petsc function MatSolverPackageGet( + ::$UnionPetscLib, + stype, + mtype, + ftype, + foundmtype, + foundstype, + f, +) + @chk ccall( + (:MatSolverPackageGet, $petsc_library), + PetscErrorCode, + ( + MatSolverType, + MatType, + MatFactorType, + Ptr{PetscBool}, + Ptr{PetscBool}, + Ptr{MatSolverFunction}, + ), + stype, + mtype, + ftype, + foundmtype, + foundstype, + f, + ) +end + +@enum MatProductType::UInt32 begin + MATPRODUCT_UNSPECIFIED = 0 + MATPRODUCT_AB = 1 + MATPRODUCT_AtB = 2 + MATPRODUCT_ABt = 3 + MATPRODUCT_PtAP = 4 + MATPRODUCT_RARt = 5 + MATPRODUCT_ABC = 6 +end + +const MatProductAlgorithm = Ptr{Cchar} + +@for_petsc function MatProductCreate(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatProductCreate, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatProductCreateWithMat( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatProductCreateWithMat, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatProductSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatProductSetType, $petsc_library), + PetscErrorCode, + (Mat, MatProductType), + arg1, + arg2, + ) +end + +@for_petsc function MatProductSetAlgorithm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatProductSetAlgorithm, $petsc_library), + PetscErrorCode, + (Mat, MatProductAlgorithm), + arg1, + arg2, + ) +end + +@for_petsc function MatProductSetFill(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatProductSetFill, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatProductSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:MatProductSetFromOptions, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatProductSymbolic(::$UnionPetscLib, arg1) + @chk ccall( + (:MatProductSymbolic, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatProductNumeric(::$UnionPetscLib, arg1) + @chk ccall( + (:MatProductNumeric, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatProductReplaceMats( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatProductReplaceMats, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatProductClear(::$UnionPetscLib, arg1) + @chk ccall((:MatProductClear, $petsc_library), PetscErrorCode, (Mat,), arg1) +end + +@for_petsc function MatProductView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatProductView, $petsc_library), + PetscErrorCode, + (Mat, PetscViewer), + arg1, + arg2, + ) +end + +@enum MatReuse::UInt32 begin + MAT_INITIAL_MATRIX = 0 + MAT_REUSE_MATRIX = 1 + MAT_IGNORE_MATRIX = 2 + MAT_INPLACE_MATRIX = 3 +end + +@enum MatCreateSubMatrixOption::UInt32 begin + MAT_DO_NOT_GET_VALUES = 0 + MAT_GET_VALUES = 1 +end + +@for_petsc function MatInitializePackage(::$UnionPetscLib) + @chk ccall((:MatInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function MatCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatSetSizes(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:MatSetSizes, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetType, $petsc_library), + PetscErrorCode, + (Mat, MatType), + arg1, + arg2, + ) +end + +@for_petsc function MatGetVecType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetVecType, $petsc_library), + PetscErrorCode, + (Mat, Ptr{VecType}), + arg1, + arg2, + ) +end + +@for_petsc function MatSetVecType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetVecType, $petsc_library), + PetscErrorCode, + (Mat, VecType), + arg1, + arg2, + ) +end + +@for_petsc function MatSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:MatSetFromOptions, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatViewFromOptions, $petsc_library), + PetscErrorCode, + (Mat, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatRegisterRootName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatRegisterRootName, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function MatAppendOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function MatGetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatSetErrorIfFailure(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetErrorIfFailure, $petsc_library), + PetscErrorCode, + (Mat, PetscBool), + arg1, + arg2, + ) +end + +@enum MatStructure::UInt32 begin + DIFFERENT_NONZERO_PATTERN = 0 + SUBSET_NONZERO_PATTERN = 1 + SAME_NONZERO_PATTERN = 2 + UNKNOWN_NONZERO_PATTERN = 3 +end + +@for_petsc function MatCreateSeqSELL( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatCreateSeqSELL, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatCreateSELL( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:MatCreateSELL, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function MatSeqSELLSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatSeqSELLSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMPISELLSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatMPISELLSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatCreateSeqDense( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatCreateSeqDense, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatCreateDense( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateDense, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscScalar}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatCreateSeqAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatCreateSeqAIJ, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatCreateAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:MatCreateAIJ, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function MatCreateMPIAIJWithArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:MatCreateMPIAIJWithArrays, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function MatUpdateMPIAIJWithArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:MatUpdateMPIAIJWithArrays, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function MatCreateMPIAIJWithSplitArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, +) + @chk ccall( + (:MatCreateMPIAIJWithSplitArrays, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + ) +end + +@for_petsc function MatCreateMPIAIJWithSeqAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatCreateMPIAIJWithSeqAIJ, $petsc_library), + PetscErrorCode, + (MPI_Comm, Mat, Mat, Ptr{$PetscInt}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatCreateSeqBAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateSeqBAIJ, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatCreateBAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:MatCreateBAIJ, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function MatCreateMPIBAIJWithArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:MatCreateMPIBAIJWithArrays, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function MatSetPreallocationCOO( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatSetPreallocationCOO, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSetValuesCOO(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSetValuesCOO, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscScalar}, InsertMode), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatCreateMPIAdj( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateMPIAdj, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatCreateSeqSBAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateSeqSBAIJ, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatCreateSBAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:MatCreateSBAIJ, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function MatCreateMPISBAIJWithArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:MatCreateMPISBAIJWithArrays, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function MatSeqSBAIJSetPreallocationCSR( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatSeqSBAIJSetPreallocationCSR, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatMPISBAIJSetPreallocationCSR( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatMPISBAIJSetPreallocationCSR, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatXAIJSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatXAIJSetPreallocation, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatCreateShell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateShell, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatCreateNormal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCreateNormal, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateNormalHermitian(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCreateNormalHermitian, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateLRC(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:MatCreateLRC, $petsc_library), + PetscErrorCode, + (Mat, Mat, Vec, Mat, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatLRCGetMats( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatLRCGetMats, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}, Ptr{Mat}, Ptr{Vec}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatCreateIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:MatCreateIS, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + ISLocalToGlobalMapping, + ISLocalToGlobalMapping, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function MatCreateSeqAIJCRL( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatCreateSeqAIJCRL, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatCreateMPIAIJCRL( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:MatCreateMPIAIJCRL, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function MatCreateScatter(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatCreateScatter, $petsc_library), + PetscErrorCode, + (MPI_Comm, VecScatter, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatScatterSetVecScatter(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatScatterSetVecScatter, $petsc_library), + PetscErrorCode, + (Mat, VecScatter), + arg1, + arg2, + ) +end + +@for_petsc function MatScatterGetVecScatter(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatScatterGetVecScatter, $petsc_library), + PetscErrorCode, + (Mat, Ptr{VecScatter}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateBlockMat( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateBlockMat, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatCompositeAddMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCompositeAddMat, $petsc_library), + PetscErrorCode, + (Mat, Mat), + arg1, + arg2, + ) +end + +@for_petsc function MatCompositeMerge(::$UnionPetscLib, arg1) + @chk ccall( + (:MatCompositeMerge, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@enum MatCompositeMergeType::UInt32 begin + MAT_COMPOSITE_MERGE_RIGHT = 0 + MAT_COMPOSITE_MERGE_LEFT = 1 +end + +@for_petsc function MatCompositeSetMergeType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCompositeSetMergeType, $petsc_library), + PetscErrorCode, + (Mat, MatCompositeMergeType), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateComposite(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatCreateComposite, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{Mat}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@enum MatCompositeType::UInt32 begin + MAT_COMPOSITE_ADDITIVE = 0 + MAT_COMPOSITE_MULTIPLICATIVE = 1 +end + +@for_petsc function MatCompositeSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCompositeSetType, $petsc_library), + PetscErrorCode, + (Mat, MatCompositeType), + arg1, + arg2, + ) +end + +@for_petsc function MatCompositeGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCompositeGetType, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatCompositeType}), + arg1, + arg2, + ) +end + +@for_petsc function MatCompositeSetMatStructure(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCompositeSetMatStructure, $petsc_library), + PetscErrorCode, + (Mat, MatStructure), + arg1, + arg2, + ) +end + +@for_petsc function MatCompositeGetMatStructure(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCompositeGetMatStructure, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatStructure}), + arg1, + arg2, + ) +end + +@for_petsc function MatCompositeGetNumberMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCompositeGetNumberMat, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatCompositeGetMat(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatCompositeGetMat, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatCompositeSetScalings(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCompositeSetScalings, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateFFT(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:MatCreateFFT, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{$PetscInt}, MatType, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatCreateSeqCUFFT(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatCreateSeqCUFFT, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{$PetscInt}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateTranspose(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCreateTranspose, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatTransposeGetMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatTransposeGetMat, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateHermitianTranspose(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCreateHermitianTranspose, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatHermitianTransposeGetMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatHermitianTransposeGetMat, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateSubMatrixVirtual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatCreateSubMatrixVirtual, $petsc_library), + PetscErrorCode, + (Mat, IS, IS, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSubMatrixVirtualUpdate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatSubMatrixVirtualUpdate, $petsc_library), + PetscErrorCode, + (Mat, Mat, IS, IS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateLocalRef(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatCreateLocalRef, $petsc_library), + PetscErrorCode, + (Mat, IS, IS, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateConstantDiagonal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateConstantDiagonal, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscScalar, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatPythonSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPythonSetType, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function MatResetPreallocation(::$UnionPetscLib, arg1) + @chk ccall( + (:MatResetPreallocation, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatSetUp(::$UnionPetscLib, arg1) + @chk ccall((:MatSetUp, $petsc_library), PetscErrorCode, (Mat,), arg1) +end + +@for_petsc function MatDestroy(::$UnionPetscLib, arg1) + @chk ccall((:MatDestroy, $petsc_library), PetscErrorCode, (Ptr{Mat},), arg1) +end + +@for_petsc function MatGetNonzeroState(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetNonzeroState, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscObjectState}), + arg1, + arg2, + ) +end + +@for_petsc function MatConjugate(::$UnionPetscLib, arg1) + @chk ccall((:MatConjugate, $petsc_library), PetscErrorCode, (Mat,), arg1) +end + +@for_petsc function MatRealPart(::$UnionPetscLib, arg1) + @chk ccall((:MatRealPart, $petsc_library), PetscErrorCode, (Mat,), arg1) +end + +@for_petsc function MatImaginaryPart(::$UnionPetscLib, arg1) + @chk ccall( + (:MatImaginaryPart, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatGetDiagonalBlock(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetDiagonalBlock, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatGetTrace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetTrace, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function MatInvertBlockDiagonal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatInvertBlockDiagonal, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatInvertVariableBlockDiagonal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatInvertVariableBlockDiagonal, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatInvertBlockDiagonalMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatInvertBlockDiagonalMat, $petsc_library), + PetscErrorCode, + (Mat, Mat), + arg1, + arg2, + ) +end + +@for_petsc function MatSetValues( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatSetValues, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatSetValuesBlocked( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatSetValuesBlocked, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatSetValuesRow(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSetValuesRow, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSetValuesRowLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSetValuesRowLocal, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSetValuesBatch( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatSetValuesBatch, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatSetRandom(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetRandom, $petsc_library), + PetscErrorCode, + (Mat, PetscRandom), + arg1, + arg2, + ) +end + +@for_petsc function MatSetStencil( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatSetStencil, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@enum MatAssemblyType::UInt32 begin + MAT_FLUSH_ASSEMBLY = 1 + MAT_FINAL_ASSEMBLY = 0 +end + +@for_petsc function MatAssemblyBegin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatAssemblyBegin, $petsc_library), + PetscErrorCode, + (Mat, MatAssemblyType), + arg1, + arg2, + ) +end + +@for_petsc function MatAssemblyEnd(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatAssemblyEnd, $petsc_library), + PetscErrorCode, + (Mat, MatAssemblyType), + arg1, + arg2, + ) +end + +@for_petsc function MatAssembled(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatAssembled, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@enum MatOption::Int32 begin + MAT_OPTION_MIN = -3 + MAT_UNUSED_NONZERO_LOCATION_ERR = -2 + MAT_ROW_ORIENTED = -1 + MAT_SYMMETRIC = 1 + MAT_STRUCTURALLY_SYMMETRIC = 2 + MAT_FORCE_DIAGONAL_ENTRIES = 3 + MAT_IGNORE_OFF_PROC_ENTRIES = 4 + MAT_USE_HASH_TABLE = 5 + MAT_KEEP_NONZERO_PATTERN = 6 + MAT_IGNORE_ZERO_ENTRIES = 7 + MAT_USE_INODES = 8 + MAT_HERMITIAN = 9 + MAT_SYMMETRY_ETERNAL = 10 + MAT_NEW_NONZERO_LOCATION_ERR = 11 + MAT_IGNORE_LOWER_TRIANGULAR = 12 + MAT_ERROR_LOWER_TRIANGULAR = 13 + MAT_GETROW_UPPERTRIANGULAR = 14 + MAT_SPD = 15 + MAT_NO_OFF_PROC_ZERO_ROWS = 16 + MAT_NO_OFF_PROC_ENTRIES = 17 + MAT_NEW_NONZERO_LOCATIONS = 18 + MAT_NEW_NONZERO_ALLOCATION_ERR = 19 + MAT_SUBSET_OFF_PROC_ENTRIES = 20 + MAT_SUBMAT_SINGLEIS = 21 + MAT_STRUCTURE_ONLY = 22 + MAT_SORTED_FULL = 23 + MAT_FORM_EXPLICIT_TRANSPOSE = 24 + MAT_OPTION_MAX = 25 +end + +@for_petsc function MatSetOption(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSetOption, $petsc_library), + PetscErrorCode, + (Mat, MatOption, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetOption(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetOption, $petsc_library), + PetscErrorCode, + (Mat, MatOption, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatPropagateSymmetryOptions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPropagateSymmetryOptions, $petsc_library), + PetscErrorCode, + (Mat, Mat), + arg1, + arg2, + ) +end + +@for_petsc function MatGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetType, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatType}), + arg1, + arg2, + ) +end + +@for_petsc function MatGetValues( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatGetValues, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatGetRow(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:MatGetRow, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatRestoreRow( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatRestoreRow, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatGetRowUpperTriangular(::$UnionPetscLib, arg1) + @chk ccall( + (:MatGetRowUpperTriangular, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatRestoreRowUpperTriangular(::$UnionPetscLib, arg1) + @chk ccall( + (:MatRestoreRowUpperTriangular, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatGetColumnVector(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetColumnVector, $petsc_library), + PetscErrorCode, + (Mat, Vec, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSeqAIJGetArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqAIJGetArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqAIJGetArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqAIJGetArrayRead, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqAIJRestoreArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqAIJRestoreArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqAIJRestoreArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqAIJRestoreArrayRead, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqAIJGetMaxRowNonzeros(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqAIJGetMaxRowNonzeros, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqAIJSetValuesLocalFast( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatSeqAIJSetValuesLocalFast, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatSeqAIJSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqAIJSetType, $petsc_library), + PetscErrorCode, + (Mat, MatType), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqAIJRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqAIJRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqBAIJGetArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqBAIJGetArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqBAIJRestoreArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqBAIJRestoreArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqSBAIJGetArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqSBAIJGetArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqSBAIJRestoreArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqSBAIJRestoreArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseGetArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseGetArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseRestoreArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseRestoreArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatDensePlaceArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDensePlaceArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseReplaceArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseReplaceArray, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseResetArray(::$UnionPetscLib, arg1) + @chk ccall( + (:MatDenseResetArray, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatDenseGetArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseGetArrayRead, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseRestoreArrayRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseRestoreArrayRead, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseGetArrayWrite(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseGetArrayWrite, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseRestoreArrayWrite(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseRestoreArrayWrite, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatGetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetBlockSize, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatSetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetBlockSize, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatGetBlockSizes(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetBlockSizes, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSetBlockSizes(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSetBlockSizes, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSetBlockSizesFromMats(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSetBlockSizesFromMats, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSetVariableBlockSizes(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSetVariableBlockSizes, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetVariableBlockSizes(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetVariableBlockSizes, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatDenseGetColumn(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatDenseGetColumn, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatDenseRestoreColumn(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseRestoreColumn, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseGetColumnVec(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatDenseGetColumnVec, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatDenseRestoreColumnVec(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatDenseRestoreColumnVec, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatDenseGetColumnVecRead(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatDenseGetColumnVecRead, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatDenseRestoreColumnVecRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatDenseRestoreColumnVecRead, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatDenseGetColumnVecWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatDenseGetColumnVecWrite, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatDenseRestoreColumnVecWrite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatDenseRestoreColumnVecWrite, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatDenseGetSubMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatDenseGetSubMatrix, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatDenseRestoreSubMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseRestoreSubMatrix, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatMult(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMult, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMultDiagonalBlock(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMultDiagonalBlock, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMultAdd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatMultAdd, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMultTranspose(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMultTranspose, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMultHermitianTranspose( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatMultHermitianTranspose, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatIsTranspose(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatIsTranspose, $petsc_library), + PetscErrorCode, + (Mat, Mat, $PetscReal, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatIsHermitianTranspose( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatIsHermitianTranspose, $petsc_library), + PetscErrorCode, + (Mat, Mat, $PetscReal, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMultTransposeAdd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMultTransposeAdd, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMultHermitianTransposeAdd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMultHermitianTransposeAdd, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMultConstrained(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMultConstrained, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMultTransposeConstrained( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatMultTransposeConstrained, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMatSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMatSolve, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMatSolveTranspose(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMatSolveTranspose, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMatTransposeSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMatTransposeSolve, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatResidual(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatResidual, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@enum MatDuplicateOption::UInt32 begin + MAT_DO_NOT_COPY_VALUES = 0 + MAT_COPY_VALUES = 1 + MAT_SHARE_NONZERO_PATTERN = 2 +end + +@for_petsc function MatConvert(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatConvert, $petsc_library), + PetscErrorCode, + (Mat, MatType, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatDuplicate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatDuplicate, $petsc_library), + PetscErrorCode, + (Mat, MatDuplicateOption, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatCopy(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatCopy, $petsc_library), + PetscErrorCode, + (Mat, Mat, MatStructure), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatView, $petsc_library), + PetscErrorCode, + (Mat, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function MatIsSymmetric(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatIsSymmetric, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatIsStructurallySymmetric(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatIsStructurallySymmetric, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function MatIsHermitian(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatIsHermitian, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatIsSymmetricKnown(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatIsSymmetricKnown, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatIsHermitianKnown(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatIsHermitianKnown, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMissingDiagonal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMissingDiagonal, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLoad, $petsc_library), + PetscErrorCode, + (Mat, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function MatGetRowIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:MatGetRowIJ, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + PetscBool, + PetscBool, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function MatRestoreRowIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:MatRestoreRowIJ, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + PetscBool, + PetscBool, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function MatGetColumnIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:MatGetColumnIJ, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + PetscBool, + PetscBool, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function MatRestoreColumnIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:MatRestoreColumnIJ, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + PetscBool, + PetscBool, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +mutable struct MatInfo + block_size::PetscLogDouble + nz_allocated::PetscLogDouble + nz_used::PetscLogDouble + nz_unneeded::PetscLogDouble + memory::PetscLogDouble + assemblies::PetscLogDouble + mallocs::PetscLogDouble + fill_ratio_given::PetscLogDouble + fill_ratio_needed::PetscLogDouble + factor_mallocs::PetscLogDouble + MatInfo() = new() +end + +@enum MatInfoType::UInt32 begin + MAT_LOCAL = 1 + MAT_GLOBAL_MAX = 2 + MAT_GLOBAL_SUM = 3 +end + +@for_petsc function MatGetInfo(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetInfo, $petsc_library), + PetscErrorCode, + (Mat, MatInfoType, Ptr{MatInfo}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetDiagonal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetDiagonal, $petsc_library), + PetscErrorCode, + (Mat, Vec), + arg1, + arg2, + ) +end + +@for_petsc function MatGetRowMax(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetRowMax, $petsc_library), + PetscErrorCode, + (Mat, Vec, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetRowMin(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetRowMin, $petsc_library), + PetscErrorCode, + (Mat, Vec, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetRowMaxAbs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetRowMaxAbs, $petsc_library), + PetscErrorCode, + (Mat, Vec, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetRowMinAbs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetRowMinAbs, $petsc_library), + PetscErrorCode, + (Mat, Vec, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetRowSum(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetRowSum, $petsc_library), + PetscErrorCode, + (Mat, Vec), + arg1, + arg2, + ) +end + +@for_petsc function MatTranspose(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatTranspose, $petsc_library), + PetscErrorCode, + (Mat, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatHermitianTranspose(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatHermitianTranspose, $petsc_library), + PetscErrorCode, + (Mat, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatPermute(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatPermute, $petsc_library), + PetscErrorCode, + (Mat, IS, IS, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatDiagonalScale(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatDiagonalScale, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatDiagonalSet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatDiagonalSet, $petsc_library), + PetscErrorCode, + (Mat, Vec, InsertMode), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatEqual(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMultEqual(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatMultEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMultAddEqual(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatMultAddEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMultTransposeEqual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMultTransposeEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMultTransposeAddEqual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMultTransposeAddEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMatMultEqual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatMatMultEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatTransposeMatMultEqual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatTransposeMatMultEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatMatTransposeMultEqual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatMatTransposeMultEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatPtAPMultEqual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatPtAPMultEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatRARtMultEqual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatRARtMultEqual, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatIsLinear(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatIsLinear, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatNorm(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatNorm, $petsc_library), + PetscErrorCode, + (Mat, NormType, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetColumnNorms(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetColumnNorms, $petsc_library), + PetscErrorCode, + (Mat, NormType, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatZeroEntries(::$UnionPetscLib, arg1) + @chk ccall((:MatZeroEntries, $petsc_library), PetscErrorCode, (Mat,), arg1) +end + +@for_petsc function MatSetInf(::$UnionPetscLib, arg1) + @chk ccall((:MatSetInf, $petsc_library), PetscErrorCode, (Mat,), arg1) +end + +@for_petsc function MatZeroRows( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatZeroRows, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatZeroRowsIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatZeroRowsIS, $petsc_library), + PetscErrorCode, + (Mat, IS, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatZeroRowsColumns( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatZeroRowsColumns, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatZeroRowsColumnsIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatZeroRowsColumnsIS, $petsc_library), + PetscErrorCode, + (Mat, IS, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatGetSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetSize, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetLocalSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetLocalSize, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetOwnershipRange(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetOwnershipRange, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetOwnershipRanges(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetOwnershipRanges, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function MatGetOwnershipRangeColumn( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatGetOwnershipRangeColumn, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetOwnershipRangesColumn(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetOwnershipRangesColumn, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function MatGetOwnershipIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetOwnershipIS, $petsc_library), + PetscErrorCode, + (Mat, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatCreateSubMatrices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatCreateSubMatrices, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{IS}, Ptr{IS}, MatReuse, Ptr{Ptr{Mat}}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatGetSubMatrices( + ::$UnionPetscLib, + mat, + n, + irow, + icol, + scall, + submat, +) + @chk ccall( + (:MatGetSubMatrices, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{IS}, Ptr{IS}, MatReuse, Ptr{Ptr{Mat}}), + mat, + n, + irow, + icol, + scall, + submat, + ) +end + +@for_petsc function MatCreateSubMatricesMPI( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatCreateSubMatricesMPI, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{IS}, Ptr{IS}, MatReuse, Ptr{Ptr{Mat}}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatGetSubMatricesMPI( + ::$UnionPetscLib, + mat, + n, + irow, + icol, + scall, + submat, +) + @chk ccall( + (:MatGetSubMatricesMPI, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{IS}, Ptr{IS}, MatReuse, Ptr{Ptr{Mat}}), + mat, + n, + irow, + icol, + scall, + submat, + ) +end + +@for_petsc function MatDestroyMatrices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDestroyMatrices, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Ptr{Mat}}), + arg1, + arg2, + ) +end + +@for_petsc function MatDestroySubMatrices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDestroySubMatrices, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Ptr{Mat}}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateSubMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatCreateSubMatrix, $petsc_library), + PetscErrorCode, + (Mat, IS, IS, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatGetSubMatrix( + ::$UnionPetscLib, + mat, + isrow, + iscol, + cll, + newmat, +) + @chk ccall( + (:MatGetSubMatrix, $petsc_library), + PetscErrorCode, + (Mat, IS, IS, MatReuse, Ptr{Mat}), + mat, + isrow, + iscol, + cll, + newmat, + ) +end + +@for_petsc function MatGetLocalSubMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatGetLocalSubMatrix, $petsc_library), + PetscErrorCode, + (Mat, IS, IS, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatRestoreLocalSubMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatRestoreLocalSubMatrix, $petsc_library), + PetscErrorCode, + (Mat, IS, IS, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatGetSeqNonzeroStructure(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetSeqNonzeroStructure, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatDestroySeqNonzeroStructure(::$UnionPetscLib, arg1) + @chk ccall( + (:MatDestroySeqNonzeroStructure, $petsc_library), + PetscErrorCode, + (Ptr{Mat},), + arg1, + ) +end + +@for_petsc function MatCreateMPIAIJSumSeqAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatCreateMPIAIJSumSeqAIJ, $petsc_library), + PetscErrorCode, + (MPI_Comm, Mat, $PetscInt, $PetscInt, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatCreateMPIAIJSumSeqAIJSymbolic( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatCreateMPIAIJSumSeqAIJSymbolic, $petsc_library), + PetscErrorCode, + (MPI_Comm, Mat, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatCreateMPIAIJSumSeqAIJNumeric( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatCreateMPIAIJSumSeqAIJNumeric, $petsc_library), + PetscErrorCode, + (Mat, Mat), + arg1, + arg2, + ) +end + +@for_petsc function MatMPIAIJGetLocalMat(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMPIAIJGetLocalMat, $petsc_library), + PetscErrorCode, + (Mat, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMPIAIJGetLocalMatCondensed( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatMPIAIJGetLocalMatCondensed, $petsc_library), + PetscErrorCode, + (Mat, MatReuse, Ptr{IS}, Ptr{IS}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatMPIAIJGetLocalMatMerge( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMPIAIJGetLocalMatMerge, $petsc_library), + PetscErrorCode, + (Mat, MatReuse, Ptr{IS}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatGetBrowsOfAcols( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatGetBrowsOfAcols, $petsc_library), + PetscErrorCode, + (Mat, Mat, MatReuse, Ptr{IS}, Ptr{IS}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatGetGhosts(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetGhosts, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatIncreaseOverlap(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatIncreaseOverlap, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{IS}, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatIncreaseOverlapSplit(::$UnionPetscLib, mat, n, is, ov) + @chk ccall( + (:MatIncreaseOverlapSplit, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{IS}, $PetscInt), + mat, + n, + is, + ov, + ) +end + +@for_petsc function MatMPIAIJSetUseScalableIncreaseOverlap( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatMPIAIJSetUseScalableIncreaseOverlap, $petsc_library), + PetscErrorCode, + (Mat, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function MatMatMult(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:MatMatMult, $petsc_library), + PetscErrorCode, + (Mat, Mat, MatReuse, $PetscReal, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatMatMatMult( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatMatMatMult, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, MatReuse, $PetscReal, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatGalerkin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatGalerkin, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, MatReuse, $PetscReal, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatPtAP(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:MatPtAP, $petsc_library), + PetscErrorCode, + (Mat, Mat, MatReuse, $PetscReal, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatRARt(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:MatRARt, $petsc_library), + PetscErrorCode, + (Mat, Mat, MatReuse, $PetscReal, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatTransposeMatMult( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatTransposeMatMult, $petsc_library), + PetscErrorCode, + (Mat, Mat, MatReuse, $PetscReal, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatMatTransposeMult( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatMatTransposeMult, $petsc_library), + PetscErrorCode, + (Mat, Mat, MatReuse, $PetscReal, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatAXPY(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatAXPY, $petsc_library), + PetscErrorCode, + (Mat, $PetscScalar, Mat, MatStructure), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatAYPX(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatAYPX, $petsc_library), + PetscErrorCode, + (Mat, $PetscScalar, Mat, MatStructure), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatScale, $petsc_library), + PetscErrorCode, + (Mat, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function MatShift(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatShift, $petsc_library), + PetscErrorCode, + (Mat, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function MatSetLocalToGlobalMapping( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatSetLocalToGlobalMapping, $petsc_library), + PetscErrorCode, + (Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetLocalToGlobalMapping( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatGetLocalToGlobalMapping, $petsc_library), + PetscErrorCode, + (Mat, Ptr{ISLocalToGlobalMapping}, Ptr{ISLocalToGlobalMapping}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatZeroRowsLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatZeroRowsLocal, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatZeroRowsLocalIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatZeroRowsLocalIS, $petsc_library), + PetscErrorCode, + (Mat, IS, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatZeroRowsColumnsLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatZeroRowsColumnsLocal, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatZeroRowsColumnsLocalIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatZeroRowsColumnsLocalIS, $petsc_library), + PetscErrorCode, + (Mat, IS, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatGetValuesLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatGetValuesLocal, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatSetValuesLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatSetValuesLocal, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatSetValuesBlockedLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatSetValuesBlockedLocal, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatStashSetInitialSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatStashSetInitialSize, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatStashGetInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatStashGetInfo, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatInterpolate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatInterpolate, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatInterpolateAdd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatInterpolateAdd, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatRestrict(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatRestrict, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMatInterpolate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMatInterpolate, $petsc_library), + PetscErrorCode, + (Mat, Mat, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMatInterpolateAdd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMatInterpolateAdd, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMatRestrict(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMatRestrict, $petsc_library), + PetscErrorCode, + (Mat, Mat, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatCreateVecs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatCreateVecs, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetVecs(::$UnionPetscLib, mat, x, y) + @chk ccall( + (:MatGetVecs, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Vec}, Ptr{Vec}), + mat, + x, + y, + ) +end + +@for_petsc function MatCreateRedundantMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatCreateRedundantMatrix, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, MPI_Comm, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatGetMultiProcBlock( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatGetMultiProcBlock, $petsc_library), + PetscErrorCode, + (Mat, MPI_Comm, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatFindZeroDiagonals(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFindZeroDiagonals, $petsc_library), + PetscErrorCode, + (Mat, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function MatFindOffBlockDiagonalEntries(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFindOffBlockDiagonalEntries, $petsc_library), + PetscErrorCode, + (Mat, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateMPIMatConcatenateSeqMat( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatCreateMPIMatConcatenateSeqMat, $petsc_library), + PetscErrorCode, + (MPI_Comm, Mat, $PetscInt, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatSetValue(::$UnionPetscLib, v, i, j, va, mode) + @chk ccall( + (:MatSetValue, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, $PetscScalar, InsertMode), + v, + i, + j, + va, + mode, + ) +end + +@for_petsc function MatGetValue(::$UnionPetscLib, v, i, j, va) + @chk ccall( + (:MatGetValue, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{$PetscScalar}), + v, + i, + j, + va, + ) +end + +@for_petsc function MatSetValueLocal(::$UnionPetscLib, v, i, j, va, mode) + @chk ccall( + (:MatSetValueLocal, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, $PetscScalar, InsertMode), + v, + i, + j, + va, + mode, + ) +end + +@for_petsc function MatShellGetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatShellGetContext, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatInodeAdjustForInodes(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatInodeAdjustForInodes, $petsc_library), + PetscErrorCode, + (Mat, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatInodeGetInodeSizes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatInodeGetInodeSizes, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSeqAIJSetColumnIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqAIJSetColumnIndices, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqBAIJSetColumnIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqBAIJSetColumnIndices, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateSeqAIJWithArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateSeqAIJWithArrays, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatCreateSeqBAIJWithArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:MatCreateSeqBAIJWithArrays, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function MatCreateSeqSBAIJWithArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:MatCreateSeqSBAIJWithArrays, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function MatCreateSeqAIJFromTriple( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:MatCreateSeqAIJFromTriple, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{Mat}, + $PetscInt, + PetscBool, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function MatSeqBAIJSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatSeqBAIJSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSeqSBAIJSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatSeqSBAIJSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSeqAIJSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatSeqAIJSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSeqAIJSetTotalPreallocation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqAIJSetTotalPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatMPIBAIJSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatMPIBAIJSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatMPISBAIJSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatMPISBAIJSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatMPIAIJSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatMPIAIJSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatSeqAIJSetPreallocationCSR( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatSeqAIJSetPreallocationCSR, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSeqBAIJSetPreallocationCSR( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatSeqBAIJSetPreallocationCSR, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatMPIAIJSetPreallocationCSR( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMPIAIJSetPreallocationCSR, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMPIBAIJSetPreallocationCSR( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatMPIBAIJSetPreallocationCSR, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatMPIAdjSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMPIAdjSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMPIAdjToSeq(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMPIAdjToSeq, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatMPIDenseSetPreallocation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMPIDenseSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqDenseSetPreallocation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqDenseSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function MatMPIAIJGetSeqAIJ(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatMPIAIJGetSeqAIJ, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}, Ptr{Mat}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMPIBAIJGetSeqBAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMPIBAIJGetSeqBAIJ, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}, Ptr{Mat}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMPIAdjCreateNonemptySubcommMat( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatMPIAdjCreateNonemptySubcommMat, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseGetLDA(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseGetLDA, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatDenseSetLDA(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseSetLDA, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqDenseSetLDA(::$UnionPetscLib, A, lda) + @chk ccall( + (:MatSeqDenseSetLDA, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt), + A, + lda, + ) +end + +@for_petsc function MatDenseGetLocalMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDenseGetLocalMatrix, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatBlockMatSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatBlockMatSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatStoreValues(::$UnionPetscLib, arg1) + @chk ccall((:MatStoreValues, $petsc_library), PetscErrorCode, (Mat,), arg1) +end + +@for_petsc function MatRetrieveValues(::$UnionPetscLib, arg1) + @chk ccall( + (:MatRetrieveValues, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatFindNonzeroRows(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFindNonzeroRows, $petsc_library), + PetscErrorCode, + (Mat, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function MatFindZeroRows(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFindZeroRows, $petsc_library), + PetscErrorCode, + (Mat, Ptr{IS}), + arg1, + arg2, + ) +end + +const MatOrderingType = Ptr{Cchar} + +@for_petsc function MatGetOrdering(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatGetOrdering, $petsc_library), + PetscErrorCode, + (Mat, MatOrderingType, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatGetOrderingList(::$UnionPetscLib, arg1) + @chk ccall( + (:MatGetOrderingList, $petsc_library), + PetscErrorCode, + (Ptr{PetscFunctionList},), + arg1, + ) +end + +@for_petsc function MatOrderingRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatOrderingRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatReorderForNonzeroDiagonal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatReorderForNonzeroDiagonal, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal, IS, IS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateLaplacian(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatCreateLaplacian, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal, PetscBool, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@enum MatFactorShiftType::UInt32 begin + MAT_SHIFT_NONE = 0 + MAT_SHIFT_NONZERO = 1 + MAT_SHIFT_POSITIVE_DEFINITE = 2 + MAT_SHIFT_INBLOCKS = 3 +end + +@enum MatFactorError::UInt32 begin + MAT_FACTOR_NOERROR = 0 + MAT_FACTOR_STRUCT_ZEROPIVOT = 1 + MAT_FACTOR_NUMERIC_ZEROPIVOT = 2 + MAT_FACTOR_OUTMEMORY = 3 + MAT_FACTOR_OTHER = 4 +end + +@for_petsc function MatFactorGetError(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFactorGetError, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatFactorError}), + arg1, + arg2, + ) +end + +@for_petsc function MatFactorClearError(::$UnionPetscLib, arg1) + @chk ccall( + (:MatFactorClearError, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatFactorGetErrorZeroPivot( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatFactorGetErrorZeroPivot, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscReal}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetInertia(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatGetInertia, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSolve, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatForwardSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatForwardSolve, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatBackwardSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatBackwardSolve, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSolveAdd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatSolveAdd, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSolveTranspose(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSolveTranspose, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSolveTransposeAdd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatSolveTransposeAdd, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatSetUnfactored(::$UnionPetscLib, arg1) + @chk ccall( + (:MatSetUnfactored, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@enum MatFactorSchurStatus::UInt32 begin + MAT_FACTOR_SCHUR_UNFACTORED = 0 + MAT_FACTOR_SCHUR_FACTORED = 1 + MAT_FACTOR_SCHUR_INVERTED = 2 +end + +@for_petsc function MatFactorSetSchurIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFactorSetSchurIS, $petsc_library), + PetscErrorCode, + (Mat, IS), + arg1, + arg2, + ) +end + +@for_petsc function MatFactorGetSchurComplement( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatFactorGetSchurComplement, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}, Ptr{MatFactorSchurStatus}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFactorRestoreSchurComplement( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatFactorRestoreSchurComplement, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}, MatFactorSchurStatus), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFactorInvertSchurComplement(::$UnionPetscLib, arg1) + @chk ccall( + (:MatFactorInvertSchurComplement, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatFactorCreateSchurComplement( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatFactorCreateSchurComplement, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}, Ptr{MatFactorSchurStatus}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFactorSolveSchurComplement( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatFactorSolveSchurComplement, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFactorSolveSchurComplementTranspose( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatFactorSolveSchurComplementTranspose, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFactorFactorizeSchurComplement(::$UnionPetscLib, arg1) + @chk ccall( + (:MatFactorFactorizeSchurComplement, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@enum MatSORType::UInt32 begin + SOR_FORWARD_SWEEP = 1 + SOR_BACKWARD_SWEEP = 2 + SOR_SYMMETRIC_SWEEP = 3 + SOR_LOCAL_FORWARD_SWEEP = 4 + SOR_LOCAL_BACKWARD_SWEEP = 8 + SOR_LOCAL_SYMMETRIC_SWEEP = 12 + SOR_ZERO_INITIAL_GUESS = 16 + SOR_EISENSTAT = 32 + SOR_APPLY_UPPER = 64 + SOR_APPLY_LOWER = 128 +end + +@for_petsc function MatSOR( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:MatSOR, $petsc_library), + PetscErrorCode, + ( + Mat, + Vec, + $PetscReal, + MatSORType, + $PetscReal, + $PetscInt, + $PetscInt, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +mutable struct _p_MatColoring end + +const MatColoring = Ptr{_p_MatColoring} + +const MatColoringType = Ptr{Cchar} + +@enum MatColoringWeightType::UInt32 begin + MAT_COLORING_WEIGHT_RANDOM = 0 + MAT_COLORING_WEIGHT_LEXICAL = 1 + MAT_COLORING_WEIGHT_LF = 2 + MAT_COLORING_WEIGHT_SL = 3 +end + +@for_petsc function MatColoringCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringCreate, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatColoring}), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringGetDegrees(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatColoringGetDegrees, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatColoringDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:MatColoringDestroy, $petsc_library), + PetscErrorCode, + (Ptr{MatColoring},), + arg1, + ) +end + +@for_petsc function MatColoringView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringView, $petsc_library), + PetscErrorCode, + (MatColoring, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringSetType, $petsc_library), + PetscErrorCode, + (MatColoring, MatColoringType), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:MatColoringSetFromOptions, $petsc_library), + PetscErrorCode, + (MatColoring,), + arg1, + ) +end + +@for_petsc function MatColoringSetDistance(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringSetDistance, $petsc_library), + PetscErrorCode, + (MatColoring, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringGetDistance(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringGetDistance, $petsc_library), + PetscErrorCode, + (MatColoring, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringSetMaxColors(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringSetMaxColors, $petsc_library), + PetscErrorCode, + (MatColoring, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringGetMaxColors(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringGetMaxColors, $petsc_library), + PetscErrorCode, + (MatColoring, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringApply(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringApply, $petsc_library), + PetscErrorCode, + (MatColoring, Ptr{ISColoring}), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringPatch( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatColoringPatch, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{ISColoringValue}, Ptr{ISColoring}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatColoringSetWeightType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringSetWeightType, $petsc_library), + PetscErrorCode, + (MatColoring, MatColoringWeightType), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringSetWeights(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatColoringSetWeights, $petsc_library), + PetscErrorCode, + (MatColoring, Ptr{$PetscReal}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatColoringCreateWeights( + ::$UnionPetscLib, + arg1, + arg2, + lperm, +) + @chk ccall( + (:MatColoringCreateWeights, $petsc_library), + PetscErrorCode, + (MatColoring, Ptr{Ptr{$PetscReal}}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + lperm, + ) +end + +@for_petsc function MatColoringTest(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatColoringTest, $petsc_library), + PetscErrorCode, + (MatColoring, ISColoring), + arg1, + arg2, + ) +end + +@for_petsc function MatColoringTestValid( + ::$UnionPetscLib, + matcoloring, + iscoloring, +) + @chk ccall( + (:MatColoringTestValid, $petsc_library), + PetscErrorCode, + (MatColoring, ISColoring), + matcoloring, + iscoloring, + ) +end + +@for_petsc function MatISColoringTest(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatISColoringTest, $petsc_library), + PetscErrorCode, + (Mat, ISColoring), + arg1, + arg2, + ) +end + +mutable struct _p_MatFDColoring end + +const MatFDColoring = Ptr{_p_MatFDColoring} + +@for_petsc function MatFDColoringCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatFDColoringCreate, $petsc_library), + PetscErrorCode, + (Mat, ISColoring, Ptr{MatFDColoring}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFDColoringDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:MatFDColoringDestroy, $petsc_library), + PetscErrorCode, + (Ptr{MatFDColoring},), + arg1, + ) +end + +@for_petsc function MatFDColoringView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFDColoringView, $petsc_library), + PetscErrorCode, + (MatFDColoring, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function MatFDColoringSetFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatFDColoringSetFunction, $petsc_library), + PetscErrorCode, + (MatFDColoring, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFDColoringGetFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatFDColoringGetFunction, $petsc_library), + PetscErrorCode, + (MatFDColoring, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFDColoringSetParameters( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatFDColoringSetParameters, $petsc_library), + PetscErrorCode, + (MatFDColoring, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFDColoringSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:MatFDColoringSetFromOptions, $petsc_library), + PetscErrorCode, + (MatFDColoring,), + arg1, + ) +end + +@for_petsc function MatFDColoringApply(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatFDColoringApply, $petsc_library), + PetscErrorCode, + (Mat, MatFDColoring, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatFDColoringSetF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFDColoringSetF, $petsc_library), + PetscErrorCode, + (MatFDColoring, Vec), + arg1, + arg2, + ) +end + +@for_petsc function MatFDColoringGetPerturbedColumns( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatFDColoringGetPerturbedColumns, $petsc_library), + PetscErrorCode, + (MatFDColoring, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFDColoringSetUp(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatFDColoringSetUp, $petsc_library), + PetscErrorCode, + (Mat, ISColoring, MatFDColoring), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFDColoringSetBlockSize( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatFDColoringSetBlockSize, $petsc_library), + PetscErrorCode, + (MatFDColoring, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatFDColoringSetValues(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatFDColoringSetValues, $petsc_library), + PetscErrorCode, + (Mat, MatFDColoring, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +mutable struct _p_MatTransposeColoring end + +const MatTransposeColoring = Ptr{_p_MatTransposeColoring} + +@for_petsc function MatTransposeColoringCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatTransposeColoringCreate, $petsc_library), + PetscErrorCode, + (Mat, ISColoring, Ptr{MatTransposeColoring}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatTransColoringApplySpToDen( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatTransColoringApplySpToDen, $petsc_library), + PetscErrorCode, + (MatTransposeColoring, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatTransColoringApplyDenToSp( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatTransColoringApplyDenToSp, $petsc_library), + PetscErrorCode, + (MatTransposeColoring, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatTransposeColoringDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:MatTransposeColoringDestroy, $petsc_library), + PetscErrorCode, + (Ptr{MatTransposeColoring},), + arg1, + ) +end + +mutable struct _p_MatPartitioning end + +const MatPartitioning = Ptr{_p_MatPartitioning} + +const MatPartitioningType = Ptr{Cchar} + +@for_petsc function MatPartitioningCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{MatPartitioning}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningSetType, $petsc_library), + PetscErrorCode, + (MatPartitioning, MatPartitioningType), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningSetNParts(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningSetNParts, $petsc_library), + PetscErrorCode, + (MatPartitioning, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningSetAdjacency(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningSetAdjacency, $petsc_library), + PetscErrorCode, + (MatPartitioning, Mat), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningSetVertexWeights( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningSetVertexWeights, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningSetPartitionWeights( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningSetPartitionWeights, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningSetUseEdgeWeights( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningSetUseEdgeWeights, $petsc_library), + PetscErrorCode, + (MatPartitioning, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningGetUseEdgeWeights( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningGetUseEdgeWeights, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningApply(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningApply, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningImprove(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningImprove, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningViewImbalance(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningViewImbalance, $petsc_library), + PetscErrorCode, + (MatPartitioning, IS), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningApplyND(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningApplyND, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:MatPartitioningDestroy, $petsc_library), + PetscErrorCode, + (Ptr{MatPartitioning},), + arg1, + ) +end + +@for_petsc function MatPartitioningRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningView, $petsc_library), + PetscErrorCode, + (MatPartitioning, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatPartitioningViewFromOptions, $petsc_library), + PetscErrorCode, + (MatPartitioning, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatPartitioningSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:MatPartitioningSetFromOptions, $petsc_library), + PetscErrorCode, + (MatPartitioning,), + arg1, + ) +end + +@for_petsc function MatPartitioningGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningGetType, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{MatPartitioningType}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningParmetisSetRepartition( + ::$UnionPetscLib, + part, +) + @chk ccall( + (:MatPartitioningParmetisSetRepartition, $petsc_library), + PetscErrorCode, + (MatPartitioning,), + part, + ) +end + +@for_petsc function MatPartitioningParmetisSetCoarseSequential( + ::$UnionPetscLib, + arg1, +) + @chk ccall( + (:MatPartitioningParmetisSetCoarseSequential, $petsc_library), + PetscErrorCode, + (MatPartitioning,), + arg1, + ) +end + +@for_petsc function MatPartitioningParmetisGetEdgeCut( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningParmetisGetEdgeCut, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@enum MPChacoGlobalType::UInt32 begin + MP_CHACO_MULTILEVEL = 1 + MP_CHACO_SPECTRAL = 2 + MP_CHACO_LINEAR = 4 + MP_CHACO_RANDOM = 5 + MP_CHACO_SCATTERED = 6 +end + +@enum MPChacoLocalType::UInt32 begin + MP_CHACO_KERNIGHAN = 1 + MP_CHACO_NONE = 2 +end + +@enum MPChacoEigenType::UInt32 begin + MP_CHACO_LANCZOS = 0 + MP_CHACO_RQI = 1 +end + +@for_petsc function MatPartitioningChacoSetGlobal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningChacoSetGlobal, $petsc_library), + PetscErrorCode, + (MatPartitioning, MPChacoGlobalType), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoGetGlobal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningChacoGetGlobal, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{MPChacoGlobalType}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoSetLocal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningChacoSetLocal, $petsc_library), + PetscErrorCode, + (MatPartitioning, MPChacoLocalType), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoGetLocal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningChacoGetLocal, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{MPChacoLocalType}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoSetCoarseLevel( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningChacoSetCoarseLevel, $petsc_library), + PetscErrorCode, + (MatPartitioning, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoSetEigenSolver( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningChacoSetEigenSolver, $petsc_library), + PetscErrorCode, + (MatPartitioning, MPChacoEigenType), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoGetEigenSolver( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningChacoGetEigenSolver, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{MPChacoEigenType}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoSetEigenTol( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningChacoSetEigenTol, $petsc_library), + PetscErrorCode, + (MatPartitioning, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoGetEigenTol( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningChacoGetEigenTol, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoSetEigenNumber( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningChacoSetEigenNumber, $petsc_library), + PetscErrorCode, + (MatPartitioning, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningChacoGetEigenNumber( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningChacoGetEigenNumber, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningPartySetGlobal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningPartySetGlobal, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningPartySetLocal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningPartySetLocal, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningPartySetCoarseLevel( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningPartySetCoarseLevel, $petsc_library), + PetscErrorCode, + (MatPartitioning, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningPartySetBipart(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatPartitioningPartySetBipart, $petsc_library), + PetscErrorCode, + (MatPartitioning, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningPartySetMatchOptimization( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningPartySetMatchOptimization, $petsc_library), + PetscErrorCode, + (MatPartitioning, PetscBool), + arg1, + arg2, + ) +end + +@enum MPPTScotchStrategyType::UInt32 begin + MP_PTSCOTCH_DEFAULT = 0 + MP_PTSCOTCH_QUALITY = 1 + MP_PTSCOTCH_SPEED = 2 + MP_PTSCOTCH_BALANCE = 3 + MP_PTSCOTCH_SAFETY = 4 + MP_PTSCOTCH_SCALABILITY = 5 +end + +@for_petsc function MatPartitioningPTScotchSetImbalance( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningPTScotchSetImbalance, $petsc_library), + PetscErrorCode, + (MatPartitioning, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningPTScotchGetImbalance( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningPTScotchGetImbalance, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningPTScotchSetStrategy( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningPTScotchSetStrategy, $petsc_library), + PetscErrorCode, + (MatPartitioning, MPPTScotchStrategyType), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningPTScotchGetStrategy( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningPTScotchGetStrategy, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{MPPTScotchStrategyType}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningHierarchicalGetFineparts( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningHierarchicalGetFineparts, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningHierarchicalGetCoarseparts( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningHierarchicalGetCoarseparts, $petsc_library), + PetscErrorCode, + (MatPartitioning, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningHierarchicalSetNcoarseparts( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningHierarchicalSetNcoarseparts, $petsc_library), + PetscErrorCode, + (MatPartitioning, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatPartitioningHierarchicalSetNfineparts( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatPartitioningHierarchicalSetNfineparts, $petsc_library), + PetscErrorCode, + (MatPartitioning, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatMeshToVertexGraph(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMeshToVertexGraph, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMeshToCellGraph(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMeshToCellGraph, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@enum MatOperation::UInt32 begin + MATOP_SET_VALUES = 0 + MATOP_GET_ROW = 1 + MATOP_RESTORE_ROW = 2 + MATOP_MULT = 3 + MATOP_MULT_ADD = 4 + MATOP_MULT_TRANSPOSE = 5 + MATOP_MULT_TRANSPOSE_ADD = 6 + MATOP_SOLVE = 7 + MATOP_SOLVE_ADD = 8 + MATOP_SOLVE_TRANSPOSE = 9 + MATOP_SOLVE_TRANSPOSE_ADD = 10 + MATOP_LUFACTOR = 11 + MATOP_CHOLESKYFACTOR = 12 + MATOP_SOR = 13 + MATOP_TRANSPOSE = 14 + MATOP_GETINFO = 15 + MATOP_EQUAL = 16 + MATOP_GET_DIAGONAL = 17 + MATOP_DIAGONAL_SCALE = 18 + MATOP_NORM = 19 + MATOP_ASSEMBLY_BEGIN = 20 + MATOP_ASSEMBLY_END = 21 + MATOP_SET_OPTION = 22 + MATOP_ZERO_ENTRIES = 23 + MATOP_ZERO_ROWS = 24 + MATOP_LUFACTOR_SYMBOLIC = 25 + MATOP_LUFACTOR_NUMERIC = 26 + MATOP_CHOLESKY_FACTOR_SYMBOLIC = 27 + MATOP_CHOLESKY_FACTOR_NUMERIC = 28 + MATOP_SETUP_PREALLOCATION = 29 + MATOP_ILUFACTOR_SYMBOLIC = 30 + MATOP_ICCFACTOR_SYMBOLIC = 31 + MATOP_GET_DIAGONAL_BLOCK = 32 + MATOP_FREE_INTER_STRUCT = 33 + MATOP_DUPLICATE = 34 + MATOP_FORWARD_SOLVE = 35 + MATOP_BACKWARD_SOLVE = 36 + MATOP_ILUFACTOR = 37 + MATOP_ICCFACTOR = 38 + MATOP_AXPY = 39 + MATOP_CREATE_SUBMATRICES = 40 + MATOP_INCREASE_OVERLAP = 41 + MATOP_GET_VALUES = 42 + MATOP_COPY = 43 + MATOP_GET_ROW_MAX = 44 + MATOP_SCALE = 45 + MATOP_SHIFT = 46 + MATOP_DIAGONAL_SET = 47 + MATOP_ZERO_ROWS_COLUMNS = 48 + MATOP_SET_RANDOM = 49 + MATOP_GET_ROW_IJ = 50 + MATOP_RESTORE_ROW_IJ = 51 + MATOP_GET_COLUMN_IJ = 52 + MATOP_RESTORE_COLUMN_IJ = 53 + MATOP_FDCOLORING_CREATE = 54 + MATOP_COLORING_PATCH = 55 + MATOP_SET_UNFACTORED = 56 + MATOP_PERMUTE = 57 + MATOP_SET_VALUES_BLOCKED = 58 + MATOP_CREATE_SUBMATRIX = 59 + MATOP_DESTROY = 60 + MATOP_VIEW = 61 + MATOP_CONVERT_FROM = 62 + MATOP_MATMAT_MULT = 63 + MATOP_MATMAT_MULT_SYMBOLIC = 64 + MATOP_MATMAT_MULT_NUMERIC = 65 + MATOP_SET_LOCAL_TO_GLOBAL_MAP = 66 + MATOP_SET_VALUES_LOCAL = 67 + MATOP_ZERO_ROWS_LOCAL = 68 + MATOP_GET_ROW_MAX_ABS = 69 + MATOP_GET_ROW_MIN_ABS = 70 + MATOP_CONVERT = 71 + MATOP_SET_COLORING = 72 + MATOP_SET_VALUES_ADIFOR = 74 + MATOP_FD_COLORING_APPLY = 75 + MATOP_SET_FROM_OPTIONS = 76 + MATOP_MULT_CONSTRAINED = 77 + MATOP_MULT_TRANSPOSE_CONSTRAIN = 78 + MATOP_FIND_ZERO_DIAGONALS = 79 + MATOP_MULT_MULTIPLE = 80 + MATOP_SOLVE_MULTIPLE = 81 + MATOP_GET_INERTIA = 82 + MATOP_LOAD = 83 + MATOP_IS_SYMMETRIC = 84 + MATOP_IS_HERMITIAN = 85 + MATOP_IS_STRUCTURALLY_SYMMETRIC = 86 + MATOP_SET_VALUES_BLOCKEDLOCAL = 87 + MATOP_CREATE_VECS = 88 + MATOP_MAT_MULT = 89 + MATOP_MAT_MULT_SYMBOLIC = 90 + MATOP_MAT_MULT_NUMERIC = 91 + MATOP_PTAP = 92 + MATOP_PTAP_SYMBOLIC = 93 + MATOP_PTAP_NUMERIC = 94 + MATOP_MAT_TRANSPOSE_MULT = 95 + MATOP_MAT_TRANSPOSE_MULT_SYMBO = 96 + MATOP_MAT_TRANSPOSE_MULT_NUMER = 97 + MATOP_PRODUCTSETFROMOPTIONS = 99 + MATOP_PRODUCTSYMBOLIC = 100 + MATOP_PRODUCTNUMERIC = 101 + MATOP_CONJUGATE = 102 + MATOP_SET_VALUES_ROW = 104 + MATOP_REAL_PART = 105 + MATOP_IMAGINARY_PART = 106 + MATOP_GET_ROW_UPPER_TRIANGULAR = 107 + MATOP_RESTORE_ROW_UPPER_TRIANG = 108 + MATOP_MAT_SOLVE = 109 + MATOP_MAT_SOLVE_TRANSPOSE = 110 + MATOP_GET_ROW_MIN = 111 + MATOP_GET_COLUMN_VECTOR = 112 + MATOP_MISSING_DIAGONAL = 113 + MATOP_GET_SEQ_NONZERO_STRUCTUR = 114 + MATOP_CREATE = 115 + MATOP_GET_GHOSTS = 116 + MATOP_GET_LOCAL_SUB_MATRIX = 117 + MATOP_RESTORE_LOCALSUB_MATRIX = 118 + MATOP_MULT_DIAGONAL_BLOCK = 119 + MATOP_HERMITIAN_TRANSPOSE = 120 + MATOP_MULT_HERMITIAN_TRANSPOSE = 121 + MATOP_MULT_HERMITIAN_TRANS_ADD = 122 + MATOP_GET_MULTI_PROC_BLOCK = 123 + MATOP_FIND_NONZERO_ROWS = 124 + MATOP_GET_COLUMN_NORMS = 125 + MATOP_INVERT_BLOCK_DIAGONAL = 126 + MATOP_CREATE_SUB_MATRICES_MPI = 128 + MATOP_SET_VALUES_BATCH = 129 + MATOP_TRANSPOSE_MAT_MULT = 130 + MATOP_TRANSPOSE_MAT_MULT_SYMBO = 131 + MATOP_TRANSPOSE_MAT_MULT_NUMER = 132 + MATOP_TRANSPOSE_COLORING_CREAT = 133 + MATOP_TRANS_COLORING_APPLY_SPT = 134 + MATOP_TRANS_COLORING_APPLY_DEN = 135 + MATOP_RART = 136 + MATOP_RART_SYMBOLIC = 137 + MATOP_RART_NUMERIC = 138 + MATOP_SET_BLOCK_SIZES = 139 + MATOP_AYPX = 140 + MATOP_RESIDUAL = 141 + MATOP_FDCOLORING_SETUP = 142 + MATOP_MPICONCATENATESEQ = 144 + MATOP_DESTROYSUBMATRICES = 145 + MATOP_TRANSPOSE_SOLVE = 146 + MATOP_GET_VALUES_LOCAL = 147 +end + +@for_petsc function MatSetOperation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatSetOperation, $petsc_library), + PetscErrorCode, + (Mat, MatOperation, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatGetOperation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatGetOperation, $petsc_library), + PetscErrorCode, + (Mat, MatOperation, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatHasOperation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatHasOperation, $petsc_library), + PetscErrorCode, + (Mat, MatOperation, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatHasCongruentLayouts(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatHasCongruentLayouts, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function MatFreeIntermediateDataStructures(::$UnionPetscLib, A) + @chk ccall( + (:MatFreeIntermediateDataStructures, $petsc_library), + PetscErrorCode, + (Mat,), + A, + ) +end + +@for_petsc function MatShellSetOperation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatShellSetOperation, $petsc_library), + PetscErrorCode, + (Mat, MatOperation, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatShellGetOperation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatShellGetOperation, $petsc_library), + PetscErrorCode, + (Mat, MatOperation, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatShellSetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatShellSetContext, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatShellSetVecType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatShellSetVecType, $petsc_library), + PetscErrorCode, + (Mat, VecType), + arg1, + arg2, + ) +end + +@for_petsc function MatShellTestMult( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatShellTestMult, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cvoid}, Vec, Ptr{Cvoid}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatShellTestMultTranspose( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatShellTestMultTranspose, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cvoid}, Vec, Ptr{Cvoid}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatShellSetManageScalingShifts(::$UnionPetscLib, arg1) + @chk ccall( + (:MatShellSetManageScalingShifts, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatShellSetMatProductOperation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatShellSetMatProductOperation, $petsc_library), + PetscErrorCode, + ( + Mat, + MatProductType, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + MatType, + MatType, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatIsShell(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatIsShell, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function MatMPIBAIJSetHashTableFactor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMPIBAIJSetHashTableFactor, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatISSetLocalMatType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatISSetLocalMatType, $petsc_library), + PetscErrorCode, + (Mat, MatType), + arg1, + arg2, + ) +end + +@for_petsc function MatISSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatISSetPreallocation, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatISStoreL2L(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatISStoreL2L, $petsc_library), + PetscErrorCode, + (Mat, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function MatISFixLocalEmpty(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatISFixLocalEmpty, $petsc_library), + PetscErrorCode, + (Mat, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function MatISGetLocalMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatISGetLocalMat, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatISRestoreLocalMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatISRestoreLocalMat, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatISSetLocalMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatISSetLocalMat, $petsc_library), + PetscErrorCode, + (Mat, Mat), + arg1, + arg2, + ) +end + +@for_petsc function MatISGetMPIXAIJ(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatISGetMPIXAIJ, $petsc_library), + PetscErrorCode, + (Mat, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +mutable struct _p_MatNullSpace end + +const MatNullSpace = Ptr{_p_MatNullSpace} + +@for_petsc function MatNullSpaceCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatNullSpaceCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, PetscBool, $PetscInt, Ptr{Vec}, Ptr{MatNullSpace}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function MatNullSpaceSetFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatNullSpaceSetFunction, $petsc_library), + PetscErrorCode, + (MatNullSpace, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatNullSpaceDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:MatNullSpaceDestroy, $petsc_library), + PetscErrorCode, + (Ptr{MatNullSpace},), + arg1, + ) +end + +@for_petsc function MatNullSpaceRemove(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatNullSpaceRemove, $petsc_library), + PetscErrorCode, + (MatNullSpace, Vec), + arg1, + arg2, + ) +end + +@for_petsc function MatGetNullSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetNullSpace, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatNullSpace}), + arg1, + arg2, + ) +end + +@for_petsc function MatGetTransposeNullSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetTransposeNullSpace, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatNullSpace}), + arg1, + arg2, + ) +end + +@for_petsc function MatSetTransposeNullSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetTransposeNullSpace, $petsc_library), + PetscErrorCode, + (Mat, MatNullSpace), + arg1, + arg2, + ) +end + +@for_petsc function MatSetNullSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetNullSpace, $petsc_library), + PetscErrorCode, + (Mat, MatNullSpace), + arg1, + arg2, + ) +end + +@for_petsc function MatSetNearNullSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetNearNullSpace, $petsc_library), + PetscErrorCode, + (Mat, MatNullSpace), + arg1, + arg2, + ) +end + +@for_petsc function MatGetNearNullSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetNearNullSpace, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatNullSpace}), + arg1, + arg2, + ) +end + +@for_petsc function MatNullSpaceTest(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatNullSpaceTest, $petsc_library), + PetscErrorCode, + (MatNullSpace, Mat, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatNullSpaceView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatNullSpaceView, $petsc_library), + PetscErrorCode, + (MatNullSpace, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function MatNullSpaceGetVecs( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatNullSpaceGetVecs, $petsc_library), + PetscErrorCode, + (MatNullSpace, Ptr{PetscBool}, Ptr{$PetscInt}, Ptr{Ptr{Vec}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatNullSpaceCreateRigidBody(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatNullSpaceCreateRigidBody, $petsc_library), + PetscErrorCode, + (Vec, Ptr{MatNullSpace}), + arg1, + arg2, + ) +end + +@for_petsc function MatReorderingSeqSBAIJ(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatReorderingSeqSBAIJ, $petsc_library), + PetscErrorCode, + (Mat, IS), + arg1, + arg2, + ) +end + +@for_petsc function MatMPISBAIJSetHashTableFactor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMPISBAIJSetHashTableFactor, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatSeqSBAIJSetColumnIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSeqSBAIJSetColumnIndices, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateMAIJ(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatCreateMAIJ, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMAIJRedimension(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMAIJRedimension, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMAIJGetAIJ(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMAIJGetAIJ, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatComputeOperator(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatComputeOperator, $petsc_library), + PetscErrorCode, + (Mat, MatType, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatComputeOperatorTranspose( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatComputeOperatorTranspose, $petsc_library), + PetscErrorCode, + (Mat, MatType, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatComputeExplicitOperator(::$UnionPetscLib, A, B) + @chk ccall( + (:MatComputeExplicitOperator, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + A, + B, + ) +end + +@for_petsc function MatComputeExplicitOperatorTranspose(::$UnionPetscLib, A, B) + @chk ccall( + (:MatComputeExplicitOperatorTranspose, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + A, + B, + ) +end + +@for_petsc function MatCreateKAIJ( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatCreateKAIJ, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + $PetscInt, + Ptr{$PetscScalar}, + Ptr{$PetscScalar}, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatKAIJGetAIJ(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatKAIJGetAIJ, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatKAIJGetS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatKAIJGetS, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatKAIJGetSRead(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatKAIJGetSRead, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatKAIJRestoreS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatKAIJRestoreS, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatKAIJRestoreSRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatKAIJRestoreSRead, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatKAIJGetT(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatKAIJGetT, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatKAIJGetTRead(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatKAIJGetTRead, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatKAIJRestoreT(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatKAIJRestoreT, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatKAIJRestoreTRead(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatKAIJRestoreTRead, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + ) +end + +@for_petsc function MatKAIJSetAIJ(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatKAIJSetAIJ, $petsc_library), + PetscErrorCode, + (Mat, Mat), + arg1, + arg2, + ) +end + +@for_petsc function MatKAIJSetS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatKAIJSetS, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatKAIJSetT(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatKAIJSetT, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatKAIJGetScaledIdentity(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatKAIJGetScaledIdentity, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function MatDiagonalScaleLocal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatDiagonalScaleLocal, $petsc_library), + PetscErrorCode, + (Mat, Vec), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateMFFD( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatCreateMFFD, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatMFFDSetBase(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMFFDSetBase, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMFFDSetFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMFFDSetFunction, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMFFDSetFunctioni(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDSetFunctioni, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDSetFunctioniBase(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDSetFunctioniBase, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDSetHHistory(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMFFDSetHHistory, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscScalar}, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatMFFDResetHHistory(::$UnionPetscLib, arg1) + @chk ccall( + (:MatMFFDResetHHistory, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatMFFDSetFunctionError(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDSetFunctionError, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDSetPeriod(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDSetPeriod, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDGetH(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDGetH, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDCheckPositivity( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatMFFDCheckPositivity, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, Vec, Vec, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatMFFDSetCheckh(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatMFFDSetCheckh, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +mutable struct _p_MatMFFD end + +const MatMFFD = Ptr{_p_MatMFFD} + +const MatMFFDType = Ptr{Cchar} + +@for_petsc function MatMFFDSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDSetType, $petsc_library), + PetscErrorCode, + (Mat, MatMFFDType), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDDSSetUmin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDDSSetUmin, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDWPSetComputeNormU(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatMFFDWPSetComputeNormU, $petsc_library), + PetscErrorCode, + (Mat, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function MatFDColoringSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFDColoringSetType, $petsc_library), + PetscErrorCode, + (MatFDColoring, MatMFFDType), + arg1, + arg2, + ) +end + +@for_petsc function PetscViewerMathematicaPutMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscViewerMathematicaPutMatrix, $petsc_library), + PetscErrorCode, + (PetscViewer, $PetscInt, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscViewerMathematicaPutCSRMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscViewerMathematicaPutCSRMatrix, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatBindToCPU(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatBindToCPU, $petsc_library), + PetscErrorCode, + (Mat, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function MatPinToCPU(::$UnionPetscLib, A, flg) + @chk ccall( + (:MatPinToCPU, $petsc_library), + PetscErrorCode, + (Mat, PetscBool), + A, + flg, + ) +end + +mutable struct _p_SplitCSRMat end + +const PetscSplitCSRDataStructure = _p_SplitCSRMat + +@for_petsc function MatCreateNest( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateNest, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{IS}, $PetscInt, Ptr{IS}, Ptr{Mat}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatNestGetSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatNestGetSize, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatNestGetISs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatNestGetISs, $petsc_library), + PetscErrorCode, + (Mat, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatNestGetLocalISs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatNestGetLocalISs, $petsc_library), + PetscErrorCode, + (Mat, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatNestGetSubMats(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatNestGetSubMats, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{Ptr{Mat}}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatNestGetSubMat(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatNestGetSubMat, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatNestSetVecType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatNestSetVecType, $petsc_library), + PetscErrorCode, + (Mat, VecType), + arg1, + arg2, + ) +end + +@for_petsc function MatNestSetSubMats( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatNestSetSubMats, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{IS}, $PetscInt, Ptr{IS}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatNestSetSubMat(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatNestSetSubMat, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, $PetscInt, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatChop(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatChop, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatComputeBandwidth(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatComputeBandwidth, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSubdomainsCreateCoalesce( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatSubdomainsCreateCoalesce, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatPreallocatorPreallocate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatPreallocatorPreallocate, $petsc_library), + PetscErrorCode, + (Mat, PetscBool, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatHeaderMerge(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatHeaderMerge, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatHeaderReplace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatHeaderReplace, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +mutable struct _p_DM end + +const DM = Ptr{_p_DM} + +@enum DMBoundaryType::UInt32 begin + DM_BOUNDARY_NONE = 0 + DM_BOUNDARY_GHOSTED = 1 + DM_BOUNDARY_MIRROR = 2 + DM_BOUNDARY_PERIODIC = 3 + DM_BOUNDARY_TWIST = 4 +end + +@enum DMBoundaryConditionType::UInt32 begin + DM_BC_ESSENTIAL = 1 + DM_BC_ESSENTIAL_FIELD = 5 + DM_BC_NATURAL = 2 + DM_BC_NATURAL_FIELD = 6 + DM_BC_ESSENTIAL_BD_FIELD = 9 + DM_BC_NATURAL_RIEMANN = 10 +end + +@enum DMPointLocationType::UInt32 begin + DM_POINTLOCATION_NONE = 0 + DM_POINTLOCATION_NEAREST = 1 + DM_POINTLOCATION_REMOVE = 2 +end + +@enum DMAdaptationStrategy::UInt32 begin + DM_ADAPTATION_INITIAL = 0 + DM_ADAPTATION_SEQUENTIAL = 1 + DM_ADAPTATION_MULTILEVEL = 2 +end + +@enum DMAdaptationCriterion::UInt32 begin + DM_ADAPTATION_NONE = 0 + DM_ADAPTATION_REFINE = 1 + DM_ADAPTATION_LABEL = 2 + DM_ADAPTATION_METRIC = 3 +end + +@enum DMAdaptFlag::Int32 begin + DM_ADAPT_DETERMINE = -1 + DM_ADAPT_KEEP = 0 + DM_ADAPT_REFINE = 1 + DM_ADAPT_COARSEN = 2 + DM_ADAPT_COARSEN_LAST = 3 + DM_ADAPT_RESERVED_COUNT = 4 +end + +@enum DMDirection::UInt32 begin + DM_X = 0 + DM_Y = 1 + DM_Z = 2 +end + +@enum DMEnclosureType::UInt32 begin + DM_ENC_EQUALITY = 0 + DM_ENC_SUPERMESH = 1 + DM_ENC_SUBMESH = 2 + DM_ENC_NONE = 3 + DM_ENC_UNKNOWN = 4 +end + +@enum DMPolytopeType::UInt32 begin + DM_POLYTOPE_POINT = 0 + DM_POLYTOPE_SEGMENT = 1 + DM_POLYTOPE_POINT_PRISM_TENSOR = 2 + DM_POLYTOPE_TRIANGLE = 3 + DM_POLYTOPE_QUADRILATERAL = 4 + DM_POLYTOPE_SEG_PRISM_TENSOR = 5 + DM_POLYTOPE_TETRAHEDRON = 6 + DM_POLYTOPE_HEXAHEDRON = 7 + DM_POLYTOPE_TRI_PRISM = 8 + DM_POLYTOPE_TRI_PRISM_TENSOR = 9 + DM_POLYTOPE_QUAD_PRISM_TENSOR = 10 + DM_POLYTOPE_PYRAMID = 11 + DM_POLYTOPE_FV_GHOST = 12 + DM_POLYTOPE_INTERIOR_GHOST = 13 + DM_POLYTOPE_UNKNOWN = 14 + DM_NUM_POLYTOPES = 15 +end + +@enum PetscUnit::UInt32 begin + PETSC_UNIT_LENGTH = 0 + PETSC_UNIT_MASS = 1 + PETSC_UNIT_TIME = 2 + PETSC_UNIT_CURRENT = 3 + PETSC_UNIT_TEMPERATURE = 4 + PETSC_UNIT_AMOUNT = 5 + PETSC_UNIT_LUMINOSITY = 6 + NUM_PETSC_UNITS = 7 +end + +mutable struct _p_DMField end + +const DMField = Ptr{_p_DMField} + +mutable struct _p_UniversalLabel end + +const DMUniversalLabel = Ptr{_p_UniversalLabel} + +mutable struct _p_PetscSpace end + +const PetscSpace = Ptr{_p_PetscSpace} + +@enum PetscSpacePolynomialType::UInt32 begin + PETSCSPACE_POLYNOMIALTYPE_P = 0 + PETSCSPACE_POLYNOMIALTYPE_PMINUS_HDIV = 1 + PETSCSPACE_POLYNOMIALTYPE_PMINUS_HCURL = 2 +end + +mutable struct _p_PetscDualSpace end + +const PetscDualSpace = Ptr{_p_PetscDualSpace} + +@enum PetscDualSpaceReferenceCell::UInt32 begin + PETSCDUALSPACE_REFCELL_SIMPLEX = 0 + PETSCDUALSPACE_REFCELL_TENSOR = 1 +end + +@enum PetscDualSpaceTransformType::UInt32 begin + IDENTITY_TRANSFORM = 0 + COVARIANT_PIOLA_TRANSFORM = 1 + CONTRAVARIANT_PIOLA_TRANSFORM = 2 +end + +mutable struct _p_PetscFE end + +const PetscFE = Ptr{_p_PetscFE} + +@enum PetscFEJacobianType::UInt32 begin + PETSCFE_JACOBIAN = 0 + PETSCFE_JACOBIAN_PRE = 1 + PETSCFE_JACOBIAN_DYN = 2 +end + +mutable struct _p_DMLabel end + +const DMLabel = Ptr{_p_DMLabel} + +@for_petsc function DMLabelCreate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{DMLabel}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLabelView, $petsc_library), + PetscErrorCode, + (DMLabel, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function DMLabelReset(::$UnionPetscLib, arg1) + @chk ccall( + (:DMLabelReset, $petsc_library), + PetscErrorCode, + (DMLabel,), + arg1, + ) +end + +@for_petsc function DMLabelDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:DMLabelDestroy, $petsc_library), + PetscErrorCode, + (Ptr{DMLabel},), + arg1, + ) +end + +@for_petsc function DMLabelGetDefaultValue(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLabelGetDefaultValue, $petsc_library), + PetscErrorCode, + (DMLabel, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMLabelSetDefaultValue(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLabelSetDefaultValue, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMLabelDuplicate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLabelDuplicate, $petsc_library), + PetscErrorCode, + (DMLabel, Ptr{DMLabel}), + arg1, + arg2, + ) +end + +@for_petsc function DMLabelGetValue(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelGetValue, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelSetValue(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelSetValue, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelClearValue(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelClearValue, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelAddStratum(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLabelAddStratum, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMLabelAddStrata(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelAddStrata, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelAddStrataIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLabelAddStrataIS, $petsc_library), + PetscErrorCode, + (DMLabel, IS), + arg1, + arg2, + ) +end + +@for_petsc function DMLabelInsertIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelInsertIS, $petsc_library), + PetscErrorCode, + (DMLabel, IS, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelGetNumValues(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLabelGetNumValues, $petsc_library), + PetscErrorCode, + (DMLabel, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMLabelGetStratumBounds( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLabelGetStratumBounds, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLabelGetValueIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLabelGetValueIS, $petsc_library), + PetscErrorCode, + (DMLabel, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function DMLabelStratumHasPoint( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLabelStratumHasPoint, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLabelHasStratum(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelHasStratum, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelGetStratumSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelGetStratumSize, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelGetStratumIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelGetStratumIS, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelSetStratumIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelSetStratumIS, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, IS), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelSetStratumBounds( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLabelSetStratumBounds, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLabelClearStratum(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLabelClearStratum, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMLabelComputeIndex(::$UnionPetscLib, arg1) + @chk ccall( + (:DMLabelComputeIndex, $petsc_library), + PetscErrorCode, + (DMLabel,), + arg1, + ) +end + +@for_petsc function DMLabelCreateIndex(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelCreateIndex, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelDestroyIndex(::$UnionPetscLib, arg1) + @chk ccall( + (:DMLabelDestroyIndex, $petsc_library), + PetscErrorCode, + (DMLabel,), + arg1, + ) +end + +@for_petsc function DMLabelHasValue(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelHasValue, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelHasPoint(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelHasPoint, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelGetBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelGetBounds, $petsc_library), + PetscErrorCode, + (DMLabel, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelFilter(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelFilter, $petsc_library), + PetscErrorCode, + (DMLabel, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelPermute(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelPermute, $petsc_library), + PetscErrorCode, + (DMLabel, IS, Ptr{DMLabel}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelDistribute(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelDistribute, $petsc_library), + PetscErrorCode, + (DMLabel, PetscSF, Ptr{DMLabel}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelGather(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelGather, $petsc_library), + PetscErrorCode, + (DMLabel, PetscSF, Ptr{DMLabel}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMLabelConvertToSection(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMLabelConvertToSection, $petsc_library), + PetscErrorCode, + (DMLabel, Ptr{PetscSection}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionCreateGlobalSectionLabel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscSectionCreateGlobalSectionLabel, $petsc_library), + PetscErrorCode, + ( + PetscSection, + PetscSF, + PetscBool, + DMLabel, + $PetscInt, + Ptr{PetscSection}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscSectionSymCreateLabel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSectionSymCreateLabel, $petsc_library), + PetscErrorCode, + (MPI_Comm, DMLabel, Ptr{PetscSectionSym}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSectionSymLabelSetLabel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSectionSymLabelSetLabel, $petsc_library), + PetscErrorCode, + (PetscSectionSym, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function PetscSectionSymLabelSetStratum( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscSectionSymLabelSetStratum, $petsc_library), + PetscErrorCode, + ( + PetscSectionSym, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + PetscCopyMode, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +mutable struct _p_PetscDS end + +const PetscDS = Ptr{_p_PetscDS} + +mutable struct _p_PetscWeakForm end + +const PetscWeakForm = Ptr{_p_PetscWeakForm} + +@for_petsc function DMInitializePackage(::$UnionPetscLib) + @chk ccall((:DMInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +const DMType = Ptr{Cchar} + +@for_petsc function DMCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMClone(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMClone, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetType, $petsc_library), + PetscErrorCode, + (DM, DMType), + arg1, + arg2, + ) +end + +@for_petsc function DMGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetType, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMType}), + arg1, + arg2, + ) +end + +@for_petsc function DMRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMRegisterDestroy(::$UnionPetscLib) + @chk ccall((:DMRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function DMView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMView, $petsc_library), + PetscErrorCode, + (DM, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function DMLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMLoad, $petsc_library), + PetscErrorCode, + (DM, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function DMDestroy(::$UnionPetscLib, arg1) + @chk ccall((:DMDestroy, $petsc_library), PetscErrorCode, (Ptr{DM},), arg1) +end + +@for_petsc function DMCreateGlobalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCreateGlobalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMCreateLocalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCreateLocalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetLocalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetLocalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMRestoreLocalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMRestoreLocalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetGlobalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetGlobalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMRestoreGlobalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMRestoreGlobalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMClearGlobalVectors(::$UnionPetscLib, arg1) + @chk ccall( + (:DMClearGlobalVectors, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMClearLocalVectors(::$UnionPetscLib, arg1) + @chk ccall( + (:DMClearLocalVectors, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMHasNamedGlobalVector(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMHasNamedGlobalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetNamedGlobalVector(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetNamedGlobalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMRestoreNamedGlobalVector( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMRestoreNamedGlobalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMHasNamedLocalVector(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMHasNamedLocalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetNamedLocalVector(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetNamedLocalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMRestoreNamedLocalVector( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMRestoreNamedLocalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetLocalToGlobalMapping(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetLocalToGlobalMapping, $petsc_library), + PetscErrorCode, + (DM, Ptr{ISLocalToGlobalMapping}), + arg1, + arg2, + ) +end + +@for_petsc function DMCreateFieldIS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMCreateFieldIS, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{Ptr{Ptr{Cchar}}}, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetBlockSize, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMCreateColoring(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMCreateColoring, $petsc_library), + PetscErrorCode, + (DM, ISColoringType, Ptr{ISColoring}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCreateMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCreateMatrix, $petsc_library), + PetscErrorCode, + (DM, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetMatrixPreallocateOnly(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetMatrixPreallocateOnly, $petsc_library), + PetscErrorCode, + (DM, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function DMSetMatrixStructureOnly(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetMatrixStructureOnly, $petsc_library), + PetscErrorCode, + (DM, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function DMCreateInterpolation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMCreateInterpolation, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{Mat}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMCreateRestriction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMCreateRestriction, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCreateInjection(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMCreateInjection, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCreateMassMatrix(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMCreateMassMatrix, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetWorkArray(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGetWorkArray, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, MPI_Datatype, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMRestoreWorkArray(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMRestoreWorkArray, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, MPI_Datatype, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMRefine(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMRefine, $petsc_library), + PetscErrorCode, + (DM, MPI_Comm, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCoarsen(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMCoarsen, $petsc_library), + PetscErrorCode, + (DM, MPI_Comm, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetCoarseDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoarseDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetCoarseDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetCoarseDM, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMGetFineDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetFineDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetFineDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetFineDM, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMRefineHierarchy(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMRefineHierarchy, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCoarsenHierarchy(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMCoarsenHierarchy, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCoarsenHookAdd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMCoarsenHookAdd, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMCoarsenHookRemove( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMCoarsenHookRemove, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMRefineHookAdd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMRefineHookAdd, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMRefineHookRemove(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMRefineHookRemove, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMRestrict(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:DMRestrict, $petsc_library), + PetscErrorCode, + (DM, Mat, Vec, Mat, DM), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMInterpolate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMInterpolate, $petsc_library), + PetscErrorCode, + (DM, Mat, DM), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMInterpolateSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMInterpolateSolution, $petsc_library), + PetscErrorCode, + (DM, DM, Mat, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall((:DMSetFromOptions, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMViewFromOptions, $petsc_library), + PetscErrorCode, + (DM, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMAdaptLabel(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMAdaptLabel, $petsc_library), + PetscErrorCode, + (DM, DMLabel, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMAdaptMetric(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMAdaptMetric, $petsc_library), + PetscErrorCode, + (DM, Vec, DMLabel, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSetUp(::$UnionPetscLib, arg1) + @chk ccall((:DMSetUp, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMCreateInterpolationScale( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMCreateInterpolationScale, $petsc_library), + PetscErrorCode, + (DM, DM, Mat, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMCreateAggregates(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMCreateAggregates, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGlobalToLocalHookAdd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMGlobalToLocalHookAdd, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToGlobalHookAdd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLocalToGlobalHookAdd, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGlobalToLocal(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGlobalToLocal, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGlobalToLocalBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMGlobalToLocalBegin, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGlobalToLocalEnd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGlobalToLocalEnd, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToGlobal(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMLocalToGlobal, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToGlobalBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLocalToGlobalBegin, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToGlobalEnd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMLocalToGlobalEnd, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToLocalBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLocalToLocalBegin, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToLocalEnd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMLocalToLocalEnd, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMConvert(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMConvert, $petsc_library), + PetscErrorCode, + (DM, DMType, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetDimension, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetDimension, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMGetDimPoints(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGetDimPoints, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGetUseNatural(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetUseNatural, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetUseNatural(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetUseNatural, $petsc_library), + PetscErrorCode, + (DM, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCoordinateDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoordinateDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetCoordinateDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetCoordinateDM, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCoordinateDim(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoordinateDim, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetCoordinateDim(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetCoordinateDim, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCoordinateSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoordinateSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetCoordinateSection(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSetCoordinateSection, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscSection), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetCoordinates(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoordinates, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetCoordinates(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetCoordinates, $petsc_library), + PetscErrorCode, + (DM, Vec), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCoordinatesLocal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoordinatesLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCoordinatesLocalSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:DMGetCoordinatesLocalSetUp, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMGetCoordinatesLocalNoncollective( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMGetCoordinatesLocalNoncollective, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCoordinatesLocalTuple( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMGetCoordinatesLocalTuple, $petsc_library), + PetscErrorCode, + (DM, IS, Ptr{PetscSection}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSetCoordinatesLocal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetCoordinatesLocal, $petsc_library), + PetscErrorCode, + (DM, Vec), + arg1, + arg2, + ) +end + +@for_petsc function DMLocatePoints(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMLocatePoints, $petsc_library), + PetscErrorCode, + (DM, Vec, DMPointLocationType, Ptr{PetscSF}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGetPeriodicity( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMGetPeriodicity, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{PetscBool}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{DMBoundaryType}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSetPeriodicity( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSetPeriodicity, $petsc_library), + PetscErrorCode, + (DM, PetscBool, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{DMBoundaryType}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMLocalizeCoordinate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLocalizeCoordinate, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscScalar}, PetscBool, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalizeCoordinates(::$UnionPetscLib, arg1) + @chk ccall( + (:DMLocalizeCoordinates, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMGetCoordinatesLocalized(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoordinatesLocalized, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCoordinatesLocalizedLocal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoordinatesLocalizedLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetNeighbors(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetNeighbors, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{Ptr{PetscMPIInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetCoordinateField(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoordinateField, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMField}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetCoordinateField(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetCoordinateField, $petsc_library), + PetscErrorCode, + (DM, DMField), + arg1, + arg2, + ) +end + +@for_petsc function DMGetBoundingBox(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetBoundingBox, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetLocalBoundingBox(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetLocalBoundingBox, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMProjectCoordinates(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMProjectCoordinates, $petsc_library), + PetscErrorCode, + (DM, PetscFE), + arg1, + arg2, + ) +end + +@for_petsc function DMSubDomainHookAdd(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMSubDomainHookAdd, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSubDomainHookRemove( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMSubDomainHookRemove, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSubDomainRestrict( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMSubDomainRestrict, $petsc_library), + PetscErrorCode, + (DM, VecScatter, VecScatter, DM), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function DMAppendOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetVecType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetVecType, $petsc_library), + PetscErrorCode, + (DM, VecType), + arg1, + arg2, + ) +end + +@for_petsc function DMGetVecType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetVecType, $petsc_library), + PetscErrorCode, + (DM, Ptr{VecType}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetMatType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetMatType, $petsc_library), + PetscErrorCode, + (DM, MatType), + arg1, + arg2, + ) +end + +@for_petsc function DMGetMatType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetMatType, $petsc_library), + PetscErrorCode, + (DM, Ptr{MatType}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetISColoringType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetISColoringType, $petsc_library), + PetscErrorCode, + (DM, ISColoringType), + arg1, + arg2, + ) +end + +@for_petsc function DMGetISColoringType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetISColoringType, $petsc_library), + PetscErrorCode, + (DM, Ptr{ISColoringType}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetApplicationContext, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetApplicationContextDestroy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetApplicationContextDestroy, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetApplicationContext, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetVariableBounds(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetVariableBounds, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMHasVariableBounds(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMHasVariableBounds, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMHasColoring(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMHasColoring, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMHasCreateRestriction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMHasCreateRestriction, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMHasCreateInjection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMHasCreateInjection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMComputeVariableBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMComputeVariableBounds, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCreateSubDM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMCreateSubDM, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{IS}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMCreateSuperDM(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMCreateSuperDM, $petsc_library), + PetscErrorCode, + (Ptr{DM}, $PetscInt, Ptr{Ptr{IS}}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMCreateSectionSubDM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMCreateSectionSubDM, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{IS}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMCreateSectionSuperDM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMCreateSectionSuperDM, $petsc_library), + PetscErrorCode, + (Ptr{DM}, $PetscInt, Ptr{Ptr{IS}}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMCreateFieldDecomposition( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMCreateFieldDecomposition, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{Ptr{Ptr{Cchar}}}, Ptr{Ptr{IS}}, Ptr{Ptr{DM}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMCreateDomainDecomposition( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMCreateDomainDecomposition, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cchar}}}, + Ptr{Ptr{IS}}, + Ptr{Ptr{IS}}, + Ptr{Ptr{DM}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMCreateDomainDecompositionScatters( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMCreateDomainDecompositionScatters, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + Ptr{DM}, + Ptr{Ptr{VecScatter}}, + Ptr{Ptr{VecScatter}}, + Ptr{Ptr{VecScatter}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMGetRefineLevel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetRefineLevel, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetRefineLevel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetRefineLevel, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCoarsenLevel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetCoarsenLevel, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetCoarsenLevel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetCoarsenLevel, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMFinalizePackage(::$UnionPetscLib) + @chk ccall((:DMFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function VecGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecGetDM, $petsc_library), + PetscErrorCode, + (Vec, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function VecSetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:VecSetDM, $petsc_library), + PetscErrorCode, + (Vec, DM), + arg1, + arg2, + ) +end + +@for_petsc function MatGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatGetDM, $petsc_library), + PetscErrorCode, + (Mat, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function MatSetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSetDM, $petsc_library), + PetscErrorCode, + (Mat, DM), + arg1, + arg2, + ) +end + +@for_petsc function MatFDColoringUseDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatFDColoringUseDM, $petsc_library), + PetscErrorCode, + (Mat, MatFDColoring), + arg1, + arg2, + ) +end + +mutable struct NLF_DAAD end + +const NLF = Ptr{NLF_DAAD} + +@for_petsc function DMPrintCellVector(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPrintCellVector, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Cchar}, $PetscInt, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPrintCellMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPrintCellMatrix, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Cchar}, $PetscInt, $PetscInt, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPrintLocalVec(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPrintLocalVec, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscReal, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSetNullSpaceConstructor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSetNullSpaceConstructor, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetNullSpaceConstructor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMGetNullSpaceConstructor, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSetNearNullSpaceConstructor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSetNearNullSpaceConstructor, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetNearNullSpaceConstructor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMGetNearNullSpaceConstructor, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetSection, $petsc_library), + PetscErrorCode, + (DM, PetscSection), + arg1, + arg2, + ) +end + +@for_petsc function DMGetLocalSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetLocalSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetLocalSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetLocalSection, $petsc_library), + PetscErrorCode, + (DM, PetscSection), + arg1, + arg2, + ) +end + +@for_petsc function DMGetGlobalSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetGlobalSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetGlobalSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetGlobalSection, $petsc_library), + PetscErrorCode, + (DM, PetscSection), + arg1, + arg2, + ) +end + +@for_petsc function DMGetDefaultSection(::$UnionPetscLib, dm, s) + @chk ccall( + (:DMGetDefaultSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + dm, + s, + ) +end + +@for_petsc function DMSetDefaultSection(::$UnionPetscLib, dm, s) + @chk ccall( + (:DMSetDefaultSection, $petsc_library), + PetscErrorCode, + (DM, PetscSection), + dm, + s, + ) +end + +@for_petsc function DMGetDefaultGlobalSection(::$UnionPetscLib, dm, s) + @chk ccall( + (:DMGetDefaultGlobalSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + dm, + s, + ) +end + +@for_petsc function DMSetDefaultGlobalSection(::$UnionPetscLib, dm, s) + @chk ccall( + (:DMSetDefaultGlobalSection, $petsc_library), + PetscErrorCode, + (DM, PetscSection), + dm, + s, + ) +end + +@for_petsc function DMGetSectionSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetSectionSF, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSF}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetSectionSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetSectionSF, $petsc_library), + PetscErrorCode, + (DM, PetscSF), + arg1, + arg2, + ) +end + +@for_petsc function DMCreateSectionSF(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMCreateSectionSF, $petsc_library), + PetscErrorCode, + (DM, PetscSection, PetscSection), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetDefaultSF(::$UnionPetscLib, dm, s) + @chk ccall( + (:DMGetDefaultSF, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSF}), + dm, + s, + ) +end + +@for_petsc function DMSetDefaultSF(::$UnionPetscLib, dm, s) + @chk ccall( + (:DMSetDefaultSF, $petsc_library), + PetscErrorCode, + (DM, PetscSF), + dm, + s, + ) +end + +@for_petsc function DMCreateDefaultSF(::$UnionPetscLib, dm, l, g) + @chk ccall( + (:DMCreateDefaultSF, $petsc_library), + PetscErrorCode, + (DM, PetscSection, PetscSection), + dm, + l, + g, + ) +end + +@for_petsc function DMGetPointSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetPointSF, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSF}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetPointSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetPointSF, $petsc_library), + PetscErrorCode, + (DM, PetscSF), + arg1, + arg2, + ) +end + +@for_petsc function DMGetDefaultConstraints(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetDefaultConstraints, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSetDefaultConstraints(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSetDefaultConstraints, $petsc_library), + PetscErrorCode, + (DM, PetscSection, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetOutputDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetOutputDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetOutputSequenceNumber( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMGetOutputSequenceNumber, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSetOutputSequenceNumber( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSetOutputSequenceNumber, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMOutputSequenceLoad( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMOutputSequenceLoad, $petsc_library), + PetscErrorCode, + (DM, PetscViewer, Ptr{Cchar}, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMGetNumFields(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetNumFields, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMSetNumFields(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSetNumFields, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMGetField(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGetField, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DMLabel}, Ptr{PetscObject}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSetField(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMSetField, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, DMLabel, PetscObject), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMAddField(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMAddField, $petsc_library), + PetscErrorCode, + (DM, DMLabel, PetscObject), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSetFieldAvoidTensor(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSetFieldAvoidTensor, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetFieldAvoidTensor(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetFieldAvoidTensor, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMClearFields(::$UnionPetscLib, arg1) + @chk ccall((:DMClearFields, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMCopyFields(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCopyFields, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMGetAdjacency(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGetAdjacency, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSetAdjacency(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMSetAdjacency, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscBool, PetscBool), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGetBasicAdjacency(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetBasicAdjacency, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSetBasicAdjacency(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSetBasicAdjacency, $petsc_library), + PetscErrorCode, + (DM, PetscBool, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetNumDS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetNumDS, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetDS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetDS, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscDS}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCellDS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetCellDS, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{PetscDS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetRegionDS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGetRegionDS, $petsc_library), + PetscErrorCode, + (DM, DMLabel, Ptr{IS}, Ptr{PetscDS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSetRegionDS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMSetRegionDS, $petsc_library), + PetscErrorCode, + (DM, DMLabel, IS, PetscDS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGetRegionNumDS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMGetRegionNumDS, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DMLabel}, Ptr{IS}, Ptr{PetscDS}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSetRegionNumDS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSetRegionNumDS, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, DMLabel, IS, PetscDS), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMFindRegionNum(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMFindRegionNum, $petsc_library), + PetscErrorCode, + (DM, PetscDS, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCreateDS(::$UnionPetscLib, arg1) + @chk ccall((:DMCreateDS, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMClearDS(::$UnionPetscLib, arg1) + @chk ccall((:DMClearDS, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMCopyDS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCopyDS, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMCopyDisc(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCopyDisc, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMComputeExactSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMComputeExactSolution, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMCreateLabel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCreateLabel, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetLabelValue(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGetLabelValue, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSetLabelValue(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMSetLabelValue, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMClearLabelValue(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMClearLabelValue, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGetLabelSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetLabelSize, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetLabelIdIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetLabelIdIS, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetStratumSize(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGetStratumSize, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGetStratumIS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGetStratumIS, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSetStratumIS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMSetStratumIS, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscInt, IS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMClearLabelStratum(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMClearLabelStratum, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetLabelOutput(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetLabelOutput, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSetLabelOutput(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSetLabelOutput, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetNumLabels(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetNumLabels, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetLabelName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetLabelName, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMHasLabel(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMHasLabel, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetLabel(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetLabel, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{DMLabel}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetLabelByNum(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetLabelByNum, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DMLabel}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMAddLabel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMAddLabel, $petsc_library), + PetscErrorCode, + (DM, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function DMRemoveLabel(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMRemoveLabel, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{DMLabel}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMRemoveLabelBySelf(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMRemoveLabelBySelf, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMLabel}, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCopyLabels(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMCopyLabels, $petsc_library), + PetscErrorCode, + (DM, DM, PetscCopyMode, PetscBool), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMAddBoundary( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, +) + @chk ccall( + (:DMAddBoundary, $petsc_library), + PetscErrorCode, + ( + DM, + DMBoundaryConditionType, + Ptr{Cchar}, + Ptr{Cchar}, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + ) +end + +@for_petsc function DMGetNumBoundary(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMGetNumBoundary, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetBoundary( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:DMGetBoundary, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + Ptr{DMBoundaryConditionType}, + Ptr{Ptr{Cchar}}, + Ptr{Ptr{Cchar}}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function DMIsBoundaryPoint(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMIsBoundaryPoint, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCopyBoundary(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCopyBoundary, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMProjectFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMProjectFunction, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMProjectFunctionLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMProjectFunctionLocal, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMProjectFunctionLabel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:DMProjectFunctionLabel, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + InsertMode, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function DMProjectFunctionLabelLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:DMProjectFunctionLabelLocal, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + InsertMode, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function DMProjectFieldLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMProjectFieldLocal, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Vec, Ptr{Ptr{Cvoid}}, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMProjectFieldLabelLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:DMProjectFieldLabelLocal, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Vec, + Ptr{Ptr{Cvoid}}, + InsertMode, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function DMProjectBdFieldLabelLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:DMProjectBdFieldLabelLocal, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Vec, + Ptr{Ptr{Cvoid}}, + InsertMode, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function DMComputeL2Diff( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMComputeL2Diff, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Vec, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMComputeL2GradientDiff( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMComputeL2GradientDiff, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Vec, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMComputeL2FieldDiff( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMComputeL2FieldDiff, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Vec, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMComputeError(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMComputeError, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{$PetscReal}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMHasBasisTransform(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMHasBasisTransform, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMCopyTransform(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCopyTransform, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMGetCompatibility(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMGetCompatibility, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMMonitorSet(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMMonitorSet, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMMonitorCancel(::$UnionPetscLib, arg1) + @chk ccall((:DMMonitorCancel, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMMonitorSetFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMMonitorSetFromOptions, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMMonitor(::$UnionPetscLib, arg1) + @chk ccall((:DMMonitor, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMPolytopeTypeGetDim(::$UnionPetscLib, ct) + ccall( + (:DMPolytopeTypeGetDim, $petsc_library), + $PetscInt, + (DMPolytopeType,), + ct, + ) +end + +@for_petsc function DMPolytopeTypeGetConeSize(::$UnionPetscLib, ct) + ccall( + (:DMPolytopeTypeGetConeSize, $petsc_library), + $PetscInt, + (DMPolytopeType,), + ct, + ) +end + +@for_petsc function DMPolytopeTypeGetNumVertices(::$UnionPetscLib, ct) + ccall( + (:DMPolytopeTypeGetNumVertices, $petsc_library), + $PetscInt, + (DMPolytopeType,), + ct, + ) +end + +@enum DMDAStencilType::UInt32 begin + DMDA_STENCIL_STAR = 0 + DMDA_STENCIL_BOX = 1 +end + +@enum DMDAInterpolationType::UInt32 begin + DMDA_Q0 = 0 + DMDA_Q1 = 1 +end + +@enum DMDAElementType::UInt32 begin + DMDA_ELEMENT_P1 = 0 + DMDA_ELEMENT_Q1 = 1 +end + +const PFType = Ptr{Cchar} + +mutable struct _p_PF end + +const PF = Ptr{_p_PF} + +@for_petsc function PFCreate(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PFCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{PF}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PFSetType(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PFSetType, $petsc_library), + PetscErrorCode, + (PF, PFType, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PFSet(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5, arg6) + @chk ccall( + (:PFSet, $petsc_library), + PetscErrorCode, + (PF, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PFApply(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PFApply, $petsc_library), + PetscErrorCode, + (PF, $PetscInt, Ptr{$PetscScalar}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PFApplyVec(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PFApplyVec, $petsc_library), + PetscErrorCode, + (PF, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PFInitializePackage(::$UnionPetscLib) + @chk ccall((:PFInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PFRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PFRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PFDestroy(::$UnionPetscLib, arg1) + @chk ccall((:PFDestroy, $petsc_library), PetscErrorCode, (Ptr{PF},), arg1) +end + +@for_petsc function PFSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall((:PFSetFromOptions, $petsc_library), PetscErrorCode, (PF,), arg1) +end + +@for_petsc function PFGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PFGetType, $petsc_library), + PetscErrorCode, + (PF, Ptr{PFType}), + arg1, + arg2, + ) +end + +@for_petsc function PFView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PFView, $petsc_library), + PetscErrorCode, + (PF, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PFViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PFViewFromOptions, $petsc_library), + PetscErrorCode, + (PF, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +mutable struct _p_AO end + +const AO = Ptr{_p_AO} + +const AOType = Ptr{Cchar} + +@for_petsc function AOInitializePackage(::$UnionPetscLib) + @chk ccall((:AOInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function AOCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:AOCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{AO}), + arg1, + arg2, + ) +end + +@for_petsc function AOSetIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:AOSetIS, $petsc_library), + PetscErrorCode, + (AO, IS, IS), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall((:AOSetFromOptions, $petsc_library), PetscErrorCode, (AO,), arg1) +end + +@for_petsc function AOCreateBasic( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:AOCreateBasic, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{AO}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function AOCreateBasicIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:AOCreateBasicIS, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{AO}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOCreateMemoryScalable( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:AOCreateMemoryScalable, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{AO}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function AOCreateMemoryScalableIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:AOCreateMemoryScalableIS, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{AO}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOCreateMapping( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:AOCreateMapping, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{AO}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function AOCreateMappingIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:AOCreateMappingIS, $petsc_library), + PetscErrorCode, + (IS, IS, Ptr{AO}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:AOView, $petsc_library), + PetscErrorCode, + (AO, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function AOViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:AOViewFromOptions, $petsc_library), + PetscErrorCode, + (AO, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AODestroy(::$UnionPetscLib, arg1) + @chk ccall((:AODestroy, $petsc_library), PetscErrorCode, (Ptr{AO},), arg1) +end + +@for_petsc function AOSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:AOSetType, $petsc_library), + PetscErrorCode, + (AO, AOType), + arg1, + arg2, + ) +end + +@for_petsc function AOGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:AOGetType, $petsc_library), + PetscErrorCode, + (AO, Ptr{AOType}), + arg1, + arg2, + ) +end + +@for_petsc function AORegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:AORegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function AOPetscToApplication(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:AOPetscToApplication, $petsc_library), + PetscErrorCode, + (AO, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOApplicationToPetsc(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:AOApplicationToPetsc, $petsc_library), + PetscErrorCode, + (AO, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOPetscToApplicationIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:AOPetscToApplicationIS, $petsc_library), + PetscErrorCode, + (AO, IS), + arg1, + arg2, + ) +end + +@for_petsc function AOApplicationToPetscIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:AOApplicationToPetscIS, $petsc_library), + PetscErrorCode, + (AO, IS), + arg1, + arg2, + ) +end + +@for_petsc function AOPetscToApplicationPermuteInt( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:AOPetscToApplicationPermuteInt, $petsc_library), + PetscErrorCode, + (AO, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOApplicationToPetscPermuteInt( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:AOApplicationToPetscPermuteInt, $petsc_library), + PetscErrorCode, + (AO, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOPetscToApplicationPermuteReal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:AOPetscToApplicationPermuteReal, $petsc_library), + PetscErrorCode, + (AO, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOApplicationToPetscPermuteReal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:AOApplicationToPetscPermuteReal, $petsc_library), + PetscErrorCode, + (AO, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOMappingHasApplicationIndex( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:AOMappingHasApplicationIndex, $petsc_library), + PetscErrorCode, + (AO, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function AOMappingHasPetscIndex(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:AOMappingHasPetscIndex, $petsc_library), + PetscErrorCode, + (AO, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +mutable struct _p_PetscQuadrature end + +const PetscQuadrature = Ptr{_p_PetscQuadrature} + +@enum PetscGaussLobattoLegendreCreateType::UInt32 begin + PETSCGAUSSLOBATTOLEGENDRE_VIA_LINEAR_ALGEBRA = 0 + PETSCGAUSSLOBATTOLEGENDRE_VIA_NEWTON = 1 +end + +@enum PetscDTNodeType::Int32 begin + PETSCDTNODES_DEFAULT = -1 + PETSCDTNODES_GAUSSJACOBI = 0 + PETSCDTNODES_EQUISPACED = 1 + PETSCDTNODES_TANHSINH = 2 +end + +@for_petsc function PetscQuadratureCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscQuadratureCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscQuadrature}), + arg1, + arg2, + ) +end + +@for_petsc function PetscQuadratureDuplicate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscQuadratureDuplicate, $petsc_library), + PetscErrorCode, + (PetscQuadrature, Ptr{PetscQuadrature}), + arg1, + arg2, + ) +end + +@for_petsc function PetscQuadratureGetOrder(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscQuadratureGetOrder, $petsc_library), + PetscErrorCode, + (PetscQuadrature, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscQuadratureSetOrder(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscQuadratureSetOrder, $petsc_library), + PetscErrorCode, + (PetscQuadrature, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscQuadratureGetNumComponents( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscQuadratureGetNumComponents, $petsc_library), + PetscErrorCode, + (PetscQuadrature, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscQuadratureSetNumComponents( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscQuadratureSetNumComponents, $petsc_library), + PetscErrorCode, + (PetscQuadrature, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscQuadratureGetData( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscQuadratureGetData, $petsc_library), + PetscErrorCode, + ( + PetscQuadrature, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscQuadratureSetData( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscQuadratureSetData, $petsc_library), + PetscErrorCode, + ( + PetscQuadrature, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscQuadratureView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscQuadratureView, $petsc_library), + PetscErrorCode, + (PetscQuadrature, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscQuadratureDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscQuadratureDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscQuadrature},), + arg1, + ) +end + +@for_petsc function PetscQuadratureExpandComposite( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscQuadratureExpandComposite, $petsc_library), + PetscErrorCode, + ( + PetscQuadrature, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{PetscQuadrature}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscQuadraturePushForward( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscQuadraturePushForward, $petsc_library), + PetscErrorCode, + ( + PetscQuadrature, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + $PetscInt, + Ptr{PetscQuadrature}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDTLegendreEval( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDTLegendreEval, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDTJacobiNorm(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscDTJacobiNorm, $petsc_library), + PetscErrorCode, + ($PetscReal, $PetscReal, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDTJacobiEval( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscDTJacobiEval, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscReal, + $PetscReal, + Ptr{$PetscReal}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscDTJacobiEvalJet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDTJacobiEvalJet, $petsc_library), + PetscErrorCode, + ( + $PetscReal, + $PetscReal, + $PetscInt, + Ptr{$PetscReal}, + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDTPKDEvalJet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDTPKDEvalJet, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDTGaussQuadrature( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDTGaussQuadrature, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscReal, $PetscReal, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDTGaussJacobiQuadrature( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDTGaussJacobiQuadrature, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDTGaussLobattoJacobiQuadrature( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDTGaussLobattoJacobiQuadrature, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDTGaussLobattoLegendreQuadrature( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDTGaussLobattoLegendreQuadrature, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + PetscGaussLobattoLegendreCreateType, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDTReconstructPoly( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDTReconstructPoly, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDTGaussTensorQuadrature( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDTGaussTensorQuadrature, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscInt, + $PetscInt, + $PetscReal, + $PetscReal, + Ptr{PetscQuadrature}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDTStroudConicalQuadrature( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDTStroudConicalQuadrature, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscInt, + $PetscInt, + $PetscReal, + $PetscReal, + Ptr{PetscQuadrature}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDTTanhSinhTensorQuadrature( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDTTanhSinhTensorQuadrature, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, $PetscReal, $PetscReal, Ptr{PetscQuadrature}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDTTanhSinhIntegrate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDTTanhSinhIntegrate, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, $PetscReal, $PetscReal, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDTTanhSinhIntegrateMPFR( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDTTanhSinhIntegrateMPFR, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid}, $PetscReal, $PetscReal, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscGaussLobattoLegendreIntegrate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscGaussLobattoLegendreIntegrate, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscGaussLobattoLegendreElementLaplacianCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGaussLobattoLegendreElementLaplacianCreate, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{Ptr{Ptr{$PetscReal}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGaussLobattoLegendreElementLaplacianDestroy( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGaussLobattoLegendreElementLaplacianDestroy, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{Ptr{Ptr{$PetscReal}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGaussLobattoLegendreElementGradientCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscGaussLobattoLegendreElementGradientCreate, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{Ptr{Ptr{$PetscReal}}}, + Ptr{Ptr{Ptr{$PetscReal}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscGaussLobattoLegendreElementGradientDestroy( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscGaussLobattoLegendreElementGradientDestroy, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{Ptr{Ptr{$PetscReal}}}, + Ptr{Ptr{Ptr{$PetscReal}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscGaussLobattoLegendreElementAdvectionCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGaussLobattoLegendreElementAdvectionCreate, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{Ptr{Ptr{$PetscReal}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGaussLobattoLegendreElementAdvectionDestroy( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGaussLobattoLegendreElementAdvectionDestroy, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{Ptr{Ptr{$PetscReal}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGaussLobattoLegendreElementMassCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGaussLobattoLegendreElementMassCreate, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{Ptr{Ptr{$PetscReal}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGaussLobattoLegendreElementMassDestroy( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGaussLobattoLegendreElementMassDestroy, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{Ptr{Ptr{$PetscReal}}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDTAltVApply( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDTAltVApply, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDTAltVWedge( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDTAltVWedge, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDTAltVWedgeMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDTAltVWedgeMatrix, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDTAltVPullback( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDTAltVPullback, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDTAltVPullbackMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDTAltVPullbackMatrix, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscReal}, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDTAltVInterior( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDTAltVInterior, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDTAltVInteriorMatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDTAltVInteriorMatrix, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDTAltVInteriorPattern( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDTAltVInteriorPattern, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{NTuple{3, $PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDTAltVStar( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscDTAltVStar, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscDTBaryToIndex(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscDTBaryToIndex, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDTIndexToBary(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscDTIndexToBary, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDTGradedOrderToIndex( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDTGradedOrderToIndex, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDTIndexToGradedOrder( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDTIndexToGradedOrder, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDTFactorial(::$UnionPetscLib, n, factorial) + @chk ccall( + (:PetscDTFactorial, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscReal}), + n, + factorial, + ) +end + +@for_petsc function PetscDTFactorialInt(::$UnionPetscLib, n, factorial) + @chk ccall( + (:PetscDTFactorialInt, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}), + n, + factorial, + ) +end + +@for_petsc function PetscDTBinomial(::$UnionPetscLib, n, k, binomial) + @chk ccall( + (:PetscDTBinomial, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscReal}), + n, + k, + binomial, + ) +end + +@for_petsc function PetscDTBinomialInt(::$UnionPetscLib, n, k, binomial) + @chk ccall( + (:PetscDTBinomialInt, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscInt}), + n, + k, + binomial, + ) +end + +@for_petsc function PetscDTEnumPerm(::$UnionPetscLib, n, k, perm, isOdd) + @chk ccall( + (:PetscDTEnumPerm, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{PetscBool}), + n, + k, + perm, + isOdd, + ) +end + +@for_petsc function PetscDTPermIndex(::$UnionPetscLib, n, perm, k, isOdd) + @chk ccall( + (:PetscDTPermIndex, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{PetscBool}), + n, + perm, + k, + isOdd, + ) +end + +@for_petsc function PetscDTEnumSubset(::$UnionPetscLib, n, k, j, subset) + @chk ccall( + (:PetscDTEnumSubset, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}), + n, + k, + j, + subset, + ) +end + +@for_petsc function PetscDTSubsetIndex(::$UnionPetscLib, n, k, subset, index) + @chk ccall( + (:PetscDTSubsetIndex, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + n, + k, + subset, + index, + ) +end + +@for_petsc function PetscDTEnumSplit(::$UnionPetscLib, n, k, j, perm, isOdd) + @chk ccall( + (:PetscDTEnumSplit, $petsc_library), + PetscErrorCode, + ($PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{PetscBool}), + n, + k, + j, + perm, + isOdd, + ) +end + +@for_petsc function PetscFEInitializePackage(::$UnionPetscLib) + @chk ccall((:PetscFEInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +const PetscSpaceType = Ptr{Cchar} + +@for_petsc function PetscSpaceCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscSpace}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSpaceDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscSpace},), + arg1, + ) +end + +@for_petsc function PetscSpaceSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceSetType, $petsc_library), + PetscErrorCode, + (PetscSpace, PetscSpaceType), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceGetType, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{PetscSpaceType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSpaceSetUp, $petsc_library), + PetscErrorCode, + (PetscSpace,), + arg1, + ) +end + +@for_petsc function PetscSpaceSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscSpaceSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscSpace,), + arg1, + ) +end + +@for_petsc function PetscSpaceViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSpaceViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscSpace, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSpaceView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceView, $petsc_library), + PetscErrorCode, + (PetscSpace, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceRegisterDestroy(::$UnionPetscLib) + @chk ccall((:PetscSpaceRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscSpaceGetDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceGetDimension, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceSetNumComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceSetNumComponents, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceGetNumComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceGetNumComponents, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceSetNumVariables(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceSetNumVariables, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceGetNumVariables(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceGetNumVariables, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceSetDegree(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSpaceSetDegree, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSpaceGetDegree(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSpaceGetDegree, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSpaceEvaluate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscSpaceEvaluate, $petsc_library), + PetscErrorCode, + ( + PetscSpace, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscSpaceGetHeightSubspace( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSpaceGetHeightSubspace, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt, Ptr{PetscSpace}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSpacePolynomialSetSymmetric( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscSpacePolynomialSetSymmetric, $petsc_library), + PetscErrorCode, + (PetscSpace, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpacePolynomialGetSymmetric( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscSpacePolynomialGetSymmetric, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpacePolynomialSetTensor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpacePolynomialSetTensor, $petsc_library), + PetscErrorCode, + (PetscSpace, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpacePolynomialGetTensor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpacePolynomialGetTensor, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceTensorSetNumSubspaces( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscSpaceTensorSetNumSubspaces, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceTensorGetNumSubspaces( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscSpaceTensorGetNumSubspaces, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceTensorSetSubspace( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSpaceTensorSetSubspace, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt, PetscSpace), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSpaceTensorGetSubspace( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscSpaceTensorGetSubspace, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt, Ptr{PetscSpace}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSpaceSumSetNumSubspaces(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceSumSetNumSubspaces, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceSumGetNumSubspaces(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceSumGetNumSubspaces, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceSumSetSubspace(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSpaceSumSetSubspace, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt, PetscSpace), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSpaceSumGetSubspace(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscSpaceSumGetSubspace, $petsc_library), + PetscErrorCode, + (PetscSpace, $PetscInt, Ptr{PetscSpace}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscSpaceSumSetConcatenate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceSumSetConcatenate, $petsc_library), + PetscErrorCode, + (PetscSpace, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceSumGetConcatenate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpaceSumGetConcatenate, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceCreateSum( + ::$UnionPetscLib, + numSubspaces, + subspaces, + concatenate, + sumSpace, +) + @chk ccall( + (:PetscSpaceCreateSum, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{PetscSpace}, PetscBool, Ptr{PetscSpace}), + numSubspaces, + subspaces, + concatenate, + sumSpace, + ) +end + +@for_petsc function PetscSpacePointGetPoints(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpacePointGetPoints, $petsc_library), + PetscErrorCode, + (PetscSpace, Ptr{PetscQuadrature}), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpacePointSetPoints(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscSpacePointSetPoints, $petsc_library), + PetscErrorCode, + (PetscSpace, PetscQuadrature), + arg1, + arg2, + ) +end + +@for_petsc function PetscSpaceCreateSubspace( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscSpaceCreateSubspace, $petsc_library), + PetscErrorCode, + ( + PetscSpace, + PetscDualSpace, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + PetscCopyMode, + Ptr{PetscSpace}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +const PetscDualSpaceType = Ptr{Cchar} + +@for_petsc function PetscDualSpaceCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscDualSpace}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDualSpaceDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscDualSpace},), + arg1, + ) +end + +@for_petsc function PetscDualSpaceDuplicate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceDuplicate, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscDualSpace}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceSetType, $petsc_library), + PetscErrorCode, + (PetscDualSpace, PetscDualSpaceType), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetType, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscDualSpaceType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetUniform(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetUniform, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetNumDof(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetNumDof, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetSection, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDualSpaceSetUp, $petsc_library), + PetscErrorCode, + (PetscDualSpace,), + arg1, + ) +end + +@for_petsc function PetscDualSpaceSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDualSpaceSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscDualSpace,), + arg1, + ) +end + +@for_petsc function PetscDualSpaceViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscDualSpace, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceView, $petsc_library), + PetscErrorCode, + (PetscDualSpace, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceRegisterDestroy(::$UnionPetscLib) + @chk ccall( + (:PetscDualSpaceRegisterDestroy, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscDualSpaceGetDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetDimension, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetInteriorDimension( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceGetInteriorDimension, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceSetNumComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceSetNumComponents, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetNumComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetNumComponents, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceSetOrder(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceSetOrder, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetOrder(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetOrder, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceSetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceSetDM, $petsc_library), + PetscErrorCode, + (PetscDualSpace, DM), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetDM, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetFunctional( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceGetFunctional, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt, Ptr{PetscQuadrature}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceCreateReferenceCell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDualSpaceCreateReferenceCell, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDualSpaceGetSymmetries( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceGetSymmetries, $petsc_library), + PetscErrorCode, + ( + PetscDualSpace, + Ptr{Ptr{Ptr{Ptr{$PetscInt}}}}, + Ptr{Ptr{Ptr{Ptr{$PetscScalar}}}}, + ), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceGetAllData(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDualSpaceGetAllData, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscQuadrature}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceCreateAllDataDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceCreateAllDataDefault, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscQuadrature}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceGetInteriorData( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceGetInteriorData, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscQuadrature}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceCreateInteriorDataDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceCreateInteriorDataDefault, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscQuadrature}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceApplyAll(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDualSpaceApplyAll, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscScalar}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceApplyAllDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceApplyAllDefault, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscScalar}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceApplyInterior( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceApplyInterior, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscScalar}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceApplyInteriorDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceApplyInteriorDefault, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscScalar}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceGetFormDegree(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetFormDegree, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceSetFormDegree(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceSetFormDegree, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetDeRahm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDualSpaceGetDeRahm, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeGetContinuity( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeGetContinuity, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeSetContinuity( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeSetContinuity, $petsc_library), + PetscErrorCode, + (PetscDualSpace, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeGetTensor( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeGetTensor, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeSetTensor( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeSetTensor, $petsc_library), + PetscErrorCode, + (PetscDualSpace, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeGetTrimmed( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeGetTrimmed, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeSetTrimmed( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeSetTrimmed, $petsc_library), + PetscErrorCode, + (PetscDualSpace, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeGetNodeType( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDualSpaceLagrangeGetNodeType, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscDTNodeType}, Ptr{PetscBool}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDualSpaceLagrangeSetNodeType( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDualSpaceLagrangeSetNodeType, $petsc_library), + PetscErrorCode, + (PetscDualSpace, PetscDTNodeType, PetscBool, $PetscReal), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDualSpaceLagrangeGetUseMoments( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeGetUseMoments, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeSetUseMoments( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeSetUseMoments, $petsc_library), + PetscErrorCode, + (PetscDualSpace, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeGetMomentOrder( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeGetMomentOrder, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceLagrangeSetMomentOrder( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceLagrangeSetMomentOrder, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceGetHeightSubspace( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceGetHeightSubspace, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt, Ptr{PetscDualSpace}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceGetPointSubspace( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceGetPointSubspace, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt, Ptr{PetscDualSpace}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceSimpleSetDimension( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceSimpleSetDimension, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscDualSpaceSimpleSetFunctional( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDualSpaceSimpleSetFunctional, $petsc_library), + PetscErrorCode, + (PetscDualSpace, $PetscInt, PetscQuadrature), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDualSpaceRefinedSetCellSpaces( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDualSpaceRefinedSetCellSpaces, $petsc_library), + PetscErrorCode, + (PetscDualSpace, Ptr{PetscDualSpace}), + arg1, + arg2, + ) +end + +const PetscFEType = Ptr{Cchar} + +@for_petsc function PetscFECreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFECreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscFE}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFEDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscFE},), + arg1, + ) +end + +@for_petsc function PetscFESetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFESetType, $petsc_library), + PetscErrorCode, + (PetscFE, PetscFEType), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEGetType, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{PetscFEType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFESetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFESetUp, $petsc_library), + PetscErrorCode, + (PetscFE,), + arg1, + ) +end + +@for_petsc function PetscFESetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFESetFromOptions, $petsc_library), + PetscErrorCode, + (PetscFE,), + arg1, + ) +end + +@for_petsc function PetscFEViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscFEViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscFE, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFESetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFESetName, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEView, $petsc_library), + PetscErrorCode, + (PetscFE, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscFERegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFERegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFERegisterDestroy(::$UnionPetscLib) + @chk ccall((:PetscFERegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscFECreateDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscFECreateDefault, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + PetscBool, + Ptr{Cchar}, + $PetscInt, + Ptr{PetscFE}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscFECreateLagrange( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscFECreateLagrange, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + PetscBool, + $PetscInt, + $PetscInt, + Ptr{PetscFE}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscFEGetDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEGetDimension, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetSpatialDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEGetSpatialDimension, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFESetNumComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFESetNumComponents, $petsc_library), + PetscErrorCode, + (PetscFE, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetNumComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEGetNumComponents, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetTileSizes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscFEGetTileSizes, $petsc_library), + PetscErrorCode, + ( + PetscFE, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscFESetTileSizes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscFESetTileSizes, $petsc_library), + PetscErrorCode, + (PetscFE, $PetscInt, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscFESetBasisSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFESetBasisSpace, $petsc_library), + PetscErrorCode, + (PetscFE, PetscSpace), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetBasisSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEGetBasisSpace, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{PetscSpace}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFESetDualSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFESetDualSpace, $petsc_library), + PetscErrorCode, + (PetscFE, PetscDualSpace), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetDualSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEGetDualSpace, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{PetscDualSpace}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFESetQuadrature(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFESetQuadrature, $petsc_library), + PetscErrorCode, + (PetscFE, PetscQuadrature), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetQuadrature(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEGetQuadrature, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{PetscQuadrature}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFESetFaceQuadrature(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFESetFaceQuadrature, $petsc_library), + PetscErrorCode, + (PetscFE, PetscQuadrature), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetFaceQuadrature(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEGetFaceQuadrature, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{PetscQuadrature}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFECopyQuadrature(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFECopyQuadrature, $petsc_library), + PetscErrorCode, + (PetscFE, PetscFE), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetNumDof(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEGetNumDof, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFERefine(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFERefine, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{PetscFE}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEGetHeightSubspace(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscFEGetHeightSubspace, $petsc_library), + PetscErrorCode, + (PetscFE, $PetscInt, Ptr{PetscFE}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFECompositeGetMapping( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscFECompositeGetMapping, $petsc_library), + PetscErrorCode, + ( + PetscFE, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscFECreateHeightTrace(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscFECreateHeightTrace, $petsc_library), + PetscErrorCode, + (PetscFE, $PetscInt, Ptr{PetscFE}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFECreatePointTrace(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscFECreatePointTrace, $petsc_library), + PetscErrorCode, + (PetscFE, $PetscInt, Ptr{PetscFE}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFEOpenCLSetRealType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEOpenCLSetRealType, $petsc_library), + PetscErrorCode, + (PetscFE, PetscDataType), + arg1, + arg2, + ) +end + +@for_petsc function PetscFEOpenCLGetRealType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFEOpenCLGetRealType, $petsc_library), + PetscErrorCode, + (PetscFE, Ptr{PetscDataType}), + arg1, + arg2, + ) +end + +@for_petsc function DMDASetInterpolationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDASetInterpolationType, $petsc_library), + PetscErrorCode, + (DM, DMDAInterpolationType), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetInterpolationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetInterpolationType, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMDAInterpolationType}), + arg1, + arg2, + ) +end + +@for_petsc function DMDACreateAggregates(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDACreateAggregates, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDASetElementType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDASetElementType, $petsc_library), + PetscErrorCode, + (DM, DMDAElementType), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetElementType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetElementType, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMDAElementType}), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetElements(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMDAGetElements, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDARestoreElements( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDARestoreElements, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGetElementsSizes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDAGetElementsSizes, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGetElementsCorners( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDAGetElementsCorners, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGetSubdomainCornersIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetSubdomainCornersIS, $petsc_library), + PetscErrorCode, + (DM, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function DMDARestoreSubdomainCornersIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDARestoreSubdomainCornersIS, $petsc_library), + PetscErrorCode, + (DM, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function DMDACreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDACreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMDASetSizes(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMDASetSizes, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDACreate1d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDACreate1d, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + DMBoundaryType, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDACreate2d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:DMDACreate2d, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + DMBoundaryType, + DMBoundaryType, + DMDAStencilType, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function DMDACreate3d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, +) + @chk ccall( + (:DMDACreate3d, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + DMBoundaryType, + DMBoundaryType, + DMBoundaryType, + DMDAStencilType, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + ) +end + +@for_petsc function DMDAGlobalToNaturalBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDAGlobalToNaturalBegin, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGlobalToNaturalEnd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDAGlobalToNaturalEnd, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDANaturalToGlobalBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDANaturalToGlobalBegin, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDANaturalToGlobalEnd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDANaturalToGlobalEnd, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDALocalToLocalBegin(::$UnionPetscLib, dm, g, mode, l) + @chk ccall( + (:DMDALocalToLocalBegin, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + dm, + g, + mode, + l, + ) +end + +@for_petsc function DMDALocalToLocalEnd(::$UnionPetscLib, dm, g, mode, l) + @chk ccall( + (:DMDALocalToLocalEnd, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + dm, + g, + mode, + l, + ) +end + +@for_petsc function DMDACreateNaturalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDACreateNaturalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetCorners( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDAGetCorners, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDAGetGhostCorners( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDAGetGhostCorners, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDAGetInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, +) + @chk ccall( + (:DMDAGetInfo, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{DMBoundaryType}, + Ptr{DMBoundaryType}, + Ptr{DMBoundaryType}, + Ptr{DMDAStencilType}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + ) +end + +@for_petsc function DMDAGetProcessorSubset( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDAGetProcessorSubset, $petsc_library), + PetscErrorCode, + (DM, DMDirection, $PetscInt, Ptr{MPI_Comm}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGetProcessorSubsets(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAGetProcessorSubsets, $petsc_library), + PetscErrorCode, + (DM, DMDirection, Ptr{MPI_Comm}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAGetRay(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:DMDAGetRay, $petsc_library), + PetscErrorCode, + (DM, DMDirection, $PetscInt, Ptr{Vec}, Ptr{VecScatter}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMDAGlobalToNaturalAllCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGlobalToNaturalAllCreate, $petsc_library), + PetscErrorCode, + (DM, Ptr{VecScatter}), + arg1, + arg2, + ) +end + +@for_petsc function DMDANaturalAllToGlobalCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDANaturalAllToGlobalCreate, $petsc_library), + PetscErrorCode, + (DM, Ptr{VecScatter}), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetScatter(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAGetScatter, $petsc_library), + PetscErrorCode, + (DM, Ptr{VecScatter}, Ptr{VecScatter}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAGetNeighbors(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetNeighbors, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{PetscMPIInt}}), + arg1, + arg2, + ) +end + +@for_petsc function DMDASetAOType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDASetAOType, $petsc_library), + PetscErrorCode, + (DM, AOType), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetAO(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetAO, $petsc_library), + PetscErrorCode, + (DM, Ptr{AO}), + arg1, + arg2, + ) +end + +@for_petsc function DMDASetUniformCoordinates( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDASetUniformCoordinates, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDASetGLLCoordinates(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDASetGLLCoordinates, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAGetCoordinateArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetCoordinateArray, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMDARestoreCoordinateArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDARestoreCoordinateArray, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetLogicalCoordinate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:DMDAGetLogicalCoordinate, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscScalar, + $PetscScalar, + $PetscScalar, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + Ptr{$PetscScalar}, + Ptr{$PetscScalar}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function DMDAMapCoordsToPeriodicDomain( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMDAMapCoordsToPeriodicDomain, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscScalar}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDACreateCompatibleDMDA(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDACreateCompatibleDMDA, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAGetReducedDMDA(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAGetReducedDMDA, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDASetFieldName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDASetFieldName, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAGetFieldName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAGetFieldName, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDASetFieldNames(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDASetFieldNames, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetFieldNames(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetFieldNames, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Ptr{Cchar}}}), + arg1, + arg2, + ) +end + +@for_petsc function DMDASetCoordinateName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDASetCoordinateName, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAGetCoordinateName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAGetCoordinateName, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDASetBoundaryType( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDASetBoundaryType, $petsc_library), + PetscErrorCode, + (DM, DMBoundaryType, DMBoundaryType, DMBoundaryType), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDASetDof(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDASetDof, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetDof(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetDof, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMDASetOverlap(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMDASetOverlap, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGetOverlap(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMDAGetOverlap, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDASetNumLocalSubDomains(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDASetNumLocalSubDomains, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetNumLocalSubDomains(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetNumLocalSubDomains, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetOffset( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDAGetOffset, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDASetOffset( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDASetOffset, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDAGetNonOverlappingRegion( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDAGetNonOverlappingRegion, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDASetNonOverlappingRegion( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDASetNonOverlappingRegion, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDASetStencilWidth(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDASetStencilWidth, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetStencilWidth(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetStencilWidth, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMDASetOwnershipRanges( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDASetOwnershipRanges, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGetOwnershipRanges( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDAGetOwnershipRanges, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{$PetscInt}}, Ptr{Ptr{$PetscInt}}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDASetNumProcs(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMDASetNumProcs, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDASetStencilType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDASetStencilType, $petsc_library), + PetscErrorCode, + (DM, DMDAStencilType), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetStencilType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDAGetStencilType, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMDAStencilType}), + arg1, + arg2, + ) +end + +@for_petsc function DMDAVecGetArray(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAVecGetArray, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAVecRestoreArray(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAVecRestoreArray, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAVecGetArrayWrite(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAVecGetArrayWrite, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAVecRestoreArrayWrite(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAVecRestoreArrayWrite, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAVecGetArrayDOF(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAVecGetArrayDOF, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAVecRestoreArrayDOF(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAVecRestoreArrayDOF, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAVecGetArrayRead(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAVecGetArrayRead, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAVecRestoreArrayRead(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAVecRestoreArrayRead, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAVecGetArrayDOFRead(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAVecGetArrayDOFRead, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDAVecRestoreArrayDOFRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMDAVecRestoreArrayDOFRead, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatRegisterDAAD(::$UnionPetscLib) + @chk ccall((:MatRegisterDAAD, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function MatCreateDAAD(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCreateDAAD, $petsc_library), + PetscErrorCode, + (DM, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatCreateSeqUSFFT(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatCreateSeqUSFFT, $petsc_library), + PetscErrorCode, + (Vec, DM, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDASetGetMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDASetGetMatrix, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMDASetBlockFills(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDASetBlockFills, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDASetBlockFillsSparse(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDASetBlockFillsSparse, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDASetRefinementFactor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDASetRefinementFactor, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGetRefinementFactor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDAGetRefinementFactor, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGetArray(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAGetArray, $petsc_library), + PetscErrorCode, + (DM, PetscBool, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDARestoreArray(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDARestoreArray, $petsc_library), + PetscErrorCode, + (DM, PetscBool, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDACreatePF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMDACreatePF, $petsc_library), + PetscErrorCode, + (DM, Ptr{PF}), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetNumCells( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMDAGetNumCells, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMDAGetCellPoint( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMDAGetCellPoint, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMDAGetNumVertices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMDAGetNumVertices, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMDAGetNumFaces( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDAGetNumFaces, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDAGetHeightStratum( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDAGetHeightStratum, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAGetDepthStratum( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDAGetDepthStratum, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDAComputeCellGeometryFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDAComputeCellGeometryFEM, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + PetscQuadrature, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDAGetTransitiveClosure( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMDAGetTransitiveClosure, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscBool, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMDARestoreTransitiveClosure( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMDARestoreTransitiveClosure, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscBool, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMDASetVertexCoordinates( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMDASetVertexCoordinates, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMDASetPreallocationCenterDimension( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMDASetPreallocationCenterDimension, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMDAGetPreallocationCenterDimension( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMDAGetPreallocationCenterDimension, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMCompositeCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCompositeCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMCompositeAddDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCompositeAddDM, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMCompositeSetCoupling(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCompositeSetCoupling, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMCompositeAddVecScatter(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCompositeAddVecScatter, $petsc_library), + PetscErrorCode, + (DM, VecScatter), + arg1, + arg2, + ) +end + +@for_petsc function DMCompositeScatterArray(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMCompositeScatterArray, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCompositeGatherArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMCompositeGatherArray, $petsc_library), + PetscErrorCode, + (DM, InsertMode, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMCompositeGetNumberDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCompositeGetNumberDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMCompositeGetAccessArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMCompositeGetAccessArray, $petsc_library), + PetscErrorCode, + (DM, Vec, $PetscInt, Ptr{$PetscInt}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMCompositeRestoreAccessArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMCompositeRestoreAccessArray, $petsc_library), + PetscErrorCode, + (DM, Vec, $PetscInt, Ptr{$PetscInt}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMCompositeGetLocalAccessArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMCompositeGetLocalAccessArray, $petsc_library), + PetscErrorCode, + (DM, Vec, $PetscInt, Ptr{$PetscInt}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMCompositeRestoreLocalAccessArray( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMCompositeRestoreLocalAccessArray, $petsc_library), + PetscErrorCode, + (DM, Vec, $PetscInt, Ptr{$PetscInt}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMCompositeGetEntriesArray(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCompositeGetEntriesArray, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMCompositeGetGlobalISs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCompositeGetGlobalISs, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{IS}}), + arg1, + arg2, + ) +end + +@for_petsc function DMCompositeGetLocalISs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCompositeGetLocalISs, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{IS}}), + arg1, + arg2, + ) +end + +@for_petsc function DMCompositeGetISLocalToGlobalMappings( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMCompositeGetISLocalToGlobalMappings, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{ISLocalToGlobalMapping}}), + arg1, + arg2, + ) +end + +@for_petsc function DMPatchCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPatchCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMPatchSolve(::$UnionPetscLib, arg1) + @chk ccall((:DMPatchSolve, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMPatchGetCoarse(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPatchGetCoarse, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +mutable struct _p_PetscPartitioner end + +const PetscPartitioner = Ptr{_p_PetscPartitioner} + +@for_petsc function PetscPartitionerInitializePackage(::$UnionPetscLib) + @chk ccall( + (:PetscPartitionerInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscPartitionerFinalizePackage(::$UnionPetscLib) + @chk ccall( + (:PetscPartitionerFinalizePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +const PetscPartitionerType = Ptr{Cchar} + +@for_petsc function PetscPartitionerRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPartitionerRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPartitionerCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPartitionerCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscPartitioner}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPartitionerDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscPartitionerDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscPartitioner},), + arg1, + ) +end + +@for_petsc function PetscPartitionerSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPartitionerSetType, $petsc_library), + PetscErrorCode, + (PetscPartitioner, PetscPartitionerType), + arg1, + arg2, + ) +end + +@for_petsc function PetscPartitionerGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPartitionerGetType, $petsc_library), + PetscErrorCode, + (PetscPartitioner, Ptr{PetscPartitionerType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPartitionerSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscPartitionerSetUp, $petsc_library), + PetscErrorCode, + (PetscPartitioner,), + arg1, + ) +end + +@for_petsc function PetscPartitionerReset(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscPartitionerReset, $petsc_library), + PetscErrorCode, + (PetscPartitioner,), + arg1, + ) +end + +@for_petsc function PetscPartitionerSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscPartitionerSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscPartitioner,), + arg1, + ) +end + +@for_petsc function PetscPartitionerViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscPartitionerViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscPartitioner, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscPartitionerView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPartitionerView, $petsc_library), + PetscErrorCode, + (PetscPartitioner, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscPartitionerPartition( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscPartitionerPartition, $petsc_library), + PetscErrorCode, + ( + PetscPartitioner, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + PetscSection, + PetscSection, + PetscSection, + Ptr{IS}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscPartitionerShellSetPartition( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscPartitionerShellSetPartition, $petsc_library), + PetscErrorCode, + (PetscPartitioner, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscPartitionerShellSetRandom(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPartitionerShellSetRandom, $petsc_library), + PetscErrorCode, + (PetscPartitioner, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscPartitionerShellGetRandom(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscPartitionerShellGetRandom, $petsc_library), + PetscErrorCode, + (PetscPartitioner, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPartitionerMatPartitioningGetMatPartitioning( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscPartitionerMatPartitioningGetMatPartitioning, $petsc_library), + PetscErrorCode, + (PetscPartitioner, Ptr{MatPartitioning}), + arg1, + arg2, + ) +end + +mutable struct _p_DMPlexCellRefiner end + +const DMPlexCellRefiner = Ptr{_p_DMPlexCellRefiner} + +@enum DMPlexCellRefinerType::UInt32 begin + DM_REFINER_REGULAR = 0 + DM_REFINER_TO_BOX = 1 + DM_REFINER_TO_SIMPLEX = 2 + DM_REFINER_ALFELD2D = 3 + DM_REFINER_ALFELD3D = 4 + DM_REFINER_POWELL_SABIN = 5 + DM_REFINER_BOUNDARYLAYER = 6 + DM_REFINER_SBR = 7 +end + +mutable struct _p_PetscLimiter end + +const PetscLimiter = Ptr{_p_PetscLimiter} + +mutable struct _p_PetscFV end + +const PetscFV = Ptr{_p_PetscFV} + +const PetscLimiterType = Ptr{Cchar} + +@for_petsc function PetscLimiterCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLimiterCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscLimiter}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLimiterDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLimiterDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscLimiter},), + arg1, + ) +end + +@for_petsc function PetscLimiterSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLimiterSetType, $petsc_library), + PetscErrorCode, + (PetscLimiter, PetscLimiterType), + arg1, + arg2, + ) +end + +@for_petsc function PetscLimiterGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLimiterGetType, $petsc_library), + PetscErrorCode, + (PetscLimiter, Ptr{PetscLimiterType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLimiterSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLimiterSetUp, $petsc_library), + PetscErrorCode, + (PetscLimiter,), + arg1, + ) +end + +@for_petsc function PetscLimiterSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscLimiterSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscLimiter,), + arg1, + ) +end + +@for_petsc function PetscLimiterViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscLimiterViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscLimiter, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscLimiterView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLimiterView, $petsc_library), + PetscErrorCode, + (PetscLimiter, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscLimiterRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscLimiterRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscLimiterRegisterDestroy(::$UnionPetscLib) + @chk ccall( + (:PetscLimiterRegisterDestroy, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function PetscLimiterLimit(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscLimiterLimit, $petsc_library), + PetscErrorCode, + (PetscLimiter, $PetscReal, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFVInitializePackage(::$UnionPetscLib) + @chk ccall((:PetscFVInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +const PetscFVType = Ptr{Cchar} + +@for_petsc function PetscFVCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscFV}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFVDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscFV},), + arg1, + ) +end + +@for_petsc function PetscFVSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVSetType, $petsc_library), + PetscErrorCode, + (PetscFV, PetscFVType), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVGetType, $petsc_library), + PetscErrorCode, + (PetscFV, Ptr{PetscFVType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFVSetUp, $petsc_library), + PetscErrorCode, + (PetscFV,), + arg1, + ) +end + +@for_petsc function PetscFVSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscFVSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscFV,), + arg1, + ) +end + +@for_petsc function PetscFVViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscFVViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscFV, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFVView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVView, $petsc_library), + PetscErrorCode, + (PetscFV, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVRegisterDestroy(::$UnionPetscLib) + @chk ccall((:PetscFVRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscFVSetComponentName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscFVSetComponentName, $petsc_library), + PetscErrorCode, + (PetscFV, $PetscInt, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFVGetComponentName(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscFVGetComponentName, $petsc_library), + PetscErrorCode, + (PetscFV, $PetscInt, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscFVSetLimiter(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVSetLimiter, $petsc_library), + PetscErrorCode, + (PetscFV, PetscLimiter), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVGetLimiter(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVGetLimiter, $petsc_library), + PetscErrorCode, + (PetscFV, Ptr{PetscLimiter}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVSetNumComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVSetNumComponents, $petsc_library), + PetscErrorCode, + (PetscFV, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVGetNumComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVGetNumComponents, $petsc_library), + PetscErrorCode, + (PetscFV, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVSetSpatialDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVSetSpatialDimension, $petsc_library), + PetscErrorCode, + (PetscFV, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVGetSpatialDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVGetSpatialDimension, $petsc_library), + PetscErrorCode, + (PetscFV, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVSetComputeGradients(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVSetComputeGradients, $petsc_library), + PetscErrorCode, + (PetscFV, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVGetComputeGradients(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVGetComputeGradients, $petsc_library), + PetscErrorCode, + (PetscFV, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVSetQuadrature(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVSetQuadrature, $petsc_library), + PetscErrorCode, + (PetscFV, PetscQuadrature), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVGetQuadrature(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVGetQuadrature, $petsc_library), + PetscErrorCode, + (PetscFV, Ptr{PetscQuadrature}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVSetDualSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVSetDualSpace, $petsc_library), + PetscErrorCode, + (PetscFV, PetscDualSpace), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVGetDualSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVGetDualSpace, $petsc_library), + PetscErrorCode, + (PetscFV, Ptr{PetscDualSpace}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVRefine(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVRefine, $petsc_library), + PetscErrorCode, + (PetscFV, Ptr{PetscFV}), + arg1, + arg2, + ) +end + +@for_petsc function PetscFVComputeGradient( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscFVComputeGradient, $petsc_library), + PetscErrorCode, + (PetscFV, $PetscInt, Ptr{$PetscScalar}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscFVLeastSquaresSetMaxFaces(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscFVLeastSquaresSetMaxFaces, $petsc_library), + PetscErrorCode, + (PetscFV, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldInitializePackage(::$UnionPetscLib) + @chk ccall((:DMFieldInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function DMFieldFinalizePackage(::$UnionPetscLib) + @chk ccall((:DMFieldFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +const DMFieldType = Ptr{Cchar} + +@for_petsc function DMFieldSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldSetType, $petsc_library), + PetscErrorCode, + (DMField, DMFieldType), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldGetType, $petsc_library), + PetscErrorCode, + (DMField, Ptr{DMFieldType}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@enum DMFieldContinuity::UInt32 begin + DMFIELD_VERTEX = 0 + DMFIELD_EDGE = 1 + DMFIELD_FACET = 2 + DMFIELD_CELL = 3 +end + +@for_petsc function DMFieldDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:DMFieldDestroy, $petsc_library), + PetscErrorCode, + (Ptr{DMField},), + arg1, + ) +end + +@for_petsc function DMFieldView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldView, $petsc_library), + PetscErrorCode, + (DMField, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldGetDM, $petsc_library), + PetscErrorCode, + (DMField, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldGetNumComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldGetNumComponents, $petsc_library), + PetscErrorCode, + (DMField, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldGetContinuity(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldGetContinuity, $petsc_library), + PetscErrorCode, + (DMField, Ptr{DMFieldContinuity}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldEvaluate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMFieldEvaluate, $petsc_library), + PetscErrorCode, + (DMField, Vec, PetscDataType, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMFieldEvaluateFE( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMFieldEvaluateFE, $petsc_library), + PetscErrorCode, + ( + DMField, + IS, + PetscQuadrature, + PetscDataType, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMFieldEvaluateFV( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMFieldEvaluateFV, $petsc_library), + PetscErrorCode, + (DMField, IS, PetscDataType, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMFieldCreateDefaultQuadrature( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMFieldCreateDefaultQuadrature, $petsc_library), + PetscErrorCode, + (DMField, IS, Ptr{PetscQuadrature}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMFieldGetDegree(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMFieldGetDegree, $petsc_library), + PetscErrorCode, + (DMField, IS, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMFieldCreateDA(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMFieldCreateDA, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscScalar}, Ptr{DMField}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMFieldCreateDS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMFieldCreateDS, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Vec, Ptr{DMField}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMFieldCreateShell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMFieldCreateShell, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, DMFieldContinuity, Ptr{Cvoid}, Ptr{DMField}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMFieldShellSetDestroy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldShellSetDestroy, $petsc_library), + PetscErrorCode, + (DMField, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldShellGetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldShellGetContext, $petsc_library), + PetscErrorCode, + (DMField, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldShellSetEvaluate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldShellSetEvaluate, $petsc_library), + PetscErrorCode, + (DMField, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldShellSetEvaluateFE(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldShellSetEvaluateFE, $petsc_library), + PetscErrorCode, + (DMField, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldShellEvaluateFEDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMFieldShellEvaluateFEDefault, $petsc_library), + PetscErrorCode, + ( + DMField, + IS, + PetscQuadrature, + PetscDataType, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMFieldShellSetEvaluateFV(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldShellSetEvaluateFV, $petsc_library), + PetscErrorCode, + (DMField, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldShellEvaluateFVDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMFieldShellEvaluateFVDefault, $petsc_library), + PetscErrorCode, + (DMField, IS, PetscDataType, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMFieldShellSetGetDegree(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMFieldShellSetGetDegree, $petsc_library), + PetscErrorCode, + (DMField, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMFieldShellSetCreateDefaultQuadrature( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMFieldShellSetCreateDefaultQuadrature, $petsc_library), + PetscErrorCode, + (DMField, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscPartitionerDMPlexPartition( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscPartitionerDMPlexPartition, $petsc_library), + PetscErrorCode, + (PetscPartitioner, DM, PetscSection, PetscSection, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexBuildFromCellList( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexBuildFromCellList, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexBuildFromCellListParallel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexBuildFromCellListParallel, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{PetscSF}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexBuildCoordinatesFromCellList( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexBuildCoordinatesFromCellList, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexBuildCoordinatesFromCellListParallel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexBuildCoordinatesFromCellListParallel, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscSF, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreateCohesiveSubmesh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexCreateCohesiveSubmesh, $petsc_library), + PetscErrorCode, + (DM, PetscBool, Ptr{Cchar}, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexCreateFromCellListPetsc( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:DMPlexCreateFromCellListPetsc, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + PetscBool, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscReal}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function DMPlexCreateFromCellList( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:DMPlexCreateFromCellList, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + PetscBool, + Ptr{Cint}, + $PetscInt, + Ptr{Cdouble}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function DMPlexCreateFromCellListParallelPetsc( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, +) + @chk ccall( + (:DMPlexCreateFromCellListParallelPetsc, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + PetscBool, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscReal}, + Ptr{PetscSF}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + ) +end + +@for_petsc function DMPlexCreateFromCellListParallel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:DMPlexCreateFromCellListParallel, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + PetscBool, + Ptr{Cint}, + $PetscInt, + Ptr{$PetscReal}, + Ptr{PetscSF}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function DMPlexCreateFromDAG( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexCreateFromDAG, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscScalar}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexCreateReferenceCell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateReferenceCell, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateReferenceCellByType( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexCreateReferenceCellByType, $petsc_library), + PetscErrorCode, + (MPI_Comm, DMPolytopeType, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetChart(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetChart, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetChart(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetChart, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetConeSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetConeSize, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetConeSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetConeSize, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexAddConeSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexAddConeSize, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetCone(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetCone, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetConeTuple(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexGetConeTuple, $petsc_library), + PetscErrorCode, + (DM, IS, Ptr{PetscSection}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetConeRecursive( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGetConeRecursive, $petsc_library), + PetscErrorCode, + (DM, IS, Ptr{$PetscInt}, Ptr{Ptr{IS}}, Ptr{Ptr{PetscSection}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexRestoreConeRecursive( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexRestoreConeRecursive, $petsc_library), + PetscErrorCode, + (DM, IS, Ptr{$PetscInt}, Ptr{Ptr{IS}}, Ptr{Ptr{PetscSection}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGetConeRecursiveVertices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexGetConeRecursiveVertices, $petsc_library), + PetscErrorCode, + (DM, IS, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetCone(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetCone, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexInsertCone(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexInsertCone, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexInsertConeOrientation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexInsertConeOrientation, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetConeOrientation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetConeOrientation, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetConeOrientation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetConeOrientation, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetSupportSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetSupportSize, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetSupportSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetSupportSize, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetSupport(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetSupport, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetSupport(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetSupport, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexInsertSupport( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexInsertSupport, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetConeSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetConeSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetSupportSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetSupportSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetCones(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetCones, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetConeOrientations(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetConeOrientations, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetMaxSizes(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetMaxSizes, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSymmetrize(::$UnionPetscLib, arg1) + @chk ccall((:DMPlexSymmetrize, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMPlexStratify(::$UnionPetscLib, arg1) + @chk ccall((:DMPlexStratify, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMPlexEqual(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexEqual, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexReverseCell(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexReverseCell, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexOrientCell(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexOrientCell, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCompareOrientations( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexCompareOrientations, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexOrient(::$UnionPetscLib, arg1) + @chk ccall((:DMPlexOrient, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMPlexPreallocateOperator( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:DMPlexPreallocateOperator, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Mat, + PetscBool, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function DMPlexGetPointLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexGetPointLocal, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexPointLocalRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexPointLocalRead, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscScalar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexPointLocalRef( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexPointLocalRef, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscScalar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetPointLocalField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGetPointLocalField, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexPointLocalFieldRef( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexPointLocalFieldRef, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexPointLocalFieldRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexPointLocalFieldRead, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGetPointGlobal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexGetPointGlobal, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexPointGlobalRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexPointGlobalRead, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscScalar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexPointGlobalRef( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexPointGlobalRef, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscScalar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetPointGlobalField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGetPointGlobalField, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexPointGlobalFieldRef( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexPointGlobalFieldRef, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexPointGlobalFieldRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexPointGlobalFieldRead, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@enum DMPlexInterpolatedFlag::Int32 begin + DMPLEX_INTERPOLATED_INVALID = -1 + DMPLEX_INTERPOLATED_NONE = 0 + DMPLEX_INTERPOLATED_PARTIAL = 1 + DMPLEX_INTERPOLATED_MIXED = 2 + DMPLEX_INTERPOLATED_FULL = 3 +end + +@for_petsc function DMPlexInterpolate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexInterpolate, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexUninterpolate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexUninterpolate, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexInterpolatePointSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexInterpolatePointSF, $petsc_library), + PetscErrorCode, + (DM, PetscSF), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexIsInterpolated(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexIsInterpolated, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMPlexInterpolatedFlag}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexIsInterpolatedCollective(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexIsInterpolatedCollective, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMPlexInterpolatedFlag}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexFilter(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexFilter, $petsc_library), + PetscErrorCode, + (DM, DMLabel, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetCellNumbering(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetCellNumbering, $petsc_library), + PetscErrorCode, + (DM, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetVertexNumbering(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetVertexNumbering, $petsc_library), + PetscErrorCode, + (DM, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreatePointNumbering(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCreatePointNumbering, $petsc_library), + PetscErrorCode, + (DM, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreateRankField(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCreateRankField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreateLabelField(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexCreateLabelField, $petsc_library), + PetscErrorCode, + (DM, DMLabel, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetDepth(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetDepth, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetDepthLabel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetDepthLabel, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMLabel}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetDepthStratum( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexGetDepthStratum, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetHeightStratum( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexGetHeightStratum, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetPointDepth(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetPointDepth, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetPointHeight(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetPointHeight, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetCellTypeLabel(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetCellTypeLabel, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMLabel}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetCellType(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetCellType, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DMPolytopeType}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetCellType(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetCellType, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, DMPolytopeType), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexComputeCellTypes(::$UnionPetscLib, arg1) + @chk ccall( + (:DMPlexComputeCellTypes, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMPlexInvertCell(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexInvertCell, $petsc_library), + PetscErrorCode, + (DMPolytopeType, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexReorderCell(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexReorderCell, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetMeet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGetMeet, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGetFullMeet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGetFullMeet, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexRestoreMeet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexRestoreMeet, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGetJoin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGetJoin, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGetFullJoin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGetFullJoin, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexRestoreJoin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexRestoreJoin, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGetTransitiveClosure( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGetTransitiveClosure, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscBool, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexRestoreTransitiveClosure( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexRestoreTransitiveClosure, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscBool, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGenerate(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexGenerate, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGenerateRegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGenerateRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGenerateRegisterAll(::$UnionPetscLib) + @chk ccall((:DMPlexGenerateRegisterAll, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function DMPlexGenerateRegisterDestroy(::$UnionPetscLib) + @chk ccall( + (:DMPlexGenerateRegisterDestroy, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function DMPlexCopyCoordinates(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCopyCoordinates, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreateDoublet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexCreateDoublet, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, PetscBool, PetscBool, $PetscReal, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexCreateSquareBoundary( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateSquareBoundary, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateCubeBoundary( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateCubeBoundary, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateBoxMesh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMPlexCreateBoxMesh, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + PetscBool, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{DMBoundaryType}, + PetscBool, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMPlexCreateSphereMesh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexCreateSphereMesh, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, PetscBool, $PetscReal, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexCreateBallMesh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateBallMesh, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscReal, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateHexCylinderMesh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateHexCylinderMesh, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, DMBoundaryType, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateWedgeCylinderMesh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateWedgeCylinderMesh, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateWedgeBoxMesh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:DMPlexCreateWedgeBoxMesh, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{DMBoundaryType}, + PetscBool, + PetscBool, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function DMPlexExtrude( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexExtrude, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + $PetscReal, + PetscBool, + Ptr{$PetscReal}, + PetscBool, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexCreateConeSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCreateConeSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCheckSymmetry(::$UnionPetscLib, arg1) + @chk ccall( + (:DMPlexCheckSymmetry, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMPlexCheckSkeleton(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCheckSkeleton, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCheckFaces(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCheckFaces, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCheckGeometry(::$UnionPetscLib, arg1) + @chk ccall( + (:DMPlexCheckGeometry, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMPlexCheckPointSF(::$UnionPetscLib, arg1) + @chk ccall( + (:DMPlexCheckPointSF, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMPlexCheckInterfaceCones(::$UnionPetscLib, arg1) + @chk ccall( + (:DMPlexCheckInterfaceCones, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMPlexCheckCellShape(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexCheckCellShape, $petsc_library), + PetscErrorCode, + (DM, PetscBool, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexComputeOrthogonalQuality( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexComputeOrthogonalQuality, $petsc_library), + PetscErrorCode, + (DM, PetscFV, $PetscReal, Ptr{Vec}, Ptr{DMLabel}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexTriangleSetOptions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexTriangleSetOptions, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexTetgenSetOptions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexTetgenSetOptions, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreateFromFile( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateFromFile, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateExodus(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexCreateExodus, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateExodusFromFile( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateExodusFromFile, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateCGNS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexCreateCGNS, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateCGNSFromFile( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateCGNSFromFile, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateGmsh(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexCreateGmsh, $petsc_library), + PetscErrorCode, + (MPI_Comm, PetscViewer, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateGmshFromFile( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateGmshFromFile, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateFluent(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexCreateFluent, $petsc_library), + PetscErrorCode, + (MPI_Comm, PetscViewer, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateFluentFromFile( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateFluentFromFile, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateMedFromFile( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateMedFromFile, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreatePLYFromFile( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreatePLYFromFile, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateEGADSFromFile( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexCreateEGADSFromFile, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Cchar}, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscViewerExodusIIGetId(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscViewerExodusIIGetId, $petsc_library), + PetscErrorCode, + (PetscViewer, Ptr{Cint}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreateNeighborCSR( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexCreateNeighborCSR, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGetPartitioner(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetPartitioner, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscPartitioner}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetPartitioner(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetPartitioner, $petsc_library), + PetscErrorCode, + (DM, PetscPartitioner), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreatePartitionerGraph( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexCreatePartitionerGraph, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{IS}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexPartitionLabelInvert( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexPartitionLabelInvert, $petsc_library), + PetscErrorCode, + (DM, DMLabel, PetscSF, DMLabel), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexPartitionLabelClosure(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexPartitionLabelClosure, $petsc_library), + PetscErrorCode, + (DM, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexPartitionLabelAdjacency(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexPartitionLabelAdjacency, $petsc_library), + PetscErrorCode, + (DM, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexPartitionLabelPropagate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexPartitionLabelPropagate, $petsc_library), + PetscErrorCode, + (DM, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexPartitionLabelCreateSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexPartitionLabelCreateSF, $petsc_library), + PetscErrorCode, + (DM, DMLabel, Ptr{PetscSF}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetPartitionBalance(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetPartitionBalance, $petsc_library), + PetscErrorCode, + (DM, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetPartitionBalance(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetPartitionBalance, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexIsDistributed(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexIsDistributed, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexDistribute(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexDistribute, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{PetscSF}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexDistributeOverlap( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexDistributeOverlap, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{PetscSF}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetOverlap(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetOverlap, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexDistributeField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexDistributeField, $petsc_library), + PetscErrorCode, + (DM, PetscSF, PetscSection, Vec, PetscSection, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexDistributeFieldIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexDistributeFieldIS, $petsc_library), + PetscErrorCode, + (DM, PetscSF, PetscSection, IS, PetscSection, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexDistributeData( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexDistributeData, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSF, + PetscSection, + MPI_Datatype, + Ptr{Cvoid}, + PetscSection, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexRebalanceSharedPoints( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexRebalanceSharedPoints, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscBool, PetscBool, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexMigrate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexMigrate, $petsc_library), + PetscErrorCode, + (DM, PetscSF, DM), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetGatherDM(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetGatherDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSF}, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetRedundantDM(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetRedundantDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSF}, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetAdjacencyUser(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetAdjacencyUser, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetAdjacencyUser(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetAdjacencyUser, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetAdjacencyUseAnchors(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetAdjacencyUseAnchors, $petsc_library), + PetscErrorCode, + (DM, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetAdjacencyUseAnchors(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetAdjacencyUseAnchors, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetAdjacency(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexGetAdjacency, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexSetMigrationSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetMigrationSF, $petsc_library), + PetscErrorCode, + (DM, PetscSF), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetMigrationSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetMigrationSF, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSF}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetOrdering(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexGetOrdering, $petsc_library), + PetscErrorCode, + (DM, MatOrderingType, DMLabel, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexPermute(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexPermute, $petsc_library), + PetscErrorCode, + (DM, IS, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexCreateProcessSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateProcessSF, $petsc_library), + PetscErrorCode, + (DM, PetscSF, Ptr{IS}, Ptr{PetscSF}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateTwoSidedProcessSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:DMPlexCreateTwoSidedProcessSF, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSF, + PetscSection, + IS, + PetscSection, + IS, + Ptr{IS}, + Ptr{PetscSF}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function DMPlexDistributeOwnership( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexDistributeOwnership, $petsc_library), + PetscErrorCode, + (DM, PetscSection, Ptr{IS}, PetscSection, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexCreateOverlapLabel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexCreateOverlapLabel, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscSection, IS, PetscSection, IS, Ptr{DMLabel}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexCreateOverlapMigrationSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexCreateOverlapMigrationSF, $petsc_library), + PetscErrorCode, + (DM, PetscSF, Ptr{PetscSF}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexStratifyMigrationSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexStratifyMigrationSF, $petsc_library), + PetscErrorCode, + (DM, PetscSF, Ptr{PetscSF}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexCreateSubmesh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexCreateSubmesh, $petsc_library), + PetscErrorCode, + (DM, DMLabel, $PetscInt, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexCreateHybridMesh( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexCreateHybridMesh, $petsc_library), + PetscErrorCode, + (DM, DMLabel, DMLabel, Ptr{DMLabel}, Ptr{DMLabel}, Ptr{DM}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexGetSubpointMap(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetSubpointMap, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMLabel}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetSubpointMap(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetSubpointMap, $petsc_library), + PetscErrorCode, + (DM, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetSubpointIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetSubpointIS, $petsc_library), + PetscErrorCode, + (DM, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function DMGetEnclosureRelation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGetEnclosureRelation, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{DMEnclosureType}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGetEnclosurePoint( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMGetEnclosurePoint, $petsc_library), + PetscErrorCode, + (DM, DM, DMEnclosureType, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexLabelComplete(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexLabelComplete, $petsc_library), + PetscErrorCode, + (DM, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexLabelCohesiveComplete( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexLabelCohesiveComplete, $petsc_library), + PetscErrorCode, + (DM, DMLabel, DMLabel, PetscBool, DM), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexLabelAddCells(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexLabelAddCells, $petsc_library), + PetscErrorCode, + (DM, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexLabelAddFaceCells(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexLabelAddFaceCells, $petsc_library), + PetscErrorCode, + (DM, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexLabelClearCells(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexLabelClearCells, $petsc_library), + PetscErrorCode, + (DM, DMLabel), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetRefinementLimit(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetRefinementLimit, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetRefinementLimit(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetRefinementLimit, $petsc_library), + PetscErrorCode, + (DM, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetRefinementUniform(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetRefinementUniform, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetRefinementUniform(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetRefinementUniform, $petsc_library), + PetscErrorCode, + (DM, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetRefinementFunction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetRefinementFunction, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetRefinementFunction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetRefinementFunction, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreateCoarsePointIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCreateCoarsePointIS, $petsc_library), + PetscErrorCode, + (DM, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetRegularRefinement(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetRegularRefinement, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetRegularRefinement(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetRegularRefinement, $petsc_library), + PetscErrorCode, + (DM, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetCellRefinerType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetCellRefinerType, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMPlexCellRefinerType}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetCellRefinerType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetCellRefinerType, $petsc_library), + PetscErrorCode, + (DM, DMPlexCellRefinerType), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetNumFaceVertices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexGetNumFaceVertices, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetOrientedFace( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMPlexGetOrientedFace, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMPlexGetMinRadius(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetMinRadius, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetMinRadius(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetMinRadius, $petsc_library), + PetscErrorCode, + (DM, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexComputeProjection2Dto1D(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexComputeProjection2Dto1D, $petsc_library), + PetscErrorCode, + (Ptr{$PetscScalar}, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexComputeProjection3Dto1D(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexComputeProjection3Dto1D, $petsc_library), + PetscErrorCode, + (Ptr{$PetscScalar}, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexComputeProjection3Dto2D( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexComputeProjection3Dto2D, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{$PetscScalar}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +mutable struct _PetscGridHash end + +const PetscGridHash = Ptr{_PetscGridHash} + +@for_petsc function PetscGridHashCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscGridHashCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, Ptr{$PetscScalar}, Ptr{PetscGridHash}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscGridHashEnlarge(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscGridHashEnlarge, $petsc_library), + PetscErrorCode, + (PetscGridHash, Ptr{$PetscScalar}), + arg1, + arg2, + ) +end + +@for_petsc function PetscGridHashSetGrid(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscGridHashSetGrid, $petsc_library), + PetscErrorCode, + (PetscGridHash, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscGridHashGetEnclosingBox( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscGridHashGetEnclosingBox, $petsc_library), + PetscErrorCode, + ( + PetscGridHash, + $PetscInt, + Ptr{$PetscScalar}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscGridHashDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscGridHashDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscGridHash},), + arg1, + ) +end + +@for_petsc function DMPlexFindVertices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexFindVertices, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscReal}, $PetscReal, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexComputeCellGeometryFVM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexComputeCellGeometryFVM, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexComputeGeometryFVM(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexComputeGeometryFVM, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexComputeGradientFVM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexComputeGradientFVM, $petsc_library), + PetscErrorCode, + (DM, PetscFV, Vec, Vec, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexGetDataFVM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexGetDataFVM, $petsc_library), + PetscErrorCode, + (DM, PetscFV, Ptr{Vec}, Ptr{Vec}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexComputeGeometryFEM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexComputeGeometryFEM, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetGeometryFVM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexGetGeometryFVM, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}, Ptr{Vec}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetGradientDM(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetGradientDM, $petsc_library), + PetscErrorCode, + (DM, PetscFV, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexInsertBoundaryValues( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexInsertBoundaryValues, $petsc_library), + PetscErrorCode, + (DM, PetscBool, Vec, $PetscReal, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexInsertTimeDerivativeBoundaryValues( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexInsertTimeDerivativeBoundaryValues, $petsc_library), + PetscErrorCode, + (DM, PetscBool, Vec, $PetscReal, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexInsertBoundaryValuesEssential( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:DMPlexInsertBoundaryValuesEssential, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function DMPlexInsertBoundaryValuesEssentialField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, +) + @chk ccall( + (:DMPlexInsertBoundaryValuesEssentialField, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + Vec, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + ) +end + +@for_petsc function DMPlexInsertBoundaryValuesEssentialBdField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, +) + @chk ccall( + (:DMPlexInsertBoundaryValuesEssentialBdField, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + Vec, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + ) +end + +@for_petsc function DMPlexInsertBoundaryValuesRiemann( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, +) + @chk ccall( + (:DMPlexInsertBoundaryValuesRiemann, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + Vec, + Vec, + Vec, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + ) +end + +@for_petsc function DMPlexMarkBoundaryFaces(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexMarkBoundaryFaces, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, DMLabel), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexCreateSection( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:DMPlexCreateSection, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{DMLabel}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{IS}, + Ptr{IS}, + IS, + Ptr{PetscSection}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function DMPlexGetSubdomainSection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetSubdomainSection, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexComputeCellGeometryAffineFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexComputeCellGeometryAffineFEM, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexComputeCellGeometryFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexComputeCellGeometryFEM, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + PetscQuadrature, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexCoordinatesToReference( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexCoordinatesToReference, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexReferenceToCoordinates( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexReferenceToCoordinates, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexShearGeometry(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexShearGeometry, $petsc_library), + PetscErrorCode, + (DM, DMDirection, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexRemapGeometry(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexRemapGeometry, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexVecGetClosure( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexVecGetClosure, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSection, + Vec, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexVecRestoreClosure( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexVecRestoreClosure, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSection, + Vec, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexVecSetClosure( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexVecSetClosure, $petsc_library), + PetscErrorCode, + (DM, PetscSection, Vec, $PetscInt, Ptr{$PetscScalar}, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexMatSetClosure( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexMatSetClosure, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSection, + PetscSection, + Mat, + $PetscInt, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexMatSetClosureGeneral( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:DMPlexMatSetClosureGeneral, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSection, + PetscSection, + DM, + PetscSection, + PetscSection, + Mat, + $PetscInt, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function DMPlexGetClosureIndices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMPlexGetClosureIndices, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSection, + PetscSection, + $PetscInt, + PetscBool, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMPlexRestoreClosureIndices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMPlexRestoreClosureIndices, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSection, + PetscSection, + $PetscInt, + PetscBool, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMPlexMatSetClosureRefined( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:DMPlexMatSetClosureRefined, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSection, + PetscSection, + DM, + PetscSection, + PetscSection, + Mat, + $PetscInt, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function DMPlexMatGetClosureIndicesRefined( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMPlexMatGetClosureIndicesRefined, $petsc_library), + PetscErrorCode, + ( + DM, + PetscSection, + PetscSection, + DM, + PetscSection, + PetscSection, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMPlexCreateClosureIndex(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCreateClosureIndex, $petsc_library), + PetscErrorCode, + (DM, PetscSection), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetClosurePermutationTensor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexSetClosurePermutationTensor, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, PetscSection), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexConstructGhostCells( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexConstructGhostCells, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{$PetscInt}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexConstructCohesiveCells( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexConstructCohesiveCells, $petsc_library), + PetscErrorCode, + (DM, DMLabel, DMLabel, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetVTKCellHeight(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetVTKCellHeight, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetVTKCellHeight(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetVTKCellHeight, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexVTKWriteAll(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexVTKWriteAll, $petsc_library), + PetscErrorCode, + (PetscObject, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetGhostCellStratum( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexGetGhostCellStratum, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetSimplexOrBoxCells( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexGetSimplexOrBoxCells, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetCellFields( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:DMPlexGetCellFields, $petsc_library), + PetscErrorCode, + ( + DM, + IS, + Vec, + Vec, + Vec, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function DMPlexRestoreCellFields( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:DMPlexRestoreCellFields, $petsc_library), + PetscErrorCode, + ( + DM, + IS, + Vec, + Vec, + Vec, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function DMPlexGetFaceFields( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:DMPlexGetFaceFields, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + $PetscInt, + Vec, + Vec, + Vec, + Vec, + Vec, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function DMPlexRestoreFaceFields( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:DMPlexRestoreFaceFields, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + $PetscInt, + Vec, + Vec, + Vec, + Vec, + Vec, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function DMPlexGetScale(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetScale, $petsc_library), + PetscErrorCode, + (DM, PetscUnit, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetScale(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetScale, $petsc_library), + PetscErrorCode, + (DM, PetscUnit, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +mutable struct JacActionCtx + dm::DM + u::Vec + J::Mat + user::Ptr{Cvoid} + JacActionCtx() = new() +end + +@for_petsc function DMPlexSetMaxProjectionHeight(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetMaxProjectionHeight, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetMaxProjectionHeight(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetMaxProjectionHeight, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetActivePoint(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetActivePoint, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexSetActivePoint(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetActivePoint, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexProjectFieldLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexProjectFieldLocal, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Ptr{Cvoid}}, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexComputeL2DiffLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexComputeL2DiffLocal, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Vec, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexComputeL2FieldDiff( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexComputeL2FieldDiff, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Vec, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexComputeL2DiffVec( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexComputeL2DiffVec, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexComputeCellwiseIntegralFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexComputeCellwiseIntegralFEM, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexComputeIntegralFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexComputeIntegralFEM, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{$PetscScalar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexComputeBdIntegral( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:DMPlexComputeBdIntegral, $petsc_library), + PetscErrorCode, + ( + DM, + Vec, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{$PetscScalar}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function DMPlexComputeInterpolatorNested( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexComputeInterpolatorNested, $petsc_library), + PetscErrorCode, + (DM, DM, PetscBool, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexComputeInterpolatorGeneral( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexComputeInterpolatorGeneral, $petsc_library), + PetscErrorCode, + (DM, DM, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexComputeGradientClementInterpolant( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexComputeGradientClementInterpolant, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexComputeInjectorFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexComputeInjectorFEM, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{VecScatter}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexComputeMassMatrixNested( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexComputeMassMatrixNested, $petsc_library), + PetscErrorCode, + (DM, DM, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexComputeMassMatrixGeneral( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexComputeMassMatrixGeneral, $petsc_library), + PetscErrorCode, + (DM, DM, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCreateRigidBody(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexCreateRigidBody, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{MatNullSpace}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexCreateRigidBodies( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexCreateRigidBodies, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + DMLabel, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{MatNullSpace}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexSetSNESLocalFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexSetSNESLocalFEM, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexSNESComputeBoundaryFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexSNESComputeBoundaryFEM, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSNESComputeResidualFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexSNESComputeResidualFEM, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexSNESComputeJacobianFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexSNESComputeJacobianFEM, $petsc_library), + PetscErrorCode, + (DM, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexComputeJacobianAction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMPlexComputeJacobianAction, $petsc_library), + PetscErrorCode, + (DM, IS, $PetscReal, $PetscReal, Vec, Vec, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMPlexComputeBdResidualSingle( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMPlexComputeBdResidualSingle, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Vec, + Vec, + Vec, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMPlexComputeBdJacobianSingle( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:DMPlexComputeBdJacobianSingle, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + DMLabel, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Vec, + Vec, + $PetscReal, + Mat, + Mat, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function DMPlexTSComputeBoundary( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexTSComputeBoundary, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexTSComputeRHSFunctionFVM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexTSComputeRHSFunctionFVM, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexTSComputeIFunctionFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexTSComputeIFunctionFEM, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Vec, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexTSComputeIJacobianFEM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:DMPlexTSComputeIJacobianFEM, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Vec, Vec, $PetscReal, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function DMPlexComputeRHSFunctionFVM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMPlexComputeRHSFunctionFVM, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMPlexReconstructGradientsFVM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexReconstructGradientsFVM, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGetAnchors(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGetAnchors, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSection}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetAnchors(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexSetAnchors, $petsc_library), + PetscErrorCode, + (DM, PetscSection, IS), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexSetReferenceTree(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetReferenceTree, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetReferenceTree(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetReferenceTree, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexReferenceTreeGetChildSymmetry( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:DMPlexReferenceTreeGetChildSymmetry, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function DMPlexCreateDefaultReferenceTree( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateDefaultReferenceTree, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, PetscBool, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexSetTree(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexSetTree, $petsc_library), + PetscErrorCode, + (DM, PetscSection, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetTree( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexGetTree, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{PetscSection}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{PetscSection}, + Ptr{Ptr{$PetscInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexGetTreeParent( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexGetTreeParent, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGetTreeChildren( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexGetTreeChildren, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexTreeRefineCell(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexTreeRefineCell, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexComputeInjectorReferenceTree( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMPlexComputeInjectorReferenceTree, $petsc_library), + PetscErrorCode, + (DM, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexTransferVecTree( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:DMPlexTransferVecTree, $petsc_library), + PetscErrorCode, + ( + DM, + Vec, + DM, + Vec, + PetscSF, + PetscSF, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + PetscBool, + $PetscReal, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function DMPlexMonitorThroughput(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexMonitorThroughput, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreateGlobalToNaturalSF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateGlobalToNaturalSF, $petsc_library), + PetscErrorCode, + (DM, PetscSection, PetscSF, Ptr{PetscSF}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexSetGlobalToNaturalSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexSetGlobalToNaturalSF, $petsc_library), + PetscErrorCode, + (DM, PetscSF), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGetGlobalToNaturalSF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGetGlobalToNaturalSF, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscSF}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexGlobalToNaturalBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexGlobalToNaturalBegin, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexGlobalToNaturalEnd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexGlobalToNaturalEnd, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexNaturalToGlobalBegin( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMPlexNaturalToGlobalBegin, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexNaturalToGlobalEnd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexNaturalToGlobalEnd, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexAdapt(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMPlexAdapt, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cchar}, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexSnapToGeomModel( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexSnapToGeomModel, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscScalar}, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexGlobalToLocalBasis(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexGlobalToLocalBasis, $petsc_library), + PetscErrorCode, + (DM, Vec), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexLocalToGlobalBasis(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexLocalToGlobalBasis, $petsc_library), + PetscErrorCode, + (DM, Vec), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCreateBasisRotation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexCreateBasisRotation, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMPlexCellRefinerCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPlexCellRefinerCreate, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMPlexCellRefiner}), + arg1, + arg2, + ) +end + +@for_petsc function DMPlexCellRefinerSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:DMPlexCellRefinerSetUp, $petsc_library), + PetscErrorCode, + (DMPlexCellRefiner,), + arg1, + ) +end + +@for_petsc function DMPlexCellRefinerDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:DMPlexCellRefinerDestroy, $petsc_library), + PetscErrorCode, + (Ptr{DMPlexCellRefiner},), + arg1, + ) +end + +@for_petsc function DMPlexCellRefinerRefine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMPlexCellRefinerRefine, $petsc_library), + PetscErrorCode, + ( + DMPlexCellRefiner, + DMPolytopeType, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Ptr{DMPolytopeType}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMPlexCellRefinerGetAffineTransforms( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPlexCellRefinerGetAffineTransforms, $petsc_library), + PetscErrorCode, + ( + DMPlexCellRefiner, + DMPolytopeType, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMPlexCellRefinerGetAffineFaceTransforms( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPlexCellRefinerGetAffineFaceTransforms, $petsc_library), + PetscErrorCode, + ( + DMPlexCellRefiner, + DMPolytopeType, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMPlexRefineUniform(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMPlexRefineUniform, $petsc_library), + PetscErrorCode, + (DM, DMPlexCellRefiner, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMRedundantCreate(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMRedundantCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, PetscMPIInt, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMRedundantSetSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMRedundantSetSize, $petsc_library), + PetscErrorCode, + (DM, PetscMPIInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMRedundantGetSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMRedundantGetSize, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscMPIInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMShellCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetContext, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellGetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellGetContext, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetMatrix, $petsc_library), + PetscErrorCode, + (DM, Mat), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetGlobalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetGlobalVector, $petsc_library), + PetscErrorCode, + (DM, Vec), + arg1, + arg2, + ) +end + +@for_petsc function DMShellGetGlobalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellGetGlobalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetLocalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetLocalVector, $petsc_library), + PetscErrorCode, + (DM, Vec), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateGlobalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetCreateGlobalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateLocalVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetCreateLocalVector, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetGlobalToLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMShellSetGlobalToLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMShellSetGlobalToLocalVecScatter( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMShellSetGlobalToLocalVecScatter, $petsc_library), + PetscErrorCode, + (DM, VecScatter), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetLocalToGlobal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMShellSetLocalToGlobal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMShellSetLocalToGlobalVecScatter( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMShellSetLocalToGlobalVecScatter, $petsc_library), + PetscErrorCode, + (DM, VecScatter), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetLocalToLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMShellSetLocalToLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMShellSetLocalToLocalVecScatter( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMShellSetLocalToLocalVecScatter, $petsc_library), + PetscErrorCode, + (DM, VecScatter), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetCreateMatrix, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCoarsen(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetCoarsen, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellGetCoarsen(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellGetCoarsen, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetRefine(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetRefine, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellGetRefine(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellGetRefine, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateInterpolation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetCreateInterpolation, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellGetCreateInterpolation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellGetCreateInterpolation, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateRestriction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetCreateRestriction, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellGetCreateRestriction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellGetCreateRestriction, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateInjection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetCreateInjection, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellGetCreateInjection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellGetCreateInjection, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateFieldDecomposition( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMShellSetCreateFieldDecomposition, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateDomainDecomposition( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMShellSetCreateDomainDecomposition, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateDomainDecompositionScatters( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMShellSetCreateDomainDecompositionScatters, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellSetCreateSubDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellSetCreateSubDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function DMShellGetCreateSubDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMShellGetCreateSubDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function DMGlobalToLocalBeginDefaultShell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMGlobalToLocalBeginDefaultShell, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMGlobalToLocalEndDefaultShell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMGlobalToLocalEndDefaultShell, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToGlobalBeginDefaultShell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLocalToGlobalBeginDefaultShell, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToGlobalEndDefaultShell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLocalToGlobalEndDefaultShell, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToLocalBeginDefaultShell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLocalToLocalBeginDefaultShell, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMLocalToLocalEndDefaultShell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMLocalToLocalEndDefaultShell, $petsc_library), + PetscErrorCode, + (DM, Vec, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSlicedCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:DMSlicedCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function DMSlicedSetPreallocation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSlicedSetPreallocation, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSlicedSetBlockFills(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSlicedSetBlockFills, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSlicedSetGhosts( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSlicedSetGhosts, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@enum DMSwarmType::UInt32 begin + DMSWARM_BASIC = 0 + DMSWARM_PIC = 1 +end + +@enum DMSwarmMigrateType::UInt32 begin + DMSWARM_MIGRATE_BASIC = 0 + DMSWARM_MIGRATE_DMCELLNSCATTER = 1 + DMSWARM_MIGRATE_DMCELLEXACT = 2 + DMSWARM_MIGRATE_USER = 3 +end + +@enum DMSwarmCollectType::UInt32 begin + DMSWARM_COLLECT_BASIC = 0 + DMSWARM_COLLECT_DMDABOUNDINGBOX = 1 + DMSWARM_COLLECT_GENERAL = 2 + DMSWARM_COLLECT_USER = 3 +end + +@enum DMSwarmPICLayoutType::UInt32 begin + DMSWARMPIC_LAYOUT_REGULAR = 0 + DMSWARMPIC_LAYOUT_GAUSS = 1 + DMSWARMPIC_LAYOUT_SUBDIVISION = 2 +end + +@for_petsc function DMSwarmCreateGlobalVectorFromField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSwarmCreateGlobalVectorFromField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmDestroyGlobalVectorFromField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSwarmDestroyGlobalVectorFromField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmCreateLocalVectorFromField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSwarmCreateLocalVectorFromField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmDestroyLocalVectorFromField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSwarmDestroyLocalVectorFromField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmInitializeFieldRegister(::$UnionPetscLib, arg1) + @chk ccall( + (:DMSwarmInitializeFieldRegister, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMSwarmFinalizeFieldRegister(::$UnionPetscLib, arg1) + @chk ccall( + (:DMSwarmFinalizeFieldRegister, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMSwarmSetLocalSizes(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSwarmSetLocalSizes, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmRegisterPetscDatatypeField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMSwarmRegisterPetscDatatypeField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscInt, PetscDataType), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSwarmRegisterUserStructField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSwarmRegisterUserStructField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Csize_t), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmRegisterUserDatatypeField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMSwarmRegisterUserDatatypeField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Csize_t, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSwarmGetField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSwarmGetField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{$PetscInt}, Ptr{PetscDataType}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSwarmRestoreField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSwarmRestoreField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, Ptr{$PetscInt}, Ptr{PetscDataType}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSwarmVectorDefineField(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmVectorDefineField, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmAddPoint(::$UnionPetscLib, arg1) + @chk ccall((:DMSwarmAddPoint, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMSwarmAddNPoints(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmAddNPoints, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmRemovePoint(::$UnionPetscLib, arg1) + @chk ccall( + (:DMSwarmRemovePoint, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMSwarmRemovePointAtIndex(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmRemovePointAtIndex, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmCopyPoint(::$UnionPetscLib, dm, arg2, arg3) + @chk ccall( + (:DMSwarmCopyPoint, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt), + dm, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmGetLocalSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmGetLocalSize, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmGetSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmGetSize, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmMigrate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmMigrate, $petsc_library), + PetscErrorCode, + (DM, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmCollectViewCreate(::$UnionPetscLib, arg1) + @chk ccall( + (:DMSwarmCollectViewCreate, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMSwarmCollectViewDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:DMSwarmCollectViewDestroy, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMSwarmSetCellDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmSetCellDM, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmGetCellDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmGetCellDM, $petsc_library), + PetscErrorCode, + (DM, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmSetType, $petsc_library), + PetscErrorCode, + (DM, DMSwarmType), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmSetPointsUniformCoordinates( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSwarmSetPointsUniformCoordinates, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscInt}, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSwarmSetPointCoordinates( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSwarmSetPointCoordinates, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscReal}, PetscBool, InsertMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSwarmInsertPointsUsingCellDM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSwarmInsertPointsUsingCellDM, $petsc_library), + PetscErrorCode, + (DM, DMSwarmPICLayoutType, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmSetPointCoordinatesCellwise( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSwarmSetPointCoordinatesCellwise, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmSetPointCoordinatesRandom( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:DMSwarmSetPointCoordinatesRandom, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmViewFieldsXDMF( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMSwarmViewFieldsXDMF, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}, $PetscInt, Ptr{Ptr{Cchar}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSwarmViewXDMF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmViewXDMF, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmSortGetAccess(::$UnionPetscLib, arg1) + @chk ccall( + (:DMSwarmSortGetAccess, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMSwarmSortRestoreAccess(::$UnionPetscLib, arg1) + @chk ccall( + (:DMSwarmSortRestoreAccess, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMSwarmSortGetPointsPerCell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMSwarmSortGetPointsPerCell, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSwarmSortGetNumberOfPointsPerCell( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSwarmSortGetNumberOfPointsPerCell, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmSortGetIsValid(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSwarmSortGetIsValid, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMSwarmSortGetSizes(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSwarmSortGetSizes, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSwarmProjectFields( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSwarmProjectFields, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{Ptr{Cchar}}, Ptr{Ptr{Vec}}, PetscBool), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSwarmCreateMassMatrixSquare( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMSwarmCreateMassMatrixSquare, $petsc_library), + PetscErrorCode, + (DM, DM, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCreate_Product(::$UnionPetscLib, arg1) + @chk ccall((:DMCreate_Product, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMProductGetDM(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMProductGetDM, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMProductSetDimensionIndex( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMProductSetDimensionIndex, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMProductSetDM(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMProductSetDM, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, DM), + arg1, + arg2, + arg3, + ) +end + +@enum DMStagStencilLocation::UInt32 begin + DMSTAG_NULL_LOCATION = 0 + DMSTAG_BACK_DOWN_LEFT = 1 + DMSTAG_BACK_DOWN = 2 + DMSTAG_BACK_DOWN_RIGHT = 3 + DMSTAG_BACK_LEFT = 4 + DMSTAG_BACK = 5 + DMSTAG_BACK_RIGHT = 6 + DMSTAG_BACK_UP_LEFT = 7 + DMSTAG_BACK_UP = 8 + DMSTAG_BACK_UP_RIGHT = 9 + DMSTAG_DOWN_LEFT = 10 + DMSTAG_DOWN = 11 + DMSTAG_DOWN_RIGHT = 12 + DMSTAG_LEFT = 13 + DMSTAG_ELEMENT = 14 + DMSTAG_RIGHT = 15 + DMSTAG_UP_LEFT = 16 + DMSTAG_UP = 17 + DMSTAG_UP_RIGHT = 18 + DMSTAG_FRONT_DOWN_LEFT = 19 + DMSTAG_FRONT_DOWN = 20 + DMSTAG_FRONT_DOWN_RIGHT = 21 + DMSTAG_FRONT_LEFT = 22 + DMSTAG_FRONT = 23 + DMSTAG_FRONT_RIGHT = 24 + DMSTAG_FRONT_UP_LEFT = 25 + DMSTAG_FRONT_UP = 26 + DMSTAG_FRONT_UP_RIGHT = 27 +end + +@enum DMStagStencilType::UInt32 begin + DMSTAG_STENCIL_NONE = 0 + DMSTAG_STENCIL_STAR = 1 + DMSTAG_STENCIL_BOX = 2 +end + +@for_petsc function DMCreate_Stag(::$UnionPetscLib, arg1) + @chk ccall((:DMCreate_Stag, $petsc_library), PetscErrorCode, (DM,), arg1) +end + +@for_petsc function DMStagCreate1d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMStagCreate1d, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + DMBoundaryType, + $PetscInt, + $PetscInt, + $PetscInt, + DMStagStencilType, + $PetscInt, + Ptr{$PetscInt}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMStagCreate2d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, +) + @chk ccall( + (:DMStagCreate2d, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + DMBoundaryType, + DMBoundaryType, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + DMStagStencilType, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + ) +end + +@for_petsc function DMStagCreate3d( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, +) + @chk ccall( + (:DMStagCreate3d, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + DMBoundaryType, + DMBoundaryType, + DMBoundaryType, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + DMStagStencilType, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + ) +end + +@for_petsc function DMStagCreateCompatibleDMStag( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMStagCreateCompatibleDMStag, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt, $PetscInt, Ptr{DM}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMStagGetBoundaryTypes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagGetBoundaryTypes, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMBoundaryType}, Ptr{DMBoundaryType}, Ptr{DMBoundaryType}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetCorners( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:DMStagGetCorners, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function DMStagGetDOF(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:DMStagGetDOF, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMStagGetEntries(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMStagGetEntries, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMStagGetEntriesPerElement(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMStagGetEntriesPerElement, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMStagGetGhostCorners( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMStagGetGhostCorners, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMStagGetGlobalSizes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagGetGlobalSizes, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetIsFirstRank( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagGetIsFirstRank, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetIsLastRank( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagGetIsLastRank, $petsc_library), + PetscErrorCode, + (DM, Ptr{PetscBool}, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetLocalSizes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagGetLocalSizes, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetLocationDOF(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMStagGetLocationDOF, $petsc_library), + PetscErrorCode, + (DM, DMStagStencilLocation, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMStagGetLocationSlot( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagGetLocationSlot, $petsc_library), + PetscErrorCode, + (DM, DMStagStencilLocation, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetNumRanks(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMStagGetNumRanks, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetOwnershipRanges( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagGetOwnershipRanges, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{$PetscInt}}, Ptr{Ptr{$PetscInt}}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetProductCoordinateArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagGetProductCoordinateArrays, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetProductCoordinateArraysRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagGetProductCoordinateArraysRead, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagGetProductCoordinateLocationSlot( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMStagGetProductCoordinateLocationSlot, $petsc_library), + PetscErrorCode, + (DM, DMStagStencilLocation, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMStagGetStencilType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMStagGetStencilType, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMStagStencilType}), + arg1, + arg2, + ) +end + +@for_petsc function DMStagGetStencilWidth(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMStagGetStencilWidth, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMStagMigrateVec(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMStagMigrateVec, $petsc_library), + PetscErrorCode, + (DM, Vec, DM, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagPopulateLocalToGlobalInjective(::$UnionPetscLib, arg1) + @chk ccall( + (:DMStagPopulateLocalToGlobalInjective, $petsc_library), + PetscErrorCode, + (DM,), + arg1, + ) +end + +@for_petsc function DMStagRestoreProductCoordinateArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagRestoreProductCoordinateArrays, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagRestoreProductCoordinateArraysRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagRestoreProductCoordinateArraysRead, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagSetBoundaryTypes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagSetBoundaryTypes, $petsc_library), + PetscErrorCode, + (DM, DMBoundaryType, DMBoundaryType, DMBoundaryType), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagSetCoordinateDMType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMStagSetCoordinateDMType, $petsc_library), + PetscErrorCode, + (DM, DMType), + arg1, + arg2, + ) +end + +@for_petsc function DMStagSetDOF(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:DMStagSetDOF, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMStagSetGlobalSizes( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagSetGlobalSizes, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagSetNumRanks(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMStagSetNumRanks, $petsc_library), + PetscErrorCode, + (DM, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagSetOwnershipRanges( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMStagSetOwnershipRanges, $petsc_library), + PetscErrorCode, + (DM, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMStagSetStencilType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMStagSetStencilType, $petsc_library), + PetscErrorCode, + (DM, DMStagStencilType), + arg1, + arg2, + ) +end + +@for_petsc function DMStagSetStencilWidth(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMStagSetStencilWidth, $petsc_library), + PetscErrorCode, + (DM, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function DMStagSetUniformCoordinates( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMStagSetUniformCoordinates, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMStagSetUniformCoordinatesExplicit( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMStagSetUniformCoordinatesExplicit, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMStagSetUniformCoordinatesProduct( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMStagSetUniformCoordinatesProduct, $petsc_library), + PetscErrorCode, + ( + DM, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function DMStagVecGetArray(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMStagVecGetArray, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMStagVecGetArrayRead(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMStagVecGetArrayRead, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMStagVecRestoreArray(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMStagVecRestoreArray, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMStagVecRestoreArrayRead( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMStagVecRestoreArrayRead, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMStagVecSplitToDMDA( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMStagVecSplitToDMDA, $petsc_library), + PetscErrorCode, + (DM, Vec, DMStagStencilLocation, $PetscInt, Ptr{DM}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMStagGet1dCoordinateArraysDOFRead( + ::$UnionPetscLib, + dm, + ax, + ay, + az, +) + @chk ccall( + (:DMStagGet1dCoordinateArraysDOFRead, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + dm, + ax, + ay, + az, + ) +end + +@for_petsc function DMStagGet1dCoordinateLocationSlot( + ::$UnionPetscLib, + dm, + loc, + s, +) + @chk ccall( + (:DMStagGet1dCoordinateLocationSlot, $petsc_library), + PetscErrorCode, + (DM, DMStagStencilLocation, Ptr{$PetscInt}), + dm, + loc, + s, + ) +end + +@for_petsc function DMStagGetGhostType(::$UnionPetscLib, dm, s) + @chk ccall( + (:DMStagGetGhostType, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMStagStencilType}), + dm, + s, + ) +end + +@for_petsc function DMStagRestore1dCoordinateArraysDOFRead( + ::$UnionPetscLib, + dm, + ax, + ay, + az, +) + @chk ccall( + (:DMStagRestore1dCoordinateArraysDOFRead, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + dm, + ax, + ay, + az, + ) +end + +@for_petsc function DMStagSetGhostType(::$UnionPetscLib, dm, s) + @chk ccall( + (:DMStagSetGhostType, $petsc_library), + PetscErrorCode, + (DM, Ptr{DMStagStencilType}), + dm, + s, + ) +end + +@for_petsc function DMStagVecGetArrayDOF(::$UnionPetscLib, dm, v, a) + @chk ccall( + (:DMStagVecGetArrayDOF, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + dm, + v, + a, + ) +end + +@for_petsc function DMStagVecGetArrayDOFRead(::$UnionPetscLib, dm, v, a) + @chk ccall( + (:DMStagVecGetArrayDOFRead, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + dm, + v, + a, + ) +end + +@for_petsc function DMStagVecRestoreArrayDOF(::$UnionPetscLib, dm, v, a) + @chk ccall( + (:DMStagVecRestoreArrayDOF, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + dm, + v, + a, + ) +end + +@for_petsc function DMStagVecRestoreArrayDOFRead(::$UnionPetscLib, dm, v, a) + @chk ccall( + (:DMStagVecRestoreArrayDOFRead, $petsc_library), + PetscErrorCode, + (DM, Vec, Ptr{Cvoid}), + dm, + v, + a, + ) +end + +@for_petsc function PetscWeakFormCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscWeakFormCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscWeakForm}), + arg1, + arg2, + ) +end + +@for_petsc function PetscWeakFormDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscWeakFormDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscWeakForm},), + arg1, + ) +end + +@for_petsc function PetscWeakFormView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscWeakFormView, $petsc_library), + PetscErrorCode, + (PetscWeakForm, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscWeakFormGetNumFields(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscWeakFormGetNumFields, $petsc_library), + PetscErrorCode, + (PetscWeakForm, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscWeakFormSetNumFields(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscWeakFormSetNumFields, $petsc_library), + PetscErrorCode, + (PetscWeakForm, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscWeakFormGetObjective( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscWeakFormGetObjective, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscWeakFormAddObjective( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscWeakFormAddObjective, $petsc_library), + PetscErrorCode, + (PetscWeakForm, DMLabel, $PetscInt, $PetscInt, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscWeakFormSetObjective( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscWeakFormSetObjective, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscWeakFormGetIndexObjective( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscWeakFormGetIndexObjective, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscWeakFormSetIndexObjective( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscWeakFormSetIndexObjective, $petsc_library), + PetscErrorCode, + (PetscWeakForm, DMLabel, $PetscInt, $PetscInt, $PetscInt, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscWeakFormGetResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscWeakFormGetResidual, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscWeakFormAddResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscWeakFormAddResidual, $petsc_library), + PetscErrorCode, + (PetscWeakForm, DMLabel, $PetscInt, $PetscInt, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscWeakFormSetResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscWeakFormSetResidual, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscWeakFormSetIndexResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscWeakFormSetIndexResidual, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscWeakFormHasJacobian(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscWeakFormHasJacobian, $petsc_library), + PetscErrorCode, + (PetscWeakForm, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscWeakFormGetJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormGetJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormAddJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscWeakFormAddJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscWeakFormSetJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormSetIndexJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetIndexJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormHasJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscWeakFormHasJacobianPreconditioner, $petsc_library), + PetscErrorCode, + (PetscWeakForm, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscWeakFormGetJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormGetJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormAddJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscWeakFormAddJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscWeakFormSetJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormSetIndexJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetIndexJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormHasDynamicJacobian( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscWeakFormHasDynamicJacobian, $petsc_library), + PetscErrorCode, + (PetscWeakForm, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscWeakFormGetDynamicJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormGetDynamicJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormAddDynamicJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscWeakFormAddDynamicJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscWeakFormSetDynamicJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetDynamicJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormSetIndexDynamicJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetIndexDynamicJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormGetBdResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscWeakFormGetBdResidual, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscWeakFormAddBdResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscWeakFormAddBdResidual, $petsc_library), + PetscErrorCode, + (PetscWeakForm, DMLabel, $PetscInt, $PetscInt, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscWeakFormSetBdResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscWeakFormSetBdResidual, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscWeakFormSetIndexBdResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:PetscWeakFormSetIndexBdResidual, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function PetscWeakFormHasBdJacobian(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscWeakFormHasBdJacobian, $petsc_library), + PetscErrorCode, + (PetscWeakForm, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscWeakFormGetBdJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormGetBdJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormAddBdJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscWeakFormAddBdJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscWeakFormSetBdJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetBdJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormSetIndexBdJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetIndexBdJacobian, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormHasBdJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscWeakFormHasBdJacobianPreconditioner, $petsc_library), + PetscErrorCode, + (PetscWeakForm, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscWeakFormGetBdJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormGetBdJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormAddBdJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PetscWeakFormAddBdJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PetscWeakFormSetBdJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetBdJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormSetIndexBdJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscWeakFormSetIndexBdJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + $PetscInt, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscWeakFormGetRiemannSolver( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscWeakFormGetRiemannSolver, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{Ptr{Cvoid}}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscWeakFormSetRiemannSolver( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscWeakFormSetRiemannSolver, $petsc_library), + PetscErrorCode, + ( + PetscWeakForm, + DMLabel, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscWeakFormSetIndexRiemannSolver( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscWeakFormSetIndexRiemannSolver, $petsc_library), + PetscErrorCode, + (PetscWeakForm, DMLabel, $PetscInt, $PetscInt, $PetscInt, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDSInitializePackage(::$UnionPetscLib) + @chk ccall((:PetscDSInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +const PetscDSType = Ptr{Cchar} + +@enum PetscDiscType::UInt32 begin + PETSC_DISC_NONE = 0 + PETSC_DISC_FE = 1 + PETSC_DISC_FV = 2 +end + +# typedef void ( * PetscPointFunc ) ( PetscInt , PetscInt , PetscInt , const PetscInt [ ] , const PetscInt [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscInt [ ] , const PetscInt [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscScalar [ ] , PetscReal , const PetscReal [ ] , PetscInt , const PetscScalar [ ] , PetscScalar [ ] ) +const PetscPointFunc = Ptr{Cvoid} + +# typedef void ( * PetscPointJac ) ( PetscInt , PetscInt , PetscInt , const PetscInt [ ] , const PetscInt [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscInt [ ] , const PetscInt [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscScalar [ ] , PetscReal , PetscReal , const PetscReal [ ] , PetscInt , const PetscScalar [ ] , PetscScalar [ ] ) +const PetscPointJac = Ptr{Cvoid} + +# typedef void ( * PetscBdPointFunc ) ( PetscInt , PetscInt , PetscInt , const PetscInt [ ] , const PetscInt [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscInt [ ] , const PetscInt [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscScalar [ ] , PetscReal , const PetscReal [ ] , const PetscReal [ ] , PetscInt , const PetscScalar [ ] , PetscScalar [ ] ) +const PetscBdPointFunc = Ptr{Cvoid} + +# typedef void ( * PetscBdPointJac ) ( PetscInt , PetscInt , PetscInt , const PetscInt [ ] , const PetscInt [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscInt [ ] , const PetscInt [ ] , const PetscScalar [ ] , const PetscScalar [ ] , const PetscScalar [ ] , PetscReal , PetscReal , const PetscReal [ ] , const PetscReal [ ] , PetscInt , const PetscScalar [ ] , PetscScalar [ ] ) +const PetscBdPointJac = Ptr{Cvoid} + +# typedef void ( * PetscRiemannFunc ) ( PetscInt , PetscInt , const PetscReal [ ] , const PetscReal [ ] , const PetscScalar [ ] , const PetscScalar [ ] , PetscInt , const PetscScalar [ ] , PetscScalar [ ] , void * ) +const PetscRiemannFunc = Ptr{Cvoid} + +# typedef PetscErrorCode ( * PetscSimplePointFunc ) ( PetscInt , PetscReal , const PetscReal [ ] , PetscInt , PetscScalar [ ] , void * ) +const PetscSimplePointFunc = Ptr{Cvoid} + +@for_petsc function PetscDSCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscDS}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDSDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscDS},), + arg1, + ) +end + +@for_petsc function PetscDSSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSSetType, $petsc_library), + PetscErrorCode, + (PetscDS, PetscDSType), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetType, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{PetscDSType}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDSSetUp, $petsc_library), + PetscErrorCode, + (PetscDS,), + arg1, + ) +end + +@for_petsc function PetscDSSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscDSSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscDS,), + arg1, + ) +end + +@for_petsc function PetscDSViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSViewFromOptions, $petsc_library), + PetscErrorCode, + (PetscDS, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSView, $petsc_library), + PetscErrorCode, + (PetscDS, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSRegisterDestroy(::$UnionPetscLib) + @chk ccall((:PetscDSRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PetscDSGetHeightSubspace(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetHeightSubspace, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{PetscDS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetSpatialDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetSpatialDimension, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetCoordinateDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetCoordinateDimension, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSSetCoordinateDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSSetCoordinateDimension, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetHybrid(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetHybrid, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSSetHybrid(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSSetHybrid, $petsc_library), + PetscErrorCode, + (PetscDS, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetNumFields(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetNumFields, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetTotalDimension(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetTotalDimension, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetTotalComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetTotalComponents, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetFieldIndex(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetFieldIndex, $petsc_library), + PetscErrorCode, + (PetscDS, PetscObject, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetFieldSize(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetFieldSize, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetFieldOffset(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetFieldOffset, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetDimensions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetDimensions, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetComponents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetComponents, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetComponentOffset( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PetscDSGetComponentOffset, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetComponentOffsets(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetComponentOffsets, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetComponentDerivativeOffsets( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDSGetComponentDerivativeOffsets, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetWeakForm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetWeakForm, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{PetscWeakForm}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSSetWeakForm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSSetWeakForm, $petsc_library), + PetscErrorCode, + (PetscDS, PetscWeakForm), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetDiscretization(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetDiscretization, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{PetscObject}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSSetDiscretization(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSSetDiscretization, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, PetscObject), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSAddDiscretization(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSAddDiscretization, $petsc_library), + PetscErrorCode, + (PetscDS, PetscObject), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetQuadrature(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetQuadrature, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{PetscQuadrature}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetImplicit(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetImplicit, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSSetImplicit(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSSetImplicit, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetJetDegree(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetJetDegree, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSSetJetDegree(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSSetJetDegree, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetConstants(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetConstants, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{$PetscInt}, Ptr{Ptr{$PetscScalar}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSSetConstants(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSSetConstants, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{$PetscScalar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetObjective(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetObjective, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSSetObjective(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSSetObjective, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetResidual(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscDSGetResidual, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSSetResidual(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PetscDSSetResidual, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSHasJacobian(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSHasJacobian, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSGetJacobian, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSSetJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSSetJacobian, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSUseJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDSUseJacobianPreconditioner, $petsc_library), + PetscErrorCode, + (PetscDS, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSHasJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDSHasJacobianPreconditioner, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSGetJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSSetJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSSetJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSHasDynamicJacobian(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSHasDynamicJacobian, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetDynamicJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSGetDynamicJacobian, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSSetDynamicJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSSetDynamicJacobian, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSGetRiemannSolver(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetRiemannSolver, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSSetRiemannSolver(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSSetRiemannSolver, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetUpdate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetUpdate, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSSetUpdate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSSetUpdate, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetContext(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSGetContext, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSSetContext(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscDSSetContext, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscDSGetBdResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSGetBdResidual, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSSetBdResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSSetBdResidual, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSHasBdJacobian(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSHasBdJacobian, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetBdJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSGetBdJacobian, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSSetBdJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSSetBdJacobian, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSHasBdJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PetscDSHasBdJacobianPreconditioner, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetBdJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSGetBdJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSSetBdJacobianPreconditioner( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSSetBdJacobianPreconditioner, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + $PetscInt, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSGetExactSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSGetExactSolution, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSSetExactSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSSetExactSolution, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSGetExactSolutionTimeDerivative( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSGetExactSolutionTimeDerivative, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSSetExactSolutionTimeDerivative( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSSetExactSolutionTimeDerivative, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSGetEvaluationArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSGetEvaluationArrays, $petsc_library), + PetscErrorCode, + ( + PetscDS, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSGetWeakFormArrays( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:PetscDSGetWeakFormArrays, $petsc_library), + PetscErrorCode, + ( + PetscDS, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function PetscDSGetWorkspace( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PetscDSGetWorkspace, $petsc_library), + PetscErrorCode, + ( + PetscDS, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + Ptr{Ptr{$PetscScalar}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PetscDSCopyConstants(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSCopyConstants, $petsc_library), + PetscErrorCode, + (PetscDS, PetscDS), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSCopyEquations(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSCopyEquations, $petsc_library), + PetscErrorCode, + (PetscDS, PetscDS), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSSelectDiscretizations( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSSelectDiscretizations, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{$PetscInt}, PetscDS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSSelectEquations( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSSelectEquations, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{$PetscInt}, PetscDS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscDSAddBoundary( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, +) + @chk ccall( + (:PetscDSAddBoundary, $petsc_library), + PetscErrorCode, + ( + PetscDS, + DMBoundaryConditionType, + Ptr{Cchar}, + Ptr{Cchar}, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + ) +end + +@for_petsc function PetscDSUpdateBoundary( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscDSUpdateBoundary, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + DMBoundaryConditionType, + Ptr{Cchar}, + Ptr{Cchar}, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscDSGetNumBoundary(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscDSGetNumBoundary, $petsc_library), + PetscErrorCode, + (PetscDS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PetscDSGetBoundary( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, +) + @chk ccall( + (:PetscDSGetBoundary, $petsc_library), + PetscErrorCode, + ( + PetscDS, + $PetscInt, + Ptr{DMBoundaryConditionType}, + Ptr{Ptr{Cchar}}, + Ptr{Ptr{Cchar}}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + ) +end + +@for_petsc function PetscDSCopyBoundary( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscDSCopyBoundary, $petsc_library), + PetscErrorCode, + (PetscDS, $PetscInt, Ptr{$PetscInt}, PetscDS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function CharacteristicInitializePackage(::$UnionPetscLib) + @chk ccall( + (:CharacteristicInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +mutable struct _p_Characteristic end + +const Characteristic = Ptr{_p_Characteristic} + +const CharacteristicType = Ptr{Cchar} + +@for_petsc function CharacteristicCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:CharacteristicCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Characteristic}), + arg1, + arg2, + ) +end + +@for_petsc function CharacteristicSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:CharacteristicSetType, $petsc_library), + PetscErrorCode, + (Characteristic, CharacteristicType), + arg1, + arg2, + ) +end + +@for_petsc function CharacteristicSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:CharacteristicSetUp, $petsc_library), + PetscErrorCode, + (Characteristic,), + arg1, + ) +end + +@for_petsc function CharacteristicSetVelocityInterpolation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:CharacteristicSetVelocityInterpolation, $petsc_library), + PetscErrorCode, + ( + Characteristic, + DM, + Vec, + Vec, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function CharacteristicSetVelocityInterpolationLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:CharacteristicSetVelocityInterpolationLocal, $petsc_library), + PetscErrorCode, + ( + Characteristic, + DM, + Vec, + Vec, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function CharacteristicSetFieldInterpolation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:CharacteristicSetFieldInterpolation, $petsc_library), + PetscErrorCode, + ( + Characteristic, + DM, + Vec, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function CharacteristicSetFieldInterpolationLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:CharacteristicSetFieldInterpolationLocal, $petsc_library), + PetscErrorCode, + ( + Characteristic, + DM, + Vec, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function CharacteristicSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:CharacteristicSolve, $petsc_library), + PetscErrorCode, + (Characteristic, $PetscReal, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function CharacteristicDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:CharacteristicDestroy, $petsc_library), + PetscErrorCode, + (Ptr{Characteristic},), + arg1, + ) +end + +@for_petsc function CharacteristicRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:CharacteristicRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +mutable struct _p_PC end + +const PC = Ptr{_p_PC} + +const PCType = Ptr{Cchar} + +@enum PCSide::Int32 begin + PC_SIDE_DEFAULT = -1 + PC_LEFT = 0 + PC_RIGHT = 1 + PC_SYMMETRIC = 2 +end + +@enum PCRichardsonConvergedReason::Int32 begin + PCRICHARDSON_CONVERGED_RTOL = 2 + PCRICHARDSON_CONVERGED_ATOL = 3 + PCRICHARDSON_CONVERGED_ITS = 4 + PCRICHARDSON_DIVERGED_DTOL = -4 +end + +@enum PCJacobiType::UInt32 begin + PC_JACOBI_DIAGONAL = 0 + PC_JACOBI_ROWMAX = 1 + PC_JACOBI_ROWSUM = 2 +end + +@enum PCASMType::UInt32 begin + PC_ASM_BASIC = 3 + PC_ASM_RESTRICT = 1 + PC_ASM_INTERPOLATE = 2 + PC_ASM_NONE = 0 +end + +@enum PCGASMType::UInt32 begin + PC_GASM_BASIC = 3 + PC_GASM_RESTRICT = 1 + PC_GASM_INTERPOLATE = 2 + PC_GASM_NONE = 0 +end + +@enum PCCompositeType::UInt32 begin + PC_COMPOSITE_ADDITIVE = 0 + PC_COMPOSITE_MULTIPLICATIVE = 1 + PC_COMPOSITE_SYMMETRIC_MULTIPLICATIVE = 2 + PC_COMPOSITE_SPECIAL = 3 + PC_COMPOSITE_SCHUR = 4 + PC_COMPOSITE_GKB = 5 +end + +@enum PCFieldSplitSchurPreType::UInt32 begin + PC_FIELDSPLIT_SCHUR_PRE_SELF = 0 + PC_FIELDSPLIT_SCHUR_PRE_SELFP = 1 + PC_FIELDSPLIT_SCHUR_PRE_A11 = 2 + PC_FIELDSPLIT_SCHUR_PRE_USER = 3 + PC_FIELDSPLIT_SCHUR_PRE_FULL = 4 +end + +@enum PCFieldSplitSchurFactType::UInt32 begin + PC_FIELDSPLIT_SCHUR_FACT_DIAG = 0 + PC_FIELDSPLIT_SCHUR_FACT_LOWER = 1 + PC_FIELDSPLIT_SCHUR_FACT_UPPER = 2 + PC_FIELDSPLIT_SCHUR_FACT_FULL = 3 +end + +@enum PCPARMSGlobalType::UInt32 begin + PC_PARMS_GLOBAL_RAS = 0 + PC_PARMS_GLOBAL_SCHUR = 1 + PC_PARMS_GLOBAL_BJ = 2 +end + +@enum PCPARMSLocalType::UInt32 begin + PC_PARMS_LOCAL_ILU0 = 0 + PC_PARMS_LOCAL_ILUK = 1 + PC_PARMS_LOCAL_ILUT = 2 + PC_PARMS_LOCAL_ARMS = 3 +end + +const PCGAMGType = Ptr{Cchar} + +const PCGAMGClassicalType = Ptr{Cchar} + +@enum PCMGType::UInt32 begin + PC_MG_MULTIPLICATIVE = 0 + PC_MG_ADDITIVE = 1 + PC_MG_FULL = 2 + PC_MG_KASKADE = 3 +end + +@enum PCMGCycleType::UInt32 begin + PC_MG_CYCLE_V = 1 + PC_MG_CYCLE_W = 2 +end + +@enum PCMGGalerkinType::UInt32 begin + PC_MG_GALERKIN_BOTH = 0 + PC_MG_GALERKIN_PMAT = 1 + PC_MG_GALERKIN_MAT = 2 + PC_MG_GALERKIN_NONE = 3 + PC_MG_GALERKIN_EXTERNAL = 4 +end + +@enum PCExoticType::UInt32 begin + PC_EXOTIC_FACE = 0 + PC_EXOTIC_WIREBASKET = 1 +end + +@enum PCBDDCInterfaceExtType::UInt32 begin + PC_BDDC_INTERFACE_EXT_DIRICHLET = 0 + PC_BDDC_INTERFACE_EXT_LUMP = 1 +end + +@enum PCMGCoarseSpaceType::UInt32 begin + PCMG_POLYNOMIAL = 0 + PCMG_HARMONIC = 1 + PCMG_EIGENVECTOR = 2 + PCMG_GENERALIZED_EIGENVECTOR = 3 +end + +@enum PCPatchConstructType::UInt32 begin + PC_PATCH_STAR = 0 + PC_PATCH_VANKA = 1 + PC_PATCH_PARDECOMP = 2 + PC_PATCH_USER = 3 + PC_PATCH_PYTHON = 4 +end + +@enum PCDeflationSpaceType::UInt32 begin + PC_DEFLATION_SPACE_HAAR = 0 + PC_DEFLATION_SPACE_DB2 = 1 + PC_DEFLATION_SPACE_DB4 = 2 + PC_DEFLATION_SPACE_DB8 = 3 + PC_DEFLATION_SPACE_DB16 = 4 + PC_DEFLATION_SPACE_BIORTH22 = 5 + PC_DEFLATION_SPACE_MEYER = 6 + PC_DEFLATION_SPACE_AGGREGATION = 7 + PC_DEFLATION_SPACE_USER = 8 +end + +@enum PCHPDDMCoarseCorrectionType::UInt32 begin + PC_HPDDM_COARSE_CORRECTION_DEFLATED = 0 + PC_HPDDM_COARSE_CORRECTION_ADDITIVE = 1 + PC_HPDDM_COARSE_CORRECTION_BALANCED = 2 +end + +@enum PCFailedReason::Int32 begin + PC_SETUP_ERROR = -1 + PC_NOERROR = 0 + PC_FACTOR_STRUCT_ZEROPIVOT = 1 + PC_FACTOR_NUMERIC_ZEROPIVOT = 2 + PC_FACTOR_OUTMEMORY = 3 + PC_FACTOR_OTHER = 4 + PC_SUBPC_ERROR = 5 +end + +@enum PCGAMGLayoutType::UInt32 begin + PCGAMG_LAYOUT_COMPACT = 0 + PCGAMG_LAYOUT_SPREAD = 1 +end + +@for_petsc function PCInitializePackage(::$UnionPetscLib) + @chk ccall((:PCInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PCCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PC}), + arg1, + arg2, + ) +end + +@for_petsc function PCSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSetType, $petsc_library), + PetscErrorCode, + (PC, PCType), + arg1, + arg2, + ) +end + +@for_petsc function PCGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCType}), + arg1, + arg2, + ) +end + +@for_petsc function PCSetUp(::$UnionPetscLib, arg1) + @chk ccall((:PCSetUp, $petsc_library), PetscErrorCode, (PC,), arg1) +end + +@for_petsc function PCSetFailedReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSetFailedReason, $petsc_library), + PetscErrorCode, + (PC, PCFailedReason), + arg1, + arg2, + ) +end + +@for_petsc function PCGetFailedReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGetFailedReason, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCFailedReason}), + arg1, + arg2, + ) +end + +@for_petsc function PCGetSetUpFailedReason(::$UnionPetscLib, pc, reason) + @chk ccall( + (:PCGetSetUpFailedReason, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCFailedReason}), + pc, + reason, + ) +end + +@for_petsc function PCGetFailedReasonRank(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGetFailedReasonRank, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCFailedReason}), + arg1, + arg2, + ) +end + +@for_petsc function PCSetUpOnBlocks(::$UnionPetscLib, arg1) + @chk ccall((:PCSetUpOnBlocks, $petsc_library), PetscErrorCode, (PC,), arg1) +end + +@for_petsc function PCApply(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCApply, $petsc_library), + PetscErrorCode, + (PC, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMatApply(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMatApply, $petsc_library), + PetscErrorCode, + (PC, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCApplySymmetricLeft(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCApplySymmetricLeft, $petsc_library), + PetscErrorCode, + (PC, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCApplySymmetricRight(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCApplySymmetricRight, $petsc_library), + PetscErrorCode, + (PC, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCApplyBAorAB( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PCApplyBAorAB, $petsc_library), + PetscErrorCode, + (PC, PCSide, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PCApplyTranspose(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCApplyTranspose, $petsc_library), + PetscErrorCode, + (PC, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCApplyTransposeExists(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCApplyTransposeExists, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCApplyBAorABTranspose( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PCApplyBAorABTranspose, $petsc_library), + PetscErrorCode, + (PC, PCSide, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PCSetReusePreconditioner(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSetReusePreconditioner, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGetReusePreconditioner(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGetReusePreconditioner, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCSetErrorIfFailure(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSetErrorIfFailure, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCApplyRichardson( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:PCApplyRichardson, $petsc_library), + PetscErrorCode, + ( + PC, + Vec, + Vec, + Vec, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscInt, + PetscBool, + Ptr{$PetscInt}, + Ptr{PCRichardsonConvergedReason}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function PCApplyRichardsonExists(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCApplyRichardsonExists, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCSetUseAmat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSetUseAmat, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGetUseAmat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGetUseAmat, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCReset(::$UnionPetscLib, arg1) + @chk ccall((:PCReset, $petsc_library), PetscErrorCode, (PC,), arg1) +end + +@for_petsc function PCDestroy(::$UnionPetscLib, arg1) + @chk ccall((:PCDestroy, $petsc_library), PetscErrorCode, (Ptr{PC},), arg1) +end + +@for_petsc function PCSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall((:PCSetFromOptions, $petsc_library), PetscErrorCode, (PC,), arg1) +end + +@for_petsc function PCFactorGetMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorGetMatrix, $petsc_library), + PetscErrorCode, + (PC, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function PCSetModifySubMatrices(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCSetModifySubMatrices, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCModifySubMatrices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PCModifySubMatrices, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{IS}, Ptr{IS}, Ptr{Mat}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PCSetOperators(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCSetOperators, $petsc_library), + PetscErrorCode, + (PC, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCGetOperators(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCGetOperators, $petsc_library), + PetscErrorCode, + (PC, Ptr{Mat}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCGetOperatorsSet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCGetOperatorsSet, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCView, $petsc_library), + PetscErrorCode, + (PC, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PCLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCLoad, $petsc_library), + PetscErrorCode, + (PC, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PCViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCViewFromOptions, $petsc_library), + PetscErrorCode, + (PC, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PCAppendOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PCGetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (PC, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PCComputeOperator(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCComputeOperator, $petsc_library), + PetscErrorCode, + (PC, MatType, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCComputeExplicitOperator(::$UnionPetscLib, A, B) + @chk ccall( + (:PCComputeExplicitOperator, $petsc_library), + PetscErrorCode, + (PC, Ptr{Mat}), + A, + B, + ) +end + +@for_petsc function PCGetDiagonalScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGetDiagonalScale, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCDiagonalScaleLeft(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCDiagonalScaleLeft, $petsc_library), + PetscErrorCode, + (PC, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCDiagonalScaleRight(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCDiagonalScaleRight, $petsc_library), + PetscErrorCode, + (PC, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCSetDiagonalScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSetDiagonalScale, $petsc_library), + PetscErrorCode, + (PC, Vec), + arg1, + arg2, + ) +end + +@for_petsc function PCSetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall((:PCSetDM, $petsc_library), PetscErrorCode, (PC, DM), arg1, arg2) +end + +@for_petsc function PCGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGetDM, $petsc_library), + PetscErrorCode, + (PC, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function PCGetInterpolations(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCGetInterpolations, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{Mat}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCGetCoarseOperators(::$UnionPetscLib, pc, arg2, arg3) + @chk ccall( + (:PCGetCoarseOperators, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{Mat}}), + pc, + arg2, + arg3, + ) +end + +@for_petsc function PCSetCoordinates(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PCSetCoordinates, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCSetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSetApplicationContext, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCGetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGetApplicationContext, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCJacobiSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCJacobiSetType, $petsc_library), + PetscErrorCode, + (PC, PCJacobiType), + arg1, + arg2, + ) +end + +@for_petsc function PCJacobiGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCJacobiGetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCJacobiType}), + arg1, + arg2, + ) +end + +@for_petsc function PCJacobiSetUseAbs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCJacobiSetUseAbs, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCJacobiGetUseAbs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCJacobiGetUseAbs, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCSORSetSymmetric(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSORSetSymmetric, $petsc_library), + PetscErrorCode, + (PC, MatSORType), + arg1, + arg2, + ) +end + +@for_petsc function PCSORGetSymmetric(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSORGetSymmetric, $petsc_library), + PetscErrorCode, + (PC, Ptr{MatSORType}), + arg1, + arg2, + ) +end + +@for_petsc function PCSORSetOmega(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSORSetOmega, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCSORGetOmega(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSORGetOmega, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PCSORSetIterations(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCSORSetIterations, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCSORGetIterations(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCSORGetIterations, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCEisenstatSetOmega(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCEisenstatSetOmega, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCEisenstatGetOmega(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCEisenstatGetOmega, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PCEisenstatSetNoDiagonalScaling( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCEisenstatSetNoDiagonalScaling, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCEisenstatGetNoDiagonalScaling( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCEisenstatGetNoDiagonalScaling, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCBJacobiSetTotalBlocks(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCBJacobiSetTotalBlocks, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCBJacobiGetTotalBlocks(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCBJacobiGetTotalBlocks, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCBJacobiSetLocalBlocks(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCBJacobiSetLocalBlocks, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCBJacobiGetLocalBlocks(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCBJacobiGetLocalBlocks, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{$PetscInt}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCShellSetApply(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetApply, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetMatApply(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetMatApply, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetApplySymmetricLeft(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetApplySymmetricLeft, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetApplySymmetricRight(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetApplySymmetricRight, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetApplyBA(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetApplyBA, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetApplyTranspose(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetApplyTranspose, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetSetUp(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetSetUp, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetApplyRichardson(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetApplyRichardson, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetView, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetDestroy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetDestroy, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetContext, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellGetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellGetContext, $petsc_library), + PetscErrorCode, + (PC, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetName, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellGetName(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellGetName, $petsc_library), + PetscErrorCode, + (PC, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetZeroPivot(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetZeroPivot, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetShiftType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetShiftType, $petsc_library), + PetscErrorCode, + (PC, MatFactorShiftType), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetShiftAmount(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetShiftAmount, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetMatSolverType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetMatSolverType, $petsc_library), + PetscErrorCode, + (PC, MatSolverType), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorGetMatSolverType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorGetMatSolverType, $petsc_library), + PetscErrorCode, + (PC, Ptr{MatSolverType}), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetUpMatSolverType(::$UnionPetscLib, arg1) + @chk ccall( + (:PCFactorSetUpMatSolverType, $petsc_library), + PetscErrorCode, + (PC,), + arg1, + ) +end + +@for_petsc function PCFactorSetMatSolverPackage(::$UnionPetscLib, pc, stype) + @chk ccall( + (:PCFactorSetMatSolverPackage, $petsc_library), + PetscErrorCode, + (PC, MatSolverType), + pc, + stype, + ) +end + +@for_petsc function PCFactorGetMatSolverPackage(::$UnionPetscLib, pc, stype) + @chk ccall( + (:PCFactorGetMatSolverPackage, $petsc_library), + PetscErrorCode, + (PC, Ptr{MatSolverType}), + pc, + stype, + ) +end + +@for_petsc function PCFactorSetUpMatSolverPackage(::$UnionPetscLib, pc) + @chk ccall( + (:PCFactorSetUpMatSolverPackage, $petsc_library), + PetscErrorCode, + (PC,), + pc, + ) +end + +@for_petsc function PCFactorSetFill(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetFill, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetColumnPivot(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetColumnPivot, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorReorderForNonzeroDiagonal( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCFactorReorderForNonzeroDiagonal, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetMatOrderingType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetMatOrderingType, $petsc_library), + PetscErrorCode, + (PC, MatOrderingType), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetReuseOrdering(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetReuseOrdering, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetReuseFill(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetReuseFill, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetUseInPlace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetUseInPlace, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorGetUseInPlace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorGetUseInPlace, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetAllowDiagonalFill(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetAllowDiagonalFill, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorGetAllowDiagonalFill(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorGetAllowDiagonalFill, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetPivotInBlocks(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetPivotInBlocks, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetLevels(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorSetLevels, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorGetLevels(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorGetLevels, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorSetDropTolerance( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCFactorSetDropTolerance, $petsc_library), + PetscErrorCode, + (PC, $PetscReal, $PetscReal, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCFactorGetZeroPivot(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorGetZeroPivot, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorGetShiftAmount(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorGetShiftAmount, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PCFactorGetShiftType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFactorGetShiftType, $petsc_library), + PetscErrorCode, + (PC, Ptr{MatFactorShiftType}), + arg1, + arg2, + ) +end + +@for_petsc function PCASMSetLocalSubdomains( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCASMSetLocalSubdomains, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCASMSetTotalSubdomains( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCASMSetTotalSubdomains, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCASMSetOverlap(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMSetOverlap, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCASMSetDMSubdomains(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMSetDMSubdomains, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCASMGetDMSubdomains(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMGetDMSubdomains, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCASMSetSortIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMSetSortIndices, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCASMSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMSetType, $petsc_library), + PetscErrorCode, + (PC, PCASMType), + arg1, + arg2, + ) +end + +@for_petsc function PCASMGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMGetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCASMType}), + arg1, + arg2, + ) +end + +@for_petsc function PCASMSetLocalType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMSetLocalType, $petsc_library), + PetscErrorCode, + (PC, PCCompositeType), + arg1, + arg2, + ) +end + +@for_petsc function PCASMGetLocalType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMGetLocalType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCCompositeType}), + arg1, + arg2, + ) +end + +@for_petsc function PCASMCreateSubdomains(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCASMCreateSubdomains, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCASMDestroySubdomains(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCASMDestroySubdomains, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCASMCreateSubdomains2D( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:PCASMCreateSubdomains2D, $petsc_library), + PetscErrorCode, + ( + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{IS}}, + Ptr{Ptr{IS}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function PCASMGetLocalSubdomains( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCASMGetLocalSubdomains, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{IS}}, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCASMGetLocalSubmatrices(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCASMGetLocalSubmatrices, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{Mat}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCASMGetSubMatType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMGetSubMatType, $petsc_library), + PetscErrorCode, + (PC, Ptr{MatType}), + arg1, + arg2, + ) +end + +@for_petsc function PCASMSetSubMatType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCASMSetSubMatType, $petsc_library), + PetscErrorCode, + (PC, MatType), + arg1, + arg2, + ) +end + +@for_petsc function PCGASMSetTotalSubdomains(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGASMSetTotalSubdomains, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCGASMSetSubdomains( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCGASMSetSubdomains, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCGASMSetOverlap(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGASMSetOverlap, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCGASMSetUseDMSubdomains(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGASMSetUseDMSubdomains, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGASMGetUseDMSubdomains(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGASMGetUseDMSubdomains, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCGASMSetSortIndices(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGASMSetSortIndices, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGASMSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGASMSetType, $petsc_library), + PetscErrorCode, + (PC, PCGASMType), + arg1, + arg2, + ) +end + +@for_petsc function PCGASMCreateSubdomains( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCGASMCreateSubdomains, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{$PetscInt}, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCGASMDestroySubdomains(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCGASMDestroySubdomains, $petsc_library), + PetscErrorCode, + ($PetscInt, Ptr{Ptr{IS}}, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCGASMCreateSubdomains2D( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:PCGASMCreateSubdomains2D, $petsc_library), + PetscErrorCode, + ( + PC, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{Ptr{IS}}, + Ptr{Ptr{IS}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function PCGASMGetSubdomains( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCGASMGetSubdomains, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{IS}}, Ptr{Ptr{IS}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCGASMGetSubmatrices(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCGASMGetSubmatrices, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{Mat}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCCompositeSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCCompositeSetType, $petsc_library), + PetscErrorCode, + (PC, PCCompositeType), + arg1, + arg2, + ) +end + +@for_petsc function PCCompositeGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCCompositeGetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCCompositeType}), + arg1, + arg2, + ) +end + +@for_petsc function PCCompositeAddPCType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCCompositeAddPCType, $petsc_library), + PetscErrorCode, + (PC, PCType), + arg1, + arg2, + ) +end + +@for_petsc function PCCompositeAddPC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCCompositeAddPC, $petsc_library), + PetscErrorCode, + (PC, PC), + arg1, + arg2, + ) +end + +@for_petsc function PCCompositeGetNumberPC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCCompositeGetNumberPC, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PCCompositeGetPC(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCCompositeGetPC, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{PC}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCCompositeSpecialSetAlpha(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCCompositeSpecialSetAlpha, $petsc_library), + PetscErrorCode, + (PC, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function PCRedundantSetNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCRedundantSetNumber, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCRedundantSetScatter(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCRedundantSetScatter, $petsc_library), + PetscErrorCode, + (PC, VecScatter, VecScatter), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCRedundantGetOperators(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCRedundantGetOperators, $petsc_library), + PetscErrorCode, + (PC, Ptr{Mat}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCSPAISetEpsilon(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSPAISetEpsilon, $petsc_library), + PetscErrorCode, + (PC, Cdouble), + arg1, + arg2, + ) +end + +@for_petsc function PCSPAISetNBSteps(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSPAISetNBSteps, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCSPAISetMax(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSPAISetMax, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCSPAISetMaxNew(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSPAISetMaxNew, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCSPAISetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSPAISetBlockSize, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCSPAISetCacheSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSPAISetCacheSize, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCSPAISetVerbose(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSPAISetVerbose, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCSPAISetSp(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCSPAISetSp, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCHYPRESetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHYPRESetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PCHYPREGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHYPREGetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function PCHYPRESetDiscreteGradient(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHYPRESetDiscreteGradient, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCHYPRESetDiscreteCurl(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHYPRESetDiscreteCurl, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCHYPRESetInterpolations( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PCHYPRESetInterpolations, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Mat, Ptr{Mat}, Mat, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PCHYPRESetEdgeConstantVectors( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCHYPRESetEdgeConstantVectors, $petsc_library), + PetscErrorCode, + (PC, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCHYPRESetAlphaPoissonMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHYPRESetAlphaPoissonMatrix, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCHYPRESetBetaPoissonMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHYPRESetBetaPoissonMatrix, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetFields( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PCFieldSplitSetFields, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cchar}, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PCFieldSplitSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetType, $petsc_library), + PetscErrorCode, + (PC, PCCompositeType), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitGetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCCompositeType}), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetBlockSize, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCFieldSplitSetIS, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cchar}, IS), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCFieldSplitGetIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCFieldSplitGetIS, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cchar}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCFieldSplitGetISByIndex(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCFieldSplitGetISByIndex, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCFieldSplitRestrictIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitRestrictIS, $petsc_library), + PetscErrorCode, + (PC, IS), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetDMSplits(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetDMSplits, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitGetDMSplits(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitGetDMSplits, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetDiagUseAmat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetDiagUseAmat, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitGetDiagUseAmat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitGetDiagUseAmat, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetOffDiagUseAmat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetOffDiagUseAmat, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitGetOffDiagUseAmat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitGetOffDiagUseAmat, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSchurPrecondition( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCFieldSplitSchurPrecondition, $petsc_library), + PetscErrorCode, + (PC, PCFieldSplitSchurPreType, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCFieldSplitSetSchurPre(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCFieldSplitSetSchurPre, $petsc_library), + PetscErrorCode, + (PC, PCFieldSplitSchurPreType, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCFieldSplitGetSchurPre(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCFieldSplitGetSchurPre, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCFieldSplitSchurPreType}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCFieldSplitSetSchurFactType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetSchurFactType, $petsc_library), + PetscErrorCode, + (PC, PCFieldSplitSchurFactType), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetSchurScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetSchurScale, $petsc_library), + PetscErrorCode, + (PC, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitGetSchurBlocks( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PCFieldSplitGetSchurBlocks, $petsc_library), + PetscErrorCode, + (PC, Ptr{Mat}, Ptr{Mat}, Ptr{Mat}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PCFieldSplitSchurGetS(::$UnionPetscLib, arg1, S) + @chk ccall( + (:PCFieldSplitSchurGetS, $petsc_library), + PetscErrorCode, + (PC, Ptr{Mat}), + arg1, + S, + ) +end + +@for_petsc function PCFieldSplitSchurRestoreS(::$UnionPetscLib, arg1, S) + @chk ccall( + (:PCFieldSplitSchurRestoreS, $petsc_library), + PetscErrorCode, + (PC, Ptr{Mat}), + arg1, + S, + ) +end + +@for_petsc function PCFieldSplitGetDetectSaddlePoint( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCFieldSplitGetDetectSaddlePoint, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetDetectSaddlePoint( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCFieldSplitSetDetectSaddlePoint, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetGKBTol(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetGKBTol, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetGKBNu(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetGKBNu, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetGKBMaxit(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetGKBMaxit, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCFieldSplitSetGKBDelay(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCFieldSplitSetGKBDelay, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCGalerkinSetRestriction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGalerkinSetRestriction, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCGalerkinSetInterpolation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGalerkinSetInterpolation, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCGalerkinSetComputeSubmatrix( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCGalerkinSetComputeSubmatrix, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCPythonSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPythonSetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PCPARMSSetGlobal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPARMSSetGlobal, $petsc_library), + PetscErrorCode, + (PC, PCPARMSGlobalType), + arg1, + arg2, + ) +end + +@for_petsc function PCPARMSSetLocal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPARMSSetLocal, $petsc_library), + PetscErrorCode, + (PC, PCPARMSLocalType), + arg1, + arg2, + ) +end + +@for_petsc function PCPARMSSetSolveTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCPARMSSetSolveTolerances, $petsc_library), + PetscErrorCode, + (PC, $PetscReal, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCPARMSSetSolveRestart(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPARMSSetSolveRestart, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCPARMSSetNonsymPerm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPARMSSetNonsymPerm, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCPARMSSetFill(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PCPARMSSetFill, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCGAMGSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetType, $petsc_library), + PetscErrorCode, + (PC, PCGAMGType), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGGetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCGAMGType}), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetProcEqLim(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetProcEqLim, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetRepartition(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetRepartition, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetUseSAEstEig(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetUseSAEstEig, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetEstEigKSPMaxIt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetEstEigKSPMaxIt, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetEstEigKSPType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetEstEigKSPType, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetEigenvalues(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCGAMGSetEigenvalues, $petsc_library), + PetscErrorCode, + (PC, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCGAMGASMSetUseAggs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGASMSetUseAggs, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetUseParallelCoarseGridSolve( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCGAMGSetUseParallelCoarseGridSolve, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetCpuPinCoarseGrids(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetCpuPinCoarseGrids, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetCoarseGridLayoutType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetCoarseGridLayoutType, $petsc_library), + PetscErrorCode, + (PC, PCGAMGLayoutType), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetThreshold(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCGAMGSetThreshold, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscReal}, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCGAMGSetRankReductionFactors( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCGAMGSetRankReductionFactors, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCGAMGSetThresholdScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetThresholdScale, $petsc_library), + PetscErrorCode, + (PC, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetCoarseEqLim(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetCoarseEqLim, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetNlevels(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetNlevels, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetNSmooths(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetNSmooths, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetSymGraph(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetSymGraph, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetSquareGraph(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetSquareGraph, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGSetReuseInterpolation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGSetReuseInterpolation, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGFinalizePackage(::$UnionPetscLib) + @chk ccall((:PCGAMGFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PCGAMGInitializePackage(::$UnionPetscLib) + @chk ccall((:PCGAMGInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PCGAMGRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGRegister, $petsc_library), + PetscErrorCode, + (PCGAMGType, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGClassicalSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGClassicalSetType, $petsc_library), + PetscErrorCode, + (PC, PCGAMGClassicalType), + arg1, + arg2, + ) +end + +@for_petsc function PCGAMGClassicalGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGAMGClassicalGetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCGAMGClassicalType}), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetDiscreteGradient( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:PCBDDCSetDiscreteGradient, $petsc_library), + PetscErrorCode, + (PC, Mat, $PetscInt, $PetscInt, PetscBool, PetscBool), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function PCBDDCSetDivergenceMat( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCBDDCSetDivergenceMat, $petsc_library), + PetscErrorCode, + (PC, Mat, PetscBool, IS), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCBDDCSetChangeOfBasisMat( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCBDDCSetChangeOfBasisMat, $petsc_library), + PetscErrorCode, + (PC, Mat, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCBDDCSetPrimalVerticesIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCSetPrimalVerticesIS, $petsc_library), + PetscErrorCode, + (PC, IS), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetPrimalVerticesLocalIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCSetPrimalVerticesLocalIS, $petsc_library), + PetscErrorCode, + (PC, IS), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCGetPrimalVerticesIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCGetPrimalVerticesIS, $petsc_library), + PetscErrorCode, + (PC, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCGetPrimalVerticesLocalIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCGetPrimalVerticesLocalIS, $petsc_library), + PetscErrorCode, + (PC, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetCoarseningRatio(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCSetCoarseningRatio, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetLevels(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCSetLevels, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetDirichletBoundaries(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCSetDirichletBoundaries, $petsc_library), + PetscErrorCode, + (PC, IS), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetDirichletBoundariesLocal( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCBDDCSetDirichletBoundariesLocal, $petsc_library), + PetscErrorCode, + (PC, IS), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCGetDirichletBoundaries(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCGetDirichletBoundaries, $petsc_library), + PetscErrorCode, + (PC, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCGetDirichletBoundariesLocal( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCBDDCGetDirichletBoundariesLocal, $petsc_library), + PetscErrorCode, + (PC, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetInterfaceExtType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCSetInterfaceExtType, $petsc_library), + PetscErrorCode, + (PC, PCBDDCInterfaceExtType), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetNeumannBoundaries(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCSetNeumannBoundaries, $petsc_library), + PetscErrorCode, + (PC, IS), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetNeumannBoundariesLocal( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCBDDCSetNeumannBoundariesLocal, $petsc_library), + PetscErrorCode, + (PC, IS), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCGetNeumannBoundaries(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCBDDCGetNeumannBoundaries, $petsc_library), + PetscErrorCode, + (PC, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCGetNeumannBoundariesLocal( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCBDDCGetNeumannBoundariesLocal, $petsc_library), + PetscErrorCode, + (PC, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function PCBDDCSetDofsSplitting(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCBDDCSetDofsSplitting, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCBDDCSetDofsSplittingLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCBDDCSetDofsSplittingLocal, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCBDDCSetLocalAdjacencyGraph( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PCBDDCSetLocalAdjacencyGraph, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, PetscCopyMode), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PCBDDCCreateFETIDPOperators( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PCBDDCCreateFETIDPOperators, $petsc_library), + PetscErrorCode, + (PC, PetscBool, Ptr{Cchar}, Ptr{Mat}, Ptr{PC}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PCBDDCMatFETIDPGetRHS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCBDDCMatFETIDPGetRHS, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCBDDCMatFETIDPGetSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCBDDCMatFETIDPGetSolution, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCBDDCFinalizePackage(::$UnionPetscLib) + @chk ccall((:PCBDDCFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PCBDDCInitializePackage(::$UnionPetscLib) + @chk ccall((:PCBDDCInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PCISSetUseStiffnessScaling(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCISSetUseStiffnessScaling, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCISSetSubdomainScalingFactor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCISSetSubdomainScalingFactor, $petsc_library), + PetscErrorCode, + (PC, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function PCISSetSubdomainDiagonalScaling( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCISSetSubdomainDiagonalScaling, $petsc_library), + PetscErrorCode, + (PC, Vec), + arg1, + arg2, + ) +end + +@for_petsc function PCMGSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGSetType, $petsc_library), + PetscErrorCode, + (PC, PCMGType), + arg1, + arg2, + ) +end + +@for_petsc function PCMGGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGGetType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCMGType}), + arg1, + arg2, + ) +end + +@for_petsc function PCMGSetLevels(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGSetLevels, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{MPI_Comm}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGGetLevels(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGGetLevels, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PCMGSetDistinctSmoothUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PCMGSetDistinctSmoothUp, $petsc_library), + PetscErrorCode, + (PC,), + arg1, + ) +end + +@for_petsc function PCMGSetNumberSmooth(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGSetNumberSmooth, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCMGSetCycleType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGSetCycleType, $petsc_library), + PetscErrorCode, + (PC, PCMGCycleType), + arg1, + arg2, + ) +end + +@for_petsc function PCMGSetCycleTypeOnLevel(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGSetCycleTypeOnLevel, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, PCMGCycleType), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGSetCyclesOnLevel(::$UnionPetscLib, pc, l, t) + @chk ccall( + (:PCMGSetCyclesOnLevel, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, $PetscInt), + pc, + l, + t, + ) +end + +@for_petsc function PCMGMultiplicativeSetCycles(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGMultiplicativeSetCycles, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCMGSetGalerkin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGSetGalerkin, $petsc_library), + PetscErrorCode, + (PC, PCMGGalerkinType), + arg1, + arg2, + ) +end + +@for_petsc function PCMGGetGalerkin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGGetGalerkin, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCMGGalerkinType}), + arg1, + arg2, + ) +end + +@for_petsc function PCMGSetAdaptInterpolation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGSetAdaptInterpolation, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCMGGetAdaptInterpolation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGGetAdaptInterpolation, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCMGSetAdaptCR(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGSetAdaptCR, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCMGGetAdaptCR(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGGetAdaptCR, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCMGSetRhs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGSetRhs, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGSetX(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGSetX, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGSetR(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGSetR, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGSetRestriction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGSetRestriction, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGGetRestriction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGGetRestriction, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGSetInjection(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGSetInjection, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGGetInjection(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGGetInjection, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGSetInterpolation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGSetInterpolation, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGSetOperators(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PCMGSetOperators, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCMGGetInterpolation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGGetInterpolation, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGSetRScale(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGSetRScale, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGGetRScale(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGGetRScale, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGSetResidual(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PCMGSetResidual, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{Cvoid}, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCMGSetResidualTranspose( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCMGSetResidualTranspose, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{Cvoid}, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCMGResidualDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCMGResidualDefault, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCMGResidualTransposeDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCMGResidualTransposeDefault, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCMGMatResidualDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCMGMatResidualDefault, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCMGMatResidualTransposeDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCMGMatResidualTransposeDefault, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCHMGSetReuseInterpolation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHMGSetReuseInterpolation, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCHMGSetUseSubspaceCoarsening(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHMGSetUseSubspaceCoarsening, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCHMGSetInnerPCType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHMGSetInnerPCType, $petsc_library), + PetscErrorCode, + (PC, PCType), + arg1, + arg2, + ) +end + +@for_petsc function PCHMGSetCoarseningComponent(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHMGSetCoarseningComponent, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCHMGUseMatMAIJ(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHMGUseMatMAIJ, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeGetSubcommType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeGetSubcommType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscSubcommType}), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeSetSubcommType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeSetSubcommType, $petsc_library), + PetscErrorCode, + (PC, PetscSubcommType), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeGetReductionFactor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeGetReductionFactor, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeSetReductionFactor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeSetReductionFactor, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeGetIgnoreDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeGetIgnoreDM, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeSetIgnoreDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeSetIgnoreDM, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeGetUseCoarseDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeGetUseCoarseDM, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeSetUseCoarseDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeSetUseCoarseDM, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeGetIgnoreKSPComputeOperators( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCTelescopeGetIgnoreKSPComputeOperators, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeSetIgnoreKSPComputeOperators( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCTelescopeSetIgnoreKSPComputeOperators, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeGetDM, $petsc_library), + PetscErrorCode, + (PC, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchSetSaveOperators(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPatchSetSaveOperators, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchGetSaveOperators(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPatchGetSaveOperators, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchSetPrecomputeElementTensors( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCPatchSetPrecomputeElementTensors, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchGetPrecomputeElementTensors( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCPatchGetPrecomputeElementTensors, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchSetPartitionOfUnity(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPatchSetPartitionOfUnity, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchGetPartitionOfUnity(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPatchGetPartitionOfUnity, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchSetSubMatType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPatchSetSubMatType, $petsc_library), + PetscErrorCode, + (PC, MatType), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchGetSubMatType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPatchGetSubMatType, $petsc_library), + PetscErrorCode, + (PC, Ptr{MatType}), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchSetCellNumbering(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPatchSetCellNumbering, $petsc_library), + PetscErrorCode, + (PC, PetscSection), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchGetCellNumbering(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPatchGetCellNumbering, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscSection}), + arg1, + arg2, + ) +end + +@for_petsc function PCPatchSetConstructType( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCPatchSetConstructType, $petsc_library), + PetscErrorCode, + (PC, PCPatchConstructType, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCPatchGetConstructType( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PCPatchGetConstructType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCPatchConstructType}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCPatchSetDiscretisationInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:PCPatchSetDiscretisationInfo, $petsc_library), + PetscErrorCode, + ( + PC, + $PetscInt, + Ptr{DM}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function PCPatchSetComputeOperator( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCPatchSetComputeOperator, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCPatchSetComputeFunction(::$UnionPetscLib, pc, func, ctx) + @chk ccall( + (:PCPatchSetComputeFunction, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}, Ptr{Cvoid}), + pc, + func, + ctx, + ) +end + +@for_petsc function PCPatchSetComputeOperatorInteriorFacets( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCPatchSetComputeOperatorInteriorFacets, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCPatchSetComputeFunctionInteriorFacets( + ::$UnionPetscLib, + pc, + func, + ctx, +) + @chk ccall( + (:PCPatchSetComputeFunctionInteriorFacets, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}, Ptr{Cvoid}), + pc, + func, + ctx, + ) +end + +@for_petsc function PCLMVMSetMatLMVM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCLMVMSetMatLMVM, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCLMVMGetMatLMVM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCLMVMGetMatLMVM, $petsc_library), + PetscErrorCode, + (PC, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function PCLMVMSetIS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCLMVMSetIS, $petsc_library), + PetscErrorCode, + (PC, IS), + arg1, + arg2, + ) +end + +@for_petsc function PCLMVMClearIS(::$UnionPetscLib, arg1) + @chk ccall((:PCLMVMClearIS, $petsc_library), PetscErrorCode, (PC,), arg1) +end + +@for_petsc function PCExoticSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCExoticSetType, $petsc_library), + PetscErrorCode, + (PC, PCExoticType), + arg1, + arg2, + ) +end + +@for_petsc function PCDeflationSetInitOnly(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCDeflationSetInitOnly, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCDeflationSetLevels(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCDeflationSetLevels, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCDeflationSetReductionFactor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCDeflationSetReductionFactor, $petsc_library), + PetscErrorCode, + (PC, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCDeflationSetCorrectionFactor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCDeflationSetCorrectionFactor, $petsc_library), + PetscErrorCode, + (PC, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function PCDeflationSetSpaceToCompute( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCDeflationSetSpaceToCompute, $petsc_library), + PetscErrorCode, + (PC, PCDeflationSpaceType, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCDeflationSetSpace(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCDeflationSetSpace, $petsc_library), + PetscErrorCode, + (PC, Mat, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCDeflationSetProjectionNullSpaceMat( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCDeflationSetProjectionNullSpaceMat, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCDeflationSetCoarseMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCDeflationSetCoarseMat, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCDeflationGetPC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCDeflationGetPC, $petsc_library), + PetscErrorCode, + (PC, Ptr{PC}), + arg1, + arg2, + ) +end + +@for_petsc function PCHPDDMSetAuxiliaryMat( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PCHPDDMSetAuxiliaryMat, $petsc_library), + PetscErrorCode, + (PC, IS, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PCHPDDMSetRHSMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHPDDMSetRHSMat, $petsc_library), + PetscErrorCode, + (PC, Mat), + arg1, + arg2, + ) +end + +@for_petsc function PCHPDDMHasNeumannMat(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHPDDMHasNeumannMat, $petsc_library), + PetscErrorCode, + (PC, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function PCHPDDMSetCoarseCorrectionType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHPDDMSetCoarseCorrectionType, $petsc_library), + PetscErrorCode, + (PC, PCHPDDMCoarseCorrectionType), + arg1, + arg2, + ) +end + +@for_petsc function PCHPDDMGetCoarseCorrectionType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHPDDMGetCoarseCorrectionType, $petsc_library), + PetscErrorCode, + (PC, Ptr{PCHPDDMCoarseCorrectionType}), + arg1, + arg2, + ) +end + +@for_petsc function PCHPDDMGetSTShareSubKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCHPDDMGetSTShareSubKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function PCHPDDMFinalizePackage(::$UnionPetscLib) + @chk ccall((:PCHPDDMFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function PCHPDDMInitializePackage(::$UnionPetscLib) + @chk ccall((:PCHPDDMInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function KSPInitializePackage(::$UnionPetscLib) + @chk ccall((:KSPInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +mutable struct _p_KSP end + +const KSP = Ptr{_p_KSP} + +const KSPType = Ptr{Cchar} + +@for_petsc function KSPCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetType, $petsc_library), + PetscErrorCode, + (KSP, KSPType), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetType, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSPType}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetUp(::$UnionPetscLib, arg1) + @chk ccall((:KSPSetUp, $petsc_library), PetscErrorCode, (KSP,), arg1) +end + +@for_petsc function KSPSetUpOnBlocks(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPSetUpOnBlocks, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPSolve, $petsc_library), + PetscErrorCode, + (KSP, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSolveTranspose(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPSolveTranspose, $petsc_library), + PetscErrorCode, + (KSP, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetUseExplicitTranspose(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetUseExplicitTranspose, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPMatSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPMatSolve, $petsc_library), + PetscErrorCode, + (KSP, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetMatSolveBatchSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetMatSolveBatchSize, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetMatSolveBlockSize(::$UnionPetscLib, ksp, n) + @chk ccall( + (:KSPSetMatSolveBlockSize, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + ksp, + n, + ) +end + +@for_petsc function KSPGetMatSolveBatchSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetMatSolveBatchSize, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetMatSolveBlockSize(::$UnionPetscLib, ksp, n) + @chk ccall( + (:KSPGetMatSolveBlockSize, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + ksp, + n, + ) +end + +@for_petsc function KSPReset(::$UnionPetscLib, arg1) + @chk ccall((:KSPReset, $petsc_library), PetscErrorCode, (KSP,), arg1) +end + +@for_petsc function KSPResetViewers(::$UnionPetscLib, arg1) + @chk ccall((:KSPResetViewers, $petsc_library), PetscErrorCode, (KSP,), arg1) +end + +@for_petsc function KSPDestroy(::$UnionPetscLib, arg1) + @chk ccall((:KSPDestroy, $petsc_library), PetscErrorCode, (Ptr{KSP},), arg1) +end + +@for_petsc function KSPSetReusePreconditioner(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetReusePreconditioner, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetReusePreconditioner(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetReusePreconditioner, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetSkipPCSetFromOptions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetSkipPCSetFromOptions, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPCheckSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPCheckSolve, $petsc_library), + PetscErrorCode, + (KSP, PC, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function KSPMonitorRegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:KSPMonitorRegister, $petsc_library), + PetscErrorCode, + ( + Ptr{Cchar}, + PetscViewerType, + PetscViewerFormat, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function KSPSetPCSide(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetPCSide, $petsc_library), + PetscErrorCode, + (KSP, PCSide), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetPCSide(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetPCSide, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PCSide}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPSetTolerances, $petsc_library), + PetscErrorCode, + (KSP, $PetscReal, $PetscReal, $PetscReal, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPGetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPGetTolerances, $petsc_library), + PetscErrorCode, + ( + KSP, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPSetInitialGuessNonzero(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetInitialGuessNonzero, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetInitialGuessNonzero(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetInitialGuessNonzero, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetErrorIfNotConverged(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetErrorIfNotConverged, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetErrorIfNotConverged(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetErrorIfNotConverged, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetComputeEigenvalues(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetComputeEigenvalues, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetComputeRitz(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetComputeRitz, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetComputeEigenvalues(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetComputeEigenvalues, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetComputeSingularValues(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetComputeSingularValues, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetComputeSingularValues(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetComputeSingularValues, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetRhs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetRhs, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetSolution(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetSolution, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetResidualNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetResidualNorm, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetIterationNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetIterationNumber, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetTotalIterations(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetTotalIterations, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPCreateVecs( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPCreateVecs, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, Ptr{Ptr{Vec}}, $PetscInt, Ptr{Ptr{Vec}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPGetVecs(::$UnionPetscLib, ksp, n, x, m, y) + @chk ccall( + (:KSPGetVecs, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, Ptr{Ptr{Vec}}, $PetscInt, Ptr{Ptr{Vec}}), + ksp, + n, + x, + m, + y, + ) +end + +@for_petsc function KSPSetPreSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPSetPreSolve, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetPostSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPSetPostSolve, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetPC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetPC, $petsc_library), + PetscErrorCode, + (KSP, PC), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetPC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetPC, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PC}), + arg1, + arg2, + ) +end + +@for_petsc function KSPMonitor(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPMonitor, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPMonitorSet(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:KSPMonitorSet, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorCancel(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPMonitorCancel, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPGetMonitorContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetMonitorContext, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetResidualHistory(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPGetResidualHistory, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{$PetscReal}}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetResidualHistory( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPSetResidualHistory, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}, $PetscInt, PetscBool), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPGetErrorHistory(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPGetErrorHistory, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{$PetscReal}}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetErrorHistory(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:KSPSetErrorHistory, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}, $PetscInt, PetscBool), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPBuildSolutionDefault(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPBuildSolutionDefault, $petsc_library), + PetscErrorCode, + (KSP, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPBuildResidualDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPBuildResidualDefault, $petsc_library), + PetscErrorCode, + (KSP, Vec, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPDestroyDefault(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPDestroyDefault, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPSetWorkVecs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetWorkVecs, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PCKSPGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCKSPGetKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function PCKSPSetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCKSPSetKSP, $petsc_library), + PetscErrorCode, + (PC, KSP), + arg1, + arg2, + ) +end + +@for_petsc function PCBJacobiGetSubKSP(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PCBJacobiGetSubKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{KSP}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCASMGetSubKSP(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PCASMGetSubKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{KSP}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCGASMGetSubKSP(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:PCGASMGetSubKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{Ptr{KSP}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCFieldSplitGetSubKSP(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCFieldSplitGetSubKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{KSP}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCFieldSplitSchurGetSubKSP( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:PCFieldSplitSchurGetSubKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{$PetscInt}, Ptr{Ptr{KSP}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGGetSmoother(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGGetSmoother, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{KSP}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGGetSmootherDown(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGGetSmootherDown, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{KSP}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGGetSmootherUp(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PCMGGetSmootherUp, $petsc_library), + PetscErrorCode, + (PC, $PetscInt, Ptr{KSP}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PCMGGetCoarseSolve(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGGetCoarseSolve, $petsc_library), + PetscErrorCode, + (PC, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function PCGalerkinGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCGalerkinGetKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function PCDeflationGetCoarseKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCDeflationGetCoarseKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function PCMGRegisterCoarseSpaceConstructor( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:PCMGRegisterCoarseSpaceConstructor, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCMGGetCoarseSpaceConstructor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCMGGetCoarseSpaceConstructor, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function KSPBuildSolution(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPBuildSolution, $petsc_library), + PetscErrorCode, + (KSP, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPBuildResidual(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:KSPBuildResidual, $petsc_library), + PetscErrorCode, + (KSP, Vec, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPRichardsonSetScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPRichardsonSetScale, $petsc_library), + PetscErrorCode, + (KSP, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function KSPRichardsonSetSelfScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPRichardsonSetSelfScale, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPChebyshevSetEigenvalues( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:KSPChebyshevSetEigenvalues, $petsc_library), + PetscErrorCode, + (KSP, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPChebyshevEstEigSet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPChebyshevEstEigSet, $petsc_library), + PetscErrorCode, + (KSP, $PetscReal, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPChebyshevEstEigSetUseNoisy(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPChebyshevEstEigSetUseNoisy, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPChebyshevEstEigGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPChebyshevEstEigGetKSP, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function KSPComputeExtremeSingularValues( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:KSPComputeExtremeSingularValues, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPComputeEigenvalues( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPComputeEigenvalues, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPComputeEigenvaluesExplicitly( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPComputeEigenvaluesExplicitly, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPComputeRitz( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:KSPComputeRitz, $petsc_library), + PetscErrorCode, + ( + KSP, + PetscBool, + PetscBool, + Ptr{$PetscInt}, + Ptr{Vec}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@enum KSPFCDTruncationType::UInt32 begin + KSP_FCD_TRUNC_TYPE_STANDARD = 0 + KSP_FCD_TRUNC_TYPE_NOTAY = 1 +end + +@for_petsc function KSPFCGSetMmax(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFCGSetMmax, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPFCGGetMmax(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFCGGetMmax, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPFCGSetNprealloc(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFCGSetNprealloc, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPFCGGetNprealloc(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFCGGetNprealloc, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPFCGSetTruncationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFCGSetTruncationType, $petsc_library), + PetscErrorCode, + (KSP, KSPFCDTruncationType), + arg1, + arg2, + ) +end + +@for_petsc function KSPFCGGetTruncationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFCGGetTruncationType, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSPFCDTruncationType}), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEFCGSetMmax(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEFCGSetMmax, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEFCGGetMmax(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEFCGGetMmax, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEFCGSetNprealloc(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEFCGSetNprealloc, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEFCGGetNprealloc(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEFCGGetNprealloc, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEFCGSetTruncationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEFCGSetTruncationType, $petsc_library), + PetscErrorCode, + (KSP, KSPFCDTruncationType), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEFCGGetTruncationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEFCGGetTruncationType, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSPFCDTruncationType}), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEGCRSetMmax(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEGCRSetMmax, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEGCRGetMmax(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEGCRGetMmax, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEGCRSetNprealloc(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEGCRSetNprealloc, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEGCRGetNprealloc(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEGCRGetNprealloc, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEGCRSetTruncationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEGCRSetTruncationType, $petsc_library), + PetscErrorCode, + (KSP, KSPFCDTruncationType), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEGCRGetTruncationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEGCRGetTruncationType, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSPFCDTruncationType}), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEGCRSetUnrollW(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEGCRSetUnrollW, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPPIPEGCRGetUnrollW(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEGCRGetUnrollW, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGMRESSetRestart(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGMRESSetRestart, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPGMRESGetRestart(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGMRESGetRestart, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGMRESSetHapTol(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGMRESSetHapTol, $petsc_library), + PetscErrorCode, + (KSP, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function KSPGMRESSetBreakdownTolerance(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGMRESSetBreakdownTolerance, $petsc_library), + PetscErrorCode, + (KSP, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function KSPGMRESSetPreAllocateVectors(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPGMRESSetPreAllocateVectors, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPGMRESSetOrthogonalization(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGMRESSetOrthogonalization, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGMRESGetOrthogonalization(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGMRESGetOrthogonalization, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGMRESModifiedGramSchmidtOrthogonalization( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:KSPGMRESModifiedGramSchmidtOrthogonalization, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPGMRESClassicalGramSchmidtOrthogonalization( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:KSPGMRESClassicalGramSchmidtOrthogonalization, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPLGMRESSetAugDim(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPLGMRESSetAugDim, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPLGMRESSetConstant(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPLGMRESSetConstant, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPPIPEFGMRESSetShift(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPIPEFGMRESSetShift, $petsc_library), + PetscErrorCode, + (KSP, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function KSPGCRSetRestart(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGCRSetRestart, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPGCRGetRestart(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGCRGetRestart, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGCRSetModifyPC(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:KSPGCRSetModifyPC, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPFETIDPGetInnerBDDC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFETIDPGetInnerBDDC, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PC}), + arg1, + arg2, + ) +end + +@for_petsc function KSPFETIDPSetInnerBDDC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFETIDPSetInnerBDDC, $petsc_library), + PetscErrorCode, + (KSP, PC), + arg1, + arg2, + ) +end + +@for_petsc function KSPFETIDPGetInnerKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFETIDPGetInnerKSP, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function KSPFETIDPSetPressureOperator(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPFETIDPSetPressureOperator, $petsc_library), + PetscErrorCode, + (KSP, Mat), + arg1, + arg2, + ) +end + +@for_petsc function KSPHPDDMSetDeflationSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPHPDDMSetDeflationSpace, $petsc_library), + PetscErrorCode, + (KSP, Mat), + arg1, + arg2, + ) +end + +@for_petsc function KSPHPDDMGetDeflationSpace(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPHPDDMGetDeflationSpace, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function KSPHPDDMMatSolve(::$UnionPetscLib, ksp, B, X) + @chk ccall( + (:KSPHPDDMMatSolve, $petsc_library), + PetscErrorCode, + (KSP, Mat, Mat), + ksp, + B, + X, + ) +end + +@enum KSPHPDDMType::UInt32 begin + KSP_HPDDM_TYPE_GMRES = 0 + KSP_HPDDM_TYPE_BGMRES = 1 + KSP_HPDDM_TYPE_CG = 2 + KSP_HPDDM_TYPE_BCG = 3 + KSP_HPDDM_TYPE_GCRODR = 4 + KSP_HPDDM_TYPE_BGCRODR = 5 + KSP_HPDDM_TYPE_BFBCG = 6 + KSP_HPDDM_TYPE_PREONLY = 7 +end + +@for_petsc function KSPHPDDMSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPHPDDMSetType, $petsc_library), + PetscErrorCode, + (KSP, KSPHPDDMType), + arg1, + arg2, + ) +end + +@for_petsc function KSPHPDDMGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPHPDDMGetType, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSPHPDDMType}), + arg1, + arg2, + ) +end + +@enum KSPGMRESCGSRefinementType::UInt32 begin + KSP_GMRES_CGS_REFINE_NEVER = 0 + KSP_GMRES_CGS_REFINE_IFNEEDED = 1 + KSP_GMRES_CGS_REFINE_ALWAYS = 2 +end + +@for_petsc function KSPGMRESSetCGSRefinementType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGMRESSetCGSRefinementType, $petsc_library), + PetscErrorCode, + (KSP, KSPGMRESCGSRefinementType), + arg1, + arg2, + ) +end + +@for_petsc function KSPGMRESGetCGSRefinementType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGMRESGetCGSRefinementType, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSPGMRESCGSRefinementType}), + arg1, + arg2, + ) +end + +@for_petsc function KSPFGMRESModifyPCNoChange( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPFGMRESModifyPCNoChange, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscInt, $PetscReal, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPFGMRESModifyPCKSP( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPFGMRESModifyPCKSP, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscInt, $PetscReal, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPFGMRESSetModifyPC( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPFGMRESSetModifyPC, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPQCGSetTrustRegionRadius(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPQCGSetTrustRegionRadius, $petsc_library), + PetscErrorCode, + (KSP, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function KSPQCGGetQuadratic(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPQCGGetQuadratic, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function KSPQCGGetTrialStepNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPQCGGetTrialStepNorm, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function KSPBCGSLSetXRes(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPBCGSLSetXRes, $petsc_library), + PetscErrorCode, + (KSP, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function KSPBCGSLSetPol(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPBCGSLSetPol, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPBCGSLSetEll(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPBCGSLSetEll, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPBCGSLSetUsePseudoinverse(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPBCGSLSetUsePseudoinverse, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPSetFromOptions, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPResetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPResetFromOptions, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPAddOptionsChecker(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPAddOptionsChecker, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid},), + arg1, + ) +end + +@for_petsc function KSPMonitorSetFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorSetFromOptions, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorLGCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:KSPMonitorLGCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Cchar}, + $PetscInt, + Ptr{Ptr{Cchar}}, + Cint, + Cint, + Cint, + Cint, + Ptr{PetscDrawLG}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function KSPMonitorResidual(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:KSPMonitorResidual, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorResidualDraw( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorResidualDraw, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorResidualDrawLG( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorResidualDrawLG, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorResidualDrawLGCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorResidualDrawLGCreate, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + PetscViewerFormat, + Ptr{Cvoid}, + Ptr{Ptr{PetscViewerAndFormat}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorResidualShort( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorResidualShort, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorResidualRange( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorResidualRange, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorTrueResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorTrueResidual, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorTrueResidualDraw( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorTrueResidualDraw, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorTrueResidualDrawLG( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorTrueResidualDrawLG, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorTrueResidualDrawLGCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorTrueResidualDrawLGCreate, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + PetscViewerFormat, + Ptr{Cvoid}, + Ptr{Ptr{PetscViewerAndFormat}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorTrueResidualMax( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorTrueResidualMax, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorError(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:KSPMonitorError, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorErrorDraw( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorErrorDraw, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorErrorDrawLG( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorErrorDrawLG, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorErrorDrawLGCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorErrorDrawLGCreate, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + PetscViewerFormat, + Ptr{Cvoid}, + Ptr{Ptr{PetscViewerAndFormat}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSolution(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:KSPMonitorSolution, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSolutionDraw( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorSolutionDraw, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSolutionDrawLG( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorSolutionDrawLG, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSolutionDrawLGCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorSolutionDrawLGCreate, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + PetscViewerFormat, + Ptr{Cvoid}, + Ptr{Ptr{PetscViewerAndFormat}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSingularValue( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorSingularValue, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSingularValueCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorSingularValueCreate, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + PetscViewerFormat, + Ptr{Cvoid}, + Ptr{Ptr{PetscViewerAndFormat}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorDefault(::$UnionPetscLib, ksp, n, rnorm, vf) + @chk ccall( + (:KSPMonitorDefault, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + ksp, + n, + rnorm, + vf, + ) +end + +@for_petsc function KSPMonitorTrueResidualNorm( + ::$UnionPetscLib, + ksp, + n, + rnorm, + vf, +) + @chk ccall( + (:KSPMonitorTrueResidualNorm, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + ksp, + n, + rnorm, + vf, + ) +end + +@for_petsc function KSPMonitorTrueResidualMaxNorm( + ::$UnionPetscLib, + ksp, + n, + rnorm, + vf, +) + @chk ccall( + (:KSPMonitorTrueResidualMaxNorm, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + ksp, + n, + rnorm, + vf, + ) +end + +@for_petsc function KSPGMRESMonitorKrylov( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPGMRESMonitorKrylov, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorDynamicTolerance( + ::$UnionPetscLib, + ksp, + its, + fnorm, + dummy, +) + @chk ccall( + (:KSPMonitorDynamicTolerance, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{Cvoid}), + ksp, + its, + fnorm, + dummy, + ) +end + +@for_petsc function KSPMonitorDynamicToleranceDestroy(::$UnionPetscLib, dummy) + @chk ccall( + (:KSPMonitorDynamicToleranceDestroy, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cvoid}},), + dummy, + ) +end + +@for_petsc function KSPMonitorSAWs(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:KSPMonitorSAWs, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSAWsCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPMonitorSAWsCreate, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function KSPMonitorSAWsDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPMonitorSAWsDestroy, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cvoid}},), + arg1, + ) +end + +@for_petsc function KSPUnwindPreconditioner(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPUnwindPreconditioner, $petsc_library), + PetscErrorCode, + (KSP, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPInitialResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:KSPInitialResidual, $petsc_library), + PetscErrorCode, + (KSP, Vec, Vec, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function KSPSetOperators(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPSetOperators, $petsc_library), + PetscErrorCode, + (KSP, Mat, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPGetOperators(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPGetOperators, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Mat}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPGetOperatorsSet(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPGetOperatorsSet, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function KSPAppendOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetDiagonalScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetDiagonalScale, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetDiagonalScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetDiagonalScale, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetDiagonalScaleFix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetDiagonalScaleFix, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetDiagonalScaleFix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetDiagonalScaleFix, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function KSPView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPView, $petsc_library), + PetscErrorCode, + (KSP, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function KSPLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPLoad, $petsc_library), + PetscErrorCode, + (KSP, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function KSPViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPViewFromOptions, $petsc_library), + PetscErrorCode, + (KSP, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPConvergedReasonView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPConvergedReasonView, $petsc_library), + PetscErrorCode, + (KSP, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function KSPConvergedReasonViewSet( + ::$UnionPetscLib, + arg1, + arg2, + vctx, + arg4, +) + @chk ccall( + (:KSPConvergedReasonViewSet, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + vctx, + arg4, + ) +end + +@for_petsc function KSPConvergedReasonViewFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPConvergedReasonViewFromOptions, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPConvergedReasonViewCancel(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPConvergedReasonViewCancel, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPConvergedRateView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPConvergedRateView, $petsc_library), + PetscErrorCode, + (KSP, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function KSPReasonView(::$UnionPetscLib, ksp, v) + @chk ccall( + (:KSPReasonView, $petsc_library), + PetscErrorCode, + (KSP, PetscViewer), + ksp, + v, + ) +end + +@for_petsc function KSPReasonViewFromOptions(::$UnionPetscLib, ksp) + @chk ccall( + (:KSPReasonViewFromOptions, $petsc_library), + PetscErrorCode, + (KSP,), + ksp, + ) +end + +@for_petsc function KSPLSQRSetExactMatNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPLSQRSetExactMatNorm, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPLSQRSetComputeStandardErrorVec( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:KSPLSQRSetComputeStandardErrorVec, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPLSQRGetStandardErrorVec(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPLSQRGetStandardErrorVec, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function KSPLSQRGetNorms(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPLSQRGetNorms, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPLSQRMonitorResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPLSQRMonitorResidual, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPLSQRMonitorResidualDrawLG( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPLSQRMonitorResidualDrawLG, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPLSQRMonitorResidualDrawLGCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPLSQRMonitorResidualDrawLGCreate, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + PetscViewerFormat, + Ptr{Cvoid}, + Ptr{Ptr{PetscViewerAndFormat}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCRedundantGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCRedundantGetKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function PCRedistributeGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCRedistributeGetKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function PCTelescopeGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCTelescopeGetKSP, $petsc_library), + PetscErrorCode, + (PC, Ptr{KSP}), + arg1, + arg2, + ) +end + +@enum KSPNormType::Int32 begin + KSP_NORM_DEFAULT = -1 + KSP_NORM_NONE = 0 + KSP_NORM_PRECONDITIONED = 1 + KSP_NORM_UNPRECONDITIONED = 2 + KSP_NORM_NATURAL = 3 +end + +@for_petsc function KSPSetNormType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetNormType, $petsc_library), + PetscErrorCode, + (KSP, KSPNormType), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetNormType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetNormType, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSPNormType}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetSupportedNorm(::$UnionPetscLib, ksp, arg2, arg3, arg4) + @chk ccall( + (:KSPSetSupportedNorm, $petsc_library), + PetscErrorCode, + (KSP, KSPNormType, PCSide, $PetscInt), + ksp, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPSetCheckNormIteration(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetCheckNormIteration, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetLagNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetLagNorm, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@enum KSPConvergedReason::Int32 begin + KSP_CONVERGED_RTOL_NORMAL = 1 + KSP_CONVERGED_ATOL_NORMAL = 9 + KSP_CONVERGED_RTOL = 2 + KSP_CONVERGED_ATOL = 3 + KSP_CONVERGED_ITS = 4 + KSP_CONVERGED_CG_NEG_CURVE = 5 + KSP_CONVERGED_CG_CONSTRAINED = 6 + KSP_CONVERGED_STEP_LENGTH = 7 + KSP_CONVERGED_HAPPY_BREAKDOWN = 8 + KSP_DIVERGED_NULL = -2 + KSP_DIVERGED_ITS = -3 + KSP_DIVERGED_DTOL = -4 + KSP_DIVERGED_BREAKDOWN = -5 + KSP_DIVERGED_BREAKDOWN_BICG = -6 + KSP_DIVERGED_NONSYMMETRIC = -7 + KSP_DIVERGED_INDEFINITE_PC = -8 + KSP_DIVERGED_NANORINF = -9 + KSP_DIVERGED_INDEFINITE_MAT = -10 + KSP_DIVERGED_PC_FAILED = -11 + # KSP_DIVERGED_PCSETUP_FAILED = -11 + KSP_CONVERGED_ITERATING = 0 +end + +@for_petsc function KSPSetConvergenceTest( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPSetConvergenceTest, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPGetConvergenceTest( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPGetConvergenceTest, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPGetAndClearConvergenceTest( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPGetAndClearConvergenceTest, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPGetConvergenceContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetConvergenceContext, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function KSPConvergedDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPConvergedDefault, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{KSPConvergedReason}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPLSQRConvergedDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPLSQRConvergedDefault, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{KSPConvergedReason}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPConvergedDefaultDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPConvergedDefaultDestroy, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid},), + arg1, + ) +end + +@for_petsc function KSPConvergedDefaultCreate(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPConvergedDefaultCreate, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cvoid}},), + arg1, + ) +end + +@for_petsc function KSPConvergedDefaultSetUIRNorm(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPConvergedDefaultSetUIRNorm, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPConvergedDefaultSetUMIRNorm(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPConvergedDefaultSetUMIRNorm, $petsc_library), + PetscErrorCode, + (KSP,), + arg1, + ) +end + +@for_petsc function KSPConvergedDefaultSetConvergedMaxits( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:KSPConvergedDefaultSetConvergedMaxits, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPConvergedSkip( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPConvergedSkip, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{KSPConvergedReason}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPGetConvergedReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetConvergedReason, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSPConvergedReason}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetConvergedReasonString(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetConvergedReasonString, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function KSPComputeConvergenceRate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:KSPComputeConvergenceRate, $petsc_library), + PetscErrorCode, + ( + KSP, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function KSPComputeOperator(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPComputeOperator, $petsc_library), + PetscErrorCode, + (KSP, MatType, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPComputeExplicitOperator(::$UnionPetscLib, A, B) + @chk ccall( + (:KSPComputeExplicitOperator, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Mat}), + A, + B, + ) +end + +@enum KSPCGType::UInt32 begin + KSP_CG_SYMMETRIC = 0 + KSP_CG_HERMITIAN = 1 +end + +@for_petsc function KSPCGSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPCGSetType, $petsc_library), + PetscErrorCode, + (KSP, KSPCGType), + arg1, + arg2, + ) +end + +@for_petsc function KSPCGUseSingleReduction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPCGUseSingleReduction, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPCGSetRadius(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPCGSetRadius, $petsc_library), + PetscErrorCode, + (KSP, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function KSPCGGetNormD(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPCGGetNormD, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function KSPCGGetObjFcn(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPCGGetObjFcn, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGLTRGetMinEig(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGLTRGetMinEig, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGLTRGetLambda(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGLTRGetLambda, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function KSPCGGLTRGetMinEig(::$UnionPetscLib, ksp, x) + @chk ccall( + (:KSPCGGLTRGetMinEig, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}), + ksp, + x, + ) +end + +@for_petsc function KSPCGGLTRGetLambda(::$UnionPetscLib, ksp, x) + @chk ccall( + (:KSPCGGLTRGetLambda, $petsc_library), + PetscErrorCode, + (KSP, Ptr{$PetscReal}), + ksp, + x, + ) +end + +@for_petsc function KSPPythonSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPPythonSetType, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function PCPreSolve(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPreSolve, $petsc_library), + PetscErrorCode, + (PC, KSP), + arg1, + arg2, + ) +end + +@for_petsc function PCPostSolve(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCPostSolve, $petsc_library), + PetscErrorCode, + (PC, KSP), + arg1, + arg2, + ) +end + +@for_petsc function KSPMonitorLGRange(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:KSPMonitorLGRange, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PCShellSetPreSolve(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetPreSolve, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function PCShellSetPostSolve(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PCShellSetPostSolve, $petsc_library), + PetscErrorCode, + (PC, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +mutable struct _p_KSPGuess end + +const KSPGuess = Ptr{_p_KSPGuess} + +const KSPGuessType = Ptr{Cchar} + +@for_petsc function KSPGuessRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGuessRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetGuess(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetGuess, $petsc_library), + PetscErrorCode, + (KSP, KSPGuess), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetGuess(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetGuess, $petsc_library), + PetscErrorCode, + (KSP, Ptr{KSPGuess}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGuessView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGuessView, $petsc_library), + PetscErrorCode, + (KSPGuess, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function KSPGuessDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPGuessDestroy, $petsc_library), + PetscErrorCode, + (Ptr{KSPGuess},), + arg1, + ) +end + +@for_petsc function KSPGuessCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGuessCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{KSPGuess}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGuessSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGuessSetType, $petsc_library), + PetscErrorCode, + (KSPGuess, KSPGuessType), + arg1, + arg2, + ) +end + +@for_petsc function KSPGuessGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGuessGetType, $petsc_library), + PetscErrorCode, + (KSPGuess, Ptr{KSPGuessType}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGuessSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPGuessSetUp, $petsc_library), + PetscErrorCode, + (KSPGuess,), + arg1, + ) +end + +@for_petsc function KSPGuessUpdate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPGuessUpdate, $petsc_library), + PetscErrorCode, + (KSPGuess, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPGuessFormGuess(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPGuessFormGuess, $petsc_library), + PetscErrorCode, + (KSPGuess, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPGuessSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:KSPGuessSetFromOptions, $petsc_library), + PetscErrorCode, + (KSPGuess,), + arg1, + ) +end + +@for_petsc function KSPGuessFischerSetModel(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPGuessFischerSetModel, $petsc_library), + PetscErrorCode, + (KSPGuess, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetUseFischerGuess(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPSetUseFischerGuess, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetInitialGuessKnoll(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetInitialGuessKnoll, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetInitialGuessKnoll(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetInitialGuessKnoll, $petsc_library), + PetscErrorCode, + (KSP, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@enum MatSchurComplementAinvType::UInt32 begin + MAT_SCHUR_COMPLEMENT_AINV_DIAG = 0 + MAT_SCHUR_COMPLEMENT_AINV_LUMP = 1 + MAT_SCHUR_COMPLEMENT_AINV_BLOCK_DIAG = 2 +end + +@enum MatLMVMSymBroydenScaleType::UInt32 begin + MAT_LMVM_SYMBROYDEN_SCALE_NONE = 0 + MAT_LMVM_SYMBROYDEN_SCALE_SCALAR = 1 + MAT_LMVM_SYMBROYDEN_SCALE_DIAGONAL = 2 + MAT_LMVM_SYMBROYDEN_SCALE_USER = 3 +end + +@for_petsc function MatCreateSchurComplement( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatCreateSchurComplement, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Mat, Mat, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatSchurComplementGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSchurComplementGetKSP, $petsc_library), + PetscErrorCode, + (Mat, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function MatSchurComplementSetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSchurComplementSetKSP, $petsc_library), + PetscErrorCode, + (Mat, KSP), + arg1, + arg2, + ) +end + +@for_petsc function MatSchurComplementSetSubMatrices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatSchurComplementSetSubMatrices, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Mat, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatSchurComplementUpdateSubMatrices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatSchurComplementUpdateSubMatrices, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Mat, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatSchurComplementGetSubMatrices( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatSchurComplementGetSubMatrices, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}, Ptr{Mat}, Ptr{Mat}, Ptr{Mat}, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatSchurComplementSetAinvType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSchurComplementSetAinvType, $petsc_library), + PetscErrorCode, + (Mat, MatSchurComplementAinvType), + arg1, + arg2, + ) +end + +@for_petsc function MatSchurComplementGetAinvType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSchurComplementGetAinvType, $petsc_library), + PetscErrorCode, + (Mat, Ptr{MatSchurComplementAinvType}), + arg1, + arg2, + ) +end + +@for_petsc function MatSchurComplementGetPmat( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:MatSchurComplementGetPmat, $petsc_library), + PetscErrorCode, + (Mat, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatSchurComplementComputeExplicitOperator( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:MatSchurComplementComputeExplicitOperator, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatGetSchurComplement( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:MatGetSchurComplement, $petsc_library), + PetscErrorCode, + ( + Mat, + IS, + IS, + IS, + IS, + MatReuse, + Ptr{Mat}, + MatSchurComplementAinvType, + MatReuse, + Ptr{Mat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function MatCreateSchurComplementPmat( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatCreateSchurComplementPmat, $petsc_library), + PetscErrorCode, + (Mat, Mat, Mat, Mat, MatSchurComplementAinvType, MatReuse, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatCreateLMVMDFP(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatCreateLMVMDFP, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateLMVMBFGS(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatCreateLMVMBFGS, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateLMVMSR1(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:MatCreateLMVMSR1, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateLMVMBroyden( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatCreateLMVMBroyden, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateLMVMBadBroyden( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatCreateLMVMBadBroyden, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateLMVMSymBroyden( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatCreateLMVMSymBroyden, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateLMVMSymBadBroyden( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatCreateLMVMSymBadBroyden, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatCreateLMVMDiagBroyden( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:MatCreateLMVMDiagBroyden, $petsc_library), + PetscErrorCode, + (MPI_Comm, $PetscInt, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function MatLMVMUpdate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatLMVMUpdate, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatLMVMIsAllocated(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMIsAllocated, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMAllocate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatLMVMAllocate, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatLMVMReset(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMReset, $petsc_library), + PetscErrorCode, + (Mat, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMResetShift(::$UnionPetscLib, arg1) + @chk ccall( + (:MatLMVMResetShift, $petsc_library), + PetscErrorCode, + (Mat,), + arg1, + ) +end + +@for_petsc function MatLMVMClearJ0(::$UnionPetscLib, arg1) + @chk ccall((:MatLMVMClearJ0, $petsc_library), PetscErrorCode, (Mat,), arg1) +end + +@for_petsc function MatLMVMSetJ0(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMSetJ0, $petsc_library), + PetscErrorCode, + (Mat, Mat), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMSetJ0Scale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMSetJ0Scale, $petsc_library), + PetscErrorCode, + (Mat, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMSetJ0Diag(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMSetJ0Diag, $petsc_library), + PetscErrorCode, + (Mat, Vec), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMSetJ0PC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMSetJ0PC, $petsc_library), + PetscErrorCode, + (Mat, PC), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMSetJ0KSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMSetJ0KSP, $petsc_library), + PetscErrorCode, + (Mat, KSP), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMApplyJ0Fwd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatLMVMApplyJ0Fwd, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatLMVMApplyJ0Inv(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:MatLMVMApplyJ0Inv, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatLMVMGetJ0(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMGetJ0, $petsc_library), + PetscErrorCode, + (Mat, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMGetJ0PC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMGetJ0PC, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PC}), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMGetJ0KSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMGetJ0KSP, $petsc_library), + PetscErrorCode, + (Mat, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMSetHistorySize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMSetHistorySize, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMGetUpdateCount(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMGetUpdateCount, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMGetRejectCount(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMGetRejectCount, $petsc_library), + PetscErrorCode, + (Mat, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMSymBroydenSetDelta(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMSymBroydenSetDelta, $petsc_library), + PetscErrorCode, + (Mat, $PetscScalar), + arg1, + arg2, + ) +end + +@for_petsc function MatLMVMSymBroydenSetScaleType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatLMVMSymBroydenSetScaleType, $petsc_library), + PetscErrorCode, + (Mat, MatLMVMSymBroydenScaleType), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetDM, $petsc_library), + PetscErrorCode, + (KSP, DM), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetDMActive(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetDMActive, $petsc_library), + PetscErrorCode, + (KSP, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetDM, $petsc_library), + PetscErrorCode, + (KSP, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPSetApplicationContext, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function KSPGetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:KSPGetApplicationContext, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function KSPSetComputeRHS(::$UnionPetscLib, arg1, func, arg3) + @chk ccall( + (:KSPSetComputeRHS, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + func, + arg3, + ) +end + +@for_petsc function KSPSetComputeOperators(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:KSPSetComputeOperators, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function KSPSetComputeInitialGuess( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:KSPSetComputeInitialGuess, $petsc_library), + PetscErrorCode, + (KSP, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMKSPSetComputeOperators(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMKSPSetComputeOperators, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMKSPGetComputeOperators(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMKSPGetComputeOperators, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMKSPSetComputeRHS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMKSPSetComputeRHS, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMKSPGetComputeRHS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMKSPGetComputeRHS, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMKSPSetComputeInitialGuess( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMKSPSetComputeInitialGuess, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMKSPGetComputeInitialGuess( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMKSPGetComputeInitialGuess, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMGlobalToLocalSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMGlobalToLocalSolve, $petsc_library), + PetscErrorCode, + (DM, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMProjectField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMProjectField, $petsc_library), + PetscErrorCode, + (DM, $PetscReal, Vec, Ptr{Ptr{Cvoid}}, InsertMode, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMAdaptInterpolator( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:DMAdaptInterpolator, $petsc_library), + PetscErrorCode, + (DM, DM, Mat, KSP, $PetscInt, Ptr{Vec}, Ptr{Vec}, Ptr{Mat}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function DMCheckInterpolator( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMCheckInterpolator, $petsc_library), + PetscErrorCode, + (DM, Mat, $PetscInt, Ptr{Vec}, Ptr{Vec}, $PetscReal), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +mutable struct _p_SNES end + +const SNES = Ptr{_p_SNES} + +const SNESType = Ptr{Cchar} + +@for_petsc function SNESInitializePackage(::$UnionPetscLib) + @chk ccall((:SNESInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function SNESCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function SNESReset(::$UnionPetscLib, arg1) + @chk ccall((:SNESReset, $petsc_library), PetscErrorCode, (SNES,), arg1) +end + +@for_petsc function SNESDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESDestroy, $petsc_library), + PetscErrorCode, + (Ptr{SNES},), + arg1, + ) +end + +@for_petsc function SNESSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetType, $petsc_library), + PetscErrorCode, + (SNES, SNESType), + arg1, + arg2, + ) +end + +@for_petsc function SNESMonitor(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESMonitor, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESMonitorSet(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESMonitorSet, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorSetFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESMonitorSetFromOptions, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESMonitorCancel(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESMonitorCancel, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function SNESMonitorSAWs(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESMonitorSAWs, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorSAWsCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESMonitorSAWsCreate, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function SNESMonitorSAWsDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESMonitorSAWsDestroy, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cvoid}},), + arg1, + ) +end + +@for_petsc function SNESSetConvergenceHistory( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESSetConvergenceHistory, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscReal}, Ptr{$PetscInt}, $PetscInt, PetscBool), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESGetConvergenceHistory( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESGetConvergenceHistory, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Ptr{$PetscReal}}, Ptr{Ptr{$PetscInt}}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESSetUp(::$UnionPetscLib, arg1) + @chk ccall((:SNESSetUp, $petsc_library), PetscErrorCode, (SNES,), arg1) +end + +@for_petsc function SNESSolve(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESSolve, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESSetErrorIfNotConverged(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetErrorIfNotConverged, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetErrorIfNotConverged(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetErrorIfNotConverged, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetWorkVecs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetWorkVecs, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESAddOptionsChecker(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESAddOptionsChecker, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid},), + arg1, + ) +end + +@for_petsc function SNESSetUpdate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetUpdate, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function SNESRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetKSP, $petsc_library), + PetscErrorCode, + (SNES, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetKSP, $petsc_library), + PetscErrorCode, + (SNES, KSP), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetSolution(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetSolution, $petsc_library), + PetscErrorCode, + (SNES, Vec), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetSolution(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetSolution, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetSolutionUpdate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetSolutionUpdate, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetRhs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetRhs, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function SNESView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESView, $petsc_library), + PetscErrorCode, + (SNES, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function SNESLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLoad, $petsc_library), + PetscErrorCode, + (SNES, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function SNESConvergedReasonViewSet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESConvergedReasonViewSet, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESViewFromOptions, $petsc_library), + PetscErrorCode, + (SNES, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESConvergedReasonView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESConvergedReasonView, $petsc_library), + PetscErrorCode, + (SNES, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function SNESConvergedReasonViewFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESConvergedReasonViewFromOptions, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function SNESConvergedReasonViewCancel(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESConvergedReasonViewCancel, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function SNESReasonView(::$UnionPetscLib, snes, v) + @chk ccall( + (:SNESReasonView, $petsc_library), + PetscErrorCode, + (SNES, PetscViewer), + snes, + v, + ) +end + +@for_petsc function SNESReasonViewFromOptions(::$UnionPetscLib, snes) + @chk ccall( + (:SNESReasonViewFromOptions, $petsc_library), + PetscErrorCode, + (SNES,), + snes, + ) +end + +@for_petsc function SNESSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function SNESAppendOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESSetFromOptions, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function SNESResetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESResetFromOptions, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function SNESSetUseMatrixFree(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESSetUseMatrixFree, $petsc_library), + PetscErrorCode, + (SNES, PetscBool, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESGetUseMatrixFree(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESGetUseMatrixFree, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function MatCreateSNESMF(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatCreateSNESMF, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function MatSNESMFGetSNES(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSNESMFGetSNES, $petsc_library), + PetscErrorCode, + (Mat, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function MatSNESMFSetReuseBase(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSNESMFSetReuseBase, $petsc_library), + PetscErrorCode, + (Mat, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function MatSNESMFGetReuseBase(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:MatSNESMFGetReuseBase, $petsc_library), + PetscErrorCode, + (Mat, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function MatMFFDComputeJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:MatMFFDComputeJacobian, $petsc_library), + PetscErrorCode, + (SNES, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetType, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNESType}), + arg1, + arg2, + ) +end + +@for_petsc function SNESMonitorDefault(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESMonitorDefault, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorScaling(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESMonitorScaling, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorRange(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESMonitorRange, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorRatio(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESMonitorRatio, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorRatioSetUp(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESMonitorRatioSetUp, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + ) +end + +@for_petsc function SNESMonitorSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESMonitorSolution, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESMonitorResidual, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorSolutionUpdate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESMonitorSolutionUpdate, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorDefaultShort( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESMonitorDefaultShort, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorDefaultField( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESMonitorDefaultField, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorJacUpdateSpectrum( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESMonitorJacUpdateSpectrum, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMonitorFields(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESMonitorFields, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSNESResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorSNESResidual, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSNESResidualDrawLG( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorSNESResidualDrawLG, $petsc_library), + PetscErrorCode, + (KSP, $PetscInt, $PetscReal, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function KSPMonitorSNESResidualDrawLGCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:KSPMonitorSNESResidualDrawLGCreate, $petsc_library), + PetscErrorCode, + ( + PetscViewer, + PetscViewerFormat, + Ptr{Cvoid}, + Ptr{Ptr{PetscViewerAndFormat}}, + ), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESSetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESSetTolerances, $petsc_library), + PetscErrorCode, + (SNES, $PetscReal, $PetscReal, $PetscReal, $PetscInt, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESSetDivergenceTolerance(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetDivergenceTolerance, $petsc_library), + PetscErrorCode, + (SNES, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESGetTolerances, $petsc_library), + PetscErrorCode, + ( + SNES, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESGetDivergenceTolerance(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetDivergenceTolerance, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetTrustRegionTolerance(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetTrustRegionTolerance, $petsc_library), + PetscErrorCode, + (SNES, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetForceIteration(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetForceIteration, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetForceIteration(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetForceIteration, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetIterationNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetIterationNumber, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetIterationNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetIterationNumber, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESNewtonTRSetPreCheck(::$UnionPetscLib, arg1, arg2, ctx) + @chk ccall( + (:SNESNewtonTRSetPreCheck, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + ctx, + ) +end + +@for_petsc function SNESNewtonTRGetPreCheck(::$UnionPetscLib, arg1, arg2, ctx) + @chk ccall( + (:SNESNewtonTRGetPreCheck, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ctx, + ) +end + +@for_petsc function SNESNewtonTRSetPostCheck(::$UnionPetscLib, arg1, arg2, ctx) + @chk ccall( + (:SNESNewtonTRSetPostCheck, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + ctx, + ) +end + +@for_petsc function SNESNewtonTRGetPostCheck(::$UnionPetscLib, arg1, arg2, ctx) + @chk ccall( + (:SNESNewtonTRGetPostCheck, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ctx, + ) +end + +@for_petsc function SNESGetNonlinearStepFailures(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetNonlinearStepFailures, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetMaxNonlinearStepFailures( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESSetMaxNonlinearStepFailures, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetMaxNonlinearStepFailures( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESGetMaxNonlinearStepFailures, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetNumberFunctionEvals(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetNumberFunctionEvals, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetLagPreconditioner(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetLagPreconditioner, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetLagPreconditioner(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetLagPreconditioner, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetLagJacobian(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetLagJacobian, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetLagJacobian(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetLagJacobian, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetLagPreconditionerPersists( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESSetLagPreconditionerPersists, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetLagJacobianPersists(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetLagJacobianPersists, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetGridSequence(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetGridSequence, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetGridSequence(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetGridSequence, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetLinearSolveIterations(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetLinearSolveIterations, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetLinearSolveFailures(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetLinearSolveFailures, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetMaxLinearSolveFailures(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetMaxLinearSolveFailures, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetMaxLinearSolveFailures(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetMaxLinearSolveFailures, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetCountersReset(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetCountersReset, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESKSPSetUseEW(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESKSPSetUseEW, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESKSPGetUseEW(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESKSPGetUseEW, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function SNESKSPSetParametersEW( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:SNESKSPSetParametersEW, $petsc_library), + PetscErrorCode, + ( + SNES, + $PetscInt, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function SNESKSPGetParametersEW( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:SNESKSPGetParametersEW, $petsc_library), + PetscErrorCode, + ( + SNES, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function SNESMonitorLGRange(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESMonitorLGRange, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESSetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetApplicationContext, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetApplicationContext, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetComputeApplicationContext( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:SNESSetComputeApplicationContext, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESPythonSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESPythonSetType, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetFunctionDomainError(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESSetFunctionDomainError, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function SNESGetFunctionDomainError(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetFunctionDomainError, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetJacobianDomainError(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetJacobianDomainError, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetJacobianDomainError(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESSetJacobianDomainError, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function SNESSetCheckJacobianDomainError( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESSetCheckJacobianDomainError, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetCheckJacobianDomainError( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESGetCheckJacobianDomainError, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@enum SNESConvergedReason::Int32 begin + SNES_CONVERGED_FNORM_ABS = 2 + SNES_CONVERGED_FNORM_RELATIVE = 3 + SNES_CONVERGED_SNORM_RELATIVE = 4 + SNES_CONVERGED_ITS = 5 + SNES_DIVERGED_FUNCTION_DOMAIN = -1 + SNES_DIVERGED_FUNCTION_COUNT = -2 + SNES_DIVERGED_LINEAR_SOLVE = -3 + SNES_DIVERGED_FNORM_NAN = -4 + SNES_DIVERGED_MAX_IT = -5 + SNES_DIVERGED_LINE_SEARCH = -6 + SNES_DIVERGED_INNER = -7 + SNES_DIVERGED_LOCAL_MIN = -8 + SNES_DIVERGED_DTOL = -9 + SNES_DIVERGED_JACOBIAN_DOMAIN = -10 + SNES_DIVERGED_TR_DELTA = -11 + # SNES_CONVERGED_TR_DELTA = -11 + SNES_CONVERGED_ITERATING = 0 +end + +@for_petsc function SNESSetConvergenceTest( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESSetConvergenceTest, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESConvergedDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:SNESConvergedDefault, $petsc_library), + PetscErrorCode, + ( + SNES, + $PetscInt, + $PetscReal, + $PetscReal, + $PetscReal, + Ptr{SNESConvergedReason}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function SNESConvergedSkip( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:SNESConvergedSkip, $petsc_library), + PetscErrorCode, + ( + SNES, + $PetscInt, + $PetscReal, + $PetscReal, + $PetscReal, + Ptr{SNESConvergedReason}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function SNESConvergedCorrectPressure( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:SNESConvergedCorrectPressure, $petsc_library), + PetscErrorCode, + ( + SNES, + $PetscInt, + $PetscReal, + $PetscReal, + $PetscReal, + Ptr{SNESConvergedReason}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function SNESGetConvergedReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetConvergedReason, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNESConvergedReason}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetConvergedReasonString(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetConvergedReasonString, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetConvergedReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetConvergedReason, $petsc_library), + PetscErrorCode, + (SNES, SNESConvergedReason), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetFunction(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESSetFunction, $petsc_library), + PetscErrorCode, + (SNES, Vec, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESGetFunction(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESGetFunction, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Vec}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESComputeFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESComputeFunction, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESSetInitialFunction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetInitialFunction, $petsc_library), + PetscErrorCode, + (SNES, Vec), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESSetJacobian, $petsc_library), + PetscErrorCode, + (SNES, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESGetJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESGetJacobian, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Mat}, Ptr{Mat}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESObjectiveComputeFunctionDefaultFD( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESObjectiveComputeFunctionDefaultFD, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESComputeJacobianDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESComputeJacobianDefault, $petsc_library), + PetscErrorCode, + (SNES, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESComputeJacobianDefaultColor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESComputeJacobianDefaultColor, $petsc_library), + PetscErrorCode, + (SNES, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESSetComputeInitialGuess( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:SNESSetComputeInitialGuess, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESSetPicard( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:SNESSetPicard, $petsc_library), + PetscErrorCode, + (SNES, Vec, Ptr{Cvoid}, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function SNESGetPicard( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:SNESGetPicard, $petsc_library), + PetscErrorCode, + ( + SNES, + Ptr{Vec}, + Ptr{Ptr{Cvoid}}, + Ptr{Mat}, + Ptr{Mat}, + Ptr{Ptr{Cvoid}}, + Ptr{Ptr{Cvoid}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function SNESPicardComputeFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESPicardComputeFunction, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESPicardComputeJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESPicardComputeJacobian, $petsc_library), + PetscErrorCode, + (SNES, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESSetObjective(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESSetObjective, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESGetObjective(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESGetObjective, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESComputeObjective(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESComputeObjective, $petsc_library), + PetscErrorCode, + (SNES, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@enum SNESNormSchedule::Int32 begin + SNES_NORM_DEFAULT = -1 + SNES_NORM_NONE = 0 + SNES_NORM_ALWAYS = 1 + SNES_NORM_INITIAL_ONLY = 2 + SNES_NORM_FINAL_ONLY = 3 + SNES_NORM_INITIAL_FINAL_ONLY = 4 +end + +@for_petsc function SNESSetNormSchedule(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetNormSchedule, $petsc_library), + PetscErrorCode, + (SNES, SNESNormSchedule), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetNormSchedule(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetNormSchedule, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNESNormSchedule}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetFunctionNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetFunctionNorm, $petsc_library), + PetscErrorCode, + (SNES, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetFunctionNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetFunctionNorm, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetUpdateNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetUpdateNorm, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetSolutionNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetSolutionNorm, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@enum SNESFunctionType::Int32 begin + SNES_FUNCTION_DEFAULT = -1 + SNES_FUNCTION_UNPRECONDITIONED = 0 + SNES_FUNCTION_PRECONDITIONED = 1 +end + +@for_petsc function SNESSetFunctionType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetFunctionType, $petsc_library), + PetscErrorCode, + (SNES, SNESFunctionType), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetFunctionType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetFunctionType, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNESFunctionType}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetNGS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESSetNGS, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESGetNGS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESGetNGS, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESComputeNGS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESComputeNGS, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESNGSSetSweeps(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNGSSetSweeps, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESNGSGetSweeps(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNGSGetSweeps, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESNGSSetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESNGSSetTolerances, $petsc_library), + PetscErrorCode, + (SNES, $PetscReal, $PetscReal, $PetscReal, $PetscInt), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESNGSGetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESNGSGetTolerances, $petsc_library), + PetscErrorCode, + ( + SNES, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESSetAlwaysComputesFinalResidual( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESSetAlwaysComputesFinalResidual, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetAlwaysComputesFinalResidual( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESGetAlwaysComputesFinalResidual, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function SNESShellGetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESShellGetContext, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function SNESShellSetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESShellSetContext, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function SNESShellSetSolve(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESShellSetSolve, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +mutable struct _p_LineSearch end + +const SNESLineSearch = Ptr{_p_LineSearch} + +const SNESLineSearchType = Ptr{Cchar} + +# typedef PetscErrorCode ( * SNESLineSearchVIProjectFunc ) ( SNES , Vec ) +const SNESLineSearchVIProjectFunc = Ptr{Cvoid} + +# typedef PetscErrorCode ( * SNESLineSearchVINormFunc ) ( SNES , Vec , Vec , PetscReal * ) +const SNESLineSearchVINormFunc = Ptr{Cvoid} + +# typedef PetscErrorCode ( * SNESLineSearchApplyFunc ) ( SNESLineSearch ) +const SNESLineSearchApplyFunc = Ptr{Cvoid} + +# typedef PetscErrorCode ( * SNESLineSearchUserFunc ) ( SNESLineSearch , void * ) +const SNESLineSearchUserFunc = Ptr{Cvoid} + +@for_petsc function SNESLineSearchCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{SNESLineSearch}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchReset(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESLineSearchReset, $petsc_library), + PetscErrorCode, + (SNESLineSearch,), + arg1, + ) +end + +@for_petsc function SNESLineSearchView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchView, $petsc_library), + PetscErrorCode, + (SNESLineSearch, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESLineSearchDestroy, $petsc_library), + PetscErrorCode, + (Ptr{SNESLineSearch},), + arg1, + ) +end + +@for_petsc function SNESLineSearchGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchGetType, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{SNESLineSearchType}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchSetType, $petsc_library), + PetscErrorCode, + (SNESLineSearch, SNESLineSearchType), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESLineSearchSetFromOptions, $petsc_library), + PetscErrorCode, + (SNESLineSearch,), + arg1, + ) +end + +@for_petsc function SNESLineSearchSetFunction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchSetFunction, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESLineSearchSetUp, $petsc_library), + PetscErrorCode, + (SNESLineSearch,), + arg1, + ) +end + +@for_petsc function SNESLineSearchApply( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESLineSearchApply, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Vec, Vec, Ptr{$PetscReal}, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESLineSearchPreCheck( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESLineSearchPreCheck, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Vec, Vec, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESLineSearchPostCheck( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESLineSearchPostCheck, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Vec, Vec, Vec, Ptr{PetscBool}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESLineSearchSetWorkVecs(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchSetWorkVecs, $petsc_library), + PetscErrorCode, + (SNESLineSearch, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchSetPreCheck(::$UnionPetscLib, arg1, arg2, ctx) + @chk ccall( + (:SNESLineSearchSetPreCheck, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + ctx, + ) +end + +@for_petsc function SNESLineSearchSetPostCheck( + ::$UnionPetscLib, + arg1, + arg2, + ctx, +) + @chk ccall( + (:SNESLineSearchSetPostCheck, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + ctx, + ) +end + +@for_petsc function SNESLineSearchGetPreCheck(::$UnionPetscLib, arg1, arg2, ctx) + @chk ccall( + (:SNESLineSearchGetPreCheck, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ctx, + ) +end + +@for_petsc function SNESLineSearchGetPostCheck( + ::$UnionPetscLib, + arg1, + arg2, + ctx, +) + @chk ccall( + (:SNESLineSearchGetPostCheck, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ctx, + ) +end + +@for_petsc function SNESLineSearchSetVIFunctions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:SNESLineSearchSetVIFunctions, $petsc_library), + PetscErrorCode, + (SNESLineSearch, SNESLineSearchVIProjectFunc, SNESLineSearchVINormFunc), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESLineSearchGetVIFunctions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:SNESLineSearchGetVIFunctions, $petsc_library), + PetscErrorCode, + ( + SNESLineSearch, + Ptr{SNESLineSearchVIProjectFunc}, + Ptr{SNESLineSearchVINormFunc}, + ), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESLineSearchSetSNES(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchSetSNES, $petsc_library), + PetscErrorCode, + (SNESLineSearch, SNES), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchGetSNES(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchGetSNES, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchGetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:SNESLineSearchGetTolerances, $petsc_library), + PetscErrorCode, + ( + SNESLineSearch, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function SNESLineSearchSetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:SNESLineSearchSetTolerances, $petsc_library), + PetscErrorCode, + ( + SNESLineSearch, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscInt, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function SNESLineSearchPreCheckPicard( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESLineSearchPreCheckPicard, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Vec, Vec, Ptr{PetscBool}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function SNESLineSearchGetLambda(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchGetLambda, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchSetLambda(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchSetLambda, $petsc_library), + PetscErrorCode, + (SNESLineSearch, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchGetDamping(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchGetDamping, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchSetDamping(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchSetDamping, $petsc_library), + PetscErrorCode, + (SNESLineSearch, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchGetOrder(::$UnionPetscLib, arg1, order) + @chk ccall( + (:SNESLineSearchGetOrder, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{$PetscInt}), + arg1, + order, + ) +end + +@for_petsc function SNESLineSearchSetOrder(::$UnionPetscLib, arg1, order) + @chk ccall( + (:SNESLineSearchSetOrder, $petsc_library), + PetscErrorCode, + (SNESLineSearch, $PetscInt), + arg1, + order, + ) +end + +@enum SNESLineSearchReason::UInt32 begin + SNES_LINESEARCH_SUCCEEDED = 0 + SNES_LINESEARCH_FAILED_NANORINF = 1 + SNES_LINESEARCH_FAILED_DOMAIN = 2 + SNES_LINESEARCH_FAILED_REDUCT = 3 + SNES_LINESEARCH_FAILED_USER = 4 + SNES_LINESEARCH_FAILED_FUNCTION = 5 +end + +@for_petsc function SNESLineSearchGetReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchGetReason, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{SNESLineSearchReason}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchSetReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchSetReason, $petsc_library), + PetscErrorCode, + (SNESLineSearch, SNESLineSearchReason), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchGetVecs( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESLineSearchGetVecs, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{Vec}, Ptr{Vec}, Ptr{Vec}, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESLineSearchSetVecs( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESLineSearchSetVecs, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Vec, Vec, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESLineSearchGetNorms( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESLineSearchGetNorms, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESLineSearchSetNorms( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESLineSearchSetNorms, $petsc_library), + PetscErrorCode, + (SNESLineSearch, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESLineSearchComputeNorms(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESLineSearchComputeNorms, $petsc_library), + PetscErrorCode, + (SNESLineSearch,), + arg1, + ) +end + +@for_petsc function SNESLineSearchSetComputeNorms(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchSetComputeNorms, $petsc_library), + PetscErrorCode, + (SNESLineSearch, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchMonitor(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESLineSearchMonitor, $petsc_library), + PetscErrorCode, + (SNESLineSearch,), + arg1, + ) +end + +@for_petsc function SNESLineSearchMonitorSet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESLineSearchMonitorSet, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESLineSearchMonitorSetFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESLineSearchMonitorSetFromOptions, $petsc_library), + PetscErrorCode, + ( + SNESLineSearch, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Cchar}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESLineSearchMonitorCancel(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESLineSearchMonitorCancel, $petsc_library), + PetscErrorCode, + (SNESLineSearch,), + arg1, + ) +end + +@for_petsc function SNESLineSearchMonitorUpdate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchMonitorUpdate, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchSetDefaultMonitor( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESLineSearchSetDefaultMonitor, $petsc_library), + PetscErrorCode, + (SNESLineSearch, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchGetDefaultMonitor( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESLineSearchGetDefaultMonitor, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{PetscViewer}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchMonitorSolutionUpdate( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESLineSearchMonitorSolutionUpdate, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchAppendOptionsPrefix( + ::$UnionPetscLib, + arg1, + prefix, +) + @chk ccall( + (:SNESLineSearchAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{Cchar}), + arg1, + prefix, + ) +end + +@for_petsc function SNESLineSearchGetOptionsPrefix( + ::$UnionPetscLib, + arg1, + prefix, +) + @chk ccall( + (:SNESLineSearchGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{Ptr{Cchar}}), + arg1, + prefix, + ) +end + +@for_petsc function SNESLineSearchShellSetUserFunc( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:SNESLineSearchShellSetUserFunc, $petsc_library), + PetscErrorCode, + (SNESLineSearch, SNESLineSearchUserFunc, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESLineSearchShellGetUserFunc( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:SNESLineSearchShellGetUserFunc, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{SNESLineSearchUserFunc}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESLineSearchBTSetAlpha(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchBTSetAlpha, $petsc_library), + PetscErrorCode, + (SNESLineSearch, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchBTGetAlpha(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchBTGetAlpha, $petsc_library), + PetscErrorCode, + (SNESLineSearch, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function SNESLineSearchRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESLineSearchRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function SNESVISetVariableBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESVISetVariableBounds, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESVISetComputeVariableBounds(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESVISetComputeVariableBounds, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function SNESVIGetInactiveSet(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESVIGetInactiveSet, $petsc_library), + PetscErrorCode, + (SNES, Ptr{IS}), + arg1, + arg2, + ) +end + +@for_petsc function SNESVIGetActiveSetIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESVIGetActiveSetIS, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec, Ptr{IS}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESVIComputeInactiveSetFnorm( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESVIComputeInactiveSetFnorm, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESVISetRedundancyCheck(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESVISetRedundancyCheck, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESTestLocalMin(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESTestLocalMin, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function SNESComputeJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESComputeJacobian, $petsc_library), + PetscErrorCode, + (SNES, Vec, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESTestJacobian(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESTestJacobian, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function SNESSetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetDM, $petsc_library), + PetscErrorCode, + (SNES, DM), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetDM, $petsc_library), + PetscErrorCode, + (SNES, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetNPC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetNPC, $petsc_library), + PetscErrorCode, + (SNES, SNES), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetNPC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetNPC, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function SNESHasNPC(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESHasNPC, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function SNESApplyNPC(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESApplyNPC, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESGetNPCFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESGetNPCFunction, $petsc_library), + PetscErrorCode, + (SNES, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESComputeFunctionDefaultNPC( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:SNESComputeFunctionDefaultNPC, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESSetNPCSide(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetNPCSide, $petsc_library), + PetscErrorCode, + (SNES, PCSide), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetNPCSide(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetNPCSide, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PCSide}), + arg1, + arg2, + ) +end + +@for_petsc function SNESSetLineSearch(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESSetLineSearch, $petsc_library), + PetscErrorCode, + (SNES, SNESLineSearch), + arg1, + arg2, + ) +end + +@for_petsc function SNESGetLineSearch(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESGetLineSearch, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNESLineSearch}), + arg1, + arg2, + ) +end + +@for_petsc function SNESRestrictHookAdd(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESRestrictHookAdd, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESGetSNESLineSearch(::$UnionPetscLib, snes, ls) + @chk ccall( + (:SNESGetSNESLineSearch, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNESLineSearch}), + snes, + ls, + ) +end + +@for_petsc function SNESSetSNESLineSearch(::$UnionPetscLib, snes, ls) + @chk ccall( + (:SNESSetSNESLineSearch, $petsc_library), + PetscErrorCode, + (SNES, SNESLineSearch), + snes, + ls, + ) +end + +@for_petsc function SNESSetUpMatrices(::$UnionPetscLib, arg1) + @chk ccall( + (:SNESSetUpMatrices, $petsc_library), + PetscErrorCode, + (SNES,), + arg1, + ) +end + +@for_petsc function DMSNESSetFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESSetFunction, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESGetFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESGetFunction, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESSetNGS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESSetNGS, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESGetNGS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESGetNGS, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESSetJacobian(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESSetJacobian, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESGetJacobian(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESGetJacobian, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESSetPicard(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMSNESSetPicard, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSNESGetPicard(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:DMSNESGetPicard, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMSNESSetObjective(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESSetObjective, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESGetObjective(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESGetObjective, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMCopyDMSNES(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMCopyDMSNES, $petsc_library), + PetscErrorCode, + (DM, DM), + arg1, + arg2, + ) +end + +# typedef PetscErrorCode ( * DMDASNESFunction ) ( DMDALocalInfo * , void * , void * , void * ) +const DMDASNESFunction = Ptr{Cvoid} + +# typedef PetscErrorCode ( * DMDASNESJacobian ) ( DMDALocalInfo * , void * , Mat , Mat , void * ) +const DMDASNESJacobian = Ptr{Cvoid} + +# typedef PetscErrorCode ( * DMDASNESObjective ) ( DMDALocalInfo * , void * , PetscReal * , void * ) +const DMDASNESObjective = Ptr{Cvoid} + +@for_petsc function DMDASNESSetFunctionLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDASNESSetFunctionLocal, $petsc_library), + PetscErrorCode, + (DM, InsertMode, DMDASNESFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDASNESSetJacobianLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDASNESSetJacobianLocal, $petsc_library), + PetscErrorCode, + (DM, DMDASNESJacobian, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDASNESSetObjectiveLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMDASNESSetObjectiveLocal, $petsc_library), + PetscErrorCode, + (DM, DMDASNESObjective, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDASNESSetPicardLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMDASNESSetPicardLocal, $petsc_library), + PetscErrorCode, + (DM, InsertMode, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSNESSetBoundaryLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESSetBoundaryLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESSetFunctionLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESSetFunctionLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESSetJacobianLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESSetJacobianLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESGetBoundaryLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESGetBoundaryLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESGetFunctionLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESGetFunctionLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMSNESGetJacobianLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMSNESGetJacobianLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESMultiblockSetFields( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESMultiblockSetFields, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cchar}, $PetscInt, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESMultiblockSetIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESMultiblockSetIS, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cchar}, IS), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESMultiblockSetBlockSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESMultiblockSetBlockSize, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESMultiblockSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESMultiblockSetType, $petsc_library), + PetscErrorCode, + (SNES, PCCompositeType), + arg1, + arg2, + ) +end + +const SNESMSType = Ptr{Cchar} + +@for_petsc function SNESMSRegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:SNESMSRegister, $petsc_library), + PetscErrorCode, + ( + SNESMSType, + $PetscInt, + $PetscInt, + $PetscReal, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function SNESMSGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESMSGetType, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNESMSType}), + arg1, + arg2, + ) +end + +@for_petsc function SNESMSSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESMSSetType, $petsc_library), + PetscErrorCode, + (SNES, SNESMSType), + arg1, + arg2, + ) +end + +@for_petsc function SNESMSGetDamping(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESMSGetDamping, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function SNESMSSetDamping(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESMSSetDamping, $petsc_library), + PetscErrorCode, + (SNES, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function SNESMSFinalizePackage(::$UnionPetscLib) + @chk ccall((:SNESMSFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function SNESMSInitializePackage(::$UnionPetscLib) + @chk ccall((:SNESMSInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function SNESMSRegisterDestroy(::$UnionPetscLib) + @chk ccall((:SNESMSRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +@enum SNESNGMRESRestartType::UInt32 begin + SNES_NGMRES_RESTART_NONE = 0 + SNES_NGMRES_RESTART_PERIODIC = 1 + SNES_NGMRES_RESTART_DIFFERENCE = 2 +end + +@enum SNESNGMRESSelectType::UInt32 begin + SNES_NGMRES_SELECT_NONE = 0 + SNES_NGMRES_SELECT_DIFFERENCE = 1 + SNES_NGMRES_SELECT_LINESEARCH = 2 +end + +@for_petsc function SNESNGMRESSetRestartType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNGMRESSetRestartType, $petsc_library), + PetscErrorCode, + (SNES, SNESNGMRESRestartType), + arg1, + arg2, + ) +end + +@for_petsc function SNESNGMRESSetSelectType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNGMRESSetSelectType, $petsc_library), + PetscErrorCode, + (SNES, SNESNGMRESSelectType), + arg1, + arg2, + ) +end + +@for_petsc function SNESNGMRESSetRestartFmRise(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNGMRESSetRestartFmRise, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESNGMRESGetRestartFmRise(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNGMRESGetRestartFmRise, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@enum SNESNCGType::UInt32 begin + SNES_NCG_FR = 0 + SNES_NCG_PRP = 1 + SNES_NCG_HS = 2 + SNES_NCG_DY = 3 + SNES_NCG_CD = 4 +end + +@for_petsc function SNESNCGSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNCGSetType, $petsc_library), + PetscErrorCode, + (SNES, SNESNCGType), + arg1, + arg2, + ) +end + +@enum SNESQNScaleType::UInt32 begin + SNES_QN_SCALE_DEFAULT = 0 + SNES_QN_SCALE_NONE = 1 + SNES_QN_SCALE_SCALAR = 2 + SNES_QN_SCALE_DIAGONAL = 3 + SNES_QN_SCALE_JACOBIAN = 4 +end + +@enum SNESQNRestartType::UInt32 begin + SNES_QN_RESTART_DEFAULT = 0 + SNES_QN_RESTART_NONE = 1 + SNES_QN_RESTART_POWELL = 2 + SNES_QN_RESTART_PERIODIC = 3 +end + +@enum SNESQNType::UInt32 begin + SNES_QN_LBFGS = 0 + SNES_QN_BROYDEN = 1 + SNES_QN_BADBROYDEN = 2 +end + +@for_petsc function SNESQNSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESQNSetType, $petsc_library), + PetscErrorCode, + (SNES, SNESQNType), + arg1, + arg2, + ) +end + +@for_petsc function SNESQNSetScaleType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESQNSetScaleType, $petsc_library), + PetscErrorCode, + (SNES, SNESQNScaleType), + arg1, + arg2, + ) +end + +@for_petsc function SNESQNSetRestartType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESQNSetRestartType, $petsc_library), + PetscErrorCode, + (SNES, SNESQNRestartType), + arg1, + arg2, + ) +end + +@for_petsc function SNESNASMGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNASMGetType, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PCASMType}), + arg1, + arg2, + ) +end + +@for_petsc function SNESNASMSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNASMSetType, $petsc_library), + PetscErrorCode, + (SNES, PCASMType), + arg1, + arg2, + ) +end + +@for_petsc function SNESNASMGetSubdomains( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESNASMGetSubdomains, $petsc_library), + PetscErrorCode, + ( + SNES, + Ptr{$PetscInt}, + Ptr{Ptr{SNES}}, + Ptr{Ptr{VecScatter}}, + Ptr{Ptr{VecScatter}}, + Ptr{Ptr{VecScatter}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESNASMSetSubdomains( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESNASMSetSubdomains, $petsc_library), + PetscErrorCode, + ( + SNES, + $PetscInt, + Ptr{SNES}, + Ptr{VecScatter}, + Ptr{VecScatter}, + Ptr{VecScatter}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESNASMSetDamping(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNASMSetDamping, $petsc_library), + PetscErrorCode, + (SNES, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function SNESNASMGetDamping(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNASMGetDamping, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function SNESNASMGetSubdomainVecs( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:SNESNASMGetSubdomainVecs, $petsc_library), + PetscErrorCode, + ( + SNES, + Ptr{$PetscInt}, + Ptr{Ptr{Vec}}, + Ptr{Ptr{Vec}}, + Ptr{Ptr{Vec}}, + Ptr{Ptr{Vec}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function SNESNASMSetComputeFinalJacobian( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:SNESNASMSetComputeFinalJacobian, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESNASMGetSNES(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESNASMGetSNES, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{SNES}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESNASMGetNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNASMGetNumber, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESNASMSetWeight(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESNASMSetWeight, $petsc_library), + PetscErrorCode, + (SNES, Vec), + arg1, + arg2, + ) +end + +@enum SNESCompositeType::UInt32 begin + SNES_COMPOSITE_ADDITIVE = 0 + SNES_COMPOSITE_MULTIPLICATIVE = 1 + SNES_COMPOSITE_ADDITIVEOPTIMAL = 2 +end + +@for_petsc function SNESCompositeSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESCompositeSetType, $petsc_library), + PetscErrorCode, + (SNES, SNESCompositeType), + arg1, + arg2, + ) +end + +@for_petsc function SNESCompositeAddSNES(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESCompositeAddSNES, $petsc_library), + PetscErrorCode, + (SNES, SNESType), + arg1, + arg2, + ) +end + +@for_petsc function SNESCompositeGetSNES(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESCompositeGetSNES, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{SNES}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESCompositeGetNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESCompositeGetNumber, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESCompositeSetDamping(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESCompositeSetDamping, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESPatchSetDiscretisationInfo( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:SNESPatchSetDiscretisationInfo, $petsc_library), + PetscErrorCode, + ( + SNES, + $PetscInt, + Ptr{DM}, + Ptr{$PetscInt}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + $PetscInt, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function SNESPatchSetComputeOperator( + ::$UnionPetscLib, + arg1, + func, + arg3, +) + @chk ccall( + (:SNESPatchSetComputeOperator, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + func, + arg3, + ) +end + +@for_petsc function SNESPatchSetComputeFunction( + ::$UnionPetscLib, + arg1, + func, + arg3, +) + @chk ccall( + (:SNESPatchSetComputeFunction, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + func, + arg3, + ) +end + +@for_petsc function SNESPatchSetConstructType( + ::$UnionPetscLib, + arg1, + arg2, + func, + arg4, +) + @chk ccall( + (:SNESPatchSetConstructType, $petsc_library), + PetscErrorCode, + (SNES, PCPatchConstructType, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + func, + arg4, + ) +end + +@for_petsc function SNESPatchSetCellNumbering(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESPatchSetCellNumbering, $petsc_library), + PetscErrorCode, + (SNES, PetscSection), + arg1, + arg2, + ) +end + +@enum SNESFASType::UInt32 begin + SNES_FAS_MULTIPLICATIVE = 0 + SNES_FAS_ADDITIVE = 1 + SNES_FAS_FULL = 2 + SNES_FAS_KASKADE = 3 +end + +@for_petsc function SNESFASSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASSetType, $petsc_library), + PetscErrorCode, + (SNES, SNESFASType), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASGetType, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNESFASType}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASSetLevels(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASSetLevels, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{MPI_Comm}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASGetLevels(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASGetLevels, $petsc_library), + PetscErrorCode, + (SNES, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASGetCycleSNES(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASGetCycleSNES, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{SNES}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASSetNumberSmoothUp(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASSetNumberSmoothUp, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASSetNumberSmoothDown(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASSetNumberSmoothDown, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASSetCycles(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASSetCycles, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASSetMonitor(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASSetMonitor, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscViewerAndFormat}, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASSetLog(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASSetLog, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASSetGalerkin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASSetGalerkin, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASGetGalerkin(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASGetGalerkin, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASGalerkinFunctionDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:SNESFASGalerkinFunctionDefault, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESFASCycleGetSmoother(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleGetSmoother, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCycleGetSmootherUp(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleGetSmootherUp, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCycleGetSmootherDown(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleGetSmootherDown, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCycleGetCorrection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleGetCorrection, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCycleGetInterpolation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleGetInterpolation, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCycleGetRestriction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleGetRestriction, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCycleGetInjection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleGetInjection, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCycleGetRScale(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleGetRScale, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCycleSetCycles(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleSetCycles, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCycleIsFine(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCycleIsFine, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASSetInterpolation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASSetInterpolation, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASGetInterpolation(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASGetInterpolation, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASSetRestriction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASSetRestriction, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASGetRestriction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASGetRestriction, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASSetInjection(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASSetInjection, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASGetInjection(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASGetInjection, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASSetRScale(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASSetRScale, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASGetRScale(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASGetRScale, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASSetContinuation(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASSetContinuation, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASGetSmoother(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASGetSmoother, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{SNES}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASGetSmootherUp(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASGetSmootherUp, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{SNES}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASGetSmootherDown(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASGetSmootherDown, $petsc_library), + PetscErrorCode, + (SNES, $PetscInt, Ptr{SNES}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASGetCoarseSolve(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASGetCoarseSolve, $petsc_library), + PetscErrorCode, + (SNES, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASFullSetDownSweep(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASFullSetDownSweep, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASCreateCoarseVec(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASCreateCoarseVec, $petsc_library), + PetscErrorCode, + (SNES, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASRestrict(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:SNESFASRestrict, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function SNESFASFullSetTotal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASFullSetTotal, $petsc_library), + PetscErrorCode, + (SNES, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function SNESFASFullGetTotal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:SNESFASFullGetTotal, $petsc_library), + PetscErrorCode, + (SNES, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMSNESCheckDiscretization( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMSNESCheckDiscretization, $petsc_library), + PetscErrorCode, + (SNES, DM, $PetscReal, Vec, $PetscReal, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMSNESCheckResidual( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMSNESCheckResidual, $petsc_library), + PetscErrorCode, + (SNES, DM, Vec, $PetscReal, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function DMSNESCheckJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMSNESCheckJacobian, $petsc_library), + PetscErrorCode, + (SNES, DM, Vec, $PetscReal, Ptr{PetscBool}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function DMSNESCheckFromOptions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMSNESCheckFromOptions, $petsc_library), + PetscErrorCode, + (SNES, Vec), + arg1, + arg2, + ) +end + +mutable struct _p_PetscConvEst end + +const PetscConvEst = Ptr{_p_PetscConvEst} + +@for_petsc function PetscConvEstCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscConvEstCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{PetscConvEst}), + arg1, + arg2, + ) +end + +@for_petsc function PetscConvEstDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscConvEstDestroy, $petsc_library), + PetscErrorCode, + (Ptr{PetscConvEst},), + arg1, + ) +end + +@for_petsc function PetscConvEstView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscConvEstView, $petsc_library), + PetscErrorCode, + (PetscConvEst, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function PetscConvEstSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscConvEstSetFromOptions, $petsc_library), + PetscErrorCode, + (PetscConvEst,), + arg1, + ) +end + +@for_petsc function PetscConvEstGetSolver(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscConvEstGetSolver, $petsc_library), + PetscErrorCode, + (PetscConvEst, Ptr{PetscObject}), + arg1, + arg2, + ) +end + +@for_petsc function PetscConvEstSetSolver(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscConvEstSetSolver, $petsc_library), + PetscErrorCode, + (PetscConvEst, PetscObject), + arg1, + arg2, + ) +end + +@for_petsc function PetscConvEstSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:PetscConvEstSetUp, $petsc_library), + PetscErrorCode, + (PetscConvEst,), + arg1, + ) +end + +@for_petsc function PetscConvEstComputeInitialGuess( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:PetscConvEstComputeInitialGuess, $petsc_library), + PetscErrorCode, + (PetscConvEst, $PetscInt, DM, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function PetscConvEstComputeError( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:PetscConvEstComputeError, $petsc_library), + PetscErrorCode, + (PetscConvEst, $PetscInt, DM, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function PetscConvEstGetConvRate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscConvEstGetConvRate, $petsc_library), + PetscErrorCode, + (PetscConvEst, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function PetscConvEstMonitorDefault(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscConvEstMonitorDefault, $petsc_library), + PetscErrorCode, + (PetscConvEst, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function PetscConvEstRateView(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:PetscConvEstRateView, $petsc_library), + PetscErrorCode, + (PetscConvEst, Ptr{$PetscReal}, PetscViewer), + arg1, + arg2, + arg3, + ) +end + +mutable struct _p_TS end + +const TS = Ptr{_p_TS} + +const TSType = Ptr{Cchar} + +@enum TSProblemType::UInt32 begin + TS_LINEAR = 0 + TS_NONLINEAR = 1 +end + +@enum TSEquationType::Int32 begin + TS_EQ_UNSPECIFIED = -1 + TS_EQ_EXPLICIT = 0 + TS_EQ_ODE_EXPLICIT = 1 + TS_EQ_DAE_SEMI_EXPLICIT_INDEX1 = 100 + TS_EQ_DAE_SEMI_EXPLICIT_INDEX2 = 200 + TS_EQ_DAE_SEMI_EXPLICIT_INDEX3 = 300 + TS_EQ_DAE_SEMI_EXPLICIT_INDEXHI = 500 + TS_EQ_IMPLICIT = 1000 + TS_EQ_ODE_IMPLICIT = 1001 + TS_EQ_DAE_IMPLICIT_INDEX1 = 1100 + TS_EQ_DAE_IMPLICIT_INDEX2 = 1200 + TS_EQ_DAE_IMPLICIT_INDEX3 = 1300 + TS_EQ_DAE_IMPLICIT_INDEXHI = 1500 +end + +@enum TSConvergedReason::Int32 begin + TS_CONVERGED_ITERATING = 0 + TS_CONVERGED_TIME = 1 + TS_CONVERGED_ITS = 2 + TS_CONVERGED_USER = 3 + TS_CONVERGED_EVENT = 4 + TS_CONVERGED_PSEUDO_FATOL = 5 + TS_CONVERGED_PSEUDO_FRTOL = 6 + TS_DIVERGED_NONLINEAR_SOLVE = -1 + TS_DIVERGED_STEP_REJECTED = -2 + TSFORWARD_DIVERGED_LINEAR_SOLVE = -3 + TSADJOINT_DIVERGED_LINEAR_SOLVE = -4 +end + +@enum TSExactFinalTimeOption::UInt32 begin + TS_EXACTFINALTIME_UNSPECIFIED = 0 + TS_EXACTFINALTIME_STEPOVER = 1 + TS_EXACTFINALTIME_INTERPOLATE = 2 + TS_EXACTFINALTIME_MATCHSTEP = 3 +end + +@for_petsc function TSInitializePackage(::$UnionPetscLib) + @chk ccall((:TSInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSFinalizePackage(::$UnionPetscLib) + @chk ccall((:TSFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{TS}), + arg1, + arg2, + ) +end + +@for_petsc function TSClone(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSClone, $petsc_library), + PetscErrorCode, + (TS, Ptr{TS}), + arg1, + arg2, + ) +end + +@for_petsc function TSDestroy(::$UnionPetscLib, arg1) + @chk ccall((:TSDestroy, $petsc_library), PetscErrorCode, (Ptr{TS},), arg1) +end + +@for_petsc function TSSetProblemType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetProblemType, $petsc_library), + PetscErrorCode, + (TS, TSProblemType), + arg1, + arg2, + ) +end + +@for_petsc function TSGetProblemType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetProblemType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSProblemType}), + arg1, + arg2, + ) +end + +@for_petsc function TSMonitor(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSMonitor, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSMonitorSet(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSMonitorSet, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSMonitorSetFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSMonitorSetFromOptions, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSMonitorCancel(::$UnionPetscLib, arg1) + @chk ccall((:TSMonitorCancel, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function TSAppendOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (TS, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall((:TSSetFromOptions, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSSetUp(::$UnionPetscLib, arg1) + @chk ccall((:TSSetUp, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSReset(::$UnionPetscLib, arg1) + @chk ccall((:TSReset, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSSetSolution(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetSolution, $petsc_library), + PetscErrorCode, + (TS, Vec), + arg1, + arg2, + ) +end + +@for_petsc function TSGetSolution(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetSolution, $petsc_library), + PetscErrorCode, + (TS, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TS2SetSolution(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TS2SetSolution, $petsc_library), + PetscErrorCode, + (TS, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TS2GetSolution(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TS2GetSolution, $petsc_library), + PetscErrorCode, + (TS, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSGetSolutionComponents(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSGetSolutionComponents, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSGetAuxSolution(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetAuxSolution, $petsc_library), + PetscErrorCode, + (TS, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetTimeError(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSGetTimeError, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSSetTimeError(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetTimeError, $petsc_library), + PetscErrorCode, + (TS, Vec), + arg1, + arg2, + ) +end + +@for_petsc function TSSetRHSJacobianP(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSSetRHSJacobianP, $petsc_library), + PetscErrorCode, + (TS, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSGetRHSJacobianP(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSGetRHSJacobianP, $petsc_library), + PetscErrorCode, + (TS, Ptr{Mat}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSComputeRHSJacobianP( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSComputeRHSJacobianP, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSSetIJacobianP(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSSetIJacobianP, $petsc_library), + PetscErrorCode, + (TS, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSComputeIJacobianP( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TSComputeIJacobianP, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec, $PetscReal, Mat, PetscBool), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TSComputeDRDPFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSComputeDRDPFunction, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSComputeDRDUFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSComputeDRDUFunction, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSSetIHessianProduct( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:TSSetIHessianProduct, $petsc_library), + PetscErrorCode, + ( + TS, + Ptr{Vec}, + Ptr{Cvoid}, + Ptr{Vec}, + Ptr{Cvoid}, + Ptr{Vec}, + Ptr{Cvoid}, + Ptr{Vec}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function TSComputeIHessianProductFunctionUU( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeIHessianProductFunctionUU, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeIHessianProductFunctionUP( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeIHessianProductFunctionUP, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeIHessianProductFunctionPU( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeIHessianProductFunctionPU, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeIHessianProductFunctionPP( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeIHessianProductFunctionPP, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSSetRHSHessianProduct( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, +) + @chk ccall( + (:TSSetRHSHessianProduct, $petsc_library), + PetscErrorCode, + ( + TS, + Ptr{Vec}, + Ptr{Cvoid}, + Ptr{Vec}, + Ptr{Cvoid}, + Ptr{Vec}, + Ptr{Cvoid}, + Ptr{Vec}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + ) +end + +@for_petsc function TSComputeRHSHessianProductFunctionUU( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeRHSHessianProductFunctionUU, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeRHSHessianProductFunctionUP( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeRHSHessianProductFunctionUP, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeRHSHessianProductFunctionPU( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeRHSHessianProductFunctionPU, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeRHSHessianProductFunctionPP( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeRHSHessianProductFunctionPP, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSSetCostHessianProducts( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSSetCostHessianProducts, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, Ptr{Vec}, Ptr{Vec}, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSGetCostHessianProducts( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSGetCostHessianProducts, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}, Ptr{Ptr{Vec}}, Ptr{Ptr{Vec}}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSComputeSNESJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSComputeSNESJacobian, $petsc_library), + PetscErrorCode, + (TS, Vec, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +mutable struct _p_TSTrajectory end + +const TSTrajectory = Ptr{_p_TSTrajectory} + +const TSTrajectoryType = Ptr{Cchar} + +@for_petsc function TSSetSaveTrajectory(::$UnionPetscLib, arg1) + @chk ccall( + (:TSSetSaveTrajectory, $petsc_library), + PetscErrorCode, + (TS,), + arg1, + ) +end + +@for_petsc function TSResetTrajectory(::$UnionPetscLib, arg1) + @chk ccall( + (:TSResetTrajectory, $petsc_library), + PetscErrorCode, + (TS,), + arg1, + ) +end + +@for_petsc function TSTrajectoryCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectoryCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{TSTrajectory}), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectoryReset(::$UnionPetscLib, arg1) + @chk ccall( + (:TSTrajectoryReset, $petsc_library), + PetscErrorCode, + (TSTrajectory,), + arg1, + ) +end + +@for_petsc function TSTrajectoryDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSTrajectoryDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TSTrajectory},), + arg1, + ) +end + +@for_petsc function TSTrajectoryView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectoryView, $petsc_library), + PetscErrorCode, + (TSTrajectory, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectorySetType(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSTrajectorySetType, $petsc_library), + PetscErrorCode, + (TSTrajectory, TS, TSTrajectoryType), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSTrajectoryGetType(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSTrajectoryGetType, $petsc_library), + PetscErrorCode, + (TSTrajectory, TS, Ptr{TSTrajectoryType}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSTrajectorySet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSTrajectorySet, $petsc_library), + PetscErrorCode, + (TSTrajectory, TS, $PetscInt, $PetscReal, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSTrajectoryGet(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSTrajectoryGet, $petsc_library), + PetscErrorCode, + (TSTrajectory, TS, $PetscInt, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSTrajectoryGetVecs( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSTrajectoryGetVecs, $petsc_library), + PetscErrorCode, + (TSTrajectory, TS, $PetscInt, Ptr{$PetscReal}, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSTrajectoryGetUpdatedHistoryVecs( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSTrajectoryGetUpdatedHistoryVecs, $petsc_library), + PetscErrorCode, + (TSTrajectory, TS, $PetscReal, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSTrajectoryGetNumSteps(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectoryGetNumSteps, $petsc_library), + PetscErrorCode, + (TSTrajectory, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectoryRestoreUpdatedHistoryVecs( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSTrajectoryRestoreUpdatedHistoryVecs, $petsc_library), + PetscErrorCode, + (TSTrajectory, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSTrajectorySetFromOptions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectorySetFromOptions, $petsc_library), + PetscErrorCode, + (TSTrajectory, TS), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectoryRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectoryRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectoryRegisterAll(::$UnionPetscLib) + @chk ccall((:TSTrajectoryRegisterAll, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSTrajectorySetUp(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectorySetUp, $petsc_library), + PetscErrorCode, + (TSTrajectory, TS), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectorySetUseHistory(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectorySetUseHistory, $petsc_library), + PetscErrorCode, + (TSTrajectory, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectorySetMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectorySetMonitor, $petsc_library), + PetscErrorCode, + (TSTrajectory, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectorySetVariableNames(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectorySetVariableNames, $petsc_library), + PetscErrorCode, + (TSTrajectory, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectorySetTransform( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSTrajectorySetTransform, $petsc_library), + PetscErrorCode, + (TSTrajectory, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSTrajectorySetSolutionOnly(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectorySetSolutionOnly, $petsc_library), + PetscErrorCode, + (TSTrajectory, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectoryGetSolutionOnly(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectoryGetSolutionOnly, $petsc_library), + PetscErrorCode, + (TSTrajectory, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectorySetKeepFiles(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectorySetKeepFiles, $petsc_library), + PetscErrorCode, + (TSTrajectory, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectorySetDirname(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectorySetDirname, $petsc_library), + PetscErrorCode, + (TSTrajectory, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function TSTrajectorySetFiletemplate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSTrajectorySetFiletemplate, $petsc_library), + PetscErrorCode, + (TSTrajectory, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetTrajectory(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetTrajectory, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSTrajectory}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetCostGradients(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSSetCostGradients, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSGetCostGradients(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSGetCostGradients, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}, Ptr{Ptr{Vec}}, Ptr{Ptr{Vec}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSSetCostIntegrand( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:TSSetCostIntegrand, $petsc_library), + PetscErrorCode, + ( + TS, + $PetscInt, + Vec, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + PetscBool, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function TSGetCostIntegral(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetCostIntegral, $petsc_library), + PetscErrorCode, + (TS, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TSComputeCostIntegrand( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSComputeCostIntegrand, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSCreateQuadratureTS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSCreateQuadratureTS, $petsc_library), + PetscErrorCode, + (TS, PetscBool, Ptr{TS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSGetQuadratureTS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSGetQuadratureTS, $petsc_library), + PetscErrorCode, + (TS, Ptr{PetscBool}, Ptr{TS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSAdjointMonitor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TSAdjointMonitor, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, $PetscInt, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TSAdjointMonitorSet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSAdjointMonitorSet, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSAdjointMonitorCancel(::$UnionPetscLib, arg1) + @chk ccall( + (:TSAdjointMonitorCancel, $petsc_library), + PetscErrorCode, + (TS,), + arg1, + ) +end + +@for_petsc function TSAdjointMonitorSetFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSAdjointMonitorSetFromOptions, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cchar}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSAdjointSetRHSJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSAdjointSetRHSJacobian, $petsc_library), + PetscErrorCode, + (TS, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSAdjointComputeRHSJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSAdjointComputeRHSJacobian, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSAdjointComputeDRDPFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSAdjointComputeDRDPFunction, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSAdjointComputeDRDYFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSAdjointComputeDRDYFunction, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSAdjointSolve(::$UnionPetscLib, arg1) + @chk ccall((:TSAdjointSolve, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSAdjointSetSteps(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdjointSetSteps, $petsc_library), + PetscErrorCode, + (TS, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TSAdjointStep(::$UnionPetscLib, arg1) + @chk ccall((:TSAdjointStep, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSAdjointSetUp(::$UnionPetscLib, arg1) + @chk ccall((:TSAdjointSetUp, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSAdjointReset(::$UnionPetscLib, arg1) + @chk ccall((:TSAdjointReset, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSAdjointCostIntegral(::$UnionPetscLib, arg1) + @chk ccall( + (:TSAdjointCostIntegral, $petsc_library), + PetscErrorCode, + (TS,), + arg1, + ) +end + +@for_petsc function TSAdjointSetForward(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdjointSetForward, $petsc_library), + PetscErrorCode, + (TS, Mat), + arg1, + arg2, + ) +end + +@for_petsc function TSAdjointResetForward(::$UnionPetscLib, arg1) + @chk ccall( + (:TSAdjointResetForward, $petsc_library), + PetscErrorCode, + (TS,), + arg1, + ) +end + +@for_petsc function TSForwardSetSensitivities( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSForwardSetSensitivities, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSForwardGetSensitivities( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSForwardGetSensitivities, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}, Ptr{Mat}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSForwardSetIntegralGradients( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSForwardSetIntegralGradients, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSForwardGetIntegralGradients( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSForwardGetIntegralGradients, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}, Ptr{Ptr{Vec}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSForwardSetUp(::$UnionPetscLib, arg1) + @chk ccall((:TSForwardSetUp, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSForwardReset(::$UnionPetscLib, arg1) + @chk ccall((:TSForwardReset, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSForwardCostIntegral(::$UnionPetscLib, arg1) + @chk ccall( + (:TSForwardCostIntegral, $petsc_library), + PetscErrorCode, + (TS,), + arg1, + ) +end + +@for_petsc function TSForwardStep(::$UnionPetscLib, arg1) + @chk ccall((:TSForwardStep, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSForwardSetInitialSensitivities( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TSForwardSetInitialSensitivities, $petsc_library), + PetscErrorCode, + (TS, Mat), + arg1, + arg2, + ) +end + +@for_petsc function TSForwardGetStages(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSForwardGetStages, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}, Ptr{Ptr{Mat}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSSetMaxSteps(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetMaxSteps, $petsc_library), + PetscErrorCode, + (TS, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TSGetMaxSteps(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetMaxSteps, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetMaxTime(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetMaxTime, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSGetMaxTime(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetMaxTime, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetExactFinalTime(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetExactFinalTime, $petsc_library), + PetscErrorCode, + (TS, TSExactFinalTimeOption), + arg1, + arg2, + ) +end + +@for_petsc function TSGetExactFinalTime(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetExactFinalTime, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSExactFinalTimeOption}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetInitialTimeStep(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSSetInitialTimeStep, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSSetDuration(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSSetDuration, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSGetDuration(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSGetDuration, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSGetTimeStepNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetTimeStepNumber, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetTotalSteps(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetTotalSteps, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSMonitorDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorDefault, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorExtreme( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorExtreme, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +mutable struct _n_TSMonitorDrawCtx end + +const TSMonitorDrawCtx = Ptr{_n_TSMonitorDrawCtx} + +@for_petsc function TSMonitorDrawCtxCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:TSMonitorDrawCtxCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Cchar}, + Ptr{Cchar}, + Cint, + Cint, + Cint, + Cint, + $PetscInt, + Ptr{TSMonitorDrawCtx}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function TSMonitorDrawCtxDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSMonitorDrawCtxDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TSMonitorDrawCtx},), + arg1, + ) +end + +@for_petsc function TSMonitorDrawSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorDrawSolution, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorDrawSolutionPhase( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorDrawSolutionPhase, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorDrawError( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorDrawError, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorDrawSolutionFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorDrawSolutionFunction, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSAdjointMonitorDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:TSAdjointMonitorDefault, $petsc_library), + PetscErrorCode, + ( + TS, + $PetscInt, + $PetscReal, + Vec, + $PetscInt, + Ptr{Vec}, + Ptr{Vec}, + Ptr{PetscViewerAndFormat}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function TSAdjointMonitorDrawSensi( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:TSAdjointMonitorDrawSensi, $petsc_library), + PetscErrorCode, + ( + TS, + $PetscInt, + $PetscReal, + Vec, + $PetscInt, + Ptr{Vec}, + Ptr{Vec}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function TSMonitorSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorSolution, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorSolutionVTK( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorSolutionVTK, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorSolutionVTKDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSMonitorSolutionVTKDestroy, $petsc_library), + PetscErrorCode, + (Ptr{Cvoid},), + arg1, + ) +end + +@for_petsc function TSStep(::$UnionPetscLib, arg1) + @chk ccall((:TSStep, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSEvaluateWLTE(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSEvaluateWLTE, $petsc_library), + PetscErrorCode, + (TS, NormType, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSEvaluateStep(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSEvaluateStep, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, Vec, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSSolve(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSolve, $petsc_library), + PetscErrorCode, + (TS, Vec), + arg1, + arg2, + ) +end + +@for_petsc function TSGetEquationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetEquationType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSEquationType}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetEquationType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetEquationType, $petsc_library), + PetscErrorCode, + (TS, TSEquationType), + arg1, + arg2, + ) +end + +@for_petsc function TSGetConvergedReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetConvergedReason, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSConvergedReason}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetConvergedReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetConvergedReason, $petsc_library), + PetscErrorCode, + (TS, TSConvergedReason), + arg1, + arg2, + ) +end + +@for_petsc function TSGetSolveTime(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetSolveTime, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetSNESIterations(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetSNESIterations, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetKSPIterations(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetKSPIterations, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetStepRejections(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetStepRejections, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetMaxStepRejections(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetMaxStepRejections, $petsc_library), + PetscErrorCode, + (TS, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TSGetSNESFailures(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetSNESFailures, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetMaxSNESFailures(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetMaxSNESFailures, $petsc_library), + PetscErrorCode, + (TS, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TSSetErrorIfStepFails(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetErrorIfStepFails, $petsc_library), + PetscErrorCode, + (TS, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSRestartStep(::$UnionPetscLib, arg1) + @chk ccall((:TSRestartStep, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSRollBack(::$UnionPetscLib, arg1) + @chk ccall((:TSRollBack, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSGetStages(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSGetStages, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}, Ptr{Ptr{Vec}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSGetTime(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetTime, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetTime(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetTime, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSGetPrevTime(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetPrevTime, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetTimeStep(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetTimeStep, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetTimeStep(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetTimeStep, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSGetStepNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetStepNumber, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetStepNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetStepNumber, $petsc_library), + PetscErrorCode, + (TS, $PetscInt), + arg1, + arg2, + ) +end + +# typedef PetscErrorCode ( * TSRHSFunction ) ( TS , PetscReal , Vec , Vec , void * ) +const TSRHSFunction = Ptr{Cvoid} + +# typedef PetscErrorCode ( * TSRHSJacobian ) ( TS , PetscReal , Vec , Mat , Mat , void * ) +const TSRHSJacobian = Ptr{Cvoid} + +# typedef PetscErrorCode ( * TSRHSJacobianP ) ( TS , PetscReal , Vec , Mat , void * ) +const TSRHSJacobianP = Ptr{Cvoid} + +@for_petsc function TSSetRHSFunction(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSSetRHSFunction, $petsc_library), + PetscErrorCode, + (TS, Vec, TSRHSFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSGetRHSFunction(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSGetRHSFunction, $petsc_library), + PetscErrorCode, + (TS, Ptr{Vec}, Ptr{TSRHSFunction}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSSetRHSJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSSetRHSJacobian, $petsc_library), + PetscErrorCode, + (TS, Mat, Mat, TSRHSJacobian, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSGetRHSJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSGetRHSJacobian, $petsc_library), + PetscErrorCode, + (TS, Ptr{Mat}, Ptr{Mat}, Ptr{TSRHSJacobian}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSRHSJacobianSetReuse(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRHSJacobianSetReuse, $petsc_library), + PetscErrorCode, + (TS, PetscBool), + arg1, + arg2, + ) +end + +# typedef PetscErrorCode ( * TSSolutionFunction ) ( TS , PetscReal , Vec , void * ) +const TSSolutionFunction = Ptr{Cvoid} + +@for_petsc function TSSetSolutionFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSSetSolutionFunction, $petsc_library), + PetscErrorCode, + (TS, TSSolutionFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +# typedef PetscErrorCode ( * TSForcingFunction ) ( TS , PetscReal , Vec , void * ) +const TSForcingFunction = Ptr{Cvoid} + +@for_petsc function TSSetForcingFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSSetForcingFunction, $petsc_library), + PetscErrorCode, + (TS, TSForcingFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +# typedef PetscErrorCode ( * TSIFunction ) ( TS , PetscReal , Vec , Vec , Vec , void * ) +const TSIFunction = Ptr{Cvoid} + +# typedef PetscErrorCode ( * TSIJacobian ) ( TS , PetscReal , Vec , Vec , PetscReal , Mat , Mat , void * ) +const TSIJacobian = Ptr{Cvoid} + +@for_petsc function TSSetIFunction(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSSetIFunction, $petsc_library), + PetscErrorCode, + (TS, Vec, TSIFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSGetIFunction(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSGetIFunction, $petsc_library), + PetscErrorCode, + (TS, Ptr{Vec}, Ptr{TSIFunction}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSSetIJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSSetIJacobian, $petsc_library), + PetscErrorCode, + (TS, Mat, Mat, TSIJacobian, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSGetIJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSGetIJacobian, $petsc_library), + PetscErrorCode, + (TS, Ptr{Mat}, Ptr{Mat}, Ptr{TSIJacobian}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +# typedef PetscErrorCode ( * TSI2Function ) ( TS , PetscReal , Vec , Vec , Vec , Vec , void * ) +const TSI2Function = Ptr{Cvoid} + +# typedef PetscErrorCode ( * TSI2Jacobian ) ( TS , PetscReal , Vec , Vec , Vec , PetscReal , PetscReal , Mat , Mat , void * ) +const TSI2Jacobian = Ptr{Cvoid} + +@for_petsc function TSSetI2Function(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSSetI2Function, $petsc_library), + PetscErrorCode, + (TS, Vec, TSI2Function, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSGetI2Function(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSGetI2Function, $petsc_library), + PetscErrorCode, + (TS, Ptr{Vec}, Ptr{TSI2Function}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSSetI2Jacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSSetI2Jacobian, $petsc_library), + PetscErrorCode, + (TS, Mat, Mat, TSI2Jacobian, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSGetI2Jacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSGetI2Jacobian, $petsc_library), + PetscErrorCode, + (TS, Ptr{Mat}, Ptr{Mat}, Ptr{TSI2Jacobian}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSRHSSplitSetIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSRHSSplitSetIS, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cchar}, IS), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSRHSSplitGetIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSRHSSplitGetIS, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cchar}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSRHSSplitSetRHSFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSRHSSplitSetRHSFunction, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cchar}, Vec, TSRHSFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSRHSSplitGetSubTS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSRHSSplitGetSubTS, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cchar}, Ptr{TS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSRHSSplitGetSubTSs(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSRHSSplitGetSubTSs, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}, Ptr{Ptr{TS}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSSetUseSplitRHSFunction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetUseSplitRHSFunction, $petsc_library), + PetscErrorCode, + (TS, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSGetUseSplitRHSFunction(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetUseSplitRHSFunction, $petsc_library), + PetscErrorCode, + (TS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TSComputeRHSFunctionLinear( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSComputeRHSFunctionLinear, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSComputeRHSJacobianConstant( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeRHSJacobianConstant, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeIFunctionLinear( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeIFunctionLinear, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeIJacobianConstant( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:TSComputeIJacobianConstant, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec, $PetscReal, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function TSComputeSolutionFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSComputeSolutionFunction, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSComputeForcingFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSComputeForcingFunction, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSComputeIJacobianDefaultColor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:TSComputeIJacobianDefaultColor, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec, $PetscReal, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function TSSetPreStep(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetPreStep, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetPreStage(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetPreStage, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetPostStage(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetPostStage, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetPostEvaluate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetPostEvaluate, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetPostStep(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetPostStep, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSPreStep(::$UnionPetscLib, arg1) + @chk ccall((:TSPreStep, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSPreStage(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSPreStage, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSPostStage(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSPostStage, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, $PetscInt, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSPostEvaluate(::$UnionPetscLib, arg1) + @chk ccall((:TSPostEvaluate, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSPostStep(::$UnionPetscLib, arg1) + @chk ccall((:TSPostStep, $petsc_library), PetscErrorCode, (TS,), arg1) +end + +@for_petsc function TSInterpolate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSInterpolate, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSSetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSSetTolerances, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, $PetscReal, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSGetTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSGetTolerances, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}, Ptr{Vec}, Ptr{$PetscReal}, Ptr{Vec}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSErrorWeightedNormInfinity( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSErrorWeightedNormInfinity, $petsc_library), + PetscErrorCode, + (TS, Vec, Vec, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSErrorWeightedNorm2( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSErrorWeightedNorm2, $petsc_library), + PetscErrorCode, + (TS, Vec, Vec, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSErrorWeightedNorm( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TSErrorWeightedNorm, $petsc_library), + PetscErrorCode, + ( + TS, + Vec, + Vec, + NormType, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TSErrorWeightedENormInfinity( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TSErrorWeightedENormInfinity, $petsc_library), + PetscErrorCode, + (TS, Vec, Vec, Vec, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TSErrorWeightedENorm2( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TSErrorWeightedENorm2, $petsc_library), + PetscErrorCode, + (TS, Vec, Vec, Vec, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TSErrorWeightedENorm( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:TSErrorWeightedENorm, $petsc_library), + PetscErrorCode, + ( + TS, + Vec, + Vec, + Vec, + NormType, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function TSSetCFLTimeLocal(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetCFLTimeLocal, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSGetCFLTime(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetCFLTime, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetFunctionDomainError(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetFunctionDomainError, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSFunctionDomainError( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSFunctionDomainError, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSPseudoSetTimeStep(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSPseudoSetTimeStep, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSPseudoTimeStepDefault(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSPseudoTimeStepDefault, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSPseudoComputeTimeStep(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSPseudoComputeTimeStep, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSPseudoSetMaxTimeStep(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSPseudoSetMaxTimeStep, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSPseudoSetVerifyTimeStep( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSPseudoSetVerifyTimeStep, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSPseudoVerifyTimeStepDefault( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSPseudoVerifyTimeStepDefault, $petsc_library), + PetscErrorCode, + (TS, Vec, Ptr{Cvoid}, Ptr{$PetscReal}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSPseudoVerifyTimeStep( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSPseudoVerifyTimeStep, $petsc_library), + PetscErrorCode, + (TS, Vec, Ptr{$PetscReal}, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSPseudoSetTimeStepIncrement(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSPseudoSetTimeStepIncrement, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSPseudoIncrementDtFromInitialDt(::$UnionPetscLib, arg1) + @chk ccall( + (:TSPseudoIncrementDtFromInitialDt, $petsc_library), + PetscErrorCode, + (TS,), + arg1, + ) +end + +@for_petsc function TSPythonSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSPythonSetType, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function TSComputeRHSFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSComputeRHSFunction, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSComputeRHSJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSComputeRHSJacobian, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSComputeIFunction( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeIFunction, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec, Vec, PetscBool), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeIJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, +) + @chk ccall( + (:TSComputeIJacobian, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec, $PetscReal, Mat, Mat, PetscBool), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + ) +end + +@for_petsc function TSComputeI2Function( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSComputeI2Function, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSComputeI2Jacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:TSComputeI2Jacobian, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Vec, Vec, Vec, $PetscReal, $PetscReal, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function TSComputeLinearStability( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSComputeLinearStability, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, $PetscReal, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSVISetVariableBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSVISetVariableBounds, $petsc_library), + PetscErrorCode, + (TS, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetBoundaryLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetBoundaryLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetRHSFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetRHSFunction, $petsc_library), + PetscErrorCode, + (DM, TSRHSFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSGetRHSFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSGetRHSFunction, $petsc_library), + PetscErrorCode, + (DM, Ptr{TSRHSFunction}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetRHSJacobian(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetRHSJacobian, $petsc_library), + PetscErrorCode, + (DM, TSRHSJacobian, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSGetRHSJacobian(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSGetRHSJacobian, $petsc_library), + PetscErrorCode, + (DM, Ptr{TSRHSJacobian}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetIFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetIFunction, $petsc_library), + PetscErrorCode, + (DM, TSIFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSGetIFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSGetIFunction, $petsc_library), + PetscErrorCode, + (DM, Ptr{TSIFunction}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetIJacobian(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetIJacobian, $petsc_library), + PetscErrorCode, + (DM, TSIJacobian, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSGetIJacobian(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSGetIJacobian, $petsc_library), + PetscErrorCode, + (DM, Ptr{TSIJacobian}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetI2Function(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetI2Function, $petsc_library), + PetscErrorCode, + (DM, TSI2Function, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSGetI2Function(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSGetI2Function, $petsc_library), + PetscErrorCode, + (DM, Ptr{TSI2Function}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetI2Jacobian(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetI2Jacobian, $petsc_library), + PetscErrorCode, + (DM, TSI2Jacobian, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSGetI2Jacobian(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSGetI2Jacobian, $petsc_library), + PetscErrorCode, + (DM, Ptr{TSI2Jacobian}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +# typedef PetscErrorCode ( * TSTransientVariable ) ( TS , Vec , Vec , void * ) +const TSTransientVariable = Ptr{Cvoid} + +@for_petsc function TSSetTransientVariable(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSSetTransientVariable, $petsc_library), + PetscErrorCode, + (TS, TSTransientVariable, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetTransientVariable(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetTransientVariable, $petsc_library), + PetscErrorCode, + (DM, TSTransientVariable, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSGetTransientVariable(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSGetTransientVariable, $petsc_library), + PetscErrorCode, + (DM, Ptr{TSTransientVariable}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSComputeTransientVariable( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSComputeTransientVariable, $petsc_library), + PetscErrorCode, + (TS, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSHasTransientVariable(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSHasTransientVariable, $petsc_library), + PetscErrorCode, + (TS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function DMTSSetSolutionFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetSolutionFunction, $petsc_library), + PetscErrorCode, + (DM, TSSolutionFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSGetSolutionFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSGetSolutionFunction, $petsc_library), + PetscErrorCode, + (DM, Ptr{TSSolutionFunction}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetForcingFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetForcingFunction, $petsc_library), + PetscErrorCode, + (DM, TSForcingFunction, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSGetForcingFunction(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSGetForcingFunction, $petsc_library), + PetscErrorCode, + (DM, Ptr{TSForcingFunction}, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSCheckFromOptions(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMTSCheckFromOptions, $petsc_library), + PetscErrorCode, + (TS, Vec), + arg1, + arg2, + ) +end + +@for_petsc function DMTSSetIFunctionLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetIFunctionLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetIJacobianLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetIJacobianLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetRHSFunctionLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMTSSetRHSFunctionLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetIFunctionSerialize( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMTSSetIFunctionSerialize, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMTSSetIJacobianSerialize( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMTSSetIJacobianSerialize, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +# typedef PetscErrorCode ( * DMDATSRHSFunctionLocal ) ( DMDALocalInfo * , PetscReal , void * , void * , void * ) +const DMDATSRHSFunctionLocal = Ptr{Cvoid} + +# typedef PetscErrorCode ( * DMDATSRHSJacobianLocal ) ( DMDALocalInfo * , PetscReal , void * , Mat , Mat , void * ) +const DMDATSRHSJacobianLocal = Ptr{Cvoid} + +# typedef PetscErrorCode ( * DMDATSIFunctionLocal ) ( DMDALocalInfo * , PetscReal , void * , void * , void * , void * ) +const DMDATSIFunctionLocal = Ptr{Cvoid} + +# typedef PetscErrorCode ( * DMDATSIJacobianLocal ) ( DMDALocalInfo * , PetscReal , void * , void * , PetscReal , Mat , Mat , void * ) +const DMDATSIJacobianLocal = Ptr{Cvoid} + +@for_petsc function DMDATSSetRHSFunctionLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDATSSetRHSFunctionLocal, $petsc_library), + PetscErrorCode, + (DM, InsertMode, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDATSSetRHSJacobianLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:DMDATSSetRHSJacobianLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMDATSSetIFunctionLocal( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMDATSSetIFunctionLocal, $petsc_library), + PetscErrorCode, + (DM, InsertMode, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function DMDATSSetIJacobianLocal(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDATSSetIJacobianLocal, $petsc_library), + PetscErrorCode, + (DM, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function DMPlexTSGetGeometryFVM( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:DMPlexTSGetGeometryFVM, $petsc_library), + PetscErrorCode, + (DM, Ptr{Vec}, Ptr{Vec}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +mutable struct _n_TSMonitorLGCtx end + +const TSMonitorLGCtx = Ptr{_n_TSMonitorLGCtx} + +mutable struct TSMonitorDMDARayCtx + ray::Vec + scatter::VecScatter + viewer::PetscViewer + lgctx::TSMonitorLGCtx + TSMonitorDMDARayCtx() = new() +end + +@for_petsc function TSMonitorDMDARayDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSMonitorDMDARayDestroy, $petsc_library), + PetscErrorCode, + (Ptr{Ptr{Cvoid}},), + arg1, + ) +end + +@for_petsc function TSMonitorDMDARay( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorDMDARay, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorLGDMDARay( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorLGDMDARay, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSType}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetType, $petsc_library), + PetscErrorCode, + (TS, TSType), + arg1, + arg2, + ) +end + +@for_petsc function TSRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetSNES(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetSNES, $petsc_library), + PetscErrorCode, + (TS, Ptr{SNES}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetSNES(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetSNES, $petsc_library), + PetscErrorCode, + (TS, SNES), + arg1, + arg2, + ) +end + +@for_petsc function TSGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetKSP, $petsc_library), + PetscErrorCode, + (TS, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function TSView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSView, $petsc_library), + PetscErrorCode, + (TS, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function TSLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSLoad, $petsc_library), + PetscErrorCode, + (TS, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function TSViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSViewFromOptions, $petsc_library), + PetscErrorCode, + (TS, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSTrajectoryViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSTrajectoryViewFromOptions, $petsc_library), + PetscErrorCode, + (TSTrajectory, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSSetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetApplicationContext, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetApplicationContext, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSMonitorLGCtxCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:TSMonitorLGCtxCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Cchar}, + Ptr{Cchar}, + Cint, + Cint, + Cint, + Cint, + $PetscInt, + Ptr{TSMonitorLGCtx}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function TSMonitorLGCtxDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSMonitorLGCtxDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TSMonitorLGCtx},), + arg1, + ) +end + +@for_petsc function TSMonitorLGTimeStep( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorLGTimeStep, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorLGSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorLGSolution, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorLGSetVariableNames(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSMonitorLGSetVariableNames, $petsc_library), + PetscErrorCode, + (TS, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function TSMonitorLGGetVariableNames(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSMonitorLGGetVariableNames, $petsc_library), + PetscErrorCode, + (TS, Ptr{Ptr{Ptr{Cchar}}}), + arg1, + arg2, + ) +end + +@for_petsc function TSMonitorLGCtxSetVariableNames(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSMonitorLGCtxSetVariableNames, $petsc_library), + PetscErrorCode, + (TSMonitorLGCtx, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function TSMonitorLGSetDisplayVariables(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSMonitorLGSetDisplayVariables, $petsc_library), + PetscErrorCode, + (TS, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function TSMonitorLGCtxSetDisplayVariables( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TSMonitorLGCtxSetDisplayVariables, $petsc_library), + PetscErrorCode, + (TSMonitorLGCtx, Ptr{Ptr{Cchar}}), + arg1, + arg2, + ) +end + +@for_petsc function TSMonitorLGSetTransform( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSMonitorLGSetTransform, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSMonitorLGCtxSetTransform( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSMonitorLGCtxSetTransform, $petsc_library), + PetscErrorCode, + (TSMonitorLGCtx, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSMonitorLGError( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorLGError, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorLGSNESIterations( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorLGSNESIterations, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorLGKSPIterations( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorLGKSPIterations, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorError( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorError, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{PetscViewerAndFormat}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorLGCtxNetworkSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorLGCtxNetworkSolution, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +mutable struct _n_TSMonitorEnvelopeCtx end + +const TSMonitorEnvelopeCtx = Ptr{_n_TSMonitorEnvelopeCtx} + +@for_petsc function TSMonitorEnvelopeCtxCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSMonitorEnvelopeCtxCreate, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSMonitorEnvelopeCtx}), + arg1, + arg2, + ) +end + +@for_petsc function TSMonitorEnvelope( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorEnvelope, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSMonitorEnvelopeGetBounds( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSMonitorEnvelopeGetBounds, $petsc_library), + PetscErrorCode, + (TS, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSMonitorEnvelopeCtxDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSMonitorEnvelopeCtxDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TSMonitorEnvelopeCtx},), + arg1, + ) +end + +mutable struct _n_TSMonitorSPEigCtx end + +const TSMonitorSPEigCtx = Ptr{_n_TSMonitorSPEigCtx} + +@for_petsc function TSMonitorSPEigCtxCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:TSMonitorSPEigCtxCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Cchar}, + Ptr{Cchar}, + Cint, + Cint, + Cint, + Cint, + $PetscInt, + Ptr{TSMonitorSPEigCtx}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function TSMonitorSPEigCtxDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSMonitorSPEigCtxDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TSMonitorSPEigCtx},), + arg1, + ) +end + +@for_petsc function TSMonitorSPEig( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorSPEig, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +mutable struct _n_TSMonitorSPCtx end + +const TSMonitorSPCtx = Ptr{_n_TSMonitorSPCtx} + +@for_petsc function TSMonitorSPCtxCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:TSMonitorSPCtxCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Cchar}, + Ptr{Cchar}, + Cint, + Cint, + Cint, + Cint, + $PetscInt, + Ptr{TSMonitorSPCtx}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function TSMonitorSPCtxDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSMonitorSPCtxDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TSMonitorSPCtx},), + arg1, + ) +end + +@for_petsc function TSMonitorSPSwarmSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSMonitorSPSwarmSolution, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscReal, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSSetEventHandler( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TSSetEventHandler, $petsc_library), + PetscErrorCode, + ( + TS, + $PetscInt, + Ptr{$PetscInt}, + Ptr{PetscBool}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TSSetPostEventIntervalStep(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetPostEventIntervalStep, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSSetEventTolerances(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSSetEventTolerances, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSGetNumEvents(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetNumEvents, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +const TSSSPType = Ptr{Cchar} + +@for_petsc function TSSSPSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSSPSetType, $petsc_library), + PetscErrorCode, + (TS, TSSSPType), + arg1, + arg2, + ) +end + +@for_petsc function TSSSPGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSSPGetType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSSSPType}), + arg1, + arg2, + ) +end + +@for_petsc function TSSSPSetNumStages(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSSPSetNumStages, $petsc_library), + PetscErrorCode, + (TS, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TSSSPGetNumStages(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSSPGetNumStages, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSSSPInitializePackage(::$UnionPetscLib) + @chk ccall((:TSSSPInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSSSPFinalizePackage(::$UnionPetscLib) + @chk ccall((:TSSSPFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +mutable struct _p_TSAdapt end + +const TSAdapt = Ptr{_p_TSAdapt} + +const TSAdaptType = Ptr{Cchar} + +@for_petsc function TSGetAdapt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetAdapt, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSAdapt}), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptInitializePackage(::$UnionPetscLib) + @chk ccall((:TSAdaptInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSAdaptFinalizePackage(::$UnionPetscLib) + @chk ccall((:TSAdaptFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSAdaptCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{TSAdapt}), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptSetType, $petsc_library), + PetscErrorCode, + (TSAdapt, TSAdaptType), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptGetType, $petsc_library), + PetscErrorCode, + (TSAdapt, Ptr{TSAdaptType}), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (TSAdapt, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptCandidatesClear(::$UnionPetscLib, arg1) + @chk ccall( + (:TSAdaptCandidatesClear, $petsc_library), + PetscErrorCode, + (TSAdapt,), + arg1, + ) +end + +@for_petsc function TSAdaptCandidateAdd( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TSAdaptCandidateAdd, $petsc_library), + PetscErrorCode, + ( + TSAdapt, + Ptr{Cchar}, + $PetscInt, + $PetscInt, + $PetscReal, + $PetscReal, + PetscBool, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TSAdaptCandidatesGet( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSAdaptCandidatesGet, $petsc_library), + PetscErrorCode, + ( + TSAdapt, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscInt}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSAdaptChoose( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSAdaptChoose, $petsc_library), + PetscErrorCode, + ( + TSAdapt, + TS, + $PetscReal, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSAdaptCheckStage( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSAdaptCheckStage, $petsc_library), + PetscErrorCode, + (TSAdapt, TS, $PetscReal, Vec, Ptr{PetscBool}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSAdaptView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptView, $petsc_library), + PetscErrorCode, + (TSAdapt, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptLoad(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptLoad, $petsc_library), + PetscErrorCode, + (TSAdapt, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptReset(::$UnionPetscLib, arg1) + @chk ccall( + (:TSAdaptReset, $petsc_library), + PetscErrorCode, + (TSAdapt,), + arg1, + ) +end + +@for_petsc function TSAdaptDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSAdaptDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TSAdapt},), + arg1, + ) +end + +@for_petsc function TSAdaptSetMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptSetMonitor, $petsc_library), + PetscErrorCode, + (TSAdapt, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptSetAlwaysAccept(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptSetAlwaysAccept, $petsc_library), + PetscErrorCode, + (TSAdapt, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptSetSafety(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSAdaptSetSafety, $petsc_library), + PetscErrorCode, + (TSAdapt, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSAdaptGetSafety(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSAdaptGetSafety, $petsc_library), + PetscErrorCode, + (TSAdapt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSAdaptSetMaxIgnore(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptSetMaxIgnore, $petsc_library), + PetscErrorCode, + (TSAdapt, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptGetMaxIgnore(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptGetMaxIgnore, $petsc_library), + PetscErrorCode, + (TSAdapt, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptSetClip(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSAdaptSetClip, $petsc_library), + PetscErrorCode, + (TSAdapt, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSAdaptGetClip(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSAdaptGetClip, $petsc_library), + PetscErrorCode, + (TSAdapt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSAdaptSetScaleSolveFailed(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptSetScaleSolveFailed, $petsc_library), + PetscErrorCode, + (TSAdapt, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptGetScaleSolveFailed(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptGetScaleSolveFailed, $petsc_library), + PetscErrorCode, + (TSAdapt, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptSetStepLimits(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSAdaptSetStepLimits, $petsc_library), + PetscErrorCode, + (TSAdapt, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSAdaptGetStepLimits(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSAdaptGetStepLimits, $petsc_library), + PetscErrorCode, + (TSAdapt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSAdaptSetCheckStage(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptSetCheckStage, $petsc_library), + PetscErrorCode, + (TSAdapt, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptHistorySetHistory( + ::$UnionPetscLib, + arg1, + n, + hist, + arg4, +) + @chk ccall( + (:TSAdaptHistorySetHistory, $petsc_library), + PetscErrorCode, + (TSAdapt, $PetscInt, Ptr{$PetscReal}, PetscBool), + arg1, + n, + hist, + arg4, + ) +end + +@for_petsc function TSAdaptHistorySetTrajectory( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TSAdaptHistorySetTrajectory, $petsc_library), + PetscErrorCode, + (TSAdapt, TSTrajectory, PetscBool), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TSAdaptHistoryGetStep( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TSAdaptHistoryGetStep, $petsc_library), + PetscErrorCode, + (TSAdapt, $PetscInt, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSAdaptSetTimeStepIncreaseDelay( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TSAdaptSetTimeStepIncreaseDelay, $petsc_library), + PetscErrorCode, + (TSAdapt, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptDSPSetFilter(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAdaptDSPSetFilter, $petsc_library), + PetscErrorCode, + (TSAdapt, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function TSAdaptDSPSetPID(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSAdaptDSPSetPID, $petsc_library), + PetscErrorCode, + (TSAdapt, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + ) +end + +mutable struct _p_TSGLLEAdapt end + +const TSGLLEAdapt = Ptr{_p_TSGLLEAdapt} + +const TSGLLEAdaptType = Ptr{Cchar} + +@for_petsc function TSGLLEAdaptRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLEAdaptRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSGLLEAdaptInitializePackage(::$UnionPetscLib) + @chk ccall( + (:TSGLLEAdaptInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function TSGLLEAdaptFinalizePackage(::$UnionPetscLib) + @chk ccall( + (:TSGLLEAdaptFinalizePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function TSGLLEAdaptCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLEAdaptCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{TSGLLEAdapt}), + arg1, + arg2, + ) +end + +@for_petsc function TSGLLEAdaptSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLEAdaptSetType, $petsc_library), + PetscErrorCode, + (TSGLLEAdapt, TSGLLEAdaptType), + arg1, + arg2, + ) +end + +@for_petsc function TSGLLEAdaptSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLEAdaptSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (TSGLLEAdapt, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function TSGLLEAdaptChoose( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:TSGLLEAdaptChoose, $petsc_library), + PetscErrorCode, + ( + TSGLLEAdapt, + $PetscInt, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + $PetscInt, + $PetscReal, + $PetscReal, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function TSGLLEAdaptView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLEAdaptView, $petsc_library), + PetscErrorCode, + (TSGLLEAdapt, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function TSGLLEAdaptDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TSGLLEAdaptDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TSGLLEAdapt},), + arg1, + ) +end + +const TSGLLEAcceptType = Ptr{Cchar} + +# typedef PetscErrorCode ( * TSGLLEAcceptFunction ) ( TS , PetscReal , PetscReal , const PetscReal [ ] , PetscBool * ) +const TSGLLEAcceptFunction = Ptr{Cvoid} + +@for_petsc function TSGLLEAcceptRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLEAcceptRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, TSGLLEAcceptFunction), + arg1, + arg2, + ) +end + +const TSGLLEType = Ptr{Cchar} + +@for_petsc function TSGLLERegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLERegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSGLLEInitializePackage(::$UnionPetscLib) + @chk ccall((:TSGLLEInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSGLLEFinalizePackage(::$UnionPetscLib) + @chk ccall((:TSGLLEFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSGLLESetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLESetType, $petsc_library), + PetscErrorCode, + (TS, TSGLLEType), + arg1, + arg2, + ) +end + +@for_petsc function TSGLLEGetAdapt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLEGetAdapt, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSGLLEAdapt}), + arg1, + arg2, + ) +end + +@for_petsc function TSGLLESetAcceptType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGLLESetAcceptType, $petsc_library), + PetscErrorCode, + (TS, TSGLLEAcceptType), + arg1, + arg2, + ) +end + +@for_petsc function TSEIMEXSetMaxRows(::$UnionPetscLib, ts, arg2) + @chk ccall( + (:TSEIMEXSetMaxRows, $petsc_library), + PetscErrorCode, + (TS, $PetscInt), + ts, + arg2, + ) +end + +@for_petsc function TSEIMEXSetRowCol(::$UnionPetscLib, ts, arg2, arg3) + @chk ccall( + (:TSEIMEXSetRowCol, $petsc_library), + PetscErrorCode, + (TS, $PetscInt, $PetscInt), + ts, + arg2, + arg3, + ) +end + +@for_petsc function TSEIMEXSetOrdAdapt(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSEIMEXSetOrdAdapt, $petsc_library), + PetscErrorCode, + (TS, PetscBool), + arg1, + arg2, + ) +end + +const TSRKType = Ptr{Cchar} + +@for_petsc function TSRKGetOrder(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRKGetOrder, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TSRKGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRKGetType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSRKType}), + arg1, + arg2, + ) +end + +@for_petsc function TSRKSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRKSetType, $petsc_library), + PetscErrorCode, + (TS, TSRKType), + arg1, + arg2, + ) +end + +@for_petsc function TSRKGetTableau( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:TSRKGetTableau, $petsc_library), + PetscErrorCode, + ( + TS, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{$PetscInt}, + Ptr{Ptr{$PetscReal}}, + Ptr{PetscBool}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function TSRKSetMultirate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRKSetMultirate, $petsc_library), + PetscErrorCode, + (TS, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSRKGetMultirate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRKGetMultirate, $petsc_library), + PetscErrorCode, + (TS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TSRKRegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:TSRKRegister, $petsc_library), + PetscErrorCode, + ( + TSRKType, + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + $PetscInt, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function TSRKInitializePackage(::$UnionPetscLib) + @chk ccall((:TSRKInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSRKFinalizePackage(::$UnionPetscLib) + @chk ccall((:TSRKFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSRKRegisterDestroy(::$UnionPetscLib) + @chk ccall((:TSRKRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +const TSMPRKType = Ptr{Cchar} + +@for_petsc function TSMPRKGetType(::$UnionPetscLib, ts, arg2) + @chk ccall( + (:TSMPRKGetType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSMPRKType}), + ts, + arg2, + ) +end + +@for_petsc function TSMPRKSetType(::$UnionPetscLib, ts, arg2) + @chk ccall( + (:TSMPRKSetType, $petsc_library), + PetscErrorCode, + (TS, TSMPRKType), + ts, + arg2, + ) +end + +@for_petsc function TSMPRKRegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, +) + @chk ccall( + (:TSMPRKRegister, $petsc_library), + PetscErrorCode, + ( + TSMPRKType, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + ) +end + +@for_petsc function TSMPRKInitializePackage(::$UnionPetscLib) + @chk ccall((:TSMPRKInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSMPRKFinalizePackage(::$UnionPetscLib) + @chk ccall((:TSMPRKFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSMPRKRegisterDestroy(::$UnionPetscLib) + @chk ccall((:TSMPRKRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +const TSGLEEType = Ptr{Cchar} + +@for_petsc function TSGLEEGetType(::$UnionPetscLib, ts, arg2) + @chk ccall( + (:TSGLEEGetType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSGLEEType}), + ts, + arg2, + ) +end + +@for_petsc function TSGLEESetType(::$UnionPetscLib, ts, arg2) + @chk ccall( + (:TSGLEESetType, $petsc_library), + PetscErrorCode, + (TS, TSGLEEType), + ts, + arg2, + ) +end + +@for_petsc function TSGLEERegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, +) + @chk ccall( + (:TSGLEERegister, $petsc_library), + PetscErrorCode, + ( + TSGLEEType, + $PetscInt, + $PetscInt, + $PetscInt, + $PetscReal, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + $PetscInt, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + ) +end + +@for_petsc function TSGLEEFinalizePackage(::$UnionPetscLib) + @chk ccall((:TSGLEEFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSGLEEInitializePackage(::$UnionPetscLib) + @chk ccall((:TSGLEEInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSGLEERegisterDestroy(::$UnionPetscLib) + @chk ccall((:TSGLEERegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +const TSARKIMEXType = Ptr{Cchar} + +@for_petsc function TSARKIMEXGetType(::$UnionPetscLib, ts, arg2) + @chk ccall( + (:TSARKIMEXGetType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSARKIMEXType}), + ts, + arg2, + ) +end + +@for_petsc function TSARKIMEXSetType(::$UnionPetscLib, ts, arg2) + @chk ccall( + (:TSARKIMEXSetType, $petsc_library), + PetscErrorCode, + (TS, TSARKIMEXType), + ts, + arg2, + ) +end + +@for_petsc function TSARKIMEXSetFullyImplicit(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSARKIMEXSetFullyImplicit, $petsc_library), + PetscErrorCode, + (TS, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSARKIMEXGetFullyImplicit(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSARKIMEXGetFullyImplicit, $petsc_library), + PetscErrorCode, + (TS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TSARKIMEXRegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, +) + @chk ccall( + (:TSARKIMEXRegister, $petsc_library), + PetscErrorCode, + ( + TSARKIMEXType, + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + ) +end + +@for_petsc function TSARKIMEXInitializePackage(::$UnionPetscLib) + @chk ccall( + (:TSARKIMEXInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function TSARKIMEXFinalizePackage(::$UnionPetscLib) + @chk ccall((:TSARKIMEXFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSARKIMEXRegisterDestroy(::$UnionPetscLib) + @chk ccall((:TSARKIMEXRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +const TSRosWType = Ptr{Cchar} + +@for_petsc function TSRosWGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRosWGetType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSRosWType}), + arg1, + arg2, + ) +end + +@for_petsc function TSRosWSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRosWSetType, $petsc_library), + PetscErrorCode, + (TS, TSRosWType), + arg1, + arg2, + ) +end + +@for_petsc function TSRosWSetRecomputeJacobian(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRosWSetRecomputeJacobian, $petsc_library), + PetscErrorCode, + (TS, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSRosWRegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:TSRosWRegister, $petsc_library), + PetscErrorCode, + ( + TSRosWType, + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + $PetscInt, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function TSRosWRegisterRos4( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TSRosWRegisterRos4, $petsc_library), + PetscErrorCode, + ( + TSRosWType, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + $PetscReal, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TSRosWInitializePackage(::$UnionPetscLib) + @chk ccall((:TSRosWInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSRosWFinalizePackage(::$UnionPetscLib) + @chk ccall((:TSRosWFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSRosWRegisterDestroy(::$UnionPetscLib) + @chk ccall((:TSRosWRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TSBDFSetOrder(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSBDFSetOrder, $petsc_library), + PetscErrorCode, + (TS, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TSBDFGetOrder(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSBDFGetOrder, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +const TSBasicSymplecticType = Ptr{Cchar} + +@for_petsc function TSBasicSymplecticSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSBasicSymplecticSetType, $petsc_library), + PetscErrorCode, + (TS, TSBasicSymplecticType), + arg1, + arg2, + ) +end + +@for_petsc function TSBasicSymplecticGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSBasicSymplecticGetType, $petsc_library), + PetscErrorCode, + (TS, Ptr{TSBasicSymplecticType}), + arg1, + arg2, + ) +end + +@for_petsc function TSBasicSymplecticRegister( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSBasicSymplecticRegister, $petsc_library), + PetscErrorCode, + ( + TSBasicSymplecticType, + $PetscInt, + $PetscInt, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSBasicSymplecticInitializePackage(::$UnionPetscLib) + @chk ccall( + (:TSBasicSymplecticInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function TSBasicSymplecticFinalizePackage(::$UnionPetscLib) + @chk ccall( + (:TSBasicSymplecticFinalizePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function TSBasicSymplecticRegisterDestroy(::$UnionPetscLib) + @chk ccall( + (:TSBasicSymplecticRegisterDestroy, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function TSDiscGradSetFormulation( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSDiscGradSetFormulation, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSThetaSetTheta(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSThetaSetTheta, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSThetaGetTheta(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSThetaGetTheta, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TSThetaGetEndpoint(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSThetaGetEndpoint, $petsc_library), + PetscErrorCode, + (TS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TSThetaSetEndpoint(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSThetaSetEndpoint, $petsc_library), + PetscErrorCode, + (TS, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSAlphaSetRadius(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAlphaSetRadius, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSAlphaSetParams(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSAlphaSetParams, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSAlphaGetParams(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TSAlphaGetParams, $petsc_library), + PetscErrorCode, + (TS, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TSAlpha2SetRadius(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSAlpha2SetRadius, $petsc_library), + PetscErrorCode, + (TS, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TSAlpha2SetParams( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSAlpha2SetParams, $petsc_library), + PetscErrorCode, + (TS, $PetscReal, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSAlpha2GetParams( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TSAlpha2GetParams, $petsc_library), + PetscErrorCode, + ( + TS, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSSetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall((:TSSetDM, $petsc_library), PetscErrorCode, (TS, DM), arg1, arg2) +end + +@for_petsc function TSGetDM(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetDM, $petsc_library), + PetscErrorCode, + (TS, Ptr{DM}), + arg1, + arg2, + ) +end + +@for_petsc function SNESTSFormFunction(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:SNESTSFormFunction, $petsc_library), + PetscErrorCode, + (SNES, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function SNESTSFormJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:SNESTSFormJacobian, $petsc_library), + PetscErrorCode, + (SNES, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TSRHSJacobianTest(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRHSJacobianTest, $petsc_library), + PetscErrorCode, + (TS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TSRHSJacobianTestTranspose(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSRHSJacobianTestTranspose, $petsc_library), + PetscErrorCode, + (TS, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TSGetComputeInitialCondition(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetComputeInitialCondition, $petsc_library), + PetscErrorCode, + (TS, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetComputeInitialCondition(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetComputeInitialCondition, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSComputeInitialCondition(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSComputeInitialCondition, $petsc_library), + PetscErrorCode, + (TS, Vec), + arg1, + arg2, + ) +end + +@for_petsc function TSGetComputeExactError(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSGetComputeExactError, $petsc_library), + PetscErrorCode, + (TS, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function TSSetComputeExactError(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetComputeExactError, $petsc_library), + PetscErrorCode, + (TS, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TSComputeExactError(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TSComputeExactError, $petsc_library), + PetscErrorCode, + (TS, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function PetscConvEstUseTS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:PetscConvEstUseTS, $petsc_library), + PetscErrorCode, + (PetscConvEst, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TSSetMatStructure(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TSSetMatStructure, $petsc_library), + PetscErrorCode, + (TS, MatStructure), + arg1, + arg2, + ) +end + +@for_petsc function VecFischer(::$UnionPetscLib, arg1, arg2, arg3, arg4, arg5) + @chk ccall( + (:VecFischer, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function VecSFischer( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:VecSFischer, $petsc_library), + PetscErrorCode, + (Vec, Vec, Vec, Vec, $PetscReal, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatDFischer( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:MatDFischer, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec, Vec, Vec, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function MatDSFischer( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, +) + @chk ccall( + (:MatDSFischer, $petsc_library), + PetscErrorCode, + (Mat, Vec, Vec, Vec, Vec, $PetscReal, Vec, Vec, Vec, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + ) +end + +@for_petsc function TaoSoftThreshold(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TaoSoftThreshold, $petsc_library), + PetscErrorCode, + (Vec, $PetscReal, $PetscReal, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@enum TaoSubsetType::UInt32 begin + TAO_SUBSET_SUBVEC = 0 + TAO_SUBSET_MASK = 1 + TAO_SUBSET_MATRIXFREE = 2 +end + +@enum TaoADMMUpdateType::UInt32 begin + TAO_ADMM_UPDATE_BASIC = 0 + TAO_ADMM_UPDATE_ADAPTIVE = 1 + TAO_ADMM_UPDATE_ADAPTIVE_RELAXED = 2 +end + +@enum TaoADMMRegularizerType::UInt32 begin + TAO_ADMM_REGULARIZER_USER = 0 + TAO_ADMM_REGULARIZER_SOFT_THRESH = 1 +end + +@enum TaoALMMType::UInt32 begin + TAO_ALMM_CLASSIC = 0 + TAO_ALMM_PHR = 1 +end + +mutable struct _p_Tao end + +const Tao = Ptr{_p_Tao} + +const TaoType = Ptr{Cchar} + +@enum TaoConvergedReason::Int32 begin + TAO_CONVERGED_GATOL = 3 + TAO_CONVERGED_GRTOL = 4 + TAO_CONVERGED_GTTOL = 5 + TAO_CONVERGED_STEPTOL = 6 + TAO_CONVERGED_MINF = 7 + TAO_CONVERGED_USER = 8 + TAO_DIVERGED_MAXITS = -2 + TAO_DIVERGED_NAN = -4 + TAO_DIVERGED_MAXFCN = -5 + TAO_DIVERGED_LS_FAILURE = -6 + TAO_DIVERGED_TR_REDUCTION = -7 + TAO_DIVERGED_USER = -8 + TAO_CONTINUE_ITERATING = 0 +end + +@for_petsc function TaoInitializePackage(::$UnionPetscLib) + @chk ccall((:TaoInitializePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TaoFinalizePackage(::$UnionPetscLib) + @chk ccall((:TaoFinalizePackage, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TaoCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{Tao}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoSetFromOptions, $petsc_library), + PetscErrorCode, + (Tao,), + arg1, + ) +end + +@for_petsc function TaoSetUp(::$UnionPetscLib, arg1) + @chk ccall((:TaoSetUp, $petsc_library), PetscErrorCode, (Tao,), arg1) +end + +@for_petsc function TaoSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetType, $petsc_library), + PetscErrorCode, + (Tao, TaoType), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetType, $petsc_library), + PetscErrorCode, + (Tao, Ptr{TaoType}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetApplicationContext, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetApplicationContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetApplicationContext, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoDestroy(::$UnionPetscLib, arg1) + @chk ccall((:TaoDestroy, $petsc_library), PetscErrorCode, (Ptr{Tao},), arg1) +end + +@for_petsc function TaoSetOptionsPrefix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cchar}), + arg1, + arg2, + ) +end + +@for_petsc function TaoView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoView, $petsc_library), + PetscErrorCode, + (Tao, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function TaoViewFromOptions(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoViewFromOptions, $petsc_library), + PetscErrorCode, + (Tao, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoSolve(::$UnionPetscLib, arg1) + @chk ccall((:TaoSolve, $petsc_library), PetscErrorCode, (Tao,), arg1) +end + +@for_petsc function TaoRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoRegisterDestroy(::$UnionPetscLib) + @chk ccall((:TaoRegisterDestroy, $petsc_library), PetscErrorCode, ()) +end + +@for_petsc function TaoGetConvergedReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetConvergedReason, $petsc_library), + PetscErrorCode, + (Tao, Ptr{TaoConvergedReason}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetSolutionStatus( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TaoGetSolutionStatus, $petsc_library), + PetscErrorCode, + ( + Tao, + Ptr{$PetscInt}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{TaoConvergedReason}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TaoSetConvergedReason(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetConvergedReason, $petsc_library), + PetscErrorCode, + (Tao, TaoConvergedReason), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetInitialVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetInitialVector, $petsc_library), + PetscErrorCode, + (Tao, Vec), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetSolutionVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetSolutionVector, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetGradientVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetGradientVector, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetGradientNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetGradientNorm, $petsc_library), + PetscErrorCode, + (Tao, Mat), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetGradientNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetGradientNorm, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetLMVMMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetLMVMMatrix, $petsc_library), + PetscErrorCode, + (Tao, Mat), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetLMVMMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetLMVMMatrix, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetRecycleHistory(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetRecycleHistory, $petsc_library), + PetscErrorCode, + (Tao, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetRecycleHistory(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetRecycleHistory, $petsc_library), + PetscErrorCode, + (Tao, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLMVMSetH0(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLMVMSetH0, $petsc_library), + PetscErrorCode, + (Tao, Mat), + arg1, + arg2, + ) +end + +@for_petsc function TaoLMVMGetH0(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLMVMGetH0, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Mat}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLMVMGetH0KSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLMVMGetH0KSP, $petsc_library), + PetscErrorCode, + (Tao, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLMVMRecycle(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLMVMRecycle, $petsc_library), + PetscErrorCode, + (Tao, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetObjectiveRoutine(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoSetObjectiveRoutine, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoSetGradientRoutine(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoSetGradientRoutine, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoSetObjectiveAndGradientRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoSetObjectiveAndGradientRoutine, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoSetHessianRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoSetHessianRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoSetResidualRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoSetResidualRoutine, $petsc_library), + PetscErrorCode, + (Tao, Vec, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoSetResidualWeights( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TaoSetResidualWeights, $petsc_library), + PetscErrorCode, + (Tao, Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TaoSetConstraintsRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoSetConstraintsRoutine, $petsc_library), + PetscErrorCode, + (Tao, Vec, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoSetInequalityConstraintsRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoSetInequalityConstraintsRoutine, $petsc_library), + PetscErrorCode, + (Tao, Vec, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoSetEqualityConstraintsRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoSetEqualityConstraintsRoutine, $petsc_library), + PetscErrorCode, + (Tao, Vec, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoSetJacobianResidualRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoSetJacobianResidualRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoSetJacobianRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoSetJacobianRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoSetJacobianStateRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TaoSetJacobianStateRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TaoSetJacobianDesignRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoSetJacobianDesignRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoSetJacobianInequalityRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoSetJacobianInequalityRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoSetJacobianEqualityRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoSetJacobianEqualityRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoShellSetSolve(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoShellSetSolve, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoShellSetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoShellSetContext, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoShellGetContext(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoShellGetContext, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Ptr{Cvoid}}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetSeparableObjectiveRoutine( + ::$UnionPetscLib, + tao, + res, + func, + ctx, +) + @chk ccall( + (:TaoSetSeparableObjectiveRoutine, $petsc_library), + PetscErrorCode, + (Tao, Vec, Ptr{Cvoid}, Ptr{Cvoid}), + tao, + res, + func, + ctx, + ) +end + +@for_petsc function TaoSetSeparableObjectiveWeights( + ::$UnionPetscLib, + tao, + sigma_v, + n, + rows, + cols, + vals, +) + @chk ccall( + (:TaoSetSeparableObjectiveWeights, $petsc_library), + PetscErrorCode, + (Tao, Vec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscReal}), + tao, + sigma_v, + n, + rows, + cols, + vals, + ) +end + +@for_petsc function TaoSetStateDesignIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoSetStateDesignIS, $petsc_library), + PetscErrorCode, + (Tao, IS, IS), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoComputeObjective(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoComputeObjective, $petsc_library), + PetscErrorCode, + (Tao, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoComputeResidual(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoComputeResidual, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoTestGradient(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoTestGradient, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoComputeGradient(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoComputeGradient, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoComputeObjectiveAndGradient( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoComputeObjectiveAndGradient, $petsc_library), + PetscErrorCode, + (Tao, Vec, Ptr{$PetscReal}, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoComputeConstraints(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoComputeConstraints, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoComputeInequalityConstraints( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoComputeInequalityConstraints, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoComputeEqualityConstraints( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoComputeEqualityConstraints, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoDefaultComputeGradient( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoDefaultComputeGradient, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoIsObjectiveDefined(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoIsObjectiveDefined, $petsc_library), + PetscErrorCode, + (Tao, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TaoIsGradientDefined(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoIsGradientDefined, $petsc_library), + PetscErrorCode, + (Tao, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TaoIsObjectiveAndGradientDefined( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoIsObjectiveAndGradientDefined, $petsc_library), + PetscErrorCode, + (Tao, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TaoComputeSeparableObjective(::$UnionPetscLib, tao, X, F) + @chk ccall( + (:TaoComputeSeparableObjective, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + tao, + X, + F, + ) +end + +@for_petsc function TaoTestHessian(::$UnionPetscLib, arg1) + @chk ccall((:TaoTestHessian, $petsc_library), PetscErrorCode, (Tao,), arg1) +end + +@for_petsc function TaoComputeHessian(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TaoComputeHessian, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoComputeResidualJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoComputeResidualJacobian, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoComputeJacobian(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TaoComputeJacobian, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoComputeJacobianState( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoComputeJacobianState, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoComputeJacobianEquality( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoComputeJacobianEquality, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoComputeJacobianInequality( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoComputeJacobianInequality, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat, Mat), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoComputeJacobianDesign(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoComputeJacobianDesign, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoDefaultComputeHessian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoDefaultComputeHessian, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoDefaultComputeHessianColor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoDefaultComputeHessianColor, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoDefaultComputeHessianMFFD( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoDefaultComputeHessianMFFD, $petsc_library), + PetscErrorCode, + (Tao, Vec, Mat, Mat, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoComputeDualVariables(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoComputeDualVariables, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoSetVariableBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoSetVariableBounds, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoGetVariableBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoGetVariableBounds, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoGetDualVariables(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoGetDualVariables, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoSetInequalityBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoSetInequalityBounds, $petsc_library), + PetscErrorCode, + (Tao, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoGetInequalityBounds(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoGetInequalityBounds, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Vec}, Ptr{Vec}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoSetVariableBoundsRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoSetVariableBoundsRoutine, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoComputeVariableBounds(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoComputeVariableBounds, $petsc_library), + PetscErrorCode, + (Tao,), + arg1, + ) +end + +@for_petsc function TaoGetTolerances(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TaoGetTolerances, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscReal}, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoSetTolerances(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TaoSetTolerances, $petsc_library), + PetscErrorCode, + (Tao, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoGetConstraintTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoGetConstraintTolerances, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoSetConstraintTolerances( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoSetConstraintTolerances, $petsc_library), + PetscErrorCode, + (Tao, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoSetFunctionLowerBound(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetFunctionLowerBound, $petsc_library), + PetscErrorCode, + (Tao, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetInitialTrustRegionRadius(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetInitialTrustRegionRadius, $petsc_library), + PetscErrorCode, + (Tao, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetMaximumIterations(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetMaximumIterations, $petsc_library), + PetscErrorCode, + (Tao, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetMaximumFunctionEvaluations( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoSetMaximumFunctionEvaluations, $petsc_library), + PetscErrorCode, + (Tao, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetFunctionLowerBound(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetFunctionLowerBound, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetInitialTrustRegionRadius(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetInitialTrustRegionRadius, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetCurrentTrustRegionRadius(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetCurrentTrustRegionRadius, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetMaximumIterations(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetMaximumIterations, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetCurrentFunctionEvaluations( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoGetCurrentFunctionEvaluations, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetMaximumFunctionEvaluations( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoGetMaximumFunctionEvaluations, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetIterationNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetIterationNumber, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetIterationNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetIterationNumber, $petsc_library), + PetscErrorCode, + (Tao, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetTotalIterationNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetTotalIterationNumber, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetTotalIterationNumber(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSetTotalIterationNumber, $petsc_library), + PetscErrorCode, + (Tao, $PetscInt), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetResidualNorm(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetResidualNorm, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetObjective(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetObjective, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TaoAppendOptionsPrefix(::$UnionPetscLib, arg1, p) + @chk ccall( + (:TaoAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cchar}), + arg1, + p, + ) +end + +@for_petsc function TaoGetOptionsPrefix(::$UnionPetscLib, arg1, p) + @chk ccall( + (:TaoGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Ptr{Cchar}}), + arg1, + p, + ) +end + +@for_petsc function TaoResetStatistics(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoResetStatistics, $petsc_library), + PetscErrorCode, + (Tao,), + arg1, + ) +end + +@for_petsc function TaoSetUpdate(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoSetUpdate, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoGetKSP(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetKSP, $petsc_library), + PetscErrorCode, + (Tao, Ptr{KSP}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetLinearSolveIterations(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetLinearSolveIterations, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscInt}), + arg1, + arg2, + ) +end + +mutable struct _p_TaoLineSearch end + +const TaoLineSearch = Ptr{_p_TaoLineSearch} + +@enum TaoLineSearchConvergedReason::Int32 begin + TAOLINESEARCH_FAILED_INFORNAN = -1 + TAOLINESEARCH_FAILED_BADPARAMETER = -2 + TAOLINESEARCH_FAILED_ASCENT = -3 + TAOLINESEARCH_CONTINUE_ITERATING = 0 + TAOLINESEARCH_SUCCESS = 1 + TAOLINESEARCH_SUCCESS_USER = 2 + TAOLINESEARCH_HALTED_OTHER = 3 + TAOLINESEARCH_HALTED_MAXFCN = 4 + TAOLINESEARCH_HALTED_UPPERBOUND = 5 + TAOLINESEARCH_HALTED_LOWERBOUND = 6 + TAOLINESEARCH_HALTED_RTOL = 7 + TAOLINESEARCH_HALTED_USER = 8 +end + +const TaoLineSearchType = Ptr{Cchar} + +@for_petsc function TaoLineSearchCreate(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLineSearchCreate, $petsc_library), + PetscErrorCode, + (MPI_Comm, Ptr{TaoLineSearch}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchSetFromOptions(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoLineSearchSetFromOptions, $petsc_library), + PetscErrorCode, + (TaoLineSearch,), + arg1, + ) +end + +@for_petsc function TaoLineSearchSetUp(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoLineSearchSetUp, $petsc_library), + PetscErrorCode, + (TaoLineSearch,), + arg1, + ) +end + +@for_petsc function TaoLineSearchDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoLineSearchDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TaoLineSearch},), + arg1, + ) +end + +@for_petsc function TaoLineSearchMonitor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoLineSearchMonitor, $petsc_library), + PetscErrorCode, + (TaoLineSearch, $PetscInt, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoLineSearchView(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLineSearchView, $petsc_library), + PetscErrorCode, + (TaoLineSearch, PetscViewer), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchViewFromOptions( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoLineSearchViewFromOptions, $petsc_library), + PetscErrorCode, + (TaoLineSearch, PetscObject, Ptr{Cchar}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoLineSearchSetOptionsPrefix( + ::$UnionPetscLib, + arg1, + prefix, +) + @chk ccall( + (:TaoLineSearchSetOptionsPrefix, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{Cchar}), + arg1, + prefix, + ) +end + +@for_petsc function TaoLineSearchReset(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoLineSearchReset, $petsc_library), + PetscErrorCode, + (TaoLineSearch,), + arg1, + ) +end + +@for_petsc function TaoLineSearchAppendOptionsPrefix( + ::$UnionPetscLib, + arg1, + prefix, +) + @chk ccall( + (:TaoLineSearchAppendOptionsPrefix, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{Cchar}), + arg1, + prefix, + ) +end + +@for_petsc function TaoLineSearchGetOptionsPrefix( + ::$UnionPetscLib, + arg1, + prefix, +) + @chk ccall( + (:TaoLineSearchGetOptionsPrefix, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{Ptr{Cchar}}), + arg1, + prefix, + ) +end + +@for_petsc function TaoLineSearchApply( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TaoLineSearchApply, $petsc_library), + PetscErrorCode, + ( + TaoLineSearch, + Vec, + Ptr{$PetscReal}, + Vec, + Vec, + Ptr{$PetscReal}, + Ptr{TaoLineSearchConvergedReason}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TaoLineSearchGetStepLength(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLineSearchGetStepLength, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchGetStartingVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLineSearchGetStartingVector, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchGetStepDirection(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLineSearchGetStepDirection, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchSetInitialStepLength( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoLineSearchSetInitialStepLength, $petsc_library), + PetscErrorCode, + (TaoLineSearch, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchGetSolution( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TaoLineSearchGetSolution, $petsc_library), + PetscErrorCode, + ( + TaoLineSearch, + Vec, + Ptr{$PetscReal}, + Vec, + Ptr{$PetscReal}, + Ptr{TaoLineSearchConvergedReason}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TaoLineSearchGetFullStepObjective( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoLineSearchGetFullStepObjective, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchGetNumberFunctionEvaluations( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoLineSearchGetNumberFunctionEvaluations, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{$PetscInt}, Ptr{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoLineSearchGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLineSearchGetType, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{TaoLineSearchType}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLineSearchSetType, $petsc_library), + PetscErrorCode, + (TaoLineSearch, TaoLineSearchType), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchIsUsingTaoRoutines( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoLineSearchIsUsingTaoRoutines, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{PetscBool}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchSetObjectiveAndGTSRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoLineSearchSetObjectiveAndGTSRoutine, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoLineSearchSetObjectiveRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoLineSearchSetObjectiveRoutine, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoLineSearchSetGradientRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoLineSearchSetGradientRoutine, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoLineSearchSetObjectiveAndGradientRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoLineSearchSetObjectiveAndGradientRoutine, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoLineSearchComputeObjective( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoLineSearchComputeObjective, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Vec, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoLineSearchComputeGradient( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoLineSearchComputeGradient, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoLineSearchComputeObjectiveAndGradient( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoLineSearchComputeObjectiveAndGradient, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Vec, Ptr{$PetscReal}, Vec), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoLineSearchComputeObjectiveAndGTS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoLineSearchComputeObjectiveAndGTS, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Vec, Ptr{$PetscReal}, Ptr{$PetscReal}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoLineSearchSetVariableBounds( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoLineSearchSetVariableBounds, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Vec, Vec), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoLineSearchInitializePackage(::$UnionPetscLib) + @chk ccall( + (:TaoLineSearchInitializePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function TaoLineSearchFinalizePackage(::$UnionPetscLib) + @chk ccall( + (:TaoLineSearchFinalizePackage, $petsc_library), + PetscErrorCode, + (), + ) +end + +@for_petsc function TaoLineSearchRegister(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLineSearchRegister, $petsc_library), + PetscErrorCode, + (Ptr{Cchar}, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoLineSearchUseTaoRoutines(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoLineSearchUseTaoRoutines, $petsc_library), + PetscErrorCode, + (TaoLineSearch, Tao), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetLineSearch(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetLineSearch, $petsc_library), + PetscErrorCode, + (Tao, Ptr{TaoLineSearch}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetConvergenceHistory( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:TaoSetConvergenceHistory, $petsc_library), + PetscErrorCode, + ( + Tao, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscReal}, + Ptr{$PetscInt}, + $PetscInt, + PetscBool, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function TaoGetConvergenceHistory( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TaoGetConvergenceHistory, $petsc_library), + PetscErrorCode, + ( + Tao, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscReal}}, + Ptr{Ptr{$PetscInt}}, + Ptr{$PetscInt}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function TaoSetMonitor(::$UnionPetscLib, arg1, arg2, arg3, arg4) + @chk ccall( + (:TaoSetMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoCancelMonitors(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoCancelMonitors, $petsc_library), + PetscErrorCode, + (Tao,), + arg1, + ) +end + +@for_petsc function TaoMonitorDefault(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoMonitorDefault, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoDefaultMonitor(::$UnionPetscLib, tao, ctx) + @chk ccall( + (:TaoDefaultMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + tao, + ctx, + ) +end + +@for_petsc function TaoDefaultGMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoDefaultGMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoDefaultSMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoDefaultSMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoDefaultCMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoDefaultCMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSolutionMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoSolutionMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoResidualMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoResidualMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoGradientMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGradientMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoStepDirectionMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoStepDirectionMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoDrawSolutionMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoDrawSolutionMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoDrawStepMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoDrawStepMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoDrawGradientMonitor(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoDrawGradientMonitor, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoAddLineSearchCounts(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoAddLineSearchCounts, $petsc_library), + PetscErrorCode, + (Tao,), + arg1, + ) +end + +@for_petsc function TaoDefaultConvergenceTest(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoDefaultConvergenceTest, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}), + arg1, + arg2, + ) +end + +@for_petsc function TaoSetConvergenceTest(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoSetConvergenceTest, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoLCLSetStateDesignIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoLCLSetStateDesignIS, $petsc_library), + PetscErrorCode, + (Tao, IS, IS), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoMonitor( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:TaoMonitor, $petsc_library), + PetscErrorCode, + (Tao, $PetscInt, $PetscReal, $PetscReal, $PetscReal, $PetscReal), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +mutable struct _n_TaoMonitorDrawCtx end + +const TaoMonitorDrawCtx = Ptr{_n_TaoMonitorDrawCtx} + +@for_petsc function TaoMonitorDrawCtxCreate( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, +) + @chk ccall( + (:TaoMonitorDrawCtxCreate, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + Ptr{Cchar}, + Ptr{Cchar}, + Cint, + Cint, + Cint, + Cint, + $PetscInt, + Ptr{TaoMonitorDrawCtx}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + ) +end + +@for_petsc function TaoMonitorDrawCtxDestroy(::$UnionPetscLib, arg1) + @chk ccall( + (:TaoMonitorDrawCtxDestroy, $petsc_library), + PetscErrorCode, + (Ptr{TaoMonitorDrawCtx},), + arg1, + ) +end + +@for_petsc function TaoBRGNGetSubsolver(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoBRGNGetSubsolver, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Tao}), + arg1, + arg2, + ) +end + +@for_petsc function TaoBRGNSetRegularizerObjectiveAndGradientRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoBRGNSetRegularizerObjectiveAndGradientRoutine, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoBRGNSetRegularizerHessianRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, +) + @chk ccall( + (:TaoBRGNSetRegularizerHessianRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + ) +end + +@for_petsc function TaoBRGNSetRegularizerWeight(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoBRGNSetRegularizerWeight, $petsc_library), + PetscErrorCode, + (Tao, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TaoBRGNSetL1SmoothEpsilon(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoBRGNSetL1SmoothEpsilon, $petsc_library), + PetscErrorCode, + (Tao, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TaoBRGNSetDictionaryMatrix(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoBRGNSetDictionaryMatrix, $petsc_library), + PetscErrorCode, + (Tao, Mat), + arg1, + arg2, + ) +end + +@for_petsc function TaoBRGNGetDampingVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoBRGNGetDampingVector, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMGetMisfitSubsolver(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoADMMGetMisfitSubsolver, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Tao}), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMGetRegularizationSubsolver( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoADMMGetRegularizationSubsolver, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Tao}), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMGetDualVector(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoADMMGetDualVector, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMGetSpectralPenalty(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoADMMGetSpectralPenalty, $petsc_library), + PetscErrorCode, + (Tao, Ptr{$PetscReal}), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMSetSpectralPenalty(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoADMMSetSpectralPenalty, $petsc_library), + PetscErrorCode, + (Tao, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TaoGetADMMParentTao(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoGetADMMParentTao, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Tao}), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMSetConstraintVectorRHS(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoADMMSetConstraintVectorRHS, $petsc_library), + PetscErrorCode, + (Tao, Vec), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMSetRegularizerCoefficient( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoADMMSetRegularizerCoefficient, $petsc_library), + PetscErrorCode, + (Tao, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMSetMisfitConstraintJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoADMMSetMisfitConstraintJacobian, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoADMMSetRegularizerConstraintJacobian( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoADMMSetRegularizerConstraintJacobian, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoADMMSetRegularizerHessianRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoADMMSetRegularizerHessianRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoADMMSetRegularizerObjectiveAndGradientRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoADMMSetRegularizerObjectiveAndGradientRoutine, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoADMMSetMisfitHessianRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:TaoADMMSetMisfitHessianRoutine, $petsc_library), + PetscErrorCode, + (Tao, Mat, Mat, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + +@for_petsc function TaoADMMSetMisfitObjectiveAndGradientRoutine( + ::$UnionPetscLib, + arg1, + arg2, + arg3, +) + @chk ccall( + (:TaoADMMSetMisfitObjectiveAndGradientRoutine, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Cvoid}, Ptr{Cvoid}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoADMMSetMisfitHessianChangeStatus( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoADMMSetMisfitHessianChangeStatus, $petsc_library), + PetscErrorCode, + (Tao, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMSetRegHessianChangeStatus( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoADMMSetRegHessianChangeStatus, $petsc_library), + PetscErrorCode, + (Tao, PetscBool), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMSetMinimumSpectralPenalty( + ::$UnionPetscLib, + arg1, + arg2, +) + @chk ccall( + (:TaoADMMSetMinimumSpectralPenalty, $petsc_library), + PetscErrorCode, + (Tao, $PetscReal), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMSetRegularizerType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoADMMSetRegularizerType, $petsc_library), + PetscErrorCode, + (Tao, TaoADMMRegularizerType), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMGetRegularizerType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoADMMGetRegularizerType, $petsc_library), + PetscErrorCode, + (Tao, Ptr{TaoADMMRegularizerType}), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMSetUpdateType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoADMMSetUpdateType, $petsc_library), + PetscErrorCode, + (Tao, TaoADMMUpdateType), + arg1, + arg2, + ) +end + +@for_petsc function TaoADMMGetUpdateType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoADMMGetUpdateType, $petsc_library), + PetscErrorCode, + (Tao, Ptr{TaoADMMUpdateType}), + arg1, + arg2, + ) +end + +@for_petsc function TaoALMMGetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoALMMGetType, $petsc_library), + PetscErrorCode, + (Tao, Ptr{TaoALMMType}), + arg1, + arg2, + ) +end + +@for_petsc function TaoALMMSetType(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoALMMSetType, $petsc_library), + PetscErrorCode, + (Tao, TaoALMMType), + arg1, + arg2, + ) +end + +@for_petsc function TaoALMMGetSubsolver(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoALMMGetSubsolver, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Tao}), + arg1, + arg2, + ) +end + +@for_petsc function TaoALMMSetSubsolver(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoALMMSetSubsolver, $petsc_library), + PetscErrorCode, + (Tao, Tao), + arg1, + arg2, + ) +end + +@for_petsc function TaoALMMGetMultipliers(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoALMMGetMultipliers, $petsc_library), + PetscErrorCode, + (Tao, Ptr{Vec}), + arg1, + arg2, + ) +end + +@for_petsc function TaoALMMSetMultipliers(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:TaoALMMSetMultipliers, $petsc_library), + PetscErrorCode, + (Tao, Vec), + arg1, + arg2, + ) +end + +@for_petsc function TaoALMMGetPrimalIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoALMMGetPrimalIS, $petsc_library), + PetscErrorCode, + (Tao, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +@for_petsc function TaoALMMGetDualIS(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:TaoALMMGetDualIS, $petsc_library), + PetscErrorCode, + (Tao, Ptr{IS}, Ptr{IS}), + arg1, + arg2, + arg3, + ) +end + +const PETSC_ARCH = "" + +const PETSC_BLASLAPACK_UNDERSCORE = 1 + +const PETSC_CLANGUAGE_C = 1 + +# Skipping MacroDefinition: PETSC_CXX_INLINE inline + +# Skipping MacroDefinition: PETSC_C_INLINE inline + +const PETSC_DIR = "/workspace/destdir" + +const PETSC_DIR_SEPARATOR = Cchar('/') + +const PETSC_DO_NOT_SWAP_CHILD_FOR_DEBUGGER = 1 + +# Skipping MacroDefinition: PETSC_FORTRAN_TYPE_INITIALIZE = - 2 + +# Skipping MacroDefinition: PETSC_FUNCTION_NAME_C __func__ + +# Skipping MacroDefinition: PETSC_FUNCTION_NAME_CXX __func__ + +const PETSC_HAVE_ACCESS = 1 + +const PETSC_HAVE_ATOLL = 1 + +const PETSC_HAVE_ATTRIBUTEALIGNED = 1 + +const PETSC_HAVE_BUILTIN_EXPECT = 1 + +const PETSC_HAVE_BZERO = 1 + +const PETSC_HAVE_C99_COMPLEX = 1 + +const PETSC_HAVE_CLOCK = 1 + +const PETSC_HAVE_CLOSURE = 1 + +const PETSC_HAVE_CXX = 1 + +const PETSC_HAVE_CXX_COMPLEX = 1 + +const PETSC_HAVE_CXX_DIALECT_CXX11 = 1 + +const PETSC_HAVE_CXX_DIALECT_CXX14 = 1 + +const PETSC_HAVE_DLADDR = 1 + +const PETSC_HAVE_DLCLOSE = 1 + +const PETSC_HAVE_DLERROR = 1 + +const PETSC_HAVE_DLOPEN = 1 + +const PETSC_HAVE_DLSYM = 1 + +const PETSC_HAVE_DOUBLE_ALIGN_MALLOC = 1 + +const PETSC_HAVE_DRAND48 = 1 + +const PETSC_HAVE_DYNAMIC_LIBRARIES = 1 + +const PETSC_HAVE_ERF = 1 + +const PETSC_HAVE_FORK = 1 + +const PETSC_HAVE_FORTRAN = 1 + +const PETSC_HAVE_FORTRAN_FLUSH = 1 + +const PETSC_HAVE_FORTRAN_GET_COMMAND_ARGUMENT = 1 + +const PETSC_HAVE_FORTRAN_TYPE_STAR = 1 + +const PETSC_HAVE_FORTRAN_UNDERSCORE = 1 + +const PETSC_HAVE_GETCWD = 1 + +const PETSC_HAVE_GETDOMAINNAME = 1 + +const PETSC_HAVE_GETHOSTBYNAME = 1 + +const PETSC_HAVE_GETHOSTNAME = 1 + +const PETSC_HAVE_GETPAGESIZE = 1 + +const PETSC_HAVE_GETRUSAGE = 1 + +const PETSC_HAVE_GETWD = 1 + +const PETSC_HAVE_ISINF = 1 + +const PETSC_HAVE_ISNAN = 1 + +const PETSC_HAVE_ISNORMAL = 1 + +const PETSC_HAVE_LGAMMA = 1 + +const PETSC_HAVE_LOG2 = 1 + +const PETSC_HAVE_LSEEK = 1 + +const PETSC_HAVE_MEMMOVE = 1 + +const PETSC_HAVE_MMAP = 1 + +const PETSC_HAVE_MPICH_NUMVERSION = 30402300 + +const PETSC_HAVE_MPIIO = 1 + +const PETSC_HAVE_MPI_COMBINER_CONTIGUOUS = 1 + +const PETSC_HAVE_MPI_COMBINER_DUP = 1 + +const PETSC_HAVE_MPI_COMBINER_NAMED = 1 + +const PETSC_HAVE_MPI_EXSCAN = 1 + +const PETSC_HAVE_MPI_F90MODULE = 1 + +const PETSC_HAVE_MPI_F90MODULE_VISIBILITY = 1 + +const PETSC_HAVE_MPI_FINALIZED = 1 + +const PETSC_HAVE_MPI_GET_ACCUMULATE = 1 + +const PETSC_HAVE_MPI_GET_LIBRARY_VERSION = 1 + +const PETSC_HAVE_MPI_IALLREDUCE = 1 + +const PETSC_HAVE_MPI_IBARRIER = 1 + +const PETSC_HAVE_MPI_INIT_THREAD = 1 + +const PETSC_HAVE_MPI_INT64_T = 1 + +const PETSC_HAVE_MPI_IN_PLACE = 1 + +const PETSC_HAVE_MPI_LONG_DOUBLE = 1 + +const PETSC_HAVE_MPI_NONBLOCKING_COLLECTIVES = 1 + +const PETSC_HAVE_MPI_ONE_SIDED = 1 + +const PETSC_HAVE_MPI_PROCESS_SHARED_MEMORY = 1 + +const PETSC_HAVE_MPI_REDUCE_LOCAL = 1 + +const PETSC_HAVE_MPI_REDUCE_SCATTER = 1 + +const PETSC_HAVE_MPI_REDUCE_SCATTER_BLOCK = 1 + +const PETSC_HAVE_MPI_RGET = 1 + +const PETSC_HAVE_MPI_TYPE_DUP = 1 + +const PETSC_HAVE_MPI_TYPE_GET_ENVELOPE = 1 + +const PETSC_HAVE_MPI_WIN_CREATE = 1 + +const PETSC_HAVE_NANOSLEEP = 1 + +const PETSC_HAVE_PACKAGES = ":blaslapack:mathlib:mpi:pthread:regex:" + +const PETSC_HAVE_POPEN = 1 + +const PETSC_HAVE_PTHREAD = 1 + +const PETSC_HAVE_RAND = 1 + +const PETSC_HAVE_READLINK = 1 + +const PETSC_HAVE_REALPATH = 1 + +const PETSC_HAVE_REGEX = 1 + +const PETSC_HAVE_RTLD_GLOBAL = 1 + +const PETSC_HAVE_RTLD_LAZY = 1 + +const PETSC_HAVE_RTLD_LOCAL = 1 + +const PETSC_HAVE_RTLD_NOW = 1 + +const PETSC_HAVE_SLEEP = 1 + +const PETSC_HAVE_SNPRINTF = 1 + +const PETSC_HAVE_SOCKET = 1 + +const PETSC_HAVE_SO_REUSEADDR = 1 + +const PETSC_HAVE_STRCASECMP = 1 + +const PETSC_HAVE_STRUCT_SIGACTION = 1 + +const PETSC_HAVE_TGAMMA = 1 + +const PETSC_HAVE_TIME = 1 + +const PETSC_HAVE_UNAME = 1 + +const PETSC_HAVE_USLEEP = 1 + +const PETSC_HAVE_VA_COPY = 1 + +const PETSC_HAVE_VSNPRINTF = 1 + +const PETSC_IS_COLORING_VALUE_TYPE = Cshort + +const PETSC_LEVEL1_DCACHE_LINESIZE = 32 + +const PETSC_LIB_DIR = "/workspace/destdir/lib" + +const PETSC_MAX_PATH_LEN = 1024 + +const PETSC_MEMALIGN = 16 + +const PETSC_MPICC_SHOW = "Unavailable" + +const PETSC_MPIU_IS_COLORING_VALUE_TYPE = MPI_UNSIGNED_SHORT + +const PETSC_PYTHON_EXE = "/usr/bin/python3" + +const PETSC_REPLACE_DIR_SEPARATOR = Cchar('\\') + +const PETSC_RTLD_DEFAULT = 1 + +const PETSC_SIZEOF_ENUM = 4 + +const PETSC_SIZEOF_INT = 4 + +const PETSC_SIZEOF_LONG = 8 + +const PETSC_SIZEOF_LONG_LONG = 8 + +const PETSC_SIZEOF_SHORT = 2 + +const PETSC_SIZEOF_SIZE_T = 8 + +const PETSC_SIZEOF_VOID_P = 8 + +const PETSC_SLSUFFIX = "dylib" + +const PETSC_USE_64BIT_INDICES = 1 + +const PETSC_USE_AVX512_KERNELS = 1 + +const PETSC_USE_BACKWARD_LOOP = 1 + +const PETSC_USE_COMPLEX = 1 + +const PETSC_USE_CTABLE = 1 + +const PETSC_USE_DEBUGGER = "gdb" + +const PETSC_USE_INFO = 1 + +const PETSC_USE_LOG = 1 + +const PETSC_USE_MALLOC_COALESCED = 1 + +const PETSC_USE_REAL_SINGLE = 1 + +const PETSC_USE_SHARED_LIBRARIES = 1 + +const PETSC_USE_SINGLE_LIBRARY = 1 + +const PETSC_USE_SOCKET_VIEWER = 1 + +const PETSC_USE_VISIBILITY_C = 1 + +const PETSC_USE_VISIBILITY_CXX = 1 + +const PETSC_USING_64BIT_PTR = 1 + +const PETSC_USING_F2003 = 1 + +const PETSC_USING_F90FREEFORM = 1 + +const PETSC__BSD_SOURCE = 1 + +const PETSC__DEFAULT_SOURCE = 1 + +const PETSC__GNU_SOURCE = 1 + +const PETSC_HAVE_COMPLEX = 1 + +const PETSC_REAL = PETSC_FLOAT + +const PETSC_SCALAR = PETSC_COMPLEX + +const PETSC_FORTRANADDR = PETSC_LONG + +const PETSC_BINARY_INT_SIZE = 32 ÷ 8 + +const PETSC_BINARY_FLOAT_SIZE = 32 ÷ 8 + +const PETSC_BINARY_CHAR_SIZE = 8 ÷ 8 + +const PETSC_BINARY_SHORT_SIZE = 16 ÷ 8 + +const PETSC_BINARY_DOUBLE_SIZE = 64 ÷ 8 + +# Skipping MacroDefinition: PETSC_BINARY_SCALAR_SIZE sizeof ( PetscScalar ) + +# Skipping MacroDefinition: PETSC_STATIC_INLINE static PETSC_INLINE + +# Skipping MacroDefinition: PETSC_DLLEXPORT __attribute__ ( ( visibility ( "default" ) ) ) + +# Skipping MacroDefinition: PETSC_DLLIMPORT __attribute__ ( ( visibility ( "default" ) ) ) + +# Skipping MacroDefinition: PETSC_VISIBILITY_INTERNAL __attribute__ ( ( visibility ( "hidden" ) ) ) + +# Skipping MacroDefinition: PETSC_EXTERN extern PETSC_VISIBILITY_PUBLIC + +# Skipping MacroDefinition: PETSC_INTERN extern PETSC_VISIBILITY_INTERNAL + +const PETSC_VERSION_RELEASE = 1 + +const PETSC_VERSION_MAJOR = 3 + +const PETSC_VERSION_MINOR = 15 + +const PETSC_VERSION_SUBMINOR = 2 + +const PETSC_VERSION_PATCH = 0 + +const PETSC_RELEASE_DATE = "Mar 30, 2021" + +const PETSC_VERSION_DATE = "Jul 10, 2021" + +const PETSC_VERSION_GIT = "v3.15.2" + +const PETSC_VERSION_DATE_GIT = "2021-07-10 11:22:33 -0500" + +const PETSC_AUTHOR_INFO = " The PETSc Team\n petsc-maint@mcs.anl.gov\n https://www.mcs.anl.gov/petsc/\n" + +const MPICH_SKIP_MPICXX = 1 + +const OMPI_SKIP_MPICXX = 1 + +const MPIU_INT64 = MPI_INT64_T + +const MPIU_INT = MPIU_INT64 + +const MPIU_REAL = MPI_FLOAT + +const PETSC_MAX_UINT16 = 65535 + +const PETSC_MAX_REAL = Float32(3.4028234663852886e38) + +const PETSC_MIN_REAL = -PETSC_MAX_REAL + +const PETSC_MACHINE_EPSILON = Float32(1.1920929e-7) + +const PETSC_SQRT_MACHINE_EPSILON = Float32(0.000345266983) + +const PETSC_SMALL = Float32(1.0e-5) + +const PETSC_INFINITY = PETSC_MAX_REAL ÷ 4 + +const PETSC_NINFINITY = -PETSC_INFINITY + +const PETSC_DECIDE = -1 + +const PETSC_DETERMINE = PETSC_DECIDE + +const PETSC_DEFAULT = -2 + +const PETSC_COMM_SELF = MPI_COMM_SELF + +const MPIU_PETSCLOGDOUBLE = MPI_DOUBLE + +const MPIU_SUM = MPI_SUM + +const MPIU_MAX = MPI_MAX + +const MPIU_MIN = MPI_MIN + +const PETSC_ERR_MIN_VALUE = 54 + +const PETSC_ERR_MEM = 55 + +const PETSC_ERR_SUP = 56 + +const PETSC_ERR_SUP_SYS = 57 + +const PETSC_ERR_ORDER = 58 + +const PETSC_ERR_SIG = 59 + +const PETSC_ERR_FP = 72 + +const PETSC_ERR_COR = 74 + +const PETSC_ERR_LIB = 76 + +const PETSC_ERR_PLIB = 77 + +const PETSC_ERR_MEMC = 78 + +const PETSC_ERR_CONV_FAILED = 82 + +const PETSC_ERR_USER = 83 + +const PETSC_ERR_SYS = 88 + +const PETSC_ERR_POINTER = 70 + +const PETSC_ERR_MPI_LIB_INCOMP = 87 + +const PETSC_ERR_ARG_SIZ = 60 + +const PETSC_ERR_ARG_IDN = 61 + +const PETSC_ERR_ARG_WRONG = 62 + +const PETSC_ERR_ARG_CORRUPT = 64 + +const PETSC_ERR_ARG_OUTOFRANGE = 63 + +const PETSC_ERR_ARG_BADPTR = 68 + +const PETSC_ERR_ARG_NOTSAMETYPE = 69 + +const PETSC_ERR_ARG_NOTSAMECOMM = 80 + +const PETSC_ERR_ARG_WRONGSTATE = 73 + +const PETSC_ERR_ARG_TYPENOTSET = 89 + +const PETSC_ERR_ARG_INCOMP = 75 + +const PETSC_ERR_ARG_NULL = 85 + +const PETSC_ERR_ARG_UNKNOWN_TYPE = 86 + +const PETSC_ERR_FILE_OPEN = 65 + +const PETSC_ERR_FILE_READ = 66 + +const PETSC_ERR_FILE_WRITE = 67 + +const PETSC_ERR_FILE_UNEXPECTED = 79 + +const PETSC_ERR_MAT_LU_ZRPVT = 71 + +const PETSC_ERR_MAT_CH_ZRPVT = 81 + +const PETSC_ERR_INT_OVERFLOW = 84 + +const PETSC_ERR_FLOP_COUNT = 90 + +const PETSC_ERR_NOT_CONVERGED = 91 + +const PETSC_ERR_MISSING_FACTOR = 92 + +const PETSC_ERR_OPT_OVERWRITE = 93 + +const PETSC_ERR_WRONG_MPI_SIZE = 94 + +const PETSC_ERR_USER_INPUT = 95 + +const PETSC_ERR_GPU_RESOURCE = 96 + +const PETSC_ERR_GPU = 97 + +const PETSC_ERR_MPI = 98 + +const PETSC_ERR_MAX_VALUE = 99 + +# Skipping MacroDefinition: CHKMEMQ do { PetscErrorCode _7_ierr = PetscMallocValidate ( __LINE__ , PETSC_FUNCTION_NAME , __FILE__ ) ; CHKERRQ ( _7_ierr ) ; } while ( 0 ) + +const PETSCSTACKSIZE = 64 + +# Skipping MacroDefinition: PetscStackPopNoCheck do { } while ( 0 ) + +const PETSC_SMALLEST_CLASSID = 1211211 + +const PETSC_MAX_OPTION_NAME = 512 + +const PETSC_EVENT = 1311311 + +const PETSC_FLOPS_PER_OP = 4.0 + +const PETSC_MPI_INT_MAX = 2147483647 + +const PETSC_MPI_INT_MIN = -2147483647 + +const PETSC_BLAS_INT_MAX = 2147483647 + +const PETSC_BLAS_INT_MIN = -2147483647 + +const PETSCRAND = "rand" + +const PETSCRAND48 = "rand48" + +const PETSCSPRNG = "sprng" + +const PETSCRANDER48 = "rander48" + +const PETSCRANDOM123 = "random123" + +const PETSCCURAND = "curand" + +const PETSC_BAG_FILE_CLASSID = 1211219 + +const PETSC_DRAW_X = "x" + +const PETSC_DRAW_NULL = "null" + +const PETSC_DRAW_WIN32 = "win32" + +const PETSC_DRAW_TIKZ = "tikz" + +const PETSC_DRAW_IMAGE = "image" + +const PETSCVIEWERSOCKET = "socket" + +const PETSCVIEWERASCII = "ascii" + +const PETSCVIEWERBINARY = "binary" + +const PETSCVIEWERSTRING = "string" + +const PETSCVIEWERDRAW = "draw" + +const PETSCVIEWERVU = "vu" + +const PETSCVIEWERMATHEMATICA = "mathematica" + +const PETSCVIEWERHDF5 = "hdf5" + +const PETSCVIEWERVTK = "vtk" + +const PETSCVIEWERMATLAB = "matlab" + +const PETSCVIEWERSAWS = "saws" + +const PETSCVIEWERGLVIS = "glvis" + +const PETSCVIEWERADIOS = "adios" + +const PETSCVIEWERADIOS2 = "adios2" + +const PETSCVIEWEREXODUSII = "exodusii" + +const PETSC_DRAW_BASIC_COLORS = 33 + +const PETSC_DRAW_ROTATE = -1 + +const PETSC_DRAW_WHITE = 0 + +const PETSC_DRAW_BLACK = 1 + +const PETSC_DRAW_RED = 2 + +const PETSC_DRAW_GREEN = 3 + +const PETSC_DRAW_CYAN = 4 + +const PETSC_DRAW_BLUE = 5 + +const PETSC_DRAW_MAGENTA = 6 + +const PETSC_DRAW_AQUAMARINE = 7 + +const PETSC_DRAW_FORESTGREEN = 8 + +const PETSC_DRAW_ORANGE = 9 + +const PETSC_DRAW_VIOLET = 10 + +const PETSC_DRAW_BROWN = 11 + +const PETSC_DRAW_PINK = 12 + +const PETSC_DRAW_CORAL = 13 + +const PETSC_DRAW_GRAY = 14 + +const PETSC_DRAW_YELLOW = 15 + +const PETSC_DRAW_GOLD = 16 + +const PETSC_DRAW_LIGHTPINK = 17 + +const PETSC_DRAW_MEDIUMTURQUOISE = 18 + +const PETSC_DRAW_KHAKI = 19 + +const PETSC_DRAW_DIMGRAY = 20 + +const PETSC_DRAW_YELLOWGREEN = 21 + +const PETSC_DRAW_SKYBLUE = 22 + +const PETSC_DRAW_DARKGREEN = 23 + +const PETSC_DRAW_NAVYBLUE = 24 + +const PETSC_DRAW_SANDYBROWN = 25 + +const PETSC_DRAW_CADETBLUE = 26 + +const PETSC_DRAW_POWDERBLUE = 27 + +const PETSC_DRAW_DEEPPINK = 28 + +const PETSC_DRAW_THISTLE = 29 + +const PETSC_DRAW_LIMEGREEN = 30 + +const PETSC_DRAW_LAVENDERBLUSH = 31 + +const PETSC_DRAW_PLUM = 32 + +const PETSC_DRAW_MAXCOLOR = 256 + +const PETSC_DRAW_FULL_SIZE = -3 + +const PETSC_DRAW_HALF_SIZE = -4 + +const PETSC_DRAW_THIRD_SIZE = -5 + +const PETSC_DRAW_QUARTER_SIZE = -6 + +const IS_FILE_CLASSID = 1211218 + +const ISGENERAL = "general" + +const ISSTRIDE = "stride" + +const ISBLOCK = "block" + +const ISLOCALTOGLOBALMAPPINGBASIC = "basic" + +const ISLOCALTOGLOBALMAPPINGHASH = "hash" + +const MPIU_COLORING_VALUE = PETSC_MPIU_IS_COLORING_VALUE_TYPE + +const VECSEQ = "seq" + +const VECMPI = "mpi" + +const VECSTANDARD = "standard" + +const VECSHARED = "shared" + +const VECSEQVIENNACL = "seqviennacl" + +const VECMPIVIENNACL = "mpiviennacl" + +const VECVIENNACL = "viennacl" + +const VECSEQCUDA = "seqcuda" + +const VECMPICUDA = "mpicuda" + +const VECCUDA = "cuda" + +const VECSEQHIP = "seqhip" + +const VECMPIHIP = "mpihip" + +const VECHIP = "hip" + +const VECNEST = "nest" + +const VECSEQKOKKOS = "seqkokkos" + +const VECMPIKOKKOS = "mpikokkos" + +const VECKOKKOS = "kokkos" + +const REAL_FILE_CLASSID = 1211213 + +const VEC_FILE_CLASSID = 1211214 + +const NORM_MAX = NORM_INFINITY + +const VECTAGGERABSOLUTE = "absolute" + +const VECTAGGERRELATIVE = "relative" + +const VECTAGGERCDF = "cdf" + +const VECTAGGEROR = "or" + +const VECTAGGERAND = "and" + +const PETSCSFBASIC = "basic" + +const PETSCSFNEIGHBOR = "neighbor" + +const PETSCSFALLGATHERV = "allgatherv" + +const PETSCSFALLGATHER = "allgather" + +const PETSCSFGATHERV = "gatherv" + +const PETSCSFGATHER = "gather" + +const PETSCSFALLTOALL = "alltoall" + +const PETSCSFWINDOW = "window" + +const MATSAME = "same" + +const MATMAIJ = "maij" + +const MATSEQMAIJ = "seqmaij" + +const MATMPIMAIJ = "mpimaij" + +const MATKAIJ = "kaij" + +const MATSEQKAIJ = "seqkaij" + +const MATMPIKAIJ = "mpikaij" + +const MATIS = "is" + +const MATAIJ = "aij" + +const MATSEQAIJ = "seqaij" + +const MATMPIAIJ = "mpiaij" + +const MATAIJCRL = "aijcrl" + +const MATSEQAIJCRL = "seqaijcrl" + +const MATMPIAIJCRL = "mpiaijcrl" + +const MATAIJCUSPARSE = "aijcusparse" + +const MATSEQAIJCUSPARSE = "seqaijcusparse" + +const MATMPIAIJCUSPARSE = "mpiaijcusparse" + +const MATAIJKOKKOS = "aijkokkos" + +const MATSEQAIJKOKKOS = "seqaijkokkos" + +const MATMPIAIJKOKKOS = "mpiaijkokkos" + +const MATAIJVIENNACL = "aijviennacl" + +const MATSEQAIJVIENNACL = "seqaijviennacl" + +const MATMPIAIJVIENNACL = "mpiaijviennacl" + +const MATAIJPERM = "aijperm" + +const MATSEQAIJPERM = "seqaijperm" + +const MATMPIAIJPERM = "mpiaijperm" + +const MATAIJSELL = "aijsell" + +const MATSEQAIJSELL = "seqaijsell" + +const MATMPIAIJSELL = "mpiaijsell" + +const MATAIJMKL = "aijmkl" + +const MATSEQAIJMKL = "seqaijmkl" + +const MATMPIAIJMKL = "mpiaijmkl" + +const MATBAIJMKL = "baijmkl" + +const MATSEQBAIJMKL = "seqbaijmkl" + +const MATMPIBAIJMKL = "mpibaijmkl" + +const MATSHELL = "shell" + +const MATDENSE = "dense" + +const MATDENSECUDA = "densecuda" + +const MATSEQDENSE = "seqdense" + +const MATSEQDENSECUDA = "seqdensecuda" + +const MATMPIDENSE = "mpidense" + +const MATMPIDENSECUDA = "mpidensecuda" + +const MATELEMENTAL = "elemental" + +const MATSCALAPACK = "scalapack" + +const MATBAIJ = "baij" + +const MATSEQBAIJ = "seqbaij" + +const MATMPIBAIJ = "mpibaij" + +const MATMPIADJ = "mpiadj" + +const MATSBAIJ = "sbaij" + +const MATSEQSBAIJ = "seqsbaij" + +const MATMPISBAIJ = "mpisbaij" + +const MATMFFD = "mffd" + +const MATNORMAL = "normal" + +const MATNORMALHERMITIAN = "normalh" + +const MATLRC = "lrc" + +const MATSCATTER = "scatter" + +const MATBLOCKMAT = "blockmat" + +const MATCOMPOSITE = "composite" + +const MATFFT = "fft" + +const MATFFTW = "fftw" + +const MATSEQCUFFT = "seqcufft" + +const MATTRANSPOSEMAT = "transpose" + +const MATSCHURCOMPLEMENT = "schurcomplement" + +const MATPYTHON = "python" + +const MATHYPRE = "hypre" + +const MATHYPRESTRUCT = "hyprestruct" + +const MATHYPRESSTRUCT = "hypresstruct" + +const MATSUBMATRIX = "submatrix" + +const MATLOCALREF = "localref" + +const MATNEST = "nest" + +const MATPREALLOCATOR = "preallocator" + +const MATSELL = "sell" + +const MATSEQSELL = "seqsell" + +const MATMPISELL = "mpisell" + +const MATDUMMY = "dummy" + +const MATLMVM = "lmvm" + +const MATLMVMDFP = "lmvmdfp" + +const MATLMVMBFGS = "lmvmbfgs" + +const MATLMVMSR1 = "lmvmsr1" + +const MATLMVMBROYDEN = "lmvmbroyden" + +const MATLMVMBADBROYDEN = "lmvmbadbroyden" + +const MATLMVMSYMBROYDEN = "lmvmsymbroyden" + +const MATLMVMSYMBADBROYDEN = "lmvmsymbadbroyden" + +const MATLMVMDIAGBROYDEN = "lmvmdiagbroyden" + +const MATCONSTANTDIAGONAL = "constantdiagonal" + +const MATHARA = "hara" + +const MATSOLVERSUPERLU = "superlu" + +const MATSOLVERSUPERLU_DIST = "superlu_dist" + +const MATSOLVERSTRUMPACK = "strumpack" + +const MATSOLVERUMFPACK = "umfpack" + +const MATSOLVERCHOLMOD = "cholmod" + +const MATSOLVERKLU = "klu" + +const MATSOLVERSPARSEELEMENTAL = "sparseelemental" + +const MATSOLVERELEMENTAL = "elemental" + +const MATSOLVERSCALAPACK = "scalapack" + +const MATSOLVERESSL = "essl" + +const MATSOLVERLUSOL = "lusol" + +const MATSOLVERMUMPS = "mumps" + +const MATSOLVERMKL_PARDISO = "mkl_pardiso" + +const MATSOLVERMKL_CPARDISO = "mkl_cpardiso" + +const MATSOLVERPASTIX = "pastix" + +const MATSOLVERMATLAB = "matlab" + +const MATSOLVERPETSC = "petsc" + +const MATSOLVERBAS = "bas" + +const MATSOLVERCUSPARSE = "cusparse" + +const MATSOLVERCUSPARSEBAND = "cusparseband" + +const MATSOLVERCUDA = "cuda" + +const MATSOLVERKOKKOS = "kokkos" + +const MATSOLVERKOKKOSDEVICE = "kokkosdevice" + +const MATPRODUCTALGORITHM_DEFAULT = "default" + +const MAT_FILE_CLASSID = 1211216 + +const MAT_SKIP_ALLOCATION = -4 + +const MATORDERINGNATURAL = "natural" + +const MATORDERINGND = "nd" + +const MATORDERING1WD = "1wd" + +const MATORDERINGRCM = "rcm" + +const MATORDERINGQMD = "qmd" + +const MATORDERINGROWLENGTH = "rowlength" + +const MATORDERINGWBM = "wbm" + +const MATORDERINGSPECTRAL = "spectral" + +const MATORDERINGAMD = "amd" + +const MATORDERINGNATURAL_OR_ND = "natural_or_nd" + +const MATORDERINGEXTERNAL = "external" + +const MATCOLORINGJP = "jp" + +const MATCOLORINGPOWER = "power" + +const MATCOLORINGNATURAL = "natural" + +const MATCOLORINGSL = "sl" + +const MATCOLORINGLF = "lf" + +const MATCOLORINGID = "id" + +const MATCOLORINGGREEDY = "greedy" + +const MATPARTITIONINGCURRENT = "current" + +const MATPARTITIONINGAVERAGE = "average" + +const MATPARTITIONINGSQUARE = "square" + +const MATPARTITIONINGPARMETIS = "parmetis" + +const MATPARTITIONINGCHACO = "chaco" + +const MATPARTITIONINGPARTY = "party" + +const MATPARTITIONINGPTSCOTCH = "ptscotch" + +const MATPARTITIONINGHIERARCH = "hierarch" + +const MP_PARTY_OPT = "opt" + +const MP_PARTY_LIN = "lin" + +const MP_PARTY_SCA = "sca" + +const MP_PARTY_RAN = "ran" + +const MP_PARTY_GBF = "gbf" + +const MP_PARTY_GCF = "gcf" + +const MP_PARTY_BUB = "bub" + +const MP_PARTY_DEF = "def" + +const MP_PARTY_HELPFUL_SETS = "hs" + +const MP_PARTY_KERNIGHAN_LIN = "kl" + +const MP_PARTY_NONE = "no" + +const MATRIX_BINARY_FORMAT_DENSE = -1 + +const MATMFFD_DS = "ds" + +const MATMFFD_WP = "wp" + +const PETSCSECTIONSYMLABEL = "label" + +const DMLOCATEPOINT_POINT_NOT_FOUND = -367 + +const DMDA = "da" + +const DMCOMPOSITE = "composite" + +const DMSLICED = "sliced" + +const DMSHELL = "shell" + +const DMPLEX = "plex" + +const DMREDUNDANT = "redundant" + +const DMPATCH = "patch" + +const DMMOAB = "moab" + +const DMNETWORK = "network" + +const DMFOREST = "forest" + +const DMP4EST = "p4est" + +const DMP8EST = "p8est" + +const DMSWARM = "swarm" + +const DMPRODUCT = "product" + +const DMSTAG = "stag" + +const DM_FILE_CLASSID = 1211221 + +const PFCONSTANT = "constant" + +const PFMAT = "mat" + +const PFSTRING = "string" + +const PFQUICK = "quick" + +const PFIDENTITY = "identity" + +const PFMATLAB = "matlab" + +const AOBASIC = "basic" + +const AOADVANCED = "advanced" + +const AOMAPPING = "mapping" + +const AOMEMORYSCALABLE = "memoryscalable" + +const PETSC_FACTORIAL_MAX = 20 + +const PETSC_BINOMIAL_MAX = 61 + +const PETSCSPACEPOLYNOMIAL = "poly" + +const PETSCSPACETENSOR = "tensor" + +const PETSCSPACESUM = "sum" + +const PETSCSPACEPOINT = "point" + +const PETSCSPACESUBSPACE = "subspace" + +const PETSCDUALSPACELAGRANGE = "lagrange" + +const PETSCDUALSPACESIMPLE = "simple" + +const PETSCDUALSPACEREFINED = "refined" + +const PETSCDUALSPACEBDM = "bdm" + +const PETSCFEBASIC = "basic" + +const PETSCFEOPENCL = "opencl" + +const PETSCFECOMPOSITE = "composite" + +const MATSEQUSFFT = "sequsfft" + +const PETSCPARTITIONERPARMETIS = "parmetis" + +const PETSCPARTITIONERPTSCOTCH = "ptscotch" + +const PETSCPARTITIONERCHACO = "chaco" + +const PETSCPARTITIONERSIMPLE = "simple" + +const PETSCPARTITIONERSHELL = "shell" + +const PETSCPARTITIONERGATHER = "gather" + +const PETSCPARTITIONERMATPARTITIONING = "matpartitioning" + +const PETSCLIMITERSIN = "sin" + +const PETSCLIMITERZERO = "zero" + +const PETSCLIMITERNONE = "none" + +const PETSCLIMITERMINMOD = "minmod" + +const PETSCLIMITERVANLEER = "vanleer" + +const PETSCLIMITERVANALBADA = "vanalbada" + +const PETSCLIMITERSUPERBEE = "superbee" + +const PETSCLIMITERMC = "mc" + +const PETSCFVUPWIND = "upwind" + +const PETSCFVLEASTSQUARES = "leastsquares" + +const DMFIELDDA = "da" + +const DMFIELDDS = "ds" + +const DMFIELDSHELL = "shell" + +const PETSCDSBASIC = "basic" + +const CHARACTERISTICDA = "da" + +const PCNONE = "none" + +const PCJACOBI = "jacobi" + +const PCSOR = "sor" + +const PCLU = "lu" + +const PCSHELL = "shell" + +const PCBJACOBI = "bjacobi" + +const PCMG = "mg" + +const PCEISENSTAT = "eisenstat" + +const PCILU = "ilu" + +const PCICC = "icc" + +const PCASM = "asm" + +const PCGASM = "gasm" + +const PCKSP = "ksp" + +const PCCOMPOSITE = "composite" + +const PCREDUNDANT = "redundant" + +const PCSPAI = "spai" + +const PCNN = "nn" + +const PCCHOLESKY = "cholesky" + +const PCPBJACOBI = "pbjacobi" + +const PCVPBJACOBI = "vpbjacobi" + +const PCMAT = "mat" + +const PCHYPRE = "hypre" + +const PCPARMS = "parms" + +const PCFIELDSPLIT = "fieldsplit" + +const PCTFS = "tfs" + +const PCML = "ml" + +const PCGALERKIN = "galerkin" + +const PCEXOTIC = "exotic" + +const PCCP = "cp" + +const PCBFBT = "bfbt" + +const PCLSC = "lsc" + +const PCPYTHON = "python" + +const PCPFMG = "pfmg" + +const PCSYSPFMG = "syspfmg" + +const PCREDISTRIBUTE = "redistribute" + +const PCSVD = "svd" + +const PCGAMG = "gamg" + +const PCCHOWILUVIENNACL = "chowiluviennacl" + +const PCROWSCALINGVIENNACL = "rowscalingviennacl" + +const PCSAVIENNACL = "saviennacl" + +const PCBDDC = "bddc" + +const PCKACZMARZ = "kaczmarz" + +const PCTELESCOPE = "telescope" + +const PCPATCH = "patch" + +const PCLMVM = "lmvm" + +const PCHMG = "hmg" + +const PCDEFLATION = "deflation" + +const PCHPDDM = "hpddm" + +const PCHARA = "hara" + +const PCGAMGAGG = "agg" + +const PCGAMGGEO = "geo" + +const PCGAMGCLASSICAL = "classical" + +const PCGAMGCLASSICALDIRECT = "direct" + +const PCGAMGCLASSICALSTANDARD = "standard" + +const PC_FILE_CLASSID = 1211222 + +const KSPRICHARDSON = "richardson" + +const KSPCHEBYSHEV = "chebyshev" + +const KSPCG = "cg" + +const KSPGROPPCG = "groppcg" + +const KSPPIPECG = "pipecg" + +const KSPPIPECGRR = "pipecgrr" + +const KSPPIPELCG = "pipelcg" + +const KSPPIPEPRCG = "pipeprcg" + +const KSPPIPECG2 = "pipecg2" + +const KSPCGNE = "cgne" + +const KSPNASH = "nash" + +const KSPSTCG = "stcg" + +const KSPGLTR = "gltr" + +const KSPFCG = "fcg" + +const KSPPIPEFCG = "pipefcg" + +const KSPGMRES = "gmres" + +const KSPPIPEFGMRES = "pipefgmres" + +const KSPFGMRES = "fgmres" + +const KSPLGMRES = "lgmres" + +const KSPDGMRES = "dgmres" + +const KSPPGMRES = "pgmres" + +const KSPTCQMR = "tcqmr" + +const KSPBCGS = "bcgs" + +const KSPIBCGS = "ibcgs" + +const KSPFBCGS = "fbcgs" + +const KSPFBCGSR = "fbcgsr" + +const KSPBCGSL = "bcgsl" + +const KSPPIPEBCGS = "pipebcgs" + +const KSPCGS = "cgs" + +const KSPTFQMR = "tfqmr" + +const KSPCR = "cr" + +const KSPPIPECR = "pipecr" + +const KSPLSQR = "lsqr" + +const KSPPREONLY = "preonly" + +const KSPQCG = "qcg" + +const KSPBICG = "bicg" + +const KSPMINRES = "minres" + +const KSPSYMMLQ = "symmlq" + +const KSPLCD = "lcd" + +const KSPPYTHON = "python" + +const KSPGCR = "gcr" + +const KSPPIPEGCR = "pipegcr" + +const KSPTSIRM = "tsirm" + +const KSPCGLS = "cgls" + +const KSPFETIDP = "fetidp" + +const KSPHPDDM = "hpddm" + +const KSP_FILE_CLASSID = 1211223 + +const KSPGUESSFISCHER = "fischer" + +const KSPGUESSPOD = "pod" + +const SNESNEWTONLS = "newtonls" + +const SNESNEWTONTR = "newtontr" + +const SNESPYTHON = "python" + +const SNESNRICHARDSON = "nrichardson" + +const SNESKSPONLY = "ksponly" + +const SNESKSPTRANSPOSEONLY = "ksptransposeonly" + +const SNESVINEWTONRSLS = "vinewtonrsls" + +const SNESVINEWTONSSLS = "vinewtonssls" + +const SNESNGMRES = "ngmres" + +const SNESQN = "qn" + +const SNESSHELL = "shell" + +const SNESNGS = "ngs" + +const SNESNCG = "ncg" + +const SNESFAS = "fas" + +const SNESMS = "ms" + +const SNESNASM = "nasm" + +const SNESANDERSON = "anderson" + +const SNESASPIN = "aspin" + +const SNESCOMPOSITE = "composite" + +const SNESPATCH = "patch" + +const SNES_FILE_CLASSID = 1211224 + +const SNESLINESEARCHBT = "bt" + +const SNESLINESEARCHNLEQERR = "nleqerr" + +const SNESLINESEARCHBASIC = "basic" + +const SNESLINESEARCHL2 = "l2" + +const SNESLINESEARCHCP = "cp" + +const SNESLINESEARCHSHELL = "shell" + +const SNESLINESEARCHNCGLINEAR = "ncglinear" + +const SNES_LINESEARCH_ORDER_LINEAR = 1 + +const SNES_LINESEARCH_ORDER_QUADRATIC = 2 + +const SNES_LINESEARCH_ORDER_CUBIC = 3 + +const SNESMSM62 = "m62" + +const SNESMSEULER = "euler" + +const SNESMSJAMESON83 = "jameson83" + +const SNESMSVLTP11 = "vltp11" + +const SNESMSVLTP21 = "vltp21" + +const SNESMSVLTP31 = "vltp31" + +const SNESMSVLTP41 = "vltp41" + +const SNESMSVLTP51 = "vltp51" + +const SNESMSVLTP61 = "vltp61" + +const TSEULER = "euler" + +const TSBEULER = "beuler" + +const TSBASICSYMPLECTIC = "basicsymplectic" + +const TSPSEUDO = "pseudo" + +const TSCN = "cn" + +const TSSUNDIALS = "sundials" + +const TSRK = "rk" + +const TSPYTHON = "python" + +const TSTHETA = "theta" + +const TSALPHA = "alpha" + +const TSALPHA2 = "alpha2" + +const TSGLLE = "glle" + +const TSGLEE = "glee" + +const TSSSP = "ssp" + +const TSARKIMEX = "arkimex" + +const TSROSW = "rosw" + +const TSEIMEX = "eimex" + +const TSMIMEX = "mimex" + +const TSBDF = "bdf" + +const TSRADAU5 = "radau5" + +const TSMPRK = "mprk" + +const TSDISCGRAD = "discgrad" + +const TSTRAJECTORYBASIC = "basic" + +const TSTRAJECTORYSINGLEFILE = "singlefile" + +const TSTRAJECTORYMEMORY = "memory" + +const TSTRAJECTORYVISUALIZATION = "visualization" + +const TS_FILE_CLASSID = 1211225 + +const TSSSPRKS2 = "rks2" + +const TSSSPRKS3 = "rks3" + +const TSSSPRK104 = "rk104" + +const TSADAPTNONE = "none" + +const TSADAPTBASIC = "basic" + +const TSADAPTDSP = "dsp" + +const TSADAPTCFL = "cfl" + +const TSADAPTGLEE = "glee" + +const TSADAPTHISTORY = "history" + +const TSGLLEADAPT_NONE = "none" + +const TSGLLEADAPT_SIZE = "size" + +const TSGLLEADAPT_BOTH = "both" + +const TSGLLEACCEPT_ALWAYS = "always" + +const TSGLLE_IRKS = "irks" + +const TSRK1FE = "1fe" + +const TSRK2A = "2a" + +const TSRK3 = "3" + +const TSRK3BS = "3bs" + +const TSRK4 = "4" + +const TSRK5F = "5f" + +const TSRK5DP = "5dp" + +const TSRK5BS = "5bs" + +const TSRK6VR = "6vr" + +const TSRK7VR = "7vr" + +const TSRK8VR = "8vr" + +const TSMPRK2A22 = "2a22" + +const TSMPRK2A23 = "2a23" + +const TSMPRK2A32 = "2a32" + +const TSMPRK2A33 = "2a33" + +const TSMPRKP2 = "p2" + +const TSMPRKP3 = "p3" + +const TSGLEEi1 = "BE1" + +const TSGLEE23 = "23" + +const TSGLEE24 = "24" + +const TSGLEE25I = "25i" + +const TSGLEE35 = "35" + +const TSGLEEEXRK2A = "exrk2a" + +const TSGLEERK32G1 = "rk32g1" + +const TSGLEERK285EX = "rk285ex" + +const TSARKIMEX1BEE = "1bee" + +const TSARKIMEXA2 = "a2" + +const TSARKIMEXL2 = "l2" + +const TSARKIMEXARS122 = "ars122" + +const TSARKIMEX2C = "2c" + +const TSARKIMEX2D = "2d" + +const TSARKIMEX2E = "2e" + +const TSARKIMEXPRSSP2 = "prssp2" + +const TSARKIMEX3 = "3" + +const TSARKIMEXBPR3 = "bpr3" + +const TSARKIMEXARS443 = "ars443" + +const TSARKIMEX4 = "4" + +const TSARKIMEX5 = "5" + +const TSROSW2M = "2m" + +const TSROSW2P = "2p" + +const TSROSWRA3PW = "ra3pw" + +const TSROSWRA34PW2 = "ra34pw2" + +const TSROSWRODAS3 = "rodas3" + +const TSROSWSANDU3 = "sandu3" + +const TSROSWASSP3P3S1C = "assp3p3s1c" + +const TSROSWLASSP3P4S2C = "lassp3p4s2c" + +const TSROSWLLSSP3P4S2C = "llssp3p4s2c" + +const TSROSWARK3 = "ark3" + +const TSROSWTHETA1 = "theta1" + +const TSROSWTHETA2 = "theta2" + +const TSROSWGRK4T = "grk4t" + +const TSROSWSHAMP4 = "shamp4" + +const TSROSWVELDD4 = "veldd4" + +const TSROSW4L = "4l" + +const TSBASICSYMPLECTICSIEULER = "1" + +const TSBASICSYMPLECTICVELVERLET = "2" + +const TSBASICSYMPLECTIC3 = "3" + +const TSBASICSYMPLECTIC4 = "4" + +const TAOLMVM = "lmvm" + +const TAONLS = "nls" + +const TAONTR = "ntr" + +const TAONTL = "ntl" + +const TAOCG = "cg" + +const TAOTRON = "tron" + +const TAOOWLQN = "owlqn" + +const TAOBMRM = "bmrm" + +const TAOBLMVM = "blmvm" + +const TAOBQNLS = "bqnls" + +const TAOBNCG = "bncg" + +const TAOBNLS = "bnls" + +const TAOBNTR = "bntr" + +const TAOBNTL = "bntl" + +const TAOBQNKLS = "bqnkls" + +const TAOBQNKTR = "bqnktr" + +const TAOBQNKTL = "bqnktl" + +const TAOBQPIP = "bqpip" + +const TAOGPCG = "gpcg" + +const TAONM = "nm" + +const TAOPOUNDERS = "pounders" + +const TAOBRGN = "brgn" + +const TAOLCL = "lcl" + +const TAOSSILS = "ssils" + +const TAOSSFLS = "ssfls" + +const TAOASILS = "asils" + +const TAOASFLS = "asfls" + +const TAOIPM = "ipm" + +const TAOPDIPM = "pdipm" + +const TAOSHELL = "shell" + +const TAOADMM = "admm" + +const TAOALMM = "almm" + +const TAOLINESEARCHUNIT = "unit" + +const TAOLINESEARCHMT = "more-thuente" + +const TAOLINESEARCHGPCG = "gpcg" + +const TAOLINESEARCHARMIJO = "armijo" + +const TAOLINESEARCHOWARMIJO = "owarmijo" + +const TAOLINESEARCHIPM = "ipm" diff --git a/src/LibPETSc.jl b/src/LibPETSc.jl new file mode 100644 index 00000000..0ade676b --- /dev/null +++ b/src/LibPETSc.jl @@ -0,0 +1,40 @@ +module LibPETSc + +using Libdl +using MPI +MPI.Initialized() || MPI.Init() + +export PetscLibType, + petsclibs, + PetscBool, + PETSC_TRUE, + PETSC_FALSE, + UnionPetscLibType, + getlib, + MatAssemblyType, + MAT_FLUSH_ASSEMBLY, + MAT_FINAL_ASSEMBLY, + InsertMode, + NOT_SET_VALUES, + INSERT_VALUES, + ADD_VALUES, + MAX_VALUES, + MIN_VALUES, + INSERT_ALL_VALUES, + ADD_ALL_VALUES, + INSERT_BC_VALUES, + ADD_BC_VALUES, + NormType, + NORM_1, + NORM_2, + NORM_FROBENIUS, + NORM_INFINITY, + NORM_1_AND_2 + +include("LibPETSc_const.jl") +include("LibPETSc_startup.jl") +include("LibPETSc_lib.jl") + +include(petsc_library_file) + +end # module diff --git a/src/LibPETSc_const.jl b/src/LibPETSc_const.jl new file mode 100644 index 00000000..b3e16408 --- /dev/null +++ b/src/LibPETSc_const.jl @@ -0,0 +1,38 @@ +# define common PETSc constants +# this excludes configurable constants (e.g. PetscScalar) which are set in lib.jl + +const PetscErrorCode = Cint + +struct PetscError <: Exception + code::PetscErrorCode +end + +macro chk(expr) + :((errcode = $(esc(expr))) == 0 || throw(PetscError(errcode))) +end + +@enum PetscBool::UInt32 begin + PETSC_FALSE = 0 + PETSC_TRUE = 1 +end + +@enum PetscDataType::UInt32 begin + PETSC_DATATYPE_UNKNOWN = 0 + PETSC_DOUBLE = 1 + PETSC_COMPLEX = 2 + PETSC_LONG = 3 + PETSC_SHORT = 4 + PETSC_FLOAT = 5 + PETSC_CHAR = 6 + PETSC_BIT_LOGICAL = 7 + PETSC_ENUM = 8 + PETSC_BOOL = 9 + PETSC___FLOAT128 = 10 + PETSC_OBJECT = 11 + PETSC_FUNCTION = 12 + PETSC_STRING = 13 + PETSC___FP16 = 14 + PETSC_STRUCT = 15 + PETSC_INT = 16 + PETSC_INT64 = 17 +end diff --git a/src/lib.jl b/src/LibPETSc_lib.jl similarity index 79% rename from src/lib.jl rename to src/LibPETSc_lib.jl index 4f8e9964..4a95e7d8 100644 --- a/src/lib.jl +++ b/src/LibPETSc_lib.jl @@ -1,4 +1,3 @@ -using Libdl """ PetscLibType{PetscScalar, PetscInt}(petsc_library) @@ -14,6 +13,19 @@ function PetscLibType{ST, IT}(petsc_library) where {ST, IT} LT = typeof(petsc_library) return PetscLibType{ST, IT, LT}(petsc_library) end +const UnionPetscLibType = Union{PetscLibType, Type{PetscLibType}} + +function Base.getproperty(petsclib::PetscLibType, name::Symbol) + if name == :PetscScalar + return scalartype(petsclib) + elseif name == :PetscReal + return realtype(petsclib) + elseif name == :PetscInt + return inttype(petsclib) + else + return getfield(petsclib, name) + end +end """ scalartype(petsclib::PetscLibType) @@ -96,33 +108,13 @@ macro for_petsc(expr) PetscScalar = scalartype(petsclib) PetscReal = realtype(petsclib) PetscInt = inttype(petsclib) + PetscComplex = complex(PetscReal) @eval esc($expr) end end end -# TODO: Remove this macro once we have switch over to @for_petsc macro -macro for_libpetsc(expr) - quote - for petsclib in petsclibs - # String for the library - libpetsc = petsclib.petsc_library - - # types we dispatch on - PetscLib = typeof(petsclib) - UnionPetscLib = Union{PetscLib, Type{PetscLib}} - - PetscScalar = scalartype(petsclib) - PetscReal = realtype(petsclib) - PetscInt = inttype(petsclib) - - @eval esc($expr) - end - end +@for_petsc begin + getlib(::Type{$PetscLib}) = $petsclib end - -# TODO: These should be removed! -const scalar_types = map(x -> scalartype(x), petsclibs) -@assert length(scalar_types) == length(unique(scalar_types)) -@for_libpetsc inttype(::Type{$PetscScalar}) = $PetscInt diff --git a/src/startup.jl b/src/LibPETSc_startup.jl similarity index 69% rename from src/startup.jl rename to src/LibPETSc_startup.jl index 00898768..9961e4ad 100644 --- a/src/startup.jl +++ b/src/LibPETSc_startup.jl @@ -13,21 +13,20 @@ end const libs = @static if !haskey(ENV, "JULIA_PETSC_LIBRARY") using PETSc_jll ( - #(PETSc_jll.libpetsc,), - (PETSc_jll.libpetsc_Float64_Real_Int64,), - (PETSc_jll.libpetsc_Float32_Real_Int64,), - (PETSc_jll.libpetsc_Float64_Complex_Int64,), - (PETSc_jll.libpetsc_Float32_Complex_Int64,), - # XXX: The following cannot be used until all types are based on PetscLib - # instead of PetscScalar - # (PETSc_jll.libpetsc_Float64_Real_Int32,), - # (PETSc_jll.libpetsc_Float32_Real_Int32,), - # (PETSc_jll.libpetsc_Float64_Complex_Int32,), - # (PETSc_jll.libpetsc_Float32_Complex_Int32,), + (PETSc_jll.libpetsc_Float64_Real_Int64,), + (PETSc_jll.libpetsc_Float32_Real_Int64,), + (PETSc_jll.libpetsc_Float64_Complex_Int64,), + (PETSc_jll.libpetsc_Float32_Complex_Int64,), + (PETSc_jll.libpetsc_Float64_Real_Int32,), + (PETSc_jll.libpetsc_Float32_Real_Int32,), + (PETSc_jll.libpetsc_Float64_Complex_Int32,), + (PETSc_jll.libpetsc_Float32_Complex_Int32,), ) else getlibs() end +const petsc_library_file = + get(ENV, "JULIA_PETSC_LIBRARY_PATH", "../lib/petsc_library.jl") function DataTypeFromString(libhdl::Ptr{Cvoid}, name::AbstractString) PetscDataTypeFromString_ptr = dlsym(libhdl, :PetscDataTypeFromString) dtype_ref = Ref{PetscDataType}() @@ -55,4 +54,3 @@ function PetscDataTypeGetSize(libhdl::Ptr{Cvoid}, dtype::PetscDataType) ) return datasize_ref[] end - diff --git a/src/PETSc.jl b/src/PETSc.jl index d59392db..711ce43c 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -1,10 +1,11 @@ module PETSc - -using MPI, LinearAlgebra, SparseArrays - +using MPI MPI.Initialized() || MPI.Init() -using Libdl +include("LibPETSc.jl") +using .LibPETSc + +using MPI, LinearAlgebra, SparseArrays function _petsc_link(fname) """ @@ -18,22 +19,19 @@ function _doc_external(fname) """ end -include("const.jl") -include("startup.jl") -include("lib.jl") include("init.jl") -include("ref.jl") -include("viewer.jl") -include("options.jl") -include("vec.jl") -include("mat.jl") -include("matshell.jl") -include("dm.jl") -include("dmda.jl") -include("dmstag.jl") -include("ksp.jl") -include("pc.jl") -include("snes.jl") -include("sys.jl") +# include("ref.jl") +# include("viewer.jl") +# include("options.jl") +# include("vec.jl") +# include("mat.jl") +# include("matshell.jl") +# include("dm.jl") +# include("dmda.jl") +# include("dmstag.jl") +# include("ksp.jl") +# include("pc.jl") +# include("snes.jl") +# include("sys.jl") end diff --git a/src/init.jl b/src/init.jl index 508743c7..b1415177 100644 --- a/src/init.jl +++ b/src/init.jl @@ -6,16 +6,10 @@ Check if `petsclib` is initialized # External Links $(_doc_external("Sys/PetscInitialized")) """ -function Initialized end -@for_petsc function initialized(::$UnionPetscLib) - r_flag = Ref{PetscBool}() - @chk ccall( - (:PetscInitialized, $petsc_library), - PetscErrorCode, - (Ptr{PetscBool},), - r_flag, - ) - return r_flag[] == PETSC_TRUE +function initialized(petsclib) + r_flag = Ref{LibPETSc.PetscBool}() + LibPETSc.PetscInitialized(petsclib, r_flag) + return r_flag[] == LibPETSc.PETSC_TRUE end """ @@ -34,26 +28,20 @@ Additionally: # External Links $(_doc_external("Sys/PetscInitializeNoArguments")) """ -function Initialize end - function initialize() map(initialize, petsclibs) return nothing end -@for_petsc function initialize(::$UnionPetscLib) - if !initialized($petsclib) +function initialize(petsclib) + if !initialized(petsclib) MPI.Initialized() || MPI.Init() - @chk ccall( - (:PetscInitializeNoArguments, $petsc_library), - PetscErrorCode, - (), - ) + LibPETSc.PetscInitializeNoArguments(petsclib) # disable signal handler - @chk ccall((:PetscPopSignalHandler, $petsc_library), PetscErrorCode, ()) + LibPETSc.PetscPopSignalHandler(petsclib) - atexit(() -> finalize($petsclib)) + atexit(() -> finalize(petsclib)) end return nothing end @@ -67,16 +55,14 @@ will be finalized. # External Links $(_doc_external("Sys/PetscFinalize")) """ -function finalize end - function finalize() map(finalize, petsclibs) return nothing end -@for_petsc function finalize(::$UnionPetscLib) - if !finalized($petsclib) - @chk ccall((:PetscFinalize, $petsc_library), PetscErrorCode, ()) +function finalize(petsclib) + if !finalized(petsclib) + LibPETSc.PetscFinalize(petsclib) end return nothing end @@ -89,14 +75,8 @@ Check if `petsclib` is finalized # External Links $(_doc_external("Sys/PetscFinalized")) """ -function finalized end -@for_petsc function finalized(::$UnionPetscLib) - r_flag = Ref{PetscBool}() - @chk ccall( - (:PetscFinalized, $petsc_library), - PetscErrorCode, - (Ptr{PetscBool},), - r_flag, - ) - return r_flag[] == PETSC_TRUE +function finalized(petsclib) + r_flag = Ref{LibPETSc.PetscBool}() + LibPETSc.PetscFinalized(petsclib, r_flag) + return r_flag[] == LibPETSc.PETSC_TRUE end diff --git a/test/init.jl b/test/init.jl new file mode 100644 index 00000000..e527714d --- /dev/null +++ b/test/init.jl @@ -0,0 +1,32 @@ +using Test +using PETSc + +@testset "init" begin + for petsclib in PETSc.petsclibs + # The first time through finalize should be false since we have never + # initialized petsclib yet... + initial_finalized_value = false + + # since we haven't called anything these should be false! + @test !(PETSc.initialized(petsclib)) + @test PETSc.finalized(petsclib) == initial_finalized_value + + # The second time through time through finalize should be true since + # we have initialized petsclib yet... + initial_finalized_value = true + + # initialize PETSc + PETSc.initialize(petsclib) + + # Check values again + @test PETSc.initialized(petsclib) + @test !(PETSc.finalized(petsclib)) + + PETSc.finalize(petsclib) + + # Check values again + @test !(PETSc.initialized(petsclib)) + @test PETSc.finalized(petsclib) + end +end + diff --git a/test/runtests.jl b/test/runtests.jl index 1bc753d2..c7398752 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,31 +1,4 @@ -using Test -using MPI - -# Do the MPI tests first so we do not have mpi running inside MPI -# XXX: Currently not working on windows, not sure why -if !Sys.iswindows() - @testset "mpi tests" begin - @test mpiexec() do mpi_cmd - cmd = `$mpi_cmd -n 4 $(Base.julia_cmd()) --project dmda.jl` - success(pipeline(cmd, stderr = stderr)) - end - end -end - -# Examples with the comment -# # INCLUDE IN MPI TEST -# will be run here -# XXX: Currently not working on windows reliably, not sure why -if !Sys.iswindows() - include("mpi_examples.jl") -end - -include("options.jl") -include("dmda.jl") -include("old_test.jl") -include("test_dmstag.jl") -include("test_snes.jl") - -# Run the examples to make sure they all work -include("examples.jl") - +include("init.jl") +# include("options.jl") +# include("vec.jl") +# include("mat.jl") From c85e8e8affef4d123686a7c04b3d6d20b0b960f2 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 19 Jul 2021 14:02:35 -0700 Subject: [PATCH 03/53] Add back in options --- src/PETSc.jl | 6 +-- src/options.jl | 96 ++++++++++++++++-------------------------------- src/sys.jl | 69 +--------------------------------- src/viewer.jl | 48 ++++++++++++------------ test/options.jl | 4 +- test/runtests.jl | 2 +- 6 files changed, 64 insertions(+), 161 deletions(-) diff --git a/src/PETSc.jl b/src/PETSc.jl index 711ce43c..7dea9a85 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -20,9 +20,9 @@ function _doc_external(fname) end include("init.jl") +include("viewer.jl") +include("options.jl") # include("ref.jl") -# include("viewer.jl") -# include("options.jl") # include("vec.jl") # include("mat.jl") # include("matshell.jl") @@ -32,6 +32,6 @@ include("init.jl") # include("ksp.jl") # include("pc.jl") # include("snes.jl") -# include("sys.jl") +include("sys.jl") end diff --git a/src/options.jl b/src/options.jl index c2be13f6..22780ba7 100644 --- a/src/options.jl +++ b/src/options.jl @@ -14,6 +14,8 @@ The PETSc global options database. """ struct GlobalOptions{PetscLib} <: AbstractOptions{PetscLib} end Base.cconvert(::Type{CPetscOptions}, obj::GlobalOptions) = C_NULL +GlobalOptions(::PetscLib) where PetscLib = GlobalOptions{PetscLib}() + """ Options{PetscLib <: PetscLibType}(kw -> arg, ...) @@ -75,6 +77,15 @@ mutable struct Options{T} <: AbstractOptions{T} ptr::CPetscOptions end +function Options(petsclib::PetscLibType) + @assert initialized(petsclib) + PetscLib = typeof(petsclib) + opts = Options{PetscLib}(C_NULL) + LibPETSc.PetscOptionsCreate(petsclib, opts) + finalizer(x->LibPETSc.PetscOptionsDestroy(PetscLib, x), opts) + return opts +end + Options(petsclib; kwargs...) = Options(petsclib, kwargs...) function Options(petsclib, ps::Pair...) opts = Options(petsclib) @@ -84,70 +95,35 @@ function Options(petsclib, ps::Pair...) return opts end -@for_petsc function Options(::$UnionPetscLib) - opts = Options{$PetscLib}(C_NULL) - @assert initialized($PetscLib) - @chk ccall( - (:PetscOptionsCreate, $petsc_library), - PetscErrorCode, - (Ptr{CPetscOptions},), - opts, - ) - finalizer(finalize, opts) - return opts -end - -@for_petsc function finalize(opts::Options{$PetscLib}) - finalized($PetscLib) || @chk ccall( - (:PetscOptionsDestroy, $petsc_library), - PetscErrorCode, - (Ptr{CPetscOptions},), - opts, - ) +function Base.push!( + ::GlobalOptions{PetscLib}, + opts::Options{PetscLib}, +) where PetscLib + LibPETSc.PetscOptionsPush(PetscLib, opts) return nothing end -@for_petsc function Base.push!( - ::GlobalOptions{$PetscLib}, - opts::Options{$PetscLib}, -) - @chk ccall( - (:PetscOptionsPush, $petsc_library), - PetscErrorCode, - (CPetscOptions,), - opts, - ) +function Base.pop!(::GlobalOptions{PetscLib}) where PetscLib + LibPETSc.PetscOptionsPop(PetscLib) return nothing end -@for_petsc function Base.pop!(::GlobalOptions{$PetscLib}) - @chk ccall((:PetscOptionsPop, $petsc_library), PetscErrorCode, ()) - return nothing -end - -@for_petsc function Base.setindex!(opts::AbstractOptions{$PetscLib}, val, key) +function Base.setindex!(opts::AbstractOptions{PetscLib}, val, key) where PetscLib val === true && (val = nothing) val === false && (return val) - @chk ccall( - (:PetscOptionsSetValue, $petsc_library), - PetscErrorCode, - (CPetscOptions, Cstring, Cstring), - opts, - string('-', key), - isnothing(val) ? C_NULL : string(val), - ) + LibPETSc.PetscOptionsSetValue(PetscLib, + opts, + string('-', key), + isnothing(val) ? C_NULL : string(val)) return val end -@for_petsc function Base.getindex(opts::AbstractOptions{$PetscLib}, key) +function Base.getindex(opts::AbstractOptions{PetscLib}, key) where PetscLib val = Vector{UInt8}(undef, 256) set_ref = Ref{PetscBool}() - @chk ccall( - (:PetscOptionsGetString, $petsc_library), - PetscErrorCode, - (CPetscOptions, Cstring, Cstring, Ptr{UInt8}, Csize_t, Ptr{PetscBool}), + LibPETSc.PetscOptionsGetString(PetscLib, opts, C_NULL, string('-', key), @@ -160,22 +136,14 @@ end return val end -@for_petsc function view( - opts::AbstractOptions{$PetscLib}, - viewer::AbstractViewer{$PetscLib} = ViewerStdout($PetscLib, MPI.COMM_SELF), -) - @chk ccall( - (:PetscOptionsView, $petsc_library), - PetscErrorCode, - (CPetscOptions, CPetscViewer), - opts, - viewer, - ) +function view( + opts::AbstractOptions{PetscLib}, + viewer = LibPETSc.PETSC_VIEWER_STDOUT_(PetscLib, MPI.COMM_SELF) +) where PetscLib + LibPETSc.PetscOptionsView(PetscLib, opts, viewer) return nothing end -@for_petsc GlobalOptions(::$UnionPetscLib) = GlobalOptions{$PetscLib}() - Base.show(io::IO, opts::AbstractOptions) = _show(io, opts) """ @@ -184,8 +152,8 @@ Base.show(io::IO, opts::AbstractOptions) = _show(io, opts) Call `f()` with the [`Options`](@ref) `opts` set temporarily (in addition to any global options). """ -function with(f, opts::Options{T}) where {T} - global_opts = GlobalOptions{T}() +function with(f, opts::Options{PetscLib}) where {PetscLib} + global_opts = GlobalOptions{PetscLib}() push!(global_opts, opts) try f() diff --git a/src/sys.jl b/src/sys.jl index c897f439..3118a7e0 100644 --- a/src/sys.jl +++ b/src/sys.jl @@ -1,15 +1,6 @@ const CPetscObject = Ptr{Cvoid} -const UnionPetscTypes = Union{ - AbstractVec, - AbstractMat, - AbstractKSP, - AbstractViewer, - AbstractSNES, - AbstractPC, - AbstractDM, - Options, -} +const UnionPetscTypes = Union{Options} # allows us to pass PETSc_XXX objects directly into CXXX ccall signatures Base.cconvert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj @@ -19,61 +10,3 @@ Base.unsafe_convert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj.ptr function Base.unsafe_convert(::Type{Ptr{CPetscObject}}, obj::UnionPetscTypes) convert(Ptr{CPetscObject}, pointer_from_objref(obj)) end - -@for_petsc begin - function getcomm( - obj::Union{ - AbstractKSP{$PetscScalar}, - AbstractMat{$PetscScalar}, - AbstractVec{$PetscScalar}, - AbstractDM{$PetscLib}, - }, - ) - comm = MPI.Comm() - @chk ccall( - (:PetscObjectGetComm, $petsc_library), - PetscErrorCode, - (CPetscObject, Ptr{MPI.MPI_Comm}), - obj, - comm, - ) - - #XXX We should really increase the petsc reference counter. - # But for for some reason the PETSc says that this communicator is - # unknown - #= - # Call the PetscCommDuplicate to increase reference count - @chk ccall( - (:PetscCommDuplicate, $petsc_library), - PetscErrorCode, - (MPI.MPI_Comm, Ptr{MPI.MPI_Comm}, Ptr{Cvoid}), - comm, - comm, - C_NULL, - ) - - # Register PetscCommDestroy to decriment the reference count - finalizer(PetscCommDestroy, comm) - =# - - return comm - end -end - -#= -#XXX Not sure why this doesn't work -@for_petsc begin - function PetscCommDestroy( - comm::MPI.Comm - ) - @show comm.val - @chk ccall( - (:PetscCommDestroy, $petsc_library), - PetscErrorCode, - (Ptr{MPI.MPI_Comm},), - comm, - ) - return nothing - end -end -=# diff --git a/src/viewer.jl b/src/viewer.jl index ee1ba7f4..c3792fac 100644 --- a/src/viewer.jl +++ b/src/viewer.jl @@ -1,3 +1,27 @@ +# ideally we would capture the output directly, but this looks difficult +# easiest option is to redirect stdout +# based on suggestion from https://github.com/JuliaLang/julia/issues/32567 +function _show(io::IO, obj) + old_stdout = stdout + try + rd, = redirect_stdout() + view(obj) + + # Since not all MPI ranks are guaranteed to print we put in a newline + # that we remove with the write since readavailable will hang if there + # is no data in the stream + println() + + Libc.flush_cstdio() + flush(stdout) + write(io, readavailable(rd)[1:(end - 1)]) + finally + redirect_stdout(old_stdout) + end + return nothing +end + +#= const CPetscViewer = Ptr{Cvoid} """ @@ -67,29 +91,7 @@ function with(f, viewer::AbstractViewer, format::PetscViewerFormat) pop!(viewer) end end - -# ideally we would capture the output directly, but this looks difficult -# easiest option is to redirect stdout -# based on suggestion from https://github.com/JuliaLang/julia/issues/32567 -function _show(io::IO, obj) - old_stdout = stdout - try - rd, = redirect_stdout() - view(obj) - - # Since not all MPI ranks are guaranteed to print we put in a newline - # that we remove with the write since readavailable will hang if there - # is no data in the stream - println() - - Libc.flush_cstdio() - flush(stdout) - write(io, readavailable(rd)[1:end-1]) - finally - redirect_stdout(old_stdout) - end - return nothing -end +=# #= # PETSc_jll isn't built with X support diff --git a/test/options.jl b/test/options.jl index 0530d7f5..fdcf111f 100644 --- a/test/options.jl +++ b/test/options.jl @@ -1,7 +1,7 @@ using Test using PETSc -@testset "options tests" begin +@testset "options" begin kw_opts = ( ksp_monitor = nothing, ksp_view = true, @@ -84,7 +84,7 @@ using PETSc end end -@testset "parse_options tests" begin +@testset "parse_options" begin @test begin julia = joinpath(Sys.BINDIR, Base.julia_exename()) run(`$(julia) --startup-file=no --project -e "using PETSc diff --git a/test/runtests.jl b/test/runtests.jl index c7398752..cac13ea3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ include("init.jl") -# include("options.jl") +include("options.jl") # include("vec.jl") # include("mat.jl") From 8c17b12937d1714ff2c7c6f6a9cdfa2f63483657 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 19 Jul 2021 14:09:21 -0700 Subject: [PATCH 04/53] Add back in vec.jl --- src/PETSc.jl | 2 +- src/sys.jl | 47 ++++- src/vec.jl | 465 ++++++++++++++++++----------------------------- test/runtests.jl | 2 +- test/vec.jl | 40 ++++ 5 files changed, 260 insertions(+), 296 deletions(-) create mode 100644 test/vec.jl diff --git a/src/PETSc.jl b/src/PETSc.jl index 7dea9a85..82192222 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -23,7 +23,7 @@ include("init.jl") include("viewer.jl") include("options.jl") # include("ref.jl") -# include("vec.jl") +include("vec.jl") # include("mat.jl") # include("matshell.jl") # include("dm.jl") diff --git a/src/sys.jl b/src/sys.jl index 3118a7e0..5ec2d5f0 100644 --- a/src/sys.jl +++ b/src/sys.jl @@ -1,6 +1,6 @@ const CPetscObject = Ptr{Cvoid} -const UnionPetscTypes = Union{Options} +const UnionPetscTypes = Union{Options, AbstractVec} # allows us to pass PETSc_XXX objects directly into CXXX ccall signatures Base.cconvert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj @@ -10,3 +10,48 @@ Base.unsafe_convert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj.ptr function Base.unsafe_convert(::Type{Ptr{CPetscObject}}, obj::UnionPetscTypes) convert(Ptr{CPetscObject}, pointer_from_objref(obj)) end + +function getcomm( + obj::Union{AbstractVec{PetscLib}}, +) where {PetscLib} + comm = MPI.Comm() + LibPETSc.PetscObjectGetComm(PetscLib, obj, comm) + + #XXX We should really increase the petsc reference counter. + # But for for some reason the PETSc says that this communicator is + # unknown + #= + # Call the PetscCommDuplicate to increase reference count + @chk ccall( + (:PetscCommDuplicate, $libpetsc), + PetscErrorCode, + (MPI.MPI_Comm, Ptr{MPI.MPI_Comm}, Ptr{Cvoid}), + comm, + comm, + C_NULL, + ) + + # Register PetscCommDestroy to decriment the reference count + finalizer(PetscCommDestroy, comm) + =# + + return comm +end + +#= +#XXX Not sure why this doesn't work +@for_libpetsc begin + function PetscCommDestroy( + comm::MPI.Comm + ) + @show comm.val + @chk ccall( + (:PetscCommDestroy, $libpetsc), + PetscErrorCode, + (Ptr{MPI.MPI_Comm},), + comm, + ) + return nothing + end +end +=# diff --git a/src/vec.jl b/src/vec.jl index e53680da..14440320 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -6,8 +6,17 @@ const CVec = Ptr{Cvoid} -abstract type AbstractVec{T} <: AbstractVector{T} end -scalartype(::AbstractVec{T}) where {T} = T +abstract type AbstractVec{PetscLib, PetscScalar} <: AbstractVector{PetscScalar} end + +Base.eltype( + ::Type{V}, +) where { + V <: AbstractVec{PetscLib, PetscScalar}, +} where {PetscLib, PetscScalar} = PetscScalar +Base.eltype( + v::AbstractVec{PetscLib, PetscScalar}, +) where {PetscLib, PetscScalar} = PetscScalar +Base.size(v::AbstractVec) = (length(v),) # allows us to pass XXVec objects directly into CVec ccall signatures Base.cconvert(::Type{CVec}, obj::AbstractVec) = obj.ptr @@ -17,227 +26,189 @@ Base.unsafe_convert(::Type{Ptr{CVec}}, obj::AbstractVec) = """ - VecSeq(v::Vector) + VecSeq(petsclib, v::Vector) -A standard, sequentially-stored serial PETSc vector, wrapping the Julia vector `v`. +A standard, sequentially-stored serial PETSc vector, wrapping the Julia vector +`v`. -This reuses the array `v` as storage, and so `v` should not be `resize!`-ed or otherwise have its length modified while the PETSc object exists. +This reuses the array `v` as storage, and so `v` should not be `resize!`-ed or +otherwise have its length modified while the PETSc object exists. -This should only be need to be called for more advanced uses, for most simple usecases, users should be able to pass `Vector`s directly and have the wrapping performed automatically +This should only be need to be called for more advanced uses, for most simple +usecases, users should be able to pass `Vector`s directly and have the wrapping +performed automatically # External Links $(_doc_external("Vec/VecCreateSeqWithArray")) """ -mutable struct VecSeq{T} <: AbstractVec{T} +mutable struct VecSeq{PetscLib, PetscScalar} <: + AbstractVec{PetscLib, PetscScalar} ptr::CVec - array::Vector{T} + array::Vector{PetscScalar} end - -""" - Vec(v::CVec) - -Container for an abstract PETSc vector - -# External Links -$(_doc_external("Vec/Vec")) -""" -mutable struct Vec{T} <: AbstractVec{T} - ptr::CVec +Base.parent(v::VecSeq) = v.array + +function VecSeq( + petsclib::PetscLib, + array::Vector{PetscScalar}; + blocksize = 1, +) where {PetscLib, PetscScalar} + comm = MPI.COMM_SELF + @assert initialized(petsclib) + @assert PetscScalar == petsclib.PetscScalar + v = VecSeq{PetscLib, PetscScalar}(C_NULL, array) + LibPETSc.VecCreateSeqWithArray( + petsclib, + comm, + blocksize, + length(array), + array, + v, + ) + finalizer(destroy, v) + return v end -Base.eltype(::Type{V}) where {V<:AbstractVec{T}} where T = T -Base.eltype(v::AbstractVec{T}) where {T} = T -Base.size(v::AbstractVec) = (length(v),) -Base.parent(v::AbstractVec) = v.array - -# this allows setting V[1:2] = 3:4 on a PetscVec (more convenient) -function Base.setindex!(v::AbstractVec, val, I) - v.array[I]=val +function destroy(v::AbstractVec{PetscLib}) where {PetscLib} + finalized(PetscLib) || LibPETSc.VecDestroy(PetscLib, v) + return nothing end -Base.getindex(v::AbstractVec, I) = v.array[I] - - -@for_libpetsc begin - function VecSeq(comm::MPI.Comm, X::Vector{$PetscScalar}; blocksize=1) - @assert initialized($petsclib) - v = VecSeq(C_NULL, X) - @chk ccall((:VecCreateSeqWithArray, $libpetsc), PetscErrorCode, - (MPI.MPI_Comm, $PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{CVec}), - comm, blocksize, length(X), X, v) - finalizer(destroy, v) - return v - end - function destroy(v::AbstractVec{$PetscScalar}) - finalized($petsclib) || - @chk ccall((:VecDestroy, $libpetsc), PetscErrorCode, (Ptr{CVec},), v) - return nothing - end - function Base.length(v::AbstractVec{$PetscScalar}) - r_sz = Ref{$PetscInt}() - @chk ccall((:VecGetSize, $libpetsc), PetscErrorCode, - (CVec, Ptr{$PetscInt}), v, r_sz) - return r_sz[] - end - function LinearAlgebra.norm(v::AbstractVec{$PetscScalar}, normtype::NormType=NORM_2) - r_val = Ref{$PetscReal}() - @chk ccall((:VecNorm, $libpetsc), PetscErrorCode, - (CVec, NormType, Ptr{$PetscReal}), - v, normtype,r_val) - return r_val[] - end - function assemblybegin(V::AbstractVec{$PetscScalar}) - @chk ccall((:VecAssemblyBegin, $libpetsc), PetscErrorCode, (CVec,), V) - return nothing - end - function assemblyend(V::AbstractVec{$PetscScalar}) - @chk ccall((:VecAssemblyEnd, $libpetsc), PetscErrorCode, (CVec,), V) - return nothing - end - function assemble(V::AbstractVec{$PetscScalar}) - assemblybegin(V) - assemblyend(V) - end +function Base.length(v::AbstractVec{PetscLib}) where {PetscLib} + petsclib = getlib(PetscLib) + PetscInt = petsclib.PetscInt + r_sz = Ref{PetscInt}() + LibPETSc.VecGetSize(PetscLib, v, r_sz) + return r_sz[] +end - function ownershiprange(vec::AbstractVec{$PetscScalar}) - r_lo = Ref{$PetscInt}() - r_hi = Ref{$PetscInt}() - @chk ccall((:VecGetOwnershipRange, $libpetsc), PetscErrorCode, - (CVec, Ptr{$PetscInt}, Ptr{$PetscInt}), vec, r_lo, r_hi) - r_lo[]:(r_hi[]-$PetscInt(1)) - end +function locallength(v::AbstractVec{PetscLib}) where {PetscLib} + petsclib = getlib(PetscLib) + PetscInt = petsclib.PetscInt + r_sz = Ref{PetscInt}() + LibPETSc.VecGetLocalSize(PetscLib, v, r_sz) + return r_sz[] +end - function view(vec::AbstractVec{$PetscScalar}, viewer::AbstractViewer{$PetscLib}=ViewerStdout($petsclib, getcomm(vec))) - @chk ccall((:VecView, $libpetsc), PetscErrorCode, - (CVec, CPetscViewer), - vec.ptr, viewer); - return nothing - end +function LinearAlgebra.norm( + v::AbstractVec{PetscLib}, + normtype::LibPETSc.NormType = LibPETSc.NORM_2, +) where {PetscLib} + petsclib = getlib(PetscLib) + PetscReal = petsclib.PetscReal + r_val = Ref{PetscReal}() + LibPETSc.VecNorm(PetscLib, v, normtype, r_val) + return r_val[] +end - function localsize(cv::CVec) - r_sz = Ref{$PetscInt}() - @chk ccall((:VecGetLocalSize, $libpetsc), PetscErrorCode, - (CVec, Ptr{$PetscInt}), cv, r_sz) - return r_sz[] - end +function view( + vec::AbstractVec{PetscLib}, + viewer = LibPETSc.PETSC_VIEWER_STDOUT_(PetscLib, getcomm(vec)), +) where {PetscLib} + LibPETSc.VecView(PetscLib, vec, viewer) + return nothing +end +Base.show(io::IO, vec::AbstractVec) = _show(io, vec) +Base.show(io::IO, ::MIME"text/plain", vec::AbstractVec) = _show(io, vec) - function setvalues!(vec::AbstractVec{$PetscScalar},idxs,vals, insertmode::InsertMode) - idxs = Vector(Int32,idxs); - vals = Vector(vals); - - @chk ccall((:VecSetValues, $libpetsc), PetscErrorCode, - (CVec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar},InsertMode), vec, length(idxs), idxs, vals, insertmode) - return nothing +""" + ownership_range(vec::AbstractVec, [base_one = true]) - end +The range of indices owned by this processor, assuming that the `vec` is laid +out with the first `n1` elements on the first processor, next `n2` elements on +the second, etc. For certain parallel layouts this range may not be well +defined. - function unsafe_localarray(::Type{$PetscScalar}, cv::CVec; read::Bool=true, write::Bool=true) - r_pv = Ref{Ptr{$PetscScalar}}() - if write - if read - @chk ccall((:VecGetArray, $libpetsc), PetscErrorCode, - (CVec, Ptr{Ptr{$PetscScalar}}), cv, r_pv) - else - @chk ccall((:VecGetArrayWrite, $libpetsc), PetscErrorCode, - (CVec, Ptr{Ptr{$PetscScalar}}), cv, r_pv) - end - else - @chk ccall((:VecGetArrayRead, $libpetsc), PetscErrorCode, - (CVec, Ptr{Ptr{$PetscScalar}}), cv, r_pv) - end - r_sz = Ref{$PetscInt}() - - @chk ccall((:VecGetLocalSize, $libpetsc), PetscErrorCode, - (CVec, Ptr{$PetscInt}), cv, r_sz) - v = unsafe_wrap(Array, r_pv[], r_sz[]; own = false) - - if write - if read - finalizer(v) do v - @chk ccall((:VecRestoreArray, $libpetsc), PetscErrorCode, (CVec, Ptr{Ptr{$PetscScalar}}), cv, Ref(pointer(v))) - return nothing - end - else - finalizer(v) do v - @chk ccall((:VecRestoreArrayWrite, $libpetsc), PetscErrorCode, (CVec, Ptr{Ptr{$PetscScalar}}), cv, Ref(pointer(v))) - return nothing - end - end - else - finalizer(v) do v - @chk ccall((:VecRestoreArrayRead, $libpetsc), PetscErrorCode, (CVec, Ptr{Ptr{$PetscScalar}}), cv, Ref(pointer(v))) - return nothing - end - end - return v - end +If the optional argument `base_one == true` then base-1 indexing is used, +otherwise base-0 index is used. - function Base.fill!(v::AbstractVec{$PetscScalar}, x) - @chk ccall((:VecSet, $libpetsc), - PetscErrorCode, - (CVec, $PetscScalar), - v, $PetscScalar(x)) - return v - end +!!! note - function Base.setindex!( - v::AbstractVec{$PetscScalar}, - val, - i::Integer, - ) - @chk ccall( - (:VecSetValues, $libpetsc), - PetscErrorCode, - (CVec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}, InsertMode), - v, - 1, - Ref{$PetscInt}(i - 1), - Ref{$PetscScalar}(val), - INSERT_VALUES, - ) - - return val - end + unlike the C function, the range returned is inclusive (`idx_first:idx_last`) - function Base.getindex( - v::AbstractVec{$PetscScalar}, - i::Integer, - ) - vals = [$PetscScalar(0)] - @chk ccall( - (:VecGetValues, $libpetsc), - PetscErrorCode, - (CVec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}), - v, - 1, - Ref{$PetscInt}(i - 1), - vals, - ) - - return vals[1] - end +# External Links +$(_doc_external("Vec/VecGetOwnershipRange")) +""" +function ownershiprange( + vec::AbstractVec{PetscLib}, + base_one::Bool = true, +) where {PetscLib} + petsclib = getlib(PetscLib) + PetscInt = petsclib.PetscInt + r_lo = Ref{PetscInt}() + r_hi = Ref{PetscInt}() + LibPETSc.VecGetOwnershipRange(PetscLib, vec, r_lo, r_hi) + return base_one ? ((r_lo[] + PetscInt(1)):(r_hi[])) : + ((r_lo[]):(r_hi[] - PetscInt(1))) end """ - unsafe_localarray(PetscScalar, ptr:CVec; read=true, write=true) - unsafe_localarray(ptr:AbstractVec; read=true, write=true) + unsafe_localarray(vec::AbstractVec; read=true, write=true) -Return an `Array{PetscScalar}` containing local portion of the PETSc data. +Return an `Array{PetscScalar}` containing local portion of the PETSc `vec` Use `read=false` if the array is write-only; `write=false` if read-only. !!! note `Base.finalize` should be called on the `Array` before the data can be used. + +# External Links +$(_doc_external("Vec/VecGetArray")) +$(_doc_external("Vec/VecGetArrayWrite")) +$(_doc_external("Vec/VecGetArrayRead")) +$(_doc_external("Vec/VecRestoreArray")) +$(_doc_external("Vec/VecRestoreArrayWrite")) +$(_doc_external("Vec/VecRestoreArrayRead")) """ -unsafe_localarray +function unsafe_localarray( + vec::AbstractVec{PetscLib}; + read::Bool = true, + write::Bool = true, +) where {PetscLib} + petsclib = getlib(PetscLib) + PetscScalar = petsclib.PetscScalar + r_pv = Ref{Ptr{PetscScalar}}() + if write && read + LibPETSc.VecGetArray(PetscLib, vec, r_pv) + elseif write + LibPETSc.VecGetArrayWrite(PetscLib, vec, r_pv) + elseif read + LibPETSc.VecGetArrayRead(PetscLib, vec, r_pv) + else + error("either read or write should be true") + end + sz = locallength(vec) + v = unsafe_wrap(Array, r_pv[], sz; own = false) -unsafe_localarray(v::AbstractVec{T}; kwargs...) where {T} = - unsafe_localarray(T, v.ptr; kwargs...) + if write && read + finalizer(v) do v + LibPETSc.VecRestoreArray(PetscLib, vec, Ref(pointer(v))) + return nothing + end + elseif write + finalizer(v) do v + LibPETSc.VecRestoreArrayWrite(PetscLib, vec, Ref(pointer(v))) + return nothing + end + elseif read + finalizer(v) do v + LibPETSc.VecRestoreArrayRead(PetscLib, vec, Ref(pointer(v))) + return nothing + end + end + return v +end """ - map_unsafe_localarray!(f!, x::AbstractVec{T}; read=true, write=true) + with_unsafe_localarray!( + f!, + x::AbstractVec; + read=true, + write=true, + ) -Convert `x` to an `Array{T}` and apply the function `f!`. +Convert `x` to an `Array{PetscScalar}` using [`unsafe_localarray`](@ref) and +apply the function `f!`. Use `read=false` if the array is write-only; `write=false` if read-only. @@ -248,115 +219,23 @@ julia> map_unsafe_localarray(x; write=true) do x end !!! note - `Base.finalize` should is automatically called on the array. + `Base.finalize` is automatically called on the array. """ -function map_unsafe_localarray!(f!, v::AbstractVec{T}; kwargs...) where {T} - array = unsafe_localarray(T, v.ptr; kwargs...) +function with_unsafe_localarray!(f!, v::AbstractVec; kwargs...) + array = unsafe_localarray(v; kwargs...) f!(array) Base.finalize(array) end - - -function Base.show(io::IO, ::MIME"text/plain", vec::AbstractVec) - _show(io, vec) -end - -VecSeq(X::Vector{T}; kwargs...) where {T} = VecSeq(MPI.COMM_SELF, X; kwargs...) -AbstractVec(X::AbstractVector) = VecSeq(X) - - -""" - ownershiprange(vec::AbstractVec) - -The range of indices owned by this processor, assuming that the vectors are laid out with the first n1 elements on the first processor, next n2 elements on the second, etc. For certain parallel layouts this range may not be well defined. - -Note: unlike the C function, the range returned is inclusive (`idx_first:idx_last`) - -# External Links -$(_doc_external("Vec/VecGetOwnershipRange")) -""" -ownershiprange - -""" - setvalues!( - vector::AbstractVec{PetscScalar}, - indices::Vector{PetscInt}, - vals::Vector{PetscScalar}, - mode::InsertMode; - num_vals = length(ind) - ) - -Insert a set of values into the `vector`. Equivalent to one of the following -depending on the `mode` -```julia -vector[indices[1:num_vals]] .= vals[1:num_vals] -vector[indices[1:num_vals]] .+= vals[1:num_vals] -``` - -!!! warning - `indices` should use 0-based indexing! - -# External Links -$(_doc_external("Vec/VecSetValues")) -""" -function setvalues!(::AbstractVec) end - -@for_libpetsc function setvalues!( - vec::AbstractVec{$PetscScalar}, - inds::Vector{$PetscInt}, - vals::Vector{$PetscScalar}, - mode::InsertMode; - num_vals = length(inds) -) - @chk ccall( - (:VecSetValues, $libpetsc), - PetscErrorCode, - (CVec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}, InsertMode), - vec, - num_vals, - inds, - vals, - mode, - ) - return vals -end - -""" - getvalues!( - vector::AbstractVec{PetscScalar}, - indices::Vector{PetscInt}, - vals::Vector{PetscScalar}; - num_vals = length(inds) - ) - -Get a set of values from the `vector`. Equivalent to one of the following -```julia -vals[1:num_vals] .= vector[indices[1:num_vals]] -``` - -!!! warning - `indices` should use 0-based indexing! - -# External Links -$(_doc_external("Vec/VecGetValues")) -""" -function getvalues!(::AbstractVec) end - -@for_libpetsc function getvalues!( - vec::AbstractVec{$PetscScalar}, - inds::Vector{$PetscInt}, - vals::Vector{$PetscScalar}; - num_vals = length(inds) -) - @chk ccall( - (:VecGetValues, $libpetsc), - PetscErrorCode, - (CVec, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}), - vec, - num_vals, - inds, - vals, - ) - return vals +#= +@for_libpetsc begin + function assemblybegin(V::AbstractVec{$PetscScalar}) + @chk ccall((:VecAssemblyBegin, $libpetsc), PetscErrorCode, (CVec,), V) + return nothing + end + function assemblyend(V::AbstractVec{$PetscScalar}) + @chk ccall((:VecAssemblyEnd, $libpetsc), PetscErrorCode, (CVec,), V) + return nothing + end end +=# diff --git a/test/runtests.jl b/test/runtests.jl index cac13ea3..410f36ba 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ include("init.jl") include("options.jl") -# include("vec.jl") +include("vec.jl") # include("mat.jl") diff --git a/test/vec.jl b/test/vec.jl new file mode 100644 index 00000000..14201b41 --- /dev/null +++ b/test/vec.jl @@ -0,0 +1,40 @@ +using Test +using PETSc +using LinearAlgebra: norm + +@testset "VecSeq" begin + N = 10 + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + x = rand(PetscScalar, N) + petsc_x = PETSc.VecSeq(petsclib, x) + @test length(petsc_x) == N + @test norm(petsc_x) ≈ norm(x) + + # make sure the viewer works + _stdout = stdout + (rd, wr) = redirect_stdout() + @show petsc_x + @test readline(rd) == "petsc_x = Vec Object: 1 MPI processes" + @test readline(rd) == " type: seq" + redirect_stdout(_stdout) + + _stdout = stdout + (rd, wr) = redirect_stdout() + show(stdout, "text/plain", petsc_x) + @test readline(rd) == "Vec Object: 1 MPI processes" + @test readline(rd) == " type: seq" + redirect_stdout(_stdout) + + @test PETSc.ownershiprange(petsc_x) == 1:N + @test PETSc.ownershiprange(petsc_x, false) == 0:(N - 1) + + PETSc.with_unsafe_localarray!(petsc_x) do x2 + @test x2 == x + end + + PETSc.destroy(petsc_x) + PETSc.finalize(petsclib) + end +end From 32c044e6b155ee0a79eb3d678d84ef3ee2168e65 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 19 Jul 2021 14:11:22 -0700 Subject: [PATCH 05/53] Add back in mat.jl --- src/PETSc.jl | 2 +- src/mat.jl | 613 +++++++++++++++++++++-------------------------- src/sys.jl | 4 +- src/vec.jl | 2 +- test/mat.jl | 143 +++++++++++ test/runtests.jl | 2 +- 6 files changed, 418 insertions(+), 348 deletions(-) create mode 100644 test/mat.jl diff --git a/src/PETSc.jl b/src/PETSc.jl index 82192222..9192ee57 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -24,7 +24,7 @@ include("viewer.jl") include("options.jl") # include("ref.jl") include("vec.jl") -# include("mat.jl") +include("mat.jl") # include("matshell.jl") # include("dm.jl") # include("dmda.jl") diff --git a/src/mat.jl b/src/mat.jl index 65471fa3..b2be4213 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -1,396 +1,333 @@ const CMat = Ptr{Cvoid} -const CMatNullSpace = Ptr{Cvoid} -abstract type AbstractMat{T} <: AbstractMatrix{T} end -scalartype(::AbstractMat{T}) where {T} = T +abstract type AbstractMat{PetscLib, PetscScalar} <: AbstractMatrix{PetscScalar} end -Base.eltype(::Type{A}) where {A<:AbstractMat{T}} where {T} = T -Base.eltype(A::AbstractMat{T}) where {T} = T +Base.eltype( + ::Type{V}, +) where { + V <: AbstractMat{PetscLib, PetscScalar}, +} where {PetscLib, PetscScalar} = PetscScalar +Base.eltype( + v::AbstractMat{PetscLib, PetscScalar}, +) where {PetscLib, PetscScalar} = PetscScalar + +function destroy(M::AbstractMat{PetscLib}) where {PetscLib} + finalized(PetscLib) || LibPETSc.MatDestroy(PetscLib, M) + return nothing +end """ - MatSeqAIJ{T} + MatSeqAIJ{PetscLib, PetscScalar} -PETSc sparse array using AIJ format (also known as a compressed sparse row or CSR format). +PETSc sparse array using AIJ format (also known as a compressed sparse row or +CSR format). Memory allocation is handled by PETSc. + +# External Links +$(_doc_external("Mat/MatCreateSeqAIJ")) """ -mutable struct MatSeqAIJ{T} <: AbstractMat{T} +mutable struct MatSeqAIJ{PetscLib, PetscScalar} <: + AbstractMat{PetscLib, PetscScalar} ptr::CMat end - """ - Mat{T} + MatSeqAIJ(petsclib, num_rows, num_cols, nonzeros) -Container for an abstract PETSc matrix +Create a PETSc sparse array using AIJ format (also known as a compressed sparse +row or CSR format) of size `num_rows X num_cols` with `nonzeros` per row -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/Mat.html) -""" -mutable struct Mat{T} <: AbstractMat{T} - ptr::CMat -end +If `nonzeros` is an `Integer` the same number of non-zeros will be used for each +row, if `nonzeros` is a `Vector{PetscInt}` then one value must be specified for +each row. -""" - MatSeqDense{T} +Memory allocation is handled by PETSc and garbage collection can be used. -PETSc dense array. This wraps a Julia `Matrix{T}` object. +# External Links +$(_doc_external("Mat/MatCreateSeqAIJ")) """ -mutable struct MatSeqDense{T} <: AbstractMat{T} - ptr::CMat - array::Matrix{T} +function MatSeqAIJ( + petsclib::PetscLib, + num_rows::Integer, + num_cols::Integer, + nonzeros::Union{Integer, Vector}, +) where {PetscLib <: PetscLibType} + comm = MPI.COMM_SELF + @assert initialized(petsclib) + PetscScalar = petsclib.PetscScalar + mat = MatSeqAIJ{PetscLib, PetscScalar}(C_NULL) + if nonzeros isa Integer + LibPETSc.MatCreateSeqAIJ( + petsclib, + comm, + num_rows, + num_cols, + nonzeros, + C_NULL, + mat, + ) + else + @assert eltype(nonzeros) == petsclib.PetscInt + @assert length(nonzeros) >= num_rows + LibPETSc.MatCreateSeqAIJ( + petsclib, + comm, + num_rows, + num_cols, + 0, + nonzeros, + mat, + ) + end + + finalizer(destroy, mat) + + return mat end """ - MatStencil{PetscInt} + MatSeqDense{PetscLib, PetscScalar} -Equivalent to the `MatStencil` in PETSc +PETSc dense array. This wraps a Julia `Matrix{PetscScalar}` object. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatStencil.html) +# External Links +$(_doc_external("Mat/MatCreateSeqDense")) """ -struct MatStencil{PetscInt} - "third grid index" - k::PetscInt - "second grid index" - j::PetscInt - "first grid index" - i::PetscInt - "degree of freedom" - c::PetscInt - function MatStencil{PetscInt}(;i, j = 1, k = 1, c = 1) where PetscInt - # convert to zero-based indexing - new{PetscInt}(k - 1, j - 1, i - 1, c - 1) - end -end -# Since julia uses 1-based indexing we need to convert on access -function Base.getproperty(obj::MatStencil{PetscInt}, sym::Symbol) where PetscInt - if sym in (:i, :j, :k, :c) - return getfield(obj, sym) + PetscInt(1) - else # fallback to getfield - return getfield(obj, sym) - end -end -# Since julia uses 1-based indexing we need to convert on show -function Base.show(io::IO, m::MatStencil{PetscInt}) where {PetscInt} - print(io, typeof(m)) - print(io, "(i = ", m.i,) - print(io, ", j = ", m.j,) - print(io, ", k = ", m.k,) - print(io, ", c = ", m.c, ")") -end -function Base.show(io::IO, ::MIME"text/plain", m::MatStencil{PetscInt}) where PetscInt - print(io, "(i = ", m.i,) - print(io, ", j = ", m.j,) - print(io, ", k = ", m.k,) - print(io, ", c = ", m.c, ")") +mutable struct MatSeqDense{PetscLib, PetscScalar} <: + AbstractMat{PetscLib, PetscScalar} + ptr::CMat + array::Matrix{PetscScalar} end - +function MatSeqDense( + petsclib::PetscLib, + A::Matrix{PetscScalar}, +) where {PetscLib <: PetscLibType, PetscScalar} + comm = MPI.COMM_SELF + @assert initialized(petsclib) + @assert PetscScalar == petsclib.PetscScalar + mat = MatSeqDense{PetscLib, PetscScalar}(C_NULL, A) + LibPETSc.MatCreateSeqDense(petsclib, comm, size(A, 1), size(A, 2), A, mat) + finalizer(destroy, mat) + return mat +end """ - MatNullSpace{T} + assemble(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) + +Assemble the matrix `M` with assembly type `t`. -Object that removes a null space from a vector, i.e. orthogonalizes the vector -to a subspace; -see [MatNullSpace](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpace.html) -and [MatNullSpaceCreate](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpaceCreate.html) +For overlapping assembly see [`assemblybegin`](@ref) and [`assemblyend`](@ref) -!!! Note - The caller is responsible for calling `destroy` on this object +# External Links +$(_doc_external("Mat/MatAssemblyBegin")) +$(_doc_external("Mat/MatAssemblyEnd")) """ -mutable struct MatNullSpace{T} - ptr::CMatNullSpace - __comm__::MPI.Comm +function assemble(M::AbstractMat, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) + assemblybegin(M, t) + assemblyend(M, t) end -# allows us to pass XXMat objects directly into CMat ccall signatures -Base.cconvert(::Type{CMatNullSpace}, obj::MatNullSpace) = obj.ptr -# allows us to pass XXMat objects directly into Ptr{CMat} ccall signatures -Base.unsafe_convert(::Type{Ptr{CMatNullSpace}}, obj::MatNullSpace) = - convert(Ptr{CMatNullSpace}, pointer_from_objref(obj)) """ - MatNullSpaceRemove!(nullspace, vec) + assemblybegin(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) -Removes all the components of a `nullspace` from `vec` +Begin assembly of the matrix `M` with assembly type `t`; finished with +[`assemblyend`](@ref). -see [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpaceRemove.html) +# External Links +$(_doc_external("Mat/MatAssemblyBegin")) """ -function MatNullSpaceRemove! end +function assemblybegin( + M::AbstractMat{PetscLib}, + t::MatAssemblyType = MAT_FINAL_ASSEMBLY, +) where {PetscLib} + LibPETSc.MatAssemblyBegin(PetscLib, M, t) + return nothing +end """ - MatSetNullSpace!(mat, nullspace) + assemblyend(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) -Attach `nullspace` to `mat` +Finish assembly of the matrix `M` with assembly type `t`; start assembly with +[`assemblybegin`](@ref). -see [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetNullSpace.html) +# External Links +$(_doc_external("Mat/MatAssemblyEnd")) """ -function MatSetNullSpace! end +function assemblyend( + M::AbstractMat{PetscLib}, + t::MatAssemblyType = MAT_FINAL_ASSEMBLY, +) where {PetscLib} + LibPETSc.MatAssemblyEnd(PetscLib, M, t) + return nothing +end -""" - MatSetValuesStencil!(mat::AbstractMat{PetscScalar}, - rows::Vector{MatStencil{PetscInt}}, - cols::Vector{MatStencil{PetscInt}}, - vals::Vector{PetscScalar}, - mode; - num_cols = length(col), - num_rows = length(row) - ) - -Insert the `vals` specified by `rows` and `cols` stencil indices into the `mat`. -The optional arguments `num_cosl` and `num_rows` allow the limiting of the -elements of the `rows` and `cols` vectors. - -see [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesStencil.html) -""" -function MatSetValuesStencil! end - -@for_libpetsc begin - function MatNullSpace{$PetscScalar}(comm::MPI.Comm, has_constant, n=0, vecs=nothing) - @assert initialized($petsclib) - @assert n == 0 && isnothing(vecs) - nullspace = MatNullSpace{$PetscScalar}(C_NULL, comm) - @chk ccall((:MatNullSpaceCreate, $libpetsc), PetscErrorCode, - (MPI.MPI_Comm, - PetscBool, - $PetscInt, - Ptr{CVec}, - Ptr{CMatNullSpace} - ), - comm, has_constant, n, C_NULL, nullspace) - return nullspace - end +function Base.size(A::AbstractMat{PetscLib}) where {PetscLib} + petsclib = getlib(PetscLib) + m = Ref{petsclib.PetscInt}() + n = Ref{petsclib.PetscInt}() + LibPETSc.MatGetSize(PetscLib, A, m, n) + return (m[], n[]) +end - function MatNullSpaceRemove!( - nullspace::MatNullSpace{$PetscScalar}, - vec::AbstractVec{$PetscScalar}, - ) - @chk ccall( - (:MatNullSpaceRemove, $libpetsc), - PetscErrorCode, - (CMatNullSpace, CVec), - nullspace, - vec, - ) - return nothing - end +function Base.:(==)( + A::AbstractMat{PetscLib}, + B::AbstractMat{PetscLib}, +) where {PetscLib} + fr = Ref{PetscBool}() + LibPETSc.MatEqual(PetscLib, A, B, fr) + return fr[] == PETSC_TRUE +end +function view( + mat::AbstractMat{PetscLib}, + viewer = LibPETSc.PETSC_VIEWER_STDOUT_(PetscLib, getcomm(mat)), +) where {PetscLib} + LibPETSc.MatView(PetscLib, mat, viewer) + return nothing +end +Base.show(io::IO, mat::AbstractMat) = _show(io, mat) +Base.show(io::IO, ::MIME"text/plain", mat::AbstractMat) = _show(io, mat) - function MatSetNullSpace!( - mat::Mat{$PetscScalar}, - nullspace::MatNullSpace{$PetscScalar}, +""" + setvalues!( + M::AbstractMat{PetscLib}, + row0idxs::Vector{PetscInt}, + col0idxs::Vector{PetscInt}, + rowvals::Array{PetscScalar}, + insertmode::InsertMode; + num_rows = length(row0idxs), + num_cols = length(col0idxs) ) - @chk ccall( - (:MatSetNullSpace, $libpetsc), - PetscErrorCode, - (CMat, CMatNullSpace), - mat, - nullspace, - ) - return nothing - end - function destroy(nullspace::MatNullSpace{$PetscScalar}) - finalized($petsclib) || - @chk ccall((:MatNullSpaceDestroy, $libpetsc), PetscErrorCode, (Ptr{CMatNullSpace},), nullspace) - return nothing - end +Set values of the matrix `M` with base-0 row and column indices `row0idxs` and +`col0idxs` inserting the values `rowvals`. - function MatSeqAIJ{$PetscScalar}(m::Integer, n::Integer, nnz::Vector{$PetscInt}) - @assert initialized($petsclib) - comm = MPI.COMM_SELF - mat = MatSeqAIJ{$PetscScalar}(C_NULL) - @chk ccall((:MatCreateSeqAIJ, $libpetsc), PetscErrorCode, - (MPI.MPI_Comm, $PetscInt, $PetscInt, $PetscInt, Ptr{$PetscInt}, Ptr{CMat}), - comm, m, n, 0, nnz, mat) - finalizer(destroy, mat) - return mat - end - function MatSeqDense(A::Matrix{$PetscScalar}) - @assert initialized($petsclib) - comm = MPI.COMM_SELF - mat = MatSeqDense(C_NULL, A) - @chk ccall((:MatCreateSeqDense, $libpetsc), PetscErrorCode, - (MPI.MPI_Comm, $PetscInt, $PetscInt, Ptr{$PetscScalar}, Ptr{CMat}), - comm, size(A,1), size(A,2), A, mat) - finalizer(destroy, mat) - return mat - end - - function MatSetValuesStencil!(mat::AbstractMat{$PetscScalar}, - rows::Vector{MatStencil{$PetscInt}}, - cols::Vector{MatStencil{$PetscInt}}, - vals::Vector{$PetscScalar}, - mode::InsertMode; - num_rows = length(rows), - num_cols = length(cols), - ) - @assert length(vals) >= num_cols * num_rows - @assert length(cols) >= num_cols - @assert length(rows) >= num_rows - @chk ccall((:MatSetValuesStencil, $libpetsc), PetscErrorCode, - (CMat, - $PetscInt, Ptr{MatStencil{$PetscInt}}, - $PetscInt, Ptr{MatStencil{$PetscInt}}, - Ptr{$PetscScalar}, InsertMode), - mat, - num_rows, rows, - num_cols, cols, - vals, mode - ) - return nothing - end +If the keyword arguments `num_rows` or `num_cols` is specified then only the +first `num_rows * num_cols` values of `rowvals` will be used. +# External Links +$(_doc_external("Mat/MatSetValues")) +""" +function setvalues!( + M::AbstractMat{PetscLib}, + row0idxs::Vector{PetscInt}, + col0idxs::Vector{PetscInt}, + rowvals::Array{PetscScalar}, + insertmode::InsertMode; + num_rows = length(row0idxs), + num_cols = length(col0idxs), +) where {PetscLib, PetscScalar, PetscInt} + @assert PetscScalar == getlib(PetscLib).PetscScalar + @assert PetscInt == getlib(PetscLib).PetscInt + LibPETSc.MatSetValues( + PetscLib, + M, + num_rows, + row0idxs, + num_cols, + col0idxs, + rowvals, + insertmode, + ) + return nothing +end +function Base.setindex!( + M::AbstractMat{PetscLib}, + val, + i::Integer, + j::Integer, +) where {PetscLib} + PetscInt = getlib(PetscLib).PetscInt + PetscScalar = getlib(PetscLib).PetscScalar + setvalues!( + M, + [PetscInt(i - 1)], + [PetscInt(j - 1)], + [PetscScalar(val)], + INSERT_VALUES, + ) + return val +end +function LinearAlgebra.norm( + M::AbstractMat{PetscLib}, + normtype::NormType = NORM_FROBENIUS, +) where {PetscLib} + PetscReal = getlib(PetscLib).PetscReal + r_val = Ref{PetscReal}() + LibPETSc.MatNorm(PetscLib, M, normtype, r_val) + return r_val[] +end - function destroy(M::AbstractMat{$PetscScalar}) - finalized($petsclib) || - @chk ccall((:MatDestroy, $libpetsc), PetscErrorCode, (Ptr{CMat},), M) - return nothing - end +function LinearAlgebra.mul!( + y::AbstractVec{PetscLib, PetscScalar}, + M::AbstractMat{PetscLib, PetscScalar}, + x::AbstractVec{PetscLib, PetscScalar}, +) where {PetscLib, PetscScalar} + LibPETSc.MatMult(PetscLib, M, x, y) + return y +end - function setvalues!(M::AbstractMat{$PetscScalar}, row0idxs::Vector{$PetscInt}, col0idxs::Vector{$PetscInt}, rowvals::Array{$PetscScalar}, insertmode::InsertMode) - @chk ccall((:MatSetValues, $libpetsc), PetscErrorCode, - (CMat, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar},InsertMode), - M, length(row0idxs), row0idxs, length(col0idxs), col0idxs, rowvals, insertmode) - return nothing - end +function LinearAlgebra.mul!( + y::AbstractVec{PetscLib, PetscScalar}, + M::Adjoint{PetscScalar, AM}, + x::AbstractVec{PetscLib, PetscScalar}, +) where {PetscLib, PetscScalar, AM <: AbstractMat{PetscLib, PetscScalar}} + LibPETSc.MatMultHermitianTranspose(PetscLib, parent(M), x, y) + return y +end - function Base.setindex!(M::AbstractMat{$PetscScalar}, val, i::Integer, j::Integer) - @chk ccall((:MatSetValues, $libpetsc), PetscErrorCode, - (CMat, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}, InsertMode), - M, 1, Ref{$PetscInt}(i-1), 1, Ref{$PetscInt}(j-1), Ref{$PetscScalar}(val), INSERT_VALUES) - return val - end +function LinearAlgebra.mul!( + y::AbstractVec{PetscLib, PetscScalar}, + M::Transpose{PetscScalar, AM}, + x::AbstractVec{PetscLib, PetscScalar}, +) where {PetscLib, PetscScalar, AM <: AbstractMat{PetscLib, PetscScalar}} + LibPETSc.MatMultTranspose(PetscLib, parent(M), x, y) + return y +end - function assembled(A::AbstractMat{$PetscScalar}) - fr = Ref{PetscBool}() - @chk ccall((:MatAssembled, $libpetsc), PetscErrorCode, - (CMat, Ptr{PetscBool}), - A, fr) - return fr[]== PETSC_TRUE - end - function Base.getindex(M::AbstractMat{$PetscScalar}, i::Integer, j::Integer) - val = Ref{$PetscScalar}() - @chk ccall((:MatGetValues, $libpetsc), PetscErrorCode, - (CMat, - $PetscInt, Ptr{$PetscInt}, - $PetscInt, Ptr{$PetscInt}, - Ptr{$PetscScalar}), +const MatAT{PetscLib, PetscScalar} = Union{ + AbstractMat{PetscLib, PetscScalar}, + Transpose{PetscScalar, <:AbstractMat{PetscLib, PetscScalar}}, + Adjoint{PetscScalar, <:AbstractMat{PetscLib, PetscScalar}}, +} + +function LinearAlgebra.mul!( + y::Vector{PetscScalar}, + M::MatAT{PetscLib, PetscScalar}, + x::Vector{PetscScalar}, +) where {PetscScalar, PetscLib} + parent( + LinearAlgebra.mul!( + VecSeq(getlib(PetscLib), y), M, - 1, Ref{$PetscInt}(i-1), - 1, Ref{$PetscInt}(j-1), - val) - return val[] - end - - function assemblybegin(M::AbstractMat{$PetscScalar}, t::MatAssemblyType=MAT_FINAL_ASSEMBLY) - @chk ccall((:MatAssemblyBegin, $libpetsc), PetscErrorCode, (CMat, MatAssemblyType), M, t) - return nothing - end - function assemblyend(M::AbstractMat{$PetscScalar}, t::MatAssemblyType=MAT_FINAL_ASSEMBLY) - @chk ccall((:MatAssemblyEnd, $libpetsc), PetscErrorCode, (CMat, MatAssemblyType), M, t) - return nothing - end - #function view(mat::AbstractMat{$PetscScalar}, viewer::AbstractViewer{$PetscLib}=ViewerStdout($petsclib, mat.comm)) - # if assembled(mat) - # @chk ccall((:MatView, $libpetsc), PetscErrorCode, - # (CMat, CPetscViewer), - # mat, viewer); - # else - # error("not yet assembled") - # end - # return nothing - #end - function view(mat::AbstractMat{$PetscScalar}) - if assembled(mat) - comm = getcomm(mat); - viewer = ViewerStdout($petsclib, comm); - @chk ccall((:MatView, $libpetsc), PetscErrorCode, - (CMat, CPetscViewer), - mat, viewer); - else - error("not yet assembled") - end - return nothing - end - - #function Base.getindex(M::AbstractMat{$PetscScalar}, i::Integer, j::Integer) - # val = Ref{$PetscScalar}() - # @chk ccall((:MatGetValues, $libpetsc), PetscErrorCode, - # (CMat, $PetscInt, Ptr{$PetscInt}, $PetscInt, Ptr{$PetscInt}, Ptr{$PetscScalar}), - # M, 1, Ref{$PetscInt}(i-1), 1, Ref{$PetscInt}(j-1), val) - # return val[] - #end - - function ownershiprange(M::AbstractMat{$PetscScalar}) - r_lo = Ref{$PetscInt}() - r_hi = Ref{$PetscInt}() - @chk ccall((:MatGetOwnershipRange, $libpetsc), PetscErrorCode, - (CMat, Ptr{$PetscInt}, Ptr{$PetscInt}), M, r_lo, r_hi) - r_lo[]:(r_hi[]-$PetscInt(1)) - end - - - function Base.size(A::AbstractMat{$PetscScalar}) - m = Ref{$PetscInt}() - n = Ref{$PetscInt}() - @chk ccall((:MatGetSize, $libpetsc), PetscErrorCode, - (CMat, Ptr{$PetscInt}, Ptr{$PetscInt}), - A, m, n) - return (m[], n[]) - end - function Base.:(==)(A::AbstractMat{$PetscScalar}, B::AbstractMat{$PetscScalar}) - fr = Ref{PetscBool}() - @chk ccall((:MatEqual, $libpetsc), PetscErrorCode, - (CMat, CMat, Ptr{PetscBool}), - A, B, fr) - return fr[] == PETSC_TRUE - end - - function LinearAlgebra.issymmetric(A::AbstractMat{$PetscScalar}; tol=zero($PetscReal)) - fr = Ref{PetscBool}() - @chk ccall((:MatIsSymmetric, $libpetsc), PetscErrorCode, - (CMat, $PetscReal, Ptr{PetscBool}), - A, tol, fr) - return fr[] == PETSC_TRUE - end - function LinearAlgebra.ishermitian(A::AbstractMat{$PetscScalar}; tol=zero($PetscReal)) - fr = Ref{PetscBool}() - @chk ccall((:MatIsHermitian, $libpetsc), PetscErrorCode, - (CMat, $PetscReal, Ptr{PetscBool}), - A, tol, fr) - return fr[] == PETSC_TRUE - end - function LinearAlgebra.norm(M::AbstractMat{$PetscScalar}, normtype::NormType=NORM_FROBENIUS) - r_val = Ref{$PetscReal}() - @chk ccall((:MatNorm, $libpetsc), PetscErrorCode, - (CMat, NormType, Ptr{$PetscReal}), - M, normtype, r_val) - return r_val[] - end - - function LinearAlgebra.mul!(y::AbstractVec{$PetscScalar}, M::AbstractMat{$PetscScalar}, x::AbstractVec{$PetscScalar}) - @chk ccall((:MatMult, $libpetsc), PetscErrorCode, (CMat, CVec, CVec), M, x, y) - return y - end - function LinearAlgebra.mul!(y::AbstractVec{$PetscScalar}, M::Adjoint{T,A}, x::AbstractVec{$PetscScalar}) where {T,A<:AbstractMat{$PetscScalar}} - @chk ccall((:MatMultHermitianTranspose, $libpetsc), PetscErrorCode, (CMat, CVec, CVec), parent(M), x, y) - return y - end - function LinearAlgebra.mul!(y::AbstractVec{$PetscScalar}, M::Transpose{T,A}, x::AbstractVec{$PetscScalar}) where {T,A<:AbstractMat{$PetscScalar}} - @chk ccall((:MatMultTranspose, $libpetsc), PetscErrorCode, (CMat, CVec, CVec), parent(M), x, y) - return y - end - - + VecSeq(getlib(PetscLib), x), + ), + ) +end -end +function LinearAlgebra.issymmetric( + A::AbstractMat{PetscLib}; + tol = 0, +) where {PetscLib} + fr = Ref{PetscBool}() + LibPETSc.MatIsSymmetric(PetscLib, A, tol, fr) + return fr[] == PETSC_TRUE +end -function assemble(M::AbstractMat, t::MatAssemblyType=MAT_FINAL_ASSEMBLY) - assemblybegin(M, t) - assemblyend(M, t) +function LinearAlgebra.ishermitian( + A::AbstractMat{PetscLib}; + tol = 0, +) where {PetscLib} + fr = Ref{PetscBool}() + LibPETSc.MatIsHermitian(PetscLib, A, tol, fr) + return fr[] == PETSC_TRUE end +#= function MatSeqAIJ(S::SparseMatrixCSC{T}) where {T} PetscInt = inttype(T) m,n = size(S) @@ -418,14 +355,4 @@ function Base.copyto!(M::PETSc.MatSeqAIJ{T}, S::SparseMatrixCSC{T}) where {T} end assemble(M); end - -function Base.show(io::IO, ::MIME"text/plain", mat::AbstractMat) - _show(io, mat) -end -AbstractMat(A::Matrix) = MatSeqDense(A) -AbstractMat(A::SparseMatrixCSC) = MatSeqAIJ(A) - -const MatAT{T} = Union{AbstractMat{T}, Transpose{T, <:AbstractMat{T}}, Adjoint{T, <:AbstractMat{T}}} - -LinearAlgebra.mul!(y::AbstractVector{T}, M::MatAT{T}, x::AbstractVector{T}) where {T} = - parent(LinearAlgebra.mul!(AbstractVec(y), M, AbstractVec(x))) +=# diff --git a/src/sys.jl b/src/sys.jl index 5ec2d5f0..88380c5f 100644 --- a/src/sys.jl +++ b/src/sys.jl @@ -1,6 +1,6 @@ const CPetscObject = Ptr{Cvoid} -const UnionPetscTypes = Union{Options, AbstractVec} +const UnionPetscTypes = Union{Options, AbstractVec, AbstractMat} # allows us to pass PETSc_XXX objects directly into CXXX ccall signatures Base.cconvert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj @@ -12,7 +12,7 @@ function Base.unsafe_convert(::Type{Ptr{CPetscObject}}, obj::UnionPetscTypes) end function getcomm( - obj::Union{AbstractVec{PetscLib}}, + obj::Union{AbstractVec{PetscLib}, AbstractMat{PetscLib}}, ) where {PetscLib} comm = MPI.Comm() LibPETSc.PetscObjectGetComm(PetscLib, obj, comm) diff --git a/src/vec.jl b/src/vec.jl index 14440320..72a47a35 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -52,7 +52,7 @@ function VecSeq( petsclib::PetscLib, array::Vector{PetscScalar}; blocksize = 1, -) where {PetscLib, PetscScalar} +) where {PetscLib <: PetscLibType, PetscScalar} comm = MPI.COMM_SELF @assert initialized(petsclib) @assert PetscScalar == petsclib.PetscScalar diff --git a/test/mat.jl b/test/mat.jl new file mode 100644 index 00000000..111fcb89 --- /dev/null +++ b/test/mat.jl @@ -0,0 +1,143 @@ +using Test +using PETSc +using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian + +@testset "MatSeqAIJ" begin + num_rows, num_cols = 5, 7 + nz_int = 2 + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + nz_vec = petsclib.PetscInt.([0, 3, 2, 1, 0]) + + A = PETSc.MatSeqAIJ(petsclib, num_rows, num_cols, nz_int) + + @test size(A) == (num_rows, num_cols) + B = PETSc.MatSeqAIJ(petsclib, num_rows, num_cols, nz_int) + PETSc.assemble(A) + PETSc.assemble(B) + # both empty + @test A == B + + C = PETSc.MatSeqAIJ(petsclib, num_rows, num_cols, nz_vec) + @test size(A) == (num_rows, num_cols) + PETSc.assemble(C) + # both empty + @test A == C + + if PetscScalar <: Real + D = PETSc.MatSeqAIJ(petsclib, num_rows, num_cols, nz_int) + D[1, [1, 2]] .= [1, 2] + D[2, [3, 4]] .= [3, 4] + D[5, [3, 4]] .= [3, 4] + PETSc.assemble(D) + + DJ = zeros(PetscScalar, num_rows, num_cols) + DJ[1, [1, 2]] .= [1, 2] + DJ[2, [3, 4]] .= [3, 4] + DJ[5, [3, 4]] .= [3, 4] + else + D = PETSc.MatSeqAIJ(petsclib, num_rows, num_cols, nz_int) + D[1, [1, 2]] .= [1, 2im] + D[2, [3, 4]] .= [3, 4im] + D[5, [3, 4]] .= [3, 4im] + PETSc.assemble(D) + + DJ = zeros(PetscScalar, num_rows, num_cols) + DJ[1, [1, 2]] .= [1, 2im] + DJ[2, [3, 4]] .= [3, 4im] + DJ[5, [3, 4]] .= [3, 4im] + end + + E = PETSc.MatSeqAIJ(petsclib, num_rows, num_cols, nz_vec) + E[2, [1, 3, 4]] .= [1, 3, 4] + E[3, [3, 4]] .= [3, 4] + E[4, [5]] .= [6] + PETSc.assemble(E) + + @test A != E + @test D != E + + # Test norm + @test norm(A) == 0 + @test norm(D) ≈ norm(DJ) + + x = PetscScalar.(Array(1:num_cols)) + y = zeros(PetscScalar, num_rows) + vec_x = PETSc.VecSeq(petsclib, copy(x)) + vec_y = PETSc.VecSeq(petsclib, copy(y)) + + # Test mul! + mul!(vec_y, D, vec_x) + y = DJ * x + @test all(vec_y.array .≈ y) + @test all(DJ * x .≈ D * x) + + mul!(vec_x, Adjoint(D), vec_y) + x = Adjoint(DJ) * y + @test all(vec_x.array .≈ x) + + mul!(vec_x, Transpose(D), vec_y) + x = Transpose(DJ) * y + @test all(vec_x.array .≈ x) + + # test issymmetric and ishermitian + if PetscScalar <: Real + A = PETSc.MatSeqAIJ(petsclib, 5, 5, 2) + A[1, 1] = 1 + A[2, 1] = -2 + A[1, 2] = -2 + PETSc.assemble(A) + + B = PETSc.MatSeqAIJ(petsclib, 5, 5, 2) + B[1, 1] = 1 + B[2, 1] = 2 + B[1, 2] = -2 + PETSc.assemble(B) + + @test issymmetric(A) + @test ishermitian(A) + @test !issymmetric(B) + @test !ishermitian(B) + else + A = PETSc.MatSeqAIJ(petsclib, 5, 5, 2) + A[1, 1] = 1 + A[2, 1] = -2 + im + A[1, 2] = -2 - im + PETSc.assemble(A) + + B = PETSc.MatSeqAIJ(petsclib, 5, 5, 2) + B[1, 1] = 1 + B[2, 1] = -2 + im + B[1, 2] = -2 + im + PETSc.assemble(B) + @test !issymmetric(A) + @test ishermitian(A) + @test issymmetric(B) + @test !ishermitian(B) + end + + PETSc.finalize(petsclib) + end +end + +@testset "MatSeqDense" begin + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + Ajl = PetscScalar.([ + 1 2 3 4 + 5 6 7 8 + 9 10 11 12 + 13 14 15 16 + ]) + + x = PetscScalar.(collect(1:4)) + + A = PETSc.MatSeqDense(petsclib, copy(Ajl)) + + @test all(A * x .≈ Ajl * x) + + PETSc.finalize(petsclib) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 410f36ba..a02d2207 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ include("init.jl") include("options.jl") include("vec.jl") -# include("mat.jl") +include("mat.jl") From b25f87c724b92665a15e202625fabdf01c11c6b7 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 19 Jul 2021 16:27:01 -0700 Subject: [PATCH 06/53] Add back matshell --- src/PETSc.jl | 2 +- src/matshell.jl | 132 ++++++++++++++++++++++++++++++++--------------- src/vec.jl | 10 ++-- test/matshell.jl | 23 +++++++++ test/runtests.jl | 1 + 5 files changed, 118 insertions(+), 50 deletions(-) create mode 100644 test/matshell.jl diff --git a/src/PETSc.jl b/src/PETSc.jl index 9192ee57..87d53f93 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -25,7 +25,7 @@ include("options.jl") # include("ref.jl") include("vec.jl") include("mat.jl") -# include("matshell.jl") +include("matshell.jl") # include("dm.jl") # include("dmda.jl") # include("dmstag.jl") diff --git a/src/matshell.jl b/src/matshell.jl index 98571bbd..fc23af87 100644 --- a/src/matshell.jl +++ b/src/matshell.jl @@ -1,60 +1,106 @@ """ - MatShell{T}(obj, m, n) - -Create a `m×n` PETSc shell matrix object wrapping `obj`. - -If `obj` is a `Function`, then the multiply action `obj(y,x)`; otherwise it calls `mul!(y, obj, x)`. -This can be changed by defining `PETSc._mul!`. - + MatShell( + petsclib::PetscLib, + obj::OType, + comm::MPI.Comm, + local_rows, + local_cols, + global_rows = LibPETSc.PETSC_DECIDE, + global_cols = LibPETSc.PETSC_DECIDE, + ) + +Create a `global_rows X global_cols` PETSc shell matrix object wrapping `obj` +with local size `local_rows X local_cols`. + +The `obj` will be registered as an `MATOP_MULT` function and if if `obj` is a +`Function`, then the multiply action `obj(y,x)`; otherwise it calls `mul!(y, +obj, x)`. + +if `comm == MPI.COMM_SELF` then the garbage connector can finalize the object, +otherwise the user is responsible for calling [`destroy`](@ref). + +# External Links +$(_doc_external("Mat/MatCreateShell")) +$(_doc_external("Mat/MatShellSetOperation")) +$(_doc_external("Mat/MATOP_MULT")) """ -mutable struct MatShell{T,A} <: AbstractMat{T} +mutable struct MatShell{PetscLib, PetscScalar, OType} <: + AbstractMat{PetscLib, PetscScalar} ptr::CMat - obj::A + obj::OType end +struct MatOp{PetscLib, PetscInt, Op} end + +function (::MatOp{PetscLib, PetscInt, LibPETSc.MATOP_MULT})( + M::CMat, + cx::CVec, + cy::CVec, +)::PetscInt where {PetscLib, PetscInt} + r_ctx = Ref{Ptr{Cvoid}}() + LibPETSc.MatShellGetContext(PetscLib, M, r_ctx) + ptr = r_ctx[] + mat = unsafe_pointer_to_objref(ptr) -struct MatOp{T,Op} end + PetscScalar = getlib(PetscLib).PetscScalar + x = unsafe_localarray(WrapVec{PetscLib, PetscScalar}(cx); write = false) + y = unsafe_localarray(WrapVec{PetscLib, PetscScalar}(cy); read = false) + _mul!(y, mat, x) -function _mul!(y,mat::MatShell{T,F},x) where {T, F<:Function} + Base.finalize(y) + Base.finalize(x) + return PetscInt(0) +end + +function _mul!( + y, + mat::MatShell{PetscLib, PetscScalar, F}, + x, +) where {PetscLib, PetscScalar, F <: Function} mat.obj(y, x) end -function _mul!(y,mat::MatShell{T},x) where {T} +function _mul!(y, mat::MatShell, x) where {T} LinearAlgebra.mul!(y, mat.obj, x) end -MatShell{T}(obj, m, n) where {T} = MatShell{T}(obj, MPI.COMM_SELF, m, n, m, n) - - -@for_libpetsc begin - function MatShell{$PetscScalar}(obj::A, comm::MPI.Comm, m, n, M, N) where {A} - mat = MatShell{$PetscScalar,A}(C_NULL, obj) - # we use the MatShell object itsel - ctx = pointer_from_objref(mat) - @chk ccall((:MatCreateShell, $libpetsc), PetscErrorCode, - (MPI.MPI_Comm,$PetscInt,$PetscInt,$PetscInt,$PetscInt,Ptr{Cvoid},Ptr{CMat}), - comm, m, n, M, N, ctx, mat) - - mulptr = @cfunction(MatOp{$PetscScalar, MATOP_MULT}(), $PetscInt, (CMat, CVec, CVec)) - @chk ccall((:MatShellSetOperation, $libpetsc), PetscErrorCode, (CMat, MatOperation, Ptr{Cvoid}), mat, MATOP_MULT, mulptr) - return mat - end - - function (::MatOp{$PetscScalar, MATOP_MULT})(M::CMat,cx::CVec,cy::CVec)::$PetscInt - r_ctx = Ref{Ptr{Cvoid}}() - @chk ccall((:MatShellGetContext, $libpetsc), PetscErrorCode, (CMat, Ptr{Ptr{Cvoid}}), M, r_ctx) - ptr = r_ctx[] - mat = unsafe_pointer_to_objref(ptr) - - x = unsafe_localarray($PetscScalar, cx; write=false) - y = unsafe_localarray($PetscScalar, cy; read=false) - - _mul!(y,mat,x) - - Base.finalize(y) - Base.finalize(x) - return $PetscInt(0) +# We have to use the macro here because of the @cfunction +LibPETSc.@for_petsc function MatShell( + petsclib::$PetscLib, + obj::OType, + comm::MPI.Comm, + local_rows, + local_cols, + global_rows = LibPETSc.PETSC_DECIDE, + global_cols = LibPETSc.PETSC_DECIDE, +) where {OType} + mat = MatShell{$PetscLib, $PetscScalar, OType}(C_NULL, obj) + + # we use the MatShell object itself + ctx = pointer_from_objref(mat) + + LibPETSc.MatCreateShell( + petsclib, + comm, + local_rows, + local_cols, + global_rows, + global_cols, + pointer_from_objref(mat), + mat, + ) + + mulptr = @cfunction( + MatOp{$PetscLib, $PetscInt, LibPETSc.MATOP_MULT}(), + $PetscInt, + (CMat, CVec, CVec) + ) + LibPETSc.MatShellSetOperation(petsclib, mat, LibPETSc.MATOP_MULT, mulptr) + + if comm == MPI.COMM_SELF + finalizer(destroy, mat) end + return mat end diff --git a/src/vec.jl b/src/vec.jl index 72a47a35..b50e88b8 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -18,12 +18,10 @@ Base.eltype( ) where {PetscLib, PetscScalar} = PetscScalar Base.size(v::AbstractVec) = (length(v),) -# allows us to pass XXVec objects directly into CVec ccall signatures -Base.cconvert(::Type{CVec}, obj::AbstractVec) = obj.ptr -# allows us to pass XXVec objects directly into Ptr{CVec} ccall signatures -Base.unsafe_convert(::Type{Ptr{CVec}}, obj::AbstractVec) = - convert(Ptr{CVec}, pointer_from_objref(obj)) - +mutable struct WrapVec{PetscLib, PetscScalar} <: + AbstractVec{PetscLib, PetscScalar} + ptr::CVec +end """ VecSeq(petsclib, v::Vector) diff --git a/test/matshell.jl b/test/matshell.jl new file mode 100644 index 00000000..3e2126f8 --- /dev/null +++ b/test/matshell.jl @@ -0,0 +1,23 @@ +using Test +using PETSc +using MPI + +@testset "MatShell" begin + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + + local_rows = 10 + local_cols = 5 + f!(x, y) = x .= [2y; 3y] + x_jl = collect + + matshell = + PETSc.MatShell(petsclib, f!, MPI.COMM_SELF, local_rows, local_cols) + x = PetscScalar.(collect(1:5)) + @test matshell * x == [2x; 3x] + + PETSc.destroy(matshell) + PETSc.finalize(petsclib) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index a02d2207..28477ea8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,3 +2,4 @@ include("init.jl") include("options.jl") include("vec.jl") include("mat.jl") +include("matshell.jl") From 90086fe83a8522a660af5d7f149f35ce59eccbc4 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 19 Jul 2021 20:59:47 -0700 Subject: [PATCH 07/53] Remove some `getlibs`s and VecSeq->VecSeqWithArray --- src/LibPETSc_lib.jl | 24 ++++++++--------- src/mat.jl | 26 +++++++++--------- src/matshell.jl | 6 ++--- src/vec.jl | 65 ++++++++++++++++++++++++++++++--------------- test/mat.jl | 4 +-- test/vec.jl | 4 +-- 6 files changed, 75 insertions(+), 54 deletions(-) diff --git a/src/LibPETSc_lib.jl b/src/LibPETSc_lib.jl index 4a95e7d8..8b3b10d1 100644 --- a/src/LibPETSc_lib.jl +++ b/src/LibPETSc_lib.jl @@ -13,18 +13,18 @@ function PetscLibType{ST, IT}(petsc_library) where {ST, IT} LT = typeof(petsc_library) return PetscLibType{ST, IT, LT}(petsc_library) end -const UnionPetscLibType = Union{PetscLibType, Type{PetscLibType}} - -function Base.getproperty(petsclib::PetscLibType, name::Symbol) - if name == :PetscScalar - return scalartype(petsclib) - elseif name == :PetscReal - return realtype(petsclib) - elseif name == :PetscInt - return inttype(petsclib) - else - return getfield(petsclib, name) - end +const UnionPetscLibType = Union{PetscLibType, Type{<:PetscLibType}} + +function Base.getproperty(petsclib::UnionPetscLibType, name::Symbol) + if name == :PetscScalar + return scalartype(petsclib) + elseif name == :PetscReal + return realtype(petsclib) + elseif name == :PetscInt + return inttype(petsclib) + else + return getfield(petsclib, name) + end end """ diff --git a/src/mat.jl b/src/mat.jl index b2be4213..52631795 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -164,9 +164,8 @@ function assemblyend( end function Base.size(A::AbstractMat{PetscLib}) where {PetscLib} - petsclib = getlib(PetscLib) - m = Ref{petsclib.PetscInt}() - n = Ref{petsclib.PetscInt}() + m = Ref{PetscLib.PetscInt}() + n = Ref{PetscLib.PetscInt}() LibPETSc.MatGetSize(PetscLib, A, m, n) return (m[], n[]) end @@ -219,8 +218,8 @@ function setvalues!( num_rows = length(row0idxs), num_cols = length(col0idxs), ) where {PetscLib, PetscScalar, PetscInt} - @assert PetscScalar == getlib(PetscLib).PetscScalar - @assert PetscInt == getlib(PetscLib).PetscInt + @assert PetscScalar == PetscLib.PetscScalar + @assert PetscInt == PetscLib.PetscInt LibPETSc.MatSetValues( PetscLib, M, @@ -240,8 +239,8 @@ function Base.setindex!( i::Integer, j::Integer, ) where {PetscLib} - PetscInt = getlib(PetscLib).PetscInt - PetscScalar = getlib(PetscLib).PetscScalar + PetscInt = PetscLib.PetscInt + PetscScalar = PetscLib.PetscScalar setvalues!( M, [PetscInt(i - 1)], @@ -256,7 +255,7 @@ function LinearAlgebra.norm( M::AbstractMat{PetscLib}, normtype::NormType = NORM_FROBENIUS, ) where {PetscLib} - PetscReal = getlib(PetscLib).PetscReal + PetscReal = PetscLib.PetscReal r_val = Ref{PetscReal}() LibPETSc.MatNorm(PetscLib, M, normtype, r_val) return r_val[] @@ -300,13 +299,12 @@ function LinearAlgebra.mul!( M::MatAT{PetscLib, PetscScalar}, x::Vector{PetscScalar}, ) where {PetscScalar, PetscLib} - parent( - LinearAlgebra.mul!( - VecSeq(getlib(PetscLib), y), - M, - VecSeq(getlib(PetscLib), x), - ), + LinearAlgebra.mul!( + VecSeqWithArray(PetscLib, y), + M, + VecSeqWithArray(PetscLib, x), ) + return y end function LinearAlgebra.issymmetric( diff --git a/src/matshell.jl b/src/matshell.jl index fc23af87..392233df 100644 --- a/src/matshell.jl +++ b/src/matshell.jl @@ -42,9 +42,9 @@ function (::MatOp{PetscLib, PetscInt, LibPETSc.MATOP_MULT})( ptr = r_ctx[] mat = unsafe_pointer_to_objref(ptr) - PetscScalar = getlib(PetscLib).PetscScalar - x = unsafe_localarray(WrapVec{PetscLib, PetscScalar}(cx); write = false) - y = unsafe_localarray(WrapVec{PetscLib, PetscScalar}(cy); read = false) + PetscScalar = PetscLib.PetscScalar + x = unsafe_localarray(VecPtr(PetscLib, cx); write = false) + y = unsafe_localarray(VecPtr(PetscLib, cy); read = false) _mul!(y, mat, x) diff --git a/src/vec.jl b/src/vec.jl index b50e88b8..434e9ea0 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -1,5 +1,5 @@ # AbstractVec -# - VecSeq: wrap +# - VecSeqWithArray: wrap # - VecMPI (TODO) # - VecGhost (TODO) # for the MPI variants we won't be able to attach finalizers, as destroy needs to be called collectively. @@ -18,13 +18,39 @@ Base.eltype( ) where {PetscLib, PetscScalar} = PetscScalar Base.size(v::AbstractVec) = (length(v),) -mutable struct WrapVec{PetscLib, PetscScalar} <: +function destroy(v::AbstractVec{PetscLib}) where {PetscLib} + finalized(PetscLib) || LibPETSc.VecDestroy(PetscLib, v) + return nothing +end + +""" + VecPtr(petsclib, v::CVec, own) + +Container type for a PETSc Vec that is just a raw pointer. + +If the `own` then the finalizer is set on the vector; calling `destroy` when +`!own` is a no-op. +""" +mutable struct VecPtr{PetscLib, PetscScalar} <: AbstractVec{PetscLib, PetscScalar} ptr::CVec end +function VecPtr( + petsclib::PetscLib, + ptr::CVec, + own, +) where {PetscLib <: PetscLibType} + v = VecPtr{PetscLib, petsclib.PetscScalar}(ptr) + if seq_finalize && occursin("seq", getpetsctype(v)) + finalizer(destroy, v) + end + return v +end +VecPtr(::Type{PetscLib}, x...) where {PetscLib <: PetscLibType} = + VecPtr(getlib(PetscLib), x...) """ - VecSeq(petsclib, v::Vector) + VecSeqWithArray(petsclib, v::Vector) A standard, sequentially-stored serial PETSc vector, wrapping the Julia vector `v`. @@ -39,14 +65,14 @@ performed automatically # External Links $(_doc_external("Vec/VecCreateSeqWithArray")) """ -mutable struct VecSeq{PetscLib, PetscScalar} <: +mutable struct VecSeqWithArray{PetscLib, PetscScalar} <: AbstractVec{PetscLib, PetscScalar} ptr::CVec array::Vector{PetscScalar} end -Base.parent(v::VecSeq) = v.array +Base.parent(v::VecSeqWithArray) = v.array -function VecSeq( +function VecSeqWithArray( petsclib::PetscLib, array::Vector{PetscScalar}; blocksize = 1, @@ -54,7 +80,7 @@ function VecSeq( comm = MPI.COMM_SELF @assert initialized(petsclib) @assert PetscScalar == petsclib.PetscScalar - v = VecSeq{PetscLib, PetscScalar}(C_NULL, array) + v = VecSeqWithArray{PetscLib, PetscScalar}(C_NULL, array) LibPETSc.VecCreateSeqWithArray( petsclib, comm, @@ -66,23 +92,23 @@ function VecSeq( finalizer(destroy, v) return v end - -function destroy(v::AbstractVec{PetscLib}) where {PetscLib} - finalized(PetscLib) || LibPETSc.VecDestroy(PetscLib, v) - return nothing +function VecSeqWithArray( + ::Type{PetscLib}, + x...; + kw..., +) where {PetscLib <: PetscLibType} + VecSeqWithArray(getlib(PetscLib), x...; kw...) end function Base.length(v::AbstractVec{PetscLib}) where {PetscLib} - petsclib = getlib(PetscLib) - PetscInt = petsclib.PetscInt + PetscInt = PetscLib.PetscInt r_sz = Ref{PetscInt}() LibPETSc.VecGetSize(PetscLib, v, r_sz) return r_sz[] end function locallength(v::AbstractVec{PetscLib}) where {PetscLib} - petsclib = getlib(PetscLib) - PetscInt = petsclib.PetscInt + PetscInt = PetscLib.PetscInt r_sz = Ref{PetscInt}() LibPETSc.VecGetLocalSize(PetscLib, v, r_sz) return r_sz[] @@ -92,8 +118,7 @@ function LinearAlgebra.norm( v::AbstractVec{PetscLib}, normtype::LibPETSc.NormType = LibPETSc.NORM_2, ) where {PetscLib} - petsclib = getlib(PetscLib) - PetscReal = petsclib.PetscReal + PetscReal = PetscLib.PetscReal r_val = Ref{PetscReal}() LibPETSc.VecNorm(PetscLib, v, normtype, r_val) return r_val[] @@ -131,8 +156,7 @@ function ownershiprange( vec::AbstractVec{PetscLib}, base_one::Bool = true, ) where {PetscLib} - petsclib = getlib(PetscLib) - PetscInt = petsclib.PetscInt + PetscInt = PetscLib.PetscInt r_lo = Ref{PetscInt}() r_hi = Ref{PetscInt}() LibPETSc.VecGetOwnershipRange(PetscLib, vec, r_lo, r_hi) @@ -163,8 +187,7 @@ function unsafe_localarray( read::Bool = true, write::Bool = true, ) where {PetscLib} - petsclib = getlib(PetscLib) - PetscScalar = petsclib.PetscScalar + PetscScalar = PetscLib.PetscScalar r_pv = Ref{Ptr{PetscScalar}}() if write && read LibPETSc.VecGetArray(PetscLib, vec, r_pv) diff --git a/test/mat.jl b/test/mat.jl index 111fcb89..ef0b14a2 100644 --- a/test/mat.jl +++ b/test/mat.jl @@ -64,8 +64,8 @@ using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian x = PetscScalar.(Array(1:num_cols)) y = zeros(PetscScalar, num_rows) - vec_x = PETSc.VecSeq(petsclib, copy(x)) - vec_y = PETSc.VecSeq(petsclib, copy(y)) + vec_x = PETSc.VecSeqWithArray(petsclib, copy(x)) + vec_y = PETSc.VecSeqWithArray(petsclib, copy(y)) # Test mul! mul!(vec_y, D, vec_x) diff --git a/test/vec.jl b/test/vec.jl index 14201b41..319aa565 100644 --- a/test/vec.jl +++ b/test/vec.jl @@ -2,13 +2,13 @@ using Test using PETSc using LinearAlgebra: norm -@testset "VecSeq" begin +@testset "VecSeqWithArray" begin N = 10 for petsclib in PETSc.petsclibs PETSc.initialize(petsclib) PetscScalar = petsclib.PetscScalar x = rand(PetscScalar, N) - petsc_x = PETSc.VecSeq(petsclib, x) + petsc_x = PETSc.VecSeqWithArray(petsclib, x) @test length(petsc_x) == N @test norm(petsc_x) ≈ norm(x) From e5b97519b354889cdfca3225ec18870a9a0207a4 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 19 Jul 2021 21:52:53 -0700 Subject: [PATCH 08/53] Add VecMPI --- src/LibPETSc.jl | 4 +- src/vec.jl | 214 +++++++++++++++++++++++++++++++++++++++++++---- test/mpivec.jl | 71 ++++++++++++++++ test/runtests.jl | 12 +++ test/vec.jl | 22 +++++ 5 files changed, 304 insertions(+), 19 deletions(-) create mode 100644 test/mpivec.jl diff --git a/src/LibPETSc.jl b/src/LibPETSc.jl index 0ade676b..1390d1a6 100644 --- a/src/LibPETSc.jl +++ b/src/LibPETSc.jl @@ -29,7 +29,9 @@ export PetscLibType, NORM_2, NORM_FROBENIUS, NORM_INFINITY, - NORM_1_AND_2 + NORM_1_AND_2, + PETSC_DETERMINE, + PETSC_DECIDE include("LibPETSc_const.jl") include("LibPETSc_startup.jl") diff --git a/src/vec.jl b/src/vec.jl index 434e9ea0..1746ca63 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -1,9 +1,3 @@ -# AbstractVec -# - VecSeqWithArray: wrap -# - VecMPI (TODO) -# - VecGhost (TODO) -# for the MPI variants we won't be able to attach finalizers, as destroy needs to be called collectively. - const CVec = Ptr{Cvoid} abstract type AbstractVec{PetscLib, PetscScalar} <: AbstractVector{PetscScalar} end @@ -100,6 +94,122 @@ function VecSeqWithArray( VecSeqWithArray(getlib(PetscLib), x...; kw...) end +""" + VecSeq(petsclib, n::Int) + +A standard, sequentially-stored serial PETSc vector for `petsclib.PetscScalar` +of length `n`. + +# External Links +$(_doc_external("Vec/VecCreateSeq")) +""" +mutable struct VecSeq{PetscLib, PetscScalar} <: + AbstractVec{PetscLib, PetscScalar} + ptr::CVec +end + +function VecSeq(petsclib::PetscLib, n::Int) where {PetscLib <: PetscLibType} + comm = MPI.COMM_SELF + @assert initialized(petsclib) + v = VecSeq{PetscLib, petsclib.PetscScalar}(C_NULL) + LibPETSc.VecCreateSeq(petsclib, comm, n, v) + finalizer(destroy, v) + return v +end + +""" + VecMPI( + petsclib, + comm:MPI.Comm, + local_length; + global_length = PETSC_DETERMINE + ) + +An sequentially-stored MPI PETSc vector for `petsclib.PetscScalar` of local +length `local_length` and global length `global_length` without ghost elements. + +If `global_length isa Int` then `local_length` can be set to `PETSC_DECIDE`. + +# External Links +$(_doc_external("Vec/VecCreateMPI")) + +!!! note + + The user is responsible for calling `destroy(vec)` on the `Vec` since + this cannot be handled by the garbage collector do to the MPI nature of the + object. +""" +mutable struct VecMPI{PetscLib, PetscScalar} <: + AbstractVec{PetscLib, PetscScalar} + ptr::CVec +end + +function VecMPI( + petsclib::PetscLib, + comm::MPI.Comm, + local_length; + global_length = PETSC_DETERMINE, +) where {PetscLib <: PetscLibType} + @assert initialized(petsclib) + @assert local_length != PETSC_DECIDE || global_length != PETSC_DETERMINE + v = VecMPI{PetscLib, petsclib.PetscScalar}(C_NULL) + LibPETSc.VecCreateMPI(petsclib, comm, local_length, global_length, v) + return v +end + +""" + VecGhost( + petsclib, + comm:MPI.Comm, + local_length + ghost::Vector{PetscInt}; + global_length = PETSC_DETERMINE, + num_ghost = length(ghost), + ) + +An sequentially-stored MPI PETSc vector for `petsclib.PetscScalar` of local +length `local_length` and global length `global_length` with ghost elements. + +If `global_length isa Int` then `local_length` can be set to `PETSC_DECIDE`. + +# External Links +$(_doc_external("Vec/VecCreateGhost")) + +!!! note + + The user is responsible for calling `destroy(vec)` on the `Vec` since + this cannot be handled by the garbage collector do to the MPI nature of the + object. +""" +mutable struct VecGhost{PetscLib, PetscScalar} <: + AbstractVec{PetscLib, PetscScalar} + ptr::CVec +end + +function VecGhost( + petsclib::PetscLib, + comm::MPI.Comm, + local_length, + ghost::Vector{PetscInt}; + global_length = PETSC_DETERMINE, + num_ghost = length(ghost), +) where {PetscLib <: PetscLibType, PetscInt} + @assert initialized(petsclib) + @assert PetscInt == PetscLib.PetscInt + @assert local_length != PETSC_DECIDE || global_length != PETSC_DETERMINE + v = VecGhost{PetscLib, petsclib.PetscScalar}(C_NULL) + LibPETSc.VecCreateGhost( + petsclib, + comm, + local_length, + global_length, + num_ghost, + ghost, + v, + ) + return v +end + function Base.length(v::AbstractVec{PetscLib}) where {PetscLib} PetscInt = PetscLib.PetscInt r_sz = Ref{PetscInt}() @@ -107,6 +217,61 @@ function Base.length(v::AbstractVec{PetscLib}) where {PetscLib} return r_sz[] end +function Base.getindex(v::AbstractVec{PetscLib}, i::Integer) where {PetscLib} + vals = [PetscLib.PetscScalar(0)] + LibPETSc.VecGetValues(PetscLib, v, 1, Ref{PetscLib.PetscInt}(i - 1), vals) + return vals[1] +end + +""" + setvalues!( + v::AbstractVec, + indices::Vector{PetscInt}, + vals::Array{PetscScalar}, + insertmode::InsertMode, + ) + +Assign the values `vals` in 0-based global `indices` of `vec`. The `insertmode` +can be `INSERT_VALUES` or `ADD_VALUES`. + +!!! warning + This function uses 0-based indexing! + +# External Links +$(_doc_external("Vec/VecSetValues")) +""" +function setvalues!( + v::AbstractVec{PetscLib}, + idxs0::Vector{PetscInt}, + vals::Array{PetscScalar}, + insertmode::InsertMode; + num_idxs = length(idxs0) +) where {PetscLib, PetscInt, PetscScalar} + @assert length(vals) >= num_idxs + @assert PetscInt == PetscLib.PetscInt + @assert PetscScalar == PetscLib.PetscScalar + LibPETSc.VecSetValues(PetscLib, v, num_idxs, idxs0, vals, insertmode) + return nothing +end + + +function Base.setindex!( + v::AbstractVec{PetscLib}, + val, + i::Integer, +) where {PetscLib} + LibPETSc.VecSetValues( + PetscLib, + v, + 1, + Ref{PetscLib.PetscInt}(i - 1), + Ref{PetscLib.PetscScalar}(val), + INSERT_VALUES, + ) + + return val +end + function locallength(v::AbstractVec{PetscLib}) where {PetscLib} PetscInt = PetscLib.PetscInt r_sz = Ref{PetscInt}() @@ -135,7 +300,7 @@ Base.show(io::IO, vec::AbstractVec) = _show(io, vec) Base.show(io::IO, ::MIME"text/plain", vec::AbstractVec) = _show(io, vec) """ - ownership_range(vec::AbstractVec, [base_one = true]) + ownershiprange(vec::AbstractVec, [base_one = true]) The range of indices owned by this processor, assuming that the `vec` is laid out with the first `n1` elements on the first processor, next `n2` elements on @@ -248,15 +413,28 @@ function with_unsafe_localarray!(f!, v::AbstractVec; kwargs...) Base.finalize(array) end -#= -@for_libpetsc begin - function assemblybegin(V::AbstractVec{$PetscScalar}) - @chk ccall((:VecAssemblyBegin, $libpetsc), PetscErrorCode, (CVec,), V) - return nothing - end - function assemblyend(V::AbstractVec{$PetscScalar}) - @chk ccall((:VecAssemblyEnd, $libpetsc), PetscErrorCode, (CVec,), V) - return nothing - end +""" + assemblybegin!(vec::AbstractVec) + +Begin assembling `vec` + +# External Links +$(_doc_external("Vec/VecAssemblyBegin")) +""" +function assemblybegin!(vec::AbstractVec{PetscLib}) where {PetscLib} + LibPETSc.VecAssemblyBegin(PetscLib, vec) + return nothing +end + +""" + assemblyend!(vec::AbstractVec) + +Finish assembling `vec` + +# External Links +$(_doc_external("Vec/VecAssemblyEnd")) +""" +function assemblyend!(vec::AbstractVec{PetscLib}) where {PetscLib} + LibPETSc.VecAssemblyEnd(PetscLib, vec) + return nothing end -=# diff --git a/test/mpivec.jl b/test/mpivec.jl new file mode 100644 index 00000000..1462e84c --- /dev/null +++ b/test/mpivec.jl @@ -0,0 +1,71 @@ +using Test +using MPI +MPI.Initialized() || MPI.Init() +using PETSc +using LinearAlgebra: norm + +@testset "VecMPI" begin + comm = MPI.COMM_WORLD + mpisize = MPI.Comm_size(comm) + mpirank = MPI.Comm_rank(comm) + + # local first and last value + n0 = sum(10 .+ (0:mpirank)) - 10 + n1 = sum(10 .+ (0:(mpirank + 1))) - 11 + + # global last value + ne = sum(10 .+ (0:mpisize)) - 11 + exact_length = ne + 1 + exact_norm = norm(0:ne) + + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + + for version in 1:2 + if version == 1 + # Create using local size + petsc_x = PETSc.VecMPI(petsclib, comm, n1 - n0 + 1) + + # check the data ownership + rng = n0:n1 + @test rng == PETSc.ownershiprange(petsc_x, false) + else + # Create using local size + petsc_x = PETSc.VecMPI( + petsclib, + comm, + PETSc.PETSC_DECIDE; + global_length = exact_length, + ) + + # get the data ownership + rng = PETSc.ownershiprange(petsc_x, false) + end + + # insert some values + julia_x = PetscScalar.(rng) + inds = PetscInt.(rng) + # 0-based + PETSc.setvalues!(petsc_x, inds, julia_x, PETSc.INSERT_VALUES) + + PETSc.assemblybegin!(petsc_x) + PETSc.assemblyend!(petsc_x) + + @test length(petsc_x) == exact_length + vec_norm = norm(petsc_x) + @test exact_norm ≈ vec_norm + # 1-based + @test petsc_x[rng .+ 1] == julia_x + + PETSc.with_unsafe_localarray!(petsc_x) do x + @test x == julia_x + end + + PETSc.destroy(petsc_x) + + end + PETSc.finalize(petsclib) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 28477ea8..59b843ee 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,3 +1,15 @@ +using Test +using MPI: mpiexec + +# Do the MPI tests first so we do not have mpi running inside MPI +@testset "mpi tests" begin + @test mpiexec() do mpi_cmd + cmd = `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no --project mpivec.jl` + success(pipeline(cmd, stderr = stderr)) + end +end + +# Run the serial tests include("init.jl") include("options.jl") include("vec.jl") diff --git a/test/vec.jl b/test/vec.jl index 319aa565..c08dfc4f 100644 --- a/test/vec.jl +++ b/test/vec.jl @@ -38,3 +38,25 @@ using LinearAlgebra: norm PETSc.finalize(petsclib) end end + +@testset "VecSeq" begin + N = 10 + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + petsc_x = PETSc.VecSeq(petsclib, N) + @test length(petsc_x) == N + + @test PETSc.ownershiprange(petsc_x) == 1:N + @test PETSc.ownershiprange(petsc_x, false) == 0:(N - 1) + + x = rand(PetscScalar, N) + PETSc.with_unsafe_localarray!(petsc_x) do x2 + x2 .= x + end + @test norm(petsc_x) ≈ norm(x) + + PETSc.destroy(petsc_x) + PETSc.finalize(petsclib) + end +end From f814d21e71b57e9c2ca33879fa6192e193d75f40 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Tue, 20 Jul 2021 15:23:33 -0700 Subject: [PATCH 09/53] Add VecGhost --- src/LibPETSc.jl | 6 ++- src/vec.jl | 139 ++++++++++++++++++++++++++++++++++++++++++++++++ test/mpivec.jl | 79 +++++++++++++++++++++++++++ 3 files changed, 223 insertions(+), 1 deletion(-) diff --git a/src/LibPETSc.jl b/src/LibPETSc.jl index 1390d1a6..27690fe2 100644 --- a/src/LibPETSc.jl +++ b/src/LibPETSc.jl @@ -31,7 +31,11 @@ export PetscLibType, NORM_INFINITY, NORM_1_AND_2, PETSC_DETERMINE, - PETSC_DECIDE + PETSC_DECIDE, + SCATTER_FORWARD, + SCATTER_REVERSE, + SCATTER_FORWARD_LOCAL, + SCATTER_REVERSE_LOCAL include("LibPETSc_const.jl") include("LibPETSc_startup.jl") diff --git a/src/vec.jl b/src/vec.jl index 1746ca63..624cf1c6 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -254,6 +254,33 @@ function setvalues!( return nothing end +""" + getvalues!( + vals::Array{PetscScalar}, + v::AbstractVec, + indices::Vector{PetscInt}, + ) + +Get the 0-based global `indices` of `vec` into the preallocated array `vals`. + +!!! warning + This function uses 0-based indexing! + +# External Links +$(_doc_external("Vec/VecGetValues")) +""" +function getvalues!( + vals::Array{PetscScalar}, + v::AbstractVec{PetscLib}, + idxs0::Vector{PetscInt}; + num_idxs = length(idxs0) +) where {PetscLib, PetscInt, PetscScalar} + @assert length(vals) >= num_idxs + @assert PetscInt == PetscLib.PetscInt + @assert PetscScalar == PetscLib.PetscScalar + LibPETSc.VecGetValues(PetscLib, v, num_idxs, idxs0, vals) + return nothing +end function Base.setindex!( v::AbstractVec{PetscLib}, @@ -438,3 +465,115 @@ function assemblyend!(vec::AbstractVec{PetscLib}) where {PetscLib} LibPETSc.VecAssemblyEnd(PetscLib, vec) return nothing end + +mutable struct LocalVec{PetscLib, PetscScalar, GVec} <: + AbstractVec{PetscLib, PetscScalar} + ptr::CVec + gvec::GVec +end +function LocalVec(gvec::AbstractVec{PetscLib}) where {PetscLib} + GVec = typeof(gvec) + PetscScalar = PetscLib.PetscScalar + LocalVec{PetscLib, PetscScalar, GVec}(C_NULL, gvec) +end + +""" + getlocalform(vec::AbstractVec) + +Obtains the local ghosted representation of a [`Vec`](@ref). + +!!! note + + When done with the object the user should call [`restorelocalform!`](@ref) + +# External Links +$(_doc_external("Vec/VecGhostGetLocalForm")) +""" +function getlocalform(gvec::AbstractVec{PetscLib}) where PetscLib + lvec = LocalVec(gvec) + LibPETSc.VecGhostGetLocalForm(PetscLib, gvec, lvec) + if lvec.ptr == C_NULL + restorelocalform!(lvec) + throw(ArgumentError("no local form for vector")) + end + return lvec +end + +""" + restorelocalform!(local_vec::LocalVec) + +Restore the `local_vec` to the associated global vector after a call to +[`getlocalform`](@ref). + +# External Links +$(_doc_external("Vec/VecGhostRestoreLocalForm")) +""" +function restorelocalform!(lvec::LocalVec{PetscLib}) where PetscLib + LibPETSc.VecGhostRestoreLocalForm(PetscLib, lvec.gvec, lvec) + lvec.ptr = C_NULL + return lvec.gvec +end + +""" + withlocalform(f::Function, vec::AbstractVec) + +Convert `vec` to a `LocalVec` and apply the function `f!`. + +```julia-repl +julia> withlocalform(vec) do l_vec + # Do something with l_vec +end +``` + +!!! note + + This wrapper handles the calling of [`restorelocalform!`](@ref) before + returning. +""" +function withlocalform(f!, vec::AbstractVec) + lvec = getlocalform(vec) + f!(lvec) + restorelocalform!(lvec) +end + +""" + ghostupdatebegin!( + vec::AbstractVec, + insertmode = INSERT_VALUES, + scattermode = SCATTER_FORWARD, + ) + +Begins scattering `vec` to the local or global representations + +# External Links +$(_doc_external("Vec/VecGhostUpdateBegin")) +""" +function ghostupdatebegin!( + vec::AbstractVec{PetscLib}, + insertmode = INSERT_VALUES, + scattermode = SCATTER_FORWARD, +) where PetscLib + LibPETSc.VecGhostUpdateBegin(PetscLib, vec, insertmode, scattermode) + return nothing +end + +""" + ghostupdateend!( + vec::AbstractVec, + insertmode = INSERT_VALUES, + scattermode = SCATTER_FORWARD, + ) + +Finishes scattering `vec` to the local or global representations + +# External Links +$(_doc_external("Vec/VecGhostUpdateEnd")) +""" +function ghostupdateend!( + vec::AbstractVec{PetscLib}, + insertmode = INSERT_VALUES, + scattermode = SCATTER_FORWARD, +) where PetscLib + LibPETSc.VecGhostUpdateEnd(PetscLib, vec, insertmode, scattermode) + return nothing +end diff --git a/test/mpivec.jl b/test/mpivec.jl index 1462e84c..81459828 100644 --- a/test/mpivec.jl +++ b/test/mpivec.jl @@ -69,3 +69,82 @@ using LinearAlgebra: norm PETSc.finalize(petsclib) end end + +@testset "VecGhost" begin + comm = MPI.COMM_WORLD + mpisize = MPI.Comm_size(comm) + mpirank = MPI.Comm_rank(comm) + + # local first and last value + n0 = sum(10 .+ (0:mpirank)) - 10 + n1 = sum(10 .+ (0:(mpirank + 1))) - 11 + local_length = n1 - n0 + 1 + + # global last value + ne = sum(10 .+ (0:mpisize)) - 11 + exact_length = ne + 1 + + # exact norm + exact_norm = norm(0:ne) + + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + + # two ghost to left and right + ghost = PetscInt.([]) + if mpirank != 0 + ghost = PetscInt.([ghost..., n0 - 2, n0 - 1]) + end + if mpirank != mpisize - 1 + ghost = PetscInt.([ghost..., n1 + 1, n1 + 2]) + end + + for version in 1:2 + if version == 1 + # Create using local size + petsc_x = PETSc.VecGhost(petsclib, comm, local_length, ghost) + + rng = PetscInt.(PETSc.ownershiprange(petsc_x)) + julia_x = PetscScalar.(rng) + PETSc.setvalues!(petsc_x, rng, julia_x, PETSc.INSERT_VALUES) + else + # Create using local size + continue + end + + PETSc.assemblybegin!(petsc_x) + PETSc.assemblyend!(petsc_x) + + @test length(petsc_x) == exact_length + + vec_norm = norm(petsc_x) + @test exact_norm ≈ vec_norm + + PETSc.withlocalform(petsc_x) do l_x + @test length(l_x) == local_length + length(ghost) + + # Check the ghost has propogated + if length(ghost) > 0 + vals = zeros(PetscScalar, length(ghost)) + inds = PetscInt.(local_length - 1 .+ (1:length(ghost))) + # Initially we have pushed the numbers so shouldn't match + PETSc.getvalues!(vals, l_x, inds) + @test !(vals == ghost) + + # propagate the ghost + PETSc.ghostupdatebegin!(petsc_x) + PETSc.ghostupdateend!(petsc_x) + + # Recheck the numbers + PETSc.getvalues!(vals, l_x, inds) + @test vals == ghost + end + end + + PETSc.destroy(petsc_x) + end + PETSc.finalize(petsclib) + end +end From 105fb5775b4cf245afabb352ee1f2261467af864 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Tue, 20 Jul 2021 15:36:51 -0700 Subject: [PATCH 10/53] Add getpetsctype for vectors --- gen/generator.toml | 1 + gen/prologue.jl | 1 + lib/petsc_library.jl | 4 +--- src/vec.jl | 7 +++++++ test/mpivec.jl | 2 ++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gen/generator.toml b/gen/generator.toml index 1c9b286f..4ac1d75e 100644 --- a/gen/generator.toml +++ b/gen/generator.toml @@ -15,6 +15,7 @@ printer_blacklist = [ "PetscViewer", "_p_PetscViewer", "PetscObject", "_p_PetscObject", "Mat", "_p_Mat", + "Vec", "_p_Vec", "VecType", # # Remove types defined in const.jl # diff --git a/gen/prologue.jl b/gen/prologue.jl index f4e964f0..2ab399aa 100644 --- a/gen/prologue.jl +++ b/gen/prologue.jl @@ -23,3 +23,4 @@ const PetscViewer = Ptr{Cvoid} const PetscObject = Ptr{Cvoid} const Vec = Ptr{Cvoid} const Mat = Ptr{Cvoid} +const VecType = Cstring diff --git a/lib/petsc_library.jl b/lib/petsc_library.jl index 3e4556f8..04e03536 100644 --- a/lib/petsc_library.jl +++ b/lib/petsc_library.jl @@ -23,7 +23,7 @@ const PetscViewer = Ptr{Cvoid} const PetscObject = Ptr{Cvoid} const Vec = Ptr{Cvoid} const Mat = Ptr{Cvoid} -const PetscObject = Ptr{Cvoid} +const VecType = Cstring const __darwin_off_t = Int64 @@ -12790,8 +12790,6 @@ end # SCATTER_LOCAL = 2 end -const VecType = Ptr{Cchar} - @for_petsc function VecScatterSetType(::$UnionPetscLib, arg1, arg2) @chk ccall( (:VecScatterSetType, $petsc_library), diff --git a/src/vec.jl b/src/vec.jl index 624cf1c6..59e125a9 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -577,3 +577,10 @@ function ghostupdateend!( LibPETSc.VecGhostUpdateEnd(PetscLib, vec, insertmode, scattermode) return nothing end + + +function getpetsctype(vec::AbstractVec{PetscLib}) where PetscLib + name_r = Ref{LibPETSc.VecType}() + LibPETSc.VecGetType(PetscLib, vec, name_r) + return unsafe_string(name_r[]) +end diff --git a/test/mpivec.jl b/test/mpivec.jl index 81459828..9b30fabd 100644 --- a/test/mpivec.jl +++ b/test/mpivec.jl @@ -63,6 +63,8 @@ using LinearAlgebra: norm @test x == julia_x end + @test "mpi" == PETSc.getpetsctype(petsc_x) + PETSc.destroy(petsc_x) end From 922d74f24e67976e4e3b0fd07a0b091e34720196 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 21 Jul 2021 13:31:19 -0700 Subject: [PATCH 11/53] Update matshell and with_localarray name --- src/matshell.jl | 6 ++---- src/vec.jl | 23 +++++++++++++---------- test/matshell.jl | 6 +++++- test/mpivec.jl | 2 +- test/vec.jl | 4 ++-- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/matshell.jl b/src/matshell.jl index 392233df..ab87ca2f 100644 --- a/src/matshell.jl +++ b/src/matshell.jl @@ -43,13 +43,11 @@ function (::MatOp{PetscLib, PetscInt, LibPETSc.MATOP_MULT})( mat = unsafe_pointer_to_objref(ptr) PetscScalar = PetscLib.PetscScalar - x = unsafe_localarray(VecPtr(PetscLib, cx); write = false) - y = unsafe_localarray(VecPtr(PetscLib, cy); read = false) + x = VecPtr(PetscLib, cx, false) + y = VecPtr(PetscLib, cy, false) _mul!(y, mat, x) - Base.finalize(y) - Base.finalize(x) return PetscInt(0) end diff --git a/src/vec.jl b/src/vec.jl index 59e125a9..6a2f752e 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -413,12 +413,9 @@ function unsafe_localarray( end """ - with_unsafe_localarray!( - f!, - x::AbstractVec; - read=true, - write=true, - ) + withlocalarray!(f!, x::AbstractVec; read=true, write=true) + withlocalarray!(f!, xs...; read=true, write=true) + withlocalarray!(f!, xs::NTuple{N, AbstractVec}...; read=true, write=true) Convert `x` to an `Array{PetscScalar}` using [`unsafe_localarray`](@ref) and apply the function `f!`. @@ -434,11 +431,17 @@ end !!! note `Base.finalize` is automatically called on the array. """ -function with_unsafe_localarray!(f!, v::AbstractVec; kwargs...) - array = unsafe_localarray(v; kwargs...) - f!(array) - Base.finalize(array) +function with_localarray!(f!, vecs::NTuple{N, AbstractVec}; kwargs...) where N + arrays = map(vecs) do v + unsafe_localarray(v; kwargs...) + end + val = f!(arrays...) + map(arrays) do array + Base.finalize(array) + end + return val end +withlocalarray!(f!, vecs...; kwargs...) = withlocalarray!(f!, vecs; kwargs...) """ assemblybegin!(vec::AbstractVec) diff --git a/test/matshell.jl b/test/matshell.jl index 3e2126f8..faf94982 100644 --- a/test/matshell.jl +++ b/test/matshell.jl @@ -9,7 +9,11 @@ using MPI local_rows = 10 local_cols = 5 - f!(x, y) = x .= [2y; 3y] + function f!(p_x, p_y) + PETSc.withlocalarray!((p_x, p_y)) do x, y + x .= [2y; 3y] + end + end x_jl = collect matshell = diff --git a/test/mpivec.jl b/test/mpivec.jl index 9b30fabd..b204fa7d 100644 --- a/test/mpivec.jl +++ b/test/mpivec.jl @@ -59,7 +59,7 @@ using LinearAlgebra: norm # 1-based @test petsc_x[rng .+ 1] == julia_x - PETSc.with_unsafe_localarray!(petsc_x) do x + PETSc.withlocalarray!(petsc_x) do x @test x == julia_x end diff --git a/test/vec.jl b/test/vec.jl index c08dfc4f..1a714392 100644 --- a/test/vec.jl +++ b/test/vec.jl @@ -30,7 +30,7 @@ using LinearAlgebra: norm @test PETSc.ownershiprange(petsc_x) == 1:N @test PETSc.ownershiprange(petsc_x, false) == 0:(N - 1) - PETSc.with_unsafe_localarray!(petsc_x) do x2 + PETSc.withlocalarray!(petsc_x) do x2 @test x2 == x end @@ -51,7 +51,7 @@ end @test PETSc.ownershiprange(petsc_x, false) == 0:(N - 1) x = rand(PetscScalar, N) - PETSc.with_unsafe_localarray!(petsc_x) do x2 + PETSc.withlocalarray!(petsc_x) do x2 x2 .= x end @test norm(petsc_x) ≈ norm(x) From a14f9e8498c5e93741ee2b0048418395394eab8b Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 21 Jul 2021 16:07:08 -0700 Subject: [PATCH 12/53] Clean up some function comments and names --- src/mat.jl | 56 ++++++++++++++++++++++------------------------------- src/vec.jl | 3 ++- test/mat.jl | 20 +++++++++---------- 3 files changed, 35 insertions(+), 44 deletions(-) diff --git a/src/mat.jl b/src/mat.jl index 52631795..f5dde582 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -16,27 +16,11 @@ function destroy(M::AbstractMat{PetscLib}) where {PetscLib} return nothing end -""" - MatSeqAIJ{PetscLib, PetscScalar} - -PETSc sparse array using AIJ format (also known as a compressed sparse row or -CSR format). - -Memory allocation is handled by PETSc. - -# External Links -$(_doc_external("Mat/MatCreateSeqAIJ")) -""" -mutable struct MatSeqAIJ{PetscLib, PetscScalar} <: - AbstractMat{PetscLib, PetscScalar} - ptr::CMat -end - """ MatSeqAIJ(petsclib, num_rows, num_cols, nonzeros) -Create a PETSc sparse array using AIJ format (also known as a compressed sparse -row or CSR format) of size `num_rows X num_cols` with `nonzeros` per row +Create a PETSc serial sparse array using AIJ format (also known as a compressed +sparse row or CSR format) of size `num_rows X num_cols` with `nonzeros` per row If `nonzeros` is an `Integer` the same number of non-zeros will be used for each row, if `nonzeros` is a `Vector{PetscInt}` then one value must be specified for @@ -47,6 +31,11 @@ Memory allocation is handled by PETSc and garbage collection can be used. # External Links $(_doc_external("Mat/MatCreateSeqAIJ")) """ +mutable struct MatSeqAIJ{PetscLib, PetscScalar} <: + AbstractMat{PetscLib, PetscScalar} + ptr::CMat +end + function MatSeqAIJ( petsclib::PetscLib, num_rows::Integer, @@ -114,53 +103,54 @@ function MatSeqDense( end """ - assemble(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) + assemble!(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) Assemble the matrix `M` with assembly type `t`. -For overlapping assembly see [`assemblybegin`](@ref) and [`assemblyend`](@ref) +For overlapping assembly see [`assemblybegin!`](@ref) and [`assemblyend!`](@ref) # External Links $(_doc_external("Mat/MatAssemblyBegin")) $(_doc_external("Mat/MatAssemblyEnd")) """ -function assemble(M::AbstractMat, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) - assemblybegin(M, t) - assemblyend(M, t) +function assemble!(M::AbstractMat, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) + assemblybegin!(M, t) + assemblyend!(M, t) + return M end """ - assemblybegin(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) + assemblybegin!(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) Begin assembly of the matrix `M` with assembly type `t`; finished with -[`assemblyend`](@ref). +[`assemblyend!`](@ref). # External Links $(_doc_external("Mat/MatAssemblyBegin")) """ -function assemblybegin( +function assemblybegin!( M::AbstractMat{PetscLib}, t::MatAssemblyType = MAT_FINAL_ASSEMBLY, ) where {PetscLib} LibPETSc.MatAssemblyBegin(PetscLib, M, t) - return nothing + return M end """ - assemblyend(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) + assemblyend!(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) Finish assembly of the matrix `M` with assembly type `t`; start assembly with -[`assemblybegin`](@ref). +[`assemblybegin!`](@ref). # External Links $(_doc_external("Mat/MatAssemblyEnd")) """ -function assemblyend( +function assemblyend!( M::AbstractMat{PetscLib}, t::MatAssemblyType = MAT_FINAL_ASSEMBLY, ) where {PetscLib} LibPETSc.MatAssemblyEnd(PetscLib, M, t) - return nothing + return M end function Base.size(A::AbstractMat{PetscLib}) where {PetscLib} @@ -195,7 +185,7 @@ Base.show(io::IO, ::MIME"text/plain", mat::AbstractMat) = _show(io, mat) row0idxs::Vector{PetscInt}, col0idxs::Vector{PetscInt}, rowvals::Array{PetscScalar}, - insertmode::InsertMode; + insertmode::InsertMode = INSERT_VALUES; num_rows = length(row0idxs), num_cols = length(col0idxs) ) @@ -214,7 +204,7 @@ function setvalues!( row0idxs::Vector{PetscInt}, col0idxs::Vector{PetscInt}, rowvals::Array{PetscScalar}, - insertmode::InsertMode; + insertmode::InsertMode = INSERT_VALUES; num_rows = length(row0idxs), num_cols = length(col0idxs), ) where {PetscLib, PetscScalar, PetscInt} diff --git a/src/vec.jl b/src/vec.jl index 6a2f752e..00c96f84 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -128,7 +128,8 @@ end An sequentially-stored MPI PETSc vector for `petsclib.PetscScalar` of local length `local_length` and global length `global_length` without ghost elements. -If `global_length isa Int` then `local_length` can be set to `PETSC_DECIDE`. +If `global_length isa Int` then `local_length` can be set to `PETSC_DECIDE` in +which case PETSc will decide the local_length. # External Links $(_doc_external("Vec/VecCreateMPI")) diff --git a/test/mat.jl b/test/mat.jl index ef0b14a2..c2254abe 100644 --- a/test/mat.jl +++ b/test/mat.jl @@ -14,14 +14,14 @@ using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian @test size(A) == (num_rows, num_cols) B = PETSc.MatSeqAIJ(petsclib, num_rows, num_cols, nz_int) - PETSc.assemble(A) - PETSc.assemble(B) + PETSc.assemble!(A) + PETSc.assemble!(B) # both empty @test A == B C = PETSc.MatSeqAIJ(petsclib, num_rows, num_cols, nz_vec) @test size(A) == (num_rows, num_cols) - PETSc.assemble(C) + PETSc.assemble!(C) # both empty @test A == C @@ -30,7 +30,7 @@ using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian D[1, [1, 2]] .= [1, 2] D[2, [3, 4]] .= [3, 4] D[5, [3, 4]] .= [3, 4] - PETSc.assemble(D) + PETSc.assemble!(D) DJ = zeros(PetscScalar, num_rows, num_cols) DJ[1, [1, 2]] .= [1, 2] @@ -41,7 +41,7 @@ using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian D[1, [1, 2]] .= [1, 2im] D[2, [3, 4]] .= [3, 4im] D[5, [3, 4]] .= [3, 4im] - PETSc.assemble(D) + PETSc.assemble!(D) DJ = zeros(PetscScalar, num_rows, num_cols) DJ[1, [1, 2]] .= [1, 2im] @@ -53,7 +53,7 @@ using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian E[2, [1, 3, 4]] .= [1, 3, 4] E[3, [3, 4]] .= [3, 4] E[4, [5]] .= [6] - PETSc.assemble(E) + PETSc.assemble!(E) @test A != E @test D != E @@ -87,13 +87,13 @@ using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian A[1, 1] = 1 A[2, 1] = -2 A[1, 2] = -2 - PETSc.assemble(A) + PETSc.assemble!(A) B = PETSc.MatSeqAIJ(petsclib, 5, 5, 2) B[1, 1] = 1 B[2, 1] = 2 B[1, 2] = -2 - PETSc.assemble(B) + PETSc.assemble!(B) @test issymmetric(A) @test ishermitian(A) @@ -104,13 +104,13 @@ using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian A[1, 1] = 1 A[2, 1] = -2 + im A[1, 2] = -2 - im - PETSc.assemble(A) + PETSc.assemble!(A) B = PETSc.MatSeqAIJ(petsclib, 5, 5, 2) B[1, 1] = 1 B[2, 1] = -2 + im B[1, 2] = -2 + im - PETSc.assemble(B) + PETSc.assemble!(B) @test !issymmetric(A) @test ishermitian(A) @test issymmetric(B) From a0013a4147aef26ea37cde29826b199e01526ebb Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 21 Jul 2021 16:07:40 -0700 Subject: [PATCH 13/53] Add a parallel matrix type and test --- src/mat.jl | 170 +++++++++++++++++++++++++++++++++++++++++++++++ src/vec.jl | 40 ++++++++--- test/mpimat.jl | 86 ++++++++++++++++++++++++ test/runtests.jl | 9 ++- 4 files changed, 294 insertions(+), 11 deletions(-) create mode 100644 test/mpimat.jl diff --git a/src/mat.jl b/src/mat.jl index f5dde582..80c725e8 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -102,6 +102,109 @@ function MatSeqDense( return mat end +""" + MatAIJ( + petsclib::PetscLib, + comm::MPI.Comm, + loc_num_rows::Integer, + loc_num_cols::Integer, + diag_nonzeros::Union{Integer, Vector}, + off_diag_nonzeros::Union{Integer, Vector}; + glo_num_rows = PETSC_DETERMINE, + glo_num_cols = PETSC_DETERMINE, + setup = true + ) where {PetscLib <: PetscLibType} + +Create an MPI PETSc sparse array on the `comm` using AIJ format (also known as a +compressed sparse row or CSR format) of size `glo_num_rows X glo_num_cols` with +local size `loc_num_rows X loc_num_cols`. + +The diagonal block and off-diagonal block non-zeros are `diag_nonzeros` and +`off_diag_nonzeros` which can be either an integer (same for all rows) or a +Vector of `PetscInt`s with on entry per row. + +Memory allocation is handled by PETSc and garbage collection can be used. + +If `glo_num_rows isa Integer` or `glo_num_cols isa Integer` then the +corresponding local variable can be `PETSC_DECIDE`. + +If `setup == true` then [`setup!`](@ref) is called + +# External Links +$(_doc_external("Mat/MatCreateAIJ")) +$(_doc_external("Mat/MatSetUp")) + +!!! note + + The user is responsible for calling `destroy(mat)` on the `MatAIJ` since + this cannot be handled by the garbage collector do to the MPI nature of the + object. +""" +mutable struct MatAIJ{PetscLib, PetscScalar} <: + AbstractMat{PetscLib, PetscScalar} + ptr::CMat +end + +function MatAIJ( + petsclib::PetscLib, + comm::MPI.Comm, + loc_num_rows::Integer, + loc_num_cols::Integer, + diag_nonzeros::Union{Integer, Vector}, + off_diag_nonzeros::Union{Integer, Vector}; + glo_num_rows = PETSC_DETERMINE, + glo_num_cols = PETSC_DETERMINE, + setup = true, +) where {PetscLib <: PetscLibType} + @assert initialized(petsclib) + PetscScalar = petsclib.PetscScalar + mat = MatAIJ{PetscLib, PetscScalar}(C_NULL) + if diag_nonzeros isa Integer + diag_nonzero = diag_nonzeros + diag_nonzeros = C_NULL + else + diag_nonzero = -1 + end + if off_diag_nonzeros isa Integer + off_diag_nonzero = off_diag_nonzeros + off_diag_nonzeros = C_NULL + else + off_diag_nonzero = -1 + end + + LibPETSc.MatCreateAIJ( + petsclib, + comm, + loc_num_rows, + loc_num_cols, + glo_num_rows, + glo_num_cols, + diag_nonzero, + diag_nonzeros, + off_diag_nonzero, + off_diag_nonzeros, + mat, + ) + + setup && setup!(mat) + + return mat +end + +""" + setup!(mat::AbstractMat) + +Set up the interal data for `mat` + +# External Links +$(_doc_external("Mat/MatSetUp")) +""" +function setup!(mat::AbstractMat{PetscLib}) where {PetscLib} + @assert initialized(PetscLib) + LibPETSc.MatSetUp(PetscLib, mat) + return mat +end + """ assemble!(M::AbstractMat[, t::MatAssemblyType = MAT_FINAL_ASSEMBLY) @@ -153,6 +256,35 @@ function assemblyend!( return M end +""" + ownershiprange(mat::AbstractMat, [base_one = true]) + +The range of row indices owned by this processor, assuming that the `mat` is +laid out with the first `n1` rows on the first processor, next `n2` rows on the +second, etc. For certain parallel layouts this range may not be well defined. + +If the optional argument `base_one == true` then base-1 indexing is used, +otherwise base-0 index is used. + +!!! note + + unlike the C function, the range returned is inclusive (`idx_first:idx_last`) + +# External Links +$(_doc_external("Mat/MatGetOwnershipRange")) +""" +function ownershiprange( + mat::AbstractMat{PetscLib}, + base_one::Bool = true, +) where {PetscLib} + PetscInt = PetscLib.PetscInt + r_lo = Ref{PetscInt}() + r_hi = Ref{PetscInt}() + LibPETSc.MatGetOwnershipRange(PetscLib, mat, r_lo, r_hi) + return base_one ? ((r_lo[] + PetscInt(1)):(r_hi[])) : + ((r_lo[]):(r_hi[] - PetscInt(1))) +end + function Base.size(A::AbstractMat{PetscLib}) where {PetscLib} m = Ref{PetscLib.PetscInt}() n = Ref{PetscLib.PetscInt}() @@ -344,3 +476,41 @@ function Base.copyto!(M::PETSc.MatSeqAIJ{T}, S::SparseMatrixCSC{T}) where {T} assemble(M); end =# + +""" + createvecs( + M::AbstractMat{PetscLib}, + ) + +Returns vectors `V` which are compatible with `M`. A right compatible vectors is +`V.right` and a left compatible vector is `V.left`; positionally these are +returned as `(right, left)` + +The created vectors are not garbage collected and should be destroyed with +[`destroy`](@ref). + +# External Links +$(_doc_external("Mat/MatCreateVecs")) +""" +function createvecs(M::AbstractMat{PetscLib}) where {PetscLib} + r_right = Ref{CVec}() + r_left = Ref{CVec}() + LibPETSc.MatCreateVecs(PetscLib, M, r_right, r_left) + right = VecPtr(PetscLib, r_right[], true) + left = VecPtr(PetscLib, r_left[], true) + return (right = right, left = left) +end + +""" + getpetsctype(mat::AbstractMat) + +return a string with the matrix type + +# External Links +$(_doc_external("Mat/MatGetType")) +""" +function getpetsctype(mat::AbstractMat{PetscLib}) where {PetscLib} + name_r = Ref{LibPETSc.MatType}() + LibPETSc.MatGetType(PetscLib, mat, name_r) + return unsafe_string(name_r[]) +end diff --git a/src/vec.jl b/src/vec.jl index 00c96f84..eefbe131 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -246,7 +246,7 @@ function setvalues!( idxs0::Vector{PetscInt}, vals::Array{PetscScalar}, insertmode::InsertMode; - num_idxs = length(idxs0) + num_idxs = length(idxs0), ) where {PetscLib, PetscInt, PetscScalar} @assert length(vals) >= num_idxs @assert PetscInt == PetscLib.PetscInt @@ -274,7 +274,7 @@ function getvalues!( vals::Array{PetscScalar}, v::AbstractVec{PetscLib}, idxs0::Vector{PetscInt}; - num_idxs = length(idxs0) + num_idxs = length(idxs0), ) where {PetscLib, PetscInt, PetscScalar} @assert length(vals) >= num_idxs @assert PetscInt == PetscLib.PetscInt @@ -432,7 +432,7 @@ end !!! note `Base.finalize` is automatically called on the array. """ -function with_localarray!(f!, vecs::NTuple{N, AbstractVec}; kwargs...) where N +function withlocalarray!(f!, vecs::NTuple{N, AbstractVec}; kwargs...) where {N} arrays = map(vecs) do v unsafe_localarray(v; kwargs...) end @@ -470,6 +470,23 @@ function assemblyend!(vec::AbstractVec{PetscLib}) where {PetscLib} return nothing end +""" + assemble!(v::AbstractVec) + +Assemble the vector `v`. + +For overlapping assembly see [`assemblybegin!`](@ref) and [`assemblyend!`](@ref) + +# External Links +$(_doc_external("Vec/VecAssemblyBegin")) +$(_doc_external("Vec/VecAssemblyEnd")) +""" +function assemble!(v::AbstractVec) + assemblybegin!(v) + assemblyend!(v) + return v +end + mutable struct LocalVec{PetscLib, PetscScalar, GVec} <: AbstractVec{PetscLib, PetscScalar} ptr::CVec @@ -493,7 +510,7 @@ Obtains the local ghosted representation of a [`Vec`](@ref). # External Links $(_doc_external("Vec/VecGhostGetLocalForm")) """ -function getlocalform(gvec::AbstractVec{PetscLib}) where PetscLib +function getlocalform(gvec::AbstractVec{PetscLib}) where {PetscLib} lvec = LocalVec(gvec) LibPETSc.VecGhostGetLocalForm(PetscLib, gvec, lvec) if lvec.ptr == C_NULL @@ -512,7 +529,7 @@ Restore the `local_vec` to the associated global vector after a call to # External Links $(_doc_external("Vec/VecGhostRestoreLocalForm")) """ -function restorelocalform!(lvec::LocalVec{PetscLib}) where PetscLib +function restorelocalform!(lvec::LocalVec{PetscLib}) where {PetscLib} LibPETSc.VecGhostRestoreLocalForm(PetscLib, lvec.gvec, lvec) lvec.ptr = C_NULL return lvec.gvec @@ -556,7 +573,7 @@ function ghostupdatebegin!( vec::AbstractVec{PetscLib}, insertmode = INSERT_VALUES, scattermode = SCATTER_FORWARD, -) where PetscLib +) where {PetscLib} LibPETSc.VecGhostUpdateBegin(PetscLib, vec, insertmode, scattermode) return nothing end @@ -577,13 +594,20 @@ function ghostupdateend!( vec::AbstractVec{PetscLib}, insertmode = INSERT_VALUES, scattermode = SCATTER_FORWARD, -) where PetscLib +) where {PetscLib} LibPETSc.VecGhostUpdateEnd(PetscLib, vec, insertmode, scattermode) return nothing end +""" + getpetsctype(vec::AbstractVec) + +return a string with the vector type -function getpetsctype(vec::AbstractVec{PetscLib}) where PetscLib +# External Links +$(_doc_external("Vec/VecGetType")) +""" +function getpetsctype(vec::AbstractVec{PetscLib}) where {PetscLib} name_r = Ref{LibPETSc.VecType}() LibPETSc.VecGetType(PetscLib, vec, name_r) return unsafe_string(name_r[]) diff --git a/test/mpimat.jl b/test/mpimat.jl new file mode 100644 index 00000000..86fcad48 --- /dev/null +++ b/test/mpimat.jl @@ -0,0 +1,86 @@ +using Test +using MPI +MPI.Initialized() || MPI.Init() +using PETSc +using LinearAlgebra: mul!, norm + +@testset "MatAIJ" begin + comm = MPI.COMM_WORLD + mpisize = MPI.Comm_size(comm) + mpirank = MPI.Comm_rank(comm) + + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + + loc_num_rows = 5 + loc_num_cols = 5 + diag_nonzeros = 3 + off_diag_non_zeros = 3 + + mat = PETSc.MatAIJ( + petsclib, + comm, + loc_num_rows, + loc_num_cols, + diag_nonzeros, + off_diag_non_zeros, + ) + + # Get compatible vectors + (right, left) = PETSc.createvecs(mat) + + # Fill the matrix and right vector + row_rng = PETSc.ownershiprange(mat, false) + for i in row_rng + if i == 0 + vals = [-2, 1] + row0idxs = [i] + col0idxs = [i, i + 1] + elseif i == mpisize * loc_num_rows - 1 + vals = [-2, 1] + row0idxs = [i] + col0idxs = [i, i - 1] + else + vals = [1, -2, 1] + row0idxs = [i] + col0idxs = [i - 1, i, i + 1] + end + PETSc.setvalues!( + mat, + PetscInt.(row0idxs), + PetscInt.(col0idxs), + PetscScalar.(vals), + ) + right[i + 1] = i^3 + end + PETSc.assemble!(mat) + PETSc.assemble!(right) + + # Do matrix multiply and check result + mul!(left, mat, right) + for i in row_rng + if i == 0 + v = -2 * i^3 + (i + 1)^3 + elseif i == mpisize * loc_num_rows - 1 + v = (i - 1)^3 - 2 * i^3 + else + v = (i - 1)^3 - 2 * i^3 + (i + 1)^3 + end + @test v == left[i + 1] + end + + # Check the norm in parallel + sz = loc_num_rows * mpisize + exact_norm = sqrt(sz * 2^2 + 2 * (sz - 1)) + @test norm(mat) ≈ exact_norm + + PETSc.destroy(mat) + PETSc.destroy(right) + PETSc.destroy(left) + + PETSc.finalize(petsclib) + end +end +nothing diff --git a/test/runtests.jl b/test/runtests.jl index 59b843ee..85d81e9d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,9 +3,12 @@ using MPI: mpiexec # Do the MPI tests first so we do not have mpi running inside MPI @testset "mpi tests" begin - @test mpiexec() do mpi_cmd - cmd = `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no --project mpivec.jl` - success(pipeline(cmd, stderr = stderr)) + for file in ("mpivec.jl", "mpimat.jl") + @test mpiexec() do mpi_cmd + cmd = + `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no --project $file` + success(pipeline(cmd, stderr = stderr)) + end end end From 21d9e05ad114942280ac59851916edf2dfc0fe89 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Tue, 3 Aug 2021 09:25:19 -0700 Subject: [PATCH 14/53] Update generator for KSP --- gen/generator.toml | 1 + gen/prologue.jl | 2 ++ lib/petsc_library.jl | 8 ++------ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gen/generator.toml b/gen/generator.toml index 4ac1d75e..3f8f9266 100644 --- a/gen/generator.toml +++ b/gen/generator.toml @@ -16,6 +16,7 @@ printer_blacklist = [ "PetscObject", "_p_PetscObject", "Mat", "_p_Mat", "Vec", "_p_Vec", "VecType", + "KSP", "_p_KSP", "KSPType", # # Remove types defined in const.jl # diff --git a/gen/prologue.jl b/gen/prologue.jl index 2ab399aa..cb14aebb 100644 --- a/gen/prologue.jl +++ b/gen/prologue.jl @@ -23,4 +23,6 @@ const PetscViewer = Ptr{Cvoid} const PetscObject = Ptr{Cvoid} const Vec = Ptr{Cvoid} const Mat = Ptr{Cvoid} +const KSP = Ptr{Cvoid} const VecType = Cstring +const KSPType = Cstring diff --git a/lib/petsc_library.jl b/lib/petsc_library.jl index 04e03536..d4dd86a1 100644 --- a/lib/petsc_library.jl +++ b/lib/petsc_library.jl @@ -23,7 +23,9 @@ const PetscViewer = Ptr{Cvoid} const PetscObject = Ptr{Cvoid} const Vec = Ptr{Cvoid} const Mat = Ptr{Cvoid} +const KSP = Ptr{Cvoid} const VecType = Cstring +const KSPType = Cstring const __darwin_off_t = Int64 @@ -51031,12 +51033,6 @@ end @chk ccall((:KSPInitializePackage, $petsc_library), PetscErrorCode, ()) end -mutable struct _p_KSP end - -const KSP = Ptr{_p_KSP} - -const KSPType = Ptr{Cchar} - @for_petsc function KSPCreate(::$UnionPetscLib, arg1, arg2) @chk ccall( (:KSPCreate, $petsc_library), From 6e7b0b7220a9e4cf52faa4d9a3411307dc3ea799 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 4 Aug 2021 10:47:37 -0700 Subject: [PATCH 15/53] Update options --- src/options.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/options.jl b/src/options.jl index 22780ba7..5652db9f 100644 --- a/src/options.jl +++ b/src/options.jl @@ -77,7 +77,7 @@ mutable struct Options{T} <: AbstractOptions{T} ptr::CPetscOptions end -function Options(petsclib::PetscLibType) +function Options_(petsclib::PetscLibType) @assert initialized(petsclib) PetscLib = typeof(petsclib) opts = Options{PetscLib}(C_NULL) @@ -86,9 +86,10 @@ function Options(petsclib::PetscLibType) return opts end -Options(petsclib; kwargs...) = Options(petsclib, kwargs...) -function Options(petsclib, ps::Pair...) - opts = Options(petsclib) +Options(petsclib::PetscLibType; kwargs...) = Options_(petsclib, kwargs...) +Options(PetscLib::Type{<:PetscLibType}; kwargs...) = Options_(getlib(PetscLib), kwargs...) +function Options_(petsclib::PetscLibType, ps::Pair...) + opts = Options_(petsclib) for (k, v) in ps opts[k] = v end From c8b91b4668cdf5be8f76628773073ac5e1b11894 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 4 Aug 2021 10:51:56 -0700 Subject: [PATCH 16/53] Add (basic) ksp functionality --- src/PETSc.jl | 2 +- src/ksp.jl | 205 ++++++++++++++++++++++++++++++----------------- src/sys.jl | 8 +- src/vec.jl | 7 ++ test/ksp.jl | 82 +++++++++++++++++++ test/runtests.jl | 3 +- 6 files changed, 231 insertions(+), 76 deletions(-) create mode 100644 test/ksp.jl diff --git a/src/PETSc.jl b/src/PETSc.jl index 87d53f93..9eb1a7ec 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -29,7 +29,7 @@ include("matshell.jl") # include("dm.jl") # include("dmda.jl") # include("dmstag.jl") -# include("ksp.jl") +include("ksp.jl") # include("pc.jl") # include("snes.jl") include("sys.jl") diff --git a/src/ksp.jl b/src/ksp.jl index f2a5ba13..23b230b9 100644 --- a/src/ksp.jl +++ b/src/ksp.jl @@ -1,28 +1,146 @@ - const CKSP = Ptr{Cvoid} const CKSPType = Cstring -abstract type AbstractKSP{T, PetscLib} <: Factorization{T} end +abstract type AbstractKSP{PetscLib, PetscScalar} <: Factorization{PetscScalar} end -Base.@kwdef mutable struct KSP{T, PetscLib} <: AbstractKSP{T, PetscLib} +Base.@kwdef mutable struct KSP{PetscLib, PetscScalar} <: + AbstractKSP{PetscLib, PetscScalar} ptr::CKSP = C_NULL - opts::Options{PetscLib} - # Stuff to keep around so that they don't get gc'ed - _A = nothing - _P = nothing - _dm = nothing - # Function pointers - ComputeRHS! = nothing - ComputeOperators! = nothing + opts::Options{PetscLib} = Options(PetscLib) + A::Union{AbstractMat, Nothing} = nothing + P::Union{AbstractMat, Nothing} = nothing +end + +""" + KSP(A::AbstractMat, P::AbstractMat{PetscLib} = A; options...) + +Create a `KSP` using the matrix `A` and preconditioner construction matrix `P` +with the `options`. + +The communicator is obtained from `A` and if it has size `1` then the garbage +collector is set, otherwise the user is responsible for calling +[`destroy`](@ref). + +# External Links +$(_doc_external("KSP/KSPCreate")) +$(_doc_external("KSP/KSPSetOperators")) +$(_doc_external("KSP/KSPSetFromOptions")) +""" +function KSP( + A::AbstractMat{PetscLib}, + P::AbstractMat{PetscLib} = A; + options..., +) where {PetscLib} + @assert initialized(PetscLib) + opts = Options(PetscLib; options...) + PetscScalar = PetscLib.PetscScalar + ksp = KSP{PetscLib, PetscScalar}(opts = opts) + comm = getcomm(A) + + with(ksp.opts) do + LibPETSc.KSPCreate(PetscLib, comm, ksp) + end + + setoperators!(ksp, A, P) + setfromoptions!(ksp) + + # If there is only one rank we can finalize the KSP with GC + if MPI.Comm_size(comm) == 1 + finalizer(destroy, ksp) + end + + return ksp +end + +function setoperators!( + ksp::AbstractKSP{PetscLib}, + A::AbstractMat{PetscLib}, + P::AbstractMat{PetscLib} = A, +) where {PetscLib} + LibPETSc.KSPSetOperators(PetscLib, ksp, A, P) + ksp.A = A + ksp.P = P + return ksp +end + +function setfromoptions!(ksp::AbstractKSP{PetscLib}) where {PetscLib} + with(ksp.opts) do + LibPETSc.KSPSetFromOptions(PetscLib, ksp) + end +end + +function destroy(ksp::AbstractKSP{PetscLib}) where {PetscLib} + finalized(PetscLib) || LibPETSc.KSPDestroy(PetscLib, ksp) + return nothing +end + +function solve!( + x::AbstractVec{PetscLib}, + ksp::AbstractKSP{PetscLib}, + b::AbstractVec{PetscLib}, +) where {PetscLib} + with(ksp.opts) do + LibPETSc.KSPSolve(PetscLib, ksp, b, x) + end + return x +end + +""" + createvecs(ksp::AbstractKSP; nright = 0, nleft = 0) + +Create `nright` right and `nleft` left vectors compatible with the `ksp`. +Returned object `V` has `Tuple` members `V.right` and `V.left` containing the +vectors. + +# External Links +$(_doc_external("KSP/KSPCreateVecs")) +""" +function createvecs( + ksp::AbstractKSP{PetscLib}; + nright = 0, + nleft = 0, +) where {PetscLib} + # pointer of pointers to the base vectors + r_right_vs = Ref{Ptr{CVec}}() + r_left_vs = Ref{Ptr{CVec}}() + + # create 1 right and left vector + LibPETSc.KSPCreateVecs(PetscLib, ksp, 1, r_right_vs, 1, r_left_vs) + + # create right vectors + a_v = unsafe_wrap(Array, r_right_vs[], 1; own = false) + v = VecPtr(PetscLib, a_v[1], false) + right = ntuple(i -> similar(v), nright) + + # create left vectors + a_v = unsafe_wrap(Array, r_left_vs[], 1; own = false) + v = VecPtr(PetscLib, a_v[1], false) + left = ntuple(i -> similar(v), nleft) + + LibPETSc.VecDestroyVecs(PetscLib, 1, r_right_vs) + LibPETSc.VecDestroyVecs(PetscLib, 1, r_left_vs) + + (right = right, left = left) +end + +function LinearAlgebra.ldiv!(x::AbstractVec, ksp::AbstractKSP, b::AbstractVec) + solve!(x, ksp, b) +end + +function Base.:\(ksp::AbstractKSP, b::AbstractVec) + x = createvecs(ksp; nleft = 1).left[1] + ldiv!(x, ksp, b) + return x end +#= +# +# OLD WRAPPERS +# struct WrappedKSP{T, PetscLib} <: AbstractKSP{T, PetscLib} ptr::CKSP end -scalartype(::KSP{T}) where {T} = T -Base.eltype(::KSP{T}) where {T} = T - LinearAlgebra.transpose(ksp) = LinearAlgebra.Transpose(ksp) LinearAlgebra.adjoint(ksp) = LinearAlgebra.Adjoint(ksp) @@ -70,32 +188,6 @@ struct Fn_KSPComputeOperators{T} end @for_libpetsc begin - function KSP{$PetscScalar}(comm::MPI.Comm; kwargs...) - @assert initialized($petsclib) - opts = Options($petsclib, kwargs...) - ksp = KSP{$PetscScalar, $PetscLib}(opts=opts) - with(ksp.opts) do - @chk ccall((:KSPCreate, $libpetsc), PetscErrorCode, (MPI.MPI_Comm, Ptr{CKSP}), comm, ksp) - end - if comm == MPI.COMM_SELF - finalizer(destroy, ksp) - end - return ksp - end - - function destroy(ksp::KSP{$PetscScalar}) - finalized($petsclib) || - @chk ccall((:KSPDestroy, $libpetsc), PetscErrorCode, (Ptr{CKSP},), ksp) - return nothing - end - - function setoperators!(ksp::KSP{$PetscScalar}, A::AbstractMat{$PetscScalar}, P::AbstractMat{$PetscScalar}) - @chk ccall((:KSPSetOperators, $libpetsc), PetscErrorCode, (CKSP, CMat, CMat), ksp, A, P) - ksp._A = A - ksp._P = P - return nothing - end - function (::Fn_KSPComputeRHS{$PetscScalar})( new_ksp_ptr::CKSP, cb::CVec, @@ -184,12 +276,6 @@ struct Fn_KSPComputeOperators{T} end return nothing end - function setfromoptions!(ksp::KSP{$PetscScalar}) - with(ksp.opts) do - @chk ccall((:KSPSetFromOptions, $libpetsc), PetscErrorCode, (CKSP,), ksp) - end - end - function gettype(ksp::KSP{$PetscScalar}) t_r = Ref{CKSPType}() @chk ccall((:KSPGetType, $libpetsc), PetscErrorCode, (CKSP, Ptr{CKSPType}), ksp, t_r) @@ -217,14 +303,6 @@ struct Fn_KSPComputeOperators{T} end return r_rnorm[] end - function solve!(x::AbstractVec{$PetscScalar}, ksp::KSP{$PetscScalar}, b::AbstractVec{$PetscScalar}) - with(ksp.opts) do - @chk ccall((:KSPSolve, $libpetsc), PetscErrorCode, - (CKSP, CVec, CVec), ksp, b, x) - end - return x - end - function solve!(ksp::KSP{$PetscScalar}) with(ksp.opts) do @chk ccall((:KSPSolve, $libpetsc), PetscErrorCode, @@ -256,21 +334,6 @@ function LinearAlgebra.ldiv!(x::AbstractVector{T}, ksp::KSPAT{T, LT}, b::Abstrac end Base.:\(ksp::KSPAT{T, LT}, b::AbstractVector{T}) where {T, LT} = ldiv!(similar(b), ksp, b) - -""" - KSP(A, P; options...) - -Construct a PETSc Krylov subspace solver. - -Any PETSc options prefixed with `ksp_` and `pc_` can be passed as keywords. -""" -function KSP(A::AbstractMat{T}, P::AbstractMat{T}=A; kwargs...) where {T} - ksp = KSP{T}(getcomm(A); kwargs...) - setoperators!(ksp, A, P) - setfromoptions!(ksp) - return ksp -end - """ KSP(da::AbstractDM; options...) @@ -290,7 +353,6 @@ end Base.show(io::IO, ksp::KSP) = _show(io, ksp) - """ iters(ksp::KSP) @@ -301,7 +363,6 @@ $(_doc_external("KSP/KSPGetIterationNumber")) """ iters - """ resnorm(ksp::KSP) @@ -311,4 +372,4 @@ Gets the last (approximate preconditioned) residual norm that has been computed. $(_doc_external("KSP/KSPGetResidualNorm")) """ resnorm - +=# diff --git a/src/sys.jl b/src/sys.jl index 88380c5f..37ad2842 100644 --- a/src/sys.jl +++ b/src/sys.jl @@ -1,6 +1,6 @@ const CPetscObject = Ptr{Cvoid} -const UnionPetscTypes = Union{Options, AbstractVec, AbstractMat} +const UnionPetscTypes = Union{Options, AbstractVec, AbstractMat, AbstractKSP} # allows us to pass PETSc_XXX objects directly into CXXX ccall signatures Base.cconvert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj @@ -12,7 +12,11 @@ function Base.unsafe_convert(::Type{Ptr{CPetscObject}}, obj::UnionPetscTypes) end function getcomm( - obj::Union{AbstractVec{PetscLib}, AbstractMat{PetscLib}}, + obj::Union{ + AbstractVec{PetscLib}, + AbstractMat{PetscLib}, + AbstractKSP{PetscLib}, + }, ) where {PetscLib} comm = MPI.Comm() LibPETSc.PetscObjectGetComm(PetscLib, obj, comm) diff --git a/src/vec.jl b/src/vec.jl index eefbe131..4259db9a 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -612,3 +612,10 @@ function getpetsctype(vec::AbstractVec{PetscLib}) where {PetscLib} LibPETSc.VecGetType(PetscLib, vec, name_r) return unsafe_string(name_r[]) end + +function Base.similar(v::AbstractVec{PetscLib}) where {PetscLib} + r_x = Ref{CVec}() + LibPETSc.VecDuplicate(PetscLib, v, r_x) + x = VecPtr(PetscLib, r_x[], true) + return x +end diff --git a/test/ksp.jl b/test/ksp.jl new file mode 100644 index 00000000..cc477192 --- /dev/null +++ b/test/ksp.jl @@ -0,0 +1,82 @@ +using Test +using MPI +MPI.Initialized() || MPI.Init() +using PETSc +using LinearAlgebra: mul! + +@testset "KSP" begin + comm = MPI.COMM_WORLD + mpisize = MPI.Comm_size(comm) + mpirank = MPI.Comm_rank(comm) + + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + + loc_num_rows = 10 + loc_num_cols = 10 + diag_nonzeros = 3 + off_diag_non_zeros = 3 + + A = PETSc.MatAIJ( + petsclib, + comm, + loc_num_rows, + loc_num_cols, + diag_nonzeros, + off_diag_non_zeros, + ) + + # Get compatible vectors + (x, b) = PETSc.createvecs(A) + + row_rng = PETSc.ownershiprange(A, false) + for i in row_rng + if i == 0 + vals = [-2, 1] + row0idxs = [i] + col0idxs = [i, i + 1] + elseif i == mpisize * loc_num_rows - 1 + vals = [-2, 1] + row0idxs = [i] + col0idxs = [i, i - 1] + else + vals = [1, -2, 1] + row0idxs = [i] + col0idxs = [i - 1, i, i + 1] + end + PETSc.setvalues!( + A, + PetscInt.(row0idxs), + PetscInt.(col0idxs), + PetscScalar.(vals), + ) + x[i + 1] = (i + 1)^3 + end + PETSc.assemble!(A) + PETSc.assemble!(x) + + mul!(b, A, x) + y = similar(x) + + ksp = PETSc.KSP(A; ksp_rtol = 1e-16, pc_type = "jacobi") + PETSc.solve!(y, ksp, b) + PETSc.withlocalarray!(x, y) do x, y + @test x ≈ y + end + PETSc.destroy(x) + + x = ksp \ b + PETSc.withlocalarray!(x, y) do x, y + @test x ≈ y + end + PETSc.destroy(x) + + # PETSc.destroy(ksp) + PETSc.destroy(A) + PETSc.destroy(y) + PETSc.destroy(b) + PETSc.finalize(petsclib) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 85d81e9d..9c4a43ab 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,7 +3,7 @@ using MPI: mpiexec # Do the MPI tests first so we do not have mpi running inside MPI @testset "mpi tests" begin - for file in ("mpivec.jl", "mpimat.jl") + for file in ("mpivec.jl", "mpimat.jl", "ksp.jl") @test mpiexec() do mpi_cmd cmd = `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no --project $file` @@ -18,3 +18,4 @@ include("options.jl") include("vec.jl") include("mat.jl") include("matshell.jl") +include("ksp.jl") From 208bd91267ef6f724e087991423151cb51bc6913 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 4 Aug 2021 12:15:39 -0700 Subject: [PATCH 17/53] Update generator for DM --- gen/generator.toml | 3 ++- gen/prologue.jl | 13 ++++++++++++- lib/petsc_library.jl | 21 ++++++++++++--------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gen/generator.toml b/gen/generator.toml index 3f8f9266..3362aac9 100644 --- a/gen/generator.toml +++ b/gen/generator.toml @@ -14,9 +14,10 @@ printer_blacklist = [ "PetscOptions", "_n_PetscOptions", "PetscViewer", "_p_PetscViewer", "PetscObject", "_p_PetscObject", - "Mat", "_p_Mat", + "Mat", "_p_Mat", "MatType", "Vec", "_p_Vec", "VecType", "KSP", "_p_KSP", "KSPType", + "DM", "_p_DM", "DMType", # # Remove types defined in const.jl # diff --git a/gen/prologue.jl b/gen/prologue.jl index cb14aebb..83753561 100644 --- a/gen/prologue.jl +++ b/gen/prologue.jl @@ -1,3 +1,7 @@ +# +# START OF PROLOGUE +# + using MPI const MPI_Comm = MPI.MPI_Comm const MPI_Datatype = MPI.MPI_Datatype @@ -22,7 +26,14 @@ const PetscOptions = Ptr{Cvoid} const PetscViewer = Ptr{Cvoid} const PetscObject = Ptr{Cvoid} const Vec = Ptr{Cvoid} +const VecType = Cstring const Mat = Ptr{Cvoid} +const MatType = Cstring const KSP = Ptr{Cvoid} -const VecType = Cstring const KSPType = Cstring +const DM = Ptr{Cvoid} +const DMType = Cstring + +# +# END OF PROLOGUE +# diff --git a/lib/petsc_library.jl b/lib/petsc_library.jl index d4dd86a1..b3efde79 100644 --- a/lib/petsc_library.jl +++ b/lib/petsc_library.jl @@ -1,3 +1,7 @@ +# +# START OF PROLOGUE +# + using MPI const MPI_Comm = MPI.MPI_Comm const MPI_Datatype = MPI.MPI_Datatype @@ -22,10 +26,17 @@ const PetscOptions = Ptr{Cvoid} const PetscViewer = Ptr{Cvoid} const PetscObject = Ptr{Cvoid} const Vec = Ptr{Cvoid} +const VecType = Cstring const Mat = Ptr{Cvoid} +const MatType = Cstring const KSP = Ptr{Cvoid} -const VecType = Cstring const KSPType = Cstring +const DM = Ptr{Cvoid} +const DMType = Cstring + +# +# END OF PROLOGUE +# const __darwin_off_t = Int64 @@ -18412,8 +18423,6 @@ end ) end -const MatType = Ptr{Cchar} - const MatSolverType = Ptr{Cchar} @enum MatFactorType::UInt32 begin @@ -26357,10 +26366,6 @@ end ) end -mutable struct _p_DM end - -const DM = Ptr{_p_DM} - @enum DMBoundaryType::UInt32 begin DM_BOUNDARY_NONE = 0 DM_BOUNDARY_GHOSTED = 1 @@ -26988,8 +26993,6 @@ const PetscWeakForm = Ptr{_p_PetscWeakForm} @chk ccall((:DMInitializePackage, $petsc_library), PetscErrorCode, ()) end -const DMType = Ptr{Cchar} - @for_petsc function DMCreate(::$UnionPetscLib, arg1, arg2) @chk ccall( (:DMCreate, $petsc_library), From bb45f9739787c067d4c27d8270a86c5d9451069b Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Thu, 5 Aug 2021 08:31:23 -0700 Subject: [PATCH 18/53] Fix generator for MatStencil --- gen/generator.toml | 19 +--- gen/wrap.jl | 61 +++++++++-- lib/petsc_library.jl | 253 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 305 insertions(+), 28 deletions(-) diff --git a/gen/generator.toml b/gen/generator.toml index 3362aac9..2a1aabd2 100644 --- a/gen/generator.toml +++ b/gen/generator.toml @@ -7,6 +7,8 @@ auto_mutability = true prologue_file_path = "./prologue.jl" # epilogue_file_path = "./epilogue.jl" +auto_mutability_blacklist = ["MatStencil"] + printer_blacklist = [ # # Defined in the prologue @@ -202,23 +204,6 @@ printer_blacklist = [ "VecTaggerCDFSetBox", "VecTaggerCDFGetBox", # -# Need MatStencil to work with interpotated values -# - "MatStencil", - "MatSetValuesStencil", - "MatSetValuesBlockedStencil", - "MatZeroRowsStencil", - "MatZeroRowsColumnsStencil", - "DMDACreatePatchIS", - "DMDAConvertToCell", - "DMDAConvertToCell", - "DMPatchZoom", - "DMPatchGetPatchSize", - "DMPatchSetPatchSize", - "DMPatchGetCommSize", - "DMPatchSetCommSize", - "DMPatchCreateGrid", -# # Need MatFactorInfo to work with interpotated values # "MatFactorInfo", diff --git a/gen/wrap.jl b/gen/wrap.jl index f35921d3..7a27a509 100644 --- a/gen/wrap.jl +++ b/gen/wrap.jl @@ -14,8 +14,8 @@ mutable struct State end function pass(x, state, f = (x, state) -> nothing) - f(x, state) - if length(x) > 0 + res = f(x, state) + if res && length(x) > 0 for a in x pass(a, state, f) end @@ -33,7 +33,8 @@ function add_chk(x, state) @assert body isa CSTParser.EXPR && body.head == :block @assert length(body) == 1 - # Clang.jl-generated ccalls should be directly part of a function definition + # Clang.jl-generated ccalls should be directly part of a function + # definition call = body.args[1] if call isa CSTParser.EXPR && call.head == :call && @@ -53,6 +54,7 @@ function add_chk(x, state) end end end + true end # make every function have $UnionPetscLib as the first argument @@ -62,7 +64,8 @@ function add_UnionPetscLib(x, state) @assert body isa CSTParser.EXPR && body.head == :block @assert length(body) == 1 - # Clang.jl-generated ccalls should be directly part of a function definition + # Clang.jl-generated ccalls should be directly part of a function + # definition call = body.args[1] if call isa CSTParser.EXPR && call.head == :call && @@ -76,6 +79,7 @@ function add_UnionPetscLib(x, state) ) end end + true end # make every function have $UnionPetscLib as the first argument @@ -85,7 +89,8 @@ function add_for_petsc(x, state) @assert body isa CSTParser.EXPR && body.head == :block @assert length(body) == 1 - # Clang.jl-generated ccalls should be directly part of a function definition + # Clang.jl-generated ccalls should be directly part of a function + # definition call = body.args[1] if call isa CSTParser.EXPR && ( (call.head == :call && call[1].val == "ccall") || @@ -94,13 +99,45 @@ function add_for_petsc(x, state) push!(state.edits, Edit(state.offset, "@for_petsc ")) end end + true end -# make every function have $UnionPetscLib as the first argument -function add_for_interpolate(x, state, val) +# interpolate the `val` in the functions with `@for_petsc` +function add_interpolations(x, state, vals) + # skip structs + if x isa CSTParser.EXPR && x.head == :struct + return false + end + if x isa CSTParser.EXPR && x.head == :IDENTIFIER && x.val in vals + push!(state.edits, Edit(state.offset, "\$")) + end + true +end + +function add_struct_types(x, state, name, val) + # skip structs + if x isa CSTParser.EXPR && x.head == :struct + return false + end if x isa CSTParser.EXPR && x.head == :IDENTIFIER && x.val == val push!(state.edits, Edit(state.offset, "\$")) end + true +end + +# Make the `structs` have type values `vals` +function add_struct_type(x, state, structs, vals) + # XXX: Maybe not the best way to do this... + if x isa CSTParser.EXPR && x.head == :IDENTIFIER && x.val in structs + push!( + state.edits, + Edit( + state.offset + length(x.val), + "{" * reduce((x, y) -> "" * x * "," * y, vals) * "}", + ), + ) + end + true end # make petsc_library @@ -117,10 +154,12 @@ function mangle_functions(output_file) add_UnionPetscLib, add_chk, add_for_petsc, - (x, s) -> add_for_interpolate(x, s, "PetscReal"), - (x, s) -> add_for_interpolate(x, s, "PetscInt"), - (x, s) -> add_for_interpolate(x, s, "PetscComplex"), - (x, s) -> add_for_interpolate(x, s, "PetscScalar"), + (x, s) -> add_struct_type(x, s, ("MatStencil",), ("PetscInt",)), + (x, s) -> add_interpolations( + x, + s, + ("PetscReal", "PetscInt", "PetscComplex", "PetscScalar"), + ), ) state = State(0, Edit[]) ast = CSTParser.parse(text, true) diff --git a/lib/petsc_library.jl b/lib/petsc_library.jl index b3efde79..3399c707 100644 --- a/lib/petsc_library.jl +++ b/lib/petsc_library.jl @@ -20349,6 +20349,77 @@ end ) end +struct MatStencil{PetscInt} + k::PetscInt + j::PetscInt + i::PetscInt + c::PetscInt +end + +@for_petsc function MatSetValuesStencil( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatSetValuesStencil, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{MatStencil{$PetscInt}}, + $PetscInt, + Ptr{MatStencil{$PetscInt}}, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + +@for_petsc function MatSetValuesBlockedStencil( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:MatSetValuesBlockedStencil, $petsc_library), + PetscErrorCode, + ( + Mat, + $PetscInt, + Ptr{MatStencil{$PetscInt}}, + $PetscInt, + Ptr{MatStencil{$PetscInt}}, + Ptr{$PetscScalar}, + InsertMode, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + @for_petsc function MatSetStencil( ::$UnionPetscLib, arg1, @@ -21885,6 +21956,50 @@ end ) end +@for_petsc function MatZeroRowsStencil( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatZeroRowsStencil, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{MatStencil{$PetscInt}}, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + +@for_petsc function MatZeroRowsColumnsStencil( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:MatZeroRowsColumnsStencil, $petsc_library), + PetscErrorCode, + (Mat, $PetscInt, Ptr{MatStencil{$PetscInt}}, $PetscScalar, Vec, Vec), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + @for_petsc function MatZeroRowsColumns( ::$UnionPetscLib, arg1, @@ -34569,6 +34684,32 @@ end ) end +@for_petsc function DMDACreatePatchIS( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, +) + @chk ccall( + (:DMDACreatePatchIS, $petsc_library), + PetscErrorCode, + ( + DM, + Ptr{MatStencil{$PetscInt}}, + Ptr{MatStencil{$PetscInt}}, + Ptr{IS}, + PetscBool, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + ) +end + @for_petsc function MatRegisterDAAD(::$UnionPetscLib) @chk ccall((:MatRegisterDAAD, $petsc_library), PetscErrorCode, ()) end @@ -34894,6 +35035,17 @@ end ) end +@for_petsc function DMDAConvertToCell(::$UnionPetscLib, arg1, arg2, arg3) + @chk ccall( + (:DMDAConvertToCell, $petsc_library), + PetscErrorCode, + (DM, MatStencil{$PetscInt}, Ptr{$PetscInt}), + arg1, + arg2, + arg3, + ) +end + @for_petsc function DMDASetVertexCoordinates( ::$UnionPetscLib, arg1, @@ -35167,10 +35319,82 @@ end ) end +@for_petsc function DMPatchZoom( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, +) + @chk ccall( + (:DMPatchZoom, $petsc_library), + PetscErrorCode, + ( + DM, + MatStencil{$PetscInt}, + MatStencil{$PetscInt}, + MPI_Comm, + Ptr{DM}, + Ptr{PetscSF}, + Ptr{PetscSF}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + ) +end + @for_petsc function DMPatchSolve(::$UnionPetscLib, arg1) @chk ccall((:DMPatchSolve, $petsc_library), PetscErrorCode, (DM,), arg1) end +@for_petsc function DMPatchGetPatchSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPatchGetPatchSize, $petsc_library), + PetscErrorCode, + (DM, Ptr{MatStencil{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function DMPatchSetPatchSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPatchSetPatchSize, $petsc_library), + PetscErrorCode, + (DM, MatStencil{$PetscInt}), + arg1, + arg2, + ) +end + +@for_petsc function DMPatchGetCommSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPatchGetCommSize, $petsc_library), + PetscErrorCode, + (DM, Ptr{MatStencil{$PetscInt}}), + arg1, + arg2, + ) +end + +@for_petsc function DMPatchSetCommSize(::$UnionPetscLib, arg1, arg2) + @chk ccall( + (:DMPatchSetCommSize, $petsc_library), + PetscErrorCode, + (DM, MatStencil{$PetscInt}), + arg1, + arg2, + ) +end + @for_petsc function DMPatchGetCoarse(::$UnionPetscLib, arg1, arg2) @chk ccall( (:DMPatchGetCoarse, $petsc_library), @@ -35181,6 +35405,35 @@ end ) end +@for_petsc function DMPatchCreateGrid( + ::$UnionPetscLib, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, +) + @chk ccall( + (:DMPatchCreateGrid, $petsc_library), + PetscErrorCode, + ( + MPI_Comm, + $PetscInt, + MatStencil{$PetscInt}, + MatStencil{$PetscInt}, + MatStencil{$PetscInt}, + Ptr{DM}, + ), + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + ) +end + mutable struct _p_PetscPartitioner end const PetscPartitioner = Ptr{_p_PetscPartitioner} From 29247995a70aa91a34d23b705a93872f80fd5a9b Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Thu, 5 Aug 2021 15:57:19 -0700 Subject: [PATCH 19/53] Add in basic dm and dmda functionality --- src/LibPETSc.jl | 12 +- src/PETSc.jl | 4 +- src/dm.jl | 166 +++++++------- src/dmda.jl | 566 +++++++++++++++++++---------------------------- src/mat.jl | 148 +++++++++++++ src/sys.jl | 3 +- test/dmda.jl | 285 ++++++++++++------------ test/runtests.jl | 3 +- 8 files changed, 609 insertions(+), 578 deletions(-) diff --git a/src/LibPETSc.jl b/src/LibPETSc.jl index 27690fe2..b23e6eb6 100644 --- a/src/LibPETSc.jl +++ b/src/LibPETSc.jl @@ -35,7 +35,17 @@ export PetscLibType, SCATTER_FORWARD, SCATTER_REVERSE, SCATTER_FORWARD_LOCAL, - SCATTER_REVERSE_LOCAL + SCATTER_REVERSE_LOCAL, + DMBoundaryType, + DM_BOUNDARY_NONE, + DM_BOUNDARY_GHOSTED, + DM_BOUNDARY_MIRROR, + DM_BOUNDARY_PERIODIC, + DM_BOUNDARY_TWIST, + DMDAStencilType, + DMDA_STENCIL_STAR, + DMDA_STENCIL_BOX, + MatStencil include("LibPETSc_const.jl") include("LibPETSc_startup.jl") diff --git a/src/PETSc.jl b/src/PETSc.jl index 9eb1a7ec..3ad41b6c 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -26,8 +26,8 @@ include("options.jl") include("vec.jl") include("mat.jl") include("matshell.jl") -# include("dm.jl") -# include("dmda.jl") +include("dm.jl") +include("dmda.jl") # include("dmstag.jl") include("ksp.jl") # include("pc.jl") diff --git a/src/dm.jl b/src/dm.jl index a81e569c..a43678d2 100644 --- a/src/dm.jl +++ b/src/dm.jl @@ -1,91 +1,54 @@ const CDM = Ptr{Cvoid} abstract type AbstractDM{PetscLib} end -""" - DMLocalVec(v::CVec, dm::AbstractDM) - -Container for an PETSc vector we know is "local" - -# External Links -$(_doc_external("Vec/Vec")) -""" -mutable struct DMLocalVec{PetscLib, T, T_DM} <: AbstractVec{T} - ptr::CVec - dm::T_DM - function DMLocalVec(ptr, dm::AbstractDM{PetscLib}) where {PetscLib} - new{PetscLib, scalartype(PetscLib), typeof(dm)}(ptr, dm) - end +function destroy(dm::AbstractDM{PetscLib}) where {PetscLib} + finalized(PetscLib) || LibPETSc.DMDestroy(PetscLib, dm) + dm.ptr = C_NULL + return nothing end """ - DMGlobalVec(v::CVec, dm::AbstractDM) - -Container for an PETSc vector we know is "global" + setfromoptions!(dm::DM, opts=dm.opts) # External Links -$(_doc_external("Vec/Vec")) +$(_doc_external("DM/DMSetFromOptions")) """ -mutable struct DMGlobalVec{PetscLib, T, T_DM} <: AbstractVec{T} - ptr::CVec - dm::T_DM - function DMGlobalVec(ptr, dm::AbstractDM{PetscLib}) where {PetscLib} - new{PetscLib, scalartype(PetscLib), typeof(dm)}(ptr, dm) +function setfromoptions!( + dm::AbstractDM{PetscLib}, + opts::Options = dm.opts, +) where {PetscLib} + with(opts) do + LibPETSc.DMSetFromOptions(PetscLib, dm) end end -# Mainly for DM we do not know the type of, namely ones returned by PETSc -# functions such as `KSPGetDM` -mutable struct PetscDM{PetscLib} <: AbstractDM{PetscLib} - ptr::CDM -end - """ - setup!(da::DM, opts=da.opts) + setup!(dm::DM, opts=dm.opts) # External Links $(_doc_external("DM/DMSetUp")) """ -function setup! end - -@for_petsc function setup!(da::AbstractDM{$PetscLib}, opts::Options = da.opts) +function setup!( + dm::AbstractDM{PetscLib}, + opts::Options = dm.opts, +) where {PetscLib} with(opts) do - @chk ccall((:DMSetUp, $petsc_library), PetscErrorCode, (CDM,), da) + LibPETSc.DMSetUp(PetscLib, dm) end end """ - setfromoptions!(da::DM, opts=da.opts) + gettype(dm::AbstractDM) + +Gets type name of the `dm` # External Links -$(_doc_external("DM/DMSetFromOptions")) +$(_doc_external("DM/DMGetType")) """ -function setfromoptions! end - -@for_petsc function setfromoptions!( - da::AbstractDM{$PetscLib}, - opts::Options = da.opts, -) - with(opts) do - @chk ccall( - (:DMSetFromOptions, $petsc_library), - PetscErrorCode, - (CDM,), - da, - ) - end -end - -@for_petsc begin - function destroy(da::AbstractDM{$PetscLib}) - finalized($PetscLib) || @chk ccall( - (:DMDestroy, $petsc_library), - PetscErrorCode, - (Ptr{CDM},), - da, - ) - da.ptr = C_NULL - return nothing - end +function gettype(dm::AbstractDM{PetscLib}) where {PetscLib} + t_r = Ref{Cstring}() + LibPETSc.DMGetType(PetscLib, dm, t_r) + return unsafe_string(t_r[]) end """ @@ -96,42 +59,68 @@ Return the topological dimension of the `dm` # External Links $(_doc_external("DM/DMGetDimension")) """ -function getdimension(::AbstractDM) end +function getdimension(dm::AbstractDM{PetscLib}) where {PetscLib} + r_dim = Ref{PetscLib.PetscInt}() + LibPETSc.DMGetDimension(PetscLib, dm, r_dim) + return r_dim[] +end -@for_petsc function getdimension(dm::AbstractDM{$PetscLib}) - dim = Ref{$PetscInt}() +""" + MatAIJ(dm::AbstractDM) - @chk ccall( - (:DMGetDimension, $petsc_library), - PetscErrorCode, - (CDM, Ptr{$PetscInt}), - dm, - dim, - ) +Generates a matrix from the `dm` object. + +# External Links +$(_doc_external("DM/DMCreateMatrix")) +""" +function MatAIJ(dm::AbstractDM{PetscLib}) where {PetscLib} + mat = MatAIJ{PetscLib, PetscLib.PetscScalar}(C_NULL) - return dim[] + LibPETSc.DMCreateMatrix(PetscLib, dm, mat) + + return mat end +#= +# +# OLD WRAPPERS +# """ - gettype(dm::AbstractDM) + DMLocalVec(v::CVec, dm::AbstractDM) -Gets type name of the `dm` +Container for an PETSc vector we know is "local" # External Links -$(_doc_external("DM/DMGetType")) +$(_doc_external("Vec/Vec")) """ -function gettype(::AbstractDM) end +mutable struct DMLocalVec{PetscLib, T, T_DM} <: AbstractVec{T} + ptr::CVec + dm::T_DM + function DMLocalVec(ptr, dm::AbstractDM{PetscLib}) where {PetscLib} + new{PetscLib, scalartype(PetscLib), typeof(dm)}(ptr, dm) + end +end -@for_petsc function gettype(dm::AbstractDM{$PetscLib}) - t_r = Ref{Cstring}() - @chk ccall( - (:DMGetType, $petsc_library), - PetscErrorCode, - (CDM, Ptr{Cstring}), - dm, - t_r, - ) - return unsafe_string(t_r[]) +""" + DMGlobalVec(v::CVec, dm::AbstractDM) + +Container for an PETSc vector we know is "global" + +# External Links +$(_doc_external("Vec/Vec")) +""" +mutable struct DMGlobalVec{PetscLib, T, T_DM} <: AbstractVec{T} + ptr::CVec + dm::T_DM + function DMGlobalVec(ptr, dm::AbstractDM{PetscLib}) where {PetscLib} + new{PetscLib, scalartype(PetscLib), typeof(dm)}(ptr, dm) + end +end + +# Mainly for DM we do not know the type of, namely ones returned by PETSc +# functions such as `KSPGetDM` +mutable struct PetscDM{PetscLib} <: AbstractDM{PetscLib} + ptr::CDM end """ @@ -520,3 +509,4 @@ function getcoordinateslocal end return coord_vec end +=# diff --git a/src/dmda.jl b/src/dmda.jl index c883506a..1a560500 100644 --- a/src/dmda.jl +++ b/src/dmda.jl @@ -1,383 +1,248 @@ -mutable struct DMDALocalInfo{IT} - dim::IT - dof_per_node::IT - stencil_width::IT - global_size::NTuple{3, IT} - local_start::NTuple{3, IT} - local_size::NTuple{3, IT} - ghosted_local_start::NTuple{3, IT} - ghosted_local_size::NTuple{3, IT} - boundary_type::NTuple{3, DMBoundaryType} - stencil_type::DMDAStencilType - ___padding___::NTuple{5, IT} - DMDALocalInfo{IT}() where {IT} = new{IT}() -end +abstract type AbstractDMDA{PetscLib} <: AbstractDM{PetscLib} end -mutable struct DMDA{PetscLib} <: AbstractDM{PetscLib} +mutable struct DMDA{PetscLib} <: AbstractDMDA{PetscLib} ptr::CDM opts::Options{PetscLib} - DMDA{PetscLib}(ptr, opts = Options(PetscLib)) where {PetscLib} = - new{PetscLib}(ptr, opts) end """ - empty(da::DMDA) - -return an uninitialized `DMDA` struct. -""" -Base.empty(::DMDA{PetscLib}) where {PetscLib} = DMDA{PetscLib}(C_NULL) - -""" - DMDACreate1d( - ::PetscLib + DMDA( + petsclib::PetscLib comm::MPI.Comm, - boundary_type::DMBoundaryType, - global_dim, - dof_per_node, - stencil_width, - points_per_proc::Union{Nothing, Vector{PetscInt}}; - dmsetfromoptions=true, - dmsetup=true, + boundary_type::NTuple{D, DMBoundaryType}, + global_dim::NTuple{D, Integer}, + dof_per_node::Integer, + stencil_width::Integer, + stencil_type; + points_per_proc::Tuple, + processors::Tuple, + setfromoptions = true, + dmsetup = true, options... ) -Creates a 1-D distributed array with the options specified using keyword -arguments. +Creates a D-dimensional distributed array with the options specified using +keyword arguments. + +If keyword argument `points_per_proc[k] isa Vector{petsclib.PetscInt}` then this +specifies the points per processor in dimension `k`. + +If keyword argument `processors[k] isa Integer` then this specifies the number of +processors used in dimension `k`; ignored when `D == 1`. + +If keyword argument `setfromoptions == true` then `setfromoptions!` called. -If keyword argument `dmsetfromoptions == true` then `setfromoptions!` called. If keyword argument `dmsetup == true` then `setup!` is called. +When `D == 1` the `stencil_type` argument is not required and ignored if +specified. + # External Links $(_doc_external("DMDA/DMDACreate1d")) +$(_doc_external("DMDA/DMDACreate2d")) +$(_doc_external("DMDA/DMDACreate3d")) """ -function DMDACreate1d end - -@for_petsc function DMDACreate1d( - ::$UnionPetscLib, +function DMDA( + petsclib::PetscLib, comm::MPI.Comm, - boundary_type::DMBoundaryType, - global_dim, - dof_per_node, - stencil_width, - points_per_proc::Union{Nothing, Vector{$PetscInt}}; - dmsetfromoptions = true, + boundary_type::NTuple{1, DMBoundaryType}, + global_dim::NTuple{1, Integer}, + dof_per_node::Integer, + stencil_width::Integer, + stencil_type = nothing; + points_per_proc::Tuple = (nothing,), + processors = nothing, + setfromoptions = true, dmsetup = true, options..., -) - opts = Options($petsclib, options...) - ref_points_per_proc = if isnothing(points_per_proc) - C_NULL - else - @assert length(points_per_proc) == MPI.Comm_size(comm) - points_per_proc - end - da = DMDA{$PetscLib}(C_NULL, opts) +) where {PetscLib} + opts = Options(petsclib; options...) + da = DMDA{PetscLib}(C_NULL, opts) + + @assert length(points_per_proc) == 1 + + ref_points_per_proc = + if isnothing(points_per_proc[1]) || points_per_proc[1] == PETSC_DECIDE + C_NULL + else + @assert points_per_proc[1] isa Array{PetscLib.PetscInt} + @assert length(points_per_proc[1]) == MPI.Comm_size(comm) + points_per_proc[1] + end + with(da.opts) do - @chk ccall( - (:DMDACreate1d, $petsc_library), - PetscErrorCode, - ( - MPI.MPI_Comm, - DMBoundaryType, - $PetscInt, - $PetscInt, - $PetscInt, - Ptr{$PetscInt}, - Ptr{CDM}, - ), + LibPETSc.DMDACreate1d( + PetscLib, comm, - boundary_type, - global_dim, + boundary_type[1], + global_dim[1], dof_per_node, stencil_width, ref_points_per_proc, da, ) end - dmsetfromoptions && setfromoptions!(da) + setfromoptions && setfromoptions!(da) dmsetup && setup!(da) + # We can only let the garbage collect finalize when we do not need to # worry about MPI (since garbage collection is asyncronous) - if comm == MPI.COMM_SELF + if MPI.Comm_size(comm) == 1 finalizer(destroy, da) end return da end -""" - DMDACreate2d( - ::PetscLib - comm::MPI.Comm, - boundary_type_x::DMBoundaryType, - boundary_type_y::DMBoundaryType, - stencil_type::DMDAStencilType, - global_dim_x, - global_dim_y, - procs_x, - procs_y, - dof_per_node, - stencil_width, - points_per_proc_x::Union{Nothing, Vector{PetscInt}}; - points_per_proc_y::Union{Nothing, Vector{PetscInt}}; - dmsetfromoptions=true, - dmsetup=true, - options... - ) - -Creates a 2-D distributed array with the options specified using keyword -arguments. - -If keyword argument `dmsetfromoptions == true` then `setfromoptions!` called. -If keyword argument `dmsetup == true` then `setup!` is called. - -# External Links -$(_doc_external("DMDA/DMDACreate2d")) -""" -function DMDACreate2d end - -@for_petsc function DMDACreate2d( - ::$UnionPetscLib, +function DMDA( + petsclib::PetscLib, comm::MPI.Comm, - boundary_type_x::DMBoundaryType, - boundary_type_y::DMBoundaryType, - stencil_type::DMDAStencilType, - global_dim_x, - global_dim_y, - procs_x, - procs_y, - dof_per_node, - stencil_width, - points_per_proc_x::Union{Nothing, Vector{$PetscInt}}, - points_per_proc_y::Union{Nothing, Vector{$PetscInt}}; - dmsetfromoptions = true, + boundary_type::NTuple{2, DMBoundaryType}, + global_dim::NTuple{2, Integer}, + dof_per_node::Integer, + stencil_width::Integer, + stencil_type; + points_per_proc::Tuple = (nothing, nothing), + processors::Tuple = (PETSC_DECIDE, PETSC_DECIDE), + setfromoptions = true, dmsetup = true, options..., -) - opts = Options($petsclib, options...) - ref_points_per_proc_x = if isnothing(points_per_proc_x) - C_NULL - else - @assert length(points_per_proc_x) == procs_x - points_per_proc_x +) where {PetscLib} + opts = Options(petsclib; options...) + da = DMDA{PetscLib}(C_NULL, opts) + + @assert length(points_per_proc) == 2 + + ref_points_per_proc = ntuple(2) do d + if isnothing(points_per_proc[d]) || points_per_proc[d] == PETSC_DECIDE + C_NULL + else + @assert points_per_proc[d] isa Array{PetscLib.PetscInt} + @assert length(points_per_proc[d]) == MPI.Comm_size(comm) + points_per_proc[d] + end end - ref_points_per_proc_y = if isnothing(points_per_proc_y) - C_NULL - else - @assert length(points_per_proc_y) == procs_y - points_per_proc_y - end - da = DMDA{$PetscLib}(C_NULL, opts) + with(da.opts) do - @chk ccall( - (:DMDACreate2d, $petsc_library), - PetscErrorCode, - ( - MPI.MPI_Comm, - DMBoundaryType, - DMBoundaryType, - DMDAStencilType, - $PetscInt, - $PetscInt, - $PetscInt, - $PetscInt, - $PetscInt, - $PetscInt, - Ptr{$PetscInt}, - Ptr{$PetscInt}, - Ptr{CDM}, - ), + LibPETSc.DMDACreate2d( + PetscLib, comm, - boundary_type_x, - boundary_type_y, + boundary_type[1], + boundary_type[2], stencil_type, - global_dim_x, - global_dim_y, - procs_x, - procs_y, + global_dim[1], + global_dim[2], + processors[1], + processors[2], dof_per_node, stencil_width, - ref_points_per_proc_x, - ref_points_per_proc_y, + ref_points_per_proc[1], + ref_points_per_proc[2], da, ) end - dmsetfromoptions && setfromoptions!(da) + setfromoptions && setfromoptions!(da) dmsetup && setup!(da) + # We can only let the garbage collect finalize when we do not need to # worry about MPI (since garbage collection is asyncronous) - if comm == MPI.COMM_SELF + if MPI.Comm_size(comm) == 1 finalizer(destroy, da) end return da end -""" - DMDACreate3d( - ::PetscLib - comm::MPI.Comm, - boundary_type_x::DMBoundaryType, - boundary_type_y::DMBoundaryType, - boundary_type_z::DMBoundaryType, - stencil_type::DMDAStencilType, - global_dim_x, - global_dim_y, - global_dim_z, - procs_x, - procs_y, - procs_z, - global_dim_z, - dof_per_node, - stencil_width, - points_per_proc_x::Union{Nothing, Vector{PetscInt}}; - points_per_proc_y::Union{Nothing, Vector{PetscInt}}; - points_per_proc_z::Union{Nothing, Vector{PetscInt}}; - dmsetfromoptions=true, - dmsetup=true, - options... - ) - -Creates a 3-D distributed array with the options specified using keyword -arguments. - -If keyword argument `dmsetfromoptions == true` then `setfromoptions!` called. -If keyword argument `dmsetup == true` then `setup!` is called. - -# External Links -$(_doc_external("DMDA/DMDACreate3d")) -""" -function DMDACreate3d end - -@for_petsc function DMDACreate3d( - ::$UnionPetscLib, +function DMDA( + petsclib::PetscLib, comm::MPI.Comm, - boundary_type_x::DMBoundaryType, - boundary_type_y::DMBoundaryType, - boundary_type_z::DMBoundaryType, - stencil_type::DMDAStencilType, - global_dim_x, - global_dim_y, - global_dim_z, - procs_x, - procs_y, - procs_z, - dof_per_node, - stencil_width, - points_per_proc_x::Union{Nothing, Vector{$PetscInt}}, - points_per_proc_y::Union{Nothing, Vector{$PetscInt}}, - points_per_proc_z::Union{Nothing, Vector{$PetscInt}}; - dmsetfromoptions = true, + boundary_type::NTuple{3, DMBoundaryType}, + global_dim::NTuple{3, Integer}, + dof_per_node::Integer, + stencil_width::Integer, + stencil_type; + points_per_proc::Tuple = (nothing, nothing, nothing), + processors::Tuple = (PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE), + setfromoptions = true, dmsetup = true, options..., -) - opts = Options($petsclib, options...) - ref_points_per_proc_x = if isnothing(points_per_proc_x) - C_NULL - else - @assert length(points_per_proc_x) == procs_x - points_per_proc_x +) where {PetscLib} + opts = Options(petsclib; options...) + da = DMDA{PetscLib}(C_NULL, opts) + + @assert length(points_per_proc) == 3 + + ref_points_per_proc = ntuple(3) do d + if isnothing(points_per_proc[d]) || points_per_proc[d] == PETSC_DECIDE + C_NULL + else + @assert points_per_proc[d] isa Array{PetscLib.PetscInt} + @assert length(points_per_proc[d]) == MPI.Comm_size(comm) + points_per_proc[d] + end end - ref_points_per_proc_y = if isnothing(points_per_proc_y) - C_NULL - else - @assert length(points_per_proc_y) == procs_y - points_per_proc_y - end - ref_points_per_proc_z = if isnothing(points_per_proc_z) - C_NULL - else - @assert length(points_per_proc_z) == procs_z - points_per_proc_z - end - da = DMDA{$PetscLib}(C_NULL, opts) + with(da.opts) do - @chk ccall( - (:DMDACreate3d, $petsc_library), - PetscErrorCode, - ( - MPI.MPI_Comm, - DMBoundaryType, - DMBoundaryType, - DMBoundaryType, - DMDAStencilType, - $PetscInt, - $PetscInt, - $PetscInt, - $PetscInt, - $PetscInt, - $PetscInt, - $PetscInt, - $PetscInt, - Ptr{$PetscInt}, - Ptr{$PetscInt}, - Ptr{$PetscInt}, - Ptr{CDM}, - ), + LibPETSc.DMDACreate3d( + PetscLib, comm, - boundary_type_x, - boundary_type_y, - boundary_type_z, + boundary_type[1], + boundary_type[2], + boundary_type[3], stencil_type, - global_dim_x, - global_dim_y, - global_dim_z, - procs_x, - procs_y, - procs_z, + global_dim[1], + global_dim[2], + global_dim[3], + processors[1], + processors[2], + processors[3], dof_per_node, stencil_width, - ref_points_per_proc_x, - ref_points_per_proc_y, - ref_points_per_proc_z, + ref_points_per_proc[1], + ref_points_per_proc[2], + ref_points_per_proc[3], da, ) end - dmsetfromoptions && setfromoptions!(da) + setfromoptions && setfromoptions!(da) dmsetup && setup!(da) + # We can only let the garbage collect finalize when we do not need to # worry about MPI (since garbage collection is asyncronous) - if comm == MPI.COMM_SELF + if MPI.Comm_size(comm) == 1 finalizer(destroy, da) end return da end """ - getinfo(da::DMDA) + getinfo(da::AbstractDMDA) -Get the info associated with the distributed array `da`. +Get the info associated with the distributed array `da`. Returns `V` which has +fields + + - `dim` + - `global_size` (`Tuple` of length 3) + - `procs_per_dim` (`Tuple` of length 3) + - `dof_per_node` + - `boundary_type` (`Tuple` of length 3) + - `stencil_width` + - `stencil_type` # External Links $(_doc_external("DMDA/DMDAGetInfo")) """ -getinfo(::DMDA) - -@for_petsc function getinfo(da::DMDA{$PetscLib}) - dim = [$PetscInt(0)] - glo_size = [$PetscInt(0), $PetscInt(0), $PetscInt(0)] - procs_per_dim = [$PetscInt(0), $PetscInt(0), $PetscInt(0)] - dof_per_node = [$PetscInt(0)] - stencil_width = [$PetscInt(0)] +function getinfo(da::AbstractDMDA{PetscLib}) where {PetscLib} + PetscInt = PetscLib.PetscInt + + dim = [PetscInt(0)] + glo_size = [PetscInt(0), PetscInt(0), PetscInt(0)] + procs_per_dim = [PetscInt(0), PetscInt(0), PetscInt(0)] + dof_per_node = [PetscInt(0)] + stencil_width = [PetscInt(0)] boundary_type = [DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE] stencil_type = [DMDA_STENCIL_STAR] - @chk ccall( - (:DMDAGetInfo, $petsc_library), - PetscErrorCode, - ( - CDM, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{DMBoundaryType}, - Ref{DMBoundaryType}, - Ref{DMBoundaryType}, - Ref{DMDAStencilType}, - ), + + LibPETSc.DMDAGetInfo( + PetscLib, da, dim, Ref(glo_size, 1), @@ -393,19 +258,20 @@ getinfo(::DMDA) Ref(boundary_type, 3), stencil_type, ) + return ( dim = dim[1], - global_size = glo_size, - procs_per_dim = procs_per_dim, + global_size = (glo_size...,), + procs_per_dim = (procs_per_dim...,), dof_per_node = dof_per_node[1], - boundary_type = boundary_type, + boundary_type = (boundary_type...,), stencil_width = stencil_width[1], stencil_type = stencil_type[1], ) end """ - getcorners(da::DMDA) + getcorners(da::AbstractDMDA) Returns a `NamedTuple` with the global indices (excluding ghost points) of the `lower` and `upper` corners as well as the `size`. @@ -413,24 +279,12 @@ Returns a `NamedTuple` with the global indices (excluding ghost points) of the # External Links $(_doc_external("DMDA/DMDAGetCorners")) """ -function getcorners(da::DMDA) end - -@for_petsc function getcorners(da::DMDA{$PetscLib}) - info = DMDALocalInfo{$PetscInt}() - corners = [$PetscInt(0), $PetscInt(0), $PetscInt(0)] - local_size = [$PetscInt(0), $PetscInt(0), $PetscInt(0)] - @chk ccall( - (:DMDAGetCorners, $petsc_library), - PetscErrorCode, - ( - CDM, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - ), +function getcorners(da::AbstractDMDA{PetscLib}) where {PetscLib} + PetscInt = PetscLib.PetscInt + corners = [PetscInt(0), PetscInt(0), PetscInt(0)] + local_size = [PetscInt(0), PetscInt(0), PetscInt(0)] + LibPETSc.DMDAGetCorners( + PetscLib, da, Ref(corners, 1), Ref(corners, 2), @@ -440,15 +294,16 @@ function getcorners(da::DMDA) end Ref(local_size, 3), ) corners .+= 1 + upper = corners .+ local_size .- PetscInt(1) return ( - lower = corners, - upper = corners .+ local_size .- $PetscInt(1), - size = local_size, + lower = CartesianIndex(corners...), + upper = CartesianIndex(upper...), + size = (local_size...,), ) end """ - getghostcorners(da::DMDA) + getghostcorners(da::AbstractDMDA) Returns a `NamedTuple` with the global indices (including ghost points) of the `lower` and `upper` corners as well as the `size`. @@ -456,24 +311,12 @@ Returns a `NamedTuple` with the global indices (including ghost points) of the # External Links $(_doc_external("DMDA/DMDAGetGhostCorners")) """ -function getghostcorners(da::DMDA) end - -@for_petsc function getghostcorners(da::DMDA{$PetscLib}) - info = DMDALocalInfo{$PetscInt}() - corners = [$PetscInt(0), $PetscInt(0), $PetscInt(0)] - local_size = [$PetscInt(0), $PetscInt(0), $PetscInt(0)] - @chk ccall( - (:DMDAGetGhostCorners, $petsc_library), - PetscErrorCode, - ( - CDM, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - Ref{$PetscInt}, - ), +function getghostcorners(da::AbstractDMDA{PetscLib}) where {PetscLib} + PetscInt = PetscLib.PetscInt + corners = [PetscInt(0), PetscInt(0), PetscInt(0)] + local_size = [PetscInt(0), PetscInt(0), PetscInt(0)] + LibPETSc.DMDAGetGhostCorners( + PetscLib, da, Ref(corners, 1), Ref(corners, 2), @@ -483,13 +326,47 @@ function getghostcorners(da::DMDA) end Ref(local_size, 3), ) corners .+= 1 + upper = corners .+ local_size .- PetscInt(1) return ( - lower = corners, - upper = corners .+ local_size .- 1, - size = local_size, + lower = CartesianIndex(corners...), + upper = CartesianIndex(upper...), + size = (local_size...,), ) end +#= +# +# OLD WRAPPERS +# +mutable struct DMDALocalInfo{IT} + dim::IT + dof_per_node::IT + stencil_width::IT + global_size::NTuple{3, IT} + local_start::NTuple{3, IT} + local_size::NTuple{3, IT} + ghosted_local_start::NTuple{3, IT} + ghosted_local_size::NTuple{3, IT} + boundary_type::NTuple{3, DMBoundaryType} + stencil_type::DMDAStencilType + ___padding___::NTuple{5, IT} + DMDALocalInfo{IT}() where {IT} = new{IT}() +end + +mutable struct DMDA{PetscLib} <: AbstractDM{PetscLib} + ptr::CDM + opts::Options{PetscLib} + DMDA{PetscLib}(ptr, opts = Options(PetscLib)) where {PetscLib} = + new{PetscLib}(ptr, opts) +end + +""" + empty(da::DMDA) + +return an uninitialized `DMDA` struct. +""" +Base.empty(::DMDA{PetscLib}) where {PetscLib} = DMDA{PetscLib}(C_NULL) + """ setuniformcoordinates!( da::DMDA @@ -542,3 +419,4 @@ function setuniformcoordinates! end ) return nothing end +=# diff --git a/src/mat.jl b/src/mat.jl index 80c725e8..dccb7be0 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -342,6 +342,7 @@ function setvalues!( ) where {PetscLib, PetscScalar, PetscInt} @assert PetscScalar == PetscLib.PetscScalar @assert PetscInt == PetscLib.PetscInt + @assert num_rows * num_cols <= length(rowvals) LibPETSc.MatSetValues( PetscLib, M, @@ -355,6 +356,51 @@ function setvalues!( return nothing end +""" + setvalues!( + M::AbstractMat{PetscLib}, + row0idxs::Vector{MatStencil{PetscInt}}, + col0idxs::Vector{MatStencil{PetscInt}}, + rowvals::Array{PetscScalar}, + insertmode::InsertMode = INSERT_VALUES; + num_rows = length(row0idxs), + num_cols = length(col0idxs) + ) + +Set values of the matrix `M` with base-0 row and column indices `row0idxs` and +`col0idxs` inserting the values `rowvals`. + +If the keyword arguments `num_rows` or `num_cols` is specified then only the +first `num_rows * num_cols` values of `rowvals` will be used. + +# External Links +$(_doc_external("Mat/MatSetValuesStencil")) +""" +function setvalues!( + M::AbstractMat{PetscLib}, + row0idxs::Vector{MatStencil{PetscInt}}, + col0idxs::Vector{MatStencil{PetscInt}}, + rowvals::Array{PetscScalar}, + insertmode::InsertMode = INSERT_VALUES; + num_rows = length(row0idxs), + num_cols = length(col0idxs), +) where {PetscLib, PetscScalar, PetscInt} + @assert PetscScalar == PetscLib.PetscScalar + @assert PetscInt == PetscLib.PetscInt + @assert num_rows * num_cols <= length(rowvals) + LibPETSc.MatSetValuesStencil( + PetscLib, + M, + num_rows, + row0idxs, + num_cols, + col0idxs, + rowvals, + insertmode, + ) + return nothing +end + function Base.setindex!( M::AbstractMat{PetscLib}, val, @@ -373,6 +419,108 @@ function Base.setindex!( return val end +function Base.setindex!( + M::AbstractMat{PetscLib}, + val, + i::CartesianIndex{N}, + j::CartesianIndex{N}, +) where {PetscLib, N} + PetscInt = PetscLib.PetscInt + PetscScalar = PetscLib.PetscScalar + ms_i = MatStencil{PetscInt}( + N < 3 ? 0 : i[3] - 1, + N < 2 ? 0 : i[2] - 1, + i[1] - 1, + N < 4 ? 0 : i[4] - 1, + ) + ms_j = MatStencil{PetscInt}( + N < 3 ? 0 : j[3] - 1, + N < 2 ? 0 : j[2] - 1, + j[1] - 1, + N < 4 ? 0 : j[4] - 1, + ) + setvalues!(M, [ms_i], [ms_j], [PetscScalar(val)], INSERT_VALUES) + return val +end + +function addindex!( + M::AbstractMat{PetscLib}, + val, + i::CartesianIndex{N}, + j::CartesianIndex{N}, +) where {PetscLib, N} + PetscInt = PetscLib.PetscInt + PetscScalar = PetscLib.PetscScalar + ms_i = MatStencil{PetscInt}( + N < 3 ? 0 : i[3] - 1, + N < 2 ? 0 : i[2] - 1, + i[1] - 1, + N < 4 ? 0 : i[4] - 1, + ) + ms_j = MatStencil{PetscInt}( + N < 3 ? 0 : j[3] - 1, + N < 2 ? 0 : j[2] - 1, + j[1] - 1, + N < 4 ? 0 : j[4] - 1, + ) + setvalues!(M, [ms_i], [ms_j], [PetscScalar(val)], ADD_VALUES) + return val +end + +""" + getvalues!( + rowvals::Array{PetscScalar}; + M::AbstractMat{PetscLib}, + row0idxs::Vector{PetscInt}, + col0idxs::Vector{PetscInt}, + num_rows = length(row0idxs), + num_cols = length(col0idxs) + ) + +get values of the matrix `M` with base-0 row and column indices `row0idxs` and +`col0idxs` inserting the values `rowvals`. + +If the keyword arguments `num_rows` or `num_cols` is specified then only the +first `num_rows * num_cols` values of `rowvals` will be used. + +# External Links +$(_doc_external("Mat/MatGetValues")) +""" +function getvalues!( + rowvals::Array{PetscScalar}, + M::AbstractMat{PetscLib}, + row0idxs::Vector{PetscInt}, + col0idxs::Vector{PetscInt}; + num_rows = length(row0idxs), + num_cols = length(col0idxs), +) where {PetscLib, PetscScalar, PetscInt} + @assert PetscScalar == PetscLib.PetscScalar + @assert PetscInt == PetscLib.PetscInt + @assert num_rows * num_cols <= length(rowvals) + LibPETSc.MatGetValues( + PetscLib, + M, + num_rows, + row0idxs, + num_cols, + col0idxs, + rowvals, + ) + return nothing +end + +function Base.getindex( + M::AbstractMat{PetscLib}, + i::Integer, + j::Integer, +) where {PetscLib} + PetscInt = PetscLib.PetscInt + PetscScalar = PetscLib.PetscScalar + v_array = [zero(PetscScalar)] + getvalues!(v_array, M, [PetscInt(i - 1)], [PetscInt(j - 1)]) + return @inbounds v_array[1] +end + function LinearAlgebra.norm( M::AbstractMat{PetscLib}, normtype::NormType = NORM_FROBENIUS, diff --git a/src/sys.jl b/src/sys.jl index 37ad2842..cedbbd4e 100644 --- a/src/sys.jl +++ b/src/sys.jl @@ -1,6 +1,6 @@ const CPetscObject = Ptr{Cvoid} -const UnionPetscTypes = Union{Options, AbstractVec, AbstractMat, AbstractKSP} +const UnionPetscTypes = Union{Options, AbstractVec, AbstractMat, AbstractKSP, AbstractDM} # allows us to pass PETSc_XXX objects directly into CXXX ccall signatures Base.cconvert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj @@ -16,6 +16,7 @@ function getcomm( AbstractVec{PetscLib}, AbstractMat{PetscLib}, AbstractKSP{PetscLib}, + AbstractDM{PetscLib}, }, ) where {PetscLib} comm = MPI.Comm() diff --git a/test/dmda.jl b/test/dmda.jl index c250c86c..b88a43ae 100644 --- a/test/dmda.jl +++ b/test/dmda.jl @@ -8,8 +8,9 @@ MPI.Initialized() || MPI.Init() mpisize = MPI.Comm_size(comm) for petsclib in PETSc.petsclibs PETSc.initialize(petsclib) - PetscScalar = PETSc.scalartype(petsclib) - PetscInt = PETSc.inttype(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + # Loop over all boundary types and try to use them for boundary_type in instances(PETSc.DMBoundaryType) @testset "$boundary_type" begin @@ -32,54 +33,64 @@ MPI.Initialized() || MPI.Init() mpirank == mpisize - 1 ? 0 : stencil_width # Set the points - da = PETSc.DMDACreate1d( + da = PETSc.DMDA( petsclib, comm, - boundary_type, - global_size, + (boundary_type,), + (global_size,), dof_per_node, - stencil_width, - points_per_proc, + stencil_width; + points_per_proc = (points_per_proc,), ) @test PETSc.gettype(da) == "da" @test PETSc.getdimension(da) == 1 da_info = PETSc.getinfo(da) - corners = PETSc.getcorners(da) - - ghost_corners = PETSc.getghostcorners(da) + @test da_info.dim == 1 - @test da_info.global_size == [global_size, 1, 1] - @test da_info.procs_per_dim == [mpisize, 1, 1] - @test da_info.boundary_type == [ + @test da_info.global_size == (global_size, 1, 1) + @test da_info.procs_per_dim == (mpisize, 1, 1) + @test da_info.boundary_type == ( boundary_type, PETSc.DM_BOUNDARY_NONE, PETSc.DM_BOUNDARY_NONE, - ] + ) @test da_info.stencil_type == PETSc.DMDA_STENCIL_BOX @test da_info.stencil_width == stencil_width + + corners = PETSc.getcorners(da) @test corners.lower == - [proc_global_offsets[mpirank + 1] + 1, 1, 1] - @test corners.upper == [proc_global_offsets[mpirank + 2], 1, 1] - @test corners.size == [points_per_proc[mpirank + 1], 1, 1] - @test ghost_corners.lower == - [proc_global_offsets[mpirank + 1] + 1 - gl, 1, 1] - @test ghost_corners.upper == - [proc_global_offsets[mpirank + 2] + gr, 1, 1] + CartesianIndex(proc_global_offsets[mpirank + 1] + 1, 1, 1) + @test corners.upper == + CartesianIndex(proc_global_offsets[mpirank + 2], 1, 1) + @test corners.size == (points_per_proc[mpirank + 1], 1, 1) + + ghost_corners = PETSc.getghostcorners(da) + @test ghost_corners.lower == CartesianIndex( + proc_global_offsets[mpirank + 1] + 1 - gl, + 1, + 1, + ) + @test ghost_corners.upper == CartesianIndex( + proc_global_offsets[mpirank + 2] + gr, + 1, + 1, + ) @test ghost_corners.size == - [points_per_proc[mpirank + 1] + gl + gr, 1, 1] + (points_per_proc[mpirank + 1] + gl + gr, 1, 1) + + PETSc.destroy(da) # Do not set the points and test option parsing da_refine = 2 - da = PETSc.DMDACreate1d( + da = PETSc.DMDA( petsclib, comm, - boundary_type, - global_size, + (boundary_type,), + (global_size,), dof_per_node, - stencil_width, - nothing; + stencil_width; da_refine = da_refine, ) @test PETSc.gettype(da) == "da" @@ -90,25 +101,26 @@ MPI.Initialized() || MPI.Init() @test da_info.dim == 1 if boundary_type == PETSc.DM_BOUNDARY_PERIODIC @test da_info.global_size == - [2^da_refine * global_size, 1, 1] + (2^da_refine * global_size, 1, 1) else @test da_info.global_size == - [2^da_refine * (global_size - 1) + 1, 1, 1] + (2^da_refine * (global_size - 1) + 1, 1, 1) end - @test da_info.procs_per_dim == [mpisize, 1, 1] - @test da_info.boundary_type == [ + @test da_info.procs_per_dim == (mpisize, 1, 1) + @test da_info.boundary_type == ( boundary_type, PETSc.DM_BOUNDARY_NONE, PETSc.DM_BOUNDARY_NONE, - ] + ) @test da_info.stencil_type == PETSc.DMDA_STENCIL_BOX @test da_info.stencil_width == stencil_width # In this case we cannot check the numbers locally - + PETSc.destroy(da) + #= # TODO: Need a better test? ksp = PETSc.KSP(da) @test PETSc.gettype(ksp) == "gmres" - + =# end end PETSc.finalize(petsclib) @@ -122,9 +134,10 @@ end global_size_x = 100 global_size_y = 45 for petsclib in PETSc.petsclibs - PetscScalar = PETSc.scalartype(petsclib) - PetscInt = PETSc.inttype(petsclib) PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + # Loop over all boundary types and stencil types for stencil_type in instances(PETSc.DMDAStencilType), boundary_type_y in instances(PETSc.DMBoundaryType), @@ -143,50 +156,38 @@ end stencil_width = 5 # Set the points - da = PETSc.DMDACreate2d( + da = PETSc.DMDA( petsclib, comm, - boundary_type_x, - boundary_type_y, - stencil_type, - global_size_x, - global_size_y, - PETSc.PETSC_DECIDE, - PETSc.PETSC_DECIDE, + (boundary_type_x, boundary_type_y), + (global_size_x, global_size_y), dof_per_node, stencil_width, - nothing, - nothing, + stencil_type, ) @test PETSc.gettype(da) == "da" @test PETSc.getdimension(da) == 2 da_info = PETSc.getinfo(da) - @test da_info.global_size == [global_size_x, global_size_y, 1] + @test da_info.global_size == (global_size_x, global_size_y, 1) @test da_info.dim == 2 @test prod(da_info.procs_per_dim) == mpisize @test da_info.boundary_type == - [boundary_type_x, boundary_type_y, PETSc.DM_BOUNDARY_NONE] + (boundary_type_x, boundary_type_y, PETSc.DM_BOUNDARY_NONE) @test da_info.stencil_type == stencil_type @test da_info.stencil_width == stencil_width # test refinement da_refine = 2 - da = PETSc.DMDACreate2d( + da = PETSc.DMDA( petsclib, comm, - boundary_type_x, - boundary_type_y, - stencil_type, - global_size_x, - global_size_y, - PETSc.PETSC_DECIDE, - PETSc.PETSC_DECIDE, + (boundary_type_x, boundary_type_y), + (global_size_x, global_size_y), dof_per_node, stencil_width, - nothing, - nothing; + stencil_type; da_refine = da_refine, ) @test PETSc.gettype(da) == "da" @@ -205,18 +206,22 @@ end 2^da_refine * (global_size_y - 1) + 1 @test da_info.global_size == - [ref_global_size_x, ref_global_size_y, 1] + (ref_global_size_x, ref_global_size_y, 1) @test prod(da_info.procs_per_dim) == mpisize @test da_info.boundary_type == - [boundary_type_x, boundary_type_y, PETSc.DM_BOUNDARY_NONE] + (boundary_type_x, boundary_type_y, PETSc.DM_BOUNDARY_NONE) @test da_info.stencil_type == stencil_type @test da_info.stencil_width == stencil_width # TODO: Test with specific distribution of processors and sizes # TODO: Need a better test? + #= ksp = PETSc.KSP(da) @test PETSc.gettype(ksp) == "gmres" + =# + + PETSc.destroy(da) end end PETSc.finalize(petsclib) @@ -231,9 +236,9 @@ end global_size_y = 13 global_size_z = 14 for petsclib in PETSc.petsclibs - PetscScalar = PETSc.scalartype(petsclib) - PetscInt = PETSc.inttype(petsclib) PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt # Loop over all boundary types and stencil types for stencil_type in instances(PETSc.DMDAStencilType), boundary_type_z in instances(PETSc.DMBoundaryType), @@ -253,24 +258,14 @@ end stencil_width = 2 # Set the points - da = PETSc.DMDACreate3d( + da = PETSc.DMDA( petsclib, comm, - boundary_type_x, - boundary_type_y, - boundary_type_z, - stencil_type, - global_size_x, - global_size_y, - global_size_z, - PETSc.PETSC_DECIDE, - PETSc.PETSC_DECIDE, - PETSc.PETSC_DECIDE, + (boundary_type_x, boundary_type_y, boundary_type_z), + (global_size_x, global_size_y, global_size_z), dof_per_node, stencil_width, - nothing, - nothing, - nothing, + stencil_type, ) @test PETSc.gettype(da) == "da" @test PETSc.getdimension(da) == 3 @@ -278,34 +273,24 @@ end da_info = PETSc.getinfo(da) @test da_info.global_size == - [global_size_x, global_size_y, global_size_z] + (global_size_x, global_size_y, global_size_z) @test da_info.dim == 3 @test prod(da_info.procs_per_dim) == mpisize @test da_info.boundary_type == - [boundary_type_x, boundary_type_y, boundary_type_z] + (boundary_type_x, boundary_type_y, boundary_type_z) @test da_info.stencil_type == stencil_type @test da_info.stencil_width == stencil_width # test refinement da_refine = 2 - da = PETSc.DMDACreate3d( + da = PETSc.DMDA( petsclib, comm, - boundary_type_x, - boundary_type_y, - boundary_type_z, - stencil_type, - global_size_x, - global_size_y, - global_size_z, - PETSc.PETSC_DECIDE, - PETSc.PETSC_DECIDE, - PETSc.PETSC_DECIDE, + (boundary_type_x, boundary_type_y, boundary_type_z), + (global_size_x, global_size_y, global_size_z), dof_per_node, stencil_width, - nothing, - nothing, - nothing; + stencil_type; da_refine = da_refine, ) @test PETSc.gettype(da) == "da" @@ -328,82 +313,99 @@ end 2^da_refine * (global_size_z - 1) + 1 @test da_info.global_size == - [ref_global_size_x, ref_global_size_y, ref_global_size_z] + (ref_global_size_x, ref_global_size_y, ref_global_size_z) @test prod(da_info.procs_per_dim) == mpisize @test da_info.boundary_type == - [boundary_type_x, boundary_type_y, boundary_type_z] + (boundary_type_x, boundary_type_y, boundary_type_z) @test da_info.stencil_type == stencil_type @test da_info.stencil_width == stencil_width # TODO: Test with specific distribution of processors and sizes # TODO: Need a better test? + #= ksp = PETSc.KSP(da) @test PETSc.gettype(ksp) == "gmres" + =# end end PETSc.finalize(petsclib) end end -@testset "creatematrix" begin +@testset "DM MatAIJ" begin comm = MPI.COMM_WORLD mpirank = MPI.Comm_rank(comm) mpisize = MPI.Comm_size(comm) - for petsclib in PETSc.petsclibs + # Just check a couple libraries + for petsclib in PETSc.petsclibs[1:2] PETSc.initialize(petsclib) - PetscScalar = PETSc.scalartype(petsclib) - PetscInt = PETSc.inttype(petsclib) - boundary_type = PETSc.DM_BOUNDARY_NONE - dof_per_node = 1 - stencil_width = 1 - number_points = 10 - points_per_proc = [PetscInt(10) for i in 1:mpisize] - global_size = sum(points_per_proc) - # Set the points - da = PETSc.DMDACreate1d( - petsclib, - comm, - boundary_type, - global_size, - dof_per_node, - stencil_width, - points_per_proc, - ) - mat = PETSc.creatematrix(da) - - # Build the 1-D Laplacian FD matrix - Sten = PETSc.MatStencil{PetscInt} - col = Vector{Sten}(undef, 2) - row = Vector{Sten}(undef, 2) - val = Vector{PetscScalar}(undef, 4) - corners = PETSc.getcorners(da) - - for i in corners.lower[1]:min(corners.upper[1], global_size - 1) - row[1] = Sten(i = i) - row[2] = Sten(i = i + 1) - col[1] = Sten(i = i) - col[2] = Sten(i = i + 1) - val .= [-1, 1, 1, -1] - PETSc.MatSetValuesStencil!(mat, row, col, val, PETSc.ADD_VALUES) - end - - PETSc.assemblybegin(mat) - PETSc.assemblyend(mat) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + for dim in 1:3 + boundary_type = ntuple(_ -> PETSc.DM_BOUNDARY_NONE, dim) + dof_per_node = 1 + stencil_width = 1 + number_points = 10 + global_size = ntuple(i -> (10 + i) * mpisize, 3) + # Set the points + da = PETSc.DMDA( + petsclib, + comm, + boundary_type, + global_size[1:dim], + dof_per_node, + stencil_width, + PETSc.DMDA_STENCIL_STAR; + # Force processor distribution so that we know how to go from + # Stencil to Linear easily + processors = (ntuple(i->1, dim-1)..., mpisize) + ) + mat = PETSc.MatAIJ(da) + + # Build the dim-dimensional Laplacian FD matrix + corners = PETSc.getcorners(da) + + for i in (corners.lower):(corners.upper) + for d in 1:dim + if i[d] - 1 > 1 + j = i - CartesianIndex(d == 1, d == 2, d == 3) + mat[i, j] = 1 + end + if i[d] + 1 < global_size[d] + j = i + CartesianIndex(d == 1, d == 2, d == 3) + mat[i, j] = 1 + end + end + mat[i, i] = -2dim + end - for i in corners.lower[1]:corners.upper[1] - if i == 1 - @test mat[i, i:(i + 1)] == [-1, 1] - elseif i == global_size - @test mat[i, (i - 1):i] == [1, -1] - else - @test mat[i, (i - 1):(i + 1)] == [1, -2, 1] + PETSc.assemble!(mat) + + ind = LinearIndices(ntuple(i->1:global_size[i], 3)) + for ci in (corners.lower):(corners.upper) + i = ind[ci] + @test mat[i, i] == -2dim + for d in 1:dim + if ci[d] - 1 > 1 + j = ind[ci - CartesianIndex(d == 1, d == 2, d == 3)] + @test mat[i, j] == 1 + end + if ci[d] + 1 < global_size[d] + j = ind[ci + CartesianIndex(d == 1, d == 2, d == 3)] + @test mat[i, j] == 1 + end + end end + + PETSc.destroy(mat) + PETSc.destroy(da) end PETSc.finalize(petsclib) end end +#= @testset "DM Vectors and Coordinates" begin comm = MPI.COMM_WORLD mpirank = MPI.Comm_rank(comm) @@ -525,5 +527,6 @@ end PETSc.finalize(petsclib) end end +=# nothing diff --git a/test/runtests.jl b/test/runtests.jl index 9c4a43ab..fafe4e0f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,7 +3,7 @@ using MPI: mpiexec # Do the MPI tests first so we do not have mpi running inside MPI @testset "mpi tests" begin - for file in ("mpivec.jl", "mpimat.jl", "ksp.jl") + for file in ("mpivec.jl", "mpimat.jl", "ksp.jl", "dmda.jl") @test mpiexec() do mpi_cmd cmd = `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no --project $file` @@ -19,3 +19,4 @@ include("vec.jl") include("mat.jl") include("matshell.jl") include("ksp.jl") +include("dmda.jl") From 2e708a93efd466272ec7ddeed7611521acba8edf Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 09:19:43 -0700 Subject: [PATCH 20/53] Move old examples to "stale" folder --- examples/{ => stale}/DMSTAG_Stokes_2D.jl | 0 examples/{ => stale}/DMSTAG_porwave_1D.jl | 0 examples/{ => stale}/DMSTAG_porwave_2D.jl | 0 examples/{ => stale}/Diffusion_2d.jl | 0 examples/{ => stale}/SNES_ex2.jl | 0 examples/{ => stale}/SNES_ex2b.jl | 0 examples/{ => stale}/ex1.jl | 0 examples/{ => stale}/ksp/ex50.jl | 0 examples/{ => stale}/laplacian.jl | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename examples/{ => stale}/DMSTAG_Stokes_2D.jl (100%) rename examples/{ => stale}/DMSTAG_porwave_1D.jl (100%) rename examples/{ => stale}/DMSTAG_porwave_2D.jl (100%) rename examples/{ => stale}/Diffusion_2d.jl (100%) rename examples/{ => stale}/SNES_ex2.jl (100%) rename examples/{ => stale}/SNES_ex2b.jl (100%) rename examples/{ => stale}/ex1.jl (100%) rename examples/{ => stale}/ksp/ex50.jl (100%) rename examples/{ => stale}/laplacian.jl (100%) diff --git a/examples/DMSTAG_Stokes_2D.jl b/examples/stale/DMSTAG_Stokes_2D.jl similarity index 100% rename from examples/DMSTAG_Stokes_2D.jl rename to examples/stale/DMSTAG_Stokes_2D.jl diff --git a/examples/DMSTAG_porwave_1D.jl b/examples/stale/DMSTAG_porwave_1D.jl similarity index 100% rename from examples/DMSTAG_porwave_1D.jl rename to examples/stale/DMSTAG_porwave_1D.jl diff --git a/examples/DMSTAG_porwave_2D.jl b/examples/stale/DMSTAG_porwave_2D.jl similarity index 100% rename from examples/DMSTAG_porwave_2D.jl rename to examples/stale/DMSTAG_porwave_2D.jl diff --git a/examples/Diffusion_2d.jl b/examples/stale/Diffusion_2d.jl similarity index 100% rename from examples/Diffusion_2d.jl rename to examples/stale/Diffusion_2d.jl diff --git a/examples/SNES_ex2.jl b/examples/stale/SNES_ex2.jl similarity index 100% rename from examples/SNES_ex2.jl rename to examples/stale/SNES_ex2.jl diff --git a/examples/SNES_ex2b.jl b/examples/stale/SNES_ex2b.jl similarity index 100% rename from examples/SNES_ex2b.jl rename to examples/stale/SNES_ex2b.jl diff --git a/examples/ex1.jl b/examples/stale/ex1.jl similarity index 100% rename from examples/ex1.jl rename to examples/stale/ex1.jl diff --git a/examples/ksp/ex50.jl b/examples/stale/ksp/ex50.jl similarity index 100% rename from examples/ksp/ex50.jl rename to examples/stale/ksp/ex50.jl diff --git a/examples/laplacian.jl b/examples/stale/laplacian.jl similarity index 100% rename from examples/laplacian.jl rename to examples/stale/laplacian.jl From a605eb3d50afb7d8a03c5c8f0861cc201495f3a7 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 09:21:49 -0700 Subject: [PATCH 21/53] Move unused tests to "stale" folder --- test/{ => stale}/old_test.jl | 0 test/{ => stale}/test_dmstag.jl | 0 test/{ => stale}/test_snes.jl | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename test/{ => stale}/old_test.jl (100%) rename test/{ => stale}/test_dmstag.jl (100%) rename test/{ => stale}/test_snes.jl (100%) diff --git a/test/old_test.jl b/test/stale/old_test.jl similarity index 100% rename from test/old_test.jl rename to test/stale/old_test.jl diff --git a/test/test_dmstag.jl b/test/stale/test_dmstag.jl similarity index 100% rename from test/test_dmstag.jl rename to test/stale/test_dmstag.jl diff --git a/test/test_snes.jl b/test/stale/test_snes.jl similarity index 100% rename from test/test_snes.jl rename to test/stale/test_snes.jl From 31c2286defb0eef65d529a9eb9759f1b551fe033 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 09:32:28 -0700 Subject: [PATCH 22/53] Enable examples and mpi_examples testing --- test/examples.jl | 8 +++++++- test/mpi_examples.jl | 6 +++++- test/runtests.jl | 9 +++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/test/examples.jl b/test/examples.jl index a9521d00..8a255dd5 100644 --- a/test/examples.jl +++ b/test/examples.jl @@ -1,3 +1,5 @@ +using Test + function find_sources(path::String, sources=String[]) if isdir(path) for entry in readdir(path) @@ -11,8 +13,12 @@ end @testset "examples" begin examples_dir = joinpath(@__DIR__, "..", "examples") + stale_examples_dir = joinpath(@__DIR__, "..", "examples", "stale") + examples = find_sources(examples_dir) - filter!(file -> readline(file) != "# EXCLUDE FROM TESTING", examples) + stale_examples = find_sources(stale_examples_dir) + + filter!(file -> file ∉ stale_examples && readline(file) != "# EXCLUDE FROM TESTING", examples) @testset "$(basename(example))" for example in examples code = """ diff --git a/test/mpi_examples.jl b/test/mpi_examples.jl index 6cff2e48..9a405c76 100644 --- a/test/mpi_examples.jl +++ b/test/mpi_examples.jl @@ -14,8 +14,12 @@ end @testset "mpi examples" begin examples_dir = joinpath(@__DIR__, "..", "examples") + stale_examples_dir = joinpath(@__DIR__, "..", "examples", "stale") + examples = find_sources(examples_dir) - filter!(file -> readline(file) == "# INCLUDE IN MPI TEST", examples) + stale_examples = find_sources(stale_examples_dir) + + filter!(file -> file ∉ stale_examples && readline(file) == "# INCLUDE IN MPI TEST", examples) @testset "$(basename(example))" for example in examples code = """ diff --git a/test/runtests.jl b/test/runtests.jl index fafe4e0f..15602152 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -12,6 +12,10 @@ using MPI: mpiexec end end +# run example with MPI that include comment line +# INCLUDE IN MPI TEST +include("mpi_examples.jl") + # Run the serial tests include("init.jl") include("options.jl") @@ -20,3 +24,8 @@ include("mat.jl") include("matshell.jl") include("ksp.jl") include("dmda.jl") + +# Run the examples +# Exclude examples with first line comment +# EXCLUDE FROM TESTING +include("examples.jl") From 05da75f31f244fd3b40af32587365b05a29d5d40 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 11:01:52 -0700 Subject: [PATCH 23/53] Update MPI test output --- test/runtests.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 15602152..fc00417d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,11 +2,11 @@ using Test using MPI: mpiexec # Do the MPI tests first so we do not have mpi running inside MPI -@testset "mpi tests" begin - for file in ("mpivec.jl", "mpimat.jl", "ksp.jl", "dmda.jl") +for file in ("mpivec.jl", "mpimat.jl", "ksp.jl", "dmda.jl") + @testset "MPI test: $file" begin @test mpiexec() do mpi_cmd cmd = - `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no --project $file` + `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no --project $file` success(pipeline(cmd, stderr = stderr)) end end From 2fb5c5d1379dd1508382a5aaaa679226fbaf6699 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 12:29:58 -0700 Subject: [PATCH 24/53] Add a Julia sparse matrix to PETSc MatSeqAIJ --- Project.toml | 4 +++- src/mat.jl | 29 +++++++++++++++++++---------- test/mat.jl | 6 ++++++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index 4b286d2e..375f9cbc 100644 --- a/Project.toml +++ b/Project.toml @@ -22,6 +22,8 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [targets] -test = ["ForwardDiff", "UnicodePlots", "Test", "Plots", "SparseDiffTools", "Printf"] +test = ["ForwardDiff", "UnicodePlots", "Test", "Plots", "SparseDiffTools", +"Printf", "Random"] diff --git a/src/mat.jl b/src/mat.jl index dccb7be0..7086dfa3 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -595,25 +595,34 @@ function LinearAlgebra.ishermitian( return fr[] == PETSC_TRUE end -#= -function MatSeqAIJ(S::SparseMatrixCSC{T}) where {T} - PetscInt = inttype(T) - m,n = size(S) - nnz = zeros(PetscInt,m) +function MatSeqAIJ( + petsclib, + S::SparseMatrixCSC{PetscScalar}, +) where {PetscScalar} + @assert petsclib.PetscScalar == PetscScalar + + PetscInt = petsclib.PetscInt + + m, n = size(S) + # Calculate non-zeros per row + nnz = zeros(PetscInt, m) + for r in S.rowval nnz[r] += 1 end - M = MatSeqAIJ{T}(m, n, nnz) - for j = 1:n - for ii = S.colptr[j]:S.colptr[j+1]-1 + + M = MatSeqAIJ(petsclib, m, n, nnz) + for j in 1:n + for ii in S.colptr[j]:(S.colptr[j + 1] - 1) i = S.rowval[ii] - M[i,j] = S.nzval[ii] + M[i, j] = S.nzval[ii] end end - assemble(M) + assemble!(M) return M end +#= function Base.copyto!(M::PETSc.MatSeqAIJ{T}, S::SparseMatrixCSC{T}) where {T} for j = 1:size(S,2) for ii = S.colptr[j]:S.colptr[j+1]-1 diff --git a/test/mat.jl b/test/mat.jl index c2254abe..c5678c9d 100644 --- a/test/mat.jl +++ b/test/mat.jl @@ -1,6 +1,8 @@ using Test using PETSc using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian +using SparseArrays: sprand +using Random @testset "MatSeqAIJ" begin num_rows, num_cols = 5, 7 @@ -117,6 +119,10 @@ using LinearAlgebra: norm, mul!, Adjoint, Transpose, issymmetric, ishermitian @test !ishermitian(B) end + Random.seed!(777) + A = sprand(PetscScalar, 10, 10, 0.2) + @test A == PETSc.MatSeqAIJ(petsclib, A) + PETSc.finalize(petsclib) end end From df23af161940c34ba8dda6832856a7065cde8d4b Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 12:42:41 -0700 Subject: [PATCH 25/53] Add function to get library with types --- src/LibPETSc_lib.jl | 12 +++++++++++- test/lib.jl | 20 ++++++++++++++++++++ test/runtests.jl | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/lib.jl diff --git a/src/LibPETSc_lib.jl b/src/LibPETSc_lib.jl index 8b3b10d1..bd986834 100644 --- a/src/LibPETSc_lib.jl +++ b/src/LibPETSc_lib.jl @@ -15,6 +15,15 @@ function PetscLibType{ST, IT}(petsc_library) where {ST, IT} end const UnionPetscLibType = Union{PetscLibType, Type{<:PetscLibType}} +""" + getlib(; PetscScalar = Float64, PetscInt = Int64) + +Return the `PetscLibType` with the associated parameters +""" +function getlib(; PetscScalar = Float64, PetscInt = Int64) + return PetscLibType{PetscScalar, PetscInt}() +end + function Base.getproperty(petsclib::UnionPetscLibType, name::Symbol) if name == :PetscScalar return scalartype(petsclib) @@ -116,5 +125,6 @@ macro for_petsc(expr) end @for_petsc begin - getlib(::Type{$PetscLib}) = $petsclib + getlib(::Type{$PetscLib}) = $petsclib + PetscLibType{$PetscScalar, $PetscInt}() = $petsclib end diff --git a/test/lib.jl b/test/lib.jl new file mode 100644 index 00000000..b93229c8 --- /dev/null +++ b/test/lib.jl @@ -0,0 +1,20 @@ +using Test +using PETSc + +@testset "lib" begin + for petsclib in PETSc.petsclibs + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + @test petsclib == + PETSc.getlib(; PetscScalar = PetscScalar, PetscInt = PetscInt) + if PetscInt == Int64 + @test petsclib == PETSc.getlib(; PetscScalar = PetscScalar) + end + if PetscScalar == Float64 + @test petsclib == PETSc.getlib(; PetscInt = PetscInt) + end + if PetscInt == Int64 && PetscScalar == Float64 + @test petsclib == PETSc.getlib() + end + end +end diff --git a/test/runtests.jl b/test/runtests.jl index fc00417d..ee106a4e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -18,6 +18,7 @@ include("mpi_examples.jl") # Run the serial tests include("init.jl") +include("lib.jl") include("options.jl") include("vec.jl") include("mat.jl") From d59de98855dc83c466f3949bcc7ddc01a5987ce6 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 13:25:13 -0700 Subject: [PATCH 26/53] Allow KSP with Julia vectors and SparseMatrixCSC --- src/ksp.jl | 36 ++++++++++++++++++++++++++++++++++++ test/ksp.jl | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/src/ksp.jl b/src/ksp.jl index 23b230b9..8ad69763 100644 --- a/src/ksp.jl +++ b/src/ksp.jl @@ -52,6 +52,18 @@ function KSP( return ksp end +""" + KSP([petsclib,] A::SparseMatrixCSC; options...) + +Create a [`KSP`](@ref) with the sparse matrix `A` using the `petsclib`. If +`petsclib` is not given, the default library will be used`. +""" +KSP(petsclib, A::SparseMatrixCSC; kwargs...) = + KSP(MatSeqAIJ(petsclib, A); kwargs...) +function KSP(A::SparseMatrixCSC{PetscScalar}; kwargs...) where {PetscScalar} + KSP(MatSeqAIJ(getlib(; PetscScalar = PetscScalar), A); kwargs...) +end + function setoperators!( ksp::AbstractKSP{PetscLib}, A::AbstractMat{PetscLib}, @@ -133,6 +145,30 @@ function Base.:\(ksp::AbstractKSP, b::AbstractVec) return x end +function Base.:\( + ksp::AbstractKSP{PetscLib}, + b::Vector{PetscScalar}, +) where {PetscLib, PetscScalar} + @assert PetscScalar == PetscLib.PetscScalar + @assert MPI.Comm_size(getcomm(ksp)) == 1 + + petsc_b = VecSeqWithArray(PetscLib, b) + petsc_x = createvecs(ksp; nleft = 1).left[1] + + ldiv!(petsc_x, ksp, petsc_b) + + x = similar(b, length(petsc_x)) + + withlocalarray!(petsc_x; read = true, write = false) do y + x .= y + end + + destroy(petsc_b) + destroy(petsc_x) + + return x +end + #= # # OLD WRAPPERS diff --git a/test/ksp.jl b/test/ksp.jl index cc477192..bcd05a57 100644 --- a/test/ksp.jl +++ b/test/ksp.jl @@ -3,6 +3,7 @@ using MPI MPI.Initialized() || MPI.Init() using PETSc using LinearAlgebra: mul! +using SparseArrays: spdiagm @testset "KSP" begin comm = MPI.COMM_WORLD @@ -80,3 +81,41 @@ using LinearAlgebra: mul! PETSc.finalize(petsclib) end end + +if MPI.Comm_rank(MPI.COMM_WORLD) == 0 + @testset "KSP with SparseMatrixCSC" begin + comm = MPI.COMM_SELF + n = 10 + + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + + A = spdiagm( + -1 => ones(PetscScalar, n - 1), + 0 => -2ones(PetscScalar, n), + 1 => ones(PetscScalar, n - 1), + ) + + ksp = PETSc.KSP(petsclib, A) + b = rand(PetscScalar, 10) + @test ksp \ b ≈ Matrix(A) \ b + PETSc.destroy(ksp) + + if PetscInt == Int64 + ksp = PETSc.KSP(A) + @test ksp \ b ≈ Matrix(A) \ b + PETSc.destroy(ksp) + end + PETSc.finalize(petsclib) + end + end +else + # Even though only rank 0 is running the test all ranks need to initialize + # PETSc + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PETSc.finalize(petsclib) + end +end From f6cb8d4416412c639e63a3202ae0caa54647559b Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 16:47:48 -0700 Subject: [PATCH 27/53] Add Laplacian example --- examples/laplacian.jl | 52 ++++++++++++++++++++++++++++++++++ examples/stale/laplacian.jl | 56 ------------------------------------- 2 files changed, 52 insertions(+), 56 deletions(-) create mode 100644 examples/laplacian.jl delete mode 100644 examples/stale/laplacian.jl diff --git a/examples/laplacian.jl b/examples/laplacian.jl new file mode 100644 index 00000000..957b5e7d --- /dev/null +++ b/examples/laplacian.jl @@ -0,0 +1,52 @@ +# # Finite Difference Laplacian +# +# In this example a simple finite difference, 1-D laplacian with Dirichlet +# boundary conditions is solved first constructing the operator as Julia sparse +# matrix then solving using PETsc + +using PETSc +using SparseArrays: spdiagm +using UnicodePlots: lineplot, lineplot! + +# Initialize PETSc +PETSc.initialize() + +# Set our PETSc Scalar Type +PetscScalar = Float64 + +# Set the total number of grid points +Nq = 100 + +# number of interior points +n = Nq - 2 + +# create the interior grid and get the grid spacing +x = range(PetscScalar(0), length = Nq, stop = 1)[2:(end - 1)] +Δx = PetscScalar(x.step) + +# Create the finite difference operator with zero Dirichlet boundary conditions +A = + spdiagm( + -1 => -ones(PetscScalar, n - 1), + 0 => 2ones(PetscScalar, n), + 1 => -ones(PetscScalar, n - 1), + ) / Δx^2 + +# Setup the exact solution and the forcing function +κ = 2PetscScalar(π) +u(x) = sin(κ * x) +f(x) = κ^2 * sin(κ * x) + +# Set up the PETSc solver +ksp = PETSc.KSP(A; ksp_monitor = true); + +# Solve the problem +v = ksp \ f.(x); + +# Compute the L2-error +ϵ = sqrt(sum((v - u.(x)) .^ 2 * Δx)) +println("L2-error is $ϵ") + +# Plot the solution and error +display(lineplot(x, v, xlabel = "x", ylabel = "solution")) +display(lineplot(x, v - u.(x), xlabel = "x", ylabel = "error")) diff --git a/examples/stale/laplacian.jl b/examples/stale/laplacian.jl deleted file mode 100644 index 2c8cc889..00000000 --- a/examples/stale/laplacian.jl +++ /dev/null @@ -1,56 +0,0 @@ -using Test -using PETSc, MPI, LinearAlgebra, SparseArrays - -MPI.Initialized() || MPI.Init() -PETSc.initialize() - -# Constructs the central finite-difference approximation of -∇² for an lx×ly box of nx×ny points -# with Dirichlet boundary conditions. Based on the code from -# http://math.mit.edu/~stevenj/18.303/lecture-10.html -function laplace(T, nx::Integer, ny::Integer=nx, lx::Integer=1, ly::Integer=lx) - dx = T(lx) / T(nx + 1) - dy = T(ly) / T(ny + 1) - Dx = [[one(T) spzeros(T, 1, nx - 1)]; spdiagm(1=>ones(T, nx - 1)) - I] / dx - Dy = [[one(T) spzeros(T, 1, ny - 1)]; spdiagm(1=>ones(T, ny - 1)) - I] / dy - Ax = Dx' * Dx - Ay = Dy' * Dy - A = kron(sparse(I, ny, ny), Ax) + kron(Ay, sparse(I, nx, nx)) - return A -end - -nx = 20 -for T in PETSc.scalar_types - S = laplace(T, nx) - - m, n = size(S) - M = PETSc.MatSeqAIJ(S) - - ksp = PETSc.KSP( - M; - ksp_monitor_true_residual = false, - ksp_view = false, - ksp_type = "cg", - ksp_rtol = 1e-8, - pc_type = "gamg", - mg_levels_ksp_type = "chebyshev", - mg_levels_ksp_max_it = 3, - mg_levels_pc_type = "bjacobi", - mg_levels_sub_pc_type = "icc", - mg_coarse_ksp_type = "preonly", - mg_coarse_pc_type = "cholesky", - ) - - # initial guess - x = PETSc.VecSeq(zeros(T, m)) - b = PETSc.VecSeq(randn(T, n)) - PETSc.solve!(x, ksp, b) - - #= - PETSc.destroy(ksp) - PETSc.destroy(M) - PETSc.destroy(b) - PETSc.destroy(x) - - PETSc.finalize() - =# -end From 94689e085887a0e9fd77212f067c81879ccd8e60 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 19:27:41 -0700 Subject: [PATCH 28/53] Add a petsc world age --- src/LibPETSc_lib.jl | 5 +++-- src/dm.jl | 11 +++++++---- src/dmda.jl | 7 ++++--- src/dmstag.jl | 4 +++- src/init.jl | 2 ++ src/ksp.jl | 10 ++++++++-- src/mat.jl | 16 ++++++++++++---- src/matshell.jl | 3 ++- src/options.jl | 15 +++++++++++++-- src/pc.jl | 6 ++++-- src/snes.jl | 4 +++- src/vec.jl | 30 ++++++++++++++++++++++-------- 12 files changed, 83 insertions(+), 30 deletions(-) diff --git a/src/LibPETSc_lib.jl b/src/LibPETSc_lib.jl index bd986834..5ad8406e 100644 --- a/src/LibPETSc_lib.jl +++ b/src/LibPETSc_lib.jl @@ -6,12 +6,13 @@ A container for specific PETSc libraries. All other containers for PETSc objects should be typed on this to ensure that dispatch is correct. """ -struct PetscLibType{PetscScalar, PetscInt, LibType} +mutable struct PetscLibType{PetscScalar, PetscInt, LibType} petsc_library::LibType + age::Int end function PetscLibType{ST, IT}(petsc_library) where {ST, IT} LT = typeof(petsc_library) - return PetscLibType{ST, IT, LT}(petsc_library) + return PetscLibType{ST, IT, LT}(petsc_library, 0) end const UnionPetscLibType = Union{PetscLibType, Type{<:PetscLibType}} diff --git a/src/dm.jl b/src/dm.jl index a43678d2..32bdb786 100644 --- a/src/dm.jl +++ b/src/dm.jl @@ -2,7 +2,12 @@ const CDM = Ptr{Cvoid} abstract type AbstractDM{PetscLib} end function destroy(dm::AbstractDM{PetscLib}) where {PetscLib} - finalized(PetscLib) || LibPETSc.DMDestroy(PetscLib, dm) + if !(finalized(PetscLib)) && + dm.age == getlib(PetscLib).age && + dm.ptr != C_NULL && + (!hasfield(typeof(dm), :own) || dm.own) + LibPETSc.DMDestroy(PetscLib, dm) + end dm.ptr = C_NULL return nothing end @@ -74,7 +79,7 @@ Generates a matrix from the `dm` object. $(_doc_external("DM/DMCreateMatrix")) """ function MatAIJ(dm::AbstractDM{PetscLib}) where {PetscLib} - mat = MatAIJ{PetscLib, PetscLib.PetscScalar}(C_NULL) + mat = MatAIJ{PetscLib, PetscLib.PetscScalar}(C_NULL, getlib(PetscLib).age) LibPETSc.DMCreateMatrix(PetscLib, dm, mat) @@ -341,7 +346,6 @@ function update!(local_ptr::CVec, global_vec::DMGlobalVec, mode::InsertMode) end return nothing end - """ update!( local_vec::DMLocalVec, @@ -368,7 +372,6 @@ function update!(local_vec::DMLocalVec, global_vec::DMGlobalVec, mode::InsertMod return nothing end - #= @for_petsc function update!( local_ptr::CVec, diff --git a/src/dmda.jl b/src/dmda.jl index 1a560500..6c3871a2 100644 --- a/src/dmda.jl +++ b/src/dmda.jl @@ -3,6 +3,7 @@ abstract type AbstractDMDA{PetscLib} <: AbstractDM{PetscLib} end mutable struct DMDA{PetscLib} <: AbstractDMDA{PetscLib} ptr::CDM opts::Options{PetscLib} + age::Int end """ @@ -57,7 +58,7 @@ function DMDA( options..., ) where {PetscLib} opts = Options(petsclib; options...) - da = DMDA{PetscLib}(C_NULL, opts) + da = DMDA{PetscLib}(C_NULL, opts, petsclib.age) @assert length(points_per_proc) == 1 @@ -108,7 +109,7 @@ function DMDA( options..., ) where {PetscLib} opts = Options(petsclib; options...) - da = DMDA{PetscLib}(C_NULL, opts) + da = DMDA{PetscLib}(C_NULL, opts, petsclib.age) @assert length(points_per_proc) == 2 @@ -166,7 +167,7 @@ function DMDA( options..., ) where {PetscLib} opts = Options(petsclib; options...) - da = DMDA{PetscLib}(C_NULL, opts) + da = DMDA{PetscLib}(C_NULL, opts, petsclib.age) @assert length(points_per_proc) == 3 diff --git a/src/dmstag.jl b/src/dmstag.jl index 6904a8a9..1a4771ba 100644 --- a/src/dmstag.jl +++ b/src/dmstag.jl @@ -924,8 +924,10 @@ $(_doc_external("DM/DMDestroy")) function destroy(dm::DMStag) end @for_petsc function destroy(dm::DMStag{$PetscLib}) - finalized($petsclib) || + if dm.age == getlib(PetscLib).age && !(finalized(PetscLib)) && dm.ptr == C_NULL @chk ccall((:DMDestroy, $petsc_library), PetscErrorCode, (Ptr{CDMStag},), dm) + end + dm.ptr = C_NULL return nothing end diff --git a/src/init.jl b/src/init.jl index b1415177..9020511b 100644 --- a/src/init.jl +++ b/src/init.jl @@ -36,6 +36,7 @@ end function initialize(petsclib) if !initialized(petsclib) MPI.Initialized() || MPI.Init() + petsclib.age += 1 LibPETSc.PetscInitializeNoArguments(petsclib) # disable signal handler @@ -62,6 +63,7 @@ end function finalize(petsclib) if !finalized(petsclib) + petsclib.age += 1 LibPETSc.PetscFinalize(petsclib) end return nothing diff --git a/src/ksp.jl b/src/ksp.jl index 8ad69763..b16a5795 100644 --- a/src/ksp.jl +++ b/src/ksp.jl @@ -9,6 +9,7 @@ Base.@kwdef mutable struct KSP{PetscLib, PetscScalar} <: opts::Options{PetscLib} = Options(PetscLib) A::Union{AbstractMat, Nothing} = nothing P::Union{AbstractMat, Nothing} = nothing + age::Int end """ @@ -34,7 +35,7 @@ function KSP( @assert initialized(PetscLib) opts = Options(PetscLib; options...) PetscScalar = PetscLib.PetscScalar - ksp = KSP{PetscLib, PetscScalar}(opts = opts) + ksp = KSP{PetscLib, PetscScalar}(opts = opts, age = getlib(PetscLib).age) comm = getcomm(A) with(ksp.opts) do @@ -82,7 +83,12 @@ function setfromoptions!(ksp::AbstractKSP{PetscLib}) where {PetscLib} end function destroy(ksp::AbstractKSP{PetscLib}) where {PetscLib} - finalized(PetscLib) || LibPETSc.KSPDestroy(PetscLib, ksp) + if !(finalized(PetscLib)) && + ksp.age == getlib(PetscLib).age && + ksp.ptr != C_NULL + LibPETSc.KSPDestroy(PetscLib, ksp) + end + ksp.ptr = C_NULL return nothing end diff --git a/src/mat.jl b/src/mat.jl index 7086dfa3..b7788186 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -12,7 +12,12 @@ Base.eltype( ) where {PetscLib, PetscScalar} = PetscScalar function destroy(M::AbstractMat{PetscLib}) where {PetscLib} - finalized(PetscLib) || LibPETSc.MatDestroy(PetscLib, M) + if !(finalized(PetscLib)) && + M.age == getlib(PetscLib).age && + M.ptr != C_NULL + LibPETSc.MatDestroy(PetscLib, M) + end + M.ptr = C_NULL return nothing end @@ -34,6 +39,7 @@ $(_doc_external("Mat/MatCreateSeqAIJ")) mutable struct MatSeqAIJ{PetscLib, PetscScalar} <: AbstractMat{PetscLib, PetscScalar} ptr::CMat + age::Int end function MatSeqAIJ( @@ -45,7 +51,7 @@ function MatSeqAIJ( comm = MPI.COMM_SELF @assert initialized(petsclib) PetscScalar = petsclib.PetscScalar - mat = MatSeqAIJ{PetscLib, PetscScalar}(C_NULL) + mat = MatSeqAIJ{PetscLib, PetscScalar}(C_NULL, petsclib.age) if nonzeros isa Integer LibPETSc.MatCreateSeqAIJ( petsclib, @@ -87,6 +93,7 @@ mutable struct MatSeqDense{PetscLib, PetscScalar} <: AbstractMat{PetscLib, PetscScalar} ptr::CMat array::Matrix{PetscScalar} + age::Int end function MatSeqDense( @@ -96,7 +103,7 @@ function MatSeqDense( comm = MPI.COMM_SELF @assert initialized(petsclib) @assert PetscScalar == petsclib.PetscScalar - mat = MatSeqDense{PetscLib, PetscScalar}(C_NULL, A) + mat = MatSeqDense{PetscLib, PetscScalar}(C_NULL, A, petsclib.age) LibPETSc.MatCreateSeqDense(petsclib, comm, size(A, 1), size(A, 2), A, mat) finalizer(destroy, mat) return mat @@ -143,6 +150,7 @@ $(_doc_external("Mat/MatSetUp")) mutable struct MatAIJ{PetscLib, PetscScalar} <: AbstractMat{PetscLib, PetscScalar} ptr::CMat + age::Int end function MatAIJ( @@ -158,7 +166,7 @@ function MatAIJ( ) where {PetscLib <: PetscLibType} @assert initialized(petsclib) PetscScalar = petsclib.PetscScalar - mat = MatAIJ{PetscLib, PetscScalar}(C_NULL) + mat = MatAIJ{PetscLib, PetscScalar}(C_NULL, petsclib.age) if diag_nonzeros isa Integer diag_nonzero = diag_nonzeros diag_nonzeros = C_NULL diff --git a/src/matshell.jl b/src/matshell.jl index ab87ca2f..ce636bee 100644 --- a/src/matshell.jl +++ b/src/matshell.jl @@ -28,6 +28,7 @@ mutable struct MatShell{PetscLib, PetscScalar, OType} <: AbstractMat{PetscLib, PetscScalar} ptr::CMat obj::OType + age::Int end struct MatOp{PetscLib, PetscInt, Op} end @@ -73,7 +74,7 @@ LibPETSc.@for_petsc function MatShell( global_rows = LibPETSc.PETSC_DECIDE, global_cols = LibPETSc.PETSC_DECIDE, ) where {OType} - mat = MatShell{$PetscLib, $PetscScalar, OType}(C_NULL, obj) + mat = MatShell{$PetscLib, $PetscScalar, OType}(C_NULL, obj, petsclib.age) # we use the MatShell object itself ctx = pointer_from_objref(mat) diff --git a/src/options.jl b/src/options.jl index 5652db9f..08e6234b 100644 --- a/src/options.jl +++ b/src/options.jl @@ -75,17 +75,28 @@ $(_doc_external("Sys/PetscOptionsCreate")) """ mutable struct Options{T} <: AbstractOptions{T} ptr::CPetscOptions + age::Int end function Options_(petsclib::PetscLibType) @assert initialized(petsclib) PetscLib = typeof(petsclib) - opts = Options{PetscLib}(C_NULL) + opts = Options{PetscLib}(C_NULL, petsclib.age) LibPETSc.PetscOptionsCreate(petsclib, opts) - finalizer(x->LibPETSc.PetscOptionsDestroy(PetscLib, x), opts) + finalizer(destroy, opts) return opts end +function destroy(opts::AbstractOptions{PetscLib}) where {PetscLib} + if !(finalized(PetscLib)) && + opts.age == getlib(PetscLib).age && + opts.ptr != C_NULL + LibPETSc.PetscOptionsDestroy(PetscLib, opts) + end + opts.ptr = C_NULL + return nothing +end + Options(petsclib::PetscLibType; kwargs...) = Options_(petsclib, kwargs...) Options(PetscLib::Type{<:PetscLibType}; kwargs...) = Options_(getlib(PetscLib), kwargs...) function Options_(petsclib::PetscLibType, ps::Pair...) diff --git a/src/pc.jl b/src/pc.jl index 1dd2f715..a18a7aff 100644 --- a/src/pc.jl +++ b/src/pc.jl @@ -28,8 +28,10 @@ scalartype(::AbstractPC{T}) where {T} = T end function destroy(pc::AbstractPC{$PetscScalar}) - finalized($petsclib) || - @chk ccall((:PCDestroy, $libpetsc), PetscErrorCode, (Ptr{CPC},), pc) + if pc.age == getlib(PetscLib).age && !(finalized(PetscLib)) && pc.ptr != C_NULL + @chk ccall((:PCDestroy, $libpetsc), PetscErrorCode, (Ptr{CPC},), pc) + end + pc.ptr = C_NULL return nothing end diff --git a/src/snes.jl b/src/snes.jl index 6a69f6be..cc7cf558 100644 --- a/src/snes.jl +++ b/src/snes.jl @@ -111,8 +111,10 @@ function SNES() end end function destroy(snes::AbstractSNES{$PetscScalar}) - finalized($petsclib) || + if snes.age == getlib(PetscLib).age && !(finalized(PetscLib)) && snes.ptr != C_NULL @chk ccall((:SNESDestroy, $libpetsc), PetscErrorCode, (Ptr{CSNES},), snes) + end + snes.ptr = C_NULL return nothing end diff --git a/src/vec.jl b/src/vec.jl index 4259db9a..2213bb58 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -13,7 +13,13 @@ Base.eltype( Base.size(v::AbstractVec) = (length(v),) function destroy(v::AbstractVec{PetscLib}) where {PetscLib} - finalized(PetscLib) || LibPETSc.VecDestroy(PetscLib, v) + if !(finalized(PetscLib)) && + v.age == getlib(PetscLib).age && + v.ptr != C_NULL && + (!hasfield(typeof(v), :own) || v.own) + LibPETSc.VecDestroy(PetscLib, v) + end + v.ptr = C_NULL return nothing end @@ -28,14 +34,17 @@ If the `own` then the finalizer is set on the vector; calling `destroy` when mutable struct VecPtr{PetscLib, PetscScalar} <: AbstractVec{PetscLib, PetscScalar} ptr::CVec + age::Int + own::Bool end function VecPtr( petsclib::PetscLib, ptr::CVec, own, ) where {PetscLib <: PetscLibType} - v = VecPtr{PetscLib, petsclib.PetscScalar}(ptr) - if seq_finalize && occursin("seq", getpetsctype(v)) + v = VecPtr{PetscLib, petsclib.PetscScalar}(ptr, petsclib.age, own) + comm = getcomm(v) + if own && MPI.Comm_size(comm) == 1 finalizer(destroy, v) end return v @@ -63,6 +72,7 @@ mutable struct VecSeqWithArray{PetscLib, PetscScalar} <: AbstractVec{PetscLib, PetscScalar} ptr::CVec array::Vector{PetscScalar} + age::Int end Base.parent(v::VecSeqWithArray) = v.array @@ -74,7 +84,7 @@ function VecSeqWithArray( comm = MPI.COMM_SELF @assert initialized(petsclib) @assert PetscScalar == petsclib.PetscScalar - v = VecSeqWithArray{PetscLib, PetscScalar}(C_NULL, array) + v = VecSeqWithArray{PetscLib, PetscScalar}(C_NULL, array, petsclib.age) LibPETSc.VecCreateSeqWithArray( petsclib, comm, @@ -106,12 +116,13 @@ $(_doc_external("Vec/VecCreateSeq")) mutable struct VecSeq{PetscLib, PetscScalar} <: AbstractVec{PetscLib, PetscScalar} ptr::CVec + age::Int end function VecSeq(petsclib::PetscLib, n::Int) where {PetscLib <: PetscLibType} comm = MPI.COMM_SELF @assert initialized(petsclib) - v = VecSeq{PetscLib, petsclib.PetscScalar}(C_NULL) + v = VecSeq{PetscLib, petsclib.PetscScalar}(C_NULL, petsclib.age) LibPETSc.VecCreateSeq(petsclib, comm, n, v) finalizer(destroy, v) return v @@ -143,6 +154,7 @@ $(_doc_external("Vec/VecCreateMPI")) mutable struct VecMPI{PetscLib, PetscScalar} <: AbstractVec{PetscLib, PetscScalar} ptr::CVec + age::Int end function VecMPI( @@ -153,7 +165,7 @@ function VecMPI( ) where {PetscLib <: PetscLibType} @assert initialized(petsclib) @assert local_length != PETSC_DECIDE || global_length != PETSC_DETERMINE - v = VecMPI{PetscLib, petsclib.PetscScalar}(C_NULL) + v = VecMPI{PetscLib, petsclib.PetscScalar}(C_NULL, petsclib.age) LibPETSc.VecCreateMPI(petsclib, comm, local_length, global_length, v) return v end @@ -185,6 +197,7 @@ $(_doc_external("Vec/VecCreateGhost")) mutable struct VecGhost{PetscLib, PetscScalar} <: AbstractVec{PetscLib, PetscScalar} ptr::CVec + age::Int end function VecGhost( @@ -198,7 +211,7 @@ function VecGhost( @assert initialized(petsclib) @assert PetscInt == PetscLib.PetscInt @assert local_length != PETSC_DECIDE || global_length != PETSC_DETERMINE - v = VecGhost{PetscLib, petsclib.PetscScalar}(C_NULL) + v = VecGhost{PetscLib, petsclib.PetscScalar}(C_NULL, petsclib.age) LibPETSc.VecCreateGhost( petsclib, comm, @@ -491,11 +504,12 @@ mutable struct LocalVec{PetscLib, PetscScalar, GVec} <: AbstractVec{PetscLib, PetscScalar} ptr::CVec gvec::GVec + age::Int end function LocalVec(gvec::AbstractVec{PetscLib}) where {PetscLib} GVec = typeof(gvec) PetscScalar = PetscLib.PetscScalar - LocalVec{PetscLib, PetscScalar, GVec}(C_NULL, gvec) + LocalVec{PetscLib, PetscScalar, GVec}(C_NULL, gvec, getlib(PetscLib).age) end """ From 9bf780edd34a79eeeb8306d4e3a41aff403426c4 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 19:52:51 -0700 Subject: [PATCH 29/53] Register finalizers based on MPI.Comm_size --- src/dm.jl | 4 ++++ src/mat.jl | 4 ++++ src/matshell.jl | 2 +- src/vec.jl | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/dm.jl b/src/dm.jl index 32bdb786..15758541 100644 --- a/src/dm.jl +++ b/src/dm.jl @@ -83,6 +83,10 @@ function MatAIJ(dm::AbstractDM{PetscLib}) where {PetscLib} LibPETSc.DMCreateMatrix(PetscLib, dm, mat) + if MPI.Comm_size(getcomm(mat)) == 1 + finalizer(destroy, mat) + end + return mat end diff --git a/src/mat.jl b/src/mat.jl index b7788186..e22a6ca6 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -196,6 +196,10 @@ function MatAIJ( setup && setup!(mat) + if MPI.Comm_size(comm) == 1 + finalizer(destroy, mat) + end + return mat end diff --git a/src/matshell.jl b/src/matshell.jl index ce636bee..1bc7ab0c 100644 --- a/src/matshell.jl +++ b/src/matshell.jl @@ -97,7 +97,7 @@ LibPETSc.@for_petsc function MatShell( ) LibPETSc.MatShellSetOperation(petsclib, mat, LibPETSc.MATOP_MULT, mulptr) - if comm == MPI.COMM_SELF + if MPI.Comm_size(comm) == 1 finalizer(destroy, mat) end diff --git a/src/vec.jl b/src/vec.jl index 2213bb58..5bc95d94 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -167,6 +167,9 @@ function VecMPI( @assert local_length != PETSC_DECIDE || global_length != PETSC_DETERMINE v = VecMPI{PetscLib, petsclib.PetscScalar}(C_NULL, petsclib.age) LibPETSc.VecCreateMPI(petsclib, comm, local_length, global_length, v) + if MPI.Comm_size(comm) == 1 + finalizer(destroy, v) + end return v end @@ -221,6 +224,9 @@ function VecGhost( ghost, v, ) + if MPI.Comm_size(comm) == 1 + finalizer(destroy, v) + end return v end From 5bc18bb277e1bdc74a6b993d75be13999a4cc9dc Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 20:00:17 -0700 Subject: [PATCH 30/53] Update .gitignore --- .gitignore | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 0b279ce1..5086eff3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,6 @@ -deps/ComplexDouble/ -deps/RealDouble/ -deps/RealSingle/ -deps/deps.jl -deps/petsc-*.tar.gz -*.jl.cov -*.jl.mem +*.swp +*.DS_Store +*~ docs/build/ docs/site/ -Manifest.toml \ No newline at end of file +Manifest.toml From 67e9d41b443c6e5277efa23eb50ea21d1fa9b482 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 20:11:43 -0700 Subject: [PATCH 31/53] Update Project.toml --- Project.toml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index 375f9cbc..b6be37ad 100644 --- a/Project.toml +++ b/Project.toml @@ -16,14 +16,9 @@ PETSc_jll = "3.15.2" julia = "1.3" [extras] -ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" -SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [targets] -test = ["ForwardDiff", "UnicodePlots", "Test", "Plots", "SparseDiffTools", -"Printf", "Random"] +test = ["Random", "Test", "UnicodePlots"] From 59c1f3331fcd26d35cd1c6739efda9029c8b5180 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 20:22:48 -0700 Subject: [PATCH 32/53] Disable dmda test with MPI and Windows Not sure why windows fails in this case... --- test/runtests.jl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index ee106a4e..0e9af319 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,11 +2,18 @@ using Test using MPI: mpiexec # Do the MPI tests first so we do not have mpi running inside MPI -for file in ("mpivec.jl", "mpimat.jl", "ksp.jl", "dmda.jl") +mpi_tests = ("mpivec.jl", "mpimat.jl", "ksp.jl") + +# XXX: We have problems with MPI and Windows with this test +if !(Sys.iswindows()) + mpi_tests = (mpi_tests..., "dmda.jl") +end + +for file in mpi_tests @testset "MPI test: $file" begin @test mpiexec() do mpi_cmd cmd = - `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no --project $file` + `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no --project $file` success(pipeline(cmd, stderr = stderr)) end end From 1edae83be9c5e4ee98ac482f020a143d791f655b Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 6 Aug 2021 21:08:36 -0700 Subject: [PATCH 33/53] Disable examples/laplacian.jl on windows --- test/examples.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/examples.jl b/test/examples.jl index 8a255dd5..54830f47 100644 --- a/test/examples.jl +++ b/test/examples.jl @@ -18,6 +18,11 @@ end examples = find_sources(examples_dir) stale_examples = find_sources(stale_examples_dir) + # XXX: Not sure why this test fails on windows... + if Sys.iswindows() + push!(stale_examples, joinpath(examples_dir, "laplacian.jl")) + end + filter!(file -> file ∉ stale_examples && readline(file) != "# EXCLUDE FROM TESTING", examples) @testset "$(basename(example))" for example in examples From d0e01e89962ace5e457a4d6b3160264c29867b91 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 9 Aug 2021 12:53:28 -0700 Subject: [PATCH 34/53] Move to test/Project.toml --- Project.toml | 8 -------- test/Project.toml | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 test/Project.toml diff --git a/Project.toml b/Project.toml index b6be37ad..22bc8ec1 100644 --- a/Project.toml +++ b/Project.toml @@ -14,11 +14,3 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" MPI = "0.15, 0.16, 0.17, 0.18, 0.19" PETSc_jll = "3.15.2" julia = "1.3" - -[extras] -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" - -[targets] -test = ["Random", "Test", "UnicodePlots"] diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 00000000..a2a632d3 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,7 @@ +[deps] +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" From ad4e9aa3ee746f8e43de12d68b14bcc98e36d3fc Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 9 Aug 2021 13:27:29 -0700 Subject: [PATCH 35/53] Allow for a Project.toml in examples --- examples/Project.toml | 4 +++ examples/README.md | 16 +++++++++ test/Project.toml | 2 +- test/examples.jl | 76 ++++++++++++++++++++++++++++--------------- test/mpi_examples.jl | 72 +++++++++++++++++++++++++--------------- 5 files changed, 117 insertions(+), 53 deletions(-) create mode 100644 examples/Project.toml create mode 100644 examples/README.md diff --git a/examples/Project.toml b/examples/Project.toml new file mode 100644 index 00000000..f7fef97a --- /dev/null +++ b/examples/Project.toml @@ -0,0 +1,4 @@ +[deps] +PETSc = "ace2c81b-2b5f-4b1e-a30d-d662738edfe0" +SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000..feb4c983 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,16 @@ +# `PETSc.jl` Examples + +The examples directory includes a `Project.toml` file. Since there is no +`Manifest.toml` when instantiated, this will use the latest released version of +`PETSc.jl`. + +To use a specific branch, for example `main`, you should run +```sh +julia --project=examples -e "import Pkg; Pkg.add(name=\"PETSc\", rev=\"main\");" +``` + +If you are developing the repository you should run +```sh +julia --project=examples -e "import Pkg; Pkg.develop(path=@__DIR__);" +``` +in order for your current developments to be used. diff --git a/test/Project.toml b/test/Project.toml index a2a632d3..1dffe449 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,7 +1,7 @@ [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" diff --git a/test/examples.jl b/test/examples.jl index 54830f47..837b6d7b 100644 --- a/test/examples.jl +++ b/test/examples.jl @@ -1,38 +1,62 @@ +# This is modeled on a combination of ideas from +# - https://github.com/JuliaGPU/KernelAbstractions.jl/blob/545457ad3918b4d5aa687d6423f3e33909f368b6/test/examples.jl +# - https://github.com/lcw/Bennu.jl/blob/54ddea41ad04d024fbd24687124ab43461609585/test/runtests.jl + using Test +using Pkg -function find_sources(path::String, sources=String[]) - if isdir(path) - for entry in readdir(path) - find_sources(joinpath(path, entry), sources) +function find_sources(path::String, sources = String[]) + if isdir(path) + for entry in readdir(path) + find_sources(joinpath(path, entry), sources) + end + elseif endswith(path, ".jl") + push!(sources, path) end - elseif endswith(path, ".jl") - push!(sources, path) - end - sources + sources end @testset "examples" begin - examples_dir = joinpath(@__DIR__, "..", "examples") - stale_examples_dir = joinpath(@__DIR__, "..", "examples", "stale") + examples_dir = joinpath(@__DIR__, "..", "examples") + stale_examples_dir = joinpath(@__DIR__, "..", "examples", "stale") + + examples = find_sources(examples_dir) + stale_examples = find_sources(stale_examples_dir) + + # XXX: Not sure why this test fails on windows... + if Sys.iswindows() + push!(stale_examples, joinpath(examples_dir, "laplacian.jl")) + end + + filter!( + file -> + file ∉ stale_examples && readline(file) != "# EXCLUDE FROM TESTING", + examples, + ) - examples = find_sources(examples_dir) - stale_examples = find_sources(stale_examples_dir) + julia = Base.julia_cmd() + base_dir = joinpath(@__DIR__, "..") - # XXX: Not sure why this test fails on windows... - if Sys.iswindows() - push!(stale_examples, joinpath(examples_dir, "laplacian.jl")) - end + old_pwd = pwd() + try + mktempdir() do tmp_dir + cd(tmp_dir) + examples_project = Pkg.Types.projectfile_path(examples_dir) + tmp_project = Pkg.Types.projectfile_path(tmp_dir) + cp(examples_project, tmp_project) - filter!(file -> file ∉ stale_examples && readline(file) != "# EXCLUDE FROM TESTING", examples) + inst_cmd = + `$julia --project=$tmp_project -e "import Pkg; Pkg.develop(path=raw\"$base_dir\"); Pkg.instantiate();"` + @test success(pipeline(inst_cmd, stderr=stderr, stdout=stdout)) - @testset "$(basename(example))" for example in examples - code = """ - $(Base.load_path_setup_code()) - include($(repr(example))) - """ - cmd = `$(Base.julia_cmd()) --startup-file=no -e $code` - @debug "Testing $example" Text(code) cmd - @test success(pipeline(cmd, stderr=stderr)) - end + cmd(script) = + `$julia --project=$tmp_project -e "include(raw\"$script\")"` + @testset "$(basename(example))" for example in examples + @test success(pipeline(cmd(example), stderr = stderr)) + end + end + finally + cd(old_pwd) + end end diff --git a/test/mpi_examples.jl b/test/mpi_examples.jl index 9a405c76..9c503f16 100644 --- a/test/mpi_examples.jl +++ b/test/mpi_examples.jl @@ -1,35 +1,55 @@ using Test using MPI +using Pkg -function find_sources(path::String, sources=String[]) - if isdir(path) - for entry in readdir(path) - find_sources(joinpath(path, entry), sources) +function find_sources(path::String, sources = String[]) + if isdir(path) + for entry in readdir(path) + find_sources(joinpath(path, entry), sources) + end + elseif endswith(path, ".jl") + push!(sources, path) end - elseif endswith(path, ".jl") - push!(sources, path) - end - sources + sources end @testset "mpi examples" begin - examples_dir = joinpath(@__DIR__, "..", "examples") - stale_examples_dir = joinpath(@__DIR__, "..", "examples", "stale") - - examples = find_sources(examples_dir) - stale_examples = find_sources(stale_examples_dir) - - filter!(file -> file ∉ stale_examples && readline(file) == "# INCLUDE IN MPI TEST", examples) - - @testset "$(basename(example))" for example in examples - code = """ - $(Base.load_path_setup_code()) - include($(repr(example))) - """ - @test mpiexec() do mpi_cmd - cmd = `$mpi_cmd -n 4 $(Base.julia_cmd()) --startup-file=no -e $code` - @debug "Testing $example" Text(code) cmd - success(pipeline(cmd, stderr=stderr)) + examples_dir = joinpath(@__DIR__, "..", "examples") + stale_examples_dir = joinpath(@__DIR__, "..", "examples", "stale") + + examples = find_sources(examples_dir) + stale_examples = find_sources(stale_examples_dir) + + filter!( + file -> + file ∉ stale_examples && readline(file) == "# INCLUDE IN MPI TEST", + examples, + ) + + julia = Base.julia_cmd() + base_dir = joinpath(@__DIR__, "..") + + old_pwd = pwd() + try + mktempdir() do tmp_dir + cd(tmp_dir) + examples_project = Pkg.Types.projectfile_path(examples_dir) + tmp_project = Pkg.Types.projectfile_path(tmp_dir) + cp(examples_project, tmp_project) + + inst_cmd = + `$julia --project=$tmp_project -e "import Pkg; Pkg.develop(path=raw\"$base_dir\"); Pkg.instantiate();"` + @test success(pipeline(inst_cmd, stderr=stderr, stdout=stdout)) + + cmd(script) = mpiexec() do mpi_cmd + `$mpi_cmd -n 4 $julia --project=$tmp_project -e "include(raw\"$script\")"` + end + + @testset "$(basename(example))" for example in examples + @test success(pipeline(cmd(example), stderr = stderr)) + end + end + finally + cd(old_pwd) end - end end From ef22f8c9b00b51f3e7833d140f4e6907ab1a61e0 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Mon, 9 Aug 2021 14:23:13 -0700 Subject: [PATCH 36/53] Rework KSP a bit to simplify cases --- src/ksp.jl | 93 +++++++++++++++++++----------------------------------- 1 file changed, 33 insertions(+), 60 deletions(-) diff --git a/src/ksp.jl b/src/ksp.jl index b16a5795..6005f636 100644 --- a/src/ksp.jl +++ b/src/ksp.jl @@ -3,13 +3,30 @@ const CKSPType = Cstring abstract type AbstractKSP{PetscLib, PetscScalar} <: Factorization{PetscScalar} end -Base.@kwdef mutable struct KSP{PetscLib, PetscScalar} <: - AbstractKSP{PetscLib, PetscScalar} - ptr::CKSP = C_NULL - opts::Options{PetscLib} = Options(PetscLib) - A::Union{AbstractMat, Nothing} = nothing - P::Union{AbstractMat, Nothing} = nothing +mutable struct KSP{PetscLib, PetscScalar} <: AbstractKSP{PetscLib, PetscScalar} + ptr::CKSP + opts::Options{PetscLib} age::Int + function KSP{PetscLib}(comm, opts) where {PetscLib} + PetscScalar = PetscLib.PetscScalar + ksp = new{PetscLib, PetscScalar}(C_NULL, opts, getlib(PetscLib).age) + with(ksp.opts) do + LibPETSc.KSPCreate(PetscLib, comm, ksp) + end + + # If there is only one rank we can finalize the KSP with GC + if MPI.Comm_size(comm) == 1 + finalizer(destroy, ksp) + end + + return ksp + end +end + +function setfromoptions!(ksp::AbstractKSP{PetscLib}) where {PetscLib} + with(ksp.opts) do + LibPETSc.KSPSetFromOptions(PetscLib, ksp) + end end """ @@ -33,25 +50,23 @@ function KSP( options..., ) where {PetscLib} @assert initialized(PetscLib) - opts = Options(PetscLib; options...) - PetscScalar = PetscLib.PetscScalar - ksp = KSP{PetscLib, PetscScalar}(opts = opts, age = getlib(PetscLib).age) - comm = getcomm(A) - with(ksp.opts) do - LibPETSc.KSPCreate(PetscLib, comm, ksp) - end + ksp = KSP{PetscLib}(getcomm(A), Options(PetscLib; options...)) setoperators!(ksp, A, P) - setfromoptions!(ksp) - # If there is only one rank we can finalize the KSP with GC - if MPI.Comm_size(comm) == 1 - finalizer(destroy, ksp) - end + setfromoptions!(ksp) return ksp end +function setoperators!( + ksp::AbstractKSP{PetscLib}, + A::AbstractMat{PetscLib}, + P::AbstractMat{PetscLib} = A, +) where {PetscLib} + LibPETSc.KSPSetOperators(PetscLib, ksp, A, P) + return ksp +end """ KSP([petsclib,] A::SparseMatrixCSC; options...) @@ -65,23 +80,6 @@ function KSP(A::SparseMatrixCSC{PetscScalar}; kwargs...) where {PetscScalar} KSP(MatSeqAIJ(getlib(; PetscScalar = PetscScalar), A); kwargs...) end -function setoperators!( - ksp::AbstractKSP{PetscLib}, - A::AbstractMat{PetscLib}, - P::AbstractMat{PetscLib} = A, -) where {PetscLib} - LibPETSc.KSPSetOperators(PetscLib, ksp, A, P) - ksp.A = A - ksp.P = P - return ksp -end - -function setfromoptions!(ksp::AbstractKSP{PetscLib}) where {PetscLib} - with(ksp.opts) do - LibPETSc.KSPSetFromOptions(PetscLib, ksp) - end -end - function destroy(ksp::AbstractKSP{PetscLib}) where {PetscLib} if !(finalized(PetscLib)) && ksp.age == getlib(PetscLib).age && @@ -290,14 +288,6 @@ struct Fn_KSPComputeOperators{T} end return ksp end - function KSPSetDM!(ksp::KSP{$PetscScalar}, dm::AbstractDM{$PetscLib}) - with(ksp.opts) do - @chk ccall((:KSPSetDM, $libpetsc), PetscErrorCode, (CKSP, CDM), ksp, dm) - end - ksp._dm = dm - return nothing - end - function DMDA(ksp::AbstractKSP{$PetscScalar}) t_dm = Ref{CDM}() @chk ccall( @@ -376,23 +366,6 @@ function LinearAlgebra.ldiv!(x::AbstractVector{T}, ksp::KSPAT{T, LT}, b::Abstrac end Base.:\(ksp::KSPAT{T, LT}, b::AbstractVector{T}) where {T, LT} = ldiv!(similar(b), ksp, b) -""" - KSP(da::AbstractDM; options...) - -Construct a PETSc Krylov subspace solver from the distributed mesh - -Any PETSc options prefixed with `ksp_` and `pc_` can be passed as keywords. - -see [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetDM.html) -""" -function KSP(dm::AbstractDM{PetscLib}; kwargs...) where {PetscLib} - T = scalartype(PetscLib) - ksp = KSP{T}(getcomm(dm); kwargs...) - KSPSetDM!(ksp, dm) - setfromoptions!(ksp) - return ksp -end - Base.show(io::IO, ksp::KSP) = _show(io, ksp) """ From 0adc67c688362324c8f4149912da6c27093e90bd Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Tue, 10 Aug 2021 12:26:46 -0700 Subject: [PATCH 37/53] Add KSP / DMDA interaction routines --- src/dmda.jl | 6 ++ src/ksp.jl | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++- src/mat.jl | 11 +++ 3 files changed, 209 insertions(+), 1 deletion(-) diff --git a/src/dmda.jl b/src/dmda.jl index 6c3871a2..af41ab69 100644 --- a/src/dmda.jl +++ b/src/dmda.jl @@ -6,6 +6,12 @@ mutable struct DMDA{PetscLib} <: AbstractDMDA{PetscLib} age::Int end +mutable struct DMDAPtr{PetscLib} <: AbstractDMDA{PetscLib} + ptr::CDM + age::Int + own::Bool +end + """ DMDA( petsclib::PetscLib diff --git a/src/ksp.jl b/src/ksp.jl index 6005f636..c381cb38 100644 --- a/src/ksp.jl +++ b/src/ksp.jl @@ -3,13 +3,32 @@ const CKSPType = Cstring abstract type AbstractKSP{PetscLib, PetscScalar} <: Factorization{PetscScalar} end +""" + KSPPtr(petsclib, ksp::CKS, own) + +Container type for a PETSc KSP that is just a raw pointer. +""" +mutable struct KSPPtr{PetscLib, PetscScalar} <: + AbstractKSP{PetscLib, PetscScalar} + ptr::CKSP + age::Int +end + mutable struct KSP{PetscLib, PetscScalar} <: AbstractKSP{PetscLib, PetscScalar} ptr::CKSP opts::Options{PetscLib} age::Int + computerhs! # Needed for KSPSetComputeRHS + computeops! # Needed for KSPSetComputeOperators function KSP{PetscLib}(comm, opts) where {PetscLib} PetscScalar = PetscLib.PetscScalar - ksp = new{PetscLib, PetscScalar}(C_NULL, opts, getlib(PetscLib).age) + ksp = new{PetscLib, PetscScalar}( + C_NULL, + opts, + getlib(PetscLib).age, + nothing, + nothing, + ) with(ksp.opts) do LibPETSc.KSPCreate(PetscLib, comm, ksp) end @@ -80,6 +99,153 @@ function KSP(A::SparseMatrixCSC{PetscScalar}; kwargs...) where {PetscScalar} KSP(MatSeqAIJ(getlib(; PetscScalar = PetscScalar), A); kwargs...) end +""" + KSP(da::AbstractDM; options...) + +Construct a PETSc Krylov subspace solver from the distributed mesh + +Any PETSc options prefixed with `ksp_` and `pc_` can be passed as keywords. + +# External Links +$(_doc_external("KSP/KSPCreate")) +$(_doc_external("KSP/KSPSetDM")) +$(_doc_external("KSP/KSPSetFromOptions")) +""" +function KSP(dm::AbstractDM{PetscLib}; options...) where {PetscLib} + @assert initialized(PetscLib) + + comm = getcomm(dm) + + ksp = KSP{PetscLib}(comm, Options(PetscLib; options...)) + + KSPSetDM!(ksp, dm) + + setfromoptions!(ksp) + + return ksp +end +function KSPSetDM!( + ksp::AbstractKSP{PetscLib}, + dm::AbstractDM{PetscLib}, +) where {PetscLib} + with(ksp.opts) do + LibPETSc.KSPSetDM(PetscLib, ksp, dm) + end + return ksp +end +# +# Wrapper for calls to setcomputerhs! +mutable struct Fn_KSPComputeRHS{PetscLib, PetscInt} end +function (w::Fn_KSPComputeRHS{PetscLib, PetscInt})( + new_ksp_ptr::CKSP, + cb::CVec, + ksp_ptr::Ptr{Cvoid}, +)::PetscInt where {PetscLib, PetscInt} + PetscScalar = PetscLib.PetscScalar + new_ksp = KSPPtr{PetscLib, PetscScalar}(new_ksp_ptr, getlib(PetscLib).age) + b = VecPtr(PetscLib, cb, false) + ksp = unsafe_pointer_to_objref(ksp_ptr) + ierr = ksp.computerhs!(b, new_ksp) + return PetscLib.PetscInt(ierr) +end + +""" + setcomputerhs!(ksp::AbstractKSP, rhs!::Function) + setcomputerhs!(rhs!::Function, ksp::AbstractKSP) + +Define `rhs!` to be the right-hand side function of the `ksp`. A call to +`rhs!(b, new_ksp)` should set the elements of the PETSc vector `b` based on the +`new_ksp`. + +!!! note + + The `new_ksp` passed to `rhs!` may not be the same as the `ksp` passed to + `setcomputerhs!`. + +# External Links +$(_doc_external("KSP/KSPSetComputeRHS")) +""" +setcomputerhs!(ksp::AbstractKSP, rhs!) = setcomputerhs!(rhs!, ksp) +# We have to use the macro here because of the @cfunction +LibPETSc.@for_petsc function setcomputerhs!(rhs!, ksp::KSP{$PetscLib}) + # We must wrap the user function in our own object + fptr = @cfunction( + Fn_KSPComputeRHS{$PetscLib, $PetscInt}(), + $PetscInt, + (CKSP, CVec, Ptr{Cvoid}) + ) + # set the computerhs! in the ksp + ksp.computerhs! = rhs! + LibPETSc.KSPSetComputeRHS($PetscLib, ksp, fptr, pointer_from_objref(ksp)) + return ksp +end + +# Wrapper for calls to setcomputerhs! +mutable struct Fn_KSPComputeOperators{PetscLib, PetscInt} end +function (w::Fn_KSPComputeOperators{PetscLib, PetscInt})( + new_ksp_ptr::CKSP, + cA::CMat, + cP::CMat, + ksp_ptr::Ptr{Cvoid}, +)::PetscInt where {PetscLib, PetscInt} + PetscScalar = PetscLib.PetscScalar + new_ksp = KSPPtr{PetscLib, PetscScalar}(new_ksp_ptr, getlib(PetscLib).age) + A = MatPtr{PetscLib, PetscScalar}(cA, getlib(PetscLib).age) + P = MatPtr{PetscLib, PetscScalar}(cP, getlib(PetscLib).age) + ksp = unsafe_pointer_to_objref(ksp_ptr) + ierr = ksp.computeops!(A, P, new_ksp) + return PetscLib.PetscInt(ierr) +end + +""" + setcomputeoperators!(ksp::AbstractKSP, ops!::Function) + setcomputeoperators!(ops!::Function, ksp::AbstractKSP) + +Define `ops!` to be the compute operators function for the `ksp`. A call to +`ops!(A, P, new_ksp)` should set the elements of the PETSc matrix linear +operator `A` and preconditioning matrix `P` based on the `new_ksp`. + +!!! note + + The `new_ksp` passed to `ops!` may not be the same as the `ksp` passed to + `setcomputeoperators!`. + +# External Links +$(_doc_external("KSP/KSPSetComputeOperators")) +""" +setcomputeoperators!(ksp::AbstractKSP, ops!) = setcomputeoperators!(ops!, ksp) +# We have to use the macro here because of the @cfunction +LibPETSc.@for_petsc function setcomputeoperators!(ops!, ksp::KSP{$PetscLib}) + # We must wrap the user function in our own object + fptr = @cfunction( + Fn_KSPComputeOperators{$PetscLib, $PetscInt}(), + $PetscInt, + (CKSP, CMat, CMat, Ptr{Cvoid}) + ) + # set the computerhs! in the ksp + ksp.computeops! = ops! + LibPETSc.KSPSetComputeOperators($PetscLib, ksp, fptr, pointer_from_objref(ksp)) + return ksp +end + +""" + getDMDA(ksp::AbstractKSP) + +Get `dmda` for `ksp` + +The returned `dmda` is owned by the `ksp` + +# External Links +$(_doc_external("KSP/KSPGetDM")) +""" +function getDMDA(ksp::AbstractKSP{PetscLib}) where PetscLib + t_dmda = Ref{CDM}() + LibPETSc.KSPGetDM(PetscLib, ksp, t_dmda) + dmda = DMDAPtr{PetscLib}(t_dmda[], getlib(PetscLib).age, false) + return dmda +end + + function destroy(ksp::AbstractKSP{PetscLib}) where {PetscLib} if !(finalized(PetscLib)) && ksp.age == getlib(PetscLib).age && @@ -101,6 +267,15 @@ function solve!( return x end +function solve!( + ksp::AbstractKSP{PetscLib}, +) where {PetscLib} + with(ksp.opts) do + LibPETSc.KSPSolve(PetscLib, ksp, C_NULL, C_NULL) + end + return ksp +end + """ createvecs(ksp::AbstractKSP; nright = 0, nleft = 0) @@ -173,6 +348,22 @@ function Base.:\( return x end +""" + getsolution(ksp) + +returns the solution vector stored in the `ksp`. This function does not make a +new copy of the vector, it merely returns the vector stored in the `ksp` + +# External Links +$(_doc_external("KSP/KSPGetSolution")) +""" +function getsolution(ksp::AbstractKSP{PetscLib}) where PetscLib + r_v = Ref{CVec}() + LibPETSc.KSPGetSolution(PetscLib, ksp, r_v) + v = VecPtr(PetscLib, r_v[], false) + return v +end + #= # # OLD WRAPPERS diff --git a/src/mat.jl b/src/mat.jl index e22a6ca6..c69f6d7a 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -21,6 +21,17 @@ function destroy(M::AbstractMat{PetscLib}) where {PetscLib} return nothing end +""" + MatPtr(petsclib, mat::CMat) + +Container type for a PETSc Mat that is just a raw pointer. +""" +mutable struct MatPtr{PetscLib, PetscScalar} <: + AbstractMat{PetscLib, PetscScalar} + ptr::CMat + age::Int +end + """ MatSeqAIJ(petsclib, num_rows, num_cols, nonzeros) From c7e6d676909e8c80408189f7e16ffab693cc0522 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Tue, 10 Aug 2021 14:42:20 -0700 Subject: [PATCH 38/53] Update options parsing --- src/options.jl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/options.jl b/src/options.jl index 08e6234b..9f3fded2 100644 --- a/src/options.jl +++ b/src/options.jl @@ -181,7 +181,7 @@ Parse the `args` vector into a `NamedTuple` that can be used as the options for the PETSc solvers. ```sh -julia --project file.jl -ksp_monitor -pc_type mg -ksp_view +julia --project file.jl -ksp_monitor -pc_type mg -ksp_view -da_refine=1 ``` """ function parse_options(args::Vector{String}) @@ -190,7 +190,14 @@ function parse_options(args::Vector{String}) while i <= length(args) @assert args[i][1] == '-' && length(args[i]) > 1 if i == length(args) || args[i + 1][1] == '-' - opts[Symbol(args[i][2:end])] = nothing + token = split(args[i][2:end], "=") + if length(token) == 1 + opts[Symbol(token[1])] = nothing + elseif length(token) == 2 + opts[Symbol(token[1])] = token[2] + else + error("invalid argument: $(args[i])") + end i = i + 1 else opts[Symbol(args[i][2:end])] = args[i + 1] From b623b2ffc53ac35154c265e081e7c25984110597 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 11 Aug 2021 14:51:34 -0700 Subject: [PATCH 39/53] Remove MPI.Init from precompile --- src/LibPETSc.jl | 1 - src/LibPETSc_lib.jl | 33 +-------------------------------- src/LibPETSc_startup.jl | 23 ++++++++++++++--------- src/PETSc.jl | 1 - 4 files changed, 15 insertions(+), 43 deletions(-) diff --git a/src/LibPETSc.jl b/src/LibPETSc.jl index b23e6eb6..9b3c1a46 100644 --- a/src/LibPETSc.jl +++ b/src/LibPETSc.jl @@ -2,7 +2,6 @@ module LibPETSc using Libdl using MPI -MPI.Initialized() || MPI.Init() export PetscLibType, petsclibs, diff --git a/src/LibPETSc_lib.jl b/src/LibPETSc_lib.jl index 5ad8406e..8239b869 100644 --- a/src/LibPETSc_lib.jl +++ b/src/LibPETSc_lib.jl @@ -70,41 +70,10 @@ function initialize(libhdl::Ptr{Cvoid}) @chk ccall(PetscInitializeNoArguments_ptr, PetscErrorCode, ()) end -const petsclibs = map(libs) do lib - libhdl = dlopen(lib...) - - # initialize petsc - PetscInitializeNoArguments_ptr = - dlsym(libhdl, :PetscInitializeNoArguments) - @chk ccall(PetscInitializeNoArguments_ptr, PetscErrorCode, ()) - - PETSC_REAL = DataTypeFromString(libhdl, "Real") - PETSC_SCALAR = DataTypeFromString(libhdl, "Scalar") - PETSC_INT_SIZE = PetscDataTypeGetSize(libhdl, PETSC_INT) - - PetscReal = - PETSC_REAL == PETSC_DOUBLE ? Cdouble : - PETSC_REAL == PETSC_FLOAT ? Cfloat : - error("PETSC_REAL = $PETSC_REAL not supported.") - - PetscScalar = - PETSC_SCALAR == PETSC_REAL ? PetscReal : - PETSC_SCALAR == PETSC_COMPLEX ? Complex{PetscReal} : - error("PETSC_SCALAR = $PETSC_SCALAR not supported.") - - PetscInt = - PETSC_INT_SIZE == 4 ? Int32 : - PETSC_INT_SIZE == 8 ? Int64 : - error("PETSC_INT_SIZE = $PETSC_INT_SIZE not supported.") - - PetscFinalize_ptr = dlsym(libhdl, :PetscFinalize) - @chk ccall(PetscFinalize_ptr, PetscErrorCode, ()) - - # TODO: PetscBLASInt, PetscMPIInt ? +const petsclibs = map(libs) do (lib, PetscScalar, PetscInt) return PetscLibType{PetscScalar, PetscInt}(lib[1]) end -# New macro is really to track the update macro for_petsc(expr) quote for petsclib in petsclibs diff --git a/src/LibPETSc_startup.jl b/src/LibPETSc_startup.jl index 9961e4ad..f97d4e6e 100644 --- a/src/LibPETSc_startup.jl +++ b/src/LibPETSc_startup.jl @@ -1,4 +1,5 @@ # Functions needed to find libraries +#= function getlibs() libs = () petsc_libs = ENV["JULIA_PETSC_LIBRARY"] @@ -10,23 +11,26 @@ function getlibs() end return libs end +=# const libs = @static if !haskey(ENV, "JULIA_PETSC_LIBRARY") using PETSc_jll ( - (PETSc_jll.libpetsc_Float64_Real_Int64,), - (PETSc_jll.libpetsc_Float32_Real_Int64,), - (PETSc_jll.libpetsc_Float64_Complex_Int64,), - (PETSc_jll.libpetsc_Float32_Complex_Int64,), - (PETSc_jll.libpetsc_Float64_Real_Int32,), - (PETSc_jll.libpetsc_Float32_Real_Int32,), - (PETSc_jll.libpetsc_Float64_Complex_Int32,), - (PETSc_jll.libpetsc_Float32_Complex_Int32,), + ((PETSc_jll.libpetsc_Float64_Real_Int64,), Float64, Int64), + ((PETSc_jll.libpetsc_Float32_Real_Int64,), Float32, Int64), + ((PETSc_jll.libpetsc_Float64_Complex_Int64,), Complex{Float64}, Int64), + ((PETSc_jll.libpetsc_Float32_Complex_Int64,), Complex{Float32}, Int64), + ((PETSc_jll.libpetsc_Float64_Real_Int32,), Float64, Int32), + ((PETSc_jll.libpetsc_Float32_Real_Int32,), Float32, Int32), + ((PETSc_jll.libpetsc_Float64_Complex_Int32,), Complex{Float64}, Int32), + ((PETSc_jll.libpetsc_Float32_Complex_Int32,), Complex{Float32}, Int32), ) else - getlibs() + error("JULIA_PETSC_LIBRARY not currently working") end + const petsc_library_file = get(ENV, "JULIA_PETSC_LIBRARY_PATH", "../lib/petsc_library.jl") + function DataTypeFromString(libhdl::Ptr{Cvoid}, name::AbstractString) PetscDataTypeFromString_ptr = dlsym(libhdl, :PetscDataTypeFromString) dtype_ref = Ref{PetscDataType}() @@ -42,6 +46,7 @@ function DataTypeFromString(libhdl::Ptr{Cvoid}, name::AbstractString) @assert found_ref[] == PETSC_TRUE return dtype_ref[] end + function PetscDataTypeGetSize(libhdl::Ptr{Cvoid}, dtype::PetscDataType) PetscDataTypeGetSize_ptr = dlsym(libhdl, :PetscDataTypeGetSize) datasize_ref = Ref{Csize_t}() diff --git a/src/PETSc.jl b/src/PETSc.jl index 3ad41b6c..ffeee7b5 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -1,6 +1,5 @@ module PETSc using MPI -MPI.Initialized() || MPI.Init() include("LibPETSc.jl") using .LibPETSc From 2abbd8d174108eefe6cf102cd0658f36c3ad1843 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Tue, 10 Aug 2021 12:27:07 -0700 Subject: [PATCH 40/53] Add dmda_laplacian example --- examples/Project.toml | 2 + examples/dmda_laplacian.jl | 226 +++++++++++++++++++++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 examples/dmda_laplacian.jl diff --git a/examples/Project.toml b/examples/Project.toml index f7fef97a..c9efe20c 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -1,4 +1,6 @@ [deps] +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" PETSc = "ace2c81b-2b5f-4b1e-a30d-d662738edfe0" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" diff --git a/examples/dmda_laplacian.jl b/examples/dmda_laplacian.jl new file mode 100644 index 00000000..28a3185a --- /dev/null +++ b/examples/dmda_laplacian.jl @@ -0,0 +1,226 @@ +# INCLUDE IN MPI TEST +# # Finite Difference Laplacian +# +# In this example a simple finite difference, 2-D laplacian with zero Dirichlet +# boundary conditions is solved using the PETSc DMDA interface +# +# The approach taken is that the 5-point Laplacian is applied in the interior +# and boundary points are included in the solve, but the forcing for the +# boundary data is the Dirichlet boundary condition and the matrix entry for +# these points is set to the identity. +# +# When run from the commandline this script will parse the commandline arguements: +# +# julia --project dmda_laplacian.jl -da_refine 4 -ksp_monitor +# +# The script can also be run in parallel: +# +# julia> using MPI +# julia> mpiexec(cmd -> run(`$cmd -n 4 julia --project dmda_laplacian.jl -da_refine 4 -ksp_monitor -pc_type asm`)) + +using MPI +using PETSc +using SparseArrays: spdiagm +using UnicodePlots: heatmap +using ForwardDiff: derivative + +opts = if !isinteractive() + PETSc.parse_options(ARGS) +else + (ksp_monitor = true, ksp_view = true, pc_type = "mg", pc_mg_levels = 2) +end + +# Set our MPI communicator +comm = MPI.COMM_WORLD + +# Set our PETSc Scalar Type +PetscScalar = Float64 + +# get the PETSc lib with our chosen `PetscScalar` type +petsclib = PETSc.getlib(; PetscScalar = PetscScalar) + +# Initialize PETSc +PETSc.initialize(petsclib) + +# Set the total number of grid points in each direction +Nq = (11, 13) + +# Set up the problem by using an exact solution and then using this to set the +# boundary data and forcing +exact(x, y) = cos(π * x) * sin(π * y) +forcing(x, y) = + derivative(x -> exact(x, y), x) * derivative(x -> exact(x, y), x) + + derivative(x -> exact(x, y), y) * derivative(x -> exact(x, y), y) + +# Create the PETSC dmda object +da = PETSc.DMDA( + petsclib, + comm, + (PETSc.DM_BOUNDARY_NONE, PETSc.DM_BOUNDARY_NONE), # Use no ghost nodes + Nq, # Global grid size + 1, # Number of DOF per node + 1, # Stencil width + PETSc.DMDA_STENCIL_STAR; # Stencil type + opts..., +) + +# Setup the Krylov solver for the distributed array +ksp = PETSc.KSP(da; opts...) + +# +# Set the right-hand side of the ksp +# +PETSc.setcomputerhs!(ksp) do petsc_b, ksp + # Get the distributed array from the ksp. + # The reason we need to query the ksp for the `da` is that this ksp may be + # different than the one we started with (e.g., multi-grid) + da = PETSc.getDMDA(ksp) + + # Get the corners of the box that this processor is responsible for + corners = PETSc.getcorners(da) + + # get the global grid dimension + Nq = PETSc.getinfo(da).global_size[1:2] + + # Determine the global grid in each direction. + g_x = range(PetscScalar(0), length = Nq[1], stop = 1) + g_y = range(PetscScalar(0), length = Nq[2], stop = 1) + + # Get the local grid in each direction + l_x = g_x[(corners.lower[1]):(corners.upper[1])] + l_y = g_y[(corners.lower[2]):(corners.upper[2])] + + # Build the RHS vector for the finite difference grid. Since `petsc_b` is a + # PETSc vectors, we covert it to a julia vector before using it + PETSc.withlocalarray!(petsc_b; read = false) do b + + # Reshape the vector into a 2-D vector of the size of the data we own + b = reshape(b, Int64(corners.size[1]), Int64(corners.size[2])) + + # Set the RHS forcing + b .= forcing.(l_x, l_y') + + # If on the boundary overwrite the forcing the with the Dirichlet data + if corners.lower[1] == 1 + b[1, :] .= exact.(l_x[1], l_y) + end + if corners.lower[2] == 1 + b[:, 1] .= exact.(l_x, l_y[1]) + end + if corners.upper[1] == Nq[1] + b[end, :] .= exact.(l_x[end], l_y) + end + if corners.upper[2] == Nq[2] + b[:, end] .= exact.(l_x, l_y[end]) + end + end + + # 0 is the PETSc success value + return 0 +end + +# +# Set the left-hand side operators of the ksp +# +PETSc.setcomputeoperators!(ksp) do A, _, ksp + # Get the distributed array from the ksp. + da = PETSc.getDMDA(ksp) + + # Get the corners of the box that this processor is responsible for + corners = PETSc.getcorners(da) + + # get the global grid dimension + Nq = PETSc.getinfo(da).global_size[1:2] + + # Get the grid spacing + Δx = PetscScalar(range(PetscScalar(0), length = Nq[1] + 2, stop = 1).step) + Δy = PetscScalar(range(PetscScalar(0), length = Nq[2] + 2, stop = 1).step) + + # Interior Points + interior = + (CartesianIndex(2, 2, 1)):(CartesianIndex(Nq[1] - 1, Nq[2] - 1, 1)) + + # Computational stencil for the interior points + sten = ( + CartesianIndex(-1, 0, 0), + CartesianIndex(1, 0, 0), + CartesianIndex(0, -1, 0), + CartesianIndex(0, 1, 0), + CartesianIndex(0, 0, 0), + ) + vals = (1 / Δx^2, 1 / Δx^2, 1 / Δy^2, 1 / Δy^2, -2 / Δx^2 - 2 / Δy^2) + + # Loop over all the points on the processory + for i in ((corners.lower):(corners.upper)) + # for the interior points set the stencil otherwise just set to identity + if i ∈ interior + for (s, v) in zip(sten, vals) + A[i, i + s] = v + end + else + A[i, i] = 1 + end + end + + # Assemble the matrix after inserting values + PETSc.assemble!(A) + + # 0 is the PETSc success value + return 0 +end + +# +# Solve the problem +# +PETSc.solve!(ksp) + +# +# Analyze the error in the solution +# + +# Get the solution +sol = PETSc.getsolution(ksp) + +# Get the corners we own +corners = PETSc.getcorners(da) + +# Get the true global size +Nq = PETSc.getinfo(da).global_size[1:2] + +# Determine the global grid in each direction. +g_x = range(PetscScalar(0), length = Nq[1], stop = 1) +g_y = range(PetscScalar(0), length = Nq[2], stop = 1) + +# Get the local grid in each direction +l_x = g_x[(corners.lower[1]):(corners.upper[1])] +l_y = g_y[(corners.lower[2]):(corners.upper[2])] + +# Determine the grid spacing +Δx = PetscScalar(l_x.step) +Δy = PetscScalar(l_y.step) + +# Calculate the error +PETSc.withlocalarray!(sol; read = false) do x + # Change to a 2-D array + u = reshape(x, corners.size[1], corners.size[2]) + + # Compute the local error squared on the mpi rank + loc_err2 = mapreduce(+, x, l_x, l_y') do u, x, y + (u - exact(x, y))^2 * Δx * Δy + end + + # reduce the error to the root rank and display + root = 0 + ϵ = MPI.Reduce(loc_err2, +, root, comm) + if root == MPI.Comm_rank(comm) + println("L2-error is $ϵ") + end + + # If we only have 1 MPI rank we plot the solution and error + if isinteractive() && MPI.Comm_size(comm) == 1 + display(heatmap(u, zlabel = "sol")) + display(heatmap(u - exact.(l_x, l_y'), zlabel = "error")) + end +end + +nothing From d3efdded6aaa1f670a1664f37927625845630aee Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Thu, 12 Aug 2021 15:55:07 -0700 Subject: [PATCH 41/53] Remove some old dmda code --- src/dmda.jl | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/dmda.jl b/src/dmda.jl index af41ab69..37862769 100644 --- a/src/dmda.jl +++ b/src/dmda.jl @@ -345,28 +345,6 @@ end # # OLD WRAPPERS # -mutable struct DMDALocalInfo{IT} - dim::IT - dof_per_node::IT - stencil_width::IT - global_size::NTuple{3, IT} - local_start::NTuple{3, IT} - local_size::NTuple{3, IT} - ghosted_local_start::NTuple{3, IT} - ghosted_local_size::NTuple{3, IT} - boundary_type::NTuple{3, DMBoundaryType} - stencil_type::DMDAStencilType - ___padding___::NTuple{5, IT} - DMDALocalInfo{IT}() where {IT} = new{IT}() -end - -mutable struct DMDA{PetscLib} <: AbstractDM{PetscLib} - ptr::CDM - opts::Options{PetscLib} - DMDA{PetscLib}(ptr, opts = Options(PetscLib)) where {PetscLib} = - new{PetscLib}(ptr, opts) -end - """ empty(da::DMDA) From 1e59f7ce1bd12c9b2f74cab798e39aa822319afa Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Thu, 12 Aug 2021 16:11:07 -0700 Subject: [PATCH 42/53] All read/write tuples for withlocalarray! --- src/vec.jl | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/vec.jl b/src/vec.jl index 5bc95d94..6cab19b9 100644 --- a/src/vec.jl +++ b/src/vec.jl @@ -433,9 +433,12 @@ function unsafe_localarray( end """ - withlocalarray!(f!, x::AbstractVec; read=true, write=true) - withlocalarray!(f!, xs...; read=true, write=true) - withlocalarray!(f!, xs::NTuple{N, AbstractVec}...; read=true, write=true) + withlocalarray!( + f!, + vecs::NTuple{N, AbstractVec}; + read::Union{Bool, NTuple{N, Bool}} = true, + write::Union{Bool, NTuple{N, Bool}} = true, + ) Convert `x` to an `Array{PetscScalar}` using [`unsafe_localarray`](@ref) and apply the function `f!`. @@ -444,16 +447,33 @@ Use `read=false` if the array is write-only; `write=false` if read-only. # Examples ```julia-repl -julia> map_unsafe_localarray(x; write=true) do x +julia> withlocalarray!(x; write=true) do x @. x .*= 2 end +julia> withlocalarray!( + x, + y; + read = (false, true), + write = (true, false) + ) do x, y + @. x .= 2 .+ y +end + !!! note `Base.finalize` is automatically called on the array. """ -function withlocalarray!(f!, vecs::NTuple{N, AbstractVec}; kwargs...) where {N} - arrays = map(vecs) do v - unsafe_localarray(v; kwargs...) +function withlocalarray!( + f!, + vecs::NTuple{N, AbstractVec}; + read::Union{Bool, NTuple{N, Bool}} = true, + write::Union{Bool, NTuple{N, Bool}} = true, +) where {N} + read isa NTuple{N, Bool} || (read = ntuple(_ -> read, N)) + write isa NTuple{N, Bool} || (write = ntuple(_ -> write, N)) + + arrays = map(vecs, read, write) do v, r, w + unsafe_localarray(v; read = r, write = w) end val = f!(arrays...) map(arrays) do array From 19d9bb08458db463707caf0387a137d57812beb5 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 18 Aug 2021 16:10:27 -0700 Subject: [PATCH 43/53] Add local and global vectors to DM --- src/dm.jl | 398 ++++++++++++++++++--------------------------------- test/dmda.jl | 127 ++++++---------- 2 files changed, 182 insertions(+), 343 deletions(-) diff --git a/src/dm.jl b/src/dm.jl index 15758541..12578c2a 100644 --- a/src/dm.jl +++ b/src/dm.jl @@ -90,377 +90,253 @@ function MatAIJ(dm::AbstractDM{PetscLib}) where {PetscLib} return mat end -#= -# -# OLD WRAPPERS -# """ - DMLocalVec(v::CVec, dm::AbstractDM) + DMLocalVec(dm::AbstractDM) -Container for an PETSc vector we know is "local" +returns a local vector from the `dm` object (has space for ghost). # External Links -$(_doc_external("Vec/Vec")) +$(_doc_external("DM/DMCreateLocalVector")) """ -mutable struct DMLocalVec{PetscLib, T, T_DM} <: AbstractVec{T} +mutable struct DMLocalVec{PetscLib, PetscScalar, DMT <: AbstractDM} <: + AbstractVec{PetscLib, PetscScalar} ptr::CVec - dm::T_DM - function DMLocalVec(ptr, dm::AbstractDM{PetscLib}) where {PetscLib} - new{PetscLib, scalartype(PetscLib), typeof(dm)}(ptr, dm) - end + age::Int + dm::DMT end +function DMLocalVec(dm::AbstractDM{PetscLib}) where {PetscLib} + petsclib = getlib(PetscLib) + PetscScalar = petsclib.PetscScalar + vec = + DMLocalVec{PetscLib, PetscScalar, typeof(dm)}(C_NULL, petsclib.age, dm) -""" - DMGlobalVec(v::CVec, dm::AbstractDM) - -Container for an PETSc vector we know is "global" + LibPETSc.DMCreateLocalVector(PetscLib, dm, vec) -# External Links -$(_doc_external("Vec/Vec")) -""" -mutable struct DMGlobalVec{PetscLib, T, T_DM} <: AbstractVec{T} - ptr::CVec - dm::T_DM - function DMGlobalVec(ptr, dm::AbstractDM{PetscLib}) where {PetscLib} - new{PetscLib, scalartype(PetscLib), typeof(dm)}(ptr, dm) + if MPI.Comm_size(getcomm(vec)) == 1 + finalizer(destroy, vec) end -end - -# Mainly for DM we do not know the type of, namely ones returned by PETSc -# functions such as `KSPGetDM` -mutable struct PetscDM{PetscLib} <: AbstractDM{PetscLib} - ptr::CDM -end - -""" - view(dm::AbstractDM, viewer::Viewer=ViewerStdout(petsclib, getcomm(dm))) - -view a `dm` with `viewer` - -# External Links -$(_doc_external("DM/DMView")) -""" -function view(::AbstractDM) end - -@for_petsc function view( - dm::AbstractDM{$PetscLib}, - viewer::AbstractViewer{$PetscLib} = ViewerStdout($petsclib, getcomm(dm)), -) - @chk ccall( - (:DMView, $petsc_library), - PetscErrorCode, - (CDM, CPetscViewer), - dm, - viewer, - ) - return nothing -end - -""" - creatematrix(dm::AbstractDM) - -Generates a matrix from the `dm` object. - -# External Links -$(_doc_external("DM/DMCreateMatrix")) -""" -function creatematrix end - -@for_petsc function creatematrix(dm::AbstractDM{$PetscLib}) - mat = Mat{$PetscScalar}(C_NULL) - - @chk ccall( - (:DMCreateMatrix, $petsc_library), - PetscErrorCode, - (CDM, Ptr{CMat}), - dm, - mat, - ) - - return mat -end - -""" - createlocalvector(dm::AbstractDM) - -returns a local vector from the `dm` object. - -# External Links -$(_doc_external("DM/DMCreateLocalVector")) -""" -function createlocalvector end - -@for_petsc function createlocalvector(dm::AbstractDM{$PetscLib}) - vec = DMLocalVec(C_NULL, dm) - - @chk ccall( - (:DMCreateLocalVector, $petsc_library), - PetscErrorCode, - (CDM, Ptr{CVec}), - dm, - vec, - ) return vec end """ - createglobalvector(dm::DM; write::Bool = true, read::Bool = true) + DMGlobalVec(dm::AbstractDM) returns a global vector from the `dm` object. # External Links $(_doc_external("DM/DMCreateGlobalVector")) """ -function createglobalvector end +mutable struct DMGlobalVec{PetscLib, PetscScalar, DMT <: AbstractDM} <: + AbstractVec{PetscLib, PetscScalar} + ptr::CVec + age::Int + dm::DMT +end +function DMGlobalVec(dm::AbstractDM{PetscLib}) where {PetscLib} + petsclib = getlib(PetscLib) + PetscScalar = petsclib.PetscScalar + vec = + DMGlobalVec{PetscLib, PetscScalar, typeof(dm)}(C_NULL, petsclib.age, dm) -@for_petsc function createglobalvector(dm::AbstractDM{$PetscLib}) - vec = DMGlobalVec(C_NULL, dm) + LibPETSc.DMCreateGlobalVector(PetscLib, dm, vec) - @chk ccall( - (:DMCreateGlobalVector, $petsc_library), - PetscErrorCode, - (CDM, Ptr{CVec}), - dm, - vec, - ) + if MPI.Comm_size(getcomm(vec)) == 1 + finalizer(destroy, vec) + end return vec end """ update!( - global_vec::DMGlobalVec, local_vec::DMLocalVec, + global_vec::AbstractVec, mode::InsertMode, ) -Updates `global_vec` from `local_vec` with insert `mode` - -# External Links -$(_doc_external("DM/DMLocalToGlobal")) -""" -function update!( global_vec::DMGlobalVec, local_vec::DMLocalVec, mode::InsertMode) end - -@for_petsc function update!( - global_vec::DMGlobalVec{$PetscLib}, - local_vec::DMLocalVec{$PetscLib}, - mode::InsertMode -) - @assert local_vec.dm === global_vec.dm - - update_local2global!( global_vec.ptr, local_vec.ptr, mode, local_vec.dm); - - return nothing -end - -""" - update!( - global_vec::DMGlobalVec, - local_ptr::CVec, - mode::InsertMode, - ) +Updates `local_vec` from the `global_vec` with insert `mode`. -Updates `global_vec` from a pointer to a local vector `local_ptr` with insert `mode` +Communication and computation can be overlapped with [`updatebegin!`](@ref) and +[`updateend!`](@ref) # External Links -$(_doc_external("DM/DMLocalToGlobal")) +$(_doc_external("DM/DMGlobalToLocal")) +$(_doc_external("DM/DMGlobalToLocalBegin")) +$(_doc_external("DM/DMGlobalToLocalEnd")) """ -function update!( global_vec::DMGlobalVec, local_ptr::CVec, mode::InsertMode) end - -@for_petsc function update!( - global_vec::DMGlobalVec{$PetscLib}, - local_ptr::CVec, - mode::InsertMode -) - update_local2global!( global_vec.ptr, local_ptr, mode, global_vec.dm); - - return nothing +function update!( + local_vec::DMLocalVec{PetscLib}, + global_vec::AbstractVec, + mode::InsertMode, +) where {PetscLib} + updatebegin!(local_vec, global_vec, mode) + return updateend!(local_vec, global_vec, mode) end """ - update!( - global_ptr::CVec, + updatebegin!( local_vec::DMLocalVec, + global_vec::AbstractVec, mode::InsertMode, ) -Updates pointer to global vec `global_ptr` from `local_vec` with insert `mode` +Begin update of `local_vec` from the `global_vec` with insert `mode`. # External Links -$(_doc_external("DM/DMLocalToGlobal")) +$(_doc_external("DM/DMGlobalToLocalBegin")) """ -function update!( global_vec::DMGlobalVec, local_ptr::CVec, mode::InsertMode) end - -@for_petsc function update!( - global_ptr::CVec, - local_vec::DMLocalVec{$PetscLib}, - mode::InsertMode -) - update_local2global!( global_ptr, local_vec.ptr, mode, local_vec.dm); +function updatebegin!( + local_vec::DMLocalVec{PetscLib}, + global_vec::AbstractVec, + mode::InsertMode, +) where {PetscLib} + LibPETSc.DMGlobalToLocalBegin( + PetscLib, + local_vec.dm, + global_vec, + mode, + local_vec, + ) return nothing end """ - update!( + updateend!( local_vec::DMLocalVec, - global_ptr::CVec, + global_vec::AbstractVec, mode::InsertMode, ) -Updates `local_vec` from pointer to global vec `global_ptr` with insert `mode` +End update of `local_vec` from the `global_vec` with insert `mode`. # External Links -$(_doc_external("DM/DMGlobalToLocal")) +$(_doc_external("DM/DMGlobalToLocalEnd")) """ -function update!(local_vec::DMLocalVec,global_ptr::CVec, mode::InsertMode) end - -@for_petsc function update!( - local_vec::DMLocalVec{$PetscLib}, - global_ptr::CVec, +function updateend!( + local_vec::DMLocalVec{PetscLib}, + global_vec::AbstractVec, mode::InsertMode, -) +) where {PetscLib} + LibPETSc.DMGlobalToLocalEnd( + PetscLib, + local_vec.dm, + global_vec, + mode, + local_vec, + ) - update_global2local!( local_vec.ptr, global_ptr, mode, local_vec.dm); - return nothing + return local_vec end """ update!( - local_ptr::CVec, - global_vec::DMGlobalVec + global_vec::AbstractVec, + local_vec::DMLocalVec, mode::InsertMode, ) -Updates pointer to local vec `local_ptr` from `global_vec` with insert `mode` +Updates `global_vec` from the `local_vec` with insert `mode`. + +Communication and computation can be overlapped with [`updatebegin!`](@ref) and +[`updateend!`](@ref) # External Links -$(_doc_external("DM/DMGlobalToLocal")) +$(_doc_external("DM/DMLocalToGlobal")) +$(_doc_external("DM/DMLocalToGlobalBegin")) +$(_doc_external("DM/DMLocalToGlobalEnd")) """ -function update!(local_ptr::CVec, global_vec::DMGlobalVec, mode::InsertMode) end - -@for_petsc function update!( - local_ptr::CVec, - global_vec::DMGlobalVec{$PetscLib}, +function update!( + global_vec::AbstractVec, + local_vec::DMLocalVec{PetscLib}, mode::InsertMode, -) - - update_global2local!( local_ptr, global_vec.ptr, mode, global_vec.dm); - return nothing +) where {PetscLib} + updatebegin!(global_vec, local_vec, mode) + return updateend!(global_vec, local_vec, mode) end """ - update!( + updatebegin!( + global_vec::AbstractVec, local_vec::DMLocalVec, - global_vec::DMGlobalVec, - mode::InsertMode + mode::InsertMode, ) -Updates `local_vec` from a pointer to a global vec `global_ptr` with insert `mode` +Begin update of `global_vec` from the `local_vec` with insert `mode`. # External Links -$(_doc_external("DM/DMGlobalToLocal")) +$(_doc_external("DM/DMLocalToGlobalBegin")) """ -function update!(local_vec::DMLocalVec, global_vec::DMGlobalVec, mode::InsertMode) end - -@for_petsc function update!( - local_vec::DMLocalVec{$PetscLib}, - global_vec::DMGlobalVec{$PetscLib}, - mode::InsertMode -) - @assert local_vec.dm === global_vec.dm - - update_global2local!( local_vec.ptr, global_vec.ptr, mode, local_vec.dm); - - return nothing -end - -#= -@for_petsc function update!( - local_ptr::CVec, - global_vec::DMGlobalVec{$PetscLib}, +function updatebegin!( + global_vec::AbstractVec, + local_vec::DMLocalVec{PetscLib}, mode::InsertMode, -) - @chk ccall( - (:DMGlobalToLocal, $petsc_library), - PetscErrorCode, - (CDM, CVec, InsertMode, CVec), - global_vec.dm, - global_vec, +) where {PetscLib} + LibPETSc.DMLocalToGlobalBegin( + PetscLib, + local_vec.dm, + local_vec, mode, - local_ptr, + global_vec, ) return nothing end -=# """ - update_local2global!( - global_ptr::CVec, - local_ptr::CVec, + updateend!( + global_vec::AbstractVec, + local_vec::DMLocalVec, mode::InsertMode, - dm::AbstractDM ) -Updates pointer of `global_vec` from pointer of `local_vec` with insert `mode`. -Both vectors should belong to the same `dm` +End update of `global_vec` from the `local_vec` with insert `mode`. -This is a low-level routine that is typically called by `update!` +# External Links +$(_doc_external("DM/DMLocalToGlobalEnd")) """ -function update_local2global! end - -@for_petsc function update_local2global!( - global_ptr::CVec, - local_ptr::CVec, +function updateend!( + global_vec::AbstractVec, + local_vec::DMLocalVec{PetscLib}, mode::InsertMode, - dm::AbstractDM{$PetscLib} -) - @chk ccall( - (:DMLocalToGlobal, $petsc_library), - PetscErrorCode, - (CDM, CVec, InsertMode, CVec), - dm, - local_ptr, +) where {PetscLib} + LibPETSc.DMLocalToGlobalEnd( + PetscLib, + local_vec.dm, + local_vec, mode, - global_ptr, + global_vec, ) - return nothing + return local_vec end +#= +# +# OLD WRAPPERS +# """ - update_global2local!( - local_ptr::CVec, - global_ptr::CVec, - mode::InsertMode, - dm::AbstractDM - ) - -Updates pointer to `local` vector from pointer to `global` vector with insert `mode`, assuming that both belong to the same `dm` + view(dm::AbstractDM, viewer::Viewer=ViewerStdout(petsclib, getcomm(dm))) -This is a low-level routine that is typically called by `update!` +view a `dm` with `viewer` +# External Links +$(_doc_external("DM/DMView")) """ -function update_global2local! end +function view(::AbstractDM) end -@for_petsc function update_global2local!( - local_ptr::CVec, - global_ptr::CVec, - mode::InsertMode, - dm::AbstractDM{$PetscLib} +@for_petsc function view( + dm::AbstractDM{$PetscLib}, + viewer::AbstractViewer{$PetscLib} = ViewerStdout($petsclib, getcomm(dm)), ) @chk ccall( - (:DMGlobalToLocal, $petsc_library), + (:DMView, $petsc_library), PetscErrorCode, - (CDM, CVec, InsertMode, CVec), + (CDM, CPetscViewer), dm, - global_ptr, - mode, - local_ptr, + viewer, ) - return nothing end diff --git a/test/dmda.jl b/test/dmda.jl index b88a43ae..138acc96 100644 --- a/test/dmda.jl +++ b/test/dmda.jl @@ -359,7 +359,7 @@ end PETSc.DMDA_STENCIL_STAR; # Force processor distribution so that we know how to go from # Stencil to Linear easily - processors = (ntuple(i->1, dim-1)..., mpisize) + processors = (ntuple(i -> 1, dim - 1)..., mpisize), ) mat = PETSc.MatAIJ(da) @@ -382,7 +382,7 @@ end PETSc.assemble!(mat) - ind = LinearIndices(ntuple(i->1:global_size[i], 3)) + ind = LinearIndices(ntuple(i -> 1:global_size[i], 3)) for ci in (corners.lower):(corners.upper) i = ind[ci] @test mat[i, i] == -2dim @@ -405,111 +405,74 @@ end end end -#= @testset "DM Vectors and Coordinates" begin comm = MPI.COMM_WORLD mpirank = MPI.Comm_rank(comm) mpisize = MPI.Comm_size(comm) for petsclib in PETSc.petsclibs PETSc.initialize(petsclib) - PetscScalar = PETSc.scalartype(petsclib) - PetscInt = PETSc.inttype(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + boundary_type = PETSc.DM_BOUNDARY_NONE dof_per_node = 1 stencil_width = 1 number_points = 10 points_per_proc = [PetscInt(10) for i in 1:mpisize] global_size = sum(points_per_proc) + # Set the points - da = PETSc.DMDACreate1d( + da = PETSc.DMDA( petsclib, comm, - boundary_type, - global_size, + (boundary_type,), + (global_size,), dof_per_node, - stencil_width, - points_per_proc, + stencil_width; + points_per_proc = (points_per_proc,), ) corners = PETSc.getcorners(da) # Create the local and global vectors - local_vec = PETSc.createlocalvector(da) - global_vec = PETSc.createglobalvector(da) - - bot_val = 0; top_val = 0; - for i=1:4 - # Fill everything with some data - fill!(local_vec, mpirank) - fill!(global_vec, mpisize) - - # Add the local values to the global values using the high-level routine - if i==1 - # 1) Use the high-level routine to do this - PETSc.update!(global_vec, local_vec, PETSc.ADD_VALUES) - elseif i==2 - # 2) Use pointer to local vector - PETSc.update!(global_vec, local_vec.ptr, PETSc.ADD_VALUES) - elseif i==3 - # 3) Use pointer to global vector - PETSc.update!(global_vec.ptr, local_vec, PETSc.ADD_VALUES) - elseif i==4 - # 4) Use low-level routines - PETSc.update_local2global!(global_vec.ptr, local_vec.ptr, PETSc.ADD_VALUES, local_vec.dm) - - end - - # end points added with neighbor due to ghost of size 1 - bot_val = mpisize + mpirank + (mpirank == 0 ? 0 : mpirank - 1) - top_val = mpisize + mpirank + (mpirank == mpisize - 1 ? 0 : mpirank + 1) - @test global_vec[corners.lower[1]] == bot_val - @test global_vec[corners.upper[1]] == top_val - - # Center is just self plus the global - for i in (corners.lower[1] + 1):(corners.upper[1] - 1) - @test global_vec[i] == mpisize + mpirank - end + local_vec = PETSc.DMLocalVec(da) + global_vec = PETSc.DMGlobalVec(da) + bot_val = 0 + top_val = 0 + + # Fill everything with some data + fill!(local_vec, mpirank) + fill!(global_vec, mpisize) + + # add the local values to the global values + PETSc.update!(global_vec, local_vec, PETSc.ADD_VALUES) + + # end points added with neighbor due to ghost of size 1 + bot_val = mpisize + mpirank + (mpirank == 0 ? 0 : mpirank - 1) + top_val = mpisize + mpirank + (mpirank == mpisize - 1 ? 0 : mpirank + 1) + @test global_vec[corners.lower[1]] == bot_val + @test global_vec[corners.upper[1]] == top_val + + # Center is just self plus the global + for i in (corners.lower[1] + 1):(corners.upper[1] - 1) + @test global_vec[i] == mpisize + mpirank end - # Reset the local values with the global values. - # This mainy tests the different local to global update! implementations - for i=1:4 - - # There are different implementations of copying global to local vectors - # That is useful if this is combined with SNES routines, as they only - # return the pointers to the vectors (not the full struct) - if i==1 - # 1) Use the high-level routine to do the copy - PETSc.update!(local_vec, global_vec, PETSc.INSERT_VALUES) - - elseif i==2 - # 2) Use a routine where a pointer to the global vector is mixed with a local vector - PETSc.update!(local_vec, global_vec.ptr, PETSc.INSERT_VALUES) - - elseif i==3 - # 3) Use a routine where a global vector is mixed with a pointer to a local vector - PETSc.update!(local_vec.ptr, global_vec, PETSc.INSERT_VALUES) - - elseif i==4 - # 4) Use the low-level (pointer) routine to do the same (not) - PETSc.update_global2local!(local_vec.ptr, global_vec.ptr, PETSc.INSERT_VALUES, global_vec.dm); # Note that this is a lower-level function that is not typically used - - end + # reset the local values with the global values + PETSc.update!(local_vec, global_vec, PETSc.INSERT_VALUES) - # My first value and my ghost should be the bot/top values - @test local_vec[1] == bot_val - @test local_vec[2] == bot_val - @test local_vec[end - 1] == top_val - @test local_vec[end] == top_val - - # interior is just self plus the global - for i in 3:(length(local_vec) - 2) - @test local_vec[i] == mpisize + mpirank - end - + # My first value and my ghost should be the bot/top values + @test local_vec[1] == bot_val + @test local_vec[2] == bot_val + @test local_vec[end - 1] == top_val + @test local_vec[end] == top_val + + # interior is just self plus the global + for i in 3:(length(local_vec) - 2) + @test local_vec[i] == mpisize + mpirank end - + #= # Test DM Coordinates coord_da = PETSc.getcoordinateDM(da) # Crank it up to 11! @@ -524,9 +487,9 @@ end for (loc, glo) in enumerate(ghost_lower:ghost_upper) @test coord_vec[loc] ≈ (glo - 1) * Δx end + =# PETSc.finalize(petsclib) end end -=# nothing From d6597faf328f85ed0be0bf43fb6ad46890b617b7 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Wed, 18 Aug 2021 16:47:13 -0700 Subject: [PATCH 44/53] Partially add DM coord --- src/dm.jl | 115 +++++++++++++++++++++++++++------------------------ src/dmda.jl | 53 +++++++++--------------- test/dmda.jl | 12 ++++-- 3 files changed, 88 insertions(+), 92 deletions(-) diff --git a/src/dm.jl b/src/dm.jl index 12578c2a..4542a846 100644 --- a/src/dm.jl +++ b/src/dm.jl @@ -103,12 +103,17 @@ mutable struct DMLocalVec{PetscLib, PetscScalar, DMT <: AbstractDM} <: ptr::CVec age::Int dm::DMT + own::Bool end function DMLocalVec(dm::AbstractDM{PetscLib}) where {PetscLib} petsclib = getlib(PetscLib) PetscScalar = petsclib.PetscScalar - vec = - DMLocalVec{PetscLib, PetscScalar, typeof(dm)}(C_NULL, petsclib.age, dm) + vec = DMLocalVec{PetscLib, PetscScalar, typeof(dm)}( + C_NULL, + petsclib.age, + dm, + true, + ) LibPETSc.DMCreateLocalVector(PetscLib, dm, vec) @@ -132,12 +137,17 @@ mutable struct DMGlobalVec{PetscLib, PetscScalar, DMT <: AbstractDM} <: ptr::CVec age::Int dm::DMT + own::Bool end function DMGlobalVec(dm::AbstractDM{PetscLib}) where {PetscLib} petsclib = getlib(PetscLib) PetscScalar = petsclib.PetscScalar - vec = - DMGlobalVec{PetscLib, PetscScalar, typeof(dm)}(C_NULL, petsclib.age, dm) + vec = DMGlobalVec{PetscLib, PetscScalar, typeof(dm)}( + C_NULL, + petsclib.age, + dm, + true, + ) LibPETSc.DMCreateGlobalVector(PetscLib, dm, vec) @@ -312,34 +322,6 @@ function updateend!( return local_vec end -#= -# -# OLD WRAPPERS -# -""" - view(dm::AbstractDM, viewer::Viewer=ViewerStdout(petsclib, getcomm(dm))) - -view a `dm` with `viewer` - -# External Links -$(_doc_external("DM/DMView")) -""" -function view(::AbstractDM) end - -@for_petsc function view( - dm::AbstractDM{$PetscLib}, - viewer::AbstractViewer{$PetscLib} = ViewerStdout($petsclib, getcomm(dm)), -) - @chk ccall( - (:DMView, $petsc_library), - PetscErrorCode, - (CDM, CPetscViewer), - dm, - viewer, - ) - return nothing -end - """ getcoordinateDM(dm::AbstractDM) @@ -348,48 +330,71 @@ Create a `coord_dm` for the coordinates of `dm`. # External Links $(_doc_external("DM/DMGetCoordinateDM")) """ -function getcoordinateDM end - -@for_petsc function getcoordinateDM(dm::AbstractDM{$PetscLib}) +function getcoordinateDM(dm::AbstractDM{PetscLib}) where {PetscLib} coord_dm = empty(dm) - @chk ccall( - (:DMGetCoordinateDM, $petsc_library), - PetscErrorCode, - (CDM, Ptr{CDM}), - dm, - coord_dm, - ) + LibPETSc.DMGetCoordinateDM(PetscLib, dm, coord_dm) - # If this fails then the `empty` call above is probably a bad idea! - if gettype(coord_dm) != "product" - @assert gettype(dm) == gettype(coord_dm) + if gettype(dm) == "stag" + @assert gettype(coord_dm) == "product" else - @assert gettype(dm) == "stag" # product can only be used with stag + @assert gettype(coord_dm) == gettype(dm) + end + + if MPI.Comm_size(getcomm(coord_dm)) == 1 + finalizer(destroy, coord_dm) end return coord_dm end """ - getcoordinateslocal(dm::AbstractDM) + coordinatesDMLocalVec(dm::AbstractDM) Gets a local vector with the coordinates associated with `dm`. # External Links $(_doc_external("DM/DMGetCoordinatesLocal")) """ -function getcoordinateslocal end +function coordinatesDMLocalVec(dm::AbstractDM{PetscLib}) where {PetscLib} + petsclib = getlib(PetscLib) + PetscScalar = petsclib.PetscScalar + coord_vec = DMLocalVec{PetscLib, PetscScalar, typeof(dm)}( + C_NULL, + petsclib.age, + dm, + false, + ) + LibPETSc.DMGetCoordinatesLocal(PetscLib, dm, coord_vec) + + return coord_vec +end + +#= +# +# OLD WRAPPERS +# +""" + view(dm::AbstractDM, [viewer]) + +view a `dm` with `viewer` + +# External Links +$(_doc_external("DM/DMView")) +""" +function view(::AbstractDM) end -@for_petsc function getcoordinateslocal(dm::AbstractDM{$PetscLib}) - coord_vec = DMLocalVec(C_NULL, dm) +@for_petsc function view( + dm::AbstractDM{$PetscLib}, + viewer::AbstractViewer{$PetscLib} = ViewerStdout($petsclib, getcomm(dm)), +) @chk ccall( - (:DMGetCoordinatesLocal, $petsc_library), + (:DMView, $petsc_library), PetscErrorCode, - (CDM, Ptr{CVec}), + (CDM, CPetscViewer), dm, - coord_vec, + viewer, ) - - return coord_vec + return nothing end + =# diff --git a/src/dmda.jl b/src/dmda.jl index 37862769..aac96296 100644 --- a/src/dmda.jl +++ b/src/dmda.jl @@ -341,16 +341,13 @@ function getghostcorners(da::AbstractDMDA{PetscLib}) where {PetscLib} ) end -#= -# -# OLD WRAPPERS -# """ - empty(da::DMDA) + similar(da::DMDA) return an uninitialized `DMDA` struct. """ -Base.empty(::DMDA{PetscLib}) where {PetscLib} = DMDA{PetscLib}(C_NULL) +Base.empty(da::DMDA{PetscLib}) where {PetscLib} = + DMDA{PetscLib}(C_NULL, da.opts, da.age) """ setuniformcoordinates!( @@ -366,34 +363,23 @@ by the `NTuple`s `xyzmin` and `xyzmax`. If `N` is less than the dimension of the # External Links $(_doc_external("DMDA/DMDASetUniformCoordinates")) """ -function setuniformcoordinates! end - -@for_petsc function setuniformcoordinates!( - da::DMDA{$PetscLib}, +function setuniformcoordinates!( + da::DMDA{PetscLib}, xyzmin::NTuple{N, Real}, xyzmax::NTuple{N, Real}, -) where {N} - xmin = $PetscReal(xyzmin[1]) - xmax = $PetscReal(xyzmax[1]) - - ymin = (N > 1) ? $PetscReal(xyzmin[2]) : $PetscReal(0) - ymax = (N > 1) ? $PetscReal(xyzmax[2]) : $PetscReal(0) - - zmin = (N > 2) ? $PetscReal(xyzmin[3]) : $PetscReal(0) - zmax = (N > 2) ? $PetscReal(xyzmax[3]) : $PetscReal(0) - - @chk ccall( - (:DMDASetUniformCoordinates, $petsc_library), - PetscErrorCode, - ( - CDM, - $PetscReal, - $PetscReal, - $PetscReal, - $PetscReal, - $PetscReal, - $PetscReal, - ), +) where {N, PetscLib} + PetscReal = PetscLib.PetscReal + xmin = PetscReal(xyzmin[1]) + xmax = PetscReal(xyzmax[1]) + + ymin = (N > 1) ? PetscReal(xyzmin[2]) : PetscReal(0) + ymax = (N > 1) ? PetscReal(xyzmax[2]) : PetscReal(0) + + zmin = (N > 2) ? PetscReal(xyzmin[3]) : PetscReal(0) + zmax = (N > 2) ? PetscReal(xyzmax[3]) : PetscReal(0) + + LibPETSc.DMDASetUniformCoordinates( + PetscLib, da, xmin, xmax, @@ -402,6 +388,5 @@ function setuniformcoordinates! end zmin, zmax, ) - return nothing + return da end -=# diff --git a/test/dmda.jl b/test/dmda.jl index 138acc96..f56cc7ba 100644 --- a/test/dmda.jl +++ b/test/dmda.jl @@ -472,13 +472,15 @@ end @test local_vec[i] == mpisize + mpirank end - #= + PETSc.destroy(global_vec) + PETSc.destroy(local_vec) + # Test DM Coordinates coord_da = PETSc.getcoordinateDM(da) # Crank it up to 11! xmin, xmax = 0, 11 PETSc.setuniformcoordinates!(coord_da, (xmin,), (xmax,)) - coord_vec = PETSc.getcoordinateslocal(coord_da) + coord_vec = PETSc.coordinatesDMLocalVec(coord_da) Δx = (xmax - xmin) / (global_size - 1) # Figure out the values we should have in the coordinate vector @@ -487,7 +489,11 @@ end for (loc, glo) in enumerate(ghost_lower:ghost_upper) @test coord_vec[loc] ≈ (glo - 1) * Δx end - =# + + PETSc.destroy(coord_vec) + PETSc.destroy(da) + PETSc.destroy(coord_da) + PETSc.finalize(petsclib) end end From caf1f70fbb4bad0863568ba47ba1a655c0d1b196 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Thu, 19 Aug 2021 12:27:14 -0700 Subject: [PATCH 45/53] Add view for DM --- src/dm.jl | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/dm.jl b/src/dm.jl index 4542a846..0a17d225 100644 --- a/src/dm.jl +++ b/src/dm.jl @@ -352,6 +352,8 @@ end Gets a local vector with the coordinates associated with `dm`. +Note that the returned vector is borrowed from the `dm` and is not a new vector. + # External Links $(_doc_external("DM/DMGetCoordinatesLocal")) """ @@ -369,10 +371,6 @@ function coordinatesDMLocalVec(dm::AbstractDM{PetscLib}) where {PetscLib} return coord_vec end -#= -# -# OLD WRAPPERS -# """ view(dm::AbstractDM, [viewer]) @@ -381,20 +379,10 @@ view a `dm` with `viewer` # External Links $(_doc_external("DM/DMView")) """ -function view(::AbstractDM) end - -@for_petsc function view( - dm::AbstractDM{$PetscLib}, - viewer::AbstractViewer{$PetscLib} = ViewerStdout($petsclib, getcomm(dm)), -) - @chk ccall( - (:DMView, $petsc_library), - PetscErrorCode, - (CDM, CPetscViewer), - dm, - viewer, - ) +function view( + dm::AbstractDM{PetscLib}, + viewer = LibPETSc.PETSC_VIEWER_STDOUT_(PetscLib, getcomm(dm)), +) where {PetscLib} + LibPETSc.DMView(PetscLib, dm, viewer) return nothing end - -=# From 2675fd632f4b4ffc0342b08ccc3030dbfdb912f0 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Thu, 12 Aug 2021 16:13:30 -0700 Subject: [PATCH 46/53] Fix up generator for SNES --- gen/generator.toml | 1 + gen/prologue.jl | 2 ++ lib/petsc_library.jl | 8 ++------ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gen/generator.toml b/gen/generator.toml index 2a1aabd2..6b3c2a9b 100644 --- a/gen/generator.toml +++ b/gen/generator.toml @@ -19,6 +19,7 @@ printer_blacklist = [ "Mat", "_p_Mat", "MatType", "Vec", "_p_Vec", "VecType", "KSP", "_p_KSP", "KSPType", + "SNES", "_p_SNES", "SNESType", "DM", "_p_DM", "DMType", # # Remove types defined in const.jl diff --git a/gen/prologue.jl b/gen/prologue.jl index 83753561..85297430 100644 --- a/gen/prologue.jl +++ b/gen/prologue.jl @@ -31,6 +31,8 @@ const Mat = Ptr{Cvoid} const MatType = Cstring const KSP = Ptr{Cvoid} const KSPType = Cstring +const SNES = Ptr{Cvoid} +const SNESType = Cstring const DM = Ptr{Cvoid} const DMType = Cstring diff --git a/lib/petsc_library.jl b/lib/petsc_library.jl index 3399c707..b3b8edf0 100644 --- a/lib/petsc_library.jl +++ b/lib/petsc_library.jl @@ -31,6 +31,8 @@ const Mat = Ptr{Cvoid} const MatType = Cstring const KSP = Ptr{Cvoid} const KSPType = Cstring +const SNES = Ptr{Cvoid} +const SNESType = Cstring const DM = Ptr{Cvoid} const DMType = Cstring @@ -55343,12 +55345,6 @@ end ) end -mutable struct _p_SNES end - -const SNES = Ptr{_p_SNES} - -const SNESType = Ptr{Cchar} - @for_petsc function SNESInitializePackage(::$UnionPetscLib) @chk ccall((:SNESInitializePackage, $petsc_library), PetscErrorCode, ()) end From ae24f145a294d9e549e12abe1f12d4815496c0c2 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 20 Aug 2021 15:39:14 -0700 Subject: [PATCH 47/53] Add back SNES functionality --- src/PETSc.jl | 2 +- src/snes.jl | 339 +++++++++++++++++++++++++++------------- src/sys.jl | 3 +- test/runtests.jl | 1 + test/snes.jl | 67 ++++++++ test/stale/test_snes.jl | 89 ----------- 6 files changed, 305 insertions(+), 196 deletions(-) create mode 100644 test/snes.jl delete mode 100644 test/stale/test_snes.jl diff --git a/src/PETSc.jl b/src/PETSc.jl index ffeee7b5..5ef3934b 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -30,7 +30,7 @@ include("dmda.jl") # include("dmstag.jl") include("ksp.jl") # include("pc.jl") -# include("snes.jl") +include("snes.jl") include("sys.jl") end diff --git a/src/snes.jl b/src/snes.jl index cc7cf558..98e51899 100644 --- a/src/snes.jl +++ b/src/snes.jl @@ -1,141 +1,268 @@ - const CSNES = Ptr{Cvoid} const CSNESType = Cstring +abstract type AbstractSNES{PetscLib} end + +""" + SNESPtr{PetscLib}(ptr, age) + +Container type for a PETSc SNES that is just a raw pointer. +""" +mutable struct SNESPtr{PetscLib} <: AbstractSNES{PetscLib} + ptr::CSNES + age::Int +end -abstract type AbstractSNES{T, PetscLib} end +function destroy(snes::AbstractSNES{PetscLib}) where {PetscLib} + if !(finalized(PetscLib)) && + snes.age == getlib(PetscLib).age && + snes.ptr != C_NULL + LibPETSc.SNESDestroy(PetscLib, snes) + end + snes.ptr = C_NULL + return nothing +end -mutable struct SNES{T, PetscLib} <: AbstractSNES{T, PetscLib} +mutable struct SNES{PetscLib} <: AbstractSNES{PetscLib} ptr::CSNES opts::Options{PetscLib} - fn! - fn_vec - update_jac! - jac_A - jac_P - user_ctx # Useful to transfer vectors and dms into the residual function + age::Int + # Garbage collection protections + f!::Function + updateJ!::Function + function SNES{PetscLib}(ptr, opts, age) where {PetscLib} + new{PetscLib}( + ptr, + opts, + age, + x -> error("function not defined"), + x -> error("function not defined"), + ) + end end -scalartype(::AbstractSNES{T}) where {T} = T +""" + SNES( + petsclib::PetscLib + comm::MPI.Comm; + setfromoptions = true, + options... + ) -Base.eltype(::AbstractSNES{T}) where {T} = T +Creates a PETSc nonlinear solve context on the communicator `comm` -# How to handle Jacobians? -# - https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESComputeJacobianDefault.html -# - https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESComputeJacobianDefaultColor.html -# - +If keyword argument `setfromoptions == true` then [`setfromoptions!`](@ref) +called on the created SNES context. -struct SNESFn{T} -end +# External Links +$(_doc_external("SNES/SNESCreate")) +$(_doc_external("SNES/SNESSetFromOptions")) +""" +function SNES( + petsclib::PetscLib, + comm::MPI.Comm; + setfromoptions = true, + options..., +) where {PetscLib} + opts = Options(petsclib; options...) + + snes = SNES{PetscLib}(C_NULL, opts, petsclib.age) + + with(snes.opts) do + LibPETSc.SNESCreate(petsclib, comm, snes) + end -struct SNESJac{T} + setfromoptions && setfromoptions!(snes) + + # We can only let the garbage collect finalize when we do not need to + # worry about MPI (since garbage collection is asyncronous) + if MPI.Comm_size(comm) == 1 + finalizer(destroy, snes) + end + + return snes end +function setfromoptions!(snes::AbstractSNES{PetscLib}) where {PetscLib} + with(snes.opts) do + LibPETSc.SNESSetFromOptions(PetscLib, snes) + end +end -#= -function _snesfn(csnes::CSNES, cx::CVec, cfx::CVec, ctx::Ptr{Cvoid}) - snes = unsafe_pointer_to_objref(ctx) - snes.Feval(cfx, cx) +function gettype(snes::AbstractSNES{PetscLib}) where {PetscLib} + r_type = Ref{CSNESType}() + LibPETSc.SNESGetType(PetscLib, snes, r_type) + return unsafe_string(r_type[]) end -function _snesjac(csnes::CSNES, cx::CVec, cAmat::CMat, cPmat::CMat, ctx::Ptr{Cvoid}) - snes = unsafe_pointer_to_objref(ctx) - snes.Jeval(cAmat, cPmat, cx) +function view( + snes::AbstractSNES{PetscLib}, + viewer = LibPETSc.PETSC_VIEWER_STDOUT_(PetscLib, getcomm(snes)), +) where {PetscLib} + LibPETSc.SNESView(PetscLib, snes, viewer) + return nothing end -=# -""" - SNES{PetscScalar}( - ::UnionPetscLib, - comm::MPI.Comm; - snessetfromoptions = true, - options...) -Initializes a `SNES` nonlinear solver object """ -function SNES() end - -@for_petsc function SNES{$PetscScalar}( - ::$UnionPetscLib, - comm::MPI.Comm; - snessetfromoptions = true, - options...) - - @assert initialized($petsclib) - opts = Options($petsclib, options...) - snes = SNES{$PetscScalar, $PetscLib}(C_NULL, opts, nothing, nothing, nothing, nothing, nothing, nothing) - - with(snes.opts) do - - @chk ccall( - (:SNESCreate, $petsc_library), - PetscErrorCode, - (MPI.MPI_Comm, - Ptr{CSNES}), - comm, - snes) + setfunction!(snes::AbstractSNES, f!::Function, x::AbstractVec) + setfunction!(f!::Function, snes::AbstractSNES, x::AbstractVec) - snessetfromoptions && setfromoptions!(snes) +Define `f!` to be the function of the `snes`. A call to `f!(fx, snes, x)` should +set the elements of the PETSc vector `fx` based on the `x`. - end +# External Links +$(_doc_external("SNES/SNESSetFunction")) +""" +setfunction!(snes::AbstractSNES, rhs!, vec) = setcomputerhs!(rhs!, snes, vec) + +# Wrapper for calls to setfunction! +mutable struct Fn_SNESSetFunction{PetscLib, PetscInt} end +function (w::Fn_SNESSetFunction{PetscLib, PetscInt})( + ::CSNES, + r_x::CVec, + r_fx::CVec, + snes_ptr::Ptr{Cvoid}, +)::PetscInt where {PetscLib, PetscInt} + snes = unsafe_pointer_to_objref(snes_ptr) + PetscScalar = PetscLib.PetscScalar + x = VecPtr(PetscLib, r_x, false) + fx = VecPtr(PetscLib, r_fx, false) + return snes.f!(fx, snes, x) +end - if comm == MPI.COMM_SELF - finalizer(destroy, snes) - end - return snes +LibPETSc.@for_petsc function setfunction!( + f!, + snes::AbstractSNES{$PetscLib}, + vec::AbstractVec{$PetscLib}, +) + ctx = pointer_from_objref(snes) + fptr = @cfunction( + Fn_SNESSetFunction{$PetscLib, $PetscInt}(), + $PetscInt, + (CSNES, CVec, CVec, Ptr{Cvoid}) + ) + with(snes.opts) do + LibPETSc.SNESSetFunction($PetscLib, snes, vec, fptr, ctx) end + snes.f! = f! + return nothing +end -@for_libpetsc begin +""" + setjacobian!( + snes::AbstractSNES, + updateJ!::Function, + J::AbstractMat, + P::AbstractMat = J + ) + setjacobian!( + updateJ!::Function, + snes::AbstractSNES, + J::AbstractMat, + P::AbstractMat = J + ) + +Define `updateJ!` to be the function that updates the Jacobian of the `snes`. + +If `J == P` then a call to `updateJ!(J, snes, x)` should set the elements of the +PETSc Jacobian (approximation). + +If `J ≠ P` then a call to `updateJ!(J, P, snes, x)` should set the elements of +the PETSc Jacobian (approximation) and preconditioning matrix `P`. + +# External Links +$(_doc_external("SNES/SNESSetJacobian")) +""" +setjacobian!(snes::AbstractSNES, updateJ!, J, PJ = J) = + setjacobian!(updateJ!, snes, J, PJ) + +# Wrapper for calls to setfunction! +mutable struct Fn_SNESSetJacobian{PetscLib, PetscInt} end +function (w::Fn_SNESSetJacobian{PetscLib, PetscInt})( + ::CSNES, + r_x::CVec, + r_A::CMat, + r_P::CMat, + snes_ptr::Ptr{Cvoid}, +)::PetscInt where {PetscLib, PetscInt} + snes = unsafe_pointer_to_objref(snes_ptr) + PetscScalar = PetscLib.PetscScalar + petsclib = getlib(PetscLib) + x = VecPtr(PetscLib, r_x, false) + A = MatPtr{PetscLib, PetscScalar}(r_A, petsclib.age) + P = MatPtr{PetscLib, PetscScalar}(r_P, petsclib.age) + P == A + return P == A ? snes.updateJ!(A, snes, x) : snes.updateJ!(A, P, snes, x) +end - function (::SNESFn{$PetscScalar})(csnes::CSNES, cx::CVec, cfx::CVec, ctx::Ptr{Cvoid})::$PetscInt - snes = unsafe_pointer_to_objref(ctx) - #x = unsafe_localarray($PetscScalar, cx; write=false) - #fx = unsafe_localarray($PetscScalar, cfx; read=false) - #snes.fn!(fx, x, snes.user_ctx) - snes.fn!(cfx, cx, snes.user_ctx) - #Base.finalize(x) - #Base.finalize(fx) - return $PetscInt(0) +LibPETSc.@for_petsc function setjacobian!( + updateJ!, + snes::AbstractSNES{$PetscLib}, + J::AbstractMat{$PetscLib}, + PJ::AbstractMat{$PetscLib} = J, +) + ctx = pointer_from_objref(snes) + fptr = @cfunction( + Fn_SNESSetJacobian{$PetscLib, $PetscInt}(), + $PetscInt, + (CSNES, CVec, CMat, CMat, Ptr{Cvoid}) + ) + with(snes.opts) do + LibPETSc.SNESSetJacobian($PetscLib, snes, J, PJ, fptr, ctx) end + snes.updateJ! = updateJ! + return nothing +end - function setfunction!(snes::AbstractSNES{$PetscScalar}, fn!, vec::AbstractVec{$PetscScalar}) - ctx = pointer_from_objref(snes) - fptr = @cfunction(SNESFn{$PetscScalar}(), $PetscInt, (CSNES, CVec, CVec, Ptr{Cvoid})) - with(snes.opts) do - @chk ccall((:SNESSetFunction, $libpetsc), PetscErrorCode, - (CSNES, CVec, Ptr{Cvoid}, Ptr{Cvoid}), - snes, vec, fptr, ctx) - end - snes.fn_vec = vec - snes.fn! = fn! - return nothing +function solve!( + x::AbstractVec{PetscLib}, + snes::AbstractSNES{PetscLib}, + b::Union{Nothing, AbstractVec{PetscLib}} = nothing, +) where {PetscLib} + with(snes.opts) do + LibPETSc.SNESSolve(PetscLib, snes, isnothing(b) ? C_NULL : b, x) end + return x +end - function destroy(snes::AbstractSNES{$PetscScalar}) - if snes.age == getlib(PetscLib).age && !(finalized(PetscLib)) && snes.ptr != C_NULL - @chk ccall((:SNESDestroy, $libpetsc), PetscErrorCode, (Ptr{CSNES},), snes) - end - snes.ptr = C_NULL - return nothing - end +""" + setDM!(snes::AbstractSNES, dm::AbstractDM) - function setfromoptions!(snes::AbstractSNES{$PetscScalar}) - @chk ccall((:SNESSetFromOptions, $libpetsc), PetscErrorCode, (CSNES,), snes) - end +Set `dm` for `snes` - function gettype(snes::AbstractSNES{$PetscScalar}) - t_r = Ref{CSNESType}() - @chk ccall((:SNESGetType, $libpetsc), PetscErrorCode, (CSNES, Ptr{CSNESType}), snes, t_r) - return unsafe_string(t_r[]) - end +# External Links +$(_doc_external("SNES/SNESSetDM")) +""" +function setDM!( + snes::AbstractSNES{PetscLib}, + dm::AbstractDM{PetscLib}, +) where {PetscLib} + LibPETSc.SNESSetDM(PetscLib, snes, dm) + return snes +end - function view(snes::AbstractSNES{$PetscScalar}, viewer::AbstractViewer{$PetscLib}=ViewerStdout($petsclib, getcomm(snes))) - @chk ccall((:SNESView, $libpetsc), PetscErrorCode, - (CSNES, CPetscViewer), - snes, viewer); - return nothing - end +""" + getDMDA(snes::AbstractSNES) +Get `dmda` for `snes` +The returned `dmda` is owned by the `snes` + +# External Links +$(_doc_external("SNES/SNESGetDM")) +""" +function getDMDA( + snes::AbstractSNES{PetscLib}, +) where {PetscLib} + t_dmda = Ref{CDM}() + LibPETSc.SNESGetDM(PetscLib, snes, t_dmda) + dmda = DMDAPtr{PetscLib}(t_dmda[], getlib(PetscLib).age, false) + return dmda +end + + +#= +@for_libpetsc begin function (::SNESJac{$PetscScalar})(csnes::CSNES, cx::CVec, cA::CMat, cP::CMat, ctx::Ptr{Cvoid})::$PetscInt snes = unsafe_pointer_to_objref(ctx) @@ -149,9 +276,11 @@ function SNES() end return $PetscInt(0) end - function setjacobian!(snes::AbstractSNES{$PetscScalar}, update_jac!, A::AbstractMat{$PetscScalar}, P::AbstractMat{$PetscScalar}=A) + function setjacobian!(snes::AbstractSNES{$PetscScalar}, update_jac!, + A::AbstractMat{$PetscScalar}, P::AbstractMat{$PetscScalar}=A) ctx = pointer_from_objref(snes) - jacptr = @cfunction(SNESJac{$PetscScalar}(), $PetscInt, (CSNES, CVec, CMat, CMat, Ptr{Cvoid})) + jacptr = @cfunction(SNESJac{$PetscScalar}(), $PetscInt, (CSNES, CVec, + CMat, CMat, Ptr{Cvoid})) with(snes.opts) do @chk ccall((:SNESSetJacobian, $libpetsc), PetscErrorCode, @@ -164,7 +293,6 @@ function SNES() end return nothing end - function solve!(x::AbstractVec{$PetscScalar}, snes::AbstractSNES{$PetscScalar}, b::AbstractVec{$PetscScalar}) with(snes.opts) do @chk ccall((:SNESSolve, $libpetsc), PetscErrorCode, @@ -183,3 +311,4 @@ function SNES() end end solve!(x::AbstractVector{T}, snes::AbstractSNES{T}) where {T} = parent(solve!(AbstractVec(x), snes)) +=# diff --git a/src/sys.jl b/src/sys.jl index cedbbd4e..c6278ea9 100644 --- a/src/sys.jl +++ b/src/sys.jl @@ -1,6 +1,6 @@ const CPetscObject = Ptr{Cvoid} -const UnionPetscTypes = Union{Options, AbstractVec, AbstractMat, AbstractKSP, AbstractDM} +const UnionPetscTypes = Union{Options, AbstractVec, AbstractMat, AbstractKSP, AbstractSNES, AbstractDM} # allows us to pass PETSc_XXX objects directly into CXXX ccall signatures Base.cconvert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj @@ -16,6 +16,7 @@ function getcomm( AbstractVec{PetscLib}, AbstractMat{PetscLib}, AbstractKSP{PetscLib}, + AbstractSNES{PetscLib}, AbstractDM{PetscLib}, }, ) where {PetscLib} diff --git a/test/runtests.jl b/test/runtests.jl index 0e9af319..4b82a579 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -31,6 +31,7 @@ include("vec.jl") include("mat.jl") include("matshell.jl") include("ksp.jl") +include("snes.jl") include("dmda.jl") # Run the examples diff --git a/test/snes.jl b/test/snes.jl new file mode 100644 index 00000000..00a36151 --- /dev/null +++ b/test/snes.jl @@ -0,0 +1,67 @@ +using Test +using PETSc +using MPI +MPI.Initialized() || MPI.Init() + +@testset "SNES" begin + comm = MPI.COMM_WORLD + mpirank = MPI.Comm_rank(comm) + mpisize = MPI.Comm_size(comm) + + for petsclib in PETSc.petsclibs + PETSc.initialize(petsclib) + PetscScalar = petsclib.PetscScalar + PetscInt = petsclib.PetscInt + + snes = PETSc.SNES( + petsclib, + comm; + ksp_rtol = 1e-4, + pc_type = "none", + ksp_monitor = false, + snes_monitor = false, + snes_converged_reason = false, + ksp_converged_reason = false, + ) + + r = PETSc.VecSeqWithArray(petsclib, zeros(PetscScalar, 2)) + PETSc.setfunction!(snes, r) do fx, snes, x + PETSc.withlocalarray!( + fx, + x; + read = (false, true), + write = (true, false), + ) do fx, x + fx[1] = x[1]^2 + x[1] * x[2] - 3 + fx[2] = x[1] * x[2] + x[2]^2 - 6 + end + return 0 + end + + J = PETSc.MatSeqDense(petsclib, zeros(PetscScalar, (2, 2))) + PETSc.setjacobian!(snes, J) do J, snes, x + PETSc.withlocalarray!(x; write = false) do x + J[1, 1] = 2x[1] + x[2] + J[1, 2] = x[1] + J[2, 1] = x[2] + J[2, 2] = x[1] + 2x[2] + end + PETSc.assemble!(J) + return 0 + end + x = PETSc.VecSeqWithArray(petsclib, PetscScalar.([2, 3])) + b = PETSc.VecSeqWithArray(petsclib, PetscScalar.([0, 0])) + PETSc.solve!(x, snes, b) + PETSc.withlocalarray!(x; read = true, write = false) do x + @test x ≈ [1, 2] rtol = 1e-4 + end + + # cleanup + PETSc.destroy(x) + PETSc.destroy(b) + PETSc.destroy(J) + PETSc.destroy(snes); + + PETSc.finalize(petsclib) + end +end diff --git a/test/stale/test_snes.jl b/test/stale/test_snes.jl deleted file mode 100644 index 9a213ace..00000000 --- a/test/stale/test_snes.jl +++ /dev/null @@ -1,89 +0,0 @@ -using Test -using PETSc, MPI, LinearAlgebra, SparseArrays - -MPI.Initialized() || MPI.Init() - -@testset "SNES" begin - - comm = MPI.COMM_WORLD - mpirank = MPI.Comm_rank(comm) - mpisize = MPI.Comm_size(comm) - - - for petsclib in PETSc.petsclibs - PETSc.initialize(petsclib) - PetscScalar = PETSc.scalartype(petsclib) - PetscInt = PETSc.inttype(petsclib) - - # This shows some examples of how SNES can be used. - # Note that you will receive pointers to PETSc vectors within your user routines. - # That is important for parallel simulations, where global residual - # and solution vectors are passed to the user-routines, but we work with - # local vectors - - function fn!(cfx, cx, user_ctx) - # We could do Global->Local here on cfx/cx, provided a pointer to the local - # vector is available in user_ctx - x_in = PETSc.unsafe_localarray(PetscScalar, cx; write=false) # read array - fx_in = PETSc.unsafe_localarray(PetscScalar, cfx; read=false) # write array - - fx_in[1] = x_in[1]^2 + x_in[1]*x_in[2] - 3 - fx_in[2] = x_in[1]*x_in[2] + x_in[2]^2 - 6 - - Base.finalize(fx_in) - Base.finalize(x_in) - end - - - function update_jac!(cx, J1, args...) - x_in = PETSc.unsafe_localarray(PetscScalar, cx; write=false) - J1[1,1] = 2x_in[1] + x_in[2] - J1[1,2] = x_in[1] - J1[2,1] = x_in[2] - J1[2,2] = x_in[1] + 2x_in[2] - - Base.finalize(x_in) - PETSc.assemble(J1) - end - - # structure with which we can pass data to the user-routines above - mutable struct Data - vec - julia - end - - julia_vec = 0; # we want pointers to local vectors - - # NOTE: for some reason, snes_monitor and ksp_monitor is not working if we specify that here. - # To be sorted out why that is (converged_reason does work) - S = PETSc.SNES{PetscScalar}(petsclib,comm; - ksp_rtol=1e-4, - pc_type="none", - ksp_monitor=true, - snes_monitor=true, - snes_converged_reason=false, - ksp_converged_reason=false) - - data = Data(PetscScalar.([100;2]), 1) - S.user_ctx = data; # we can pack anything we need in this struct - - PJ = PETSc.MatSeqDense(zeros(PetscScalar,(2,2))) - PETSc.setfunction!(S, fn!, PETSc.VecSeq( PetscScalar.(zeros(2)))) - PETSc.setjacobian!(S, update_jac!, PJ, PJ) - - x = PETSc.VecSeq(PetscScalar.([2.0, 3.0])); - b = PETSc.VecSeq(PetscScalar.([0.0, 0.0])); - PETSc.solve!(x, S, b) - - sol = PETSc.unsafe_localarray(PetscScalar, x.ptr; read=false) - @test sol ≈ [1.0,2.0] rtol=1e-4 - - # cleanup - PETSc.destroy(x); - PETSc.destroy(b); - PETSc.destroy(PJ); - #PETSc.destroy(S); - - PETSc.finalize(petsclib) - end -end From 7fdff8574c354660a3faadf45cc69cc60c5fe812 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Tue, 31 Aug 2021 15:38:05 -0700 Subject: [PATCH 48/53] Add better options parsing --- src/options.jl | 113 +++++++++++++++++++++++++++++++++++++++--------- test/options.jl | 29 +++++++++++++ 2 files changed, 122 insertions(+), 20 deletions(-) diff --git a/src/options.jl b/src/options.jl index 9f3fded2..253387c5 100644 --- a/src/options.jl +++ b/src/options.jl @@ -14,8 +14,7 @@ The PETSc global options database. """ struct GlobalOptions{PetscLib} <: AbstractOptions{PetscLib} end Base.cconvert(::Type{CPetscOptions}, obj::GlobalOptions) = C_NULL -GlobalOptions(::PetscLib) where PetscLib = GlobalOptions{PetscLib}() - +GlobalOptions(::PetscLib) where {PetscLib} = GlobalOptions{PetscLib}() """ Options{PetscLib <: PetscLibType}(kw -> arg, ...) @@ -79,12 +78,12 @@ mutable struct Options{T} <: AbstractOptions{T} end function Options_(petsclib::PetscLibType) - @assert initialized(petsclib) - PetscLib = typeof(petsclib) - opts = Options{PetscLib}(C_NULL, petsclib.age) - LibPETSc.PetscOptionsCreate(petsclib, opts) - finalizer(destroy, opts) - return opts + @assert initialized(petsclib) + PetscLib = typeof(petsclib) + opts = Options{PetscLib}(C_NULL, petsclib.age) + LibPETSc.PetscOptionsCreate(petsclib, opts) + finalizer(destroy, opts) + return opts end function destroy(opts::AbstractOptions{PetscLib}) where {PetscLib} @@ -98,7 +97,8 @@ function destroy(opts::AbstractOptions{PetscLib}) where {PetscLib} end Options(petsclib::PetscLibType; kwargs...) = Options_(petsclib, kwargs...) -Options(PetscLib::Type{<:PetscLibType}; kwargs...) = Options_(getlib(PetscLib), kwargs...) +Options(PetscLib::Type{<:PetscLibType}; kwargs...) = + Options_(getlib(PetscLib), kwargs...) function Options_(petsclib::PetscLibType, ps::Pair...) opts = Options_(petsclib) for (k, v) in ps @@ -110,32 +110,39 @@ end function Base.push!( ::GlobalOptions{PetscLib}, opts::Options{PetscLib}, -) where PetscLib +) where {PetscLib} LibPETSc.PetscOptionsPush(PetscLib, opts) return nothing end -function Base.pop!(::GlobalOptions{PetscLib}) where PetscLib +function Base.pop!(::GlobalOptions{PetscLib}) where {PetscLib} LibPETSc.PetscOptionsPop(PetscLib) return nothing end -function Base.setindex!(opts::AbstractOptions{PetscLib}, val, key) where PetscLib +function Base.setindex!( + opts::AbstractOptions{PetscLib}, + val, + key, +) where {PetscLib} val === true && (val = nothing) val === false && (return val) - LibPETSc.PetscOptionsSetValue(PetscLib, - opts, - string('-', key), - isnothing(val) ? C_NULL : string(val)) + LibPETSc.PetscOptionsSetValue( + PetscLib, + opts, + string('-', key), + isnothing(val) ? C_NULL : string(val), + ) return val end -function Base.getindex(opts::AbstractOptions{PetscLib}, key) where PetscLib +function Base.getindex(opts::AbstractOptions{PetscLib}, key) where {PetscLib} val = Vector{UInt8}(undef, 256) set_ref = Ref{PetscBool}() - LibPETSc.PetscOptionsGetString(PetscLib, + LibPETSc.PetscOptionsGetString( + PetscLib, opts, C_NULL, string('-', key), @@ -150,8 +157,8 @@ end function view( opts::AbstractOptions{PetscLib}, - viewer = LibPETSc.PETSC_VIEWER_STDOUT_(PetscLib, MPI.COMM_SELF) -) where PetscLib + viewer = LibPETSc.PETSC_VIEWER_STDOUT_(PetscLib, MPI.COMM_SELF), +) where {PetscLib} LibPETSc.PetscOptionsView(PetscLib, opts, viewer) return nothing end @@ -206,3 +213,69 @@ function parse_options(args::Vector{String}) end return NamedTuple(opts) end + +""" + typedget(opt::NamedTuple, key::Symbol, default::T) + +Parse `opt` similar to [`get`](@ref) but ensures that the returned value is the +same type as the default value. When `T <: NTuple` keys that result in a single +value will be filled into an `NTuple` of the same length as `T`; in the case of +strings it is parsed using [`split`](@ref) with comma delimiter + +# Examples +```julia-repl +julia> opt = (tup = (1, 2, 3), string_tup = "1,2,3", string_int = "4", int = 4) +(tup = (1, 2, 3), string_tup = "1,2,3", string_int = "4", int = 4) + +julia> typedget(opt, :int, 7) +4 + +julia> typedget(opt, :bad_key, 7) +7 + +julia> typedget(opt, :tup, (1, 1, 1)) +(1, 2, 3) + +julia> typedget(opt, :string_tup, (1, 1, 1)) +tokens = SubString{String}["1", "2", "3"] +(1, 2, 3) + +julia> typedget(opt, :string_int, (1, 1, 1)) +tokens = SubString{String}["4"] +(4, 4, 4) + +julia> typedget(opt, :int, (1, 1, 1)) +(4, 4, 4) + +julia> typedget(opt, :int, (1., 1., 1.)) +(4.0, 4.0, 4.0) +``` +""" +function typedget(opt::NamedTuple, key::Symbol, default::T) where {T} + v = get(opt, key, default) + if !(v isa T) + if T <: String + return string(v) + elseif v isa String + if T <: NTuple + ET = T.types[1] + tokens = split(v, ",") + if length(tokens) == 1 + return ntuple(_ -> parse(ET, tokens[1]), length(T.types)) + else + return ntuple(j -> parse(ET, tokens[j]), length(T.types)) + end + else + return parse(T, v) + end + else + if T <: NTuple && !(v isa Tuple) + ET = T.types[1] + return ntuple(j -> convert(ET, v), length(T.types)) + else + return convert(T, v) + end + end + end + return v +end diff --git a/test/options.jl b/test/options.jl index fdcf111f..8506830d 100644 --- a/test/options.jl +++ b/test/options.jl @@ -105,3 +105,32 @@ end true end end + +@testset "typedget" begin + opt = (tup = (1, 2, 3), string_tup = "1,2,3", string_int = "4", int = 4) + @test PETSc.typedget(opt, :bad_key, (1, 1, 1)) === (1, 1, 1) + @test PETSc.typedget(opt, :string_tup, (1, 1, 1)) === opt.tup + @test PETSc.typedget(opt, :string_tup, "a") === opt.string_tup + @test PETSc.typedget(opt, :bad_key, "a") === "a" + @test PETSc.typedget(opt, :int, Float64(7)) === Float64(opt.int) + @test PETSc.typedget(opt, :bad_key, Float64(7)) === Float64(7) + @test PETSc.typedget(opt, :tup, Float64.((1, 1, 1))) === Float64.(opt.tup) + @test PETSc.typedget(opt, :bad_key, Float64.((1, 1, 1))) === + Float64.((1, 1, 1)) + @test PETSc.typedget(opt, :string_tup, Float64.((1, 1, 1))) === + Float64.(opt.tup) + @test PETSc.typedget(opt, :tup, (1, 1, 1)) === opt.tup + @test PETSc.typedget(opt, :bad_key, (1, 1, 1)) === (1, 1, 1) + @test PETSc.typedget(opt, :string_tup, (1, 1, 1)) === opt.tup + @test PETSc.typedget(opt, :string_tup, "a") === opt.string_tup + @test PETSc.typedget(opt, :bad_key, "a") === "a" + @test PETSc.typedget(opt, :int, 7) === opt.int + @test PETSc.typedget(opt, :bad_key, 7) === 7 + @test PETSc.typedget(opt, :int, Float64(7)) === Float64(opt.int) + @test PETSc.typedget(opt, :bad_key, Float64(7)) === Float64(7) + @test PETSc.typedget(opt, :tup, Float64.((1, 1, 1))) === Float64.(opt.tup) + @test PETSc.typedget(opt, :bad_key, Float64.((1, 1, 1))) === + Float64.((1, 1, 1)) + @test PETSc.typedget(opt, :string_tup, Float64.((1, 1, 1))) === + Float64.(opt.tup) +end From 208178c9a7bd4557d8d7bf8905d7a943b1e0c266 Mon Sep 17 00:00:00 2001 From: Boris Kaus <61824822+boriskaus@users.noreply.github.com> Date: Tue, 31 Aug 2021 15:48:45 -0700 Subject: [PATCH 49/53] Add coord and reshape utils to dmda --- Project.toml | 1 + src/PETSc.jl | 1 + src/dmda.jl | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ test/dmda.jl | 53 ++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+) diff --git a/Project.toml b/Project.toml index 22bc8ec1..0d4308c1 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ version = "0.1.3" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" +OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" PETSc_jll = "8fa3689e-f0b9-5420-9873-adf6ccf46f2d" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" diff --git a/src/PETSc.jl b/src/PETSc.jl index 5ef3934b..410d9ab9 100644 --- a/src/PETSc.jl +++ b/src/PETSc.jl @@ -5,6 +5,7 @@ include("LibPETSc.jl") using .LibPETSc using MPI, LinearAlgebra, SparseArrays +using OffsetArrays function _petsc_link(fname) """ diff --git a/src/dmda.jl b/src/dmda.jl index aac96296..5b4e2cf1 100644 --- a/src/dmda.jl +++ b/src/dmda.jl @@ -390,3 +390,94 @@ function setuniformcoordinates!( ) return da end + +""" + getlocalcoordinatearray(da::AbstractDMDA) + +Returns a `NamedTuple` with OffsetArrays that contain the local coordinates and +that can be addressed uisng global indices + +""" +function getlocalcoordinatearray(da::AbstractDMDA{PetscLib}) where {PetscLib} + # retrieve local coordinates + coord_vec = coordinatesDMLocalVec(da) + # array + array1D = unsafe_localarray(coord_vec; read = true, write = false) + dim = [PetscLib.PetscInt(0)] + LibPETSc.DMGetCoordinateDim(PetscLib, da, dim) + dim = dim[1] + corners = getghostcorners(da) + + return reshapelocalarray(array1D, da, dim) +end + +""" + localinteriorlinearindex(dmda::AbstractDMDA) + +returns the linear indices associated with the degrees of freedom own by this +MPI rank embedded in the ghost index space for the `dmda` +""" +function localinteriorlinearindex(da::AbstractDMDA{PetscLib}) where PetscLib + # Determine the indices of the linear indices of the local part of the + # matrix we own + ghost_corners = PETSc.getghostcorners(da) + corners = PETSc.getcorners(da) + + # First compute the Cartesian indices for the local portion we own + offset = ghost_corners.lower - CartesianIndex(1, 1, 1) + l_inds = ((corners.lower):(corners.upper)) .- offset + + # Create a grid of indices with ghost then extract only the local part + lower = CartesianIndex(1, ghost_corners.lower) + upper = CartesianIndex(ndofs(da), ghost_corners.upper) + ind_local = LinearIndices(lower:upper)[:, l_inds][:] + return ind_local +end + +""" + ndofs(da::AbstractDMDA) + +Return the number of dofs in for `da` + +# External Links +$(_doc_external("DMDA/DMDAGetDof")) +""" +function ndofs(da::AbstractDMDA{PetscLib}) where PetscLib + PetscInt = PetscLib.PetscInt + ndof = [PetscInt(0)] + + # number of DOF that the DMDA has + LibPETSc.DMDAGetDof(PetscLib, da, ndof) + return @inbounds ndof[1] +end + +""" + reshapelocalarray(Arr, da::AbstractDMDA{PetscLib}[, ndof = ndofs(da)]) + +Returns an array with the same data as `Arr` but reshaped as an array that can +be addressed with global indexing. +""" +function reshapelocalarray( + Arr, + da::AbstractDMDA{PetscLib}, + ndof::Integer = ndofs(da), +) where {PetscLib} + + # First we try to use a ghosted size + corners = getghostcorners(da) + # If this is two big for the array use non-ghosted + if length(Arr) < prod(corners.size) * ndof + corners = getcorners(da) + end + @assert length(Arr) == prod(corners.size) * ndof + + oArr = OffsetArray( + reshape(Arr, Int64(ndof), Int64.(corners.size)...), + 1:ndof, + (corners.lower[1]):(corners.upper[1]), + (corners.lower[2]):(corners.upper[2]), + (corners.lower[3]):(corners.upper[3]), + ) + + return oArr +end diff --git a/test/dmda.jl b/test/dmda.jl index f56cc7ba..34ccce2b 100644 --- a/test/dmda.jl +++ b/test/dmda.jl @@ -490,6 +490,59 @@ end @test coord_vec[loc] ≈ (glo - 1) * Δx end + # Test setting coordinates in 2D & retrieving values + global_size_x, global_size_y = 10, 12 + dof_per_node = 2 + + # Create 2D DMDA + da_2D = PETSc.DMDA( + petsclib, + comm, + (boundary_type, boundary_type), + (global_size_x, global_size_y), + dof_per_node, + stencil_width, + PETSc.DMDA_STENCIL_STAR, + ) + + # Set uniform coordinates + xmin, xmax = 0, 11 + ymin, ymax = -20, 20 + Δx = (xmax - xmin) / (global_size_x - 1) # only needed for testing + Δy = (ymax - ymin) / (global_size_y - 1) # only needed for testing + + PETSc.setuniformcoordinates!(da_2D, (xmin, ymin), (xmax, ymax)) + + # Retrieve local coordinate array (shaped accordingly) + coord = PETSc.getlocalcoordinatearray(da_2D) + + # Check + corners = PETSc.getcorners(da_2D) + for i in ((corners.lower):(corners.upper)) + @test coord[1, i] ≈ (i[1] - 1) * Δx + xmin + @test coord[2, i] ≈ (i[2] - 1) * Δy + ymin + end + + # Retrieve local array of the 2 DOF DMDA and set values + x_g = PETSc.DMGlobalVec(da_2D) + x_l = PETSc.DMLocalVec(da_2D) + + PETSc.withlocalarray!(x_l; read = false) do l_x + x = PETSc.reshapelocalarray(l_x, da_2D) + @test 2 == size(x, 1) + + Array_1 = @view x[1, :, :, :] + Array_1 .= 11.1 + + Array_2 = @view x[2, :, :, :] + Array_2 .= 22.2 + end + PETSc.update!(x_g, x_l, PETSc.INSERT_VALUES) # add local values tp global vector + + sum_val = [PetscScalar(0)] # compute sum of parallel + PETSc.LibPETSc.VecSum(petsclib, x_g, sum_val) + @test sum_val[1] ≈ PetscScalar(3996) # check sum of global vector + PETSc.destroy(coord_vec) PETSc.destroy(da) PETSc.destroy(coord_da) From 2c7ff3d0630f6302abe6322b076e0a7bfb92fa2c Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 20 Aug 2021 15:39:26 -0700 Subject: [PATCH 50/53] Add SNES example (Liouville-Bratu-Gelfand equation) --- examples/Liouville_Bratu_Gelfand.jl | 276 ++++++++++++++++++++++++++++ examples/Project.toml | 1 + 2 files changed, 277 insertions(+) create mode 100644 examples/Liouville_Bratu_Gelfand.jl diff --git a/examples/Liouville_Bratu_Gelfand.jl b/examples/Liouville_Bratu_Gelfand.jl new file mode 100644 index 00000000..723d0a88 --- /dev/null +++ b/examples/Liouville_Bratu_Gelfand.jl @@ -0,0 +1,276 @@ +# INCLUDE IN MPI TEST +#= +In this example we solve the [Liouville–Bratu–Gelfand +equation](https://en.wikipedia.org/wiki/Liouville%E2%80%93Bratu%E2%80%93Gelfand_equation): +```math +∇² ψ + λ exp(ψ) +``` +with zero Dirichlet boundary conditions. + +To solve the problem we use the standard central, finite difference +approximation of the Laplacian in `d`-dimensions + +This example is motivated by the following PETSc examples: +- [`snes/ex5`](https://petsc.org/release/src/snes/tutorials/ex5.c.html) +- [`snes/ex14`](https://petsc.org/release/src/snes/tutorials/ex14.c.html) +=# + +using MPI +using PETSc +using OffsetArrays: OffsetArray +using LinearAlgebra: norm + +opts = if !isinteractive() + PETSc.parse_options(ARGS) +else + (ksp_monitor = true, ksp_view = true) +end + +# Set our MPI communicator +comm = MPI.COMM_WORLD + +# Set our PETSc Scalar Type +PetscScalar = Float64 + +# get the PETSc lib with our chosen `PetscScalar` type +petsclib = PETSc.getlib(; PetscScalar = PetscScalar) + +# Initialize PETSc +PETSc.initialize(petsclib) + +# dimensionality of the problem +dim = haskey(opts, :dim) ? opts.dim : 3 + +# Set the total number of grid points in each direction +Nq = ntuple(_ -> 10, dim) + +# Set the boundary conditions on each side +bcs = ntuple(_ -> PETSc.DM_BOUNDARY_NONE, dim) + +# Set parameter +λ = PetscScalar(6) + +# Create the PETSC dmda object +da = PETSc.DMDA( + petsclib, + comm, + bcs, # boundary conditions + Nq, # Global grid size + 1, # Number of DOF per node + 1, # Stencil width + PETSc.DMDA_STENCIL_STAR; # Stencil type + opts..., +) + +# Create the PETSC snes object +snes = PETSc.SNES(petsclib, comm; opts...) + +# add the da to the snes +PETSc.setDM!(snes, da) + +# Set up the initial guess +x = PETSc.DMGlobalVec(da) +xl = PETSc.DMLocalVec(da) +PETSc.withlocalarray!(xl; read = false) do l_x + corners = PETSc.getcorners(da) + + # Get the global grid dimensions + Nq = PETSc.getinfo(da).global_size + + # Figure out the interior points + int_min = min(CartesianIndex(corners.size), CartesianIndex(2, 2, 2)) + int_max = max(CartesianIndex(corners.size .- 1), CartesianIndex(1, 1, 1)) + interior = (int_min):(int_max) + + # Allows us to adress the local array with global indexing + ox = @view PETSc.reshapelocalarray(l_x, da)[1, :, :, :] + + # Set up the global coordinates in each direction + # -1 to 1 when Nq > 1 and 0 otherwise + coords = map( + Nq -> + Nq == 1 ? range(PetscScalar(0), stop = 0, length = Nq) : + range(-PetscScalar(1), stop = 1, length = Nq), + Nq, + ) + + scaling = λ / (λ + 1) + + # Loop over all the points on the processor and set the initial condition to + # be a hat function + for i in ((corners.lower):(corners.upper)) + ox[i] = + scaling * sqrt( + min( + (1 - abs(coords[1][i[1]])), + (1 - abs(coords[2][i[2]])), + (1 - abs(coords[3][i[3]])), + ), + ) + end +end +PETSc.update!(x, xl, PETSc.INSERT_VALUES) # update local -> global + +# Set up the nonlinear function +r = similar(x) +PETSc.setfunction!(snes, r) do g_fx, snes, g_x + # Get the DMDA associated with the snes + da = PETSc.getDMDA(snes) + + # Get a local vector and transfer the data from the global vector into it + l_x = PETSc.DMLocalVec(da) + PETSc.update!(l_x, g_x, PETSc.INSERT_VALUES) + + ghostcorners = PETSc.getghostcorners(da) + corners = PETSc.getcorners(da) + + # Global grid size + Nq = PETSc.getinfo(da).global_size + + # grid spacing in each dimension + Δx, Δy, Δz = PetscScalar(1) ./ Nq + + # Get local arrays + PETSc.withlocalarray!( + (g_fx, l_x); + read = (false, true), + write = (true, false), + ) do fx, x + + # reshape the array and allow for global indexing + x = @view PETSc.reshapelocalarray(x, da)[1, :, :, :] + fx = @view PETSc.reshapelocalarray(fx, da)[1, :, :, :] + + # Store a tuple of stencils in each direction + stencils = ( + ( + CartesianIndex(-1, 0, 0), + CartesianIndex(0, 0, 0), + CartesianIndex(1, 0, 0), + ), + ( + CartesianIndex(0, -1, 0), + CartesianIndex(0, 0, 0), + CartesianIndex(0, 1, 0), + ), + ( + CartesianIndex(0, 0, -1), + CartesianIndex(0, 0, 0), + CartesianIndex(0, 0, 1), + ), + ) + # Weights for each direction + weights = (Δy * Δz / Δx, Δx * Δz / Δy, Δx * Δy / Δz) + + # loop over indices and set the function value + for ind in ((corners.lower):(corners.upper)) + # If on the boundary just set equal to the incoming data + # otherwise apply the finite difference operator + if any(ntuple(j -> ind[j] == 1 || ind[j] == Nq[j], dim)) + fx[ind] = x[ind] + else + # Apply the source + u = -Δx * Δy * Δz * λ * exp(x[ind]) + + # Apply the finite diffference stencil + for (s, w) in zip(stencils[1:dim], weights[1:dim]) + u += + w * (-x[ind + s[1]] + 2 * x[ind + s[2]] - x[ind + s[3]]) + end + fx[ind] = u + end + end + end + + # Clean up the local vector + PETSc.destroy(l_x) + return 0 +end + +J = PETSc.MatAIJ(da) +PETSc.setjacobian!(snes, J) do J, snes, g_x + # Get the DMDA associated with the snes + da = PETSc.getDMDA(snes) + + # Get the corners of the points we own + corners = PETSc.getcorners(da) + + # Global grid size + Nq = PETSc.getinfo(da).global_size + + # grid spacing in each dimension + Δx, Δy, Δz = PetscScalar(1) ./ Nq + + # Store a tuple of stencils in each direction + stencils = ( + ( + CartesianIndex(-1, 0, 0), + CartesianIndex(0, 0, 0), + CartesianIndex(1, 0, 0), + ), + ( + CartesianIndex(0, -1, 0), + CartesianIndex(0, 0, 0), + CartesianIndex(0, 1, 0), + ), + ( + CartesianIndex(0, 0, -1), + CartesianIndex(0, 0, 0), + CartesianIndex(0, 0, 1), + ), + ) + # Weights for each direction + weights = (Δy * Δz / Δx, Δx * Δz / Δy, Δx * Δy / Δz) + + # Get a local array of the solution vector + PETSc.withlocalarray!(g_x; write = false) do l_x + # reshape so we can use multi-D indexing + x = @view PETSc.reshapelocalarray(l_x, da)[1, :, :, :] + + # loop over indices and set the function value + for ind in ((corners.lower):(corners.upper)) + # If on the boundary just set equal to the incoming data + # otherwise apply the finite difference operator + if any(ntuple(j -> ind[j] == 1 || ind[j] == Nq[j], dim)) + J[ind, ind] = 1 + else + # We accumulate the diagonal and add it at the end + Jii = -Δx * Δy * Δz * λ * exp(x[ind]) # Apply the source + + # Apply the finite diffference stencil + for (s, w) in zip(stencils[1:dim], weights[1:dim]) + Jii += w * 2 + J[ind, ind + s[1]] = -w + J[ind, ind + s[3]] = -w + end + J[ind, ind] = Jii + end + end + end + + # Assemble the Jacobian matrix + PETSc.assemble!(J) + return 0 +end + +if MPI.Comm_rank(comm) == 0 + println(@elapsed(PETSc.solve!(x, snes))) +else + PETSc.solve!(x, snes) +end +g = similar(x) +snes.f!(g, snes, x) +nm = norm(g) +if MPI.Comm_rank(comm) == 0 + @show nm +end + +# Do some clean up +PETSc.destroy(J) +PETSc.destroy(x) +PETSc.destroy(g) +PETSc.destroy(r) +PETSc.destroy(da) +PETSc.destroy(snes) + +PETSc.finalize(petsclib) diff --git a/examples/Project.toml b/examples/Project.toml index c9efe20c..278e352c 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -1,6 +1,7 @@ [deps] ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" +OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" PETSc = "ace2c81b-2b5f-4b1e-a30d-d662738edfe0" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" From fb8f5d40322bafc90661ab2490ac9fcbd4a1e5c1 Mon Sep 17 00:00:00 2001 From: Boris Kaus <61824822+boriskaus@users.noreply.github.com> Date: Tue, 31 Aug 2021 15:58:40 -0700 Subject: [PATCH 51/53] Add copyto! between Julia and PETSc sparse matrix --- src/mat.jl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mat.jl b/src/mat.jl index c69f6d7a..719d7f7b 100644 --- a/src/mat.jl +++ b/src/mat.jl @@ -645,16 +645,23 @@ function MatSeqAIJ( return M end -#= -function Base.copyto!(M::PETSc.MatSeqAIJ{T}, S::SparseMatrixCSC{T}) where {T} - for j = 1:size(S,2) - for ii = S.colptr[j]:S.colptr[j+1]-1 +# Copy a local sparse matrix to a PETSc matrix +function Base.copyto!( + M::AbstractMat{PetscLib}, + S::SparseMatrixCSC, +) where {PetscLib} + row_rng = ownershiprange(M, false) + row_start = row_rng[1] + _, n = size(S) + for j in 1:n + for ii in S.colptr[j]:(S.colptr[j + 1] - 1) i = S.rowval[ii] - M[i,j] = S.nzval[ii] + M[i + row_start, j + row_start] = S.nzval[ii] end end - assemble(M); end + +#= =# """ From 16d3fbf1e3736155af4da26ca2043fa813b9c103 Mon Sep 17 00:00:00 2001 From: Boris Kaus <61824822+boriskaus@users.noreply.github.com> Date: Tue, 31 Aug 2021 16:00:06 -0700 Subject: [PATCH 52/53] Add porosity waves example --- examples/Project.toml | 1 + examples/porosity_waves.jl | 446 +++++++++++++++++++++++++++++++++++++ 2 files changed, 447 insertions(+) create mode 100644 examples/porosity_waves.jl diff --git a/examples/Project.toml b/examples/Project.toml index 278e352c..34f907d3 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -4,4 +4,5 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" PETSc = "ace2c81b-2b5f-4b1e-a30d-d662738edfe0" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804" UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" diff --git a/examples/porosity_waves.jl b/examples/porosity_waves.jl new file mode 100644 index 00000000..1f5f6cd4 --- /dev/null +++ b/examples/porosity_waves.jl @@ -0,0 +1,446 @@ +# INCLUDE IN MPI TEST +#= +In this example we solve the 1D viscoelastic porosity wave equations which +describe how magma ascends in the Earth's mantle. The equations are discussed +in [Vasyliev et al. Geophysical Research Letters (25), 17. p. +3239-3242](https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/98GL52358): +```math + { ∂ϕ/∂t} = -De {∂Pe/∂t} - ϕ^m Pe + De {∂Pe/∂t} = ∇( ϕ^n (∇Pe + e_x) ) - ϕ^m Pe +``` +with Dirichlet boundary conditions Pe=0 and ϕ=1 on either side. n,m are +parameters and De is the Deborah number which indicates the importance of +elasticity (De>>1). e_x is the unit vector in the direction of gravity (here +taken to be the x-direction) + +To solve the problem we use a standard central, finite difference approximation +in 1D, and simultaneously solve for Pe and ϕ on a collocated grid. We employ a +DMDA/SNES and compute the Jacobian by automatic differentiation. +=# + +using MPI +using PETSc +using OffsetArrays: OffsetArray +using LinearAlgebra: norm +using ForwardDiff +using SparseArrays +using SparseDiffTools + +# when not run interactive options can be passed via commandline arguments: +# julia --project=examples examples/Porosity_Waves.jl -Nq1 101 -snes_monitor +opts = if !isinteractive() + PETSc.parse_options(ARGS) +else + ( + ksp_monitor = false, + ksp_rtol = 1e-10, + ksp_converged_reason = false, + snes_monitor = true, + snes_converged_reason = true, + snes_view = false, + snes_max_it = 100, + snes_max_funcs = 10000, + snes_max_linear_solve_fail = 1000, + snes_mf_operator = false, + Nq1 = 501, + max_it = 4000, + max_time = 25 + ) +end + +# To use plotting either `]add Plots` +CreatePlots = isinteractive() && try + using Plots + true +catch + false +end + +# Set our MPI communicator +comm = MPI.COMM_WORLD + +# Set our PETSc Scalar Type +PetscScalar = Float64 +PetscInt = Int64 + +# get the PETSc lib with our chosen `PetscScalar` type +petsclib = PETSc.getlib(; PetscScalar = PetscScalar, PetscInt = PetscInt) + +# Initialize PETSc +PETSc.initialize(petsclib) + +# dimensionality of the problem +dim = PETSc.typedget(opts, :dim, 1) + +# Set the total number of grid points in each direction +Nq1 = PETSc.typedget(opts, :Nq1, 11) + +Nq = (Nq1, 5, 5) +Nq = Nq[1:dim] + +max_it = PETSc.typedget(opts, :max_it, 10) +max_time = PETSc.typedget(opts, :max_time, 25) + +# Set the boundary conditions on each side (Dirichlet in direction of gravity) +bcs = ( + PETSc.DM_BOUNDARY_NONE, + PETSc.DM_BOUNDARY_GHOSTED, + PETSc.DM_BOUNDARY_GHOSTED, + )[1:dim] + +# Set parameters +n = 3 +m = 2 +De = PetscScalar(1e2) +dt = PetscScalar(1e-2) + +# Create the PETSC dmda object +da = PETSc.DMDA( + petsclib, + comm, + bcs, # boundary conditions + Nq, # Global grid size + 2, # Number of DOF per node + 1, # Stencil width + PETSc.DMDA_STENCIL_STAR; # Stencil type + opts..., +) + +# Set coordinates of the DMDA (2D and 3D ignored for 1D DMDA) +PETSc.setuniformcoordinates!(da, (-20, -10, -10), (150, 10, 10)) + +# Create the PETSC snes object +snes = PETSc.SNES(petsclib, comm; opts...) + +# add the da to the snes +PETSc.setDM!(snes, da) + +# Sets the initial profiles +g_x = PETSc.DMGlobalVec(da) +PETSc.withlocalarray!(g_x; read = false) do l_x + corners = PETSc.getcorners(da) + + x = PETSc.reshapelocalarray(l_x, da) + Phi = @view x[1, :, :, :] + Pe = @view x[2, :, :, :] + + # retrieve arrays with local coordinates + coord = PETSc.getlocalcoordinatearray(da) + + Phi0 = 1 + dPhi1 = 8 + dPhi2 = 1 + z1 = 0 + z2 = 40 + lambda = 1 + dPe1 = dPhi1 / De + dPe2 = dPhi2 / De + + # Loop over all the points on the processor and set the initial condition + for i in ((corners.lower):(corners.upper)) + Phi[i] = + Phi0 + + dPhi1 * exp(-((coord[1, i] - z1)^2) / lambda^2) + + dPhi2 * exp(-((coord[1, i] - z2)^2) / lambda^2) + Pe[i] = + -dPe1 * exp(-((coord[1, i] - z1)^2) / lambda^2) - + dPe2 * exp(-((coord[1, i] - z2)^2) / lambda^2) + end +end + +# Initialize x_old on every processor +g_xold = deepcopy(g_x); # initialize Pe and Phi of last timestep +l_xold = PETSc.DMLocalVec(da) +PETSc.update!(l_xold, g_xold, PETSc.INSERT_VALUES) +x_old = PETSc.unsafe_localarray(l_xold, read = true, write = false) + +# Routine wuth julia-only input/output vectors that computes the local residual +function ComputeLocalResidual!(l_fx, l_x) + + # Compute the local residual. + # The local vectors of l_x/x_old include ghost points + x = PETSc.reshapelocalarray(l_x, da) + Phi = @view x[1, :, :, :] + Pe = @view x[2, :, :, :] + x_old_reshaped = PETSc.reshapelocalarray(x_old, da) + Phi_old = @view x_old_reshaped[1, :, :, :] + Pe_old = @view x_old_reshaped[2, :, :, :] + + # The local residual vectors do not include ghost points + fx = PETSc.reshapelocalarray(l_fx, da) + res_Phi = @view fx[1, :, :, :] + res_Pe = @view fx[2, :, :, :] + + # Global grid size + Nq = PETSc.getinfo(da).global_size + + # Local sizes + corners = PETSc.getcorners(da) + + # set ghost boundaries (flux free conditions) + if Nq[2] > 1 + if corners.lower[2] == 1 + Phi[:, 0, :] = Phi[:, 1, :] + Pe[:, 0, :] = Pe[:, 1, :] + end + if corners.upper[2] == Nq[2] + Phi[:, Nq[2] + 1, :] = Phi[:, Nq[2], :] + Pe[:, Nq[2] + 1, :] = Pe[:, Nq[2], :] + end + end + if Nq[3] > 1 + if corners.lower[3] == 1 + Phi[:, :, 0] = Phi[:, :, 1] + Pe[:, :, 0] = Pe[:, :, 1] + end + if corners.upper[3] == Nq[3] + Phi[:, :, Nq[3] + 1] = Phi[:, :, Nq[3]] + Pe[:, :, Nq[3] + 1] = Pe[:, :, Nq[3]] + end + end + + # Stencil + ix_p1 = CartesianIndex(1, 0, 0) # ix + 1 + ix_m1 = CartesianIndex(-1, 0, 0) # ix - 1 + iy_p1 = CartesianIndex(0, 1, 0) # iy + 1 + iy_m1 = CartesianIndex(0, -1, 0) # iy - 1 + iz_p1 = CartesianIndex(0, 0, 1) # iz + 1 + iz_m1 = CartesianIndex(0, 0, -1) # iz - 1 + + # Coordinates and spacing (assumed constant) + coord = PETSc.getlocalcoordinatearray(da) + Δx = coord[1, corners.lower + ix_p1] - coord[1, corners.lower] + if dim > 1 + Δy = coord[2, corners.lower + iy_p1] - coord[2, corners.lower] + end + if dim == 3 + Δz = coord[1, corners.lower + iz_p1] - coord[1, corners.lower] + end + + # corners.lower + for i in ((corners.lower):(corners.upper)) + if (i[1] == 1 || i[1] == Nq[1]) # Dirichlet upper/lower BC's + res_Phi[i] = Phi[i] - 1 + res_Pe[i] = Pe[i] - 0 + + else # Central points + res_Phi[i] = + (Phi[i] - Phi_old[i]) / dt + + De * (Pe[i] - Pe_old[i]) / dt + + (Phi[i]^m) * Pe[i] + + Phi_c_p1 = (Phi[i + ix_p1] + Phi[i]) / 2 + Phi_c_m1 = (Phi[i + ix_m1] + Phi[i]) / 2 + + res_Pe[i] = + De * (Pe[i] - Pe_old[i]) / dt - + ( + (Phi_c_p1^n) * ((Pe[i + ix_p1] - Pe[i]) / Δx + 1) - + (Phi_c_m1^n) * ((Pe[i] - Pe[i + ix_m1]) / Δx + 1) + ) / Δx + (Phi[i]^m) * Pe[i] + if dim > 1 + # Derivatives in y-direction (for 2D and 3D) + Phi_c_p1 = (Phi[i + iy_p1] + Phi[i]) / 2 + Phi_c_m1 = (Phi[i + iy_m1] + Phi[i]) / 2 + res_Pe[i] = + res_Pe[i] + + ( + (Phi_c_p1^n) * ((Pe[i + iy_p1] - Pe[i]) / Δy) - + (Phi_c_m1^n) * ((Pe[i] - Pe[i + iy_m1]) / Δy) + ) / Δy + end + if dim == 3 + # Derivatives in z-direction (for 3D) + Phi_c_p1 = (Phi[i + iz_p1] + Phi[i]) / 2 + Phi_c_m1 = (Phi[i + iz_m1] + Phi[i]) / 2 + res_Pe[i] = + res_Pe[i] + + ( + (Phi_c_p1^n) * ((Pe[i + iz_p1] - Pe[i]) / Δz) - + (Phi_c_m1^n) * ((Pe[i] - Pe[i + iz_m1]) / Δz) + ) / Δz + end + end + end +end + +# Helper function, for autmatic differentiation +function ForwardDiff_res(x) + fx = similar(x) # vector of zeros, of same type as x (local vector) + + ComputeLocalResidual!(fx, x) + + return fx +end + +# Set up the nonlinear function +r = similar(g_x) +PETSc.setfunction!(snes, r) do g_fx, snes, g_x + # Get the DMDA associated with the snes + da = PETSc.getDMDA(snes) + + # Get a local vector and transfer the data from the global->local vector + l_x = PETSc.DMLocalVec(da) + PETSc.update!(l_x, g_x, PETSc.INSERT_VALUES) + + # Get local arrays + PETSc.withlocalarray!( + (g_fx, l_x); + read = (false, true), + write = (true, false), + ) do fx, x + + # Compute the local residual (using local julia vectors) + ComputeLocalResidual!(fx, x) + end + + # Clean up the local vectors + PETSc.destroy(l_x) + + return 0 +end + +# Compute the sparsity pattern and coloring of the jacobian @ every processor +# Ideally this should be done with an automatic sparsity detection algorithm; +# yet this is currently not working in combination with OffsetArrays (see +# https://github.com/JuliaDiff/SparseDiffTools.jl/issues/154) Therefore, we use +# a less efficient approach here. + +l_x = PETSc.DMLocalVec(da) +input = rand(length(l_x)) +sparsity_pattern = + sparse(abs.(ForwardDiff.jacobian(ForwardDiff_res, input)) .> 0); +jac = Float64.(sparsity_pattern) +colors = matrix_colors(jac) + +# Compute the Jacobian, using automatic differentiation +J = PETSc.MatAIJ(da) # initialize space for the matrix from the dmda +PETSc.setjacobian!(snes, J, J) do J, snes, g_x + # Get the DMDA associated with the snes + da = PETSc.getDMDA(snes) + + # Get a local vector and transfer the data from the global->local vector + l_x = PETSc.DMLocalVec(da) + PETSc.update!(l_x, g_x, PETSc.INSERT_VALUES) + + # Get a local array of the solution vector + PETSc.withlocalarray!((l_x); read = (true), write = (false)) do x_julia + # Note that we need to extract x_old as well, as it is used inside the + # residual routine + + # use ForwardDiff to compute (local part of) jacobian. This is slow, as + # it forms a dense matrix (and therefor commented) + # S = sparse(ForwardDiff.jacobian(ForwardDiff_res, x_julia)); + + # Using SparseDiffTools this is more efficient, but requires + # initializing the sparsity pattern & coloring: + S = forwarddiff_color_jacobian( + ForwardDiff_res, + x_julia, + colorvec = colors, + sparsity = sparsity_pattern, + jac_prototype = jac, + ) + + ind_local = PETSc.localinteriorlinearindex(da) + + S = S[ind_local, ind_local] + + # Copy local sparse matrix to parallel PETSc matrix + copyto!(J, S) + end + + # Assemble the Jacobian matrix + PETSc.assemble!(J) + + # Clean up the local vectors + PETSc.destroy(l_x) + + return 0 +end + +# Timestep loop +time, it = PetscScalar(0), 1; +while (it < max_it && time < max_time) + global time, it, x_old, g_xold, g_x + + # Solve nonlinear system of equations + PETSc.solve!(g_x, snes) + + # Just for checking: compute norm of nonlinear solution + g = similar(g_x) + snes.f!(g, snes, g_x) + nm = norm(g) + if MPI.Comm_rank(comm) == 0 + @show nm + end + + # Update time + time += dt + it += 1 + + # Update the x_old values (Phi_old, Pe_old) on every processor + finalize(x_old) # Free the previous x_old vector + PETSc.update!(l_xold, g_x, PETSc.INSERT_VALUES) # Update + x_old = PETSc.unsafe_localarray(l_xold, read = true, write = false) + + # Visualisation + if (mod(it, 20) == 0 && CreatePlots == true) + coord = PETSc.getlocalcoordinatearray(da) + x = coord[1, :, :, :] + x = x[:,1,1] + time_vec = ones(size(x)) * time + #= + p1 = plot!( + x, + time_vec, + g_x[2:2:end], + zlabel = "Pe", + title = "De=$(De)", + ylabel = "time", + xlabel = "depth", + linecolor = :blue, + legend = :none, + xlims = (-20, 150), + ylims = (0, 25), + zlims = (-1.5, 1.5), + camera = (20, 70), + dpi = 300, + ) # Pe + savefig(p1, "Pe_porositywave") + =# + + p2 = plot!( + x, + time_vec, + g_x[1:2:end], + zlabel = "Phi", + title = "De=$(De)", + ylabel = "time", + xlabel = "depth", + linecolor = :blue, + legend = :none, + xlims = (-20, 150), + ylims = (0, 25), + zlims = (0, 2), + #zlims = (0, 5), + camera = (20, 82), + dpi = 300, + ) # Pe + savefig(p2, "Phi_porositywave") + end + if MPI.Comm_rank(comm) == 0 + println("Timestep $it, time=$time") + end +end + +# Do some clean up + +PETSc.destroy(J) +PETSc.destroy(g_x) +finalize(x_old); +PETSc.destroy(r) +PETSc.destroy(snes) +PETSc.destroy(da) + +PETSc.finalize(petsclib) From 581f37990b6e54fd31cf2bec8e938d51a73dbc92 Mon Sep 17 00:00:00 2001 From: Jeremy E Kozdon Date: Fri, 3 Sep 2021 09:49:14 -0700 Subject: [PATCH 53/53] Fix viewer for long output on stdout --- src/viewer.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/viewer.jl b/src/viewer.jl index c3792fac..74837beb 100644 --- a/src/viewer.jl +++ b/src/viewer.jl @@ -3,20 +3,20 @@ # based on suggestion from https://github.com/JuliaLang/julia/issues/32567 function _show(io::IO, obj) old_stdout = stdout + rd, = redirect_stdout() + # to prevent the pipe from filling up + # based on + # https://github.com/JuliaDocs/IOCapture.jl/blob/d8b27045cec8953e0e5a8d719ca1692b3a6d0d02/src/IOCapture.jl#L107-L108 + task = @async write(io, rd) try - rd, = redirect_stdout() view(obj) - # Since not all MPI ranks are guaranteed to print we put in a newline - # that we remove with the write since readavailable will hang if there - # is no data in the stream - println() - Libc.flush_cstdio() flush(stdout) - write(io, readavailable(rd)[1:(end - 1)]) finally + close(rd) redirect_stdout(old_stdout) + wait(task) end return nothing end