Skip to content

Commit 6daeb96

Browse files
authored
Merge pull request #109 from gridap/gridap-0.19
Gridap 0.19
2 parents e9e9e36 + 8f484c7 commit 6daeb96

25 files changed

+250
-182
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/" # Location of package manifests
6+
schedule:
7+
interval: "monthly"

.github/workflows/ci.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,34 @@ jobs:
88
fail-fast: false
99
matrix:
1010
version:
11-
- '1.9'
11+
- '1.10'
1212
os:
1313
- ubuntu-latest
1414
arch:
1515
- x64
1616
steps:
17-
- uses: actions/checkout@v2
18-
- uses: julia-actions/setup-julia@v1
17+
- uses: actions/checkout@v4
18+
- uses: julia-actions/setup-julia@v2
1919
with:
2020
version: ${{ matrix.version }}
2121
arch: ${{ matrix.arch }}
22-
- uses: actions/cache@v1
23-
env:
24-
cache-name: cache-artifacts
25-
with:
26-
path: ~/.julia/artifacts
27-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
28-
restore-keys: |
29-
${{ runner.os }}-test-${{ env.cache-name }}-
30-
${{ runner.os }}-test-
31-
${{ runner.os }}-
22+
- uses: julia-actions/cache@v2
3223
- uses: julia-actions/julia-buildpkg@v1
3324
- uses: julia-actions/julia-runtest@v1
3425
- uses: julia-actions/julia-processcoverage@v1
35-
- uses: codecov/codecov-action@v1
26+
- uses: codecov/codecov-action@v5
3627
with:
3728
file: lcov.info
29+
verbose: true
30+
token: ${{ secrets.CODECOV_TOKEN }}
3831
docs:
3932
name: Documentation
4033
runs-on: ubuntu-latest
4134
steps:
42-
- uses: actions/checkout@v2
43-
- uses: julia-actions/setup-julia@v1
35+
- uses: actions/checkout@v4
36+
- uses: julia-actions/setup-julia@v2
4437
with:
45-
version: '1.9'
38+
version: '1.10'
4639
- run: |
4740
julia --project=docs -e '
4841
using Pkg

