<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>k-Wave User Forum &#187; Topic: FFT_X_temp and Temp_1_RS3D</title>
		<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:29:44 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.k-wave.org/forum/rss/topic/fft_x_temp-and-temp_1_rs3d" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "FFT_X_temp and Temp_1_RS3D"</title>
			<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d#post-3735</link>
			<pubDate>Thu, 20 Jun 2013 22:23:13 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">3735@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Anthony,&#60;/p&#62;
&#60;p&#62;The short answer is yes, but probably not for some time. We have done some preliminary work on this in 1D and it works well. However, the extension to 2D and 3D is still an active area of research.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anthony on "FFT_X_temp and Temp_1_RS3D"</title>
			<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d#post-3729</link>
			<pubDate>Tue, 18 Jun 2013 16:39:31 +0000</pubDate>
			<dc:creator>Anthony</dc:creator>
			<guid isPermaLink="false">3729@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Brad,&#60;/p&#62;
&#60;p&#62;I just came across this topic and I am curious about the possibility to use non uniform grids: do you have any idea of when you plan to release such a feature (if it is still part of the plan)? It must be a tough job to do that!&#60;/p&#62;
&#60;p&#62;It would we awesome: I am simulating focused fields and I would love to be able to refine the grid near the focal point.&#60;/p&#62;
&#60;p&#62;Thanks a lot for what you and your team are doing with k-wave!&#60;br /&#62;
Anthony&#60;/p&#62;
&#60;p&#62;PS : sorry if it not the right place to ask, but I didn't want to create a new topic only to satisfy my curiosity :-)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "FFT_X_temp and Temp_1_RS3D"</title>
			<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d#post-1058</link>
			<pubDate>Fri, 23 Nov 2012 01:18:54 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">1058@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Chao,&#60;/p&#62;
&#60;p&#62;Nonuniform in the sense that the grid points are not uniformly distributed, so dx/dy/dz are not constant across the domain. You can already define Nx/Ny/Nz and dx/dy/dx to not be equal if you wish, but the grid spacing is forced to be scalar.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>huangchao on "FFT_X_temp and Temp_1_RS3D"</title>
			<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d#post-1057</link>
			<pubDate>Fri, 23 Nov 2012 00:17:10 +0000</pubDate>
			<dc:creator>huangchao</dc:creator>
			<guid isPermaLink="false">1057@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Brad&#60;/p&#62;
&#60;p&#62;Could you elaborate more on the nonuniform grid. Does nonuniform mean that the dx, dy and dz are not equal or Nx, Ny and Nz are not equal? Or it means dx (and/or dy, dz) is not a constant?&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Chao
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "FFT_X_temp and Temp_1_RS3D"</title>
			<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d#post-1054</link>
			<pubDate>Thu, 22 Nov 2012 23:34:46 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">1054@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Chao,&#60;/p&#62;
&#60;p&#62;The flag (and some additional functions) will be used in future releases to allow nonuniform grids to be defined. It's included in the current release so that HDF5 input files created with k-Wave version 1.0 are forward compatible. &#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>huangchao on "FFT_X_temp and Temp_1_RS3D"</title>
			<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d#post-1052</link>
			<pubDate>Thu, 22 Nov 2012 21:59:11 +0000</pubDate>
			<dc:creator>huangchao</dc:creator>
			<guid isPermaLink="false">1052@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Jiri,&#60;/p&#62;
&#60;p&#62;Another quick question:&#60;/p&#62;
&#60;p&#62;I find in Appendix B of the manual that the 'nonuniform_grid_flag' must be set to 0. If so, what is the 'nonuniform_grid_flag' used for?&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Chao
&#60;/p&#62;</description>
		</item>
		<item>
			<title>huangchao on "FFT_X_temp and Temp_1_RS3D"</title>
			<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d#post-1051</link>
			<pubDate>Thu, 22 Nov 2012 18:20:31 +0000</pubDate>
			<dc:creator>huangchao</dc:creator>
			<guid isPermaLink="false">1051@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Jiri,&#60;/p&#62;
