diff --git a/FDTD/extensions/engine_ext_lumpedRLC.cpp b/FDTD/extensions/engine_ext_lumpedRLC.cpp index 6eac857..f046b66 100644 --- a/FDTD/extensions/engine_ext_lumpedRLC.cpp +++ b/FDTD/extensions/engine_ext_lumpedRLC.cpp @@ -99,7 +99,8 @@ void Engine_Ext_LumpedRLC::DoPreVoltageUpdates() return; } -void Engine_Ext_LumpedRLC::Apply2Voltages() +template +void Engine_Ext_LumpedRLC::Apply2VoltagesImpl(EngineType* eng) { uint **pos = m_Op_Ext_RLC->v_RLC_pos; int *dir = m_Op_Ext_RLC->v_RLC_dir; @@ -113,31 +114,8 @@ void Engine_Ext_LumpedRLC::Apply2Voltages() // Read engine calculated node voltage - switch (m_Eng->GetType()) - { - case Engine::BASIC: - { - for (uint pIdx = 0 ; pIdx < m_Op_Ext_RLC->RLC_count ; pIdx++) - v_Vdn[0][pIdx] = m_Eng->Engine::GetVolt(dir[pIdx],pos[0][pIdx],pos[1][pIdx],pos[2][pIdx]); - - break; - } - case Engine::SSE: - { - Engine_sse* eng_sse = (Engine_sse*)m_Eng; - for (uint pIdx = 0 ; pIdx < m_Op_Ext_RLC->RLC_count ; pIdx++) - v_Vdn[0][pIdx] = eng_sse->Engine_sse::GetVolt(dir[pIdx],pos[0][pIdx],pos[1][pIdx],pos[2][pIdx]); - - break; - } - default: - { - for (uint pIdx = 0 ; pIdx < m_Op_Ext_RLC->RLC_count ; pIdx++) - v_Vdn[0][pIdx] = m_Eng->GetVolt(dir[pIdx],pos[0][pIdx],pos[1][pIdx],pos[2][pIdx]);; - - break; - } - } + for (uint pIdx = 0 ; pIdx < m_Op_Ext_RLC->RLC_count ; pIdx++) + v_Vdn[0][pIdx] = eng->EngineType::GetVolt(dir[pIdx],pos[0][pIdx],pos[1][pIdx],pos[2][pIdx]); // Post process: Calculate node voltage with respect to the lumped RLC auxilliary quantity, J for (uint pIdx = 0 ; pIdx < m_Op_Ext_RLC->RLC_count ; pIdx++) @@ -162,34 +140,11 @@ void Engine_Ext_LumpedRLC::Apply2Voltages() // Update node voltage - switch (m_Eng->GetType()) - { - case Engine::BASIC: - { - for (uint pIdx = 0 ; pIdx < m_Op_Ext_RLC->RLC_count ; pIdx++) - m_Eng->Engine::SetVolt(dir[pIdx],pos[0][pIdx],pos[1][pIdx],pos[2][pIdx],v_Vdn[0][pIdx]); - - break; - } - case Engine::SSE: - { - Engine_sse* eng_sse = (Engine_sse*)m_Eng; - for (uint pIdx = 0 ; pIdx < m_Op_Ext_RLC->RLC_count ; pIdx++) - eng_sse->Engine_sse::SetVolt(dir[pIdx],pos[0][pIdx],pos[1][pIdx],pos[2][pIdx],v_Vdn[0][pIdx]); - - break; - } - default: - { - for (uint pIdx = 0 ; pIdx < m_Op_Ext_RLC->RLC_count ; pIdx++) - m_Eng->SetVolt(dir[pIdx],pos[0][pIdx],pos[1][pIdx],pos[2][pIdx],v_Vdn[0][pIdx]); - - break; - } - } - - - return; + for (uint pIdx = 0 ; pIdx < m_Op_Ext_RLC->RLC_count ; pIdx++) + eng->EngineType::SetVolt(dir[pIdx],pos[0][pIdx],pos[1][pIdx],pos[2][pIdx],v_Vdn[0][pIdx]); } - +void Engine_Ext_LumpedRLC::Apply2Voltages() +{ + ENG_DISPATCH(Apply2VoltagesImpl); +} diff --git a/FDTD/extensions/engine_ext_lumpedRLC.h b/FDTD/extensions/engine_ext_lumpedRLC.h index af44af4..b0e27ce 100644 --- a/FDTD/extensions/engine_ext_lumpedRLC.h +++ b/FDTD/extensions/engine_ext_lumpedRLC.h @@ -21,6 +21,7 @@ #include "engine_extension.h" #include "FDTD/engine.h" #include "FDTD/operator.h" +#include "engine_extension_dispatcher.h" class Operator_Ext_LumpedRLC; @@ -39,6 +40,9 @@ public: virtual void Apply2Voltages(); protected: + template + void Apply2VoltagesImpl(EngineType* eng); + Operator_Ext_LumpedRLC* m_Op_Ext_RLC; // Auxilliary containers