From 77cae6185ee0a8ac2916eacd19de153ae3cb225a Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 28 Mar 2011 10:38:48 +0200 Subject: [PATCH] MPI: added closed cylinder operator support --- FDTD/extensions/operator_ext_cylinder.cpp | 2 +- FDTD/operator_cylinder.cpp | 36 ++++++++++++++++++++++- FDTD/operator_cylinder.h | 5 ++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/FDTD/extensions/operator_ext_cylinder.cpp b/FDTD/extensions/operator_ext_cylinder.cpp index 13f48d5..a7e9a1d 100644 --- a/FDTD/extensions/operator_ext_cylinder.cpp +++ b/FDTD/extensions/operator_ext_cylinder.cpp @@ -47,7 +47,7 @@ bool Operator_Ext_Cylinder::BuildExtension() //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) || (CC_closedAlpha==false)) + if (CC_R0_included==false) return true; vv_R0 = new FDTD_FLOAT[m_Op->GetOriginalNumLines(2)]; diff --git a/FDTD/operator_cylinder.cpp b/FDTD/operator_cylinder.cpp index 392c391..97accd6 100644 --- a/FDTD/operator_cylinder.cpp +++ b/FDTD/operator_cylinder.cpp @@ -209,6 +209,7 @@ bool Operator_Cylinder::SetupCSXGrid(CSRectGrid* grid) CC_closedAlpha=false; } + CC_R0_included = false; if (grid->GetLine(0,0)<0) { cerr << "Operator_Cylinder::SetupCSXGrid: r<0 not allowed in Cylinder Coordinates!!!" << endl; @@ -218,9 +219,42 @@ bool Operator_Cylinder::SetupCSXGrid(CSRectGrid* grid) else if (grid->GetLine(0,0)==0.0) { cout << "Operator_Cylinder::SetupCSXGrid: r=0 included..." << endl; - CC_R0_included= true; //also needed for correct ec-calculation + CC_R0_included = CC_closedAlpha; //needed for correct ec-calculation, deactivate if closed cylinder is false... --> E_r = 0 anyways } +#ifdef MPI_SUPPORT + // Setup an MPI split in alpha direction for a closed cylinder + CC_MPI_Alpha = false; + if ((m_NeighborUp[1]>=0) || (m_NeighborDown[1]>=0)) //check for MPI split in alpha direction + { + double minmaxA = 2*PI;// fabs(m_OrigDiscLines[1][m_OrigNumLines[1]-1]-m_OrigDiscLines[1][0]); + if (fabs(minmaxA-2*PI) < OPERATOR_CYLINDER_CLOSED_ALPHA_THRESHOLD) //check for closed alpha MPI split + { + CC_MPI_Alpha = true; + if (m_OrigDiscLines[0][0]==0) + { + cerr << "Operator_Cylinder::SetupCSXGrid: Error: MPI split in alpha direction for closed cylinder including r==0 is currently not supported! Exit!" << endl; + exit(-2); + } + + if (m_NeighborUp[1]<0) //check if this process is at the alpha-end + { + grid->SetLine(1,alphaNum-1,2*PI+m_OrigDiscLines[1][0]); + grid->AddDiscLine(1,2*PI+m_OrigDiscLines[1][1]); + + SetNeighborUp(1,m_ProcTable[m_ProcTablePos[0]][0][m_ProcTablePos[2]]); + } + + if (m_NeighborDown[1]<0) //check if this process is at the alpha-start + { + SetNeighborDown(1,m_ProcTable[m_ProcTablePos[0]][m_SplitNumber[1]-1][m_ProcTablePos[2]]); + } + + //Note: the process table will not reflect this up/down neighbors necessary for a closed cylinder + } + } +#endif + if (Operator_Multithread::SetupCSXGrid(grid)==false) return false; diff --git a/FDTD/operator_cylinder.h b/FDTD/operator_cylinder.h index 56d2807..8c5a9d2 100644 --- a/FDTD/operator_cylinder.h +++ b/FDTD/operator_cylinder.h @@ -30,6 +30,7 @@ all special cases e.g. a closed alpha mesh or an included r=0 case is treated by class Operator_Cylinder : public Operator_Multithread { friend class Operator_CylinderMultiGrid; + friend class Operator_Ext_Cylinder; public: static Operator_Cylinder* New(unsigned int numThreads = 0); virtual ~Operator_Cylinder(); @@ -86,6 +87,10 @@ protected: bool CC_closedAlpha; bool CC_R0_included; + +#ifdef MPI_SUPPORT + bool CC_MPI_Alpha; +#endif }; #endif // OPERATOR_CYLINDER_H