allocate dynamic CSX and allow access from basic operator

This commit is contained in:
Thorsten Liebig 2011-01-31 12:00:00 +01:00
parent 10ac457899
commit 24bac9499f
6 changed files with 39 additions and 23 deletions

View File

@ -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;

View File

@ -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();

View File

@ -56,8 +56,6 @@ void Operator::Init()
{
Operator_Base::Init();
CSX = NULL;
vv=NULL;
vi=NULL;
iv=NULL;

View File

@ -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();

View File

@ -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<CSProperties*> Probes = CSX.GetPropertyByType(CSProperties::PROBEBOX);
vector<CSProperties*> Probes = m_CSX->GetPropertyByType(CSProperties::PROBEBOX);
for (size_t i=0; i<Probes.size(); ++i)
{
//only looking for one prim atm
@ -350,7 +353,7 @@ bool openEMS::SetupProcessing(ContinuousStructure& CSX)
}
}
vector<CSProperties*> DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX);
vector<CSProperties*> DumpProps = m_CSX->GetPropertyByType(CSProperties::DUMPBOX);
for (size_t i=0; i<DumpProps.size(); ++i)
{
ProcessFields* ProcField=NULL;
@ -423,9 +426,9 @@ bool openEMS::SetupProcessing(ContinuousStructure& CSX)
return true;
}
bool openEMS::SetupMaterialStorages(ContinuousStructure& CSX)
bool openEMS::SetupMaterialStorages()
{
vector<CSProperties*> DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX);
vector<CSProperties*> DumpProps = m_CSX->GetPropertyByType(CSProperties::DUMPBOX);
for (size_t i=0; i<DumpProps.size(); ++i)
{
CSPropDumpBox* db = DumpProps.at(i)->ToDumpBox();
@ -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)

View File

@ -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