removed FDTD engine from (nearly) all processing classes
todo: - remove FTDT operator from all processingX and replace by abstract-base-operator? - remove FDTD engine from ProcessCurrent - remove or cleanup ProcessEField + ProcessHField Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>pull/1/head
parent
ab1119f468
commit
32cbdc5d0b
|
@ -44,9 +44,18 @@ public:
|
||||||
//! Get the (interpolated) magnetic field at \p pos. \sa SetInterpolationType
|
//! Get the (interpolated) magnetic field at \p pos. \sa SetInterpolationType
|
||||||
virtual double* GetHField(const unsigned int* pos, double* out) const {UNUSED(pos);return out;}
|
virtual double* GetHField(const unsigned int* pos, double* out) const {UNUSED(pos);return out;}
|
||||||
|
|
||||||
|
//! Calculate the electric field integral along a given line
|
||||||
|
virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const {UNUSED(start);UNUSED(stop);return 0.0;}
|
||||||
|
|
||||||
//! Convert the interpolation type into a string.
|
//! Convert the interpolation type into a string.
|
||||||
static std::string GetInterpolationNameByType(InterpolationType mode);
|
static std::string GetInterpolationNameByType(InterpolationType mode);
|
||||||
|
|
||||||
|
//! Get the current simulation time
|
||||||
|
virtual double GetTime(bool dualTime=false) const {UNUSED(dualTime);return 0.0;}
|
||||||
|
|
||||||
|
//! Get the current number of timesteps
|
||||||
|
virtual unsigned int GetNumberOfTimesteps() const {return 0;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Engine_Interface_Base();
|
Engine_Interface_Base();
|
||||||
|
|
||||||
|
|
|
@ -161,3 +161,24 @@ double* Engine_Interface_FDTD::GetHField(const unsigned int* pos, double* out) c
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Engine_Interface_FDTD::CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const
|
||||||
|
{
|
||||||
|
double result=0;
|
||||||
|
for (int n=0;n<3;++n)
|
||||||
|
{
|
||||||
|
if (start[n]<stop[n])
|
||||||
|
{
|
||||||
|
unsigned int pos[3]={start[0],start[1],start[2]};
|
||||||
|
for (;pos[n]<stop[n];++pos[n])
|
||||||
|
result += m_Eng->GetVolt(n,pos[0],pos[1],pos[2]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned int pos[3]={stop[0],stop[1],stop[2]};
|
||||||
|
for (;pos[n]<start[n];++pos[n])
|
||||||
|
result -= m_Eng->GetVolt(n,pos[0],pos[1],pos[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,11 @@ public:
|
||||||
virtual double* GetEField(const unsigned int* pos, double* out) const;
|
virtual double* GetEField(const unsigned int* pos, double* out) const;
|
||||||
virtual double* GetHField(const unsigned int* pos, double* out) const;
|
virtual double* GetHField(const unsigned int* pos, double* out) const;
|
||||||
|
|
||||||
|
virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const;
|
||||||
|
|
||||||
|
virtual double GetTime(bool dualTime=false) const {return ((double)m_Eng->GetNumberOfTimesteps() + (double)dualTime*0.5)*m_Op->GetTimestep();};
|
||||||
|
virtual unsigned int GetNumberOfTimesteps() const {return m_Eng->GetNumberOfTimesteps();}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Operator* m_Op;
|
Operator* m_Op;
|
||||||
Engine* m_Eng;
|
Engine* m_Eng;
|
||||||
|
|
|
@ -19,8 +19,9 @@
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "process_efield.h"
|
#include "process_efield.h"
|
||||||
|
|
||||||
ProcessEField::ProcessEField(Operator* op, Engine* eng) : Processing(op, eng)
|
ProcessEField::ProcessEField(Operator* op, Engine* eng) : Processing(op)
|
||||||
{
|
{
|
||||||
|
Eng = eng;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessEField::~ProcessEField()
|
ProcessEField::~ProcessEField()
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
virtual int Process();
|
virtual int Process();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Engine* Eng;
|
||||||
vector<double_complex> FD_Values[3];
|
vector<double_complex> FD_Values[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,10 @@
|
||||||
|
|
||||||
#include "tools/global.h"
|
#include "tools/global.h"
|
||||||
#include "processcurrent.h"
|
#include "processcurrent.h"
|
||||||
|
#include "engine_interface_fdtd.h"
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
ProcessCurrent::ProcessCurrent(Operator* op, Engine* eng) : ProcessIntegral(op, eng)
|
ProcessCurrent::ProcessCurrent(Operator* op) : ProcessIntegral(op)
|
||||||
{
|
{
|
||||||
m_TimeShift = op->GetTimestep()/2.0;
|
m_TimeShift = op->GetTimestep()/2.0;
|
||||||
m_dualMesh = true;
|
m_dualMesh = true;
|
||||||
|
@ -33,96 +34,103 @@ double ProcessCurrent::CalcIntegral()
|
||||||
{
|
{
|
||||||
FDTD_FLOAT current=0;
|
FDTD_FLOAT current=0;
|
||||||
|
|
||||||
int Dump_Dim = 0;
|
Engine_Interface_FDTD* EI_FDTD = dynamic_cast<Engine_Interface_FDTD*>(m_Eng_Interface);
|
||||||
int NormDir = 0;
|
|
||||||
|
|
||||||
for (int n=0;n<3;++n)
|
if (EI_FDTD)
|
||||||
{
|
{
|
||||||
if (start[n]>stop[n])
|
const Engine* Eng = EI_FDTD->GetFDTDEngine();
|
||||||
|
|
||||||
|
int Dump_Dim = 0;
|
||||||
|
int NormDir = 0;
|
||||||
|
|
||||||
|
for (int n=0;n<3;++n)
|
||||||
{
|
{
|
||||||
unsigned int help=start[n];
|
if (start[n]>stop[n])
|
||||||
start[n]=stop[n];
|
{
|
||||||
stop[n]=help;
|
unsigned int help=start[n];
|
||||||
bool b_help=m_start_inside[n];
|
start[n]=stop[n];
|
||||||
m_start_inside[n] = m_stop_inside[n];
|
stop[n]=help;
|
||||||
m_stop_inside[n] = b_help;
|
bool b_help=m_start_inside[n];
|
||||||
|
m_start_inside[n] = m_stop_inside[n];
|
||||||
|
m_stop_inside[n] = b_help;
|
||||||
|
}
|
||||||
|
if (m_stop_inside[n]==false) // integrate up to the wall, Operator::SnapToMesh would give numLines[n]-2
|
||||||
|
stop[n]=Op->GetNumberOfLines(n)-1;
|
||||||
|
|
||||||
|
if (stop[n]>start[n])
|
||||||
|
++Dump_Dim;
|
||||||
|
if (stop[n] == start[n])
|
||||||
|
NormDir = n;
|
||||||
}
|
}
|
||||||
if (m_stop_inside[n]==false) // integrate up to the wall, Operator::SnapToMesh would give numLines[n]-2
|
|
||||||
stop[n]=Op->GetNumberOfLines(n)-1;
|
|
||||||
|
|
||||||
if (stop[n]>start[n])
|
if (Dump_Dim!=2)
|
||||||
++Dump_Dim;
|
{
|
||||||
if (stop[n] == start[n])
|
cerr << "ProcessCurrent::Process(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << Dump_Dim << ") --> i = 0" << endl;
|
||||||
NormDir = n;
|
current = 0;
|
||||||
}
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
if (Dump_Dim!=2)
|
switch (NormDir)
|
||||||
{
|
{
|
||||||
cerr << "ProcessCurrent::Process(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << Dump_Dim << ") --> i = 0" << endl;
|
case 0:
|
||||||
current = 0;
|
//y-current
|
||||||
return 0.0;
|
if (m_stop_inside[0] && m_start_inside[2])
|
||||||
}
|
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
||||||
|
current+=Eng->GetCurr(1,stop[0],i,start[2]);
|
||||||
switch (NormDir)
|
//z-current
|
||||||
{
|
if (m_stop_inside[0] && m_stop_inside[1])
|
||||||
case 0:
|
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||||
//y-current
|
current+=Eng->GetCurr(2,stop[0],stop[1],i);
|
||||||
if (m_stop_inside[0] && m_start_inside[2])
|
//y-current
|
||||||
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
if (m_start_inside[0] && m_stop_inside[2])
|
||||||
current+=Eng->GetCurr(1,stop[0],i,start[2]);
|
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
||||||
//z-current
|
current-=Eng->GetCurr(1,start[0],i,stop[2]);
|
||||||
if (m_stop_inside[0] && m_stop_inside[1])
|
//z-current
|
||||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
if (m_start_inside[0] && m_start_inside[1])
|
||||||
current+=Eng->GetCurr(2,stop[0],stop[1],i);
|
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||||
//y-current
|
current-=Eng->GetCurr(2,start[0],start[1],i);
|
||||||
if (m_start_inside[0] && m_stop_inside[2])
|
break;
|
||||||
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
case 1:
|
||||||
current-=Eng->GetCurr(1,start[0],i,stop[2]);
|
//z-current
|
||||||
//z-current
|
if (m_start_inside[0] && m_start_inside[1])
|
||||||
if (m_start_inside[0] && m_start_inside[1])
|
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
current+=Eng->GetCurr(2,start[0],start[1],i);
|
||||||
current-=Eng->GetCurr(2,start[0],start[1],i);
|
//x-current
|
||||||
break;
|
if (m_stop_inside[1] && m_stop_inside[2])
|
||||||
case 1:
|
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||||
//z-current
|
current+=Eng->GetCurr(0,i,stop[1],stop[2]);
|
||||||
if (m_start_inside[0] && m_start_inside[1])
|
//z-current
|
||||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
if (m_stop_inside[0] && m_stop_inside[1])
|
||||||
current+=Eng->GetCurr(2,start[0],start[1],i);
|
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||||
//x-current
|
current-=Eng->GetCurr(2,stop[0],stop[1],i);
|
||||||
if (m_stop_inside[1] && m_stop_inside[2])
|
//x-current
|
||||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
if (m_start_inside[1] && m_start_inside[2])
|
||||||
current+=Eng->GetCurr(0,i,stop[1],stop[2]);
|
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||||
//z-current
|
current-=Eng->GetCurr(0,i,start[1],start[2]);
|
||||||
if (m_stop_inside[0] && m_stop_inside[1])
|
break;
|
||||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
case 2:
|
||||||
current-=Eng->GetCurr(2,stop[0],stop[1],i);
|
//x-current
|
||||||
//x-current
|
if (m_start_inside[1] && m_start_inside[2])
|
||||||
if (m_start_inside[1] && m_start_inside[2])
|
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
current+=Eng->GetCurr(0,i,start[1],start[2]);
|
||||||
current-=Eng->GetCurr(0,i,start[1],start[2]);
|
//y-current
|
||||||
break;
|
if (m_stop_inside[0] && m_start_inside[2])
|
||||||
case 2:
|
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
||||||
//x-current
|
current+=Eng->GetCurr(1,stop[0],i,start[2]);
|
||||||
if (m_start_inside[1] && m_start_inside[2])
|
//x-current
|
||||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
if (m_stop_inside[1] && m_stop_inside[2])
|
||||||
current+=Eng->GetCurr(0,i,start[1],start[2]);
|
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||||
//y-current
|
current-=Eng->GetCurr(0,i,stop[1],stop[2]);
|
||||||
if (m_stop_inside[0] && m_start_inside[2])
|
//y-current
|
||||||
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
if (m_start_inside[0] && m_stop_inside[2])
|
||||||
current+=Eng->GetCurr(1,stop[0],i,start[2]);
|
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
||||||
//x-current
|
current-=Eng->GetCurr(1,start[0],i,stop[2]);
|
||||||
if (m_stop_inside[1] && m_stop_inside[2])
|
break;
|
||||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
default:
|
||||||
current-=Eng->GetCurr(0,i,stop[1],stop[2]);
|
//this cannot happen...
|
||||||
//y-current
|
return 0.0;
|
||||||
if (m_start_inside[0] && m_stop_inside[2])
|
break;
|
||||||
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
}
|
||||||
current-=Eng->GetCurr(1,start[0],i,stop[2]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//this cannot happen...
|
|
||||||
return 0.0;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return current;
|
return current;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
class ProcessCurrent : public ProcessIntegral
|
class ProcessCurrent : public ProcessIntegral
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProcessCurrent(Operator* op, Engine* eng);
|
ProcessCurrent(Operator* op);
|
||||||
virtual ~ProcessCurrent();
|
virtual ~ProcessCurrent();
|
||||||
|
|
||||||
//! Integrate currents flowing through an area
|
//! Integrate currents flowing through an area
|
||||||
|
|
|
@ -19,8 +19,9 @@
|
||||||
#include <H5Cpp.h>
|
#include <H5Cpp.h>
|
||||||
#include "tools/global.h"
|
#include "tools/global.h"
|
||||||
#include "processfields.h"
|
#include "processfields.h"
|
||||||
|
#include "engine_interface_fdtd.h"
|
||||||
|
|
||||||
ProcessFields::ProcessFields(Operator* op, Engine* eng) : Processing(op, eng)
|
ProcessFields::ProcessFields(Operator* op) : Processing(op)
|
||||||
{
|
{
|
||||||
m_DumpType = E_FIELD_DUMP;
|
m_DumpType = E_FIELD_DUMP;
|
||||||
// vtk-file is default
|
// vtk-file is default
|
||||||
|
@ -212,30 +213,35 @@ void ProcessFields::DefineStartStopCoord(double* dstart, double* dstop)
|
||||||
|
|
||||||
double ProcessFields::CalcTotalEnergy() const
|
double ProcessFields::CalcTotalEnergy() const
|
||||||
{
|
{
|
||||||
if (!Eng)
|
double energy=0.0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
double energy=0;
|
Engine_Interface_FDTD* EI_FDTD = dynamic_cast<Engine_Interface_FDTD*>(m_Eng_Interface);
|
||||||
unsigned int pos[3];
|
|
||||||
for (pos[0]=0;pos[0]<Op->GetNumberOfLines(0);++pos[0])
|
if (EI_FDTD)
|
||||||
{
|
{
|
||||||
for (pos[1]=0;pos[1]<Op->GetNumberOfLines(1);++pos[1])
|
const Engine* Eng = EI_FDTD->GetFDTDEngine();
|
||||||
|
|
||||||
|
unsigned int pos[3];
|
||||||
|
for (pos[0]=0;pos[0]<Op->GetNumberOfLines(0);++pos[0])
|
||||||
{
|
{
|
||||||
for (pos[2]=0;pos[2]<Op->GetNumberOfLines(2);++pos[2])
|
for (pos[1]=0;pos[1]<Op->GetNumberOfLines(1);++pos[1])
|
||||||
{
|
{
|
||||||
energy+=fabs(Eng->GetVolt(0,pos[0],pos[1],pos[2]) * Eng->GetCurr(1,pos[0],pos[1],pos[2]));
|
for (pos[2]=0;pos[2]<Op->GetNumberOfLines(2);++pos[2])
|
||||||
energy+=fabs(Eng->GetVolt(0,pos[0],pos[1],pos[2]) * Eng->GetCurr(2,pos[0],pos[1],pos[2]));
|
{
|
||||||
energy+=fabs(Eng->GetVolt(1,pos[0],pos[1],pos[2]) * Eng->GetCurr(0,pos[0],pos[1],pos[2]));
|
energy+=fabs(Eng->GetVolt(0,pos[0],pos[1],pos[2]) * Eng->GetCurr(1,pos[0],pos[1],pos[2]));
|
||||||
energy+=fabs(Eng->GetVolt(1,pos[0],pos[1],pos[2]) * Eng->GetCurr(2,pos[0],pos[1],pos[2]));
|
energy+=fabs(Eng->GetVolt(0,pos[0],pos[1],pos[2]) * Eng->GetCurr(2,pos[0],pos[1],pos[2]));
|
||||||
energy+=fabs(Eng->GetVolt(2,pos[0],pos[1],pos[2]) * Eng->GetCurr(0,pos[0],pos[1],pos[2]));
|
energy+=fabs(Eng->GetVolt(1,pos[0],pos[1],pos[2]) * Eng->GetCurr(0,pos[0],pos[1],pos[2]));
|
||||||
energy+=fabs(Eng->GetVolt(2,pos[0],pos[1],pos[2]) * Eng->GetCurr(1,pos[0],pos[1],pos[2]));
|
energy+=fabs(Eng->GetVolt(1,pos[0],pos[1],pos[2]) * Eng->GetCurr(2,pos[0],pos[1],pos[2]));
|
||||||
|
energy+=fabs(Eng->GetVolt(2,pos[0],pos[1],pos[2]) * Eng->GetCurr(0,pos[0],pos[1],pos[2]));
|
||||||
|
energy+=fabs(Eng->GetVolt(2,pos[0],pos[1],pos[2]) * Eng->GetCurr(1,pos[0],pos[1],pos[2]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return energy*0.5;
|
return energy*0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir)
|
void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir)
|
||||||
{
|
{
|
||||||
if (dir>2) return;
|
if (dir>2) return;
|
||||||
if (dir<0)
|
if (dir<0)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
class ProcessFields : public Processing
|
class ProcessFields : public Processing
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProcessFields(Operator* op, Engine* eng);
|
ProcessFields(Operator* op);
|
||||||
virtual ~ProcessFields();
|
virtual ~ProcessFields();
|
||||||
|
|
||||||
enum FileType { VTK_FILETYPE, HDF5_FILETYPE};
|
enum FileType { VTK_FILETYPE, HDF5_FILETYPE};
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
ProcessFieldsTD::ProcessFieldsTD(Operator* op, Engine* eng) : ProcessFields(op, eng)
|
ProcessFieldsTD::ProcessFieldsTD(Operator* op) : ProcessFields(op)
|
||||||
{
|
{
|
||||||
pad_length = 8;
|
pad_length = 8;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ int ProcessFieldsTD::Process()
|
||||||
if (m_fileType==VTK_FILETYPE)
|
if (m_fileType==VTK_FILETYPE)
|
||||||
{
|
{
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << filePattern << std::setw( pad_length ) << std::setfill( '0' ) << Eng->GetNumberOfTimesteps() << ".vtk";
|
ss << filePattern << std::setw( pad_length ) << std::setfill( '0' ) << m_Eng_Interface->GetNumberOfTimesteps() << ".vtk";
|
||||||
filename = ss.str();
|
filename = ss.str();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -107,8 +107,8 @@ int ProcessFieldsTD::Process()
|
||||||
else if (m_fileType==HDF5_FILETYPE)
|
else if (m_fileType==HDF5_FILETYPE)
|
||||||
{
|
{
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << std::setw( pad_length ) << std::setfill( '0' ) << Eng->GetNumberOfTimesteps();
|
ss << std::setw( pad_length ) << std::setfill( '0' ) << m_Eng_Interface->GetNumberOfTimesteps();
|
||||||
DumpVectorArray2HDF5(filename.c_str(),string( ss.str() ),field,numLines,(0.5+Eng->GetNumberOfTimesteps())*Op->GetTimestep());
|
DumpVectorArray2HDF5(filename.c_str(),string( ss.str() ),field,numLines,(0.5+m_Eng_Interface->GetNumberOfTimesteps())*Op->GetTimestep());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cerr << "ProcessFieldsTD::Process: unknown File-Type" << endl;
|
cerr << "ProcessFieldsTD::Process: unknown File-Type" << endl;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
class ProcessFieldsTD : public ProcessFields
|
class ProcessFieldsTD : public ProcessFields
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProcessFieldsTD(Operator* op, Engine* eng);
|
ProcessFieldsTD(Operator* op);
|
||||||
virtual ~ProcessFieldsTD();
|
virtual ~ProcessFieldsTD();
|
||||||
|
|
||||||
virtual int Process();
|
virtual int Process();
|
||||||
|
|
|
@ -21,10 +21,9 @@
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
|
||||||
Processing::Processing(Operator* op, Engine* eng)
|
Processing::Processing(Operator* op)
|
||||||
{
|
{
|
||||||
Op=op;
|
Op=op;
|
||||||
Eng=eng;
|
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
m_PS_pos = 0;
|
m_PS_pos = 0;
|
||||||
SetPrecision(12);
|
SetPrecision(12);
|
||||||
|
@ -59,7 +58,7 @@ bool Processing::CheckTimestep()
|
||||||
{
|
{
|
||||||
if (m_ProcessSteps.size()>m_PS_pos)
|
if (m_ProcessSteps.size()>m_PS_pos)
|
||||||
{
|
{
|
||||||
if (m_ProcessSteps.at(m_PS_pos)==Eng->GetNumberOfTimesteps())
|
if (m_ProcessSteps.at(m_PS_pos)==m_Eng_Interface->GetNumberOfTimesteps())
|
||||||
{
|
{
|
||||||
++m_PS_pos;
|
++m_PS_pos;
|
||||||
return true;
|
return true;
|
||||||
|
@ -67,12 +66,12 @@ bool Processing::CheckTimestep()
|
||||||
}
|
}
|
||||||
if (ProcessInterval)
|
if (ProcessInterval)
|
||||||
{
|
{
|
||||||
if (Eng->GetNumberOfTimesteps()%ProcessInterval==0) return true;
|
if (m_Eng_Interface->GetNumberOfTimesteps()%ProcessInterval==0) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_FD_Interval)
|
if (m_FD_Interval)
|
||||||
{
|
{
|
||||||
if (Eng->GetNumberOfTimesteps()%m_FD_Interval==0) return true;
|
if (m_Eng_Interface->GetNumberOfTimesteps()%m_FD_Interval==0) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -83,11 +82,11 @@ int Processing::GetNextInterval() const
|
||||||
int next=INT_MAX;
|
int next=INT_MAX;
|
||||||
if (m_ProcessSteps.size()>m_PS_pos)
|
if (m_ProcessSteps.size()>m_PS_pos)
|
||||||
{
|
{
|
||||||
next = (int)m_ProcessSteps.at(m_PS_pos)-(int)Eng->GetNumberOfTimesteps();
|
next = (int)m_ProcessSteps.at(m_PS_pos)-(int)m_Eng_Interface->GetNumberOfTimesteps();
|
||||||
}
|
}
|
||||||
if (ProcessInterval!=0)
|
if (ProcessInterval!=0)
|
||||||
{
|
{
|
||||||
int next_Interval = (int)ProcessInterval - (int)Eng->GetNumberOfTimesteps()%ProcessInterval;
|
int next_Interval = (int)ProcessInterval - (int)m_Eng_Interface->GetNumberOfTimesteps()%ProcessInterval;
|
||||||
if (next_Interval<next)
|
if (next_Interval<next)
|
||||||
next = next_Interval;
|
next = next_Interval;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +94,7 @@ int Processing::GetNextInterval() const
|
||||||
//check for FD sample interval
|
//check for FD sample interval
|
||||||
if (m_FD_Interval!=0)
|
if (m_FD_Interval!=0)
|
||||||
{
|
{
|
||||||
int next_Interval = (int)m_FD_Interval - (int)Eng->GetNumberOfTimesteps()%m_FD_Interval;
|
int next_Interval = (int)m_FD_Interval - (int)m_Eng_Interface->GetNumberOfTimesteps()%m_FD_Interval;
|
||||||
if (next_Interval<next)
|
if (next_Interval<next)
|
||||||
next = next_Interval;
|
next = next_Interval;
|
||||||
}
|
}
|
||||||
|
@ -165,58 +164,6 @@ void Processing::DefineStartStopCoord(double* dstart, double* dstop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double Processing::CalcLineIntegral(unsigned int* start, unsigned int* stop, int field) const
|
|
||||||
{
|
|
||||||
switch (field) {
|
|
||||||
case 0:
|
|
||||||
return CalcLineIntegral_V( start, stop );
|
|
||||||
case 1:
|
|
||||||
return CalcLineIntegral_I( start, stop );
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
double Processing::CalcLineIntegral_I(unsigned int* start, unsigned int* stop) const
|
|
||||||
{
|
|
||||||
double result=0;
|
|
||||||
for (int n=0;n<3;++n)
|
|
||||||
{
|
|
||||||
if (start[n]<stop[n])
|
|
||||||
{
|
|
||||||
unsigned int pos[3]={start[0],start[1],start[2]};
|
|
||||||
for (;pos[n]<stop[n];++pos[n])
|
|
||||||
result += Eng->GetCurr(n,pos[0],pos[1],pos[2]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned int pos[3]={stop[0],stop[1],stop[2]};
|
|
||||||
for (;pos[n]<start[n];++pos[n])
|
|
||||||
result -= Eng->GetCurr(n,pos[0],pos[1],pos[2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
double Processing::CalcLineIntegral_V(unsigned int* start, unsigned int* stop) const
|
|
||||||
{
|
|
||||||
double result=0;
|
|
||||||
for (int n=0;n<3;++n)
|
|
||||||
{
|
|
||||||
if (start[n]<stop[n])
|
|
||||||
{
|
|
||||||
unsigned int pos[3]={start[0],start[1],start[2]};
|
|
||||||
for (;pos[n]<stop[n];++pos[n])
|
|
||||||
result += Eng->GetVolt(n,pos[0],pos[1],pos[2]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned int pos[3]={stop[0],stop[1],stop[2]};
|
|
||||||
for (;pos[n]<start[n];++pos[n])
|
|
||||||
result -= Eng->GetVolt(n,pos[0],pos[1],pos[2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Processing::OpenFile( string outfile )
|
void Processing::OpenFile( string outfile )
|
||||||
{
|
{
|
||||||
if (file.is_open())
|
if (file.is_open())
|
||||||
|
|
|
@ -33,7 +33,7 @@ typedef std::complex<double> double_complex;
|
||||||
class Processing
|
class Processing
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Processing(Operator* op, Engine* eng);
|
Processing(Operator* op);
|
||||||
virtual ~Processing();
|
virtual ~Processing();
|
||||||
|
|
||||||
//! Set the interface to the engine. Each processing needs its own engine interface. This class will take ownership and cleanup the interface on deletion!
|
//! Set the interface to the engine. Each processing needs its own engine interface. This class will take ownership and cleanup the interface on deletion!
|
||||||
|
@ -85,7 +85,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
Engine_Interface_Base* m_Eng_Interface;
|
Engine_Interface_Base* m_Eng_Interface;
|
||||||
Operator* Op;
|
Operator* Op;
|
||||||
Engine* Eng;
|
|
||||||
MeshType m_Mesh_Type;
|
MeshType m_Mesh_Type;
|
||||||
|
|
||||||
unsigned int m_precision;
|
unsigned int m_precision;
|
||||||
|
@ -128,10 +127,6 @@ protected:
|
||||||
string m_filename;
|
string m_filename;
|
||||||
|
|
||||||
virtual void OpenFile(string outfile);
|
virtual void OpenFile(string outfile);
|
||||||
|
|
||||||
double CalcLineIntegral(unsigned int* start, unsigned int* stop, int field) const;
|
|
||||||
double CalcLineIntegral_I(unsigned int* start, unsigned int* stop) const;
|
|
||||||
double CalcLineIntegral_V(unsigned int* start, unsigned int* stop) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProcessingArray
|
class ProcessingArray
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "processintegral.h"
|
#include "processintegral.h"
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
ProcessIntegral::ProcessIntegral(Operator* op, Engine* eng) : Processing(op, eng)
|
ProcessIntegral::ProcessIntegral(Operator* op) : Processing(op)
|
||||||
{
|
{
|
||||||
m_TimeShift = 0.0;
|
m_TimeShift = 0.0;
|
||||||
m_Results=NULL;
|
m_Results=NULL;
|
||||||
|
@ -56,11 +56,11 @@ int ProcessIntegral::Process()
|
||||||
int NrInt = GetNumberOfIntegrals();
|
int NrInt = GetNumberOfIntegrals();
|
||||||
double integral = m_Results[0] * m_weight;
|
double integral = m_Results[0] * m_weight;
|
||||||
|
|
||||||
double time = (double)Eng->GetNumberOfTimesteps()*Op->GetTimestep() + m_TimeShift;
|
double time = m_Eng_Interface->GetTime(false) + m_TimeShift;
|
||||||
|
|
||||||
if (ProcessInterval)
|
if (ProcessInterval)
|
||||||
{
|
{
|
||||||
if (Eng->GetNumberOfTimesteps()%ProcessInterval==0)
|
if (m_Eng_Interface->GetNumberOfTimesteps()%ProcessInterval==0)
|
||||||
{
|
{
|
||||||
TD_Values.push_back(integral);
|
TD_Values.push_back(integral);
|
||||||
file << setprecision(m_precision) << time;
|
file << setprecision(m_precision) << time;
|
||||||
|
@ -72,7 +72,7 @@ int ProcessIntegral::Process()
|
||||||
|
|
||||||
if (m_FD_Interval)
|
if (m_FD_Interval)
|
||||||
{
|
{
|
||||||
if (Eng->GetNumberOfTimesteps()%m_FD_Interval==0)
|
if (m_Eng_Interface->GetNumberOfTimesteps()%m_FD_Interval==0)
|
||||||
{
|
{
|
||||||
double T = time;
|
double T = time;
|
||||||
for (size_t n=0;n<m_FD_Samples.size();++n)
|
for (size_t n=0;n<m_FD_Samples.size();++n)
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
virtual int Process();
|
virtual int Process();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ProcessIntegral(Operator* op, Engine* eng);
|
ProcessIntegral(Operator* op);
|
||||||
|
|
||||||
//! timeshift to be used in TD and FD data, e.g. 0.5*dT in case of current based parameter
|
//! timeshift to be used in TD and FD data, e.g. 0.5*dT in case of current based parameter
|
||||||
double m_TimeShift;
|
double m_TimeShift;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "CSFunctionParser.h"
|
#include "CSFunctionParser.h"
|
||||||
#include "tools/array_ops.h"
|
#include "tools/array_ops.h"
|
||||||
|
|
||||||
ProcessModeMatch::ProcessModeMatch(Operator* op, Engine* eng) : ProcessIntegral(op, eng)
|
ProcessModeMatch::ProcessModeMatch(Operator* op) : ProcessIntegral(op)
|
||||||
{
|
{
|
||||||
for (int n=0;n<2;++n)
|
for (int n=0;n<2;++n)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@ class CSFunctionParser;
|
||||||
class ProcessModeMatch : public ProcessIntegral
|
class ProcessModeMatch : public ProcessIntegral
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProcessModeMatch(Operator* op, Engine* eng);
|
ProcessModeMatch(Operator* op);
|
||||||
virtual ~ProcessModeMatch();
|
virtual ~ProcessModeMatch();
|
||||||
|
|
||||||
virtual void InitProcess();
|
virtual void InitProcess();
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "processvoltage.h"
|
#include "processvoltage.h"
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
ProcessVoltage::ProcessVoltage(Operator* op, Engine* eng) : ProcessIntegral(op, eng)
|
ProcessVoltage::ProcessVoltage(Operator* op) : ProcessIntegral(op)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,5 +29,5 @@ ProcessVoltage::~ProcessVoltage()
|
||||||
double ProcessVoltage::CalcIntegral()
|
double ProcessVoltage::CalcIntegral()
|
||||||
{
|
{
|
||||||
//integrate voltages from start to stop on a line
|
//integrate voltages from start to stop on a line
|
||||||
return CalcLineIntegral(start,stop,0);
|
return m_Eng_Interface->CalcVoltageIntegral(start,stop);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
class ProcessVoltage : public ProcessIntegral
|
class ProcessVoltage : public ProcessIntegral
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProcessVoltage(Operator* op, Engine* eng);
|
ProcessVoltage(Operator* op);
|
||||||
virtual ~ProcessVoltage();
|
virtual ~ProcessVoltage();
|
||||||
|
|
||||||
virtual double CalcIntegral();
|
virtual double CalcIntegral();
|
||||||
|
|
11
openems.cpp
11
openems.cpp
|
@ -447,12 +447,12 @@ int openEMS::SetupFDTD(const char* file)
|
||||||
{
|
{
|
||||||
if (pb->GetProbeType()==0)
|
if (pb->GetProbeType()==0)
|
||||||
{
|
{
|
||||||
ProcessVoltage* procVolt = new ProcessVoltage(FDTD_Op,FDTD_Eng);
|
ProcessVoltage* procVolt = new ProcessVoltage(FDTD_Op);
|
||||||
proc=procVolt;
|
proc=procVolt;
|
||||||
}
|
}
|
||||||
else if (pb->GetProbeType()==1)
|
else if (pb->GetProbeType()==1)
|
||||||
{
|
{
|
||||||
ProcessCurrent* procCurr = new ProcessCurrent(FDTD_Op,FDTD_Eng);
|
ProcessCurrent* procCurr = new ProcessCurrent(FDTD_Op);
|
||||||
proc=procCurr;
|
proc=procCurr;
|
||||||
}
|
}
|
||||||
else if (pb->GetProbeType()==2)
|
else if (pb->GetProbeType()==2)
|
||||||
|
@ -461,7 +461,7 @@ int openEMS::SetupFDTD(const char* file)
|
||||||
proc = new ProcessHField(FDTD_Op,FDTD_Eng);
|
proc = new ProcessHField(FDTD_Op,FDTD_Eng);
|
||||||
else if ((pb->GetProbeType()==10) || (pb->GetProbeType()==11))
|
else if ((pb->GetProbeType()==10) || (pb->GetProbeType()==11))
|
||||||
{
|
{
|
||||||
ProcessModeMatch* pmm = new ProcessModeMatch(FDTD_Op,FDTD_Eng);
|
ProcessModeMatch* pmm = new ProcessModeMatch(FDTD_Op);
|
||||||
pmm->SetFieldType(pb->GetProbeType()-10);
|
pmm->SetFieldType(pb->GetProbeType()-10);
|
||||||
pmm->SetModeFunction(0,pb->GetAttributeValue("ModeFunctionX"));
|
pmm->SetModeFunction(0,pb->GetAttributeValue("ModeFunctionX"));
|
||||||
pmm->SetModeFunction(1,pb->GetAttributeValue("ModeFunctionY"));
|
pmm->SetModeFunction(1,pb->GetAttributeValue("ModeFunctionY"));
|
||||||
|
@ -493,7 +493,7 @@ int openEMS::SetupFDTD(const char* file)
|
||||||
vector<CSProperties*> DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX);
|
vector<CSProperties*> DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX);
|
||||||
for (size_t i=0;i<DumpProps.size();++i)
|
for (size_t i=0;i<DumpProps.size();++i)
|
||||||
{
|
{
|
||||||
ProcessFieldsTD* ProcTD = new ProcessFieldsTD(FDTD_Op,FDTD_Eng);
|
ProcessFieldsTD* ProcTD = new ProcessFieldsTD(FDTD_Op);
|
||||||
ProcTD->SetEnable(Enable_Dumps);
|
ProcTD->SetEnable(Enable_Dumps);
|
||||||
ProcTD->SetProcessInterval(Nyquist/m_OverSampling);
|
ProcTD->SetProcessInterval(Nyquist/m_OverSampling);
|
||||||
|
|
||||||
|
@ -581,7 +581,8 @@ void openEMS::RunFDTD()
|
||||||
cout << "Running FDTD engine... this may take a while... grab a cup of coffee?!?" << endl;
|
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...
|
//special handling of a field processing, needed to realize the end criteria...
|
||||||
ProcessFields* ProcField = new ProcessFields(FDTD_Op,FDTD_Eng);
|
ProcessFields* ProcField = new ProcessFields(FDTD_Op);
|
||||||
|
ProcField->SetEngineInterface(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng));
|
||||||
PA->AddProcessing(ProcField);
|
PA->AddProcessing(ProcField);
|
||||||
double maxE=0,currE=0;
|
double maxE=0,currE=0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue