@@ -60,16 +60,16 @@ function Base.copy(FEV::FEMatrix{TvM, TiM, TvG, TiG, nbrow, nbcol, nbtotal}) whe
60
60
end
61
61
62
62
# Add value to matrix if it is nonzero
63
- @inline function _addnz (ESM:: ExtendableSparseMatrix , i, j, v:: Tv , fac) where Tv
63
+ @inline function _addnz (ESM:: AbstractExtendableSparseMatrixCSC , i, j, v:: Tv , fac, part = 1 ) where Tv
64
64
if v != zero (Tv)
65
- rawupdateindex! (ESM, + , v * fac, i, j)
65
+ rawupdateindex! (ESM, + , v * fac, i, j, part )
66
66
end
67
67
end
68
68
69
69
# Add value to matrix if it is nonzero
70
- @inline function _addnz (FEB:: FEMatrixBlock , i, j, v:: Tv , fac) where Tv
70
+ @inline function _addnz (FEB:: FEMatrixBlock , i, j, v:: Tv , fac, part = 1 ) where Tv
71
71
if v != zero (Tv)
72
- rawupdateindex! (FEB. entries, + , v * fac, FEB. offset + i, FEB. offsetY + j)
72
+ rawupdateindex! (FEB. entries, + , v * fac, FEB. offset + i, FEB. offsetY + j, part )
73
73
end
74
74
end
75
75
@@ -205,7 +205,7 @@ FEMatrix{TvM,TiM}(FESX, FESY; name = "auto")
205
205
206
206
Creates an FEMatrix with blocks coressponding to the ndofs of FESX (rows) and FESY (columns).
207
207
"""
208
- function FEMatrix {TvM, TiM} (FESX:: Array{<:FESpace{TvG, TiG}, 1} , FESY:: Array{<:FESpace{TvG, TiG}, 1} ; entries = nothing , name = nothing , tags = nothing , tagsX = tags, tagsY = tagsX, kwargs... ) where {TvM, TiM, TvG, TiG}
208
+ function FEMatrix {TvM, TiM} (FESX:: Array{<:FESpace{TvG, TiG}, 1} , FESY:: Array{<:FESpace{TvG, TiG}, 1} ; entries = nothing , name = nothing , tags = nothing , tagsX = tags, tagsY = tagsX, npartitions = 1 , kwargs... ) where {TvM, TiM, TvG, TiG}
209
209
ndofsX, ndofsY = 0 , 0
210
210
for j ∈ 1 : length (FESX)
211
211
ndofsX += FESX[j]. ndofs
@@ -214,7 +214,11 @@ function FEMatrix{TvM, TiM}(FESX::Array{<:FESpace{TvG, TiG}, 1}, FESY::Array{<:F
214
214
ndofsY += FESY[j]. ndofs
215
215
end
216
216
if entries === nothing
217
- entries = ExtendableSparseMatrix {TvM, TiM} (ndofsX, ndofsY)
217
+ if npartitions == 1
218
+ entries = ExtendableSparseMatrixCSC {TvM, TiM} (ndofsX, ndofsY)
219
+ elseif npartitions > 1
220
+ entries = MTExtendableSparseMatrixCSC {TvM, TiM} (ndofsX, ndofsY, npartitions)
221
+ end
218
222
else
219
223
@assert size (entries) == (ndofsX, ndofsY) " size of given entries not matching number of dofs in given FE space(s)"
220
224
end
@@ -284,10 +288,10 @@ Adds FEMatrix/ExtendableSparseMatrix/CSCMatrix B to FEMatrix A.
284
288
function add! (A:: FEMatrix{Tv, Ti} , B:: FEMatrix{Tv, Ti} ; kwargs... ) where {Tv, Ti}
285
289
add! (A. entries, B. entries; kwargs... )
286
290
end
287
- function add! (AM:: ExtendableSparseMatrix {Tv, Ti} , BM:: ExtendableSparseMatrix {Tv, Ti} ; kwargs... ) where {Tv, Ti}
291
+ function add! (AM:: AbstractExtendableSparseMatrixCSC {Tv, Ti} , BM:: AbstractExtendableSparseMatrixCSC {Tv, Ti} ; kwargs... ) where {Tv, Ti}
288
292
add! (AM, BM. cscmatrix; kwargs... )
289
293
end
290
- function add! (AM:: ExtendableSparseMatrix {Tv, Ti} , cscmat:: SparseMatrixCSC{Tv, Ti} ; factor = 1 , rowoffset = 0 , coloffset = 0 , transpose:: Bool = false ) where {Tv, Ti}
294
+ function add! (AM:: AbstractExtendableSparseMatrixCSC {Tv, Ti} , cscmat:: SparseMatrixCSC{Tv, Ti} ; factor = 1 , rowoffset = 0 , coloffset = 0 , transpose:: Bool = false ) where {Tv, Ti}
291
295
rows:: Array{Ti, 1} = rowvals (cscmat)
292
296
valsB:: Array{Tv, 1} = cscmat. nzval
293
297
ncols:: Int = size (cscmat, 2 )
@@ -318,8 +322,8 @@ $(TYPEDSIGNATURES)
318
322
Adds FEMatrixBlock B to FEMatrixBlock A.
319
323
"""
320
324
function addblock! (A:: FEMatrixBlock{Tv, Ti} , B:: FEMatrixBlock{Tv, Ti} ; factor = 1 , transpose:: Bool = false ) where {Tv, Ti}
321
- AM:: ExtendableSparseMatrix {Tv, Ti} = A. entries
322
- BM:: ExtendableSparseMatrix {Tv, Ti} = B. entries
325
+ AM:: AbstractExtendableSparseMatrixCSC {Tv, Ti} = A. entries
326
+ BM:: AbstractExtendableSparseMatrixCSC {Tv, Ti} = B. entries
323
327
cscmat:: SparseMatrixCSC{Tv, Ti} = BM. cscmatrix
324
328
rows:: Array{Ti, 1} = rowvals (cscmat)
325
329
valsB:: Array{Tv, 1} = cscmat. nzval
@@ -357,7 +361,7 @@ $(TYPEDSIGNATURES)
357
361
358
362
Adds ExtendableSparseMatrix B to FEMatrixBlock A.
359
363
"""
360
- function addblock! (A:: FEMatrixBlock{Tv} , B:: ExtendableSparseMatrix {Tv, Ti} ; factor = 1 , transpose:: Bool = false ) where {Tv, Ti <: Integer }
364
+ function addblock! (A:: FEMatrixBlock{Tv} , B:: AbstractExtendableSparseMatrixCSC {Tv, Ti} ; factor = 1 , transpose:: Bool = false ) where {Tv, Ti <: Integer }
361
365
addblock! (A, B. cscmatrix; factor = factor, transpose = transpose)
362
366
end
363
367
@@ -368,7 +372,7 @@ $(TYPEDSIGNATURES)
368
372
Adds SparseMatrixCSC B to FEMatrixBlock A.
369
373
"""
370
374
function addblock! (A:: FEMatrixBlock{Tv} , cscmat:: SparseArrays.SparseMatrixCSC{Tv, Ti} ; factor = 1 , transpose:: Bool = false ) where {Tv, Ti <: Integer }
371
- AM:: ExtendableSparseMatrix {Tv, Int64} = A. entries
375
+ AM:: AbstractExtendableSparseMatrixCSC {Tv, Int64} = A. entries
372
376
rows:: Array{Int, 1} = rowvals (cscmat)
373
377
valsB:: Array{Tv, 1} = cscmat. nzval
374
378
arow:: Int = 0
@@ -396,7 +400,7 @@ function addblock!(A::FEMatrixBlock{Tv}, cscmat::SparseArrays.SparseMatrixCSC{Tv
396
400
return nothing
397
401
end
398
402
399
- function apply_penalties! (A:: ExtendableSparseMatrix , fixed_dofs, penalty)
403
+ function apply_penalties! (A:: AbstractExtendableSparseMatrixCSC , fixed_dofs, penalty)
400
404
for dof in fixed_dofs
401
405
A[dof, dof] = penalty
402
406
end
@@ -410,7 +414,7 @@ $(TYPEDSIGNATURES)
410
414
Adds matrix-matrix product B times C to FEMatrixBlock A.
411
415
"""
412
416
function addblock_matmul! (A:: FEMatrixBlock{Tv} , cscmatB:: SparseMatrixCSC{Tv, Ti} , cscmatC:: SparseMatrixCSC{Tv, Ti} ; factor = 1 , transposed:: Bool = false ) where {Tv, Ti}
413
- AM:: ExtendableSparseMatrix {Tv, Int64} = A. entries
417
+ AM:: AbstractExtendableSparseMatrixCSC {Tv, Int64} = A. entries
414
418
rowsB:: Array{Ti, 1} = rowvals (cscmatB)
415
419
rowsC:: Array{Ti, 1} = rowvals (cscmatC)
416
420
valsB:: Array{Tv, 1} = cscmatB. nzval
@@ -529,7 +533,7 @@ $(TYPEDSIGNATURES)
529
533
530
534
Adds matrix-vector product B times b to FEVectorBlock a.
531
535
"""
532
- function addblock_matmul! (a:: FEVectorBlock{Tv} , B:: ExtendableSparseMatrix {Tv, Ti} , b:: FEVectorBlock{Tv} ; factor = 1 ) where {Tv, Ti <: Integer }
536
+ function addblock_matmul! (a:: FEVectorBlock{Tv} , B:: AbstractExtendableSparseMatrixCSC {Tv, Ti} , b:: FEVectorBlock{Tv} ; factor = 1 ) where {Tv, Ti <: Integer }
533
537
cscmat:: SparseMatrixCSC{Tv, Ti} = B. cscmatrix
534
538
rows:: Array{Ti, 1} = rowvals (cscmat)
535
539
valsB:: Array{Tv, 1} = cscmat. nzval
@@ -567,7 +571,7 @@ $(TYPEDSIGNATURES)
567
571
568
572
Computes vector'-matrix-vector product a'*B*b.
569
573
"""
570
- function lrmatmul (a:: AbstractVector{Tv} , B:: ExtendableSparseMatrix {Tv, Ti} , b:: AbstractVector{Tv} ; factor = 1 ) where {Tv, Ti <: Integer }
574
+ function lrmatmul (a:: AbstractVector{Tv} , B:: AbstractExtendableSparseMatrixCSC {Tv, Ti} , b:: AbstractVector{Tv} ; factor = 1 ) where {Tv, Ti <: Integer }
571
575
cscmat:: SparseMatrixCSC{Tv, Ti} = B. cscmatrix
572
576
valsB:: Array{Tv, 1} = cscmat. nzval
573
577
rows:: Array{Ti, 1} = rowvals (cscmat)
@@ -586,7 +590,7 @@ $(TYPEDSIGNATURES)
586
590
587
591
Computes vector'-matrix-vector product (a1-a2)'*B*(b1-b2).
588
592
"""
589
- function ldrdmatmul (a1:: AbstractVector{Tv} , a2:: AbstractVector{Tv} , B:: ExtendableSparseMatrix {Tv, Ti} , b1:: AbstractVector{Tv} , b2:: AbstractVector{Tv} ; factor = 1 ) where {Tv, Ti <: Integer }
593
+ function ldrdmatmul (a1:: AbstractVector{Tv} , a2:: AbstractVector{Tv} , B:: AbstractExtendableSparseMatrixCSC {Tv, Ti} , b1:: AbstractVector{Tv} , b2:: AbstractVector{Tv} ; factor = 1 ) where {Tv, Ti <: Integer }
590
594
cscmat:: SparseMatrixCSC{Tv, Ti} = B. cscmatrix
591
595
valsB:: Array{Tv, 1} = cscmat. nzval
592
596
rows:: Array{Ti, 1} = rowvals (cscmat)
@@ -600,7 +604,7 @@ function ldrdmatmul(a1::AbstractVector{Tv}, a2::AbstractVector{Tv}, B::Extendabl
600
604
end
601
605
602
606
603
- function submatrix (A:: ExtendableSparseMatrix {Tv,Ti} , srows, scols) where {Tv,Ti}
607
+ function submatrix (A:: AbstractExtendableSparseMatrixCSC {Tv,Ti} , srows, scols) where {Tv,Ti}
604
608
cscmat:: SparseMatrixCSC{Tv, Ti} = A. cscmatrix
605
609
valsA:: Array{Tv, 1} = cscmat. nzval
606
610
rows:: Array{Ti, 1} = rowvals (cscmat)
0 commit comments