diff --git a/FunctionSpace/Basis.cpp b/FunctionSpace/Basis.cpp deleted file mode 100644 index 153bd0243b884937777374746fac8adec574a5b2..0000000000000000000000000000000000000000 --- a/FunctionSpace/Basis.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "Basis.h" - -Basis::Basis(void){ -} - -Basis::~Basis(void){ -} diff --git a/FunctionSpace/Basis.h b/FunctionSpace/Basis.h deleted file mode 100644 index 0d8ac22d5e03e3eea38834cd803662c0e140a1f7..0000000000000000000000000000000000000000 --- a/FunctionSpace/Basis.h +++ /dev/null @@ -1,329 +0,0 @@ -#ifndef _BASIS_H_ -#define _BASIS_H_ - -#include <string> -#include "MElement.h" - -/** - @interface Basis - @brief Common Interface of all Basis - - This class is the common interface for all Basis. - - A Basis is set of linearly independent Polynomial%s - (or Vector%s of Polynomial%s). - - The returned matrices are the result of the evaluation - of the basis functions (at N points). - - The i-th row of these matrices is always refering to the - i-th function of the basis. - - Depending on the nature of the returned value (scalar or vector), - the columns are organized diferently. - - For scalar values, we have: - @li The j-th column of the i-th row is - the evaluation of the i-th function at the j-th point - - For vectorial values, we have: - @li The j-th column of the i-th row is the first coordinate of - the evaluation of the i-th function at the 3 x j-th point - - @li The (j-th + 1) column of the i-th row is the second coordinate of - the evaluation of the i-th function at the 3 x j-th point - - @li The (j-th + 2) column of the i-th row is the third coordinate of - the evaluation of the i-th function at the 3 x j-th point - */ - -class Basis{ - protected: - bool scalar; - bool local; - - size_t order; - size_t type; - size_t form; - size_t dim; - - size_t nVertex; - size_t nEdge; - size_t nFace; - size_t nCell; - - size_t nFunction; - - public: - // Destructor // - virtual ~Basis(void); - - // Scalar & Local // - bool isScalar(void) const; - bool isLocal(void) const; - - // Type of Basis // - size_t getOrder(void) const; - size_t getType(void) const; - size_t getForm(void) const; - size_t getDim(void) const; - - // Number of Functions // - size_t getNVertexBased(void) const; - size_t getNEdgeBased(void) const; - size_t getNFaceBased(void) const; - size_t getNCellBased(void) const; - size_t getNFunction(void) const; - - // Direct Access to Evaluated Functions // - virtual void getFunctions(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const = 0; - - virtual void getFunctions(fullMatrix<double>& retValues, - size_t orientation, - double u, double v, double w) const = 0; - - virtual void getDerivative(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const = 0; - - // Precompute Functions // - virtual - void preEvaluateFunctions(const fullMatrix<double>& point) const = 0; - virtual - void preEvaluateDerivatives(const fullMatrix<double>& point) const = 0; - - // Access to Precomputed Functions // - virtual const fullMatrix<double>& - getPreEvaluatedFunctions(const MElement& element) const = 0; - - virtual const fullMatrix<double>& - getPreEvaluatedDerivatives(const MElement& element) const = 0; - - virtual const fullMatrix<double>& - getPreEvaluatedFunctions(size_t orientation) const = 0; - - virtual const fullMatrix<double>& - getPreEvaluatedDerivatives(size_t orientation) const = 0; - - virtual std::string toString(void) const = 0; - - protected: - // 'Constructor' // - Basis(void); -}; - - -/** - @internal - @fn Basis::Basis - - Instantiate a new Basis - @endinternal - ** - - @fn Basis::~Basis - - Deletes this Basis - ** - - @fn Basis::isScalar - @return Returns: - @li true, if this is a scalar Basis - @li false, if this is a vectorial Basis - - Scalar basis are sets of Polynomial%s, - and Vectorial basis are sets of Vector%s of Polynomial%s - ** - - @fn Basis::isLocal - @return Returns: - @li true, if this is a Local Basis - @li false, if this is a Global Basis - ** - - @fn Basis::getOrder - @return Returns the polynomial order of the Basis - ** - - @fn Basis::getType - @return Returns the type of the Basis (coherent with gmsh element types): - @li 1 for Points - @li 2 for Lines - @li 3 for Triangles - @li 4 for Quadrangles - @li 5 for Tetrahedra - @li 6 for Pyramids - @li 7 for Prisms - @li 8 for Hexahedra - ** - - @fn Basis::getForm - @return Returns the diferential form of the Basis: - @li 0 for 0-form - @li 1 for 1-form - @li 2 for 2-form - @li 3 for 3-form - ** - - @fn Basis::getDim - @return Returns the dimension (1D, 2D or 3D) of the Basis - ** - - @fn Basis::getNVertexBased - @return Returns the number of Vertex based functions of this Basis - ** - - @fn Basis::getNEdgeBased - @return Returns the number of Edge based functions of this Basis - ** - - @fn Basis::getNFaceBased - @return Returns the number of Face based functions of this Basis - ** - - @fn Basis::getNCellBased - @return Returns the number of Cell based functions of this Basis - ** - - @fn Basis::getNFunction - @return Returns the number of Polynomial%s - (or Vector%s of Polynomial%s) Functions in this Basis - ** - - @fn Basis::getFunctions(fullMatrix<double>&, const MElement&, double, double, double) const - @param retValues An allocated matrix - @param element A MElement - @param u A u coordinate in the reference space of this Basis - @param v A v coordinate in the reference space of this Basis - @param w A w coordinate in the reference space of this Basis - - The given matrix is populated with the evaluation of every basis function - at the given coordinates, and for the orientation of the given element - ** - - @fn Basis::getFunctions(fullMatrix<double>&, size_t, double, double, double) const - @param retValues An allocated matrix - @param orientation A integer - @param u A u coordinate in the reference space of this Basis - @param v A v coordinate in the reference space of this Basis - @param w A w coordinate in the reference space of this Basis - - The given matrix is populated with the evaluation of every basis function - at the given coordinates, and for the given orientation - ** - - @fn Basis::getDerivative(fullMatrix<double>&, const MElement&, double, double, double) const - @param retValues An allocated matrix - @param element A MElement - @param u A u coordinate in the reference space of this Basis - @param v A v coordinate in the reference space of this Basis - @param w A w coordinate in the reference space of this Basis - - The given matrix is populated with the evaluation of the derivative - of every basis function at the given coordinates, - and for the orientation of the given element - ** - - @fn Basis::preEvaluateFunctions - @param point A Matrix with points coordinate - (each line is a point and got 3 coordinates, i.e. 3 rows) - - Pre Evaluates every basis function at the given points - ** - - @fn Basis::preEvaluateDerivatives - @param point A Matrix with points coordinate - (each line is a point and got 3 coordinates, i.e. 3 rows) - - Pre Evaluates every basis function derivative at the given points - - @li For 0-Form it computes the gradient - @li For 1-Form it computes the curl - @li For 2-Form it computes the divergence - ** - - @fn Basis::getPreEvaluatedFunctions(size_t) const - @param orientation A natural number defining the reference space orientation - @return Returns a Matrix with the PreEvaluated basis functions - (see Basis::preEvaluateFunctions()), with the given orientation - - If no PreEvaluation has been done before calling this function, - an Exception is thrown - ** - - @fn Basis::getPreEvaluatedDerivatives(size_t) const - @param orientation A natural number defining the reference space orientation - @return Returns a Matrix with the PreEvaluated basis functions derivatives - (see Basis::preEvaluateDerivatives()), with the given orientation - - If no PreEvaluation of the gradient has been done - before calling this function, an Exception is thrown - ** - - @fn Basis::getPreEvaluatedFunctions(const MElement&) const - @param element A MElement - @return Same as Basis::getPreEvaluatedFunctions, - but the orientation is computed with the given element - ** - - @fn Basis::getPreEvaluatedDerivatives(const MElement&) const - @param element A MElement - @return Same as Basis::getPreEvaluatedFunctions, - but the orientation is computed with the given element - ** - - @fn Basis::toString - @return Returns a string describing this Basis -*/ - -////////////////////// -// Inline Functions // -////////////////////// - -inline bool Basis::isScalar(void) const{ - return scalar; -} - -inline bool Basis::isLocal(void) const{ - return local; -} - -inline size_t Basis::getOrder(void) const{ - return order; -} - -inline size_t Basis::getType(void) const{ - return type; -} - -inline size_t Basis::getForm(void) const{ - return form; -} - -inline size_t Basis::getDim(void) const{ - return dim; -} - -inline size_t Basis::getNVertexBased(void) const{ - return nVertex; -} - -inline size_t Basis::getNEdgeBased(void) const{ - return nEdge; -} - -inline size_t Basis::getNFaceBased(void) const{ - return nFace; -} - -inline size_t Basis::getNCellBased(void) const{ - return nCell; -} - -inline size_t Basis::getNFunction(void) const{ - return nFunction; -} - -#endif diff --git a/FunctionSpace/BasisGenerator.cpp b/FunctionSpace/BasisGenerator.cpp deleted file mode 100644 index c1a12f40f96d3268ee7fbd6a9704d9605a5d65da..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisGenerator.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include "BasisGenerator.h" -#include "GmshDefines.h" -#include "Exception.h" - -#include "LineNodeBasis.h" -#include "LineEdgeBasis.h" -#include "LineNedelecBasis.h" -#include "LineLagrangeBasis.h" - -#include "TriNodeBasis.h" -#include "TriEdgeBasis.h" -#include "TriNedelecBasis.h" -#include "TriLagrangeBasis.h" - -#include "QuadNodeBasis.h" -#include "QuadEdgeBasis.h" -#include "QuadNedelecBasis.h" -#include "QuadLagrangeBasis.h" - -#include "TetNodeBasis.h" -#include "TetEdgeBasis.h" -#include "TetNedelecBasis.h" -#include "TetLagrangeBasis.h" - -#include "HexNodeBasis.h" -#include "HexEdgeBasis.h" -#include "HexLagrangeBasis.h" - -BasisGenerator::BasisGenerator(void){ -} - -BasisGenerator::~BasisGenerator(void){ -} - -BasisLocal* BasisGenerator::generate(size_t elementType, - size_t basisType, - size_t order, - std::string family){ - - if(!family.compare(std::string("hierarchical"))) - return generateHierarchical(elementType, basisType, order); - - else if(!family.compare(std::string("lagrange"))) - return generateLagrange(elementType, basisType, order); - - else - throw Exception("Unknwown Basis Family: %s", family.c_str()); -} - -BasisLocal* BasisGenerator::generateHierarchical(size_t elementType, - size_t basisType, - size_t order){ - switch(elementType){ - case TYPE_LIN: return linHierarchicalGen(basisType, order); - case TYPE_TRI: return triHierarchicalGen(basisType, order); - case TYPE_QUA: return quaHierarchicalGen(basisType, order); - case TYPE_TET: return tetHierarchicalGen(basisType, order); - case TYPE_HEX: return hexHierarchicalGen(basisType, order); - - default: throw Exception("Unknown Element Type (%d) for Basis Generation", - elementType); - } -} - -BasisLocal* BasisGenerator::generateLagrange(size_t elementType, - size_t basisType, - size_t order){ - if(basisType != 0) - throw - Exception("Cannot Have a %d-Form Lagrange Basis (0-Form only)", - basisType); - - switch(elementType){ - case TYPE_LIN: return new LineLagrangeBasis(order); - case TYPE_TRI: return new TriLagrangeBasis(order); - case TYPE_QUA: return new QuadLagrangeBasis(order); - case TYPE_TET: return new TetLagrangeBasis(order); - case TYPE_HEX: return new HexLagrangeBasis(order); - - default: throw Exception("Unknown Element Type (%d) for Basis Generation", - elementType); - } -} - -BasisLocal* BasisGenerator::linHierarchicalGen(size_t basisType, - size_t order){ - switch(basisType){ - case 0: return new LineNodeBasis(order); - case 1: - if (order == 0) return new LineNedelecBasis(); - else return new LineEdgeBasis(order); - - case 2: throw Exception("2-form not implemented on Lines"); - case 3: throw Exception("3-form not implemented on Lines"); - - default: throw Exception("There is no %d-form", basisType); - } -} - -BasisLocal* BasisGenerator::triHierarchicalGen(size_t basisType, - size_t order){ - switch(basisType){ - case 0: return new TriNodeBasis(order); - case 1: - if (order == 0) return new TriNedelecBasis(); - else return new TriEdgeBasis(order); - - case 2: throw Exception("2-form not implemented on Triangles"); - case 3: throw Exception("3-form not implemented on Triangles"); - - default: throw Exception("There is no %d-form", basisType); - } -} - -BasisLocal* BasisGenerator::quaHierarchicalGen(size_t basisType, - size_t order){ - switch(basisType){ - case 0: return new QuadNodeBasis(order); - case 1: - if (order == 0) return new QuadNedelecBasis(); - else return new QuadEdgeBasis(order); - - case 2: throw Exception("2-form not implemented on Quads"); - case 3: throw Exception("3-form not implemented on Quads"); - - default: throw Exception("There is no %d-form", basisType); - } -} - -BasisLocal* BasisGenerator::tetHierarchicalGen(size_t basisType, - size_t order){ - switch(basisType){ - case 0: return new TetNodeBasis(order); - case 1: - if (order == 0) return new TetNedelecBasis(); - else return new TetEdgeBasis(order); - - case 2: throw Exception("2-form not implemented on Tetrahedrons"); - case 3: throw Exception("3-form not implemented on Tetrahedrons"); - - default: throw Exception("There is no %d-form", basisType); - } -} - -BasisLocal* BasisGenerator::hexHierarchicalGen(size_t basisType, - size_t order){ - switch(basisType){ - case 0: return new HexNodeBasis(order); - //case 1: return new HexEdgeBasis(order); - case 1: throw Exception("1-form not implemented on Hexs"); - case 2: throw Exception("2-form not implemented on Hexs"); - case 3: throw Exception("3-form not implemented on Hexs"); - - default: throw Exception("There is no %d-form", basisType); - } -} diff --git a/FunctionSpace/BasisGenerator.h b/FunctionSpace/BasisGenerator.h deleted file mode 100644 index 64c1033400889d7af0fa1713c6c40174fb74451e..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisGenerator.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _BASISGENERATOR_H_ -#define _BASISGENERATOR_H_ - -#include <string> -#include "BasisLocal.h" - -/** - @class BasisGenerator - @brief A bunch of class method to generate a Local Basis - - A BasisGenerator is a bunch of class methods to generate a local Basis. -*/ - -class BasisGenerator{ - public: - BasisGenerator(void); - ~BasisGenerator(void); - - static BasisLocal* generate(size_t elementType, - size_t basisType, - size_t order, - std::string family); - - static BasisLocal* generate(size_t elementType, - size_t basisType, - size_t order); - - static BasisLocal* linHierarchicalGen(size_t basisType, size_t order); - static BasisLocal* triHierarchicalGen(size_t basisType, size_t order); - static BasisLocal* quaHierarchicalGen(size_t basisType, size_t order); - static BasisLocal* tetHierarchicalGen(size_t basisType, size_t order); - static BasisLocal* hexHierarchicalGen(size_t basisType, size_t order); - - private: - static BasisLocal* generateHierarchical(size_t elementType, - size_t basisType, - size_t order); - - static BasisLocal* generateLagrange(size_t elementType, - size_t basisType, - size_t order); -}; - - -/** - @fn BasisGenerator::BasisGenerator - Instantiates a new BasisGenerator - - This class got only class methods, so it is not required to instanciate it. - ** - - @fn BasisGenerator::~BasisGenerator - Deletes this BasisGenerator - ** - - @fn BasisGenerator::generate(size_t, size_t, size_t, std::string) - @param elementType The element type of the requested Basis - @param basisType The Basis type - @param order The order or the requested Basis - @param family A string - - This method will instanciate the requested Basis of the requested family - - @return Returns a pointer to a newly instantiated Basis - - Element types are: - @li @c TYPE_LIN for Lines - @li @c TYPE_TRI for Triangles - @li @c TYPE_QUA for Quadrangles - @li @c TYPE_TET for Tetrahedrons - @li @c TYPE_HEX for Hexahedrons - - Basis types are: - @li 0 for 0-Form - @li 1 for 1-Form - @li 2 for 2-Form - @li 3 for 3-Form - - Families are: - @li hierarchical for - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis functions - @li lagrange for Lagrange's Basis functions - ** - - @fn BasisGenerator::generate(size_t, size_t, size_t) - @param elementType The element type of the requested Basis - @param basisType The Basis type - @param order The order or the requested Basis - - Same as - BasisGenerator::generate(elementType, basisType, order, @em hierarchical) - - @return Returns a pointer to a newly instantiated Basis - ** - - @fn BasisGenerator::linHierarchicalGen - @param basisType The Basis type - @param order The order or the requested Basis - - This method will instanciate the requested Basis with a Line support - - @return Returns a pointer to a newly instantiated Basis - - Basis types are: - @li 0 for 0-Form - @li 1 for 1-Form - @li 2 for 2-Form - @li 3 for 3-Form - - The Basis family will be hierarchical - ** - - @fn BasisGenerator::triHierarchicalGen - @param basisType The Basis type - @param order The order or the requested Basis - - Same as BasisGenerator::linHierarchicalGen() but for Triangles - ** - - @fn BasisGenerator::quaHierarchicalGen - @param basisType The Basis type - @param order The order or the requested Basis - - Same as BasisGenerator::linHierarchicalGen() but for Quadrangles - ** - - @fn BasisGenerator::tetHierarchicalGen - @param basisType The Basis type - @param order The order or the requested Basis - - Same as BasisGenerator::linHierarchicalGen() but for Tetrahedra - ** - - @fn BasisGenerator::hexHierarchicalGen - @param basisType The Basis type - @param order The order or the requested Basis - - Same as BasisGenerator::linHierarchicalGen() but for Hexahedra - */ - -////////////////////// -// Inline Functions // -////////////////////// - -inline BasisLocal* BasisGenerator::generate(size_t elementType, - size_t basisType, - size_t order){ - - return BasisGenerator::generate(elementType, - basisType, - order, - "hierarchical"); -} - -#endif diff --git a/FunctionSpace/BasisHierarchical0Form.cpp b/FunctionSpace/BasisHierarchical0Form.cpp deleted file mode 100644 index df97eebade7b5e38655d354e7198356ddf5c84cd..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisHierarchical0Form.cpp +++ /dev/null @@ -1,250 +0,0 @@ -#include <sstream> -#include "Exception.h" -#include "ReferenceSpaceManager.h" - -#include "BasisHierarchical0Form.h" - -using namespace std; - -BasisHierarchical0Form::BasisHierarchical0Form(void){ - // Scalar Basis ? // - scalar = true; - - // 0-Form // - form = 0; - - // Grad Basis // - hasGrad = false; - grad = NULL; - - // PreEvaluation // - preEvaluated = false; - preEvaluatedGrad = false; - - preEvaluatedFunction = NULL; - preEvaluatedGradFunction = NULL; -} - -BasisHierarchical0Form::~BasisHierarchical0Form(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(getType()); - - // Grad Basis // - if(hasGrad){ - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete grad[i][j]; - - delete[] grad[i]; - } - - delete[] grad; - } - - // PreEvaluation // - if(preEvaluated){ - for(size_t i = 0; i < nOrientation; i++) - delete preEvaluatedFunction[i]; - - delete[] preEvaluatedFunction; - } - - if(preEvaluatedGrad){ - for(size_t i = 0; i < nOrientation; i++) - delete preEvaluatedGradFunction[i]; - - delete[] preEvaluatedGradFunction; - } -} - -void BasisHierarchical0Form:: -getFunctions(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const{ - - // Define Orientation // - const size_t orientation = ReferenceSpaceManager::getOrientation(element); - - // Fill Matrix // - for(size_t i = 0; i < nFunction; i++) - retValues(i, 0) = basis[orientation][i]->at(u, v, w); -} - -void BasisHierarchical0Form:: -getFunctions(fullMatrix<double>& retValues, - size_t orientation, - double u, double v, double w) const{ - - // Fill Matrix // - for(size_t i = 0; i < nFunction; i++) - retValues(i, 0) = basis[orientation][i]->at(u, v, w); -} - -void BasisHierarchical0Form::getDerivative(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const{ - // Get Grad // - if(!hasGrad) - getGrad(); - - // Define Orientation // - const size_t orientation = ReferenceSpaceManager::getOrientation(element); - - // Fill Matrix // - for(size_t i = 0; i < nFunction; i++){ - retValues(i, 0) = grad[orientation][i]->at(0).at(u, v, w); - retValues(i, 1) = grad[orientation][i]->at(1).at(u, v, w); - retValues(i, 2) = grad[orientation][i]->at(2).at(u, v, w); - } -} - -void BasisHierarchical0Form:: -preEvaluateFunctions(const fullMatrix<double>& point) const{ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(getType()); - - // Delete if older // - if(preEvaluated){ - for(size_t i = 0; i < nOrientation; i++) - delete preEvaluatedFunction[i]; - - delete[] preEvaluatedFunction; - } - - // Alloc // - const size_t nPoint = point.size1(); - preEvaluatedFunction = new fullMatrix<double>*[nOrientation]; - - for(size_t i = 0; i < nOrientation; i++) - preEvaluatedFunction[i] = new fullMatrix<double>(nFunction, nPoint); - - // Fill Matrix // - for(size_t i = 0; i < nOrientation; i++) - for(size_t j = 0; j < nFunction; j++) - for(size_t k = 0; k < nPoint; k++) - (*preEvaluatedFunction[i])(j, k) = basis[i][j]->at(point(k, 0), - point(k, 1), - point(k, 2)); - // PreEvaluated // - preEvaluated = true; -} - -void BasisHierarchical0Form:: -preEvaluateDerivatives(const fullMatrix<double>& point) const{ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(getType()); - - // Build Grad // - if(!hasGrad) - getGrad(); - - // Delete if older // - if(preEvaluatedGrad){ - for(size_t i = 0; i < nOrientation; i++) - delete preEvaluatedGradFunction[i]; - - delete[] preEvaluatedGradFunction; - } - - // Alloc // - const size_t nPoint = point.size1(); - const size_t nPoint3 = nPoint * 3; - preEvaluatedGradFunction = new fullMatrix<double>*[nOrientation]; - - for(size_t i = 0; i < nOrientation; i++) - preEvaluatedGradFunction[i] = new fullMatrix<double>(nFunction, nPoint3); - - // Fill Matrix // - fullVector<double> tmp(3); - - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++){ - for(size_t k = 0; k < nPoint; k++){ - tmp = Polynomial::at(*grad[i][j], - point(k, 0), - point(k, 1), - point(k, 2)); - - (*preEvaluatedGradFunction[i])(j, 3 * k) = tmp(0); - (*preEvaluatedGradFunction[i])(j, 3 * k + 1) = tmp(1); - (*preEvaluatedGradFunction[i])(j, 3 * k + 2) = tmp(2); - } - } - } - - // PreEvaluated // - preEvaluatedGrad = true; -} - -const fullMatrix<double>& BasisHierarchical0Form:: -getPreEvaluatedFunctions(const MElement& element) const{ - return - getPreEvaluatedFunctions(ReferenceSpaceManager::getOrientation(element)); -} - -const fullMatrix<double>& BasisHierarchical0Form:: -getPreEvaluatedDerivatives(const MElement& element) const{ - return - getPreEvaluatedDerivatives(ReferenceSpaceManager::getOrientation(element)); -} - -const fullMatrix<double>& BasisHierarchical0Form:: -getPreEvaluatedFunctions(size_t orientation) const{ - if(!preEvaluated) - throw Exception - ("getPreEvaluatedFunction: function has not been preEvaluated"); - - return *preEvaluatedFunction[orientation]; -} - -const fullMatrix<double>& BasisHierarchical0Form:: -getPreEvaluatedDerivatives(size_t orientation) const{ - if(!preEvaluatedGrad) - throw Exception - ("getPreEvaluatedDerivative: gradient has not been preEvaluated"); - - return *preEvaluatedGradFunction[orientation]; -} - -void BasisHierarchical0Form::getGrad(void) const{ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(getType()); - - // Alloc // - grad = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - grad[s] = new vector<Polynomial>*[nFunction]; - - // Grad // - for(size_t s = 0; s < nOrientation; s++) - for(size_t f = 0 ; f < nFunction; f++) - grad[s][f] = new vector<Polynomial>(basis[s][f]->gradient()); - - // Has Grad // - hasGrad = true; -} - -string BasisHierarchical0Form::toString(void) const{ - stringstream stream; - size_t i = 0; - const size_t refSpace = 0; - - stream << "Vertex Based:" << endl; - for(; i < nVertex; i++) - stream << "f(" << i + 1 << ") = " - << basis[refSpace][i]->toString() << endl; - - stream << "Edge Based:" << endl; - for(; i < nVertex + nEdge; i++) - stream << "f(" << i + 1 << ") = " - << basis[refSpace][i]->toString() << endl; - - stream << "Face Based:" << endl; - for(; i < nVertex + nEdge + nFace; i++) - stream << "f(" << i + 1 << ") = " - << basis[refSpace][i]->toString() << endl; - - stream << "Cell Based:" << endl; - for(; i < nVertex + nEdge + nFace + nCell; i++) - stream << "f(" << i + 1 << ") = " - << basis[refSpace][i]->toString() << endl; - - return stream.str(); -} diff --git a/FunctionSpace/BasisHierarchical0Form.h b/FunctionSpace/BasisHierarchical0Form.h deleted file mode 100644 index 373cf5687eed6e2b36ceaee4f039ddb6da67f7a4..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisHierarchical0Form.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _BASISHIERARCHICAL0FORM_H_ -#define _BASISHIERARCHICAL0FORM_H_ - -#include "BasisLocal.h" -#include "Polynomial.h" - -/** - @interface BasisHierarchical0Form - @brief Interface for hierarchical 0-form local Basis - - This is an interface for hierarchical 0-form local Basis.@n -*/ - -class BasisHierarchical0Form: public BasisLocal{ - protected: - // Basis // - Polynomial*** basis; - - // Grad Basis // - mutable bool hasGrad; - mutable std::vector<Polynomial>*** grad; - - // PreEvaluation // - mutable bool preEvaluated; - mutable bool preEvaluatedGrad; - - mutable fullMatrix<double>** preEvaluatedFunction; - mutable fullMatrix<double>** preEvaluatedGradFunction; - - public: - virtual ~BasisHierarchical0Form(void); - - virtual void getFunctions(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const; - - virtual void getFunctions(fullMatrix<double>& retValues, - size_t orientation, - double u, double v, double w) const; - - virtual void getDerivative(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const; - - virtual void preEvaluateFunctions(const fullMatrix<double>& point) const; - virtual void preEvaluateDerivatives(const fullMatrix<double>& point) const; - - virtual const fullMatrix<double>& - getPreEvaluatedFunctions(const MElement& element) const; - - virtual const fullMatrix<double>& - getPreEvaluatedDerivatives(const MElement& element) const; - - virtual const fullMatrix<double>& - getPreEvaluatedFunctions(size_t orientation) const; - - virtual const fullMatrix<double>& - getPreEvaluatedDerivatives(size_t orientation) const; - - virtual std::string toString(void) const; - - protected: - BasisHierarchical0Form(void); - - private: - void getGrad(void) const; -}; - -/** - @internal - @fn BasisHierarchical0Form::BasisHierarchical0Form - Instanciates an new BasisHierarchical0Form - @endinternal - ** - - @fn BasisHierarchical0Form::~BasisHierarchical0Form - Deletes this BasisHierarchical0Form - */ - -#endif diff --git a/FunctionSpace/BasisHierarchical1Form.cpp b/FunctionSpace/BasisHierarchical1Form.cpp deleted file mode 100644 index 680abc374997b27139683186587788d8e71c68f4..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisHierarchical1Form.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#include <sstream> -#include "Exception.h" -#include "ReferenceSpaceManager.h" - -#include "BasisHierarchical1Form.h" - -using namespace std; - -BasisHierarchical1Form::BasisHierarchical1Form(void){ - // Scalar Basis ?// - scalar = false; - - // 1-Form // - form = 1; - - // Curl Basis // - hasCurl = false; - curl = NULL; - - // PreEvaluation // - preEvaluated = false; - preEvaluatedCurl = false; - - preEvaluatedFunction = NULL; - preEvaluatedCurlFunction = NULL; -} - -BasisHierarchical1Form::~BasisHierarchical1Form(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(getType()); - - // Curl Basis // - if(hasCurl){ - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete curl[i][j]; - - delete[] curl[i]; - } - - delete[] curl; - } - - // PreEvaluation // - if(preEvaluated){ - for(size_t i = 0; i < nOrientation; i++) - delete preEvaluatedFunction[i]; - - delete[] preEvaluatedFunction; - } - - if(preEvaluatedCurl){ - for(size_t i = 0; i < nOrientation; i++) - delete preEvaluatedCurlFunction[i]; - - delete[] preEvaluatedCurlFunction; - } -} - -void BasisHierarchical1Form:: -getFunctions(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const{ - - // Define Orientation // - size_t orientation = ReferenceSpaceManager::getOrientation(element); - - // Fill Vector // - for(size_t i = 0; i < nFunction; i++){ - fullVector<double> eval = Polynomial::at(*basis[orientation][i], u, v, w); - - retValues(i, 0) = eval(0); - retValues(i, 1) = eval(1); - retValues(i, 2) = eval(2); - } -} - -void BasisHierarchical1Form:: -getFunctions(fullMatrix<double>& retValues, - size_t orientation, - double u, double v, double w) const{ - - // Fill Vector // - for(size_t i = 0; i < nFunction; i++){ - fullVector<double> eval = Polynomial::at(*basis[orientation][i], u, v, w); - - retValues(i, 0) = eval(0); - retValues(i, 1) = eval(1); - retValues(i, 2) = eval(2); - } -} - -void BasisHierarchical1Form::getDerivative(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const{ - // Build Curl // - if(!hasCurl) - getCurl(); - - // Define Orientation // - const size_t orientation = ReferenceSpaceManager::getOrientation(element); - - // Fill Matrix // - for(size_t i = 0; i < nFunction; i++){ - retValues(i, 0) = curl[orientation][i]->at(0).at(u, v, w); - retValues(i, 1) = curl[orientation][i]->at(1).at(u, v, w); - retValues(i, 2) = curl[orientation][i]->at(2).at(u, v, w); - } -} - -void BasisHierarchical1Form:: -preEvaluateFunctions(const fullMatrix<double>& point) const{ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(getType()); - - // Delete if older // - if(preEvaluated){ - for(size_t i = 0; i < nOrientation; i++) - delete preEvaluatedFunction[i]; - - delete[] preEvaluatedFunction; - } - - // Alloc // - const size_t nPoint = point.size1(); - const size_t nPoint3 = nPoint * 3; - preEvaluatedFunction = new fullMatrix<double>*[nOrientation]; - - for(size_t i = 0; i < nOrientation; i++) - preEvaluatedFunction[i] = new fullMatrix<double>(nFunction, nPoint3); - - // Fill Matrix // - fullVector<double> tmp(3); - - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++){ - for(size_t k = 0; k < nPoint; k++){ - tmp = Polynomial::at(*basis[i][j], - point(k, 0), - point(k, 1), - point(k, 2)); - - (*preEvaluatedFunction[i])(j, 3 * k) = tmp(0); - (*preEvaluatedFunction[i])(j, 3 * k + 1) = tmp(1); - (*preEvaluatedFunction[i])(j, 3 * k + 2) = tmp(2); - } - } - } - - // PreEvaluated // - preEvaluated = true; -} - -void BasisHierarchical1Form:: -preEvaluateDerivatives(const fullMatrix<double>& point) const{ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(getType()); - - // Build Curl // - if(!hasCurl) - getCurl(); - - // Delete if older // - if(preEvaluatedCurl){ - for(size_t i = 0; i < nOrientation; i++) - delete preEvaluatedCurlFunction[i]; - - delete[] preEvaluatedCurlFunction; - } - - // Alloc // - const size_t nPoint = point.size1(); - const size_t nPoint3 = nPoint * 3; - preEvaluatedCurlFunction = new fullMatrix<double>*[nOrientation]; - - for(size_t i = 0; i < nOrientation; i++) - preEvaluatedCurlFunction[i] = new fullMatrix<double>(nFunction, nPoint3); - - // Fill Matrix // - fullVector<double> tmp(3); - - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++){ - for(size_t k = 0; k < nPoint; k++){ - tmp = Polynomial::at(*curl[i][j], - point(k, 0), - point(k, 1), - point(k, 2)); - - (*preEvaluatedCurlFunction[i])(j, 3 * k) = tmp(0); - (*preEvaluatedCurlFunction[i])(j, 3 * k + 1) = tmp(1); - (*preEvaluatedCurlFunction[i])(j, 3 * k + 2) = tmp(2); - } - } - } - - // PreEvaluated // - preEvaluatedCurl = true; -} - -const fullMatrix<double>& BasisHierarchical1Form:: -getPreEvaluatedFunctions(const MElement& element) const{ - return - getPreEvaluatedFunctions(ReferenceSpaceManager::getOrientation(element)); -} - -const fullMatrix<double>& BasisHierarchical1Form:: -getPreEvaluatedDerivatives(const MElement& element) const{ - return - getPreEvaluatedDerivatives(ReferenceSpaceManager::getOrientation(element)); -} - -const fullMatrix<double>& BasisHierarchical1Form:: -getPreEvaluatedFunctions(size_t orientation) const{ - if(!preEvaluated) - throw - Exception("getPreEvaluatedFunction: function has not been preEvaluated"); - - return *preEvaluatedFunction[orientation]; -} - -const fullMatrix<double>& BasisHierarchical1Form:: -getPreEvaluatedDerivatives(size_t orientation) const{ - if(!preEvaluatedCurl) - throw - Exception("getPreEvaluatedDerivative: curl has not been preEvaluated"); - - return *preEvaluatedCurlFunction[orientation]; -} - -void BasisHierarchical1Form::getCurl(void) const{ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(getType()); - - // Alloc // - curl = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - curl[s] = new vector<Polynomial>*[nFunction]; - - // Curl // - for(size_t s = 0; s < nOrientation; s++) - for(size_t f = 0 ; f < nFunction; f++) - curl[s][f] = new vector<Polynomial>(Polynomial::curl(*basis[s][f])); - - // Has Curl // - hasCurl = true; -} - -string BasisHierarchical1Form::toString(void) const{ - stringstream stream; - size_t i = 0; - const size_t refSpace = 0; - - stream << "Vertex Based:" << endl; - for(; i < nVertex; i++) - stream << "f(" << i + 1 << ") = " << endl - << "\t[ " << (*basis[refSpace][i])[0].toString() << " ]" << endl - << "\t[ " << (*basis[refSpace][i])[1].toString() << " ]" << endl - << "\t[ " << (*basis[refSpace][i])[2].toString() << " ]" << endl; - - stream << "Edge Based:" << endl; - for(; i < nVertex + nEdge; i++) - stream << " f(" << i + 1 << ") = " << endl - << "\t[ " << (*basis[refSpace][i])[0].toString() << " ]" << endl - << "\t[ " << (*basis[refSpace][i])[1].toString() << " ]" << endl - << "\t[ " << (*basis[refSpace][i])[2].toString() << " ]" << endl; - - stream << "Face Based:" << endl; - for(; i < nVertex + nEdge + nFace; i++) - stream << " f(" << i + 1 << ") = " << endl - << "\t[ " << (*basis[refSpace][i])[0].toString() << " ]" << endl - << "\t[ " << (*basis[refSpace][i])[1].toString() << " ]" << endl - << "\t[ " << (*basis[refSpace][i])[2].toString() << " ]" << endl; - - stream << "Cell Based:" << endl; - for(; i < nVertex + nEdge + nFace + nCell; i++) - stream << " f(" << i + 1 << ") = " << endl - << "\t[ " << (*basis[refSpace][i])[0].toString() << " ]" << endl - << "\t[ " << (*basis[refSpace][i])[1].toString() << " ]" << endl - << "\t[ " << (*basis[refSpace][i])[2].toString() << " ]" << endl; - - return stream.str(); -} diff --git a/FunctionSpace/BasisHierarchical1Form.h b/FunctionSpace/BasisHierarchical1Form.h deleted file mode 100644 index 84e5be34734b9c0bd346704edb99cbe75cbd7577..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisHierarchical1Form.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _BASISHIERARCHICAL1FORM_H_ -#define _BASISHIERARCHICAL1FORM_H_ - -#include "BasisLocal.h" -#include "Polynomial.h" - -/** - @interface BasisHierarchical1Form - @brief Interface for hierarchical 1-form local Basis - - This is an interface for hierarchical 1-form local Basis.@n -*/ - -class BasisHierarchical1Form: public BasisLocal{ - protected: - // Basis // - std::vector<Polynomial>*** basis; - - // Curl Basis // - mutable bool hasCurl; - mutable std::vector<Polynomial>*** curl; - - // PreEvaluation // - mutable bool preEvaluated; - mutable bool preEvaluatedCurl; - - mutable fullMatrix<double>** preEvaluatedFunction; - mutable fullMatrix<double>** preEvaluatedCurlFunction; - - public: - virtual ~BasisHierarchical1Form(void); - - virtual void getFunctions(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const; - - virtual void getFunctions(fullMatrix<double>& retValues, - size_t orientation, - double u, double v, double w) const; - - virtual void getDerivative(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const; - - virtual void preEvaluateFunctions(const fullMatrix<double>& point) const; - virtual void preEvaluateDerivatives(const fullMatrix<double>& point) const; - - virtual const fullMatrix<double>& - getPreEvaluatedFunctions(const MElement& element) const; - - virtual const fullMatrix<double>& - getPreEvaluatedDerivatives(const MElement& element) const; - - virtual const fullMatrix<double>& - getPreEvaluatedFunctions(size_t orientation) const; - - virtual const fullMatrix<double>& - getPreEvaluatedDerivatives(size_t orientation) const; - - virtual std::string toString(void) const; - - protected: - BasisHierarchical1Form(void); - - private: - void getCurl(void) const; -}; - -/** - @internal - @fn BasisHierarchical1Form::BasisHierarchical1Form - Instanciates an new BasisHierarchical1Form - @endinternal - ** - - @fn BasisHierarchical1Form::~BasisHierarchical1Form - Deletes this BasisHierarchical1Form - */ - -#endif diff --git a/FunctionSpace/BasisLagrange.cpp b/FunctionSpace/BasisLagrange.cpp deleted file mode 100644 index 461c6579f48acc5387250876c976934087cccf8c..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisLagrange.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include "ReferenceSpaceManager.h" -#include "BasisLagrange.h" -#include "Exception.h" - -using namespace std; - -BasisLagrange::BasisLagrange(void){ - scalar = true; - form = 0; - - preEvaluated = false; - preEvaluatedGrad = false; - - preEvaluatedFunction = NULL; - preEvaluatedGradFunction = NULL; -} - -BasisLagrange::~BasisLagrange(void){ - if(preEvaluated) - delete preEvaluatedFunction; - - if(preEvaluatedGrad) - delete preEvaluatedGradFunction; -} - -void BasisLagrange:: -getFunctions(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const{ - - // Fill Matrix // - fullMatrix<double> tmp; - fullMatrix<double> point(1, 3); - point(0, 0) = u; - point(0, 1) = v; - point(0, 2) = w; - - lBasis->f(point, tmp); - - // Transpose 'tmp': otherwise not coherent with df !! - retValues = tmp.transpose(); - - // Permute retValues, accordingly to ReferenceSpace - permutation(ReferenceSpaceManager::getOrientation(element), retValues); -} - -void BasisLagrange:: -getFunctions(fullMatrix<double>& retValues, - size_t orientation, - double u, double v, double w) const{ - - // Fill Matrix // - fullMatrix<double> tmp; - fullMatrix<double> point(1, 3); - point(0, 0) = u; - point(0, 1) = v; - point(0, 2) = w; - - lBasis->f(point, tmp); - - // Transpose 'tmp': otherwise not coherent with df !! - retValues = tmp.transpose(); - - // Permute retValues, accordingly to ReferenceSpace - permutation(orientation, retValues); -} - -void BasisLagrange::getDerivative(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const{ - throw Exception("Not Implemented"); -} - -void BasisLagrange::preEvaluateFunctions(const fullMatrix<double>& point) const{ - // Delete if older // - if(preEvaluated) - delete preEvaluatedFunction; - - // Fill Matrix // - fullMatrix<double> tmp; - lBasis->f(point, tmp); - - // Transpose 'tmp': otherwise not coherent with df !! - preEvaluatedFunction = new fullMatrix<double>(tmp.transpose()); - - // PreEvaluated // - preEvaluated = true; -} - -void BasisLagrange:: -preEvaluateDerivatives(const fullMatrix<double>& point) const{ - // Delete if older // - if(preEvaluatedGrad) - delete preEvaluatedGradFunction; - - // Alloc // - preEvaluatedGradFunction = new fullMatrix<double>; - - // Fill Matrix // - lBasis->df(point, *preEvaluatedGradFunction); - - // PreEvaluated // - preEvaluatedGrad = true; -} - -const fullMatrix<double>& -BasisLagrange::getPreEvaluatedFunctions(const MElement& element) const{ - return *preEvaluatedFunction; -} - -const fullMatrix<double>& -BasisLagrange::getPreEvaluatedDerivatives(const MElement& element) const{ - return *preEvaluatedGradFunction; -} - -const fullMatrix<double>& -BasisLagrange::getPreEvaluatedFunctions(size_t orientation) const{ - return *preEvaluatedFunction; -} - -const fullMatrix<double>& -BasisLagrange::getPreEvaluatedDerivatives(size_t orientation) const{ - return *preEvaluatedGradFunction; -} - -vector<double> BasisLagrange:: -project(const MElement& element, - const std::vector<double>& coef, - const FunctionSpaceScalar& fSpace){ - - // Init New Coefs // - const size_t size = lPoint->size1(); - const size_t dim = lPoint->size2(); - - vector<double> newCoef(size); - - // Interpolation at Lagrange Points // - for(size_t i = 0; i < size; i++){ - fullVector<double> uvw(3); - - if(dim > 0) - uvw(0) = (*lPoint)(i, 0); - else - uvw(0) = 0; - - if(dim > 1) - uvw(1) = (*lPoint)(i, 1); - else - uvw(1) = 0; - - if(dim > 2) - uvw(2) = (*lPoint)(i, 2); - else - uvw(2) = 0; - - newCoef[i] = fSpace.interpolateInRefSpace(element, - coef, - uvw); - } - - // Return ; - return newCoef; -} - -std::vector<double> BasisLagrange:: -project(const MElement& element, - const std::vector<double>& coef, - const FunctionSpaceVector& fSpace){ - - // Init New Coefs // - const size_t size = lPoint->size1(); - const size_t dim = lPoint->size2(); - - vector<double> newCoef(size * 3); - fullVector<double> tmp(3); - - // Interpolation at Lagrange Points // - for(size_t i = 0; i < size; i++){ - fullVector<double> uvw(3); - - if(dim > 0) - uvw(0) = (*lPoint)(i, 0); - else - uvw(0) = 0; - - if(dim > 1) - uvw(1) = (*lPoint)(i, 1); - else - uvw(1) = 0; - - if(dim > 2) - uvw(2) = (*lPoint)(i, 2); - else - uvw(2) = 0; - - tmp = fSpace.interpolateInRefSpace(element, - coef, - uvw); - newCoef[i * 3 + 0] = tmp(0); - newCoef[i * 3 + 1] = tmp(1); - newCoef[i * 3 + 2] = tmp(2); - } - - // Return ; - return newCoef; -} - -void BasisLagrange::permutation(size_t orientation, - fullMatrix<double>& function) const{ -} - -std::string BasisLagrange::toString(void) const{ - return std::string("BasisLagrange::toString() not Implemented"); -} diff --git a/FunctionSpace/BasisLagrange.h b/FunctionSpace/BasisLagrange.h deleted file mode 100644 index c32d6a581efaac6e08f82effb27f37d225563780..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisLagrange.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef _BASISLAGRANGE_H_ -#define _BASISLAGRANGE_H_ - -#include "BasisLocal.h" -#include "FunctionSpaceScalar.h" -#include "FunctionSpaceVector.h" -#include "fullMatrix.h" -#include "polynomialBasis.h" - -/** - @interface BasisLagrange - @brief Interface for Lagrange Basis - - This is an interface for Lagrange Basis. - - These local scalar Basis allow a coefficient matrix and a monomial matrix - to be consulted. - - Coefficients from an other Basis can be projected into a Lagrange Basis. -*/ - -class BasisLagrange: public BasisLocal{ - protected: - polynomialBasis* lBasis; // Lagrange Basis - fullMatrix<double>* lPoint; // Lagrange Points - - // PreEvaluation // - mutable bool preEvaluated; - mutable bool preEvaluatedGrad; - - mutable fullMatrix<double>* preEvaluatedFunction; - mutable fullMatrix<double>* preEvaluatedGradFunction; - - public: - virtual ~BasisLagrange(void); - - virtual void getFunctions(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const; - - virtual void getFunctions(fullMatrix<double>& retValues, - size_t orientation, - double u, double v, double w) const; - - virtual void getDerivative(fullMatrix<double>& retValues, - const MElement& element, - double u, double v, double w) const; - - virtual void preEvaluateFunctions(const fullMatrix<double>& point) const; - virtual void preEvaluateDerivatives(const fullMatrix<double>& point) const; - - virtual const fullMatrix<double>& - getPreEvaluatedFunctions(const MElement& element) const; - - virtual const fullMatrix<double>& - getPreEvaluatedDerivatives(const MElement& element) const; - - virtual const fullMatrix<double>& - getPreEvaluatedFunctions(size_t orientation) const; - - virtual const fullMatrix<double>& - getPreEvaluatedDerivatives(size_t orientation) const; - - const fullMatrix<double>& getCoefficient(void) const; - const fullMatrix<double>& getMonomial(void) const; - - std::vector<double> - project(const MElement& element, - const std::vector<double>& coef, - const FunctionSpaceScalar& fSpace); - - std::vector<double> - project(const MElement& element, - const std::vector<double>& coef, - const FunctionSpaceVector& fSpace); - - virtual std::string toString(void) const; - - protected: - BasisLagrange(void); - - private: - void permutation(size_t orientation, - fullMatrix<double>& function) const; -}; - - -/** - @internal - @fn BasisLagrange::BasisLagrange - Instanciates an new BasisLagrange - @endinternal - ** - - @fn BasisLagrange::~BasisLagrange - Deletes this BasisLagrange - ** - - @fn BasisLagrange::getCoefficient - @return Returns the Coefficient Matrix - ** - - @fn BasisLagrange::getMonomial - @return Returns the Monomial Matrix - ** - - @fn BasisLagrange::project(const MElement&, const std::vector<double>&, const FunctionSpaceScalar&) - @param element A MElement - @param coef A vector of coefficient associated to the given element - @param fSpace The (scalar) FunctionSpace of the given coefficients - @return Returns a vector with the projection of the given coefficients - in this BasisLagrange - ** - - @fn BasisLagrange::project(const MElement&, const std::vector<double>&, const FunctionSpaceVector&) - @param element A MElement - @param coef A vector of coefficient associated to the given element - @param fSpace The (vectorial) FunctionSpace of the given coefficients - @return Returns a vector with the projection of the given coefficients - in this BasisLagrange - - The returned vector has a size three times bigger than coef, - since we need three coefficients with a Lagrange basis, - when we project a vectorial basis on it (one per direction). - - The Lagranges coefficients corresponding to the ith entry of coef - are located, in the returned vector, at the index i * 3, - with the following padding: - @li index i * 3 + 0 is the projected coefficient for direction x - @li index i * 3 + 1 is the projected coefficient for direction y - @li index i * 3 + 2 is the projected coefficient for direction z - */ - -////////////////////// -// Inline Functions // -////////////////////// - -inline const fullMatrix<double>& BasisLagrange:: -getCoefficient(void) const{ - return lBasis->coefficients; -} - -inline const fullMatrix<double>& BasisLagrange:: -getMonomial(void) const{ - return lBasis->monomials; -} - -#endif diff --git a/FunctionSpace/BasisLocal.cpp b/FunctionSpace/BasisLocal.cpp deleted file mode 100644 index f72b7f36bbc5fcfd6b405ce3abbe7d5e4df7fab2..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisLocal.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "BasisLocal.h" - -BasisLocal::BasisLocal(void){ - local = true; -} - -BasisLocal::~BasisLocal(void){ -} diff --git a/FunctionSpace/BasisLocal.h b/FunctionSpace/BasisLocal.h deleted file mode 100644 index c1b9bba40073d2ee89a43bbea92558ab67e757b0..0000000000000000000000000000000000000000 --- a/FunctionSpace/BasisLocal.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _BASISLOCAL_H_ -#define _BASISLOCAL_H_ - -#include "Basis.h" - -/** - @interface BasisLocal - @brief Common interface of all local Basis - - This class is the common interface for all local Basis. - */ - -class BasisLocal: public Basis{ - public: - //! Deletes this BasisLocal - //! - virtual ~BasisLocal(void); - - protected: - //! @internal - //! Instantiate a new BasisLocal - //! - //! @endinternal - BasisLocal(void); -}; - -#endif diff --git a/FunctionSpace/CMakeLists.txt b/FunctionSpace/CMakeLists.txt deleted file mode 100644 index 167742fe33d94a38effd649628374203f7950106..0000000000000000000000000000000000000000 --- a/FunctionSpace/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -# Gmsh - Copyright (C) 1997-2016 C. Geuzaine, J.-F. Remacle -# -# See the LICENSE.txt file for license information. Please report all -# bugs and problems to the public mailing list <gmsh@onelab.info>. - -set(SRC - Polynomial.cpp - Legendre.cpp - - PermutationTree.cpp - - ReferenceSpace.cpp - LineReferenceSpace.cpp - TriReferenceSpace.cpp - QuadReferenceSpace.cpp - TetReferenceSpace.cpp - HexReferenceSpace.cpp - PyrReferenceSpace.cpp - PriReferenceSpace.cpp - - ReferenceSpaceManager.cpp - - Basis.cpp - BasisLocal.cpp - BasisGenerator.cpp - - BasisLagrange.cpp - BasisHierarchical0Form.cpp - BasisHierarchical1Form.cpp - - LineNodeBasis.cpp - LineEdgeBasis.cpp - LineNedelecBasis.cpp - LineLagrangeBasis.cpp - - TriNodeBasis.cpp - TriEdgeBasis.cpp - TriNedelecBasis.cpp - TriLagrangeBasis.cpp - - QuadNodeBasis.cpp - QuadEdgeBasis.cpp - QuadNedelecBasis.cpp - QuadLagrangeBasis.cpp - - TetNodeBasis.cpp - TetEdgeBasis.cpp - TetNedelecBasis.cpp - TetLagrangeBasis.cpp - - HexNodeBasis.cpp - HexEdgeBasis.cpp - HexLagrangeBasis.cpp - - FunctionSpace.cpp - FunctionSpaceScalar.cpp - FunctionSpaceVector.cpp -) - -file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h) -append_gmsh_src(FunctionSpace "${SRC};${HDR}") - -## Compatibility with SmallFEM (TO BE REMOVED !!!) -add_sources_in_gmsh(FunctionSpace "${SRC}") diff --git a/FunctionSpace/FunctionSpace.cpp b/FunctionSpace/FunctionSpace.cpp deleted file mode 100644 index 3a7d3fc537943896f6cc5be4c9a39c4d136b6fa7..0000000000000000000000000000000000000000 --- a/FunctionSpace/FunctionSpace.cpp +++ /dev/null @@ -1,322 +0,0 @@ -#include <sstream> - -#include "ReferenceSpaceManager.h" -#include "BasisGenerator.h" -#include "ElementType.h" - -#include "FunctionSpace.h" - -using namespace std; - -const size_t FunctionSpace::nGeoType = 9; - size_t FunctionSpace::nxtOffset = 0; - -FunctionSpace::FunctionSpace(void){ - // Clear // - dof.clear(); - rejected.clear(); - - // Alloc Basis Vector for all possible geomtrical types // - basis.resize(nGeoType, NULL); - - // Alloc Function per Entity // - fPerVertex.resize(nGeoType, 0); - fPerEdge.resize(nGeoType , 0); - fPerFace.resize(nGeoType , 0); - fPerCell.resize(nGeoType , 0); -} - -FunctionSpace::~FunctionSpace(void){ - for(size_t i = 0; i < nGeoType; i++) - if(basis[i]) - delete basis[i]; -} - -void FunctionSpace::build(const vector<const GroupOfElement*>& goe, - const vector<const GroupOfElement*>& exl, - string family){ - // Save Dof type offset // - offset = nxtOffset; - - // Save Mesh & Get number of GoE// - const size_t nGoe = goe.size(); - const size_t nExl = exl.size(); - this->mesh = &(goe[0]->getMesh()); - - // Build Bases // - for(size_t i = 0; i < nGoe; i++) - getBases(*goe[i], family); - - // Build Dof to reject // - for(size_t i = 0; i < nExl; i++) - getRejec(*exl[i]); - - // Build Dof // - for(size_t i = 0; i < nGoe; i++) - getMyDof(*goe[i]); - - // Next Offset for next FunctionSpace - nxtOffset = findMaxType() + 1; -} - -void FunctionSpace::getBases(const GroupOfElement& goe, string family){ - // Generate Bases // - const vector<size_t>& geoTypeStat = goe.getTypeStats(); - const size_t nGeoType = geoTypeStat.size(); - - for(size_t i = 0; i < nGeoType; i++) - if(geoTypeStat[i] != 0 && basis[i] == NULL) - basis[i] = BasisGenerator::generate(i, form, order, family); - - // Get Number of Function per Entity // - for(size_t i = 0; i < nGeoType; i++){ - if(geoTypeStat[i] != 0 && fPerVertex[i] == 0){ - int nVertex = ReferenceSpaceManager::getNVertex(i); - int nEdge = ReferenceSpaceManager::getNEdge(i); - int nFace = ReferenceSpaceManager::getNFace(i); - - fPerVertex[i] = basis[i]->getNVertexBased() / nVertex; - - if(nEdge) - fPerEdge[i] = this->basis[i]->getNEdgeBased() / nEdge; - else - fPerEdge[i] = 0; - - if(nFace) - fPerFace[i] = this->basis[i]->getNFaceBased() / nFace; - else - fPerFace[i] = 0; - - fPerCell[i] = this->basis[i]->getNCellBased(); - } - } -} - -void FunctionSpace::getMyDof(const GroupOfElement& goe){ - // Get Elements // - const size_t nElement = goe.getNumber(); - const vector<const MElement*>& element = goe.getAll(); - - // Push GroupOfElement into map // - pair<size_t, vector<vector<Dof> > > toInsert; - pair<map<size_t, vector<vector<Dof> > >::iterator, bool> isInserted; - - toInsert.first = goe.getId(); - toInsert.second = vector<vector<Dof> >(0); - isInserted = dof.insert(toInsert); - - if(!isInserted.second) - throw Exception("FunctionSpace: cannot computed Dofs for GroupOfElement %d", - goe.getId()); - - // Reference & Allocate // - vector<vector<Dof> >& myDof = isInserted.first->second; - myDof.resize(nElement); - - // Create Dofs // - for(size_t i = 0; i < nElement; i++) - getKeys(*(element[i]), myDof[i]); -} - -void FunctionSpace::getRejec(const GroupOfElement& goe){ - // Get Elements // - const size_t nElement = goe.getNumber(); - const vector<const MElement*>& element = goe.getAll(); - - // Allocate // - vector<vector<Dof> > myDof(nElement); - - // Create Dofs // - for(size_t i = 0; i < nElement; i++) - getKeys(*(element[i]), myDof[i]); - - // Push in rejection map // - for(size_t i = 0; i < nElement; i++){ - size_t nDof = myDof[i].size(); - - for(size_t j = 0; j < nDof; j++) - rejected.insert(myDof[i][j]); - } -} - -size_t FunctionSpace::findMaxType(void){ - // Maximum type // - size_t maxType = 0; - - // Iterate on GroupOfElement Id // - map<size_t, vector<vector<Dof> > >::iterator it = dof.begin(); - map<size_t, vector<vector<Dof> > >::iterator end = dof.end(); - - size_t nElement; - size_t nDof; - size_t type; - - for(; it != end; it++){ - // Iterate on Elements of this GroupOfElement // - nElement = it->second.size(); - - for(size_t e = 0; e < nElement; e++){ - // Iterate on Dofs of this Element // - nDof = it->second[e].size(); - - for(size_t d = 0; d < nDof; d++){ - // Check if not a RejectedDof - if(it->second[e][d] != Dof::RejectedDof()){ - // This Dof Type - type = it->second[e][d].getType(); - - // If this Dof type is bigger, it becomes the new 'maxType' - if(type > maxType) - maxType = type; - } - } - } - } - - // Return maxType // - return maxType; -} - -void FunctionSpace::getUnorderedKeys(const MElement& elem, - std::vector<Dof>& dof) const{ - // Const_Cast // - MElement& element = const_cast<MElement&>(elem); - - // Vertex, Edge & Face // - const size_t nVertex = element.getNumPrimaryVertices(); - const size_t nEdge = element.getNumEdges(); - const size_t nFace = element.getNumFaces(); - - vector<MVertex*> vertex(nVertex); - vector<MEdge> edge(nEdge); - vector<MFace> face(nFace); - - for(size_t i = 0; i < nVertex; i++) - vertex[i] = element.getVertex(i); - - for(size_t i = 0; i < nEdge; i++) - edge[i] = element.getEdge(i); - - for(size_t i = 0; i < nFace; i++) - face[i] = element.getFace(i); - - // Create Dof // - const size_t type = element.getType(); - const size_t fPerVertex = this->fPerVertex[type]; - const size_t fPerEdge = this->fPerEdge[type]; - const size_t fPerFace = this->fPerFace[type]; - const size_t fPerCell = this->fPerCell[type]; - - size_t it = 0; - size_t nDof = - fPerVertex * nVertex + - fPerEdge * nEdge + - fPerFace * nFace + - fPerCell; - - dof.resize(nDof); - - // Add Vertex Based Dof // - for(size_t i = 0; i < nVertex; i++){ - for(size_t j = 0; j < fPerVertex; j++){ - dof[it].setDof(mesh->getGlobalId(*vertex[i]), j + offset); - it++; - } - } - - // Add Edge Based Dof // - for(size_t i = 0; i < nEdge; i++){ - for(size_t j = 0; j < fPerEdge; j++){ - dof[it].setDof(mesh->getGlobalId(edge[i]), j + offset); - it++; - } - } - - // Add Face Based Dof // - for(size_t i = 0; i < nFace; i++){ - for(size_t j = 0; j < fPerFace; j++){ - dof[it].setDof(mesh->getGlobalId(face[i]), j + offset); - it++; - } - } - - // Add Cell Based Dof // - for(size_t j = 0; j < fPerCell; j++){ - dof[it].setDof(mesh->getGlobalId(element), j + offset); - it++; - } - - // Mark rejected keys // - markKeys(dof); -} - -void FunctionSpace::markKeys(vector<Dof>& dof) const{ - if(rejected.size() != 0){ - const size_t nDof = dof.size(); - - for(size_t i = 0; i < nDof; i++) - if(rejected.count(dof[i]) == 1) - dof[i] = Dof::RejectedDof(); - } -} - -void FunctionSpace::getKeys(const MElement& elem, std::vector<Dof>& dof) const{ - // Const_Cast // - MElement& element = const_cast<MElement&>(elem); - - // Create New Element With Permuted Vertices // - // Permutation - const vector<size_t>& vPerm = - ReferenceSpaceManager::getNodeIndexFromABCtoUVW(elem); - - // Permuted Vertices - const size_t nVertex = element.getNumPrimaryVertices(); - vector<MVertex*> vertex(nVertex); - - for(size_t i = 0; i < nVertex; i++) - vertex[i] = element.getVertex(vPerm[i]); - - // New Element - MElementFactory factory; - int parentTag = ElementType::ParentTypeFromTag(elem.getTypeForMSH()); - int lowOrderTag = ElementType::getTag(parentTag, 1, false); - - MElement* permElement = factory.create(lowOrderTag, vertex, element.getNum()); - - // Get Dofs from permuted Element // - getUnorderedKeys(*permElement, dof); - - // Free and Return // - delete permElement; -} - -void FunctionSpace::getKeys(const GroupOfElement& goe, - std::set<Dof>& dof) const{ - // Get Dofs // - const vector<vector<Dof> >& allDofs = getKeys(goe); - - // Add them into map // - const size_t size = allDofs.size(); - size_t nDof; - - for(size_t i = 0; i < size; i++){ - nDof = allDofs[i].size(); - - for(size_t j = 0; j < nDof; j++) - if(allDofs[i][j] != Dof::RejectedDof()) - dof.insert(allDofs[i][j]); - } -} - -const std::vector<std::vector<Dof> >& -FunctionSpace::getKeys(const GroupOfElement& goe) const{ - // Find vector of Dof from map // - map<size_t, vector<vector<Dof> > >::const_iterator it = dof.find(goe.getId()); - - if(it == dof.end()) - throw Exception("FunctionSpace: cannot find Dofs of GroupOfElement %d", - goe.getId()); - - // Return vector // - return it->second; -} diff --git a/FunctionSpace/FunctionSpace.h b/FunctionSpace/FunctionSpace.h deleted file mode 100644 index 269c474f92e821bf3e78914153e709cd3f8acf89..0000000000000000000000000000000000000000 --- a/FunctionSpace/FunctionSpace.h +++ /dev/null @@ -1,179 +0,0 @@ -#ifndef _FUNCTIONSPACE_H_ -#define _FUNCTIONSPACE_H_ - -#include <map> -#include <vector> - -#include "Dof.h" -#include "Mesh.h" -#include "Basis.h" -#include "MElement.h" -#include "Exception.h" -#include "GroupOfElement.h" - -/** - @interface FunctionSpace - @brief Common Interface of all Function Spaces - - This is the common interface of all Function Spaces. - - A FunctionSpace is defined on a support, - which is a collection of MElement%s (GroupOfElement). - - Those MElement%s must belong to the same Mesh. - - A FunctionSpace is also responsible for the generation of all - the Dof%s related to its geometrical Support. -*/ - -class Mesh; -class GroupOfElement; - -class FunctionSpace{ - protected: - // Number of possible geomtrical topologies & Dof Type offset // - static const size_t nGeoType; - static size_t nxtOffset; - - protected: - // Offset // - size_t offset; - - // Mesh // - const Mesh* mesh; - - // Basis // - std::vector<const Basis*> basis; - - std::vector<size_t> fPerVertex; - std::vector<size_t> fPerEdge; - std::vector<size_t> fPerFace; - std::vector<size_t> fPerCell; - - // Differential From & Order // - bool scalar; - size_t form; - size_t order; - - // Rejected Dofs // - std::set<Dof> rejected; - - // Dofs // - std::map<size_t, std::vector<std::vector<Dof> > > dof; - - public: - virtual ~FunctionSpace(void); - - bool isScalar(void) const; - size_t getForm(void) const; - size_t getOrder(void) const; - - const Basis& getBasis(const MElement& element) const; - const Basis& getBasis(size_t eType) const; - - void getKeys(const MElement& element, std::vector<Dof>& dof) const; - void getKeys(const GroupOfElement& goe, std::set<Dof>& dof) const; - const std::vector<std::vector<Dof> >& getKeys(const GroupOfElement& goe)const; - - protected: - FunctionSpace(void); - void build(const std::vector<const GroupOfElement*>& goe, - const std::vector<const GroupOfElement*>& exl, - std::string family); - - void getBases(const GroupOfElement& goe, std::string family); - void getMyDof(const GroupOfElement& goe); - void getRejec(const GroupOfElement& goe); - - size_t findMaxType(void); - - void getUnorderedKeys(const MElement& element, std::vector<Dof>& dof) const; - void markKeys(std::vector<Dof>& dof) const; -}; - - -/** - @internal - @fn FunctionSpace::FunctionSpace - Instatiate a new FunctionSpace - @endinternal - ** - - @fn FunctionSpace::~FunctionSpace - Deletes this FunctionSpace - ** - - @fn FunctionSpace::isScalar - @return Returns: - @li true, if this FunstionSpace is scalar - @li flase, otherwise - ** - - @fn FunctionSpace::getForm - @return Returns this FunctionSpace differential form (0, 1, 2 or 3) - ** - - @fn FunctionSpace::getOrder - @return Returns this FunctionSpace order - ** - - @fn FunctionSpace::getBasis(const MElement& element) const - @param element A MElement - @return Returns the Basis associated to the given element - ** - - @fn FunctionSpace::getBasis(size_t eType) const - @param eType A geomtrical element type tag - @return Returns the Basis associated to the given geomtrical element type tag - ** - - @fn void FunctionSpace::getKeys(const MElement&,std::vector<Dof>&) const - @param element A MElement - @param dof A vector of Dof%s - - Populates the given vector with the Dof%s associated to the given MElement - ** - - @fn void FunctionSpace::getKeys(const GroupOfElement&, std::set<Dof>&) const - @param goe A GroupOfElement - @param dof A set of Dof%s - - Populates the given set with the Dof%s associated to the MElement%s - of the given GroupOfElement - ** - - @fn const std::vector<std::vector<Dof> >& FunctionSpace::getKeys(const GroupOfElement&) const - @param goe A GroupOfElement - @return Returns a vector of vector of Dof such that: - dof[i][j] is the jth Dof of the ith element of the given GroupOfElement -*/ - -////////////////////// -// Inline Functions // -////////////////////// - -inline bool FunctionSpace::isScalar(void) const{ - return scalar; -} - -inline size_t FunctionSpace::getForm(void) const{ - return form; -} - -inline size_t FunctionSpace::getOrder(void) const{ - return order; -} - -inline const Basis& FunctionSpace::getBasis(const MElement& element) const{ - return *basis[element.getType()]; -} - -inline const Basis& FunctionSpace::getBasis(size_t eType) const{ - if(eType >= basis.size()) - throw Exception("FunctionSpace::getBasis() -- unknown geometrical type %u", - eType); - - return *basis[eType]; -} - -#endif diff --git a/FunctionSpace/FunctionSpaceScalar.cpp b/FunctionSpace/FunctionSpaceScalar.cpp deleted file mode 100644 index 818d3b17fa261ebd1d0a40ff9f57b2bfd19bfe07..0000000000000000000000000000000000000000 --- a/FunctionSpace/FunctionSpaceScalar.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "Mapper.h" -#include "Exception.h" -#include "FunctionSpaceScalar.h" - -using namespace std; - -FunctionSpaceScalar:: -FunctionSpaceScalar(const vector<const GroupOfElement*>& goe, - const vector<const GroupOfElement*>& exclude, - size_t order, string family){ - // Init - init(goe, exclude, order, family); -} - -FunctionSpaceScalar:: -FunctionSpaceScalar(const vector<const GroupOfElement*>& goe, - size_t order, string family){ - // Dummy exclude - vector<const GroupOfElement*> dummy; - - // Init - init(goe, dummy, order, family); -} - -FunctionSpaceScalar:: -FunctionSpaceScalar(const GroupOfElement& goe, size_t order, string family){ - // Temp vector - vector<const GroupOfElement*> tmp(1); - tmp[0] = &goe; - - // Dummy exclude - vector<const GroupOfElement*> dummy; - - // Init - init(tmp, dummy, order, family); -} - -FunctionSpaceScalar::~FunctionSpaceScalar(void){ - // Done by FunctionSpace -} - -void FunctionSpaceScalar::init(const vector<const GroupOfElement*>& goe, - const vector<const GroupOfElement*>& exclude, - size_t order, string family){ - // Check - if(order == 0) - throw Exception("FunctionSpaceScalar: " - "Cannot have a order 0 scalar function space"); - // Init - this->scalar = true; - this->form = 0; - this->order = order; - - // Build FunctionSpace - build(goe, exclude, family); -} - -double FunctionSpaceScalar::interpolateInABC(const MElement& element, - const vector<double>& coef, - double abc[3]) const{ - // Get Basis Functions // - const Basis& basis = getBasis(element); - const size_t nFun = basis.getNFunction(); - fullMatrix<double> fun(nFun, 1); - - basis.getFunctions(fun, element, abc[0], abc[1], abc[2]); - - // Get All Dofs - vector<Dof> myDof; - getKeys(element, myDof); - - // Interpolate (in Reference Place) // - double val = 0; - - for(size_t i = 0; i < nFun; i++){ - if(myDof[i] != Dof::RejectedDof()) - val += fun(i, 0) * coef[i]; - } - - // Return Interpolated Value // - return val; -} - -fullVector<double> FunctionSpaceScalar:: -interpolateDerivativeInABC(const MElement& element, - const vector<double>& coef, - double abc[3]) const{ - // Get Jacobian // - fullMatrix<double> invJac(3, 3); - ReferenceSpaceManager::getJacobian(element, abc[0], abc[1], abc[2], invJac); - invJac.invertInPlace(); - - // Get Basis Functions // - const Basis& basis = getBasis(element); - const size_t nFun = basis.getNFunction(); - fullMatrix<double> fun(nFun, 3); - - basis.getDerivative(fun, element, abc[0], abc[1], abc[2]); - - // Get All Dofs - vector<Dof> myDof; - getKeys(element, myDof); - - // Interpolate (in Reference Place) // - fullMatrix<double> val(1, 3); - val(0, 0) = 0; - val(0, 1) = 0; - val(0, 2) = 0; - - for(size_t i = 0; i < nFun; i++){ - if(myDof[i] != Dof::RejectedDof()){ - val(0, 0) += fun(i, 0) * coef[i]; - val(0, 1) += fun(i, 1) * coef[i]; - val(0, 2) += fun(i, 2) * coef[i]; - } - } - - // Return Interpolated Value // - fullVector<double> map(3); - Mapper::hCurl(val, 0, 0, invJac, map); - return map; -} diff --git a/FunctionSpace/FunctionSpaceScalar.h b/FunctionSpace/FunctionSpaceScalar.h deleted file mode 100644 index b24f7f38d632f579b366d6d06f53b78784f89a6a..0000000000000000000000000000000000000000 --- a/FunctionSpace/FunctionSpaceScalar.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef _FUNCTIONSPACESCALAR_H_ -#define _FUNCTIONSPACESCALAR_H_ - -#include "ReferenceSpaceManager.h" -#include "FunctionSpace.h" - -/** - @class FunctionSpaceScalar - @brief A scalar FunctionSpace - - This class is a scalar FunctionSpaces. - - A FunctionSpaceScalar can be interpolated. -*/ - - -class FunctionSpaceScalar : public FunctionSpace{ - public: - FunctionSpaceScalar(const std::vector<const GroupOfElement*>& goe, - const std::vector<const GroupOfElement*>& exclude, - size_t order, std::string family = "hierarchical"); - - FunctionSpaceScalar(const std::vector<const GroupOfElement*>& goe, - size_t order, std::string family = "hierarchical"); - - FunctionSpaceScalar(const GroupOfElement& goe, - size_t order, std::string family = "hierarchical"); - - virtual ~FunctionSpaceScalar(void); - - double - interpolate(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& xyz) const; - - double - interpolateInRefSpace(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& uvw) const; - - fullVector<double> - interpolateDerivative(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& xyz) const; - - private: - void init(const std::vector<const GroupOfElement*>& goe, - const std::vector<const GroupOfElement*>& exclude, - size_t order, std::string family); - - double interpolateInABC(const MElement& element, - const std::vector<double>& coef, - double abc[3]) const; - fullVector<double> - interpolateDerivativeInABC(const MElement& element, - const std::vector<double>& coef, - double abc[3]) const; -}; - - -/** - @fn FunctionSpaceScalar::FunctionSpaceScalar(const std::vector<const GroupOfElement*>&,const std::vector<const GroupOfElement*>&,size_t,std::string) - @param goe A vector of GroupOfElement - @param exclude An other of GroupOfElement - @param order A natural number - @param family A string (defaulted to 'hierarchical') - - Instanciates a new FunctionSpaceScalar - on the GroupOfElement%s of 'goe', - with the exception of the GroupOfElement%s of 'exclude', - and with the given order - - The instanciated FunctionSpace will use the requested Basis family: - @li If family is equal to 'lagrange' a Lagrange Basis will be used - @li If family is equal to 'hierarchical' a hierarchical Basis will be used - - @see See BasisGenerator::generate() - ** - - @fn FunctionSpaceScalar::FunctionSpaceScalar(const std::vector<const GroupOfElement*>&,size_t,std::string) - @param goe A vector of GroupOfElement - @param order A natural number - @param family A string (defaulted to 'hierarchical') - - Same as FunctionSpaceScalar::FunctionSpaceScalar(goe, [], order, family) - ** - - @fn FunctionSpaceScalar::FunctionSpaceScalar(const GroupOfElement&,size_t,std::string) - @param goe A GroupOfElement - @param order A natural number - @param family A string (defaulted to 'hierarchical') - - Same as FunctionSpaceScalar::FunctionSpaceScalar([goe], [], order, family) - ** - - @fn FunctionSpaceScalar::~FunctionSpaceScalar - Deletes this FunctionSpaceScalar - ** - - @fn FunctionSpaceScalar::interpolate - @param element The MElement to interpolate on - @param coef The coefficients of the interpolation - @param xyz The coordinate (of a point inside the given element) - of the interpolation in the @em physical space - - @return Returns the (scalar) interpolated value - - If the given coordinate are not in the given - element @em Bad @em Things may happend - ** - - @fn FunctionSpaceScalar::interpolateInRefSpace - @param element The MElement to interpolate on - @param coef The coefficients of the interpolation - @param uvw The coordinate (of a point inside the given element) - of the interpolation in the @em reference space - - @return Returns the (scalar) interpolated value - - If the given coordinate are not in the given - element @em Bad @em Things may happend - ** - - @fn FunctionSpaceScalar::interpolateDerivative - @param element The MElement to interpolate on - @param coef The coefficients of the interpolation - @param xyz The coordinate (of a point inside the given element) - of the interpolation in the @em physical space - - Same as FunctionSpaceScalar::interpolate(element, coef, xyz), - but this method iterpolates the derivative. -*/ - - -////////////////////// -// Inline Functions // -////////////////////// - -inline double FunctionSpaceScalar:: -interpolate(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& xyz) const{ - - // Get ABC Space coordinate // - double abc[3]; - ReferenceSpaceManager::mapFromXYZtoABC(element, xyz(0), xyz(1), xyz(2), abc); - - // Interpolate in ABC // - return interpolateInABC(element, coef, abc); -} - -inline double FunctionSpaceScalar:: -interpolateInRefSpace(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& uvw) const{ - - // Get ABC Space coordinate // - double abc[3]; - ReferenceSpaceManager::mapFromUVWtoABC(element, uvw(0), uvw(1), uvw(2), abc); - - // Interpolate in ABC // - return interpolateInABC(element, coef, abc); -} - -inline fullVector<double> FunctionSpaceScalar:: -interpolateDerivative(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& xyz) const{ - - // Get ABC Space coordinate // - double abc[3]; - ReferenceSpaceManager::mapFromXYZtoABC(element, xyz(0), xyz(1), xyz(2), abc); - - // Interpolate in ABC // - return interpolateDerivativeInABC(element, coef, abc); -} - -#endif diff --git a/FunctionSpace/FunctionSpaceVector.cpp b/FunctionSpace/FunctionSpaceVector.cpp deleted file mode 100644 index efb0d83f6b61bf388020f27cb178595502372cbc..0000000000000000000000000000000000000000 --- a/FunctionSpace/FunctionSpaceVector.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "Mapper.h" -#include "FunctionSpaceVector.h" - -using namespace std; - -FunctionSpaceVector:: -FunctionSpaceVector(const vector<const GroupOfElement*>& goe, - const vector<const GroupOfElement*>& exclude, - size_t order, string family){ - // Init - init(goe, exclude, order, family); -} - -FunctionSpaceVector:: -FunctionSpaceVector(const vector<const GroupOfElement*>& goe, - size_t order, string family){ - // Dummy Exclude - vector<const GroupOfElement*> dummy; - - // Init - init(goe, dummy, order, family); -} - -FunctionSpaceVector:: -FunctionSpaceVector(const GroupOfElement& goe, - size_t order, string family){ - // Temp vector - vector<const GroupOfElement*> tmp(1); - tmp[0] = &goe; - - // Dummy Exclude - vector<const GroupOfElement*> dummy; - - // Init - init(tmp, dummy, order, family); -} - -FunctionSpaceVector::~FunctionSpaceVector(void){ - // Done by FunctionSpace -} - -void FunctionSpaceVector::init(const vector<const GroupOfElement*>& goe, - const vector<const GroupOfElement*>& exclude, - size_t order, string family){ - // Init - this->scalar = false; - this->form = 1; - this->order = order; - - // Build FunctionSpace - build(goe, exclude, family); -} - -fullVector<double> FunctionSpaceVector:: -interpolateInABC(const MElement& element, - const vector<double>& coef, - double abc[3]) const{ - - // Get Jacobian // - fullMatrix<double> invJac(3, 3); - ReferenceSpaceManager::getJacobian(element, abc[0], abc[1], abc[2], invJac); - invJac.invertInPlace(); - - // Get Basis Functions // - const Basis& basis = getBasis(element); - const size_t nFun = basis.getNFunction(); - fullMatrix<double> fun(nFun, 3); - - basis.getFunctions(fun, element, abc[0], abc[1], abc[2]); - - // Get All Dofs - vector<Dof> myDof; - getKeys(element, myDof); - - // Interpolate (in Reference Place) // - fullMatrix<double> val(1, 3); - val(0, 0) = 0; - val(0, 1) = 0; - val(0, 2) = 0; - - for(size_t i = 0; i < nFun; i++){ - if(myDof[i] != Dof::RejectedDof()){ - val(0, 0) += fun(i, 0) * coef[i]; - val(0, 1) += fun(i, 1) * coef[i]; - val(0, 2) += fun(i, 2) * coef[i]; - } - } - - // Return Interpolated Value // - fullVector<double> map(3); - Mapper::hCurl(val, 0, 0, invJac, map); - return map; -} - -fullVector<double> FunctionSpaceVector:: -interpolateDerivativeInABC(const MElement& element, - const vector<double>& coef, - double abc[3]) const{ - // Get Jacobian // - fullMatrix<double> jac(3, 3); - double det = - ReferenceSpaceManager::getJacobian(element, abc[0], abc[1], abc[2], jac); - - // Get Basis Functions // - const Basis& basis = getBasis(element); - const size_t nFun = basis.getNFunction(); - fullMatrix<double> fun(nFun, 3); - - basis.getDerivative(fun, element, abc[0], abc[1], abc[2]); - - // Get All Dofs - vector<Dof> myDof; - getKeys(element, myDof); - - // Interpolate (in Reference Place) // - fullMatrix<double> val(1, 3); - val(0, 0) = 0; - val(0, 1) = 0; - val(0, 2) = 0; - - for(size_t i = 0; i < nFun; i++){ - if(myDof[i] != Dof::RejectedDof()){ - val(0, 0) += fun(i, 0) * coef[i]; - val(0, 1) += fun(i, 1) * coef[i]; - val(0, 2) += fun(i, 2) * coef[i]; - } - } - - // Return Interpolated Value // - fullVector<double> map(3); - Mapper::hDiv(val, 0, 0, jac, det, map); - return map; -} diff --git a/FunctionSpace/FunctionSpaceVector.h b/FunctionSpace/FunctionSpaceVector.h deleted file mode 100644 index 7fa7e5d18006933654ee3191bc38e5299d40a0c0..0000000000000000000000000000000000000000 --- a/FunctionSpace/FunctionSpaceVector.h +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef _FUNCTIONSPACEVECTOR_H_ -#define _FUNCTIONSPACEVECTOR_H_ - -#include "fullMatrix.h" -#include "FunctionSpaceScalar.h" -#include "FunctionSpace.h" - -/** - @class FunctionSpaceVector - @brief A vectorial FunctionSpaces - - This class is a vectorial FunctionSpaces. - - A FunctionSpaceVector can be interpolated. -*/ - - -class FunctionSpaceVector : public FunctionSpace{ - public: - FunctionSpaceVector(const std::vector<const GroupOfElement*>& goe, - const std::vector<const GroupOfElement*>& exclude, - size_t order, std::string family = "hierarchical"); - - FunctionSpaceVector(const std::vector<const GroupOfElement*>& goe, - size_t order, std::string family = "hierarchical"); - - FunctionSpaceVector(const GroupOfElement& goe, - size_t order, std::string family = "hierarchical"); - - virtual ~FunctionSpaceVector(void); - - fullVector<double> - interpolate(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& xyz) const; - - fullVector<double> - interpolateInRefSpace(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& uvw) const; - - fullVector<double> - interpolateDerivative(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& xyz) const; - - fullVector<double> - interpolateDerivativeInRefSpace(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& uvw) const; - private: - void init(const std::vector<const GroupOfElement*>& goe, - const std::vector<const GroupOfElement*>& exclude, - size_t order, std::string family); - - fullVector<double> - interpolateInABC(const MElement& element, - const std::vector<double>& coef, - double abc[3]) const; - - fullVector<double> - interpolateDerivativeInABC(const MElement& element, - const std::vector<double>& coef, - double abc[3]) const; -}; - - -/** - @fn FunctionSpaceVector::FunctionSpaceVector(const std::vector<const GroupOfElement*>&,const std::vector<const GroupOfElement*>&,size_t,std::string) - @param goe A vector of GroupOfElement - @param exclude An other of GroupOfElement - @param order A natural number - @param family A string (defaulted to 'hierarchical') - - Instanciates a new FunctionSpaceVector - on the GroupOfElement%s of 'goe', - with the exception of the GroupOfElement%s of 'exclude', - and with the given order - - The instanciated FunctionSpace will use the requested Basis family: - @li If family is equal to 'lagrange' a Lagrange Basis will be used - @li If family is equal to 'hierarchical' a hierarchical Basis will be used - - @see See BasisGenerator::generate() - ** - - @fn FunctionSpaceVector::FunctionSpaceVector(const std::vector<const GroupOfElement*>&,size_t,std::string) - @param goe A vector of GroupOfElement - @param order A natural number - @param family A string (defaulted to 'hierarchical') - - Same as FunctionSpaceVector::FunctionSpaceVector(goe, [], order, family) - ** - - @fn FunctionSpaceVector::FunctionSpaceVector(const GroupOfElement&,size_t,std::string) - @param goe A GroupOfElement - @param order A natural number - @param family A string (defaulted to 'hierarchical') - - Same as FunctionSpaceVector::FunctionSpaceVector([goe], [], order, family) - ** - - @fn FunctionSpaceVector::~FunctionSpaceVector - Deletes this FunctionSpaceVector - ** - - @fn FunctionSpaceVector::interpolate - @param element The MElement to interpolate on - @param coef The coefficients of the interpolation - @param xyz The coordinate (of a point inside the given element) - of the interpolation in the @em physical space - - @return Returns the (vectorial) interpolated value - - If the given coordinate are not in the given - element @em Bad @em Things may happend - ** - - @fn FunctionSpaceVector::interpolateInRefSpace - @param element The MElement to interpolate on - @param coef The coefficients of the interpolation - @param uvw The coordinate (of a point inside the given element) - of the interpolation in the @em reference space - - @return Returns the (vectorial) interpolated value - - If the given coordinate are not in the given - element @em Bad @em Things may happend - ** - - @fn FunctionSpaceVector::interpolateDerivative - @param element The MElement to interpolate on - @param coef The coefficients of the interpolation - @param xyz The coordinate (of a point inside the given element) - of the interpolation in the @em physical space - - Same as FunctionSpaceVector::interpolate(element, coef, xyz), - but this method iterpolates the derivative. - ** - - @fn FunctionSpaceVector::interpolateDerivativeInRefSpace - @param element The MElement to interpolate on - @param coef The coefficients of the interpolation - @param uvw The coordinate (of a point inside the given element) - of the interpolation in the @em reference space - - Same as FunctionSpaceVector::interpolateInRefSpace(element, coef, uvw), - but this method iterpolates the derivative. -*/ - - -////////////////////// -// Inline Functions // -////////////////////// - -inline fullVector<double> FunctionSpaceVector:: -interpolate(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& xyz) const{ - - // Get ABC Space coordinate // - double abc[3]; - ReferenceSpaceManager::mapFromXYZtoABC(element, xyz(0), xyz(1), xyz(2), abc); - - // Interpolate in ABC // - return interpolateInABC(element, coef, abc); -} - -inline fullVector<double> FunctionSpaceVector:: -interpolateInRefSpace(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& uvw) const{ - - // Get ABC Space coordinate // - double abc[3]; - ReferenceSpaceManager::mapFromUVWtoABC(element, uvw(0), uvw(1), uvw(2), abc); - - // Interpolate in ABC // - return interpolateInABC(element, coef, abc); -} - -inline fullVector<double> FunctionSpaceVector:: -interpolateDerivative(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& xyz) const{ - - // Get ABC Space coordinate // - double abc[3]; - ReferenceSpaceManager::mapFromXYZtoABC(element, xyz(0), xyz(1), xyz(2), abc); - - // Interpolate in ABC // - return interpolateDerivativeInABC(element, coef, abc); -} - -inline fullVector<double> FunctionSpaceVector:: -interpolateDerivativeInRefSpace(const MElement& element, - const std::vector<double>& coef, - const fullVector<double>& uvw) const{ - - // Get ABC Space coordinate // - double abc[3]; - ReferenceSpaceManager::mapFromUVWtoABC(element, uvw(0), uvw(1), uvw(2), abc); - - // Interpolate in ABC // - return interpolateDerivativeInABC(element, coef, abc); -} - -#endif diff --git a/FunctionSpace/HexEdgeBasis.cpp b/FunctionSpace/HexEdgeBasis.cpp deleted file mode 100644 index 84383203a7eba4d28f04c0cb2c4edfc2102fbf37..0000000000000000000000000000000000000000 --- a/FunctionSpace/HexEdgeBasis.cpp +++ /dev/null @@ -1,468 +0,0 @@ -#include <vector> -#include "HexEdgeBasis.h" -#include "Legendre.h" - -using namespace std; - -HexEdgeBasis::HexEdgeBasis(size_t order){ - /* - // Set Basis Type // - this->order = order; - - type = 1; - dim = 3; - - nVertex = 0; - nEdge = 12 * (order + 1); - nFace = 12 * order * (order + 1); - nCell = 3 * order * order * (order + 1); - - nEdgeClosure = 2; - nFaceClosure = 8; - - size = 3 * (order + 2) * (order + 2) * (order + 1); - - // Alloc Temporary Space // - const int orderPlus = order + 1; - Polynomial* legendre = new Polynomial[orderPlus]; - Polynomial* intLegendre = new Polynomial[orderPlus]; - - Polynomial* xi = new Polynomial[6]; - Polynomial* eta = new Polynomial[6]; - Polynomial* lambda = new Polynomial[6]; - - vector<Polynomial>* grXi = new vector<Polynomial>[6]; - vector<Polynomial>* grEta = new vector<Polynomial>[6]; - - Polynomial** iLegendreXi = new Polynomial*[orderPlus]; - Polynomial** iLegendreEta = new Polynomial*[orderPlus]; - Polynomial** legendreXi = new Polynomial*[orderPlus]; - Polynomial** legendreEta = new Polynomial*[orderPlus]; - - Polynomial* iLegendreX = new Polynomial[orderPlus]; - Polynomial* iLegendreY = new Polynomial[orderPlus]; - Polynomial* iLegendreZ = new Polynomial[orderPlus]; - - Polynomial* lagrange = new Polynomial[8]; - Polynomial* lagrangeSum = new Polynomial[12]; - - Polynomial* lifting = new Polynomial[8]; - Polynomial* liftingSub = new Polynomial[12]; - - - // Legendre Polynomial // - Legendre::integrated(intLegendre, orderPlus); - Legendre::legendre(legendre, order); - - - // Points definig Edges // - int edge1[12] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3}; - int edge2[12] = {1, 2, 3, 0, 5, 6, 7, 4, 4, 5, 6, 7}; - - - // Lagrange // - lagrange[0] = - (Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1)); - - lagrange[1] = - (Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1)); - - lagrange[2] = - (Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1)); - - lagrange[3] = - (Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1)); - - lagrange[4] = - (Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) * - Polynomial(1, 0, 0, 1); - - lagrange[5] = - (Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) * - Polynomial(1, 0, 0, 1); - - lagrange[6] = - (Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0)) * - Polynomial(1, 0, 0, 1); - - lagrange[7] = - (Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0)) * - Polynomial(1, 0, 0, 1); - - // Lagrange Sum // - for(int i = 0; i < 12; i++) - lagrangeSum[i] = lagrange[edge1[i]] + lagrange[edge2[i]]; - - - // Lifting // - lifting[0] = - (Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1)); - - lifting[1] = - (Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1)); - - lifting[2] = - (Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1)); - - lifting[3] = - (Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1)); - - lifting[4] = - (Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) + - Polynomial(1, 0, 0, 1); - - lifting[5] = - (Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) + - Polynomial(1, 0, 0, 1); - - lifting[6] = - (Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0)) + - Polynomial(1, 0, 0, 1); - - lifting[7] = - (Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0)) + - Polynomial(1, 0, 0, 1); - - // Lifting Sub // - for(int i = 0; i < 12; i++) - liftingSub[i] = lifting[edge1[i]] - lifting[edge2[i]]; - - - // Basis (temporary --- *no* const) // - std::vector<std::vector<Polynomial>*> basis(size); - - - // Edge Based (Nedelec) // - int i = 0; // Function Counter - Polynomial oneHalf(0.5, 0, 0, 0); - - for(int e = 0; e < 12; e++){ - basis[i] = - new std::vector<Polynomial>((liftingSub[e]).gradient()); - - basis[i]->at(0).mul(lagrangeSum[e]); - basis[i]->at(1).mul(lagrangeSum[e]); - basis[i]->at(2).mul(lagrangeSum[e]); - - basis[i]->at(0).mul(oneHalf); - basis[i]->at(1).mul(oneHalf); - basis[i]->at(2).mul(oneHalf); - - i++; - } - - - // Edge Based (High Order) // - for(int l = 1; l < orderPlus; l++){ - for(int e = 0; e < 12; e++){ - basis[i] = - new std::vector<Polynomial>((intLegendre[l].compose(liftingSub[e]) * lagrangeSum[e]).gradient()); - - i++; - } - } - - - // Face Based (Preliminary) // - // Points definig Faces - int face1[6] = {0, 3, 2, 1, 5, 4}; - int face2[6] = {1, 7, 6, 0, 6, 7}; - int face3[6] = {2, 6, 5, 4, 7, 3}; - int face4[6] = {3, 2, 1, 5, 4, 0}; - - // 'Xi' Functions - for(int f = 0; f < 6; f++) - xi[f] = lifting[face1[f]] - lifting[face2[f]]; - - // 'Eta' Functions - for(int f = 0; f < 6; f++) - eta[f] = lifting[face1[f]] - lifting[face4[f]]; - - // 'Lambda' Functions - for(int f = 0; f < 6; f++) - lambda[f] = - lagrange[face1[f]] + - lagrange[face2[f]] + - lagrange[face3[f]] + - lagrange[face4[f]]; - - // Gradients - for(int f = 0; f < 6; f++){ - grXi[f] = xi[f].gradient(); - grEta[f] = eta[f].gradient(); - } - - // Compositions - for(int l = 0; l < orderPlus; l++){ - iLegendreXi[l] = new Polynomial[6]; - iLegendreEta[l] = new Polynomial[6]; - - legendreXi[l] = new Polynomial[6]; - legendreEta[l] = new Polynomial[6]; - - for(int f = 0; f < 6; f++){ - iLegendreXi[l][f] = intLegendre[l].compose(xi[f]); - iLegendreEta[l][f] = intLegendre[l].compose(eta[f]); - - legendreXi[l][f] = legendre[l].compose(xi[f]); - legendreEta[l][f] = legendre[l].compose(eta[f]); - } - } - - - // Face Based (Type 1) // - for(int l1 = 1; l1 < orderPlus; l1++){ - for(int l2 = 1; l2 < orderPlus; l2++){ - for(int f = 0; f < 6; f++){ - basis[i] = new std::vector<Polynomial>((iLegendreXi[l1][f] * - iLegendreEta[l2][f] * - lambda[f]).gradient()); - i++; - } - } - } - - - // Face Based (Type 2) // - for(int l1 = 1; l1 < orderPlus; l1++){ - for(int l2 = 1; l2 < orderPlus; l2++){ - for(int f = 0; f < 6; f++){ - basis[i] = new std::vector<Polynomial>(3); - - Polynomial tmp1 = - legendreXi[l1][f] * - iLegendreEta[l2][f]; - - Polynomial tmp2 = - iLegendreXi[l1][f] * - legendreEta[l2][f]; - - vector<Polynomial> gr1 = grXi[f]; - gr1[0].mul(tmp1); - gr1[1].mul(tmp1); - gr1[2].mul(tmp1); - - vector<Polynomial> gr2 = grEta[f]; - gr2[0].mul(tmp2); - gr2[1].mul(tmp2); - gr2[2].mul(tmp2); - - basis[i]->at(0) = (gr1[0] - gr2[0]) * lambda[f]; - basis[i]->at(1) = (gr1[1] - gr2[1]) * lambda[f]; - basis[i]->at(2) = (gr1[2] - gr2[2]) * lambda[f]; - - i++; - } - } - } - - - // Face Based (Type 3 -- Xi) // - for(int l = 1; l < orderPlus; l++){ - for(int f = 0; f < 6; f++){ - Polynomial tmp = iLegendreEta[l][f] * lambda[f]; - - basis[i] = new std::vector<Polynomial>(grXi[f]); - - basis[i]->at(0).mul(tmp); - basis[i]->at(1).mul(tmp); - basis[i]->at(2).mul(tmp); - - i++; - } - } - - - // Face Based (Type 3 -- Eta) // - for(int l = 1; l < orderPlus; l++){ - for(int f = 0; f < 6; f++){ - Polynomial tmp = iLegendreXi[l][f] * lambda[f]; - - basis[i] = new std::vector<Polynomial>(grEta[f]); - - basis[i]->at(0).mul(tmp); - basis[i]->at(1).mul(tmp); - basis[i]->at(2).mul(tmp); - - i++; - } - } - - - // Cell Based (Preliminary) // - Polynomial px = Polynomial(2, 1, 0, 0); - Polynomial py = Polynomial(2, 0, 1, 0); - Polynomial pz = Polynomial(2, 0, 0, 1); - Polynomial zero = Polynomial(0, 0, 0, 0); - - px = px - Polynomial(1, 0, 0, 0); - py = py - Polynomial(1, 0, 0, 0); - pz = pz - Polynomial(1, 0, 0, 0); - - for(int l = 0; l < orderPlus; l++){ - iLegendreX[l] = intLegendre[l].compose(px); - iLegendreY[l] = intLegendre[l].compose(py); - iLegendreZ[l] = intLegendre[l].compose(pz); - } - - - // Cell Based (Type 1) // - int cellStart = i; // Type one cell base counter - int cellNumber = 0; - - for(int l1 = 1; l1 < orderPlus; l1++){ - for(int l2 = 1; l2 < orderPlus; l2++){ - for(int l3 = 1; l3 < orderPlus; l3++){ - basis[i] = new std::vector<Polynomial>((iLegendreX[l1] * - iLegendreY[l2] * - iLegendreZ[l3]).gradient()); - - i++; - cellNumber++; - } - } - } - - - // Cell Based (Type 2 -- First Part) // - for(int j = 0; j < cellNumber; j++){ - basis[i] = new std::vector<Polynomial>(3); - - int off = j + cellStart; - - basis[i]->at(0) = basis[off]->at(0); - basis[i]->at(1) = basis[off]->at(1) * Polynomial(-1, 0, 0, 0); - basis[i]->at(2) = basis[off]->at(2); - - i++; - } - - - // Cell Based (Type 2 -- Second Part) // - for(int j = 0; j < cellNumber; j++){ - basis[i] = new std::vector<Polynomial>(3); - - int off = j + cellStart; - - basis[i]->at(0) = basis[off]->at(0); - basis[i]->at(1) = basis[off]->at(1) * Polynomial(-1, 0, 0, 0); - basis[i]->at(2) = basis[off]->at(2) * Polynomial(-1, 0, 0, 0); - - i++; - } - - - // Cell Based (Type 3 -- First Part) // - for(int l2 = 1; l2 < orderPlus; l2++){ - for(int l3 = 1; l3 < orderPlus; l3++){ - basis[i] = new std::vector<Polynomial>(3); - - basis[i]->at(0) = iLegendreY[l2] * iLegendreZ[l3]; - basis[i]->at(1) = zero; - basis[i]->at(2) = zero; - - i++; - } - } - - - // Cell Based (Type 3 -- Second Part) // - for(int l1 = 1; l1 < orderPlus; l1++){ - for(int l3 = 1; l3 < orderPlus; l3++){ - basis[i] = new std::vector<Polynomial>(3); - - basis[i]->at(0) = zero; - basis[i]->at(1) = iLegendreX[l1] * iLegendreZ[l3]; - basis[i]->at(2) = zero; - - i++; - } - } - - - // Cell Based (Type 3 -- Thrid Part) // - for(int l1 = 1; l1 < orderPlus; l1++){ - for(int l2 = 1; l2 < orderPlus; l2++){ - basis[i] = new std::vector<Polynomial>(3); - - basis[i]->at(0) = zero; - basis[i]->at(1) = zero; - basis[i]->at(2) = iLegendreX[l1] * iLegendreY[l2]; - - i++; - } - } - - - // Free Temporary Sapce // - delete[] legendre; - delete[] intLegendre; - - delete[] lagrange; - delete[] lagrangeSum; - - delete[] lifting; - delete[] liftingSub; - - delete[] xi; - delete[] eta; - delete[] lambda; - - delete[] grXi; - delete[] grEta; - - for(int l = 0; l < orderPlus; l++){ - delete[] iLegendreXi[l]; - delete[] iLegendreEta[l]; - delete[] legendreXi[l]; - delete[] legendreEta[l]; - } - - delete[] iLegendreXi; - delete[] iLegendreEta; - delete[] legendreXi; - delete[] legendreEta; - - delete[] iLegendreX; - delete[] iLegendreY; - delete[] iLegendreZ; - - - // Set Basis // - this->basis = new std::vector<const std::vector<Polynomial>*> - (basis.begin(), basis.end()); - */ -} - -HexEdgeBasis::~HexEdgeBasis(void){ - /* - for(int i = 0; i < size; i++) - delete (*basis)[i]; - - delete basis; - */ -} diff --git a/FunctionSpace/HexEdgeBasis.h b/FunctionSpace/HexEdgeBasis.h deleted file mode 100644 index 811f5ba9009118e8c18fa6f40a55b975c4a4efc6..0000000000000000000000000000000000000000 --- a/FunctionSpace/HexEdgeBasis.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _HEXEDGEBASIS_H_ -#define _HEXEDGEBASIS_H_ - -#include "BasisHierarchical1Form.h" - -/** - @class HexEdgeBasis - @brief An Edge Basis for Hexahedra - - This class can instantiate an Edge-Based Basis - (high or low order) for Hexahedra. - - It uses - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation. - */ - -class HexEdgeBasis: public BasisHierarchical1Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Edge-Basis for Hexahedra of the given order - HexEdgeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~HexEdgeBasis(void); -}; - -#endif diff --git a/FunctionSpace/HexLagrangeBasis.cpp b/FunctionSpace/HexLagrangeBasis.cpp deleted file mode 100644 index 71d2be0295b72247333c7a260756a2a76c28455b..0000000000000000000000000000000000000000 --- a/FunctionSpace/HexLagrangeBasis.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "ElementType.h" -#include "GmshDefines.h" -#include "pointsGenerators.h" - -#include "HexLagrangeBasis.h" - -HexLagrangeBasis::HexLagrangeBasis(size_t order){ - // If order 0 (Nedelec): use order 1 - if(order == 0) - order = 1; - - // Set Basis Type // - this->order = order; - - type = TYPE_HEX; - dim = 3; - - nVertex = 8; - nEdge = 12 * (order - 1); - nFace = 6 * (order - 1) * (order - 1); - nCell = (order - 1) * (order - 1) * (order - 1); - nFunction = nVertex + nEdge + nFace + nCell; - - // Init polynomialBasis // - lBasis = new polynomialBasis(ElementType::getTag(TYPE_HEX, order, false)); - - // Init Lagrange Point // - lPoint = new fullMatrix<double>(gmshGeneratePointsHexahedron(order, false)); -} - -HexLagrangeBasis::~HexLagrangeBasis(void){ - delete lBasis; - delete lPoint; -} diff --git a/FunctionSpace/HexLagrangeBasis.h b/FunctionSpace/HexLagrangeBasis.h deleted file mode 100644 index 986f8c115084ab37132982b875af66691db08436..0000000000000000000000000000000000000000 --- a/FunctionSpace/HexLagrangeBasis.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _HEXLAGRANGEBASIS_H_ -#define _HEXLAGRANGEBASIS_H_ - -#include "BasisLagrange.h" - -/** - @class HexLagrangeBasis - @brief Lagrange Basis for Hexahedra - - This class can instantiate a Lagrange Basis - for a Hexahedron and for a given order. - - It uses - <a href="http://geuz.org/gmsh/">gmsh</a> Basis. - */ - -class HexLagrangeBasis: public BasisLagrange{ - public: - //! @param order A natural number - //! - //! Returns a new HexLagrangeBasis of the given order - HexLagrangeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~HexLagrangeBasis(void); -}; - -#endif diff --git a/FunctionSpace/HexNodeBasis.cpp b/FunctionSpace/HexNodeBasis.cpp deleted file mode 100644 index ecbb3bebc100d4dbc02d91f898c9cdf0bf2a035f..0000000000000000000000000000000000000000 --- a/FunctionSpace/HexNodeBasis.cpp +++ /dev/null @@ -1,235 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "HexNodeBasis.h" - -using namespace std; - -HexNodeBasis::HexNodeBasis(size_t order){ - // Set Basis Type // - this->order = order; - - type = TYPE_HEX; - dim = 3; - - nVertex = 8; - nEdge = 12 * (order - 1); - nFace = 6 * (order - 1) * (order - 1); - nCell = (order - 1) * (order - 1) * (order - 1); - nFunction = nVertex + nEdge + nFace + nCell; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - const vector<vector<vector<size_t> > >& - faceIdx = ReferenceSpaceManager::getFaceNodeIndex(type); - - // Legendre Polynomial // - Polynomial* legendre = new Polynomial[order]; - Legendre::integrated(legendre, order); - - // Lagrange & Lifting // - const Polynomial lagrange[8] = - { - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0)) * - (Polynomial(1, 0, 0, 1))) - }; - - const Polynomial lifting[8] = - { - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 1))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0)) + - (Polynomial(1, 0, 0, 1))) - }; - - // Basis // - basis = new Polynomial**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new Polynomial*[nFunction]; - - // Vertex Based // - for(size_t s = 0; s < nOrientation; s++){ - basis[s][0] = new Polynomial(lagrange[0]); - basis[s][1] = new Polynomial(lagrange[1]); - basis[s][2] = new Polynomial(lagrange[2]); - basis[s][3] = new Polynomial(lagrange[3]); - basis[s][4] = new Polynomial(lagrange[4]); - basis[s][5] = new Polynomial(lagrange[5]); - basis[s][6] = new Polynomial(lagrange[6]); - basis[s][7] = new Polynomial(lagrange[7]); - } - - // Edge Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex; - - for(size_t e = 0; e < 12; e++){ - for(size_t l = 1; l < order; l++){ - basis[s][i] = - new Polynomial(legendre[l].compose(lifting[edgeIdx[s][e][1]] - - lifting[edgeIdx[s][e][0]]) - * - (lagrange[edgeIdx[s][e][0]] + - lagrange[edgeIdx[s][e][1]])); - - i++; - } - } - } - - // Face Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex + nEdge; - - for(size_t f = 0; f < 6; f++){ - for(size_t l1 = 1; l1 < order; l1++){ - for(size_t l2 = 1; l2 < order; l2++){ - Polynomial sum = - lagrange[faceIdx[s][f][0]] + - lagrange[faceIdx[s][f][1]] + - lagrange[faceIdx[s][f][2]] + - lagrange[faceIdx[s][f][3]]; - - basis[s][i] = - new Polynomial(legendre[l1].compose(lifting[faceIdx[s][f][0]] - - lifting[faceIdx[s][f][1]]) * - - legendre[l2].compose(lifting[faceIdx[s][f][0]] - - lifting[faceIdx[s][f][3]]) * - sum); - i++; - } - } - } - } - - // Cell Based // - Polynomial px = Polynomial(2, 1, 0, 0); - Polynomial py = Polynomial(2, 0, 1, 0); - Polynomial pz = Polynomial(2, 0, 0, 1); - - px = px - Polynomial(1, 0, 0, 0); - py = py - Polynomial(1, 0, 0, 0); - pz = pz - Polynomial(1, 0, 0, 0); - - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex + nEdge + nFace; - - for(size_t l1 = 1; l1 < order; l1++){ - for(size_t l2 = 1; l2 < order; l2++){ - for(size_t l3 = 1; l3 < order; l3++){ - basis[s][i] = - new Polynomial(legendre[l1].compose(px) * - legendre[l2].compose(py) * - legendre[l3].compose(pz)); - - i++; - } - } - } - } - - // Mapping to Gmsh Quad // - // x = (u + 1) / 2 - // y = (v + 1) / 2 - // - // (x, y) = Zaglmayr Ref Quad - // (u, v) = Gmsh Ref Quad - - Polynomial mapX(Polynomial(0.5, 1, 0, 0) + - Polynomial(0.5, 0, 0, 0)); - - Polynomial mapY(Polynomial(0.5, 0, 1, 0) + - Polynomial(0.5, 0, 0, 0)); - - Polynomial mapZ(Polynomial(0.5, 0, 0, 1) + - Polynomial(0.5, 0, 0, 0)); - - for(size_t s = 0; s < nOrientation; s++){ - for(size_t i = 0; i < nFunction; i++){ - Polynomial* tmp; - tmp = basis[s][i]; - basis[s][i] = new Polynomial(tmp->compose(mapX, mapY, mapZ)); - delete tmp; - } - } - - // Free Temporary Sapce // - delete[] legendre; -} - -HexNodeBasis::~HexNodeBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/HexNodeBasis.h b/FunctionSpace/HexNodeBasis.h deleted file mode 100644 index 1457e3faf786a4b3d376a4f86f259bbc607c9f54..0000000000000000000000000000000000000000 --- a/FunctionSpace/HexNodeBasis.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _HEXNODEBASIS_H_ -#define _HEXNODEBASIS_H_ - -#include "BasisHierarchical0Form.h" - -/** - @class HexNodeBasis - @brief A Node Basis for Hexahedra - - This class can instantiate a Node-Based Basis - (high or low order) for Hexahedra. - - It uses - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation. - */ - -class HexNodeBasis: public BasisHierarchical0Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Node-Basis for Hexahedra of the given order - HexNodeBasis(size_t order); - - //! @return Deletes this Basis - //! - virtual ~HexNodeBasis(void); -}; - -#endif diff --git a/FunctionSpace/HexReferenceSpace.cpp b/FunctionSpace/HexReferenceSpace.cpp deleted file mode 100644 index fe098808043cae89cbe3434c8aa343363ef00e8d..0000000000000000000000000000000000000000 --- a/FunctionSpace/HexReferenceSpace.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include <sstream> - -#include "HexReferenceSpace.h" -#include "MHexahedron.h" - -using namespace std; - -HexReferenceSpace::HexReferenceSpace(void){ - // Look if a serialized HexReferenceSpace is present in root // - // If it does, load it // - // If not, create it and serialize it for an other time // - - try{ - init(string("hex.refSpace")); - } - - catch(std::exception& exception){ - initHex(); - serialize("hex.refSpace"); - } -} - -void HexReferenceSpace::initHex(void){ - // Vertex Definition // - nVertex = 8; - - // Edge Definition // - const size_t nEdge = 12; - refEdgeNodeIdx.resize(nEdge); - - for(size_t i = 0; i < nEdge; i++){ - refEdgeNodeIdx[i].resize(2); // Two Nodes per Edge - refEdgeNodeIdx[i][0] = MHexahedron::edges_hexa(i, 0); - refEdgeNodeIdx[i][1] = MHexahedron::edges_hexa(i, 1); - } - - // Face Definition // - size_t nFace = 6; - refFaceNodeIdx.resize(nFace); - - for(size_t i = 0; i < nFace; i++){ - refFaceNodeIdx[i].resize(4); // Four Nodes per Face - refFaceNodeIdx[i][0] = MHexahedron::faces_hexa(i, 0); - refFaceNodeIdx[i][1] = MHexahedron::faces_hexa(i, 1); - refFaceNodeIdx[i][2] = MHexahedron::faces_hexa(i, 2); - refFaceNodeIdx[i][3] = MHexahedron::faces_hexa(i, 3); - } - - // Init All // - init(); -} - -HexReferenceSpace::~HexReferenceSpace(void){ -} - -string HexReferenceSpace::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/HexReferenceSpace.h b/FunctionSpace/HexReferenceSpace.h deleted file mode 100644 index 28a0cccc1e5a9318958f20ed0a1a442bfeeee81c..0000000000000000000000000000000000000000 --- a/FunctionSpace/HexReferenceSpace.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _HEXREFERENCESPACE_H_ -#define _HEXREFERENCESPACE_H_ - -#include <string> -#include "ReferenceSpace.h" - -/** - @class HexReferenceSpace - @brief ReferenceSpace for Hexahedron - - This class implements a ReferenceSpace for a Hexahedron. - */ - -class HexReferenceSpace: public ReferenceSpace{ - public: - HexReferenceSpace(void); - virtual ~HexReferenceSpace(void); - - virtual std::string toLatex(void) const; - - private: - void initHex(void); -}; - -/** - @fn HexReferenceSpace::HexReferenceSpace - Instatiate a new ReferenceSpace for a Hexahedron - ** - - @fn HexReferenceSpace::~HexReferenceSpace - Deletes this HexReferenceSpace -*/ - -#endif diff --git a/FunctionSpace/Legendre.cpp b/FunctionSpace/Legendre.cpp deleted file mode 100644 index 583a52b47b4506be476f3eae8caf04473c740958..0000000000000000000000000000000000000000 --- a/FunctionSpace/Legendre.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "Legendre.h" - -Polynomial Legendre::legendre(int n, const Polynomial& l, - const Polynomial& lMinus){ - const double nPlus = n + 1; - - return - l * Polynomial(1, 1, 0, 0) * ((2 * n + 1) / nPlus) - lMinus * (n / nPlus); -} - -Polynomial Legendre::scaled(int n, const Polynomial& l, - const Polynomial& lMinus){ - const double nPlus = n + 1; - - return - l * Polynomial(1, 1, 0, 0) * ((2 * n + 1) / nPlus) - - lMinus * Polynomial(1, 0, 2, 0) * (( n ) / nPlus); -} - -Polynomial Legendre::integrated(int n, const Polynomial& l, - const Polynomial& lMinus){ - const double nPlus = n + 1; - - return - l * Polynomial(1, 1, 0, 0) * ((2 * n - 1) / nPlus) - - lMinus * ((n - 2) / nPlus); -} - -Polynomial Legendre::intScaled(int n, const Polynomial& l, - const Polynomial& lMinus){ - const double nPlus = n + 1; - - return - l * Polynomial(1, 1, 0, 0) * ((2 * n - 1) / nPlus) - - lMinus * Polynomial(1, 0, 2, 0) * (( n - 2) / nPlus); -} - - - -void Legendre::legendre(Polynomial* polynomial, int order){ - int i, j, k; - - if(order >= 0) - - polynomial[0] = Polynomial(1, 0, 0, 0); - - if(order >= 1) - polynomial[1] = Polynomial(1, 1, 0, 0); - - if(order >= 2){ - for(k = 2; k <= order; k++){ - i = k - 1; - j = k - 2; - - polynomial[k] = legendre(i, polynomial[i], polynomial[j]); - } - } -} - -void Legendre::integrated(Polynomial* polynomial, int order){ - int i, j, k; - - if(order >= 1) - polynomial[0] = Polynomial(1, 1, 0, 0); - - if(order >= 2) - polynomial[1] = (Polynomial(1, 2, 0, 0) + Polynomial(-1, 0, 0, 0)) * 0.5; - - if(order >= 3){ - for(k = 2; k < order; k++){ - i = k - 1; - j = k - 2; - - polynomial[k] = integrated(k, polynomial[i], polynomial[j]); - } - } -} - -void Legendre::scaled(Polynomial* polynomial, int order){ - int i, j, k; - - if(order >= 0) - polynomial[0] = Polynomial(1, 0, 0, 0); - - if(order >= 1) - polynomial[1] = Polynomial(1, 1, 0, 0); - - if(order >= 2){ - for(k = 2; k <= order; k++){ - i = k - 1; - j = k - 2; - - polynomial[k] = scaled(i, polynomial[i], polynomial[j]); - } - } -} - -void Legendre::intScaled(Polynomial* polynomial, int order){ - int i, j, k; - - if(order >= 1) - polynomial[0] = Polynomial(1, 1, 0, 0); - - if(order >= 2) - polynomial[1] = (Polynomial(1, 2, 0, 0) + Polynomial(-1, 0, 2, 0)) * 0.5; - - if(order >= 3){ - for(k = 2; k < order; k++){ - i = k - 1; - j = k - 2; - - polynomial[k] = intScaled(k, polynomial[i], polynomial[j]); - } - } -} diff --git a/FunctionSpace/Legendre.h b/FunctionSpace/Legendre.h deleted file mode 100644 index 4cf6106de0bebc73091fb0a9df459456acbfd449..0000000000000000000000000000000000000000 --- a/FunctionSpace/Legendre.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef _LEGENDRE_H_ -#define _LEGENDRE_H_ - -#include "Polynomial.h" - -/** - @class Legendre - @brief Generators for Legendre Polynomial%s - - This class handles the generation of Legendre Polynomial%s of many types: - @li Classical Legendre (Legendre::legendre) - @li Integrated Legendre (Legendre::integrated) - @li Scaled Legendre (Legendre::scaled) - @li Integrated Scaled Legendre (Legendre::intScaled) - - It is not requiered to instantiate a Legendre class. - Indeed, all its methods are static. - */ - -class Legendre{ - public: - static void legendre(Polynomial* polynomial, int order); - static void integrated(Polynomial* polynomial, int order); - static void scaled(Polynomial* polynomial, int order); - static void intScaled(Polynomial* polynomial,int order); - - private: - static Polynomial legendre(int n, - const Polynomial& l, - const Polynomial& lMinus); - - static Polynomial integrated(int n, - const Polynomial& l, - const Polynomial& lMinus); - - static Polynomial scaled(int n, - const Polynomial& l, - const Polynomial& lMinus); - - static Polynomial intScaled(int n, - const Polynomial& l, - const Polynomial& lMinus); -}; - -/** - @fn void Legendre::legendre(Polynomial*, int) - @param polynomial An allocated array (of size 'order' + 1) - for storing the requested legendre Polynomial%s - @param order The maximal order of the requested Polynomial%s - - Stores in 'polynomial' all the classical legendre Polynomial%s - of order [0, 'order'] - ** - - @fn void Legendre::integrated(Polynomial*, int) - @param polynomial An allocated array (of size 'order') - for storing the requested legendre Polynomial%s - @param order The maximal order of the requested Polynomial%s - - Stores in 'polynomial' all the integrated legendre Polynomial%s - of order [1, 'order'] - ** - - @fn void Legendre::scaled(Polynomial*, int) - @param polynomial An allocated array (of size 'order' + 1) - for storing the requested legendre Polynomial%s - @param order The maximal order of the requested Polynomial%s - - Stores in 'polynomial' all the scaled legendre Polynomial%s - of order [0, 'order'] - ** - - @fn void Legendre::intScaled(Polynomial*, int) - @param polynomial An allocated array (of size 'order') - for storing the requested legendre Polynomial%s - @param order The maximal order of the requested Polynomial%s - - Stores in 'polynomial' all the scaled integrated legendre Polynomial%s - of order [1, 'order'] - */ - -#endif diff --git a/FunctionSpace/LineEdgeBasis.cpp b/FunctionSpace/LineEdgeBasis.cpp deleted file mode 100644 index 1801458f47a67af3de74ceb2caa1d1dd0f397fce..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineEdgeBasis.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "LineEdgeBasis.h" - -using namespace std; - -LineEdgeBasis::LineEdgeBasis(size_t order){ - // Set Basis Type // - this->order = order; - - type = TYPE_LIN; - dim = 1; - - nVertex = 0; - nEdge = (order + 1); - nFace = 0; - nCell = 0; - nFunction = nVertex + nEdge + nFace + nCell; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - // Legendre Polynomial // - const size_t orderPlus = order + 1; - Polynomial* intLegendre = new Polynomial[orderPlus]; - - Legendre::integrated(intLegendre, orderPlus); - - // Lagrange Polynomial // - const Polynomial lagrange[2] = - { - Polynomial(Polynomial(0.5, 0, 0, 0) - - Polynomial(0.5, 1, 0, 0)), - - Polynomial(Polynomial(0.5, 0, 0, 0) + - Polynomial(0.5, 1, 0, 0)), - }; - - // Basis // - basis = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new vector<Polynomial>*[nFunction]; - - // Edge Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = 0; - - for(size_t l = 0; l < orderPlus; l++){ - // Nedelec - if(l == 0){ - vector<Polynomial> tmp1 = lagrange[edgeIdx[s][0][1]].gradient(); - vector<Polynomial> tmp2 = lagrange[edgeIdx[s][0][0]].gradient(); - - tmp1[0].mul(lagrange[edgeIdx[s][0][0]]); - tmp1[1].mul(lagrange[edgeIdx[s][0][0]]); - tmp1[2].mul(lagrange[edgeIdx[s][0][0]]); - - tmp2[0].mul(lagrange[edgeIdx[s][0][1]]); - tmp2[1].mul(lagrange[edgeIdx[s][0][1]]); - tmp2[2].mul(lagrange[edgeIdx[s][0][1]]); - - tmp2[0].sub(tmp1[0]); - tmp2[1].sub(tmp1[1]); - tmp2[2].sub(tmp1[2]); - - basis[s][i] = new vector<Polynomial>(tmp2); - } - - // High Order - else{ - basis[s][i] = - new vector<Polynomial> - ((intLegendre[l].compose(lagrange[edgeIdx[s][0][0]] - - lagrange[edgeIdx[s][0][1]]).gradient())); - } - i++; - } - } - - // Free Temporary Space // - delete[] intLegendre; -} - -LineEdgeBasis::~LineEdgeBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/LineEdgeBasis.h b/FunctionSpace/LineEdgeBasis.h deleted file mode 100644 index 02e170a0b8b1d92e2101e633c3267c83021c2d14..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineEdgeBasis.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _LINEEDGEBASIS_H_ -#define _LINEEDGEBASIS_H_ - -#include "BasisHierarchical1Form.h" - -/** - @class LineEdgeBasis - @brief An Edge Basis for Lines - - This class can instantiate an Edge-Based Basis (high or low order) for Lines. - - It uses an adaptation of - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation.@n - - This Basis is a restriction of a Quad Basis to @f$y = 0@f$. - - It also uses the following mapping: @f$x = \frac{u + 1}{2}@f$. -*/ - -class LineEdgeBasis: public BasisHierarchical1Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Edge-Basis for Lines of the given order - LineEdgeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~LineEdgeBasis(void); -}; - -#endif diff --git a/FunctionSpace/LineLagrangeBasis.cpp b/FunctionSpace/LineLagrangeBasis.cpp deleted file mode 100644 index 30792d36fc3ba4d871a08055cde167e01b393aee..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineLagrangeBasis.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "ElementType.h" -#include "GmshDefines.h" -#include "pointsGenerators.h" - -#include "LineLagrangeBasis.h" - -LineLagrangeBasis::LineLagrangeBasis(size_t order){ - // If order 0 (Nedelec): use order 1 - if(order == 0) - order = 1; - - // Set Basis Type // - this->order = order; - - type = TYPE_LIN; - dim = 1; - - nVertex = 2; - nEdge = (order - 1); - nFace = 0; - nCell = 0; - nFunction = nVertex + nEdge + nFace + nCell; - - // Init polynomialBasis // - lBasis = new polynomialBasis(ElementType::getTag(TYPE_LIN, order, false)); - - // Init Lagrange Point // - lPoint = new fullMatrix<double>(gmshGeneratePointsLine(order)); -} - -LineLagrangeBasis::~LineLagrangeBasis(void){ - delete lBasis; - delete lPoint; -} diff --git a/FunctionSpace/LineLagrangeBasis.h b/FunctionSpace/LineLagrangeBasis.h deleted file mode 100644 index 1d92aa7d90d981cc49a05c84b9702d459ab5e573..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineLagrangeBasis.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _LINELAGRANGEBASIS_H_ -#define _LINELAGRANGEBASIS_H_ - -#include "BasisLagrange.h" - -/** - @class LineLagrangeBasis - @brief Lagrange Basis for Lines - - This class can instantiate a Lagrange Basis - for a Line and for a given order. - - It uses - <a href="http://geuz.org/gmsh/">gmsh</a> Basis. - */ - -class LineLagrangeBasis: public BasisLagrange{ - public: - //! @param order A natural number - //! - //! Returns a new LineLagrangeBasis of the given order - LineLagrangeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~LineLagrangeBasis(void); -}; - -#endif diff --git a/FunctionSpace/LineNedelecBasis.cpp b/FunctionSpace/LineNedelecBasis.cpp deleted file mode 100644 index 3f8e55bd4c04599e9a2e58ffc29edccfd1dccb58..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineNedelecBasis.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "LineNedelecBasis.h" - -using namespace std; - -LineNedelecBasis::LineNedelecBasis(void){ - // Set Basis Type // - order = 0; - - type = TYPE_LIN; - dim = 1; - - nVertex = 0; - nEdge = 1; - nFace = 0; - nCell = 0; - nFunction = 1; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - // Lagrange Polynomial // - const Polynomial lagrange[2] = - { - Polynomial(Polynomial(0.5, 0, 0, 0) - - Polynomial(0.5, 1, 0, 0)), - - Polynomial(Polynomial(0.5, 0, 0, 0) + - Polynomial(0.5, 1, 0, 0)), - }; - - // Basis // - basis = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new vector<Polynomial>*[nFunction]; - - // Edge Based (Nedelec) // - for(size_t s = 0; s < nOrientation; s++){ - vector<Polynomial> tmp1 = lagrange[edgeIdx[s][0][1]].gradient(); - vector<Polynomial> tmp2 = lagrange[edgeIdx[s][0][0]].gradient(); - - tmp1[0].mul(lagrange[edgeIdx[s][0][0]]); - tmp1[1].mul(lagrange[edgeIdx[s][0][0]]); - tmp1[2].mul(lagrange[edgeIdx[s][0][0]]); - - tmp2[0].mul(lagrange[edgeIdx[s][0][1]]); - tmp2[1].mul(lagrange[edgeIdx[s][0][1]]); - tmp2[2].mul(lagrange[edgeIdx[s][0][1]]); - - tmp2[0].sub(tmp1[0]); - tmp2[1].sub(tmp1[1]); - tmp2[2].sub(tmp1[2]); - - basis[s][0] = new vector<Polynomial>(tmp2); - } -} - -LineNedelecBasis::~LineNedelecBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/LineNedelecBasis.h b/FunctionSpace/LineNedelecBasis.h deleted file mode 100644 index 51d4b43789555a68702198ddeaa2d800e4612543..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineNedelecBasis.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _LINENEDELECBASIS_H_ -#define _LINENEDELECBASIS_H_ - -#include "BasisHierarchical1Form.h" - -/** - @class LineNedelecBasis - @brief Nedelec Basis for Lines - - This class can instantiate a Nedelec Basis for Lines -*/ - -class LineNedelecBasis: public BasisHierarchical1Form{ - public: - //! Returns a new Nedelec Basis for Lines - //! - LineNedelecBasis(void); - - //! Deletes this Basis - //! - virtual ~LineNedelecBasis(void); -}; - -#endif diff --git a/FunctionSpace/LineNodeBasis.cpp b/FunctionSpace/LineNodeBasis.cpp deleted file mode 100644 index 337801c7c8d66aaa89a8b6dbbcd3b2f0fbc85a76..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineNodeBasis.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "LineNodeBasis.h" - -using namespace std; - -LineNodeBasis::LineNodeBasis(size_t order){ - // Set Basis Type // - this->order = order; - - type = TYPE_LIN; - dim = 1; - - nVertex = 2; - nEdge = (order - 1); - nFace = 0; - nCell = 0; - nFunction = nVertex + nEdge + nFace + nCell; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - // Legendre Polynomial // - Polynomial* intLegendre = new Polynomial[order]; - Legendre::integrated(intLegendre, order); - - // Lagrange Polynomial // - const Polynomial lagrange[2] = - { - Polynomial(Polynomial(0.5, 0, 0, 0) - - Polynomial(0.5, 1, 0, 0)), - - Polynomial(Polynomial(0.5, 0, 0, 0) + - Polynomial(0.5, 1, 0, 0)), - }; - - // Basis // - basis = new Polynomial**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new Polynomial*[nFunction]; - - // Vertex Based // - for(size_t s = 0; s < nOrientation; s++){ - basis[s][0] = new Polynomial(lagrange[0]); - basis[s][1] = new Polynomial(lagrange[1]); - } - - // Edge Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex; - - for(size_t l = 1; l < order; l++){ - basis[s][i] = - new Polynomial(intLegendre[l].compose(lagrange[edgeIdx[s][0][1]] - - lagrange[edgeIdx[s][0][0]])); - - i++; - } - } - - // Free Temporary Sapce // - delete[] intLegendre; -} - -LineNodeBasis::~LineNodeBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/LineNodeBasis.h b/FunctionSpace/LineNodeBasis.h deleted file mode 100644 index 4b46bbe497cd59a46b42b5226e22da5e1b71dfdc..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineNodeBasis.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _LINENODEBASIS_H_ -#define _LINENODEBASIS_H_ - -#include "BasisHierarchical0Form.h" - -/** - @class LineNodeBasis - @brief A Node Basis for Lines - - This class can instantiate a Node-Based Basis (high or low order) for Lines. - - It uses an adaptation of - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation. - - This Basis is a restriction of a Quad Basis to @f$y = 0@f$. - - It also uses the following mapping: @f$x = \frac{u + 1}{2}@f$. - */ - -class LineNodeBasis: public BasisHierarchical0Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Node-Basis for Lines of the given order - LineNodeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~LineNodeBasis(void); -}; - -#endif diff --git a/FunctionSpace/LineReferenceSpace.cpp b/FunctionSpace/LineReferenceSpace.cpp deleted file mode 100644 index 7106c8b6f7230ffd29343d835b41ca598194372d..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineReferenceSpace.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include <sstream> -#include "LineReferenceSpace.h" - -using namespace std; - -LineReferenceSpace::LineReferenceSpace(void){ - // Vertex Definition // - nVertex = 2; - - // Edge Definition // - refEdgeNodeIdx.resize(1); // One Edge per Line - refEdgeNodeIdx[0].resize(2); // Two Nodes per Edge - - refEdgeNodeIdx[0][0] = 0; - refEdgeNodeIdx[0][1] = 1; - - // Face Definition // - refFaceNodeIdx.clear(); // No Face in Line - - init(); -} - -LineReferenceSpace::~LineReferenceSpace(void){ -} - -string LineReferenceSpace::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}{c}" << 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 - << endl - - << "\\path[line]" - << " (n" << orderedEdgeNodeIdx[s][0][0] << ")" - << " -- " - << " (n" << orderedEdgeNodeIdx[s][0][1] << ");" - << endl - - << "\\end{tikzpicture} \\\\ \\\\" << endl << endl; - } - - stream << "\\end{longtable}" << endl - << "\\end{document}" << endl; - - return stream.str(); -} diff --git a/FunctionSpace/LineReferenceSpace.h b/FunctionSpace/LineReferenceSpace.h deleted file mode 100644 index ab613949acc073fd1c0e6dc5a170f506e2c15df3..0000000000000000000000000000000000000000 --- a/FunctionSpace/LineReferenceSpace.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _LINEREFERENCESPACE_H_ -#define _LINEREFERENCESPACE_H_ - -#include <string> -#include "ReferenceSpace.h" - -/** - @class LineReferenceSpace - @brief ReferenceSpace for a Line - - This class implements a ReferenceSpace for a Line. - */ - -class LineReferenceSpace: public ReferenceSpace{ - public: - LineReferenceSpace(void); - virtual ~LineReferenceSpace(void); - - virtual std::string toLatex(void) const; -}; - -/** - @fn LineReferenceSpace::LineReferenceSpace - Instatiate a new ReferenceSpace for a Line - ** - - @fn LineReferenceSpace::~LineReferenceSpace - Deletes this LineReferenceSpace -*/ - -#endif diff --git a/FunctionSpace/PermutationTree.cpp b/FunctionSpace/PermutationTree.cpp deleted file mode 100644 index f918dc2eed4f3a1a5b33b83e02f4fe10b523dcba..0000000000000000000000000000000000000000 --- a/FunctionSpace/PermutationTree.cpp +++ /dev/null @@ -1,636 +0,0 @@ -#include <map> -#include <fstream> -#include <cstring> - -#include "Exception.h" -#include "PermutationTree.h" - -using namespace std; - -PermutationTree::PermutationTree(const std::vector<size_t>& refSequence){ - // Sequence size // - sequenceSize = refSequence.size(); - - // List of leaf // - list<node_s*> listOfLeaf; - - // Root // - root = new node_t; - - root->myChoice = -1; - root->nxtChoice = refSequence; - root->father = NULL; - - root->leafId = -1; - root->tag = -1; - - // Tree // - nextNodeId = 0; - populate(root, listOfLeaf); - - // Leaf // - const size_t nLeaf = listOfLeaf.size(); - leaf.assign(listOfLeaf.begin(), listOfLeaf.end()); - - for(size_t i = 0; i < nLeaf; i++) - leaf[i]->leafId = i; -} - -PermutationTree::PermutationTree(const char* stream){ - // Populate from stream - populateFromStream(stream); -} - -PermutationTree::PermutationTree(const std::string& path){ - // Read file // - // Open Stream - ifstream input; - input.exceptions(std::ifstream::failbit | std::ifstream::badbit); - input.open(path.c_str(), std::ifstream::binary); - - // Get size of stream (go to stream end) - input.seekg(0, std::ifstream::end); - const size_t size = input.tellg(); - - // Reset stream possition - input.seekg(0, std::ifstream::beg); - - // Alloc byte stream & Read file - char* stream = new char[size]; - input.read(stream, size); - - // Populate from stream - populateFromStream(stream); - - // Free stream - delete[] stream; -} - -void PermutationTree::populate(node_t* node, - std::list<node_t*>& listOfLeaf){ - // Node Id // - node->nodeId = nextNodeId; - nextNodeId++; - - // Number of son // - const size_t nSon = node->nxtChoice.size(); - - // Alloc space for son // - node->son.resize(nSon); - - // Init each son // - for(size_t i = 0; i < nSon; i++){ - // Alloc Son - node->son[i] = new node_t; - - // Take father ith choice - node->son[i]->myChoice = node->nxtChoice[i]; - - // Next choices are all but ith - node->son[i]->nxtChoice.resize(nSon - 1); - for(size_t j = 0, k = 0; j < nSon; j++){ - if(j != i){ - node->son[i]->nxtChoice[k] = node->nxtChoice[j]; - k++; - } - - else{ - } - } - - // Dummy Stuff - node->son[i]->leafId = -1; - node->son[i]->tag = -1; - - // Father - node->son[i]->father = node; - - // Add Son - populate(node->son[i], listOfLeaf); - } - - // If I am a leaf, add me to listOfLeaf - if(!nSon) - listOfLeaf.push_back(node); -} - -void PermutationTree::populateFromStream(const char* stream){ - // Header Size - const size_t hSize = headerSize(); - - // Read header - size_t uSize; // Unlink struct size - - memcpy(&uSize, stream + 0 * sizeof(size_t), sizeof(size_t)); - memcpy(&nextNodeId, stream + 1 * sizeof(size_t), sizeof(size_t)); - memcpy(&sequenceSize, stream + 2 * sizeof(size_t), sizeof(size_t)); - - // Unserialize unlink struct - vector<unlink_t> unlink(nextNodeId); - for(size_t i = 0; i < nextNodeId; i++) - unserialize(stream + hSize + (i * uSize), &unlink[i]); - - // Regenerate Tree // - rebuild(unlink); -} - -void PermutationTree::unserialize(const char* stream, unlink_t* unlink){ - // Some padding data // - const size_t nxtChoiceStart = 2 * sizeof(size_t); - const size_t fatherIdStart = nxtChoiceStart + sequenceSize * sizeof(size_t); - const size_t sonStart = fatherIdStart + 2 * sizeof(size_t); - const size_t otherIdStart = sonStart + sequenceSize * sizeof(size_t); - - // Next Choice // - memcpy(&unlink->myChoice, stream + 0 * sizeof(size_t), sizeof(size_t)); - memcpy(&unlink->nNxtChoice, stream + 1 * sizeof(size_t), sizeof(size_t)); - - unlink->nxtChoice.resize(unlink->nNxtChoice); - for(size_t i = 0; i < unlink->nNxtChoice; i++) - memcpy(&unlink->nxtChoice[i], - stream + nxtChoiceStart + i * sizeof(size_t), sizeof(size_t)); - - // Father and Son // - memcpy(&unlink->fatherId, - stream + fatherIdStart + 0 * sizeof(size_t), sizeof(size_t)); - - memcpy(&unlink->nSon, - stream + fatherIdStart + 1 * sizeof(size_t), sizeof(size_t)); - - unlink->sonId.resize(unlink->nSon); - for(size_t i = 0; i < unlink->nSon; i++) - memcpy(&unlink->sonId[i], - stream + sonStart + i * sizeof(size_t), sizeof(size_t)); - - // Node Id // - memcpy(&unlink->nodeId, - stream + otherIdStart + 0 * sizeof(size_t), sizeof(size_t)); - - // Leaf Id // - memcpy(&unlink->leafId, - stream + otherIdStart + 1 * sizeof(size_t), sizeof(size_t)); - - // Tag // - memcpy(&unlink->tag, - stream + otherIdStart + 2 * sizeof(size_t), sizeof(size_t)); -} - -void PermutationTree::rebuild(std::vector<unlink_t>& unlink){ - // Almost linked nodes (node of node_t type but without connected nodes) // - vector<node_t*> node(nextNodeId); - for(size_t i = 0; i < nextNodeId; i++) - node[i] = copy(&unlink[i]); - - // Root // - root = node[0]; - for(size_t j = 0; j < root->son.size(); j++) - root->son[j] = node[unlink[0].sonId[j]]; - - // Link all other nodes & Gather leafs // - list<node_t*> listOfLeaf; - - for(size_t i = 1; i < nextNodeId; i++){ - // Father - node[i]->father = node[unlink[i].fatherId]; - - // Son - for(size_t j = 0; j < node[i]->son.size(); j++) - node[i]->son[j] = node[unlink[i].sonId[j]]; - - // Leaf (if it is actualy a leaf) - if(node[i]->leafId != (size_t)(-1)) - listOfLeaf.push_back(node[i]); - } - - // Get Leafs // - leaf.assign(listOfLeaf.begin(), listOfLeaf.end()); -} - -PermutationTree::node_t* PermutationTree::copy(unlink_t* unlink){ - node_t* node = new node_t; - - node->myChoice = unlink->myChoice; - node->nxtChoice.resize(unlink->nNxtChoice); - - for(size_t i = 0; i < unlink->nNxtChoice; i++) - node->nxtChoice[i] = unlink->nxtChoice[i]; - - node->father = NULL; - node->son.resize(unlink->nSon); - - node->nodeId = unlink->nodeId; - node->leafId = unlink->leafId; - node->tag = unlink->tag; - - return node; -} - -PermutationTree::~PermutationTree(void){ - destroy(root); -} - -void PermutationTree::destroy(node_t* node){ - // Delete Son - const size_t nSon = node->son.size(); - - for(size_t i = 0; i < nSon; i++) - destroy(node->son[i]); - - // Delete me - delete node; -} - -PermutationTree::node_t* -PermutationTree::getLeaf(node_t* root, - const std::vector<size_t>& sequence, - size_t offset){ - // Number of son - const size_t nSon = root->son.size(); - - // If a leaf return root - if(!nSon) - return root; - - // Else, lookup - else{ - // Find next son - size_t i = 0; - for(i = 0; i < nSon && root->nxtChoice[i] != sequence[offset]; i++) - ; - - // If no math found, throw an Exception - if(i == nSon) - throw Exception("PermutationTree: cannot find given sequence"); - - // Get son leaf - return getLeaf(root->son[i], sequence, offset + 1); - } -} - -void -PermutationTree::fillWithPermutation(size_t permutationId, - std::vector<size_t>& vectorToFill) const{ - // Go from ith leaf to root // - // And fill vectorToFill from end to start // - - const size_t max = -1; - - node_t* node = leaf[permutationId]; - size_t i = sequenceSize - 1; - - while(i != max && node){ - vectorToFill[i] = node->myChoice; - i--; - node = node->father; - } -} - -void PermutationTree::compressTag(void){ - // Populate Tag map - const size_t nLeaf = leaf.size(); - multimap<size_t, node_t*> tag; - - for(size_t i = 0; i < nLeaf; i++) - tag.insert(pair<size_t, node_t*>(leaf[i]->tag, leaf[i])); - - // Compress Tag - const multimap<size_t, node_t*>::iterator end = tag.end(); - multimap<size_t, node_t*>::iterator it = tag.begin(); - - size_t currentTag = it->first; - size_t nextTag = 0; - - for(; it != end; it++){ - // If new old tag --> increase new tag by one - if(it->first != currentTag){ - currentTag = it->first; - nextTag++; - } - - // Apply same new tag - it->second->tag = nextTag; - } -} - -std::vector<std::pair<size_t, size_t> > -PermutationTree::getAllTagsCount(void) const{ - // Init Temp map - map<size_t, size_t> counter; - - // Loop on leafs and populate map - const size_t nLeaf = leaf.size(); - pair<map<size_t, size_t>::iterator, bool> inserted; - - for(size_t i = 0; i < nLeaf; i++){ - // Try insert new tag with counter to one - inserted = counter.insert(std::pair<size_t, size_t>(leaf[i]->tag, 1)); - - if(!inserted.second) - // If known tag -- add one to mapped value - inserted.first->second++; - } - - // Serialize this map and return - std::vector<std::pair<size_t, size_t> > ret(counter.begin(), counter.end()); - return ret; -} - -string PermutationTree::toString(void) const{ - // Number of Permutation // - const size_t max_t = -1; - const size_t nPerm = leaf.size(); - - // Temporary // - stringstream stream; - vector<size_t> permutation(sequenceSize); - - // Build String // - for(size_t i = 0; i < nPerm; i++){ - fillWithPermutation(i, permutation); - - stream << "Permutation #" << i << ":" << endl - << " -- " << permutation[0]; - - for(size_t j = 1; j < sequenceSize; j++) - stream << " " << permutation[j]; - - stream << endl << " -- Tag ("; - - if(leaf[i]-> tag != max_t) - stream << leaf[i]->tag; - - stream << ")" << endl - << endl; - } - - // Return // - return stream.str(); -} - -string PermutationTree::toLatex(void) const{ - stringstream stream; - - // Small FEM // - stream << "%%% Automaticaly generated by SmallFem" << endl; - - // Header // - stream << "\\documentclass[11pt]{article}" << endl << endl - - << "\\usepackage{tikz}" << endl - << endl - << "\\usetikzlibrary{arrows}" << endl - << "\\tikzstyle{vertex} = [circle, fill = black!25, inner sep = 2pt," - << endl - << " minimum size = 15pt]" - << endl - << "\\tikzstyle{circ} = [draw, circle, minimum size = 15pt]" - << endl - << "\\tikzstyle{line} = [thick, black]" << endl - << "\\tikzstyle{box} = [draw, rectangle, minimum width=20pt," - << endl - << " minimum height=10pt]" - << endl - << "\\tikzstyle{arrow} = [-stealth']" << endl << endl - << "\\begin{document}" << endl - << "\\begin{tikzpicture}"; - - // Options // - stream << "[" - << "grow = right," - << "edge from parent/.style={draw, line}," - << "level 1/.style={sibling distance=12em}," - << "level 2/.style={sibling distance=4em}," - << "level 3/.style={sibling distance=2em}," - << "level 5/.style={level distance=5em}," - << "]" << endl; - - // Tree // - // Root - stream << "\\node[vertex] (root) {\\phantom{$0$}}" << endl; - - // Travel from root in deepFirst and add childs to stream - deepFirstStream(root, stream); - - // Final ; - stream << ";" << endl << endl; - - // Reference Element - for(size_t i = 0; i < leaf.size(); i++) - if(leaf[i]->tag == leaf[i]->leafId) - stream << "\\node[right, xshift = 0.6em] at(l" << leaf[i]->tag - << ") {(\\textit{Reference})};" << endl; - - stream << endl; - - // Legend - stream << "\\node[box, xshift = -10em, yshift = 1.5em] at(root) (box) " - << "{};" << endl - << "\\node[right, xshift = 0.7em] at(box) " - << "{Leaf Tag};" << endl - << "\\node[vertex, yshift = 3em] at(box) (vert) " - << "{};" << endl - << "\\node[right, xshift = 0.7em] at(vert) " - << "{Vertex number};" << endl - << "\\node[ xshift = -10em, yshift = -1.5em] at(root) (ori) " - << "{$[\\dots]$};" << endl - << "\\node[right, xshift = 0.7em] at(ori) " - << "{Permutation};" << endl - << "\\node[circ, yshift = -3em] at(ori) (circ) " - << "{};" << endl - << "\\node[right, xshift = 0.7em] at(circ) " - << "{Orientation tag};" << endl; - - // Footer // - stream << "\\end{tikzpicture}" << endl - << "\\end{document}" << endl; - - return stream.str(); - -} - -void PermutationTree::deepFirstStream(node_t* node, stringstream& stream) const{ - vector<size_t> permutation(getSequenceSize()); - - // If node is root, don't add to stream: just loop on its childs - if(node->myChoice == (size_t)(-1)) - for(size_t i = 0; i < node->son.size(); i++) - deepFirstStream(node->son[i], stream); - - // Else, insert node in stream as child // - else{ - stream << "child{node[vertex]"; - - // If node, name it - // if(node->son.size() == 0) - // stream << "(l" << node->leafId << ")"; - - stream << "{" << node->myChoice << "}" << endl; - - for(size_t i = 0; i < node->son.size(); i++) - deepFirstStream(node->son[i], stream); - - // If leaf, child is tag and permutation // - if(node->son.size() == 0){ - // Leaf Id - stream << "child{node[box, anchor=west]{$" << node->leafId << "$} " - << "edge from parent[arrow]" << endl; - - // Permutation - fillWithPermutation(node->leafId, permutation); - - stream << "child[anchor=west]{node{$["; - - for(size_t j = 0; j < permutation.size() - 1; j++) - stream << permutation[j] << ", "; - - stream << permutation[permutation.size() - 1] << "]$}" - << " edge from parent[arrow]" << endl; - - // Tag - stream << "child{node[circ, anchor=west]"; - - // Is true orientation ? - if(node->tag == node->leafId) - stream << " (l" << node->tag << ") "; - - stream << "{" << node->tag << "} edge from parent[arrow]" << endl; - - // Done - stream << "}}}"; - } - - stream << "}" << endl; - } - - // If leaf, return // - if(node->son.size() == 0) - return; -} - -std::pair<size_t, char*> PermutationTree::serialize(void) const{ - // Enumerate Nodes // - list<node_t*> node; - enumerate(root, node); - - // Serialize all nodes // - // Unlink root to get (fixed) size of unlink type - unlink_t tmp; - unlink(root, &tmp, sequenceSize); - - // Get Sizes - const size_t hSize = headerSize(); // Header size - const size_t uSize = unlinkSize(&tmp); // Unlink struct size - const size_t nNode = node.size(); // Number of node/unlink struct - const size_t nSize = uSize * nNode; // Total size for unlink struct - const size_t sSize = hSize + nSize; // Stream size - - // Alloc byte Stream - char* stream = new char[sSize]; - for(size_t i = 0; i < sSize; i++) - stream[i] = 0; - - // Write header in Stream - memcpy(stream + 0 * sizeof(size_t), &uSize, sizeof(size_t)); - memcpy(stream + 1 * sizeof(size_t), &nNode, sizeof(size_t)); - memcpy(stream + 2 * sizeof(size_t), &sequenceSize, sizeof(size_t)); - - // Write unlinked node in Stream - list<node_t*>::iterator it = node.begin(); - - for(size_t i = 0; i < nNode; i++, it++){ - unlink(*it, &tmp, sequenceSize); - serialize(stream + hSize + (i * uSize), &tmp); - } - - // Return Stream & its size - return pair<size_t, char*>(sSize, stream); -} - -void PermutationTree::serialize(const std::string& path) const{ - // Serialize into byte Stream - std::pair<size_t, char*> stream = serialize(); - - // Write byte stream - ofstream output; - output.exceptions(std::ofstream::failbit | std::ofstream::badbit); - output.open(path.c_str(), std::ofstream::binary); - output.write(stream.second, stream.first); - output.close(); - - // Free - delete[] stream.second; -} - -void PermutationTree::enumerate(node_t* node, std::list<node_t*>& listOfNode){ - // Add this node - listOfNode.push_back(node); - - // Add son - const size_t nSon = node->son.size(); - for(size_t i = 0; i < nSon; i++) - enumerate(node->son[i], listOfNode); -} - -void PermutationTree::unlink(node_t* node, unlink_t* unlink, size_t maxSize){ - unlink->myChoice = node->myChoice; - unlink->nNxtChoice = node->nxtChoice.size(); - unlink->nxtChoice.resize(maxSize); // Use fixed size -- easyer serialization - - for(size_t i = 0; i < unlink->nNxtChoice; i++) - unlink->nxtChoice[i] = node->nxtChoice[i]; - - if(!node->father) - unlink->fatherId = (size_t)(-1); - else - unlink->fatherId = node->father->nodeId; - - unlink->nSon = node->son.size(); - unlink->sonId.resize(maxSize); // Use fixed size -- easyer serialization - - for(size_t i = 0; i < unlink->nSon; i++) - unlink->sonId[i] = node->son[i]->nodeId; - - unlink->nodeId = node->nodeId; - unlink->leafId = node->leafId; - unlink->tag = node->tag; -} - -void -PermutationTree::serialize(char* stream, unlink_t* unlink) const{ - // Some padding data // - const size_t nxtChoiceStart = 2 * sizeof(size_t); - const size_t fatherIdStart = nxtChoiceStart + sequenceSize * sizeof(size_t); - const size_t sonStart = fatherIdStart + 2 * sizeof(size_t); - const size_t otherIdStart = sonStart + sequenceSize * sizeof(size_t); - - // Next Choice // - memcpy(stream + 0 * sizeof(size_t), &unlink->myChoice, sizeof(size_t)); - memcpy(stream + 1 * sizeof(size_t), &unlink->nNxtChoice, sizeof(size_t)); - - for(size_t i = 0; i < unlink->nNxtChoice; i++) - memcpy(stream + nxtChoiceStart + i * sizeof(size_t), - &unlink->nxtChoice[i], sizeof(size_t)); - - // Father and Son // - memcpy(stream + fatherIdStart + 0 * sizeof(size_t), - &unlink->fatherId, sizeof(size_t)); - - memcpy(stream + fatherIdStart + 1 * sizeof(size_t), - &unlink->nSon, sizeof(size_t)); - - for(size_t i = 0; i < unlink->nSon; i++) - memcpy(stream + sonStart + i * sizeof(size_t), - &unlink->sonId[i], sizeof(size_t)); - - // Node Id // - memcpy(stream + otherIdStart + 0 * sizeof(size_t), - &unlink->nodeId, sizeof(size_t)); - - // Leaf Id // - memcpy(stream + otherIdStart + 1 * sizeof(size_t), - &unlink->leafId, sizeof(size_t)); - - // Tag // - memcpy(stream + otherIdStart + 2 * sizeof(size_t), - &unlink->tag, sizeof(size_t)); -} diff --git a/FunctionSpace/PermutationTree.h b/FunctionSpace/PermutationTree.h deleted file mode 100644 index 44b3c70b92ade37cb8629a2ee3ad45e976b3b05a..0000000000000000000000000000000000000000 --- a/FunctionSpace/PermutationTree.h +++ /dev/null @@ -1,258 +0,0 @@ -#ifndef _PERMUTATIONTREE_H_ -#define _PERMUTATIONTREE_H_ - -#include <cstdlib> -#include <vector> -#include <list> -#include <string> -#include <sstream> - -/** - @class PermutationTree - @brief A Permutation Tree - - This class represents a permutation tree. - That is, given a sequence of length N, - this tree will hold all the possible permutations - of the N elements of the given sequence. - - Every permuted sequence can be associated an ID and a tag. - By default all sequences are assigned the tag 0. - */ - -class PermutationTree{ - private: - // Tree node // - typedef struct node_s{ - size_t myChoice; - std::vector<size_t> nxtChoice; - - node_s* father; - std::vector<node_s*> son; - - size_t nodeId; - size_t leafId; - size_t tag; - } node_t; - - private: - // Tree node for serialization // - typedef struct unlink_s{ - size_t myChoice; - size_t nNxtChoice; - std::vector<size_t> nxtChoice; - - size_t fatherId; - size_t nSon; - std::vector<size_t> sonId; - - size_t nodeId; - size_t leafId; - size_t tag; - } unlink_t; - - private: - // Next Node Id & Total number of node // - size_t nextNodeId; - - // Sequence size // - size_t sequenceSize; - - // Root // - node_t* root; - - // Leaf // - std::vector<node_t*> leaf; - - public: - PermutationTree(const std::vector<size_t>& refSequence); - PermutationTree(const char* stream); - PermutationTree(const std::string& path); - ~PermutationTree(void); - - size_t getSequenceSize(void) const; - - size_t getNPermutation(void) const; - size_t getPermutationId(const std::vector<size_t>& sequence) const; - - void fillWithPermutation(size_t permutationId, - std::vector<size_t>& vectorToFill) const; - - void addTagToPermutation(size_t permutationId, size_t tag); - void compressTag(void); - size_t getTagFromPermutation(size_t permutationId) const; - - std::vector<std::pair<size_t, size_t> > getAllTagsCount(void) const; - - std::string toString(void) const; - std::string toLatex(void) const; - - std::pair<size_t, char*> serialize(void) const; - void serialize(const std::string& path) const; - - private: - void populate(node_t* node, std::list<node_t*>& listOfLeaf); - void populateFromStream(const char* stream); - void unserialize(const char* stream, unlink_t* unlink); - void rebuild(std::vector<unlink_t>& unlink); - - static node_t* copy(unlink_t* unlink); - static void destroy(node_t* node); - - static node_t* getLeaf(node_t* root, - const std::vector<size_t>& sequence, - size_t offset); - - void deepFirstStream(node_t* node, std::stringstream& stream) const; - - static void enumerate(node_t* node, std::list<node_t*>& listOfNode); - static void unlink(node_t* node, unlink_t* unlink, size_t maxSize); - void serialize(char* stream, unlink_t* unlink) const; - - static size_t unlinkSize(unlink_t* unlink); - static size_t headerSize(void); -}; - -/** - @fn PermutationTree::PermutationTree(const std::vector<size_t>& refSequence) - @param refSequence A vector of integers - - Instanciates a new PermutationTree build on the given vector - ** - - @fn PermutationTree::PermutationTree(const char* stream) - @param stream A byte stream - - Instanciates a new PermutationTree by loading the given byte stream - - @see PermutationTree:serialize(char*) - ** - - @fn PermutationTree::PermutationTree(const std::string& path) - @param path A file path - - Instanciates a new PermutationTree by loading the file given in path - - @see PermutationTree:serialize(const std::string&) - ** - - @fn PermutationTree::~PermutationTree - - Deletes this PermutationTree - ** - - @fn PermutationTree::getSequenceSize - @return Returns the size of the sequences - ** - - @fn PermutationTree::getNPermutation - @return Returns the number of permutation of the original sequence - (including the original sequence) - ** - - @fn PermutationTree::getPermutationId - @param sequence A sequence - @return Returns the ID of the given sequence - ** - - @fn PermutationTree::fillWithPermutation - @param permutationId A permuted sequence ID - @param vectorToFill An allocated vector of size - PermutationTree::getSequenceSize() - - Populates the given vector with the permuted sequence of the given ID - ** - - @fn PermutationTree::addTagToPermutation - @param permutationId A permuted sequence ID - @param tag An integer - - Associates the given permutation with the given tag - ** - - @fn PermutationTree::compressTag - - Takes all the tags of this tree and replace them - by their compressed version. - - When tags are compressed, it means that their value - is mapped in the range 0, ..., (number of different tag - 1). - - The mapping is such that the smaller/bigger relation - between the tags is preserved. - ** - - @fn PermutationTree::getTagFromPermutation - @param permutationId A permuted sequence ID - @return Returns the tag of the given sequence - ** - - @fn PermutationTree::getAllTagsCount - @return Returns a vector of pair such that: - @li The first entry is a tag - @li The second entry is the number of node having this tag - - The returned vector has en entry for each possible tag - ** - - @fn PermutationTree::toString - @return Returns a string describing this PermutationTree - ** - - @fn PermutationTree::toLatex - @return Returns a string (of a Latex file) describing this PermutationTree - ** - - @fn PermutationTree::serialize(void) const - - Serialize this PermutationTree into a byte stream - - @return Returns a pair such that: - @li The first entry is stream size - @li the second entry is a pointer to the allocated stream - ** - - @fn PermutationTree::serialize(const std::string&) const - @param path A file path - - Serialize this PermutationTree into the given file path - */ - -////////////////////// -// Inline Functions // -////////////////////// - -inline size_t PermutationTree::getSequenceSize(void) const{ - return sequenceSize; -} - -inline size_t PermutationTree::getNPermutation(void) const{ - return leaf.size(); -} - -inline size_t PermutationTree:: -getPermutationId(const std::vector<size_t>& sequence) const{ - return getLeaf(root, sequence, 0)->leafId; -} - -inline void PermutationTree:: -addTagToPermutation(size_t permutationId, size_t tag){ - leaf[permutationId]->tag = tag; -} - -inline size_t PermutationTree:: -getTagFromPermutation(size_t permutationId) const{ - return leaf[permutationId]->tag; -} - -inline size_t -PermutationTree::unlinkSize(unlink_t* unlink){ - return (7 + unlink->nNxtChoice + unlink->nSon) * sizeof(size_t); -} - -inline size_t -PermutationTree::headerSize(void){ - return 3 * sizeof(size_t); -} - -#endif diff --git a/FunctionSpace/Polynomial.cpp b/FunctionSpace/Polynomial.cpp deleted file mode 100644 index 9418c0350fd184286d41b645445f5ef62ae3f617..0000000000000000000000000000000000000000 --- a/FunctionSpace/Polynomial.cpp +++ /dev/null @@ -1,704 +0,0 @@ -#include <cmath> -#include <sstream> -#include <stack> - -#include "Polynomial.h" - -using namespace std; - -const char Polynomial::coefName[3] = {'x', 'y', 'z'}; - -Polynomial::Polynomial(double coef, - int powerX, - int powerY, - int powerZ){ - nMon = 1; - mon = new monomial_t[1]; - - mon[0].coef = coef; - mon[0].power[0] = powerX; - mon[0].power[1] = powerY; - mon[0].power[2] = powerZ; -} - -Polynomial::Polynomial(const Polynomial& other){ - nMon = other.nMon; - mon = copyMonomial(other.mon, nMon); -} - -Polynomial::Polynomial(void){ - nMon = 0; - mon = NULL; -} - -Polynomial::~Polynomial(void){ - if(mon) - delete[] mon; -} - -void Polynomial::derivative(int dim){ - // Take derivative // - for(int i = 0; i < nMon; i++){ - mon[i].coef *= mon[i].power[dim]; - mon[i].power[dim] -= 1; - } - - // Remove zero monomials // - int N = 0; - stack<monomial_t*> s; - - for(int i = 0; i < nMon; i++){ - if(mon[i].coef != 0.0){ - s.push(&mon[i]); - N++; - } - } - - // If no monomial any more ---> return zero polynomial - if(!N){ - delete[] mon; - - mon = zeroPolynomial(); - nMon = 1; - return; - } - - // If no zero found ---> return; - if(N == nMon) - return; - - // Else, remove them // - monomial_t* tmp = mon; - - mon = new monomial_t[N]; - nMon = N; - - for(int i = N - 1; i >= 0; i--){ - mon[i] = *(s.top()); - s.pop(); - } - - delete[] tmp; - - // Sort resulting monomial and return // - sort(mon, nMon); - - return; -} - -vector<Polynomial> Polynomial::gradient(void) const{ - vector<Polynomial> grad(3); - - // Copy Polynomial // - grad[0] = *this; - grad[1] = *this; - grad[2] = *this; - - // Derivative with respect to each direction // - grad[0].derivative(0); - grad[1].derivative(1); - grad[2].derivative(2); - - return grad; -} - -vector<Polynomial> Polynomial::curl(const vector<Polynomial>& p){ - vector<Polynomial> rot(3); - - // Partial Derivatives // - Polynomial dP0d1 = p[0]; - Polynomial dP0d2 = p[0]; - Polynomial dP1d0 = p[1]; - Polynomial dP1d2 = p[1]; - Polynomial dP2d0 = p[2]; - Polynomial dP2d1 = p[2]; - - dP0d1.derivative(1); - dP0d2.derivative(2); - dP1d0.derivative(0); - dP1d2.derivative(2); - dP2d0.derivative(0); - dP2d1.derivative(1); - - // Curl // - rot[0] = dP2d1 - dP1d2; - rot[1] = dP0d2 - dP2d0; - rot[2] = dP1d0 - dP0d1; - - // Return // - return rot; -} - -Polynomial Polynomial::divergence(const vector<Polynomial>& p){ - // Partial Derivatives // - Polynomial dP0d0 = p[0]; - Polynomial dP1d1 = p[1]; - Polynomial dP2d2 = p[2]; - - dP0d0.derivative(0); - dP1d1.derivative(1); - dP2d2.derivative(2); - - // Return Div // - return dP0d0 + dP1d1 + dP2d2; -} - -double Polynomial::at - (double x, double y, double z) const{ - - double val = 0; - for(int i = 0; i < nMon; i++){ - val += mon[i].coef * pow(x, mon[i].power[0]) - * pow(y, mon[i].power[1]) - * pow(z, mon[i].power[2]); - } - - return val; -} - -fullVector<double> Polynomial::at(const std::vector<Polynomial>& P, - double x, - double y, - double z){ - fullVector<double> val(3); - - val(0) = P[0].at(x, y, z); - val(1) = P[1].at(x, y, z); - val(2) = P[2].at(x, y, z); - - return val; -} - - -Polynomial Polynomial::operator+(const Polynomial& other) const{ - Polynomial newP; - - newP.nMon = mergeMon(mon, nMon, other.mon, other.nMon, &newP.mon); - - return newP; -} - -Polynomial Polynomial::operator-(const Polynomial& other) const{ - const int otherNMon = other.nMon; - monomial_t* otherMinus = copyMonomial(other.mon, otherNMon); - - Polynomial newP; - - mult(otherMinus, otherNMon, -1); - newP.nMon = mergeMon(mon, nMon, otherMinus, otherNMon, &newP.mon); - - delete[] otherMinus; - return newP; -} - -Polynomial Polynomial::operator*(const Polynomial& other) const{ - Polynomial newP; - - newP.nMon = mult(mon, nMon, other.mon, other.nMon, &newP.mon); - - return newP; -} - -Polynomial Polynomial::operator*(double alpha) const{ - Polynomial newP; - - newP.mon = copyMonomial(mon, nMon); - newP.nMon = nMon; - - newP.mul(alpha); - - return newP; -} - - -void Polynomial::add(const Polynomial& other){ - monomial_t* tmp = mon; - - nMon = mergeMon(mon, nMon, other.mon, other.nMon, &mon); - - delete[] tmp; -} - -void Polynomial::sub(const Polynomial& other){ - const int otherNMon = other.nMon; - monomial_t* otherMinus = copyMonomial(other.mon, otherNMon); - monomial_t* tmp = mon; - - mult(otherMinus, otherNMon, -1); - nMon = mergeMon(mon, nMon, otherMinus, otherNMon, &mon); - - delete[] otherMinus; - delete[] tmp; -} - -void Polynomial::mul(const Polynomial& other){ - monomial_t* tmp = mon; - - nMon = mult(mon, nMon, other.mon, other.nMon, &mon); - - delete[] tmp; -} - -void Polynomial::mul(double alpha){ - for(int i = 0; i < nMon; i++) - mon[i].coef *= alpha; -} - -void Polynomial::power(int n){ - if (n < 0) - return; - - switch(n){ - case 0: - delete[] mon; - - mon = unitPolynomial(); - nMon = 1; - - break; - - case 1: - break; - - default: - Polynomial old = *this; - - for(int i = 1; i < n; i++) - mul(old); - - break; - } -} - -Polynomial Polynomial::compose(const Polynomial& other) const{ - stack<monomial_t> stk; - - for(int i = 0; i < nMon; i++) - compose(&mon[i], other, &stk); - - return polynomialFromStack(stk); -} - -Polynomial Polynomial::compose(const Polynomial& otherA, - const Polynomial& otherB) const{ - stack<monomial_t> stk; - - for(int i = 0; i < nMon; i++) - compose(&mon[i], otherA, otherB, &stk); - - return polynomialFromStack(stk); -} - -Polynomial Polynomial::compose(const Polynomial& otherA, - const Polynomial& otherB, - const Polynomial& otherC) const{ - stack<monomial_t> stk; - - for(int i = 0; i < nMon; i++) - compose(&mon[i], otherA, otherB, otherC, &stk); - - return polynomialFromStack(stk); -} - -void Polynomial::operator=(const Polynomial& other){ - if(mon) - delete[] mon; - - nMon = other.nMon; - mon = copyMonomial(other.mon, nMon); -} - -string Polynomial:: -toString(const Polynomial::monomial_t* mon, const bool isAbs){ - stringstream stream; - const bool minusOne = mon->coef == -1.0; - const bool notUnitCoef = mon->coef != 1.0 && !minusOne; - - // If we have a constant term - if(!mon->power[0] && !mon->power[1] && !mon->power[2]){ - stream << mon->coef; - return stream.str(); - } - - // If we're here, we do not have a constant term - - // If we have a coefficient of '1', we don't display it - if(notUnitCoef && isAbs) - stream << abs(mon->coef); - - if(notUnitCoef && !isAbs) - stream << mon->coef; - - if(minusOne && !isAbs) - stream << "-"; - - // We look for each power - bool notOnce = false; - for(int i = 0; i < 3; i++){ - // If we have a non zero power, we display it - if(mon->power[i]){ - if(notUnitCoef || notOnce) - stream << " * "; - - stream << coefName[i]; - - if(mon->power[i] != 1) - stream << "^" << mon->power[i]; - - notOnce = true; - } - } - - return stream.str(); -} - -string Polynomial::toString(void) const{ - stringstream stream; - bool isAbs = false; - - stream << toString(&mon[0], isAbs); - - for(int i = 1; i < nMon; i++){ - if(mon[i].coef < 0.0){ - stream << " - "; - isAbs = true; - } - - else{ - stream << " + "; - isAbs = false; - } - - stream << toString(&mon[i], isAbs); - } - - return stream.str(); -} - -bool Polynomial::isSmaller(const Polynomial::monomial_t* a, - const Polynomial::monomial_t* b){ - // GRevLex order: - // http://www.math.uiuc.edu/Macaulay2/doc/Macaulay2-1.4/share/doc/Macaulay2/Macaulay2Doc/html/___G__Rev__Lex.html - - int dif[3]; - int last = 0; - - if(isSmallerPower(a, b)) - return true; - - if(isEqualPower(a, b)){ - for(int i = 0, j = 2; i < 3; i++, j--) - dif[i] = b->power[j] - a->power[j]; - - for(int i = 0; i < 3; i++) - if(dif[i]) - last = dif[i]; - - if(last < 0) - return true; - - else - return false; - } - - return false; -} - -void Polynomial::sort(monomial_t* mon, int size){ - for(int i = 0; i < size; i++) - for(int j = i; j < size; j++) - if(isSmaller(&mon[j], &mon[i])) - swap(mon, i, j); -} - -void Polynomial::swap(monomial_t* mon, int i, int j){ - monomial_t tmp = mon[i]; - mon[i] = mon[j]; - mon[j] = tmp; -} - - -int Polynomial::mergeMon(monomial_t* sourceA, int sizeA, - monomial_t* sourceB, int sizeB, - monomial_t** dest){ - stack<monomial_t> s; - monomial_t tmp; - - int i = 0; - int j = 0; - int N = 0; - - while(i < sizeA && j < sizeB){ - if(sourceA[i].coef == 0.0) - i++; - - else if(sourceB[j].coef == 0.0) - j++; - - else if(isEqual(&sourceA[i], &sourceB[j])){ - tmp = sourceA[i]; - tmp.coef += sourceB[j].coef; - - if(tmp.coef != 0.0){ - s.push(tmp); - N++; - } - - i++; - j++; - } - - else if(isSmaller(&sourceA[i], &sourceB[j])){ - s.push(sourceA[i]); - i++; - N++; - } - - else{ - s.push(sourceB[j]); - j++; - N++; - } - } - - while(i == sizeA && j < sizeB){ - s.push(sourceB[j]); - j++; - N++; - } - - while(i < sizeA && j == sizeB){ - s.push(sourceA[i]); - i++; - N++; - } - - if(!N){ - *dest = zeroPolynomial(); - N++; - } - - else{ - *dest = new monomial_t[N]; - - for(int k = N - 1; k >= 0; k--){ - (*dest)[k] = s.top(); - s.pop(); - } - } - - return N; -} - -int Polynomial::mult(const monomial_t* sourceA, int sizeA, - const monomial_t* sourceB, int sizeB, - monomial_t** dest){ - - const monomial_t* a; // smaller polynomial - const monomial_t* b; // bigger polynomial - int nDist; - int size; - - if(sizeA < sizeB){ - a = sourceA; - b = sourceB; - nDist = sizeA; - size = sizeB; - } - - else{ - a = sourceB; - b = sourceA; - nDist = sizeB; - size = sizeA; - } - - // Check if zero // - if(a[0].coef == 0 || b[0].coef == 0){ - *dest = zeroPolynomial(); - return 1; - } - - // Distrubute all monomials // - monomial_t** dist = new monomial_t*[nDist]; - - for(int i = 0; i < nDist; i++){ - dist[i] = copyMonomial(b, size); - - distribute(dist[i], size, &a[i]); - } - - // Merge // - int finalSize = size; - int nDistMinus = nDist - 1; - monomial_t** tmp = new monomial_t*[nDistMinus]; // Temp array for all dist[0]; - - for(int i = 1, j = 0; i < nDist; i++, j++){ - tmp[j] = dist[0]; - - finalSize = mergeMon(dist[0], finalSize, - dist[i], size, - &dist[0]); - } - - // Keep distributed polynomial // - *dest = dist[0]; - - // Free Temporary Resources and Return // - for(int i = 1, j = 0; i < nDist; i++, j++){ - delete[] dist[i]; - delete[] tmp[j]; - } - - delete[] dist; - delete[] tmp; - - return finalSize; -} - -void Polynomial::mult(monomial_t* source, int size, double alpha){ - for(int i = 0; i < size; i++) - source[i].coef *= alpha; -} - - -void Polynomial::distribute(monomial_t* src, int size, const monomial_t* m){ - for(int i = 0; i < size; i++){ - src[i].coef *= m->coef; - - src[i].power[0] += m->power[0]; - src[i].power[1] += m->power[1]; - src[i].power[2] += m->power[2]; - } -} - -void Polynomial::compose(const monomial_t* src, - Polynomial comp, - std::stack<monomial_t>* stk){ - - comp.power(src->power[0]); - comp.mul(src->coef); - - const int size = comp.nMon; - - for(int i = 0; i < size; i++){ - if(comp.mon[i].coef != 0){ - - comp.mon[i].power[1] += src->power[1]; - comp.mon[i].power[2] += src->power[2]; - - stk->push(comp.mon[i]); - } - } -} - -void Polynomial::compose(const monomial_t* src, - Polynomial compA, Polynomial compB, - std::stack<monomial_t>* stk){ - - compA.power(src->power[0]); - compB.power(src->power[1]); - - compA.mul(compB); - compA.mul(src->coef); - - const int size = compA.nMon; - - for(int i = 0; i < size; i++){ - if(compA.mon[i].coef != 0){ - - compA.mon[i].power[2] += src->power[2]; - - stk->push(compA.mon[i]); - } - } -} - -void Polynomial::compose(const monomial_t* src, - Polynomial compA, Polynomial compB, Polynomial compC, - std::stack<monomial_t>* stk){ - - compA.power(src->power[0]); - compB.power(src->power[1]); - compC.power(src->power[2]); - - compA.mul(compB); - compA.mul(compC); - compA.mul(src->coef); - - const int size = compA.nMon; - - for(int i = 0; i < size; i++){ - if(compA.mon[i].coef != 0) - stk->push(compA.mon[i]); - } -} - -Polynomial Polynomial:: -polynomialFromStack(std::stack<Polynomial::monomial_t>& stk){ - Polynomial newP; - monomial_t* tmp; - monomial_t* newMon; - int newNMon; - - if(!stk.size()){ - newMon = zeroPolynomial(); - newNMon = 1; - } - - else{ - newMon = new monomial_t[1]; - newMon[0] = stk.top(); - newNMon = 1; - stk.pop(); - - while(!stk.empty()){ - tmp = newMon; - newNMon = mergeMon(newMon, newNMon, &stk.top(), 1, &newMon); - stk.pop(); - - delete[] tmp; - } - } - - newP.nMon = newNMon; - newP.mon = newMon; - - return newP; -} - -Polynomial::monomial_t* Polynomial::copyMonomial(const monomial_t* src, - int size){ - monomial_t* dest = new monomial_t[size]; - - for(int i = 0; i < size; i++){ - dest[i].coef = src[i].coef; - dest[i].power[0] = src[i].power[0]; - dest[i].power[1] = src[i].power[1]; - dest[i].power[2] = src[i].power[2]; - } - - return dest; -} - -Polynomial::monomial_t* Polynomial::zeroPolynomial(void){ - monomial_t* zero = new monomial_t[1]; - - zero->coef = 0; - zero->power[0] = 0; - zero->power[1] = 0; - zero->power[2] = 0; - - return zero; -} - -Polynomial::monomial_t* Polynomial::unitPolynomial(void){ - monomial_t* unit = new monomial_t[1]; - - unit->coef = 1; - unit->power[0] = 0; - unit->power[1] = 0; - unit->power[2] = 0; - - return unit; -} diff --git a/FunctionSpace/Polynomial.h b/FunctionSpace/Polynomial.h deleted file mode 100644 index bde4d6fafb020d428b1e47b67862b6b3b957a8de..0000000000000000000000000000000000000000 --- a/FunctionSpace/Polynomial.h +++ /dev/null @@ -1,321 +0,0 @@ -#ifndef _POLYNOMIAL_H_ -#define _POLYNOMIAL_H_ - -#include <string> -#include <stack> -#include <vector> -#include "fullMatrix.h" - -/** - @class Polynomial - @brief Represents 3D polynomials - - This class represents 3D polynomials. - A 3D polynomials uses monomials of 'xyz' type. - */ - -// We suppose 3D Polynomial -class Polynomial{ - private: - static const char coefName[3]; - - struct monomial_t{ - double coef; - int power[3]; - }; - - int nMon; - monomial_t* mon; - - public: - Polynomial(double coef, - int powerX, - int powerY, - int powerZ); - - Polynomial(const Polynomial& other); - Polynomial(void); - ~Polynomial(void); - - void derivative(int dim); - std::vector<Polynomial> gradient(void) const; - static std::vector<Polynomial> curl(const std::vector<Polynomial>& p); - static Polynomial divergence(const std::vector<Polynomial>& p); - - double operator() - (double x, double y, double z) const; - - double at - (double x, double y, double z) const; - - static fullVector<double> at(const std::vector<Polynomial>& P, - double x, - double y, - double z); - - Polynomial operator+(const Polynomial& other) const; - Polynomial operator-(const Polynomial& other) const; - Polynomial operator*(const Polynomial& other) const; - Polynomial operator*(double alpha) const; - - void add(const Polynomial& other); - void sub(const Polynomial& other); - void mul(const Polynomial& other); - void mul(double alpha); - - void power(int n); - - Polynomial compose(const Polynomial& other) const; - Polynomial compose(const Polynomial& otherA, - const Polynomial& otherB) const; - Polynomial compose(const Polynomial& otherA, - const Polynomial& otherB, - const Polynomial& otherC) const; - - void operator=(const Polynomial& other); - - std::string toString(void) const; - - private: - static std::string toString(const monomial_t* mon, const bool isAbs); - - static bool isSmaller(const monomial_t* a, const monomial_t*b); - static bool isEqual(const monomial_t* a, const monomial_t*b); - static bool isSmallerPower(const monomial_t* a, const monomial_t* b); - static bool isEqualPower(const monomial_t* a, const monomial_t* b); - - static void sort(monomial_t* mon, int size); - static void swap(monomial_t* mon, int i, int j); - - static int mergeMon(monomial_t* sourceA, int sizeA, - monomial_t* sourceB, int sizeB, - monomial_t** dest); - - static int mult(const monomial_t* sourceA, int sizeA, - const monomial_t* sourceB, int sizeB, - monomial_t** dest); - - static void mult(monomial_t* source, int size, double alpha); - - static void distribute(monomial_t* src, int size, const monomial_t* m); - - static void compose(const monomial_t* src, - Polynomial comp, - std::stack<monomial_t>* stk); - - static void compose(const monomial_t* src, - Polynomial compA, Polynomial compB, - std::stack<monomial_t>* stk); - - static void compose(const monomial_t* src, - Polynomial compA, Polynomial compB, Polynomial compC, - std::stack<monomial_t>* stk); - - static Polynomial polynomialFromStack(std::stack<monomial_t>& stk); - - static monomial_t* copyMonomial(const monomial_t* src, int size); - - static monomial_t* zeroPolynomial(void); - static monomial_t* unitPolynomial(void); -}; - -/** - @fn Polynomial::Polynomial(double, int, int, int) - @param coef The coeficient of the futur monomial - @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 copy of the given one - ** - - @fn Polynomial::Polynomial(void) - @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 - @return Deletes this Polynomial - ** - - @fn Polynomial::derivative - @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 the gradient of this Polynomial - ** - - @fn Polynomial::curl - @param p A 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 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 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 evaluation of this Polynomial at (x, y, z) - ** - - @fn fullVector<double> Polynomial::at(const std::vector<Polynomial>&, double, double, double) - @param P A vector of Polynomial%s - @param x A value - @param y A value - @param z A value - @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 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 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 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 new Polynomial, - which is this Polynomial multiplied by alpha - ** - - @fn Polynomial::add - @param other An other 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 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 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 multiplied by the given value - - Note that the result of this operation is stored in this Polynomial - ** - - @fn Polynomial::power - @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 Q(x, y, z) - @return - 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 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 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 copy of the given one - ** - - @fn Polynomial::toString - @return Returns a string representing this Polynomial -*/ - -////////////////////// -// Inline Functions // -////////////////////// - -inline double Polynomial::operator() (double x, - double y, - double z) const{ - return at(x, y, z); -} - -inline bool Polynomial::isEqual(const Polynomial::monomial_t* a, - const Polynomial::monomial_t* b){ - return a->power[0] == b->power[0] && - a->power[1] == b->power[1] && - a->power[2] == b->power[2]; -} - -inline bool Polynomial::isSmallerPower(const Polynomial::monomial_t* a, - const Polynomial::monomial_t* b){ - - return - a->power[0] + a->power[1] + a->power[2] - < - b->power[0] + b->power[1] + b->power[2] ; -} - -inline bool Polynomial::isEqualPower(const Polynomial::monomial_t* a, - const Polynomial::monomial_t* b){ - - return - a->power[0] + a->power[1] + a->power[2] - == - b->power[0] + b->power[1] + b->power[2] ; -} - -#endif diff --git a/FunctionSpace/PriReferenceSpace.cpp b/FunctionSpace/PriReferenceSpace.cpp deleted file mode 100644 index 9015d6da8d23d131b6b8d96ebfa2d77e064ef085..0000000000000000000000000000000000000000 --- a/FunctionSpace/PriReferenceSpace.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#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 deleted file mode 100644 index 173361668cc05bca3e41a5ba2fdbd108752350bb..0000000000000000000000000000000000000000 --- a/FunctionSpace/PriReferenceSpace.h +++ /dev/null @@ -1,31 +0,0 @@ -#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 deleted file mode 100644 index b6edaac530d5771e5ce2e4725e78cb29618b98e1..0000000000000000000000000000000000000000 --- a/FunctionSpace/PyrReferenceSpace.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#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 deleted file mode 100644 index 7ecc3885a43f16e208ce56a52adf7a7e9bb1db93..0000000000000000000000000000000000000000 --- a/FunctionSpace/PyrReferenceSpace.h +++ /dev/null @@ -1,31 +0,0 @@ -#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 diff --git a/FunctionSpace/QuadEdgeBasis.cpp b/FunctionSpace/QuadEdgeBasis.cpp deleted file mode 100644 index 337678818f3cc5afe80f4dbe1d0d2ce153ab6a44..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadEdgeBasis.cpp +++ /dev/null @@ -1,257 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "QuadEdgeBasis.h" - -using namespace std; - -QuadEdgeBasis::QuadEdgeBasis(size_t order){ - // Set Basis Type // - this->order = order; - - type = TYPE_QUA; - dim = 2; - - nVertex = 0; - nEdge = 4 * (order + 1); - nFace = 2 * (order + 1) * order; - nCell = 0; - nFunction = nVertex + nEdge + nFace + nCell; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - const vector<vector<vector<size_t> > >& - faceIdx = ReferenceSpaceManager::getFaceNodeIndex(type); - - - // Legendre Polynomial // - const size_t orderPlus = order + 1; - - Polynomial* legendre = new Polynomial[orderPlus]; - Polynomial* intLegendre = new Polynomial[orderPlus]; - - Legendre::integrated(intLegendre, orderPlus); - Legendre::legendre(legendre, order); - - // Lagrange & Lifting // - const Polynomial lagrange[4] = - { - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0))) - }; - - const Polynomial lifting[4] = - { - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0))) - }; - - // Basis // - basis = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new vector<Polynomial>*[nFunction]; - - // Edge Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = 0; - - for(size_t e = 0; e < 4; e++){ - for(size_t l = 0; l < orderPlus; l++){ - // Nedelec - if(l == 0){ - Polynomial lambda = (lagrange[edgeIdx[s][e][0]] + - lagrange[edgeIdx[s][e][1]]) * 0.5; - - basis[s][i] = - new vector<Polynomial>((lifting[edgeIdx[s][e][1]] - - lifting[edgeIdx[s][e][0]]).gradient()); - - basis[s][i]->at(0).mul(lambda); - basis[s][i]->at(1).mul(lambda); - basis[s][i]->at(2).mul(lambda); - } - - // High Order - else{ - basis[s][i] = - new vector<Polynomial> - ((intLegendre[l].compose(lifting[edgeIdx[s][e][1]] - - lifting[edgeIdx[s][e][0]]) - * - (lagrange[edgeIdx[s][e][0]] + - lagrange[edgeIdx[s][e][1]])).gradient()); - } - - i++; - } - } - } - - // Face Based // - - // NB: We use (*(*faceIdx[s])[f])[] - // where f = 0, because triangles - // have only ONE face: the face '0' - - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nEdge; - - // Type 1 - for(size_t l1 = 1; l1 < orderPlus; l1++){ - for(size_t l2 = 1; l2 < orderPlus; l2++){ - basis[s][i] = - new vector<Polynomial> - ((intLegendre[l1].compose(lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][1]]) - * - - intLegendre[l2].compose(lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][3]])).gradient()); - - i++; - } - } - - // Type 2 - for(size_t l1 = 1; l1 < orderPlus; l1++){ - for(size_t l2 = 1; l2 < orderPlus; l2++){ - Polynomial pOne = lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][1]]; - - Polynomial pTwo = lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][3]]; - - Polynomial lOne = legendre[l1].compose(pOne) * - intLegendre[l2].compose(pTwo); - - Polynomial lTwo = legendre[l2].compose(pTwo) * - intLegendre[l1].compose(pOne); - - vector<Polynomial> gradOne = pOne.gradient(); - vector<Polynomial> gradTwo = pTwo.gradient(); - - gradOne[0].mul(lOne); - gradOne[1].mul(lOne); - gradOne[2].mul(lOne); - - gradTwo[0].mul(lTwo); - gradTwo[1].mul(lTwo); - gradTwo[2].mul(lTwo); - - basis[s][i] = new vector<Polynomial>(gradOne); - - basis[s][i]->at(0).sub(gradTwo[0]); - basis[s][i]->at(1).sub(gradTwo[1]); - basis[s][i]->at(2).sub(gradTwo[2]); - - i++; - } - } - - // Type 3.1 - for(size_t l1 = 1; l1 < orderPlus; l1++){ - Polynomial tmp = - intLegendre[l1].compose(lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][3]]); - - - basis[s][i] = - new vector<Polynomial>((lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][1]]).gradient()); - - basis[s][i]->at(0).mul(tmp); - basis[s][i]->at(1).mul(tmp); - basis[s][i]->at(2).mul(tmp); - - i++; - } - - // Type 3.2 - for(size_t l1 = 1; l1 < orderPlus; l1++){ - Polynomial tmp = - intLegendre[l1].compose(lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][1]]); - - - basis[s][i] = - new vector<Polynomial>((lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][3]]).gradient()); - - basis[s][i]->at(0).mul(tmp); - basis[s][i]->at(1).mul(tmp); - basis[s][i]->at(2).mul(tmp); - - i++; - } - } - - // Mapping to Gmsh Quad // - // x = (u + 1) / 2 - // y = (v + 1) / 2 - // - // (x, y) = Zaglmayr Ref Quad - // (u, v) = Gmsh Ref Quad - - Polynomial mapX(Polynomial(0.5, 1, 0, 0) + - Polynomial(0.5, 0, 0, 0)); - - Polynomial mapY(Polynomial(0.5, 0, 1, 0) + - Polynomial(0.5, 0, 0, 0)); - - for(size_t s = 0; s < nOrientation; s++){ - for(size_t i = 0; i < nFunction; i++){ - vector<Polynomial>* old; - vector<Polynomial> nxt(3); - - old = basis[s][i]; - nxt[0] = (*old)[0].compose(mapX, mapY); - nxt[1] = (*old)[1].compose(mapX, mapY); - nxt[2] = (*old)[2].compose(mapX, mapY); - - basis[s][i] = new vector<Polynomial>(nxt); - delete old; - } - } - - // Free Temporary Sapce // - delete[] legendre; - delete[] intLegendre; -} - -QuadEdgeBasis::~QuadEdgeBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/QuadEdgeBasis.h b/FunctionSpace/QuadEdgeBasis.h deleted file mode 100644 index 733da3f0ac969685db4afb50e82fc7705dcbdcac..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadEdgeBasis.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _QUADEDGEBASIS_H_ -#define _QUADEDGEBASIS_H_ - -#include "BasisHierarchical1Form.h" - -/** - @class QuadEdgeBasis - @brief An Edge Basis for Quads - - This class can instantiate an Edge-Based Basis (high or low order) for Quads. - - It uses a variation of - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation.@n - - The following mapping has been applied to Zaglmayr's Basis for Quads: - @li @f$x = \frac{u + 1}{2}@f$ - @li @f$y = \frac{v + 1}{2}@f$ -*/ - -class QuadEdgeBasis: public BasisHierarchical1Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Edge-Basis for Quads of the given order - QuadEdgeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~QuadEdgeBasis(void); -}; - -#endif diff --git a/FunctionSpace/QuadLagrangeBasis.cpp b/FunctionSpace/QuadLagrangeBasis.cpp deleted file mode 100644 index 30974d5ec4d7af7d227f52d37de3686ff54a9ffc..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadLagrangeBasis.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "ElementType.h" -#include "GmshDefines.h" -#include "pointsGenerators.h" -#include "QuadLagrangeBasis.h" - -QuadLagrangeBasis::QuadLagrangeBasis(size_t order){ - // If order 0 (Nedelec): use order 1 - if(order == 0) - order = 1; - - // Set Basis Type // - this->order = order; - - type = TYPE_QUA; - dim = 2; - - nVertex = 4; - nEdge = 4 * (order - 1); - nFace = (order - 1) * (order - 1); - nCell = 0; - nFunction = nVertex + nEdge + nFace + nCell; - - // Init polynomialBasis // - lBasis = new polynomialBasis(ElementType::getTag(TYPE_QUA, order, false)); - - // Init Lagrange Point // - lPoint = new fullMatrix<double>(gmshGeneratePointsQuadrangle(order, false)); -} - -QuadLagrangeBasis::~QuadLagrangeBasis(void){ - delete lBasis; - delete lPoint; -} diff --git a/FunctionSpace/QuadLagrangeBasis.h b/FunctionSpace/QuadLagrangeBasis.h deleted file mode 100644 index 313aed1e1df3702bdf052742c9176a5116228787..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadLagrangeBasis.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _QUADLAGRANGEBASIS_H_ -#define _QUADLAGRANGEBASIS_H_ - -#include "BasisLagrange.h" - -/** - @class QuadLagrangeBasis - @brief Lagrange Basis for Quadrangles - - This class can instantiate a Lagrange Basis - for a Quadrangle and for a given order. - - It uses - <a href="http://geuz.org/gmsh/">gmsh</a> Basis. - */ - -class QuadLagrangeBasis: public BasisLagrange{ - public: - //! @param order A natural number - //! - //! Returns a new QuadLagrangeBasis of the given order - QuadLagrangeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~QuadLagrangeBasis(void); -}; - -#endif diff --git a/FunctionSpace/QuadNedelecBasis.cpp b/FunctionSpace/QuadNedelecBasis.cpp deleted file mode 100644 index 2bf00eb8c8628667e7aa197e3ed2760889114c5d..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadNedelecBasis.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "QuadNedelecBasis.h" - -using namespace std; - -QuadNedelecBasis::QuadNedelecBasis(void){ - // Set Basis Type // - order = 0; - - type = TYPE_QUA; - dim = 2; - - nVertex = 0; - nEdge = 4; - nFace = 0; - nCell = 0; - nFunction = 4; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - // Lagrange & Lifting // - const Polynomial lagrange[4] = - { - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0))) - }; - - const Polynomial lifting[4] = - { - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0))) - }; - - // Basis // - basis = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new vector<Polynomial>*[nFunction]; - - // Edge Based (Nedelec) // - for(size_t s = 0; s < nOrientation; s++){ - for(size_t e = 0; e < 4; e++){ - - Polynomial lambda = (lagrange[edgeIdx[s][e][0]] + - lagrange[edgeIdx[s][e][1]]) * 0.5; - - basis[s][e] = - new vector<Polynomial>((lifting[edgeIdx[s][e][1]] - - lifting[edgeIdx[s][e][0]]).gradient()); - - basis[s][e]->at(0).mul(lambda); - basis[s][e]->at(1).mul(lambda); - basis[s][e]->at(2).mul(lambda); - } - } - - // Mapping to Gmsh Quad // - // x = (u + 1) / 2 - // y = (v + 1) / 2 - // - // (x, y) = Zaglmayr Ref Quad - // (u, v) = Gmsh Ref Quad - - Polynomial mapX(Polynomial(0.5, 1, 0, 0) + - Polynomial(0.5, 0, 0, 0)); - - Polynomial mapY(Polynomial(0.5, 0, 1, 0) + - Polynomial(0.5, 0, 0, 0)); - - for(size_t s = 0; s < nOrientation; s++){ - for(size_t i = 0; i < nFunction; i++){ - vector<Polynomial>* old; - vector<Polynomial> nxt(3); - - old = basis[s][i]; - nxt[0] = (*old)[0].compose(mapX, mapY); - nxt[1] = (*old)[1].compose(mapX, mapY); - nxt[2] = (*old)[2].compose(mapX, mapY); - - basis[s][i] = new vector<Polynomial>(nxt); - delete old; - } - } -} - -QuadNedelecBasis::~QuadNedelecBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/QuadNedelecBasis.h b/FunctionSpace/QuadNedelecBasis.h deleted file mode 100644 index 59a40af619cc180be2a8e02a960a360af49a6ca0..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadNedelecBasis.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _QUADNEDELECBASIS_H_ -#define _QUADNEDELECBASIS_H_ - -#include "BasisHierarchical1Form.h" - -/** - @class QuadNedelecBasis - @brief Nedelec Basis for Quads - - This class can instantiate a Nedelec Basis for Quadrangles. -*/ - -class QuadNedelecBasis: public BasisHierarchical1Form{ - public: - //! Returns a new Nedelec Basis for Quadrangles - //! - QuadNedelecBasis(void); - - //! Deletes this Basis - //! - virtual ~QuadNedelecBasis(void); -}; - -#endif diff --git a/FunctionSpace/QuadNodeBasis.cpp b/FunctionSpace/QuadNodeBasis.cpp deleted file mode 100644 index 00b254051e38ffbcda69517df281ad104b169620..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadNodeBasis.cpp +++ /dev/null @@ -1,160 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "QuadNodeBasis.h" - -using namespace std; - -QuadNodeBasis::QuadNodeBasis(size_t order){ - // Set Basis Type // - this->order = order; - - type = TYPE_QUA; - dim = 2; - - nVertex = 4; - nEdge = 4 * (order - 1); - nFace = (order - 1) * (order - 1); - nCell = 0; - nFunction = nVertex + nEdge + nFace + nCell; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - const vector<vector<vector<size_t> > >& - faceIdx = ReferenceSpaceManager::getFaceNodeIndex(type); - - // Legendre Polynomial // - Polynomial* legendre = new Polynomial[order]; - Legendre::integrated(legendre, order); - - // Lagrange & Lifting // - const Polynomial lagrange[4] = - { - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) * - (Polynomial(1, 0, 1, 0))) - }; - - const Polynomial lifting[4] = - { - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0))), - - Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) + - (Polynomial(1, 0, 1, 0))) - }; - - // Basis // - basis = new Polynomial**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new Polynomial*[nFunction]; - - // Vertex Based // - for(size_t s = 0; s < nOrientation; s++){ - basis[s][0] = new Polynomial(lagrange[0]); - basis[s][1] = new Polynomial(lagrange[1]); - basis[s][2] = new Polynomial(lagrange[2]); - basis[s][3] = new Polynomial(lagrange[3]); - } - - // Edge Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex; - - for(size_t e = 0; e < 4; e++){ - for(size_t l = 1; l < order; l++){ - basis[s][i] = - new Polynomial(legendre[l].compose(lifting[edgeIdx[s][e][1]] - - lifting[edgeIdx[s][e][0]]) - * - (lagrange[edgeIdx[s][e][0]] + - lagrange[edgeIdx[s][e][1]])); - - i++; - } - } - } - - // Face Based // - - // NB: We use (*(*faceIdx[s])[f])[] - // where f = 0, because triangles - // have only ONE face: the face '0' - - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex + nEdge; - - for(size_t l1 = 1; l1 < order; l1++){ - for(size_t l2 = 1; l2 < order; l2++){ - basis[s][i] = - new Polynomial(legendre[l1].compose(lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][1]]) - * - - legendre[l2].compose(lifting[faceIdx[s][0][0]] - - lifting[faceIdx[s][0][3]])); - - i++; - } - } - } - - // Mapping to Gmsh Quad // - // x = (u + 1) / 2 - // y = (v + 1) / 2 - // - // (x, y) = Zaglmayr Ref Quad - // (u, v) = Gmsh Ref Quad - - Polynomial mapX(Polynomial(0.5, 1, 0, 0) + - Polynomial(0.5, 0, 0, 0)); - - Polynomial mapY(Polynomial(0.5, 0, 1, 0) + - Polynomial(0.5, 0, 0, 0)); - - for(size_t s = 0; s < nOrientation; s++){ - for(size_t i = 0; i < nFunction; i++){ - Polynomial* tmp; - tmp = basis[s][i]; - basis[s][i] = new Polynomial(tmp->compose(mapX, mapY)); - delete tmp; - } - } - - // Free Temporary Sapce // - delete[] legendre; -} - -QuadNodeBasis::~QuadNodeBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/QuadNodeBasis.h b/FunctionSpace/QuadNodeBasis.h deleted file mode 100644 index 86725a3241f070ede4af4922fa2e18c3ae3e041f..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadNodeBasis.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _QUADNODEBASIS_H_ -#define _QUADNODEBASIS_H_ - -#include "BasisHierarchical0Form.h" - -/** - @class QuadNodeBasis - @brief A Node Basis for Quads - - This class can instantiate a Node-Based Basis (high or low order) for Quads. - - It uses a variation of - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation.@n - - The following mapping has been applied to Zaglmayr's Basis for Quads: - @li @f$x = \frac{u + 1}{2}@f$ - @li @f$y = \frac{v + 1}{2}@f$ -*/ - -class QuadNodeBasis: public BasisHierarchical0Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Node-Basis for Quads of the given order - QuadNodeBasis(size_t order); - - //! @return Deletes this Basis - //! - virtual ~QuadNodeBasis(void); -}; - -#endif diff --git a/FunctionSpace/QuadReferenceSpace.cpp b/FunctionSpace/QuadReferenceSpace.cpp deleted file mode 100644 index d7124608d6268eed1d8822fd13388e3efaca378e..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadReferenceSpace.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include <sstream> -#include "QuadReferenceSpace.h" -#include "MQuadrangle.h" - -using namespace std; - -QuadReferenceSpace::QuadReferenceSpace(void){ - // Vertex Definition // - nVertex = 4; - - // Edge Definition // - const size_t nEdge = 4; - refEdgeNodeIdx.resize(nEdge); - - for(size_t i = 0; i < nEdge; i++){ - refEdgeNodeIdx[i].resize(2); // Two Nodes per Edge - refEdgeNodeIdx[i][0] = MQuadrangle::edges_quad(i, 0); - refEdgeNodeIdx[i][1] = MQuadrangle::edges_quad(i, 1); - } - - // Face Definition // - refFaceNodeIdx.resize(1); // One Face per Triangle - refFaceNodeIdx[0].resize(4); // Four Nodes per Face - - refFaceNodeIdx[0][0] = 0; - refFaceNodeIdx[0][1] = 1; - refFaceNodeIdx[0][2] = 2; - refFaceNodeIdx[0][3] = 3; - - // Init All // - init(); -} - -QuadReferenceSpace::~QuadReferenceSpace(void){ -} - -string QuadReferenceSpace::toLatex(void) const{ - const size_t nRefSpace = refSpaceNodeId.size(); - stringstream stream; - - // stream << pTree->toLatex() << endl; - // return stream.str(); - - 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(3, 3) {$" << refSpaceNodeId[s][2] << "$};" - << endl - << "\\node[vertex] (n3) at(0, 3) {$" << refSpaceNodeId[s][3] << "$};" - << endl - << endl; - - for(size_t e = 0; e < 4; 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; - - return stream.str(); -} diff --git a/FunctionSpace/QuadReferenceSpace.h b/FunctionSpace/QuadReferenceSpace.h deleted file mode 100644 index dadc5a7f48e358403e81f84e736983fae85d7999..0000000000000000000000000000000000000000 --- a/FunctionSpace/QuadReferenceSpace.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _QUADREFERENCESPACE_H_ -#define _QUADREFERENCESPACE_H_ - -#include <string> -#include "ReferenceSpace.h" - -/** - @class QuadReferenceSpace - @brief ReferenceSpace for a Quadrangle - - This class implements a ReferenceSpace for a Quadrangle. - */ - -class QuadReferenceSpace: public ReferenceSpace{ - public: - QuadReferenceSpace(void); - virtual ~QuadReferenceSpace(void); - - virtual std::string toLatex(void) const; -}; - -/** - @fn QuadReferenceSpace::QuadReferenceSpace - Instatiate a new ReferenceSpace for a Quadrangle - ** - - @fn QuadReferenceSpace::~QuadReferenceSpace - Deletes this QuadReferenceSpace -*/ - -#endif diff --git a/FunctionSpace/ReferenceSpace.cpp b/FunctionSpace/ReferenceSpace.cpp deleted file mode 100644 index d54c03c268195c9ea18aad7e6529a4cccca2251d..0000000000000000000000000000000000000000 --- a/FunctionSpace/ReferenceSpace.cpp +++ /dev/null @@ -1,1073 +0,0 @@ -#include <algorithm> -#include <fstream> -#include <sstream> -#include <cstring> -#include <set> - -#include "Exception.h" -#include "Numeric.h" -#include "ReferenceSpace.h" - -using namespace std; - -ReferenceSpace::ReferenceSpace(void){ - // Defining Ref Edge and Face in // - // Derived Class // -} - -ReferenceSpace::ReferenceSpace(const std::string& path){ - init(path); -} - -ReferenceSpace::~ReferenceSpace(void){ - delete pTree; -} - -void ReferenceSpace::init(void){ - // Tree // - vector<size_t> vertexSeq(nVertex); - - for(size_t i = 0; i < nVertex; i++) - vertexSeq[i] = i; - - pTree = new PermutationTree(vertexSeq); - - // Connectivity // - list<size_t> listOfTrueReferenceSpace; - list<vector<size_t> > listOfRefNodeIndexPermutation; - list<vector<size_t> > listOfReverseNodeIndexPermutation; - - findConnectivity(listOfTrueReferenceSpace, - listOfRefNodeIndexPermutation, - listOfReverseNodeIndexPermutation); - - // Iterators // - list<size_t>::iterator refSpaceIt = listOfTrueReferenceSpace.begin(); - - // Reference Spaces Node Id // - const size_t nRefSpace = listOfTrueReferenceSpace.size(); - refSpaceNodeId.resize(nRefSpace); - - for(size_t i = 0; i < nRefSpace; i++, refSpaceIt++){ - refSpaceNodeId[i].resize(nVertex); - - pTree->fillWithPermutation(*refSpaceIt, refSpaceNodeId[i]); - } - - // Compress Tag, so that they refer to refSpaceNodeId indices - // insted of leafId of pTree. - pTree->compressTag(); - - // ABC space to UVW space shape function index mapping // - const size_t nPermutation = pTree->getNPermutation(); - ABCtoUVWIndex.resize(nPermutation); - ABCtoUVWIndex.assign(listOfReverseNodeIndexPermutation.begin(), - listOfReverseNodeIndexPermutation.end()); - - // UVW space to ABC space shape function index mapping // - UVWtoABCIndex.resize(nPermutation); - UVWtoABCIndex.assign(listOfRefNodeIndexPermutation.begin(), - listOfRefNodeIndexPermutation.end()); - - // Ordered Edges & Faces Node Index// - getOrderedEdge(); - getOrderedFace(); -} - -void ReferenceSpace::init(const char* stream){ - // nVector - size_t offset = 0; - - memcpy(&nVertex, stream + offset, sizeof(size_t)); - offset += sizeof(size_t); - - // Fef {Edge, Face} Node Idx - offset += unserialize(stream + offset, refEdgeNodeIdx); - offset += unserialize(stream + offset, refFaceNodeIdx); - - // Permutation Tree - size_t tSize; // Tree Size - - memcpy(&tSize, stream + offset, sizeof(size_t)); - offset += sizeof(size_t); - - pTree = new PermutationTree(stream + offset); - offset += tSize; - - // RefSpace Node Id - offset += unserialize(stream + offset, refSpaceNodeId); - - // Index mapping - offset += unserialize(stream + offset, ABCtoUVWIndex); - offset += unserialize(stream + offset, UVWtoABCIndex); - - // Oredered {Edge, Face} Node Idx - offset += unserialize(stream + offset, orderedEdgeNodeIdx); - offset += unserialize(stream + offset, orderedFaceNodeIdx); -} - -void ReferenceSpace::init(const std::string& path){ - // Read file // - // Open Stream - ifstream input; - input.exceptions(std::ifstream::failbit | std::ifstream::badbit); - input.open(path.c_str(), std::ifstream::binary); - - // Get size of stream (go to stream end) - input.seekg(0, std::ifstream::end); - const size_t size = input.tellg(); - - // Reset stream possition - input.seekg(0, std::ifstream::beg); - - // Alloc byte stream & Read file - char* stream = new char[size]; - input.read(stream, size); - - // Init from stream - init(stream); - - // Free stream - delete[] stream; -} - -void ReferenceSpace:: -findConnectivity(list<size_t>& listOfTrueReferenceSpace, - list<vector<size_t> >& listOfRefNodeIndexPermutation, - list<vector<size_t> >& listOfReverseNodeIndexPermutation){ - - // Alloc Some Data // - const size_t nPerm = pTree->getNPermutation(); - - vector<size_t> pTest(nVertex); - vector<size_t> pRef(nVertex); - - list<size_t>::iterator it; - list<size_t>::iterator end; - triplet match; - - // Values For unPermutedIndex // - vector<size_t> unPermutedIndex(nVertex); - - for(size_t i = 0; i < nVertex; i++) - unPermutedIndex[i] = i; - - // Find Connectivity // - for(size_t i = 0; i < nPerm; i++){ - // No match - match.first = false; - - // Get Permutation 'i' - pTree->fillWithPermutation(i, pTest); - - // Test it with already found Reference Space - it = listOfTrueReferenceSpace.begin(); - end = listOfTrueReferenceSpace.end(); - - while(it != end && !match.first){ - // Take Reference Space 'it' - pTree->fillWithPermutation(*it, pRef); - - // Look if it matches (do pTest and pRef have the same connectivity ?) - match = isSameConnectivity(pTest, pRef); - - // If not, go to next Reference Space - if(!match.first) - it++; - } - - // If no Reference Space is found - // --> this Permutation is a new Reference Space - if(!match.first){ - listOfTrueReferenceSpace.push_back(i); - - listOfRefNodeIndexPermutation.push_back(unPermutedIndex); - listOfReverseNodeIndexPermutation.push_back(unPermutedIndex); - - pTree->addTagToPermutation(i, i); - } - - // If a ReferenceSpace is found, add the index permutations - else{ - listOfRefNodeIndexPermutation.push_back(match.second); - listOfReverseNodeIndexPermutation.push_back(match.third); - - pTree->addTagToPermutation(i, *it); - } - } -} - -ReferenceSpace::triplet ReferenceSpace:: -isSameConnectivity(const vector<size_t>& pTest, - const vector<size_t>& pRef) const{ - - // Triplet to return - triplet tri; - - // Test if we have the same connectivity (i.e. the same edges) - bool haveSameEdge = isSameEdge(pTest, pRef); - - if(haveSameEdge){ - tri.first = true; - tri.second = getRefIndexPermutation(pRef, pTest); - tri.third = getReverseIndexPermutation(pRef, pTest); - } - - else{ - tri.first = false; - tri.second = vector<size_t>(0); - tri.third = vector<size_t>(0); - } - - return tri; -} - -bool ReferenceSpace::isSameEdge(const std::vector<size_t>& pTest, - const std::vector<size_t>& pRef) const{ - // Set of Reference Edges - const size_t nEdge = refEdgeNodeIdx.size(); - std::set<std::vector<size_t>, EdgeComparator> refEdge; - std::vector<size_t> tmp(2); - - for(size_t e = 0; e < nEdge; e++){ - tmp[0] = pRef[refEdgeNodeIdx[e][0]]; - tmp[1] = pRef[refEdgeNodeIdx[e][1]]; - refEdge.insert(tmp); - } - - // Compare Test Edges - bool match = true; - for(size_t e = 0; e < nEdge && match; e++){ - tmp[0] = pTest[refEdgeNodeIdx[e][0]]; - tmp[1] = pTest[refEdgeNodeIdx[e][1]]; - - match = (refEdge.find(tmp) != refEdge.end()); - } - - return match; -} - -bool ReferenceSpace::EdgeComparator::operator()(const std::vector<size_t>& a, - const std::vector<size_t>& b){ - size_t maxA, minA; - size_t maxB, minB; - - if(a[0] < a[1]){ - maxA = a[1]; - minA = a[0]; - } - - else{ - maxA = a[0]; - minA = a[1]; - } - - if(b[0] < b[1]){ - maxB = b[1]; - minB = b[0]; - } - - else{ - maxB = b[0]; - minB = b[1]; - } - - return - ((minA != minB) && (minA < minB)) || - ((minA == minB) && (maxA < maxB)); -} - -vector<size_t> -ReferenceSpace::getRefIndexPermutation(const vector<size_t>& ref, - const vector<size_t>& test) const{ - const size_t size = ref.size(); - vector<size_t> idxVec(ref.size()); - size_t idx; - - for(size_t i = 0; i < size; i++){ - idx = 0; - - while(test[i] != ref[idx]) - idx++; - - idxVec[i] = idx; - } - - return idxVec; -} - -vector<size_t> -ReferenceSpace::getReverseIndexPermutation(const vector<size_t>& ref, - const vector<size_t>& test) const{ - const size_t size = ref.size(); - vector<size_t> idxVec(ref.size()); - size_t idx; - - for(size_t i = 0; i < size; i++){ - idx = 0; - - while(test[idx] != ref[i]) - idx++; - - idxVec[i] = idx; - } - - return idxVec; -} - -void ReferenceSpace::getOrderedEdge(void){ - // Fill orderedEdgeNodeIdx[s][e] // - // (for all reference space 's' and edge 'e') such that: // - // // - // refSpaceNodeId[s][orderedEdgeNodeIdx[s][e][0]] < // - // refSpaceNodeId[s][orderedEdgeNodeIdx[s][e][1]] // - - // Alloc - const size_t nEdge = refEdgeNodeIdx.size(); - const size_t nRefSpace = refSpaceNodeId.size(); - - orderedEdgeNodeIdx.resize(nRefSpace); - - // Populate Edge - for(size_t s = 0; s < nRefSpace; s++){ - orderedEdgeNodeIdx[s].resize(nEdge); - - for(size_t e = 0; e < nEdge; e++){ - orderedEdgeNodeIdx[s][e].resize(2); - - orderRefEntityForGivenRefSpace(refEdgeNodeIdx[e], - refSpaceNodeId[s], - orderedEdgeNodeIdx[s][e]); - } - } -} - -void ReferenceSpace::getOrderedFace(void){ - // Fill orderedEdgeNodeIdx[s][f] // - // (for all reference space 's' and face 'f') such that: // - // // - // refSpaceNodeId[s][orderedFaceNodeIdx[s][f][0]] < // - // refSpaceNodeId[s][orderedFaceNodeIdx[s][f][1]] < // - // refSpaceNodeId[s][orderedFaceNodeIdx[s][f][2]] < // - // (refSpaceNodeId[s][orderedFaceNodeIdx[s][f][3]]) (Quad Face) // - // // - // If we have a Quad face, a correction is needed such that: // - // // - // orderedFaceNodeIdx[s][f][2] // - // is *opposite* to // - // orderedFaceNodeIdx[s][f][0] // - - // Alloc - const size_t nFace = refFaceNodeIdx.size(); - const size_t nRefSpace = refSpaceNodeId.size(); - - orderedFaceNodeIdx.resize(nRefSpace); - - // Populate Face - for(size_t s = 0; s < nRefSpace; s++){ - orderedFaceNodeIdx[s].resize(nFace); - - for(size_t f = 0; f < nFace; f++){ - size_t nNodeInFace = refFaceNodeIdx[f].size(); - - orderedFaceNodeIdx[s][f].resize(nNodeInFace); - - orderRefEntityForGivenRefSpace(refFaceNodeIdx[f], - refSpaceNodeId[s], - orderedFaceNodeIdx[s][f]); - if(nNodeInFace == 4) - correctQuadFaceNodeIdx(f, orderedFaceNodeIdx[s][f]); - } - } -} - -void ReferenceSpace:: -orderRefEntityForGivenRefSpace(vector<size_t>& refEntityNodeIdx, - vector<size_t>& refSpaceNodeId, - vector<size_t>& orderedEntityNodeIdx){ - // Get Size - const size_t size = orderedEntityNodeIdx.size(); - - // Ref Entity Node *ID* - vector<pair<size_t, size_t> > refEntityNodeId(size); - - for(size_t i = 0; i < size; i++){ - refEntityNodeId[i].first = i; // Node Id INDEX - refEntityNodeId[i].second = refSpaceNodeId[refEntityNodeIdx[i]]; // Node Id - } - - // Sort it with repsect to second entry (Node ID) - std::sort(refEntityNodeId.begin(), refEntityNodeId.end(), sortPredicate); - - // Populate orderedEntityNodeIdx (Usign sorted Node ID old Index) - for(size_t i = 0; i < size; i++) - orderedEntityNodeIdx[i] = refEntityNodeIdx[refEntityNodeId[i].first]; -} - -void ReferenceSpace:: -correctQuadFaceNodeIdx(size_t faceId, - vector<size_t>& correctedQuadFaceNodeIdx){ - // Get : // - // correctedQuadFaceNodeIdx[2] // - // is *opposite* to // - // correctedQuadFaceNodeIdx[0] // - - // Get opposite Node // - // Find node correctedQuadFaceNodeIdx[0] in refFaceNodeId[faceId] - size_t refIdx = 0; - - while((refIdx < 4) - && - (refFaceNodeIdx[faceId][refIdx] != correctedQuadFaceNodeIdx[0])){ - - refIdx++; - } - - if(refIdx == 4) - throw Exception("Error in correctQuadFaceNodeIdx: vertex 0 not found"); - - // Get opposite Node - size_t opposite = refFaceNodeIdx[faceId][(refIdx + 2) % 4]; - - // If correction needed, do it // - if(correctedQuadFaceNodeIdx[2] != opposite){ - // Find opposite node index - size_t tmp; - size_t idx = 1; - - while(correctedQuadFaceNodeIdx[idx] != opposite) - idx++; - - // Swap correctedQuadFaceNodeIdx[2] and correctedQuadFaceNodeIdx[idx] - tmp = correctedQuadFaceNodeIdx[2]; - correctedQuadFaceNodeIdx[2] = opposite; - correctedQuadFaceNodeIdx[idx] = tmp; - } -} - -size_t ReferenceSpace::getPermutationIdx(const MElement& element) const{ - // Get Primary Vertices Global ID // - vector<pair<size_t, size_t> > vertexGlobalId(nVertex); - - for(size_t i = 0; i < nVertex; i++){ - vertexGlobalId[i].first = i; - vertexGlobalId[i].second = element.getVertex(i)->getNum(); - } - - // Sort Them with repsect to Vertex Global ID // - // (vertex[i].second->getNum) // - std::sort(vertexGlobalId.begin(), vertexGlobalId.end(), sortPredicate); - - // Reduce Vertex Global ID // - vector<size_t> vertexReducedId(nVertex); - - for(size_t i = 0; i < nVertex; i++) - vertexReducedId[vertexGlobalId[i].first] = i; - - // Tree Lookup // - try{ - return pTree->getPermutationId(vertexReducedId); - } - - catch(...){ - throw Exception("Cannot Find Reference Space for Element %d", - element.getNum()); - } -} - -void ReferenceSpace::mapFromABCtoUVW(const MElement& element, - double a, double b, double c, - double uvw[3]) const{ - // Get Index Permutation - const size_t permutationIdx = getPermutationIdx(element); - - // UVW node coordinate in ABC - double** uvwNode = new double*[nVertex]; - - for(size_t i = 0; i < nVertex; i++) - uvwNode[i] = new double[3]; - - for(size_t i = 0; i < nVertex; i++) - element.getNode(i, - uvwNode[UVWtoABCIndex[permutationIdx][i]][0], - uvwNode[UVWtoABCIndex[permutationIdx][i]][1], - uvwNode[UVWtoABCIndex[permutationIdx][i]][2]); - - // ABC (order 1) grad shape functions - double* phiABC = new double[nVertex]; - element.getShapeFunctions(a, b, c, phiABC, 1); - - // Map From ABC to UVW // - uvw[0] = 0; - for(size_t i = 0; i < nVertex; i++) - uvw[0] += uvwNode[i][0] * phiABC[i]; - - uvw[1] = 0; - for(size_t i = 0; i < nVertex; i++) - uvw[1] += uvwNode[i][1] * phiABC[i]; - - uvw[2] = 0; - for(size_t i = 0; i < nVertex; i++) - uvw[2] += uvwNode[i][2] * phiABC[i]; - - // Free // - delete[] phiABC; - - for(size_t i = 0; i < nVertex; i++) - delete[] uvwNode[i]; - - delete[] uvwNode; -} - -void ReferenceSpace::mapFromABCtoXYZ(const MElement& element, - double a, double b, double c, - double xyz[3]) const{ - // Map From ABC to UVW - double uvw[3]; - mapFromABCtoUVW(element, a, b, c, uvw); - - // Map From UVW to XYZ - SPoint3 pxyz; - element.pnt(uvw[0], uvw[1], uvw[2], pxyz); - - xyz[0] = pxyz.x(); - xyz[1] = pxyz.y(); - xyz[2] = pxyz.z(); -} - -void ReferenceSpace::mapFromUVWtoABC(const MElement& element, - double u, double v, double w, - double abc[3]) const{ - // Element Permutation Index - const size_t permutationIdx = getPermutationIdx(element); - - // ABC node coordinate in UVW - double** abcNode = new double*[nVertex]; - - for(size_t i = 0; i < nVertex; i++) - abcNode[i] = new double[3]; - - for(size_t i = 0; i < nVertex; i++) - element.getNode(i, - abcNode[ABCtoUVWIndex[permutationIdx][i]][0], - abcNode[ABCtoUVWIndex[permutationIdx][i]][1], - abcNode[ABCtoUVWIndex[permutationIdx][i]][2]); - - // UVW (order 1) shape functions - double* phiUVW = new double[nVertex]; - element.getShapeFunctions(u, v, w, phiUVW, 1); - - // Map From UVW to ABC - abc[0] = 0; - for(size_t i = 0; i < nVertex; i++) - abc[0] += abcNode[i][0] * phiUVW[i]; - - abc[1] = 0; - for(size_t i = 0; i < nVertex; i++) - abc[1] += abcNode[i][1] * phiUVW[i]; - - abc[2] = 0; - for(size_t i = 0; i < nVertex; i++) - abc[2] += abcNode[i][2] * phiUVW[i]; - - // Free - delete[] phiUVW; - - for(size_t i = 0; i < nVertex; i++) - delete[] abcNode[i]; - - delete[] abcNode; -} - -void ReferenceSpace::mapFromXYZtoABC(const MElement& element, - double x, double y, double z, - double abc[3]) const{ - // Get UVW coordinate // - double xyz[3] = {x, y, z}; - double uvw[3]; - - element.xyz2uvw(xyz, uvw); - - // Get ABC coordinate // - mapFromUVWtoABC(element, uvw[0], uvw[1], uvw[2], abc); -} - -double ReferenceSpace::getJacobian(const MElement& element, - double a, double b, double c, - fullMatrix<double>& jac) const{ - // ABC to UVW Jacobian // - // Get Index Permutation - const size_t permutationIdx = getPermutationIdx(element); - - // UVW node coordinate - double** uvwNode = new double*[nVertex]; - - for(size_t i = 0; i < nVertex; i++) - uvwNode[i] = new double[3]; - - for(size_t i = 0; i < nVertex; i++) - element.getNode(i, - uvwNode[UVWtoABCIndex[permutationIdx][i]][0], - uvwNode[UVWtoABCIndex[permutationIdx][i]][1], - uvwNode[UVWtoABCIndex[permutationIdx][i]][2]); - - // ABC (order 1) grad shape functions - double phiABC[1256][3]; // Cannot be dynamicaly allocated since - // GMSH wants a double[][3] for phiABC !!! - - element.getGradShapeFunctions(a, b, c, phiABC, 1); - - // Jacobian - fullMatrix<double> jacABCtoUVW(3, 3); - jacABCtoUVW.setAll(0); - - for(size_t i = 0; i < nVertex; i++){ - jacABCtoUVW(0, 0) += uvwNode[i][0] * phiABC[i][0]; - jacABCtoUVW(0, 1) += uvwNode[i][1] * phiABC[i][0]; - jacABCtoUVW(0, 2) += uvwNode[i][2] * phiABC[i][0]; - } - - for(size_t i = 0; i < nVertex; i++){ - jacABCtoUVW(1, 0) += uvwNode[i][0] * phiABC[i][1]; - jacABCtoUVW(1, 1) += uvwNode[i][1] * phiABC[i][1]; - jacABCtoUVW(1, 2) += uvwNode[i][2] * phiABC[i][1]; - } - - for(size_t i = 0; i < nVertex; i++){ - jacABCtoUVW(2, 0) += uvwNode[i][0] * phiABC[i][2]; - jacABCtoUVW(2, 1) += uvwNode[i][1] * phiABC[i][2]; - jacABCtoUVW(2, 2) += uvwNode[i][2] * phiABC[i][2]; - } - - // Regularize Jacobian - regularize(element.getDim(), jacABCtoUVW); - - // Free - for(size_t i = 0; i < nVertex; i++) - delete[] uvwNode[i]; - - delete[] uvwNode; - - // Map ABC coordinate to UVW point // - double uvw[3]; - mapFromABCtoUVW(element, a, b, c, uvw); - - // UVW to XYZ Jacobian // - fullMatrix<double> jacUVWtoXYZ(3, 3); - element.getJacobian(uvw[0], uvw[1], uvw[2], jacUVWtoXYZ); - - // Product of the two Jacobians & Return // - // Do a naive gemm, so that we do not encounter nested threads - // (limitation of OpenBLAS) - jac.gemm_naive(jacABCtoUVW, jacUVWtoXYZ, 1, 0); - - // New Jacobian determinant (same as jacUVWtoXYZ with maybe a SIGN CHANGE) // - // ---> Has to be recomputed! - return - jac(0, 0) * jac(1, 1) * jac(2, 2) + - jac(0, 1) * jac(1, 2) * jac(2, 0) + - jac(0, 2) * jac(1, 0) * jac(2, 1) - - - jac(0, 2) * jac(1, 1) * jac(2, 0) - - jac(0, 1) * jac(1, 0) * jac(2, 2) - - jac(0, 0) * jac(1, 2) * jac(2, 1); -} - -void ReferenceSpace::regularize(size_t dim, fullMatrix<double>& jac){ - double a[3]; - double b[3]; - double c[3]; - - switch(dim){ - case 0: - jac(0, 0) = jac(1, 1) = jac(2, 2) = 1.0; - jac(0, 1) = jac(1, 0) = jac(2, 0) = 0.0; - jac(0, 2) = jac(1, 2) = jac(2, 1) = 0.0; - break; - - case 1: - a[0] = jac(0, 0); - a[1] = jac(0, 1); - a[2] = jac(0, 2); - - if((fabs(a[0]) >= fabs(a[1]) && fabs(a[0]) >= fabs(a[2])) || - (fabs(a[1]) >= fabs(a[0]) && fabs(a[1]) >= fabs(a[2]))){ - b[0] = a[1]; - b[1] = -a[0]; - b[2] = 0.; - } - - else{ - b[0] = 0.; - b[1] = a[2]; - b[2] = -a[1]; - } - - norme(b); - prodve(a, b, c); - norme(c); - - jac(1, 0) = b[0]; jac(1, 1) = b[1]; jac(1, 2) = b[2]; - jac(2, 0) = c[0]; jac(2, 1) = c[1]; jac(2, 2) = c[2]; - break; - - case 2: - a[0] = jac(0, 0); - a[1] = jac(0, 1); - a[2] = jac(0, 2); - - b[0] = jac(1, 0); - b[1] = jac(1, 1); - b[2] = jac(1, 2); - - prodve(a, b, c); - norme(c); - - jac(2, 0) = c[0]; jac(2, 1) = c[1]; jac(2, 2) = c[2]; - break; - - case 3: - break; - } -} - -string ReferenceSpace::toString(void) const{ - const size_t nRefSpace = refSpaceNodeId.size(); - const size_t nEdge = refEdgeNodeIdx.size(); - const size_t nFace = refFaceNodeIdx.size(); - stringstream stream; - - // Reference Space Node IDs // - stream << "Reference Space Node IDs:" << endl; - - for(size_t s = 0; s < nRefSpace; s++){ - stream << " ** Reference Space #" << s << ": ["; - - for(size_t v = 0; v < nVertex - 1; v++) - stream << refSpaceNodeId[s][v] << ", "; - - stream << refSpaceNodeId[s][nVertex - 1] << "]" << endl; - } - - // Oriented Edges Node Index // - stream << endl << "Ordered Edge Node Index:" << endl; - - for(size_t s = 0; s < nRefSpace; s++){ - stream << " ** Reference Space #" << s << ":" - << endl; - - for(size_t e = 0; e < nEdge; e++) - stream << " -- [" - << orderedEdgeNodeIdx[s][e][0] << ", " - << orderedEdgeNodeIdx[s][e][1] << "]" - << endl; - } - - // Oriented Faces Node Index // - stream << endl << "Ordered Face Node Index:" << endl; - - for(size_t s = 0; s < nRefSpace; s++){ - stream << " ** Reference Space #" << s << ":" - << endl; - - for(size_t f = 0; f < nFace; f++){ - const size_t nNodeInFace = orderedFaceNodeIdx[s][f].size(); - stream << " -- ["; - - for(size_t n = 0; n < nNodeInFace - 1; n++) - stream << orderedFaceNodeIdx[s][f][n] << ", "; - - stream << orderedFaceNodeIdx[s][f][nNodeInFace - 1] << "]" - << endl; - } - } - - return stream.str(); -} - -string ReferenceSpace::toLatex(void) const{ - stringstream stream; - - stream << "\\documentclass{article}" << endl << endl - << "\\begin{document}" << endl - - << "\texttt{toLatex} not implemented" << endl - - << "\\end{document}" << endl; - - return stream.str(); -} - -std::pair<size_t, char*> ReferenceSpace::serialize(void) const{ - // Serialize // - // refEdgeNodeIdx - pair<size_t, char*> sRefEdgeIdx = serialize(refEdgeNodeIdx); - - // refFaceNodeIdx - pair<size_t, char*> sRefFaceIdx = serialize(refFaceNodeIdx); - - // PermutationTree - pair<size_t, char*> sPTree = pTree->serialize(); - - // Reference Space - pair<size_t, char*> sRSpace = serialize(refSpaceNodeId); - - // ABCtoUVW - pair<size_t, char*> sABCtoUVW = serialize(ABCtoUVWIndex); - - // UVWtoUVW - pair<size_t, char*> sUVWtoABC = serialize(UVWtoABCIndex); - - // orderedEdgeNodeIdx - pair<size_t, char*> sEdgeIdx = serialize(orderedEdgeNodeIdx); - - // orderedEdgeNodeIdx - pair<size_t, char*> sFaceIdx = serialize(orderedFaceNodeIdx); - - // Full Serialized Stream // - // Alloc (+ 1 * sizeof(size_t) for nVertex) - const size_t size = sizeof(size_t) + sRefEdgeIdx.first - + sRefFaceIdx.first - + sizeof(size_t) // pTree Size - + sPTree.first // pTree - + sRSpace.first - + sABCtoUVW.first - + sUVWtoABC.first - + sEdgeIdx.first - + sFaceIdx.first; - char* stream = new char[size]; - - // Populate - size_t offset = 0; - - memcpy(stream + offset, &nVertex, sizeof(size_t)); - offset += sizeof(size_t); - - memcpy(stream + offset, sRefEdgeIdx.second, sRefEdgeIdx.first); - offset += sRefEdgeIdx.first; - - memcpy(stream + offset, sRefFaceIdx.second, sRefFaceIdx.first); - offset += sRefFaceIdx.first; - - memcpy(stream + offset, &sPTree.first, sizeof(size_t)); // pTree size - offset += sizeof(size_t); - - memcpy(stream + offset, sPTree.second, sPTree.first); // pTree - offset += sPTree.first; - - memcpy(stream + offset, sRSpace.second, sRSpace.first); - offset += sRSpace.first; - - memcpy(stream + offset, sABCtoUVW.second, sABCtoUVW.first); - offset += sABCtoUVW.first; - - memcpy(stream + offset, sUVWtoABC.second, sABCtoUVW.first); - offset += sABCtoUVW.first; - - memcpy(stream + offset, sEdgeIdx.second, sEdgeIdx.first); - offset += sEdgeIdx.first; - - memcpy(stream + offset, sFaceIdx.second, sFaceIdx.first); - offset += sFaceIdx.first; - - // Free Temp - delete[] sRefEdgeIdx.second; - delete[] sRefFaceIdx.second; - delete[] sPTree.second; - delete[] sRSpace.second; - delete[] sABCtoUVW.second; - delete[] sUVWtoABC.second; - delete[] sEdgeIdx.second; - delete[] sFaceIdx.second; - - // Return - return pair<size_t, char*>(size, stream); -} - -void ReferenceSpace::serialize(const std::string& path) const{ - // Serialize into byte Stream - std::pair<size_t, char*> stream = serialize(); - - // Write byte stream - ofstream output; - output.exceptions(std::ofstream::failbit | std::ofstream::badbit); - output.open(path.c_str(), std::ofstream::binary); - output.write(stream.second, stream.first); - output.close(); - - // Free - delete[] stream.second; -} - -std::pair<size_t, char*> ReferenceSpace:: -serialize(const std::vector<std::vector<size_t> >& source){ - // Vector & Stream size // - size_t nVector = source.size(); - size_t totalSize = sizeof(size_t); // Init to header size (nVector) - - for(size_t i = 0; i < nVector; i++) - totalSize += (source[i].size() + 1) * sizeof(size_t); - // + 1 for subvector size header - - // Alloc Stream // - char* stream = new char[totalSize]; - - // Header (nVector) // - memcpy(stream, &nVector, sizeof(size_t)); - - // SubVectors // - size_t tmpSize; - size_t offset = sizeof(size_t); - - for(size_t i = 0; i < nVector; i++){ - // SubVector size - tmpSize = source[i].size(); - memcpy(stream + offset, &tmpSize, sizeof(size_t)); - offset += sizeof(size_t); - - // SubVector stored values - for(size_t j = 0; j < tmpSize; j++){ - memcpy(stream + offset, &source[i][j], sizeof(size_t)); - offset += sizeof(size_t); - } - } - - // Return // - return pair<size_t, char*>(totalSize, stream); -} - -std::pair<size_t, char*> ReferenceSpace:: -serialize(const std::vector<std::vector<std::vector<size_t> > >& source){ - // Vector & Stream size // - size_t nVector = source.size(); - size_t totalSize = sizeof(size_t); // Init to header size (nVector) - - for(size_t i = 0; i < nVector; i++){ - totalSize += sizeof(size_t); // Subvector size header - - for(size_t j = 0; j < source[i].size(); j++) - totalSize += (source[i][j].size() + 1) * sizeof(size_t); - // + 1 for subsubvector size header - } - - // Alloc Stream // - char* stream = new char[totalSize]; - - // Header (nVector) // - memcpy(stream, &nVector, sizeof(size_t)); - - // SubVectors // - size_t tmpSize; - size_t tmpSubSize; - size_t offset = sizeof(size_t); - - for(size_t i = 0; i < nVector; i++){ - // SubVector size - tmpSize = source[i].size(); - memcpy(stream + offset, &tmpSize, sizeof(size_t)); - offset += sizeof(size_t); - - for(size_t j = 0; j < tmpSize; j++){ - // SubSubVector size - tmpSubSize = source[i][j].size(); - memcpy(stream + offset, &tmpSubSize, sizeof(size_t)); - offset += sizeof(size_t); - - // SubSubVector stored values - for(size_t k = 0; k < tmpSubSize; k++){ - memcpy(stream + offset, &source[i][j][k], sizeof(size_t)); - offset += sizeof(size_t); - } - } - } - - // Return // - return pair<size_t, char*>(totalSize, stream); -} - -size_t ReferenceSpace:: -unserialize(const char* stream, - std::vector<std::vector<size_t> >& dest){ - // Vector size // - size_t nVector; - size_t offset = 0; - - memcpy(&nVector, stream + offset, sizeof(size_t)); - offset += sizeof(size_t); - - // Alloc Vector // - dest.resize(nVector); - - // Populate // - size_t tmpSize; - size_t tmpVal; - - for(size_t i = 0; i < nVector; i++){ - // Subvector size - memcpy(&tmpSize, stream + offset, sizeof(size_t)); - offset += sizeof(size_t); - - // Alloc Subvector - dest[i].resize(tmpSize); - - // Populate Subvector - for(size_t j = 0; j < tmpSize; j++){ - memcpy(&tmpVal, stream + offset, sizeof(size_t)); - offset += sizeof(size_t); - - dest[i][j] = tmpVal; - } - } - - // Return size // - return offset; -} - -size_t ReferenceSpace:: - unserialize(const char* stream, - std::vector<std::vector<std::vector<size_t> > >& dest){ - // Vector size // - size_t nVector; - size_t offset = 0; - - memcpy(&nVector, stream + offset, sizeof(size_t)); - offset += sizeof(size_t); - - // Alloc Vector // - dest.resize(nVector); - - // Populate // - size_t tmpSize; - size_t tmpSubSize; - size_t tmpVal; - - for(size_t i = 0; i < nVector; i++){ - // Subvector size - memcpy(&tmpSize, stream + offset, sizeof(size_t)); - offset += sizeof(size_t); - - // Alloc Subvector - dest[i].resize(tmpSize); - - // Populate Subvector - for(size_t j = 0; j < tmpSize; j++){ - // Subsubvector size - memcpy(&tmpSubSize, stream + offset, sizeof(size_t)); - offset += sizeof(size_t); - - // Alloc Subsubvector - dest[i][j].resize(tmpSubSize); - - // Populate Subsubvector - for(size_t k = 0; k < tmpSubSize; k++){ - memcpy(&tmpVal, stream + offset,sizeof(size_t)); - offset += sizeof(size_t); - - dest[i][j][k] = tmpVal; // AT LAST !! (-: - } - } - } - - // Return size // - return offset; -} diff --git a/FunctionSpace/ReferenceSpace.h b/FunctionSpace/ReferenceSpace.h deleted file mode 100644 index 1e0e04489e3bb7ea7303ecc9ff74dfa7c77cacea..0000000000000000000000000000000000000000 --- a/FunctionSpace/ReferenceSpace.h +++ /dev/null @@ -1,428 +0,0 @@ -#ifndef _REFERENCESPACE_H_ -#define _REFERENCESPACE_H_ - -#include <vector> -#include <list> -#include <string> - -#include "MElement.h" -#include "fullMatrix.h" -#include "PermutationTree.h" - -/** - @interface ReferenceSpace - @brief Base interface for all ReferenceSpace%s - - A Reference Space is the space where all the mesh elements - (of the same geomtrical family) will be mapped. - - A given geomtrical family has one reference space. - Howerver, this reference space can be @em oriented in multiple ways. - These orientations depend on the global number of the mesh element vertices, - and the bigger/smaller relations that exist among them. - - This class can orient the reference space of a geomtrical family - (see specialized classes). - It can also compute the jacobian matrices for the mapping - between the physcial and reference spaces, - @em by @em taking @em orientation @em into @em acount. - - This class can handle three different types of reference spaces: - @li The XYZ space, which is the space of the physical (mesh) elements - @li The UVW space, which is the @em unoriented reference space (mesh module) - @li The ABC spaces, which are the set @em oriented UVW spaces - - Note that the UVW and ABC spaces are defined on the same domain - (the one of UVW). - The only difference is how the vertices are indexed - (@em i.e. the orientation). - Actualy, the ABC spaces are constructed by orienting (that is reindexing) - the edges and faces of the UVW space. - - Also note that a given mesh element can have only one orientation, - so it can be mapped on only one of the ABC spaces. - This class is able to find which ABC space (orientation) - corresponds to a mesh element. - - The edges (or faces) are represended by the index of their vertices. - For a given edge (or face), this class is able to return these indexes, - so that the bigger/smaller relations between the indexed vertices is valid. - By valid, one need to understand: so that the bigger/smaller relations - are the same for every edge (or face) of every mesh element. - Or, one can say: such that the edges (or faces) are oriented. - - Since an ABC space corresponds to an orientation, an ABC space corresponds - to a set of ordered edge (or face) node index. This class is able to give - these node index relations for all its ABC spaces. -*/ - -class ReferenceSpace{ - private: - class EdgeComparator{ - public: - bool operator()(const std::vector<size_t>& a, - const std::vector<size_t>& b); - }; - - private: - typedef struct{ - bool first; - std::vector<size_t> second; - std::vector<size_t> third; - } triplet; - - protected: - // Element Definition // - size_t nVertex; - std::vector<std::vector<size_t> > refEdgeNodeIdx; - std::vector<std::vector<size_t> > refFaceNodeIdx; - - // Permutation Tree // - PermutationTree* pTree; - - // Reference Spaces Node Ids // - std::vector<std::vector<size_t> > refSpaceNodeId; - - // ABC space to UVW space shape function index mapping // - std::vector<std::vector<size_t> > ABCtoUVWIndex; - - // UVW space to ABC space shape function index mapping // - std::vector<std::vector<size_t> > UVWtoABCIndex; - - // Ordered Edge & Face Node Index // - std::vector<std::vector<std::vector<size_t> > > orderedEdgeNodeIdx; - std::vector<std::vector<std::vector<size_t> > > orderedFaceNodeIdx; - - public: - ReferenceSpace(const std::string& path); - virtual ~ReferenceSpace(void); - - size_t getNVertex(void) const; - size_t getNEdge(void) const; - size_t getNFace(void) const; - - size_t getNOrientation(void) const; - size_t getOrientation(const MElement& element) const; - - const std::vector<std::vector<std::vector<size_t> > >& - getEdgeNodeIndex(void) const; - - const std::vector<std::vector<std::vector<size_t> > >& - getFaceNodeIndex(void) const; - - const std::vector<size_t>& - getNodeIndexFromABCtoUVW(const MElement& element) const; - - void mapFromABCtoUVW(const MElement& element, - double a, double b, double c, - double uvw[3]) const; - - void mapFromABCtoXYZ(const MElement& element, - double a, double b, double c, - double xyz[3]) const; - - void mapFromUVWtoABC(const MElement& element, - double u, double v, double w, - double abc[3]) const; - - void mapFromXYZtoABC(const MElement& element, - double x, double y, double z, - double abc[3]) const; - - double getJacobian(const MElement& element, - double a, double b, double c, - fullMatrix<double>& jac) const; - - virtual std::string toString(void) const; - virtual std::string toLatex(void) const; - - std::pair<size_t, char*> serialize(void) const; - void serialize(const std::string& path) const; - - protected: - ReferenceSpace(void); - - void init(void); - void init(const char* stream); - void init(const std::string& path); - - private: - void getOrderedEdge(void); - void getOrderedFace(void); - - void findConnectivity - (std::list<size_t>& listOfTrueReferenceSpace, - std::list<std::vector<size_t> >& listOfRefNodeIndexPermutation, - std::list<std::vector<size_t> >& listOfReverseNodeIndexPermutation); - - triplet isSameConnectivity(const std::vector<size_t>& pTest, - const std::vector<size_t>& pRef) const; - - bool isSameEdge(const std::vector<size_t>& pTest, - const std::vector<size_t>& pRef) const; - - static bool edgeComparator(const std::vector<size_t>& a, - const std::vector<size_t>& b); - - std::vector<size_t> - getRefIndexPermutation(const std::vector<size_t>& ref, - const std::vector<size_t>& test) const; - - std::vector<size_t> - getReverseIndexPermutation(const std::vector<size_t>& ref, - const std::vector<size_t>& test) const; - - size_t getPermutationIdx(const MElement& element) const; - - static void - orderRefEntityForGivenRefSpace(std::vector<size_t>& refEntityNodeIdx, - std::vector<size_t>& refSpaceNodeId, - std::vector<size_t>& orderedEntityNodeIdx); - - void correctQuadFaceNodeIdx(size_t faceId, - std::vector<size_t>& correctedQuadFaceNodeIdx); - - static bool sortPredicate(const std::pair<size_t, size_t>& a, - const std::pair<size_t, size_t>& b); - - static void regularize(size_t dim, fullMatrix<double>& jac); - - static std::pair<size_t, char*> - serialize(const std::vector<std::vector<size_t> >& source); - - static std::pair<size_t, char*> - serialize(const std::vector<std::vector<std::vector<size_t> > >& source); - - static size_t - unserialize(const char* stream, - std::vector<std::vector<size_t> >& dest); - - static size_t - unserialize(const char* stream, - std::vector<std::vector<std::vector<size_t> > >& dest); -}; - - -/** - @internal - @fn ReferenceSpace::ReferenceSpace(void) - Instatiate a new ReferenceSpace - @endinternal - ** - - @fn ReferenceSpace::ReferenceSpace(const std::string&) - @param path A file path - - Instanciates a new ReferenceSpace by loading the file in the given path - ** - - @fn ReferenceSpace::~ReferenceSpace - Deletes this ReferenceSpace - ** - - @fn ReferenceSpace::getNVertex - @return Returns the number of topological vertices of this ReferenceSpace - ** - - @fn ReferenceSpace::getNEdge - @return Returns the number of topological edges of this ReferenceSpace - ** - - @fn ReferenceSpace::getNFace - @return Returns the number of topological faces of this ReferenceSpace - ** - - @fn ReferenceSpace::getNOrientation - @returns Returns the number of orientations for this ReferenceSpace - (that is the number of ABC spaces for this UVW space) - ** - - @fn ReferenceSpace::getOrientation - @param element A MElement - @returns - Returns a natural number defining the orientation (that its ABC space) - of the given element - - If the given element does not belong to the same geometrical entity - as this ReferenceSpace an Exception is thrown - ** - - @fn ReferenceSpace::getEdgeNodeIndex - @return Returns every oriented edge node index of this ReferenceSpace - - @li The first vector represents a particular ABC space - (see ReferenceSpace::getOrientation()) - @li The second vector represents a particular edge (for the given ABC space) - @li The last vector represents the vertex indexes of the given edge - ** - - @fn ReferenceSpace::getFaceNodeIndex - @return Returns every oriented face node index of this ReferenceSpace - - @li The first vector represents a particular ABC space - (see ReferenceSpace::getOrientation()) - @li The second vector represents a particular face (for the given ABC space) - @li The last vector represents the vertex indexes of the given face - ** - - @fn ReferenceSpace::getNodeIndexFromABCtoUVW - @param element A MElement - - We call ABC[i] the ID of the ith node in the ABC space of the given element. - We call UVW[i] the ID of the ith node in the UVW space of the given element. - - @return Returns a vector, called map, such that: ABC[i] = UVW[map[i]] - - Note that this is valid, since ABC spaces and UVW space are defined on the - same domain. The only difference between those spaces is the node indexing. - - If the given element does not belong to the same geometrical entity - as this ReferenceSpace an Exception is thrown - ** - - @fn ReferenceSpace::mapFromABCtoUVW - @param element A MElement - @param a The 'A' coordinate of a point in the ABC space of the given element - @param b The 'B' coordinate of a point in the ABC space of the given element - @param c The 'C' coordinate of a point in the ABC space of the given element - @param uvw A vector in the UVW space of the given element - - Fills the given vector with the coordinates of the - (a, b, c) point in the UVW space - - If the given element does not belong to the same geometrical entity - as this ReferenceSpace an Exception is thrown - ** - - @fn ReferenceSpace::mapFromABCtoXYZ - @param element A MElement - @param a The 'A' coordinate of a point in the ABC space of the given element - @param b The 'B' coordinate of a point in the ABC space of the given element - @param c The 'C' coordinate of a point in the ABC space of the given element - @param xyz A vector in the XYZ space of the given element - - Fills the given vector with the coordinates of the - (a, b, c) point in the XYZ space - - If the given element does not belong to the same geometrical entity - as this ReferenceSpace an Exception is thrown - ** - - @fn ReferenceSpace::mapFromUVWtoABC - @param element A MElement - @param u The 'U' coordinate of a point in the UVW space of the given element - @param v The 'V' coordinate of a point in the UVW space of the given element - @param w The 'W' coordinate of a point in the UVW space of the given element - @param abc A vector in the ABC space of the given element - - Fills the given vector with the coordinates of the - (u, v, w) point in the ABC space - - If the given element does not belong to the same geometrical entity - as this ReferenceSpace an Exception is thrown - ** - - @fn ReferenceSpace::mapFromXYZtoABC - @param element A MElement - @param x The 'X' coordinate of a point in the XYZ space of the given element - @param y The 'Y' coordinate of a point in the XYZ space of the given element - @param z The 'Z' coordinate of a point in the XYZ space of the given element - @param abc A vector in the ABC space of the given element - - Fills the given vector with the coordinates of the - (x, y, z) point in the ABC space - - If the given element does not belong to the same geometrical entity - as this ReferenceSpace an Exception is thrown - ** - - @fn ReferenceSpace::getJacobian - @param element A MElement - @param a The 'A' coordinate of a point in the ABC space of the given element - @param b The 'B' coordinate of a point in the ABC space of the given element - @param c The 'C' coordinate of a point in the ABC space of the given element - @param jac A 3 by 3 allocated fullMatrix - - Fills the given matrix with the jacobian, evaluated at (a, b, c), - of the mapping between the ABC space and the XYZ space - - @return Returns the determinant of the jacobian matrix - - If the given element does not belong to the same geometrical entity - as this ReferenceSpace an Exception is thrown - ** - - @fn ReferenceSpace::toString - @return Returns a string describing this ReferenceSpace - ** - - @fn ReferenceSpace::toLatex - @return Returns a string (of a Latex file) describing this ReferenceSpace - ** - - @fn ReferenceSpace::serialize(void) const - - Serialize this ReferenceSpace into a byte stream - - @return Returns a pair such that: - @li The first entry is the byte stream size - @li The second entry is a pointer the allocated byte stream - ** - - @fn ReferenceSpace::serialize(const std::string&) const - @param path A file path - - Serialize this ReferenceSpace into the given file - */ - -////////////////////// -// Inline Functions // -////////////////////// - -inline size_t ReferenceSpace::getNVertex(void) const{ - return nVertex; -} - -inline size_t ReferenceSpace::getNEdge(void) const{ - return refEdgeNodeIdx.size(); -} - -inline size_t ReferenceSpace::getNFace(void) const{ - return refFaceNodeIdx.size(); -} - -inline size_t ReferenceSpace::getNOrientation(void) const{ - return refSpaceNodeId.size(); -} - -inline -size_t ReferenceSpace::getOrientation(const MElement& element) const{ - return pTree->getTagFromPermutation(getPermutationIdx(element)); -} - -inline -const std::vector<std::vector<std::vector<size_t> > >& -ReferenceSpace::getEdgeNodeIndex(void) const{ - return orderedEdgeNodeIdx; -} - -inline -const std::vector<std::vector<std::vector<size_t> > >& -ReferenceSpace::getFaceNodeIndex(void) const{ - return orderedFaceNodeIdx; -} - -inline -const std::vector<size_t>& -ReferenceSpace::getNodeIndexFromABCtoUVW(const MElement& element) const{ - return ABCtoUVWIndex[getPermutationIdx(element)]; -} - -inline -bool -ReferenceSpace::sortPredicate(const std::pair<size_t, size_t>& a, - const std::pair<size_t, size_t>& b){ - return a.second < b.second; -} - -#endif diff --git a/FunctionSpace/ReferenceSpaceManager.cpp b/FunctionSpace/ReferenceSpaceManager.cpp deleted file mode 100644 index 3023c2e36bae195cc5ec545fe798496a9ff9479d..0000000000000000000000000000000000000000 --- a/FunctionSpace/ReferenceSpaceManager.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "Exception.h" -#include "ReferenceSpaceManager.h" - -using namespace std; - -const size_t ReferenceSpaceManager::nSpace = 9; -vector<ReferenceSpace*> ReferenceSpaceManager::refSpace(nSpace, NULL); - -ReferenceSpaceManager::ReferenceSpaceManager(void){ -} - -ReferenceSpaceManager::~ReferenceSpaceManager(void){ -} - -void ReferenceSpaceManager::init(int elementType){ - // Warning: no elementType == 0 - // --> refSpace[0] will be alwys null --> not realy important - - switch(elementType){ - case 1: throw Exception("ReferenceSpace for Points not implemented"); - - case 2: refSpace[elementType] = new LineReferenceSpace; break; - case 3: refSpace[elementType] = new TriReferenceSpace; break; - case 4: refSpace[elementType] = new QuadReferenceSpace; break; - case 5: refSpace[elementType] = new TetReferenceSpace; break; - case 6: refSpace[elementType] = new PyrReferenceSpace; break; - case 7: refSpace[elementType] = new PriReferenceSpace; break; - case 8: refSpace[elementType] = new HexReferenceSpace; break; - - case 9: throw Exception("ReferenceSpace for POLYG not implemented"); - case 10: throw Exception("ReferenceSpace for POLYH not implemented"); - case 11: throw Exception("ReferenceSpace for XFEM not implemented"); - } -} - -void ReferenceSpaceManager::clear(void){ - for(size_t i = 0; i < nSpace; i++) - if(refSpace[i]) - delete refSpace[i]; - - for(size_t i = 0; i < nSpace; i++) - refSpace[i] = NULL; -} diff --git a/FunctionSpace/ReferenceSpaceManager.h b/FunctionSpace/ReferenceSpaceManager.h deleted file mode 100644 index 4e6cfdde3af2e0dcddb14ab35400a736369cc78f..0000000000000000000000000000000000000000 --- a/FunctionSpace/ReferenceSpaceManager.h +++ /dev/null @@ -1,359 +0,0 @@ -#ifndef _REFERENCESPACEMANAGER_H_ -#define _REFERENCESPACEMANAGER_H_ - -#include "ReferenceSpace.h" - -#include "LineReferenceSpace.h" -#include "TriReferenceSpace.h" -#include "QuadReferenceSpace.h" -#include "TetReferenceSpace.h" -#include "PyrReferenceSpace.h" -#include "PriReferenceSpace.h" -#include "HexReferenceSpace.h" - -/** - @class ReferenceSpaceManager - @brief A way to handel ReferenceSpace%s - - This class implements class method to handel and access ReferenceSpace%s. - - This class uses tags to define the geomtrical type of an element. - These tags are taken from <a href="http://geuz.org/gmsh/">gmsh</a>. - - Finaly, this class will autmoticaly instanciate a ReferenceSpace for a given - element type, once this type is first met. - These instance will remain in memory unless a clear method is used. - - @see - See also the ReferenceSpace documentation - */ - -class ReferenceSpaceManager{ - private: - static const size_t nSpace; - static std::vector<ReferenceSpace*> refSpace; - - public: - ReferenceSpaceManager(void); - ~ReferenceSpaceManager(void); - - static void clear(void); - static const ReferenceSpace& getReferenceSpace(int elementType); - - static size_t getNVertex(int elementType); - static size_t getNEdge(int elementType); - static size_t getNFace(int elementType); - - static size_t getNOrientation(int elementType); - static size_t getOrientation(const MElement& element); - - static const std::vector<std::vector<std::vector<size_t> > >& - getEdgeNodeIndex(int elementType); - - static const std::vector<std::vector<std::vector<size_t> > >& - getFaceNodeIndex(int elementType); - - static const std::vector<size_t>& - getNodeIndexFromABCtoUVW(const MElement& element); - - static void mapFromABCtoUVW(const MElement& element, - double a, double b, double c, double uvw[3]); - - static void mapFromABCtoXYZ(const MElement& element, - double a, double b, double c, double xyz[3]); - - static void mapFromUVWtoABC(const MElement& element, - double u, double v, double w, double abc[3]); - - static void mapFromXYZtoABC(const MElement& element, - double x, double y, double z, double abc[3]); - - static double getJacobian(const MElement& element, - double a, double b, double c, - fullMatrix<double>& jac); - private: - static void init(int elementType); -}; - -/** - @fn ReferenceSpaceManager::ReferenceSpaceManager - Instanciates a new ReferenceSpaceManager - (not needed since it got only class methods) - ** - - @fn ReferenceSpaceManager::~ReferenceSpaceManager - Deletes this ReferenceSpaceManager - - It is worth mentioning that @em no ReferenceSpaceManager::clear() calls - are done. - ** - - @fn ReferenceSpaceManager::clear - Clears all the ReferenceSpace%s that where instanciated by - ReferenceSpaceManager - - @see - See detailed description for how ReferenceSpace%s are instanciated by - ReferenceSpaceManager - ** - - @fn ReferenceSpaceManager::getReferenceSpace - @param elementType A geometrical tag - @return Returns the ReferenceSpace associated to the given tag - ** - - @fn ReferenceSpaceManager::getNVertex - @param elementType A geometrical tag - @return Returns the number of topological vertices for the given - geomtrical tag - ** - - @fn ReferenceSpaceManager::getNEdge - @param elementType A geometrical tag - @return Returns the number of topological edges for the given geometrical tag - ** - - @fn ReferenceSpaceManager::getNFace - @param elementType A geometrical tag - @return Returns the number of topological faces for the given geometrical tag - ** - - @fn ReferenceSpaceManager::getNOrientation - @param elementType A geometrical tag - @return Returns the number of orientation (that is the number of ABC spaces) - for the given geomtrical tag - ** - - @fn ReferenceSpaceManager::getOrientation - @param element A MElement - @return - Retruns a natural number defining the orientation (that is its ABC space) - of the given element - ** - - @fn ReferenceSpaceManager::getEdgeNodeIndex - @param elementType A geometrical tag - @return Returns every oriented edge node index for the given geomtrical tag - - @li The first vector represents a particular ABC space - (see ReferenceSpaceManager::getOrientation()) - @li The second vector represents a particular edge (for the given ABC space) - @li The last vector represents the vertex indexes of the given edge - ** - - @fn ReferenceSpaceManager::getFaceNodeIndex - @param elementType A geometrical tag - @return Returns every oriented face node index for the given geomtrical tag - - @li The first vector represents a particular ABC space - (see ReferenceSpaceManager::getOrientation()) - @li The second vector represents a particular face (for the given ABC space) - @li The last vector represents the vertex indexes of the given face - ** - - @fn ReferenceSpaceManager::getNodeIndexFromABCtoUVW - @param element A MElement - - We call ABC[i] the ID of the ith node in the ABC space of the given element. - We call UVW[i] the ID of the ith node in the UVW space of the given element. - - @return Returns a vector, called map, such that: ABC[i] = UVW[map[i]] - - Note that this is valid, since ABC spaces and UVW space are defined on the - same domain. The only difference between those spaces is the node indexing. - ** - - @fn ReferenceSpaceManager::mapFromABCtoUVW - @param element A MElement - @param a The 'A' coordinate of a point in the ABC space of the given element - @param b The 'B' coordinate of a point in the ABC space of the given element - @param c The 'C' coordinate of a point in the ABC space of the given element - @param uvw A vector in the UVW space of the given element - - Fills the given vector with the coordinates of the - (a, b, c) point in the UVW space - ** - - @fn ReferenceSpaceManager::mapFromABCtoXYZ - @param element A MElement - @param a The 'A' coordinate of a point in the ABC space of the given element - @param b The 'B' coordinate of a point in the ABC space of the given element - @param c The 'C' coordinate of a point in the ABC space of the given element - @param xyz A vector in the XYZ space of the given element - - Fills the given vector with the coordinates of the - (a, b, c) point in the XYZ space - ** - - @fn ReferenceSpaceManager::mapFromUVWtoABC - @param element A MElement - @param u The 'U' coordinate of a point in the UVW space of the given element - @param v The 'V' coordinate of a point in the UVW space of the given element - @param w The 'W' coordinate of a point in the UVW space of the given element - @param abc A vector in the ABC space of the given element - - Fills the given vector with the coordinates of the - (u, v, w) point in the ABC space - ** - - @fn ReferenceSpaceManager::mapFromXYZtoABC - @param element A MElement - @param x The 'X' coordinate of a point in the XYZ space of the given element - @param y The 'Y' coordinate of a point in the XYZ space of the given element - @param z The 'Z' coordinate of a point in the XYZ space of the given element - @param abc A vector in the ABC space of the given element - - Fills the given vector with the coordinates of the - (x, y, z) point in the ABC space - ** - - @fn ReferenceSpaceManager::getJacobian - @param element A MElement - @param a The 'A' coordinate of a point in the ABC space of the given element - @param b The 'B' coordinate of a point in the ABC space of the given element - @param c The 'C' coordinate of a point in the ABC space of the given element - @param jac A 3 by 3 allocated fullMatrix - - Fills the given matrix with the jacobian, evaluated at (a, b, c), - of the mapping between the ABC space and the XYZ space - - @return Returns the determinant of the jacobian matrix - ** - */ - -//////////////////// -// Inline Methods // -//////////////////// - -inline size_t ReferenceSpaceManager::getNVertex(int elementType){ - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->getNVertex(); -} - -inline size_t ReferenceSpaceManager::getNEdge(int elementType){ - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->getNEdge(); -} - -inline size_t ReferenceSpaceManager::getNFace(int elementType){ - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->getNFace(); -} - -inline -const ReferenceSpace& ReferenceSpaceManager::getReferenceSpace(int elementType){ - if(!refSpace[elementType]) - init(elementType); - - return *refSpace[elementType]; -} - -inline -size_t ReferenceSpaceManager::getNOrientation(int elementType){ - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->getNOrientation(); -} - -inline -size_t ReferenceSpaceManager::getOrientation(const MElement& element){ - const int elementType = element.getType(); - - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->getOrientation(element); -} - -inline -const std::vector<std::vector<std::vector<size_t> > >& -ReferenceSpaceManager::getEdgeNodeIndex(int elementType){ - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->getEdgeNodeIndex(); -} - -inline -const std::vector<std::vector<std::vector<size_t> > >& -ReferenceSpaceManager::getFaceNodeIndex(int elementType){ - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->getFaceNodeIndex(); -} - -inline -const std::vector<size_t>& -ReferenceSpaceManager::getNodeIndexFromABCtoUVW(const MElement& element){ - const int elementType = element.getType(); - - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->getNodeIndexFromABCtoUVW(element); -} - -inline void ReferenceSpaceManager::mapFromABCtoUVW(const MElement& element, - double a, double b, double c, - double uvw[3]){ - const int elementType = element.getType(); - - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->mapFromABCtoUVW(element, a, b, c, uvw); -} - -inline void ReferenceSpaceManager::mapFromABCtoXYZ(const MElement& element, - double a, double b, double c, - double xyz[3]){ - const int elementType = element.getType(); - - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->mapFromABCtoXYZ(element, a, b, c, xyz); -} - -inline void ReferenceSpaceManager::mapFromUVWtoABC(const MElement& element, - double u, double v, double w, - double abc[3]){ - const int elementType = element.getType(); - - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->mapFromUVWtoABC(element, u, v, w, abc); -} - -inline void ReferenceSpaceManager::mapFromXYZtoABC(const MElement& element, - double x, double y, double z, - double abc[3]){ - const int elementType = element.getType(); - - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->mapFromXYZtoABC(element, x, y, z, abc); -} - -inline double ReferenceSpaceManager::getJacobian(const MElement& element, - double a, double b, double c, - fullMatrix<double>& jac){ - const int elementType = element.getType(); - - if(!refSpace[elementType]) - init(elementType); - - return refSpace[elementType]->getJacobian(element, a, b, c, jac); -} - -#endif diff --git a/FunctionSpace/TetEdgeBasis.cpp b/FunctionSpace/TetEdgeBasis.cpp deleted file mode 100644 index f90eeeaba0a71a160db89a7d320a89829c57b2eb..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetEdgeBasis.cpp +++ /dev/null @@ -1,331 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "TetEdgeBasis.h" - -using namespace std; - -TetEdgeBasis::TetEdgeBasis(size_t order){ - // Set Basis Type // - this->order = order; - - type = TYPE_TET; - dim = 3; - - nVertex = 0; - nEdge = 6 * (order + 1); - nFace = 4 * (order + 1) * (order - 1); - nCell = (order + 1) * (order - 1) * (order - 2) / 2; - nFunction = nVertex + nEdge + nFace + nCell; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - const vector<vector<vector<size_t> > >& - faceIdx = ReferenceSpaceManager::getFaceNodeIndex(type); - - // Alloc Temporary Space // - const int orderPlus = order + 1; - const int orderMinus = order - 1; - const int orderMinusTwo = order - 2; - - Polynomial* legendre = new Polynomial[orderMinus]; - Polynomial* sclLegendre = new Polynomial[orderMinus]; - Polynomial* intLegendre = new Polynomial[orderPlus]; - - // Legendre Polynomial // - Legendre::legendre(legendre, orderMinusTwo); - Legendre::scaled(sclLegendre, orderMinusTwo); - Legendre::intScaled(intLegendre, orderPlus); - - // Lagrange Polynomial // - const Polynomial lagrange[4] = - { - Polynomial(Polynomial(1, 0, 0, 0) - - Polynomial(1, 1, 0, 0) - - Polynomial(1, 0, 1, 0) - - Polynomial(1, 0, 0, 1)), - - Polynomial(Polynomial(1, 1, 0, 0)), - - Polynomial(Polynomial(1, 0, 1, 0)), - - Polynomial(Polynomial(1, 0, 0, 1)) - }; - - - // Basis // - basis = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new vector<Polynomial>*[nFunction]; - - // Edge Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = 0; - - for(int e = 0; e < 6; e++){ - for(int l = 0; l < orderPlus; l++){ - // Nedelec - if(l == 0){ - vector<Polynomial> tmp1 = lagrange[edgeIdx[s][e][1]].gradient(); - vector<Polynomial> tmp2 = lagrange[edgeIdx[s][e][0]].gradient(); - - tmp1[0].mul(lagrange[edgeIdx[s][e][0]]); - tmp1[1].mul(lagrange[edgeIdx[s][e][0]]); - tmp1[2].mul(lagrange[edgeIdx[s][e][0]]); - - tmp2[0].mul(lagrange[edgeIdx[s][e][1]]); - tmp2[1].mul(lagrange[edgeIdx[s][e][1]]); - tmp2[2].mul(lagrange[edgeIdx[s][e][1]]); - - tmp2[0].sub(tmp1[0]); - tmp2[1].sub(tmp1[1]); - tmp2[2].sub(tmp1[2]); - - basis[s][i] = new vector<Polynomial>(tmp2); - } - - // High Order - else{ - basis[s][i] = - new vector<Polynomial> - ((intLegendre[l].compose(lagrange[edgeIdx[s][e][0]] - - lagrange[edgeIdx[s][e][1]] - , - lagrange[edgeIdx[s][e][0]] + - lagrange[edgeIdx[s][e][1]])).gradient()); - } - i++; - } - } - } - - // Face Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nEdge; - - for(int f = 0; f < 4; f++){ - for(size_t l1 = 1; l1 < order; l1++){ - for(int l2 = 0; l2 + (int)l1 - 1 < orderMinus; l2++){ - // Preliminary Type 1 - Polynomial sum = - lagrange[faceIdx[s][f][0]] + - lagrange[faceIdx[s][f][1]] + - lagrange[faceIdx[s][f][2]]; - - Polynomial u = - intLegendre[l1].compose(lagrange[faceIdx[s][f][1]] - - lagrange[faceIdx[s][f][0]] - , - lagrange[faceIdx[s][f][0]] + - lagrange[faceIdx[s][f][1]]); - Polynomial v = - lagrange[faceIdx[s][f][2]] * - sclLegendre[l2].compose(lagrange[faceIdx[s][f][2]] * 2 - sum, sum); - - // Preliminary Type 2 - vector<Polynomial> gradU = u.gradient(); - vector<Polynomial> gradV = v.gradient(); - - vector<Polynomial> vGradU(gradU); - vGradU[0].mul(v); - vGradU[1].mul(v); - vGradU[2].mul(v); - - vector<Polynomial> uGradV(gradV); - uGradV[0].mul(u); - uGradV[1].mul(u); - uGradV[2].mul(u); - - vector<Polynomial> subGradUV(vGradU); - subGradUV[0].sub(uGradV[0]); - subGradUV[1].sub(uGradV[1]); - subGradUV[2].sub(uGradV[2]); - - // Preliminary Type 3 - vector<Polynomial> gradL1 = lagrange[faceIdx[s][f][0]].gradient(); - vector<Polynomial> gradL2 = lagrange[faceIdx[s][f][1]].gradient(); - - vector<Polynomial> l2GradL1(gradL1); - l2GradL1[0].mul(lagrange[faceIdx[s][f][1]]); - l2GradL1[1].mul(lagrange[faceIdx[s][f][1]]); - l2GradL1[2].mul(lagrange[faceIdx[s][f][1]]); - - vector<Polynomial> l1GradL2(gradL2); - l1GradL2[0].mul(lagrange[faceIdx[s][f][0]]); - l1GradL2[1].mul(lagrange[faceIdx[s][f][0]]); - l1GradL2[2].mul(lagrange[faceIdx[s][f][0]]); - - vector<Polynomial> subGradL1L2V(l2GradL1); - subGradL1L2V[0].sub(l1GradL2[0]); - subGradL1L2V[1].sub(l1GradL2[1]); - subGradL1L2V[2].sub(l1GradL2[2]); - - subGradL1L2V[0].mul(v); - subGradL1L2V[1].mul(v); - subGradL1L2V[2].mul(v); - - - // Type 1 - basis[s][i] = new vector<Polynomial>((u * v).gradient()); - i++; - - // Type 2 - basis[s][i] = new vector<Polynomial>(subGradUV); - i++; - - // Type 3 - if(l1 == 1){ - basis[s][i] = new vector<Polynomial>(subGradL1L2V); - i++; - } - } - } - } - } - - // Cell Based // - const Polynomial one(1, 0, 0, 0); - - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nEdge + nFace; - - for(int l1 = 1; l1 < orderMinus; l1++){ - for(int l2 = 0; l2 + l1 - 1 < orderMinusTwo; l2++){ - for(int l3 = 0; l3 + l2 + l1 - 1 < orderMinusTwo; l3++){ - // Preliminary Type 1 - Polynomial u = intLegendre[l1].compose - (lagrange[0] - lagrange[1], - lagrange[0] + lagrange[1]); - - Polynomial v = lagrange[2] * sclLegendre[l2].compose - (lagrange[2] * 2 - (one - lagrange[3]), one - lagrange[3]); - - Polynomial w = lagrange[3] * legendre[l3].compose - (lagrange[3] * 2 - one); - - // Preliminary Type 2 - vector<Polynomial> gradU = u.gradient(); - vector<Polynomial> gradV = v.gradient(); - vector<Polynomial> gradW = w.gradient(); - - vector<Polynomial> vwGradU(gradU); - vwGradU[0].mul(v); - vwGradU[1].mul(v); - vwGradU[2].mul(v); - - vwGradU[0].mul(w); - vwGradU[1].mul(w); - vwGradU[2].mul(w); - - vector<Polynomial> uwGradV(gradV); - uwGradV[0].mul(u); - uwGradV[1].mul(u); - uwGradV[2].mul(u); - - uwGradV[0].mul(w); - uwGradV[1].mul(w); - uwGradV[2].mul(w); - - vector<Polynomial> uvGradW(gradW); - uvGradW[0].mul(u); - uvGradW[1].mul(u); - uvGradW[2].mul(u); - - uvGradW[0].mul(v); - uvGradW[1].mul(v); - uvGradW[2].mul(v); - - vector<Polynomial> term1(vwGradU); - term1[0].sub(uwGradV[0]); - term1[1].sub(uwGradV[1]); - term1[2].sub(uwGradV[2]); - - term1[0].add(uvGradW[0]); - term1[1].add(uvGradW[1]); - term1[2].add(uvGradW[2]); - - vector<Polynomial> term2(vwGradU); - term2[0].add(uwGradV[0]); - term2[1].add(uwGradV[1]); - term2[2].add(uwGradV[2]); - - term2[0].sub(uvGradW[0]); - term2[1].sub(uvGradW[1]); - term2[2].sub(uvGradW[2]); - - // Preliminary Type 3 - vector<Polynomial> gradL1 = lagrange[0].gradient(); - vector<Polynomial> gradL2 = lagrange[1].gradient(); - - vector<Polynomial> l2GradL1(gradL1); - l2GradL1[0].mul(lagrange[1]); - l2GradL1[1].mul(lagrange[1]); - l2GradL1[2].mul(lagrange[1]); - - vector<Polynomial> l1GradL2(gradL2); - l1GradL2[0].mul(lagrange[0]); - l1GradL2[1].mul(lagrange[0]); - l1GradL2[2].mul(lagrange[0]); - - vector<Polynomial> subGradL1L2VW(l2GradL1); - subGradL1L2VW[0].sub(l1GradL2[0]); - subGradL1L2VW[1].sub(l1GradL2[1]); - subGradL1L2VW[2].sub(l1GradL2[2]); - - subGradL1L2VW[0].mul(v); - subGradL1L2VW[1].mul(v); - subGradL1L2VW[2].mul(v); - - subGradL1L2VW[0].mul(w); - subGradL1L2VW[1].mul(w); - subGradL1L2VW[2].mul(w); - - - // Type 1 - basis[s][i] = new vector<Polynomial>((u * v * w).gradient()); - i++; - - // Type 2 -- Part 1 - basis[s][i] = new vector<Polynomial>(term1); - i++; - - // Type 2 -- Part 2 - basis[s][i] = new vector<Polynomial>(term2); - i++; - - // Type 3 - if(l1 == 1){ - basis[s][i] = new vector<Polynomial>(subGradL1L2VW); - i++; - } - } - } - } - } - - // Free Temporary Space // - // Legendre - delete[] legendre; - delete[] sclLegendre; - delete[] intLegendre; -} - -TetEdgeBasis::~TetEdgeBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/TetEdgeBasis.h b/FunctionSpace/TetEdgeBasis.h deleted file mode 100644 index 0cc8d9917627112c6796509dc13278ce65b97c23..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetEdgeBasis.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _TETEDGEBASIS_H_ -#define _TETEDGEBASIS_H_ - -#include "BasisHierarchical1Form.h" - -/** - @class TetEdgeBasis - @brief An Edge Basis for Tetrahedra - - This class can instantiate an Edge-Based Basis - (high or low order) for Tetrahedra - - It uses - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation. -*/ - -class TetEdgeBasis: public BasisHierarchical1Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Edge-Basis for Tetrahedra of the given order - TetEdgeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~TetEdgeBasis(void); -}; - -#endif diff --git a/FunctionSpace/TetLagrangeBasis.cpp b/FunctionSpace/TetLagrangeBasis.cpp deleted file mode 100644 index 05ba166ed8ca03e54350a41d57414d0fec9d8b94..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetLagrangeBasis.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "ElementType.h" -#include "GmshDefines.h" -#include "pointsGenerators.h" - -#include "TetLagrangeBasis.h" - -TetLagrangeBasis::TetLagrangeBasis(size_t order){ - // If order 0 (Nedelec): use order 1 - if(order == 0) - order = 1; - - // Set Basis Type // - this->order = order; - - type = TYPE_TET; - dim = 3; - - nVertex = 4; - nEdge = 6 * (order - 1); - nFace = 2 * (order - 1) * (order - 2); - nCell = (order - 1) * (order - 2) * (order - 3) / 6; - nFunction = nVertex + nEdge + nFace + nCell; - - // Init polynomialBasis // - lBasis = new polynomialBasis(ElementType::getTag(TYPE_TET, order, false)); - - // Init Lagrange Point // - lPoint = new fullMatrix<double>(gmshGeneratePointsTetrahedron(order, false)); -} - -TetLagrangeBasis::~TetLagrangeBasis(void){ - delete lBasis; - delete lPoint; -} diff --git a/FunctionSpace/TetLagrangeBasis.h b/FunctionSpace/TetLagrangeBasis.h deleted file mode 100644 index 5c19d8254796e50c7c36d2dea85c595a0f23eee8..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetLagrangeBasis.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _TETLAGRANGEBASIS_H_ -#define _TETLAGRANGEBASIS_H_ - -#include "BasisLagrange.h" - -/** - @class TetLagrangeBasis - @brief Lagrange Basis for Tetrahedra - - This class can instantiate a Lagrange Basis - for a Tetrahedron and for a given order. - - It uses - <a href="http://geuz.org/gmsh/">gmsh</a> Basis. - */ - -class TetLagrangeBasis: public BasisLagrange{ - public: - //! @param order A natural number - //! - //! Returns a new TetLagrangeBasis of the given order - TetLagrangeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~TetLagrangeBasis(void); -}; - -#endif diff --git a/FunctionSpace/TetNedelecBasis.cpp b/FunctionSpace/TetNedelecBasis.cpp deleted file mode 100644 index 7a027ef689a4da06f8fc85ef774db93f8798dc0b..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetNedelecBasis.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "TetNedelecBasis.h" - -using namespace std; - -TetNedelecBasis::TetNedelecBasis(void){ - // Set Basis Type // - this->order = 0; - - type = TYPE_TET; - dim = 3; - - nVertex = 0; - nEdge = 6; - nFace = 0; - nCell = 0; - nFunction = 6; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - // Lagrange Polynomial // - const Polynomial lagrange[4] = - { - Polynomial(Polynomial(1, 0, 0, 0) - - Polynomial(1, 1, 0, 0) - - Polynomial(1, 0, 1, 0) - - Polynomial(1, 0, 0, 1)), - - Polynomial(Polynomial(1, 1, 0, 0)), - - Polynomial(Polynomial(1, 0, 1, 0)), - - Polynomial(Polynomial(1, 0, 0, 1)) - }; - - - // Basis // - basis = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new vector<Polynomial>*[nFunction]; - - // Edge Based (Nedelec) // - for(size_t s = 0; s < nOrientation; s++){ - for(size_t e = 0; e < 6; e++){ - vector<Polynomial> tmp1 = lagrange[edgeIdx[s][e][1]].gradient(); - vector<Polynomial> tmp2 = lagrange[edgeIdx[s][e][0]].gradient(); - - tmp1[0].mul(lagrange[edgeIdx[s][e][0]]); - tmp1[1].mul(lagrange[edgeIdx[s][e][0]]); - tmp1[2].mul(lagrange[edgeIdx[s][e][0]]); - - tmp2[0].mul(lagrange[edgeIdx[s][e][1]]); - tmp2[1].mul(lagrange[edgeIdx[s][e][1]]); - tmp2[2].mul(lagrange[edgeIdx[s][e][1]]); - - tmp2[0].sub(tmp1[0]); - tmp2[1].sub(tmp1[1]); - tmp2[2].sub(tmp1[2]); - - basis[s][e] = new vector<Polynomial>(tmp2); - } - } -} - -TetNedelecBasis::~TetNedelecBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/TetNedelecBasis.h b/FunctionSpace/TetNedelecBasis.h deleted file mode 100644 index 79381974cf25612e12dfc1ac10475faa7a1517a0..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetNedelecBasis.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _TETNEDELECBASIS_H_ -#define _TETNEDELECBASIS_H_ - -#include "BasisHierarchical1Form.h" - -/** - @class TetNedelecBasis - @brief A Nedelec Basis for Tetrahedra - - This class can instantiate a Nedelec Basis for Tetrahedra. -*/ - -class TetNedelecBasis: public BasisHierarchical1Form{ - public: - //! Returns a new Nedelec Basis for Tetrahedra - //! - TetNedelecBasis(void); - - //! Deletes this Basis - //! - virtual ~TetNedelecBasis(void); -}; - -#endif diff --git a/FunctionSpace/TetNodeBasis.cpp b/FunctionSpace/TetNodeBasis.cpp deleted file mode 100644 index 9080b20e3944996e077d69420bf99bf5447c976d..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetNodeBasis.cpp +++ /dev/null @@ -1,170 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "TetNodeBasis.h" - -using namespace std; - -TetNodeBasis::TetNodeBasis(size_t order){ - // Set Basis Type // - this->order = order; - - type = TYPE_TET; - dim = 3; - - nVertex = 4; - nEdge = 6 * (order - 1); - nFace = 2 * (order - 1) * (order - 2); - nCell = (order - 1) * (order - 2) * (order - 3) / 6; - nFunction = nVertex + nEdge + nFace + nCell; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - const vector<vector<vector<size_t> > >& - faceIdx = ReferenceSpaceManager::getFaceNodeIndex(type); - - // Alloc Temporary Space // - const int orderMinus = order - 1; - const int orderMinusTwo = order - 2; - const int orderMinusThree = order - 3; - - Polynomial* legendre = new Polynomial[order]; - Polynomial* sclLegendre = new Polynomial[order]; - Polynomial* intLegendre = new Polynomial[order]; - - // Legendre Polynomial // - Legendre::legendre(legendre, orderMinus); - Legendre::scaled(sclLegendre, orderMinus); - Legendre::intScaled(intLegendre, order); - - // Lagrange Polynomial // - const Polynomial lagrange[4] = - { - Polynomial(Polynomial(1, 0, 0, 0) - - Polynomial(1, 1, 0, 0) - - Polynomial(1, 0, 1, 0) - - Polynomial(1, 0, 0, 1)), - - Polynomial(Polynomial(1, 1, 0, 0)), - - Polynomial(Polynomial(1, 0, 1, 0)), - - Polynomial(Polynomial(1, 0, 0, 1)) - }; - - - // Basis // - basis = new Polynomial**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new Polynomial*[nFunction]; - - // Vertex Based // - for(size_t s = 0; s < nOrientation; s++){ - basis[s][0] = new Polynomial(lagrange[0]); - basis[s][1] = new Polynomial(lagrange[1]); - basis[s][2] = new Polynomial(lagrange[2]); - basis[s][3] = new Polynomial(lagrange[3]); - } - - // Edge Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex; - - for(int e = 0; e < 6; e++){ - for(size_t l = 1; l < order; l++){ - basis[s][i] = - new Polynomial(intLegendre[l].compose - (lagrange[edgeIdx[s][e][1]] - - lagrange[edgeIdx[s][e][0]] - , - lagrange[edgeIdx[s][e][0]] + - lagrange[edgeIdx[s][e][1]])); - i++; - } - } - } - - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex + nEdge; - - for(int f = 0; f < 4; f++){ - for(int l1 = 1; l1 < orderMinus; l1++){ - for(int l2 = 0; l1 + l2 - 1 < orderMinusTwo; l2++){ - Polynomial sum = - lagrange[faceIdx[s][f][0]] + - lagrange[faceIdx[s][f][1]] + - lagrange[faceIdx[s][f][2]]; - - basis[s][i] = - new Polynomial(intLegendre[l1].compose - (lagrange[faceIdx[s][f][1]] - - lagrange[faceIdx[s][f][0]] - , - lagrange[faceIdx[s][f][0]] + - lagrange[faceIdx[s][f][1]]) - - * - - lagrange[faceIdx[s][f][2]] - * - sclLegendre[l2].compose - (lagrange[faceIdx[s][f][2]] * 2 - sum, sum)); - i++; - } - } - } - } - - // Cell Based // - const Polynomial oneMinusFour = Polynomial(1, 0, 0, 0) - lagrange[3]; - const Polynomial twoThreeOneMinusFour = lagrange[2] * 2 - oneMinusFour; - const Polynomial twoFourMinusOne = - lagrange[3] * 2 - Polynomial(1, 0, 0, 0); - - const Polynomial sub = lagrange[0] - lagrange[1]; - const Polynomial add = lagrange[0] + lagrange[1]; - - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex + nEdge + nFace; - - for(int l1 = 1; l1 < orderMinusTwo; l1++){ - for(int l2 = 0; l2 + l1 - 1 < orderMinusThree; l2++){ - for(int l3 = 0; l3 + l2 + l1 - 1 < orderMinusThree; l3++){ - basis[s][i] = - new Polynomial(intLegendre[l1].compose(sub, add) * - lagrange[2] * - sclLegendre[l2].compose(twoThreeOneMinusFour, - oneMinusFour) * - lagrange[3] * - legendre[l3].compose(twoFourMinusOne)); - i++; - } - } - } - } - - // Free Temporary Sapce // - delete[] legendre; - delete[] sclLegendre; - delete[] intLegendre; -} - -TetNodeBasis::~TetNodeBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/TetNodeBasis.h b/FunctionSpace/TetNodeBasis.h deleted file mode 100644 index 6aa732df7a1b8aa7bf9e8053d4ff1c168df34288..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetNodeBasis.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _TETNODEBASIS_H_ -#define _TETNODEBASIS_H_ - -#include "BasisHierarchical0Form.h" - -/** - @class TetNodeBasis - @brief A Node Basis for Tetrahedra - - This class can instantiate a Node-Based Basis - (high or low order) for Tetrahedra. - - It uses - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation.@n - */ - -class TetNodeBasis: public BasisHierarchical0Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Node-Basis for Tetrahedra of the given order - TetNodeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~TetNodeBasis(void); -}; - -#endif diff --git a/FunctionSpace/TetReferenceSpace.cpp b/FunctionSpace/TetReferenceSpace.cpp deleted file mode 100644 index 402d9104df9feed0af1cb70314c4e2a7c2e7c7df..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetReferenceSpace.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include <sstream> -#include "TetReferenceSpace.h" -#include "MTetrahedron.h" - -using namespace std; - -TetReferenceSpace::TetReferenceSpace(void){ - // Vertex Definition // - nVertex = 4; - - // Edge Definition // - const size_t nEdge = 6; - refEdgeNodeIdx.resize(nEdge); - - for(size_t i = 0; i < nEdge; i++){ - refEdgeNodeIdx[i].resize(2); // Two Nodes per Edge - refEdgeNodeIdx[i][0] = MTetrahedron::edges_tetra(i, 0); - refEdgeNodeIdx[i][1] = MTetrahedron::edges_tetra(i, 1); - } - - // Face Definition // - size_t nFace = 4; - refFaceNodeIdx.resize(nFace); - - for(size_t i = 0; i < nFace; i++){ - refFaceNodeIdx[i].resize(3); // Three Nodes per Face - refFaceNodeIdx[i][0] = MTetrahedron::faces_tetra(i, 0); - refFaceNodeIdx[i][1] = MTetrahedron::faces_tetra(i, 1); - refFaceNodeIdx[i][2] = MTetrahedron::faces_tetra(i, 2); - } - - // Init All // - init(); -} - -TetReferenceSpace::~TetReferenceSpace(void){ -} - -string TetReferenceSpace::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; - - return stream.str(); -} diff --git a/FunctionSpace/TetReferenceSpace.h b/FunctionSpace/TetReferenceSpace.h deleted file mode 100644 index cec36e26ad534d90a6eec4859492b293ad891da3..0000000000000000000000000000000000000000 --- a/FunctionSpace/TetReferenceSpace.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _TETREFERENCESPACE_H_ -#define _TETREFERENCESPACE_H_ - -#include <string> -#include "ReferenceSpace.h" - -/** - @class TetReferenceSpace - @brief ReferenceSpace for Tetrahedron - - This class implements a ReferenceSpace for a Tetrahedron. - */ - -class TetReferenceSpace: public ReferenceSpace{ - public: - TetReferenceSpace(void); - virtual ~TetReferenceSpace(void); - - virtual std::string toLatex(void) const; -}; - -/** - @fn TetReferenceSpace::TetReferenceSpace - Instatiate a new ReferenceSpace for a Tetrahedron - ** - - @fn TetReferenceSpace::~TetReferenceSpace - Deletes this TetReferenceSpace -*/ - -#endif diff --git a/FunctionSpace/TriEdgeBasis.cpp b/FunctionSpace/TriEdgeBasis.cpp deleted file mode 100644 index 6066dcd7e14398f708d8a91abe4024d0ea1f83d1..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriEdgeBasis.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "TriEdgeBasis.h" - -using namespace std; - -TriEdgeBasis::TriEdgeBasis(size_t order){ - // Set Basis Type // - this->order = order; - - type = TYPE_TRI; - dim = 2; - - nVertex = 0; - nEdge = 3 * (order + 1); - nFace = ((order - 1) * order + order - 1); - nCell = 0; - nFunction = nVertex + nEdge + nFace + nCell; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - const vector<vector<vector<size_t> > >& - faceIdx = ReferenceSpaceManager::getFaceNodeIndex(type); - - // Alloc Some Space // - const int orderPlus = order + 1; - const int orderMinus = order - 1; - - Polynomial* legendre = new Polynomial[orderPlus]; - Polynomial* intLegendre = new Polynomial[orderPlus]; - - // Legendre Polynomial // - Legendre::legendre(legendre, order); - Legendre::intScaled(intLegendre, orderPlus); - - // Lagrange // - const Polynomial lagrange[3] = - { - Polynomial(Polynomial(1, 0, 0, 0) - - Polynomial(1, 1, 0, 0) - - Polynomial(1, 0, 1, 0)), - - Polynomial(Polynomial(1, 1, 0, 0)), - - Polynomial(Polynomial(1, 0, 1, 0)) - }; - - // One // - Polynomial one(1, 0, 0, 0); - - // Basis // - basis = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new vector<Polynomial>*[nFunction]; - - // Edge Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = 0; - - for(int e = 0; e < 3; e++){ - for(int l = 0; l < orderPlus; l++){ - // Nedelec - if(l == 0){ - vector<Polynomial> tmp1 = lagrange[edgeIdx[s][e][1]].gradient(); - vector<Polynomial> tmp2 = lagrange[edgeIdx[s][e][0]].gradient(); - - tmp1[0].mul(lagrange[edgeIdx[s][e][0]]); - tmp1[1].mul(lagrange[edgeIdx[s][e][0]]); - tmp1[2].mul(lagrange[edgeIdx[s][e][0]]); - - tmp2[0].mul(lagrange[edgeIdx[s][e][1]]); - tmp2[1].mul(lagrange[edgeIdx[s][e][1]]); - tmp2[2].mul(lagrange[edgeIdx[s][e][1]]); - - tmp2[0].sub(tmp1[0]); - tmp2[1].sub(tmp1[1]); - tmp2[2].sub(tmp1[2]); - - basis[s][i] = new vector<Polynomial>(tmp2); - } - - // High Order - else{ - basis[s][i] = - new vector<Polynomial> - ((intLegendre[l].compose(lagrange[edgeIdx[s][e][0]] - - lagrange[edgeIdx[s][e][1]] - , - lagrange[edgeIdx[s][e][1]] + - lagrange[edgeIdx[s][e][0]])).gradient()); - } - i++; - } - } - } - - // Face Based // - - // NB: We use (*(*faceIdx[s])[f])[] - // where f = 0, because triangles - // have only ONE face: the face '0' - - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nEdge; - - for(size_t l1 = 1; l1 < order; l1++){ - for(int l2 = 0; l2 + (int)l1 - 1 < orderMinus; l2++){ - // Preliminary Type 1 - Polynomial u = - intLegendre[l1].compose(lagrange[faceIdx[s][0][1]] - - lagrange[faceIdx[s][0][0]] - , - lagrange[faceIdx[s][0][0]] + - lagrange[faceIdx[s][0][1]]); - Polynomial v = - lagrange[faceIdx[s][0][2]] * - legendre[l2].compose(lagrange[faceIdx[s][0][2]] * 2 - one); - - // Preliminary Type 2 - vector<Polynomial> gradU = u.gradient(); - vector<Polynomial> gradV = v.gradient(); - - vector<Polynomial> vGradU(gradU); - vGradU[0].mul(v); - vGradU[1].mul(v); - vGradU[2].mul(v); - - vector<Polynomial> uGradV(gradV); - uGradV[0].mul(u); - uGradV[1].mul(u); - uGradV[2].mul(u); - - vector<Polynomial> subGradUV(vGradU); - subGradUV[0].sub(uGradV[0]); - subGradUV[1].sub(uGradV[1]); - subGradUV[2].sub(uGradV[2]); - - // Preliminary Type 3 - vector<Polynomial> gradL1 = lagrange[faceIdx[s][0][0]].gradient(); - vector<Polynomial> gradL2 = lagrange[faceIdx[s][0][1]].gradient(); - - vector<Polynomial> l2GradL1(gradL1); - l2GradL1[0].mul(lagrange[faceIdx[s][0][1]]); - l2GradL1[1].mul(lagrange[faceIdx[s][0][1]]); - l2GradL1[2].mul(lagrange[faceIdx[s][0][1]]); - - vector<Polynomial> l1GradL2(gradL2); - l1GradL2[0].mul(lagrange[faceIdx[s][0][0]]); - l1GradL2[1].mul(lagrange[faceIdx[s][0][0]]); - l1GradL2[2].mul(lagrange[faceIdx[s][0][0]]); - - vector<Polynomial> subGradL1L2V(l2GradL1); - subGradL1L2V[0].sub(l1GradL2[0]); - subGradL1L2V[1].sub(l1GradL2[1]); - subGradL1L2V[2].sub(l1GradL2[2]); - - subGradL1L2V[0].mul(v); - subGradL1L2V[1].mul(v); - subGradL1L2V[2].mul(v); - - - // Type 1 - basis[s][i] = new vector<Polynomial>((u * v).gradient()); - i++; - - // Type 2 - basis[s][i] = new vector<Polynomial>(subGradUV); - i++; - - // Type 3 - if(l1 == 1){ - basis[s][i] = new vector<Polynomial>(subGradL1L2V); - i++; - } - } - } - } - - // Clear // - delete[] legendre; - delete[] intLegendre; -} - -TriEdgeBasis::~TriEdgeBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/TriEdgeBasis.h b/FunctionSpace/TriEdgeBasis.h deleted file mode 100644 index 77b6f76e37ae2593589a3f58b6ff81e70e9d27c6..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriEdgeBasis.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _TRIEDGEBASIS_H_ -#define _TRIEDGEBASIS_H_ - -#include "BasisHierarchical1Form.h" - -/** - @class TriEdgeBasis - @brief An Edge Basis for Triangles - - This class can instantiate an Edge-Based Basis - (high or low order) for Triangles. - - It uses - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation. -*/ - -class TriEdgeBasis: public BasisHierarchical1Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Edge-Basis for Triangles of the given order - TriEdgeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~TriEdgeBasis(void); -}; - -#endif diff --git a/FunctionSpace/TriLagrangeBasis.cpp b/FunctionSpace/TriLagrangeBasis.cpp deleted file mode 100644 index 96d16c7f1e294091a8ae8c954f820e1d0b46ac1b..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriLagrangeBasis.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "ElementType.h" -#include "GmshDefines.h" -#include "pointsGenerators.h" - -#include "TriLagrangeBasis.h" - -TriLagrangeBasis::TriLagrangeBasis(size_t order){ - // If order 0 (Nedelec): use order 1 - if(order == 0) - order = 1; - - // Set Basis Type // - this->order = order; - - type = TYPE_TRI; - dim = 2; - - nVertex = 3; - nEdge = 3 * (order - 1); - nFace = (order - 1) * (order - 2) / 2; - nCell = 0; - nFunction = nVertex + nEdge + nFace + nCell; - - // Init polynomialBasis // - lBasis = new polynomialBasis(ElementType::getTag(TYPE_TRI, order, false)); - - // Init Lagrange Point // - lPoint = new fullMatrix<double>(gmshGeneratePointsTriangle(order, false)); -} - -TriLagrangeBasis::~TriLagrangeBasis(void){ - delete lBasis; - delete lPoint; -} diff --git a/FunctionSpace/TriLagrangeBasis.h b/FunctionSpace/TriLagrangeBasis.h deleted file mode 100644 index 01ea8bed7ecb77517d3bd3970be63dec37a88405..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriLagrangeBasis.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _TRILAGRANGEBASIS_H_ -#define _TRILAGRANGEBASIS_H_ - -#include "BasisLagrange.h" - -/** - @class TriLagrangeBasis - @brief Lagrange Basis for Triangles - - This class can instantiate a Lagrange Basis - for a Triangle and for a given order. - - It uses - <a href="http://geuz.org/gmsh/">gmsh</a> Basis. - */ - -class TriLagrangeBasis: public BasisLagrange{ - public: - //! @param order A natural number - //! - //! Returns a new TriLagrangeBasis of the given order - TriLagrangeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~TriLagrangeBasis(void); -}; - -#endif diff --git a/FunctionSpace/TriNedelecBasis.cpp b/FunctionSpace/TriNedelecBasis.cpp deleted file mode 100644 index db87fb845d618c393b57afc34b8d7b47a8229fee..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriNedelecBasis.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "TriNedelecBasis.h" - -using namespace std; - -TriNedelecBasis::TriNedelecBasis(void){ - // Set Basis Type // - order = 0; - - type = TYPE_TRI; - dim = 2; - - nVertex = 0; - nEdge = 3; - nFace = 0; - nCell = 0; - nFunction = 3; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - // Lagrange // - const Polynomial lagrange[3] = - { - Polynomial(Polynomial(1, 0, 0, 0) - - Polynomial(1, 1, 0, 0) - - Polynomial(1, 0, 1, 0)), - - Polynomial(Polynomial(1, 1, 0, 0)), - - Polynomial(Polynomial(1, 0, 1, 0)) - }; - - // Basis // - basis = new vector<Polynomial>**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new vector<Polynomial>*[nFunction]; - - // Edge Based (Nedelec) // - for(size_t s = 0; s < nOrientation; s++){ - for(size_t e = 0; e < 3; e++){ - vector<Polynomial> tmp1 = lagrange[edgeIdx[s][e][1]].gradient(); - vector<Polynomial> tmp2 = lagrange[edgeIdx[s][e][0]].gradient(); - - tmp1[0].mul(lagrange[edgeIdx[s][e][0]]); - tmp1[1].mul(lagrange[edgeIdx[s][e][0]]); - tmp1[2].mul(lagrange[edgeIdx[s][e][0]]); - - tmp2[0].mul(lagrange[edgeIdx[s][e][1]]); - tmp2[1].mul(lagrange[edgeIdx[s][e][1]]); - tmp2[2].mul(lagrange[edgeIdx[s][e][1]]); - - tmp2[0].sub(tmp1[0]); - tmp2[1].sub(tmp1[1]); - tmp2[2].sub(tmp1[2]); - - basis[s][e] = new vector<Polynomial>(tmp2); - } - } -} - -TriNedelecBasis::~TriNedelecBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/TriNedelecBasis.h b/FunctionSpace/TriNedelecBasis.h deleted file mode 100644 index 1b94731a177145d759bc3a9d123eb5453f59d0f5..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriNedelecBasis.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _TRINEDELECBASIS_H_ -#define _TRINEDELECBASIS_H_ - -#include "BasisHierarchical1Form.h" - -/** - @class TriNedelecBasis - @brief Nedelec Basis for Triangles - - This class can instantiate a Nedelec Basis for Triangles. -*/ - -class TriNedelecBasis: public BasisHierarchical1Form{ - public: - //! Returns a new Nedelec Basis for Triangles - //! - TriNedelecBasis(void); - - //! Deletes this Basis - //! - virtual ~TriNedelecBasis(void); -}; - -#endif diff --git a/FunctionSpace/TriNodeBasis.cpp b/FunctionSpace/TriNodeBasis.cpp deleted file mode 100644 index 79e75c1708322730b367baa501f10bedf1caa6dc..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriNodeBasis.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "Legendre.h" -#include "GmshDefines.h" -#include "ReferenceSpaceManager.h" - -#include "TriNodeBasis.h" - -using namespace std; - -TriNodeBasis::TriNodeBasis(size_t order){ - // Set BasisTwo Type // - this->order = order; - - type = TYPE_TRI; - dim = 2; - - nVertex = 3; - nEdge = 3 * (order - 1); - nFace = (order - 1) * (order - 2) / 2; - nCell = 0; - nFunction = nVertex + nEdge + nFace + nCell; - - // Reference Space // - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - const vector<vector<vector<size_t> > >& - edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type); - - const vector<vector<vector<size_t> > >& - faceIdx = ReferenceSpaceManager::getFaceNodeIndex(type); - - // Legendre Polynomial // - const int orderMinus = order - 1; - - Polynomial* legendre = new Polynomial[order]; - Polynomial* intLegendre = new Polynomial[order]; - - Legendre::legendre(legendre, orderMinus); - Legendre::intScaled(intLegendre, order); - - // Lagrange Polynomial // - const Polynomial lagrange[3] = - { - Polynomial(Polynomial(1, 0, 0, 0) - - Polynomial(1, 1, 0, 0) - - Polynomial(1, 0, 1, 0)), - - Polynomial(Polynomial(1, 1, 0, 0)), - - Polynomial(Polynomial(1, 0, 1, 0)) - }; - - // Basis // - basis = new Polynomial**[nOrientation]; - - for(size_t s = 0; s < nOrientation; s++) - basis[s] = new Polynomial*[nFunction]; - - // Vertex Based // - for(size_t s = 0; s < nOrientation; s++){ - basis[s][0] = new Polynomial(lagrange[0]); - basis[s][1] = new Polynomial(lagrange[1]); - basis[s][2] = new Polynomial(lagrange[2]); - } - - // Edge Based // - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex; - - for(size_t e = 0; e < 3; e++){ - for(size_t l = 1; l < order; l++){ - basis[s][i] = - new Polynomial(intLegendre[l].compose(lagrange[edgeIdx[s][e][1]] - - lagrange[edgeIdx[s][e][0]] - , - lagrange[edgeIdx[s][e][0]] + - lagrange[edgeIdx[s][e][1]])); - i++; - } - } - } - - // Face Based // - - // NB: We use (*(*faceIdx[s])[f])[] - // where f = 0, because triangles - // have only ONE face: the face '0' - const int orderMinusTwo = order - 2; - - for(size_t s = 0; s < nOrientation; s++){ - size_t i = nVertex + nEdge; - - for(int l1 = 1; l1 < orderMinus; l1++){ - for(int l2 = 0; l2 + l1 - 1 < orderMinusTwo; l2++){ - basis[s][i] = - new Polynomial(intLegendre[l1].compose(lagrange[faceIdx[s][0][1]] - - lagrange[faceIdx[s][0][0]] - , - lagrange[faceIdx[s][0][0]] + - lagrange[faceIdx[s][0][1]]) - * - - legendre[l2].compose((lagrange[faceIdx[s][0][2]] * 2) - - - Polynomial(1, 0, 0, 0)) - * - - lagrange[faceIdx[s][0][2]]); - i++; - } - } - } - - // Free Temporary Sapce // - delete[] legendre; - delete[] intLegendre; -} - -TriNodeBasis::~TriNodeBasis(void){ - const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type); - - // Basis // - for(size_t i = 0; i < nOrientation; i++){ - for(size_t j = 0; j < nFunction; j++) - delete basis[i][j]; - - delete[] basis[i]; - } - - delete[] basis; -} diff --git a/FunctionSpace/TriNodeBasis.h b/FunctionSpace/TriNodeBasis.h deleted file mode 100644 index bcb9381f7c736bbae3a26dcea61e0580744dd007..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriNodeBasis.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _TRINODEBASIS_H_ -#define _TRINODEBASIS_H_ - -#include "BasisHierarchical0Form.h" - -/** - @class TriNodeBasis - @brief A Node Basis for Triangles - - This class can instantiate a Node-Based Basis - (high or low order) for Triangles. - - It uses - <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> - Basis for high order Polynomial%s generation. - */ - -class TriNodeBasis: public BasisHierarchical0Form{ - public: - //! @param order The order of the Basis - //! - //! Returns a new Node-Basis for Triangles of the given order - TriNodeBasis(size_t order); - - //! Deletes this Basis - //! - virtual ~TriNodeBasis(void); -}; - -#endif diff --git a/FunctionSpace/TriReferenceSpace.cpp b/FunctionSpace/TriReferenceSpace.cpp deleted file mode 100644 index 69ecc2c04b417764eaf4fb165b5e1a28ddd4e80c..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriReferenceSpace.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include <sstream> - -#include "TriReferenceSpace.h" -#include "MTriangle.h" - -using namespace std; - -TriReferenceSpace::TriReferenceSpace(void){ - // Vertex Definition // - nVertex = 3; - - // Edge Definition // - const size_t nEdge = 3; - refEdgeNodeIdx.resize(nEdge); - - for(size_t i = 0; i < nEdge; i++){ - refEdgeNodeIdx[i].resize(2); // Two Nodes per Edge - refEdgeNodeIdx[i][0] = MTriangle::edges_tri(i, 0); - refEdgeNodeIdx[i][1] = MTriangle::edges_tri(i, 1); - } - - // Face Definition // - refFaceNodeIdx.resize(1); // One Face per Triangle - refFaceNodeIdx[0].resize(3); // Three Nodes per Face - - refFaceNodeIdx[0][0] = 0; - refFaceNodeIdx[0][1] = 1; - refFaceNodeIdx[0][2] = 2; - - // Init All // - init(); -} - -TriReferenceSpace::~TriReferenceSpace(void){ -} - -string TriReferenceSpace::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 - << endl; - - for(size_t e = 0; e < 3; 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; - - return stream.str(); -} diff --git a/FunctionSpace/TriReferenceSpace.h b/FunctionSpace/TriReferenceSpace.h deleted file mode 100644 index 9f52b5d64eb9fe56dd5fff7e840c95d15bc77b25..0000000000000000000000000000000000000000 --- a/FunctionSpace/TriReferenceSpace.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _TRIREFERENCESPACE_H_ -#define _TRIREFERENCESPACE_H_ - -#include <string> -#include "ReferenceSpace.h" - -/** - @class TriReferenceSpace - @brief ReferenceSpace for a Triangle - - This class implements a ReferenceSpace for a Triangle. - */ - -class TriReferenceSpace: public ReferenceSpace{ - public: - TriReferenceSpace(void); - virtual ~TriReferenceSpace(void); - - virtual std::string toLatex(void) const; -}; - -/** - @fn TriReferenceSpace::TriReferenceSpace - Instatiate a new ReferenceSpace for a Triangle - ** - - @fn TriReferenceSpace::~TriReferenceSpace - Deletes this TriReferenceSpace -*/ - -#endif