!*********************************************************************************************************************************************************!
!* 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. 																															 *!
!*********************************************************************************************************************************************************!
! integrated in VABS_PreGen_7_elemno_layerid_theta1_0810

*DEL, Patch_Anum
*DIM, Patch_Anum, ARRAY, 100, 1, 1

ASEL, ALL
*GET, amin,   AREA, 0, NUM, MIND
*GET, amax,   AREA, 0, NUM, MAXD

PatchCounter = 0

*DO, i, amin, amax
	*IF, PatchFlag_A%i%, EQ, 1, THEN
		PatchCounter = PatchCounter + 1
		Patch_Anum(PatchCounter) = i
	*ENDIF
*ENDDO


!++++++++++++++++++++++++++++++++++++++++++++++++++++
*IF, PatchCounter, NE, 0, THEN

	!================================================
	*ABSET,'Calculating Isotropic Patch Element', BAR
	
	*DO, i, 1, PatchCounter
	
	 mm = (i/PatchCounter)*100
	*ABCHECK,mm  
	
		apn = Patch_Anum(i)
	
		ASEL, S, AREA, , apn
		ESLA, S
		*GET, nepct, ELEM, 0, COUNT
	
		*Del, elistA%apn%
		*Del, elayrA%apn%
		*Del, etheta1A%apn%
	
		*DIM, 	elistA%apn%,   ARRAY, nepct
		*VGET,	elistA%apn%,   ELEM, , ELIST
		*DIM, 	elayrA%apn%,   ARRAY, nepct
		*DIM, 	etheta1A%apn%, ARRAY, nepct
	
		*DEL, 	YI
		*DEL, 	LING
		*DIM, 	YI,   ARRAY, nepct, 1, 1
		*DIM, 	LING, ARRAY, nepct, 1, 1
		*VFUN,  YI,     COS, LING
	
		*VFACT, Lyr_PatchA%apn%
		*VFUN,  elayrA%apn%, COPY, YI
	
		*VFUN,  etheta1A%apn%, COPY, LING	
	
	*ENDDO
	
	ASEL, ALL
	*ABFINISH

*ENDIF