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

Replace python with julia #7

Merged
merged 19 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 3 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ version = "0.1.6"
GeophysicalModelGenerator = "3700c31b-fa53-48a6-808a-ef22d5a84742"
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
LaMEM_jll = "15d6fa20-f789-5486-b71b-22b4ac8eb1c1"
MicroMamba = "0b3b1443-0f03-428d-bdfb-f27f9c1191ea"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
ReadVTK = "dc215faf-f008-4882-a9f7-a79a826fadc3"

[compat]
GeophysicalModelGenerator = "0.4"
Glob = "1"
LaMEM_jll = "1.2"
MicroMamba = "0.1.9 - 0.1.9" # MicroMamba 0.1.10 appears to be broken
PythonCall = "0.9"
LaMEM_jll = "1.2.3"
julia = "1.6"
ReadVTK = "0.1.5"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
11 changes: 11 additions & 0 deletions src/IO.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module IO
# this contains I/O routines of LaMEM, which don't require LaMEM_jll

include("read_timestep.jl")
export Read_LaMEM_PVTR_File, Read_LaMEM_PVTS_File, field_names, readPVD, Read_LaMEM_PVTU_File

include("utils_IO.jl")
export clean_directory, changefolder


end
48 changes: 12 additions & 36 deletions src/LaMEM.jl
Original file line number Diff line number Diff line change
@@ -1,40 +1,16 @@
module LaMEM
using LaMEM_jll
using PythonCall
using Glob

ENV["JULIA_CONDAPKG_BACKEND"] = "MicroMamba"

# load the correct MPI
const mpiexec = if isdefined(LaMEM_jll,:MPICH_jll)
LaMEM_jll.MPICH_jll.mpiexec()
elseif isdefined(LaMEM_jll,:MicrosoftMPI_jll)
LaMEM_jll.MicrosoftMPI_jll.mpiexec()
else
nothing
end

# Reading files back into julia
const pyvtk = PythonCall.pynew()

function __init__()

println("Adding PythonCall dependencies to read LaMEM timesteps")
pth = (@__DIR__)*"/python" # Path where the python routines are
pyimport("sys").path.append(pth) # append path

# link vtk. Note that all python dependencies are listed in PythonCallDeps.toml
PythonCall.pycopy!(pyvtk, pyimport("vtk")) # used to read VTK files
end


include("run_lamem.jl")
include("run_lamem_save_grid.jl")
include("read_timestep.jl")
include("utils.jl")

export run_lamem
export run_lamem_save_grid
export pyvtk
# Functions to read LaMEM output
include("IO.jl")
using .IO
export Read_LaMEM_PVTR_File, Read_LaMEM_PVTS_File, Read_LaMEM_PVTU_File
export Read_LaMEM_simulation, Read_LaMEM_timestep, Read_LaMEM_fieldnames
export clean_directory, changefolder

# Functions
include("Run.jl")
using .Run
export run_lamem, run_lamem_save_grid, mpiexec
export remove_popup_messages_mac, show_paths_LaMEM

end # module
22 changes: 22 additions & 0 deletions src/Run.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Run
# module to run LaMEM_jll
using LaMEM_jll,Glob

export run_lamem, run_lamem_save_grid, mpiexec
export remove_popup_messages_mac, show_paths_LaMEM

include("run_lamem.jl")
include("run_lamem_save_grid.jl")
include("utils_Run.jl")

# load the correct MPI
const mpiexec = if isdefined(LaMEM_jll,:MPICH_jll)
LaMEM_jll.MPICH_jll.mpiexec()
elseif isdefined(LaMEM_jll,:MicrosoftMPI_jll)
LaMEM_jll.MicrosoftMPI_jll.mpiexec()
else
nothing
end


end
Loading