21 real Cx0 = 0.0, Cx1 = 0.0, Cy0 = 0.0, Cy1 = 0.0,
23 dx0 = 1.0, dx1 = 1.0, dy0 = 1.0, dy1 = 1.0;
25 real *dx = thrust::raw_pointer_cast(&(domInfo->dx[0])),
26 *dy = thrust::raw_pointer_cast(&(domInfo->dy[0]));
29 int numUV = numU + nx*(ny-1);
33 cooH LHost(numUV, numUV, 5*numUV-4*(nx+ny)+4);
35 real nu = (*paramDB)[
"flow"][
"nu"].get<
real>();
37 for (
int j=0; j < ny; j++)
42 dy1 = 0.5*(dy[0]+dy[1]);
46 dy0 = 0.5*(dy[ny-2]+dy[ny-1]);
51 dy0 = 0.5*(dy[j]+dy[j-1]);
52 dy1 = 0.5*(dy[j]+dy[j+1]);
54 Cy0 = 2.0 * nu / ( dy1*(dy1+dy0) );
55 Cy1 = 2.0 * nu / ( dy0*(dy1+dy0) );
57 for (
int i=0; i < nx-1; i++)
61 Cx0 = 2.0 * nu / ( dx[i+1]*(dx[i+1]+dx[i]) );
62 Cx1 = 2.0 * nu / ( dx[i]*(dx[i+1]+dx[i]) );
64 scale = 0.5*(dx[i+1]+dx[i]);
69 LHost.row_indices[num_elements] = I;
70 LHost.column_indices[num_elements] = I - (nx-1);
71 LHost.values[num_elements] = Cy1 * scale / dy[j-1];
77 LHost.row_indices[num_elements] = I;
78 LHost.column_indices[num_elements] = I - 1;
79 LHost.values[num_elements] = Cx1 * scale / dy[j];
83 LHost.row_indices[num_elements] = I;
84 LHost.column_indices[num_elements] = I;
85 LHost.values[num_elements] = (-Cy0-Cy1-Cx0-Cx1) * scale / dy[j];
90 LHost.row_indices[num_elements] = I;
91 LHost.column_indices[num_elements] = I + 1;
92 LHost.values[num_elements] = Cx0 * scale / dy[j];
98 LHost.row_indices[num_elements] = I;
99 LHost.column_indices[num_elements] = I + (nx-1);
100 LHost.values[num_elements] = Cy0 * scale / dy[j+1];
107 for (
int j=0; j < ny-1; j++)
109 Cy0 = 2.0 * nu / ( dy[j+1]*(dy[j+1]+dy[j]) );
110 Cy1 = 2.0 * nu / ( dy[j]*(dy[j+1]+dy[j]) );
112 for (
int i=0; i < nx; i++)
116 if((i>0) && (i<nx-1))
118 dx0 = 0.5*(dx[i]+dx[i-1]);
119 dx1 = 0.5*(dx[i]+dx[i+1]);
124 dx1 = 0.5*(dx[i]+dx[i+1]);
128 dx0 = 0.5*(dx[i]+dx[i-1]);
131 Cx0 = 2.0 * nu /( dx1*(dx1+dx0) );
132 Cx1 = 2.0 * nu /( dx0*(dx1+dx0) );
134 scale = 0.5*(dy[j+1]+dy[j]);
139 LHost.row_indices[num_elements] = I;
140 LHost.column_indices[num_elements] = I - nx;
141 LHost.values[num_elements] = Cy1 * scale / dx[i];
147 LHost.row_indices[num_elements] = I;
148 LHost.column_indices[num_elements] = I - 1;
149 LHost.values[num_elements] = Cx1 * scale / dx[i-1];
153 LHost.row_indices[num_elements] = I;
154 LHost.column_indices[num_elements] = I;
155 LHost.values[num_elements] = (-Cy0-Cy1-Cx0-Cx1) * scale / dx[i];
160 LHost.row_indices[num_elements] = I;
161 LHost.column_indices[num_elements] = I + 1;
162 LHost.values[num_elements] = Cx0 * scale / dx[i+1];
168 LHost.row_indices[num_elements] = I;
169 LHost.column_indices[num_elements] = I + nx;
170 LHost.values[num_elements] = Cy0 * scale / dx[i];
double real
Is a float or a double depending on the machine precision.
cusp::coo_matrix< int, real, host_memory > cooH
COO matrix stored on the host.