Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
visu.F90
Go to the documentation of this file.
1
4
5PROGRAM main
6
7 IMPLICIT NONE
8
10 ! if the header file is in the "include" directory
11 ! #include "libmmg2df.h"
12
13 ! if the header file is in "include/mmg/mmg2d"
14#include "mmg/mmg2d/libmmg2df.h"
15
16 mmg5_data_ptr_t :: mesh
17 mmg5_data_ptr_t :: sol,mmgmet
18 INTEGER :: ier,argc,i,j,opt
19
20 CHARACTER(len=300) :: exec_name,filename,fileout
21
22 print*," -- 2D MESH GENERATION FOR VISUALIZATION"
23
24 argc = command_argument_count();
25 CALL get_command_argument(0, exec_name)
26
27
28 IF ( argc /= 2 ) THEN
29 print*," Usage: ",trim(adjustl(exec_name)),&
30 " input_file_name output_file_name" &
31 " Generation of a triangular mesh for solution vizualisation (at VTK &
32 & file format) from a Medit mesh file containing only points and the &
33 & associated solution file."
34 CALL exit(1);
35 ENDIF
36
37 ! Name and path of the mesh file
38 CALL get_command_argument(1, filename)
39 CALL get_command_argument(2, fileout)
40
41 !!> ------------------------------ STEP I --------------------------
42 !! 1) Initialisation of mesh and sol structures */
43 !! args of InitMesh:
44 !! MMG5_ARG_start: we start to give the args of a variadic func
45 !! MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh
46 !! &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh)
47 !! MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric
48 !! &mmgSol: pointer toward your MMG5_pSol (that store your metric)
49
50 mesh = 0
51 sol = 0
52 mmgmet = 0
53
54 CALL mmg2d_init_mesh(mmg5_arg_start, &
55 mmg5_arg_ppmesh,mmgmesh,mmg5_arg_ppmet,mmgmet, &
56 mmg5_arg_ppmet,sol, &
57 mmg5_arg_end);
58
59
60 !!> 2) Build initial mesh and solutions in MMG5 format
61 !! Two solutions: just use the MMG2D_loadMesh function that will read a .mesh(b)
62 !! file formatted or manually set your mesh using the MMG2D_Set* functions
63
64 !!> Automatic loading of the mesh and multiple solutions
65 CALL mmg2d_loadmesh(mesh,trim(adjustl(filename)),&
66 len(trim(adjustl(filename))),ier)
67 IF ( ier /= 1 ) CALL exit(102)
68
69 CALL mmg2d_loadsol(mesh,sol,trim(adjustl(filename)),&
70 len(trim(adjustl(filename))),ier)
71 IF ( ier /= 1 ) CALL exit(103)
72
73 !!> ------------------------------ STEP II ---------------------------
74 !! Mesh generation
75 CALL mmg2d_set_iparameter(mesh,mmgmet,mmg2d_iparam_noinsert,1,ier);
76 IF ( ier /= 1 ) CALL exit(104)
77
78 CALL mmg2d_set_iparameter(mesh,mmgmet,mmg2d_iparam_noswap,1,ier);
79 IF ( ier /= 1 ) CALL exit(105)
80
81 CALL mmg2d_set_iparameter(mesh,mmgmet,mmg2d_iparam_nomove,1,ier);
82 IF ( ier /= 1 ) CALL exit(106)
83
84 CALL mmg2d_mmg2dmesh(mesh,mmgmet,ier)
85 IF ( ier /= mmg5_success ) CALL exit(200)
86
87 !!> ------------------------------ STEP III --------------------------
88 !! Save the new data
89 !! Use the MMG2D_saveMesh/MMG2D_saveAllSols functions
90 !! save the mesh
92 CALL mmg2d_savevtkmesh(mesh,sol,trim(adjustl(fileout)),len(trim(adjustl(fileout))),ier)
93 IF ( ier /= 1 ) CALL exit(300)
94
95 !!> 3) Free the MMG2D structures
96 CALL mmg2d_free_all(mmg5_arg_start, &
97 mmg5_arg_ppmesh,mesh,mmg5_arg_ppmet,mmgmet, &
98 mmg5_arg_ppmet,sol, &
99 mmg5_arg_end)
100
101END PROGRAM main
int main(int argc, char *argv[])
Definition: mmg2d.c:275