Skip to content

v0.7 upgrade, comments, bugfixes and cleanup #43

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

Merged
merged 37 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f40ac89
v0.7 support, cleanup, comments and bug fixes
mohamed82008 Aug 1, 2018
7078229
neighbour -> directed strong couplings in comments
mohamed82008 Aug 1, 2018
52b8322
v0.6 backward compatibility
mohamed82008 Aug 1, 2018
2b9e314
v0.6 backward compatibility 2
mohamed82008 Aug 1, 2018
26ba084
fix travis
mohamed82008 Aug 1, 2018
22ba11e
fix package name in travis
mohamed82008 Aug 1, 2018
110e1c5
allow failures for v0.7 and nightly
mohamed82008 Aug 1, 2018
87cb134
allow failures 2
mohamed82008 Aug 1, 2018
e812e22
allow failures 3
mohamed82008 Aug 1, 2018
686222c
AMG -> AlgebraicMultigrid
mohamed82008 Aug 2, 2018
ad2be73
fix travis package name
mohamed82008 Aug 2, 2018
9443fe5
jld -> jld2
mohamed82008 Aug 2, 2018
5248060
add JLD2 to test REQUIRE
mohamed82008 Aug 2, 2018
3913da1
disallow failures for v0.7 and nightly
mohamed82008 Aug 2, 2018
8bc5deb
Generalize direct interpol for non-symmetric matrices and edge cases
mohamed82008 Aug 2, 2018
e89a333
use callable structs
mohamed82008 Aug 12, 2018
d193468
jld2 -> jl files
mohamed82008 Aug 12, 2018
aee7c2d
callable Pinv and some inplace
mohamed82008 Aug 12, 2018
cd43348
log only when log is true
mohamed82008 Aug 12, 2018
4d3929f
add preallocation and block support machinery
mohamed82008 Aug 12, 2018
e0b9684
allow preallocating x
mohamed82008 Aug 12, 2018
b70d841
srand -> seed!
mohamed82008 Aug 12, 2018
37d9576
save top residual calculation when preconditioning
mohamed82008 Aug 12, 2018
716973b
pre-alloc all multiplications
mohamed82008 Aug 12, 2018
f67246c
remove FileIO and JLD2 from test REQUIRE
mohamed82008 Aug 12, 2018
f0f22f0
Fix solve and preconditioner API allowing different initializations
mohamed82008 Aug 12, 2018
a495879
remove using FileIO from runtests.jl
mohamed82008 Aug 12, 2018
20948ec
fix v0.6 tests
mohamed82008 Aug 12, 2018
933f9b7
allow failure on nightly
mohamed82008 Aug 12, 2018
ca7ba87
try v1.0 in Travis and fix nightly
mohamed82008 Aug 12, 2018
e15ef16
pre-allocate in Jacobi smoother
mohamed82008 Aug 12, 2018
7ed4c68
block smoothing, remove branches, and parallel Jacobi
mohamed82008 Aug 12, 2018
b519b1c
AbstractVector -> AbstractArray and minor fixes
mohamed82008 Aug 12, 2018
df9db80
fix tests
mohamed82008 Aug 12, 2018
76ac8f1
Make \ call ldiv!
mohamed82008 Aug 15, 2018
c467855
fix v0.6 perf
mohamed82008 Aug 19, 2018
94bd0df
fix type stability of ifelse
mohamed82008 Aug 19, 2018
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
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ os:
- linux
julia:
- 0.6
- 0.7
- 1.0
- nightly
notifications:
email: false
Expand All @@ -14,7 +16,7 @@ git:
## (tests will run but not make your overall status red)
matrix:
allow_failures:
- julia: nightly
- julia: nightly

## uncomment and modify the following lines to manually install system packages
addons:
Expand All @@ -25,10 +27,10 @@ addons:
# - if [ $TRAVIS_OS_NAME = osx ]; then brew install gcc; fi

## uncomment the following lines to override the default test script
#script:
# - julia -e 'Pkg.clone(pwd()); Pkg.build("AMG"); Pkg.test("AMG"; coverage=true)'
script:
- julia -e 'VERSION >= v"0.7-" && using Pkg; Pkg.clone(pwd()); Pkg.build("AlgebraicMultigrid"); Pkg.test("AlgebraicMultigrid"; coverage=true)'
after_success:
# push coverage results to Coveralls
- julia -e 'cd(Pkg.dir("AMG")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
- julia -e 'cd(Pkg.dir("AlgebraicMultigrid")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("AMG")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia -e 'cd(Pkg.dir("AlgebraicMultigrid")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
3 changes: 2 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
julia 0.6
IterativeSolvers 0.4.1
IterativeSolvers 0.6.0
Compat 1.0.0
19 changes: 14 additions & 5 deletions src/AMG.jl → src/AlgebraicMultigrid.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
module AMG
module AlgebraicMultigrid

import IterativeSolvers: gauss_seidel!
using Compat, Compat.LinearAlgebra
using Compat.SparseArrays, Compat.Printf
using Base.Threads

using Compat: rmul!

if VERSION < v"0.7-"
const mul! = A_mul_B!
end

const MT = false
const AMG = AlgebraicMultigrid

include("utils.jl")
export approximate_spectral_radius

include("strength.jl")
export strength_of_connection, Classical, SymmetricStrength
export Classical, SymmetricStrength

include("splitting.jl")
export split_nodes, RS
export RS

include("gallery.jl")
export poisson

include("smoother.jl")
export GaussSeidel, SymmetricSweep, ForwardSweep, BackwardSweep,
smooth_prolongator, JacobiProlongation
JacobiProlongation

include("multilevel.jl")
export solve
Expand All @@ -28,7 +37,7 @@ include("classical.jl")
export ruge_stuben

include("aggregate.jl")
export aggregation, StandardAggregation
export StandardAggregation

include("aggregation.jl")
export fit_candidates, smoothed_aggregation
Expand Down
4 changes: 2 additions & 2 deletions src/aggregate.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
struct StandardAggregation
end

function aggregation(::StandardAggregation, S::SparseMatrixCSC{T,R}) where {T,R}
function (::StandardAggregation)(S::SparseMatrixCSC{T,R}) where {T,R}

n = size(S, 1)
x = zeros(R, n)
Expand Down Expand Up @@ -97,7 +97,7 @@ function aggregation(::StandardAggregation, S::SparseMatrixCSC{T,R}) where {T,R}
if minimum(x) == -1
mask = x .!= -1
I = collect(R, 1:n)[mask]
J = x[mask] + R(1)
J = x[mask] .+ R(1)
#J = x[mask] + 1
V = ones(eltype(S), length(J))
AggOp = sparse(J,I,V,N,M)
Expand Down
25 changes: 14 additions & 11 deletions src/aggregation.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
function smoothed_aggregation(A::SparseMatrixCSC{T,V},
function smoothed_aggregation(A::SparseMatrixCSC{T,V}, ::Type{Val{bs}}=Val{1},
symmetry = HermitianSymmetry(),
strength = SymmetricStrength(),
aggregate = StandardAggregation(),
smooth = JacobiProlongation(4.0/3.0),
presmoother = GaussSeidel(),
postsmoother = GaussSeidel(),
improve_candidates = GaussSeidel(4),
improve_candidates = GaussSeidel(iter=4),
max_levels = 10,
max_coarse = 10,
diagonal_dominance = false,
keep = false,
coarse_solver = Pinv()) where {T,V}

coarse_solver = Pinv) where {T,V,bs}

n = size(A, 1)
# B = kron(ones(n, 1), eye(1))
Expand All @@ -30,19 +29,23 @@ function smoothed_aggregation(A::SparseMatrixCSC{T,V},

levels = Vector{Level{T,V}}()
bsr_flag = false
w = MultiLevelWorkspace(Val{bs}, eltype(A))

while length(levels) + 1 < max_levels && size(A, 1) > max_coarse
residual!(w, size(A, 1))
A, B, bsr_flag = extend_hierarchy!(levels, strength, aggregate, smooth,
improve_candidates, diagonal_dominance,
keep, A, B, symmetry, bsr_flag)
coarse_x!(w, size(A, 1))
coarse_b!(w, size(A, 1))
#=if size(A, 1) <= max_coarse
break
end=#
end
#=A, B = extend_hierarchy!(levels, strength, aggregate, smooth,
improve_candidates, diagonal_dominance,
keep, A, B, symmetry)=#
MultiLevel(levels, A, presmoother, postsmoother)
MultiLevel(levels, A, coarse_solver(A), presmoother, postsmoother, w)
end

struct HermitianSymmetry
Expand All @@ -54,18 +57,18 @@ function extend_hierarchy!(levels, strength, aggregate, smooth,
symmetry, bsr_flag)

# Calculate strength of connection matrix
S = strength_of_connection(strength, A, bsr_flag)
S = strength(A, bsr_flag)

# Aggregation operator
AggOp = aggregation(aggregate, S)
AggOp = aggregate(S)
# b = zeros(eltype(A), size(A, 1))

# Improve candidates
b = zeros(size(A,1))
relax!(improve_candidates, A, B, b)
improve_candidates(A, B, b)
T, B = fit_candidates(AggOp, B)

P = smooth_prolongator(smooth, A, T, S, B)
P = smooth(A, T, S, B)
R = construct_R(symmetry, P)
push!(levels, Level(A, P, R))

Expand All @@ -77,11 +80,11 @@ function extend_hierarchy!(levels, strength, aggregate, smooth,

A, B, bsr_flag
end
construct_R(::HermitianSymmetry, P) = P'
construct_R(::HermitianSymmetry, P) = copy(P')

function fit_candidates(AggOp, B, tol = 1e-10)

A = AggOp.'
A = copy(AggOp')
n_fine, n_coarse = size(A)
n_col = n_coarse

Expand Down
Loading