summaryrefslogtreecommitdiff
path: root/openEMS
diff options
context:
space:
mode:
authorRuben Undheim <ruben.undheim@gmail.com>2016-07-05 18:02:38 +0200
committerRuben Undheim <ruben.undheim@gmail.com>2016-07-05 18:02:38 +0200
commitef962f6008f25ab7cbd4ca21bcc72b97a1e2d76f (patch)
tree8149bee93d1a3f91d4503bfb3853adac4af0a85e /openEMS
Imported Upstream version 0.0.34
Diffstat (limited to 'openEMS')
-rw-r--r--openEMS/Analyse/PlotVoltage.m70
-rw-r--r--openEMS/CMakeLists.txt208
-rw-r--r--openEMS/COPYING674
-rw-r--r--openEMS/Common/CMakeLists.txt23
-rw-r--r--openEMS/Common/engine_interface_base.cpp39
-rw-r--r--openEMS/Common/engine_interface_base.h88
-rw-r--r--openEMS/Common/operator_base.cpp154
-rw-r--r--openEMS/Common/operator_base.h179
-rw-r--r--openEMS/Common/processcurrent.cpp168
-rw-r--r--openEMS/Common/processcurrent.h41
-rw-r--r--openEMS/Common/processfieldprobe.cpp92
-rw-r--r--openEMS/Common/processfieldprobe.h43
-rw-r--r--openEMS/Common/processfields.cpp341
-rw-r--r--openEMS/Common/processfields.h104
-rw-r--r--openEMS/Common/processfields_fd.cpp225
-rw-r--r--openEMS/Common/processfields_fd.h43
-rw-r--r--openEMS/Common/processfields_sar.cpp335
-rw-r--r--openEMS/Common/processfields_sar.h61
-rw-r--r--openEMS/Common/processfields_td.cpp91
-rw-r--r--openEMS/Common/processfields_td.h42
-rw-r--r--openEMS/Common/processing.cpp372
-rw-r--r--openEMS/Common/processing.h204
-rw-r--r--openEMS/Common/processintegral.cpp177
-rw-r--r--openEMS/Common/processintegral.h71
-rw-r--r--openEMS/Common/processmodematch.cpp265
-rw-r--r--openEMS/Common/processmodematch.h68
-rw-r--r--openEMS/Common/processvoltage.cpp40
-rw-r--r--openEMS/Common/processvoltage.h39
-rw-r--r--openEMS/Common/readme.txt6
-rw-r--r--openEMS/Doxyfile1551
-rw-r--r--openEMS/FDTD/CMakeLists.txt30
-rw-r--r--openEMS/FDTD/engine.cpp232
-rw-r--r--openEMS/FDTD/engine.h104
-rw-r--r--openEMS/FDTD/engine_cylinder.cpp38
-rw-r--r--openEMS/FDTD/engine_cylinder.h36
-rw-r--r--openEMS/FDTD/engine_cylindermultigrid.cpp226
-rw-r--r--openEMS/FDTD/engine_cylindermultigrid.h85
-rw-r--r--openEMS/FDTD/engine_interface_cylindrical_fdtd.cpp64
-rw-r--r--openEMS/FDTD/engine_interface_cylindrical_fdtd.h39
-rw-r--r--openEMS/FDTD/engine_interface_fdtd.cpp274
-rw-r--r--openEMS/FDTD/engine_interface_fdtd.h65
-rw-r--r--openEMS/FDTD/engine_interface_sse_fdtd.cpp69
-rw-r--r--openEMS/FDTD/engine_interface_sse_fdtd.h38
-rw-r--r--openEMS/FDTD/engine_mpi.cpp211
-rw-r--r--openEMS/FDTD/engine_mpi.h57
-rw-r--r--openEMS/FDTD/engine_multithread.cpp343
-rw-r--r--openEMS/FDTD/engine_multithread.h127
-rw-r--r--openEMS/FDTD/engine_sse.cpp176
-rw-r--r--openEMS/FDTD/engine_sse.h60
-rw-r--r--openEMS/FDTD/engine_sse_compressed.cpp163
-rw-r--r--openEMS/FDTD/engine_sse_compressed.h38
-rw-r--r--openEMS/FDTD/excitation.cpp304
-rw-r--r--openEMS/FDTD/excitation.h115
-rw-r--r--openEMS/FDTD/extensions/CMakeLists.txt32
-rw-r--r--openEMS/FDTD/extensions/OptimizeCondSheetParameter.m107
-rw-r--r--openEMS/FDTD/extensions/cond_sheet_parameter.h14
-rw-r--r--openEMS/FDTD/extensions/engine_ext_cylinder.cpp101
-rw-r--r--openEMS/FDTD/extensions/engine_ext_cylinder.h49
-rw-r--r--openEMS/FDTD/extensions/engine_ext_cylindermultigrid.cpp165
-rw-r--r--openEMS/FDTD/extensions/engine_ext_cylindermultigrid.h58
-rw-r--r--openEMS/FDTD/extensions/engine_ext_dispersive.cpp162
-rw-r--r--openEMS/FDTD/extensions/engine_ext_dispersive.h51
-rw-r--r--openEMS/FDTD/extensions/engine_ext_excitation.cpp170
-rw-r--r--openEMS/FDTD/extensions/engine_ext_excitation.h40
-rw-r--r--openEMS/FDTD/extensions/engine_ext_lorentzmaterial.cpp322
-rw-r--r--openEMS/FDTD/extensions/engine_ext_lorentzmaterial.h48
-rw-r--r--openEMS/FDTD/extensions/engine_ext_mur_abc.cpp263
-rw-r--r--openEMS/FDTD/extensions/engine_ext_mur_abc.h63
-rw-r--r--openEMS/FDTD/extensions/engine_ext_steadystate.cpp112
-rw-r--r--openEMS/FDTD/extensions/engine_ext_steadystate.h51
-rw-r--r--openEMS/FDTD/extensions/engine_ext_tfsf.cpp215
-rw-r--r--openEMS/FDTD/extensions/engine_ext_tfsf.h40
-rw-r--r--openEMS/FDTD/extensions/engine_ext_upml.cpp493
-rw-r--r--openEMS/FDTD/extensions/engine_ext_upml.h55
-rw-r--r--openEMS/FDTD/extensions/engine_extension.cpp95
-rw-r--r--openEMS/FDTD/extensions/engine_extension.h88
-rw-r--r--openEMS/FDTD/extensions/operator_ext_conductingsheet.cpp261
-rw-r--r--openEMS/FDTD/extensions/operator_ext_conductingsheet.h51
-rw-r--r--openEMS/FDTD/extensions/operator_ext_cylinder.cpp114
-rw-r--r--openEMS/FDTD/extensions/operator_ext_cylinder.h60
-rw-r--r--openEMS/FDTD/extensions/operator_ext_dispersive.cpp78
-rw-r--r--openEMS/FDTD/extensions/operator_ext_dispersive.h56
-rw-r--r--openEMS/FDTD/extensions/operator_ext_excitation.cpp372
-rw-r--r--openEMS/FDTD/extensions/operator_ext_excitation.h84
-rw-r--r--openEMS/FDTD/extensions/operator_ext_lorentzmaterial.cpp453
-rw-r--r--openEMS/FDTD/extensions/operator_ext_lorentzmaterial.h62
-rw-r--r--openEMS/FDTD/extensions/operator_ext_mur_abc.cpp210
-rw-r--r--openEMS/FDTD/extensions/operator_ext_mur_abc.h68
-rw-r--r--openEMS/FDTD/extensions/operator_ext_steadystate.cpp104
-rw-r--r--openEMS/FDTD/extensions/operator_ext_steadystate.h61
-rw-r--r--openEMS/FDTD/extensions/operator_ext_tfsf.cpp429
-rw-r--r--openEMS/FDTD/extensions/operator_ext_tfsf.h82
-rw-r--r--openEMS/FDTD/extensions/operator_ext_upml.cpp478
-rw-r--r--openEMS/FDTD/extensions/operator_ext_upml.h106
-rw-r--r--openEMS/FDTD/extensions/operator_extension.cpp54
-rw-r--r--openEMS/FDTD/extensions/operator_extension.h87
-rw-r--r--openEMS/FDTD/openems_fdtd_mpi.cpp545
-rw-r--r--openEMS/FDTD/openems_fdtd_mpi.h72
-rw-r--r--openEMS/FDTD/operator.cpp2131
-rw-r--r--openEMS/FDTD/operator.h287
-rw-r--r--openEMS/FDTD/operator_cylinder.cpp576
-rw-r--r--openEMS/FDTD/operator_cylinder.h118
-rw-r--r--openEMS/FDTD/operator_cylindermultigrid.cpp569
-rw-r--r--openEMS/FDTD/operator_cylindermultigrid.h109
-rw-r--r--openEMS/FDTD/operator_mpi.cpp209
-rw-r--r--openEMS/FDTD/operator_mpi.h90
-rw-r--r--openEMS/FDTD/operator_multithread.cpp203
-rw-r--r--openEMS/FDTD/operator_multithread.h89
-rw-r--r--openEMS/FDTD/operator_sse.cpp91
-rw-r--r--openEMS/FDTD/operator_sse.h63
-rw-r--r--openEMS/FDTD/operator_sse_compressed.cpp251
-rw-r--r--openEMS/FDTD/operator_sse_compressed.h84
-rw-r--r--openEMS/INSTALL27
-rw-r--r--openEMS/NEWS40
-rw-r--r--openEMS/README19
-rw-r--r--openEMS/TESTSUITE/combinedtests/Coax.m158
-rw-r--r--openEMS/TESTSUITE/combinedtests/README3
-rw-r--r--openEMS/TESTSUITE/combinedtests/cavity.m229
-rw-r--r--openEMS/TESTSUITE/enginetests/cavity.m190
-rw-r--r--openEMS/TESTSUITE/helperscripts/check_frequency.m31
-rw-r--r--openEMS/TESTSUITE/helperscripts/check_limits.m22
-rw-r--r--openEMS/TESTSUITE/probes/fieldprobes.m324
-rw-r--r--openEMS/TESTSUITE/run_testsuite.m58
-rw-r--r--openEMS/TODO14
-rwxr-xr-xopenEMS/astyle.sh4
-rw-r--r--openEMS/cmake/Modules/FindTinyXML.cmake74
-rw-r--r--openEMS/known_bugs1
-rw-r--r--openEMS/known_problems4
-rw-r--r--openEMS/linux/CalcNF2FF.m.patch14
-rw-r--r--openEMS/linux/README.patch15
-rw-r--r--openEMS/linux/debian.changelog27
-rw-r--r--openEMS/linux/debian.control12
-rw-r--r--openEMS/linux/debian.docs2
-rw-r--r--openEMS/linux/debian.rules90
-rw-r--r--openEMS/linux/debian.series3
-rw-r--r--openEMS/linux/fedora17.diff13
-rw-r--r--openEMS/linux/invoke_openEMS.m.patch15
-rw-r--r--openEMS/linux/openEMS.dsc9
-rw-r--r--openEMS/linux/openEMS.spec113
-rw-r--r--openEMS/main.cpp81
-rw-r--r--openEMS/matlab/AR_estimate.m115
-rw-r--r--openEMS/matlab/Add2Queue.m48
-rw-r--r--openEMS/matlab/AddCPWPort.m285
-rw-r--r--openEMS/matlab/AddCircWaveGuidePort.m109
-rw-r--r--openEMS/matlab/AddCoaxialPort.m232
-rw-r--r--openEMS/matlab/AddCurvePort.m182
-rw-r--r--openEMS/matlab/AddLumpedPort.m129
-rw-r--r--openEMS/matlab/AddMRStub.m73
-rw-r--r--openEMS/matlab/AddMSLPort.m265
-rw-r--r--openEMS/matlab/AddPML.m92
-rw-r--r--openEMS/matlab/AddRectWaveGuidePort.m92
-rw-r--r--openEMS/matlab/AddStripLinePort.m283
-rw-r--r--openEMS/matlab/AddWaveGuidePort.m119
-rw-r--r--openEMS/matlab/AnalyzeNF2FF.m231
-rw-r--r--openEMS/matlab/CalcNF2FF.m161
-rw-r--r--openEMS/matlab/CheckQueue.m60
-rw-r--r--openEMS/matlab/ConvertHDF5_VTK.m100
-rw-r--r--openEMS/matlab/CreateNF2FFBox.m94
-rw-r--r--openEMS/matlab/DFT_time2freq.m47
-rw-r--r--openEMS/matlab/Dump2VTK.m179
-rw-r--r--openEMS/matlab/DumpFF2VTK.m105
-rw-r--r--openEMS/matlab/FFT_time2freq.m18
-rw-r--r--openEMS/matlab/FindFreeSSH.m87
-rw-r--r--openEMS/matlab/FinishQueue.m40
-rw-r--r--openEMS/matlab/GetField_Interpolation.m147
-rw-r--r--openEMS/matlab/GetField_Range.m71
-rw-r--r--openEMS/matlab/GetField_SubSampling.m63
-rw-r--r--openEMS/matlab/GetField_TD2FD.m48
-rw-r--r--openEMS/matlab/InitCylindricalFDTD.m21
-rw-r--r--openEMS/matlab/InitFDTD.m64
-rw-r--r--openEMS/matlab/InitQueue.m90
-rw-r--r--openEMS/matlab/PlotHDF5FieldData.m94
-rw-r--r--openEMS/matlab/ReadHDF5Attribute.m33
-rw-r--r--openEMS/matlab/ReadHDF5Dump.m92
-rw-r--r--openEMS/matlab/ReadHDF5FieldData.m119
-rw-r--r--openEMS/matlab/ReadHDF5Mesh.m80
-rw-r--r--openEMS/matlab/ReadUI.m107
-rw-r--r--openEMS/matlab/ResultsQueue.m24
-rw-r--r--openEMS/matlab/RunOpenEMS.m186
-rw-r--r--openEMS/matlab/RunOpenEMS_MPI.m125
-rw-r--r--openEMS/matlab/RunOpenEMS_Parallel.m92
-rw-r--r--openEMS/matlab/SetBoundaryCond.m68
-rw-r--r--openEMS/matlab/SetCustomExcite.m21
-rw-r--r--openEMS/matlab/SetDiracExcite.m3
-rw-r--r--openEMS/matlab/SetGaussExcite.m18
-rw-r--r--openEMS/matlab/SetSinusExcite.m14
-rw-r--r--openEMS/matlab/SetStepExcite.m3
-rw-r--r--openEMS/matlab/SetupMPI.m17
-rw-r--r--openEMS/matlab/Tutorials/Bent_Patch_Antenna.m197
-rw-r--r--openEMS/matlab/Tutorials/CRLH_Extraction.m155
-rw-r--r--openEMS/matlab/Tutorials/CRLH_LeakyWaveAnt.m168
-rw-r--r--openEMS/matlab/Tutorials/Circ_Waveguide.m105
-rw-r--r--openEMS/matlab/Tutorials/Conical_Horn_Antenna.m180
-rw-r--r--openEMS/matlab/Tutorials/CreateCRLH.m55
-rw-r--r--openEMS/matlab/Tutorials/CylindricalWave_CC.m104
-rw-r--r--openEMS/matlab/Tutorials/Dipole_SAR.m221
-rw-r--r--openEMS/matlab/Tutorials/Helical_Antenna.m202
-rw-r--r--openEMS/matlab/Tutorials/Horn_Antenna.m202
-rw-r--r--openEMS/matlab/Tutorials/MRI_LP_Birdcage.m320
-rw-r--r--openEMS/matlab/Tutorials/MRI_Loop_Coil.m334
-rw-r--r--openEMS/matlab/Tutorials/MSL_NotchFilter.m92
-rw-r--r--openEMS/matlab/Tutorials/Parallel_Plate_Waveguide.m51
-rw-r--r--openEMS/matlab/Tutorials/Patch_Antenna_Array.m170
-rw-r--r--openEMS/matlab/Tutorials/Patch_Antenna_Phased_Array.m166
-rw-r--r--openEMS/matlab/Tutorials/RCS_Sphere.m138
-rw-r--r--openEMS/matlab/Tutorials/Rect_Waveguide.m121
-rw-r--r--openEMS/matlab/Tutorials/Simple_Patch_Antenna.m180
-rw-r--r--openEMS/matlab/Tutorials/readme1
-rw-r--r--openEMS/matlab/WriteHDF5.m73
-rw-r--r--openEMS/matlab/WriteOpenEMS.m19
-rw-r--r--openEMS/matlab/calcLumpedPort.m107
-rw-r--r--openEMS/matlab/calcPort.m82
-rw-r--r--openEMS/matlab/calcTLPort.m173
-rw-r--r--openEMS/matlab/calcWGPort.m145
-rw-r--r--openEMS/matlab/calc_ypar.m69
-rw-r--r--openEMS/matlab/examples/__deprecated__/MSL2.m254
-rw-r--r--openEMS/matlab/examples/antennas/Bi_Quad_Antenna.m139
-rw-r--r--openEMS/matlab/examples/antennas/Patch_Antenna.m218
-rw-r--r--openEMS/matlab/examples/antennas/Patch_Antenna_Array.m256
-rw-r--r--openEMS/matlab/examples/antennas/infDipol.m121
-rw-r--r--openEMS/matlab/examples/antennas/inverted_f.m205
-rw-r--r--openEMS/matlab/examples/optimizer/optimizer_asco.m36
-rw-r--r--openEMS/matlab/examples/optimizer/optimizer_simfun.m134
-rw-r--r--openEMS/matlab/examples/other/Helix.m154
-rw-r--r--openEMS/matlab/examples/other/LumpedElement.m158
-rw-r--r--openEMS/matlab/examples/other/Metamaterial_PlaneWave_Drude.m147
-rw-r--r--openEMS/matlab/examples/other/PML_reflection_analysis.m196
-rw-r--r--openEMS/matlab/examples/other/PlaneWave.m69
-rw-r--r--openEMS/matlab/examples/other/gauss_excitation_test.m72
-rw-r--r--openEMS/matlab/examples/other/resistance_sheet.m207
-rw-r--r--openEMS/matlab/examples/transmission_lines/CPW_Line.m125
-rw-r--r--openEMS/matlab/examples/transmission_lines/Finite_Stripline.m91
-rw-r--r--openEMS/matlab/examples/transmission_lines/MSL.m185
-rw-r--r--openEMS/matlab/examples/transmission_lines/MSL_Losses.m102
-rw-r--r--openEMS/matlab/examples/transmission_lines/Stripline.m78
-rw-r--r--openEMS/matlab/examples/transmission_lines/directional_coupler.m261
-rw-r--r--openEMS/matlab/examples/waveguide/Circ_Waveguide.m207
-rw-r--r--openEMS/matlab/examples/waveguide/Circ_Waveguide_CylinderCoords.m204
-rw-r--r--openEMS/matlab/examples/waveguide/Coax.m120
-rw-r--r--openEMS/matlab/examples/waveguide/Coax_CylinderCoords.m190
-rw-r--r--openEMS/matlab/examples/waveguide/Coax_Cylindrical_MG.m155
-rw-r--r--openEMS/matlab/examples/waveguide/Rect_Waveguide.m240
-rwxr-xr-xopenEMS/matlab/h5readatt_octave.cc135
-rw-r--r--openEMS/matlab/harminv.m77
-rw-r--r--openEMS/matlab/optimize.m203
-rw-r--r--openEMS/matlab/optimizer_asco_sim.m88
-rw-r--r--openEMS/matlab/physical_constants.m12
-rw-r--r--openEMS/matlab/plotFF3D.m91
-rw-r--r--openEMS/matlab/plotFFdB.m78
-rw-r--r--openEMS/matlab/polarFF.m172
-rw-r--r--openEMS/matlab/private/ReadNF2FF.m82
-rw-r--r--openEMS/matlab/private/invoke_openEMS.m47
-rw-r--r--openEMS/matlab/queue_addProcess.m22
-rw-r--r--openEMS/matlab/queue_checkProcess.m25
-rw-r--r--openEMS/matlab/queue_delProcess.m40
-rw-r--r--openEMS/matlab/setup.m36
-rw-r--r--openEMS/nf2ff/CMakeLists.txt51
-rw-r--r--openEMS/nf2ff/main.cpp44
-rw-r--r--openEMS/nf2ff/nf2ff.cpp661
-rw-r--r--openEMS/nf2ff/nf2ff.h74
-rw-r--r--openEMS/nf2ff/nf2ff_calc.cpp513
-rw-r--r--openEMS/nf2ff/nf2ff_calc.h136
-rwxr-xr-xopenEMS/openEMS.sh11
-rw-r--r--openEMS/openEMS_MPI.pro5
-rwxr-xr-xopenEMS/openEMS_MPI.sh11
-rw-r--r--openEMS/openems.cpp1231
-rw-r--r--openEMS/openems.h167
-rw-r--r--openEMS/tools/AdrOp.cpp554
-rw-r--r--openEMS/tools/AdrOp.h149
-rw-r--r--openEMS/tools/CMakeLists.txt28
-rw-r--r--openEMS/tools/ErrorMsg.cpp98
-rw-r--r--openEMS/tools/ErrorMsg.h50
-rw-r--r--openEMS/tools/ExpenseLog.cpp145
-rw-r--r--openEMS/tools/ExpenseLog.h92
-rw-r--r--openEMS/tools/aligned_allocator.h173
-rw-r--r--openEMS/tools/array_ops.cpp144
-rw-r--r--openEMS/tools/array_ops.h196
-rw-r--r--openEMS/tools/constants.h29
-rw-r--r--openEMS/tools/global.cpp78
-rw-r--r--openEMS/tools/global.h65
-rw-r--r--openEMS/tools/hdf5_file_reader.cpp689
-rw-r--r--openEMS/tools/hdf5_file_reader.h78
-rw-r--r--openEMS/tools/hdf5_file_writer.cpp515
-rw-r--r--openEMS/tools/hdf5_file_writer.h68
-rw-r--r--openEMS/tools/sar_calculation.cpp656
-rw-r--r--openEMS/tools/sar_calculation.h122
-rw-r--r--openEMS/tools/useful.cpp185
-rw-r--r--openEMS/tools/useful.h44
-rw-r--r--openEMS/tools/vtk_file_writer.cpp340
-rw-r--r--openEMS/tools/vtk_file_writer.h94
290 files changed, 43355 insertions, 0 deletions
diff --git a/openEMS/Analyse/PlotVoltage.m b/openEMS/Analyse/PlotVoltage.m
new file mode 100644
index 0000000..19989c1
--- /dev/null
+++ b/openEMS/Analyse/PlotVoltage.m
@@ -0,0 +1,70 @@
+%close all;
+clear all;
+clc
+
+fmax = 50e6;
+
+figure(1);
+tmpu = load('../tmp/u1');
+tmpi = load('../tmp/i1');
+
+t = tmpu(:,1);
+u = tmpu(:,2);
+
+subplot(2,2,1);
+title('u_1 TD');
+plot(t,u);
+xlabel('t \rightarrow');
+ylabel('ut_1 \rightarrow');
+grid on;
+
+dt=t(2)-t(1);
+u= [u ; zeros(5000,1)];
+L=numel(u);
+t = (1:L)*dt;
+
+f = (0:L-1)/L/dt;
+fu = fft(u)/L;
+subplot(2,2,2);
+title('u_1 FD');
+plot(f(1:L/2),abs(fu(1:L/2)));
+xlabel('f \rightarrow');
+ylabel('|uf_1| \rightarrow');
+grid on;
+
+
+t = tmpi(:,1);
+i = tmpi(:,2);
+
+subplot(2,2,3);
+title('i_1 TD');
+plot(t,i);
+xlabel('t \rightarrow');
+ylabel('it_1 \rightarrow');
+grid on;
+
+dt=t(2)-t(1);
+i = [i; zeros(5000,1)];
+L=numel(i);
+t = (1:L)*dt;
+f = (0:L-1)/L/dt;
+
+fi = fft(i)/L;
+subplot(2,2,4);
+title('i_1 FD');
+plot(f(1:L/2),abs(fi(1:L/2)));
+xlabel('f \rightarrow');
+ylabel('|if_1| \rightarrow');
+grid on;
+
+figure(2);
+subplot(2,1,1);
+plot(f,real(fu./fi));
+xlim([0 fmax]);
+grid on;
+subplot(2,1,2);
+plot(f,imag(fu./fi));
+xlim([0 fmax]);
+grid on;
+
+
diff --git a/openEMS/CMakeLists.txt b/openEMS/CMakeLists.txt
new file mode 100644
index 0000000..5434138
--- /dev/null
+++ b/openEMS/CMakeLists.txt
@@ -0,0 +1,208 @@
+
+# define build type
+IF( DEFINED CMAKE_BUILD_TYPE )
+ SET( CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Set to either \"Release\" or \"Debug\"" )
+ELSE()
+ SET( CMAKE_BUILD_TYPE Release CACHE STRING "Set to either \"Release\" or \"Debug\"" )
+ENDIF()
+
+PROJECT(openEMS CXX)
+cmake_minimum_required(VERSION 2.8)
+
+# default
+set(LIB_VERSION_MAJOR 0)
+set(LIB_VERSION_MINOR 0)
+set(LIB_VERSION_PATCH 34)
+set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH})
+
+set(VERSION "v${LIB_VERSION_STRING}")
+
+IF(EXISTS ${PROJECT_SOURCE_DIR}/localConfig.cmake)
+ include(${PROJECT_SOURCE_DIR}/localConfig.cmake)
+ENDIF()
+
+set(VERSION "v0.0.34")
+
+# add git revision
+IF(EXISTS ${PROJECT_SOURCE_DIR}/.git )
+ FIND_PACKAGE(Git)
+ # Get the latest abbreviated commit hash of the working branch
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} describe --tags
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ OUTPUT_VARIABLE GITREV
+ )
+ set(VERSION ${GITREV})
+ string(STRIP ${VERSION} VERSION)
+ message(STATUS "Found Git repository, ${PROJECT_NAME} version tag: ${VERSION}")
+ENDIF()
+
+ADD_DEFINITIONS(-DGIT_VERSION=\"${VERSION}\")
+
+#
+# Set up RPATH for the project
+#
+option(ENABLE_RPATH "Enable rpath support on Linux and Mac" ON)
+if(NOT CMAKE_INSTALL_RPATH)
+ # the RPATH to be used when installing, but only if it's not a system directory
+ LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" isSystemDir)
+ IF("${isSystemDir}" STREQUAL "-1")
+ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
+ ENDIF("${isSystemDir}" STREQUAL "-1")
+endif()
+if(APPLE AND NOT CMAKE_INSTALL_NAME_DIR)
+ set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
+endif()
+if(UNIX AND ENABLE_RPATH)
+ set(CMAKE_SKIP_BUILD_RPATH FALSE)
+ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+endif()
+
+
+if (WITH_MPI)
+ ADD_DEFINITIONS(-DMPI_SUPPORT)
+ # Require MPI for this project:
+ find_package(MPI REQUIRED)
+ INCLUDE_DIRECTORIES( ${MPI_INCLUDE_PATH} )
+
+ message(STATUS "Found MPI. INCLUDE " ${MPI_INCLUDE_PATH})
+endif()
+
+# Set locations of extra CMake modules
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${openEMS_SOURCE_DIR}/cmake/Modules/")
+
+# fparser
+# $ cmake -D FPARSER_ROOT_DIR=~/opt/openEMS .
+# SET(FPARSER_ROOT_DIR ~/opt/openEMS)
+find_library(fparser_LIBRARIES
+ NAMES fparser
+ HINTS ${FPARSER_ROOT_DIR}/lib${LIB_SUFFIX}
+ NO_CMAKE_FIND_ROOT_PATH
+)
+message(STATUS "fparser: ${fparser_LIBRARIES}" )
+#TODO test if fparser was found
+INCLUDE_DIRECTORIES( ${FPARSER_ROOT_DIR}/include )
+
+# CSXCAD
+# $ cmake -D CSXCAD_ROOT_DIR=~/opt/openEMS .
+# SET(CSXCAD_ROOT_DIR ~/opt/openEMS)
+find_library(CSXCAD_LIBRARIES
+ NAMES CSXCAD
+ HINTS ${CSXCAD_ROOT_DIR}/lib${LIB_SUFFIX}
+ NO_CMAKE_FIND_ROOT_PATH
+)
+message(STATUS "CSXCAD_LIBRARIES: ${CSXCAD_LIBRARIES}" )
+#TODO test if CSXCADs was found
+find_path(CSXCAD_INCLUDE_DIR
+ NAMES ContinuousStructure.h
+ HINTS ${CSXCAD_ROOT_DIR}/include
+ PATH_SUFFIXES "CSXCAD" ${CSXCAD_INCLUDE_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+)
+message(STATUS "CSXCAD_INCLUDE_DIR: ${CSXCAD_INCLUDE_DIR}" )
+INCLUDE_DIRECTORIES( ${CSXCAD_INCLUDE_DIR} )
+
+# TinyXML module from https://github.com/ros/cmake_modules
+find_package(TinyXML REQUIRED)
+ADD_DEFINITIONS( -DTIXML_USE_STL )
+
+# hdf5
+find_package(HDF5 1.8 COMPONENTS C HL REQUIRED)
+INCLUDE_DIRECTORIES (${HDF5_INCLUDE_DIR})
+link_directories(${HDF5_LIBRARY_DIRS})
+
+# hdf5 compat
+ADD_DEFINITIONS( -DH5_USE_16_API )
+
+# boost
+find_package(Boost 1.46 COMPONENTS
+ thread
+ system
+ date_time
+ serialization
+ chrono
+)
+
+# vtk
+if (WIN32)
+ find_package(VTK 6.1 REQUIRED)
+else()
+ # prefer >=6.1, fallback to >=5.4
+ find_package(VTK 6.1 COMPONENTS vtkIOXML vtkIOGeometry vtkIOLegacy vtkIOPLY NO_MODULE)
+ IF (NOT ${VTK_FOUND})
+ find_package(VTK REQUIRED)
+ endif()
+endif()
+
+message(STATUS "Found package VTK. Using version " ${VTK_VERSION})
+if("${VTK_MAJOR_VERSION}" GREATER 5)
+ set( vtk_LIBS ${VTK_LIBRARIES} )
+else()
+ set( vtk_LIBS
+ vtkCommon
+ vtkIO
+ )
+endif()
+message(STATUS "vtk libraries " ${vtk_LIBS})
+
+include(${VTK_USE_FILE})
+INCLUDE_DIRECTORIES (${VTK_INCLUDE_DIR})
+
+#set(CMAKE_CXX_FLAGS "-msse -march=native")
+
+# independent tool
+ADD_SUBDIRECTORY( nf2ff )
+
+set(SOURCES
+ openems.cpp
+)
+
+# libs
+ADD_SUBDIRECTORY( tools )
+ADD_SUBDIRECTORY( FDTD )
+ADD_SUBDIRECTORY( FDTD/extensions )
+ADD_SUBDIRECTORY( Common )
+
+INCLUDE_DIRECTORIES( ${openEMS_SOURCE_DIR} ) #find tools
+
+message(STATUS "Sources:" ${SOURCES})
+
+if (${MPI_CXX_FOUND})
+ set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
+ set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
+ SET(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
+endif()
+
+add_library( openEMS SHARED ${SOURCES})
+set_target_properties(openEMS PROPERTIES VERSION ${LIB_VERSION_STRING} SOVERSION ${LIB_VERSION_MAJOR})
+TARGET_LINK_LIBRARIES( openEMS
+ ${CSXCAD_LIBRARIES}
+ ${fparser_LIBRARIES}
+ tinyxml
+ ${HDF5_LIBRARIES}
+ ${Boost_LIBRARIES}
+ ${vtk_LIBS}
+ ${MPI_LIBRARIES}
+)
+
+# main program
+ADD_EXECUTABLE( openEMS_bin main.cpp )
+SET_TARGET_PROPERTIES(openEMS_bin PROPERTIES OUTPUT_NAME openEMS)
+TARGET_LINK_LIBRARIES(openEMS_bin openEMS)
+
+INSTALL(TARGETS openEMS DESTINATION lib${LIB_SUFFIX})
+INSTALL(TARGETS openEMS_bin DESTINATION bin )
+
+if (UNIX)
+ INSTALL( FILES openEMS.sh
+ DESTINATION bin
+ PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
+ if (WITH_MPI)
+ INSTALL( FILES openEMS_MPI.sh
+ DESTINATION bin
+ PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
+ endif()
+endif ()
+INSTALL( DIRECTORY matlab DESTINATION share/openEMS )
+# TODO mpi, tarball, debug, release
diff --git a/openEMS/COPYING b/openEMS/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/openEMS/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/openEMS/Common/CMakeLists.txt b/openEMS/Common/CMakeLists.txt
new file mode 100644
index 0000000..004b35e
--- /dev/null
+++ b/openEMS/Common/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+#INCLUDE_DIRECTORIES( ${openEMS_SOURCE_DIR} )
+
+set(SOURCES
+ ${SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_interface_base.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_base.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processcurrent.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processfieldprobe.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processfields.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processfields_fd.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processfields_sar.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processfields_td.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processing.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processintegral.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processmodematch.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/processvoltage.cpp
+ PARENT_SCOPE
+)
+
+# Common lib
+#add_library( Common STATIC ${SOURCES} )
+
diff --git a/openEMS/Common/engine_interface_base.cpp b/openEMS/Common/engine_interface_base.cpp
new file mode 100644
index 0000000..4db393c
--- /dev/null
+++ b/openEMS/Common/engine_interface_base.cpp
@@ -0,0 +1,39 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine_interface_base.h"
+#include "string"
+
+Engine_Interface_Base::Engine_Interface_Base(Operator_Base* base_op)
+{
+ m_Op_Base = base_op;
+ m_InterpolType = NO_INTERPOLATION;
+}
+
+std::string Engine_Interface_Base::GetInterpolationNameByType(InterpolationType mode)
+{
+ switch (mode)
+ {
+ case NO_INTERPOLATION:
+ return std::string("None");
+ case NODE_INTERPOLATE:
+ return std::string("Node");
+ case CELL_INTERPOLATE:
+ return std::string("Cell");
+ }
+ return std::string();
+}
diff --git a/openEMS/Common/engine_interface_base.h b/openEMS/Common/engine_interface_base.h
new file mode 100644
index 0000000..6ce466b
--- /dev/null
+++ b/openEMS/Common/engine_interface_base.h
@@ -0,0 +1,88 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_INTERFACE_BASE_H
+#define ENGINE_INTERFACE_BASE_H
+
+#include "tools/global.h"
+
+class Operator_Base;
+
+//! This is the abstact base for all Engine Interface classes.
+/*!
+ This is the abstact base for all Engine Interface classes. It will provide unified access to the field information of the corresponding engine.
+ All processing methods should only access this base class.
+*/
+class Engine_Interface_Base
+{
+public:
+ enum InterpolationType { NO_INTERPOLATION, NODE_INTERPOLATE, CELL_INTERPOLATE };
+
+ virtual ~Engine_Interface_Base() {;} //!< provide a virtual destructor to correctly delete derived objects
+
+ //! Set the operator used for this engine interface.
+ virtual void SetOperator(Operator_Base* base_op) {m_Op_Base=base_op;}
+ //! Get the operator used for this engine interface.
+ virtual const Operator_Base* GetOperator() const {return m_Op_Base;}
+
+ //! Set the current interpolation type \sa GetInterpolationType
+ void SetInterpolationType(InterpolationType type) {m_InterpolType=type;}
+ //! Set the current interpolation type \sa GetInterpolationType
+ void SetInterpolationType(int type) {m_InterpolType=(InterpolationType)type;}
+ //! Get the current interpolation type as string \sa SetInterpolationType GetInterpolationType GetInterpolationNameByType
+ std::string GetInterpolationTypeString() {return GetInterpolationNameByType(m_InterpolType);}
+ //! Get the current interpolation type \sa SetInterpolationType
+ InterpolationType GetInterpolationType() {return m_InterpolType;}
+
+ //! Get the (interpolated) electric field at \p pos. \sa SetInterpolationType
+ virtual double* GetEField(const unsigned int* pos, double* out) const =0;
+ //! Get the (interpolated) magnetic field at \p pos. \sa SetInterpolationType
+ virtual double* GetHField(const unsigned int* pos, double* out) const =0;
+ //! Get the (interpolated) electric current density field at \p pos. \sa SetInterpolationType
+ virtual double* GetJField(const unsigned int* pos, double* out) const =0;
+ //! Get the total current density field by rot(H) at \p pos. \sa SetInterpolationType
+ virtual double* GetRotHField(const unsigned int* pos, double* out) const =0;
+
+ //! Calculate the electric field integral along a given line
+ virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const =0;
+
+ //! Convert the interpolation type into a string.
+ static std::string GetInterpolationNameByType(InterpolationType mode);
+
+ //! Get the current simulation time
+ virtual double GetTime(bool dualTime=false) const =0;
+
+ //! Get the current number of timesteps
+ virtual unsigned int GetNumberOfTimesteps() const =0;
+
+ //! Calc (roughly) the total energy
+ /*!
+ This method only calculates a very rough estimate of the total energy in the simulation domain.
+ The result may even be roughly proportional to the real system energy only.
+ Primary goal is speed, not accuracy.
+ */
+ virtual double CalcFastEnergy() const =0;
+
+protected:
+ Engine_Interface_Base(Operator_Base* base_op);
+
+ Operator_Base* m_Op_Base;
+
+ InterpolationType m_InterpolType;
+};
+
+#endif // ENGINE_INTERFACE_BASE_H
diff --git a/openEMS/Common/operator_base.cpp b/openEMS/Common/operator_base.cpp
new file mode 100644
index 0000000..e5d26f5
--- /dev/null
+++ b/openEMS/Common/operator_base.cpp
@@ -0,0 +1,154 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "operator_base.h"
+
+using namespace std;
+
+Operator_Base::Operator_Base()
+{
+ Init();
+ m_MeshType = CARTESIAN;
+ m_StoreMaterial[0]=false;
+ m_StoreMaterial[1]=false;
+ m_StoreMaterial[2]=false;
+ m_StoreMaterial[3]=false;
+}
+
+Operator_Base::~Operator_Base()
+{
+ Delete();
+}
+
+bool Operator_Base::SetGeometryCSX(ContinuousStructure* geo)
+{
+ if (geo==NULL) return false;
+ CSX = geo;
+
+ return true;
+}
+
+std::string Operator_Base::GetDirName(int ny) const
+{
+ if (ny==0) return "x";
+ if (ny==1) return "y";
+ if (ny==2) return "z";
+ return "";
+}
+
+void Operator_Base::Init()
+{
+ CSX = NULL;
+
+ dT = 0;
+ for (int n=0; n<3; ++n)
+ discLines[n]=NULL;
+ for (int n=0; n<6; ++n)
+ m_BC[n]=0;
+
+ SetBackgroundMaterial(1,1,0,0);
+}
+
+void Operator_Base::Delete()
+{
+ for (int n=0; n<3; ++n)
+ {
+ delete[] discLines[n];
+ discLines[n]=0;
+ }
+ for (int n=0; n<6; ++n)
+ m_BC[n]=0;
+ dT = 0;
+}
+
+void Operator_Base::Reset()
+{
+ Delete();
+}
+
+void Operator_Base::SetMaterialStoreFlags(int type, bool val)
+{
+ if ((type<0) || (type>4))
+ return;
+ m_StoreMaterial[type]=val;
+}
+
+bool Operator_Base::GetCellCenterMaterialAvgCoord(const unsigned int pos[3], double coord[3]) const
+{
+ int ipos[3] = {(int)pos[0], (int)pos[1], (int)pos[2]};
+ return GetCellCenterMaterialAvgCoord(ipos, coord);
+}
+
+void Operator_Base::SetBackgroundMaterial(double epsR, double mueR, double kappa, double sigma, double density)
+{
+ SetBackgroundEpsR(epsR);
+ SetBackgroundMueR(mueR);
+ SetBackgroundKappa(kappa);
+ SetBackgroundSigma(sigma);
+ SetBackgroundDensity(density);
+}
+
+void Operator_Base::SetBackgroundEpsR(double val)
+{
+ if (val<1)
+ {
+ cerr << __func__ << ": Warning, a relative electric permittivity <1 it not supported, skipping" << endl;
+ return;
+ }
+ m_BG_epsR=val;
+}
+
+void Operator_Base::SetBackgroundMueR(double val)
+{
+ if (val<1)
+ {
+ cerr << __func__ << ": Warning, a relative magnetic permeability <1 it not supported, skipping" << endl;
+ return;
+ }
+ m_BG_mueR=val;
+}
+
+void Operator_Base::SetBackgroundKappa(double val)
+{
+ if (val<0)
+ {
+ cerr << __func__ << ": Warning, an electric conductivity <0 it not supported, skipping" << endl;
+ return;
+ }
+ m_BG_kappa=val;
+}
+
+void Operator_Base::SetBackgroundSigma(double val)
+{
+ if (val<0)
+ {
+ cerr << __func__ << ": Warning, an artifival magnetic conductivity <0 it not supported, skipping" << endl;
+ return;
+ }
+ m_BG_sigma=val;
+}
+
+
+void Operator_Base::SetBackgroundDensity(double val)
+{
+ if (val<0)
+ {
+ cerr << __func__ << ": Warning, a mass density <0 it not supported, skipping" << endl;
+ return;
+ }
+ m_BG_density=val;
+}
diff --git a/openEMS/Common/operator_base.h b/openEMS/Common/operator_base.h
new file mode 100644
index 0000000..cfbd40b
--- /dev/null
+++ b/openEMS/Common/operator_base.h
@@ -0,0 +1,179 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_BASE_H
+#define OPERATOR_BASE_H
+
+#include "ContinuousStructure.h"
+#include "tools/global.h"
+#include "Common/processing.h"
+#include "string"
+
+typedef struct
+{
+ std::vector<unsigned int> posPath[3];
+ std::vector<unsigned short> dir;
+} Grid_Path;
+
+//! Abstract base-class for a common operator
+class Operator_Base
+{
+public:
+ virtual ~Operator_Base();
+
+ virtual bool SetGeometryCSX(ContinuousStructure* geo);
+ virtual ContinuousStructure* GetGeometryCSX() const {return CSX;}
+
+ //! Get the timestep used by this operator
+ virtual double GetTimestep() const {return dT;}
+
+ //! Get the number of cells or nodes defined by this operator
+ virtual double GetNumberCells() const =0;
+
+ //! Get the number of timesteps satisfying the nyquist condition (may depend on the excitation)
+ virtual unsigned int GetNumberOfNyquistTimesteps() const =0;
+
+ //! Returns the number of lines as needed for post-processing etc.
+ virtual unsigned int GetNumberOfLines(int ny, bool full=false) const =0;
+
+ //! Get the name for the given direction: 0 -> x, 1 -> y, 2 -> z
+ virtual std::string GetDirName(int ny) const;
+
+ //! Get the grid drawing unit in m
+ virtual double GetGridDelta() const =0;
+
+ //! Get the disc line in \a n direction (in drawing units)
+ virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const =0;
+
+ //! Get the disc line delta in \a n direction (in drawing units)
+ virtual double GetDiscDelta(int n, unsigned int pos, bool dualMesh=false) const =0;
+
+ //! Get the node width for a given direction \a n and a given mesh position \a pos
+ virtual double GetNodeWidth(int ny, const unsigned int pos[3], bool dualMesh = false) const =0;
+
+ //! Get the node area for a given direction \a n and a given mesh position \a pos
+ virtual double GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const =0;
+
+ //! Get the length of an FDTD edge (unit is meter).
+ virtual double GetEdgeLength(int ny, const unsigned int pos[3], bool dualMesh = false) const =0;
+
+ //! Get the area around an edge for a given direction \a n and a given mesh posisition \a pos
+ /*!
+ This will return the area around an edge with a given direction, measured at the middle of the edge.
+ In a cartesian mesh this is equal to the NodeArea, may be different in other coordinate systems.
+ */
+ virtual double GetEdgeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const =0;
+
+ //! Get the volume of an FDTD cell
+ virtual double GetCellVolume(const unsigned int pos[3], bool dualMesh = false) const =0;
+
+ //! Snap the given coodinates to mesh indices, return box dimension
+ virtual bool SnapToMesh(const double* coord, unsigned int* uicoord, bool dualMesh=false, bool fullMesh=false, bool* inside=NULL) const =0;
+
+ //! Snap a given box to the operator mesh, uiStart will be always <= uiStop
+ /*!
+ \param[in] start the box-start coorindate
+ \param[in] stop the box-stopt coorindate
+ \param[out] uiStart the snapped box-start coorindate index
+ \param[out] uiStop the snapped box-stop coorindate index
+ \param[in] dualMesh snap to main or dual mesh (default is main mesh)
+ \param[in] SnapMethod Snapping method, 0=snap to closest line, 1/(2)=snap such that given box is inside (outside) the snapped lines
+ \return returns the box dimension or -1 if box is not inside the simulation domain
+ */
+ virtual int SnapBox2Mesh(const double* start, const double* stop, unsigned int* uiStart, unsigned int* uiStop, bool dualMesh=false, bool fullMesh=false, int SnapMethod=0, bool* bStartIn=NULL, bool* bStopIn=NULL) const =0;
+
+ //! Set the boundary conditions
+ virtual void SetBoundaryCondition(int* BCs) {for (int n=0; n<6; ++n) m_BC[n]=BCs[n];}
+
+ //! Set flags to store material data for post-processing
+ virtual void SetMaterialStoreFlags(int type, bool val);
+
+ //! Check storage flags and cleanup
+ virtual void CleanupMaterialStorage() = 0;
+
+ //! Get stored discrete material (if storage is enabled).
+ virtual double GetDiscMaterial(int type, int ny, const unsigned int pos[3]) const = 0;
+
+ //! Get the cell center coordinate usable for material averaging (Warning, may not be the yee cell center)
+ bool GetCellCenterMaterialAvgCoord(const unsigned int pos[3], double coord[3]) const;
+
+ //! Get the cell center coordinate usable for material averaging (Warning, may not be the yee cell center)
+ virtual bool GetCellCenterMaterialAvgCoord(const int pos[3], double coord[3]) const = 0;
+
+ virtual std::vector<CSPrimitives*> GetPrimitivesBoundBox(int posX, int posY, int posZ, CSProperties::PropertyType type=CSProperties::ANY) const = 0;
+
+ //! Set the background material (default is vacuum)
+ virtual void SetBackgroundMaterial(double epsR=0, double mueR=0, double kappa=0, double sigma=0, double density=0);
+
+ //! Get background rel. electric permittivity
+ double GetBackgroundEpsR() const {return m_BG_epsR;}
+ //! Set background rel. electric permittivity
+ void SetBackgroundEpsR(double val);
+
+ //! Get background rel. magnetic permeability
+ double GetBackgroundMueR() const {return m_BG_mueR;}
+ //! Set background rel. magnetic permeability
+ void SetBackgroundMueR(double val);
+
+ //! Get background electric conductivity
+ double GetBackgroundKappa() const {return m_BG_kappa;}
+ //! Set background electric conductivity
+ void SetBackgroundKappa(double val);
+
+ //! Get background magnetic conductivity (artificial)
+ double GetBackgroundSigma() const {return m_BG_sigma;}
+ //! Set background magnetic conductivity (artificial)
+ void SetBackgroundSigma(double val);
+
+ //! Get background mass density
+ double GetBackgroundDensity() const {return m_BG_density;}
+ //! Set background mass density
+ void SetBackgroundDensity(double val);
+
+protected:
+ Operator_Base();
+
+ ContinuousStructure* CSX;
+
+ virtual void Init();
+ //! Cleanup data and reset
+ void Delete();
+ virtual void Reset();
+
+ //! boundary conditions
+ int m_BC[6];
+
+ //! The operator timestep
+ double dT;
+
+ //! bool flag array to store material data for post-processing
+ bool m_StoreMaterial[4];
+
+ //! background materials
+ double m_BG_epsR;
+ double m_BG_mueR;
+ double m_BG_kappa;
+ double m_BG_sigma;
+ double m_BG_density;
+
+ CoordinateSystem m_MeshType;
+ unsigned int numLines[3];
+ double* discLines[3];
+ double gridDelta;
+};
+
+#endif // OPERATOR_BASE_H
diff --git a/openEMS/Common/processcurrent.cpp b/openEMS/Common/processcurrent.cpp
new file mode 100644
index 0000000..8c35bf0
--- /dev/null
+++ b/openEMS/Common/processcurrent.cpp
@@ -0,0 +1,168 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "tools/global.h"
+#include "processcurrent.h"
+#include "FDTD/engine_interface_fdtd.h"
+#include <iomanip>
+
+ProcessCurrent::ProcessCurrent(Engine_Interface_Base* eng_if) : ProcessIntegral(eng_if)
+{
+ m_SnapMethod=1;
+}
+
+ProcessCurrent::~ProcessCurrent()
+{
+}
+
+string ProcessCurrent::GetIntegralName(int row) const
+{
+ if (row==0)
+ return "current";
+ return "unknown";
+}
+
+void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop)
+{
+ ProcessIntegral::DefineStartStopCoord(dstart, dstop);
+
+ if ((m_normDir<0) || (m_normDir>2))
+ {
+ if (m_Dimension!=2)
+ {
+ cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << m_Dimension << ") nor has it set a valid normal direction! --> disabled" << endl;
+ SetEnable(false);
+ return;
+ }
+
+ for (int n=0; n<3; ++n)
+ {
+ if (stop[n] == start[n])
+ m_normDir = n;
+ }
+ }
+ else
+ {
+ //expand dimension to 2 if possible
+ m_Dimension = 0;
+ for (int n=0; n<3; ++n)
+ {
+ if (n==m_normDir)
+ continue;
+ if (dstart[n]==dstop[n])
+ {
+ if ((Op->GetDiscLine( n, start[n], true ) > dstart[n]) && (start[n]>0))
+ --start[n];
+ if ((Op->GetDiscLine( n, start[n], true ) < dstart[n]) && (stop[n]<Op->GetNumberOfLines(n)-1))
+ ++stop[n];
+ }
+ if (stop[n] > start[n])
+ ++m_Dimension;
+ }
+ }
+
+ if (start[m_normDir]!=stop[m_normDir])
+ {
+ cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" has an expansion in normal direction! --> disabled" << endl;
+ SetEnable(false);
+ return;
+ }
+
+ if ((m_normDir<0) || (m_normDir>2))
+ {
+ cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" has an invalid normal direction --> disabled" << endl;
+ SetEnable(false);
+ return;
+ }
+}
+
+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:
+ //y-current
+ if (m_stop_inside[0] && m_start_inside[2])
+ for (unsigned int i=start[1]+1; i<=stop[1]; ++i)
+ current+=Eng->GetCurr(1,stop[0],i,start[2]);
+ //z-current
+ if (m_stop_inside[0] && m_stop_inside[1])
+ for (unsigned int i=start[2]+1; i<=stop[2]; ++i)
+ current+=Eng->GetCurr(2,stop[0],stop[1],i);
+ //y-current
+ if (m_start_inside[0] && m_stop_inside[2])
+ for (unsigned int i=start[1]+1; i<=stop[1]; ++i)
+ current-=Eng->GetCurr(1,start[0],i,stop[2]);
+ //z-current
+ if (m_start_inside[0] && m_start_inside[1])
+ for (unsigned int i=start[2]+1; i<=stop[2]; ++i)
+ current-=Eng->GetCurr(2,start[0],start[1],i);
+ break;
+ case 1:
+ //z-current
+ if (m_start_inside[0] && m_start_inside[1])
+ for (unsigned int i=start[2]+1; i<=stop[2]; ++i)
+ current+=Eng->GetCurr(2,start[0],start[1],i);
+ //x-current
+ if (m_stop_inside[1] && m_stop_inside[2])
+ for (unsigned int i=start[0]+1; i<=stop[0]; ++i)
+ current+=Eng->GetCurr(0,i,stop[1],stop[2]);
+ //z-current
+ if (m_stop_inside[0] && m_stop_inside[1])
+ for (unsigned int i=start[2]+1; i<=stop[2]; ++i)
+ current-=Eng->GetCurr(2,stop[0],stop[1],i);
+ //x-current
+ if (m_start_inside[1] && m_start_inside[2])
+ for (unsigned int i=start[0]+1; i<=stop[0]; ++i)
+ current-=Eng->GetCurr(0,i,start[1],start[2]);
+ break;
+ case 2:
+ //x-current
+ if (m_start_inside[1] && m_start_inside[2])
+ for (unsigned int i=start[0]+1; i<=stop[0]; ++i)
+ current+=Eng->GetCurr(0,i,start[1],start[2]);
+ //y-current
+ if (m_stop_inside[0] && m_start_inside[2])
+ for (unsigned int i=start[1]+1; i<=stop[1]; ++i)
+ current+=Eng->GetCurr(1,stop[0],i,start[2]);
+ //x-current
+ if (m_stop_inside[1] && m_stop_inside[2])
+ for (unsigned int i=start[0]+1; i<=stop[0]; ++i)
+ current-=Eng->GetCurr(0,i,stop[1],stop[2]);
+ //y-current
+ if (m_start_inside[0] && m_stop_inside[2])
+ for (unsigned int i=start[1]+1; i<=stop[1]; ++i)
+ current-=Eng->GetCurr(1,start[0],i,stop[2]);
+ break;
+ default:
+ //this cannot happen...
+ return 0.0;
+ break;
+ }
+ }
+
+ return current;
+}
diff --git a/openEMS/Common/processcurrent.h b/openEMS/Common/processcurrent.h
new file mode 100644
index 0000000..5152b92
--- /dev/null
+++ b/openEMS/Common/processcurrent.h
@@ -0,0 +1,41 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 PROCESSCURRENT_H
+#define PROCESSCURRENT_H
+
+#include "processintegral.h"
+
+class ProcessCurrent : public ProcessIntegral
+{
+public:
+ ProcessCurrent(Engine_Interface_Base* eng_if);
+ virtual ~ProcessCurrent();
+
+ virtual std::string GetProcessingName() const {return "current integration";}
+
+ virtual std::string GetIntegralName(int row) const;
+
+ virtual void DefineStartStopCoord(double* dstart, double* dstop);
+
+ //! Integrate currents flowing through an area
+ virtual double CalcIntegral();
+
+protected:
+};
+
+#endif // PROCESSCURRENT_H
diff --git a/openEMS/Common/processfieldprobe.cpp b/openEMS/Common/processfieldprobe.cpp
new file mode 100644
index 0000000..c456a22
--- /dev/null
+++ b/openEMS/Common/processfieldprobe.cpp
@@ -0,0 +1,92 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 "processfieldprobe.h"
+
+using namespace std;
+
+ProcessFieldProbe::ProcessFieldProbe(Engine_Interface_Base* eng_if, int type) : ProcessIntegral(eng_if)
+{
+ SetFieldType(type);
+}
+
+ProcessFieldProbe::~ProcessFieldProbe()
+{
+
+}
+
+string ProcessFieldProbe::GetProcessingName() const
+{
+ if (m_ModeFieldType==0)
+ return "electric field probe";
+ if (m_ModeFieldType==1)
+ return "magnetic field probe";
+ return "unknown field probe";
+}
+
+string ProcessFieldProbe::GetIntegralName(int row) const
+{
+ if (row==0)
+ {
+ if (m_ModeFieldType==0)
+ return "Ex/(V/m)";
+ if (m_ModeFieldType==1)
+ return "Hx/(A/m)";
+ }
+ if (row==1)
+ {
+ if (m_ModeFieldType==0)
+ return "Ey/(V/m)";
+ if (m_ModeFieldType==1)
+ return "Hy/(A/m)";
+ }
+ if (row==2)
+ {
+ if (m_ModeFieldType==0)
+ return "Ez/(V/m)";
+ if (m_ModeFieldType==1)
+ return "Hz/(A/m)";
+ }
+ return "unknown";
+}
+
+void ProcessFieldProbe::SetFieldType(int type)
+{
+ if ((type<0) || (type>1))
+ {
+ cerr << "ProcessFieldProbe::SetFieldType: Error: unknown field type... skipping" << endl;
+ Enabled=false;
+ }
+ m_ModeFieldType = type;
+}
+
+double* ProcessFieldProbe::CalcMultipleIntegrals()
+{
+ m_Eng_Interface->SetInterpolationType(Engine_Interface_Base::NO_INTERPOLATION);
+
+ switch (m_ModeFieldType)
+ {
+ case 0:
+ default:
+ m_Eng_Interface->GetEField(start,m_Results);
+ break;
+ case 1:
+ m_Eng_Interface->GetHField(start,m_Results);
+ break;
+ }
+ return m_Results;
+}
diff --git a/openEMS/Common/processfieldprobe.h b/openEMS/Common/processfieldprobe.h
new file mode 100644
index 0000000..342eba4
--- /dev/null
+++ b/openEMS/Common/processfieldprobe.h
@@ -0,0 +1,43 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 PROCESSFIELDPROBE_H
+#define PROCESSFIELDPROBE_H
+
+#include "processintegral.h"
+
+class ProcessFieldProbe : public ProcessIntegral
+{
+public:
+ ProcessFieldProbe(Engine_Interface_Base* eng_if, int type=0);
+ virtual ~ProcessFieldProbe();
+
+ virtual std::string GetProcessingName() const;
+
+ virtual std::string GetIntegralName(int row) const;
+
+ //! Set the field type (0 electric field, 1 magnetic field)
+ void SetFieldType(int type);
+
+ virtual int GetNumberOfIntegrals() const {return 3;}
+ virtual double* CalcMultipleIntegrals();
+
+protected:
+ int m_ModeFieldType;
+};
+
+#endif // PROCESSFIELDPROBE_H
diff --git a/openEMS/Common/processfields.cpp b/openEMS/Common/processfields.cpp
new file mode 100644
index 0000000..f52fc14
--- /dev/null
+++ b/openEMS/Common/processfields.cpp
@@ -0,0 +1,341 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 <iomanip>
+#include "tools/global.h"
+#include "tools/vtk_file_writer.h"
+#include "tools/hdf5_file_writer.h"
+#include "processfields.h"
+#include "FDTD/engine_interface_fdtd.h"
+
+ProcessFields::ProcessFields(Engine_Interface_Base* eng_if) : Processing(eng_if)
+{
+ m_DumpType = E_FIELD_DUMP;
+ // vtk-file is default
+ m_fileType = VTK_FILETYPE;
+ m_SampleType = NONE;
+ m_Vtk_Dump_File = NULL;
+ m_HDF5_Dump_File = NULL;
+ SetPrecision(6);
+ m_dualTime = false;
+
+ // dump box should be always inside the snapped lines
+ m_SnapMethod = 1;
+
+ for (int n=0; n<3; ++n)
+ {
+ numLines[n]=0;
+ posLines[n]=NULL;
+ discLines[n]=NULL;
+ subSample[n]=1;
+ optResolution[n]=0;
+ }
+}
+
+ProcessFields::~ProcessFields()
+{
+ delete m_Vtk_Dump_File;
+ m_Vtk_Dump_File = NULL;
+ for (int n=0; n<3; ++n)
+ {
+ delete[] posLines[n];
+ posLines[n]=NULL;
+ delete[] discLines[n];
+ discLines[n]=NULL;
+ }
+}
+
+string ProcessFields::GetFieldNameByType(DumpType type)
+{
+ switch (type)
+ {
+ case E_FIELD_DUMP:
+ return "E-Field";
+ case H_FIELD_DUMP:
+ return "H-Field";
+ case J_FIELD_DUMP:
+ return "J-Field";
+ case ROTH_FIELD_DUMP:
+ return "RotH-Field";
+ case SAR_LOCAL_DUMP:
+ return "SAR-local";
+ case SAR_1G_DUMP:
+ return "SAR_1g";
+ case SAR_10G_DUMP:
+ return "SAR_10g";
+ case SAR_RAW_DATA:
+ return "SAR_raw_data";
+ }
+ return "unknown field";
+}
+
+bool ProcessFields::NeedConductivity() const
+{
+ switch (m_DumpType)
+ {
+ case J_FIELD_DUMP:
+ return true;
+ default:
+ return false;
+ }
+ return false;
+}
+
+void ProcessFields::InitProcess()
+{
+ if (Enabled==false) return;
+
+ CalcMeshPos();
+
+ if (m_fileType==VTK_FILETYPE)
+ {
+ delete m_Vtk_Dump_File;
+ m_Vtk_Dump_File = new VTK_File_Writer(m_filename,(int)m_Mesh_Type);
+
+ #ifdef OUTPUT_IN_DRAWINGUNITS
+ double discScaling = 1;
+ #else
+ double discScaling = Op->GetGridDelta();
+ #endif
+ m_Vtk_Dump_File->SetMeshLines(discLines,numLines,discScaling);
+ m_Vtk_Dump_File->SetNativeDump(g_settings.NativeFieldDumps());
+ }
+ if (m_fileType==HDF5_FILETYPE)
+ {
+ delete m_HDF5_Dump_File;
+ m_HDF5_Dump_File = new HDF5_File_Writer(m_filename+".h5");
+
+ #ifdef OUTPUT_IN_DRAWINGUNITS
+ double discScaling = 1;
+ #else
+ double discScaling = Op->GetGridDelta();
+ #endif
+ m_HDF5_Dump_File->WriteRectMesh(numLines,discLines,(int)m_Mesh_Type,discScaling);
+
+ m_HDF5_Dump_File->WriteAtrribute("/","openEMS_HDF5_version",0.2);
+ }
+}
+
+void ProcessFields::SetDumpMode(Engine_Interface_Base::InterpolationType mode)
+{
+ m_Eng_Interface->SetInterpolationType(mode);
+ if (mode==Engine_Interface_Base::CELL_INTERPOLATE)
+ m_dualMesh=true;
+ else if (mode==Engine_Interface_Base::NODE_INTERPOLATE)
+ m_dualMesh=false;
+ //else keep the preset/user defined case
+}
+
+void ProcessFields::DefineStartStopCoord(double* dstart, double* dstop)
+{
+ Processing::DefineStartStopCoord(dstart,dstop);
+
+ // normalize order of start and stop
+ for (int n=0; n<3; ++n)
+ {
+ if (start[n]>stop[n])
+ {
+ unsigned int help = start[n];
+ start[n]=stop[n];
+ stop[n]=help;
+ }
+ }
+}
+
+double ProcessFields::CalcTotalEnergyEstimate() const
+{
+ return m_Eng_Interface->CalcFastEnergy();
+}
+
+void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir)
+{
+ if (dir>2) return;
+ if (dir<0)
+ {
+ subSample[0]=subSampleRate;
+ subSample[1]=subSampleRate;
+ subSample[2]=subSampleRate;
+ }
+ else subSample[dir]=subSampleRate;
+ m_SampleType = SUBSAMPLE;
+}
+
+void ProcessFields::SetOptResolution(double optRes, int dir)
+{
+ if (dir>2) return;
+ if (dir<0)
+ {
+ optResolution[0]=optRes;
+ optResolution[1]=optRes;
+ optResolution[2]=optRes;
+ }
+ else optResolution[dir]=optRes;
+ m_SampleType = OPT_RESOLUTION;
+}
+
+void ProcessFields::CalcMeshPos()
+{
+ if ((m_SampleType==SUBSAMPLE) || (m_SampleType==NONE))
+ {
+ vector<unsigned int> tmp_pos;
+
+ for (int n=0; n<3; ++n)
+ {
+ // construct new discLines
+ tmp_pos.clear();
+ for (unsigned int i=start[n]; i<=stop[n]; i+=subSample[n])
+ tmp_pos.push_back(i);
+
+ numLines[n] = tmp_pos.size();
+ delete[] discLines[n];
+ discLines[n] = new double[numLines[n]];
+ delete[] posLines[n];
+ posLines[n] = new unsigned int[numLines[n]];
+ for (unsigned int i=0; i<numLines[n]; ++i)
+ {
+ posLines[n][i] = tmp_pos.at(i);
+ discLines[n][i] = Op->GetDiscLine(n,tmp_pos.at(i),m_dualMesh);
+ }
+ }
+ }
+ if ((m_SampleType==OPT_RESOLUTION))
+ {
+ vector<unsigned int> tmp_pos;
+ double oldPos=0;
+ for (int n=0; n<3; ++n)
+ {
+ // construct new discLines
+ tmp_pos.clear();
+ tmp_pos.push_back(start[n]);
+ oldPos=Op->GetDiscLine(n,start[n],m_dualMesh);
+ if (stop[n]==0)
+ tmp_pos.push_back(stop[n]);
+ else
+ for (unsigned int i=start[n]+1; i<=stop[n]-1; ++i)
+ {
+ if ( (Op->GetDiscLine(n,i+1,m_dualMesh)-oldPos) >= optResolution[n])
+ {
+ tmp_pos.push_back(i);
+ oldPos=Op->GetDiscLine(n,i,m_dualMesh);
+ }
+ }
+ if (start[n]!=stop[n])
+ tmp_pos.push_back(stop[n]);
+ numLines[n] = tmp_pos.size();
+ delete[] discLines[n];
+ discLines[n] = new double[numLines[n]];
+ delete[] posLines[n];
+ posLines[n] = new unsigned int[numLines[n]];
+ for (unsigned int i=0; i<numLines[n]; ++i)
+ {
+ posLines[n][i] = tmp_pos.at(i);
+ discLines[n][i] = Op->GetDiscLine(n,tmp_pos.at(i),m_dualMesh);
+ }
+ }
+ }
+}
+
+FDTD_FLOAT**** ProcessFields::CalcField()
+{
+ unsigned int pos[3];
+ double out[3];
+ //create array
+ FDTD_FLOAT**** field = Create_N_3DArray<FDTD_FLOAT>(numLines);
+ switch (m_DumpType)
+ {
+ case E_FIELD_DUMP:
+ for (unsigned int i=0; i<numLines[0]; ++i)
+ {
+ pos[0]=posLines[0][i];
+ for (unsigned int j=0; j<numLines[1]; ++j)
+ {
+ pos[1]=posLines[1][j];
+ for (unsigned int k=0; k<numLines[2]; ++k)
+ {
+ pos[2]=posLines[2][k];
+
+ m_Eng_Interface->GetEField(pos,out);
+ field[0][i][j][k] = out[0];
+ field[1][i][j][k] = out[1];
+ field[2][i][j][k] = out[2];
+ }
+ }
+ }
+ return field;
+ case H_FIELD_DUMP:
+ for (unsigned int i=0; i<numLines[0]; ++i)
+ {
+ pos[0]=posLines[0][i];
+ for (unsigned int j=0; j<numLines[1]; ++j)
+ {
+ pos[1]=posLines[1][j];
+ for (unsigned int k=0; k<numLines[2]; ++k)
+ {
+ pos[2]=posLines[2][k];
+
+ m_Eng_Interface->GetHField(pos,out);
+ field[0][i][j][k] = out[0];
+ field[1][i][j][k] = out[1];
+ field[2][i][j][k] = out[2];
+ }
+ }
+ }
+ return field;
+ case J_FIELD_DUMP:
+ for (unsigned int i=0; i<numLines[0]; ++i)
+ {
+ pos[0]=posLines[0][i];
+ for (unsigned int j=0; j<numLines[1]; ++j)
+ {
+ pos[1]=posLines[1][j];
+ for (unsigned int k=0; k<numLines[2]; ++k)
+ {
+ pos[2]=posLines[2][k];
+
+ m_Eng_Interface->GetJField(pos,out);
+ field[0][i][j][k] = out[0];
+ field[1][i][j][k] = out[1];
+ field[2][i][j][k] = out[2];
+ }
+ }
+ }
+ return field;
+ case ROTH_FIELD_DUMP:
+ for (unsigned int i=0; i<numLines[0]; ++i)
+ {
+ pos[0]=posLines[0][i];
+ for (unsigned int j=0; j<numLines[1]; ++j)
+ {
+ pos[1]=posLines[1][j];
+ for (unsigned int k=0; k<numLines[2]; ++k)
+ {
+ pos[2]=posLines[2][k];
+
+ m_Eng_Interface->GetRotHField(pos,out);
+ field[0][i][j][k] = out[0];
+ field[1][i][j][k] = out[1];
+ field[2][i][j][k] = out[2];
+ }
+ }
+ }
+ return field;
+ default:
+ cerr << "ProcessFields::CalcField(): Error, unknown dump type..." << endl;
+ return field;
+ }
+}
+
diff --git a/openEMS/Common/processfields.h b/openEMS/Common/processfields.h
new file mode 100644
index 0000000..3d4085b
--- /dev/null
+++ b/openEMS/Common/processfields.h
@@ -0,0 +1,104 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 PROCESSFIELDS_H
+#define PROCESSFIELDS_H
+
+#include "processing.h"
+#include "tools/array_ops.h"
+
+#define __VTK_DATA_TYPE__ "double"
+
+class VTK_File_Writer;
+class HDF5_File_Writer;
+
+class ProcessFields : public Processing
+{
+public:
+ ProcessFields(Engine_Interface_Base* eng_if);
+ virtual ~ProcessFields();
+
+ //! File type definition.
+ enum FileType { VTK_FILETYPE, HDF5_FILETYPE};
+
+ //! Dump type definitions.
+ /*!
+ Current dump types are electric field (E_FIELD_DUMP), magnetic field (H_FIELD_DUMP),
+ (conduction) electric current density (kappa*E) (J_FIELD_DUMP) and total current density (rotH)
+ */
+ enum DumpType { E_FIELD_DUMP=0, H_FIELD_DUMP=1, J_FIELD_DUMP=2, ROTH_FIELD_DUMP=3, SAR_LOCAL_DUMP=20, SAR_1G_DUMP=21, SAR_10G_DUMP=22, SAR_RAW_DATA=29};
+
+ virtual std::string GetProcessingName() const {return "common field processing";}
+
+ virtual void InitProcess();
+
+ virtual void DefineStartStopCoord(double* dstart, double* dstop);
+
+ //! Define a field dump sub sampling rate for a given direction (default: \a dir = -1 means all directions)
+ virtual void SetSubSampling(unsigned int subSampleRate, int dir=-1);
+
+ //! Define a field dump optimal resolution for a given direction (default: \a dir = -1 means all directions)
+ virtual void SetOptResolution(double optRes, int dir=-1);
+
+ //! Set the filename for a hdf5 data group file (HDF5 FileType only) \sa SetFileType()
+ void SetFileName(std::string fn) {m_filename=fn;}
+ std::string SetFileName() const {return m_filename;}
+
+ //! Define the Dump-Mode
+ void SetDumpMode(Engine_Interface_Base::InterpolationType mode);
+ //! This methode will dump all fields on a main cell node using 2 E-field and 4 H-fields per direction.
+ void SetDumpMode2Node() {SetDumpMode(Engine_Interface_Base::NODE_INTERPOLATE);}
+ //! This methode will dump all fields in the center of a main cell (dual-node) using 4 E-field and 2 H-fields per direction.
+ void SetDumpMode2Cell() {SetDumpMode(Engine_Interface_Base::CELL_INTERPOLATE);}
+
+ //! Set dump type: 0 for E-fields, 1 for H-fields, 2 for D-fields, 3 for B-fields, 4 for J-fields, etc...
+ virtual void SetDumpType(DumpType type) {m_DumpType=type;}
+
+ double CalcTotalEnergyEstimate() const;
+
+ void SetFileType(FileType fileType) {m_fileType=fileType;}
+
+ static std::string GetFieldNameByType(DumpType type);
+
+ virtual bool NeedConductivity() const;
+
+protected:
+ DumpType m_DumpType;
+ FileType m_fileType;
+
+ VTK_File_Writer* m_Vtk_Dump_File;
+ HDF5_File_Writer* m_HDF5_Dump_File;
+
+ enum SampleType {NONE, SUBSAMPLE, OPT_RESOLUTION} m_SampleType;
+ virtual void CalcMeshPos();
+
+ //! field dump sub-sampling (if enabled)
+ unsigned int subSample[3];
+
+ //! field dump optimal resolution (if enabled)
+ double optResolution[3];
+
+ //! dump mesh information
+ unsigned int numLines[3]; //number of lines to dump
+ unsigned int* posLines[3]; //grid positions to dump
+ double* discLines[3]; //mesh disc lines to dump
+
+ //! Calculate and return the defined field. Caller has to cleanup the array.
+ FDTD_FLOAT**** CalcField();
+};
+
+#endif // PROCESSFIELDS_H
diff --git a/openEMS/Common/processfields_fd.cpp b/openEMS/Common/processfields_fd.cpp
new file mode 100644
index 0000000..ca59b2b
--- /dev/null
+++ b/openEMS/Common/processfields_fd.cpp
@@ -0,0 +1,225 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "processfields_fd.h"
+#include "Common/operator_base.h"
+#include "tools/vtk_file_writer.h"
+#include "tools/hdf5_file_writer.h"
+#include <iomanip>
+#include <sstream>
+#include <string>
+
+using namespace std;
+
+ProcessFieldsFD::ProcessFieldsFD(Engine_Interface_Base* eng_if) : ProcessFields(eng_if)
+{
+}
+
+ProcessFieldsFD::~ProcessFieldsFD()
+{
+ for (size_t n = 0; n<m_FD_Fields.size(); ++n)
+ {
+ Delete_N_3DArray(m_FD_Fields.at(n),numLines);
+ }
+ m_FD_Fields.clear();
+}
+
+void ProcessFieldsFD::InitProcess()
+{
+ if (Enabled==false) return;
+
+ if (m_FD_Samples.size()==0)
+ {
+ cerr << "ProcessFieldsFD::InitProcess: No frequencies found... skipping this dump!" << endl;
+ Enabled=false;
+ return;
+ }
+
+ //setup the hdf5 file
+ ProcessFields::InitProcess();
+
+ if (m_Vtk_Dump_File)
+ m_Vtk_Dump_File->SetHeader(string("openEMS FD Field Dump -- Interpolation: ")+m_Eng_Interface->GetInterpolationTypeString());
+
+ if (m_HDF5_Dump_File)
+ {
+ m_HDF5_Dump_File->SetCurrentGroup("/FieldData/FD");
+ m_HDF5_Dump_File->WriteAtrribute("/FieldData/FD","frequency",m_FD_Samples);
+ }
+
+ //create data structures...
+ for (size_t n = 0; n<m_FD_Samples.size(); ++n)
+ {
+ std::complex<float>**** field_fd = Create_N_3DArray<std::complex<float> >(numLines);
+ m_FD_Fields.push_back(field_fd);
+ }
+}
+
+int ProcessFieldsFD::Process()
+{
+ if (Enabled==false) return -1;
+ if (CheckTimestep()==false) return GetNextInterval();
+
+ if ((m_FD_Interval==0) || (m_Eng_Interface->GetNumberOfTimesteps()%m_FD_Interval!=0))
+ return GetNextInterval();
+
+ FDTD_FLOAT**** field_td = CalcField();
+ std::complex<float>**** field_fd = NULL;
+
+ double T = m_Eng_Interface->GetTime(m_dualTime);
+ unsigned int pos[3];
+ for (size_t n = 0; n<m_FD_Samples.size(); ++n)
+ {
+ std::complex<float> exp_jwt_2_dt = std::exp( (std::complex<float>)(-2.0 * _I * M_PI * m_FD_Samples.at(n) * T) );
+ exp_jwt_2_dt *= 2; // *2 for single-sided spectrum
+ exp_jwt_2_dt *= Op->GetTimestep() * m_FD_Interval; // multiply with timestep-interval
+ field_fd = m_FD_Fields.at(n);
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ field_fd[0][pos[0]][pos[1]][pos[2]] += field_td[0][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt;
+ field_fd[1][pos[0]][pos[1]][pos[2]] += field_td[1][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt;
+ field_fd[2][pos[0]][pos[1]][pos[2]] += field_td[2][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt;
+ }
+ }
+ }
+ }
+ Delete_N_3DArray<FDTD_FLOAT>(field_td,numLines);
+ ++m_FD_SampleCount;
+ return GetNextInterval();
+}
+
+void ProcessFieldsFD::PostProcess()
+{
+ DumpFDData();
+}
+
+void ProcessFieldsFD::DumpFDData()
+{
+ if (m_fileType==VTK_FILETYPE)
+ {
+ unsigned int pos[3];
+ FDTD_FLOAT**** field = Create_N_3DArray<float>(numLines);
+ std::complex<float>**** field_fd = NULL;
+ double angle=0;
+ int Nr_Ph = 21;
+
+ for (size_t n = 0; n<m_FD_Samples.size(); ++n)
+ {
+ //dump multiple phase to vtk-files
+ for (int p=0; p<Nr_Ph; ++p)
+ {
+ angle = 2.0 * M_PI * p / Nr_Ph;
+ std::complex<float> exp_jwt = std::exp( (std::complex<float>)( _I * angle) );
+ field_fd = m_FD_Fields.at(n);
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ field[0][pos[0]][pos[1]][pos[2]] = real(field_fd[0][pos[0]][pos[1]][pos[2]] * exp_jwt);
+ field[1][pos[0]][pos[1]][pos[2]] = real(field_fd[1][pos[0]][pos[1]][pos[2]] * exp_jwt);
+ field[2][pos[0]][pos[1]][pos[2]] = real(field_fd[2][pos[0]][pos[1]][pos[2]] * exp_jwt);
+ }
+ }
+ }
+ stringstream ss;
+ ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n) << "_p=" << std::setw( 3 ) << std::setfill( '0' ) <<(int)(angle * 180 / M_PI);
+
+ m_Vtk_Dump_File->SetFilename(ss.str());
+ m_Vtk_Dump_File->ClearAllFields();
+ m_Vtk_Dump_File->AddVectorField(GetFieldNameByType(m_DumpType),field);
+ if (m_Vtk_Dump_File->Write()==false)
+ cerr << "ProcessFieldsFD::Process: can't dump to file... abort! " << endl;
+ }
+
+ {
+ //dump magnitude to vtk-files
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ field[0][pos[0]][pos[1]][pos[2]] = abs(field_fd[0][pos[0]][pos[1]][pos[2]]);
+ field[1][pos[0]][pos[1]][pos[2]] = abs(field_fd[1][pos[0]][pos[1]][pos[2]]);
+ field[2][pos[0]][pos[1]][pos[2]] = abs(field_fd[2][pos[0]][pos[1]][pos[2]]);
+ }
+ }
+ }
+ stringstream ss;
+ ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n) << "_abs";
+ m_Vtk_Dump_File->SetFilename(ss.str());
+ m_Vtk_Dump_File->ClearAllFields();
+ m_Vtk_Dump_File->AddVectorField(GetFieldNameByType(m_DumpType),field);
+ if (m_Vtk_Dump_File->Write()==false)
+ cerr << "ProcessFieldsFD::Process: can't dump to file... abort! " << endl;
+ }
+
+ {
+ //dump phase to vtk-files
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ field[0][pos[0]][pos[1]][pos[2]] = arg(field_fd[0][pos[0]][pos[1]][pos[2]]);
+ field[1][pos[0]][pos[1]][pos[2]] = arg(field_fd[1][pos[0]][pos[1]][pos[2]]);
+ field[2][pos[0]][pos[1]][pos[2]] = arg(field_fd[2][pos[0]][pos[1]][pos[2]]);
+ }
+ }
+ }
+ stringstream ss;
+ ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n) << "_arg";
+ m_Vtk_Dump_File->SetFilename(ss.str());
+ m_Vtk_Dump_File->ClearAllFields();
+ m_Vtk_Dump_File->AddVectorField(GetFieldNameByType(m_DumpType),field);
+ if (m_Vtk_Dump_File->Write()==false)
+ cerr << "ProcessFieldsFD::Process: can't dump to file... abort! " << endl;
+ }
+ }
+ Delete_N_3DArray(field,numLines);
+ return;
+ }
+
+ if (m_fileType==HDF5_FILETYPE)
+ {
+ for (size_t n = 0; n<m_FD_Samples.size(); ++n)
+ {
+ stringstream ss;
+ ss << "f" << n;
+ size_t datasize[]={numLines[0],numLines[1],numLines[2]};
+ if (m_HDF5_Dump_File->WriteVectorField(ss.str(), m_FD_Fields.at(n), datasize)==false)
+ cerr << "ProcessFieldsFD::Process: can't dump to file...! " << endl;
+
+ //legacy support, use /FieldData/FD frequency-Attribute in the future
+ float freq[1] = {(float)m_FD_Samples.at(n)};
+ if (m_HDF5_Dump_File->WriteAtrribute("/FieldData/FD/"+ss.str()+"_real","frequency",freq,1)==false)
+ cerr << "ProcessFieldsFD::Process: can't dump to file...! " << endl;
+ if (m_HDF5_Dump_File->WriteAtrribute("/FieldData/FD/"+ss.str()+"_imag","frequency",freq,1)==false)
+ cerr << "ProcessFieldsFD::Process: can't dump to file...! " << endl;
+ }
+ return;
+ }
+
+ cerr << "ProcessFieldsFD::Process: unknown File-Type" << endl;
+}
diff --git a/openEMS/Common/processfields_fd.h b/openEMS/Common/processfields_fd.h
new file mode 100644
index 0000000..2049cc3
--- /dev/null
+++ b/openEMS/Common/processfields_fd.h
@@ -0,0 +1,43 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 PROCESSFIELDS_FD_H
+#define PROCESSFIELDS_FD_H
+
+#include "processfields.h"
+
+class ProcessFieldsFD : public ProcessFields
+{
+public:
+ ProcessFieldsFD(Engine_Interface_Base* eng_if);
+ virtual ~ProcessFieldsFD();
+
+ virtual std::string GetProcessingName() const {return "frequency domain field dump";}
+
+ virtual void InitProcess();
+
+ virtual int Process();
+ virtual void PostProcess();
+
+protected:
+ virtual void DumpFDData();
+
+ //! frequency domain field storage
+ std::vector<std::complex<float>****> m_FD_Fields;
+};
+
+#endif // PROCESSFIELDS_FD_H
diff --git a/openEMS/Common/processfields_sar.cpp b/openEMS/Common/processfields_sar.cpp
new file mode 100644
index 0000000..9bbdab2
--- /dev/null
+++ b/openEMS/Common/processfields_sar.cpp
@@ -0,0 +1,335 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 "processfields_sar.h"
+#include "operator_base.h"
+#include "tools/vtk_file_writer.h"
+#include "tools/hdf5_file_writer.h"
+#include "tools/sar_calculation.h"
+
+#include "CSPropMaterial.h"
+
+using namespace std;
+
+ProcessFieldsSAR::ProcessFieldsSAR(Engine_Interface_Base* eng_if) : ProcessFieldsFD(eng_if)
+{
+ m_UseCellKappa = true;
+ m_SAR_method = "Simple";
+}
+
+ProcessFieldsSAR::~ProcessFieldsSAR()
+{
+ for (size_t n = 0; n<m_E_FD_Fields.size(); ++n)
+ Delete_N_3DArray(m_E_FD_Fields.at(n),numLines);
+ m_E_FD_Fields.clear();
+
+ for (size_t n = 0; n<m_J_FD_Fields.size(); ++n)
+ Delete_N_3DArray(m_J_FD_Fields.at(n),numLines);
+ m_J_FD_Fields.clear();
+}
+
+void ProcessFieldsSAR::SetDumpType(DumpType type)
+{
+ if (type==SAR_RAW_DATA)
+ m_UseCellKappa = true;
+ ProcessFieldsFD::SetDumpType(type);
+}
+
+bool ProcessFieldsSAR::NeedConductivity() const
+{
+ return !m_UseCellKappa;
+}
+
+void ProcessFieldsSAR::SetSubSampling(unsigned int subSampleRate, int dir)
+{
+ UNUSED(subSampleRate);UNUSED(dir);
+ cerr << "ProcessFieldsSAR::SetSubSampling: Warning: Defining a sub-sampling for SAR calculation is not allowed!!! Skipped!" << endl;
+}
+
+void ProcessFieldsSAR::SetOptResolution(double optRes, int dir)
+{
+ UNUSED(optRes);UNUSED(dir);
+ cerr << "ProcessFieldsSAR::SetOptResolution: Warning: Defining a sub-sampling for SAR calculation is not allowed!!! Skipped!" << endl;
+}
+
+void ProcessFieldsSAR::InitProcess()
+{
+ if ((m_DumpType!=SAR_LOCAL_DUMP) && (m_DumpType!=SAR_1G_DUMP) && (m_DumpType!=SAR_10G_DUMP) && (m_DumpType!=SAR_RAW_DATA))
+ {
+ Enabled=false;
+ cerr << "ProcessFieldsSAR::InitProcess(): Error, wrong dump type... this should not happen... skipping!" << endl;
+ return;
+ }
+ if (m_Eng_Interface->GetInterpolationType()!=Engine_Interface_Base::CELL_INTERPOLATE)
+ {
+ cerr << "ProcessFieldsSAR::InitProcess(): Warning, interpolation type is not supported, resetting to CELL!" << endl;
+ SetDumpMode2Cell();
+ }
+
+ if ((m_DumpType==SAR_RAW_DATA) && (m_fileType!=HDF5_FILETYPE))
+ {
+ Enabled=false;
+ cerr << "ProcessFieldsSAR::InitProcess(): Error, wrong file type for dumping raw SAR data! skipping" << endl;
+ return;
+
+ }
+
+ ProcessFieldsFD::InitProcess();
+
+ if (Enabled==false) return;
+
+ //create data structures...
+ for (size_t n = 0; n<m_FD_Samples.size(); ++n)
+ {
+ m_E_FD_Fields.push_back(Create_N_3DArray<std::complex<float> >(numLines));
+ if (!m_UseCellKappa)
+ m_J_FD_Fields.push_back(Create_N_3DArray<std::complex<float> >(numLines));
+ }
+}
+
+int ProcessFieldsSAR::Process()
+{
+ if (Enabled==false) return -1;
+ if (CheckTimestep()==false) return GetNextInterval();
+
+ if ((m_FD_Interval==0) || (m_Eng_Interface->GetNumberOfTimesteps()%m_FD_Interval!=0))
+ return GetNextInterval();
+
+ std::complex<float>**** field_fd = NULL;
+ unsigned int pos[3];
+ double T;
+ FDTD_FLOAT**** field_td=NULL;
+
+ //save dump type
+ DumpType save_dump_type = m_DumpType;
+
+ // calc E-field
+ m_DumpType = E_FIELD_DUMP;
+ field_td = CalcField();
+ T = m_Eng_Interface->GetTime(m_dualTime);
+ for (size_t n = 0; n<m_FD_Samples.size(); ++n)
+ {
+ std::complex<float> exp_jwt_2_dt = std::exp( (std::complex<float>)(-2.0 * _I * M_PI * m_FD_Samples.at(n) * T) );
+ exp_jwt_2_dt *= 2; // *2 for single-sided spectrum
+ exp_jwt_2_dt *= Op->GetTimestep() * m_FD_Interval; // multiply with timestep-interval
+ field_fd = m_E_FD_Fields.at(n);
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ field_fd[0][pos[0]][pos[1]][pos[2]] += field_td[0][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt;
+ field_fd[1][pos[0]][pos[1]][pos[2]] += field_td[1][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt;
+ field_fd[2][pos[0]][pos[1]][pos[2]] += field_td[2][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt;
+ }
+ }
+ }
+ }
+ Delete_N_3DArray<FDTD_FLOAT>(field_td,numLines);
+
+ // calc J-field
+ if (!m_UseCellKappa)
+ {
+ m_DumpType = J_FIELD_DUMP;
+ field_td = CalcField();
+ T = m_Eng_Interface->GetTime(m_dualTime);
+ for (size_t n = 0; n<m_FD_Samples.size(); ++n)
+ {
+ std::complex<float> exp_jwt_2_dt = std::exp( (std::complex<float>)(-2.0 * _I * M_PI * m_FD_Samples.at(n) * T) );
+ exp_jwt_2_dt *= 2; // *2 for single-sided spectrum
+ exp_jwt_2_dt *= Op->GetTimestep() * m_FD_Interval; // multiply with timestep-interval
+ field_fd = m_J_FD_Fields.at(n);
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ field_fd[0][pos[0]][pos[1]][pos[2]] += field_td[0][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt;
+ field_fd[1][pos[0]][pos[1]][pos[2]] += field_td[1][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt;
+ field_fd[2][pos[0]][pos[1]][pos[2]] += field_td[2][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt;
+ }
+ }
+ }
+ }
+ Delete_N_3DArray<FDTD_FLOAT>(field_td,numLines);
+ }
+
+ //reset dump type
+ m_DumpType = save_dump_type;
+
+ ++m_FD_SampleCount;
+ return GetNextInterval();
+}
+
+void ProcessFieldsSAR::DumpFDData()
+{
+ if (Enabled==false) return;
+ unsigned int pos[3];
+ unsigned int orig_pos[3];
+ float*** SAR = Create3DArray<float>(numLines);
+ double coord[3];
+ ContinuousStructure* CSX = Op->GetGeometryCSX();
+ CSProperties* prop = NULL;
+ CSPropMaterial* matProp = NULL;
+
+ double power;
+
+ float*** cell_volume = Create3DArray<float>(numLines);
+ float*** cell_density = Create3DArray<float>(numLines);
+ float*** cell_kappa = NULL;
+ if (m_UseCellKappa)
+ cell_kappa = Create3DArray<float>(numLines);
+
+ bool found_UnIsotropic=false;
+
+ // calculate volumes and masses for all cells
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ orig_pos[0] = posLines[0][pos[0]];
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ orig_pos[1] = posLines[1][pos[1]];
+ vector<CSPrimitives*> vPrims = Op->GetPrimitivesBoundBox(orig_pos[0], orig_pos[1], -1, CSProperties::MATERIAL);
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ orig_pos[2] = posLines[2][pos[2]];
+
+ cell_volume[pos[0]][pos[1]][pos[2]] = Op->GetCellVolume(orig_pos);
+ cell_density[pos[0]][pos[1]][pos[2]] = 0.0;
+
+ Op->GetCellCenterMaterialAvgCoord(orig_pos, coord);
+ prop = CSX->GetPropertyByCoordPriority(coord, vPrims);
+// prop = CSX->GetPropertyByCoordPriority(coord,CSProperties::MATERIAL);
+ if (prop!=0)
+ {
+ matProp = dynamic_cast<CSPropMaterial*>(prop);
+ if (matProp)
+ {
+ found_UnIsotropic |= !matProp->GetIsotropy();
+ cell_density[pos[0]][pos[1]][pos[2]] = matProp->GetDensityWeighted(coord);
+ if (m_UseCellKappa)
+ cell_kappa[pos[0]][pos[1]][pos[2]] = matProp->GetKappaWeighted(0,coord);
+ }
+ }
+ }
+ }
+ }
+ if (found_UnIsotropic)
+ cerr << "ProcessFieldsSAR::DumpFDData(): Warning, found unisotropic material in SAR calculation... this is unsupported!" << endl;
+
+ float* cellWidth[3];
+ for (int n=0;n<3;++n)
+ {
+ cellWidth[n]=new float[numLines[n]];
+ for (unsigned int i=0;i<numLines[n];++i)
+ cellWidth[n][i]=Op->GetDiscDelta(n,posLines[n][i])*Op->GetGridDelta();
+ }
+
+ if (m_DumpType == SAR_RAW_DATA)
+ {
+ if (m_fileType!=HDF5_FILETYPE)
+ {
+ cerr << "ProcessFieldsSAR::DumpFDData(): Error, wrong file type, this should not happen!!! skipped" << endl;
+ return;
+ }
+
+ size_t datasize[]={numLines[0],numLines[1],numLines[2]};
+ for (size_t n = 0; n<m_FD_Samples.size(); ++n)
+ {
+ stringstream ss;
+ ss << "f" << n;
+ if (m_HDF5_Dump_File->WriteVectorField(ss.str(), m_E_FD_Fields.at(n), datasize)==false)
+ cerr << "ProcessFieldsSAR::DumpFDData: can't dump to file...! " << endl;
+ }
+
+ m_HDF5_Dump_File->SetCurrentGroup("/CellData");
+ if (m_UseCellKappa==false)
+ cerr << "ProcessFieldsSAR::DumpFDData: Error, cell conductivity data not available, this should not happen... skipping! " << endl;
+ else if (m_HDF5_Dump_File->WriteScalarField("Conductivity", cell_kappa, datasize)==false)
+ cerr << "ProcessFieldsSAR::DumpFDData: can't dump to file...! " << endl;
+ if (m_HDF5_Dump_File->WriteScalarField("Density", cell_density, datasize)==false)
+ cerr << "ProcessFieldsSAR::DumpFDData: can't dump to file...! " << endl;
+ if (m_HDF5_Dump_File->WriteScalarField("Volume", cell_volume, datasize)==false)
+ cerr << "ProcessFieldsSAR::DumpFDData: can't dump to file...! " << endl;
+ }
+ else
+ {
+ SAR_Calculation SAR_Calc;
+ SAR_Calc.SetAveragingMethod(m_SAR_method, g_settings.GetVerboseLevel()==0);
+ SAR_Calc.SetDebugLevel(g_settings.GetVerboseLevel());
+ SAR_Calc.SetNumLines(numLines);
+ if (m_DumpType == SAR_LOCAL_DUMP)
+ SAR_Calc.SetAveragingMass(0);
+ else if (m_DumpType == SAR_1G_DUMP)
+ SAR_Calc.SetAveragingMass(1e-3);
+ else if (m_DumpType == SAR_10G_DUMP)
+ SAR_Calc.SetAveragingMass(10e-3);
+ else
+ {
+ cerr << "ProcessFieldsSAR::DumpFDData: unknown SAR dump type...!" << endl;
+ }
+ SAR_Calc.SetCellDensities(cell_density);
+ SAR_Calc.SetCellWidth(cellWidth);
+ SAR_Calc.SetCellVolumes(cell_volume);
+ SAR_Calc.SetCellCondictivity(cell_kappa); // cell_kappa will be NULL if m_UseCellKappa is false
+
+ for (size_t n = 0; n<m_FD_Samples.size(); ++n)
+ {
+ SAR_Calc.SetEField(m_E_FD_Fields.at(n));
+ if (!m_UseCellKappa)
+ SAR_Calc.SetJField(m_J_FD_Fields.at(n));
+ power = SAR_Calc.CalcSARPower();
+ SAR_Calc.CalcSAR(SAR);
+
+ if (m_fileType==VTK_FILETYPE)
+ {
+ stringstream ss;
+ ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n);
+
+ m_Vtk_Dump_File->SetFilename(ss.str());
+ m_Vtk_Dump_File->ClearAllFields();
+ m_Vtk_Dump_File->AddScalarField(GetFieldNameByType(m_DumpType),SAR);
+ if (m_Vtk_Dump_File->Write()==false)
+ cerr << "ProcessFieldsSAR::DumpFDData: can't dump to file...! " << endl;
+ }
+ else if (m_fileType==HDF5_FILETYPE)
+ {
+ stringstream ss;
+ ss << "f" << n;
+ size_t datasize[]={numLines[0],numLines[1],numLines[2]};
+ if (m_HDF5_Dump_File->WriteScalarField(ss.str(), SAR, datasize)==false)
+ cerr << "ProcessFieldsSAR::DumpFDData: can't dump to file...! " << endl;
+ float freq[1] = {(float)m_FD_Samples.at(n)};
+ if (m_HDF5_Dump_File->WriteAtrribute("/FieldData/FD/"+ss.str(),"frequency",freq,1)==false)
+ cerr << "ProcessFieldsSAR::DumpFDData: can't dump to file...! " << endl;
+ float pow[1] = {(float)power};
+ if (m_HDF5_Dump_File->WriteAtrribute("/FieldData/FD/"+ss.str(),"power",pow,1)==false)
+ cerr << "ProcessFieldsSAR::DumpFDData: can't dump to file...! " << endl;
+ }
+ else
+ cerr << "ProcessFieldsSAR::DumpFDData: unknown File-Type" << endl;
+ }
+ }
+ for (int n=0;n<3;++n)
+ delete[] cellWidth[n];
+ Delete3DArray(cell_volume,numLines);
+ Delete3DArray(cell_density,numLines);
+ Delete3DArray(cell_kappa,numLines);
+ Delete3DArray(SAR,numLines);
+}
diff --git a/openEMS/Common/processfields_sar.h b/openEMS/Common/processfields_sar.h
new file mode 100644
index 0000000..289100d
--- /dev/null
+++ b/openEMS/Common/processfields_sar.h
@@ -0,0 +1,61 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 PROCESSFIELDS_SAR_H
+#define PROCESSFIELDS_SAR_H
+
+#include "processfields_fd.h"
+
+class ProcessFieldsSAR : public ProcessFieldsFD
+{
+public:
+ ProcessFieldsSAR(Engine_Interface_Base* eng_if);
+ virtual ~ProcessFieldsSAR();
+
+ virtual void SetDumpType(DumpType type);
+
+ virtual bool NeedConductivity() const;
+
+ virtual std::string GetProcessingName() const {return "SAR dump";}
+
+ virtual void InitProcess();
+
+ virtual int Process();
+
+ virtual void SetSubSampling(unsigned int subSampleRate, int dir=-1);
+
+ virtual void SetOptResolution(double optRes, int dir=-1);
+
+ //! Set to true for using the conductivity found at the center of a cell, or false for E*J instead
+ virtual void SetUseCellConductivity(bool val) {m_UseCellKappa=val;}
+
+ virtual void SetSARAveragingMethod(std::string method) {m_SAR_method=method;}
+
+protected:
+ virtual void DumpFDData();
+
+ bool m_UseCellKappa;
+
+ std::string m_SAR_method;
+
+ //! frequency domain electric field storage
+ std::vector<std::complex<float>****> m_E_FD_Fields;
+ //! frequency domain current density storage
+ std::vector<std::complex<float>****> m_J_FD_Fields;
+};
+
+#endif // PROCESSFIELDS_SAR_H
diff --git a/openEMS/Common/processfields_td.cpp b/openEMS/Common/processfields_td.cpp
new file mode 100644
index 0000000..d67e48b
--- /dev/null
+++ b/openEMS/Common/processfields_td.cpp
@@ -0,0 +1,91 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "processfields_td.h"
+#include "Common/operator_base.h"
+#include "tools/vtk_file_writer.h"
+#include "tools/hdf5_file_writer.h"
+#include <iomanip>
+#include <sstream>
+#include <string>
+
+using namespace std;
+
+ProcessFieldsTD::ProcessFieldsTD(Engine_Interface_Base* eng_if) : ProcessFields(eng_if)
+{
+ pad_length = 8;
+}
+
+ProcessFieldsTD::~ProcessFieldsTD()
+{
+}
+
+void ProcessFieldsTD::InitProcess()
+{
+ if (Enabled==false) return;
+
+ ProcessFields::InitProcess();
+
+ if (m_Vtk_Dump_File)
+ m_Vtk_Dump_File->SetHeader(string("openEMS TD Field Dump -- Interpolation: ")+m_Eng_Interface->GetInterpolationTypeString());
+
+ if (m_HDF5_Dump_File)
+ m_HDF5_Dump_File->SetCurrentGroup("/FieldData/TD");
+}
+
+int ProcessFieldsTD::Process()
+{
+ if (Enabled==false) return -1;
+ if (CheckTimestep()==false) return GetNextInterval();
+
+ string filename = m_filename;
+
+ float**** field = CalcField();
+ bool success = true;
+
+ if (m_fileType==VTK_FILETYPE)
+ {
+ m_Vtk_Dump_File->SetTimestep(m_Eng_Interface->GetNumberOfTimesteps());
+ m_Vtk_Dump_File->ClearAllFields();
+ m_Vtk_Dump_File->AddVectorField(GetFieldNameByType(m_DumpType),field);
+ success &= m_Vtk_Dump_File->Write();
+ }
+ else if (m_fileType==HDF5_FILETYPE)
+ {
+ stringstream ss;
+ ss << std::setw( pad_length ) << std::setfill( '0' ) << m_Eng_Interface->GetNumberOfTimesteps();
+ size_t datasize[]={numLines[0],numLines[1],numLines[2]};
+ success &= m_HDF5_Dump_File->WriteVectorField(ss.str(), field, datasize);
+ float time[1] = {(float)m_Eng_Interface->GetTime(m_dualTime)};
+ success &= m_HDF5_Dump_File->WriteAtrribute("/FieldData/TD/"+ss.str(),"time",time,1);
+ }
+ else
+ {
+ success = false;
+ cerr << "ProcessFieldsTD::Process: unknown File-Type" << endl;
+ }
+
+ Delete_N_3DArray<FDTD_FLOAT>(field,numLines);
+
+ if (success==false)
+ {
+ SetEnable(false);
+ cerr << "ProcessFieldsTD::Process: can't dump to file... disabled! " << endl;
+ }
+
+ return GetNextInterval();
+}
diff --git a/openEMS/Common/processfields_td.h b/openEMS/Common/processfields_td.h
new file mode 100644
index 0000000..91c4c04
--- /dev/null
+++ b/openEMS/Common/processfields_td.h
@@ -0,0 +1,42 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 PROCESSFIELDS_TD_H
+#define PROCESSFIELDS_TD_H
+
+#include "processfields.h"
+
+class ProcessFieldsTD : public ProcessFields
+{
+public:
+ ProcessFieldsTD(Engine_Interface_Base* eng_if);
+ virtual ~ProcessFieldsTD();
+
+ virtual std::string GetProcessingName() const {return "time domain field dump";}
+
+ virtual void InitProcess();
+
+ virtual int Process();
+
+ //! Set the length of the filename timestep pad filled with zeros (default is 8)
+ void SetPadLength(int val) {pad_length=val;};
+
+protected:
+ int pad_length;
+};
+
+#endif // PROCESSFIELDS_TD_H
diff --git a/openEMS/Common/processing.cpp b/openEMS/Common/processing.cpp
new file mode 100644
index 0000000..a444d9d
--- /dev/null
+++ b/openEMS/Common/processing.cpp
@@ -0,0 +1,372 @@
+/*
+* Copyright (C) 2010-2015 Thorsten Liebig (Thorsten.Liebig@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 "tools/global.h"
+#include "tools/useful.h"
+#include "Common/operator_base.h"
+#include <algorithm>
+#include "processing.h"
+#include <climits>
+
+using namespace std;
+
+Processing::Processing(Engine_Interface_Base* eng_if)
+{
+ m_Eng_Interface = NULL;
+ SetEngineInterface(eng_if);
+
+ Enabled = true;
+ m_PS_pos = 0;
+ SetPrecision(12);
+ ProcessInterval=0;
+ m_FD_SampleCount=0;
+ m_FD_Interval=0;
+ m_weight=1;
+ m_Flush = false;
+ m_dualMesh = false;
+ m_dualTime = false;
+ m_SnapMethod = 0;
+ m_Mesh_Type = CARTESIAN_MESH;
+
+ startTS=0;
+ stopTS =UINT_MAX;
+ for (int n=0;n<3;++n)
+ {
+ start[n]=0;
+ stop[n]=0;
+ }
+}
+
+Processing::~Processing()
+{
+ SetEngineInterface(NULL);
+ file.close();
+}
+
+void Processing::Reset()
+{
+ m_PS_pos=0;
+}
+
+void Processing::SetEngineInterface(Engine_Interface_Base* eng_if)
+{
+ delete m_Eng_Interface;
+ m_Eng_Interface = eng_if;
+ if (m_Eng_Interface)
+ Op=m_Eng_Interface->GetOperator();
+ else
+ Op=NULL;
+}
+
+void Processing::SetName(string val, int number)
+{
+ stringstream ss;
+ ss << val << "_" << number;
+ SetName(ss.str());
+}
+
+bool Processing::CheckTimestep()
+{
+ unsigned int ts = m_Eng_Interface->GetNumberOfTimesteps();
+ if (ts<startTS || ts>stopTS)
+ return false;
+ if (m_ProcessSteps.size()>m_PS_pos)
+ {
+ if (m_ProcessSteps.at(m_PS_pos)==ts)
+ {
+ ++m_PS_pos;
+ return true;
+ }
+ }
+ if (ProcessInterval)
+ {
+ if (ts%ProcessInterval==0) return true;
+ }
+
+ if (m_FD_Interval)
+ {
+ if (ts%m_FD_Interval==0) return true;
+ }
+ return false;
+}
+
+int Processing::GetNextInterval() const
+{
+ if (Enabled==false) return -1;
+ int next=INT_MAX;
+ int ts = (int)m_Eng_Interface->GetNumberOfTimesteps();
+ if (m_ProcessSteps.size()>m_PS_pos)
+ {
+ next = (int)m_ProcessSteps.at(m_PS_pos)-ts;
+ }
+ if (ProcessInterval!=0)
+ {
+ int next_Interval = (int)ProcessInterval - ts%ProcessInterval;
+ if (next_Interval<next)
+ next = next_Interval;
+ }
+
+ //check for FD sample interval
+ if (m_FD_Interval!=0)
+ {
+ int next_Interval = (int)m_FD_Interval - ts%m_FD_Interval;
+ if (next_Interval<next)
+ next = next_Interval;
+ }
+
+ return next;
+}
+
+void Processing::AddStep(unsigned int step)
+{
+ if (m_ProcessSteps.size()==0)
+ m_ProcessSteps.push_back(step);
+ else if (find(m_ProcessSteps.begin(), m_ProcessSteps.end(),step)==m_ProcessSteps.end())
+ m_ProcessSteps.push_back(step);
+}
+
+void Processing::AddSteps(vector<unsigned int> steps)
+{
+ for (size_t n=0; n<steps.size(); ++n)
+ {
+ AddStep(steps.at(n));
+ }
+}
+
+void Processing::AddFrequency(double freq)
+{
+ unsigned int nyquistTS = CalcNyquistNum(freq,Op->GetTimestep());
+
+ if (nyquistTS == 0)
+ {
+ cerr << "Processing::AddFrequency: Requested frequency " << freq << " is too high for the current timestep used... skipping..." << endl;
+ return;
+ }
+ else if (nyquistTS<Op->GetNumberOfNyquistTimesteps())
+ {
+ cerr << "Processing::AddFrequency: Warning: Requested frequency " << freq << " is higher than maximum excited frequency..." << endl;
+ }
+
+ if (m_FD_Interval==0)
+ m_FD_Interval = Op->GetNumberOfNyquistTimesteps();
+ if (m_FD_Interval>nyquistTS)
+ m_FD_Interval = nyquistTS;
+
+ m_FD_Samples.push_back(freq);
+}
+
+void Processing::AddFrequency(vector<double> *freqs)
+{
+ for (size_t n=0; n<freqs->size(); ++n)
+ {
+ AddFrequency(freqs->at(n));
+ }
+}
+
+void Processing::DefineStartStopCoord(double* dstart, double* dstop)
+{
+ m_Dimension = Op->SnapBox2Mesh(dstart,dstop,start,stop,m_dualMesh,false,m_SnapMethod, m_start_inside, m_stop_inside);
+ if (m_Dimension<0)
+ {
+ cerr << "Processing::DefineStartStopCoord: Warning in " << m_Name << " (" << GetProcessingName() << ") : Box is outside the field domain!! Disabling" << endl;
+ Enabled = false;
+ return;
+ }
+}
+
+void Processing::ShowSnappedCoords()
+{
+ cerr << m_Name << ": snapped ";
+ if (m_dualMesh)
+ cerr << "dual";
+ else
+ cerr << "primary";
+ cerr << " 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::SetProcessStartStopTime(double start, double stop)
+{
+ double dT = Op->GetTimestep();
+ startTS = 0;
+ stopTS = UINT_MAX;
+ if (start>0)
+ startTS = floor(start/dT);
+ if (stop>0)
+ stopTS = ceil(stop/dT);
+ if (stopTS<=startTS)
+ {
+ cerr << "Processing::SetProcessStartStopTimestep: Invalid start/stop values! Disabling!" << endl;
+ startTS = 0;
+ stopTS = UINT_MAX;
+ }
+}
+
+void Processing::OpenFile( string outfile )
+{
+ if (file.is_open())
+ file.close();
+
+ file.open( outfile.c_str() );
+ if (!file.is_open())
+ cerr << "Can't open file: " << outfile << endl;
+
+ m_filename = outfile;
+}
+
+void Processing::PostProcess()
+{
+ FlushData();
+}
+
+void Processing::DumpBox2File( string vtkfilenameprefix, bool dualMesh ) const
+{
+ string vtkfilename = vtkfilenameprefix + m_filename + ".vtk";
+
+ ofstream file( vtkfilename.c_str() );
+ if (!file.is_open())
+ {
+ cerr << "Processing::DumpBoxes2File(): Can't open file: " << vtkfilename << endl;
+ return;
+ }
+
+ // normalize coordinates
+ double s1[3], s2[3];
+ for (int i=0; i<3; i++)
+ {
+ s1[i] = min(Op->GetDiscLine(i,start[i],dualMesh),Op->GetDiscLine(i,stop[i],dualMesh));
+ s2[i] = max(Op->GetDiscLine(i,start[i],dualMesh),Op->GetDiscLine(i,stop[i],dualMesh));
+ }
+
+ // fix degenerate box/plane -> line (paraview display problem)
+ if (((s1[0] == s2[0]) && (s1[1] == s2[1])) || ((s1[0] == s2[0]) && (s1[2] == s2[2])) || ((s1[2] == s2[2]) && (s1[1] == s2[1])))
+ {
+ // line are not displayed correctly -> enlarge
+ for (int i=0; i<3; i++)
+ {
+ double delta = min( Op->GetEdgeLength( i, start,dualMesh ), Op->GetEdgeLength( i, stop,dualMesh ) ) / Op->GetGridDelta() / 4.0;
+ s1[i] -= delta;
+ s2[i] += delta;
+ }
+ }
+
+ // rescale coordinates
+#ifndef OUTPUT_IN_DRAWINGUNITS
+ double scaling = Op->GetGridDelta();
+ for (int i=0; i<3; i++)
+ {
+ s1[i] *= scaling;
+ s2[i] *= scaling;
+ }
+#endif
+
+ file << "# vtk DataFile Version 2.0" << endl;
+ file << "" << endl;
+ file << "ASCII" << endl;
+ file << "DATASET POLYDATA" << endl;
+
+ file << "POINTS 8 float" << endl;
+ file << s1[0] << " " << s1[1] << " " << s1[2] << endl;
+ file << s2[0] << " " << s1[1] << " " << s1[2] << endl;
+ file << s2[0] << " " << s2[1] << " " << s1[2] << endl;
+ file << s1[0] << " " << s2[1] << " " << s1[2] << endl;
+ file << s1[0] << " " << s1[1] << " " << s2[2] << endl;
+ file << s2[0] << " " << s1[1] << " " << s2[2] << endl;
+ file << s2[0] << " " << s2[1] << " " << s2[2] << endl;
+ file << s1[0] << " " << s2[1] << " " << s2[2] << endl;
+
+ file << "POLYGONS 6 30" << endl;
+ file << "4 0 1 2 3" << endl;
+ file << "4 4 5 6 7" << endl;
+ file << "4 7 6 2 3" << endl;
+ file << "4 4 5 1 0" << endl;
+ file << "4 0 4 7 3" << endl;
+ file << "4 5 6 2 1" << endl;
+
+ file.close();
+}
+
+void ProcessingArray::AddProcessing(Processing* proc)
+{
+ ProcessArray.push_back(proc);
+}
+
+void ProcessingArray::InitAll()
+{
+ for (size_t i=0; i<ProcessArray.size(); ++i)
+ {
+ ProcessArray.at(i)->InitProcess();
+ }
+}
+
+void ProcessingArray::FlushNext()
+{
+ for (size_t i=0; i<ProcessArray.size(); ++i)
+ {
+ ProcessArray.at(i)->FlushNext();
+ }
+}
+
+void ProcessingArray::Reset()
+{
+ for (size_t i=0; i<ProcessArray.size(); ++i)
+ {
+ ProcessArray.at(i)->Reset();
+ }
+}
+
+void ProcessingArray::DeleteAll()
+{
+ for (size_t i=0; i<ProcessArray.size(); ++i)
+ {
+ delete ProcessArray.at(i);
+ }
+ ProcessArray.clear();
+}
+
+void ProcessingArray::PreProcess()
+{
+ for (size_t i=0; i<ProcessArray.size(); ++i) ProcessArray.at(i)->PreProcess();
+}
+
+int ProcessingArray::Process()
+{
+ int nextProcess=maxInterval;
+ //this could be done nicely in parallel??
+ for (size_t i=0; i<ProcessArray.size(); ++i)
+ {
+ int step = ProcessArray.at(i)->Process();
+ if ((step>0) && (step<nextProcess))
+ nextProcess=step;
+ }
+ return nextProcess;
+}
+
+void ProcessingArray::PostProcess()
+{
+ for (size_t i=0; i<ProcessArray.size(); ++i) ProcessArray.at(i)->PostProcess();
+}
+
+void ProcessingArray::DumpBoxes2File( string vtkfilenameprefix ) const
+{
+ for (size_t i=0; i<ProcessArray.size(); ++i)
+ ProcessArray.at(i)->DumpBox2File( vtkfilenameprefix );
+}
diff --git a/openEMS/Common/processing.h b/openEMS/Common/processing.h
new file mode 100644
index 0000000..2042706
--- /dev/null
+++ b/openEMS/Common/processing.h
@@ -0,0 +1,204 @@
+/*
+* Copyright (C) 2010-2015 Thorsten Liebig (Thorsten.Liebig@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 PROCESSING_H
+#define PROCESSING_H
+
+#include <complex>
+typedef std::complex<double> double_complex;
+#define _I double_complex(0.0,1.0)
+
+#include <iostream>
+#include <fstream>
+#include <cmath>
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "Common/engine_interface_base.h"
+
+class Operator_Base;
+
+class Processing
+{
+public:
+ virtual ~Processing();
+
+ enum MeshType { CARTESIAN_MESH, CYLINDRICAL_MESH};
+
+ //! Set the interface to the engine. Each processing needs its own engine interface. This class will take ownership and cleanup the interface on deletion!
+ void SetEngineInterface(Engine_Interface_Base* eng_if);
+
+ virtual void SetName(std::string val) {m_Name=val;}
+ virtual void SetName(std::string val, int number);
+ virtual std::string GetName() const {return m_Name;}
+
+ //! Get the name for this processing, will be used in file description.
+ virtual std::string GetProcessingName() const = 0;
+
+ virtual void InitProcess() {};
+ virtual void Reset();
+
+ virtual void DefineStartStopCoord(double* dstart, double* dstop);
+
+ virtual void ShowSnappedCoords();
+
+ void SetProcessInterval(unsigned int interval) {ProcessInterval=std::max((unsigned int)1,interval);}
+ void SetProcessStartStopTime(double start, double stop);
+
+ void AddStep(unsigned int step);
+ void AddSteps(std::vector<unsigned int> steps);
+
+ void AddFrequency(double freq);
+ void AddFrequency(std::vector<double> *freqs);
+
+ bool CheckTimestep();
+
+ //! Process data prior to the simulation run.
+ virtual void PreProcess() {};
+
+ //! Process data during simulation run.
+ virtual int Process() {return GetNextInterval();}
+
+ //! Process data after simulation has finished.
+ virtual void PostProcess();
+
+ //! If disabled, Process() will do nothing...
+ virtual void SetEnable(bool val) {Enabled=val;}
+ //! If disabled, Process() will do nothing...
+ virtual bool GetEnable() const {return Enabled;}
+
+ virtual void SetWeight(double weight) {m_weight=weight;}
+ virtual double GetWeight() {return m_weight;}
+
+ //! Invoke this flag to flush all stored data to disk
+ virtual void FlushNext() {m_Flush = true;}
+ virtual void FlushData() {};
+
+ void SetMeshType(MeshType meshType) {m_Mesh_Type=meshType;}
+
+ //! Set the dump precision
+ void SetPrecision(unsigned int val) {m_precision = val;}
+
+ //! Dump probe geometry to file (will obay main or dual mesh property)
+ virtual void DumpBox2File(std::string vtkfilenameprefix) const {DumpBox2File(vtkfilenameprefix,m_dualMesh);}
+
+ //! Dump probe geometry to file
+ virtual void DumpBox2File(std::string vtkfilenameprefix, bool dualMesh) const;
+
+ virtual void SetDualMesh(bool val) {m_dualMesh=val;}
+ virtual void SetDualTime(bool val) {m_dualTime=val;}
+
+protected:
+ Processing(Engine_Interface_Base* eng_if);
+ Engine_Interface_Base* m_Eng_Interface;
+ const Operator_Base* Op;
+ MeshType m_Mesh_Type;
+
+ unsigned int m_precision;
+
+ std::string m_Name;
+
+ bool m_Flush;
+
+ double m_weight;
+
+ bool Enabled;
+
+ int GetNextInterval() const;
+ unsigned int ProcessInterval;
+
+ size_t m_PS_pos; //! current position in list of processing steps
+ std::vector<unsigned int> m_ProcessSteps; //! list of processing steps
+
+ //! Vector of frequency samples
+ std::vector<double> m_FD_Samples;
+ //! Number of samples already processed
+ unsigned int m_FD_SampleCount;
+ //! Sampling interval needed for the FD_Samples
+ unsigned int m_FD_Interval;
+
+ //! define if given coords are on main or dualMesh (default is false)
+ bool m_dualMesh;
+
+ //! define if given processing uses the dual time concept (default is false);
+ bool m_dualTime;
+
+ //! define the snap method used for this processing
+ int m_SnapMethod;
+
+ //! dimension of the snapped box
+ int m_Dimension;
+
+ //! define/store snapped start/stop coords as mesh index
+ unsigned int start[3];
+ unsigned int stop[3];
+
+ //! start/stop timestep
+ unsigned int startTS, stopTS;
+
+ //! define/store if snapped start/stop coords are inside the field domain
+ bool m_start_inside[3];
+ bool m_stop_inside[3];
+
+ std::ofstream file;
+ std::string m_filename;
+
+ virtual void OpenFile(std::string outfile);
+};
+
+class ProcessingArray
+{
+public:
+ ProcessingArray(unsigned int maximalInterval) {maxInterval=maximalInterval;}
+ ~ProcessingArray() {};
+
+ void AddProcessing(Processing* proc);
+
+ void InitAll();
+
+ //! Invoke this flag to flush all stored data to disk for all processings on next Process()
+ void FlushNext();
+
+ void Reset();
+
+ //! Deletes all given processing's, can be helpful, but use carefull!!!
+ void DeleteAll();
+
+ //! Invoke PreProcess() on all Processings.
+ void PreProcess();
+
+ //! Invoke Process() on all Processings. Will return the smallest next iteration interval.
+ int Process();
+
+ //! Invoke PostProcess() on all Processings.
+ void PostProcess();
+
+ void DumpBoxes2File(std::string vtkfilenameprefix ) const;
+
+ size_t GetNumberOfProcessings() const {return ProcessArray.size();}
+
+ Processing* GetProcessing(size_t number) {return ProcessArray.at(number);}
+
+protected:
+ unsigned int maxInterval;
+ std::vector<Processing*> ProcessArray;
+};
+
+#endif // PROCESSING_H
diff --git a/openEMS/Common/processintegral.cpp b/openEMS/Common/processintegral.cpp
new file mode 100644
index 0000000..b64b479
--- /dev/null
+++ b/openEMS/Common/processintegral.cpp
@@ -0,0 +1,177 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "processintegral.h"
+#include "Common/operator_base.h"
+#include "time.h"
+#include <iomanip>
+
+using namespace std;
+
+ProcessIntegral::ProcessIntegral(Engine_Interface_Base* eng_if) : Processing(eng_if)
+{
+ m_Results=NULL;
+ m_FD_Results=NULL;
+ m_normDir = -1;
+}
+
+ProcessIntegral::~ProcessIntegral()
+{
+ delete[] m_Results;
+ delete[] m_FD_Results;
+ m_Results = NULL;
+ m_FD_Results = NULL;
+}
+
+
+void ProcessIntegral::InitProcess()
+{
+ delete[] m_Results; m_Results = NULL;
+ delete[] m_FD_Results; m_FD_Results = NULL;
+
+ if (!Enabled)
+ return;
+
+ m_Results = new double[GetNumberOfIntegrals()];
+ m_FD_Results = new vector<double_complex>[GetNumberOfIntegrals()];
+
+ m_filename = m_Name;
+ OpenFile(m_filename);
+
+ //write header
+ time_t rawTime;
+ time(&rawTime);
+ file << "% time-domain " << GetProcessingName() << " by openEMS " << GIT_VERSION << " @" << ctime(&rawTime);
+ file << "% start-coordinates: ("
+ << Op->GetDiscLine(0,start[0])*Op->GetGridDelta() << ","
+ << Op->GetDiscLine(1,start[1])*Op->GetGridDelta() << ","
+ << Op->GetDiscLine(2,start[2])*Op->GetGridDelta() << ") m -> [" << start[0] << "," << start[1] << "," << start[2] << "]" << endl;
+ file << "% stop-coordinates: ("
+ << Op->GetDiscLine(0,stop[0])*Op->GetGridDelta() << ","
+ << Op->GetDiscLine(1,stop[1])*Op->GetGridDelta() << ","
+ << Op->GetDiscLine(2,stop[2])*Op->GetGridDelta() << ") m -> [" << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl;
+ file << "% t/s";
+ for (int n=0;n<GetNumberOfIntegrals();++n)
+ {
+ file << "\t" << GetIntegralName(n);
+ }
+ file << endl;
+
+ for (int i=0;i<GetNumberOfIntegrals();++i)
+ {
+ for (size_t n=0; n<m_FD_Samples.size(); ++n)
+ {
+ m_FD_Results[i].push_back(0);
+ }
+ }
+}
+
+void ProcessIntegral::FlushData()
+{
+ if (!Enabled)
+ return;
+ if (m_FD_Samples.size())
+ Dump_FD_Data(1.0,m_filename + "_FD");
+}
+
+
+void ProcessIntegral::Dump_FD_Data(double factor, string filename)
+{
+ if (m_FD_Samples.size()==0)
+ return;
+ ofstream file;
+ file.open( filename.c_str() );
+ if (!file.is_open())
+ cerr << "ProcessIntegral::Dump_FD_Data: Error: Can't open file: " << filename << endl;
+
+ //write header
+ time_t rawTime;
+ time(&rawTime);
+ file << "% frequency-domain " << GetProcessingName() << " by openEMS " << GIT_VERSION << " @" << ctime(&rawTime);
+ file << "% start-coordinates: ("
+ << Op->GetDiscLine(0,start[0])*Op->GetGridDelta() << ","
+ << Op->GetDiscLine(1,start[1])*Op->GetGridDelta() << ","
+ << Op->GetDiscLine(2,start[2])*Op->GetGridDelta() << ") m -> [" << start[0] << "," << start[1] << "," << start[2] << "]" << endl;
+ file << "% stop-coordinates: ("
+ << Op->GetDiscLine(0,stop[0])*Op->GetGridDelta() << ","
+ << Op->GetDiscLine(1,stop[1])*Op->GetGridDelta() << ","
+ << Op->GetDiscLine(2,stop[2])*Op->GetGridDelta() << ") m -> [" << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl;
+ file << "% f/Hz";
+ for (int n=0;n<GetNumberOfIntegrals();++n)
+ {
+ file << "\t" << GetIntegralName(n) << "\t";
+ }
+ file << endl << "%";
+ for (int i = 0; i < GetNumberOfIntegrals();++i)
+ file << "\treal\timag";
+ file << endl;
+
+ for (size_t n=0; n<m_FD_Samples.size(); ++n)
+ {
+ file << m_FD_Samples.at(n) ;
+ for (int i = 0; i < GetNumberOfIntegrals();++i)
+ file << "\t" << std::real(m_FD_Results[i].at(n))*factor << "\t" << std::imag(m_FD_Results[i].at(n))*factor;
+ file << "\n";
+ }
+
+ file.close();
+}
+
+int ProcessIntegral::Process()
+{
+ if (Enabled==false) return -1;
+ if (CheckTimestep()==false) return GetNextInterval();
+
+ CalcMultipleIntegrals();
+ int NrInt = GetNumberOfIntegrals();
+ double time = m_Eng_Interface->GetTime(m_dualTime);
+
+ if (ProcessInterval)
+ {
+ if (m_Eng_Interface->GetNumberOfTimesteps()%ProcessInterval==0)
+ {
+ file << setprecision(m_precision) << time;
+ for (int n=0; n<NrInt; ++n)
+ file << "\t" << m_Results[n] * m_weight;
+ file << endl;
+ }
+ }
+
+ if (m_FD_Interval)
+ {
+ if (m_Eng_Interface->GetNumberOfTimesteps()%m_FD_Interval==0)
+ {
+ for (size_t n=0; n<m_FD_Samples.size(); ++n)
+ {
+ for (int i=0; i<NrInt; ++i)
+ m_FD_Results[i].at(n) += (double)m_Results[i] * m_weight * std::exp( -2.0 * _I * M_PI * m_FD_Samples.at(n) * time ) * 2.0 * Op->GetTimestep() * (double)m_FD_Interval;
+ }
+ ++m_FD_SampleCount;
+ if (m_Flush)
+ FlushData();
+ m_Flush = false;
+ }
+ }
+
+ return GetNextInterval();
+}
+
+double* ProcessIntegral::CalcMultipleIntegrals()
+{
+ m_Results[0] = CalcIntegral();
+ return m_Results;
+}
diff --git a/openEMS/Common/processintegral.h b/openEMS/Common/processintegral.h
new file mode 100644
index 0000000..1bddfd6
--- /dev/null
+++ b/openEMS/Common/processintegral.h
@@ -0,0 +1,71 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 PROCESSINTEGRAL_H
+#define PROCESSINTEGRAL_H
+
+#include "processing.h"
+
+//! Abstract base class for integral parameter processing
+/*!
+ \todo Weighting is applied equally to all integral parameter --> todo: weighting for each result individually
+ */
+class ProcessIntegral : public Processing
+{
+public:
+ virtual ~ProcessIntegral();
+
+ virtual void InitProcess();
+
+ virtual std::string GetProcessingName() const = 0;
+
+ virtual void GetNormalDir(int nd) {m_normDir=nd;}
+
+ //! Flush FD data to disk
+ virtual void FlushData();
+
+ //! This method can calculate multiple integral parameter and must be overloaded for each derived class. \sa GetNumberOfIntegrals
+ /*!
+ This method will store its integral results internally with a size given by GetNumberOfIntegrals()
+ It will return the result for the CalcIntegral() as default.
+ */
+ virtual double* CalcMultipleIntegrals();
+
+ //! Get the name of the integral for the given row. The names will be used in the file header.
+ virtual std::string GetIntegralName(int row) const = 0;
+
+ //! Number of calculated results produced by this integral processing. \sa CalcMultipleIntegrals
+ virtual int GetNumberOfIntegrals() const {return 1;}
+
+ //! This method should calculate the integral parameter and must be overloaded for each derived class
+ virtual double CalcIntegral() {return 0;}
+
+ //! This method will write the TD and FD dump files using CalcIntegral() to calculate the integral parameter
+ virtual int Process();
+
+protected:
+ ProcessIntegral(Engine_Interface_Base* eng_if);
+
+ void Dump_FD_Data(double factor, std::string filename);
+
+ std::vector<double_complex> *m_FD_Results;
+ double *m_Results;
+
+ int m_normDir; // normal direction as required by some integral processings
+};
+
+#endif // PROCESSINTEGRAL_H
diff --git a/openEMS/Common/processmodematch.cpp b/openEMS/Common/processmodematch.cpp
new file mode 100644
index 0000000..9c71c7a
--- /dev/null
+++ b/openEMS/Common/processmodematch.cpp
@@ -0,0 +1,265 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "processmodematch.h"
+#include "CSFunctionParser.h"
+#include "Common/operator_base.h"
+#include "tools/array_ops.h"
+
+using namespace std;
+
+ProcessModeMatch::ProcessModeMatch(Engine_Interface_Base* eng_if) : ProcessIntegral(eng_if)
+{
+ for (int n=0; n<2; ++n)
+ {
+ m_ModeParser[n] = new CSFunctionParser();
+ m_ModeDist[n] = NULL;
+ }
+ delete[] m_Results;
+ m_Results = new double[2];
+}
+
+ProcessModeMatch::~ProcessModeMatch()
+{
+ for (int n=0; n<2; ++n)
+ {
+ delete m_ModeParser[n];
+ m_ModeParser[n] = NULL;
+ }
+ Reset();
+}
+
+string ProcessModeMatch::GetIntegralName(int row) const
+{
+ if (row==0)
+ {
+ if (m_ModeFieldType==0)
+ return "voltage";
+ if (m_ModeFieldType==1)
+ return "current";
+ }
+ if (row==1)
+ {
+ return "mode_purity";
+ }
+ return "unknown";
+}
+
+string ProcessModeMatch::GetProcessingName() const
+{
+ if (m_ModeFieldType==0)
+ return "voltage mode matching";
+ if (m_ModeFieldType==1)
+ return "current mode matching";
+ return "unknown mode matching";
+}
+
+void ProcessModeMatch::InitProcess()
+{
+ if (!Enabled) return;
+
+ if (m_Eng_Interface==NULL)
+ {
+ cerr << "ProcessModeMatch::InitProcess: Error, Engine_Interface is NULL, abort mode mathcing..." << endl;
+ Enabled=false;
+ return;
+ }
+ m_Eng_Interface->SetInterpolationType(Engine_Interface_Base::NODE_INTERPOLATE);
+
+ int Dump_Dim=0;
+ m_ny = -1;
+ for (int n=0; n<3; ++n)
+ {
+ if (start[n]>stop[n])
+ {
+ unsigned int help=start[n];
+ start[n]=stop[n];
+ stop[n]=help;
+ }
+
+ //exclude boundaries from mode-matching
+ if (start[n]==0)
+ ++start[n];
+ if (stop[n]==Op->GetNumberOfLines(n)-1)
+ --stop[n];
+
+ if (stop[n]!=start[n])
+ ++Dump_Dim;
+
+ if (stop[n] == start[n])
+ m_ny = n;
+ }
+
+ if ((Dump_Dim!=2) || (m_ny<0))
+ {
+ cerr << "ProcessModeMatch::InitProcess(): Warning Mode Matching Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << Dump_Dim << ")" << endl;
+ SetEnable(false);
+ Reset();
+ return;
+ }
+
+ int nP = (m_ny+1)%3;
+ int nPP = (m_ny+2)%3;
+ m_numLines[0] = stop[nP] - start[nP] + 1;
+ m_numLines[1] = stop[nPP] - start[nPP] + 1;
+
+ for (int n=0; n<2; ++n)
+ {
+ int ny = (m_ny+n+1)%3;
+ int res = m_ModeParser[n]->Parse(m_ModeFunction[ny], "x,y,z,rho,a,r,t");
+ if (res >= 0)
+ {
+ cerr << "ProcessModeMatch::InitProcess(): Warning, an error occured parsing the mode matching function (see below) ..." << endl;
+ cerr << m_ModeFunction[ny] << "\n" << string(res, ' ') << "^\n" << m_ModeParser[n]->ErrorMsg() << "\n";
+ SetEnable(false);
+ Reset();
+ }
+ }
+
+ for (int n=0; n<2; ++n)
+ {
+ m_ModeDist[n] = Create2DArray<double>(m_numLines);
+ }
+
+ unsigned int pos[3] = {0,0,0};
+ double discLine[3] = {0,0,0};
+ double gridDelta = 1; // 1 -> mode-matching function is definied in drawing units...
+ double var[7];
+ pos[m_ny] = start[m_ny];
+ discLine[m_ny] = Op->GetDiscLine(m_ny,pos[m_ny],m_dualMesh);
+ double norm = 0;
+ double area = 0;
+ for (unsigned int posP = 0; posP<m_numLines[0]; ++posP)
+ {
+ pos[nP] = start[nP] + posP;
+ discLine[nP] = Op->GetDiscLine(nP,pos[nP],m_dualMesh);
+ for (unsigned int posPP = 0; posPP<m_numLines[1]; ++posPP)
+ {
+ pos[nPP] = start[nPP] + posPP;
+ discLine[nPP] = Op->GetDiscLine(nPP,pos[nPP],m_dualMesh);
+
+ var[0] = discLine[0] * gridDelta; // x
+ var[1] = discLine[1] * gridDelta; // y
+ var[2] = discLine[2] * gridDelta; // z
+ var[3] = sqrt(discLine[0]*discLine[0] + discLine[1]*discLine[1]) * gridDelta; // rho = sqrt(x^2 + y^2)
+ var[4] = atan2(discLine[1], discLine[0]); // a = atan(y,x)
+ var[5] = sqrt(pow(discLine[0],2)+pow(discLine[1],2)+pow(discLine[2],2)) * gridDelta; // r
+ var[6] = asin(1)-atan(var[2]/var[3]); //theta (t)
+
+ if (m_Mesh_Type == CYLINDRICAL_MESH)
+ {
+ var[3] = discLine[0] * gridDelta; // rho
+ var[4] = discLine[1]; // a
+ var[0] = discLine[0] * cos(discLine[1]) * gridDelta; // x = r*cos(a)
+ var[1] = discLine[0] * sin(discLine[1]) * gridDelta; // y = r*sin(a)
+ var[5] = sqrt(pow(discLine[0],2)+pow(discLine[2],2)) * gridDelta; // r
+ var[6] = asin(1)-atan(var[2]/var[3]); //theta (t)
+ }
+ area = Op->GetNodeArea(m_ny,pos,m_dualMesh);
+ for (int n=0; n<2; ++n)
+ {
+ m_ModeDist[n][posP][posPP] = m_ModeParser[n]->Eval(var); //calc mode template
+ if ((isnan(m_ModeDist[n][posP][posPP])) || (isinf(m_ModeDist[n][posP][posPP])))
+ m_ModeDist[n][posP][posPP] = 0.0;
+ norm += pow(m_ModeDist[n][posP][posPP],2) * area;
+ }
+// cerr << discLine[0] << " " << discLine[1] << " : " << m_ModeDist[0][posP][posPP] << " , " << m_ModeDist[1][posP][posPP] << endl;
+ }
+ }
+
+ norm = sqrt(norm);
+// cerr << norm << endl;
+ // normalize template function...
+ for (unsigned int posP = 0; posP<m_numLines[0]; ++posP)
+ for (unsigned int posPP = 0; posPP<m_numLines[1]; ++posPP)
+ {
+ for (int n=0; n<2; ++n)
+ {
+ m_ModeDist[n][posP][posPP] /= norm;
+ }
+// cerr << posP << " " << posPP << " : " << m_ModeDist[0][posP][posPP] << " , " << m_ModeDist[1][posP][posPP] << endl;
+ }
+
+ ProcessIntegral::InitProcess();
+}
+
+void ProcessModeMatch::Reset()
+{
+ ProcessIntegral::Reset();
+ for (int n=0; n<2; ++n)
+ {
+ Delete2DArray<double>(m_ModeDist[n],m_numLines);
+ m_ModeDist[n] = NULL;
+ }
+}
+
+
+void ProcessModeMatch::SetModeFunction(int ny, string function)
+{
+ if ((ny<0) || (ny>2)) return;
+ m_ModeFunction[ny] = function;
+}
+
+void ProcessModeMatch::SetFieldType(int type)
+{
+ m_ModeFieldType = type;
+ if ((type<0) || (type>1))
+ cerr << "ProcessModeMatch::SetFieldType: Warning, unknown field type..." << endl;
+}
+
+double* ProcessModeMatch::CalcMultipleIntegrals()
+{
+ double value = 0;
+ double field = 0;
+ double purity = 0;
+ double area = 0;
+
+ int nP = (m_ny+1)%3;
+ int nPP = (m_ny+2)%3;
+
+ unsigned int pos[3] = {0,0,0};
+ pos[m_ny] = start[m_ny];
+
+ double out[3]={0,0,0};
+
+ for (unsigned int posP = 0; posP<m_numLines[0]; ++posP)
+ {
+ pos[nP] = start[nP] + posP;
+ for (unsigned int posPP = 0; posPP<m_numLines[1]; ++posPP)
+ {
+ pos[nPP] = start[nPP] + posPP;
+ area = Op->GetNodeArea(m_ny,pos,m_dualMesh);
+ if (m_ModeFieldType==0)
+ m_Eng_Interface->GetEField(pos,out);
+ if (m_ModeFieldType==1)
+ m_Eng_Interface->GetHField(pos,out);
+
+ for (int n=0; n<2; ++n)
+ {
+ field = out[(m_ny+n+1)%3];
+ value += field * m_ModeDist[n][posP][posPP] * area;
+ purity += field*field * area;
+ }
+ }
+ }
+ if (purity!=0)
+ m_Results[1] = value*value/purity;
+ else
+ m_Results[1] = 0;
+ m_Results[0] = value;
+ return m_Results;
+}
diff --git a/openEMS/Common/processmodematch.h b/openEMS/Common/processmodematch.h
new file mode 100644
index 0000000..0bb03b7
--- /dev/null
+++ b/openEMS/Common/processmodematch.h
@@ -0,0 +1,68 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 PROCESSMODEMATCH_H
+#define PROCESSMODEMATCH_H
+
+#include "processintegral.h"
+
+class CSFunctionParser;
+
+//! Processing class to match a mode to a given analytic function and return the integral value.
+/*!
+ The analytric function has to be definied in drawing units.
+ It will return the integral value and the mode purity as a secondary value.
+ */
+class ProcessModeMatch : public ProcessIntegral
+{
+public:
+ ProcessModeMatch(Engine_Interface_Base* eng_if);
+ virtual ~ProcessModeMatch();
+
+ virtual std::string GetProcessingName() const;
+
+ virtual std::string GetIntegralName(int row) const;
+
+ virtual void InitProcess();
+ virtual void Reset();
+
+ //! Set the field type (0 electric field, 1 magnetic field)
+ void SetFieldType(int type);
+ //! Set the mode function in the given direction ny. For example: SetModeFunction(0,"cos(pi/1000*x)*sin(pi/500*y)");
+ void SetModeFunction(int ny, std::string function);
+
+ virtual int GetNumberOfIntegrals() const {return 2;}
+ virtual double* CalcMultipleIntegrals();
+
+protected:
+ //normal direction of the mode plane
+ int m_ny;
+
+ int m_ModeFieldType;
+
+ double GetField(int ny, const unsigned int pos[3]);
+ double GetEField(int ny, const unsigned int pos[3]);
+ double GetHField(int ny, const unsigned int pos[3]);
+
+ std::string m_ModeFunction[3];
+ CSFunctionParser* m_ModeParser[2];
+
+ unsigned int m_numLines[2];
+ double** m_ModeDist[2];
+};
+
+#endif // PROCESSMODEMATCH_H
diff --git a/openEMS/Common/processvoltage.cpp b/openEMS/Common/processvoltage.cpp
new file mode 100644
index 0000000..6875b03
--- /dev/null
+++ b/openEMS/Common/processvoltage.cpp
@@ -0,0 +1,40 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "processvoltage.h"
+#include <iomanip>
+
+ProcessVoltage::ProcessVoltage(Engine_Interface_Base* eng_if) : ProcessIntegral(eng_if)
+{
+}
+
+ProcessVoltage::~ProcessVoltage()
+{
+}
+
+std::string ProcessVoltage::GetIntegralName(int row) const
+{
+ if (row==0)
+ return "voltage";
+ return "unknown";
+}
+
+double ProcessVoltage::CalcIntegral()
+{
+ //integrate voltages from start to stop on a line
+ return m_Eng_Interface->CalcVoltageIntegral(start,stop);
+}
diff --git a/openEMS/Common/processvoltage.h b/openEMS/Common/processvoltage.h
new file mode 100644
index 0000000..509ddbf
--- /dev/null
+++ b/openEMS/Common/processvoltage.h
@@ -0,0 +1,39 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 PROCESSVOLTAGE_H
+#define PROCESSVOLTAGE_H
+
+#include "processintegral.h"
+
+//! Process voltage along a line from start to stop coordinates. ATM integration along the axis e.g.: in x, then y then z direction (Future: diagonal integration)
+class ProcessVoltage : public ProcessIntegral
+{
+public:
+ ProcessVoltage(Engine_Interface_Base* eng_if);
+ virtual ~ProcessVoltage();
+
+ virtual std::string GetProcessingName() const {return "voltage integration";}
+
+ virtual std::string GetIntegralName(int row) const;
+
+ virtual double CalcIntegral();
+
+protected:
+};
+
+#endif // PROCESSVOLTAGE_H
diff --git a/openEMS/Common/readme.txt b/openEMS/Common/readme.txt
new file mode 100644
index 0000000..8c62be8
--- /dev/null
+++ b/openEMS/Common/readme.txt
@@ -0,0 +1,6 @@
+readme for openEMS/Common
+
+- This folder contains all classes common for all numerical solver included in openEMS (currently only EC-FDTD)
+ - Operator-Base class
+ - Engine-Interface classes
+ - Common processing classes
diff --git a/openEMS/Doxyfile b/openEMS/Doxyfile
new file mode 100644
index 0000000..0b67b59
--- /dev/null
+++ b/openEMS/Doxyfile
@@ -0,0 +1,1551 @@
+# Doxyfile 1.6.3
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = openEMS
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = . FDTD FDTD/extensions Common tools
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = YES
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = YES
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/openEMS/FDTD/CMakeLists.txt b/openEMS/FDTD/CMakeLists.txt
new file mode 100644
index 0000000..b0358d3
--- /dev/null
+++ b/openEMS/FDTD/CMakeLists.txt
@@ -0,0 +1,30 @@
+
+if (WITH_MPI)
+ set(MPI_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/openems_fdtd_mpi.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_mpi.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_mpi.cpp
+ )
+endif()
+
+set(SOURCES
+ ${SOURCES}
+ ${MPI_SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_multithread.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_cylinder.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_cylinder.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_sse.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_sse.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_sse_compressed.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_sse_compressed.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_multithread.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/excitation.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_cylindermultigrid.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_cylindermultigrid.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_interface_fdtd.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_interface_sse_fdtd.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_interface_cylindrical_fdtd.cpp
+ PARENT_SCOPE
+)
diff --git a/openEMS/FDTD/engine.cpp b/openEMS/FDTD/engine.cpp
new file mode 100644
index 0000000..26725e6
--- /dev/null
+++ b/openEMS/FDTD/engine.cpp
@@ -0,0 +1,232 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine.h"
+#include "extensions/engine_extension.h"
+#include "extensions/operator_extension.h"
+#include "tools/array_ops.h"
+
+//! \brief construct an Engine instance
+//! it's the responsibility of the caller to free the returned pointer
+Engine* Engine::New(const Operator* op)
+{
+ cout << "Create FDTD engine" << endl;
+ Engine* e = new Engine(op);
+ e->Init();
+ return e;
+}
+
+Engine::Engine(const Operator* op)
+{
+ m_type = BASIC;
+ numTS = 0;
+ Op = op;
+ for (int n=0; n<3; ++n)
+ numLines[n] = Op->GetNumberOfLines(n, true);
+ volt=NULL;
+ curr=NULL;
+}
+
+Engine::~Engine()
+{
+ this->Reset();
+}
+
+void Engine::Init()
+{
+ numTS = 0;
+ volt = Create_N_3DArray<FDTD_FLOAT>(numLines);
+ curr = Create_N_3DArray<FDTD_FLOAT>(numLines);
+
+ InitExtensions();
+ SortExtensionByPriority();
+}
+
+void Engine::InitExtensions()
+{
+ for (size_t n=0; n<Op->GetNumberOfExtentions(); ++n)
+ {
+ Operator_Extension* op_ext = Op->GetExtension(n);
+ Engine_Extension* eng_ext = op_ext->CreateEngineExtention();
+ if (eng_ext)
+ {
+ eng_ext->SetEngine(this);
+ m_Eng_exts.push_back(eng_ext);
+ }
+ }
+}
+
+void Engine::ClearExtensions()
+{
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ delete m_Eng_exts.at(n);
+ m_Eng_exts.clear();
+}
+
+bool CompareExtensions(Engine_Extension* i, Engine_Extension* j)
+{
+ return (*i<*j);
+}
+
+void Engine::SortExtensionByPriority()
+{
+ stable_sort(m_Eng_exts.begin(),m_Eng_exts.end(), CompareExtensions);
+ reverse(m_Eng_exts.begin(),m_Eng_exts.end());
+
+ if (g_settings.GetVerboseLevel()>1)
+ {
+ cout << "--- Engine::SortExtensionByPriority() ---" << endl;
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ cout << " #" << n << ": " << m_Eng_exts.at(n)->GetExtensionName() << " (" << m_Eng_exts.at(n)->GetPriority() << ")" << endl;
+ }
+}
+
+void Engine::Reset()
+{
+ Delete_N_3DArray(volt,numLines);
+ volt=NULL;
+ Delete_N_3DArray(curr,numLines);
+ curr=NULL;
+
+ ClearExtensions();
+}
+
+void Engine::UpdateVoltages(unsigned int startX, unsigned int numX)
+{
+ unsigned int pos[3];
+ bool shift[3];
+
+ pos[0] = startX;
+ //voltage updates
+ for (unsigned int posX=0; posX<numX; ++posX)
+ {
+ shift[0]=pos[0];
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ shift[1]=pos[1];
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ shift[2]=pos[2];
+ //do the updates here
+ //for x
+ volt[0][pos[0]][pos[1]][pos[2]] *= Op->vv[0][pos[0]][pos[1]][pos[2]];
+ volt[0][pos[0]][pos[1]][pos[2]] += Op->vi[0][pos[0]][pos[1]][pos[2]] * ( curr[2][pos[0]][pos[1]][pos[2]] - curr[2][pos[0]][pos[1]-shift[1]][pos[2]] - curr[1][pos[0]][pos[1]][pos[2]] + curr[1][pos[0]][pos[1]][pos[2]-shift[2]]);
+
+ //for y
+ volt[1][pos[0]][pos[1]][pos[2]] *= Op->vv[1][pos[0]][pos[1]][pos[2]];
+ volt[1][pos[0]][pos[1]][pos[2]] += Op->vi[1][pos[0]][pos[1]][pos[2]] * ( curr[0][pos[0]][pos[1]][pos[2]] - curr[0][pos[0]][pos[1]][pos[2]-shift[2]] - curr[2][pos[0]][pos[1]][pos[2]] + curr[2][pos[0]-shift[0]][pos[1]][pos[2]]);
+
+ //for z
+ volt[2][pos[0]][pos[1]][pos[2]] *= Op->vv[2][pos[0]][pos[1]][pos[2]];
+ volt[2][pos[0]][pos[1]][pos[2]] += Op->vi[2][pos[0]][pos[1]][pos[2]] * ( curr[1][pos[0]][pos[1]][pos[2]] - curr[1][pos[0]-shift[0]][pos[1]][pos[2]] - curr[0][pos[0]][pos[1]][pos[2]] + curr[0][pos[0]][pos[1]-shift[1]][pos[2]]);
+ }
+ }
+ ++pos[0];
+ }
+}
+
+void Engine::UpdateCurrents(unsigned int startX, unsigned int numX)
+{
+ unsigned int pos[3];
+ pos[0] = startX;
+ for (unsigned int posX=0; posX<numX; ++posX)
+ {
+ for (pos[1]=0; pos[1]<numLines[1]-1; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numLines[2]-1; ++pos[2])
+ {
+ //do the updates here
+ //for x
+ curr[0][pos[0]][pos[1]][pos[2]] *= Op->ii[0][pos[0]][pos[1]][pos[2]];
+ curr[0][pos[0]][pos[1]][pos[2]] += Op->iv[0][pos[0]][pos[1]][pos[2]] * ( volt[2][pos[0]][pos[1]][pos[2]] - volt[2][pos[0]][pos[1]+1][pos[2]] - volt[1][pos[0]][pos[1]][pos[2]] + volt[1][pos[0]][pos[1]][pos[2]+1]);
+
+ //for y
+ curr[1][pos[0]][pos[1]][pos[2]] *= Op->ii[1][pos[0]][pos[1]][pos[2]];
+ curr[1][pos[0]][pos[1]][pos[2]] += Op->iv[1][pos[0]][pos[1]][pos[2]] * ( volt[0][pos[0]][pos[1]][pos[2]] - volt[0][pos[0]][pos[1]][pos[2]+1] - volt[2][pos[0]][pos[1]][pos[2]] + volt[2][pos[0]+1][pos[1]][pos[2]]);
+
+ //for z
+ curr[2][pos[0]][pos[1]][pos[2]] *= Op->ii[2][pos[0]][pos[1]][pos[2]];
+ curr[2][pos[0]][pos[1]][pos[2]] += Op->iv[2][pos[0]][pos[1]][pos[2]] * ( volt[1][pos[0]][pos[1]][pos[2]] - volt[1][pos[0]+1][pos[1]][pos[2]] - volt[0][pos[0]][pos[1]][pos[2]] + volt[0][pos[0]][pos[1]+1][pos[2]]);
+ }
+ }
+ ++pos[0];
+ }
+}
+
+void Engine::DoPreVoltageUpdates()
+{
+ //execute extensions in reverse order -> highest priority gets access to the voltages last
+ for (int n=m_Eng_exts.size()-1; n>=0; --n)
+ m_Eng_exts.at(n)->DoPreVoltageUpdates();
+
+}
+
+void Engine::DoPostVoltageUpdates()
+{
+ //execute extensions in normal order -> highest priority gets access to the voltages first
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ m_Eng_exts.at(n)->DoPostVoltageUpdates();
+}
+
+void Engine::Apply2Voltages()
+{
+ //execute extensions in normal order -> highest priority gets access to the voltages first
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ m_Eng_exts.at(n)->Apply2Voltages();
+}
+
+void Engine::DoPreCurrentUpdates()
+{
+ //execute extensions in reverse order -> highest priority gets access to the currents last
+ for (int n=m_Eng_exts.size()-1; n>=0; --n)
+ m_Eng_exts.at(n)->DoPreCurrentUpdates();
+}
+
+void Engine::DoPostCurrentUpdates()
+{
+ //execute extensions in normal order -> highest priority gets access to the currents first
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ m_Eng_exts.at(n)->DoPostCurrentUpdates();
+}
+
+void Engine::Apply2Current()
+{
+ //execute extensions in normal order -> highest priority gets access to the currents first
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ m_Eng_exts.at(n)->Apply2Current();
+}
+
+bool Engine::IterateTS(unsigned int iterTS)
+{
+ for (unsigned int iter=0; iter<iterTS; ++iter)
+ {
+ //voltage updates with extensions
+ DoPreVoltageUpdates();
+ UpdateVoltages(0,numLines[0]);
+ DoPostVoltageUpdates();
+ Apply2Voltages();
+
+ //current updates with extensions
+ DoPreCurrentUpdates();
+ UpdateCurrents(0,numLines[0]-1);
+ DoPostCurrentUpdates();
+ Apply2Current();
+
+ ++numTS;
+ }
+ return true;
+}
diff --git a/openEMS/FDTD/engine.h b/openEMS/FDTD/engine.h
new file mode 100644
index 0000000..72d17e1
--- /dev/null
+++ b/openEMS/FDTD/engine.h
@@ -0,0 +1,104 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_H
+#define ENGINE_H
+
+#include <fstream>
+#include "operator.h"
+
+namespace NS_Engine_Multithread
+{
+class thread; // evil hack to access numTS from multithreading context
+}
+
+class Engine_Extension;
+
+class Engine
+{
+public:
+ enum EngineType
+ {
+ BASIC, SSE, UNKNOWN
+ };
+
+ static Engine* New(const Operator* op);
+ virtual ~Engine();
+
+ virtual void Init();
+ virtual void Reset();
+
+ //!Iterate a number of timesteps
+ virtual bool IterateTS(unsigned int iterTS);
+
+ virtual unsigned int GetNumberOfTimesteps() {return numTS;}
+
+ //this access functions muss be overloaded by any new engine using a different storage model
+ inline virtual FDTD_FLOAT GetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return volt[n][x][y][z]; }
+ inline virtual FDTD_FLOAT GetVolt( unsigned int n, const unsigned int pos[3] ) const { return volt[n][pos[0]][pos[1]][pos[2]]; }
+ inline virtual FDTD_FLOAT GetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return curr[n][x][y][z]; }
+ inline virtual FDTD_FLOAT GetCurr( unsigned int n, const unsigned int pos[3] ) const { return curr[n][pos[0]][pos[1]][pos[2]]; }
+
+ inline virtual void SetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z, FDTD_FLOAT value) { volt[n][x][y][z]=value; }
+ inline virtual void SetVolt( unsigned int n, const unsigned int pos[3], FDTD_FLOAT value ) { volt[n][pos[0]][pos[1]][pos[2]]=value; }
+ inline virtual void SetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z, FDTD_FLOAT value) { curr[n][x][y][z]=value; }
+ inline virtual void SetCurr( unsigned int n, const unsigned int pos[3], FDTD_FLOAT value ) { curr[n][pos[0]][pos[1]][pos[2]]=value; }
+
+ //! Execute Pre-Voltage extension updates
+ virtual void DoPreVoltageUpdates();
+ //! Main FDTD engine voltage updates
+ virtual void UpdateVoltages(unsigned int startX, unsigned int numX);
+ //! Execute Post-Voltage extension updates
+ virtual void DoPostVoltageUpdates();
+ //! Apply extension voltage changes
+ virtual void Apply2Voltages();
+
+ //! Execute Pre-Current extension updates
+ virtual void DoPreCurrentUpdates();
+ //! Main FDTD engine current updates
+ virtual void UpdateCurrents(unsigned int startX, unsigned int numX);
+ //! Execute Post-Current extension updates
+ virtual void DoPostCurrentUpdates();
+ //! Apply extension current changes
+ virtual void Apply2Current();
+
+ inline size_t GetExtensionCount() {return m_Eng_exts.size();}
+ inline Engine_Extension* GetExtension(size_t nr) {return m_Eng_exts.at(nr);}
+ virtual void SortExtensionByPriority();
+
+ EngineType GetType() const {return m_type;}
+
+protected:
+ EngineType m_type;
+
+ Engine(const Operator* op);
+ const Operator* Op;
+
+ unsigned int numLines[3];
+
+ FDTD_FLOAT**** volt;
+ FDTD_FLOAT**** curr;
+ unsigned int numTS;
+
+ virtual void InitExtensions();
+ virtual void ClearExtensions();
+ vector<Engine_Extension*> m_Eng_exts;
+
+ friend class NS_Engine_Multithread::thread; // evil hack to access numTS from multithreading context
+};
+
+#endif // ENGINE_H
diff --git a/openEMS/FDTD/engine_cylinder.cpp b/openEMS/FDTD/engine_cylinder.cpp
new file mode 100644
index 0000000..8d62cb9
--- /dev/null
+++ b/openEMS/FDTD/engine_cylinder.cpp
@@ -0,0 +1,38 @@
+/*
+* Copyright (C) 2012 Thorsten Liebig (Thorsten.Liebig@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 "engine_cylinder.h"
+
+Engine_Cylinder::Engine_Cylinder(const Operator_Cylinder* op) : Engine_Multithread(op)
+{
+ m_Op_Cyl = op;
+}
+
+Engine_Cylinder::~Engine_Cylinder()
+{
+
+}
+
+Engine_Cylinder* Engine_Cylinder::New(const Operator_Cylinder* op, unsigned int numThreads)
+{
+ cout << "Create FDTD engine (cylindrical mesh using sse compression + multithreading)" << endl;
+ Engine_Cylinder* e = new Engine_Cylinder(op);
+ e->setNumThreads(numThreads);
+ e->Init();
+ return e;
+}
+
diff --git a/openEMS/FDTD/engine_cylinder.h b/openEMS/FDTD/engine_cylinder.h
new file mode 100644
index 0000000..cbf33c0
--- /dev/null
+++ b/openEMS/FDTD/engine_cylinder.h
@@ -0,0 +1,36 @@
+/*
+* Copyright (C) 2012 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_CYLINDER_H
+#define ENGINE_CYLINDER_H
+
+#include "operator_cylinder.h"
+#include "engine_multithread.h"
+
+class Engine_Cylinder : public Engine_Multithread
+{
+public:
+ static Engine_Cylinder* New(const Operator_Cylinder* op, unsigned int numThreads = 0);
+ virtual ~Engine_Cylinder();
+
+protected:
+ Engine_Cylinder(const Operator_Cylinder* op);
+
+ const Operator_Cylinder* m_Op_Cyl;
+};
+
+#endif // ENGINE_CYLINDER_H
diff --git a/openEMS/FDTD/engine_cylindermultigrid.cpp b/openEMS/FDTD/engine_cylindermultigrid.cpp
new file mode 100644
index 0000000..8e5ce85
--- /dev/null
+++ b/openEMS/FDTD/engine_cylindermultigrid.cpp
@@ -0,0 +1,226 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine_cylindermultigrid.h"
+#include "operator_cylindermultigrid.h"
+#include "extensions/engine_ext_cylindermultigrid.h"
+
+Engine_CylinderMultiGrid* Engine_CylinderMultiGrid::New(const Operator_CylinderMultiGrid* op, unsigned int numThreads)
+{
+ cout << "Create FDTD engine (cylindrical multi grid mesh using sse compression + multithreading)" << endl;
+ Engine_CylinderMultiGrid* e = new Engine_CylinderMultiGrid(op);
+ e->setNumThreads( numThreads );
+ e->Init();
+ return e;
+}
+
+Engine_CylinderMultiGrid::Engine_CylinderMultiGrid(const Operator_CylinderMultiGrid* op) : Engine_Cylinder(op)
+{
+ Op_CMG = op;
+
+ m_WaitOnBase = new boost::barrier(2);
+ m_WaitOnChild = new boost::barrier(2);
+ m_WaitOnSync = new boost::barrier(2);
+
+ m_Eng_Ext_MG = new Engine_Ext_CylinderMultiGrid(NULL,true);
+ m_Eng_Ext_MG->SetBarrier(m_WaitOnBase, m_WaitOnChild, m_WaitOnSync);
+ m_Eng_Ext_MG->SetEngine(this);
+
+ Engine* eng = op->GetInnerOperator()->CreateEngine();
+ m_InnerEngine = dynamic_cast<Engine_Multithread*>(eng);
+
+ Engine_Ext_CylinderMultiGrid* m_InnerEng_Ext_MG = new Engine_Ext_CylinderMultiGrid(NULL,false);
+ m_InnerEng_Ext_MG->SetBarrier(m_WaitOnBase, m_WaitOnChild, m_WaitOnSync);
+
+ // if already has a base extension, switch places ... seems to be faster...
+ for (size_t n=0; n<m_InnerEngine->m_Eng_exts.size(); ++n)
+ {
+ Engine_Ext_CylinderMultiGrid* eng_mg = dynamic_cast<Engine_Ext_CylinderMultiGrid*>(m_InnerEngine->m_Eng_exts.at(n));
+ if (eng_mg)
+ {
+ m_InnerEngine->m_Eng_exts.at(n) = m_InnerEng_Ext_MG;
+ m_InnerEng_Ext_MG = eng_mg;
+ break;
+ }
+ }
+ m_InnerEngine->m_Eng_exts.push_back(m_InnerEng_Ext_MG);
+}
+
+Engine_CylinderMultiGrid::~Engine_CylinderMultiGrid()
+{
+#ifdef MPI_SUPPORT
+ delete m_InnerEngine->m_MPI_Barrier;
+ m_InnerEngine->m_MPI_Barrier = NULL;
+#endif
+
+ m_Thread_NumTS = 0;
+ m_startBarrier->wait();
+
+ m_IteratorThread_Group.join_all();
+
+ delete m_InnerEngine;
+ m_InnerEngine = NULL;
+
+ delete m_WaitOnBase;
+ m_WaitOnBase = NULL;
+ delete m_WaitOnChild;
+ m_WaitOnChild = NULL;
+ delete m_WaitOnSync;
+ m_WaitOnSync = NULL;
+
+ delete m_startBarrier;
+ m_startBarrier = NULL;
+ delete m_stopBarrier;
+ m_stopBarrier = NULL;
+}
+
+void Engine_CylinderMultiGrid::Init()
+{
+ Engine_Multithread::Init();
+
+ m_Eng_exts.push_back(m_Eng_Ext_MG);
+
+ m_startBarrier = new boost::barrier(3); //both engines + organizer
+ m_stopBarrier = new boost::barrier(3); //both engines + organizer
+
+ boost::thread *t = NULL;
+
+ t = new boost::thread( Engine_CylinderMultiGrid_Thread(this,m_startBarrier,m_stopBarrier,&m_Thread_NumTS, true) );
+ m_IteratorThread_Group.add_thread( t );
+
+ t = new boost::thread( Engine_CylinderMultiGrid_Thread(m_InnerEngine,m_startBarrier,m_stopBarrier,&m_Thread_NumTS, false) );
+ m_IteratorThread_Group.add_thread( t );
+
+ m_InnerEngine->SortExtensionByPriority();
+ SortExtensionByPriority();
+
+#ifdef MPI_SUPPORT
+ //assign an MPI barrier to inner Engine
+ m_InnerEngine->m_MPI_Barrier = new boost::barrier(2);
+#endif
+}
+
+bool Engine_CylinderMultiGrid::IterateTS(unsigned int iterTS)
+{
+ m_Thread_NumTS = iterTS;
+
+ m_startBarrier->wait(); //start base and child iterations
+
+ m_stopBarrier->wait(); //tell base and child to wait for another start event...
+
+ //interpolate child data to base mesh...
+ for (unsigned int n=0; n<Op_CMG->m_Split_Pos-1; ++n)
+ InterpolVoltChild2Base(n);
+ for (unsigned int n=0; n<Op_CMG->m_Split_Pos-2; ++n)
+ InterpolCurrChild2Base(n);
+
+ return true;
+}
+
+void Engine_CylinderMultiGrid::InterpolVoltChild2Base(unsigned int rPos)
+{
+ //interpolate voltages from child engine to the base engine...
+ unsigned int pos[3];
+ pos[0] = rPos;
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numVectors; ++pos[2])
+ {
+ //r - direction
+ f4_volt[0][pos[0]][pos[1]][pos[2]].v = Op_CMG->f4_interpol_v_2p[0][pos[1]].v * m_InnerEngine->f4_volt[0][pos[0]][Op_CMG->m_interpol_pos_v_2p[0][pos[1]]][pos[2]].v
+ + Op_CMG->f4_interpol_v_2pp[0][pos[1]].v * m_InnerEngine->f4_volt[0][pos[0]][Op_CMG->m_interpol_pos_v_2pp[0][pos[1]]][pos[2]].v;
+
+ //z - direction
+ f4_volt[2][pos[0]][pos[1]][pos[2]].v = Op_CMG->f4_interpol_v_2p[0][pos[1]].v * m_InnerEngine->f4_volt[2][pos[0]][Op_CMG->m_interpol_pos_v_2p[0][pos[1]]][pos[2]].v
+ + Op_CMG->f4_interpol_v_2pp[0][pos[1]].v * m_InnerEngine->f4_volt[2][pos[0]][Op_CMG->m_interpol_pos_v_2pp[0][pos[1]]][pos[2]].v;
+
+ //alpha - direction
+ f4_volt[1][pos[0]][pos[1]][pos[2]].v = Op_CMG->f4_interpol_v_2p[1][pos[1]].v * m_InnerEngine->f4_volt[1][pos[0]][Op_CMG->m_interpol_pos_v_2p[1][pos[1]]][pos[2]].v
+ + Op_CMG->f4_interpol_v_2pp[1][pos[1]].v * m_InnerEngine->f4_volt[1][pos[0]][Op_CMG->m_interpol_pos_v_2pp[1][pos[1]]][pos[2]].v;
+ }
+ }
+}
+
+void Engine_CylinderMultiGrid::InterpolCurrChild2Base(unsigned int rPos)
+{
+ //interpolate voltages from child engine to the base engine...
+ unsigned int pos[3];
+ pos[0] = rPos;
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numVectors; ++pos[2])
+ {
+ //r - direction
+ f4_curr[0][pos[0]][pos[1]][pos[2]].v = Op_CMG->f4_interpol_i_2p[0][pos[1]].v * m_InnerEngine->f4_curr[0][pos[0]][Op_CMG->m_interpol_pos_i_2p[0][pos[1]]][pos[2]].v
+ + Op_CMG->f4_interpol_i_2pp[0][pos[1]].v * m_InnerEngine->f4_curr[0][pos[0]][Op_CMG->m_interpol_pos_i_2pp[0][pos[1]]][pos[2]].v;
+
+ //z - direction
+ f4_curr[2][pos[0]][pos[1]][pos[2]].v = Op_CMG->f4_interpol_i_2p[0][pos[1]].v * m_InnerEngine->f4_curr[2][pos[0]][Op_CMG->m_interpol_pos_i_2p[0][pos[1]]][pos[2]].v
+ + Op_CMG->f4_interpol_i_2pp[0][pos[1]].v * m_InnerEngine->f4_curr[2][pos[0]][Op_CMG->m_interpol_pos_i_2pp[0][pos[1]]][pos[2]].v;
+
+ //alpha - direction
+ f4_curr[1][pos[0]][pos[1]][pos[2]].v = Op_CMG->f4_interpol_i_2p[1][pos[1]].v * m_InnerEngine->f4_curr[1][pos[0]][Op_CMG->m_interpol_pos_i_2p[1][pos[1]]][pos[2]].v
+ + Op_CMG->f4_interpol_i_2pp[1][pos[1]].v * m_InnerEngine->f4_curr[1][pos[0]][Op_CMG->m_interpol_pos_i_2pp[1][pos[1]]][pos[2]].v;
+ }
+ }
+}
+
+#ifdef MPI_SUPPORT
+ void Engine_CylinderMultiGrid::SendReceiveVoltages()
+ {
+ //do the local voltage sync, child is waiting...
+ Engine_Multithread::SendReceiveVoltages();
+
+ //run inner voltage sync
+ m_InnerEngine->m_MPI_Barrier->wait();
+ }
+
+ void Engine_CylinderMultiGrid::SendReceiveCurrents()
+ {
+ //do the local current sync, child is waiting...
+ Engine_Multithread::SendReceiveCurrents();
+
+ //run inner voltage sync
+ m_InnerEngine->m_MPI_Barrier->wait();
+ }
+
+#endif
+
+/****************************************************************************************/
+Engine_CylinderMultiGrid_Thread::Engine_CylinderMultiGrid_Thread( Engine_Multithread* engine, boost::barrier *start, boost::barrier *stop, volatile unsigned int* numTS, bool isBase)
+{
+ m_startBarrier = start;
+ m_stopBarrier = stop;
+ m_Eng=engine;
+ m_isBase=isBase;
+ m_numTS = numTS;
+}
+
+void Engine_CylinderMultiGrid_Thread::operator()()
+{
+ m_startBarrier->wait(); //wait for Base engine to start the iterations...
+
+ while (*m_numTS>0) //m_numTS==0 request to terminate this thread...
+ {
+ if (m_isBase)
+ m_Eng->Engine_Multithread::IterateTS(*m_numTS);
+ else
+ m_Eng->IterateTS(*m_numTS);
+ m_stopBarrier->wait(); //sync all workers after iterations are performed
+ m_startBarrier->wait(); //wait for Base engine to start the iterations again ...
+ }
+}
diff --git a/openEMS/FDTD/engine_cylindermultigrid.h b/openEMS/FDTD/engine_cylindermultigrid.h
new file mode 100644
index 0000000..66f337f
--- /dev/null
+++ b/openEMS/FDTD/engine_cylindermultigrid.h
@@ -0,0 +1,85 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_CYLINDERMULTIGRID_H
+#define ENGINE_CYLINDERMULTIGRID_H
+
+#include "engine_cylinder.h"
+
+class Operator_CylinderMultiGrid;
+class Engine_CylinderMultiGrid_Thread;
+class Engine_Ext_CylinderMultiGrid;
+
+class Engine_CylinderMultiGrid : public Engine_Cylinder
+{
+ friend class Engine_Ext_CylinderMultiGrid;
+public:
+// Engine_CylinderMultiGrid();
+
+ static Engine_CylinderMultiGrid* New(const Operator_CylinderMultiGrid* op, unsigned int numThreads = 0);
+ virtual ~Engine_CylinderMultiGrid();
+
+ virtual void InterpolVoltChild2Base(unsigned int rPos);
+ virtual void InterpolCurrChild2Base(unsigned int rPos);
+
+ virtual void Init();
+
+ //! Iterate \a iterTS number of timesteps
+ virtual bool IterateTS(unsigned int iterTS);
+
+protected:
+ Engine_CylinderMultiGrid(const Operator_CylinderMultiGrid* op);
+ const Operator_CylinderMultiGrid* Op_CMG;
+
+ Engine_Multithread* m_InnerEngine;
+
+ volatile unsigned int m_Thread_NumTS;
+ boost::thread_group m_IteratorThread_Group;
+ boost::barrier *m_startBarrier;
+ boost::barrier *m_stopBarrier;
+ Engine_CylinderMultiGrid_Thread* m_IteratorThread;
+ Engine_CylinderMultiGrid_Thread* m_InnerIteratorThread;
+
+ //extension barrier
+ boost::barrier *m_WaitOnBase;
+ boost::barrier *m_WaitOnChild;
+ boost::barrier *m_WaitOnSync;
+
+ Engine_Ext_CylinderMultiGrid* m_Eng_Ext_MG;
+
+#ifdef MPI_SUPPORT
+ virtual void SendReceiveVoltages();
+ virtual void SendReceiveCurrents();
+#endif
+};
+
+
+class Engine_CylinderMultiGrid_Thread
+{
+public:
+ Engine_CylinderMultiGrid_Thread( Engine_Multithread* engine, boost::barrier *start, boost::barrier *stop, volatile unsigned int* numTS, bool isBase);
+ void operator()();
+
+protected:
+ Engine_Multithread *m_Eng;
+ bool m_isBase;
+ boost::barrier *m_startBarrier;
+ boost::barrier *m_stopBarrier;
+ volatile unsigned int *m_numTS;
+};
+
+#endif // ENGINE_CYLINDERMULTIGRID_H
diff --git a/openEMS/FDTD/engine_interface_cylindrical_fdtd.cpp b/openEMS/FDTD/engine_interface_cylindrical_fdtd.cpp
new file mode 100644
index 0000000..065a4ef
--- /dev/null
+++ b/openEMS/FDTD/engine_interface_cylindrical_fdtd.cpp
@@ -0,0 +1,64 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 "engine_interface_cylindrical_fdtd.h"
+
+Engine_Interface_Cylindrical_FDTD::Engine_Interface_Cylindrical_FDTD(Operator_sse* op) : Engine_Interface_SSE_FDTD(op)
+{
+ m_Op_Cyl = dynamic_cast<Operator_Cylinder*>(op);
+ if (m_Op_Cyl==NULL)
+ {
+ cerr << "Engine_Interface_Cylindrical_FDTD::Engine_Interface_Cylindrical_FDTD: Error: Operator is not a cylindrical operator! Exit!" << endl;
+ exit(1);
+ }
+}
+
+Engine_Interface_Cylindrical_FDTD::~Engine_Interface_Cylindrical_FDTD()
+{
+}
+
+double* Engine_Interface_Cylindrical_FDTD::GetHField(const unsigned int* pos, double* out) const
+{
+ if (m_Op_Cyl->GetClosedAlpha()==false)
+ return Engine_Interface_FDTD::GetHField(pos, out);
+
+ unsigned int iPos[] = {pos[0],pos[1],pos[2]};
+
+ if ((m_InterpolType==CELL_INTERPOLATE) && (pos[1]==m_Op->GetNumberOfLines(1)))
+ iPos[1]=0;
+
+ if ((m_InterpolType==NODE_INTERPOLATE) && (iPos[1]==0))
+ iPos[1]=m_Op->GetNumberOfLines(1);
+
+ return Engine_Interface_FDTD::GetHField(iPos, out);
+}
+
+double* Engine_Interface_Cylindrical_FDTD::GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const
+{
+ if (m_Op_Cyl->GetClosedAlpha()==false)
+ return Engine_Interface_FDTD::GetRawInterpolatedField(pos,out,type);
+
+ unsigned int iPos[] = {pos[0],pos[1],pos[2]};
+
+ if ((m_InterpolType==NODE_INTERPOLATE) && (pos[1]==0))
+ iPos[1]=m_Op->GetNumberOfLines(1);
+
+ if ((m_InterpolType==CELL_INTERPOLATE) && (pos[1]==m_Op->GetNumberOfLines(1)))
+ iPos[1]=0;
+
+ return Engine_Interface_FDTD::GetRawInterpolatedField(iPos,out,type);
+}
diff --git a/openEMS/FDTD/engine_interface_cylindrical_fdtd.h b/openEMS/FDTD/engine_interface_cylindrical_fdtd.h
new file mode 100644
index 0000000..adbe184
--- /dev/null
+++ b/openEMS/FDTD/engine_interface_cylindrical_fdtd.h
@@ -0,0 +1,39 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 "engine_interface_sse_fdtd.h"
+#include "operator_cylinder.h"
+
+#ifndef ENGINE_INTERFACE_CYLINDRICAL_FDTD_H
+#define ENGINE_INTERFACE_CYLINDRICAL_FDTD_H
+
+class Engine_Interface_Cylindrical_FDTD : public Engine_Interface_SSE_FDTD
+{
+public:
+ Engine_Interface_Cylindrical_FDTD(Operator_sse* op);
+ virtual ~Engine_Interface_Cylindrical_FDTD();
+
+ virtual double* GetHField(const unsigned int* pos, double* out) const;
+
+protected:
+ Operator_Cylinder* m_Op_Cyl;
+
+ //! Internal method to get an interpolated field of a given type. (0: E, 1: J, 2: rotH)
+ virtual double* GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const;
+};
+
+#endif // ENGINE_INTERFACE_CYLINDRICAL_FDTD_H
diff --git a/openEMS/FDTD/engine_interface_fdtd.cpp b/openEMS/FDTD/engine_interface_fdtd.cpp
new file mode 100644
index 0000000..b8fd9de
--- /dev/null
+++ b/openEMS/FDTD/engine_interface_fdtd.cpp
@@ -0,0 +1,274 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine_interface_fdtd.h"
+
+Engine_Interface_FDTD::Engine_Interface_FDTD(Operator* op) : Engine_Interface_Base(op)
+{
+ if (op==NULL)
+ {
+ cerr << "Engine_Interface_FDTD::Engine_Interface_FDTD: Error: Operator is not set! Exit!" << endl;
+ exit(1);
+ }
+ m_Op = op;
+ m_Eng = m_Op->GetEngine();
+ if (m_Eng==NULL)
+ {
+ cerr << "Engine_Interface_FDTD::Engine_Interface_FDTD: Error: Engine is not set! Exit!" << endl;
+ exit(1);
+ }
+}
+
+Engine_Interface_FDTD::~Engine_Interface_FDTD()
+{
+}
+
+double* Engine_Interface_FDTD::GetEField(const unsigned int* pos, double* out) const
+{
+ return GetRawInterpolatedField(pos, out, 0);
+}
+
+double* Engine_Interface_FDTD::GetJField(const unsigned int* pos, double* out) const
+{
+ return GetRawInterpolatedField(pos, out, 1);
+}
+
+double* Engine_Interface_FDTD::GetRotHField(const unsigned int* pos, double* out) const
+{
+ return GetRawInterpolatedField(pos, out, 2);
+}
+
+double* Engine_Interface_FDTD::GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const
+{
+ unsigned int iPos[] = {pos[0],pos[1],pos[2]};
+ int nP,nPP;
+ double delta;
+ switch (m_InterpolType)
+ {
+ default:
+ case NO_INTERPOLATION:
+ for (int n=0; n<3; ++n)
+ out[n] = GetRawField(n,pos,type);
+ break;
+ case NODE_INTERPOLATE:
+ for (int n=0; n<3; ++n)
+ {
+ if (pos[n]==m_Op->GetNumberOfLines(n, true)-1) // use only the "lower value" at the upper bound
+ {
+ --iPos[n];
+ out[n] = (double)GetRawField(n,iPos,type);
+ ++iPos[n];
+ continue;
+ }
+ delta = m_Op->GetEdgeLength(n,iPos);
+ out[n] = GetRawField(n,iPos,type);
+ if (delta==0)
+ {
+ out[n]=0;
+ continue;
+ }
+ if (pos[n]==0) // use only the "upper value" at the lower bound
+ continue;
+ --iPos[n];
+ double deltaDown = m_Op->GetEdgeLength(n,iPos);
+ double deltaRel = delta / (delta+deltaDown);
+ out[n] = out[n]*(1.0-deltaRel) + (double)GetRawField(n,iPos,type)*deltaRel;
+ ++iPos[n];
+ }
+ break;
+ case CELL_INTERPOLATE:
+ for (int n=0; n<3; ++n)
+ {
+ nP = (n+1)%3;
+ nPP = (n+2)%3;
+ if ((pos[0]==m_Op->GetNumberOfLines(0,true)-1) || (pos[1]==m_Op->GetNumberOfLines(1,true)-1) || (pos[2]==m_Op->GetNumberOfLines(2,true)-1))
+ {
+ out[n] = 0; //electric field outside the field domain is always zero
+ continue;
+ }
+ out[n]=GetRawField(n,iPos,type);
+ ++iPos[nP];
+ out[n]+=GetRawField(n,iPos,type);
+ ++iPos[nPP];
+ out[n]+=GetRawField(n,iPos,type);
+ --iPos[nP];
+ out[n]+=GetRawField(n,iPos,type);
+ --iPos[nPP];
+ out[n]/=4;
+ }
+ break;
+ }
+ return out;
+}
+
+double* Engine_Interface_FDTD::GetHField(const unsigned int* pos, double* out) const
+{
+ unsigned int iPos[] = {pos[0],pos[1],pos[2]};
+ int nP,nPP;
+ double delta;
+ switch (m_InterpolType)
+ {
+ default:
+ case NO_INTERPOLATION:
+ out[0] = m_Eng->GetCurr(0,pos) / m_Op->GetEdgeLength(0,pos,true);
+ out[1] = m_Eng->GetCurr(1,pos) / m_Op->GetEdgeLength(1,pos,true);
+ out[2] = m_Eng->GetCurr(2,pos) / m_Op->GetEdgeLength(2,pos,true);
+ break;
+ case NODE_INTERPOLATE:
+ for (int n=0; n<3; ++n)
+ {
+ nP = (n+1)%3;
+ nPP = (n+2)%3;
+ if ((pos[0]==m_Op->GetNumberOfLines(0,true)-1) || (pos[1]==m_Op->GetNumberOfLines(1,true)-1) || (pos[2]==m_Op->GetNumberOfLines(2,true)-1) || (pos[nP]==0) || (pos[nPP]==0))
+ {
+ out[n] = 0;
+ continue;
+ }
+ out[n]=m_Eng->GetCurr(n,iPos)/m_Op->GetEdgeLength(n,iPos,true);
+ --iPos[nP];
+ out[n]+=m_Eng->GetCurr(n,iPos)/m_Op->GetEdgeLength(n,iPos,true);
+ --iPos[nPP];
+ out[n]+=m_Eng->GetCurr(n,iPos)/m_Op->GetEdgeLength(n,iPos,true);
+ ++iPos[nP];
+ out[n]+=m_Eng->GetCurr(n,iPos)/m_Op->GetEdgeLength(n,iPos,true);
+ ++iPos[nPP];
+ out[n]/=4;
+ }
+ break;
+ case CELL_INTERPOLATE:
+ for (int n=0; n<3; ++n)
+ {
+ delta = m_Op->GetEdgeLength(n,iPos,true);
+ out[n] = m_Eng->GetCurr(n,iPos);
+ if ((pos[n]>=m_Op->GetNumberOfLines(n,true)-1))
+ {
+ out[n] = 0; //magnetic field on the outer boundaries is always zero
+ continue;
+ }
+ ++iPos[n];
+ double deltaUp = m_Op->GetEdgeLength(n,iPos,true);
+ double deltaRel = delta / (delta+deltaUp);
+ out[n] = out[n]*(1.0-deltaRel)/delta + (double)m_Eng->GetCurr(n,iPos)/deltaUp*deltaRel;
+ --iPos[n];
+ }
+ break;
+ }
+
+ return out;
+}
+
+double Engine_Interface_FDTD::CalcVoltageIntegral(const unsigned int* start, const 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 += m_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 -= m_Eng->GetVolt(n,pos[0],pos[1],pos[2]);
+ }
+ }
+ return result;
+}
+
+
+double Engine_Interface_FDTD::GetRawField(unsigned int n, const unsigned int* pos, int type) const
+{
+ double value = m_Eng->GetVolt(n,pos[0],pos[1],pos[2]);
+ double delta = m_Op->GetEdgeLength(n,pos);
+ if ((type==0) && (delta))
+ return value/delta;
+ if ((type==1) && (m_Op->m_kappa) && (delta))
+ return value*m_Op->m_kappa[n][pos[0]][pos[1]][pos[2]]/delta;
+ if (type==2) //calc rot(H)
+ {
+ int nP = (n+1)%3;
+ int nPP = (n+2)%3;
+ unsigned int locPos[] = {pos[0],pos[1],pos[2]};
+ double area = m_Op->GetEdgeArea(n,pos);
+ value = m_Eng->GetCurr(nPP,pos);
+ value -= m_Eng->GetCurr(nP,pos);
+ if (pos[nPP]>0)
+ {
+ --locPos[nPP];
+ value += m_Eng->GetCurr(nP,locPos);
+ ++locPos[nPP];
+ }
+ if (pos[nP]>0)
+ {
+ --locPos[nP];
+ value -= m_Eng->GetCurr(nPP,locPos);
+ }
+ return value/area;
+ }
+
+ return 0.0;
+}
+
+double Engine_Interface_FDTD::CalcFastEnergy() const
+{
+ double E_energy=0.0;
+ double H_energy=0.0;
+
+ unsigned int pos[3];
+ if (m_Eng->GetType()==Engine::BASIC)
+ {
+ for (pos[0]=0; pos[0]<m_Op->GetNumberOfLines(0)-1; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<m_Op->GetNumberOfLines(1)-1; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<m_Op->GetNumberOfLines(2)-1; ++pos[2])
+ {
+ E_energy+=m_Eng->Engine::GetVolt(0,pos[0],pos[1],pos[2]) * m_Eng->Engine::GetVolt(0,pos[0],pos[1],pos[2]);
+ E_energy+=m_Eng->Engine::GetVolt(1,pos[0],pos[1],pos[2]) * m_Eng->Engine::GetVolt(1,pos[0],pos[1],pos[2]);
+ E_energy+=m_Eng->Engine::GetVolt(2,pos[0],pos[1],pos[2]) * m_Eng->Engine::GetVolt(2,pos[0],pos[1],pos[2]);
+
+ H_energy+=m_Eng->Engine::GetCurr(0,pos[0],pos[1],pos[2]) * m_Eng->Engine::GetCurr(0,pos[0],pos[1],pos[2]);
+ H_energy+=m_Eng->Engine::GetCurr(1,pos[0],pos[1],pos[2]) * m_Eng->Engine::GetCurr(1,pos[0],pos[1],pos[2]);
+ H_energy+=m_Eng->Engine::GetCurr(2,pos[0],pos[1],pos[2]) * m_Eng->Engine::GetCurr(2,pos[0],pos[1],pos[2]);
+ }
+ }
+ }
+ }
+ else
+ {
+ for (pos[0]=0; pos[0]<m_Op->GetNumberOfLines(0)-1; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<m_Op->GetNumberOfLines(1)-1; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<m_Op->GetNumberOfLines(2)-1; ++pos[2])
+ {
+ E_energy+=m_Eng->GetVolt(0,pos[0],pos[1],pos[2]) * m_Eng->GetVolt(0,pos[0],pos[1],pos[2]);
+ E_energy+=m_Eng->GetVolt(1,pos[0],pos[1],pos[2]) * m_Eng->GetVolt(1,pos[0],pos[1],pos[2]);
+ E_energy+=m_Eng->GetVolt(2,pos[0],pos[1],pos[2]) * m_Eng->GetVolt(2,pos[0],pos[1],pos[2]);
+
+ H_energy+=m_Eng->GetCurr(0,pos[0],pos[1],pos[2]) * m_Eng->GetCurr(0,pos[0],pos[1],pos[2]);
+ H_energy+=m_Eng->GetCurr(1,pos[0],pos[1],pos[2]) * m_Eng->GetCurr(1,pos[0],pos[1],pos[2]);
+ H_energy+=m_Eng->GetCurr(2,pos[0],pos[1],pos[2]) * m_Eng->GetCurr(2,pos[0],pos[1],pos[2]);
+ }
+ }
+ }
+ }
+ return __EPS0__*E_energy + __MUE0__*H_energy;
+}
diff --git a/openEMS/FDTD/engine_interface_fdtd.h b/openEMS/FDTD/engine_interface_fdtd.h
new file mode 100644
index 0000000..4e824ac
--- /dev/null
+++ b/openEMS/FDTD/engine_interface_fdtd.h
@@ -0,0 +1,65 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_INTERFACE_FDTD_H
+#define ENGINE_INTERFACE_FDTD_H
+
+#include <cmath>
+
+#include "Common/engine_interface_base.h"
+#include "operator.h"
+#include "engine.h"
+
+class Engine_Interface_FDTD : public Engine_Interface_Base
+{
+public:
+ Engine_Interface_FDTD(Operator* op);
+ virtual ~Engine_Interface_FDTD();
+
+ //! Set the FDTD operator
+ virtual void SetFDTDOperator(Operator* op) {SetOperator(op); m_Op=op;}
+ //! Set the FDTD engine
+ virtual void SetFDTDEngine(Engine* eng) {m_Eng=eng;}
+
+ //! Get the FDTD engine in case direct access is needed. Direct access is not recommended!
+ const Engine* GetFDTDEngine() const {return m_Eng;}
+ //! Get the FDTD operator in case direct access is needed. Direct access is not recommended!
+ const Operator* GetFDTDOperator() const {return m_Op;}
+
+ virtual double* GetEField(const unsigned int* pos, double* out) const;
+ virtual double* GetHField(const unsigned int* pos, double* out) const;
+ virtual double* GetJField(const unsigned int* pos, double* out) const;
+ virtual double* GetRotHField(const unsigned int* pos, double* out) const;
+
+ virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const;
+
+ virtual double GetTime(bool dualTime=false) const {return ((double)m_Eng->GetNumberOfTimesteps() + (double)dualTime*0.5)*m_Op->GetTimestep();};
+ virtual unsigned int GetNumberOfTimesteps() const {return m_Eng->GetNumberOfTimesteps();}
+
+ virtual double CalcFastEnergy() const;
+
+protected:
+ Operator* m_Op;
+ Engine* m_Eng;
+
+ //! Internal method to get an interpolated field of a given type. (0: E, 1: J, 2: rotH)
+ virtual double* GetRawInterpolatedField(const unsigned int* pos, double* out, int type) const;
+ //! Internal method to get a raw field of a given type. (0: E, 1: J, 2: rotH)
+ virtual double GetRawField(unsigned int n, const unsigned int* pos, int type) const;
+};
+
+#endif // ENGINE_INTERFACE_FDTD_H
diff --git a/openEMS/FDTD/engine_interface_sse_fdtd.cpp b/openEMS/FDTD/engine_interface_sse_fdtd.cpp
new file mode 100644
index 0000000..b7e9a3c
--- /dev/null
+++ b/openEMS/FDTD/engine_interface_sse_fdtd.cpp
@@ -0,0 +1,69 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 "engine_interface_sse_fdtd.h"
+
+Engine_Interface_SSE_FDTD::Engine_Interface_SSE_FDTD(Operator_sse* op) : Engine_Interface_FDTD(op)
+{
+ m_Op_SSE = op;
+ m_Eng_SSE = dynamic_cast<Engine_sse*>(m_Op_SSE->GetEngine());
+ if (m_Eng_SSE==NULL)
+ {
+ cerr << "Engine_Interface_SSE_FDTD::Engine_Interface_SSE_FDTD: Error: SSE-Engine is not set! Exit!" << endl;
+ exit(1);
+ }
+}
+
+Engine_Interface_SSE_FDTD::~Engine_Interface_SSE_FDTD()
+{
+ m_Op_SSE=NULL;
+ m_Eng_SSE=NULL;
+}
+
+double Engine_Interface_SSE_FDTD::CalcFastEnergy() const
+{
+ f4vector E_energy;
+ E_energy.f[0]=0;
+ E_energy.f[1]=0;
+ E_energy.f[2]=0;
+ E_energy.f[3]=0;
+ f4vector H_energy;
+ H_energy = E_energy;
+
+ if (m_Eng_SSE->GetType()!=Engine::SSE)
+ return Engine_Interface_FDTD::CalcFastEnergy();
+
+ unsigned int pos[3];
+ for (pos[0]=0; pos[0]<m_Op_SSE->GetNumberOfLines(0)-1; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<m_Op_SSE->GetNumberOfLines(1)-1; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<m_Op_SSE->numVectors; ++pos[2])
+ {
+ E_energy.v += m_Eng_SSE->Engine_sse::f4_volt[0][pos[0]][pos[1]][pos[2]].v * m_Eng_SSE->Engine_sse::f4_volt[0][pos[0]][pos[1]][pos[2]].v;
+ E_energy.v += m_Eng_SSE->Engine_sse::f4_volt[1][pos[0]][pos[1]][pos[2]].v * m_Eng_SSE->Engine_sse::f4_volt[1][pos[0]][pos[1]][pos[2]].v;
+ E_energy.v += m_Eng_SSE->Engine_sse::f4_volt[2][pos[0]][pos[1]][pos[2]].v * m_Eng_SSE->Engine_sse::f4_volt[2][pos[0]][pos[1]][pos[2]].v;
+
+ H_energy.v += m_Eng_SSE->Engine_sse::f4_curr[0][pos[0]][pos[1]][pos[2]].v * m_Eng_SSE->Engine_sse::f4_curr[0][pos[0]][pos[1]][pos[2]].v;
+ H_energy.v += m_Eng_SSE->Engine_sse::f4_curr[1][pos[0]][pos[1]][pos[2]].v * m_Eng_SSE->Engine_sse::f4_curr[1][pos[0]][pos[1]][pos[2]].v;
+ H_energy.v += m_Eng_SSE->Engine_sse::f4_curr[2][pos[0]][pos[1]][pos[2]].v * m_Eng_SSE->Engine_sse::f4_curr[2][pos[0]][pos[1]][pos[2]].v;
+ }
+ }
+ }
+
+ return __EPS0__*(E_energy.f[0]+E_energy.f[1]+E_energy.f[2]+E_energy.f[3]) + __MUE0__*(H_energy.f[0]+H_energy.f[1]+H_energy.f[2]+H_energy.f[3]);
+}
diff --git a/openEMS/FDTD/engine_interface_sse_fdtd.h b/openEMS/FDTD/engine_interface_sse_fdtd.h
new file mode 100644
index 0000000..b8f837a
--- /dev/null
+++ b/openEMS/FDTD/engine_interface_sse_fdtd.h
@@ -0,0 +1,38 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_INTERFACE_SSE_FDTD_H
+#define ENGINE_INTERFACE_SSE_FDTD_H
+
+#include "engine_interface_fdtd.h"
+#include "operator_sse.h"
+#include "engine_sse.h"
+
+class Engine_Interface_SSE_FDTD : public Engine_Interface_FDTD
+{
+public:
+ Engine_Interface_SSE_FDTD(Operator_sse* op);
+ virtual ~Engine_Interface_SSE_FDTD();
+
+ virtual double CalcFastEnergy() const;
+
+protected:
+ Operator_sse* m_Op_SSE;
+ Engine_sse* m_Eng_SSE;
+};
+
+#endif // ENGINE_INTERFACE_SSE_FDTD_H
diff --git a/openEMS/FDTD/engine_mpi.cpp b/openEMS/FDTD/engine_mpi.cpp
new file mode 100644
index 0000000..c6a5b2c
--- /dev/null
+++ b/openEMS/FDTD/engine_mpi.cpp
@@ -0,0 +1,211 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 "engine_mpi.h"
+
+Engine_MPI* Engine_MPI::New(const Operator_MPI* op)
+{
+ cout << "Create FDTD engine (compressed SSE + MPI)" << endl;
+ Engine_MPI* e = new Engine_MPI(op);
+ e->Init();
+ return e;
+}
+
+Engine_MPI::Engine_MPI(const Operator_MPI* op) : Engine_SSE_Compressed(op)
+{
+ m_Op_MPI = op;
+}
+
+Engine_MPI::~Engine_MPI()
+{
+ Reset();
+}
+
+void Engine_MPI::Init()
+{
+ Engine_SSE_Compressed::Init();
+
+ for (int i=0;i<3;++i)
+ {
+ m_BufferUp[i]=NULL;
+ m_BufferDown[i]=NULL;
+ m_BufferSize[i]=0;
+ }
+
+ if (m_Op_MPI->GetMPIEnabled())
+ {
+ // init buffers, nx*ny*2 for the tangential electric or magnetic fields at the interface
+ for (int n=0;n<3;++n)
+ {
+ int nP = (n+1)%3;
+ int nPP = (n+2)%3;
+ m_BufferSize[n] = m_Op_MPI->numLines[nP]*m_Op_MPI->numLines[nPP];
+
+ if (m_Op_MPI->m_NeighborDown[n]>=0)
+ {
+ m_BufferDown[n] = new float[m_BufferSize[n]*2];
+ }
+ if (m_Op_MPI->m_NeighborUp[n]>=0)
+ {
+ m_BufferUp[n] = new float[m_BufferSize[n]*2];
+ }
+ }
+ }
+}
+
+void Engine_MPI::Reset()
+{
+ for (int i=0;i<3;++i)
+ {
+ delete[] m_BufferUp[i];
+ delete[] m_BufferDown[i];
+ m_BufferUp[i]=NULL;
+ m_BufferDown[i]=NULL;
+ m_BufferSize[i]=0;
+ }
+
+ Engine_SSE_Compressed::Reset();
+}
+
+void Engine_MPI::SendReceiveVoltages()
+{
+ unsigned int pos[3];
+
+ //non-blocking prepare for receive...
+ for (int n=0;n<3;++n)
+ if (m_Op_MPI->m_NeighborDown[n]>=0)
+ MPI_Irecv( m_BufferDown[n] , m_BufferSize[n]*2, MPI_FLOAT, m_Op_MPI->m_NeighborDown[n], m_Op_MPI->m_MyTag, MPI_COMM_WORLD, &Recv_Request[n]);
+
+ for (int n=0;n<3;++n)
+ {
+ int nP = (n+1)%3;
+ int nPP = (n+2)%3;
+
+ //send voltages
+ unsigned int iPos=0;
+ pos[n]=numLines[n]-2;
+ if (m_Op_MPI->m_NeighborUp[n]>=0)
+ {
+ for (pos[nP]=0; pos[nP]<numLines[nP]; ++pos[nP])
+ {
+ for (pos[nPP]=0; pos[nPP]<numLines[nPP]; ++pos[nPP])
+ {
+ m_BufferUp[n][iPos++] = Engine_SSE_Compressed::GetVolt(nP ,pos);
+ m_BufferUp[n][iPos++] = Engine_SSE_Compressed::GetVolt(nPP,pos);
+ }
+ }
+ MPI_Isend( m_BufferUp[n] , m_BufferSize[n]*2, MPI_FLOAT, m_Op_MPI->m_NeighborUp[n], m_Op_MPI->m_MyTag, MPI_COMM_WORLD, &Send_Request[n]);
+ }
+
+ //receive voltages
+ pos[n]=0;
+ iPos=0;
+ if (m_Op_MPI->m_NeighborDown[n]>=0)
+ {
+ //wait for receive to finish...
+ MPI_Wait(&Recv_Request[n],&stat);
+ for (pos[nP]=0; pos[nP]<numLines[nP]; ++pos[nP])
+ {
+ for (pos[nPP]=0; pos[nPP]<numLines[nPP]; ++pos[nPP])
+ {
+ Engine_SSE_Compressed::SetVolt(nP ,pos,m_BufferDown[n][iPos++]);
+ Engine_SSE_Compressed::SetVolt(nPP,pos,m_BufferDown[n][iPos++]);
+ }
+ }
+ }
+
+ }
+}
+
+void Engine_MPI::SendReceiveCurrents()
+{
+ unsigned int pos[3];
+
+ //non-blocking prepare for receive...
+ for (int n=0;n<3;++n)
+ if (m_Op_MPI->m_NeighborUp[n]>=0)
+ MPI_Irecv( m_BufferUp[n] , m_BufferSize[n]*2, MPI_FLOAT, m_Op_MPI->m_NeighborUp[n], m_Op_MPI->m_MyTag, MPI_COMM_WORLD, &Recv_Request[n]);
+
+ for (int n=0;n<3;++n)
+ {
+ int nP = (n+1)%3;
+ int nPP = (n+2)%3;
+
+ //send currents
+ unsigned int iPos=0;
+ pos[n]=0;
+ if (m_Op_MPI->m_NeighborDown[n]>=0)
+ {
+ for (pos[nP]=0; pos[nP]<numLines[nP]; ++pos[nP])
+ {
+ for (pos[nPP]=0; pos[nPP]<numLines[nPP]; ++pos[nPP])
+ {
+ m_BufferDown[n][iPos++] = Engine_SSE_Compressed::GetCurr(nP ,pos);
+ m_BufferDown[n][iPos++] = Engine_SSE_Compressed::GetCurr(nPP,pos);
+ }
+ }
+ MPI_Isend( m_BufferDown[n] , m_BufferSize[n]*2, MPI_FLOAT, m_Op_MPI->m_NeighborDown[n], m_Op_MPI->m_MyTag, MPI_COMM_WORLD, &Send_Request[n]);
+ }
+
+ //receive currents
+ pos[n]=numLines[n]-2;
+ iPos=0;
+ if (m_Op_MPI->m_NeighborUp[n]>=0)
+ {
+ //wait for receive to finish...
+ MPI_Wait(&Recv_Request[n],&stat);
+ for (pos[nP]=0; pos[nP]<numLines[nP]; ++pos[nP])
+ {
+ for (pos[nPP]=0; pos[nPP]<numLines[nPP]; ++pos[nPP])
+ {
+ Engine_SSE_Compressed::SetCurr(nP ,pos,m_BufferUp[n][iPos++]);
+ Engine_SSE_Compressed::SetCurr(nPP,pos,m_BufferUp[n][iPos++]);
+ }
+ }
+ }
+
+ }
+}
+
+bool Engine_MPI::IterateTS(unsigned int iterTS)
+{
+ if (!m_Op_MPI->GetMPIEnabled())
+ {
+ return Engine_SSE_Compressed::IterateTS(iterTS);
+ }
+
+ for (unsigned int iter=0; iter<iterTS; ++iter)
+ {
+ //voltage updates with extensions
+ DoPreVoltageUpdates();
+ UpdateVoltages(0,numLines[0]);
+ DoPostVoltageUpdates();
+ Apply2Voltages();
+ SendReceiveVoltages();
+
+ //current updates with extensions
+ DoPreCurrentUpdates();
+ UpdateCurrents(0,numLines[0]-1);
+ DoPostCurrentUpdates();
+ Apply2Current();
+ SendReceiveCurrents();
+
+ ++numTS;
+ }
+ return true;
+}
+
diff --git a/openEMS/FDTD/engine_mpi.h b/openEMS/FDTD/engine_mpi.h
new file mode 100644
index 0000000..5aa1226
--- /dev/null
+++ b/openEMS/FDTD/engine_mpi.h
@@ -0,0 +1,57 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_MPI_H
+#define ENGINE_MPI_H
+
+#include "operator_mpi.h"
+#include "engine_sse_compressed.h"
+#include "mpi.h"
+
+class Engine_MPI : public Engine_SSE_Compressed
+{
+public:
+ Engine_MPI();
+
+ static Engine_MPI* New(const Operator_MPI* op);
+ virtual ~Engine_MPI();
+
+ virtual void Init();
+ virtual void Reset();
+
+ virtual bool IterateTS(unsigned int iterTS);
+
+protected:
+ Engine_MPI(const Operator_MPI* op);
+ const Operator_MPI* m_Op_MPI;
+
+ MPI_Status stat;
+ MPI_Request Send_Request[3];
+ MPI_Request Recv_Request[3];
+
+ //field buffer for MPI transfer...
+ unsigned int m_BufferSize[3];
+ float* m_BufferUp[3];
+ float* m_BufferDown[3];
+
+ //! Transfer all tangential voltages at the upper bounds to the lower bounds of the neighbouring MPI-processes
+ virtual void SendReceiveVoltages();
+ //! Transfer all tangential currents at the lower bounds to the upper bounds of the neighbouring MPI-processes
+ virtual void SendReceiveCurrents();
+};
+
+#endif // ENGINE_MPI_H
diff --git a/openEMS/FDTD/engine_multithread.cpp b/openEMS/FDTD/engine_multithread.cpp
new file mode 100644
index 0000000..7370198
--- /dev/null
+++ b/openEMS/FDTD/engine_multithread.cpp
@@ -0,0 +1,343 @@
+/*
+* 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/>.
+*/
+
+//#define ENABLE_DEBUG_TIME
+
+#ifdef ENABLE_DEBUG_TIME
+#define DEBUG_TIME(x) x;
+#else
+#define DEBUG_TIME(x) ;
+#endif
+
+
+
+#include "engine_multithread.h"
+#include "extensions/engine_extension.h"
+#include "tools/array_ops.h"
+
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include <iomanip>
+#include <xmmintrin.h>
+
+//! \brief construct an Engine_Multithread instance
+//! it's the responsibility of the caller to free the returned pointer
+Engine_Multithread* Engine_Multithread::New(const Operator_Multithread* op, unsigned int numThreads)
+{
+ cout << "Create FDTD engine (compressed SSE + multi-threading)" << endl;
+ Engine_Multithread* e = new Engine_Multithread(op);
+ e->setNumThreads( numThreads );
+ e->Init();
+ return e;
+}
+
+Engine_Multithread::Engine_Multithread(const Operator_Multithread* op) : ENGINE_MULTITHREAD_BASE(op)
+{
+ m_Op_MT = op;
+ m_type = SSE;
+ m_IterateBarrier = 0;
+ m_startBarrier = 0;
+ m_stopBarrier = 0;
+
+#ifdef ENABLE_DEBUG_TIME
+ m_MPI_Barrier = 0;
+#endif
+}
+
+Engine_Multithread::~Engine_Multithread()
+{
+#ifdef ENABLE_DEBUG_TIME
+ NS_Engine_Multithread::DBG().cout() << "Engine_Multithread::~Engine_Multithread()" << endl;
+ std::map<boost::thread::id, std::vector<double> >::iterator it;
+ for (it=m_timer_list.begin(); it!=m_timer_list.end(); it++)
+ {
+ NS_Engine_Multithread::DBG().cout() << "*** DEBUG Thread: " << it->first << std::endl;
+ std::vector<double>::iterator it2;
+ for (it2=it->second.begin(); it2<it->second.end();)
+ {
+ NS_Engine_Multithread::DBG().cout() << "after voltage update, before barrier1: " << fixed << setprecision(6) << *(it2++) << std::endl;
+ NS_Engine_Multithread::DBG().cout() << "after barrier1, before barrier2: " << fixed << setprecision(6) << *(it2++) << std::endl;
+ NS_Engine_Multithread::DBG().cout() << "after barrier2, before current update: " << fixed << setprecision(6) << *(it2++) << std::endl;
+ NS_Engine_Multithread::DBG().cout() << "after current update, before barrier3: " << fixed << setprecision(6) << *(it2++) << std::endl;
+ NS_Engine_Multithread::DBG().cout() << "after barrier3: " << fixed << setprecision(6) << *(it2++) << std::endl;
+ }
+ }
+#endif
+
+ Reset();
+}
+
+void Engine_Multithread::setNumThreads( unsigned int numThreads )
+{
+ m_numThreads = numThreads;
+}
+
+void Engine_Multithread::Init()
+{
+ m_stopThreads = true;
+ ENGINE_MULTITHREAD_BASE::Init();
+
+ // initialize threads
+ m_stopThreads = false;
+ if (m_numThreads == 0)
+ m_numThreads = boost::thread::hardware_concurrency();
+
+ vector<unsigned int> m_Start_Lines;
+ vector<unsigned int> m_Stop_Lines;
+ m_Op_MT->CalcStartStopLines( m_numThreads, m_Start_Lines, m_Stop_Lines );
+
+ if (g_settings.GetVerboseLevel()>0)
+ cout << "Multithreaded engine using " << m_numThreads << " threads. Utilization: (";
+ m_IterateBarrier = new boost::barrier(m_numThreads); // numThread workers
+
+ m_startBarrier = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller
+ m_stopBarrier = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller
+#ifdef MPI_SUPPORT
+ m_MPI_Barrier = 0;
+#endif
+
+ for (unsigned int n=0; n<m_numThreads; n++)
+ {
+ unsigned int start = m_Start_Lines.at(n);
+ unsigned int stop = m_Stop_Lines.at(n);
+ unsigned int stop_h = stop;
+ if (n == m_numThreads-1)
+ {
+ // last thread
+ stop_h = stop-1;
+ if (g_settings.GetVerboseLevel()>0)
+ cout << stop-start+1 << ")" << endl;
+ }
+ else
+ if (g_settings.GetVerboseLevel()>0)
+ cout << stop-start+1 << ";";
+// NS_Engine_Multithread::DBG().cout() << "###DEBUG## Thread " << n << ": start=" << start << " stop=" << stop << " stop_h=" << stop_h << std::endl;
+ boost::thread *t = new boost::thread( NS_Engine_Multithread::thread(this,start,stop,stop_h,n) );
+ m_thread_group.add_thread( t );
+ }
+
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ m_Eng_exts.at(n)->SetNumberOfThreads(m_numThreads);
+}
+
+void Engine_Multithread::Reset()
+{
+ if (!m_stopThreads) // prevent multiple invocations
+ {
+ ClearExtensions(); //prevent extensions from interfering with thread reset...
+
+ // stop the threads
+ //NS_Engine_Multithread::DBG().cout() << "stopping all threads" << endl;
+ m_iterTS = 1;
+ m_startBarrier->wait(); // start the threads
+ m_stopThreads = true;
+ m_stopBarrier->wait(); // wait for the threads to finish
+ m_thread_group.join_all(); // wait for termination
+ delete m_IterateBarrier;
+ m_IterateBarrier = 0;
+ delete m_startBarrier;
+ m_startBarrier = 0;
+ delete m_stopBarrier;
+ m_stopBarrier = 0;
+ }
+
+ ENGINE_MULTITHREAD_BASE::Reset();
+}
+
+bool Engine_Multithread::IterateTS(unsigned int iterTS)
+{
+ m_iterTS = iterTS;
+
+ //cout << "bool Engine_Multithread::IterateTS(): starting threads ...";
+ m_startBarrier->wait(); // start the threads
+
+ //cout << "... threads started";
+
+ m_stopBarrier->wait(); // wait for the threads to finish <iterTS> time steps
+ return true;
+}
+
+void Engine_Multithread::DoPreVoltageUpdates(int threadID)
+{
+ //execute extensions in reverse order -> highest priority gets access to the voltages last
+ for (int n=m_Eng_exts.size()-1; n>=0; --n)
+ {
+ m_Eng_exts.at(n)->DoPreVoltageUpdates(threadID);
+ m_IterateBarrier->wait();
+ }
+
+}
+
+void Engine_Multithread::DoPostVoltageUpdates(int threadID)
+{
+ //execute extensions in normal order -> highest priority gets access to the voltages first
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ {
+ m_Eng_exts.at(n)->DoPostVoltageUpdates(threadID);
+ m_IterateBarrier->wait();
+ }
+}
+
+void Engine_Multithread::Apply2Voltages(int threadID)
+{
+ //execute extensions in normal order -> highest priority gets access to the voltages first
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ {
+ m_Eng_exts.at(n)->Apply2Voltages(threadID);
+ m_IterateBarrier->wait();
+ }
+}
+
+void Engine_Multithread::DoPreCurrentUpdates(int threadID)
+{
+ //execute extensions in reverse order -> highest priority gets access to the currents last
+ for (int n=m_Eng_exts.size()-1; n>=0; --n)
+ {
+ m_Eng_exts.at(n)->DoPreCurrentUpdates(threadID);
+ m_IterateBarrier->wait();
+ }
+}
+
+void Engine_Multithread::DoPostCurrentUpdates(int threadID)
+{
+ //execute extensions in normal order -> highest priority gets access to the currents first
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ {
+ m_Eng_exts.at(n)->DoPostCurrentUpdates(threadID);
+ m_IterateBarrier->wait();
+ }
+}
+
+void Engine_Multithread::Apply2Current(int threadID)
+{
+ //execute extensions in normal order -> highest priority gets access to the currents first
+ for (size_t n=0; n<m_Eng_exts.size(); ++n)
+ {
+ m_Eng_exts.at(n)->Apply2Current(threadID);
+ m_IterateBarrier->wait();
+ }
+}
+
+//
+// *************************************************************************************************************************
+//
+namespace NS_Engine_Multithread
+{
+
+thread::thread( Engine_Multithread* ptr, unsigned int start, unsigned int stop, unsigned int stop_h, unsigned int threadID )
+{
+ m_enginePtr = ptr;
+ m_start = start;
+ m_stop = stop;
+ m_stop_h = stop_h;
+ m_threadID = threadID;
+}
+
+void thread::operator()()
+{
+ //std::cout << "thread::operator() Parameters: " << m_start << " " << m_stop << std::endl;
+ //DBG().cout() << "Thread " << m_threadID << " (" << boost::this_thread::get_id() << ") started." << endl;
+
+ // speed up the calculation of denormal floating point values (flush-to-zero)
+#ifndef SSE_CORRECT_DENORMALS
+ unsigned int oldMXCSR = _mm_getcsr(); //read the old MXCSR setting
+ unsigned int newMXCSR = oldMXCSR | 0x8040; // set DAZ and FZ bits
+ _mm_setcsr( newMXCSR ); //write the new MXCSR setting to the MXCSR
+#endif
+
+ while (!m_enginePtr->m_stopThreads)
+ {
+ // wait for start
+ //DBG().cout() << "Thread " << m_threadID << " (" << boost::this_thread::get_id() << ") waiting..." << endl;
+ m_enginePtr->m_startBarrier->wait();
+ //cout << "Thread " << boost::this_thread::get_id() << " waiting... started." << endl;
+
+ DEBUG_TIME( Timer timer1 );
+
+ for (unsigned int iter=0; iter<m_enginePtr->m_iterTS; ++iter)
+ {
+ // pre voltage stuff...
+ m_enginePtr->DoPreVoltageUpdates(m_threadID);
+
+ //voltage updates
+ m_enginePtr->UpdateVoltages(m_start,m_stop-m_start+1);
+
+ // record time
+ DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
+
+ //cout << "Thread " << boost::this_thread::get_id() << " m_barrier1 waiting..." << endl;
+ m_enginePtr->m_IterateBarrier->wait();
+
+ // record time
+ DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
+
+ //post voltage stuff...
+ m_enginePtr->DoPostVoltageUpdates(m_threadID);
+ m_enginePtr->Apply2Voltages(m_threadID);
+
+#ifdef MPI_SUPPORT
+ if (m_threadID==0)
+ {
+ if (m_enginePtr->m_MPI_Barrier)
+ m_enginePtr->m_MPI_Barrier->wait();
+ m_enginePtr->SendReceiveVoltages();
+ }
+ m_enginePtr->m_IterateBarrier->wait();
+#endif
+
+ // record time
+ DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
+
+ //pre current stuff
+ m_enginePtr->DoPreCurrentUpdates(m_threadID);
+
+ //current updates
+ m_enginePtr->UpdateCurrents(m_start,m_stop_h-m_start+1);
+
+ // record time
+ DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
+ m_enginePtr->m_IterateBarrier->wait();
+
+ // record time
+ DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
+
+ //post current stuff
+ m_enginePtr->DoPostCurrentUpdates(m_threadID);
+ m_enginePtr->Apply2Current(m_threadID);
+
+#ifdef MPI_SUPPORT
+ if (m_threadID==0)
+ {
+ if (m_enginePtr->m_MPI_Barrier)
+ m_enginePtr->m_MPI_Barrier->wait();
+ m_enginePtr->SendReceiveCurrents();
+ }
+ m_enginePtr->m_IterateBarrier->wait();
+#endif
+
+ if (m_threadID == 0)
+ ++m_enginePtr->numTS; // only the first thread increments numTS
+ }
+
+ m_enginePtr->m_stopBarrier->wait();
+ }
+
+ //DBG().cout() << "Thread " << m_threadID << " (" << boost::this_thread::get_id() << ") finished." << endl;
+}
+
+} // namespace
+
diff --git a/openEMS/FDTD/engine_multithread.h b/openEMS/FDTD/engine_multithread.h
new file mode 100644
index 0000000..20e7073
--- /dev/null
+++ b/openEMS/FDTD/engine_multithread.h
@@ -0,0 +1,127 @@
+/*
+* 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 ENGINE_MULTITHREAD_H
+#define ENGINE_MULTITHREAD_H
+
+#include "operator_multithread.h"
+#include "engine_sse_compressed.h"
+
+#include <boost/thread.hpp>
+#include <boost/fusion/include/list.hpp>
+#include <boost/fusion/container/list/list_fwd.hpp>
+#include <boost/fusion/include/list_fwd.hpp>
+
+//#ifdef WIN32
+//#include <Winsock2.h> // for struct timeval
+//#endif
+
+#include <sys/time.h>
+
+#ifdef MPI_SUPPORT
+ #define ENGINE_MULTITHREAD_BASE Engine_MPI
+ #include "engine_mpi.h"
+#else
+ #define ENGINE_MULTITHREAD_BASE Engine_SSE_Compressed
+#endif
+
+
+class Engine_Multithread;
+
+namespace NS_Engine_Multithread
+{
+
+class DBG // debug
+{
+public:
+ DBG() {}
+ ~DBG() { std::cout << os.str();}
+ std::ostringstream& cout() {return os;}
+protected:
+ std::ostringstream os;
+};
+
+class Timer //debug
+{
+public:
+ Timer() {gettimeofday(&t1,NULL);}
+ double elapsed() {gettimeofday(&t2,NULL); return (t2.tv_sec-t1.tv_sec) + (t2.tv_usec-t1.tv_usec)*1e-6;}
+protected:
+ timeval t1,t2;
+};
+
+class thread
+{
+public:
+ thread( Engine_Multithread* ptr, unsigned int start, unsigned int stop, unsigned int stop_h, unsigned int threadID );
+ void operator()();
+
+protected:
+ unsigned int m_start, m_stop, m_stop_h, m_threadID;
+ Engine_Multithread *m_enginePtr;
+};
+} // namespace
+
+
+class Engine_Multithread : public ENGINE_MULTITHREAD_BASE
+{
+ friend class NS_Engine_Multithread::thread;
+ friend class Engine_CylinderMultiGrid;
+public:
+ static Engine_Multithread* New(const Operator_Multithread* op, unsigned int numThreads = 0);
+ virtual ~Engine_Multithread();
+
+ virtual void setNumThreads( unsigned int numThreads );
+ virtual void Init();
+ virtual void Reset();
+
+ //! Iterate \a iterTS number of timesteps
+ virtual bool IterateTS(unsigned int iterTS);
+
+ virtual void DoPreVoltageUpdates(int threadID);
+ virtual void DoPostVoltageUpdates(int threadID);
+ virtual void Apply2Voltages(int threadID);
+
+ virtual void DoPreCurrentUpdates(int threadID);
+ virtual void DoPostCurrentUpdates(int threadID);
+ virtual void Apply2Current(int threadID);
+
+protected:
+ Engine_Multithread(const Operator_Multithread* op);
+ const Operator_Multithread* m_Op_MT;
+ boost::thread_group m_thread_group;
+ boost::barrier *m_startBarrier, *m_stopBarrier;
+ boost::barrier *m_IterateBarrier;
+ volatile unsigned int m_iterTS;
+ unsigned int m_numThreads; //!< number of worker threads
+ volatile bool m_stopThreads;
+
+#ifdef MPI_SUPPORT
+ /*! Workaround needed for subgridding scheme... (see Engine_CylinderMultiGrid)
+ Some engines may need an additional barrier for synchronizing MPI communication.
+ This engine will not initialize or cleanup this barrier, but check for it and wait before executing any MPI sync.
+ Make sure to cleanup (delete) this barriere before Engine_Multithread::Reset() is called.
+ */
+ boost::barrier *m_MPI_Barrier;
+#endif
+
+#ifdef ENABLE_DEBUG_TIME
+ std::map<boost::thread::id, std::vector<double> > m_timer_list;
+#endif
+};
+
+#endif // ENGINE_MULTITHREAD_H
diff --git a/openEMS/FDTD/engine_sse.cpp b/openEMS/FDTD/engine_sse.cpp
new file mode 100644
index 0000000..660e6d6
--- /dev/null
+++ b/openEMS/FDTD/engine_sse.cpp
@@ -0,0 +1,176 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 <xmmintrin.h>
+#include "engine_sse.h"
+
+//! \brief construct an Engine_sse instance
+//! it's the responsibility of the caller to free the returned pointer
+Engine_sse* Engine_sse::New(const Operator_sse* op)
+{
+ cout << "Create FDTD engine (SSE)" << endl;
+ Engine_sse* e = new Engine_sse(op);
+ e->Init();
+ return e;
+}
+
+Engine_sse::Engine_sse(const Operator_sse* op) : Engine(op)
+{
+ m_type = SSE;
+ Op = op;
+ f4_volt = 0;
+ f4_curr = 0;
+ numVectors = ceil((double)numLines[2]/4.0);
+
+ // speed up the calculation of denormal floating point values (flush-to-zero)
+#ifndef SSE_CORRECT_DENORMALS
+ unsigned int oldMXCSR = _mm_getcsr(); //read the old MXCSR setting
+ unsigned int newMXCSR = oldMXCSR | 0x8040; // set DAZ and FZ bits
+ _mm_setcsr( newMXCSR ); //write the new MXCSR setting to the MXCSR
+#endif
+}
+
+Engine_sse::~Engine_sse()
+{
+ //_mm_setcsr( oldMXCSR ); // restore old setting
+ Reset();
+}
+
+void Engine_sse::Init()
+{
+ Engine::Init();
+
+ Delete_N_3DArray(volt,numLines);
+ volt=NULL; // not used
+ Delete_N_3DArray(curr,numLines);
+ curr=NULL; // not used
+
+ f4_volt = Create_N_3DArray_v4sf(numLines);
+ f4_curr = Create_N_3DArray_v4sf(numLines);
+}
+
+void Engine_sse::Reset()
+{
+ Engine::Reset();
+ Delete_N_3DArray_v4sf(f4_volt,numLines);
+ f4_volt = 0;
+ Delete_N_3DArray_v4sf(f4_curr,numLines);
+ f4_curr = 0;
+}
+
+void Engine_sse::UpdateVoltages(unsigned int startX, unsigned int numX)
+{
+ unsigned int pos[3];
+ bool shift[2];
+ f4vector temp;
+
+ pos[0] = startX;
+ for (unsigned int posX=0; posX<numX; ++posX)
+ {
+ shift[0]=pos[0];
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ shift[1]=pos[1];
+ for (pos[2]=1; pos[2]<numVectors; ++pos[2])
+ {
+ // x-polarization
+ f4_volt[0][pos[0]][pos[1]][pos[2]].v *= Op->f4_vv[0][pos[0]][pos[1]][pos[2]].v;
+ f4_volt[0][pos[0]][pos[1]][pos[2]].v += Op->f4_vi[0][pos[0]][pos[1]][pos[2]].v * ( f4_curr[2][pos[0]][pos[1]][pos[2]].v - f4_curr[2][pos[0]][pos[1]-shift[1]][pos[2]].v - f4_curr[1][pos[0]][pos[1]][pos[2]].v + f4_curr[1][pos[0]][pos[1]][pos[2]-1].v );
+
+ // y-polarization
+ f4_volt[1][pos[0]][pos[1]][pos[2]].v *= Op->f4_vv[1][pos[0]][pos[1]][pos[2]].v;
+ f4_volt[1][pos[0]][pos[1]][pos[2]].v += Op->f4_vi[1][pos[0]][pos[1]][pos[2]].v * ( f4_curr[0][pos[0]][pos[1]][pos[2]].v - f4_curr[0][pos[0]][pos[1]][pos[2]-1].v - f4_curr[2][pos[0]][pos[1]][pos[2]].v + f4_curr[2][pos[0]-shift[0]][pos[1]][pos[2]].v);
+
+ // z-polarization
+ f4_volt[2][pos[0]][pos[1]][pos[2]].v *= Op->f4_vv[2][pos[0]][pos[1]][pos[2]].v;
+ f4_volt[2][pos[0]][pos[1]][pos[2]].v += Op->f4_vi[2][pos[0]][pos[1]][pos[2]].v * ( f4_curr[1][pos[0]][pos[1]][pos[2]].v - f4_curr[1][pos[0]-shift[0]][pos[1]][pos[2]].v - f4_curr[0][pos[0]][pos[1]][pos[2]].v + f4_curr[0][pos[0]][pos[1]-shift[1]][pos[2]].v);
+ }
+
+ // for pos[2] = 0
+ // x-polarization
+ temp.f[0] = 0;
+ temp.f[1] = f4_curr[1][pos[0]][pos[1]][numVectors-1].f[0];
+ temp.f[2] = f4_curr[1][pos[0]][pos[1]][numVectors-1].f[1];
+ temp.f[3] = f4_curr[1][pos[0]][pos[1]][numVectors-1].f[2];
+ f4_volt[0][pos[0]][pos[1]][0].v *= Op->f4_vv[0][pos[0]][pos[1]][0].v;
+ f4_volt[0][pos[0]][pos[1]][0].v += Op->f4_vi[0][pos[0]][pos[1]][0].v * ( f4_curr[2][pos[0]][pos[1]][0].v - f4_curr[2][pos[0]][pos[1]-shift[1]][0].v - f4_curr[1][pos[0]][pos[1]][0].v + temp.v );
+
+ // y-polarization
+ temp.f[0] = 0;
+ temp.f[1] = f4_curr[0][pos[0]][pos[1]][numVectors-1].f[0];
+ temp.f[2] = f4_curr[0][pos[0]][pos[1]][numVectors-1].f[1];
+ temp.f[3] = f4_curr[0][pos[0]][pos[1]][numVectors-1].f[2];
+ f4_volt[1][pos[0]][pos[1]][0].v *= Op->f4_vv[1][pos[0]][pos[1]][0].v;
+ f4_volt[1][pos[0]][pos[1]][0].v += Op->f4_vi[1][pos[0]][pos[1]][0].v * ( f4_curr[0][pos[0]][pos[1]][0].v - temp.v - f4_curr[2][pos[0]][pos[1]][0].v + f4_curr[2][pos[0]-shift[0]][pos[1]][0].v);
+
+ // z-polarization
+ f4_volt[2][pos[0]][pos[1]][0].v *= Op->f4_vv[2][pos[0]][pos[1]][0].v;
+ f4_volt[2][pos[0]][pos[1]][0].v += Op->f4_vi[2][pos[0]][pos[1]][0].v * ( f4_curr[1][pos[0]][pos[1]][0].v - f4_curr[1][pos[0]-shift[0]][pos[1]][0].v - f4_curr[0][pos[0]][pos[1]][0].v + f4_curr[0][pos[0]][pos[1]-shift[1]][0].v);
+ }
+ ++pos[0];
+ }
+}
+
+void Engine_sse::UpdateCurrents(unsigned int startX, unsigned int numX)
+{
+ unsigned int pos[5];
+ f4vector temp;
+
+ pos[0] = startX;
+ for (unsigned int posX=0; posX<numX; ++posX)
+ {
+ for (pos[1]=0; pos[1]<numLines[1]-1; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numVectors-1; ++pos[2])
+ {
+ // x-pol
+ f4_curr[0][pos[0]][pos[1]][pos[2]].v *= Op->f4_ii[0][pos[0]][pos[1]][pos[2]].v;
+ f4_curr[0][pos[0]][pos[1]][pos[2]].v += Op->f4_iv[0][pos[0]][pos[1]][pos[2]].v * ( f4_volt[2][pos[0]][pos[1]][pos[2]].v - f4_volt[2][pos[0]][pos[1]+1][pos[2]].v - f4_volt[1][pos[0]][pos[1]][pos[2]].v + f4_volt[1][pos[0]][pos[1]][pos[2]+1].v);
+
+ // y-pol
+ f4_curr[1][pos[0]][pos[1]][pos[2]].v *= Op->f4_ii[1][pos[0]][pos[1]][pos[2]].v;
+ f4_curr[1][pos[0]][pos[1]][pos[2]].v += Op->f4_iv[1][pos[0]][pos[1]][pos[2]].v * ( f4_volt[0][pos[0]][pos[1]][pos[2]].v - f4_volt[0][pos[0]][pos[1]][pos[2]+1].v - f4_volt[2][pos[0]][pos[1]][pos[2]].v + f4_volt[2][pos[0]+1][pos[1]][pos[2]].v);
+
+ // z-pol
+ f4_curr[2][pos[0]][pos[1]][pos[2]].v *= Op->f4_ii[2][pos[0]][pos[1]][pos[2]].v;
+ f4_curr[2][pos[0]][pos[1]][pos[2]].v += Op->f4_iv[2][pos[0]][pos[1]][pos[2]].v * ( f4_volt[1][pos[0]][pos[1]][pos[2]].v - f4_volt[1][pos[0]+1][pos[1]][pos[2]].v - f4_volt[0][pos[0]][pos[1]][pos[2]].v + f4_volt[0][pos[0]][pos[1]+1][pos[2]].v);
+ }
+
+ // for pos[2] = numVectors-1
+ // x-pol
+ temp.f[0] = f4_volt[1][pos[0]][pos[1]][0].f[1];
+ temp.f[1] = f4_volt[1][pos[0]][pos[1]][0].f[2];
+ temp.f[2] = f4_volt[1][pos[0]][pos[1]][0].f[3];
+ temp.f[3] = 0;
+ f4_curr[0][pos[0]][pos[1]][numVectors-1].v *= Op->f4_ii[0][pos[0]][pos[1]][numVectors-1].v;
+ f4_curr[0][pos[0]][pos[1]][numVectors-1].v += Op->f4_iv[0][pos[0]][pos[1]][numVectors-1].v * ( f4_volt[2][pos[0]][pos[1]][numVectors-1].v - f4_volt[2][pos[0]][pos[1]+1][numVectors-1].v - f4_volt[1][pos[0]][pos[1]][numVectors-1].v + temp.v);
+
+ // y-pol
+ temp.f[0] = f4_volt[0][pos[0]][pos[1]][0].f[1];
+ temp.f[1] = f4_volt[0][pos[0]][pos[1]][0].f[2];
+ temp.f[2] = f4_volt[0][pos[0]][pos[1]][0].f[3];
+ temp.f[3] = 0;
+ f4_curr[1][pos[0]][pos[1]][numVectors-1].v *= Op->f4_ii[1][pos[0]][pos[1]][numVectors-1].v;
+ f4_curr[1][pos[0]][pos[1]][numVectors-1].v += Op->f4_iv[1][pos[0]][pos[1]][numVectors-1].v * ( f4_volt[0][pos[0]][pos[1]][numVectors-1].v - temp.v - f4_volt[2][pos[0]][pos[1]][numVectors-1].v + f4_volt[2][pos[0]+1][pos[1]][numVectors-1].v);
+
+ // z-pol
+ f4_curr[2][pos[0]][pos[1]][numVectors-1].v *= Op->f4_ii[2][pos[0]][pos[1]][numVectors-1].v;
+ f4_curr[2][pos[0]][pos[1]][numVectors-1].v += Op->f4_iv[2][pos[0]][pos[1]][numVectors-1].v * ( f4_volt[1][pos[0]][pos[1]][numVectors-1].v - f4_volt[1][pos[0]+1][pos[1]][numVectors-1].v - f4_volt[0][pos[0]][pos[1]][numVectors-1].v + f4_volt[0][pos[0]][pos[1]+1][numVectors-1].v);
+ }
+ ++pos[0];
+ }
+}
diff --git a/openEMS/FDTD/engine_sse.h b/openEMS/FDTD/engine_sse.h
new file mode 100644
index 0000000..9389f84
--- /dev/null
+++ b/openEMS/FDTD/engine_sse.h
@@ -0,0 +1,60 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_SSE_H
+#define ENGINE_SSE_H
+
+#include "engine.h"
+#include "operator_sse.h"
+
+class Engine_sse : public Engine
+{
+public:
+ static Engine_sse* New(const Operator_sse* op);
+ virtual ~Engine_sse();
+
+ virtual void Init();
+ virtual void Reset();
+
+ virtual unsigned int GetNumberOfTimesteps() {return numTS;};
+
+ //this access functions muss be overloaded by any new engine using a different storage model
+ inline virtual FDTD_FLOAT GetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return f4_volt[n][x][y][z%numVectors].f[z/numVectors]; }
+ inline virtual FDTD_FLOAT GetVolt( unsigned int n, const unsigned int pos[3] ) const { return f4_volt[n][pos[0]][pos[1]][pos[2]%numVectors].f[pos[2]/numVectors]; }
+ inline virtual FDTD_FLOAT GetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return f4_curr[n][x][y][z%numVectors].f[z/numVectors]; }
+ inline virtual FDTD_FLOAT GetCurr( unsigned int n, const unsigned int pos[3] ) const { return f4_curr[n][pos[0]][pos[1]][pos[2]%numVectors].f[pos[2]/numVectors]; }
+
+ inline virtual void SetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z, FDTD_FLOAT value) { f4_volt[n][x][y][z%numVectors].f[z/numVectors]=value; }
+ inline virtual void SetVolt( unsigned int n, const unsigned int pos[3], FDTD_FLOAT value ) { f4_volt[n][pos[0]][pos[1]][pos[2]%numVectors].f[pos[2]/numVectors]=value; }
+ inline virtual void SetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z, FDTD_FLOAT value) { f4_curr[n][x][y][z%numVectors].f[z/numVectors]=value; }
+ inline virtual void SetCurr( unsigned int n, const unsigned int pos[3], FDTD_FLOAT value ) { f4_curr[n][pos[0]][pos[1]][pos[2]%numVectors].f[pos[2]/numVectors]=value; }
+
+protected:
+ Engine_sse(const Operator_sse* op);
+ const Operator_sse* Op;
+
+ virtual void UpdateVoltages(unsigned int startX, unsigned int numX);
+ virtual void UpdateCurrents(unsigned int startX, unsigned int numX);
+
+ unsigned int numVectors;
+
+public: //public access to the sse arrays for efficient extensions access... use careful...
+ f4vector**** f4_volt;
+ f4vector**** f4_curr;
+};
+
+#endif // ENGINE_SSE_H
diff --git a/openEMS/FDTD/engine_sse_compressed.cpp b/openEMS/FDTD/engine_sse_compressed.cpp
new file mode 100644
index 0000000..8e83387
--- /dev/null
+++ b/openEMS/FDTD/engine_sse_compressed.cpp
@@ -0,0 +1,163 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine_sse_compressed.h"
+#ifdef __SSE2__
+#include <emmintrin.h>
+#endif
+
+Engine_SSE_Compressed* Engine_SSE_Compressed::New(const Operator_SSE_Compressed* op)
+{
+ cout << "Create FDTD engine (compressed SSE)" << endl;
+ Engine_SSE_Compressed* e = new Engine_SSE_Compressed(op);
+ e->Init();
+ return e;
+}
+
+Engine_SSE_Compressed::Engine_SSE_Compressed(const Operator_SSE_Compressed* op) : Engine_sse(op)
+{
+ Op = op;
+}
+
+Engine_SSE_Compressed::~Engine_SSE_Compressed()
+{
+}
+
+void Engine_SSE_Compressed::UpdateVoltages(unsigned int startX, unsigned int numX)
+{
+ unsigned int pos[3];
+ bool shift[2];
+ f4vector temp;
+
+ pos[0] = startX;
+ unsigned int index=0;
+ for (unsigned int posX=0; posX<numX; ++posX)
+ {
+ shift[0]=pos[0];
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ shift[1]=pos[1];
+ for (pos[2]=1; pos[2]<numVectors; ++pos[2])
+ {
+ index = Op->m_Op_index[pos[0]][pos[1]][pos[2]];
+ // x-polarization
+ f4_volt[0][pos[0]][pos[1]][pos[2]].v *= Op->f4_vv_Compressed[0][index].v;
+ f4_volt[0][pos[0]][pos[1]][pos[2]].v += Op->f4_vi_Compressed[0][index].v * ( f4_curr[2][pos[0]][pos[1]][pos[2]].v - f4_curr[2][pos[0]][pos[1]-shift[1]][pos[2]].v - f4_curr[1][pos[0]][pos[1]][pos[2]].v + f4_curr[1][pos[0]][pos[1]][pos[2]-1].v );
+
+ // y-polarization
+ f4_volt[1][pos[0]][pos[1]][pos[2]].v *= Op->f4_vv_Compressed[1][index].v;
+ f4_volt[1][pos[0]][pos[1]][pos[2]].v += Op->f4_vi_Compressed[1][index].v * ( f4_curr[0][pos[0]][pos[1]][pos[2]].v - f4_curr[0][pos[0]][pos[1]][pos[2]-1].v - f4_curr[2][pos[0]][pos[1]][pos[2]].v + f4_curr[2][pos[0]-shift[0]][pos[1]][pos[2]].v);
+
+ // z-polarization
+ f4_volt[2][pos[0]][pos[1]][pos[2]].v *= Op->f4_vv_Compressed[2][index].v;
+ f4_volt[2][pos[0]][pos[1]][pos[2]].v += Op->f4_vi_Compressed[2][index].v * ( f4_curr[1][pos[0]][pos[1]][pos[2]].v - f4_curr[1][pos[0]-shift[0]][pos[1]][pos[2]].v - f4_curr[0][pos[0]][pos[1]][pos[2]].v + f4_curr[0][pos[0]][pos[1]-shift[1]][pos[2]].v);
+ }
+
+ // for pos[2] = 0
+ // x-polarization
+ index = Op->m_Op_index[pos[0]][pos[1]][0];
+#ifdef __SSE2__
+ temp.v = (__m128)_mm_slli_si128( (__m128i)f4_curr[1][pos[0]][pos[1]][numVectors-1].v, 4 );
+#else
+ temp.f[0] = 0;
+ temp.f[1] = f4_curr[1][pos[0]][pos[1]][numVectors-1].f[0];
+ temp.f[2] = f4_curr[1][pos[0]][pos[1]][numVectors-1].f[1];
+ temp.f[3] = f4_curr[1][pos[0]][pos[1]][numVectors-1].f[2];
+#endif
+ f4_volt[0][pos[0]][pos[1]][0].v *= Op->f4_vv_Compressed[0][index].v;
+ f4_volt[0][pos[0]][pos[1]][0].v += Op->f4_vi_Compressed[0][index].v * ( f4_curr[2][pos[0]][pos[1]][0].v - f4_curr[2][pos[0]][pos[1]-shift[1]][0].v - f4_curr[1][pos[0]][pos[1]][0].v + temp.v );
+
+ // y-polarization
+#ifdef __SSE2__
+ temp.v = (__m128)_mm_slli_si128( (__m128i)f4_curr[0][pos[0]][pos[1]][numVectors-1].v, 4 );
+#else
+ temp.f[0] = 0;
+ temp.f[1] = f4_curr[0][pos[0]][pos[1]][numVectors-1].f[0];
+ temp.f[2] = f4_curr[0][pos[0]][pos[1]][numVectors-1].f[1];
+ temp.f[3] = f4_curr[0][pos[0]][pos[1]][numVectors-1].f[2];
+#endif
+ f4_volt[1][pos[0]][pos[1]][0].v *= Op->f4_vv_Compressed[1][index].v;
+ f4_volt[1][pos[0]][pos[1]][0].v += Op->f4_vi_Compressed[1][index].v * ( f4_curr[0][pos[0]][pos[1]][0].v - temp.v - f4_curr[2][pos[0]][pos[1]][0].v + f4_curr[2][pos[0]-shift[0]][pos[1]][0].v);
+
+ // z-polarization
+ f4_volt[2][pos[0]][pos[1]][0].v *= Op->f4_vv_Compressed[2][index].v;
+ f4_volt[2][pos[0]][pos[1]][0].v += Op->f4_vi_Compressed[2][index].v * ( f4_curr[1][pos[0]][pos[1]][0].v - f4_curr[1][pos[0]-shift[0]][pos[1]][0].v - f4_curr[0][pos[0]][pos[1]][0].v + f4_curr[0][pos[0]][pos[1]-shift[1]][0].v);
+ }
+ ++pos[0];
+ }
+}
+
+void Engine_SSE_Compressed::UpdateCurrents(unsigned int startX, unsigned int numX)
+{
+ unsigned int pos[3];
+ f4vector temp;
+
+ pos[0] = startX;
+ unsigned int index;
+ for (unsigned int posX=0; posX<numX; ++posX)
+ {
+ for (pos[1]=0; pos[1]<numLines[1]-1; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numVectors-1; ++pos[2])
+ {
+ index = Op->m_Op_index[pos[0]][pos[1]][pos[2]];
+ // x-pol
+ f4_curr[0][pos[0]][pos[1]][pos[2]].v *= Op->f4_ii_Compressed[0][index].v;
+ f4_curr[0][pos[0]][pos[1]][pos[2]].v += Op->f4_iv_Compressed[0][index].v * ( f4_volt[2][pos[0]][pos[1]][pos[2]].v - f4_volt[2][pos[0]][pos[1]+1][pos[2]].v - f4_volt[1][pos[0]][pos[1]][pos[2]].v + f4_volt[1][pos[0]][pos[1]][pos[2]+1].v);
+
+ // y-pol
+ f4_curr[1][pos[0]][pos[1]][pos[2]].v *= Op->f4_ii_Compressed[1][index].v;
+ f4_curr[1][pos[0]][pos[1]][pos[2]].v += Op->f4_iv_Compressed[1][index].v * ( f4_volt[0][pos[0]][pos[1]][pos[2]].v - f4_volt[0][pos[0]][pos[1]][pos[2]+1].v - f4_volt[2][pos[0]][pos[1]][pos[2]].v + f4_volt[2][pos[0]+1][pos[1]][pos[2]].v);
+
+ // z-pol
+ f4_curr[2][pos[0]][pos[1]][pos[2]].v *= Op->f4_ii_Compressed[2][index].v;
+ f4_curr[2][pos[0]][pos[1]][pos[2]].v += Op->f4_iv_Compressed[2][index].v * ( f4_volt[1][pos[0]][pos[1]][pos[2]].v - f4_volt[1][pos[0]+1][pos[1]][pos[2]].v - f4_volt[0][pos[0]][pos[1]][pos[2]].v + f4_volt[0][pos[0]][pos[1]+1][pos[2]].v);
+ }
+
+ index = Op->m_Op_index[pos[0]][pos[1]][numVectors-1];
+ // for pos[2] = numVectors-1
+ // x-pol
+#ifdef __SSE2__
+ temp.v = (__m128)_mm_srli_si128( (__m128i)f4_volt[1][pos[0]][pos[1]][0].v, 4 );
+#else
+ temp.f[0] = f4_volt[1][pos[0]][pos[1]][0].f[1];
+ temp.f[1] = f4_volt[1][pos[0]][pos[1]][0].f[2];
+ temp.f[2] = f4_volt[1][pos[0]][pos[1]][0].f[3];
+ temp.f[3] = 0;
+#endif
+ f4_curr[0][pos[0]][pos[1]][numVectors-1].v *= Op->f4_ii_Compressed[0][index].v;
+ f4_curr[0][pos[0]][pos[1]][numVectors-1].v += Op->f4_iv_Compressed[0][index].v * ( f4_volt[2][pos[0]][pos[1]][numVectors-1].v - f4_volt[2][pos[0]][pos[1]+1][numVectors-1].v - f4_volt[1][pos[0]][pos[1]][numVectors-1].v + temp.v);
+
+ // y-pol
+#ifdef __SSE2__
+ temp.v = (__m128)_mm_srli_si128( (__m128i)f4_volt[0][pos[0]][pos[1]][0].v, 4 );
+#else
+ temp.f[0] = f4_volt[0][pos[0]][pos[1]][0].f[1];
+ temp.f[1] = f4_volt[0][pos[0]][pos[1]][0].f[2];
+ temp.f[2] = f4_volt[0][pos[0]][pos[1]][0].f[3];
+ temp.f[3] = 0;
+#endif
+ f4_curr[1][pos[0]][pos[1]][numVectors-1].v *= Op->f4_ii_Compressed[1][index].v;
+ f4_curr[1][pos[0]][pos[1]][numVectors-1].v += Op->f4_iv_Compressed[1][index].v * ( f4_volt[0][pos[0]][pos[1]][numVectors-1].v - temp.v - f4_volt[2][pos[0]][pos[1]][numVectors-1].v + f4_volt[2][pos[0]+1][pos[1]][numVectors-1].v);
+
+ // z-pol
+ f4_curr[2][pos[0]][pos[1]][numVectors-1].v *= Op->f4_ii_Compressed[2][index].v;
+ f4_curr[2][pos[0]][pos[1]][numVectors-1].v += Op->f4_iv_Compressed[2][index].v * ( f4_volt[1][pos[0]][pos[1]][numVectors-1].v - f4_volt[1][pos[0]+1][pos[1]][numVectors-1].v - f4_volt[0][pos[0]][pos[1]][numVectors-1].v + f4_volt[0][pos[0]][pos[1]+1][numVectors-1].v);
+ }
+ ++pos[0];
+ }
+}
diff --git a/openEMS/FDTD/engine_sse_compressed.h b/openEMS/FDTD/engine_sse_compressed.h
new file mode 100644
index 0000000..ab86cc8
--- /dev/null
+++ b/openEMS/FDTD/engine_sse_compressed.h
@@ -0,0 +1,38 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_SSE_COMPRESSED_H
+#define ENGINE_SSE_COMPRESSED_H
+
+#include "engine_sse.h"
+#include "operator_sse_compressed.h"
+
+class Engine_SSE_Compressed : public Engine_sse
+{
+public:
+ static Engine_SSE_Compressed* New(const Operator_SSE_Compressed* op);
+ virtual ~Engine_SSE_Compressed();
+
+protected:
+ Engine_SSE_Compressed(const Operator_SSE_Compressed* op);
+ const Operator_SSE_Compressed* Op;
+
+ virtual void UpdateVoltages(unsigned int startX, unsigned int numX);
+ virtual void UpdateCurrents(unsigned int startX, unsigned int numX);
+};
+
+#endif // ENGINE_SSE_COMPRESSED_H
diff --git a/openEMS/FDTD/excitation.cpp b/openEMS/FDTD/excitation.cpp
new file mode 100644
index 0000000..f095b53
--- /dev/null
+++ b/openEMS/FDTD/excitation.cpp
@@ -0,0 +1,304 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "tools/array_ops.h"
+#include "tools/useful.h"
+#include <iostream>
+#include <fstream>
+#include "fparser.hh"
+#include "excitation.h"
+
+using namespace std;
+
+Excitation::Excitation()
+{
+ Signal_volt = 0;
+ Signal_curr = 0;
+
+ this->Reset(0);
+
+ m_Excit_Type = Excitation::UNDEFINED;
+ m_SignalPeriod = 0;
+}
+
+Excitation::~Excitation()
+{
+ this->Reset(0);
+}
+
+void Excitation::Reset( double timestep )
+{
+ delete[] Signal_volt;
+ Signal_volt = 0;
+ delete[] Signal_curr;
+ Signal_curr = 0;
+
+ dT = timestep;
+ m_nyquistTS = 0;
+ m_f_max = 0;
+ m_foi = 0;
+}
+
+bool Excitation::SetupGaussianPulse(double f0, double fc)
+{
+ m_Excit_Type = Excitation::GaissianPulse;
+ m_f0 = f0;
+ m_fc = fc;
+ m_f_max = f0+fc;
+ m_SignalPeriod = 0;
+}
+
+bool Excitation::SetupSinusoidal(double f0)
+{
+ m_Excit_Type = Excitation::Sinusoidal;
+ m_f0 = f0;
+ m_f_max = f0;
+ m_SignalPeriod = 1/f0;
+}
+
+bool Excitation::SetupDiracPulse(double fmax)
+{
+ m_Excit_Type = Excitation::DiracPulse;
+ m_SignalPeriod = 0;
+ m_f_max = fmax;
+}
+
+bool Excitation::SetupStepExcite(double fmax)
+{
+ m_Excit_Type = Excitation::Step;
+ m_SignalPeriod = 0;
+ m_f_max = fmax;
+}
+
+bool Excitation::SetupCustomExcite(string str, double f0, double fmax)
+{
+ m_Excit_Type = Excitation::CustomExcite;
+ m_CustomExc_Str = str;
+ m_f0 = f0;
+ m_SignalPeriod = 0;
+ m_f_max = fmax;
+}
+
+bool Excitation::buildExcitationSignal(unsigned int maxTS)
+{
+ if (dT<=0)
+ {
+ cerr << "Excitation::setupExcitation: Error, invalid timestep... " << endl;
+ return false;
+ }
+
+ switch (m_Excit_Type)
+ {
+ case Excitation::GaissianPulse:
+ CalcGaussianPulsExcitation(m_f0,m_fc,maxTS);
+ break;
+ case Excitation::Sinusoidal:
+ CalcSinusExcitation(m_f0,maxTS);
+ break;
+ case Excitation::DiracPulse:
+ CalcDiracPulsExcitation();
+ break;
+ case Excitation::Step:
+ CalcStepExcitation();
+ break;
+ case Excitation::CustomExcite:
+ CalcCustomExcitation(m_f0,maxTS,m_CustomExc_Str);
+ break;
+ default:
+ cerr << "Excitation::buildExcitationSignal: Unknown excitation type: \"" << m_Excit_Type<< "\" !!" << endl;
+ m_Excit_Type = Excitation::UNDEFINED;
+ return false;
+ }
+
+ if (GetNyquistNum() == 0)
+ {
+ cerr << "Excitation::buildExcitationSignal: Unknown error... excitation setup failed!!" << endl;
+ return false;
+ }
+
+ return true;
+}
+
+unsigned int Excitation::GetMaxExcitationTimestep() const
+{
+ FDTD_FLOAT maxAmp=0;
+ unsigned int maxStep=0;
+ for (unsigned int n=1; n<Length+1; ++n)
+ {
+ if (fabs(Signal_volt[n])>maxAmp)
+ {
+ maxAmp = fabs(Signal_volt[n]);
+ maxStep = n;
+ }
+ }
+ return maxStep;
+}
+
+void Excitation::CalcGaussianPulsExcitation(double f0, double fc, int nTS)
+{
+ if (dT==0) return;
+
+ Length = (unsigned int)(2.0 * 9.0/(2.0*PI*fc) / dT);
+ if (Length>(unsigned int)nTS)
+ {
+ cerr << "Operator::CalcGaussianPulsExcitation: Requested excitation pusle would be " << Length << " timesteps or " << Length * dT << " s long. Cutting to max number of timesteps!" << endl;
+ Length=(unsigned int)nTS;
+ }
+ delete[] Signal_volt;
+ delete[] Signal_curr;
+ Signal_volt = new FDTD_FLOAT[Length+1];
+ Signal_curr = new FDTD_FLOAT[Length+1];
+ Signal_volt[0]=0.0;
+ Signal_curr[0]=0.0;
+ for (unsigned int n=1; n<Length+1; ++n)
+ {
+ double t = (n-1)*dT;
+ Signal_volt[n] = cos(2.0*PI*f0*(t-9.0/(2.0*PI*fc)))*exp(-1*pow(2.0*PI*fc*t/3.0-3,2));
+ t += 0.5*dT;
+ Signal_curr[n] = cos(2.0*PI*f0*(t-9.0/(2.0*PI*fc)))*exp(-1*pow(2.0*PI*fc*t/3.0-3,2));
+ }
+
+ m_foi = f0;
+ m_f_max = f0+fc;
+
+ SetNyquistNum( CalcNyquistNum(f0+fc,dT) );
+}
+
+void Excitation::CalcDiracPulsExcitation()
+{
+ if (dT==0) return;
+
+ Length = 1;
+// cerr << "Operator::CalcDiracPulsExcitation: Length of the excite signal: " << ExciteLength << " timesteps" << endl;
+ delete[] Signal_volt;
+ delete[] Signal_curr;
+ Signal_volt = new FDTD_FLOAT[Length+1];
+ Signal_curr = new FDTD_FLOAT[Length+1];
+ Signal_volt[0]=0.0;
+ Signal_volt[1]=1.0;
+ Signal_curr[0]=0.0;
+ Signal_curr[1]=1.0;
+
+ m_foi = 0;
+ m_f_max = 0;
+
+ SetNyquistNum( 1 );
+}
+
+void Excitation::CalcStepExcitation()
+{
+ if (dT==0) return;
+
+ Length = 1;
+ delete[] Signal_volt;
+ delete[] Signal_curr;
+ Signal_volt = new FDTD_FLOAT[Length+1];
+ Signal_curr = new FDTD_FLOAT[Length+1];
+ Signal_volt[0]=1.0;
+ Signal_volt[1]=1.0;
+ Signal_curr[0]=1.0;
+ Signal_curr[1]=1.0;
+
+ m_foi = 0;
+ m_f_max = 0;
+
+ SetNyquistNum( 1 );
+}
+
+void Excitation::CalcCustomExcitation(double f0, int nTS, string signal)
+{
+ if (dT==0) return;
+ if (nTS<=0) return;
+
+ Length = (unsigned int)(nTS);
+// cerr << "Operator::CalcSinusExcitation: Length of the excite signal: " << ExciteLength << " timesteps" << endl;
+ delete[] Signal_volt;
+ delete[] Signal_curr;
+ Signal_volt = new FDTD_FLOAT[Length+1];
+ Signal_curr = new FDTD_FLOAT[Length+1];
+ Signal_volt[0]=0.0;
+ Signal_curr[0]=0.0;
+ FunctionParser fParse;
+ fParse.AddConstant("pi", 3.14159265358979323846);
+ fParse.AddConstant("e", 2.71828182845904523536);
+ fParse.Parse(signal,"t");
+ if (fParse.GetParseErrorType()!=FunctionParser::FP_NO_ERROR)
+ {
+ cerr << "Operator::CalcCustomExcitation: Function Parser error: " << fParse.ErrorMsg() << endl;
+ exit(1);
+ }
+ double vars[1];
+ for (unsigned int n=1; n<Length+1; ++n)
+ {
+ vars[0] = (n-1)*dT;
+ Signal_volt[n] = fParse.Eval(vars);
+ vars[0] += 0.5*dT;
+ Signal_curr[n] = fParse.Eval(vars);
+ }
+
+ m_f_max = f0;
+ m_foi = f0;
+ SetNyquistNum( CalcNyquistNum(f0,dT) );
+}
+
+void Excitation::CalcSinusExcitation(double f0, int nTS)
+{
+ if (dT==0) return;
+ if (nTS<=0) return;
+
+ Length = (unsigned int)(2.0/f0/dT);
+ //cerr << "Operator::CalcSinusExcitation: Length of the excite signal: " << Length << " timesteps " << Length*dT << "s" << endl;
+ delete[] Signal_volt;
+ delete[] Signal_curr;
+ Signal_volt = new FDTD_FLOAT[Length+1];
+ Signal_curr = new FDTD_FLOAT[Length+1];
+ Signal_volt[0]=0.0;
+ Signal_curr[0]=0.0;
+ for (unsigned int n=1; n<Length+1; ++n)
+ {
+ double t = (n-1)*dT;
+ Signal_volt[n] = sin(2.0*PI*f0*t);
+ t += 0.5*dT;
+ Signal_curr[n] = sin(2.0*PI*f0*t);
+ }
+ m_f_max = f0;
+ m_foi = f0;
+ SetNyquistNum( CalcNyquistNum(f0,dT) );
+}
+
+void Excitation::DumpVoltageExcite(string filename)
+{
+ ofstream file;
+ file.open( filename.c_str() );
+ if (file.fail())
+ return;
+ for (unsigned int n=1; n<Length+1; ++n)
+ file << (n-1)*dT << "\t" << Signal_volt[n] << "\n";
+ file.close();
+}
+
+void Excitation::DumpCurrentExcite(string filename)
+{
+ ofstream file;
+ file.open( filename.c_str() );
+ if (file.fail())
+ return;
+ for (unsigned int n=1; n<Length+1; ++n)
+ file << (n-1)*dT + 0.5*dT << "\t" << Signal_curr[n] << "\n";
+ file.close();
+}
+
diff --git a/openEMS/FDTD/excitation.h b/openEMS/FDTD/excitation.h
new file mode 100644
index 0000000..8ae3a5b
--- /dev/null
+++ b/openEMS/FDTD/excitation.h
@@ -0,0 +1,115 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 EXCITATION_H
+#define EXCITATION_H
+
+#include <vector>
+#include <string>
+#include "tools/constants.h"
+
+class Excitation
+{
+public:
+ enum ExciteTypes {UNDEFINED=-1, GaissianPulse=0, Sinusoidal=1, DiracPulse=2, Step=3, CustomExcite=10};
+ Excitation();
+ virtual ~Excitation();
+
+ virtual void Reset( double timestep );
+
+ bool SetupGaussianPulse(double f0, double fc);
+ bool SetupSinusoidal(double f0);
+ bool SetupDiracPulse(double fmax);
+ bool SetupStepExcite(double fmax);
+ bool SetupCustomExcite(std::string str, double f0, double fmax);
+
+ double GetCenterFreq() {return m_f0;}
+ double GetCutOffFreq() {return m_fc;}
+ double GetMaxFreq() {return m_f_max;}
+
+ bool buildExcitationSignal(unsigned int maxTS);
+
+ //! Get the excitation timestep with the (first) max amplitude
+ virtual unsigned int GetMaxExcitationTimestep() const;
+
+ void SetNyquistNum(unsigned int nyquist) {m_nyquistTS=nyquist;}
+ unsigned int GetNyquistNum() const {return m_nyquistTS;}
+
+ //! Dump voltage excitation signal to ASCII file
+ void DumpVoltageExcite(std::string filename);
+
+ //! Dump current excitation signal to ASCII file
+ void DumpCurrentExcite(std::string filename);
+
+ //! Get the used timestep
+ double GetTimestep() const {return dT;}
+
+ //! Get the type of excitation
+ int GetExciteType() const {return m_Excit_Type;}
+
+ //! Get the length of the excitation signal
+ unsigned int GetLength() const {return Length;}
+
+ //! Get the max frequeny excited by this signal
+ double GetMaxFrequency() const {return m_f_max;}
+
+ //! Get the frequency of interest
+ double GetFrequencyOfInterest() const {return m_foi;}
+
+ //! Get the signal period, 0 if not a periodical signal
+ double GetSignalPeriod() const {return m_SignalPeriod;}
+
+ FDTD_FLOAT* GetVoltageSignal() const {return Signal_volt;}
+ FDTD_FLOAT* GetCurrentSignal() const {return Signal_curr;}
+
+protected:
+ double dT;
+ unsigned int m_nyquistTS;
+ double m_SignalPeriod;
+ ExciteTypes m_Excit_Type;
+
+ //Excitation time-signal
+ unsigned int Length;
+ FDTD_FLOAT* Signal_volt;
+ FDTD_FLOAT* Signal_curr;
+
+ // center frequency
+ double m_f0;
+
+ // cutoff-frequency (Gaussian pulse only)
+ double m_fc;
+
+ std::string m_CustomExc_Str;
+
+ // max frequency
+ double m_f_max;
+ // frequency of interest
+ double m_foi;
+
+ //! Calculate a custom signal
+ virtual void CalcCustomExcitation(double f0, int nTS, std::string signal);
+ //! Calculate an excitation with center of \a f0 and the half bandwidth \a fc
+ virtual void CalcGaussianPulsExcitation(double f0, double fc, int nTS);
+ //! Calculate a sinusoidal excitation with frequency \a f0 and a duration of \a nTS number of timesteps
+ virtual void CalcSinusExcitation(double f0, int nTS);
+ //! Calculate a dirac impuls excitation
+ virtual void CalcDiracPulsExcitation();
+ //! Calculate a step excitation
+ virtual void CalcStepExcitation();
+};
+
+#endif // EXCITATION_H
diff --git a/openEMS/FDTD/extensions/CMakeLists.txt b/openEMS/FDTD/extensions/CMakeLists.txt
new file mode 100644
index 0000000..3566944
--- /dev/null
+++ b/openEMS/FDTD/extensions/CMakeLists.txt
@@ -0,0 +1,32 @@
+
+#INCLUDE_DIRECTORIES( ${openEMS_SOURCE_DIR} )
+#INCLUDE_DIRECTORIES( ${CSXCAD_SOURCE_DIR}/src )
+
+set(SOURCES
+ ${SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_extension.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_ext_dispersive.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_ext_lorentzmaterial.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_ext_conductingsheet.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_ext_dispersive.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_ext_lorentzmaterial.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_ext_cylindermultigrid.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_ext_upml.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_ext_upml.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_extension.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_ext_mur_abc.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_ext_mur_abc.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_ext_cylinder.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_ext_cylinder.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_ext_excitation.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_ext_excitation.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_ext_tfsf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_ext_tfsf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/operator_ext_steadystate.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/engine_ext_steadystate.cpp
+ PARENT_SCOPE
+)
+
+# FDTD/extensions lib
+#add_library( extensions STATIC ${SOURCES} )
+
diff --git a/openEMS/FDTD/extensions/OptimizeCondSheetParameter.m b/openEMS/FDTD/extensions/OptimizeCondSheetParameter.m
new file mode 100644
index 0000000..12ac8ec
--- /dev/null
+++ b/openEMS/FDTD/extensions/OptimizeCondSheetParameter.m
@@ -0,0 +1,107 @@
+function OptimizeCondSheetParameter
+% function OptimizeCondSheetParameter
+%
+% internal openEMS function to create the "cond_sheet_parameter.h" header
+% file containing optimized parameter values for the conducting sheet model
+%
+% (c) 2012: Thorsten Liebig, thorsten.liebig@gmx.de
+
+
+close all
+clear
+clc
+
+
+X = [1 1 1 1 1];
+lb = zeros(size(X));
+ub = ones(size(X))*1000;
+
+
+Omega = linspace(0,20,51);
+Omega = Omega(2:end);
+
+Omega_fine = linspace(0,20,15001);
+Omega_fine = Omega_fine(2:end);
+
+options = optimset('fzero');
+% options = optimset(options,'Display','iter')
+options = optimset(options,'MaxFunEvals',5000);
+options = optimset(options,'MaxIter',5000);
+
+omg_stop_str = [];
+omg_critical_20 = [];
+omg_critical_5 = [];
+g_str = [];
+r1_str= [];
+r2_str= [];
+l1_str= [];
+l2_str= [];
+
+numPara = 30;
+factor = 1.5;
+
+for p = 1:numPara
+
+ X = lsqnonlin(@(X)CalcYDiff(Omega,X),X,lb,ub,options);
+
+ omg_stop_str = [omg_stop_str num2str(Omega(end),10) ','];
+ g_str = [g_str num2str(X(1),10) ','];
+ r1_str = [r1_str num2str(X(2),10) ','];
+ l1_str = [l1_str num2str(X(3),10) ','];
+ r2_str = [r2_str num2str(X(4),10) ','];
+ l2_str = [l2_str num2str(X(5),10) ','];
+
+ Ys = tanh((1+1j)*sqrt(Omega_fine))/(1+1j)./sqrt(Omega_fine);
+
+ err = (CalcYDiff(Omega_fine,X))./real(1./Ys);
+
+ fc = Omega_fine(find(abs(err)>0.2,1,'last'));
+ if (isempty(fc))
+ fc = 0;
+ end
+ omg_critical_20 = [omg_critical_20 num2str(fc,10) ','];
+
+ fc = Omega_fine(find(abs(err)>0.05,1,'last'));
+ if (isempty(fc))
+ fc = 0;
+ end
+ omg_critical_5 = [omg_critical_5 num2str(fc,10) ','];
+
+% disp(['max error: ' num2str(max(abs(err)*100)) ])
+% figure
+% plot(Omega_fine,err*100,'g--');
+
+ Omega_fine = Omega_fine*factor;
+ Omega = Omega*factor;
+end
+
+%% write to file
+fid = fopen('cond_sheet_parameter.h','w');
+
+fprintf(fid,'// This is a list of conducting sheet model parameter for different ranges of omega = w/w0\n');
+fprintf(fid,'// This file was created automatically using Matlab: OptimizeCondSheetParameter.m \n');
+fprintf(fid,'// Do not change this file! \n');
+fprintf(fid,'// Creation: %s \n\n',datestr(now));
+
+
+
+fprintf(fid,'unsigned int numOptPara=%d;\n',numPara);
+
+fprintf(fid,'double omega_stop[%d]={%s};\n',numPara,omg_stop_str(1:end-1));
+fprintf(fid,'double omega_critical_5[%d]={%s};\n',numPara,omg_critical_5(1:end-1));
+fprintf(fid,'double omega_critical_20[%d]={%s};\n',numPara,omg_critical_20(1:end-1));
+fprintf(fid,'double g[%d]={%s};\n',numPara,g_str(1:end-1));
+fprintf(fid,'double r1[%d]={%s};\n',numPara,r1_str(1:end-1));
+fprintf(fid,'double l1[%d]={%s};\n',numPara,l1_str(1:end-1));
+fprintf(fid,'double r2[%d]={%s};\n',numPara,r2_str(1:end-1));
+fprintf(fid,'double l2[%d]={%s};\n',numPara,l2_str(1:end-1));
+
+fclose(fid);
+
+function Ydiff = CalcYDiff(omega, X)
+
+Ys = tanh((1+1j)*sqrt(omega))/(1+1j)./sqrt(omega);
+
+Y = X(1) + 1./(X(2)+1j*omega*X(3)) + 1./(X(4)+1j*omega*X(5));
+
+Ydiff = real(1./Ys)-real(1./Y); \ No newline at end of file
diff --git a/openEMS/FDTD/extensions/cond_sheet_parameter.h b/openEMS/FDTD/extensions/cond_sheet_parameter.h
new file mode 100644
index 0000000..b3fc77b
--- /dev/null
+++ b/openEMS/FDTD/extensions/cond_sheet_parameter.h
@@ -0,0 +1,14 @@
+// This is a list of conducting sheet model parameter for different ranges of omega = w/w0
+// This file was created automatically using Matlab: OptimizeCondSheetParameter.m
+// Do not change this file!
+// Creation: 08-May-2012 09:49:53
+
+unsigned int numOptPara=30;
+double omega_stop[30]={20,30,45,67.5,101.25,151.875,227.8125,341.71875,512.578125,768.8671875,1153.300781,1729.951172,2594.926758,3892.390137,5838.585205,8757.877808,13136.81671,19705.22507,29557.8376,44336.7564,66505.1346,99757.7019,149636.5529,224454.8293,336682.2439,505023.3659,757535.0488,1136302.573,1704453.86,2556680.79};
+double omega_critical_5[30]={0,0,0,1.566,6.8445,10.4085,15.1419375,22.30284375,33.45426562,50.28391406,75.42587109,113.1388066,169.70821,254.5623149,381.8434724,572.7652086,859.1478129,1288.721719,1933.082579,2899.623869,4349.435803,6524.153704,9786.230557,14679.34583,22019.01875,33028.52813,35503.14262,119084.5097,180444.8486,704280.3349};
+double omega_critical_20[30]={0,0,0,0,1.41075,2.7135,4.100625,5.90034375,8.6113125,12.86571094,19.37545312,29.06317969,43.59476953,65.3921543,98.08823145,147.1323472,220.6985208,331.0477811,496.5716717,744.8575075,1117.286261,1675.929392,2513.894088,3770.841132,5656.261698,8484.392547,10504.48601,11363.02573,11135.76522,7499.596983};
+double g[30]={0.1370843401,0.1244327709,0.1087425925,0.09215450299,0.07639249525,0.06239206861,0.05068701937,0.04124161681,0.03364925947,0.0274825647,0.02244156564,0.01832317373,0.01496080786,0.01221545053,0.009973874666,0.008143635713,0.006649251918,0.005429092739,0.00443283702,0.003619397792,0.002955227653,0.002412935361,0.001970156167,0.001608629812,0.001313423397,0.001072422468,0.0009031383439,0.0007674973627,0.0006482579571,0.0005450699565};
+double r1[30]={1.302754546,1.2992612,1.320033314,1.41829213,1.674326257,2.138770494,2.769126112,3.498802047,4.311446869,5.266204065,6.443980095,7.893402541,9.667414736,11.84010502,14.50110421,17.76014698,21.75163911,26.64019322,32.6274156,39.96021835,48.94100192,59.94011376,73.41109983,89.90930992,110.1195785,134.8631576,149.2770459,153.5258961,148.9373215,119.3522908};
+double l1[30]={0.9542567116,0.9412051444,0.8999655165,0.8189903271,0.702028543,0.5718817624,0.4577262324,0.3689027719,0.3004106661,0.2455514861,0.2005633225,0.1637496639,0.1337010005,0.1091664663,0.0891340699,0.07277768839,0.05942276018,0.04851850861,0.03961522618,0.03234573021,0.02641021614,0.02156389712,0.0176069076,0.01437606898,0.0117376269,0.009584103516,0.008750848841,0.008547706786,0.00854127488,0.008801399365};
+double r2[30]={10.62245057,10.21952962,10.24755832,10.99147713,12.70450822,15.59830718,19.55714986,24.32580904,29.88733852,36.55680626,44.75374078,54.81575133,67.13533424,82.22360504,100.7029064,123.3353165,151.0542147,185.0027444,226.5809553,277.5035137,339.8704104,416.2534638,509.8022059,624.3729288,764.7279941,936.5525496,1000,999.9999981,999.999984,999.9999985};
+double l2[30]={0.7925524826,0.6926195458,0.5814718257,0.4784644339,0.3916667501,0.3204661897,0.2620413998,0.2140939121,0.1748272154,0.1427375388,0.1165424396,0.09515681664,0.07769522035,0.06343788358,0.05179681795,0.04229192785,0.03453121766,0.02819462457,0.0230208182,0.01879642336,0.01534721999,0.01253095815,0.01023149158,0.008353988465,0.006820957973,0.005569332359,0.004553963932,0.003696380632,0.002978504727,0.002391295771};
diff --git a/openEMS/FDTD/extensions/engine_ext_cylinder.cpp b/openEMS/FDTD/extensions/engine_ext_cylinder.cpp
new file mode 100644
index 0000000..e240f1b
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_cylinder.cpp
@@ -0,0 +1,101 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "FDTD/engine.h"
+#include "engine_ext_cylinder.h"
+#include "operator_ext_cylinder.h"
+#include "FDTD/engine_sse.h"
+
+Engine_Ext_Cylinder::Engine_Ext_Cylinder(Operator_Ext_Cylinder* op_ext) : Engine_Extension(op_ext)
+{
+ cyl_Op = op_ext;
+ m_Eng_SSE = NULL;
+
+ CC_closedAlpha = op_ext->CC_closedAlpha;
+ CC_R0_included = op_ext->CC_R0_included;
+
+ for (int n=0; n<3; ++n)
+ numLines[n] = op_ext->m_Op->GetNumberOfLines(n,true);
+
+ //this cylindrical extension should be executed first?
+ m_Priority = ENG_EXT_PRIO_CYLINDER;
+}
+
+void Engine_Ext_Cylinder::SetEngine(Engine* eng)
+{
+ Engine_Extension::SetEngine(eng);
+ m_Eng_SSE = dynamic_cast<Engine_sse*>(m_Eng);
+}
+
+void Engine_Ext_Cylinder::DoPostVoltageUpdates()
+{
+ if (CC_closedAlpha==false) return;
+
+ if (CC_R0_included)
+ {
+ unsigned int pos[3];
+ pos[0] = 0;
+ FDTD_FLOAT volt=0;
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ volt =m_Eng_SSE->Engine_sse::GetVolt(2,0,0,pos[2])*cyl_Op->vv_R0[pos[2]];
+ for (pos[1]=0; pos[1]<numLines[1]-1; ++pos[1])
+ volt +=cyl_Op->vi_R0[pos[2]] * m_Eng_SSE->Engine_sse::GetCurr(1,0,pos[1],pos[2]);
+ m_Eng_SSE->Engine_sse::SetVolt(2,0,0,pos[2], volt);
+ }
+
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ m_Eng_SSE->Engine_sse::SetVolt(1,0,pos[1],pos[2], 0); //no voltage in alpha-direction at r=0
+ m_Eng_SSE->Engine_sse::SetVolt(2,0,pos[1],pos[2], m_Eng_SSE->Engine_sse::GetVolt(2,0,0,pos[2]) );
+ }
+ }
+ }
+
+ //close alpha
+ unsigned int pos[3];
+ // copy tangential voltages from last alpha-plane to first
+ unsigned int last_A_Line = numLines[1]-2;
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ m_Eng_SSE->Engine_sse::SetVolt(0,pos[0],0,pos[2], m_Eng_SSE->Engine_sse::GetVolt(0,pos[0],last_A_Line,pos[2]) );
+ m_Eng_SSE->Engine_sse::SetVolt(2,pos[0],0,pos[2], m_Eng_SSE->Engine_sse::GetVolt(2,pos[0],last_A_Line,pos[2]) );
+ }
+ }
+}
+
+void Engine_Ext_Cylinder::DoPostCurrentUpdates()
+{
+ if (CC_closedAlpha==false) return;
+
+ //close alpha
+ unsigned int pos[3];
+ // copy tangential currents from first alpha-plane to last
+ for (pos[0]=0; pos[0]<numLines[0]-1; ++pos[0])
+ {
+ unsigned int last_A_Line = numLines[1]-2;
+ for (pos[2]=0; pos[2]<numLines[2]-1; ++pos[2])
+ {
+ m_Eng_SSE->Engine_sse::SetCurr(0,pos[0],last_A_Line,pos[2], m_Eng_SSE->Engine_sse::GetCurr(0,pos[0],0,pos[2]) );
+ m_Eng_SSE->Engine_sse::SetCurr(2,pos[0],last_A_Line,pos[2], m_Eng_SSE->Engine_sse::GetCurr(2,pos[0],0,pos[2]) );
+ }
+ }
+}
diff --git a/openEMS/FDTD/extensions/engine_ext_cylinder.h b/openEMS/FDTD/extensions/engine_ext_cylinder.h
new file mode 100644
index 0000000..c996a9d
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_cylinder.h
@@ -0,0 +1,49 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_CYLINDER_H
+#define ENGINE_CYLINDER_H
+
+#include "FDTD/engine.h"
+#include "engine_extension.h"
+#include "FDTD/operator_cylinder.h"
+
+class Operator_Ext_Cylinder;
+class Engine_sse;
+
+class Engine_Ext_Cylinder : public Engine_Extension
+{
+public:
+ Engine_Ext_Cylinder(Operator_Ext_Cylinder* op_ext);
+
+ virtual void DoPostVoltageUpdates();
+
+ virtual void DoPostCurrentUpdates();
+
+ virtual void SetEngine(Engine* eng);
+
+protected:
+ Operator_Ext_Cylinder* cyl_Op;
+ Engine_sse* m_Eng_SSE;
+
+ unsigned int numLines[3];
+
+ bool CC_closedAlpha;
+ bool CC_R0_included;
+};
+
+#endif // ENGINE_CYLINDER_H
diff --git a/openEMS/FDTD/extensions/engine_ext_cylindermultigrid.cpp b/openEMS/FDTD/extensions/engine_ext_cylindermultigrid.cpp
new file mode 100644
index 0000000..eca2c9e
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_cylindermultigrid.cpp
@@ -0,0 +1,165 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "FDTD/engine.h"
+#include "engine_ext_cylindermultigrid.h"
+#include "FDTD/engine_cylindermultigrid.h"
+
+Engine_Ext_CylinderMultiGrid::Engine_Ext_CylinderMultiGrid(Operator_Extension* op_ext, bool isBase) : Engine_Extension(op_ext)
+{
+ m_IsBase = isBase;
+ m_Eng_MG = NULL;
+
+ // the multi-grid should be applies last?
+ m_Priority = ENG_EXT_PRIO_CYLINDERMULTIGRID;
+}
+
+Engine_Ext_CylinderMultiGrid::~Engine_Ext_CylinderMultiGrid()
+{
+}
+
+void Engine_Ext_CylinderMultiGrid::SetBarrier(boost::barrier* waitBase, boost::barrier* waitChild, boost::barrier* waitSync)
+{
+ m_WaitOnBase = waitBase;
+ m_WaitOnChild = waitChild;
+ m_WaitOnSync = waitSync;
+}
+
+void Engine_Ext_CylinderMultiGrid::SetEngine(Engine* eng)
+{
+ m_Eng_MG = dynamic_cast<Engine_CylinderMultiGrid*>(eng);
+ if (m_Eng_MG==NULL)
+ {
+ cerr << "Engine_Ext_CylinderMultiGrid::SetEngine(): Error" << endl;
+ exit(0);
+ }
+}
+
+void Engine_Ext_CylinderMultiGrid::DoPreVoltageUpdates()
+{
+ //cerr << "Engine_Ext_CylinderMultiGrid::DoPreVoltageUpdates() for " << m_IsBase << endl;
+ if (!m_IsBase)
+ {
+ //cerr << "child: volt wait on base " << endl;
+ m_WaitOnBase->wait(); //wait on base to finisch current sync and/or to finisch voltage updates, than start child voltage updates
+ }
+}
+
+void Engine_Ext_CylinderMultiGrid::DoPostVoltageUpdates()
+{
+
+}
+
+void Engine_Ext_CylinderMultiGrid::Apply2Voltages()
+{
+ if (m_IsBase)
+ {
+ m_WaitOnBase->wait(); //base voltage updates are done, tell child to start its voltage updates
+ m_WaitOnChild->wait(); //wait for child to finisch its updates
+ SyncVoltages(); //child is finisch, run sync and go to current updates next
+ m_WaitOnSync->wait(); //sync is done... move on and tell child to move on...
+ }
+ else
+ {
+ m_WaitOnChild->wait(); //child is finished voltage updates, will tell base to run sync
+ m_WaitOnSync->wait(); //wait for base to finisch sync before going to wait for current updates
+ }
+}
+
+void Engine_Ext_CylinderMultiGrid::SyncVoltages()
+{
+ if (m_Eng_MG==NULL)
+ {
+ cerr << "Engine_Ext_CylinderMultiGrid::SyncVoltages: Error engine is NULL" << endl;
+ return;
+ }
+
+ unsigned int* numLines = m_Eng_MG->numLines;
+
+ Engine_Multithread* m_InnerEng = m_Eng_MG->m_InnerEngine;
+
+ //interpolate voltages from base engine to child engine...
+ unsigned int pos[3];
+ pos[0] = m_Eng_MG->Op_CMG->GetSplitPos()-1;
+ unsigned int pos1_half = 0;
+ f4vector v_null;
+ v_null.f[0] = 0;
+ v_null.f[1] = 0;
+ v_null.f[2] = 0;
+ v_null.f[3] = 0;
+ for (pos[1]=0; pos[1]<numLines[1]-1; pos[1]+=2)
+ {
+ pos1_half = pos[1]/2;
+ for (pos[2]=0; pos[2]<m_Eng_MG->numVectors; ++pos[2])
+ {
+ //r - direczion
+ m_InnerEng->f4_volt[0][pos[0]][pos1_half][pos[2]].v = v_null.v;
+
+ //z - direction
+ m_InnerEng->f4_volt[2][pos[0]][pos1_half][pos[2]].v = m_Eng_MG->f4_volt[2][pos[0]][pos[1]][pos[2]].v;
+
+ //alpha - direction
+ m_InnerEng->f4_volt[1][pos[0]][pos1_half][pos[2]].v = m_Eng_MG->f4_volt[1][pos[0]][pos[1]][pos[2]].v;
+ m_InnerEng->f4_volt[1][pos[0]][pos1_half][pos[2]].v += m_Eng_MG->f4_volt[1][pos[0]][pos[1]+1][pos[2]].v;
+ }
+ }
+}
+
+void Engine_Ext_CylinderMultiGrid::DoPreCurrentUpdates()
+{
+ //cerr << "Engine_Ext_CylinderMultiGrid::DoPreCurrentUpdates() for " << m_IsBase << endl;
+ if (!m_IsBase)
+ {
+ //cerr << "child: curr wait on base " << endl;
+ m_WaitOnBase->wait(); //wait on base to finisch voltage sync and current updates, than start child current updates
+ }
+}
+
+void Engine_Ext_CylinderMultiGrid::DoPostCurrentUpdates()
+{
+
+}
+
+void Engine_Ext_CylinderMultiGrid::Apply2Current()
+{
+ if (m_IsBase)
+ {
+ //cerr << "Base: curr wait on base done, wait on sync" << endl;
+ m_WaitOnBase->wait(); //base current updates are done, tell child to start its current updates
+ m_WaitOnChild->wait(); //wait for child to finisch its updates
+ SyncCurrents(); //child is finisch, run sync and go to voltage updates next
+ m_WaitOnSync->wait(); //sync is done... move on and tell child to move on...
+ }
+ else
+ {
+ m_WaitOnChild->wait(); //child is finished current updates, will tell base to run sync...
+ m_WaitOnSync->wait(); //wait for base to finisch sync before going to wait for next voltage updates
+ //cerr << "Child: curr done, wait on sync" << endl;
+ }
+}
+
+void Engine_Ext_CylinderMultiGrid::SyncCurrents()
+{
+ if (m_Eng_MG==NULL)
+ {
+ cerr << "Engine_Ext_CylinderMultiGrid::SyncCurrents: Error engine is NULL" << endl;
+ return;
+ }
+
+ m_Eng_MG->InterpolCurrChild2Base(m_Eng_MG->Op_CMG->GetSplitPos()-2);
+ return;
+}
diff --git a/openEMS/FDTD/extensions/engine_ext_cylindermultigrid.h b/openEMS/FDTD/extensions/engine_ext_cylindermultigrid.h
new file mode 100644
index 0000000..e9226f5
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_cylindermultigrid.h
@@ -0,0 +1,58 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_EXT_CYLINDERMULTIGRID_H
+#define ENGINE_EXT_CYLINDERMULTIGRID_H
+
+#include "FDTD/engine_cylindermultigrid.h"
+#include "engine_extension.h"
+#include "FDTD/operator_cylindermultigrid.h"
+
+class Operator_Ext_CylinderMultiGrid;
+
+class Engine_Ext_CylinderMultiGrid : public Engine_Extension
+{
+public:
+ Engine_Ext_CylinderMultiGrid(Operator_Extension* op_ext, bool isBase);
+ virtual ~Engine_Ext_CylinderMultiGrid();
+
+ void SetBarrier(boost::barrier* waitBase, boost::barrier* waitChild, boost::barrier* waitSync);
+
+ virtual void DoPreVoltageUpdates();
+ virtual void DoPostVoltageUpdates();
+ virtual void Apply2Voltages();
+
+ virtual void DoPreCurrentUpdates();
+ virtual void DoPostCurrentUpdates();
+ virtual void Apply2Current();
+
+ virtual void SetEngine(Engine* eng);
+
+protected:
+ void SyncVoltages();
+ void SyncCurrents();
+
+ Engine_CylinderMultiGrid* m_Eng_MG;
+
+ boost::barrier *m_WaitOnBase;
+ boost::barrier *m_WaitOnChild;
+ boost::barrier *m_WaitOnSync;
+
+ bool m_IsBase;
+};
+
+#endif // ENGINE_EXT_CYLINDERMULTIGRID_H
diff --git a/openEMS/FDTD/extensions/engine_ext_dispersive.cpp b/openEMS/FDTD/extensions/engine_ext_dispersive.cpp
new file mode 100644
index 0000000..d9c431b
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_dispersive.cpp
@@ -0,0 +1,162 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine_ext_dispersive.h"
+#include "operator_ext_dispersive.h"
+#include "FDTD/engine_sse.h"
+
+Engine_Ext_Dispersive::Engine_Ext_Dispersive(Operator_Ext_Dispersive* op_ext_disp) : Engine_Extension(op_ext_disp)
+{
+ m_Op_Ext_Disp = op_ext_disp;
+ int order = m_Op_Ext_Disp->m_Order;
+ curr_ADE = new FDTD_FLOAT**[order];
+ volt_ADE = new FDTD_FLOAT**[order];
+ for (int o=0;o<order;++o)
+ {
+ curr_ADE[o] = new FDTD_FLOAT*[3];
+ volt_ADE[o] = new FDTD_FLOAT*[3];
+ for (int n=0; n<3; ++n)
+ {
+ if (m_Op_Ext_Disp->m_curr_ADE_On[o]==true)
+ {
+ curr_ADE[o][n] = new FDTD_FLOAT[m_Op_Ext_Disp->m_LM_Count[o]];
+ for (unsigned int i=0; i<m_Op_Ext_Disp->m_LM_Count[o]; ++i)
+ curr_ADE[o][n][i]=0.0;
+ }
+ else
+ curr_ADE[o][n] = NULL;
+ if (m_Op_Ext_Disp->m_volt_ADE_On[o]==true)
+ {
+ volt_ADE[o][n] = new FDTD_FLOAT[m_Op_Ext_Disp->m_LM_Count[o]];
+ for (unsigned int i=0; i<m_Op_Ext_Disp->m_LM_Count[o]; ++i)
+ volt_ADE[o][n][i]=0.0;
+ }
+ else
+ volt_ADE[o][n] = NULL;
+ }
+ }
+}
+
+Engine_Ext_Dispersive::~Engine_Ext_Dispersive()
+{
+ if (curr_ADE==NULL && volt_ADE==NULL)
+ return;
+
+ for (int o=0;o<m_Op_Ext_Disp->m_Order;++o)
+ {
+ for (int n=0; n<3; ++n)
+ {
+ delete[] curr_ADE[o][n];
+ delete[] volt_ADE[o][n];
+ }
+ delete[] curr_ADE[o];
+ delete[] volt_ADE[o];
+ }
+ delete[] curr_ADE;
+ curr_ADE=NULL;
+
+ delete[] volt_ADE;
+ volt_ADE=NULL;
+}
+
+void Engine_Ext_Dispersive::Apply2Voltages()
+{
+ for (int o=0;o<m_Op_Ext_Disp->m_Order;++o)
+ {
+ if (m_Op_Ext_Disp->m_volt_ADE_On[o]==false) continue;
+
+ unsigned int **pos = m_Op_Ext_Disp->m_LM_pos[o];
+
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int i=0; i<m_Op_Ext_Disp->m_LM_Count.at(o); ++i)
+ {
+ m_Eng->Engine::SetVolt(0,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetVolt(0,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[o][0][i]);
+ m_Eng->Engine::SetVolt(1,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetVolt(1,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[o][1][i]);
+ m_Eng->Engine::SetVolt(2,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetVolt(2,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[o][2][i]);
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*)m_Eng;
+ for (unsigned int i=0; i<m_Op_Ext_Disp->m_LM_Count.at(o); ++i)
+ {
+ eng_sse->Engine_sse::SetVolt(0,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetVolt(0,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[o][0][i]);
+ eng_sse->Engine_sse::SetVolt(1,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetVolt(1,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[o][1][i]);
+ eng_sse->Engine_sse::SetVolt(2,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetVolt(2,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[o][2][i]);
+ }
+ break;
+ }
+ default:
+ for (unsigned int i=0; i<m_Op_Ext_Disp->m_LM_Count.at(o); ++i)
+ {
+ m_Eng->SetVolt(0,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetVolt(0,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[o][0][i]);
+ m_Eng->SetVolt(1,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetVolt(1,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[o][1][i]);
+ m_Eng->SetVolt(2,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetVolt(2,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[o][2][i]);
+ }
+ break;
+ }
+ }
+}
+
+void Engine_Ext_Dispersive::Apply2Current()
+{
+ for (int o=0;o<m_Op_Ext_Disp->m_Order;++o)
+ {
+ if (m_Op_Ext_Disp->m_curr_ADE_On[o]==false) continue;
+
+ unsigned int **pos = m_Op_Ext_Disp->m_LM_pos[o];
+
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int i=0; i<m_Op_Ext_Disp->m_LM_Count.at(o); ++i)
+ {
+ m_Eng->Engine::SetCurr(0,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetCurr(0,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[o][0][i]);
+ m_Eng->Engine::SetCurr(1,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetCurr(1,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[o][1][i]);
+ m_Eng->Engine::SetCurr(2,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetCurr(2,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[o][2][i]);
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*)m_Eng;
+ for (unsigned int i=0; i<m_Op_Ext_Disp->m_LM_Count.at(o); ++i)
+ {
+ eng_sse->Engine_sse::SetCurr(0,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetCurr(0,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[o][0][i]);
+ eng_sse->Engine_sse::SetCurr(1,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetCurr(1,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[o][1][i]);
+ eng_sse->Engine_sse::SetCurr(2,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetCurr(2,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[o][2][i]);
+ }
+ break;
+ }
+ default:
+ for (unsigned int i=0; i<m_Op_Ext_Disp->m_LM_Count.at(o); ++i)
+ {
+ m_Eng->SetCurr(0,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetCurr(0,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[o][0][i]);
+ m_Eng->SetCurr(1,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetCurr(1,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[o][1][i]);
+ m_Eng->SetCurr(2,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetCurr(2,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[o][2][i]);
+ }
+ break;
+ }
+ }
+}
diff --git a/openEMS/FDTD/extensions/engine_ext_dispersive.h b/openEMS/FDTD/extensions/engine_ext_dispersive.h
new file mode 100644
index 0000000..c1b84ea
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_dispersive.h
@@ -0,0 +1,51 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_EXT_DISPERSIVE_H
+#define ENGINE_EXT_DISPERSIVE_H
+
+#include "engine_extension.h"
+#include "FDTD/engine.h"
+#include "FDTD/operator.h"
+
+class Operator_Ext_Dispersive;
+
+class Engine_Ext_Dispersive : public Engine_Extension
+{
+public:
+ Engine_Ext_Dispersive(Operator_Ext_Dispersive* op_ext_disp);
+ virtual ~Engine_Ext_Dispersive();
+
+ virtual void Apply2Voltages();
+ virtual void Apply2Current();
+
+protected:
+ Operator_Ext_Dispersive* m_Op_Ext_Disp;
+
+ //! Dispersive order
+ int m_Order;
+
+ //! ADE currents
+ // Array setup: curr_ADE[N_order][direction][mesh_pos]
+ FDTD_FLOAT ***curr_ADE;
+
+ //! ADE voltages
+ // Array setup: volt_ADE[N_order][direction][mesh_pos]
+ FDTD_FLOAT ***volt_ADE;
+};
+
+#endif // ENGINE_EXT_DISPERSIVE_H
diff --git a/openEMS/FDTD/extensions/engine_ext_excitation.cpp b/openEMS/FDTD/extensions/engine_ext_excitation.cpp
new file mode 100644
index 0000000..b5bd8bd
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_excitation.cpp
@@ -0,0 +1,170 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 "engine_ext_excitation.h"
+#include "operator_ext_excitation.h"
+#include "FDTD/engine_sse.h"
+
+Engine_Ext_Excitation::Engine_Ext_Excitation(Operator_Ext_Excitation* op_ext) : Engine_Extension(op_ext)
+{
+ m_Op_Exc = op_ext;
+ m_Priority = ENG_EXT_PRIO_EXCITATION;
+}
+
+Engine_Ext_Excitation::~Engine_Ext_Excitation()
+{
+
+}
+
+void Engine_Ext_Excitation::Apply2Voltages()
+{
+ //soft voltage excitation here (E-field excite)
+ int exc_pos;
+ unsigned int ny;
+ unsigned int pos[3];
+ int numTS = m_Eng->GetNumberOfTimesteps();
+ unsigned int length = m_Op_Exc->m_Exc->GetLength();
+ FDTD_FLOAT* exc_volt = m_Op_Exc->m_Exc->GetVoltageSignal();
+
+ int p = numTS+1;
+ if (m_Op_Exc->m_Exc->GetSignalPeriod()>0)
+ p = int(m_Op_Exc->m_Exc->GetSignalPeriod()/m_Op_Exc->m_Exc->GetTimestep());
+
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int n=0; n<m_Op_Exc->Volt_Count; ++n)
+ {
+ exc_pos = numTS - (int)m_Op_Exc->Volt_delay[n];
+ exc_pos *= (exc_pos>0);
+ exc_pos %= p;
+ exc_pos *= (exc_pos<=(int)length);
+ ny = m_Op_Exc->Volt_dir[n];
+ pos[0]=m_Op_Exc->Volt_index[0][n];
+ pos[1]=m_Op_Exc->Volt_index[1][n];
+ pos[2]=m_Op_Exc->Volt_index[2][n];
+ m_Eng->Engine::SetVolt(ny,pos, m_Eng->Engine::GetVolt(ny,pos) + m_Op_Exc->Volt_amp[n]*exc_volt[exc_pos]);
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ for (unsigned int n=0; n<m_Op_Exc->Volt_Count; ++n)
+ {
+ Engine_sse* eng_sse = (Engine_sse*) m_Eng;
+ exc_pos = numTS - (int)m_Op_Exc->Volt_delay[n];
+ exc_pos *= (exc_pos>0);
+ exc_pos %= p;
+ exc_pos *= (exc_pos<=(int)length);
+ ny = m_Op_Exc->Volt_dir[n];
+ pos[0]=m_Op_Exc->Volt_index[0][n];
+ pos[1]=m_Op_Exc->Volt_index[1][n];
+ pos[2]=m_Op_Exc->Volt_index[2][n];
+ eng_sse->Engine_sse::SetVolt(ny,pos, eng_sse->Engine_sse::GetVolt(ny,pos) + m_Op_Exc->Volt_amp[n]*exc_volt[exc_pos]);
+ }
+ break;
+ }
+ default:
+ {
+ for (unsigned int n=0; n<m_Op_Exc->Volt_Count; ++n)
+ {
+ exc_pos = numTS - (int)m_Op_Exc->Volt_delay[n];
+ exc_pos *= (exc_pos>0);
+ exc_pos %= p;
+ exc_pos *= (exc_pos<=(int)length);
+ ny = m_Op_Exc->Volt_dir[n];
+ pos[0]=m_Op_Exc->Volt_index[0][n];
+ pos[1]=m_Op_Exc->Volt_index[1][n];
+ pos[2]=m_Op_Exc->Volt_index[2][n];
+ m_Eng->SetVolt(ny,pos, m_Eng->GetVolt(ny,pos) + m_Op_Exc->Volt_amp[n]*exc_volt[exc_pos]);
+ }
+ break;
+ }
+ }
+}
+
+void Engine_Ext_Excitation::Apply2Current()
+{
+ //soft current excitation here (H-field excite)
+
+ int exc_pos;
+ unsigned int ny;
+ unsigned int pos[3];
+ int numTS = m_Eng->GetNumberOfTimesteps();
+ unsigned int length = m_Op_Exc->m_Exc->GetLength();
+ FDTD_FLOAT* exc_curr = m_Op_Exc->m_Exc->GetCurrentSignal();
+
+ int p = numTS+1;
+ if (m_Op_Exc->m_Exc->GetSignalPeriod()>0)
+ p = int(m_Op_Exc->m_Exc->GetSignalPeriod()/m_Op_Exc->m_Exc->GetTimestep());
+
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int n=0; n<m_Op_Exc->Curr_Count; ++n)
+ {
+ exc_pos = numTS - (int)m_Op_Exc->Curr_delay[n];
+ exc_pos *= (exc_pos>0);
+ exc_pos %= p;
+ exc_pos *= (exc_pos<=(int)length);
+ ny = m_Op_Exc->Curr_dir[n];
+ pos[0]=m_Op_Exc->Curr_index[0][n];
+ pos[1]=m_Op_Exc->Curr_index[1][n];
+ pos[2]=m_Op_Exc->Curr_index[2][n];
+ m_Eng->Engine::SetCurr(ny,pos, m_Eng->Engine::GetCurr(ny,pos) + m_Op_Exc->Curr_amp[n]*exc_curr[exc_pos]);
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ for (unsigned int n=0; n<m_Op_Exc->Curr_Count; ++n)
+ {
+ Engine_sse* eng_sse = (Engine_sse*) m_Eng;
+ exc_pos = numTS - (int)m_Op_Exc->Curr_delay[n];
+ exc_pos *= (exc_pos>0);
+ exc_pos %= p;
+ exc_pos *= (exc_pos<=(int)length);
+ ny = m_Op_Exc->Curr_dir[n];
+ pos[0]=m_Op_Exc->Curr_index[0][n];
+ pos[1]=m_Op_Exc->Curr_index[1][n];
+ pos[2]=m_Op_Exc->Curr_index[2][n];
+ eng_sse->Engine_sse::SetCurr(ny,pos, eng_sse->Engine_sse::GetCurr(ny,pos) + m_Op_Exc->Curr_amp[n]*exc_curr[exc_pos]);
+ }
+ break;
+ }
+ default:
+ {
+ for (unsigned int n=0; n<m_Op_Exc->Curr_Count; ++n)
+ {
+ exc_pos = numTS - (int)m_Op_Exc->Curr_delay[n];
+ exc_pos *= (exc_pos>0);
+ exc_pos %= p;
+ exc_pos *= (exc_pos<=(int)length);
+ ny = m_Op_Exc->Curr_dir[n];
+ pos[0]=m_Op_Exc->Curr_index[0][n];
+ pos[1]=m_Op_Exc->Curr_index[1][n];
+ pos[2]=m_Op_Exc->Curr_index[2][n];
+ m_Eng->SetCurr(ny,pos, m_Eng->GetCurr(ny,pos) + m_Op_Exc->Curr_amp[n]*exc_curr[exc_pos]);
+ }
+ break;
+ }
+ }
+}
diff --git a/openEMS/FDTD/extensions/engine_ext_excitation.h b/openEMS/FDTD/extensions/engine_ext_excitation.h
new file mode 100644
index 0000000..aae58a0
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_excitation.h
@@ -0,0 +1,40 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_EXT_EXCITATION_H
+#define ENGINE_EXT_EXCITATION_H
+
+#include "engine_extension.h"
+#include "FDTD/engine.h"
+#include "FDTD/operator.h"
+
+class Operator_Ext_Excitation;
+
+class Engine_Ext_Excitation : public Engine_Extension
+{
+public:
+ Engine_Ext_Excitation(Operator_Ext_Excitation* op_ext);
+ virtual ~Engine_Ext_Excitation();
+
+ virtual void Apply2Voltages();
+ virtual void Apply2Current();
+
+protected:
+ Operator_Ext_Excitation* m_Op_Exc;
+};
+
+#endif // ENGINE_EXT_EXCITATION_H
diff --git a/openEMS/FDTD/extensions/engine_ext_lorentzmaterial.cpp b/openEMS/FDTD/extensions/engine_ext_lorentzmaterial.cpp
new file mode 100644
index 0000000..9aaa1ff
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_lorentzmaterial.cpp
@@ -0,0 +1,322 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine_ext_lorentzmaterial.h"
+#include "operator_ext_lorentzmaterial.h"
+#include "FDTD/engine_sse.h"
+
+Engine_Ext_LorentzMaterial::Engine_Ext_LorentzMaterial(Operator_Ext_LorentzMaterial* op_ext_lorentz) : Engine_Ext_Dispersive(op_ext_lorentz)
+{
+ m_Op_Ext_Lor = op_ext_lorentz;
+ m_Order = m_Op_Ext_Lor->GetDispersionOrder();
+ int order = m_Op_Ext_Lor->m_Order;
+
+ curr_Lor_ADE = new FDTD_FLOAT**[order];
+ volt_Lor_ADE = new FDTD_FLOAT**[order];
+ for (int o=0;o<order;++o)
+ {
+ curr_Lor_ADE[o] = new FDTD_FLOAT*[3];
+ volt_Lor_ADE[o] = new FDTD_FLOAT*[3];
+ for (int n=0; n<3; ++n)
+ {
+ if (m_Op_Ext_Lor->m_curr_Lor_ADE_On[o]==true)
+ {
+ curr_Lor_ADE[o][n] = new FDTD_FLOAT[m_Op_Ext_Lor->m_LM_Count[o]];
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count[o]; ++i)
+ curr_Lor_ADE[o][n][i]=0.0;
+ }
+ else
+ curr_Lor_ADE[o][n] = NULL;
+
+ if (m_Op_Ext_Lor->m_volt_Lor_ADE_On[o]==true)
+ {
+ volt_Lor_ADE[o][n] = new FDTD_FLOAT[m_Op_Ext_Lor->m_LM_Count[o]];
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count[o]; ++i)
+ volt_Lor_ADE[o][n][i]=0.0;
+ }
+ else
+ volt_Lor_ADE[o][n] = NULL;
+ }
+ }
+}
+
+Engine_Ext_LorentzMaterial::~Engine_Ext_LorentzMaterial()
+{
+ if (curr_Lor_ADE==NULL && volt_Lor_ADE==NULL)
+ return;
+
+ for (int o=0;o<m_Op_Ext_Lor->m_Order;++o)
+ {
+ for (int n=0; n<3; ++n)
+ {
+ delete[] curr_Lor_ADE[o][n];
+ delete[] volt_Lor_ADE[o][n];
+ }
+ delete[] curr_Lor_ADE[o];
+ delete[] volt_Lor_ADE[o];
+ }
+ delete[] curr_Lor_ADE;
+ curr_Lor_ADE=NULL;
+
+ delete[] volt_Lor_ADE;
+ volt_Lor_ADE=NULL;
+}
+
+void Engine_Ext_LorentzMaterial::DoPreVoltageUpdates()
+{
+ for (int o=0;o<m_Order;++o)
+ {
+ if (m_Op_Ext_Lor->m_volt_ADE_On[o]==false) continue;
+
+ unsigned int **pos = m_Op_Ext_Lor->m_LM_pos[o];
+
+ if (m_Op_Ext_Lor->m_volt_Lor_ADE_On[o])
+ {
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ volt_Lor_ADE[o][0][i]+=m_Op_Ext_Lor->v_Lor_ADE[o][0][i]*volt_ADE[o][0][i];
+ volt_ADE[o][0][i] *= m_Op_Ext_Lor->v_int_ADE[o][0][i];
+ volt_ADE[o][0][i] += m_Op_Ext_Lor->v_ext_ADE[o][0][i] * (m_Eng->Engine::GetVolt(0,pos[0][i],pos[1][i],pos[2][i])-volt_Lor_ADE[o][0][i]);
+
+ volt_Lor_ADE[o][1][i]+=m_Op_Ext_Lor->v_Lor_ADE[o][1][i]*volt_ADE[o][1][i];
+ volt_ADE[o][1][i] *= m_Op_Ext_Lor->v_int_ADE[o][1][i];
+ volt_ADE[o][1][i] += m_Op_Ext_Lor->v_ext_ADE[o][1][i] * (m_Eng->Engine::GetVolt(1,pos[0][i],pos[1][i],pos[2][i])-volt_Lor_ADE[o][2][i]);
+
+ volt_Lor_ADE[o][2][i]+=m_Op_Ext_Lor->v_Lor_ADE[o][2][i]*volt_ADE[o][2][i];
+ volt_ADE[o][2][i] *= m_Op_Ext_Lor->v_int_ADE[o][2][i];
+ volt_ADE[o][2][i] += m_Op_Ext_Lor->v_ext_ADE[o][2][i] * (m_Eng->Engine::GetVolt(2,pos[0][i],pos[1][i],pos[2][i])-volt_Lor_ADE[o][2][i]);
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*)m_Eng;
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ volt_Lor_ADE[o][0][i]+=m_Op_Ext_Lor->v_Lor_ADE[o][0][i]*volt_ADE[o][0][i];
+ volt_ADE[o][0][i] *= m_Op_Ext_Lor->v_int_ADE[o][0][i];
+ volt_ADE[o][0][i] += m_Op_Ext_Lor->v_ext_ADE[o][0][i] * (eng_sse->Engine_sse::GetVolt(0,pos[0][i],pos[1][i],pos[2][i])-volt_Lor_ADE[o][0][i]);
+
+ volt_Lor_ADE[o][1][i]+=m_Op_Ext_Lor->v_Lor_ADE[o][1][i]*volt_ADE[o][1][i];
+ volt_ADE[o][1][i] *= m_Op_Ext_Lor->v_int_ADE[o][1][i];
+ volt_ADE[o][1][i] += m_Op_Ext_Lor->v_ext_ADE[o][1][i] * (eng_sse->Engine_sse::GetVolt(1,pos[0][i],pos[1][i],pos[2][i])-volt_Lor_ADE[o][1][i]);
+
+ volt_Lor_ADE[o][2][i]+=m_Op_Ext_Lor->v_Lor_ADE[o][2][i]*volt_ADE[o][2][i];
+ volt_ADE[o][2][i] *= m_Op_Ext_Lor->v_int_ADE[o][2][i];
+ volt_ADE[o][2][i] += m_Op_Ext_Lor->v_ext_ADE[o][2][i] * (eng_sse->Engine_sse::GetVolt(2,pos[0][i],pos[1][i],pos[2][i])-volt_Lor_ADE[o][2][i]);
+ }
+ break;
+ }
+ default:
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ volt_Lor_ADE[o][0][i]+=m_Op_Ext_Lor->v_Lor_ADE[o][0][i]*volt_ADE[o][0][i];
+ volt_ADE[o][0][i] *= m_Op_Ext_Lor->v_int_ADE[o][0][i];
+ volt_ADE[o][0][i] += m_Op_Ext_Lor->v_ext_ADE[o][0][i] * (m_Eng->GetVolt(0,pos[0][i],pos[1][i],pos[2][i])-volt_Lor_ADE[o][0][i]);
+
+ volt_Lor_ADE[o][1][i]+=m_Op_Ext_Lor->v_Lor_ADE[o][1][i]*volt_ADE[o][1][i];
+ volt_ADE[o][1][i] *= m_Op_Ext_Lor->v_int_ADE[o][1][i];
+ volt_ADE[o][1][i] += m_Op_Ext_Lor->v_ext_ADE[o][1][i] * (m_Eng->GetVolt(1,pos[0][i],pos[1][i],pos[2][i])-volt_Lor_ADE[o][1][i]);
+
+ volt_Lor_ADE[o][2][i]+=m_Op_Ext_Lor->v_Lor_ADE[o][2][i]*volt_ADE[o][2][i];
+ volt_ADE[o][2][i] *= m_Op_Ext_Lor->v_int_ADE[o][2][i];
+ volt_ADE[o][2][i] += m_Op_Ext_Lor->v_ext_ADE[o][2][i] * (m_Eng->GetVolt(2,pos[0][i],pos[1][i],pos[2][i])-volt_Lor_ADE[o][2][i]);
+ }
+ break;
+ }
+ }
+ else
+ {
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ volt_ADE[o][0][i] *= m_Op_Ext_Lor->v_int_ADE[o][0][i];
+ volt_ADE[o][0][i] += m_Op_Ext_Lor->v_ext_ADE[o][0][i] * m_Eng->Engine::GetVolt(0,pos[0][i],pos[1][i],pos[2][i]);
+
+ volt_ADE[o][1][i] *= m_Op_Ext_Lor->v_int_ADE[o][1][i];
+ volt_ADE[o][1][i] += m_Op_Ext_Lor->v_ext_ADE[o][1][i] * m_Eng->Engine::GetVolt(1,pos[0][i],pos[1][i],pos[2][i]);
+
+ volt_ADE[o][2][i] *= m_Op_Ext_Lor->v_int_ADE[o][2][i];
+ volt_ADE[o][2][i] += m_Op_Ext_Lor->v_ext_ADE[o][2][i] * m_Eng->Engine::GetVolt(2,pos[0][i],pos[1][i],pos[2][i]);
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*)m_Eng;
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ volt_ADE[o][0][i] *= m_Op_Ext_Lor->v_int_ADE[o][0][i];
+ volt_ADE[o][0][i] += m_Op_Ext_Lor->v_ext_ADE[o][0][i] * eng_sse->Engine_sse::GetVolt(0,pos[0][i],pos[1][i],pos[2][i]);
+
+ volt_ADE[o][1][i] *= m_Op_Ext_Lor->v_int_ADE[o][1][i];
+ volt_ADE[o][1][i] += m_Op_Ext_Lor->v_ext_ADE[o][1][i] * eng_sse->Engine_sse::GetVolt(1,pos[0][i],pos[1][i],pos[2][i]);
+
+ volt_ADE[o][2][i] *= m_Op_Ext_Lor->v_int_ADE[o][2][i];
+ volt_ADE[o][2][i] += m_Op_Ext_Lor->v_ext_ADE[o][2][i] * eng_sse->Engine_sse::GetVolt(2,pos[0][i],pos[1][i],pos[2][i]);
+ }
+ break;
+ }
+ default:
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ volt_ADE[o][0][i] *= m_Op_Ext_Lor->v_int_ADE[o][0][i];
+ volt_ADE[o][0][i] += m_Op_Ext_Lor->v_ext_ADE[o][0][i] * m_Eng->GetVolt(0,pos[0][i],pos[1][i],pos[2][i]);
+
+ volt_ADE[o][1][i] *= m_Op_Ext_Lor->v_int_ADE[o][1][i];
+ volt_ADE[o][1][i] += m_Op_Ext_Lor->v_ext_ADE[o][1][i] * m_Eng->GetVolt(1,pos[0][i],pos[1][i],pos[2][i]);
+
+ volt_ADE[o][2][i] *= m_Op_Ext_Lor->v_int_ADE[o][2][i];
+ volt_ADE[o][2][i] += m_Op_Ext_Lor->v_ext_ADE[o][2][i] * m_Eng->GetVolt(2,pos[0][i],pos[1][i],pos[2][i]);
+ }
+ break;
+ }
+ }
+ }
+}
+
+void Engine_Ext_LorentzMaterial::DoPreCurrentUpdates()
+{
+ for (int o=0;o<m_Order;++o)
+ {
+ if (m_Op_Ext_Lor->m_curr_ADE_On[o]==false) continue;
+
+ unsigned int **pos = m_Op_Ext_Lor->m_LM_pos[o];
+
+ if (m_Op_Ext_Lor->m_curr_Lor_ADE_On[o])
+ {
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ curr_Lor_ADE[o][0][i]+=m_Op_Ext_Lor->i_Lor_ADE[o][0][i]*curr_ADE[o][0][i];
+ curr_ADE[o][0][i] *= m_Op_Ext_Lor->i_int_ADE[o][0][i];
+ curr_ADE[o][0][i] += m_Op_Ext_Lor->i_ext_ADE[o][0][i] * (m_Eng->Engine::GetCurr(0,pos[0][i],pos[1][i],pos[2][i])-curr_Lor_ADE[o][0][i]);
+
+ curr_Lor_ADE[o][1][i]+=m_Op_Ext_Lor->i_Lor_ADE[o][1][i]*curr_ADE[o][1][i];
+ curr_ADE[o][1][i] *= m_Op_Ext_Lor->i_int_ADE[o][1][i];
+ curr_ADE[o][1][i] += m_Op_Ext_Lor->i_ext_ADE[o][1][i] * (m_Eng->Engine::GetCurr(1,pos[0][i],pos[1][i],pos[2][i])-curr_Lor_ADE[o][1][i]);
+
+ curr_Lor_ADE[o][2][i]+=m_Op_Ext_Lor->i_Lor_ADE[o][2][i]*curr_ADE[o][2][i];
+ curr_ADE[o][2][i] *= m_Op_Ext_Lor->i_int_ADE[o][2][i];
+ curr_ADE[o][2][i] += m_Op_Ext_Lor->i_ext_ADE[o][2][i] * (m_Eng->Engine::GetCurr(2,pos[0][i],pos[1][i],pos[2][i])-curr_Lor_ADE[o][2][i]);
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*)m_Eng;
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ curr_Lor_ADE[o][0][i]+=m_Op_Ext_Lor->i_Lor_ADE[o][0][i]*curr_ADE[o][0][i];
+ curr_ADE[o][0][i] *= m_Op_Ext_Lor->i_int_ADE[o][0][i];
+ curr_ADE[o][0][i] += m_Op_Ext_Lor->i_ext_ADE[o][0][i] * (eng_sse->Engine_sse::GetCurr(0,pos[0][i],pos[1][i],pos[2][i])-curr_Lor_ADE[o][0][i]);
+
+ curr_Lor_ADE[o][1][i]+=m_Op_Ext_Lor->i_Lor_ADE[o][1][i]*curr_ADE[o][1][i];
+ curr_ADE[o][1][i] *= m_Op_Ext_Lor->i_int_ADE[o][1][i];
+ curr_ADE[o][1][i] += m_Op_Ext_Lor->i_ext_ADE[o][1][i] * (eng_sse->Engine_sse::GetCurr(1,pos[0][i],pos[1][i],pos[2][i])-curr_Lor_ADE[o][1][i]);
+
+ curr_Lor_ADE[o][2][i]+=m_Op_Ext_Lor->i_Lor_ADE[o][2][i]*curr_ADE[o][2][i];
+ curr_ADE[o][2][i] *= m_Op_Ext_Lor->i_int_ADE[o][2][i];
+ curr_ADE[o][2][i] += m_Op_Ext_Lor->i_ext_ADE[o][2][i] * (eng_sse->Engine_sse::GetCurr(2,pos[0][i],pos[1][i],pos[2][i])-curr_Lor_ADE[o][2][i]);
+ }
+ break;
+ }
+ default:
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ curr_Lor_ADE[o][0][i]+=m_Op_Ext_Lor->i_Lor_ADE[o][0][i]*curr_ADE[o][0][i];
+ curr_ADE[o][0][i] *= m_Op_Ext_Lor->i_int_ADE[o][0][i];
+ curr_ADE[o][0][i] += m_Op_Ext_Lor->i_ext_ADE[o][0][i] * (m_Eng->GetCurr(0,pos[0][i],pos[1][i],pos[2][i])-curr_Lor_ADE[o][0][i]);
+
+ curr_Lor_ADE[o][1][i]+=m_Op_Ext_Lor->i_Lor_ADE[o][1][i]*curr_ADE[o][1][i];
+ curr_ADE[o][1][i] *= m_Op_Ext_Lor->i_int_ADE[o][1][i];
+ curr_ADE[o][1][i] += m_Op_Ext_Lor->i_ext_ADE[o][1][i] * (m_Eng->GetCurr(1,pos[0][i],pos[1][i],pos[2][i])-curr_Lor_ADE[o][1][i]);
+
+ curr_Lor_ADE[o][2][i]+=m_Op_Ext_Lor->i_Lor_ADE[o][2][i]*curr_ADE[o][2][i];
+ curr_ADE[o][2][i] *= m_Op_Ext_Lor->i_int_ADE[o][2][i];
+ curr_ADE[o][2][i] += m_Op_Ext_Lor->i_ext_ADE[o][2][i] * (m_Eng->GetCurr(2,pos[0][i],pos[1][i],pos[2][i])-curr_Lor_ADE[o][2][i]);
+ }
+ break;
+ }
+ }
+ else
+ {
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ curr_ADE[o][0][i] *= m_Op_Ext_Lor->i_int_ADE[o][0][i];
+ curr_ADE[o][0][i] += m_Op_Ext_Lor->i_ext_ADE[o][0][i] * m_Eng->Engine::GetCurr(0,pos[0][i],pos[1][i],pos[2][i]);
+
+ curr_ADE[o][1][i] *= m_Op_Ext_Lor->i_int_ADE[o][1][i];
+ curr_ADE[o][1][i] += m_Op_Ext_Lor->i_ext_ADE[o][1][i] * m_Eng->Engine::GetCurr(1,pos[0][i],pos[1][i],pos[2][i]);
+
+ curr_ADE[o][2][i] *= m_Op_Ext_Lor->i_int_ADE[o][2][i];
+ curr_ADE[o][2][i] += m_Op_Ext_Lor->i_ext_ADE[o][2][i] * m_Eng->Engine::GetCurr(2,pos[0][i],pos[1][i],pos[2][i]);
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*)m_Eng;
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ curr_ADE[o][0][i] *= m_Op_Ext_Lor->i_int_ADE[o][0][i];
+ curr_ADE[o][0][i] += m_Op_Ext_Lor->i_ext_ADE[o][0][i] * eng_sse->Engine_sse::GetCurr(0,pos[0][i],pos[1][i],pos[2][i]);
+
+ curr_ADE[o][1][i] *= m_Op_Ext_Lor->i_int_ADE[o][1][i];
+ curr_ADE[o][1][i] += m_Op_Ext_Lor->i_ext_ADE[o][1][i] * eng_sse->Engine_sse::GetCurr(1,pos[0][i],pos[1][i],pos[2][i]);
+
+ curr_ADE[o][2][i] *= m_Op_Ext_Lor->i_int_ADE[o][2][i];
+ curr_ADE[o][2][i] += m_Op_Ext_Lor->i_ext_ADE[o][2][i] * eng_sse->Engine_sse::GetCurr(2,pos[0][i],pos[1][i],pos[2][i]);
+ }
+ break;
+ }
+ default:
+ for (unsigned int i=0; i<m_Op_Ext_Lor->m_LM_Count.at(o); ++i)
+ {
+ curr_ADE[o][0][i] *= m_Op_Ext_Lor->i_int_ADE[o][0][i];
+ curr_ADE[o][0][i] += m_Op_Ext_Lor->i_ext_ADE[o][0][i] * m_Eng->GetCurr(0,pos[0][i],pos[1][i],pos[2][i]);
+
+ curr_ADE[o][1][i] *= m_Op_Ext_Lor->i_int_ADE[o][1][i];
+ curr_ADE[o][1][i] += m_Op_Ext_Lor->i_ext_ADE[o][1][i] * m_Eng->GetCurr(1,pos[0][i],pos[1][i],pos[2][i]);
+
+ curr_ADE[o][2][i] *= m_Op_Ext_Lor->i_int_ADE[o][2][i];
+ curr_ADE[o][2][i] += m_Op_Ext_Lor->i_ext_ADE[o][2][i] * m_Eng->GetCurr(2,pos[0][i],pos[1][i],pos[2][i]);
+ }
+ break;
+ }
+ }
+ }
+}
+
diff --git a/openEMS/FDTD/extensions/engine_ext_lorentzmaterial.h b/openEMS/FDTD/extensions/engine_ext_lorentzmaterial.h
new file mode 100644
index 0000000..804f49a
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_lorentzmaterial.h
@@ -0,0 +1,48 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_EXT_LORENTZMATERIAL_H
+#define ENGINE_EXT_LORENTZMATERIAL_H
+
+#include "engine_ext_dispersive.h"
+
+class Operator_Ext_LorentzMaterial;
+
+class Engine_Ext_LorentzMaterial : public Engine_Ext_Dispersive
+{
+public:
+ Engine_Ext_LorentzMaterial(Operator_Ext_LorentzMaterial* op_ext_lorentz);
+ virtual ~Engine_Ext_LorentzMaterial();
+
+ virtual void DoPreVoltageUpdates();
+
+ virtual void DoPreCurrentUpdates();
+
+protected:
+ Operator_Ext_LorentzMaterial* m_Op_Ext_Lor;
+
+ //! ADE Lorentz voltages
+ // Array setup: volt_Lor_ADE[N_order][direction][mesh_pos]
+ FDTD_FLOAT ***volt_Lor_ADE;
+
+ //! ADE Lorentz currents
+ // Array setup: curr_Lor_ADE[N_order][direction][mesh_pos]
+ FDTD_FLOAT ***curr_Lor_ADE;
+
+};
+
+#endif // ENGINE_EXT_LORENTZMATERIAL_H
diff --git a/openEMS/FDTD/extensions/engine_ext_mur_abc.cpp b/openEMS/FDTD/extensions/engine_ext_mur_abc.cpp
new file mode 100644
index 0000000..d9f1b17
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_mur_abc.cpp
@@ -0,0 +1,263 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine_ext_mur_abc.h"
+#include "operator_ext_mur_abc.h"
+#include "FDTD/engine.h"
+#include "FDTD/engine_sse.h"
+#include "tools/array_ops.h"
+#include "tools/useful.h"
+#include "operator_ext_excitation.h"
+
+Engine_Ext_Mur_ABC::Engine_Ext_Mur_ABC(Operator_Ext_Mur_ABC* op_ext) : Engine_Extension(op_ext)
+{
+ m_Op_mur = op_ext;
+ m_numLines[0] = m_Op_mur->m_numLines[0];
+ m_numLines[1] = m_Op_mur->m_numLines[1];
+ m_ny = m_Op_mur->m_ny;
+ m_nyP = m_Op_mur->m_nyP;
+ m_nyPP = m_Op_mur->m_nyPP;
+ m_LineNr = m_Op_mur->m_LineNr;
+ m_LineNr_Shift = m_Op_mur->m_LineNr_Shift;
+
+ m_Mur_Coeff_nyP = m_Op_mur->m_Mur_Coeff_nyP;
+ m_Mur_Coeff_nyPP = m_Op_mur->m_Mur_Coeff_nyPP;
+
+ m_volt_nyP = Create2DArray<FDTD_FLOAT>(m_numLines);
+ m_volt_nyPP = Create2DArray<FDTD_FLOAT>(m_numLines);
+
+ //find if some excitation is on this mur-abc and find the max length of this excite, so that the abc can start after the excitation is done...
+ int maxDelay=-1;
+ Operator_Ext_Excitation* Exc_ext = m_Op_mur->m_Op->GetExcitationExtension();
+ for (unsigned int n=0; n<Exc_ext->GetVoltCount(); ++n)
+ {
+ if ( ((Exc_ext->Volt_dir[n]==m_nyP) || (Exc_ext->Volt_dir[n]==m_nyPP)) && (Exc_ext->Volt_index[m_ny][n]==m_LineNr) )
+ {
+ if ((int)Exc_ext->Volt_delay[n]>maxDelay)
+ maxDelay = (int)Exc_ext->Volt_delay[n];
+ }
+ }
+ m_start_TS = 0;
+ if (maxDelay>=0)
+ {
+ m_start_TS = maxDelay + m_Op_mur->m_Op->GetExcitationSignal()->GetLength() + 10; //give it some extra timesteps, for the excitation to travel at least one cell away
+ cerr << "Engine_Ext_Mur_ABC::Engine_Ext_Mur_ABC: Warning: Excitation inside the Mur-ABC #" << m_ny << "-" << (int)(m_LineNr>0) << " found!!!! Mur-ABC will be switched on after excitation is done at " << m_start_TS << " timesteps!!! " << endl;
+ }
+
+ SetNumberOfThreads(1);
+}
+
+Engine_Ext_Mur_ABC::~Engine_Ext_Mur_ABC()
+{
+ Delete2DArray(m_volt_nyP,m_numLines);
+ m_volt_nyP = NULL;
+ Delete2DArray(m_volt_nyPP,m_numLines);
+ m_volt_nyPP = NULL;
+}
+
+
+void Engine_Ext_Mur_ABC::SetNumberOfThreads(int nrThread)
+{
+ Engine_Extension::SetNumberOfThreads(nrThread);
+
+ m_numX = AssignJobs2Threads(m_numLines[0],m_NrThreads,false);
+ m_start.resize(m_NrThreads,0);
+ m_start.at(0)=0;
+ for (size_t n=1; n<m_numX.size(); ++n)
+ m_start.at(n) = m_start.at(n-1) + m_numX.at(n-1);
+}
+
+
+void Engine_Ext_Mur_ABC::DoPreVoltageUpdates(int threadID)
+{
+ if (IsActive()==false) return;
+ if (m_Eng==NULL) return;
+ if (threadID>=m_NrThreads)
+ return;
+ unsigned int pos[] = {0,0,0};
+ unsigned int pos_shift[] = {0,0,0};
+ pos[m_ny] = m_LineNr;
+ pos_shift[m_ny] = m_LineNr_Shift;
+
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ pos[m_nyP]=lineX+m_start.at(threadID);
+ pos_shift[m_nyP] = pos[m_nyP];
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ pos_shift[m_nyPP] = pos[m_nyPP];
+ m_volt_nyP[pos[m_nyP]][pos[m_nyPP]] = m_Eng->Engine::GetVolt(m_nyP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->Engine::GetVolt(m_nyP,pos);
+ m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] = m_Eng->Engine::GetVolt(m_nyPP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->Engine::GetVolt(m_nyPP,pos);
+ }
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*) m_Eng;
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ pos[m_nyP]=lineX+m_start.at(threadID);
+ pos_shift[m_nyP] = pos[m_nyP];
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ pos_shift[m_nyPP] = pos[m_nyPP];
+ m_volt_nyP[pos[m_nyP]][pos[m_nyPP]] = eng_sse->Engine_sse::GetVolt(m_nyP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * eng_sse->Engine_sse::GetVolt(m_nyP,pos);
+ m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] = eng_sse->Engine_sse::GetVolt(m_nyPP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] * eng_sse->Engine_sse::GetVolt(m_nyPP,pos);
+ }
+ }
+ break;
+ }
+ default:
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ pos[m_nyP]=lineX+m_start.at(threadID);
+ pos_shift[m_nyP] = pos[m_nyP];
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ pos_shift[m_nyPP] = pos[m_nyPP];
+ m_volt_nyP[pos[m_nyP]][pos[m_nyPP]] = m_Eng->GetVolt(m_nyP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->GetVolt(m_nyP,pos);
+ m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] = m_Eng->GetVolt(m_nyPP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->GetVolt(m_nyPP,pos);
+ }
+ }
+ break;
+ }
+}
+
+void Engine_Ext_Mur_ABC::DoPostVoltageUpdates(int threadID)
+{
+ if (IsActive()==false) return;
+ if (m_Eng==NULL) return;
+ if (threadID>=m_NrThreads)
+ return;
+ unsigned int pos[] = {0,0,0};
+ unsigned int pos_shift[] = {0,0,0};
+ pos[m_ny] = m_LineNr;
+ pos_shift[m_ny] = m_LineNr_Shift;
+
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ pos[m_nyP]=lineX+m_start.at(threadID);
+ pos_shift[m_nyP] = pos[m_nyP];
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ pos_shift[m_nyPP] = pos[m_nyPP];
+ m_volt_nyP[pos[m_nyP]][pos[m_nyPP]] += m_Op_mur->m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->Engine::GetVolt(m_nyP,pos_shift);
+ m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] += m_Op_mur->m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->Engine::GetVolt(m_nyPP,pos_shift);
+ }
+ }
+ break;
+ }
+
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*) m_Eng;
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ pos[m_nyP]=lineX+m_start.at(threadID);
+ pos_shift[m_nyP] = pos[m_nyP];
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ pos_shift[m_nyPP] = pos[m_nyPP];
+ m_volt_nyP[pos[m_nyP]][pos[m_nyPP]] += m_Op_mur->m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * eng_sse->Engine_sse::GetVolt(m_nyP,pos_shift);
+ m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] += m_Op_mur->m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] * eng_sse->Engine_sse::GetVolt(m_nyPP,pos_shift);
+ }
+ }
+ break;
+ }
+
+ default:
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ pos[m_nyP]=lineX+m_start.at(threadID);
+ pos_shift[m_nyP] = pos[m_nyP];
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ pos_shift[m_nyPP] = pos[m_nyPP];
+ m_volt_nyP[pos[m_nyP]][pos[m_nyPP]] += m_Op_mur->m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->GetVolt(m_nyP,pos_shift);
+ m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] += m_Op_mur->m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->GetVolt(m_nyPP,pos_shift);
+ }
+ }
+ break;
+ }
+}
+
+void Engine_Ext_Mur_ABC::Apply2Voltages(int threadID)
+{
+ if (IsActive()==false) return;
+ if (threadID>=m_NrThreads)
+ return;
+ if (m_Eng==NULL) return;
+ unsigned int pos[] = {0,0,0};
+ pos[m_ny] = m_LineNr;
+
+ //switch for different engine types to access faster inline engine functions
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ pos[m_nyP]=lineX+m_start.at(threadID);
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ m_Eng->Engine::SetVolt(m_nyP,pos, m_volt_nyP[pos[m_nyP]][pos[m_nyPP]]);
+ m_Eng->Engine::SetVolt(m_nyPP,pos, m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]]);
+ }
+ }
+ break;
+ }
+
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*) m_Eng;
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ pos[m_nyP]=lineX+m_start.at(threadID);
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ eng_sse->Engine_sse::SetVolt(m_nyP,pos, m_volt_nyP[pos[m_nyP]][pos[m_nyPP]]);
+ eng_sse->Engine_sse::SetVolt(m_nyPP,pos, m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]]);
+ }
+ }
+ break;
+ }
+
+ default:
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ pos[m_nyP]=lineX+m_start.at(threadID);
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ m_Eng->SetVolt(m_nyP,pos, m_volt_nyP[pos[m_nyP]][pos[m_nyPP]]);
+ m_Eng->SetVolt(m_nyPP,pos, m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]]);
+ }
+ }
+ break;
+ }
+
+}
diff --git a/openEMS/FDTD/extensions/engine_ext_mur_abc.h b/openEMS/FDTD/extensions/engine_ext_mur_abc.h
new file mode 100644
index 0000000..aadb2fd
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_mur_abc.h
@@ -0,0 +1,63 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_EXT_MUR_ABC_H
+#define ENGINE_EXT_MUR_ABC_H
+
+#include "engine_extension.h"
+#include "FDTD/engine.h"
+#include "FDTD/operator.h"
+
+class Operator_Ext_Mur_ABC;
+
+class Engine_Ext_Mur_ABC : public Engine_Extension
+{
+public:
+ Engine_Ext_Mur_ABC(Operator_Ext_Mur_ABC* op_ext);
+ virtual ~Engine_Ext_Mur_ABC();
+
+ virtual void SetNumberOfThreads(int nrThread);
+
+ virtual void DoPreVoltageUpdates() {Engine_Ext_Mur_ABC::DoPreVoltageUpdates(0);}
+ virtual void DoPreVoltageUpdates(int threadID);
+ virtual void DoPostVoltageUpdates() {Engine_Ext_Mur_ABC::DoPostVoltageUpdates(0);}
+ virtual void DoPostVoltageUpdates(int threadID);
+ virtual void Apply2Voltages() {Engine_Ext_Mur_ABC::Apply2Voltages(0);}
+ virtual void Apply2Voltages(int threadID);
+
+protected:
+ Operator_Ext_Mur_ABC* m_Op_mur;
+
+ inline bool IsActive() {if (m_Eng->GetNumberOfTimesteps()<m_start_TS) return false; return true;}
+ unsigned int m_start_TS;
+
+ int m_ny;
+ int m_nyP,m_nyPP;
+ unsigned int m_LineNr;
+ int m_LineNr_Shift;
+ unsigned int m_numLines[2];
+
+ vector<unsigned int> m_start;
+ vector<unsigned int> m_numX;
+
+ FDTD_FLOAT** m_Mur_Coeff_nyP;
+ FDTD_FLOAT** m_Mur_Coeff_nyPP;
+ FDTD_FLOAT** m_volt_nyP; //n+1 direction
+ FDTD_FLOAT** m_volt_nyPP; //n+2 direction
+};
+
+#endif // ENGINE_EXT_MUR_ABC_H
diff --git a/openEMS/FDTD/extensions/engine_ext_steadystate.cpp b/openEMS/FDTD/extensions/engine_ext_steadystate.cpp
new file mode 100644
index 0000000..9e5d0ce
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_steadystate.cpp
@@ -0,0 +1,112 @@
+/*
+* Copyright (C) 2015 Thorsten Liebig (Thorsten.Liebig@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 "engine_ext_steadystate.h"
+#include "operator_ext_steadystate.h"
+#include "FDTD/engine_sse.h"
+#include "FDTD/engine_interface_fdtd.h"
+
+Engine_Ext_SteadyState::Engine_Ext_SteadyState(Operator_Ext_SteadyState* op_ext): Engine_Extension(op_ext)
+{
+ m_Op_SS = op_ext;
+ m_Priority = ENG_EXT_PRIO_STEADYSTATE;
+
+ for (size_t n=0;n<m_Op_SS->m_E_probe_dir.size();++n)
+ {
+ double* rec = new double[m_Op_SS->m_TS_period*2];
+ m_E_records.push_back(rec);
+ }
+ m_last_max_diff = 1;
+ last_total_energy = 0;
+ m_Eng_Interface = NULL;
+}
+
+Engine_Ext_SteadyState::~Engine_Ext_SteadyState()
+{
+ for (size_t n=0;n<m_E_records.size();++n)
+ {
+ delete[] m_E_records.at(n);
+ m_E_records.at(n) = NULL;
+ }
+ m_E_records.clear();
+ delete m_Eng_Interface;
+ m_Eng_Interface = NULL;
+}
+
+void Engine_Ext_SteadyState::Apply2Voltages()
+{
+ unsigned int p = m_Op_SS->m_TS_period;
+ unsigned int TS = m_Eng->GetNumberOfTimesteps();
+ unsigned int rel_pos = m_Eng->GetNumberOfTimesteps()%(2*p);
+ for (size_t n=0;n<m_E_records.size();++n)
+ m_E_records.at(n)[rel_pos] = m_Eng->GetVolt(m_Op_SS->m_E_probe_dir.at(n), m_Op_SS->m_E_probe_pos[0].at(n), m_Op_SS->m_E_probe_pos[1].at(n), m_Op_SS->m_E_probe_pos[2].at(n));
+ if ((TS%(m_Op_SS->m_TS_period)==0) && (TS>=2*p))
+ {
+ bool no_valid = true;
+ m_last_max_diff = 0;
+ double curr_total_energy = m_Eng_Interface->CalcFastEnergy();
+ if (last_total_energy>0)
+ {
+ m_last_max_diff = abs(curr_total_energy-last_total_energy)/last_total_energy;
+ no_valid = false;
+ }
+ //cerr << curr_total_energy << "/" << last_total_energy << "=" << abs(curr_total_energy-last_total_energy)/last_total_energy << endl;
+ last_total_energy = curr_total_energy;
+ unsigned int old_pos = 0;
+ unsigned int new_pos = p;
+ if (rel_pos<=p)
+ {
+ new_pos = 0;
+ old_pos = p;
+ }
+ //cerr << TS << "/" << rel_pos << ": one period complete, new_pos" << new_pos << " old pos: " << old_pos << endl;
+ double *curr_pow = new double[m_E_records.size()];
+ double *diff_pow = new double[m_E_records.size()];
+ double max_pow = 0;
+ for (size_t n=0;n<m_E_records.size();++n)
+ {
+ double *buf = m_E_records.at(n);
+ curr_pow[n] = 0;
+ diff_pow[n] = 0;
+ for (unsigned int nt=0;nt<p;++nt)
+ {
+ curr_pow[n] += buf[nt+new_pos]*buf[nt+new_pos];
+ diff_pow[n] += (buf[nt+old_pos]-buf[nt+new_pos])*(buf[nt+old_pos]-buf[nt+new_pos]);
+ }
+ max_pow = max(max_pow, curr_pow[n]);
+ }
+ for (size_t n=0;n<m_E_records.size();++n)
+ {
+ //cerr << "curr_pow: " << curr_pow[n] << " diff_pow: " << diff_pow[n] << " diff: " << diff_pow[n]/curr_pow[n] << endl;
+ if (curr_pow[n]>max_pow*1e-2)
+ {
+ m_last_max_diff = max(m_last_max_diff, diff_pow[n]/curr_pow[n]);
+ //cerr << m_last_max_diff << endl;
+ no_valid = false;
+ }
+ }
+ if ((no_valid) || (m_last_max_diff>1))
+ m_last_max_diff = 1;
+ delete[] curr_pow; curr_pow = NULL;
+ //cerr << m_last_max_diff << endl;
+ }
+}
+
+void Engine_Ext_SteadyState::Apply2Current()
+{
+
+}
diff --git a/openEMS/FDTD/extensions/engine_ext_steadystate.h b/openEMS/FDTD/extensions/engine_ext_steadystate.h
new file mode 100644
index 0000000..b66596e
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_steadystate.h
@@ -0,0 +1,51 @@
+/*
+* Copyright (C) 2015 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_EXT_STEADYSTATE_H
+#define ENGINE_EXT_STEADYSTATE_H
+
+#include "engine_extension.h"
+#include "FDTD/engine.h"
+#include "FDTD/operator.h"
+
+class Operator_Ext_SteadyState;
+class Engine_Interface_FDTD;
+
+class Engine_Ext_SteadyState : public Engine_Extension
+{
+public:
+ Engine_Ext_SteadyState(Operator_Ext_SteadyState* op_ext);
+ virtual ~Engine_Ext_SteadyState();
+
+ virtual void Apply2Voltages();
+ virtual void Apply2Current();
+
+ void SetEngineInterface(Engine_Interface_FDTD* eng_if) {m_Eng_Interface=eng_if;}
+ double GetLastDiff() {return m_last_max_diff;}
+
+protected:
+ Operator_Ext_SteadyState* m_Op_SS;
+ double m_last_max_diff;
+ vector<double*> m_E_records;
+ vector<double*> m_H_records;
+
+ double last_total_energy;
+ Engine_Interface_FDTD* m_Eng_Interface;
+};
+
+
+#endif // ENGINE_EXT_STEADYSTATE_H
diff --git a/openEMS/FDTD/extensions/engine_ext_tfsf.cpp b/openEMS/FDTD/extensions/engine_ext_tfsf.cpp
new file mode 100644
index 0000000..cd3b107
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_tfsf.cpp
@@ -0,0 +1,215 @@
+/*
+* Copyright (C) 2012 Thorsten Liebig (Thorsten.Liebig@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 "engine_ext_tfsf.h"
+#include "operator_ext_tfsf.h"
+#include "FDTD/engine_sse.h"
+
+Engine_Ext_TFSF::Engine_Ext_TFSF(Operator_Ext_TFSF* op_ext) : Engine_Extension(op_ext)
+{
+ m_Op_TFSF = op_ext;
+ m_Priority = ENG_EXT_PRIO_TFSF;
+
+ m_DelayLookup = new unsigned int[m_Op_TFSF->m_maxDelay+1];
+}
+
+Engine_Ext_TFSF::~Engine_Ext_TFSF()
+{
+ delete[] m_DelayLookup;
+ m_DelayLookup = NULL;
+}
+
+void Engine_Ext_TFSF::DoPostVoltageUpdates()
+{
+ unsigned int numTS = m_Eng->GetNumberOfTimesteps();
+ unsigned int length = m_Op_TFSF->m_Exc->GetLength();
+
+ int p = int(m_Op_TFSF->m_Exc->GetSignalPeriod()/m_Op_TFSF->m_Exc->GetTimestep());
+
+ for (unsigned int n=0;n<=m_Op_TFSF->m_maxDelay;++n)
+ {
+ if ( numTS < n )
+ m_DelayLookup[n]=0;
+ else if ((numTS-n > length) && (p==0))
+ m_DelayLookup[n]=0;
+ else
+ m_DelayLookup[n] = numTS - n;
+ if (p>0)
+ m_DelayLookup[n] = (m_DelayLookup[n] % p);
+ }
+
+ //get the current signal since an H-field is added ...
+ FDTD_FLOAT* signal = m_Op_TFSF->m_Exc->GetCurrentSignal();
+
+ int nP,nPP;
+ unsigned int ui_pos;
+ unsigned int pos[3];
+ for (int n=0;n<3;++n)
+ {
+ nP = (n+1)%3;
+ nPP = (n+2)%3;
+
+ // lower plane
+ pos[nP] = m_Op_TFSF->m_Start[nP];
+ ui_pos = 0;
+ if (m_Op_TFSF->m_ActiveDir[n][0])
+ {
+
+ for (unsigned int i=0;i<m_Op_TFSF->m_numLines[nP];++i)
+ {
+ pos[nPP] = m_Op_TFSF->m_Start[nPP];
+ for (unsigned int j=0;j<m_Op_TFSF->m_numLines[nPP];++j)
+ {
+ // current updates
+ pos[n] = m_Op_TFSF->m_Start[n];
+
+ m_Eng->SetVolt(nP,pos, m_Eng->GetVolt(nP,pos)
+ + (1.0-m_Op_TFSF->m_VoltDelayDelta[n][0][0][ui_pos])*m_Op_TFSF->m_VoltAmp[n][0][0][ui_pos]*signal[m_DelayLookup[ m_Op_TFSF->m_VoltDelay[n][0][0][ui_pos]]]
+ + m_Op_TFSF->m_VoltDelayDelta[n][0][0][ui_pos] *m_Op_TFSF->m_VoltAmp[n][0][0][ui_pos]*signal[m_DelayLookup[1+m_Op_TFSF->m_VoltDelay[n][0][0][ui_pos]]] );
+
+ m_Eng->SetVolt(nPP,pos, m_Eng->GetVolt(nPP,pos)
+ + (1.0-m_Op_TFSF->m_VoltDelayDelta[n][0][1][ui_pos])*m_Op_TFSF->m_VoltAmp[n][0][1][ui_pos]*signal[m_DelayLookup[ m_Op_TFSF->m_VoltDelay[n][0][1][ui_pos]]]
+ + m_Op_TFSF->m_VoltDelayDelta[n][0][1][ui_pos] *m_Op_TFSF->m_VoltAmp[n][0][1][ui_pos]*signal[m_DelayLookup[1+m_Op_TFSF->m_VoltDelay[n][0][1][ui_pos]]] );
+
+ ++pos[nPP];
+ ++ui_pos;
+ }
+ ++pos[nP];
+ }
+ }
+
+ // upper plane
+ pos[nP] = m_Op_TFSF->m_Start[nP];
+ ui_pos = 0;
+ if (m_Op_TFSF->m_ActiveDir[n][1])
+ {
+
+ for (unsigned int i=0;i<m_Op_TFSF->m_numLines[nP];++i)
+ {
+ pos[nPP] = m_Op_TFSF->m_Start[nPP];
+ for (unsigned int j=0;j<m_Op_TFSF->m_numLines[nPP];++j)
+ {
+ // current updates
+ pos[n] = m_Op_TFSF->m_Stop[n];
+
+ m_Eng->SetVolt(nP,pos, m_Eng->GetVolt(nP,pos)
+ + (1.0-m_Op_TFSF->m_VoltDelayDelta[n][1][0][ui_pos])*m_Op_TFSF->m_VoltAmp[n][1][0][ui_pos]*signal[m_DelayLookup[ m_Op_TFSF->m_VoltDelay[n][1][0][ui_pos]]]
+ + m_Op_TFSF->m_VoltDelayDelta[n][1][0][ui_pos] *m_Op_TFSF->m_VoltAmp[n][1][0][ui_pos]*signal[m_DelayLookup[1+m_Op_TFSF->m_VoltDelay[n][1][0][ui_pos]]] );
+
+ m_Eng->SetVolt(nPP,pos, m_Eng->GetVolt(nPP,pos)
+ + (1.0-m_Op_TFSF->m_VoltDelayDelta[n][1][1][ui_pos])*m_Op_TFSF->m_VoltAmp[n][1][1][ui_pos]*signal[m_DelayLookup[ m_Op_TFSF->m_VoltDelay[n][1][1][ui_pos]]]
+ + m_Op_TFSF->m_VoltDelayDelta[n][1][1][ui_pos] *m_Op_TFSF->m_VoltAmp[n][1][1][ui_pos]*signal[m_DelayLookup[1+m_Op_TFSF->m_VoltDelay[n][1][1][ui_pos]]] );
+
+ ++pos[nPP];
+ ++ui_pos;
+ }
+ ++pos[nP];
+ }
+ }
+ }
+}
+
+void Engine_Ext_TFSF::DoPostCurrentUpdates()
+{
+ unsigned int numTS = m_Eng->GetNumberOfTimesteps();
+ unsigned int length = m_Op_TFSF->m_Exc->GetLength();
+
+ int p = int(m_Op_TFSF->m_Exc->GetSignalPeriod()/m_Op_TFSF->m_Exc->GetTimestep());
+
+ for (unsigned int n=0;n<m_Op_TFSF->m_maxDelay;++n)
+ {
+ if ( numTS < n )
+ m_DelayLookup[n]=0;
+ else if ((numTS-n > length) && (p==0))
+ m_DelayLookup[n]=0;
+ else
+ m_DelayLookup[n] = numTS - n;
+ if (p>0)
+ m_DelayLookup[n] = (m_DelayLookup[n] % p);
+ }
+
+ //get the current signal since an E-field is added ...
+ FDTD_FLOAT* signal = m_Op_TFSF->m_Exc->GetVoltageSignal();
+
+ int nP,nPP;
+ unsigned int ui_pos;
+ unsigned int pos[3];
+ for (int n=0;n<3;++n)
+ {
+ if (!m_Op_TFSF->m_ActiveDir[n][0] && !m_Op_TFSF->m_ActiveDir[n][1])
+ continue;
+
+ nP = (n+1)%3;
+ nPP = (n+2)%3;
+
+ // lower plane
+ pos[nP] = m_Op_TFSF->m_Start[nP];
+ ui_pos = 0;
+ if (m_Op_TFSF->m_ActiveDir[n][0])
+ {
+ for (unsigned int i=0;i<m_Op_TFSF->m_numLines[nP];++i)
+ {
+ pos[nPP] = m_Op_TFSF->m_Start[nPP];
+ for (unsigned int j=0;j<m_Op_TFSF->m_numLines[nPP];++j)
+ {
+ // current updates
+ pos[n] = m_Op_TFSF->m_Start[n]-1;
+
+ m_Eng->SetCurr(nP,pos, m_Eng->GetCurr(nP,pos)
+ + (1.0-m_Op_TFSF->m_CurrDelayDelta[n][0][0][ui_pos])*m_Op_TFSF->m_CurrAmp[n][0][0][ui_pos]*signal[m_DelayLookup[ m_Op_TFSF->m_CurrDelay[n][0][0][ui_pos]]]
+ + m_Op_TFSF->m_CurrDelayDelta[n][0][0][ui_pos] *m_Op_TFSF->m_CurrAmp[n][0][0][ui_pos]*signal[m_DelayLookup[1+m_Op_TFSF->m_CurrDelay[n][0][0][ui_pos]]] );
+
+ m_Eng->SetCurr(nPP,pos, m_Eng->GetCurr(nPP,pos)
+ + (1.0-m_Op_TFSF->m_CurrDelayDelta[n][0][1][ui_pos])*m_Op_TFSF->m_CurrAmp[n][0][1][ui_pos]*signal[m_DelayLookup[ m_Op_TFSF->m_CurrDelay[n][0][1][ui_pos]]]
+ + m_Op_TFSF->m_CurrDelayDelta[n][0][1][ui_pos] *m_Op_TFSF->m_CurrAmp[n][0][1][ui_pos]*signal[m_DelayLookup[1+m_Op_TFSF->m_CurrDelay[n][0][1][ui_pos]]] );
+
+ ++pos[nPP];
+ ++ui_pos;
+ }
+ ++pos[nP];
+ }
+ }
+
+ // upper plane
+ pos[nP] = m_Op_TFSF->m_Start[nP];
+ ui_pos = 0;
+ if (m_Op_TFSF->m_ActiveDir[n][1])
+ {
+ for (unsigned int i=0;i<m_Op_TFSF->m_numLines[nP];++i)
+ {
+ pos[nPP] = m_Op_TFSF->m_Start[nPP];
+ for (unsigned int j=0;j<m_Op_TFSF->m_numLines[nPP];++j)
+ {
+ // current updates
+ pos[n] = m_Op_TFSF->m_Stop[n];
+
+ m_Eng->SetCurr(nP,pos, m_Eng->GetCurr(nP,pos)
+ + (1.0-m_Op_TFSF->m_CurrDelayDelta[n][1][0][ui_pos])*m_Op_TFSF->m_CurrAmp[n][1][0][ui_pos]*signal[m_DelayLookup[ m_Op_TFSF->m_CurrDelay[n][1][0][ui_pos]]]
+ + m_Op_TFSF->m_CurrDelayDelta[n][1][0][ui_pos] *m_Op_TFSF->m_CurrAmp[n][1][0][ui_pos]*signal[m_DelayLookup[1+m_Op_TFSF->m_CurrDelay[n][1][0][ui_pos]]] );
+
+ m_Eng->SetCurr(nPP,pos, m_Eng->GetCurr(nPP,pos)
+ + (1.0-m_Op_TFSF->m_CurrDelayDelta[n][1][1][ui_pos])*m_Op_TFSF->m_CurrAmp[n][1][1][ui_pos]*signal[m_DelayLookup[ m_Op_TFSF->m_CurrDelay[n][1][1][ui_pos]]]
+ + m_Op_TFSF->m_CurrDelayDelta[n][1][1][ui_pos] *m_Op_TFSF->m_CurrAmp[n][1][1][ui_pos]*signal[m_DelayLookup[1+m_Op_TFSF->m_CurrDelay[n][1][1][ui_pos]]] );
+
+ ++pos[nPP];
+ ++ui_pos;
+ }
+ ++pos[nP];
+ }
+ }
+ }
+}
diff --git a/openEMS/FDTD/extensions/engine_ext_tfsf.h b/openEMS/FDTD/extensions/engine_ext_tfsf.h
new file mode 100644
index 0000000..d4e662a
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_tfsf.h
@@ -0,0 +1,40 @@
+/*
+* Copyright (C) 2012 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_EXT_TFSF_H
+#define ENGINE_EXT_TFSF_H
+
+#include "engine_extension.h"
+
+class Operator_Ext_TFSF;
+
+class Engine_Ext_TFSF : public Engine_Extension
+{
+public:
+ Engine_Ext_TFSF(Operator_Ext_TFSF* op_ext);
+ virtual ~Engine_Ext_TFSF();
+
+ virtual void DoPostVoltageUpdates();
+ virtual void DoPostCurrentUpdates();
+
+protected:
+ Operator_Ext_TFSF* m_Op_TFSF;
+
+ unsigned int* m_DelayLookup;
+};
+
+#endif // ENGINE_EXT_TFSF_H
diff --git a/openEMS/FDTD/extensions/engine_ext_upml.cpp b/openEMS/FDTD/extensions/engine_ext_upml.cpp
new file mode 100644
index 0000000..8cb365f
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_upml.cpp
@@ -0,0 +1,493 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine_ext_upml.h"
+#include "operator_ext_upml.h"
+#include "FDTD/engine.h"
+#include "FDTD/engine_sse.h"
+#include "tools/array_ops.h"
+#include "tools/useful.h"
+
+Engine_Ext_UPML::Engine_Ext_UPML(Operator_Ext_UPML* op_ext) : Engine_Extension(op_ext)
+{
+ m_Op_UPML = op_ext;
+
+ //this ABC extension should be executed first!
+ m_Priority = ENG_EXT_PRIO_UPML;
+
+ volt_flux = Create_N_3DArray<FDTD_FLOAT>(m_Op_UPML->m_numLines);
+ curr_flux = Create_N_3DArray<FDTD_FLOAT>(m_Op_UPML->m_numLines);
+
+ SetNumberOfThreads(1);
+}
+
+Engine_Ext_UPML::~Engine_Ext_UPML()
+{
+ Delete_N_3DArray<FDTD_FLOAT>(volt_flux,m_Op_UPML->m_numLines);
+ volt_flux=NULL;
+ Delete_N_3DArray<FDTD_FLOAT>(curr_flux,m_Op_UPML->m_numLines);
+ curr_flux=NULL;
+}
+
+void Engine_Ext_UPML::SetNumberOfThreads(int nrThread)
+{
+ Engine_Extension::SetNumberOfThreads(nrThread);
+
+ m_numX = AssignJobs2Threads(m_Op_UPML->m_numLines[0],m_NrThreads,false);
+ m_start.resize(m_NrThreads,0);
+ m_start.at(0)=0;
+ for (size_t n=1; n<m_numX.size(); ++n)
+ m_start.at(n) = m_start.at(n-1) + m_numX.at(n-1);
+}
+
+
+void Engine_Ext_UPML::DoPreVoltageUpdates(int threadID)
+{
+ if (m_Eng==NULL)
+ return;
+
+ if (threadID>=m_NrThreads)
+ return;
+
+ unsigned int pos[3];
+ unsigned int loc_pos[3];
+ FDTD_FLOAT f_help;
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = m_Op_UPML->vv[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetVolt(0,pos)
+ - m_Op_UPML->vvfo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->Engine::SetVolt(0,pos, volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->vv[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetVolt(1,pos)
+ - m_Op_UPML->vvfo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->Engine::SetVolt(1,pos, volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->vv[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetVolt(2,pos)
+ - m_Op_UPML->vvfo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->Engine::SetVolt(2,pos, volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+ }
+ }
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*) m_Eng;
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = m_Op_UPML->vv[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetVolt(0,pos)
+ - m_Op_UPML->vvfo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ eng_sse->Engine_sse::SetVolt(0,pos, volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->vv[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetVolt(1,pos)
+ - m_Op_UPML->vvfo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ eng_sse->Engine_sse::SetVolt(1,pos, volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->vv[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetVolt(2,pos)
+ - m_Op_UPML->vvfo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ eng_sse->Engine_sse::SetVolt(2,pos, volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+ }
+ }
+ }
+ break;
+ }
+ default:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = m_Op_UPML->vv[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetVolt(0,pos)
+ - m_Op_UPML->vvfo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->SetVolt(0,pos, volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->vv[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetVolt(1,pos)
+ - m_Op_UPML->vvfo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->SetVolt(1,pos, volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->vv[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetVolt(2,pos)
+ - m_Op_UPML->vvfo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->SetVolt(2,pos, volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+ }
+ }
+ }
+ break;
+ }
+ }
+
+}
+
+void Engine_Ext_UPML::DoPostVoltageUpdates(int threadID)
+{
+ if (m_Eng==NULL)
+ return;
+ if (threadID>=m_NrThreads)
+ return;
+
+ unsigned int pos[3];
+ unsigned int loc_pos[3];
+ FDTD_FLOAT f_help;
+
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->Engine::GetVolt(0,pos);
+ m_Eng->Engine::SetVolt(0,pos, f_help + m_Op_UPML->vvfn[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->Engine::GetVolt(1,pos);
+ m_Eng->Engine::SetVolt(1,pos, f_help + m_Op_UPML->vvfn[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->Engine::GetVolt(2,pos);
+ m_Eng->Engine::SetVolt(2,pos, f_help + m_Op_UPML->vvfn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ }
+ }
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*) m_Eng;
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = eng_sse->Engine_sse::GetVolt(0,pos);
+ eng_sse->Engine_sse::SetVolt(0,pos, f_help + m_Op_UPML->vvfn[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = eng_sse->Engine_sse::GetVolt(1,pos);
+ eng_sse->Engine_sse::SetVolt(1,pos, f_help + m_Op_UPML->vvfn[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = eng_sse->Engine_sse::GetVolt(2,pos);
+ eng_sse->Engine_sse::SetVolt(2,pos, f_help + m_Op_UPML->vvfn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ }
+ }
+ }
+ break;
+ }
+ default:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->GetVolt(0,pos);
+ m_Eng->SetVolt(0,pos, f_help + m_Op_UPML->vvfn[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->GetVolt(1,pos);
+ m_Eng->SetVolt(1,pos, f_help + m_Op_UPML->vvfn[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->GetVolt(2,pos);
+ m_Eng->SetVolt(2,pos, f_help + m_Op_UPML->vvfn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ }
+ }
+ }
+ break;
+ }
+ }
+
+}
+
+void Engine_Ext_UPML::DoPreCurrentUpdates(int threadID)
+{
+ if (m_Eng==NULL)
+ return;
+ if (threadID>=m_NrThreads)
+ return;
+
+ unsigned int pos[3];
+ unsigned int loc_pos[3];
+ FDTD_FLOAT f_help;
+
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = m_Op_UPML->ii[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetCurr(0,pos)
+ - m_Op_UPML->iifo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->Engine::SetCurr(0,pos, curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->ii[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetCurr(1,pos)
+ - m_Op_UPML->iifo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->Engine::SetCurr(1,pos, curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->ii[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetCurr(2,pos)
+ - m_Op_UPML->iifo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->Engine::SetCurr(2,pos, curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+ }
+ }
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*) m_Eng;
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = m_Op_UPML->ii[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetCurr(0,pos)
+ - m_Op_UPML->iifo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ eng_sse->Engine_sse::SetCurr(0,pos, curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->ii[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetCurr(1,pos)
+ - m_Op_UPML->iifo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ eng_sse->Engine_sse::SetCurr(1,pos, curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->ii[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetCurr(2,pos)
+ - m_Op_UPML->iifo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ eng_sse->Engine_sse::SetCurr(2,pos, curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ }
+ }
+ }
+ break;
+ }
+ default:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = m_Op_UPML->ii[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetCurr(0,pos)
+ - m_Op_UPML->iifo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->SetCurr(0,pos, curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->ii[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetCurr(1,pos)
+ - m_Op_UPML->iifo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->SetCurr(1,pos, curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+
+ f_help = m_Op_UPML->ii[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetCurr(2,pos)
+ - m_Op_UPML->iifo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ m_Eng->SetCurr(2,pos, curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help;
+ }
+ }
+ }
+ break;
+ }
+ }
+}
+
+void Engine_Ext_UPML::DoPostCurrentUpdates(int threadID)
+{
+ if (m_Eng==NULL)
+ return;
+ if (threadID>=m_NrThreads)
+ return;
+
+ unsigned int pos[3];
+ unsigned int loc_pos[3];
+ FDTD_FLOAT f_help;
+
+ switch (m_Eng->GetType())
+ {
+ case Engine::BASIC:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->Engine::GetCurr(0,pos);
+ m_Eng->Engine::SetCurr(0,pos, f_help + m_Op_UPML->iifn[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->Engine::GetCurr(1,pos);
+ m_Eng->Engine::SetCurr(1,pos, f_help + m_Op_UPML->iifn[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->Engine::GetCurr(2,pos);
+ m_Eng->Engine::SetCurr(2,pos, f_help + m_Op_UPML->iifn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ }
+ }
+ }
+ break;
+ }
+ case Engine::SSE:
+ {
+ Engine_sse* eng_sse = (Engine_sse*) m_Eng;
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = eng_sse->Engine_sse::GetCurr(0,pos);
+ eng_sse->Engine_sse::SetCurr(0,pos, f_help + m_Op_UPML->iifn[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = eng_sse->Engine_sse::GetCurr(1,pos);
+ eng_sse->Engine_sse::SetCurr(1,pos, f_help + m_Op_UPML->iifn[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = eng_sse->Engine_sse::GetCurr(2,pos);
+ eng_sse->Engine_sse::SetCurr(2,pos, f_help + m_Op_UPML->iifn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ }
+ }
+ }
+ break;
+ }
+ default:
+ {
+ for (unsigned int lineX=0; lineX<m_numX.at(threadID); ++lineX)
+ {
+ loc_pos[0]=lineX+m_start.at(threadID);
+ pos[0] = loc_pos[0] + m_Op_UPML->m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_Op_UPML->m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1];
+ for (loc_pos[2]=0; loc_pos[2]<m_Op_UPML->m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2];
+
+ f_help = curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->GetCurr(0,pos);
+ m_Eng->SetCurr(0,pos, f_help + m_Op_UPML->iifn[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->GetCurr(1,pos);
+ m_Eng->SetCurr(1,pos, f_help + m_Op_UPML->iifn[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+
+ f_help = curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]];
+ curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->GetCurr(2,pos);
+ m_Eng->SetCurr(2,pos, f_help + m_Op_UPML->iifn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]);
+ }
+ }
+ }
+ break;
+ }
+ }
+}
diff --git a/openEMS/FDTD/extensions/engine_ext_upml.h b/openEMS/FDTD/extensions/engine_ext_upml.h
new file mode 100644
index 0000000..283c886
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_ext_upml.h
@@ -0,0 +1,55 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_EXT_UPML_H
+#define ENGINE_EXT_UPML_H
+
+#include "engine_extension.h"
+#include "FDTD/engine.h"
+#include "FDTD/operator.h"
+
+class Operator_Ext_UPML;
+
+class Engine_Ext_UPML : public Engine_Extension
+{
+public:
+ Engine_Ext_UPML(Operator_Ext_UPML* op_ext);
+ virtual ~Engine_Ext_UPML();
+
+ virtual void SetNumberOfThreads(int nrThread);
+
+ virtual void DoPreVoltageUpdates() {Engine_Ext_UPML::DoPreVoltageUpdates(0);};
+ virtual void DoPreVoltageUpdates(int threadID);
+ virtual void DoPostVoltageUpdates() {Engine_Ext_UPML::DoPostVoltageUpdates(0);};
+ virtual void DoPostVoltageUpdates(int threadID);
+
+ virtual void DoPreCurrentUpdates() {Engine_Ext_UPML::DoPreCurrentUpdates(0);};
+ virtual void DoPreCurrentUpdates(int threadID);
+ virtual void DoPostCurrentUpdates() {Engine_Ext_UPML::DoPostCurrentUpdates(0);};
+ virtual void DoPostCurrentUpdates(int threadID);
+
+protected:
+ Operator_Ext_UPML* m_Op_UPML;
+
+ vector<unsigned int> m_start;
+ vector<unsigned int> m_numX;
+
+ FDTD_FLOAT**** volt_flux;
+ FDTD_FLOAT**** curr_flux;
+};
+
+#endif // ENGINE_EXT_UPML_H
diff --git a/openEMS/FDTD/extensions/engine_extension.cpp b/openEMS/FDTD/extensions/engine_extension.cpp
new file mode 100644
index 0000000..6f688a3
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_extension.cpp
@@ -0,0 +1,95 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "engine_extension.h"
+#include "operator_extension.h"
+
+#include "FDTD/engine.h"
+
+Engine_Extension::Engine_Extension(Operator_Extension* op_ext)
+{
+ m_Op_ext = op_ext;
+ m_Eng = NULL;
+ m_Priority = ENG_EXT_PRIO_DEFAULT;
+ m_NrThreads = 1;
+}
+
+Engine_Extension::~Engine_Extension()
+{
+}
+
+void Engine_Extension::SetNumberOfThreads(int nrThread)
+{
+ if (nrThread<1)
+ return;
+ m_NrThreads=nrThread;
+}
+
+string Engine_Extension::GetExtensionName() const
+{
+ if (m_Op_ext)
+ return m_Op_ext->GetExtensionName();
+ else
+ return "Unknown Extension";
+}
+
+void Engine_Extension::DoPreVoltageUpdates(int threadID)
+{
+ //if this method gets called the derived extension obviously doesn't support multithrading, calling non-MT method...
+ if (threadID==0)
+ DoPreVoltageUpdates();
+}
+
+void Engine_Extension::DoPostVoltageUpdates(int threadID)
+{
+ //if this method gets called the derived extension obviously doesn't support multithrading, calling non-MT method...
+ if (threadID==0)
+ DoPostVoltageUpdates();
+}
+
+void Engine_Extension::Apply2Voltages(int threadID)
+{
+ //if this method gets called the derived extension obviously doesn't support multithrading, calling non-MT method...
+ if (threadID==0)
+ Apply2Voltages();
+}
+
+void Engine_Extension::DoPreCurrentUpdates(int threadID)
+{
+ //if this method gets called the derived extension obviously doesn't support multithrading, calling non-MT method...
+ if (threadID==0)
+ DoPreCurrentUpdates();
+}
+
+void Engine_Extension::DoPostCurrentUpdates(int threadID)
+{
+ //if this method gets called the derived extension obviously doesn't support multithrading, calling non-MT method...
+ if (threadID==0)
+ DoPostCurrentUpdates();
+}
+
+void Engine_Extension::Apply2Current(int threadID)
+{
+ //if this method gets called the derived extension obviously doesn't support multithrading, calling non-MT method...
+ if (threadID==0)
+ Apply2Current();
+}
+
+bool Engine_Extension::operator< (const Engine_Extension& other)
+{
+ return (GetPriority()<other.GetPriority());
+}
diff --git a/openEMS/FDTD/extensions/engine_extension.h b/openEMS/FDTD/extensions/engine_extension.h
new file mode 100644
index 0000000..12ef712
--- /dev/null
+++ b/openEMS/FDTD/extensions/engine_extension.h
@@ -0,0 +1,88 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 ENGINE_EXTENSION_H
+#define ENGINE_EXTENSION_H
+
+#define ENG_EXT_PRIO_DEFAULT 0 //default engine extension priority
+
+// priority definitions for some important extensions
+#define ENG_EXT_PRIO_STEADYSTATE +2e6 //steady state extension priority
+#define ENG_EXT_PRIO_UPML +1e6 //unaxial pml extension priority
+#define ENG_EXT_PRIO_CYLINDER +1e5 //cylindrial extension priority
+#define ENG_EXT_PRIO_TFSF +5e4 //total-field/scattered-field extension priority
+#define ENG_EXT_PRIO_EXCITATION -1000 //excitation priority
+#define ENG_EXT_PRIO_CYLINDERMULTIGRID -3000 //cylindrial multi-grid extension priority
+
+#include <string>
+
+class Operator_Extension;
+class Engine;
+
+//! Abstract base-class for all engine extensions
+class Engine_Extension
+{
+public:
+ virtual ~Engine_Extension();
+
+ virtual void SetNumberOfThreads(int nrThread);
+
+ //! This methode will be called __before__ the main engine does the usual voltage updates. This methode may __not__ change the engine voltages!!!
+ virtual void DoPreVoltageUpdates() {}
+ virtual void DoPreVoltageUpdates(int threadID);
+ //! This methode will be called __after__ the main engine does the usual voltage updates. This methode may __not__ change the engine voltages!!!
+ virtual void DoPostVoltageUpdates() {}
+ virtual void DoPostVoltageUpdates(int threadID);
+ //! This methode will be called __after__ all updates to the voltages and extensions and may add/set its results to the engine voltages, but may __not__ rely on the current value of the engine voltages!!!
+ virtual void Apply2Voltages() {}
+ virtual void Apply2Voltages(int threadID);
+
+ //! This methode will be called __before__ the main engine does the usual current updates. This methode may __not__ change the engine current!!!
+ virtual void DoPreCurrentUpdates() {}
+ virtual void DoPreCurrentUpdates(int threadID);
+ //! This methode will be called __after__ the main engine does the usual current updates. This methode may __not__ change the engine current!!!
+ virtual void DoPostCurrentUpdates() {}
+ virtual void DoPostCurrentUpdates(int threadID);
+ //! This methode will be called __after__ all updates to the current and extensions and may add/set its results to the engine current, but may __not__ rely on the current value of the engine current!!!
+ virtual void Apply2Current() {}
+ virtual void Apply2Current(int threadID);
+
+ //! Set the Engine to this extention. This will usually done automatically by Engine::AddExtension
+ virtual void SetEngine(Engine* eng) {m_Eng=eng;}
+
+ //! Get the priority for this extension
+ virtual int GetPriority() const {return m_Priority;}
+
+ //! Set the priority for this extension
+ virtual void SetPriority(int val) {m_Priority=val;}
+
+ virtual bool operator< (const Engine_Extension& other);
+
+ virtual std::string GetExtensionName() const;
+
+protected:
+ Engine_Extension(Operator_Extension* op_ext);
+
+ Operator_Extension* m_Op_ext;
+ Engine* m_Eng;
+
+ int m_Priority;
+
+ int m_NrThreads;
+};
+
+#endif // ENGINE_EXTENSION_H
diff --git a/openEMS/FDTD/extensions/operator_ext_conductingsheet.cpp b/openEMS/FDTD/extensions/operator_ext_conductingsheet.cpp
new file mode 100644
index 0000000..28c51bb
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_conductingsheet.cpp
@@ -0,0 +1,261 @@
+/*
+* Copyright (C) 2012 Thorsten Liebig (Thorsten.Liebig@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 "operator_ext_conductingsheet.h"
+#include "tools/array_ops.h"
+#include "tools/constants.h"
+#include "cond_sheet_parameter.h"
+
+#include "CSPropConductingSheet.h"
+
+Operator_Ext_ConductingSheet::Operator_Ext_ConductingSheet(Operator* op, double f_max) : Operator_Ext_LorentzMaterial(op)
+{
+ m_f_max = f_max;
+}
+
+Operator_Ext_ConductingSheet::Operator_Ext_ConductingSheet(Operator* op, Operator_Ext_ConductingSheet* op_ext) : Operator_Ext_LorentzMaterial(op, op_ext)
+{
+ m_f_max = op_ext->m_f_max;
+}
+
+Operator_Extension* Operator_Ext_ConductingSheet::Clone(Operator* op)
+{
+ if (dynamic_cast<Operator_Ext_ConductingSheet*>(this)==NULL)
+ return NULL;
+ return new Operator_Ext_ConductingSheet(op, this);
+}
+
+bool Operator_Ext_ConductingSheet::BuildExtension()
+{
+ double dT = m_Op->GetTimestep();
+ unsigned int pos[] = {0,0,0};
+ double coord[3];
+ unsigned int numLines[3] = {m_Op->GetNumberOfLines(0,true),m_Op->GetNumberOfLines(1,true),m_Op->GetNumberOfLines(2,true)};
+
+ m_Order = 0;
+ vector<unsigned int> v_pos[3];
+ int ****tanDir = Create_N_3DArray<int>(numLines);
+ float ****Conductivity = Create_N_3DArray<float>(numLines);
+ float ****Thickness = Create_N_3DArray<float>(numLines);
+
+ CSPrimitives* cs_sheet = NULL;
+ double box[6];
+ int nP, nPP;
+ bool b_pos_on;
+ bool disable_pos;
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ vector<CSPrimitives*> vPrims = m_Op->GetPrimitivesBoundBox(pos[0], pos[1], -1, (CSProperties::PropertyType)(CSProperties::MATERIAL | CSProperties::METAL));
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ b_pos_on = false;
+ disable_pos = false;
+ // disable conducting sheet model inside the boundary conditions, especially inside a pml
+ for (int m=0;m<3;++m)
+ if ((pos[m]<=(unsigned int)m_Op->GetBCSize(2*m)) || (pos[m]>=(numLines[m]-m_Op->GetBCSize(2*m+1)-1)))
+ disable_pos = true;
+
+ for (int n=0; n<3; ++n)
+ {
+ nP = (n+1)%3;
+ nPP = (n+2)%3;
+
+ tanDir[n][pos[0]][pos[1]][pos[2]] = -1; //deactivate by default
+ Conductivity[n][pos[0]][pos[1]][pos[2]] = 0; //deactivate by default
+ Thickness[n][pos[0]][pos[1]][pos[2]] = 0; //deactivate by default
+
+ if (m_Op->GetYeeCoords(n,pos,coord,false)==false)
+ continue;
+
+ // Ez at r==0 not supported --> set to PEC
+ if (m_CC_R0_included && (n==2) && (pos[0]==0))
+ disable_pos = true;
+
+// CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord,(CSProperties::PropertyType)(CSProperties::METAL | CSProperties::MATERIAL), false, &cs_sheet);
+ CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord, vPrims, false, &cs_sheet);
+ CSPropConductingSheet* cs_prop = dynamic_cast<CSPropConductingSheet*>(prop);
+ if (cs_prop)
+ {
+ if (cs_sheet==NULL)
+ return false; //sanity check, this should never happen
+ if (cs_sheet->GetDimension()!=2)
+ {
+ cerr << "Operator_Ext_ConductingSheet::BuildExtension: A conducting sheet primitive (ID: " << cs_sheet->GetID() << ") with dimension: " << cs_sheet->GetDimension() << " found, fallback to PEC!" << endl;
+ m_Op->SetVV(n,pos[0],pos[1],pos[2], 0 );
+ m_Op->SetVI(n,pos[0],pos[1],pos[2], 0 );
+ ++m_Op->m_Nr_PEC[n];
+ continue;
+ }
+ cs_sheet->SetPrimitiveUsed(true);
+
+ if (disable_pos)
+ {
+ m_Op->SetVV(n,pos[0],pos[1],pos[2], 0 );
+ m_Op->SetVI(n,pos[0],pos[1],pos[2], 0 );
+ ++m_Op->m_Nr_PEC[n];
+ continue;
+ }
+
+ Conductivity[n][pos[0]][pos[1]][pos[2]] = cs_prop->GetConductivity();
+ Thickness[n][pos[0]][pos[1]][pos[2]] = cs_prop->GetThickness();
+
+ if ((Conductivity[n][pos[0]][pos[1]][pos[2]]<=0) || (Thickness[n][pos[0]][pos[1]][pos[2]]<=0))
+ {
+ cerr << "Operator_Ext_ConductingSheet::BuildExtension: Warning: Zero conductivity or thickness detected... fallback to PEC!" << endl;
+ m_Op->SetVV(n,pos[0],pos[1],pos[2], 0 );
+ m_Op->SetVI(n,pos[0],pos[1],pos[2], 0 );
+ ++m_Op->m_Nr_PEC[n];
+ continue;
+ }
+
+ cs_sheet->GetBoundBox(box);
+ if (box[2*nP]!=box[2*nP+1])
+ tanDir[n][pos[0]][pos[1]][pos[2]] = nP;
+ if (box[2*nPP]!=box[2*nPP+1])
+ tanDir[n][pos[0]][pos[1]][pos[2]] = nPP;
+ b_pos_on = true;
+ }
+ }
+ if (b_pos_on)
+ {
+ for (int n=0; n<3; ++n)
+ v_pos[n].push_back(pos[n]);
+ }
+ }
+ }
+ }
+
+ size_t numCS = v_pos[0].size();
+ if (numCS==0)
+ return false;
+
+ m_LM_Count.push_back(numCS);
+ m_LM_Count.push_back(numCS);
+
+ m_Order = 2;
+ m_volt_ADE_On = new bool[m_Order];
+ m_volt_ADE_On[0] = m_volt_ADE_On[1]=true;
+ m_curr_ADE_On = new bool[m_Order];
+ m_curr_ADE_On[0] = m_curr_ADE_On[1]=false;
+
+ m_volt_Lor_ADE_On = new bool[m_Order];
+ m_volt_Lor_ADE_On[0] = m_volt_Lor_ADE_On[1]=false;
+ m_curr_Lor_ADE_On = new bool[m_Order];
+ m_curr_Lor_ADE_On[0] = m_curr_Lor_ADE_On[1]=false;
+
+ m_LM_pos = new unsigned int**[m_Order];
+ m_LM_pos[0] = new unsigned int*[3];
+ m_LM_pos[1] = new unsigned int*[3];
+
+ v_int_ADE = new FDTD_FLOAT**[m_Order];
+ v_ext_ADE = new FDTD_FLOAT**[m_Order];
+
+ v_int_ADE[0] = new FDTD_FLOAT*[3];
+ v_ext_ADE[0] = new FDTD_FLOAT*[3];
+ v_int_ADE[1] = new FDTD_FLOAT*[3];
+ v_ext_ADE[1] = new FDTD_FLOAT*[3];
+
+ for (int n=0; n<3; ++n)
+ {
+ m_LM_pos[0][n] = new unsigned int[numCS];
+ m_LM_pos[1][n] = new unsigned int[numCS];
+ for (unsigned int i=0; i<numCS; ++i)
+ {
+ m_LM_pos[0][n][i] = v_pos[n].at(i);
+ m_LM_pos[1][n][i] = v_pos[n].at(i);
+ }
+ v_int_ADE[0][n] = new FDTD_FLOAT[numCS];
+ v_int_ADE[1][n] = new FDTD_FLOAT[numCS];
+ v_ext_ADE[0][n] = new FDTD_FLOAT[numCS];
+ v_ext_ADE[1][n] = new FDTD_FLOAT[numCS];
+ }
+
+ unsigned int index;
+ float w_stop = m_f_max*2*PI;
+ float Omega_max=0;
+ float G,L1,L2,R1,R2,Lmin;
+ float G0, w0;
+ float wtl; //width to length factor
+ float factor=1;
+ int t_dir=0; //tangential sheet direction
+ unsigned int tpos[] = {0,0,0};
+ unsigned int optParaPos;
+ for (unsigned int i=0;i<numCS;++i)
+ {
+ pos[0]=m_LM_pos[0][0][i];pos[1]=m_LM_pos[0][1][i];pos[2]=m_LM_pos[0][2][i];
+ tpos[0]=pos[0];tpos[1]=pos[1];tpos[2]=pos[2];
+ index = m_Op->MainOp->SetPos(pos[0],pos[1],pos[2]);
+ for (int n=0;n<3;++n)
+ {
+ tpos[0]=pos[0];tpos[1]=pos[1];tpos[2]=pos[2];
+ t_dir = tanDir[n][pos[0]][pos[1]][pos[2]];
+ G0 = Conductivity[n][pos[0]][pos[1]][pos[2]]*Thickness[n][pos[0]][pos[1]][pos[2]];
+ w0 = 8.0/ G0 / Thickness[n][pos[0]][pos[1]][pos[2]]/__MUE0__;
+ Omega_max = w_stop/w0;
+ for (optParaPos=0;optParaPos<numOptPara;++optParaPos)
+ if (omega_stop[optParaPos]>Omega_max)
+ break;
+ if (optParaPos>=numOptPara)
+ {
+ cerr << "Operator_Ext_ConductingSheet::BuildExtension(): Error, conductor thickness, conductivity or max. simulation frequency of interest is too high! Check parameter!" << endl;
+ cerr << " --> max f: " << m_f_max << "Hz, Conductivity: " << Conductivity[n][pos[0]][pos[1]][pos[2]] << "S/m, Thickness " << Thickness[n][pos[0]][pos[1]][pos[2]]*1e6 << "um" << endl;
+ optParaPos = numOptPara-1;
+ }
+ v_int_ADE[0][n][i]=0;
+ v_ext_ADE[0][n][i]=0;
+ v_int_ADE[1][n][i]=0;
+ v_ext_ADE[1][n][i]=0;
+ if (t_dir>=0)
+ {
+ wtl = m_Op->GetEdgeLength(n,pos)/m_Op->GetNodeWidth(t_dir,pos);
+ factor = 1;
+ if (tanDir[t_dir][tpos[0]][tpos[1]][tpos[2]]<0)
+ factor = 2;
+ --tpos[t_dir];
+ if (tanDir[t_dir][tpos[0]][tpos[1]][tpos[2]]<0)
+ factor = 2;
+
+ L1 = l1[optParaPos]/G0/w0*factor;
+ L2 = l2[optParaPos]/G0/w0*factor;
+ R1 = r1[optParaPos]/G0*factor;
+ R2 = r2[optParaPos]/G0*factor;
+ G = G0*g[optParaPos]/factor;
+
+ L1*=wtl;
+ L2*=wtl;
+ R1*=wtl;
+ R2*=wtl;
+ G/=wtl;
+
+ Lmin = L1;
+ if (L2<L1)
+ Lmin = L2;
+ m_Op->EC_G[n][index]= G;
+ m_Op->EC_C[n][index]= dT*dT/4.0*(16.0/Lmin + 1/L1 + 1/L2);
+ m_Op->Calc_ECOperatorPos(n,pos);
+
+ v_int_ADE[0][n][i]=(2.0*L1-dT*R1)/(2.0*L1+dT*R1);
+ v_ext_ADE[0][n][i]=dT/(L1+dT*R1/2.0)*m_Op->GetVI(n,pos[0],pos[1],pos[2]);
+ v_int_ADE[1][n][i]=(2.0*L2-dT*R2)/(2.0*L2+dT*R2);
+ v_ext_ADE[1][n][i]=dT/(L2+dT*R2/2.0)*m_Op->GetVI(n,pos[0],pos[1],pos[2]);
+ }
+ }
+ }
+ return true;
+}
diff --git a/openEMS/FDTD/extensions/operator_ext_conductingsheet.h b/openEMS/FDTD/extensions/operator_ext_conductingsheet.h
new file mode 100644
index 0000000..f84dc4b
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_conductingsheet.h
@@ -0,0 +1,51 @@
+/*
+* Copyright (C) 2012 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXT_CONDUCTINGSHEET_H
+#define OPERATOR_EXT_CONDUCTINGSHEET_H
+
+#include "FDTD/operator.h"
+#include "operator_ext_lorentzmaterial.h"
+
+/*!
+ FDTD extension for a conducting sheet model as described in:
+ Lauer, A.; Wolff, I.; , "A conducting sheet model for efficient wide band FDTD analysis of planar waveguides and circuits," Microwave Symposium Digest, 1999 IEEE MTT-S International , vol.4, no., pp.1589-1592 vol.4, 1999
+ doi: 10.1109/MWSYM.1999.780262
+ URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=780262&isnumber=16934
+ */
+class Operator_Ext_ConductingSheet : public Operator_Ext_LorentzMaterial
+{
+public:
+ Operator_Ext_ConductingSheet(Operator* op, double f_max);
+
+ virtual Operator_Extension* Clone(Operator* op);
+
+ virtual bool BuildExtension();
+
+ virtual bool IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const {UNUSED(closedAlpha); UNUSED(R0_included); return true;}
+ virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child); return true;}
+ virtual bool IsMPISave() const {return true;}
+
+ virtual string GetExtensionName() const {return string("Conducting Sheet Extension");}
+
+protected:
+ //! Copy constructor
+ Operator_Ext_ConductingSheet(Operator* op, Operator_Ext_ConductingSheet* op_ext);
+ double m_f_max;
+};
+
+#endif // OPERATOR_EXT_CONDUCTINGSHEET_H
diff --git a/openEMS/FDTD/extensions/operator_ext_cylinder.cpp b/openEMS/FDTD/extensions/operator_ext_cylinder.cpp
new file mode 100644
index 0000000..d400bf8
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_cylinder.cpp
@@ -0,0 +1,114 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "operator_ext_cylinder.h"
+#include "FDTD/operator_cylinder.h"
+#include "engine_ext_cylinder.h"
+
+Operator_Ext_Cylinder::Operator_Ext_Cylinder(Operator_Cylinder* op) : Operator_Extension(op)
+{
+ m_Op_Cyl = op;
+
+ CC_R0_included=m_Op_Cyl->GetR0Included();
+ CC_closedAlpha=m_Op_Cyl->GetClosedAlpha();
+
+ vv_R0 = NULL;
+ vi_R0 = NULL;
+}
+
+Operator_Ext_Cylinder::~Operator_Ext_Cylinder()
+{
+ delete[] vv_R0;
+ vv_R0=NULL;
+ delete[] vi_R0;
+ vi_R0=NULL;
+}
+
+bool Operator_Ext_Cylinder::BuildExtension()
+{
+ delete[] vv_R0;
+ vv_R0=NULL;
+ delete[] vi_R0;
+ vi_R0=NULL;
+
+ //if r=0 is not included -> obviously no special treatment for r=0
+ //if alpha direction is not closed, PEC-BC at r=0 necessary and already set...
+ if (CC_R0_included==false)
+ return true;
+
+ vv_R0 = new FDTD_FLOAT[m_Op->GetNumberOfLines(2,true)];
+ vi_R0 = new FDTD_FLOAT[m_Op->GetNumberOfLines(2,true)];
+
+ unsigned int pos[3];
+ double coord[3];
+ double inEC[4];
+ double dT = m_Op->GetTimestep();
+ pos[0]=0;
+ vector<CSPrimitives*> vPrims_metal = m_Op->GetPrimitivesBoundBox(pos[0], -1, -1, (CSProperties::PropertyType)(CSProperties::MATERIAL | CSProperties::METAL));
+ for (pos[2]=0; pos[2]<m_Op->GetNumberOfLines(2,true); ++pos[2])
+ {
+ double C=0;
+ double G=0;
+ vector<CSPrimitives*> vPrims_mat = m_Op->GetPrimitivesBoundBox(pos[0], -1, pos[2], CSProperties::MATERIAL);
+ for (pos[1]=0; pos[1]<m_Op->GetNumberOfLines(1,true)-2; ++pos[1])
+ {
+ m_Op_Cyl->Calc_ECPos(2,pos,inEC,vPrims_mat);
+ C+=inEC[0];
+ G+=inEC[1];
+ }
+ m_Op->SetVV(2,0,0,pos[2], 1);
+ vv_R0[pos[2]] = (1-dT*G/2/C)/(1+dT*G/2/C);
+ vi_R0[pos[2]] = (dT/C)/(1+dT*G/2/C);
+
+ for (unsigned int i=0; i<m_Op->GetNumberOfLines(1,true); ++i)
+ {
+ m_Op->EC_C[2][m_Op->MainOp->SetPos(0,i,pos[2])] = C;
+ m_Op->EC_G[2][m_Op->MainOp->SetPos(0,i,pos[2])] = G;
+ }
+
+ //search for metal on z-axis
+ m_Op_Cyl->GetYeeCoords(2,pos,coord,false);
+ CSProperties* prop = m_Op->CSX->GetPropertyByCoordPriority(coord, vPrims_metal, true);
+ if (prop)
+ {
+ if (prop->GetType()==CSProperties::METAL) //set to PEC
+ {
+ m_Op->SetVV(2,0,0,pos[2], 0);
+ vv_R0[pos[2]] = 0;
+ vi_R0[pos[2]] = 0;
+ m_Op->EC_C[2][m_Op->MainOp->SetPos(0,0,pos[2])] = 0;
+ m_Op->EC_G[2][m_Op->MainOp->SetPos(0,0,pos[2])] = 0;
+ }
+ }
+ }
+ return true;
+}
+
+Engine_Extension* Operator_Ext_Cylinder::CreateEngineExtention()
+{
+ Engine_Ext_Cylinder* eng_ext = new Engine_Ext_Cylinder(this);
+ return eng_ext;
+}
+
+
+void Operator_Ext_Cylinder::ShowStat(ostream &ostr) const
+{
+ Operator_Extension::ShowStat(ostr);
+ string On_Off[2] = {"Off", "On"};
+ ostr << " Zeroth Radius\t\t: " << On_Off[CC_R0_included] << endl;
+ ostr << " Closed Rotation\t: " << On_Off[CC_closedAlpha] << endl;
+}
diff --git a/openEMS/FDTD/extensions/operator_ext_cylinder.h b/openEMS/FDTD/extensions/operator_ext_cylinder.h
new file mode 100644
index 0000000..c8dff2d
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_cylinder.h
@@ -0,0 +1,60 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXT_CYLINDER_H
+#define OPERATOR_EXT_CYLINDER_H
+
+#include "operator_extension.h"
+#include "FDTD/operator.h"
+
+class Operator_Cylinder;
+
+class Operator_Ext_Cylinder : public Operator_Extension
+{
+ friend class Engine_Ext_Cylinder;
+ friend class Operator_Ext_LorentzMaterial;
+public:
+ Operator_Ext_Cylinder(Operator_Cylinder* op);
+ ~Operator_Ext_Cylinder();
+
+ virtual bool BuildExtension();
+
+ virtual Engine_Extension* CreateEngineExtention();
+
+ virtual bool IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const {UNUSED(closedAlpha); UNUSED(R0_included); return true;}
+ virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child); return true;}
+
+ // FIXME, this extension is not save or unknown to be save to use with MPI
+ virtual bool IsMPISave() const {return false;}
+
+ virtual std::string GetExtensionName() const {return std::string("Extension for the Cylinder-Coords Operator");}
+
+ virtual void ShowStat(ostream &ostr) const;
+
+protected:
+ Operator_Cylinder* m_Op_Cyl;
+
+ bool CC_closedAlpha;
+ bool CC_R0_included;
+
+ //special EC operator for R0
+ FDTD_FLOAT* vv_R0; //calc new voltage from old voltage
+ FDTD_FLOAT* vi_R0; //calc new voltage from old current
+
+};
+
+#endif // OPERATOR_EXT_CYLINDER_H
diff --git a/openEMS/FDTD/extensions/operator_ext_dispersive.cpp b/openEMS/FDTD/extensions/operator_ext_dispersive.cpp
new file mode 100644
index 0000000..ed01f1d
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_dispersive.cpp
@@ -0,0 +1,78 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "operator_ext_dispersive.h"
+
+#include "tools/array_ops.h"
+
+using namespace std;
+
+Operator_Ext_Dispersive::Operator_Ext_Dispersive(Operator* op) : Operator_Extension(op)
+{
+ m_curr_ADE_On = NULL;
+ m_volt_ADE_On = NULL;
+
+ m_LM_pos=NULL;
+ m_curr_ADE_On=NULL;
+ m_volt_ADE_On=NULL;
+
+ m_Order = 0;
+}
+
+Operator_Ext_Dispersive::Operator_Ext_Dispersive(Operator* op, Operator_Ext_Dispersive* op_ext) : Operator_Extension(op,op_ext)
+{
+ m_curr_ADE_On = NULL;
+ m_volt_ADE_On = NULL;
+
+ m_LM_pos=NULL;
+ m_curr_ADE_On=NULL;
+ m_volt_ADE_On=NULL;
+
+ m_Order = 0;
+}
+
+Operator_Ext_Dispersive::~Operator_Ext_Dispersive()
+{
+ delete[] m_curr_ADE_On;
+ delete[] m_volt_ADE_On;
+ m_curr_ADE_On=NULL;
+ m_volt_ADE_On=NULL;
+
+ for (int n=0;n<m_Order;++n)
+ {
+ delete[] m_LM_pos[n][0];
+ delete[] m_LM_pos[n][1];
+ delete[] m_LM_pos[n][2];
+ }
+ delete[] m_LM_pos;
+ m_LM_pos=NULL;
+ m_Order=0;
+ m_LM_Count.clear();
+}
+
+void Operator_Ext_Dispersive::ShowStat(ostream &ostr) const
+{
+ Operator_Extension::ShowStat(ostr);
+ string On_Off[2] = {"Off", "On"};
+ ostr << " Max. Dispersion Order N = " << m_Order << endl;
+ for (int i=0;i<m_Order;++i)
+ {
+ ostr << " N=" << i << ":\t Active cells\t\t: " << m_LM_Count.at(i) << endl;
+ ostr << " N=" << i << ":\t Voltage ADE is \t: " << On_Off[m_volt_ADE_On[i]] << endl;
+ ostr << " N=" << i << ":\t Current ADE is \t: " << On_Off[m_curr_ADE_On[i]] << endl;
+ }
+}
diff --git a/openEMS/FDTD/extensions/operator_ext_dispersive.h b/openEMS/FDTD/extensions/operator_ext_dispersive.h
new file mode 100644
index 0000000..fab354c
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_dispersive.h
@@ -0,0 +1,56 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXT_DISPERSIVE_H
+#define OPERATOR_EXT_DISPERSIVE_H
+
+//#include "operator.h"
+#include "operator_extension.h"
+#include "vector"
+
+//! Abstract base class for all dispersive material models, based on an ADE (additional differential equation)
+class Operator_Ext_Dispersive : public Operator_Extension
+{
+ friend class Engine_Ext_Dispersive;
+public:
+ virtual ~Operator_Ext_Dispersive();
+
+ virtual int GetDispersionOrder() {return m_Order;}
+
+ virtual std::string GetExtensionName() const {return std::string("Dispersive Material Abstract Base class");}
+
+ virtual void ShowStat(std::ostream &ostr) const;
+
+protected:
+ Operator_Ext_Dispersive(Operator* op);
+ //! Copy constructor
+ Operator_Ext_Dispersive(Operator* op, Operator_Ext_Dispersive* op_ext);
+
+ //! Dispersive order
+ int m_Order;
+
+ //! Dispersive material count
+ std::vector<unsigned int> m_LM_Count;
+ //! Index with dispersive material
+ // Array setup: m_LM_pos[N_order][direction][mesh_pos]
+ unsigned int ***m_LM_pos;
+
+ bool *m_curr_ADE_On;
+ bool *m_volt_ADE_On;
+};
+
+#endif // OPERATOR_EXT_DISPERSIVE_H
diff --git a/openEMS/FDTD/extensions/operator_ext_excitation.cpp b/openEMS/FDTD/extensions/operator_ext_excitation.cpp
new file mode 100644
index 0000000..d2085ff
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_excitation.cpp
@@ -0,0 +1,372 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 "operator_ext_excitation.h"
+#include "engine_ext_excitation.h"
+#include "FDTD/excitation.h"
+#include "ContinuousStructure.h"
+
+#include "CSPrimCurve.h"
+#include "CSPropExcitation.h"
+
+Operator_Ext_Excitation::Operator_Ext_Excitation(Operator* op) : Operator_Extension(op)
+{
+ Init();
+}
+
+Operator_Ext_Excitation::~Operator_Ext_Excitation()
+{
+ Reset();
+}
+
+Operator_Extension* Operator_Ext_Excitation::Clone(Operator* op)
+{
+ Operator_Ext_Excitation* clone = new Operator_Ext_Excitation(op, this);
+ return clone;
+}
+
+void Operator_Ext_Excitation::Init()
+{
+ Operator_Extension::Init();
+ Volt_delay = 0;
+ Volt_amp = 0;
+ Volt_dir = 0;
+ Volt_Count = 0;
+ Curr_delay = 0;
+ Curr_amp = 0;
+ Curr_dir = 0;
+ Curr_Count = 0;
+
+ for (int n=0; n<3; ++n)
+ {
+ Volt_index[n] = 0;
+ Curr_index[n] = 0;
+ Volt_Count_Dir[n] = 0;
+ Curr_Count_Dir[n] = 0;
+ }
+ m_Exc = 0;
+}
+
+void Operator_Ext_Excitation::Reset()
+{
+ Operator_Extension::Reset();
+ delete[] Volt_delay;
+ Volt_delay = 0;
+ delete[] Volt_dir;
+ Volt_dir = 0;
+ delete[] Volt_amp;
+ Volt_amp = 0;
+ delete[] Curr_delay;
+ Curr_delay = 0;
+ delete[] Curr_dir;
+ Curr_dir = 0;
+ delete[] Curr_amp;
+ Curr_amp = 0;
+
+ Volt_Count = 0;
+ Curr_Count = 0;
+
+ for (int n=0; n<3; ++n)
+ {
+ delete[] Volt_index[n];
+ Volt_index[n] = 0;
+ delete[] Curr_index[n];
+ Curr_index[n] = 0;
+
+ Volt_Count_Dir[n] = 0;
+ Curr_Count_Dir[n] = 0;
+ }
+}
+
+
+Operator_Ext_Excitation::Operator_Ext_Excitation(Operator* op, Operator_Ext_Excitation* op_ext) : Operator_Extension(op, op_ext)
+{
+ Init();
+}
+
+bool Operator_Ext_Excitation::BuildExtension()
+{
+ m_Exc = m_Op->GetExcitationSignal();
+ double dT = m_Op->GetTimestep();
+ if (dT==0)
+ return false;
+ if (m_Exc==0)
+ return false;
+
+ Reset();
+ ContinuousStructure* CSX = m_Op->GetGeometryCSX();
+
+ unsigned int pos[3];
+ double amp=0;
+
+ vector<unsigned int> volt_vIndex[3];
+ vector<FDTD_FLOAT> volt_vExcit;
+ vector<unsigned int> volt_vDelay;
+ vector<unsigned int> volt_vDir;
+ double volt_coord[3];
+
+ vector<unsigned int> curr_vIndex[3];
+ vector<FDTD_FLOAT> curr_vExcit;
+ vector<unsigned int> curr_vDelay;
+ vector<unsigned int> curr_vDir;
+ double curr_coord[3];
+
+ vector<CSProperties*> vec_prop = CSX->GetPropertyByType(CSProperties::EXCITATION);
+
+ if (vec_prop.size()==0)
+ {
+ cerr << "Operator::CalcFieldExcitation: Warning, no excitation properties found" << endl;
+ return false;
+ }
+
+ CSPropExcitation* elec=NULL;
+ CSProperties* prop=NULL;
+ int priority=0;
+
+ unsigned int numLines[] = {m_Op->GetNumberOfLines(0,true),m_Op->GetNumberOfLines(1,true),m_Op->GetNumberOfLines(2,true)};
+
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ //electric field excite
+ for (int n=0; n<3; ++n)
+ {
+ if (m_Op->GetYeeCoords(n,pos,volt_coord,false)==false)
+ continue;
+ if (m_CC_R0_included && (n==2) && (pos[0]==0))
+ volt_coord[1] = m_Op->GetDiscLine(1,0);
+
+ if (m_CC_R0_included && (n==1) && (pos[0]==0))
+ continue;
+
+ for (size_t p=0; p<vec_prop.size(); ++p)
+ {
+ prop = vec_prop.at(p);
+ elec = prop->ToExcitation();
+ if (elec==NULL)
+ continue;
+ if (prop->CheckCoordInPrimitive(volt_coord,priority,true))
+ {
+ if ((elec->GetActiveDir(n)) && ( (elec->GetExcitType()==0) || (elec->GetExcitType()==1) ))//&& (pos[n]<numLines[n]-1))
+ {
+ amp = elec->GetWeightedExcitation(n,volt_coord)*m_Op->GetEdgeLength(n,pos);// delta[n]*gridDelta;
+ if (amp!=0)
+ {
+ volt_vExcit.push_back(amp);
+ volt_vDelay.push_back((unsigned int)(elec->GetDelay()/dT));
+ volt_vDir.push_back(n);
+ volt_vIndex[0].push_back(pos[0]);
+ volt_vIndex[1].push_back(pos[1]);
+ volt_vIndex[2].push_back(pos[2]);
+ }
+ if (elec->GetExcitType()==1) //hard excite
+ {
+ m_Op->SetVV(n,pos[0],pos[1],pos[2], 0 );
+ m_Op->SetVI(n,pos[0],pos[1],pos[2], 0 );
+ }
+ }
+ }
+ }
+ }
+
+ //magnetic field excite
+ for (int n=0; n<3; ++n)
+ {
+ if ((pos[0]>=numLines[0]-1) || (pos[1]>=numLines[1]-1) || (pos[2]>=numLines[2]-1))
+ continue; //skip the last H-Line which is outside the FDTD-domain
+ if (m_Op->GetYeeCoords(n,pos,curr_coord,true)==false)
+ continue;
+ for (size_t p=0; p<vec_prop.size(); ++p)
+ {
+ prop = vec_prop.at(p);
+ elec = prop->ToExcitation();
+ if (elec==NULL)
+ continue;
+ if (prop->CheckCoordInPrimitive(curr_coord,priority,true))
+ {
+ if ((elec->GetActiveDir(n)) && ( (elec->GetExcitType()==2) || (elec->GetExcitType()==3) ))
+ {
+ amp = elec->GetWeightedExcitation(n,curr_coord)*m_Op->GetEdgeLength(n,pos,true);// delta[n]*gridDelta;
+ if (amp!=0)
+ {
+ curr_vExcit.push_back(amp);
+ curr_vDelay.push_back((unsigned int)(elec->GetDelay()/dT));
+ curr_vDir.push_back(n);
+ curr_vIndex[0].push_back(pos[0]);
+ curr_vIndex[1].push_back(pos[1]);
+ curr_vIndex[2].push_back(pos[2]);
+ }
+ if (elec->GetExcitType()==3) //hard excite
+ {
+ m_Op->SetII(n,pos[0],pos[1],pos[2], 0 );
+ m_Op->SetIV(n,pos[0],pos[1],pos[2], 0 );
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+
+ //special treatment for primitives of type curve (treated as wires) see also Calc_PEC
+ double p1[3];
+ double p2[3];
+ Grid_Path path;
+ for (size_t p=0; p<vec_prop.size(); ++p)
+ {
+ prop = vec_prop.at(p);
+ elec = prop->ToExcitation();
+ for (size_t n=0; n<prop->GetQtyPrimitives(); ++n)
+ {
+ CSPrimitives* prim = prop->GetPrimitive(n);
+ CSPrimCurve* curv = prim->ToCurve();
+ if (curv)
+ {
+ for (size_t i=1; i<curv->GetNumberOfPoints(); ++i)
+ {
+ curv->GetPoint(i-1,p1,m_Op->m_MeshType);
+ curv->GetPoint(i,p2,m_Op->m_MeshType);
+ path = m_Op->FindPath(p1,p2);
+ if (path.dir.size()>0)
+ prim->SetPrimitiveUsed(true);
+ for (size_t t=0; t<path.dir.size(); ++t)
+ {
+ n = path.dir.at(t);
+ pos[0] = path.posPath[0].at(t);
+ pos[1] = path.posPath[1].at(t);
+ pos[2] = path.posPath[2].at(t);
+ m_Op->GetYeeCoords(n,pos,volt_coord,false);
+ if (elec!=NULL)
+ {
+ if ((elec->GetActiveDir(n)) && (pos[n]<numLines[n]-1) && ( (elec->GetExcitType()==0) || (elec->GetExcitType()==1) ))
+ {
+ amp = elec->GetWeightedExcitation(n,volt_coord)*m_Op->GetEdgeLength(n,pos);
+ if (amp!=0)
+ {
+ volt_vExcit.push_back(amp);
+ volt_vDelay.push_back((unsigned int)(elec->GetDelay()/dT));
+ volt_vDir.push_back(n);
+ volt_vIndex[0].push_back(pos[0]);
+ volt_vIndex[1].push_back(pos[1]);
+ volt_vIndex[2].push_back(pos[2]);
+ }
+ if (elec->GetExcitType()==1) //hard excite
+ {
+ m_Op->SetVV(n,pos[0],pos[1],pos[2], 0 );
+ m_Op->SetVI(n,pos[0],pos[1],pos[2], 0 );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // set voltage excitations
+ setupVoltageExcitation( volt_vIndex, volt_vExcit, volt_vDelay, volt_vDir );
+
+ // set current excitations
+ setupCurrentExcitation( curr_vIndex, curr_vExcit, curr_vDelay, curr_vDir );
+
+ return true;
+}
+
+void Operator_Ext_Excitation::setupVoltageExcitation( vector<unsigned int> const volt_vIndex[3], vector<FDTD_FLOAT> const& volt_vExcit,
+ vector<unsigned int> const& volt_vDelay, vector<unsigned int> const& volt_vDir )
+{
+ Volt_Count = volt_vIndex[0].size();
+ for (int n=0; n<3; n++)
+ {
+ Volt_Count_Dir[n]=0;
+ delete[] Volt_index[n];
+ Volt_index[n] = new unsigned int[Volt_Count];
+ }
+ delete[] Volt_delay;
+ delete[] Volt_amp;
+ delete[] Volt_dir;
+ Volt_delay = new unsigned int[Volt_Count];
+ Volt_amp = new FDTD_FLOAT[Volt_Count];
+ Volt_dir = new unsigned short[Volt_Count];
+
+// cerr << "Excitation::setupVoltageExcitation(): Number of voltage excitation points: " << Volt_Count << endl;
+// if (Volt_Count==0)
+// cerr << "No E-Field/voltage excitation found!" << endl;
+ for (int n=0; n<3; n++)
+ for (unsigned int i=0; i<Volt_Count; i++)
+ Volt_index[n][i] = volt_vIndex[n].at(i);
+ for (unsigned int i=0; i<Volt_Count; i++)
+ {
+ Volt_delay[i] = volt_vDelay.at(i);
+ Volt_amp[i] = volt_vExcit.at(i);
+ Volt_dir[i] = volt_vDir.at(i);
+ ++Volt_Count_Dir[Volt_dir[i]];
+ }
+}
+
+void Operator_Ext_Excitation::setupCurrentExcitation( vector<unsigned int> const curr_vIndex[3], vector<FDTD_FLOAT> const& curr_vExcit,
+ vector<unsigned int> const& curr_vDelay, vector<unsigned int> const& curr_vDir )
+{
+ Curr_Count = curr_vIndex[0].size();
+ for (int n=0; n<3; n++)
+ {
+ Curr_Count_Dir[n]=0;
+ delete[] Curr_index[n];
+ Curr_index[n] = new unsigned int[Curr_Count];
+ }
+ delete[] Curr_delay;
+ delete[] Curr_amp;
+ delete[] Curr_dir;
+ Curr_delay = new unsigned int[Curr_Count];
+ Curr_amp = new FDTD_FLOAT[Curr_Count];
+ Curr_dir = new unsigned short[Curr_Count];
+
+// cerr << "Excitation::setupCurrentExcitation(): Number of current excitation points: " << Curr_Count << endl;
+// if (Curr_Count==0)
+// cerr << "No H-Field/current excitation found!" << endl;
+ for (int n=0; n<3; ++n)
+ for (unsigned int i=0; i<Curr_Count; i++)
+ Curr_index[n][i] = curr_vIndex[n].at(i);
+ for (unsigned int i=0; i<Curr_Count; i++)
+ {
+ Curr_delay[i] = curr_vDelay.at(i);
+ Curr_amp[i] = curr_vExcit.at(i);
+ Curr_dir[i] = curr_vDir.at(i);
+ ++Curr_Count_Dir[Curr_dir[i]];
+ }
+
+}
+
+Engine_Extension* Operator_Ext_Excitation::CreateEngineExtention()
+{
+ return new Engine_Ext_Excitation(this);
+}
+
+void Operator_Ext_Excitation::ShowStat(ostream &ostr) const
+{
+ Operator_Extension::ShowStat(ostr);
+ cout << "Voltage excitations\t: " << Volt_Count << "\t (" << Volt_Count_Dir[0] << ", " << Volt_Count_Dir[1] << ", " << Volt_Count_Dir[2] << ")" << endl;
+ cout << "Current excitations\t: " << Curr_Count << "\t (" << Curr_Count_Dir[0] << ", " << Curr_Count_Dir[1] << ", " << Curr_Count_Dir[2] << ")" << endl;
+ cout << "Excitation Length (TS)\t: " << m_Exc->GetLength() << endl;
+ cout << "Excitation Length (s)\t: " << m_Exc->GetLength()*m_Op->GetTimestep() << endl;
+}
+
diff --git a/openEMS/FDTD/extensions/operator_ext_excitation.h b/openEMS/FDTD/extensions/operator_ext_excitation.h
new file mode 100644
index 0000000..2abcef0
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_excitation.h
@@ -0,0 +1,84 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXT_EXCITATION_H
+#define OPERATOR_EXT_EXCITATION_H
+
+#include "operator_extension.h"
+#include "FDTD/operator.h"
+
+class Excitation;
+
+class Operator_Ext_Excitation : public Operator_Extension
+{
+ friend class Engine_Ext_Excitation;
+ friend class Engine_Ext_Mur_ABC;
+ friend class Operator;
+public:
+ Operator_Ext_Excitation(Operator* op);
+ ~Operator_Ext_Excitation();
+
+ virtual Operator_Extension* Clone(Operator* op);
+
+ virtual bool BuildExtension();
+
+ virtual Engine_Extension* CreateEngineExtention();
+
+ virtual bool IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const {UNUSED(closedAlpha); UNUSED(R0_included); return true;}
+ virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child); return true;}
+ virtual bool IsMPISave() const {return true;}
+
+ virtual string GetExtensionName() const {return string("Excitation Extension");}
+
+ virtual void ShowStat(ostream &ostr) const;
+
+ virtual void Init();
+ virtual void Reset();
+
+ unsigned int GetVoltCount() const {return Volt_Count;}
+ unsigned int GetVoltCount(int ny) const {return Volt_Count_Dir[ny];}
+
+ unsigned int GetCurrCount() const {return Curr_Count;}
+ unsigned int GetCurrCount(int ny) const {return Curr_Count_Dir[ny];}
+
+protected:
+ Operator_Ext_Excitation(Operator* op, Operator_Ext_Excitation* op_ext);
+
+ Excitation* m_Exc;
+
+ void setupVoltageExcitation( vector<unsigned int> const volt_vIndex[3], vector<FDTD_FLOAT> const& volt_vExcit,
+ vector<unsigned int> const& volt_vDelay, vector<unsigned int> const& volt_vDir );
+ void setupCurrentExcitation( vector<unsigned int> const curr_vIndex[3], vector<FDTD_FLOAT> const& curr_vExcit,
+ vector<unsigned int> const& curr_vDelay, vector<unsigned int> const& curr_vDir );
+ //E-Field/voltage Excitation
+ unsigned int Volt_Count;
+ unsigned int Volt_Count_Dir[3];
+ unsigned int* Volt_index[3];
+ unsigned short* Volt_dir;
+ FDTD_FLOAT* Volt_amp; //represented as edge-voltages!!
+ unsigned int* Volt_delay;
+
+ //H-Field/current Excitation
+ unsigned int Curr_Count;
+ unsigned int Curr_Count_Dir[3];
+ unsigned int* Curr_index[3];
+ unsigned short* Curr_dir;
+ FDTD_FLOAT* Curr_amp; //represented as edge-currents!!
+ unsigned int* Curr_delay;
+};
+
+#endif // OPERATOR_EXT_EXCITATION_H
diff --git a/openEMS/FDTD/extensions/operator_ext_lorentzmaterial.cpp b/openEMS/FDTD/extensions/operator_ext_lorentzmaterial.cpp
new file mode 100644
index 0000000..9f386fc
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_lorentzmaterial.cpp
@@ -0,0 +1,453 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "operator_ext_lorentzmaterial.h"
+#include "engine_ext_lorentzmaterial.h"
+#include "operator_ext_cylinder.h"
+#include "../operator_cylinder.h"
+
+#include "CSPropLorentzMaterial.h"
+#include "CSPropDebyeMaterial.h"
+
+Operator_Ext_LorentzMaterial::Operator_Ext_LorentzMaterial(Operator* op) : Operator_Ext_Dispersive(op)
+{
+ v_int_ADE = NULL;
+ v_ext_ADE = NULL;
+ i_int_ADE = NULL;
+ i_ext_ADE = NULL;
+
+ v_Lor_ADE = NULL;
+ i_Lor_ADE = NULL;
+
+ m_curr_Lor_ADE_On = NULL;
+ m_curr_Lor_ADE_On = NULL;
+}
+
+Operator_Ext_LorentzMaterial::Operator_Ext_LorentzMaterial(Operator* op, Operator_Ext_LorentzMaterial* op_ext) : Operator_Ext_Dispersive(op,op_ext)
+{
+ v_int_ADE = NULL;
+ v_ext_ADE = NULL;
+ i_int_ADE = NULL;
+ i_ext_ADE = NULL;
+
+ v_Lor_ADE = NULL;
+ i_Lor_ADE = NULL;
+
+ m_curr_Lor_ADE_On = NULL;
+ m_curr_Lor_ADE_On = NULL;
+}
+
+Operator_Ext_LorentzMaterial::~Operator_Ext_LorentzMaterial()
+{
+ for (int i=0;i<m_Order;++i)
+ {
+ for (int n=0; n<3; ++n)
+ {
+ if (m_volt_ADE_On[i])
+ {
+ delete[] v_int_ADE[i][n];
+ delete[] v_ext_ADE[i][n];
+ }
+ if (m_curr_ADE_On[i])
+ {
+ delete[] i_int_ADE[i][n];
+ delete[] i_ext_ADE[i][n];
+ }
+ if (m_volt_Lor_ADE_On[i])
+ delete[] v_Lor_ADE[i][n];
+ if (m_curr_Lor_ADE_On[i])
+ delete[] i_Lor_ADE[i][n];
+ }
+ if (m_volt_ADE_On[i])
+ {
+ delete[] v_int_ADE[i];
+ delete[] v_ext_ADE[i];
+ }
+ if (m_curr_ADE_On[i])
+ {
+ delete[] i_int_ADE[i];
+ delete[] i_ext_ADE[i];
+ }
+ if (m_volt_Lor_ADE_On[i])
+ delete[] v_Lor_ADE[i];
+ if (m_curr_Lor_ADE_On[i])
+ delete[] i_Lor_ADE[i];
+ }
+ delete[] v_int_ADE;
+ delete[] v_ext_ADE;
+ delete[] i_int_ADE;
+ delete[] i_ext_ADE;
+ v_int_ADE = NULL;
+ v_ext_ADE = NULL;
+ i_int_ADE = NULL;
+ i_ext_ADE = NULL;
+
+ delete[] v_Lor_ADE;
+ delete[] i_Lor_ADE;
+ v_Lor_ADE = NULL;
+ i_Lor_ADE = NULL;
+
+ delete[] m_curr_Lor_ADE_On;
+ delete[] m_volt_Lor_ADE_On;
+ m_curr_Lor_ADE_On = NULL;
+ m_curr_Lor_ADE_On = NULL;
+}
+
+Operator_Extension* Operator_Ext_LorentzMaterial::Clone(Operator* op)
+{
+ if (dynamic_cast<Operator_Ext_LorentzMaterial*>(this)==NULL)
+ return NULL;
+ return new Operator_Ext_LorentzMaterial(op, this);
+}
+
+bool Operator_Ext_LorentzMaterial::BuildExtension()
+{
+ double dT = m_Op->GetTimestep();
+ unsigned int pos[] = {0,0,0};
+ double coord[3];
+ unsigned int numLines[3] = {m_Op->GetNumberOfLines(0,true),m_Op->GetNumberOfLines(1,true),m_Op->GetNumberOfLines(2,true)};
+ CSPropLorentzMaterial* mat = NULL;
+ CSPropDebyeMaterial* debye_mat = NULL;
+
+ bool warn_once = true;
+
+ bool b_pos_on;
+ vector<unsigned int> v_pos[3];
+
+ // drude material parameter
+ double w_plasma,t_relax;
+ double L_D[3], C_D[3];
+ double R_D[3], G_D[3];
+ vector<double> v_int[3];
+ vector<double> v_ext[3];
+ vector<double> i_int[3];
+ vector<double> i_ext[3];
+
+ //additional Dorentz material parameter
+ double w_Lor_Pol;
+ double C_L[3];
+ double L_L[3];
+ vector<double> v_Lor[3];
+ vector<double> i_Lor[3];
+
+ m_Order = 0;
+ vector<CSProperties*> LD_props = m_Op->CSX->GetPropertyByType(CSProperties::LORENTZMATERIAL);
+ for (size_t n=0;n<LD_props.size();++n)
+ {
+ CSPropLorentzMaterial* LorMat = dynamic_cast<CSPropLorentzMaterial*>(LD_props.at(n));
+ if (LorMat==NULL)
+ return false; //sanity check, this should not happen
+ if (LorMat->GetDispersionOrder()>m_Order)
+ m_Order=LorMat->GetDispersionOrder();
+ }
+ LD_props = m_Op->CSX->GetPropertyByType(CSProperties::DEBYEMATERIAL);
+ for (size_t n=0;n<LD_props.size();++n)
+ {
+ CSPropDebyeMaterial* DebyeMat = dynamic_cast<CSPropDebyeMaterial*>(LD_props.at(n));
+ if (DebyeMat==NULL)
+ return false; //sanity check, this should not happen
+ if (DebyeMat->GetDispersionOrder()>m_Order)
+ m_Order=DebyeMat->GetDispersionOrder();
+ }
+
+ m_LM_pos = new unsigned int**[m_Order];
+
+ m_volt_ADE_On = new bool[m_Order];
+ m_curr_ADE_On = new bool[m_Order];
+ m_volt_Lor_ADE_On = new bool[m_Order];
+ m_curr_Lor_ADE_On = new bool[m_Order];
+
+ v_int_ADE = new FDTD_FLOAT**[m_Order];
+ v_ext_ADE = new FDTD_FLOAT**[m_Order];
+ i_int_ADE = new FDTD_FLOAT**[m_Order];
+ i_ext_ADE = new FDTD_FLOAT**[m_Order];
+
+ v_Lor_ADE = new FDTD_FLOAT**[m_Order];
+ i_Lor_ADE = new FDTD_FLOAT**[m_Order];
+
+ for (int order=0;order<m_Order;++order)
+ {
+ m_volt_ADE_On[order]=false;
+ m_curr_ADE_On[order]=false;
+
+ m_volt_Lor_ADE_On[order]=false;
+ m_curr_Lor_ADE_On[order]=false;
+
+ for (int n=0;n<3;++n)
+ {
+ v_pos[n].clear();
+
+ v_int[n].clear();
+ v_ext[n].clear();
+ i_int[n].clear();
+ i_ext[n].clear();
+
+ v_Lor[n].clear();
+ i_Lor[n].clear();
+ }
+
+ for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
+ {
+ for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
+ {
+ vector<CSPrimitives*> vPrims = m_Op->GetPrimitivesBoundBox(pos[0], pos[1], -1, (CSProperties::PropertyType)(CSProperties::MATERIAL | CSProperties::METAL));
+ for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
+ {
+ unsigned int index = m_Op->MainOp->SetPos(pos[0],pos[1],pos[2]);
+ //calc epsilon lorentz material
+ b_pos_on = false;
+ for (int n=0; n<3; ++n)
+ {
+ L_D[n]=0;
+ R_D[n]=0;
+ C_L[n]=0;
+ if (m_Op->GetYeeCoords(n,pos,coord,false)==false)
+ continue;
+ if (m_CC_R0_included && (n==2) && (pos[0]==0))
+ coord[1] = m_Op->GetDiscLine(1,0);
+
+ if (m_Op->GetVI(n,pos[0],pos[1],pos[2])==0)
+ continue;
+
+// CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord,(CSProperties::PropertyType)(CSProperties::METAL | CSProperties::MATERIAL), true);
+ CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord, vPrims, true);
+ if ((mat = prop->ToLorentzMaterial()))
+ {
+ w_plasma = mat->GetEpsPlasmaFreqWeighted(order,n,coord) * 2 * PI;
+ if ((w_plasma>0) && (m_Op->EC_C[n][index]>0))
+ {
+ b_pos_on = true;
+ m_volt_ADE_On[order] = true;
+ L_D[n] = 1/(w_plasma*w_plasma*m_Op->EC_C[n][index]);
+ }
+ t_relax = mat->GetEpsRelaxTimeWeighted(order,n,coord);
+ if ((t_relax>0) && m_volt_ADE_On[order])
+ {
+ R_D[n] = L_D[n]/t_relax;
+ }
+ w_Lor_Pol = mat->GetEpsLorPoleFreqWeighted(order,n,coord) * 2 * PI;
+ if ((w_Lor_Pol>0) && (L_D[n]>0))
+ {
+ m_volt_Lor_ADE_On[order] = true;
+ C_L[n] = 1/(w_Lor_Pol*w_Lor_Pol*L_D[n]);
+ }
+ }
+ if ((debye_mat = prop->ToDebyeMaterial()))
+ {
+ C_L[n] = 8.85418781762e-12*debye_mat->GetEpsDeltaWeighted(order,n,coord) * m_Op->GetEdgeArea(n, pos) / m_Op->GetEdgeLength(n,pos);
+ t_relax = debye_mat->GetEpsRelaxTimeWeighted(order,n,coord);
+ if ((t_relax<2.0*dT) && warn_once)
+ {
+ warn_once = false;
+ cerr << "Operator_Ext_LorentzMaterial::BuildExtension(): Warning, debye relaxation time is to small, skipping..." << endl;
+ }
+ if ((C_L[n]>0) && (t_relax>0) && (t_relax>2.0*dT))
+ {
+ R_D[n] = t_relax/C_L[n];
+ b_pos_on = true;
+ m_volt_ADE_On[order] = true;
+ m_volt_Lor_ADE_On[order] = true;
+ }
+ }
+ }
+
+ for (int n=0; n<3; ++n)
+ {
+ C_D[n]=0;
+ G_D[n]=0;
+ L_L[n]=0;
+ if (m_Op->GetYeeCoords(n,pos,coord,true)==false)
+ continue;
+ if (m_Op->GetIV(n,pos[0],pos[1],pos[2])==0)
+ continue;
+
+// CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord,(CSProperties::PropertyType)(CSProperties::METAL | CSProperties::MATERIAL), true);
+ CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord, vPrims, true);
+ if ((mat = prop->ToLorentzMaterial()))
+ {
+ w_plasma = mat->GetMuePlasmaFreqWeighted(order,n,coord) * 2 * PI;
+ if ((w_plasma>0) && (m_Op->EC_L[n][index]>0))
+ {
+ b_pos_on = true;
+ m_curr_ADE_On[order] = true;
+ C_D[n] = 1/(w_plasma*w_plasma*m_Op->EC_L[n][index]);
+ }
+ t_relax = mat->GetMueRelaxTimeWeighted(order,n,coord);
+ if ((t_relax>0) && m_curr_ADE_On[order])
+ {
+ G_D[n] = C_D[n]/t_relax;
+ }
+ w_Lor_Pol = mat->GetMueLorPoleFreqWeighted(order,n,coord) * 2 * PI;
+ if ((w_Lor_Pol>0) && (C_D[n]>0))
+ {
+ m_curr_Lor_ADE_On[order] = true;
+ L_L[n] = 1/(w_Lor_Pol*w_Lor_Pol*C_D[n]);
+ }
+ }
+ }
+
+ if (b_pos_on) //this position has active drude material
+ {
+ for (unsigned int n=0; n<3; ++n)
+ {
+ v_pos[n].push_back(pos[n]);
+ if (L_D[n]>0)
+ {
+ v_int[n].push_back((2.0*L_D[n]-dT*R_D[n])/(2.0*L_D[n]+dT*R_D[n]));
+ // check for r==0 in clyindrical coords and get special VI cooefficient
+ if (m_CC_R0_included && n==2 && pos[0]==0)
+ v_ext[n].push_back(dT/(L_D[n]+dT*R_D[n]/2.0)*m_Op_Cyl->m_Cyl_Ext->vi_R0[pos[2]]);
+ else
+ v_ext[n].push_back(dT/(L_D[n]+dT*R_D[n]/2.0)*m_Op->GetVI(n,pos[0],pos[1],pos[2]));
+ }
+ else if ((R_D[n]>0) && (C_L[n]>0))
+ {
+ v_int[n].push_back((2.0*dT-R_D[n]*C_L[n])/(C_L[n]*R_D[n]));
+ v_ext[n].push_back(2.0/R_D[n]*m_Op->GetVI(n,pos[0],pos[1],pos[2]));
+ }
+ else
+ {
+ v_int[n].push_back(1);
+ v_ext[n].push_back(0);
+ }
+ if (C_D[n]>0)
+ {
+ i_int[n].push_back((2.0*C_D[n]-dT*G_D[n])/(2.0*C_D[n]+dT*G_D[n]));
+ i_ext[n].push_back(dT/(C_D[n]+dT*G_D[n]/2.0)*m_Op->GetIV(n,pos[0],pos[1],pos[2]));
+ }
+ else
+ {
+ i_int[n].push_back(1);
+ i_ext[n].push_back(0);
+ }
+ if (C_L[n]>0)
+ v_Lor[n].push_back(dT/C_L[n]/m_Op->GetVI(n,pos[0],pos[1],pos[2]));
+ else
+ v_Lor[n].push_back(0);
+ if (L_L[n]>0)
+ i_Lor[n].push_back(dT/L_L[n]/m_Op->GetIV(n,pos[0],pos[1],pos[2]));
+ else
+ i_Lor[n].push_back(0);
+ }
+ }
+ }
+ }
+ }
+
+ //copy all vectors into the array's
+ m_LM_Count.push_back(v_pos[0].size());
+
+ m_LM_pos[order] = new unsigned int*[3];
+
+ if (m_volt_ADE_On[order])
+ {
+ v_int_ADE[order] = new FDTD_FLOAT*[3];
+ v_ext_ADE[order] = new FDTD_FLOAT*[3];
+ }
+ else
+ {
+ v_int_ADE[order] = NULL;
+ v_ext_ADE[order] = NULL;
+ }
+
+ if (m_curr_ADE_On[order])
+ {
+ i_int_ADE[order] = new FDTD_FLOAT*[3];
+ i_ext_ADE[order] = new FDTD_FLOAT*[3];
+ }
+ else
+ {
+ i_int_ADE[order] = NULL;
+ i_ext_ADE[order] = NULL;
+ }
+
+ if (m_volt_Lor_ADE_On[order])
+ v_Lor_ADE[order] = new FDTD_FLOAT*[3];
+ else
+ v_Lor_ADE[order] = NULL;
+
+ if (m_curr_Lor_ADE_On[order])
+ i_Lor_ADE[order] = new FDTD_FLOAT*[3];
+ else
+ i_Lor_ADE[order] = NULL;
+
+ for (int n=0; n<3; ++n)
+ {
+ m_LM_pos[order][n] = new unsigned int[m_LM_Count.at(order)];
+ for (unsigned int i=0; i<m_LM_Count.at(order); ++i)
+ m_LM_pos[order][n][i] = v_pos[n].at(i);
+ if (m_volt_ADE_On[order])
+ {
+ v_int_ADE[order][n] = new FDTD_FLOAT[m_LM_Count.at(order)];
+ v_ext_ADE[order][n] = new FDTD_FLOAT[m_LM_Count.at(order)];
+
+ for (unsigned int i=0; i<m_LM_Count.at(order); ++i)
+ {
+ v_int_ADE[order][n][i] = v_int[n].at(i);
+ v_ext_ADE[order][n][i] = v_ext[n].at(i);
+ }
+ }
+ if (m_curr_ADE_On[order])
+ {
+ i_int_ADE[order][n] = new FDTD_FLOAT[m_LM_Count.at(order)];
+ i_ext_ADE[order][n] = new FDTD_FLOAT[m_LM_Count.at(order)];
+
+ for (unsigned int i=0; i<m_LM_Count.at(order); ++i)
+ {
+ i_int_ADE[order][n][i] = i_int[n].at(i);
+ i_ext_ADE[order][n][i] = i_ext[n].at(i);
+ }
+ }
+
+ if (m_volt_Lor_ADE_On[order])
+ {
+ v_Lor_ADE[order][n] = new FDTD_FLOAT[m_LM_Count.at(order)];
+ for (unsigned int i=0; i<m_LM_Count.at(order); ++i)
+ v_Lor_ADE[order][n][i] = v_Lor[n].at(i);
+ }
+ if (m_curr_Lor_ADE_On[order])
+ {
+ i_Lor_ADE[order][n] = new FDTD_FLOAT[m_LM_Count.at(order)];
+ for (unsigned int i=0; i<m_LM_Count.at(order); ++i)
+ i_Lor_ADE[order][n][i] = i_Lor[n].at(i);
+ }
+ }
+ }
+
+ return true;
+}
+
+Engine_Extension* Operator_Ext_LorentzMaterial::CreateEngineExtention()
+{
+ Engine_Ext_LorentzMaterial* eng_ext_lor = new Engine_Ext_LorentzMaterial(this);
+ return eng_ext_lor;
+}
+
+void Operator_Ext_LorentzMaterial::ShowStat(ostream &ostr) const
+{
+ Operator_Extension::ShowStat(ostr);
+ string On_Off[2] = {"Off", "On"};
+ ostr << " Max. Dispersion Order N = " << m_Order << endl;
+ for (int i=0;i<m_Order;++i)
+ {
+ ostr << " N=" << i << ":\t Active cells\t\t: " << m_LM_Count.at(i) << endl;
+ ostr << " N=" << i << ":\t Voltage ADE is \t: " << On_Off[m_volt_ADE_On[i]] << endl;
+ ostr << " N=" << i << ":\t Voltage Lor-ADE is \t: " << On_Off[m_volt_Lor_ADE_On[i]] << endl;
+ ostr << " N=" << i << ":\t Current ADE is \t: " << On_Off[m_curr_ADE_On[i]] << endl;
+ ostr << " N=" << i << ":\t Current Lor-ADE is \t: " << On_Off[m_curr_Lor_ADE_On[i]] << endl;
+ }
+}
diff --git a/openEMS/FDTD/extensions/operator_ext_lorentzmaterial.h b/openEMS/FDTD/extensions/operator_ext_lorentzmaterial.h
new file mode 100644
index 0000000..d9e600b
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_lorentzmaterial.h
@@ -0,0 +1,62 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXT_LORENTZMATERIAL_H
+#define OPERATOR_EXT_LORENTZMATERIAL_H
+
+#include "FDTD/operator.h"
+#include "operator_ext_dispersive.h"
+
+class Operator_Ext_LorentzMaterial : public Operator_Ext_Dispersive
+{
+ friend class Engine_Ext_LorentzMaterial;
+public:
+ Operator_Ext_LorentzMaterial(Operator* op);
+ virtual ~Operator_Ext_LorentzMaterial();
+
+ virtual Operator_Extension* Clone(Operator* op);
+
+ virtual bool BuildExtension();
+
+ virtual Engine_Extension* CreateEngineExtention();
+
+ virtual bool IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const {UNUSED(closedAlpha); UNUSED(R0_included); return true;}
+ virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child); return true;}
+ virtual bool IsMPISave() const {return true;}
+
+ virtual string GetExtensionName() const {return string("Drude/Lorentz Dispersive Material Extension");}
+
+ virtual void ShowStat(ostream &ostr) const;
+
+protected:
+ //! Copy constructor
+ Operator_Ext_LorentzMaterial(Operator* op, Operator_Ext_LorentzMaterial* op_ext);
+
+ //ADE update coefficients, array setup: coeff[N_order][direction][mesh_pos_index]
+ FDTD_FLOAT ***v_int_ADE;
+ FDTD_FLOAT ***v_ext_ADE;
+ FDTD_FLOAT ***i_int_ADE;
+ FDTD_FLOAT ***i_ext_ADE;
+
+ bool *m_curr_Lor_ADE_On;
+ bool *m_volt_Lor_ADE_On;
+
+ FDTD_FLOAT ***v_Lor_ADE;
+ FDTD_FLOAT ***i_Lor_ADE;
+};
+
+#endif // OPERATOR_EXT_LORENTZMATERIAL_H
diff --git a/openEMS/FDTD/extensions/operator_ext_mur_abc.cpp b/openEMS/FDTD/extensions/operator_ext_mur_abc.cpp
new file mode 100644
index 0000000..1df8583
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_mur_abc.cpp
@@ -0,0 +1,210 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "operator_ext_mur_abc.h"
+#include "engine_ext_mur_abc.h"
+
+#include "tools/array_ops.h"
+
+#include "CSPropMaterial.h"
+
+Operator_Ext_Mur_ABC::Operator_Ext_Mur_ABC(Operator* op) : Operator_Extension(op)
+{
+ Initialize();
+}
+
+Operator_Ext_Mur_ABC::~Operator_Ext_Mur_ABC()
+{
+ Delete2DArray(m_Mur_Coeff_nyP,m_numLines);
+ m_Mur_Coeff_nyP = NULL;
+ Delete2DArray(m_Mur_Coeff_nyPP,m_numLines);
+ m_Mur_Coeff_nyPP = NULL;
+}
+
+Operator_Ext_Mur_ABC::Operator_Ext_Mur_ABC(Operator* op, Operator_Ext_Mur_ABC* op_ext) : Operator_Extension(op, op_ext)
+{
+ Initialize();
+ m_v_phase = op_ext->m_v_phase;
+ SetDirection(op_ext->m_ny,op_ext->m_top);
+}
+
+Operator_Extension* Operator_Ext_Mur_ABC::Clone(Operator* op)
+{
+ if (dynamic_cast<Operator_Ext_Mur_ABC*>(this)==NULL)
+ return NULL;
+ return new Operator_Ext_Mur_ABC(op, this);
+}
+
+bool Operator_Ext_Mur_ABC::IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const
+{
+ if ((m_ny==0) && (!m_top) && (R0_included || closedAlpha))
+ return false;
+ if ((m_ny==1) && (closedAlpha))
+ return false;
+ return true;
+}
+
+bool Operator_Ext_Mur_ABC::IsCylindricalMultiGridSave(bool child) const
+{
+ if (m_ny==2) //always allow in z-direction
+ return true;
+ if ((m_ny==0) && (m_top) && (!child)) //if top r-direction and is not a child grid allow Mur...
+ return true;
+ //in all other cases this ABC is not save to use in CylindricalMultiGrid
+ return false;
+}
+
+void Operator_Ext_Mur_ABC::Initialize()
+{
+ m_ny = -1;
+ m_nyP = -1;
+ m_nyPP = -1;
+ m_LineNr = 0;
+ m_LineNr_Shift = 0;
+
+ m_v_phase = 0.0;
+
+ m_Mur_Coeff_nyP = NULL;
+ m_Mur_Coeff_nyPP = NULL;
+
+ m_numLines[0]=0;
+ m_numLines[1]=0;
+}
+
+void Operator_Ext_Mur_ABC::SetDirection(int ny, bool top_ny)
+{
+ if ((ny<0) || (ny>2))
+ return;
+
+ Delete2DArray(m_Mur_Coeff_nyP,m_numLines);
+ Delete2DArray(m_Mur_Coeff_nyPP,m_numLines);
+
+ m_ny = ny;
+ m_top = top_ny;
+ m_nyP = (ny+1)%3;
+ m_nyPP = (ny+2)%3;
+ if (!top_ny)
+ {
+ m_LineNr = 0;
+ m_LineNr_Shift = 1;
+ }
+ else
+ {
+ m_LineNr = m_Op->GetNumberOfLines(m_ny,true)-1;
+ m_LineNr_Shift = m_Op->GetNumberOfLines(m_ny,true) - 2;
+ }
+
+ m_numLines[0] = m_Op->GetNumberOfLines(m_nyP,true);
+ m_numLines[1] = m_Op->GetNumberOfLines(m_nyPP,true);
+
+ m_Mur_Coeff_nyP = Create2DArray<FDTD_FLOAT>(m_numLines);
+ m_Mur_Coeff_nyPP = Create2DArray<FDTD_FLOAT>(m_numLines);
+
+}
+
+bool Operator_Ext_Mur_ABC::BuildExtension()
+{
+ if (m_ny<0)
+ {
+ cerr << "Operator_Ext_Mur_ABC::BuildExtension: Warning, Extension not initialized! Use SetDirection!! Abort build!!" << endl;
+ return false;
+ }
+ double dT = m_Op->GetTimestep();
+ unsigned int pos[] = {0,0,0};
+ pos[m_ny] = m_LineNr;
+ double delta = fabs(m_Op->GetEdgeLength(m_ny,pos));
+ double coord[] = {0,0,0};
+ coord[0] = m_Op->GetDiscLine(0,pos[0]);
+ coord[1] = m_Op->GetDiscLine(1,pos[1]);
+ coord[2] = m_Op->GetDiscLine(2,pos[2]);
+
+ double eps,mue;
+ double c0t;
+
+ if (m_LineNr==0)
+ coord[m_ny] = m_Op->GetDiscLine(m_ny,pos[m_ny]) + delta/2 / m_Op->GetGridDelta();
+ else
+ coord[m_ny] = m_Op->GetDiscLine(m_ny,pos[m_ny]) - delta/2 / m_Op->GetGridDelta();
+
+ int posBB[3];
+ posBB[m_ny] =pos[m_ny];
+ posBB[m_nyPP]=-1;
+
+ for (pos[m_nyP]=0; pos[m_nyP]<m_numLines[0]; ++pos[m_nyP])
+ {
+ posBB[m_nyP]=pos[m_nyP];
+ vector<CSPrimitives*> vPrims = m_Op->GetPrimitivesBoundBox(posBB[0], posBB[1], posBB[2], CSProperties::MATERIAL);
+ coord[m_nyP] = m_Op->GetDiscLine(m_nyP,pos[m_nyP]);
+ for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
+ {
+ coord[m_nyPP] = m_Op->GetDiscLine(m_nyPP,pos[m_nyPP]);
+// CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord, CSProperties::MATERIAL, false);
+ CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord, vPrims, false);
+ if (prop)
+ {
+ CSPropMaterial* mat = prop->ToMaterial();
+
+ //nP
+ eps = mat->GetEpsilonWeighted(m_nyP,coord);
+ mue = mat->GetMueWeighted(m_nyP,coord);
+ if (m_v_phase>0.0)
+ c0t = m_v_phase * dT;
+ else
+ c0t = __C0__ * dT / sqrt(eps*mue);
+ m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] = (c0t - delta) / (c0t + delta);
+
+ //nPP
+ eps = mat->GetEpsilonWeighted(m_nyPP,coord);
+ mue = mat->GetMueWeighted(m_nyPP,coord);
+ if (m_v_phase>0.0)
+ c0t = m_v_phase * dT;
+ else
+ c0t = __C0__ * dT / sqrt(eps*mue);
+ m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] = (c0t - delta) / (c0t + delta);
+
+ }
+ else
+ {
+ if (m_v_phase>0.0)
+ c0t = m_v_phase * dT;
+ else
+ c0t = __C0__ / sqrt(m_Op->GetBackgroundEpsR()*m_Op->GetBackgroundMueR()) * dT;
+ m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] = (c0t - delta) / (c0t + delta);
+ m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] = m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]];
+ }
+// cerr << m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] << " : " << m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] << endl;
+ }
+ }
+// cerr << "Operator_Ext_Mur_ABC::BuildExtension(): " << m_ny << " @ " << m_LineNr << endl;
+ return true;
+}
+
+Engine_Extension* Operator_Ext_Mur_ABC::CreateEngineExtention()
+{
+ Engine_Ext_Mur_ABC* eng_ext = new Engine_Ext_Mur_ABC(this);
+ return eng_ext;
+}
+
+
+void Operator_Ext_Mur_ABC::ShowStat(ostream &ostr) const
+{
+ Operator_Extension::ShowStat(ostr);
+ string XYZ[3] = {"x","y","z"};
+ ostr << " Active direction\t: " << XYZ[m_ny] << " at line: " << m_LineNr << endl;
+ if (m_v_phase>0.0)
+ ostr << " Used phase velocity\t: " << m_v_phase << " (" << m_v_phase/__C0__ << " * c_0)" <<endl;
+}
diff --git a/openEMS/FDTD/extensions/operator_ext_mur_abc.h b/openEMS/FDTD/extensions/operator_ext_mur_abc.h
new file mode 100644
index 0000000..ddc43c1
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_mur_abc.h
@@ -0,0 +1,68 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXT_MUR_ABC_H
+#define OPERATOR_EXT_MUR_ABC_H
+
+#include "FDTD/operator.h"
+#include "operator_extension.h"
+
+class Operator_Ext_Mur_ABC : public Operator_Extension
+{
+ friend class Engine_Ext_Mur_ABC;
+public:
+ Operator_Ext_Mur_ABC(Operator* op);
+ ~Operator_Ext_Mur_ABC();
+
+ virtual Operator_Extension* Clone(Operator* op);
+
+ //! Define the direction of this ABC: \a ny=0,1,2 -> x,y,z and if at bottom_ny -> e.g. x=0 or x=end
+ void SetDirection(int ny, bool top_ny);
+
+ //! Set (override) the expected phase velocity of the incoming wave
+ void SetPhaseVelocity(double c_phase) {m_v_phase=c_phase;};
+
+ virtual bool BuildExtension();
+
+ virtual Engine_Extension* CreateEngineExtention();
+
+ virtual bool IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const;
+ virtual bool IsCylindricalMultiGridSave(bool child) const;
+ virtual bool IsMPISave() const {return true;}
+
+ virtual string GetExtensionName() const {return string("Mur ABC Extension");}
+
+ virtual void ShowStat(ostream &ostr) const;
+
+protected:
+ Operator_Ext_Mur_ABC(Operator* op, Operator_Ext_Mur_ABC* op_ext);
+ void Initialize();
+ int m_ny;
+ int m_nyP,m_nyPP;
+ bool m_top;
+ unsigned int m_LineNr;
+ int m_LineNr_Shift;
+
+ double m_v_phase;
+
+ unsigned int m_numLines[2];
+
+ FDTD_FLOAT** m_Mur_Coeff_nyP;
+ FDTD_FLOAT** m_Mur_Coeff_nyPP;
+};
+
+#endif // OPERATOR_EXT_MUR_ABC_H
diff --git a/openEMS/FDTD/extensions/operator_ext_steadystate.cpp b/openEMS/FDTD/extensions/operator_ext_steadystate.cpp
new file mode 100644
index 0000000..b8395a8
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_steadystate.cpp
@@ -0,0 +1,104 @@
+/*
+* Copyright (C) 2015 Thorsten Liebig (Thorsten.Liebig@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 "operator_ext_steadystate.h"
+#include "engine_ext_steadystate.h"
+
+Operator_Ext_SteadyState::Operator_Ext_SteadyState(Operator* op, double period): Operator_Extension(op)
+{
+ this->Reset();
+ m_T_period = period;
+}
+
+Operator_Ext_SteadyState::Operator_Ext_SteadyState(Operator* op, Operator_Ext_SteadyState* op_ext): Operator_Extension(op, op_ext)
+{
+ this->Reset();
+ m_T_period = op_ext->m_T_period;
+}
+
+Operator_Ext_SteadyState::~Operator_Ext_SteadyState()
+{
+}
+
+Operator_Extension* Operator_Ext_SteadyState::Clone(Operator* op)
+{
+ //disable cloning, only the main operator needs to have a steady state detection
+ UNUSED(op);
+ return NULL;
+}
+
+bool Operator_Ext_SteadyState::BuildExtension()
+{
+ double dT = m_Op->GetTimestep();
+ m_TS_period = round(m_T_period/dT);
+ m_T_period = m_TS_period*dT;
+ return true;
+}
+
+void Operator_Ext_SteadyState::Reset()
+{
+ for (int n=0;n<3;++n)
+ {
+ m_E_probe_pos[n].clear();
+ m_H_probe_pos[n].clear();
+ }
+ m_E_probe_dir.clear();
+ m_H_probe_dir.clear();
+ m_T_period = 0;
+ m_TS_period = 0;
+}
+
+bool Operator_Ext_SteadyState::Add_E_Probe(unsigned int pos[3], int dir)
+{
+ if ((dir<0) || (dir>2))
+ return false;
+ for (int n=0;n<3;++n)
+ if (pos[n]>=m_Op->GetNumberOfLines(n))
+ return false;
+ for (int n=0;n<3;++n)
+ m_E_probe_pos[n].push_back(pos[n]);
+ m_E_probe_dir.push_back(dir);
+ return true;
+}
+
+bool Operator_Ext_SteadyState::Add_H_Probe(unsigned int pos[3], int dir)
+{
+ if ((dir<0) || (dir>2))
+ return false;
+ for (int n=0;n<3;++n)
+ if (pos[n]>=m_Op->GetNumberOfLines(n))
+ return false;
+ for (int n=0;n<3;++n)
+ m_H_probe_pos[n].push_back(pos[n]);
+ m_H_probe_dir.push_back(dir);
+ return true;
+}
+
+Engine_Extension* Operator_Ext_SteadyState::CreateEngineExtention()
+{
+ m_Eng_Ext = new Engine_Ext_SteadyState(this);
+ return m_Eng_Ext;
+}
+
+void Operator_Ext_SteadyState::ShowStat(ostream &ostr) const
+{
+ Operator_Extension::ShowStat(ostr);
+ cout << "Period time (s): " << m_T_period << "\t Period TS: " << m_TS_period << endl;
+ cout << "Number of E probes\t: " << m_E_probe_dir.size() << endl;
+ cout << "Number of H probes\t: " << m_H_probe_dir.size() << endl;
+}
+
diff --git a/openEMS/FDTD/extensions/operator_ext_steadystate.h b/openEMS/FDTD/extensions/operator_ext_steadystate.h
new file mode 100644
index 0000000..b735ca3
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_steadystate.h
@@ -0,0 +1,61 @@
+/*
+* Copyright (C) 2015 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXT_STEADYSTATE_H
+#define OPERATOR_EXT_STEADYSTATE_H
+
+#include "operator_extension.h"
+#include "FDTD/operator.h"
+
+class Engine_Ext_SteadyState;
+
+class Operator_Ext_SteadyState : public Operator_Extension
+{
+ friend class Engine_Ext_SteadyState;
+public:
+ Operator_Ext_SteadyState(Operator* op, double period);
+ virtual ~Operator_Ext_SteadyState();
+
+ virtual Operator_Extension* Clone(Operator* op);
+
+ virtual bool BuildExtension();
+ virtual Engine_Extension* CreateEngineExtention();
+
+ virtual bool IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const {UNUSED(closedAlpha); UNUSED(R0_included); return true;}
+ virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child); return true;}
+ virtual bool IsMPISave() const {return true;}
+
+ virtual string GetExtensionName() const {return string("Steady-State Detection Extension");}
+
+ virtual void ShowStat(ostream &ostr) const;
+
+ virtual void Reset();
+
+ bool Add_E_Probe(unsigned int pos[3], int dir);
+ bool Add_H_Probe(unsigned int pos[3], int dir);
+
+protected:
+ Operator_Ext_SteadyState(Operator* op, Operator_Ext_SteadyState* op_ext);
+ double m_T_period;
+ unsigned int m_TS_period;
+ vector<unsigned int> m_E_probe_pos[3];
+ vector<unsigned int> m_E_probe_dir;
+ vector<unsigned int> m_H_probe_pos[3];
+ vector<unsigned int> m_H_probe_dir;
+};
+
+#endif // OPERATOR_EXT_STEADYSTATE_H
diff --git a/openEMS/FDTD/extensions/operator_ext_tfsf.cpp b/openEMS/FDTD/extensions/operator_ext_tfsf.cpp
new file mode 100644
index 0000000..663dc1f
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_tfsf.cpp
@@ -0,0 +1,429 @@
+/*
+* Copyright (C) 2012 Thorsten Liebig (Thorsten.Liebig@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 "operator_ext_tfsf.h"
+#include "engine_ext_tfsf.h"
+#include <cmath>
+
+#include "CSPrimBox.h"
+#include "CSPropExcitation.h"
+
+Operator_Ext_TFSF::Operator_Ext_TFSF(Operator* op) : Operator_Extension(op)
+{
+ Init();
+}
+
+Operator_Ext_TFSF::~Operator_Ext_TFSF()
+{
+ Reset();
+}
+
+void Operator_Ext_TFSF::Init()
+{
+ for (int n=0;n<3;++n)
+ for (int l=0;l<2;++l)
+ for (int c=0;c<2;++c)
+ {
+ m_VoltDelay[n][l][c]=NULL;
+ m_VoltDelayDelta[n][l][c]=NULL;
+ m_VoltAmp[n][l][c]=NULL;
+ m_CurrDelay[n][l][c]=NULL;
+ m_CurrDelayDelta[n][l][c]=NULL;
+ m_CurrAmp[n][l][c]=NULL;
+ }
+
+ m_Frequency = 0.0;
+ m_PhVel = __C0__;
+ Operator_Extension::Init();
+}
+
+void Operator_Ext_TFSF::Reset()
+{
+ for (int n=0;n<3;++n)
+ for (int l=0;l<2;++l)
+ for (int c=0;c<2;++c)
+ {
+ delete[] m_VoltDelay[n][l][c];
+ m_VoltDelay[n][l][c]=NULL;
+ delete[] m_VoltDelayDelta[n][l][c];
+ m_VoltDelayDelta[n][l][c]=NULL;
+ delete[] m_VoltAmp[n][l][c];
+ m_VoltAmp[n][l][c]=NULL;
+ delete[] m_CurrDelay[n][l][c];
+ m_CurrDelay[n][l][c]=NULL;
+ delete[] m_CurrDelayDelta[n][l][c];
+ m_CurrDelayDelta[n][l][c]=NULL;
+ delete[] m_CurrAmp[n][l][c];
+ m_CurrAmp[n][l][c]=NULL;
+ }
+ Operator_Extension::Reset();
+}
+
+Operator_Extension* Operator_Ext_TFSF::Clone(Operator* op)
+{
+ UNUSED(op);
+ return NULL;
+}
+
+bool Operator_Ext_TFSF::BuildExtension()
+{
+ m_Exc = m_Op->GetExcitationSignal();
+ double dT = m_Op->GetTimestep();
+ if (dT==0)
+ return false;
+ if (m_Exc==0)
+ return false;
+
+ Reset();
+ ContinuousStructure* CSX = m_Op->GetGeometryCSX();
+
+ vector<CSProperties*> vec_prop = CSX->GetPropertyByType(CSProperties::EXCITATION);
+
+ if (vec_prop.size()==0)
+ {
+ cerr << "Operator_Ext_TFSF::BuildExtension: Warning, no excitation properties found" << endl;
+ SetActive(false);
+ return false;
+ }
+
+ double ref_index = sqrt(m_Op->GetBackgroundEpsR()*m_Op->GetBackgroundMueR());
+ m_PhVel = __C0__/ref_index;
+ CSPropExcitation* elec=NULL;
+ CSProperties* prop=NULL;
+ CSPrimitives* prim=NULL;
+ CSPrimBox* box=NULL;
+ for (size_t p=0; p<vec_prop.size(); ++p)
+ {
+ prop = vec_prop.at(p);
+ elec = prop->ToExcitation();
+ if (elec->GetExcitType()!=10)
+ continue;
+ if (prop->GetQtyPrimitives()!=1)
+ {
+ cerr << "Operator_Ext_TFSF::BuildExtension: Warning, plane wave excitation found with more (or less) than one primitive, skipping..." << endl;
+ continue;
+ }
+ prim = prop->GetPrimitive(0);
+ if (prim->GetType()!=CSPrimitives::BOX)
+ {
+ cerr << "Operator_Ext_TFSF::BuildExtension: Warning, plane wave excitation found with false non-Box primitive, skipping..." << endl;
+ continue;
+ }
+ box = prim->ToBox();
+ if (box==NULL) //sanity check, should not happen!
+ {
+ SetActive(false);
+ return false;
+ }
+
+ // found a plane-wave excite with exactly one box
+ for (int n=0;n<3;++n)
+ m_PropDir[n] = elec->GetPropagationDir(n);
+ double dir_norm = sqrt(m_PropDir[0]*m_PropDir[0]+m_PropDir[1]*m_PropDir[1]+m_PropDir[2]*m_PropDir[2]);
+ if (dir_norm==0)
+ {
+ cerr << "Operator_Ext_TFSF::BuildExtension: Warning, plane wave direction is zero, skipping..." << endl;
+ SetActive(false);
+ return false;
+ }
+
+ //make it a unit vector
+ m_PropDir[0]/=dir_norm;m_PropDir[1]/=dir_norm;m_PropDir[2]/=dir_norm;
+
+ if (m_Op->SnapBox2Mesh(box->GetStartCoord()->GetNativeCoords(), box->GetStopCoord()->GetNativeCoords(), m_Start, m_Stop)!=3)
+ {
+ cerr << "Operator_Ext_TFSF::BuildExtension: Warning, plane wave box dimension is invalid, skipping..." << endl;
+ SetActive(false);
+ return false;
+ }
+
+ m_Frequency = elec->GetFrequency();
+// if (m_Frequency<=0)
+// m_Frequency = m_Op->GetExcitationSignal()->GetFrequencyOfInterest();
+ if (m_Frequency<=0)
+ m_PhVel=__C0__/ref_index;
+ else
+ m_PhVel=m_Op->CalcNumericPhaseVelocity(m_Start,m_Stop,m_PropDir,m_Frequency);
+
+ if ((m_PhVel<0) || (m_PhVel>__C0__/ref_index) || isnan(m_PhVel))
+ {
+ cerr << "Operator_Ext_TFSF::BuildExtension: Warning, invalid phase velocity found, resetting to c0! " << endl;
+ m_PhVel = __C0__/ref_index;
+ }
+
+ double origin[3];
+ unsigned int ui_origin[3];
+ for (int n=0;n<3;++n)
+ {
+ m_E_Amp[n] = elec->GetExcitation(n);
+ m_numLines[n] = m_Stop[n]-m_Start[n]+1;
+ m_IncLow[n] = m_PropDir[n]>=0;
+
+ if (m_Start[n]==0)
+ m_ActiveDir[n][0]=false;
+ else
+ m_ActiveDir[n][0]=true;
+ if (m_Stop[n]==m_Op->GetNumberOfLines(n,true)-1)
+ m_ActiveDir[n][1]=false;
+ else
+ m_ActiveDir[n][1]=true;
+
+ if (m_IncLow[n])
+ {
+ ui_origin[n] = m_Start[n]-1;
+ }
+ else
+ {
+ ui_origin[n] = m_Stop[n]+1;
+ }
+ origin[n] = m_Op->GetDiscLine(n,ui_origin[n]);
+ }
+
+ double dotEk = (m_E_Amp[0]*m_PropDir[0] + m_E_Amp[1]*m_PropDir[1] + m_E_Amp[2]*m_PropDir[2]);
+ double angle = acos( dotEk / (m_E_Amp[0]*m_E_Amp[0] + m_E_Amp[1]*m_E_Amp[1] + m_E_Amp[2]*m_E_Amp[2]) ) / PI * 180;
+
+ if (angle==0)
+ {
+ cerr << "Operator_Ext_TFSF::BuildExtension: Warning, plane wave direction and polarization is identical, skipping..." << endl;
+ SetActive(false);
+ return false;
+ }
+ if (angle!=90)
+ {
+ cerr << "Operator_Ext_TFSF::BuildExtension: Warning, angle between propagation direction and polarization is not 90deg, resetting E-polarization to : (";
+ for (int n=0;n<3;++n)
+ m_E_Amp[n]-=m_PropDir[n]*dotEk;
+ cerr << m_E_Amp[0] << "," << m_E_Amp[1] << "," << m_E_Amp[2] << ")" << endl;
+ }
+
+ int nP,nPP;
+ for (int n=0;n<3;++n)
+ {
+ nP = (n+1)%3;
+ nPP = (n+2)%3;
+ m_H_Amp[n] = m_PropDir[nP]*m_E_Amp[nPP] - m_PropDir[nPP]*m_E_Amp[nP];
+ m_H_Amp[n] /= __Z0__*sqrt(m_Op->GetBackgroundMueR()/m_Op->GetBackgroundEpsR());
+ }
+
+ double coord[3];
+ double unit = m_Op->GetGridDelta();
+ double delay;
+ double dist;
+ unsigned int pos[3];
+ unsigned int numP, ui_pos;
+ m_maxDelay = 0;
+ for (int n=0;n<3;++n)
+ {
+ nP = (n+1)%3;
+ nPP = (n+2)%3;
+ pos[n] = 0; //unused
+ pos[nP] = m_Start[nP];
+
+ numP = m_numLines[nP]*m_numLines[nPP];
+
+ if (!m_ActiveDir[n][0] && !m_ActiveDir[n][1])
+ continue;
+
+ for (int l=0;l<2;++l)
+ for (int c=0;c<2;++c)
+ {
+ if (m_ActiveDir[n][l])
+ {
+ m_VoltDelay[n][l][c]=new unsigned int[numP];
+ m_VoltDelayDelta[n][l][c]=new FDTD_FLOAT[numP];
+ m_VoltAmp[n][l][c]=new FDTD_FLOAT[numP];
+
+ m_CurrDelay[n][l][c]=new unsigned int[numP];
+ m_CurrDelayDelta[n][l][c]=new FDTD_FLOAT[numP];
+ m_CurrAmp[n][l][c]=new FDTD_FLOAT[numP];
+ }
+ }
+
+ ui_pos = 0;
+ for (unsigned int i=0;i<m_numLines[nP];++i)
+ {
+ pos[nPP] = m_Start[nPP];
+ for (unsigned int j=0;j<m_numLines[nPP];++j)
+ {
+ // current updates
+ pos[n] = m_Start[n];
+
+ if (m_ActiveDir[n][0])
+ {
+ m_Op->GetYeeCoords(nP,pos,coord,false);
+ dist = fabs((coord[0]-origin[0])*m_PropDir[0])+fabs((coord[1]-origin[1])*m_PropDir[1])+fabs((coord[2]-origin[2])*m_PropDir[2]);
+ delay = dist*unit/m_PhVel/dT;
+ m_maxDelay = max((unsigned int)delay,m_maxDelay);
+ m_CurrDelay[n][0][1][ui_pos] = floor(delay);
+ m_CurrDelayDelta[n][0][1][ui_pos] = delay - floor(delay);
+ m_CurrAmp[n][0][1][ui_pos] = m_E_Amp[nP]*m_Op->GetEdgeLength(nP,pos);
+
+ m_Op->GetYeeCoords(nPP,pos,coord,false);
+ dist = fabs((coord[0]-origin[0])*m_PropDir[0])+fabs((coord[1]-origin[1])*m_PropDir[1])+fabs((coord[2]-origin[2])*m_PropDir[2]);
+ delay = dist*unit/m_PhVel/dT;
+ m_maxDelay = max((unsigned int)delay,m_maxDelay);
+ m_CurrDelay[n][0][0][ui_pos] = floor(delay);
+ m_CurrDelayDelta[n][0][0][ui_pos] = delay - floor(delay);
+ m_CurrAmp[n][0][0][ui_pos] = m_E_Amp[nPP]*m_Op->GetEdgeLength(nPP,pos);
+
+ --pos[n];
+ m_CurrAmp[n][0][0][ui_pos]*=m_Op->GetIV(nP,pos);
+ m_CurrAmp[n][0][1][ui_pos]*=m_Op->GetIV(nPP,pos);
+ }
+
+ if (m_ActiveDir[n][1])
+ {
+ pos[n] = m_Stop[n];
+ m_Op->GetYeeCoords(nP,pos,coord,false);
+ dist = fabs((coord[0]-origin[0])*m_PropDir[0])+fabs((coord[1]-origin[1])*m_PropDir[1])+fabs((coord[2]-origin[2])*m_PropDir[2]);
+ delay = dist*unit/m_PhVel/dT;
+ m_maxDelay = max((unsigned int)delay,m_maxDelay);
+ m_CurrDelay[n][1][1][ui_pos] = floor(delay);
+ m_CurrDelayDelta[n][1][1][ui_pos] = delay - floor(delay);
+ m_CurrAmp[n][1][1][ui_pos] = m_E_Amp[nP]*m_Op->GetEdgeLength(nP,pos);
+
+ m_Op->GetYeeCoords(nPP,pos,coord,false);
+ dist = fabs((coord[0]-origin[0])*m_PropDir[0])+fabs((coord[1]-origin[1])*m_PropDir[1])+fabs((coord[2]-origin[2])*m_PropDir[2]);
+ delay = dist*unit/m_PhVel/dT;
+ m_maxDelay = max((unsigned int)delay,m_maxDelay);
+ m_CurrDelay[n][1][0][ui_pos] = floor(delay);
+ m_CurrDelayDelta[n][1][0][ui_pos] = delay - floor(delay);
+ m_CurrAmp[n][1][0][ui_pos] = m_E_Amp[nPP]*m_Op->GetEdgeLength(nPP,pos);
+
+ m_CurrAmp[n][1][0][ui_pos]*=m_Op->GetIV(nP,pos);
+ m_CurrAmp[n][1][1][ui_pos]*=m_Op->GetIV(nPP,pos);
+ }
+
+ if (m_ActiveDir[n][0])
+ m_CurrAmp[n][0][0][ui_pos]*=-1;
+ if (m_ActiveDir[n][1])
+ m_CurrAmp[n][1][1][ui_pos]*=-1;
+
+ if (pos[nP]==m_Stop[nP])
+ {
+ if (m_ActiveDir[n][0])
+ m_CurrAmp[n][0][1][ui_pos]=0;
+ if (m_ActiveDir[n][1])
+ m_CurrAmp[n][1][1][ui_pos]=0;
+ }
+ if (pos[nPP]==m_Stop[nPP])
+ {
+ if (m_ActiveDir[n][0])
+ m_CurrAmp[n][0][0][ui_pos]=0;
+ if (m_ActiveDir[n][1])
+ m_CurrAmp[n][1][0][ui_pos]=0;
+ }
+
+ // voltage updates
+ pos[n] = m_Start[n]-1;
+ if (m_ActiveDir[n][0])
+ {
+ m_Op->GetYeeCoords(nP,pos,coord,true);
+ dist = fabs((coord[0]-origin[0])*m_PropDir[0])+fabs((coord[1]-origin[1])*m_PropDir[1])+fabs((coord[2]-origin[2])*m_PropDir[2]);
+ delay = dist*unit/m_PhVel/dT + 1.0;
+ m_maxDelay = max((unsigned int)delay,m_maxDelay);
+ m_VoltDelay[n][0][1][ui_pos] = floor(delay);
+ m_VoltDelayDelta[n][0][1][ui_pos] = delay - floor(delay);
+ m_VoltAmp[n][0][1][ui_pos] = m_H_Amp[nP]*m_Op->GetEdgeLength(nP,pos,true);
+
+ m_Op->GetYeeCoords(nPP,pos,coord,true);
+ dist = fabs((coord[0]-origin[0])*m_PropDir[0])+fabs((coord[1]-origin[1])*m_PropDir[1])+fabs((coord[2]-origin[2])*m_PropDir[2]);
+ delay = dist*unit/m_PhVel/dT + 1.0;
+ m_maxDelay = max((unsigned int)delay,m_maxDelay);
+ m_VoltDelay[n][0][0][ui_pos] = floor(delay);
+ m_VoltDelayDelta[n][0][0][ui_pos] = delay - floor(delay);
+ m_VoltAmp[n][0][0][ui_pos] = m_H_Amp[nPP]*m_Op->GetEdgeLength(nPP,pos,true);
+
+ ++pos[n];
+ m_VoltAmp[n][0][0][ui_pos]*=m_Op->GetVI(nP,pos);
+ m_VoltAmp[n][0][1][ui_pos]*=m_Op->GetVI(nPP,pos);
+ }
+
+ pos[n] = m_Stop[n];
+ if (m_ActiveDir[n][1])
+ {
+ m_Op->GetYeeCoords(nP,pos,coord,true);
+ dist = fabs((coord[0]-origin[0])*m_PropDir[0])+fabs((coord[1]-origin[1])*m_PropDir[1])+fabs((coord[2]-origin[2])*m_PropDir[2]);
+ delay = dist*unit/m_PhVel/dT + 1.0;
+ m_maxDelay = max((unsigned int)delay,m_maxDelay);
+ m_VoltDelay[n][1][1][ui_pos] = floor(delay);
+ m_VoltDelayDelta[n][1][1][ui_pos] = delay - floor(delay);
+ m_VoltAmp[n][1][1][ui_pos] = m_H_Amp[nP]*m_Op->GetEdgeLength(nP,pos,true);
+
+ m_Op->GetYeeCoords(nPP,pos,coord,true);
+ dist = fabs((coord[0]-origin[0])*m_PropDir[0])+fabs((coord[1]-origin[1])*m_PropDir[1])+fabs((coord[2]-origin[2])*m_PropDir[2]);
+ delay = dist*unit/m_PhVel/dT + 1.0;
+ m_maxDelay = max((unsigned int)delay,m_maxDelay);
+ m_VoltDelay[n][1][0][ui_pos] = floor(delay);
+ m_VoltDelayDelta[n][1][0][ui_pos] = delay - floor(delay);
+ m_VoltAmp[n][1][0][ui_pos] = m_H_Amp[nPP]*m_Op->GetEdgeLength(nPP,pos,true);
+
+ m_VoltAmp[n][1][0][ui_pos]*=m_Op->GetVI(nP,pos);
+ m_VoltAmp[n][1][1][ui_pos]*=m_Op->GetVI(nPP,pos);
+ }
+
+ if (m_ActiveDir[n][1])
+ m_VoltAmp[n][1][0][ui_pos]*=-1;
+ if (m_ActiveDir[n][0])
+ m_VoltAmp[n][0][1][ui_pos]*=-1;
+
+ if (pos[nP]==m_Stop[nP])
+ {
+ if (m_ActiveDir[n][0])
+ m_VoltAmp[n][0][0][ui_pos]=0;
+ if (m_ActiveDir[n][1])
+ m_VoltAmp[n][1][0][ui_pos]=0;
+ }
+ if (pos[nPP]==m_Stop[nPP])
+ {
+ if (m_ActiveDir[n][0])
+ m_VoltAmp[n][0][1][ui_pos]=0;
+ if (m_ActiveDir[n][1])
+ m_VoltAmp[n][1][1][ui_pos]=0;
+ }
+
+ ++pos[nPP];
+ ++ui_pos;
+ }
+ ++pos[nP];
+ }
+ }
+ ++m_maxDelay;
+ return true;
+ }
+ SetActive(false);
+ return false;
+}
+
+Engine_Extension* Operator_Ext_TFSF::CreateEngineExtention()
+{
+ return new Engine_Ext_TFSF(this);
+}
+
+void Operator_Ext_TFSF::ShowStat(ostream &ostr) const
+{
+ Operator_Extension::ShowStat(ostr);
+ cout << "Active directions\t: " << "(" << m_ActiveDir[0][0] << "/" << m_ActiveDir[0][1] << ", " << m_ActiveDir[1][0] << "/" << m_ActiveDir[1][1] << ", " << m_ActiveDir[2][0] << "/" << m_ActiveDir[2][1] << ")" << endl;
+ cout << "Propagation direction\t: " << "(" << m_PropDir[0] << ", " << m_PropDir[1] << ", " << m_PropDir[2] << ")" << endl;
+ cout << "Rel. propagation speed\t: " << m_PhVel/__C0__ << "*c0 @ " << m_Frequency << " Hz" << endl;
+ cout << "E-field amplitude (V/m)\t: " << "(" << m_E_Amp[0] << ", " << m_E_Amp[1] << ", " << m_E_Amp[2] << ")" << endl;
+ cout << "H-field amplitude (A/m)\t: " << "(" << m_H_Amp[0] << ", " << m_H_Amp[1] << ", " << m_H_Amp[2] << ")" << endl;
+ cout << "Box Dimensions\t\t: " << m_numLines[0] << " x " << m_numLines[1] << " x " << m_numLines[2] << endl;
+ cout << "Max. Delay (TS)\t\t: " << m_maxDelay << endl;
+ int dirs = m_ActiveDir[0][0] + m_ActiveDir[0][1] + m_ActiveDir[1][0] + m_ActiveDir[1][1] + m_ActiveDir[2][0] + m_ActiveDir[2][1] ;
+ cout << "Memory usage (est.)\t: ~" << m_numLines[0] * m_numLines[1] * m_numLines[2] * dirs * 4 * 4 / 1024 << " kiB" << endl;
+}
diff --git a/openEMS/FDTD/extensions/operator_ext_tfsf.h b/openEMS/FDTD/extensions/operator_ext_tfsf.h
new file mode 100644
index 0000000..e1e714e
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_tfsf.h
@@ -0,0 +1,82 @@
+/*
+* Copyright (C) 2012 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXT_TFSF_H
+#define OPERATOR_EXT_TFSF_H
+
+#include "operator_extension.h"
+#include "FDTD/operator.h"
+#include "tools/constants.h"
+
+class Excitation;
+
+class Operator_Ext_TFSF : public Operator_Extension
+{
+ friend class Engine_Ext_TFSF;
+public:
+ Operator_Ext_TFSF(Operator* op);
+ ~Operator_Ext_TFSF();
+
+ virtual Operator_Extension* Clone(Operator* op);
+
+ virtual bool BuildExtension();
+
+ virtual Engine_Extension* CreateEngineExtention();
+
+ virtual bool IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const {UNUSED(closedAlpha); UNUSED(R0_included); return false;}
+ virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child); return false;}
+
+ // FIXME, this extension is not save to use with MPI
+ virtual bool IsMPISave() const {return false;}
+
+ virtual string GetExtensionName() const {return string("Total-Field/Scattered-Field Extension");}
+
+ virtual void ShowStat(ostream &ostr) const;
+
+ virtual void Init();
+ virtual void Reset();
+
+protected:
+ Excitation* m_Exc;
+
+ bool m_IncLow[3];
+ bool m_ActiveDir[3][2]; // m_ActiveDir[direction][low/high]
+ unsigned int m_Start[3];
+ unsigned int m_Stop[3];
+ unsigned int m_numLines[3];
+
+ double m_PropDir[3];
+ double m_E_Amp[3];
+ double m_H_Amp[3];
+
+ double m_Frequency;
+ double m_PhVel;
+
+ unsigned int m_maxDelay;
+
+ // array setup [direction][low/high][component][ <mesh_position> ]
+ unsigned int* m_VoltDelay[3][2][2];
+ FDTD_FLOAT* m_VoltDelayDelta[3][2][2];
+ FDTD_FLOAT* m_VoltAmp[3][2][2];
+
+ unsigned int* m_CurrDelay[3][2][2];
+ FDTD_FLOAT* m_CurrDelayDelta[3][2][2];
+ FDTD_FLOAT* m_CurrAmp[3][2][2];
+
+};
+
+#endif // OPERATOR_EXT_TFSF_H
diff --git a/openEMS/FDTD/extensions/operator_ext_upml.cpp b/openEMS/FDTD/extensions/operator_ext_upml.cpp
new file mode 100644
index 0000000..fc46d85
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_upml.cpp
@@ -0,0 +1,478 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "operator_ext_upml.h"
+#include "FDTD/operator_cylindermultigrid.h"
+#include "engine_ext_upml.h"
+#include "tools/array_ops.h"
+#include "fparser.hh"
+
+using namespace std;
+
+Operator_Ext_UPML::Operator_Ext_UPML(Operator* op) : Operator_Extension(op)
+{
+ m_GradingFunction = new FunctionParser();
+ //default grading function
+ SetGradingFunction(" -log(1e-6)*log(2.5)/(2*dl*Z*(pow(2.5,W/dl)-1)) * pow(2.5, D/dl) ");
+
+ for (int n=0; n<6; ++n)
+ {
+ m_BC[n]=0;
+ m_Size[n]=0;
+ }
+ for (int n=0; n<3; ++n)
+ {
+ m_StartPos[n]=0;
+ m_numLines[n]=0;
+ }
+
+ vv = NULL;
+ vvfo = NULL;
+ vvfn = NULL;
+ ii = NULL;
+ iifo = NULL;
+ iifn = NULL;
+}
+
+Operator_Ext_UPML::~Operator_Ext_UPML()
+{
+ delete m_GradingFunction;
+ m_GradingFunction = NULL;
+ DeleteOp();
+}
+
+void Operator_Ext_UPML::SetBoundaryCondition(const int* BCs, const unsigned int size[6])
+{
+ for (int n=0; n<6; ++n)
+ {
+ m_BC[n]=BCs[n];
+ m_Size[n]=size[n];
+ }
+}
+
+void Operator_Ext_UPML::SetRange(const unsigned int start[3], const unsigned int stop[3])
+{
+ for (int n=0; n<3; ++n)
+ {
+ m_StartPos[n]=start[n];
+ m_numLines[n]=stop[n]-start[n]+1;
+ }
+}
+
+bool Operator_Ext_UPML::Create_UPML(Operator* op, const int ui_BC[6], const unsigned int ui_size[6], string gradFunc)
+{
+ int BC[6]={ui_BC[0],ui_BC[1],ui_BC[2],ui_BC[3],ui_BC[4],ui_BC[5]};
+ unsigned int size[6]={ui_size[0],ui_size[1],ui_size[2],ui_size[3],ui_size[4],ui_size[5]};
+
+ //check if mesh is large enough to support the pml
+ for (int n=0; n<3; ++n)
+ if ( (size[2*n]*(BC[2*n]==3)+size[2*n+1]*(BC[2*n+1]==3)) >= op->GetNumberOfLines(n,true) )
+ {
+ cerr << "Operator_Ext_UPML::Create_UPML: Warning: Not enough lines in direction: " << n << ", resetting to PEC" << endl;
+ BC[2*n]=0;
+ size[2*n]=0;
+ BC[2*n+1]=0;
+ size[2*n+1]=0;
+ }
+
+ //check cylindrical coord compatiblility
+ Operator_Cylinder* op_cyl = dynamic_cast<Operator_Cylinder*>(op);
+ if (op_cyl)
+ {
+ if ((BC[0]==3) && (op_cyl->GetClosedAlpha() || op_cyl->GetR0Included()))
+ {
+ BC[0]=0;
+ size[0]=0;
+ cerr << "Operator_Ext_UPML::Create_UPML: Warning: An upml in r-min direction is not possible, resetting to PEC..." << endl;
+ }
+ if ( (BC[2]==3) && (op_cyl->GetClosedAlpha()) )
+ {
+ BC[2]=0;
+ size[2]=0;
+ cerr << "Operator_Ext_UPML::Create_UPML: Warning: An upml in alpha-min direction is not possible, resetting to PEC..." << endl;
+ }
+ if ( (BC[3]==3) && (op_cyl->GetClosedAlpha()) )
+ {
+ BC[3]=0;
+ size[3]=0;
+ cerr << "Operator_Ext_UPML::Create_UPML: Warning: An upml in alpha-max direction is not possible, resetting to PEC..." << endl;
+ }
+ }
+
+ //check cylindrical coord compatiblility
+ if (dynamic_cast<Operator_CylinderMultiGrid*>(op))
+ {
+ if (BC[2]==3)
+ {
+ BC[2]=0;
+ size[2]=0;
+ cerr << "Operator_Ext_UPML::Create_UPML: Warning: An upml in alpha direction is not possible for a cylindrical multi-grid, resetting to PEC..." << endl;
+ }
+ if (BC[3]==3)
+ {
+ BC[3]=0;
+ size[3]=0;
+ cerr << "Operator_Ext_UPML::Create_UPML: Warning: An upml in alpha direction is not possible for a cylindrical multi-grid, resetting to PEC..." << endl;
+ }
+ }
+
+
+ Operator_Ext_UPML* op_ext_upml=NULL;
+ unsigned int start[3]={0 ,0 ,0};
+ unsigned int stop[3] ={op->GetNumberOfLines(0,true)-1,op->GetNumberOfLines(1,true)-1,op->GetNumberOfLines(2,true)-1};
+
+ //create a pml in x-direction over the full width of yz-space
+ if (BC[0]==3)
+ {
+ op_ext_upml = new Operator_Ext_UPML(op);
+ op_ext_upml->SetGradingFunction(gradFunc);
+ start[0]=0;
+ stop[0] =size[0];
+ op_ext_upml->SetBoundaryCondition(BC, size);
+ op_ext_upml->SetRange(start,stop);
+ op->AddExtension(op_ext_upml);
+ }
+ if (BC[1]==3)
+ {
+ op_ext_upml = new Operator_Ext_UPML(op);
+ op_ext_upml->SetGradingFunction(gradFunc);
+ start[0]=op->GetNumberOfLines(0,true)-1-size[1];
+ stop[0] =op->GetNumberOfLines(0,true)-1;
+ op_ext_upml->SetBoundaryCondition(BC, size);
+ op_ext_upml->SetRange(start,stop);
+ op->AddExtension(op_ext_upml);
+ }
+
+ //create a pml in y-direction over the xz-space (if a pml in x-direction already exists, skip that corner regions)
+ start[0]=(size[0]+1)*(BC[0]==3);
+ stop[0] =op->GetNumberOfLines(0,true)-1-(size[0]+1)*(BC[1]==3);
+
+ if (BC[2]==3)
+ {
+ op_ext_upml = new Operator_Ext_UPML(op);
+ op_ext_upml->SetGradingFunction(gradFunc);
+ start[1]=0;
+ stop[1] =size[2];
+ op_ext_upml->SetBoundaryCondition(BC, size);
+ op_ext_upml->SetRange(start,stop);
+ op->AddExtension(op_ext_upml);
+ }
+ if (BC[3]==3)
+ {
+ op_ext_upml = new Operator_Ext_UPML(op);
+ op_ext_upml->SetGradingFunction(gradFunc);
+ start[1]=op->GetNumberOfLines(1,true)-1-size[3];
+ stop[1] =op->GetNumberOfLines(1,true)-1;
+ op_ext_upml->SetBoundaryCondition(BC, size);
+ op_ext_upml->SetRange(start,stop);
+ op->AddExtension(op_ext_upml);
+ }
+
+ //create a pml in z-direction over the xy-space (if a pml in x- and/or y-direction already exists, skip that corner/edge regions)
+ start[1]=(size[2]+1)*(BC[2]==3);
+ stop[1] =op->GetNumberOfLines(1,true)-1-(size[3]+1)*(BC[3]==3);
+
+ //exclude x-lines that does not belong to the base multi-grid operator;
+ Operator_CylinderMultiGrid* op_cyl_MG = dynamic_cast<Operator_CylinderMultiGrid*>(op);
+ if (op_cyl_MG)
+ start[0] = op_cyl_MG->GetSplitPos()-1;
+
+ if (BC[4]==3)
+ {
+ op_ext_upml = new Operator_Ext_UPML(op);
+ op_ext_upml->SetGradingFunction(gradFunc);
+ start[2]=0;
+ stop[2] =size[4];
+ op_ext_upml->SetBoundaryCondition(BC, size);
+ op_ext_upml->SetRange(start,stop);
+ op->AddExtension(op_ext_upml);
+ }
+ if (BC[5]==3)
+ {
+ op_ext_upml = new Operator_Ext_UPML(op);
+ op_ext_upml->SetGradingFunction(gradFunc);
+ start[2]=op->GetNumberOfLines(2,true)-1-size[5];
+ stop[2] =op->GetNumberOfLines(2,true)-1;
+ op_ext_upml->SetBoundaryCondition(BC, size);
+ op_ext_upml->SetRange(start,stop);
+ op->AddExtension(op_ext_upml);
+ }
+
+ BC[1]=0;
+ size[1]=0;
+ //create pml extensions (in z-direction only) for child operators in cylindrical multigrid operators
+ while (op_cyl_MG)
+ {
+ Operator_Cylinder* op_child = op_cyl_MG->GetInnerOperator();
+ op_cyl_MG = dynamic_cast<Operator_CylinderMultiGrid*>(op_child);
+ for (int n=0; n<2; ++n)
+ {
+ start[n]=0;
+ stop[n]=op_child->GetNumberOfLines(n,true)-1;
+ }
+
+ if (op_cyl_MG)
+ start[0] = op_cyl_MG->GetSplitPos()-1;
+
+ if (BC[4]==3)
+ {
+ op_ext_upml = new Operator_Ext_UPML(op_child);
+ op_ext_upml->SetGradingFunction(gradFunc);
+ start[2]=0;
+ stop[2] =size[4];
+ op_ext_upml->SetBoundaryCondition(BC, size);
+ op_ext_upml->SetRange(start,stop);
+ op_child->AddExtension(op_ext_upml);
+ }
+ if (BC[5]==3)
+ {
+ op_ext_upml = new Operator_Ext_UPML(op_child);
+ op_ext_upml->SetGradingFunction(gradFunc);
+ start[2]=op->GetNumberOfLines(2,true)-1-size[5];
+ stop[2] =op->GetNumberOfLines(2,true)-1;
+ op_ext_upml->SetBoundaryCondition(BC, size);
+ op_ext_upml->SetRange(start,stop);
+ op_child->AddExtension(op_ext_upml);
+ }
+ }
+
+ return true;
+}
+
+
+void Operator_Ext_UPML::DeleteOp()
+{
+ Delete_N_3DArray<FDTD_FLOAT>(vv,m_numLines);
+ vv = NULL;
+ Delete_N_3DArray<FDTD_FLOAT>(vvfo,m_numLines);
+ vvfo = NULL;
+ Delete_N_3DArray<FDTD_FLOAT>(vvfn,m_numLines);
+ vvfn = NULL;
+ Delete_N_3DArray<FDTD_FLOAT>(ii,m_numLines);
+ ii = NULL;
+ Delete_N_3DArray<FDTD_FLOAT>(iifo,m_numLines);
+ iifo = NULL;
+ Delete_N_3DArray<FDTD_FLOAT>(iifn,m_numLines);
+ iifn = NULL;
+}
+
+
+bool Operator_Ext_UPML::SetGradingFunction(string func)
+{
+ if (func.empty())
+ return true;
+
+ m_GradFunc = func;
+ int res = m_GradingFunction->Parse(m_GradFunc.c_str(), "D,dl,W,Z,N");
+ if (res < 0) return true;
+
+ cerr << "Operator_Ext_UPML::SetGradingFunction: Warning, an error occured parsing the pml grading function (see below) ..." << endl;
+ cerr << func << "\n" << string(res, ' ') << "^\n" << m_GradingFunction->ErrorMsg() << "\n";
+ return false;
+}
+
+void Operator_Ext_UPML::CalcGradingKappa(int ny, unsigned int pos[3], double Zm, double kappa_v[3], double kappa_i[3])
+{
+ double depth=0;
+ double width=0;
+ for (int n=0; n<3; ++n)
+ {
+ if ((pos[n] <= m_Size[2*n]) && (m_BC[2*n]==3)) //lower pml in n-dir
+ {
+ width = (m_Op->GetDiscLine(n,m_Size[2*n]) - m_Op->GetDiscLine(n,0))*m_Op->GetGridDelta();
+ depth = width - (m_Op->GetDiscLine(n,pos[n]) - m_Op->GetDiscLine(n,0))*m_Op->GetGridDelta();
+
+ if ((m_Op_Cyl) && (n==1))
+ {
+ width *= m_Op_Cyl->GetDiscLine(0,pos[0]);
+ depth *= m_Op_Cyl->GetDiscLine(0,pos[0]);
+ }
+
+ if (n==ny)
+ depth-=m_Op->GetEdgeLength(n,pos)/2;
+ double vars[5] = {depth, width/m_Size[2*n], width, Zm, (double)m_Size[2*n]};
+ if (depth>0)
+ kappa_v[n] = m_GradingFunction->Eval(vars);
+ else
+ kappa_v[n]=0;
+ if (n==ny)
+ depth+=m_Op->GetEdgeLength(n,pos)/2;
+
+ if (n!=ny)
+ depth-=m_Op->GetEdgeLength(n,pos)/2;
+ if (depth<0)
+ depth=0;
+ vars[0]=depth;
+ if (depth>0)
+ kappa_i[n] = m_GradingFunction->Eval(vars);
+ else
+ kappa_i[n] = 0;
+ }
+ else if ((pos[n] >= m_Op->GetNumberOfLines(n,true) -1 -m_Size[2*n+1]) && (m_BC[2*n+1]==3)) //upper pml in n-dir
+ {
+ width = (m_Op->GetDiscLine(n,m_Op->GetNumberOfLines(n,true)-1) - m_Op->GetDiscLine(n,m_Op->GetNumberOfLines(n,true)-m_Size[2*n+1]-1))*m_Op->GetGridDelta();
+ depth = width - (m_Op->GetDiscLine(n,m_Op->GetNumberOfLines(n,true)-1) - m_Op->GetDiscLine(n,pos[n]))*m_Op->GetGridDelta();
+
+ if ((m_Op_Cyl) && (n==1))
+ {
+ width *= m_Op_Cyl->GetDiscLine(0,pos[0]);
+ depth *= m_Op_Cyl->GetDiscLine(0,pos[0]);
+ }
+
+ if (n==ny)
+ depth+=m_Op->GetEdgeLength(n,pos)/2;
+ double vars[5] = {depth, width/(m_Size[2*n]), width, Zm, (double)m_Size[2*n]};
+ if (depth>0)
+ kappa_v[n] = m_GradingFunction->Eval(vars);
+ else
+ kappa_v[n]=0;
+ if (n==ny)
+ depth-=m_Op->GetEdgeLength(n,pos)/2;
+
+ if (n!=ny)
+ depth+=m_Op->GetEdgeLength(n,pos)/2;
+ if (depth>width)
+ depth=0;
+ vars[0]=depth;
+ if (depth>0)
+ kappa_i[n] = m_GradingFunction->Eval(vars);
+ else
+ kappa_i[n]=0;
+ }
+ else
+ {
+ kappa_v[n] = 0;
+ kappa_i[n] = 0;
+ }
+ }
+}
+
+bool Operator_Ext_UPML::BuildExtension()
+{
+ /*Calculate the upml coefficients as defined in:
+ Allen Taflove, computational electrodynamics - the FDTD method, third edition, chapter 7.8, pages 297-300
+ - modified by Thorsten Liebig to match the equivalent circuit (EC) FDTD method
+ - kappa is used for conductivities (instead of sigma)
+ */
+ if (m_Op==NULL)
+ return false;
+
+ DeleteOp();
+ vv = Create_N_3DArray<FDTD_FLOAT>(m_numLines);
+ vvfo = Create_N_3DArray<FDTD_FLOAT>(m_numLines);
+ vvfn = Create_N_3DArray<FDTD_FLOAT>(m_numLines);
+ ii = Create_N_3DArray<FDTD_FLOAT>(m_numLines);
+ iifo = Create_N_3DArray<FDTD_FLOAT>(m_numLines);
+ iifn = Create_N_3DArray<FDTD_FLOAT>(m_numLines);
+
+ unsigned int pos[3];
+ unsigned int loc_pos[3];
+ int nP,nPP;
+ double kappa_v[3]={0,0,0};
+ double kappa_i[3]={0,0,0};
+ double eff_Mat[4];
+ double dT = m_Op->GetTimestep();
+
+ for (loc_pos[0]=0; loc_pos[0]<m_numLines[0]; ++loc_pos[0])
+ {
+ pos[0] = loc_pos[0] + m_StartPos[0];
+ for (loc_pos[1]=0; loc_pos[1]<m_numLines[1]; ++loc_pos[1])
+ {
+ pos[1] = loc_pos[1] + m_StartPos[1];
+ vector<CSPrimitives*> vPrims = m_Op->GetPrimitivesBoundBox(pos[0], pos[1], -1, CSProperties::MATERIAL);
+ for (loc_pos[2]=0; loc_pos[2]<m_numLines[2]; ++loc_pos[2])
+ {
+ pos[2] = loc_pos[2] + m_StartPos[2];
+ for (int n=0; n<3; ++n)
+ {
+ m_Op->Calc_EffMatPos(n,pos,eff_Mat,vPrims);
+ CalcGradingKappa(n, pos,__Z0__ ,kappa_v ,kappa_i);
+ nP = (n+1)%3;
+ nPP = (n+2)%3;
+ if ((kappa_v[0]+kappa_v[1]+kappa_v[2])!=0)
+ {
+ //check if pos is on PEC
+ if ( (m_Op->GetVV(n,pos[0],pos[1],pos[2]) + m_Op->GetVI(n,pos[0],pos[1],pos[2])) != 0 )
+ {
+ //modify the original operator to perform eq. (7.85) by the main engine (EC-FDTD: equation is multiplied by delta_n)
+ //the engine extension will replace the original voltages with the "voltage flux" (volt*eps0) prior to the voltage updates
+ //after the updates are done the extension will calculate the new voltages (see below) and place them back into the main field domain
+ m_Op->SetVV(n,pos[0],pos[1],pos[2], (2*__EPS0__ - kappa_v[nP]*dT) / (2*__EPS0__ + kappa_v[nP]*dT) );
+ m_Op->SetVI(n,pos[0],pos[1],pos[2], (2*__EPS0__*dT) / (2*__EPS0__ + kappa_v[nP]*dT) * m_Op->GetEdgeLength(n,pos) / m_Op->GetEdgeArea(n,pos) );
+
+
+ //operators needed by eq. (7.88) to calculate new voltages from old voltages and old and new "voltage fluxes"
+ GetVV(n,loc_pos) = (2*__EPS0__ - kappa_v[nPP]*dT) / (2*__EPS0__ + kappa_v[nPP]*dT);
+ GetVVFN(n,loc_pos) = (2*__EPS0__ + kappa_v[n]*dT) / (2*__EPS0__ + kappa_v[nPP]*dT)/eff_Mat[0];
+ GetVVFO(n,loc_pos) = (2*__EPS0__ - kappa_v[n]*dT) / (2*__EPS0__ + kappa_v[nPP]*dT)/eff_Mat[0];
+ }
+ }
+ else
+ {
+ //disable upml
+ GetVV(n,loc_pos) = m_Op->GetVV(n,pos[0],pos[1],pos[2]);
+ m_Op->SetVV(n,pos[0],pos[1],pos[2], 0 );
+ GetVVFO(n,loc_pos) = 0;
+ GetVVFN(n,loc_pos) = 1;
+ }
+
+ if ((kappa_i[0]+kappa_i[1]+kappa_i[2])!=0)
+ {
+ //check if pos is on PMC
+ if ( (m_Op->GetII(n,pos[0],pos[1],pos[2]) + m_Op->GetIV(n,pos[0],pos[1],pos[2])) != 0 )
+ {
+ //modify the original operator to perform eq. (7.89) by the main engine (EC-FDTD: equation is multiplied by delta_n)
+ //the engine extension will replace the original currents with the "current flux" (curr*mu0) prior to the current updates
+ //after the updates are done the extension will calculate the new currents (see below) and place them back into the main field domain
+ m_Op->SetII(n,pos[0],pos[1],pos[2], (2*__EPS0__ - kappa_i[nP]*dT) / (2*__EPS0__ + kappa_i[nP]*dT) );
+ m_Op->SetIV(n,pos[0],pos[1],pos[2], (2*__EPS0__*dT) / (2*__EPS0__ + kappa_i[nP]*dT) * m_Op->GetEdgeLength(n,pos,true) / m_Op->GetEdgeArea(n,pos,true) );
+
+ //operators needed by eq. (7.90) to calculate new currents from old currents and old and new "current fluxes"
+ GetII(n,loc_pos) = (2*__EPS0__ - kappa_i[nPP]*dT) / (2*__EPS0__ + kappa_i[nPP]*dT);
+ GetIIFN(n,loc_pos) = (2*__EPS0__ + kappa_i[n]*dT) / (2*__EPS0__ + kappa_i[nPP]*dT)/eff_Mat[2];
+ GetIIFO(n,loc_pos) = (2*__EPS0__ - kappa_i[n]*dT) / (2*__EPS0__ + kappa_i[nPP]*dT)/eff_Mat[2];
+ }
+ }
+ else
+ {
+ //disable upml
+ GetII(n,loc_pos) = m_Op->GetII(n,pos[0],pos[1],pos[2]);
+ m_Op->SetII(n,pos[0],pos[1],pos[2], 0 );
+ GetIIFO(n,loc_pos) = 0;
+ GetIIFN(n,loc_pos) = 1;
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+
+Engine_Extension* Operator_Ext_UPML::CreateEngineExtention()
+{
+ Engine_Ext_UPML* eng_ext = new Engine_Ext_UPML(this);
+ return eng_ext;
+}
+
+void Operator_Ext_UPML::ShowStat(ostream &ostr) const
+{
+ Operator_Extension::ShowStat(ostr);
+
+ ostr << " PML range\t\t: " << "[" << m_StartPos[0]<< "," << m_StartPos[1]<< "," << m_StartPos[2]<< "] to ["
+ << m_StartPos[0]+m_numLines[0]-1 << "," << m_StartPos[1]+m_numLines[1]-1 << "," << m_StartPos[2]+m_numLines[2]-1 << "]" << endl;
+ ostr << " Grading function\t: \"" << m_GradFunc << "\"" << endl;
+}
diff --git a/openEMS/FDTD/extensions/operator_ext_upml.h b/openEMS/FDTD/extensions/operator_ext_upml.h
new file mode 100644
index 0000000..5256655
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_ext_upml.h
@@ -0,0 +1,106 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXT_UPML_H
+#define OPERATOR_EXT_UPML_H
+
+#include "FDTD/operator.h"
+#include "operator_extension.h"
+
+class FunctionParser;
+
+//! Operator extension implemention an uniaxial perfectly matched layer (upml)
+/*
+ The priority for this extension should be the highest of all extensions since this operator will use the main engine to perform vital parts in the upml implementation.
+ Therefore the voltages and currents as well as the operator are replaced during these update process.
+ This extension is propably incompatible with the most other extensions operating in the same regions.
+ */
+class Operator_Ext_UPML : public Operator_Extension
+{
+ friend class Engine_Ext_UPML;
+public:
+ virtual ~Operator_Ext_UPML();
+
+ //! Returns always true, Create_UPML method will take care of creating a valid pml for the cylindrical fdtd
+ virtual bool IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const { UNUSED(closedAlpha); UNUSED(R0_included); return true;}
+
+ //! Returns always true if base grid, Create_UPML will create proper child pml extensions.
+ virtual bool IsCylindricalMultiGridSave(bool child) const {if (child) return false; return true;}
+
+ virtual bool IsMPISave() const {return true;}
+
+ void SetBoundaryCondition(const int* BCs, const unsigned int size[6]);
+
+ void SetRange(const unsigned int start[3], const unsigned int stop[3]);
+
+ //! Set the grading function for the pml
+ /*!
+ Define the pml grading grading function.
+ Predefined variables in this grading function are:
+ D = depth in the pml in meter
+ dl = mesh delta inside the pml in meter
+ W = width (length) of the pml in meter
+ N = number of cells for the pml
+ Z = wave impedance at the current depth and position
+ example: SetGradingFunction(" -log(1e-6)*log(2.5)/(2*dl*Z*(pow(2.5,W/dl)-1)) * pow(2.5, D/dl) ");
+
+ An empty function string will be ignored.
+ */
+ virtual bool SetGradingFunction(string func);
+
+ virtual bool BuildExtension();
+
+ virtual Engine_Extension* CreateEngineExtention();
+
+ virtual string GetExtensionName() const {return string("Uniaxial PML Extension");}
+
+ virtual void ShowStat(ostream &ostr) const;
+
+ //! Create the UPML
+ static bool Create_UPML(Operator* op, const int ui_BC[6], const unsigned int ui_size[6], const string gradFunc);
+
+protected:
+ Operator_Ext_UPML(Operator* op);
+ int m_BC[6];
+ unsigned int m_Size[6];
+
+ unsigned int m_StartPos[3];
+ unsigned int m_numLines[3];
+
+ string m_GradFunc;
+ FunctionParser* m_GradingFunction;
+
+ void CalcGradingKappa(int ny, unsigned int pos[3], double Zm, double kappa_v[3], double kappa_i[3]);
+
+ void DeleteOp();
+
+ virtual FDTD_FLOAT& GetVV(int ny, unsigned int pos[3]) {return vv[ny][pos[0]][pos[1]][pos[2]];}
+ virtual FDTD_FLOAT& GetVVFO(int ny, unsigned int pos[3]) {return vvfo[ny][pos[0]][pos[1]][pos[2]];}
+ virtual FDTD_FLOAT& GetVVFN(int ny, unsigned int pos[3]) {return vvfn[ny][pos[0]][pos[1]][pos[2]];}
+ virtual FDTD_FLOAT& GetII(int ny, unsigned int pos[3]) {return ii[ny][pos[0]][pos[1]][pos[2]];}
+ virtual FDTD_FLOAT& GetIIFO(int ny, unsigned int pos[3]) {return iifo[ny][pos[0]][pos[1]][pos[2]];}
+ virtual FDTD_FLOAT& GetIIFN(int ny, unsigned int pos[3]) {return iifn[ny][pos[0]][pos[1]][pos[2]];}
+
+ FDTD_FLOAT**** vv; //calc new voltage from old voltage
+ FDTD_FLOAT**** vvfo; //calc new voltage from old voltage flux
+ FDTD_FLOAT**** vvfn; //calc new voltage from new voltage flux
+ FDTD_FLOAT**** ii; //calc new current from old current
+ FDTD_FLOAT**** iifo; //calc new current from old current flux
+ FDTD_FLOAT**** iifn; //calc new current from new current flux
+};
+
+#endif // OPERATOR_EXT_UPML_H
diff --git a/openEMS/FDTD/extensions/operator_extension.cpp b/openEMS/FDTD/extensions/operator_extension.cpp
new file mode 100644
index 0000000..50e7068
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_extension.cpp
@@ -0,0 +1,54 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 "operator_extension.h"
+#include "FDTD/operator.h"
+#include "FDTD/operator_cylinder.h"
+
+using namespace std;
+
+Operator_Extension::Operator_Extension(Operator* op)
+{
+ m_Op = op;
+ m_Active = true;
+
+ m_CC_R0_included = false;
+ m_Op_Cyl = dynamic_cast<Operator_Cylinder*>(op);
+ if (m_Op_Cyl)
+ m_CC_R0_included=m_Op_Cyl->GetR0Included();
+ m_Eng_Ext = NULL;
+}
+
+Operator_Extension::~Operator_Extension()
+{
+}
+
+Operator_Extension::Operator_Extension(Operator* op, Operator_Extension* op_ext)
+{
+ UNUSED(op_ext);
+ m_Op = op;
+ m_Op_Cyl = dynamic_cast<Operator_Cylinder*>(op);
+ m_Active = op_ext->m_Active;
+ if (m_Op_Cyl)
+ m_CC_R0_included=m_Op_Cyl->GetR0Included();
+ m_Eng_Ext = NULL;
+}
+
+void Operator_Extension::ShowStat(ostream &ostr) const
+{
+ ostr << "--- " << GetExtensionName() << " ---" << endl;
+}
diff --git a/openEMS/FDTD/extensions/operator_extension.h b/openEMS/FDTD/extensions/operator_extension.h
new file mode 100644
index 0000000..21e42af
--- /dev/null
+++ b/openEMS/FDTD/extensions/operator_extension.h
@@ -0,0 +1,87 @@
+/*
+* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@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 OPERATOR_EXTENSION_H
+#define OPERATOR_EXTENSION_H
+
+#include <string>
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "tools/global.h"
+
+class Operator;
+class Operator_Cylinder;
+class Engine_Extension;
+
+//! Abstract base-class for all operator extensions
+class Operator_Extension
+{
+ friend class Engine_Extension;
+public:
+ virtual ~Operator_Extension();
+
+ //! Create a clone of this extension, will return NULL if this is impossible
+ /*!
+ Create a clone of this extension, will return NULL if this is impossible (e.g. derived extension has no clone method and copy-constructor)...
+ BuildExtension has to be called separatly!
+ */
+ virtual Operator_Extension* Clone(Operator* op) {UNUSED(op); return NULL;}
+
+ virtual bool BuildExtension() {return true;}
+
+ virtual Engine_Extension* CreateEngineExtention() {return 0;}
+ virtual Engine_Extension* GetEngineExtention() {return m_Eng_Ext;}
+
+ //! The cylindrical operator will check whether the extension is save to use. Default is false. Derive this method to override.
+ virtual bool IsCylinderCoordsSave(bool closedAlpha, bool R0_included) const {UNUSED(closedAlpha); UNUSED(R0_included); return false;}
+
+ //! The cylindrical multi grid operator will check whether the extension is save to use. Default is false. Derive this method to override.
+ virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child); return false;}
+
+ //! The MPI operator (if enabled) will check whether the extension is compatible with MPI. Default is false. Derive this method to override.
+ virtual bool IsMPISave() const {return false;}
+
+ virtual std::string GetExtensionName() const {return std::string("Abstract Operator Extension Base Class");}
+
+ virtual void ShowStat(std::ostream &ostr) const;
+
+ virtual bool IsActive() const {return m_Active;}
+ virtual void SetActive(bool active=true) {m_Active=active;}
+
+ virtual void Init() {}
+ virtual void Reset() {}
+
+protected:
+ Operator_Extension(Operator* op);
+ //! Copy constructor
+ Operator_Extension(Operator* op, Operator_Extension* op_ext);
+
+ bool m_Active;
+
+ //FDTD Operator
+ Operator* m_Op;
+ Engine_Extension* m_Eng_Ext;
+
+ //Cylindrical FDTD Operator (not NULL if a cylindrical FDTD is used)
+ Operator_Cylinder* m_Op_Cyl;
+ bool m_CC_R0_included;
+};
+
+#endif // OPERATOR_EXTENSION_H
diff --git a/openEMS/FDTD/openems_fdtd_mpi.cpp b/openEMS/FDTD/openems_fdtd_mpi.cpp
new file mode 100644
index 0000000..eaab59a
--- /dev/null
+++ b/openEMS/FDTD/openems_fdtd_mpi.cpp
@@ -0,0 +1,545 @@
+/*
+* Copyright (C) 2011 Thorsten Liebig (Thorsten.Liebig@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 "openems_fdtd_mpi.h"
+#include "FDTD/engine_interface_fdtd.h"
+#include "FDTD/operator_mpi.h"
+#include "FDTD/operator_cylinder.h"
+#include "FDTD/engine_mpi.h"
+#include "Common/processfields.h"
+#include "Common/processintegral.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <iomanip>
+#include <string.h>
+#include <sys/time.h>
+#include <time.h>
+#include "mpi.h"
+#include "tools/useful.h"
+#include "tinyxml.h"
+
+openEMS_FDTD_MPI::openEMS_FDTD_MPI(bool m_MPI_Debug) : openEMS()
+{
+ m_MyID = MPI::COMM_WORLD.Get_rank();
+ m_NumProc = MPI::COMM_WORLD.Get_size();
+
+ m_MaxEnergy = 0;
+ m_EnergyDecrement = 1;
+ m_MPI_Op = NULL;
+
+ if (m_NumProc>1)
+ m_MPI_Enabled=true;
+ else
+ m_MPI_Enabled=false;
+
+ if (m_MyID==0)
+ {
+ m_Gather_Buffer = new int[m_NumProc];
+ m_Energy_Buffer = new double[m_NumProc];
+ }
+ else
+ {
+ m_Gather_Buffer = NULL;
+ m_Energy_Buffer = NULL;
+ }
+
+ m_MPI_Elem = NULL;
+ m_Original_Grid = NULL;
+
+ //redirect output to file for all ranks > 0
+ if ((m_MyID>0) && (m_MPI_Debug==false))
+ {
+ stringstream out_name;
+ out_name << "ID" << m_MyID << "_" << "output.txt";
+ m_Output = new ofstream();
+ m_Output->open(out_name.str().c_str());
+ cout.rdbuf(m_Output->rdbuf());
+ cerr.rdbuf(m_Output->rdbuf());
+ }
+ else
+ m_Output = NULL;
+}
+
+openEMS_FDTD_MPI::~openEMS_FDTD_MPI()
+{
+ delete[] m_Gather_Buffer;
+ m_Gather_Buffer = NULL;
+ delete[] m_Energy_Buffer;
+ m_Energy_Buffer = NULL;
+ delete m_Original_Grid;
+ m_Original_Grid = NULL;
+ delete m_Output;
+ m_Output=NULL;
+}
+
+string openEMS_FDTD_MPI::GetExtLibsInfo()
+{
+ stringstream str;
+
+ str << openEMS::GetExtLibsInfo();
+
+ // MPI
+ str << "\t\t" << "MPI -- Version: " << MPI_VERSION << "." << MPI_SUBVERSION << endl;
+ str << "\t\t" << " compiled against: ";
+#ifdef MPICH2_VERSION
+ str << "MPICH2 " << MPICH2_VERSION << endl;
+#endif
+
+#ifdef OMPI_MAJOR_VERSION
+ str << "openMPI" << OMPI_MAJOR_VERSION << "." << OMPI_MINOR_VERSION << "." << OMPI_RELEASE_VERSION << endl;
+#endif
+
+ return str.str();
+}
+
+
+bool openEMS_FDTD_MPI::parseCommandLineArgument( const char *argv )
+{
+ if (!argv)
+ return false;
+
+ bool ret = openEMS::parseCommandLineArgument( argv );
+
+ if (ret)
+ return ret;
+
+ if (strcmp(argv,"--engine=MPI")==0)
+ {
+ cout << "openEMS_FDTD_MPI - enabled MPI parallel processing" << endl;
+ m_engine = EngineType_MPI;
+ return true;
+ }
+
+ return false;
+}
+
+bool openEMS_FDTD_MPI::Parse_XML_FDTDSetup(TiXmlElement* FDTD_Opts)
+{
+ m_MPI_Elem = FDTD_Opts->FirstChildElement("MPI");
+ if (!m_MPI_Enabled)
+ {
+ if ((m_MPI_Elem!=NULL))
+ cerr << "openEMS_FDTD_MPI::SetupMPI: Warning: Number of MPI processes is 1, skipping MPI engine... " << endl;
+ return openEMS::Parse_XML_FDTDSetup(FDTD_Opts);
+ }
+
+ if (m_MPI_Elem==NULL)
+ {
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (m_MyID==0)
+ cerr << "openEMS_FDTD_MPI::SetupMPI: Error: no MPI settings found, exiting MPI engine... " << endl;
+ exit(-1);
+ }
+
+ CSRectGrid* grid = m_CSX->GetGrid();
+ delete m_Original_Grid;
+ m_Original_Grid = CSRectGrid::Clone(grid);
+
+ string arg_Pos_Names[] = {"SplitPos_X", "SplitPos_Y", "SplitPos_Z"};
+ string arg_N_Names[] = {"SplitN_X", "SplitN_Y", "SplitN_Z"};
+ const char* tmp = NULL;
+ for (int n=0;n<3;++n)
+ {
+ m_SplitNumber[n].clear();
+ m_SplitNumber[n].push_back(0);
+ tmp = m_MPI_Elem->Attribute(arg_Pos_Names[n].c_str());
+ if (tmp) //check if a split position is requested
+ {
+ vector<double> SplitLines = SplitString2Double(tmp, ',');
+ bool inside;
+ unsigned int line;
+ for (size_t lineN = 0; lineN<SplitLines.size();++lineN)
+ {
+ line = m_Original_Grid->Snap2LineNumber(n, SplitLines.at(lineN), inside);
+ if (inside)
+ m_SplitNumber[n].push_back(line);
+ }
+ }
+ else //check if a number of splits is requested
+ {
+ int SplitN=0;
+ if (m_MPI_Elem->QueryIntAttribute( arg_N_Names[n].c_str(), &SplitN) == TIXML_SUCCESS)
+ {
+ if (SplitN>1)
+ {
+
+ vector<unsigned int> jobs = AssignJobs2Threads(m_Original_Grid->GetQtyLines(n)-1, SplitN, true);
+ unsigned int line=0;
+ for (size_t i = 0; i<jobs.size()-1;++i)
+ {
+ line += jobs.at(i);
+ m_SplitNumber[n].push_back(line);
+ }
+ }
+ }
+ }
+
+ m_SplitNumber[n].push_back(m_Original_Grid->GetQtyLines(n)-1);
+ unique(m_SplitNumber[n].begin(), m_SplitNumber[n].end());
+ }
+
+ return openEMS::Parse_XML_FDTDSetup(FDTD_Opts);
+}
+
+bool openEMS_FDTD_MPI::SetupMPI()
+{
+ if (!m_MPI_Enabled)
+ return true;
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ //validate number of processes
+ unsigned int numProcs = (m_SplitNumber[0].size()-1)*(m_SplitNumber[1].size()-1)*(m_SplitNumber[2].size()-1);
+ if (numProcs!=m_NumProc)
+ {
+ if (m_MyID==0)
+ cerr << "openEMS_FDTD_MPI::SetupMPI: Error: Requested splits require " << numProcs << " processes, but only " << m_NumProc << " were found! Exit! " << endl;
+ exit(10);
+ }
+
+ //create process table
+ unsigned int procN = 0;
+ unsigned int splits[] = {(unsigned int)m_SplitNumber[0].size()-1, (unsigned int)m_SplitNumber[1].size()-1, (unsigned int)m_SplitNumber[2].size()-1};
+ m_MPI_Op->SetSplitNumbers(0,splits[0]);
+ m_MPI_Op->SetSplitNumbers(1,splits[1]);
+ m_MPI_Op->SetSplitNumbers(2,splits[2]);
+ unsigned int*** procTable=Create3DArray<unsigned int>(splits);
+ for (size_t i=0;i<m_SplitNumber[0].size()-1;++i)
+ for (size_t j=0;j<m_SplitNumber[1].size()-1;++j)
+ for (size_t k=0;k<m_SplitNumber[2].size()-1;++k)
+ {
+ procTable[i][j][k] = procN;
+ ++procN;
+ }
+ m_MPI_Op->SetProcessTable(procTable);
+
+ CSRectGrid* grid = m_CSX->GetGrid();
+ //assign mesh and neighbors to this process
+ for (size_t i=0;i<m_SplitNumber[0].size()-1;++i)
+ {
+ for (size_t j=0;j<m_SplitNumber[1].size()-1;++j)
+ {
+ for (size_t k=0;k<m_SplitNumber[2].size()-1;++k)
+ {
+ if (procTable[i][j][k] == m_MyID)
+ {
+ m_MPI_Op->SetProcessTablePosition(0,i);
+ m_MPI_Op->SetProcessTablePosition(1,j);
+ m_MPI_Op->SetProcessTablePosition(2,k);
+
+ grid->ClearLines(0);
+ grid->ClearLines(1);
+ grid->ClearLines(2);
+
+ for (unsigned int n=m_SplitNumber[0].at(i);n<=m_SplitNumber[0].at(i+1);++n)
+ grid->AddDiscLine(0, m_Original_Grid->GetLine(0,n) );
+ for (unsigned int n=m_SplitNumber[1].at(j);n<=m_SplitNumber[1].at(j+1);++n)
+ grid->AddDiscLine(1, m_Original_Grid->GetLine(1,n) );
+ for (unsigned int n=m_SplitNumber[2].at(k);n<=m_SplitNumber[2].at(k+1);++n)
+ grid->AddDiscLine(2, m_Original_Grid->GetLine(2,n) );
+
+ m_MPI_Op->SetSplitPos(0,m_SplitNumber[0].at(i));
+ m_MPI_Op->SetSplitPos(1,m_SplitNumber[1].at(i));
+ m_MPI_Op->SetSplitPos(2,m_SplitNumber[2].at(i));
+
+ if (i>0)
+ m_MPI_Op->SetNeighborDown(0,procTable[i-1][j][k]);
+ if (i<m_SplitNumber[0].size()-2)
+ {
+ //add one additional line
+ grid->AddDiscLine(0, m_Original_Grid->GetLine(0,m_SplitNumber[0].at(i+1)+1 ));
+ m_MPI_Op->SetNeighborUp(0,procTable[i+1][j][k]);
+ }
+
+ if (j>0)
+ m_MPI_Op->SetNeighborDown(1,procTable[i][j-1][k]);
+ if (j<m_SplitNumber[1].size()-2)
+ {
+ //add one additional line
+ grid->AddDiscLine(1, m_Original_Grid->GetLine(1,m_SplitNumber[1].at(j+1)+1 ));
+ m_MPI_Op->SetNeighborUp(1,procTable[i][j+1][k]);
+ }
+
+ if (k>0)
+ m_MPI_Op->SetNeighborDown(2,procTable[i][j][k-1]);
+ if (k<m_SplitNumber[2].size()-2)
+ {
+ //add one additional line
+ grid->AddDiscLine(2, m_Original_Grid->GetLine(2,m_SplitNumber[2].at(k+1)+1 ));
+ m_MPI_Op->SetNeighborUp(2,procTable[i][j][k+1]);
+ }
+
+ }
+ }
+ }
+ }
+
+ m_MPI_Op->SetOriginalMesh(m_Original_Grid);
+
+ m_MPI_Op->SetTag(0);
+
+ return true;
+}
+
+
+bool openEMS_FDTD_MPI::SetupOperator()
+{
+ bool ret = true;
+ if (m_engine == EngineType_MPI)
+ {
+ FDTD_Op = Operator_MPI::New();
+ }
+ else
+ {
+ ret = openEMS::SetupOperator();
+ }
+
+ m_MPI_Op = dynamic_cast<Operator_MPI*>(FDTD_Op);
+
+ if ((m_MPI_Enabled) && (m_MPI_Op==NULL))
+ {
+ cerr << "openEMS_FDTD_MPI::SetupOperator: Error: MPI is enabled but requested engine does not support MPI... EXIT!!!" << endl;
+ MPI_Barrier(MPI_COMM_WORLD);
+ exit(0);
+ }
+
+ ret &= SetupMPI();
+
+ return ret;
+}
+
+unsigned int openEMS_FDTD_MPI::GetNextStep()
+{
+ //start processing and get local next step
+ int step=PA->Process();
+ double currTS = FDTD_Eng->GetNumberOfTimesteps();
+ if ((step<0) || (step>(int)(NrTS - currTS))) step=NrTS - currTS;
+
+ int local_step=step;
+
+ //find the smallest next step requestes by all processings
+ MPI_Reduce(&local_step, &step, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
+ //send the smallest next step to all
+ MPI_Bcast(&step, 1, MPI_INT, 0, MPI_COMM_WORLD);
+
+ return step;
+}
+
+bool openEMS_FDTD_MPI::CheckEnergyCalc()
+{
+ int local_Check = (int)m_ProcField->CheckTimestep();
+ int result;
+
+ //check if some process request an energy calculation --> the sum is larger than 0
+ MPI_Reduce(&local_Check, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
+ //send result to all
+ MPI_Bcast(&result, 1, MPI_INT, 0, MPI_COMM_WORLD);
+
+ //calc energy if result is non-zero
+ return result>0;
+}
+
+double openEMS_FDTD_MPI::CalcEnergy()
+{
+ double energy = 0;
+ double loc_energy= m_ProcField->CalcTotalEnergyEstimate();
+
+ //calc the sum of all local energies
+ MPI_Reduce(&loc_energy, &energy, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
+ //send sum-energy to all processes
+ MPI_Bcast(&energy, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
+
+ if (energy>m_MaxEnergy)
+ m_MaxEnergy = energy;
+ if (m_MaxEnergy)
+ m_EnergyDecrement = energy/m_MaxEnergy;
+
+ return energy;
+}
+
+bool openEMS_FDTD_MPI::SetupProcessing()
+{
+ bool ret = openEMS::SetupProcessing();
+
+ //search for active processings in different processes
+ size_t numProc = PA->GetNumberOfProcessings();
+ int active=0;
+ bool deactivate = false;
+ bool rename = false;
+ for (size_t n=0;n<numProc;++n)
+ {
+ Processing* proc = PA->GetProcessing(n);
+ int isActive = (int)proc->GetEnable();
+ //sum of all active processings
+ MPI_Reduce(&isActive, &active, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
+ deactivate = false;
+ rename = false;
+ if ((m_MyID==0) && (active>1)) //more than one active processing...
+ {
+ deactivate = true; //default
+ if (dynamic_cast<ProcessIntegral*>(proc)!=NULL)
+ {
+ //type is integral processing --> disable! Needs to be fixed!
+ cerr << "openEMS_FDTD_MPI::SetupProcessing(): Warning: Processing: " << proc->GetName() << " occures multiple times and is being deactivated..." << endl;
+ deactivate = true;
+ rename = false;
+ }
+ if (dynamic_cast<ProcessFields*>(proc)!=NULL)
+ {
+ //type is field processing --> renameing! Needs to be fixed!
+ cerr << "openEMS_FDTD_MPI::SetupProcessing(): Warning: Processing: " << proc->GetName() << " occures multiple times and is being renamed..." << endl;
+ deactivate = false;
+ rename = true;
+ }
+ }
+ //broadcast informations to all
+ MPI_Bcast(&deactivate, 1, MPI::BOOL, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&rename, 1, MPI::BOOL, 0, MPI_COMM_WORLD);
+ if (deactivate)
+ proc->SetEnable(false);
+ if (rename)
+ {
+ ProcessFields* ProcField = dynamic_cast<ProcessFields*>(proc);
+ if (ProcField)
+ {
+ stringstream name_ss;
+ name_ss << "ID" << m_MyID << "_" << ProcField->GetName();
+ ProcField->SetName(name_ss.str());
+ ProcField->SetFileName(name_ss.str());
+ }
+ }
+ }
+ return ret;
+}
+
+int openEMS_FDTD_MPI::SetupFDTD()
+{
+ return openEMS::SetupFDTD();
+}
+
+void openEMS_FDTD_MPI::RunFDTD()
+{
+ if (!m_MPI_Enabled)
+ return openEMS::RunFDTD();
+
+ cout << "Running MPI-FDTD engine... this may take a while... grab a cup of coffe