diff --git a/Common/operator_base.cpp b/Common/operator_base.cpp index 858d751..11c4eaf 100644 --- a/Common/operator_base.cpp +++ b/Common/operator_base.cpp @@ -32,6 +32,14 @@ Operator_Base::~Operator_Base() Delete(); } +bool Operator_Base::SetGeometryCSX(ContinuousStructure* geo) +{ + if (geo==NULL) return false; + CSX = geo; + + return true; +} + std::string Operator_Base::GetDirName(int ny) const { if (ny==0) return "x"; @@ -42,6 +50,8 @@ std::string Operator_Base::GetDirName(int ny) const void Operator_Base::Init() { + CSX = NULL; + dT = 0; for (int n=0; n<3; ++n) discLines[n]=NULL; diff --git a/Common/operator_base.h b/Common/operator_base.h index e7caba1..901ae52 100644 --- a/Common/operator_base.h +++ b/Common/operator_base.h @@ -18,6 +18,7 @@ #ifndef OPERATOR_BASE_H #define OPERATOR_BASE_H +#include "ContinuousStructure.h" #include "tools/global.h" #include "Common/processing.h" #include "string" @@ -28,6 +29,9 @@ class Operator_Base public: virtual ~Operator_Base(); + virtual bool SetGeometryCSX(ContinuousStructure* geo); + virtual ContinuousStructure* GetGeometryCSX() const {return CSX;} + //! Get the timestep used by this operator virtual double GetTimestep() const {return dT;}; @@ -77,9 +81,12 @@ public: //! Check storage flags and cleanup virtual void CleanupMaterialStorage() = 0; + protected: Operator_Base(); + ContinuousStructure* CSX; + virtual void Init(); //! Cleanup data and reset void Delete(); diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index f0188e5..279de8c 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -56,8 +56,6 @@ void Operator::Init() { Operator_Base::Init(); - CSX = NULL; - vv=NULL; vi=NULL; iv=NULL; diff --git a/FDTD/operator.h b/FDTD/operator.h index 673ca8a..c960d3b 100644 --- a/FDTD/operator.h +++ b/FDTD/operator.h @@ -18,7 +18,6 @@ #ifndef OPERATOR_H #define OPERATOR_H -#include "ContinuousStructure.h" #include "tools/AdrOp.h" #include "tools/constants.h" #include "excitation.h" @@ -45,7 +44,6 @@ public: virtual Engine* CreateEngine() const; virtual bool SetGeometryCSX(ContinuousStructure* geo); - virtual ContinuousStructure* GetGeometryCSX() {return CSX;} virtual int CalcECOperator( DebugFlags debugFlags = None ); @@ -140,8 +138,6 @@ protected: }; struct Grid_Path FindPath(double start[], double stop[]); - ContinuousStructure* CSX; - //! Calculate the field excitations. virtual bool CalcFieldExcitation(); diff --git a/openems.cpp b/openems.cpp index 2a6ee40..dcd5f6f 100644 --- a/openems.cpp +++ b/openems.cpp @@ -53,6 +53,7 @@ openEMS::openEMS() { FDTD_Op=NULL; FDTD_Eng=NULL; + m_CSX=NULL; PA=NULL; CylinderCoords = false; Enable_Dumps = true; @@ -83,6 +84,8 @@ void openEMS::Reset() FDTD_Eng=0; delete FDTD_Op; FDTD_Op=0; + delete m_CSX; + m_CSX=0; } //! \brief processes a command line argument @@ -271,7 +274,7 @@ bool openEMS::SetupBoundaryConditions(TiXmlElement* BC) return true; } -bool openEMS::SetupProcessing(ContinuousStructure& CSX) +bool openEMS::SetupProcessing() { //*************** setup processing ************// cout << "Setting up processing..." << endl; @@ -281,7 +284,7 @@ bool openEMS::SetupProcessing(ContinuousStructure& CSX) double start[3]; double stop[3]; - vector Probes = CSX.GetPropertyByType(CSProperties::PROBEBOX); + vector Probes = m_CSX->GetPropertyByType(CSProperties::PROBEBOX); for (size_t i=0; i DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX); + vector DumpProps = m_CSX->GetPropertyByType(CSProperties::DUMPBOX); for (size_t i=0; i DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX); + vector DumpProps = m_CSX->GetPropertyByType(CSProperties::DUMPBOX); for (size_t i=0; iToDumpBox(); @@ -508,8 +511,8 @@ int openEMS::SetupFDTD(const char* file) } cout << "Read Geometry..." << endl; - ContinuousStructure CSX; - string EC(CSX.ReadFromXML(openEMSxml)); + m_CSX = new ContinuousStructure(); + string EC(m_CSX->ReadFromXML(openEMSxml)); if (EC.empty()==false) { cerr << EC << endl; @@ -517,14 +520,14 @@ int openEMS::SetupFDTD(const char* file) } if (CylinderCoords) - if (CSX.GetCoordInputType()!=CYLINDRICAL) + if (m_CSX->GetCoordInputType()!=CYLINDRICAL) { cerr << "openEMS::SetupFDTD: Warning: Coordinate system found in the CSX file is not a cylindrical. Forcing to cylindrical coordinate system!" << endl; - CSX.SetCoordInputType(CYLINDRICAL); //tell CSX to use cylinder-coords + m_CSX->SetCoordInputType(CYLINDRICAL); //tell CSX to use cylinder-coords } if (m_debugCSX) - CSX.Write2XML("debugCSX.xml"); + m_CSX->Write2XML("debugm_CSX->xml"); //*************** setup operator ************// if (CylinderCoords) @@ -555,11 +558,11 @@ int openEMS::SetupFDTD(const char* file) FDTD_Op = Operator::New(); } - if (FDTD_Op->SetGeometryCSX(&CSX)==false) return(2); + if (FDTD_Op->SetGeometryCSX(m_CSX)==false) return(2); SetupBoundaryConditions(BC); - if (CSX.GetQtyPropertyType(CSProperties::LORENTZMATERIAL)>0) + if (m_CSX->GetQtyPropertyType(CSProperties::LORENTZMATERIAL)>0) FDTD_Op->AddExtension(new Operator_Ext_LorentzMaterial(FDTD_Op)); double timestep=0; @@ -568,7 +571,7 @@ int openEMS::SetupFDTD(const char* file) FDTD_Op->SetTimestep(timestep); //check all properties to request material storage during operator creation... - SetupMaterialStorages(CSX); + SetupMaterialStorages(); /******************* create the EC-FDTD operator *****************************/ Operator::DebugFlags debugFlags = Operator::None; @@ -613,14 +616,14 @@ int openEMS::SetupFDTD(const char* file) FDTD_Eng = FDTD_Op->CreateEngine(); //setup all processing classes - if (SetupProcessing(CSX)==false) + if (SetupProcessing()==false) return 2; // Cleanup all unused material storages... FDTD_Op->CleanupMaterialStorage(); //check and warn for unused properties and primitives - CSX.WarnUnusedPrimitves(cerr); + m_CSX->WarnUnusedPrimitves(cerr); // dump all boxes (voltage, current, fields, ...) if (m_debugBox) diff --git a/openems.h b/openems.h index a6328f2..485c8c9 100644 --- a/openems.h +++ b/openems.h @@ -61,6 +61,8 @@ public: protected: bool CylinderCoords; + ContinuousStructure* m_CSX; + //! Number of Timesteps unsigned int NrTS; bool Enable_Dumps; @@ -84,10 +86,10 @@ protected: bool SetupBoundaryConditions(TiXmlElement* BC); //! Check whether or not the FDTD-Operator has to store material data. - bool SetupMaterialStorages(ContinuousStructure& CSX); + bool SetupMaterialStorages(); //! Setup all processings. - bool SetupProcessing(ContinuousStructure& CSX); + bool SetupProcessing(); }; #endif // OPENEMS_H