Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
aelligp committed Jul 5, 2024
1 parent 9599ffa commit d8a30a6
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 42 deletions.
10 changes: 5 additions & 5 deletions src/JustRelax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ include("types/phases.jl")
# export PhaseRatio

include("boundaryconditions/types.jl")
export AbstractBoundaryConditions,
TemperatureBoundaryConditions,
AbstractFlowBoundaryConditions,
DisplacementBoundaryConditions,
VelocityBoundaryConditions
export AbstractBoundaryConditions,
TemperatureBoundaryConditions,
AbstractFlowBoundaryConditions,
DisplacementBoundaryConditions,
VelocityBoundaryConditions

include("types/traits.jl")
export BackendTrait, CPUBackendTrait, NonCPUBackendTrait
Expand Down
3 changes: 2 additions & 1 deletion src/Utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ macro displacement(A)
end
end

@inline unpack_displacement(U::JustRelax.Displacement{<:AbstractArray{T,2}}) where {T} = U.Ux, U.Uy
@inline unpack_displacement(U::JustRelax.Displacement{<:AbstractArray{T,2}}) where {T} =
U.Ux, U.Uy
@inline unpack_displacement(U::JustRelax.Displacement{<:AbstractArray{T,3}}) where {T} =
U.Ux, U.Uy, U.Uz

Expand Down
18 changes: 9 additions & 9 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ include("types/displacement.jl")
export velocity2displacement!, displacement2velocity!

include("boundaryconditions/BoundaryConditions.jl")
export AbstractBoundaryConditions,
TemperatureBoundaryConditions,
AbstractFlowBoundaryConditions,
DisplacementBoundaryConditions,
VelocityBoundaryConditions,
flow_bcs!,
thermal_bcs!,
pureshear_bc!,
apply_free_slip!
export AbstractBoundaryConditions,
TemperatureBoundaryConditions,
AbstractFlowBoundaryConditions,
DisplacementBoundaryConditions,
VelocityBoundaryConditions,
flow_bcs!,
thermal_bcs!,
pureshear_bc!,
apply_free_slip!

include("MiniKernels.jl")

