Scaling coastal engineering projects with Inductiva API

Ivan Pombo
Ivan Pombo Author
Luís Sarmento
Luís Sarmento Reviewer

Portugal has one of the largest coast-to-area ratios with enchanted beaches under the sun, making it one of the top European summer destinations. However, such an extensive coastline is also a fragile ecosystem, exposed to erosion, overtopping and flooding, from North to South [1]. A recent report states that Portugal lost more than 1313 hectares of coastal territory from 1958 to 2020 [4]. To know more about the impact of these problems check this documentary.

In this blog post, we illustrate how Inductiva API democratizes simulations at scale. In particular, we showcase how coastal engineering researchers from the Hydraulics, Water Resources and Environment Division Laboratory (SHRHA) at the Faculty of Engineering of Porto University (FEUP) employed it to study the best way of protecting a particularly fragile section of the Portuguese coastline.

Coastal Protection

Furadouro Beach is a beautiful beach located between Porto and Aveiro. In the last decades, this region has been subject to severe coastal erosion, and, consequently, populations have suffered from recurrent flooding events and loss of property [2, 3].

Figure 1. Satellite view of Furadouro beach. Credits: Google Earth.

The Hydraulics, Water Resources and Environment Division Laboratory (SHRHA) at FEUP has been at the forefront of research on coastal protection. The research they develop is broad and goes from the conception and design of protective maritime structures to supporting their final deployment on-site.

In the case of Furadouro, FEUP researchers have been studying the possibility of building a breakwater to mitigate flooding events. Breakwaters have been extensively deployed around Portugal to protect the coastline and are effective mechanisms to protect the coast by decreasing the energy of the waves and stopping them from overtopping structures on the shore.

To find an optimal breakwater arrangement that offers the most protection for multiple sea conditions we need to select several parameters: number of breakwaters (1, 2, 3,…) and the shape, location and dimensions of each breakwater. Even though the problem seems simple, there are millions of possible configurations at stake.

How to find an optimal breakwater?
Simulation to the rescue

To study the usefulness and validity of so many possibilities, researchers take advantage of computational simulation. Simulation is a low-cost solution for estimating the impact of different breakwater configurations. The alternative to simulation would be building small-scale physical replicas of the project and testing them in an actual wave tank. But that is extremely expensive and, therefore it can only be implemented for a small number of designs. On the other hand, we can run simulations to test thousands of configurations.

For this specific type of coastal engineering project, one of the most frequently used simulation packages is SWASH, a numerical tool that solves the nonlinear shallow water equations, that describe the wave propagation from deep water to beaches, ports and others that present complex changes to rapidly varying flows in shallow waters (such as rivers).

To create a virtual beach, researchers used data from topographic surveys that create a representative bathymetry of the region under study.

Thereafter, the simulator is configured to set up various wave conditions and iterate over a diverse set of admissible breakwaters configurations. After running the simulations, engineers process the outputs and compute metrics for evaluating the effectiveness of each breakwater configuration.

Video 1: Simulation of a single wave configuration at Furadouro beach, as currently it is, without breakwaters. The red color represents a higher free surface elevation. Credits: Moeketsi Lawrence Duiker / FEUP

In video 1, the coastal area is represented in white with some residential buildings in colors. After 400s the waves are overtopping the shoreline, represented by a high free surface elevation in red. At 800s, a sequence of waves hits the shore and floods the area, represented by a red region in the residential area. Breakwaters are meant to mitigate these effects.

Running simulations

A single realistic SWASH simulation takes 40h on a single thread of a standard CPU.

The simulation in video 1, takes approximately 40h to run on a single core in a local computer, which significantly hinders a search for an optimal breakwater. For example, running 10 simulations, a small fraction of the admissible search space, would take about two weeks. As a result, many interesting design options – even potentially the optimal one – are likely not to be even considered and evaluated under simulation.

FEUP researchers at SHRHA started using a better computational infrastructure, that allowed them to parallelize the simulation to 16 threads. Now, a simulation takes 4h, ten times less than running it in a single core. Notice that, the increase to 16 threads does not provide a sixteen times speed-up.

An easy way to scale further is to run multiple simulations in parallel, however, a certain level of expertise is required to manage multiple machines. Ideally, researchers should be able to solely focus on their simulations and not have to deal with all of this complexity.

