Skip to content

Commit

Permalink
update PT coefs inside iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-de-montserrat committed Aug 16, 2024
1 parent dcc79be commit d3b9e85
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/ext/AMDGPU/2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions src/ext/AMDGPU/3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions src/ext/CUDA/2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions src/ext/CUDA/3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions src/thermal_diffusion/DiffusionPT_coefficients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/thermal_diffusion/DiffusionPT_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)...,
Expand Down

0 comments on commit d3b9e85

Please sign in to comment.