// does Cuthill-McKee algorithm as described in Hoole; #include #include #include #include #include "fkn.h" #include "fknDlg.h" #include "complex.h" #include "mesh.h" #include "spars.h" #include "FemmeDocCore.h" #define muo 1.2566370614359173e-6 BOOL CFemmeDocCore::SortElements() { // Comb Sort -- see http://en.wikipedia.org/wiki/Comb_sort int *Score; int i,j,k,gap; CElement e; Score=(int*)calloc(NumEls,sizeof(int)); for(k=0;k 1) { gap=(gap*10)/13; if ((gap==10) || (gap==9)) gap=11; } //a single "comb" over the input list for(j=0,i=0;(j+gap)Score[j+gap]) { k=j+gap; i=Score[k];Score[k]=Score[j];Score[j]=i; e=meshele[k];meshele[k]=meshele[j];meshele[j]=e; i=1; } } }while((gap>1)&&(i>0)); free(Score); return TRUE; } BOOL CFemmeDocCore::Cuthill() { FILE *fp; int i,j,k,n0,n1,n; int newwide,*newnum,**ocon; int *numcon,*nxtnum; CNode swap; char infile[256]; // allocate storage nxtnum=(int *)calloc(NumNodes,sizeof(int)); newnum=(int *)calloc(NumNodes,sizeof(int)); numcon=(int *)calloc(NumNodes,sizeof(int)); ocon=(int **)calloc(NumNodes,sizeof(int *)); // initialize node array; for(i=0;inewwide) { newwide=abs(newnum[n0]-ocon[n0][i]); } } BandWidth=newwide+1; // } // free up the variables that we needed during the routine.... free(numcon); free(nxtnum); free(ocon[0]); free(ocon); // new mapping remains in newnum; // apply this mapping to elements first. for(i=0;i