processing constructor with Engine_Interface_Base only

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
This commit is contained in:
Thorsten Liebig 2010-12-07 16:47:23 +01:00
parent 57ead21ccc
commit 043ec7c1a1
23 changed files with 51 additions and 46 deletions

View File

@ -18,8 +18,9 @@
#include "engine_interface_base.h" #include "engine_interface_base.h"
#include "string" #include "string"
Engine_Interface_Base::Engine_Interface_Base() Engine_Interface_Base::Engine_Interface_Base(Operator_Base* base_op)
{ {
m_Op_Base = base_op;
m_InterpolType = NO_INTERPOLATION; m_InterpolType = NO_INTERPOLATION;
} }

View File

@ -20,6 +20,8 @@
#include "tools/global.h" #include "tools/global.h"
class Operator_Base;
//! This is the abstact base for all Engine Interface classes. //! This is the abstact base for all Engine Interface classes.
/*! /*!
This is the abstact base for all Engine Interface classes. It will provide unified access to the field information of the corresponding engine. This is the abstact base for all Engine Interface classes. It will provide unified access to the field information of the corresponding engine.
@ -30,6 +32,11 @@ class Engine_Interface_Base
public: public:
enum InterpolationType { NO_INTERPOLATION, NODE_INTERPOLATE, CELL_INTERPOLATE }; enum InterpolationType { NO_INTERPOLATION, NODE_INTERPOLATE, CELL_INTERPOLATE };
//! Set the operator used for this engine interface.
virtual void SetOperator(Operator_Base* base_op) {m_Op_Base=base_op;}
//! Get the operator used for this engine interface.
virtual const Operator_Base* GetOperator() const {return m_Op_Base;}
//! Set the current interpolation type \sa GetInterpolationType //! Set the current interpolation type \sa GetInterpolationType
void SetInterpolationType(InterpolationType type) {m_InterpolType=type;} void SetInterpolationType(InterpolationType type) {m_InterpolType=type;}
//! Set the current interpolation type \sa GetInterpolationType //! Set the current interpolation type \sa GetInterpolationType
@ -57,7 +64,9 @@ public:
virtual unsigned int GetNumberOfTimesteps() const =0; virtual unsigned int GetNumberOfTimesteps() const =0;
protected: protected:
Engine_Interface_Base(); Engine_Interface_Base(Operator_Base* base_op);
Operator_Base* m_Op_Base;
InterpolationType m_InterpolType; InterpolationType m_InterpolType;
}; };

View File

@ -19,7 +19,7 @@
#include "time.h" #include "time.h"
#include "process_efield.h" #include "process_efield.h"
ProcessEField::ProcessEField(Operator_Base* op, Engine* eng) : Processing(op) ProcessEField::ProcessEField(Engine_Interface_Base* eng_if, Engine* eng) : Processing(eng_if)
{ {
Eng = eng; Eng = eng;
} }

View File

@ -29,7 +29,7 @@
class ProcessEField : public Processing class ProcessEField : public Processing
{ {
public: public:
ProcessEField(Operator_Base* op, Engine* eng); ProcessEField(Engine_Interface_Base* eng_if, Engine* eng);
virtual ~ProcessEField(); virtual ~ProcessEField();
virtual void InitProcess(); virtual void InitProcess();

View File

@ -19,7 +19,7 @@
#include "tools/global.h" #include "tools/global.h"
#include "process_hfield.h" #include "process_hfield.h"
ProcessHField::ProcessHField(Operator_Base* op, Engine* eng) : ProcessEField(op, eng) ProcessHField::ProcessHField(Engine_Interface_Base* eng_if, Engine* eng) : ProcessEField(eng_if, eng)
{ {
} }

View File

@ -28,7 +28,7 @@
class ProcessHField : public ProcessEField class ProcessHField : public ProcessEField
{ {
public: public:
ProcessHField(Operator_Base* op, Engine* eng); ProcessHField(Engine_Interface_Base* eng_if, Engine* eng);
virtual ~ProcessHField(); virtual ~ProcessHField();
virtual void InitProcess(); virtual void InitProcess();

View File

@ -20,9 +20,9 @@
#include "FDTD/engine_interface_fdtd.h" #include "FDTD/engine_interface_fdtd.h"
#include <iomanip> #include <iomanip>
ProcessCurrent::ProcessCurrent(Operator_Base* op) : ProcessIntegral(op) ProcessCurrent::ProcessCurrent(Engine_Interface_Base* eng_if) : ProcessIntegral(eng_if)
{ {
m_TimeShift = op->GetTimestep()/2.0; m_TimeShift = Op->GetTimestep()/2.0;
m_dualMesh = true; m_dualMesh = true;
} }

View File

@ -23,7 +23,7 @@
class ProcessCurrent : public ProcessIntegral class ProcessCurrent : public ProcessIntegral
{ {
public: public:
ProcessCurrent(Operator_Base* op); ProcessCurrent(Engine_Interface_Base* eng_if);
virtual ~ProcessCurrent(); virtual ~ProcessCurrent();
//! Integrate currents flowing through an area //! Integrate currents flowing through an area

View File

@ -21,7 +21,7 @@
#include "processfields.h" #include "processfields.h"
#include "FDTD/engine_interface_fdtd.h" #include "FDTD/engine_interface_fdtd.h"
ProcessFields::ProcessFields(Operator_Base* op) : Processing(op) ProcessFields::ProcessFields(Engine_Interface_Base* eng_if) : Processing(eng_if)
{ {
m_DumpType = E_FIELD_DUMP; m_DumpType = E_FIELD_DUMP;
// vtk-file is default // vtk-file is default

View File

@ -26,7 +26,7 @@
class ProcessFields : public Processing class ProcessFields : public Processing
{ {
public: public:
ProcessFields(Operator_Base* op); ProcessFields(Engine_Interface_Base* eng_if);
virtual ~ProcessFields(); virtual ~ProcessFields();
enum FileType { VTK_FILETYPE, HDF5_FILETYPE}; enum FileType { VTK_FILETYPE, HDF5_FILETYPE};

View File

@ -21,7 +21,7 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
ProcessFieldsTD::ProcessFieldsTD(Operator_Base* op) : ProcessFields(op) ProcessFieldsTD::ProcessFieldsTD(Engine_Interface_Base* eng_if) : ProcessFields(eng_if)
{ {
pad_length = 8; pad_length = 8;
} }

View File

@ -23,7 +23,7 @@
class ProcessFieldsTD : public ProcessFields class ProcessFieldsTD : public ProcessFields
{ {
public: public:
ProcessFieldsTD(Operator_Base* op); ProcessFieldsTD(Engine_Interface_Base* eng_if);
virtual ~ProcessFieldsTD(); virtual ~ProcessFieldsTD();
virtual int Process(); virtual int Process();

View File

@ -23,9 +23,11 @@
#include "time.h" #include "time.h"
#include <climits> #include <climits>
Processing::Processing(Operator_Base* op) Processing::Processing(Engine_Interface_Base* eng_if)
{ {
Op=op; m_Eng_Interface = NULL;
SetEngineInterface(eng_if);
Enabled = true; Enabled = true;
m_PS_pos = 0; m_PS_pos = 0;
SetPrecision(12); SetPrecision(12);
@ -36,7 +38,6 @@ Processing::Processing(Operator_Base* op)
m_Flush = false; m_Flush = false;
m_dualMesh = false; m_dualMesh = false;
m_Mesh_Type = CARTESIAN_MESH; m_Mesh_Type = CARTESIAN_MESH;
m_Eng_Interface = NULL;
} }
Processing::~Processing() Processing::~Processing()
@ -54,6 +55,10 @@ void Processing::SetEngineInterface(Engine_Interface_Base* eng_if)
{ {
delete m_Eng_Interface; delete m_Eng_Interface;
m_Eng_Interface = eng_if; m_Eng_Interface = eng_if;
if (m_Eng_Interface)
Op=m_Eng_Interface->GetOperator();
else
Op=NULL;
} }
bool Processing::CheckTimestep() bool Processing::CheckTimestep()

View File

@ -40,7 +40,7 @@ using namespace std;
class Processing class Processing
{ {
public: public:
Processing(Operator_Base* op); Processing(Engine_Interface_Base* eng_if);
virtual ~Processing(); virtual ~Processing();
enum MeshType { CARTESIAN_MESH, CYLINDRICAL_MESH}; enum MeshType { CARTESIAN_MESH, CYLINDRICAL_MESH};
@ -91,7 +91,7 @@ public:
protected: protected:
Engine_Interface_Base* m_Eng_Interface; Engine_Interface_Base* m_Eng_Interface;
Operator_Base* Op; const Operator_Base* Op;
MeshType m_Mesh_Type; MeshType m_Mesh_Type;
unsigned int m_precision; unsigned int m_precision;

View File

@ -18,7 +18,7 @@
#include "processintegral.h" #include "processintegral.h"
#include <iomanip> #include <iomanip>
ProcessIntegral::ProcessIntegral(Operator_Base* op) : Processing(op) ProcessIntegral::ProcessIntegral(Engine_Interface_Base* eng_if) : Processing(eng_if)
{ {
m_TimeShift = 0.0; m_TimeShift = 0.0;
m_Results=NULL; m_Results=NULL;

View File

@ -51,7 +51,7 @@ public:
virtual int Process(); virtual int Process();
protected: protected:
ProcessIntegral(Operator_Base* op); ProcessIntegral(Engine_Interface_Base* eng_if);
//! timeshift to be used in TD and FD data, e.g. 0.5*dT in case of current based parameter //! timeshift to be used in TD and FD data, e.g. 0.5*dT in case of current based parameter
double m_TimeShift; double m_TimeShift;

View File

@ -20,7 +20,7 @@
#include "Common/operator_base.h" #include "Common/operator_base.h"
#include "tools/array_ops.h" #include "tools/array_ops.h"
ProcessModeMatch::ProcessModeMatch(Operator_Base* op) : ProcessIntegral(op) ProcessModeMatch::ProcessModeMatch(Engine_Interface_Base* eng_if) : ProcessIntegral(eng_if)
{ {
for (int n=0; n<2; ++n) for (int n=0; n<2; ++n)
{ {

View File

@ -30,7 +30,7 @@ class CSFunctionParser;
class ProcessModeMatch : public ProcessIntegral class ProcessModeMatch : public ProcessIntegral
{ {
public: public:
ProcessModeMatch(Operator_Base* op); ProcessModeMatch(Engine_Interface_Base* eng_if);
virtual ~ProcessModeMatch(); virtual ~ProcessModeMatch();
virtual void InitProcess(); virtual void InitProcess();

View File

@ -18,7 +18,7 @@
#include "processvoltage.h" #include "processvoltage.h"
#include <iomanip> #include <iomanip>
ProcessVoltage::ProcessVoltage(Operator_Base* op) : ProcessIntegral(op) ProcessVoltage::ProcessVoltage(Engine_Interface_Base* eng_if) : ProcessIntegral(eng_if)
{ {
} }

View File

@ -24,7 +24,7 @@
class ProcessVoltage : public ProcessIntegral class ProcessVoltage : public ProcessIntegral
{ {
public: public:
ProcessVoltage(Operator_Base* op); ProcessVoltage(Engine_Interface_Base* eng_if);
virtual ~ProcessVoltage(); virtual ~ProcessVoltage();
virtual double CalcIntegral(); virtual double CalcIntegral();

View File

@ -17,16 +17,10 @@
#include "engine_interface_fdtd.h" #include "engine_interface_fdtd.h"
Engine_Interface_FDTD::Engine_Interface_FDTD() : Engine_Interface_Base() Engine_Interface_FDTD::Engine_Interface_FDTD(Operator* op, Engine* eng) : Engine_Interface_Base(op)
{ {
m_Op = NULL; m_Op = op;
m_Eng = NULL; m_Eng = eng;
}
Engine_Interface_FDTD::Engine_Interface_FDTD(Operator* op, Engine* eng) : Engine_Interface_Base()
{
SetOperator(op);
SetEngine(eng);
} }
Engine_Interface_FDTD::~Engine_Interface_FDTD() Engine_Interface_FDTD::~Engine_Interface_FDTD()

View File

@ -27,14 +27,13 @@
class Engine_Interface_FDTD : public Engine_Interface_Base class Engine_Interface_FDTD : public Engine_Interface_Base
{ {
public: public:
Engine_Interface_FDTD();
Engine_Interface_FDTD(Operator* op, Engine* eng); Engine_Interface_FDTD(Operator* op, Engine* eng);
virtual ~Engine_Interface_FDTD(); virtual ~Engine_Interface_FDTD();
//! Set the FDTD operator //! Set the FDTD operator
virtual void SetOperator(Operator* op) {m_Op=op;} virtual void SetFDTDOperator(Operator* op) {SetOperator(op); m_Op=op;}
//! Set the FDTD engine //! Set the FDTD engine
virtual void SetEngine(Engine* eng) {m_Eng=eng;} virtual void SetFDTDEngine(Engine* eng) {m_Eng=eng;}
//! Get the FDTD engine in case direct access is needed. Direct access is not recommended! //! Get the FDTD engine in case direct access is needed. Direct access is not recommended!
const Engine* GetFDTDEngine() const {return m_Eng;} const Engine* GetFDTDEngine() const {return m_Eng;}

View File

@ -460,21 +460,21 @@ int openEMS::SetupFDTD(const char* file)
{ {
if (pb->GetProbeType()==0) if (pb->GetProbeType()==0)
{ {
ProcessVoltage* procVolt = new ProcessVoltage(FDTD_Op); ProcessVoltage* procVolt = new ProcessVoltage(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
proc=procVolt; proc=procVolt;
} }
else if (pb->GetProbeType()==1) else if (pb->GetProbeType()==1)
{ {
ProcessCurrent* procCurr = new ProcessCurrent(FDTD_Op); ProcessCurrent* procCurr = new ProcessCurrent(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
proc=procCurr; proc=procCurr;
} }
else if (pb->GetProbeType()==2) else if (pb->GetProbeType()==2)
proc = new ProcessEField(FDTD_Op,FDTD_Eng); proc = new ProcessEField(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng),FDTD_Eng);
else if (pb->GetProbeType()==3) else if (pb->GetProbeType()==3)
proc = new ProcessHField(FDTD_Op,FDTD_Eng); proc = new ProcessHField(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng),FDTD_Eng);
else if ((pb->GetProbeType()==10) || (pb->GetProbeType()==11)) else if ((pb->GetProbeType()==10) || (pb->GetProbeType()==11))
{ {
ProcessModeMatch* pmm = new ProcessModeMatch(FDTD_Op); ProcessModeMatch* pmm = new ProcessModeMatch(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
pmm->SetFieldType(pb->GetProbeType()-10); pmm->SetFieldType(pb->GetProbeType()-10);
pmm->SetModeFunction(0,pb->GetAttributeValue("ModeFunctionX")); pmm->SetModeFunction(0,pb->GetAttributeValue("ModeFunctionX"));
pmm->SetModeFunction(1,pb->GetAttributeValue("ModeFunctionY")); pmm->SetModeFunction(1,pb->GetAttributeValue("ModeFunctionY"));
@ -488,7 +488,6 @@ int openEMS::SetupFDTD(const char* file)
} }
if (CylinderCoords) if (CylinderCoords)
proc->SetMeshType(Processing::CYLINDRICAL_MESH); proc->SetMeshType(Processing::CYLINDRICAL_MESH);
proc->SetEngineInterface(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
proc->SetProcessInterval(Nyquist/m_OverSampling); proc->SetProcessInterval(Nyquist/m_OverSampling);
proc->AddFrequency(pb->GetFDSamples()); proc->AddFrequency(pb->GetFDSamples());
proc->SetName(pb->GetName()); proc->SetName(pb->GetName());
@ -506,7 +505,7 @@ int openEMS::SetupFDTD(const char* file)
vector<CSProperties*> DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX); vector<CSProperties*> DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX);
for (size_t i=0; i<DumpProps.size(); ++i) for (size_t i=0; i<DumpProps.size(); ++i)
{ {
ProcessFieldsTD* ProcTD = new ProcessFieldsTD(FDTD_Op); ProcessFieldsTD* ProcTD = new ProcessFieldsTD(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcTD->SetEnable(Enable_Dumps); ProcTD->SetEnable(Enable_Dumps);
ProcTD->SetProcessInterval(Nyquist/m_OverSampling); ProcTD->SetProcessInterval(Nyquist/m_OverSampling);
@ -528,7 +527,6 @@ int openEMS::SetupFDTD(const char* file)
CSPropDumpBox* db = DumpProps.at(i)->ToDumpBox(); CSPropDumpBox* db = DumpProps.at(i)->ToDumpBox();
if (db) if (db)
{ {
ProcTD->SetEngineInterface(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcTD->SetDumpType((ProcessFields::DumpType)db->GetDumpType()); ProcTD->SetDumpType((ProcessFields::DumpType)db->GetDumpType());
ProcTD->SetDumpMode((Engine_Interface_Base::InterpolationType)db->GetDumpMode()); ProcTD->SetDumpMode((Engine_Interface_Base::InterpolationType)db->GetDumpMode());
ProcTD->SetFileType((ProcessFields::FileType)db->GetFileType()); ProcTD->SetFileType((ProcessFields::FileType)db->GetFileType());
@ -598,8 +596,7 @@ void openEMS::RunFDTD()
cout << "Running FDTD engine... this may take a while... grab a cup of coffee?!?" << endl; cout << "Running FDTD engine... this may take a while... grab a cup of coffee?!?" << endl;
//special handling of a field processing, needed to realize the end criteria... //special handling of a field processing, needed to realize the end criteria...
ProcessFields* ProcField = new ProcessFields(FDTD_Op); ProcessFields* ProcField = new ProcessFields(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcField->SetEngineInterface(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
PA->AddProcessing(ProcField); PA->AddProcessing(ProcField);
double maxE=0,currE=0; double maxE=0,currE=0;