processing functions are now independent of the underlying engine data format

pull/1/head
Sebastian Held 2010-04-21 14:28:16 +02:00 committed by Thorsten Liebig
parent be6d7510e8
commit e9cdadb01a
7 changed files with 84 additions and 70 deletions

View File

@ -35,8 +35,8 @@ public:
virtual unsigned int GetNumberOfTimesteps() {return numTS;}; virtual unsigned int GetNumberOfTimesteps() {return numTS;};
virtual FDTD_FLOAT**** GetVoltages() {return volt;}; inline virtual FDTD_FLOAT GetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return volt[n][x][y][z]; }
virtual FDTD_FLOAT**** GetCurrents() {return curr;}; inline virtual FDTD_FLOAT GetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return curr[n][x][y][z]; }
protected: protected:
Engine(const Operator* op); Engine(const Operator* op);

View File

@ -34,7 +34,6 @@ void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop)
int ProcessCurrent::Process() int ProcessCurrent::Process()
{ {
FDTD_FLOAT**** curr = Eng->GetCurrents();
if (Enabled==false) return -1; if (Enabled==false) return -1;
if (CheckTimestep()==false) return GetNextInterval(); if (CheckTimestep()==false) return GetNextInterval();
FDTD_FLOAT current=0; FDTD_FLOAT current=0;
@ -56,27 +55,27 @@ int ProcessCurrent::Process()
//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];i<stop[0];++i) for (unsigned int i=start[0];i<stop[0];++i)
current+=curr[0][i][start[1]][start[2]]; current+=Eng->GetCurr(0,i,start[1],start[2]);
//y-current //y-current
if (m_stop_inside[0] && m_start_inside[2]) if (m_stop_inside[0] && m_start_inside[2])
for (unsigned int i=start[1];i<stop[1];++i) for (unsigned int i=start[1];i<stop[1];++i)
current+=curr[1][stop[0]][i][start[2]]; current+=Eng->GetCurr(1,stop[0],i,start[2]);
//z-current //z-current
if (m_stop_inside[0] && m_stop_inside[1]) if (m_stop_inside[0] && m_stop_inside[1])
for (unsigned int i=start[2];i<stop[2];++i) for (unsigned int i=start[2];i<stop[2];++i)
current+=curr[2][stop[0]][stop[1]][i]; current+=Eng->GetCurr(2,stop[0],stop[1],i);
//x-current //x-current
if (m_stop_inside[1] && m_stop_inside[2]) if (m_stop_inside[1] && m_stop_inside[2])
for (unsigned int i=start[0];i<stop[0];++i) for (unsigned int i=start[0];i<stop[0];++i)
current-=curr[0][i][stop[1]][stop[2]]; current-=Eng->GetCurr(0,i,stop[1],stop[2]);
//y-current //y-current
if (m_start_inside[0] && m_stop_inside[2]) if (m_start_inside[0] && m_stop_inside[2])
for (unsigned int i=start[1];i<stop[1];++i) for (unsigned int i=start[1];i<stop[1];++i)
current-=curr[1][start[0]][i][stop[2]]; 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];i<stop[2];++i) for (unsigned int i=start[2];i<stop[2];++i)
current-=curr[2][start[0]][start[1]][i]; current-=Eng->GetCurr(2,start[0],start[1],i);
// cerr << "ts: " << Eng->numTS << " i: " << current << endl; // cerr << "ts: " << Eng->numTS << " i: " << current << endl;
v_current.push_back(current); v_current.push_back(current);

View File

