Ejemplo n.º 1
0
double taylorDistanceSq1D(const GradientBasis *gb, const fullMatrix<double> &nodesXYZ,
                          const std::vector<SVector3> &tanCAD)
{
  const int nV = nodesXYZ.size1();
  fullMatrix<double> dxyzdX(nV, 3);
  gb->getGradientsFromNodes(nodesXYZ, &dxyzdX, 0, 0);
//  const double dx = nodesXYZ(1, 0) - nodesXYZ(0, 0), dy = nodesXYZ(1, 1) - nodesXYZ(0, 1),
//               dz = nodesXYZ(1, 2) - nodesXYZ(0, 2), h = 0.5*sqrt(dx*dx+dy*dy+dz*dz)/double(nV-1);
  double distSq = 0.;
  for (int i=0; i<nV; i++) {
    SVector3 tanMesh(dxyzdX(i, 0), dxyzdX(i, 1), dxyzdX(i, 2));
    const double h = 0.25*tanMesh.normalize();                                            // Half of "local edge length"
    SVector3 diff = (dot(tanCAD[i], tanMesh) > 0) ?
                    tanCAD[i] - tanMesh : tanCAD[i] + tanMesh;
    distSq += h*h*diff.normSq();
  }
  return distSq;
}
Ejemplo n.º 2
0
double taylorDistanceSq2D(const GradientBasis *gb, const fullMatrix<double> &nodesXYZ,
                          const std::vector<SVector3> &normCAD)
{
  const int nV = nodesXYZ.size1();
  fullMatrix<double> dxyzdX(nV, 3), dxyzdY(nV, 3);
  gb->getGradientsFromNodes(nodesXYZ, &dxyzdX, &dxyzdY, 0);
  double distSq = 0.;
  for (int i=0; i<nV; i++) {
    const double nz = dxyzdX(i, 0) * dxyzdY(i, 1) - dxyzdX(i, 1) * dxyzdY(i, 0);
    const double ny = -dxyzdX(i, 0) * dxyzdY(i, 2) + dxyzdX(i, 2) * dxyzdY(i, 0);
    const double nx = dxyzdX(i, 1) * dxyzdY(i, 2) - dxyzdX(i, 2) * dxyzdY(i, 1);
    SVector3 normMesh(nx, ny, nz);
    const double h = 0.25*sqrt(normMesh.normalize());                                     // Half of sqrt of "local area", to be adjusted w.r.t. el. type?
    SVector3 diff = (dot(normCAD[i], normMesh) > 0) ?
                    normCAD[i] - normMesh : normCAD[i] + normMesh;
    distSq += h*h*diff.normSq();
  }
  return distSq;
}