本案例演示利用OpenFOAM的icoFoam求解器计算弯曲管道中的混合流动问题。linux
启动终端,且拷贝tutorials文件夹中的文件。利用命令:shell
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/elbow/ $FOAM_RUN
将案例文件拷贝到了$FOAM_RUN路径中。ubuntu
此时能够利用命令查看目录结构:bash
tree $FOAM_RUN/elbow
查询结果以下图所示。app
$ tree $FOAM_RUN/elbow /home/ofuser/blueCFD/ofuser-of4/run/elbow ├── 0 │ ├── p │ └── U ├── Allclean ├── Allrun ├── constant │ └── transportProperties ├── elbow.msh └── system ├── controlDict ├── foamDataToFluentDict ├── fvSchemes └── fvSolution 3 directories, 10 files
包含三个文件夹:0、constant以及system。编辑器
案例中的网格使用的是msh文件,这里要经过命令将其转化为openfoam网格。工具
采用命令:code
cd $FOAM_RUN/elbow fluentMeshToFoam elbow.msh
以下图所示。orm
注:Fluent提供了众多的工具用于将外部网格文件转换为OpenFOAM网格ip
OpenFOAM的case组织结构如如所示。
包含三个基本文件夹:
本案例中0文件夹中包含两个文件:p文件与U文件,分别设置初始时刻的压力与速度。
利用文本编辑器打开p文件。在blueCFD中能够使用命令(先进入0目录,而后用nano打开p文件):
cd 0 nano p
注意:在不一样的linux系统中能够使用不一样的文本编辑器,如在ubuntu系统中,能够使用gedit、nano或vi
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 4.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField uniform 0; boundaryField { wall-4 { type zeroGradient; } velocity-inlet-5 { type zeroGradient; } velocity-inlet-6 { type zeroGradient; } pressure-outlet-7 { type fixedValue; value uniform 0; } wall-8 { type zeroGradient; } frontAndBackPlanes { type empty; } } // ************************************************************************* //
文件内容:
关于OpenFOAM中的边界类型:
当fixedvalue的值与internalField的值相同时,fixedValue边界与zeroGradient边界等效。
U文件中指定边界速度值。利用文本编辑器打开U文件。
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 4.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField uniform (0 0 0); boundaryField { wall-4 { type noSlip; } velocity-inlet-5 { type fixedValue; value uniform (1 0 0); } velocity-inlet-6 { type fixedValue; value uniform (0 3 0); } pressure-outlet-7 { type zeroGradient; } wall-8 { type noSlip; } frontAndBackPlanes { type empty; } } // ************************************************************************* //
文件中指定边界velocity-inlet-5的速度为x方向1m/s,velocity-inlet-6边界速度为y方向3m/s。
本案例中U文件不须要修改。
constant目录下保存了网格数据与物性参数等。
├── polyMesh │ ├── boundary │ ├── cellZones │ ├── faces │ ├── faceZones │ ├── neighbour │ ├── owner │ ├── points │ └── pointZones └── transportProperties 1 directory, 9 files
本案例中的网格来自于外部转化,所以不须要修改polyMesh文件夹中的内容。
transportProperties文件中存储了传输属性参数,用文本文件打开来看。
nano transportProperties
此文件的内容:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 4.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "constant"; object transportProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // nu [0 2 -1 0 0 0 0] 0.01; // ************************************************************************* //
此文件中只是定义了粘度为0.01 m2/s。在不可压缩流动中,只须要定义此参数。
system目录下包含四个文件。
. ├── controlDict ├── foamDataToFluentDict ├── fvSchemes └── fvSolution 0 directories, 4 files
本案例须要关注的是文件controlDict。用文本文件打开此文件,修改endTime为75。其余参数保持默认。
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 4.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application icoFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 75; deltaT 0.05; writeControl timeStep; writeInterval 20; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; // ************************************************************************* //
在case路径下输入命令:
icoFoam
计算自动进行,直至求解完成。
输入命令:
paraFoam
系统启动paraView进行后处理。
速度分布如图所示。
压力分布如图所示。