Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
main.c
Go to the documentation of this file.
1/*Authors Cécile Dobrzynski
2
3 Example for using mmg2dlib
4
5*/
6#include <assert.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <signal.h>
10#include <string.h>
11#include <ctype.h>
12#include <math.h>
13#include <float.h>
14
16// if the header file is in the "include" directory
17// #include "libmmg2d.h"
18// if the header file is in "include/mmg/mmg2d"
19#include "mmg/mmg2d/libmmg2d.h"
20
21int main(int argc,char *argv[]) {
22 MMG5_pMesh mmgMesh;
23 MMG5_pSol mmgSol;
24 char *filename, *outname;
25
26 int ier;
27
28 fprintf(stdout," -- TEST MMG2DMESH \n");
29
30
31 if ( argc != 3 ) {
32 printf(" Usage: %s filein fileout \n",argv[0]);
33 return(1);
34 }
35
36 /* Name and path of the mesh file */
37 filename = (char *) calloc(strlen(argv[1]) + 1, sizeof(char));
38 if ( filename == NULL ) {
39 perror(" ## Memory problem: calloc");
40 exit(EXIT_FAILURE);
41 }
42 strcpy(filename,argv[1]);
43
44 outname = (char *) calloc(strlen(argv[2]) + 1, sizeof(char));
45 if ( outname == NULL ) {
46 perror(" ## Memory problem: calloc");
47 exit(EXIT_FAILURE);
48 }
49 strcpy(outname,argv[2]);
50
53 /* args of InitMesh:
54 * MMG5_ARG_start: we start to give the args of a variadic func
55 * MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh
56 * &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh)
57 * MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric
58 * &mmgSol: pointer toward your MMG5_pSol (that store your metric) */
59
60 mmgMesh = NULL;
61 mmgSol = NULL;
63 MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol,
65
71 MMG2D_loadMesh(mmgMesh,filename);
72
74 MMG2D_Set_dparameter(mmgMesh,mmgSol,MMG2D_DPARAM_hmax,0.1);
75
78
79
81 ier = MMG2D_mmg2dmesh(mmgMesh,mmgSol);
82
83 if ( ier == MMG5_STRONGFAILURE ) {
84 fprintf(stdout,"BAD ENDING OF MMG2DMESH: UNABLE TO SAVE MESH\n");
85 return(ier);
86 } else if ( ier == MMG5_LOWFAILURE )
87 fprintf(stdout,"BAD ENDING OF MMG2DMESH\n");
88
89 /*save result*/
90 if ( MMG2D_saveMesh(mmgMesh,outname) != 1 )
91 exit(EXIT_FAILURE);
92
93 /*save metric*/
94 if ( MMG2D_saveSol(mmgMesh,mmgSol,outname) != 1 )
95 exit(EXIT_FAILURE);
96
99 MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol,
101
102 free(filename);
103 filename = NULL;
104
105
106 free(outname);
107 outname = NULL;
108
109 return(0);
110}
int MMG2D_Init_mesh(const int starter,...)
Initialize a mesh structure and optionally the associated solution and metric structures.
int MMG2D_Set_iparameter(MMG5_pMesh mesh, MMG5_pSol sol, int iparam, MMG5_int val)
Set integer parameter iparam to value val.
int MMG2D_Set_dparameter(MMG5_pMesh mesh, MMG5_pSol sol, int dparam, double val)
Set double parameter dparam to value val.
int MMG2D_Free_all(const int starter,...)
Deallocations before return.
int ier
MMG5_pMesh char * filename
program main
Example for using mmglib (basic use)
Definition: main.F90:6
int MMG2D_saveMesh(MMG5_pMesh mesh, const char *filename)
Save a mesh in .mesh/.meshb format.
Definition: inout_2d.c:1101
int MMG2D_saveSol(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Save metric field in medit solution file format.
Definition: inout_2d.c:1617
int MMG2D_loadMesh(MMG5_pMesh mesh, const char *filename)
Load a mesh (in .mesh/.mesb format) from file.
Definition: inout_2d.c:28
int MMG2D_mmg2dmesh(MMG5_pMesh mesh, MMG5_pSol met)
Main "program" for the mesh generation library.
Definition: libmmg2d.c:305
@ MMG2D_DPARAM_hmax
Definition: libmmg2d.h:136
@ MMG2D_IPARAM_verbose
Definition: libmmg2d.h:112
#define MMG5_ARG_ppMesh
Definition: libmmgtypes.h:102
#define MMG5_ARG_end
Definition: libmmgtypes.h:179
#define MMG5_STRONGFAILURE
Definition: libmmgtypes.h:65
#define MMG5_LOWFAILURE
Definition: libmmgtypes.h:57
#define MMG5_ARG_start
Definition: libmmgtypes.h:93
#define MMG5_ARG_ppMet
Definition: libmmgtypes.h:122
MMG mesh structure.
Definition: libmmgtypes.h:613