1、原視頻地址
https://www.bilibili.com/video/BV1ME411A73k/?spm_id_from=333.1007.top_right_bar_window_custom_collection.content.click&vd_source=33b50a4dd201d7564e6e63d321809ce9
2、網格劃分及匯入
2.1 網格劃分
本案例使用ICEM劃分網格,并匯入openfoam中

2.2 網格轉換
目前通過在 3 維中定義網格來處理 2 維幾何,其中前平面和后平面定義為空邊界塊型別,讀取二維 Fluent 網格時,轉換器會自動在第三方向拉伸網格并添加空面片,將其命名為 frontAndBackPlanes,
fluentMeshToFoam:讀取fluent.msh網格檔案,(指南的5.5章)
命令:
fluentMeshToFoam <meshFile>

2.3 檢查網格
checkMesh

system/blockMeshDict檔案可以洗掉
3、邊界條件
3.1 網格boundary
這是轉換網格后自動生成的,
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
5
(
INLET
{
type patch;
nFaces 30;
startFace 13060;
}
OUTLET
{
type patch;
nFaces 30;
startFace 13090;
}
WALL
{
type wall;
inGroups List<word> 1(wall);
nFaces 100;
startFace 13120;
}
CYLINDER
{
type wall;
inGroups List<word> 1(wall);
nFaces 120;
startFace 13220;
}
frontAndBackPlanes // 空,表示2維
{
type empty;
inGroups List<word> 1(empty);
nFaces 13200;
startFace 13340;
}
)
// ************************************************************************* //
3.2 0/P檔案
- 在OpenFOAM中,zeroGradient是一種邊界條件,用于指定在邊界上的量的梯度為零,這意味著該邊界的值不會改變,例如,對于速度邊界條件,zeroGradient表示速度沿該邊界的梯度為零,即速度沿該邊界的值不會改變,通常,這種邊界條件在流體邊界和對稱邊界上使用,在代碼中,它表示為:
, - 在 OpenFOAM 中,
fixedValue是一種邊界條件型別,表示在特定的邊界上施加固定的值,這個值通常是在0、uniform、nonuniform或list中指定的,具體取決于場的型別和邊界的特征,例如,在一個流體模擬中,可以將固定的速度值施加在流場的邊界上,這可以通過設定邊界條件型別為fixedValue并指定速度值來實作,同樣地,可以將固定的溫度、壓力或其他物理量值應用于相應的場變數上,在 OpenFOAM 中,邊界條件的設定是在 case 目錄下的0檔案夾中的boundary檔案中完成的,使用fixedValue邊界條件時,用戶需要指定固定的值并將其應用于適當的邊界, - 在OpenFOAM中,empty邊界型別用于定義沒有物理邊界或者該邊界不需要與周圍區域相互作用的情況,例如,計算空氣在室內流動的情況,室內墻壁可以定義為empty邊界,在empty邊界中,OpenFOAM不會對物理量進行任何修改,因此需要在邊界條件的設定中進行額外的注意,在empty邊界中,通常會使用fixedValue或者fixedGradient來設定邊界條件,
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
INLET // 壓力梯度為0
{
type zeroGradient; // 壓力梯度為0
}
WALL
{
type zeroGradient;
}
CYLINDER
{
type zeroGradient;
}
OUTLET // 出口壓力為固定值0
{
type fixedValue;
value uniform 0;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
3.3 0/U檔案
- internalField是指某個場量在整個計算域內的初始值,在進行流體流動計算時,internalField可以表示壓力、速度、溫度等場量的初始值,internalField可以被定義為標量、向量、對稱張量和非對稱張量場量,常見的初始化方法包括常數、分布式初始化和從其他場量插值得到,例如,對于速度場量,可以通過設定其為一個初始速度場量或者通過從初始條件的壓力梯度中計算得到,一旦internalField被定義,將無法在后續的計算程序中修改,因此,需要根據計算需求仔細地定義initialField,
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
// 場內初始值
internalField uniform (50 0 0);
boundaryField
{
INLET // 速度為固定值ux=50m/s
{
type fixedValue;
value uniform (50 0 0);
}
WALL
{
type fixedValue;
value uniform (50 0 0);
}
OUTLET
{
type zeroGradient;
}
CYLINDER
{
type fixedValue;
value uniform (0 0 0);
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
oepnfoam中zeroGradient和uniform (0 0 0)的區別:
zeroGradient只表示在邊界上梯度不變,并不是不隨時間變化,
uniform (0 0 0)更強硬一些,就是為某個值,
4、計算引數
4.1 controlDict
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.05;
deltaT 0.00001; // Co = U * t / x
writeControl timeStep;
writeInterval 100;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
4.2 fvSchemes
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linear;
}
laplacianSchemes
{
default Gauss linear orthogonal;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default orthogonal;
}
// ************************************************************************* //
4.3 fvSolution
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0.05;
}
pFinal
{
$p;
relTol 0;
}
U
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-05;
relTol 0;
}
}
PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}
// ************************************************************************* //
5、計算
icoFoam > log

6、后處理
生成臨時后處理檔案
paraFoam -builtin

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/549631.html
標籤:其他
下一篇:mit 6.824 lab1分析
