person-carry-boxTutorial

This page will explain the set-up, run and visualization of a typical case. For a quick overview of running the code, see Quickrun. At a glance, domain dimension and control parameters are handled in the file inputs (or similar name) while the problem description is in prob.h

circle-exclamation

Problem Set-up

The problem involves a heavy fluid descending into a lighter fluid, creating conditions for a Rayleigh-Taylor instability. The upper half of the domain contains a fluid with a density of 2, while the lower half is filled with a fluid of density 1. The initial pressure distribution is hydrostatic, and a velocity perturbation is introduced to trigger the instability The initial conditions can be summarised as

where Inline equation: y0y_0 is the middle of the domain, P0=2P_0=2 is the pressure and gravity is taken as 1 pointing downwards and the perturbation is ϵ=0.025\epsilon=0.025. The initial conditions followed the paper by Shi et al . Both fluids are miscible and follow the ideal gas law with adiabatic coefficient of 5/3.

prob.h

Set-up of Problem Parameters

The parameters of the problem (not the domain) are wrapped into a ProbParm structure

// problem parameters
struct ProbParm {
  Real p_int = 2.0;
  Real rho_1 = 1.0;
  Real rho_2 = 2.0;
  Real grav = -1.0; 
  Real eps =  0.025;
};

Set-up of initial conditions

This is done in the function prob_initdata

where the spatial coordinates x and y of the cells are determined from the mesh sizes and problem dimensions (which are defined in inputs).

The initial conditions are defined as

The array state holds all the information required in conserved variables

to initialise the problem.

Solvers

The solvers are selected in the line

which defines the problem to solve

Source Term

Function

The lines below loop over the cells and gravity is added to the momentum and energy equation. The prob_parm.grav reads the gravity value defined in ProbParm structure.

AMR

This function defines which points need to be "tagged" to be refined. AMReX will then create patches around that cell to create the refined regions.

The actual tagging is produced in the follwoing lines, where the array tagfab(i,j,k) is set to true or false based on the value of density.

Input file

Time steps

Boundary conditions

The boundary conditions are defined in the following lines. More complex configurations can be specified—see the boundaries set-up section for details.

The boundary conditions above specify periodic boundaries at both ends of the x-direction and no-slip walls along the y-direction.

Mesh and refinement

These lines will select the size of the mesh and how often to regrid

Compile and Running

To compile use

and run case using 2 cores (or any number you want)

Post-processing

The input file is set up to plot every 100 steps

In the following sectionsm we will show how to visualize the results using Python, Visit and Paraview.

Python

The following assumes that yt is installed. See the Tips section for installation instructions. A Python script has been set up for ease of use and can be run with:

The last density snaphot at t=2 will be saved into a png file, which looks like (with default color scheme in yt).

Results of python plot.py

Visit

To see the results with VisItarrow-up-right, you can use the script cerisse, to open all directories at the same time (to make an animation for example). See Tipsarrow-up-right to set-up the script.

This will create a file movie.visit in the tutorial directory. To open Visit, type visit (or use the appropiate icon).

Once opened, use File/Open to load the movie.visit file. If it loads correctly, it should look something like:

Adding a plot is easy by just Add/Pseudocolor/Density

The results shows the pseudocolor for density with default visualization options (see Visit manual and webpage for details on costumization). By clicking the arrow in the panel

we obtain a quick animation of the results. The final snapshot should be

By Add/Subset/Levels we can get an idea of the refinement

Double-cliking on the Subset/Levels we can edit the attributes of the plot

And the final plot should look like, where the solid lines are the limits of refinmement

There is no need to load the entire database—individual time steps can be opened by accessing their respective header files (e.g., plot/plt02600/Header). VisIt is well-suited for interactive data exploration and also supports Python scripting. For a VisIt tutorial, see the VisIt users in VisIt tutorialarrow-up-right

Paraview

To use Paraviewarrow-up-right, start Paraview in the usual way and open the plot\plt... folder

Select the AMReX/Boxlib Grid Reader

Tick the density box and click Apply, it would look something like

Select Density and Surface

And then use the final time to show the final plot (with default options)

Like VisIt, ParaView is well-suited for interactive data exploration and supports Python scripting. Both tools offer similar capabilities, including HPC integration, remote visualization, and efficient handling of large datasets—with support for billions of data points. A Paraview Tutorial and manual can be found in Paraview Manualarrow-up-right

Last updated