This folder contains a few setups for LaMEM, which are created within MATLAB/OCTAVE.

Using MATLAB/Octave to generate a model setup is a very flexible way to precisely
control the phase and temperature at every point of the domain. You can also look 
at the setup before creating an actual simulation. It generates the input markers,
which are read in by LaMEM upon starting.

Compared to defining the internal geometry, this method has the disadvantage that 
you need to run an octave/matlab script before you start a LaMEM simulation. If the 
resolution of your model domain changes, you'll have to to recreate the input file.

There are two ways to create a setup, depending on whether you will run LaMEM in 
   parallel or not:
   

Method 1) If you run your simulation on one processor, you can simply run the 
   corresponding *.m file, while making sure that the LaMEM *.dat input file is 
   in the same directory

Method 2) Of you run your simulation in parallel, you first need to generate a 
   parallel partitioning file, as explained below.


Creating such a geometry involves 3 steps:

2a) Create a partitioning file, by adding the command-line option "-mode save_grid"
   ../../bin/opt/LaMEM -ParamFile <FileName.dat> -mode save_grid
 
2b) Run the MATLAB script, while making sure that the partitioning file is specified
   All examples in this directory also create a VTK file of the input geometry and 
   temperature structure, so you can check it is correct, before running a simulation.
   This file is called VTK_ModelSetup_paraview_binary.vtr

2c) Run the LaMEM file, the normal way (or with "-mode normal", which is default)
   ../../bin/opt/LaMEM -ParamFile <FileName.dat>

And as always, you can use Paraview to visualize the files.


If you are a new user of LaMEM, we recommend you look & run the files in the
following order:

1) Subduction2D_FreeSlip_MATLABParticles_Linear_DirectSolver.dat:
   2D subduction setup, in which the slab has a constant (linear) viscosity,
   we employ a free slip upper boundary and a plastic crust.
   Use the MATLAB script CreateMarkers_Subduction_Linear_FreeSlip_parallel.m
   to create the input geometry.

2) Subduction2D_FreeSurface_MATLABParticles_Nonlinear_DirectSolver.dat: 	   
   2D subduction setup, but in this case we also have a free surface, set
   the initial temperature structure in MATLAB (based on halfspace cooling)
   and employ a viscoelastoplastic rheology with both dislocation and 
   diffusion creep (where we also show how to override the default value of
   the activation volume)   

  
3) Subduction3D_FreeSlip_MATLABParticles_Linear_Multigrid.dat:    
   As 1), but with a 3D geometry and a multigrid solver, and with a lower
   resolution (to make this work on smaller machines as well) 

Last updated: Boris, 4.11.2020