From a607bc6969cb317438bf14db26461522d25eb5f3 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Wed, 15 May 2013 16:02:30 +0200 Subject: [PATCH] more options to setup SAR averaging method Signed-off-by: Thorsten Liebig --- Common/processfields_sar.cpp | 8 ++++---- Common/processfields_sar.h | 4 ++++ openems.cpp | 8 +++++++- tools/sar_calculation.cpp | 32 +++++++++++++++++++++++++++----- tools/sar_calculation.h | 5 ++++- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Common/processfields_sar.cpp b/Common/processfields_sar.cpp index e6b3a18..7dc884e 100644 --- a/Common/processfields_sar.cpp +++ b/Common/processfields_sar.cpp @@ -26,6 +26,7 @@ ProcessFieldsSAR::ProcessFieldsSAR(Engine_Interface_Base* eng_if) : ProcessFieldsFD(eng_if) { m_UseCellKappa = false; + m_SAR_method = "Simple"; } ProcessFieldsSAR::~ProcessFieldsSAR() @@ -48,9 +49,7 @@ void ProcessFieldsSAR::SetDumpType(DumpType type) bool ProcessFieldsSAR::NeedConductivity() const { - if (m_UseCellKappa) - return false; - return true; + return !m_UseCellKappa; } void ProcessFieldsSAR::SetSubSampling(unsigned int subSampleRate, int dir) @@ -270,6 +269,7 @@ void ProcessFieldsSAR::DumpFDData() else { SAR_Calculation SAR_Calc; + SAR_Calc.SetAveragingMethod(m_SAR_method); SAR_Calc.SetDebugLevel(g_settings.GetVerboseLevel()); SAR_Calc.SetNumLines(numLines); if (m_DumpType == SAR_LOCAL_DUMP) @@ -285,7 +285,7 @@ void ProcessFieldsSAR::DumpFDData() SAR_Calc.SetCellDensities(cell_density); SAR_Calc.SetCellWidth(cellWidth); SAR_Calc.SetCellVolumes(cell_volume); - SAR_Calc.SetCellCondictivity(cell_kappa); + SAR_Calc.SetCellCondictivity(cell_kappa); // cell_kappa will be NULL if m_UseCellKappa is false for (size_t n = 0; n****> m_E_FD_Fields; //! frequency domain current density storage diff --git a/openems.cpp b/openems.cpp index f9f295a..d930db8 100644 --- a/openems.cpp +++ b/openems.cpp @@ -435,7 +435,13 @@ bool openEMS::SetupProcessing() else if ((db->GetDumpType()>=10) && (db->GetDumpType()<=13)) ProcField = new ProcessFieldsFD(NewEngineInterface()); else if ( ((db->GetDumpType()>=20) && (db->GetDumpType()<=22)) || (db->GetDumpType()==29) ) - ProcField = new ProcessFieldsSAR(NewEngineInterface()); + { + ProcessFieldsSAR* procSAR = new ProcessFieldsSAR(NewEngineInterface()); + ProcField = procSAR; + string method = db->GetAttributeValue("SAR_Method"); + if (!method.empty()) + procSAR->SetSARAveragingMethod(method); + } else cerr << "openEMS::SetupFDTD: unknown dump box type... skipping!" << endl; if (ProcField) diff --git a/tools/sar_calculation.cpp b/tools/sar_calculation.cpp index de0a89c..0f9e296 100644 --- a/tools/sar_calculation.cpp +++ b/tools/sar_calculation.cpp @@ -19,13 +19,14 @@ #include "sar_calculation.h" #include "cfloat" #include "array_ops.h" +#include "global.h" SAR_Calculation::SAR_Calculation() { m_Vx_Used = NULL; m_Vx_Valid = NULL; m_DebugLevel = 0; - SetAveragingMethod(SIMPLE); + SetAveragingMethod(SIMPLE, true); Reset(); } @@ -52,9 +53,23 @@ void SAR_Calculation::Reset() m_Vx_Valid = NULL; } -void SAR_Calculation::SetAveragingMethod(SARAveragingMethod method) +void SAR_Calculation::SetAveragingMethod(string method, bool silent) { - if (method==IEEE_C95_3) + if (method.compare("IEEE_C95_3")==0) + return SetAveragingMethod(IEEE_C95_3, silent); + if (method.compare("IEEE_62704")==0) + return SetAveragingMethod(IEEE_62704, silent); + if (method.compare("SIMPLE")==0) + return SetAveragingMethod(SIMPLE, silent); + + cerr << __func__ << ": Error, """ << method << """ is an unknown averaging method..." << endl; + // unknown method, fallback to simple + SetAveragingMethod(SIMPLE, false); +} + +void SAR_Calculation::SetAveragingMethod(SARAveragingMethod method, bool silent) +{ + if (method==IEEE_62704) { m_massTolerance = 0.0001; m_maxMassIterations = 100; @@ -62,9 +77,11 @@ void SAR_Calculation::SetAveragingMethod(SARAveragingMethod method) m_markPartialAsUsed = false; m_UnusedRelativeVolLimit = 1.05; m_IgnoreFaceValid = false; + if (!silent) + cerr << __func__ << ": Setting averaging method to IEEE_62704" << endl; return; } - else if (method==IEEE_62704) + else if (method==IEEE_C95_3) { m_massTolerance = 0.05; m_maxMassIterations = 100; @@ -72,6 +89,8 @@ void SAR_Calculation::SetAveragingMethod(SARAveragingMethod method) m_markPartialAsUsed = true; m_UnusedRelativeVolLimit = 1; m_IgnoreFaceValid = false; + if (!silent) + cerr << __func__ << ": Setting averaging method to IEEE_C95_3" << endl; return; } else if (method==SIMPLE) @@ -82,11 +101,14 @@ void SAR_Calculation::SetAveragingMethod(SARAveragingMethod method) m_markPartialAsUsed = true; m_UnusedRelativeVolLimit = 1; m_IgnoreFaceValid = true; + if (!silent) + cerr << __func__ << ": Setting averaging method to SIMPLE" << endl; return; } + cerr << __func__ << ": Error, unknown averaging method..." << endl; // unknown method, fallback to simple - SetAveragingMethod(SIMPLE); + SetAveragingMethod(SIMPLE, false); } void SAR_Calculation::SetNumLines(unsigned int numLines[3]) diff --git a/tools/sar_calculation.h b/tools/sar_calculation.h index 48b6890..58d9ab8 100644 --- a/tools/sar_calculation.h +++ b/tools/sar_calculation.h @@ -34,7 +34,10 @@ public: void SetDebugLevel(int level) {m_DebugLevel=level;} //! Set the used averaging method - void SetAveragingMethod(SARAveragingMethod method); + void SetAveragingMethod(SARAveragingMethod method, bool silent=false); + + //! Set the used averaging method + void SetAveragingMethod(std::string method, bool silent=false); //! Set number of lines in all direcitions. (mandatory information) void SetNumLines(unsigned int numLines[3]);