Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions libexamples/mmg3d/progress_callback_example0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Progress callback example

## I/ Implementation
This example shows how to register a progress callback with the **mmg3d**
library before calling **MMG3D_mmg3dlib**.

The callback receives the current remeshing phase, the iteration count and the
number of mesh operations performed during the iteration. It returns 1 to keep
remeshing; returning 0 asks Mmg to stop.

A phase may stop before reaching its maximum iteration count when the mesh has
converged. Mmg emits a final completion notification so progress bars can close
at 100%.

The same pattern can be used with **MMG2D_Set_progressCallback** and
**MMGS_Set_progressCallback** for the 2D and surface libraries.

## II/ Compilation
1. Build and install the **mmg3d** shared and static library. We suppose in
the following that you have installed the **mmg3d** library in the
**_$CMAKE_INSTALL_PREFIX_** directory;
2. compile the main.c file specifying:
* the **mmg3d** include directory with the **-I** option;
* the **mmg3d** library location with the **-L** option;
* the **mmg3d** library name with the **-l** option;
* for the static library you must also link the executable with, if used for
the **mmg3d** library compilation, the scotch and scotcherr libraries and
with the math library.

> Example 1
> Command line to link the application with the **mmg3d** static library:
> ```Shell
> gcc -I$CMAKE_INSTALL_PREFIX/include main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmg3d -lscotch -lscotcherr -lm
> ```

> Example 2
> Command line to link the application with the **mmg3d** shared library:
> ```Shell
> gcc -I$CMAKE_INSTALL_PREFIX/include main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg3d
> export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH
> ```

## III/ Run
```Shell
./a.out cube.mesh cube-progress.mesh
```

For a larger input that makes progress reporting visible, run the command-line
tool on the 2 spheres example:

```Shell
mmg3d -progress ../adaptation_example2/2spheres.mesh -out 2spheres-progress.mesh
```

The **-progress** option keeps the usual Mmg output and adds progress reporting.
With verbose output, progress is printed as regular rows to avoid overwriting
diagnostic messages.
58 changes: 58 additions & 0 deletions libexamples/mmg3d/progress_callback_example0/cube.mesh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
MeshVersionFormatted 2

Dimension 3

Vertices
12
0 0 0 0
0.5 0 0 0
0.5 0 1 0
0 0 1 0
0 1 0 0
0.5 1 0 0
0.5 1 1 0
0 1 1 0
1 0 0 0
1 1 0 0
1 0 1 0
1 1 1 0

Tetrahedra
12
1 4 2 8 1
8 3 2 7 1
5 2 6 8 1
5 8 1 2 1
7 2 8 6 1
2 4 3 8 1
9 2 3 7 2
7 11 9 12 2
6 9 10 7 2
6 7 2 9 2
12 9 7 10 2
9 3 11 7 2

Triangles
20
1 4 8 3
1 2 4 3
8 3 7 3
5 8 6 3
5 6 2 3
5 2 1 3
5 1 8 3
7 6 8 3
4 3 8 3
2 3 4 3
9 3 2 4
11 9 12 4
7 11 12 4
6 7 10 4
6 10 9 4
6 9 2 4
12 10 7 4
12 9 10 4
3 11 7 4
9 11 3 4

End
21 changes: 21 additions & 0 deletions libexamples/mmg3d/progress_callback_example0/cube.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MeshVersionFormatted 2

Dimension 3

SolAtVertices
12
1 1
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5

End
Loading