@ -168,13 +168,12 @@ void ProcessFields::DefineStartStopCoord(double* dstart, double* dstop)
} }
} }
double ProcessFields::CalcTotalEnergy() const
double ProcessFields::CalcTotalEnergy()
{ {
FDTD_FLOAT**** volt = Eng->GetVoltages(); if (!Eng)
FDTD_FLOAT**** curr = Eng->GetCurrents(); return 0;
double energy=0; double energy=0;
if (Eng==NULL) return 0.0;
unsigned int pos[3]; unsigned int pos[3];
for (pos[0]=0;pos[0]<Op->GetNumberOfLines(0);++pos[0]) for (pos[0]=0;pos[0]<Op->GetNumberOfLines(0);++pos[0])
{ {
@ -182,12 +181,12 @@ double ProcessFields::CalcTotalEnergy()
{ {
for (pos[2]=0;pos[2]<Op->GetNumberOfLines(2);++pos[2]) for (pos[2]=0;pos[2]<Op->GetNumberOfLines(2);++pos[2])
{ {
energy+=fabs(volt[0][pos[0]][pos[1]][pos[2]] * curr[1][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(volt[0][pos[0]][pos[1]][pos[2]] * curr[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(volt[1][pos[0]][pos[1]][pos[2]] * curr[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(volt[1][pos[0]][pos[1]][pos[2]] * curr[2][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(volt[2][pos[0]][pos[1]][pos[2]] * curr[0][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(volt[2][pos[0]][pos[1]][pos[2]] * curr[1][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]));
} }
} }
} }
@ -206,7 +205,7 @@ void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir)
else subSample[dir]=subSampleRate; else subSample[dir]=subSampleRate;
} }
void ProcessFields::WriteVTKHeader(ofstream &file, double** discLines, unsigned int* numLines, unsigned int precision) void ProcessFields::WriteVTKHeader(ofstream &file, double const* const* discLines, unsigned int const* numLines, unsigned int precision)
{ {
file << "# vtk DataFile Version 2.0" << endl; file << "# vtk DataFile Version 2.0" << endl;
file << "Rectilinear Grid openEMS_ProcessFields" << endl; file << "Rectilinear Grid openEMS_ProcessFields" << endl;
@ -228,7 +227,7 @@ void ProcessFields::WriteVTKHeader(ofstream &file, double** discLines, unsigned
file << "POINT_DATA " << numLines[0]*numLines[1]*numLines[2] << endl; file << "POINT_DATA " << numLines[0]*numLines[1]*numLines[2] << endl;
} }
void ProcessFields::WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT**** array, unsigned int* numLines, unsigned int precision) void ProcessFields::WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT const* const* const* const* array, unsigned int const* numLines, unsigned int precision)
{ {
file << "VECTORS " << name << " float " << endl; file << "VECTORS " << name << " float " << endl;
@ -251,14 +250,14 @@ void ProcessFields::WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT*
} }
bool ProcessFields::DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT**** array, double** discLines, unsigned int* numLines, unsigned int precision) bool ProcessFields::DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT const* const* const* const* array, double const* const* discLines, unsigned int const* numLines, unsigned int precision)
{ {
WriteVTKHeader(file, discLines, numLines, precision); WriteVTKHeader(file, discLines, numLines, precision);
WriteVTKVectorArray(file, name, array, numLines, precision); WriteVTKVectorArray(file, name, array, numLines, precision);
return true; return true;
} }
bool ProcessFields::DumpMultiVectorArray2VTK(ofstream &file, string names[], FDTD_FLOAT**** array[], unsigned int numFields, double** discLines, unsigned int* numLines, unsigned int precision) bool ProcessFields::DumpMultiVectorArray2VTK(ofstream &file, string names[], FDTD_FLOAT const* const* const* const* const* array, unsigned int numFields, double const* const* discLines, unsigned int const* numLines, unsigned int precision)
{ {
WriteVTKHeader(file, discLines, numLines, precision); WriteVTKHeader(file, discLines, numLines, precision);
for (unsigned int n=0;n<numFields;++n) for (unsigned int n=0;n<numFields;++n)
@ -269,7 +268,7 @@ bool ProcessFields::DumpMultiVectorArray2VTK(ofstream &file, string names[], FDT
return true; return true;
} }
void ProcessFields::WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT*** array, unsigned int* numLines, unsigned int precision) void ProcessFields::WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT const* const* const* array, unsigned int const* numLines, unsigned int precision)
{ {
file << "SCALARS " << name << " float " << 1 << endl; file << "SCALARS " << name << " float " << 1 << endl;
file << "LOOKUP_TABLE default" << endl; file << "LOOKUP_TABLE default" << endl;
@ -290,14 +289,14 @@ void ProcessFields::WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT*
} }
} }
bool ProcessFields::DumpScalarArray2VTK(ofstream &file, string name, FDTD_FLOAT*** array, double** discLines, unsigned int* numLines, unsigned int precision) bool ProcessFields::DumpScalarArray2VTK(ofstream &file, string name, FDTD_FLOAT const* const* const* array, double const* const* discLines, unsigned int const* numLines, unsigned int precision)
{ {
WriteVTKHeader(file, discLines, numLines, precision); WriteVTKHeader(file, discLines, numLines, precision);
WriteVTKScalarArray(file, name, array, numLines, precision); WriteVTKScalarArray(file, name, array, numLines, precision);
return true; return true;
} }
bool ProcessFields::DumpMultiScalarArray2VTK(ofstream &file, string names[], FDTD_FLOAT*** array[], unsigned int numFields, double** discLines, unsigned int* numLines, unsigned int precision) bool ProcessFields::DumpMultiScalarArray2VTK(ofstream &file, string names[], FDTD_FLOAT const* const* const* const* array, unsigned int numFields, double const* const* discLines, unsigned int const* numLines, unsigned int precision)
{ {
WriteVTKHeader(file, discLines, numLines); WriteVTKHeader(file, discLines, numLines);
for (unsigned int n=0;n<numFields;++n) for (unsigned int n=0;n<numFields;++n)
@ -308,7 +307,7 @@ bool ProcessFields::DumpMultiScalarArray2VTK(ofstream &file, string names[], FDT
return true; return true;
} }
bool ProcessFields::DumpVectorArray2HDF5(string filename, string name, FDTD_FLOAT**** array, unsigned int* numLines) bool ProcessFields::DumpVectorArray2HDF5(string filename, string name, FDTD_FLOAT const* const* const* const* array, unsigned int const* numLines)
{ {
const H5std_string FILE_NAME(filename); const H5std_string FILE_NAME(filename);
const H5std_string DATASET_NAME( name ); const H5std_string DATASET_NAME( name );

View File

@ -52,22 +52,22 @@ public:
//! Set dump type: 0 for E-fields, 1 for H-fields, 2 for D-fields, 3 for B-fields, 4 for J-fields, etc... //! Set dump type: 0 for E-fields, 1 for H-fields, 2 for D-fields, 3 for B-fields, 4 for J-fields, etc...
void SetDumpType(DumpType type) {m_DumpType=type;} void SetDumpType(DumpType type) {m_DumpType=type;}
static bool DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT**** array, double** discLines, unsigned int* numLines, unsigned int precision=12); static bool DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT const* const* const * const* array, double const* const* discLines, unsigned int const* numLines, unsigned int precision=12);
static bool DumpMultiVectorArray2VTK(ofstream &file, string names[], FDTD_FLOAT**** array[], unsigned int numFields, double** discLines, unsigned int* numLines, unsigned int precision=12); static bool DumpMultiVectorArray2VTK(ofstream &file, string names[], FDTD_FLOAT const* const* const* const* const* array, unsigned int numFields, double const* const* discLines, unsigned int const* numLines, unsigned int precision=12);
static bool DumpScalarArray2VTK(ofstream &file, string name, FDTD_FLOAT*** array, double** discLines, unsigned int* numLines, unsigned int precision=12); static bool DumpScalarArray2VTK(ofstream &file, string name, FDTD_FLOAT const* const* const* array, double const* const* discLines, unsigned int const* numLines, unsigned int precision=12);
static bool DumpMultiScalarArray2VTK(ofstream &file, string names[], FDTD_FLOAT*** array[], unsigned int numFields, double** discLines, unsigned int* numLines, unsigned int precision=12); static bool DumpMultiScalarArray2VTK(ofstream &file, string names[], FDTD_FLOAT const* const* const* const* array, unsigned int numFields, double const* const* discLines, unsigned int const* numLines, unsigned int precision=12);
static bool DumpVectorArray2HDF5(string filename, string name, FDTD_FLOAT**** array, unsigned int* numLines); static bool DumpVectorArray2HDF5(string filename, string name, FDTD_FLOAT const* const* const* const* array, unsigned int const* numLines);
double CalcTotalEnergy(); double CalcTotalEnergy() const;
void SetFileType(FileType fileType) {m_fileType=fileType;} void SetFileType(FileType fileType) {m_fileType=fileType;}
// virtual void Process(); // virtual void Process();
protected: protected:
static void WriteVTKHeader(ofstream &file, double** discLines, unsigned int* numLines, unsigned int precision=12); static void WriteVTKHeader(ofstream &file, double const* const* discLines, unsigned int const* numLines, unsigned int precision=12);
static void WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT**** array, unsigned int* numLines, unsigned int precision=12); static void WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT const* const* const* const* array, unsigned int const* numLines, unsigned int precision=12);
static void WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT*** array, unsigned int* numLines, unsigned int precision=12); static void WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT const* const* const* array, unsigned int const* numLines, unsigned int precision=12);
static string GetFieldNameByType(DumpType type); static string GetFieldNameByType(DumpType type);
DumpMode m_DumpMode; DumpMode m_DumpMode;

