diff --git a/FunctionSpace/FunctionSpace.cpp b/FunctionSpace/FunctionSpace.cpp index 62340ec4051c4883e6fa487b1bea9b559f0382a5..92721d39917a71d2e9e0bfb87f882d3a27306017 100644 --- a/FunctionSpace/FunctionSpace.cpp +++ b/FunctionSpace/FunctionSpace.cpp @@ -4,24 +4,22 @@ using namespace std; FunctionSpace::FunctionSpace(const GroupOfElement& goe, int basisType, int order){ - // DofManager // - dofM = NULL; - // Save GroupOfElement // this->goe = &goe; - // Look for 1st element to get element type // - // (We suppose only one type of Mesh !!) // - int elementType = goe.get(0).getType(); + // Get Geo Data (WARNING HOMOGENE MESH REQUIRED)// + MElement& element = goe.get(0); + int elementType = element.getType(); + int nVertex = element.getNumVertices(); + int nEdge = element.getNumEdges(); + int nFace = element.getNumFaces(); + nTotVertex = goe.getNVertex(); // Init Struct // - type = basisType; - basis = BasisGenerator::generate(elementType, basisType, order); - - // Count Function per Entity // - int nVertex = goe.get(0).getNumVertices(); - int nEdge = goe.get(0).getNumEdges(); - int nFace = goe.get(0).getNumFaces(); + type = basisType; + basis = BasisGenerator::generate(elementType, + basisType, + order); fPerVertex = basis->getNVertexBased() / nVertex; // NB: fPreVertex = 0 *or* 1 @@ -39,10 +37,11 @@ FunctionSpace::FunctionSpace(const GroupOfElement& goe, int basisType, int order fPerCell = basis->getNCellBased(); // We always got 1 cell } -const vector<Dof*> FunctionSpace::getKeys(const MElement& elem) const{ - // nTotVertex - int nTotVertex = goe->getNVertex(); +FunctionSpace::~FunctionSpace(void){ + delete basis; +} +vector<Dof> FunctionSpace::getKeys(const MElement& elem) const{ // Const_Cast // MElement& element = const_cast<MElement&>(elem); @@ -79,56 +78,21 @@ const vector<Dof*> FunctionSpace::getKeys(const MElement& elem) const{ int nDof = nDofVertex + nDofEdge + nDofFace + nDofCell; - vector<Dof*> myDof(nDof); + vector<Dof> myDof(nDof); int it = 0; // Add Vertex Based Dof // for(int i = 0; i < nVertex; i++){ - // Get Id of Vertex - const int id = vertex[i]->getNum(); - - // New Dof for(int j = 0; j < nFVertex; j++){ - myDof[it] = new Dof(id, j); - it++; - } - } - - // Add Edge Based Dof // - for(int i = 0; i < nEdge; i++){ - // Get Id of Edge - MVertex* vEdge0 = edge[i].getSortedVertex(0); - MVertex* vEdge1 = edge[i].getSortedVertex(1); - - const int id = - vEdge0->getNum() + - vEdge1->getNum() * nTotVertex; - - // Insert new Dof - for(int j = 0; j < nFEdge; j++){ - myDof[it] = new Dof(id, j); + myDof[it].setDof(vertex[i]->getNum(), j); it++; } - } - - // Add Cell Based Dof // - // Get Id of Cell - const int id = element.getNum() * nTotVertex * nTotVertex; - - // Insert new Dof - for(int j = 0; j < nFCell; j++){ - myDof[it] = new Dof(id, j); - it++; } return myDof; } -FunctionSpace::~FunctionSpace(void){ - delete basis; -} - /* #include "Polynomial.h" #include "BasisScalar.h" diff --git a/FunctionSpace/FunctionSpace.h b/FunctionSpace/FunctionSpace.h index 27ff74a4e420396ed70e8180d0f1ec75b4da9b63..1298ebfd097199505b78b1da2ddf5be9a6b990ec 100644 --- a/FunctionSpace/FunctionSpace.h +++ b/FunctionSpace/FunctionSpace.h @@ -4,10 +4,12 @@ #include <vector> #include "Basis.h" +#include "Dof.h" #include "GroupOfElement.h" #include "MElement.h" -#include "Dof.h" -#include "DofManager.h" +#include "MVertex.h" +#include "MEdge.h" +#include "MFace.h" /** @class FunctionSpace @@ -19,22 +21,18 @@ Hybrid Mesh@n */ -class ElementComparator; -class DofManager; - class FunctionSpace{ protected: - const Basis* basis; - const GroupOfElement* goe; - const DofManager* dofM; - + const Basis* basis; int fPerVertex; int fPerEdge; int fPerFace; int fPerCell; - int type; + const GroupOfElement* goe; + int nTotVertex; + public: FunctionSpace(const GroupOfElement& goe, int basisType, int order); @@ -45,14 +43,16 @@ class FunctionSpace{ const Basis& getBasis(const MElement& element) const; int getType(void) const; - void associate(const DofManager& dofM); - const std::vector<Dof*> getKeys(const MElement& element) const; - int getNFunctionPerVertex(const MElement& element) const; int getNFunctionPerEdge(const MElement& element) const; int getNFunctionPerFace(const MElement& element) const; int getNFunctionPerCell(const MElement& element) const; + std::vector<Dof> getKeys(const MElement& element) const; + std::vector<Dof> getKeys(const MVertex& element) const; + std::vector<Dof> getKeys(const MEdge& element) const; + std::vector<Dof> getKeys(const MFace& element) const; + /* void interpolateAtNodes(const MElement& element, const std::vector<double>& coef, @@ -76,10 +76,6 @@ inline int FunctionSpace::getType(void) const{ return type; } -inline void FunctionSpace::associate(const DofManager& dofM){ - this->dofM = &dofM; -} - inline int FunctionSpace::getNFunctionPerVertex(const MElement& element) const{ return fPerVertex; }