Split of CartOperator into base-class and added Engine-class

pull/1/head
Thorsten Liebig 2010-03-01 09:19:39 +01:00
parent db4980c32f
commit 50e8ddaf0f
7 changed files with 162 additions and 62 deletions

View File

@ -3,53 +3,42 @@
CartOperator::CartOperator()
{
Init();
Operator::Init();
}
CartOperator::~CartOperator()
{
Reset();
Operator::Reset();
}
void CartOperator::Init()
{
CSX = NULL;
MainOp=NULL;
DualOp=NULL;
E_Ex_index = NULL;
E_Ex_delay = NULL;
for (int n=0;n<3;++n)
{
discLines[n]=NULL;
EC_C[n]=NULL;
EC_G[n]=NULL;
EC_L[n]=NULL;
EC_R[n]=NULL;
vv[n]=NULL;
vi[n]=NULL;
iv[n]=NULL;
ii[n]=NULL;
E_Ex_amp[n]=NULL;
for (int n=0;n<3;++n)
{
EC_C[n]=NULL;
EC_G[n]=NULL;
EC_L[n]=NULL;
EC_R[n]=NULL;
}
Operator::Init();
}
void CartOperator::Reset()
{
delete[] E_Ex_index;
delete[] E_Ex_delay;
delete MainOp;
delete DualOp;
for (int n=0;n<3;++n)
{
delete[] EC_C[n];
delete[] EC_G[n];
delete[] EC_L[n];
delete[] EC_R[n];
delete[] vv[n];
delete[] vi[n];
delete[] iv[n];
delete[] ii[n];
delete[] E_Ex_amp[n];
}
delete MainOp;
delete DualOp;
Init();
}

View File

@ -1,57 +1,31 @@
#ifndef CARTOPERATOR_H
#define CARTOPERATOR_H
#include "ContinuousStructure.h"
#include "tools/AdrOp.h"
#include "tools/constants.h"
#include "operator.h"
#define FDTD_FLOAT float
class CartOperator
class CartOperator : public Operator
{
public:
CartOperator();
virtual ~CartOperator();
void SetGeometryCSX(ContinuousStructure* geo);
virtual void SetGeometryCSX(ContinuousStructure* geo);
int CalcECOperator();
virtual int CalcECOperator();
void ApplyElectricBC(bool* dirs); //applied by default to all boundaries
void ApplyMagneticBC(bool* dirs);
virtual void ApplyElectricBC(bool* dirs); //applied by default to all boundaries
virtual void ApplyMagneticBC(bool* dirs);
double GetTimestep() {return dT;};
void Reset();
virtual void Reset();
protected:
void Init();
ContinuousStructure* CSX;
virtual void Init();
AdrOp* MainOp;
AdrOp* DualOp;
double* discLines[3];
unsigned int numLines[3];
double gridDelta;
double dT; //FDTD timestep!
//EC operator
FDTD_FLOAT* vv[3]; //calc new voltage from old voltage
FDTD_FLOAT* vi[3]; //calc new voltage from old current
FDTD_FLOAT* ii[3]; //calc new current from old current
FDTD_FLOAT* iv[3]; //calc new current from old voltage
//E-Field Excitation
//! Calc the electric field excitation.
bool CalcEFieldExcitation();
unsigned int E_Ex_Count;
unsigned int* E_Ex_index;
FDTD_FLOAT* E_Ex_amp[3]; //represented as edge-voltages!!
FDTD_FLOAT* E_Ex_delay;
//Calc timestep only internal use
double CalcTimestep();
virtual bool CalcEFieldExcitation();
virtual double CalcTimestep();
//EC elements, internal only!
bool Calc_EC();

9
FDTD/engine.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "engine.h"
Engine::Engine()
{
}
Engine::~Engine()
{
}

17
FDTD/engine.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef ENGINE_H
#define ENGINE_H
class Engine
{
public:
Engine();
virtual ~Engine();
//!Iterate a number of timesteps
bool IterateTS(unsigned int numTS);
protected:
};
#endif // ENGINE_H

51
FDTD/operator.cpp Normal file
View File

@ -0,0 +1,51 @@
#include "operator.h"
Operator::Operator()
{
Operator::Init();
}
Operator::~Operator()
{
Operator::Reset();
}
void Operator::Init()
{
CSX = NULL;
E_Ex_index = NULL;
E_Ex_delay = NULL;
for (int n=0;n<3;++n)
{
discLines[n]=NULL;
vv[n]=NULL;
vi[n]=NULL;
iv[n]=NULL;
ii[n]=NULL;
E_Ex_amp[n]=NULL;
}
}
void Operator::Reset()
{
delete[] E_Ex_index;
delete[] E_Ex_delay;
for (int n=0;n<3;++n)
{
delete[] vv[n];
delete[] vi[n];
delete[] iv[n];
delete[] ii[n];
delete[] E_Ex_amp[n];
}
Operator::Init();
}
void Operator::SetGeometryCSX(ContinuousStructure* geo)
{
if (geo==NULL) return;
Reset();
CSX = geo;
}

56
FDTD/operator.h Normal file
View File

@ -0,0 +1,56 @@
#ifndef OPERATOR_H
#define OPERATOR_H
#include "ContinuousStructure.h"
#include "tools/AdrOp.h"
#include "tools/constants.h"
#define FDTD_FLOAT float
//! Abstract base-class for the FDTD-operator
class Operator
{
friend class Engine;
public:
Operator();
virtual ~Operator();
virtual void SetGeometryCSX(ContinuousStructure* geo);
virtual int CalcECOperator() {};
virtual void ApplyElectricBC(bool* dirs) {}; //applied by default to all boundaries
virtual void ApplyMagneticBC(bool* dirs) {};
double GetTimestep() {return dT;};
virtual void Reset();
protected:
virtual void Init();
ContinuousStructure* CSX;
double gridDelta;
double* discLines[3];
unsigned int numLines[3];
//EC operator
FDTD_FLOAT* vv[3]; //calc new voltage from old voltage
FDTD_FLOAT* vi[3]; //calc new voltage from old current
FDTD_FLOAT* ii[3]; //calc new current from old current
FDTD_FLOAT* iv[3]; //calc new current from old voltage
//E-Field Excitation
//! Calc the electric field excitation.
virtual bool CalcEFieldExcitation() {};
unsigned int E_Ex_Count;
unsigned int* E_Ex_index;
FDTD_FLOAT* E_Ex_amp[3]; //represented as edge-voltages!!
FDTD_FLOAT* E_Ex_delay;
//Calc timestep only internal use
virtual double CalcTimestep() {};
double dT; //FDTD timestep!
};
#endif // OPERATOR_H

View File

@ -17,8 +17,12 @@ LIBS += -L../CSXCAD \
SOURCES += main.cpp \
FDTD/cartoperator.cpp \
tools/ErrorMsg.cpp \
tools/AdrOp.cpp
tools/AdrOp.cpp \
FDTD/engine.cpp \
FDTD/operator.cpp
HEADERS += FDTD/cartoperator.h \
tools/ErrorMsg.h \
tools/AdrOp.h \
tools/constants.h
tools/constants.h \
FDTD/engine.h \
FDTD/operator.h