new: operator & engine extensions
This commit is contained in:
parent
13bd884e8e
commit
9c5c5e9057
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
#include "engine_extension.h"
|
||||||
#include "tools/array_ops.h"
|
#include "tools/array_ops.h"
|
||||||
|
|
||||||
//! \brief construct an Engine instance
|
//! \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)
|
bool Engine::IterateTS(unsigned int iterTS)
|
||||||
{
|
{
|
||||||
for (unsigned int iter=0;iter<iterTS;++iter)
|
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();
|
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();
|
ApplyVoltageExcite();
|
||||||
|
|
||||||
|
//current updates with extensions
|
||||||
|
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||||
|
m_Eng_exts.at(n)->DoPreCurrentUpdates();
|
||||||
|
|
||||||
UpdateCurrents();
|
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();
|
ApplyCurrentExcite();
|
||||||
|
|
||||||
++numTS;
|
++numTS;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "operator.h"
|
#include "operator.h"
|
||||||
|
|
||||||
|
class Engine_Extension;
|
||||||
|
|
||||||
class Engine
|
class Engine
|
||||||
{
|
{
|
||||||
public:
|
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 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]; }
|
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:
|
protected:
|
||||||
Engine(const Operator* op);
|
Engine(const Operator* op);
|
||||||
const Operator* Op;
|
const Operator* Op;
|
||||||
@ -53,6 +57,8 @@ protected:
|
|||||||
FDTD_FLOAT**** curr;
|
FDTD_FLOAT**** curr;
|
||||||
unsigned int numTS;
|
unsigned int numTS;
|
||||||
|
|
||||||
|
vector<Engine_Extension*> m_Eng_exts;
|
||||||
|
|
||||||
ofstream file_et1;
|
ofstream file_et1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
9
FDTD/engine_extension.cpp
Normal file
9
FDTD/engine_extension.cpp
Normal 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
49
FDTD/engine_extension.h
Normal 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
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "operator.h"
|
#include "operator.h"
|
||||||
|
#include "operator_extension.h"
|
||||||
#include "processfields.h"
|
#include "processfields.h"
|
||||||
#include "tools/array_ops.h"
|
#include "tools/array_ops.h"
|
||||||
#include "fparser.hh"
|
#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
|
//cleanup
|
||||||
for (int n=0;n<3;++n)
|
for (int n=0;n<3;++n)
|
||||||
{
|
{
|
||||||
@ -1091,3 +1096,7 @@ bool Operator::CalcPEC()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Operator::AddExtension(Operator_Extension* op_ext)
|
||||||
|
{
|
||||||
|
m_Op_exts.push_back(op_ext);
|
||||||
|
}
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#define FDTD_FLOAT float
|
#define FDTD_FLOAT float
|
||||||
|
|
||||||
|
class Operator_Extension;
|
||||||
|
|
||||||
//! Abstract base-class for the FDTD-operator
|
//! Abstract base-class for the FDTD-operator
|
||||||
class Operator
|
class Operator
|
||||||
{
|
{
|
||||||
@ -80,6 +82,8 @@ public:
|
|||||||
virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const;
|
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 bool SnapToMesh(double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL);
|
||||||
|
|
||||||
|
virtual void AddExtension(Operator_Extension* op_ext);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! use New() for creating a new Operator
|
//! use New() for creating a new Operator
|
||||||
Operator();
|
Operator();
|
||||||
@ -126,6 +130,8 @@ protected:
|
|||||||
AdrOp* MainOp;
|
AdrOp* MainOp;
|
||||||
AdrOp* DualOp;
|
AdrOp* DualOp;
|
||||||
|
|
||||||
|
vector<Operator_Extension*> m_Op_exts;
|
||||||
|
|
||||||
// engine/post-proc needs access
|
// engine/post-proc needs access
|
||||||
public:
|
public:
|
||||||
//EC operator
|
//EC operator
|
||||||
|
8
FDTD/operator_extension.cpp
Normal file
8
FDTD/operator_extension.cpp
Normal 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
34
FDTD/operator_extension.h
Normal 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
|
@ -38,7 +38,9 @@ SOURCES += main.cpp \
|
|||||||
openems.cpp \
|
openems.cpp \
|
||||||
FDTD/engine_multithread.cpp \
|
FDTD/engine_multithread.cpp \
|
||||||
FDTD/operator_cylinder.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 \
|
HEADERS += tools/ErrorMsg.h \
|
||||||
tools/AdrOp.h \
|
tools/AdrOp.h \
|
||||||
tools/constants.h \
|
tools/constants.h \
|
||||||
@ -54,7 +56,9 @@ HEADERS += tools/ErrorMsg.h \
|
|||||||
openems.h \
|
openems.h \
|
||||||
FDTD/engine_multithread.h \
|
FDTD/engine_multithread.h \
|
||||||
FDTD/operator_cylinder.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 \
|
QMAKE_CXXFLAGS_RELEASE = -O2 \
|
||||||
-g \
|
-g \
|
||||||
-march=native
|
-march=native
|
||||||
|
Loading…
Reference in New Issue
Block a user