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
|
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)
|
bool Engine::IterateTS(unsigned int iterTS)
|
||||||
{
|
{
|
||||||
for (unsigned int iter=0;iter<iterTS;++iter)
|
for (unsigned int iter=0;iter<iterTS;++iter)
|
||||||
{
|
{
|
||||||
//voltage updates with extensions
|
//voltage updates with extensions
|
||||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
DoPreVoltageUpdates();
|
||||||
m_Eng_exts.at(n)->DoPreVoltageUpdates();
|
|
||||||
|
|
||||||
UpdateVoltages(0,numLines[0]);
|
UpdateVoltages(0,numLines[0]);
|
||||||
|
DoPostVoltageUpdates();
|
||||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
Apply2Voltages();
|
||||||
m_Eng_exts.at(n)->DoPostVoltageUpdates();
|
|
||||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
|
||||||
m_Eng_exts.at(n)->Apply2Voltages();
|
|
||||||
|
|
||||||
ApplyVoltageExcite();
|
ApplyVoltageExcite();
|
||||||
|
|
||||||
//current updates with extensions
|
//current updates with extensions
|
||||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
DoPreCurrentUpdates();
|
||||||
m_Eng_exts.at(n)->DoPreCurrentUpdates();
|
|
||||||
|
|
||||||
UpdateCurrents(0,numLines[0]-1);
|
UpdateCurrents(0,numLines[0]-1);
|
||||||
|
DoPostCurrentUpdates();
|
||||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
Apply2Current();
|
||||||
m_Eng_exts.at(n)->DoPostCurrentUpdates();
|
|
||||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
|
||||||
m_Eng_exts.at(n)->Apply2Current();
|
|
||||||
|
|
||||||
ApplyCurrentExcite();
|
ApplyCurrentExcite();
|
||||||
|
|
||||||
++numTS;
|
++numTS;
|
||||||
|
@ -62,6 +62,14 @@ public:
|
|||||||
virtual void UpdateCurrents(unsigned int startX, unsigned int numX);
|
virtual void UpdateCurrents(unsigned int startX, unsigned int numX);
|
||||||
virtual void ApplyCurrentExcite();
|
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 size_t GetExtensionCount() {return m_Eng_exts.size();}
|
||||||
inline Engine_Extension* GetExtension(size_t nr) {return m_Eng_exts.at(nr);}
|
inline Engine_Extension* GetExtension(size_t nr) {return m_Eng_exts.at(nr);}
|
||||||
virtual void SortExtensionByPriority();
|
virtual void SortExtensionByPriority();
|
||||||
|
@ -207,8 +207,8 @@ void thread::operator()()
|
|||||||
for (unsigned int iter=0;iter<m_enginePtr->m_iterTS;++iter)
|
for (unsigned int iter=0;iter<m_enginePtr->m_iterTS;++iter)
|
||||||
{
|
{
|
||||||
// pre voltage stuff...
|
// pre voltage stuff...
|
||||||
for (size_t n=m_threadID;n<m_enginePtr->GetExtensionCount();n+=m_enginePtr->m_numThreads)
|
if (m_threadID==0)
|
||||||
m_enginePtr->GetExtension(n)->DoPreVoltageUpdates();
|
m_enginePtr->DoPreVoltageUpdates();
|
||||||
|
|
||||||
m_enginePtr->m_barrier_PreVolt->wait();
|
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() ); )
|
DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
|
||||||
|
|
||||||
//post voltage stuff...
|
//post voltage stuff...
|
||||||
for (size_t n=m_threadID;n<m_enginePtr->GetExtensionCount();n+=m_enginePtr->m_numThreads)
|
if (m_threadID==0)
|
||||||
m_enginePtr->GetExtension(n)->DoPostVoltageUpdates();
|
{
|
||||||
|
m_enginePtr->DoPostVoltageUpdates();
|
||||||
|
m_enginePtr->Apply2Voltages();
|
||||||
|
}
|
||||||
m_enginePtr->m_barrier_PostVolt->wait();
|
m_enginePtr->m_barrier_PostVolt->wait();
|
||||||
|
|
||||||
// e-field excitation (thread thread_e_excitation)
|
// 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() ); )
|
DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
|
||||||
|
|
||||||
//pre current stuff
|
//pre current stuff
|
||||||
for (size_t n=m_threadID;n<m_enginePtr->GetExtensionCount();n+=m_enginePtr->m_numThreads)
|
if (m_threadID==0)
|
||||||
m_enginePtr->GetExtension(n)->DoPreCurrentUpdates();
|
m_enginePtr->DoPreCurrentUpdates();
|
||||||
m_enginePtr->m_barrier_PreCurr->wait();
|
m_enginePtr->m_barrier_PreCurr->wait();
|
||||||
|
|
||||||
//current updates
|
//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() ); )
|
DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
|
||||||
|
|
||||||
//post current stuff
|
//post current stuff
|
||||||
for (size_t n=m_threadID;n<m_enginePtr->GetExtensionCount();n+=m_enginePtr->m_numThreads)
|
if (m_threadID==0)
|
||||||
m_enginePtr->GetExtension(n)->DoPostCurrentUpdates();
|
{
|
||||||
|
m_enginePtr->DoPostCurrentUpdates();
|
||||||
|
m_enginePtr->Apply2Current();
|
||||||
|
}
|
||||||
m_enginePtr->m_barrier_PostCurr->wait();
|
m_enginePtr->m_barrier_PostCurr->wait();
|
||||||
|
|
||||||
//soft current excitation here (H-field excite)
|
//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
|
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->ApplyVoltageExcite();
|
||||||
|
|
||||||
m_enginePtr->m_barrier_VoltExcite->wait(); // continue NS_Engine_Multithread::thread
|
m_enginePtr->m_barrier_VoltExcite->wait(); // continue NS_Engine_Multithread::thread
|
||||||
|
|
||||||
|
|
||||||
m_enginePtr->m_barrier_PostCurr->wait(); // waiting on 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->ApplyCurrentExcite();
|
||||||
|
|
||||||
m_enginePtr->m_barrier_CurrExcite->wait(); // continue NS_Engine_Multithread::thread
|
m_enginePtr->m_barrier_CurrExcite->wait(); // continue NS_Engine_Multithread::thread
|
||||||
|
Loading…
Reference in New Issue
Block a user