]> git.treefish.org Git - seamulator.git/blobdiff - include/sea.h
Changed directory structure
[seamulator.git] / include / sea.h
diff --git a/include/sea.h b/include/sea.h
new file mode 100644 (file)
index 0000000..798b92d
--- /dev/null
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <chrono>
+#include <complex>
+#include <random>
+
+#include <fftw3.h>
+
+#include "seafwd.h"
+
+#include "watersurfacefwd.h"
+
+class Sea
+{
+ public:
+  Sea(WaterSurfacePtr surface);
+  ~Sea();
+  Sea(const Sea&) = delete;
+  Sea& operator=(const Sea&) = delete;
+  void update();
+
+ private:
+  static const double PHILLIPS_CONSTANT;
+  static const double GRAVITATIONAL_CONSTANT;
+
+  WaterSurfacePtr m_surface;
+  double m_windDirection[2];
+  double m_windSpeed;
+  std::random_device m_randomDevice;
+  std::mt19937 m_randomGenerator;
+  std::normal_distribution<> m_normalDistribution;
+  std::vector<std::complex<double>> m_fourierAmplitudes;
+  fftw_complex *m_fftwIn, *m_fftwOut;
+  fftw_plan m_fftwPlan;
+  std::chrono::time_point<std::chrono::system_clock> m_startTime;
+
+  double phillipsSpectrum(double k_x, double k_y) const;
+  std::complex<double>& fourierAmplitudeAt(int n, int m);
+  void generateFourierAmplitudes();
+  double spatialFrequencyForIndex(int n) const;
+  double getRuntime() const;
+};