diff --git a/Geo/GEdgeCompound.cpp b/Geo/GEdgeCompound.cpp
index 8ef28d87726faa6b0a474338ef1415060020979b..642452e7743c84093775985607adee8bf993b561 100644
--- a/Geo/GEdgeCompound.cpp
+++ b/Geo/GEdgeCompound.cpp
@@ -30,48 +30,66 @@ void GEdgeCompound::orderEdges()
   }
   _c.push_back(*(edges.begin())); 
   edges.erase(edges.begin());
-  _orientation.push_back(true);
+  _orientation.push_back(1);
   GVertex *first = _c[0]->getBeginVertex();
   GVertex *last = _c[0]->getEndVertex();  
 
   while (first != last){
     if (edges.empty())break;
+    bool found = false;
     for (std::list<GEdge*>::iterator it = edges.begin() ; it != edges.end() ; ++it){
       GEdge *e = *it;
       //      printf("last %d edge %d %d\n",last->tag(),e->getBeginVertex()->tag(),
-      //	     e->getEndVertex()->tag());
+      //      	     e->getEndVertex()->tag());
       if (e->getBeginVertex() == last){
 	_c.push_back(e); 
 	edges.erase(it);
-	_orientation.push_back(true);
+	_orientation.push_back(1);
 	last = e->getEndVertex();
+	found = true;
 	break;
       }
       else if (e->getEndVertex() == last){
 	_c.push_back(e); 
 	edges.erase(it);
-	_orientation.push_back(false);
+	_orientation.push_back(0);
 	last = e->getBeginVertex();
+	found = true;
 	break;
       }
     }
+    if (!found){
+      if (_c.size() == 1 && _orientation[0]){
+	GVertex *temp = first;
+	first = last;
+	last = temp;
+	_orientation[0] = 0;
+	printf("coucou\n");
+      }
+      else {
+	Msg::Error("Compound Edge %d is wrong",tag());
+	return;
+      }
+    }
   }  
   _compound = _c;
 
   if (_compound.size() < 2)return;
-  if (   _compound[0]->getEndVertex() != _compound[1]->getEndVertex() 
+  if (_orientation[0] && _compound[0]->getEndVertex() != _compound[1]->getEndVertex() 
       && _compound[0]->getEndVertex() != _compound[1]->getBeginVertex()){  
+    //    printf("coucou again\n");
     for (int i=0;i<_compound.size();i++){
       _orientation[i] = !_orientation[i] ;
     }
   }
-//   for (int i=0;i<_compound.size();i++){
-//     printf("o %d e %d (%d,%d)\n",
-// 	   (int)_orientation[i],
-// 	   _compound[i]->tag(),
-// 	   _compound[i]->getBeginVertex()->tag(),
-// 	   _compound[i]->getEndVertex()->tag());
-//   }
+  return;
+   for (int i=0;i<_compound.size();i++){
+     printf("o %d e %d (%d,%d)\n",
+	    (int)_orientation[i],
+	    _compound[i]->tag(),
+	    _compound[i]->getBeginVertex()->tag(),
+	    _compound[i]->getEndVertex()->tag());
+   }
 
 }
 
