2010-04-27 21:06:42 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "operator_ext_mur_abc.h"
|
|
|
|
#include "engine_ext_mur_abc.h"
|
|
|
|
|
|
|
|
#include "tools/array_ops.h"
|
|
|
|
|
|
|
|
Operator_Ext_Mur_ABC::Operator_Ext_Mur_ABC(Operator* op) : Operator_Extension(op)
|
2010-09-03 09:53:33 +00:00
|
|
|
{
|
|
|
|
Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
Operator_Ext_Mur_ABC::~Operator_Ext_Mur_ABC()
|
|
|
|
{
|
|
|
|
Delete2DArray(m_Mur_Coeff_nyP,m_numLines);
|
|
|
|
m_Mur_Coeff_nyP = NULL;
|
|
|
|
Delete2DArray(m_Mur_Coeff_nyPP,m_numLines);
|
|
|
|
m_Mur_Coeff_nyPP = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Operator_Ext_Mur_ABC::Operator_Ext_Mur_ABC(Operator* op, Operator_Ext_Mur_ABC* op_ext) : Operator_Extension(op, op_ext)
|
|
|
|
{
|
|
|
|
Initialize();
|
|
|
|
m_v_phase = op_ext->m_v_phase;
|
|
|
|
SetDirection(op_ext->m_ny,op_ext->m_top);
|
|
|
|
}
|
|
|
|
|
|
|
|
Operator_Extension* Operator_Ext_Mur_ABC::Clone(Operator* op)
|
|
|
|
{
|
|
|
|
if (dynamic_cast<Operator_Ext_Mur_ABC*>(this)==NULL)
|
|
|
|
return NULL;
|
|
|
|
return new Operator_Ext_Mur_ABC(op, this);
|
|
|
|
}
|
|
|
|
|
2010-09-22 07:58:45 +00:00
|
|
|
bool Operator_Ext_Mur_ABC::IsCylinderCoordsSave() const
|
|
|
|
{
|
|
|
|
if (m_ny==2)
|
|
|
|
return true;
|
|
|
|
if ((m_ny==0) && (m_top))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Operator_Ext_Mur_ABC::IsCylindricalMultiGridSave(bool child) const
|
|
|
|
{
|
|
|
|
if (m_ny==2) //always allow in z-direction
|
|
|
|
return true;
|
|
|
|
if ((m_ny==0) && (m_top) && (!child)) //if top r-direction and is not a child grid allow Mur...
|
|
|
|
return true;
|
|
|
|
//in all other cases this ABC is not save to use in CylindricalMultiGrid
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-03 09:53:33 +00:00
|
|
|
void Operator_Ext_Mur_ABC::Initialize()
|
2010-04-27 21:06:42 +00:00
|
|
|
{
|
|
|
|
m_ny = -1;
|
|
|
|
m_nyP = -1;
|
|
|
|
m_nyPP = -1;
|
|
|
|
m_LineNr = 0;
|
|
|
|
m_LineNr_Shift = 0;
|
2010-04-28 19:45:05 +00:00
|
|
|
|
2010-08-10 05:50:53 +00:00
|
|
|
m_v_phase = 0.0;
|
|
|
|
|
2010-04-28 19:45:05 +00:00
|
|
|
m_Mur_Coeff_nyP = NULL;
|
|
|
|
m_Mur_Coeff_nyPP = NULL;
|
|
|
|
|
|
|
|
m_numLines[0]=0;
|
|
|
|
m_numLines[1]=0;
|
2010-04-27 21:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Operator_Ext_Mur_ABC::SetDirection(int ny, bool top_ny)
|
|
|
|
{
|
|
|
|
if ((ny<0) || (ny>2))
|
|
|
|
return;
|
2010-04-28 19:45:05 +00:00
|
|
|
|
|
|
|
Delete2DArray(m_Mur_Coeff_nyP,m_numLines);
|
|
|
|
Delete2DArray(m_Mur_Coeff_nyPP,m_numLines);
|
|
|
|
|
2010-04-27 21:06:42 +00:00
|
|
|
m_ny = ny;
|
2010-09-03 09:53:33 +00:00
|
|
|
m_top = top_ny;
|
2010-04-27 21:06:42 +00:00
|
|
|
m_nyP = (ny+1)%3;
|
|
|
|
m_nyPP = (ny+2)%3;
|
|
|
|
if (!top_ny)
|
|
|
|
{
|
|
|
|
m_LineNr = 0;
|
|
|
|
m_LineNr_Shift = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_LineNr = m_Op->GetNumberOfLines(m_ny)-1;
|
|
|
|
m_LineNr_Shift = m_Op->GetNumberOfLines(m_ny) - 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_numLines[0] = m_Op->GetNumberOfLines(m_nyP);
|
|
|
|
m_numLines[1] = m_Op->GetNumberOfLines(m_nyPP);
|
2010-04-28 19:45:05 +00:00
|
|
|
|
2010-06-06 18:22:05 +00:00
|
|
|
m_Mur_Coeff_nyP = Create2DArray<FDTD_FLOAT>(m_numLines);
|
|
|
|
m_Mur_Coeff_nyPP = Create2DArray<FDTD_FLOAT>(m_numLines);
|
2010-04-28 19:45:05 +00:00
|
|
|
|
2010-04-27 21:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Operator_Ext_Mur_ABC::BuildExtension()
|
|
|
|
{
|
|
|
|
if (m_ny<0)
|
|
|
|
{
|
|
|
|
cerr << "Operator_Ext_Mur_ABC::BuildExtension: Warning, Extension not initialized! Use SetDirection!! Abort build!!" << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
double dT = m_Op->GetTimestep();
|
|
|
|
unsigned int pos[] = {0,0,0};
|
|
|
|
pos[m_ny] = m_LineNr;
|
2010-12-08 15:55:27 +00:00
|
|
|
double delta = fabs(m_Op->GetEdgeLength(m_ny,pos));
|
2010-04-28 19:45:05 +00:00
|
|
|
double coord[] = {0,0,0};
|
|
|
|
coord[0] = m_Op->GetDiscLine(0,pos[0]);
|
|
|
|
coord[1] = m_Op->GetDiscLine(1,pos[1]);
|
|
|
|
coord[2] = m_Op->GetDiscLine(2,pos[2]);
|
|
|
|
|
|
|
|
double eps,mue;
|
|
|
|
double c0t;
|
|
|
|
|
|
|
|
if (m_LineNr==0)
|
|
|
|
coord[m_ny] = m_Op->GetDiscLine(m_ny,pos[m_ny]) + delta/2 / m_Op->GetGridDelta();
|
|
|
|
else
|
|
|
|
coord[m_ny] = m_Op->GetDiscLine(m_ny,pos[m_ny]) - delta/2 / m_Op->GetGridDelta();
|
|
|
|
|
2010-12-06 12:04:37 +00:00
|
|
|
for (pos[m_nyP]=0; pos[m_nyP]<m_numLines[0]; ++pos[m_nyP])
|
2010-04-28 19:45:05 +00:00
|
|
|
{
|
|
|
|
coord[m_nyP] = m_Op->GetDiscLine(m_nyP,pos[m_nyP]);
|
2010-12-06 12:04:37 +00:00
|
|
|
for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
|
2010-04-28 19:45:05 +00:00
|
|
|
{
|
|
|
|
coord[m_nyPP] = m_Op->GetDiscLine(m_nyPP,pos[m_nyPP]);
|
2010-10-19 14:54:35 +00:00
|
|
|
CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord, CSProperties::MATERIAL, false);
|
2010-04-28 19:45:05 +00:00
|
|
|
if (prop)
|
|
|
|
{
|
|
|
|
CSPropMaterial* mat = prop->ToMaterial();
|
|
|
|
|
|
|
|
//nP
|
|
|
|
eps = mat->GetEpsilonWeighted(m_nyP,coord);
|
|
|
|
mue = mat->GetMueWeighted(m_nyP,coord);
|
2010-08-10 05:50:53 +00:00
|
|
|
if (m_v_phase>0.0)
|
|
|
|
c0t = m_v_phase * dT;
|
|
|
|
else
|
|
|
|
c0t = __C0__ * dT / sqrt(eps*mue);
|
2010-04-28 19:45:05 +00:00
|
|
|
m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] = (c0t - delta) / (c0t + delta);
|
|
|
|
|
|
|
|
//nPP
|
|
|
|
eps = mat->GetEpsilonWeighted(m_nyPP,coord);
|
|
|
|
mue = mat->GetMueWeighted(m_nyPP,coord);
|
2010-08-10 05:50:53 +00:00
|
|
|
if (m_v_phase>0.0)
|
|
|
|
c0t = m_v_phase * dT;
|
|
|
|
else
|
|
|
|
c0t = __C0__ * dT / sqrt(eps*mue);
|
2010-04-28 19:45:05 +00:00
|
|
|
m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] = (c0t - delta) / (c0t + delta);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-10 05:50:53 +00:00
|
|
|
if (m_v_phase>0.0)
|
|
|
|
c0t = m_v_phase * dT;
|
|
|
|
else
|
|
|
|
c0t = __C0__ * dT;
|
2010-04-28 19:45:05 +00:00
|
|
|
m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] = (c0t - delta) / (c0t + delta);
|
|
|
|
m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] = m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]];
|
|
|
|
}
|
|
|
|
// cerr << m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] << " : " << m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// cerr << "Operator_Ext_Mur_ABC::BuildExtension(): " << m_ny << " @ " << m_LineNr << endl;
|
2010-04-27 21:06:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Engine_Extension* Operator_Ext_Mur_ABC::CreateEngineExtention()
|
|
|
|
{
|
|
|
|
Engine_Ext_Mur_ABC* eng_ext = new Engine_Ext_Mur_ABC(this);
|
|
|
|
return eng_ext;
|
|
|
|
}
|
2010-07-11 21:45:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
void Operator_Ext_Mur_ABC::ShowStat(ostream &ostr) const
|
|
|
|
{
|
|
|
|
Operator_Extension::ShowStat(ostr);
|
|
|
|
string XYZ[3] = {"x","y","z"};
|
2010-08-10 05:50:53 +00:00
|
|
|
ostr << " Active direction\t: " << XYZ[m_ny] << " at line: " << m_LineNr << endl;
|
|
|
|
if (m_v_phase>0.0)
|
|
|
|
ostr << " Used phase velocity\t: " << m_v_phase << " (" << m_v_phase/__C0__ << " * c_0)" <<endl;
|
2010-07-11 21:45:41 +00:00
|
|
|
}
|