.github/workflows/ci_extra.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,34 @@ name: CI_EXTRA
22
on: [push, pull_request]
33
jobs:
44
test:
5-
name: Tests ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
5+
name: Tests ${{ matrix.version }} - PETSc v${{ matrix.petsc_version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
66
runs-on: ${{ matrix.os }}
77
env:
88
JULIA_MPI_BINARY: "system"
9-
JULIA_PETSC_LIBRARY: "/opt/petsc/3.15.4/lib/libpetsc"
9+
JULIA_PETSC_LIBRARY: "/opt/petsc/${{ matrix.petsc_version }}/lib/libpetsc"
1010
strategy:
1111
fail-fast: false
1212
matrix:
1313
version:
14-
- '1.9'
14+
- '1.10'
1515
os:
1616
- ubuntu-latest
1717
arch:
1818
- x64
19+
petsc_version:
20+
- '3.23.0'
1921
steps:
20-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2123
- name: Cache petsc
2224
id: cache-petsc
23-
uses: actions/cache@v2
25+
uses: actions/cache@v4
2426
with:
2527
path: ${{env.JULIA_PETSC_LIBRARY}}
2628
key: ${{ runner.os }}-build-${{ env.JULIA_PETSC_LIBRARY }}-
2729
restore-keys: |
2830
${{ runner.os }}-build-${{ env.JULIA_PETSC_LIBRARY }}-
2931
${{ runner.os }}-build-
3032
${{ runner.os }}-
31-
- uses: julia-actions/setup-julia@v1
32-
with:
33-
version: ${{ matrix.version }}
34-
arch: ${{ matrix.arch }}
3533
- name: Install petsc dependencies
3634
run: |
3735
sudo apt-get update
@@ -41,7 +39,7 @@ jobs:
4139
run: |
4240
CURR_DIR=$(pwd)
4341
PACKAGE=petsc
44-
VERSION=3.15.4
42+
VERSION=${{ matrix.petsc_version }}
4543
INSTALL_ROOT=/opt
4644
PETSC_INSTALL=$INSTALL_ROOT/$PACKAGE/$VERSION
4745
TAR_FILE=$PACKAGE-$VERSION.tar.gz
@@ -59,16 +57,18 @@ jobs:
5957
--with-mpi=1 --with-64-bit-indices
6058
make
6159
make install
62-
- name: add MPIPreferences
60+
- uses: julia-actions/setup-julia@v2
61+
with:
62+
version: ${{ matrix.version }}
63+
arch: ${{ matrix.arch }}
64+
- name: Set system MPI with MPIPreferences
6365
shell: julia --color=yes --project=. {0}
6466
run: |
6567
using Pkg
6668
Pkg.add("MPIPreferences")
67-
- name: use MPI system binary
68-
shell: julia --color=yes --project=. {0}
69-
run: |
7069
using MPIPreferences
7170
MPIPreferences.use_system_binary()
72-
- run: julia --project=. -e 'using Pkg; Pkg.instantiate(); Pkg.build(); Pkg.precompile()'
71+
- uses: julia-actions/julia-buildpkg@v1
72+
- run: julia --project=. --color=yes --check-bounds=yes test/serial/runtests.jl
7373
- run: julia --project=. --color=yes --check-bounds=yes test/sequential/runtests.jl
7474
- run: julia --project=. --color=yes --check-bounds=yes test/mpi/runtests.jl

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GridapPETSc"
22
uuid = "bcdc36c2-0c3e-11ea-095a-c9dadae499f1"
33
authors = ["Francesc Verdugo <fverdugo@cimne.upc.edu>", "Víctor Sande <vsande@cimne.upc.edu>", "Alberto F. Martin <alberto.martin@monash.edu>"]
4-
version = "0.5.3"
4+
version = "0.5.4"
55

66
[deps]
77
Gridap = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e"
@@ -16,10 +16,10 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1616
SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
1717

1818
[compat]
19-
Gridap = "0.17, 0.18"
19+
Gridap = "0.17, 0.18, 0.19"
2020
GridapDistributed = "0.3, 0.4"
2121
MPI = "0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20"
22-
PETSc_jll = "=3.13.4, =3.15.2"
22+
PETSc_jll = "3"
2323
PartitionedArrays = "0.3"
2424
SparseMatricesCSR = "0.6.6"
2525
julia = "1.3"

src/PETScArrays.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,13 @@ function Base.copy(a::PETScMatrix)
306306
Init(v)
307307
end
308308

309+
function Base.copy!(a::PETScMatrix,b::PETScMatrix)
310+
if a !== b
311+
@check_error_code PETSC.MatCopy(b.mat[],a.mat[],PETSC.SAME_NONZERO_PATTERN)
312+
end
313+
a
314+
end
315+
309316
function Base.copy!(a::PETScMatrix,b::AbstractMatrix)
310317
_copy!(a.mat[],b)
311318
end

src/PETScLinearSolvers.jl

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,47 +61,69 @@ end
6161

6262
function Algebra.solve!(x::PETScVector,ns::PETScLinearSolverNS,b::PETScVector)
6363
@check_error_code PETSC.KSPSolve(ns.ksp[],b.vec[],x.vec[])
64-
x
64+
return x
6565
end
6666

6767
function Algebra.solve!(x::PETScVector,ns::PETScLinearSolverNS,b::AbstractVector)
68-
if (x.comm != MPI.COMM_SELF)
69-
gridap_petsc_gc() # Do garbage collection of PETSc objects
70-
end
68+
# Jordi: Somehow, I think this destroys PETSc objects that are
69+
# still in use. This then leads to a PETSc error 62 when calling KSPSolve.
70+
# Instead, I have added GridapPETSc.Finalize(...) calls for the specific PETSc
71+
# objects that we are creating internally.
72+
#
73+
# if (x.comm != MPI.COMM_SELF)
74+
# gridap_petsc_gc() # Do garbage collection of PETSc objects
75+
# end
7176

7277
B = convert(PETScVector,b)
7378
solve!(x,ns,B)
74-
x
79+
GridapPETSc.Finalize(B)
80+
return x
7581
end
7682

77-
function Algebra.solve!(x::Vector{PetscScalar},ns::PETScLinearSolverNS,b::AbstractVector)
83+
function Algebra.solve!(x::AbstractVector,ns::PETScLinearSolverNS,b::AbstractVector)
7884
X = convert(PETScVector,x)
7985
solve!(X,ns,b)
80-
x
86+
copy!(x,X)
87+
GridapPETSc.Finalize(X)
88+
return x
8189
end
8290

83-
function Algebra.solve!(x::AbstractVector,ns::PETScLinearSolverNS,b::AbstractVector)
84-
X = convert(Vector{PetscScalar},x)
91+
# When x is a Vector{PetscScalar}, the memory is aliased with the PETSc Vec object, i.e
92+
# we do not need to copy the data back into x.
93+
function Algebra.solve!(x::Vector{PetscScalar},ns::PETScLinearSolverNS,b::AbstractVector)
94+
X = convert(PETScVector,x)
8595
solve!(X,ns,b)
86-
x .= X
87-
x
96+
return x
8897
end
8998

99+
# In the case of PVectors, we need to ensure that ghost layouts match. In the case they
100+
# do not, we have to create a new vector and copy (which is less efficient, but necessary).
90101
function Algebra.solve!(x::PVector,ns::PETScLinearSolverNS,b::PVector)
91-
X = similar(b,(axes(ns.A)[2],))
92-
B = similar(b,(axes(ns.A)[2],))
93-
copy!(X,x)
94-
copy!(B,b)
95-
Y = convert(PETScVector,X)
96-
solve!(Y,ns,B)
97-
copy!(x,Y)
98-
x
102+
rows, cols = axes(ns.A)
103+
if partition(axes(x,1)) !== partition(cols)
104+
y = pzeros(PetscScalar,partition(cols))
105+
copy!(y,x)
106+
else
107+
y = x
108+
end
109+
if partition(axes(b,1)) !== partition(rows)
110+
c = pzeros(PetscScalar,partition(rows))
111+
copy!(c,b)
112+
else
113+
c = b
114+
end
115+
116+
X = convert(PETScVector,y)
117+
solve!(X,ns,c)
118+
copy!(x,X)
119+
GridapPETSc.Finalize(X)
120+
return x
99121
end
100122

101123
function Algebra.numerical_setup!(ns::PETScLinearSolverNS,A::AbstractMatrix)
102124
ns.A = A
103125
ns.B = convert(PETScMatrix,A)
104126
@check_error_code PETSC.KSPSetOperators(ns.ksp[],ns.B.mat[],ns.B.mat[])
105127
@check_error_code PETSC.KSPSetUp(ns.ksp[])
106-
ns
128+
return ns
107129
end

0 commit comments

Comments
 (0)