Skip to content

Commit 6f70862

Browse files
committed
2 parents 6c5cb22 + b6da4ce commit 6f70862

29 files changed

+2156
-163
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- x64
2626
steps:
2727
- uses: actions/checkout@v4
28-
- uses: julia-actions/setup-julia@v1
28+
- uses: julia-actions/setup-julia@v2
2929
with:
3030
version: ${{ matrix.version }}
3131
arch: ${{ matrix.arch }}

.github/workflows/Documenter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- uses: actions/checkout@v4
33-
- uses: julia-actions/setup-julia@v1
33+
- uses: julia-actions/setup-julia@v2
3434
with:
3535
version: '1.9'
3636
show-versioninfo: true

Project.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GeophysicalModelGenerator"
22
uuid = "3700c31b-fa53-48a6-808a-ef22d5a84742"
33
authors = ["Boris Kaus", "Marcel Thielmann"]
4-
version = "0.7.1"
4+
version = "0.7.2"
55

66
[deps]
77
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
@@ -31,10 +31,12 @@ WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"
3131
[weakdeps]
3232
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
3333
GMT = "5752ebe1-31b9-557e-87aa-f909b540aa54"
34+
GridapGmsh = "3025c34a-b394-11e9-2a55-3fee550c04c8"
3435

3536
[extensions]
3637
GLMakie_Visualisation = "GLMakie"
3738
GMT_utils = "GMT"
39+
Gmsh_utils = "GridapGmsh"
3840

3941
[compat]
4042
Colors = "0.9 - 0.12"
@@ -43,14 +45,15 @@ FFMPEG = "0.4"
4345
FileIO = "1"
4446
GLMakie = "0.8, 0.9, 0.10"
4547
GMT = "1"
46-
GeoParams = "0.2 - 0.5"
48+
GeoParams = "0.2 - 0.6"
4749
Geodesy = "1"
4850
GeometryBasics = "0.1 - 0.4"
4951
Glob = "1.2 - 1.3"
52+
GridapGmsh = "0.5 - 0.7"
5053
ImageIO = "0.1 - 0.6"
5154
Interpolations = "0.14, 0.15"
52-
LightXML = "0.8, 0.9"
5355
JLD2 = "0.4"
56+
LightXML = "0.8, 0.9"
5457
MeshIO = "0.1 - 0.4"
5558
NearestNeighbors = "0.2 - 0.4"
5659
Parameters = "0.9 - 0.12"
@@ -66,4 +69,4 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
6669
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6770

6871
[targets]
69-
test = ["Test", "GMT", "StableRNGs"]
72+
test = ["Test", "GMT", "StableRNGs","GridapGmsh"]

docs/make.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ makedocs(;
120120
"Gravity code" => "man/gravity_code.md",
121121
"Numerical model setups" => "man/geodynamic_setups.md",
122122
"LaMEM" => "man/lamem.md",
123+
"pTatin" => "man/lamem.md",
123124
"Profile Processing" => "man/profile_processing.md",
125+
"Gmsh" => "man/gmsh.md",
124126
"Movies" => "man/movies.md"
125127
],
126128
"List of functions" => "man/listfunctions.md",

docs/src/man/datastructures.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ For plotting, we transfer this into the `ParaviewData` structure, which has cart
88
GeoData
99
CartData
1010
UTMData
11+
Q1Data
12+
FEData
1113
ParaviewData
1214
lonlatdepth_grid
1315
xyz_grid

