25 else if(r>0.5 && r<=1.5)
26 return 1.0/(6*h)*( 5.0 - 3.0*r - sqrt(-3.0*(1-r)*(1-r) + 1.0) );
28 return 1.0/(3*h)*( 1.0 + sqrt(-3.0*r*r + 1.0) );
65 void updateQ(
int *QRows,
int *QCols,
real *QVals,
int QSize,
int *tags)
67 int I = threadIdx.x + blockIdx.x*blockDim.x;
71 QVals[I] *= (tags[QRows[I]] == -1);
87 void updateQT(
int *QTRows,
int *QTCols,
real *QTVals,
int QTSize,
int *tags,
real *coeffs)
89 int I = threadIdx.x + blockIdx.x*blockDim.x;
95 QTCols[I] = (tags[col]==-1)*col + (tags[col]!=-1)*tags[col];
96 QTVals[I] = (tags[col]==-1)*val + (tags[col]!=-1)*coeffs[col]*val;
112 int numU = (nx-1)*ny;
116 int num_elements = 0;
121 for(
int j=0; j<ny; j++)
123 for(
int i=0; i<nx; i++)
126 Iv = j*nx + i + numU;
130 QTRows[num_elements] = row;
131 QTCols[num_elements] = Iu - 1;
132 QTVals[num_elements] = 1;
137 QTRows[num_elements] = row;
138 QTCols[num_elements] = Iu;
139 QTVals[num_elements] = -1;
144 QTRows[num_elements] = row;
145 QTCols[num_elements] = Iv - nx;
146 QTVals[num_elements] = 1;
151 QTRows[num_elements] = row;
152 QTCols[num_elements] = Iv;
153 QTVals[num_elements] = -1;
185 int *ERows,
int *ECols,
real *EVals,
187 int totalPoints,
real *xB,
real *yB,
int *I,
int *J)
189 int bodyIdx = threadIdx.x + blockIdx.x*blockDim.x;
191 if(bodyIdx >= totalPoints)
196 QTIdx = 4*nx*ny - 2*(nx+ny) + bodyIdx*12,
203 for(j=Jb-1; j<=Jb+1; j++)
205 for(i=Ib-2; i<=Ib+1; i++)
207 QTRows[QTIdx] = bodyIdx + nx*ny;
208 ERows[EIdx] = bodyIdx;
210 QTCols[QTIdx] = j*(nx-1) + i;
211 ECols[EIdx] = QTCols[QTIdx];
213 QTVals[QTIdx] = Dx*
deltaDeviceQT(x[i+1]-xB[bodyIdx], 0.5*(y[j]+y[j+1])-yB[bodyIdx], Dx);
214 EVals[EIdx] = QTVals[QTIdx];
222 for(j=Jb-2; j<=Jb+1; j++)
224 for(i=Ib-1; i<=Ib+1; i++)
226 QTRows[QTIdx+12*totalPoints-12] = bodyIdx + nx*ny + totalPoints;
227 ERows[EIdx+12*totalPoints-12] = bodyIdx + totalPoints;
229 QTCols[QTIdx+12*totalPoints-12] = j*nx + i + (nx-1)*ny;
230 ECols[EIdx+12*totalPoints-12] = QTCols[QTIdx+12*totalPoints-12];
232 QTVals[QTIdx+12*totalPoints-12] = Dx*
deltaDeviceQT(0.5*(x[i]+x[i+1])-xB[bodyIdx], y[j+1]-yB[bodyIdx], Dx);
233 EVals[EIdx+12*totalPoints-12] = QTVals[QTIdx+12*totalPoints-12];
__global__ void updateQT(int *QTRows, int *QTCols, real *QTVals, int QTSize, int *tags, real *coeffs)
Update the divergence operator at forcing nodes.
__device__ real dhRomaDeviceQT(real x, real h)
Discrete delta function defined by Roma et al. (1999).
double real
Is a float or a double depending on the machine precision.
Contains all the custom-written CUDA kernels.
void generateQT(int *QTRows, int *QTCols, real *QTVals, int nx, int ny)
Generates the divergence matrix (on the host).
__device__ real deltaDeviceQT(real x, real y, real h)
Two-dimensional discrete delta function.
Declaration of the kernels to generate gradient matrix and interpolation matrix.
__global__ void updateQ(int *QRows, int *QCols, real *QVals, int QSize, int *tags)
Update the gradient operator at forcing nodes.