PeriDyno 1.2.1
Loading...
Searching...
No Matches
OceanPatch.h
Go to the documentation of this file.
1
16#pragma once
17#include <cufft.h>
18#include <vector>
19#include "Node.h"
20
21#include "Complex.h"
23
24namespace dyno {
25
26 struct WindParam
27 {
28 float windSpeed;
29 float A;
31 float global;
32 };
33
34 template<typename TDataType>
35 class OceanPatch : public Node
36 {
37 DECLARE_TCLASS(OceanPatch, TDataType)
38 public:
39 typedef typename TDataType::Real Real;
40 typedef typename TDataType::Coord Coord;
41 typedef typename ::dyno::Complex<Real> Complex;
42
45
46 std::string getNodeType() override { return "Height Fields"; }
47 public:
48 DEF_VAR(uint, WindType, 2, "wind Types");
49
50 DEF_VAR(Real, Amplitude, 0, "");
51
52 DEF_VAR(Real, AmplitudeScale, 1, "");
53
54 DEF_VAR(Real, WindSpeed, 0, "");
55
56 DEF_VAR(Real, Choppiness, 0, "");
57
58 DEF_VAR(Real, GlobalShift, 0, "");
59
60
61 DEF_VAR(Real, WindDirection, Real(60), "Wind direction");
62
63 DEF_VAR(uint, Resolution, 512, "");
64
65 DEF_VAR(Real, PatchSize, Real(512), "Real patch size");
66
67 DEF_VAR(Real, TimeScale, Real(1), "");
68
69 public:
71
72 protected:
73 void resetStates() override;
74
75 void updateStates() override;
76 void postUpdateStates() override;
77
78 private:
80
81 std::vector<WindParam> mParams; //A set of pre-defined configurations
82
83 DArray2D<Complex> mH0; //Initial spectrum
84 DArray2D<Complex> mHt; //Current spectrum
85
86 DArray2D<Complex> mDxt; //x-axis offset
87 DArray2D<Complex> mDzt; //z-axis offset
88
89 DArray2D<Coord> mDisp; //xyz-axis offset
90
91 const Real g = 9.81f; //Gravity
92
94
95 cufftHandle fftPlan;
96
97 int mSpectrumWidth; //with of spectrum
98 int mSpectrumHeight; //height of spectrum
99 };
100
101 IMPLEMENT_TCLASS(OceanPatch, TDataType)
102}
#define DECLARE_TCLASS(name, T1)
Definition Object.h:87
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
DEF_VAR(Real, Amplitude, 0, "")
DArray2D< Complex > mHt
Definition OceanPatch.h:84
std::vector< WindParam > mParams
Definition OceanPatch.h:81
DEF_VAR(Real, Choppiness, 0, "")
DArray2D< Complex > mDxt
Definition OceanPatch.h:86
DEF_VAR(uint, Resolution, 512, "")
DArray2D< Complex > mDzt
Definition OceanPatch.h:87
DEF_VAR(Real, AmplitudeScale, 1, "")
DArray2D< Complex > mH0
Definition OceanPatch.h:83
void updateStates() override
DEF_VAR(Real, WindSpeed, 0, "")
::dyno::Complex< Real > Complex
Definition OceanPatch.h:41
DArray2D< Coord > mDisp
Definition OceanPatch.h:89
DEF_INSTANCE_STATE(HeightField< TDataType >, HeightField, "Height field")
DEF_VAR(Real, PatchSize, Real(512), "Real patch size")
DEF_VAR(uint, WindType, 2, "wind Types")
DEF_VAR(Real, GlobalShift, 0, "")
const Real g
Definition OceanPatch.h:91
DEF_VAR(Real, TimeScale, Real(1), "")
TDataType::Coord Coord
Definition OceanPatch.h:40
DEF_VAR(Real, WindDirection, Real(60), "Wind direction")
std::string getNodeType() override
Definition OceanPatch.h:46
TDataType::Real Real
Definition OceanPatch.h:39
void resetStates() override
void postUpdateStates() override
cufftHandle fftPlan
Definition OceanPatch.h:95
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
Array2D< T, DeviceType::GPU > DArray2D
Definition Array2D.inl:90
unsigned int uint
Definition VkProgram.h:14