@@ -739,17 +739,23 @@ end
739739getncols (sp:: FastSparsityPattern ) = length (sp. marker)
740740getnrows (sp:: FastSparsityPattern ) = length (sp. rowlen)
741741
742- function create_celldofs (dh)
742+ function create_celldofs (dh:: DofHandler )
743+ isclosed (dh) || throw (ArgumentError (" DofHandler must be closed" ))
743744 ncells = getncells (dh. grid)
744745 indices = similar (dh. cell_dofs_offset, ncells + 1 )
745746 cell_dofs = similar (dh. cell_dofs)
746747 n = 1
747- for cell_idx in 1 : getncells (dh . grid)
748+ for cell_idx in 1 : ncells
748749 indices[cell_idx] = n
749- r = n: (n + ndofs_per_cell (dh, cell_idx) - 1 )
750- celldofs! (view (cell_dofs, r), dh, cell_idx)
750+ num = ndofs_per_cell (dh, cell_idx)
751+ num == 0 && continue
752+ r = n: (n + num - 1 )
753+ # celldofs!(view(cell_dofs, r), dh, cell_idx), but faster without view:
754+ soffs = dh. cell_dofs_offset[cell_idx]
755+ copyto! (cell_dofs, n, dh. cell_dofs, soffs, num)
751756 n = last (r) + 1
752757 end
758+ indices[end ] = n
753759 return ArrayOfVectorViews (indices, cell_dofs, LinearIndices ((ncells,)))
754760end
755761
@@ -764,7 +770,6 @@ function create_row_to_cells(cell_dofs::ArrayOfVectorViews, sp)
764770 n_connected += 1
765771 end
766772 end
767- # n_connected = sum(num_cells) better?
768773
769774 # 2: Create the correct datastructure
770775 data = Vector {Int} (undef, n_connected)
0 commit comments