Processing updates: CalcLineIntegral

pull/1/head
Thorsten Liebig 2010-03-11 10:48:00 +01:00
parent f73bf210ed
commit 0e1eba5028
5 changed files with 36 additions and 21 deletions

View File

@ -5,6 +5,7 @@
class Engine class Engine
{ {
friend class Processing;
friend class ProcessVoltage; friend class ProcessVoltage;
friend class ProcessCurrent; friend class ProcessCurrent;
friend class ProcessFieldsTD; friend class ProcessFieldsTD;

View File

@ -29,6 +29,37 @@ void Processing::DefineStartStopCoord(double* dstart, double* dstop)
if (Op->SnapToMesh(dstop,stop)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapping problem, check stop value!!" << endl; if (Op->SnapToMesh(dstop,stop)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapping problem, check stop value!!" << endl;
} }
double Processing::CalcLineIntegral(unsigned int* start, unsigned int* stop, int field)
{
double result=0;
FDTD_FLOAT**** array;
if (field==0)
array=Eng->volt;
else if (field==1)
array=Eng->curr;
else return 0.0;
unsigned int pos[3]={start[0],start[1],start[2]};
// cerr << Eng->volt[1][pos[0]][pos[1]][pos[2]] << endl;
for (int n=0;n<3;++n)
{
if (start[n]<stop[n])
{
for (;pos[n]<stop[n];++pos[n])
{
result+=array[n][pos[0]][pos[1]][pos[2]];
// cerr << n << " " << pos[0] << " " << pos[1] << " " << pos[2] << " " << Eng->volt[n][pos[0]][pos[1]][pos[2]] << endl;
}
}
else
{
for (;pos[n]>stop[n];--pos[n])
result-=array[n][pos[0]][pos[1]][pos[2]];
}
}
return result;
}
void ProcessingArray::AddProcessing(Processing* proc) void ProcessingArray::AddProcessing(Processing* proc)
{ {

View File

@ -34,6 +34,8 @@ protected:
unsigned int start[3]; unsigned int start[3];
unsigned int stop[3]; unsigned int stop[3];
double CalcLineIntegral(unsigned int* start, unsigned int* stop, int field);
}; };
class ProcessingArray class ProcessingArray

View File

@ -25,26 +25,7 @@ int ProcessVoltage::Process()
{ {
if (Enabled==false) return -1; if (Enabled==false) return -1;
if (CheckTimestep()==false) return GetNextInterval(); if (CheckTimestep()==false) return GetNextInterval();
FDTD_FLOAT voltage=0; FDTD_FLOAT voltage=CalcLineIntegral(start,stop,0);
unsigned int pos[3]={start[0],start[1],start[2]};
// cerr << Eng->volt[1][pos[0]][pos[1]][pos[2]] << endl;
for (int n=0;n<3;++n)
{
if (start[n]<stop[n])
{
for (;pos[n]<stop[n];++pos[n])
{
voltage+=Eng->volt[n][pos[0]][pos[1]][pos[2]];
// cerr << n << " " << pos[0] << " " << pos[1] << " " << pos[2] << " " << Eng->volt[n][pos[0]][pos[1]][pos[2]] << endl;
}
}
else
{
for (;pos[n]>stop[n];--pos[n])
voltage-=Eng->volt[n][pos[0]][pos[1]][pos[2]];
}
}
// cerr << voltage << endl; // cerr << voltage << endl;
voltages.push_back(voltage); voltages.push_back(voltage);
file << (double)Eng->numTS*Op->GetTimestep() << "\t" << voltage << endl; file << (double)Eng->numTS*Op->GetTimestep() << "\t" << voltage << endl;