15 logger.startTimer(
"tagPoints");
18 vecH bxH(B.totalPoints), byH(B.totalPoints), uBH(B.totalPoints), vBH(B.totalPoints);
25 real *bx = thrust::raw_pointer_cast(&(bxH[0])),
26 *by = thrust::raw_pointer_cast(&(byH[0])),
27 *uB = thrust::raw_pointer_cast(&(uBH[0])),
28 *vB = thrust::raw_pointer_cast(&(vBH[0]));
31 tagPoints(bx, by, uB, vB);
40 logger.stopTimer(
"tagPoints");
59 template <
typename memoryType>
69 std::string folder = db[
"inputs"][
"caseFolder"].get<std::string>();
73 int bottom, top, left, right;
75 bool outsideX, outsideY;
76 int bdryFlagX, bdryFlagY, bdryFlag2X, bdryFlag2Y;
78 real cfX, cfY, cf2X, cf2Y;
86 std::ofstream mask((folder+
"/mask.txt").c_str());
87 std::ofstream eta((folder+
"/eta_u.txt").c_str());
90 for(
int j=0; j<ny; j++)
92 for(
int i=0; i<nx-1; i++)
122 while(l<totalPoints && !flag)
148 if (by[bottom]-eps < yu[j] && by[top]-eps > yu[j])
151 if (fabs(by[l]-by[k]) > eps)
154 x = bx[k] + (bx[l]-bx[k]) * (yu[j]-by[k])/(by[l]-by[k]);
157 uvX = uB[k] + (uB[l]-uB[k]) * (yu[j]-by[k])/(by[l]-by[k]);
160 if (fabs(x-xu[i]) < eps)
171 else if (x > xu[i]+eps)
172 outsideX = !outsideX;
175 if (x>xu[i-1]+eps && x<xu[i]-eps)
184 case CONSTANT : cfX = 0.0; cf2X = 0.0;
break;
185 case LINEAR : cfX = a/(a+b); cf2X = 0.0;
break;
186 case QUADRATIC: cfX = 2*a/(a+b); cf2X = -a/(a+2*b);
break;
187 default: cfX = a/(a+b); cf2X = 0.0;
break;
191 else if (x>xu[i]+eps && x<xu[i+1]-eps)
200 case CONSTANT : cfX = 0.0; cf2X = 0.0;
break;
201 case LINEAR : cfX = a/(a+b); cf2X = 0.0;
break;
202 case QUADRATIC: cfX = 2*a/(a+b); cf2X = -a/(a+2*b);
break;
203 default: cfX = a/(a+b); cf2X = 0.0;
break;
210 if ( (bx[left]-eps < xu[i]) && (bx[right]-eps > xu[i]) && ( !flag ) )
213 if (fabs(bx[l]-bx[k]) > eps)
216 y = by[k] + (by[l]-by[k]) * (xu[i]-bx[k]) / (bx[l]-bx[k]);
219 uvY = uB[k] + (uB[l]-uB[k]) * (xu[i]-bx[k])/(bx[l]-bx[k]);
222 if (fabs(y-yu[j]) < eps)
233 else if (y > yu[j]+eps)
234 outsideY = !outsideY;
237 if (y>yu[j-1]+eps && y<yu[j]-eps)
239 bdryFlagY = I+(nx-1);
240 bdryFlag2Y= I+2*(nx-1);
246 case CONSTANT : cfY = 0.0; cf2Y = 0.0;
break;
247 case LINEAR : cfY = a/(a+b); cf2Y = 0.0;
break;
248 case QUADRATIC: cfY = 2*a/(a+b); cf2Y = -a/(a+2*b);
break;
249 default: cfY = a/(a+b); cf2Y = 0.0;
break;
253 else if (y>yu[j]+eps && y<yu[j+1]-eps)
255 bdryFlagY = I-(nx-1);
256 bdryFlag2Y= I-2*(nx-1);
262 case CONSTANT : cfY = 0.0; cf2Y = 0.0;
break;
263 case LINEAR : cfY = a/(a+b); cf2Y = 0.0;
break;
264 case QUADRATIC: cfY = 2*a/(a+b); cf2Y = -a/(a+2*b);
break;
265 default: cfY = a/(a+b); cf2Y = 0.0;
break;
273 if (outsideX && bdryFlagX>=0)
276 tags2[I] = bdryFlag2X;
280 eta << etaX << std::endl;
282 else if (outsideY && bdryFlagY>=0)
285 tags2[I] = bdryFlag2Y;
289 eta << etaY << std::endl;
291 mask << ((outsideX || outsideY)? 1 : 0) << std::endl;
296 std::ofstream file((folder+
"/tagx.txt").c_str());
297 for(
int j=0; j<ny; j++)
299 for(
int i=0; i<nx-1; i++)
304 file << xu[i] <<
'\t' << yu[j] << std::endl;
306 file << xu[i-1] <<
'\t' << yu[j] << std::endl;
307 else if (tags[I] == I+1)
308 file << xu[i+1] <<
'\t' << yu[j] << std::endl;
309 else if (tags[I] == I-(nx-1))
310 file << xu[i] <<
'\t' << yu[j-1] << std::endl;
311 else if (tags[I] == I+(nx-1))
312 file << xu[i] <<
'\t' << yu[j+1] << std::endl;
319 eta.open((folder+
"/eta_v.txt").c_str());
325 for(
int j=0; j<ny-1; j++)
327 for(
int i=0; i<nx; i++)
330 I = j*nx+i + (nx-1)*ny;
378 if (by[bottom]-eps < yv[j] && by[top]-eps > yv[j] && !flag)
381 if (fabs(by[l]-by[k]) > eps)
384 x = bx[k] + (bx[l]-bx[k]) * (yv[j]-by[k])/(by[l]-by[k]);
386 uvX = vB[k] + (vB[l]-vB[k]) * (yv[j]-by[k])/(by[l]-by[k]);
389 if (fabs(x-xv[i]) < eps)
400 else if (x > xv[i]+eps)
401 outsideX = !outsideX;
404 if (x>xv[i-1]+eps && x<xv[i]-eps)
413 case CONSTANT : cfX = 0.0; cf2X = 0.0;
break;
414 case LINEAR : cfX = a/(a+b); cf2X = 0.0;
break;
415 case QUADRATIC: cfX = 2*a/(a+b); cf2X = -a/(a+2*b);
break;
416 default: cfX = a/(a+b); cf2X = 0.0;
break;
420 else if (x>xv[i]+eps && x<xv[i+1]-eps)
429 case CONSTANT : cfX = 0.0; cf2X = 0.0;
break;
430 case LINEAR : cfX = a/(a+b); cf2X = 0.0;
break;
431 case QUADRATIC: cfX = 2*a/(a+b); cf2X = -a/(a+2*b);
break;
432 default: cfX = a/(a+b); cf2X = 0.0;
break;
438 if (bx[left]-eps < xv[i] && bx[right]-eps > xv[i] && !flag)
441 if (fabs(bx[l]-bx[k]) > eps)
444 y = by[k] + (by[l]-by[k]) * (xv[i]-bx[k])/(bx[l]-bx[k]);
446 uvY = vB[k] + (vB[l]-vB[k]) * (xv[i]-bx[k])/(bx[l]-bx[k]);
449 if (fabs(y-yv[j]) < eps)
460 else if (y > yv[j]+eps)
461 outsideY = !outsideY;
463 if (y>yv[j-1]+eps && y<yv[j]-eps)
472 case CONSTANT : cfY = 0.0; cf2Y = 0.0;
break;
473 case LINEAR : cfY = a/(a+b); cf2Y = 0.0;
break;
474 case QUADRATIC: cfY = 2*a/(a+b); cf2Y = -a/(a+2*b);
break;
475 default: cfY = a/(a+b); cf2Y = 0.0;
break;
478 else if (y>yv[j]+eps && y<yv[j+1]-eps)
487 case CONSTANT : cfY = 0.0; cf2Y = 0.0;
break;
488 case LINEAR : cfY = a/(a+b); cf2Y = 0.0;
break;
489 case QUADRATIC: cfY = 2*a/(a+b); cf2Y = -a/(a+2*b);
break;
490 default: cfY = a/(a+b); cf2Y = 0.0;
break;
498 if (outsideY && bdryFlagY>=0)
501 tags2[I] = bdryFlag2Y;
505 eta << etaY << std::endl;
507 else if (outsideX && bdryFlagX>=0)
510 tags2[I] = bdryFlag2X;
514 eta << etaX << std::endl;
516 mask << ((outsideX || outsideY)? 1 : 0) << std::endl;
522 file.open((folder+
"/tagy.txt").c_str());
523 for(
int j=0; j<ny-1; j++)
525 for(
int i=0; i<nx; i++)
527 I = j*nx+i+(nx-1)*ny;
528 if (tags[I] >= 0 || tags[I] >= 0)
530 file << xv[i] <<
'\t' << yv[j] << std::endl;
532 file << xv[i-1] <<
'\t' << yv[j] << std::endl;
533 else if (tags[I] == I+1)
534 file << xv[i+1] <<
'\t' << yv[j] << std::endl;
535 else if (tags[I] == I-nx)
536 file << xv[i] <<
'\t' << yv[j-1] << std::endl;
537 else if (tags[I] == I+nx)
538 file << xv[i] <<
'\t' << yv[j+1] << std::endl;
double real
Is a float or a double depending on the machine precision.
std::map< std::string, componentParameter > parameterDB
Map from a string to a componentParameter.
cusp::array1d< real, host_memory > vecH
Cusp 1D array stored in the host.
interpolationType
Specifies the type of interpolation.
Generic Navier-Stokes solver in the presence of immersed boundaries.
Solves the Navier-Stokes equations in a rectangular domain.