OpenFOAM中divDevRhoReff和divDevReff详解

OpenFOAM中divDevRhoReff和divDevReff具体是啥?

先看动量方程:

$$\frac{\partial \rho \mathbf{U}}{\partial t}+\nabla \cdot \left( \rho \mathbf{UU} \right)=\nabla \cdot \sigma +\mathbf{f} \tag{1}$$                       

其中应力张量:

$$\begin{equation}\begin{split} \sigma &=-\left( p+\frac{2}{3}\mu \nabla \cdot \mathbf{U} \right)\mathbf{I}+\mu \left[ \nabla \mathbf{U}+{{\left( \nabla \mathbf{U} \right)}^{\text{T}}} \right] \\ & \text{  }\\&=-p\mathbf{I}-\frac{2}{3}\mu \nabla \cdot \mathbf{UI}+\mu \nabla \mathbf{U}+\mu {{\left( \nabla \mathbf{U} \right)}^{\text{T}}} \\ \end{split}\end{equation} \tag{2}$$                                                

将公式(2)带入(1)可得:

$$\frac{\partial \rho \mathbf{U}}{\partial t}+\nabla \cdot \left( \rho \mathbf{UU} \right)=\nabla \cdot \left[ -p\mathbf{I}-\frac{2}{3}\mu \nabla \cdot \mathbf{UI}+\mu \nabla \mathbf{U}+\mu {{\left( \nabla \mathbf{U} \right)}^{\text{T}}} \right]+\mathbf{f} \tag{3}$$                       

后边的推导过程仅看公式(3)中右边的第一项:

$$\text{RHS}=\nabla \cdot \left( -p\mathbf{I} \right)+\nabla \cdot \left[ -\frac{2}{3}\mu \nabla \cdot \mathbf{UI}+\mu \nabla \mathbf{U}+\mu {{\left( \nabla \mathbf{U} \right)}^{\text{T}}} \right] \tag{4} $$                                            

公式(4)中第一项为压力梯度:

$$\nabla \cdot \left( -p\mathbf{I} \right)=-\nabla p \tag{5}    $$                                                                                                          

推导过程为:

$$\begin{align}  \nabla \cdot \left( -p\mathbf{I} \right)&=\nabla \cdot \left[ -p\left( \begin{matrix}1 & 0 & 0  \\0 & 1 & 0  \\0 & 0 & 1  \\\end{matrix} \right) \right]=\nabla \cdot \left( \begin{matrix} -p & 0 & 0  \\ 0 & -p & 0  \\ 0 & 0 & -p  \\\end{matrix} \right) \\& \text{               =}\left[ \begin{matrix} \left( -\frac{\partial p}{\partial x} \right)+0+0  \\ 0+\left( -\frac{\partial p}{\partial y} \right)+0  \\0+0+\left( -\frac{\partial p}{\partial z} \right)  \\\end{matrix} \right]=\left( \begin{matrix} -\frac{\partial p}{\partial x}  \\-\frac{\partial p}{\partial y}  \\-\frac{\partial p}{\partial z}  \\\end{matrix} \right)=-\nabla p \\\end{align}$$

公式(4)中第二项括号内的内容通常用\tau表示,代表粘性应力张量:

$$ \nabla \cdot \tau =\nabla \cdot \left[ -\frac{2}{3}\mu \nabla \cdot \mathbf{UI}+\mu \nabla \mathbf{U}+\mu {{\left( \nabla \mathbf{U} \right)}^{\text{T}}} \right]   \tag{6}   $$                                                                

公式(6)在OpenFOAM中可通过调用divDevRhoReff(U)或divDevReff(U)函数来进行计算,前者是可压缩时调用的函数,后者是不可压缩时调用的函数。下面分别进行介绍。

 

可压缩

在可压缩中计算公式调用的是divDevRhoReff(U),其代码为:

tmplamina::divDevRhoReff(volVectorField &U) const

