awx

← Blog

Walk-through · 24 November 2026

How to run an OpenFOAM simulation overnight, laptop closed

A CFD run can take hours. If you run it on your laptop, it stays on, busy and plugged in the whole time. We used an awx computer to run OpenFOAM’s classic cavity flow at a Reynolds number of 1,000 on 65,536 cells. The solver ran for an hour without anyone watching. Then we used ParaView to see the flow and checked the result against the benchmark every CFD course uses.

Awi the cat agent asleep on a laptop

Step 1: a computer that keeps running

Create a Large computer in awx. We called ours openfoam-cfd, and it had 1.5 vCPU and 2 GiB of memory. Before you install anything, open Settings, go to Power, and tick Keep it running until my credit runs out.

An awx computer goes to sleep after 30 minutes without anyone using it. A solver can be busy all that time and still count as unattended. Ticking the box lets the computer keep running after you close your laptop. It stops on its own only when your credit runs out. Untick the box once the run is done. On the paid plan, running time costs nothing.

Step 2: install OpenFOAM and ParaView

Run these commands in the computer’s Terminal tab.

sudo apt-get update
sudo apt-get install -y openfoam paraview
echo 'export WM_PROJECT_DIR=/usr/share/openfoam' >> ~/.bashrc
source ~/.bashrc

The install took 36 seconds and gave us OpenFOAM v1912 and ParaView 5.11. Ubuntu’s package already puts the programs on your path, so you can skip the step in the official installers that asks you to source an OpenFOAM bashrc. The programs still need to know where to find their settings. The third line sets that variable. Without it, every solver stops with Could not find mandatory etc entry (mode=ugo) 'controlDict'.

Step 3: the tutorial cases

Ubuntu’s OpenFOAM keeps its tutorials under /usr/share/doc. If those folders look empty, that is because awx computers run a slim Ubuntu that leaves out the documentation, even though the folders are there. The commands below fetch the examples package and unpack it into your home folder (33 MB, about a second).

mkdir -p ~/cfd && cd ~/cfd
apt-get download openfoam-examples
dpkg-deb -x openfoam-examples_*.deb ex
ls ex/usr/share/doc/openfoam-examples/examples/incompressible/icoFoam/cavity

You can use the same approach for any Ubuntu package whose examples you cannot find.

Step 4: the classic cavity, in a tenth of a second

Start with the case every CFD course uses. A square box holds fluid, and its lid slides to the right at 1 m/s.

cp -r ex/usr/share/doc/openfoam-examples/examples/incompressible/icoFoam/cavity/cavity .
cd cavity
blockMesh          # the mesh: 20 x 20 = 400 cells
icoFoam            # the solver: laminar, incompressible

Meshing and solving together took 0.1 seconds. The solver ran for 100 time steps at a Reynolds number of 10, with a lid speed of 1 m/s, a box size of 0.1 m and a viscosity of 0.01 m²/s. You can find the results in folders 0.1 to 0.5. This is a good first check, and it runs easily without a cloud computer.

Step 5: make it a real run

Two changes make this a more demanding run. Making the fluid 100 times less viscous raises the Reynolds number to 1,000. That gives you a strong main vortex and small corner vortices. To resolve them, use a mesh of 256 × 256 cells (65,536, or 164 times the tutorial mesh).

cd ~/cfd && cp -r cavity cavity1000 && cd cavity1000
rm -rf 0.[1-9]* log.*
sed -i 's/(20 20 1)/(256 256 1)/' system/blockMeshDict
sed -i 's/^nu .*/nu              0.0001;/' constant/transportProperties
foamDictionary system/controlDict -entry deltaT -set 0.0002
foamDictionary system/controlDict -entry endTime -set 5
foamDictionary system/controlDict -entry writeControl -set runTime
foamDictionary system/controlDict -entry writeInterval -set 0.5
blockMesh

The smaller cells are the reason for choosing a time step of 0.0002 s. The Courant number is speed × time step / cell size, and OpenFOAM’s own tutorial says to keep it below 1 for this solver. The cells are now 0.1 / 256 = 0.39 mm. Using the lid speed of 1 m/s gives 1 × 0.0002 / 0.00039 = 0.51. The log confirms the value is below 1 (Courant Number ... max: 0.496), with the fastest cell a little slower than the lid. Five seconds of flow time takes 25,000 time steps and is 50 times as long as the lid takes to cross the box. Step 8 checks whether that gives the flow enough time to settle.

Step 6: start it, close the laptop

nohup icoFoam > log.icoFoam 2>&1 &

nohup and the & let the solver carry on after the terminal closes. Once the command is running, you can close the browser tab or the laptop. When you return, open the Terminal tab and use these commands to see how far the solver has got.

cd ~/cfd/cavity1000
pgrep -a icoFoam; grep '^Time =' log.icoFoam | tail -n 3; grep ExecutionTime log.icoFoam | tail -n 1

While the solver is running, pgrep shows icoFoam. When the run finishes, pgrep prints nothing. You can confirm it finished by checking that the log ends with End.

