From 116d9d3811546bd09de82acc5dfd039306e105fe Mon Sep 17 00:00:00 2001
From: Thomas Toulorge <thomas.toulorge@mines-paristech.fr>
Date: Tue, 11 Feb 2014 18:11:10 +0000
Subject: [PATCH] Changed getFunctionSpace in MElement and derived classes to
 allow returning Serendip bases

---
 Geo/MElement.cpp     |  7 +++++++
 Geo/MElement.h       |  2 +-
 Geo/MElementCut.h    | 12 ++++++------
 Geo/MHexahedron.cpp  |  8 --------
 Geo/MHexahedron.h    |  1 -
 Geo/MLine.cpp        |  8 --------
 Geo/MLine.h          |  1 -
 Geo/MPoint.h         |  4 ----
 Geo/MPrism.cpp       |  8 --------
 Geo/MPrism.h         |  1 -
 Geo/MPyramid.cpp     |  8 --------
 Geo/MPyramid.h       |  1 -
 Geo/MQuadrangle.cpp  |  8 --------
 Geo/MQuadrangle.h    |  1 -
 Geo/MSubElement.cpp  | 16 ++++++++--------
 Geo/MSubElement.h    |  8 ++++----
 Geo/MTetrahedron.cpp |  8 --------
 Geo/MTetrahedron.h   |  1 -
 Geo/MTriangle.cpp    |  8 --------
 Geo/MTriangle.h      |  1 -
 20 files changed, 26 insertions(+), 86 deletions(-)

diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp
index adcd2ec447..f277c07b45 100644
--- a/Geo/MElement.cpp
+++ b/Geo/MElement.cpp
@@ -309,6 +309,13 @@ std::string MElement::getInfoString()
   return std::string(tmp);
 }
 
