Skip to content

Commit

Permalink
Merge branch 'main' into compathelper/new_version/2024-05-18-01-03-13…
Browse files Browse the repository at this point in the history
…-788-03157019633
  • Loading branch information
boriskaus authored Aug 26, 2024
2 parents e68190c + affa562 commit 90b4039
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
fail-fast: false
matrix:
version:
- '1.9'
- '1.10'
- '~1.11.0-0'
- 'nightly'
os:
- ubuntu-latest
Expand Down
9 changes: 5 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LaMEM"
uuid = "2e889f3d-35ce-4a77-8ea2-858aecb630f7"
authors = ["Boris Kaus <kaus@uni-mainz.de>"]
version = "0.3.4"
version = "0.4.0"

[deps]
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Expand All @@ -23,24 +23,25 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PlotsExt = "Plots"

[compat]
CairoMakie = "0.11"
DelimitedFiles = "1"
DocStringExtensions = "0.9"
GeoParams = "0.4, 0.5, 0.6"
GeophysicalModelGenerator = "0.7"
Glob = "1"
LightXML = "0.9"
MPICH_jll = "4.1 - 4.1.2"
LaMEM_jll = "~2.1.4"
Plots = "1"
ReadVTK = "0.1, 0.2"
Statistics = "1.0"
WriteVTK = "1"
julia = "1.9"
julia = "1.10"


