42 MMG5_int ns,nc,nsw,nns,nnc,nnsw;
50 if ( typchk == 2 && it == 0 ) {
61 fprintf(stderr,
" ## Unable to complete surface mesh. Exit program.\n");
67 fprintf(stdout,
" ## Hashing problem. Exit program.\n");
74 fprintf(stderr,
" ## Unable to collapse mesh. Exiting.\n");
87 fprintf(stderr,
" ## Unable to improve mesh. Exiting.\n");
98 fprintf(stdout,
" %8" MMG5_PRId
" splitted, %8" MMG5_PRId
" collapsed, %8" MMG5_PRId
" swapped\n",ns,nc,nsw);
99 if ( it > 3 && MMG5_abs(nc-ns) < 0.1 *
MG_MAX(nc,ns) )
break;
101 while ( ++it < maxit && ns+nc+nsw >0 );
105 fprintf(stdout,
" %8" MMG5_PRId
" splitted, %8" MMG5_PRId
" collapsed, %8" MMG5_PRId
" swapped, %d iter.\n",nns,nnc,nnsw,it);
115 double len,s,o[2],no[2];
117 MMG5_int ni,npinit,ns,nc,k,nt,ip1,ip2,ip,vx[3];
118 int8_t i,ic,i1,i2,
ier;
119 static int8_t mmgWarn0=0;
128 for (k=1; k<=
mesh->
nt; k++) {
130 if ( !
MG_EOK(pt) || (pt->
ref < 0) )
continue;
141 else if ( typchk ==2 ) {
142 for (i=0; i<3; i++) {
145 len = MMG2D_lencurv(
mesh,met,pt->
v[i1],pt->
v[i2]);
152 for (i=0; i<3; i++) {
161 if ( !pt->
flag )
continue;
165 for (i=0; i<3; i++) {
172 if ( ip > 0 )
continue;
184 fprintf(stderr,
"\n ## Error: %s: unable to"
185 " allocate a new point.\n",__func__);
189 }
while (
mesh->
np>npinit );
return -1;,
201 MMG2D_intmet(
mesh,met,k,i,ip,s);
213 for (k=1; k<=
mesh->
nt; k++) {
215 if ( !
MG_EOK(pt) || pt->
ref < 0 )
continue;
216 else if ( pt->
flag == 7 )
continue;
219 for (i=0; i<3; i++) {
233 fprintf(stdout,
" %" MMG5_PRId
" analyzed %" MMG5_PRId
" proposed\n",
mesh->
nt,ns);
237 for (k=1; k<=
mesh->
np; k++)
244 for ( k=1; k<=
mesh->
nt; k++) {
246 if ( !
MG_EOK(pt) || pt->
ref < 0 )
continue;
247 else if ( pt->
flag == 0 )
continue;
249 vx[0] = vx[1] =vx[2] = 0;
253 for (i=0; i<3; i++) {
263 if ( !pt->
flag )
continue;
265 case 1:
case 2:
case 4:
285 for (i=0; i<3; i++) {
290 ppt->
c[0] = 0.5 * (p1->
c[0] + p2->
c[0]);
291 ppt->
c[1] = 0.5 * (p1->
c[1] + p2->
c[1]);
298 while ( ni >0 && ++it <20 );
301 fprintf(stdout,
" %" MMG5_PRId
" corrected, %" MMG5_PRId
" invalid\n",nc,ni);
308 for (k=1; k<=nt; k++) {
310 if ( !
MG_EOK(pt) || pt->ref < 0 )
continue;
311 else if ( pt->flag == 0 )
continue;
313 vx[0] = vx[1] = vx[2] = 0;
314 for (i=0; i<3; i++) {
317 if (
MG_GET(pt->flag,i) ) {
322 fprintf(stderr,
"\n ## Error: %s: unable to create point on"
323 " at least 1 edge.\n Exit program.\n",__func__);
329 if ( pt->flag == 1 || pt->flag == 2 || pt->flag == 4 ) {
333 else if ( pt->flag == 7 ) {
341 if ( !
ier )
return -1;
344 fprintf(stdout,
" %7" MMG5_PRId
" splitted\n",ns);
363 double o[3][2],p[3][2];
372 for (i=0; i<3; i++) {
373 memset(p[i],0,2*
sizeof(
double));
374 memset(o[i],0,2*
sizeof(
double));
383 o[i][0] = 0.5 * (pa->
c[0] + pb->
c[0]);
384 o[i][1] = 0.5 * (pa->
c[1] + pb->
c[1]);
397 for (i=0; i<3; i++) {
400 ps->
c[0] = o[i][0] + t*(p[i][0] - o[i][0]);
401 ps->
c[1] = o[i][1] + t*(p[i][1] - o[i][1]);
405 case 1:
case 2:
case 4:
420 while ( ++it < maxit );
425 for (i=0; i<3; i++) {
428 ps->
c[0] = o[i][0] + t*(p[i][0] - o[i][0]);
429 ps->
c[1] = o[i][1] + t*(p[i][1] - o[i][1]);
440 double ux,uy,ll,hmin2;
444 uint8_t i,i1,i2,open;
450 for (k=1; k<=
mesh->
nt; k++) {
452 if ( !
MG_EOK(pt) || pt->
ref < 0 )
continue;
457 for (i=0; i<3; i++) {
475 open = (
mesh->
adja[3*(k-1)+1+i] == 0) ? 1 : 0;
479 ux = p2->
c[0] - p1->
c[0];
480 uy = p2->
c[1] - p1->
c[1];
482 if ( ll > hmin2 )
continue;
485 ll = MMG2D_lencurv(
mesh,met,pt->
v[i1],pt->
v[i2]);
492 if ( ilist > 3 || ( ilist == 3 && open ) ) {
496 else if ( ilist == 3 ) {
500 else if ( ilist == 2 ) {
508 fprintf(stdout,
" %8" MMG5_PRId
" vertices removed\n",nc);
527 for (k=1; k<=
mesh->
nt; k++) {
529 if ( !
MG_EOK(pt) || pt->
ref < 0 )
continue;
531 for (i=0; i<3; i++) {
541 while ( ns > 0 && ++it<maxit );
543 fprintf(stdout,
" %8" MMG5_PRId
" edge swapped\n",nns);
552 MMG5_int nns,ns,nnc,nc,nnsw,nsw,nnm,nm;
554 nns = nnc = nnsw = nnm = it = 0;
562 fprintf(stderr,
" ## Problem in function adpspl."
563 " Unable to complete mesh. Exit program.\n");
569 fprintf(stderr,
" ## Problem in function adpcol."
570 " Unable to complete mesh. Exit program.\n");
582 fprintf(stderr,
" ## Problem in function swpmsh."
583 " Unable to complete mesh. Exit program.\n");
593 fprintf(stderr,
" ## Problem in function movtri. "
594 "Unable to complete mesh. Exit program.\n");
607 fprintf(stdout,
" %8" MMG5_PRId
" splitted, %8" MMG5_PRId
" collapsed, %8" MMG5_PRId
" swapped, %8" MMG5_PRId
" moved\n",ns,nc,nsw,nm);
608 if ( ns < 10 && MMG5_abs(nc-ns) < 3 )
break;
609 else if ( it > 3 && MMG5_abs(nc-ns) < 0.3 *
MG_MAX(nc,ns) )
break;
611 while( ++it < maxit && (nc+ns+nsw+nm > 0) );
617 fprintf(stderr,
" ## Problem in function movtri. Unable to complete mesh."
625 fprintf(stdout,
" %8" MMG5_PRId
" splitted, %8" MMG5_PRId
" collapsed, %8" MMG5_PRId
" swapped, %8" MMG5_PRId
" moved, %d iter. \n",nns,nnc,nnsw,nnm,it);
651 for (k=1; k<=nt; k++) {
653 if ( !
MG_EOK(pt) || pt->
ref < 0 )
continue;
657 for (i=0; i<3; i++) {
662 len = MMG2D_lencurv(
mesh,met,pt->
v[i1],pt->
v[i2]);
671 else if (
MG_SIN(pt->
tag[imax]) )
continue;
706 for (k=1; k<=
mesh->
nt; k++) {
708 if ( !
MG_EOK(pt) || pt->
ref < 0 )
continue;
712 for (i=0; i<3; i++) {
715 open = (
mesh->
adja[3*(k-1)+1+i] == 0 ) ? 1 : 0;
730 len = MMG2D_lencurv(
mesh,met,pt->
v[i1],pt->
v[i2]);
736 if ( ilist > 3 || ( ilist==3 && open ) ) {
740 else if ( ilist == 3 ) {
744 else if ( ilist == 2 ) {
758 MMG5_int nnm,nm,ns,k;
766 for (k=1; k<=
mesh->
np; k++)
772 for (k=1; k<=
mesh->
nt; k++) {
774 if ( !
MG_EOK(pt) || pt->
ref < 0 )
continue;
776 for (i=0; i<3; i++) {
788 if ( met->
size == 3 && met->
m )
801 if (
mesh->
info.
ddebug ) fprintf(stdout,
" %8" MMG5_PRId
" moved, %" MMG5_PRId
" geometry\n",nm,ns);
803 while ( ++it < maxit && nm > 0 );
806 fprintf(stdout,
" %8" MMG5_PRId
" vertices moved, %d iter.\n",nnm,it);
823 fprintf(stdout,
" ** GEOMETRIC MESH\n");
826 fprintf(stderr,
" ## Unable to split mesh-> Exiting.\n");
832 if ( getenv(
"MMG_SAVE_ANATRI1") ) {
833 printf(
" ## WARNING: EXIT AFTER ANATRI-1."
834 " (MMG_SAVE_ANATRI1 env variable is exported).\n");
840 fprintf(stdout,
" ** COMPUTATIONAL MESH\n");
842 if ( !MMG2D_defsiz(
mesh,met) ) {
843 fprintf(stderr,
" ## Metric undefined. Exit program.\n");
849 if ( getenv(
"MMG_SAVE_DEFSIZ") ) {
850 printf(
" ## WARNING: EXIT AFTER DEFSIZ."
851 " (MMG_SAVE_DEFSIZ env variable is exported).\n");
857 if (!MMG2D_gradsiz(
mesh,met) ) {
858 fprintf(stderr,
" ## Gradation problem. Exit program.\n");
864 MMG2D_gradsizreq(
mesh,met);
868 if ( getenv(
"MMG_SAVE_GRADSIZ") ) {
869 printf(
" ## WARNING: EXIT AFTER GRADSIZ."
870 " (MMG_SAVE_GRADSIZ env variable is exported).\n");
875 fprintf(stderr,
" ## Unable to proceed adaptation. Exit program.\n");
880 if ( getenv(
"MMG_SAVE_ANATRI1") ) {
881 printf(
" ## WARNING: EXIT AFTER ANATRI-2."
882 " (MMG_SAVE_ANATRI2 env variable is exported).\n");
889 fprintf(stderr,
" ## Unable to make fine improvements. Exit program.\n");
int MMG2D_movintpt_ani(MMG5_pMesh mesh, MMG5_pSol met, int ilist, MMG5_int *list, int8_t improve)
int MMG2D_bezierCurv(MMG5_pMesh mesh, MMG5_int k, int8_t i, double s, double *o, double *no)
int MMG2D_chkedg(MMG5_pMesh mesh, MMG5_int k)
int MMG5_boulet(MMG5_pMesh mesh, MMG5_int start, int ip, MMG5_int *list, int8_t s, int8_t *opn)
int MMG2D_colver(MMG5_pMesh mesh, int ilist, MMG5_int *list)
int MMG2D_chkcol(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, int8_t i, MMG5_int *list, int8_t typchk)
int MMG2D_colver3(MMG5_pMesh mesh, MMG5_int *list)
int MMG2D_colver2(MMG5_pMesh mesh, MMG5_int *list)
int MMG5_hashNew(MMG5_pMesh mesh, MMG5_Hash *hash, MMG5_int hsiz, MMG5_int hmax)
MMG5_int MMG5_hashGet(MMG5_Hash *hash, MMG5_int a, MMG5_int b)
int MMG5_hashEdge(MMG5_pMesh mesh, MMG5_Hash *hash, MMG5_int a, MMG5_int b, MMG5_int k)
int MMG2D_hashTria(MMG5_pMesh mesh)
void MMG5_gradation_info(MMG5_pMesh mesh)
#define MMG2D_POINT_REALLOC(mesh, sol, ip, wantedGap, law, o, tag)
int MMG2D_movintpt(MMG5_pMesh, MMG5_pSol, int, MMG5_int *, int8_t)
int MMG2D_split3(MMG5_pMesh, MMG5_pSol, MMG5_int, MMG5_int vx[3])
int MMG2D_split2_sim(MMG5_pMesh, MMG5_pSol, MMG5_int, MMG5_int vx[3])
int MMG2D_split2(MMG5_pMesh, MMG5_pSol, MMG5_int, MMG5_int vx[3])
int MMG2D_chkswp(MMG5_pMesh, MMG5_pSol, MMG5_int, int8_t, int8_t)
MMG5_int MMG2D_chkspl(MMG5_pMesh, MMG5_pSol, MMG5_int, int8_t)
int MMG2D_split1b(MMG5_pMesh, MMG5_int, int8_t, MMG5_int)
int MMG2D_split1(MMG5_pMesh, MMG5_pSol, MMG5_int, MMG5_int vx[3])
MMG5_int MMG2D_newPt(MMG5_pMesh mesh, double c[2], uint16_t tag)
void MMG2D_delPt(MMG5_pMesh mesh, MMG5_int ip)
int MMG2D_split1_sim(MMG5_pMesh, MMG5_pSol, MMG5_int, MMG5_int vx[3])
int MMG2D_swapar(MMG5_pMesh, MMG5_int, int8_t)
int MMG2D_movedgpt(MMG5_pMesh, MMG5_pSol, int, MMG5_int *, int8_t)
int MMG2D_split3_sim(MMG5_pMesh, MMG5_pSol, MMG5_int, MMG5_int vx[3])
int MMG2D_adptri(MMG5_pMesh mesh, MMG5_pSol met)
MMG5_int MMG2D_anaelt(MMG5_pMesh mesh, MMG5_pSol met, int typchk)
MMG5_int MMG2D_movtri(MMG5_pMesh mesh, MMG5_pSol met, int maxit, int8_t improve)
int MMG2D_anatri(MMG5_pMesh mesh, MMG5_pSol met, int8_t typchk)
int MMG2D_dichoto(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int *vx)
int MMG2D_adpcol(MMG5_pMesh mesh, MMG5_pSol met)
int MMG2D_mmg2d1n(MMG5_pMesh mesh, MMG5_pSol met)
MMG5_int MMG2D_colelt(MMG5_pMesh mesh, MMG5_pSol met, int typchk)
MMG5_int MMG2D_swpmsh(MMG5_pMesh mesh, MMG5_pSol met, int typchk)
MMG5_int MMG2D_adpspl(MMG5_pMesh mesh, MMG5_pSol met)
#define MMG5_INCREASE_MEM_MESSAGE()
#define MG_CLR(flag, bit)
static const uint8_t MMG5_iprv2[3]
#define MG_GET(flag, bit)
static const uint8_t MMG5_inxt2[6]
#define MMG5_DEL_MEM(mesh, ptr)
#define MG_SET(flag, bit)
Identic as MMG5_HGeom but use MMG5_hedge to store edges instead of MMG5_hgeom (memory economy).
Structure to store vertices of an MMG mesh.
Structure to store triangles of a MMG mesh.