Expand Down
20 changes: 16 additions & 4 deletions src/ext/AMDGPU/2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,31 @@ function JR2D.PTThermalCoeffs(
end

# Boundary conditions
function JR2D.flow_bcs!(::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions)
function JR2D.flow_bcs!(
::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions
)
return _flow_bcs!(bcs, @velocity(stokes))
end

function flow_bcs!(::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions)
function flow_bcs!(
::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions
)
return _flow_bcs!(bcs, @velocity(stokes))
end

function JR2D.flow_bcs!(::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions)
function JR2D.flow_bcs!(
::AMDGPUBackendTrait,
stokes::JustRelax.StokesArrays,
bcs::DisplacementBoundaryConditions,
)
return _flow_bcs!(bcs, @displacement(stokes))
end

function flow_bcs!(::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions)
function flow_bcs!(
::AMDGPUBackendTrait,
stokes::JustRelax.StokesArrays,
bcs::DisplacementBoundaryConditions,
)
return _flow_bcs!(bcs, @displacement(stokes))
end

Expand Down
30 changes: 21 additions & 9 deletions src/ext/AMDGPU/3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import JustRelax:
Geometry,
@cell
import JustRelax:
AbstractBoundaryConditions,
TemperatureBoundaryConditions,
AbstractFlowBoundaryConditions,
DisplacementBoundaryConditions,
VelocityBoundaryConditions
AbstractBoundaryConditions,
TemperatureBoundaryConditions,
AbstractFlowBoundaryConditions,
DisplacementBoundaryConditions,
VelocityBoundaryConditions

@init_parallel_stencil(AMDGPU, Float64, 3)

Expand Down Expand Up @@ -86,19 +86,31 @@ function JR3D.PTThermalCoeffs(
end

# Boundary conditions
function JR3D.flow_bcs!(::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions)
function JR3D.flow_bcs!(
::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions
)
return _flow_bcs!(bcs, @velocity(stokes))
end

function flow_bcs!(::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions)
function flow_bcs!(
::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions
)
return _flow_bcs!(bcs, @velocity(stokes))
end

function JR3D.flow_bcs!(::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions)
function JR3D.flow_bcs!(
::AMDGPUBackendTrait,
stokes::JustRelax.StokesArrays,
bcs::DisplacementBoundaryConditions,
)
return _flow_bcs!(bcs, @displacement(stokes))
end

function flow_bcs!(::AMDGPUBackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions)
function flow_bcs!(
::AMDGPUBackendTrait,
stokes::JustRelax.StokesArrays,
bcs::DisplacementBoundaryConditions,
)
return _flow_bcs!(bcs, @displacement(stokes))
end

Expand Down
16 changes: 12 additions & 4 deletions src/ext/CUDA/2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,27 @@ function JR2D.PTThermalCoeffs(
end

# Boundary conditions
function JR2D.flow_bcs!(::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions)
function JR2D.flow_bcs!(
::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions
)
return _flow_bcs!(bcs, @velocity(stokes))
end

function flow_bcs!(::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions)
function flow_bcs!(
::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions
)
return _flow_bcs!(bcs, @velocity(stokes))
end

function JR2D.flow_bcs!(::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions)
function JR2D.flow_bcs!(
::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions
)
return _flow_bcs!(bcs, @displacement(stokes))
end

function flow_bcs!(::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions)
function flow_bcs!(
::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions
)
return _flow_bcs!(bcs, @velocity(stokes))
end

Expand Down
17 changes: 12 additions & 5 deletions src/ext/CUDA/3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import JustRelax:
DisplacementBoundaryConditions,
VelocityBoundaryConditions


@init_parallel_stencil(CUDA, Float64, 3)

include("../../common.jl")
Expand Down Expand Up @@ -97,20 +96,28 @@ function JR3D.update_pt_thermal_arrays!(
end

# Boundary conditions
function JR3D.flow_bcs!(::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions)
function JR3D.flow_bcs!(
::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions
)
return _flow_bcs!(bcs, @velocity(stokes))
end

function flow_bcs!(::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions)
function flow_bcs!(
::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::VelocityBoundaryConditions
)
return _flow_bcs!(bcs, @velocity(stokes))
end

# Boundary conditions
function JR3D.flow_bcs!(::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions)
function JR3D.flow_bcs!(
::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions
)
return _flow_bcs!(bcs, @displacement(stokes))
end

function flow_bcs!(::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions)
function flow_bcs!(
::CUDABackendTrait, stokes::JustRelax.StokesArrays, bcs::DisplacementBoundaryConditions
)
return _flow_bcs!(bcs, @displacement(stokes))
end

Expand Down
13 changes: 8 additions & 5 deletions src/types/displacement.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Velocity to displacement interpolation
velocity2displacement!(stokes, dt) = velocity2displacement!(backend(stokes), stokes, dt)


function velocity2displacement!(::CPUBackendTrait, stokes::JustRelax.StokesArrays, dt)
return _velocity2displacement!(stokes, dt)
end
Expand Down Expand Up @@ -30,7 +29,7 @@ end

# Displacement to velocity interpolation

displacement2velocity!(stokes, dt) = displacement2velocity!(backend(stokes), stokes, dt)
displacement2velocity!(stokes, dt) = displacement2velocity!(backend(stokes), stokes, dt)

function displacement2velocity!(::CPUBackendTrait, stokes::JustRelax.StokesArrays, dt)
return _displacement2velocity!(stokes, dt)
Expand All @@ -39,11 +38,15 @@ end
function _displacement2velocity!(stokes::JustRelax.StokesArrays, dt)
ni = size(stokes.P)
(; V, U) = stokes
@parallel (@idx ni .+ 2) _displacement2velocity_kernel!(U.Ux, U.Uy, U.Uz, V.Vx, V.Vy, V.Vz, 1 / dt)
@parallel (@idx ni .+ 2) _displacement2velocity_kernel!(
U.Ux, U.Uy, U.Uz, V.Vx, V.Vy, V.Vz, 1 / dt
)
return nothing
end

@parallel_indices (I...) function _displacement2velocity_kernel!(Ux, Uy, Uz, Vx, Vy, Vz, _dt)
@parallel_indices (I...) function _displacement2velocity_kernel!(
Ux, Uy, Uz, Vx, Vy, Vz, _dt
)
if all(I .≤ size(Ux))
Vx[I...] = Ux[I...] * _dt
end
Expand All @@ -56,7 +59,7 @@ end
return nothing
end

function displacement2velocity!(stokes,dt, flow_bcs::AbstractFlowBoundaryConditions)
function displacement2velocity!(stokes, dt, flow_bcs::AbstractFlowBoundaryConditions)
if typeof(flow_bcs) <: DisplacementBoundaryConditions
displacement2velocity!(backend(stokes), stokes, dt)
return nothing
Expand Down

0 comments on commit d8a30a6

Please sign in to comment.