fluidflow 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,237 @@
1
+ Metadata-Version: 2.4
2
+ Name: fluidflow
3
+ Version: 0.1.0
4
+ Summary: FluidFlow: models and training utilities for flow matching and diffusion
5
+ Author-email: David Ramos <david.ramos.archilla@upm.es>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: einops
9
+ Requires-Dist: torch>=2.6
10
+ Requires-Dist: accelerate
11
+ Requires-Dist: torchdiffeq
12
+ Requires-Dist: timm
13
+ Requires-Dist: ema_pytorch
14
+ Requires-Dist: tqdm
15
+ Requires-Dist: matplotlib
16
+ Requires-Dist: scipy
17
+
18
+ # *FluidFlow*: a flow-matching generative model for fluid dynamics surrogates on unstructured meshes
19
+
20
+ **David Ramos¹, Lucas Lacasa², Fermín Gutiérrez¹, Eusebio Valero¹·³, Gonzalo Rubio¹·³**
21
+
22
+ ¹ ETSIAE-UPM · School of Aeronautics, Universidad Politécnica de Madrid
23
+ ² Institute for Cross-Disciplinary Physics and Complex Systems (IFISC, CSIC-UIB)
24
+ ³ Center for Computational Simulation, Universidad Politécnica de Madrid
25
+
26
+ [![Paper](https://img.shields.io/badge/Paper-coming%20soon-lightgrey?style=flat-square)](https://github.com/DavidRamosArchilla/FluidFlow)
27
+ [![arXiv](https://img.shields.io/badge/arXiv-coming%20soon-b31b1b?style=flat-square)](https://github.com/DavidRamosArchilla/FluidFlow)
28
+ [![Project Page](https://img.shields.io/badge/Project-Page-2e8fd6?style=flat-square)](https://DavidRamosArchilla.github.io/FluidFlow)
29
+
30
+ ---
31
+
32
+ <video src="https://github.com/user-attachments/assets/6730b733-7352-4ac2-8f4b-aa0821bf3394" width="100%" controls autoplay loop></video>
33
+
34
+ ## Usage
35
+
36
+ Look at `scripts/` to see more examples.
37
+
38
+ ```python
39
+ from data.generate_synthetic_data import AnalyticalFunctionDataset
40
+ from fluidFlow.dit import DiT
41
+ from fluidFlow.trainer import Trainer
42
+ from fluidFlow.flow_matching import create_flow_matching
43
+
44
+ import numpy as np
45
+ import torch
46
+ from torch.utils.data import TensorDataset
47
+
48
+ # 1. generate synthetic dataset / load you own dataset here
49
+ data_resolution = (32, 32)
50
+ generator = AnalyticalFunctionDataset(nx=data_resolution[0], ny=data_resolution[1], x_range=(0, 2*np.pi), y_range=(0, 2*np.pi))
51
+ solutions_random, parameters_random = generator.generate_dataset(
52
+ n_samples=1000,
53
+ alpha1_range=(-2.0, 2.0),
54
+ alpha2_range=(-2.0, 2.0)
55
+ )
56
+ # add channel dimension to solutions
57
+ solutions_random = solutions_random[:, None, :, :]
58
+ n_train = int(0.8 * len(solutions_random))
59
+ train_data = TensorDataset(torch.from_numpy(solutions_random[:n_train]).float(), torch.from_numpy(parameters_random[:n_train]).float())
60
+ test_data = TensorDataset(torch.from_numpy(solutions_random[n_train:]).float(), torch.from_numpy(parameters_random[n_train:]).float())
61
+
62
+ # 2. Define the DiT model and the flow-matching training procedure
63
+ model = DiT(
64
+ depth=6,
65
+ hidden_size=128,
66
+ patch_size=1,
67
+ num_heads=4,
68
+ input_size=data_resolution, # dataset grid size
69
+ cond_dim=2, # number of parameters (alpha1, alpha2)
70
+ class_dropout_prob=0.2,
71
+ in_channels=1,
72
+ learn_sigma=False,
73
+ use_swiglu=True,
74
+ use_rope=True,
75
+ # qk_norm=True, # when bf16 training
76
+ attn_type="vanilla", # window, linear, vanilla
77
+ mlp_ratio=2.5,
78
+ )
79
+
80
+ flow_matching = create_flow_matching(
81
+ neural_net=model,
82
+ input_size=data_resolution,
83
+ cond_scale=2.0,
84
+ sampling_method="euler",
85
+ num_sampling_steps=400,
86
+ )
87
+
88
+ # 3. Define trainer and training configuration
89
+ results_folder = './results'
90
+ train_steps = 100000
91
+ trainer = Trainer(
92
+ flow_matching,
93
+ dataset=train_data,
94
+ dataset_test=test_data,
95
+ train_batch_size=64,
96
+ train_lr=2e-4,
97
+ train_num_steps=train_steps, # total training steps
98
+ gradient_accumulate_every=1, # gradient accumulation steps
99
+ ema_decay=0.995, # exponential moving average decay
100
+ # amp=True, # turn on mixed precision for faster training and reduced memory usage
101
+ # mixed_precision_type='bf16',
102
+ results_folder=results_folder, # folder to save results to
103
+ save_and_sample_every=20000,
104
+ eta_min_scheduler=1e-6,
105
+ max_grad_norm=1.0,
106
+ use_cpu=True, # JUST FOR TESTING, SET TO FALSE FOR ACTUAL TRAINING
107
+ compile_model=True,
108
+ split_batches=True
109
+ )
110
+
111
+ # 4. Train the model
112
+ trainer.train()
113
+ ```
114
+ Samples and model checkpoints will be logged to `./results` periodically
115
+
116
+ ### Multi-GPU Training
117
+
118
+ The `Trainer` class is now equipped with <a href="https://huggingface.co/docs/accelerate/en/package_reference/accelerator">🤗 Accelerator</a>. You can easily do multi-gpu training in two steps using their `accelerate` CLI
119
+
120
+ At the project root directory, run
121
+
122
+ ```python
123
+ $ accelerate config
124
+ ```
125
+
126
+ Then, in the same directory
127
+
128
+ ```python
129
+ $ accelerate launch train.py
130
+ ```
131
+
132
+ ### Flash Attention 4
133
+
134
+ The DiT architecture can be trained with Flash Attention 4 for improved speed and memory efficiency. To enable it, you need to <a href="https://github.com/Dao-AILab/flash-attention">install</a> it and FluidFlow will autmatically use it if available. As an important note, Flash Attention 4 doesn't with with values of `head_dim` smaller than 128.
135
+
136
+
137
+ ## Abstract
138
+
139
+ Computational fluid dynamics (CFD) provides high-fidelity simulations of fluid flows but remains computationally expensive for many-query applications. In recent years deep supervised learning (DL) has been used to construct data-driven fluid-dynamic surrogate models. In this work we consider a different learning paradigm and embrace generative modelling as a framework for constructing scalable fluid-dynamics surrogate models.
140
+
141
+ We introduce *FluidFlow*, a generative model based on conditional flow-matching — a recent alternative to diffusion models that learns deterministic transport maps between noise and data distributions. *FluidFlow* is specifically designed to operate directly on CFD data defined on both structured and unstructured meshes alike, without the need to perform any mesh interpolation pre-processing and preserving geometric fidelity.
142
+
143
+ We assess the capabilities of *FluidFlow* using two different core neural network architectures — a U-Net and a Diffusion Transformer (DiT) — and condition their learning on physically meaningful parameters such as Mach number, angle of attack, or stagnation pressure (a proxy for Reynolds number). The methodology is validated on two benchmark problems of increasing complexity: prediction of pressure coefficients along an airfoil boundary across different operating conditions, and prediction of pressure and friction coefficients over a full three-dimensional aircraft geometry discretized on a large unstructured mesh.
144
+
145
+ In both cases, *FluidFlow* outperforms strong multilayer perceptron baselines, achieving significantly lower error metrics and improved generalisation across operating conditions. Notably, the transformer-based architecture enables scalable learning on large unstructured datasets while maintaining high predictive accuracy. These results demonstrate that flow-matching generative models provide an effective and flexible framework for surrogate modelling in fluid dynamics, with potential for realistic engineering and scientific applications.
146
+
147
+ ---
148
+
149
+ ## Method
150
+
151
+ We trained FluidFlow with 2 different CFD datasets: airfoil Cp distribution and aircraft Cp and Cf distributions. The airfoil case is simpler, since it can be considered as 1D structured data. Here, we tested two neural network architectures: U-Net and DiT. Both models perform similarly and can work with this kind of data without significant modification.
152
+
153
+ However, some problems arise when we switch to 3D. Here, the data comes from unstructured meshes and spatial information is more difficult to capture. This makes the U-Net unsuitable for this task, since it relies on convolutional layers. To address this issue, we treated the data as a sequence of points. With this approach, the DiT could be used with only minor modifications to the patching block to accommodate this sequential data. However, the DiT presents its own challenges since it relies on the attention mechanism, which scales quadratically with the number of points — too expensive given that each aircraft has more than 260,000 points.
154
+
155
+ We propose replacing self-attention with linear attention, a different approach that does not scale quadratically and incurs only a slight loss in accuracy. The diagram below illustrates how the patching and attention components of the blocks are modified.
156
+
157
+ ![FluidFlow Pipeline](docs/src/images/generalDiagram.svg)
158
+ *Figure 1. Overview of the FluidFlow DiT modifications: 1D patcher and linear attention replacement.*
159
+
160
+ ---
161
+
162
+ ## 3D Aircraft Results
163
+
164
+ FluidFlow faithfully reconstructs high-fidelity pressure and velocity fields across a wide range of Reynolds numbers and geometries directly on the native unstructured mesh, without any remeshing step.
165
+
166
+ ![FluidFlow vs CFD](docs/src/images/aircraft_cfd_comparison.png)
167
+ *Comparison between (ground truth) CFD pressure/friction coefficient fields (top panels) and the prediction generated by the DiT flow-matching model (bottom panels) for one particular operating condition with parameters π = 1×10⁵, M = 0.3 and AoA = −6.*
168
+
169
+ We evaluate FluidFlow on the [ONERA 468 CRM challenge](https://www.codabench.org/competitions/7535/), a public benchmark for aerodynamic surrogate modeling on the Common Research Model geometry. The task consists of predicting the pressure coefficient Cp and the friction coefficients Cf,x, Cf,y, Cf,z over the aircraft surface across varying flight conditions, using the official train/test split provided by the challenge. We compare against the baseline MLP model supplied by the organizers — FluidFlow (DiT) outperforms it on every metric.
170
+
171
+ | Model | R² | R²\_Cp | R²\_Cf,x | R²\_Cf,y | R²\_Cf,z |
172
+ |---|---|---|---|---|---|
173
+ | MLP | 0.956 | 0.972 | 0.944 | 0.951 | 0.957 |
174
+ | *FluidFlow* (DiT) | **0.965** | **0.974** | **0.959** | **0.960** | **0.965** |
175
+
176
+ ---
177
+
178
+ To reproduce this results, download the <a href="https://entrepot.recherche.data.gouv.fr/file.xhtml?persistentId=doi:10.57745/Z9LDY8&version=2.0">data</a> and run the `scripts/train_onera_crm.py` script.
179
+
180
+ ## Airfoil Results
181
+
182
+ FluidFlow outperforms a standard multilayer perceptron (MLP). The following animations demonstrate how FluidFlow carries out the denoising process for the airfoil Cp case — starting from Gaussian noise and travelling to the data distribution for unseen test cases.
183
+
184
+ <table style="width: 100%; text-align: center;">
185
+ <tr>
186
+ <td><video src="https://github.com/user-attachments/assets/d9a5cbf6-d8f1-4ac0-91fe-04e04170209d" width="100%" controls autoplay loop muted></video></td>
187
+ <td><video src="https://github.com/user-attachments/assets/afd95730-588a-45ec-8e29-26448bdab3fd" width="100%" controls autoplay loop muted></video></td>
188
+ <td><video src="https://github.com/user-attachments/assets/1a04454a-cfc2-4fab-9911-40b4ac678de8" width="100%" controls autoplay loop muted></video></td>
189
+ </tr>
190
+ <tr>
191
+ <td>Airfoil simulation 1</td>
192
+ <td>Airfoil simulation 2</td>
193
+ <td>Airfoil simulation 3</td>
194
+ </tr>
195
+ <tr>
196
+ <td><video src="https://github.com/user-attachments/assets/2bf0a392-c552-4938-8096-1adfae8f41f6" width="100%" controls autoplay loop muted></video></td>
197
+ <td><video src="https://github.com/user-attachments/assets/6d67513d-946a-47fa-8e15-cbcdb52eda03" width="100%" controls autoplay loop muted></video></td>
198
+ <td></td>
199
+ </tr>
200
+ <tr>
201
+ <td>Airfoil simulation 4</td>
202
+ <td>Airfoil simulation 5</td>
203
+ <td></td>
204
+ </tr>
205
+ </table>
206
+
207
+ > **Note:** If the animations take to long to load, please visit the [project page](https://DavidRamosArchilla.github.io/FluidFlow) to watch them.
208
+
209
+ In the following table we compare the metrics extracted for the test set of a well-optimized MLP (tuned via Optuna) with the two versions of FluidFlow (U-Net and DiT):
210
+
211
+ | Model | MSE | RMSE | MAE | MRE (%) | AE₉₅ | AE₉₉ | R² | Relative L² |
212
+ |---|---|---|---|---|---|---|---|---|
213
+ | Vanilla MLP | 0.00129 | 0.03598 | 0.01763 | 16.85219 | 0.05716 | 0.14176 | 0.99730 | 0.04911 |
214
+ | *FluidFlow* (U-Net) | **0.00009** | 0.00961 | **0.00240** | 4.48810 | **0.00761** | **0.03175** | **0.99981** | 0.01325 |
215
+ | *FluidFlow* (DiT) | **0.00009** | **0.00953** | 0.00249 | **3.43723** | 0.00764 | 0.03246 | **0.99981** | **0.01314** |
216
+
217
+ ---
218
+
219
+ ## BibTeX
220
+
221
+ If you find this work useful, please consider citing:
222
+
223
+ ```bibtex
224
+ @article{ramos2025fluidflow,
225
+ title = {FluidFlow: a flow-matching generative model for
226
+ fluid dynamics surrogates on unstructured meshes},
227
+ author = {Ramos, David and Lacasa, Lucas and
228
+ Guti{\'e}rrez, Ferm{\'i}n and
229
+ Valero, Eusebio and Rubio, Gonzalo},
230
+ journal = {arXiv preprint arXiv:2501.XXXXX},
231
+ year = {2025},
232
+ }
233
+ ```
234
+
235
+ ---
236
+
237
+ © 2026 FluidFlow Authors · [Project Page](https://DavidRamosArchilla.github.io/FluidFlow) · [NuMath Lab](https://numath.dmae.upm.es/)
@@ -0,0 +1,220 @@
1
+ # *FluidFlow*: a flow-matching generative model for fluid dynamics surrogates on unstructured meshes
2
+
3
+ **David Ramos¹, Lucas Lacasa², Fermín Gutiérrez¹, Eusebio Valero¹·³, Gonzalo Rubio¹·³**
4
+
5
+ ¹ ETSIAE-UPM · School of Aeronautics, Universidad Politécnica de Madrid
6
+ ² Institute for Cross-Disciplinary Physics and Complex Systems (IFISC, CSIC-UIB)
7
+ ³ Center for Computational Simulation, Universidad Politécnica de Madrid
8
+
9
+ [![Paper](https://img.shields.io/badge/Paper-coming%20soon-lightgrey?style=flat-square)](https://github.com/DavidRamosArchilla/FluidFlow)
10
+ [![arXiv](https://img.shields.io/badge/arXiv-coming%20soon-b31b1b?style=flat-square)](https://github.com/DavidRamosArchilla/FluidFlow)
11
+ [![Project Page](https://img.shields.io/badge/Project-Page-2e8fd6?style=flat-square)](https://DavidRamosArchilla.github.io/FluidFlow)
12
+
13
+ ---
14
+
15
+ <video src="https://github.com/user-attachments/assets/6730b733-7352-4ac2-8f4b-aa0821bf3394" width="100%" controls autoplay loop></video>
16
+
17
+ ## Usage
18
+
19
+ Look at `scripts/` to see more examples.
20
+
21
+ ```python
22
+ from data.generate_synthetic_data import AnalyticalFunctionDataset
23
+ from fluidFlow.dit import DiT
24
+ from fluidFlow.trainer import Trainer
25
+ from fluidFlow.flow_matching import create_flow_matching
26
+
27
+ import numpy as np
28
+ import torch
29
+ from torch.utils.data import TensorDataset
30
+
31
+ # 1. generate synthetic dataset / load you own dataset here
32
+ data_resolution = (32, 32)
33
+ generator = AnalyticalFunctionDataset(nx=data_resolution[0], ny=data_resolution[1], x_range=(0, 2*np.pi), y_range=(0, 2*np.pi))
34
+ solutions_random, parameters_random = generator.generate_dataset(
35
+ n_samples=1000,
36
+ alpha1_range=(-2.0, 2.0),
37
+ alpha2_range=(-2.0, 2.0)
38
+ )
39
+ # add channel dimension to solutions
40
+ solutions_random = solutions_random[:, None, :, :]
41
+ n_train = int(0.8 * len(solutions_random))
42
+ train_data = TensorDataset(torch.from_numpy(solutions_random[:n_train]).float(), torch.from_numpy(parameters_random[:n_train]).float())
43
+ test_data = TensorDataset(torch.from_numpy(solutions_random[n_train:]).float(), torch.from_numpy(parameters_random[n_train:]).float())
44
+
45
+ # 2. Define the DiT model and the flow-matching training procedure
46
+ model = DiT(
47
+ depth=6,
48
+ hidden_size=128,
49
+ patch_size=1,
50
+ num_heads=4,
51
+ input_size=data_resolution, # dataset grid size
52
+ cond_dim=2, # number of parameters (alpha1, alpha2)
53
+ class_dropout_prob=0.2,
54
+ in_channels=1,
55
+ learn_sigma=False,
56
+ use_swiglu=True,
57
+ use_rope=True,
58
+ # qk_norm=True, # when bf16 training
59
+ attn_type="vanilla", # window, linear, vanilla
60
+ mlp_ratio=2.5,
61
+ )
62
+
63
+ flow_matching = create_flow_matching(
64
+ neural_net=model,
65
+ input_size=data_resolution,
66
+ cond_scale=2.0,
67
+ sampling_method="euler",
68
+ num_sampling_steps=400,
69
+ )
70
+
71
+ # 3. Define trainer and training configuration
72
+ results_folder = './results'
73
+ train_steps = 100000
74
+ trainer = Trainer(
75
+ flow_matching,
76
+ dataset=train_data,
77
+ dataset_test=test_data,
78
+ train_batch_size=64,
79
+ train_lr=2e-4,
80
+ train_num_steps=train_steps, # total training steps
81
+ gradient_accumulate_every=1, # gradient accumulation steps
82
+ ema_decay=0.995, # exponential moving average decay
83
+ # amp=True, # turn on mixed precision for faster training and reduced memory usage
84
+ # mixed_precision_type='bf16',
85
+ results_folder=results_folder, # folder to save results to
86
+ save_and_sample_every=20000,
87
+ eta_min_scheduler=1e-6,
88
+ max_grad_norm=1.0,
89
+ use_cpu=True, # JUST FOR TESTING, SET TO FALSE FOR ACTUAL TRAINING
90
+ compile_model=True,
91
+ split_batches=True
92
+ )
93
+
94
+ # 4. Train the model
95
+ trainer.train()
96
+ ```
97
+ Samples and model checkpoints will be logged to `./results` periodically
98
+
99
+ ### Multi-GPU Training
100
+
101
+ The `Trainer` class is now equipped with <a href="https://huggingface.co/docs/accelerate/en/package_reference/accelerator">🤗 Accelerator</a>. You can easily do multi-gpu training in two steps using their `accelerate` CLI
102
+
103
+ At the project root directory, run
104
+
105
+ ```python
106
+ $ accelerate config
107
+ ```
108
+
109
+ Then, in the same directory
110
+
111
+ ```python
112
+ $ accelerate launch train.py
113
+ ```
114
+
115
+ ### Flash Attention 4
116
+
117
+ The DiT architecture can be trained with Flash Attention 4 for improved speed and memory efficiency. To enable it, you need to <a href="https://github.com/Dao-AILab/flash-attention">install</a> it and FluidFlow will autmatically use it if available. As an important note, Flash Attention 4 doesn't with with values of `head_dim` smaller than 128.
118
+
119
+
120
+ ## Abstract
121
+
122
+ Computational fluid dynamics (CFD) provides high-fidelity simulations of fluid flows but remains computationally expensive for many-query applications. In recent years deep supervised learning (DL) has been used to construct data-driven fluid-dynamic surrogate models. In this work we consider a different learning paradigm and embrace generative modelling as a framework for constructing scalable fluid-dynamics surrogate models.
123
+
124
+ We introduce *FluidFlow*, a generative model based on conditional flow-matching — a recent alternative to diffusion models that learns deterministic transport maps between noise and data distributions. *FluidFlow* is specifically designed to operate directly on CFD data defined on both structured and unstructured meshes alike, without the need to perform any mesh interpolation pre-processing and preserving geometric fidelity.
125
+
126
+ We assess the capabilities of *FluidFlow* using two different core neural network architectures — a U-Net and a Diffusion Transformer (DiT) — and condition their learning on physically meaningful parameters such as Mach number, angle of attack, or stagnation pressure (a proxy for Reynolds number). The methodology is validated on two benchmark problems of increasing complexity: prediction of pressure coefficients along an airfoil boundary across different operating conditions, and prediction of pressure and friction coefficients over a full three-dimensional aircraft geometry discretized on a large unstructured mesh.
127
+
128
+ In both cases, *FluidFlow* outperforms strong multilayer perceptron baselines, achieving significantly lower error metrics and improved generalisation across operating conditions. Notably, the transformer-based architecture enables scalable learning on large unstructured datasets while maintaining high predictive accuracy. These results demonstrate that flow-matching generative models provide an effective and flexible framework for surrogate modelling in fluid dynamics, with potential for realistic engineering and scientific applications.
129
+
130
+ ---
131
+
132
+ ## Method
133
+
134
+ We trained FluidFlow with 2 different CFD datasets: airfoil Cp distribution and aircraft Cp and Cf distributions. The airfoil case is simpler, since it can be considered as 1D structured data. Here, we tested two neural network architectures: U-Net and DiT. Both models perform similarly and can work with this kind of data without significant modification.
135
+
136
+ However, some problems arise when we switch to 3D. Here, the data comes from unstructured meshes and spatial information is more difficult to capture. This makes the U-Net unsuitable for this task, since it relies on convolutional layers. To address this issue, we treated the data as a sequence of points. With this approach, the DiT could be used with only minor modifications to the patching block to accommodate this sequential data. However, the DiT presents its own challenges since it relies on the attention mechanism, which scales quadratically with the number of points — too expensive given that each aircraft has more than 260,000 points.
137
+
138
+ We propose replacing self-attention with linear attention, a different approach that does not scale quadratically and incurs only a slight loss in accuracy. The diagram below illustrates how the patching and attention components of the blocks are modified.
139
+
140
+ ![FluidFlow Pipeline](docs/src/images/generalDiagram.svg)
141
+ *Figure 1. Overview of the FluidFlow DiT modifications: 1D patcher and linear attention replacement.*
142
+
143
+ ---
144
+
145
+ ## 3D Aircraft Results
146
+
147
+ FluidFlow faithfully reconstructs high-fidelity pressure and velocity fields across a wide range of Reynolds numbers and geometries directly on the native unstructured mesh, without any remeshing step.
148
+
149
+ ![FluidFlow vs CFD](docs/src/images/aircraft_cfd_comparison.png)
150
+ *Comparison between (ground truth) CFD pressure/friction coefficient fields (top panels) and the prediction generated by the DiT flow-matching model (bottom panels) for one particular operating condition with parameters π = 1×10⁵, M = 0.3 and AoA = −6.*
151
+
152
+ We evaluate FluidFlow on the [ONERA 468 CRM challenge](https://www.codabench.org/competitions/7535/), a public benchmark for aerodynamic surrogate modeling on the Common Research Model geometry. The task consists of predicting the pressure coefficient Cp and the friction coefficients Cf,x, Cf,y, Cf,z over the aircraft surface across varying flight conditions, using the official train/test split provided by the challenge. We compare against the baseline MLP model supplied by the organizers — FluidFlow (DiT) outperforms it on every metric.
153
+
154
+ | Model | R² | R²\_Cp | R²\_Cf,x | R²\_Cf,y | R²\_Cf,z |
155
+ |---|---|---|---|---|---|
156
+ | MLP | 0.956 | 0.972 | 0.944 | 0.951 | 0.957 |
157
+ | *FluidFlow* (DiT) | **0.965** | **0.974** | **0.959** | **0.960** | **0.965** |
158
+
159
+ ---
160
+
161
+ To reproduce this results, download the <a href="https://entrepot.recherche.data.gouv.fr/file.xhtml?persistentId=doi:10.57745/Z9LDY8&version=2.0">data</a> and run the `scripts/train_onera_crm.py` script.
162
+
163
+ ## Airfoil Results
164
+
165
+ FluidFlow outperforms a standard multilayer perceptron (MLP). The following animations demonstrate how FluidFlow carries out the denoising process for the airfoil Cp case — starting from Gaussian noise and travelling to the data distribution for unseen test cases.
166
+
167
+ <table style="width: 100%; text-align: center;">
168
+ <tr>
169
+ <td><video src="https://github.com/user-attachments/assets/d9a5cbf6-d8f1-4ac0-91fe-04e04170209d" width="100%" controls autoplay loop muted></video></td>
170
+ <td><video src="https://github.com/user-attachments/assets/afd95730-588a-45ec-8e29-26448bdab3fd" width="100%" controls autoplay loop muted></video></td>
171
+ <td><video src="https://github.com/user-attachments/assets/1a04454a-cfc2-4fab-9911-40b4ac678de8" width="100%" controls autoplay loop muted></video></td>
172
+ </tr>
173
+ <tr>
174
+ <td>Airfoil simulation 1</td>
175
+ <td>Airfoil simulation 2</td>
176
+ <td>Airfoil simulation 3</td>
177
+ </tr>
178
+ <tr>
179
+ <td><video src="https://github.com/user-attachments/assets/2bf0a392-c552-4938-8096-1adfae8f41f6" width="100%" controls autoplay loop muted></video></td>
180
+ <td><video src="https://github.com/user-attachments/assets/6d67513d-946a-47fa-8e15-cbcdb52eda03" width="100%" controls autoplay loop muted></video></td>
181
+ <td></td>
182
+ </tr>
183
+ <tr>
184
+ <td>Airfoil simulation 4</td>
185
+ <td>Airfoil simulation 5</td>
186
+ <td></td>
187
+ </tr>
188
+ </table>
189
+
190
+ > **Note:** If the animations take to long to load, please visit the [project page](https://DavidRamosArchilla.github.io/FluidFlow) to watch them.
191
+
192
+ In the following table we compare the metrics extracted for the test set of a well-optimized MLP (tuned via Optuna) with the two versions of FluidFlow (U-Net and DiT):
193
+
194
+ | Model | MSE | RMSE | MAE | MRE (%) | AE₉₅ | AE₉₉ | R² | Relative L² |
195
+ |---|---|---|---|---|---|---|---|---|
196
+ | Vanilla MLP | 0.00129 | 0.03598 | 0.01763 | 16.85219 | 0.05716 | 0.14176 | 0.99730 | 0.04911 |
197
+ | *FluidFlow* (U-Net) | **0.00009** | 0.00961 | **0.00240** | 4.48810 | **0.00761** | **0.03175** | **0.99981** | 0.01325 |
198
+ | *FluidFlow* (DiT) | **0.00009** | **0.00953** | 0.00249 | **3.43723** | 0.00764 | 0.03246 | **0.99981** | **0.01314** |
199
+
200
+ ---
201
+
202
+ ## BibTeX
203
+
204
+ If you find this work useful, please consider citing:
205
+
206
+ ```bibtex
207
+ @article{ramos2025fluidflow,
208
+ title = {FluidFlow: a flow-matching generative model for
209
+ fluid dynamics surrogates on unstructured meshes},
210
+ author = {Ramos, David and Lacasa, Lucas and
211
+ Guti{\'e}rrez, Ferm{\'i}n and
212
+ Valero, Eusebio and Rubio, Gonzalo},
213
+ journal = {arXiv preprint arXiv:2501.XXXXX},
214
+ year = {2025},
215
+ }
216
+ ```
217
+
218
+ ---
219
+
220
+ © 2026 FluidFlow Authors · [Project Page](https://DavidRamosArchilla.github.io/FluidFlow) · [NuMath Lab](https://numath.dmae.upm.es/)
@@ -0,0 +1,16 @@
1
+ """Top-level package for FluidFlow.
2
+
3
+ Provides a minimal package initializer so the project can be installed.
4
+ """
5
+
6
+ __all__ = [
7
+ "attention",
8
+ "basic_modules",
9
+ "dit",
10
+ "moe",
11
+ "trainer",
12
+ "unet",
13
+ "flow_matching",
14
+ ]
15
+
16
+ __version__ = "0.1.0"