+const nodalBasis* MElement::getFunctionSpace(int order, bool serendip) const
+{
+  if (order == -1) return BasisFactory::getNodalBasis(getTypeForMSH());
+  int tag = ElementType::getTag(getType(), order, serendip);
+  return tag ? BasisFactory::getNodalBasis(tag) : NULL;
+}
+
 static double _computeDeterminantAndRegularize(const MElement *ele, double jac[3][3])
 {
   double dJ = 0;
diff --git a/Geo/MElement.h b/Geo/MElement.h
index 99637b1b48..7df20c6ae0 100644
--- a/Geo/MElement.h
+++ b/Geo/MElement.h
@@ -225,7 +225,7 @@ class MElement
   virtual std::string getInfoString();
 
   // get the function space for the element
-  virtual const nodalBasis* getFunctionSpace(int order=-1) const { return 0; }
+  virtual const nodalBasis* getFunctionSpace(int order=-1, bool serendip=false) const;
 
   // get the function space for the jacobian of the element
   virtual const JacobianBasis* getJacobianFuncSpace(int order=-1) const { return 0; }
diff --git a/Geo/MElementCut.h b/Geo/MElementCut.h
index f1a011cb74..a8229ea021 100644
--- a/Geo/MElementCut.h
+++ b/Geo/MElementCut.h
@@ -121,9 +121,9 @@ class MPolyhedron : public MElement {
       vol += _parts[i]->getVolume();
     return vol;
   }
-  virtual const nodalBasis* getFunctionSpace(int order=-1) const
+  virtual const nodalBasis* getFunctionSpace(int order=-1, bool serendip=false) const
   {
-    return (_orig ? _orig->getFunctionSpace(order) : 0);
+    return (_orig ? _orig->getFunctionSpace(order, serendip) : 0);
   }
   virtual const JacobianBasis* getJacobianFuncSpace(int order=-1) const
   {
@@ -271,9 +271,9 @@ class MPolygon : public MElement {
   virtual int getNumChildren() const { return _parts.size(); }
   virtual MElement *getChild(int i) const { return _parts[i]; }
   virtual bool ownsParent() const { return _owner; }
-  virtual const nodalBasis* getFunctionSpace(int order=-1) const
+  virtual const nodalBasis* getFunctionSpace(int order=-1, bool serendip=false) const
   {
-    return (_orig ? _orig->getFunctionSpace(order) : 0);
+    return (_orig ? _orig->getFunctionSpace(order, serendip) : 0);
   }
   virtual const JacobianBasis* getJacobianFuncSpace(int order=-1) const
   {
@@ -341,9 +341,9 @@ class MLineChild : public MLine {
       delete _orig;
   }
   virtual int getTypeForMSH() const { return MSH_LIN_C; }
-  virtual const nodalBasis* getFunctionSpace(int order=-1) const
+  virtual const nodalBasis* getFunctionSpace(int order=-1, bool serendip=false) const
   {
-    if(_orig) return _orig->getFunctionSpace(order);
+    if(_orig) return _orig->getFunctionSpace(order, serendip);
     return 0;
   }
   virtual const JacobianBasis* getJacobianFuncSpace(int order=-1) const
diff --git a/Geo/MHexahedron.cpp b/Geo/MHexahedron.cpp
index f862e644f4..31f5e74d71 100644
--- a/Geo/MHexahedron.cpp
+++ b/Geo/MHexahedron.cpp
@@ -193,14 +193,6 @@ int MHexahedronN::getNumEdgesRep(bool curved)
   return curved ? 12 * CTX::instance()->mesh.numSubEdges : 12;
 }
 
-const nodalBasis* MHexahedron::getFunctionSpace(int order) const
-{
-  if (order == -1) return BasisFactory::getNodalBasis(getTypeForMSH());
-
-  int tag = ElementType::getTag(TYPE_HEX, order);
-  return tag ? BasisFactory::getNodalBasis(tag) : NULL;
-}
-
 const JacobianBasis* MHexahedron::getJacobianFuncSpace(int order) const
 {
   if (order == -1) return BasisFactory::getJacobianBasis(getTypeForMSH());
diff --git a/Geo/MHexahedron.h b/Geo/MHexahedron.h
index 22ddc41034..2b29dea0a8 100644
--- a/Geo/MHexahedron.h
+++ b/Geo/MHexahedron.h
@@ -59,7 +59,6 @@ class MHexahedron : public MElement {
   virtual MVertex *getVertex(int num){ return _v[num]; }
   virtual const MVertex *getVertex(int num) const { return _v[num]; }
   virtual void setVertex(int num,  MVertex *v){ _v[num] = v; }
-  virtual const nodalBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
   virtual MVertex *getVertexDIFF(int num)
   {
diff --git a/Geo/MLine.cpp b/Geo/MLine.cpp
index 4dfc65ff85..c0859e5358 100644
--- a/Geo/MLine.cpp
+++ b/Geo/MLine.cpp
@@ -11,14 +11,6 @@
 #include "Context.h"
 #include "qualityMeasures.h"
 
-const nodalBasis* MLine::getFunctionSpace(int order) const
-{
-  if (order == -1) return BasisFactory::getNodalBasis(getTypeForMSH());
-
-  int tag = ElementType::getTag(TYPE_LIN, order);
-  return tag ? BasisFactory::getNodalBasis(tag) : NULL;
-}
-
 const JacobianBasis* MLine::getJacobianFuncSpace(int order) const
 {
   if (order == -1) return BasisFactory::getJacobianBasis(getTypeForMSH());
diff --git a/Geo/MLine.h b/Geo/MLine.h
index d6e47489c4..98d6d240a7 100644
--- a/Geo/MLine.h
+++ b/Geo/MLine.h
@@ -74,7 +74,6 @@ class MLine : public MElement {
   {
     MVertex *tmp = _v[0]; _v[0] = _v[1]; _v[1] = tmp;
   }
-  virtual const nodalBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
   virtual bool isInside(double u, double v, double w) const
   {
diff --git a/Geo/MPoint.h b/Geo/MPoint.h
index 0ce0bee58e..df733f1910 100644
--- a/Geo/MPoint.h
+++ b/Geo/MPoint.h
@@ -61,10 +61,6 @@ class MPoint : public MElement {
   {
     s[0][0] = s[0][1] = s[0][2] = 0.;
   }
-  virtual const nodalBasis* getFunctionSpace(int o) const
-  {
-    return BasisFactory::getNodalBasis(MSH_PNT);
-  }
   virtual const JacobianBasis* getJacobianFuncSpace(int o) const
   {
     return BasisFactory::getJacobianBasis(MSH_PNT);
diff --git a/Geo/MPrism.cpp b/Geo/MPrism.cpp
index b83af8b1a6..36dcfc1d10 100644
--- a/Geo/MPrism.cpp
+++ b/Geo/MPrism.cpp
@@ -32,14 +32,6 @@ void MPrism::getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
   *pts = getGQPriPts(pOrder);
 }
 
-const nodalBasis* MPrism::getFunctionSpace(int order) const
-{
-  if (order == -1) return BasisFactory::getNodalBasis(getTypeForMSH());
-
-  int tag = ElementType::getTag(TYPE_PRI, order);
-  return tag ? BasisFactory::getNodalBasis(tag) : NULL;
-}
-
 const JacobianBasis* MPrism::getJacobianFuncSpace(int order) const
 {
   if (order == -1) return BasisFactory::getJacobianBasis(getTypeForMSH());
diff --git a/Geo/MPrism.h b/Geo/MPrism.h
index 2a2075f174..1ac48c5d0d 100644
--- a/Geo/MPrism.h
+++ b/Geo/MPrism.h
@@ -128,7 +128,6 @@ class MPrism : public MElement {
     tmp = _v[0]; _v[0] = _v[1]; _v[1] = tmp;
     tmp = _v[3]; _v[3] = _v[4]; _v[4] = tmp;
   }
-  virtual const nodalBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
   virtual int getVolumeSign();
   virtual void getNode(int num, double &u, double &v, double &w) const
diff --git a/Geo/MPyramid.cpp b/Geo/MPyramid.cpp
index 4bf91037f7..1d2af2da91 100644
--- a/Geo/MPyramid.cpp
+++ b/Geo/MPyramid.cpp
@@ -33,14 +33,6 @@ void MPyramid::getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
   *pts = getGQPyrPts(pOrder);
 }
 
-const nodalBasis* MPyramid::getFunctionSpace(int order) const
-{
-  if (order == -1) return BasisFactory::getNodalBasis(getTypeForMSH());
-
-  int tag = ElementType::getTag(TYPE_PYR, order);
-  return tag ? BasisFactory::getNodalBasis(tag) : NULL;
-}
-
 const JacobianBasis* MPyramid::getJacobianFuncSpace(int o) const
 {
   // FIXME add other order and see MPyramid::getFunctionSpace for 'design'
diff --git a/Geo/MPyramid.h b/Geo/MPyramid.h
index 423a7d0ae1..7a3623ffab 100644
--- a/Geo/MPyramid.h
+++ b/Geo/MPyramid.h
@@ -69,7 +69,6 @@ class MPyramid : public MElement {
   virtual MVertex *getVertex(int num){ return _v[num]; }
   virtual const MVertex *getVertex(int num) const{ return _v[num]; }
   virtual void setVertex(int num,  MVertex *v){ _v[num] = v; }
-  virtual const nodalBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
   virtual int getNumEdges(){ return 8; }
   virtual MEdge getEdge(int num) const
diff --git a/Geo/MQuadrangle.cpp b/Geo/MQuadrangle.cpp
index 271c6d7008..95c6313636 100644
--- a/Geo/MQuadrangle.cpp
+++ b/Geo/MQuadrangle.cpp
@@ -17,14 +17,6 @@
 
 #define SQU(a)      ((a)*(a))
 
-const nodalBasis* MQuadrangle::getFunctionSpace(int order) const
-{
-  if (order == -1) return BasisFactory::getNodalBasis(getTypeForMSH());
-
-  int tag = ElementType::getTag(TYPE_QUA, order);
-  return tag ? BasisFactory::getNodalBasis(tag) : NULL;
-}
-
 const JacobianBasis* MQuadrangle::getJacobianFuncSpace(int order) const
 {
   if (order == -1) return BasisFactory::getJacobianBasis(getTypeForMSH());
diff --git a/Geo/MQuadrangle.h b/Geo/MQuadrangle.h
index 07f171f142..738ae4097c 100644
--- a/Geo/MQuadrangle.h
+++ b/Geo/MQuadrangle.h
@@ -117,7 +117,6 @@ class MQuadrangle : public MElement {
   virtual const char *getStringForBDF() const { return "CQUAD4"; }
   virtual const char *getStringForDIFF() const { return "ElmB4n2D"; }
   virtual const char *getStringForINP() const { return "CPS4"/*"C2D4"*/; }
-  virtual const nodalBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
   virtual void getNode(int num, double &u, double &v, double &w) const
   {
diff --git a/Geo/MSubElement.cpp b/Geo/MSubElement.cpp
index 3a4e24db8d..ae58a393d8 100644
--- a/Geo/MSubElement.cpp
+++ b/Geo/MSubElement.cpp
@@ -17,9 +17,9 @@ MSubTetrahedron::~MSubTetrahedron()
   if(_base) delete _base;
 }
 
-const nodalBasis* MSubTetrahedron::getFunctionSpace(int order) const
+const nodalBasis* MSubTetrahedron::getFunctionSpace(int order, bool serendip) const
 {
-  if(_orig) return _orig->getFunctionSpace(order);
+  if(_orig) return _orig->getFunctionSpace(order, serendip);
   return 0;
 }
 
@@ -209,9 +209,9 @@ MSubTriangle::~MSubTriangle()
   if(_base) delete _base;
 }
 
-const nodalBasis* MSubTriangle::getFunctionSpace(int order) const
+const nodalBasis* MSubTriangle::getFunctionSpace(int order, bool serendip) const
 {
-  if(_orig) return _orig->getFunctionSpace(order);
+  if(_orig) return _orig->getFunctionSpace(order, serendip);
   return 0;
 }
 
@@ -447,9 +447,9 @@ MSubLine::~MSubLine()
   if(_base) delete _base;
 }
 
-const nodalBasis* MSubLine::getFunctionSpace(int order) const
+const nodalBasis* MSubLine::getFunctionSpace(int order, bool serendip) const
 {
-  if(_orig) return _orig->getFunctionSpace(order);
+  if(_orig) return _orig->getFunctionSpace(order, serendip);
   return 0;
 }
 
@@ -676,9 +676,9 @@ MSubPoint::~MSubPoint()
   if(_base) delete _base;
 }
 
-const nodalBasis* MSubPoint::getFunctionSpace(int order) const
+const nodalBasis* MSubPoint::getFunctionSpace(int order, bool serendip) const
 {
-  if(_orig) return _orig->getFunctionSpace(order);
+  if(_orig) return _orig->getFunctionSpace(order, serendip);
   return 0;
 }
 
diff --git a/Geo/MSubElement.h b/Geo/MSubElement.h
index 72404d034e..9415ead679 100644
--- a/Geo/MSubElement.h
+++ b/Geo/MSubElement.h
@@ -41,7 +41,7 @@ class MSubTetrahedron : public MTetrahedron
   ~MSubTetrahedron();
 
   virtual int getTypeForMSH() const { return MSH_TET_SUB; }
-  virtual const nodalBasis* getFunctionSpace(int order=-1) const;
+  virtual const nodalBasis* getFunctionSpace(int order=-1, bool serendip=false) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int order=-1) const;
   // the parametric coordinates are the coordinates in the local parent element
   virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const;
@@ -99,7 +99,7 @@ class MSubTriangle : public MTriangle
   ~MSubTriangle();
 
   virtual int getTypeForMSH() const { return MSH_TRI_SUB; }
-  virtual const nodalBasis* getFunctionSpace(int order=-1) const;
+  virtual const nodalBasis* getFunctionSpace(int order=-1, bool serendip=false) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int order=-1) const;
   // the parametric coordinates are the coordinates in the local parent element
   virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const;
@@ -157,7 +157,7 @@ class MSubLine : public MLine
   ~MSubLine();
 
   virtual int getTypeForMSH() const { return MSH_LIN_SUB; }
-  virtual const nodalBasis* getFunctionSpace(int order=-1) const;
+  virtual const nodalBasis* getFunctionSpace(int order=-1, bool serendip=false) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int order=-1) const;
   // the parametric coordinates are the coordinates in the local parent element
   virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const;
@@ -215,7 +215,7 @@ class MSubPoint : public MPoint
   ~MSubPoint();
 
   virtual int getTypeForMSH() const { return MSH_PNT_SUB; }
-  virtual const nodalBasis* getFunctionSpace(int order=-1) const;
+  virtual const nodalBasis* getFunctionSpace(int order=-1, bool serendip=false) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int order=-1) const;
   // the parametric coordinates are the coordinates in the local parent element
   virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const;
diff --git a/Geo/MTetrahedron.cpp b/Geo/MTetrahedron.cpp
index 6a7ce29931..43e5587f54 100644
--- a/Geo/MTetrahedron.cpp
+++ b/Geo/MTetrahedron.cpp
@@ -100,14 +100,6 @@ void MTetrahedron::xyz2uvw(double xyz[3], double uvw[3]) const
   sys3x3(mat, b, uvw, &det);
 }
 
-const nodalBasis* MTetrahedron::getFunctionSpace(int order) const
-{
-  if (order == -1) return BasisFactory::getNodalBasis(getTypeForMSH());
-
-  int tag = ElementType::getTag(TYPE_TET, order);
-  return tag ? BasisFactory::getNodalBasis(tag) : NULL;
-}
-
 const JacobianBasis* MTetrahedron::getJacobianFuncSpace(int order) const
 {
   if (order == -1) return BasisFactory::getJacobianBasis(getTypeForMSH());
diff --git a/Geo/MTetrahedron.h b/Geo/MTetrahedron.h
index 245fdc09a8..721b88017b 100644
--- a/Geo/MTetrahedron.h
+++ b/Geo/MTetrahedron.h
@@ -129,7 +129,6 @@ class MTetrahedron : public MElement {
   virtual double getCircumRadius();
   virtual double etaShapeMeasure();
   virtual void xyz2uvw(double xyz[3], double uvw[3]) const;
-  virtual const nodalBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
   virtual void getNode(int num, double &u, double &v, double &w) const
   {
diff --git a/Geo/MTriangle.cpp b/Geo/MTriangle.cpp
index 28ab257227..587d7a1a52 100644
--- a/Geo/MTriangle.cpp
+++ b/Geo/MTriangle.cpp
@@ -116,14 +116,6 @@ void MTriangle::xyz2uvw(double xyz[3], double uvw[3]) const
   uvw[2] = 0.;
 }
 
-const nodalBasis* MTriangle::getFunctionSpace(int order) const
-{
-  if (order == -1) return BasisFactory::getNodalBasis(getTypeForMSH());
-
-  int tag = ElementType::getTag(TYPE_TRI, order);
-  return tag ? BasisFactory::getNodalBasis(tag) : NULL;
-}
-
 const JacobianBasis* MTriangle::getJacobianFuncSpace(int order) const
 {
   if (order == -1) return BasisFactory::getJacobianBasis(getTypeForMSH());
diff --git a/Geo/MTriangle.h b/Geo/MTriangle.h
index dbda43a1f2..0d648ac219 100644
--- a/Geo/MTriangle.h
+++ b/Geo/MTriangle.h
@@ -124,7 +124,6 @@ class MTriangle : public MElement {
   {
     MVertex *tmp = _v[1]; _v[1] = _v[2]; _v[2] = tmp;
   }
-  virtual const nodalBasis* getFunctionSpace(int o=-1) const;
   virtual const JacobianBasis* getJacobianFuncSpace(int o=-1) const;
   virtual void getNode(int num, double &u, double &v, double &w) const
   {
-- 
GitLab