!   TITLE:  create_interface.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates an interface area on a specified volume that
!   overlaps an adjoining area on another volume.
!
!
!   COMMAND SYNTAX:
!
!                          (1)     (2)      (3)       (4)
!       CREATE_INTERFACE, 'v_p1', 'v_p2', 'v_i_p1', 'v_i_p2'
!
!
!   ARGUMENTS:
!
!       (1) 'v_p1' = part name of the 1st part, whose volumes are to
!                    interface with the 2nd part volumes (argument 2).
!                    [ must be in single quotes]
!
!       (2) 'v_p2' = part name of the 2nd part, whose volumes are to
!                    interface with the 1st part volumes (argument 1).
!                    [ must be in single quotes]
!
!       (3) 'v_i_p1' = component name of the subset of selected volumes
!                      of the 1st part (if applicable).
!                      [ must be in single quotes]
!                      (These volumes shall replace the original volumes
!                       from part 1, and input back into that part name)
!
!       (4) 'v_i_p2' = component name of the subset of selected volumes
!                      of the 2nd part (if applicable).
!                      [ must be in single quotes]
!                      (These volumes shall replace the original volumes
!                       from part 2, and input back into that part name)
!
!
!   DESCRIPTION:
!
!   Overlapping area(s) is/are created on the surface of the volume(s) of the
!   parts of arguments 1 and 2 (or the subset volumes of arguments 2 and 4).
!
!   These interface areas directly overlap the area(s) [in size and shape] of
!   the interfacing volume(s) such that the mesh patterns in these areas will,
!   at least closely, overlap. This is for the purpose of creating interfacing
!   mesh areas that will accomodate coupling or constraints of close or
!   coincident nodes.
!
!   Therefore, the volumes do not share a common area (as in the VGLUE
!   operation),  but have 2 overlapping areas between the interfacing volumes,
!   such that each area is attached to the separate volumes.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
volsp1_=arg1
volsp2_=arg2
volsip1_=arg3
volsip2_=arg4
!
!
! Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar,
!                 4=character array, -1=undefined
!
init_entity_num,1
configuration,0,,1
!
*get,argtyp1_,parm,volsip1_,type
*get,argtyp2_,parm,volsip2_,type
!
*if,argtyp1_,eq,3,then         ! If component group name (3rd argument)
    cmsel,s,volsip1_           !   is specified, then select volume subset of
    cm,vof1stp_,volu           !   part 1, and store in component group, VOF1STP_.
*elseif,argtyp1_,eq,0,then     ! If component group name is NOT specified, then
    select,volsp1_             !   select (all of)  part 1, and store these
    cm,vof1stp_,volu           !   volumes in component group, VOF1STP_.
*endif
!
configuration,1,,1
!
*if,argtyp2_,eq,3,then         ! If component group name (4th argument)
    cmsel,s,volsip2_           !   is specified, then select volume subset of
    cm,vof2ndp_,volu           !   part 1, and store in component group, VOF2NDP_.
*elseif,argtyp2_,eq,0,then     ! If component group name is NOT specified, then
    select,volsp2_             !   select (all of)  part 2, and store these
    cm,vof2ndp_,volu           !   volumes in component group, VOF2NDP_.
*endif
!
configuration,1,,1
!
cmsel,s,vof1stp_            !   1.) store the 1st part volumes.
v_sel-attr,0,1
!
configuration,1,,1
!
cmsel,s,vof2ndp_            !   2.) store the 2nd part volumes.
v_sel-attr,0,2
!
cmsel,a,vof1stp_            !   3.) select both volume sets to be glued.
!
vglue,all                   !   4.) perform the glue operation.
cm,vgset1_,volu
init_entity_num,1
!
v_sel-attr,1,1              !   5.) reselect the volumes stored from part 1,
cm,vset1_,volu              !       and store in a component group, VSET1_.
!
csys,0                      !   6.) Duplicate the glued volumes from part 1.
vtran,0,all
!
cmsel,u,vset1_              !   7.) unselect the original glued volumes from
cm,new_vol1,volu            !       part 1, and store remaining in component
!                           !       group, NEW_VOL1.
!
*if,argtyp1_,eq,3,then
    select,volsp1_
    cmsel,a,new_vol1
    cm,%volsp1_%,volu
*elseif,argtyp1_,eq,0,then
    cmsel,s,new_vol1
    cm,%volsp1_%,volu
*endif
!
init_entity_num,1
!
cmsel,s,vset1_
vdele,all,,,1
init_entity_num,1
!
cmsel,s,vgset1_
cm,new_vol2,volu
init_entity_num,1
!
*if,argtyp2_,eq,3,then
    select,volsp2_
    cmsel,a,new_vol2
    cm,%volsp2_%,volu
*elseif,argtyp2_,eq,0,then
    cmsel,s,new_vol2
    cm,%volsp2_%,volu
*endif
!
configuration,1,,1
init_entity_num,1
!
select,volsp1_
nummrg,kp
init_entity_num,1
!
select,volsp2_
nummrg,kp
init_entity_num,1
!
vsum
vplot
!
cmdele,vof1stp_
cmdele,vof2ndp_
cmdele,vgset1_
cmdele,volsip1_
cmdele,volsip2_
!
cmdele,vset1_
cmdele,new_vol1
cmdele,new_vol2
!
*set,volsp1_,
*set,volsp2_,
*set,volsip1_,
*set,volsip2_,
*set,argtyp1_,
*set,argtyp2_,
!
*if,prkey_,eq,1,then
    /go
*endif