OpenFOAM中网格局部加密

为了降低整体的网格数量,同时保证局部高Re数区域的精确求解,我们往往需要对网格的局部进行加密。Google了很久也没有找到可行的blockMesh方案,但最后在OpenFOAM自带的tutorial里发现了一个局部网格加密的例子,这里和大家分享一下。

加密前的网格


Old Mesh

加密后的网格


Refined Mesh

Case路径$FOAM_TUTORIALS/mesh/refineMesh

#!/bin/sh
cd "${0%/*}" || exit                                # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions        # Tutorial run functions
#------------------------------------------------------------------------------

wmake calcRadiusField # 编译calcRadiusField文件,用于计算网格的轴向、径向、轴向的方向
wclean calcRadiusField

runApplication blockMesh

##### Procedure for special refinement over Z

# We need the 0 folder to exist for these steps
mkdir 0

# Refine over Z, in 6 passes
for index in 1 2 3 4 5 6
do

  runApplication -s tier$index  calcRadiusField # 计算方向角

  runApplication -s tier$index \
      topoSet -dict system/topoSetDict.tier$index # 选定区域

  ## foamToVTK -cellSet tier$index

  runApplication -s tier$index \
      refineMesh -dict system/refineMeshDict.tier$index -overwrite  # 在选定区域内加密网格

  rm -r 0/*

done

# Refine over cylindrical coordinates, in 3 passes
for index in 1 2 3
do

  runApplication -s range$index  calcRadiusField -calcDirections

  runApplication -s range$index \
      topoSet -dict system/topoSetDict.range$index

  ## foamToVTK -cellSet tier$index

  runApplication -s range$index \
      refineMesh -dict system/refineMeshDict.range$index -overwrite

  rm -r 0/*

done

#------------------------------------------------------------------------------

你可能感兴趣的:(OpenFOAM中网格局部加密)