diff --git a/FDTD/processfields.cpp b/FDTD/processfields.cpp index bb10899..49214c7 100644 --- a/FDTD/processfields.cpp +++ b/FDTD/processfields.cpp @@ -110,9 +110,12 @@ double ProcessFields::CalcTotalEnergy() { for (pos[2]=0;pos[2]numLines[2];++pos[2]) { - energy+=fabs(Eng->volt[0][pos[0]][pos[1]][pos[2]] * Eng->curr[0][pos[0]][pos[1]][pos[2]]); - energy+=fabs(Eng->volt[1][pos[0]][pos[1]][pos[2]] * Eng->curr[1][pos[0]][pos[1]][pos[2]]); - energy+=fabs(Eng->volt[2][pos[0]][pos[1]][pos[2]] * Eng->curr[2][pos[0]][pos[1]][pos[2]]); + energy+=fabs(Eng->volt[0][pos[0]][pos[1]][pos[2]] * Eng->curr[1][pos[0]][pos[1]][pos[2]]); + energy+=fabs(Eng->volt[0][pos[0]][pos[1]][pos[2]] * Eng->curr[2][pos[0]][pos[1]][pos[2]]); + energy+=fabs(Eng->volt[1][pos[0]][pos[1]][pos[2]] * Eng->curr[0][pos[0]][pos[1]][pos[2]]); + energy+=fabs(Eng->volt[1][pos[0]][pos[1]][pos[2]] * Eng->curr[2][pos[0]][pos[1]][pos[2]]); + energy+=fabs(Eng->volt[2][pos[0]][pos[1]][pos[2]] * Eng->curr[0][pos[0]][pos[1]][pos[2]]); + energy+=fabs(Eng->volt[2][pos[0]][pos[1]][pos[2]] * Eng->curr[1][pos[0]][pos[1]][pos[2]]); } } } diff --git a/FDTD/processing.cpp b/FDTD/processing.cpp index f4d16a8..34e19dd 100644 --- a/FDTD/processing.cpp +++ b/FDTD/processing.cpp @@ -94,7 +94,7 @@ void ProcessingArray::DeleteAll() int ProcessingArray::Process() { - int nextProcess=1e100; + int nextProcess=maxInterval; //this could be done nicely in parallel?? for (size_t i=0;i ProcessArray; }; diff --git a/openems.cpp b/openems.cpp index 499dcf6..e8834a8 100644 --- a/openems.cpp +++ b/openems.cpp @@ -173,7 +173,7 @@ int openEMS::SetupFDTD(const char* file) //*************** setup processing ************// cout << "Setting up processing..." << endl; - PA = new ProcessingArray(); + PA = new ProcessingArray(Nyquist); double start[3]; double stop[3]; @@ -274,11 +274,13 @@ void openEMS::RunFDTD() if (t_diff>4) { currE = ProcField.CalcTotalEnergy(); - if ((currE>0) && (currE>maxE)) + if (currE>maxE) maxE=currE; cout << "Timestep: " << setw(12) << currTS << " (" << setw(6) << setprecision(2) << std::fixed << (double)currTS/(double)NrTS*100.0 << "%)" ; cout << " with currently " << setw(6) << setprecision(1) << std::fixed << speed*(double)(currTS-prevTS)/t_diff << " MCells/s" ; - cout << " --- Energy: ~" << setw(6) << setprecision(2) << std::scientific << currE << " (decrement: " << setw(6) << setprecision(2) << std::fixed << fabs(10.0*log10(currE/maxE)) << "dB)" << endl; + if (maxE) + change = currE/maxE; + cout << " --- Energy: ~" << setw(6) << setprecision(2) << std::scientific << currE << " (decrement: " << setw(6) << setprecision(2) << std::fixed << fabs(10.0*log10(change)) << "dB)" << endl; prevTime=currTime; prevTS=currTS; }