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

Restore schur methods #102

Merged
merged 2 commits into from
Aug 24, 2022
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
27 changes: 1 addition & 26 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,23 @@ name: Documentation
on:
push:
branches:
- master
- main
tags: '*'
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install MUMPS from Homebrew
id: set-up-mumps
run: |
brew tap brewsci/num
brew tap dpo/mumps-jl
brew install gcc openblas cmake
brew install mpich-mumps
echo "$(brew --prefix)/bin" >> $GITHUB_PATH
echo "::set-output name=prefix::$(brew --prefix)"
echo "::set-output name=gfortran::$(which gfortran)"
echo "::set-output name=mpif90::$(which mpif90)"
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: '1'
arch: x64
- name: Install dependencies
run: julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(); Pkg.build("MUMPS")'
env:
MUMPS_PREFIX: "${{steps.set-up-mumps.outputs.prefix}}/opt/mpich-mumps"
SCALAPACK_PREFIX: "${{steps.set-up-mumps.outputs.prefix}}/opt/mpich-scalapack"
JULIA_MPI_PATH: "${{steps.set-up-mumps.outputs.prefix}}/opt/mpich"
JULIA_MPI_Fortran_COMPILER: "${{steps.set-up-mumps.outputs.mpif90}}"
FC: "${{steps.set-up-mumps.outputs.prefix}}/opt/gcc/bin/gfortran"
- name: Build and deploy
run: julia --project=docs --color=yes docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
MUMPS_PREFIX: "${{steps.set-up-mumps.outputs.prefix}}/opt/mpich-mumps"
SCALAPACK_PREFIX: "${{steps.set-up-mumps.outputs.prefix}}/opt/mpich-scalapack"
JULIA_MPI_PATH: "${{steps.set-up-mumps.outputs.prefix}}/opt/mpich"
JULIA_MPI_Fortran_COMPILER: "${{steps.set-up-mumps.outputs.mpif90}}"
FC: "${{steps.set-up-mumps.outputs.prefix}}/opt/gcc/bin/gfortran"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI
on:
push:
branches:
- master
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
Expand Down
2 changes: 1 addition & 1 deletion src/MUMPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This mode of operation gives the user complete control as described
in the MUMPS manual, though it exposes unsafe operations, so beware.

More convenient are the use of the functions [`mumps_solve`](@ref), [`mumps_factorize`](@ref),
[`mumps_det`](@ref), [`mumps_schur`](@ref), and [`mumps_select_inv`](@ref), which all have
[`mumps_det`](@ref), [`mumps_schur_complement`](@ref), and [`mumps_select_inv`](@ref), which all have
mutating counterparts (such as [`mumps_solve!`](@ref)). These can take matrices
and right hand sides directly, so, for example, the equation `A*x=y`, solved
in Base by `x=A\\y` or `LinearAlbegra.ldiv!(x,A,y)`, can be solved with MUMPS
Expand Down
26 changes: 13 additions & 13 deletions src/convenience.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,17 @@ function mumps_det(A)
end

"""
mumps_schur!(mumps, schur_inds)
mumps_schur!(mumps, x)
mumps_schur_complement!(mumps, schur_inds)
mumps_schur_complement!(mumps, x)

`schur_inds` is integer array of Schur indices.
If `x` is sparse, Schur indices determined from populated rows of `x`

See also: [`mumps_schur`](@ref), [`get_schur!`](@ref), [`get_schur`](@ref)
See also: [`mumps_schur_complement`](@ref), [`get_schur_complement!`](@ref), [`get_schur_complement`](@ref)
"""
function mumps_schur! end
function mumps_schur_complement! end

function mumps_schur!(mumps::Mumps, schur_inds::AbstractArray{Int, 1})
function mumps_schur_complement!(mumps::Mumps, schur_inds::AbstractArray{Int, 1})
set_schur_centralized_by_column!(mumps, schur_inds)
if mumps.job ∈ [1] # if analyzed only, factorize
mumps.job = 2
Expand All @@ -190,26 +190,26 @@ function mumps_schur!(mumps::Mumps, schur_inds::AbstractArray{Int, 1})
invoke_mumps!(mumps)
end

