openFoam旋轉(zhuǎn)機(jī)械propeller案例教程
1 簡(jiǎn)介
以of10版本下官方算例propeller作為介紹,從模型、網(wǎng)格、計(jì)算和后處理進(jìn)行詳細(xì)描述。關(guān)于ESI版本(如openfoam2206)可參考最后第6部分
位于tutorials/incompressible/pimpleFoam/RAS/propeller
2 模型
?

propeller算例由4個(gè)模型組成,其作用分別為:
(1)propeller:幾何模型
(2)propeller-innerCylinder:用于創(chuàng)建rotationZone
(3)propeller-middleCylinder:用于網(wǎng)格加密
(4)propeller-outerCylinder:螺旋槳的流體域
3 網(wǎng)格劃分
propeller算例采用snappyHexMesh對(duì)網(wǎng)格進(jìn)行劃分,其步驟及結(jié)果如下:
(1)blockMesh生產(chǎn)背景網(wǎng)格
?

(2)surfaceFeatures提取面和幾何特征
surfaceFeatures指令需要提前在surfaceFeaturesDict文件中定義需要提取的幾何文件,如下所示:
surfaces
(
????"propeller-innerCylinder.obj"
????"propeller-outerCylinder.obj"
????"propeller.obj"
);
includedAngle ??150;
trimFeatures
{
????minElem ????????10;
}
surfaceFeaturesDict中定義了提取inner、outerCylinder和propeller三個(gè)文件的幾何特征。運(yùn)行surfaceFeatures指令后,會(huì)在算例文件canstant/extendedFeatureEdgeMesh下生成三個(gè)幾何文件的extendedFeatureEdgeMesh文件。
(3)decomposePar -noFields分塊計(jì)算
decomposePar指令會(huì)將模型根據(jù)decomposeParDict字典文件中的分塊策略對(duì)模型進(jìn)行分塊,用于分塊網(wǎng)格劃分和計(jì)算,Dict文件如下:
numberOfSubdomains 8; ?//將模型分成8塊
method ?????????hierarchical; ?//分塊方法
hierarchicalCoeffs
{
????n ??????????????(2 2 2); //xyz方向各2塊
????order ??????????xyz;
}
默認(rèn)運(yùn)行decomposePar指令是將網(wǎng)格和場(chǎng)同時(shí)進(jìn)行分塊,算例執(zhí)行的指令是decomposePar -noFields,-noFields意思是僅僅對(duì)幾何進(jìn)行分塊,其目的是用于后續(xù)snappyHexMesh。
(4)mpirun -np 8 snappyHexMesh -parallel
網(wǎng)格劃分這里就不再贅述,這里需要注意一點(diǎn):算例的進(jìn)出口邊界條件,即進(jìn)口inlet patch和出口outlet patch定義在propeller-outerCylinder.obj幾何文件中,通過(guò)定義在snappyHexMeshDict文件中字典,實(shí)現(xiàn)patch的命名:
outerCylinder
????????{
????????????level ??????(0 0);
????????????regions
????????????{
????????????????inlet
????????????????{
????????????????????level ??????(0 0);
????????????????????patchInfo
????????????????????{
????????????????????????type ???????patch;
????????????????????}
????????????????}
????????????????outlet
????????????????{
????????????????????level ??????(0 0);
????????????????????patchInfo
????????????????????{
????????????????????????type ???????patch;
????????????????????}
????????????????}
????????????}
????????}
(5)mpirun -np 8 createBaffles -overwrite -parallel
網(wǎng)格劃分好之后就可以對(duì)網(wǎng)格和交界面以及邊界面進(jìn)行處理,由于該算例的幾何文件中并沒(méi)有創(chuàng)建螺旋狀旋轉(zhuǎn)交界面,因此需要使用createBaffles指令來(lái)生成動(dòng)靜交界面,createBaffles指令需要定義Dict文件,如下所示。
internalFacesOnly true;
baffles
{
????nonCouple
????{
????????type ???????faceZone; ?//創(chuàng)建baffles的方法為通過(guò)面域生成
????????zoneName ???innerCylinder; ?//面域?yàn)閕nner幾何體
?
????????patches ?//baffles對(duì)應(yīng)的patch名字
????????{
????????????owner
????????????{
????????????????name ???????nonCouple1;
????????????????type ???????patch;
????????????}
?
????????????neighbour
????????????{
????????????????name ???????nonCouple2;
????????????????type ???????patch;
????????????}
????????}
????}
}
結(jié)果如下圖所示:

?
(6)mpirun -np 8 splitBaffles -overwrite -parallel
事實(shí)上createBaffles只是創(chuàng)建了一個(gè)Baffles即動(dòng)靜交界面,還需要執(zhí)行split命令使其網(wǎng)格獨(dú)立出來(lái),這里不需要Dict文件。
(7)mpirun -np 8 createNonConformalCouples -overwrite nonCouple1 nonCouple2 -parallel
創(chuàng)建動(dòng)靜交界面。
(8)decomposePar -fields -copyZero
-fields :僅利用現(xiàn)有幾何拆分文件和轉(zhuǎn)換場(chǎng);
-copyZero:復(fù)制0文件到每個(gè)塊內(nèi)而不是分解場(chǎng)。
(9)網(wǎng)格劃分結(jié)果
?

