FDTD: new argument to reduce the used timestep by a given factor

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
pull/1/head
Thorsten Liebig 2012-09-27 14:20:20 +02:00
parent 2f228f2161
commit 0022996df6
4 changed files with 23 additions and 0 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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

View File

@ -652,6 +652,9 @@ int openEMS::SetupFDTD(const char* file)
FDTD_Opts->QueryDoubleAttribute("TimeStep",&timestep);
if (timestep)
FDTD_Op->SetTimestep(timestep);
double timestepfactor=0;
if (FDTD_Opts->QueryDoubleAttribute("TimeStepFactor",&timestepfactor)==TIXML_SUCCESS)
FDTD_Op->SetTimestepFactor(timestepfactor);
if (m_CSX->GetQtyPropertyType(CSProperties::LORENTZMATERIAL)>0)
FDTD_Op->AddExtension(new Operator_Ext_LorentzMaterial(FDTD_Op));