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

Remove getGoDFromElement -- Use getKeys instead + Preparing FunctionSpace for multiple basis

parent 9284469a
No related branches found
No related tags found
No related merge requests found
...@@ -13,10 +13,8 @@ FunctionSpace::FunctionSpace(void){ ...@@ -13,10 +13,8 @@ FunctionSpace::FunctionSpace(void){
} }
FunctionSpace::~FunctionSpace(void){ FunctionSpace::~FunctionSpace(void){
// Delete Vector of Basis // // Delete Vector of Basis
// (FunctionSpace is not responsible for // (FunctionSpace is not responsible for 'true' Basis Deletion)
// 'true' Basis Deletion)
delete basis;
} }
void FunctionSpace::build(GroupOfElement& goe, void FunctionSpace::build(GroupOfElement& goe,
...@@ -36,26 +34,30 @@ void FunctionSpace::build(GroupOfElement& goe, ...@@ -36,26 +34,30 @@ void FunctionSpace::build(GroupOfElement& goe,
int nFace = myElement.getNumFaces(); int nFace = myElement.getNumFaces();
// Init Struct // // Init Struct //
this->nBasis = 1; this->basis.resize(1);
this->basis = new vector<const Basis*>(nBasis); this->basis[0] = &basis;
(*this->basis)[0] = &basis;
// Number of *Per* Entity functions // // Number of *Per* Entity functions //
fPerVertex = (*this->basis)[0]->getNVertexBased() / nVertex; // Init
// NB: fPreVertex = 0 *or* 1 fPerVertex.resize(1);
fPerEdge.resize(1);
fPerFace.resize(1);
fPerCell.resize(1);
// Populate
fPerVertex[0] = this->basis[0]->getNVertexBased() / nVertex;
if(nEdge) if(nEdge)
fPerEdge = (*this->basis)[0]->getNEdgeBased() / nEdge; fPerEdge[0] = this->basis[0]->getNEdgeBased() / nEdge;
else else
fPerEdge = 0; fPerEdge[0] = 0;
if(nFace) if(nFace)
fPerFace = (*this->basis)[0]->getNFaceBased() / nFace; fPerFace[0] = this->basis[0]->getNFaceBased() / nFace;
else else
fPerFace = 0; fPerFace[0] = 0;
fPerCell = (*this->basis)[0]->getNCellBased(); fPerCell[0] = this->basis[0]->getNCellBased();
// We always got 1 cell
// Build Dof // // Build Dof //
buildDof(); buildDof();
...@@ -79,12 +81,8 @@ void FunctionSpace::buildDof(void){ ...@@ -79,12 +81,8 @@ void FunctionSpace::buildDof(void){
for(size_t j = 0; j < nDof; j++) for(size_t j = 0; j < nDof; j++)
dof.insert(myDof[j]); dof.insert(myDof[j]);
// Save vectorCreate new GroupOfDof // Save vector
group[i] = myDof; group[i] = myDof;
// Map GOD
eToGod.insert
(pair<const MElement*, const vector<Dof>*>(element[i], &group[i]));
} }
} }
...@@ -119,10 +117,10 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{ ...@@ -119,10 +117,10 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{
// Create Dof // // Create Dof //
size_t nDof = size_t nDof =
fPerVertex * nVertex + fPerVertex[0] * nVertex +
fPerEdge * nEdge + fPerEdge[0] * nEdge +
fPerFace * nFace + fPerFace[0] * nFace +
fPerCell * nCell; fPerCell[0] * nCell;
vector<Dof> myDof(nDof); vector<Dof> myDof(nDof);
...@@ -130,7 +128,7 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{ ...@@ -130,7 +128,7 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{
// Add Vertex Based Dof // // Add Vertex Based Dof //
for(size_t i = 0; i < nVertex; i++){ for(size_t i = 0; i < nVertex; i++){
for(size_t j = 0; j < fPerVertex; j++){ for(size_t j = 0; j < fPerVertex[0]; j++){
myDof[it].setDof(mesh->getGlobalId(*vertex[i]), j); myDof[it].setDof(mesh->getGlobalId(*vertex[i]), j);
it++; it++;
} }
...@@ -138,7 +136,7 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{ ...@@ -138,7 +136,7 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{
// Add Edge Based Dof // // Add Edge Based Dof //
for(size_t i = 0; i < nEdge; i++){ for(size_t i = 0; i < nEdge; i++){
for(size_t j = 0; j < fPerEdge; j++){ for(size_t j = 0; j < fPerEdge[0]; j++){
myDof[it].setDof(mesh->getGlobalId(edge[i]), j); myDof[it].setDof(mesh->getGlobalId(edge[i]), j);
it++; it++;
} }
...@@ -146,7 +144,7 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{ ...@@ -146,7 +144,7 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{
// Add Face Based Dof // // Add Face Based Dof //
for(size_t i = 0; i < nFace; i++){ for(size_t i = 0; i < nFace; i++){
for(size_t j = 0; j < fPerFace; j++){ for(size_t j = 0; j < fPerFace[0]; j++){
myDof[it].setDof(mesh->getGlobalId(face[i]), j); myDof[it].setDof(mesh->getGlobalId(face[i]), j);
it++; it++;
} }
...@@ -154,7 +152,7 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{ ...@@ -154,7 +152,7 @@ vector<Dof> FunctionSpace::getUnorderedKeys(const MElement& elem) const{
// Add Cell Based Dof // // Add Cell Based Dof //
for(size_t i = 0; i < nCell; i++){ for(size_t i = 0; i < nCell; i++){
for(size_t j = 0; j < fPerCell; j++){ for(size_t j = 0; j < fPerCell[0]; j++){
myDof[it].setDof(mesh->getGlobalId(element), j); myDof[it].setDof(mesh->getGlobalId(element), j);
it++; it++;
} }
...@@ -211,19 +209,3 @@ void FunctionSpace::getKeys(const GroupOfElement& goe, ...@@ -211,19 +209,3 @@ void FunctionSpace::getKeys(const GroupOfElement& goe,
dof.insert(myDof[d]); dof.insert(myDof[d]);
} }
} }
const std::vector<Dof>& FunctionSpace::
getGoDFromElement(const MElement& element) const{
const map<const MElement*,
const std::vector<Dof>*,
ElementComparator>::const_iterator it = eToGod.find(&element);
if(it == eToGod.end())
throw
Exception("Their is no GroupOfDof associated with the given MElement: %d",
element.getNum());
else
return *(it->second);
}
...@@ -4,18 +4,11 @@ ...@@ -4,18 +4,11 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include "Basis.h"
#include "Comparators.h"
#include "Dof.h" #include "Dof.h"
#include "Mesh.h" #include "Mesh.h"
#include "GroupOfElement.h" #include "Basis.h"
#include "MElement.h" #include "MElement.h"
#include "MVertex.h" #include "GroupOfElement.h"
#include "MEdge.h"
#include "MFace.h"
/** /**
@interface FunctionSpace @interface FunctionSpace
...@@ -29,11 +22,10 @@ ...@@ -29,11 +22,10 @@
Those MElement%s must belong to the same Mesh. Those MElement%s must belong to the same Mesh.
A FunctionSpace is also responsible for the generation of all A FunctionSpace is also responsible for the generation of all
the Dof%s and GroupOfDof%s related to its geometrical Support. the Dof%s related to its geometrical Support.
@todo @todo
Allow Hybrid Mesh Allow Hybrid Mesh
Remove call to GroupOfElement::orientAllElements()
*/ */
class Mesh; class Mesh;
...@@ -46,12 +38,11 @@ class FunctionSpace{ ...@@ -46,12 +38,11 @@ class FunctionSpace{
GroupOfElement* goe; GroupOfElement* goe;
// Basis // // Basis //
std::vector<const Basis*>* basis; std::vector<const Basis*> basis;
size_t nBasis; std::vector<size_t> fPerVertex;
size_t fPerVertex; std::vector<size_t> fPerEdge;
size_t fPerEdge; std::vector<size_t> fPerFace;
size_t fPerFace; std::vector<size_t> fPerCell;
size_t fPerCell;
// Scalar Field ? // // Scalar Field ? //
bool scalar; bool scalar;
...@@ -59,33 +50,24 @@ class FunctionSpace{ ...@@ -59,33 +50,24 @@ class FunctionSpace{
// Dofs // // Dofs //
std::set<Dof> dof; std::set<Dof> dof;
std::vector<std::vector<Dof> > group; std::vector<std::vector<Dof> > group;
std::map<
const MElement*,
const std::vector<Dof>*, ElementComparator> eToGod;
public: public:
virtual ~FunctionSpace(void); virtual ~FunctionSpace(void);
const std::vector<const Basis*>& getBasis(const MElement& element) const; const std::vector<const Basis*>& getBasis(const MElement& element) const;
const Basis& getBasis(size_t i) const; const Basis& getBasis(size_t i) const;
size_t getNBasis(void) const;
GroupOfElement& getSupport(void) const; GroupOfElement& getSupport(void) const;
bool isScalar(void) const; bool isScalar(void) const;
std::vector<Dof> getUnorderedKeys(const MElement& element) const; std::vector<Dof> getUnorderedKeys(const MElement& element) const;
std::vector<Dof> getKeys(const MElement& element) const; std::vector<Dof> getKeys(const MElement& element) const;
std::vector<Dof> getKeys(const MVertex& vertex) const;
std::vector<Dof> getKeys(const MEdge& edge) const;
std::vector<Dof> getKeys(const MFace& face) const;
void getKeys(const GroupOfElement& goe, std::set<Dof>& dof) const; void getKeys(const GroupOfElement& goe, std::set<Dof>& dof) const;
const std::set<Dof>& getAllDofs(void) const; const std::set<Dof>& getAllDofs(void) const;
const std::vector<std::vector<Dof> >& getAllGroups(void) const; const std::vector<std::vector<Dof> >& getAllGroups(void) const;
const std::vector<Dof>& getGoDFromElement(const MElement& element) const;
protected: protected:
FunctionSpace(void); FunctionSpace(void);
...@@ -142,28 +124,8 @@ class FunctionSpace{ ...@@ -142,28 +124,8 @@ class FunctionSpace{
** **
@fn FunctionSpace::getAllGroups @fn FunctionSpace::getAllGroups
@return Returns all the GroupOfDof%s associated to every Element%s @return Returns all the Dof%s associated to every Element%s
of this FunctionSpace support of this FunctionSpace support
**
@fn FunctionSpace::getGoDFromElement
@param element An Element of the FunctionSpace Support
@return Returns the GroupOfDof%s associated to
the given Element
If the given Element is not in the FunctionSpace Support,
an Exception is thrown
**
@fn FunctionSpace::dofNumber
@return Returns the number of Dof%s
given by FunctionSpace::getAllDofs()
**
@fn FunctionSpace::groupNumber
@return Returns the number of GroupOfDof%s
given by FunctionSpace::getAllGroups()
**
*/ */
...@@ -173,15 +135,11 @@ class FunctionSpace{ ...@@ -173,15 +135,11 @@ class FunctionSpace{
inline const std::vector<const Basis*>& inline const std::vector<const Basis*>&
FunctionSpace::getBasis(const MElement& element) const{ FunctionSpace::getBasis(const MElement& element) const{
return *basis; return basis;
} }
inline const Basis& FunctionSpace::getBasis(size_t i) const{ inline const Basis& FunctionSpace::getBasis(size_t i) const{
return *(*basis)[i]; return *basis[i];
}
inline size_t FunctionSpace::getNBasis(void) const{
return nBasis;
} }
inline GroupOfElement& FunctionSpace::getSupport(void) const{ inline GroupOfElement& FunctionSpace::getSupport(void) const{
......
...@@ -17,10 +17,10 @@ interpolateInABC(const MElement& element, ...@@ -17,10 +17,10 @@ interpolateInABC(const MElement& element,
double abc[3]) const{ double abc[3]) const{
// Get Basis Functions // // Get Basis Functions //
const size_t nFun = (*basis)[0]->getNFunction(); const size_t nFun = basis[0]->getNFunction();
fullMatrix<double> fun(nFun, 1); fullMatrix<double> fun(nFun, 1);
(*basis)[0]->getFunctions(fun, element, abc[0], abc[1], abc[2]); basis[0]->getFunctions(fun, element, abc[0], abc[1], abc[2]);
// Interpolate (in Reference Place) // // Interpolate (in Reference Place) //
double val = 0; double val = 0;
...@@ -42,10 +42,10 @@ interpolateDerivativeInABC(const MElement& element, ...@@ -42,10 +42,10 @@ interpolateDerivativeInABC(const MElement& element,
invJac.invertInPlace(); invJac.invertInPlace();
// Get Basis Functions // // Get Basis Functions //
const size_t nFun = (*basis)[0]->getNFunction(); const size_t nFun = basis[0]->getNFunction();
fullMatrix<double> fun(nFun, 3); fullMatrix<double> fun(nFun, 3);
(*basis)[0]->getDerivative(fun, element, abc[0], abc[1], abc[2]); basis[0]->getDerivative(fun, element, abc[0], abc[1], abc[2]);
// Interpolate (in Reference Place) // // Interpolate (in Reference Place) //
fullMatrix<double> val(1, 3); fullMatrix<double> val(1, 3);
......
...@@ -22,10 +22,10 @@ interpolateInABC(const MElement& element, ...@@ -22,10 +22,10 @@ interpolateInABC(const MElement& element,
invJac.invertInPlace(); invJac.invertInPlace();
// Get Basis Functions // // Get Basis Functions //
const size_t nFun = (*basis)[0]->getNFunction(); const size_t nFun = basis[0]->getNFunction();
fullMatrix<double> fun(nFun, 3); fullMatrix<double> fun(nFun, 3);
(*basis)[0]->getFunctions(fun, element, abc[0], abc[1], abc[2]); basis[0]->getFunctions(fun, element, abc[0], abc[1], abc[2]);
// Interpolate (in Reference Place) // // Interpolate (in Reference Place) //
fullMatrix<double> val(1, 3); fullMatrix<double> val(1, 3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment