Skip to content

List of all functions ​

These are all functions that are available in the package, which can roughly be divided into two groups (running & reading LaMEM)

Julia interface to LaMEM ​

The functions for building a model setup from julia are listed under Available functions.

Running LaMEM ​

LaMEM.Run.mpi_available Method
julia
mpi_available()

Whether this LaMEM_jll can run in parallel, i.e. whether an mpiexec was found above.

Windows builds used to be serial, so run_lamem silently fell back to one core there. Since LaMEM_jll 3.1.0 (PETSc_jll 3.25.4) the Windows binaries are built against Microsoft MPI and run in parallel like every other platform, so the platform is no longer the question.

source
LaMEM.Run.read_LaMEM_logfile Method
julia
read_LaMEM_logfile(Filename::String; ID=nothing, header=true)

Reads a LaMEM logfile (provided it was run with "-log_view") and collects key results from it; mostly for scalability tests on HPC machines. It prints a markdown summary table with grid sizes, core counts, multigrid levels, solver iterations, and timing information.

You can also pass a vector of filenames to compare multiple runs:

julia
julia> read_LaMEM_logfile(["logfile_64cpu_1234.out", "logfile_128cpu_5678.out"])
source
LaMEM.Run.remove_popup_messages_mac Method
julia
remove_popup_messages_mac()

On a Mac with firewall enabled, running LaMEM will result in a popup window that says: "Accept incoming connections" which you should Allow or Deny. This is a bit annoying, so this julia script fixes that. Note that you must have administrator rights on your machine as we need to run "sudo"

Run this script from the terminal with

julia
julia> remove_popup_messages_mac()

You need to do this once (every time a new version is installed)

source
LaMEM.Run.run_lamem Function
julia
run_lamem(ParamFile::String, cores::Int64=1, args:String=""; wait=true, deactivate_multithreads=true, logfile=nothing, append=nothing)

This starts a LaMEM simulation, for using the parameter file ParamFile on cores number of cores. Optional additional command-line parameters can be specified with args.

Use logfile to additionally save the LaMEM output to a file, while still showing it in the REPL. A name without an extension gets ".log" appended, so logfile="test" writes to "test.log".

By default a restart (args containing -mode restart) appends to an existing logfile, so the log of a simulation that was restarted stays in one file, while a normal run starts a fresh one. Set append=true or append=false to decide this yourself.

Example:

You can call LaMEM with:

julia
julia> using LaMEM
julia> ParamFile="../../input_models/BuildInSetups/FallingBlock_Multigrid.dat";
julia> run_lamem(ParamFile)

Do the same on 2 cores with a command-line argument as:

julia
julia> ParamFile="../../input_models/BuildInSetups/FallingBlock_Multigrid.dat";
julia> run_lamem(ParamFile, 2, "-nstep_max = 1")

Save the output to "test.log" as well as showing it in the REPL:

julia
julia> run_lamem(ParamFile, 1, "-nstep_max = 1", logfile="test")

Restarting the simulation adds its output to the same "test.log":

julia
julia> run_lamem(ParamFile, 1, "-mode restart", logfile="test")
source
LaMEM.Run.run_lamem_save_grid Function
julia
ProcessorPartFile = run_lamem_save_grid(ParamFile::String, cores::Int64=1; verbose=true, directory=pwd())

This calls LaMEM simulation, for using the parameter file ParamFile and creates processor partitioning file "ProcessorPartitioning_Xcpu_X.Y.Z.bin" for {X} number of cores.

Example:

julia
julia> using LaMEM
julia> ParamFile="../../input_models/BuildInSetups/FallingBlock_Multigrid.dat";
julia> ProcessorPartFile = run_lamem_save_grid(ParamFile, 2)
source
LaMEM.Run.show_paths_LaMEM Method
julia
show_paths_LaMEM()

The downloaded LaMEM binaries can also be called from outside julia (directly from the terminal). In that case, you will need to set load correct dynamic libraries (such as PETSc) and call the correct binaries.

This function shows this for your system.

source

Reading LaMEM output back into julia ​

LaMEM.IO_functions.changefolder Method
julia
changefolder()

Starts a GUI on Windowss or Mac machines, which allows you to change our working directory

source
LaMEM.IO_functions.clean_directory Function
julia
clean_directory(DirName)

Removes all LaMEM timesteps & *.pvd files from the directory DirName

source
LaMEM.IO_functions.compress_pvd Method
julia
compress_pvd(filename_pvd::String; Dir=pwd(), delete_original_files=false)

This compresses all LaMEM VTR files in a simulation.

source
LaMEM.IO_functions.compress_vtr_file Method
julia
filename_compressed::String =  compress_vtr_file(filename::String; Dir=pwd(), delete_original_files=false)

