Skip to content

Commit

Permalink
Refactored repo
Browse files Browse the repository at this point in the history
  • Loading branch information
luraess committed Mar 1, 2021
1 parent 5c9fbbe commit cc6aa13
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 74 deletions.
46 changes: 13 additions & 33 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ version = "0.10.9"

[[Colors]]
deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Reexport"]
git-tree-sha1 = "008d6bc68dea6beb6303fdc37188cb557391ebf2"
git-tree-sha1 = "ac5f2213e56ed8a34a3dd2f681f4df1166b34929"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.4"
version = "0.12.6"

[[Conda]]
deps = ["JSON", "VersionParsing"]
git-tree-sha1 = "7a58bb32ce5d85f8bf7559aa7c2842f9aecf52fc"
git-tree-sha1 = "c0647249d785f1d5139c0cc96db8f6b32f7ec416"
uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d"
version = "1.4.1"
version = "1.5.0"

[[Dates]]
deps = ["Printf"]
Expand Down Expand Up @@ -50,10 +50,6 @@ git-tree-sha1 = "c7aebfecb1a60d59c0fe023a68ec947a208b1e6b"
uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
version = "1.2.0"

[[LibGit2]]
deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

Expand All @@ -66,9 +62,9 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[MacroTools]]
deps = ["Markdown", "Random"]
git-tree-sha1 = "f7d2e3f654af75f01ec49be82c231c382214223a"
git-tree-sha1 = "6a8a2a625ab0dea913aba95c11370589e0239ff0"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.5"
version = "0.5.6"

[[Markdown]]
deps = ["Base64"]
Expand All @@ -78,47 +74,35 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "8077624b3c450b15c087944363606a6ba12f925e"
deps = ["Dates"]
git-tree-sha1 = "50c9a9ed8c714945e01cd53a21007ed3865ed714"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.0.10"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.0.15"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[PyCall]]
deps = ["Conda", "Dates", "Libdl", "LinearAlgebra", "MacroTools", "Serialization", "VersionParsing"]
git-tree-sha1 = "b6dff5fa725eff4f775f472acd86756d6e31fb02"
git-tree-sha1 = "dd1a970b543bd02efce2984582e996af28cab27f"
uuid = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
version = "1.92.1"
version = "1.92.2"

[[PyPlot]]
deps = ["Colors", "LaTeXStrings", "PyCall", "Sockets", "Test", "VersionParsing"]
git-tree-sha1 = "67dde2482fe1a72ef62ed93f8c239f947638e5a2"
uuid = "d330b81b-6aea-500a-939a-2ce795aea3ee"
version = "2.9.0"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Reexport]]
deps = ["Pkg"]
git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0"
git-tree-sha1 = "57d8440b0c7d98fc4f889e478e80f268d534c9d5"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "0.2.0"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "1.0.0"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand All @@ -138,10 +122,6 @@ uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

Expand Down
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[deps]
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
54 changes: 26 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# PseudoTransientSolvers
Concise and multi-[CPU/GPU]-ready iterative PDE solvers for Earth-science applications and beyond; examples.
# ViscousGlacier2D
Concise and CPU and GPU iterative Stokes solvers for viscous flow - 2D glacier examples.


## Description
This repository contains various Pseudo-Transient (PT) routines with application to Earth-sciences (glaciology and subsurface processes). These routines exemplify the implementation of a fast and concise (60 lines of code) iterative solving strategy referred to as Pseudo-Transient. The core of the Pseudo-Transient approach relies in using physics-motivated transient terms within differential equations in order to iteratively converge to an accurate solution.
This repository contains GPU and CPU implementations of a 2D Stokes solver to resolve glacier flow on an inclined plane with a stress-free surface. The routines exemplify the implementation of a fast and concise (60 lines of code) iterative solving strategy referred to as Pseudo-Transient. The core of the Pseudo-Transient approach relies in using physics-motivated transient terms within differential equations in order to iteratively converge to an accurate solution.

