Cavity2d

For a while, I used the old version of Palabos software.

It recently updated and I have opportunity to attend a online Summer school. Honestly to say, there are so many items I do not know. Then, it is necessary to practice the hands-on exercises.

Install cmake and paraview

To compile this example you need Cmake installed in your system. To check the installation type on your terminal: cmake --version.

If it returns an error, you need to proceed with the installation. Try sudo apt install cmake

You will also need to have installed paraview in your machine to read the output files and
(optionally) gifsicle to merge .gif files created by Palabos. Test if they are already installed with installed: gifsicle --version and paraview --version. If this is not the case, try to install them:

sudo apt install gifsicle

sudo apt install paraview

CMAKE file

At first, you need compile the CMAKE file, and produce a EXE file. For this file, you need to know where to change the project name and define the executable_name, when necessary.

1
2
3
4
5
project(cavity2d)
enable_language(CXX)

set(EXECUTABLE_NAME "cavity2d_incomplete_with_bug")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "../")

Most importantly, you need set the PALABOS_ROOT. Otherwise you will face a compile error after the command cmake ..

# # # If the palabos root folder is in your path, you don't need to modify anything.
# # # In the other case you have 2 options: 1. add PALABOS_ROOT=path/to/palabos to the path of your system
# # # 2. you comment the next line and uncomment the one after, explicitly giving the path/to/palabos
# # # (NB you can use ${CMAKE_CURRENT_SOURCE_DIR} to give paths relative to the CMakeLists.txt location)
#file(TO_CMAKE_PATH $ENV{PALABOS_ROOT} PALABOS_ROOT)
set(PALABOS_ROOT "../../.")

Open a terminal in the current directory and type the following commands to compile the code with cmake:

cd build
cmake .. && make -j 2
cd ..

At this point you should have an executable in the current directory
named cavity_2d_incomplete_with_bug. Try to run it in parallel

mpirun -np 2 cavity_2d_incomplete_with_bug

in the case of a linux-based system.

or just using:

./cavity_2d_incomplete_with_bug

Cavity2d.cpp

In the main function, Physical and Numerical parameters can be set for the simulation.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
    // Physical parameters (chosen by the user).

    T lx = 0.05; // length in x direction, 0.05 m
    T ly = 0.05; // length in y direction, 0.05 m
    T uPhys = 0.02; // fluid velocity, 0.02 m/s
    T nuPhys = 0.00001; // kinematic viscosity, 10-5 m2/s 

    // Numerical parameters (need to be filled by the participants).

    uLB = 0.01; // fluid velocity 
    plint N = 256; // grids

    dx = lx / ((T) N - 1); // lattice spacing
    nx = util::roundToInt(lx / dx) + 1; //Grids i	n x direction
    ny = util::roundToInt(ly / dx) + 1; //Grids in y directions

    dt = dx * uLB / uPhys; // time step

    T nuLB = nuPhys * dt / (dx*dx); // kinematic viscosity

    T tau = DESCRIPTOR<T>::invCs2 * nuLB + 0.5; // Tau, BGK Relaxration Time
    T omega = 1.0 / tau;

At last, have a glance at the uNorm at 9s in the 2D Cavity:

uNorm

updatedupdated2020-07-312020-07-31