From 92d60b32045800b61644866afbb8a77fd3d8668a Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 14 Mar 2011 10:37:12 +0100 Subject: [PATCH] fix in cylindrical multigrids: check for valid number of subgrids --- FDTD/operator_cylindermultigrid.cpp | 5 +++++ FDTD/operator_cylindermultigrid.h | 2 ++ openems.cpp | 2 ++ 3 files changed, 9 insertions(+) diff --git a/FDTD/operator_cylindermultigrid.cpp b/FDTD/operator_cylindermultigrid.cpp index e78e4d7..5483567 100644 --- a/FDTD/operator_cylindermultigrid.cpp +++ b/FDTD/operator_cylindermultigrid.cpp @@ -34,6 +34,11 @@ Operator_CylinderMultiGrid::~Operator_CylinderMultiGrid() Operator_CylinderMultiGrid* Operator_CylinderMultiGrid::New(vector Split_Radii, unsigned int numThreads) { + if ((Split_Radii.size()==0) || (Split_Radii.size()>CYLIDINDERMULTIGRID_LIMIT)) + { + cerr << "Operator_CylinderMultiGrid::New: Warning: Number of multigrids invalid! Split-Number: " << Split_Radii.size() << endl; + return NULL; + } cout << "Create cylindrical multi grid FDTD operator " << endl; Operator_CylinderMultiGrid* op = new Operator_CylinderMultiGrid(Split_Radii); op->setNumThreads(numThreads); diff --git a/FDTD/operator_cylindermultigrid.h b/FDTD/operator_cylindermultigrid.h index 6e7a147..ade2c82 100644 --- a/FDTD/operator_cylindermultigrid.h +++ b/FDTD/operator_cylindermultigrid.h @@ -18,6 +18,8 @@ #ifndef OPERATOR_CYLINDERMULTIGRID_H #define OPERATOR_CYLINDERMULTIGRID_H +#define CYLIDINDERMULTIGRID_LIMIT 20 + #include "operator_cylinder.h" //! This is a cylindrical FDTD operator using a simple multi-grid approach. diff --git a/openems.cpp b/openems.cpp index 14849aa..a31e07b 100644 --- a/openems.cpp +++ b/openems.cpp @@ -457,6 +457,8 @@ bool openEMS::SetupOperator(TiXmlElement* FDTD_Opts) { string rad(radii); FDTD_Op = Operator_CylinderMultiGrid::New(SplitString2Double(rad,','),m_engine_numThreads); + if (FDTD_Op==NULL) + FDTD_Op = Operator_Cylinder::New(m_engine_numThreads); } else FDTD_Op = Operator_Cylinder::New(m_engine_numThreads);