OpenFoam中有很多自带的小工具,方便实用。有需要的小伙伴可以自己去下面查找,方法如下:
hty@ubuntu:~$ util
hty@ubuntu:/opt/openfoam4/applications/utilities$ ls
mesh parallelProcessing preProcessing thermophysical
miscellaneous postProcessing surface
hty@ubuntu:/opt/openfoam4/applications/utilities$
已经有博主分类整理了OpenFOAM 工具列表,并给出了每个小工具的简单介绍,需要的请自行查看。
下面将几种常用的工具初步整理如下,后续会陆续更新。有整理好的小伙伴可以call我,将不胜感激。
文章目录
1. Co
C o = δ t ∣ U ∣ δ x Co=\frac{\delta t|\mathbf U|}{\delta x} Co=δxδt∣U∣
2. vorticity(速度场的旋度)
3. yPlus
y+
值非常重要,因为它可以反映网格网格正确解析边界层。通常,你也可以使用壁函数,否则在粘性子层处使用y+<5。yPlus计算并报告所有近壁单元格的y+墙修补程序,用于层流、LES和RAS的指定时间。对于应用墙功能的墙,墙函数提供y+值,否则直接获得从近壁速度梯度和有效层流粘度学。
4. sample
- 示例实用程序用于生成图像或提取曲面。
- 为了使用它,案例文件夹下需要有一个
system/simpleDict
文件。 - 键入
sample-help
获取可选的flag。
5. foamCalc
对场进行操作:
foamCalc <calcType> <fieldName1 ... fieldnameN>
calcType 包括:
- div:场的散度,需要注意 fvScheme,规定了计算散度所必须的格式;
- magSqr:幅值的平方
- mag:幅值
- grad:场的梯度
- components:提取场的一部分
6. probeLocations
- 对固定位置在时间上进行连续采样;
- 案例文件夹下需要有一个
system/simpleDict
文件; - 需要对采样场和采样点进行声明;
fields//声明采样场
(
p
):
probeLocations//声明采样点
(
0.2 0.2 0.2
);
7. topoSet
通过字典文件对网格序列(点、面、网格)进行操作;
需要 topoSetDict 文件;
actions
(
{
name c0;
type cellSet;
action new;
source boxTocell;
sourceInfo
{
box (0.3 0.3 0.3) (0.6 0.6 0);
}
}
);
action
种类:
- clear:清除
- invert:倒转,将未选中的元素选中,选中的元素重置为未选中
- remove:移除
- new +source:创建新的设置或源
- add+source:添加源
- delete+source:删除源
源的操作类型:
- labelToCell:从给定的标签中选择单元格。
- cellToCell:从单元格集中复制元素。
- zoneToCell:选择单元格区域中的单元格。
- faceToCell: 从面中选择单元(所有者或邻居)
- boxToCell:选择框中的单元格。
- cylinderToCell:选择中心位于圆柱体内的单元格。
- sphereToCell:选择中心位于球体内的单元。
- nearestToCell:选择单元格中心最接近的单元格协调。
- fieldToCell:选择字段值在一定范围的单元格。
8. setFields
主要用于多相流模型,重新定义场量信息。
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object setFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defaultFieldValues
(
volScalarFieldValue alpha.air 1
volScalarFieldValue alpha.water 0
);
regions
(
boxToCell
{
box (0 0 0) (0.01 0.05 0.01);//对体中心在该范围的网格单元
fieldValues
(
volScalarFieldValue alpha.air 0
volScalarFieldValue alpha.water 0
);
}
);
// ************************************************************************* //
9. checkMesh
用于检查网格质量,输出信息如下:
[stu cavity]$ checkMesh
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 4.1
Exec : checkMesh
Date : Sep 28 2020
Time : 21:37:29
Host : "node01"
PID : 151764
Case : /home/student2/OpenFOAM/student2-4.1/run/cavity
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time
Create polyMesh for time = 0
Time = 0
Mesh stats
points: 882
internal points: 0
faces: 1640
internal faces: 760
cells: 400
faces per cell: 6
boundary patches: 3
point zones: 0
face zones: 0
cell zones: 0
Overall number of cells of each type:
hexahedra: 400
prisms: 0
wedges: 0
pyramids: 0
tet wedges: 0
tetrahedra: 0
polyhedra: 0
Checking topology...
Boundary definition OK.
Cell to face addressing OK.
Point usage OK.
Upper triangular ordering OK.
Face vertices OK.
Number of regions: 1 (OK).
Checking patch topology for multiply connected surfaces...
Patch Faces Points Surface topology
movingWall 20 42 ok (non-closed singly connected)
fixedWalls 60 122 ok (non-closed singly connected)
frontAndBack 800 882 ok (non-closed singly connected)
Checking geometry...
Overall domain bounding box (0 0 0) (0.1 0.1 0.01)
Mesh has 2 geometric (non-empty/wedge) directions (1 1 0)
Mesh has 2 solution (non-empty) directions (1 1 0)
All edges aligned with or perpendicular to non-empty directions.
Boundary openness (8.47033e-18 -8.47033e-18 -4.51751e-17) OK.
Max cell openness = 1.35525e-16 OK.
Max aspect ratio = 1 OK.//长宽比
Minimum face area = 2.5e-05. Maximum face area = 5e-05. Face area magnitudes OK.
Min volume = 2.5e-07. Max volume = 2.5e-07. Total volume = 0.0001. Cell volumes OK.
Mesh non-orthogonality Max: 0 average: 0//非正交网格数
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 1.66533e-14 OK.//网格偏斜情况
Coupled point location match (average 0) OK.
Mesh OK.
End
10. transformPoints
用于网格的移动、比例放大及旋转。
- translate+vector:沿给定矢量方向移动;
- rotate+(vector vector):将点沿第一个矢量向第二个矢量旋转;
- scale+vector:根据规定矢量对网格单元进行比例放大或缩小。
[stu run]$ ls
cavity
[stu run]$ cp -r cavity cavityTranslate
[stu run]$ touch cavityTranslate/cavityTranslate.OpenFAOM //创建一个可供paraview打开的文件
[stu run]$ transformPoints -case cavityTranslate/ -translate "(0.2 0.2 0.2)" //对网格单元进行平移
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 4.1
Exec : transformPoints -case cavityTranslate/ -translate (0.2 0.2 0.2)
Date : Sep 28 2020
Time : 22:03:41
Host : "node01"
PID : 152372
Case : ./cavityTranslate
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time
Translating points by (0.2 0.2 0.2)
Writing points into directory "./cavityTranslate/constant/polyMesh"
End
[stu run]$ paraview //打开paraview,比较两者差距
11. createBaffles
- 将内部面转换为两个没有厚度的边界面,或者将多个边界面转化为一个边界面;
- 可以在这个面上添加边界条件。
createBafflesDict
/*--------------------------------*- 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;
object createBafflesDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sample for creating baffles:
// - usually converting internal faces into two boundary faces
// - or converting boundary faces into a boundary face
// (internalFacesOnly=false)(though should use really createPatch
// to do this)
//
// - selection of faces (and orientation) to 'baffle' through:
// faceZone:
// type faceZone;
// zoneName f0;
// searchableSurface:
// type searchableSurface;
// surface triSurfaceMesh;
// name baffle1D.stl;
//
// - specification of patches for baffle sides in one of two modes:
// - patchPairs : create two patches of same type, same input
// - patches : create patches separately, full control over what
// to create on what side
// (this mode can also create duplicate (overlapping)
// sets of baffles:
// - internalFacesOnly = false
// - have 4 entries in patches:
// - master
// - slave
// - additional master
// - additional slave)
// Whether to convert internal faces only (so leave boundary faces intact).
// This is only relevant if your face selection type can pick up boundary
// faces.
internalFacesOnly true;
// Optionally do not read/convert/write any fields.
//noFields true;
// Baffles to create.
baffles
{
baffle1
{
//- Use surface to select faces and orientation.
type searchableSurface;
surface triSurfaceMesh;
name baffle1D.stl;
//- Optional flip
//flip false;
// Generate patchGroup baffle1 with two patches:
// - baffle1_master
// - baffle1_slave
patchPairs
{
type wall;
//- Optional override of added patchfields. If not specified
// any added patchfields are of type calculated.
patchFields
{
U
{
type fixedValue;
value uniform (0 0 0);
}
}
}
}
cyclicFaces//cyclic:周期性条件
{
//- Select faces and orientation through a searchableSurface
type searchableSurface;
surface searchablePlate;
origin (0.099 -0.006 0.004);
span (0 0.012 0.012);
// Generate patches explicitly
patches
{
master
{
//- Master side patch
name fan_half0;
type cyclic;
neighbourPatch fan_half1;
patchFields
{
p
{
type fan;
patchType cyclic;
jump uniform 0;
value uniform 0;
jumpTable polynomial 1((100 0));
}
}
}
slave
{
//- Slave side patch
name fan_half1;
type cyclic;
neighbourPatch fan_half0;
patchFields
{
p
{
type fan;
patchType cyclic;
value uniform 0;
}
}
}
}
}
}
// ************************************************************************* //
12. refineMesh
加密网格
- 可以直接使用 refineMesh
refineMesh -overwrite//对原网格进行覆盖、重写加密,这样就不会生成新的文件夹
- 也可以使用 refineMeshDict:
/*--------------------------------*- 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;
object refineMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Cells to refine; name of cell set
set c0;// 涉及到 topoSet
// Type of coordinate system:
// - global : coordinate system same for every cell. Usually aligned with
// x,y,z axis. Specify in globalCoeffs section below.
// - patchLocal : coordinate system different for every cell. Specify in
// patchLocalCoeffs section below.
// - fieldBased : uses the list of field names from the directions list for
// selecting the directions to cut. Meant to be used with geometricCut, but
// can also be used with useHexTopology.
coordinateSystem global;
//coordinateSystem patchLocal;
//coordinateSystem fieldBased;
// .. and its coefficients. x,y in this case. (normal direction is calculated
// as tan1^tan2)
globalCoeffs
{
tan1 (1 0 0);
tan2 (0 1 0);
}
patchLocalCoeffs
{
patch outside; // Normal direction is facenormal of zero'th face of patch
tan1 (1 0 0);
}
// List of directions to refine, if global or patchLocal
directions
(
tan1
tan2
normal
);
// List of directions to refine, if "fieldBased". Keep in mind that these
// fields must be of type "vectorField", not "volVectorField".
//directions
//(
// radialDirectionFieldName
// angularDirectionFieldName
// heightDirectionFieldName
//);
// Whether to use hex topology. This will
// - if patchLocal: all cells on selected patch should be hex
// - split all hexes in 2x2x2 through the middle of edges.
useHexTopology true;
// Cut purely geometric (will cut hexes through vertices) or take topology
// into account. Incompatible with useHexTopology
geometricCut false;
// Write meshes from intermediate steps
writeMesh false;
// ************************************************************************* //
13. mapFields
mapFields 指令可以把一个给定几何的场信息,映射到另一个几何的对应场。它通过读取被映射场(target
)算例 controlDict
文件startFrom/startTime
中指定的时间步文件夹,对原始场(source
)进行映射。详情可参考mapFields–场映射指令