atat-mirror/glue/pandat/pandat2vtk

39 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

2023-08-31 20:30:18 +02:00
#!/bin/bash
cat $1/section_default_?/Table/Default.table $1/section_default_??/Table/Default.table |\
grep -v -e "xml" -e "mole" -e "Default" | sed -e 's/x00[0-9][0-9]//g' -e 's/G=.*//g' |\
grep -v 'f____[^=]*__="[^"][^"]' |\
sed -e 's/f[^=]*="0"//g' -e 's/f[^=]*=""//g' -e 's/f____\([^=]*\)__="1"/onephase="\1"/g' -e 's/phase_name="[^"]*"//g' -e 's/=""/="0"/g' |\
sed -e 's/[^"]*"\([^"]*\)"/\1 /g' -e 's+ *<default />++g' | awk 'BEGIN {last=""} {if (last!="" && $5!="" && $5!=last) {print "";} last=$5; print $0}' | \
awk 'BEGIN {getline; print $0; l2=$0; getline; l1=$0} {if ($0!="" || l2!="") {print l1;} else {l2=l1; l1=$0; getline;}; l2=l1; l1=$0} END {if (l2!="") {print l1;}}' > alltables.tmp
awk '{if ($5!="") {file="phase_" $5 ".out"; print $1,$2,$3,$4 > file;} else {print "" > file}}' alltables.tmp
#rm alltables.tmp
col=0
for file in phase_*.out
do
echo $file
triph -bf -sc=$2 -col=$col -t=$file > $(echo $file | sed 's/.out/.vtk/g')
col=$((col+1))
done
cat $1/section_default_?/Table/tieline.table $1/section_default_??/Table/tieline.table |\
sed 's/""/"0"/g' | grep -v -e "xml" -e "mole" | grep '"' | sed -e 's/[^"]*"\([^"]*\)"/\1 /g' -e 's+ */>++g' | awk '{print $2,$1,$3,$4,$5}' > alltielines.tmp
cat - > tielines.vtk <<EOF
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
EOF
echo POINTS `cat alltielines.tmp | wc -l` float >> tielines.vtk
awk '{print $2/'$2',$3+$4/2.,$4*sqrt(3.)/2.}' alltielines.tmp >> tielines.vtk
echo LINES `cat alltielines.tmp | wc -l | awk '{print $1/2,$1/2*3}'` >> tielines.vtk
awk 'BEGIN {n=0} {getline; print 2,n,n+1; n+=2;}' alltielines.tmp >> tielines.vtk
#rm alltielines.tmp