From c13768f5e23632383cb6cdfaf0f14773655b9b89 Mon Sep 17 00:00:00 2001
From: Nicolas Marsic <nicolas.marsic@gmail.com>
Date: Fri, 6 Sep 2013 13:04:47 +0000
Subject: [PATCH] Prism and Pyramid ReferenceSpace: seems to work \o/ --
 Correcting Polynomial doc

---
 FunctionSpace/CMakeLists.txt        |   2 +
 FunctionSpace/HexReferenceSpace.cpp |  52 ++--------
 FunctionSpace/Polynomial.cpp        |  14 +--
 FunctionSpace/Polynomial.h          | 156 ++++++++++++----------------
 FunctionSpace/PriReferenceSpace.cpp |  59 +++++++++++
 FunctionSpace/PriReferenceSpace.h   |  31 ++++++
 FunctionSpace/PyrReferenceSpace.cpp |  59 +++++++++++
 FunctionSpace/PyrReferenceSpace.h   |  31 ++++++
 8 files changed, 263 insertions(+), 141 deletions(-)
 create mode 100644 FunctionSpace/PriReferenceSpace.cpp
 create mode 100644 FunctionSpace/PriReferenceSpace.h
 create mode 100644 FunctionSpace/PyrReferenceSpace.cpp
 create mode 100644 FunctionSpace/PyrReferenceSpace.h

diff --git a/FunctionSpace/CMakeLists.txt b/FunctionSpace/CMakeLists.txt
index 9e0a0206e6..a54b1450ec 100644
--- a/FunctionSpace/CMakeLists.txt
+++ b/FunctionSpace/CMakeLists.txt
@@ -15,6 +15,8 @@ set(SRC
   QuadReferenceSpace.cpp
   TetReferenceSpace.cpp
   HexReferenceSpace.cpp
+  PyrReferenceSpace.cpp
+  PriReferenceSpace.cpp
 
   Basis.cpp
   BasisLocal.cpp
diff --git a/FunctionSpace/HexReferenceSpace.cpp b/FunctionSpace/HexReferenceSpace.cpp
index cc6806496a..fe09880804 100644
--- a/FunctionSpace/HexReferenceSpace.cpp
+++ b/FunctionSpace/HexReferenceSpace.cpp
@@ -54,52 +54,14 @@ HexReferenceSpace::~HexReferenceSpace(void){
 }
 
 string HexReferenceSpace::toLatex(void) const{
-  //const size_t nRefSpace = refSpaceNodeId.size();
   stringstream stream;
-  /*
-  stream << "\\documentclass{article}" << endl << endl
-
-         << "\\usepackage{longtable}"  << endl
-         << "\\usepackage{tikz}"       << endl
-         << "\\usetikzlibrary{arrows}" << endl << endl
-
-         << "\\begin{document}"                                   << endl
-         << "\\tikzstyle{vertex} = [circle, fill = black!25]"     << endl
-         << "\\tikzstyle{line}   = [draw, thick, black, -latex']" << endl
-         << endl
-
-         << "\\begin{longtable}{ccc}" << endl << endl;
-
-  for(size_t s = 0; s < nRefSpace; s++){
-    stream << "\\begin{tikzpicture}" << endl
-
-           << "\\node[vertex] (n0) at(0, 0) {$" << refSpaceNodeId[s][0] << "$};"
-           << endl
-           << "\\node[vertex] (n1) at(3, 0) {$" << refSpaceNodeId[s][1] << "$};"
-           << endl
-           << "\\node[vertex] (n2) at(0, 3) {$" << refSpaceNodeId[s][2] << "$};"
-           << endl
-           << "\\node[vertex] (n3) at(1, 1) {$" << refSpaceNodeId[s][3] << "$};"
-           << endl
-           << endl;
-
-    for(size_t e = 0; e < 6; e++)
-      stream << "\\path[line]"
-             << " (n" << orderedEdgeNodeIdx[s][e][0] << ")"
-             << " -- "
-             << " (n" << orderedEdgeNodeIdx[s][e][1] << ");"
-             << endl;
-
-    if((s + 1) % 3)
-      stream << "\\end{tikzpicture} & "        << endl << endl;
-
-    else
-      stream << "\\end{tikzpicture} \\\\ \\\\" << endl << endl;
-  }
 
-  stream << "\\end{longtable}" << endl
-         << "\\end{document}"  << endl;
-  */
-  stream << "Not Implemented" << endl;
+    stream << "\\documentclass{article}" << endl << endl
+         << "\\begin{document}"        << endl
+
+         << "\texttt{toLatex} not implemented" << endl
+
+         << "\\end{document}"          << endl;
+
   return stream.str();
 }
diff --git a/FunctionSpace/Polynomial.cpp b/FunctionSpace/Polynomial.cpp
index b664eb9bee..9418c0350f 100644
--- a/FunctionSpace/Polynomial.cpp
+++ b/FunctionSpace/Polynomial.cpp
@@ -156,7 +156,7 @@ double Polynomial::at
   return val;
 }
 
