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中文网

知

知白

@知白
关于
帖子
4
主题
1
群组
0
粉丝
0
关注
0

帖子

最新

  • 在使用codedFixedValue边界条件时,如何获得网格中心坐标?
    知 知白

    @李东岳 请问李老师,codedFixedValue边界条件在U文件和pointDisplacement文件中获得网格坐标的方法是不是不通用,同样的代码,如:

            type    codedFixedValue;
            value   uniform (0 0 0);
            name    name_of_BC;
            code
            #{
                const Patch& boundaryPatch = patch();
                const vectorField& Cf = patch().Cf();       
            #};
    

    在U文件里可以使用,在pointDisplacement文件里就会出错。

    出错内容如下:

    Create time
    
    Create mesh for time = 0
    
    Selecting dynamicFvMesh dynamicMotionSolverFvMesh
    Selecting motion solver: displacementLayeredMotion
    Using dynamicCode for codedFixedValue name_of_BC at line 32 in "/mnt/hgfs/share/shotSleeveModeling3/0/pointDisplacement/boundaryField/movingWalls"
    Creating new library in "dynamicCode/name_of_BC/platforms/linux64GccDPInt32Opt/lib/libname_of_BC_2749dd0d9becc7c4794a34f8159e9b4cbe66efce.so"
    "/home/dyfluid/OpenFOAM/OpenFOAM-9/etc/codeTemplates/dynamicCode/codedFixedValuePointPatchFieldTemplate.C" "/mnt/hgfs/share/shotSleeveModeling3/dynamicCode/name_of_BC/codedFixedValuePointPatchFieldTemplate.C"
    "/home/dyfluid/OpenFOAM/OpenFOAM-9/etc/codeTemplates/dynamicCode/codedFixedValuePointPatchFieldTemplate.H" "/mnt/hgfs/share/shotSleeveModeling3/dynamicCode/name_of_BC/codedFixedValuePointPatchFieldTemplate.H"
    Invoking "wmake -s libso /mnt/hgfs/share/shotSleeveModeling3/dynamicCode/name_of_BC"
    wmake libso /mnt/hgfs/share/shotSleeveModeling3/dynamicCode/name_of_BC
        ln: ./lnInclude
    ln: failed to create symbolic link './codedFixedValuePointPatchFieldTemplate.C': Operation not supported
    ln: failed to create symbolic link './codedFixedValuePointPatchFieldTemplate.H': Operation not supported
        wmkdep: codedFixedValuePointPatchFieldTemplate.C
        Ctoo: codedFixedValuePointPatchFieldTemplate.C
    /mnt/hgfs/share/shotSleeveModeling3/0/pointDisplacement/boundaryField/movingWalls: In member function ‘virtual void Foam::name_of_BCFixedValuePointPatchVectorField::updateCoeffs()’:
    /mnt/hgfs/share/shotSleeveModeling3/0/pointDisplacement/boundaryField/movingWalls:39:45: error: ‘const class Foam::pointPatch’ has no member named ‘Cf’
    /mnt/hgfs/share/shotSleeveModeling3/0/pointDisplacement/boundaryField/movingWalls:37:14: warning: unused variable ‘boundaryPatch’ [-Wunused-variable]
    /mnt/hgfs/share/shotSleeveModeling3/0/pointDisplacement/boundaryField/movingWalls:39:32: warning: unused variable ‘Cf’ [-Wunused-variable]
    make: *** [/home/dyfluid/OpenFOAM/OpenFOAM-9/wmake/rules/General/transform:26: Make/linux64GccDPInt32Opt/codedFixedValuePointPatchFieldTemplate.o] Error 1
    
    
    --> FOAM FATAL IO ERROR: 
    Failed wmake "dynamicCode/name_of_BC/platforms/linux64GccDPInt32Opt/lib/libname_of_BC_2749dd0d9becc7c4794a34f8159e9b4cbe66efce.so"
    
    
    file: /mnt/hgfs/share/shotSleeveModeling3/0/pointDisplacement/boundaryField/movingWalls from line 32 to line 36.
    
        From function void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
        in file db/dynamicLibrary/codedBase/codedBase.C at line 209.
    
    FOAM exiting
    

    其中最关键的感觉是这几处:

    ln: failed to create symbolic link './codedFixedValuePointPatchFieldTemplate.C': Operation not supported
    ln: failed to create symbolic link './codedFixedValuePointPatchFieldTemplate.H': Operation not supported
    
    /mnt/hgfs/share/shotSleeveModeling3/0/pointDisplacement/boundaryField/movingWalls:39:45: error: ‘const class Foam::pointPatch’ has no member named ‘Cf’
    

    在U文件使用上述代码,只会出现第一处提示,不会出现第二处错误。


  • 在使用codedFixedValue边界条件时,如何获得网格中心坐标?
    知 知白

    @李东岳 李老师您意思是要使用下面代码,需要重新编译求解器,不能只在pointDisplacement里直接修改边界条件吗?

     forAll(field, faceI)
    {
          const scalar x = mesh.Cf().boundaryField()[faceI][0];
    
           field[faceI].x() = 0;
           field[faceI].y() = 0;
           field[faceI].z() = U_0*sin(t);
     }
    

    我看教程里,只是修改了边界条件,没有重新编译求解器:
    4d93a015-754c-462a-915c-00b3007f470c-image.png


  • 在使用codedFixedValue边界条件时,如何获得网格中心坐标?
    知 知白

    @李东岳 李老师好!
    OpenFOAM我刚开始学,所以不是很懂,不知道您说的是不是这样使用,可以获得网格x方向的坐标:

     forAll(field, faceI)
    {
          const scalar x = mesh.Cf().boundaryField()[faceI][0];
    
           field[faceI].x() = 0;
           field[faceI].y() = 0;
           field[faceI].z() = U_0*sin(t);
     }
    

    在这样使用时会报错:
    error: ‘mesh’ was not declared in this scope

    请问这是为什么。


  • 在使用codedFixedValue边界条件时,如何获得网格中心坐标?
    知 知白

    大家好,我在学习一个shotSleeveModeling的动网格案例,几何模型如下,运动边界为movingWalls;

    Pasted image 20220816214329.png

    我采用codedFixedValue边界条件,实现了movingWalls边界的往复运动,pointDisplacement和dynamicMeshDict文件的部分内容如下:

    //pointDisplacement
    boundaryField
    {
    
        "(outlet|fixedWalls)"
        {
            type       fixedValue;
            value     uniform (0 0 0);
        }
    
        movingWalls
        {
            type    codedFixedValue;
            value   uniform (0 0 0);
            name    name_of_BC;
    
            code
            #{
                //const fvPatch & boundaryPatch = patch();
                //const Patch & boundaryPatch = patch();
                //const vectorField & Cf = boundaryPatch.Cf(); 
    
                vectorField & field = *this;
                scalar U_0 = 0.1, p_r = 0.03;
                scalar t = this->db().time().value();
    
                forAll(field, faceI)
                {
                    //const scalar x = boundaryPatch.Cf()[faceI][0];
                    //const scalar y = boundaryPatch.Cf()[faceI][1];
                    //const scalar z = boundaryPatch.Cf()[faceI][2];
    
                    field[faceI].x() = 0;
                    field[faceI].y() = 0;
                    field[faceI].z() = U_0*sin(t);
                    //field[faceI].z() = U_0*sin(t)*pow(field[faceI].y(),2)/(p_r*p_r);
                }
            #};
        }
        slipWalls
        {
    
            type            calculated;
        }
    
        frontAndBack
        {
            //type            empty;
            type            calculated;
        }
    }
    
    //dynamicMeshDict
    dynamicFvMesh       dynamicMotionSolverFvMesh; 
    motionSolverLibs ( "libfvMotionSolvers.so" );
    motionSolver          displacementLayeredMotion;
    cellZone movingCells;
    displacementLayeredMotionCoeffs
    {
        regions
        {
            movingCells
            {
                interpolationScheme linear;
                boundaryField
                {
                    movingFaces { type follow; }
                    boundaryMovingFixed { type  fixedValue; value uniform (0 0 0); }
                }
            }
        }
    }
    

    movingWalls边界的往复运动如下图所示:

    shot2.gif

    在实现往复运动的基础上,我想让movingWalls沿y轴方向从中间到两边的网格运动速度递减,呈一个抛物线型,因此我需要获得网格中心坐标;

    首先,我在pointDisplacement->movingWalls->code#{ #}中增加如下语句,会报错:

    const fvPatch & boundaryPatch = patch();
    

    不过按照提示将上述语句中的fvPatch改成Patch,就可以解决错误了。

    但是当我在pointDisplacement->movingWalls->code#{ #}中再增加如下语句,用来获得网格中心坐标时,也会报错:

    const vectorField & Cf = boundaryPatch.Cf(); //网格中心
    

    报错内容为:
    /mnt/hgfs/share/shotSleeveModeling3/0/pointDisplacement.boundaryField.movingWalls:40:52: error: ‘const Patch’ {aka ‘const class Foam::pointPatch’} has no member named ‘Cf’

    我用了OpenFOAM9和OpenFOAM v2112,都会出错。按照提示,应该是Patch下面没有Cf这个成员,但是我看了很多教程获取网格坐标都是用的Cf。我卡在这很久了,都不知道要怎么修改,希望有知道的大神能指导下,多谢!!!

  • 登录

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