Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    影响计算效率的因素

    OpenFOAM
    1
    1
    848
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 浪
      浪迹天大 last edited by

      //2.4s
      label meshSize = this->thermo().rho()().size();
      for(label i=0; i < this->nSpecie_; i++)
      {
          for(label icell = 0; icell < meshSize; icell++)
          {
              label  izone = ZoneNumber[icell];
              this->RR_[i][icell]     = RRCCM[i][izone]*correctCH[icell];
          }
      } 
      
      //24s
      for(label i=0; i < this->nSpecie_; i++)
      {
          for(label icell = 0; icell < this->thermo().rho()().size(); icell++)
          {
              label  izone = ZoneNumber[icell];
              this->RR_[i][icell]     = RRCCM[i][izone]*correctCH[icell];
          }
      } 
      

      上边两种用法,计算耗时相差 10 倍!
      改用 thermo.T() 之后计算时间又变成 2.4 s 了,所以原因应该是 rho 后边跟了两个括号,深层原因是啥呢?

      //2.4s
      label meshSize = this->thermo().rho()().size();
      for(label i=0; i < this->nSpecie_; i++)
      {
          for(label icell = 0; icell < this->thermo().T().size(); icell++)
          {
              label  izone = ZoneNumber[icell];
              this->RR_[i][icell]     = RRCCM[i][izone]*correctCH[icell];
          }
      } 
      

      此外,还可以使用 forAll(this->thermo().T(), icell),效果和 for 循环几乎一样。

      OpenFOAM 学习交流:https://openfoam.top

      1 Reply Last reply Reply Quote
      • First post
        Last post

      CFD中文网 | 东岳流体 | 京ICP备15017992号-2