0%

laplacianFoam

背景介绍

导热问题,常发生在固体加热,此时由于介质均一,热量的传递仅由热扩散作用决定,因而可忽略对流的影响。

算法解析

基础知识

N-S方程:
$$
\rho(\frac{\partial \mathbf u}{\partial t}+\mathbf u \cdot\nabla\mathbf u)=-\nabla p+\mu\nabla^2\mathbf u\tag{1}
$$

$$
\nabla\cdot\mathbf u=0\tag{2}
$$

温度方程:
$$
\frac{\partial(\rho T)}{\partial t}+\nabla(\rho\mathbf U T)=\nabla\cdot(\frac{\lambda}{c_p}\nabla T)+S_T\tag{3}
$$

控制方程

在本文中,考虑非稳态导热问题,控制方程如下:
$$
\frac{\partial T}{\partial t}=\nabla\cdot(\frac \lambda {\rho c_p}) \tag{4}
$$

问题1:什么情况下散度加梯度等于拉普拉斯

代码解析

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
\*---------------------------------------------------------------------------*/

#include "fvCFD.H" //这个之前看过
#include "simpleControl.H" //SIMPLE控件类,用于为SIMPLE循环提供收敛信息检查

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
#include "setRootCase.H" //设置算例的根目录

#include "createTime.H" //创建时间对象
#include "createMesh.H" //创建网格对象
//include "createFields.H"
Info<< "Reading field T\n" << endl;

volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);


Info<< "Reading transportProperties\n" << endl;

IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);


Info<< "Reading diffusivity DT\n" << endl;

dimensionedScalar DT
(
transportProperties.lookup("DT")
);


simpleControl simple(mesh);

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nCalculating temperature distribution\n" << endl;

while (simple.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

while (simple.correctNonOrthogonal()) //Non-orthogonal corrector loop,解释如下
{
solve
(
fvm::ddt(T) - fvm::laplacian(DT, T)
);
}

#include "write.H"

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

return 0;
}


// ************************************************************************* //

correctNonorthogonal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
inline bool Foam::solutionControl::correctNonOrthogonal()
{
corrNonOrtho_++;

if (debug)
{
Info<< algorithmName_ << " correctNonOrthogonal: corrNonOrtho = "
<< corrNonOrtho_ << endl;
}

if (corrNonOrtho_ <= nNonOrthCorr_ + 1)
{
return true;
}
else
{
corrNonOrtho_ = 0;
return false;
}
}