Skip to content
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(不使用皮肤)
  • 不使用皮肤
折叠
CFD中文网

CFD中文网

  1. CFD中文网
  2. OpenFOAM
  3. foamextend5.0求解器编译报错显示”expected unqualified-id before ‘if’“

foamextend5.0求解器编译报错显示”expected unqualified-id before ‘if’“

已定时 已固定 已锁定 已移动 OpenFOAM
4 帖子 1 发布者 1.4k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • Y 离线
    Y 离线
    yuanliangwojt
    写于 最后由 yuanliangwojt 编辑
    #1
    #include "fvCFD.H"
    #include "MULES.H"
    #include "subCycle.H"
    #include "interfaceProperties.H"
    #include "twoPhaseMixture.H"
    #include "turbulenceModel.H"
    #include "dynamicFvMesh.H"
    #include "pimpleControl.H"
    #include "immersedBoundaryPolyPatch.H"
    #include "immersedBoundaryFvPatch.H"
    #include "emptyFvPatch.H"
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    int main(int argc, char *argv[])
    {
    #   include "setRootCase.H"
    
    #   include "createTime.H"
    #   include "createDynamicFvMesh.H"
    
        pimpleControl pimple(mesh);
    
    
    #   include "readGravitationalAcceleration.H"
    
    
    #   include "initContinuityErrs.H"
    #   include "createIbMasks.H"
    #   include "createFields.H"
    #   include "createControls.H"
    #   include "correctPhi.H"
    #   include "CourantNo.H"
    #   include "setInitialDeltaT.H"
    

    我在foamextend5.0环境下编写具有IBM方法的两相流求解器,是在foamextend5.0自带的求解器pimpleDyMIbFoam基础上修改的,以上是一部分主程序代码,我在foam extend5.0环境下编译这个求解器,显示如下错误,是在我上边发的代码的第33行fa0baa3f-b089-4732-9121-f06d739099c0-image.png
    请问各位大佬应该这么修改呢?我确定这个报错路径下的CourantNo.H文件是没有问题的,因为这是系统路径下的文件啊,我也没有修改过,之前使用过这个文件编译其他求解器,也是没有问题的,所以现在不知道问题出在哪里了?
    还请各位老师不吝赐教

    1 条回复 最后回复
  • Y 离线
    Y 离线
    yuanliangwojt
    写于 最后由 编辑
    #2
    此回复已被删除!
    1 条回复 最后回复
  • Y 离线
    Y 离线
    yuanliangwojt
    写于 最后由 编辑
    #3

    下附CourantNo.H文件内容

    /*---------------------------------------------------------------------------*\
      =========                 |
      \\      /  F ield         | foam-extend: Open Source CFD
       \\    /   O peration     | Version:     5.0
        \\  /    A nd           | Web:         http://www.foam-extend.org
         \\/     M anipulation  | For copyright notice see file Copyright
    -------------------------------------------------------------------------------
    License
        This file is part of foam-extend.
    
        foam-extend is free software: you can redistribute it and/or modify it
        under the terms of the GNU General Public License as published by the
        Free Software Foundation, either version 3 of the License, or (at your
        option) any later version.
    
        foam-extend is distributed in the hope that it will be useful, but
        WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        General Public License for more details.
    
        You should have received a copy of the GNU General Public License
        along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
    
    Global
        CourantNo
    
    Description
        Calculates and outputs the mean and maximum Courant Numbers.
    
    \*---------------------------------------------------------------------------*/
    
    scalar CoNum = 0.0;
    scalar meanCoNum = 0.0;
    scalar velMag = 0.0;
    
    // HR 26.06.18: A parallel run has at least two cells and therefore at least
    // one internal face in the global mesh. It may be a processor boundary, but
    // this is captured by max(mag(phi)).
    // Old formulation hangs on parallel cases where one partition is degenerated
    // to a single cell.
    if (mesh.nInternalFaces() || Pstream::parRun())
    {
        surfaceScalarField magPhi = mag(phi);
    
        surfaceScalarField SfUfbyDelta =
            mesh.surfaceInterpolation::deltaCoeffs()*magPhi;
    
        const scalar deltaT = runTime.deltaT().value();
    
        CoNum = max(SfUfbyDelta/mesh.magSf()).value()*deltaT;
    
        meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())).value()*deltaT;
    
        velMag = max(magPhi/mesh.magSf()).value();
    }
    else
    {
        // Single cell mesh: Co is still defined; use cell formulation
    
        const scalar deltaT = runTime.deltaT().value();
    
        const scalar deltaX = Foam::cbrt(mesh.V()[0]);
    
        // recover velocity field in a more general way
        const volVectorField& URef
    	    = mesh.db().lookupObject<const volVectorField>("U");
    
        velMag = mag(URef[0]);
    
        CoNum = velMag*deltaT/deltaX;
    
        meanCoNum = CoNum;
    }
    
    Info<< "Courant Number mean: " << meanCoNum
        << " max: " << CoNum
        << " velocity magnitude: " << velMag
        << endl;
    
    // ************************************************************************* //
    
    1 条回复 最后回复
  • Y 离线
    Y 离线
    yuanliangwojt
    写于 最后由 编辑
    #4

    第一次在这个网站上求助各位大佬,报错图片不知道怎么看不了了,不好意思![IWE)}@6(NH98E9LRH@PDEK.png

    1 条回复 最后回复

  • 登录

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]