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

Update to gridap v0.15.1 #23

Merged
merged 23 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
11136ad
Update README.md
ericneiva Feb 17, 2021
d433db0
Updated to Gridap 0.15
ericneiva Feb 17, 2021
6bf3040
Switching to GH Actions
ericneiva Feb 17, 2021
e66524b
Install dependencies
ericneiva Feb 17, 2021
4f7f067
Fixing install dependencies command
ericneiva Feb 17, 2021
fd72772
Fixing install deps command
ericneiva Feb 17, 2021
54634f4
Fixed wrong openmpi package name
ericneiva Feb 17, 2021
49a30d1
Debian petsc-dev is version 3.7.7
ericneiva Feb 17, 2021
0444307
Add environment variable to build MPI.jl
ericneiva Feb 17, 2021
02a0002
Do not rely on PetscDataType enum constants, they differ across 3.X v…
ericneiva Feb 17, 2021
d5063e1
Build package to generate Docs
ericneiva Feb 17, 2021
21cc259
Update README.md
ericneiva Feb 17, 2021
19f8e92
Downgrade CI tests to Ubuntu 18.04
ericneiva Feb 18, 2021
f7c0585
Install missing lib to pass tests in Ubuntu 20.04
ericneiva Feb 18, 2021
beb7433
Revert "Install missing lib to pass tests in Ubuntu 20.04"
ericneiva Feb 18, 2021
cd73c31
Revert "Downgrade CI tests to Ubuntu 18.04"
ericneiva Feb 18, 2021
f96d989
Support to use GAMG on SeqAIJ matrices
ericneiva Feb 18, 2021
3bbcc5b
Implemented PETSc_get_number_of_iterations
ericneiva Feb 22, 2021
9353cb4
Downgrade CI tests to Ubuntu 18.04
ericneiva Feb 18, 2021
819d48c
test ci_x86 on push
ericneiva Mar 2, 2021
9a5e329
Tell Ci_X86 workflow where mpi is
ericneiva Mar 2, 2021
1589007
Try different MPI lib for Ubuntu 20
ericneiva Mar 2, 2021
178bba8
delete ci_x86.yml workflow
ericneiva Mar 2, 2021
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
3 changes: 1 addition & 2 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: CompatHelper

on:
schedule:
- cron: '00 00 * * *'

workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI
on: [push, pull_request]
jobs:
test:
name: Tests ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.5'
os:
- ubuntu-18.04
arch:
- x64
steps:
- name: Install dependencies
run: sudo apt-get update; sudo apt-get install libopenmpi-dev petsc-dev
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
env:
JULIA_MPI_BINARY: system
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1.5'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
Pkg.build()'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
Gridap = "0.8.0, 0.9.0, 0.10, 0.11, 0.12, 0.13"
MPI = "0.10.1, 0.13.1, < 0.14.2"
julia = "1"
Gridap = "0.15"
MPI = "0.14, 0.15, 0.16"
julia = "1.3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
53 changes: 34 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://gridap.github.io/GridapPETSc.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://gridap.github.io/GridapPETSc.jl/dev)
[![Build Status](https://travis-ci.com/gridap/GridapPETSc.jl.svg?branch=master)](https://travis-ci.com/gridap/GridapPETSc.jl)
[![Build Status](https://github.com/gridap/GridapPETSc.jl/workflows/CI/badge.svg?branch=master)](https://github.com/gridap/GridapPETSc.jl/actions?query=workflow%3ACI)
[![Codecov](https://codecov.io/gh/gridap/GridapPETSc.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/gridap/GridapPETSc.jl)

[Gridap](https://github.com/gridap/Gridap.jl) (Grid-based approximation of partial differential equations in Julia) plugin to use PETSC ([Portable, Extensible Toolkit for Scientific Computation](https://www.mcs.anl.gov/petsc/)).
Expand All @@ -12,7 +12,8 @@
```julia
using MPI
using Gridap
using GridapPETSC
using GridapPETSc
using SparseArrays

MPI.Init()
GridapPETSc.Init()
Expand All @@ -32,31 +33,37 @@ MPI.Finalize()
## Usage in a Finite Element computation

```julia
using MPI
using Gridap
using GridapPETSc

tol = 1e-10

MPI.Init()
GridapPETSc.Init()
GridapPETSc.Init(["-ksp_rtol","$tol"])

# Define the FE problem
# -Δu = x*y in (0,1)^3, u = 0 on the boundary.
domain = (0,1,0,1,0,1)
cells = (10,10,10)
model = CartesianDiscreteModel(domain,cells)

model = CartesianDiscreteModel((0,1,0,1,0,1), (10,10,10))
order = 1
V = TestFESpace( model,
ReferenceFE(lagrangian,Float64,order),
conformity=:H1, dirichlet_tags="boundary" )
U = TrialFESpace(V)

V = TestFESpace(reffe=:Lagrangian, order=1, valuetype=Float64,
conformity=:H1, model=model, dirichlet_tags="boundary")
Ω = Triangulation(model)

U = TrialFESpace(V)
degree = 2*order
dΩ = Measure(Ω,degree)

trian = get_triangulation(model)
quad = CellQuadrature(trian,2)
f(x) = x[1]*x[2]

t_Ω = AffineFETerm(
(u,v) -> inner(∇(v),∇(u)),
(v) -> inner(v, (x) -> x[1]*x[2] ),
trian, quad)
a(u,v) = ∫( ∇(v)⋅∇(u) )*dΩ
l(v) = ∫( v*f )*dΩ

op = AffineFEOperator(SparseMatrixCSR{0,PetscReal,PetscInt},U,V,t_Ω)
ass = SparseMatrixAssembler(SparseMatrixCSR{0,PetscReal,PetscInt},U,V)
op = AffineFEOperator(a,l,ass)

ls = PETScSolver()
solver = LinearFESolver(ls)
Expand All @@ -71,7 +78,7 @@ MPI.Finalize()

**GridPETSc** itself is installed when you add and use it into another project.

Please, ensure that your system fulfill the requirements.
Please, ensure that your system fulfills the requirements.

To include into your project form Julia REPL, use the following commands:

Expand All @@ -83,7 +90,7 @@ julia> using GridapPETSc
If, for any reason, you need to manually build the project, write down the following commands in Julia REPL:
```
pkg> add GridapPETSc
pkg> build GridPETSc
pkg> build GridapPETSc
julia> using GridapPETSc
```

Expand All @@ -108,7 +115,7 @@ Basic `PETSc` installation in order to use it from `GridapPETSc` julia package i

```
$ sudo apt-get update
$ sudo apt-get openmpi petsc-dev
$ sudo apt-get install openmpi-bin petsc-dev
```

## Continuous integration
Expand All @@ -126,6 +133,14 @@ addons:
- petsc-dev
```

If your CI process is based on `GitHub Actions` you can add the following block at the beginning of the test steps in the `.github/workflows/ci.yml` file:

```
steps:
- name: Install dependencies
run: sudo apt-get update; sudo apt-get install openmpi-bin petsc-dev
```

## Notes

`GridapPETSc` default sparse matrix format is 0-based compressed sparse row. This types of sparse matrix can be described by `SparseMatrixCSR{0,PetscReal,PetscInt}` and `SymSparseMatrixCSR{0,PetscReal,PetscInt}`.These types of matrix are implemented in the [SparseMatricesCSR](https://gridap.github.io/SparseMatricesCSR.jl/stable/)) julia package.
19 changes: 10 additions & 9 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ PETSC_SCALAR_DATATYPE = Float64
PETSC_REAL_DATATYPE = Float64
PETSC_INT_DATATYPE = Int32


# Check PETSC_DIR exists
if isdir(PETSC_DIR)
@info "PETSc directory found at: $PETSC_DIR"
Expand Down Expand Up @@ -73,7 +72,7 @@ if isdir(PETSC_DIR)
Cint,
(Cstring,
Ptr{Cint},
Ptr{UInt32}),
Ptr{UInt32}),
name, ptype, found)
return ptype[1], convert(Bool, found[1])
end
Expand All @@ -84,24 +83,27 @@ if isdir(PETSC_DIR)
ccall( (:PetscDataTypeGetSize, PETSC),
Cint,
(Cint,
Ptr{Csize_t}),
Ptr{Csize_t}),
dtype, datasize)
return datasize[1]
end

# Define types that depend on the options PETSc was compiled with
(petsc_real_data_type, found_real) = PetscDataTypeFromString("Real")
(petsc_real_data_type, found_real) = PetscDataTypeFromString("Real")
(petsc_scalar_data_type, found_scalar) = PetscDataTypeFromString("Scalar")
petsc_int_size = PetscDataTypeGetSize(PETSC_INT)
(petsc_int_data_type, found_int) = PetscDataTypeFromString("Int")

petsc_real_size = PetscDataTypeGetSize(petsc_real_data_type)
petsc_int_size = PetscDataTypeGetSize(petsc_int_data_type)

@assert(found_real & found_scalar)
@assert(found_real & found_scalar & found_int)

petsc_scalar_data_type != petsc_real_data_type && throw(ErrorException("[ERROR] Only Real PetscScalar type is supported"))

# Figure out equivalent Julia types for PETSc
if petsc_real_data_type == PETSC_DOUBLE
if petsc_real_size == 8
PETSC_SCALAR_DATATYPE = PETSC_REAL_DATATYPE = Float64
elseif petsc_real_data_type == PETSC_FLOAT
elseif petsc_real_size == 4
PETSC_SCALAR_DATATYPE = PETSC_REAL_DATATYPE = Float32
else
@warn "Unknown type of Real. Petsc real data type is $petsc_real_data_type"
Expand Down Expand Up @@ -161,4 +163,3 @@ PETSc configuration:
- PETSC_REAL_DATATYPE = $PETSC_REAL_DATATYPE
- PETSC_INT_DATATYPE = $PETSC_INT_DATATYPE
"""

29 changes: 3 additions & 26 deletions src/GridapPETSc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,18 @@ import Gridap.Algebra: symbolic_setup, SymbolicSetup
import Gridap.Algebra: numerical_setup, numerical_setup!, NumericalSetup
import Gridap.Algebra: solve, solve!

# Supported PETSc data types
# Supported PETSc data types
export PetscInt
export PetscReal
export PetscScalar

# Mat
#export MatCreateSeqBAIJWithArrays!
#export MatCreateSeqBAIJWithArrays
#export MatCreateSeqSBAIJWithArrays!
#export MatCreateSeqSBAIJWithArrays
#export MatDestroy!
#export MatView

# Vec
#export VecCreateSeqWithArray!
#export VecCreateSeqWithArray
#export VecDestroy!
#export VecView

# KSP
#export KSPCreate!
#export KSPCreate
#export KSPSetOperators!
#export KSPSolve!
#export KSPSolveTranspose!
#export KSPDestroy!

# GridapPETSc datatypes
#export PetscMat
#export PetscVec
#export PetscKSP
export PETScSolver
export PETScSymbolicSetup
export PETScNumericalSetup

export PETSc_get_number_of_iterations

include("load.jl")
include("const.jl")
include("init.jl")
Expand Down
Loading