Skip to content
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ExtendableFEM"
uuid = "a722555e-65e0-4074-a036-ca7ce79a4aed"
version = "1.10.0"
version = "1.10.1"
authors = ["Christian Merdon <merdon@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]

[deps]
Expand Down
18 changes: 15 additions & 3 deletions src/solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,17 @@ function init_linear_solver!(SC, A, b, timer)
allocs_assembly = 0

if SC.linsolver === nothing
if SC.parameters[:verbosity] > 0
@info ".... initializing linear solver ($(method_linear))\n"
end
@timeit timer "initialization" begin
stats = @timed begin
abstol = SC.parameters[:abstol]
reltol = SC.parameters[:reltol]
method_linear = SC.parameters[:method_linear]
precon_linear = SC.parameters[:precon_linear]

if SC.parameters[:verbosity] > 0
@info ".... initializing linear solver ($(method_linear))\n"
end

LP = LinearProblem(A, b)
if precon_linear !== nothing
SC.linsolver = init(LP, method_linear; Pl = precon_linear(A), abstol, reltol)
Expand Down Expand Up @@ -296,13 +297,18 @@ function solve_linear_system!(A, b, sol, soltemp, residual, unknowns, freedofs,
## create block matrix
if linsolve_needs_matrix
if SC.parameters[:compress_restrictions]

SC.parameters[:verbosity] > 1 && @info "Compressing the restriction matrices..."

# combine all restriction matrices into one:
combined_transposed_restriction_matrix = vcat(restriction_matrices'...)
combined_restriction_rhs = vcat(restriction_rhss...)

# compute rank revealing QR decomposition (of the transposed matrix)
qr_result = qr(combined_transposed_restriction_matrix)

SC.parameters[:verbosity] > 1 && @info "QR decomposition computed"

# extract components (from docs: Q*R = combined_transposed_restriction_matrix[prow, pcol])
(; Q, R, prow, pcol) = qr_result

Expand Down Expand Up @@ -332,6 +338,8 @@ function solve_linear_system!(A, b, sol, soltemp, residual, unknowns, freedofs,
# update sizes
block_sizes = [length(b_unrestricted), length(combined_restriction_rhs)]
total_size = sum(block_sizes)

SC.parameters[:verbosity] > 1 && @info "Created new CompressedRestriction"
end

A_block = BlockMatrix(spzeros(Tv, total_size, total_size), block_sizes, block_sizes)
Expand Down Expand Up @@ -369,13 +377,17 @@ function solve_linear_system!(A, b, sol, soltemp, residual, unknowns, freedofs,

(n_row, n_col) = size(blocks(A_block))


SC.parameters[:verbosity] > 1 && @info "Assemble flat matrix out of blocks..."
for i in 1:n_row, j in 1:n_col
range_row = (lasts_row[i] + 1):lasts_row[i + 1]
range_col = (lasts_col[j] + 1):lasts_col[j + 1]

# write each block directly in the resulting matrix
A_flat[range_row, range_col] = A_block[Block(i, j)]
end
SC.parameters[:verbosity] > 1 && @info "... matrix assembly complete!"

linsolve_A = A_flat
end
end
Expand Down
Loading