From c0c66518c17bfdb4fa2c66cdeb8dd640cefb1ae7 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 10 Jan 2011 11:15:22 +0100 Subject: [PATCH] new dump type: total current density (rotH) field dump --- Common/engine_interface_base.h | 2 ++ Common/processfields.cpp | 22 +++++++++++++++++++++- Common/processfields.h | 5 +++-- FDTD/engine_interface_fdtd.cpp | 26 ++++++++++++++++++++++++++ FDTD/engine_interface_fdtd.h | 1 + openems.cpp | 4 ++-- 6 files changed, 55 insertions(+), 5 deletions(-) diff --git a/Common/engine_interface_base.h b/Common/engine_interface_base.h index b4808a9..5f1ad5a 100644 --- a/Common/engine_interface_base.h +++ b/Common/engine_interface_base.h @@ -52,6 +52,8 @@ public: virtual double* GetHField(const unsigned int* pos, double* out) const =0; //! Get the (interpolated) electric current density field at \p pos. \sa SetInterpolationType virtual double* GetJField(const unsigned int* pos, double* out) const =0; + //! Get the total current density field by rot(H) at \p pos. \sa SetInterpolationType + virtual double* GetRotHField(const unsigned int* pos, double* out) const =0; //! Calculate the electric field integral along a given line virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const =0; diff --git a/Common/processfields.cpp b/Common/processfields.cpp index 5b13504..1c6c295 100644 --- a/Common/processfields.cpp +++ b/Common/processfields.cpp @@ -65,6 +65,8 @@ string ProcessFields::GetFieldNameByType(DumpType type) return "H-Field"; case J_FIELD_DUMP: return "J-Field"; + case ROTH_FIELD_DUMP: + return "RotH-Field"; } return "unknown field"; } @@ -600,8 +602,26 @@ FDTD_FLOAT**** ProcessFields::CalcField() } } return field; - } + case ROTH_FIELD_DUMP: + for (unsigned int i=0; iGetRotHField(pos,out); + field[0][i][j][k] = out[0]; + field[1][i][j][k] = out[1]; + field[2][i][j][k] = out[2]; + } + } + } + return field; + } cerr << "ProcessFields::CalcField(): Error, unknown dump type..." << endl; return field; } diff --git a/Common/processfields.h b/Common/processfields.h index 344013a..aa2d13b 100644 --- a/Common/processfields.h +++ b/Common/processfields.h @@ -34,9 +34,10 @@ public: //! Dump type definitions. /*! - Current dump types are electric field (E_FIELD_DUMP), magnetic field (H_FIELD_DUMP) and (conduction) electric current density (kappa*E) (J_FIELD_DUMP). + Current dump types are electric field (E_FIELD_DUMP), magnetic field (H_FIELD_DUMP), + (conduction) electric current density (kappa*E) (J_FIELD_DUMP) and total current density (rotH) */ - enum DumpType { E_FIELD_DUMP, H_FIELD_DUMP, J_FIELD_DUMP}; + enum DumpType { E_FIELD_DUMP, H_FIELD_DUMP, J_FIELD_DUMP, ROTH_FIELD_DUMP}; virtual void InitProcess(); diff --git a/FDTD/engine_interface_fdtd.cpp b/FDTD/engine_interface_fdtd.cpp index 1f83a03..ee7e9e0 100644 --- a/FDTD/engine_interface_fdtd.cpp +++ b/FDTD/engine_interface_fdtd.cpp @@ -37,6 +37,11 @@ double* Engine_Interface_FDTD::GetJField(const unsigned int* pos, double* out) c return GetRawInterpolatedField(pos, out, 1); } +double* Engine_Interface_FDTD::GetRotHField(const unsigned int* pos, double* out) const +{ + return GetRawInterpolatedField(pos, out, 2); +} + double* Engine_Interface_FDTD::GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const { unsigned int iPos[] = {pos[0],pos[1],pos[2]}; @@ -182,6 +187,27 @@ double Engine_Interface_FDTD::GetRawField(unsigned int n, const unsigned int* po return value/delta; if ((type==1) && (m_Op->m_kappa) && (delta)) return value*m_Op->m_kappa[n][pos[0]][pos[1]][pos[2]]/delta; + if (type==2) //calc rot(H) + { + int nP = (n+1)%3; + int nPP = (n+2)%3; + unsigned int locPos[] = {pos[0],pos[1],pos[2]}; + double area = m_Op->GetEdgeArea(n,pos); + value = m_Eng->GetCurr(nPP,pos); + value -= m_Eng->GetCurr(nP,pos); + if (pos[nPP]>0) + { + --locPos[nPP]; + value += m_Eng->GetCurr(nP,locPos); + ++locPos[nPP]; + } + if (pos[nP]>0) + { + --locPos[nP]; + value -= m_Eng->GetCurr(nPP,locPos); + } + return value/area; + } return 0.0; } diff --git a/FDTD/engine_interface_fdtd.h b/FDTD/engine_interface_fdtd.h index 4da9ad6..b2a72f8 100644 --- a/FDTD/engine_interface_fdtd.h +++ b/FDTD/engine_interface_fdtd.h @@ -43,6 +43,7 @@ public: virtual double* GetEField(const unsigned int* pos, double* out) const; virtual double* GetHField(const unsigned int* pos, double* out) const; virtual double* GetJField(const unsigned int* pos, double* out) const; + virtual double* GetRotHField(const unsigned int* pos, double* out) const; virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const; diff --git a/openems.cpp b/openems.cpp index f9adc91..7eb6551 100644 --- a/openems.cpp +++ b/openems.cpp @@ -372,9 +372,9 @@ bool openEMS::SetupProcessing(ContinuousStructure& CSX) CSPropDumpBox* db = DumpProps.at(i)->ToDumpBox(); if (db) { - if ((db->GetDumpType()>=0) && (db->GetDumpType()<=2)) + if ((db->GetDumpType()>=0) && (db->GetDumpType()<=3)) ProcField = new ProcessFieldsTD(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng)); - else if ((db->GetDumpType()>=10) && (db->GetDumpType()<=12)) + else if ((db->GetDumpType()>=10) && (db->GetDumpType()<=13)) ProcField = new ProcessFieldsFD(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng)); else cerr << "openEMS::SetupFDTD: unknown dump box type... skipping!" << endl;