55 MMG5_int boxNbr, vertIdx;
56 SCOTCH_Num logMaxVal, SupMaxVal, InfMaxVal, maxVal;
58 SCOTCH_Num *sortPartTb;
63 boxNbr = vertNbr / boxVertNbr;
64 if (boxNbr * boxVertNbr != vertNbr) {
70 CHECK_SCOTCH(SCOTCH_stratInit(&strat),
"scotch_stratInit", 0) ;
72 CHECK_SCOTCH(SCOTCH_archCmplt(&arch, boxNbr),
"scotch_archCmplt", 0) ;
75 CHECK_SCOTCH(SCOTCH_archVcmplt(&arch),
"scotch_archVcmplt", 0) ;
77 sprintf(s,
"m{vert=%" MMG5_PRId
",low=r{job=t,map=t,poli=S,sep=m{vert=80,low=h{pass=10}f{bal=0.0005,move=80},asc=f{bal=0.005,move=80}}}}", vertNbr / boxVertNbr);
78 CHECK_SCOTCH(SCOTCH_stratGraphMap(&strat, s),
"scotch_stratGraphMap", 0) ;
84 if ( 0!=SCOTCH_graphMap(graf, &arch, &strat, sortPartTb) ) {
85 perror(
"scotch_graphMap");
96 maxVal = sortPartTb[0];
98 for (vertIdx = vertNbr - 1 ; vertIdx >= 0 ; vertIdx--) {
99 sortPartTb[2*vertIdx] = sortPartTb[vertIdx];
100 sortPartTb[2*vertIdx+1] = vertIdx + 1;
102 if (sortPartTb[vertIdx] > maxVal)
103 maxVal = sortPartTb[vertIdx];
110 while ( maxVal > 0) {
116 InfMaxVal = logMaxVal << logMaxVal;
117 SupMaxVal = (logMaxVal << (logMaxVal + 1)) - 1;
120 for (vertIdx = 0 ; vertIdx < vertNbr ; vertIdx++) {
121 while (!(sortPartTb[2*vertIdx] >= InfMaxVal && sortPartTb[2*vertIdx] <= SupMaxVal)) {
122 sortPartTb[2*vertIdx] <<= 1;
132 for (vertIdx = 0; vertIdx < vertNbr ; vertIdx++) {
133 permVrtTab[sortPartTb[2*vertIdx + 1]] = vertIdx + 1;
136 SCOTCH_stratExit(&strat) ;
137 SCOTCH_archExit(&arch) ;
159 MMG5_pSol field,MMG5_int* perm,MMG5_int ind1, MMG5_int ind2,
int solsiz) {
164 MMG5_int
tmp,addr2,addr1;
167 memcpy(&ptttmp ,&points[ind2],
sizeof(
MMG5_Point));
168 memcpy(&points[ind2],&points[ind1],
sizeof(
MMG5_Point));
169 memcpy(&points[ind1],&ptttmp ,
sizeof(
MMG5_Point));
175 memcpy(&soltmp ,&sols[addr2],solsiz*
sizeof(
double));
176 memcpy(&sols[addr2],&sols[addr1],solsiz*
sizeof(
double));
177 memcpy(&sols[addr1],&soltmp ,solsiz*
sizeof(
double));
185 assert ( psl && psl->
m );
191 memcpy(&soltmp , psl->
m + addr2,pslsiz*
sizeof(
double));
192 memcpy(psl->
m + addr2, psl->
m + addr1,pslsiz*
sizeof(
double));
193 memcpy(psl->
m + addr1, &soltmp ,pslsiz*
sizeof(
double));
204 memcpy(&soltmp , psl->
m + addr2,pslsiz*
sizeof(
double));
205 memcpy(psl->
m + addr2, psl->
m + addr1,pslsiz*
sizeof(
double));
206 memcpy(psl->
m + addr1, &soltmp ,pslsiz*
sizeof(
double));
213 perm[ind2] = perm[ind1];
236 static int8_t mmgWarn = 0;
237 static int8_t mmgError = 0;
244 fprintf(stderr,
"\n ## Warning: %s: fail to determine scotch version."
245 " No renumbering.\n",__func__);
253 fprintf(stdout,
" -- RENUMBERING. \n");
257 fprintf(stderr,
"\n ## Error: %s: Unable to renumber mesh. "
258 "Try to run without renumbering option (-rn 0).\n",
266 fprintf(stdout,
" -- PHASE RENUMBERING COMPLETED. \n");
270 if ( !MMG5_chkmsh(
mesh,1,0) )
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)
int MMG5_scotchCall(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol fields, MMG5_int *permNodGlob)
#define CHECK_SCOTCH(t, m, e)
int _SCOTCHintSort2asc1(SCOTCH_Num *sortPartTb, MMG5_int vertNbr)
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
#define MMG5_ADD_MEM(mesh, size, message, law)
#define MMG5_DEL_MEM(mesh, ptr)
Structure to store vertices of an MMG mesh.