2013-12-09 54 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