cuIBM
A GPU-based Immersed Boundary Method code
body.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 
23 class body
24 {
25 public:
26  int numPoints;
27 
28  vecH X,
29  Y;
30 
31  real X0[2];
32 
33  real Xc0[2],
34  Theta0;
35 
36  real Xc[2],
37  Theta,
38  vel[2],
39  angVel;
40 
41  bool moving[2];
42 
44  omega;
45 
47  yOscillation[3],
48  pitchOscillation[3];
49  // Note that the angular amplitude & phase difference are stored in radians, and angular frequncy is radians/time
50  // But the inputs in bodies.yaml are provided in degrees, and degrees/time.
51 
52 
59  void update(real Time)
60  {
61  // if the body is translating
62  if(moving[0])
63  {
64  Xc[0] = Xc0[0] + velocity[0]*Time + xOscillation[0]*sin(xOscillation[1]*Time + xOscillation[2]);
65  Xc[1] = Xc0[1] + velocity[1]*Time + yOscillation[0]*sin(yOscillation[1]*Time + yOscillation[2]);
66  vel[0] = velocity[0] + xOscillation[0]*xOscillation[1]*cos(xOscillation[1]*Time + xOscillation[2]);
67  vel[1] = velocity[1] + yOscillation[0]*yOscillation[1]*cos(yOscillation[1]*Time + yOscillation[2]);
68  }
69  // if the body is rotating
70  if(moving[1])
71  {
72  Theta = Theta0 + omega*Time + pitchOscillation[0]*sin(pitchOscillation[1]*Time + pitchOscillation[2]);
73  angVel = omega + pitchOscillation[0]*pitchOscillation[1]*cos(pitchOscillation[1]*Time + pitchOscillation[2]);
74  }
75  } // update
76 
77 
84  void reset()
85  {
86  X0[0] = X0[1] = 0.0;
87  Xc0[0] = Xc0[1] = 0.0;
88  Theta0 = 0.0;
89  Xc[0] = Xc[1] = 0.0;
90  Theta = 0.0;
91  vel[0] = vel[1] = 0.0;
92  angVel = 0.0;
93  moving[0] = false;
94  moving[1] = false;
95  velocity[0] = 0.0;
96  velocity[1] = 0.0;
97  omega = 0.0;
98  xOscillation[0] = xOscillation[1] = xOscillation[2] = 0.0;
99  yOscillation[0] = yOscillation[1] = yOscillation[2] = 0.0;
100  pitchOscillation[0] = pitchOscillation[1] = pitchOscillation[2] = 0.0;
101  } // reset
102 }; // body
real xOscillation[3]
amplitude, angular frequency and phase difference of oscillation in the x-direction ...
Definition: body.h:46
double real
Is a float or a double depending on the machine precision.
Definition: types.h:116
real pitchOscillation[3]
amplitude, angular frequency and phase difference of pitch oscillation
Definition: body.h:46
vecH Y
reference y-coordinate of boundary points
Definition: body.h:28
Contains information about an immersed boundary in the flow.
Definition: body.h:23
cusp::array1d< real, host_memory > vecH
Cusp 1D array stored in the host.
Definition: types.h:154
vecH X
reference x-coordinate of boundary points
Definition: body.h:28
real X0[2]
reference center of rotation
Definition: body.h:31
real angVel
angular velocity (counterlockwise is positive)
Definition: body.h:36
real Theta0
initial angle of attack
Definition: body.h:33
real Xc[2]
actual center of rotation (x- and y-coordinates)
Definition: body.h:36
real Theta
actual angle of attack (counterclockwise is positive)
Definition: body.h:36
real omega
uniform rotational velocity
Definition: body.h:43
void update(real Time)
Updates the position of the center of rotation of the body, as well as its the translational and rota...
Definition: body.h:59
real velocity[2]
uniform translational velocity (x- and y-components)
Definition: body.h:43
real vel[2]
translational velocity (x- and y- components)
Definition: body.h:36
bool moving[2]
flag to indicate if the body is moving (translating or rotating)
Definition: body.h:41
int numPoints
number of boundary points
Definition: body.h:26
real Xc0[2]
initial position of center of rotation
Definition: body.h:33
void reset()
Resets the position and motion of the body.
Definition: body.h:84
real yOscillation[3]
amplitude, angular frequency and phase difference of oscillation in the y-direction ...
Definition: body.h:46