Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added petscviews for KSP and PC, added BCGS test for KSP #40

Merged
merged 1 commit into from
Dec 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/ksp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# common options: Orthogonilization type, KSP type, PC type
# use PC context created as part of KSP

export KSP
export KSP, petscview

###########################################################################

Expand All @@ -22,6 +22,11 @@ function KSPDestroy{T}(o::KSP{T})
PetscFinalized(T) || C.KSPDestroy(Ref(o.p))
end

function petscview{T}(o::KSP{T})
viewer = C.PetscViewer{T}(C_NULL)
chk(C.KSPView(o.p, viewer))
end

"""
KSP(A::Mat, PA=A; kws...)
KSP(pc::PC; kws...)
Expand Down
7 changes: 6 additions & 1 deletion src/pc.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export PC
export PC, petscview

# preconditioner context
type PC{T}
Expand All @@ -16,6 +16,11 @@ function PCDestroy{T}(o::PC{T})
PetscFinalized(T) || C.PCDestroy(Ref(o.p))
end

function petscview{T}(o::PC{T})
viewer = C.PetscViewer{T}(C_NULL)
chk(C.PCView(o.p, viewer))
end

"""
PC(A::Mat, PA=A, kws...)

Expand Down
22 changes: 19 additions & 3 deletions test/ksp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ facts("\nTesting KSP") do
b[3] = RC(Complex(1,1))
b_julia[3] = RC(Complex(1,1))

ksp = PETSc.KSP(A, ksp_monitor="")
kspg = PETSc.KSP(A, ksp_monitor="")

println("performing ksp solve")
x = ksp\b
println("performing ksp GMRES solve")
x = kspg\b
println("finished ksp solve")
x_julia = A_julia\b_julia

Expand All @@ -32,4 +32,20 @@ facts("\nTesting KSP") do
println("A = ", A)
println("b = ", b)
println(" x = ", x)
println("ksp info:\n",petscview(kspg))

kspb = PETSc.KSP(A, ksp_type="bcgs", ksp_monitor="")
println("performing ksp BCGS solve")
x = kspb\b
println("finished ksp solve")
x_julia = A_julia\b_julia

for i=1:3
@fact x[i] --> roughly(x_julia[i])
end

println("A = ", A)
println("b = ", b)
println(" x = ", x)
println("ksp info:\n",petscview(kspb))
end