From a748b6416f7104815ddaa4c628b87672e971b73a Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Wed, 16 Nov 2011 11:31:50 +0100 Subject: [PATCH] bug fix handling field dumps for cylindrical coordinates & closed alpha mesh --- FDTD/engine_interface_cylindrical_fdtd.cpp | 63 +++++----------------- FDTD/engine_interface_fdtd.cpp | 6 +-- 2 files changed, 17 insertions(+), 52 deletions(-) diff --git a/FDTD/engine_interface_cylindrical_fdtd.cpp b/FDTD/engine_interface_cylindrical_fdtd.cpp index a140888..116d6dd 100644 --- a/FDTD/engine_interface_cylindrical_fdtd.cpp +++ b/FDTD/engine_interface_cylindrical_fdtd.cpp @@ -33,34 +33,18 @@ Engine_Interface_Cylindrical_FDTD::~Engine_Interface_Cylindrical_FDTD() double* Engine_Interface_Cylindrical_FDTD::GetHField(const unsigned int* pos, double* out) const { - if ((m_Op_Cyl->GetClosedAlpha()==false) || (m_InterpolType!=NODE_INTERPOLATE)) + if (m_Op_Cyl->GetClosedAlpha()==false) return Engine_Interface_FDTD::GetHField(pos, out); unsigned int iPos[] = {pos[0],pos[1],pos[2]}; - if (iPos[1]==0) - iPos[1]=m_Op->GetNumberOfLines(1)-1; - int nP,nPP; - for (int n=0; n<3; ++n) - { - nP = (n+1)%3; - nPP = (n+2)%3; - if ((iPos[0]==m_Op->GetNumberOfLines(0)-1) || (iPos[2]==m_Op->GetNumberOfLines(2)-1) || (iPos[nP]==0) || (iPos[nPP]==0)) - { - out[n] = 0; - continue; - } - out[n]=m_Eng->GetCurr(n,iPos)/m_Op->GetEdgeLength(n,iPos,true); - --iPos[nP]; - out[n]+=m_Eng->GetCurr(n,iPos)/m_Op->GetEdgeLength(n,iPos,true); - --iPos[nPP]; - out[n]+=m_Eng->GetCurr(n,iPos)/m_Op->GetEdgeLength(n,iPos,true); - ++iPos[nP]; - out[n]+=m_Eng->GetCurr(n,iPos)/m_Op->GetEdgeLength(n,iPos,true); - ++iPos[nPP]; - out[n]/=4; - } - return out; + if ((m_InterpolType==CELL_INTERPOLATE) && (pos[1]==m_Op->GetNumberOfLines(1))) + iPos[1]=0; + + if ((m_InterpolType==NODE_INTERPOLATE) && (iPos[1]==0)) + iPos[1]=m_Op->GetNumberOfLines(1); + + return Engine_Interface_FDTD::GetHField(iPos, out); } double* Engine_Interface_Cylindrical_FDTD::GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const @@ -70,30 +54,11 @@ double* Engine_Interface_Cylindrical_FDTD::GetRawInterpolatedField(const unsigne unsigned int iPos[] = {pos[0],pos[1],pos[2]}; - switch (m_InterpolType) - { - default: - case NO_INTERPOLATION: - return Engine_Interface_FDTD::GetRawInterpolatedField(pos,out,type); - break; - case NODE_INTERPOLATE: - for (int n=0; n<3; ++n) - { - if (pos[1]==0) - iPos[1]=m_Op->GetNumberOfLines(1)-1; - return Engine_Interface_FDTD::GetRawInterpolatedField(iPos,out,type); - } - break; - case CELL_INTERPOLATE: - for (int n=0; n<3; ++n) - { - if (pos[1]==m_Op->GetNumberOfLines(1)-1) - iPos[1]=0; - return Engine_Interface_FDTD::GetRawInterpolatedField(iPos,out,type); - } - break; - } + if ((m_InterpolType==NODE_INTERPOLATE) && (pos[1]==0)) + iPos[1]=m_Op->GetNumberOfLines(1); - //! this should not happen - return Engine_Interface_FDTD::GetRawInterpolatedField(pos,out,type); + if ((m_InterpolType==CELL_INTERPOLATE) && (pos[1]==m_Op->GetNumberOfLines(1))) + iPos[1]=0; + + return Engine_Interface_FDTD::GetRawInterpolatedField(iPos,out,type); } diff --git a/FDTD/engine_interface_fdtd.cpp b/FDTD/engine_interface_fdtd.cpp index 3768b5b..2da5513 100644 --- a/FDTD/engine_interface_fdtd.cpp +++ b/FDTD/engine_interface_fdtd.cpp @@ -81,7 +81,7 @@ double* Engine_Interface_FDTD::GetRawInterpolatedField(const unsigned int* pos, { nP = (n+1)%3; nPP = (n+2)%3; - if ((pos[0]==m_Op->GetNumberOfLines(0)-1) || (pos[1]==m_Op->GetNumberOfLines(1)-1) || (pos[2]==m_Op->GetNumberOfLines(2)-1)) + if ((pos[0]==m_Op->GetOriginalNumLines(0)-1) || (pos[1]==m_Op->GetOriginalNumLines(1)-1) || (pos[2]==m_Op->GetOriginalNumLines(2)-1)) { out[n] = 0; //electric field outside the field domain is always zero continue; @@ -119,7 +119,7 @@ double* Engine_Interface_FDTD::GetHField(const unsigned int* pos, double* out) c { nP = (n+1)%3; nPP = (n+2)%3; - if ((pos[0]==m_Op->GetNumberOfLines(0)-1) || (pos[1]==m_Op->GetNumberOfLines(1)-1) || (pos[2]==m_Op->GetNumberOfLines(2)-1) || (pos[nP]==0) || (pos[nPP]==0)) + if ((pos[0]==m_Op->GetOriginalNumLines(0)-1) || (pos[1]==m_Op->GetOriginalNumLines(1)-1) || (pos[2]==m_Op->GetOriginalNumLines(2)-1) || (pos[nP]==0) || (pos[nPP]==0)) { out[n] = 0; continue; @@ -140,7 +140,7 @@ double* Engine_Interface_FDTD::GetHField(const unsigned int* pos, double* out) c { delta = m_Op->GetEdgeLength(n,iPos,true); out[n] = m_Eng->GetCurr(n,iPos); - if ((pos[n]>=m_Op->GetNumberOfLines(n)-1)) + if ((pos[n]>=m_Op->GetOriginalNumLines(n)-1)) { out[n] = 0; //magnetic field on the outer boundaries is always zero continue;