#!/bin/ksh ## ## SCRIPT NAME: feinp_nas2stl_nogui_TESTawkprogs ## in $FEDIR/scripts ## where FEDIR=/apps/nns_com/fea ## ## based on 'feinp_nas2stl_bygui' with most GUI's removed ## and TEST NASTRAN input filename hard-coded. ######################################################################## ## PURPOSE: ## ** This script ## ** translates a NASTRAN input file containing GRID & element records ## ** --- like CTRIAx,CQUADx,CTETRA,CPENTA,CHEXA and many others --- ## ** into an STL file. ## ## For testing one (or more) of 3 awk-progs, or new verions: ## 1) feinp_nas2freeform_nodeinfo_awkprog ## 2) feinp_nas2freeform_elinfo_awkprog ## 3) feinp_generic2stl_awkprog ## ## Example: ## The 'production' awk-progs ## feinp_nas2freeform_elinfo_awkprog ## and feinp_generic2stl_awkprog ## ## could be replaced by ## ## feinp_nas2freeform_elinfo_awkprog_NEWcbar_cbeam ## and feinp_generic2stl_awkprog_NEWcbar_cbeam ## ## and then (after adding cbar_cbeam code to NEW prod versions) ## ## feinp_nas2freeform_elinfo_awkprog_NEW ## and feinp_generic2stl_awkprog_NEW ## ######################################################################## ## PROCESSING LOGIC: ## ## This script utility --- 'feinp_nas2stl_nogui_TESTawkprogs' --- ## basically executes the following series of awk-progs: ## ## 1) feinp_nas2freeform_nodeinfo_awkprog ## 2) feinp_nas2freeform_elinfo_awkprog ## (sort and concatenate their output) ## ## 3) feinp_generic2stl_awkprog (yields an STL file to view) ## ## In more detail: ## ## 1) SET A NASTRAN FILENAME: ## 'Hard-codes' a fully-qulified TEST NASTRAN input filename, ## in var $FILEIN. ## Usually a filename in /apps/nns_com/fea/demos_nas2stl. ##----------- ## STEPS 2 & 3 CONVERT the NASTRAN FILE TO TWO FILES -- ## 1) a 'generic', 'free-format' grids=nodes file ## 2) a 'generic', 'free-format' elements file. ##----------- ## 2) GRID INFO EXTRACTION: ## Awk-prog 'feinp_nas2freeform_nodeinfo_awkprog' is executed to ## read sequentially through the NASTRAN file and ## extracts the 'grid' records from the NASTRAN input file and creates ## a 'generic', 'free-format' grids-file (= nodes-file) in ## ${LOCDIR}/temp_freeform_nodeinfo.txt. ## ## 3) ELEMENT INFO EXTRACTION: ## Awk-prog 'feinp_nas2freeform_elinfo_awkprog' is executed to ## read the NASTRAN file a second time and ## extracts most (if not all) of the various types of element records ## from the NASTRAN input file and creates ## a 'generic', 'free-format' elements-file in ## ${LOCDIR}/temp_freeform_elinfo.txt. ## ## 4) SORT GRIDS & PASTE THE TWO 'generic' FE-GEOMETRY-INFO FILES TOGETHER: ## ## a) Sort the 'generic' nodes/grids file by nodeid (2nd field) --- ## into file ${LOCDIR}/temp_freeform_nodes_els_info.txt ## ## b) Concatenate the 'free-format' elements-file onto this file. ## ## (In steps a & b, removes comment lines, which begin with '#'.) ## ## ## 5) TRANSLATE THE 'generic' FE-GEOMETRY-INFO FILE INTO AN STL file: ## 'feinp_generic2stl_awkprog' is called in ## an 'awk' command in this script. ## ## Input is the 'generic' FE-geometry-info file. Output is an Ascii ## STL file. ## ## ## 6) Shows the resulting STL-format file with 'nedit -read', with ## a confirm-popup window indicating how to look for ERRORs in the ## STL output file. ## ######################################################################## ## CALLED BY: manually, usually in directory$FEDIR/scripts. ## ######################################################################## ## TEST FILES: Test NASTRAN files with various elements are ## in directory /apps/nns_com/fea/demos_nas2stl ## and/or /apps/simtec_2000/test_files_nas2stl. ## Some of these NASTRAN input files are from ## /apps/msc/msc70/msc70/nast/demo ## and /apps/msc/msc70/msc70/nast/tpl. ## Others may be from NNS NASTRAN users. ######################################################################## ## MAINTENANCE HISTORY: ## Written by: B.Montandon O06 12Sep2000 Based on 'feinp_nas2stl_bygui' ## in $FEDIR/scripts ## Updated by: B.Montandon O06 12Sep2000 ######################################################################## ############################################################################# ## DEFINE VARS to allow running outside of the nnsFEAmenu system. ############################################################################# if test "$FEDIR" = "" then FEDIR="/apps/nns_com/fea" fi ############################################################################# ## SAVE 'this hostname' for host-checks and form titles. ############################################################################# THISHOST=`hostname` ######################################################################### ## SET var LOCDIR to /local/scratch/$USER --- if possible -- ## for output STL file(s) -- and generic,free-format nodes & els files. ######################################################################### . $FEDIR/scripts/set_localuserdir ## cd $LOCDIR ######################################################################## ## START OF PROMPTING LOOP, FOR FILE SELECTION. ## (Commented for testing hard-coded NASTRAN filename.) ######################################################################## # # while true # while : # do ######################################################################## ## GET NASTRAN FILE NAME. ######################################################################## FILEIN=/apps/nns_com/fea/demos_nas2stl/ctria3s_1_fixed.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/ctria3s_12_box_fixed.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/ctria6s_1_fixed.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/cquad4s_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/cquad4s_6_box_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/cquad8s_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/cquad8s_6_box_free_gridsfixed.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/ctetras_1_fixed.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/ctetras_5_fixed_gridsfree.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/cpentas_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/chexas_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/cbars_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/cbeams_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/crods_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/crods_4_fixed_tpl_acc001.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/ctubes_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/cbeam_bar_tube_rod_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/cbend_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/conrods_1_free.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/conrods_9_fixed_tpl_acc003.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/rbe2s_1_fixed.dat # FILEIN=/apps/nns_com/fea/demos_nas2stl/rbars_1_fixed.dat # FILEIN="/apps/nns_com/fea/demos_nas2stl/cbeams_4_square_fixed.dat" ######################################################################### ## CONVERT the NASTRAN FILE TO TWO FILES -- ## 1) a 'generic', 'free-format' grids=nodes file ## 2) a 'generic', 'free-format' elements file ######################################################################### ######################################################################### ## AWK-PROG#1: ## CREATE THE 'GENERIC' GRIDS=NODES FILE. ######################################################################### NODESFILE="${LOCDIR}/temp_freeform_nodeinfo.txt" rm -f $NODESFILE ## $FEDIR/scripts/feinp_nas2freeform_nodeinfo $FILEIN $NODESFILE ## FOR TESTING: ## set -x ## FOR TESTING: Use awk-var DE_BUG to SET DEBUG=1 in the BEGIN section of ## $FEDIR/scripts/feinp_nas2freeform_elinfo_awkprog . DEBUG=1 # DEBUG=0 ## AWK-PROGS TO SWITCH IN/OUT FOR TESTING: # -f $FEDIR/scripts/feinp_nas2freeform_nodeinfo_awkprog \ # -f $FEDIR/scripts/feinp_nas2freeform_nodeinfo_awkprog_NEW \ awk -v FILE_IN="$FILEIN" -v DE_BUG="$DEBUG" \ -f $FEDIR/scripts/feinp_nas2freeform_nodeinfo_awkprog \ $FILEIN > $NODESFILE ## FOR TESTING: ## set - ## FOR TESTING, ## SHOW the generic,free-form GRID-info file -- via 'nedit' in read-only mode. if test "$DEBUG" = "1" then nedit -read $NODESFILE & fi ######################################################################### ## AWK-PROG#2: ## CREATE THE 'GENERIC' ELEMENTS FILE. ######################################################################### ELSFILE="${LOCDIR}/temp_freeform_elinfo.txt" rm -f $ELSFILE ## $FEDIR/scripts/feinp_nas2freeform_elinfo $FILEIN $ELSFILE ## FOR TESTING: ## set -x ## FOR TESTING: Use awk-var DE_BUG to SET DEBUG=1 in the BEGIN section of ## $FEDIR/scripts/feinp_nas2freeform_elinfo_awkprog . DEBUG=1 # DEBUG=0 ## AWK-PROGS TO SWITCH IN/OUT FOR TESTING: # -f $FEDIR/scripts/feinp_nas2freeform_elinfo_awkprog \ # -f $FEDIR/scripts/feinp_nas2freeform_elinfo_awkprog_NEW \ awk -v FILE_IN="$FILEIN" -v DE_BUG="$DEBUG" \ -f $FEDIR/scripts/feinp_nas2freeform_elinfo_awkprog \ $FILEIN > $ELSFILE ## FOR TESTING: ## set - ## FOR TESTING, ## SHOW the generic,free-form ELS-info file -- via 'nedit' in read-only mode. if test "$DEBUG" = "1" then nedit -read $ELSFILE & fi ######################################################################### ## PASTE THE TWO 'generic' FE-GEOMETRY-INFO FILES TOGETHER. ## (Remove the comment lines, which begin with '#' --- and sort ## the nodes/grids file by nodeid.) ######################################################################### GENERIC_FE_FILE="${LOCDIR}/temp_freeform_nodes_els_info.txt" rm -f $GENERIC_FE_FILE grep -v '^#' $NODESFILE | sort -k2n > $GENERIC_FE_FILE grep -v '^#' $ELSFILE >> $GENERIC_FE_FILE ######################################################################### ## AWK-PROG#3: ## TRANSLATE THE 'generic' FE-GEOMETRY-INFO FILE INTO AN STL file. ######################################################################### ## NOTE1: ## THE 'awk3' PROGRAM LOGIC DEPENDS ON *ALL* THE 'GENERIC' GRID RECORDS ## BEING BEFORE *ALL* THE 'GENERIC' ELEMENT RECORDS. ## NOTE2: ## THE 'awk3' PROGRAM LOGIC ASSUMES THE DATA IN THE NODE & ELEMENT ## RECORDS ARE IN FREE-FORMAT, SEPARATED BY SPACE(S). [This ## facilitates use of the default field separators used by Unix ## utilities like 'sort' and 'awk'.] ######################################################################### OUTFILE="${LOCDIR}/temp.stl" rm -f $OUTFILE ## FOR TESTING: ## set -x ## FOR TESTING: SET DEBUG=1 DEBUG=1 # DEBUG=0 ## AWK-PROGS TO SWITCH IN/OUT FOR TESTING: # -f $FEDIR/scripts/feinp_generic2stl_awkprog \ # -f $FEDIR/scripts/feinp_generic2stl_awkprog_NEW \ awk -v FILE_IN="$FILEIN" -v DE_BUG="$DEBUG" \ -f $FEDIR/scripts/feinp_generic2stl_awkprog_NEW \ $GENERIC_FE_FILE > $OUTFILE ## FOR TESTING: ## set - ######################################################################### ## ADD SOME HOW/WHEN-GENERATED INFO TO THE END OF THE STL FILE. ######################################################################### echo "\ ENDSOLID - created via $FEDIR/scripts/feinp_nas2stl_nogui_TESTawkprogs ENDSOLID - `date '+%Y %b %d %a %T%p %Z'` on host $THISHOST ENDSOLID - Generated via 'generic,free-format' FE file $GENERIC_FE_FILE ENDSOLID - which was built from sorting the nodes file $NODESFILE ENDSOLID - and attaching the elements file $ELSFILE " >> $OUTFILE ######################################################################### ## SHOW the STL file -- via 'nedit' in read-only mode. ######################################################################### nedit -read $OUTFILE & ######################################################################### ## TELL THE USER WHAT TO LOOK FOR IN the STL file. ######################################################################### # xconfirm -c -header "NAS-Geom-to-STL - NOTE" -B DISMISS \ # -t "The full name of the STL file is" \ # -t " $OUTFILE" \ # -t " " \ # -t "If it contains no '*ERROR:' statements and" \ # -t "there is no x,y,z missing data in 'vertex' statements, you" \ # -t "can try viewing its shaded image in a 'NNS-SGI STL Viewer'." \ # -t " " \ # -t "To continue (translate another NASTRAN file or exit)," \ # -t "click the 'Dismiss' button." \ # -icon warning > /dev/null CONFIRM_TEXT="\ The full name of the STL file is $OUTFILE If it contains no '*ERROR:' statements and there is no missing x,y,z data in 'vertex' statements, you can try viewing its shaded image in a 'NNS-SGI STL Viewer'. To continue (translate another NASTRAN file or exit), click the 'Dismiss' button." export CONFIRM_TEXT CONFIRM_GEOM="+700+080" CONFIRM_MINSIZE="150 100" CONFIRM_TITLE="NAS-Geom-to-STL File Translator" CONFIRM_COLOR="plum2" # CONFIRM_COLOR="#EEAEEE" # CONFIRM_COLOR="#CC99CC" # CONFIRM_COLOR="#996699" export CONFIRM_COLOR CONFIRM_TITLE CONFIRM_MINSIZE CONFIRM_GEOM JUNK=`$FEDIR/tkGUIs/confirm.tk DISMISS` ######################################################################## ## RETURN TO FILE-SELECTION PROMPT. ## (Commented for testing hard-coded NASTRAN filename.) ######################################################################## ## ... ## FILSEL_MSG="\ ## SELECT ANOTHER NASTRAN INPUT FILE ... ## for *TRANSLATION* to an STL file. OR click 'Cancel' to exit." ## ... # done ######################################################################## ## END OF prompting loop, for NASTRAN file name. ########################################################################