new: operator & engine extensions

pull/1/head
Thorsten Liebig 2010-04-25 21:59:05 +02:00
parent 13bd884e8e
commit 9c5c5e9057
9 changed files with 155 additions and 2 deletions

View File

@ -16,6 +16,7 @@
*/
#include "engine.h"
#include "engine_extension.h"
#include "tools/array_ops.h"
//! \brief construct an Engine instance
@ -142,14 +143,41 @@ void Engine::ApplyCurrentExcite()
{
}
void Engine::AddExtension(Engine_Extension* eng_ext)
{
m_Eng_exts.push_back(eng_ext);
}
bool Engine::IterateTS(unsigned int iterTS)
{
for (unsigned int iter=0;iter<iterTS;++iter)
{
//voltage updates with extensions
for (size_t n=0;n<m_Eng_exts.size();++n)
m_Eng_exts.at(n)->DoPreVoltageUpdates();
UpdateVoltages();
for (size_t n=0;n<m_Eng_exts.size();++n)
m_Eng_exts.at(n)->DoPostVoltageUpdates();
for (size_t n=0;n<m_Eng_exts.size();++n)
m_Eng_exts.at(n)->Apply2Voltages();
ApplyVoltageExcite();
//current updates with extensions
for (size_t n=0;n<m_Eng_exts.size();++n)
m_Eng_exts.at(n)->DoPreCurrentUpdates();
UpdateCurrents();
for (size_t n=0;n<m_Eng_exts.size();++n)
m_Eng_exts.at(n)->DoPostCurrentUpdates();
for (size_t n=0;n<m_Eng_exts.size();++n)
m_Eng_exts.at(n)->Apply2Current();
ApplyCurrentExcite();
++numTS;
}
return true;

View File

@ -21,6 +21,8 @@
#include <fstream>
#include "operator.h"
class Engine_Extension;
class Engine
{
public:
@ -38,6 +40,8 @@ public:
inline virtual FDTD_FLOAT GetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return volt[n][x][y][z]; }
inline virtual FDTD_FLOAT GetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return curr[n][x][y][z]; }
virtual void AddExtension(Engine_Extension* eng_ext);
protected:
Engine(const Operator* op);
const Operator* Op;
@ -53,6 +57,8 @@ protected:
FDTD_FLOAT**** curr;
unsigned int numTS;
vector<Engine_Extension*> m_Eng_exts;
ofstream file_et1;
};

View File

@ -0,0 +1,9 @@
#include "engine_extension.h"
#include "engine.h"
Engine_Extension::Engine_Extension(Operator_Extension* op_ext, Engine* eng)
{
m_Op_ext = op_ext;
m_Eng = eng;
}

49
FDTD/engine_extension.h Normal file
View File

@ -0,0 +1,49 @@
/*
* Copyright (C) 2010 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ENGINE_EXTENSION_H
#define ENGINE_EXTENSION_H
class Operator_Extension;
class Engine;
//! Abstract base-class for all engine extensions
class Engine_Extension
{
public:
//! This methode will be called __before__ the main engine does the usual voltage updates. This methode may __not__ change the engine voltages!!!
virtual void DoPreVoltageUpdates() {}
//! This methode will be called __after__ the main engine does the usual voltage updates. This methode may __not__ change the engine voltages!!!
virtual void DoPostVoltageUpdates() {}
//! This methode will be called __after__ all updates to the voltages and extensions and may add its results to the engine voltages, but may __not__ rely on the current value of the engine voltages!!!
virtual void Apply2Voltages() {}
//! This methode will be called __before__ the main engine does the usual current updates. This methode may __not__ change the engine current!!!
virtual void DoPreCurrentUpdates() {}
//! This methode will be called __after__ the main engine does the usual current updates. This methode may __not__ change the engine current!!!
virtual void DoPostCurrentUpdates() {}
//! This methode will be called __after__ all updates to the current and extensions and may add its results to the engine current, but may __not__ rely on the current value of the engine current!!!
virtual void Apply2Current() {}
protected:
Engine_Extension(Operator_Extension* op_ext, Engine* eng);
Operator_Extension* m_Op_ext;
Engine* m_Eng;
};
#endif // ENGINE_EXTENSION_H

View File

@ -17,6 +17,7 @@
#include <fstream>
#include "operator.h"
#include "operator_extension.h"
#include "processfields.h"
#include "tools/array_ops.h"
#include "fparser.hh"
@ -553,6 +554,10 @@ int Operator::CalcECOperator()
}
}
//all information available for extension... create now...
for (size_t n=0;n<m_Op_exts.size();++n)
m_Op_exts.at(n)->BuildExtension();
//cleanup
for (int n=0;n<3;++n)
{
@ -1091,3 +1096,7 @@ bool Operator::CalcPEC()
return true;
}
void Operator::AddExtension(Operator_Extension* op_ext)
{
m_Op_exts.push_back(op_ext);
}

View File

@ -24,6 +24,8 @@
#define FDTD_FLOAT float
class Operator_Extension;
//! Abstract base-class for the FDTD-operator
class Operator
{
@ -80,6 +82,8 @@ public:
virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const;
virtual bool SnapToMesh(double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL);
virtual void AddExtension(Operator_Extension* op_ext);
protected:
//! use New() for creating a new Operator
Operator();
@ -126,6 +130,8 @@ protected:
AdrOp* MainOp;
AdrOp* DualOp;
vector<Operator_Extension*> m_Op_exts;
// engine/post-proc needs access
public:
//EC operator

View File

@ -0,0 +1,8 @@
#include "operator_extension.h"
#include "operator.h"
Operator_Extension::Operator_Extension(Operator* op)
{
m_Op = op;
}

34
FDTD/operator_extension.h Normal file
View File

@ -0,0 +1,34 @@
/*
* Copyright (C) 2010 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPERATOR_EXTENSION_H
#define OPERATOR_EXTENSION_H
class Operator;
//! Abstract base-class for all operator extensions
class Operator_Extension
{
public:
virtual bool BuildExtension() {return true;}
protected:
Operator_Extension(Operator* op);
Operator* m_Op;
};
#endif // OPERATOR_EXTENSION_H

View File

@ -38,7 +38,9 @@ SOURCES += main.cpp \
openems.cpp \
FDTD/engine_multithread.cpp \
FDTD/operator_cylinder.cpp \
FDTD/engine_cylinder.cpp
FDTD/engine_cylinder.cpp \
FDTD/operator_extension.cpp \
FDTD/engine_extension.cpp
HEADERS += tools/ErrorMsg.h \
tools/AdrOp.h \
tools/constants.h \
@ -54,7 +56,9 @@ HEADERS += tools/ErrorMsg.h \
openems.h \
FDTD/engine_multithread.h \
FDTD/operator_cylinder.h \
FDTD/engine_cylinder.h
FDTD/engine_cylinder.h \
FDTD/operator_extension.h \
FDTD/engine_extension.h
QMAKE_CXXFLAGS_RELEASE = -O2 \
-g \
-march=native