Introduce isconstrained bitvector in ConstraintHandler#1310
Conversation
Also used to make close simpler and slightly faster, and make it easier to check if dof is constrained
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1310 +/- ##
=======================================
Coverage 94.30% 94.31%
=======================================
Files 40 40
Lines 6763 6768 +5
=======================================
+ Hits 6378 6383 +5
Misses 385 385 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
There is also |
BitSet([itr])
Construct a sorted set of Ints generated by the given iterable object,
or an empty set. Implemented as a bit string, and therefore designed
for dense integer sets. If the set will be sparse (for example, holding
a few very large integers), use Set instead.I thought of it but discarded when reading this, since for the constrained dofs we have very sparse sets for large grids. But is there a better way to use this than my naive thinking of |
|
Yeah, probably not worthwhile. I don't think it matters in practice though, this should be a lot smaller than many of the other data structures used already. |
| nzval = K.nzval | ||
| return @inbounds for i in eachindex(colval, nzval) | ||
| if haskey(ch.dofmapping, colval[i]) | ||
| return @inbounds for (i, col) in pairs(colval) |
There was a problem hiding this comment.
pairs here feels odd. Should it be enumerate?
There was a problem hiding this comment.
My interpretation here is that colval and nzval have the same indices, hence it should be pairs. Of course, in practice for SparseMatrixCSR both colval and nzval are Vectors, so it doesn't matter.
There was a problem hiding this comment.
Ok, I think that is fair.
| @inbounds for i in eachindex(rowval, nzval) | ||
| if haskey(ch.dofmapping, rowval[i]) | ||
| nzval[i] = 0 | ||
| @inbounds for (i, row) in pairs(rowval) |
There was a problem hiding this comment.
As above, but here the storage types in AbstractSparseMatrixCSC could be offset arrays, and then I assume that it should be pairs since we assume rowval and nzval have the same indexing?
KristofferC
left a comment
There was a problem hiding this comment.
Should be good to go I think?
This makes it easier and faster to check if a dof is constrained.
Previous check was
haskey(ch.dof_mapping, dofnr), now justch.isconstrained[dofnr].This speeds up
zero_out_rows!and makes creatingfree_dofseasier (and a tiny bit faster).Benchmarks
benchmark code
Extra runs for close!: