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
|
||||
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.
|
||||
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:
|
||||
Engine_Interface_Base();
|
||||
|
||||
|
|
|
@ -161,3 +161,24 @@ double* Engine_Interface_FDTD::GetHField(const unsigned int* pos, double* out) c
|
|||
|
||||
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* 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:
|
||||
Operator* m_Op;
|
||||
Engine* m_Eng;
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
#include "time.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()
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
virtual int Process();
|
||||
|
||||
protected:
|
||||
Engine* Eng;
|
||||
vector<double_complex> FD_Values[3];
|
||||
};
|
||||
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
|
||||
#include "tools/global.h"
|
||||
#include "processcurrent.h"
|
||||
#include "engine_interface_fdtd.h"
|
||||
#include <iomanip>
|
||||
|
||||
ProcessCurrent::ProcessCurrent(Operator* op, Engine* eng) : ProcessIntegral(op, eng)
|
||||
ProcessCurrent::ProcessCurrent(Operator* op) : ProcessIntegral(op)
|
||||
{
|
||||
m_TimeShift = op->GetTimestep()/2.0;
|
||||
m_dualMesh = true;
|
||||
|
@ -33,96 +34,103 @@ double ProcessCurrent::CalcIntegral()
|
|||
{
|
||||
FDTD_FLOAT current=0;
|
||||
|
||||
int Dump_Dim = 0;
|
||||
int NormDir = 0;
|
||||
Engine_Interface_FDTD* EI_FDTD = dynamic_cast<Engine_Interface_FDTD*>(m_Eng_Interface);
|
||||
|
||||
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];
|
||||
start[n]=stop[n];
|
||||
stop[n]=help;
|
||||
bool b_help=m_start_inside[n];
|
||||
m_start_inside[n] = m_stop_inside[n];
|
||||
m_stop_inside[n] = b_help;
|
||||
if (start[n]>stop[n])
|
||||
{
|
||||
unsigned int help=start[n];
|
||||
start[n]=stop[n];
|
||||
stop[n]=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])
|
||||
++Dump_Dim;
|
||||
if (stop[n] == start[n])
|
||||
NormDir = n;
|
||||
}
|
||||
if (Dump_Dim!=2)
|
||||
{
|
||||
cerr << "ProcessCurrent::Process(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << Dump_Dim << ") --> i = 0" << endl;
|
||||
current = 0;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (Dump_Dim!=2)
|
||||
{
|
||||
cerr << "ProcessCurrent::Process(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << Dump_Dim << ") --> i = 0" << endl;
|
||||
current = 0;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
switch (NormDir)
|
||||
{
|
||||
case 0:
|
||||
//y-current
|
||||
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]);
|
||||
//z-current
|
||||
if (m_stop_inside[0] && m_stop_inside[1])
|
||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||
current+=Eng->GetCurr(2,stop[0],stop[1],i);
|
||||
//y-current
|
||||
if (m_start_inside[0] && m_stop_inside[2])
|
||||
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
||||
current-=Eng->GetCurr(1,start[0],i,stop[2]);
|
||||
//z-current
|
||||
if (m_start_inside[0] && m_start_inside[1])
|
||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||
current-=Eng->GetCurr(2,start[0],start[1],i);
|
||||
break;
|
||||
case 1:
|
||||
//z-current
|
||||
if (m_start_inside[0] && m_start_inside[1])
|
||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||
current+=Eng->GetCurr(2,start[0],start[1],i);
|
||||
//x-current
|
||||
if (m_stop_inside[1] && m_stop_inside[2])
|
||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||
current+=Eng->GetCurr(0,i,stop[1],stop[2]);
|
||||
//z-current
|
||||
if (m_stop_inside[0] && m_stop_inside[1])
|
||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||
current-=Eng->GetCurr(2,stop[0],stop[1],i);
|
||||
//x-current
|
||||
if (m_start_inside[1] && m_start_inside[2])
|
||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||
current-=Eng->GetCurr(0,i,start[1],start[2]);
|
||||
break;
|
||||
case 2:
|
||||
//x-current
|
||||
if (m_start_inside[1] && m_start_inside[2])
|
||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||
current+=Eng->GetCurr(0,i,start[1],start[2]);
|
||||
//y-current
|
||||
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]);
|
||||
//x-current
|
||||
if (m_stop_inside[1] && m_stop_inside[2])
|
||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||
current-=Eng->GetCurr(0,i,stop[1],stop[2]);
|
||||
//y-current
|
||||
if (m_start_inside[0] && m_stop_inside[2])
|
||||
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;
|
||||
switch (NormDir)
|
||||
{
|
||||
case 0:
|
||||
//y-current
|
||||
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]);
|
||||
//z-current
|
||||
if (m_stop_inside[0] && m_stop_inside[1])
|
||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||
current+=Eng->GetCurr(2,stop[0],stop[1],i);
|
||||
//y-current
|
||||
if (m_start_inside[0] && m_stop_inside[2])
|
||||
for (unsigned int i=start[1]+1;i<=stop[1];++i)
|
||||
current-=Eng->GetCurr(1,start[0],i,stop[2]);
|
||||
//z-current
|
||||
if (m_start_inside[0] && m_start_inside[1])
|
||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||
current-=Eng->GetCurr(2,start[0],start[1],i);
|
||||
break;
|
||||
case 1:
|
||||
//z-current
|
||||
if (m_start_inside[0] && m_start_inside[1])
|
||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||
current+=Eng->GetCurr(2,start[0],start[1],i);
|
||||
//x-current
|
||||
if (m_stop_inside[1] && m_stop_inside[2])
|
||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||
current+=Eng->GetCurr(0,i,stop[1],stop[2]);
|
||||
//z-current
|
||||
if (m_stop_inside[0] && m_stop_inside[1])
|
||||
for (unsigned int i=start[2]+1;i<=stop[2];++i)
|
||||
current-=Eng->GetCurr(2,stop[0],stop[1],i);
|
||||
//x-current
|
||||
if (m_start_inside[1] && m_start_inside[2])
|
||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||
current-=Eng->GetCurr(0,i,start[1],start[2]);
|
||||
break;
|
||||
case 2:
|
||||
//x-current
|
||||
if (m_start_inside[1] && m_start_inside[2])
|
||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||
current+=Eng->GetCurr(0,i,start[1],start[2]);
|
||||
//y-current
|
||||
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]);
|
||||
//x-current
|
||||
if (m_stop_inside[1] && m_stop_inside[2])
|
||||
for (unsigned int i=start[0]+1;i<=stop[0];++i)
|
||||
current-=Eng->GetCurr(0,i,stop[1],stop[2]);
|
||||
//y-current
|
||||
if (m_start_inside[0] && m_stop_inside[2])
|
||||
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;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class ProcessCurrent : public ProcessIntegral
|
||||
{
|
||||
public:
|
||||
ProcessCurrent(Operator* op, Engine* eng);
|
||||
ProcessCurrent(Operator* op);
|
||||
virtual ~ProcessCurrent();
|
||||
|
||||
//! Integrate currents flowing through an area
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
#include <H5Cpp.h>
|
||||
#include "tools/global.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;
|
||||
// vtk-file is default
|
||||
|
@ -212,30 +213,35 @@ void ProcessFields::DefineStartStopCoord(double* dstart, double* dstop)
|
|||
|
||||
double ProcessFields::CalcTotalEnergy() const
|
||||
{
|
||||
if (!Eng)
|
||||
return 0;
|
||||
double energy=0.0;
|
||||
|
||||
double energy=0;
|
||||
unsigned int pos[3];
|
||||
for (pos[0]=0;pos[0]<Op->GetNumberOfLines(0);++pos[0])
|
||||
Engine_Interface_FDTD* EI_FDTD = dynamic_cast<Engine_Interface_FDTD*>(m_Eng_Interface);
|
||||
|
||||
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]));
|
||||
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(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]));
|
||||
for (pos[2]=0;pos[2]<Op->GetNumberOfLines(2);++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(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(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;
|
||||
}
|
||||
|
||||
void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir)
|
||||
void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir)
|
||||
{
|
||||
if (dir>2) return;
|
||||
if (dir<0)
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
class ProcessFields : public Processing
|
||||
{
|
||||
public:
|
||||
ProcessFields(Operator* op, Engine* eng);
|
||||
ProcessFields(Operator* op);
|
||||
virtual ~ProcessFields();
|
||||
|
||||
enum FileType { VTK_FILETYPE, HDF5_FILETYPE};
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
ProcessFieldsTD::ProcessFieldsTD(Operator* op, Engine* eng) : ProcessFields(op, eng)
|
||||
ProcessFieldsTD::ProcessFieldsTD(Operator* op) : ProcessFields(op)
|
||||
{
|
||||
pad_length = 8;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ int ProcessFieldsTD::Process()
|
|||
if (m_fileType==VTK_FILETYPE)
|
||||
{
|
||||
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();
|
||||
}
|
||||
else
|
||||
|
@ -107,8 +107,8 @@ int ProcessFieldsTD::Process()
|
|||
else if (m_fileType==HDF5_FILETYPE)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << std::setw( pad_length ) << std::setfill( '0' ) << Eng->GetNumberOfTimesteps();
|
||||
DumpVectorArray2HDF5(filename.c_str(),string( ss.str() ),field,numLines,(0.5+Eng->GetNumberOfTimesteps())*Op->GetTimestep());
|
||||
ss << std::setw( pad_length ) << std::setfill( '0' ) << m_Eng_Interface->GetNumberOfTimesteps();
|
||||
DumpVectorArray2HDF5(filename.c_str(),string( ss.str() ),field,numLines,(0.5+m_Eng_Interface->GetNumberOfTimesteps())*Op->GetTimestep());
|
||||
}
|
||||
else
|
||||
cerr << "ProcessFieldsTD::Process: unknown File-Type" << endl;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class ProcessFieldsTD : public ProcessFields
|
||||
{
|
||||
public:
|
||||
ProcessFieldsTD(Operator* op, Engine* eng);
|
||||
ProcessFieldsTD(Operator* op);
|
||||
virtual ~ProcessFieldsTD();
|
||||
|
||||
virtual int Process();
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
#include "time.h"
|
||||
#include <climits>
|
||||
|
||||
Processing::Processing(Operator* op, Engine* eng)
|
||||
Processing::Processing(Operator* op)
|
||||
{
|
||||
Op=op;
|
||||
Eng=eng;
|
||||
Enabled = true;
|
||||
m_PS_pos = 0;
|
||||
SetPrecision(12);
|
||||
|
@ -59,7 +58,7 @@ bool Processing::CheckTimestep()
|
|||
{
|
||||
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;
|
||||
return true;
|
||||
|
@ -67,12 +66,12 @@ bool Processing::CheckTimestep()
|
|||
}
|
||||
if (ProcessInterval)
|
||||
{
|
||||
if (Eng->GetNumberOfTimesteps()%ProcessInterval==0) return true;
|
||||
if (m_Eng_Interface->GetNumberOfTimesteps()%ProcessInterval==0) return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -83,11 +82,11 @@ int Processing::GetNextInterval() const
|
|||
int next=INT_MAX;
|
||||
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)
|
||||
{
|
||||
int next_Interval = (int)ProcessInterval - (int)Eng->GetNumberOfTimesteps()%ProcessInterval;
|
||||
int next_Interval = (int)ProcessInterval - (int)m_Eng_Interface->GetNumberOfTimesteps()%ProcessInterval;
|
||||
if (next_Interval<next)
|
||||
next = next_Interval;
|
||||
}
|
||||
|
@ -95,7 +94,7 @@ int Processing::GetNextInterval() const
|
|||
//check for FD sample interval
|
||||
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)
|
||||
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 )
|
||||
{
|
||||
if (file.is_open())
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef std::complex<double> double_complex;
|
|||
class Processing
|
||||
{
|
||||
public:
|
||||
Processing(Operator* op, Engine* eng);
|
||||
Processing(Operator* op);
|
||||
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!
|
||||
|
@ -85,7 +85,6 @@ public:
|
|||
protected:
|
||||
Engine_Interface_Base* m_Eng_Interface;
|
||||
Operator* Op;
|
||||
Engine* Eng;
|
||||
MeshType m_Mesh_Type;
|
||||
|
||||
unsigned int m_precision;
|
||||
|
@ -128,10 +127,6 @@ protected:
|
|||
string m_filename;
|
||||
|
||||
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
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "processintegral.h"
|
||||
#include <iomanip>
|
||||
|
||||
ProcessIntegral::ProcessIntegral(Operator* op, Engine* eng) : Processing(op, eng)
|
||||
ProcessIntegral::ProcessIntegral(Operator* op) : Processing(op)
|
||||
{
|
||||
m_TimeShift = 0.0;
|
||||
m_Results=NULL;
|
||||
|
@ -56,11 +56,11 @@ int ProcessIntegral::Process()
|
|||
int NrInt = GetNumberOfIntegrals();
|
||||
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 (Eng->GetNumberOfTimesteps()%ProcessInterval==0)
|
||||
if (m_Eng_Interface->GetNumberOfTimesteps()%ProcessInterval==0)
|
||||
{
|
||||
TD_Values.push_back(integral);
|
||||
file << setprecision(m_precision) << time;
|
||||
|
@ -72,7 +72,7 @@ int ProcessIntegral::Process()
|
|||
|
||||
if (m_FD_Interval)
|
||||
{
|
||||
if (Eng->GetNumberOfTimesteps()%m_FD_Interval==0)
|
||||
if (m_Eng_Interface->GetNumberOfTimesteps()%m_FD_Interval==0)
|
||||
{
|
||||
double T = time;
|
||||
for (size_t n=0;n<m_FD_Samples.size();++n)
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
virtual int Process();
|
||||
|
||||
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
|
||||
double m_TimeShift;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CSFunctionParser.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)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ class CSFunctionParser;
|
|||
class ProcessModeMatch : public ProcessIntegral
|
||||
{
|
||||
public:
|
||||
ProcessModeMatch(Operator* op, Engine* eng);
|
||||
ProcessModeMatch(Operator* op);
|
||||
virtual ~ProcessModeMatch();
|
||||
|
||||
virtual void InitProcess();
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "processvoltage.h"
|
||||
#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()
|
||||
{
|
||||
//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
|
||||
{
|
||||
public:
|
||||
ProcessVoltage(Operator* op, Engine* eng);
|
||||
ProcessVoltage(Operator* op);
|
||||
virtual ~ProcessVoltage();
|
||||
|
||||
virtual double CalcIntegral();
|
||||
|
|
11
openems.cpp
11
openems.cpp
|
@ -447,12 +447,12 @@ int openEMS::SetupFDTD(const char* file)
|
|||
{
|
||||
if (pb->GetProbeType()==0)
|
||||
{
|
||||
ProcessVoltage* procVolt = new ProcessVoltage(FDTD_Op,FDTD_Eng);
|
||||
ProcessVoltage* procVolt = new ProcessVoltage(FDTD_Op);
|
||||
proc=procVolt;
|
||||
}
|
||||
else if (pb->GetProbeType()==1)
|
||||
{
|
||||
ProcessCurrent* procCurr = new ProcessCurrent(FDTD_Op,FDTD_Eng);
|
||||
ProcessCurrent* procCurr = new ProcessCurrent(FDTD_Op);
|
||||
proc=procCurr;
|
||||
}
|
||||
else if (pb->GetProbeType()==2)
|
||||
|
@ -461,7 +461,7 @@ int openEMS::SetupFDTD(const char* file)
|
|||
proc = new ProcessHField(FDTD_Op,FDTD_Eng);
|
||||
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->SetModeFunction(0,pb->GetAttributeValue("ModeFunctionX"));
|
||||
pmm->SetModeFunction(1,pb->GetAttributeValue("ModeFunctionY"));
|
||||
|
@ -493,7 +493,7 @@ int openEMS::SetupFDTD(const char* file)
|
|||
vector<CSProperties*> DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX);
|
||||
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->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;
|
||||
|
||||
//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);
|
||||
double maxE=0,currE=0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue