56 memcpy(&pttmp ,&trias[ind2],
sizeof(
MMG5_Tria));
57 memcpy(&trias[ind2],&trias[ind1],
sizeof(
MMG5_Tria));
58 memcpy(&trias[ind1],&pttmp ,
sizeof(
MMG5_Tria));
62 perm[ind2] = perm[ind1];
85 SCOTCH_Num *vertTab, *edgeTab, *permVrtTab;
87 MMG5_int vertNbr, nodeGlbIdx, triaIdx, ballTriIdx;
88 MMG5_int j, k, edgeSiz;
89 MMG5_int *vertOldTab, *permNodTab, ntreal, npreal;
100 for(triaIdx = 1 ; triaIdx <
mesh->
nt + 1 ; triaIdx++) {
104 vertOldTab[triaIdx] = ++vertNbr;
118 if (!memset(vertTab, ~0,
sizeof(SCOTCH_Num)*(vertNbr + 2))) {
119 perror(
" ## Memory problem: memset");
138 for(triaIdx = 1 ; triaIdx <
mesh->
nt + 1 ; triaIdx++) {
143 iadr = 3*(triaIdx-1) + 1;
145 for (i=0; i<3; i++) {
146 ballTriIdx = adja[i] / 3;
148 if (!ballTriIdx)
continue;
151 if (vertTab[vertOldTab[triaIdx]] < 0)
152 vertTab[vertOldTab[triaIdx]] = edgeNbr;
155 if (edgeNbr >= edgeSiz) {
156 int oldsize = edgeSiz;
165 edgeTab[edgeNbr++] = vertOldTab[ballTriIdx];
168 vertTab[vertNbr+1] = edgeNbr;
171 for(triaIdx = 1 ; triaIdx <
mesh->
nt + 1 ; triaIdx++) {
175 if (vertTab[vertOldTab[triaIdx]] < 0) {
176 if(vertOldTab[triaIdx] == vertNbr) {
177 fprintf(stderr,
" ## Warning: %s: graph error, no renumbering.\n",
183 if(vertTab[vertOldTab[triaIdx] + 1] > 0)
184 vertTab[vertOldTab[triaIdx]] = vertTab[vertOldTab[triaIdx] + 1];
186 if(vertOldTab[triaIdx]+1 == vertNbr) {
187 fprintf(stderr,
" ## Warning: %s: graph error, no renumbering.\n",
196 }
while((vertTab[vertOldTab[triaIdx] + i] < 0) && ((vertOldTab[triaIdx] + i) < vertNbr));
197 if(vertOldTab[triaIdx] + i == vertNbr) {
198 fprintf(stderr,
" ## Warning: %s: graph error, no renumbering.\n",
204 vertTab[vertOldTab[triaIdx]] = vertTab[vertOldTab[triaIdx] + i];
213 SCOTCH_graphInit(&graf) ;
214 CHECK_SCOTCH(SCOTCH_graphBuild(&graf, (SCOTCH_Num) 1, vertNbr, vertTab+1,
215 NULL, NULL, NULL, edgeNbr, edgeTab+1, NULL),
216 "scotch_graphbuild", 0) ;
221 fprintf(stdout,
"checking graph...\n");
223 CHECK_SCOTCH(SCOTCH_graphCheck(&graf),
"scotch_graphcheck", 0);
237 SCOTCH_graphExit(&graf) ;
247 for (j=1; j<=
mesh->
nt; j++) {
248 if ( !
mesh->
tria[triaIdx].
v[0] )
continue;
250 vertOldTab[triaIdx] = permVrtTab[vertOldTab[triaIdx]];
255 for(triaIdx = 1 ; triaIdx <
mesh->
nt + 1 ; triaIdx++) {
256 while ( vertOldTab[triaIdx] != triaIdx && vertOldTab[triaIdx] )
266 for(triaIdx = 1 ; triaIdx <
mesh->
nt + 1 ; triaIdx++) {
270 if (!ptri->
v[0])
continue;
274 for(j = 0 ; j <= 2 ; j++) {
276 nodeGlbIdx = ptri->
v[j];
278 if ( permNodTab[nodeGlbIdx] )
continue;
284 permNodTab[nodeGlbIdx] = ++npreal;
289 for ( k=1; k<=
mesh->
np; ++k) {
294 if ( permNodTab[k] )
continue;
299 permNodTab[k] = ++npreal;
305 for( triaIdx = 1; triaIdx < ntreal + 1; triaIdx++) {
306 for(j = 0 ; j < 3 ; j++) {
313 for ( k=1; k<=
mesh->
np; ++k ) {
314 permNodGlob[k] = permNodTab[permNodGlob[k]];
319 for (j=1; j<=
mesh->
np; j++) {
320 while ( permNodTab[j] != j && permNodTab[j] )
339 for (k=
mesh->
npnil; k<mesh->npmax-1; k++) {
347 for (k=
mesh->
nenil; k<mesh->ntmax-1; k++) {
MMG5_pMesh MMG5_pSol * sol
int MMGS_hashTria(MMG5_pMesh mesh)
API headers and documentation for the mmgs library.
int MMG5_kPartBoxCompute(SCOTCH_Graph *graf, MMG5_int vertNbr, MMG5_int boxVertNbr, SCOTCH_Num *permVrtTab, MMG5_pMesh mesh)
void MMG5_swapNod(MMG5_pMesh mesh, MMG5_pPoint points, double *sols, MMG5_pSol field, MMG5_int *perm, MMG5_int ind1, MMG5_int ind2, int solsiz)
#define CHECK_SCOTCH(t, m, e)
static void MMG5_swapTri(MMG5_pTria trias, MMG5_int *perm, MMG5_int ind1, MMG5_int ind2)
int MMG5_mmgsRenumbering(int boxVertNbr, MMG5_pMesh mesh, MMG5_pSol sol, MMG5_pSol fields, MMG5_int *permNodGlob)
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
#define MMG5_ADD_MEM(mesh, size, message, law)
#define MMG5_SAFE_REALLOC(ptr, prevSize, newSize, type, message, law)
#define MMG5_DEL_MEM(mesh, ptr)
Structure to store vertices of an MMG mesh.
Structure to store triangles of a MMG mesh.