{

         Return

         (

             -fvm::laplacian(muEff(), U)

             -fvc::div(muEff()*dev2(T(fvc::grad(U))))

          )

}

对比代码和公式(6)发现二者并不对应,这是什么原因呢?下面通过公式(6)的进一步推导来进行解释。在推导公式(6)之前需要先看一个数学恒等式,后边推导会用到,这个恒等式为:

$$\nabla \cdot \mathbf{a}=tr\left( \nabla \mathbf{a} \right)=tr{{\left( \nabla \mathbf{a} \right)}^{\text{T}}}\    \tag{7}$$                                                                                                                       

其中\mathbf{a}={{a}_{1}}\mathbf{i}+{{a}_{2}}\mathbf{j}+{{a}_{3}}\mathbf{k}$为任意矢量。上式的证明如下:

因为

$$\begin{align}& \nabla \mathbf{a}=\left( \frac{\partial }{\partial x}\mathbf{i}+\frac{\partial }{\partial y}\mathbf{j}+\frac{\partial }{\partial z}\mathbf{k} \right)\left( {{a}_{1}}\mathbf{i}+{{a}_{2}}\mathbf{j}+{{a}_{3}}\mathbf{k} \right) \\& \text{      =}\left[ \begin{matrix} \frac{\partial {{a}_{1}}}{\partial x} & \frac{\partial {{a}_{2}}}{\partial x} & \frac{\partial {{a}_{3}}}{\partial x}  \\\frac{\partial {{a}_{1}}}{\partial y} & \frac{\partial {{a}_{2}}}{\partial y} & \frac{\partial {{a}_{3}}}{\partial y}  \\\frac{\partial {{a}_{1}}}{\partial z} & \frac{\partial {{a}_{2}}}{\partial z} & \frac{\partial {{a}_{3}}}{\partial z}  \\\end{matrix} \right] \\\end{align}$$

所以

$$tr\left( \nabla \mathbf{a} \right)=\frac{\partial {{a}_{1}}}{\partial x}+\frac{\partial {{a}_{2}}}{\partial y}+\frac{\partial {{a}_{3}}}{\partial z}=\nabla \cdot \mathbf{a}$$

又因为

$$tr\left( \nabla \mathbf{a} \right)=tr{{\left( \nabla \mathbf{a} \right)}^{\text{T}}}$$

所以公式(7)得证。通过公式(7)可将公式(6)重新整理为:

$$ \nabla \cdot \tau =\nabla \cdot \left[ \mu \nabla \mathbf{U}+\mu \left( {{\left( \nabla \mathbf{U} \right)}^{\text{T}}}-\frac{2}{3}tr{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}\mathbf{I} \right) \right]      \tag{8}     $$                                                                   

$$\nabla \cdot \tau =\nabla \cdot \left( \mu \nabla \mathbf{U} \right)+\nabla \cdot \left[ \mu \left( {{\left( \nabla \mathbf{U} \right)}^{\text{T}}}-\frac{2}{3}tr{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}\mathbf{I} \right) \right]       \tag{9}       $$                      

{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}=A,则式(9)变为:

$$ \nabla \cdot \tau =\nabla \cdot \left( \mu \nabla \mathbf{U} \right)+\nabla \cdot \left[ \mu \left( A-\frac{2}{3}tr\left( A \right)\mathbf{I} \right) \right]     \tag{10}   $$                                                                            

这里需要矩阵的知识,矩阵的偏置为:

$$\begin{align}& dev\left( A \right)=A-\frac{1}{3}tr\left( A \right)\mathbf{I} \\& dev2\left( A \right)=A-\frac{2}{3}tr\left( A \right)\mathbf{I}\\\end{align} \tag{11}     $$                                                                                                                   

因为公式(10)中前的系数为-\frac{2}{3},所以调用的是dev2(),可以看出公式(10)与代码是对应的,负号的差别是因为代码中将公式(10)移到了动量方程的左边。

 

