CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Native Meshers: blockMesh (http://www.cfd-online.com/Forums/openfoam-meshing-blockmesh/)
-   -   A script for combining two blockMeshDict (http://www.cfd-online.com/Forums/openfoam-meshing-blockmesh/67795-script-combining-two-blockmeshdict.html)

yingfeng August 26, 2009 16:05

A script for combining two blockMeshDict
 
Sometimes I need to combine two blockMeshDict to create multi zone mesh or more complicated geometry. The vertex index in one of the dictionary has to be increased before you can copy and paste the text. Here is a short script I would like to share. Please feel free to improve and add more functionalities.

##/usr/bin/bash
# ./BlockMeshInc blockMeshDictUpper 100
#

if [ $# -eq 0 ]; then
echo 'Increase the point index of a BlockMeshDict for combining with another'
echo 'usage: BlockMeshInc blockMeshDict number'
exit 1
fi

sed -e 's/(\([0-9]\)/( \1/' -e 's/\([0-9]\))/\1 )/' $1 | \

awk -v N=$2 \
'
BEGIN {}
{if ($1=="hex") print "\t",$1,$2,$3+N,$4+N,$5+N,$6+N,$7+N,$8+N,$9+N,$10+ N,$11,$12,$13,$14,$15,$16,$17,$18}
{if ($1=="arc") print "\t",$1,$2+N,$3+N,$4,$5,$6,$7,$8}
{if ($1=="(" && $6 ==")") print "\t\t",$1,$2+N,$3+N,$4+N,$5+N,$6}
{if (NF==1 && $1!=");" || $1!=");" && $1!="(" && $1!="hex" && $1!="arc") print $0}
{if ($1=="(" && $5==")") print $0}
{if ($1==");") print $1}
END {}


All times are GMT -4. The time now is 22:53.