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. openFOAM codedFixedValue边界条件中调用标量场的问题

openFOAM codedFixedValue边界条件中调用标量场的问题

已定时 已固定 已锁定 已移动 OpenFOAM
3 帖子 2 发布者 790 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • L 离线
    L 离线
    L_LL
    写于2024年10月11日 06:08 最后由 编辑
    #1

    我尝试将of2306的jouleHeating算例中的jouleHeating::V从恒定电压改为恒定电流设置,因此想要通过电流乘以电阻来计算电压,其中电阻的设置涉及到电导率,而这个电导率是随着温度的变化变化的,所以想要读取标量场中的电导率(sigma)数据。
    以下是sigma设置

    /*--------------------------------*- C++ -*----------------------------------*\
    | =========                 |                                                 |
    | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
    |  \\    /   O peration     | Version:  v2206                                 |
    |   \\  /    A nd           | Website:  www.openfoam.com                      |
    |    \\/     M anipulation  |                                                 |
    \*---------------------------------------------------------------------------*/
    FoamFile
    {
        version     2.0;
        format      ascii;
        class       dictionary;
        object      fvOptions;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    heating
    {
        type            jouleHeatingSource;
        active          true;
    
        jouleHeatingSourceCoeffs
        {
            anisotropicElectricalConductivity no;
    
            // Optionally specify sigma as a function of temperature
            //sigma           127599.8469;
            //
            sigma           table
            (   
                (273      59600000)
                (298      58000000)
                (500      32000000)
            );
        }
    }
    
    
    // ************************************************************************* //
    

    下面是我写的codedFixedValue边界条件

    boundaryField
    {
    
        inlet
        {
            type            codedFixedValue;
            value           uniform 0;// 初始值,可以为0或其他合理的数值
            name            dynamicV;
           
            codeInclude
        	#{
        	    #include "mathematicalConstants.H"
        	    #include "fvCFD.H"
        	#};
        	codeOptions
        	#{
           	    -I$(LIB_SRC)/finiteVolume/lnInclude \
                -I$(LIB_SRC)/meshTools/lnInclude
       	#};
       	codeLibs
       	#{
       		-lmeshTools \
       		-lfiniteVolume
       	#};
       	
           code
           #{
                const fvMesh& mesh = this->patch().boundaryMesh().mesh();
    	    dictionary C = mesh.lookupObject<dictionary>("fvOptions");
               
                // 定义常数
                scalar I = 0.6;
                scalar L = 0.007875;
                scalar A = 1.125e-8;
    
               
       	    const volScalarField& sigma = mesh.lookupObject<volScalarField>("sigma");
    	    
    	    scalar sigma = gMax(sigma);
    
                // 计算电阻
                scalar R = L / (sigma * A);
                // 计算电压,确保恒定电流 I
                scalar V =  I * R;
    	    Info << "V: " << V << endl;
    	    Info << "R: " << R << endl;
    	    Info << "sigma: " << sigma << endl;
                // 将计算出的电压值作为边界条件
                operator==(V);
            #};
    
        }
    
        outlet
        {
            type            fixedValue;
            value           uniform 0;
        }
    

    这样的写法会出现

    Failed wmake "dynamicCode/dynamicV/platforms/linux64GccDPInt32Opt/lib/libdynamicV_c6587780c1810df06b6735b285db38c4418d36ec.so"
    
    
    file: 0/solid/jouleHeatingSource:V.boundaryField.inlet at line 28 to 47.
    
        From void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
        in file db/dynamicLibrary/codedBase/codedBase.C at line 245.
    
    FOAM exiting
    code_text
    

    但是如果我把上面的sigam换成T又是可以运行的,想问问大家知道我该如何去写这段代码吗

    1 条回复 最后回复
  • 李 在线
    李 在线
    李东岳 管理员
    写于2024年10月11日 06:16 最后由 编辑
    #2

    const volScalarField& sigma = mesh.lookupObject<volScalarField>("sigma");

    这一行换成T就可以了么?

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

    L 1 条回复 最后回复 2024年10月11日 06:26
  • L 离线
    L 离线
    L_LL
    在 2024年10月11日 06:26 中回复了 李东岳 最后由 编辑
    #3

    @李东岳 是的,这里换成T后下面的scalar T = gMax(T)函数也可以正常使用

    1 条回复 最后回复
2024年10月11日 06:08

3/3

2024年10月11日 06:26

2024年10月11日 06:26
  • 登录

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