OpenFOAM11设置codedFixedValue边界
-
大佬们好,我想在OpenFOAM11中添加一个根据流固耦合边界温度和热通量改变物质分数和速度的边条。
尝试了一下,能运行,但是后处理发现很明显边界温度Tw还没有到我代码中设置的Tw0=432K,物质分数就变成1了
而且监测该边界的质量通量一直是0,应该是U一直是0。
个人感觉可能是调用字典文件的问题,但不知道该怎么改
有没有大佬愿意帮忙看一下,感谢!gas_to_solid { type codedFixedValue; name fuelInject; value uniform 0; codeInclude #{ #include "solver.H" //OpenFOAM11里求解器中带的头文件,感觉可以用来替代fvCFD.H #include <cmath> #include <iostream> #}; codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; codeLibs #{ -lmeshTools \ -lfiniteVolume #}; code #{ const fvMesh& mesh = this->patch().boundaryMesh().mesh(); label patchID = mesh.boundaryMesh().findPatchID("gas_to_solid"); const polyPatch& myPatch = mesh.boundaryMesh()[patchID]; const scalar Tw0 = 432; //K //定义开始分解温度 const scalarField& Tw = mesh.lookupObject<scalarField>("T"); //获取壁面温度 forAll(myPatch, faceI) // loop over all the patch faces { if (Tw[faceI] > Tw0) { (*this)[faceI] = 1; } else (*this)[faceI] = 0; } #}; } gas_to_solid { type codedFixedValue; name fuelinlet; value uniform (0 0 0); redirectType inletLaminarSquareProfile; codeInclude #{ #include "solver.H" #include <cmath> #include <iostream> #}; codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; codeLibs #{ -lmeshTools \ -lfiniteVolume #}; code #{ const fvMesh& mesh = this->patch().boundaryMesh().mesh(); label patchID = mesh.boundaryMesh().findPatchID("gas_to_solid"); const polyPatch& myPatch = mesh.boundaryMesh()[patchID]; const scalar rho_s = 927; //kg/m^3 const scalar L_v = 1819000; //J/kg const scalar Tw0 = 432; //K //定义开始分解温度 const scalarField& Tw = mesh.lookupObject<scalarField>("T"); //获取壁面温度 const scalarField& rho_g = mesh.lookupObject<scalarField>("rho"); //获取壁面上方气体密度 const scalarField& q = mesh.lookupObject<scalarField>("qr"); //获取壁面热通量 forAll(myPatch, faceI) // loop over all the patch faces { if (Tw[faceI] >= Tw0) { const scalar r = q[faceI] / (rho_s * L_v); const scalar U_y = rho_s / rho_g[faceI] * r; (*this)[faceI] = vector(0, U_y, 0); } else (*this)[faceI] = vector(0, 0, 0); } #}; }
以下是计算过程中某时刻该边界上方第一层网格内的结果