2013-12-09 47 views
-3

在上課時間()方法運行使用變量BOOL subCycling_下面的代碼:什麼意思是分循環?

 bool Foam::Time::run() const 
    810 { 
    811  bool running = value() < (endTime_ - 0.5*deltaT_); 
    812 
    813  if (!subCycling_) //bool subCycling_; //- Is the time currently being sub-cycled? 
    814  { 
    815   // only execute when the condition is no longer true 
    816   // ie, when exiting the control loop 
    817   if (!running && timeIndex_ != startTimeIndex_) 
    818   { 
    819    // Note, end() also calls an indirect start() as required 
    820    functionObjects_.end(); 
    821   } 
    822  } 
    823 
    824  if (running) 
    825  { 
    826   if (!subCycling_) 
    827   { 
    828    const_cast<Time&>(*this).readModifiedObjects(); 
    829 
    830    if (timeIndex_ == startTimeIndex_) 
    831    { 
    832     functionObjects_.start(); 
    833    } 
    834    else 
    835    { 
    836     functionObjects_.execute(); 
    837    } 
    838   } 
    839 
    840   // Update the "running" status following the 
    841   // possible side-effects from functionObjects 
    842   running = value() < (endTime_ - 0.5*deltaT_); 
    843  } 
    844 
    845  return running; 
    846 } 
    847 
    848 
    849 bool Foam::Time::loop() 
    850 { 
    851  bool running = run(); 
    852 
    853  if (running) 
    854  { 
    855   operator++(); 
    856  } 
    857 
    858  return running; 
    859 } 

當我翻譯子循環成德文我還是不明白意思。 那麼,什麼意思是分循環[line 813]?這裏的一個例子會很棒。

問候 streight

+0

看起來它只是一個布爾變量... – Josh

+0

英語也沒有多大意義。如果作者沒有記錄它,那麼你需要閱讀'if'語句中的代碼,並弄清楚它做了什麼,以便知道他的意思。 –

+0

@Soylent:當然,但我需要知道變量背後的含義。 – Streight

回答

1

你得去問誰寫代碼的人。從這個微小的代碼片段中無任何上下文地隨機地講出來是不可能的。在後面的行中可能會有提示(因爲這些布爾值會影響這些行),但是您沒有向我們展示這些內容。但是,作爲線索,一些定時器實現使用「子循環」來描述在主事件循環的每個循環內運行定時器機制的重複迭代。這可以解決競爭造成單個等待條件:

它在運行的機械裝置的代碼更經常被發現。

+0

好吧,我已經在OpenFOAM論壇上發佈了一個星期前的這個問題,但還沒有答案。只是想在這裏嘗試一下,也許有人已經與它合作,因此可能有線索。 – Streight