2010-03-01 18:35:28 +00:00
|
|
|
#include "processvoltage.h"
|
|
|
|
|
|
|
|
ProcessVoltage::ProcessVoltage(Operator* op, Engine* eng) : Processing(op, eng)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessVoltage::~ProcessVoltage()
|
|
|
|
{
|
2010-03-02 13:54:50 +00:00
|
|
|
file.close();
|
2010-03-01 18:35:28 +00:00
|
|
|
}
|
|
|
|
|
2010-03-02 13:54:50 +00:00
|
|
|
void ProcessVoltage::OpenFile(string outfile)
|
2010-03-01 18:35:28 +00:00
|
|
|
{
|
2010-03-02 13:54:50 +00:00
|
|
|
if (file.is_open()) file.close();
|
|
|
|
|
|
|
|
file.open(outfile.c_str());
|
|
|
|
if (file.is_open()==false)
|
|
|
|
{
|
|
|
|
cerr << "Can't open file: " << outfile << endl;
|
|
|
|
return;
|
|
|
|
}
|
2010-03-01 18:35:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessVoltage::Process()
|
|
|
|
{
|
2010-03-02 18:01:03 +00:00
|
|
|
if (Enabled==false) return;
|
2010-03-01 18:35:28 +00:00
|
|
|
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]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// cerr << voltage << endl;
|
|
|
|
voltages.push_back(voltage);
|
2010-03-01 19:50:42 +00:00
|
|
|
file << (double)Eng->numTS*Op->GetTimestep() << "\t" << voltage << endl;
|
2010-03-01 18:35:28 +00:00
|
|
|
}
|