Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update convection mini-apps #67

Merged
merged 7 commits into from
Nov 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
2D convection miniapp
albert-de-montserrat committed Nov 6, 2023
commit 31fefa382c63aa2f0f24c38cb27a31502218cb72
14 changes: 9 additions & 5 deletions miniapps/convection/GlobalConvection2D.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using JustRelax

# setup ParallelStencil.jl environment
model = PS_Setup(:gpu, Float64, 2)
model = PS_Setup(:threads, Float64, 2)
environment!(model)

using Printf, LinearAlgebra, GeoParams, GLMakie, SpecialFunctions
@@ -164,7 +164,7 @@ function thermal_convection2D(; ar=8, ny=16, nx=ny*8, figdir="figs2D", thermal_p
# STOKES ---------------------------------------------
# Allocate arrays needed for every Stokes problem
stokes = StokesArrays(ni, ViscoElastic)
pt_stokes = PTStokesCoeffs(li, di; ϵ=1e-4, CFL = 1.0 / √2.1)
pt_stokes = PTStokesCoeffs(li, di; ϵ=1e-4, CFL = 0.8 / √2.1)
# Buoyancy forces
ρg = @zeros(ni...), @zeros(ni...)
for _ in 1:2
@@ -176,7 +176,10 @@ function thermal_convection2D(; ar=8, ny=16, nx=ny*8, figdir="figs2D", thermal_p
η = @ones(ni...)
depth = PTArray([y for x in xci[1], y in xci[2]])
args = (; T = thermal.Tc, P = stokes.P, depth = depth, dt = Inf)
@parallel (@idx ni) compute_viscosity!(η, 1, 1e-15, args, rheology)
viscosity_cutoff = 1e18, 1e23
@parallel (@idx ni) compute_viscosity!(
η, 1.0, @strain(stokes)..., args, rheology, viscosity_cutoff
)
η_vep = deepcopy(η)
# Boundary conditions
flow_bcs = FlowBoundaryConditions(;
@@ -220,12 +223,13 @@ function thermal_convection2D(; ar=8, ny=16, nx=ny*8, figdir="figs2D", thermal_p
ρg,
η,
η_vep,
rheology_plastic,
rheology,
args,
dt,
igg;
iterMax=250e3,
iterMax=50e3,
nout=1e3,
viscosity_cutoff = viscosity_cutoff
);
dt = compute_dt(stokes, di, dt_diff, igg)
# ------------------------------
4 changes: 4 additions & 0 deletions src/stokes/Stokes2D.jl
Original file line number Diff line number Diff line change
@@ -355,6 +355,7 @@ function JustRelax.solve!(
# solver loop
wtime0 = 0.0
λ = @zeros(ni...)
θ = @zeros(ni...)
while iter < 2 || (err > ϵ && iter ≤ iterMax)
wtime0 += @elapsed begin
@parallel (@idx ni) compute_∇V!(stokes.∇V, @velocity(stokes)..., _di...)
@@ -381,6 +382,7 @@ function JustRelax.solve!(
@tensor(stokes.τ_o),
@strain(stokes),
stokes.P,
θ,
η,
η_vep,
λ,
@@ -436,6 +438,8 @@ function JustRelax.solve!(
end
end

stokes.P .= θ

return (
iter=iter,
err_evo1=err_evo1,
9 changes: 7 additions & 2 deletions src/stokes/StressKernels.jl
Original file line number Diff line number Diff line change
@@ -263,6 +263,7 @@ end
τ_old, # shear @ centers
ε, # shear @ vertices
P,
θ,
η,
η_vep,
λ,
@@ -277,12 +278,16 @@ end
dτ_r = compute_dτ_r(θ_dτ, ηij, _Gdt)

# get plastic paremeters (if any...)
is_pl, C, sinϕ, η_reg = plastic_params(rheology[1])
plastic_parameters = (; is_pl, C, sinϕ, η_reg)
is_pl, C, sinϕ, cosϕ, sinψ, η_reg = plastic_params_phase(rheology, 1)
# plastic volumetric change K*dt*sinϕ*sinψ
K = get_bulkmodulus(rheology[1])
volume = isinf(K) ? 0.0 : K * dt * sinϕ * sinψ
plastic_parameters = (; is_pl, C, sinϕ, cosϕ, η_reg, volume)

_compute_τ_nonlinear!(
τ, τII, τ_old, ε, P, ηij, η_vep, λ, dτ_r, _Gdt, plastic_parameters, I...
)
θ[I...] = P[I...] + (isinf(K) ? 0.0 : K * dt * λ[I...] * sinψ)

return nothing
end