subroutine compute_ubar
include 'SIZE'
include 'TOTAL'
include 'NEKUSE'
c Initialize the parameters
real ubar, vbar, wbar, U_mean
c Total number of grid points
n = nx1*ny1*nz1*nelv
c Computing the mean velocity in the domain
ubar = glsc2(vx,bm1,n)/volvm1
vbar = glsc2(vy,bm1,n)/volvm1
wbar = glsc2(vz,bm1,n)/volvm1
U_mean = (ubar**2+vbar**2+wbar**2)**0.5
c Print it to the screen
c If I comment out the if statement it prints out the results n times if I am using n mpi ranks.
c if(nio.eq.0) then
write (*,*) U_mean
c endif
return
end
--
You received this message because you are subscribed to the Google Groups "Nek5000" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nek5000+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nek5000/CACqPjWG-3AfEDFSt_jpTHeqeGhc1XcGTPaQXzPGZ_O4ts1UqrA%40mail.gmail.com.
subroutine myZAverage
include 'SIZE'
include 'TOTAL'
real ua(nz1),w1(nz1),w2(nz1)
call planar_average_z(ua,vx,w1,w2)
return
end
When i use this below routine it says nelz cannot show up here error. So I am a little confused as to what the hell is happening (hopefully I am doing something stupid).
subroutine myZAverage
include 'SIZE'
include 'TOTAL'
real ua(nz1,nelz),w1(nz1,nelz),w2(nz1,nelz)
call planar_average_z(ua,vx,w1,w2)
return
end
idir = 3 ! z
call gtpp_gs_setup(igs_z,nelx*nely,1,nelz,idir)
call planar_avg(uavg_z,vx,igs_z)
gtpp_gs_setup: invalid gtp mesh dimensions!
subroutine gtpp_gs_setup(hndl,nelgx,nelgy,nelgz,idir)
include 'SIZE'
include 'TOTAL'
integer hndl,nelgx,nelgy,nelgz,idir
common /nekmpi/ mid,mp,nekcomm,nekgroup,nekreal
common /c_is1/ glo_num(lx1,ly1,lz1,lelv)
integer e,ex,ey,ez,eg
integer*8 glo_num,ex_g
nelgxyz = nelgx*nelgy*nelgz
if (nelgxyz .ne. nelgv)
$ call exitti('gtpp_gs_setup: invalid gtp mesh dimensions!$',
$ nelgxyz)
if(nid .eq. 0) then
print *, 'nelgv:', nelgv, 'nelgxyz:', nelgxyz
endif
The output is nelgv: 1000 nelgxyz: 21966
subroutine userchk()
include 'SIZE'
include 'TOTAL'
include 'ZPER'
c Define the number of elements since userchk() wont know whats in channel.box
nelx=10
nely=10
nelz=10
c Define the direction over which averaging to be done
idir = 3 ! z
call gtpp_gs_setup(igs_z,nelx*nely,1,nelz,idir)
call planar_avg(uavg_z,vx,igs_z)
return
end
To view this discussion on the web visit https://groups.google.com/d/msgid/nek5000/CACqPjWFF%3D0DgCeb6PEsJBFn8tGf-obeCX5p2Yd71CUp7wCXX3Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nek5000/CACqPjWEEdzWzYAmOO0pjS3KyOnh7MvHUHEzj2YSFNZNX%2Bwwrag%40mail.gmail.com.
real uavg_y(lx1*ly1*lz1*lelt)
idir = 2 ! y
call gtpp_gs_setup(igs_y,nelx*nelz,nely,1,idir)
call planar_avg(uavg_y,vx,igs_y)
real uavg_y(lx1*ly1*lz1*lelt), uavg_yx(lx1*ly1*lz1*lelt)
c First average in y and then use that result to average in x
c This way the only values that we get are a function of z (vertical coordinate in my case)
idir = 2 ! y
call gtpp_gs_setup(igs_y,nelx*nelz,nely,1,idir)
call planar_avg(uavg_y,vx,igs_y)
idir = 1 ! x
call gtpp_gs_setup(igs_x,nelx,nely,nelz,idir)
call planar_avg(uavg_yx,uavg_y,igs_x)
c Define the call for averaging
integer icalld
save icalld
data icalld /0/
c Define the averaging parameters
real atime,timel
save atime,timel
c Define the data dumping parameters
integer ntdump
save ntdump
c Define the interpolation stuff
real rwk(INTP_NMAX,ldim+1) ! r, s, t, dist2
integer iwk(INTP_NMAX,3) ! code, proc, el
save rwk, iwk
integer nint, intp_h
save nint, intp_h
logical iffpts
save iffpts
c Define the working array based on the interpolation point number
real xint(INTP_NMAX),yint(INTP_NMAX),zint(INTP_NMAX)
save xint, yint, zint
save igs_x, igs_y
c Define the parameters and the array sizes
parameter(nstat=9)
real ravg(lx1*ly1*lz1*lelt,nstat)
real stat(lx1*ly1*lz1*lelt,nstat)
real stat_z(INTP_NMAX*nstat)
save ravg, stat, stat_z
c Define the working array and logical parameter to save
logical ifverbose
common /gaaa/ wo1(lx1,ly1,lz1,lelv)
c Define a fixed value of the shear velocity
real u_tau
u_tau = 5.3e-3
c Define the number of points
n = nx1*ny1*nz1*nelv
c Define the number of elements in each direction
nelx = NUM_X
nely = NUM_Y
nelz = NUM_Z
c Computing the mean velocities
ubar = glsc2(vx,bm1,n)/volvm1
e2 = glsc3(vy,bm1,vy,n)+glsc3(vz,bm1,vz,n)
e2 = e2/volvm1
c Print the values at each time step
if(nid.eq.0) write(6,*) 'Time:',time,'Ux:',ubar,'Uy+Uz:',e2
if (time.lt.tSTATSTART) return
c
c What follows computes some statistics ...
c
if(icalld.eq.0) then
if(nid.eq.0) write(6,*) 'Start collecting statistics ...', u_tau
nxm = 1 ! mesh is linear
call interp_setup(intp_h,0.0,nxm,nelt)
nint = 0
if (nid.eq.0) then
nint = INTP_NMAX
call cfill(xint,XCINT,size(xint))
call cfill(yint,YCINT,size(yint))
do i = 1,INTP_NMAX
zi = (i-1.)/(INTP_NMAX-1)
zi = 0.1*zi !Rescaling the z values
zint(i) = tanh(BETAM*(2*zi-1))/tanh(BETAM)
enddo
endif
iffpts = .true. ! dummy call to find points
call interp_nfld(stat_z,ravg,1,xint,yint,zint,nint,
$ iwk,rwk,INTP_NMAX,iffpts,intp_h)
iffpts = .false.
call gtpp_gs_setup(igs_x,nelx ,nely,nelz,1) ! x-avx
call gtpp_gs_setup(igs_y,nelx*nelz,nely,1,2) ! y-avg
call rzero(ravg,size(ravg))
atime = 0
timel = time
ntdump = int(time/tSTATFREQ)
icalld = 1
endif
c Set the time averaging parameters
dtime = time - timel
atime = atime + dtime
c Averaging over time
if (atime.ne.0. .and. dtime.ne.0.) then
beta = dtime / atime
alpha = 1. - beta
ifverbose = .false.
call avg1(ravg(1,1),vx ,alpha,beta,n,'uavg',ifverbose)
call avg2(ravg(1,2),vx ,alpha,beta,n,'urms',ifverbose)
call avg2(ravg(1,3),vy ,alpha,beta,n,'vrms',ifverbose)
call avg2(ravg(1,4),vz ,alpha,beta,n,'wrms',ifverbose)
call avg3(ravg(1,5),vx,vy,alpha,beta,n,'uvmm',ifverbose)
call avg1(ravg(1,6),t ,alpha,beta,n,'tavg',ifverbose)
call avg2(ravg(1,7),t ,alpha,beta,n,'trms',ifverbose)
call avg3(ravg(1,8),vx,t ,alpha,beta,n,'utmm',ifverbose)
call avg3(ravg(1,9),vy,t ,alpha,beta,n,'vtmm',ifverbose)
endif
c Reset old time as new time
timel = time
! write statistics to file
if(istep.gt.0 .and. time.gt.(ntdump+1)*tSTATFREQ) then
! averaging over statistical homogeneous directions (x-y)
do i = 1,nstat
call planar_avg(wo1 ,ravg(1,i),igs_x)
call planar_avg(stat(1,i),wo1 ,igs_y)
enddo
! extract data along wall normal direction (1D profile)
call interp_nfld(stat_z,stat,nstat,xint,yint,zint,nint,
$ iwk,rwk,INTP_NMAX,iffpts,intp_h)
ntdump = ntdump + 1
if (nid.ne.0) goto 998
write(6,*) 'Dumping statistics ...'
open(unit=56,file='vel_fluc_prof.dat')
write(56,'(A,1pe14.7)') '#time = ', time
write(56,'(A)')
$ '# z uu vv ww uv'
open(unit=57,file='mean_prof.dat')
write(57,'(A,1pe14.7)') '#time = ', time
write(57,'(A)')
$ '# z Umean'
do i = 1,nint
zz = 1+zint(i)
write(56,3)
& zz,
& (stat_z(1*nint+i)-(stat_z(0*nint+i))**2),
& stat_z(2*nint+i),
& stat_z(3*nint+i),
& stat_z(4*nint+i)
write(57,3)
& zz,
& stat_z(0*nint+i)
3 format(1p15e17.9)
enddo
close(56)
close(57)
998 endif
call userchk
Time: 0.0000000000000000 Ux: 5.7054317786125811E-002 Uy+Uz: 3.3048747827478064E-003
Start collecting statistics ... 5.3000000000000000E-003
call intp_setup tol= 4.9999999999999999E-013
Nmsh for findpts: 1
WARNING: point not within mesh xy[z]: ! 4.2439916-314 4.2439916-314 -1.0000000E+00
WARNING: point not within mesh xy[z]: ! 4.2439916-314 4.2439916-314 -9.9894341E-01
WARNING: point not within mesh xy[z]: ! 4.2439916-314 4.2439916-314 -9.9788331E-01
WARNING: point not within mesh xy[z]: ! 4.2439916-314 4.2439916-314 -9.9681969E-01
WARNING: point not within mesh xy[z]: ! 4.2439916-314 4.2439916-314 -9.9575256E-01
total number of points = 100
failed = 100
To view this discussion on the web visit https://groups.google.com/d/msgid/nek5000/CACqPjWFtj3u9v%3Dj4VwgQh00OnFzw-pPkJY5MDDZnpXFioz-mXQ%40mail.gmail.com.
c Define the uavg array which is of a predefined size (in this case N*Nez = 8*10 = 80) real uavg(80) real numProc c Set the number of processor #define NUM_PROC <userValue> defined earlier numProc = NUM_PROC c Define the total number of data points (on one processor/mpi rank?) n = nx1*ny1*nz1*nelv c Define the counters which will be used zCounter = 1 counter = 1 c Main loop which loops over the number of processors (mpi ranks) do proc=1,numProc c Reset the startt and endd variables to 1 and 80*80 so that it starts at the right values startt = 1 endd = 80*80 c Loop over the points do i=1,n uavg(zCounter) = sum(vx(startt:endd,1,1,numProc))/endd if(counter == 80*80) then c print *, uavg(zCounter), zCounter !NOTE counter = 1 !Reset the counter to 1 zCounter = zCounter + 1 !Increment the z position counter startt = i !Reset the startt of the array sum endd = startt + 80*80 endif counter = counter + 1 enddo enddo
c Define the call for averaging integer icalld save icalld data icalld /0/ c Define the averaging parameters real atime,timel save atime,timel c Define the data dumping parameters integer ntdump save ntdump c Define the interpolation stuff real rwk(INTP_NMAX,ldim+1) ! r, s, t, dist2 integer iwk(INTP_NMAX,3) ! code, proc, el save rwk, iwk integer nint, intp_h save nint, intp_h logical iffpts save iffpts c Define the working array based on the interpolation point number real xint(INTP_NMAX),yint(INTP_NMAX),zint(INTP_NMAX) save xint, yint, zint save igs_x, igs_y c Define the parameters and the array sizes parameter(nstat=9) real ravg(lx1*ly1*lz1*lelt,nstat) real stat(lx1*ly1*lz1*lelt,nstat) real stat_z(INTP_NMAX*nstat) save ravg, stat, stat_z c Define the working array and logical parameter to save logical ifverbose common /gaaa/ wo1(lx1,ly1,lz1,lelv) c Define the number of points n = nx1*ny1*nz1*nelv c Define the number of elements in each direction nelx = NUM_X nely = NUM_Y nelz = NUM_Z c Define the scaling factor scalingFactor = SCALEFAC c Computing the mean velocities ubar = glsc2(vx,bm1,n)/volvm1 e2 = glsc3(vy,bm1,vy,n)+glsc3(vz,bm1,vz,n) e2 = e2/volvm1 c Print the values at each time step if(nid.eq.0) write(6,*) 'Time:',time,'Ux:',ubar,'Uy+Uz:',e2 if (time.lt.tSTATSTART) return c c What follows computes some statistics ... c if(icalld.eq.0) then if(nid.eq.0) write(6,*) 'Start collecting statistics ...' nxm = 1 ! mesh is linear call interp_setup(intp_h,0.0,nxm,nelt) nint = 0 if (nid.eq.0) then nint = INTP_NMAX call cfill(xint,XCINT,size(xint)) call cfill(yint,YCINT,size(yint)) do i = 1,INTP_NMAX zi = (i-1.)/(INTP_NMAX-1) c zi = 0.1*zi !Rescaling the z values c zint(i) = tanh(BETAM*(2*zi-1))/tanh(BETAM) zint(i) = scalingFactor*zi enddo endif iffpts = .true. ! dummy call to find points call interp_nfld(stat_z,ravg,1,xint,yint,zint,nint, $ iwk,rwk,INTP_NMAX,iffpts,intp_h) iffpts = .false. call gtpp_gs_setup(igs_x,nelx*nelz,nely,1,1) ! x-avx call gtpp_gs_setup(igs_y,nelx,nely,nelz,2) ! y-avg call rzero(ravg,size(ravg)) atime = 0 timel = time ntdump = int(time/tSTATFREQ) icalld = 1 endif c Set the time averaging parameters dtime = time - timel atime = atime + dtime c Averaging over time if (atime.ne.0. .and. dtime.ne.0.) then beta = dtime / atime alpha = 1. - beta ifverbose = .false. call avg1(ravg(1,1),vx ,alpha,beta,n,'uavg',ifverbose) call avg2(ravg(1,2),vx ,alpha,beta,n,'urms',ifverbose) call avg2(ravg(1,3),vy ,alpha,beta,n,'vrms',ifverbose) call avg2(ravg(1,4),vz ,alpha,beta,n,'wrms',ifverbose) call avg3(ravg(1,5),vx,vy,alpha,beta,n,'uvmm',ifverbose) call avg1(ravg(1,6),t ,alpha,beta,n,'tavg',ifverbose) call avg2(ravg(1,7),t ,alpha,beta,n,'trms',ifverbose) call avg3(ravg(1,8),vx,t ,alpha,beta,n,'utmm',ifverbose) call avg3(ravg(1,9),vy,t ,alpha,beta,n,'vtmm',ifverbose) endif c Reset old time as new time timel = time ! write statistics to file if(istep.gt.0 .and. time.gt.(ntdump+1)*tSTATFREQ) then ! averaging over statistical homogeneous directions (x-y) do i = 1,nstat call planar_avg(wo1 ,ravg(1,i),igs_x) call planar_avg(stat(1,i),wo1 ,igs_y) enddo ! extract data along wall normal direction (1D profile) call interp_nfld(stat_z,stat,nstat,xint,yint,zint,nint, $ iwk,rwk,INTP_NMAX,iffpts,intp_h) ntdump = ntdump + 1 if (nid.ne.0) goto 998 write(6,*) 'Dumping statistics ...' open(unit=56,file='vel_fluc_prof.dat') write(56,'(A,1pe14.7)') '#time = ', time write(56,'(A)') $ '# z uu vv ww uv' open(unit=57,file='mean_prof.dat') write(57,'(A,1pe14.7)') '#time = ', time write(57,'(A)') $ '# z Umean' do i = 1,nint c zz = 1+zint(i) zz = zint(i) write(56,3) & zz, & (stat_z(1*nint+i)-(stat_z(0*nint+i))**2), & stat_z(2*nint+i), & stat_z(3*nint+i), & stat_z(4*nint+i) write(57,3) & zz, & stat_z(0*nint+i) 3 format(1p15e17.9) enddo close(56) close(57) 998 endif