[extras]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "CairoMakie", "Plots"]
test = ["Test", "Plots"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ More details are given in the [documentation](https://juliageodynamics.github.io
We rely on the following packages:
- [GeophysicalModelGenerator](https://github.com/JuliaGeodynamics/GeophysicalModelGenerator.jl) - Data structure in which we store the info of a LaMEM timestep. The package can also be used to generate setups for LaMEM.
- [LaMEM_jll](https://github.com/JuliaRegistries/General/tree/master/L/LaMEM_jll) - this contains the LaMEM binaries, precompiled for most systems. Note that on windows, the MUMPS parallel direct solver is not available.
- [ReadVTK](https://github.com/JuliaVTK/ReadVTK.jl) - This reads the LaMEM `*.vtk` files (or the rectilinear and structured grid versions of it) baxck into julia.
- [ReadVTK](https://github.com/JuliaVTK/ReadVTK.jl) - This reads the LaMEM `*.vtk` files (or the rectilinear and structured grid versions of it) baxck into julia.


### 6. Funding
Expand Down
1 change: 1 addition & 0 deletions docs/src/juliasetup_TMSubduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ continentalLithosphere = copy_phase( dryPeridotite,
```

*Sticky air*

Finally, the "air" in our model is a layer with low density and low viscosity, such that it essentially gives very low stresses compared to those within the lithosphere. We cannot give it the viscosity of real air, as this results in a too large viscosity jump at the surface (geodynamic codes cannot handle that). We therefore also often call this "sticky air". Note that we also give it a very high thermal conductivity to ensure that the temperature within the air layer remains more or less constant throughout a simulation (and equal to the temperature at the upper boundary of the model):

```julia
Expand Down
14 changes: 8 additions & 6 deletions scripts/StrengthEnvelop.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LaMEM, CairoMakie
using LaMEM

model = Model(Grid(nel=(4,32), x=[-1,1], z=[-30,1]),
Time(nstep_max=25, dt_min=1e-4, dt=1e-3, dt_max=10, time_end=100),
Expand All @@ -24,9 +24,11 @@ run_lamem(model,1)

data,_ = read_LaMEM_timestep(model, last=true)

#Create plot
fig1 = Figure(size=(800,800))
ax = Axis(fig1[1,1], xlabel = "τII [MPa]", ylabel = "Depth [km]",title="Geotherm=$(Tgradient)°C/km")
if 1==0
#Create plot
fig1 = Figure(size=(800,800))
ax = Axis(fig1[1,1], xlabel = "τII [MPa]", ylabel = "Depth [km]",title="Geotherm=$(Tgradient)°C/km")

lines!(ax, data.fields.j2_dev_stress[1,1,:], data.z.val[1,1,:], label="t=$time")
display(fig1)
lines!(ax, data.fields.j2_dev_stress[1,1,:], data.z.val[1,1,:], label="t=$time")
display(fig1)
end
17 changes: 12 additions & 5 deletions scripts/Subduction3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ using LaMEM, GeophysicalModelGenerator
# Note that a range of default values will be set, depending on the parameters you specify.
model = Model(
## Define the grid
Grid(nel=(128,32,64), x=[-3960, 500], y=[0,2640], z=[-660 ,0]),
Grid( #nel=(128,32,64),
nel=(64,16,32), # reduce resolution for CI
x=[-3960, 500], y=[0,2640], z=[-660 ,0]),

## No slip lower boundary; the rest is free slip
BoundaryConditions(noslip = [0, 0, 0, 0, 1, 0]),
Expand All @@ -29,7 +31,8 @@ model = Model(
Output(out_file_name="Subduction_3D", out_dir="Subduction_3D"),

## Timestepping etc
Time(nstep_max=200, nstep_out=5, time_end=100, dt_min=1e-5),
Time( nstep_max=200,
nstep_out=5, time_end=100, dt_min=1e-5),

## Scaling:
Scaling(GEO_units(length=1km, stress=1e9Pa) )
Expand All @@ -46,8 +49,8 @@ add_box!(model, xlim=(-3000,-1000), ylim=(0,1000), zlim=(-80,0), phase=Lithosphe
add_box!(model, xlim=(-1000,-810), ylim=(0,1000), zlim=(-80,0), phase=LithosphericPhases(Layers=[20,60], Phases=[1,2]), DipAngle=16)

# There is a simple way to have a quick look at this setup by using the `Plots.jl` package:
using Plots
plot_cross_section(model, y=100, field=:phase)
#using Plots
#plot_cross_section(model, y=100, field=:phase)

# Which will give the following plot:
# ![2D cross section](assets/SubductionSetup_3D.png)
Expand Down Expand Up @@ -87,7 +90,11 @@ end
# Add this stage, we are ready to run the simulation. On my machine it takes around 4 seconds per timestep on 8 cores:
try testing == true
# if we run this as part of the test suite, use fewer timesteps
run_lamem(model, 8, "-nstep_max 2 -nstep_out 1")
if !Sys.iswindows()
run_lamem(model, 8, "-nstep_max 2 -nstep_out 1")
else
run_lamem(model, 1, "-nstep_max 2 -nstep_out 1")
end
catch
run_lamem(model, 8) # run on 8 cores (if possible)
end
Expand Down
20 changes: 17 additions & 3 deletions scripts/TM_Subduction_example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ using LaMEM, GeophysicalModelGenerator
model = Model(Grid( x = [-2000.,2000.],
y = [-2.5, 2.5], # <- model is 2D, size in y-direction is choosen to be close to a cube shape for the cell
z = [-660,40] ,
nel = (512,1,128) ),
#nel = (512,1,128)
nel = (256,1,64)

),

## Output filename
Output(out_file_name="TMSubduction_2D", out_dir="TMSubduction_2D"),

BoundaryConditions( temp_bot = 1565.0,
temp_top = 20.0,
Expand Down Expand Up @@ -228,9 +234,17 @@ model.Solver = Solver( SolverType = "multigrid",
]
)

try testing == true
if Sys.iswindows()
model.Solver.MGCoarseSolver = "direct"
end

try testing == true
# if we run this as part of the test suite, use fewer timesteps
run_lamem(model, 8, "-nstep_max 2 -nstep_out 1")
if !Sys.iswindows()
run_lamem(model, 8, "-nstep_max 2 -nstep_out 1")
else
run_lamem(model, 1, "-nstep_max 2 -nstep_out 1")
end
catch
run_lamem(model, 8)
end
7 changes: 5 additions & 2 deletions test/read_timestep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pkg_dir = pkgdir(LaMEM)
data, time = read_LaMEM_timestep(FileName,Timestep, phase=true)

@test data.fields.phase[1000] == 0

#=
# read subduction setup
data, time = read_LaMEM_timestep("Subduction2D_FreeSlip_direct",1)
@test data.fields.density[10000] ≈ 3200.0f0
Expand All @@ -32,15 +32,18 @@ pkg_dir = pkgdir(LaMEM)
# Read PVD file
Timestep, FileNames, Time = read_LaMEM_simulation("Subduction2D_FreeSlip_direct")
@test Time[2] ≈ 0.055

=#

# Read passive tracers
data, time = read_LaMEM_timestep("PlumeLithosphereInteraction",10, passive_tracers=true)
@test data.z[100] -298.4531f0
@test data.fields.Temperature[100] 1350.0f0

# Read surface data
#=
data, time = read_LaMEM_timestep("Subduction2D_FreeSurface_direct",5, surf=true)
@test data.z[100] ≈ 0.68236357f0
@test sum(data.fields.topography[:,1,1]) ≈ 1.2645866f0
=#
end

6 changes: 3 additions & 3 deletions test/runLaMEM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ pkg_dir = pkgdir(LaMEM)
end

# Create a setup using GMG
include("CreateMarkers_Subduction_Linear_FreeSlip_parallel.jl")
out = run_lamem(ParamFile_2, 1, "-nstep_max 1") # 1 core
@test isnothing(out)
#include("CreateMarkers_Subduction_Linear_FreeSlip_parallel.jl")
#out = run_lamem(ParamFile_2, 1, "-nstep_max 1") # 1 core
#@test isnothing(out)

# Try direct solvers
ParamFile = "input_files/FallingBlock_DirectSolver.dat";
Expand Down
16 changes: 8 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Test
using LaMEM

#include("test_julia_setups.jl")
#include("runLaMEM.jl")
#include("read_timestep.jl")
#include("run_lamem_save_grid_test.jl")
#include("mesh_refinement_test.jl")
#include("read_logfile.jl")
#include("test_compression.jl")
#include("test_GeoParams_integration.jl")
include("test_julia_setups.jl")
include("runLaMEM.jl")
include("read_timestep.jl")
include("run_lamem_save_grid_test.jl")
include("mesh_refinement_test.jl")
include("read_logfile.jl")
include("test_compression.jl")
include("test_GeoParams_integration.jl")
include("test_examples.jl")

if !Sys.iswindows()
Expand Down
44 changes: 28 additions & 16 deletions test/test_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ using Test

const testing = true
@testset "examples in /scripts" begin


# Subduction example
@testset "TM_Subduction_example" begin
include("../scripts/TM_Subduction_example.jl")
data,time = read_LaMEM_timestep(model,last=true);
@test time 0.001736862
@test sum(data.fields.velocity[3][:,:,:]) 1192.9121f0 rtol=1e-4 # check Vz
end

curdir = pwd()
pkg_dir = pkgdir(LaMEM)
cd(pkg_dir)
#cd(joinpath(pkg_dir,"test"))

# 3D subduction example
@testset "Subduction3D" begin
clean_directory()
include("../scripts/Subduction3D.jl")
data,time = read_LaMEM_timestep(model,last=true);
@test time 0.03517227
@test sum(data.fields.velocity[3][:,:,:]) -33.77553f0 rtol=1e-4 # check Vz
if !Sys.iswindows()
@testset "Subduction3D" begin
clean_directory()
include("../scripts/Subduction3D.jl")
data,time = read_LaMEM_timestep(model,last=true);
@test time 0.05504613
@test sum(data.fields.velocity[3][:,:,:]) -51.314083f0 rtol=1e-4 # check Vz
end
end

# Strength envelop example
Expand All @@ -31,4 +28,19 @@ const testing = true
@test sum(data.fields.velocity[3][:,:,:]) 14.305277f0 rtol=1e-4 # check Vz
end


# Subduction example
if !Sys.iswindows()
@testset "TM_Subduction_example" begin
clean_directory()
include("../scripts/TM_Subduction_example.jl")
data,time = read_LaMEM_timestep(model,last=true);
@test time 0.0021
@test sum(data.fields.velocity[3][:,:,:]) 420.10352f0 rtol=1e-4 # check Vz
end

end

cd(curdir)

end
3 changes: 0 additions & 3 deletions test/test_julia_setups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,4 @@ end
add_geom!(model, geom_ellipsoid, geom_box, geom_layer, geom_cylinder, geom_ridge, geom_hex)
out = run_lamem(model)
@test isnothing(out)



end

0 comments on commit 90b4039

Please sign in to comment.