48 met->
m[ip] = (1.0-s)*met->
m[ip1] + s*met->
m[ip2];
55 double det,imn[4],dd,den,sqDelta,trimn,lambda[2],vp[2][2],dm[2];
56 double dn[2],vnorm,d0,d1,ip[4];
57 static int8_t mmgWarn0=0,mmgWarn1=0;
60 det = m[0]*m[2] - m[1]*m[1];
64 fprintf(stderr,
"\n ## Error: %s: null metric det : %E \n",
71 imn[0] = det * ( m[2]*n[0] - m[1]*n[1]);
72 imn[1] = det * ( m[2]*n[1] - m[1]*n[2]);
73 imn[2] = det * (-m[1]*n[0] + m[0]*n[1]);
74 imn[3] = det * (-m[1]*n[1] + m[0]*n[2]);
76 sqDelta = sqrt(fabs(dd*dd + 4.0*imn[1]*imn[2]));
77 trimn = imn[0] + imn[3];
79 lambda[0] = 0.5 * (trimn - sqDelta);
80 if ( lambda[0] < 0.0 ) {
83 fprintf(stderr,
"\n ## Error: %s: at least 1 negative eigenvalue: %f \n",
111 dn[0] = lambda[0]*dm[0];
112 dn[1] = lambda[0]*dm[1];
116 den = (1.0-s)*(1.0-s)*dn[0] + s*s*dm[0] + 2.0*s*(1.0-s)*sqrt(dd);
119 if ( den <
MMG5_EPS ) d0 = (1.0-s)*dm[0] + s*dn[0];
123 den = (1.0-s)*(1.0-s)*dn[1] + s*s*dm[1] + 2.0*s*(1.0-s)*sqrt(dd);
125 if ( den <
MMG5_EPS ) d1 = (1.0-s)*dm[1] + s*dn[1];
129 mr[0] = d0*vp[0][0]*vp[0][0] + d1*vp[1][0]*vp[1][0];
130 mr[1] = d0*vp[0][0]*vp[0][1] + d1*vp[1][0]*vp[1][1];
131 mr[2] = d0*vp[0][1]*vp[0][1] + d1*vp[1][1]*vp[1][1];
139 lambda[1] = 0.5 * (trimn + sqDelta);
140 assert(lambda[1] >= 0.0);
143 vp[0][1] = (lambda[0] - imn[0]);
144 vnorm = sqrt(vp[0][0]*vp[0][0] + vp[0][1]*vp[0][1]);
147 vp[0][0] = (lambda[0] - imn[3]);
149 vnorm = sqrt(vp[0][0]*vp[0][0] + vp[0][1]*vp[0][1]);
157 vp[1][1] = (lambda[1] - imn[0]);
158 vnorm = sqrt(vp[1][0]*vp[1][0] + vp[1][1]*vp[1][1]);
161 vp[1][0] = (lambda[1] - imn[3]);
163 vnorm = sqrt(vp[1][0]*vp[1][0] + vp[1][1]*vp[1][1]);
171 dm[0] = m[0]*vp[0][0]*vp[0][0] + 2.0*m[1]*vp[0][0]*vp[0][1] + m[2]*vp[0][1]*vp[0][1];
172 dm[1] = m[0]*vp[1][0]*vp[1][0] + 2.0*m[1]*vp[1][0]*vp[1][1] + m[2]*vp[1][1]*vp[1][1];
173 dn[0] = n[0]*vp[0][0]*vp[0][0] + 2.0*n[1]*vp[0][0]*vp[0][1] + n[2]*vp[0][1]*vp[0][1];
174 dn[1] = n[0]*vp[1][0]*vp[1][0] + 2.0*n[1]*vp[1][0]*vp[1][1] + n[2]*vp[1][1]*vp[1][1];
178 den = (1.0-s)*(1.0-s)*dn[0] + s*s*dm[0] + 2.0*s*(1.0-s)*sqrt(dd);
180 if ( den <
MMG5_EPS ) d0 = (1.0-s)*dm[0] + s*dn[0];
184 den = (1.0-s)*(1.0-s)*dn[1] + s*s*dm[1] + 2.0*s*(1.0-s)*sqrt(dd);
186 if ( den <
MMG5_EPS ) d1 = (1.0-s)*dm[1] + s*dn[1];
190 det = vp[0][0]*vp[1][1] - vp[0][1]*vp[1][0];
191 if ( fabs(det) <
MMG5_EPS )
return 0;
194 ip[0] = vp[1][1]*det;
195 ip[1] = -vp[1][0]*det;
196 ip[2] = -vp[0][1]*det;
197 ip[3] = vp[0][0]*det;
199 mr[0] = d0*ip[0]*ip[0] + d1*ip[2]*ip[2];
200 mr[1] = d0*ip[0]*ip[1] + d1*ip[2]*ip[3];
201 mr[2] = d0*ip[1]*ip[1] + d1*ip[3]*ip[3];
217 static int8_t mmgWarn=0;
231 fprintf(stderr,
" ## Error: %s: at least 1 naive interpolation.\n",
234 mr[0] = (1.0-s)*m1[0] + s*m2[0];
235 mr[1] = (1.0-s)*m1[1] + s*m2[1];
236 mr[2] = (1.0-s)*m1[2] + s*m2[2];
241 det = mr[0]*mr[2] - mr[1]*mr[1];
243 fprintf(stderr,
"\n ## Error: %s: interpolation results in null metric det:"
244 " %e \n",__func__,det);
246 printf(
"\nInterpolated metrics:\n");
248 double lambda[2],vp[2][2];
249 printf(
"Metric %" MMG5_PRId
" (tag %d): %e %e %e\n",ip1,
mesh->
point[ip1].
tag,m1[0],m1[1],m1[2]);
252 printf (
"eigenval: %e %e\n",lambda[0],lambda[1] );
253 printf (
"size: %e %e\n",1./sqrt(lambda[0]),1./sqrt(lambda[1]) );
254 printf (
"eigenvec: %e %e\n",vp[0][0],vp[0][1] );
255 printf (
"eigenvec: %e %e\n\n",vp[1][0],vp[1][1] );
257 printf(
"Metric %" MMG5_PRId
" (tag %d): %e %e %e\n",ip2,
mesh->
point[ip2].
tag,m2[0],m2[1],m2[2]);
259 printf (
"eigenval: %e %e\n",lambda[0],lambda[1] );
260 printf (
"size: %e %e\n",1./sqrt(lambda[0]),1./sqrt(lambda[1]) );
261 printf (
"eigenvec: %e %e\n",vp[0][0],vp[0][1] );
262 printf (
"eigenvec: %e %e\n\n",vp[1][0],vp[1][1] );
int MMG5_eigensym(double m[3], double lambda[2], double vp[2][2])
int MMG5_eigen2(double *mm, double *lambda, double vp[2][2])
Find eigenvalues and vectors of a 2x2 matrix.
int MMG5_interpmet22(MMG5_pMesh mesh, double *m, double *n, double s, double *mr)
int MMG2D_intmet_iso(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, int8_t i, MMG5_int ip, double s)
int MMG2D_intmet_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, int8_t i, MMG5_int ip, double s)
static const uint8_t MMG5_iprv2[3]
static const uint8_t MMG5_inxt2[6]
Structure to store triangles of a MMG mesh.