From e880fa3ee80b5f5d7254d815f818943c6e836d0a Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 28 Jun 2010 18:27:41 +0200 Subject: [PATCH] Processing: some code cleanups & consistencies Signed-off-by: Thorsten Liebig --- FDTD/processcurrent.cpp | 4 +++- FDTD/processcurrent.h | 2 +- FDTD/processfields.cpp | 4 ++-- FDTD/processfields.h | 3 +-- FDTD/processfields_td.cpp | 6 +++--- FDTD/processing.h | 10 +++++++--- FDTD/processvoltage.cpp | 4 +++- FDTD/processvoltage.h | 2 +- openems.cpp | 5 ++--- 9 files changed, 23 insertions(+), 17 deletions(-) diff --git a/FDTD/processcurrent.cpp b/FDTD/processcurrent.cpp index e0efb07..f7517f2 100644 --- a/FDTD/processcurrent.cpp +++ b/FDTD/processcurrent.cpp @@ -46,8 +46,10 @@ void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop) } } -void ProcessCurrent::Init() +void ProcessCurrent::InitProcess() { + m_filename = m_Name; + OpenFile(m_filename); FD_currents.clear(); for (size_t n=0;ncreateGroup( "/Mesh" )); for (int n=0;n<3;++n) diff --git a/FDTD/processfields.h b/FDTD/processfields.h index a282d9b..083dddc 100644 --- a/FDTD/processfields.h +++ b/FDTD/processfields.h @@ -43,7 +43,7 @@ public: void SetFilePattern(string fp) {m_filename=filePattern=fp;} //! Set the filename for a hdf5 data group file (HDF5 FileType only) \sa SetFileType - void SetFileName(string fn) {m_filename=m_fileName=fn;} + void SetFileName(string fn) {m_filename=fn;} //! Define the Dump-Mode void SetDumpMode(DumpMode mode) {m_DumpMode=mode;} @@ -87,7 +87,6 @@ protected: DumpType m_DumpType; MeshType m_Mesh_Type; string filePattern; - string m_fileName; FileType m_fileType; //! field dump sub-sampling diff --git a/FDTD/processfields_td.cpp b/FDTD/processfields_td.cpp index 10cb3dc..705e306 100644 --- a/FDTD/processfields_td.cpp +++ b/FDTD/processfields_td.cpp @@ -387,11 +387,11 @@ int ProcessFieldsTD::Process() else if (m_fileType==HDF5_FILETYPE) { if (m_DumpMode==NO_INTERPOLATION) - DumpNoInterpol(m_fileName); + DumpNoInterpol(m_filename); if (m_DumpMode==NODE_INTERPOLATE) - DumpNodeInterpol(m_fileName); + DumpNodeInterpol(m_filename); if (m_DumpMode==CELL_INTERPOLATE) - DumpCellInterpol(m_fileName); + DumpCellInterpol(m_filename); } return GetNextInterval(); } diff --git a/FDTD/processing.h b/FDTD/processing.h index ce74068..2e00e84 100644 --- a/FDTD/processing.h +++ b/FDTD/processing.h @@ -31,7 +31,9 @@ public: Processing(Operator* op, Engine* eng); virtual ~Processing(); - virtual void Init() {}; + virtual void SetName(string val) {m_Name=val;} + + virtual void InitProcess() {}; virtual void Reset(); virtual void DefineStartStopCoord(double* dstart, double* dstop); @@ -62,8 +64,6 @@ public: //! Set the dump precision void SetPrecision(unsigned int val) {m_precision = val;} - virtual void OpenFile( string outfile ); - virtual void DumpBox2File( string vtkfilenameprefix, bool dualMesh = false ) const; //!< dump geometry to file protected: @@ -71,6 +71,8 @@ protected: Engine* Eng; unsigned int m_precision; + string m_Name; + bool m_Flush; double m_weight; @@ -103,6 +105,8 @@ protected: ofstream file; string m_filename; + virtual void OpenFile(string outfile); + double CalcLineIntegral(unsigned int* start, unsigned int* stop, int field) const; double CalcLineIntegral_I(unsigned int* start, unsigned int* stop) const; double CalcLineIntegral_V(unsigned int* start, unsigned int* stop) const; diff --git a/FDTD/processvoltage.cpp b/FDTD/processvoltage.cpp index a847f85..20e1805 100644 --- a/FDTD/processvoltage.cpp +++ b/FDTD/processvoltage.cpp @@ -28,8 +28,10 @@ ProcessVoltage::~ProcessVoltage() ProcessVoltage::FlushData(); } -void ProcessVoltage::Init() +void ProcessVoltage::InitProcess() { + m_filename = m_Name; + OpenFile(m_filename); FD_voltages.clear(); for (size_t n=0;nGetProbeType()==0) { ProcessVoltage* procVolt = new ProcessVoltage(FDTD_Op,FDTD_Eng); - procVolt->OpenFile(pb->GetName()); proc=procVolt; } else if (pb->GetProbeType()==1) { ProcessCurrent* procCurr = new ProcessCurrent(FDTD_Op,FDTD_Eng); - procCurr->OpenFile(pb->GetName()); proc=procCurr; } else @@ -333,7 +331,8 @@ int openEMS::SetupFDTD(const char* file) proc->AddFrequency(pb->GetFDSamples()); proc->DefineStartStopCoord(start,stop); proc->SetWeight(pb->GetWeighting()); - proc->Init(); + proc->SetName(pb->GetName()); + proc->InitProcess(); PA->AddProcessing(proc); prim->SetPrimitiveUsed(true); }