Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with Chmy.jl #141

Merged
merged 39 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bb0e7a4
store 1D vectors instead of ranges
boriskaus Oct 8, 2024
53275a7
add Chmy interface and multiple dispatch for most functions
boriskaus Oct 8, 2024
884272f
missing dependencies
boriskaus Oct 8, 2024
4abc21f
spellcheck
boriskaus Oct 8, 2024
0cf7795
add functionality for above/belowSurface
boriskaus Oct 9, 2024
5a3b2cd
spell check
boriskaus Oct 9, 2024
94daeea
correct test
boriskaus Oct 9, 2024
7a65cf2
albert's suggestion
boriskaus Oct 9, 2024
7b4c24e
changes to make this work with purely 2D arrays
boriskaus Oct 9, 2024
749ea32
activate 2D for more routines
boriskaus Oct 9, 2024
48b6791
deactivate test that fails locally but runs on CI
boriskaus Oct 9, 2024
95f4335
bugfix for add_sphere!, more tests
boriskaus Oct 9, 2024
a032cac
Merge branch 'main' into bk-chmy
boriskaus Oct 9, 2024
12971e2
fix cylinder bug
boriskaus Oct 9, 2024
1ce3c6a
bugfixes for 2D
boriskaus Oct 9, 2024
fc905eb
Merge remote-tracking branch 'origin/main' into bk-chmy
boriskaus Oct 9, 2024
787dc9f
remove debugging
boriskaus Oct 9, 2024
2b123bd
bugfixes
boriskaus Oct 9, 2024
231db49
add released 1.11 to CI
boriskaus Oct 9, 2024
ab0ad0b
test intel Macs as well
boriskaus Oct 9, 2024
8b5ea61
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
b0416c9
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
12ead9b
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
a4decaf
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
30a658e
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
8fb92e6
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
4a1a436
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
769cb68
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
3d1899e
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
c0f9cdc
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
7016142
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
fb57455
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
8fb17a3
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
a34d1f1
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
41e9b43
Update src/Setup_geometry.jl
boriskaus Oct 9, 2024
779798d
add Chmy tutorial to the docs
boriskaus Oct 9, 2024
7dc6bd8
Merge remote-tracking branch 'origin/bk-chmy' into bk-chmy
boriskaus Oct 9, 2024
3050774
cancel running ongoing CI runs upon new push
boriskaus Oct 9, 2024
115a1cc
some of albert's suggestions broke the tests
boriskaus Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GeophysicalModelGenerator"
uuid = "3700c31b-fa53-48a6-808a-ef22d5a84742"
authors = ["Boris Kaus", "Marcel Thielmann"]
version = "0.7.7"
version = "0.7.8"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Expand Down Expand Up @@ -32,23 +32,26 @@ WhereTheWaterFlows = "ea906314-1493-4d22-a0af-f886a20c9fba"
WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"

[weakdeps]
Chmy = "33a72cf0-4690-46d7-b987-06506c2248b9"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
GMT = "5752ebe1-31b9-557e-87aa-f909b540aa54"
GridapGmsh = "3025c34a-b394-11e9-2a55-3fee550c04c8"

[extensions]
Chmy_utils = "Chmy"
GLMakie_Visualisation = "GLMakie"
GMT_utils = "GMT"
Gmsh_utils = "GridapGmsh"

[compat]
Chmy = "0.1.20"
Colors = "0.9 - 0.12"
Downloads = "1"
FFMPEG = "0.4"
FileIO = "1"
GDAL_jll = "300.900.0 - 301.900.0"
GLMakie = "0.10"
GMT = "1"
GDAL_jll = "300.900.0 - 301.901.0"
GLMakie = "0.8, 0.9, 0.10"
GMT = "1.0 - 1.14"
GeoParams = "0.2 - 0.6"
Geodesy = "1"
GeometryBasics = "0.1 - 0.4"
Expand All @@ -63,15 +66,17 @@ NearestNeighbors = "0.2 - 0.4"
Parameters = "0.9 - 0.12"
SpecialFunctions = "1.0, 2"
StaticArrays = "1"
WhereTheWaterFlows = "0.10"
WhereTheWaterFlows = "0.10, 0.11"
WriteVTK = "1"
julia = "1.9"

