diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index 2156ab4..f1b7090 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -1064,14 +1064,14 @@ bool Operator::CalcPEC() { m_Nr_PEC[0]=0; m_Nr_PEC[1]=0; m_Nr_PEC[2]=0; - CalcPEC_Range(0,numLines[0]-1); + CalcPEC_Range(0,numLines[0]-1,m_Nr_PEC); CalcPEC_Curves(); return true; } -void Operator::CalcPEC_Range(unsigned int startX, unsigned int stopX) +void Operator::CalcPEC_Range(unsigned int startX, unsigned int stopX, unsigned int* counter) { double coord[3]; double delta; @@ -1087,7 +1087,6 @@ void Operator::CalcPEC_Range(unsigned int startX, unsigned int stopX) coord[0] = discLines[0][pos[0]]; coord[1] = discLines[1][pos[1]]; coord[2] = discLines[2][pos[2]]; - MainOp->SetPos(pos[0],pos[1],pos[2]); delta=MainOp->GetIndexDelta(n,pos[n]); coord[n]= discLines[n][pos[n]] + delta*0.5; CSProperties* prop = CSX->GetPropertyByCoordPriority(coord, (CSProperties::PropertyType)(CSProperties::MATERIAL | CSProperties::METAL)); @@ -1097,7 +1096,7 @@ void Operator::CalcPEC_Range(unsigned int startX, unsigned int stopX) { GetVV(n,pos[0],pos[1],pos[2]) = 0; GetVI(n,pos[0],pos[1],pos[2]) = 0; - ++m_Nr_PEC[n]; + ++counter[n]; // cerr << "CartOperator::CalcPEC: PEC found at " << pos[0] << " ; " << pos[1] << " ; " << pos[2] << endl; } } diff --git a/FDTD/operator.h b/FDTD/operator.h index 8b5cddd..99fa4d6 100644 --- a/FDTD/operator.h +++ b/FDTD/operator.h @@ -106,8 +106,9 @@ protected: //! Calculate the field excitations. virtual bool CalcFieldExcitation(); + unsigned int m_Nr_PEC[3]; //count PEC edges virtual bool CalcPEC(); - virtual void CalcPEC_Range(unsigned int startX, unsigned int stopX); //internal to CalcPEC + virtual void CalcPEC_Range(unsigned int startX, unsigned int stopX, unsigned int* counter); //internal to CalcPEC virtual void CalcPEC_Curves(); //internal to CalcPEC //Calc timestep only internal use @@ -127,8 +128,6 @@ protected: double* EC_L[3]; double* EC_R[3]; - unsigned int m_Nr_PEC[3]; - int m_MeshType; unsigned int numLines[3]; double* discLines[3]; diff --git a/FDTD/operator_multithread.cpp b/FDTD/operator_multithread.cpp index 6acecba..1b8daff 100644 --- a/FDTD/operator_multithread.cpp +++ b/FDTD/operator_multithread.cpp @@ -46,6 +46,9 @@ Operator_Multithread::Operator_Multithread() { m_CalcEC_Start=NULL; m_CalcEC_Stop=NULL; + + m_CalcPEC_Start=NULL; + m_CalcPEC_Stop=NULL; } void Operator_Multithread::Init() @@ -53,6 +56,9 @@ void Operator_Multithread::Init() Operator_SSE_Compressed::Init(); m_CalcEC_Start=NULL; m_CalcEC_Stop=NULL; + + m_CalcPEC_Start=NULL; + m_CalcPEC_Stop=NULL; } void Operator_Multithread::Reset() @@ -63,6 +69,9 @@ void Operator_Multithread::Reset() delete m_CalcEC_Start;m_CalcEC_Start=NULL; delete m_CalcEC_Stop;m_CalcEC_Stop=NULL; + + delete m_CalcPEC_Start;m_CalcPEC_Start=NULL; + delete m_CalcPEC_Stop;m_CalcPEC_Stop=NULL; } int Operator_Multithread::CalcECOperator() @@ -76,6 +85,9 @@ int Operator_Multithread::CalcECOperator() delete m_CalcEC_Start;m_CalcEC_Start = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller delete m_CalcEC_Stop;m_CalcEC_Stop = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller + delete m_CalcPEC_Start;m_CalcPEC_Start = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller + delete m_CalcPEC_Stop;m_CalcPEC_Stop = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller + unsigned int linesPerThread = round((float)numLines[0] / (float)m_numThreads); for (unsigned int n=0; nwait(); + + m_CalcPEC_Stop->wait(); + + for (unsigned int t=0;tm_CalcEC_Stop->wait(); + + //************** calculate EC (Calc_EC) ***********************// + m_OpPtr->m_CalcPEC_Start->wait(); + for (int n=0;n<3;++n) + m_OpPtr->m_Nr_PEC_thread[m_threadID][n] = 0; + + m_OpPtr->CalcPEC_Range(m_start,m_stop,m_OpPtr->m_Nr_PEC_thread[m_threadID]); + m_OpPtr->m_CalcPEC_Stop->wait(); } diff --git a/FDTD/operator_multithread.h b/FDTD/operator_multithread.h index 896753c..ddc17af 100644 --- a/FDTD/operator_multithread.h +++ b/FDTD/operator_multithread.h @@ -43,8 +43,16 @@ protected: virtual bool Calc_EC(); //this method is using multi-threading + unsigned int (*m_Nr_PEC_thread)[3]; //count PEC edges per thread + virtual bool CalcPEC(); //this method is using multi-threading + + //Calc_EC barrier boost::barrier* m_CalcEC_Start; boost::barrier* m_CalcEC_Stop; + //CalcPEC barrier + boost::barrier* m_CalcPEC_Start; + boost::barrier* m_CalcPEC_Stop; + boost::thread_group m_thread_group; unsigned int m_numThreads; // number of worker threads };