你的位置:首页-利盛安染料有限公司 > 新闻资讯 > 在求解器求解策划时会自动编译生成步调库并加载运行
在求解器求解策划时会自动编译生成步调库并加载运行
- 发布日期:2024-06-21 12:43 点击次数:148
本文描述操纵codeStream与setField自界说运转条目。
1 先容在栽植策划域的局部运转条目时,不错使用步调setFields。此实用步调卓绝活泼,除了不错栽植指定区域内的运转值外,还不错读取STL文献并使用它们来运滚动物理场。有关词要是使用setFields无法赢得所要的成果时,不错使用codeStream编制步调来完结自界说的运转条目。
codeStream界说运转条目与界说限度条目的面貌通常,界说完结后,在求解器求解策划时会自动编译生成步调库并加载运行。如下示例为运滚动示例:
// internalField为运转条目要道字internalField #codeStream{ { // 这里列举编译所需的头文献 codeInclude #{ #include "fvCFD.H" #}; // 这里列举编译选项 codeOptions #{ - I$(LIB_SRC) / finiteVolume / lnInclude - I$(LIB_SRC) / meshTools / lnInclude #}; // 这里列举编译所需的外部库 codeLibs #{ - lmeshTools - lfiniteVolume #}; // 这里摈弃功能完结源代码 code #{ #}; };}
如底下的示例模子。
图片
操纵codeStream界说椭圆区域内相Phase2的体积分数。不错在字典文献alpha.phase1中领受底下的代码:
internalField #codeStream{ { codeInclude #{ #include "fvCFD.H" #}; codeOptions #{ -I$(LIB_SRC) / finiteVolume / lnInclude \ -I$(LIB_SRC) / meshTools / lnInclude #}; codeLibs #{ -lmeshTools - lfiniteVolume #}; code #{ // 探问到策划网格信息 const IOdictionary& d = static_cast<const IOdictionary&>(dict); const fvMesh& mesh = refCast<const fvMesh>(d.db()); // 界说区域内运转体积分数为0 scalarField alpha(mesh.nCells(), 0.); scalar he = 0.5; scalar ke = 0.5; scalar ae = 0.3; scalar be = 0.15; forAll(alpha, i) { // 获取网格面的x,y,z坐标 const scalar x = mesh.C()[i][0]; const scalar y = mesh.C()[i][1]; const scalar z = mesh.C()[i][2]; // 得到卵形区域 if ( pow(y-ke,2) <= ((1 - pow(x-he,2)/pow(ae,2) )*pow(be,2)) ) { // 指定区域内体积分数为1 alpha[i] = 1.; } } writeEntry(os,首页-信西安香精有限公司 "", 民丰县嘉亨烹饪有限公司 alpha); #}; };}
疏导的模子其实也不错使用setField来科罚, 中蓝国际化工有限公司如构建底下的几何模子。
图片
准备底下的setFieldsDict字典:
defaultFieldValues( volScalarFieldValue alpha.phase1 0); regions( surfaceToCell { file "./geo/ellipse.stl"; outsidePoints((0.5 0.85 0)); includeInside true; includeOutside false; includeCut false; fieldValues ( volScalarFieldValue alpha.phase1 1 ); });2 示例2.1示例1
如底下用于策划Rayleigh-Taylor不牢固线性的模子。
图片
需要运滚动相间界面,这里指定其相间界面为余弦函数漫衍:
不错编制其代码为:
code#{ const IOdictionary &d = static_cast<const IOdictionary &>(dict); const fvMesh &mesh = refCast<const fvMesh>(d.db()); scalarField alpha(mesh.nCells(), 0.); forAll(alpha, i) { const scalar x = mesh.C()[i][0]; const scalar y = mesh.C()[i][1]; if (y >= -0.05 * cos(2 * constant::mathematical::pi * x)) { alpha[i] = 1.; } } writeEntry(os, "", alpha);#};2.2 示例2
如下图所示的策划模子。
图片
在alpha.water字典中使用codeStream指定运转水位。
internalField #codeStream{ ... ... ... code #{ const IOdictionary &d = static_cast<const IOdictionary &>(dict); const fvMesh &mesh = refCast<const fvMesh>(d.db()); scalarField alpha(mesh.nCells(), 0.); forAll(alpha, i) { const scalar x = mesh.C()[i][0]; const scalar y = mesh.C()[i][1]; const scalar z = mesh.C()[i][2]; if (y <= 0.2) { alpha[i] = 1.; } } writeEntry(os, "", alpha); #};}
在alpha.water中指定进口限度中水相体积分数:
leftWall{ type codedFixedValue; value uniform 0; name inletProfile2; code #{ const fvPatch &boundaryPatch = patch(); const vectorField &Cf = boundaryPatch.Cf(); scalarField &field = *this; field = patchInternalField(); scalar min = 0.5; scalar max = 0.7; scalar t = this->db().time().value(); forAll(Cf, faceI) { if ( (Cf[faceI].z() > min) && (Cf[faceI].z() < max) && (Cf[faceI].y() > min) && (Cf[faceI].y() < max)) { if (t < 2.) { field[faceI] = 1.; } else { field[faceI] = 0.; } } } #};}
在0/U限度条目中指定进口速率与时辰臆测冶金矿产,使用codedFixedValue进行指定:
leftWall{ type codedFixedValue; value uniform(0 0 0); name inletProfile1; code #{ const fvPatch &boundaryPatch = patch(); const vectorField &Cf = boundaryPatch.Cf(); vectorField &field = *this; scalar min = 0.5; scalar max = 0.7; scalar t = this->db().time().value(); forAll(Cf, faceI) { if ( (Cf[faceI].z() > min) && (Cf[faceI].z() < max) && (Cf[faceI].y() > min) && (Cf[faceI].y() < max)) { if (t < 2.) { field[faceI] = vector(1, 0, 0); } else { field[faceI] = vector(0, 0, 0); } } } #};}本站仅提供存储劳动,通盘推行均由用户发布,如发现存害或侵权推行,请点击举报。
相关资讯