new H-field probe
parent
efe64fca4d
commit
1a93650fa0
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Sebastian Held (sebastian.held@gmx.de)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <complex.h>
|
||||
#include <iomanip>
|
||||
#include "tools/global.h"
|
||||
#include "process_hfield.h"
|
||||
|
||||
ProcessHField::ProcessHField(Operator* op, Engine* eng) : ProcessEField(op, eng)
|
||||
{
|
||||
}
|
||||
|
||||
ProcessHField::~ProcessHField()
|
||||
{
|
||||
}
|
||||
|
||||
void ProcessHField::DefineStartStopCoord(double* dstart, double* dstop)
|
||||
{
|
||||
if (Op->SnapToMesh(dstart,start,true,m_start_inside)==false)
|
||||
cerr << "ProcessHField::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl;
|
||||
if (Op->SnapToMesh(dstop,stop,true,m_stop_inside)==false)
|
||||
cerr << "ProcessHField::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl;
|
||||
|
||||
if (g_settings.showProbeDiscretization()) {
|
||||
cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], true ) << ","
|
||||
<< Op->GetDiscLine( 1, start[1], true ) << "," << Op->GetDiscLine( 2, start[2], true ) << ") -> ("
|
||||
<< Op->GetDiscLine( 0, stop[0], true ) << ","<< Op->GetDiscLine( 1, stop[1], true ) << ","
|
||||
<< Op->GetDiscLine( 2, stop[2], true ) << ")";
|
||||
cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> ["
|
||||
<< stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ProcessHField::Process()
|
||||
{
|
||||
if (!Enabled)
|
||||
return -1;
|
||||
if (CheckTimestep()==false)
|
||||
return GetNextInterval();
|
||||
|
||||
|
||||
if (ProcessInterval)
|
||||
{
|
||||
// time-domain processing
|
||||
if (Eng->GetNumberOfTimesteps()%ProcessInterval==0)
|
||||
{
|
||||
file << setprecision(m_precision) << (double)Eng->GetNumberOfTimesteps()*Op->GetTimestep();
|
||||
for (int n=0; n<3; n++)
|
||||
{
|
||||
FDTD_FLOAT field = Eng->GetCurr(n,start) / Op->GetMeshDelta(n,start,true);
|
||||
field *= m_weight;
|
||||
// TD_Values.push_back(voltage);
|
||||
file << "\t" << field;
|
||||
}
|
||||
file << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_FD_Interval)
|
||||
{
|
||||
// frequency-domain processing
|
||||
if (Eng->GetNumberOfTimesteps()%m_FD_Interval==0)
|
||||
{
|
||||
double T = (double)Eng->GetNumberOfTimesteps() * Op->GetTimestep();
|
||||
for (int pol=0; pol<3; pol++)
|
||||
{
|
||||
FDTD_FLOAT field = Eng->GetCurr(pol,start) / Op->GetMeshDelta(pol,start,true);
|
||||
field *= m_weight;
|
||||
for (size_t n=0;n<m_FD_Samples.size();++n)
|
||||
{
|
||||
FD_Values[pol].at(n) += field * cexp( -2.0 * 1.0i * M_PI * m_FD_Samples.at(n) * T );
|
||||
}
|
||||
++m_FD_SampleCount;
|
||||
}
|
||||
if (m_Flush)
|
||||
FlushData();
|
||||
m_Flush = false;
|
||||
}
|
||||
}
|
||||
|
||||
return GetNextInterval();
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Sebastian Held (sebastian.held@gmx.de)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PROCESS_HFIELD_H
|
||||
#define PROCESS_HFIELD_H
|
||||
|
||||
#include "process_efield.h"
|
||||
|
||||
typedef _Complex double complexdouble;
|
||||
|
||||
/*! \brief Process H-field at a point
|
||||
|
||||
This class calculates the E-field at a point in the FDTD lattice.
|
||||
Other primitives than \c Point are not supported.
|
||||
*/
|
||||
class ProcessHField : public ProcessEField
|
||||
{
|
||||
public:
|
||||
ProcessHField(Operator* op, Engine* eng);
|
||||
virtual ~ProcessHField();
|
||||
|
||||
void DefineStartStopCoord(double* dstart, double* dstop);
|
||||
virtual int Process();
|
||||
};
|
||||
|
||||
#endif // PROCESS_HFIELD_H
|
|
@ -36,7 +36,7 @@ void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop)
|
|||
cerr << "ProcessCurrent::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl;
|
||||
|
||||
if (g_settings.showProbeDiscretization()) {
|
||||
cerr << m_filename << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], true ) << ","
|
||||
cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], true ) << ","
|
||||
<< Op->GetDiscLine( 1, start[1], true ) << "," << Op->GetDiscLine( 2, start[2], true ) << ") -> ("
|
||||
<< Op->GetDiscLine( 0, stop[0], true ) << ","<< Op->GetDiscLine( 1, stop[1], true ) << ","
|
||||
<< Op->GetDiscLine( 2, stop[2], true ) << ")";
|
||||
|
|
|
@ -52,6 +52,7 @@ SOURCES += main.cpp \
|
|||
tools/array_ops.cpp \
|
||||
FDTD/processvoltage.cpp \
|
||||
FDTD/process_efield.cpp \
|
||||
FDTD/process_hfield.cpp \
|
||||
FDTD/processing.cpp \
|
||||
FDTD/processintegral.cpp \
|
||||
FDTD/processfields.cpp \
|
||||
|
@ -88,6 +89,7 @@ HEADERS += tools/ErrorMsg.h \
|
|||
tools/array_ops.h \
|
||||
FDTD/processvoltage.h \
|
||||
FDTD/process_efield.h \
|
||||
FDTD/process_hfield.h \
|
||||
FDTD/processing.h \
|
||||
FDTD/processintegral.h \
|
||||
FDTD/processfields.h \
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "FDTD/processvoltage.h"
|
||||
#include "FDTD/processcurrent.h"
|
||||
#include "FDTD/process_efield.h"
|
||||
#include "FDTD/process_hfield.h"
|
||||
#include "FDTD/processfields_td.h"
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
@ -343,8 +344,8 @@ int openEMS::SetupFDTD(const char* file)
|
|||
}
|
||||
else if (pb->GetProbeType()==2)
|
||||
proc = new ProcessEField(FDTD_Op,FDTD_Eng);
|
||||
// else if (pb->GetProbeType()==3)
|
||||
// proc = new ProcessHField(FDTD_Op,FDTD_Eng);
|
||||
else if (pb->GetProbeType()==3)
|
||||
proc = new ProcessHField(FDTD_Op,FDTD_Eng);
|
||||
else
|
||||
{
|
||||
cerr << "openEMS::SetupFDTD: Warning: Probe type " << pb->GetProbeType() << " of property '" << pb->GetName() << "' is unknown..." << endl;
|
||||
|
|
Loading…
Reference in New Issue