Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions src/rheology/GeoParams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ function get_bulk_modulus(args::Vararg{Any, N}) where {N}
end

function get_shear_modulus(args::Vararg{Any, N}) where {N}
Kb = GeoParams.get_G(args...)
if isnan(Kb) || iszero(Kb)
G = GeoParams.get_G(args...)
if isnan(G) || iszero(G)
return Inf
end
return Kb
return G
end

get_thermal_expansion(args::Vararg{Any, N}) where {N} = get_α(args...)
Expand Down
29 changes: 18 additions & 11 deletions src/stokes/PressureKernels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
end

## Compressible
@parallel_indices (I...) function compute_P!(P, P0, RP, ∇V, Q, η, K, dt, r, θ_dτ)
@parallel_indices (I...) function compute_P!(P, P0, RP, ∇V, Q, η, K, G, dt, r, θ_dτ)
@inbounds RP[I...], P[I...] = _compute_P!(
P[I...], P0[I...], ∇V[I...], Q[I...], η[I...], K[I...], dt, r, θ_dτ
P[I...], P0[I...], ∇V[I...], Q[I...], η[I...], K[I...], G[I...], dt, r, θ_dτ
)
return nothing
end
Expand All @@ -20,7 +20,8 @@ end
P, P0, RP, ∇V, Q, η, rheology::NTuple{N, MaterialParams}, phase, dt, r, θ_dτ, args
) where {N}
K = get_bulk_modulus(rheology, phase[I...])
@inbounds RP[I...], P[I...] = _compute_P!(P[I...], P0[I...], ∇V[I...], Q[I...], η[I...], K, dt, r, θ_dτ)
G = get_shear_modulus(rheology, phase[I...])
@inbounds RP[I...], P[I...] = _compute_P!(P[I...], P0[I...], ∇V[I...], Q[I...], η[I...], K, G, dt, r, θ_dτ)
return nothing
end

Expand Down Expand Up @@ -95,7 +96,8 @@ end
::Nothing,
) where {N, C <: JustRelax.CellArray}
K = fn_ratio(get_bulk_modulus, rheology, @cell(phase_ratio[I...]))
@inbounds RP[I...], P[I...] = _compute_P!(P[I...], P0[I...], ∇V[I...], Q[I...], η[I...], K, dt, r, θ_dτ)
G = fn_ratio(get_shear_modulus, rheology, @cell(phase_ratio[I...]))
@inbounds RP[I...], P[I...] = _compute_P!(P[I...], P0[I...], ∇V[I...], Q[I...], η[I...], K, G, dt, r, θ_dτ)
return nothing
end

Expand All @@ -115,7 +117,8 @@ end
melt_fraction,
) where {N, C <: JustRelax.CellArray}
K = fn_ratio(get_bulk_modulus, rheology, @cell(phase_ratio[I...]))
@inbounds RP[I...], P[I...] = _compute_P!(P[I...], P0[I...], ∇V[I...], Q[I...], η[I...], K, dt, r, θ_dτ)
G = fn_ratio(get_shear_modulus, rheology, @cell(phase_ratio[I...]))
@inbounds RP[I...], P[I...] = _compute_P!(P[I...], P0[I...], ∇V[I...], Q[I...], η[I...], K, G, dt, r, θ_dτ)
return nothing
end

Expand All @@ -136,9 +139,10 @@ end
) where {N, C <: JustRelax.CellArray}
@inbounds phase_ratio_I = phase_ratio[I...]
@inbounds K = fn_ratio(get_bulk_modulus, rheology, phase_ratio_I)
@inbounds G = fn_ratio(get_shear_modulus, rheology, phase_ratio_I)
@inbounds α = fn_ratio(get_thermal_expansion, rheology, phase_ratio_I)
@inbounds RP[I...], P[I...] = _compute_P!(
P[I...], P0[I...], ∇V[I...], Q[I...], ΔTc[I...], α, η[I...], K, dt, r, θ_dτ
P[I...], P0[I...], ∇V[I...], Q[I...], ΔTc[I...], α, η[I...], K, G, dt, r, θ_dτ
)
return nothing
end
Expand All @@ -159,9 +163,10 @@ end
melt_fraction,
) where {N, C <: JustRelax.CellArray}
@inbounds K = fn_ratio(get_bulk_modulus, rheology, @cell(phase_ratio[I...]))
@inbounds G = fn_ratio(get_shear_modulus, rheology, @cell(phase_ratio[I...]))
@inbounds α = fn_ratio(get_thermal_expansion, rheology, @cell(phase_ratio[I...]), (; ϕ = melt_fraction[I...]))
@inbounds RP[I...], P[I...] = _compute_P!(
P[I...], P0[I...], ∇V[I...], Q[I...], ΔTc[I...], α, η[I...], K, dt, r, θ_dτ
P[I...], P0[I...], ∇V[I...], Q[I...], ΔTc[I...], α, η[I...], K, G, dt, r, θ_dτ
)
return nothing
end
Expand All @@ -174,21 +179,23 @@ function _compute_P!(P, ∇V, Q, η, dt, r, θ_dτ)
return RP, P
end

function _compute_P!(P, P0, ∇V, Q, η, K, dt, r, θ_dτ)
function _compute_P!(P, P0, ∇V, Q, η, K, G, dt, r, θ_dτ)
_Kdt = inv(K * dt)
_Gdt = inv(G * dt)
_dt = inv(dt)
RP = muladd(-(P - P0), _Kdt, (-∇V + (Q * _dt)))
ψ = inv(inv(r / θ_dτ * η) + _Kdt)
ψ = inv(inv(η) + _Gdt) * r / θ_dτ
P = ((muladd(P0, _Kdt, (-∇V + (Q * _dt)))) * ψ + P) / (1 + _Kdt * ψ)

return RP, P
end

function _compute_P!(P, P0, ∇V, Q, ΔTc, α, η, K, dt, r, θ_dτ)
function _compute_P!(P, P0, ∇V, Q, ΔTc, α, η, K, G, dt, r, θ_dτ)
_Kdt = inv(K * dt)
_Gdt = inv(G * dt)
_dt = inv(dt)
RP = muladd(-(P - P0), _Kdt, (-∇V + (α * (ΔTc * _dt)) + (Q * _dt)))
ψ = inv(inv(r / θ_dτ * η) + _Kdt)
ψ = inv(inv(η) + _Gdt) * r / θ_dτ
P = ((muladd(P0, _Kdt, (-∇V + (α * (ΔTc * _dt)) + (Q * _dt)))) * ψ + P) / (1 + _Kdt * ψ)

return RP, P
Expand Down
5 changes: 3 additions & 2 deletions src/stokes/Stokes2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function _solve!(
@parallel (@idx ni) compute_∇V!(stokes.∇V, @velocity(stokes), _di)

@parallel compute_P!(
stokes.P, stokes.P0, stokes.R.RP, stokes.∇V, stokes.Q, ητ, K, dt, r, θ_dτ
stokes.P, stokes.P0, stokes.R.RP, stokes.∇V, stokes.Q, ητ, K, G, dt, r, θ_dτ
)

@parallel (@idx ni .+ 1) compute_strain_rate!(
Expand Down Expand Up @@ -328,6 +328,7 @@ function _solve!(
# end

Kb = get_Kb(rheology)
G = get_G(rheology)

# errors
err_it1 = 1.0
Expand Down Expand Up @@ -368,7 +369,7 @@ function _solve!(

@parallel (@idx ni) compute_∇V!(stokes.∇V, @velocity(stokes), _di)
@parallel compute_P!(
stokes.P, stokes.P0, stokes.R.RP, stokes.∇V, stokes.Q, η, Kb, dt, r, θ_dτ
stokes.P, stokes.P0, stokes.R.RP, stokes.∇V, stokes.Q, η, Kb, G, dt, r, θ_dτ
)

update_ρg!(ρg[2], rheology, args)
Expand Down
1 change: 1 addition & 0 deletions src/stokes/Stokes3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function _solve!(
stokes.Q,
η,
K,
G,
dt,
pt_stokes.r,
pt_stokes.θ_dτ,
Expand Down
Loading