Skip to content

Commit

Permalink
Bail early if all coeffs are emtpy
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Oct 26, 2022
1 parent b4fca40 commit 73266c6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Dofs/ConstraintHandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ end
Add the `AffineConstraint` to the `ConstraintHandler`.
"""
function add!(ch::ConstraintHandler, ac::AffineConstraint)
add_prescribed_dof!(ch, ac.constrained_dof, ac.b, isempty(ac.entries) ? nothing : ac.entries)
# TODO: Would be nice to pass nothing if ac.entries is empty, but then we lose the fact
# that this constraint is an AffineConstraint which is currently needed in update!
# in order to not update inhomogeneities for affine constraints
add_prescribed_dof!(ch, ac.constrained_dof, ac.b, #=isempty(ac.entries) ? nothing : =# ac.entries)
end

"""
Expand Down Expand Up @@ -618,7 +621,7 @@ function _condense_sparsity_pattern!(K::SparseMatrixCSC{T}, dofcoefficients::Vec
ndofs = size(K, 1)

# Return early if there are no non-trivial affine constraints
any(i -> i !== nothing, dofcoefficients) || return
any(i -> !(i === nothing || isempty(i)), dofcoefficients) || return

# Adding new entries to K is extremely slow, so create a new sparsity triplet for the
# condensed sparsity pattern
Expand Down Expand Up @@ -686,7 +689,7 @@ function _condense!(K::SparseMatrixCSC, f::AbstractVector, dofcoefficients::Vect
condense_f && @assert( length(f) == ndofs )

# Return early if there are no non-trivial affine constraints
any(i -> i !== nothing, dofcoefficients) || return
any(i -> !(i === nothing || isempty(i)), dofcoefficients) || return

for col in 1:ndofs
col_coeffs = coefficients_for_dof(dofmapping, dofcoefficients, col)
Expand Down

0 comments on commit 73266c6

Please sign in to comment.