void tfsfUpdate(Grid *g){ /* check if tfsfinit has run */ if (tfsfBoundary <= 0) { fprintf(stderr, "tfsfinit must be called first.\n" "Boundary location must be a positive int.\n"); exit(-1); } char filename[100], base[20]="ezinc"; FILE *source; sprintf(filename, "%s.%d",base,Time); source = fopen(filename, "w"); fprintf(source, "%g\n", ezInc(Time, 0)); fclose(source); //corret hy adajcent to tfsf boundary Hy(tfsfBoundary) -= ezInc(Time, 0.0) * Chye(tfsfBoundary); // correct ez adjacnet to tfsf boundary Ez(tfsfBoundary + 1) += ezInc(Time + 0.5, -0.5); return; }
void tfsfUpdate(Grid *g) { /* check if tfsfInit() has been called */ if (tfsfBoundary <= 0) { fprintf(stderr,"tfsfUpdate: tfsfInit must be called before tfsfUpdate.\n""Boundary location must be set to positive value.\n"); exit(-1); } /* correct Hy adjacent to TFSF boundary */ Hy(tfsfBoundary) -= ezInc(Time, 0.0) * Chye(tfsfBoundary); /* correct Ez adjacent to TFSF boundary */ Ez(tfsfBoundary + 1) += ezInc(Time + 0.5, -0.5); return; }
int main() { Grid *g; ALLOC_1D(g, 1, Grid); // allocate memory for Grid gridInit(g); // initialize the grid ezIncInit(g); snapshotInit2d(g); // initialize snapshots /* do time stepping */ for (Time = 0; Time < MaxTime; Time++) { updateH2d(g); // update magnetic field updateE2d(g); // update electric field Ez(SizeX / 2, SizeY / 2) = ezInc(Time, 0.0); // add a source snapshot2d(g); // take a snapshot (if appropriate) } // end of time-stepping return 0; }
int main() { Grid *g; /*@ \label{improved2A} @*/ ALLOC_1D(g, 1, Grid); // allocate memory for Grid /*@ \label{improved2B} @*/ gridInit2(g); // initialize the grid /*@ \label{improved2C} @*/ ezIncInit(g); // initialize source function /*@ \label{improved2H} @*/ /* do time stepping */ for (Time = 0; Time < MaxTime; Time++) { /*@ \label{improved2D} @*/ updateH2(g); // update magnetic field /*@ \label{improved2E} @*/ updateE2(g); // update electric field /*@ \label{improved2F} @*/ Ez(0) = ezInc(Time, 0.0); // apply source function /*@ \label{improved2Z} @*/ printf("%g\n", Ez(50)); // print output /*@ \label{improved2G} @*/ } // end of time-stepping return 0; }