Skip to content

Commit

Permalink
update benchmarks (avro added)
Browse files Browse the repository at this point in the history
  • Loading branch information
xgarnaud committed Mar 14, 2024
1 parent df29013 commit 743c3d5
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 98 deletions.
8 changes: 6 additions & 2 deletions benchmarks/cube_cylinder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@

This is the [polar-1](https://github.com/UGAWG/adapt-benchmarks/tree/master/cube-cylinder) benchmark from the Unstructured Grid Adaptation Working Group.

NB: the metric is not limited at each remeshing step

![mesh](mesh.png)

## Initial mesh

Gmsh `.geo` files are provided to generate the initial mesh (identical to the UGAWG benchmark) and a stl-like geometry. The input mesh can be generated as
```
wget https://raw.githubusercontent.com/UGAWG/adapt-benchmarks/master/cube-cylinder/cube-cylinder.step
wget https://raw.githubusercontent.com/UGAWG/adapt-benchmarks/master/cube-cylinder/cube-cylinder.egads
wget https://raw.githubusercontent.com/UGAWG/adapt-benchmarks/master/cube-cylinder/cube-cylinder.meshb
gmsh cube-cylinder.geo -3 -o cube-cylinder.mesh
gmsh cube-cylinder-boundary.geo -2 -o cube-cylinder-boundary.mesh
```

## Results after 4 iterations
## Results after 5 iterations

NB: the egads file is not yet used for refine and Omega_h
(NB: metric limiting applied to avro only)

![quality](quality.png)
![perfo](perfo.png)
Expand Down
Binary file modified benchmarks/cube_cylinder/perfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmarks/cube_cylinder/quality.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 16 additions & 28 deletions benchmarks/cube_cylinder/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from pytucanos.remesh import (
remesh,
remesh_mmg,
remesh_omega_h,
# remesh_omega_h,
remesh_refine,
remesh_avro,
)
from pytucanos.quality import qualities_and_lengths

Expand Down Expand Up @@ -54,22 +55,18 @@ def get_metric(msh):
return m


def run_loop(remesh, name, with_geom):
def run_loop(remesh, name):

pth = os.path.dirname(__file__)
msh = Mesh33.from_meshb(os.path.join(pth, "cube-cylinder.mesh"))
if with_geom:
bdy = Mesh32.from_meshb(os.path.join(pth, "cube-cylinder-boundary.mesh"))
if name == "tucanos":
msh = Mesh33.from_meshb(os.path.join(pth, "cube-cylinder.mesh"))
else:
print(f"WARNING: geometry not used for {name}")
msh = Mesh33.from_meshb(os.path.join(pth, "cube-cylinder.meshb"))

t0 = time()
for _ in range(5):
h = get_metric(msh)
if with_geom:
msh = remesh(msh, h, bdy)
else:
msh = remesh(msh, h)
msh = remesh(msh, h)
t1 = time()

return msh, t1 - t0
Expand All @@ -84,16 +81,11 @@ def run(cases):
fig_q, axs_q = plt.subplots(2, 1, tight_layout=True)
fig_p, axs_p = plt.subplots(2, 1, tight_layout=True, sharex=True)

names = ["tucanos", "MMG", "Omega_h", "refine"]
fns = [remesh, remesh_mmg, remesh_omega_h, remesh_refine]

perf = []
for name, (with_geom, fn) in cases.items():
if name == "Omega_h":
continue
for name, fn in cases.items():
print("Running %s" % name)
try:
msh, t = run_loop(fn, name, with_geom)
msh, t = run_loop(fn, name)
perf.append((name, t, msh.n_elems()))
print("%s: %d elems, %f s" % (name, msh.n_elems(), t))

Expand Down Expand Up @@ -178,18 +170,14 @@ def run(cases):
),
}

pth = os.path.dirname(__file__)
bdy = Mesh32.from_meshb(os.path.join(pth, "cube-cylinder-boundary.mesh"))

