Skip to content

Commit

Permalink
Performance test using FEMBase standard assembler and SparseMatrixCOO
Browse files Browse the repository at this point in the history
  • Loading branch information
ahojukka5 committed Oct 4, 2018
1 parent 8392e44 commit 4c52893
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
64 changes: 64 additions & 0 deletions resources/create_data.jl
@@ -0,0 +1,64 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/FEMSparse.jl/blob/master/LICENSE

using JuliaFEM, HDF5

function create_data()
mesh = abaqus_read_mesh("EIFFEL_TOWER_TET10_220271.inp")
tower = Problem(Elasticity, "tower", 3)
tower_elements = create_elements(mesh, "TOWER")
update!(tower_elements, "youngs modulus", 210.0E3)
update!(tower_elements, "poissons ratio", 0.3)
update!(tower_elements, "density", 7.85E-9)
update!(tower_elements, "displacement load 3", -9810.0)
add_elements!(tower, tower_elements)
initialize!(tower, 0.0)
assemble!(tower, 0.0)
# contains 99342 x Tet10 elements
# 30x30 matrices => length of I, J, V = 89407800

dofs = zeros(Int, 30, length(tower_elements))
for (i,element) in enumerate(tower_elements)
for (j,dof) in enumerate(get_gdofs(tower, element))
dofs[j,i] = dof
end
end

K = copy(reshape(tower.assembly.K.V, 900, length(tower_elements)))

return K, dofs
end

K, dofs = create_data()

save = false
if save
h5open("data.h5", "w") do fid
fid["dofs", "blosc", 9] = dofs
fid["stiffness", "blosc", 9] = K
end
end

using SparseArrays, TimerOutputs

function create_stiffness_matrix(stiffness, dofs, N)
@timeit "initialize sparse matrix" K = SparseMatrixCOO()
for _ in 1:N
@timeit "create sparse stiffness matrix" begin
empty!(K)
ndofs, nelements = size(dofs)
Ke = zeros(30,30)
gdofs = zeros(Int, 30)
@timeit "assemble" for i=1:nelements
gdofs[:] .= dofs[:,i]
Ke[:] .= stiffness[:,i]
add!(K, gdofs, gdofs, Ke)
end
@timeit "convert to CSC" Ks = sparse(K)
end
end
end

reset_timer!()
create_stiffness_matrix(K, dofs, 10)
print_timer()
12 changes: 12 additions & 0 deletions resources/results.md
@@ -0,0 +1,12 @@
─────────────────────────────────────────────────────────────────────────────────────────
Time Allocations
────────────────────── ───────────────────────
Tot / % measured: 57.4s / 96.6% 29.5GiB / 100%

Section ncalls time %tot avg alloc %tot avg
─────────────────────────────────────────────────────────────────────────────────────────
create sparse stiffness matrix 10 55.4s 100% 5.54s 29.4GiB 100% 2.94GiB
assemble 10 33.0s 59.5% 3.30s 9.45GiB 32.1% 0.94GiB
convert to CSC 10 22.4s 40.5% 2.24s 20.0GiB 67.9% 2.00GiB
initialize sparse matrix 1 3.30μs 0.00% 3.30μs - 0.00% -
─────────────────────────────────────────────────────────────────────────────────────────

0 comments on commit 4c52893

Please sign in to comment.