From e2fdd6583be9484a745cd7b76fa57f1548397996 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 18 Oct 2010 06:07:12 +0000 Subject: [PATCH] *** empty log message *** --- src/INTERP_KERNEL/InterpKernelMeshQuality.cxx | 209 ++++++++++++++++++ src/INTERP_KERNEL/InterpKernelMeshQuality.hxx | 37 ++++ src/INTERP_KERNEL/Makefile.am | 4 +- 3 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 src/INTERP_KERNEL/InterpKernelMeshQuality.cxx create mode 100644 src/INTERP_KERNEL/InterpKernelMeshQuality.hxx diff --git a/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx b/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx new file mode 100644 index 000000000..b7f4fbf9d --- /dev/null +++ b/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx @@ -0,0 +1,209 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "InterpKernelMeshQuality.hxx" + +#include +#include +#include +#include + +double INTERP_KERNEL::quadSkew(const double *coo) +{ + double pa0[3]={ + coo[3]+coo[6]-coo[0]-coo[9], + coo[4]+coo[7]-coo[1]-coo[10], + coo[5]+coo[8]-coo[2]-coo[11] + }; + double pa1[3]={ + coo[6]+coo[9]-coo[0]-coo[3], + coo[7]+coo[10]-coo[1]-coo[4], + coo[8]+coo[11]-coo[2]-coo[5], + }; + double l0=sqrt(pa0[0]*pa0[0]+pa0[1]*pa0[1]+pa0[2]*pa0[2]); + double l1=sqrt(pa1[0]*pa1[0]+pa1[1]*pa1[1]+pa1[2]*pa1[2]); + if(l0<1.e-15) + return 0.; + if(l1<1.e-15) + return 0.; + pa0[0]/=l0; pa0[1]/=l0; pa0[2]/=l0; + pa1[0]/=l1; pa1[1]/=l1; pa1[2]/=l1; + return pa0[0]*pa1[0]+pa0[1]*pa1[1]+pa0[2]*pa1[2]; +} + +double INTERP_KERNEL::quadEdgeRatio(const double *coo) +{ + double a2=(coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2]); + double b2=(coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5]); + double c2=(coo[9]-coo[6])*(coo[9]-coo[6])+(coo[10]-coo[7])*(coo[10]-coo[7])+(coo[11]-coo[8])*(coo[11]-coo[8]); + double d2=(coo[0]-coo[9])*(coo[0]-coo[9])+(coo[1]-coo[10])*(coo[1]-coo[10])+(coo[2]-coo[11])*(coo[2]-coo[11]); + double mab=a2Mcd?Mab:Mcd; + if(m2>1.e-15) + return sqrt(M2/m2); + else + return std::numeric_limits::max(); +} + +double INTERP_KERNEL::quadAspectRatio(const double *coo) +{ + double a=sqrt((coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2])); + double b=sqrt((coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5])); + double c=sqrt((coo[9]-coo[6])*(coo[9]-coo[6])+(coo[10]-coo[7])*(coo[10]-coo[7])+(coo[11]-coo[8])*(coo[11]-coo[8])); + double d=sqrt((coo[0]-coo[9])*(coo[0]-coo[9])+(coo[1]-coo[10])*(coo[1]-coo[10])+(coo[2]-coo[11])*(coo[2]-coo[11])); + double ma=a>b?a:b; + double mb=c>d?c:d; + double hm=ma>mb?ma:mb; + double ab[3]={(coo[4]-coo[1])*(coo[8]-coo[5])-(coo[7]-coo[4])*(coo[5]-coo[2]), + (coo[5]-coo[2])*(coo[6]-coo[3])-(coo[3]-coo[0])*(coo[8]-coo[5]), + (coo[3]-coo[0])*(coo[7]-coo[4])-(coo[4]-coo[1])*(coo[6]-coo[3])}; + double cd[3]={(coo[10]-coo[7])*(coo[2]-coo[11])-(coo[1]-coo[10])*(coo[11]-coo[8]), + (coo[11]-coo[8])*(coo[0]-coo[9])-(coo[9]-coo[6])*(coo[2]-coo[11]), + (coo[9]-coo[6])*(coo[1]-coo[10])-(coo[10]-coo[7])*(coo[0]-coo[9])}; + double e=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2])+sqrt(cd[0]*cd[0]+cd[1]*cd[1]+cd[2]*cd[2]); + if(d>1e-15) + return 0.5*(a+b+c+d)*hm/e; + else + return std::numeric_limits::max(); +} + +double quadWarp(const double *coo) +{ + double e0[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; + double e1[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; + double e2[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; + double e3[3]={coo[0]-coo[9],coo[1]-coo[10],coo[2]-coo[11]}; + + double n0[3]={e3[1]*e0[2]-e3[2]*e0[1],e3[2]*e0[0]-e3[0]*e0[2],e3[0]*e0[1]-e3[1]*e0[0]}; + double n1[3]={e0[1]*e1[2]-e0[2]*e1[1],e0[2]*e1[0]-e0[0]*e1[2],e0[0]*e1[1]-e0[1]*e1[0]}; + double n2[3]={e1[1]*e2[2]-e1[2]*e2[1],e1[2]*e2[0]-e1[0]*e2[2],e1[0]*e2[1]-e1[1]*e2[0]}; + double n3[3]={e2[1]*e3[2]-e2[2]*e3[1],e2[2]*e3[0]-e2[0]*e3[2],e2[0]*e3[1]-e2[1]*e3[0]}; + + double l0=sqrt(n0[0]*n0[0]+n0[1]*n0[1]+n0[2]*n0[2]); + double l1=sqrt(n1[0]*n1[0]+n1[1]*n1[1]+n1[2]*n1[2]); + double l2=sqrt(n2[0]*n2[0]+n2[1]*n2[1]+n2[2]*n2[2]); + double l3=sqrt(n3[0]*n3[0]+n3[1]*n3[1]+n3[2]*n3[2]); + + if(l0<1.e-15 || l1<1.e-15 || l2<1.e-15 || l3<1e-15) + return std::numeric_limits::min(); + + double warp=std::min(n0[0]/l0*n2[0]/l2+n0[1]/l0*n2[1]/l2+n0[2]/l0*n2[2]/l2,n1[0]/l1*n3[0]/l3+n1[1]/l1*n3[1]/l3+n1[2]/l1*n3[2]/l3); + return warp*warp*warp; +} + +double INTERP_KERNEL::triEdgeRatio(const double *coo) +{ + double a2=(coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2]); + double b2=(coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5]); + double c2=(coo[0]-coo[6])*(coo[0]-coo[6])+(coo[1]-coo[7])*(coo[1]-coo[7])+(coo[2]-coo[8])*(coo[2]-coo[8]); + double mab=a2mab?mab:c2; + double M2=c2>Mab?c2:Mab; + if(m2>1.e-15) + return sqrt(M2/m2); + else + return std::numeric_limits::max(); +} + +double INTERP_KERNEL::triAspectRatio(const double *coo) +{ + double a=sqrt((coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2])); + double b=sqrt((coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5])); + double c=sqrt((coo[0]-coo[6])*(coo[0]-coo[6])+(coo[1]-coo[7])*(coo[1]-coo[7])+(coo[2]-coo[8])*(coo[2]-coo[8])); + + double hm=a>b?a:b; + hm=hm>c?hm:c; + + double ab[3]={(coo[4]-coo[1])*(coo[8]-coo[5])-(coo[7]-coo[4])*(coo[5]-coo[2]), + (coo[5]-coo[2])*(coo[6]-coo[3])-(coo[3]-coo[0])*(coo[8]-coo[5]), + (coo[3]-coo[0])*(coo[7]-coo[4])-(coo[4]-coo[1])*(coo[6]-coo[3])}; + double d=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]); + static const double normalizeCoeff=sqrt(3.)/6.; + if(d>1.e-15) + return normalizeCoeff*hm*(a+b+c)/d; + else + return std::numeric_limits::max(); +} + +double INTERP_KERNEL::tetraEdgeRatio(const double *coo) +{ + double a[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; + double b[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; + double c[3]={coo[0]-coo[6],coo[1]-coo[7],coo[2]-coo[8]}; + double d[3]={coo[9]-coo[0],coo[10]-coo[1],coo[11]-coo[2]}; + double e[3]={coo[9]-coo[3],coo[10]-coo[4],coo[11]-coo[5]}; + double f[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; + + double l2[6]= + {a[0]*a[0]+a[1]*a[1]+a[2]*a[2], + b[0]*b[0]+b[1]*b[1]+b[2]*b[2], + c[0]*c[0]+c[1]*c[1]+c[2]*c[2], + d[0]*d[0]+d[1]*d[1]+d[2]*d[2], + e[0]*e[0]+e[1]*e[1]+e[2]*e[2], + f[0]*f[0]+f[1]*f[1]+f[2]*f[2]}; + + double M2=*std::max_element(l2,l2+6); + double m2=*std::min_element(l2,l2+6); + if(m2>1e-15) + return sqrt(M2/m2); + else + return std::numeric_limits::max(); +} + +double INTERP_KERNEL::tetraAspectRatio(const double *coo) +{ + static const double normalizeCoeff=sqrt(6.)/12.; + double ab[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; + double ac[3]={coo[6]-coo[0],coo[7]-coo[1],coo[8]-coo[2]}; + double ad[3]={coo[9]-coo[0],coo[10]-coo[1],coo[11]-coo[2]}; + double detTet=(ab[0]*(ac[1]*ad[2]-ac[2]*ad[1]))+(ab[1]*(ac[2]*ad[0]-ac[0]*ad[2]))+(ab[2]*(ac[0]*ad[1]-ac[1]*ad[2])); + if(detTet<1.e-15) + return std::numeric_limits::max(); + double bc[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; + double bd[3]={coo[9]-coo[3],coo[10]-coo[4],coo[11]-coo[5]}; + double cd[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; + + double ab2=ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]; + double bc2=bc[0]*bc[0]+bc[1]*bc[1]+bc[2]*bc[2]; + double ac2=ac[0]*ac[0]+ac[1]*ac[1]+ac[2]*ac[2]; + double ad2=ad[0]*ad[0]+ad[1]*ad[1]+ad[2]*ad[2]; + double bd2=bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]; + double cd2=cd[0]*cd[0]+cd[1]*cd[1]+cd[2]*cd[2]; + + double A=ab2>bc2?ab2:bc2; + double B=ac2>ad2?ac2:ad2; + double C=bd2>cd2?bd2:cd2; + double D=A>B?A:B; + double hm=D>C?sqrt(D):sqrt(C); + + bd[0]=ab[1]*bc[2]-ab[2]*bc[1]; bd[1]=ab[2]*bc[0]-ab[0]*bc[2]; bd[2]=ab[0]*bc[1]-ab[1]*bc[0]; + A=sqrt(bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]); + bd[0]=ab[1]*ad[2]-ab[2]*ad[1]; bd[1]=ab[2]*ad[0]-ab[0]*ad[2]; bd[2]=ab[0]*ad[1]-ab[1]*ad[0]; + B=sqrt(bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]); + bd[0]=ac[1]*ad[2]-ac[2]*ad[1]; bd[1]=ac[2]*ad[0]-ac[0]*ad[2]; bd[2]=ac[0]*ad[1]-ac[1]*ad[0]; + C=sqrt(bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]); + bd[0]=bc[1]*cd[2]-bc[2]*cd[1]; bd[1]=bc[2]*cd[0]-bc[0]*cd[2]; bd[2]=bc[0]*cd[1]-bc[1]*cd[0]; + D=sqrt(bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]); + return normalizeCoeff*hm*(A+B+C+D)/fabs(detTet); +} diff --git a/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx b/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx new file mode 100644 index 000000000..2f11bb4d1 --- /dev/null +++ b/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __INTERPKERNELMESHQUALITY_HXX_ +#define __INTERPKERNELMESHQUALITY_HXX__ + +#include "INTERPKERNELDefines.hxx" + +namespace INTERP_KERNEL +{ + INTERPKERNEL_EXPORT double quadSkew(const double *coo); + INTERPKERNEL_EXPORT double quadEdgeRatio(const double *coo); + INTERPKERNEL_EXPORT double quadAspectRatio(const double *coo); + INTERPKERNEL_EXPORT double quadWarp(const double *coo); + INTERPKERNEL_EXPORT double triEdgeRatio(const double *coo); + INTERPKERNEL_EXPORT double triAspectRatio(const double *coo); + INTERPKERNEL_EXPORT double tetraEdgeRatio(const double *coo); + INTERPKERNEL_EXPORT double tetraAspectRatio(const double *coo); +} + +#endif diff --git a/src/INTERP_KERNEL/Makefile.am b/src/INTERP_KERNEL/Makefile.am index afbe7285d..e3dfc56cb 100644 --- a/src/INTERP_KERNEL/Makefile.am +++ b/src/INTERP_KERNEL/Makefile.am @@ -43,6 +43,7 @@ PointLocator2DIntersector.hxx \ PointLocator2DIntersector.txx \ INTERPKERNELDefines.hxx \ InterpKernelMatrix.hxx \ +InterpKernelMeshQuality.hxx \ Interpolation.hxx \ Interpolation.txx \ Interpolation2D.hxx \ @@ -187,7 +188,8 @@ dist_libinterpkernel_la_SOURCES = \ CellModel.cxx \ UnitTetraIntersectionBary.cxx \ InterpolationOptions.cxx \ - DirectedBoundingBox.cxx + DirectedBoundingBox.cxx \ + InterpKernelMeshQuality.cxx libinterpkernel_la_CPPFLAGS=-I$(srcdir)/Geometric2D -I$(srcdir)/Bases -- 2.39.2