Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
libexamples
mmg3d
LagrangianMotion_example0
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
36
#include <assert.h>
37
#include <stdio.h>
38
#include <stdlib.h>
39
#include <signal.h>
40
#include <string.h>
41
#include <ctype.h>
42
#include <math.h>
43
#include <float.h>
44
46
// if the header file is in the "include" directory
47
// #include "libmmg3d.h"
48
// if the header file is in "include/mmg/mmg3d"
49
#include "mmg/mmg3d/libmmg3d.h"
50
51
int
main
(
int
argc,
char
*argv[]) {
52
MMG5_pMesh
mmgMesh;
53
MMG5_pSol
mmgSol,mmgDisp;
54
int
ier
;
55
char
*inname,*outname;
56
57
fprintf(stdout,
" -- TEST MMG3DMOV \n"
);
58
59
if
( argc != 3 ) {
60
printf(
" Usage: %s filein fileout \n"
,argv[0]);
61
return
(1);
62
}
63
64
/* Name and path of the mesh files */
65
inname = (
char
*) calloc(strlen(argv[1]) + 1,
sizeof
(char));
66
if
( inname == NULL ) {
67
perror(
" ## Memory problem: calloc"
);
68
exit(EXIT_FAILURE);
69
}
70
strcpy(inname,argv[1]);
71
72
outname = (
char
*) calloc(strlen(argv[2]) + 1,
sizeof
(char));
73
if
( outname == NULL ) {
74
perror(
" ## Memory problem: calloc"
);
75
exit(EXIT_FAILURE);
76
}
77
strcpy(outname,argv[2]);
78
80
/* args of InitMesh:
81
* MMG5_ARG_start: we start to give the args of a variadic func
82
* MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh
83
* &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh)
84
* MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric
85
* &mmgSol: pointer toward your MMG5_pSol (that store your metric) */
86
mmgMesh = NULL;
87
mmgSol = NULL;
88
mmgDisp = NULL;
89
MMG3D_Init_mesh
(
MMG5_ARG_start
,
90
MMG5_ARG_ppMesh
,&mmgMesh,
MMG5_ARG_ppMet
,&mmgSol,
91
MMG5_ARG_ppDisp
,&mmgDisp,
92
MMG5_ARG_end
);
93
99
if
(
MMG3D_loadMesh
(mmgMesh,inname) != 1 ) exit(EXIT_FAILURE);
100
106
/* Ask for lagrangian motion (mode 1) */
107
if
(
MMG3D_Set_iparameter
(mmgMesh,mmgDisp,
MMG3D_IPARAM_lag
, 1) != 1 )
108
exit(EXIT_FAILURE);
109
111
if
(
MMG3D_loadSol
(mmgMesh,mmgDisp,inname) != 1 )
112
exit(EXIT_FAILURE);
113
115
if
(
MMG3D_Chk_meshData
(mmgMesh,mmgDisp) != 1 ) exit(EXIT_FAILURE);
116
124
/* debug mode ON (default value = OFF) */
125
if
(
MMG3D_Set_iparameter
(mmgMesh,mmgDisp,
MMG3D_IPARAM_debug
, 1) != 1 )
126
exit(EXIT_FAILURE);
127
129
ier
=
MMG3D_mmg3dmov
(mmgMesh,mmgSol,mmgDisp);
130
131
if
(
ier
==
MMG5_STRONGFAILURE
) {
132
fprintf(stdout,
"BAD ENDING OF MMG3DMOV: UNABLE TO SAVE MESH\n"
);
133
return
(
ier
);
134
}
else
if
(
ier
==
MMG5_LOWFAILURE
)
135
fprintf(stdout,
"BAD ENDING OF MMG3DMOV\n"
);
136
137
/* (Not mandatory) Automatically save the mesh */
138
if
(
MMG3D_saveMesh
(mmgMesh,outname) != 1 )
139
exit(EXIT_FAILURE);
140
141
/* 9) free the MMG3D5 structures */
142
MMG3D_Free_all
(
MMG5_ARG_start
,
143
MMG5_ARG_ppMesh
,&mmgMesh,
MMG5_ARG_ppMet
,&mmgSol,
144
MMG5_ARG_ppDisp
,&mmgDisp,
145
MMG5_ARG_end
);
146
free(inname);
147
inname = NULL;
148
149
free(outname);
150
outname = NULL;
151
152
return
(
ier
);
153
}
MMG3D_Init_mesh
int MMG3D_Init_mesh(const int starter,...)
Definition:
API_functions_3d.c:46
MMG3D_Chk_meshData
int MMG3D_Chk_meshData(MMG5_pMesh mesh, MMG5_pSol met)
Definition:
API_functions_3d.c:1879
MMG3D_Free_all
int MMG3D_Free_all(const int starter,...)
Definition:
API_functions_3d.c:2533
MMG3D_Set_iparameter
int MMG3D_Set_iparameter(MMG5_pMesh mesh, MMG5_pSol sol, int iparam, MMG5_int val)
Definition:
API_functions_3d.c:2109
ier
int ier
Definition:
API_functionsf_2d.c:743
main
program main
Example for using mmglib (basic use)
Definition:
main.F90:6
MMG3D_saveMesh
int MMG3D_saveMesh(MMG5_pMesh mesh, const char *filename)
Definition:
inout_3d.c:1259
MMG3D_loadSol
int MMG3D_loadSol(MMG5_pMesh mesh, MMG5_pSol met, const char *filename)
Definition:
inout_3d.c:2129
MMG3D_loadMesh
int MMG3D_loadMesh(MMG5_pMesh mesh, const char *filename)
Definition:
inout_3d.c:1044
MMG3D_mmg3dmov
int MMG3D_mmg3dmov(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol disp)
Definition:
libmmg3d.c:1475
MMG3D_IPARAM_debug
@ MMG3D_IPARAM_debug
Definition:
libmmg3d.h:72
MMG3D_IPARAM_lag
@ MMG3D_IPARAM_lag
Definition:
libmmg3d.h:78
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_ppDisp
#define MMG5_ARG_ppDisp
Definition:
libmmgtypes.h:126
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