From 0fe63823d0c802e02d77dd4a8a9196149137ef68 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 25 Jul 2011 14:56:27 +0200 Subject: [PATCH] bug fix in operator resetting and (Re)InitExcitation --- FDTD/excitation.cpp | 36 ++++++++++++++++++++++++++++++++++++ FDTD/excitation.h | 2 ++ FDTD/operator.cpp | 11 +++++++---- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/FDTD/excitation.cpp b/FDTD/excitation.cpp index 5207db6..f1899d9 100644 --- a/FDTD/excitation.cpp +++ b/FDTD/excitation.cpp @@ -63,7 +63,43 @@ Excitation::~Excitation() delete[] Volt_index[n]; delete[] Curr_index[n]; } +} +void Excitation::Reset( double timestep ) +{ + delete[] Signal_volt; + Signal_volt = 0; + delete[] Signal_curr; + Signal_curr = 0; + delete[] Volt_delay; + Volt_delay = 0; + delete[] Volt_dir; + Volt_dir = 0; + delete[] Volt_amp; + Volt_amp = 0; + delete[] Curr_delay; + Curr_delay = 0; + delete[] Curr_dir; + Curr_dir = 0; + delete[] Curr_amp; + Curr_amp = 0; + + Volt_Count = 0; + Curr_Count = 0; + + for (int n=0; n<3; ++n) + { + delete[] Volt_index[n]; + Volt_index[n] = 0; + delete[] Curr_index[n]; + Curr_index[n] = 0; + + Volt_Count_Dir[n] = 0; + Curr_Count_Dir[n] = 0; + } + + dT = timestep; + m_nyquistTS = 0; } bool Excitation::setupExcitation( TiXmlElement* Excite, unsigned int maxTS ) diff --git a/FDTD/excitation.h b/FDTD/excitation.h index fbbbb9b..c2c0986 100644 --- a/FDTD/excitation.h +++ b/FDTD/excitation.h @@ -30,6 +30,8 @@ public: Excitation( double timestep ); virtual ~Excitation(); + virtual void Reset( double timestep ); + bool setupExcitation( TiXmlElement* Excite, unsigned int maxTS ); //! Get the excitation timestep with the (first) max amplitude diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index cf3a26d..5d4c318 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -803,10 +803,13 @@ double Operator::GetDiscMaterial(int type, int n, const unsigned int pos[3]) con void Operator::InitExcitation() { - delete Exc; - Exc = new Excitation( dT ); - - this->AddExtension(new Operator_Ext_Excitation(this,Exc)); + if (Exc!=NULL) + Exc->Reset(dT); + else + { + Exc = new Excitation( dT ); + this->AddExtension(new Operator_Ext_Excitation(this,Exc)); + } } void Operator::Calc_ECOperatorPos(int n, unsigned int* pos)