不可压缩

在不可压中,计算公式调用的是divDevReff(U),其代码为:

tmplamina::divDevReff(volVectorField &U) const

{

         Return

         (

             -fvm::laplacian(nuEff(), U)

             -fvc::div(nuEff()*dev(T(fvc::grad(U))))

         )

}

下面进行推导,将公式(6)重写为不可压的形式:

 $$   \nabla \cdot \tau =\nabla \cdot \left[ -\frac{2}{3}\nu \nabla \cdot \mathbf{UI}+\nu \nabla \mathbf{U}+\nu {{\left( \nabla \mathbf{U} \right)}^{\text{T}}} \right] \tag{12}             $$                                                                      

由于不可压中质量守恒,所以:

  $$       \nabla \cdot \mathbf{U}=0        \tag{13}       $$                                                                           

将式(13)代入(12)可得:

$$ \nabla \cdot \tau =\nabla \cdot \left[ \nu \nabla \mathbf{U}+\nu {{\left( \nabla \mathbf{U} \right)}^{\text{T}}} \right]     \tag{14}      $$                                                                                                         

$$ \nabla \cdot \tau =\nabla \cdot \left( \nu \nabla \mathbf{U} \right)+\nabla \cdot \left[ \nu {{\left( \nabla \mathbf{U} \right)}^{\text{T}}} \right]     \tag{15}    $$                                                                                                

可以看到在公式(15)中是没有偏置部分的,但在OpenFOAM中,我们用divDevReff计算粘性应力张量\tau,所以构造以下方程:

  $$  \nabla \cdot \tau =\nabla \cdot \left( \nu \nabla \mathbf{U} \right)+\nabla \cdot \left[ \nu {{\left( \nabla \mathbf{U} \right)}^{\text{T}}}-\nu \frac{1}{3}tr{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}\mathbf{I}+\nu \frac{1}{3}tr{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}\mathbf{I} \right]    \tag{16}   $$                            

将公式(16)整理为:

$$   \nabla \cdot \tau =\nabla \cdot \left( \nu \nabla \mathbf{U} \right)+\nabla \cdot \left[ \nu \left( {{\left( \nabla \mathbf{U} \right)}^{\text{T}}}-\frac{1}{3}tr{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}\mathbf{I} \right)+\nu \frac{1}{3}tr{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}\mathbf{I} \right]  \tag{17}   $$                            

公式(17)中最后一项为0,因为:

$$\nu \frac{1}{3}tr{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}\mathbf{I}=\nu \frac{1}{3}tr\left( \nabla \mathbf{U} \right)\mathbf{I}=\nu \frac{1}{3}\nabla \cdot \mathbf{UI}=0$$

所以公式(17)可整理为:

  $$  \nabla \cdot \tau =\nabla \cdot \left( \nu \nabla \mathbf{U} \right)+\nabla \cdot \left[ \nu \left( {{\left( \nabla \mathbf{U} \right)}^{\text{T}}}-\frac{1}{3}tr{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}\mathbf{I} \right) \right]  \tag{18}  $$                                                              

同样假定{{\left( \nabla \mathbf{U} \right)}^{\text{T}}}=A,所以公式(18)变为:

$$  \nabla \cdot \tau =\nabla \cdot \left( \nu \nabla \mathbf{U} \right)+\nabla \cdot \left[ \nu \left( A-\frac{1}{3}tr\left( A \right)\mathbf{I} \right) \right]        \tag{19}   $$                                                                        

将公式(11)中对应的公式代入式(19)可得:

 $$    \nabla \cdot \tau =\nabla \cdot \left( \nu \nabla \mathbf{U} \right)+\nabla \cdot \left[ \nu \left( dev\left( A \right) \right) \right]      \tag{20}       $$                                                                            

可以看出公式(20)与代码是对应的。

 

你可能感兴趣的:(OpenFOAM)