Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    添加湍流模型遇到问题(重发)

    OpenFOAM
    3
    7
    2352
    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 李东岳

      我用of5.0版本,想添加mykEpsilon模型,用sed语句修改kEpsilon,mykEpsilon.C代码如下

      namespace Foam
      {
      namespace RASModels
      {
      
      // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
      
      template<class BasicTurbulenceModel>
      void mykEpsilon<BasicTurbulenceModel>::correctNut()
      {
          this->nut_ = Cmu_*sqr(k_)/epsilon_;
          this->nut_.correctBoundaryConditions();
          fv::options::New(this->mesh_).correct(this->nut_);
      
          BasicTurbulenceModel::correctNut();
      }
      
      
      template<class BasicTurbulenceModel>
      tmp<fvScalarMatrix> mykEpsilon<BasicTurbulenceModel>::kSource() const
      {
          return tmp<fvScalarMatrix>
          (
              new fvScalarMatrix
              (
                  k_,
                  dimVolume*this->rho_.dimensions()*k_.dimensions()
                  /dimTime
              )
          );
      }
      
      
      template<class BasicTurbulenceModel>
      tmp<fvScalarMatrix> mykEpsilon<BasicTurbulenceModel>::epsilonSource() const
      {
          return tmp<fvScalarMatrix>
          (
              new fvScalarMatrix
              (
                  epsilon_,
                  dimVolume*this->rho_.dimensions()*epsilon_.dimensions()
                  /dimTime
              )
          );
      }
      
      
      
      // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
      
      template<class BasicTurbulenceModel>
      mykEpsilon<BasicTurbulenceModel>::mykEpsilon
      (
          const alphaField& alpha,
          const rhoField& rho,
          const volVectorField& U,
          const surfaceScalarField& alphaRhoPhi,
          const surfaceScalarField& phi,
          const transportModel& transport,
          const word& propertiesName,
          const word& type
      )
      :
          eddyViscosity<RASModel<BasicTurbulenceModel>>
          (
              type,
              alpha,
              rho,
              U,
              alphaRhoPhi,
              phi,
              transport,
              propertiesName
          ),
      
          Cmu_
          (
              dimensioned<scalar>::lookupOrAddToDict
              (
                  "Cmu",
                  this->coeffDict_,
                  0.09
              )
          ),
          C1_
          (
              dimensioned<scalar>::lookupOrAddToDict
              (
                  "C1",
                  this->coeffDict_,
                  1.44
              )
          ),
          C2_
          (
              dimensioned<scalar>::lookupOrAddToDict
              (
                  "C2",
                  this->coeffDict_,
                  1.92
              )
          ),
          C3_
          (
              dimensioned<scalar>::lookupOrAddToDict
              (
                  "C3",
                  this->coeffDict_,
                  0
              )
          ),
          sigmak_
          (
              dimensioned<scalar>::lookupOrAddToDict
              (
                  "sigmak",
                  this->coeffDict_,
                  1.0
              )
          ),
          sigmaEps_
          (
              dimensioned<scalar>::lookupOrAddToDict
              (
                  "sigmaEps",
                  this->coeffDict_,
                  1.3
              )
          ),
      
          k_
          (
              IOobject
              (
                  IOobject::groupName("k", U.group()),
                  this->runTime_.timeName(),
                  this->mesh_,
                  IOobject::MUST_READ,
                  IOobject::AUTO_WRITE
              ),
              this->mesh_
          ),
          epsilon_
          (
              IOobject
              (
                  IOobject::groupName("epsilon", U.group()),
                  this->runTime_.timeName(),
                  this->mesh_,
                  IOobject::MUST_READ,
                  IOobject::AUTO_WRITE
              ),
              this->mesh_
          )
      {
          bound(k_, this->kMin_);
          bound(epsilon_, this->epsilonMin_);
      
          if (type == typeName)
          {
              this->printCoeffs(type);
          }
      }
      
      
      // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
      
      template<class BasicTurbulenceModel>
      bool mykEpsilon<BasicTurbulenceModel>::read()
      {
          if (eddyViscosity<RASModel<BasicTurbulenceModel>>::read())
          {
              Cmu_.readIfPresent(this->coeffDict());
              C1_.readIfPresent(this->coeffDict());
              C2_.readIfPresent(this->coeffDict());
              C3_.readIfPresent(this->coeffDict());
              sigmak_.readIfPresent(this->coeffDict());
              sigmaEps_.readIfPresent(this->coeffDict());
      
              return true;
          }
          else
          {
              return false;
          }
      }
      
      
      template<class BasicTurbulenceModel>
      void mykEpsilon<BasicTurbulenceModel>::correct()
      {
          if (!this->turbulence_)
          {
              return;
          }
      
          // Local references
          const alphaField& alpha = this->alpha_;
          const rhoField& rho = this->rho_;
          const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
          const volVectorField& U = this->U_;
          volScalarField& nut = this->nut_;
          fv::options& fvOptions(fv::options::New(this->mesh_));
      
          eddyViscosity<RASModel<BasicTurbulenceModel>>::correct();
      
          volScalarField::Internal divU
          (
              fvc::div(fvc::absolute(this->phi(), U))().v()
          );
      
          tmp<volTensorField> tgradU = fvc::grad(U);
          volScalarField::Internal G
          (
              this->GName(),
              nut.v()*(dev(twoSymm(tgradU().v())) && tgradU().v())
          );
          tgradU.clear();
      
          // Update epsilon and G at the wall
          epsilon_.boundaryFieldRef().updateCoeffs();
      
          // Dissipation equation
          tmp<fvScalarMatrix> epsEqn
          (
              fvm::ddt(alpha, rho, epsilon_)
            + fvm::div(alphaRhoPhi, epsilon_)
            - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_)
           ==
              C1_*alpha()*rho()*G*epsilon_()/k_()
            - fvm::SuSp(((2.0/3.0)*C1_ - C3_)*alpha()*rho()*divU, epsilon_)
            - fvm::Sp(C2_*alpha()*rho()*epsilon_()/k_(), epsilon_)
            + epsilonSource()
            + fvOptions(alpha, rho, epsilon_)
          );
      
          epsEqn.ref().relax();
          fvOptions.constrain(epsEqn.ref());
          epsEqn.ref().boundaryManipulate(epsilon_.boundaryFieldRef());
          solve(epsEqn);
          fvOptions.correct(epsilon_);
          bound(epsilon_, this->epsilonMin_);
      
          // Turbulent kinetic energy equation
          tmp<fvScalarMatrix> kEqn
          (
              fvm::ddt(alpha, rho, k_)
            + fvm::div(alphaRhoPhi, k_)
            - fvm::laplacian(alpha*rho*DkEff(), k_)
           ==
              alpha()*rho()*G
            - fvm::SuSp((2.0/3.0)*alpha()*rho()*divU, k_)
            - fvm::Sp(alpha()*rho()*epsilon_()/k_(), k_)
            + kSource()
            + fvOptions(alpha, rho, k_)
          );
      
          kEqn.ref().relax();
          fvOptions.constrain(kEqn.ref());
          solve(kEqn);
          fvOptions.correct(k_);
          bound(k_, this->kMin_);
      
          correctNut();
      }
      

      用wmake libso编译出现错误

      0_1525217013819_2018-05-01 23-17-09屏幕截图.png

      有谁知道是怎么回事吗?

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

        你主要对哪一行代码进行了改动呢?

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

        1 Reply Last reply Reply Quote
        • 郑
          郑澄远 last edited by

          李老师,我按照手册上还没有进行改动,只把kEpsilon改成mykEpsilon,但是编译就报错了,不知道是不是和of5.0有关

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

            就是说你把kEpsilon文件夹下面所有的kEpsilon关键字替换为了mykEpsilon?

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

            郑 1 Reply Last reply Reply Quote
            • 郑
              郑澄远 @李东岳 last edited by

              @东岳 是的,老师

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

                明天我试试

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

                1 Reply Last reply Reply Quote
                • R
                  Rui last edited by

                  李老师您好,请问这个问题解决了吗?我也遇到类似的问题,就是只改湍流模型的名字,在编译的时候也出现了一些error

                  1 Reply Last reply Reply Quote
                  • First post
                    Last post

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