int InverseElementTransformation::FindClosestRefPoint( const Vector& pt, const IntegrationRule &ir) { MFEM_VERIFY(T != NULL, "invalid ElementTransformation"); MFEM_VERIFY(pt.Size() == T->GetSpaceDim(), "invalid point"); // Initialize distance and index of closest point int minIndex = -1; double minDist = std::numeric_limits<double>::max(); // Check all integration points in ir using the local metric at each point // induced by the transformation. Vector dp(T->GetSpaceDim()), dr(T->GetDimension()); const int npts = ir.GetNPoints(); for (int i = 0; i < npts; ++i) { const IntegrationPoint &ip = ir.IntPoint(i); T->Transform(ip, dp); dp -= pt; T->SetIntPoint(&ip); T->InverseJacobian().Mult(dp, dr); double dist = dr.Norml2(); // double dist = dr.Normlinf(); if (dist < minDist) { minDist = dist; minIndex = i; } } return minIndex; }
void IsoparametricTransformation::Transform (const IntegrationRule &ir, DenseMatrix &tr) { int dof, n, dim, i, j, k; dim = PointMat.Height(); dof = FElem->GetDof(); n = ir.GetNPoints(); shape.SetSize(dof); tr.SetSize(dim, n); for (j = 0; j < n; j++) { FElem -> CalcShape (ir.IntPoint(j), shape); for (i = 0; i < dim; i++) { tr(i, j) = 0.0; for (k = 0; k < dof; k++) { tr(i, j) += PointMat(i, k) * shape(k); } } } }
int InverseElementTransformation::FindClosestPhysPoint( const Vector& pt, const IntegrationRule &ir) { MFEM_VERIFY(T != NULL, "invalid ElementTransformation"); MFEM_VERIFY(pt.Size() == T->GetSpaceDim(), "invalid point"); DenseMatrix physPts; T->Transform(ir, physPts); // Initialize distance and index of closest point int minIndex = -1; double minDist = std::numeric_limits<double>::max(); // Check all integration points in ir const int npts = ir.GetNPoints(); for (int i = 0; i < npts; ++i) { double dist = pt.DistanceTo(physPts.GetColumn(i)); if (dist < minDist) { minDist = dist; minIndex = i; } } return minIndex; }
void IntegrationPointTransformation::Transform (const IntegrationRule &ir1, IntegrationRule &ir2) { int i, n; n = ir1.GetNPoints(); for (i = 0; i < n; i++) { Transform (ir1.IntPoint(i), ir2.IntPoint(i)); } }