-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add displacement struct * ext: displacements * rework and test displacement * format * remove line * fixup
- Loading branch information
1 parent
c9590b8
commit 8f4600a
Showing
11 changed files
with
193 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
function velocity2displacement!(stokes::JustRelax.StokesArrays, dt) | ||
velocity2displacement!(stokes, backend(stokes), dt) | ||
return nothing | ||
end | ||
|
||
function velocity2displacement!(stokes::JustRelax.StokesArrays, ::CPUBackendTrait, dt) | ||
return _velocity2displacement!(stokes, dt) | ||
end | ||
|
||
function _velocity2displacement!(stokes::JustRelax.StokesArrays, dt) | ||
ni = size(stokes.P) | ||
(; V, U) = stokes | ||
@parallel (@idx ni .+ 2) _velocity2displacement!( | ||
V.Vx, V.Vy, V.Vz, U.Ux, U.Uy, U.Uz, 1 / dt | ||
) | ||
return nothing | ||
end | ||
|
||
@parallel_indices (I...) function _velocity2displacement!(Vx, Vy, Vz, Ux, Uy, Uz, _dt) | ||
if all(I .≤ size(Ux)) | ||
Ux[I...] = Vx[I...] * _dt | ||
end | ||
if all(I .≤ size(Uy)) | ||
Uy[I...] = Vy[I...] * _dt | ||
end | ||
if !isnothing(Vz) && all(I .≤ size(Uz)) | ||
Uz[I...] = Vz[I...] * _dt | ||
end | ||
return nothing | ||
end | ||
|
||
function displacement2velocity!(stokes::JustRelax.StokesArrays, dt) | ||
displacement2velocity!(stokes, backend(stokes), dt) | ||
return nothing | ||
end | ||
|
||
function displacement2velocity!(stokes::JustRelax.StokesArrays, ::CPUBackendTrait, dt) | ||
return _displacement2velocity!(stokes, dt) | ||
end | ||
|
||
function _displacement2velocity!(stokes::JustRelax.StokesArrays, dt) | ||
ni = size(stokes.P) | ||
(; V, U) = stokes | ||
@parallel (@idx ni .+ 2) _displacement2velocity!(U.Ux, U.Uy, U.Uz, V.Vx, V.Vy, V.Vz, dt) | ||
return nothing | ||
end | ||
|
||
@parallel_indices (I...) function _displacement2velocity!(Ux, Uy, Uz, Vx, Vy, Vz, dt) | ||
if all(I .≤ size(Ux)) | ||
Vx[I...] = Ux[I...] * dt | ||
end | ||
if all(I .≤ size(Uy)) | ||
Vy[I...] = Uy[I...] * dt | ||
end | ||
if !isnothing(Vz) && all(I .≤ size(Uz)) | ||
Vz[I...] = Uz[I...] * dt | ||
end | ||
return nothing | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters