From af922a10bc7e1507b960ba335d0f75defd329443 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Sat, 25 Sep 2010 19:23:53 +0200 Subject: [PATCH] new extension priority system --- FDTD/engine.cpp | 12 ++++++++++++ FDTD/engine.h | 1 + FDTD/engine_cylindermultigrid.cpp | 3 +++ FDTD/engine_ext_cylinder.cpp | 3 +++ FDTD/engine_ext_cylindermultigrid.cpp | 3 +++ FDTD/engine_extension.cpp | 6 ++++++ FDTD/engine_extension.h | 11 +++++++++++ 7 files changed, 39 insertions(+) diff --git a/FDTD/engine.cpp b/FDTD/engine.cpp index 7a151ad..98ea487 100644 --- a/FDTD/engine.cpp +++ b/FDTD/engine.cpp @@ -56,6 +56,7 @@ void Engine::Init() file_ht.open( "ht" ); InitExtensions(); + SortExtensionByPriority(); } void Engine::InitExtensions() @@ -79,6 +80,17 @@ void Engine::ClearExtensions() m_Eng_exts.clear(); } +bool CompareExtensions(Engine_Extension* i, Engine_Extension* j) +{ + return (*i<*j); +} + +void Engine::SortExtensionByPriority() +{ + stable_sort(m_Eng_exts.begin(),m_Eng_exts.end(), CompareExtensions); + reverse(m_Eng_exts.begin(),m_Eng_exts.end()); +} + void Engine::Reset() { Delete_N_3DArray(volt,numLines); diff --git a/FDTD/engine.h b/FDTD/engine.h index dbad0b4..d5a1fd0 100644 --- a/FDTD/engine.h +++ b/FDTD/engine.h @@ -64,6 +64,7 @@ public: inline size_t GetExtensionCount() {return m_Eng_exts.size();} inline Engine_Extension* GetExtension(size_t nr) {return m_Eng_exts.at(nr);} + virtual void SortExtensionByPriority(); EngineType GetType() const {return m_type;} diff --git a/FDTD/engine_cylindermultigrid.cpp b/FDTD/engine_cylindermultigrid.cpp index 57b91e6..a32785e 100644 --- a/FDTD/engine_cylindermultigrid.cpp +++ b/FDTD/engine_cylindermultigrid.cpp @@ -100,6 +100,9 @@ void Engine_CylinderMultiGrid::Init() t = new boost::thread( Engine_CylinderMultiGrid_Thread(m_InnerEngine,m_startBarrier,m_stopBarrier,&m_Thread_NumTS, false) ); m_IteratorThread_Group.add_thread( t ); + + m_InnerEngine->SortExtensionByPriority(); + SortExtensionByPriority(); } bool Engine_CylinderMultiGrid::IterateTS(unsigned int iterTS) diff --git a/FDTD/engine_ext_cylinder.cpp b/FDTD/engine_ext_cylinder.cpp index 3964791..476b9f2 100644 --- a/FDTD/engine_ext_cylinder.cpp +++ b/FDTD/engine_ext_cylinder.cpp @@ -28,6 +28,9 @@ Engine_Ext_Cylinder::Engine_Ext_Cylinder(Operator_Ext_Cylinder* op_ext) : Engine for (int n=0;n<3;++n) numLines[n] = op_ext->m_Op->GetOriginalNumLines(n); + + //this cylindrical extension should be executed first? + m_Priority = 2000; } void Engine_Ext_Cylinder::Apply2Voltages() diff --git a/FDTD/engine_ext_cylindermultigrid.cpp b/FDTD/engine_ext_cylindermultigrid.cpp index e8d858d..39577fc 100644 --- a/FDTD/engine_ext_cylindermultigrid.cpp +++ b/FDTD/engine_ext_cylindermultigrid.cpp @@ -23,6 +23,9 @@ Engine_Ext_CylinderMultiGrid::Engine_Ext_CylinderMultiGrid(Operator_Extension* o { m_IsBase = isBase; m_Eng_MG = NULL; + + // the multi-grid should be applies last? + m_Priority = -1000; } Engine_Ext_CylinderMultiGrid::~Engine_Ext_CylinderMultiGrid() diff --git a/FDTD/engine_extension.cpp b/FDTD/engine_extension.cpp index e185b65..216a170 100644 --- a/FDTD/engine_extension.cpp +++ b/FDTD/engine_extension.cpp @@ -23,8 +23,14 @@ Engine_Extension::Engine_Extension(Operator_Extension* op_ext) { m_Op_ext = op_ext; m_Eng = NULL; + m_Priority = 0; } Engine_Extension::~Engine_Extension() { } + +bool Engine_Extension::operator< (const Engine_Extension& other) +{ + return (GetPriority()