月曜日, 7月 30, 2012

網模様4 : mesh textile 4


---------------------
これまで,いろんな細かなスクリプトを作ったが

結局 tetgen 用のファイルを簡単に用意すれば,
直方体くらいのメッシュはキッチリ切ってくれることがわかった.


---------------------

食べさせる poly ファイルを以下のように,用意.

# Part 1 - node list
8  3  0  0
   1    0.0      0.0     0.0
   2   100.0     0.0     0.0
   3   100.0   150.0     0.0
   4     0.0   150.0     0.0
   5    0.0      0.0   130.0
   6   100.0     0.0   130.0
   7   100.0   150.0   130.0
   8     0.0   150.0   130.0

# Part 2 - facet list
6 1
1 0  1
4  1   2    3   4
1 0  1
4  5   6    7   8
1 0  1
4  1   4   8   5
1 0  1
4  2   3   7   6
1 0  1
4  1    2    6   5
1 0  1
4  4    3    7    8

# Part 3 - hole list
0

# Part 4 - region list
0


で,コマンドラインから

 tetgen -pKa10 ./data/rect.poly

a10 は体積の拘束.


背景が背景だけに,見えにくいかなぁ.

---------------------

早速,スクリプト作成して,いつでもブロックを作れるように..

#!/bin/bash

#/-----------------------------------------------------------------------
#
#                                CreateRectangularParallelopipedVTK.sh
#                                      T.Y.   Mon. July 30, 2012
#/-----------------------------------------------------------------------

#-------------------------------------------------------
#----------  modify following parameters  --------------
#-------------------------------------------------------
####
x0=0.0
y0=0.0
z0=0.0
Lx=100.0
Ly=120.0
Lz=140.0
dL=20.0

####
FilePOLY="./data/box.poly"



#-------------------------------------------------------
#----------  display parameters  -----------------------
#-------------------------------------------------------
echo " "
echo "----------------------------------------"
echo "   CreateRectangularParallelopipedVTK.sh   "
echo "----------------------------------------"
echo " "
echo "input file : "${FilePOLY}
echo " "
echo "x0 : "${x0}
echo "y0 : "${y0}
echo "z0 : "${z0}
echo "Lx : "${Lx}
echo "Ly : "${Ly}
echo "Lz : "${Lz}
echo " "
echo "dL : "${dL}
dV=`echo " ${dL} * ${dL} * ${dL} * ( sqrt ( 2 ) ) / 12 " | bc`
echo "dV : "${dV}
echo " "



#-------------------------------------------------------
#----------  create poly file    -----------------------
#-------------------------------------------------------
echo "## box.poly " > ${FilePOLY}
echo "# Part 1 - node list" >> ${FilePOLY}
echo "8  3  0  0" >> ${FilePOLY}

x1=`echo " ${x0} + ${Lx} " | bc`
y1=`echo " ${y0} + ${Ly} " | bc`
z1=`echo " ${z0} + ${Lz} " | bc`

echo "   1  "${x0}" "${y0}" "${z0}" " >> ${FilePOLY}
echo "   2  "${x1}" "${y0}" "${z0}" " >> ${FilePOLY}
echo "   3  "${x1}" "${y1}" "${z0}" " >> ${FilePOLY}
echo "   4  "${x0}" "${y1}" "${z0}" " >> ${FilePOLY}
echo "   5  "${x0}" "${y0}" "${z1}" " >> ${FilePOLY}
echo "   6  "${x1}" "${y0}" "${z1}" " >> ${FilePOLY}
echo "   7  "${x1}" "${y1}" "${z1}" " >> ${FilePOLY}
echo "   8  "${x0}" "${y1}" "${z1}" " >> ${FilePOLY}

echo "" >> ${FilePOLY}
echo "# Part 2 - facet list" >> ${FilePOLY}
echo "6 1" >> ${FilePOLY}
echo "1 0  1" >> ${FilePOLY}
echo "4  1   2    3   4" >> ${FilePOLY}
echo "1 0  1" >> ${FilePOLY}
echo "4  5   6    7   8" >> ${FilePOLY}
echo "1 0  1" >> ${FilePOLY}
echo "4  1   4   8   5" >> ${FilePOLY}
echo "1 0  1" >> ${FilePOLY}
echo "4  2   3   7   6" >> ${FilePOLY}
echo "1 0  1" >> ${FilePOLY}
echo "4  1    2    6   5" >> ${FilePOLY}
echo "1 0  1" >> ${FilePOLY}
echo "4  4    3    7    8" >> ${FilePOLY}
echo "" >> ${FilePOLY}
echo "# Part 3 - hole list" >> ${FilePOLY}
echo "0" >> ${FilePOLY}
echo "" >> ${FilePOLY}
echo "# Part 4 - region list" >> ${FilePOLY}
echo "0" >> ${FilePOLY}
echo "" >> ${FilePOLY}
echo "" >> ${FilePOLY}

#-------------------------------------------------------
#----------  tetgen command    -------------------------
#-------------------------------------------------------
tetgen -pKa${dV} ${FilePOLY}


実行したら, box.1.vtk ができるので,
パラビューでみると


こんな感じ.

あとは,O/F フォーマットに適当にコンバートできればよいが,
側面境界の番号取得とか,ややこしそうだなぁ...

---------------------

---------------------

---------------------


0 件のコメント: