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

Fix LineEdgeBasis: went wrong way -- Add LineLagrangeBasis

parent a5a051c3
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "LineNodeBasis.h" #include "LineNodeBasis.h"
#include "LineEdgeBasis.h" #include "LineEdgeBasis.h"
#include "LineNedelecBasis.h" #include "LineNedelecBasis.h"
#include "LineLagrangeBasis.h"
#include "QuadNodeBasis.h" #include "QuadNodeBasis.h"
#include "QuadEdgeBasis.h" #include "QuadEdgeBasis.h"
...@@ -68,7 +69,7 @@ BasisLocal* BasisGenerator::generateLagrange(unsigned int elementType, ...@@ -68,7 +69,7 @@ BasisLocal* BasisGenerator::generateLagrange(unsigned int elementType,
basisType); basisType);
switch(elementType){ switch(elementType){
case TYPE_LIN: throw Exception("Lagrange Basis on Lines not Implemented"); case TYPE_LIN: return new LineLagrangeBasis(order);
case TYPE_TRI: return new TriLagrangeBasis(order); case TYPE_TRI: return new TriLagrangeBasis(order);
case TYPE_QUA: throw Exception("Lagrange Basis on Quads not Implemented"); case TYPE_QUA: throw Exception("Lagrange Basis on Quads not Implemented");
case TYPE_TET: return new TetLagrangeBasis(order); case TYPE_TET: return new TetLagrangeBasis(order);
......
...@@ -23,6 +23,7 @@ set(SRC ...@@ -23,6 +23,7 @@ set(SRC
LineNodeBasis.cpp LineNodeBasis.cpp
LineEdgeBasis.cpp LineEdgeBasis.cpp
LineNedelecBasis.cpp LineNedelecBasis.cpp
LineLagrangeBasis.cpp
# QuadNodeBasis.cpp # QuadNodeBasis.cpp
# QuadEdgeBasis.cpp # QuadEdgeBasis.cpp
......
...@@ -29,18 +29,18 @@ LineEdgeBasis::LineEdgeBasis(unsigned int order){ ...@@ -29,18 +29,18 @@ LineEdgeBasis::LineEdgeBasis(unsigned int order){
Polynomial* intLegendre = new Polynomial[orderPlus]; Polynomial* intLegendre = new Polynomial[orderPlus];
vector<Polynomial> first(3); vector<Polynomial> first(3);
first[0] = Polynomial(+0.5, 0, 0, 0); first[0] = Polynomial(-0.5, 0, 0, 0);
first[1] = Polynomial( 0 , 0, 0, 0); first[1] = Polynomial( 0 , 0, 0, 0);
first[2] = Polynomial( 0 , 0, 0, 0); first[2] = Polynomial( 0 , 0, 0, 0);
vector<Polynomial> second(3); vector<Polynomial> second(3);
second[0] = Polynomial(-0.5, 0, 0, 0); second[0] = Polynomial(+0.5, 0, 0, 0);
second[1] = Polynomial( 0 , 0, 0, 0); second[1] = Polynomial( 0 , 0, 0, 0);
second[2] = Polynomial( 0 , 0, 0, 0); second[2] = Polynomial( 0 , 0, 0, 0);
const Polynomial x[2] = { const Polynomial x[2] = {
Polynomial(+1, 1, 0, 0), Polynomial(-1, 1, 0, 0),
Polynomial(-1, 1, 0, 0) Polynomial(+1, 1, 0, 0)
}; };
// Legendre Polynomial // // Legendre Polynomial //
......
#include "Exception.h"
#include "LineLagrangeBasis.h"
LineLagrangeBasis::LineLagrangeBasis(unsigned int order){
// If order 0 (Nedelec): use order 1
if(order == 0)
order = 1;
// Set Basis Type //
this->order = order;
type = 0;
dim = 1;
nVertex = 2;
nEdge = (order - 1);
nFace = 0;
nCell = 0;
nFunction = nVertex + nEdge + nFace + nCell;
// Init polynomialBasis //
lBasis = new polynomialBasis(getTag(order));
// Init Lagrange Point //
lPoint = new fullMatrix<double>(linePoint(order));
}
LineLagrangeBasis::~LineLagrangeBasis(void){
delete lBasis;
delete lPoint;
}
unsigned int LineLagrangeBasis::getTag(unsigned int order){
unsigned int tag = nodalBasis::getTag(TYPE_LIN, order, false);
if(tag)
return tag;
else
throw Exception
("Can't instanciate an order %d Lagrangian Basis for a Line",
order);
}
fullMatrix<double> LineLagrangeBasis::
linePoint(unsigned int order){
fullMatrix<double> line(order + 1, 1);
line(0 ,0) = 0;
if(order > 0){
line(0, 0) = -1.;
line(1, 0) = 1.;
double dd = 2. / order;
for(unsigned int i = 2; i < order + 1; i++)
line(i, 0) = -1. + dd * (i - 1);
}
return line;
}
#ifndef _LINELAGRANGEBASIS_H_
#define _LINELAGRANGEBASIS_H_
#include "BasisLagrange.h"
/**
@class LineLagrangeBasis
@brief Lagrange Basis for Lines
This class can instantiate a @em Lagrange @em Basis
for a Line and for a given Order.@n
It uses
<a href="http://geuz.org/gmsh/">gmsh</a> Basis.
*/
class LineLagrangeBasis: public BasisLagrange{
public:
//! @param order A natural number
//!
//! Returns a new LineLagrangeBasis
//! of the given Order
LineLagrangeBasis(unsigned int order);
//! Deletes this Basis
//!
virtual ~LineLagrangeBasis(void);
private:
//! @param order A natural number
//! @return Returns the @em tag of a @em Line of
//! the given order
static unsigned int getTag(unsigned int order);
//! @param order A natural number
//! @return Returns Lagrangian Points on a Line
//! for the given Order
static fullMatrix<double> linePoint(unsigned int order);
};
#endif
...@@ -23,12 +23,12 @@ LineNedelecBasis::LineNedelecBasis(void){ ...@@ -23,12 +23,12 @@ LineNedelecBasis::LineNedelecBasis(void){
// Alloc Temporary Space // // Alloc Temporary Space //
vector<Polynomial> first(3); vector<Polynomial> first(3);
first[0] = Polynomial(+0.5, 0, 0, 0); first[0] = Polynomial(-0.5, 0, 0, 0);
first[1] = Polynomial( 0 , 0, 0, 0); first[1] = Polynomial( 0 , 0, 0, 0);
first[2] = Polynomial( 0 , 0, 0, 0); first[2] = Polynomial( 0 , 0, 0, 0);
vector<Polynomial> second(3); vector<Polynomial> second(3);
second[0] = Polynomial(-0.5, 0, 0, 0); second[0] = Polynomial(+0.5, 0, 0, 0);
second[1] = Polynomial( 0 , 0, 0, 0); second[1] = Polynomial( 0 , 0, 0, 0);
second[2] = Polynomial( 0 , 0, 0, 0); second[2] = Polynomial( 0 , 0, 0, 0);
......
...@@ -14,8 +14,8 @@ TriLagrangeBasis::TriLagrangeBasis(unsigned int order){ ...@@ -14,8 +14,8 @@ TriLagrangeBasis::TriLagrangeBasis(unsigned int order){
nVertex = 3; nVertex = 3;
nEdge = 3 * (order - 1); nEdge = 3 * (order - 1);
nFace = 0; nFace = (order - 1) * (order - 2) / 2;
nCell = (order - 1) * (order - 2) / 2; nCell = 0;
nFunction = nVertex + nEdge + nFace + nCell; nFunction = nVertex + nEdge + nFace + nCell;
// Init polynomialBasis // // Init polynomialBasis //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment