• 最新
  • 版块
  • 热门
  • 东岳流体
皮肤
  • 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中文网

记录一些自己用过的代码

已定时 已固定 已锁定 已移动 OpenFOAM
6 帖子 2 发布者 4.6k 浏览
    • 从旧到新
    • 从新到旧
    • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • 李东岳李 离线
    李东岳李 离线
    李东岳 管理员
    写于 最后由 李东岳 编辑
    #1
    const fvPatchList& patches = mesh.boundary();
    
    forAll(patches, patch)
    {
    	Info << patches[patch].name() << nl;
            const fvPatch& currPatch = patches[patch];
            forAll(currPatch, face)
            {
    		Info << abs_[0].boundaryField()[patch][face] << nl;
    	}
    }
    

    CFD高性能服务器 http://dyfluid.com/servers.html
    论坛随机不定时开放注册

    1 条回复 最后回复
  • 李东岳李 离线
    李东岳李 离线
    李东岳 管理员
    写于 最后由 李东岳 编辑
    #2

    OpenFOAM-4.x以前?反正是老的:

    const scalarField& psi = U.internalField(); 
    scalarField& psi = U.internalField(); 
    

    OpenFOAM-5.x, 4.x:

    const scalarField& psi = U.primitiveField(); 
    scalarField& psi = U.primitiveFieldRef(); 
    

    tmp旧式风格:

    tmp<volScalarField> tField = ... 
    volScalarField& non_const_field = tField(); 
    const volScalarField& const_field = tField(); 
    

    新式风格:

    tmp<volScalarField> tField = ... 
    volScalarField& non_const_field = tField().ref(); 
    const volScalarField& const_field = tField(); 
    

    旧式:

    const volScalarField::GeometricBoundaryField& bsf = field.boundaryField(); 
    volScalarField::GeometricBoundaryField& bsf = field.boundaryField(); 
    

    新式:

    const volScalarField::Boundary& bsf = field.boundaryField(); 
    volScalarField::Boundary& bsf = field.boundaryFieldRef(); 
    

    dimensionedInternalField已经被volScalarField::Internal替换
    https://www.openfoam.com/documentation/developer-upgrade-guide.php

    CFD高性能服务器 http://dyfluid.com/servers.html
    论坛随机不定时开放注册

    1 条回复 最后回复
  • 李东岳李 离线
    李东岳李 离线
    李东岳 管理员
    写于 最后由 编辑
    #3
        const labelUList& owner = mesh_.owner();
        const labelUList& neighbour = mesh_.neighbour();
    
        forAll(weis_, kth)
        {
            forAll(sumWeisF[kth], cellI)
            {
    
                Info << "Current cell index is " << cellI << nl;
    
                //- Loop the faces of cellI
                forAll(mesh_.cells()[cellI], faceI)
                {
                    //- Check if it is an internal face
                    if (mesh_.isInternalFace(mesh_.cells()[cellI][faceI]))   
                    {
                        label faceIndex = mesh_.cells()[cellI][faceI];
                        Info << " its faceIndex is " << faceIndex;
                        Info << ", and this face's owner is "
                            << owner[faceIndex] << ", its neighbour is "
                            << neighbour[faceIndex] << nl;
                    }
                }
                
                Info << nl;
            } 
        }
    

    输出如下:

    Current cell index is 851
     its faceIndex is 1684, and this face's owner is 851, its neighbour is 852
     its faceIndex is 1685, and this face's owner is 851, its neighbour is 896
     its faceIndex is 1596, and this face's owner is 806, its neighbour is 851
     its faceIndex is 1682, and this face's owner is 850, its neighbour is 851
    
    Current cell index is 852
     its faceIndex is 1686, and this face's owner is 852, its neighbour is 853
     its faceIndex is 1687, and this face's owner is 852, its neighbour is 897
     its faceIndex is 1598, and this face's owner is 807, its neighbour is 852
     its faceIndex is 1684, and this face's owner is 851, its neighbour is 852
    
    

    希望有用 :confused:

    CFD高性能服务器 http://dyfluid.com/servers.html
    论坛随机不定时开放注册

    1 条回复 最后回复
  • 李东岳李 离线
    李东岳李 离线
    李东岳 管理员
    写于 最后由 编辑
    #4
    const labelList& inletCells = mesh.boundary()["inlet"].faceCells();
    
    template<class Type>
    void zeroCells
    (
        GeometricField<Type, fvPatchField, volMesh>& vf,
        const labelList& cells
    )
    {
        forAll(cells, i)
        {
            vf[cells[i]] = Zero;
        }
    }
    
    zeroCells(alpha, inletCells);
    

    CFD高性能服务器 http://dyfluid.com/servers.html
    论坛随机不定时开放注册

    1 条回复 最后回复
  • 李东岳李 离线
    李东岳李 离线
    李东岳 管理员
    写于 最后由 李东岳 编辑
    #5

    输出边界条件类型:

    Info << alpha.boundaryField().types()[patch] << nl;
    

    CFD高性能服务器 http://dyfluid.com/servers.html
    论坛随机不定时开放注册

    1 条回复 最后回复
  • 同学博同 离线
    同学博同 离线
    同学博
    写于 最后由 编辑
    #6

    亲测实用:140:

    1 条回复 最后回复

CFD中文网2016-2023 | 京ICP备15017992号-2

  • 登录

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 最新
  • 版块
  • 热门
  • 东岳流体
  • 登录

  • 登录或注册以进行搜索。