Created
December 23, 2017 15:46
-
-
Save ChrisRackauckas/79757d0a4bfcbfdfec2fb138f1e151e5 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 fast_gm(t,u,p,du) | |
a,α,Abar,β,D1,D2 = p | |
@inbounds for i in 2:N-1, j in 2:N-1 | |
du[i,j,1] = D1*(u[i-1,j,1] + u[i+1,j,1] + u[i,j+1,1] + u[i,j-1,1] - 4u[i,j,1]) + | |
a*u[i,j,1]^2/u[i,j,2] + Abar - α*u[i,j,1] | |
end | |
@inbounds for i in 2:N-1, j in 2:N-1 | |
du[i,j,2] = D2*(u[i-1,j,2] + u[i+1,j,2] + u[i,j+1,2] + u[i,j-1,2] - 4u[i,j,2]) + | |
a*u[i,j,1]^2 - β*u[i,j,2] | |
end | |
@inbounds for j in 2:N-1 | |
i = 1 | |
du[1,j,1] = D1*(2u[i+1,j,1] + u[i,j+1,1] + u[i,j-1,1] - 4u[i,j,1]) + | |
a*u[i,j,1]^2/u[i,j,2] + Abar - α*u[i,j,1] | |
end | |
@inbounds for j in 2:N-1 | |
i = 1 | |
du[1,j,2] = D2*(2u[i+1,j,2] + u[i,j+1,2] + u[i,j-1,2] - 4u[i,j,2]) + | |
a*u[i,j,1]^2 - β*u[i,j,2] | |
end | |
@inbounds for j in 2:N-1 | |
i = N | |
du[end,j,1] = D1*(2u[i-1,j,1] + u[i,j+1,1] + u[i,j-1,1] - 4u[i,j,1]) + | |
a*u[i,j,1]^2/u[i,j,2] + Abar - α*u[i,j,1] | |
end | |
@inbounds for j in 2:N-1 | |
i = N | |
du[end,j,2] = D2*(2u[i-1,j,2] + u[i,j+1,2] + u[i,j-1,2] - 4u[i,j,2]) + | |
a*u[i,j,1]^2 - β*u[i,j,2] | |
end | |
@inbounds for i in 2:N-1 | |
j = 1 | |
du[i,1,1] = D1*(u[i-1,j,1] + u[i+1,j,1] + 2u[i,j+1,1] - 4u[i,j,1]) + | |
a*u[i,j,1]^2/u[i,j,2] + Abar - α*u[i,j,1] | |
end | |
@inbounds for i in 2:N-1 | |
j = 1 | |
du[i,1,2] = D2*(u[i-1,j,2] + u[i+1,j,2] + 2u[i,j+1,2] - 4u[i,j,2]) + | |
a*u[i,j,1]^2 - β*u[i,j,2] | |
end | |
@inbounds for i in 2:N-1 | |
j = N | |
du[i,end,1] = D1*(u[i-1,j,1] + u[i+1,j,1] + 2u[i,j-1,1] - 4u[i,j,1]) + | |
a*u[i,j,1]^2/u[i,j,2] + Abar - α*u[i,j,1] | |
end | |
@inbounds for i in 2:N-1 | |
j = N | |
du[i,end,2] = D2*(u[i-1,j,2] + u[i+1,j,2] + 2u[i,j-1,2] - 4u[i,j,2]) + | |
a*u[i,j,1]^2 - β*u[i,j,2] | |
end | |
@inbounds begin | |
i = 1; j = 1 | |
du[1,1,1] = D1*(2u[i+1,j,1] + 2u[i,j+1,1] - 4u[i,j,1]) + | |
a*u[i,j,1]^2/u[i,j,2] + Abar - α*u[i,j,1] | |
du[1,1,2] = D2*(2u[i+1,j,2] + 2u[i,j+1,2] - 4u[i,j,2]) + | |
a*u[i,j,1]^2 - β*u[i,j,2] | |
i = 1; j = N | |
du[1,N,1] = D1*(2u[i+1,j,1] + 2u[i,j-1,1] - 4u[i,j,1]) + | |
a*u[i,j,1]^2/u[i,j,2] + Abar - α*u[i,j,1] | |
du[1,N,2] = D2*(2u[i+1,j,2] + 2u[i,j-1,2] - 4u[i,j,2]) + | |
a*u[i,j,1]^2 - β*u[i,j,2] | |
i = N; j = 1 | |
du[N,1,1] = D1*(2u[i-1,j,1] + 2u[i,j+1,1] - 4u[i,j,1]) + | |
a*u[i,j,1]^2/u[i,j,2] + Abar - α*u[i,j,1] | |
du[N,1,2] = D2*(2u[i-1,j,2] + 2u[i,j+1,2] - 4u[i,j,2]) + | |
a*u[i,j,1]^2 - β*u[i,j,2] | |
i = N; j = N | |
du[end,end,1] = D1*(2u[i-1,j,1] + 2u[i,j-1,1] - 4u[i,j,1]) + | |
a*u[i,j,1]^2/u[i,j,2] + Abar - α*u[i,j,1] | |
du[end,end,2] = D2*(2u[i-1,j,2] + 2u[i,j-1,2] - 4u[i,j,2]) + | |
a*u[i,j,1]^2 - β*u[i,j,2] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment