diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index e917c22..c506d3b 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -84,6 +84,7 @@ void Operator::Init() } m_Exc = 0; + m_TimeStepFactor = 1; } void Operator::Delete() @@ -891,6 +892,8 @@ int Operator::CalcECOperator( DebugFlags debugFlags ) else CalcTimestep(); + dT*=m_TimeStepFactor; + m_Exc->Reset(dT); InitOperator(); @@ -1484,6 +1487,18 @@ bool Operator::Calc_EC() return true; } +void Operator::SetTimestepFactor(double factor) +{ + if ((factor<=0) || (factor>1)) + { + cerr << "Operator::SetTimestepFactor: Warning, invalid timestep factor, skipping!" << endl; + return; + } + + cout << "Operator::SetTimestepFactor: Setting timestep factor to " << factor << endl; + m_TimeStepFactor=factor; +} + double Operator::CalcTimestep() { if (m_TimeStepVar==3) diff --git a/FDTD/operator.h b/FDTD/operator.h index 30b4ad9..b164027 100644 --- a/FDTD/operator.h +++ b/FDTD/operator.h @@ -78,7 +78,9 @@ public: //! Set a forced timestep to use by the operator virtual void SetTimestep(double ts) {dT = ts;} + virtual void SetTimestepFactor(double factor); bool GetTimestepValid() const {return !m_InvaildTimestep;} + virtual double GetNumberCells() const; virtual unsigned int GetNumberOfNyquistTimesteps() const {return m_Exc->GetNyquistNum();} @@ -180,6 +182,7 @@ protected: //Calc timestep only internal use int m_TimeStepVar; + double m_TimeStepFactor; virtual double CalcTimestep(); double opt_dT; bool m_InvaildTimestep; diff --git a/matlab/InitFDTD.m b/matlab/InitFDTD.m index fd28b3a..a775d31 100644 --- a/matlab/InitFDTD.m +++ b/matlab/InitFDTD.m @@ -12,6 +12,8 @@ function FDTD = InitFDTD(NrTS, endCrit, varargin) % optional field arguments for usage with openEMS: % OverSampling: nyquist oversampling of time domain dumps % CoordSystem: choose coordinate system (0 Cartesian, 1 Cylindrical) +% TimeStep: force to use a given timestep (dangerous!) +% TimeStepFactor: reduce the timestep by a given factor (>0 to <=1) % % examples: % %default init with 1e9 max. timesteps and -50dB end-criteria diff --git a/openems.cpp b/openems.cpp index aebb7bc..4112c30 100644 --- a/openems.cpp +++ b/openems.cpp @@ -652,6 +652,9 @@ int openEMS::SetupFDTD(const char* file) FDTD_Opts->QueryDoubleAttribute("TimeStep",×tep); if (timestep) FDTD_Op->SetTimestep(timestep); + double timestepfactor=0; + if (FDTD_Opts->QueryDoubleAttribute("TimeStepFactor",×tepfactor)==TIXML_SUCCESS) + FDTD_Op->SetTimestepFactor(timestepfactor); if (m_CSX->GetQtyPropertyType(CSProperties::LORENTZMATERIAL)>0) FDTD_Op->AddExtension(new Operator_Ext_LorentzMaterial(FDTD_Op));