From 0e1eba5028b3a557a40d685544fe5fb970df952a Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Thu, 11 Mar 2010 10:48:00 +0100 Subject: [PATCH] Processing updates: CalcLineIntegral --- FDTD/engine.h | 1 + FDTD/processfields_td.cpp | 2 +- FDTD/processing.cpp | 31 +++++++++++++++++++++++++++++++ FDTD/processing.h | 2 ++ FDTD/processvoltage.cpp | 21 +-------------------- 5 files changed, 36 insertions(+), 21 deletions(-) diff --git a/FDTD/engine.h b/FDTD/engine.h index 5a8da91..a8420e5 100644 --- a/FDTD/engine.h +++ b/FDTD/engine.h @@ -5,6 +5,7 @@ class Engine { + friend class Processing; friend class ProcessVoltage; friend class ProcessCurrent; friend class ProcessFieldsTD; diff --git a/FDTD/processfields_td.cpp b/FDTD/processfields_td.cpp index bb6096d..8d1a591 100644 --- a/FDTD/processfields_td.cpp +++ b/FDTD/processfields_td.cpp @@ -14,7 +14,7 @@ ProcessFieldsTD::~ProcessFieldsTD() void ProcessFieldsTD::DumpCellInterpol(ofstream &file) { - if (DumpType==0) + if (DumpType==0) { //create array FDTD_FLOAT**** E_T = Create_N_3DArray(numDLines); diff --git a/FDTD/processing.cpp b/FDTD/processing.cpp index 09e89b9..be436c9 100644 --- a/FDTD/processing.cpp +++ b/FDTD/processing.cpp @@ -29,6 +29,37 @@ void Processing::DefineStartStopCoord(double* dstart, double* dstop) if (Op->SnapToMesh(dstop,stop)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapping problem, check stop value!!" << endl; } +double Processing::CalcLineIntegral(unsigned int* start, unsigned int* stop, int field) +{ + double result=0; + FDTD_FLOAT**** array; + if (field==0) + array=Eng->volt; + else if (field==1) + array=Eng->curr; + else return 0.0; + + unsigned int pos[3]={start[0],start[1],start[2]}; +// cerr << Eng->volt[1][pos[0]][pos[1]][pos[2]] << endl; + for (int n=0;n<3;++n) + { + if (start[n]volt[n][pos[0]][pos[1]][pos[2]] << endl; + } + } + else + { + for (;pos[n]>stop[n];--pos[n]) + result-=array[n][pos[0]][pos[1]][pos[2]]; + } + } + return result; +} + void ProcessingArray::AddProcessing(Processing* proc) { diff --git a/FDTD/processing.h b/FDTD/processing.h index ee67041..0133147 100644 --- a/FDTD/processing.h +++ b/FDTD/processing.h @@ -34,6 +34,8 @@ protected: unsigned int start[3]; unsigned int stop[3]; + + double CalcLineIntegral(unsigned int* start, unsigned int* stop, int field); }; class ProcessingArray diff --git a/FDTD/processvoltage.cpp b/FDTD/processvoltage.cpp index d3683ce..9b0c525 100644 --- a/FDTD/processvoltage.cpp +++ b/FDTD/processvoltage.cpp @@ -25,26 +25,7 @@ int ProcessVoltage::Process() { if (Enabled==false) return -1; if (CheckTimestep()==false) return GetNextInterval(); - FDTD_FLOAT voltage=0; - unsigned int pos[3]={start[0],start[1],start[2]}; -// cerr << Eng->volt[1][pos[0]][pos[1]][pos[2]] << endl; - for (int n=0;n<3;++n) - { - if (start[n]volt[n][pos[0]][pos[1]][pos[2]]; -// cerr << n << " " << pos[0] << " " << pos[1] << " " << pos[2] << " " << Eng->volt[n][pos[0]][pos[1]][pos[2]] << endl; - } - - } - else - { - for (;pos[n]>stop[n];--pos[n]) - voltage-=Eng->volt[n][pos[0]][pos[1]][pos[2]]; - } - } + FDTD_FLOAT voltage=CalcLineIntegral(start,stop,0); // cerr << voltage << endl; voltages.push_back(voltage); file << (double)Eng->numTS*Op->GetTimestep() << "\t" << voltage << endl;