Skip to content

Commit

Permalink
Merge pull request #280 from laetitia-m/feature/overlap
Browse files Browse the repository at this point in the history
Change tag type (int  -> uint) and add the tag MG_OVERLAP (for ParMmg)
  • Loading branch information
Algiane authored Sep 10, 2024
2 parents bf6bcab + 176f3b2 commit 88d9d1e
Show file tree
Hide file tree
Showing 30 changed files with 213 additions and 92 deletions.
25 changes: 25 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/lib/x86_64-linux-gnu/openmpi/include",
"/usr/local/include/vtk-9.2/**",
"/home/lmottet/Work/Software/ParMmg/**",
"/home/lmottet/Work/Software/mmg/**",
"/home/lmottet/Work/Software/mmg/build-dev/include/**",
"/home/lmottet/Work/Software/mmg/build-dev/lib/**",
"/home/lmottet/Work/Software/mmg/build-*/include/**",
"/home/lmottet/Work/Software/mmg/build-*/lib/**"

],
"defines": [],
"compilerPath": "/usr/bin/mpirun",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
23 changes: 23 additions & 0 deletions cmake/testing/code/mmg_get_tagname.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
#include <stdlib.h>

#include "libmmgcommon_private.h"

int main() {

uint16_t tag;
char *tags_name;

tag = 0;
printf("%s\n", MMG5_Get_tagName(tag));

tag = UINT16_MAX;
printf("%s\n", MMG5_Get_tagName(tag));

tag &= ~MG_NUL;
printf("%s\n", MMG5_Get_tagName(tag));


return 0;

}
2 changes: 1 addition & 1 deletion cmake/testing/code/ridge-preservation-in-ls-mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int main(int argc,char *argv[]) {
MMG5_pEdge ped = &mesh1->edge[k];
if ( ped->tag & MG_GEO ) {
MMG5_int ref;
int16_t tag;
uint16_t tag;
if ( !MMG5_hGet(&hash,ped->a,ped->b,&ref,&tag) ) {
continue;
}
Expand Down
61 changes: 60 additions & 1 deletion cmake/testing/mmg_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,65 @@ ADD_TEST(NAME mmg_CommandLineAni_${SHRT_EXEC}
${MMG_CI_TESTS}/SurfEdges_house/housebad.meshb
-out ${CTEST_OUTPUT_DIR}/mmg_SurfEdges_OptimAni_${SHRT_EXEC}.o.meshb)

ENDFOREACH()

# Unit tests
## Really not clean: as the organization of the functions definition in .c files
## and headers declatation in .h files is very badly done (and has never been
## cleaned), and we try to test a private function of Mmg, we have to include
## almost all the .c/.h files to be able to build this unit test.
##
## Not built and tested on windows due to unallowed definition of dllimport data
##

ENDFOREACH()
IF ( NOT WIN32 )
FILE(
GLOB
mmg_get_tagname_files
${mmg2d_library_files}
${mmg3d_library_files}
${mmgs_library_files}
${PROJECT_SOURCE_DIR}/cmake/testing/code/mmg_get_tagname.c
)

ADD_EXECUTABLE ( mmg_get_tagname ${mmg_get_tagname_files} )

ADD_DEPENDENCIES ( mmg_get_tagname copy_mmgcommon_headers
copy_3d_headers copy_2d_headers copy_s_headers )


IF ( CMAKE_VERSION VERSION_LESS 2.8.12 )
INCLUDE_DIRECTORIES ( BEFORE
${MMGCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include
${PROJECT_BINARY_DIR}/src/common )
if ( SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF )
INCLUDE_DIRECTORIES ( AFTER ${SCOTCH_INCLUDE_DIRS} )
ENDIF()

IF( ELAS_FOUND AND NOT USE_ELAS MATCHES OFF )
# Set flags for building test program
INCLUDE_DIRECTORIES(AFTER ${ELAS_INCLUDE_DIR})
SET( GET_TAGNAME_LIBRARIES ${ELAS_LINK_FLAGS} ${ELAS_LIBRARY} ${LIBRARIES})

ENDIF ( )


ELSE ( )
TARGET_INCLUDE_DIRECTORIES ( mmg_get_tagname BEFORE PUBLIC
${MMGCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include
${PROJECT_BINARY_DIR}/src/common
)
if ( SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF )
target_include_directories( mmg_get_tagname BEFORE PUBLIC ${SCOTCH_INCLUDE_DIRS} )
ENDIF ( )

IF( ELAS_FOUND AND NOT USE_ELAS MATCHES OFF )
target_include_directories( mmg_get_tagname AFTER PUBLIC ${ELAS_INCLUDE_DIR} )
SET( GET_TAGNAME_LIBRARIES ${ELAS_LINK_FLAGS} ${ELAS_LIBRARY} ${LIBRARIES})
ENDIF ( )

ENDIF ( )

TARGET_LINK_LIBRARIES ( mmg_get_tagname PRIVATE ${GET_TAGNAME_LIBRARIES} )

ENDIF ( )
9 changes: 7 additions & 2 deletions src/common/API_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ const char* MMG5_Get_typeName(enum MMG5_type typ)
}
}

const char* MMG5_Get_tagName(int tag)
const char* MMG5_Get_tagName(uint16_t tag)
{
static char tags_name[1024];

Expand Down Expand Up @@ -791,7 +791,12 @@ const char* MMG5_Get_tagName(int tag)

if ( tag & MG_PARBDY) {
strcat(tags_name,"Parbdy ");
}
}

if ( tag & MG_OVERLAP) {
strcat(tags_name,"Overlap ");
}

strcat(tags_name,"tag(s).");

return tags_name;
Expand Down
2 changes: 1 addition & 1 deletion src/common/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ int MMG5_hashUpdate(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k) {
* tag. If the edge exist, add the new tag to the already stored tags.
*
*/
int MMG5_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash, MMG5_int a,MMG5_int b,int16_t tag) {
int MMG5_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash, MMG5_int a,MMG5_int b,uint16_t tag) {
MMG5_hedge *ph;
MMG5_int key;
MMG5_int ia,ib,j;
Expand Down
2 changes: 1 addition & 1 deletion src/common/libmmgcommon_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ LIBMMG_CORE_EXPORT int MMG5_Compute_constantSize(MMG5_pMesh mesh,MMG5_pSol met,d
*
* \warning for debug purpose, no thread safe.
*/
const char* MMG5_Get_tagName(int tag);
const char* MMG5_Get_tagName(uint16_t tag);

/**
* \param mesh pointer to the mesh structure.
Expand Down
22 changes: 11 additions & 11 deletions src/common/libmmgtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ typedef struct {
the unused points)*/
MMG5_int flag; /*!< Flag to know if we have already treated the point */
MMG5_int s;
int16_t tag; /*!< Contains binary flags : if \f$tag=23=16+4+2+1\f$, then
uint16_t tag; /*!< Contains binary flags : if \f$tag=23=16+4+2+1\f$, then
the point is \a MG_REF, \a MG_GEO, \a MG_REQ and \a MG_BDY */
int8_t tagdel; /*!< Tag for delaunay */
} MMG5_Point;
Expand All @@ -313,7 +313,7 @@ typedef struct {
MMG5_int ref; /*!< Reference of the edge */
MMG5_int base; /*!< 2Donly: used to store the tria+ tria edge indices
that allow to access to the edge */
int16_t tag; /*!< Binary flags */
uint16_t tag; /*!< Binary flags */
} MMG5_Edge;
typedef MMG5_Edge * MMG5_pEdge;

Expand Down Expand Up @@ -345,7 +345,7 @@ typedef struct {
MMG5_int edg[3]; /*!< edg[i] contains the ref of the \f$i^{th}\f$ edge
of triangle */
MMG5_int flag;
int16_t tag[3]; /*!< tag[i] contains the tag associated to the
uint16_t tag[3]; /*!< tag[i] contains the tag associated to the
\f$i^{th}\f$ edge of triangle */
} MMG5_Tria;
typedef MMG5_Tria * MMG5_pTria;
Expand Down Expand Up @@ -375,7 +375,7 @@ typedef struct {
MMG5_int base;
MMG5_int edg[4]; /*!< edg[i] contains the ref of the \f$i^{th}\f$ edge
of quadrangle */
int16_t tag[4]; /*!< tag[i] contains the tag associated to the
uint16_t tag[4]; /*!< tag[i] contains the tag associated to the
\f$i^{th}\f$ edge of quadrangle */
} MMG5_Quad;
typedef MMG5_Quad * MMG5_pQuad;
Expand Down Expand Up @@ -414,7 +414,7 @@ typedef struct {
tetrahedron (only for tetrahedra that are adjacent to
surfaces) */
MMG5_int flag;
int16_t tag;
uint16_t tag;
} MMG5_Tetra;
typedef MMG5_Tetra * MMG5_pTetra;

Expand All @@ -427,9 +427,9 @@ typedef struct {
\f$i^{th}\f$ vertex of the tetrahedron;*/
MMG5_int edg[6]; /*!< edg[i] contains the reference of the
\f$i^{th}\f$ edge of the tetrahedron */
int16_t ftag[4]; /*!< ftag[i] contains the tag associated to the
uint16_t ftag[4]; /*!< ftag[i] contains the tag associated to the
\f$i^{th}\f$ face of the tetrahedron */
int16_t tag[6]; /*!< tag[i] contains the tag associated to the
uint16_t tag[6]; /*!< tag[i] contains the tag associated to the
\f$i^{th}\f$ edge of the tetrahedron */
int8_t ori; /*!< Orientation of the triangles of the tetrahedron:
the $\f$i^{th}\f$ bit of ori is set to 0 when the
Expand Down Expand Up @@ -473,7 +473,7 @@ typedef struct {
MMG5_int flag;
MMG5_int xpr; /*!< Index of the surface \ref MMG5_xPrism associated to
the prism*/
int8_t tag;
uint8_t tag;
} MMG5_Prism;
typedef MMG5_Prism * MMG5_pPrism;

Expand All @@ -488,9 +488,9 @@ typedef struct {
* edg[0]={0,1},edg[1]={0,2},edg[2]={0,3},edg[3]={1,2},
* edg[4]={1,4},edg[5]={2,5},edg[6]={3,4},edg[7]={3,5},
* edg[8]={4,5}*/
int16_t ftag[5]; /*!< ftag[i] contains the tag associated to the
uint16_t ftag[5]; /*!< ftag[i] contains the tag associated to the
\f$i^{th}\f$ face of the prism */
int16_t tag[9]; /*!< tag[i] contains the tag associated to the
uint16_t tag[9]; /*!< tag[i] contains the tag associated to the
\f$i^{th}\f$ edge of the prism */
} MMG5_xPrism;
typedef MMG5_xPrism * MMG5_pxPrism;
Expand Down Expand Up @@ -572,7 +572,7 @@ typedef struct {
MMG5_int b; /*!< Second extremity of edge */
MMG5_int ref; /*!< Reference or idx (2D) of edge */
MMG5_int nxt; /*!< Next element of hash table */
int16_t tag; /*!< tag of edge */
uint16_t tag; /*!< tag of edge */
} MMG5_hgeom;

/**
Expand Down
5 changes: 3 additions & 2 deletions src/common/mmgcommon_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ extern "C" {
#define MG_OLDPARBDY (1 << 11) /**< 2048 old parallel boundary */
#define MG_PARBDYBDY (1 << 12) /**< 4096 parallel boundary over a boundary */
#define MG_PARBDY (1 << 13) /**< 8192 parallel boundary */
#define MG_NUL (1 << 14) /**< 16384 vertex removed */
#define MG_OVERLAP (1 << 14) /**< 16384 elements on overlap */
#define MG_NUL (1 << 15) /**< 32768 vertex removed */

/* binary tags for local parameters */
#define MG_Vert (1 << 0 ) /**< 1 local parameter applied over vertex */
Expand Down Expand Up @@ -676,7 +677,7 @@ 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_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,int16_t k);
int MMG5_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,uint16_t k);
MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b);
int MMG5_hashNew(MMG5_pMesh mesh, MMG5_Hash *hash,MMG5_int hsiz,MMG5_int hmax);
int MMG5_intmetsavedir(MMG5_pMesh mesh, double *m,double *n,double *mr);
Expand Down
2 changes: 1 addition & 1 deletion src/mmg2d/analys_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int MMG2D_setadj(MMG5_pMesh mesh, int8_t init_cc) {
MMG5_pTria pt,pt1;
MMG5_pQuad pq;
MMG5_int *pile,*adja,ipil,k,kk,ncc,ip1,ip2,nr,nref;
int16_t tag;
uint16_t tag;
int8_t i,ii,i1,i2;

if ( !mesh->nt ) {
Expand Down
2 changes: 1 addition & 1 deletion src/mmg2d/libmmg2d_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static const unsigned int MMG2D_idir[5] = {0,1,2,0,1};

/* Prototypes */
/*zaldy*/
MMG5_int MMG2D_newPt(MMG5_pMesh mesh,double c[2],int16_t tag);
MMG5_int MMG2D_newPt(MMG5_pMesh mesh,double c[2],uint16_t tag);
void MMG2D_delPt(MMG5_pMesh mesh,MMG5_int ip) ;
void MMG5_delEdge(MMG5_pMesh mesh,MMG5_int iel);
MMG5_int MMG2D_newElt(MMG5_pMesh mesh);
Expand Down
2 changes: 1 addition & 1 deletion src/mmg2d/zaldy_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


/* Create a new vertex in the mesh, and return its number */
MMG5_int MMG2D_newPt(MMG5_pMesh mesh,double c[2],int16_t tag) {
MMG5_int MMG2D_newPt(MMG5_pMesh mesh,double c[2],uint16_t tag) {
MMG5_pPoint ppt;
MMG5_int curpt;

Expand Down
2 changes: 1 addition & 1 deletion src/mmg3d/analys_3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int MMG5_setadj(MMG5_pMesh mesh){
MMG5_pTria pt,pt1;
MMG5_int *adja,*adjb,adji1,adji2,*pile,iad,ipil,ip1,ip2,gen;
MMG5_int k,kk,iel,jel,nvf,nf,nr,nm,nt,nre,nreq,ncc,ned,ref;
int16_t tag;
uint16_t tag;
int8_t i,ii,i1,i2,ii1,ii2,voy;

nvf = nf = ncc = ned = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/mmg3d/anisomovpt_3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ int MMG5_movbdyregpt_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG3D_pPROctree PROctre
*/
static inline
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 int16_t edgTag){
int ilistv,MMG5_int *lists, int ilists,int improve,const uint16_t edgTag){
MMG5_pTetra pt;
MMG5_pPoint p0;
MMG5_Tria tt;
Expand Down
14 changes: 7 additions & 7 deletions src/mmg3d/boulep_3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int MMG5_boulenm(MMG5_pMesh mesh,MMG5_int start,int ip,int iface,
double dd,nt[3];
int nr,nnm;
MMG5_int base,nump,k,*adja,piv,nvstart,aux,na,nb,adj,fstart,ip0,ip1;
int16_t tag;
uint16_t tag;
int8_t iopp,ipiv,indb,inda,i,isface;
int8_t indedg[4][4] = { {-1,0,1,2}, {0,-1,3,4}, {1,3,-1,5}, {2,4,5,-1} };

Expand Down Expand Up @@ -1176,11 +1176,11 @@ int MMG5_bouletrid(MMG5_pMesh mesh,MMG5_int start,int iface,int ip,int *il1,MMG5
*/
static inline
int MMG3D_settag_oneDir(MMG5_pMesh mesh,MMG5_int start, MMG5_int na, MMG5_int nb,
int16_t tag,int edg, MMG5_int piv,MMG5_int adj) {
uint16_t tag,int edg, MMG5_int piv,MMG5_int adj) {
MMG5_pTetra pt;
MMG5_pxTetra pxt;
MMG5_int *adja;
int16_t taginit;
uint16_t taginit;
int8_t i;

while ( adj && (adj != start) ) {
Expand Down Expand Up @@ -1231,11 +1231,11 @@ int MMG3D_settag_oneDir(MMG5_pMesh mesh,MMG5_int start, MMG5_int na, MMG5_int n
* travelling its shell.
*
*/
int MMG5_settag(MMG5_pMesh mesh,MMG5_int start,int ia,int16_t tag,int edg) {
int MMG5_settag(MMG5_pMesh mesh,MMG5_int start,int ia,uint16_t tag,int edg) {
MMG5_pTetra pt;
MMG5_pxTetra pxt;
MMG5_int na,nb,*adja,adj,piv;
int16_t taginit;
uint16_t taginit;

assert( start >= 1 );
pt = &mesh->tetra[start];
Expand Down Expand Up @@ -1298,7 +1298,7 @@ int MMG5_settag(MMG5_pMesh mesh,MMG5_int start,int ia,int16_t tag,int edg) {
*/
static inline
int MMG3D_deltag_oneDir(MMG5_pMesh mesh,MMG5_int start, MMG5_int na, MMG5_int nb,
int16_t tag,MMG5_int piv,MMG5_int adj) {
uint16_t tag,MMG5_int piv,MMG5_int adj) {
MMG5_pTetra pt;
MMG5_pxTetra pxt;
MMG5_int *adja;
Expand Down Expand Up @@ -1344,7 +1344,7 @@ int MMG3D_deltag_oneDir(MMG5_pMesh mesh,MMG5_int start, MMG5_int na, MMG5_int n
* shell.
*
*/
int MMG5_deltag(MMG5_pMesh mesh,MMG5_int start,int ia,int16_t tag) {
int MMG5_deltag(MMG5_pMesh mesh,MMG5_int start,int ia,uint16_t tag) {
MMG5_pTetra pt;
MMG5_pxTetra pxt;
MMG5_int na,nb,*adja,adj,piv;
Expand Down
Loading

0 comments on commit 88d9d1e

Please sign in to comment.