52 ASSERTL0(
m_geom !=
nullptr,
"A locator needs a geometry to search.");
79 ASSERTL0(geom !=
nullptr,
"A locator needs a geometry to search.");
85 loc = std::make_unique<GeometryLocator1D>(geom);
88 loc = std::make_unique<GeometryLocator2D>(geom);
91 loc = std::make_unique<GeometryLocator3D>(geom);
95 "No inverse mapping for this shape dimension.");
174 p->GetCoords(x[0], x[1], x[2]);
175 for (
int j = 0; j < 3; ++j)
183 p->GetCoords(x[0], x[1], x[2]);
184 for (
int j = 0; j < 3; ++j)
186 min[j] = (x[j] <
min[j] ? x[j] :
min[j]);
187 max[j] = (x[j] >
max[j] ? x[j] :
max[j]);
197 for (
int j = 0; j < 3; ++j)
205 for (
int j = 0; j < 3; ++j)
207 for (
int i = 0; i < nq; ++i)
209 min[j] = (xvec[j][i] <
min[j] ? xvec[j][i] :
min[j]);
210 max[j] = (xvec[j][i] >
max[j] ? xvec[j][i] :
max[j]);
216 for (
int j = 0; j < 3; ++j)
226 for (
int j = 0; j < 3; ++j)
256 edgeDist = std::numeric_limits<double>::max();
284 "Expects number of global coordinates supplied to be greater than "
285 "or equal to the mesh dimension.");
290 if ((gloCoord[i] < minMax[i]) || (gloCoord[i] > minMax[i + 3]))
307 ASSERTL1(locCoord.size() >= dim,
"Expects local coordinates to be same or "
308 "larger than shape dimension.");
315 for (
int i = 0; i < dim; ++i)
317 if (!std::isfinite(locCoord[i]))
322 else if (locCoord[i] < -(1. + tol))
324 locCoord[i] = -(1. + tol);
327 else if (locCoord[i] > (1. + tol))
329 locCoord[i] = 1. + tol;
351 if (edgeDist < std::numeric_limits<double>::max())
365 if (locDist < std::numeric_limits<double>::max())
367 dist = std::max(dist, locDist);
398 dist = std::numeric_limits<double>::max();
430 "This function is only valid for expansion type geometries");
439 "This function has not been defined for this geometry");
476 NekDouble dist = std::numeric_limits<double>::max();
491 len += (pts[npts - 1] - pts[0]) * (pts[npts - 1] - pts[0]);
492 xi += (coords[i] - pts[0]) * (pts[npts - 1] - pts[0]);
497 dist = -xi *
sqrt(len);
501 dist = (xi - 1.) *
sqrt(len);
504 Lcoords[0] = 2. * xi - 1.0;
509 "inverse mapping must be set up to use this call");
530 tmp += (xs[i] - gloCoord[i]) * (xs[i] - gloCoord[i]);
550 for (
int i = 0; i < dim; ++i)
559 NekDouble fx_prev = std::numeric_limits<NekDouble>::max();
568 NekDouble fx = 0, fxp = 0, fxp2 = 0, xcDiff = 0;
569 for (
int j = 0; j < dim; ++j)
574 xcDiff = xc[j] - xs[j];
576 fx += xcDiff * xcDiff;
577 fxp += xc_der[j][0] * xcDiff;
578 fxp2 += xc_der2[j][0] * xcDiff + xc_der[j][0] * xc_der[j][0];
585 if (std::abs(fx - fx_prev) < 1e-12)
602 while (gamma > 1e-10)
605 xi_pk[0] = xi[0] + pk * gamma;
607 if (xi_pk[0] < -1.0 || xi_pk[0] > 1.0)
615 NekDouble fx_pk = 0, fxp_pk = 0, xc_pkDiff = 0;
616 for (
int j = 0; j < dim; ++j)
621 xc_pkDiff = xc_pk[j] - xs[j];
622 fx_pk += xc_pkDiff * xc_pkDiff;
623 fxp_pk += xc_der_pk[j][0] * xc_pkDiff;
630 if ((fx_pk - (fx + c1 * gamma * pk * fxp)) <
631 std::numeric_limits<NekDouble>::epsilon() &&
632 (-pk * fxp_pk + c2 * pk * fxp) <
633 std::numeric_limits<NekDouble>::epsilon())
651 return sqrt(fx_prev);
665 int i0 = 0, i1 = 1, j1 = 0, j2 = 1;
679 (coords[i1] - gamma * coords[i0] - isoParam[1][0]) * isoParam[1][1];
680 NekDouble denom = 1. / (isoParam[0][2] + isoParam[0][3] * tty);
682 NekDouble h = (isoParam[0][0] + isoParam[0][1] * tty - coords[i0]) * denom;
683 Lcoords[j2] = -h / (0.5 +
sqrt(0.25 - epsilon * h));
684 Lcoords[j1] = -
beta * Lcoords[j2] + tty;
709 NekDouble derx_1, derx_2, dery_1, dery_2, jac;
712 NekDouble init0 = Lcoords[0], init1 = Lcoords[1];
730 while (cnt++ < MaxIterations)
741 F1 = coords[0] - xmap;
742 F2 = coords[1] - ymap;
744 if (F1 * F1 + F2 * F2 < ScaledTol)
746 resid =
sqrt(F1 * F1 + F2 * F2);
757 jac = dery_2 * derx_1 - dery_1 * derx_2;
763 (dery_2 * (coords[0] - xmap) - derx_2 * (coords[1] - ymap)) / jac;
767 (-dery_1 * (coords[0] - xmap) + derx_1 * (coords[1] - ymap)) / jac;
769 if (!(std::isfinite(Lcoords[0]) && std::isfinite(Lcoords[1])))
772 std::ostringstream ss;
773 ss <<
"nan or inf found in NewtonIterationForLocCoord in element "
778 if (fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv)
792 F1 = coords[0] - xmap;
793 F2 = coords[1] - ymap;
794 dist =
sqrt(F1 * F1 + F2 * F2);
808 F1 = coords[0] - xmap;
809 F2 = coords[1] - ymap;
810 dist = std::sqrt(F1 * F1 + F2 * F2);
814 if (cnt >= MaxIterations)
820 if ((collCoords[0] >= -1.0 && collCoords[0] <= 1.0) &&
821 (collCoords[1] >= -1.0 && collCoords[1] <= 1.0))
823 std::ostringstream ss;
825 ss <<
"Reached MaxIterations (" << MaxIterations
826 <<
") in Newton iteration ";
827 ss <<
"Init value (" << std::setprecision(4) << init0 <<
","
830 ss <<
"Fin value (" << Lcoords[0] <<
"," << Lcoords[1] <<
","
832 ss <<
"Resid = " << resid
833 <<
" Tolerance = " << std::sqrt(ScaledTol);
835 WARNINGL1(cnt < MaxIterations, ss.str());
843 NekDouble dist = std::numeric_limits<double>::max();
878 Vmath::Sadd(npts, -tmpcoords[0], ptsx, 1, tmpx, 1);
879 Vmath::Sadd(npts, -tmpcoords[1], ptsy, 1, tmpy, 1);
888 eta[0] = za[min_i % za.size()];
889 eta[1] = zb[min_i / za.size()];
909 dist =
sqrt(z * z + dist * dist);
935 return sqrt((xs[0] - gloCoord[0]) * (xs[0] - gloCoord[0]) +
936 (xs[1] - gloCoord[1]) * (xs[1] - gloCoord[1]) +
937 (xs[2] - gloCoord[2]) * (xs[2] - gloCoord[2]));
959 zderxi1(nq, 0.0), xderxi2(nq, 0.0), yderxi2(nq, 0.0),
960 zderxi2(nq, 0.0), xderxi1xi1(nq, 0.0), yderxi1xi1(nq, 0.0),
961 zderxi1xi1(nq, 0.0), xderxi1xi2(nq, 0.0), yderxi1xi2(nq, 0.0),
962 zderxi1xi2(nq, 0.0), xderxi2xi1(nq, 0.0), yderxi2xi1(nq, 0.0),
963 zderxi2xi1(nq, 0.0), xderxi2xi2(nq, 0.0), yderxi2xi2(nq, 0.0),
967 std::array<NekDouble, 3> xc_derxi, yc_derxi, zc_derxi;
982 NekDouble fx_prev = std::numeric_limits<NekDouble>::max();
1016 NekDouble fx = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
1018 NekDouble fx_derxi1 = 2.0 * xdiff * xc_derxi[0] +
1019 2.0 * ydiff * yc_derxi[0] +
1020 2.0 * zdiff * zc_derxi[0];
1022 NekDouble fx_derxi2 = 2.0 * xdiff * xc_derxi[1] +
1023 2.0 * ydiff * yc_derxi[1] +
1024 2.0 * zdiff * zc_derxi[1];
1027 2.0 * xdiff * xc_derxi1xi1 + 2.0 * xc_derxi[0] * xc_derxi[0] +
1028 2.0 * ydiff * yc_derxi1xi1 + 2.0 * yc_derxi[0] * yc_derxi[0] +
1029 2.0 * zdiff * zc_derxi1xi1 + 2.0 * zc_derxi[0] * zc_derxi[0];
1032 2.0 * xdiff * xc_derxi1xi2 + 2.0 * xc_derxi[1] * xc_derxi[0] +
1033 2.0 * ydiff * yc_derxi1xi2 + 2.0 * yc_derxi[1] * yc_derxi[0] +
1034 2.0 * zdiff * zc_derxi1xi2 + 2.0 * zc_derxi[1] * zc_derxi[0];
1037 2.0 * xdiff * xc_derxi2xi2 + 2.0 * xc_derxi[1] * xc_derxi[1] +
1038 2.0 * ydiff * yc_derxi2xi2 + 2.0 * yc_derxi[1] * yc_derxi[1] +
1039 2.0 * zdiff * zc_derxi2xi2 + 2.0 * zc_derxi[1] * zc_derxi[1];
1050 1 / (fx_derxi1xi1 * fx_derxi2xi2 - fx_derxi1xi2 * fx_derxi1xi2);
1051 hessInv[0][0] = det * fx_derxi2xi2;
1052 hessInv[0][1] = det * -fx_derxi1xi2;
1053 hessInv[1][0] = det * -fx_derxi1xi2;
1054 hessInv[1][1] = det * fx_derxi1xi1;
1057 if (std::abs(fx - fx_prev) < 1e-12)
1072 pk[0] = -(hessInv[0][0] * jac[0] + hessInv[1][0] * jac[1]);
1073 pk[1] = -(hessInv[0][1] * jac[0] + hessInv[1][1] * jac[1]);
1076 while (gamma > 1e-10)
1079 xi_pk[0] = xi[0] + pk[0] * gamma;
1080 xi_pk[1] = xi[1] + pk[1] * gamma;
1086 (-1 - std::numeric_limits<NekDouble>::epsilon()) ||
1088 (1 + std::numeric_limits<NekDouble>::epsilon()) ||
1090 (-1 - std::numeric_limits<NekDouble>::epsilon()) ||
1091 eta_pk[1] > (1 + std::numeric_limits<NekDouble>::epsilon()))
1097 std::array<NekDouble, 3> xc_pk_derxi, yc_pk_derxi, zc_pk_derxi;
1110 NekDouble fx_pk = xc_pk_diff * xc_pk_diff +
1111 yc_pk_diff * yc_pk_diff +
1112 zc_pk_diff * zc_pk_diff;
1114 NekDouble fx_pk_derxi1 = 2.0 * xc_pk_diff * xc_pk_derxi[0] +
1115 2.0 * yc_pk_diff * yc_pk_derxi[0] +
1116 2.0 * zc_pk_diff * zc_pk_derxi[0];
1118 NekDouble fx_pk_derxi2 = 2.0 * xc_pk_diff * xc_pk_derxi[1] +
1119 2.0 * yc_pk_diff * yc_pk_derxi[1] +
1120 2.0 * zc_pk_diff * zc_pk_derxi[1];
1124 NekDouble tmp = pk[0] * fx_derxi1 + pk[1] * fx_derxi2;
1125 NekDouble tmp2 = pk[0] * fx_pk_derxi1 + pk[1] * fx_pk_derxi2;
1126 if ((fx_pk - (fx + c1 * gamma * tmp)) <
1127 std::numeric_limits<NekDouble>::epsilon() &&
1128 (-tmp2 - (-c2 * tmp)) <
1129 std::numeric_limits<NekDouble>::epsilon())
1143 xi[0] += gamma * pk[0];
1144 xi[1] += gamma * pk[1];
1148 return sqrt(fx_prev);
1178 std::array<std::array<NekDouble, 3>, 2> x;
1180 int i0 = 1, i1 = 0, direction = 1;
1186 ->
GetCoords(x[i1][0], x[i1][1], x[i1][2]);
1213 if (direction == -1)
1226 std::array<NekDouble, 3> vertex;
1262 nearDist = std::max(nearDist, -s / std::sqrt(n2));
1267 edgeDist = nearDist;
1294 std::vector<NekDouble> c(3);
1295 for (
int i = 0; i < 3; ++i)
1299 if (fabs(c[1]) >= fabs(c[2]))
1336 const int MaxIterations = 51;
1348 ScaledTol *= Tol * Tol;
1356 while (cnt++ < MaxIterations)
1358 var[1] = Lcoords[0];
1359 var[2] = Lcoords[1];
1360 var[3] = Lcoords[2];
1361 var[4] = Lcoords[0] * Lcoords[1];
1362 var[5] = Lcoords[1] * Lcoords[2];
1363 var[6] = Lcoords[0] * Lcoords[2];
1364 var[7] = var[4] * Lcoords[2];
1366 xmap =
Vmath::Dot(nIso, var.data(), 1, isoParam[0].data(), 1);
1367 ymap =
Vmath::Dot(nIso, var.data(), 1, isoParam[1].data(), 1);
1368 zmap =
Vmath::Dot(nIso, var.data(), 1, isoParam[2].data(), 1);
1370 tmp[0] = coords[0] - xmap;
1371 tmp[1] = coords[1] - ymap;
1372 tmp[2] = coords[2] - zmap;
1374 res = tmp[0] * tmp[0] + tmp[1] * tmp[1] + tmp[2] * tmp[2];
1375 if (res < ScaledTol)
1383 deriv[0] = isoParam[0][1] + isoParam[0][4] * Lcoords[1];
1384 deriv[1] = isoParam[0][2] + isoParam[0][4] * Lcoords[0];
1385 deriv[2] = isoParam[0][3];
1386 deriv[3] = isoParam[1][1] + isoParam[1][4] * Lcoords[1];
1387 deriv[4] = isoParam[1][2] + isoParam[1][4] * Lcoords[0];
1388 deriv[5] = isoParam[1][3];
1389 deriv[6] = isoParam[2][1] + isoParam[2][4] * Lcoords[1];
1390 deriv[7] = isoParam[2][2] + isoParam[2][4] * Lcoords[0];
1391 deriv[8] = isoParam[2][3];
1394 deriv[1] += isoParam[0][5] * Lcoords[2];
1395 deriv[2] += isoParam[0][5] * Lcoords[1];
1396 deriv[4] += isoParam[1][5] * Lcoords[2];
1397 deriv[5] += isoParam[1][5] * Lcoords[1];
1398 deriv[7] += isoParam[2][5] * Lcoords[2];
1399 deriv[8] += isoParam[2][5] * Lcoords[1];
1403 deriv[0] += isoParam[0][6] * Lcoords[2] + isoParam[0][7] * var[5];
1404 deriv[1] += isoParam[0][7] * var[6];
1405 deriv[2] += isoParam[0][6] * Lcoords[0] + isoParam[0][7] * var[4];
1406 deriv[3] += isoParam[1][6] * Lcoords[2] + isoParam[1][7] * var[5];
1407 deriv[4] += isoParam[1][7] * var[6];
1408 deriv[5] += isoParam[1][6] * Lcoords[0] + isoParam[1][7] * var[4];
1409 deriv[6] += isoParam[2][6] * Lcoords[2] + isoParam[2][7] * var[5];
1410 deriv[7] += isoParam[2][7] * var[6];
1411 deriv[8] += isoParam[2][6] * Lcoords[0] + isoParam[2][7] * var[4];
1417 Lcoords[0] +=
Vmath::Dot(3, mat->GetPtr(), 1, tmp, 1);
1418 Lcoords[1] +=
Vmath::Dot(3, mat->GetPtr() + 3, 1, tmp, 1);
1419 Lcoords[2] +=
Vmath::Dot(3, mat->GetPtr() + 6, 1, tmp, 1);
1421 if (!(std::isfinite(Lcoords[0]) && std::isfinite(Lcoords[1]) &&
1422 std::isfinite(Lcoords[2])) ||
1423 fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv ||
1424 fabs(Lcoords[2]) > LcoordDiv)
1426 std::ostringstream ss;
1427 ss <<
"Iteration has diverged in NewtonIterationForLocCoord in "
1437 var[1] = Lcoords[0];
1438 var[2] = Lcoords[1];
1439 var[3] = Lcoords[2];
1440 var[4] = Lcoords[0] * Lcoords[1];
1441 var[5] = Lcoords[1] * Lcoords[2];
1442 var[6] = Lcoords[0] * Lcoords[2];
1443 var[7] = var[4] * Lcoords[2];
1444 for (
int i = 0; i < 3; ++i)
1447 coords[i] -
Vmath::Dot(nIso, var.data(), 1, isoParam[i].data(), 1);
1449 dist = std::sqrt(tmp[0] * tmp[0] + tmp[1] * tmp[1] + tmp[2] * tmp[2]);
1451 std::ostringstream ss;
1453 ss <<
"Reached MaxIterations (" << MaxIterations
1454 <<
") in Newton iteration ";
1456 WARNINGL1(cnt < MaxIterations, ss.str());
1483 NekDouble derx_1, derx_2, derx_3, dery_1, dery_2, dery_3, derz_1, derz_2,
1487 NekDouble init0 = Lcoords[0], init1 = Lcoords[1], init2 = Lcoords[2];
1508 F1 = F2 = F3 = 2000;
1511 while (cnt++ < MaxIterations)
1524 F1 = coords[0] - xmap;
1525 F2 = coords[1] - ymap;
1526 F3 = coords[2] - zmap;
1528 if (F1 * F1 + F2 * F2 + F3 * F3 < ScaledTol)
1530 resid =
sqrt(F1 * F1 + F2 * F2 + F3 * F3);
1546 jac = derx_1 * (dery_2 * derz_3 - dery_3 * derz_2) -
1547 derx_2 * (dery_1 * derz_3 - dery_3 * derz_1) +
1548 derx_3 * (dery_1 * derz_2 - dery_2 * derz_1);
1554 ((dery_2 * derz_3 - dery_3 * derz_2) * (coords[0] - xmap) -
1555 (derx_2 * derz_3 - derx_3 * derz_2) * (coords[1] - ymap) +
1556 (derx_2 * dery_3 - derx_3 * dery_2) * (coords[2] - zmap)) /
1561 ((dery_1 * derz_3 - dery_3 * derz_1) * (coords[0] - xmap) -
1562 (derx_1 * derz_3 - derx_3 * derz_1) * (coords[1] - ymap) +
1563 (derx_1 * dery_3 - derx_3 * dery_1) * (coords[2] - zmap)) /
1568 ((dery_1 * derz_2 - dery_2 * derz_1) * (coords[0] - xmap) -
1569 (derx_1 * derz_2 - derx_2 * derz_1) * (coords[1] - ymap) +
1570 (derx_1 * dery_2 - derx_2 * dery_1) * (coords[2] - zmap)) /
1573 if (!(std::isfinite(Lcoords[0]) && std::isfinite(Lcoords[1]) &&
1574 std::isfinite(Lcoords[2])))
1577 std::ostringstream ss;
1578 ss <<
"nan or inf found in NewtonIterationForLocCoord in element "
1583 if (fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv ||
1584 fabs(Lcoords[2]) > LcoordDiv)
1600 F1 = coords[0] - xmap;
1601 F2 = coords[1] - ymap;
1602 F3 = coords[2] - zmap;
1603 dist =
sqrt(F1 * F1 + F2 * F2 + F3 * F3);
1619 F1 = coords[0] - xmap;
1620 F2 = coords[1] - ymap;
1621 F3 = coords[2] - zmap;
1622 dist = std::sqrt(F1 * F1 + F2 * F2 + F3 * F3);
1626 if (cnt >= MaxIterations)
1632 if ((collCoords[0] >= -1.0 && collCoords[0] <= 1.0) &&
1633 (collCoords[1] >= -1.0 && collCoords[1] <= 1.0) &&
1634 (collCoords[2] >= -1.0 && collCoords[2] <= 1.0))
1636 std::ostringstream ss;
1638 ss <<
"Reached MaxIterations (" << MaxIterations
1639 <<
") in Newton iteration ";
1640 ss <<
"Init value (" << std::setprecision(4) << init0 <<
","
1641 << init1 <<
"," << init2 <<
") ";
1642 ss <<
"Fin value (" << Lcoords[0] <<
"," << Lcoords[1] <<
","
1643 << Lcoords[2] <<
") ";
1644 ss <<
"Resid = " << resid
1645 <<
" Tolerance = " << std::sqrt(ScaledTol);
1647 WARNINGL1(cnt < MaxIterations, ss.str());
1655 NekDouble dist = std::numeric_limits<double>::max();
1657 tmpcoords[0] = coords[0];
1658 tmpcoords[1] = coords[1];
1659 tmpcoords[2] = coords[2];
1702 Vmath::Vvtvp(npts, tmp2, 1, tmp2, 1, tmp1, 1, tmp1, 1);
1704 Vmath::Vvtvp(npts, tmp2, 1, tmp2, 1, tmp1, 1, tmp1, 1);
1709 int qa = za.size(), qb = zb.size();
1712 eta[2] = zc[min_i / (qa * qb)];
1713 min_i = min_i % (qa * qb);
1714 eta[1] = zb[min_i / qa];
1715 eta[0] = za[min_i % qa];
1728 for (
int i = 0; i < 3; ++i)
1730 for (
int j = 0; j < 3; ++j)
1737 for (
int i = 0; i < 3; ++i)
1739 for (
int j = 0; j < 3; ++j)
#define WARNINGL1(condition, msg)
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
NekDouble GetCoord(const int i, const Array< OneD, const NekDouble > &Lcoord)
Evaluate the mapping: physical coordinate in direction i at the local collapsed coordinate Lcoord.
LibUtilities::ShapeType GetShapeType(void)
The shape this object is, as a LibUtilities::ShapeType.
int GetShapeDim() const
Dimension of the shape itself, which may be less than GetCoordim().
GeomType CalcGeomType()
Classify whether this shape is regular or deformed.
int GetGlobalID(void) const
Get the ID of this object.
PointGeom * GetVertex(int i) const
Get vertex i of this object.
int GetCoordim() const
Dimension of the space this object is embedded in.
void FillGeom()
Gather the coefficients of from this object's boundary, unless that has already been done.
int GetNumVerts() const
Get the number of vertices of this object.
bool HasLinearXmap()
True if every basis is linear.
Geometry1D * GetEdge(int i) const
Get edge i of this object.
StdRegions::StdExpansion * GetXmap() const
The expansion holding the mapping from the standard element to this one. Shared between geometries a...
const Array< OneD, const NekDouble > & GetCoeffs(const int i)
The coefficients of in coordinate direction i, filling them first if that has not happened yet.
GeomFactorsUniquePtr GenGeomFactors(LibUtilities::PointsKeyVector &keyTgt)
Build the #GeomFactors for this object at the quadrature points keyTgt.
NekDouble v_FindDistance(const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi) override
NekDouble v_GetLocCoords(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) override
void v_CalculateInverseIsoParam() override
int v_AllLeftCheck(const Array< OneD, const NekDouble > &gloCoord, NekDouble &edgeDist) override
void v_PreSolveStraightEdge() override
NekDouble v_FindDistance(const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi) override
void NewtonIterationForLocCoord(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &ptsx, const Array< OneD, const NekDouble > &ptsy, Array< OneD, NekDouble > &Lcoords, NekDouble &dist)
NekDouble v_GetLocCoords(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) override
void SolveStraightEdgeQuad(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
void NewtonIterationForLocCoord(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords, NekDouble &dist)
void v_CalculateInverseIsoParam() override
NekDouble v_GetLocCoords(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) override
int PreliminaryCheck(const Array< OneD, const NekDouble > &gloCoord, NekDouble &edgeDist)
A fast and robust check if a given global coord is outside of a deformed element. For regular element...
bool m_edgeNormalBuilt
2D only: inward edge normals used to reject points outside straight-sided elements....
virtual NekDouble v_GetLocCoords(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
IsoParam m_iso
The shape's isoparametric coefficients. The straight-edged 2D solve rewrites them into a factored for...
NekDouble FindDistance(const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi)
Geometry * m_geom
The geometry being searched. Not owned.
virtual void v_CalculateInverseIsoParam()
std::array< std::array< NekDouble, 2 >, kMaxGeomVerts > m_edgeNormal
static std::unique_ptr< GeometryLocator > Create(Geometry *geom)
Build the locator appropriate to geom's dimension, with its cache already populated.
virtual void v_PreSolveStraightEdge()
std::array< NekDouble, 6 > GetBoundingBox()
Generates the bounding box for the element.
bool ContainsPoint(const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0)
Determine whether the element contains a Cartesian coordinate.
NekDouble GetLocCoords(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
Determine the local collapsed coordinates corresponding to a given Cartesian coordinate.
bool MinMaxCheck(const Array< OneD, const NekDouble > &gloCoord)
Check if given global coord is within the BoundingBox of the element.
void Build()
Populate the cache. Called by Create() once the concrete type exists, since it dispatches virtually.
std::array< NekDouble, 6 > m_boundingBox
int m_straightEdge
Non-zero if every basis is linear. Bits 1 and 2 are used by the 2D straight-edged solve to record wh...
std::array< std::array< NekDouble, kMaxGeomDim >, kMaxGeomDim > m_invIsoParam
Inverse of the linear part of m_iso, for regular elements.
GeometryLocator(Geometry *geom)
virtual NekDouble v_FindDistance(const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi)
static bool ClampLocCoords(Array< OneD, NekDouble > &locCoord, int dim, NekDouble tol=std::numeric_limits< NekDouble >::epsilon())
Clamp local coordinates into the reference element , returning whether anything was clamped....
bool m_hasBoundingBox
Element bounding box as (xmin, ymin, zmin, xmax, ymax, zmax).
std::array< bool, kMaxGeomVerts > m_hasEdgeNormal
virtual int v_AllLeftCheck(const Array< OneD, const NekDouble > &gloCoord, NekDouble &edgeDist)
bool m_newtonConverged
Whether the Newton iteration of the last GetLocCoords call converged, i.e. whether its local coordina...
void GetCoords(NekDouble &x, NekDouble &y, NekDouble &z)
const LibUtilities::BasisSharedPtr & GetBasis(int dir) const
This function gets the shared point to basis in the dir direction.
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
const LibUtilities::PointsKeyVector GetPointsKeys() const
void LocCoordToLocCollapsed(const Array< OneD, const NekDouble > &xi, Array< OneD, NekDouble > &eta)
Convert local cartesian coordinate xi into local collapsed coordinates eta.
const Array< OneD, const NekDouble > & GetPoints(const int dir) const
This function returns a pointer to the array containing the quadrature points in dir direction.
NekDouble PhysEvaluate(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &physvals)
This function evaluates the expansion at a single (arbitrary) point of the domain.
void BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
This function performs the Backward transformation from coefficient space to physical space.
void LocCollapsedToLocCoord(const Array< OneD, const NekDouble > &eta, Array< OneD, NekDouble > &xi)
Convert local collapsed coordinates eta into local cartesian coordinate xi.
void PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1=NullNekDouble1DArray, Array< OneD, NekDouble > &out_d2=NullNekDouble1DArray)
std::vector< PointsKey > PointsKeyVector
@ beta
Gauss Radau pinned at x=-1,.
static const NekDouble kGeomFactorsTol
static const NekDouble kFindDistanceMin
static const unsigned int kNewtonIterations
GeomType
Indicates the type of element geometry.
@ eRegular
Geometry is straight-sided with constant geometric factors.
@ eDeformed
Geometry is curved or has non-constant factors.
std::unique_ptr< GeometryLocator > GeometryLocatorUniquePtr
std::shared_ptr< DNekMat > DNekMatSharedPtr
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
T Dot(int n, const T *w, const T *x)
dot product
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > max(scalarT< T > lhs, scalarT< T > rhs)
scalarT< T > min(scalarT< T > lhs, scalarT< T > rhs)
scalarT< T > sqrt(scalarT< T > in)
std::array< int, kMaxGeomDim > m_manifold
2D only: coordinate directions spanning the manifold.
int m_nCoeff
Coefficients per coordinate direction. Only the leading m_nCoeff entries of each row are meaningful,...
std::array< std::array< NekDouble, kMaxGeomIsoCoeff >, kMaxGeomDim > m_coeff