Skip to content

Commit 272db1a

Browse files
authored
Merge pull request #114 from WIAS-PDELib/chmerdon/faster_combinedofs_operator
faster combinedofs operator assembly
2 parents 0638bef + bc536ea commit 272db1a

5 files changed

Lines changed: 22 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGES
22

3+
4+
## v.1.10.4
5+
6+
### Fixed
7+
- assembly of CombineDofs operator now much faster
8+
9+
310
## v.1.10.3
411

512
### Fixed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ExtendableFEM"
22
uuid = "a722555e-65e0-4074-a036-ca7ce79a4aed"
3-
version = "1.10.3"
3+
version = "1.10.4"
44
authors = ["Christian Merdon <merdon@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
55

66
[deps]

examples/Example312_PeriodicElasticity3D.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ end
129129

130130
function main(;
131131
order = 1,
132-
periodic_coupling = :none, # :restriction, :operator, :high_level_restriction
132+
periodic_coupling = :high_level_restriction, # :restriction, :operator, :high_level_restriction
133133
Plotter = nothing,
134134
force = 1.0,
135135
h = 1.0e-4,

src/ExtendableFEM.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ using ExtendableGrids: ExtendableGrids, AT_NODES, AbstractElementGeometry,
6161
unique, update_trafo!, xrefFACE2xrefCELL,
6262
xrefFACE2xrefOFACE
6363
using ExtendableSparse: ExtendableSparse, ExtendableSparseMatrix, flush!,
64-
MTExtendableSparseMatrixCSC, findindex,
64+
MTExtendableSparseMatrixCSC,
6565
rawupdateindex!
6666
using ForwardDiff: ForwardDiff
6767
using GridVisualize: GridVisualize, GridVisualizer, gridplot!, reveal, save,

src/common_operators/combinedofs.jl

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,29 +107,27 @@ function build_assembler!(CD::CombineDofs{UT, CT}, FE::Array{<:FEVectorBlock, 1}
107107

108108
function assemble!(A::AbstractSparseArray{T}, b::AbstractVector{T}, assemble_matrix::Bool, assemble_rhs::Bool, kwargs...) where {T}
109109
if assemble_matrix
110+
111+
@views AT = sparse(A.cscmatrix[fixed_dofs .+ offsetX, :]')
112+
110113
# go through each constrained dof and update the FE adjacency info
111114
# of the coupled dofs
112-
for dof_i in fixed_dofs
115+
for (i, dof_i) in enumerate(fixed_dofs)
113116
# this col-view is efficient
114117
coupling_i = @views coupling_matrix[:, dof_i]
115118

116-
# write the FE adjacency of the constrained dofs into this row
117-
sourcerow = dof_i + offsetX
118-
119119
# extract the constrained dofs and the weights
120120
coupled_dofs_i, weights_i = findnz(coupling_i)
121121

122122
# parse through sourcerow and add the contents to the coupled dofs
123-
for col in 1:size(A, 2)
124-
r = findindex(A.cscmatrix, sourcerow, col)
125-
if r > 0
126-
val = A.cscmatrix.nzval[r]
127-
if abs(val) > 1.0e-15
128-
for (dof_k, weight_ik) in zip(coupled_dofs_i, weights_i)
129-
targetrow = dof_k + offsetX
130-
_addnz(A, targetrow, col, val, weight_ik)
131-
end
132-
end
123+
A_row = @views AT[:, i]
124+
cols_i, vals_i = findnz(A_row)
125+
126+
# copy values of sourcerow to the coupled targetrow
127+
for (col, val) in zip(cols_i, vals_i)
128+
for (dof_k, weight_ik) in zip(coupled_dofs_i, weights_i)
129+
targetrow = dof_k + offsetX
130+
_addnz(A, targetrow, col, val, weight_ik)
133131
end
134132
end
135133
end

0 commit comments

Comments
 (0)