docs/src/man/gmsh.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Gmsh
2+
3+
[Gmsh](https://gmsh.info) is a widely used 3D unstructured mesh generator that produces tetrahedral meshes which can be tagged by region. It is possible to import such meshes and use that to set region info in a `GMG` data set, or use it to generate pTatin input.
4+
5+
```@docs
6+
GeophysicalModelGenerator.import_Gmsh
7+
```

docs/src/man/ptatin.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# pTatin
2+
3+
We provide a few routines that allow exporting GMG input data sets to a format that can be read by the 3D geodynamic modelling software [pTatin](https://bitbucket.org/dmay/ptatin-total-dev.git/src), which is an open-source Cartesian code to perform crustal and lithospheric-scale simulations.
4+
5+
The `Q1Data` format can be saved directly to pTatin.
6+
7+
```@docs
8+
GeophysicalModelGenerator.write_pTatin_mesh
9+
GeophysicalModelGenerator.swap_yz_dims
10+
```

ext/Gmsh_utils.jl

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Support for Gmsh meshes
2+
3+
module Gmsh_utils
4+
5+
using GridapGmsh, StaticArrays
6+
7+
import GeophysicalModelGenerator: import_Gmsh, FEData, CartData
8+
9+
10+
"""
11+
fe_data, tag_names = import_Gmsh(fname::String)
12+
13+
Reads a Gmsh file and returns a `FEData` object with info about the mesh. `tag_names` contains the names of the regions of the FE mesh
14+
"""
15+
function import_Gmsh(fname::String)
16+
17+
mesh = GmshDiscreteModel(fname, renumber=false)
18+
19+
# Extract vertices
20+
nverts = length(mesh.grid.node_coordinates);
21+
dims = length(mesh.grid.node_coordinates[1])
22+
vertices = [mesh.grid.node_coordinates[n][i] for i=1:dims,n=1:nverts]
23+
24+
# write coords as 1D double array
25+
nvertices_cell = length(mesh.grid.cell_node_ids[1])
26+
connectivity = [c[i] for i=1:nvertices_cell, c in mesh.grid.cell_node_ids]
27+
28+
# extract tag of each of the tetrahedrons
29+
regions, tag_names = cell_tags_from_gmsh(mesh)
30+
31+
cellfields = (regions=regions,)
32+
fields = nothing
33+
34+
return FEData(vertices,connectivity, fields, cellfields), tag_names
35+
end
36+
37+
38+
"""
39+
tags, tag_names = cell_tags_from_gmsh(mesh::GmshDiscreteModel)
40+
41+
Returns a list with integers that are the tags for each of the cells
42+
"""
43+
function cell_tags_from_gmsh(mesh)
44+
cell_entities = mesh.face_labeling.d_to_dface_to_entity[4] # volumetric entities
45+
cell_entities_unique = unique(cell_entities)
46+
tag_unique = zeros(Int64,size(cell_entities_unique))
47+
48+
for i=1:length(cell_entities_unique)
49+
for (n,tag) in enumerate(mesh.face_labeling.tag_to_entities)
50+
if any(tag .== cell_entities_unique[i])
51+
tag_unique[i] = n
52+
end
53+
end
54+
end
55+
56+
# create tags for cells
57+
tags = zeros(Int64,length(cell_entities))
58+
for (i,entity) in enumerate(cell_entities_unique)
59+
id = findall(cell_entities.==entity)
60+
tags[id] .= tag_unique[i]
61+
end
62+
63+
return tags, mesh.face_labeling.tag_to_name
64+
end
65+
66+
67+
68+
69+
end

src/GeophysicalModelGenerator.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ include("Paraview_collection.jl")
3939
include("transformation.jl")
4040
include("voxel_gravity.jl")
4141
include("LaMEM_io.jl")
42+
include("pTatin_IO.jl")
4243
include("Setup_geometry.jl")
4344
include("stl.jl")
4445
include("ProfileProcessing.jl")
@@ -70,10 +71,18 @@ export import_topo, import_GeoTIFF
7071
visualise
7172
Interactive widget that allows you to explore a 3D data set `DataSet` in an interactive manner.
7273
It requires you to load `GLMakie`.
73-
"""
74+
""";
7475
function visualise end
7576
export visualise
7677

7778

79+
"""
80+
import_Gmsh(fname::String)
81+
82+
Reads a Gmsh file. Requires loading `GridapGmsh`.
83+
"""
84+
function import_Gmsh end
85+
export import_Gmsh
86+
7887

7988
end

src/LaMEM_io.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,11 +1016,15 @@ function create_partitioning_file(LaMEM_input::String,NumProc::Int64; LaMEM_dir:
10161016
end
10171017

10181018
"""
1019-
X,Y,Z = coordinate_grids(Data::LaMEM_grid)
1019+
X,Y,Z = coordinate_grids(Data::LaMEM_grid; cell=false)
10201020
10211021
Returns 3D coordinate arrays
10221022
"""
1023-
function coordinate_grids(Data::LaMEM_grid)
1024-
1025-
return Data.X, Data.Y, Data.Z
1023+
function coordinate_grids(Data::LaMEM_grid; cell=false)
1024+
X,Y,Z = Data.X, Data.Y, Data.Z
1025+
if cell
1026+
X,Y,Z = average_q1(X),average_q1(Y), average_q1(Z)
1027+
end
1028+
1029+
return X,Y,Z
10261030
end

0 commit comments

Comments
 (0)