mmg2d
mmgcommon.h
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 
24 #ifndef MMGCOMMON_H
25 #define MMGCOMMON_H
26 
27 #include <assert.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <limits.h>
31 #include <string.h>
32 #include <signal.h>
33 #include <ctype.h>
34 #include <float.h>
35 #include <math.h>
36 #include <complex.h>
37 #include "mmgcmakedefines.h"
38 
39 #if (defined(__APPLE__) && defined(__MACH__))
40 #include <sys/sysctl.h>
41 #elif defined(__unix__) || defined(__unix) || defined(unix)
42 #include <unistd.h>
43 #elif defined(_WIN16) || defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)
44 #ifndef MMG_GNU
45 #define _WIN32_WINNT 0x0500
46 #endif
47 
48 #include <windows.h>
49 #endif
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 #include "eigenv.h"
56 #include "libmmgcommon.h"
57 
58 #define MG_STR "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
59 
61 #define MG_SMSGN(a,b) (((double)(a)*(double)(b) > (0.0)) ? (1) : (0))
62 
64 #define MMG5_BOXSIZE 500
65 
67 #define MMG5_MEMMAX 800
68 #define MMG5_BITWIZE_MB_TO_B 20
69 #define MMG5_MEMPERCENT 0.5
71 /* Macro for unset or unititialized mark */
72 #define MMG5_UNSET -1
73 
74 /* reference of the boundary that moves in lagrangian mode */
75 #define MMG5_DISPREF 10
76 
77 /* million */
78 #define MMG5_MILLION 1048576
79 
80 /* numerical accuracy */
81 #define MMG5_ANGEDG 0.707106781186548 /*0.573576436351046 */
82 #define MMG5_ANGLIM -0.999999
83 #define MMG5_ATHIRD 0.333333333333333
84 
85 #define MMG5_EPSD 1.e-30
86 #define MMG5_EPSD2 1.0e-200
87 #define MMG5_EPS 1.e-06
88 #define MMG5_EPSOK 1.e-15
89 #define MMG5_NULKAL 1.e-30
90 
91 #define MMG5_SQR32 0.866025403784439
92 
93 #ifndef M_PI
94 #define M_PI 3.14159265358979323846
95 #define M_PI_2 1.57079632679489661923
96 #endif
97 
98 #define A64TH 0.015625
99 #define A16TH 0.0625
100 #define A32TH 0.03125
101 
102 #define MMG5_MEMMIN 38
104 #define MMG5_LMAX 10240
105 
106 #define MMG5_PATHSEP '/'
107 
108 /* Variables for option initialization */
109 #define MMG5_NONSET_MEM -1
110 #define MMG5_NONSET_HMIN -1
111 #define MMG5_NONSET_HMAX -1
112 #define MMG5_NONSET_HSIZ -1
113 #define MMG5_NONSET -1
114 #define MMG5_HAUSD 0.01
115 #define MMG5_HGRAD 0.26236426446
116 #define MMG5_HGRADREQ 0.83290912294
117 #define MMG5_NOHGRAD -1
118 #define MMG5_LAG -1
119 #define MMG5_NR -1
120 #define MMG5_LS 0.0
121 #define MMG5_PROCTREE 32
122 #define MMG5_OFF 0
123 #define MMG5_ON 1
124 #define MMG5_GAP 0.2
125 #define MMG5_HMINCOE 0.001
126 #define MMG5_HMAXCOE 2
127 #define MMG5_HMINMAXGAP 5
128 #define MMG5_FEM 1
129 #define MMG5_FILESTR_LGTH 128
131 /* Macros */
132 #define MG_MAX(a,b) (((a) > (b)) ? (a) : (b))
133 #define MG_MIN(a,b) (((a) < (b)) ? (a) : (b))
134 
135 /* tags */
136 #define MG_NOTAG (0)
137 #define MG_REF (1 << 0)
138 #define MG_GEO (1 << 1)
139 #define MG_REQ (1 << 2)
140 #define MG_NOM (1 << 3)
141 #define MG_BDY (1 << 4)
142 #define MG_CRN (1 << 5)
143 #define MG_NOSURF (1 << 6)
144 #define MG_OPNBDY (1 << 7)
145 #define MG_OLDPARBDY (1 << 11)
146 #define MG_PARBDYBDY (1 << 12)
147 #define MG_PARBDY (1 << 13)
148 #define MG_NUL (1 << 14)
150 /* binary tags for local parameters */
151 #define MG_Vert (1 << 0 )
152 #define MG_Tria (1 << 1 )
153 #define MG_Tetra (1 << 2 )
154 #define MG_Edge (1 << 3 )
157 #define MG_VOK(ppt) (ppt && ((ppt)->tag < MG_NUL))
158 #define MG_EOK(pt) (pt && ((pt)->v[0] > 0))
160 #define MG_EDG(tag) ((tag & MG_GEO) || (tag & MG_REF))
161 #define MG_SIN(tag) ((tag & MG_CRN) || (tag & MG_REQ))
162 #define MG_RID(tag) ((!( MG_SIN(tag)||(tag & MG_NOM))) && tag & MG_GEO )
165 #define MG_SET(flag,bit) ((flag) |= (1 << (bit)))
166 #define MG_CLR(flag,bit) ((flag) &= ~(1 << (bit)))
167 #define MG_GET(flag,bit) ((flag) & (1 << (bit)))
169 #define MMG5_KA 7
170 #define MMG5_KB 11
172 /* file reading */
173 #define MMG5_SW 4
174 #define MMG5_SD 8
175 
179 #define _LIBMMG5_RETURN(mesh,sol,met,val)do \
180  { \
181  signal(SIGABRT,SIG_DFL); \
182  signal(SIGFPE,SIG_DFL); \
183  signal(SIGILL,SIG_DFL); \
184  signal(SIGSEGV,SIG_DFL); \
185  signal(SIGTERM,SIG_DFL); \
186  signal(SIGINT,SIG_DFL); \
187  mesh->npi = mesh->np; \
188  mesh->nti = mesh->nt; \
189  mesh->nai = mesh->na; \
190  mesh->nei = mesh->ne; \
191  mesh->xt = 0; \
192  if ( sol ) { sol->npi = sol->np; } \
193  if ( met ) { met->npi = met->np; } \
194  return val; \
195  }while(0)
196 
197 /* Macros for memory management */
200 #define MMG5_CHK_MEM(mesh,size,string,law) do \
201  { \
202  if ( (mesh)->memCur > (mesh)->memMax ) { \
203  fprintf(stderr," ## Error:"); \
204  fprintf(stderr," unable to allocate %s.\n",string); \
205  fprintf(stderr," ## Check the mesh size or "); \
206  fprintf(stderr,"increase maximal authorized memory with the -m option.\n"); \
207  (mesh)->memCur -= (size); \
208  law; \
209  } \
210  }while(0)
211 
212 static inline
213 void * mycalloc(size_t c, size_t s) {
214  char *ptr;
215  ptr = (char *)calloc(c*s+sizeof(size_t),1);
216  if (ptr == NULL)
217  return NULL;
218  else {
219  *((size_t*)ptr)=c*s;
220  ptr+=sizeof(size_t);
221  return (void*)ptr;
222  }
223 }
224 
225 static inline
226 void * mymalloc(size_t s) {
227  char *ptr;
228  ptr = (char *)malloc(s+sizeof(size_t));
229  if (ptr == NULL)
230  return NULL;
231  else {
232  *((size_t*)ptr)=s;
233  ptr+=sizeof(size_t);
234  return (void*)ptr;
235  }
236 }
237 
238 static inline
239 void * myrealloc(void * ptr_in, size_t s, size_t oldsize) {
240  char *ptr;
241  char *ptr_in_c = (char*)ptr_in;
242 
243  if ( !ptr_in ) {
244  assert ( !oldsize );
245  return mymalloc( s );
246  }
247 
248  ptr_in_c -= sizeof(size_t);
249  if (oldsize != *((size_t*)ptr_in_c)) {
250  fprintf(stderr, "myrealloc: Error: freed memory mismatch\n");
251  assert(0);
252  }
253  ptr = (char *)realloc(ptr_in_c, s+sizeof(size_t));
254  if (ptr == NULL)
255  return NULL;
256  else {
257  *((size_t*)ptr)=s;
258  ptr+=sizeof(size_t);
259  return (void*)ptr;
260  }
261 }
262 
263 static inline
264 size_t myfree(void *ptr) {
265  size_t s;
266  char * ptr_c = (char*)ptr;
267 
268  if ( !ptr ) return 0;
269 
270  ptr_c = ptr_c-sizeof(size_t);
271  s = *((size_t*)ptr_c);
272  free(ptr_c);
273 
274  return s;
275 }
276 
278 #define MMG5_DEL_MEM(mesh,ptr) do \
279  { \
280  size_t size_to_free = myfree(ptr); \
281  (mesh)->memCur -= size_to_free; \
282  ptr = NULL; \
283  }while(0)
284 
287 #define MMG5_ADD_MEM(mesh,size,message,law) do \
288  { \
289  (mesh)->memCur += (size); \
290  MMG5_CHK_MEM(mesh,size,message,law); \
291  }while(0)
292 
294 #define MMG5_SAFE_FREE(ptr) do \
295  { \
296  myfree(ptr); \
297  ptr = NULL; \
298  }while(0)
299 
301 #define MMG5_SAFE_CALLOC(ptr,size,type,law) do \
302  { \
303  ptr = (type*)mycalloc(size,sizeof(type)); \
304  if ( !ptr ) { \
305  perror(" ## Memory problem: calloc"); \
306  law; \
307  } \
308  }while(0)
309 
311 #define MMG5_SAFE_MALLOC(ptr,size,type,law) do \
312  { \
313  size_t size_to_allocate = (size)*sizeof(type); \
314  ptr = (type*)mymalloc(size_to_allocate); \
315  if ( !ptr ) { \
316  perror(" ## Memory problem: malloc"); \
317  law; \
318  } \
319  }while(0)
320 
322 #define MMG5_SAFE_REALLOC(ptr,prevSize,newSize,type,message,law) do \
323  { \
324  type* tmp; \
325  size_t size_to_allocate = (newSize)*sizeof(type); \
326  \
327  tmp = (type *)myrealloc((ptr),size_to_allocate,(prevSize)*sizeof(type)); \
328  if ( !tmp ) { \
329  MMG5_SAFE_FREE(ptr); \
330  perror(" ## Memory problem: realloc"); \
331  law; \
332  } \
333  \
334  (ptr) = tmp; \
335  }while(0)
336 
338 #define MMG5_SAFE_RECALLOC(ptr,prevSize,newSize,type,message,law) do \
339  { \
340  type* tmp; \
341  size_t size_to_allocate = (newSize)*sizeof(type); \
342  \
343  tmp = (type *)myrealloc((ptr),size_to_allocate,(prevSize)*sizeof(type)); \
344  if ( !tmp ) { \
345  MMG5_SAFE_FREE(ptr); \
346  perror(" ## Memory problem: realloc"); \
347  law; \
348  } \
349  else { \
350  (ptr) = tmp; \
351  assert(ptr); \
352  if ( newSize > prevSize ) { \
353  memset(&((ptr)[prevSize]),0,((newSize)-(prevSize))*sizeof(type)); \
354  } \
355  } \
356  }while(0)
357 
361 #define MMG5_TAB_RECALLOC(mesh,ptr,initSize,wantedGap,type,message,law) do \
362  { \
363  int gap; \
364  \
365  assert ( mesh->memCur < mesh->memMax ); \
366  \
367  gap = (int)(wantedGap * initSize); \
368  if ( !gap ) gap = 1; \
369  \
370  if ( mesh->memMax < mesh->memCur + gap*sizeof(type) ) { \
371  gap = (int)((mesh->memMax-mesh->memCur)/sizeof(type)); \
372  if(gap<1) { \
373  fprintf(stderr," ## Error:"); \
374  fprintf(stderr," unable to allocate %s.\n",message); \
375  fprintf(stderr," ## Check the mesh size or "); \
376  fprintf(stderr,"increase maximal authorized memory with the -m option.\n"); \
377  law; \
378  } \
379  } \
380  \
381  MMG5_ADD_MEM(mesh,gap*sizeof(type),message,law); \
382  MMG5_SAFE_RECALLOC((ptr),initSize+1,initSize+gap+1,type,message,law); \
383  initSize = initSize+gap; \
384  }while(0);
385 
387 #define MMG5_INCREASE_MEM_MESSAGE() do \
388  { \
389  printf(" ## Check the mesh size or increase maximal"); \
390  printf(" authorized memory with the -m option.\n"); \
391  } while(0)
392 
393 #define MMG5_SAFELL2LCAST(longlongval) (((longlongval) > (LONG_MAX)) ? 0 : ((long)(longlongval)))
394 #define MMG5_SAFELL2ICAST(longlongval) (((longlongval) > (INT_MAX)) ? 0 : ((int)(longlongval)))
395 
397 #define MMG_FREAD(ptr,size,count,stream) do \
398  { \
399  \
400  if ( count != fread(ptr,size,count,stream) ) { \
401  fputs ( "Reading error", stderr ); \
402  return -1; \
403  } \
404  } while(0);
405 
407 #define CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
408 
410 #define CV_VA_NUM_ARGS(...) CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
411 
418 #ifdef MMG_POSIX
419 #define MMG_FSCANF(stream,format,...) do \
420  { \
421  int io_count = fscanf(stream,format,__VA_ARGS__); \
422  int args_count = CV_VA_NUM_ARGS(__VA_ARGS__); \
423  if ( args_count != io_count ) { \
424  fprintf (stderr, "Reading error: fscanf counts %d args while %d provided\n",io_count,args_count ); \
425  return -1; \
426  } \
427  } while(0);
428 #else
429 #define MMG_FSCANF(stream,format,...) do \
430  { \
431  int io_count = fscanf(stream,format,__VA_ARGS__); \
432  int args_count = CV_VA_NUM_ARGS(__VA_ARGS__); \
433  if ( 0 > io_count ) { \
434  fprintf (stderr, "Reading error: fscanf counts %d args\n",io_count); \
435  return -1; \
436  } \
437  } while(0);
438 #endif
439 
441 #ifdef USE_SCOTCH
443 static inline
444 void MMG5_warnScotch(MMG5_pMesh mesh) {
445  if ( mesh->info.imprim > 4 || mesh->info.ddebug ) {
446  if ( mesh->info.mem >= 0 ) {
447  fprintf(stdout," ## Warning: we will overflow the memory asked with \"-m\"");
448  fprintf(stdout," option during Scotch call.\n" );
449  }
450  }
451 }
452 #endif
459 static inline
460 void MMG5_excfun(int sigid) {
461  fprintf(stdout,"\n Unexpected error:"); fflush(stdout);
462  switch(sigid) {
463  case SIGABRT:
464  fprintf(stdout," *** potential lack of memory.\n"); break;
465  case SIGFPE:
466  fprintf(stdout," *** Floating-point exception\n"); break;
467  case SIGILL:
468  fprintf(stdout," *** Illegal instruction\n"); break;
469  case SIGSEGV:
470  fprintf(stdout," *** Segmentation fault\n"); break;
471  case SIGTERM:
472  case SIGINT:
473  fprintf(stdout," *** Program killed\n"); break;
474  }
475  exit(EXIT_FAILURE);
476 }
477 
478 /* Macro for fortran function generation */
492 #define FORTRAN_NAME(nu,nl,pl,pc) \
493  void nu pl; \
494  void nl pl \
495  { nu pc; } \
496  void nl##_ pl \
497  { nu pc; } \
498  void nl##__ pl \
499  { nu pc; } \
500  void nu pl
501 
514 #define FORTRAN_VARIADIC(nu,nl,pl,body) \
515  void nu pl \
516  { body } \
517  void nl pl \
518  { body } \
519  void nl##_ pl \
520  { body } \
521  void nl##__ pl \
522  { body } \
523 
540 };
541 
542 
543 /* Global variables */
544  static const uint8_t MMG5_inxt2[6] = {1,2,0,1,2};
545  static const uint8_t MMG5_iprv2[3] = {2,0,1};
547 /* Private structures */
554 typedef struct {
555  double b[10][3];
556  double n[6][3];
557  double t[6][3];
558  MMG5_pPoint p[3];
559 } MMG5_Bezier;
561 
566 typedef struct MMG5_iNode_s {
567  int val;
568  struct MMG5_iNode_s *nxt;
570 
575 typedef struct MMG5_dNode_s {
576  int k;
577  double val;
578  struct MMG5_dNode_s *nxt;
580 
581 
582 /* Functions declarations */
583  extern double MMG5_det3pt1vec(double c0[3],double c1[3],double c2[3],double v[3]);
584  extern double MMG5_det4pt(double c0[3],double c1[3],double c2[3],double c3[3]);
585  int MMG5_devangle(double* n1, double *n2, double crit);
586  extern double MMG5_orvol(MMG5_pPoint point,int *v);
587  int MMG5_Add_inode( MMG5_pMesh mesh, MMG5_iNode **liLi, int val );
588  int MMG5_Add_dnode( MMG5_pMesh mesh, MMG5_dNode **liLi, int, double);
589  extern void MMG5_bezierEdge(MMG5_pMesh, int, int, double*, double*, int8_t,double*);
590  int MMG5_buildridmet(MMG5_pMesh,MMG5_pSol,int,double,double,double,double*,double[3][3]);
591  extern int MMG5_buildridmetfic(MMG5_pMesh,double*,double*,double,double,double,double*);
592  int MMG5_buildridmetnor(MMG5_pMesh, MMG5_pSol, int,double*, double*,double[3][3]);
593 void MMG5_check_hminhmax(MMG5_pMesh mesh, int8_t sethmin, int8_t sethmax);
594  int MMG5_paratmet(double c0[3],double n0[3],double m[6],double c1[3],double n1[3],double mt[6]);
595  void MMG5_mn(double m[6], double n[6], double mn[9] );
596  extern int MMG5_rmtr(double r[3][3],double m[6], double mr[6]);
598  int MMG5_boulep(MMG5_pMesh mesh,int start,int ip,int*,int *list);
599  int MMG5_boulec(MMG5_pMesh, int*, int, int i,double *tt);
600  int MMG5_boulen(MMG5_pMesh, int*, int, int i,double *nn);
601  int MMG5_bouler(MMG5_pMesh, int*, int, int i,int *,int *,int *, int*, int);
603  extern double MMG5_caltri_ani(MMG5_pMesh mesh,MMG5_pSol met,MMG5_pTria ptt);
604  extern double MMG5_caltri_iso(MMG5_pMesh mesh,MMG5_pSol met,MMG5_pTria ptt);
605  void MMG5_defUninitSize(MMG5_pMesh mesh,MMG5_pSol met,int8_t ismet);
606  void MMG5_displayLengthHisto(MMG5_pMesh,int,double*,int,int,double,
607  int,int,double,int,double*,int*,int8_t);
608  void MMG5_displayLengthHisto_internal( int,int,int,double,
609  int,int,double, int,double*,
610  int*,int8_t,int);
611  int MMG5_minQualCheck ( int iel, double minqual, double alpha );
613  MMG5_Bezier*,double r[3][3],double gv[2]);
614  void MMG5_fillDefmetregSys( int, MMG5_pPoint, int, MMG5_Bezier,double r[3][3],
615  double *, double *, double *, double *);
620  char *MMG5_Get_filenameExt( char *filename );
621  char *MMG5_Get_basename(char *path);
622  char *MMG5_Get_path(char *path);
623  char *MMG5_Remove_ext( char *path, char* );
624  const char *MMG5_Get_formatName(enum MMG5_Format fmt);
625  int MMG5_Get_format( char *ptr, int );
626  int MMG5_hashEdge(MMG5_pMesh mesh,MMG5_Hash *hash,int a,int b,int k);
627  int MMG5_hashUpdate(MMG5_Hash *hash,int a,int b,int k);
628  int MMG5_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash,int a,int b,int16_t k);
629  int MMG5_hashGet(MMG5_Hash *hash,int a,int b);
630  int MMG5_hashNew(MMG5_pMesh mesh, MMG5_Hash *hash,int hsiz,int hmax);
631  int MMG5_intmetsavedir(MMG5_pMesh mesh, double *m,double *n,double *mr);
632  int MMG5_intridmet(MMG5_pMesh,MMG5_pSol,int,int,double,double*,double*);
633  int MMG5_mmgIntmet33_ani(double*,double*,double*,double);
634  int MMG5_mmgIntextmet(MMG5_pMesh,MMG5_pSol,int,double *,double *);
635  size_t MMG5_memSize(void);
638  int MMG5_mmgHashTria(MMG5_pMesh mesh, int *adja, MMG5_Hash*, int chkISO);
640  void MMG5_mmgUsage(char *prog);
641  void MMG5_paramUsage1(void);
642  void MMG5_paramUsage2(void);
643  void MMG5_2d3dUsage(void);
644  void MMG5_lagUsage(void);
645  void MMG5_advancedUsage(void);
646  extern int MMG5_nonUnitNorPts(MMG5_pMesh,int,int,int,double*);
647  extern double MMG5_nonorsurf(MMG5_pMesh mesh,MMG5_pTria pt);
648  extern int MMG5_norpts(MMG5_pMesh,int,int,int,double *);
649  extern int MMG5_nortri(MMG5_pMesh mesh,MMG5_pTria pt,double *n);
650  void MMG5_printTria(MMG5_pMesh mesh,char* fileName);
651  extern int MMG5_rotmatrix(double n[3],double r[3][3]);
652  int MMG5_invmat(double *m,double *mi);
653  int MMG5_invmatg(double m[9],double mi[9]);
654  int MMG5_invmat33(double m[3][3],double mi[3][3]);
656  double MMG5_ridSizeInNormalDir(MMG5_pMesh,int,double*,MMG5_pBezier,double,double);
657  double MMG5_ridSizeInTangentDir(MMG5_pMesh, MMG5_pPoint,int,int*,double,double);
658  int MMG5_scale_meshAndSol(MMG5_pMesh,MMG5_pSol,MMG5_pSol,double*,int8_t*,int8_t*);
659  int MMG5_scale_scalarMetric(MMG5_pMesh, MMG5_pSol,double, int8_t, int8_t);
663  int MMG5_solveDefmetregSys( MMG5_pMesh, double r[3][3], double *, double *,
664  double *, double *, double, double, double);
665  int MMG5_solveDefmetrefSys( MMG5_pMesh,MMG5_pPoint,int*, double r[3][3],
666  double *, double *, double *, double *,
667  double, double, double);
669  double MMG5_surftri33_ani(MMG5_pMesh,MMG5_pTria,double*,double*,double*);
671  extern int MMG5_sys33sym(double a[6], double b[3], double r[3]);
673  int MMG5_interpreg_ani(MMG5_pMesh,MMG5_pSol,MMG5_pTria,int8_t,double,double *mr);
674  int MMG5_interp_iso(double *ma,double *mb,double *mp,double t);
675  int MMG5_intersecmet22(MMG5_pMesh mesh, double *m,double *n,double *mr);
677  extern int MMG5_writeLocalParamAtTri( MMG5_pMesh,MMG5_iNode *,FILE*);
678  double MMG2D_quickarea(double a[2],double b[2],double c[2]);
679  void MMG5_build3DMetric(MMG5_pMesh mesh,MMG5_pSol sol,int ip,double dbuf[6]);
680  int MMG5_loadVtuMesh(MMG5_pMesh mesh,MMG5_pSol sol,const char *filename);
681  int MMG5_loadMshMesh_part1(MMG5_pMesh mesh,const char *filename,
682  FILE **inm,long *posNodes, long *posElts,
683  long **posNodeData, int *bin, int *iswp,
684  int *nelts,int *nsols);
685  int MMG5_check_readedMesh(MMG5_pMesh mesh,int nref);
687  const long posNodes,const long posElts,
688  const long *posNodeData,const int bin,
689  const int iswp,const int nelts,
690  const int nsols);
691 int MMG5_saveMshMesh(MMG5_pMesh,MMG5_pSol*,const char*, int);
692 int MMG5_loadSolHeader(const char*,int,FILE**,int*,int*,int*,int*,
693  int*,int*,int**,long*,int);
694 int MMG5_chkMetricType(MMG5_pMesh mesh,int *type, FILE *inm);
695 int MMG5_readFloatSol3D(MMG5_pSol,FILE*,int,int,int);
696 int MMG5_readDoubleSol3D(MMG5_pSol,FILE*,int,int,int);
697 int MMG5_saveSolHeader( MMG5_pMesh,const char*,FILE**,int,int*,int*,int,
698  int,int,int*,int*,int*);
699 int MMG5_saveSolAtTrianglesHeader( MMG5_pMesh,FILE *,int,int,int*,int,
700  int,int*,int*,int*);
701 int MMG5_saveSolAtTetrahedraHeader( MMG5_pMesh,FILE *,int,int,int*,int,
702  int,int*,int*,int*);
703 void MMG5_writeDoubleSol3D(MMG5_pMesh,MMG5_pSol,FILE*,int,int,int);
706 
707 int MMG5_defsiz_startingMessage (MMG5_pMesh,MMG5_pSol,const char * funcname );
709 int MMG5_sum_reqEdgeLengthsAtPoint ( MMG5_pMesh,MMG5_pSol,int ip0,int ip1 );
712 
717 int MMG5_gradsiz_ani(MMG5_pMesh mesh,MMG5_pSol met,int *it);
719 int MMG5_simred(MMG5_pMesh,double*,double*,double dm[2],double dn[2],double vp[2][2]);
720 void MMG5_gradEigenvreq(double *dm,double *dn,double,int8_t,int8_t *);
721 int MMG5_updatemetreq_ani(double *n,double dn[2],double vp[2][2]);
722 int MMG5_swapbin(int sbin);
723 float MMG5_swapf(float sbin);
724 double MMG5_swapd(double sbin);
726 int MMG5_isLevelSet(MMG5_pMesh,int,int);
727 int MMG5_isSplit(MMG5_pMesh ,int ,int *,int *);
728 int MMG5_isNotSplit(MMG5_pMesh ,int);
729 int MMG5_getStartRef(MMG5_pMesh ,int, int *);
730 
731 
732 /* tools */
734 void MMG5_mark_usedVertices ( MMG5_pMesh mesh,void (*delPt)(MMG5_pMesh,int) );
735 void MMG5_keep_subdomainElts ( MMG5_pMesh,int,int (*delElt)(MMG5_pMesh,int) );
736 
737 /* function pointers */
738 extern int (*MMG5_chkmsh)(MMG5_pMesh,int,int);
739 extern int (*MMG5_bezierCP)(MMG5_pMesh ,MMG5_Tria *,MMG5_pBezier ,int8_t );
740 extern double (*MMG5_lenSurfEdg)(MMG5_pMesh mesh,MMG5_pSol sol ,int ,int, int8_t );
741 extern int (*MMG5_grad2met_ani)(MMG5_pMesh,MMG5_pSol,MMG5_pTria,int,int);
742 extern int (*MMG5_grad2metreq_ani)(MMG5_pMesh,MMG5_pSol,MMG5_pTria,int,int);
744 
745 
746 /* useful functions to debug */
747 extern int (*MMG5_indElt)(MMG5_pMesh mesh,int kel);
748 extern int (*MMG5_indPt)(MMG5_pMesh mesh,int kp);
749 
750 #ifdef USE_SCOTCH
751 extern int (*MMG5_renumbering)(int,MMG5_pMesh,MMG5_pSol sol,MMG5_pSol fields,int*);
752 #endif
753 
755 
756 #ifdef __cplusplus
757 }
758 #endif
759 
760 #endif
MMG5_pMesh MMG5_pSol * sol
Definition: API_functionsf_2d.c:63
MMG5_pMesh * mesh
Definition: API_functionsf_2d.c:63
API header for the common part of the MMG libraries.
MMG5_Tria * MMG5_pTria
Definition: libmmgtypes.h:325
MMG5_Sol * MMG5_pSol
Definition: libmmgtypes.h:647
MMG5_Mesh * MMG5_pMesh
Definition: libmmgtypes.h:627
int MMG5_simred(MMG5_pMesh, double *, double *, double dm[2], double dn[2], double vp[2][2])
Definition: anisosiz.c:1262
void MMG5_bezierEdge(MMG5_pMesh, int, int, double *, double *, int8_t, double *)
int MMG5_gradsizreq_ani(MMG5_pMesh mesh, MMG5_pSol met)
Definition: anisosiz.c:1818
int(* MMG5_chkmsh)(MMG5_pMesh, int, int)
Definition: mmgexterns.c:27
int MMG5_loadSolHeader(const char *, int, FILE **, int *, int *, int *, int *, int *, int *, int **, long *, int)
Definition: inout.c:2030
int MMG5_scotchCall(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_pSol fields, int *)
Definition: librnbg.c:229
void MMG5_mmgInit_parameters(MMG5_pMesh mesh)
int MMG5_readFloatSol3D(MMG5_pSol, FILE *, int, int, int)
Definition: inout.c:2170
int MMG5_unscaleMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol ls)
Definition: scalem.c:401
void MMG5_gradEigenvreq(double *dm, double *dn, double, int8_t, int8_t *)
Definition: anisosiz.c:1380
const char * MMG5_Get_formatName(enum MMG5_Format fmt)
Definition: mmg.c:557
int(* MMG5_compute_meanMetricAtMarkedPoints)(MMG5_pMesh, MMG5_pSol)
Definition: mmgexterns.c:34
int MMG5_loadMshMesh_part1(MMG5_pMesh mesh, const char *filename, FILE **inm, long *posNodes, long *posElts, long **posNodeData, int *bin, int *iswp, int *nelts, int *nsols)
Definition: inout.c:238
void MMG5_advancedUsage(void)
Definition: mmg.c:135
int MMG5_mmgHashTria(MMG5_pMesh mesh, int *adja, MMG5_Hash *, int chkISO)
Definition: hash.c:50
int MMG5_check_readedMesh(MMG5_pMesh mesh, int nref)
Definition: inout.c:486
void MMG5_mn(double m[6], double n[6], double mn[9])
Definition: tools.c:171
int MMG5_readDoubleSol3D(MMG5_pSol, FILE *, int, int, int)
Definition: inout.c:2219
size_t MMG5_memSize(void)
Definition: tools.c:547
int MMG5_countLocalParamAtTri(MMG5_pMesh, MMG5_iNode **)
Definition: mmg.c:193
int(* MMG5_bezierCP)(MMG5_pMesh, MMG5_Tria *, MMG5_pBezier, int8_t)
Definition: mmgexterns.c:28
int MMG5_boulec(MMG5_pMesh, int *, int, int i, double *tt)
Definition: boulep.c:189
static void * mycalloc(size_t c, size_t s)
Definition: mmgcommon.h:213
int MMG5_scale_scalarMetric(MMG5_pMesh, MMG5_pSol, double, int8_t, int8_t)
Definition: scalem.c:122
int MMG5_gradsizreq_iso(MMG5_pMesh, MMG5_pSol)
Definition: isosiz.c:368
double MMG5_caltri_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria ptt)
Definition: quality.c:115
double MMG2D_quickarea(double a[2], double b[2], double c[2])
Definition: tools.c:858
int MMG5_hashEdge(MMG5_pMesh mesh, MMG5_Hash *hash, int a, int b, int k)
Definition: hash.c:269
int MMG5_intridmet(MMG5_pMesh, MMG5_pSol, int, int, double, double *, double *)
int MMG5_solveDefmetrefSys(MMG5_pMesh, MMG5_pPoint, int *, double r[3][3], double *, double *, double *, double *, double, double, double)
void MMG5_printSolStats(MMG5_pMesh mesh, MMG5_pSol *sol)
Definition: inout.c:2659
void MMG5_memOption_memSet(MMG5_pMesh mesh)
Definition: tools.c:586
float MMG5_swapf(float sbin)
Definition: inout.c:61
double MMG5_nonorsurf(MMG5_pMesh mesh, MMG5_pTria pt)
Definition: tools.c:107
int MMG5_isNotSplit(MMG5_pMesh, int)
Definition: mmg2.c:358
int MMG5_Add_dnode(MMG5_pMesh mesh, MMG5_dNode **liLi, int, double)
Definition: tools.c:742
int MMG5_grad2metSurfreq(MMG5_pMesh, MMG5_pSol, MMG5_pTria, int, int)
Definition: anisosiz.c:1448
int MMG5_boundingBox(MMG5_pMesh mesh)
Definition: scalem.c:45
static void MMG5_excfun(int sigid)
Definition: mmgcommon.h:460
int MMG5_saveSolAtTetrahedraHeader(MMG5_pMesh, FILE *, int, int, int *, int, int, int *, int *, int *)
Definition: inout.c:2543
int MMG5_Add_inode(MMG5_pMesh mesh, MMG5_iNode **liLi, int val)
Definition: tools.c:644
int MMG5_updatemetreq_ani(double *n, double dn[2], double vp[2][2])
Definition: anisosiz.c:1411
int MMG5_regnor(MMG5_pMesh mesh)
Definition: analys.c:46
void MMG5_mmgUsage(char *prog)
Definition: mmg.c:44
int MMG5_writeLocalParamAtTri(MMG5_pMesh, MMG5_iNode *, FILE *)
Definition: mmg.c:237
int MMG5_isLevelSet(MMG5_pMesh, int, int)
Definition: mmg2.c:382
void MMG5_build3DMetric(MMG5_pMesh mesh, MMG5_pSol sol, int ip, double dbuf[6])
Definition: inout.c:1479
int MMG5_interp_iso(double *ma, double *mb, double *mp, double t)
Definition: intmet.c:478
double MMG5_surftri_iso(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria ptt)
Definition: isosiz.c:42
int(* MMG5_indPt)(MMG5_pMesh mesh, int kp)
Definition: mmgexterns.c:31
int MMG5_saveSolHeader(MMG5_pMesh, const char *, FILE **, int, int *, int *, int, int, int, int *, int *, int *)
Definition: inout.c:2337
void MMG5_check_hminhmax(MMG5_pMesh mesh, int8_t sethmin, int8_t sethmax)
Definition: scalem.c:88
int MMG5_getStartRef(MMG5_pMesh, int, int *)
Definition: mmg2.c:143
int MMG5_compute_meanMetricAtMarkedPoints_ani(MMG5_pMesh mesh, MMG5_pSol met)
Definition: anisosiz.c:1702
static void * mymalloc(size_t s)
Definition: mmgcommon.h:226
double MMG5_ridSizeInTangentDir(MMG5_pMesh, MMG5_pPoint, int, int *, double, double)
Definition: anisosiz.c:723
int MMG5_scale_meshAndSol(MMG5_pMesh, MMG5_pSol, MMG5_pSol, double *, int8_t *, int8_t *)
Definition: scalem.c:182
void MMG5_displayLengthHisto(MMG5_pMesh, int, double *, int, int, double, int, int, double, int, double *, int *, int8_t)
Definition: quality.c:251
int MMG5_intersecmet22(MMG5_pMesh mesh, double *m, double *n, double *mr)
Definition: mettools.c:254
void MMG5_paramUsage1(void)
Definition: mmg.c:72
void MMG5_2d3dUsage(void)
Definition: mmg.c:121
void MMG5_solTruncatureForOptim(MMG5_pMesh mesh, MMG5_pSol met)
Definition: mmg.c:264
static const uint8_t MMG5_iprv2[3]
Definition: mmgcommon.h:545
double MMG5_det3pt1vec(double c0[3], double c1[3], double c2[3], double v[3])
Definition: tools.c:807
int MMG5_mmgIntextmet(MMG5_pMesh, MMG5_pSol, int, double *, double *)
int MMG5_mmgIntmet33_ani(double *, double *, double *, double)
Definition: intmet.c:49
double MMG5_det4pt(double c0[3], double c1[3], double c2[3], double c3[3])
Definition: tools.c:819
MMG5_Format
Type of supported file format.
Definition: mmgcommon.h:528
@ MMG5_FMT_MeditBinary
Definition: mmgcommon.h:530
@ MMG5_FMT_Tetgen
Definition: mmgcommon.h:538
@ MMG5_FMT_VtkVtk
Definition: mmgcommon.h:537
@ MMG5_FMT_GmshBinary
Definition: mmgcommon.h:532
@ MMG5_FMT_VtkPvtp
Definition: mmgcommon.h:533
@ MMG5_FMT_Unknown
Definition: mmgcommon.h:539
@ MMG5_FMT_GmshASCII
Definition: mmgcommon.h:531
@ MMG5_FMT_MeditASCII
Definition: mmgcommon.h:529
@ MMG5_FMT_VtkVtp
Definition: mmgcommon.h:536
@ MMG5_FMT_VtkPvtu
Definition: mmgcommon.h:534
@ MMG5_FMT_VtkVtu
Definition: mmgcommon.h:535
int MMG5_saveMshMesh(MMG5_pMesh, MMG5_pSol *, const char *, int)
Definition: inout.c:1538
int MMG5_buildridmetnor(MMG5_pMesh, MMG5_pSol, int, double *, double *, double[3][3])
void MMG5_mark_pointsOnReqEdge_fromTria(MMG5_pMesh mesh)
Definition: isosiz.c:242
int MMG5_buildridmetfic(MMG5_pMesh, double *, double *, double, double, double, double *)
MMG5_Bezier * MMG5_pBezier
Definition: mmgcommon.h:560
int MMG5_saveSolAtTrianglesHeader(MMG5_pMesh, FILE *, int, int, int *, int, int, int *, int *, int *)
Definition: inout.c:2474
void MMG5_writeDoubleSol3D(MMG5_pMesh, MMG5_pSol, FILE *, int, int, int)
Definition: inout.c:2268
void MMG5_mmgDefaultValues(MMG5_pMesh mesh)
Definition: mmg.c:150
int MMG5_sum_reqEdgeLengthsAtPoint(MMG5_pMesh, MMG5_pSol, int ip0, int ip1)
Definition: isosiz.c:129
int MMG5_hashUpdate(MMG5_Hash *hash, int a, int b, int k)
Definition: hash.c:323
int MMG5_chkMetricType(MMG5_pMesh mesh, int *type, FILE *inm)
Definition: inout.c:2608
void MMG5_keep_subdomainElts(MMG5_pMesh, int, int(*delElt)(MMG5_pMesh, int))
Definition: tools.c:958
int MMG5_rmtr(double r[3][3], double m[6], double mr[6])
Definition: tools.c:199
int MMG5_invmat33(double m[3][3], double mi[3][3])
Definition: tools.c:370
int MMG5_hashEdgeTag(MMG5_pMesh mesh, MMG5_Hash *hash, int a, int b, int16_t k)
Definition: hash.c:359
void MMG5_lagUsage(void)
Definition: mmg.c:105
double MMG5_swapd(double sbin)
Definition: inout.c:73
int MMG5_loadVtuMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
int MMG5_hashGet(MMG5_Hash *hash, int a, int b)
Definition: hash.c:416
void MMG5_defUninitSize(MMG5_pMesh mesh, MMG5_pSol met, int8_t ismet)
Definition: anisosiz.c:225
double(* MMG5_lenSurfEdg)(MMG5_pMesh mesh, MMG5_pSol sol, int, int, int8_t)
Definition: mmgexterns.c:29
int MMG5_paratmet(double c0[3], double n0[3], double m[6], double c1[3], double n1[3], double mt[6])
Definition: mettools.c:652
int MMG5_norpts(MMG5_pMesh, int, int, int, double *)
Definition: tools.c:130
struct MMG5_iNode_s MMG5_iNode
void MMG5_Free_ilinkedList(MMG5_pMesh mesh, MMG5_iNode *liLi)
Definition: tools.c:696
static const uint8_t MMG5_inxt2[6]
Definition: mmgcommon.h:544
char * MMG5_Get_basename(char *path)
Definition: mmg.c:403
void MMG5_mark_verticesAsUnused(MMG5_pMesh mesh)
Definition: tools.c:881
static size_t myfree(void *ptr)
Definition: mmgcommon.h:264
double MMG5_surftri_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria ptt)
Definition: anisosiz.c:122
void MMG5_displayLengthHisto_internal(int, int, int, double, int, int, double, int, double *, int *, int8_t, int)
Definition: quality.c:293
double MMG5_ridSizeInNormalDir(MMG5_pMesh, int, double *, MMG5_pBezier, double, double)
void MMG5_printTria(MMG5_pMesh mesh, char *fileName)
Definition: tools.c:520
void MMG5_printMetStats(MMG5_pMesh mesh, MMG5_pSol met)
Definition: inout.c:2641
int MMG5_devangle(double *n1, double *n2, double crit)
Definition: tools.c:50
static void * myrealloc(void *ptr_in, size_t s, size_t oldsize)
Definition: mmgcommon.h:239
int MMG5_isSplit(MMG5_pMesh, int, int *, int *)
Definition: mmg2.c:322
int MMG5_grad2metSurf(MMG5_pMesh, MMG5_pSol, MMG5_pTria, int, int)
Definition: anisosiz.c:910
int MMG5_elementWeight(MMG5_pMesh, MMG5_pSol, MMG5_pTria, MMG5_pPoint, MMG5_Bezier *, double r[3][3], double gv[2])
Definition: anisomovpt.c:53
int MMG5_bouler(MMG5_pMesh, int *, int, int i, int *, int *, int *, int *, int)
Definition: boulep.c:277
int MMG5_MultiMat_init(MMG5_pMesh)
Definition: mmg2.c:255
int MMG5_scaleMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol ls)
Definition: scalem.c:273
int MMG5_buildridmet(MMG5_pMesh, MMG5_pSol, int, double, double, double, double *, double[3][3])
char * MMG5_Get_path(char *path)
Definition: mmg.c:420
void MMG5_paramUsage2(void)
Definition: mmg.c:89
int(* MMG5_grad2metreq_ani)(MMG5_pMesh, MMG5_pSol, MMG5_pTria, int, int)
Definition: mmgexterns.c:33
int MMG5_nortri(MMG5_pMesh mesh, MMG5_pTria pt, double *n)
Definition: tools.c:156
int MMG5_interpreg_ani(MMG5_pMesh, MMG5_pSol, MMG5_pTria, int8_t, double, double *mr)
int(* MMG5_indElt)(MMG5_pMesh mesh, int kel)
Definition: mmgexterns.c:30
int MMG5_nonUnitNorPts(MMG5_pMesh, int, int, int, double *)
Definition: tools.c:74
int MMG5_loadMshMesh_part2(MMG5_pMesh mesh, MMG5_pSol *sol, FILE **inm, const long posNodes, const long posElts, const long *posNodeData, const int bin, const int iswp, const int nelts, const int nsols)
Definition: inout.c:626
int MMG5_rotmatrix(double n[3], double r[3][3])
Definition: tools.c:233
int MMG5_sys33sym(double a[6], double b[3], double r[3])
Definition: tools.c:464
void MMG5_gradation_info(MMG5_pMesh)
Definition: isosiz.c:96
int MMG5_boulen(MMG5_pMesh, int *, int, int i, double *nn)
Definition: boulep.c:113
int MMG5_defsiz_startingMessage(MMG5_pMesh, MMG5_pSol, const char *funcname)
Definition: isosiz.c:77
int(* MMG5_grad2met_ani)(MMG5_pMesh, MMG5_pSol, MMG5_pTria, int, int)
Definition: mmgexterns.c:32
void MMG5_mark_usedVertices(MMG5_pMesh mesh, void(*delPt)(MMG5_pMesh, int))
Definition: tools.c:905
int MMG5_gradsiz_iso(MMG5_pMesh mesh, MMG5_pSol met)
Definition: isosiz.c:277
int MMG5_compute_meanMetricAtMarkedPoints_iso(MMG5_pMesh mesh, MMG5_pSol met)
Definition: isosiz.c:167
int MMG5_invmatg(double m[9], double mi[9])
Definition: tools.c:330
int MMG5_swapbin(int sbin)
Definition: inout.c:38
int MMG5_gradsiz_ani(MMG5_pMesh mesh, MMG5_pSol met, int *it)
Definition: anisosiz.c:1756
char * MMG5_Remove_ext(char *path, char *)
Definition: mmg.c:455
int MMG5_boulep(MMG5_pMesh mesh, int start, int ip, int *, int *list)
Definition: boulep.c:51
int MMG5_minQualCheck(int iel, double minqual, double alpha)
Definition: quality.c:342
char * MMG5_Get_filenameExt(char *filename)
Definition: mmg.c:376
double MMG5_orvol(MMG5_pPoint point, int *v)
Definition: tools.c:838
void MMG5_Free_dlinkedList(MMG5_pMesh mesh, MMG5_dNode *liLi)
Definition: tools.c:794
void MMG5_fillDefmetregSys(int, MMG5_pPoint, int, MMG5_Bezier, double r[3][3], double *, double *, double *, double *)
struct MMG5_dNode_s MMG5_dNode
void MMG5_Set_commonFunc(void)
double MMG5_caltri_iso(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria ptt)
Definition: quality.c:198
int MMG5_reset_metricAtReqEdges_surf(MMG5_pMesh, MMG5_pSol, int8_t)
Definition: isosiz.c:204
int MMG5_hashNew(MMG5_pMesh mesh, MMG5_Hash *hash, int hsiz, int hmax)
Definition: hash.c:446
int MMG5_Get_format(char *ptr, int)
Definition: mmg.c:509
int MMG5_solveDefmetregSys(MMG5_pMesh, double r[3][3], double *, double *, double *, double *, double, double, double)
double MMG5_surftri33_ani(MMG5_pMesh, MMG5_pTria, double *, double *, double *)
double MMG5_caltri33_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria pt)
Definition: quality.c:47
int MMG5_intmetsavedir(MMG5_pMesh mesh, double *m, double *n, double *mr)
Definition: mettools.c:86
int MMG5_invmat(double *m, double *mi)
Definition: tools.c:279
Definition: mmgcommon.h:554
Identic as MMG5_HGeom but use MMG5_hedge to store edges instead of MMG5_hgeom (memory economy).
Definition: libmmgtypes.h:565
int8_t ddebug
Definition: libmmgtypes.h:509
int mem
Definition: libmmgtypes.h:500
int imprim
Definition: libmmgtypes.h:506
MMG mesh structure.
Definition: libmmgtypes.h:575
MMG5_Info info
Definition: libmmgtypes.h:622
Structure to store points of a MMG mesh.
Definition: libmmgtypes.h:252
Definition: libmmgtypes.h:633
Definition: libmmgtypes.h:312
Definition: mmgcommon.h:575
struct MMG5_dNode_s * nxt
Definition: mmgcommon.h:578
int k
Definition: mmgcommon.h:576
double val
Definition: mmgcommon.h:577
Cell for linked list of double value.
Definition: mmgcommon.h:566
struct MMG5_iNode_s * nxt
Definition: mmgcommon.h:568
int val
Definition: mmgcommon.h:567
Cell for linked list of integer value.