&#60;p&#62;Thanks for your details explanation, I was confused by this statement:&#60;/p&#62;
&#60;p&#62;Get_FFT_X_temp().Compute_iFFT_3D_C2R(Get_Temp_1_RS3D());&#60;/p&#62;
&#60;p&#62;The reason is that I thought Get_Temp_1_RS3D() is the input argument, so I didn't understand where Get_Temp_1_RS3D get updated and wonder why iFFT still operates on Get_Temp_1_RS3D.&#60;/p&#62;
&#60;p&#62;I just realize Get_Temp_1_RS3D() is the output matrix defined in the FFTWComplexMatrix.h file, and it's very clear to me now.&#60;/p&#62;
&#60;p&#62;I am writing it here in case someone has similar problems as me.&#60;/p&#62;
&#60;p&#62;Thanks again!&#60;/p&#62;
&#60;p&#62;Chao
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Jiri Jaros on "FFT_X_temp and Temp_1_RS3D"</title>
			<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d#post-1049</link>
			<pubDate>Thu, 22 Nov 2012 05:50:49 +0000</pubDate>
			<dc:creator>Jiri Jaros</dc:creator>
			<guid isPermaLink="false">1049@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Chao,&#60;/p&#62;
&#60;p&#62;Matrices &#60;code&#62;FFTW_X_temp, FFTW_Y_temp, and FFTW_Z_temp&#60;/code&#62; serve as temporary storage for data in the complex domain at various places of the code. &#60;/p&#62;
&#60;p&#62;Any time I want to take FFT of something, I need to store the result somewhere. I usually need to take FFTs of three different spatial components, e.g. ux, uy, uz calculate duxdx, dyuduy, duzdz, so that’s why I need three temporary matrices. In the special case of pressure, I don’t need to take FFT of pressure 3 times, as the result will always be the same. That’s why I do so only once and store the result in &#60;code&#62;FFT_X_temp&#60;/code&#62;. That’s the first line of &#60;code&#62;Compute_ddx_kappa_fft_p()&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;However, when I multiply the FFT(p) with ddx/ddy/ddz and kappa I get 3 different results. Thus I need two more temporary matrices and store the output in FFT_X_temp, FFT_Y_temp and FFT_Z_temp in order to take the inverse FFT to calculate ux, uy, uz.&#60;/p&#62;
&#60;p&#62;Let’s dismantle the Matlab code for this part (the C++ code follows the MATLAB):&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;% calculate ux, uy and uz at the next time step using dp/dx, dp/dy and
% dp/dz at the current time step
ux_sgx = bsxfun(@times, pml_x_sgx,  ...
        bsxfun(@times, pml_x_sgx, ux_sgx) ...
        - dt./rho0_sgx .* real(ifftn( ...
        bsxfun(@times, ddx_k_shift_pos, kappa .* p_k) )));

uy_sgy = bsxfun(@times, pml_y_sgy, ...
        bsxfun(@times, pml_y_sgy, uy_sgy) ...
        - dt./rho0_sgy .* real(ifftn( ...
        bsxfun(@times, ddy_k_shift_pos, kappa .* p_k) )));

uz_sgz = bsxfun(@times, pml_z_sgz, ...
        bsxfun(@times, pml_z_sgz, uz_sgz) ...
        - dt./rho0_sgz .* real(ifftn( ...
        bsxfun(@times, ddz_k_shift_pos, kappa .* p_k) )));&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;In order to save computational resources I calculate all of these statements simultaneously (kappa and p_k are the same think in all 3 statements).&#60;/p&#62;
