new engine interface for cylindrical fdtd, handling the closed cylinder

pull/1/head
Thorsten Liebig 2011-04-13 12:16:54 +02:00
parent 1bab004858
commit 1a06418914
6 changed files with 147 additions and 13 deletions

View File

@ -0,0 +1,79 @@
/*
* Copyright (C) 2011 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 "engine_interface_cylindrical_fdtd.h"
Engine_Interface_Cylindrical_FDTD::Engine_Interface_Cylindrical_FDTD(Operator* op, Engine* eng) : Engine_Interface_FDTD(op,eng)
{
m_Op_Cyl = dynamic_cast<Operator_Cylinder*>(op);
if (m_Op_Cyl==NULL)
{
cerr << "Engine_Interface_Cylindrical_FDTD::Engine_Interface_Cylindrical_FDTD: Error: Operator is not a cylindrical operator! Exit!" << endl;
exit(1);
}
}
Engine_Interface_Cylindrical_FDTD::~Engine_Interface_Cylindrical_FDTD()
{
}
double* Engine_Interface_Cylindrical_FDTD::GetHField(const unsigned int* pos, double* out) const
{
if ((m_Op_Cyl->GetClosedAlpha()==false) || (m_InterpolType!=NODE_INTERPOLATE))
return Engine_Interface_FDTD::GetHField(pos, out);
unsigned int iPos[] = {pos[0],pos[1],pos[2]};
if (pos[1]==m_Op->GetNumberOfLines(1)-1)
iPos[1]=0;
return Engine_Interface_FDTD::GetHField(iPos, out);
}
double* Engine_Interface_Cylindrical_FDTD::GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const
{
if (m_Op_Cyl->GetClosedAlpha()==false)
return Engine_Interface_FDTD::GetRawInterpolatedField(pos,out,type);
unsigned int iPos[] = {pos[0],pos[1],pos[2]};
switch (m_InterpolType)
{
default:
case NO_INTERPOLATION:
return Engine_Interface_FDTD::GetRawInterpolatedField(pos,out,type);
break;
case NODE_INTERPOLATE:
for (int n=0; n<3; ++n)
{
if (pos[1]==0)
iPos[1]=m_Op->GetNumberOfLines(1)-1;
return Engine_Interface_FDTD::GetRawInterpolatedField(iPos,out,type);
}
break;
case CELL_INTERPOLATE:
for (int n=0; n<3; ++n)
{
if (pos[1]==m_Op->GetNumberOfLines(1)-1)
iPos[1]=0;
return Engine_Interface_FDTD::GetRawInterpolatedField(iPos,out,type);
}
break;
}
//! this should not happen
return Engine_Interface_FDTD::GetRawInterpolatedField(pos,out,type);
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2011 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 "engine_interface_fdtd.h"
#include "operator_cylinder.h"
#ifndef ENGINE_INTERFACE_CYLINDRICAL_FDTD_H
#define ENGINE_INTERFACE_CYLINDRICAL_FDTD_H
class Engine_Interface_Cylindrical_FDTD : public Engine_Interface_FDTD
{
public:
Engine_Interface_Cylindrical_FDTD(Operator* op, Engine* eng);
virtual ~Engine_Interface_Cylindrical_FDTD();
virtual double* GetHField(const unsigned int* pos, double* out) const;
protected:
Operator_Cylinder* m_Op_Cyl;
//! Internal method to get an interpolated field of a given type. (0: E, 1: J, 2: rotH)
virtual double* GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const;
};
#endif // ENGINE_INTERFACE_CYLINDRICAL_FDTD_H

View File

@ -54,8 +54,10 @@ protected:
Operator* m_Op;
Engine* m_Eng;
double* GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const;
double GetRawField(unsigned int n, const unsigned int* pos, int type) const;
//! Internal method to get an interpolated field of a given type. (0: E, 1: J, 2: rotH)
virtual double* GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const;
//! Internal method to get a raw field of a given type. (0: E, 1: J, 2: rotH)
virtual double GetRawField(unsigned int n, const unsigned int* pos, int type) const;
};
#endif // ENGINE_INTERFACE_FDTD_H

View File

@ -83,7 +83,8 @@ SOURCES += FDTD/engine.cpp \
FDTD/excitation.cpp \
FDTD/operator_cylindermultigrid.cpp \
FDTD/engine_cylindermultigrid.cpp \
FDTD/engine_interface_fdtd.cpp
FDTD/engine_interface_fdtd.cpp \
FDTD/engine_interface_cylindrical_fdtd.cpp
# FDTD/extensions source files
SOURCES += FDTD/extensions/engine_extension.cpp \
@ -143,7 +144,8 @@ HEADERS += FDTD/engine.h \
FDTD/operator_multithread.h \
FDTD/operator_cylindermultigrid.h \
FDTD/engine_cylindermultigrid.h \
FDTD/engine_interface_fdtd.h
FDTD/engine_interface_fdtd.h \
FDTD/engine_interface_cylindrical_fdtd.h
# FDTD/extensions header files
HEADERS += FDTD/extensions/operator_extension.h \

View File

@ -27,6 +27,7 @@
#include "FDTD/extensions/operator_ext_upml.h"
#include "FDTD/extensions/operator_ext_lorentzmaterial.h"
#include "FDTD/engine_interface_fdtd.h"
#include "FDTD/engine_interface_cylindrical_fdtd.h"
#include "Common/processvoltage.h"
#include "Common/processcurrent.h"
#include "Common/processfieldprobe.h"
@ -278,6 +279,14 @@ bool openEMS::SetupBoundaryConditions(TiXmlElement* BC)
return true;
}
Engine_Interface_FDTD* openEMS::NewEngineInterface()
{
Operator_Cylinder* op_cyl = dynamic_cast<Operator_Cylinder*>(FDTD_Op);
if (op_cyl)
return new Engine_Interface_Cylindrical_FDTD(FDTD_Op,FDTD_Eng);
return new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng);
}
bool openEMS::SetupProcessing()
{
//*************** setup processing ************//
@ -310,21 +319,21 @@ bool openEMS::SetupProcessing()
{
if (pb->GetProbeType()==0)
{
ProcessVoltage* procVolt = new ProcessVoltage(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcessVoltage* procVolt = new ProcessVoltage(NewEngineInterface());
proc=procVolt;
}
else if (pb->GetProbeType()==1)
{
ProcessCurrent* procCurr = new ProcessCurrent(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcessCurrent* procCurr = new ProcessCurrent(NewEngineInterface());
proc=procCurr;
}
else if (pb->GetProbeType()==2)
proc = new ProcessFieldProbe(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng),0);
proc = new ProcessFieldProbe(NewEngineInterface(),0);
else if (pb->GetProbeType()==3)
proc = new ProcessFieldProbe(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng),1);
proc = new ProcessFieldProbe(NewEngineInterface(),1);
else if ((pb->GetProbeType()==10) || (pb->GetProbeType()==11))
{
ProcessModeMatch* pmm = new ProcessModeMatch(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcessModeMatch* pmm = new ProcessModeMatch(NewEngineInterface());
pmm->SetFieldType(pb->GetProbeType()-10);
pmm->SetModeFunction(0,pb->GetAttributeValue("ModeFunctionX"));
pmm->SetModeFunction(1,pb->GetAttributeValue("ModeFunctionY"));
@ -378,11 +387,11 @@ bool openEMS::SetupProcessing()
if (db)
{
if ((db->GetDumpType()>=0) && (db->GetDumpType()<=3))
ProcField = new ProcessFieldsTD(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcField = new ProcessFieldsTD(NewEngineInterface());
else if ((db->GetDumpType()>=10) && (db->GetDumpType()<=13))
ProcField = new ProcessFieldsFD(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcField = new ProcessFieldsFD(NewEngineInterface());
else if (db->GetDumpType()==20)
ProcField = new ProcessFieldsSAR(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcField = new ProcessFieldsSAR(NewEngineInterface());
else
cerr << "openEMS::SetupFDTD: unknown dump box type... skipping!" << endl;
if (ProcField)
@ -696,7 +705,7 @@ void openEMS::RunFDTD()
cout << "Running FDTD engine... this may take a while... grab a cup of coffee?!?" << endl;
//special handling of a field processing, needed to realize the end criteria...
ProcessFields* ProcField = new ProcessFields(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
ProcessFields* ProcField = new ProcessFields(NewEngineInterface());
PA->AddProcessing(ProcField);
double maxE=0,currE=0;

View File

@ -30,6 +30,7 @@ class Engine_Interface_FDTD;
class ProcessingArray;
class TiXmlElement;
class ContinuousStructure;
class Engine_Interface_FDTD;
double CalcDiffTime(timeval t1, timeval t2);
string FormatTime(int sec);
@ -63,6 +64,8 @@ public:
//! Check for abort conditions
bool CheckAbortCond();
Engine_Interface_FDTD* NewEngineInterface();
protected:
bool CylinderCoords;