From 9ca18cfed7764d31d0472148ab525785b87f3670 Mon Sep 17 00:00:00 2001 From: Nicolas Marsic <nicolas.marsic@gmail.com> Date: Thu, 19 Jul 2012 15:19:27 +0000 Subject: [PATCH] Basis: add number of Vertex - Edge - Face - Cell based functions --- FunctionSpace/Basis.h | 65 ++++++++++++++++++++++++------- FunctionSpace/HexEdgeBasis.cpp | 10 +++++ FunctionSpace/HexNodeBasis.cpp | 12 +++++- FunctionSpace/QuadEdgeBasis.cpp | 12 +++++- FunctionSpace/QuadNodeBasis.cpp | 16 ++++++-- FunctionSpace/TriEdgeBasis.cpp | 12 +++++- FunctionSpace/TriNedelecBasis.cpp | 11 +++++- FunctionSpace/TriNodeBasis.cpp | 16 ++++++-- 8 files changed, 130 insertions(+), 24 deletions(-) diff --git a/FunctionSpace/Basis.h b/FunctionSpace/Basis.h index e6556f5ca7..6b45a5bfa5 100644 --- a/FunctionSpace/Basis.h +++ b/FunctionSpace/Basis.h @@ -21,11 +21,29 @@ class Basis{ int nodeNbr; int dim; + int nVertex; + int nEdge; + int nFace; + int nCell; + public: //! Deletes this Basis //! virtual ~Basis(void); + //! @return Returns: + //! @li @c true, if this is a + //! @em scalar Basis (BasisScalar) + //! @li @c false, if this is a + //! @em vectorial Basis (BasisVector) + //! + //! @note + //! Scalar basis are sets of + //! Polynomial%s@n + //! Vectorial basis are sets of + //! Vector%s of Polynomial%s + bool isScalar(void) const; + //! @return Returns the @em polynomial @em order of the Basis int getOrder(void) const; @@ -49,18 +67,21 @@ class Basis{ //! (1D, 2D or 3D) of the Basis int getDim(void) const; - //! @return Returns: - //! @li @c true, if this is a - //! @em scalar Basis (BasisScalar) - //! @li @c false, if this is a - //! @em vectorial Basis (BasisVector) - //! - //! @note - //! Scalar basis are sets of - //! Polynomial%s@n - //! Vectorial basis are sets of - //! Vector%s of Polynomial%s - bool isScalar(void) const; + //! @return Returns the number of @em Vertex + //! @em Based functions of this Basis + int getNVertex(void) const; + + //! @return Returns the number of @em Edge + //! @em Based functions of this Basis + int getNEdge(void) const; + + //! @return Returns the number of @em Face + //! @em Based functions of this Basis + int getNFace(void) const; + + //! @return Returns the number of @em Cell + //! @em Based functions of this Basis + int getNCell(void) const; protected: //! Instantiate a new Basis @@ -72,6 +93,10 @@ class Basis{ // Inline Functions // ////////////////////// +inline bool Basis::isScalar(void) const{ + return scalar; +} + inline int Basis::getOrder(void) const{ return order; } @@ -92,8 +117,20 @@ inline int Basis::getDim(void) const{ return dim; } -inline bool Basis::isScalar(void) const{ - return scalar; +inline int Basis::getNVertex(void) const{ + return nVertex; +} + +inline int Basis::getNEdge(void) const{ + return nEdge; +} + +inline int Basis::getNFace(void) const{ + return nFace; +} + +inline int Basis::getNCell(void) const{ + return nCell; } #endif diff --git a/FunctionSpace/HexEdgeBasis.cpp b/FunctionSpace/HexEdgeBasis.cpp index 0134bcbd28..505655ebf5 100644 --- a/FunctionSpace/HexEdgeBasis.cpp +++ b/FunctionSpace/HexEdgeBasis.cpp @@ -13,6 +13,10 @@ HexEdgeBasis::HexEdgeBasis(const int order){ nodeNbr = 8; dim = 3; + nVertex = 0 ; + nEdge = 12 * (order + 1); + nFace = 12 * order * (order + 1); + nCell = 3 * order * order * (order + 1); // Alloc Temporary Space // const int orderPlus = order + 1; @@ -448,6 +452,11 @@ int main(void){ const char x[3] = {'X', 'Y', 'Z'}; HexEdgeBasis b(P); + + printf("%d = %d + %d + %d + %d = %d\n", + b.getSize(), + b.getNVertex(), b.getNEdge(), b.getNFace(), b.getNCell(), + b.getNVertex() + b.getNEdge() + b.getNFace() + b.getNCell()); const std::vector<std::vector<Polynomial> >& basis = b.getBasis(); @@ -515,3 +524,4 @@ int main(void){ return 0; } */ + diff --git a/FunctionSpace/HexNodeBasis.cpp b/FunctionSpace/HexNodeBasis.cpp index db62d72d6a..c026845b3e 100644 --- a/FunctionSpace/HexNodeBasis.cpp +++ b/FunctionSpace/HexNodeBasis.cpp @@ -10,6 +10,11 @@ HexNodeBasis::HexNodeBasis(const int order){ nodeNbr = 8; dim = 3; + nVertex = 8; + nEdge = 12 * (order - 1); + nFace = 6 * (order - 1) * (order - 1); + nCell = (order - 1) * (order - 1) * (order - 1); + // Alloc Temporary Space // Polynomial* legendre = new Polynomial[order]; Polynomial* lifting = new Polynomial[8]; @@ -207,11 +212,16 @@ HexNodeBasis::~HexNodeBasis(void){ #include <cstdio> int main(void){ - const int P = 3; + const int P = 8; const double d = 0.05; HexNodeBasis b(P); + printf("%d = %d + %d + %d + %d = %d\n", + b.getSize(), + b.getNVertex(), b.getNEdge(), b.getNFace(), b.getNCell(), + b.getNVertex() + b.getNEdge() + b.getNFace() + b.getNCell()); + const std::vector<Polynomial>& basis = b.getBasis(); printf("\n"); diff --git a/FunctionSpace/QuadEdgeBasis.cpp b/FunctionSpace/QuadEdgeBasis.cpp index f403d567f6..c2ac4bfb66 100644 --- a/FunctionSpace/QuadEdgeBasis.cpp +++ b/FunctionSpace/QuadEdgeBasis.cpp @@ -10,6 +10,11 @@ QuadEdgeBasis::QuadEdgeBasis(const int order){ nodeNbr = 4; dim = 2; + nVertex = 0 ; + nEdge = 4 * (order + 1) ; + nFace = 0 ; + nCell = 2 * (order + 1) * order; + // Alloc Temporary Space // const int orderPlus = order + 1; Polynomial* legendre = new Polynomial[orderPlus]; @@ -181,11 +186,16 @@ QuadEdgeBasis::~QuadEdgeBasis(void){ /* #include <cstdio> int main(void){ - const int P = 3; + const int P = 8; const double d = 0.05; const char x[2] = {'X', 'Y'}; QuadEdgeBasis b(P); + + printf("%d = %d + %d + %d + %d = %d\n", + b.getSize(), + b.getNVertex(), b.getNEdge(), b.getNFace(), b.getNCell(), + b.getNVertex() + b.getNEdge() + b.getNFace() + b.getNCell()); const std::vector<std::vector<Polynomial> >& basis = b.getBasis(); diff --git a/FunctionSpace/QuadNodeBasis.cpp b/FunctionSpace/QuadNodeBasis.cpp index d62a1cc017..6c86298c4e 100644 --- a/FunctionSpace/QuadNodeBasis.cpp +++ b/FunctionSpace/QuadNodeBasis.cpp @@ -10,6 +10,11 @@ QuadNodeBasis::QuadNodeBasis(const int order){ nodeNbr = 4; dim = 2; + nVertex = 4 ; + nEdge = 4 * (order - 1) ; + nFace = 0 ; + nCell = (order - 1) * (order - 1); + // Alloc Temporary Space // Polynomial* legendre = new Polynomial[order]; Polynomial* lifting = new Polynomial[4]; @@ -95,10 +100,15 @@ QuadNodeBasis::~QuadNodeBasis(void){ /* #include <cstdio> int main(void){ - const int P = 4; + const int P = 8; const double d = 0.05; QuadNodeBasis b(P); + + printf("%d = %d + %d + %d + %d = %d\n", + b.getSize(), + b.getNVertex(), b.getNEdge(), b.getNFace(), b.getNCell(), + b.getNVertex() + b.getNEdge() + b.getNFace() + b.getNCell()); const std::vector<Polynomial>& basis = b.getBasis(); @@ -137,7 +147,7 @@ int main(void){ printf("\n"); for(int i = 0; i < b.getSize(); i++) - printf("p%d(j, i) = p(%d, x(i), y(j));\n", i + 1, i + 1, i + 1); + printf("p%d(j, i) = p(%d, x(i), y(j));\n", i + 1, i + 1); printf("end\n"); printf("end\n"); @@ -148,7 +158,7 @@ int main(void){ printf("\n"); for(int i = b.getSize(); i > 0; i--) - printf("figure;\ncontourf(x, y, p%d);\ncolorbar;\n", i, i); + printf("figure;\ncontourf(x, y, p%d);\ncolorbar;\n", i); printf("\n"); diff --git a/FunctionSpace/TriEdgeBasis.cpp b/FunctionSpace/TriEdgeBasis.cpp index 3cd6fc66e8..01d0287d2f 100644 --- a/FunctionSpace/TriEdgeBasis.cpp +++ b/FunctionSpace/TriEdgeBasis.cpp @@ -10,6 +10,11 @@ TriEdgeBasis::TriEdgeBasis(const int order){ nodeNbr = 3; dim = 2; + nVertex = 0; + nEdge = 3 * (order + 1); + nFace = 0; + nCell = ((order - 1) * order + order - 1); + // Alloc Temporary Space // const int orderPlus = order + 1; const int orderMinus = order - 1; @@ -167,11 +172,16 @@ TriEdgeBasis::~TriEdgeBasis(void){ /* #include <cstdio> int main(void){ - const int P = 6; + const int P = 8; const double d = 0.05; const char x[2] = {'X', 'Y'}; TriEdgeBasis b(P); + + printf("%d = %d + %d + %d + %d = %d\n", + b.getSize(), + b.getNVertex(), b.getNEdge(), b.getNFace(), b.getNCell(), + b.getNVertex() + b.getNEdge() + b.getNFace() + b.getNCell()); const std::vector<std::vector<Polynomial> >& basis = b.getBasis(); diff --git a/FunctionSpace/TriNedelecBasis.cpp b/FunctionSpace/TriNedelecBasis.cpp index dba1d667bb..c419b060c5 100644 --- a/FunctionSpace/TriNedelecBasis.cpp +++ b/FunctionSpace/TriNedelecBasis.cpp @@ -8,6 +8,11 @@ TriNedelecBasis::TriNedelecBasis(void){ nodeNbr = 3; dim = 2; + nVertex = 0; + nEdge = 3; + nFace = 0; + nCell = 0; + // Lagrange // Polynomial* lagrange = new Polynomial[3]; @@ -54,11 +59,15 @@ TriNedelecBasis::~TriNedelecBasis(void){ /* #include <cstdio> int main(void){ - const int P = 1; const double d = 0.05; const char x[2] = {'X', 'Y'}; TriNedelecBasis b; + + printf("%d = %d + %d + %d + %d = %d\n", + b.getSize(), + b.getNVertex(), b.getNEdge(), b.getNFace(), b.getNCell(), + b.getNVertex() + b.getNEdge() + b.getNFace() + b.getNCell()); const std::vector<std::vector<Polynomial> >& basis = b.getBasis(); diff --git a/FunctionSpace/TriNodeBasis.cpp b/FunctionSpace/TriNodeBasis.cpp index 14e3c49e92..c0856f2b30 100644 --- a/FunctionSpace/TriNodeBasis.cpp +++ b/FunctionSpace/TriNodeBasis.cpp @@ -10,6 +10,11 @@ TriNodeBasis::TriNodeBasis(const int order){ nodeNbr = 3; dim = 2; + nVertex = 3; + nEdge = 3 * (order - 1); + nFace = 0; + nCell = (order - 1) * (order - 2) / 2; + // Alloc Temporary Space // Polynomial* legendre = new Polynomial[order]; Polynomial* intLegendre = new Polynomial[order]; @@ -86,10 +91,15 @@ TriNodeBasis::~TriNodeBasis(void){ /* #include <cstdio> int main(void){ - const int P = 5; + const int P = 8; const double d = 0.01; TriNodeBasis b(P); + + printf("%d = %d + %d + %d + %d = %d\n", + b.getSize(), + b.getNVertex(), b.getNEdge(), b.getNFace(), b.getNCell(), + b.getNVertex() + b.getNEdge() + b.getNFace() + b.getNCell()); const std::vector<Polynomial>& basis = b.getBasis(); @@ -128,7 +138,7 @@ int main(void){ printf("\n"); for(int i = 0; i < b.getSize(); i++) - printf("p%d(j, i) = p(%d, x(i), y(j));\n", i + 1, i + 1, i + 1); + printf("p%d(j, i) = p(%d, x(i), y(j));\n", i + 1, i + 1); printf("end\n"); printf("end\n"); @@ -139,7 +149,7 @@ int main(void){ printf("\n"); for(int i = 0; i < b.getSize(); i++) - printf("figure;\ncontourf(x, y, p%d);\ncolorbar;\n", i + 1, i + 1); + printf("figure;\ncontourf(x, y, p%d);\ncolorbar;\n", i + 1); printf("\n"); -- GitLab