allow boundary conditions strings e.g. "PEC" "PMC" or "PML_8"
parent
3d1c7f22b9
commit
e85f8ef8b7
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "tools/array_ops.h"
|
#include "tools/array_ops.h"
|
||||||
|
|
||||||
bool Build_Split_Field_PML(Operator* op, int BC[6])
|
bool Build_Split_Field_PML(Operator* op, int BC[6], int size[6])
|
||||||
{
|
{
|
||||||
for (int n=0;n<6;++n)
|
for (int n=0;n<6;++n)
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ bool Build_Split_Field_PML(Operator* op, int BC[6])
|
||||||
cerr << "Build_Split_Field_PML:: Warning, currently only pml planes are implemented... edges and corner coming soon..." << endl;
|
cerr << "Build_Split_Field_PML:: Warning, currently only pml planes are implemented... edges and corner coming soon..." << endl;
|
||||||
Operator_Ext_PML_SF_Plane* op_pml_sf = new Operator_Ext_PML_SF_Plane(op);
|
Operator_Ext_PML_SF_Plane* op_pml_sf = new Operator_Ext_PML_SF_Plane(op);
|
||||||
op_pml_sf->SetDirection(n/2,n%2);
|
op_pml_sf->SetDirection(n/2,n%2);
|
||||||
op_pml_sf->SetPMLLength(8);
|
op_pml_sf->SetPMLLength(size[n]);
|
||||||
op_pml_sf->SetBoundaryCondition(BC);
|
op_pml_sf->SetBoundaryCondition(BC);
|
||||||
op->AddExtension(op_pml_sf);
|
op->AddExtension(op_pml_sf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "operator_extension.h"
|
#include "operator_extension.h"
|
||||||
|
|
||||||
//! Insert split field pml planes, edges and corner as necessary by the given boundary conditions
|
//! Insert split field pml planes, edges and corner as necessary by the given boundary conditions
|
||||||
bool Build_Split_Field_PML(Operator* op, int BC[6]);
|
bool Build_Split_Field_PML(Operator* op, int BC[6], int size[6]);
|
||||||
|
|
||||||
//! This is the abstract operator extension for truncating the FDTD domain with a split field pml
|
//! This is the abstract operator extension for truncating the FDTD domain with a split field pml
|
||||||
class Operator_Ext_PML_SF : public Operator_Extension
|
class Operator_Ext_PML_SF : public Operator_Extension
|
||||||
|
|
75
openems.cpp
75
openems.cpp
|
@ -153,11 +153,63 @@ bool openEMS::parseCommandLineArgument( const char *argv )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool openEMS::SetupBoundaryConditions(TiXmlElement* BC)
|
||||||
|
{
|
||||||
|
int EC; //error code of tinyxml
|
||||||
|
int bounds[6] = {0,0,0,0,0,0}; //default boundary cond. (PEC)
|
||||||
|
int pml_size[6] = {8,8,8,8,8,8}; //default pml size
|
||||||
|
string s_bc;
|
||||||
|
|
||||||
|
string bound_names[] = {"xmin","xmax","ymin","ymax","zmin","zmax"};
|
||||||
|
|
||||||
|
for (int n=0;n<6;++n)
|
||||||
|
{
|
||||||
|
EC = BC->QueryIntAttribute(bound_names[n].c_str(),&bounds[n]);
|
||||||
|
if (EC==TIXML_SUCCESS)
|
||||||
|
continue;
|
||||||
|
if (EC==TIXML_WRONG_TYPE)
|
||||||
|
{
|
||||||
|
s_bc = string(BC->Attribute(bound_names[n].c_str()));
|
||||||
|
if (s_bc=="PEC")
|
||||||
|
bounds[n] = 0;
|
||||||
|
else if (s_bc=="PMC")
|
||||||
|
bounds[n] = 1;
|
||||||
|
else if (s_bc=="MUR")
|
||||||
|
bounds[n] = 2;
|
||||||
|
else if(strncmp(s_bc.c_str(),"PML_=",4)==0)
|
||||||
|
{
|
||||||
|
bounds[n] = 3;
|
||||||
|
pml_size[n] = atoi(s_bc.c_str()+4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cerr << "openEMS::SetupBoundaryConditions: Warning, boundary condition for \"" << bound_names[n] << "\" unknown... set to PEC " << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cerr << "openEMS::SetupBoundaryConditions: Warning, boundary condition for \"" << bound_names[n] << "\" not found... set to PEC " << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
FDTD_Op->SetBoundaryCondition(bounds); //operator only knows about PEC and PMC, everything else is defined by extensions (see below)
|
||||||
|
|
||||||
|
/**************************** create all operator/engine extensions here !!!! **********************************/
|
||||||
|
//Mur-ABC, defined as extension to the operator
|
||||||
|
for (int n=0;n<6;++n)
|
||||||
|
{
|
||||||
|
if (bounds[n]==2) //Mur-ABC
|
||||||
|
{
|
||||||
|
Operator_Ext_Mur_ABC* op_ext_mur = new Operator_Ext_Mur_ABC(FDTD_Op);
|
||||||
|
op_ext_mur->SetDirection(n/2,n%2);
|
||||||
|
FDTD_Op->AddExtension(op_ext_mur);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Build_Split_Field_PML(FDTD_Op,bounds,pml_size);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int openEMS::SetupFDTD(const char* file)
|
int openEMS::SetupFDTD(const char* file)
|
||||||
{
|
{
|
||||||
if (file==NULL) return -1;
|
if (file==NULL) return -1;
|
||||||
Reset();
|
Reset();
|
||||||
int bounds[6];
|
|
||||||
|
|
||||||
timeval startTime;
|
timeval startTime;
|
||||||
gettimeofday(&startTime,NULL);
|
gettimeofday(&startTime,NULL);
|
||||||
|
@ -218,12 +270,6 @@ int openEMS::SetupFDTD(const char* file)
|
||||||
cerr << "Can't read openEMS boundary cond Settings... " << endl;
|
cerr << "Can't read openEMS boundary cond Settings... " << endl;
|
||||||
exit(-3);
|
exit(-3);
|
||||||
}
|
}
|
||||||
BC->QueryIntAttribute("xmin",&bounds[0]);
|
|
||||||
BC->QueryIntAttribute("xmax",&bounds[1]);
|
|
||||||
BC->QueryIntAttribute("ymin",&bounds[2]);
|
|
||||||
BC->QueryIntAttribute("ymax",&bounds[3]);
|
|
||||||
BC->QueryIntAttribute("zmin",&bounds[4]);
|
|
||||||
BC->QueryIntAttribute("zmax",&bounds[5]);
|
|
||||||
|
|
||||||
cout << "Read Geometry..." << endl;
|
cout << "Read Geometry..." << endl;
|
||||||
ContinuousStructure CSX;
|
ContinuousStructure CSX;
|
||||||
|
@ -262,20 +308,7 @@ int openEMS::SetupFDTD(const char* file)
|
||||||
|
|
||||||
if (FDTD_Op->SetGeometryCSX(&CSX)==false) return(2);
|
if (FDTD_Op->SetGeometryCSX(&CSX)==false) return(2);
|
||||||
|
|
||||||
FDTD_Op->SetBoundaryCondition(bounds); //operator only knows about PEC and PMC, everything else is defined by extensions (see below)
|
SetupBoundaryConditions(BC);
|
||||||
|
|
||||||
/**************************** create all operator/engine extensions here !!!! **********************************/
|
|
||||||
//Mur-ABC, defined as extension to the operator
|
|
||||||
for (int n=0;n<6;++n)
|
|
||||||
{
|
|
||||||
if (bounds[n]==2) //Mur-ABC
|
|
||||||
{
|
|
||||||
Operator_Ext_Mur_ABC* op_ext_mur = new Operator_Ext_Mur_ABC(FDTD_Op);
|
|
||||||
op_ext_mur->SetDirection(n/2,n%2);
|
|
||||||
FDTD_Op->AddExtension(op_ext_mur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Build_Split_Field_PML(FDTD_Op,bounds);
|
|
||||||
|
|
||||||
if (CSX.GetQtyPropertyType(CSProperties::LORENTZMATERIAL)>0)
|
if (CSX.GetQtyPropertyType(CSProperties::LORENTZMATERIAL)>0)
|
||||||
FDTD_Op->AddExtension(new Operator_Ext_LorentzMaterial(FDTD_Op));
|
FDTD_Op->AddExtension(new Operator_Ext_LorentzMaterial(FDTD_Op));
|
||||||
|
|
|
@ -63,6 +63,9 @@ protected:
|
||||||
enum EngineType {EngineType_Standard, EngineType_SSE, EngineType_SSE_Compressed, EngineType_Multithreaded};
|
enum EngineType {EngineType_Standard, EngineType_SSE, EngineType_SSE_Compressed, EngineType_Multithreaded};
|
||||||
EngineType m_engine;
|
EngineType m_engine;
|
||||||
unsigned int m_engine_numThreads;
|
unsigned int m_engine_numThreads;
|
||||||
|
|
||||||
|
//! Read boundary conditions from xml element and apply to FDTD operator
|
||||||
|
bool SetupBoundaryConditions(TiXmlElement* BC);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OPENEMS_H
|
#endif // OPENEMS_H
|
||||||
|
|
Loading…
Reference in New Issue