From dff9323bdee682aeae9b4a8712f8777e3ac35b17 Mon Sep 17 00:00:00 2001
From: Matti Pellika <matti.pellikka@tut.fi>
Date: Tue, 22 Mar 2011 13:41:30 +0000
Subject: [PATCH] Copied getNode function from Post/shapeFunctions.h to 1st
 order MElements.

---
 Geo/MElement.h     |  7 +++++++
 Geo/MHexahedron.h  | 14 ++++++++++++++
 Geo/MLine.h        |  9 +++++++++
 Geo/MPoint.h       |  4 ++++
 Geo/MPrism.h       | 12 ++++++++++++
 Geo/MPyramid.h     | 11 +++++++++++
 Geo/MQuadrangle.h  | 11 +++++++++++
 Geo/MTetrahedron.h | 10 ++++++++++
 Geo/MTriangle.h    | 10 ++++++++++
 9 files changed, 88 insertions(+)

diff --git a/Geo/MElement.h b/Geo/MElement.h
index 22133a09f4..0ef83ff584 100644
--- a/Geo/MElement.h
+++ b/Geo/MElement.h
@@ -224,6 +224,13 @@ class MElement
   // get the function space for the jacobian of the element
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const { return 0; }
 
+  // return parametric coordinates (u, v, w) of a vertex
+  virtual void getNode(int num, double &u, double &v, double &w)
+  {
+    u = v = w = 0.;
+    Msg::Error("Node get not available for this element");
+  }
+
   // return the interpolating nodal shape functions evaluated at point
   // (u,v,w) in parametric coordinates (if order == -1, use the
   // polynomial order of the element)
diff --git a/Geo/MHexahedron.h b/Geo/MHexahedron.h
index 118e3c7509..6b6a33f415 100644
--- a/Geo/MHexahedron.h
+++ b/Geo/MHexahedron.h
@@ -166,6 +166,20 @@ class MHexahedron : public MElement {
     s[7][1] =  0.125 * (1. - u) * (1. + w);
     s[7][2] =  0.125 * (1. - u) * (1. + v);
   }
+  void getNode(int num, double &u, double &v, double &w)
+  {
+    switch(num) {
+    case 0 : u = -1.; v = -1.; w = -1.; break;
+    case 1 : u =  1.; v = -1.; w = -1.; break;
+    case 2 : u =  1.; v =  1.; w = -1.; break;
+    case 3 : u = -1.; v =  1.; w = -1.; break;
+    case 4 : u = -1.; v = -1.; w =  1.; break;
+    case 5 : u =  1.; v = -1.; w =  1.; break;
+    case 6 : u =  1.; v =  1.; w =  1.; break;
+    case 7 : u = -1.; v =  1.; w =  1.; break;
+    default: u =  0.; v =  0.; w =  0.; break;
+    }
+  }
   virtual bool isInside(double u, double v, double w)
   {
     double tol = _isInsideTolerance;
diff --git a/Geo/MLine.h b/Geo/MLine.h
index d9dfa89a42..b8b8b63d44 100644
--- a/Geo/MLine.h
+++ b/Geo/MLine.h
@@ -78,6 +78,15 @@ class MLine : public MElement {
       return false;
     return true;
   }
+  void getNode(int num, double &u, double &v, double &w)
+  {
+    v = w = 0.;
+    switch(num) {
+    case 0 : u = -1.; break;
+    case 1 : u =  1.; break;
+    default: u =  0.; break;
+    }
+  }
   virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts);
   static void registerBindings(binding *b);
 };
