diff --git a/FDTD/extensions/operator_ext_conductingsheet.h b/FDTD/extensions/operator_ext_conductingsheet.h index 9a7d12d..f84dc4b 100644 --- a/FDTD/extensions/operator_ext_conductingsheet.h +++ b/FDTD/extensions/operator_ext_conductingsheet.h @@ -38,6 +38,7 @@ public: 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");} diff --git a/FDTD/extensions/operator_ext_cylinder.h b/FDTD/extensions/operator_ext_cylinder.h index 6ec07ff..c8dff2d 100644 --- a/FDTD/extensions/operator_ext_cylinder.h +++ b/FDTD/extensions/operator_ext_cylinder.h @@ -38,6 +38,9 @@ public: 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; diff --git a/FDTD/extensions/operator_ext_excitation.h b/FDTD/extensions/operator_ext_excitation.h index 9757c41..2abcef0 100644 --- a/FDTD/extensions/operator_ext_excitation.h +++ b/FDTD/extensions/operator_ext_excitation.h @@ -40,6 +40,7 @@ public: 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");} diff --git a/FDTD/extensions/operator_ext_lorentzmaterial.h b/FDTD/extensions/operator_ext_lorentzmaterial.h index 37d9b1a..b5e6e4c 100644 --- a/FDTD/extensions/operator_ext_lorentzmaterial.h +++ b/FDTD/extensions/operator_ext_lorentzmaterial.h @@ -36,6 +36,7 @@ public: 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");} diff --git a/FDTD/extensions/operator_ext_mur_abc.h b/FDTD/extensions/operator_ext_mur_abc.h index 8ffb444..ddc43c1 100644 --- a/FDTD/extensions/operator_ext_mur_abc.h +++ b/FDTD/extensions/operator_ext_mur_abc.h @@ -42,6 +42,7 @@ public: 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");} diff --git a/FDTD/extensions/operator_ext_tfsf.h b/FDTD/extensions/operator_ext_tfsf.h index 61e1f03..ff6f372 100644 --- a/FDTD/extensions/operator_ext_tfsf.h +++ b/FDTD/extensions/operator_ext_tfsf.h @@ -40,6 +40,9 @@ public: 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; diff --git a/FDTD/extensions/operator_ext_upml.h b/FDTD/extensions/operator_ext_upml.h index d865408..5256655 100644 --- a/FDTD/extensions/operator_ext_upml.h +++ b/FDTD/extensions/operator_ext_upml.h @@ -41,6 +41,8 @@ public: //! 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]); diff --git a/FDTD/extensions/operator_extension.h b/FDTD/extensions/operator_extension.h index 794a15b..da20658 100644 --- a/FDTD/extensions/operator_extension.h +++ b/FDTD/extensions/operator_extension.h @@ -56,6 +56,9 @@ public: //! 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 string GetExtensionName() const {return string("Abstract Operator Extension Base Class");} virtual void ShowStat(ostream &ostr) const; diff --git a/FDTD/operator_mpi.cpp b/FDTD/operator_mpi.cpp index e79120e..12486e4 100644 --- a/FDTD/operator_mpi.cpp +++ b/FDTD/operator_mpi.cpp @@ -19,6 +19,7 @@ #include "operator_sse_compressed.h" #include "engine_sse_compressed.h" #include "engine_mpi.h" +#include "extensions/operator_extension.h" #include "tools/array_ops.h" #include "tools/useful.h" #include "mpi.h" @@ -163,6 +164,21 @@ unsigned int Operator_MPI::GetNumberOfLines(int ny) const return Operator_SSE_Compressed::GetNumberOfLines(ny)-1; } +void Operator_MPI::AddExtension(Operator_Extension* op_ext) +{ + if (m_MPI_Enabled==false) + return Operator_SSE_Compressed::AddExtension(op_ext); + + if (op_ext->IsMPISave()) + Operator_SSE_Compressed::AddExtension(op_ext); + else + { + delete op_ext; + cerr << "Operator_MPI::AddExtension: Warning: Operator extension \"" << op_ext->GetExtensionName() << "\" is not compatible with MPI!! skipping...!" << endl; + } +} + + string Operator_MPI::PrependRank(string name) { stringstream out_name; diff --git a/FDTD/operator_mpi.h b/FDTD/operator_mpi.h index 9f2e2c3..341c6a6 100644 --- a/FDTD/operator_mpi.h +++ b/FDTD/operator_mpi.h @@ -52,6 +52,8 @@ public: virtual unsigned int GetNumberOfLines(int ny) const; + virtual void AddExtension(Operator_Extension* op_ext); + protected: Operator_MPI(); bool m_MPI_Enabled;