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. codedFixedValue中如何获得主程序中的常量或者从边界条件里的dict获得

codedFixedValue中如何获得主程序中的常量或者从边界条件里的dict获得

已定时 已固定 已锁定 已移动 OpenFOAM
3 帖子 2 发布者 1.8k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • J 离线
    J 离线
    Junren Hou
    写于 最后由 Junren Hou 编辑
    #1

    我想在codedFixedValue中的获得主程序中的常量,比如下面这个边界条件里。

            type       codedFixedValue;
            value     uniform 0;
            name     f4_f2;
            code
            #{
                const fvPatch& boundaryPatch = patch();
                scalar c = 0.5;
                scalar cs2 = 3.0/c/c;
                scalar cs4 = 4.5/c/c/c/c;
                dimensionedVector U4("U4", dimensionSet(0, 0, 0, 0, 0), vector(0, -c, 0));
                fvPatchField<scalar> f4 = boundaryPatch.lookupPatchField<volScalarField,scalar>("f4");
                const fvPatchField<scalar> rho = boundaryPatch.lookupPatchField<volScalarField,scalar>("rho");
                const fvPatchField<vector> U = boundaryPatch.lookupPatchField<volVectorField,vector>("U");
                const scalarField f4Internal = boundaryPatch.lookupPatchField<volScalarField,scalar>("f4").patchInternalField();
                const scalarField rhoInternal = boundaryPatch.lookupPatchField<volScalarField,scalar>("rho").patchInternalField();
                const vectorField UInternal = boundaryPatch.lookupPatchField<volVectorField,vector>("U").patchInternalField();
                dimensionedScalar feq4;
                dimensionedScalar feq4Internal;
                forAll(boundaryPatch, faceI)
                {
                    feq4 = rho[faceI]*1.0/9.0*(1.0+cs2*(U4&U[faceI])+cs4*(U4&U[faceI])*(U4&U[faceI])-cs2/2*(U[faceI]&U[faceI]));
                    feq4Internal = rhoInternal[faceI]*1.0/9.0*(1+cs2*(U4&UInternal[faceI])+cs4*(U4&UInternal[faceI])*(U4&UInternal[faceI])-cs2/2*(UInternal[faceI]&UInternal[faceI]));
                    f4[faceI] = feq4.value() + f4Internal[faceI] - feq4Internal.value();
                }
                operator==(f4);
            #};
    

    c在求解器里通过transportProperties进行了定义,我想获得它。

    dimensionedScalar c
    (
        "c",
        dimensionSet(0, 0, 0, 0, 0, 0, 0),
        transportProperties
    );
    

    如果不行,退而求其次,能否在边界条件里,通过设置c value;来获得呢,这样就不用每次改c值都得重新编译边界条件了。就像下面这个图里的样子

    a10a94f9-d045-440b-9ac5-3fe424eb89ea-image.png

    用的OpenFOAM-v2012

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

    http://dyfluid.com/code.html#id1

    wall
    {
        type            codedFixedValue;
        value           uniform (10 0 0);
        name            linearTBC1;
        code
        #{
            const fvMesh& mesh = this->patch().boundaryMesh().mesh();
            dictionary C = mesh.lookupObject<dictionary>("physicalProperties");
            scalar test(readScalar(C.lookup("test")));
        #};
    }
    

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    1 条回复 最后回复
  • J 离线
    J 离线
    Junren Hou
    写于 最后由 编辑
    #3

    谢谢岳哥,成了,牛牛牛

    1 条回复 最后回复

  • 登录

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