Run a Single Simulation

First, we will run a single OpenFOAM simulation using the motorBike case. This should be straightforward as all the necessary input files are already prepared, as described in the previous section.

Code Overview

The Python code required to run a OpenFOAM simulation using the Inductiva API follows a consistent structure. We adapted it for this specific use case, as shown below.

import inductiva

# Allocate cloud machine on Google Cloud Platform
cloud_machine = inductiva.resources.MachineGroup( \
    provider="GCP",
    machine_type="c2d-highcpu-4",
    # 1 thread per physical core
    threads_per_core=1,
    spot=True)

# Initialize OpenFOAM stack
openfoam = inductiva.simulators.OpenFOAM( \
    version="8",
    distribution="foundation")

task = openfoam.run( \
    input_dir="openfoam-input-example/",
    shell_script="./Allrun",
    on=cloud_machine)

# Wait for the simulation to finish and download the results
task.wait()
cloud_machine.terminate()

task.download_outputs()

task.print_summary()

Note: OpenFOAM-Foundation v8 limits the simulation to use only physical cores, this is why we use threads_per_core=1. Learn more about this here.

When the simulation is complete, we terminate the machine, download the results and print a summary of the simulation as shown as follows.

Task status: Success

Timeline:
        Waiting for Input         at 03/06, 10:31:51      1.346 s
        In Queue                  at 03/06, 10:31:52      41.149 s
        Preparing to Compute      at 03/06, 10:32:34      4.007 s
        In Progress               at 03/06, 10:32:38      156.559 s
                └> 156.233 s       bash ./Allrun
        Finalizing                at 03/06, 10:35:14      1.23 s
        Success                   at 03/06, 10:35:15

Data:
        Size of zipped output:    115.53 MB
        Size of unzipped output:  184.12 MB
        Number of output files:   110

Total estimated cost (US$): 0.0180 US$
    Estimated computation cost (US$): 0.0080 US$
    Task orchestration fee (US$): 0.010 US$

Note: A per-run orchestration fee (0.010 US$) applies to tasks run from 01 Dec 2025, in addition to the computation costs.
Learn more about costs at: https://inductiva.ai/guides/basics/how-much-does-it-cost

You can also visit the Inductiva Web Console to view task details, navigate the task the filesystem, and monitor logs in real time.

In the next part of this tutorial, we'll take things to the next level by running dozens of OpenFOAM simulations in parallel on Inductiva, demonstrating the true power of cloud-based scalability. Stay tuned!