!*********************************************************************************************************************************************************!
!* Copyright (c) <2015> <Purdue University> All rights reserved.																					     *!
!*                                                                      																			     *!
!* Developed by:  Fang Jiang, Wenbin Yu                                                                                                                  *!
!*        <Prof. Yu’s Research Group>,                                                                                                                   *!
!*        <School of Aeronautics and Astronautics, Purdue University>                                                                                    *!
!*        <https://cdmhub.org/projects/ansysvabsgui2015>                                                                                                 *!
!*                                                                      																			     *!
!* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),    *!
!* to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,  *!
!* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:            *!
!*                                                                      																			     *!
!* •Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.                        *!
!*                                                                      																			     *!
!* •Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation *!
!*  and/or other materials provided with the distribution.                                                                                               *!
!*                                                                      																			     *!
!* •Neither the names of < Prof. Yu’s Research Group, School of Aeronautics and Astronautics, Purdue University >,                                       *!
!*  nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission.   *!
!*                                                                      																			     *!
!* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *!
!* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *!
!* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER     *!
!* DEALINGS WITH THE SOFTWARE. 																															 *!
!*********************************************************************************************************************************************************!
/GRAPHICS,FULL
ALLSEL,ALL
NSEL,ALL
ESEL,ALL
*GET, nnode, NODE, 0, COUNT
*GET, nelem, ELEM, 0, COUNT

! part #6
!=================================================================================
! elemant-node connectivity relations block      Done
!---------------------------------------------------------------------------------
! elem_no; node_1; node_2; node_3; node_4; node_5; node_6; node_7; node_8; node_9;
!---------------------------------------------------------------------------------
! If a node is not present in the element, the value is 0.
!Although the arrangement of elem_no is not necessary to be consecutive, 
!every element starting from 1 to nelem should be present.

!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!3-Node Triangle
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ALLSEL,ALL
ESEL, S, TYPE, , 1 
*GET, nelem1, ELEM, 0, COUNT

*IF, nelem1, NE, 0, THEN

	*DEL, e1_MASK
	*DEL, e1_LST
	*DEL, e1_NODE_1
	*DEL, e1_NODE_2
	*DEL, e1_NODE_3
	*DEL, e1_NODE_4
	*DEL, e1_NODE_5
	*DEL, e1_NODE_6
	*DEL, e1_NODE_7
	*DEL, e1_NODE_8
	*DEL, e1_NODE_9
	*DEL, e1_NODE_0
	*DEL, e1_NV01
	
	*DEL, e1_NODE_1_ALL
	*DEL, e1_NODE_2_ALL
	*DEL, e1_NODE_3_ALL
	*DEL, e1_NODE_4_ALL
	*DEL, e1_NODE_5_ALL
	*DEL, e1_NODE_6_ALL
	*DEL, e1_NODE_7_ALL
	*DEL, e1_NODE_8_ALL
	*DEL, e1_NODE_9_ALL
	*DEL, e1_NODE_0_ALL	
	
	!---------------------------------------------------------------------------------
	*DIM,  e1_MASK,   ARRAY, nelem, 1, 1
	*VGET, e1_MASK(1), ELEM, 1, ESEL   !A mask vector for the selected ELEMENTS

	*DIM,  e1_NODE_1_ALL, ARRAY, nelem, 1, 1
	*DIM,  e1_NODE_2_ALL, ARRAY, nelem, 1, 1
	*DIM,  e1_NODE_3_ALL, ARRAY, nelem, 1, 1
	*DIM,  e1_NODE_4_ALL, ARRAY, nelem, 1, 1
	*DIM,  e1_NODE_5_ALL, ARRAY, nelem, 1, 1
	*DIM,  e1_NODE_6_ALL, ARRAY, nelem, 1, 1
	*DIM,  e1_NODE_7_ALL, ARRAY, nelem, 1, 1
	*DIM,  e1_NODE_8_ALL, ARRAY, nelem, 1, 1
	*DIM,  e1_NODE_9_ALL, ARRAY, nelem, 1, 1
	*DIM,  e1_NODE_0_ALL, ARRAY, nelem, 1, 1

	*DIM,  e1_LST,    ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_1, ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_2, ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_3, ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_4, ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_5, ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_6, ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_7, ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_8, ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_9, ARRAY, nelem1, 1, 1
	*DIM,  e1_NODE_0, ARRAY, nelem1, 1, 1
	*DIM,  e1_NV01,   ARRAY, nelem1, 1, 1

	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VGET,  e1_LST, ELEM, , ELIST
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e1_MASK(1)
	*VGET,  e1_NODE_1_ALL, ELEM, 1, NODE, 1
	*VMASK, e1_MASK(1)
	*VFUN,  e1_NODE_1(1), COMP, e1_NODE_1_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e1_MASK(1)
	*VGET,  e1_NODE_2_ALL, ELEM, 1, NODE, 2
	*VMASK, e1_MASK(1)
	*VFUN,  e1_NODE_2(1), COMP, e1_NODE_2_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e1_MASK(1)
	*VGET,  e1_NODE_3_ALL, ELEM, 1, NODE, 3
	*VMASK, e1_MASK(1)
	*VFUN,  e1_NODE_3(1), COMP, e1_NODE_3_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*ENDIF