This is where Inductiva API comes into play!

Inductiva API

Inductiva API is the way to go for simulations using on-demand high performance machines! Inductiva API allows users to configure, run and scale their simulations in a simple way with only a few lines of Python code. Users can benefit from the best performance, while Inductiva takes care of all the complexity!

For example, to run a typical SWASH simulation we need a configuration file (named input.sws) and a bathymetry file. Other files may be used to configure other aspects of the simulation and so we will assume that all of them are placed in the swash_input folder.

The Python code to run such a typical SWASH simulation with Inductiva API is as follows:

import inductiva

# Initialize the simulator
swash_sim = inductiva.simulators.SWASH()

# Launch the asynchronous simulation
task = swash_sim.run(input_dir="swash_input", sim_config_filename="input.sws")

# Wait for it to finish
task.wait()

Observe that, besides installing Inductiva API client, via a single command line pip install inductiva, no other setup step is needed to start running simulations.

Now, this simulation was submitted to a shared pool of machines, which serve mostly for testing purposes, and may not improve much the times obtained with the current FEUP infrastructure.

However, with Inductiva API we provide computational flexibility and allow users to select higher-performance hardware not available in everyday computers. Using the Inductiva API you can select the type of (virtual) machine where a simulation is going to run. Currently, we are making available machines from Google Cloud. As an example, we will now choose a c2d-standard-16 machine that contains 16 virtual CPUs (vCPUs). Observe that up to now we have been talking about threads, and now we are talking about vCPUs. For all practical purposes because of the way the virtualization is made we can consider vCPUs to be equivalent to threads.

So, let’s look at an example:

import inductiva

# Launch a Machine Group with one machine of type c2d-standard-16
machine = inductiva.resources.MachineGroup(machine_type="c2d-standard-16")
machine.start()

# Initialize the simulator
swash_sim = inductiva.simulators.SWASH()

# Launch the same simulation into the dedicated machine
task = swash_sim.run(
  input_dir="swash_input", sim_config_filename="input.sws", on=machine)

# Wait for it to finish
task.wait()

With this virtual machine, the simulation took 3h43m06 which is on par with the performance obtained with FEUP infrastructure. However, virtual machines with a higher number of vCPUs are available and can be used to improve performance. In the section, we use a c2d-standard-112 machine with 112 vCPUs and take the exploration to the next level.

Taking exploration to the next level

In the particular case of searching a design space, Inductiva API allows to scale further by running multiple simulations simultaneously. Researchers at the Hydraulics Lab at FEUP took advantage of this feature to run 40 simulations in parallel from their local computer. Let’s see the details!

Just send them all in one go!

After preparing all of the input folders in a general input_dataset folder, that contains the configuration files for all the simulations we wish to run, we are ready to go. Here, we combine launching 40 machines and simulations in parallel with 112 vCPUs.

import inductiva

inductiva.output_dir = "swash_dataset"
tasks = []
num_simulations = 40

# Initialize the simulator
swash_sim = inductiva.simulators.SWASH()

machine_groups = inductiva.resources.MachineGroup(
              machine_type="c2d-highcpu-112",
              num_machines=num_simulations)
machine_groups.start()

for sim_index in range(num_simulations):
    # Run the simulation
    task = swash_sim.run(input_dir=str(sim_index),
                  sim_config_filename="input.sws",
                  on=machine_groups)
    tasks.append(task)

Researchers obtain the results of all 40 simulation in 1h10min. Notice that, running them sequentially it would take 40h40min or around 2 days in the same machine, or 160h and around 7 days with the previous infrastructure used by FEUP.

This represents a 40x speed-up compared with running sequentialy and a 137x speed-up on the previous infrastructure used by FEUP.

In a single day, the search was finished and, swiftly, they tested more configurations than they would be able to do before. This brute-force approach led them to obtain an almost perfect protection strategy with two decouple breakwaters and a V breakwater connected to the land, see the simulation video below. The optimal design of this experiment protects almost all of Furadouro coastline against flooding events.

Video 2: Simulation of a single wave configuration at Furadouro beach, with an optimal breakwater strategy deployed near shore. Credits: Moeketsi Lawrence Duiker / FEUP

