Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    rhoCentralFoam是如何计算温度的?

    OpenFOAM
    2
    5
    2192
    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.
    • sibo
      sibo last edited by 李东岳

      在rhoCentralFoam中,能量方程解了之后求的是e--internal energy, 那么温度是在哪里计算的呢?
      我在rhoCentralFoam中的createField.H里面看到:const volScalarField& T = thermo.T(); 请问为何这里将T声明为const呢?在之后加T.boundaryFieldRef()=###, 编译会报错,就是说T被声明为了const。想问const的声明是否是必须的呢?

      谢谢大家!

      1 Reply Last reply Reply Quote
      • sibo
        sibo last edited by 李东岳

        做了一些search后有如下进展:
        解完能量方程后,有这样一行:thermo.correct();
        然后thermal correct基本就是calculate();
        在hePsiThermo.C中发现:

        TCells[celli] = mixture_.THE
                (
                    hCells[celli],
                    pCells[celli],
                    TCells[celli]
                );
        

        就又去找了THE的解释:

        inline Foam::scalar Foam::species::thermo<Thermo, Type>::THE
        (
            const scalar he,
            const scalar p,
            const scalar T0
        ) const
        {
            return Type<thermo<Thermo, Type>>::THE(*this, he, p, T0);
        }
        

        但是到这里还是不清楚到底是如何计算T的啊?

        1 Reply Last reply Reply Quote
        • 李东岳
          李东岳 管理员 last edited by

          const volScalarField& T = thermo.T();请问为何这里将T声明为const呢?

          防止求解器直接求解T,你建立一个场也可以,这有一部分是好编程习惯养成的问题。所以你操作T的boundaryField不成功

          计算方法总结一下,希望对后来者有用

          最原始来自于抽象基类basicThermo.H:

          rhoCentralFoam.C -> thermo.correct(); -> hePsiThermo.C -> correct(); -> calculate(); ->

          TCells[celli] = mixture_.THE
                  (
                      hCells[celli],
                      pCells[celli],
                      TCells[celli]
                  );
          

          ->

          const typename MixtureType::thermoType& mixture_ =
                      this->cellMixture(celli);
          

          ->
          basicThermo.H,
          ->

          //- Temperature from enthalpy/internal energy for cell-set
          virtual tmp<scalarField> THE
                      (
                          const scalarField& h,
                          const scalarField& p,
                          const scalarField& T0,      // starting temperature
                          const labelList& cells
                      ) const = 0;
          

          -> 运行时选择 -> sensibleInternalEnerge.H

          //- Temperature from sensible internal energy
                      //  given an initial temperature T0
                      scalar THE
                      (
                          const Thermo& thermo,
                          const scalar e,
                          const scalar p,
                          const scalar T0
                      ) const
                      {
                          return thermo.TEs(e, p, T0);
                      }
          

          -> thermoI.H

          template<class Thermo, template<class> class Type>
          inline Foam::scalar Foam::species::thermo<Thermo, Type>::TEs
          (
              const scalar es,
              const scalar p,
              const scalar T0
          ) const
          {
              return T
              (
                  es,
                  p,
                  T0,
                  &thermo<Thermo, Type>::Es,
                  &thermo<Thermo, Type>::Cv,
                  &thermo<Thermo, Type>::limit
              );
          }
          

          ->

          template<class Thermo, template<class> class Type>
          inline Foam::scalar Foam::species::thermo<Thermo, Type>::T
          (
              scalar f,
              scalar p,
              scalar T0,
              scalar (thermo<Thermo, Type>::*F)(const scalar, const scalar) const,
              scalar (thermo<Thermo, Type>::*dFdT)(const scalar, const scalar)
                  const,
              scalar (thermo<Thermo, Type>::*limit)(const scalar) const
          ) const
          {
             ...
              return Tnew;
          }
          

          线上CFD课程 7月1日报名截止 http://dyfluid.com/class.html
          CFD高性能服务器 http://dyfluid.com/servers.html

          1 Reply Last reply Reply Quote
          • sibo
            sibo last edited by

            感谢东岳师兄指导!当时找到THE就不知道该怎么找下去了,还想请问一下如何可以准确的找到方程的定义啊?比如在找THE的时候,会出现在很多.H文件里,怎么能知道具体的某个solver是用的哪个呢?我一直都是在doxygen里面看最相关的,但是有时候不熟悉的话就得重复找好多次。。。很糟心。。。后来用了Qt,在写自己solver的时候是挺方便,但是看其他openfoam solver还得自己重新整理所有头文件进去,也很麻烦。。还请各位前辈给些意见~谢谢啦!

            1 Reply Last reply Reply Quote
            • 李东岳
              李东岳 管理员 last edited by

              这和工作习惯有关,我这面接触的课题组里面大家都没怎么用doxygen,导致我也没怎么用,不过我这面有人用Qt,但是我个人用的是VIM。但我知道好像大家说doxygen很好用,Qt在国内也很受欢迎。对于找代码,我非常低级,就是从类的继承关系找..需要哪个打开哪个

              线上CFD课程 7月1日报名截止 http://dyfluid.com/class.html
              CFD高性能服务器 http://dyfluid.com/servers.html

              1 Reply Last reply Reply Quote
              • First post
                Last post

              CFD中文网 | 东岳流体 | 京ICP备15017992号-2
              论坛登录问题反馈可联系 li.dy@dyfluid.com