Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    关于调用 PtrDictionary<phaseModel> 类储存的场的数据

    OpenFOAM
    4
    7
    2613
    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.
    • J
      Jacobian last edited by

      在 multiphaseEulerFoam,multiphaseInterFoam,compressibleMultiphaseInterFoam 等多相流求解器中,都会用到PtrDictionary<phaseModel>这个类来储存部分物理量的场的数据。
      如果代码中要调用它所保存的物理量,比如体积分数场,怎么实现最方便?

      1 Reply Last reply Reply Quote
      • J
        Jacobian last edited by

        换一种问法吧,以multiphaseEulerFoam为例,如何添加调用第n项的体积分数场的代码?

        1 Reply Last reply Reply Quote
        • J
          Jacobian last edited by

          自己顶一下,
          个人认为,最好的方法应该是用 .db().lookupObject<volScalarField>("xxxxx") ,比如要求水的体积分数,就在括号在填"alpha.water"。但有时不知道物理量被命名为什么,也就是说不知道"xxxxx"该填什么,比如compressibleMultiphaseInterFoam中的密度,填"rho.water"是无效的,这种情况下,可以用下面的代码:

          Foam::tmp<Foam::volScalarField> Foam::multiphaseMixtureThermo::rho3() const  
          {
          
              PtrDictionary<phaseModel>::const_iterator phasei = phases_.begin();
          
              ++phasei;
              ++phasei;
          
              tmp<volScalarField> trho(phasei().thermo().rho());  
              //换成 tmp<volScalarField> talpha(phasei()); 也可以求体积分数alpha
          
              return trho;
          }
          

          该代码是用来第3相密度的成员函数。如果想求第n相的话,就进行n-1次++phasei。调用该函数,即可返回密度。虽然方法比较丑陋,但确实能用。
          不知道大家还有什么更好的方法?

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

            我觉得高亮的代码挺好了 有什么弊端么?

            CFD高性能服务器 http://dyfluid.com/servers.html

            ZY-GONG 1 Reply Last reply Reply Quote
            • 影
              影川风 @Jacobian last edited by

              @Jacobian 你好,非常感谢提供的参考,试了下的确有用。我现在遇到一个问题,我现在想在compressibleMultiphaseInterFoam求解器下multiphaseMixtureThermo.C下想调用压力,因为直接使用编译会说没有宣称。我能用什么办法调用压力呢?

              影 1 Reply Last reply Reply Quote
              • 影
                影川风 @影川风 last edited by

                @影川风 已解决,看了底层的基类,发现已有定义,直接调用过来就行。

                1 Reply Last reply Reply Quote
                • ZY-GONG
                  ZY-GONG @李东岳 last edited by

                  @李东岳 李老师我想请教一个问题,最近在多项欧拉Foam里植入了一个曳力模型,编译成功了但是求解动量方程的时候就会报错,我想请问这个报错的意思是我这pow函数没有用对吗?报错如下

                  PIMPLE: Iteration 1
                  MULES: Solving for alpha.air
                  air fraction, min, max = 0.293333 0 1
                  MULES: Solving for alpha.air
                  air fraction, min, max = 0.293333 0 1
                  Constructing momentum equations
                  #0  Foam::error::printStack(Foam::Ostream&) at ??:?
                  #1  Foam::sigFpe::sigHandler(int) at ??:?
                  #2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
                  #3  ? in "/lib/x86_64-linux-gnu/libm.so.6"
                  #4  powf64 in "/lib/x86_64-linux-gnu/libm.so.6"
                  #5  Foam::pow(Foam::Field<double>&, Foam::UList<double> const&, double const&) at ??:?
                  #6  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::pow<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::dimensioned<double> const&) at ??:?
                  #7  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::pow<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, double const&) at ??:?
                  #8  Foam::dragModels::bubbleDrag::CdRe() const at ??:?
                  #9  Foam::dragModels::dispersedDragModel::Ki() const at ??:?
                  #10  Foam::dragModels::dispersedDragModel::K() const at ??:?
                  #11  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::BlendedInterfacialModel<Foam::dragModel>::evaluate<double, Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > (Foam::dragModel::*)() const, Foam::word const&, Foam::dimensionSet const&, bool) const at ??:?
                  #12  Foam::blendedDragModel::K() const at ??:?
                  #13  Foam::MomentumTransferPhaseSystem<Foam::phaseSystem>::momentumTransfer() at ??:?
                  #14  Foam::PhaseTransferPhaseSystem<Foam::OneResistanceHeatTransferPhaseSystem<Foam::MomentumTransferPhaseSystem<Foam::phaseSystem> > >::momentumTransfer() at ??:?
                  #15  ? in "/home/gzy/OpenFOAM/OpenFOAM-10/platforms/linux64GccDPInt32Opt/bin/multiphaseEulerFoam"
                  #16  ? in "/lib/x86_64-linux-gnu/libc.so.6"
                  #17  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
                  #18  ? in "/home/gzy/OpenFOAM/OpenFOAM-10/platforms/linux64GccDPInt32Opt/bin/multiphaseEulerFoam"
                  Floating point exception (core dumped)
                  

                  我目前的想法是在主函数里输出一下这些场,然后逐个排查下哪里出了问题,请问这些场该怎么调用呢?直接info+场名行不通,我不大清楚这样的语句要怎么写,麻烦您指导一下,非常感谢,例如

                  Foam::dragModels::bubbleDrag::bubbleDrag
                  (
                      const dictionary& dict,
                      const phaseInterface& interface,
                      const bool registerObject
                  )
                  :
                      dispersedDragModel(dict, interface, registerObject),
                      residualRe_("residualRe", dimless, dict)
                  {}
                  
                  
                  // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
                  
                  Foam::dragModels::bubbleDrag::~bubbleDrag()
                  {}
                  
                  
                  // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
                  
                  Foam::tmp<Foam::volScalarField> Foam::dragModels::bubbleDrag::CdRe() const
                  {
                      volScalarField TTT(interface_.continuous().thermo().T());:xiexie: 
                      TTT.dimensions().reset(dimless);
                      const volScalarField g1(1-TTT/647);
                      const volScalarField g2(max(g1, residualRe_));
                      const volScalarField g3(pow(g2, 0.98));
                      volScalarField ddd(interface_.dispersed().d());
                      ddd.dimensions().reset(dimless);
                  

                  :xiexie:

                  1 Reply Last reply Reply Quote
                  • First post
                    Last post

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