Skip to content

Launching your first simulation

ghazalemir edited this page Apr 6, 2020 · 26 revisions

The objective of this section is to highlight the steps that are necessary to launch your a simulation after you have cloned and compiled Lethe.

Launching of an application requires an executable of the required solver, and a parameters file (with extension .prm if it uses the parameter file format, or .json if it uses the JSON file format). After building Lethe, the solver executable files can be found in : $BUILD_FOLDER/applications directory

For instance, gd_navier_stokes_2d executable is located in the $BUILD_FOLDER/applications/gd_navier_stokes_2d directory.

The executable for the solvers can be used directly from the folder it is compiled to. This can be achieved by:

  • Writing the absolute path of the solver (e.g. $BUILD_FOLDER/applications/gd_navier_stokes_2d/gd_navier_stokes_2d`);
  • Adding the lethe folder paths to your PATH environment variable;
  • Specifying an installation folder when you compile Lethe to ensure that all the applications are grouped within a single folder;
  • Locally copying the executable to the folder you are running your simulation from.

All these workflow can achieve the same result.

To launch a simulation, you must specify the solver executable and the parameter file in the following format: solver parameter_file. For example, glsNS2d poiseuille2d.prm

In what follow, we describe a simple procedure to launch your first simulation using Lethe.

Step 1: Copying an example

The source folder of lethe contains an examples folder. This folder contains ready to run examples. Some examples use the mesh generation capacity of Lethe and only require a parameter file, whereas others contain an additional '.msh' file to describe the mesh. In the present case, we copy the 'examples/cavity' example to a new folder using the terminal 'cp -r $SOURCE_FOLDER/examples/cavity destination/first_simualtion'

Step 2: Launching the example

The cavity example we are launching uses the 2D gls_navier_stokes solver. All of the solvers of Lethe can be found in the build folder where you have compiled Lethe or within the installation folder. Inside of your build folder, six other folders should be found:

  • applications;
  • applications_tests;
  • CMakeFiles;
  • prototypes;
  • source;
  • tests;

Inside the applications folder, there is one folder for each solver of Lethe. In the gls_navier_stokes_2d folder, we find the executable file with the same name as the folder: 'gls_navier_stokes_2d'. This solver solves the 2D incompressible Navier-Stokes equations using a Galerkin Least-Square formulation.

From the 'first_simulation' folder we have created, we can launch the simulation directly. I you have decided to copy the executable to the 'first_simulation' folder, you can launch using the following command: './gls_navier_stokes_2d cavity.prm'. You can also launch the simulation using the absolute path of the executable:'$BUILD_FOLDER/applications/gls_navier_stokes_2d/gls_navier_stokes_2d cavity.prm'.

Step 3: Post-processing the results

Once the application has ran, the simulation results can be looked at by opening the '.pvd' file using Paraview.

Understanding the examples

Lethe comes pre-packaged with some examples which are documented on the present wiki. We greatly encourage you to look at these examples to understand how Lethe can be used to solve CFD problems. For a more in-depth understanding of the parameter file, the reader can take a look at this section of the wiki.

Example 1 : Cavity Flow

In this example, flow of fluid in a two-dimensional square-shaped cavity is simulated using Lethe. The geometry and boundary conditions of the simulated system is illustrated in the following. (Fig1) In this case, only the upper wall boundary (ID = 3) moves in x direction with a constant velocity (u = 1 m/s) while the other boundaries are fixed (no slip boundary condition). Note the numbering method of the boundaries in Lethe format on this figure. We will use "gls_navier_stokes_2d" solver for this simulation. In the parameter handler file the geometry and mesh is determined as:


#---------------------------------------------------
# Mesh
#---------------------------------------------------
subsection mesh
    set type                 = dealii
    set grid type            = hyper_cube
    set grid arguments       = -1 : 1 : true
    set initial refinement   = 6
end

As can be observed, the geometry is defined using a hyper_cube, starting from -1 to 1 in each direction and the initial number of refinements is set equal to 6. The boundary conditions of this simulation are also determined as:


# --------------------------------------------------
# Boundary Conditions
#---------------------------------------------------
subsection boundary conditions
  set number                  = 4
    subsection bc 0
        set id                = 0
        set type              = noslip
    end
    subsection bc 1
        set id                = 1
        set type              = noslip
    end
    subsection bc 2
        set id                = 2
        set type              = noslip
    end
    subsection bc 3
        set id                = 3
        set type              = function
        subsection u
            set Function expression = 1
        end
        subsection v
            set Function expression = 0
        end
    end
end

In the boundary conditions section, "no slip" boundary condition was chosen for the first three boundaries, while the motion of the top wall is defined using function boundary condition. In the function boundary condition, the velocity in x direction is set equal to 1. The velocity distribution in the steady state is illustrated in the following: (Fig2)

Clone this wiki locally