From 8870a207874a2adce802fbafdd901509f099ef09 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Wed, 22 Sep 2010 16:08:39 +0200 Subject: [PATCH] fixed extensions handling for cylindrical multigrid --- FDTD/operator_cylindermultigrid.cpp | 18 ++++++++++-------- FDTD/operator_ext_cylinder.h | 2 +- FDTD/operator_extension.h | 4 +++- tools/global.h | 2 ++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/FDTD/operator_cylindermultigrid.cpp b/FDTD/operator_cylindermultigrid.cpp index b02b106..8edd06b 100644 --- a/FDTD/operator_cylindermultigrid.cpp +++ b/FDTD/operator_cylindermultigrid.cpp @@ -195,16 +195,20 @@ void Operator_CylinderMultiGrid::SetBoundaryCondition(int* BCs) void Operator_CylinderMultiGrid::AddExtension(Operator_Extension* op_ext) { - if (dynamic_cast(op_ext)) + //check whether extension is save to use in multi-grid + if (op_ext->IsCylindricalMultiGridSave(false)==false) { - if (op_ext->IsCylindricalMultiGridSave(false)==false) - return; - else - cerr << "Operator_CylinderMultiGrid::AddExtension: Warning: Operator extension \"" << op_ext->GetExtensionName() << "\" is not compatible with cylindrical multi-grids!! skipping...!" << endl; - Operator_Cylinder::AddExtension(op_ext); + cerr << "Operator_CylinderMultiGrid::AddExtension: Warning: Operator extension \"" << op_ext->GetExtensionName() << "\" is not compatible with cylindrical multi-grids!! skipping...!" << endl; return; } + Operator_Cylinder::AddExtension(op_ext); + + // cylinder extension does not need to be cloned, it will be created by each operator of its own... + if (dynamic_cast(op_ext)) + return; + + //check whether extension is save to use in child multi-grid if (op_ext->IsCylindricalMultiGridSave(true)) { Operator_Extension* child_Ext = op_ext->Clone(m_InnerOp); @@ -216,8 +220,6 @@ void Operator_CylinderMultiGrid::AddExtension(Operator_Extension* op_ext) //give the copy to child m_InnerOp->AddExtension(child_Ext); } - - Operator_Cylinder::AddExtension(op_ext); } void Operator_CylinderMultiGrid::ShowStat() const diff --git a/FDTD/operator_ext_cylinder.h b/FDTD/operator_ext_cylinder.h index 188e9b6..9da72ae 100644 --- a/FDTD/operator_ext_cylinder.h +++ b/FDTD/operator_ext_cylinder.h @@ -35,7 +35,7 @@ public: virtual Engine_Extension* CreateEngineExtention(); virtual bool IsCylinderCoordsSave() const {return true;} - virtual bool IsCylindricalMultiGridChildSave(bool child) const {UNUSED(child);return true;} + virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child);return true;} virtual std::string GetExtensionName() const {return std::string("Extension for the Cylinder-Coords Operator");} diff --git a/FDTD/operator_extension.h b/FDTD/operator_extension.h index 6e6950c..cbe4b26 100644 --- a/FDTD/operator_extension.h +++ b/FDTD/operator_extension.h @@ -24,6 +24,8 @@ #include #include +#include "tools/global.h" + using namespace std; class Operator; @@ -49,7 +51,7 @@ public: virtual bool IsCylinderCoordsSave() const {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 {return false;} + virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child);return false;} virtual std::string GetExtensionName() const {return std::string("Abstract Operator Extension Base Class");} diff --git a/tools/global.h b/tools/global.h index cb6a133..b56a6dd 100644 --- a/tools/global.h +++ b/tools/global.h @@ -20,6 +20,8 @@ #include +#define UNUSED(x) (void)(x); + class Global { public: