cylinder engine extension should use inline functions for field accesss

pull/1/head
Thorsten Liebig 2011-03-18 14:46:27 +01:00
parent 7ac5ab67c8
commit 1dff63d2cd
2 changed files with 20 additions and 8 deletions

View File

@ -18,10 +18,12 @@
#include "FDTD/engine.h" #include "FDTD/engine.h"
#include "engine_ext_cylinder.h" #include "engine_ext_cylinder.h"
#include "operator_ext_cylinder.h" #include "operator_ext_cylinder.h"
#include "FDTD/engine_sse.h"
Engine_Ext_Cylinder::Engine_Ext_Cylinder(Operator_Ext_Cylinder* op_ext) : Engine_Extension(op_ext) Engine_Ext_Cylinder::Engine_Ext_Cylinder(Operator_Ext_Cylinder* op_ext) : Engine_Extension(op_ext)
{ {
cyl_Op = op_ext; cyl_Op = op_ext;
m_Eng_SSE = NULL;
CC_closedAlpha = op_ext->CC_closedAlpha; CC_closedAlpha = op_ext->CC_closedAlpha;
CC_R0_included = op_ext->CC_R0_included; CC_R0_included = op_ext->CC_R0_included;
@ -33,6 +35,12 @@ Engine_Ext_Cylinder::Engine_Ext_Cylinder(Operator_Ext_Cylinder* op_ext) : Engine
m_Priority = ENG_EXT_PRIO_CYLINDER; m_Priority = ENG_EXT_PRIO_CYLINDER;
} }
void Engine_Ext_Cylinder::SetEngine(Engine* eng)
{
Engine_Extension::SetEngine(eng);
m_Eng_SSE = dynamic_cast<Engine_sse*>(m_Eng);
}
void Engine_Ext_Cylinder::Apply2Voltages() void Engine_Ext_Cylinder::Apply2Voltages()
{ {
if (CC_closedAlpha==false) return; if (CC_closedAlpha==false) return;
@ -43,18 +51,18 @@ void Engine_Ext_Cylinder::Apply2Voltages()
pos[0] = 0; pos[0] = 0;
for (pos[2]=0; pos[2]<numLines[2]; ++pos[2]) for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
{ {
m_Eng->SetVolt(2,0,0,pos[2], m_Eng->GetVolt(2,0,0,pos[2])*cyl_Op->vv_R0[pos[2]]); m_Eng_SSE->Engine_sse::SetVolt(2,0,0,pos[2], m_Eng_SSE->Engine_sse::GetVolt(2,0,0,pos[2])*cyl_Op->vv_R0[pos[2]]);
for (pos[1]=0; pos[1]<numLines[1]-1; ++pos[1]) for (pos[1]=0; pos[1]<numLines[1]-1; ++pos[1])
{ {
m_Eng->SetVolt(2,0,0,pos[2], m_Eng->GetVolt(2,0,0,pos[2]) + cyl_Op->vi_R0[pos[2]] * m_Eng->GetCurr(1,0,pos[1],pos[2]) ); m_Eng_SSE->Engine_sse::SetVolt(2,0,0,pos[2], m_Eng_SSE->Engine_sse::GetVolt(2,0,0,pos[2]) + cyl_Op->vi_R0[pos[2]] * m_Eng_SSE->Engine_sse::GetCurr(1,0,pos[1],pos[2]) );
} }
} }
for (pos[1]=0; pos[1]<numLines[1]; ++pos[1]) for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
{ {
for (pos[2]=0; pos[2]<numLines[2]; ++pos[2]) for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
{ {
m_Eng->SetVolt(1,0,pos[1],pos[2], 0); //no voltage in alpha-direction at r=0 m_Eng_SSE->Engine_sse::SetVolt(1,0,pos[1],pos[2], 0); //no voltage in alpha-direction at r=0
m_Eng->SetVolt(2,0,pos[1],pos[2], m_Eng->GetVolt(2,0,0,pos[2]) ); m_Eng_SSE->Engine_sse::SetVolt(2,0,pos[1],pos[2], m_Eng_SSE->Engine_sse::GetVolt(2,0,0,pos[2]) );
} }
} }
} }
@ -67,8 +75,8 @@ void Engine_Ext_Cylinder::Apply2Voltages()
{ {
for (pos[2]=0; pos[2]<numLines[2]; ++pos[2]) for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
{ {
m_Eng->SetVolt(0,pos[0],0,pos[2], m_Eng->GetVolt(0,pos[0],last_A_Line,pos[2]) ); m_Eng_SSE->Engine_sse::SetVolt(0,pos[0],0,pos[2], m_Eng_SSE->Engine_sse::GetVolt(0,pos[0],last_A_Line,pos[2]) );
m_Eng->SetVolt(2,pos[0],0,pos[2], m_Eng->GetVolt(2,pos[0],last_A_Line,pos[2]) ); m_Eng_SSE->Engine_sse::SetVolt(2,pos[0],0,pos[2], m_Eng_SSE->Engine_sse::GetVolt(2,pos[0],last_A_Line,pos[2]) );
} }
} }
} }
@ -85,8 +93,8 @@ void Engine_Ext_Cylinder::Apply2Current()
unsigned int last_A_Line = numLines[1]-2; unsigned int last_A_Line = numLines[1]-2;
for (pos[2]=0; pos[2]<numLines[2]-1; ++pos[2]) for (pos[2]=0; pos[2]<numLines[2]-1; ++pos[2])
{ {
m_Eng->SetCurr(0,pos[0],last_A_Line,pos[2], m_Eng->GetCurr(0,pos[0],0,pos[2]) ); m_Eng_SSE->Engine_sse::SetCurr(0,pos[0],last_A_Line,pos[2], m_Eng_SSE->Engine_sse::GetCurr(0,pos[0],0,pos[2]) );
m_Eng->SetCurr(2,pos[0],last_A_Line,pos[2], m_Eng->GetCurr(2,pos[0],0,pos[2]) ); m_Eng_SSE->Engine_sse::SetCurr(2,pos[0],last_A_Line,pos[2], m_Eng_SSE->Engine_sse::GetCurr(2,pos[0],0,pos[2]) );
} }
} }
} }

View File

@ -23,6 +23,7 @@
#include "FDTD/operator_cylinder.h" #include "FDTD/operator_cylinder.h"
class Operator_Ext_Cylinder; class Operator_Ext_Cylinder;
class Engine_sse;
class Engine_Ext_Cylinder : public Engine_Extension class Engine_Ext_Cylinder : public Engine_Extension
{ {
@ -33,8 +34,11 @@ public:
virtual void Apply2Current(); virtual void Apply2Current();
virtual void SetEngine(Engine* eng);
protected: protected:
Operator_Ext_Cylinder* cyl_Op; Operator_Ext_Cylinder* cyl_Op;
Engine_sse* m_Eng_SSE;
unsigned int numLines[3]; unsigned int numLines[3];