# write exodus file with side facesets # interpolated from boundary attributes itetclr and lay1_out # overwrite side values with the top layer outlet value # # There are 2 easy ways to find the top layer # 1. make attribute and assign 1 - nlayers (in the stack mesh) # 2. use layertyp = -2 to pset top and inclusive connected sides # then make element set of faces on sides but not top # # This example includes both methods to find and set elements by layer id # But uses method 2 which is more general # # See surfmesh_fs_all.inp and .gmv to check for correct fs assignments # define INPUT_MESH stack.inp define INPUT_BNDRY bndry_line_colors.inp define CMO_IN momesh define CMO_BNDRY moline # READ mesh read / INPUT_MESH / CMO_IN resetpts / itp ################### color mesh by nlayers ################# # METHOD 1. FIND AND SET ilayer 1-N starting at top # THIS IS NOT GENERAL # this might take awhile but needed if doing layers in addition to top layer # this assumes each layer is neperlayer=336 with nelements=1344 # this assumes element order from top to bottom cmo/addatt/CMO_IN/ilayer/VINT/scalar/nelements/linear/permanent/gxaf/0.0 cmo/setatt/ CMO_IN ilayer 1 cmo/setatt/ CMO_IN ilayer/ 673,1008 2 cmo/setatt/ CMO_IN ilayer/ 337,672 3 cmo/setatt/ CMO_IN ilayer/ 1,336,1 4 # check ilayer colors cmo printatt CMO_IN ilayer minmax dump gmv tmp_ilayers.gmv CMO_IN ############################################################ # ASSUME INPUT BNDRY LINE ATTRIBUTES itetclr lay1_out read / INPUT_BNDRY / CMO_BNDRY resetpts / itp # CHECK overlap of mesh and bndry cmo/printatt / CMO_IN / -xyz- minmax cmo/printatt / CMO_BNDRY / -xyz- minmax # CHECK ATTRIBUTES # these will be used to set facesets on sides and top layer cmo/printatt / CMO_BNDRY / itetclr minmax cmo/printatt / CMO_BNDRY / lay1_out minmax # PREPARE stack mesh for Exodus # sort based on element itetclr number and median location # Note Exodus expects materials to appear in mesh in order 1 to N # this is also done so numbering for Exodus matches other formats cmo/select/CMO_IN createpts / median sort / CMO_IN / index / ascending / ikey / itetclr xmed ymed zmed reorder / CMO_IN / ikey cmo / DELATT / CMO_IN / xmed cmo / DELATT / CMO_IN / ymed cmo / DELATT / CMO_IN / zmed cmo / DELATT / CMO_IN / ikey # EXTRACT surface with cell and face attributes # to get the outside face to element relationships # this will be used to write faceset files for dump/exo extract / surfmesh / 1 0 0 / mo_surf / CMO_IN / external cmo / printatt / mo_surf / -all- / minmax # This is the default for finding mesh facesets 1-6 # Set surface elements to direction they face based on normals # This can be skipped or just overwrite cmo / addatt / mo_surf / id_side / vint / scalar / nelements cmo / select mo_surf settets / normal cmo / copyatt / mo_surf mo_surf / id_side itetclr cmo / printatt / mo_surf / id_side / minmax dump gmv tmp_fs_normals.gmv mo_surf # This selection is more accurate for top and bottom # use stack attribute to avoid surface with multiple normal directions # set all sides to default 3 all cmo / select mo_surf cmo setatt mo_surf/ id_side / 3 pset/ ptop /attribute layertyp/1,0,0/ eq -2 pset/ pbot /attribute layertyp/1,0,0/ eq -1 eltset/ etop / exclusive pset,get,ptop eltset/ ebot / exclusive pset,get,pbot cmo setatt mo_surf/ id_side / eltset,get,etop 2 cmo setatt mo_surf/ id_side / eltset,get,ebot 1 cmo printatt mo_surf/ id_side/ minmax cmo/copyatt/ mo_surf mo_surf/ itetclr id_side dump gmv tmp_surf_sides.gmv mo_surf ############## NEW BNDRY SET SIDES ############################ # based on boundary lines, set all sides same as boundary lines # ELEMENT SET of all sides cmo select mo_surf eltset/esides/ id_side eq 3 pset/psides/ eltset/ esides # POINT SET of sides, top, and bottom cmo/setatt/ mo_surf/ imt pset,get,ptop 2 cmo/setatt/ mo_surf/ imt pset,get,pbot 1 cmo/setatt/ mo_surf/ imt pset,get,psides 3 dump gmv tmp_surf_sides.gmv mo_surf # PREPARE FOR INTERPOLATE # Make 3D mesh flat on same plane as boundary lines cmo select mo_surf cmo/addatt/ mo_surf / zsave / vdouble / scalar / nnodes cmo copyatt mo_surf mo_surf zsave zic cmo setatt mo_surf zic 0. cmo setatt CMO_BNDRY zic 0. # INTERPOLATE boundary faces to side faces # FIX numbering so mesh itetclr 1 and 2 remain top and bottom # ADD 2 to the boundary line materials assuming they start with 1 math/add/CMO_BNDRY/itetclr/1,0,0/CMO_BNDRY itetclr / 2 cmo printatt CMO_BNDRY itetclr minmax # SET ATTRIBUTE id_side and lay1_out from boundary lines cmo/addatt/mo_surf/lay1_out/VINT/scalar/nelements/linear/permanent/gxaf/0.0 cmo/addatt/mo_surf/ilayer/VINT/scalar/nelements/linear/permanent/gxaf/0.0 interpolate/map/mo_surf id_side/eltset,get,esides/CMO_BNDRY itetclr/keepatt interpolate/map/mo_surf lay1_out/eltset,get,esides/CMO_BNDRY lay1_out cmo printatt CMO_BNDRY id_sides minmax cmo printatt mo_surf id_sides minmax cmo printatt mo_surf lay1_out minmax cmo copyatt mo_surf mo_surf zic zsave cmo DELATT mo_surf zsave dump gmv tmp_interpolate_sides.gmv mo_surf # CHECK facesets have 2 plus bndry num side values # total = bndry + top and bottom = 5 + 2 =7 cmo printatt mo_surf itetclr minmax # SET FINAL FACE VALUES for SIDES (outlet will overwrite these) # TOP and Bottom were defined earlier, do the sides eltset/e3/ id_side / eq 3 eltset/e4/ id_side / eq 4 eltset/e5/ id_side / eq 5 eltset/e6/ id_side / eq 6 eltset/e7/ id_side / eq 7 cmo setatt mo_surf/ id_side / eltset,get,etop 2 cmo setatt mo_surf/ id_side / eltset,get,ebot 1 cmo printatt mo_surf/ id_side/ minmax # check material numbers, must be greater than 0 # copy id_side to itetclr which is done except for outlets cmo/copyatt/ mo_surf mo_surf/ itetclr id_side cmo printatt CMO_BNDRY imt minmax cmo printatt mo_surf imt minmax cmo printatt mo_surf itetclr minmax dump gmv surfmesh_fs_sides.gmv mo_surf dump avs surfmesh_fs_sides.inp mo_surf ############## NEW SET OUTLET LAYER 1 ########################### # based on boundary lines, set all sides same as boundary lines # There are 2 easy ways to find the top layer # - make attribute and assign 1 - nlayers (in the stack mesh) # - use layertyp = -2 to pset top and inclusive connected sides # then make element set of faces on sides but not top # # FOR THIS WORKFLOW USE top surface points to find layer 1 top layer cmo select mo_surf cmo setatt mo_surf ilayer 0 # METHOD 2. FIND AND SET top ilayer 1 # SET ATTRIBUTE ilayer pset/ ptop /attribute layertyp/1,0,0/ eq -2 eltset/ elay_inc/ inclusive pset,get,ptop cmo setatt mo_surf ilayer eltset,get,elay_inc 1 cmo setatt mo_surf ilayer eltset,get,etop 0 # INTERSECT ilayer with lay1_out and overwrite itetclr # This faceset will be value of itetclr + 1 = 8 eltset/e1/ ilayer eq 1 eltset/e2/ lay1_out eq 1 eltset/e_out1/ inter e1 e2 cmo/setatt/ mo_surf/ itetclr / eltset,get,e_out1 8 dump gmv surfmesh_fs_all.gmv mo_surf dump avs surfmesh_fs_all.inp mo_surf cmo/printatt/mo_surf/ -all- minmax # make sure to remove all attributes except idelem1 and idface1 cmo / DELATT / mo_surf / itetclr0 cmo / DELATT / mo_surf / idnode0 cmo / DELATT / mo_surf / idelem0 cmo / DELATT / mo_surf / facecol cmo / DELATT / mo_surf / itetclr1 cmo / DELATT / mo_surf / idface0 cmo / DELATT / mo_surf / ikey_utr cmo / DELATT / mo_surf / nlayers cmo / DELATT / mo_surf / nnperlayer cmo / DELATT / mo_surf / neperlayer cmo / DELATT / mo_surf / layertyp cmo / DELATT / mo_surf / ncon50 cmo / DELATT / mo_surf / nconbnd cmo / DELATT / mo_surf / icontab cmo / DELATT / mo_surf / id_side cmo / DELATT / mo_surf / ilayer cmo / DELATT / mo_surf / lay1_out # CHECK only user attributes should be idelem1 and idface1 cmo/printatt/mo_surf/ -all- minmax ######## WRITE FACESET FILES #################### # itetclr now has all faces colored from 1 to N=8 # LOOP through 1 to N and write fsID.faceset files # we assume 1 is bottom and 2 is top define / FILENAME / fs1_bot.faceset define / SS_ID / 1 cmo / copy / mo_tmp / mo_surf cmo / select / mo_tmp eltset / e_keep / itetclr / eq / SS_ID eltset / e_delete / not / e_keep rmpoint / element / eltset get e_delete rmpoint / compress dump / avs2 / FILENAME / mo_tmp / 0 0 0 2 cmo / delete / mo_tmp define / FILENAME / fs2_top.faceset define / SS_ID / 2 cmo / copy / mo_tmp / mo_surf cmo / select / mo_tmp eltset / e_keep / itetclr / eq / SS_ID eltset / e_delete / not / e_keep rmpoint / element / eltset get e_delete rmpoint / compress dump / avs2 / FILENAME / mo_tmp / 0 0 0 2 cmo / delete / mo_tmp ## CHECK that top number of faces = bottom = layer define / FILENAME / fs3.faceset define / SS_ID / 3 cmo / copy / mo_tmp / mo_surf cmo / select / mo_tmp eltset / e_keep / itetclr / eq / SS_ID eltset / e_delete / not / e_keep rmpoint / element / eltset get e_delete rmpoint / compress dump / avs2 / FILENAME / mo_tmp / 0 0 0 2 cmo / delete / mo_tmp define / FILENAME / fs3.faceset define / SS_ID / 3 cmo / copy / mo_tmp / mo_surf cmo / select / mo_tmp eltset / e_keep / itetclr / eq / SS_ID eltset / e_delete / not / e_keep rmpoint / element / eltset get e_delete rmpoint / compress dump / avs2 / FILENAME / mo_tmp / 0 0 0 2 cmo / delete / mo_tmp define / FILENAME / fs4.faceset define / SS_ID / 4 cmo / copy / mo_tmp / mo_surf cmo / select / mo_tmp eltset / e_keep / itetclr / eq / SS_ID eltset / e_delete / not / e_keep rmpoint / element / eltset get e_delete rmpoint / compress dump / avs2 / FILENAME / mo_tmp / 0 0 0 2 cmo / delete / mo_tmp define / FILENAME / fs5.faceset define / SS_ID / 5 cmo / copy / mo_tmp / mo_surf cmo / select / mo_tmp eltset / e_keep / itetclr / eq / SS_ID eltset / e_delete / not / e_keep rmpoint / element / eltset get e_delete rmpoint / compress dump / avs2 / FILENAME / mo_tmp / 0 0 0 2 cmo / delete / mo_tmp define / FILENAME / fs6.faceset define / SS_ID / 6 cmo / copy / mo_tmp / mo_surf cmo / select / mo_tmp eltset / e_keep / itetclr / eq / SS_ID eltset / e_delete / not / e_keep rmpoint / element / eltset get e_delete rmpoint / compress dump / avs2 / FILENAME / mo_tmp / 0 0 0 2 cmo / delete / mo_tmp define / FILENAME / fs7.faceset define / SS_ID / 7 cmo / copy / mo_tmp / mo_surf cmo / select / mo_tmp eltset / e_keep / itetclr / eq / SS_ID eltset / e_delete / not / e_keep rmpoint / element / eltset get e_delete rmpoint / compress dump / avs2 / FILENAME / mo_tmp / 0 0 0 2 cmo / delete / mo_tmp define / FILENAME / fs8.faceset define / SS_ID / 8 cmo / copy / mo_tmp / mo_surf cmo / select / mo_tmp eltset / e_keep / itetclr / eq / SS_ID eltset / e_delete / not / e_keep rmpoint / element / eltset get e_delete rmpoint / compress dump / avs2 / FILENAME / mo_tmp / 0 0 0 2 cmo / delete / mo_tmp ############################ # WRITE final mesh with multi material and all facesets define OUT_EXO mesh_fs8.exo dump / exo / OUT_EXO / CMO_IN / / / facesets & fs1_bot.faceset fs2_top.faceset fs3.faceset & fs4.faceset fs5.faceset fs6.faceset fs7.faceset fs8.faceset # GMV can display facesets as surfaces dump / gmv / mesh_exo.gmv / CMO_IN # REPORT ATTRIBUTE VALUES of MESH cmo/printatt/CMO_IN/ -all- minmax finish