-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring MMG5_chkBdryTria #259
Refactoring MMG5_chkBdryTria #259
Conversation
src/mmg3d/hash_3d.c
Outdated
if ( k!=nbl ) { | ||
pttnew = &mesh->tria[nbl]; | ||
memcpy(pttnew,ptt,sizeof(MMG5_Tria)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we can remove / extract this from the loop and just delete extra triangles inside the loop.
Then, after the loop (so outside the MMG5_chkbdryTria_deleteExtraBoundaries()
func), it should be possible to :
- travel triangles
- detect the deleted tria
- pack the array accordingly
- update the perm array for ParMmg only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like that :
nt=0; nbl=1;
for (k=1; k<=mesh->nt; k++) {
ptt = &mesh->tria[k];
if ( !MG_EOK(ptt) ) continue;
++nt;
if ( k!=nbl ) {
pttnew = &mesh->tria[nbl];
memcpy(pttnew,ptt,sizeof(MMG5_Tria));
if ( permtria ) {
permtria[k] = nbl;
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or more elegant but also more error-prone (I am not sure that it works ;-) )
k = 1;
do {
ptt = &mesh->tria[k];
if ( !MG_EOK(ptt) ) {
pttnew = &mesh->tria[mesh->nt];
assert( ptt && pttnew && MG_EOK(pttnew) );
memcpy(ptt,pttnew,sizeof(MMG5_Tria));
if ( permtria ) permtria[mesh->nt] = k;
ptt->v[0] = 0;
mesh->nt--;
}
}
while ( ++k < mesh->nt );
src/mmg3d/hash_3d.c
Outdated
if ( k!=nbl ) { | ||
pttnew = &mesh->tria[nbl]; | ||
memcpy(pttnew,ptt,sizeof(MMG5_Tria)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like that :
nt=0; nbl=1;
for (k=1; k<=mesh->nt; k++) {
ptt = &mesh->tria[k];
if ( !MG_EOK(ptt) ) continue;
++nt;
if ( k!=nbl ) {
pttnew = &mesh->tria[nbl];
memcpy(pttnew,ptt,sizeof(MMG5_Tria));
if ( permtria ) {
permtria[k] = nbl;
}
}
}
} | ||
else if ( j > 0 ) { | ||
/* the face already exists in the tria table */ | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that here we can insert the tria deletion in order to perform the compression of triangle array outside the loop (see comment where the array is currently packed).
With something like : ptt->v[0] = 0; MG_EOK(ptt) should be false.
src/mmg3d/hash_3d.c
Outdated
if ( k!=nbl ) { | ||
pttnew = &mesh->tria[nbl]; | ||
memcpy(pttnew,ptt,sizeof(MMG5_Tria)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or more elegant but also more error-prone (I am not sure that it works ;-) )
k = 1;
do {
ptt = &mesh->tria[k];
if ( !MG_EOK(ptt) ) {
pttnew = &mesh->tria[mesh->nt];
assert( ptt && pttnew && MG_EOK(pttnew) );
memcpy(ptt,pttnew,sizeof(MMG5_Tria));
if ( permtria ) permtria[mesh->nt] = k;
ptt->v[0] = 0;
mesh->nt--;
}
}
while ( ++k < mesh->nt );
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #259 +/- ##
===========================================
+ Coverage 43.96% 43.98% +0.01%
===========================================
Files 179 179
Lines 54102 54124 +22
Branches 10249 10252 +3
===========================================
+ Hits 23786 23805 +19
Misses 22599 22599
- Partials 7717 7720 +3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This update refactorizes the function
MMG_chkBdryTria
. It is now written as a sequence of several sub-functions. It does not modify the behaviour or features of mmg. However, this update is necessary for parmmg, in order to take into account the fact that we pack themesh->tria
array when extra triangles are deleted from it.This update primarily ensures the maintainability of the code and avoids redundancy in mmg and parmmg.