Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
libexamples
mmgs
adaptation_example0
example0_a
main.c
Go to the documentation of this file.
1
/* =============================================================================
2
** This file is part of the mmg software package for the tetrahedral
3
** mesh modification.
4
** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- .
5
**
6
** mmg is free software: you can redistribute it and/or modify it
7
** under the terms of the GNU Lesser General Public License as published
8
** by the Free Software Foundation, either version 3 of the License, or
9
** (at your option) any later version.
10
**
11
** mmg is distributed in the hope that it will be useful, but WITHOUT
12
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14
** License for more details.
15
**
16
** You should have received a copy of the GNU Lesser General Public
17
** License and of the GNU General Public License along with mmg (in
18
** files COPYING.LESSER and COPYING). If not, see
19
** <http://www.gnu.org/licenses/>. Please read their terms carefully and
20
** use this copy of the mmg distribution only if you accept them.
21
** =============================================================================
22
*/
23
35
#include <assert.h>
36
#include <stdio.h>
37
#include <stdlib.h>
38
#include <signal.h>
39
#include <string.h>
40
#include <ctype.h>
41
#include <math.h>
42
#include <float.h>
43
45
// if the header file is in the "include" directory
46
// #include "libmmgs.h"
47
// if the header file is in "include/mmg/mmgs"
48
#include "mmg/mmgs/libmmgs.h"
49
50
int
main
(
int
argc,
char
*argv[]) {
51
MMG5_pMesh
mmgMesh;
52
MMG5_pSol
mmgSol;
53
int
ier
;
54
char
*
filename
, *fileout;
55
56
fprintf(stdout,
" -- TEST MMGSLIB \n"
);
57
58
if
( argc != 3 ) {
59
printf(
" Usage: %s filein fileout\n"
,argv[0]);
60
return
(1);
61
}
62
63
/* Name and path of the mesh file */
64
filename
= (
char
*) calloc(strlen(argv[1]) + 1,
sizeof
(char));
65
if
(
filename
== NULL ) {
66
perror(
" ## Memory problem: calloc"
);
67
exit(EXIT_FAILURE);
68
}
69
strcpy(
filename
,argv[1]);
70
71
72
fileout = (
char
*) calloc(strlen(argv[2]) + 1,
sizeof
(char));
73
if
( fileout == NULL ) {
74
perror(
" ## Memory problem: calloc"
);
75
exit(EXIT_FAILURE);
76
}
77
strcpy(fileout,argv[2]);
78
81
/* args of InitMesh:
82
* MMG5_ARG_start: we start to give the args of a variadic func
83
* MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh
84
* &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh)
85
* MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric
86
* &mmgSol: pointer toward your MMG5_pSol (that store your metric) */
87
mmgMesh = NULL;
88
mmgSol = NULL;
89
MMGS_Init_mesh
(
MMG5_ARG_start
,
90
MMG5_ARG_ppMesh
,&mmgMesh,
MMG5_ARG_ppMet
,&mmgSol,
91
MMG5_ARG_end
);
92
98
if
(
MMGS_loadMesh
(mmgMesh,
filename
) != 1 ) exit(EXIT_FAILURE);
99
105
if
(
MMGS_loadSol
(mmgMesh,mmgSol,
filename
) != 1 )
106
exit(EXIT_FAILURE);
107
109
if
(
MMGS_Chk_meshData
(mmgMesh,mmgSol) != 1 ) exit(EXIT_FAILURE);
110
113
ier
=
MMGS_mmgslib
(mmgMesh,mmgSol);
114
if
(
ier
==
MMG5_STRONGFAILURE
) {
115
fprintf(stdout,
"BAD ENDING OF MMGSLIB: UNABLE TO SAVE MESH\n"
);
116
return
(
ier
);
117
}
else
if
(
ier
==
MMG5_LOWFAILURE
)
118
fprintf(stdout,
"BAD ENDING OF MMGSLIB\n"
);
119
120
128
if
(
MMGS_saveMesh
(mmgMesh,fileout) != 1 )
129
exit(EXIT_FAILURE);
130
132
if
(
MMGS_saveSol
(mmgMesh,mmgSol,fileout) != 1 )
133
exit(EXIT_FAILURE);
134
136
MMGS_Free_all
(
MMG5_ARG_start
,
137
MMG5_ARG_ppMesh
,&mmgMesh,
MMG5_ARG_ppMet
,&mmgSol,
138
MMG5_ARG_end
);
139
140
free(
filename
);
141
filename
= NULL;
142
143
free(fileout);
144
fileout = NULL;
145
146
return
(
ier
);
147
}
MMGS_Init_mesh
int MMGS_Init_mesh(const int starter,...)
Definition:
API_functions_s.c:43
MMGS_Free_all
int MMGS_Free_all(const int starter,...)
Definition:
API_functions_s.c:1676
MMGS_Chk_meshData
int MMGS_Chk_meshData(MMG5_pMesh mesh, MMG5_pSol met)
Definition:
API_functions_s.c:1256
ier
int ier
Definition:
API_functionsf_2d.c:743
filename
MMG5_pMesh char * filename
Definition:
API_functionsf_3d.c:1026
main
program main
Example for using mmglib (basic use)
Definition:
main.F90:6
MMGS_loadSol
int MMGS_loadSol(MMG5_pMesh mesh, MMG5_pSol met, const char *filename)
Definition:
inout_s.c:1307
MMGS_saveMesh
int MMGS_saveMesh(MMG5_pMesh mesh, const char *filename)
Definition:
inout_s.c:837
MMGS_saveSol
int MMGS_saveSol(MMG5_pMesh mesh, MMG5_pSol met, const char *filename)
Definition:
inout_s.c:1478
MMGS_loadMesh
int MMGS_loadMesh(MMG5_pMesh mesh, const char *filename)
Definition:
inout_s.c:41
MMGS_mmgslib
int MMGS_mmgslib(MMG5_pMesh mesh, MMG5_pSol met)
Definition:
libmmgs.c:545
MMG5_ARG_ppMesh
#define MMG5_ARG_ppMesh
Definition:
libmmgtypes.h:96
MMG5_ARG_end
#define MMG5_ARG_end
Definition:
libmmgtypes.h:173
MMG5_STRONGFAILURE
#define MMG5_STRONGFAILURE
Definition:
libmmgtypes.h:59
MMG5_LOWFAILURE
#define MMG5_LOWFAILURE
Definition:
libmmgtypes.h:51
MMG5_ARG_start
#define MMG5_ARG_start
Definition:
libmmgtypes.h:87
MMG5_ARG_ppMet
#define MMG5_ARG_ppMet
Definition:
libmmgtypes.h:116
MMG5_Mesh
MMG mesh structure.
Definition:
libmmgtypes.h:605
MMG5_Sol
Definition:
libmmgtypes.h:662
Generated on Thu Jan 19 2023 00:00:00 for Mmg by
1.9.6