diff --git a/Geo/MPoint.h b/Geo/MPoint.h
index e81eaa95fb..c172208798 100644
--- a/Geo/MPoint.h
+++ b/Geo/MPoint.h
@@ -42,6 +42,10 @@ class MPoint : public MElement {
   virtual int getTypeForMSH() const { return MSH_PNT; }
   virtual int getTypeForVTK() const { return 1; }
   virtual const char *getStringForPOS() const { return "SP"; }
+  void getNode(int num, double &u, double &v, double &w)
+  {
+    u = v = w = 0.;
+  }
   virtual void getShapeFunctions(double u, double v, double w, double s[], int o)
   {
     s[0] = 1.;
diff --git a/Geo/MPrism.h b/Geo/MPrism.h
index 4b3713ee09..7f1d4a8e8a 100644
--- a/Geo/MPrism.h
+++ b/Geo/MPrism.h
@@ -165,6 +165,18 @@ class MPrism : public MElement {
     s[5][1] =  0.5 * (1. + w)    ;
     s[5][2] =  0.5 * v           ;
   }*/
+  void getNode(int num, double &u, double &v, double &w)
+  {
+    switch(num) {
+    case 0 : u = 0.; v = 0.; w = -1.; break;
+    case 1 : u = 1.; v = 0.; w = -1.; break;
+    case 2 : u = 0.; v = 1.; w = -1.; break;
+    case 3 : u = 0.; v = 0.; w =  1.; break;
+    case 4 : u = 1.; v = 0.; w =  1.; break;
+    case 5 : u = 0.; v = 1.; w =  1.; break;
+    default: u = 0.; v = 0.; w =  0.; break;
+    }
+  }
   virtual bool isInside(double u, double v, double w)
   {
     double tol = _isInsideTolerance;
diff --git a/Geo/MPyramid.h b/Geo/MPyramid.h
index b955baad16..bd63e67f45 100644
--- a/Geo/MPyramid.h
+++ b/Geo/MPyramid.h
@@ -170,6 +170,17 @@ class MPyramid : public MElement {
     s[4][1] = 0.;
     s[4][2] = 1.;
   }
+  void getNode(int num, double &u, double &v, double &w)
+  {
+    switch(num) {
+    case 0 : u = -1.; v = -1.; w = 0.; break;
+    case 1 : u =  1.; v = -1.; w = 0.; break;
+    case 2 : u =  1.; v =  1.; w = 0.; break;
+    case 3 : u = -1.; v =  1.; w = 0.; break;
+    case 4 : u =  0.; v =  0.; w = 1.; break;
+    default: u =  0.; v =  0.; w = 0.; break;
+    }
+  }
   virtual bool isInside(double u, double v, double w)
   {
     double tol = _isInsideTolerance;
diff --git a/Geo/MQuadrangle.h b/Geo/MQuadrangle.h
index 8de5e45fcb..adb67da138 100644
--- a/Geo/MQuadrangle.h
+++ b/Geo/MQuadrangle.h
@@ -123,6 +123,17 @@ void projectInMeanPlane(double *xn, double *yn);
   virtual const char *getStringForINP() const { return "C2D4"; }
   virtual const polynomialBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
+  void getNode(int num, double &u, double &v, double &w)
+  {
+    w = 0.;
+    switch(num) {
+    case 0 : u = -1.; v = -1.; break;
+    case 1 : u =  1.; v = -1.; break;
+    case 2 : u =  1.; v =  1.; break;
+    case 3 : u = -1.; v =  1.; break;
+    default: u =  0.; v =  0.; break;
+    }
+  }
   virtual void revert()
   {
     MVertex *tmp = _v[1]; _v[1] = _v[3]; _v[3] = tmp;
diff --git a/Geo/MTetrahedron.h b/Geo/MTetrahedron.h
index 10c6f8df36..599e44163b 100644
--- a/Geo/MTetrahedron.h
+++ b/Geo/MTetrahedron.h
@@ -135,6 +135,16 @@ class MTetrahedron : public MElement {
   void xyz2uvw(double xyz[3], double uvw[3]);
   virtual const polynomialBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
+  void getNode(int num, double &u, double &v, double &w)
+  {
+    switch(num) {
+    case 0 : u = 0.; v = 0.; w = 0.; break;
+    case 1 : u = 1.; v = 0.; w = 0.; break;
+    case 2 : u = 0.; v = 1.; w = 0.; break;
+    case 3 : u = 0.; v = 0.; w = 1.; break;
+    default: u = 0.; v = 0.; w = 0.; break;
+    }
+  }
   virtual bool isInside(double u, double v, double w)
   {
     double tol = _isInsideTolerance;
diff --git a/Geo/MTriangle.h b/Geo/MTriangle.h
index f749d2933e..4dc273298a 100644
--- a/Geo/MTriangle.h
+++ b/Geo/MTriangle.h
@@ -130,6 +130,16 @@ class MTriangle : public MElement {
   }
   virtual const polynomialBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
+  void getNode(int num, double &u, double &v, double &w)
+  {
+    w = 0.;
+    switch(num) {
+    case 0 : u = 0.; v = 0.; break;
+    case 1 : u = 1.; v = 0.; break;
+    case 2 : u = 0.; v = 1.; break;
+    default: u = 0.; v = 0.; break;
+    }
+  }
   virtual bool isInside(double u, double v, double w)
   {
     double tol = _isInsideTolerance;
-- 
GitLab