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

BasisLagrange::projection -- BasisGenerator: zaglmayr family becomes...

BasisLagrange::projection -- BasisGenerator: zaglmayr family becomes hierarchical family + Lagrange works again
parent 4ecd5284
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "TriNodeBasis.h" #include "TriNodeBasis.h"
#include "TriEdgeBasis.h" #include "TriEdgeBasis.h"
#include "TriNedelecBasis.h" #include "TriNedelecBasis.h"
//#include "TriLagrangeBasis.h" #include "TriLagrangeBasis.h"
#include "TetNodeBasis.h" #include "TetNodeBasis.h"
#include "TetEdgeBasis.h" #include "TetEdgeBasis.h"
...@@ -32,31 +32,31 @@ Basis* BasisGenerator::generate(unsigned int elementType, ...@@ -32,31 +32,31 @@ Basis* BasisGenerator::generate(unsigned int elementType,
unsigned int order, unsigned int order,
std::string family){ std::string family){
if(!family.compare(std::string("zaglmayr"))) if(!family.compare(std::string("hierarchical")))
return generateZaglmayr(elementType, basisType, order); return generateHierarchical(elementType, basisType, order);
/*
else if(!family.compare(std::string("lagrange"))) else if(!family.compare(std::string("lagrange")))
return generateLagrange(elementType, basisType, order); return generateLagrange(elementType, basisType, order);
*/
else else
throw Exception("Unknwown Basis Family: %s", family.c_str()); throw Exception("Unknwown Basis Family: %s", family.c_str());
} }
Basis* BasisGenerator::generateZaglmayr(unsigned int elementType, Basis* BasisGenerator::generateHierarchical(unsigned int elementType,
unsigned int basisType, unsigned int basisType,
unsigned int order){ unsigned int order){
switch(elementType){ switch(elementType){
case TYPE_LIN: return linZaglmayrGen(basisType, order); case TYPE_LIN: return linHierarchicalGen(basisType, order);
case TYPE_TRI: return triZaglmayrGen(basisType, order); case TYPE_TRI: return triHierarchicalGen(basisType, order);
case TYPE_QUA: return quaZaglmayrGen(basisType, order); case TYPE_QUA: return quaHierarchicalGen(basisType, order);
case TYPE_TET: return tetZaglmayrGen(basisType, order); case TYPE_TET: return tetHierarchicalGen(basisType, order);
case TYPE_HEX: return hexZaglmayrGen(basisType, order); case TYPE_HEX: return hexHierarchicalGen(basisType, order);
default: throw Exception("Unknown Element Type (%d) for Basis Generation", default: throw Exception("Unknown Element Type (%d) for Basis Generation",
elementType); elementType);
} }
} }
/*
Basis* BasisGenerator::generateLagrange(unsigned int elementType, Basis* BasisGenerator::generateLagrange(unsigned int elementType,
unsigned int basisType, unsigned int basisType,
unsigned int order){ unsigned int order){
...@@ -76,9 +76,9 @@ Basis* BasisGenerator::generateLagrange(unsigned int elementType, ...@@ -76,9 +76,9 @@ Basis* BasisGenerator::generateLagrange(unsigned int elementType,
elementType); elementType);
} }
} }
*/
Basis* BasisGenerator::linZaglmayrGen(unsigned int basisType, Basis* BasisGenerator::linHierarchicalGen(unsigned int basisType,
unsigned int order){ unsigned int order){
switch(basisType){ switch(basisType){
case 0: return new LineNodeBasis(order); case 0: return new LineNodeBasis(order);
case 1: case 1:
...@@ -92,8 +92,8 @@ Basis* BasisGenerator::linZaglmayrGen(unsigned int basisType, ...@@ -92,8 +92,8 @@ Basis* BasisGenerator::linZaglmayrGen(unsigned int basisType,
} }
} }
Basis* BasisGenerator::triZaglmayrGen(unsigned int basisType, Basis* BasisGenerator::triHierarchicalGen(unsigned int basisType,
unsigned int order){ unsigned int order){
switch(basisType){ switch(basisType){
case 0: return new TriNodeBasis(order); case 0: return new TriNodeBasis(order);
case 1: case 1:
...@@ -107,8 +107,8 @@ Basis* BasisGenerator::triZaglmayrGen(unsigned int basisType, ...@@ -107,8 +107,8 @@ Basis* BasisGenerator::triZaglmayrGen(unsigned int basisType,
} }
} }
Basis* BasisGenerator::quaZaglmayrGen(unsigned int basisType, Basis* BasisGenerator::quaHierarchicalGen(unsigned int basisType,
unsigned int order){ unsigned int order){
switch(basisType){ switch(basisType){
//case 0: return new QuadNodeBasis(order); //case 0: return new QuadNodeBasis(order);
//case 1: return new QuadEdgeBasis(order); //case 1: return new QuadEdgeBasis(order);
...@@ -119,8 +119,8 @@ Basis* BasisGenerator::quaZaglmayrGen(unsigned int basisType, ...@@ -119,8 +119,8 @@ Basis* BasisGenerator::quaZaglmayrGen(unsigned int basisType,
} }
} }
Basis* BasisGenerator::tetZaglmayrGen(unsigned int basisType, Basis* BasisGenerator::tetHierarchicalGen(unsigned int basisType,
unsigned int order){ unsigned int order){
switch(basisType){ switch(basisType){
case 0: return new TetNodeBasis(order); case 0: return new TetNodeBasis(order);
case 1: return new TetEdgeBasis(order); case 1: return new TetEdgeBasis(order);
...@@ -131,8 +131,8 @@ Basis* BasisGenerator::tetZaglmayrGen(unsigned int basisType, ...@@ -131,8 +131,8 @@ Basis* BasisGenerator::tetZaglmayrGen(unsigned int basisType,
} }
} }
Basis* BasisGenerator::hexZaglmayrGen(unsigned int basisType, Basis* BasisGenerator::hexHierarchicalGen(unsigned int basisType,
unsigned int order){ unsigned int order){
switch(basisType){ switch(basisType){
//case 0: return new HexNodeBasis(order); //case 0: return new HexNodeBasis(order);
//case 1: return new HexEdgeBasis(order); //case 1: return new HexEdgeBasis(order);
......
...@@ -30,21 +30,20 @@ class BasisGenerator{ ...@@ -30,21 +30,20 @@ class BasisGenerator{
unsigned int basisType, unsigned int basisType,
unsigned int order); unsigned int order);
static Basis* linZaglmayrGen(unsigned int basisType, unsigned int order); static Basis* linHierarchicalGen(unsigned int basisType, unsigned int order);
static Basis* triZaglmayrGen(unsigned int basisType, unsigned int order); static Basis* triHierarchicalGen(unsigned int basisType, unsigned int order);
static Basis* quaZaglmayrGen(unsigned int basisType, unsigned int order); static Basis* quaHierarchicalGen(unsigned int basisType, unsigned int order);
static Basis* tetZaglmayrGen(unsigned int basisType, unsigned int order); static Basis* tetHierarchicalGen(unsigned int basisType, unsigned int order);
static Basis* hexZaglmayrGen(unsigned int basisType, unsigned int order); static Basis* hexHierarchicalGen(unsigned int basisType, unsigned int order);
private: private:
static Basis* generateZaglmayr(unsigned int elementType, static Basis* generateHierarchical(unsigned int elementType,
unsigned int basisType, unsigned int basisType,
unsigned int order); unsigned int order);
/*
static Basis* generateLagrange(unsigned int elementType, static Basis* generateLagrange(unsigned int elementType,
unsigned int basisType, unsigned int basisType,
unsigned int order); unsigned int order);
*/
}; };
...@@ -88,7 +87,7 @@ class BasisGenerator{ ...@@ -88,7 +87,7 @@ class BasisGenerator{
@li @c 3 for 3-Form @li @c 3 for 3-Form
@note Families are: @note Families are:
@li @c zaglmayr for @li @c hierarchical for
<a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a> <a href="http://www.hpfem.jku.at/publications/szthesis.pdf">Zaglmayr's</a>
Basis Functions Basis Functions
@li @c lagrange for Lagrange's Basis Functions @li @c lagrange for Lagrange's Basis Functions
...@@ -101,13 +100,13 @@ class BasisGenerator{ ...@@ -101,13 +100,13 @@ class BasisGenerator{
@param order The order or the requested Basis @param order The order or the requested Basis
Same as Same as
BasisGenerator::generate(@c elementType, @c basisType, @c order, @c zaglmayr) BasisGenerator::generate(@c elementType, @c basisType, @c order, @c hierarchical)
@return Returns a @em pointer to a newly @return Returns a @em pointer to a newly
@em instantiated Basis @em instantiated Basis
** **
@fn BasisGenerator::linZaglmayrGen @fn BasisGenerator::linHierarchicalGen
@param basisType The Basis type @param basisType The Basis type
@param order The order or the requested Basis @param order The order or the requested Basis
...@@ -123,10 +122,10 @@ class BasisGenerator{ ...@@ -123,10 +122,10 @@ class BasisGenerator{
@li @c 2 for 2-Form @li @c 2 for 2-Form
@li @c 3 for 3-Form @li @c 3 for 3-Form
@note The Basis family will be @c zaglmayr @note The Basis family will be @c hierarchical
** **
@fn BasisGenerator::triZaglmayrGen @fn BasisGenerator::triHierarchicalGen
@param basisType The Basis type @param basisType The Basis type
@param order The order or the requested Basis @param order The order or the requested Basis
...@@ -142,10 +141,10 @@ class BasisGenerator{ ...@@ -142,10 +141,10 @@ class BasisGenerator{
@li @c 2 for 2-Form @li @c 2 for 2-Form
@li @c 3 for 3-Form @li @c 3 for 3-Form
@note The Basis family will be @c zaglmayr @note The Basis family will be @c hierarchical
** **
@fn BasisGenerator::quaZaglmayrGen @fn BasisGenerator::quaHierarchicalGen
@param basisType The Basis type @param basisType The Basis type
@param order The order or the requested Basis @param order The order or the requested Basis
...@@ -161,10 +160,10 @@ class BasisGenerator{ ...@@ -161,10 +160,10 @@ class BasisGenerator{
@li @c 2 for 2-Form @li @c 2 for 2-Form
@li @c 3 for 3-Form @li @c 3 for 3-Form
@note The Basis family will be @c zaglmayr @note The Basis family will be @c hierarchical
** **
@fn BasisGenerator::tetZaglmayrGen @fn BasisGenerator::tetHierarchicalGen
@param basisType The Basis type @param basisType The Basis type
@param order The order or the requested Basis @param order The order or the requested Basis
...@@ -180,10 +179,10 @@ class BasisGenerator{ ...@@ -180,10 +179,10 @@ class BasisGenerator{
@li @c 2 for 2-Form @li @c 2 for 2-Form
@li @c 3 for 3-Form @li @c 3 for 3-Form
@note The Basis family will be @c zaglmayr @note The Basis family will be @c hierarchical
** **
@fn BasisGenerator::hexZaglmayrGen @fn BasisGenerator::hexHierarchicalGen
@param basisType The Basis type @param basisType The Basis type
@param order The order or the requested Basis @param order The order or the requested Basis
...@@ -199,7 +198,7 @@ class BasisGenerator{ ...@@ -199,7 +198,7 @@ class BasisGenerator{
@li @c 2 for 2-Form @li @c 2 for 2-Form
@li @c 3 for 3-Form @li @c 3 for 3-Form
@note The Basis family will be @c zaglmayr @note The Basis family will be @c hierarchical
** **
*/ */
...@@ -214,7 +213,7 @@ inline Basis* BasisGenerator::generate(unsigned int elementType, ...@@ -214,7 +213,7 @@ inline Basis* BasisGenerator::generate(unsigned int elementType,
return BasisGenerator::generate(elementType, return BasisGenerator::generate(elementType,
basisType, basisType,
order, order,
"zaglmayr"); "hierarchical");
} }
#endif #endif
...@@ -25,7 +25,7 @@ fullMatrix<double>* BasisLagrange::getFunctions(unsigned int permutation, ...@@ -25,7 +25,7 @@ fullMatrix<double>* BasisLagrange::getFunctions(unsigned int permutation,
point(0, 1) = v; point(0, 1) = v;
point(0, 2) = w; point(0, 2) = w;
basis->f(point, tmp); lBasis->f(point, tmp);
*values = tmp.transpose(); // Otherwise not coherent with df !! *values = tmp.transpose(); // Otherwise not coherent with df !!
...@@ -48,3 +48,53 @@ const fullMatrix<double>& ...@@ -48,3 +48,53 @@ const fullMatrix<double>&
BasisLagrange::getPreEvaluatedGradFunctions(const MElement& element) const{ BasisLagrange::getPreEvaluatedGradFunctions(const MElement& element) const{
return fullMatrix<double>(nFunction, 1); return fullMatrix<double>(nFunction, 1);
} }
std::vector<double> BasisLagrange::
project(const MElement& element,
const std::vector<double>& coef,
const FunctionSpaceScalar& fSpace){
// Init New Coefs //
const unsigned int size = lPoint->size1();
std::vector<double> newCoef(size);
// Interpolation at Lagrange Points //
for(unsigned int i = 0; i < size; i++){
fullVector<double> uvw(3);
uvw(0) = (*lPoint)(i, 0);
uvw(1) = (*lPoint)(i, 1);
uvw(2) = (*lPoint)(i, 2);
newCoef[i] = fSpace.interpolateInRefSpace(element,
coef,
uvw);
}
// Return ;
return newCoef;
}
std::vector<fullVector<double> > BasisLagrange::
project(const MElement& element,
const std::vector<double>& coef,
const FunctionSpaceVector& fSpace){
// Init New Coefs //
const unsigned int size = lPoint->size1();
std::vector<fullVector<double> > newCoef(size);
// Interpolation at Lagrange Points //
for(unsigned int i = 0; i < size; i++){
fullVector<double> uvw(3);
uvw(0) = (*lPoint)(i, 0);
uvw(1) = (*lPoint)(i, 1);
uvw(2) = (*lPoint)(i, 2);
newCoef[i] = fSpace.interpolateInRefSpace(element,
coef,
uvw);
}
// Return ;
return newCoef;
}
...@@ -2,11 +2,31 @@ ...@@ -2,11 +2,31 @@
#define _BASISLAGRANGE_H_ #define _BASISLAGRANGE_H_
#include "BasisScalar.h" #include "BasisScalar.h"
#include "FunctionSpaceScalar.h"
#include "FunctionSpaceVector.h"
#include "fullMatrix.h"
#include "polynomialBasis.h" #include "polynomialBasis.h"
/**
@interface BasisLagrange
@brief Interface for Lagrange Basis
This is an interface for Lagrange Basis.@n
These Scalar Basis allow a @em Coefficient Matrix,
and a Monomial Matrix, to be consulted.@n
A vector from an Other Basis (set of Functions)
can also be projected into a Lagrange Basis.@n
@todo
Add a method to get lagrange Point in polynomialBasis
*/
class BasisLagrange: public BasisScalar{ class BasisLagrange: public BasisScalar{
protected: protected:
polynomialBasis* basis; polynomialBasis* lBasis; // Lagrange Basis
fullMatrix<double>* lPoint; // Lagrange Points
public: public:
virtual ~BasisLagrange(void); virtual ~BasisLagrange(void);
...@@ -26,8 +46,49 @@ class BasisLagrange: public BasisScalar{ ...@@ -26,8 +46,49 @@ class BasisLagrange: public BasisScalar{
virtual const fullMatrix<double>& virtual const fullMatrix<double>&
getPreEvaluatedGradFunctions(const MElement& element) const; getPreEvaluatedGradFunctions(const MElement& element) const;
//! @return Returns the Coefficient Matrix
const fullMatrix<double>& getCoefficient(void) const;
//! @return Returns the Monomial Matrix
const fullMatrix<double>& getMonomial(void) const;
//! @param element A MElement
//! @param coef A vector of coefficient associated
//! to the given Element
//! @param fSpace The (scalar) Function Space
//! of the given Coefficients
//! @return Projects the given Coefficients in this BasisLagrange
std::vector<double> project(const MElement& element,
const std::vector<double>& coef,
const FunctionSpaceScalar& fSpace);
//! @param element A MElement
//! @param coef A vector of coefficient associated
//! to the given Element
//! @param fSpace The (vectorial) Function Space
//! of the given Coefficients
//! @return Projects the given Coefficients in this BasisLagrange
std::vector<fullVector<double> >
project(const MElement& element,
const std::vector<double>& coef,
const FunctionSpaceVector& fSpace);
protected: protected:
BasisLagrange(void); BasisLagrange(void);
}; };
//////////////////////
// Inline Functions //
//////////////////////
inline const fullMatrix<double>& BasisLagrange::
getCoefficient(void) const{
return lBasis->coefficients;
}
inline const fullMatrix<double>& BasisLagrange::
getMonomial(void) const{
return lBasis->monomials;
}
#endif #endif
...@@ -60,7 +60,7 @@ void FunctionSpace::build(const GroupOfElement& goe, ...@@ -60,7 +60,7 @@ void FunctionSpace::build(const GroupOfElement& goe,
type = basisType; type = basisType;
basis = BasisGenerator::generate(elementType, basis = BasisGenerator::generate(elementType,
basisType, basisType,
order, "zaglmayr"); order, "hierarchical");
// Number of *Per* Entity functions // // Number of *Per* Entity functions //
fPerVertex = basis->getNVertexBased() / nVertex; fPerVertex = basis->getNVertexBased() / nVertex;
......
...@@ -15,11 +15,15 @@ TriLagrangeBasis::TriLagrangeBasis(unsigned int order){ ...@@ -15,11 +15,15 @@ TriLagrangeBasis::TriLagrangeBasis(unsigned int order){
nFunction = nVertex + nEdge + nFace + nCell; nFunction = nVertex + nEdge + nFace + nCell;
// Init polynomialBasis // // Init polynomialBasis //
basis = new polynomialBasis(getTag(order)); lBasis = new polynomialBasis(getTag(order));
// Init Lagrange Point //
lPoint = new fullMatrix<double>(triPoint(order));
} }
TriLagrangeBasis::~TriLagrangeBasis(void){ TriLagrangeBasis::~TriLagrangeBasis(void){
delete basis; delete lBasis;
delete lPoint;
} }
unsigned int TriLagrangeBasis::getTag(unsigned int order){ unsigned int TriLagrangeBasis::getTag(unsigned int order){
...@@ -42,7 +46,6 @@ unsigned int TriLagrangeBasis::getTag(unsigned int order){ ...@@ -42,7 +46,6 @@ unsigned int TriLagrangeBasis::getTag(unsigned int order){
} }
} }
/*
fullMatrix<double> TriLagrangeBasis:: fullMatrix<double> TriLagrangeBasis::
triPoint(unsigned int order){ triPoint(unsigned int order){
unsigned int nbPoints = (order + 1) * (order + 2) / 2; unsigned int nbPoints = (order + 1) * (order + 2) / 2;
...@@ -111,4 +114,3 @@ triPoint(unsigned int order){ ...@@ -111,4 +114,3 @@ triPoint(unsigned int order){
return point; return point;
} }
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment