diff --git a/FunctionSpace/CMakeLists.txt b/FunctionSpace/CMakeLists.txt index 18dab32b3c44e9429749548636fd6007b9ed53d8..04d39e2f1e67a3653c37d2d4721d84f36ee629ae 100644 --- a/FunctionSpace/CMakeLists.txt +++ b/FunctionSpace/CMakeLists.txt @@ -16,13 +16,15 @@ set(SRC CurlBasis.cpp DivBasis.cpp - QuadNodeBasis.cpp - QuadEdgeBasis.cpp - LagrangeGenerator.cpp LagrangeBasis.cpp TriLagrangeBasis.cpp + LineNodeBasis.cpp + + QuadNodeBasis.cpp + QuadEdgeBasis.cpp + TriNodeBasis.cpp TriEdgeBasis.cpp TriNedelecBasis.cpp diff --git a/FunctionSpace/LineNodeBasis.cpp b/FunctionSpace/LineNodeBasis.cpp new file mode 100644 index 0000000000000000000000000000000000000000..24bed9e3cfe45ebfb1c16f1abe84061235df2f06 --- /dev/null +++ b/FunctionSpace/LineNodeBasis.cpp @@ -0,0 +1,97 @@ +#include "LineNodeBasis.h" +#include "Legendre.h" + +using namespace std; + +LineNodeBasis::LineNodeBasis(int order){ + // Set Basis Type // + this->order = order; + + type = 0; + dim = 1; + + nVertex = 2; + nEdge = (order - 1); + nFace = 0; + nCell = 0; + + nEdgeClosure = 2; + nFaceClosure = 0; + + size = nVertex + nEdge + nFace + nCell; + + // Legendre Polynomial // + Polynomial* intLegendre = new Polynomial[order]; + Legendre::integrated(intLegendre, order); + + // Basis // + node = new vector<Polynomial*>(nVertex); + edge = new vector<vector<Polynomial*>*>(nEdgeClosure); + face = new vector<vector<Polynomial*>*>(nFaceClosure); + cell = new vector<Polynomial*>(nCell); + + (*edge)[0] = new vector<Polynomial*>(nEdge); + (*edge)[1] = new vector<Polynomial*>(nEdge); + + + // Vertex Based (Lagrange) // + (*node)[0] = + new Polynomial(Polynomial(1, 0, 0, 0) - + Polynomial(1, 1, 0, 0) * + 0.5); + + (*node)[1] = + new Polynomial(Polynomial(1, 0, 0, 0) + + Polynomial(1, 1, 0, 0) * + 0.5); + + + // Edge Based // + const int permutation[2] = {0, 1}; + const Polynomial x[2] = { + Polynomial(+1, 1, 0, 0), + Polynomial(-1, 1, 0, 0) + }; + + for(int c = 0; c < 2; c++){ + unsigned int i = 0; + + for(int l = 1; l < order; l++){ + (*(*edge)[c])[i] = + new Polynomial(intLegendre[l].compose(x[permutation[c]])); + + i++; + } + } + + + // Free Temporary Sapce // + delete[] intLegendre; +} + +LineNodeBasis::~LineNodeBasis(void){ + // Vertex Based // + for(int i = 0; i < nVertex; i++) + delete (*node)[i]; + + delete node; + + + // Edge Based // + for(int c = 0; c < 2; c++){ + for(int i = 0; i < nEdge; i++) + delete (*(*edge)[c])[i]; + + delete (*edge)[c]; + } + + delete edge; + + + // Face Based // + delete face; + + + // Cell Based // + delete cell; +} diff --git a/FunctionSpace/LineNodeBasis.h b/FunctionSpace/LineNodeBasis.h new file mode 100644 index 0000000000000000000000000000000000000000..3b07ecaa8b39d260e66e1234672f00f220a24c14 --- /dev/null +++ b/FunctionSpace/LineNodeBasis.h @@ -0,0 +1,34 @@ +#ifndef _LINENODEBASIS_H_ +#define _LINENODEBASIS_H_ + +#include "BasisScalar.h" + +/** + @class LineNodeBasis + @brief A Node Basis for Lines + + This class can instantiate a Node-Based Basis + (high or low order) for Lines.@n + + It uses an @em adaptation of + <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> + Basis for @em high @em order Polynomial%s generation.@n + + This Basis is a restriction of a Quad Basis to @f$y = 0@f$.@n + + It also uses the following mapping: @f$x = \frac{u + 1}{2}@f$. + */ + +class LineNodeBasis: public BasisScalar{ + public: + //! @param order The order of the Basis + //! + //! Returns a new Node-Basis for Lines of the given order + LineNodeBasis(int order); + + //! Deletes this Basis + //! + virtual ~LineNodeBasis(void); +}; + +#endif