Neural networks for mesh generation and processing in structural and fluid mechanics

opening gif

Ugo Pelissier
ugo.pelissier@etu.minesparis.psl.eu

  • Prof. Youssef Mesri - Mines Paris
  • Augustin Parret-Fréaud, Ph.D - Safran Tech
  • Felipe Bordeu, Ph.D - Safran Tech

Table of contents

1. Mesh Generation in Computational Science

2. Deep Neural Networks (DNNs) for mesh-based simulations
3. Graph Neural Networks (GNNs) for mesh-based simulations
4. MESHNET: GNN for mesh generation
5. GRAPHNET: GNN for mesh adaptation
6. ADAPTNET: Framework for automated mesh generation and adaptation

Meshes in simulation

Mesh-based finite element (FE) simulations are the 1st for many problems across science & engineering.

fem1 fem2 fem3
wiki logo

"The finite element method (FEM) is the most widely used method for solving problems of engineering and mathematical models".

Meshes in simulation

High quality mesh generation framework

framework

Meshes in simulation

High quality mesh generation framework

framework_mesh_generation

Parameters for Mesh Generation

Mesh generation depends on several critical parameters:

  • Local Metrics: Metrics at specific points in the mesh.
  • Element Sizes: Maximum and minimum sizes of elements.
  • Hausdorff Coefficient: A measure of domain complexity.
  • Metric Gradation: Acceptable gradation of the metric.
  • Others: Additional parameters influencing the mesh.

These parameters play a vital role in determining mesh quality and efficiency.

Parameters for Mesh Generation

  • Local Metrics: Metrics at specific points in the mesh.
geo

Parameters for Mesh Generation

  • Local Metrics: Metrics at specific points in the mesh.

						//+
						Mesh.MshFileVersion = 2.2;
						//+
						SetFactory("OpenCASCADE");
						//+
						Box(1) = {0.045462, -3.922459, 0.000000, 35.722251, 9.127825, 1.000000};
						//+
						MeshSize {1} = 2.518574;
						//+
						MeshSize {2} = 2.518574;
						//+
						MeshSize {3} = 2.409870;
						//+
						MeshSize {4} = 2.409870;
						//+
						MeshSize {5} = 0.597988;
						//+
						MeshSize {6} = 0.597988;
						//+
						MeshSize {7} = 0.700752;
						//+
						MeshSize {8} = 0.700752;
						//+
						Cylinder(2) = {27.432369, -0.761381, 0.000000, 0.000000, 0.000000, 1.000000, 1.138991, 2*Pi};
						//+
						MeshSize {9} = 0.113899;
						//+
						MeshSize {10} = 0.113899;
						//+
						Cylinder(3) = {17.813682, 1.160731, 0.000000, 0.000000, 0.000000, 1.000000, 0.789672, 2*Pi};
						//+
						MeshSize {11} = 0.078967;
						//+
						MeshSize {12} = 0.078967;
						//+
						BooleanDifference{ Volume{1}; Delete; }{ Volume{2}; Volume{3}; Delete; }
						

Parameters for Mesh Generation

  • Local Metrics: Metrics at specific points in the mesh.
mesh

MESHNET

A framework for learning local metrics parameters using graph neural networks.

framework_meshnet

MESHNET

