]> git.treefish.org Git - seamulator.git/commitdiff
Pass wind speed and magic constant via sea constructor
authorAlexander Schmidt <alex@treefish.org>
Wed, 20 Jul 2016 20:55:20 +0000 (22:55 +0200)
committerAlexander Schmidt <alex@treefish.org>
Wed, 20 Jul 2016 20:55:20 +0000 (22:55 +0200)
include/sea.h
src/sea.cpp
src/seamulator.cpp

index 798b92d138eb68f7a9719f6461ad369af8616cf7..01f8c92307c34b5460fac96564b46ba0f0ccc55c 100644 (file)
 class Sea
 {
  public:
-  Sea(WaterSurfacePtr surface);
+  Sea(WaterSurfacePtr surface, double windSpeed, double magicConstant);
   ~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;
+  double m_magicConstant;
   std::random_device m_randomDevice;
   std::mt19937 m_randomGenerator;
   std::normal_distribution<> m_normalDistribution;
index 85191d4fd7680fc5708dc25bd7da23ca53ee2767..597e0a1be73d460a38b4542107be9ea85e568f2b 100644 (file)
@@ -6,13 +6,13 @@
 
 #include "watersurface.h"
 
-const double Sea::PHILLIPS_CONSTANT{0.0000001};
 const double Sea::GRAVITATIONAL_CONSTANT{9.8};
 
-Sea::Sea(WaterSurfacePtr surface) :
+Sea::Sea(WaterSurfacePtr surface, double windSpeed, double magicConstant) :
   m_surface{surface},
   m_windDirection{1, 0},
-  m_windSpeed{10},
+  m_windSpeed{windSpeed},
+  m_magicConstant{magicConstant},
   m_randomGenerator{m_randomDevice()},
   m_normalDistribution{0.0, 1.0}
 {
@@ -89,7 +89,7 @@ double Sea::phillipsSpectrum(double k_x, double k_y) const
   const double cosineFactor = pow((k_x / k) * m_windDirection[0] +
                                  (k_y / k) * m_windDirection[1], 2);
 
-  return PHILLIPS_CONSTANT * exp(-1 / pow(k * L, 2)) / pow(k, 4) *
+  return m_magicConstant * exp(-1 / pow(k * L, 2)) / pow(k, 4) *
     cosineFactor;
 }
 
index c5f7936c652c9aed72afb23747476b15b6a9b457..92dfac608d383a97c9b345729d44e3990c3a4bc8 100644 (file)
@@ -33,7 +33,7 @@ int main(int argc, char** argv)
   std::srand(std::time(0));
 
   surface = std::make_shared<WaterSurface>(LATTICE_SIZE, LATTICE_EXTEND);
-  sea = std::make_shared<Sea>(surface);
+  sea = std::make_shared<Sea>(surface, 10, 0.0000001);
   seaView = std::make_unique<SeaView>(INIT_VIEW_DISTANCE, INIT_VIEW_AZIMUTH,
                                      INIT_VIEW_ALTITUDE);