/* ***********NOTICE********** */ /* */ /* The EMAP finite element modeling codes were created at the */ /* University of Missouri-Rolla Electromagnetic Compatibility Laboratory. */ /* They are intended for use in teaching or research. They may be freely */ /* copied and distributed PROVIDED THE CODE IS NOT MODIFIED IN ANY MANNER.*/ /* */ /* Suggested modifications or questions about these codes can be */ /* directed to Dr. Todd Hubing, Department of Electrical Engineering */ /* University of Missouri-Rolla, Rolla, MO 65401. Principal authors */ /* of these codes are Mr. Mohammad Ali and Mr. Girish Bhat of the */ /* University of Missouri-Rolla. */ /* */ /* Neither the authors nor the University of Missouri makes any warranty, */ /* express or implied, or assumes any legal responsibility for the */ /* accuracy, completeness or usefulness of these codes or any information */ /* distributed with these codes. */ /* */ /* 2/2/95 */ /*************************************************************************** * PROGRAM : Emap3.c (Version 2.02) * LAST UPDATE : February 15, 1995 * DESCRIPTION : A 3-D Vector Finite Element Modeling Code for Analyzing Time Varying Complex Electromagnetic Fields. * INPUT FILE : emap3.in or or 1st argument of emap command * OUTPUT FILE : file(s) specified by input file * ****************************************************************************/ /**************************** Include Files ********************************/ #include #include #include #include #include #include /******************** Dynamic Memory Allocation Functions ******************/ int *INT_Vector(nh) /* Allocates an int vector with range [0 ... nh-1] */ int nh; { int *v; v=(int *)malloc((unsigned) nh*sizeof(int)); return v; } double *FLOAT_Vector(nh) /* Allocates a double vector with range [0 ... nh-1] */ int nh; { double *v; v=(double *)malloc((unsigned) nh*sizeof(double)); return v; } double **FLOAT_Matrix(row,column) /*Allocates a double matrix with range [0..rw-1][0..cl-1]*/ int row,column; { int i;double **m; m=(double **) malloc((unsigned) row*sizeof(double*)); for(i=0;i 2) { fprintf(stderr,"Usage: Emap3 [input_file] \n"); exit(1);} if (argc < 2) { argv[1] = "emap3.in"; strcpy(Ifile, argv[1]); } else strcpy(Ifile, argv[1]); fprintf(stdout, "\nEMAP3 Version 2.02\n\n"); fprintf(stdout, "The input will be read from the file: %s\n", Ifile); InF = fopen(argv[1], "r"); if (InF == NULL) { fprintf(stderr, " Error: Can't open input file.\n"); exit(1); } Read_Input_Pass_1(); ParameterInfo(); HexNode = INT_Matrix(TotNumHexHedron,8); HexEdgeNum = INT_Matrix(TotNumHexHedron,19); RELPerm = FLOAT_Matrix(TotNumHexHedron,2); NodeCord = FLOAT_Matrix(TotNodeNum,3); TetGlobalNodeNum = INT_Matrix(5,4); TetEdgeNum = INT_Matrix(5,6); TetGlobalEdgeEnds = INT_Matrix(TotEdgeNum,2); Read_Input_Pass_2(); AssignGlobalCoorDinates(); AssignHexHedronNodeNumbering(); AssignHexHedronEdgeNumbering(); GBL_Matrix_Data=FLOAT_Matrix(TotEdgeNum,GBL_Matrix_MaxColNos); GBL_Matrix_ColNos=INT_Matrix(TotEdgeNum,GBL_Matrix_MaxColNos); GBL_Matrix_Index=INT_Vector(TotEdgeNum); for(i=0;i3)&&(Count<7)) Row=1; else if(Count>6) Row=2; CoF[Row][Col]=Buff[i][j]; Col++; Col=Col%3; } } Row=0;Col=0;Count=0; CoFs[RowNum][ColNum] =CoF[0][0]*((CoF[1][1]*CoF[2][2])-(CoF[1][2]*CoF[2][1])) -CoF[0][1]*((CoF[1][0]*CoF[2][2])-(CoF[2][0]*CoF[1][2])) +CoF[0][2]*((CoF[1][0]*CoF[2][1])-(CoF[2][0]*CoF[1][1])); if((RowNum+ColNum)%2!=0) CoFs[RowNum][ColNum]*=-1.0; } for(RowNum=0;RowNum<=3;RowNum++) { if (RowNum==0) Col = 3; else if(RowNum==1) Col = 0; else if(RowNum==2) Col = 1; else if(RowNum==3) Col = 2; for(ColNum=0;ColNum<=3;ColNum++) { CoFactor[RowNum][ColNum] = -CoFs[ColNum][Col]; }} } } /*************************************************************************** * FUNCTION : S_Matrix() ****************************************************************************/ void S_Matrix() { int i,j; double Length_i,Length_j,Mult1,Volume; { Volume = TetVolume; Mult1 = (1296.0*Volume*Volume*Volume); for(i=0;i<=5;i++) for(j=0;j<=5;j++) { Length_i = VTXmag(NodeCord[TetGlobalNodeNum[t][edge_end[i][0]]-1], NodeCord[TetGlobalNodeNum[t][edge_end[i][1]]-1]); Length_j = VTXmag(NodeCord[TetGlobalNodeNum[t][edge_end[j][0]]-1], NodeCord[TetGlobalNodeNum[t][edge_end[j][1]]-1]); S_mat[i][j] = ( CoFactor[2][edge_end[i][0]] * CoFactor[3][edge_end[i][1]] - CoFactor[3][edge_end[i][0]] * CoFactor[2][edge_end[i][1]] ) * ( CoFactor[2][edge_end[j][0]] * CoFactor[3][edge_end[j][1]] - CoFactor[3][edge_end[j][0]] * CoFactor[2][edge_end[j][1]] ) + ( CoFactor[3][edge_end[i][0]] * CoFactor[1][edge_end[i][1]] - CoFactor[1][edge_end[i][0]] * CoFactor[3][edge_end[i][1]] ) * ( CoFactor[3][edge_end[j][0]] * CoFactor[1][edge_end[j][1]] - CoFactor[1][edge_end[j][0]] * CoFactor[3][edge_end[j][1]] ) + ( CoFactor[1][edge_end[i][0]] * CoFactor[2][edge_end[i][1]] - CoFactor[2][edge_end[i][0]] * CoFactor[1][edge_end[i][1]] ) * ( CoFactor[1][edge_end[j][0]] * CoFactor[2][edge_end[j][1]] - CoFactor[2][edge_end[j][0]] * CoFactor[1][edge_end[j][1]] ); S_mat[i][j] = (Length_i * Length_j * S_mat[i][j])/ Mult1 ; } } } /*************************************************************************** * FUNCTION : T_Matrix() ****************************************************************************/ void T_Matrix() { int i,j; double Mult1,Length_i,Length_j; Mult1 = 1.0/(720.0 * TetVolume); T_mat[0][0] = ff(1,1) + ff(2,2) - ff(1,2); T_mat[0][1] = 2 * ff(2,3) - ff(2,1) - ff(1,3) + ff(1,1); T_mat[0][2] = 2 * ff(2,4) - ff(2,1) - ff(1,4) + ff(1,1); T_mat[0][3] =-2 * ff(1,3) - ff(2,2) + ff(2,3) + ff(1,2); T_mat[0][4] = 2 * ff(1,4) - ff(2,4) - ff(1,2) + ff(2,2); T_mat[0][5] = ff(2,4) - ff(2,3) - ff(1,4) + ff(1,3); T_mat[1][1] = ff(1,1) + ff(3,3) - ff(1,3); T_mat[1][2] = 2 * ff(3,4) - ff(1,3) - ff(1,4) + ff(1,1); T_mat[1][3] = 2 * ff(1,2) - ff(2,3) - ff(1,3) + ff(3,3); T_mat[1][4] = ff(2,3) - ff(3,4) - ff(1,2) + ff(1,4); T_mat[1][5] =-2 * ff(1,4) - ff(3,3) + ff(1,3) + ff(3,4); T_mat[2][2] = ff(1,1) + ff(4,4) - ff(1,4); T_mat[2][3] = ff(3,4) - ff(2,4) - ff(1,3) + ff(1,2); T_mat[2][4] =-2 * ff(1,2) - ff(4,4) + ff(1,4) + ff(2,4); T_mat[2][5] = 2 * ff(1,3) - ff(3,4) - ff(1,4) + ff(4,4); T_mat[3][3] = ff(3,3) + ff(2,2) - ff(2,3); T_mat[3][4] =-2 * ff(3,4) - ff(2,2) + ff(2,3) + ff(2,4); T_mat[3][5] =-2 * ff(2,4) - ff(3,3) + ff(2,3) + ff(3,4); T_mat[4][4] = ff(2,2) + ff(4,4) - ff(2,4); T_mat[4][5] =-2 * ff(2,3) - ff(4,4) + ff(2,4) + ff(3,4); T_mat[5][5] = ff(3,3) + ff(4,4) - ff(3,4); for(i=0;i<=5;i++) for(j=0;j<=i-1;j++) {T_mat[i][j] = T_mat[j][i];} for(i=0;i<=5;i++) for(j=0;j<=5;j++) { Length_i = VTXmag(NodeCord[TetGlobalNodeNum[t][edge_end[i][0]]-1], NodeCord[TetGlobalNodeNum[t][edge_end[i][1]]-1]); Length_j = VTXmag(NodeCord[TetGlobalNodeNum[t][edge_end[j][0]]-1], NodeCord[TetGlobalNodeNum[t][edge_end[j][1]]-1]); if(i==j) T_mat[i][j] = 2 * Length_i * Length_j * Mult1 * T_mat[i][j]; else T_mat[i][j] = Length_i * Length_j * Mult1 * T_mat[i][j]; T_mat[i][j] = RELPerm[HexNum][0] * T_mat[i][j] ; T_mat[i][j] = WaveNumber*WaveNumber * T_mat[i][j] ; } } /*************************************************************************** * FUNCTION : TetraSubMatrix() ****************************************************************************/ void TetraSubMatrix() { int i,j; for(i=0;i<=5;i++) for(j=0;j<=5;j++) {A_mat[t][i][j]=0.0;} for(i=0;i<=5;i++) for(j=0;j<=5;j++) {A_mat[t][i][j] =4.0*S_mat[i][j]-T_mat[i][j];} for(i=0;i<=5;i++) for(j=0;j<=5;j++) {A_mat[t][i][j] = A_mat[t][i][j] * Sign(TetEdgeNum[t][j]);} for(i=0;i<=5;i++) for(j=0;j<=5;j++) {A_mat[t][i][j] = A_mat[t][i][j] * Sign(TetEdgeNum[t][i]);} } /*************************************************************************** * FUNCTION : FindGlobalMatrix() ****************************************************************************/ void FindGlobalMatrix() { int m,n,k,l,rval; { for(m=0;m<=5;m++) for(n=0;n<=5;n++) { k=absol(TetEdgeNum[t][m])-1; l=absol(TetEdgeNum[t][n])-1; if(fabs(A_mat[t][m][n])>1.0E-10) { rval=Srch_NZ_Element_Column(k,l); if(rval>=0) { GBL_Matrix_Data[k][rval]+=A_mat[t][m][n]; } else { GBL_Matrix_ColNos[k][GBL_Matrix_Index[k]]=l; GBL_Matrix_Data[k][GBL_Matrix_Index[k]]=A_mat[t][m][n]; GBL_Matrix_Index[k]++; } } } } } /*************************************************************************** * FUNCTION : CountHalfBandWidth() ****************************************************************************/ void CountHalfBandWidth() { short int i,j,k,l,ColDiff,Val; { for(i=0;i=0) { ColDiff=j-i; if(HalfBandWidth<=(ColDiff+1)) {HalfBandWidth=(ColDiff+1);} } } } } } /*************************************************************************** * FUNCTION : PartitionGlobalMatrix() ****************************************************************************/ void PartitionGlobalMatrix() { int i,j,k,l,ColDiff,val,g=0; { for(i=0;i=0)) { ColDiff=j-i; HalfBandMatrix[i+1][ColDiff+1]=GBL_Matrix_Data[k][val]; } else { ColDiff=j-i; HalfBandMatrix[i+1][ColDiff+1]=0.0;} } } for(i=0;i=0) { FORC_Matrix_ColNos[i][g]=j; FORC_Matrix_Data[i][g]=(GBL_Matrix_Data[k][val]); g++; } } g=0; } g=0; } } /*************************************************************************** * FUNCTION : ComputeRHSVector() ****************************************************************************/ void ComputeRHSVector() { int Count_i,Count_j,Srch_Ptr=0; double Temp_Buff,Multpl; { for(Count_i=0;Count_i=0) { Temp_Buff=FORC_Matrix_Data[Count_i][Srch_Ptr];} else { Temp_Buff=0.0;} if(Temp_Buff!=0.0) { Multpl=Temp_Buff*ForcdValue[Count_j][0]; RHSVector[Count_i]+=Multpl; } } RHSVector[Count_i]=RHSVector[Count_i]*-1.0; } } } /*************************************************************************** * FUNCTION : BandMatrixSolver() ****************************************************************************/ void BandMatrixSolver() { int Count_i,Count_j,Count_k,Count_l,Count_m,Count_n; int Row_Number,Column_Number; double Pivot_Emement,Multpl_1,Multpl_2; { Row_Number=TotInnerEdgeNum; Column_Number=HalfBandWidth; for(Count_i=1;Count_i<=Row_Number;Count_i++) { for(Count_j=2;Count_j<=Column_Number;Count_j++) { if(HalfBandMatrix[Count_i][Count_j]!=0.0) { Pivot_Emement=HalfBandMatrix[Count_i][Count_j]/HalfBandMatrix[Count_i][1]; Count_n=Count_i+Count_j-1; Count_l=0; for(Count_k=Count_j;Count_k<=Column_Number;Count_k++) { Count_l=Count_l+1; Multpl_1=Pivot_Emement*HalfBandMatrix[Count_i][Count_k]; HalfBandMatrix[Count_n][Count_l] -= Multpl_1; } Multpl_2=Pivot_Emement*RHSVector[Count_i-1]; RHSVector[Count_n-1] -= Multpl_2; } } } RHSVector[Row_Number-1] /= HalfBandMatrix[Row_Number][1]; for(Count_m=2;Count_m<=Row_Number;Count_m++) { Count_i=Row_Number+1-Count_m; for(Count_j=2;Count_j<=Column_Number;Count_j++) { if(HalfBandMatrix[Count_i][Count_j]!=0.0) { Count_k=Count_i+Count_j-1; Multpl_1=HalfBandMatrix[Count_i][Count_j]*RHSVector[Count_k-1]; RHSVector[Count_i-1] -= Multpl_1; } } RHSVector[Count_i-1] /= HalfBandMatrix[Count_i][1]; } } } /*************************************************************************** * FUNCTION : Read_Input_Pass_1() ****************************************************************************/ void Read_Input_Pass_1() { int x1, y1, z1, x2, y2, z2, OutF_Count=0, output_flag=0; char type[20], att1[20], att2[18], att3[18], att4[18]; float tmp1, tmp2, cell_dim = 1; double freq = 0; char buffer[80]; Min_X = 10000; Min_Y=10000; Min_Z=10000; Max_X = 0; Max_Y=0; Max_Z=0; while (fgets(buffer, 80, InF)) { if (buffer[0] == '#') continue; if(!strncmp(buffer, "default_output",14)) { sscanf(buffer, "%s%s", type, Out_FileName0); OutF_0=fopen(Out_FileName0, "w"); if (OutF_0 == NULL) {fprintf(stderr, " Error: Can't create default output file %s\n", Out_FileName0); exit(1);} output_flag=1; continue; } if(!strncmp(buffer, "celldim", 7)) { sscanf(buffer, "%s%g%s", type, &tmp1, att1); if (!strcmp(att1, "cm")) tmp2=0.01; else if(!strcmp(att1, "m")) tmp2=1; else if(!strcmp(att1, "mm")) tmp2=0.001; else if(!strcmp(att1, "in")) tmp2=0.0254; else {fprintf(stderr,"ERROR: unrecognized cell dimension.\n"); exit(1);} cell_dim=tmp1*tmp2; continue; } if(sscanf(buffer, "%s%d%d%d%d%d%d%s%s%s%s", type, &x1, &y1, &z1, &x2, &y2, &z2, att1, att2, att3, att4)>2) { if(!strcmp(type,"boundary")) {fprintf(stderr, "\n\nERROR: boundary keyword is not allowed by EMAP3 \n"); exit(1);} if(!strcmp(type, "dielectric")) { if (x1Max_X) Max_X=x1; if (x2>Max_X) Max_X=x2; if (y1Max_Y) Max_Y=y1; if (y2>Max_Y) Max_Y=y2; if (z1Max_Z) Max_Z=z1; if (z2>Max_Z) Max_Z=z2; if((x1==x2)||(y1==y2)||(z1==z2)) {fprintf(stderr, "ERROR: diel thickness is not finite./n"); exit(1); } continue; } if(!strcmp(type, "box")) { if((x1==x2)||(y1==y2)||(z1==z2)){ fprintf(stderr, "ERROR: box dimension is invalid."); exit(1);} if (x1Max_X) Max_X=x1; if (x2>Max_X) Max_X=x2; if (y1Max_Y) Max_Y=y1; if (y2>Max_Y) Max_Y=y2; if (z1Max_Z) Max_Z=z1; if (z2>Max_Z) Max_Z=z2; continue; } if(!strcmp(type,"conductor")) { if (x1Max_X) Max_X=x1; if (x2>Max_X) Max_X=x2; if (y1Max_Y) Max_Y=y1; if (y2>Max_Y) Max_Y=y2; if (z1Max_Z) Max_Z=z1; if (z2>Max_Z) Max_Z=z2; continue; } if(!strcmp(type, "aperture")) { if((x1!=x2) & (y1!=y2) & (z1!=z2)){fprintf(stderr,"ERROR: aperture dimension is invalid.\n"); exit(1); } if(((x1==x2)&&(y1==y2))||((x1==x2)&&(z1==z2))||((z1==z2)&&(y1==y2))) {fprintf(stderr, "ERROR: aperture dimension is invalid.\n"); exit(1); } continue; } if(!strcmp(type, "seam")) continue; if(!strcmp(type,"esource")) { if (x1Max_X) Max_X=x1; if (x2>Max_X) Max_X=x2; if (y1Max_Y) Max_Y=y1; if (y2>Max_Y) Max_Y=y2; if (z1Max_Z) Max_Z=z1; if (z2>Max_Z) Max_Z=z2; freq = atof(att1); if((x1==x2)&&(y1==y2)&&(z1==z2)) { fprintf(stderr, "ERROR: esource cannot be defined at a point.\n"); exit(1); } if ((att2[0] != 'x') && (att2[0] != 'y') && (att2[0] != 'z')){ fprintf(stderr, "ERROR: unrecognized polarization of esource statement %c\n",att2[0]); exit(1); } continue; } if(!strcmp(type, "msource")) { if (x1Max_X) Max_X=x1; if (x2>Max_X) Max_X=x2; if (y1Max_Y) Max_Y=y1; if (y2>Max_Y) Max_Y=y2; if (z1Max_Z) Max_Z=z1; if (z2>Max_Z) Max_Z=z2; freq = atof(att1); continue; } if(!strcmp(type, "efield_output")) { switch (OutF_Count) { case 0: {OutF_Count=1; strcpy(Out_FileName1, att1); OutF_1=fopen(Out_FileName1,"w"); break;} case 1: {if(strcmp(att1, Out_FileName1)){OutF_Count=2; strcpy(Out_FileName2, att1); OutF_2=fopen(Out_FileName2,"w");} break; } case 2: {if(strcmp(att1, Out_FileName1) && strcmp(att1, Out_FileName2)) {OutF_Count=3; strcpy(Out_FileName3, att1); OutF_3=fopen(Out_FileName3,"w");} break; } case 3: {if((strcmp(att1, Out_FileName1) && strcmp(att1, Out_FileName2)) && strcmp(att1, Out_FileName3)) {fprintf(stderr, "ERROR: too many different files specified by efield_output commands \n"); exit(1);} break; } } output_flag=1; continue; } fprintf(stderr,"Warning: Unrecognized Keyword %s\n", type); } /*end of if*/ OperateFreq = freq; } /* end of while */ if(freq == 0) fprintf(stderr,"\nWARNING: The input file does not specify a source, code will not produce output!\n\n"); if(output_flag == 0) fprintf(stderr,"\nWARNING: The input file does not contain an output statement, code will not produce output!\n\n"); rewind(InF); XdiM = Max_X - Min_X; YdiM = Max_Y - Min_Y; ZdiM = Max_Z - Min_Z; OperateFreq = freq; CellDimension = cell_dim; } /*************************************************************************** * FUNCTION : Read_Input_Pass_2() ****************************************************************************/ void Read_Input_Pass_2() { void swap(); void edge(); void deter_edge(); void CountEdgeType(); int i, j, k, x1, y1, z1, x2, y2, z2, nn, tmp; char type[20], att1[20], att2[18], att3[18], att4[18]; char buffer[80]; /* Dynamically allocate memory for large variables */ Epsilon= (double *) calloc( TotEdgeNum*sizeof(double), sizeof(double)); Sigma= (double *) calloc( TotEdgeNum*sizeof(double), sizeof(double)); EdgeStatus = (double *) calloc( TotEdgeNum*sizeof(double), sizeof(double)); ForceStat= (int *) calloc( TotEdgeNum*sizeof(int), sizeof(int)); xn = (int **) calloc(TotEdgeNum*sizeof(int),sizeof(int)); for(i=0;i2) { if(!strcmp(type, "boundary")) { continue; } if(!strcmp(type, "efield_output")) { if((x1Max_X)||(x2Max_X)) {fprintf(stderr,"ERROR: efield_output parameter out of range.\n"); exit(1);} if((y1Max_Y)||(y2Max_Y)) {fprintf(stderr,"ERROR: efield_output parameter out of range.\n"); exit(1);} if((z1Max_Z)||(z2Max_Z)) {fprintf(stderr,"ERROR: efield_output parameter out of range.\n"); exit(1);} continue; } if(!strcmp(type, "dielectric")) { if (x2= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 1\n",scratch); fflush(stdout); } if ((j==0)||(k==0)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch=xn[nn][1]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 2\n",scratch); fflush(stdout); } if ((i==0)||(k==0)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch=xn[nn][2]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 3\n",scratch); fflush(stdout); fflush(stdout); } if (k==0) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][3]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 4\n",scratch); fflush(stdout); } if ((i==(XdiM-1))||(k==0)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][4]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 5\n",scratch); fflush(stdout); } if ((j==(YdiM-1))||(k==0)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][5]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 6\n",scratch); fflush(stdout); } if ((j==0)||(i==0)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][6]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 7\n",scratch); fflush(stdout); } if (j==0) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][7]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 8\n",scratch); fflush(stdout); } if ((i==(XdiM-1))||(j==0)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][8]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 9\n",scratch); fflush(stdout); } if (i==0) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][9]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 10\n",scratch); fflush(stdout); } if (i==(XdiM-1)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][10]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 11\n",scratch); fflush(stdout); } if ((j==(YdiM-1))||(i==0)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][11]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 12\n",scratch); fflush(stdout); } if (j==(YdiM-1)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][12]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 13\n",scratch); fflush(stdout); } if ((i==(XdiM-1))||(j==(YdiM-1))) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][13]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 14\n",scratch); fflush(stdout); } if ((k==(ZdiM-1))||(j==0)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][14]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 15\n",scratch); fflush(stdout); } if ((k==(ZdiM-1))||(i==0)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][15]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 16\n",scratch); fflush(stdout); } if (k==(ZdiM-1)) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][16]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 17\n",scratch); fflush(stdout); } if ((i==(XdiM-1))||(k==(ZdiM-1))) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; scratch = xn[nn][17]; if ((scratch >= TotEdgeNum) || (scratch < 0)) { printf("scratch=%d out of bounds spot 18\n",scratch); fflush(stdout); } if ((j==(YdiM-1))||(k==(ZdiM-1))) EdgeStatus[scratch] = -2; else EdgeStatus[scratch] = -1; return; } /*************************************************************************** * FUNCTION : Produce_Output() ****************************************************************************/ void Produce_Output() { int i, j, k, x1, y1, z1, x2, y2, z2, Count_i, dflag=0; char type[20], att1[20], att2[8], att3[8], att4[8]; char buffer[80]; FILE *OutF; EfieldData = (double *) calloc( TotEdgeNum*sizeof(double), sizeof(double)); for(Count_i=0;Count_i