engine: update handling extensions & multithreading priority handling fixed
This commit is contained in:
parent
8f4f9729a4
commit
fb3ccd36bf
@ -212,34 +212,59 @@ void Engine::ApplyCurrentExcite()
|
||||
file_ht << (numTS+0.5) * Op->GetTimestep() << "\t" << Op->Exc->Signal_curr[numTS] << "\n"; // do not use std::endl here, because it will do an implicit flush
|
||||
}
|
||||
|
||||
void Engine::DoPreVoltageUpdates()
|
||||
{
|
||||
for (int n=m_Eng_exts.size()-1;n>=0;--n)
|
||||
m_Eng_exts.at(n)->DoPreVoltageUpdates();
|
||||
|
||||
}
|
||||
|
||||
void Engine::DoPostVoltageUpdates()
|
||||
{
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPostVoltageUpdates();
|
||||
}
|
||||
|
||||
void Engine::Apply2Voltages()
|
||||
{
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->Apply2Voltages();
|
||||
}
|
||||
|
||||
void Engine::DoPreCurrentUpdates()
|
||||
{
|
||||
for (int n=m_Eng_exts.size()-1;n>=0;--n)
|
||||
m_Eng_exts.at(n)->DoPreCurrentUpdates();
|
||||
}
|
||||
|
||||
void Engine::DoPostCurrentUpdates()
|
||||
{
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPostCurrentUpdates();
|
||||
}
|
||||
|
||||
void Engine::Apply2Current()
|
||||
{
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->Apply2Current();
|
||||
}
|
||||
|
||||
bool Engine::IterateTS(unsigned int iterTS)
|
||||
{
|
||||
for (unsigned int iter=0;iter<iterTS;++iter)
|
||||
{
|
||||
//voltage updates with extensions
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPreVoltageUpdates();
|
||||
|
||||
DoPreVoltageUpdates();
|
||||
UpdateVoltages(0,numLines[0]);
|
||||
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPostVoltageUpdates();
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->Apply2Voltages();
|
||||
|
||||
DoPostVoltageUpdates();
|
||||
Apply2Voltages();
|
||||
ApplyVoltageExcite();
|
||||
|
||||
//current updates with extensions
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPreCurrentUpdates();
|
||||
|
||||
DoPreCurrentUpdates();
|
||||
UpdateCurrents(0,numLines[0]-1);
|
||||
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPostCurrentUpdates();
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->Apply2Current();
|
||||
|
||||
DoPostCurrentUpdates();
|
||||
Apply2Current();
|
||||
ApplyCurrentExcite();
|
||||
|
||||
++numTS;
|
||||
|
@ -62,6 +62,14 @@ public:
|
||||
virtual void UpdateCurrents(unsigned int startX, unsigned int numX);
|
||||
virtual void ApplyCurrentExcite();
|
||||
|
||||
virtual void DoPreVoltageUpdates();
|
||||
virtual void DoPostVoltageUpdates();
|
||||
virtual void Apply2Voltages();
|
||||
|
||||
virtual void DoPreCurrentUpdates();
|
||||
virtual void DoPostCurrentUpdates();
|
||||
virtual void Apply2Current();
|
||||
|
||||
inline size_t GetExtensionCount() {return m_Eng_exts.size();}
|
||||
inline Engine_Extension* GetExtension(size_t nr) {return m_Eng_exts.at(nr);}
|
||||
virtual void SortExtensionByPriority();
|
||||
|
@ -207,8 +207,8 @@ void thread::operator()()
|
||||
for (unsigned int iter=0;iter<m_enginePtr->m_iterTS;++iter)
|
||||
{
|
||||
// pre voltage stuff...
|
||||
for (size_t n=m_threadID;n<m_enginePtr->GetExtensionCount();n+=m_enginePtr->m_numThreads)
|
||||
m_enginePtr->GetExtension(n)->DoPreVoltageUpdates();
|
||||
if (m_threadID==0)
|
||||
m_enginePtr->DoPreVoltageUpdates();
|
||||
|
||||
m_enginePtr->m_barrier_PreVolt->wait();
|
||||
|
||||
@ -225,8 +225,11 @@ void thread::operator()()
|
||||
DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
|
||||
|
||||
//post voltage stuff...
|
||||
for (size_t n=m_threadID;n<m_enginePtr->GetExtensionCount();n+=m_enginePtr->m_numThreads)
|
||||
m_enginePtr->GetExtension(n)->DoPostVoltageUpdates();
|
||||
if (m_threadID==0)
|
||||
{
|
||||
m_enginePtr->DoPostVoltageUpdates();
|
||||
m_enginePtr->Apply2Voltages();
|
||||
}
|
||||
m_enginePtr->m_barrier_PostVolt->wait();
|
||||
|
||||
// e-field excitation (thread thread_e_excitation)
|
||||
@ -237,8 +240,8 @@ void thread::operator()()
|
||||
DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
|
||||
|
||||
//pre current stuff
|
||||
for (size_t n=m_threadID;n<m_enginePtr->GetExtensionCount();n+=m_enginePtr->m_numThreads)
|
||||
m_enginePtr->GetExtension(n)->DoPreCurrentUpdates();
|
||||
if (m_threadID==0)
|
||||
m_enginePtr->DoPreCurrentUpdates();
|
||||
m_enginePtr->m_barrier_PreCurr->wait();
|
||||
|
||||
//current updates
|
||||
@ -252,8 +255,11 @@ void thread::operator()()
|
||||
DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
|
||||
|
||||
//post current stuff
|
||||
for (size_t n=m_threadID;n<m_enginePtr->GetExtensionCount();n+=m_enginePtr->m_numThreads)
|
||||
m_enginePtr->GetExtension(n)->DoPostCurrentUpdates();
|
||||
if (m_threadID==0)
|
||||
{
|
||||
m_enginePtr->DoPostCurrentUpdates();
|
||||
m_enginePtr->Apply2Current();
|
||||
}
|
||||
m_enginePtr->m_barrier_PostCurr->wait();
|
||||
|
||||
//soft current excitation here (H-field excite)
|
||||
@ -291,19 +297,12 @@ void thread_e_excitation::operator()()
|
||||
{
|
||||
m_enginePtr->m_barrier_PostVolt->wait(); // waiting on NS_Engine_Multithread::thread
|
||||
|
||||
for (size_t n=0;n<m_enginePtr->GetExtensionCount();++n)
|
||||
m_enginePtr->GetExtension(n)->Apply2Voltages();
|
||||
|
||||
m_enginePtr->ApplyVoltageExcite();
|
||||
|
||||
m_enginePtr->m_barrier_VoltExcite->wait(); // continue NS_Engine_Multithread::thread
|
||||
|
||||
|
||||
m_enginePtr->m_barrier_PostCurr->wait(); // waiting on NS_Engine_Multithread::thread
|
||||
|
||||
for (size_t n=0;n<m_enginePtr->GetExtensionCount();++n)
|
||||
m_enginePtr->GetExtension(n)->Apply2Current();
|
||||
|
||||
m_enginePtr->ApplyCurrentExcite();
|
||||
|
||||
m_enginePtr->m_barrier_CurrExcite->wait(); // continue NS_Engine_Multithread::thread
|
||||
|
Loading…
Reference in New Issue
Block a user