Ian Jauslin
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/navier-stokes.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/navier-stokes.c b/src/navier-stokes.c
index 89bfbbd..e553022 100644
--- a/src/navier-stokes.c
+++ b/src/navier-stokes.c
@@ -495,7 +495,8 @@ int ns_T(
fftw_execute(fft2.fft_plan);
// write to ifft
for(i=0;i<N1*N2;i++){
- ifft.fft[i]=fft1.fft[i]*fft2.fft[i];
+ // control numerical truncation by taking imaginary part (fft1 and fft2 should be purely imaginary)
+ ifft.fft[i]=-(__imag__ fft1.fft[i])*(__imag__ fft2.fft[i]);
}
// F(py/|p|*u)*F(qx*|q|*u)
@@ -519,7 +520,8 @@ int ns_T(
fftw_execute(fft2.fft_plan);
// write to ifft
for(i=0;i<N1*N2;i++){
- ifft.fft[i]=ifft.fft[i]-fft1.fft[i]*fft2.fft[i];
+ // control numerical truncation by taking imaginary part (fft1 and fft2 should be purely imaginary)
+ ifft.fft[i]=ifft.fft[i]+(__imag__ fft1.fft[i])*(__imag__ fft2.fft[i]);
}
// inverse fft