Skip to content

Commit 590c1ea

Browse files
committed
fix precompilation
1 parent d1a578f commit 590c1ea

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

src/Commons/SolverOptions.jl

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using Gridap
33
using GridapDistributed
44
using GridapPETSc
55
using GridapPETSc.PETSC
6+
using PartitionedArrays
67

78
using Gridap.Algebra
89
using MPI
@@ -49,6 +50,14 @@ function petsc_options_airfoil()
4950
-pres_ksp_type cg -pres_pc_type gamg -pres_ksp_rtol 1.e-2 -pres_ksp_converged_reason -ksp_atol 0.0"
5051
end
5152

53+
54+
# Wrap the VMS NumericalSetup to allow specialized methods that omit
55+
# garbage collection at every time step.
56+
struct VMSPETScNS{T} <: NumericalSetup
57+
ns::PETScLinearSolverNS{T}
58+
end
59+
60+
5261
"""
5362
create_PETSc_setup(M::AbstractMatrix,ksp_setup::Function)
5463
@@ -59,32 +68,45 @@ function create_PETSc_setup(M::AbstractMatrix,ksp_setup::Function)
5968
ss = symbolic_setup(solver, M)
6069
ns = numerical_setup(ss, M)
6170
# @check_error_code GridapPETSc.PETSC.KSPView(ns.ksp[],C_NULL)
62-
return ns
71+
return VMSPETScNS(ns)
6372
end
6473

65-
function Algebra.numerical_setup!(ns::PETScLinearSolverNS,A::AbstractMatrix)
74+
function Algebra.numerical_setup!(vmsns::VMSPETScNS,A::AbstractMatrix)
75+
ns = vmsns.ns
6676
ns.A = A
6777
println("convert")
6878
@time ns.B = convert(PETScMatrix,A)
6979
@check_error_code PETSC.KSPSetOperators(ns.ksp[],ns.B.mat[],ns.B.mat[])
7080

7181
# @time @check_error_code PETSC.KSPSetUp(ns.ksp[])
72-
ns
82+
return ns
7383
end
7484

75-
function Algebra.solve!(x::PETScVector,ns::PETScLinearSolverNS,b::AbstractVector)
85+
function Algebra.solve!(x::PartitionedArrays.PVector,vmsns::VMSPETScNS,b::PartitionedArrays.PVector)
86+
ns = vmsns.ns
87+
X = similar(b,(axes(ns.A)[2],))
88+
B = similar(b,(axes(ns.A)[2],))
89+
copy!(X,x)
90+
copy!(B,b)
91+
Y = convert(PETScVector,X)
92+
solve!(Y,vmsns,B)
93+
copy!(x,Y)
94+
x
95+
end
7696

97+
function Algebra.solve!(x::PETScVector,vmsns::VMSPETScNS,b::AbstractVector)
7798
# if MPI.Initialized()
7899
# if petsc_gc && (x.comm != MPI.COMM_SELF)
79100
# # gridap_petsc_gc() # Do garbage collection of PETSc objects
80101
# end
81102
# end
82103

104+
ns = vmsns.ns
105+
83106
B = convert(PETScVector,b)
84107
solve!(x,ns,B)
85108
x
109+
return x
86110
end
87111

88-
89-
90112
end

src/SegregatedVMSSolver.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module SegregatedVMSSolver
22

3-
__precompile__(false)
3+
# __precompile__(false)
44

55
include(joinpath("Commons","SolverOptions.jl"))
66
include(joinpath("Commons","Interfaces.jl"))

0 commit comments

Comments
 (0)