<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Correct usage of zfft2d? in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Correct-usage-of-zfft2d/m-p/936037#M14101</link>
    <description>I am currently working on a Navier-Stokes solver which assumes periodic boundary conditions in two dimensions.  In the code, fragment shown below, I use the MKL zfft2d routine for complex to complex ffts.  I am concerned that I may not be using it quite correctly and hope to get some advice on this from the community.  &lt;BR /&gt;&lt;BR /&gt;The basic issue is whether I need to use arrays of declared size 0:255 or 1:256. The NS solver in space uses 1:256 by 1:4096.  I am getting some results which draw this into question. Also, I am not explicitly making the 1:256 by 1:4096 2D array periodic.  I suspect that this can have bad consequences unless the fft routine actually takes care of assumed periodicity internally.  I am also not calling the routine for any initialization prior to using it. From the documentation that I see, the initialization call sometimes needed by fft routines is not needed in this case. Correct?&lt;BR /&gt;&lt;BR /&gt;To show you what I am doing I list below a code fragment and ask experienced users for their input.  Thanks very much.&lt;BR /&gt;&lt;BR /&gt;Comer Duncan&lt;BR /&gt;Department of Physics and Astronomy&lt;BR /&gt;Bowling Green State University&lt;BR /&gt;Bowling Green, OH 43403&lt;BR /&gt;email:  gcomerd@yahoo.com &lt;BR /&gt;&lt;BR /&gt;!!!!!!!!!!!!!!!!! begin code fragment !!!!!!!!!!!!!!!&lt;BR /&gt;       double precision,dimension(1:40000)::vpx,vpy,filxn2,filyn2,filxn1_0, &amp;amp;&lt;BR /&gt;        filyn1_0,filxn2_0,filyn2_0,vpx_0,vpy_0&lt;BR /&gt;        double precision,dimension(1:256,1:4096)::ux,uy,ffx,ffy,sx,sy,ss,aa,vvx,vvy,p,ux0,uy0&lt;BR /&gt;        double complex,dimension(1:256,1:4096)::csx,csy,css&lt;BR /&gt;        double complex,dimension(1:256,1:4096)::vxc,vyc,pc&lt;BR /&gt; &lt;BR /&gt;!! snip snip&lt;BR /&gt;!&lt;BR /&gt; &lt;BR /&gt;         nx = 256&lt;BR /&gt;         ny = 4096&lt;BR /&gt; &lt;BR /&gt;        j=1,ny&lt;BR /&gt;        i=1,nx&lt;BR /&gt;                                                                                      &lt;BR /&gt;        sx(i,j)=dsin(2.d0*pi/dfloat(nx)*dfloat(i-1))&lt;BR /&gt;                                                                                      &lt;BR /&gt;        sy(i,j)=dsin(2.d0*pi/dfloat(ny)*dfloat(j-1))&lt;BR /&gt;                                                                                      &lt;BR /&gt;        ss(i,j)=sx(i,j)*sx(i,j)+sy(i,j)*sy(i,j)&lt;BR /&gt;                                                                                      &lt;BR /&gt;                                                                                      &lt;BR /&gt;                                                                                      &lt;BR /&gt;        aa(i,j)=1.d0+4.0d0*mu*(dt/(ro*h*h))*(dsin(pi*dfloat(i-1)/dfloat(nx))**2+ &amp;amp;&lt;BR /&gt;        dsin(pi*dfloat(j-1)/dfloat(ny))**2)&lt;BR /&gt;                                                                                      &lt;BR /&gt;         csx(i,j) = cmplx(0.0d0,c*sx(i,j))&lt;BR /&gt;                                                                                      &lt;BR /&gt;         csy(i,j) = cmplx(0.0d0,c*sy(i,j))&lt;BR /&gt;                                                                                      &lt;BR /&gt;         css(i,j) = cmplx(0.0d0,c*ss(i,j))&lt;BR /&gt;                                                                                      &lt;BR /&gt;        if(ss(i,j)==0.0d0) then&lt;BR /&gt;                                                                                      &lt;BR /&gt;                sx(i,j) = 0.0d0&lt;BR /&gt;                                                                                      &lt;BR /&gt;                sy(i,j) = 0.0d0&lt;BR /&gt;                                                                                      &lt;BR /&gt;                css(i,j) = 1.0d0&lt;BR /&gt;                               
                                                       &lt;BR /&gt;        endif&lt;BR /&gt;                                                                                      &lt;BR /&gt;        enddo&lt;BR /&gt;        enddo&lt;BR /&gt; &lt;BR /&gt;!! snip snip snip&lt;BR /&gt;                                                                                      &lt;BR /&gt;        vxc=cmplx(vvx,0.d0)&lt;BR /&gt;        vyc=cmplx(vvy,0.d0)&lt;BR /&gt;                                                                                      &lt;BR /&gt;! call the complex to complex fft routines to get fft of vxc and vyc, the inputs to the solve&lt;BR /&gt;!&lt;BR /&gt;                                                                                      &lt;BR /&gt;       call zfft2d(vxc,nx,ny,-1)&lt;BR /&gt;       call zfft2d(vyc,nx,ny,-1)&lt;BR /&gt; &lt;BR /&gt;! now do arithmetic in k-space&lt;BR /&gt;                           &lt;BR /&gt; &lt;BR /&gt;       pc=(sx*vxc+sy*vyc)/(css/2.d0)&lt;BR /&gt;       vxc=(vxc-csx/2.d0*pc)/(aa/2.d0+0.5d0)&lt;BR /&gt;       vyc=(vyc-csy/2.d0*pc)/(aa/2.d0+0.5d0)&lt;BR /&gt;                                                                                      &lt;BR /&gt;! now do inverse fft to return new ux in vxc and new uy in vyc&lt;BR /&gt; &lt;BR /&gt;       call zfft2d(vxc,nx,ny,1)&lt;BR /&gt;       call zfft2d(vyc,nx,ny,1)&lt;BR /&gt;                                                                                      &lt;BR /&gt;                                                                                      &lt;BR /&gt;! now assign real part of returned arrays to physical ux and uy&lt;BR /&gt;        ux=real(vxc)&lt;BR /&gt;        uy=real(vyc)&lt;BR /&gt;        p =real(pc)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;!!!!!!!!!!!!!!  end code fragment !!!!!!!!!!!!!!!!!!!!!</description>
    <pubDate>Fri, 01 Oct 2004 21:14:12 GMT</pubDate>
    <dc:creator>abcduncan</dc:creator>
    <dc:date>2004-10-01T21:14:12Z</dc:date>
    <item>
      <title>Correct usage of zfft2d?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Correct-usage-of-zfft2d/m-p/936037#M14101</link>
      <description>I am currently working on a Navier-Stokes solver which assumes periodic boundary conditions in two dimensions.  In the code, fragment shown below, I use the MKL zfft2d routine for complex to complex ffts.  I am concerned that I may not be using it quite correctly and hope to get some advice on this from the community.  &lt;BR /&gt;&lt;BR /&gt;The basic issue is whether I need to use arrays of declared size 0:255 or 1:256. The NS solver in space uses 1:256 by 1:4096.  I am getting some results which draw this into question. Also, I am not explicitly making the 1:256 by 1:4096 2D array periodic.  I suspect that this can have bad consequences unless the fft routine actually takes care of assumed periodicity internally.  I am also not calling the routine for any initialization prior to using it. From the documentation that I see, the initialization call sometimes needed by fft routines is not needed in this case. Correct?&lt;BR /&gt;&lt;BR /&gt;To show you what I am doing I list below a code fragment and ask experienced users for their input.  Thanks very much.&lt;BR /&gt;&lt;BR /&gt;Comer Duncan&lt;BR /&gt;Department of Physics and Astronomy&lt;BR /&gt;Bowling Green State University&lt;BR /&gt;Bowling Green, OH 43403&lt;BR /&gt;email:  gcomerd@yahoo.com &lt;BR /&gt;&lt;BR /&gt;!!!!!!!!!!!!!!!!! begin code fragment !!!!!!!!!!!!!!!&lt;BR /&gt;       double precision,dimension(1:40000)::vpx,vpy,filxn2,filyn2,filxn1_0, &amp;amp;&lt;BR /&gt;        filyn1_0,filxn2_0,filyn2_0,vpx_0,vpy_0&lt;BR /&gt;        double precision,dimension(1:256,1:4096)::ux,uy,ffx,ffy,sx,sy,ss,aa,vvx,vvy,p,ux0,uy0&lt;BR /&gt;        double complex,dimension(1:256,1:4096)::csx,csy,css&lt;BR /&gt;        double complex,dimension(1:256,1:4096)::vxc,vyc,pc&lt;BR /&gt; &lt;BR /&gt;!! snip snip&lt;BR /&gt;!&lt;BR /&gt; &lt;BR /&gt;         nx = 256&lt;BR /&gt;         ny = 4096&lt;BR /&gt; &lt;BR /&gt;        j=1,ny&lt;BR /&gt;        i=1,nx&lt;BR /&gt;                                                                                      &lt;BR /&gt;        sx(i,j)=dsin(2.d0*pi/dfloat(nx)*dfloat(i-1))&lt;BR /&gt;                                                                                      &lt;BR /&gt;        sy(i,j)=dsin(2.d0*pi/dfloat(ny)*dfloat(j-1))&lt;BR /&gt;                                                                                      &lt;BR /&gt;        ss(i,j)=sx(i,j)*sx(i,j)+sy(i,j)*sy(i,j)&lt;BR /&gt;                                                                                      &lt;BR /&gt;                                                                                      &lt;BR /&gt;                                                                                      &lt;BR /&gt;        aa(i,j)=1.d0+4.0d0*mu*(dt/(ro*h*h))*(dsin(pi*dfloat(i-1)/dfloat(nx))**2+ &amp;amp;&lt;BR /&gt;        dsin(pi*dfloat(j-1)/dfloat(ny))**2)&lt;BR /&gt;                                                                                      &lt;BR /&gt;         csx(i,j) = cmplx(0.0d0,c*sx(i,j))&lt;BR /&gt;                                                                                      &lt;BR /&gt;         csy(i,j) = cmplx(0.0d0,c*sy(i,j))&lt;BR /&gt;                                                                                      &lt;BR /&gt;         css(i,j) = cmplx(0.0d0,c*ss(i,j))&lt;BR /&gt;                                                                                      &lt;BR /&gt;        if(ss(i,j)==0.0d0) then&lt;BR /&gt;                                                                                      &lt;BR /&gt;                sx(i,j) = 0.0d0&lt;BR /&gt;                                                                                      &lt;BR /&gt;                sy(i,j) = 0.0d0&lt;BR /&gt;                                                                                      &lt;BR /&gt;                css(i,j) = 1.0d0&lt;BR /&gt;                               
                                                       &lt;BR /&gt;        endif&lt;BR /&gt;                                                                                      &lt;BR /&gt;        enddo&lt;BR /&gt;        enddo&lt;BR /&gt; &lt;BR /&gt;!! snip snip snip&lt;BR /&gt;                                                                                      &lt;BR /&gt;        vxc=cmplx(vvx,0.d0)&lt;BR /&gt;        vyc=cmplx(vvy,0.d0)&lt;BR /&gt;                                                                                      &lt;BR /&gt;! call the complex to complex fft routines to get fft of vxc and vyc, the inputs to the solve&lt;BR /&gt;!&lt;BR /&gt;                                                                                      &lt;BR /&gt;       call zfft2d(vxc,nx,ny,-1)&lt;BR /&gt;       call zfft2d(vyc,nx,ny,-1)&lt;BR /&gt; &lt;BR /&gt;! now do arithmetic in k-space&lt;BR /&gt;                           &lt;BR /&gt; &lt;BR /&gt;       pc=(sx*vxc+sy*vyc)/(css/2.d0)&lt;BR /&gt;       vxc=(vxc-csx/2.d0*pc)/(aa/2.d0+0.5d0)&lt;BR /&gt;       vyc=(vyc-csy/2.d0*pc)/(aa/2.d0+0.5d0)&lt;BR /&gt;                                                                                      &lt;BR /&gt;! now do inverse fft to return new ux in vxc and new uy in vyc&lt;BR /&gt; &lt;BR /&gt;       call zfft2d(vxc,nx,ny,1)&lt;BR /&gt;       call zfft2d(vyc,nx,ny,1)&lt;BR /&gt;                                                                                      &lt;BR /&gt;                                                                                      &lt;BR /&gt;! now assign real part of returned arrays to physical ux and uy&lt;BR /&gt;        ux=real(vxc)&lt;BR /&gt;        uy=real(vyc)&lt;BR /&gt;        p =real(pc)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;!!!!!!!!!!!!!!  end code fragment !!!!!!!!!!!!!!!!!!!!!</description>
      <pubDate>Fri, 01 Oct 2004 21:14:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Correct-usage-of-zfft2d/m-p/936037#M14101</guid>
      <dc:creator>abcduncan</dc:creator>
      <dc:date>2004-10-01T21:14:12Z</dc:date>
    </item>
  </channel>
</rss>

