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

LineNodeBasis: Convergence Test -- Seems OK

parent d7510e91
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "GmshDefines.h" #include "GmshDefines.h"
#include "Exception.h" #include "Exception.h"
#include "LineNodeBasis.h"
#include "QuadNodeBasis.h" #include "QuadNodeBasis.h"
#include "QuadEdgeBasis.h" #include "QuadEdgeBasis.h"
...@@ -26,6 +28,7 @@ Basis* BasisGenerator::generate(int elementType, ...@@ -26,6 +28,7 @@ Basis* BasisGenerator::generate(int elementType,
int basisType, int basisType,
int order){ int order){
switch(elementType){ switch(elementType){
case TYPE_LIN: return linGen(basisType, order);
case TYPE_TRI: return triGen(basisType, order); case TYPE_TRI: return triGen(basisType, order);
case TYPE_QUA: return quaGen(basisType, order); case TYPE_QUA: return quaGen(basisType, order);
case TYPE_TET: return tetGen(basisType, order); case TYPE_TET: return tetGen(basisType, order);
...@@ -36,6 +39,18 @@ Basis* BasisGenerator::generate(int elementType, ...@@ -36,6 +39,18 @@ Basis* BasisGenerator::generate(int elementType,
} }
} }
Basis* BasisGenerator::linGen(int basisType,
int order){
switch(basisType){
case 0: return new LineNodeBasis(order);
case 1: throw Exception("1-form not implemented on Lines");
case 2: throw Exception("2-form not implemented on Lines");
case 3: throw Exception("3-form not implemented on Lines");
default: throw Exception("There is no %d-form", basisType);
}
}
Basis* BasisGenerator::triGen(int basisType, Basis* BasisGenerator::triGen(int basisType,
int order){ int order){
switch(basisType){ switch(basisType){
......
...@@ -24,6 +24,7 @@ class BasisGenerator{ ...@@ -24,6 +24,7 @@ class BasisGenerator{
int basisType, int basisType,
int order); int order);
static Basis* linGen(int basisType, int order);
static Basis* triGen(int basisType, int order); static Basis* triGen(int basisType, int order);
static Basis* quaGen(int basisType, int order); static Basis* quaGen(int basisType, int order);
static Basis* tetGen(int basisType, int order); static Basis* tetGen(int basisType, int order);
...@@ -56,6 +57,7 @@ class BasisGenerator{ ...@@ -56,6 +57,7 @@ class BasisGenerator{
@em instantiated Basis @em instantiated Basis
@note Element types are: @note Element types are:
@li @c TYPE_LIN for Lines
@li @c TYPE_TRI for Triangles @li @c TYPE_TRI for Triangles
@li @c TYPE_QUA for Quadrangles @li @c TYPE_QUA for Quadrangles
@li @c TYPE_TET for Tetrahedrons @li @c TYPE_TET for Tetrahedrons
...@@ -68,6 +70,23 @@ class BasisGenerator{ ...@@ -68,6 +70,23 @@ class BasisGenerator{
@li @c 3 for 3-Form @li @c 3 for 3-Form
** **
@fn BasisGenerator::linGen
@param basisType The Basis type
@param order The order or the requested Basis
This method will @em instanciate the requested Basis,
with a @em Line for support
@return Returns a @em pointer to a newly
@em instantiated Basis
@note Basis types are:
@li @c 0 for 0-Form
@li @c 1 for 1-Form
@li @c 2 for 2-Form
@li @c 3 for 3-Form
**
@fn BasisGenerator::triGen @fn BasisGenerator::triGen
@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
......
...@@ -321,34 +321,40 @@ FunctionSpace::locBasis(const MElement& element, ...@@ -321,34 +321,40 @@ FunctionSpace::locBasis(const MElement& element,
// Edge Based // Edge Based
// Number of basis function *per* edge // Number of basis function *per* edge
// --> should always be an integer ! // --> should always be an integer !
const unsigned int nEdge = edgeClosure.size(); const unsigned int nEdge = edgeClosure.size();
const unsigned int nFPerEdge = nFEdge / nEdge;
unsigned int fEdge = 0;
for(unsigned int j = 0; j < nFPerEdge; j++){ if(nEdge){
for(unsigned int k = 0; k < nEdge; k++){ const unsigned int nFPerEdge = nFEdge / nEdge;
fun[i] = unsigned int fEdge = 0;
&basis.getEdgeFunction(edgeClosure[k], fEdge);
for(unsigned int j = 0; j < nFPerEdge; j++){
fEdge++; for(unsigned int k = 0; k < nEdge; k++){
i++; fun[i] =
&basis.getEdgeFunction(edgeClosure[k], fEdge);
fEdge++;
i++;
}
} }
} }
// Face Based // Face Based
// Number of basis function *per* face // Number of basis function *per* face
// --> should always be an integer ! // --> should always be an integer !
const unsigned int nFace = faceClosure.size(); const unsigned int nFace = faceClosure.size();
const unsigned int nFPerFace = nFFace / nFace;
unsigned int fFace = 0; if(nFace){
const unsigned int nFPerFace = nFFace / nFace;
for(unsigned int j = 0; j < nFPerFace; j++){ unsigned int fFace = 0;
for(unsigned int k = 0; k < nFace; k++){
fun[i] = for(unsigned int j = 0; j < nFPerFace; j++){
&basis.getFaceFunction(faceClosure[k], fFace); for(unsigned int k = 0; k < nFace; k++){
fun[i] =
fFace++; &basis.getFaceFunction(faceClosure[k], fFace);
i++;
fFace++;
i++;
}
} }
} }
...@@ -390,16 +396,19 @@ FunctionSpace::locBasis(const MElement& element, ...@@ -390,16 +396,19 @@ FunctionSpace::locBasis(const MElement& element,
// Number of basis function *per* edge // Number of basis function *per* edge
// --> should always be an integer ! // --> should always be an integer !
const unsigned int nEdge = edgeClosure.size(); const unsigned int nEdge = edgeClosure.size();
const unsigned int nFPerEdge = nFEdge / nEdge;
unsigned int fEdge = 0;
for(unsigned int j = 0; j < nFPerEdge; j++){ if(nEdge){
for(unsigned int k = 0; k < nEdge; k++){ const unsigned int nFPerEdge = nFEdge / nEdge;
fun[i] = unsigned int fEdge = 0;
&basis.getEdgeFunction(edgeClosure[k], fEdge);
for(unsigned int j = 0; j < nFPerEdge; j++){
fEdge++; for(unsigned int k = 0; k < nEdge; k++){
i++; fun[i] =
&basis.getEdgeFunction(edgeClosure[k], fEdge);
fEdge++;
i++;
}
} }
} }
...@@ -407,16 +416,19 @@ FunctionSpace::locBasis(const MElement& element, ...@@ -407,16 +416,19 @@ FunctionSpace::locBasis(const MElement& element,
// Number of basis function *per* face // Number of basis function *per* face
// --> should always be an integer ! // --> should always be an integer !
const unsigned int nFace = faceClosure.size(); const unsigned int nFace = faceClosure.size();
const unsigned int nFPerFace = nFFace / nFace;
unsigned int fFace = 0;
for(unsigned int j = 0; j < nFPerFace; j++){ if(nFace){
for(unsigned int k = 0; k < nFace; k++){ const unsigned int nFPerFace = nFFace / nFace;
fun[i] = unsigned int fFace = 0;
&basis.getFaceFunction(faceClosure[k], fFace);
for(unsigned int j = 0; j < nFPerFace; j++){
fFace++; for(unsigned int k = 0; k < nFace; k++){
i++; fun[i] =
&basis.getFaceFunction(faceClosure[k], fFace);
fFace++;
i++;
}
} }
} }
......
...@@ -36,16 +36,14 @@ LineNodeBasis::LineNodeBasis(int order){ ...@@ -36,16 +36,14 @@ LineNodeBasis::LineNodeBasis(int order){
// Vertex Based (Lagrange) // // Vertex Based (Lagrange) //
(*node)[0] = (*node)[0] =
new Polynomial((Polynomial(1, 0, 0, 0) - new Polynomial(Polynomial(0.5, 0, 0, 0) -
Polynomial(1, 1, 0, 0)) * Polynomial(0.5, 1, 0, 0));
0.5);
(*node)[1] = (*node)[1] =
new Polynomial((Polynomial(1, 0, 0, 0) + new Polynomial(Polynomial(0.5, 0, 0, 0) +
Polynomial(1, 1, 0, 0)) * Polynomial(0.5, 1, 0, 0));
0.5);
// Edge Based // // Edge Based //
const int permutation[2] = {0, 1}; const int permutation[2] = {0, 1};
const Polynomial x[2] = { const Polynomial x[2] = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment