From dcc79bec587302437451c7084acad75f3cae5c25 Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Fri, 16 Aug 2024 12:05:05 +0200 Subject: [PATCH 1/9] implicit PT update for heat diffusion --- src/thermal_diffusion/DiffusionPT_kernels.jl | 112 ++++++++++++++++--- 1 file changed, 98 insertions(+), 14 deletions(-) diff --git a/src/thermal_diffusion/DiffusionPT_kernels.jl b/src/thermal_diffusion/DiffusionPT_kernels.jl index 93b03fed..f3ae2d8c 100644 --- a/src/thermal_diffusion/DiffusionPT_kernels.jl +++ b/src/thermal_diffusion/DiffusionPT_kernels.jl @@ -371,6 +371,83 @@ end return nothing end +# @parallel_indices (i, j) function update_T!( +# T::AbstractArray{_T,2}, Told, qTx, qTy, H, shear_heating, ρCp, dτ_ρ, _dt, _dx, _dy +# ) where {_T} +# nx, ny = size(ρCp) + +# d_xa(A) = _d_xa(A, i, j, _dx) +# d_ya(A) = _d_ya(A, i, j, _dy) +# #! format: off +# function av(A) +# ( +# A[clamp(i - 1, 1, nx), clamp(j - 1, 1, ny)] + +# A[clamp(i - 1, 1, nx), j] + +# A[i, clamp(j - 1, 1, ny)] + +# A[i, j] +# ) * 0.25 +# end +# #! format: on + +# T[i + 1, j + 1] += +# av(dτ_ρ) * ( +# (-(d_xa(qTx) + d_ya(qTy))) - +# av(ρCp) * (T[i + 1, j + 1] - Told[i + 1, j + 1]) * _dt + +# av(H) + +# av(shear_heating) +# ) +# return nothing +# end + + +# @parallel_indices (i, j) function update_T!( +# T::AbstractArray{_T,2}, +# Told, +# qTx, +# qTy, +# H, +# shear_heating, +# adiabatic, +# rheology, +# phase, +# dτ_ρ, +# _dt, +# _dx, +# _dy, +# args::NamedTuple, +# ) where {_T} +# nx, ny = size(args.P) + +# i0 = clamp(i - 1, 1, nx) +# i1 = clamp(i, 1, nx) +# j0 = clamp(j - 1, 1, ny) +# j1 = clamp(j, 1, ny) + +# d_xa(A) = _d_xa(A, i, j, _dx) +# d_ya(A) = _d_ya(A, i, j, _dy) +# av(A) = (A[i0, j0] + A[i0, j1] + A[i1, j0] + A[i1, j1]) * 0.25 + +# T_ij = T[i + 1, j + 1] +# args_ij = (; T=T_ij, P=av(args.P)) + +# ρCp = +# ( +# compute_ρCp(rheology, getindex_phase(phase, i0, j0), args_ij) + +# compute_ρCp(rheology, getindex_phase(phase, i0, j1), args_ij) + +# compute_ρCp(rheology, getindex_phase(phase, i1, j0), args_ij) + +# compute_ρCp(rheology, getindex_phase(phase, i1, j1), args_ij) +# ) * 0.25 + +# T[i + 1, j + 1] += +# av(dτ_ρ) * ( +# (-(d_xa(qTx) + d_ya(qTy))) - ρCp * (T_ij - Told[i + 1, j + 1]) * _dt + +# av(H) + +# av(shear_heating) + +# adiabatic[i, j] * T[i + 1, j + 1] +# ) +# return nothing +# end + @parallel_indices (i, j) function update_T!( T::AbstractArray{_T,2}, Told, qTx, qTy, H, shear_heating, ρCp, dτ_ρ, _dt, _dx, _dy ) where {_T} @@ -389,13 +466,16 @@ end end #! format: on - T[i + 1, j + 1] += - av(dτ_ρ) * ( - (-(d_xa(qTx) + d_ya(qTy))) - - av(ρCp) * (T[i + 1, j + 1] - Told[i + 1, j + 1]) * _dt + - av(H) + - av(shear_heating) - ) + T[i + 1, j + 1] = + ( + av(dτ_ρ) * ( + -(d_xa(qTx) + d_ya(qTy)) + + Told[i + 1, j + 1] * av(ρCp) * _dt + + av(H) + + av(shear_heating) + ) + T[i + 1, j + 1] + ) / (one(_T) + av(dτ_ρ) * av(ρCp) * _dt) + return nothing end @@ -437,13 +517,17 @@ end compute_ρCp(rheology, getindex_phase(phase, i1, j1), args_ij) ) * 0.25 - T[i + 1, j + 1] += - av(dτ_ρ) * ( - (-(d_xa(qTx) + d_ya(qTy))) - ρCp * (T_ij - Told[i + 1, j + 1]) * _dt + - av(H) + - av(shear_heating) + - adiabatic[i, j] * T[i + 1, j + 1] - ) + T[i + 1, j + 1] = + ( + av(dτ_ρ) * ( + -(d_xa(qTx) + d_ya(qTy)) + + Told[i + 1, j + 1] * ρCp * _dt + + av(H) + + av(shear_heating) + + adiabatic[i, j] * T[i + 1, j + 1] + ) + T[i + 1, j + 1] + ) / (one(_T) + av(dτ_ρ) * ρCp * _dt) + return nothing end From d3b9e85d64c2e111f818fac75c8120e15f6d9a23 Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Fri, 16 Aug 2024 14:28:57 +0200 Subject: [PATCH 2/9] update PT coefs inside iterations --- src/ext/AMDGPU/2D.jl | 24 +++++++++++++++++++ src/ext/AMDGPU/3D.jl | 24 +++++++++++++++++++ src/ext/CUDA/2D.jl | 24 +++++++++++++++++++ src/ext/CUDA/3D.jl | 24 +++++++++++++++++++ .../DiffusionPT_coefficients.jl | 24 +++++++++++++++++++ src/thermal_diffusion/DiffusionPT_solver.jl | 1 + 6 files changed, 121 insertions(+) diff --git a/src/ext/AMDGPU/2D.jl b/src/ext/AMDGPU/2D.jl index 28093b54..aef41d40 100644 --- a/src/ext/AMDGPU/2D.jl +++ b/src/ext/AMDGPU/2D.jl @@ -85,6 +85,30 @@ function JR2D.PTThermalCoeffs( return PTThermalCoeffs(rheology, args, dt, ni, di, li; ϵ=ϵ, CFL=CFL) end +function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function JR3D. update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + # Boundary conditions function JR2D.flow_bcs!( ::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions diff --git a/src/ext/AMDGPU/3D.jl b/src/ext/AMDGPU/3D.jl index 112347d2..c03ba3b7 100644 --- a/src/ext/AMDGPU/3D.jl +++ b/src/ext/AMDGPU/3D.jl @@ -85,6 +85,30 @@ function JR3D.PTThermalCoeffs( return PTThermalCoeffs(rheology, args, dt, ni, di, li; ϵ=ϵ, CFL=CFL) end +function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function JR3D. update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + # Boundary conditions function JR3D.flow_bcs!( ::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions diff --git a/src/ext/CUDA/2D.jl b/src/ext/CUDA/2D.jl index cbe74022..981f3e9d 100644 --- a/src/ext/CUDA/2D.jl +++ b/src/ext/CUDA/2D.jl @@ -84,6 +84,30 @@ function JR2D.PTThermalCoeffs( return PTThermalCoeffs(rheology, args, dt, ni, di, li; ϵ=ϵ, CFL=CFL) end +function JR2D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, phase_ratios, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function JR2D. update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function JR2D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, ::Nothing, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + # Boundary conditions function JR2D.flow_bcs!( ::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions diff --git a/src/ext/CUDA/3D.jl b/src/ext/CUDA/3D.jl index 7013245a..7056f533 100644 --- a/src/ext/CUDA/3D.jl +++ b/src/ext/CUDA/3D.jl @@ -95,6 +95,30 @@ function JR3D.update_pt_thermal_arrays!( return nothing end +function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, phase_ratios, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function JR3D. update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, ::Nothing, args, dt) where {T} + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + # Boundary conditions function JR3D.flow_bcs!( ::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions diff --git a/src/thermal_diffusion/DiffusionPT_coefficients.jl b/src/thermal_diffusion/DiffusionPT_coefficients.jl index acd809c0..793f8fa2 100644 --- a/src/thermal_diffusion/DiffusionPT_coefficients.jl +++ b/src/thermal_diffusion/DiffusionPT_coefficients.jl @@ -121,3 +121,27 @@ function _compute_pt_thermal_arrays!( return nothing end + +function update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs, rheology, phase_ratios, args, dt) + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs, rheology, args, dt) + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end + +function update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs, rheology, ::Nothing, args, dt) + ni = size(pt_thermal.dτ_ρ) + @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + ) + return nothing +end \ No newline at end of file diff --git a/src/thermal_diffusion/DiffusionPT_solver.jl b/src/thermal_diffusion/DiffusionPT_solver.jl index dc4b76df..5f2bb886 100644 --- a/src/thermal_diffusion/DiffusionPT_solver.jl +++ b/src/thermal_diffusion/DiffusionPT_solver.jl @@ -147,6 +147,7 @@ function _heatdiffusion_PT!( while err > ϵ && iter < iterMax wtime0 += @elapsed begin + update_thermal_coeffs!(pt_thermal, rheology, phase, args, dt) @parallel flux_range(ni...) compute_flux!( @qT(thermal)..., @qT2(thermal)..., From d07abaab079bfb77a91e42e61a73670d3f1bba7d Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Fri, 16 Aug 2024 14:48:52 +0200 Subject: [PATCH 3/9] 3D implicite PT update --- .../DiffusionPT_coefficients.jl | 6 +- src/thermal_diffusion/DiffusionPT_kernels.jl | 111 +++--------------- 2 files changed, 22 insertions(+), 95 deletions(-) diff --git a/src/thermal_diffusion/DiffusionPT_coefficients.jl b/src/thermal_diffusion/DiffusionPT_coefficients.jl index 793f8fa2..1189f21c 100644 --- a/src/thermal_diffusion/DiffusionPT_coefficients.jl +++ b/src/thermal_diffusion/DiffusionPT_coefficients.jl @@ -124,7 +124,7 @@ end function update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs, rheology, phase_ratios, args, dt) ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) ) return nothing @@ -132,7 +132,7 @@ end function update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs, rheology, args, dt) ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) ) return nothing @@ -140,7 +140,7 @@ end function update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs, rheology, ::Nothing, args, dt) ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) ) return nothing diff --git a/src/thermal_diffusion/DiffusionPT_kernels.jl b/src/thermal_diffusion/DiffusionPT_kernels.jl index f3ae2d8c..6734affa 100644 --- a/src/thermal_diffusion/DiffusionPT_kernels.jl +++ b/src/thermal_diffusion/DiffusionPT_kernels.jl @@ -127,14 +127,15 @@ end d_za(A) = _d_za(A, I..., _dz) I1 = I .+ 1 - T[I1...] += - av(dτ_ρ) * ( - (-(d_xa(qTx) + d_ya(qTy) + d_za(qTz))) - - av(ρCp) * (T[I1...] - Told[I1...]) * _dt - ) + - av(H) + - av(shear_heating) - + T[I1...] = + ( + av(dτ_ρ) * ( + -(d_xa(qTx) + d_ya(qTy) + d_za(qTz)) + + Told[I1...] * av(ρCp) * _dt + + av(H) + + av(shear_heating) + ) + T[I1...] + ) / (one(_T) + av(dτ_ρ) * av(ρCp) * _dt) return nothing end @@ -166,16 +167,18 @@ end T_ijk = T[I...] args_ijk = (; T=T_ijk, P=av(args.P)) phase_ijk = getindex_phase(phase, i, j, k) + ρCp = compute_ρCp(rheology, phase_ijk, args_ijk) T[I...] = - T_ijk + - av(dτ_ρ) * ( - (-(d_xa(qTx) + d_ya(qTy) + d_za(qTz))) - - compute_ρCp(rheology, phase_ijk, args_ijk) * (T_ijk - Told[I...]) * _dt + - av(H) + - av(shear_heating) + - adiabatic[i, j, k] * T_ijk - ) + ( + av(dτ_ρ) * ( + -(d_xa(qTx) + d_ya(qTy) + d_za(qTz)) + + Told[I...] * ρCp * _dt + + av(H) + + av(shear_heating) + + adiabatic[i, j] * T_ijk + ) + T_ijk + ) / (one(_T) + av(dτ_ρ) * ρCp * _dt) return nothing end @@ -371,82 +374,6 @@ end return nothing end -# @parallel_indices (i, j) function update_T!( -# T::AbstractArray{_T,2}, Told, qTx, qTy, H, shear_heating, ρCp, dτ_ρ, _dt, _dx, _dy -# ) where {_T} -# nx, ny = size(ρCp) - -# d_xa(A) = _d_xa(A, i, j, _dx) -# d_ya(A) = _d_ya(A, i, j, _dy) -# #! format: off -# function av(A) -# ( -# A[clamp(i - 1, 1, nx), clamp(j - 1, 1, ny)] + -# A[clamp(i - 1, 1, nx), j] + -# A[i, clamp(j - 1, 1, ny)] + -# A[i, j] -# ) * 0.25 -# end -# #! format: on - -# T[i + 1, j + 1] += -# av(dτ_ρ) * ( -# (-(d_xa(qTx) + d_ya(qTy))) - -# av(ρCp) * (T[i + 1, j + 1] - Told[i + 1, j + 1]) * _dt + -# av(H) + -# av(shear_heating) -# ) -# return nothing -# end - - -# @parallel_indices (i, j) function update_T!( -# T::AbstractArray{_T,2}, -# Told, -# qTx, -# qTy, -# H, -# shear_heating, -# adiabatic, -# rheology, -# phase, -# dτ_ρ, -# _dt, -# _dx, -# _dy, -# args::NamedTuple, -# ) where {_T} -# nx, ny = size(args.P) - -# i0 = clamp(i - 1, 1, nx) -# i1 = clamp(i, 1, nx) -# j0 = clamp(j - 1, 1, ny) -# j1 = clamp(j, 1, ny) - -# d_xa(A) = _d_xa(A, i, j, _dx) -# d_ya(A) = _d_ya(A, i, j, _dy) -# av(A) = (A[i0, j0] + A[i0, j1] + A[i1, j0] + A[i1, j1]) * 0.25 - -# T_ij = T[i + 1, j + 1] -# args_ij = (; T=T_ij, P=av(args.P)) - -# ρCp = -# ( -# compute_ρCp(rheology, getindex_phase(phase, i0, j0), args_ij) + -# compute_ρCp(rheology, getindex_phase(phase, i0, j1), args_ij) + -# compute_ρCp(rheology, getindex_phase(phase, i1, j0), args_ij) + -# compute_ρCp(rheology, getindex_phase(phase, i1, j1), args_ij) -# ) * 0.25 - -# T[i + 1, j + 1] += -# av(dτ_ρ) * ( -# (-(d_xa(qTx) + d_ya(qTy))) - ρCp * (T_ij - Told[i + 1, j + 1]) * _dt + -# av(H) + -# av(shear_heating) + -# adiabatic[i, j] * T[i + 1, j + 1] -# ) -# return nothing -# end @parallel_indices (i, j) function update_T!( T::AbstractArray{_T,2}, Told, qTx, qTy, H, shear_heating, ρCp, dτ_ρ, _dt, _dx, _dy From 626fd419dc5840cd8599dd18917be181d7880dd4 Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Fri, 16 Aug 2024 15:13:44 +0200 Subject: [PATCH 4/9] update tests --- test/test_diffusion2D.jl | 4 ++-- test/test_diffusion2D_multiphase.jl | 2 +- test/test_diffusion3D.jl | 4 ++-- test/test_diffusion3D_multiphase.jl | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_diffusion2D.jl b/test/test_diffusion2D.jl index d3891829..e9354188 100644 --- a/test/test_diffusion2D.jl +++ b/test/test_diffusion2D.jl @@ -74,7 +74,7 @@ function diffusion_2D(; nx=32, ny=32, lx=100e3, ly=100e3, ρ0=3.3e3, Cp0=1.2e3, ) # fields needed to compute density on the fly P = @zeros(ni...) - args = (; P=P) + args = (; P=P, T=@zeros(ni.+1...)) ## Allocate arrays needed for every Thermal Diffusion thermal = ThermalArrays(backend_JR, ni) @@ -85,7 +85,7 @@ function diffusion_2D(; nx=32, ny=32, lx=100e3, ly=100e3, ρ0=3.3e3, Cp0=1.2e3, K = @fill(K0, ni...) ρCp = @. Cp * ρ - pt_thermal = PTThermalCoeffs(backend_JR, K, ρCp, dt, di, li) + pt_thermal = PTThermalCoeffs(backend_JR, K, ρCp, dt, di, li; CFL = 0.95 / √2.1) thermal_bc = TemperatureBoundaryConditions(; no_flux = (left = true, right = true, top = false, bot = false), ) diff --git a/test/test_diffusion2D_multiphase.jl b/test/test_diffusion2D_multiphase.jl index 49ec80e7..cc39b725 100644 --- a/test/test_diffusion2D_multiphase.jl +++ b/test/test_diffusion2D_multiphase.jl @@ -165,7 +165,7 @@ function diffusion_2D(; nx=32, ny=32, lx=100e3, ly=100e3, Cp0=1.2e3, K0=3.0) # PT coefficients for thermal diffusion args = (; P=P, T=thermal.Tc) pt_thermal = PTThermalCoeffs( - backend_JR, rheology, phase_ratios, args, dt, ni, di, li; ϵ=1e-5, CFL=0.65 / √2 + backend_JR, rheology, phase_ratios, args, dt, ni, di, li; ϵ=1e-5, CFL=0.95 / √2 ) # Time loop diff --git a/test/test_diffusion3D.jl b/test/test_diffusion3D.jl index 41ea255f..ab86c624 100644 --- a/test/test_diffusion3D.jl +++ b/test/test_diffusion3D.jl @@ -89,7 +89,7 @@ function diffusion_3D(; # fields needed to compute density on the fly P = @zeros(ni...) - args = (; P=P) + args = (; P=P, T=@zeros(ni.+1...)) ## Allocate arrays needed for every Thermal Diffusion # general thermal arrays @@ -102,7 +102,7 @@ function diffusion_3D(; ρCp = @. Cp * ρ # Boundary conditions - pt_thermal = PTThermalCoeffs(backend, K, ρCp, dt, di, li; CFL = 0.75 / √3.1) + pt_thermal = PTThermalCoeffs(backend, K, ρCp, dt, di, li; CFL = 0.95 / √3.1) thermal_bc = TemperatureBoundaryConditions(; no_flux = (left = true , right = true , top = false, bot = false, front = true , back = true), ) diff --git a/test/test_diffusion3D_multiphase.jl b/test/test_diffusion3D_multiphase.jl index 255486e2..13bfcd8d 100644 --- a/test/test_diffusion3D_multiphase.jl +++ b/test/test_diffusion3D_multiphase.jl @@ -177,7 +177,7 @@ function diffusion_3D(; # PT coefficients for thermal diffusion args = (; P=P, T=thermal.Tc) - pt_thermal = PTThermalCoeffs(backend_JR, K, ρCp, dt, di, li; CFL = 0.75 / √3.1) + pt_thermal = PTThermalCoeffs(backend_JR, K, ρCp, dt, di, li; CFL = 0.95 / √3.1) t = 0.0 it = 0 From de162b42d662d991b9ca3fab6154b9f017c80585 Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Fri, 16 Aug 2024 15:14:44 +0200 Subject: [PATCH 5/9] format --- src/ext/AMDGPU/2D.jl | 37 ++++++++++++++++--- src/ext/AMDGPU/3D.jl | 37 ++++++++++++++++--- src/ext/CUDA/2D.jl | 37 ++++++++++++++++--- src/ext/CUDA/3D.jl | 37 ++++++++++++++++--- .../DiffusionPT_coefficients.jl | 35 +++++++++++++++--- src/thermal_diffusion/DiffusionPT_kernels.jl | 1 - 6 files changed, 153 insertions(+), 31 deletions(-) diff --git a/src/ext/AMDGPU/2D.jl b/src/ext/AMDGPU/2D.jl index aef41d40..70de1f27 100644 --- a/src/ext/AMDGPU/2D.jl +++ b/src/ext/AMDGPU/2D.jl @@ -85,26 +85,51 @@ function JR2D.PTThermalCoeffs( return PTThermalCoeffs(rheology, args, dt, ni, di, li; ϵ=ϵ, CFL=CFL) end -function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt) where {T} +function JR3D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + phase_ratios.center, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end -function JR3D. update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt) where {T} +function JR3D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end -function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt) where {T} +function JR3D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end diff --git a/src/ext/AMDGPU/3D.jl b/src/ext/AMDGPU/3D.jl index c03ba3b7..d7e1d944 100644 --- a/src/ext/AMDGPU/3D.jl +++ b/src/ext/AMDGPU/3D.jl @@ -85,26 +85,51 @@ function JR3D.PTThermalCoeffs( return PTThermalCoeffs(rheology, args, dt, ni, di, li; ϵ=ϵ, CFL=CFL) end -function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt) where {T} +function JR3D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + phase_ratios.center, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end -function JR3D. update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt) where {T} +function JR3D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end -function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt) where {T} +function JR3D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end diff --git a/src/ext/CUDA/2D.jl b/src/ext/CUDA/2D.jl index 981f3e9d..9c6671ff 100644 --- a/src/ext/CUDA/2D.jl +++ b/src/ext/CUDA/2D.jl @@ -84,26 +84,51 @@ function JR2D.PTThermalCoeffs( return PTThermalCoeffs(rheology, args, dt, ni, di, li; ϵ=ϵ, CFL=CFL) end -function JR2D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, phase_ratios, args, dt) where {T} +function JR2D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, phase_ratios, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + phase_ratios.center, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end -function JR2D. update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, args, dt) where {T} +function JR2D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end -function JR2D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, ::Nothing, args, dt) where {T} +function JR2D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, ::Nothing, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end diff --git a/src/ext/CUDA/3D.jl b/src/ext/CUDA/3D.jl index 7056f533..1fb6a6b5 100644 --- a/src/ext/CUDA/3D.jl +++ b/src/ext/CUDA/3D.jl @@ -95,26 +95,51 @@ function JR3D.update_pt_thermal_arrays!( return nothing end -function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, phase_ratios, args, dt) where {T} +function JR3D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, phase_ratios, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + phase_ratios.center, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end -function JR3D. update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, args, dt) where {T} +function JR3D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end -function JR3D.update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, ::Nothing, args, dt) where {T} +function JR3D.update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, ::Nothing, args, dt +) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end diff --git a/src/thermal_diffusion/DiffusionPT_coefficients.jl b/src/thermal_diffusion/DiffusionPT_coefficients.jl index 1189f21c..2ee4f643 100644 --- a/src/thermal_diffusion/DiffusionPT_coefficients.jl +++ b/src/thermal_diffusion/DiffusionPT_coefficients.jl @@ -122,10 +122,19 @@ function _compute_pt_thermal_arrays!( return nothing end -function update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs, rheology, phase_ratios, args, dt) +function update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs, rheology, phase_ratios, args, dt +) ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + phase_ratios.center, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end @@ -133,15 +142,29 @@ end function update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs, rheology, args, dt) ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing end -function update_thermal_coeffs!(pt_thermal::JustRelax.PTThermalCoeffs, rheology, ::Nothing, args, dt) +function update_thermal_coeffs!( + pt_thermal::JustRelax.PTThermalCoeffs, rheology, ::Nothing, args, dt +) ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) compute_pt_thermal_arrays!( - pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, args, pt_thermal.max_lxyz, pt_thermal.Vpdτ, inv(dt) + pt_thermal.θr_dτ, + pt_thermal.dτ_ρ, + rheology, + args, + pt_thermal.max_lxyz, + pt_thermal.Vpdτ, + inv(dt), ) return nothing -end \ No newline at end of file +end diff --git a/src/thermal_diffusion/DiffusionPT_kernels.jl b/src/thermal_diffusion/DiffusionPT_kernels.jl index 6734affa..281f42b2 100644 --- a/src/thermal_diffusion/DiffusionPT_kernels.jl +++ b/src/thermal_diffusion/DiffusionPT_kernels.jl @@ -374,7 +374,6 @@ end return nothing end - @parallel_indices (i, j) function update_T!( T::AbstractArray{_T,2}, Told, qTx, qTy, H, shear_heating, ρCp, dτ_ρ, _dt, _dx, _dy ) where {_T} From a1ece2ca5a59177a6bc247ef1e94b74bc675ecaf Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Fri, 16 Aug 2024 15:39:31 +0200 Subject: [PATCH 6/9] typo --- src/ext/AMDGPU/2D.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ext/AMDGPU/2D.jl b/src/ext/AMDGPU/2D.jl index 70de1f27..800105e9 100644 --- a/src/ext/AMDGPU/2D.jl +++ b/src/ext/AMDGPU/2D.jl @@ -85,7 +85,7 @@ function JR2D.PTThermalCoeffs( return PTThermalCoeffs(rheology, args, dt, ni, di, li; ϵ=ϵ, CFL=CFL) end -function JR3D.update_thermal_coeffs!( +function JR2D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) @@ -102,7 +102,7 @@ function JR3D.update_thermal_coeffs!( return nothing end -function JR3D.update_thermal_coeffs!( +function JR2D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) @@ -118,7 +118,7 @@ function JR3D.update_thermal_coeffs!( return nothing end -function JR3D.update_thermal_coeffs!( +function JR2D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) From 0d9b06cf0ab737f368e354294fb5eeeaef3da3a0 Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Fri, 16 Aug 2024 15:56:04 +0200 Subject: [PATCH 7/9] ext fixes --- src/ext/AMDGPU/2D.jl | 8 ++++---- src/ext/AMDGPU/3D.jl | 6 +++--- src/ext/CUDA/2D.jl | 6 +++--- src/ext/CUDA/3D.jl | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ext/AMDGPU/2D.jl b/src/ext/AMDGPU/2D.jl index 800105e9..0221e935 100644 --- a/src/ext/AMDGPU/2D.jl +++ b/src/ext/AMDGPU/2D.jl @@ -89,14 +89,14 @@ function JR2D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, phase_ratios.center, args, pt_thermal.max_lxyz, - pt_thermal.Vpdτ, + pt_thermal.Vpdτ,4 inv(dt), ) return nothing @@ -106,7 +106,7 @@ function JR2D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, @@ -122,7 +122,7 @@ function JR2D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, diff --git a/src/ext/AMDGPU/3D.jl b/src/ext/AMDGPU/3D.jl index d7e1d944..e039ad8a 100644 --- a/src/ext/AMDGPU/3D.jl +++ b/src/ext/AMDGPU/3D.jl @@ -89,7 +89,7 @@ function JR3D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, @@ -106,7 +106,7 @@ function JR3D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, @@ -122,7 +122,7 @@ function JR3D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, diff --git a/src/ext/CUDA/2D.jl b/src/ext/CUDA/2D.jl index 9c6671ff..dfb3aaff 100644 --- a/src/ext/CUDA/2D.jl +++ b/src/ext/CUDA/2D.jl @@ -88,7 +88,7 @@ function JR2D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, phase_ratios, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, @@ -105,7 +105,7 @@ function JR2D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, @@ -121,7 +121,7 @@ function JR2D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, ::Nothing, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, diff --git a/src/ext/CUDA/3D.jl b/src/ext/CUDA/3D.jl index 1fb6a6b5..dfbdd21d 100644 --- a/src/ext/CUDA/3D.jl +++ b/src/ext/CUDA/3D.jl @@ -99,7 +99,7 @@ function JR3D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, phase_ratios, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, @@ -116,7 +116,7 @@ function JR3D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, @@ -132,7 +132,7 @@ function JR3D.update_thermal_coeffs!( pt_thermal::JustRelax.PTThermalCoeffs{T,<:CuArray}, rheology, ::Nothing, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) - @parallel (@idx ni) JustRelax2D.compute_pt_thermal_arrays!( + @parallel (@idx ni) compute_pt_thermal_arrays!( pt_thermal.θr_dτ, pt_thermal.dτ_ρ, rheology, From 8145121d8f56a885001055a84100c3970279d511 Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Fri, 16 Aug 2024 15:58:40 +0200 Subject: [PATCH 8/9] typo --- src/ext/AMDGPU/2D.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ext/AMDGPU/2D.jl b/src/ext/AMDGPU/2D.jl index 0221e935..30f71a91 100644 --- a/src/ext/AMDGPU/2D.jl +++ b/src/ext/AMDGPU/2D.jl @@ -96,7 +96,7 @@ function JR2D.update_thermal_coeffs!( phase_ratios.center, args, pt_thermal.max_lxyz, - pt_thermal.Vpdτ,4 + pt_thermal.Vpdτ, inv(dt), ) return nothing From 12af17eb7f8f6f17eb78411ac33accf12d4065ba Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Fri, 16 Aug 2024 16:07:44 +0200 Subject: [PATCH 9/9] AMD ext bug --- src/ext/AMDGPU/2D.jl | 6 +++--- src/ext/AMDGPU/3D.jl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ext/AMDGPU/2D.jl b/src/ext/AMDGPU/2D.jl index 30f71a91..b537f83a 100644 --- a/src/ext/AMDGPU/2D.jl +++ b/src/ext/AMDGPU/2D.jl @@ -86,7 +86,7 @@ function JR2D.PTThermalCoeffs( end function JR2D.update_thermal_coeffs!( - pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt + pt_thermal::JustRelax.PTThermalCoeffs{T,<:ROCArray}, rheology, phase_ratios, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) compute_pt_thermal_arrays!( @@ -103,7 +103,7 @@ function JR2D.update_thermal_coeffs!( end function JR2D.update_thermal_coeffs!( - pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt + pt_thermal::JustRelax.PTThermalCoeffs{T,<:ROCArray}, rheology, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) compute_pt_thermal_arrays!( @@ -119,7 +119,7 @@ function JR2D.update_thermal_coeffs!( end function JR2D.update_thermal_coeffs!( - pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt + pt_thermal::JustRelax.PTThermalCoeffs{T,<:ROCArray}, rheology, ::Nothing, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) compute_pt_thermal_arrays!( diff --git a/src/ext/AMDGPU/3D.jl b/src/ext/AMDGPU/3D.jl index e039ad8a..1b45cac4 100644 --- a/src/ext/AMDGPU/3D.jl +++ b/src/ext/AMDGPU/3D.jl @@ -86,7 +86,7 @@ function JR3D.PTThermalCoeffs( end function JR3D.update_thermal_coeffs!( - pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, phase_ratios, args, dt + pt_thermal::JustRelax.PTThermalCoeffs{T,<:ROCArray}, rheology, phase_ratios, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) compute_pt_thermal_arrays!( @@ -103,7 +103,7 @@ function JR3D.update_thermal_coeffs!( end function JR3D.update_thermal_coeffs!( - pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, args, dt + pt_thermal::JustRelax.PTThermalCoeffs{T,<:ROCArray}, rheology, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) compute_pt_thermal_arrays!( @@ -119,7 +119,7 @@ function JR3D.update_thermal_coeffs!( end function JR3D.update_thermal_coeffs!( - pt_thermal::JustRelax.PTThermalCoeffs{T,<:RocArray}, rheology, ::Nothing, args, dt + pt_thermal::JustRelax.PTThermalCoeffs{T,<:ROCArray}, rheology, ::Nothing, args, dt ) where {T} ni = size(pt_thermal.dτ_ρ) @parallel (@idx ni) compute_pt_thermal_arrays!(