fixes in current integration box

the given coordinates are now always inside the integration box
This commit is contained in:
Thorsten Liebig 2011-07-13 09:36:23 +02:00
parent 8237d39ece
commit afd4a5d07b
5 changed files with 57 additions and 39 deletions

View File

@ -35,18 +35,11 @@ string ProcessCurrent::GetIntegralName(int row) const
return "unknown"; return "unknown";
} }
double ProcessCurrent::CalcIntegral() void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop)
{ {
FDTD_FLOAT current=0; ProcessIntegral::DefineStartStopCoord(dstart, dstop);
Engine_Interface_FDTD* EI_FDTD = dynamic_cast<Engine_Interface_FDTD*>(m_Eng_Interface);
if (EI_FDTD)
{
const Engine* Eng = EI_FDTD->GetFDTDEngine();
int Dump_Dim = 0; int Dump_Dim = 0;
int NormDir = 0;
for (int n=0; n<3; ++n) for (int n=0; n<3; ++n)
{ {
@ -63,19 +56,37 @@ double ProcessCurrent::CalcIntegral()
stop[n]=Op->GetNumberOfLines(n)-1; stop[n]=Op->GetNumberOfLines(n)-1;
if (stop[n]>start[n]) if (stop[n]>start[n])
{
++Dump_Dim; ++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]<Op->GetNumberOfLines(n)-1))
++stop[n];
}
if (stop[n] == start[n]) if (stop[n] == start[n])
NormDir = n; m_normDir = n;
} }
if (Dump_Dim!=2) if (Dump_Dim!=2)
{ {
cerr << "ProcessCurrent::Process(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << Dump_Dim << ") --> i = 0" << endl; cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << Dump_Dim << ") --> disabled" << endl;
current = 0; SetEnable(false);
return 0.0; return;
}
} }
switch (NormDir) double ProcessCurrent::CalcIntegral()
{
FDTD_FLOAT current=0;
Engine_Interface_FDTD* EI_FDTD = dynamic_cast<Engine_Interface_FDTD*>(m_Eng_Interface);
if (EI_FDTD)
{
const Engine* Eng = EI_FDTD->GetFDTDEngine();
switch (m_normDir)
{ {
case 0: case 0:
//y-current //y-current

View File

@ -30,10 +30,13 @@ public:
virtual string GetIntegralName(int row) const; virtual string GetIntegralName(int row) const;
virtual void DefineStartStopCoord(double* dstart, double* dstop);
//! Integrate currents flowing through an area //! Integrate currents flowing through an area
virtual double CalcIntegral(); virtual double CalcIntegral();
protected: protected:
int m_normDir; //current box has to be 2D plane, this is the normal direction
}; };
#endif // PROCESSCURRENT_H #endif // PROCESSCURRENT_H

View File

@ -178,8 +178,9 @@ void Processing::DefineStartStopCoord(double* dstart, double* dstop)
cerr << "Processing::DefineStartStopCoord: Warning in " << m_Name << " (" << GetProcessingName() << ") : Snapped start line outside field domain!!" << endl; 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) 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; cerr << "Processing::DefineStartStopCoord: Warning in " << m_Name << " (" << GetProcessingName() << ") : Snapped stop line outside field domain!!" << endl;
}
if (g_settings.showProbeDiscretization()) void Processing::ShowSnappedCoords()
{ {
cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], m_dualMesh ) << "," 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( 1, start[1], m_dualMesh ) << "," << Op->GetDiscLine( 2, start[2], m_dualMesh ) << ") -> ("
@ -188,7 +189,6 @@ void Processing::DefineStartStopCoord(double* dstart, double* dstop)
cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> [" cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> ["
<< stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl;
} }
}
void Processing::OpenFile( string outfile ) void Processing::OpenFile( string outfile )
{ {

View File

@ -58,6 +58,8 @@ public:
virtual void DefineStartStopCoord(double* dstart, double* dstop); virtual void DefineStartStopCoord(double* dstart, double* dstop);
virtual void ShowSnappedCoords();
void SetProcessInterval(unsigned int interval) {ProcessInterval=max((unsigned int)1,interval);} void SetProcessInterval(unsigned int interval) {ProcessInterval=max((unsigned int)1,interval);}
void AddStep(unsigned int step); void AddStep(unsigned int step);

View File

@ -356,6 +356,8 @@ bool openEMS::SetupProcessing()
proc->AddFrequency(pb->GetFDSamples()); proc->AddFrequency(pb->GetFDSamples());
proc->SetName(pb->GetName()); proc->SetName(pb->GetName());
proc->DefineStartStopCoord(start,stop); proc->DefineStartStopCoord(start,stop);
if (g_settings.showProbeDiscretization())
proc->ShowSnappedCoords();
proc->SetWeight(pb->GetWeighting()); proc->SetWeight(pb->GetWeighting());
PA->AddProcessing(proc); PA->AddProcessing(proc);
prim->SetPrimitiveUsed(true); prim->SetPrimitiveUsed(true);