From 1a93650fa0767b73304dd44625b795c232b58f0d Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Mon, 19 Jul 2010 08:41:53 +0200 Subject: [PATCH] new H-field probe --- FDTD/process_hfield.cpp | 97 +++++++++++++++++++++++++++++++++++++++++ FDTD/process_hfield.h | 40 +++++++++++++++++ FDTD/processcurrent.cpp | 2 +- openEMS.pro | 2 + openems.cpp | 5 ++- 5 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 FDTD/process_hfield.cpp create mode 100644 FDTD/process_hfield.h diff --git a/FDTD/process_hfield.cpp b/FDTD/process_hfield.cpp new file mode 100644 index 0000000..b866455 --- /dev/null +++ b/FDTD/process_hfield.cpp @@ -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 . +*/ + +#include +#include +#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. +*/ + +#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 diff --git a/FDTD/processcurrent.cpp b/FDTD/processcurrent.cpp index 49be042..2ac1a7d 100644 --- a/FDTD/processcurrent.cpp +++ b/FDTD/processcurrent.cpp @@ -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 ) << ")"; diff --git a/openEMS.pro b/openEMS.pro index b451aed..cf45d0c 100644 --- a/openEMS.pro +++ b/openEMS.pro @@ -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 \ diff --git a/openems.cpp b/openems.cpp index 97cdd29..a736e05 100644 --- a/openems.cpp +++ b/openems.cpp @@ -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 #include @@ -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;