View File

@ -31,9 +31,6 @@ ProcessFieldsTD::~ProcessFieldsTD()
void ProcessFieldsTD::DumpCellInterpol(string filename) void ProcessFieldsTD::DumpCellInterpol(string filename)
{ {
FDTD_FLOAT**** volt = Eng->GetVoltages();
FDTD_FLOAT**** curr = Eng->GetCurrents();
if (m_DumpType==E_FIELD_DUMP) if (m_DumpType==E_FIELD_DUMP)
{ {
//create array //create array
@ -55,21 +52,21 @@ void ProcessFieldsTD::DumpCellInterpol(string filename)
delta = Op->GetMeshDelta(0,OpPos); //Op->discLines[0][OpPos[0]+1] - Op->discLines[0][OpPos[0]]; delta = Op->GetMeshDelta(0,OpPos); //Op->discLines[0][OpPos[0]+1] - Op->discLines[0][OpPos[0]];
if (delta) if (delta)
{ {
E_T[0][pos[0]][pos[1]][pos[2]] = volt[0][OpPos[0]][OpPos[1]][OpPos[2]] + volt[0][OpPos[0]][OpPos[1]+1][OpPos[2]] + volt[0][OpPos[0]][OpPos[1]][OpPos[2]+1] + volt[0][OpPos[0]][OpPos[1]+1][OpPos[2]+1]; E_T[0][pos[0]][pos[1]][pos[2]] = Eng->GetVolt(0,OpPos[0],OpPos[1],OpPos[2]) + Eng->GetVolt(0,OpPos[0],OpPos[1]+1,OpPos[2]) + Eng->GetVolt(0,OpPos[0],OpPos[1],OpPos[2]+1) + Eng->GetVolt(0,OpPos[0],OpPos[1]+1,OpPos[2]+1);
E_T[0][pos[0]][pos[1]][pos[2]] /= (4*delta);//*Op->gridDelta); E_T[0][pos[0]][pos[1]][pos[2]] /= (4*delta);//*Op->gridDelta);
} }
//in y //in y
delta = Op->GetMeshDelta(1,OpPos); //Op->discLines[1][OpPos[1]+1] - Op->discLines[1][OpPos[1]]; delta = Op->GetMeshDelta(1,OpPos); //Op->discLines[1][OpPos[1]+1] - Op->discLines[1][OpPos[1]];
if (delta) if (delta)
{ {
E_T[1][pos[0]][pos[1]][pos[2]] = volt[1][OpPos[0]][OpPos[1]][OpPos[2]] + volt[1][OpPos[0]+1][OpPos[1]][OpPos[2]] + volt[1][OpPos[0]][OpPos[1]][OpPos[2]+1] + volt[1][OpPos[0]+1][OpPos[1]][OpPos[2]+1]; E_T[1][pos[0]][pos[1]][pos[2]] = Eng->GetVolt(1,OpPos[0],OpPos[1],OpPos[2]) + Eng->GetVolt(1,OpPos[0]+1,OpPos[1],OpPos[2]) + Eng->GetVolt(1,OpPos[0],OpPos[1],OpPos[2]+1) + Eng->GetVolt(1,OpPos[0]+1,OpPos[1],OpPos[2]+1);
E_T[1][pos[0]][pos[1]][pos[2]] /= (4*delta);//*Op->gridDelta); E_T[1][pos[0]][pos[1]][pos[2]] /= (4*delta);//*Op->gridDelta);
} }
//in z //in z
delta = Op->GetMeshDelta(2,OpPos); //Op->discLines[2][OpPos[2]+1] - Op->discLines[2][OpPos[2]]; delta = Op->GetMeshDelta(2,OpPos); //Op->discLines[2][OpPos[2]+1] - Op->discLines[2][OpPos[2]];
if (delta) if (delta)
{ {
E_T[2][pos[0]][pos[1]][pos[2]] = volt[2][OpPos[0]][OpPos[1]][OpPos[2]] + volt[2][OpPos[0]][OpPos[1]+1][OpPos[2]] + volt[2][OpPos[0]+1][OpPos[1]][OpPos[2]] + volt[2][OpPos[0]+1][OpPos[1]+1][OpPos[2]]; E_T[2][pos[0]][pos[1]][pos[2]] = Eng->GetVolt(2,OpPos[0],OpPos[1],OpPos[2]) + Eng->GetVolt(2,OpPos[0],OpPos[1]+1,OpPos[2]) + Eng->GetVolt(2,OpPos[0]+1,OpPos[1],OpPos[2]) + Eng->GetVolt(2,OpPos[0]+1,OpPos[1]+1,OpPos[2]);
E_T[2][pos[0]][pos[1]][pos[2]] /= (4*delta);//*Op->gridDelta); E_T[2][pos[0]][pos[1]][pos[2]] /= (4*delta);//*Op->gridDelta);
} }
} }
@ -118,7 +115,7 @@ void ProcessFieldsTD::DumpCellInterpol(string filename)
delta = Op->GetDiscLine(0,OpPos[0],true); delta = Op->GetDiscLine(0,OpPos[0],true);
if (delta) if (delta)
{ {
H_T[0][pos[0]][pos[1]][pos[2]] = curr[0][OpPos[0]][OpPos[1]][OpPos[2]] + curr[0][OpPos[0]+1][OpPos[1]][OpPos[2]]; H_T[0][pos[0]][pos[1]][pos[2]] = Eng->GetCurr(0,OpPos[0],OpPos[1],OpPos[2]) + Eng->GetCurr(0,OpPos[0]+1,OpPos[1],OpPos[2]);
H_T[0][pos[0]][pos[1]][pos[2]] /= (2*delta);//*Op->gridDelta); H_T[0][pos[0]][pos[1]][pos[2]] /= (2*delta);//*Op->gridDelta);
} }
//in y //in y
@ -126,7 +123,7 @@ void ProcessFieldsTD::DumpCellInterpol(string filename)
delta = Op->GetDiscLine(1,OpPos[1],true); delta = Op->GetDiscLine(1,OpPos[1],true);
if (delta) if (delta)
{ {
H_T[1][pos[0]][pos[1]][pos[2]] = curr[1][OpPos[0]][OpPos[1]][OpPos[2]] + curr[1][OpPos[0]][OpPos[1]+1][OpPos[2]]; H_T[1][pos[0]][pos[1]][pos[2]] = Eng->GetCurr(1,OpPos[0],OpPos[1],OpPos[2]) + Eng->GetCurr(1,OpPos[0],OpPos[1]+1,OpPos[2]);
H_T[1][pos[0]][pos[1]][pos[2]] /= (2*delta);//*Op->gridDelta); H_T[1][pos[0]][pos[1]][pos[2]] /= (2*delta);//*Op->gridDelta);
} }
//in z //in z
@ -134,7 +131,7 @@ void ProcessFieldsTD::DumpCellInterpol(string filename)
delta = Op->GetDiscLine(2,OpPos[2],true); delta = Op->GetDiscLine(2,OpPos[2],true);
if (delta) if (delta)
{ {
H_T[2][pos[0]][pos[1]][pos[2]] = curr[2][OpPos[0]][OpPos[1]][OpPos[2]] + curr[2][OpPos[0]][OpPos[1]][OpPos[2]+1]; H_T[2][pos[0]][pos[1]][pos[2]] = Eng->GetCurr(2,OpPos[0],OpPos[1],OpPos[2]) + Eng->GetCurr(2,OpPos[0],OpPos[1],OpPos[2]+1);
H_T[2][pos[0]][pos[1]][pos[2]] /= (2*delta);//*Op->gridDelta); H_T[2][pos[0]][pos[1]][pos[2]] /= (2*delta);//*Op->gridDelta);
} }
} }
@ -162,9 +159,6 @@ void ProcessFieldsTD::DumpCellInterpol(string filename)
void ProcessFieldsTD::DumpNoInterpol(string filename) void ProcessFieldsTD::DumpNoInterpol(string filename)
{ {
FDTD_FLOAT**** volt = Eng->GetVoltages();
FDTD_FLOAT**** curr = Eng->GetCurrents();
unsigned int pos[3]; unsigned int pos[3];
unsigned int OpPos[3]; unsigned int OpPos[3];
double delta[3]; double delta[3];
@ -185,11 +179,11 @@ void ProcessFieldsTD::DumpNoInterpol(string filename)
OpPos[2]=start[2]+pos[2]*subSample[2]; OpPos[2]=start[2]+pos[2]*subSample[2];
delta[2]=Op->GetMeshDelta(2,OpPos);//fabs(Op->MainOp->GetIndexDelta(2,OpPos[2])); delta[2]=Op->GetMeshDelta(2,OpPos);//fabs(Op->MainOp->GetIndexDelta(2,OpPos[2]));
if (delta[0]) if (delta[0])
E_T[0][pos[0]][pos[1]][pos[2]] = volt[0][OpPos[0]][OpPos[1]][OpPos[2]]/delta[0];// /Op->gridDelta; E_T[0][pos[0]][pos[1]][pos[2]] = Eng->GetVolt(0,OpPos[0],OpPos[1],OpPos[2])/delta[0];// /Op->gridDelta;
if (delta[1]) if (delta[1])
E_T[1][pos[0]][pos[1]][pos[2]] = volt[1][OpPos[0]][OpPos[1]][OpPos[2]]/delta[1];// /Op->gridDelta; E_T[1][pos[0]][pos[1]][pos[2]] = Eng->GetVolt(1,OpPos[0],OpPos[1],OpPos[2])/delta[1];// /Op->gridDelta;
if (delta[2]) if (delta[2])
E_T[2][pos[0]][pos[1]][pos[2]] = volt[2][OpPos[0]][OpPos[1]][OpPos[2]]/delta[2];// /Op->gridDelta; E_T[2][pos[0]][pos[1]][pos[2]] = Eng->GetVolt(2,OpPos[0],OpPos[1],OpPos[2])/delta[2];// /Op->gridDelta;
} }
} }
} }
@ -231,11 +225,11 @@ void ProcessFieldsTD::DumpNoInterpol(string filename)
delta[2]=Op->GetMeshDelta(2,OpPos,true);//fabs(Op->MainOp->GetIndexWidth(2,OpPos[2])); delta[2]=Op->GetMeshDelta(2,OpPos,true);//fabs(Op->MainOp->GetIndexWidth(2,OpPos[2]));
//in x //in x
if (delta[0]) if (delta[0])
H_T[0][pos[0]][pos[1]][pos[2]] = curr[0][OpPos[0]][OpPos[1]][OpPos[2]]/delta[0];// /Op->gridDelta; H_T[0][pos[0]][pos[1]][pos[2]] = Eng->GetCurr(0,OpPos[0],OpPos[1],OpPos[2])/delta[0];// /Op->gridDelta;
if (delta[1]) if (delta[1])
H_T[1][pos[0]][pos[1]][pos[2]] = curr[1][OpPos[0]][OpPos[1]][OpPos[2]]/delta[1];// /Op->gridDelta; H_T[1][pos[0]][pos[1]][pos[2]] = Eng->GetCurr(1,OpPos[0],OpPos[1],OpPos[2])/delta[1];// /Op->gridDelta;
if (delta[2]) if (delta[2])
H_T[2][pos[0]][pos[1]][pos[2]] = curr[2][OpPos[0]][OpPos[1]][OpPos[2]]/delta[2];// /Op->gridDelta; H_T[2][pos[0]][pos[1]][pos[2]] = Eng->GetCurr(2,OpPos[0],OpPos[1],OpPos[2])/delta[2];// /Op->gridDelta;
} }
} }
} }

