Created
April 26, 2017 13:30
-
-
Save KristofferC/1660cd312d17454009644e3516c10c94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDivGrad(n1,n2,n3) | |
# the Divergence | |
D1 = kron(speye(n3),kron(speye(n2),ddx(n1))) | |
D2 = kron(speye(n3),kron(ddx(n2),speye(n1))) | |
D3 = kron(ddx(n3),kron(speye(n2),speye(n1))) | |
# DIV from faces to cell-centers | |
Div = [D1 D2 D3] | |
return Div*Div'; | |
end | |
function ddx(n) | |
# generate 1D derivatives | |
return d = spdiagm((-ones(n),ones(n)),[0,1],n,n+1) | |
end | |
K = getDivGrad(60,60,60); b = rand(size(K,1)); c = similar(b); | |
@time for i in 1:1000 A_mul_B!(c,K,b) end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment