From 3c45c28a668857361dc864b49ec8248f7ee095f7 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Wed, 11 Aug 2010 12:28:09 +0200 Subject: [PATCH] Revision: integral parameter processing (voltage & current calc) revision necessary to keep the object oriented concept consistent for upcoming new integral parameter --- FDTD/processcurrent.cpp | 65 ++++------------------------------------ FDTD/processcurrent.h | 7 ++--- FDTD/processing.cpp | 13 ++++---- FDTD/processing.h | 9 +++++- FDTD/processintegral.cpp | 41 +++++++++++++++++++++++++ FDTD/processintegral.h | 12 +++++++- FDTD/processvoltage.cpp | 36 ++-------------------- FDTD/processvoltage.h | 2 +- 8 files changed, 79 insertions(+), 106 deletions(-) diff --git a/FDTD/processcurrent.cpp b/FDTD/processcurrent.cpp index 2ac1a7d..4a32180 100644 --- a/FDTD/processcurrent.cpp +++ b/FDTD/processcurrent.cpp @@ -22,33 +22,16 @@ ProcessCurrent::ProcessCurrent(Operator* op, Engine* eng) : ProcessIntegral(op, eng) { + m_TimeShift = op->GetTimestep()/2.0; + m_dualMesh = true; } ProcessCurrent::~ProcessCurrent() { } -void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop) +double ProcessCurrent::CalcIntegral() { - if (Op->SnapToMesh(dstart,start,true,m_start_inside)==false) - cerr << "ProcessCurrent::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl; - if (Op->SnapToMesh(dstop,stop,true,m_stop_inside)==false) - cerr << "ProcessCurrent::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl; - - if (g_settings.showProbeDiscretization()) { - cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], true ) << "," - << Op->GetDiscLine( 1, start[1], true ) << "," << Op->GetDiscLine( 2, start[2], true ) << ") -> (" - << Op->GetDiscLine( 0, stop[0], true ) << ","<< Op->GetDiscLine( 1, stop[1], true ) << "," - << Op->GetDiscLine( 2, stop[2], true ) << ")"; - cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> [" - << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; - } -} - -int ProcessCurrent::Process() -{ - if (Enabled==false) return -1; - if (CheckTimestep()==false) return GetNextInterval(); FDTD_FLOAT current=0; int Dump_Dim = 0; @@ -78,7 +61,7 @@ int ProcessCurrent::Process() { cerr << "ProcessCurrent::Process(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << Dump_Dim << ") --> i = 0" << endl; current = 0; - return -1; + return 0.0; } switch (NormDir) @@ -139,45 +122,9 @@ int ProcessCurrent::Process() break; default: //this cannot happen... - return -2; + return 0.0; break; } - // cerr << "ts: " << Eng->numTS << " i: " << current << endl; - current*=m_weight; - - - if (ProcessInterval) - { - if (Eng->GetNumberOfTimesteps()%ProcessInterval==0) - { - TD_Values.push_back(current); - //current is sampled half a timestep later then the voltages - file << setprecision(m_precision) << (0.5 + (double)Eng->GetNumberOfTimesteps())*Op->GetTimestep() << "\t" << current << endl; - } - } - - if (m_FD_Interval) - { - if (Eng->GetNumberOfTimesteps()%m_FD_Interval==0) - { - double T = ((double)Eng->GetNumberOfTimesteps() + 0.5) * Op->GetTimestep(); - for (size_t n=0;n freqs) void Processing::DefineStartStopCoord(double* dstart, double* dstop) { - if (Op->SnapToMesh(dstart,start)==false) + if (Op->SnapToMesh(dstart,start,m_dualMesh,m_start_inside)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl; - if (Op->SnapToMesh(dstop,stop)==false) + if (Op->SnapToMesh(dstop,stop,m_dualMesh,m_stop_inside)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl; if (g_settings.showProbeDiscretization()) { - cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], false ) << "," - << Op->GetDiscLine( 1, start[1], false ) << "," << Op->GetDiscLine( 2, start[2], false ) << ") -> (" - << Op->GetDiscLine( 0, stop[0], false ) << ","<< Op->GetDiscLine( 1, stop[1], false ) << "," - << Op->GetDiscLine( 2, stop[2], false ) << ")"; + cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], m_dualMesh ) << "," + << Op->GetDiscLine( 1, start[1], m_dualMesh ) << "," << Op->GetDiscLine( 2, start[2], m_dualMesh ) << ") -> (" + << Op->GetDiscLine( 0, stop[0], m_dualMesh ) << ","<< Op->GetDiscLine( 1, stop[1], m_dualMesh ) << "," + << Op->GetDiscLine( 2, stop[2], m_dualMesh ) << ")"; cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> [" << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; } diff --git a/FDTD/processing.h b/FDTD/processing.h index 3b721e3..0d093bc 100644 --- a/FDTD/processing.h +++ b/FDTD/processing.h @@ -63,7 +63,11 @@ public: //! Set the dump precision void SetPrecision(unsigned int val) {m_precision = val;} - virtual void DumpBox2File( string vtkfilenameprefix, bool dualMesh = false ) const; //!< dump geometry to file + //! Dump probe geometry to file (will obay main or dual mesh property) + virtual void DumpBox2File( string vtkfilenameprefix) const {DumpBox2File(vtkfilenameprefix,m_dualMesh);} + + //! Dump probe geometry to file + virtual void DumpBox2File( string vtkfilenameprefix, bool dualMesh) const; protected: Operator* Op; @@ -93,6 +97,9 @@ protected: void Dump_FD_Data(vector<_Complex double> value, double factor, string filename); + //! define if given coords are on main or dualMesh (default is false) + bool m_dualMesh; + //! define/store snapped start/stop coords as mesh index unsigned int start[3]; unsigned int stop[3]; diff --git a/FDTD/processintegral.cpp b/FDTD/processintegral.cpp index 8980711..ddf8b6d 100644 --- a/FDTD/processintegral.cpp +++ b/FDTD/processintegral.cpp @@ -16,9 +16,12 @@ */ #include "processintegral.h" +#include +#include ProcessIntegral::ProcessIntegral(Operator* op, Engine* eng) : Processing(op, eng) { + m_TimeShift = 0.0; } ProcessIntegral::~ProcessIntegral() @@ -42,3 +45,41 @@ void ProcessIntegral::FlushData() Dump_FD_Data(FD_Values,1.0/(double)m_FD_SampleCount,m_filename + "_FD"); } +int ProcessIntegral::Process() +{ + if (Enabled==false) return -1; + if (CheckTimestep()==false) return GetNextInterval(); + + FDTD_FLOAT integral=CalcIntegral(); + integral*=m_weight; + + double time = (double)Eng->GetNumberOfTimesteps()*Op->GetTimestep() + m_TimeShift; + + if (ProcessInterval) + { + if (Eng->GetNumberOfTimesteps()%ProcessInterval==0) + { + TD_Values.push_back(integral); + file << setprecision(m_precision) << time << "\t" << integral << endl; + } + } + + if (m_FD_Interval) + { + if (Eng->GetNumberOfTimesteps()%m_FD_Interval==0) + { + double T = time; + for (size_t n=0;n TD_Values; + //! timeshift to be used in TD and FD data, e.g. 0.5*dT in case of current based parameter + double m_TimeShift; + vector TD_Values; vector<_Complex double> FD_Values; }; diff --git a/FDTD/processvoltage.cpp b/FDTD/processvoltage.cpp index 014a3c0..4959c18 100644 --- a/FDTD/processvoltage.cpp +++ b/FDTD/processvoltage.cpp @@ -27,38 +27,8 @@ ProcessVoltage::~ProcessVoltage() { } -int ProcessVoltage::Process() +double ProcessVoltage::CalcIntegral() { - if (Enabled==false) return -1; - if (CheckTimestep()==false) return GetNextInterval(); - - FDTD_FLOAT voltage=CalcLineIntegral(start,stop,0); - voltage*=m_weight; - - if (ProcessInterval) - { - if (Eng->GetNumberOfTimesteps()%ProcessInterval==0) - { - TD_Values.push_back(voltage); - file << setprecision(m_precision) << (double)Eng->GetNumberOfTimesteps()*Op->GetTimestep() << "\t" << voltage << endl; - } - } - - if (m_FD_Interval) - { - if (Eng->GetNumberOfTimesteps()%m_FD_Interval==0) - { - double T = (double)Eng->GetNumberOfTimesteps() * Op->GetTimestep(); - for (size_t n=0;n