From ea496b61291eeb9e27eeb955cd31f10c5676b4ed Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Fri, 7 Jan 2011 10:45:26 +0100 Subject: [PATCH] operator: new material data storage for post-processing purposes --- Common/operator_base.cpp | 11 ++++++ Common/operator_base.h | 9 +++++ FDTD/operator.cpp | 83 ++++++++++++++++++++++++++++++++++++++++ FDTD/operator.h | 9 +++++ 4 files changed, 112 insertions(+) diff --git a/Common/operator_base.cpp b/Common/operator_base.cpp index 4054253..254f006 100644 --- a/Common/operator_base.cpp +++ b/Common/operator_base.cpp @@ -21,6 +21,10 @@ Operator_Base::Operator_Base() { Init(); m_MeshType = Processing::CARTESIAN_MESH; + m_StoreMaterial[0]=false; + m_StoreMaterial[1]=false; + m_StoreMaterial[2]=false; + m_StoreMaterial[3]=false; } Operator_Base::~Operator_Base() @@ -51,3 +55,10 @@ void Operator_Base::Reset() delete[] discLines[n]; Init(); } + +void Operator_Base::SetMaterialStoreFlags(int type, bool val) +{ + if ((type<0) || (type>4)) + return; + m_StoreMaterial[type]=val; +} diff --git a/Common/operator_base.h b/Common/operator_base.h index f8a4825..34ff4ef 100644 --- a/Common/operator_base.h +++ b/Common/operator_base.h @@ -69,6 +69,12 @@ public: //! Set the boundary conditions virtual void SetBoundaryCondition(int* BCs) {for (int n=0; n<6; ++n) m_BC[n]=BCs[n];} + //! Set flags to store material data for post-processing + virtual void SetMaterialStoreFlags(int type, bool val); + + //! Check storage flags and cleanup + virtual void CleanupMaterialStorage() = 0; + protected: Operator_Base(); virtual ~Operator_Base(); @@ -82,6 +88,9 @@ protected: //! The operator timestep double dT; + //! bool flag array to store material data for post-processing + bool m_StoreMaterial[4]; + Processing::MeshType m_MeshType; unsigned int numLines[3]; double* discLines[3]; diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index 5e4a000..a25593f 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -62,6 +62,11 @@ void Operator::Init() iv=NULL; ii=NULL; + m_epsR=NULL; + m_kappa=NULL; + m_mueR=NULL; + m_sigma=NULL; + MainOp=NULL; DualOp=NULL; @@ -94,6 +99,11 @@ void Operator::Reset() delete Exc; + Delete_N_3DArray(m_epsR,numLines); + Delete_N_3DArray(m_kappa,numLines); + Delete_N_3DArray(m_mueR,numLines); + Delete_N_3DArray(m_sigma,numLines); + Operator_Base::Reset(); } @@ -585,6 +595,70 @@ void Operator::InitOperator() ii = Create_N_3DArray(numLines); } +void Operator::InitDataStorage() +{ + if (m_StoreMaterial[0]) + { + if (g_settings.GetVerboseLevel()>0) + cerr << "Operator::InitDataStorage(): Storing epsR material data..." << endl; + Delete_N_3DArray(m_epsR,numLines); + m_epsR = Create_N_3DArray(numLines); + } + if (m_StoreMaterial[1]) + { + if (g_settings.GetVerboseLevel()>0) + cerr << "Operator::InitDataStorage(): Storing kappa material data..." << endl; + Delete_N_3DArray(m_kappa,numLines); + m_kappa = Create_N_3DArray(numLines); + } + if (m_StoreMaterial[2]) + { + if (g_settings.GetVerboseLevel()>0) + cerr << "Operator::InitDataStorage(): Storing muR material data..." << endl; + Delete_N_3DArray(m_mueR,numLines); + m_mueR = Create_N_3DArray(numLines); + } + if (m_StoreMaterial[3]) + { + if (g_settings.GetVerboseLevel()>0) + cerr << "Operator::InitDataStorage(): Storing sigma material data..." << endl; + Delete_N_3DArray(m_sigma,numLines); + m_sigma = Create_N_3DArray(numLines); + } +} + +void Operator::CleanupMaterialStorage() +{ + if (!m_StoreMaterial[0] && m_epsR) + { + if (g_settings.GetVerboseLevel()>0) + cerr << "Operator::CleanupMaterialStorage(): Delete epsR material data..." << endl; + Delete_N_3DArray(m_epsR,numLines); + m_epsR = NULL; + } + if (!m_StoreMaterial[1] && m_kappa) + { + if (g_settings.GetVerboseLevel()>0) + cerr << "Operator::CleanupMaterialStorage(): Delete kappa material data..." << endl; + Delete_N_3DArray(m_kappa,numLines); + m_kappa = NULL; + } + if (!m_StoreMaterial[2] && m_mueR) + { + if (g_settings.GetVerboseLevel()>0) + cerr << "Operator::CleanupMaterialStorage(): Delete mueR material data..." << endl; + Delete_N_3DArray(m_mueR,numLines); + m_mueR = NULL; + } + if (!m_StoreMaterial[3] && m_sigma) + { + if (g_settings.GetVerboseLevel()>0) + cerr << "Operator::CleanupMaterialStorage(): Delete sigma material data..." << endl; + Delete_N_3DArray(m_sigma,numLines); + m_sigma = NULL; + } +} + void Operator::InitExcitation() { delete Exc; @@ -619,6 +693,7 @@ void Operator::Calc_ECOperatorPos(int n, unsigned int* pos) int Operator::CalcECOperator( DebugFlags debugFlags ) { Init_EC(); + InitDataStorage(); if (Calc_EC()==0) return -1; @@ -800,6 +875,14 @@ bool Operator::Calc_ECPos(int ny, const unsigned int* pos, double* EC) const double EffMat[4]; Calc_EffMatPos(ny,pos,EffMat); + if (m_epsR) + m_epsR[ny][pos[0]][pos[1]][pos[2]] = EffMat[0]; + if (m_kappa) + m_kappa[ny][pos[0]][pos[1]][pos[2]] = EffMat[1]; + if (m_mueR) + m_mueR[ny][pos[0]][pos[1]][pos[2]] = EffMat[2]; + if (m_sigma) + m_sigma[ny][pos[0]][pos[1]][pos[2]] = EffMat[3]; double delta = GetEdgeLength(ny,pos); double area = GetEdgeArea(ny,pos); diff --git a/FDTD/operator.h b/FDTD/operator.h index dc7bd85..6db0430 100644 --- a/FDTD/operator.h +++ b/FDTD/operator.h @@ -119,6 +119,8 @@ public: virtual size_t GetNumberOfExtentions() const {return m_Op_exts.size();} virtual Operator_Extension* GetExtension(size_t index) const {return m_Op_exts.at(index);} + virtual void CleanupMaterialStorage(); + protected: //! use New() for creating a new Operator Operator(); @@ -126,6 +128,7 @@ protected: virtual void Init(); virtual void Reset(); virtual void InitOperator(); + virtual void InitDataStorage(); virtual void InitExcitation(); struct Grid_Path @@ -162,6 +165,12 @@ protected: //! Calc operator at certain \a pos virtual void Calc_ECOperatorPos(int n, unsigned int* pos); + //store material properties for post-processing + float**** m_epsR; + float**** m_kappa; + float**** m_mueR; + float**** m_sigma; + //EC elements, internal only! virtual void Init_EC(); virtual bool Calc_EC();