53 MMG5_int *pile,*adja,ipil,k,kk,ncc,ip1,ip2,nr,nref;
62 fprintf(stdout,
" ** SETTING TOPOLOGY\n");
69 for ( k=1; k<=
mesh->
nt; ++k ) {
88 if ( !
MG_EOK(pt) )
continue;
105 pt->
tag[i] &= ~MG_REF;
106 pt->
tag[i] &= ~MG_BDY;
107 pt->
tag[i] &= ~MG_GEO;
109 pt1->
tag[ii] &= ~MG_REF;
110 pt1->
tag[ii] &= ~MG_BDY;
111 pt1->
tag[ii] &= ~MG_GEO;
113 pt1->
tag[ii] |= pt->
tag[i];
114 pt->
tag[i] |= pt1->
tag[ii];
118 pt1->
tag[ii] |= pt->
tag[i];
119 pt->
tag[i] |= pt1->
tag[ii];
165 || MMG5_abs(pt1->
ref) != MMG5_abs(pt->
ref) ) {
195 if ( kk > k ) nref++;
199 if ( pt1->
cc > 0 )
continue;
208 for (kk=1; kk<=
mesh->
nt; kk++) {
210 if ( pt->
v[0] && (pt->
cc == 0) ) {
225 if ( !
MG_EOK(pq) )
continue;
228 for (i=0; i<4; i++) {
246 assert ( pt->
edg[ii] == pq->
edg[i] );
263 fprintf(stdout,
" Connected component or subdomains: %" MMG5_PRId
" \n",ncc);
264 fprintf(stdout,
" Tagged edges: %" MMG5_PRId
", ridges: %" MMG5_PRId
", refs: %" MMG5_PRId
"\n",nr+nref,nr,nref);
283 double ux,uy,uz,vx,vy,vz,dd;
292 for (k=1; k<=
mesh->
np; ++k) {
299 for ( k=1; k<=
mesh->
np; ++k ) {
304 for ( k=1; k<=
mesh->
nt; ++k ) {
307 for (i=0; i<3; i++) {
309 if ( pt->
edg[i] != ref )
continue;
318 for (k=1; k<=
mesh->
nt; k++) {
320 if ( !
MG_EOK(pt) )
continue;
322 for (i=0; i<3; i++) {
325 if ( ppt->
s )
continue;
351 else if ( (ng == 1) && (nr == 1) ) {
356 else if ( ng == 1 && !nr ){
362 else if ( nr == 1 && !ng ){
369 assert ( ng == 2 || nr == 2 );
372 ux = p1->
c[0] - ppt->
c[0];
373 uy = p1->
c[1] - ppt->
c[1];
374 uz = p1->
c[2] - ppt->
c[2];
375 vx = p2->
c[0] - ppt->
c[0];
376 vy = p2->
c[1] - ppt->
c[1];
377 vz = p2->
c[2] - ppt->
c[2];
378 dd = (ux*ux + uy*uy + uz*uz) * (vx*vx + vy*vy + vz*vz);
381 if ( listref[1] != listref[2] ) {
388 dd = (ux*vx + uy*vy + uz*vz) / sqrt(dd);
399 fprintf(stdout,
" %" MMG5_PRId
" corners, %" MMG5_PRId
" singular points and %" MMG5_PRId
" non manifold points detected\n",nc,nre,nm);
417 MMG5_int k,kk,nn,pleft,pright;
424 for (k=1; k<=
mesh->
np; ++k) {
431 for ( k=1; k<=
mesh->
np; ++k ) {
436 for ( k=1; k<=
mesh->
nt; ++k ) {
439 for (i=0; i<3; i++) {
441 if ( pt->
edg[i] != ref )
continue;
450 for (k=1; k<=
mesh->
nt; k++) {
452 if ( !
MG_EOK(pt) )
continue;
454 for (i=0; i<3; i++) {
465 fprintf(stderr,
"\n ## Error: %s: Impossible to"
466 " calculate normal vector at vertex %" MMG5_PRId
".\n",
487 fprintf(stderr,
"\n ## Error: %s: Impossible to"
488 " calculate normal vector at vertex %" MMG5_PRId
".\n",
505 fprintf(stdout,
" %" MMG5_PRId
" calculated normal vectors\n",nn);
522 double *
tmp,dd,ps,lm1,lm2,nx,ny,ux,uy,nxt,nyt,res,res0,n[2];
523 MMG5_int k,iel,ip1,ip2,nn,list[
MMG5_LMAX];
538 for (k=1; k<=
mesh->
nt; k++) {
540 if ( !
MG_EOK(pt) )
continue;
542 for (i=0; i<3; i++) {
550 for (k=1; k<=
mesh->
np; k++) {
552 if ( !
MG_VOK(ppt) )
continue;
560 if ( pt->
v[1] == k ) i = 1;
561 if ( pt->
v[2] == k ) i = 2;
566 fprintf(stderr,
"\n ## Error: %s: Abort.\n",__func__);
576 ux = p1->
c[0] - ppt->
c[0];
577 uy = p1->
c[1] - ppt->
c[1];
587 ps = nxt*ppt->
n[0] + nyt*ppt->
n[1];
604 ux = p2->
c[0] - ppt->
c[0];
605 uy = p2->
c[1] - ppt->
c[1];
615 ps = nxt*ppt->
n[0] + nyt*ppt->
n[1];
639 tmp[2*(k-1)+1] = ppt->
n[0] + lm1 * (nx - ppt->
n[0]);
640 tmp[2*(k-1)+2] = ppt->
n[1] + lm1 * (ny - ppt->
n[1]);
645 for (k=1; k<=
mesh->
np; k++) {
648 if ( !
MG_VOK(ppt) )
continue;
656 if ( pt->
v[1] == k ) i = 1;
657 if ( pt->
v[2] == k ) i = 2;
661 fprintf(stderr,
"\n ## Error: %s: Abort.\n",__func__);
671 ux = p1->
c[0] - ppt->
c[0];
672 uy = p1->
c[1] - ppt->
c[1];
682 ps = nxt*ppt->
n[0] + nyt*ppt->
n[1];
693 nx +=
tmp[2*(ip1-1)+1];
694 ny +=
tmp[2*(ip1-1)+2];
699 ux = p2->
c[0] - ppt->
c[0];
700 uy = p2->
c[1] - ppt->
c[1];
710 ps = nxt*ppt->
n[0] + nyt*ppt->
n[1];
721 nx +=
tmp[2*(ip2-1)+1];
722 ny +=
tmp[2*(ip2-1)+2];
734 n[0] =
tmp[2*(k-1)+1] - lm2 * (nx -
tmp[2*(k-1)+1]);
735 n[1] =
tmp[2*(k-1)+2] - lm2 * (ny -
tmp[2*(k-1)+2]);
736 res += (n[0]-ppt->
n[0])*(n[0]-ppt->
n[0]) + (n[1]-ppt->
n[1])*(n[1]-ppt->
n[1]);
743 for (k=1; k<=
mesh->
np; k++) {
745 if ( !
MG_VOK(ppt) )
continue;
749 dd = ppt->
n[0]*ppt->
n[0] + ppt->
n[1]*ppt->
n[1];
757 if ( it == 0 ) res0 = res;
758 if ( res0 >
MMG5_EPSD ) res = res / res0;
761 fprintf(stdout,
" iter %5d res %.3E",it,res);
765 while ( ++it < maxit && res >
MMG5_EPS );
769 fprintf(stdout,
" %" MMG5_PRId
" normals regularized: %.3e\n",nn,res);
790 double p[2],co[3][2],vol,to,tp,t;
791 int it,maxit,pos,i,j;
802 for ( i=0 ; i<3 ; i++ ) {
803 for ( j=0 ; j<2 ; j++ ) {
813 if ( pt->
v[1] == k ) i = 1;
814 if ( pt->
v[2] == k ) i = 2;
817 co[i][0] = ppt->
c[0] + t*(p[0] - ppt->
c[0]);
818 co[i][1] = ppt->
c[1] + t*(p[1] - ppt->
c[1]);
834 while ( ++it < maxit );
856 double *
tmp,lm1,lm2,cx,cy,res,res0,c[2],co[3][2],vol;
857 MMG5_int k,kt,iel,ip1,ip2,nn,list[
MMG5_LMAX];
858 int it,maxit,j,ilist,noupdate;
872 for (k=1; k<=
mesh->
nt; k++) {
874 if ( !
MG_EOK(pt) )
continue;
876 for (i=0; i<3; i++) {
884 for (k=1; k<=
mesh->
np; k++) {
886 tmp[2*(k-1)+1] = ppt->
c[0];
887 tmp[2*(k-1)+2] = ppt->
c[1];
889 if ( !
MG_VOK(ppt) )
continue;
897 if ( pt->
v[1] == k ) i = 1;
898 if ( pt->
v[2] == k ) i = 2;
903 fprintf(stderr,
"\n ## Error: %s: Abort.\n",__func__);
920 tmp[2*(k-1)+1] = ppt->
c[0] + lm1 * (cx - ppt->
c[0]);
921 tmp[2*(k-1)+2] = ppt->
c[1] + lm1 * (cy - ppt->
c[1]);
926 for (k=1; k<=
mesh->
np; k++) {
929 if ( !
MG_VOK(ppt) )
continue;
937 if ( pt->
v[1] == k ) i = 1;
938 if ( pt->
v[2] == k ) i = 2;
943 fprintf(stderr,
"\n ## Error: %s: Abort.\n",__func__);
948 cx +=
tmp[2*(ip1-1)+1];
949 cy +=
tmp[2*(ip1-1)+2];
951 cx +=
tmp[2*(ip2-1)+1];
952 cy +=
tmp[2*(ip2-1)+2];
957 c[0] =
tmp[2*(k-1)+1] - lm2 * (cx -
tmp[2*(k-1)+1]);
958 c[1] =
tmp[2*(k-1)+2] - lm2 * (cy -
tmp[2*(k-1)+2]);
963 for (kt=0; kt<ilist;kt++) {
965 if ( !
MG_EOK(pt) )
continue;
967 for ( i=0 ; i<3 ; i++ ) {
968 for ( j=0 ; j<2 ; j++ ) {
974 if ( pt->
v[1] == k ) i = 1;
975 if ( pt->
v[2] == k ) i = 2;
977 for ( j=0 ; j<2 ; j++ ) {
989 res += (c[0]-ppt->
c[0])*(c[0]-ppt->
c[0]) + (c[1]-ppt->
c[1])*(c[1]-ppt->
c[1]);
996 if ( it == 0 ) res0 = res;
997 if ( res0 >
MMG5_EPSD ) res = res / res0;
1000 fprintf(stdout,
" iter %5d res %.3E",it,res);
1004 while ( ++it < maxit && res >
MMG5_EPS );
1007 fprintf(stdout,
" %" MMG5_PRId
" coordinates regularized: %.3e\n",nn,res);
1019 fprintf(stderr,
"\n ## Problem in setting boundary. Exit program.\n");
1025 fprintf(stderr,
"\n ## Hashing problem. Exit program.\n");
1031 fprintf(stderr,
"\n ## Quadrilaterals hashing problem. Exit program.\n");
1046 fprintf(stderr,
"\n ## Problem in function setadj. Exit program.\n");
1052 fprintf(stderr,
"\n ## Problem in identifying singularities. Exit program.\n");
1058 fprintf(stderr,
"\n ## Problem in regularizing vertices coordinates. Exit program.\n");
1064 fprintf(stderr,
"\n ## Problem in calculating normal vectors. Exit program.\n");
1070 fprintf(stderr,
"\n ## Problem in regularizing normal vectors. Exit program.\n");
int MMG2D_singul(MMG5_pMesh mesh, MMG5_int ref)
int MMG2D_regver(MMG5_pMesh mesh)
int MMG2D_regnor(MMG5_pMesh mesh)
int MMG2D_analys(MMG5_pMesh mesh)
int MMG2D_setadj(MMG5_pMesh mesh, int8_t init_cc)
static int MMG2D_dichotomy(MMG5_pMesh mesh, MMG5_pTria pt, MMG5_int k, double *c)
int MMG2D_norver(MMG5_pMesh mesh, MMG5_int ref)
int MMG5_bouler(MMG5_pMesh mesh, MMG5_int *adjt, MMG5_int start, int ip, MMG5_int *list, MMG5_int *listref, int *ng, int *nr, int lmax)
int MMG2D_bouleendp(MMG5_pMesh mesh, MMG5_int start, int8_t ip, MMG5_int *ip1, MMG5_int *ip2, MMG5_int *list)
int MMG2D_boulen(MMG5_pMesh mesh, MMG5_int start, int8_t ip, MMG5_int *pleft, MMG5_int *pright, double *nn)
int MMG2D_hashQuad(MMG5_pMesh mesh)
int MMG2D_assignEdge(MMG5_pMesh mesh)
int MMG2D_hashTria(MMG5_pMesh mesh)
MMG5_int MMG2D_indPt(MMG5_pMesh mesh, MMG5_int kp)
static const uint8_t MMG2D_idir_q[4][2]
idir[i]: vertices of edge i for a quad
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
double MMG2D_quickarea(double a[2], double b[2], double c[2])
static const uint8_t MMG5_iprv2[3]
static const uint8_t MMG5_inxt2[6]
#define MMG5_SAFE_MALLOC(ptr, size, type, law)
#define MMG5_SAFE_FREE(ptr)
#define MMG5_DEL_MEM(mesh, ptr)
Structure to store vertices of an MMG mesh.
Structure to store quadrangles of an MMG mesh.
Structure to store triangles of a MMG mesh.