-fullVector<double> Polynomial::at(const vector<Polynomial>& P,
+fullVector<double> Polynomial::at(const std::vector<Polynomial>& P,
                                   double x,
                                   double y,
                                   double z){
@@ -572,9 +572,9 @@ void Polynomial::distribute(monomial_t* src, int size, const monomial_t* m){
   }
 }
 
-void Polynomial::compose(const Polynomial::monomial_t* src,
+void Polynomial::compose(const monomial_t* src,
                          Polynomial comp,
-                         stack<Polynomial::monomial_t>* stk){
+                         std::stack<monomial_t>* stk){
 
   comp.power(src->power[0]);
   comp.mul(src->coef);
@@ -592,9 +592,9 @@ void Polynomial::compose(const Polynomial::monomial_t* src,
   }
 }
 
-void Polynomial::compose(const Polynomial::monomial_t* src,
+void Polynomial::compose(const monomial_t* src,
                          Polynomial compA, Polynomial compB,
-                         stack<Polynomial::monomial_t>* stk){
+                         std::stack<monomial_t>* stk){
 
   compA.power(src->power[0]);
   compB.power(src->power[1]);
@@ -614,9 +614,9 @@ void Polynomial::compose(const Polynomial::monomial_t* src,
   }
 }
 
-void Polynomial::compose(const Polynomial::monomial_t* src,
+void Polynomial::compose(const monomial_t* src,
                          Polynomial compA, Polynomial compB, Polynomial compC,
-                         stack<Polynomial::monomial_t>* stk){
+                         std::stack<monomial_t>* stk){
 
   compA.power(src->power[0]);
   compB.power(src->power[1]);
diff --git a/FunctionSpace/Polynomial.h b/FunctionSpace/Polynomial.h
index 94951920bf..bde4d6fafb 100644
--- a/FunctionSpace/Polynomial.h
+++ b/FunctionSpace/Polynomial.h
@@ -8,10 +8,10 @@
 
 /**
    @class Polynomial
-   @brief Represents @c 3D polynomials
+   @brief Represents 3D polynomials
 
-   This class represents @c 3D polynomials.@n
-   A @c 3D polynomials uses monomials of '@c xyz' type.
+   This class represents 3D polynomials.
+   A 3D polynomials uses monomials of 'xyz' type.
  */
 
 // We suppose 3D Polynomial
@@ -122,34 +122,24 @@ class Polynomial{
 /**
    @fn Polynomial::Polynomial(double, int, int, int)
    @param coef The coeficient of the futur monomial
-   @param powerX The power of the '@c x' coordinate
-   of the futur monomial
-   @param powerY The power of the '@c y' coordinate
-   of the futur monomial
-   @param powerZ The power of the '@c z' coordinate
-   of the futur monomial
-   @return Returns a new Monomial with the given
-   parameters
-   @note
-   Note that Monomials are special case of Polynomial%s
+   @param powerX The power of the 'x' coordinate of the futur monomial
+   @param powerY The power of the 'y' coordinate of the futur monomial
+   @param powerZ The power of the 'z' coordinate of the futur monomial
+   @return Returns a new Monomial with the given parameters
+   (note that Monomials are special case of Polynomial%s)
    **
 
    @fn Polynomial::Polynomial(const Polynomial&)
    @param other A Polynomial
-   @return Returns a new Polynomial, which is
-   the @em copy of the given one
+   @return Returns a new Polynomial, which is the copy of the given one
    **
 
    @fn Polynomial::Polynomial(void)
-   @return Returns a new Polynomial, which is
-   @em empty
-   @warning
-   An @em empty Polynomial means: @em A @em Polynomial
-   @em with @em no @em monomials.@n
-   In particular, the empty Polynomial is @em not
-   the @em zero @em Polynomial.@n
-   Indeed, the @em zero @em Polynomial has one monomial,
-   @em @c 0.
+   @return Returns a new Polynomial, which is empty
+
+   An empty Polynomial means: a Polynomial with no monomials.
+   In particular, the empty Polynomial is not the zero Polynomial.
+   Indeed, the zero Polynomial has one monomial, 0.
    **
 
    @fn Polynomial::~Polynomial
@@ -157,48 +147,41 @@ class Polynomial{
    **
 
    @fn Polynomial::derivative
-   @param dim The dimention to use for the
-   derivation
-   @returns Derivates this Polynomial with
-   respect to the given dimention
-   @note
-   Dimention:
-   @li @c 0 is for the @c x coordinate
-   @li @c 1 is for the @c y coordinate
-   @li @c 2 is for the @c z coordinate
+   @param dim The dimention to use for the derivation
+   @returns Derivates this Polynomial with respect to the given dimention
+
+   Note that dimention:
+   @li 0 is for the x coordinate
+   @li 1 is for the y coordinate
+   @li 2 is for the z coordinate
    **
 
    @fn Polynomial::gradient
-   @return Returns a Vector with the gradient
-   of this Polynomial
+   @return Returns the gradient of this Polynomial
    **
 
    @fn Polynomial::curl
    @param p A vector of Polynomial%s
-   @return Returns the @em curl of the given
-   vector of Polynomial%s
+   @return Returns the curl of the given vector of Polynomial%s
    **
 
    @fn Polynomial::divergence
    @param p A vector of Polynomial%s
-   @return Returns the @em divergence of the given
-   vector of Polynomial%s
+   @return Returns the divergence of the given vector of Polynomial%s
    **
 
    @fn double Polynomial::operator()(double, double, double)
    @param x A value
    @param y A value
    @param z A value
-   @return Returns the @em evaluation of this
-   Polynomial at (@c x, @c y, @c z)
+   @return Returns the evaluation of this Polynomial at (x, y, z)
    **
 
    @fn double Polynomial::at(double, double, double) const
    @param x A value
    @param y A value
    @param z A value
-   @return Returns the @em evaluation of this
-   Polynomial at (@c x, @c y, @c z)
+   @return Returns the evaluation of this Polynomial at (x, y, z)
    **
 
    @fn fullVector<double> Polynomial::at(const std::vector<Polynomial>&, double, double, double)
@@ -206,99 +189,94 @@ class Polynomial{
    @param x A value
    @param y A value
    @param z A value
-   @return Returns a fullVector with the @em evaluation of
-   the given vector of Polynomial%s at (@c x, @c y, @c z)
+   @return Returns a fullVector with the evaluation of
+   the given vector of Polynomial%s at (x, y, z)
    **
 
    @fn Polynomial Polynomial::operator+(const Polynomial&) const
    @param other An other Polynomial
-   @return Returns a @em new Polynomial, which is the
-   @em sum of this Polynomial and the given one
+   @return Returns a new Polynomial,
+   which is the sum of this Polynomial and the given one
    **
 
    @fn Polynomial Polynomial::operator-(const Polynomial&) const
    @param other An other Polynomial
-   @return Returns a @em new Polynomial, which is the
-   @em difference of this Polynomial and the given one
+   @return Returns a new Polynomial,
+   which is the difference of this Polynomial and the given one
    **
 
    @fn Polynomial Polynomial::operator*(const Polynomial&) const
    @param other An other Polynomial
-   @return Returns a @em new Polynomial, which is the
-   @em product of this Polynomial and the given one
+   @return Returns a new Polynomial,
+   which is the product of this Polynomial and the given one
    **
 
    @fn Polynomial Polynomial::operator*(double) const
    @param alpha A value
-   @return Returns a @em new Polynomial,
-   which is this Polynomial @em multiplied by @c alpha
+   @return Returns a new Polynomial,
+   which is this Polynomial multiplied by alpha
    **
 
    @fn Polynomial::add
    @param other An other Polynomial
-   @return The given Polynomial is
-   @em added to this Polynomial
-   @note
-   The result of this operation is stored in
-   this Polynomial
+   @return The given Polynomial is added to this Polynomial
+
+   Note that the result of this operation is stored in this Polynomial
    **
 
    @fn Polynomial::sub
    @param other An other Polynomial
-   @return The given Polynomial is
-   @em substracted to this Polynomial
-   @note
-   The result of this operation is stored in
-   this Polynomial
+   @return The given Polynomial is substracted to this Polynomial
+
+   Note that the result of this operation is stored in this Polynomial
    **
 
    @fn void Polynomial::mul(const Polynomial&)
    @param other An other Polynomial
-   @return The given Polynomial is
-   @em multiplied with this Polynomial
-   @note
-   The result of this operation is stored in
-   this Polynomial
+   @return The given Polynomial is multiplied with this Polynomial
+
+   Note that the result of this operation is stored in this Polynomial
    **
 
    @fn void Polynomial::mul(double)
    @param alpha A value
-   @return This Polynomial is @em multiplied
-   by the given value
-   @note
-   The result of this operation is stored in
-   this Polynomial
+   @return This Polynomial is multiplied by the given value
+
+   Note that the result of this operation is stored in this Polynomial
    **
 
    @fn Polynomial::power
-   @param n A @em natural number
-   @return Takes this Polynomial to the power @c n
+   @param n A natural number
+   @return Takes this Polynomial to the power n
    **
 
    @fn Polynomial Polynomial::compose(const Polynomial&) const
-   @param other An other Polynomial,
-   called @c Q(x, @c y, @c z)
+   @param other An other Polynomial, called Q(x, y, z)
    @return
-   Let this Polynomial be @c P(x, @c y, @c z).@n
-   This method returns a @em new Polynomial,
-   representing @c P(Q(x, @c y, @c z), @c y, @c z)
+   Let this Polynomial be P(x, y, z). This method returns a new Polynomial,
+   representing P(Q(x, y, z), y, z)
    **
 
    @fn Polynomial Polynomial::compose(const Polynomial&, const Polynomial&) const
-   @param otherA An other Polynomial,
-   called @c Q(x, @c y, @c z)
-   @param otherB An other Polynomial,
-   called @c R(x, @c y, @c z)
+   @param otherA An other Polynomial, called Q(x, y, z)
+   @param otherB An other Polynomial, called R(x, y, z)
+   @return
+   Let this Polynomial be P(x, y, z). This method returns a new Polynomial,
+   representing P(Q(x, y, z), R(x, y, z), z)
+   **
+
+   @fn Polynomial Polynomial::compose(const Polynomial&, const Polynomial&, const Polynomial&) const
+   @param otherA An other Polynomial, called Q(x, y, z)
+   @param otherB An other Polynomial, called R(x, y, z)
+   @param otherC An other Polynomial, called S(x, y, z)
    @return
-   Let this Polynomial be @c P(x, @c y, @c z).@n
-   This method returns a @em new Polynomial, representing
-   @c P(Q(x, @c y, @c z), @c R(x, @c y, @c z), @c z)
+   Let this Polynomial be P(x, y, z). This method returns a new Polynomial,
+   representing P(Q(x, y, z), R(x, y, z), S(x, y, z))
    **
 
    @fn void Polynomial::operator=(const Polynomial&)
    @param other A Polynomial
-   @return Sets this Polynomial to a @em copy
-   of the given one
+   @return Sets this Polynomial to a copy of the given one
    **
 
    @fn Polynomial::toString
diff --git a/FunctionSpace/PriReferenceSpace.cpp b/FunctionSpace/PriReferenceSpace.cpp
new file mode 100644
index 0000000000..9015d6da8d
--- /dev/null
+++ b/FunctionSpace/PriReferenceSpace.cpp
@@ -0,0 +1,59 @@
+#include <sstream>
+#include "PriReferenceSpace.h"
+#include "MPrism.h"
+
+using namespace std;
+
+PriReferenceSpace::PriReferenceSpace(void){
+  // Vertex Definition //
+  nVertex = 6;
+
+  // Edge Definition //
+  const size_t nEdge = 9;
+  refEdgeNodeIdx.resize(nEdge);
+
+  for(size_t i = 0; i < nEdge; i++){
+    refEdgeNodeIdx[i].resize(2); // Two Nodes per Edge
+    refEdgeNodeIdx[i][0] = MPrism::edges_prism(i, 0);
+    refEdgeNodeIdx[i][1] = MPrism::edges_prism(i, 1);
+  }
+
+  // Face Definition //
+  size_t nFace = 5;
+  refFaceNodeIdx.resize(nFace);
+
+  for(size_t i = 0; i < nFace; i++){
+    int fourthNodeIdx = MPrism::faces_prism(i, 3);
+
+    if(fourthNodeIdx != -1)
+      refFaceNodeIdx[i].resize(4);  // Four Nodes in this face
+    else
+      refFaceNodeIdx[i].resize(3);  // Three Nodes in this face
+
+    refFaceNodeIdx[i][0] = MPrism::faces_prism(i, 0);
+    refFaceNodeIdx[i][1] = MPrism::faces_prism(i, 1);
+    refFaceNodeIdx[i][2] = MPrism::faces_prism(i, 2);
+
+    if(fourthNodeIdx != -1)
+      refFaceNodeIdx[i][3] = fourthNodeIdx;
+  }
+
+  // Init All //
+  init();
+}
+
+PriReferenceSpace::~PriReferenceSpace(void){
+}
+
+string PriReferenceSpace::toLatex(void) const{
+  stringstream stream;
+
+  stream << "\\documentclass{article}" << endl << endl
+         << "\\begin{document}"        << endl
+
+         << "\texttt{toLatex} not implemented" << endl
+
+         << "\\end{document}"          << endl;
+
+  return stream.str();
+}
diff --git a/FunctionSpace/PriReferenceSpace.h b/FunctionSpace/PriReferenceSpace.h
new file mode 100644
index 0000000000..173361668c
--- /dev/null
+++ b/FunctionSpace/PriReferenceSpace.h
@@ -0,0 +1,31 @@
+#ifndef _PRIREFERENCESPACE_H_
+#define _PRIREFERENCESPACE_H_
+
+#include <string>
+#include "ReferenceSpace.h"
+
+/**
+   @class PriReferenceSpace
+   @brief ReferenceSpace for Prisms
+
+   This class implements a ReferenceSpace for a Prism.
+ */
+
+class PriReferenceSpace: public ReferenceSpace{
+ public:
+  PriReferenceSpace(void);
+  virtual ~PriReferenceSpace(void);
+
+  virtual std::string toLatex(void) const;
+};
+
+/**
+   @fn PriReferenceSpace::PriReferenceSpace
+   Instatiate a new ReferenceSpace for a Prism
+   **
+
+   @fn PriReferenceSpace::~PriReferenceSpace
+   Deletes this PriReferenceSpace
+*/
+
+#endif
diff --git a/FunctionSpace/PyrReferenceSpace.cpp b/FunctionSpace/PyrReferenceSpace.cpp
new file mode 100644
index 0000000000..b6edaac530
--- /dev/null
+++ b/FunctionSpace/PyrReferenceSpace.cpp
@@ -0,0 +1,59 @@
+#include <sstream>
+#include "PyrReferenceSpace.h"
+#include "MPyramid.h"
+
+using namespace std;
+
+PyrReferenceSpace::PyrReferenceSpace(void){
+  // Vertex Definition //
+  nVertex = 5;
+
+  // Edge Definition //
+  const size_t nEdge = 8;
+  refEdgeNodeIdx.resize(nEdge);
+
+  for(size_t i = 0; i < nEdge; i++){
+    refEdgeNodeIdx[i].resize(2); // Two Nodes per Edge
+    refEdgeNodeIdx[i][0] = MPyramid::edges_pyramid(i, 0);
+    refEdgeNodeIdx[i][1] = MPyramid::edges_pyramid(i, 1);
+  }
+
+  // Face Definition //
+  size_t nFace = 5;
+  refFaceNodeIdx.resize(nFace);
+
+  for(size_t i = 0; i < nFace; i++){
+    int fourthNodeIdx = MPyramid::faces_pyramid(i, 3);
+
+    if(fourthNodeIdx != -1)
+      refFaceNodeIdx[i].resize(4);  // Four Nodes in this face
+    else
+      refFaceNodeIdx[i].resize(3);  // Three Nodes in this face
+
+    refFaceNodeIdx[i][0] = MPyramid::faces_pyramid(i, 0);
+    refFaceNodeIdx[i][1] = MPyramid::faces_pyramid(i, 1);
+    refFaceNodeIdx[i][2] = MPyramid::faces_pyramid(i, 2);
+
+    if(fourthNodeIdx != -1)
+      refFaceNodeIdx[i][3] = fourthNodeIdx;
+  }
+
+  // Init All //
+  init();
+}
+
+PyrReferenceSpace::~PyrReferenceSpace(void){
+}
+
+string PyrReferenceSpace::toLatex(void) const{
+  stringstream stream;
+
+  stream << "\\documentclass{article}" << endl << endl
+         << "\\begin{document}"        << endl
+
+         << "\texttt{toLatex} not implemented" << endl
+
+         << "\\end{document}"          << endl;
+
+  return stream.str();
+}
diff --git a/FunctionSpace/PyrReferenceSpace.h b/FunctionSpace/PyrReferenceSpace.h
new file mode 100644
index 0000000000..7ecc3885a4
--- /dev/null
+++ b/FunctionSpace/PyrReferenceSpace.h
@@ -0,0 +1,31 @@
+#ifndef _PYRREFERENCESPACE_H_
+#define _PYRREFERENCESPACE_H_
+
+#include <string>
+#include "ReferenceSpace.h"
+
+/**
+   @class PyrReferenceSpace
+   @brief ReferenceSpace for Pyramids
+
+   This class implements a ReferenceSpace for a Pyramid.
+ */
+
+class PyrReferenceSpace: public ReferenceSpace{
+ public:
+  PyrReferenceSpace(void);
+  virtual ~PyrReferenceSpace(void);
+
+  virtual std::string toLatex(void) const;
+};
+
+/**
+   @fn PyrReferenceSpace::PyrReferenceSpace
+   Instatiate a new ReferenceSpace for a Pyramid
+   **
+
+   @fn PyrReferenceSpace::~PyrReferenceSpace
+   Deletes this PyrReferenceSpace
+*/
+
+#endif
-- 
GitLab