Breaking down the numbers

Recall that before starting to use Inductiva API, users were either running their simulations locally or in the FEUP infrastructure. At the start, this allowed them to configure the simulation to avoid instabilities and computational errors, a common strategy in the simulation community.

However, the search for an optimal breakwater they needed to scale even further their infrastructure. Here, Inductiva API allowed researchers to scale up and accelerate their exploration, by running simulations simultaneously over multiple high-performance machines. From the comfort of their local computer, researchers could launch multiple machines and ran their simulations in parallel.

Let’s break down the performance of the hardware in numbers. The following table shows the time a single simulation takes to run for different hardware infrastructures. To highlight the versatility of Inductiva API we include the times for several different machines that are available to the user:

Workers Simulation Time
1 thread ~ 40h
FEUP Infrastructure - 16 threads 4h
Inductiva API - “c2d-standard-16” 3h43m06
Inductiva API - “c2d-standard-32” 1h58m35
Inductiva API - “c2d-standard-56” 1h18m52
Inductiva API - “c2d-standard-112” 1h03m05
Inductiva API - “c3-standard-88” 1h08m41
Inductiva API - “c3-standard-176” 0h57m30
Inductiva API - “c3d-standard-90” 1h12m58
Inductiva API - “c3d-standard-180” 0h49m37s

When researchers select a machine similar to the FEUP infrastructure, with the same number of cores, Inductiva API matches the simulation time. To scale and obtain a performance boost, researchers can simply select a better machine, like the c3d-standard-180.

Inductiva API accelerated by 4.89x a single simulation!

This is just part of the story. Inductiva API lets researchers launch many high-performance machines simultaneously and run multiple simulations in parallel, which means that the time cost for running N simulations, over N machines, is the same as running one simulation. All of it from your local computer, without worrying about the hardship of managing several machines.

And… Inductiva API is User friendly

Inductiva API is powerful and users loved the experience!

My research goal was to find an optimal solution for the protection of flooding events. With Inductiva API, I conducted my exploration in a single day! Moreover, I could launch all of the simulations simply from my local computer.

— Lawrence Duiker, Master’s Student at FEUP

Inductiva API is the simplest way for researchers and engineers to scale their simulations and obtain results faster!

🌊🌊🌊 Simulations at Scale 🌊🌊🌊

Empowered with the ability to run multiple simulations at the same time, finding an optimal solution is much simpler! Researchers can put all their efforts into their research instead of dealing with the complexity and hardship of scaling their experiments.


Acknowledgements

Inductiva wants to acknowledge our partners at FEUP Hydraulics laboratory. Namely, we would like to express our gratitude to the researchers involved in this collaboration: Prof. Paulo Rosa Santos, Director of the Hydraulics laboratory at FEUP, Dr. Jose Victor Castro and the master student Moeketsi Lawrence Duiker.

Disclaimer

This study is set in an academic background and the results presented here are not representative of all possibilities and effects in real-world applications. The results presented here are only for demonstration purposes.

References

[1] Ferreira, O., & Matias, A. (2013). Portugal. Coastal Erosion and Protection in Europe, 275.

[2] De Freitas, J. G., & Dias, J. A. (2017). A historical view on coastal erosion: The case of Furadouro (Portugal). Environment and History, 23(2), 217-252.

[3] Pinto, I. M. P. (2022). Galgamentos e Inundações Costeiras na Frente Urbana do Furadouro-Concelho de Ovar. Master thesis at FLUP.

[4] COSMO. https://cosmo.apambiente.pt/

Recent posts from our blog

Luís Sarmento

Luís Sarmento

Ivan Pombo

Ivan Pombo

Maya Hershey

Maya Hershey

Discover the 3D model mesh resolution threshold that still yields stable and dependable estimations of physical properties in engineering simulations.

Hugo Penedones

Hugo Penedones

Luís Sarmento

Luís Sarmento

The Inductiva API v0.5 release brings two New Simulators, Up-to-date GCP pricing information, additional features on Command Line Interface, more Metrics and Benchmarks, a Template Manager and more revamped Documentation. Additionally we are open sourcing all the scientific software containers we are using in our backend - Project KUTU.