allocate dynamic CSX and allow access from basic operator
This commit is contained in:
parent
10ac457899
commit
24bac9499f
@ -32,6 +32,14 @@ Operator_Base::~Operator_Base()
|
|||||||
Delete();
|
Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Operator_Base::SetGeometryCSX(ContinuousStructure* geo)
|
||||||
|
{
|
||||||
|
if (geo==NULL) return false;
|
||||||
|
CSX = geo;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Operator_Base::GetDirName(int ny) const
|
std::string Operator_Base::GetDirName(int ny) const
|
||||||
{
|
{
|
||||||
if (ny==0) return "x";
|
if (ny==0) return "x";
|
||||||
@ -42,6 +50,8 @@ std::string Operator_Base::GetDirName(int ny) const
|
|||||||
|
|
||||||
void Operator_Base::Init()
|
void Operator_Base::Init()
|
||||||
{
|
{
|
||||||
|
CSX = NULL;
|
||||||
|
|
||||||
dT = 0;
|
dT = 0;
|
||||||
for (int n=0; n<3; ++n)
|
for (int n=0; n<3; ++n)
|
||||||
discLines[n]=NULL;
|
discLines[n]=NULL;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#ifndef OPERATOR_BASE_H
|
#ifndef OPERATOR_BASE_H
|
||||||
#define OPERATOR_BASE_H
|
#define OPERATOR_BASE_H
|
||||||
|
|
||||||
|
#include "ContinuousStructure.h"
|
||||||
#include "tools/global.h"
|
#include "tools/global.h"
|
||||||
#include "Common/processing.h"
|
#include "Common/processing.h"
|
||||||
#include "string"
|
#include "string"
|
||||||
@ -28,6 +29,9 @@ class Operator_Base
|
|||||||
public:
|
public:
|
||||||
virtual ~Operator_Base();
|
virtual ~Operator_Base();
|
||||||
|
|
||||||
|
virtual bool SetGeometryCSX(ContinuousStructure* geo);
|
||||||
|
virtual ContinuousStructure* GetGeometryCSX() const {return CSX;}
|
||||||
|
|
||||||
//! Get the timestep used by this operator
|
//! Get the timestep used by this operator
|
||||||
virtual double GetTimestep() const {return dT;};
|
virtual double GetTimestep() const {return dT;};
|
||||||
|
|
||||||
@ -77,9 +81,12 @@ public:
|
|||||||
//! Check storage flags and cleanup
|
//! Check storage flags and cleanup
|
||||||
virtual void CleanupMaterialStorage() = 0;
|
virtual void CleanupMaterialStorage() = 0;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Operator_Base();
|
Operator_Base();
|
||||||
|
|
||||||
|
ContinuousStructure* CSX;
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
//! Cleanup data and reset
|
//! Cleanup data and reset
|
||||||
void Delete();
|
void Delete();
|
||||||
|
@ -56,8 +56,6 @@ void Operator::Init()
|
|||||||
{
|
{
|
||||||
Operator_Base::Init();
|
Operator_Base::Init();
|
||||||
|
|
||||||
CSX = NULL;
|
|
||||||
|
|
||||||
vv=NULL;
|
vv=NULL;
|
||||||
vi=NULL;
|
vi=NULL;
|
||||||
iv=NULL;
|
iv=NULL;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#ifndef OPERATOR_H
|
#ifndef OPERATOR_H
|
||||||
#define OPERATOR_H
|
#define OPERATOR_H
|
||||||
|
|
||||||
#include "ContinuousStructure.h"
|
|
||||||
#include "tools/AdrOp.h"
|
#include "tools/AdrOp.h"
|
||||||
#include "tools/constants.h"
|
#include "tools/constants.h"
|
||||||
#include "excitation.h"
|
#include "excitation.h"
|
||||||
@ -45,7 +44,6 @@ public:
|
|||||||
virtual Engine* CreateEngine() const;
|
virtual Engine* CreateEngine() const;
|
||||||
|
|
||||||
virtual bool SetGeometryCSX(ContinuousStructure* geo);
|
virtual bool SetGeometryCSX(ContinuousStructure* geo);
|
||||||
virtual ContinuousStructure* GetGeometryCSX() {return CSX;}
|
|
||||||
|
|
||||||
virtual int CalcECOperator( DebugFlags debugFlags = None );
|
virtual int CalcECOperator( DebugFlags debugFlags = None );
|
||||||
|
|
||||||
@ -140,8 +138,6 @@ protected:
|
|||||||
};
|
};
|
||||||
struct Grid_Path FindPath(double start[], double stop[]);
|
struct Grid_Path FindPath(double start[], double stop[]);
|
||||||
|
|
||||||
ContinuousStructure* CSX;
|
|
||||||
|
|
||||||
//! Calculate the field excitations.
|
//! Calculate the field excitations.
|
||||||
virtual bool CalcFieldExcitation();
|
virtual bool CalcFieldExcitation();
|
||||||
|
|
||||||
|
33
openems.cpp
33
openems.cpp
@ -53,6 +53,7 @@ openEMS::openEMS()
|
|||||||
{
|
{
|
||||||
FDTD_Op=NULL;
|
FDTD_Op=NULL;
|
||||||
FDTD_Eng=NULL;
|
FDTD_Eng=NULL;
|
||||||
|
m_CSX=NULL;
|
||||||
PA=NULL;
|
PA=NULL;
|
||||||
CylinderCoords = false;
|
CylinderCoords = false;
|
||||||
Enable_Dumps = true;
|
Enable_Dumps = true;
|
||||||
@ -83,6 +84,8 @@ void openEMS::Reset()
|
|||||||
FDTD_Eng=0;
|
FDTD_Eng=0;
|
||||||
delete FDTD_Op;
|
delete FDTD_Op;
|
||||||
FDTD_Op=0;
|
FDTD_Op=0;
|
||||||
|
delete m_CSX;
|
||||||
|
m_CSX=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief processes a command line argument
|
//! \brief processes a command line argument
|
||||||
@ -271,7 +274,7 @@ bool openEMS::SetupBoundaryConditions(TiXmlElement* BC)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool openEMS::SetupProcessing(ContinuousStructure& CSX)
|
bool openEMS::SetupProcessing()
|
||||||
{
|
{
|
||||||
//*************** setup processing ************//
|
//*************** setup processing ************//
|
||||||
cout << "Setting up processing..." << endl;
|
cout << "Setting up processing..." << endl;
|
||||||
@ -281,7 +284,7 @@ bool openEMS::SetupProcessing(ContinuousStructure& CSX)
|
|||||||
|
|
||||||
double start[3];
|
double start[3];
|
||||||
double stop[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)
|
for (size_t i=0; i<Probes.size(); ++i)
|
||||||
{
|
{
|
||||||
//only looking for one prim atm
|
//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)
|
for (size_t i=0; i<DumpProps.size(); ++i)
|
||||||
{
|
{
|
||||||
ProcessFields* ProcField=NULL;
|
ProcessFields* ProcField=NULL;
|
||||||
@ -423,9 +426,9 @@ bool openEMS::SetupProcessing(ContinuousStructure& CSX)
|
|||||||
return true;
|
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)
|
for (size_t i=0; i<DumpProps.size(); ++i)
|
||||||
{
|
{
|
||||||
CSPropDumpBox* db = DumpProps.at(i)->ToDumpBox();
|
CSPropDumpBox* db = DumpProps.at(i)->ToDumpBox();
|
||||||
@ -508,8 +511,8 @@ int openEMS::SetupFDTD(const char* file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cout << "Read Geometry..." << endl;
|
cout << "Read Geometry..." << endl;
|
||||||
ContinuousStructure CSX;
|
m_CSX = new ContinuousStructure();
|
||||||
string EC(CSX.ReadFromXML(openEMSxml));
|
string EC(m_CSX->ReadFromXML(openEMSxml));
|
||||||
if (EC.empty()==false)
|
if (EC.empty()==false)
|
||||||
{
|
{
|
||||||
cerr << EC << endl;
|
cerr << EC << endl;
|
||||||
@ -517,14 +520,14 @@ int openEMS::SetupFDTD(const char* file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CylinderCoords)
|
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;
|
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)
|
if (m_debugCSX)
|
||||||
CSX.Write2XML("debugCSX.xml");
|
m_CSX->Write2XML("debugm_CSX->xml");
|
||||||
|
|
||||||
//*************** setup operator ************//
|
//*************** setup operator ************//
|
||||||
if (CylinderCoords)
|
if (CylinderCoords)
|
||||||
@ -555,11 +558,11 @@ int openEMS::SetupFDTD(const char* file)
|
|||||||
FDTD_Op = Operator::New();
|
FDTD_Op = Operator::New();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FDTD_Op->SetGeometryCSX(&CSX)==false) return(2);
|
if (FDTD_Op->SetGeometryCSX(m_CSX)==false) return(2);
|
||||||
|
|
||||||
SetupBoundaryConditions(BC);
|
SetupBoundaryConditions(BC);
|
||||||
|
|
||||||
if (CSX.GetQtyPropertyType(CSProperties::LORENTZMATERIAL)>0)
|
if (m_CSX->GetQtyPropertyType(CSProperties::LORENTZMATERIAL)>0)
|
||||||
FDTD_Op->AddExtension(new Operator_Ext_LorentzMaterial(FDTD_Op));
|
FDTD_Op->AddExtension(new Operator_Ext_LorentzMaterial(FDTD_Op));
|
||||||
|
|
||||||
double timestep=0;
|
double timestep=0;
|
||||||
@ -568,7 +571,7 @@ int openEMS::SetupFDTD(const char* file)
|
|||||||
FDTD_Op->SetTimestep(timestep);
|
FDTD_Op->SetTimestep(timestep);
|
||||||
|
|
||||||
//check all properties to request material storage during operator creation...
|
//check all properties to request material storage during operator creation...
|
||||||
SetupMaterialStorages(CSX);
|
SetupMaterialStorages();
|
||||||
|
|
||||||
/******************* create the EC-FDTD operator *****************************/
|
/******************* create the EC-FDTD operator *****************************/
|
||||||
Operator::DebugFlags debugFlags = Operator::None;
|
Operator::DebugFlags debugFlags = Operator::None;
|
||||||
@ -613,14 +616,14 @@ int openEMS::SetupFDTD(const char* file)
|
|||||||
FDTD_Eng = FDTD_Op->CreateEngine();
|
FDTD_Eng = FDTD_Op->CreateEngine();
|
||||||
|
|
||||||
//setup all processing classes
|
//setup all processing classes
|
||||||
if (SetupProcessing(CSX)==false)
|
if (SetupProcessing()==false)
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
// Cleanup all unused material storages...
|
// Cleanup all unused material storages...
|
||||||
FDTD_Op->CleanupMaterialStorage();
|
FDTD_Op->CleanupMaterialStorage();
|
||||||
|
|
||||||
//check and warn for unused properties and primitives
|
//check and warn for unused properties and primitives
|
||||||
CSX.WarnUnusedPrimitves(cerr);
|
m_CSX->WarnUnusedPrimitves(cerr);
|
||||||
|
|
||||||
// dump all boxes (voltage, current, fields, ...)
|
// dump all boxes (voltage, current, fields, ...)
|
||||||
if (m_debugBox)
|
if (m_debugBox)
|
||||||
|
@ -61,6 +61,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
bool CylinderCoords;
|
bool CylinderCoords;
|
||||||
|
|
||||||
|
ContinuousStructure* m_CSX;
|
||||||
|
|
||||||
//! Number of Timesteps
|
//! Number of Timesteps
|
||||||
unsigned int NrTS;
|
unsigned int NrTS;
|
||||||
bool Enable_Dumps;
|
bool Enable_Dumps;
|
||||||
@ -84,10 +86,10 @@ protected:
|
|||||||
bool SetupBoundaryConditions(TiXmlElement* BC);
|
bool SetupBoundaryConditions(TiXmlElement* BC);
|
||||||
|
|
||||||
//! Check whether or not the FDTD-Operator has to store material data.
|
//! Check whether or not the FDTD-Operator has to store material data.
|
||||||
bool SetupMaterialStorages(ContinuousStructure& CSX);
|
bool SetupMaterialStorages();
|
||||||
|
|
||||||
//! Setup all processings.
|
//! Setup all processings.
|
||||||
bool SetupProcessing(ContinuousStructure& CSX);
|
bool SetupProcessing();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OPENEMS_H
|
#endif // OPENEMS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user