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 and our coastal engineering blog post series.

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 setup various wave conditions and iterate over a diverse set of admissable 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 shore line, 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 to run.

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 admissable 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 cores. Now, a simulation takes 4h, ten times less than running it in a single core. Notice that, the increase to 16 cores 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 others 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.fluids.SWASH()

# Run the simulation
swash_sim.run(input_dir="swash_input", n_cores=16)

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. This specific simulation can now be run in just 3h40min.

With three lines of code, Inductiva API is in the same playing field as the infrastructure FEUP was using before.

But we don’t have to stop here: there is still room for improvement. With Inductiva API you can select a much higher-perfomance hardware not available in everyday’s computers. As an example, we will now choose a machine with an AMD EPYC Milan (3rd gen) CPU containing 56 cores, designated by c2d-highcpu-112 in the Google Cloud nomenclature for running the same simulation.

import inductiva

# Launch a machine with 56 cores
machines = inductiva.resources.launch_machines(machine_type="c2d-highcpu-112")

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

# Run the simulation
swash_sim.run(input_dir="swash_input", n_cores=56)

With this setup, we achieve the same simulation result, but in 1h10min, a 3.43x speed-up by increasing 3.5x the number of cores.

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 and in a distributed fashion. 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 56 cores.

import inductiva

inductiva.working_dir = "swash_dataset"
num_simulations = 40

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

machines = manage_machines.launch_machines(
              machine_type="c2d-highcpu-112",
              image_name="SWASH",
              nmb_machines=num_simulations)

for sim_index in range(num_simulations):
    # Run the simulation
    swash_sim.run(input_dir=str(sim_index),
                  n_cores=56)

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 35x speed-up on the sequential infrastructure!

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 infrastucture. 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 two different machines selected by the user.

Workers CPU Cores Simulation Time
Local 1 ~ 40h
FEUP Infrastructure 16 4h
Inductiva API - “c2d-highcpu-32” 16 3h40min
Inductiva API - “c2d-highcpu-112” 56 1h10min

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 c2-highcpu-112.

Inductiva API accelerated by 3.43x 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

Sofia Guerreiro

Sofia Guerreiro

Cristiana Carpinteiro

Cristiana Carpinteiro

In this series of blog posts we will explore a specific case of the use of AI in the pharmaceutical industry - using Graph Neural Networks for predicting binding affinity. But for now, let’s start by understanding the problem of drug discovery and some fundamental concepts like binding affinity.

Hugo Penedones

Hugo Penedones

Luís Sarmento

Luís Sarmento

Luís Cunha

Luís Cunha

Guidelines for programming effectively and with high impact.