!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!6-Node Triangle
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ALLSEL,ALL
ESEL, S, TYPE, , 2
*GET, nelem2, ELEM, 0, COUNT

*IF, nelem2, NE, 0, THEN

	*DEL, e2_MASK
	*DEL, e2_LST
	*DEL, e2_NODE_1
	*DEL, e2_NODE_2
	*DEL, e2_NODE_3
	*DEL, e2_NODE_4
	*DEL, e2_NODE_5
	*DEL, e2_NODE_6
	*DEL, e2_NODE_7
	*DEL, e2_NODE_8
	*DEL, e2_NODE_9
	*DEL, e2_NODE_0
	*DEL, e2_NV01

	*DEL, e2_NODE_1_ALL
	*DEL, e2_NODE_2_ALL
	*DEL, e2_NODE_3_ALL
	*DEL, e2_NODE_4_ALL
	*DEL, e2_NODE_5_ALL
	*DEL, e2_NODE_6_ALL
	*DEL, e2_NODE_7_ALL
	*DEL, e2_NODE_8_ALL
	*DEL, e2_NODE_9_ALL
	*DEL, e2_NODE_0_ALL
	
	!---------------------------------------------------------------------------------
	*DIM,  e2_MASK,   ARRAY, nelem, 1, 1
	*VGET, e2_MASK(1), ELEM, 1, ESEL   !A mask vector for the selected ELEMENTS

	*DIM,  e2_NODE_1_ALL, ARRAY, nelem, 1, 1
	*DIM,  e2_NODE_2_ALL, ARRAY, nelem, 1, 1
	*DIM,  e2_NODE_3_ALL, ARRAY, nelem, 1, 1
	*DIM,  e2_NODE_4_ALL, ARRAY, nelem, 1, 1
	*DIM,  e2_NODE_5_ALL, ARRAY, nelem, 1, 1
	*DIM,  e2_NODE_6_ALL, ARRAY, nelem, 1, 1
	*DIM,  e2_NODE_7_ALL, ARRAY, nelem, 1, 1
	*DIM,  e2_NODE_8_ALL, ARRAY, nelem, 1, 1
	*DIM,  e2_NODE_9_ALL, ARRAY, nelem, 1, 1
	*DIM,  e2_NODE_0_ALL, ARRAY, nelem, 1, 1

	*DIM,  e2_LST,    ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_1, ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_2, ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_3, ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_4, ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_5, ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_6, ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_7, ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_8, ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_9, ARRAY, nelem2, 1, 1
	*DIM,  e2_NODE_0, ARRAY, nelem2, 1, 1
	*DIM,  e2_NV01,   ARRAY, nelem2, 1, 1

	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VGET,  e2_LST, ELEM, , ELIST
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e2_MASK(1)
	*VGET,  e2_NODE_1_ALL, ELEM, 1, NODE, 1
	*VMASK, e2_MASK(1)
	*VFUN,  e2_NODE_1(1), COMP, e2_NODE_1_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e2_MASK(1)
	*VGET,  e2_NODE_2_ALL, ELEM, 1, NODE, 2
	*VMASK, e2_MASK(1)	
	*VFUN,  e2_NODE_2(1), COMP, e2_NODE_2_ALL(1)	
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e2_MASK(1)
	*VGET,  e2_NODE_3_ALL, ELEM, 1, NODE, 3
	*VMASK, e2_MASK(1)
	*VFUN,  e2_NODE_3(1), COMP, e2_NODE_3_ALL(1)	
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	!=================================
	*VMASK, e2_MASK(1)
	*VGET,  e2_NODE_5_ALL, ELEM, 1, NODE, 4
	*VMASK, e2_MASK(1)	
	*VFUN,  e2_NODE_5(1), COMP, e2_NODE_5_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e2_MASK(1)
	*VGET,  e2_NODE_6_ALL, ELEM, 1, NODE, 5
	*VFUN,  e2_NODE_6(1), COMP, e2_NODE_6_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e2_MASK(1)
	*VGET,  e2_NODE_7_ALL, ELEM, 1, NODE, 6
	*VMASK, e2_MASK(1)
	*VFUN,  e2_NODE_7(1), COMP, e2_NODE_7_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 


