int GaussLegendreTet(int n1, int n2, int n3, IntPt *pts) 
{
  /* get degenerate n1Xn2Xn3 Gauss-Legendre scheme to integrate over a tet */
  int i,j,k,index=0;
  double *pt1,*pt2,*pt3,*wt1,*wt2,*wt3,dJ;

  gmshGaussLegendre1D(n1,&pt1,&wt1);
  gmshGaussLegendre1D(n2,&pt2,&wt2);
  gmshGaussLegendre1D(n3,&pt3,&wt3);
  for(i=0; i < n1; i++) {
    for(j=0; j < n2; j++) {
      for(k=0; k < n3; k++) {
        brickToTet(pt1[i],pt2[j],pt3[k],&(pts[index].pt[0]),
                   &(pts[index].pt[1]),&(pts[index].pt[2]),&dJ);
        pts[index++].weight = dJ*wt1[i]*wt2[j]*wt3[k];
      }
    }
  }
  return index;
}
int GaussLegendreTet(int n1,int n2,int n3,double GLrstw[][4],double *GLwt) {
  /* get degenerate n1Xn2Xn3 Gauss-Legendre scheme to integrate over a tet */
  int i,j,k,index=0;
  double *pt1,*pt2,*pt3,*wt1,*wt2,*wt3,dJ;
  const double six=6.000000000000000;

  GaussLegendre1D(n1,&pt1,&wt1);
  GaussLegendre1D(n2,&pt2,&wt2);
  GaussLegendre1D(n3,&pt3,&wt3);
  for(i=0; i < n1; i++) {
    for(j=0; j < n2; j++) {
      for(k=0; k < n3; k++) {
        brickToTet(pt1[i],pt2[j],pt3[k],&GLrstw[index][0],
                   &GLrstw[index][1],&GLrstw[index][2],&dJ);
        GLrstw[index][3] = 1.0e0-GLrstw[index][0]-GLrstw[index][1]
                                -GLrstw[index][2];
        GLwt[index++] = dJ*wt1[i]*wt2[j]*wt3[k]*six;
      }
    }
  }
  return index;
}