From eca50702746fc0e8c933bac32cd4e5623d88ca53 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Wed, 18 May 2022 10:53:00 +0200 Subject: compute convolution term in its own function --- src/navier-stokes.c | 51 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'src/navier-stokes.c') diff --git a/src/navier-stokes.c b/src/navier-stokes.c index 3fbce07..13d9531 100644 --- a/src/navier-stokes.c +++ b/src/navier-stokes.c @@ -329,6 +329,37 @@ int ins_rhs( int kx,ky; int i; + // compute convolution term + ns_T(u,K1,K2,N1,N2,fft1,fft2,ifft); + + for(i=0; i<(2*K1+1)*(2*K2+1); i++){ + out[i]=0; + } + for(kx=-K1;kx<=K1;kx++){ + for(ky=-K2;ky<=K2;ky++){ + if(kx!=0 || ky!=0){ + out[klookup(kx,ky,2*K1+1,2*K2+1)]=-4*M_PI*M_PI*nu*(kx*kx+ky*ky)*u[klookup(kx,ky,2*K1+1,2*K2+1)]+(*g)(kx,ky)+4*M_PI*M_PI/sqrt(kx*kx+ky*ky)*ifft.fft[klookup(kx,ky,N1,N2)]; + } + } + } + + return(0); +} + +// convolution term in right side of convolution equation +int ns_T( + _Complex double* u, + int K1, + int K2, + int N1, + int N2, + fft_vect fft1, + fft_vect fft2, + fft_vect ifft +){ + int kx,ky; + int i; + // F(px/|p|*u)*F(qy*|q|*u) // init to 0 for(i=0; i