Skip to content
Snippets Groups Projects
Commit d26697cd authored by Nicolas Marsic's avatar Nicolas Marsic
Browse files

DofManager & FunctionSpace cleaning

parent 1d57728b
No related branches found
No related tags found
No related merge requests found
...@@ -4,24 +4,22 @@ ...@@ -4,24 +4,22 @@
using namespace std; using namespace std;
FunctionSpace::FunctionSpace(const GroupOfElement& goe, int basisType, int order){ FunctionSpace::FunctionSpace(const GroupOfElement& goe, int basisType, int order){
// DofManager //
dofM = NULL;
// Save GroupOfElement // // Save GroupOfElement //
this->goe = &goe; this->goe = &goe;
// Look for 1st element to get element type // // Get Geo Data (WARNING HOMOGENE MESH REQUIRED)//
// (We suppose only one type of Mesh !!) // MElement& element = goe.get(0);
int elementType = goe.get(0).getType(); int elementType = element.getType();
int nVertex = element.getNumVertices();
int nEdge = element.getNumEdges();
int nFace = element.getNumFaces();
nTotVertex = goe.getNVertex();
// Init Struct // // Init Struct //
type = basisType; type = basisType;
basis = BasisGenerator::generate(elementType, basisType, order); basis = BasisGenerator::generate(elementType,
basisType,
// Count Function per Entity // order);
int nVertex = goe.get(0).getNumVertices();
int nEdge = goe.get(0).getNumEdges();
int nFace = goe.get(0).getNumFaces();
fPerVertex = basis->getNVertexBased() / nVertex; fPerVertex = basis->getNVertexBased() / nVertex;
// NB: fPreVertex = 0 *or* 1 // NB: fPreVertex = 0 *or* 1
...@@ -39,10 +37,11 @@ FunctionSpace::FunctionSpace(const GroupOfElement& goe, int basisType, int order ...@@ -39,10 +37,11 @@ FunctionSpace::FunctionSpace(const GroupOfElement& goe, int basisType, int order
fPerCell = basis->getNCellBased(); // We always got 1 cell fPerCell = basis->getNCellBased(); // We always got 1 cell
} }
const vector<Dof*> FunctionSpace::getKeys(const MElement& elem) const{ FunctionSpace::~FunctionSpace(void){
// nTotVertex delete basis;
int nTotVertex = goe->getNVertex(); }
vector<Dof> FunctionSpace::getKeys(const MElement& elem) const{
// Const_Cast // // Const_Cast //
MElement& element = const_cast<MElement&>(elem); MElement& element = const_cast<MElement&>(elem);
...@@ -79,56 +78,21 @@ const vector<Dof*> FunctionSpace::getKeys(const MElement& elem) const{ ...@@ -79,56 +78,21 @@ const vector<Dof*> FunctionSpace::getKeys(const MElement& elem) const{
int nDof = int nDof =
nDofVertex + nDofEdge + nDofFace + nDofCell; nDofVertex + nDofEdge + nDofFace + nDofCell;
vector<Dof*> myDof(nDof); vector<Dof> myDof(nDof);
int it = 0; int it = 0;
// Add Vertex Based Dof // // Add Vertex Based Dof //
for(int i = 0; i < nVertex; i++){ 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++){ for(int j = 0; j < nFVertex; j++){
myDof[it] = new Dof(id, j); myDof[it].setDof(vertex[i]->getNum(), 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);
it++; 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; return myDof;
} }
FunctionSpace::~FunctionSpace(void){
delete basis;
}
/* /*
#include "Polynomial.h" #include "Polynomial.h"
#include "BasisScalar.h" #include "BasisScalar.h"
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
#include <vector> #include <vector>
#include "Basis.h" #include "Basis.h"
#include "Dof.h"
#include "GroupOfElement.h" #include "GroupOfElement.h"
#include "MElement.h" #include "MElement.h"
#include "Dof.h" #include "MVertex.h"
#include "DofManager.h" #include "MEdge.h"
#include "MFace.h"
/** /**
@class FunctionSpace @class FunctionSpace
...@@ -19,22 +21,18 @@ ...@@ -19,22 +21,18 @@
Hybrid Mesh@n Hybrid Mesh@n
*/ */
class ElementComparator;
class DofManager;
class FunctionSpace{ class FunctionSpace{
protected: protected:
const Basis* basis; const Basis* basis;
const GroupOfElement* goe;
const DofManager* dofM;
int fPerVertex; int fPerVertex;
int fPerEdge; int fPerEdge;
int fPerFace; int fPerFace;
int fPerCell; int fPerCell;
int type; int type;
const GroupOfElement* goe;
int nTotVertex;
public: public:
FunctionSpace(const GroupOfElement& goe, FunctionSpace(const GroupOfElement& goe,
int basisType, int order); int basisType, int order);
...@@ -45,14 +43,16 @@ class FunctionSpace{ ...@@ -45,14 +43,16 @@ class FunctionSpace{
const Basis& getBasis(const MElement& element) const; const Basis& getBasis(const MElement& element) const;
int getType(void) 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 getNFunctionPerVertex(const MElement& element) const;
int getNFunctionPerEdge(const MElement& element) const; int getNFunctionPerEdge(const MElement& element) const;
int getNFunctionPerFace(const MElement& element) const; int getNFunctionPerFace(const MElement& element) const;
int getNFunctionPerCell(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, void interpolateAtNodes(const MElement& element,
const std::vector<double>& coef, const std::vector<double>& coef,
...@@ -76,10 +76,6 @@ inline int FunctionSpace::getType(void) const{ ...@@ -76,10 +76,6 @@ inline int FunctionSpace::getType(void) const{
return type; return type;
} }
inline void FunctionSpace::associate(const DofManager& dofM){
this->dofM = &dofM;
}
inline int FunctionSpace::getNFunctionPerVertex(const MElement& element) const{ inline int FunctionSpace::getNFunctionPerVertex(const MElement& element) const{
return fPerVertex; return fPerVertex;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment