Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <jauslin@ias.edu>2018-01-11 22:48:14 +0000
committerIan Jauslin <jauslin@ias.edu>2018-01-11 22:48:14 +0000
commit01f47ace6756c28deb9ea0daaee3904ffa5ce9e0 (patch)
tree5f17fab452c96c3df7ae5da8875d1178d461e79e /src/navier-stokes.h
Initial commit
Diffstat (limited to 'src/navier-stokes.h')
-rw-r--r--src/navier-stokes.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/navier-stokes.h b/src/navier-stokes.h
new file mode 100644
index 0000000..cd093d7
--- /dev/null
+++ b/src/navier-stokes.h
@@ -0,0 +1,48 @@
+#ifndef NAVIERSTOKES_H
+#define NAVIERSTOKES_H
+
+#include <complex.h>
+#include <fftw3.h>
+
+// to extract elements from array of size S representing a function of momentum, use
+// array[KEXTRACT(kx,ky,size)]
+#define KLOOKUP(X,Y,S) (X>=0?X:S+X)*S+(Y>=0?Y:S+Y)
+
+
+// parameters for the NS equation
+typedef struct ns_params {
+ // number of modes
+ int K;
+ // 2*K+1
+ int S;
+ // 4*K+1
+ int N;
+ // forcing term
+ _Complex double* g;
+ // time step
+ double h;
+ // friction
+ double nu;
+} ns_params;
+
+// arrays on which the ffts are performed
+typedef struct fft_vects {
+ fftw_complex* fft1;
+ fftw_complex* fft2;
+ fftw_complex* invfft;
+ fftw_plan fft1_plan;
+ fftw_plan fft2_plan;
+ fftw_plan invfft_plan;
+} fft_vects;
+
+// next time step for Irreversible Navier-Stokes equation
+int ins_step(_Complex double* u, ns_params params, fft_vects vects, _Complex double* tmp1, _Complex double* tmp2, _Complex double* tmp3);
+
+// right side of Irreversible Navier-Stokes equation
+int ins_rhs(_Complex double* out, _Complex double* u, ns_params params, fft_vects vects);
+
+// compute alpha
+_Complex double compute_alpha(_Complex double* u, ns_params params);
+
+#endif
+