-
Notifications
You must be signed in to change notification settings - Fork 9
/
GridapPETSc.jl
92 lines (68 loc) · 1.88 KB
/
GridapPETSc.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
module GridapPETSc
using MPI
using Libdl
using Gridap.Helpers
using Gridap.Algebra
using Gridap.Arrays
using LinearAlgebra
using SparseArrays
using SparseMatricesCSR
using PartitionedArrays
let deps_jl = joinpath(@__DIR__,"..","deps","deps.jl")
if !isfile(deps_jl)
msg = """
GridapPETSc needs to be configured before use. Type
pkg> build
and try again.
"""
error(msg)
end
include(deps_jl)
end
if !libpetsc_found
msg = """
GridapPETSc was not configured correcnly. See the errors in file:
$(joinpath(@__DIR__,"..","deps","build.log"))
If you are using the environment variable JULIA_PETSC_LIBRARY, make sure
that it points to a correct PETSc dynamic library object.
Solve the issue and
pkg> build
again.
"""
end
@static if libpetsc_provider != "JULIA_PETSC_LIBRARY"
using PETSc_jll
end
const libpetsc_handle = Ref{Ptr{Cvoid}}()
const _PRELOADS = Tuple{Ref{Ptr{Cvoid}},Symbol}[]
function __init__()
if libpetsc_provider == "JULIA_PETSC_LIBRARY"
flags = Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND | Libdl.RTLD_GLOBAL
libpetsc_handle[] = Libdl.dlopen(libpetsc_path, flags)
else
libpetsc_handle[] = PETSc_jll.libpetsc_handle
end
for (handle,sym) in _PRELOADS
handle[] = Libdl.dlsym(libpetsc_handle[],sym)
end
end
include("PETSC.jl")
using GridapPETSc.PETSC: @check_error_code
using GridapPETSc.PETSC: PetscBool, PetscInt, PetscScalar, Vec, Mat, KSP, PC, SNES
#export PETSC
export @check_error_code
export PetscBool, PetscInt, PetscScalar, Vec, Mat, KSP, PC
include("Environment.jl")
export PETScVector
export get_local_oh_vector
export get_local_vector, restore_local_vector!
export PETScMatrix
export petsc_sparse
include("PETScArrays.jl")
include("PartitionedArrays.jl")
export PETScLinearSolver
include("PETScLinearSolvers.jl")
export PETScNonlinearSolver
include("PETScNonlinearSolvers.jl")
include("PETScAssembly.jl")
end # module