Skip to content
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

Wrap splits functions - for ParMmg convenience #225

Merged
merged 20 commits into from
Nov 7, 2023

Conversation

laetitia-m
Copy link
Contributor

@laetitia-m laetitia-m commented Oct 16, 2023

  1. Wrap the splits functions used in LS mode (split1, split2sf, split3cone and split4op) for ParMmg convenience. In the splits, the configuration is determined based on the vertices indices. In ParMmg, we need to use the global vertices numbering instead of the local (in term of proc) vertices numbering: to allow this, split functions have been modified to be able to specify the tetra vertices numbering as argument. This change has no impact on mmg.
  2. Rename some split configuration functions for consistency (e.g. MMG3D_configSplit3op becomes MMG3D_split3op_cfg).

@Algiane Algiane self-assigned this Oct 23, 2023
@Algiane Algiane self-requested a review October 23, 2023 07:59
Copy link
Member

@Algiane Algiane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I have few remarks on the factorization choice. It can be discussed tomorrow if needed.

Best

* \return 1 if success, 0 if fail (edge is not found).
*
* Update the index of the new point stored along the edge \f$[a;b]\f$
* If ls mode in ParMmg:: update the index of the new point in internal edge communicator;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "::" -> ":"


return 0;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this function be used in Mmg? If not, I think that we should move it into ParMmg (and rename it PMMG_hashUpdate_all) with the adding of a remark in the MMG5_hashUpdate function saying that an equivalent function that updates both the k and s fields has been added to ParMmg and can be moved into Mmg if we ever need it in Mmg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MMG5_hashUpdate_all has been removed from mmg and replaced by PMMG_hashUpdate_all in ParMmg.

Comment on lines 559 to 601
/**
* \param hash pointer toward the hash table of edges.
* \param a index of the first extremity of the edge.
* \param b index of the second extremity of the edge.
* \param k index of new point along the edge [a,b].
* \param s If ls mode in ParMmg:: index of new point in internal edge communicator;
* otherwise, the value stored in variable s.
* \return 1 if success, 0 if fail (edge is not found).
*
* Find the index of the new point stored along the edge \f$[a;b]\f$
* If ls mode in ParMmg:: find the index of the new point in internal edge communicator;
* otherwise, find the value stored in variable s.
*
*/
MMG5_int MMG5_hashGet_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int *k,MMG5_int *s) {
MMG5_hedge *ph;
MMG5_int key;
MMG5_int ia,ib;

if ( !hash->item ) return 0;

ia = MG_MIN(a,b);
ib = MG_MAX(a,b);
key = (MMG5_KA*(int64_t)ia + MMG5_KB*(int64_t)ib) % hash->siz;
ph = &hash->item[key];

if ( !ph->a ) return 0;
if ( ph->a == ia && ph->b == ib ) {
*k = ph->k;
*s = ph->s;
return 1;
}
while ( ph->nxt ) {
ph = &hash->item[ph->nxt];
if ( ph->a == ia && ph->b == ib ) {
*k = ph->k;
*s = ph->s;
return 1;
}
}
return 0;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment: If not used in Mmg, I think that it is better to move this inside ParMmg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MMG5_hashGet_all has been removed from mmg and replaced by PMMG_hashGet_all in ParMmg.

@@ -676,8 +676,10 @@ typedef struct MMG5_iNode_s {
MMG5_int MMG5_hashFace(MMG5_pMesh,MMG5_Hash*,MMG5_int,MMG5_int,MMG5_int,MMG5_int);
int MMG5_hashEdge(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k);
int MMG5_hashUpdate(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k);
int MMG5_hashUpdate_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k,MMG5_int s);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clean if we choose to move the function defs into ParMmg

int MMG5_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,int16_t k);
MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b);
MMG5_int MMG5_hashGet_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int *k,MMG5_int *s);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clean if we choose to move the function defs into ParMmg

* \return 0 if fail, 1 otherwise
*
* Split 1 edge of tetra \a k.
*
*/
int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp) {
int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If vGlobNum is not used (because there are no ambiguous configs in the face splitting), I think that we can avoid this function redefinition and just let the old MMG5_split1 function unchanged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, MMG5_split1 has been kept as it was.

@@ -991,17 +1013,17 @@ int MMG5_split1b(MMG5_pMesh mesh, MMG5_pSol met,int64_t *list, int ret, MMG5_int

/**
* \param flag flag to detect the splitting configuration
* \param v indices of the tetra nodes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* \param v indices of the tetra nodes (global node indices if called from ParMmg)

* \param met pointer toward the metric structure.
* \param k index of element to split.
* \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i.
* \param vGlobNum vertices indices of the tetra k.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* \param vGlobNum vertices indices of the tetra k (global vertices indices if we come from ParMmg)

int MMG3D_split1_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]);
int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp);
int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't need the global numbering for this function, I think that we can remove the MMG5_split1_globNum function (for sake of readability).

@Algiane Algiane added kind: refactoring needs refactoring part: mmg3d mmg3d specific labels Nov 7, 2023
@Algiane Algiane merged commit 62340b7 into MmgTools:develop Nov 7, 2023
22 checks passed
@Algiane
Copy link
Member

Algiane commented Nov 7, 2023

Thanks

@laetitia-m laetitia-m deleted the feature/split-vertices branch November 7, 2023 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: refactoring needs refactoring part: mmg3d mmg3d specific
Development

Successfully merging this pull request may close these issues.

2 participants