58 MMG5_int it1,MMG5_int it2,int8_t typchk) {
64 double b0[3],b1[3],n[3],v[3],c[3],ux,uy,uz,ps,disnat,dischg;
65 double cal1,cal2,calnat,calchg,calold,calnew,caltmp,hausd;
66 MMG5_int iel,iel1,iel2,np,nq,na1,na2,k,nminus,nplus,
info,refm;
68 int8_t ifa1,ifa2,ia,ip,iq,ia1,ia2,j,isshell,
ier;
83 assert ( pt->
xt &&
"Boundary edges have to be swapped from a boundary face" );
96 for (k=0; k<ilist; k++) {
99 if ( pt->
ref == refm ) {
106 if ( nplus == 1 || nminus == 1 )
return 0;
114 assert( 0<=ifa1 && ifa1<4 &&
"unexpected local face idx");
115 assert( 0<=ifa2 && ifa2<4 &&
"unexpected local face idx");
119 for (ia1=0; ia1<3; ia1++) {
120 if ( (tt1.
v[ia1] != np) && (tt1.
v[ia1] != nq) )
break;
123 if ( ia1==3 )
return 0;
129 for (ia2=0; ia2<3; ia2++) {
130 if ( (tt2.
v[ia2] != np) && (tt2.
v[ia2] != nq) )
break;
134 if ( ia2 ==3 )
return 0;
143 ps = b0[0]*b1[0] + b0[1]*b1[1] + b0[2]*b1[2];
154 if (
ier < 0 )
return -1;
155 else if ( !
ier )
return 0;
156 ps = b0[0]*n[0] + b0[1]*n[1] + b0[2]*n[2];
158 if ( ps < mesh->
info.
dhd )
return 0;
163 if (
ier<0 )
return -1;
164 else if ( !
ier )
return 0;
165 ps = b0[0]*n[0] + b0[1]*n[1] + b0[2]*n[2];
167 if ( ps < mesh->
info.
dhd )
return 0;
172 if (
ier<0 )
return -1;
173 else if ( !
ier )
return 0;
174 ps = b1[0]*n[0] + b1[1]*n[1] + b1[2]*n[2];
176 if ( ps < mesh->
info.
dhd )
return 0;
181 if (
ier<0 )
return -1;
182 else if ( !
ier )
return 0;
183 ps = b1[0]*n[0] + b1[1]*n[1] + b1[2]*n[2];
185 if ( ps < mesh->
info.
dhd )
return 0;
200 if ( tt1.
ref == tt2.
ref ) {
218 if ( tt1.
ref!=par->
ref && tt2.
ref !=par->
ref )
continue;
229 if ( tt1.
ref!=par->
ref && tt2.
ref !=par->
ref )
continue;
247 for ( k=0; k<ilist; ++k ) {
249 if ( par->
ref != pt->
ref )
continue;
260 for ( k=0; k<ilist; ++k ) {
262 if ( par->
ref != pt->
ref )
continue;
270 ux = p1->
c[0] - p0->
c[0];
271 uy = p1->
c[1] - p0->
c[1];
272 uz = p1->
c[2] - p0->
c[2];
279 disnat = c[0]*c[0] + c[1]*c[1] + c[2]*c[2];
285 disnat =
MG_MAX(disnat, c[0]*c[0] + c[1]*c[1] + c[2]*c[2]);
289 disnat =
MG_MAX(disnat,hausd * hausd);
293 ux = p1->
c[0] - p0->
c[0];
294 uy = p1->
c[1] - p0->
c[1];
295 uz = p1->
c[2] - p0->
c[2];
304 dischg = c[0]*c[0] + c[1]*c[1] + c[2]*c[2];
310 dischg =
MG_MAX(dischg,c[0]*c[0] + c[1]*c[1] + c[2]*c[2]);
311 dischg =
MG_MAX(dischg,hausd * hausd);
313 if ( dischg > disnat )
return 0;
315 if ( typchk==1 && met->
size > 1 && met->
m ) {
320 cal1 = MMG5_caltri(
mesh,met,&tt1);
321 cal2 = MMG5_caltri(
mesh,met,&tt2);
324 calnat =
MG_MIN(cal1,cal2);
325 for (j=0; j<3; j++) {
326 if ( tt1.
v[j] == nq ) tt1.
v[j] = na2;
327 if ( tt2.
v[j] == np ) tt2.
v[j] = na1;
330 if ( typchk==1 && met->
size > 1 && met->
m ) {
335 cal1 = MMG5_caltri(
mesh,met,&tt1);
336 cal2 = MMG5_caltri(
mesh,met,&tt2);
339 calchg =
MG_MIN(cal1,cal2);
340 if ( calchg < 1.01 * calnat )
return 0;
345 ppt0->
c[0] = 0.5*(p0->
c[0] + p1->
c[0]);
346 ppt0->
c[1] = 0.5*(p0->
c[1] + p1->
c[1]);
347 ppt0->
c[2] = 0.5*(p0->
c[2] + p1->
c[2]);
354 fprintf(stderr,
"\n ## Warning: %s: 0. unable to get edge info"
358 assert ( (tag &
MG_BDY) &&
"Edge should be boundary but is not");
363 assert ( pt->
xt &&
"Boundary edge interpolated from non-boundary face");
369 if ( typchk == 1 && (met->
size>1) ) {
374 if ( MMG5_intmet(
mesh,met,list[0]/6,list[0]%6,0,0.5) <= 0 )
380 calold = calnew = DBL_MAX;
381 for (k=0; k<ilist; k++) {
386 assert ( isfinite(calold) );
388 ia1 = ia2 = ip = iq = -1;
389 for (j=0; j< 4; j++) {
390 if (pt->
v[j] == np) ip = j;
391 else if (pt->
v[j] == nq) iq = j;
392 else if ( ia1 < 0 ) ia1 = j;
395 assert((ip >= 0) && (iq >= 0) && (ia1 >= 0) && (ia2 >= 0));
396 isshell = (pt->
v[ia1] == na1 || pt->
v[ia2] == na1);
401 if ( typchk==1 && met->
size > 1 && met->
m )
411 MMG5_int adj =
mesh->
adja[4*(iel-1)+1+ip];
424 if ( typchk==1 && met->
size > 1 && met->
m )
429 calnew =
MG_MIN(calnew,caltmp);
434 if ( typchk==1 && met->
size > 1 && met->
m )
443 MMG5_int adj =
mesh->
adja[4*(iel-1)+1+iq];
456 if ( typchk==1 && met->
size > 1 && met->
m )
463 calnew =
MG_MIN(calnew,caltmp);
466 if ( calold <
MMG5_EPSOK && calnew <= calold )
return 0;
468 else if ( calnew < 0.3 * calold )
return 0;
494 MMG5_int iel,np,nq,nm,src,iel1;
496 int8_t ia,iface1,j,ipa,im;
523 if ( (pt1->
v[ipa] != np)&&(pt1->
v[ipa] != nq) ) {
533 c[0] = 0.5*( p0->
c[0] + p1->
c[0]);
534 c[1] = 0.5*( p0->
c[1] + p1->
c[1]);
535 c[2] = 0.5*( p0->
c[2] + p1->
c[2]);
544 fprintf(stderr,
"\n ## Error: %s: unable to allocate a"
545 " new point\n",__func__);
552 if ( typchk == 1 && (met->
size>1) ) {
556 if ( MMG5_intmet(
mesh,met,iel,ia,nm,0.5)<=0 )
return 0;
565 fprintf(stderr,
"\n ## Warning: %s: unable to swap boundary edge.\n",
575 memset(list,0,(
MMG3D_LMAX+2)*
sizeof(MMG5_int));
576 for (j=0; j<3; j++) {
578 if ( pt1->
v[im] == nm )
break;
580 if ( pt1->
v[im] != nm ){
582 fprintf(stderr,
"\n # Warning: %s: pt1->v[im] != nm.\n",__func__);
587 assert(list[0]/4 == iel1);
588 assert(pt1->
v[ipa] == na);
592 fprintf(stderr,
"\n ## Warning: %s: unable to swap boundary edge.\n",
602 assert (
ier &&
"Unable to collapse the point created during the boundary swap");
626 int ifac,
int conf0,MMG5_int adj,
int conf1) {
630 MMG5_int xt1,k1,*adja,iel,np;
631 MMG5_int adj0_2,adj0_3,adj1_1,adj1_2,adj1_3;
633 uint8_t tau0[4],tau1[4];
634 const uint8_t *taued0,*taued1;
639 assert ( ifac>=0 && adj>0 );
665 tau0[0] = 1; tau0[1] = 0; tau0[2] = 3; tau0[3] = 2;
669 tau0[0] = 2; tau0[1] = 0; tau0[2] = 1; tau0[3] = 3;
673 tau0[0] = 3; tau0[1] = 0; tau0[2] = 2; tau0[3] = 1;
679 tau0[0] = 0; tau0[1] = 1; tau0[2] = 2; tau0[3] = 3;
687 assert(pt0->
ref == pt1->
ref);
691 tau1[0] = 0; tau1[1] = 2; tau1[2] = 3; tau1[3] = 1;
695 tau1[0] = 0; tau1[1] = 3; tau1[2] = 1; tau1[3] = 2;
699 tau1[0] = 1; tau1[1] = 0; tau1[2] = 3; tau1[3] = 2;
703 tau1[0] = 1; tau1[1] = 3; tau1[2] = 2; tau1[3] = 0;
707 tau1[0] = 1; tau1[1] = 2; tau1[2] = 0; tau1[3] = 3;
711 tau1[0] = 2; tau1[1] = 0; tau1[2] = 1; tau1[3] = 3;
715 tau1[0] = 2; tau1[1] = 1; tau1[2] = 3; tau1[3] = 0;
719 tau1[0] = 2; tau1[1] = 3; tau1[2] = 0; tau1[3] = 1;
723 tau1[0] = 3; tau1[1] = 0; tau1[2] = 2; tau1[3] = 1;
727 tau1[0] = 3; tau1[1] = 2; tau1[2] = 1; tau1[3] = 0;
731 tau1[0] = 3; tau1[1] = 1; tau1[2] = 0; tau1[3] = 2;
736 tau1[0] = 0; tau1[1] = 1; tau1[2] = 2; tau1[3] = 3;
745 np = pt1->
v[tau1[0]];
747 MMG5_int ref[6] = {0};
748 uint16_t tag[6] = {0};
751 fprintf(stderr,
"\n ## Error: %s: %d. unable to get edge info.\n",__func__,i);
761 fprintf(stderr,
"\n ## Error: %s: unable to allocate"
762 " a new element.\n",__func__);
764 fprintf(stderr,
" Exit program.\n");
773 pt0->
v[tau0[1]] = np;
776 pt1->
v[tau0[2]] = np;
779 ptnew->
v[tau0[3]] = np;
789 adj0_2 = adja[tau0[2]];
790 adj0_3 = adja[tau0[3]];
793 adj1_1 = adja[tau1[1]];
794 adj1_2 = adja[tau1[2]];
795 adj1_3 = adja[tau1[3]];
799 adja[tau0[0]] = adj1_1;
800 adja[tau0[2]] = 4*k1 + tau0[1] ;
801 adja[tau0[3]] = 4*iel + tau0[1] ;
803 mesh->
adja[4*(adj1_1/4-1) + 1 + adj1_1%4] = 4*k + tau0[0];
806 adja[tau0[0]] = adj1_3;
807 adja[tau0[1]] = 4*k + tau0[2] ;
808 adja[tau0[2]] = adj0_2;
809 adja[tau0[3]] = 4*iel + tau0[2] ;
811 mesh->
adja[4*(adj1_3/4-1) + 1 + adj1_3%4] = 4*k1 + tau0[0];
813 mesh->
adja[4*(adj0_2/4-1) + 1 + adj0_2%4] = 4*k1 + tau0[2];
816 adja[tau0[0]] = adj1_2;
817 adja[tau0[1]] = 4*k + tau0[3] ;
818 adja[tau0[2]] = 4*k1 + tau0[3] ;
819 adja[tau0[3]] = adj0_3;
821 mesh->
adja[4*(adj1_2/4-1) + 1 + adj1_2%4] = 4*iel + tau0[0];
823 mesh->
adja[4*(adj0_3/4-1) + 1 + adj0_3%4] = 4*iel + tau0[3];
829 xt[0].
tag[taued0[0]] = 0;
830 xt[0].
tag[taued0[3]] = 0;
831 xt[0].
tag[taued0[4]] = 0;
833 xt[0].
edg[taued0[0]] = 0;
834 xt[0].
edg[taued0[3]] = 0;
835 xt[0].
edg[taued0[4]] = 0;
837 xt[0].
ref[ tau0[0]] = 0;
838 xt[0].
ref[ tau0[2]] = 0;
839 xt[0].
ref[ tau0[3]] = 0;
840 xt[0].
ftag[tau0[0]] = 0;
841 xt[0].
ftag[tau0[2]] = 0;
842 xt[0].
ftag[tau0[3]] = 0;
844 MG_SET(xt[0].ori, tau0[0]);
845 MG_SET(xt[0].ori, tau0[2]);
846 MG_SET(xt[0].ori, tau0[3]);
849 xt[1].
tag[taued0[1]] = 0;
850 xt[1].
tag[taued0[3]] = 0;
851 xt[1].
tag[taued0[5]] = 0;
853 xt[1].
edg[taued0[1]] = 0;
854 xt[1].
edg[taued0[3]] = 0;
855 xt[1].
edg[taued0[5]] = 0;
857 xt[1].
ref[ tau0[0]] = 0;
858 xt[1].
ref[ tau0[1]] = 0;
859 xt[1].
ref[ tau0[3]] = 0;
860 xt[1].
ftag[tau0[0]] = 0;
861 xt[1].
ftag[tau0[1]] = 0;
862 xt[1].
ftag[tau0[3]] = 0;
864 MG_SET(xt[1].ori, tau0[0]);
865 MG_SET(xt[1].ori, tau0[1]);
866 MG_SET(xt[1].ori, tau0[3]);
869 xt[1].
tag[taued0[2]] = 0;
870 xt[1].
tag[taued0[4]] = 0;
871 xt[1].
tag[taued0[5]] = 0;
873 xt[1].
edg[taued0[2]] = 0;
874 xt[1].
edg[taued0[4]] = 0;
875 xt[1].
edg[taued0[5]] = 0;
877 xt[1].
ref[ tau0[0]] = 0;
878 xt[1].
ref[ tau0[1]] = 0;
879 xt[1].
ref[ tau0[2]] = 0;
880 xt[1].
ftag[tau0[0]] = 0;
881 xt[1].
ftag[tau0[1]] = 0;
882 xt[1].
ftag[tau0[2]] = 0;
884 MG_SET(xt[1].ori, tau0[0]);
885 MG_SET(xt[1].ori, tau0[1]);
886 MG_SET(xt[1].ori, tau0[2]);
899 xt[0].
tag[taued0[0]] = 0;
901 xt[0].
tag[taued0[3]] = tag[2];
902 xt[0].
tag[taued0[4]] = tag[1];
905 xt[0].
tag[taued0[5]] = tag[5];
908 xt[0].
edg[taued0[0]] = 0;
909 xt[0].
edg[taued0[3]] = ref[2];
910 xt[0].
edg[taued0[4]] = ref[1];
911 xt[0].
edg[taued0[5]] = ref[5];
913 xt[0].
ref[ tau0[0]] = pxt1->
ref[tau1[1]];
914 xt[0].
ref[ tau0[2]] = 0;
915 xt[0].
ref[ tau0[3]] = 0;
916 xt[0].
ftag[tau0[0]] = pxt1->
ftag[tau1[1]];
917 xt[0].
ftag[tau0[2]] = 0;
918 xt[0].
ftag[tau0[3]] = 0;
921 MG_SET(xt[0].ori, tau0[2]);
922 MG_SET(xt[0].ori, tau0[3]);
925 xt[1].
tag[taued0[1]] = 0;
927 xt[1].
tag[taued0[3]] = tag[0];
928 xt[1].
tag[taued0[5]] = tag[1];
932 xt[1].
tag[taued0[4]] = tag[3];
934 xt[1].
edg[taued0[1]] = 0;
935 xt[1].
edg[taued0[3]] = ref[0];
936 xt[1].
edg[taued0[5]] = ref[1];
937 xt[1].
edg[taued0[4]] = ref[3];
939 xt[1].
ref[ tau0[0]] = pxt1->
ref[tau1[3]];
940 xt[1].
ref[ tau0[1]] = 0;
941 xt[1].
ref[ tau0[3]] = 0;
942 xt[1].
ftag[tau0[0]] = pxt1->
ftag[tau1[3]];
943 xt[1].
ftag[tau0[1]] = 0;
944 xt[1].
ftag[tau0[3]] = 0;
947 MG_SET(xt[1].ori, tau0[1]);
948 MG_SET(xt[1].ori, tau0[3]);
951 xt[2].
tag[taued0[2]] = 0;
953 xt[2].
tag[taued0[4]] = tag[0];
954 xt[2].
tag[taued0[5]] = tag[2];
958 xt[2].
tag[taued0[3]] = tag[4];
960 xt[2].
edg[taued0[2]] = 0;
961 xt[2].
edg[taued0[4]] = ref[0];
962 xt[2].
edg[taued0[5]] = ref[2];
963 xt[2].
edg[taued0[3]] = ref[4];
965 xt[2].
ref[ tau0[0]] = pxt1->
ref[tau1[2]];
966 xt[2].
ref[ tau0[1]] = 0;
967 xt[2].
ref[ tau0[2]] = 0;
968 xt[2].
ftag[tau0[0]] = pxt1->
ftag[tau1[2]];
969 xt[2].
ftag[tau0[1]] = 0;
970 xt[2].
ftag[tau0[2]] = 0;
973 MG_SET(xt[2].ori, tau0[1]);
974 MG_SET(xt[2].ori, tau0[2]);
978 isxt[0] = isxt[1] = isxt[2] = 0;
979 for (i=0; i<4; i++) {
980 if ( xt[0].ref[i] || xt[0].ftag[i] ) isxt[0] = 1;
981 if ( xt[1].ref[i] || xt[1].ftag[i] ) isxt[1] = 1;
982 if ( xt[2].ref[i] || xt[2].ftag[i] ) isxt[2] = 1;
985 assert ( (isxt[0] && isxt[1]) || (isxt[1] && isxt[2]) || (isxt[2] && isxt[0]) );
999 "larger xtetra table",
1001 fprintf(stderr,
" Exit program.\n");
1022 "larger xtetra table",
1024 fprintf(stderr,
" Exit program.\n");
1038 "larger xtetra table",
1040 fprintf(stderr,
" Exit program.\n");
1063 "larger xtetra table",
1065 fprintf(stderr,
" Exit program.\n");
1075 if ( (!metRidTyp) && met->
m && met->
size>1 )
1080 if ( (!metRidTyp) && met->
m && met->
size>1 )
1085 if ( (!metRidTyp) && met->
m && met->
size>1 )
int MMG5_BezierEdge(MMG5_pMesh mesh, MMG5_int ip0, MMG5_int ip1, double b0[3], double b1[3], int8_t ised, double v[3])
int MMG5_boulevolp(MMG5_pMesh mesh, MMG5_int start, int ip, int64_t *list)
Given a vertex and a tetrahedron, find all tetrahedra in the ball of this vertex.
int MMG3D_get_shellEdgeTag(MMG5_pMesh mesh, MMG5_int start, int8_t ia, uint16_t *tag, MMG5_int *ref)
MMG5_int MMG5_colver(MMG5_pMesh mesh, MMG5_pSol met, int64_t *list, int ilist, int8_t indq, int8_t typchk)
static double MMG5_orcal(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int iel)
int MMG3D_intmet33_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, int8_t i, MMG5_int ip, double s)
API headers and documentation for the mmg3d library, for volumetric meshes in 3D.
int MMG5_split1b(MMG5_pMesh, MMG5_pSol, int64_t *, int, MMG5_int, int, int8_t, int8_t)
MMG5_int MMG3D_newElt(MMG5_pMesh mesh)
int MMG3D_normalAdjaTri(MMG5_pMesh, MMG5_int, int8_t, int, double n[3])
void MMG3D_delPt(MMG5_pMesh mesh, MMG5_int ip)
static const uint8_t MMG5_permedge[12][6]
MMG5_int MMG3D_newPt(MMG5_pMesh mesh, double c[3], uint16_t tag, MMG5_int src)
double MMG5_caltet33_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTetra pt)
static const uint8_t MMG5_iare[6][2]
vertices of extremities of the edges of the tetra
#define MMG3D_POINT_REALLOC(mesh, sol, ip, wantedGap, law, o, tag, src)
void MMG5_tet2tri(MMG5_pMesh mesh, MMG5_int k, int8_t ie, MMG5_Tria *ptt)
int MMG5_norface(MMG5_pMesh mesh, MMG5_int k, int iface, double v[3])
#define MMG3D_TETRA_REALLOC(mesh, jel, wantedGap, law)
static const uint8_t MMG5_idir[4][3]
idir[i]: vertices of face opposite to vertex i
MMG5_int MMG3D_indElt(MMG5_pMesh mesh, MMG5_int kel)
#define MMG5_INCREASE_MEM_MESSAGE()
static const uint8_t MMG5_iprv2[3]
#define MG_EDG_OR_NOM(tag)
#define MMG5_TAB_RECALLOC(mesh, ptr, initSize, wantedGap, type, message, law)
#define MG_GEO_OR_NOM(tag)
#define MG_GET(flag, bit)
static const uint8_t MMG5_inxt2[6]
int MMG5_norpts(MMG5_pMesh, MMG5_int, MMG5_int, MMG5_int, double *)
double MMG5_caltri33_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria pt)
#define MG_SET(flag, bit)
Local parameters for a specific entity and reference.
Structure to store vertices of an MMG mesh.
Structure to store tetrahedra of an MMG mesh.
Structure to store triangles of a MMG mesh.
Structure to store additional information for the surface tetrahedra of an MMG mesh.
int MMG3D_swap23(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, int8_t metRidTyp, int ifac, int conf0, MMG5_int adj, int conf1)
int MMG5_swpbdy(MMG5_pMesh mesh, MMG5_pSol met, int64_t *list, int ret, MMG5_int it1, MMG3D_pPROctree PROctree, int8_t typchk)
int MMG5_chkswpbdy(MMG5_pMesh mesh, MMG5_pSol met, int64_t *list, int ilist, MMG5_int it1, MMG5_int it2, int8_t typchk)