&#60;p&#62;1) We take fft(p) and store the result in &#60;code&#62;p_k&#60;/code&#62;. (in the C code this is&#60;code&#62;FFT_X_temp&#60;/code&#62;)&#60;br /&#62;
2) We calculate&#60;/p&#62;
&#60;p&#62;   a. &#60;code&#62;bsxfun(@times, ddx_k_shift_pos, kappa .* p_k)&#60;/code&#62;&#60;br /&#62;
   b. &#60;code&#62;bsxfun(@times, ddy_k_shift_pos, kappa .* p_k)&#60;/code&#62;&#60;br /&#62;
   c. &#60;code&#62;bsxfun(@times, ddz_k_shift_pos, kappa .* p_k)&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;We’ll do this at once meaning taking an element from p_k, multiplying it with kappa (which is same in all statements) and store this in a single float variable say &#60;code&#62;p_k_element&#60;/code&#62;. Then we carry out bsxfun on this element and ddx/ddy/ddz and store three results into target elements in &#60;code&#62;FFT_X_temp, FFT_Y_temp, FFT_Z_temp&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;3) Now, we will take inverse FFTs and we need some place where to store it. We can’t override &#60;code&#62;ux_sgx&#60;/code&#62; or &#60;code&#62;uy_sgy&#60;/code&#62; or &#60;code&#62;uz_sgz&#60;/code&#62; because we will need them. So we have to do&#60;/p&#62;
&#60;p&#62;  a. &#60;code&#62;Temp_1_RS3D = real(ifft(FFT_X_temp));&#60;/code&#62;&#60;br /&#62;
  b. &#60;code&#62;Temp_2_RS3D = real(ifft(FFT_Y_temp));&#60;/code&#62;&#60;br /&#62;
  c. &#60;code&#62;Temp_3_RS3D = real(ifft(FFT_Z_temp));&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;4) Now we finish the rest of the statements:&#60;/p&#62;
&#60;p&#62;  a. &#60;code&#62;ux_sgx = bsxfun(@times, pml_x_sgx, bsxfun(@times, pml_x_sgx, ux_sgx) .-   dt./rho0_sgx .* Temp_1_RS3D );&#60;/code&#62;&#60;br /&#62;
  b. &#60;code&#62;uy_sgy = bsxfun(@times, pml_y_sgy, bsxfun(@times, pml_y_sgy, uy_sgy) .- dt./rho0_sgy .* Temp_2_RS3D );&#60;/code&#62;&#60;br /&#62;
  c. &#60;code&#62;uz_sgz = bsxfun(@times, pml_z_sgz, bsxfun(@times, pml_z_sgz, uz_sgz) .- dt./rho0_sgz .* Temp_3_RS3D  );&#60;/code&#62; &#60;/p&#62;
&#60;p&#62;Please note that, the &#60;code&#62;Temp_1_RS3D, Temp_2_RS3D and Temp_3_RS3D&#60;/code&#62; matrices are used at different places in the code in different meanings. Simply said, always I need a memory buffer I use one of these matrices since dynamic allocation could be very very very expensive!&#60;/p&#62;
&#60;p&#62;The code makes a lot of compromises to the readability in order to squeeze every possible FLOP and B/s from the HW :-)&#60;/p&#62;
&#60;p&#62;Jiri
&#60;/p&#62;</description>
		</item>
		<item>
			<title>huangchao on "FFT_X_temp and Temp_1_RS3D"</title>
			<link>http://www.k-wave.org/forum/topic/fft_x_temp-and-temp_1_rs3d#post-1048</link>
			<pubDate>Thu, 22 Nov 2012 04:53:04 +0000</pubDate>
			<dc:creator>huangchao</dc:creator>
			<guid isPermaLink="false">1048@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Jiri,&#60;/p&#62;
&#60;p&#62;I am studying the code and get confused by the temporary variables 'FFT_X_temp' and 'Temp_1_RS3D' (also for the temporary variables in the y and z directions).&#60;/p&#62;
&#60;p&#62;In the function 'Compute_ddx_kappa_fft_p', it seems that 'FFT_X_temp' is updated and used to stored the value of 'bsxfun(\@times, ddx_k_shift_pos, kappa .* p_k)', while in the function 'Compute_uxyz', the value of 'bsxfun(\@times, ddx_k_shift_pos, kappa .* p_k)' looks like being stored in 'Temp_1_RS3D', and I don't know where the 'Temp_1_RS3D' gets updated.&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Chao
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
