Skip to content

Commit d619511

Browse files
fix tests + add nns tests to ci
1 parent 517bb95 commit d619511

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

Project.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
2424
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
2525
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2626
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
27+
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
28+
Ferrite = "c061ca5d-56c9-439f-9c0e-210fe06d3992"
29+
FerriteGmsh = "4f95f4f8-b27c-4ae5-9a39-ea55e634e36b"
2730

2831
[targets]
29-
test = ["DelimitedFiles", "FileIO", "IterativeSolvers", "JLD2", "LinearSolve", "Random", "Test"]
32+
test = ["DelimitedFiles", "FileIO", "IterativeSolvers", "JLD2", "LinearSolve", "Random", "Test","Ferrite","FerriteGmsh","Downloads"]

src/aggregation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ construct_R(::HermitianSymmetry, P) = P'
9090

9191
function fit_candidates(AggOp, B; tol=1e-10)
9292
A = adjoint(AggOp)
93-
n_fine, m = size(B)
93+
n_fine, m = ndims(B) == 1 ? (length(B), 1) : size(B)
9494
n_fine2, n_agg = size(A)
9595
@assert n_fine2 == n_fine
9696
n_coarse = m * n_agg

test/nns_test.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import AlgebraicMultigrid as AMG
33
using Test
44
using SparseArrays, LinearAlgebra
55
using Ferrite, FerriteGmsh, SparseArrays
6-
using Printf
76
using Downloads: download
87

98
## Test QR factorization
@@ -259,7 +258,7 @@ function create_nns_frame(x_coords::Vector{Float64}, dofmap::Vector{Int})
259258
return B
260259
end
261260

262-
function cantilever_beam(P, E,A, I, L, n_elem)
261+
function cantilever_beam(P, E, A, I, L, n_elem)
263262
le = L / n_elem
264263
n_nodes = n_elem + 1
265264
dofs_per_node = 3 # u, w, theta
@@ -316,8 +315,9 @@ end
316315
ml = smoothed_aggregation(A, B)
317316
@show ml
318317

319-
@printf("No NNS: final residual at iteration %2d: %6.2e\n", length(residuals_wonns), residuals_nns[end])
320-
@printf("With NNS: final residual at iteration %2d: %6.2e\n", length(residuals_nns), residuals_wonns[end])
318+
println("No NNS: final residual at iteration ", length(residuals_wonns), ": ", residuals_nns[end])
319+
println("With NNS: final residual at iteration ", length(residuals_nns), ": ", residuals_wonns[end])
320+
321321

322322
#test QR factorization on linear elasticity
323323
aggregate = StandardAggregation()
@@ -341,7 +341,7 @@ end
341341
A = 1e-4 # Cross-section area (for axial)
342342
I = 1e-6 # Moment of inertia (for bending)
343343
L = 1.0 # Total length
344-
A, b, B = cantilever_beam(P, E,A, I, L, n_elem)
344+
A, b, B = cantilever_beam(P, E, A, I, L, n_elem)
345345
# test solution
346346
# Analaytical solution for cantilever beam
347347
u = A \ b
@@ -351,8 +351,9 @@ end
351351
x_nns, residuals_nns = solve(A, b, SmoothedAggregationAMG(B); log=true, reltol=1e-10)
352352
x_wonns, residuals_wonns = solve(A, b, SmoothedAggregationAMG(); log=true, reltol=1e-10)
353353

354-
@printf("No NNS: final residual at iteration %2d: %6.2e\n", length(residuals_wonns), residuals_nns[end])
355-
@printf("With NNS: final residual at iteration %2d: %6.2e\n", length(residuals_nns), residuals_wonns[end])
354+
println("No NNS: final residual at iteration ", length(residuals_wonns), ": ", residuals_nns[end])
355+
println("With NNS: final residual at iteration ", length(residuals_nns), ": ", residuals_wonns[end])
356+
356357

357358
# test QR factorization on bending beam
358359
# Aggregation

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using Random: seed!
99

1010
include("sa_tests.jl")
1111
include("cycle_tests.jl")
12+
include("nns_test.jl")
1213

1314
@testset "AlgebraicMultigrid Tests" begin
1415

0 commit comments

Comments
 (0)