mumps_schur!(mumps::Mumps, x::SparseMatrixCSC) = mumps_schur!(mumps, unique!(sort(x.rowval)))
mumps_schur_complement!(mumps::Mumps, x::SparseMatrixCSC) = mumps_schur_complement!(mumps, unique!(sort(x.rowval)))

mumps_schur!(mumps::Mumps, x::SparseVector) = mumps_schur!(mumps, x.nzind)
mumps_schur_complement!(mumps::Mumps, x::SparseVector) = mumps_schur_complement!(mumps, x.nzind)

"""
mumps_schur(A,schur_inds) -> S
mumps_schur(A,x) -> S
mumps_schur_complement(A,schur_inds) -> S
mumps_schur_complement(A,x) -> S

`schur_inds` is integer array
`x` is sparse, populated rows are Schur indices
`S` is Schur complement matrix.

See also: [`mumps_schur!`](@ref)
See also: [`mumps_schur_complement!`](@ref)
"""
function mumps_schur(A::AbstractArray, x)
function mumps_schur_complement(A::AbstractArray, x)
mumps = Mumps(A)
suppress_display!(mumps)
set_icntl!(mumps, 8, 0) # turn scaling off, not used with schur anyway (suppresses warning message with schur)
mumps_schur!(mumps, x)
S = get_schur(mumps)
mumps_schur_complement!(mumps, x)
S = get_schur_complement(mumps)
finalize!(mumps)
return S
end
Expand Down
20 changes: 10 additions & 10 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,34 +350,34 @@ function get_sol(mumps::Mumps{T}) where {T}
end

"""
get_schur!(S,mumps)
get_schur_complement!(S,mumps)

Retrieve Schur complement matrix from `mumps` into pre-allocated `S`

See also: [`get_schur`](@ref), [`mumps_schur!`](@ref), [`mumps_schur`](@ref)
See also: [`get_schur_complement`](@ref), [`mumps_schur_complement!`](@ref), [`mumps_schur_complement`](@ref)
"""
function get_schur!(S, mumps::Mumps)
function get_schur_complement!(S, mumps::Mumps)
has_schur(mumps) || throw(MUMPSException("schur complement not yet allocated."))
get_schur_unsafe!(S, mumps)
get_schur_complement_unsafe!(S, mumps)
end

function get_schur_unsafe!(S, mumps::Mumps)
function get_schur_complement_unsafe!(S, mumps::Mumps)
for i ∈ LinearIndices(S)
S[i] = unsafe_load(mumps.schur, i)
end
return S
end

"""
get_schur(mumps) -> S
get_schur_complement(mumps) -> S

Retrieve Schur complement matrix `S` from `mumps`

See also: [`get_schur!`](@ref), [`mumps_schur!`](@ref), [`mumps_schur`](@ref)
See also: [`get_schur_complement!`](@ref), [`mumps_schur_complement!`](@ref), [`mumps_schur_complement`](@ref)
"""
function get_schur(mumps::Mumps{T}) where {T}
function get_schur_complement(mumps::Mumps{T}) where {T}
S = Array{T}(undef, mumps.size_schur, mumps.size_schur)
get_schur!(S, mumps)
get_schur_complement!(S, mumps)
end

"""
Expand All @@ -386,7 +386,7 @@ end
Set up Schur complement matrix calculation for the "centralized by column"
method suggested in the MUMPS manual

See also: [`mumps_schur!`](@ref), [`mumps_schur`](@ref)
See also: [`mumps_schur_complement!`](@ref), [`mumps_schur_complement`](@ref)
"""
function set_schur_centralized_by_column!(mumps::Mumps{T}, schur_inds::AbstractArray{Int}) where {T}
mumps.size_schur = length(schur_inds)
Expand Down