19 real Cx0 = 0.0, Cx1 = 0.0, Cy0 = 0.0, Cy1 = 0.0,
21 dx0 = 1.0, dx1 = 1.0, dy0 = 1.0, dy1 = 1.0;
23 real *dx = thrust::raw_pointer_cast(&(domInfo->dx[0])),
24 *dy = thrust::raw_pointer_cast(&(domInfo->dy[0]));
27 int numUV = numU + nx*(ny-1);
31 cooH LHost(numUV, numUV, 5*numUV-4*(nx+ny)+4);
33 real nu = (*paramDB)[
"flow"][
"nu"].get<
real>();
34 real dt = (*paramDB)[
"simulation"][
"dt"].get<
real>();
37 bool notBdryNode =
true;
58 for (
int j=0; j < ny; j++)
63 dy1 = 0.5*(dy[0]+dy[1]);
67 dy0 = 0.5*(dy[ny-2]+dy[ny-1]);
72 dy0 = 0.5*(dy[j]+dy[j-1]);
73 dy1 = 0.5*(dy[j]+dy[j+1]);
75 Cy0 = 2.0 * nu / ( dy1*(dy1+dy0) );
76 Cy1 = 2.0 * nu / ( dy0*(dy1+dy0) );
78 for (
int i=0; i < nx-1; i++)
84 notBdryNode = (tags[I]==-1);
86 Cx0 = 2.0 * nu / ( dx[i+1]*(dx[i+1]+dx[i]) );
87 Cx1 = 2.0 * nu / ( dx[i]*(dx[i+1]+dx[i]) );
90 scale = 0.5*(dx[i+1]+dx[i]);
95 LHost.row_indices[num_elements] = I;
96 LHost.column_indices[num_elements] = I-(nx-1);
97 LHost.values[num_elements] = 0.0;
100 LHost.values[num_elements] = Cy1 * scale / dy[j-1];
101 else if(tags[I]==I-(nx-1) && interpType==
LINEAR)
102 LHost.values[num_elements] = coeffs[I] /dt * scale / dy[j-1];
103 else if((tags2[I]==I-2 || tags2[I]==I-2*(nx-1)) && interpType==
QUADRATIC)
105 LHost.column_indices[num_elements] = tags2[I];
106 LHost.values[num_elements] = coeffs2[I] /dt * scale / dy[j-1];
114 LHost.row_indices[num_elements] = I;
115 LHost.column_indices[num_elements] = I-1;
116 LHost.values[num_elements] = 0.0;
119 LHost.values[num_elements] = Cx1 * scale / dy[j];
120 else if(tags[I]==I-1)
121 LHost.values[num_elements] = coeffs[I] /dt * scale / dy[j];
122 else if(tags[I]==I-(nx-1) && interpType==
QUADRATIC)
124 LHost.column_indices[num_elements] = I-(nx-1);
125 LHost.values[num_elements] = coeffs[I] /dt * scale / dy[j];
131 LHost.row_indices[num_elements] = I;
132 LHost.column_indices[num_elements] = I;
134 LHost.values[num_elements] = (-Cy0-Cy1-Cx0-Cx1) * scale / dy[j];
136 LHost.values[num_elements] = 0.0;
141 LHost.row_indices[num_elements] = I;
142 LHost.column_indices[num_elements] = I+1;
143 LHost.values[num_elements] = 0.0;
146 LHost.values[num_elements] = Cx0 * scale / dy[j];
147 else if(tags[I]==I+1)
148 LHost.values[num_elements] = coeffs[I] /dt * scale / dy[j];
149 else if(tags[I]==I+(nx-1) && interpType==
QUADRATIC)
151 LHost.column_indices[num_elements] = I+(nx-1);
152 LHost.values[num_elements] = coeffs[I] /dt * scale / dy[j];
160 LHost.row_indices[num_elements] = I;
161 LHost.column_indices[num_elements] = I+(nx-1);
162 LHost.values[num_elements] = 0.0;
165 LHost.values[num_elements] = Cy0 * scale / dy[j+1];
166 else if(tags[I]==I+(nx-1) && interpType==
LINEAR)
167 LHost.values[num_elements] = coeffs[I] /dt * scale / dy[j+1];
168 else if((tags2[I]==I+2 || tags2[I]==I+2*(nx-1)) && interpType==
QUADRATIC)
170 LHost.column_indices[num_elements] = tags2[I];
171 LHost.values[num_elements] = coeffs2[I] /dt * scale / dy[j+1];
180 for (
int j=0; j < ny-1; j++)
182 Cy0 = 2.0 * nu / ( dy[j+1]*(dy[j+1]+dy[j]) );
183 Cy1 = 2.0 * nu / ( dy[j]*(dy[j+1]+dy[j]) );
185 for (
int i=0; i < nx; i++)
188 notBdryNode = (tags[I]==-1);
190 if((i>0) && (i<nx-1))
192 dx0 = 0.5*(dx[i]+dx[i-1]);
193 dx1 = 0.5*(dx[i]+dx[i+1]);
198 dx1 = 0.5*(dx[i]+dx[i+1]);
202 dx0 = 0.5*(dx[i]+dx[i-1]);
205 Cx0 = 2.0 * nu /( dx1*(dx1+dx0) );
206 Cx1 = 2.0 * nu /( dx0*(dx1+dx0) );
208 scale = 0.5*(dy[j+1]+dy[j]);
213 LHost.row_indices[num_elements] = I;
214 LHost.column_indices[num_elements] = I-nx;
215 LHost.values[num_elements] = 0.0;
218 LHost.values[num_elements] = Cy1 * scale / dx[i];
219 else if(tags[I]==I-nx && interpType==
LINEAR)
220 LHost.values[num_elements] = coeffs[I] /dt * scale / dx[i];
221 else if((tags2[I]==I-2 || tags2[I]==I-2*nx) && interpType==
QUADRATIC)
223 LHost.column_indices[num_elements] = tags2[I];
224 LHost.values[num_elements] = coeffs2[I] /dt * scale / dx[i];
232 LHost.row_indices[num_elements] = I;
233 LHost.column_indices[num_elements] = I-1;
234 LHost.values[num_elements] = 0.0;
237 LHost.values[num_elements] = Cx1 * scale / dx[i-1];
238 else if(tags[I]==I-1)
239 LHost.values[num_elements] = coeffs[I] /dt * scale / dx[i-1];
240 else if(tags[I]==I-nx && interpType==
QUADRATIC)
242 LHost.column_indices[num_elements] = I-nx;
243 LHost.values[num_elements] = coeffs[I] /dt * scale / dx[i-1];
249 LHost.row_indices[num_elements] = I;
250 LHost.column_indices[num_elements] = I;
252 LHost.values[num_elements] = (-Cy0-Cy1-Cx0-Cx1) * scale / dx[i];
254 LHost.values[num_elements] = 0.0;
259 LHost.row_indices[num_elements] = I;
260 LHost.column_indices[num_elements] = I+1;
261 LHost.values[num_elements] = 0.0;
264 LHost.values[num_elements] = Cx0 * scale / dx[i+1];
265 else if(tags[I]==I+1)
266 LHost.values[num_elements] = coeffs[I] /dt * scale / dx[i+1];
267 else if(tags[I]==I+nx && interpType==
QUADRATIC)
269 LHost.column_indices[num_elements] = I+nx;
270 LHost.values[num_elements] = coeffs[I] /dt * scale / dx[i+1];
278 LHost.row_indices[num_elements] = I;
279 LHost.column_indices[num_elements] = I+nx;
280 LHost.values[num_elements] = 0.0;
283 LHost.values[num_elements] = Cy0 * scale / dx[i];
284 else if(tags[I]==I+nx && interpType==
LINEAR)
285 LHost.values[num_elements] = coeffs[I] /dt * scale / dx[i];
286 else if((tags2[I]==I+2 || tags2[I]==I+2*nx) && interpType==
QUADRATIC)
288 LHost.column_indices[num_elements] = tags2[I];
289 LHost.values[num_elements] = coeffs2[I] /dt * scale / dx[i];
double real
Is a float or a double depending on the machine precision.
interpolationType
Specifies the type of interpolation.
cusp::coo_matrix< int, real, host_memory > cooH
COO matrix stored on the host.