*ENDIF


!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!4-Node Quadrilateral
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ALLSEL,ALL
ESEL, S, TYPE, , 3
*GET, nelem3, ELEM, 0, COUNT

*IF, nelem3, NE, 0, THEN

	*DEL, e3_MASK
	*DEL, e3_LST
	*DEL, e3_NODE_1
	*DEL, e3_NODE_2
	*DEL, e3_NODE_3
	*DEL, e3_NODE_4
	*DEL, e3_NODE_5
	*DEL, e3_NODE_6
	*DEL, e3_NODE_7
	*DEL, e3_NODE_8
	*DEL, e3_NODE_9
	*DEL, e3_NODE_0
	*DEL, e3_NV01
	
	*DEL, e3_NODE_1_ALL
	*DEL, e3_NODE_2_ALL
	*DEL, e3_NODE_3_ALL
	*DEL, e3_NODE_4_ALL
	*DEL, e3_NODE_5_ALL
	*DEL, e3_NODE_6_ALL
	*DEL, e3_NODE_7_ALL
	*DEL, e3_NODE_8_ALL
	*DEL, e3_NODE_9_ALL
	
	!---------------------------------------------------------------------------------
	*DIM, e3_MASK, ARRAY, nelem, 1, 1
	*VGET, e3_MASK(1), ELEM, 1, ESEL   !A mask vector for the selected ELEMENTS

	*DIM, e3_NODE_1_ALL, ARRAY, nelem, 1, 1
	*DIM, e3_NODE_2_ALL, ARRAY, nelem, 1, 1
	*DIM, e3_NODE_3_ALL, ARRAY, nelem, 1, 1
	*DIM, e3_NODE_4_ALL, ARRAY, nelem, 1, 1
	*DIM, e3_NODE_5_ALL, ARRAY, nelem, 1, 1
	*DIM, e3_NODE_6_ALL, ARRAY, nelem, 1, 1
	*DIM, e3_NODE_7_ALL, ARRAY, nelem, 1, 1
	*DIM, e3_NODE_8_ALL, ARRAY, nelem, 1, 1
	*DIM, e3_NODE_9_ALL, ARRAY, nelem, 1, 1

	*DIM, e3_LST,    ARRAY, nelem3, 1, 1	
	*DIM, e3_NODE_1, ARRAY, nelem3, 1, 1
	*DIM, e3_NODE_2, ARRAY, nelem3, 1, 1
	*DIM, e3_NODE_3, ARRAY, nelem3, 1, 1
	*DIM, e3_NODE_4, ARRAY, nelem3, 1, 1
	*DIM, e3_NODE_5, ARRAY, nelem3, 1, 1
	*DIM, e3_NODE_6, ARRAY, nelem3, 1, 1
	*DIM, e3_NODE_7, ARRAY, nelem3, 1, 1
	*DIM, e3_NODE_8, ARRAY, nelem3, 1, 1
	*DIM, e3_NODE_9, ARRAY, nelem3, 1, 1
	*DIM, e3_NODE_0, ARRAY, nelem3, 1, 1
	*DIM, e3_NV01, ARRAY, nelem3, 1, 1
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VGET, e3_LST, ELEM, , ELIST
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e3_MASK(1)
	*VGET,  e3_NODE_1_ALL, ELEM, 1, NODE, 1
	*VMASK, e3_MASK(1)
	*VFUN,  e3_NODE_1(1), COMP, e3_NODE_1_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e3_MASK(1)
	*VGET,  e3_NODE_2_ALL, ELEM, 1, NODE, 2
	*VMASK, e3_MASK(1)
	*VFUN,  e3_NODE_2(1), COMP, e3_NODE_2_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e3_MASK(1)
	*VGET,  e3_NODE_3_ALL, ELEM, 1, NODE, 3
	*VMASK, e3_MASK(1)
	*VFUN,  e3_NODE_3(1), COMP, e3_NODE_3_ALL(1)

	!============================================
	! get node # at position 4
	*VMASK, e3_MASK(1)	
	*VGET,  e3_NODE_4_ALL, ELEM, 1, NODE, 4           
	*VMASK, e3_MASK(1)
	*VFUN,  e3_NODE_4(1), COMP, e3_NODE_4_ALL(1)
	
	*VOPER, e3_NV01, e3_NODE_4, EQ, e3_NODE_3         ! if #4=#3, the corresponding element is reduced to triangle	
	*VSCFUN, NEXIST, SUM, e3_NV01                  ! the total number of reduced element
	
	*IF, NEXIST, GT, 0, THEN                   			
		*VMASK, e3_NV01(1)                   ! use "NV01" array as a mask to zero the node position 4 of reduced element
	    *VFUN, e3_NODE_4, copy, e3_NODE_0	
	*ENDIF

