My Project
shape_coef_gcn.f90
Go to the documentation of this file.
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 !/===========================================================================/
13 ! Copyright (c) 2007, The University of Massachusetts Dartmouth
14 ! Produced at the School of Marine Science & Technology
15 ! Marine Ecosystem Dynamics Modeling group
16 ! All rights reserved.
17 !
18 ! FVCOM has been developed by the joint UMASSD-WHOI research team. For
19 ! details of authorship and attribution of credit please see the FVCOM
20 ! technical manual or contact the MEDM group.
21 !
22 !
23 ! This file is part of FVCOM. For details, see http://fvcom.smast.umassd.edu
24 ! The full copyright notice is contained in the file COPYRIGHT located in the
25 ! root directory of the FVCOM code. This original header must be maintained
26 ! in all distributed versions.
27 !
28 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 ! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30 ! THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 ! PURPOSE ARE DISCLAIMED.
32 !
33 !/---------------------------------------------------------------------------/
34 ! CVS VERSION INFORMATION
35 ! $Id$
36 ! $Name$
37 ! $Revision$
38 !/===========================================================================/
39 
40  SUBROUTINE shape_coef_gcn
41 
42 !----------------------------------------------------------------------!
43 ! This subrountine is used to calculate the coefficient for a linear !
44 ! function on the x-y plane, i.e.: !
45 ! r(x,y;phai)=phai_c+cofa1*x+cofa2*y !
46 ! innc(i)=0 cells on the boundary !
47 ! innc(i)=1 cells in the interior !
48 !----------------------------------------------------------------------!
49 
50  USE all_vars
51  USE mod_utils
52  IMPLICIT NONE
53  REAL(DP) X1,X2,X3,Y1,Y2,Y3,DELT,AI1,AI2,AI3,BI1,BI2,BI3,CI1,CI2,CI3
54  REAL(DP) DELTX,DELTY,TEMP1,ANG1,ANG2,B1,B2,ANGLE
55  INTEGER I,II,J,JJ,J1,J2
56 !
57 !---------------interior cells-----------------------------------------!
58 !
59  IF(dbg_set(dbg_log)) THEN
60  WRITE(ipt,*) "!"
61  WRITE(ipt,*) "! SETTING UP LINEAR INTEROPOLATION COEFFICIENTS"
62  END IF
63 
64  DO i=1,n
65  IF(isbce(i) == 0)THEN
66  y1 = yc(nbe(i,1))-yc(i)
67  y2 = yc(nbe(i,2))-yc(i)
68  y3 = yc(nbe(i,3))-yc(i)
69  x1=xc(nbe(i,1))-xc(i)
70  x2=xc(nbe(i,2))-xc(i)
71  x3=xc(nbe(i,3))-xc(i)
72 
73  x1=x1/1000.0_sp
74  x2=x2/1000.0_sp
75  x3=x3/1000.0_sp
76  y1=y1/1000.0_sp
77  y2=y2/1000.0_sp
78  y3=y3/1000.0_sp
79 
80  delt=(x1*y2-x2*y1)**2+(x1*y3-x3*y1)**2+(x2*y3-x3*y2)**2
81  delt=delt*1000.
82 
83  a1u(i,1)=(y1+y2+y3)*(x1*y1+x2*y2+x3*y3)- &
84  (x1+x2+x3)*(y1**2+y2**2+y3**2)
85  a1u(i,1)=a1u(i,1)/delt
86  a1u(i,2)=(y1**2+y2**2+y3**2)*x1-(x1*y1+x2*y2+x3*y3)*y1
87  a1u(i,2)=a1u(i,2)/delt
88  a1u(i,3)=(y1**2+y2**2+y3**2)*x2-(x1*y1+x2*y2+x3*y3)*y2
89  a1u(i,3)=a1u(i,3)/delt
90  a1u(i,4)=(y1**2+y2**2+y3**2)*x3-(x1*y1+x2*y2+x3*y3)*y3
91  a1u(i,4)=a1u(i,4)/delt
92 
93  a2u(i,1)=(x1+x2+x3)*(x1*y1+x2*y2+x3*y3)- &
94  (y1+y2+y3)*(x1**2+x2**2+x3**2)
95  a2u(i,1)=a2u(i,1)/delt
96  a2u(i,2)=(x1**2+x2**2+x3**2)*y1-(x1*y1+x2*y2+x3*y3)*x1
97  a2u(i,2)=a2u(i,2)/delt
98  a2u(i,3)=(x1**2+x2**2+x3**2)*y2-(x1*y1+x2*y2+x3*y3)*x2
99  a2u(i,3)=a2u(i,3)/delt
100  a2u(i,4)=(x1**2+x2**2+x3**2)*y3-(x1*y1+x2*y2+x3*y3)*x3
101  a2u(i,4)=a2u(i,4)/delt
102  end if
103 
104  x1=vx(nv(i,1))-xc(i)
105  x2=vx(nv(i,2))-xc(i)
106  x3=vx(nv(i,3))-xc(i)
107  y1=vy(nv(i,1))-yc(i)
108  y2=vy(nv(i,2))-yc(i)
109  y3=vy(nv(i,3))-yc(i)
110 
111 
112  ai1=y2-y3
113  ai2=y3-y1
114  ai3=y1-y2
115  bi1=x3-x2
116  bi2=x1-x3
117  bi3=x2-x1
118  ci1=x2*y3-x3*y2
119  ci2=x3*y1-x1*y3
120  ci3=x1*y2-x2*y1
121 
122  aw0(i,1)=-ci1/2./art(i)
123  aw0(i,2)=-ci2/2./art(i)
124  aw0(i,3)=-ci3/2./art(i)
125  awx(i,1)=-ai1/2./art(i)
126  awx(i,2)=-ai2/2./art(i)
127  awx(i,3)=-ai3/2./art(i)
128  awy(i,1)=-bi1/2./art(i)
129  awy(i,2)=-bi2/2./art(i)
130  awy(i,3)=-bi3/2./art(i)
131  end do
132 
133 !
134 !--------boundary cells------------------------------------------------!
135 !
136  do i=1,n
137  if(isbce(i) > 1) then
138  do j=1,4
139  a1u(i,j)=0.0_sp
140  a2u(i,j)=0.0_sp
141  end do
142  else if(isbce(i) == 1) then
143  do j=1,3
144  if(nbe(i,j) == 0) jj=j
145  end do
146  j1=jj+1-int((jj+1)/4)*3
147  j2=jj+2-int((jj+2)/4)*3
148  x1=vx(nv(i,j1))-xc(i)
149  x2=vx(nv(i,j2))-xc(i)
150  y1=vy(nv(i,j1))-yc(i)
151  y2=vy(nv(i,j2))-yc(i)
152 
153  delt=x1*y2-x2*y1
154  b1=(y2-y1)/delt
155  b2=(x1-x2)/delt
156  deltx=vx(nv(i,j1))-vx(nv(i,j2))
157  delty=vy(nv(i,j1))-vy(nv(i,j2))
158 
159  alpha(i)=atan2(delty,deltx)
160  alpha(i)=alpha(i)-3.1415926_sp/2.0_sp
161  x1=xc(nbe(i,j1))-xc(i)
162  x2=xc(nbe(i,j2))-xc(i)
163  y1=yc(nbe(i,j1))-yc(i)
164  y2=yc(nbe(i,j2))-yc(i)
165  temp1=x1*y2-x2*y1
166 
167  if(abs(temp1).lt.1.e-6_sp) then
168  print*, 'shape_f of solid b. c. temp1=0'
169  print*, 'i,jj,j1,j2,x1,x2,y1,y2'
170  print*, i,jj,j1,j2,x1,x2,y1,y2
171  print*, 'x1*y2==',x1*y2
172  print*, 'x2*y1==',x2*y1
173  call pstop
174  end if
175 
176  a1u(i,1)=0.0_sp
177  a1u(i,jj+1)=0.0_sp
178  a1u(i,j1+1)=0.0_sp
179  a1u(i,j2+1)=0.0_sp
180 
181  a2u(i,1)=0.0_sp
182  a2u(i,jj+1)=0.0_sp
183  a2u(i,j1+1)=0.0_sp
184  a2u(i,j2+1)=0.0_sp
185  end if
186  end do
187 
188 
189  ang1=359.9_sp/180.0_sp*3.1415926_sp
190  ang2=-0.1_sp/180.0_sp*3.1415926_sp
191 
192  do i=1,m
193  if((isonb(i).eq.1).and.(ntve(i).gt.2)) then
194  angle=alpha(nbve(i,ntve(i)))-alpha(nbve(i,1))
195  if(angle.gt.ang1) then
196  angle=100000.0_sp
197  else if(angle.gt.3.1415926_sp) then
198  angle=angle-2.0_sp*3.1415926_sp
199  else if(angle.lt.-3.1415926_sp) then
200  angle=angle+2.0_sp*3.1415926_sp
201  else if(angle.lt.ang2) then
202  angle=100000.0_sp
203  end if
204  do j=2,ntve(i)-1
205  ii=nbve(i,j)
206  if(isbce(ii).ne.1) then
207  alpha(ii)=alpha(nbve(i,1))+ &
208  angle/float(ntve(i)-1)*float(j-1)
209  end if
210  end do
211  end if
212  end do
213 
214 
215  IF(dbg_set(dbg_log)) THEN
216  WRITE(ipt,*) "!"
217  WRITE(ipt,*) "! INTERP COEFFICIENTS : COMPLETE"
218  END IF
219 
220  return
221  end subroutine shape_coef_gcn
real(sp), dimension(:), allocatable, target alpha
Definition: mod_main.f90:1336
real(sp), dimension(:), allocatable, target art
Definition: mod_main.f90:1009
subroutine shape_coef_gcn
logical function dbg_set(vrb)
Definition: mod_utils.f90:182
real(sp), dimension(:), allocatable, target yc
Definition: mod_main.f90:1004
real(sp), dimension(:,:), allocatable, target a1u
Definition: mod_main.f90:1331
real(sp), dimension(:,:), allocatable, target awx
Definition: mod_main.f90:1333
real(sp), dimension(:,:), allocatable, target aw0
Definition: mod_main.f90:1335
real(sp), dimension(:,:), allocatable, target awy
Definition: mod_main.f90:1334
real(sp), dimension(:), allocatable, target vx
Definition: mod_main.f90:1001
subroutine pstop
Definition: mod_utils.f90:273
real(sp), dimension(:), allocatable, target vy
Definition: mod_main.f90:1002
integer, dimension(:), allocatable, target ntve
Definition: mod_main.f90:1022
integer, dimension(:,:), allocatable, target nbe
Definition: mod_main.f90:1020
integer, dimension(:,:), allocatable, target nv
Definition: mod_main.f90:1018
real(sp), dimension(:,:), allocatable, target a2u
Definition: mod_main.f90:1332
integer, dimension(:,:), allocatable, target nbve
Definition: mod_main.f90:1034
real(sp), dimension(:), allocatable, target xc
Definition: mod_main.f90:1003
integer, dimension(:), allocatable, target isbce
Definition: mod_main.f90:1027
integer, dimension(:), allocatable, target isonb
Definition: mod_main.f90:1024
integer, parameter dbg_log
Definition: mod_utils.f90:65