[extras]
Chmy = "33a72cf0-4690-46d7-b987-06506c2248b9"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
GMT = "5752ebe1-31b9-557e-87aa-f909b540aa54"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "GMT", "StableRNGs", "GridapGmsh"]
test = ["Test", "GMT", "StableRNGs", "GridapGmsh", "Chmy","KernelAbstractions"]
108 changes: 108 additions & 0 deletions ext/Chmy_utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#helper functions to make GMG work with Chmy grids and fields
module Chmy_utils

using Chmy, Chmy.Grids, Chmy.Fields

import GeophysicalModelGenerator: create_CartGrid, CartGrid, CartData
import GeophysicalModelGenerator: add_box!, add_sphere!, add_ellipsoid!, add_cylinder!
import GeophysicalModelGenerator: add_layer!, add_polygon!, add_slab!, add_stripes!, add_volcano!
import GeophysicalModelGenerator: above_surface, below_surface

println("Loading Chmy-GMG tools")

"""
CartGrid = create_CartGrid(grid::StructuredGrid; ylevel=0.0)

Creates a GMG `CartGrid` data structure from a `Chmy` grid object
"""
function create_CartGrid(grid::StructuredGrid; ylevel=0.0)

coord1D = Vector.(coords(grid, Vertex()))
coord1D_cen = Vector.(coords(grid, Center()))
N = length.(coord1D)
L = extent(grid, Vertex())
X₁ = origin(grid, Vertex())
Δ = spacing(grid)
ConstantΔ = false;
if isa(grid, UniformGrid)
ConstantΔ = true
end
if ndims(grid)==2
# we need a special treatment of this, as all GMG routines work with 3D coordinates
X₁ = (X₁[1], ylevel, X₁[2])
L = (L[1], 0.0, L[2])
Δ = (Δ[1], 0.0, Δ[2])
N = (N[1],1,N[2])
coord1D = (coord1D[1], [0.0], coord1D[2])
coord1D_cen = (coord1D_cen[1], [0.0], coord1D_cen[2])
end
Xₙ = X₁ .+ L


return CartGrid(ConstantΔ,N,Δ,L,X₁,Xₙ,coord1D, coord1D_cen)
end

# all functions to be ported
function_names = (:add_box!, :add_sphere!, :add_ellipsoid!, :add_cylinder!, :add_layer!, :add_polygon!, :add_slab!, :add_stripes!, :add_volcano!)

for fn in function_names

@eval begin
"""
$($fn)( Phase::Field,
Temp::Field,
Grid::StructuredGrid; # required input
kwargs...)

Sets `$($fn)` function for `Chmy` fields and grids.
"""
function $fn( Phase::Field,
Temp::Field,
Grid::StructuredGrid; # required input
kwargs...)

CartGrid = create_CartGrid(Grid)

cell = false
if all(location(Phase).==Center())
cell = true
end

return ($fn)(Phase, Temp, CartGrid; cell=cell, kwargs...)
end
end

end


# all functions to be ported
function_names = (:above_surface, :below_surface)

for fn in function_names

@eval begin
"""
$($fn)( Grid::StructuredGrid, field::Field, DataSurface_Cart::CartData; kwargs...)

Sets `$($fn)` function for `Chmy` grids and the field `field` which can be either on vertices or centers
"""
function $fn( Grid::StructuredGrid,
field::Field,
DataSurface_Cart::CartData;
kwargs...)

CartGrid = create_CartGrid(Grid)

cell = false
if all(location(field).==Center())
cell = true
end

return ($fn)(CartGrid, DataSurface_Cart; cell=cell, kwargs...)
end
end

end


end # end of module
Loading
Loading