A framework for learning local metrics parameters using graph neural networks.


						Point(1) = {0.045462, -3.922459, 1};
						Point(2) = {0.045462, -3.922459, 0};
						Point(3) = {0.045462, 5.205366, 1};
						Point(4) = {0.045462, 5.205366, 0};
						Point(5) = {35.767713, -3.922459, 0};
						Point(6) = {35.767713, -3.922459, 1};
						Point(7) = {35.767713, 5.205366, 1};
						Point(8) = {28.57136, -0.7613810000000002, 1};
						Point(9) = {18.603354, 1.160731, 1};
						Point(10) = {35.767713, 5.205366, 0};
						Point(11) = {28.57136, -0.7613810000000002, 0};
						Point(12) = {18.603354, 1.160731, 0};
						Line(1) = {2, 1};
						Line(2) = {1, 3};
						Line(3) = {4, 3};
						Line(4) = {2, 4};
						Line(5) = {2, 5};
						Line(6) = {5, 6};
						Line(7) = {1, 6};
						Line(8) = {3, 7};
						Line(9) = {6, 7};
						Spline(10) = {8, ...
						

MESHNET

A framework for learning local metrics parameters using graph neural networks.


						cl__1 = 2.518574;
						cl__2 = 2.40987;
						cl__3 = 0.597988;
						cl__4 = 0.700752;
						cl__5 = 0.113899;
						cl__6 = 0.078967;
						Point(1) = {0.045462, -3.922459, 1, cl__1};
						Point(2) = {0.045462, -3.922459, 0, cl__1};
						Point(3) = {0.045462, 5.205366, 1, cl__2};
						Point(4) = {0.045462, 5.205366, 0, cl__2};
						Point(5) = {35.767713, -3.922459, 0, cl__3};
						Point(6) = {35.767713, -3.922459, 1, cl__3};
						Point(7) = {35.767713, 5.205366, 1, cl__4};
						Point(8) = {28.57136, -0.7613810000000002, 1, cl__5};
						Point(9) = {18.603354, 1.160731, 1, cl__6};
						Point(10) = {35.767713, 5.205366, 0, cl__4};
						Point(11) = {28.57136, -0.7613810000000002, 0, cl__5};
						Point(12) = {18.603354, 1.160731, 0, cl__6};
						Line(1) = {2, 1};
						Line(2) = {1, 3};
						Line(3) = {4, 3};
						Line(4) = {2, 4};
						Line(5) = {2, 5};
						Line(6) = {5, 6};
						Line(7) = {1, 6};
						Line(8) = {3, 7};
						Line(9) = {6, 7};
						Spline(10) = {8, ...
						

Adaptive Mesh Refinement

Adapting the precision of the numerical computation based on the requirements of a computation problem in specific areas.

framework_mesh_adaptation

Adaptive Mesh Refinement

Adapting the precision of the numerical computation based on the requirements of a computation problem in specific areas.

Hessian-based metric

\[ f: \mathbb{R}^n \rightarrow \mathbb{R}; (x_1, \dots, x_n) \mapsto f(x_1, \dots, x_n) \] \[ H(f)=\left[ \begin{array}{ccc} \frac{\partial^2 f}{\partial x_1^2} & \cdots & \frac{\partial^2 f}{\partial x_1 \partial x_n} \\ \vdots & \ddots & \vdots \\ \frac{\partial^2 f}{\partial x_n \partial x_1} & \cdots & \frac{\partial^2 f}{\partial x_n^2} \end{array} \right] \]

Adaptive Mesh Refinement

Hessian-based metric

u adaptive mesh refinement h adaptive mesh refinement

GRAPHNET

A framework for learning mesh-based simulations using graph neural networks (GNNs)

framework_graphnet

GRAPHNET

A framework for learning mesh-based simulations using graph neural networks (GNNs)

u adaptive mesh refinement h adaptive mesh refinement

ADAPTNET

A framework for automated mesh generation and adaptation

framework_adaptnet

Table of contents

1. Mesh Generation in Computational Science

2. Deep Neural Networks (DNNs) for mesh-based simulations

3. Graph Neural Networks (GNNs) for mesh-based simulations
4. MESHNET: GNN for mesh generation
5. GRAPHNET: GNN for mesh adaptation
6. ADAPTNET: Framework for automated mesh generation and adaptation

Deep Neural Networks for mesh-based simulations

Most work on predicting high-dimensional physical systems focuses on Cartesian grids, owing to the popularity and hardware support for CNN architectures.

cnn

Deep Neural Networks for mesh-based simulations

Most work on predicting high-dimensional physical systems focuses on Cartesian grids, owing to the popularity and hardware support for CNN architectures.

mesh_grid

Zoomed-in view of the discrete structured C-mesh representation of an airfoil (S814) (in black) on a Cartesian grid (in red). The airfoil boundary points are in blue.

mesh_grid

A signed distance function contour plotted for the S814 airfoil in a 150x150 Cartesian grid. The magnitude of the SDF values on the Cartesian grid equals the shortest distance to the airfoil. The airfoil boundary points are in white. [1]

Deep Neural Networks for mesh-based simulations

Most work on predicting high-dimensional physical systems focuses on Cartesian grids, owing to the popularity and hardware support for CNN architectures.

Sdf

Signed-fixed distance

Pred

Prediction

Ground truth

Ground truth

Deep Neural Networks for mesh-based simulations

Most work on predicting high-dimensional physical systems focuses on Cartesian grids, owing to the popularity and hardware support for CNN architectures.

Sdf

Signed-fixed distance

Pred

Prediction

Ground truth

Ground truth

This limitation significantly undermines the applicability of these surrogates to field-scale models with more complex geometries.

Table of contents

1. Mesh Generation in Computational Science
2. Deep Neural Networks (DNNs) for mesh-based simulations

3. Graph Neural Networks (GNNs) for mesh-based simulations

4. MESHNET: GNN for mesh generation
5. GRAPHNET: GNN for mesh adaptation
6. ADAPTNET: Framework for automated mesh generation and adaptation

Graph Neural Networks for mesh-based simulations

The key feature of GNNs is to represent unstructured simulation data as graphs with nodes and edges to achieve one of three tasks:

  • Node classification: predicting unknown quantities for the nodes of the graph
  • Link classification: predicting the existence of missing links between nodes
  • Graph classification: predicting unknown for the entire graph
tasks

Message passing Graph Neural Networks

Whichever the task, the key idea in GNNs is to learn how to propagate information into nodes from their local neighbourhoods across interconnecting edges for all nodes in the graph.

Example graph

An example graph used to illustrate node classification

Message passing Graph Neural Netwroks

Example graph

An example graph used to illustrate node classification

  • Message computation: for each node, we compute a message that it passes to neighboring nodes in the network.
\[ m_u^{(l)} = \textbf{MSG}^{(l)}(h_u^{(l-1)}) \]

Embedding h of node u at the previous level of the GNN are transformed by the message function MSG into message m.

Message passing Graph Neural Netwroks

Example graph

An example graph used to illustrate node classification

  • Message computation
  • Aggregation: for each node, a function aggregates all of the messages received from neighbours.
\[ h_v^{(l)} = \textbf{AGG}_{u \in N(v)}^{(l)}(m_u^{(l)}) \]

Function used to aggregate the messages from neighboring nodes v for node u.

Message passing Graph Neural Netwroks

Example graph

An example graph used to illustrate node classification

  • Message computation

  • Aggregation
  • Updating: given the aggregated messages from neighbouring nodes, the embedding of each node is updated using a processor function.
\[ h_v^{(l)} = \textbf{Processor}^{(l)}(h_v^{(l)}) \]

Embedding of node v is updated using a processor function given the aggregated information from neighbouring nodes.

Message passing Graph Neural Netwroks

Each node has its own computational graph defined by its local neighborhood.

Example graph

An example graph used to illustrate node classification

Example layers

The general computational graph for the update of the blue node

MeshGraphNets (MGN)

Learning mesh-based simulation with Graph Networks [2]

MeshGraphNets (MGN)

Dataset

Simulations of incompressible Navier-Stokes flow trajectories over a circular cylinder over time.

ns
  • 1200 trajectories

  • 600 time steps

  • Different simulation domains
traj

MeshGraphNets (MGN)

Data associated with each simulation

  • Node type: a 5-dimensional one-hot vector corresponding to node location in fluid, wall, inflow, or outflow regions.
  • Mesh topology: a each node contains the 2D position vector of its location in the two dimensional space that is being simulated.
  • Node attributes: 2D velocity vector of the fluid, and the scalar pressure.
attributes

MeshGraphNets (MGN)

Graph signature in PyTorch Geometric (PyG)

graph_attributes

MeshGraphNets (MGN)

Graph signature in PyTorch Geometric (PyG)


						'''
						For each node i in the graph with neighbor node j:
						x - (node features) ground truth 2D velocities &
						5D node type one-hot vector for all nodes [num_nodes x 7]
						edge_index - connectivity of the graph. [2 x num_edges]
						edge_attr - (edge features) 2D position vector between connecting nodes
						& 2-norm of the position vector. [num_edges x 3]
						y - (node outputs) ground truth 2D velocities at next time step.
						[num_nodes x 2]
						p - pressure scalar, used for validation [num_nodes x 1]
						cells and mesh_pos: these attributes contain no new information.
						'''
						Data(x=x, edge_index=edge_index, edge_attr=edge_attr, y=y, p=p,
															cells=cells, mesh_pos=mesh_pos)
						

MeshGraphNets (MGN)

Netwrok architecture: Encoding - Processing - Decoding

MeshGraphNets (MGN)

Netwrok architecture: Encoding - Processing - Decoding

1. Encoding

node_encoding

MeshGraphNets (MGN)

Netwrok architecture: Encoding - Processing - Decoding

2. Processing: Message Passing, Aggregation, Updating

processing

MeshGraphNets (MGN)

Netwrok architecture: Encoding - Processing - Decoding

3. Decode

processing

MeshGraphNets (MGN)

Learning mesh-based simulation with Graph Networks

Table of contents

1. Mesh Generation in Computational Science
2. Deep Neural Networks (DNNs) for mesh-based simulations
3. Graph Neural Networks (GNNs) for mesh-based simulations

4. MESHNET: GNN for mesh generation

5. GRAPHNET: GNN for mesh adaptation
6. ADAPTNET: Framework for automated mesh generation and adaptation

MESHNET: learning local metrics parameters

Dataset

MESHNET: learning local metrics parameters

Dataset associated with each simulation

Dataset

MESHNET: learning local metrics parameters

Graph signature in PyTorch Geometric (PyG)

meshnet_graph_attributes

MESHNET: learning local metrics parameters

Different datasets

Dataset

MESHNET: learning local metrics parameters

Networks

Breakdown of the number of parameters in each component of MESHNET
Name Type Params
0 node_encoder Sequential 50.9K
1 edge_encoder Sequential 50.4K
2 processor Sequential 1.7M
3 decoder Sequential 49.9K

MESHNET: learning local metrics parameters

meshnet_loss

MESHNET: learning local metrics parameters

meshnet_loss
Dataset Duration
(1) 3h23min
(2) 3h25min
(3) 3h27min

MESHNET: learning local metrics parameters

meshnet_loss
meshnet_loss meshnet_loss

MESHNET: learning local metrics parameters

dataset_2_comp

MESHNET: learning local metrics parameters

dataset_2_comp
Type Nodes Cells
ground truth 5387 10778
prediction 5191 10386

MESHNET: learning local metrics parameters

dataset_3_comp

MESHNET: learning local metrics parameters

dataset_2_comp
Type Nodes Cells
ground truth 3853 7710
prediction 3916 7836

Table of contents

1. Mesh Generation in Computational Science
2. Deep Neural Networks (DNNs) for mesh-based simulations
3. Graph Neural Networks (GNNs) for mesh-based simulations
4. MESHNET: GNN for mesh generation

5. GRAPHNET: GNN for mesh adaptation

6. ADAPTNET: Framework for automated mesh generation and adaptation

GRAPHNET: direct prediction of steady-state flow field

framework_graphnet

GRAPHNET: direct prediction of steady-state flow field

Stokes equation:

\[ \begin{cases} \mu \Delta \textbf{u} - \nabla p = \textbf{f} \\ \nabla \cdot \textbf{u} = 0 \\ \end{cases} \] stokes

GRAPHNET: direct prediction of steady-state flow field

Dataset associated with each simulation

stokes_u stokes_u stokes_u

GRAPHNET: direct prediction of steady-state flow field

Graph signature in PyTorch Geometric (PyG)

graphnet_graph_attributes

GRAPHNET: direct prediction of steady-state flow field

Datasets

Dataset

GRAPHNET: direct prediction of steady-state flow field

Networks

Breakdown of the number of parameters in each component of GRAPHNET
Name Type Params
0 node_encoder Sequential 50.9K
1 edge_encoder Sequential 50.4K
2 processor Sequential 1.7M
3 decoder Sequential 49.9K

GRAPHNET: direct prediction of steady-state flow field

graphnet_loss

GRAPHNET: direct prediction of steady-state flow field

graphnet_loss
Dataset Duration
(1) 19h04min
(2) 27h56min
(3) 25h36min

GRAPHNET: direct prediction of steady-state flow field

u_comp_3

GRAPHNET: direct prediction of steady-state flow field

mesh_comp_3

GRAPHNET: direct prediction of steady-state flow field

dataset_2_comp
Type Nodes Cells
initial 4118 21143
ground truth 2845 11452
prediction 2838 11405

Table of contents

1. Mesh Generation in Computational Science
2. Deep Neural Networks (DNNs) for mesh-based simulations
3. Graph Neural Networks (GNNs) for mesh-based simulations
4. MESHNET: GNN for mesh generation
5. GRAPHNET: GNN for mesh adaptation

6. ADAPTNET: Framework for automated mesh generation and adaptation

ADAPTNET: automated mesh generation & adaptation pipeline

opening gif

ADAPTNET: automated mesh generation & adaptation pipeline

opening gif
Step Standard ADAPTNET
Mesh generation Eng. time 0.97s
Solution field computation 4.71s 0.38s
Overall 4.71s ++ 1.35s

THE END

Questions?

[1] Bhatnagar et al. Prediction of aerodynamic flow fields using convolutional neural networks. Computational Mechanics, 64(2):525-545, 6 2019.
[2] Grätsch and Bathe. Learning mesh-based simulations with graph networks. International Conference on Learning Representations, 2021.