diff --git a/src/PETScLinearSolvers.jl b/src/PETScLinearSolvers.jl index b79b007..babc0c9 100644 --- a/src/PETScLinearSolvers.jl +++ b/src/PETScLinearSolvers.jl @@ -83,7 +83,7 @@ function Algebra.solve!(x::PVector,ns::PETScLinearSolverNS,b::PVector) copy!(X,x) Y = convert(PETScVector,X) solve!(Y,ns,b) - _copy_and_exchange!(x,Y) + copy!(x,Y) end diff --git a/src/PETScNonlinearSolvers.jl b/src/PETScNonlinearSolvers.jl index 838ee3f..dc3d1b1 100644 --- a/src/PETScNonlinearSolvers.jl +++ b/src/PETScNonlinearSolvers.jl @@ -146,22 +146,6 @@ function _setup_cache(x::AbstractVector,nls::PETScNonlinearSolver,op::NonlinearO jac_petsc_mat_A, jac_petsc_mat_A) end -# Helper private functions to implement the solve! methods below. -# It allows to execute the solve! methods below in a serial context, i.e., -# whenever -function _myexchange!(x::AbstractVector) - x -end -function _myexchange!(x::PVector) - exchange!(x) -end - -function _copy_and_exchange!(a::AbstractVector,b::PETScVector) - copy!(a,b.vec[]) - _myexchange!(a) -end - - function Algebra.solve!(x::T, nls::PETScNonlinearSolver, op::NonlinearOperator, @@ -169,7 +153,7 @@ function Algebra.solve!(x::T, @assert cache.op === op @check_error_code PETSC.SNESSolve(cache.snes[],C_NULL,cache.x_petsc.vec[]) - _copy_and_exchange!(x,cache.x_petsc) + copy!(x,cache.x_petsc) cache end @@ -186,6 +170,6 @@ function Algebra.solve!(x::AbstractVector,nls::PETScNonlinearSolver,op::Nonlinea PETSC.SNESSetJacobian(cache.snes[],cache.jac_petsc_mat_A.mat[],cache.jac_petsc_mat_A.mat[],fptr,ctx) @check_error_code PETSC.SNESSolve(cache.snes[],C_NULL,cache.x_petsc.vec[]) - _copy_and_exchange!(x,cache.x_petsc) + copy!(x,cache.x_petsc) cache end