diff --git a/Geo/GEdgeCompound.h b/Geo/GEdgeCompound.h
index 4f9b1e45489570a41bf77aad7612320bc8cadde2..c0444128d02dd887dc07e7728c40e6ba02f8b1c4 100644
--- a/Geo/GEdgeCompound.h
+++ b/Geo/GEdgeCompound.h
@@ -16,7 +16,7 @@ A GEdgeCompound is a model edge that is the compound of model edges.
 class GEdgeCompound : public GEdge {
  protected:
   std::vector<GEdge*> _compound;
-  std::vector<bool> _orientation;
+  std::vector<int> _orientation;
   std::vector<double> _pars;
   void parametrize() ;
   void orderEdges()  ;
diff --git a/Geo/Makefile b/Geo/Makefile
index fcb2a22ac12dbb1f4c49ebae596c16a6e712d9ac..6a95fa8f791e429823daa36171cada47c3b167d9 100644
--- a/Geo/Makefile
+++ b/Geo/Makefile
@@ -114,9 +114,9 @@ GEdgeCompound${OBJEXT}: GEdgeCompound.cpp ../Common/GmshConfig.h GEdgeCompound.h
   ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Common/GmshMessage.h
 GFaceCompound${OBJEXT}: GFaceCompound.cpp ../Common/GmshConfig.h GFaceCompound.h \
   GFace.h GEntity.h Range.h SPoint3.h SBoundingBox3d.h GPoint.h \
-  GEdgeLoop.h GEdge.h GVertex.h SPoint2.h SVector3.h Pair.h MLine.h \
-  MElement.h ../Common/GmshDefines.h MVertex.h MEdge.h MFace.h \
-  ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
+  GEdgeLoop.h GEdge.h GVertex.h SPoint2.h SVector3.h Pair.h \
+  GEdgeCompound.h MLine.h MElement.h ../Common/GmshDefines.h MVertex.h \
+  MEdge.h MFace.h ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
   ../Numeric/GmshMatrix.h ../Numeric/Gauss.h MTriangle.h \
   ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Common/Octree.h \
   ../Common/OctreeInternals.h ../Numeric/gmshAssembler.h \
@@ -141,8 +141,8 @@ gmshVertex${OBJEXT}: gmshVertex.cpp GFace.h GEntity.h Range.h SPoint3.h \
   ../Numeric/GmshMatrix.h ../Numeric/Gauss.h
 gmshEdge${OBJEXT}: gmshEdge.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h GPoint.h SPoint2.h GEdge.h SVector3.h GFace.h \
-  GEdgeLoop.h Pair.h GRegion.h GFaceCompound.h gmshEdge.h Geo.h \
-  ../Common/GmshDefines.h gmshSurface.h ../Numeric/Numeric.h \
+  GEdgeLoop.h Pair.h GRegion.h GFaceCompound.h GEdgeCompound.h gmshEdge.h \
+  Geo.h ../Common/GmshDefines.h gmshSurface.h ../Numeric/Numeric.h \
   ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Common/GmshMessage.h \
   ../Common/ListUtils.h ../Common/TreeUtils.h ../Common/avl.h \
   ../Common/ListUtils.h ExtrudeParams.h ../Common/SmoothData.h \
@@ -321,8 +321,8 @@ findLinks${OBJEXT}: findLinks.cpp ../Common/GmshMessage.h GModel.h GVertex.h \
   ../Common/avl.h ../Common/ListUtils.h
 MVertex${OBJEXT}: MVertex.cpp MVertex.h SPoint2.h SPoint3.h GVertex.h GEntity.h \
   Range.h SBoundingBox3d.h GPoint.h GEdge.h SVector3.h GFace.h \
-  GEdgeLoop.h Pair.h GFaceCompound.h ../Common/GmshMessage.h \
-  ../Common/StringUtils.h
+  GEdgeLoop.h Pair.h GFaceCompound.h GEdgeCompound.h \
+  ../Common/GmshMessage.h ../Common/StringUtils.h
 MFace${OBJEXT}: MFace.cpp ../Common/GmshConfig.h MFace.h MVertex.h SPoint2.h \
   SPoint3.h MEdge.h SVector3.h ../Numeric/Numeric.h \
   ../Numeric/GmshMatrix.h ../Common/GmshMessage.h ../Common/Context.h \
@@ -364,7 +364,8 @@ MTetrahedron${OBJEXT}: MTetrahedron.cpp MTetrahedron.h MElement.h \
   ../Mesh/qualityMeasures.h ../Mesh/meshGFaceDelaunayInsertion.h \
   ../Geo/MTriangle.h ../Geo/MElement.h \
   ../Mesh/meshGRegionDelaunayInsertion.h ../Geo/MTetrahedron.h \
-  ../Mesh/BackgroundMesh.h ../Mesh/qualityMeasures.h
+  ../Mesh/BackgroundMesh.h ../Geo/STensor3.h ../Geo/SVector3.h \
+  ../Mesh/qualityMeasures.h
 MHexahedron${OBJEXT}: MHexahedron.cpp MHexahedron.h MElement.h \
   ../Common/GmshDefines.h MVertex.h SPoint2.h SPoint3.h MEdge.h \
   SVector3.h MFace.h ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
@@ -388,4 +389,9 @@ CellComplex${OBJEXT}: CellComplex.cpp CellComplex.h ../Common/GmshConfig.h \
   ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h ../Numeric/Gauss.h \
   GModel.h GVertex.h GEntity.h Range.h SBoundingBox3d.h GPoint.h GEdge.h \
   GFace.h GEdgeLoop.h Pair.h GRegion.h
-ChainComplex${OBJEXT}: ChainComplex.cpp ChainComplex.h
+ChainComplex${OBJEXT}: ChainComplex.cpp ChainComplex.h ../Common/GmshConfig.h \
+  MElement.h ../Common/GmshDefines.h MVertex.h SPoint2.h SPoint3.h \
+  MEdge.h SVector3.h MFace.h ../Common/GmshMessage.h \
+  ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h ../Numeric/Gauss.h \
+  GModel.h GVertex.h GEntity.h Range.h SBoundingBox3d.h GPoint.h GEdge.h \
+  GFace.h GEdgeLoop.h Pair.h GRegion.h CellComplex.h
diff --git a/Mesh/BackgroundMesh.cpp b/Mesh/BackgroundMesh.cpp
index 0e58bf9acc9989ff2c6e14c85ad61c5dde2f6152..5cb04d200006b2a8f22ec6f9d502aec77b7d41fe 100644
--- a/Mesh/BackgroundMesh.cpp
+++ b/Mesh/BackgroundMesh.cpp
@@ -180,17 +180,17 @@ SMetric3 BGM_MeshMetric(GEntity *ge,
 			double X, double Y, double Z)
 {
   // default lc (mesh size == size of the model)
-  SMetric3 l1(CTX::instance()->lc);
+  double l1 = CTX::instance()->lc;
 
   // lc from points            
-  SMetric3 l2(MAX_LC);
+  double l2 = MAX_LC;
   if(CTX::instance()->mesh.lcFromPoints && ge->dim() < 2) 
-    l2 = SMetric3(LC_MVertex_PNTS(ge, U, V));
+    l2 = LC_MVertex_PNTS(ge, U, V);
   
   // lc from curvature
-  SMetric3 l3 (MAX_LC);
+  double l3 =MAX_LC;
   if(CTX::instance()->mesh.lcFromCurvature && ge->dim() < 3)
-    l3 = SMetric3(LC_MVertex_CURV(ge, U, V));
+    l3 = LC_MVertex_CURV(ge, U, V);
 
   // lc from fields
   SMetric3 l4 (MAX_LC);
@@ -198,26 +198,28 @@ SMetric3 BGM_MeshMetric(GEntity *ge,
   if(fields->background_field > 0){
     Field *f = fields->get(fields->background_field);
     if(f){
-      //      if (!f->isotropic())
-      //	(*f)(X, Y, Z, ge,l4);
-      //      else
+      if (!f->isotropic())
+	(*f)(X, Y, Z, l4,ge);
+      else
 	l4 = SMetric3((*f)(X, Y, Z, ge));
     }
   }
   
   // take the minimum, then constrain by lcMin and lcMax
-  //  double lc = std::min(std::min(std::min(l1, l2), l3), l4);
+  double lc = std::min(std::min(l1, l2), l3);
 
-  //  lc = std::max(lc, CTX::instance()->mesh.lcMin);
-  //  lc = std::min(lc, CTX::instance()->mesh.lcMax);
+  lc = std::max(lc, CTX::instance()->mesh.lcMin);
+  lc = std::min(lc, CTX::instance()->mesh.lcMax);
 
-  //  if(lc <= 0.){
-  ///    Msg::Error("Wrong characteristic length lc = %g (lcmin = %g, lcmax = %g)",
-  //	       lc, CTX::instance()->mesh.lcMin, CTX::instance()->mesh.lcMax);
-  //    lc = l1;
-  //  }
+  if(lc <= 0.){
+     Msg::Error("Wrong characteristic length lc = %g (lcmin = %g, lcmax = %g)",
+  	       lc, CTX::instance()->mesh.lcMin, CTX::instance()->mesh.lcMax);
+     lc = l1;
+  }
+  SMetric3 LC(lc);
+  return intersection (l4,LC);
 
-//  return lc * CTX::instance()->mesh.lcFactor;
+  //  return lc * CTX::instance()->mesh.lcFactor;
 }
 
 
diff --git a/Mesh/BackgroundMesh.h b/Mesh/BackgroundMesh.h
index da24500e9eef08261d03122db56a37ec64ad39ae..a4d03c3400c65c01aa1409ff10d996927a8aa6bd 100644
--- a/Mesh/BackgroundMesh.h
+++ b/Mesh/BackgroundMesh.h
@@ -5,9 +5,10 @@
 
 #ifndef _BACKGROUND_MESH_H_
 #define _BACKGROUND_MESH_H_
-
+#include "STensor3.h"
 class GEntity;
 double BGM_MeshSize(GEntity *ge, double U, double V, double X, double Y, double Z);
+SMetric3 BGM_MeshMetric(GEntity *ge, double U, double V, double X, double Y, double Z);
 bool Extend1dMeshIn2dSurfaces();
 bool Extend2dMeshIn3dVolumes();
 
diff --git a/Mesh/Makefile b/Mesh/Makefile
index 6c56f66267cd5a0614960b2c97974a8c73f6e83e..ab4622a7c2fbe51f49fcb83edbb75d8bce724d3c 100644
--- a/Mesh/Makefile
+++ b/Mesh/Makefile
@@ -95,8 +95,8 @@ Generator${OBJEXT}: Generator.cpp ../Common/GmshConfig.h ../Common/GmshMessage.h
   ../Geo/MHexahedron.h ../Geo/MElement.h ../Geo/MPrism.h \
   ../Geo/MElement.h ../Geo/MPyramid.h ../Geo/MElement.h meshGEdge.h \
   meshGFace.h meshGFaceBDS.h meshGRegion.h BackgroundMesh.h \
-  BoundaryLayers.h HighOrder.h Generator.h ../Post/PView.h \
-  ../Post/PViewData.h
+  ../Geo/STensor3.h ../Geo/SVector3.h BoundaryLayers.h HighOrder.h \
+  Generator.h ../Post/PView.h ../Post/PViewData.h
 Field${OBJEXT}: Field.cpp ../Common/GmshConfig.h \
   ../contrib/ANN/include/ANN/ANN.h ../Common/Context.h \
   ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h Field.h \
@@ -161,8 +161,9 @@ meshGEdge${OBJEXT}: meshGEdge.cpp ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/MFace.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/SVector3.h \
   ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
   ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Numeric/Gauss.h \
-  BackgroundMesh.h ../Numeric/Numeric.h ../Numeric/GmshMatrix.h \
-  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h
+  BackgroundMesh.h ../Geo/STensor3.h ../Geo/SVector3.h \
+  ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h
 meshGEdgeExtruded${OBJEXT}: meshGEdgeExtruded.cpp ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -186,10 +187,12 @@ meshGFace${OBJEXT}: meshGFace.cpp meshGFace.h meshGFaceBDS.h \
   ../Geo/SVector3.h ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
   ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Numeric/Gauss.h \
   meshGFaceQuadrilateralize.h meshGFaceOptimize.h DivideAndConquer.h \
-  BackgroundMesh.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h \
-  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  BackgroundMesh.h ../Geo/STensor3.h ../Geo/SVector3.h \
+  ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
   ../Geo/GEdgeCompound.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
   ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
   ../Geo/Pair.h ../Geo/GEdge.h ../Geo/GModel.h ../Geo/GVertex.h \
@@ -197,9 +200,8 @@ meshGFace${OBJEXT}: meshGFace.cpp meshGFace.h meshGFaceBDS.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/MLine.h \
   ../Geo/MElement.h ../Geo/MQuadrangle.h ../Geo/MElement.h \
   ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h \
-  ../Numeric/Numeric.h ../Numeric/GmshMatrix.h BDS.h qualityMeasures.h \
-  Field.h ../Geo/STensor3.h ../Geo/SVector3.h ../Post/PView.h \
-  ../Common/OS.h HighOrder.h
+  BDS.h qualityMeasures.h Field.h ../Post/PView.h ../Common/OS.h \
+  HighOrder.h
 meshGFaceTransfinite${OBJEXT}: meshGFaceTransfinite.cpp meshGFace.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -241,33 +243,34 @@ meshGFaceBDS${OBJEXT}: meshGFaceBDS.cpp ../Common/GmshMessage.h \
   ../Geo/MEdge.h ../Geo/SVector3.h ../Numeric/FunctionSpace.h \
   ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Numeric/Gauss.h \
   meshGFaceDelaunayInsertion.h ../Geo/MTriangle.h ../Geo/MElement.h \
-  BackgroundMesh.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h \
-  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h \
-  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h \
-  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Numeric/Numeric.h ../Numeric/GmshMatrix.h \
-  BDS.h qualityMeasures.h Field.h ../Geo/STensor3.h ../Geo/SVector3.h \
-  ../Post/PView.h ../Common/OS.h
+  BackgroundMesh.h ../Geo/STensor3.h ../Geo/SVector3.h \
+  ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h \
+  ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
+  ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h ../Geo/GModel.h \
+  ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h BDS.h \
+  qualityMeasures.h Field.h ../Post/PView.h ../Common/OS.h
 meshGFaceDelaunayInsertion${OBJEXT}: meshGFaceDelaunayInsertion.cpp \
   ../Common/GmshMessage.h ../Numeric/GmshPredicates.h BackgroundMesh.h \
-  meshGFaceDelaunayInsertion.h ../Geo/MTriangle.h ../Geo/MElement.h \
-  ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint2.h \
-  ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/MEdge.h \
+  ../Geo/STensor3.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Numeric/Numeric.h \
+  ../Numeric/GmshMatrix.h meshGFaceDelaunayInsertion.h ../Geo/MTriangle.h \
+  ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \
+  ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/MEdge.h \
   ../Geo/SVector3.h ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h \
-  ../Common/GmshConfig.h ../Numeric/Gauss.h meshGFaceOptimize.h \
-  meshGFace.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/GEntity.h \
-  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Numeric/Numeric.h \
-  ../Numeric/GmshMatrix.h ../Geo/STensor3.h ../Geo/SVector3.h
+  ../Numeric/Gauss.h meshGFaceOptimize.h meshGFace.h ../Geo/GFace.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h
 meshGFaceOptimize${OBJEXT}: meshGFaceOptimize.cpp meshGFaceOptimize.h \
   ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \
   ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h \
@@ -282,7 +285,8 @@ meshGFaceOptimize${OBJEXT}: meshGFaceOptimize.cpp meshGFaceOptimize.h \
   ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h \
   ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/SPoint2.h ../Geo/SVector3.h \
   ../Geo/Pair.h ../Geo/MQuadrangle.h ../Geo/MElement.h BackgroundMesh.h \
-  ../Numeric/Numeric.h ../Numeric/GmshMatrix.h Generator.h
+  ../Geo/STensor3.h ../Geo/SVector3.h ../Numeric/Numeric.h \
+  ../Numeric/GmshMatrix.h Generator.h
 meshGFaceQuadrilateralize${OBJEXT}: meshGFaceQuadrilateralize.cpp \
   meshGFaceQuadrilateralize.h ../Common/GmshMessage.h \
   ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Common/GmshConfig.h \
@@ -306,32 +310,7 @@ meshGRegion${OBJEXT}: meshGRegion.cpp ../Common/GmshConfig.h \
   ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/SVector3.h \
   ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h ../Numeric/Gauss.h \
   ../Numeric/Numeric.h ../Numeric/GmshMatrix.h BackgroundMesh.h \
-  qualityMeasures.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
-  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/gmshRegion.h ../Geo/Geo.h \
-  ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
-  ../Geo/SPoint3.h ../Geo/SVector3.h ../Geo/SBoundingBox3d.h \
-  ../Common/ListUtils.h ../Common/TreeUtils.h ../Common/avl.h \
-  ../Common/ListUtils.h ../Geo/SPoint2.h ../Geo/ExtrudeParams.h \
-  ../Common/SmoothData.h ../Geo/GRegion.h ../Geo/MLine.h \
-  ../Geo/MElement.h ../Geo/MTriangle.h ../Geo/MElement.h \
-  ../Geo/MQuadrangle.h ../Geo/MElement.h BDS.h ../Common/Context.h \
-  ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h
-meshGRegionDelaunayInsertion${OBJEXT}: meshGRegionDelaunayInsertion.cpp \
-  ../Common/GmshMessage.h ../Numeric/GmshPredicates.h ../Common/OS.h \
-  BackgroundMesh.h meshGRegion.h meshGRegionLocalMeshMod.h \
-  meshGRegionDelaunayInsertion.h ../Geo/MTetrahedron.h ../Geo/MElement.h \
-  ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint2.h \
-  ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/SVector3.h ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h \
-  ../Common/GmshConfig.h ../Numeric/Gauss.h ../Numeric/Numeric.h \
-  ../Numeric/GmshMatrix.h qualityMeasures.h ../Geo/GModel.h \
+  ../Geo/STensor3.h ../Geo/SVector3.h qualityMeasures.h ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
   ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
@@ -339,7 +318,32 @@ meshGRegionDelaunayInsertion${OBJEXT}: meshGRegionDelaunayInsertion.cpp \
   ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
   ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h \
   ../Geo/GEntity.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
-  ../Geo/MTriangle.h ../Geo/MElement.h
+  ../Geo/gmshRegion.h ../Geo/Geo.h ../Geo/gmshSurface.h ../Geo/Pair.h \
+  ../Geo/Range.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/SVector3.h \
+  ../Geo/SBoundingBox3d.h ../Common/ListUtils.h ../Common/TreeUtils.h \
+  ../Common/avl.h ../Common/ListUtils.h ../Geo/SPoint2.h \
+  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Geo/GRegion.h \
+  ../Geo/MLine.h ../Geo/MElement.h ../Geo/MTriangle.h ../Geo/MElement.h \
+  ../Geo/MQuadrangle.h ../Geo/MElement.h BDS.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h
+meshGRegionDelaunayInsertion${OBJEXT}: meshGRegionDelaunayInsertion.cpp \
+  ../Common/GmshMessage.h ../Numeric/GmshPredicates.h ../Common/OS.h \
+  BackgroundMesh.h ../Geo/STensor3.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Numeric/Numeric.h \
+  ../Numeric/GmshMatrix.h meshGRegion.h meshGRegionLocalMeshMod.h \
+  meshGRegionDelaunayInsertion.h ../Geo/MTetrahedron.h ../Geo/MElement.h \
+  ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint2.h \
+  ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/SVector3.h \
+  ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h ../Numeric/Gauss.h \
+  qualityMeasures.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
+  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
+  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/MTriangle.h ../Geo/MElement.h
 meshGRegionTransfinite${OBJEXT}: meshGRegionTransfinite.cpp meshGFace.h \
   ../Geo/GFace.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -402,26 +406,26 @@ meshGRegionLocalMeshMod${OBJEXT}: meshGRegionLocalMeshMod.cpp \
   ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
   ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Numeric/Gauss.h \
   ../Numeric/Numeric.h ../Numeric/GmshMatrix.h BackgroundMesh.h \
-  qualityMeasures.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GRegion.h \
-  ../Geo/GEntity.h
+  ../Geo/STensor3.h ../Geo/SVector3.h qualityMeasures.h ../Geo/GEntity.h \
+  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Geo/GRegion.h ../Geo/GEntity.h
 DivideAndConquer${OBJEXT}: DivideAndConquer.cpp ../Common/GmshMessage.h \
   ../Numeric/GmshPredicates.h ../Numeric/Numeric.h \
   ../Numeric/GmshMatrix.h ../Common/GmshConfig.h DivideAndConquer.h \
   ../Common/MallocUtils.h
 BackgroundMesh${OBJEXT}: BackgroundMesh.cpp ../Common/GmshMessage.h \
-  BackgroundMesh.h ../Numeric/Numeric.h ../Numeric/GmshMatrix.h \
-  ../Common/GmshConfig.h ../Common/Context.h ../Geo/CGNSOptions.h \
+  BackgroundMesh.h ../Geo/STensor3.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Numeric/Numeric.h \
+  ../Numeric/GmshMatrix.h ../Common/Context.h ../Geo/CGNSOptions.h \
   ../Mesh/meshPartitionOptions.h ../Geo/GVertex.h ../Geo/GEntity.h \
   ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
   ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
-  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GModel.h ../Geo/GVertex.h \
-  ../Geo/GEdge.h ../Geo/GFace.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h Field.h ../Geo/STensor3.h \
-  ../Geo/SVector3.h ../Post/PView.h
+  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEdge.h \
+  ../Geo/GFace.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h Field.h ../Post/PView.h
 qualityMeasures${OBJEXT}: qualityMeasures.cpp qualityMeasures.h BDS.h \
   ../Common/GmshMessage.h ../Geo/MVertex.h ../Geo/SPoint2.h \
   ../Geo/SPoint3.h ../Geo/MTriangle.h ../Geo/MElement.h \
diff --git a/Mesh/meshGFaceDelaunayInsertion.cpp b/Mesh/meshGFaceDelaunayInsertion.cpp
index 9e85a481606d17d6eeea87c0d96a9262d94bea12..70858d03b9388f347d3362481073b43dbdebc405 100644
--- a/Mesh/meshGFaceDelaunayInsertion.cpp
+++ b/Mesh/meshGFaceDelaunayInsertion.cpp
@@ -332,8 +332,11 @@ double getSurfUV(MTriangle *t, std::vector<double> &Us, std::vector<double> &Vs)
 bool insertVertex(GFace *gf, MVertex *v, double *param , MTri3 *t,
                   std::set<MTri3*, compareTri3Ptr> &allTets,
                   std::set<MTri3*, compareTri3Ptr> *activeTets,
-                  std::vector<double> &vSizes, std::vector<double> &vSizesBGM,
-                  std::vector<double> &Us, std::vector<double> &Vs,
+                  std::vector<double> &vSizes, 
+		  std::vector<double> &vSizesBGM,
+		  std::vector<SMetric3> &vMetricsBGM,
+                  std::vector<double> &Us, 
+		  std::vector<double> &Vs,
                   double *metric = 0)
 {
   std::list<edgeXface> shell;
@@ -481,6 +484,7 @@ static void insertAPoint(GFace *gf,
 			 std::vector<double> &Vs,
 			 std::vector<double> &vSizes, 
 			 std::vector<double> &vSizesBGM,
+			 std::vector<SMetric3> &vMetricsBGM,
 			 std::set<MTri3*,compareTri3Ptr> &AllTris,
 			 std::set<MTri3*,compareTri3Ptr> * ActiveTris = 0,
 			 MTri3 *worst = 0){
@@ -526,12 +530,14 @@ static void insertAPoint(GFace *gf,
     		  uv[1] * vSizes [ptin->tri()->getVertex(2)->getNum()]); 
     // double eigMetricSurface = gf->getMetricEigenvalue(SPoint2(center[0],center[1]));
     double lc = BGM_MeshSize(gf,center[0],center[1],p.x(),p.y(),p.z());
+    SMetric3 metr = BGM_MeshMetric(gf,center[0],center[1],p.x(),p.y(),p.z());
+    vMetricsBGM.push_back(metr);
     vSizesBGM.push_back(lc);
     vSizes.push_back(lc1);
     Us.push_back(center[0]);
     Vs.push_back(center[1]);
     
-    if (!insertVertex(gf, v, center, worst, AllTris,ActiveTris, vSizes, vSizesBGM, 
+    if (!insertVertex(gf, v, center, worst, AllTris,ActiveTris, vSizes, vSizesBGM,vMetricsBGM, 
 		      Us, Vs, metric)) {
       Msg::Debug("2D Delaunay : a cavity is not star shaped");
       AllTris.erase(it);
@@ -563,6 +569,7 @@ void gmshBowyerWatson(GFace *gf)
 {
   std::set<MTri3*,compareTri3Ptr> AllTris;
   std::vector<double> vSizes, vSizesBGM, Us, Vs;
+  std::vector<SMetric3> vMetricsBGM;
 
   buildMeshGenerationDataStructures(gf, AllTris, vSizes, vSizesBGM, Us, Vs);
 
@@ -595,7 +602,7 @@ void gmshBowyerWatson(GFace *gf)
                        Vs[base->getVertex(2)->getNum()]) / 3.};
       buildMetric(gf, pa, metric);
       circumCenterMetric(worst->tri(), metric, Us, Vs, center, r2);       
-      insertAPoint(gf, AllTris.begin(), center, metric, Us, Vs, vSizes, vSizesBGM, 
+      insertAPoint(gf, AllTris.begin(), center, metric, Us, Vs, vSizes, vSizesBGM, vMetricsBGM,
                    AllTris);
     }
     //     if(ITER % 10== 0){
@@ -666,6 +673,7 @@ void gmshBowyerWatsonFrontal(GFace *gf)
   std::set<MTri3*,compareTri3Ptr> AllTris;
   std::set<MTri3*,compareTri3Ptr> ActiveTris;
   std::vector<double> vSizes, vSizesBGM, Us, Vs;
+  std::vector<SMetric3> vMetricsBGM;
 
   testTensor();
 
@@ -746,7 +754,7 @@ void gmshBowyerWatsonFrontal(GFace *gf)
       const double d = (rhoM_hat + sqrt (rhoM_hat * rhoM_hat - p * p)) / RATIO;
       
       double newPoint[2] = {midpoint[0] + d * dir[0], midpoint[1] + d * dir[1]};
-      insertAPoint(gf, AllTris.end(), newPoint, metric, Us, Vs, vSizes, vSizesBGM,
+      insertAPoint(gf, AllTris.end(), newPoint, metric, Us, Vs, vSizes, vSizesBGM, vMetricsBGM,
                    AllTris, &ActiveTris, worst);
     } 
 //     if(ITER % 1000== 0){
diff --git a/Numeric/gmshLinearSystem.h b/Numeric/gmshLinearSystem.h
index 106e4f1f8f5f1d761d0c6755847eada1f0c81f93..4a288a1befb2a90f6a7c5b813b99cf1ad77fcf7a 100644
--- a/Numeric/gmshLinearSystem.h
+++ b/Numeric/gmshLinearSystem.h
@@ -15,7 +15,6 @@ class gmshLinearSystem {
   gmshLinearSystem (){}
   virtual bool isAllocated() const = 0;
   virtual void allocate(int nbRows) = 0;
-  virtual ~gmshLinearSystem() {}
   virtual void addToMatrix(int _row, int _col, scalar val) = 0;
   virtual scalar getFromMatrix(int _row, int _col) const = 0;
   virtual void addToRightHandSide(int _row, scalar val) = 0;