cases_benchmark = {
"tucanos": (
True,
lambda mesh, h, bdy: remesh(
mesh,
h,
bdy,
step=4.0,
),
),
"MMG": (False, remesh_mmg),
"refine": (False, remesh_refine),
"tucanos": lambda mesh, h: remesh(mesh, h, bdy),
"MMG": remesh_mmg,
"refine": lambda mesh, h: remesh_refine(mesh, h, "cube-cylinder.egads"),
"avro": lambda mesh, h: remesh_avro(mesh, h, "cube-cylinder.egads", limit=True),
}

run(cases_benchmark)
Expand Down
Binary file modified benchmarks/cube_iso/perfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmarks/cube_iso/quality.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions benchmarks/cube_iso/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
remesh_mmg,
remesh_omega_h,
remesh_refine,
remesh_avro,
)
from pytucanos.quality import qualities_and_lengths

Expand Down Expand Up @@ -124,6 +125,8 @@ def run(cases):
),
"MMG": remesh_mmg,
"refine": remesh_refine,
"avro": lambda mesh, h: remesh_avro(mesh, h, "box"),
"Omega_h": remesh_omega_h,
}

run(cases_benchmark)
Expand Down
9 changes: 1 addition & 8 deletions benchmarks/cube_linear/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@

## Configuration

This is the [linear](https://github.com/UGAWG/adapt-benchmarks/tree/master/cube) benchmark from the Unstructured Grid Adaptation Working Group.
This is similar to the [linear](https://github.com/UGAWG/adapt-benchmarks/tree/master/cube) benchmark from the Unstructured Grid Adaptation Working Group.

![mesh](mesh.png)

## Start mesh

The initial mesh only contains 5 tetrahedra. 5 iterations are performed to reach the target metric.

As the quality of the initial mesh is quite high, one should allow a decrease of the mesh quality during split and collapse loops, e.g. by setting
```python
remesher.remesh(
split_min_q_rel=0.5,
collapse_min_q_rel=0.5,
)
```

## Results after 5 iterations

Expand Down
Binary file modified benchmarks/cube_linear/perfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmarks/cube_linear/quality.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion benchmarks/cube_linear/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from pytucanos.remesh import (
remesh,
remesh_mmg,
remesh_omega_h,
# remesh_omega_h,
remesh_refine,
remesh_avro,
)
from pytucanos.quality import qualities_and_lengths

Expand Down Expand Up @@ -132,6 +133,8 @@ def run(cases):
),
"MMG": remesh_mmg,
"refine": remesh_refine,
"avro": lambda mesh, h: remesh_avro(mesh, h, "box"),
# "Omega_h": remesh_omega_h,
}

run(cases_benchmark)
Expand Down
9 changes: 9 additions & 0 deletions benchmarks/run_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -ex

for test in square_iso square_linear cube_iso cube_linear cube_cylinder
do
cd $test
python run_test.py
cd ../
done
8 changes: 0 additions & 8 deletions benchmarks/square_iso/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ with $h_{min} = 0.01$ and $h_{max} = 0.3$

The initial mesh only contains two triangles, so 5 iterations are required to reach the target cell sizes.

As the quality of the initial mesh is quite high, one should allow a decrease of the mesh quality during split and collapse loops, e.g. by setting
```python
remesher.remesh(
split_min_q_rel=0.5,
collapse_min_q_rel=0.5,
)
```

## Results after 5 iterations

![quality](quality.png)
Expand Down
Binary file modified benchmarks/square_iso/perfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmarks/square_iso/quality.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions benchmarks/square_linear/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ The target anisotropic cell size are

The initial mesh only contains two triangles. 4 iterations are performed to avoid differences with the metric interpolation.

As the quality of the initial mesh is quite high, one should allow a decrease of the mesh quality during split and collapse loops, e.g. by setting
```python
remesher.remesh(
split_min_q_rel=0.5,
collapse_min_q_rel=0.5,
)
```

## Results after 5 iterations

Expand Down
Binary file modified benchmarks/square_linear/perfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmarks/square_linear/quality.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 743c3d5

Please sign in to comment.