sf_pml: read grading function from xml & fix: string handling
parent
f2a3b19d6e
commit
c6bafbe885
|
@ -21,17 +21,31 @@
|
||||||
#include "tools/array_ops.h"
|
#include "tools/array_ops.h"
|
||||||
#include "fparser.hh"
|
#include "fparser.hh"
|
||||||
|
|
||||||
bool Build_Split_Field_PML(Operator* op, int BC[6], int size[6])
|
bool Build_Split_Field_PML(Operator* op, int BC[6], int size[6], string gradFunc)
|
||||||
{
|
{
|
||||||
for (int n=0;n<6;++n)
|
for (int n=0;n<6;++n)
|
||||||
{
|
{
|
||||||
if (BC[n]==3) //split field PML
|
if (BC[n]==3) //split field PML
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
if ((size[n]<4) || (size[n]>50))
|
||||||
|
{
|
||||||
|
cerr << "Build_Split_Field_PML: Warning, pml size invalid, skipping pml..." << endl;
|
||||||
|
delete op_pml_sf;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
op_pml_sf->SetPMLLength(size[n]);
|
op_pml_sf->SetPMLLength(size[n]);
|
||||||
op_pml_sf->SetBoundaryCondition(BC);
|
op_pml_sf->SetBoundaryCondition(BC);
|
||||||
|
|
||||||
|
if (!op_pml_sf->SetGradingFunction(gradFunc))
|
||||||
|
{
|
||||||
|
cerr << "Build_Split_Field_PML: Warning, pml grading function invalid, skipping pml..." << endl;
|
||||||
|
delete op_pml_sf;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
cerr << "Build_Split_Field_PML:: Warning, currently only pml planes are implemented... edges and corner coming soon..." << endl;
|
||||||
op->AddExtension(op_pml_sf);
|
op->AddExtension(op_pml_sf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +126,11 @@ void Operator_Ext_PML_SF::DeleteOP()
|
||||||
|
|
||||||
bool Operator_Ext_PML_SF::SetGradingFunction(string func)
|
bool Operator_Ext_PML_SF::SetGradingFunction(string func)
|
||||||
{
|
{
|
||||||
int res = m_GradingFunction->Parse(func.c_str(), "D,dl,W,Z,N");
|
if (func.empty())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
m_GradFunc = func;
|
||||||
|
int res = m_GradingFunction->Parse(m_GradFunc.c_str(), "D,dl,W,Z,N");
|
||||||
if(res < 0) return true;
|
if(res < 0) return true;
|
||||||
|
|
||||||
cerr << "Operator_Ext_PML_SF::SetGradingFunction: Warning, an error occured parsing the pml grading function (see below) ..." << endl;
|
cerr << "Operator_Ext_PML_SF::SetGradingFunction: Warning, an error occured parsing the pml grading function (see below) ..." << endl;
|
||||||
|
@ -401,4 +419,5 @@ void Operator_Ext_PML_SF_Plane::ShowStat(ostream &ostr) const
|
||||||
string top_bot[2] = {"bottom", "top"};
|
string top_bot[2] = {"bottom", "top"};
|
||||||
ostr << " Active direction\t: " << XYZ[m_ny] << " (" << top_bot[m_top] << ")" << endl;
|
ostr << " Active direction\t: " << XYZ[m_ny] << " (" << top_bot[m_top] << ")" << endl;
|
||||||
ostr << " PML width (cells)\t: " << m_numLines[m_ny] << endl;
|
ostr << " PML width (cells)\t: " << m_numLines[m_ny] << endl;
|
||||||
|
ostr << " Grading function\t: \"" << m_GradFunc << "\"" << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
class FunctionParser;
|
class FunctionParser;
|
||||||
|
|
||||||
//! 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], int size[6]);
|
bool Build_Split_Field_PML(Operator* op, int BC[6], int size[6], string gradFunc);
|
||||||
|
|
||||||
//! 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
|
||||||
|
@ -57,6 +57,8 @@ public:
|
||||||
N = number of cells for the pml
|
N = number of cells for the pml
|
||||||
Z = wave impedance at the current depth and position
|
Z = wave impedance at the current depth and position
|
||||||
example: SetGradingFunction("-log(1e-6)*log(2.5)/(2*dl*pow(2.5,W/dl)-1) * pow(2.5, D/dl) / Z");
|
example: SetGradingFunction("-log(1e-6)*log(2.5)/(2*dl*pow(2.5,W/dl)-1) * pow(2.5, D/dl) / Z");
|
||||||
|
|
||||||
|
An empty function string will be ignored.
|
||||||
*/
|
*/
|
||||||
virtual bool SetGradingFunction(string func);
|
virtual bool SetGradingFunction(string func);
|
||||||
|
|
||||||
|
@ -78,6 +80,7 @@ protected:
|
||||||
|
|
||||||
int m_BC[6];
|
int m_BC[6];
|
||||||
|
|
||||||
|
string m_GradFunc;
|
||||||
FunctionParser* m_GradingFunction;
|
FunctionParser* m_GradingFunction;
|
||||||
|
|
||||||
void InitOP();
|
void InitOP();
|
||||||
|
|
10
openems.cpp
10
openems.cpp
|
@ -159,6 +159,10 @@ bool openEMS::SetupBoundaryConditions(TiXmlElement* BC)
|
||||||
int bounds[6] = {0,0,0,0,0,0}; //default boundary cond. (PEC)
|
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
|
int pml_size[6] = {8,8,8,8,8,8}; //default pml size
|
||||||
string s_bc;
|
string s_bc;
|
||||||
|
const char* tmp = BC->Attribute("PML_Grading");
|
||||||
|
string pml_gradFunc;
|
||||||
|
if (tmp)
|
||||||
|
pml_gradFunc = string(tmp);
|
||||||
|
|
||||||
string bound_names[] = {"xmin","xmax","ymin","ymax","zmin","zmax"};
|
string bound_names[] = {"xmin","xmax","ymin","ymax","zmin","zmax"};
|
||||||
|
|
||||||
|
@ -169,7 +173,9 @@ bool openEMS::SetupBoundaryConditions(TiXmlElement* BC)
|
||||||
continue;
|
continue;
|
||||||
if (EC==TIXML_WRONG_TYPE)
|
if (EC==TIXML_WRONG_TYPE)
|
||||||
{
|
{
|
||||||
s_bc = string(BC->Attribute(bound_names[n].c_str()));
|
tmp = BC->Attribute(bound_names[n].c_str());
|
||||||
|
if (tmp)
|
||||||
|
s_bc = string(tmp);
|
||||||
if (s_bc=="PEC")
|
if (s_bc=="PEC")
|
||||||
bounds[n] = 0;
|
bounds[n] = 0;
|
||||||
else if (s_bc=="PMC")
|
else if (s_bc=="PMC")
|
||||||
|
@ -201,7 +207,7 @@ bool openEMS::SetupBoundaryConditions(TiXmlElement* BC)
|
||||||
FDTD_Op->AddExtension(op_ext_mur);
|
FDTD_Op->AddExtension(op_ext_mur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Build_Split_Field_PML(FDTD_Op,bounds,pml_size);
|
Build_Split_Field_PML(FDTD_Op,bounds,pml_size,pml_gradFunc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue