From b73004be487522700da38782eae7041718fd52b4 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Tue, 8 Mar 2011 13:35:38 +0100 Subject: [PATCH] new method to dump excitation signals --- FDTD/engine.cpp | 14 -------------- FDTD/engine.h | 2 -- FDTD/excitation.cpp | 24 ++++++++++++++++++++++++ FDTD/excitation.h | 6 ++++++ FDTD/operator.cpp | 6 ++++++ FDTD/operator.h | 2 ++ openems.cpp | 2 ++ 7 files changed, 40 insertions(+), 16 deletions(-) diff --git a/FDTD/engine.cpp b/FDTD/engine.cpp index 9d1dc9f..ce3fc88 100644 --- a/FDTD/engine.cpp +++ b/FDTD/engine.cpp @@ -52,9 +52,6 @@ void Engine::Init() volt = Create_N_3DArray(numLines); curr = Create_N_3DArray(numLines); - file_et.open( "et" ); - file_ht.open( "ht" ); - InitExtensions(); SortExtensionByPriority(); } @@ -98,9 +95,6 @@ void Engine::Reset() Delete_N_3DArray(curr,numLines); curr=NULL; - file_et.close(); - file_ht.close(); - ClearExtensions(); } @@ -155,10 +149,6 @@ void Engine::ApplyVoltageExcite() pos[2]=Op->Exc->Volt_index[2][n]; SetVolt(ny,pos, GetVolt(ny,pos) + Op->Exc->Volt_amp[n]*Op->Exc->Signal_volt[exc_pos]); } - - // write the voltage excitation function into the file "et" - if (numTS < Op->Exc->Length) - file_et << numTS * Op->GetTimestep() << "\t" << Op->Exc->Signal_volt[numTS] << "\n"; // do not use std::endl here, because it will do an implicit flush } void Engine::UpdateCurrents(unsigned int startX, unsigned int numX) @@ -206,10 +196,6 @@ void Engine::ApplyCurrentExcite() pos[2]=Op->Exc->Curr_index[2][n]; SetCurr(ny,pos, GetCurr(ny,pos) + Op->Exc->Curr_amp[n]*Op->Exc->Signal_curr[exc_pos]); } - - // write the current excitation function into the file "ht" - if (numTS < Op->Exc->Length) - file_ht << (numTS+0.5) * Op->GetTimestep() << "\t" << Op->Exc->Signal_curr[numTS] << "\n"; // do not use std::endl here, because it will do an implicit flush } void Engine::DoPreVoltageUpdates() diff --git a/FDTD/engine.h b/FDTD/engine.h index 7ef8887..9efb569 100644 --- a/FDTD/engine.h +++ b/FDTD/engine.h @@ -93,8 +93,6 @@ protected: virtual void ClearExtensions(); vector m_Eng_exts; - ofstream file_et, file_ht; //excite signal dump file - friend class NS_Engine_Multithread::thread; // evil hack to access numTS from multithreading context }; diff --git a/FDTD/excitation.cpp b/FDTD/excitation.cpp index f228874..6c9b73d 100644 --- a/FDTD/excitation.cpp +++ b/FDTD/excitation.cpp @@ -17,6 +17,8 @@ #include "tools/array_ops.h" #include "tools/useful.h" +#include +#include #include "fparser.hh" #include "tinyxml.h" #include "excitation.h" @@ -248,6 +250,28 @@ void Excitation::CalcSinusExcitation(double f0, int nTS) SetNyquistNum( CalcNyquistNum(f0,dT) ); } +void Excitation::DumpVoltageExcite(string filename) +{ + ofstream file; + file.open( filename.c_str() ); + if (file.fail()) + return; + for (unsigned int n=1; n const volt_vIndex[3], vector const& volt_vExcit, vector const& volt_vDelay, vector const& volt_vDir ) { diff --git a/FDTD/excitation.h b/FDTD/excitation.h index d56e3eb..c0f1c77 100644 --- a/FDTD/excitation.h +++ b/FDTD/excitation.h @@ -43,6 +43,12 @@ public: void SetNyquistNum(unsigned int nyquist) {m_nyquistTS=nyquist;} unsigned int GetNyquistNum() const {return m_nyquistTS;} + //! Dump voltage excitation signal to ASCII file + void DumpVoltageExcite(string filename); + + //! Dump current excitation signal to ASCII file + void DumpCurrentExcite(string filename); + //Excitation time-signal unsigned int Length; FDTD_FLOAT* Signal_volt; diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index 486488f..7b10a54 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -1128,6 +1128,12 @@ bool Operator::Calc_EffMatPos(int ny, const unsigned int* pos, double* EffMat) c return true; } +void Operator::DumpExciationSignals() +{ + Exc->DumpVoltageExcite("et"); + Exc->DumpCurrentExcite("ht"); +} + void Operator::Init_EC() { for (int n=0; n<3; ++n) diff --git a/FDTD/operator.h b/FDTD/operator.h index effc9e8..223e5a7 100644 --- a/FDTD/operator.h +++ b/FDTD/operator.h @@ -55,6 +55,8 @@ public: virtual bool SetupExcitation(TiXmlElement* Excite, unsigned int maxTS) {return Exc->setupExcitation(Excite,maxTS);}; + virtual void DumpExciationSignals(); + // the next four functions need to be reimplemented in a derived class inline virtual FDTD_FLOAT GetVV( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return vv[n][x][y][z]; } inline virtual FDTD_FLOAT GetVI( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return vi[n][x][y][z]; } diff --git a/openems.cpp b/openems.cpp index f079527..e544c1e 100644 --- a/openems.cpp +++ b/openems.cpp @@ -605,6 +605,8 @@ int openEMS::SetupFDTD(const char* file) if (!FDTD_Op->SetupExcitation( FDTD_Opts->FirstChildElement("Excitation"), NrTS )) exit(2); + FDTD_Op->DumpExciationSignals(); + timeval OpDoneTime; gettimeofday(&OpDoneTime,NULL);