Skip to content

Commit

Permalink
WIP inclusion test
Browse files Browse the repository at this point in the history
  • Loading branch information
utkinis committed Aug 10, 2023
1 parent 9cc5e1b commit 914373a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
25 changes: 13 additions & 12 deletions scripts_future_API/tm_stokes_wip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ boundary_conditions = (
r = 0.7
re_mech = 5π
lτ_re_m = minimum(extent(grid)) / re_mech
vdτ = minimum(spacing(grid)) / sqrt(5.1)
vdτ = minimum(spacing(grid)) / sqrt(8.1)
θ_dτ = lτ_re_m * (r + 4 / 3) / vdτ
dτ_r = 1.0 ./ (θ_dτ .+ 1.0)
nudτ = vdτ * lτ_re_m
Expand All @@ -48,8 +48,8 @@ other_fields = (
A = Field(backend, grid, Center()),
)

init_incl(x, y, z, x0, y0, z0, r, ηi, ηm) = ifelse((x-x0)^2 + (y-y0)^2 + (z-z0)^2 < r^2, ηi, ηm)
set!(other_fields.A, grid, init_incl; continuous = true, parameters = (x0 = 0.0, y0 = 0.0, z0 = 0.5, r = 0.2, ηi = 1e-1, ηm = 1.0))
init_incl(x, y, z, x0, y0, z0, r, Ai, Am) = ifelse((x-x0)^2 + (y-y0)^2 + (z-z0)^2 < r^2, Ai, Am)
set!(other_fields.A, grid, init_incl; continuous = true, parameters = (x0 = 0.0, y0 = 0.0, z0 = 0.5, r = 0.2, Ai = 1e1, Am = 1.0))

model = IsothermalFullStokesModel(;
backend,
Expand All @@ -60,6 +60,12 @@ model = IsothermalFullStokesModel(;
other_fields
)

fig = Figure(resolution=(1000,1000), fontsize=32)
ax = Axis(fig[1,1][1,1]; aspect=DataAspect(), xlabel="x", ylabel="y")

plt = heatmap!(ax, xcenters(grid), ycenters(grid), interior(model.fields.Pr)[:, :, size(grid,3)÷2]; colormap=:turbo)
Colorbar(fig[1,1][1,2], plt)

set!(model.fields.Pr, 0.0)
foreach(x -> set!(x, 0.0), model.fields.τ)
Isothermal.apply_bcs!(model.backend, model.grid, model.fields, model.boundary_conditions.stress)
Expand All @@ -74,17 +80,12 @@ Isothermal.apply_bcs!(model.backend, model.grid, model.fields, model.boundary_co
set!(model.fields.η, other_fields.A)
extrapolate!(data(model.fields.η))


for it in 1:100
advance_iteration!(model, 0.0, 1.0; async = false)
if it % 10 == 0
plt[3][] = interior(model.fields.Pr)[:, :, size(grid,3)÷2]
yield()
end
end

fig = Figure(resolution=(1000,1000), fontsize=32)
ax = Axis(fig[1,1][1,1]; aspect=DataAspect(), xlabel="x", ylabel="y")

plt = heatmap!(ax, xcenters(grid), ycenters(grid), interior(model.fields.Pr)[:, :, size(grid,3)÷2]; colormap=:turbo)
Colorbar(fig[1,1][1,2], plt)

plt[3][] = interior(model.fields.Pr)[:, :, size(grid,3)÷2]

yield()
2 changes: 1 addition & 1 deletion src/models/full_stokes/isothermal/isothermal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function advance_iteration!(model::IsothermalFullStokesModel, t, Δt; async = tr
set_bcs!(bcs) = apply_bcs!(model.backend, model.grid, model.fields, bcs)

# stress
update_σ!(backend, 256, (nx, ny, nz))(interior(Pr), interior(τ), V, η, Δτ, Δ)
update_σ!(backend, 256, (nx+1, ny+1, nz+1))(interior(Pr), interior(τ), V, η, Δτ, Δ)
set_bcs!(model.boundary_conditions.stress)
# velocity
update_V!(backend, 256, (nx + 1, ny + 1, nz + 1))(interior(V), Pr, τ, η, Δτ, Δ)
Expand Down
18 changes: 12 additions & 6 deletions src/models/full_stokes/isothermal/kernels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ end
@kernel function update_σ!(Pr, τ, V, η, Δτ, Δ)
ix, iy, iz = @index(Global, NTuple)
@inbounds if checkbounds(Bool, Pr, ix, iy, iz)
ε̇xx = @∂_x(V.x) / Δ.x
ε̇yy = @∂_y(V.y) / Δ.y
ε̇zz = @∂_z(V.z) / Δ.z
ε̇xx = @∂_xi(V.x) / Δ.x
ε̇yy = @∂_yi(V.y) / Δ.y
ε̇zz = @∂_zi(V.z) / Δ.z
∇V = ε̇xx + ε̇yy + ε̇zz
# hydrostatic
@all(Pr) -= ∇V * @inn(η) * Δτ.Pr
Expand All @@ -23,13 +23,19 @@ end
@all.zz) -= (@all.zz) - 2.0 * @inn(η) * (ε̇zz - ∇V / 3.0)) * Δτ.τ.zz
end
@inbounds if checkbounds(Bool, τ.xy, ix, iy, iz)
@all.xy) -= (@all.xy) - @av_xy(η) * (@∂_x(V.y) / Δ.x + @∂_y(V.x) / Δ.y)) * Δτ.τ.xy
exy = (V.y[ix+1, iy, iz+1] - V.y[ix, iy, iz+1]) / Δ.x +
(V.x[ix, iy+1, iz+1] - V.x[ix, iy, iz+1]) / Δ.y
@all.xy) -= (@all.xy) - @av_xyi(η) * exy) * Δτ.τ.xy
end
@inbounds if checkbounds(Bool, τ.xz, ix, iy, iz)
@all.xz) -= (@all.xz) - @av_xz(η) * (@∂_x(V.z) / Δ.x + @∂_z(V.x) / Δ.z)) * Δτ.τ.xz
exz = (V.z[ix+1, iy+1, iz ] - V.z[ix, iy+1, iz]) / Δ.x +
(V.x[ix , iy+1, iz+1] - V.x[ix, iy+1, iz]) / Δ.z
@all.xz) -= (@all.xz) - @av_xzi(η) * exz) * Δτ.τ.xz
end
@inbounds if checkbounds(Bool, τ.yz, ix, iy, iz)
@all.yz) -= (@all.yz) - @av_yz(η) * (@∂_y(V.z) / Δ.y + @∂_z(V.y) / Δ.z)) * Δτ.τ.yz
eyz = (V.z[ix+1, iy+1, iz ] - V.z[ix+1, iy, iz]) / Δ.y +
(V.y[ix+1, iy , iz+1] - V.y[ix+1, iy, iz]) / Δ.z
@all.yz) -= (@all.yz) - @av_yzi(η) * eyz) * Δτ.τ.yz
end
end

Expand Down

0 comments on commit 914373a

Please sign in to comment.