Skip to content

Commit 037e074

Browse files
authored
Merge pull request #25 from ranjanan/no_agg
Fix Aggregation Operator construction when some nodes aren't aggregated.
2 parents 4db3d34 + 013b37a commit 037e074

File tree

6 files changed

+41
-17
lines changed

6 files changed

+41
-17
lines changed

src/aggregate.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,19 @@ function aggregation(::StandardAggregation, S)
9393
y = y[1:next_aggregate]
9494
M,N = (n, next_aggregate)
9595

96-
Tp = collect(1:n+1)
97-
x .= x .+ 1
98-
Tx = ones(eltype(S), length(x))
96+
# Some nodes not aggregated
97+
if minimum(x) == -1
98+
mask = x .!= -1
99+
I = collect(1:n)[mask]
100+
J = x[mask] + 1
101+
V = ones(eltype(S), length(J))
102+
AggOp = sparse(J,I,V,N,M)
103+
else
104+
Tp = collect(1:n+1)
105+
x .= x .+ 1
106+
Tx = ones(eltype(S), length(x))
107+
AggOp = SparseMatrixCSC(N, M, Tp, x, Tx)
108+
end
99109

100-
SparseMatrixCSC(N, M, Tp, x, Tx)
110+
AggOp
101111
end

src/aggregation.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ function fit_candidates(AggOp, B, tol = 1e-10)
8686

8787
R = zeros(eltype(B), n_coarse)
8888
Qx = zeros(eltype(B), nnz(A))
89-
90-
copy!(Qx, B)
89+
90+
# copy!(Qx, B)
91+
for i = 1:size(Qx, 1)
92+
Qx[i] = B[i]
93+
end
9194
# copy!(A.nzval, B)
9295
for i = 1:n_col
9396
for j in nzrange(A,i)

src/strength.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ function strength_of_connection{T}(s::SymmetricStrength{T}, A, bsr_flag = false)
118118
dropzeros!(S)
119119

120120
# S.nzval .= abs.(S.nzval)
121-
#for i = 1:size(S.nzval, 1)
122-
# S.nzval[i] = abs(S.nzval[i])
123-
#end
121+
# for i = 1:size(S.nzval, 1)
122+
# S.nzval[i] = abs(S.nzval[i])
123+
# end
124124

125125
scale_cols_by_largest_entry!(S)
126126

test/onetoall.jld

10.4 KB
Binary file not shown.

test/runtests.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,28 +241,31 @@ end
241241

242242
@testset "Symmetric Strength of Connection" begin
243243

244-
test_symmetric_soc()
244+
test_symmetric_soc()
245245
end
246246

247247
@testset "Standard Aggregation" begin
248248

249-
test_standard_aggregation()
249+
test_standard_aggregation()
250250
end
251251

252252
@testset "Fit Candidates" begin
253-
test_fit_candidates()
253+
test_fit_candidates()
254254
end
255255

256256
@testset "Approximate Spectral Radius" begin
257-
test_approximate_spectral_radius()
257+
test_approximate_spectral_radius()
258258
end
259259
end
260260

261261
@testset "Gauss Seidel" begin
262-
test_gauss_seidel()
262+
test_gauss_seidel()
263263
end
264264

265265
@testset "Jacobi Prolongation" begin
266-
test_jacobi_prolongator()
266+
test_jacobi_prolongator()
267+
end
268+
269+
# Issue #24
270+
nodes_not_agg()
267271
end
268-
end

test/sa_tests.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,12 @@ function test_jacobi_prolongator()
311311
x = smooth_prolongator(JacobiProlongation(4/3), A, T, 1, 1)
312312
ref = load("ref_R.jld")["G"]
313313
@test sum(abs2, x - ref) < 1e-6
314-
end
314+
end
315+
316+
# Issue #24
317+
function nodes_not_agg()
318+
A = load("onetoall.jld")["G"]
319+
ml = smoothed_aggregation(A)
320+
@test size(ml.levels[2].A) == (11,11)
321+
@test size(ml.final_A) == (2,2)
322+
end

0 commit comments

Comments
 (0)