X-Git-Url: http://git.treefish.org/~alex/seamulator.git/blobdiff_plain/ce5cb9e3b065ec3eabd2ffa79923043fdfb2087a..40fe15ee6190427f3bbc5db4ff640442626cc3bb:/include/sea.h?ds=sidebyside diff --git a/include/sea.h b/include/sea.h new file mode 100644 index 0000000..798b92d --- /dev/null +++ b/include/sea.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include +#include + +#include + +#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> m_fourierAmplitudes; + fftw_complex *m_fftwIn, *m_fftwOut; + fftw_plan m_fftwPlan; + std::chrono::time_point m_startTime; + + double phillipsSpectrum(double k_x, double k_y) const; + std::complex& fourierAmplitudeAt(int n, int m); + void generateFourierAmplitudes(); + double spatialFrequencyForIndex(int n) const; + double getRuntime() const; +};