<div dir="ltr"><div><div><div><div><div><div>Hi Neks,<br>I am interested in the scalar average inside a specified volume (similar to the glsc2 routine, but only in a small volume). The volume is given by means of the x/y/z-coordinate. V=(x_2-x_1)*(y_2-y_1)*(z_2-z_1), where “1” indicates the lower and “2” the upper coordinate.<br><br>My first idea was (e.g. for the velocity in streamwise direction): <br>=========================================================<br>real x1, x2, y1, y2, z1, z2<br>real lval, lvol, gval, gvol<br>real vxavg<br>integer i,j,k,e<br><br>[...]<br><br></div><div>! Specify the volume<br></div>x1=1.0<br></div>x2=2.0<br></div>y1=0.0<br></div>y2=0.5<br></div>z1=0.0<br></div>z2=1.0<br><div><div><div><div><div><div><br></div><div>! Init<br></div><div>lvol=0.0<br>lval=0.0<br>gval=0.0<br>gvol=0.0<br><br></div><div>! Loop<br></div><div>do e=1,nelt<br>do k=1,nz1<br>do j=1,ny1<br>do i=1,nx1<br>    if (xm1(i,j,k,e)>=x1 .and. xm1(i,j,k,e)<=x2 <br>     & .and. <br>     & ym1(i,j,k,e)>=y1 .and. ym1(i,j,k,e)<=y2<br>     & .and. <br>     & zm1(i,j,k,e)>=z1 .and. zm1(i,j,k,e)<=z2<br>     & ) then<br> <br>        lvol=lvol+bm1(i,j,k,e) ! Volume<br>        lval=lval+vx(i,j,k,e)*bm1(i,j,k,e) ! Weighted scalar value<br><br>    end if<br>end do<br>end do<br>end do <br>end do<br><br></div><div>! MPI<br></div><div>call gop(gval,lval,'+  ',1)<br>call gop(gvol,lvol,'+  ',1)<br><br></div><div>! Volume averaged streamwise velocity<br></div><div>vxavg=gval/gvol<br>=========================================================<br><br>This unfortunately doesn't work. Do you see where the problem is?<br><br>Thanks in advance!<br>Jan F.<br></div></div></div></div></div></div></div>