The routines relate to a seminar on _"Simply solving PDEs"_. Slide compilation is accessible [here](#seminar-presentation).

## Content
* [Script list](#script-list)
* [Usage](#usage)
* [Output](#output)
* [To-Do](#to-do)
* [Questions and comments](#questions-and-comments)
* [Seminar presentation](#seminar-presentation)


## Script list
The [/scripts](/scripts/) folder contains various PT routines grouped into subprojects. Currently, the subprojects and correpsonding routines are
- [/scripts/viscous_gl2D](/scripts/viscous_gl2D/)
- `viscous_gl2D.jl`
- `viscous_gl2D_gpu.jl`
- `viscous_gl2D_nondim.jl`
- `viscous_gl2D_nondim_gpu.jl`
The [/scripts](/scripts/) folder contains the following PT routines:
- [`viscous_gl2D.jl`](scripts/viscous_gl2D.jl)
- [`viscous_gl2D_gpu.jl`](scripts/viscous_gl2D_gpu.jl)
- [`viscous_gl2D_nondim.jl`](scripts/viscous_gl2D_nondim.jl)
- [`viscous_gl2D_nondim_gpu.jl`](scripts/viscous_gl2D_nondim_gpu.jl)

The keywords in the code naming stand for:
- viscous_gl2D: 2D viscous (full) Stokes with linear shear viscosity (scalar)
- gpu: Nvidia GPU ready routines using the [CUDA.jl] package
- nondim: non-dimensional version of the code, using natural scaling


## Usage
If not stated otherwise, all the routines are written in Julia and can be executed from the REPL. Output is produced using [PyPlot.jl] requiring a valid and on `PATH` python (+ matplotlib) install.
The routines are written in [Julia] and can be executed from the REPL. Output is produced using [PyPlot.jl] requiring a valid and on `PATH` python (+ matplotlib) install.

Example running the `viscous_gl2D_nondim.jl` routine.

1. Launch Julia
```sh
% julia --project
```
2. Activate and instantiate the environment
2. ENter package mode `]` and instantiate the environment
```julia-repl
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
Expand All @@ -47,22 +47,21 @@ Example running the `viscous_gl2D_nondim.jl` routine.
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia>
julia>
(PseudoTransientExamples) pkg> instantiate
(ViscousGlacier2D) pkg> add instantiate
(PseudoTransientExamples) pkg> st
Status `~/Documents/git/github/PseudoTransientExamples/Project.toml`
(ViscousGlacier2D) pkg> st
Status `~/Documents/git/github/ViscousGlacier2D/Project.toml`
[d330b81b] PyPlot v2.9.0
[10745b16] Statistics
(PseudoTransientExamples) pkg>
(ViscousGlacier2D) pkg>
julia>
```
3. Run the script
```julia-repl
julia> include("viscous_gl2D_nondim.jl")
julia> include("scripts/viscous_gl2D_nondim.jl")
error = 0.007844763087162187
error = 0.0035814871757943543
error = 0.0005235773871451197
Expand All @@ -83,15 +82,14 @@ julia>
The output of running the `viscous_gl2D_nondim.jl` script is following
![Viscous 2D full Stokes flow (2D glacier) with stress free surface](docs/fig_viscous_gl2D_nondim.png)

## Questions and comments
Contact me or open an issue if you have any questions or comments about the presented material.

## Seminar presentation

![Simply solving PDEs](docs/slides.png)

## To-Do
A non-exhaustive list of potential future next steps:
- complete the README
- with references and cross-refs
- further links to GPU-related computing, Julia-related computing, to stencil-based HPC Julia modules and distributed memory parallelisation Julia modules
- add more code examples
- add some simple visualisation scripts
- certainly more to come... stay tuned

[Julia]: https://julialang.org
[CUDA.jl]: https://github.com/JuliaGPU/CUDA.jl
[PyPlot.jl]: https://github.com/JuliaPy/PyPlot.jl
Binary file added docs/slides.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ using PyPlot, Statistics
st = 4; s2d = 60*60*24
(Xp, Yp ) = (X2r[1:st:end,1:st:end], Y2r[1:st:end,1:st:end])
(Vxp, Vyp) = (0.5*(Vx[1:st:end-1,1:st:end ]+Vx[2:st:end,1:st:end]), 0.5*(Vy[1:st:end ,1:st:end-1]+Vy[1:st:end,2:st:end]))
subplot(311), pcolor(X2r,Y2r, 1e-3*Pt, shading="auto"), plt.axis("off"), plt.title("pressure [kPa]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(311), pcolor(X2r,Y2r, 1e-3*Pt), plt.axis("off"), plt.title("pressure [kPa]"), plt.colorbar(fraction=0.02, pad=0.03)
quiver(Xp, Yp, Vxp, Vyp, pivot="mid", color="white")
subplot(312), pcolor(X2r,Y2r, s2d*Vx[2:end,:], shading="auto"), plt.axis("off"), plt.title("Vel-x [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(313), pcolor(X2r,Y2r, s2d*Vy[:,2:end], shading="auto"), plt.axis("off"), plt.title("Vel-y [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(312), pcolor(X2r,Y2r, s2d*Vx[2:end,:]), plt.axis("off"), plt.title("Vel-x [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(313), pcolor(X2r,Y2r, s2d*Vy[:,2:end]), plt.axis("off"), plt.title("Vel-y [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
return
end
viscous_glacier2D()
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ using CUDA, PyPlot, Statistics
st = 4; s2d = 60*60*24
(Xp, Yp ) = (X2r[1:st:end,1:st:end], Y2r[1:st:end,1:st:end])
(Vxp, Vyp) = (0.5*(Vx[1:st:end-1,1:st:end ]+Vx[2:st:end,1:st:end]), 0.5*(Vy[1:st:end ,1:st:end-1]+Vy[1:st:end,2:st:end]))
subplot(311), pcolor(X2r,Y2r, 1e-3*Array(Pt), shading="auto"), plt.axis("off"), plt.title("pressure [kPa]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(311), pcolor(X2r,Y2r, 1e-3*Array(Pt)), plt.axis("off"), plt.title("pressure [kPa]"), plt.colorbar(fraction=0.02, pad=0.03)
quiver(Xp, Yp, Vxp, Vyp, pivot="mid", color="white")
subplot(312), pcolor(X2r,Y2r, s2d*Array(Vx[2:end,:]), shading="auto"), plt.axis("off"), plt.title("Vel-x [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(313), pcolor(X2r,Y2r, s2d*Array(Vy[:,2:end]), shading="auto"), plt.axis("off"), plt.title("Vel-y [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(312), pcolor(X2r,Y2r, s2d*Array(Vx[2:end,:])), plt.axis("off"), plt.title("Vel-x [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(313), pcolor(X2r,Y2r, s2d*Array(Vy[:,2:end])), plt.axis("off"), plt.title("Vel-y [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
return
end
viscous_glacier2D()
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ using PyPlot, Statistics
st = 4; s2d = 60*60*24
(Xp, Yp ) = (X2r[1:st:end,1:st:end], Y2r[1:st:end,1:st:end])
(Vxp, Vyp) = (0.5*(Vx[1:st:end-1,1:st:end ]+Vx[2:st:end,1:st:end]), 0.5*(Vy[1:st:end ,1:st:end-1]+Vy[1:st:end,2:st:end]))
subplot(311), pcolor(x̂*X2r,x̂*Y2r, 1e-3**Pt, shading="auto"), plt.axis("off"), plt.title("pressure [kPa]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(311), pcolor(x̂*X2r,x̂*Y2r, 1e-3**Pt), plt.axis("off"), plt.title("pressure [kPa]"), plt.colorbar(fraction=0.02, pad=0.03)
quiver(x̂*Xp, x̂*Yp, v̂*Vxp, v̂*Vyp, pivot="mid", color="white")
subplot(312), pcolor(x̂*X2r,x̂*Y2r, s2d**Vx[2:end,:], shading="auto"), plt.axis("off"), plt.title("Vel-x [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(313), pcolor(x̂*X2r,x̂*Y2r, s2d**Vy[:,2:end], shading="auto"), plt.axis("off"), plt.title("Vel-y [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(312), pcolor(x̂*X2r,x̂*Y2r, s2d**Vx[2:end,:]), plt.axis("off"), plt.title("Vel-x [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(313), pcolor(x̂*X2r,x̂*Y2r, s2d**Vy[:,2:end]), plt.axis("off"), plt.title("Vel-y [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
return
end
viscous_glacier2D()
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ using CUDA, PyPlot, Statistics
st = 4; s2d = 60*60*24
(Xp, Yp ) = (X2r[1:st:end,1:st:end], Y2r[1:st:end,1:st:end])
(Vxp, Vyp) = (0.5*(Vx[1:st:end-1,1:st:end ]+Vx[2:st:end,1:st:end]), 0.5*(Vy[1:st:end ,1:st:end-1]+Vy[1:st:end,2:st:end]))
subplot(311), pcolor(x̂*X2r,x̂*Y2r, 1e-3**Array(Pt), shading="auto"), plt.axis("off"), plt.title("pressure [kPa]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(311), pcolor(x̂*X2r,x̂*Y2r, 1e-3**Array(Pt)), plt.axis("off"), plt.title("pressure [kPa]"), plt.colorbar(fraction=0.02, pad=0.03)
quiver(x̂*Xp, x̂*Yp, v̂*Vxp, v̂*Vyp, pivot="mid", color="white")
subplot(312), pcolor(x̂*X2r,x̂*Y2r, s2d**Array(Vx[2:end,:]), shading="auto"), plt.axis("off"), plt.title("Vel-x [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(313), pcolor(x̂*X2r,x̂*Y2r, s2d**Array(Vy[:,2:end]), shading="auto"), plt.axis("off"), plt.title("Vel-y [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(312), pcolor(x̂*X2r,x̂*Y2r, s2d**Array(Vx[2:end,:])), plt.axis("off"), plt.title("Vel-x [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
subplot(313), pcolor(x̂*X2r,x̂*Y2r, s2d**Array(Vy[:,2:end])), plt.axis("off"), plt.title("Vel-y [m/d]"), plt.colorbar(fraction=0.02, pad=0.03)
return
end
viscous_glacier2D()

0 comments on commit cc6aa13

Please sign in to comment.