注意:如不進(jìn)行并行計(jì)算,snappyHexMesh后可以執(zhí)行reconstructParMesh -constant。
4 模型初始化及邊界條件定義
(1)邊界條件設(shè)置
邊界條件設(shè)置比較簡(jiǎn)單,重點(diǎn)介紹一下其中一個(gè)邊界條件設(shè)置:
movingWallVelocity:該類(lèi)型通常用于moving網(wǎng)格中的movingWal,根據(jù)網(wǎng)格的移動(dòng)會(huì)自動(dòng)修正通量值,這樣保障了網(wǎng)格移動(dòng)以后通過(guò)壁面的總通量為0。將movingWall設(shè)置成期望的速度,這里用$internalField,即0;
(2)動(dòng)網(wǎng)格設(shè)置dynamicMeshDict
螺旋槳的轉(zhuǎn)動(dòng)在dynamicMeshDict字典中定義。
mover
{
????type ???????????motionSolver;
????libs ???????????("libfvMeshMovers.so" "libfvMotionSolvers.so");
????motionSolver ???solidBody;
????cellZone ???????innerCylinder;
????solidBodyMotionFunction ?rotatingMotion;
????origin ?????(0 0 0);
????axis ???????(0 1 0);
????omega ??????158; // rad/s
(3)fvSchemes數(shù)值離散設(shè)置
fvSchemes文件用來(lái)設(shè)置離散格式,凡是求解器里面出現(xiàn)的方程,都需要在這里面設(shè)置離散格式。一般默認(rèn)即可。
(4)fvSolution方程求解器、殘差、算法控制
默認(rèn)即可。
(5)controlDict全局控制
application ????pimpleFoam;
startFrom ??????startTime;//還有firstTime和lastestTime
startTime ??????0;
stopAt ?????????endTime;
endTime ????????0.005;
deltaT ?????????1e-5; ?//時(shí)間步長(zhǎng)
writeControl ???adjustableRunTime; ?//輸出設(shè)置
writeInterval ??0.001; ?//每0.001s輸出1個(gè)文件
////- For testing with moveMesh
//deltaT ?????????0.01;
//writeControl ???timeStep;
//writeInterval ??1;
purgeWrite ?????0; ?//循環(huán)寫(xiě)入數(shù)據(jù)方式
writeFormat ????binary; ?//輸出二進(jìn)制文件
writePrecision ?6;
writeCompression off; ?//數(shù)據(jù)壓縮
timeFormat ?????general; //文件時(shí)間步命名
timePrecision ??6;
runTimeModifiable true;
adjustTimeStep ?yes; ?//是否開(kāi)啟可調(diào)節(jié)時(shí)間步長(zhǎng)
maxCo ??????????2; ?//最大庫(kù)郎數(shù)
functions ?????//需要添加的函數(shù)
{
????#includeFunc Q ??//計(jì)算Q值
????#include "surfaces"
????#include "forces"
}
5 后處理
對(duì)于水泵、水輪機(jī)、風(fēng)機(jī)的性能計(jì)算(以及在許多其他情況下),通常需要關(guān)于壓降、流量和功率的數(shù)據(jù)。如果計(jì)算空化問(wèn)題,還需要獲得壓力的最大值和最小值,同時(shí)最大值和最小值速度也可以說(shuō)明收斂或數(shù)值問(wèn)題。所有這些值最好在運(yùn)行時(shí)計(jì)算,因此最好如下所示定義controlDict.functionObjects:
1)轉(zhuǎn)矩
forces
{
????type ?????????forces;
????libs ?????????("libforces.so");
????writeControl ?timeStep;
????timeInterval ?1;
????log ??????????yes;
????patches ??????("propeller.*");
????rho ??????????rhoInf; ????// Indicates incompressible
????log ??????????true;
????rhoInf ???????998; ?????????// Redundant for incompressible
????CofR ?????????(0 0 0); ???// Rotation around centre line of propeller
????pitchAxis ????(0 1 0);
}
6?關(guān)于ESI版本的openfoam(如openfoam2206)
對(duì)于ESI版本的propeller算例,原理都是一樣的,如openfoam2206官方算例的做法是,通過(guò)topoSet的方式生成cyclicAMI、inlet和outlet的faceset,然后用createPatchDict將這些faceset定義為patch。
實(shí)際上,在openfoam2206中也能采用上面of10的方法,先通過(guò)snappyHexMesh生成網(wǎng)格,利用propeller-innerCylinder.obj生成facezone,然后輸入以下指令:
(1)createBaffles//生成cyclicAMI
(2)mergeOrSplitBaffles -split -overwrite//生成動(dòng)靜交界面
(3)renumberMesh -overwrite