diff --git a/Common/processing.cpp b/Common/processing.cpp index 7cab6e6..686f3be 100644 --- a/Common/processing.cpp +++ b/Common/processing.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) +* Copyright (C) 2010-2015 Thorsten Liebig (Thorsten.Liebig@gmx.de) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +40,8 @@ Processing::Processing(Engine_Interface_Base* eng_if) m_SnapMethod = 0; m_Mesh_Type = CARTESIAN_MESH; + startTS=0; + stopTS =UINT_MAX; for (int n=0;n<3;++n) { start[n]=0; @@ -77,9 +79,12 @@ void Processing::SetName(string val, int number) bool Processing::CheckTimestep() { + unsigned int ts = m_Eng_Interface->GetNumberOfTimesteps(); + if (tsstopTS) + return false; if (m_ProcessSteps.size()>m_PS_pos) { - if (m_ProcessSteps.at(m_PS_pos)==m_Eng_Interface->GetNumberOfTimesteps()) + if (m_ProcessSteps.at(m_PS_pos)==ts) { ++m_PS_pos; return true; @@ -87,12 +92,12 @@ bool Processing::CheckTimestep() } if (ProcessInterval) { - if (m_Eng_Interface->GetNumberOfTimesteps()%ProcessInterval==0) return true; + if (ts%ProcessInterval==0) return true; } if (m_FD_Interval) { - if (m_Eng_Interface->GetNumberOfTimesteps()%m_FD_Interval==0) return true; + if (ts%m_FD_Interval==0) return true; } return false; } @@ -101,13 +106,14 @@ int Processing::GetNextInterval() const { if (Enabled==false) return -1; int next=INT_MAX; + int ts = (int)m_Eng_Interface->GetNumberOfTimesteps(); if (m_ProcessSteps.size()>m_PS_pos) { - next = (int)m_ProcessSteps.at(m_PS_pos)-(int)m_Eng_Interface->GetNumberOfTimesteps(); + next = (int)m_ProcessSteps.at(m_PS_pos)-ts; } if (ProcessInterval!=0) { - int next_Interval = (int)ProcessInterval - (int)m_Eng_Interface->GetNumberOfTimesteps()%ProcessInterval; + int next_Interval = (int)ProcessInterval - ts%ProcessInterval; if (next_IntervalGetNumberOfTimesteps()%m_FD_Interval; + int next_Interval = (int)m_FD_Interval - ts%m_FD_Interval; if (next_IntervalGetTimestep(); + startTS = 0; + stopTS = UINT_MAX; + if (start>0) + startTS = floor(start/dT); + if (stop>0) + stopTS = ceil(stop/dT); + if (stopTS<=startTS) + { + cerr << "Processing::SetProcessStartStopTimestep: Invalid start/stop values! Disabling!" << endl; + startTS = 0; + stopTS = UINT_MAX; + } +} + void Processing::OpenFile( string outfile ) { if (file.is_open()) diff --git a/Common/processing.h b/Common/processing.h index d3cc88d..e6c37fb 100644 --- a/Common/processing.h +++ b/Common/processing.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) +* Copyright (C) 2010-2015 Thorsten Liebig (Thorsten.Liebig@gmx.de) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,6 +62,7 @@ public: virtual void ShowSnappedCoords(); void SetProcessInterval(unsigned int interval) {ProcessInterval=max((unsigned int)1,interval);} + void SetProcessStartStopTime(double start, double stop); void AddStep(unsigned int step); void AddSteps(vector steps); @@ -151,6 +152,9 @@ protected: unsigned int start[3]; unsigned int stop[3]; + //! start/stop timestep + unsigned int startTS, stopTS; + //! define/store if snapped start/stop coords are inside the field domain bool m_start_inside[3]; bool m_stop_inside[3]; diff --git a/main.cpp b/main.cpp index 1d5408e..b1ace94 100644 --- a/main.cpp +++ b/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) cout << " ---------------------------------------------------------------------- " << endl; cout << " | openEMS " << bits << " -- version " GIT_VERSION << endl; - cout << " | (C) 2010-2013 Thorsten Liebig GPL license" << endl; + cout << " | (C) 2010-2015 Thorsten Liebig GPL license" << endl; cout << " ---------------------------------------------------------------------- " << endl; #ifdef MPI_SUPPORT cout << openEMS_FDTD_MPI::GetExtLibsInfo() << endl; diff --git a/openems.cpp b/openems.cpp index 4013134..b23f8a0 100644 --- a/openems.cpp +++ b/openems.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) +* Copyright (C) 2010-2015 Thorsten Liebig (Thorsten.Liebig@gmx.de) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -406,6 +406,8 @@ bool openEMS::SetupProcessing() proc->SetDualMesh(true); } proc->SetProcessInterval(Nyquist/m_OverSampling); + if (pb->GetStartTime()>0 || pb->GetStopTime()>0) + proc->SetProcessStartStopTime(pb->GetStartTime(), pb->GetStopTime()); proc->AddFrequency(pb->GetFDSamples()); proc->GetNormalDir(pb->GetNormalDir()); if (l_MultiBox==false) @@ -470,6 +472,8 @@ bool openEMS::SetupProcessing() { ProcField->SetEnable(Enable_Dumps); ProcField->SetProcessInterval(Nyquist/m_OverSampling); + if (db->GetStopTime()>0 || db->GetStartTime()>0) + ProcField->SetProcessStartStopTime(db->GetStartTime(), db->GetStopTime()); if ((db->GetDumpType()==1) || (db->GetDumpType()==11)) { ProcField->SetDualTime(true);