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

Cleaning FunctionSpace: don't do Basis Job anymore

parent 36f63032
No related branches found
No related tags found
No related merge requests found
......@@ -6,10 +6,10 @@
/**
@class BasisGenerator
@brief A bunch of class method to generate a Basis
@brief A bunch of class method to generate a Local Basis
A BasisGenerator is a bunch of @em class
methods to generate a Basis.
methods to generate a Local Basis (BasisLocal).
@note
A BasisGenerator got @em only @em class @em methods,
......
......@@ -14,7 +14,10 @@ FunctionSpace::FunctionSpace(void){
FunctionSpace::~FunctionSpace(void){
// Basis //
delete localBasis;
for(unsigned int i = 0; i < nBasis; i++)
delete (*basis)[i];
delete basis;
// Dof //
if(dof){
......@@ -57,26 +60,27 @@ void FunctionSpace::build(const GroupOfElement& goe,
int nFace = myElement.getNumFaces();
// Init Struct //
type = basisType;
localBasis = BasisGenerator::generate(elementType,
nBasis = 1;
basis = new vector<const Basis*>(nBasis);
(*basis)[0] = BasisGenerator::generate(elementType,
basisType,
order, "hierarchical");
// Number of *Per* Entity functions //
fPerVertex = localBasis->getNVertexBased() / nVertex;
fPerVertex = (*basis)[0]->getNVertexBased() / nVertex;
// NB: fPreVertex = 0 *or* 1
if(nEdge)
fPerEdge = localBasis->getNEdgeBased() / nEdge;
fPerEdge = (*basis)[0]->getNEdgeBased() / nEdge;
else
fPerEdge = 0;
if(nFace)
fPerFace = localBasis->getNFaceBased() / nFace;
fPerFace = (*basis)[0]->getNFaceBased() / nFace;
else
fPerFace = 0;
fPerCell = localBasis->getNCellBased(); // We always got 1 cell
fPerCell = (*basis)[0]->getNCellBased(); // We always got 1 cell
// Build Dof //
buildDof();
......@@ -140,68 +144,60 @@ vector<Dof> FunctionSpace::getKeys(const MElement& elem) const{
MElement& element = const_cast<MElement&>(elem);
// Get Element Data //
const int nVertex = element.getNumPrimaryVertices();
const int nEdge = element.getNumEdges();
const int nFace = element.getNumFaces();
const unsigned int nVertex = element.getNumPrimaryVertices();
const unsigned int nEdge = element.getNumEdges();
const unsigned int nFace = element.getNumFaces();
vector<MVertex*> vertex(nVertex);
vector<MEdge> edge(nEdge);
vector<MFace> face(nFace);
for(int i = 0; i < nVertex; i++)
for(unsigned int i = 0; i < nVertex; i++)
vertex[i] = element.getVertex(i);
for(int i = 0; i < nEdge; i++)
for(unsigned int i = 0; i < nEdge; i++)
edge[i] = element.getEdge(i);
for(int i = 0; i < nFace; i++)
for(unsigned int i = 0; i < nFace; i++)
face[i] = element.getFace(i);
// Get FunctionSpace Data for this Element //
const int nFVertex = getNFunctionPerVertex(element);
const int nFEdge = getNFunctionPerEdge(element);
const int nFFace = getNFunctionPerFace(element);
const int nFCell = getNFunctionPerCell(element);
// Create Dof //
const int nDofVertex = nFVertex * nVertex;
const int nDofEdge = nFEdge * nEdge;
const int nDofFace = nFFace * nFace;
const int nDofCell = nFCell;
int nDof =
nDofVertex + nDofEdge + nDofFace + nDofCell;
unsigned int nDof =
fPerVertex * nVertex +
fPerEdge * nEdge +
fPerFace * nFace +
fPerCell;
vector<Dof> myDof(nDof);
int it = 0;
unsigned int it = 0;
// Add Vertex Based Dof //
for(int i = 0; i < nVertex; i++){
for(int j = 0; j < nFVertex; j++){
for(unsigned int i = 0; i < nVertex; i++){
for(unsigned int j = 0; j < fPerVertex; j++){
myDof[it].setDof(mesh->getGlobalId(*vertex[i]), j);
it++;
}
}
// Add Edge Based Dof //
for(int i = 0; i < nEdge; i++){
for(int j = 0; j < nFEdge; j++){
for(unsigned int i = 0; i < nEdge; i++){
for(unsigned int j = 0; j < fPerEdge; j++){
myDof[it].setDof(mesh->getGlobalId(edge[i]), j);
it++;
}
}
// Add Face Based Dof //
for(int i = 0; i < nFace; i++){
for(int j = 0; j < nFFace; j++){
for(unsigned int i = 0; i < nFace; i++){
for(unsigned int j = 0; j < fPerFace; j++){
myDof[it].setDof(mesh->getGlobalId(face[i]), j);
it++;
}
}
// Add Cell Based Dof //
for(int j = 0; j < nFCell; j++){
for(unsigned int j = 0; j < fPerCell; j++){
myDof[it].setDof(mesh->getGlobalId(element), j);
it++;
}
......
......@@ -4,7 +4,7 @@
#include <map>
#include <vector>
#include "BasisLocal.h"
#include "Basis.h"
#include "Comparators.h"
#include "Dof.h"
......@@ -44,12 +44,15 @@ class FunctionSpace{
const GroupOfElement* goe;
// Basis //
const BasisLocal* localBasis;
std::vector<const Basis*>* basis;
unsigned int nBasis;
unsigned int fPerVertex;
unsigned int fPerEdge;
unsigned int fPerFace;
unsigned int fPerCell;
unsigned int type;
// Scalar Field ? //
bool scalar;
// Dofs //
std::set<const Dof*, DofComparator>* dof;
......@@ -61,16 +64,14 @@ class FunctionSpace{
public:
virtual ~FunctionSpace(void);
const std::vector<const Basis*>& getBasis(const MElement& element) const;
const Basis& getBasis(unsigned int i) const;
unsigned int getNBasis(void) const;
const GroupOfElement& getSupport(void) const;
unsigned int getOrder(void) const;
unsigned int getType(void) const;
bool isScalar(void) const;
unsigned int getNFunctionPerVertex(const MElement& element) const;
unsigned int getNFunctionPerEdge(const MElement& element) const;
unsigned int getNFunctionPerFace(const MElement& element) const;
unsigned int getNFunctionPerCell(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;
......@@ -81,9 +82,6 @@ class FunctionSpace{
const GroupOfDof& getGoDFromElement(const MElement& element) const;
unsigned int getNOrientation(void) const;
unsigned int getOrientation(const MElement& element) const;
unsigned int dofNumber(void) const;
unsigned int groupNumber(void) const;
......@@ -116,47 +114,10 @@ class FunctionSpace{
FunctionSpace
**
@fn FunctionSpace::getOrder
@return Return the @em order
of this FunctionSpace
**
@fn FunctionSpace::getType
@return Return the @em type of
the Basis functions composing
this Function Space.
@see Basis::getType()
**
@fn FunctionSpace::isScalar
@return Returns:
@li @c true, if this FunstionSpace is scalar
@li @c flase, otherwise
@see Basis::isScalar()
**
@fn FunctionSpace::getNFunctionPerVertex
@param element A MElement of the support
@return Returns the number of @em Vertex Based
Basis Functions, defined on the given element
**
@fn FunctionSpace::getNFunctionPerEdge
@param element A MElement of the support
@return Returns the number of @em Edge Based
Basis Functions, defined on the given element
**
@fn FunctionSpace::getNFunctionPerFace
@param element A MElement of the support
@return Returns the number of @em Face Based
Basis Functions, defined on the given element
**
@fn FunctionSpace::getNFunctionPerCell
@param element A MElement of the support
@return Returns the number of @em Cell Based
Basis Functions, defined on the given element
**
@fn vector<Dof> FunctionSpace::getKeys(const MElement& element) const
......@@ -198,20 +159,6 @@ class FunctionSpace{
an Exception is thrown
**
@fn FunctionSpace::getNOrientation
@return Returns the number of
@em orientations of the
FunctionSpace reference space
@todo Multiple basis
**
@fn FunctionSpace::getOrientation
@param element A MElement
@return Returns a number charaterizing
the @em orientation of the given element
@todo Multiple basis
**
@fn FunctionSpace::dofNumber
@return Returns the number of Dof%s
given by FunctionSpace::getAllDofs()
......@@ -228,44 +175,30 @@ class FunctionSpace{
// Inline Functions //
//////////////////////
inline const GroupOfElement& FunctionSpace::getSupport(void) const{
return *goe;
}
inline unsigned int FunctionSpace::getOrder(void) const{
return (unsigned int)(localBasis->getOrder());
inline const std::vector<const Basis*>&
FunctionSpace::getBasis(const MElement& element) const{
return *basis;
}
inline unsigned int FunctionSpace::getType(void) const{
return type;
}
inline bool FunctionSpace::isScalar(void) const{
return localBasis->isScalar();
inline const Basis& FunctionSpace::getBasis(unsigned int i) const{
return *(*basis)[i];
}
inline unsigned int FunctionSpace::getNFunctionPerVertex(const MElement& element) const{
return fPerVertex;
inline unsigned int FunctionSpace::getNBasis(void) const{
return nBasis;
}
inline unsigned int FunctionSpace::getNFunctionPerEdge(const MElement& element) const{
return fPerEdge;
}
inline unsigned int FunctionSpace::getNFunctionPerFace(const MElement& element) const{
return fPerFace;
}
inline unsigned int FunctionSpace::getNFunctionPerCell(const MElement& element) const{
return fPerCell;
inline const GroupOfElement& FunctionSpace::getSupport(void) const{
return *goe;
}
inline unsigned int FunctionSpace::getNOrientation(void) const{
return localBasis->getNOrientation();
#include "Exception.h"
inline unsigned int FunctionSpace::getOrder(void) const{
throw Exception("Remove me!");
return (unsigned int)((*basis)[0]->getOrder());
}
inline unsigned int FunctionSpace::getOrientation(const MElement& element) const{
return localBasis->getOrientation(element);
inline bool FunctionSpace::isScalar(void) const{
return scalar;
}
inline unsigned int FunctionSpace::dofNumber(void) const{
......
......@@ -36,7 +36,7 @@ interpolate(const MElement& element,
// Get Basis Functions //
fullMatrix<double>* fun =
localBasis->getFunctions(element, uvw[0], uvw[1], uvw[2]);
(*basis)[0]->getFunctions(element, uvw[0], uvw[1], uvw[2]);
const unsigned int nFun = fun->size1();
......@@ -73,7 +73,7 @@ interpolateInRefSpace(const MElement& element,
// Get Basis Functions //
fullMatrix<double>* fun =
localBasis->getFunctions(element, uvw(0), uvw(1), uvw(2));
(*basis)[0]->getFunctions(element, uvw(0), uvw(1), uvw(2));
const unsigned int nFun = fun->size1();
......
......@@ -31,7 +31,7 @@ interpolate(const MElement& element,
// Get Basis Functions //
fullMatrix<double>* fun =
localBasis->getFunctions(element, uvw[0], uvw[1], uvw[2]);
(*basis)[0]->getFunctions(element, uvw[0], uvw[1], uvw[2]);
const unsigned int nFun = fun->size1();
......@@ -53,7 +53,7 @@ interpolateInRefSpace(const MElement& element,
// Get Basis Functions //
fullMatrix<double>* fun =
localBasis->getFunctions(element, uvw(0), uvw(1), uvw(2));
(*basis)[0]->getFunctions(element, uvw(0), uvw(1), uvw(2));
const unsigned int nFun = fun->size1();
......
#include "FunctionSpaceScalar.h"
FunctionSpaceScalar::FunctionSpaceScalar(void){
scalar = true;
}
FunctionSpaceScalar::~FunctionSpaceScalar(void){
......
#ifndef _FUNCTIONSPACESCALAR_H_
#define _FUNCTIONSPACESCALAR_H_
#include "Exception.h"
#include "FunctionSpace.h"
/**
......@@ -35,21 +34,6 @@ class FunctionSpaceScalar : public FunctionSpace{
const std::vector<double>& coef,
const fullVector<double>& uvw) const = 0;
void preEvaluateLocalFunctions(const fullMatrix<double>& point) const;
void preEvaluateGradLocalFunctions(const fullMatrix<double>& point) const;
const fullMatrix<double>&
getEvaluatedLocalFunctions(const MElement& element) const;
const fullMatrix<double>&
getEvaluatedGradLocalFunctions(const MElement& element) const;
const fullMatrix<double>&
getEvaluatedLocalFunctions(unsigned int orientation) const;
const fullMatrix<double>&
getEvaluatedGradLocalFunctions(unsigned int orientation) const;
protected:
FunctionSpaceScalar(void);
};
......@@ -96,124 +80,6 @@ class FunctionSpaceScalar : public FunctionSpace{
If the given coordinate are not in the given
@c element @em Bad @em Things may happend
---> check
**
@fn FunctionSpaceScalar::preEvaluateLocalFunctions
@param point A set of @c 3D Points
Precomputes the Local Functions of this FunctionSpace
at the given Points.
@note Each row of @c point is a new Point,
and each column is a coordinate (for a total of
3 columns)
**
@fn FunctionSpaceScalar::preEvaluateGradLocalFunctions
@param point A set of @c 3D Points
Precomputes the @em Gradient of the Local Functions
of this FunctionSpace at the given Points.
@note Each row of @c point is a new Point,
and each column is a coordinate (for a total of
3 columns)
**
@fn FunctionSpaceScalar::getEvaluatedLocalFunctions(const MElement&) const
@param element A MElement
@return Returns the @em values of the @em precomputed
Basis Functions associated
to the given element (with correct @em closure)
@note
The returned values @em must be computed by
FunctionSpaceScalar::preEvaluateLocalFunctions(),
if not an Exception will be thrown
**
@fn FunctionSpaceScalar::getEvaluatedGradLocalFunctions(const MElement&) const
@param element A MElement
@return Returns the @em values of the @em precomputed
@em Gradients of the Basis Functions associated
to the given element (with correct @em closure)
@note
The returned values @em must be computed by
FunctionSpaceScalar::preEvaluateGradLocalFunctions(),
if not an Exception will be thrown
**
@fn FunctionSpaceScalar::getEvaluatedLocalFunctions(unsigned int) const
@param orientation A number definig the orientation of the reference space
@return Same as
FunctionSpaceScalar::getEvaluatedLocalFunctions(const MElement&) const
but the orientation is not given by en element but by a number (@c orientation)
**
@fn FunctionSpaceScalar::getEvaluatedGradLocalFunctions(unsigned int) const
@param orientation A number definig the orientation of the reference space
@return Same as
FunctionSpaceScalar::getEvaluatedGradLocalFunctions(const MElement&) const
but the orientation is not given by en element but by a number (@c orientation)
*/
//////////////////////
// Inline Functions //
//////////////////////
inline void FunctionSpaceScalar::
preEvaluateLocalFunctions(const fullMatrix<double>& point) const{
localBasis->preEvaluateFunctions(point);
}
inline void FunctionSpaceScalar::
preEvaluateGradLocalFunctions(const fullMatrix<double>& point) const{
localBasis->preEvaluateDerivatives(point);
}
inline const fullMatrix<double>&
FunctionSpaceScalar::getEvaluatedLocalFunctions(const MElement& element) const{
try{
return localBasis->getPreEvaluatedFunctions(element);
}
catch(Exception& any){
throw Exception("Local Basis Functions not PreEvaluated");
}
}
inline const fullMatrix<double>&
FunctionSpaceScalar::getEvaluatedGradLocalFunctions(const MElement& element) const{
try{
return localBasis->getPreEvaluatedDerivatives(element);
}
catch(Exception& any){
throw Exception("Gradient of Local Basis Functions not PreEvaluated");
}
}
inline const fullMatrix<double>&
FunctionSpaceScalar::getEvaluatedLocalFunctions(unsigned int orientation) const{
try{
return localBasis->getPreEvaluatedFunctions(orientation);
}
catch(Exception& any){
throw Exception("Local Basis Functions not PreEvaluated");
}
}
inline const fullMatrix<double>&
FunctionSpaceScalar::getEvaluatedGradLocalFunctions(unsigned int orientation) const{
try{
return localBasis->getPreEvaluatedDerivatives(orientation);
}
catch(Exception& any){
throw Exception("Gradient of Local Basis Functions not PreEvaluated");
}
}
#endif
#include "FunctionSpaceVector.h"
FunctionSpaceVector::FunctionSpaceVector(void){
scalar = false;
}
FunctionSpaceVector::~FunctionSpaceVector(void){
......
......@@ -35,28 +35,6 @@ class FunctionSpaceVector : public FunctionSpace{
const std::vector<double>& coef,
const fullVector<double>& uvw) const = 0;
void preEvaluateLocalFunctions(const fullMatrix<double>& point) const;
void preEvaluateCurlLocalFunctions(const fullMatrix<double>& point) const;
void preEvaluateDivLocalFunctions(const fullMatrix<double>& point) const;
const fullMatrix<double>&
getEvaluatedLocalFunctions(const MElement& element) const;
const fullMatrix<double>&
getEvaluatedCurlLocalFunctions(const MElement& element) const;
const fullMatrix<double>&
getEvaluatedDivLocalFunctions(const MElement& element) const;
const fullMatrix<double>&
getEvaluatedLocalFunctions(unsigned int orientation) const;
const fullMatrix<double>&
getEvaluatedCurlLocalFunctions(unsigned int orientation) const;
const fullMatrix<double>&
getEvaluatedDivLocalFunctions(unsigned int orientation) const;
protected:
FunctionSpaceVector(void);
};
......@@ -103,181 +81,6 @@ class FunctionSpaceVector : public FunctionSpace{
If the given coordinate are not in the given
@c element @em Bad @em Things may happend
---> check
**
@fn FunctionSpaceVector::preEvaluateLocalFunctions
@param point A set of @c 3D Points
Precomputes the Local Functions of this FunctionSpace
at the given Points.
@note Each row of @c point is a new Point,
and each column is a coordinate (for a total of
3 columns)
**
@fn FunctionSpaceVector::preEvaluateCurlLocalFunctions
@param point A set of @c 3D Points
Precomputes the @em Curl of the Local Functions
of this FunctionSpace at the given Points.
@note Each row of @c point is a new Point,
and each column is a coordinate (for a total of
3 columns)
**
@fn FunctionSpaceVector::preEvaluateDivLocalFunctions
@param point A set of @c 3D Points
Precomputes the @em Divergence of the Local Functions
of this FunctionSpace at the given Points.
@note Each row of @c point is a new Point,
and each column is a coordinate (for a total of
3 columns)
**
@fn FunctionSpaceVector::getEvaluatedLocalFunctions(const MElement&) const
@param element A MElement
@return Returns the @em values of the @em precomputed
Basis Functions associated
to the given element (with correct @em closure)
@note
The returned values @em must be computed by
FunctionSpaceVector::preEvaluateLocalFunctions(),
if not an Exception will be thrown
**
@fn FunctionSpaceVector::getEvaluatedCurlLocalFunctions(const MElement&) const
@param element A MElement
@return Returns the @em values of the @em precomputed
@em Curls of the Basis Functions associated
to the given element (with correct @em closure)
@note
The returned values @em must be computed by
FunctionSpaceVector::preEvaluateCurlLocalFunctions(),
if not an Exception will be thrown
**
@fn FunctionSpaceVector::getEvaluatedDivLocalFunctions(const MElement&) const
@param element A MElement
@return Returns the @em values of the @em precomputed
@em Divergences of the Basis Functions associated
to the given element (with correct @em closure)
@note
The returned values @em must be computed by
FunctionSpaceVector::preEvaluateDivLocalFunctions(),
if not an Exception will be thrown
**
@fn FunctionSpaceVector::getEvaluatedLocalFunctions(unsigned int) const
@param orientation A number definig the orientation of the reference space
@return Same as
FunctionSpaceVector::getEvaluatedLocalFunctions(const MElement&) const
but the orientation is not given by en element but by a number (@c orientation)
**
@fn FunctionSpaceVector::getEvaluatedCurlLocalFunctions(unsigned int) const
@param orientation A number definig the orientation of the reference space
@return Same as
FunctionSpaceVector::getEvaluatedCurlLocalFunctions(const MElement&) const
but the orientation is not given by en element but by a number (@c orientation)
**
@fn FunctionSpaceVector::getEvaluatedDivLocalFunctions(unsigned int) const
@param orientation A number definig the orientation of the reference space
@return Same as
FunctionSpaceVector::getEvaluatedDivLocalFunctions(const MElement&) const
but the orientation is not given by en element but by a number (@c orientation)
*/
//////////////////////
// Inline Functions //
//////////////////////
inline void FunctionSpaceVector::
preEvaluateLocalFunctions(const fullMatrix<double>& point) const{
localBasis->preEvaluateFunctions(point);
}
inline void FunctionSpaceVector::
preEvaluateCurlLocalFunctions(const fullMatrix<double>& point) const{
localBasis->preEvaluateDerivatives(point);
}
inline void FunctionSpaceVector::
preEvaluateDivLocalFunctions(const fullMatrix<double>& point) const{
localBasis->preEvaluateDerivatives(point);
}
inline const fullMatrix<double>&
FunctionSpaceVector::getEvaluatedLocalFunctions(const MElement& element) const{
try{
return localBasis->getPreEvaluatedFunctions(element);
}
catch(Exception& any){
throw Exception("Local Basis Functions not PreEvaluated");
}
}
inline const fullMatrix<double>&
FunctionSpaceVector::getEvaluatedCurlLocalFunctions(const MElement& element) const{
try{
return localBasis->getPreEvaluatedDerivatives(element);
}
catch(Exception& any){
throw Exception("Curl of Local Basis Functions not PreEvaluated");
}
}
inline const fullMatrix<double>&
FunctionSpaceVector::getEvaluatedDivLocalFunctions(const MElement& element) const{
try{
return localBasis->getPreEvaluatedFunctions(element);
}
catch(Exception& any){
throw Exception("Divergence of Local Basis Functions not PreEvaluated");
}
}
inline const fullMatrix<double>&
FunctionSpaceVector::getEvaluatedLocalFunctions(unsigned int orientation) const{
try{
return localBasis->getPreEvaluatedFunctions(orientation);
}
catch(Exception& any){
throw Exception("Local Basis Functions not PreEvaluated");
}
}
inline const fullMatrix<double>&
FunctionSpaceVector::getEvaluatedCurlLocalFunctions(unsigned int orientation) const{
try{
return localBasis->getPreEvaluatedDerivatives(orientation);
}
catch(Exception& any){
throw Exception("Curl of Local Basis Functions not PreEvaluated");
}
}
inline const fullMatrix<double>&
FunctionSpaceVector::getEvaluatedDivLocalFunctions(unsigned int orientation) const{
try{
return localBasis->getPreEvaluatedFunctions(orientation);
}
catch(Exception& any){
throw Exception("Divergence of Local Basis Functions not PreEvaluated");
}
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment