part_7.br

来自「The Finite Difference Time Domain Method」· BR 代码 · 共 45 行

BR
45
字号
		// Copy the proper streams back into C arrays 
		// so we can output them

		// Check which is the last streams updated		

	        if(i%2==0) {
			streamWrite(Ez, outputEz);
			streamWrite(Hx, outputHx);
			streamWrite(Hy, outputHy);
		} else {
			streamWrite(o_Ez, outputEz);
			streamWrite(o_Hx, outputHx);
			streamWrite(o_Hy, outputHy);
		}


		// Close The Observation and Data Files		
		fclose (pFile);
		fclose (pFile2);
		
		// Output the field states into a text file
		pFile = fopen ("Ezdata.txt","wt");
		pFile2 = fopen ("Hxdata.txt","wt");
		pFile3 = fopen ("Hydata.txt","wt");

		for (j=0; j<ny; j++) {
			for (i=0; i<nx; i++) {
				fprintf (pFile,"%e ",outputEz[nx*j+i]);
		                fprintf (pFile2,"%e ",outputHx[nx*j+i]);
                		fprintf (pFile3,"%e ",outputHy[nx*j+i]);
			}
			fprintf (pFile,"\n");
			fprintf (pFile2,"\n");
			fprintf (pFile3,"\n");
		}
	}

	// Close Field Files
	fclose (pFile);
	fclose (pFile2);
	fclose (pFile3);
	printf("Program complete\n");
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?