diff --git a/Common/processcurrent.cpp b/Common/processcurrent.cpp index e97356e..112e387 100644 --- a/Common/processcurrent.cpp +++ b/Common/processcurrent.cpp @@ -35,6 +35,46 @@ string ProcessCurrent::GetIntegralName(int row) const return "unknown"; } +void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop) +{ + ProcessIntegral::DefineStartStopCoord(dstart, dstop); + + int Dump_Dim = 0; + + for (int n=0; n<3; ++n) + { + 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 ((Op->GetDiscLine( n, start[n], m_dualMesh ) > min(dstart[n],dstop[n])) && (start[n]>0)) + --start[n]; + if ((Op->GetDiscLine( n, stop[n], m_dualMesh ) < max(dstart[n],dstop[n])) && (stop[n]GetNumberOfLines(n)-1)) + ++stop[n]; + } + if (stop[n] == start[n]) + m_normDir = n; + } + + if (Dump_Dim!=2) + { + cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << Dump_Dim << ") --> disabled" << endl; + SetEnable(false); + return; + } +} + double ProcessCurrent::CalcIntegral() { FDTD_FLOAT current=0; @@ -45,37 +85,8 @@ double ProcessCurrent::CalcIntegral() { const Engine* Eng = EI_FDTD->GetFDTDEngine(); - int Dump_Dim = 0; - int NormDir = 0; - for (int n=0; n<3; ++n) - { - 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 (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) + switch (m_normDir) { case 0: //y-current diff --git a/Common/processcurrent.h b/Common/processcurrent.h index de3b686..79ca947 100644 --- a/Common/processcurrent.h +++ b/Common/processcurrent.h @@ -30,10 +30,13 @@ public: virtual string GetIntegralName(int row) const; + virtual void DefineStartStopCoord(double* dstart, double* dstop); + //! Integrate currents flowing through an area virtual double CalcIntegral(); protected: + int m_normDir; //current box has to be 2D plane, this is the normal direction }; #endif // PROCESSCURRENT_H diff --git a/Common/processing.cpp b/Common/processing.cpp index a105984..c1365ee 100644 --- a/Common/processing.cpp +++ b/Common/processing.cpp @@ -178,16 +178,16 @@ void Processing::DefineStartStopCoord(double* dstart, double* dstop) cerr << "Processing::DefineStartStopCoord: Warning in " << m_Name << " (" << GetProcessingName() << ") : Snapped start line outside field domain!!" << endl; if (Op->SnapToMesh(dstop,stop,m_dualMesh,m_stop_inside)==false) cerr << "Processing::DefineStartStopCoord: Warning in " << m_Name << " (" << GetProcessingName() << ") : Snapped stop line outside field domain!!" << endl; +} - if (g_settings.showProbeDiscretization()) - { - cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], m_dualMesh ) << "," - << Op->GetDiscLine( 1, start[1], m_dualMesh ) << "," << Op->GetDiscLine( 2, start[2], m_dualMesh ) << ") -> (" - << Op->GetDiscLine( 0, stop[0], m_dualMesh ) << ","<< Op->GetDiscLine( 1, stop[1], m_dualMesh ) << "," - << Op->GetDiscLine( 2, stop[2], m_dualMesh ) << ")"; - cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> [" - << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; - } +void Processing::ShowSnappedCoords() +{ + cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], m_dualMesh ) << "," + << Op->GetDiscLine( 1, start[1], m_dualMesh ) << "," << Op->GetDiscLine( 2, start[2], m_dualMesh ) << ") -> (" + << Op->GetDiscLine( 0, stop[0], m_dualMesh ) << ","<< Op->GetDiscLine( 1, stop[1], m_dualMesh ) << "," + << Op->GetDiscLine( 2, stop[2], m_dualMesh ) << ")"; + cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> [" + << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; } void Processing::OpenFile( string outfile ) diff --git a/Common/processing.h b/Common/processing.h index b828855..9dbda1a 100644 --- a/Common/processing.h +++ b/Common/processing.h @@ -58,6 +58,8 @@ public: virtual void DefineStartStopCoord(double* dstart, double* dstop); + virtual void ShowSnappedCoords(); + void SetProcessInterval(unsigned int interval) {ProcessInterval=max((unsigned int)1,interval);} void AddStep(unsigned int step); diff --git a/openems.cpp b/openems.cpp index c4a3d09..235c99e 100644 --- a/openems.cpp +++ b/openems.cpp @@ -356,6 +356,8 @@ bool openEMS::SetupProcessing() proc->AddFrequency(pb->GetFDSamples()); proc->SetName(pb->GetName()); proc->DefineStartStopCoord(start,stop); + if (g_settings.showProbeDiscretization()) + proc->ShowSnappedCoords(); proc->SetWeight(pb->GetWeighting()); PA->AddProcessing(proc); prim->SetPrimitiveUsed(true);