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

R

raymondieei

@raymondieei
关于
帖子
1
主题
1
群组
0
粉丝
0
关注
0

帖子

最新

  • openfoam中添加新变量并输出
    R raymondieei

    各位老师好,由于openfoam里进行LES计算时,内置的field average只能输出雷诺应力,但是我的雷诺应力和经典文献结果对不上,所以我想在openfoam里增加速度二阶量UU及其时均值的计算。
    但是我在controlDict的增加了function以后并没有在结果文件里看到我定义的物理量,不知道各位有没有过类似的工作的可以指点一下。感谢!以下是我的代码

    functions
    {
        velocityUU
        {
            libs ("libutilityFunctionObjects.so");
            type coded;
            name velocityUU; // 将名称与输出文件的名称一致    
    
            region          region0;
            enabled         true;
            log             true;      
            executeControl  timeStep;
            executeInterval 1;
            writeControl    timeStep;
            writeInterval   1;
    
            codeInclude
            #{
                #include "fvCFD.H"
                #include <cmath>
                #include <iostream>
            #};
            
            codeOptions
            #{
                -I$(LIB_SRC)/finiteVolume/lnInclude \
                -I$(LIB_SRC)/meshTools/lnInclude
            #};
            
            codeLibs
            #{
                -lmeshTools \
                -lfiniteVolume
            #};
    
            codeExecute
            #{
                // 获取速度场 U
                const volVectorField& U = mesh().lookupObject<volVectorField>("U");
    
                // 计算速度场 U 的平方
                volScalarField UXSquared = U[0] * U[0];
    
                // 定义静态指针,用于存储 volScalarField 对象
                static autoPtr<volScalarField> pField;
    
                // 如果指针无效,创建 volScalarField 对象
                if (!pField.valid())
                {
                    pField.set(
                        new volScalarField(
                            IOobject(
                                "velocityUU",    // 输出文件的名称与函数名称一致
                                mesh().time().timeName(),
                                U.mesh(),
                                IOobject::NO_READ,
                                IOobject::AUTO_WRITE
                            ),
                            UXSquared
                        )
                    );
                }
    
                // 获取 velocityUU 引用
                volScalarField& result = pField();
    
                // 将 result 标记为有效
                result.checkIn();
    
                // 更新 result 的值
                result = UXSquared;
            #};
        }
    }
    
    
  • 登录

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