Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
genxyz.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------
3 !-------------------------------------------------------------------
4 subroutine setdef()
5  use kinds, only : dp
6  use size_m, only : nid, nelt
7  use input, only : param, ifmvbd, if3d, ccurve, xc, yc, zc
8  use mesh, only : ifdfrm
9  implicit none
10 
11  real(DP) :: XCC(8),YCC(8),ZCC(8)
12  integer :: INDX(8)
13  REAL(DP) :: VEC(3,12)
14  LOGICAL :: IFVCHK
15 
16  integer :: ie, iedg, i, i1, j, i2
17  real(DP) :: veclen
18 
19 ! Corner notation:
20 
21 ! 4+-----+3 ^ Y
22 ! / /| |
23 ! / / | |
24 ! 8+-----+7 +2 +----> X
25 ! | | / /
26 ! | |/ /
27 ! 5+-----+6 Z
28 
29 
30  DO ie=1,nelt
31  ifdfrm(ie)= .false.
32  END DO
33 
34  IF (ifmvbd) return
35 
36 ! Force IFDFRM=.true. for all elements (for timing purposes only)
37 
38  IF (param(59) /= 0 .AND. nid == 0) &
39  write(6,*) 'NOTE: All elements deformed , param(59) ^=0'
40  IF (param(59) /= 0) return
41 
42 ! Check against cases which won't allow for savings in HMHOLTZ
43 
44  indx(1)=1
45  indx(2)=2
46  indx(3)=4
47  indx(4)=3
48  indx(5)=5
49  indx(6)=6
50  indx(7)=8
51  indx(8)=7
52 
53 ! Check for deformation (rotation is acceptable).
54 
55  DO 500 ie=1,nelt
56 
57  vec = 0._dp
58  IF (if3d) THEN
59  DO 100 iedg=1,8
60  IF(ccurve(iedg,ie) /= ' ') THEN
61  ifdfrm(ie)= .true.
62  goto 500
63  ENDIF
64  100 END DO
65 
66  DO 105 i=1,8
67  xcc(i)=xc(indx(i),ie)
68  ycc(i)=yc(indx(i),ie)
69  zcc(i)=zc(indx(i),ie)
70  105 END DO
71 
72  DO 110 i=1,4
73  vec(1,i)=xcc(2*i)-xcc(2*i-1)
74  vec(2,i)=ycc(2*i)-ycc(2*i-1)
75  vec(3,i)=zcc(2*i)-zcc(2*i-1)
76  110 END DO
77 
78  i1=4
79  DO i=0,1
80  DO j=0,1
81  i1=i1+1
82  i2=4*i+j+3
83  vec(1,i1)=xcc(i2)-xcc(i2-2)
84  vec(2,i1)=ycc(i2)-ycc(i2-2)
85  vec(3,i1)=zcc(i2)-zcc(i2-2)
86  enddo
87  enddo
88 
89  i1=8
90  DO 130 i=5,8
91  i1=i1+1
92  vec(1,i1)=xcc(i)-xcc(i-4)
93  vec(2,i1)=ycc(i)-ycc(i-4)
94  vec(3,i1)=zcc(i)-zcc(i-4)
95  130 END DO
96 
97  DO 140 i=1,12
98  veclen = vec(1,i)**2 + vec(2,i)**2 + vec(3,i)**2
99  veclen = sqrt(veclen)
100  vec(1,i)=vec(1,i)/veclen
101  vec(2,i)=vec(2,i)/veclen
102  vec(3,i)=vec(3,i)/veclen
103  140 END DO
104 
105  ! Check the dot product of the adjacent edges to see that it is zero.
106 
107  ifdfrm(ie)= .false.
108  IF ( ifvchk(vec,1,5, 9) ) ifdfrm(ie)= .true.
109  IF ( ifvchk(vec,1,6,10) ) ifdfrm(ie)= .true.
110  IF ( ifvchk(vec,2,5,11) ) ifdfrm(ie)= .true.
111  IF ( ifvchk(vec,2,6,12) ) ifdfrm(ie)= .true.
112  IF ( ifvchk(vec,3,7, 9) ) ifdfrm(ie)= .true.
113  IF ( ifvchk(vec,3,8,10) ) ifdfrm(ie)= .true.
114  IF ( ifvchk(vec,4,7,11) ) ifdfrm(ie)= .true.
115  IF ( ifvchk(vec,4,8,12) ) ifdfrm(ie)= .true.
116 
117  ! Check the 2D case....
118 
119  ELSE
120 
121  DO 200 iedg=1,4
122  IF(ccurve(iedg,ie) /= ' ') THEN
123  ifdfrm(ie)= .true.
124  goto 500
125  ENDIF
126  200 END DO
127 
128  DO 205 i=1,4
129  xcc(i)=xc(indx(i),ie)
130  ycc(i)=yc(indx(i),ie)
131  205 END DO
132 
133  vec(1,1)=xcc(2)-xcc(1)
134  vec(1,2)=xcc(4)-xcc(3)
135  vec(1,3)=xcc(3)-xcc(1)
136  vec(1,4)=xcc(4)-xcc(2)
137  vec(1,5)=0.0
138  vec(2,1)=ycc(2)-ycc(1)
139  vec(2,2)=ycc(4)-ycc(3)
140  vec(2,3)=ycc(3)-ycc(1)
141  vec(2,4)=ycc(4)-ycc(2)
142  vec(2,5)=0.0
143 
144  DO 220 i=1,4
145  veclen = vec(1,i)**2 + vec(2,i)**2
146  veclen = sqrt(veclen)
147  vec(1,i)=vec(1,i)/veclen
148  vec(2,i)=vec(2,i)/veclen
149  220 END DO
150 
151  ! Check the dot product of the adjacent edges to see that it is zero.
152 
153  ifdfrm(ie)= .false.
154  IF ( ifvchk(vec,1,3,5) ) ifdfrm(ie)= .true.
155  IF ( ifvchk(vec,1,4,5) ) ifdfrm(ie)= .true.
156  IF ( ifvchk(vec,2,3,5) ) ifdfrm(ie)= .true.
157  IF ( ifvchk(vec,2,4,5) ) ifdfrm(ie)= .true.
158  ENDIF
159  500 END DO
160  return
161 end subroutine setdef
162 
164 LOGICAL FUNCTION ifvchk(VEC,I1,I2,I3)
165  use kinds, only : dp
166  implicit none
167 
168  real(DP) :: vec(3,12)
169  integer :: i1, i2, i3
170  LOGICAL :: IFTMP
171 
172  real(DP) :: epsm, dot1, dot2, dot3, dot
173 
174  iftmp= .false.
175  epsm=1.0e-06
176 
177  dot1=vec(1,i1)*vec(1,i2)+vec(2,i1)*vec(2,i2)+vec(3,i1)*vec(3,i2)
178  dot2=vec(1,i2)*vec(1,i3)+vec(2,i2)*vec(2,i3)+vec(3,i2)*vec(3,i3)
179  dot3=vec(1,i1)*vec(1,i3)+vec(2,i1)*vec(2,i3)+vec(3,i1)*vec(3,i3)
180 
181  dot1=abs(dot1)
182  dot2=abs(dot2)
183  dot3=abs(dot3)
184  dot=dot1+dot2+dot3
185  IF (dot > epsm) iftmp= .true.
186 
187  ifvchk=iftmp
188  return
189 END FUNCTION ifvchk
190 
191 !-----------------------------------------------------------------------
195 !-----------------------------------------------------------------------
196 subroutine gencoor ()!xm3,ym3,zm3)
197  use size_m, only : nx1, ny1, nz1
198  use geom, only : ifgmsh3, xm1, ym1, zm1
199  implicit none
200 
201 !max real(DP) :: XM3(LX3,LY3,LZ3,1),YM3(LX3,LY3,LZ3,1),ZM3(LX3,LY3,LZ3,1)
202 
203 ! Select appropriate mesh
204  IF ( ifgmsh3 ) THEN
205  write(*,*) "Oops: IFGMSH3"
206 !max CALL GENXYZ (XM3,YM3,ZM3,NX3,NY3,NZ3)
207  ELSE
208  CALL genxyz(xm1,ym1,zm1,nx1,ny1,nz1)
209  ENDIF
210 
211  return
212 end subroutine gencoor
213 
214 !-----------------------------------------------------------------------
215 subroutine genxyz (xml,yml,zml,nxl,nyl,nzl)
216  use kinds, only : dp
217  use size_m, only : lx1, nelt, ndim
218  use input, only : ccurve, ifaxis
219  implicit none
220 
221  integer :: nxl, nyl, nzl
222  real(DP) :: xml(nxl,nyl,nzl,1),yml(nxl,nyl,nzl,1),zml(nxl,nyl,nzl,1)
223 
224  real(DP) :: h(lx1,3,2), zgml(lx1,3)
225 
226  character(1) :: ccv
227  integer :: ie, nfaces, iface, isid
228 
229 
230 #ifdef MOAB
231 ! already read/initialized vertex positions
232  if (ifmoab) return
233 #endif
234 
235 ! Initialize geometry arrays with bi- triquadratic deformations
236  call linquad(xml,yml,zml,nxl,nyl,nzl)
237 
238  do ie=1,nelt
239 
240  call setzgml(zgml,ie,nxl,nyl,nzl,ifaxis)
241  call sethmat(h,zgml,nxl,nyl,nzl)
242 
243  ! Deform surfaces - general 3D deformations
244  ! - extruded geometry deformations
245  nfaces = 2*ndim
246  do iface=1,nfaces
247  ccv = ccurve(iface,ie)
248  if (ccv == 's') then
249  write(*,*) "Oops: ccv = 's'"
250 !max call sphsrf(xml,yml,zml,iface,ie,nxl,nyl,nzl,work)
251  endif
252  if (ccv == 'e') then
253  write(*,*) "Oops: ccv = 'e'"
254 !max call gensrf(xml,yml,zml,iface,ie,nxl,nyl,nzl,zgml)
255  endif
256  enddo
257 
258  do isid=1,8
259  ccv = ccurve(isid,ie)
260  if (ccv == 'C') then
261  write(*,*) "Oops: ccv = 'C'"
262 !max call arcsrf(xml,yml,zml,nxl,nyl,nzl,ie,isid)
263  endif
264  enddo
265 
266  enddo
267 
268  return
269 end subroutine genxyz
270 
271 !-----------------------------------------------------------------------
272 subroutine sethmat(h,zgml,nxl,nyl,nzl)
273  use kinds, only : dp
274  use size_m, only : lx1
275  use input, only : if3d
276  implicit none
277 
278  real(DP) :: h(lx1,3,2),zgml(lx1,3)
279  integer :: nxl, nyl, nzl
280 
281  integer :: ix, iy, iz
282 
283  do 10 ix=1,nxl
284  h(ix,1,1)=(1.0-zgml(ix,1))*0.5
285  h(ix,1,2)=(1.0+zgml(ix,1))*0.5
286  10 END DO
287  do 20 iy=1,nyl
288  h(iy,2,1)=(1.0-zgml(iy,2))*0.5
289  h(iy,2,2)=(1.0+zgml(iy,2))*0.5
290  20 END DO
291  if (if3d) then
292  do 30 iz=1,nzl
293  h(iz,3,1)=(1.0-zgml(iz,3))*0.5
294  h(iz,3,2)=(1.0+zgml(iz,3))*0.5
295  30 END DO
296  else
297  h(:,3,:) = 1._dp
298  endif
299 
300  return
301 end subroutine sethmat
302 
303 !-----------------------------------------------------------------------
304 subroutine setzgml (zgml,e,nxl,nyl,nzl,ifaxl)
305  use kinds, only : dp
306  use size_m, only : lx1, nx1, nx3, ny1, nz1
307  use geom, only : ifgmsh3, ifrzer
308  use wz_m, only : zgm1
309  implicit none
310 
311  real(DP), intent(out) :: zgml(lx1,3)
312  integer :: e, nxl, nyl, nzl
313  logical :: ifaxl
314 
315  integer :: k
316  real(DP) :: zam1
317 
318  zgml = 0._dp
319 
320  if (nxl == 3 .AND. .NOT. ifaxl) then
321  do k=1,3
322  zgml(1,k) = -1
323  zgml(2,k) = 0
324  zgml(3,k) = 1
325  enddo
326  elseif (ifgmsh3 .AND. nxl == nx3) then
327  write(*,*) "Oops: IFGMSH3"
328 #if 0
329  call copy(zgml(1,1),zgm3(1,1),nx3)
330  call copy(zgml(1,2),zgm3(1,2),ny3)
331  call copy(zgml(1,3),zgm3(1,3),nz3)
332  if (ifaxl .AND. ifrzer(e)) call copy(zgml(1,2),zam3,ny3)
333 #endif
334  elseif (nxl == nx1 .and. nyl == ny1 .and. nzl == nz1) then
335  call copy(zgml(1,1),zgm1(1,1),nxl)
336  call copy(zgml(1,2),zgm1(1,2),nyl)
337  call copy(zgml(1,3),zgm1(1,3),nzl)
338  if (ifaxl .AND. ifrzer(e)) call copy(zgml(1,2),zam1,ny1)
339  else
340  call exitti('ABORT setzgml! $',nxl)
341  endif
342 
343  return
344  end subroutine setzgml
345 
346 !-----------------------------------------------------------------------
348 REAL(DP) FUNCTION dot(V1,V2,N)
349  use kinds, only : dp
350  implicit none
351 
352  integer :: n
353  real(DP) :: V1(n),V2(n)
354 
355  real(DP) :: sum
356  integer :: i
357 
358  sum = 0
359  DO 100 i=1,n
360  sum = sum + v1(i)*v2(i)
361  100 END DO
362  dot = sum
363  return
364 END FUNCTION dot
365 
366 !-----------------------------------------------------------------------
367 subroutine linquad(xl,yl,zl,nxl,nyl,nzl)
368  use kinds, only : dp
369  use size_m, only : ndim, nelt, lx1
370  use input, only : ccurve, ifaxis
371  implicit none
372 
373  integer :: nxl, nyl, nzl
374  real(DP) :: xl(nxl*nyl*nzl,*),yl(nxl*nyl*nzl,*),zl(nxl*nyl*nzl,*)
375 
376  integer :: e, nedge, k
377  logical :: ifmid
378 
379  nedge = 4 + 8*(ndim-2)
380 
381  do e=1,nelt ! Loop over all elements
382 
383  ifmid = .false.
384  do k=1,nedge
385  if (ccurve(k,e) == 'm') ifmid = .true.
386  enddo
387 
388  if (lx1 == 2) ifmid = .false.
389  if (ifmid) then
390  write(*,*) "Oops: ifmid"
391 !max call xyzquad(xl(1,e),yl(1,e),zl(1,e),nxl,nyl,nzl,e)
392  else
393  call xyzlin(xl(1,e),yl(1,e),zl(1,e),nxl,nyl,nzl,e,ifaxis)
394  endif
395  enddo
396 
397  return
398 end subroutine linquad
399 
400 !-----------------------------------------------------------------------
402 subroutine xyzlin(xl,yl,zl,nxl,nyl,nzl,e,ifaxl)
403  use kinds, only : dp
404  use size_m, only : lx1, ly1, lz1, ndim
405  use input, only : xc, yc, zc
406  implicit none
407 
408  integer :: nxl, nyl, nzl, e
409  real(DP) :: xl(nxl,nyl,nzl),yl(nxl,nyl,nzl),zl(nxl,nyl,nzl)
410  logical :: ifaxl ! local ifaxis specification
411 
412 ! Preprocessor Corner notation: Symmetric Corner notation:
413 
414 ! 4+-----+3 ^ s 3+-----+4 ^ s
415 ! / /| | / /| |
416 ! / / | | / / | |
417 ! 8+-----+7 +2 +----> r 7+-----+8 +2 +----> r
418 ! | | / / | | / /
419 ! | |/ / | |/ /
420 ! 5+-----+6 t 5+-----+6 t
421 
422  integer, save :: indx(8) = (/ 1,2,4,3,5,6,8,7 /)
423 
424  integer, parameter :: ldw=4*lx1*ly1*lz1
425  real(DP) :: xcb(2,2,2),ycb(2,2,2),zcb(2,2,2),w(ldw)
426 
427 ! real(DP) :: zgml, jx,jy,jz,jxt,jyt,jzt, zlin
428  real(DP) :: zgml(lx1,3),jx (lx1*2)
429  real(DP) :: jxt(lx1*2),jyt(lx1*2),jzt(lx1*2),zlin(2)
430 
431  integer :: i, k, ndim2
432 
433  call setzgml(zgml,e,nxl,nyl,nzl,ifaxl)
434 
435  zlin(1) = -1
436  zlin(2) = 1
437 
438  k = 1
439  do i=1,nxl
440  call fd_weights_full(zgml(i,1),zlin,1,0,jxt(k))
441  call fd_weights_full(zgml(i,2),zlin,1,0,jyt(k))
442  call fd_weights_full(zgml(i,3),zlin,1,0,jzt(k))
443  k=k+2
444  enddo
445  call transpose(jx,nxl,jxt,2)
446 
447  ndim2 = 2**ndim
448  ! Convert prex notation to lexicographical
449  xcb = reshape(xc(indx(1:ndim2),e), (/2,2,2/))
450  ycb = reshape(yc(indx(1:ndim2),e), (/2,2,2/))
451  zcb = reshape(zc(indx(1:ndim2),e), (/2,2,2/))
452 
453 ! Map R-S-T space into physical X-Y-Z space.
454 
455 ! NOTE: Assumes nxl=nyl=nzl !
456 
457  call tensr3(xl,nxl,xcb,2,jx,jyt,jzt,w)
458  call tensr3(yl,nxl,ycb,2,jx,jyt,jzt,w)
459  call tensr3(zl,nxl,zcb,2,jx,jyt,jzt,w)
460 
461  return
462 end subroutine xyzlin
463 !-----------------------------------------------------------------------
real(dp) function dot(V1, V2, N)
Compute Cartesian vector dot product.
Definition: genxyz.F90:348
Input parameters from preprocessors.
Definition: input_mod.F90:11
cleaned
Definition: wz_mod.F90:2
subroutine xyzlin(xl, yl, zl, nxl, nyl, nzl, e, ifaxl)
Generate bi- or trilinear mesh.
Definition: genxyz.F90:402
logical function ifvchk(VEC, I1, I2, I3)
Take the dot product of the three components of VEC to see if it's zero.
Definition: genxyz.F90:164
subroutine fd_weights_full(xx, x, n, m, c)
This routine evaluates the derivative based on all points in the stencils. It is more memory efficien...
Definition: fast3d.F90:409
cleaned
Definition: mesh_mod.F90:2
subroutine copy(a, b, n)
Definition: math.F90:52
subroutine setzgml(zgml, e, nxl, nyl, nzl, ifaxl)
Definition: genxyz.F90:304
subroutine linquad(xl, yl, zl, nxl, nyl, nzl)
Definition: genxyz.F90:367
subroutine genxyz(xml, yml, zml, nxl, nyl, nzl)
Definition: genxyz.F90:215
subroutine sethmat(h, zgml, nxl, nyl, nzl)
Definition: genxyz.F90:272
Geometry arrays.
Definition: geom_mod.F90:2
subroutine gencoor()
Generate xyz coordinates for all elements. Velocity formulation : mesh 3 is used Stress formulation :...
Definition: genxyz.F90:196
subroutine setdef()
Set up deformed element logical switches.
Definition: genxyz.F90:4
subroutine exitti(stringi, idata)
Definition: comm_mpi.F90:328
subroutine tensr3(v, nv, u, nu, A, Bt, Ct, w)
Tensor product application of v = (C x B x A) u . NOTE – the transpose of B & C must be input...
Definition: fasts.F90:5