Skip to content

Commit

Permalink
Eliminate Dirichlet boundary conditions differently
Browse files Browse the repository at this point in the history
Slicing is very expensive operation on sparse matrices. Avoid slicing
by calculating matrix product `K_red = C1*K*C1`, where C1 is diagonal
matrix. This should be much cheaper.
  • Loading branch information
ahojukka5 committed Aug 20, 2017
1 parent 6e03687 commit a08a928
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/solvers_modal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ function eliminate_boundary_conditions!(K_red::SparseMatrixCSC,
@assert nnz(g) == 0
@assert C1 == C2
@assert isdiag(C1)
nz = get_nonzero_rows(C1)
info("bc $(problem.name): $(length(nz)) nonzeros, $nz")
K_red[nz,:] = 0.0
K_red[:,nz] = 0.0
M_red[nz,:] = 0.0
M_red[:,nz] = 0.0
fixed_dofs = get_nonzero_rows(C1)
P = ones(ndim)
P[fixed_dofs] = 0.0
Q = spdiagm(P)
K_red[:,:] = Q' * K_red * Q
M_red[:,:] = Q' * M_red * Q
return
end

""" Given data vector, return slave displacements. """
Expand Down

0 comments on commit a08a928

Please sign in to comment.