cuIBM
A GPU-based Immersed Boundary Method code
calculateForce.inl
Go to the documentation of this file.
1 
9 
10 
18 template <typename memoryType>
20 {
21  typedef typename cusp::array1d<real, memoryType>::iterator ValueIterator;
22  typedef typename cusp::array1d_view<ValueIterator> View;
23 
26  numBodies = NSWithBody<memoryType>::B.numBodies,
27  totalPoints = NSWithBody<memoryType>::B.totalPoints,
28  ETRows = (nx-1)*ny + nx*(ny-1);
29  real dx, dy;
30  View f, fView;
31 
32  cusp::array1d<real, memoryType> F(ETRows), fTemp(2*totalPoints);
33 
35  dy = dx;
36 
38 
39  // loop through bodies
40  for(int l=0; l < numBodies; l++)
41  {
43  dy = dx;
44 
45  // x-component of the force
46  fTemp = f;
47  fView = View(fTemp.begin(), fTemp.begin() + NSWithBody<memoryType>::B.offsets[l]);
48  cusp::blas::fill(fView, 0.0);
49  if(l < numBodies-1)
50  {
51  fView = View(fTemp.begin() + NSWithBody<memoryType>::B.offsets[l+1], fTemp.end());
52  cusp::blas::fill(fView, 0.0);
53  }
54  else
55  {
56  fView = View(fTemp.begin() + totalPoints, fTemp.end());
57  cusp::blas::fill(fView, 0.0);
58  }
59  cusp::multiply(ET, fTemp, F);
60  NSWithBody<memoryType>::B.forceX[l] = (dx*dy)/dx*thrust::reduce(F.begin(), F.end());
61 
62  // y-component of the force
63  fTemp = f;
64  fView = View(fTemp.begin(), fTemp.begin() + totalPoints + NSWithBody<memoryType>::B.offsets[l]);
65  cusp::blas::fill(fView, 0.0);
66  if(l < numBodies-1)
67  {
68  fView = View(fTemp.begin() + totalPoints + NSWithBody<memoryType>::B.offsets[l+1], fTemp.end());
69  cusp::blas::fill(fView, 0.0);
70  }
71  cusp::multiply(ET, fTemp, F);
72  NSWithBody<memoryType>::B.forceY[l] = (dx*dy)/dy*thrust::reduce(F.begin(), F.end());
73  }
74 } // calculateForce
double real
Is a float or a double depending on the machine precision.
Definition: types.h:116
Declaration of the kernels to calculate the forces acting on a body The method is described in Lai & ...
real forceX
force acting on each body in the x-direction
Definition: NSWithBody.h:26
real forceY
force acting on each body in the y-direction
Definition: NSWithBody.h:26
virtual void calculateForce()
Calculates forces acting on each immersed body.
Generic Navier-Stokes solver in the presence of immersed boundaries.
Definition: NSWithBody.h:21
Solves the Navier-Stokes equations in a rectangular domain.