View File

@ -91,33 +91,53 @@ void Processing::DefineStartStopCoord(double* dstart, double* dstop)
if (Op->SnapToMesh(dstop,stop)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl; if (Op->SnapToMesh(dstop,stop)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl;
} }
double Processing::CalcLineIntegral(unsigned int* start, unsigned int* stop, int field) 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; double result=0;
FDTD_FLOAT**** array;
if (field==0)
array=Eng->GetVoltages();
else if (field==1)
array=Eng->GetCurrents();
else return 0.0;
for (int n=0;n<3;++n) for (int n=0;n<3;++n)
{ {
if (start[n]<stop[n]) if (start[n]<stop[n])
{ {
unsigned int pos[3]={start[0],start[1],start[2]}; unsigned int pos[3]={start[0],start[1],start[2]};
for (;pos[n]<stop[n];++pos[n]) for (;pos[n]<stop[n];++pos[n])
{ result += Eng->GetCurr(n,pos[0],pos[1],pos[2]);
result+=array[n][pos[0]][pos[1]][pos[2]];
}
} }
else else
{ {
unsigned int pos[3]={stop[0],stop[1],stop[2]}; unsigned int pos[3]={stop[0],stop[1],stop[2]};
for (;pos[n]<start[n];++pos[n]) for (;pos[n]<start[n];++pos[n])
{ result -= Eng->GetCurr(n,pos[0],pos[1],pos[2]);
result-=array[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; return result;

View File

@ -76,7 +76,9 @@ protected:
ofstream file; ofstream file;
string m_filename; string m_filename;
double CalcLineIntegral(unsigned int* start, unsigned int* stop, int field); 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