*ENDIF


!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!8-Node Quadrilateral
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ALLSEL,ALL
ESEL, S, TYPE, , 4
*GET, nelem4, ELEM, 0, COUNT

*IF, nelem4, NE, 0, THEN

	*DEL, e4_MASK
	*DEL, e4_LST
	*DEL, e4_NODE_1
	*DEL, e4_NODE_2
	*DEL, e4_NODE_3
	*DEL, e4_NODE_4
	*DEL, e4_NODE_5
	*DEL, e4_NODE_6
	*DEL, e4_NODE_7
	*DEL, e4_NODE_8
	*DEL, e4_NODE_9
	*DEL, e4_NODE_0
	*DEL, e4_NV01

	*DEL, e4_NODE_1_ALL
	*DEL, e4_NODE_2_ALL
	*DEL, e4_NODE_3_ALL
	*DEL, e4_NODE_4_ALL
	*DEL, e4_NODE_5_ALL
	*DEL, e4_NODE_6_ALL
	*DEL, e4_NODE_7_ALL
	*DEL, e4_NODE_8_ALL
	*DEL, e4_NODE_9_ALL
	*DEL, e4_NODE_0_ALL

	!---------------------------------------------------------------------------------
	*DIM,  e4_MASK, ARRAY, nelem, 1, 1
	*VGET, e4_MASK(1), ELEM, 1, ESEL   !A mask vector for the selected ELEMENTS

	*DIM, e4_NODE_1_ALL, ARRAY, nelem, 1, 1
	*DIM, e4_NODE_2_ALL, ARRAY, nelem, 1, 1
	*DIM, e4_NODE_3_ALL, ARRAY, nelem, 1, 1
	*DIM, e4_NODE_4_ALL, ARRAY, nelem, 1, 1
	*DIM, e4_NODE_5_ALL, ARRAY, nelem, 1, 1
	*DIM, e4_NODE_6_ALL, ARRAY, nelem, 1, 1
	*DIM, e4_NODE_7_ALL, ARRAY, nelem, 1, 1
	*DIM, e4_NODE_8_ALL, ARRAY, nelem, 1, 1
	*DIM, e4_NODE_9_ALL, ARRAY, nelem, 1, 1
	*DIM, e4_NODE_0_ALL, ARRAY, nelem, 1, 1

	*DIM, e4_LST,    ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_1, ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_2, ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_3, ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_4, ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_5, ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_6, ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_7, ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_8, ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_9, ARRAY, nelem4, 1, 1
	*DIM, e4_NODE_0, ARRAY, nelem4, 1, 1
	*DIM, e4_NV01,   ARRAY, nelem4, 1, 1

	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VGET,  e4_LST, ELEM, , ELIST
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e4_MASK(1)
	*VGET,  e4_NODE_1_ALL, ELEM, 1, NODE, 1
	*VMASK, e4_MASK(1)
	*VFUN,  e4_NODE_1(1), COMP, e4_NODE_1_ALL(1)	
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e4_MASK(1)
	*VGET,  e4_NODE_2_ALL, ELEM, 1, NODE, 2
	*VMASK, e4_MASK(1)
	*VFUN,  e4_NODE_2(1), COMP, e4_NODE_2_ALL(1)	
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e4_MASK(1)
	*VGET,  e4_NODE_3_ALL, ELEM, 1, NODE, 3
	*VMASK, e4_MASK(1)	
	*VFUN,  e4_NODE_3(1), COMP, e4_NODE_3_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e4_MASK(1)
	*VGET,  e4_NODE_4_ALL, ELEM, 1, NODE, 4           ! get node # at position 4
	*VMASK, e4_MASK(1)
	*VFUN,  e4_NODE_4(1), COMP, e4_NODE_4_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e4_MASK(1)
	*VGET,  e4_NODE_5_ALL, ELEM, 1, NODE, 5           ! get node # at position 5
	*VMASK, e4_MASK(1)
	*VFUN,  e4_NODE_5(1), COMP, e4_NODE_5_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e4_MASK(1)
	*VGET,  e4_NODE_6_ALL, ELEM, 1, NODE, 6           ! get node # at position 6
	*VMASK, e4_MASK(1)
	*VFUN,  e4_NODE_6(1), COMP, e4_NODE_6_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e4_MASK(1)
	*VGET,  e4_NODE_7_ALL, ELEM, 1, NODE, 7           ! get node # at position 7
	*VMASK, e4_MASK(1)
	*VFUN,  e4_NODE_7(1), COMP, e4_NODE_7_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	*VMASK, e4_MASK(1)
	*VGET,  e4_NODE_8_ALL, ELEM, 1, NODE, 8           ! get node # at position 7
	*VMASK, e4_MASK(1)
	*VFUN,  e4_NODE_8(1), COMP, e4_NODE_8_ALL(1)
	!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

		!===============================
		*VOPER, e4_NV01, e4_NODE_4, EQ, e4_NODE_3         ! if #4=#3, the corresponding element is reduced to triangle

		*VSCFUN, e4_NEXIST, SUM, e4_NV01                  ! the total number of reduced element

		*IF, e4_NEXIST, GT, 0, THEN                   		
				!~~~~~~~~~~~~~~~~~~~~~~~~~~~~
				*VMASK, e4_NV01(1)                   ! use "NV01" array as a mask to copy node position 8 to node position 7
                *VFUN,  e4_NODE_7, copy, e4_NODE_8
				!~~~~~~~~~~~~~~~~~~~~~~~~~~~~
				*VMASK, e4_NV01(1)                   ! use "NV01" array as a mask to zero the node position 8 of reduced element
                *VFUN,  e4_NODE_8, copy, e4_NODE_0
				!~~~~~~~~~~~~~~~~~~~~~~~~~~~~
				*VMASK, e4_NV01(1)                   ! use "NV01" array as a mask to zero the node position 4 of reduced element
                *VFUN,  e4_NODE_4, copy, e4_NODE_0
				!~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		*ENDIF
		
*ENDIF