fvSchemes学习

# 1 前言

cd $FOAM_TUTORIALS grep -r "Schemes" * -h |sort -n|uniq 可以看到输出里面包含所有关键字： d2dt2Schemes ddtSchemes divSchemes echo "Modifying the fvSchemes to contain only default schemes" -e s/"$$fvSchemes[ \t]*$$$$[0-9]$$;"/"\1 1;"/g \ for FV_SC in find . -name fvSchemes gradSchemes gradSchemes { default Gauss linear; } integrationSchemes interpolationSchemes interpolationSchemes interpolationSchemes { default linear; } laplacianSchemes laplacianSchemes { default Gauss linear corrected; } * limited corrected 0.5 on all laplacianSchemes because the mesh is so poor object fvSchemes; SCHEMES_FILE="FvSchemes" SCHEMES_TEMP="FvSchemes.temp" setDefaultFvSchemes() setDefaultFvSchemes >>${FV_SC}
solver setting in fvSolution and a div(phi,age) scheme in fvSchemes.


d2dt2Schemes
ddtSchemes
divSchemes
interpolationSchemes
laplacianSchemes
snGradSchemes

1. banana方法
我是在wolf dynamic的教程中学到的，即将一个选项的值替换成一个肯定不存在的值，如banana，这样就可以从输出信息中找到有哪些选项。（当然在某些情况这个方法不起作用）
2. 利用Linux自身的强大查找命令，如grepfind...我还没怎么学会，平时就用用简单的grep。
3. 利用OpenFOAM自带命令，如foamInfofoamSearch等，缺点是说明比较少，不知道哪些能搜到哪些搜不到，一切随缘。常见用法，如：
 foamSearch $FOAM_TUTORIALS fvSchemes ddtSchemes.default foamSearch$FOAM_TUTORIALS fvSchemes "divSchemes.div(phi,U)"
foamSearch -c $FOAM_TUTORIALS fvSolution solvers.p.solver #-c 则会统计每个关键词信息出现的数量 foamSearch$FOAM_TUTORIALS RAS.RASModel turbulenceProperties
可见foamSearch这一命令用的好的话对学习OpenFOAM还是很有帮助的
4. 直接从代码里找？ 这个我没试过，因为C++还没到家，看着头疼，不过能看的懂代码的话应该会好很多。
5. Vim里的vim-OpenFoam-syntax插件，带有自动提示补全功能，有一定作用但需要有一些经验才能很好使用。

# 2 总览

## 2.1 文件实例

//文件说明
FoamFile
{
version     2.0;                //版本号
format      ascii;              //文本格式
class       dictionary;         //类型为字典文件
location    "system";           //所在目录
object      fvSchemes;          //对象名
}
//时间一阶导项(非定常项)格式
ddtSchemes
{
default         Euler;
}
//梯度项格式
{
default         Gauss linear;
}
//散度项格式
divSchemes
{
default         none;
}
//拉普拉斯项格式
laplacianSchemes
{
default         none;
laplacian(DT,T) Gauss linear corrected;
}
//插值格式
interpolationSchemes
{
default         linear;
}
//面法向梯度格式
{
default         corrected;
}
//需要用来计算通量的场
fluxRequired
{
default         no;
T;
}

## 2.2 keywords

interpolationSchemes 网格体心至面心插值格式
snGradSchemes 面法向梯度格式
timeScheme 时间导数项$\frac{\partial}{\partial t}$ $\frac{\partial ^2}{\partial t^2}$
divSchemes 散度(对流)项格式 $\nabla \cdot$
gradSchemes 梯度项格式$\nabla$
laplacianSchemes 拉普拉斯项格式$\nabla ^2$
fluxRequired 如(wallDist) 需要计算通量的场

Valid schemes are :

61
(
CoBlended
Gamma
GammaV
LUST
MUSCL
MUSCLV
Minmod
MinmodV
OSPRE
OSPREV
Phi
QUICK
QUICKV
SFCD
SFCDV
SuperBee
SuperBeeV
UMIST
UMISTV
biLinearFit
blended
cellCoBlended
clippedLinear
cubic
cubicUpwindFit
downwind
filteredLinear
filteredLinear2
filteredLinear2V
filteredLinear3
filteredLinear3V
fixedBlended
limitWith
limitedCubic
limitedCubicV
limitedLinear
limitedLinearV
limiterBlended
linear
linearFit
linearPureUpwindFit
linearUpwind
linearUpwindV
localBlended
localMax
localMin
midPoint
outletStabilised
pointLinear
reverseLinear
skewCorrected
upwind
vanLeer
vanLeerV
weighted
)


