1*1e99f302SBen Matthews! This software is Copyright (c) 2012-2015 The Regents of the 2*1e99f302SBen Matthews! University of California. All Rights Reserved. 3*1e99f302SBen Matthews! 4*1e99f302SBen Matthews! Permission to copy and modify this software and its documentation 5*1e99f302SBen Matthews! for educational, research and non-profit purposes, without fee, 6*1e99f302SBen Matthews! and without a written agreement is hereby granted, provided that 7*1e99f302SBen Matthews! the above copyright notice, this paragraph and the following three 8*1e99f302SBen Matthews! paragraphs appear in all copies. 9*1e99f302SBen Matthews! 10*1e99f302SBen Matthews! Permission to make commercial use of this software may be obtained 11*1e99f302SBen Matthews! by contacting: 12*1e99f302SBen Matthews! 13*1e99f302SBen Matthews! Technology Transfer Office 14*1e99f302SBen Matthews! 9500 Gilman Drive, Mail Code 0910 15*1e99f302SBen Matthews! University of California 16*1e99f302SBen Matthews! La Jolla, CA 92093-0910 17*1e99f302SBen Matthews! (858) 534-5815 18*1e99f302SBen Matthews! invent@ucsd.edu 19*1e99f302SBen Matthews! 20*1e99f302SBen Matthews! This software program and documentation are copyrighted by The 21*1e99f302SBen Matthews! Regents of the University of California. The software program and 22*1e99f302SBen Matthews! documentation are supplied "as is", without any accompanying 23*1e99f302SBen Matthews! services from The Regents. The Regents does not warrant that the 24*1e99f302SBen Matthews! operation of the program will be uninterrupted or error-free. The 25*1e99f302SBen Matthews! end-user understands that the program was developed for research 26*1e99f302SBen Matthews! purposes and is advised not to rely exclusively on the program for 27*1e99f302SBen Matthews! any reason. 28*1e99f302SBen Matthews! 29*1e99f302SBen Matthews! IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY 30*1e99f302SBen Matthews! PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL 31*1e99f302SBen Matthews! DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS 32*1e99f302SBen Matthews! SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF 33*1e99f302SBen Matthews! CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34*1e99f302SBen Matthews! THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 35*1e99f302SBen Matthews! WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36*1e99f302SBen Matthews! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE 37*1e99f302SBen Matthews! SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE 38*1e99f302SBen Matthews! UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE 39*1e99f302SBen Matthews! MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 40*1e99f302SBen Matthews 41*1e99f302SBen Matthews SUBROUTINE svLS_BC_CREATE (lhs, faIn, nNo, dof, BC_type, gNodes, 42*1e99f302SBen Matthews 2 Val) 43*1e99f302SBen Matthews 44*1e99f302SBen Matthews INCLUDE "svLS_STD.h" 45*1e99f302SBen Matthews 46*1e99f302SBen Matthews TYPE(svLS_lhsType), INTENT(INOUT) :: lhs 47*1e99f302SBen Matthews INTEGER, INTENT(IN) :: faIn, nNo, dof 48*1e99f302SBen Matthews INTEGER, INTENT(IN) :: BC_type 49*1e99f302SBen Matthews INTEGER, INTENT(IN) :: gNodes(nNo) 50*1e99f302SBen Matthews REAL*8, INTENT(IN), OPTIONAL :: Val(dof,nNo) 51*1e99f302SBen Matthews 52*1e99f302SBen Matthews INTEGER a, Ac, i 53*1e99f302SBen Matthews REAL*8, ALLOCATABLE :: v(:,:) 54*1e99f302SBen Matthews 55*1e99f302SBen Matthews IF (faIn .GT. lhs%nFaces) THEN 56*1e99f302SBen Matthews PRINT *, "faIn is exceeding lhs structure maximum number of", 57*1e99f302SBen Matthews 2 "face:", lhs%nFaces, ">", faIn 58*1e99f302SBen Matthews STOP 59*1e99f302SBen Matthews END IF 60*1e99f302SBen Matthews IF (faIn .LT. 0) THEN 61*1e99f302SBen Matthews PRINT *, "faIn is should be greater than zero" 62*1e99f302SBen Matthews STOP 63*1e99f302SBen Matthews END IF 64*1e99f302SBen Matthews 65*1e99f302SBen Matthews IF (lhs%face(faIn)%foC) THEN 66*1e99f302SBen Matthews PRINT *, "BC(", faIn,") is not free" 67*1e99f302SBen Matthews PRINT *, "You may use svLS_BC_FREE to free this structure" 68*1e99f302SBen Matthews END IF 69*1e99f302SBen Matthews 70*1e99f302SBen Matthews lhs%face(faIn)%nNo = nNo 71*1e99f302SBen Matthews lhs%face(faIn)%dof = dof 72*1e99f302SBen Matthews lhs%face(faIn)%bGrp = BC_type 73*1e99f302SBen Matthews 74*1e99f302SBen Matthews ALLOCATE(lhs%face(faIn)%glob(nNo), lhs%face(faIn)%val(dof,nNo), 75*1e99f302SBen Matthews 2 lhs%face(faIn)%valM(dof,nNo)) 76*1e99f302SBen Matthews 77*1e99f302SBen Matthews DO a=1, nNo 78*1e99f302SBen Matthews Ac = lhs%map(gNodes(a)) 79*1e99f302SBen Matthews lhs%face(faIn)%glob(a) = Ac 80*1e99f302SBen Matthews END DO 81*1e99f302SBen Matthews 82*1e99f302SBen Matthews IF (PRESENT(Val)) THEN 83*1e99f302SBen Matthews DO a=1, nNo 84*1e99f302SBen Matthews lhs%face(faIn)%val(:,a) = Val(:,a) 85*1e99f302SBen Matthews END DO 86*1e99f302SBen Matthews ELSE 87*1e99f302SBen Matthews lhs%face(faIn)%val = 0D0 88*1e99f302SBen Matthews END IF 89*1e99f302SBen Matthews 90*1e99f302SBen Matthews IF (lhs%commu%nTasks .GT. 1) THEN 91*1e99f302SBen Matthews a = 0 92*1e99f302SBen Matthews IF (lhs%face(faIn)%nNo .NE. 0) a = 1 93*1e99f302SBen Matthews CALL MPI_ALLREDUCE(a, Ac, 1, mpint, 94*1e99f302SBen Matthews 2 MPI_SUM, lhs%commu%comm, i) 95*1e99f302SBen Matthews IF (Ac .GT. 1) THEN 96*1e99f302SBen Matthews lhs%face(faIn)%sharedFlag = .TRUE. 97*1e99f302SBen Matthews IF (.NOT.ALLOCATED(v)) ALLOCATE(v(dof,lhs%nNo)) 98*1e99f302SBen Matthews v = 0D0 99*1e99f302SBen Matthews DO a=1, nNo 100*1e99f302SBen Matthews Ac = lhs%face(faIn)%glob(a) 101*1e99f302SBen Matthews v(:,Ac) = lhs%face(faIn)%val(:,a) 102*1e99f302SBen Matthews END DO 103*1e99f302SBen Matthews CALL COMMUV(dof, lhs%nNo, lhs%commu, lhs%cS, v) 104*1e99f302SBen Matthews 105*1e99f302SBen Matthews DO a=1, nNo 106*1e99f302SBen Matthews Ac = lhs%face(faIn)%glob(a) 107*1e99f302SBen Matthews lhs%face(faIn)%val(:,a) = v(:,Ac) 108*1e99f302SBen Matthews END DO 109*1e99f302SBen Matthews END IF 110*1e99f302SBen Matthews END IF 111*1e99f302SBen Matthews 112*1e99f302SBen Matthews RETURN 113*1e99f302SBen Matthews END SUBROUTINE svLS_BC_CREATE 114*1e99f302SBen Matthews 115*1e99f302SBen Matthews!==================================================================== 116*1e99f302SBen Matthews 117*1e99f302SBen Matthews SUBROUTINE svLS_BC_FREE (lhs, faIn) 118*1e99f302SBen Matthews 119*1e99f302SBen Matthews INCLUDE "svLS_STD.h" 120*1e99f302SBen Matthews 121*1e99f302SBen Matthews TYPE(svLS_lhsType), INTENT(INOUT) :: lhs 122*1e99f302SBen Matthews INTEGER, INTENT(IN) :: faIn 123*1e99f302SBen Matthews 124*1e99f302SBen Matthews IF (.NOT.lhs%face(faIn)%foC) THEN 125*1e99f302SBen Matthews PRINT *, 'Cannot free face:', faIn 126*1e99f302SBen Matthews PRINT *, 'It is not created yet' 127*1e99f302SBen Matthews STOP 128*1e99f302SBen Matthews END IF 129*1e99f302SBen Matthews lhs%face(faIn)%foC = .FALSE. 130*1e99f302SBen Matthews lhs%face(faIn)%nNo = 0 131*1e99f302SBen Matthews lhs%face(faIn)%bGrp = BC_TYPE_Dir 132*1e99f302SBen Matthews lhs%face(faIn)%res = 0D0 133*1e99f302SBen Matthews lhs%face(faIn)%sharedFlag = .FALSE. 134*1e99f302SBen Matthews 135*1e99f302SBen Matthews DEALLOCATE(lhs%face(faIn)%glob, lhs%face(faIn)%val, 136*1e99f302SBen Matthews 2 lhs%face(faIn)%valM) 137*1e99f302SBen Matthews 138*1e99f302SBen Matthews RETURN 139*1e99f302SBen Matthews END SUBROUTINE svLS_BC_FREE 140*1e99f302SBen Matthews 141