The awx Terminal tab of the computer openfoam-cfd, showing that icoFoam is running and has reached Time = 0.6624 after 983 seconds
Sixteen minutes in: still running, at 0.66 s of the 5.

The whole run took 1 hour 5 minutes (3,884 seconds) on the Large computer. The run sped up because the solver needed fewer iterations per time step as the flow settled. It uses one core here, so a recent laptop might finish just as quickly. Running it on the Large computer meant we could close the laptop and leave the solver to finish on its own.

Step 7: look at the flow

ParaView can draw the flow without a screen. Our script render.py loads the last saved time, colours the cavity by speed and adds streamlines. It also saves the velocity along the two centre lines so you have the values you need for Step 8. Download both scripts into the case folder and run the rendering script there.

cd ~/cfd/cavity1000
for f in render.py compare.py; do curl -sO https://awanbox.com/blog/files/openfoam-cavity/$f; done
touch cavity1000.foam                  # an empty file ParaView opens the case by
pvpython --no-mpi render.py

The script saves cavity_speed.png in the case folder. You can open it from the Files tab. The --no-mpi switch skips MPI because ParaView does not need it here. While our long run was going, plain pvpython stopped with Unable to start a daemon on the local node. It worked on a fresh computer, and the switch lets it work in both situations. To explore the flow by dragging and turning the view, start paraview on the computer’s Desktop tab and open cavity1000.foam.

The square cavity coloured by speed, from dark purple (still) to yellow (1 m/s) along the moving lid at the top; white streamlines circle one large vortex whose centre sits a little above and right of the middle of the box
After 5 seconds: one large vortex, its centre a little above and right of the middle, and nearly still fluid in the bottom corners.

Step 8: check it against the benchmark

Before you rely on a CFD result, check it against a reference. For this flow, the standard is Ghia, Ghia and Shin (1982). They used a careful 129 × 129 calculation of the steady flow, and their velocities along the box’s two centre lines have been the reference ever since. The script compare.py checks that our flow has settled by looking for agreement between the last two saved times. It then compares Ghia’s values with our velocities along the same lines, taken using ParaView’s Plot Over Line and saved as CSV by render.py. Run the script in the case folder. The matplotlib it needs came with ParaView.

python3 compare.py
largest change on the centre lines between the last two saved times: 0.0005 (lid speed = 1)
u on the vertical centre line:   largest difference from Ghia 0.005, average 0.002 (lid speed = 1)
v on the horizontal centre line: largest difference from Ghia 0.016, average 0.006
strongest backflow u = -0.386 at y = 0.173 (Ghia: -0.383 at 0.172)
Two charts comparing the OpenFOAM run (purple line) with Ghia et al. 1982 (orange circles) at Re = 1000. Left: horizontal speed along the vertical centre line, from about -0.38 near the bottom to 1 at the lid. Right: vertical speed along the horizontal centre line, from about 0.37 on the left to -0.52 on the right. The purple curves pass through every orange circle.
Our run (purple) against Ghia’s table (circles), on both centre lines.

Between 4.5 and 5 seconds, the velocities on the centre lines changed by at most 0.0005 of the lid speed. That tells us the flow had settled, so we can compare it with the steady flow Ghia tabulated. On the vertical line, the horizontal speed is within 0.005 of Ghia everywhere (0.002 on average). On the horizontal line, the vertical speed is within 0.016 (0.006 on average). Our strongest backflow, −0.386 at 17.3% of the height, is close to Ghia’s −0.383 at 17.2%. This is the agreement you would expect from a 256 × 256 mesh. Include these comparisons in your CFD report so the reader can see how closely the run matches the benchmark.

What it cost

On the Free plan, a Large computer uses RM0.10 of credit an hour and is billed by the minute. This run lasted just over an hour and cost about RM0.11. New accounts start with RM5, and on the paid plan running time is included. When you finish, untick Keep it running so the computer can sleep again.

To set up the case in one go, use make_case.sh. After the install in Step 2, run bash make_case.sh to do steps 3 to 5. The scripts for viewing and checking the results are render.py and compare.py.

Common questions

Can I run OpenFOAM without a powerful laptop?

Yes. The awx computer in the cloud runs the solver. Your laptop only displays the terminal in a browser tab, so you can close the laptop while the run continues.

Will the run stop when I close the laptop?

The run can continue if you start it with nohup and tick Keep it running until my credit runs out in the computer's Settings. If you leave the box unticked, an unused computer goes to sleep after 30 minutes and the run stops.

Which OpenFOAM is this?

We used apt to install Ubuntu's package, which provides OpenFOAM v1912 from openfoam.com. If your course uses a newer version from openfoam.com or openfoam.org, you can install it on the same computer.

How big a case can I run?

A Large computer has 2 GiB of memory. That is plenty for 2D cases and for small 3D cases with a few hundred thousand cells. If you are working with bigger 3D cases, keep the mesh coarse while you learn.

Keep reading

Getting started

Sign in with your Google account and ask to join. Once your request is approved, create a Large computer and follow the steps above to run the case.

Open awx

Awi the cat agent celebrates with confetti

Awi, signing off.

← All posts