41 double calold,calnew,area,det,alpha,ps,ps1,ps2,step,sqdetm1,sqdetm2;
42 double gr[2],grp[2],*m0,*m1,*m2;
43 MMG5_int k,iel,ip0,ip1,ip2;
45 static int8_t mmgWarn0=0;
50 calold = calnew = DBL_MAX;
58 for (k=0; k<ilist; k++) {
63 calold =
MG_MIN(MMG2D_caltri(
mesh,met,pt),calold);
77 area = (p1->
c[0]-p0->
c[0])*(p2->
c[1]-p0->
c[1]) - (p1->
c[1]-p0->
c[1])*(p2->
c[0]-p0->
c[0]);
78 area = 0.5*fabs(area);
84 sqdetm1 = sqrt(m1[0]*m1[2]-m1[1]*m1[1]);
85 sqdetm2 = sqrt(m2[0]*m2[2]-m2[1]*m2[1]);
87 gr[0] +=
MMG5_ATHIRD*area*((p1->
c[0]-p0->
c[0])*sqdetm1 + (p2->
c[0]-p0->
c[0])*sqdetm2);
88 gr[1] +=
MMG5_ATHIRD*area*((p1->
c[1]-p0->
c[1])*sqdetm1 + (p2->
c[1]-p0->
c[1])*sqdetm2);
92 assert(m0 && (m0+1) && (m0+2));
93 det = m0[0]*m0[2]-m0[1]*m0[1];
98 grp[0] = det*(m0[2]*gr[0]-m0[1]*gr[1]);
99 grp[1] = det*(-m0[1]*gr[0]+m0[0]*gr[1]);
103 for (k=0; k<ilist; k++) {
119 ps1 = (p1->
c[0]-p0->
c[0])*grp[1] - (p1->
c[1]-p0->
c[1])*grp[0];
120 ps2 = grp[0]*(p2->
c[1]-p0->
c[1]) - grp[1]*(p2->
c[0]-p0->
c[0]);
122 if ( ps1 >= 0.0 && ps2 >= 0.0 )
break;
128 fprintf(stderr,
"\n ## Error: %s: impossible to locate at least"
129 " 1 gradient - abort.\n",__func__);
136 det = (p1->
c[0]-p0->
c[0])*(p2->
c[1]-p0->
c[1]) - (p1->
c[1]-p0->
c[1])*(p2->
c[0]-p0->
c[0]);
141 ppt0->
c[0] = p0->
c[0] + alpha*step*grp[0];
142 ppt0->
c[1] = p0->
c[1] + alpha*step*grp[1];
147 for (k=0; k<ilist; k++) {
154 calnew =
MG_MIN(MMG2D_caltri(
mesh,met,pt0),calnew);
157 if (calold <
MMG2D_NULKAL && calnew <= calold)
return 0;
159 else if ( improve && calnew < 1.02 * calold )
return 0;
160 else if ( calnew < 0.3 * calold )
return 0;
164 p0->
c[0] = ppt0->
c[0];
165 p0->
c[1] = ppt0->
c[1];
int MMG2D_movintpt_ani(MMG5_pMesh mesh, MMG5_pSol met, int ilist, MMG5_int *list, int8_t improve)
static const uint8_t MMG5_iprv2[3]
static const uint8_t MMG5_inxt2[6]
Structure to store vertices of an MMG mesh.
Structure to store triangles of a MMG mesh.