52 double surf,dens,J[3][2],mJ[3][2],tJmJ[2][2];
54 static int8_t mmgErr=0;
58 if ( !MMG5_bezierCP(
mesh,ptt,&b,1) )
return 0.0;
64 J[0][0] = 3.0*( b.
b[7][0] - b.
b[0][0] ) ; J[0][1] = 3.0*( b.
b[6][0] - b.
b[0][0] );
65 J[1][0] = 3.0*( b.
b[7][1] - b.
b[0][1] ) ; J[1][1] = 3.0*( b.
b[6][1] - b.
b[0][1] );
66 J[2][0] = 3.0*( b.
b[7][2] - b.
b[0][2] ) ; J[2][1] = 3.0*( b.
b[6][2] - b.
b[0][2] );
69 J[0][0] = 3.0*( b.
b[1][0] - b.
b[8][0] ) ; J[0][1] = 3.0*( b.
b[3][0] - b.
b[8][0] );
70 J[1][0] = 3.0*( b.
b[1][1] - b.
b[8][1] ) ; J[1][1] = 3.0*( b.
b[3][1] - b.
b[8][1] );
71 J[2][0] = 3.0*( b.
b[1][2] - b.
b[8][2] ) ; J[2][1] = 3.0*( b.
b[3][2] - b.
b[8][2] );
74 J[0][0] = 3.0*( b.
b[4][0] - b.
b[5][0] ) ; J[0][1] = 3.0*( b.
b[2][0] - b.
b[5][0] );
75 J[1][0] = 3.0*( b.
b[4][1] - b.
b[5][1] ) ; J[1][1] = 3.0*( b.
b[2][1] - b.
b[5][1] );
76 J[2][0] = 3.0*( b.
b[4][2] - b.
b[5][2] ) ; J[2][1] = 3.0*( b.
b[2][2] - b.
b[5][2] );
79 mJ[0][0] = m[i][0]*J[0][0] + m[i][1]*J[1][0] + m[i][2]*J[2][0];
80 mJ[1][0] = m[i][1]*J[0][0] + m[i][3]*J[1][0] + m[i][4]*J[2][0];
81 mJ[2][0] = m[i][2]*J[0][0] + m[i][4]*J[1][0] + m[i][5]*J[2][0];
83 mJ[0][1] = m[i][0]*J[0][1] + m[i][1]*J[1][1] + m[i][2]*J[2][1];
84 mJ[1][1] = m[i][1]*J[0][1] + m[i][3]*J[1][1] + m[i][4]*J[2][1];
85 mJ[2][1] = m[i][2]*J[0][1] + m[i][4]*J[1][1] + m[i][5]*J[2][1];
88 tJmJ[0][0] = J[0][0]*mJ[0][0] + J[1][0]*mJ[1][0] + J[2][0]*mJ[2][0];
89 tJmJ[0][1] = J[0][0]*mJ[0][1] + J[1][0]*mJ[1][1] + J[2][0]*mJ[2][1];
90 tJmJ[1][0] = J[0][1]*mJ[0][0] + J[1][1]*mJ[1][0] + J[2][1]*mJ[2][0];
91 tJmJ[1][1] = J[0][1]*mJ[0][1] + J[1][1]*mJ[1][1] + J[2][1]*mJ[2][1];
93 dens = tJmJ[0][0]*tJmJ[1][1] - tJmJ[1][0]*tJmJ[0][1];
97 fprintf(stderr,
"\n ## Warning: %s: at least 1 negative or null density.\n",
105 surf += sqrt(fabs(dens));
108 if ( nullDens==3 )
return 0;
127 double ux,uy,uz,m[3][6],rbasis[3][3];
131 for (i=0; i<3; i++) {
140 memcpy(&m[i][0],&met->
m[6*np[i]],6*
sizeof(
double));
142 else if ( p[i]->tag &
MG_GEO ) {
145 ux = 0.5*(p[i1]->
c[0]+p[i2]->
c[0]) - p[i]->c[0];
146 uy = 0.5*(p[i1]->
c[1]+p[i2]->
c[1]) - p[i]->c[1];
147 uz = 0.5*(p[i1]->
c[2]+p[i2]->
c[2]) - p[i]->c[2];
152 memcpy(&m[i][0],&met->
m[6*np[i]],6*
sizeof(
double));
172 double ma[6],
double mb[6],
double mc[6]) {
174 double *a,*b,*c,abx,aby,abz,acx,acy,acz,dens[3],surf;
198 dens[0] = (abx*abx*mm[0]+abx*aby*mm[1]+abx*abz*mm[2])
199 + (aby*abx*mm[1]+aby*aby*mm[3]+aby*abz*mm[4])
200 + (abz*abx*mm[2]+abz*aby*mm[4]+abz*abz*mm[5]);
202 dens[1] = (abx*acx*mm[0]+abx*acy*mm[1]+abx*acz*mm[2])
203 + (aby*acx*mm[1]+aby*acy*mm[3]+aby*acz*mm[4])
204 + (abz*acx*mm[2]+abz*acy*mm[4]+abz*acz*mm[5]);
206 dens[2] = (acx*acx*mm[0]+acx*acy*mm[1]+acx*acz*mm[2])
207 + (acy*acx*mm[1]+acy*acy*mm[3]+acy*acz*mm[4])
208 + (acz*acx*mm[2]+acz*acy*mm[4]+acz*acz*mm[5]);
210 surf = dens[0]*dens[2]-dens[1]*dens[1];
231 double *m,*n,r[3][3],isqhmax;
235 for (k=1; k<=
mesh->
np; k++) {
237 if ( !
MG_VOK(ppt) || ppt->
flag > 0 )
continue;
242 m[0] = m[1] = m[2] = m[3] = m[4] = isqhmax;
250 memset(m,0,6*
sizeof(
double));
252 m[0] = m[3] = m[5] = isqhmax;
257 m[0] = m[1] = m[2] = m[3] = m[4] = isqhmax;
262 m[0] = isqhmax*(r[0][0]*r[0][0]+r[1][0]*r[1][0]+r[2][0]*r[2][0]);
263 m[1] = isqhmax*(r[0][0]*r[0][1]+r[1][0]*r[1][1]+r[2][0]*r[2][1]);
264 m[2] = isqhmax*(r[0][0]*r[0][2]+r[1][0]*r[1][2]+r[2][0]*r[2][2]);
265 m[3] = isqhmax*(r[0][1]*r[0][1]+r[1][1]*r[1][1]+r[2][1]*r[2][1]);
266 m[4] = isqhmax*(r[0][1]*r[0][2]+r[1][1]*r[1][2]+r[2][1]*r[2][2]);
267 m[5] = isqhmax*(r[0][2]*r[0][2]+r[1][2]*r[1][2]+r[2][2]*r[2][2]);
291 double r[3][3],
double c[3],
293 double tAA[6],
double tAb[3] )
295 double b0[3],b1[3],d[3];
299 c[0] = b.
b[j][0] - p0->
c[0];
300 c[1] = b.
b[j][1] - p0->
c[1];
301 c[2] = b.
b[j][2] - p0->
c[2];
303 b.
b[j][0] = r[0][0]*c[0] + r[0][1]*c[1] + r[0][2]*c[2];
304 b.
b[j][1] = r[1][0]*c[0] + r[1][1]*c[1] + r[1][2]*c[2];
305 b.
b[j][2] = r[2][0]*c[0] + r[2][1]*c[1] + r[2][2]*c[2];
310 memcpy(b0,&(b.
b[7][0]),3*
sizeof(
double));
311 memcpy(b1,&(b.
b[8][0]),3*
sizeof(
double));
314 memcpy(b0,&(b.
b[3][0]),3*
sizeof(
double));
315 memcpy(b1,&(b.
b[4][0]),3*
sizeof(
double));
318 memcpy(b0,&(b.
b[5][0]),3*
sizeof(
double));
319 memcpy(b1,&(b.
b[6][0]),3*
sizeof(
double));
325 c[0] = 3.0/8.0*b0[0] + 3.0/8.0*b1[0] + 1.0/8.0*lispoi[3*k+1];
326 c[1] = 3.0/8.0*b0[1] + 3.0/8.0*b1[1] + 1.0/8.0*lispoi[3*k+2];
327 c[2] = 3.0/8.0*b0[2] + 3.0/8.0*b1[2] + 1.0/8.0*lispoi[3*k+3];
332 tAA[0] += c[0]*c[0]*c[0]*c[0];
333 tAA[1] += c[0]*c[0]*c[1]*c[1];
334 tAA[2] += c[0]*c[0]*c[0]*c[1];
335 tAA[3] += c[1]*c[1]*c[1]*c[1];
336 tAA[4] += c[0]*c[1]*c[1]*c[1];
337 tAA[5] += c[0]*c[0]*c[1]*c[1];
339 tAb[0] += c[0]*c[0]*c[2];
340 tAb[1] += c[1]*c[1]*c[2];
341 tAb[2] += c[0]*c[1]*c[2];
343 tAA[0] += lispoi[3*k+1]*lispoi[3*k+1]*lispoi[3*k+1]*lispoi[3*k+1];
344 tAA[1] += lispoi[3*k+1]*lispoi[3*k+1]*lispoi[3*k+2]*lispoi[3*k+2];
345 tAA[2] += lispoi[3*k+1]*lispoi[3*k+1]*lispoi[3*k+1]*lispoi[3*k+2];
346 tAA[3] += lispoi[3*k+2]*lispoi[3*k+2]*lispoi[3*k+2]*lispoi[3*k+2];
347 tAA[4] += lispoi[3*k+1]*lispoi[3*k+2]*lispoi[3*k+2]*lispoi[3*k+2];
348 tAA[5] += lispoi[3*k+1]*lispoi[3*k+1]*lispoi[3*k+2]*lispoi[3*k+2];
350 tAb[0] += lispoi[3*k+1]*lispoi[3*k+1]*lispoi[3*k+3];
351 tAb[1] += lispoi[3*k+2]*lispoi[3*k+2]*lispoi[3*k+3];
352 tAb[2] += lispoi[3*k+1]*lispoi[3*k+2]*lispoi[3*k+3];
358 c[0] =
A64TH*(b.
b[1][0] + b.
b[2][0] + 3.0*(b.
b[3][0] + b.
b[4][0])) \
359 + 3.0*
A16TH*(b.
b[6][0] + b.
b[7][0] + b.
b[9][0]) +
A32TH*(b.
b[5][0] + b.
b[8][0]);
360 c[1] =
A64TH*(b.
b[1][1] + b.
b[2][1] + 3.0*(b.
b[3][1] + b.
b[4][1])) \
361 + 3.0*
A16TH*(b.
b[6][1] + b.
b[7][1] + b.
b[9][1]) +
A32TH*(b.
b[5][1] + b.
b[8][1]);
362 c[2] =
A64TH*(b.
b[1][2] + b.
b[2][2] + 3.0*(b.
b[3][2] + b.
b[4][2])) \
363 + 3.0*
A16TH*(b.
b[6][2] + b.
b[7][2] + b.
b[9][2]) +
A32TH*(b.
b[5][2] + b.
b[8][2]);
365 d[0] = 0.125*b.
b[1][0] + 0.375*(b.
b[3][0] + b.
b[4][0]) + 0.125*b.
b[2][0];
366 d[1] = 0.125*b.
b[1][1] + 0.375*(b.
b[3][1] + b.
b[4][1]) + 0.125*b.
b[2][1];
367 d[2] = 0.125*b.
b[1][2] + 0.375*(b.
b[3][2] + b.
b[4][2]) + 0.125*b.
b[2][2];
370 c[0] =
A64TH*(b.
b[0][0] + b.
b[2][0] + 3.0*(b.
b[5][0] + b.
b[6][0])) \
371 + 3.0*
A16TH*(b.
b[3][0] + b.
b[8][0] + b.
b[9][0]) +
A32TH*(b.
b[4][0] + b.
b[7][0]);
372 c[1] =
A64TH*(b.
b[0][1] + b.
b[2][1] + 3.0*(b.
b[5][1] + b.
b[6][1])) \
373 + 3.0*
A16TH*(b.
b[3][1] + b.
b[8][1] + b.
b[9][1]) +
A32TH*(b.
b[4][1] + b.
b[7][1]);
374 c[2] =
A64TH*(b.
b[0][2] + b.
b[2][2] + 3.0*(b.
b[5][2] + b.
b[6][2])) \
375 + 3.0*
A16TH*(b.
b[3][2] + b.
b[8][2] + b.
b[9][2]) +
A32TH*(b.
b[4][2] + b.
b[7][2]);
377 d[0] = 0.125*b.
b[2][0] + 0.375*(b.
b[5][0] + b.
b[6][0]) + 0.125*b.
b[0][0];
378 d[1] = 0.125*b.
b[2][1] + 0.375*(b.
b[5][1] + b.
b[6][1]) + 0.125*b.
b[0][1];
379 d[2] = 0.125*b.
b[2][2] + 0.375*(b.
b[5][2] + b.
b[6][2]) + 0.125*b.
b[0][2];
382 c[0] =
A64TH*(b.
b[0][0] + b.
b[1][0] + 3.0*(b.
b[7][0] + b.
b[8][0])) \
383 + 3.0*
A16TH*(b.
b[4][0] + b.
b[5][0] + b.
b[9][0]) +
A32TH*(b.
b[3][0] + b.
b[6][0]);
384 c[1] =
A64TH*(b.
b[0][1] + b.
b[1][1] + 3.0*(b.
b[7][1] + b.
b[8][1])) \
385 + 3.0*
A16TH*(b.
b[4][1] + b.
b[5][1] + b.
b[9][1]) +
A32TH*(b.
b[3][1] + b.
b[6][1]);
386 c[2] =
A64TH*(b.
b[0][2] + b.
b[1][2] + 3.0*(b.
b[7][2] + b.
b[8][2])) \
387 + 3.0*
A16TH*(b.
b[4][2] + b.
b[5][2] + b.
b[9][2]) +
A32TH*(b.
b[3][2] + b.
b[6][2]);
389 d[0] = 0.125*b.
b[0][0] + 0.375*(b.
b[7][0] + b.
b[8][0]) + 0.125*b.
b[1][0];
390 d[1] = 0.125*b.
b[0][1] + 0.375*(b.
b[7][1] + b.
b[8][1]) + 0.125*b.
b[1][1];
391 d[2] = 0.125*b.
b[0][2] + 0.375*(b.
b[7][2] + b.
b[8][2]) + 0.125*b.
b[1][2];
395 tAA[0] += c[0]*c[0]*c[0]*c[0];
396 tAA[1] += c[0]*c[0]*c[1]*c[1];
397 tAA[2] += c[0]*c[0]*c[0]*c[1];
398 tAA[3] += c[1]*c[1]*c[1]*c[1];
399 tAA[4] += c[0]*c[1]*c[1]*c[1];
400 tAA[5] += c[0]*c[0]*c[1]*c[1];
402 tAb[0] += c[0]*c[0]*c[2];
403 tAb[1] += c[1]*c[1]*c[2];
404 tAb[2] += c[0]*c[1]*c[2];
406 tAA[0] += d[0]*d[0]*d[0]*d[0];
407 tAA[1] += d[0]*d[0]*d[1]*d[1];
408 tAA[2] += d[0]*d[0]*d[0]*d[1];
409 tAA[3] += d[1]*d[1]*d[1]*d[1];
410 tAA[4] += d[0]*d[1]*d[1]*d[1];
411 tAA[5] += d[0]*d[0]*d[1]*d[1];
413 tAb[0] += d[0]*d[0]*d[2];
414 tAb[1] += d[1]*d[1]*d[2];
415 tAb[2] += d[0]*d[1]*d[2];
437 double tAA[6],
double tAb[3],
double *m,
438 double isqhmin,
double isqhmax,
double hausd)
440 double intm[3], kappa[2], vp[2][2], b0[3], b1[3], b2[3];
441 static int mmgWarn0=0;
443 memset(intm,0x0,3*
sizeof(
double));
448 if((tAb[0]*tAb[0] + tAb[1]*tAb[1] + tAb[2]*tAb[2]) <
MMG5_EPSD) {
461 fprintf(stderr,
"\n ## Warning: %s: unable to solve the system on at"
462 " least 1 point.\n",__func__);
476 kappa[0] = 2.0/9.0 * fabs(kappa[0])/hausd;
477 kappa[0] =
MG_MIN(kappa[0],isqhmin);
478 kappa[0] =
MG_MAX(kappa[0],isqhmax);
480 kappa[1] = 2.0/9.0 * fabs(kappa[1])/hausd;
481 kappa[1] =
MG_MIN(kappa[1],isqhmin);
482 kappa[1] =
MG_MAX(kappa[1],isqhmax);
486 intm[0] = kappa[0]*vp[0][0]*vp[0][0] + kappa[1]*vp[1][0]*vp[1][0];
487 intm[1] = kappa[0]*vp[0][0]*vp[0][1] + kappa[1]*vp[1][0]*vp[1][1];
488 intm[2] = kappa[0]*vp[0][1]*vp[0][1] + kappa[1]*vp[1][1]*vp[1][1];
498 b0[0] = intm[0]*r[0][0] + intm[1]*r[1][0];
499 b0[1] = intm[0]*r[0][1] + intm[1]*r[1][1];
500 b0[2] = intm[0]*r[0][2] + intm[1]*r[1][2];
501 b1[0] = intm[1]*r[0][0] + intm[2]*r[1][0];
502 b1[1] = intm[1]*r[0][1] + intm[2]*r[1][1];
503 b1[2] = intm[1]*r[0][2] + intm[2]*r[1][2];
504 b2[0] = isqhmax*r[2][0];
505 b2[1] = isqhmax*r[2][1];
506 b2[2] = isqhmax*r[2][2];
508 m[0] = r[0][0] * b0[0] + r[1][0] * b1[0] + r[2][0] * b2[0];
509 m[1] = r[0][0] * b0[1] + r[1][0] * b1[1] + r[2][0] * b2[1];
510 m[2] = r[0][0] * b0[2] + r[1][0] * b1[2] + r[2][0] * b2[2];
512 m[3] = r[0][1] * b0[1] + r[1][1] * b1[1] + r[2][1] * b2[1];
513 m[4] = r[0][1] * b0[2] + r[1][1] * b1[2] + r[2][1] * b2[2];
515 m[5] = r[0][2] * b0[2] + r[1][2] * b1[2] + r[2][2] * b2[2];
539 double r[3][3],
double c[3],
540 double tAA[6],
double tAb[3],
double *m,
541 double isqhmin,
double isqhmax,
double hausd)
544 double intm[3], kappa[2], vp[2][2], b0[3], b1[3], b2[3], kappacur;
545 double gammasec[3],tau[2], ux, uy, uz, ps1, l, ll, *t, *t1;
547 static int8_t mmgWarn=0;
551 memset(intm,0x0,3*
sizeof(
double));
555 if((tAb[0]*tAb[0] + tAb[1]*tAb[1] + tAb[2]*tAb[2]) <
MMG5_EPSD) {
568 fprintf(stderr,
"\n ## Warning: %s: unable to solve the system on at"
569 " least 1 point.\n", __func__);
585 kappa[0] =
MG_MIN(kappa[0],isqhmin);
586 kappa[0] =
MG_MAX(kappa[0],isqhmax);
589 kappa[1] =
MG_MIN(kappa[1],isqhmin);
590 kappa[1] =
MG_MAX(kappa[1],isqhmax);
594 intm[0] = kappa[0]*vp[0][0]*vp[0][0] + kappa[1]*vp[1][0]*vp[1][0];
595 intm[1] = kappa[0]*vp[0][0]*vp[0][1] + kappa[1]*vp[1][0]*vp[1][1];
596 intm[2] = kappa[0]*vp[0][1]*vp[0][1] + kappa[1]*vp[1][1]*vp[1][1];
603 for (i=0; i<2; i++) {
605 ux = p1->
c[0] - p0->
c[0];
606 uy = p1->
c[1] - p0->
c[1];
607 uz = p1->
c[2] - p0->
c[2];
609 ps1 = ux*t[0] + uy*t[1] + uz*t[2];
614 b0[0] = r[0][0]*c[0] + r[0][1]*c[1] + r[0][2]*c[2];
615 b0[1] = r[1][0]*c[0] + r[1][1]*c[1] + r[1][2]*c[2];
616 b0[2] = r[2][0]*c[0] + r[2][1]*c[1] + r[2][2]*c[2];
626 ps1 = -(ux*t1[0] + uy*t1[1] + uz*t1[2]);
635 b1[0] = r[0][0]*c[0] + r[0][1]*c[1] + r[0][2]*c[2];
636 b1[1] = r[1][0]*c[0] + r[1][1]*c[1] + r[1][2]*c[2];
637 b1[2] = r[2][0]*c[0] + r[2][1]*c[1] + r[2][2]*c[2];
642 ll = tau[0]*tau[0] + tau[1]*tau[1];
651 gammasec[0] = -12.0*b0[0] + 6.0*b1[0];
652 gammasec[1] = -12.0*b0[1] + 6.0*b1[1];
653 gammasec[2] = -12.0*b0[2] + 6.0*b1[2];
655 ps1 = tau[0]*gammasec[0] + tau[1]*gammasec[1];
656 c[0] = gammasec[0] - ps1*tau[0];
657 c[1] = gammasec[1] - ps1*tau[1];
661 kappacur =
MG_MAX(kappacur,
MG_MAX(0.0,1.0/ll*fabs(c[2])));
665 c[0] = r[0][0]*t[0] + r[0][1]*t[1] + r[0][2]*t[2];
666 c[1] = r[1][0]*t[0] + r[1][1]*t[1] + r[1][2]*t[2];
667 c[2] = r[2][0]*t[0] + r[2][1]*t[1] + r[2][2]*t[2];
668 memcpy(tau,&c[0],2*
sizeof(
double));
672 kappacur =
MG_MIN(kappacur,isqhmin);
673 kappacur =
MG_MAX(kappacur,isqhmax);
676 c[0] = kappacur*tau[0]*tau[0] + isqhmax*tau[1]*tau[1];
677 c[1] = (kappacur - isqhmax)*tau[0]*tau[1];
678 c[2] = kappacur*tau[1]*tau[1] + isqhmax*tau[0]*tau[0];
682 memcpy(intm,b0,3*
sizeof(
double));
692 b0[0] = intm[0]*r[0][0] + intm[1]*r[1][0];
693 b0[1] = intm[0]*r[0][1] + intm[1]*r[1][1];
694 b0[2] = intm[0]*r[0][2] + intm[1]*r[1][2];
695 b1[0] = intm[1]*r[0][0] + intm[2]*r[1][0];
696 b1[1] = intm[1]*r[0][1] + intm[2]*r[1][1];
697 b1[2] = intm[1]*r[0][2] + intm[2]*r[1][2];
698 b2[0] = isqhmax*r[2][0];
699 b2[1] = isqhmax*r[2][1];
700 b2[2] = isqhmax*r[2][2];
702 m[0] = r[0][0] * b0[0] + r[1][0] * b1[0] + r[2][0] * b2[0];
703 m[1] = r[0][0] * b0[1] + r[1][0] * b1[1] + r[2][0] * b2[1];
704 m[2] = r[0][0] * b0[2] + r[1][0] * b1[2] + r[2][0] * b2[2];
706 m[3] = r[0][1] * b0[1] + r[1][1] * b1[1] + r[2][1] * b2[1];
707 m[4] = r[0][1] * b0[2] + r[1][1] * b1[2] + r[2][1] * b2[2];
709 m[5] = r[0][2] * b0[2] + r[1][2] * b1[2] + r[2][2] * b2[2];
765 MMG5_int* iprid,
double isqhmin,
double isqhmax)
768 double n0[3],tau[3],gammasec[3],c[3],ps,ll,l,m;
769 double b0[3],b1[3],kappacur;
772 for (i=0; i<2; i++) {
778 tau[0] = 3.0*(b0[0] - p0->
c[0]);
779 tau[1] = 3.0*(b0[1] - p0->
c[1]);
780 tau[2] = 3.0*(b0[2] - p0->
c[2]);
781 ll = tau[0]*tau[0] + tau[1]*tau[1] + tau[2]*tau[2];
790 gammasec[0] = 6.0*p0->
c[0] -12.0*b0[0] + 6.0*b1[0];
791 gammasec[1] = 6.0*p0->
c[1] -12.0*b0[1] + 6.0*b1[1];
792 gammasec[2] = 6.0*p0->
c[2] -12.0*b0[2] + 6.0*b1[2];
795 ps = tau[0]*gammasec[0] + tau[1]*gammasec[1] + tau[2]*gammasec[2];
799 c[0] = gammasec[0] - ps*tau[0];
800 c[1] = gammasec[1] - ps*tau[1];
801 c[2] = gammasec[2] - ps*tau[2];
806 kappacur =
MG_MAX(0.0,1.0/ll*sqrt(c[0]*c[0] + c[1]*c[1] + c[2]*c[2]));
810 kappacur =
MG_MIN(kappacur,isqhmin);
811 kappacur =
MG_MAX(kappacur,isqhmax);
839 double lambda[2],Jacb[3][2],Hb[3][3],tau[3],ll,l,gammasec[3],c[3];
848 Jacb[0][0] = 3.0*(b->
b[7][0]-b->
b[0][0]);
849 Jacb[1][0] = 3.0*(b->
b[7][1]-b->
b[0][1]);
850 Jacb[2][0] = 3.0*(b->
b[7][2]-b->
b[0][2]);
852 Jacb[0][1] = 3.0*(b->
b[6][0]-b->
b[0][0]);
853 Jacb[1][1] = 3.0*(b->
b[6][1]-b->
b[0][1]);
854 Jacb[2][1] = 3.0*(b->
b[6][2]-b->
b[0][2]);
858 Hb[0][0] = 6.0*(b->
b[0][0] - 2.0*b->
b[7][0] + b->
b[8][0]);
859 Hb[1][0] = 6.0*(b->
b[0][1] - 2.0*b->
b[7][1] + b->
b[8][1]);
860 Hb[2][0] = 6.0*(b->
b[0][2] - 2.0*b->
b[7][2] + b->
b[8][2]);
862 Hb[0][1] = 6.0*(b->
b[0][0] - b->
b[7][0] - b->
b[6][0] + b->
b[9][0]);
863 Hb[1][1] = 6.0*(b->
b[0][1] - b->
b[7][1] - b->
b[6][1] + b->
b[9][1]);
864 Hb[2][1] = 6.0*(b->
b[0][2] - b->
b[7][2] - b->
b[6][2] + b->
b[9][2]);
866 Hb[0][2] = 6.0*(b->
b[0][0] - 2.0*b->
b[6][0] + b->
b[5][0]);
867 Hb[1][2] = 6.0*(b->
b[0][1] - 2.0*b->
b[6][1] + b->
b[5][1]);
868 Hb[2][2] = 6.0*(b->
b[0][2] - 2.0*b->
b[6][2] + b->
b[5][2]);
870 else if ( i0 == 1 ) {
874 Jacb[0][0] = 3.0*(b->
b[1][0]-b->
b[8][0]);
875 Jacb[1][0] = 3.0*(b->
b[1][1]-b->
b[8][1]);
876 Jacb[2][0] = 3.0*(b->
b[1][2]-b->
b[8][2]);
878 Jacb[0][1] = 3.0*(b->
b[3][0]-b->
b[8][0]);
879 Jacb[1][1] = 3.0*(b->
b[3][1]-b->
b[8][1]);
880 Jacb[2][1] = 3.0*(b->
b[3][2]-b->
b[8][2]);
882 Hb[0][0] = 6.0*(b->
b[1][0] - 2.0*b->
b[8][0] + b->
b[7][0]);
883 Hb[1][0] = 6.0*(b->
b[1][1] - 2.0*b->
b[8][1] + b->
b[7][1]);
884 Hb[2][0] = 6.0*(b->
b[1][2] - 2.0*b->
b[8][2] + b->
b[7][2]);
886 Hb[0][1] = 6.0*(b->
b[7][0] - b->
b[8][0] - b->
b[9][0] + b->
b[3][0]);
887 Hb[1][1] = 6.0*(b->
b[7][1] - b->
b[8][1] - b->
b[9][1] + b->
b[3][1]);
888 Hb[2][1] = 6.0*(b->
b[7][2] - b->
b[8][2] - b->
b[9][2] + b->
b[3][2]);
890 Hb[0][2] = 6.0*(b->
b[4][0] - 2.0*b->
b[9][0] + b->
b[7][0]);
891 Hb[1][2] = 6.0*(b->
b[4][1] - 2.0*b->
b[9][1] + b->
b[7][1]);
892 Hb[2][2] = 6.0*(b->
b[4][2] - 2.0*b->
b[9][2] + b->
b[7][2]);
898 Jacb[0][0] = 3.0*(b->
b[4][0]-b->
b[5][0]);
899 Jacb[1][0] = 3.0*(b->
b[4][1]-b->
b[5][1]);
900 Jacb[2][0] = 3.0*(b->
b[4][2]-b->
b[5][2]);
902 Jacb[0][1] = 3.0*(b->
b[2][0]-b->
b[5][0]);
903 Jacb[1][1] = 3.0*(b->
b[2][1]-b->
b[5][1]);
904 Jacb[2][1] = 3.0*(b->
b[2][2]-b->
b[5][2]);
906 Hb[0][0] = 6.0*(b->
b[3][0] - 2.0*b->
b[9][0] + b->
b[6][0]);
907 Hb[1][0] = 6.0*(b->
b[3][1] - 2.0*b->
b[9][1] + b->
b[6][1]);
908 Hb[2][0] = 6.0*(b->
b[3][2] - 2.0*b->
b[9][2] + b->
b[6][2]);
910 Hb[0][1] = 6.0*(b->
b[4][0] - b->
b[5][0] - b->
b[9][0] + b->
b[6][0]);
911 Hb[1][1] = 6.0*(b->
b[4][1] - b->
b[5][1] - b->
b[9][1] + b->
b[6][1]);
912 Hb[2][1] = 6.0*(b->
b[4][2] - b->
b[5][2] - b->
b[9][2] + b->
b[6][2]);
914 Hb[0][2] = 6.0*(b->
b[2][0] - 2.0*b->
b[5][0] + b->
b[6][0]);
915 Hb[1][2] = 6.0*(b->
b[2][1] - 2.0*b->
b[5][1] + b->
b[6][1]);
916 Hb[2][2] = 6.0*(b->
b[2][2] - 2.0*b->
b[5][2] + b->
b[6][2]);
920 tau[0] = Jacb[0][0]*lambda[0] + Jacb[0][1]*lambda[1];
921 tau[1] = Jacb[1][0]*lambda[0] + Jacb[1][1]*lambda[1];
922 tau[2] = Jacb[2][0]*lambda[0] + Jacb[2][1]*lambda[1];
923 ll = tau[0]*tau[0] + tau[1]*tau[1] + tau[2]*tau[2];
931 gammasec[0] = Hb[0][0]*lambda[0]*lambda[0] + 2.0*Hb[0][1]*lambda[0]*lambda[1] + Hb[0][2]*lambda[1]*lambda[1];
932 gammasec[1] = Hb[1][0]*lambda[0]*lambda[0] + 2.0*Hb[1][1]*lambda[0]*lambda[1] + Hb[1][2]*lambda[1]*lambda[1];
933 gammasec[2] = Hb[2][0]*lambda[0]*lambda[0] + 2.0*Hb[2][1]*lambda[0]*lambda[1] + Hb[2][2]*lambda[1]*lambda[1];
935 ps = tau[0]*gammasec[0] + tau[1]*gammasec[1] + tau[2]*gammasec[2];
939 c[0] = gammasec[0] - ps*tau[0];
940 c[1] = gammasec[1] - ps*tau[1];
941 c[2] = gammasec[2] - ps*tau[2];
945 kappacur =
MG_MAX(0.0,1.0/ll*sqrt(c[0]*c[0] + c[1]*c[1] + c[2]*c[2]));
949 kappacur =
MG_MIN(kappacur,isqhmin);
950 kappacur =
MG_MAX(kappacur,isqhmax);
979 double *mm1,*mm2,*nn1,*nn2,ps1,ps2,ux,uy,uz,m1[6],m2[6],n1[3],n2[3],nt[3];
980 double r1[3][3],r2[3][3],t1[2],t2[2],c[3],mtan1[3],mtan2[3],mr1[6],mr2[6];
981 double mtmp[3][3],val,rbasis[3][3];
983 double lambda[2],vp[2][2],alpha,beta,mu[3];
990 ux = p2->
c[0] - p1->
c[0];
991 uy = p2->
c[1] - p1->
c[1];
992 uz = p2->
c[2] - p1->
c[2];
994 mm1 = &met->
m[6*np1];
995 mm2 = &met->
m[6*np2];
1002 memcpy(n1,nt,3*
sizeof(
double));
1003 memcpy(m1,mm1,6*
sizeof(
double));
1008 ps1 = nt[0]*nn1[0] + nt[1]*nn1[1] + nt[2]*nn1[2];
1009 ps2 = nt[0]*nn2[0] + nt[1]*nn2[1] + nt[2]*nn2[2];
1011 if( fabs(ps1) < fabs(ps2))
1012 memcpy(n1,nn2,3*
sizeof(
double));
1014 memcpy(n1,nn1,3*
sizeof(
double));
1023 memcpy(m1,mm1,6*
sizeof(
double));
1027 memcpy(n1,p1->
n,3*
sizeof(
double));
1028 memcpy(m1,mm1,6*
sizeof(
double));
1033 memcpy(n2,nt,3*
sizeof(
double));
1034 memcpy(m2,mm2,6*
sizeof(
double));
1039 ps1 = nt[0]*nn1[0] + nt[1]*nn1[1] + nt[2]*nn1[2];
1040 ps2 = nt[0]*nn2[0] + nt[1]*nn2[1] + nt[2]*nn2[2];
1042 if( fabs(ps1) < fabs(ps2))
1043 memcpy(n2,nn2,3*
sizeof(
double));
1045 memcpy(n2,nn1,3*
sizeof(
double));
1054 memcpy(m2,mm2,6*
sizeof(
double));
1058 memcpy(n2,p2->
n,3*
sizeof(
double));
1059 memcpy(m2,mm2,6*
sizeof(
double));
1067 l = sqrt(ux*ux+uy*uy+uz*uz);
1076 c[0] = r1[0][0]*ux + r1[0][1]*uy + r1[0][2]*uz;
1077 c[1] = r1[1][0]*ux + r1[1][1]*uy + r1[1][2]*uz;
1079 memcpy(t1,c,2*
sizeof(
double));
1081 dd = t1[0]*t1[0] + t1[1]*t1[1];
1090 ps1 = mtan1[0]*t1[0]*t1[0] + 2.0*mtan1[1]*t1[0]*t1[1] + mtan1[2]*t1[1]*t1[1];
1091 assert ( ps1 > 0. );
1100 c[0] = - ( r2[0][0]*ux + r2[0][1]*uy + r2[0][2]*uz );
1101 c[1] = - ( r2[1][0]*ux + r2[1][1]*uy + r2[1][2]*uz );
1102 memcpy(t2,c,2*
sizeof(
double));
1104 dd = t2[0]*t2[0] + t2[1]*t2[1];
1113 ps2 = mtan2[0]*t2[0]*t2[0] + 2.0*mtan2[1]*t2[0]*t2[1] + mtan2[2]*t2[1]*t2[1];
1114 assert ( ps2 > 0. );
1129 c[0] = t1[0]*vp[0][0] + t1[1]*vp[0][1] ;
1130 c[1] = t1[0]*vp[1][0] + t1[1]*vp[1][1] ;
1137 val = fabs(c[ichg]);
1138 for (idx = 1; idx<2; ++idx) {
1139 if ( fabs(c[idx]) > val ) {
1144 assert(c[ichg]*c[ichg] >
MMG5_EPS );
1147 beta = (alpha*alpha - ps1*ps1)/(c[ichg]*c[ichg]);
1163 c[0] = fabs(mm1[0]-lambda[ichg]);
1164 c[1] = fabs(mm1[1]-lambda[ichg]);
1165 c[2] = fabs(mm1[2]-lambda[ichg]);
1169 val = fabs(c[kmin]);
1170 for (idx = 1; idx<3; ++idx) {
1171 if ( fabs(c[idx]) < val ) {
1188 mtan1[0] = mu[0]*vp[0][0]*vp[0][0] + mu[1]*vp[1][0]*vp[1][0];
1189 mtan1[1] = mu[0]*vp[0][0]*vp[0][1] + mu[1]*vp[1][0]*vp[1][1];
1190 mtan1[2] = mu[0]*vp[0][1]*vp[0][1] + mu[1]*vp[1][1]*vp[1][1];
1195 mtmp[0][0] = mtan1[0]*r1[0][0] + mtan1[1]*r1[1][0];
1196 mtmp[0][1] = mtan1[0]*r1[0][1] + mtan1[1]*r1[1][1];
1197 mtmp[0][2] = mtan1[0]*r1[0][2] + mtan1[1]*r1[1][2];
1199 mtmp[1][0] = mtan1[1]*r1[0][0] + mtan1[2]*r1[1][0];
1200 mtmp[1][1] = mtan1[1]*r1[0][1] + mtan1[2]*r1[1][1];
1201 mtmp[1][2] = mtan1[1]*r1[0][2] + mtan1[2]*r1[1][2];
1203 mtmp[2][0] = mr1[5]*r1[2][0];
1204 mtmp[2][1] = mr1[5]*r1[2][1];
1205 mtmp[2][2] = mr1[5]*r1[2][2];
1207 m1[0] = r1[0][0]*mtmp[0][0] + r1[1][0]*mtmp[1][0] + r1[2][0]*mtmp[2][0];
1208 m1[1] = r1[0][0]*mtmp[0][1] + r1[1][0]*mtmp[1][1] + r1[2][0]*mtmp[2][1];
1209 m1[2] = r1[0][0]*mtmp[0][2] + r1[1][0]*mtmp[1][2] + r1[2][0]*mtmp[2][2];
1211 m1[3] = r1[0][1]*mtmp[0][1] + r1[1][1]*mtmp[1][1] + r1[2][1]*mtmp[2][1];
1212 m1[4] = r1[0][1]*mtmp[0][2] + r1[1][1]*mtmp[1][2] + r1[2][1]*mtmp[2][2];
1214 m1[5] = r1[0][2]*mtmp[0][2] + r1[1][2]*mtmp[1][2] + r1[2][2]*mtmp[2][2];
1216 memcpy(mm1,m1,6*
sizeof(
double));
1229 c[0] = t2[0]*vp[0][0] + t2[1]*vp[0][1] ;
1230 c[1] = t2[0]*vp[1][0] + t2[1]*vp[1][1] ;
1235 val = fabs(c[ichg]);
1236 for (idx = 1; idx<2; ++idx) {
1237 if ( fabs(c[idx]) > val ) {
1242 assert(c[ichg]*c[ichg] >
MMG5_EPS );
1246 beta = (alpha*alpha - ps2*ps2)/(c[ichg]*c[ichg]);
1260 c[0] = fabs(mm2[0]-lambda[ichg]);
1261 c[1] = fabs(mm2[1]-lambda[ichg]);
1262 c[2] = fabs(mm2[2]-lambda[ichg]);
1265 val = fabs(c[kmin]);
1266 for (idx = 1; idx<3; ++idx) {
1267 if ( fabs(c[idx]) < val ) {
1281 mtan2[0] = mu[0]*vp[0][0]*vp[0][0] + mu[1]*vp[1][0]*vp[1][0];
1282 mtan2[1] = mu[0]*vp[0][0]*vp[0][1] + mu[1]*vp[1][0]*vp[1][1];
1283 mtan2[2] = mu[0]*vp[0][1]*vp[0][1] + mu[1]*vp[1][1]*vp[1][1];
1286 mtmp[0][0] = mtan2[0]*r2[0][0] + mtan2[1]*r2[1][0];
1287 mtmp[0][1] = mtan2[0]*r2[0][1] + mtan2[1]*r2[1][1];
1288 mtmp[0][2] = mtan2[0]*r2[0][2] + mtan2[1]*r2[1][2];
1290 mtmp[1][0] = mtan2[1]*r2[0][0] + mtan2[2]*r2[1][0];
1291 mtmp[1][1] = mtan2[1]*r2[0][1] + mtan2[2]*r2[1][1];
1292 mtmp[1][2] = mtan2[1]*r2[0][2] + mtan2[2]*r2[1][2];
1294 mtmp[2][0] = mr2[5]*r2[2][0];
1295 mtmp[2][1] = mr2[5]*r2[2][1];
1296 mtmp[2][2] = mr2[5]*r2[2][2];
1298 m2[0] = r2[0][0]*mtmp[0][0] + r2[1][0]*mtmp[1][0] + r2[2][0]*mtmp[2][0];
1299 m2[1] = r2[0][0]*mtmp[0][1] + r2[1][0]*mtmp[1][1] + r2[2][0]*mtmp[2][1];
1300 m2[2] = r2[0][0]*mtmp[0][2] + r2[1][0]*mtmp[1][2] + r2[2][0]*mtmp[2][2];
1302 m2[3] = r2[0][1]*mtmp[0][1] + r2[1][1]*mtmp[1][1] + r2[2][1]*mtmp[2][1];
1303 m2[4] = r2[0][1]*mtmp[0][2] + r2[1][1]*mtmp[1][2] + r2[2][1]*mtmp[2][2];
1305 m2[5] = r2[0][2]*mtmp[0][2] + r2[1][2]*mtmp[1][2] + r2[2][2]*mtmp[2][2];
1307 memcpy(mm2,m2,6*
sizeof(
double));
1327 double dn[2],
double vp[2][2] ) {
1329 double det,lambda[2],imn[4];
1331 static int8_t mmgWarn0=0;
1334 det = m[0]*m[2] - m[1]*m[1];
1338 fprintf(stderr,
"\n ## Warning: %s: at least 1 null metric det : %E \n",
1345 imn[0] = det * ( m[2]*n[0] - m[1]*n[1]);
1346 imn[1] = det * ( m[2]*n[1] - m[1]*n[2]);
1347 imn[2] = det * (-m[1]*n[0] + m[0]*n[1]);
1348 imn[3] = det * (-m[1]*n[1] + m[0]*n[2]);
1356 fprintf(stderr,
"\n ## Warning: %s: at least 1 failing"
1357 " simultaneous reduction.\n",__func__);
1379 dn[0] = lambda[0]*dm[0];
1380 dn[1] = lambda[0]*dm[1];
1385 else if( order == 1 ) {
1388 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];
1389 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];
1390 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];
1391 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];
1417 double dn[3],
double vp[3][3] ) {
1419 double lambda[3],im[6],imn[9];
1421 static int8_t mmgWarn0=0;
1427 fprintf(stderr,
"\n ## Warning: %s: unable to invert the matrix.\n",__func__);
1440 fprintf(stderr,
"\n ## Warning: %s: at least 1 failing"
1441 " simultaneous reduction.\n",__func__);
1469 dn[0] = lambda[0]*dm[0];
1470 dn[1] = lambda[0]*dm[1];
1471 dn[2] = lambda[0]*dm[2];
1473 else if( order == 2 ) {
1479 double mred[6],nred[6];
1498 double wp[2][2],up[2][3];
1502 for( j = 0; j < 2; j++ ) {
1503 for( i = 0; i < 3; i++ ) {
1505 for( k = 0; k < 2; k++ ) {
1506 up[j][i] += vp[k][i]*wp[j][k];
1510 for( j = 0; j < 2; j++ ) {
1511 for( i = 0; i < 3; i++ ) {
1512 vp[j][i] = up[j][i];
1517 dn[0] = lambda[0]*dm[0];
1518 dn[1] = lambda[0]*dm[1];
1525 dm[0] = m[0]*vp[0][0]*vp[0][0] + 2.0*m[1]*vp[0][0]*vp[0][1] + 2.0*m[2]*vp[0][0]*vp[0][2]
1526 + m[3]*vp[0][1]*vp[0][1] + 2.0*m[4]*vp[0][1]*vp[0][2] + m[5]*vp[0][2]*vp[0][2];
1527 dm[1] = m[0]*vp[1][0]*vp[1][0] + 2.0*m[1]*vp[1][0]*vp[1][1] + 2.0*m[2]*vp[1][0]*vp[1][2]
1528 + m[3]*vp[1][1]*vp[1][1] + 2.0*m[4]*vp[1][1]*vp[1][2] + m[5]*vp[1][2]*vp[1][2];
1529 dm[2] = m[0]*vp[2][0]*vp[2][0] + 2.0*m[1]*vp[2][0]*vp[2][1] + 2.0*m[2]*vp[2][0]*vp[2][2]
1530 + m[3]*vp[2][1]*vp[2][1] + 2.0*m[4]*vp[2][1]*vp[2][2] + m[5]*vp[2][2]*vp[2][2];
1532 dn[0] = n[0]*vp[0][0]*vp[0][0] + 2.0*n[1]*vp[0][0]*vp[0][1] + 2.0*n[2]*vp[0][0]*vp[0][2]
1533 + n[3]*vp[0][1]*vp[0][1] + 2.0*n[4]*vp[0][1]*vp[0][2] + n[5]*vp[0][2]*vp[0][2];
1534 dn[1] = n[0]*vp[1][0]*vp[1][0] + 2.0*n[1]*vp[1][0]*vp[1][1] + 2.0*n[2]*vp[1][0]*vp[1][2]
1535 + n[3]*vp[1][1]*vp[1][1] + 2.0*n[4]*vp[1][1]*vp[1][2] + n[5]*vp[1][2]*vp[1][2];
1536 dn[2] = n[0]*vp[2][0]*vp[2][0] + 2.0*n[1]*vp[2][0]*vp[2][1] + 2.0*n[2]*vp[2][0]*vp[2][2]
1537 + n[3]*vp[2][1]*vp[2][1] + 2.0*n[4]*vp[2][1]*vp[2][2] + n[5]*vp[2][2]*vp[2][2];
1563 double *swap,int8_t *perm ) {
1567 for( int8_t i = 0; i < dim; i++ )
1586 double dmnum[2],dnnum[2],vpnum[2][2],ivpnum[2][2],mnum[3],nnum[3];
1587 double swap[2],maxerr,err;
1600 fprintf(stderr,
" ## Error first matrix coreduction values: in function %s, max error %e\n",
1606 fprintf(stderr,
" ## Error second matrix coreduction values: in function %s, max error %e\n",
1613 for( int8_t i = 0; i < 2; i++ ) {
1615 for( int8_t j = 0; j < 2; j++ )
1616 err += vpex[i][j] * vpnum[i][j];
1618 maxerr =
MG_MAX(maxerr,err);
1621 fprintf(stderr,
" ## Error matrix coreduction vectors: in function %s, max error %e\n",
1635 fprintf(stderr,
" ## Error first matrix coreduction recomposition: in function %s, max error %e\n",
1641 fprintf(stderr,
" ## Error second matrix coreduction recomposition: in function %s, max error %e\n",
1664 double dmnum[3],dnnum[3],vpnum[3][3],ivpnum[3][3],mnum[6],nnum[6];
1665 double swap[3],maxerr,err;
1678 fprintf(stderr,
" ## Error first matrix coreduction values: in function %s, max error %e\n",
1684 fprintf(stderr,
" ## Error second matrix coreduction values: in function %s, max error %e\n",
1691 for( int8_t i = 0; i < 3; i++ ) {
1693 for( int8_t j = 0; j < 3; j++ )
1694 err += vpex[i][j] * vpnum[i][j];
1696 maxerr =
MG_MAX(maxerr,err);
1699 fprintf(stderr,
" ## Error matrix coreduction vectors: in function %s, max error %e\n",
1713 fprintf(stderr,
" ## Error first matrix coreduction recomposition: in function %s, max error %e\n",
1719 fprintf(stderr,
" ## Error second matrix coreduction recomposition: in function %s, max error %e\n",
1743 double vp[2][2],int8_t
ier ) {
1746 det = vp[0][0]*vp[1][1] - vp[0][1]*vp[1][0];
1747 if ( fabs(det) <
MMG5_EPS )
return 0;
1750 ip[0] = vp[1][1]*det;
1751 ip[1] = -vp[1][0]*det;
1752 ip[2] = -vp[0][1]*det;
1753 ip[3] = vp[0][0]*det;
1756 m[0] = dm[0]*ip[0]*ip[0] + dm[1]*ip[2]*ip[2];
1757 m[1] = dm[0]*ip[0]*ip[1] + dm[1]*ip[2]*ip[3];
1758 m[2] = dm[0]*ip[1]*ip[1] + dm[1]*ip[3]*ip[3];
1761 n[0] = dn[0]*ip[0]*ip[0] + dn[1]*ip[2]*ip[2];
1762 n[1] = dn[0]*ip[0]*ip[1] + dn[1]*ip[2]*ip[3];
1763 n[2] = dn[0]*ip[1]*ip[1] + dn[1]*ip[3]*ip[3];
1784 double vp[3][3],int8_t
ier ) {
1806 double mex[3] = { 508., -504, 502.};
1807 double nex[3] = {4020.,-2020.,1020.};
1808 double dm[2] = { 1., 100. };
1809 double dn[2] = {500., 4. };
1810 double vp[2][2] = {{ 1./sqrt(2.),1./sqrt(2.)},
1811 {1./sqrt(5.),2./sqrt(5.)}};
1812 double mnum[3],nnum[3],maxerr;
1821 fprintf(stderr,
" ## Error first matrix recomposition from simultaneous reduction: in function %s, max error %e\n",
1827 fprintf(stderr,
" ## Error second matrix recomposition from simultaneous reduction: in function %s, max error %e\n",
1842 double mex[6] = {111./2.,-109./2., 89./2.,111./2.,-91./2.,111./2.};
1843 double nex[6] = {409./2.,-393./2.,-407./2.,409./2.,391./2.,409./2.};
1844 double dm[3] = {1., 10.,100.};
1845 double dn[3] = {8.,400., 1.};
1846 double vp[3][3] = {{1./sqrt(2.),1./sqrt(2.),0.},
1847 {0., 1./sqrt(2.),1./sqrt(2.)},
1848 {1./sqrt(2.), 0.,1./sqrt(2.)}};
1849 double mnum[6],nnum[6],maxerr;
1858 fprintf(stderr,
" ## Error first matrix recomposition from simultaneous reduction: in function %s, max error %e\n",
1864 fprintf(stderr,
" ## Error second matrix recomposition from simultaneous reduction: in function %s, max error %e\n",
1886 hm = 1.0 / sqrt(dm[dir]);
1887 hn = 1.0 / sqrt(dn[dir]);
1892 dn[dir] = 1.0 / (hn*hn);
1898 dn[dir] = 1.0 / (hn*hn);
1917 det = vp[0][0]*vp[1][1] - vp[0][1]*vp[1][0];
1918 if ( fabs(det) <
MMG5_EPS )
return 0;
1921 ip[0] = vp[1][1]*det;
1922 ip[1] = -vp[1][0]*det;
1923 ip[2] = -vp[0][1]*det;
1924 ip[3] = vp[0][0]*det;
1926 n[0] = dn[0]*ip[0]*ip[0] + dn[1]*ip[2]*ip[2];
1927 n[1] = dn[0]*ip[0]*ip[1] + dn[1]*ip[2]*ip[3];
1928 n[2] = dn[0]*ip[1]*ip[1] + dn[1]*ip[3]*ip[3];
1956 double *mm1,*mm2,*nn1,*nn2,ps1,ps2,ux,uy,uz,m1[6],m2[6],n1[3],n2[3],nt[3];
1957 double r1[3][3],r2[3][3],mtan1[3],mtan2[3],mr1[6],mr2[6];
1958 double mtmp[3][3],rbasis1[3][3],rbasis2[3][3];
1959 double l,difsiz,rmet3D[6];
1960 double lambda[2],vp[2][2],beta,mu[3];
1967 ux = p2->
c[0] - p1->
c[0];
1968 uy = p2->
c[1] - p1->
c[1];
1969 uz = p2->
c[2] - p1->
c[2];
1971 mm1 = &met->
m[6*npmaster];
1972 mm2 = &met->
m[6*npslave];
1982 memcpy(n1,nt,3*
sizeof(
double));
1983 memcpy(m1,mm1,6*
sizeof(
double));
1988 ps1 = nt[0]*nn1[0] + nt[1]*nn1[1] + nt[2]*nn1[2];
1989 ps2 = nt[0]*nn2[0] + nt[1]*nn2[1] + nt[2]*nn2[2];
1991 if( fabs(ps1) < fabs(ps2))
1992 memcpy(n1,nn2,3*
sizeof(
double));
1994 memcpy(n1,nn1,3*
sizeof(
double));
2001 memcpy(m1,mm1,6*
sizeof(
double));
2005 memcpy(n1,p1->
n,3*
sizeof(
double));
2006 memcpy(m1,mm1,6*
sizeof(
double));
2011 memcpy(n2,nt,3*
sizeof(
double));
2012 memcpy(m2,mm2,6*
sizeof(
double));
2017 ps1 = nt[0]*nn1[0] + nt[1]*nn1[1] + nt[2]*nn1[2];
2018 ps2 = nt[0]*nn2[0] + nt[1]*nn2[1] + nt[2]*nn2[2];
2020 if( fabs(ps1) < fabs(ps2))
2021 memcpy(n2,nn2,3*
sizeof(
double));
2023 memcpy(n2,nn1,3*
sizeof(
double));
2026 if( !cfg_m2 ) {
return 0; }
2031 memcpy(m2,mm2,6*
sizeof(
double));
2035 memcpy(n2,p2->
n,3*
sizeof(
double));
2036 memcpy(m2,mm2,6*
sizeof(
double));
2044 l = sqrt(ux*ux+uy*uy+uz*uz);
2085 double ll[3],rr[3][3],llmin;
2091 for( i = 0; i < 3; i++ )
2096 beta = mu[0] - llmin;
2098 if ( fabs(beta) < fabs(llmin-mu[1]) ) {
2099 beta = mu[1] - llmin;
2104 assert ( ll[0]>0. && ll[1]>0. && ll[2]>0. );
2105 mm2[0] = ll[0]*rr[0][0]*rr[0][0] + ll[1]*rr[1][0]*rr[1][0] + ll[2]*rr[2][0]*rr[2][0];
2106 mm2[1] = ll[0]*rr[0][0]*rr[0][1] + ll[1]*rr[1][0]*rr[1][1] + ll[2]*rr[2][0]*rr[2][1];
2107 mm2[2] = ll[0]*rr[0][0]*rr[0][2] + ll[1]*rr[1][0]*rr[1][2] + ll[2]*rr[2][0]*rr[2][2];
2108 mm2[3] = ll[0]*rr[0][1]*rr[0][1] + ll[1]*rr[1][1]*rr[1][1] + ll[2]*rr[2][1]*rr[2][1];
2109 mm2[4] = ll[0]*rr[0][1]*rr[0][2] + ll[1]*rr[1][1]*rr[1][2] + ll[2]*rr[2][1]*rr[2][2];
2110 mm2[5] = ll[0]*rr[0][2]*rr[0][2] + ll[1]*rr[1][2]*rr[1][2] + ll[2]*rr[2][2]*rr[2][2];
2119 rmet3D[0] = mtan2[0];
2120 rmet3D[1] = mtan2[1];
2122 rmet3D[3] = mtan2[2];
2126 mu[0] = rmet3D[0]*rbasis2[0][0]*rbasis2[0][0] + 2. * rmet3D[1]*rbasis2[1][0]*rbasis2[0][0]
2127 + 2. * rmet3D[2]*rbasis2[2][0]*rbasis2[0][0]
2128 + rmet3D[3]*rbasis2[1][0]*rbasis2[1][0] + 2. * rmet3D[4]*rbasis2[2][0]*rbasis2[1][0]
2129 + rmet3D[5]*rbasis2[2][0]*rbasis2[2][0];
2134 mu[1] = rmet3D[0]*rbasis2[0][1]*rbasis2[0][1] + 2. * rmet3D[1]*rbasis2[1][1]*rbasis2[0][1]
2135 + 2. * rmet3D[2]*rbasis2[2][1]*rbasis2[0][1]
2136 + rmet3D[3]*rbasis2[1][1]*rbasis2[1][1] + 2. * rmet3D[4]*rbasis2[2][1]*rbasis2[1][1]
2137 + rmet3D[5]*rbasis2[2][1]*rbasis2[2][1];
2146 mm2[cfg_m2] = mu[1];
2156 mtmp[0][0] = mtan2[0]*r2[0][0] + mtan2[1]*r2[1][0];
2157 mtmp[0][1] = mtan2[0]*r2[0][1] + mtan2[1]*r2[1][1];
2158 mtmp[0][2] = mtan2[0]*r2[0][2] + mtan2[1]*r2[1][2];
2160 mtmp[1][0] = mtan2[1]*r2[0][0] + mtan2[2]*r2[1][0];
2161 mtmp[1][1] = mtan2[1]*r2[0][1] + mtan2[2]*r2[1][1];
2162 mtmp[1][2] = mtan2[1]*r2[0][2] + mtan2[2]*r2[1][2];
2164 mtmp[2][0] = mr2[5]*r2[2][0];
2165 mtmp[2][1] = mr2[5]*r2[2][1];
2166 mtmp[2][2] = mr2[5]*r2[2][2];
2168 m2[0] = r2[0][0]*mtmp[0][0] + r2[1][0]*mtmp[1][0] + r2[2][0]*mtmp[2][0];
2169 m2[1] = r2[0][0]*mtmp[0][1] + r2[1][0]*mtmp[1][1] + r2[2][0]*mtmp[2][1];
2170 m2[2] = r2[0][0]*mtmp[0][2] + r2[1][0]*mtmp[1][2] + r2[2][0]*mtmp[2][2];
2172 m2[3] = r2[0][1]*mtmp[0][1] + r2[1][1]*mtmp[1][1] + r2[2][1]*mtmp[2][1];
2173 m2[4] = r2[0][1]*mtmp[0][2] + r2[1][1]*mtmp[1][2] + r2[2][1]*mtmp[2][2];
2175 m2[5] = r2[0][2]*mtmp[0][2] + r2[1][2]*mtmp[1][2] + r2[2][2]*mtmp[2][2];
2182 assert ( mu[0] > 0.);
2183 assert ( mu[1] > 0.);
2184 assert ( mu[2] > 0.);
2187 memcpy(mm2,m2,6*
sizeof(
double));
2211 for ( k=1; k<=
mesh->
np; k++ ) {
2213 if ( !
MG_VOK(p0) )
continue;
2215 if ( !p0->
s )
continue;
2218 lm = p0->
s/met->
m[iadr];
2219 met->
m[iadr] = lm*lm;
2222 met->
m[iadr+2] = met->
m[iadr];
2226 met->
m[iadr+3] = met->
m[iadr+5] = met->
m[iadr];
2230 met->
m[iadr+2] = met->
m[iadr+1] = met->
m[iadr];
2231 met->
m[iadr+4] = met->
m[iadr+3] = met->
m[iadr];
2240 printf(
"\n -- SIZEMAP CORRECTION : overwritten of sizes at required vertices\n");
2263 MMG5_int
ier,k,np1,np2,nup,nu;
2269 for (k=1; k<=
mesh->
np; k++)
2277 for (k=1; k<=
mesh->
nt; k++) {
2279 if ( !
MG_EOK(pt) )
continue;
2281 for (i=0; i<3; i++) {
2289 if ( p1->
s || p2->
s )
continue;
2291 ier = MMG5_grad2met_ani(
mesh,met,pt,np1,np2);
2296 else if (
ier == np2 ) {
2304 while( ++(*it) < maxit && nu > 0 );
2307 fprintf(stdout,
" gradation: %7"MMG5_PRId
" updated, %d iter.\n",nup,(*it));
2327 MMG5_int k,np1,np2,npslave,npmaster,nup,nu;
2332 fprintf(stdout,
" ** Grading required points.\n");
2346 for (k=1; k<=
mesh->
nt; k++) {
2348 if ( !
MG_EOK(pt) )
continue;
2350 for (i=0; i<3; i++) {
2356 if ( MMG5_abs ( p1->
s - p2->
s ) < 2 ) {
2360 else if ( p1->
s > p2->
s ) {
2365 assert ( p2->
s > p1->
s );
2373 ier = MMG5_grad2metreq_ani(
mesh,met,pt,npmaster,npslave);
2383 while ( ++it < maxit && nu > 0 );
2386 fprintf(stdout,
" gradation (required): %7"MMG5_PRId
" updated, %d iter.\n",nup,it);
int MMG5_gradsizreq_ani(MMG5_pMesh mesh, MMG5_pSol met)
void MMG5_sort_simred(int8_t dim, double *dm, double *dn, double *vp, double *swap, int8_t *perm)
int MMG5_test_updatemet3d_ani()
int MMG5_test_simred2d(MMG5_pMesh mesh, double *mex, double *nex, double *dmex, double *dnex, double vpex[][2])
void MMG5_fillDefmetregSys(MMG5_int k, MMG5_pPoint p0, int i0, MMG5_Bezier b, double r[3][3], double c[3], double *lispoi, double tAA[6], double tAb[3])
int MMG5_updatemetreq_ani(double *n, double dn[2], double vp[2][2])
double MMG5_surftri33_ani(MMG5_pMesh mesh, MMG5_pTria ptt, double ma[6], double mb[6], double mc[6])
int MMG5_compute_meanMetricAtMarkedPoints_ani(MMG5_pMesh mesh, MMG5_pSol met)
int MMG5_solveDefmetregSys(MMG5_pMesh mesh, double r[3][3], double c[3], double tAA[6], double tAb[3], double *m, double isqhmin, double isqhmax, double hausd)
int MMG5_test_updatemet2d_ani()
int MMG5_simred3d(MMG5_pMesh mesh, double *m, double *n, double dm[3], double dn[3], double vp[3][3])
void MMG5_gradEigenvreq(double *dm, double *dn, double difsiz, int8_t dir, int8_t *ier)
void MMG5_defUninitSize(MMG5_pMesh mesh, MMG5_pSol met, int8_t ismet)
static double MMG5_surf(MMG5_pMesh mesh, double m[3][6], MMG5_pTria ptt)
MMG5_int MMG5_grad2metSurf(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria pt, MMG5_int np1, MMG5_int np2)
double MMG5_surftri_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria ptt)
int MMG5_updatemet2d_ani(double *m, double *n, double dm[2], double dn[2], double vp[2][2], int8_t ier)
double MMG5_ridSizeInNormalDir(MMG5_pMesh mesh, int i0, double *bcu, MMG5_Bezier *b, double isqhmin, double isqhmax)
int MMG5_grad2metSurfreq(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria pt, MMG5_int npmaster, MMG5_int npslave)
int MMG5_updatemet3d_ani(double *m, double *n, double dm[3], double dn[3], double vp[3][3], int8_t ier)
int MMG5_simred2d(MMG5_pMesh mesh, double *m, double *n, double dm[2], double dn[2], double vp[2][2])
int MMG5_solveDefmetrefSys(MMG5_pMesh mesh, MMG5_pPoint p0, MMG5_int ipref[2], double r[3][3], double c[3], double tAA[6], double tAb[3], double *m, double isqhmin, double isqhmax, double hausd)
int MMG5_test_simred3d(MMG5_pMesh mesh, double *mex, double *nex, double *dmex, double *dnex, double vpex[][3])
MMG5_int MMG5_gradsiz_ani(MMG5_pMesh mesh, MMG5_pSol met, int *it)
double MMG5_ridSizeInTangentDir(MMG5_pMesh mesh, MMG5_pPoint p0, MMG5_int idp, MMG5_int *iprid, double isqhmin, double isqhmax)
void MMG5_bezierEdge(MMG5_pMesh mesh, MMG5_int i0, MMG5_int i1, double b0[3], double b1[3], int8_t isrid, double v[3])
int MMG5_eigensym(double m[3], double lambda[2], double vp[2][2])
int MMG5_eigenv3d(int symmat, double *mat, double lambda[3], double v[3][3])
Find eigenvalues and vectors of a 3x3 matrix.
int MMG5_eigenv2d(int symmat, double *mat, double lambda[2], double vp[2][2])
Find eigenvalues and vectors of a 2x2 matrix.
static void MMG5_simredmat(int8_t dim, double *m, double *dm, double *iv)
void MMG5_mark_pointsOnReqEdge_fromTria(MMG5_pMesh mesh)
void MMG5_mn(double m[6], double n[6], double mn[9])
double MMG5_test_mat_error(int8_t nelem, double m1[], double m2[])
static const uint8_t MMG5_iprv2[3]
int MMG5_rmtr(double r[3][3], double m[6], double mr[6])
int MMG5_invmat33(double m[3][3], double mi[3][3])
static const uint8_t MMG5_inxt2[6]
int MMG5_nortri(MMG5_pMesh mesh, MMG5_pTria pt, double *n)
int MMG5_rotmatrix(double n[3], double r[3][3])
int MMG5_sys33sym(double a[6], double b[3], double r[3])
void MMG5_nsort(int8_t, double *, int8_t *)
void MMG5_nperm(int8_t n, int8_t shift, int8_t stride, double *val, double *oldval, int8_t *perm)
int MMG5_invmat22(double m[2][2], double mi[2][2])
int MMG5_invmat(double *m, double *mi)
Structure to store vertices of an MMG mesh.
Structure to store triangles of a MMG mesh.