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

FunctionSpace & Formulation rework: FunctionSpace are now defined outside Formulation

parent 6d85e05e
No related branches found
No related tags found
No related merge requests found
...@@ -15,64 +15,9 @@ FunctionSpace::FunctionSpace(void){ ...@@ -15,64 +15,9 @@ FunctionSpace::FunctionSpace(void){
} }
FunctionSpace::~FunctionSpace(void){ FunctionSpace::~FunctionSpace(void){
if(self) for(size_t i = 0; i < nGeoType; i++)
for(size_t i = 0; i < nGeoType; i++) if(basis[i])
if(basis[i]) delete basis[i];
delete basis[i];
}
void FunctionSpace::build(GroupOfElement& goe,
const Basis& basis){
// Save GroupOfElement & Mesh //
this->goe = &goe;
this->mesh = &(goe.getMesh());
// Check if homogene GoE and get geo type //
const vector<size_t>& gType = goe.getTypeStats();
const size_t nGType = gType.size();
size_t eType = (size_t)(-1);
for(size_t i = 0; i < nGType; i++)
if((eType == (size_t)(-1)) && (gType[i] != 0))
eType = i;
else if((eType != (size_t)(-1)) && (gType[i] != 0))
throw Exception("FunctionSpace needs a uniform mesh");
// Check if basis is matching type //
if(eType != basis.getType())
throw Exception("FunctionSpace: Basis is not matching type");
// Alloc Bases and save given Basis //
this->self = false;
this->basis.resize(nGeoType, NULL);
this->basis[eType] = &basis;
// Get Number of Function per Entity //
// Same for all basis since we have a uniform order
MElement& myElement = const_cast<MElement&>(goe.get(0));
int nVertex = myElement.getNumPrimaryVertices();
int nEdge = myElement.getNumEdges();
int nFace = myElement.getNumFaces();
// Number of *Per* Entity functions //
fPerVertex = this->basis[eType]->getNVertexBased() / nVertex;
if(nEdge)
fPerEdge = this->basis[eType]->getNEdgeBased() / nEdge;
else
fPerEdge = 0;
if(nFace)
fPerFace = this->basis[eType]->getNFaceBased() / nFace;
else
fPerFace = 0;
fPerCell = this->basis[eType]->getNCellBased();
// Build Dof //
buildDof();
} }
void FunctionSpace::build(GroupOfElement& goe, void FunctionSpace::build(GroupOfElement& goe,
...@@ -83,7 +28,6 @@ void FunctionSpace::build(GroupOfElement& goe, ...@@ -83,7 +28,6 @@ void FunctionSpace::build(GroupOfElement& goe,
this->mesh = &(goe.getMesh()); this->mesh = &(goe.getMesh());
// Alloc Basis Vector for all possible geomtrical types // // Alloc Basis Vector for all possible geomtrical types //
self = true;
basis.resize(nGeoType, NULL); basis.resize(nGeoType, NULL);
// Generate Bases // // Generate Bases //
......
...@@ -39,7 +39,6 @@ class FunctionSpace{ ...@@ -39,7 +39,6 @@ class FunctionSpace{
GroupOfElement* goe; GroupOfElement* goe;
// Basis // // Basis //
bool self;
std::vector<const Basis*> basis; std::vector<const Basis*> basis;
size_t fPerVertex; size_t fPerVertex;
...@@ -73,8 +72,6 @@ class FunctionSpace{ ...@@ -73,8 +72,6 @@ class FunctionSpace{
protected: protected:
FunctionSpace(void); FunctionSpace(void);
void build(GroupOfElement& goe, const Basis& basis);
void build(GroupOfElement& goe, void build(GroupOfElement& goe,
size_t order, size_t form, std::string family); size_t order, size_t form, std::string family);
void buildDof(void); void buildDof(void);
......
#include "Mapper.h" #include "Mapper.h"
#include "FunctionSpaceScalar.h" #include "FunctionSpaceScalar.h"
FunctionSpaceScalar::FunctionSpaceScalar(GroupOfElement& goe, FunctionSpaceScalar::FunctionSpaceScalar(GroupOfElement& goe, size_t order){
const Basis& basis){
scalar = true; scalar = true;
build(goe, basis); build(goe, order, 0, "hierarchical");
} }
FunctionSpaceScalar::FunctionSpaceScalar(GroupOfElement& goe, size_t order){ FunctionSpaceScalar::FunctionSpaceScalar(GroupOfElement& goe, size_t order,
std::string family){
scalar = true; scalar = true;
build(goe, order, 0, "hierarchical"); build(goe, order, 0, family);
} }
FunctionSpaceScalar::~FunctionSpaceScalar(void){ FunctionSpaceScalar::~FunctionSpaceScalar(void){
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
class FunctionSpaceScalar : public FunctionSpace{ class FunctionSpaceScalar : public FunctionSpace{
public: public:
FunctionSpaceScalar(GroupOfElement& goe, const Basis& basis);
FunctionSpaceScalar(GroupOfElement& goe, size_t order); FunctionSpaceScalar(GroupOfElement& goe, size_t order);
FunctionSpaceScalar(GroupOfElement& goe, size_t order, std::string family);
virtual ~FunctionSpaceScalar(void); virtual ~FunctionSpaceScalar(void);
......
#include "Mapper.h" #include "Mapper.h"
#include "FunctionSpaceVector.h" #include "FunctionSpaceVector.h"
FunctionSpaceVector::FunctionSpaceVector(GroupOfElement& goe, FunctionSpaceVector::FunctionSpaceVector(GroupOfElement& goe, size_t order){
const Basis& basis){
scalar = false; scalar = false;
build(goe, basis); build(goe, order, 1, "hierarchical");
}
FunctionSpaceVector::FunctionSpaceVector(GroupOfElement& goe, size_t order,
std::string family){
scalar = false;
build(goe, order, 1, family);
} }
FunctionSpaceVector::~FunctionSpaceVector(void){ FunctionSpaceVector::~FunctionSpaceVector(void){
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
class FunctionSpaceVector : public FunctionSpace{ class FunctionSpaceVector : public FunctionSpace{
public: public:
FunctionSpaceVector(GroupOfElement& goe, const Basis& basis); FunctionSpaceVector(GroupOfElement& goe, size_t order);
FunctionSpaceVector(GroupOfElement& goe, size_t order, std::string family);
virtual ~FunctionSpaceVector(void); virtual ~FunctionSpaceVector(void);
fullVector<double> fullVector<double>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment