From 0f4a78cdbf66b3081941c63eed70cd6c42403a8d Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 28 Jun 2010 19:45:19 +0200 Subject: [PATCH] new ProcessingIntegral as abstract base class to voltage and current processing --- FDTD/processcurrent.cpp | 22 ++++---------------- FDTD/processcurrent.h | 11 +++------- FDTD/processing.cpp | 10 +++++++++ FDTD/processintegral.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ FDTD/processintegral.h | 40 ++++++++++++++++++++++++++++++++++++ FDTD/processvoltage.cpp | 21 +++---------------- FDTD/processvoltage.h | 11 ++-------- openEMS.pro | 2 ++ 8 files changed, 108 insertions(+), 53 deletions(-) create mode 100644 FDTD/processintegral.cpp create mode 100644 FDTD/processintegral.h diff --git a/FDTD/processcurrent.cpp b/FDTD/processcurrent.cpp index f7517f2..49be042 100644 --- a/FDTD/processcurrent.cpp +++ b/FDTD/processcurrent.cpp @@ -20,13 +20,12 @@ #include #include -ProcessCurrent::ProcessCurrent(Operator* op, Engine* eng) : Processing(op, eng) +ProcessCurrent::ProcessCurrent(Operator* op, Engine* eng) : ProcessIntegral(op, eng) { } ProcessCurrent::~ProcessCurrent() { - ProcessCurrent::FlushData(); } void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop) @@ -46,16 +45,6 @@ void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop) } } -void ProcessCurrent::InitProcess() -{ - m_filename = m_Name; - OpenFile(m_filename); - FD_currents.clear(); - for (size_t n=0;nnumTS << " i: " << current << endl; current*=m_weight; + if (ProcessInterval) { if (Eng->GetNumberOfTimesteps()%ProcessInterval==0) { - v_current.push_back(current); + 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; } @@ -174,7 +164,7 @@ int ProcessCurrent::Process() double T = ((double)Eng->GetNumberOfTimesteps() + 0.5) * Op->GetTimestep(); for (size_t n=0;n v_current; - vector<_Complex double> FD_currents; - void WriteFDCurrents(); +protected: }; #endif // PROCESSCURRENT_H diff --git a/FDTD/processing.cpp b/FDTD/processing.cpp index 1856670..ee7bbb5 100644 --- a/FDTD/processing.cpp +++ b/FDTD/processing.cpp @@ -275,11 +275,21 @@ void Processing::DumpBox2File( string vtkfilenameprefix, bool dualMesh ) const void Processing::Dump_FD_Data(vector<_Complex double> value, double factor, string filename) { + if (value.size()==0) + return; + if (value.size()!=m_FD_Samples.size()) + { + cerr << "Processing::Dump_FD_Data: Error: Complex value and frequency vector have different size! This should never happend!!!" << endl; + return; + } ofstream file; file.open( filename.c_str() ); if (!file.is_open()) cerr << "Can't open file: " << filename << endl; + time_t rawTime; + time(&rawTime); + file << "%dump by openEMS @" << ctime(&rawTime) << "%frequency\treal\timag\n"; for (size_t n=0;n. +*/ + +#include "processintegral.h" + +ProcessIntegral::ProcessIntegral(Operator* op, Engine* eng) : Processing(op, eng) +{ +} + +ProcessIntegral::~ProcessIntegral() +{ + ProcessIntegral::FlushData(); +} + + +void ProcessIntegral::InitProcess() +{ + m_filename = m_Name; + OpenFile(m_filename); + FD_Values.clear(); + for (size_t n=0;n. +*/ + +#ifndef PROCESSINTEGRAL_H +#define PROCESSINTEGRAL_H + +#include "processing.h" + +//! Abstract base class for integral parameter processing +class ProcessIntegral : public Processing +{ +public: + virtual ~ProcessIntegral(); + + virtual void InitProcess(); + virtual void FlushData(); + +protected: + ProcessIntegral(Operator* op, Engine* eng); + + vector TD_Values; + + vector<_Complex double> FD_Values; +}; + +#endif // PROCESSINTEGRAL_H diff --git a/FDTD/processvoltage.cpp b/FDTD/processvoltage.cpp index 20e1805..014a3c0 100644 --- a/FDTD/processvoltage.cpp +++ b/FDTD/processvoltage.cpp @@ -19,22 +19,12 @@ #include #include -ProcessVoltage::ProcessVoltage(Operator* op, Engine* eng) : Processing(op, eng) +ProcessVoltage::ProcessVoltage(Operator* op, Engine* eng) : ProcessIntegral(op, eng) { } ProcessVoltage::~ProcessVoltage() { - ProcessVoltage::FlushData(); -} - -void ProcessVoltage::InitProcess() -{ - m_filename = m_Name; - OpenFile(m_filename); - FD_voltages.clear(); - for (size_t n=0;nGetNumberOfTimesteps()%ProcessInterval==0) { - voltages.push_back(voltage); + TD_Values.push_back(voltage); file << setprecision(m_precision) << (double)Eng->GetNumberOfTimesteps()*Op->GetTimestep() << "\t" << voltage << endl; } } @@ -61,7 +51,7 @@ int ProcessVoltage::Process() double T = (double)Eng->GetNumberOfTimesteps() * Op->GetTimestep(); for (size_t n=0;n voltages; - - vector<_Complex double> FD_voltages; - void WriteFDVoltages(); }; #endif // PROCESSVOLTAGE_H diff --git a/openEMS.pro b/openEMS.pro index 3df9bad..e4a8e48 100644 --- a/openEMS.pro +++ b/openEMS.pro @@ -38,6 +38,7 @@ SOURCES += main.cpp \ tools/array_ops.cpp \ FDTD/processvoltage.cpp \ FDTD/processing.cpp \ + FDTD/processintegral.cpp \ FDTD/processfields.cpp \ FDTD/processfields_td.cpp \ FDTD/processcurrent.cpp \ @@ -66,6 +67,7 @@ HEADERS += tools/ErrorMsg.h \ tools/array_ops.h \ FDTD/processvoltage.h \ FDTD/processing.h \ + FDTD/processintegral.h \ FDTD/processfields.h \ FDTD/processfields_td.h \ FDTD/processcurrent.h \