new: operator should create its engine

pull/1/head
Thorsten Liebig 2010-05-08 18:12:44 +02:00 committed by Thorsten Liebig
parent 74ba9eceff
commit 54d0671d33
7 changed files with 33 additions and 26 deletions

View File

@ -17,6 +17,7 @@
#include <fstream> #include <fstream>
#include "operator.h" #include "operator.h"
#include "engine.h"
#include "operator_extension.h" #include "operator_extension.h"
#include "processfields.h" #include "processfields.h"
#include "tools/array_ops.h" #include "tools/array_ops.h"
@ -43,6 +44,12 @@ Operator::~Operator()
Reset(); Reset();
} }
Engine* Operator::CreateEngine()
{
Engine* eng = Engine::New(this);
return eng;
}
void Operator::Init() void Operator::Init()
{ {
CSX = NULL; CSX = NULL;

View File

@ -24,6 +24,7 @@
#include "excitation.h" #include "excitation.h"
class Operator_Extension; class Operator_Extension;
class Engine;
//! Abstract base-class for the FDTD-operator //! Abstract base-class for the FDTD-operator
class Operator class Operator
@ -34,6 +35,8 @@ public:
static Operator* New(); static Operator* New();
virtual ~Operator(); virtual ~Operator();
virtual Engine* CreateEngine();
virtual bool SetGeometryCSX(ContinuousStructure* geo); virtual bool SetGeometryCSX(ContinuousStructure* geo);
virtual ContinuousStructure* GetGeometryCSX() {return CSX;} virtual ContinuousStructure* GetGeometryCSX() {return CSX;}

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "engine.h"
#include "operator_cylinder.h" #include "operator_cylinder.h"
#include "operator_extension.h" #include "operator_extension.h"
#include "operator_ext_cylinder.h" #include "operator_ext_cylinder.h"
@ -35,6 +36,13 @@ Operator_Cylinder::~Operator_Cylinder()
Operator::Reset(); Operator::Reset();
} }
Engine* Operator_Cylinder::CreateEngine()
{
//!create a confentional engine... cylinder special operations will be dealt by engine extentions
Engine* eng = Engine::New(this);
return eng;
}
void Operator_Cylinder::Init() void Operator_Cylinder::Init()
{ {
CC_closedAlpha = false; CC_closedAlpha = false;

View File

@ -30,6 +30,8 @@ class Operator_Cylinder : public Operator
public: public:
static Operator_Cylinder* New(); static Operator_Cylinder* New();
virtual ~Operator_Cylinder(); virtual ~Operator_Cylinder();
virtual Engine* CreateEngine();
virtual bool SetGeometryCSX(ContinuousStructure* geo); virtual bool SetGeometryCSX(ContinuousStructure* geo);

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "engine_sse.h"
#include "operator_sse.h" #include "operator_sse.h"
#include "tools/array_ops.h" #include "tools/array_ops.h"
@ -34,6 +35,13 @@ Operator_sse::~Operator_sse()
Reset(); Reset();
} }
Engine* Operator_sse::CreateEngine()
{
//!create a special sse-engine
Engine_sse* eng = Engine_sse::New(this);
return eng;
}
void Operator_sse::Init() void Operator_sse::Init()
{ {
Operator::Init(); Operator::Init();

View File

@ -28,6 +28,8 @@ public:
static Operator_sse* New(); static Operator_sse* New();
virtual ~Operator_sse(); virtual ~Operator_sse();
virtual Engine* CreateEngine();
inline virtual FDTD_FLOAT& GetVV( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return f4_vv[n][x][y][z%numVectors].f[z/numVectors]; } inline virtual FDTD_FLOAT& GetVV( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return f4_vv[n][x][y][z%numVectors].f[z/numVectors]; }
inline virtual FDTD_FLOAT& GetVI( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return f4_vi[n][x][y][z%numVectors].f[z/numVectors]; } inline virtual FDTD_FLOAT& GetVI( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return f4_vi[n][x][y][z%numVectors].f[z/numVectors]; }

View File

@ -252,35 +252,12 @@ int openEMS::SetupFDTD(const char* file)
cout << "Creation time for operator: " << difftime(OpDoneTime,startTime) << " s" << endl; cout << "Creation time for operator: " << difftime(OpDoneTime,startTime) << " s" << endl;
//create FDTD engine //create FDTD engine
if (CylinderCoords) if (m_engine==EngineType_Multithreaded)
{ {
cerr << "openEMS: creating cylinder coordinate FDTD engine..." << endl; FDTD_Eng = Engine_Multithread::New(FDTD_Op,m_engine_numThreads);
switch (m_engine) {
// case EngineType_Multithreaded:
// FDTD_Eng = Engine_Multithread::New(FDTD_Op,m_engine_numThreads);
// break;
// case EngineType_SSE:
// FDTD_Eng = Engine_sse::New(dynamic_cast<Operator_sse*>(FDTD_Op));
// break;
default:
FDTD_Eng = Engine::New(FDTD_Op);
break;
}
} }
else else
{ FDTD_Eng = FDTD_Op->CreateEngine();
switch (m_engine) {
case EngineType_Multithreaded:
FDTD_Eng = Engine_Multithread::New(FDTD_Op,m_engine_numThreads);
break;
case EngineType_SSE:
FDTD_Eng = Engine_sse::New(dynamic_cast<Operator_sse*>(FDTD_Op));
break;
default:
FDTD_Eng = Engine::New(FDTD_Op);
break;
}
}
//*************** setup processing ************// //*************** setup processing ************//
cout << "Setting up processing..." << endl; cout << "Setting up processing..." << endl;