# 3 逐项分析

## 3.1 ddtSchemes $\frac{\partial }{\partial t}\left(\phi\right)$

Valid ddt schemes are :

8
(
CoEuler
CrankNicolson
Euler
SLTS
backward
bounded
localEuler
)

### 3.1.1 CoEuler

Courant number limited first-order Euler implicit/explicit ddt.
This scheme should only be used for steady-state computations using transient codes where local time-stepping is preferable to under-relaxation for transport consistency reasons.

default CoEuler phi rho 1;
• phiName: Name of the flux field used to calculate the local time-step
• rhoName: Name of the density field used to obtain the volumetric flux from the mass flux if required
• maxCo: Maximum local Courant number

### 3.1.2 CrankNicolson

Second-order Crank-Nicolson implicit ddt using the current and previous time-step fields as well as the previous time-step ddt.
The Crank-Nicolson scheme is often unstable for complex flows in complex geometries and it is necessary to "off-centre" the scheme to stabilize it while retaining greater temporal accuracy than the first-order Euler-implicit scheme. Off-centering is specified via the mandatory coefficient \c ocCoeff in the range [0,1] following the scheme name e.g.

default         CrankNicolson 0.9;

or with an optional "ramp" function to transition from the Euler scheme to Crank-Nicolson over a initial period to avoid start-up problems, e.g.

default         CrankNicolson
ocCoeff
{
type scale;
scale linearRamp;
duration 0.01;
value 0.9;
};

With a coefficient of 1 the scheme is fully centred and second-order, with a coefficient of 0 the scheme is equivalent to Euler-implicit. A coefficient of 0.9 has been found to be suitable for a range of cases for which higher-order accuracy in time is needed and provides similar accuracy and stability to the backward scheme. However, the backward scheme has been found to be more robust and provides formal second-order accuracy in time.

The advantage of the Crank-Nicolson scheme over backward is that only the new and old-time values are needed, the additional terms relating to the fluxes and sources are evaluated at the mid-point of the time-step which provides the opportunity to limit the fluxes in such a way as to ensure boundedness while maintaining greater accuracy in time compared to the Euler-implicit scheme. This approach is now used with MULES in the interFoam family of solvers. Boundedness cannot be guaranteed with the backward scheme.
Note: The Crank-Nicolson coefficient for the implicit part of the RHS is related to the off-centering coefficient by cnCoeff = 1.0/(1.0 + ocCoeff);

Forward Euler:
$$\frac{\partial }{\partial t}\left(\phi^{n}\right)\approx\frac{\phi^{n+1}-\phi^{n}}{\Delta t} \tag{3-1}$$

Backward Euler:
$$\frac{\partial }{\partial t}\left(\phi^{n}\right)\approx\frac{\phi^{n}-\phi^{n-1}}{\Delta t} \tag{3-2}$$

Fully centred CN: Forward Euler + Backward Euler:

$$\frac{\partial }{\partial t}\left(\phi^{n}\right)\approx\frac{\phi^{n+1}-\phi^{n}}{2\Delta t} +\frac{\phi^{n}-\phi^{n-1}}{2\Delta t}=\frac{\phi^{n+1}-\phi^{n-1}}{2\Delta t} \tag{3-3}$$

$$\frac{\partial }{\partial t}\left(\phi^{n}\right)\approx\frac{\lambda}{1+\lambda}\frac{\phi^{n+1}-\phi^{n}}{\Delta t}+\frac{1}{1+\lambda}\frac{\phi^{n}-\phi^{n-1}}{\Delta t} \tag{3-4}$$

Author:
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source zcp !

Valine utteranc.es
Previous
Airfoil optimization for Vertical Axis Hydrokinetic Turbine using genetic algorithm(4)---VATs simulation
Well, I'm just too lazy and so I'd like to end with this PowerPoint only. 这是嵌入 Microsoft Office 演示文稿，由 Office 提供
2020-01-04
Next
Airfoil optimization for Vertical Axis Hydrokinetic Turbine using genetic algorithm(3)---Evaluation of PARSEC parametrization
1 Evaluation of PARSEC parametrizationThe principles that parametrization technique should satisfy are: Minimize t
2019-12-11
TOC