Processing updates: CalcLineIntegral
parent
f73bf210ed
commit
0e1eba5028
|
@ -5,6 +5,7 @@
|
|||
|
||||
class Engine
|
||||
{
|
||||
friend class Processing;
|
||||
friend class ProcessVoltage;
|
||||
friend class ProcessCurrent;
|
||||
friend class ProcessFieldsTD;
|
||||
|
|
|
@ -14,7 +14,7 @@ ProcessFieldsTD::~ProcessFieldsTD()
|
|||
|
||||
void ProcessFieldsTD::DumpCellInterpol(ofstream &file)
|
||||
{
|
||||
if (DumpType==0)
|
||||
if (DumpType==0)
|
||||
{
|
||||
//create array
|
||||
FDTD_FLOAT**** E_T = Create_N_3DArray(numDLines);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -34,6 +34,8 @@ protected:
|
|||
|
||||
unsigned int start[3];
|
||||
unsigned int stop[3];
|
||||
|
||||
double CalcLineIntegral(unsigned int* start, unsigned int* stop, int field);
|
||||
};
|
||||
|
||||
class ProcessingArray
|
||||
|
|
|
@ -25,26 +25,7 @@ int ProcessVoltage::Process()
|
|||
{
|
||||
if (Enabled==false) return -1;
|
||||
if (CheckTimestep()==false) return GetNextInterval();
|
||||
FDTD_FLOAT voltage=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]];
|
||||
}
|
||||
}
|
||||
FDTD_FLOAT voltage=CalcLineIntegral(start,stop,0);
|
||||
// cerr << voltage << endl;
|
||||
voltages.push_back(voltage);
|
||||
file << (double)Eng->numTS*Op->GetTimestep() << "\t" << voltage << endl;
|
||||
|
|
Loading…
Reference in New Issue