#!/bin/csh -f
#
# shell script for generating a pin for the connector problem
# usage: pin <xo> <yo> <zo> <relperm_at_sleeve> <id> <passed_directly>
#  all args must be given always (interface does no error checking)
#  use passed directly arg as "-d" to turn off all discretization (for plots)
#  called by script `connector4' 
#  requires input file generators `pyragen' and `cubegen'
#
set bindir = "../bin/"
set pyragen = "${bindir}pyragen"
set cubegen = "${bindir}cubegen"
set xh = 1.3
set yh = 1.3
set xyh = "-xh${xh} -yh${yh}"
set pnth = 1.0
set offset = "$1 $2 $3"
set ex = $1$2$3$4$5$6
set refpnt = "0.0 0.0 2.5"
#
# top end
${pyragen} -b -zo20.2 ${xyh} -zh${pnth} $6 > pin_end1${ex}.qui
# long tube
${cubegen} -t -b -zo5.2 ${xyh} -zh15.0 $6 > pin_long${ex}.qui
# sleeve
${cubegen} -t -b ${xyh} -zh5.2 $6 > pin_sleeve${ex}.qui
# short tube
${cubegen} -t -b -zo-7.0 ${xyh} -zh7.0 $6 > pin_short${ex}.qui
# bottom end
${pyragen} -b -zo-7.0 ${xyh} -zh-${pnth} $6 > pin_end2${ex}.qui
#### dielectric panels on back of conductor
# small panel, above pin
${cubegen} -p -yo1.3 -xh1.3 -yh2.6 -zh5.2 -e0 -n2 $6 > pin_sm_a${ex}.qui
# small panel, below pin
${cubegen} -p -yo-2.6 -xh1.3 -yh2.6 -zh5.2 -e0 -n2 $6 > pin_sm_b${ex}.qui
# big panel, left of pin
${cubegen} -p -yo-2.6 -xo-2.6 -xh2.6 -yh6.5 -zh5.2 -e0 -n4 $6 > pin_big_l${ex}.qui
# big panel, right of pin
${cubegen} -p -yo-2.6 -xo1.3 -xh2.6 -yh6.5 -zh5.2 -e0 -n4 $6 > pin_big_r${ex}.qui
#
# write list file
#
echo "* pin${ex}.lst" > pin${ex}.lst
echo "C pin_end1${ex}.qui 1.0 ${offset} +" >> pin${ex}.lst
echo "C pin_long${ex}.qui 1.0 ${offset} +" >> pin${ex}.lst
echo "C pin_sleeve${ex}.qui $4 ${offset} +" >> pin${ex}.lst
echo "C pin_short${ex}.qui 1.0 ${offset} +" >> pin${ex}.lst
echo "C pin_end2${ex}.qui 1.0 ${offset}" >> pin${ex}.lst
echo "D pin_sm_a${ex}.qui 1.0 $4 ${offset} ${refpnt} -" >> pin${ex}.lst
echo "D pin_sm_b${ex}.qui 1.0 $4 ${offset} ${refpnt} -" >> pin${ex}.lst
echo "D pin_big_l${ex}.qui 1.0 $4 ${offset} ${refpnt} -" >> pin${ex}.lst
echo "D pin_big_r${ex}.qui 1.0 $4 ${offset} ${refpnt} -" >> pin${ex}.lst
#
# update final .lst file 
#
cat pin${ex}.lst >> connector$5$4$6.lst