Compresses a LaMEM VTR file (loads parallel files & save them again )

source
LaMEM.IO_functions.passivetracer_time Function
julia
PT = passivetracer_time(ID::Union{Vector{Int64},Int64}, FileName::String, DirName::String="")

This reads passive tracers with ID from a LaMEM simulation, and returns a named tuple with the temporal evolution of these passive tracers. We return x,y,z coordinates and all fields specified in the FileName for particles number ID.

source
LaMEM.IO_functions.project_onto_crosssection Method
julia
data_projected = project_onto_crosssection(data::CartData, Cross::CartData)

This function is helpful if you used the cross_section routine of the GeophysicalModelGenerator package to create a 2D cross-section through a 3D model, which "flattens" the cross-section to a 2D model. If you later want to visualize the LaMEM model results in the original 3D context (along with topography, for example), you need to project the 2D model back onto the 3D model. This function does that.

source
LaMEM.IO_functions.project_onto_crosssection Method
julia
project_onto_crosssection(simulation_name::String, Cross::CartData)

Reads the output of a LaMEM simulation and projects it onto a 2D cross-section Cross

source
LaMEM.IO_functions.readPVD Method
julia
FileNames, Time, Timestep = readPVD(FileName::String)

This reads a PVD file & returns the FileNames, Time and Timesteps

source
LaMEM.IO_functions.read_LaMEM_PVTR_file Method
julia
data_output = read_LaMEM_PVTR_file(DirName, FileName; fields=nothing)

Reads a 3D LaMEM timestep from a parallel VTR file FileName, located in directory DirName. By default, it will read all fields. If you want you can only read a specific field. See the function fieldnames to get a list with all available fields in the file.

It will return data_output which is a CartData output structure.

source
LaMEM.IO_functions.read_LaMEM_PVTS_file Method
julia
data_output = read_LaMEM_PVTS_file(DirName, FileName; field=nothing)

Reads a 3D LaMEM timestep from VTS file FileName, located in directory DirName. Typically this is done to read passive tracers back into julia. By default, it will read all fields. If you want you can only read a specific field. See the function fieldnames to get a list with all available fields in the file.

It will return data_output which is a CartData output structure.

source
LaMEM.IO_functions.read_LaMEM_PVTU_file Method
julia
data_output = read_LaMEM_PVTU_file(DirName, FileName; fields=nothing)

Reads a 3D LaMEM timestep from VTU file FileName, located in directory DirName. Typically this is done to read passive tracers back into julia. By default, it will read all fields. If you want you can only read a specific field. See the function fieldnames to get a list with all available fields in the file.

It will return data_output which is a CartData output structure.

source
LaMEM.IO_functions.read_LaMEM_VTR_file Method
julia
data_output = read_LaMEM_VTR_file(DirName, FileName; fields=nothing, verbose=false)

Reads a 3D LaMEM timestep from VTR or VTS file FileName, located in directory DirName. By default, it will read all fields. If you want you can only read a specific field. See the function fieldnames to get a list with all available fields in the file.

It will return data_output which is a CartData output structure.

source
LaMEM.IO_functions.read_LaMEM_fieldnames Function
julia
read_LaMEM_fieldnames(FileName::String, DirName_base::String=""; phase=false, surf=false, tracers=false)

Returns the names of the datasets stored in FileName

source
LaMEM.IO_functions.read_LaMEM_simulation Function
julia
Timestep, FileNames, Time = read_LaMEM_simulation(FileName::String, DirName::String=""; phase=false, surf=false, passive_tracers=false)

Reads a LaMEM simulation FileName in directory DirName and returns the timesteps, times and filenames of that simulation.

source
LaMEM.IO_functions.read_LaMEM_timestep Function
julia
data, time = read_LaMEM_timestep(FileName::String, TimeStep::Int64=0, DirName::String=""; fields=nothing, phase=false, surf=false, last=false)

This reads a LaMEM timestep.

Input Arguments:

  • FileName: name of the simulation, w/out extension

  • Timestep: timestep to be read, unless last=true in which case we read the last one

  • DirName: name of the main directory (i.e. where the *.pvd files are located)

  • fields: Tuple with optional fields; if not specified all will be loaded

  • phase: Loads the phase information of LaMEM if true

  • surf: Loads the free surface of LaMEM if true

  • passive_tracers: Loads passive tracers if true

  • last: Loads the last timestep

Output:

  • data: Cartesian data struct with LaMEM output

  • time: The time of the timestep

source
LaMEM.IO_functions.read_phase_diagram Method
julia
out = read_phase_diagram(name::String)

Reads a phase diagram from a file name and returns a NamedTuple with temperature T, pressure P, melt density ρ_melt, solid density ρ_solid, density ρ and melt fraction ϕ

source