53 MMG5_int *pile,*adja,ipil,k,kk,ncc,ip1,ip2,nr,nref;
58 fprintf(stdout,
" ** SETTING TOPOLOGY\n");
65 for ( k=1; k<=
mesh->
nt; ++k ) {
84 if ( !
MG_EOK(pt) )
continue;
101 pt->
tag[i] &= ~MG_REF;
102 pt->
tag[i] &= ~MG_BDY;
103 pt->
tag[i] &= ~MG_GEO;
105 pt1->
tag[ii] &= ~MG_REF;
106 pt1->
tag[ii] &= ~MG_BDY;
107 pt1->
tag[ii] &= ~MG_GEO;
109 pt1->
tag[ii] |= pt->
tag[i];
110 pt->
tag[i] |= pt1->
tag[ii];
114 pt1->
tag[ii] |= pt->
tag[i];
115 pt->
tag[i] |= pt1->
tag[ii];
161 || MMG5_abs(pt1->
ref) != MMG5_abs(pt->
ref) ) {
191 if ( kk > k ) nref++;
195 if ( pt1->
cc > 0 )
continue;
204 for (kk=1; kk<=
mesh->
nt; kk++) {
206 if ( pt->
v[0] && (pt->
cc == 0) ) {
221 if ( !
MG_EOK(pq) )
continue;
224 for (i=0; i<4; i++) {
242 assert ( pt->
edg[ii] == pq->
edg[i] );
259 fprintf(stdout,
" Connected component or subdomains: %" MMG5_PRId
" \n",ncc);
260 fprintf(stdout,
" Tagged edges: %" MMG5_PRId
", ridges: %" MMG5_PRId
", refs: %" MMG5_PRId
"\n",nr+nref,nr,nref);
279 double ux,uy,uz,vx,vy,vz,dd;
288 for (k=1; k<=
mesh->
np; ++k) {
295 for ( k=1; k<=
mesh->
np; ++k ) {
300 for ( k=1; k<=
mesh->
nt; ++k ) {
303 for (i=0; i<3; i++) {
305 if ( pt->
edg[i] != ref )
continue;
314 for (k=1; k<=
mesh->
nt; k++) {
316 if ( !
MG_EOK(pt) )
continue;
318 for (i=0; i<3; i++) {
321 if ( ppt->
s )
continue;
347 else if ( (ng == 1) && (nr == 1) ) {
352 else if ( ng == 1 && !nr ){
358 else if ( nr == 1 && !ng ){
365 assert ( ng == 2 || nr == 2 );
368 ux = p1->
c[0] - ppt->
c[0];
369 uy = p1->
c[1] - ppt->
c[1];
370 uz = p1->
c[2] - ppt->
c[2];
371 vx = p2->
c[0] - ppt->
c[0];
372 vy = p2->
c[1] - ppt->
c[1];
373 vz = p2->
c[2] - ppt->
c[2];
374 dd = (ux*ux + uy*uy + uz*uz) * (vx*vx + vy*vy + vz*vz);
377 if ( listref[1] != listref[2] ) {
384 dd = (ux*vx + uy*vy + uz*vz) / sqrt(dd);
395 fprintf(stdout,
" %" MMG5_PRId
" corners, %" MMG5_PRId
" singular points and %" MMG5_PRId
" non manifold points detected\n",nc,nre,nm);
413 MMG5_int k,kk,nn,pleft,pright;
420 for (k=1; k<=
mesh->
np; ++k) {
427 for ( k=1; k<=
mesh->
np; ++k ) {
432 for ( k=1; k<=
mesh->
nt; ++k ) {
435 for (i=0; i<3; i++) {
437 if ( pt->
edg[i] != ref )
continue;
446 for (k=1; k<=
mesh->
nt; k++) {
448 if ( !
MG_EOK(pt) )
continue;
450 for (i=0; i<3; i++) {
461 fprintf(stderr,
"\n ## Error: %s: Impossible to"
462 " calculate normal vector at vertex %" MMG5_PRId
".\n",
483 fprintf(stderr,
"\n ## Error: %s: Impossible to"
484 " calculate normal vector at vertex %" MMG5_PRId
".\n",
501 fprintf(stdout,
" %" MMG5_PRId
" calculated normal vectors\n",nn);
518 double *
tmp,dd,ps,lm1,lm2,nx,ny,ux,uy,nxt,nyt,res,res0,n[2];
519 MMG5_int k,iel,ip1,ip2,nn,list[
MMG5_LMAX];
534 for (k=1; k<=
mesh->
nt; k++) {
536 if ( !
MG_EOK(pt) )
continue;
538 for (i=0; i<3; i++) {
546 for (k=1; k<=
mesh->
np; k++) {
548 if ( !
MG_VOK(ppt) )
continue;
556 if ( pt->
v[1] == k ) i = 1;
557 if ( pt->
v[2] == k ) i = 2;
562 fprintf(stderr,
"\n ## Error: %s: Abort.\n",__func__);
572 ux = p1->
c[0] - ppt->
c[0];
573 uy = p1->
c[1] - ppt->
c[1];
583 ps = nxt*ppt->
n[0] + nyt*ppt->
n[1];
600 ux = p2->
c[0] - ppt->
c[0];
601 uy = p2->
c[1] - ppt->
c[1];
611 ps = nxt*ppt->
n[0] + nyt*ppt->
n[1];
635 tmp[2*(k-1)+1] = ppt->
n[0] + lm1 * (nx - ppt->
n[0]);
636 tmp[2*(k-1)+2] = ppt->
n[1] + lm1 * (ny - ppt->
n[1]);
641 for (k=1; k<=
mesh->
np; k++) {
644 if ( !
MG_VOK(ppt) )
continue;
652 if ( pt->
v[1] == k ) i = 1;
653 if ( pt->
v[2] == k ) i = 2;
657 fprintf(stderr,
"\n ## Error: %s: Abort.\n",__func__);
667 ux = p1->
c[0] - ppt->
c[0];
668 uy = p1->
c[1] - ppt->
c[1];
678 ps = nxt*ppt->
n[0] + nyt*ppt->
n[1];
689 nx +=
tmp[2*(ip1-1)+1];
690 ny +=
tmp[2*(ip1-1)+2];
695 ux = p2->
c[0] - ppt->
c[0];
696 uy = p2->
c[1] - ppt->
c[1];
706 ps = nxt*ppt->
n[0] + nyt*ppt->
n[1];
717 nx +=
tmp[2*(ip2-1)+1];
718 ny +=
tmp[2*(ip2-1)+2];
730 n[0] =
tmp[2*(k-1)+1] - lm2 * (nx -
tmp[2*(k-1)+1]);
731 n[1] =
tmp[2*(k-1)+2] - lm2 * (ny -
tmp[2*(k-1)+2]);
732 res += (n[0]-ppt->
n[0])*(n[0]-ppt->
n[0]) + (n[1]-ppt->
n[1])*(n[1]-ppt->
n[1]);
739 for (k=1; k<=
mesh->
np; k++) {
741 if ( !
MG_VOK(ppt) )
continue;
745 dd = ppt->
n[0]*ppt->
n[0] + ppt->
n[1]*ppt->
n[1];
753 if ( it == 0 ) res0 = res;
754 if ( res0 >
MMG5_EPSD ) res = res / res0;
757 fprintf(stdout,
" iter %5d res %.3E",it,res);
761 while ( ++it < maxit && res >
MMG5_EPS );
765 fprintf(stdout,
" %" MMG5_PRId
" normals regularized: %.3e\n",nn,res);
786 double p[2],co[3][2],vol,to,tp,t;
787 int it,maxit,pos,i,j;
798 for ( i=0 ; i<3 ; i++ ) {
799 for ( j=0 ; j<2 ; j++ ) {
809 if ( pt->
v[1] == k ) i = 1;
810 if ( pt->
v[2] == k ) i = 2;
813 co[i][0] = ppt->
c[0] + t*(p[0] - ppt->
c[0]);
814 co[i][1] = ppt->
c[1] + t*(p[1] - ppt->
c[1]);
830 while ( ++it < maxit );
852 double *
tmp,lm1,lm2,cx,cy,res,res0,c[2],co[3][2],vol;
853 MMG5_int k,kt,iel,ip1,ip2,nn,list[
MMG5_LMAX];
854 int it,maxit,j,ilist,noupdate;
868 for (k=1; k<=
mesh->
nt; k++) {
870 if ( !
MG_EOK(pt) )
continue;
872 for (i=0; i<3; i++) {
880 for (k=1; k<=
mesh->
np; k++) {
882 tmp[2*(k-1)+1] = ppt->
c[0];
883 tmp[2*(k-1)+2] = ppt->
c[1];
885 if ( !
MG_VOK(ppt) )
continue;
893 if ( pt->
v[1] == k ) i = 1;
894 if ( pt->
v[2] == k ) i = 2;
899 fprintf(stderr,
"\n ## Error: %s: Abort.\n",__func__);
916 tmp[2*(k-1)+1] = ppt->
c[0] + lm1 * (cx - ppt->
c[0]);
917 tmp[2*(k-1)+2] = ppt->
c[1] + lm1 * (cy - ppt->
c[1]);
922 for (k=1; k<=
mesh->
np; k++) {
925 if ( !
MG_VOK(ppt) )
continue;
933 if ( pt->
v[1] == k ) i = 1;
934 if ( pt->
v[2] == k ) i = 2;
939 fprintf(stderr,
"\n ## Error: %s: Abort.\n",__func__);
944 cx +=
tmp[2*(ip1-1)+1];
945 cy +=
tmp[2*(ip1-1)+2];
947 cx +=
tmp[2*(ip2-1)+1];
948 cy +=
tmp[2*(ip2-1)+2];
953 c[0] =
tmp[2*(k-1)+1] - lm2 * (cx -
tmp[2*(k-1)+1]);
954 c[1] =
tmp[2*(k-1)+2] - lm2 * (cy -
tmp[2*(k-1)+2]);
959 for (kt=0; kt<ilist;kt++) {
961 if ( !
MG_EOK(pt) )
continue;
963 for ( i=0 ; i<3 ; i++ ) {
964 for ( j=0 ; j<2 ; j++ ) {
970 if ( pt->
v[1] == k ) i = 1;
971 if ( pt->
v[2] == k ) i = 2;
973 for ( j=0 ; j<2 ; j++ ) {
985 res += (c[0]-ppt->
c[0])*(c[0]-ppt->
c[0]) + (c[1]-ppt->
c[1])*(c[1]-ppt->
c[1]);
992 if ( it == 0 ) res0 = res;
993 if ( res0 >
MMG5_EPSD ) res = res / res0;
996 fprintf(stdout,
" iter %5d res %.3E",it,res);
1000 while ( ++it < maxit && res >
MMG5_EPS );
1003 fprintf(stdout,
" %" MMG5_PRId
" coordinates regularized: %.3e\n",nn,res);
1015 fprintf(stderr,
"\n ## Problem in setting boundary. Exit program.\n");
1021 fprintf(stderr,
"\n ## Hashing problem. Exit program.\n");
1027 fprintf(stderr,
"\n ## Quadrilaterals hashing problem. Exit program.\n");
1042 fprintf(stderr,
"\n ## Problem in function setadj. Exit program.\n");
1048 fprintf(stderr,
"\n ## Problem in identifying singularities. Exit program.\n");
1054 fprintf(stderr,
"\n ## Problem in regularizing vertices coordinates. Exit program.\n");
1060 fprintf(stderr,
"\n ## Problem in calculating normal vectors. Exit program.\n");
1066 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 points of a MMG mesh.