Skip to content

Commit

Permalink
Fix usage of Scotch in Lagrangian motion 3D: permute displacement fie…
Browse files Browse the repository at this point in the history
…ld (but remember it is nullified after Lagrangian step).
  • Loading branch information
lcirrottola committed Nov 16, 2020
1 parent a6f0bac commit f5d7e8e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
37 changes: 26 additions & 11 deletions src/common/librnbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,32 @@ void MMG5_swapNod(MMG5_pMesh mesh,MMG5_pPoint points, double* sols,

/* swap solution fields (for ParMmg) */
if ( field ) {
for ( i=0; i<mesh->nsols; ++i ) {
psl = field+i;
assert ( psl && psl->m );

pslsiz = psl->size;
addr1 = ind1*pslsiz;
addr2 = ind2*pslsiz;

memcpy(&soltmp , psl->m + addr2,pslsiz*sizeof(double));
memcpy(psl->m + addr2, psl->m + addr1,pslsiz*sizeof(double));
memcpy(psl->m + addr1, &soltmp ,pslsiz*sizeof(double));
if( mesh->nsols ) { /* swap solution fields (for ParMmg) */
for ( i=0; i<mesh->nsols; ++i ) {
psl = field+i;
assert ( psl && psl->m );

pslsiz = psl->size;
addr1 = ind1*pslsiz;
addr2 = ind2*pslsiz;

memcpy(&soltmp , psl->m + addr2,pslsiz*sizeof(double));
memcpy(psl->m + addr2, psl->m + addr1,pslsiz*sizeof(double));
memcpy(psl->m + addr1, &soltmp ,pslsiz*sizeof(double));
}
} else { /* swap a single displacement field (for Lagrangian motion) */
psl = field;
assert ( psl );

if( psl->m ) { /* it is null after Lagrangian step */
pslsiz = psl->size;
addr1 = ind1*pslsiz;
addr2 = ind2*pslsiz;

memcpy(&soltmp , psl->m + addr2,pslsiz*sizeof(double));
memcpy(psl->m + addr2, psl->m + addr1,pslsiz*sizeof(double));
memcpy(psl->m + addr1, &soltmp ,pslsiz*sizeof(double));
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/mmg3d/libmmg3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ int MMG3D_mmg3dmov(MMG5_pMesh mesh,MMG5_pSol met, MMG5_pSol disp) {
}

/* renumerotation if available */
if ( !MMG5_scotchCall(mesh,met,NULL,NULL) )
if ( !MMG5_scotchCall(mesh,met,disp,NULL) )
{
if ( !MMG5_unscaleMesh(mesh,met,disp) ) _LIBMMG5_RETURN(mesh,met,disp,MMG5_STRONGFAILURE);
MMG5_RETURN_AND_PACK(mesh,met,disp,MMG5_LOWFAILURE);
Expand Down Expand Up @@ -1674,7 +1674,7 @@ int MMG3D_mmg3dmov(MMG5_pMesh mesh,MMG5_pSol met, MMG5_pSol disp) {
}

/* renumerotation if available */
if ( !MMG5_scotchCall(mesh,met,NULL,NULL) )
if ( !MMG5_scotchCall(mesh,met,disp,NULL) )
{
if ( !MMG5_unscaleMesh(mesh,met,disp) ) _LIBMMG5_RETURN(mesh,met,disp,MMG5_STRONGFAILURE);
MMG5_RETURN_AND_PACK(mesh,met,disp,MMG5_LOWFAILURE);
Expand Down Expand Up @@ -1708,9 +1708,9 @@ int MMG3D_mmg3dmov(MMG5_pMesh mesh,MMG5_pSol met, MMG5_pSol disp) {
}

/* last renum to give back a good numbering to the user */
if ( !MMG5_scotchCall(mesh,met,NULL,NULL) )
if ( !MMG5_scotchCall(mesh,met,disp,NULL) )
{
if ( !MMG5_unscaleMesh(mesh,met,NULL) ) _LIBMMG5_RETURN(mesh,met,disp,MMG5_STRONGFAILURE);
if ( !MMG5_unscaleMesh(mesh,met,disp) ) _LIBMMG5_RETURN(mesh,met,disp,MMG5_STRONGFAILURE);
MMG5_RETURN_AND_PACK(mesh,met,disp,MMG5_LOWFAILURE);
}

Expand Down

0 comments on commit f5d7e8e

Please sign in to comment.