64 double vol,totvol,m[6];
65 double calold,calnew,callist[
MMG3D_LMAX+2],det;
71 fprintf(stderr,
"\n ## Error: %s:"
72 " volumic ball has null or negative size (%d)\n",
90 for (k=0; k<ilist; k++) {
105 det = m[0] * ( m[3]*m[5] - m[4]*m[4]) - m[1] * ( m[1]*m[5] - m[2]*m[4])
106 + m[2] * ( m[1]*m[4] - m[2]*m[3]);
115 ppt0->
c[0] += 0.25 * vol*(p0->
c[0] + p1->
c[0] + p2->
c[0] + p3->
c[0]);
116 ppt0->
c[1] += 0.25 * vol*(p0->
c[1] + p1->
c[1] + p2->
c[1] + p3->
c[1]);
117 ppt0->
c[2] += 0.25 * vol*(p0->
c[2] + p1->
c[2] + p2->
c[2] + p3->
c[2]);
124 totvol = 1.0 / totvol;
125 ppt0->
c[0] *= totvol;
126 ppt0->
c[1] *= totvol;
127 ppt0->
c[2] *= totvol;
131 for (k=0; k<ilist; k++) {
141 calnew =
MG_MIN(calnew,callist[k]);
143 if (calold <
MMG5_EPSOK && calnew <= calold) {
149 else if ( improve && calnew < 1.02* calold ) {
152 else if ( calnew < 0.3 * calold ) {
161 p0->
c[0] = ppt0->
c[0];
162 p0->
c[1] = ppt0->
c[1];
163 p0->
c[2] = ppt0->
c[2];
164 for (k=0; k<ilist; k++) {
165 (&
mesh->
tetra[list[k]/4])->qual=callist[k];
192 int64_t *listv,
int ilistv,MMG5_int *lists,
int ilists,
193 int improveSurf,
int improveVol) {
200 double n[3],r[3][3],lispoi[3*
MMG3D_LMAX+1],det2d;
201 double detloc,gv[2],step,lambda[3];
202 double o[3],no[3],*m0,ncur[3],nprev[3],nneighi[3];
203 double calold,calnew,caltmp,callist[
MMG3D_LMAX+2];
204 MMG5_int k,kel,iel,ip0,nxp;
208 static int8_t mmgErr0=0;
211 if ( ilists < 2 )
return 0;
241 for (k=0; k<ilists; k++) {
243 iface = lists[k] % 4;
247 assert( 0<=iface && iface<4 &&
"unexpected local face idx");
253 fprintf(stderr,
"\n ## Error: %s: function MMG5_bezierCP return 0.\n",
263 fprintf(stderr,
"\n ## Warning: %s:"
264 " unable to compute optimal position for at least"
265 " 1 point.\n",__func__);
273 det2d = lispoi[1]*gv[1] - lispoi[2]*gv[0];
275 if ( det2d >= 0.0 ) {
276 for (k=0; k<ilists; k++) {
277 detloc = gv[0]*lispoi[3*(k+1)+2] - gv[1]*lispoi[3*(k+1)+1];
278 if ( detloc >= 0.0 ) {
288 for (k=ilists-1; k>=0; k--) {
289 detloc = lispoi[3*k+1]*gv[1] - lispoi[3*k+2]*gv[0];
290 if ( detloc >= 0.0 ) {
301 det2d = -gv[1]*(lispoi[3*(kel+1)+1] - lispoi[3*(kel)+1]) + \
302 gv[0]*(lispoi[3*(kel+1)+2] - lispoi[3*(kel)+2]);
310 det2d = lispoi[3*(kel)+1]*(lispoi[3*(kel+1)+2] - lispoi[3*(kel)+2]) - \
311 lispoi[3*(kel)+2 ]*(lispoi[3*(kel+1)+1] - lispoi[3*(kel)+1]);
318 det2d = lispoi[3*kel+1]*lispoi[3*(kel+1)+2] - lispoi[3*kel+2]*lispoi[3*(kel+1)+1];
323 lambda[1] = lispoi[3*(kel+1)+2]*gv[0] - lispoi[3*(kel+1)+1]*gv[1];
324 lambda[2] = -lispoi[3*(kel)+2]*gv[0] + lispoi[3*(kel)+1]*gv[1];
327 lambda[0] = 1.0 - lambda[1] - lambda[2];
353 k = lists[ilists-1] / 4;
354 iface = lists[ilists-1] % 4;
356 assert( 0<=iface && iface<4 &&
"unexpected local face idx");
358 for( i=0 ; i<3 ; i++ )
359 if ( tt.
v[i] == ip0 )
break;
361 if ( i>=3 )
return 0;
366 calold = calnew = DBL_MAX;
367 for (l=0; l<ilists; l++) {
369 iface = lists[l] % 4;
371 assert( 0<=iface && iface<4 &&
"unexpected local face idx");
373 calold =
MG_MIN(calold,MMG5_caltri(
mesh,met,&tt));
375 for( i=0 ; i<3 ; i++ )
376 if ( tt.
v[i] == ip0 )
break;
379 if ( i>=3 )
return 0;
382 caltmp = MMG5_caltri(
mesh,met,&tt);
388 calnew =
MG_MIN(calnew,caltmp);
416 memcpy(nprev, ncur, 3*
sizeof(
double));
419 if ( calold <
MMG5_EPSOK && calnew <= calold ) {
424 else if (improveSurf && calnew < 1.02*calold) {
427 else if ( calnew < 0.3*calold ) {
433 calold = calnew = DBL_MAX;
434 for (l=0; l<ilistv; l++) {
446 calnew =
MG_MIN(calnew,callist[l]);
449 if ( calold <
MMG5_EPSOK && calnew <= calold ) {
455 else if (improveVol && calnew < calold) {
458 else if ( calnew < 0.3*calold ) {
474 memcpy(m0,&met->
m[0],6*
sizeof(
double));
476 for(l=0; l<ilistv; l++){
477 (&
mesh->
tetra[listv[l]/4])->qual= callist[l];
506 int ilistv,MMG5_int *lists,
int ilists,
int improve,
const uint16_t edgTag){
510 double ll1old,ll2old,l1new,l2new;
511 double o[3],no[3],no2[3],to[3], ncur[3],nprev[3],nneighi[3];
512 double calold,calnew,caltmp;
513 MMG5_int l,iel,ip0,ip1,ip2,ip;
514 uint8_t i,iface,isrid;
518 ip0 = pt->
v[listv[0]%4];
525 assert ( edgTag & p0->
tag );
540 ll1old = MMG5_lenSurfEdg(
mesh,met,ip0,ip1,isrid);
541 ll2old = MMG5_lenSurfEdg(
mesh,met,ip0,ip2,isrid);
543 if ( (!ll1old) || (!ll2old) ) {
570 l1new = MMG5_lenSurfEdg(
mesh,met,0,ip1,isrid);
571 l2new = MMG5_lenSurfEdg(
mesh,met,0,ip2,isrid);
573 if ( (!l1new) || (!l2new) ) {
577 if ( fabs(l2new -l1new) >= fabs(ll2old -ll1old) ) {
586 iel = lists[ilists-1] / 4;
587 iface = lists[ilists-1] % 4;
589 assert( 0<=iface && iface<4 &&
"unexpected local face idx");
591 for( i=0 ; i<3 ; i++ ) {
592 if ( tt.
v[i] == ip0 ) {
607 calold = calnew = DBL_MAX;
608 for( l=0 ; l<ilists ; l++ ){
610 iface = lists[l] % 4;
612 assert( 0<=iface && iface<4 &&
"unexpected local face idx");
614 caltmp = MMG5_caltri(
mesh,met,&tt);
615 calold =
MG_MIN(calold,caltmp);
617 for( i=0 ; i<3 ; i++ ) {
618 if ( tt.
v[i] == ip0 ) {
629 caltmp = MMG5_caltri(
mesh,met,&tt);
635 calnew =
MG_MIN(calnew,caltmp);
665 memcpy(nprev, ncur, 3*
sizeof(
double));
667 if ( calold <
MMG5_EPSOK && calnew <= calold ) {
670 else if ( calnew < calold ) {
679 improve,p0,ip0,isrid,o,no,no2,to);
682 memcpy(&met->
m[6*ip0],&met->
m[0],6*
sizeof(
double));
707 int ilistv, MMG5_int *lists,
int ilists,
int improve){
731 int64_t *listv,
int ilistv, MMG5_int *lists,
int ilists,
755 int64_t *listv,
int ilistv,MMG5_int *lists,
int ilists,
int MMG3D_movePROctree(MMG5_pMesh mesh, MMG3D_pPROctree q, MMG5_int no, double *newVer, double *oldVer)
int MMG5_elementWeight(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTria pt, MMG5_pPoint p0, MMG5_Bezier *pb, double r[3][3], double gv[2])
int MMG5_movbdynompt_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG3D_pPROctree PROctree, int64_t *listv, int ilistv, MMG5_int *lists, int ilists, int improve)
static int MMG3D_movbdycurvept_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG3D_pPROctree PROctree, int64_t *listv, int ilistv, MMG5_int *lists, int ilists, int improve, const uint16_t edgTag)
int MMG5_movbdyregpt_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG3D_pPROctree PROctree, int64_t *listv, int ilistv, MMG5_int *lists, int ilists, int improveSurf, int improveVol)
int MMG5_movbdyrefpt_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG3D_pPROctree PROctree, int64_t *listv, int ilistv, MMG5_int *lists, int ilists, int improve)
int MMG5_movintpt_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG3D_pPROctree PROctree, int64_t *list, int ilist, int improve)
int MMG5_movbdyridpt_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG3D_pPROctree PROctree, int64_t *listv, int ilistv, MMG5_int *lists, int ilists, int improve)
int MMG5_moymet(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTetra pt, double *m1)
static double MMG5_orcal(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int iel)
int MMG5_intridmet(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int ip1, MMG5_int ip2, double s, double v[3], double mr[6])
API headers and documentation for the mmg3d library, for volumetric meshes in 3D.
int MMG3D_movbdycurvept_chckAndUpdate(MMG5_pMesh mesh, MMG5_pSol met, MMG3D_pPROctree PROctree, int64_t *listv, int ilistv, int improve, MMG5_pPoint p0, MMG5_int ip0, uint8_t isrid, double o[3], double no[3], double no2[3], double to[3])
int MMG3D_rotate_surfacicBall(MMG5_pMesh, MMG5_int *, int, MMG5_int, double r[3][3], double *)
int MMG3D_normalAdjaTri(MMG5_pMesh, MMG5_int, int8_t, int, double n[3])
int MMG3D_movbdycurvept_newPosForSimu(MMG5_pMesh, MMG5_pPoint, MMG5_int, MMG5_int, MMG5_int, double, double, uint8_t, const double, double[3], double[3], double[3], double[3], const uint16_t)
void MMG5_tet2tri(MMG5_pMesh mesh, MMG5_int k, int8_t ie, MMG5_Tria *ptt)
int MMG3D_curveEndingPts(MMG5_pMesh, MMG5_int *, int, const uint16_t, MMG5_int, MMG5_int *, MMG5_int *)
int MMG3D_movbdyregpt_geom(MMG5_pMesh, MMG5_int *, const MMG5_int, const MMG5_int, double[3], double[3], double[3], double[3])
static const uint8_t MMG5_iprv2[3]
double MMG5_det4pt(double c0[3], double c1[3], double c2[3], double c3[3])
#define MG_GEO_OR_NOM(tag)
#define MG_GET(flag, bit)
int MMG5_devangle(double *n1, double *n2, double crit)
int MMG5_nortri(MMG5_pMesh mesh, MMG5_pTria pt, double *n)
int MMG5_rotmatrix(double n[3], double r[3][3])
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 surface vertices of an MMG mesh.
Structure to store additional information for the surface tetrahedra of an MMG mesh.