OpenFOAM槽道流动怎么添加初始湍流脉动

OpenFOAM槽道流动怎么添加初始湍流脉动

   在槽道流动计算中,湍流状态是很难发生的,因为计算中扰动比较难发生,一般都是人工进行添加来进行计算,但是由于人工添加脉动可能在计算过程逐渐被耗散,因此需要一些专门方式来进行添加脉动。

boxTurb

  boxturb前处理工具1:不支持非均匀化网格,需要网格进行均匀化处理,最后mapFields到其他网格上去,进行继续计算。
  具体也可以参考A boxTurb16 and dnsFoam tutorial2简单的介绍。
  具体例子见此贴子3

Codestream

  EugeneDeVilliers博士论文提到的方法4,见章节5.1.2。
  代码解析:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
internalField   #codeStream
{
code
#{
const IOdictionary& d = static_cast<const IOdictionary&>(dict);
const objectRegistry& db = d.db();

const fvMesh& mesh = refCast<const fvMesh>(d.db());

volVectorField& fld =
const_cast<volVectorField&>(db.lookupObject<volVectorField>("U"));

// settings need modified start
// direction
direction streamDir = 0;
direction spanDir = 2;
direction heightDir = 1;
// half height
const scalar h = 1.0;
const scalar Um = 0.4;
const scalar Retau = 1000;
const scalar nu = 2e-5;
const scalar utau = Retau*nu/h;
// settings need modified end

// spanwise wavenumber: spacing z+ = 200
const scalar betaPlus = 2.0*constant::mathematical::pi*(1.0/200.0);
// streamwise wave number: spacing x+ = 500
const scalar alphaPlus = 2.0*constant::mathematical::pi*(1.0/500.0);
const scalar sigma = 0.00055;
const scalar epsilon = Um/200.0;
const scalar duplus = Um*0.25/utau; //具体见Eugene De Villiers的博士论文

const bool setBulk = true;
const bool perturb = true;

// Random number generator
Random perturbation(1234567);

const vectorField& centres = mesh.C();

forAll(centres, celli)
{
// add a small (+/-20%) random component to enhance symetry breaking
scalar deviation=1.0 + 0.2*perturbation.GaussNormal<scalar>();

const vector& cCentre = centres[celli];

scalar zplus = cCentre[spanDir]*Retau/h;
scalar y = min(cCentre[heightDir], 2*h-cCentre[heightDir]);
scalar yplus = y*Retau/h;
scalar xplus = cCentre[streamDir]*Retau/h;

if (setBulk)
{
// laminar parabolic profile
fld[celli] = vector::zero;

fld[celli][streamDir] =
3.0*Um * (y/h - 0.5*sqr(y/h));
// Blasius Um*( 5/4*(1-pow(zloc-1,4)));
}

if (perturb)
{
// streak streamwise velocity
fld[celli][streamDir] +=
(utau * duplus/2.0) * (yplus/40.0)
* Foam::exp(-sigma * Foam::sqr(yplus) + 0.5)
* Foam::cos(betaPlus*zplus)*deviation;

// streak spanwise perturbation
fld[celli][spanDir] =
epsilon
* Foam::sin(alphaPlus*xplus)
* yplus
* Foam::exp(-sigma*Foam::sqr(yplus))
* deviation;
}
}
fld.writeEntry("", os);
// os << fld.internalField();

#};

codeInclude
#{
#include "fvCFD.H"
#};

codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#};

codeLibs
#{
-lfiniteVolume \
-lmeshTools
#};

};

  按照代码说明把需要改的参数改好,将上述代码写入算例/0/U文件中,即可计算,具体效果如下图。

利用CodeStream生成的湍流

mapFields

  The mapFields function object maps input fields from local mesh to secondary mesh at runtime. mapFields 可以使得之前的湍流流场(速度场和压力场)插值到新算例中,从来进行计算,这样计算大大增加了计算速度,可以很快地出现湍流现象。
  格式如下:
  Usage: mapFields [OPTIONS] <sourceCase>7
  Options的选项:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-case <dir>       Specify case directory to use (instead of cwd)
-consistent Source and target geometry and boundary conditions identical
-mapMethod <word>
Specify the mapping method
-parallelSource The source is decomposed
-parallelTarget The target is decomposed
-sourceDecomposeParDict <file> Read decomposePar dictionary from specified location
-sourceRegion <word>
Specify the source region
-sourceTime <scalar|'latestTime'>
Specify the source time
-subtract Subtract mapped source from target
-targetDecomposeParDict <file>
Read decomposePar dictionary from specified location
-targetRegion <word>
Specify the target region
-doc Display documentation in browser
-help Display short help and exit
-help-full Display full help and exit

Map volume fields from one mesh to another

Using: OpenFOAM-v2206 (2206) - visit www.openfoam.com

  其中需要注意的是:consistent代表的是几何条件和边界条件都相同的时候使用,当不相同的时候(比如在使用光滑算例插值到有结构的算例中去的时候,就不能使用consistent Options)8

参考链接

Buy me a coffee
OYYO WeChat Pay WeChat Pay