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

HexNodeBasis: seems OK -- YEAAAHHHHHH -- Polynomial: combination of three arguments

parent 4fdd4d7a
No related branches found
No related tags found
No related merge requests found
...@@ -119,59 +119,51 @@ HexNodeBasis::HexNodeBasis(size_t order){ ...@@ -119,59 +119,51 @@ HexNodeBasis::HexNodeBasis(size_t order){
basis[s][6] = new Polynomial(lagrange[6]); basis[s][6] = new Polynomial(lagrange[6]);
basis[s][7] = new Polynomial(lagrange[7]); basis[s][7] = new Polynomial(lagrange[7]);
} }
/*
// Edge Based // // Edge Based //
for(size_t s = 0; s < nRefSpace; s++){
size_t i = nVertex;
for(int l = 1; l < order; l++){ for(size_t e = 0; e < 12; e++){
for(int e = 0; e < 12; e++){ for(size_t l = 1; l < order; l++){
(*basis)[i] = new Polynomial( basis[s][i] =
legendre[l].compose(lifting[edge1[e]] - lifting[edge2[e]]) * new Polynomial(legendre[l].compose(lifting[edgeIdx[s][e][1]] -
(*(*basis)[edge1[e]] + *(*basis)[edge2[e]])); lifting[edgeIdx[s][e][0]])
*
(lagrange[edgeIdx[s][e][0]] +
lagrange[edgeIdx[s][e][1]]));
i++; i++;
}
} }
} }
// Face Based (Preliminary) //
// Points definig Faces
const int face1[6] = {0, 3, 2, 1, 5, 4};
const int face2[6] = {1, 7, 6, 0, 6, 7};
const int face3[6] = {2, 6, 5, 4, 7, 3};
const int face4[6] = {3, 2, 1, 5, 4, 0};
// 'Xi' Functions
for(int f = 0; f < 6; f++)
xi[f] = lifting[face1[f]] - lifting[face2[f]];
// 'Eta' Functions
for(int f = 0; f < 6; f++)
eta[f] = lifting[face1[f]] - lifting[face4[f]];
// 'Lambda' Functions
for(int f = 0; f < 6; f++)
lambda[f] =
*(*basis)[face1[f]] +
*(*basis)[face2[f]] +
*(*basis)[face3[f]] +
*(*basis)[face4[f]];
// Face Based // // Face Based //
for(int l1 = 1; l1 < order; l1++){ for(size_t s = 0; s < nRefSpace; s++){
for(int l2 = 1; l2 < order; l2++){ size_t i = nVertex + nEdge;
for(int f = 0; f < 6; f++){
(*basis)[i] = new Polynomial( for(size_t f = 0; f < 6; f++){
legendre[l1].compose(xi[f]) * for(size_t l1 = 1; l1 < order; l1++){
legendre[l2].compose(eta[f]) * for(size_t l2 = 1; l2 < order; l2++){
lambda[f]); Polynomial sum =
lagrange[faceIdx[s][f][0]] +
i++; lagrange[faceIdx[s][f][1]] +
lagrange[faceIdx[s][f][2]] +
lagrange[faceIdx[s][f][3]];
basis[s][i] =
new Polynomial(legendre[l1].compose(lifting[faceIdx[s][f][0]] -
lifting[faceIdx[s][f][1]]) *
legendre[l2].compose(lifting[faceIdx[s][f][0]] -
lifting[faceIdx[s][f][3]]) *
sum);
i++;
}
} }
} }
} }
// Cell Based // // Cell Based //
Polynomial px = Polynomial(2, 1, 0, 0); Polynomial px = Polynomial(2, 1, 0, 0);
Polynomial py = Polynomial(2, 0, 1, 0); Polynomial py = Polynomial(2, 0, 1, 0);
...@@ -181,28 +173,50 @@ HexNodeBasis::HexNodeBasis(size_t order){ ...@@ -181,28 +173,50 @@ HexNodeBasis::HexNodeBasis(size_t order){
py = py - Polynomial(1, 0, 0, 0); py = py - Polynomial(1, 0, 0, 0);
pz = pz - Polynomial(1, 0, 0, 0); pz = pz - Polynomial(1, 0, 0, 0);
for(int l1 = 1; l1 < order; l1++){ for(size_t s = 0; s < nRefSpace; s++){
for(int l2 = 1; l2 < order; l2++){ size_t i = nVertex + nEdge + nFace;
for(int l3 = 1; l3 < order; l3++){
(*basis)[i] = for(size_t l1 = 1; l1 < order; l1++){
new Polynomial(legendre[l1].compose(px) * for(size_t l2 = 1; l2 < order; l2++){
legendre[l2].compose(py) * for(size_t l3 = 1; l3 < order; l3++){
legendre[l3].compose(pz)); basis[s][i] =
new Polynomial(legendre[l1].compose(px) *
i++; legendre[l2].compose(py) *
legendre[l3].compose(pz));
i++;
}
} }
} }
} }
// Mapping to Gmsh Quad //
// x = (u + 1) / 2
// y = (v + 1) / 2
//
// (x, y) = Zaglmayr Ref Quad
// (u, v) = Gmsh Ref Quad
Polynomial mapX(Polynomial(0.5, 1, 0, 0) +
Polynomial(0.5, 0, 0, 0));
Polynomial mapY(Polynomial(0.5, 0, 1, 0) +
Polynomial(0.5, 0, 0, 0));
Polynomial mapZ(Polynomial(0.5, 0, 0, 1) +
Polynomial(0.5, 0, 0, 0));
for(size_t s = 0; s < nRefSpace; s++){
for(size_t i = 0; i < nFunction; i++){
Polynomial* tmp;
tmp = basis[s][i];
basis[s][i] = new Polynomial(tmp->compose(mapX, mapY, mapZ));
delete tmp;
}
}
// Free Temporary Sapce // // Free Temporary Sapce //
delete[] legendre; delete[] legendre;
delete[] lifting;
delete[] xi;
delete[] eta;
delete[] lambda;
*/
} }
HexNodeBasis::~HexNodeBasis(void){ HexNodeBasis::~HexNodeBasis(void){
......
...@@ -289,6 +289,17 @@ Polynomial Polynomial::compose(const Polynomial& otherA, ...@@ -289,6 +289,17 @@ Polynomial Polynomial::compose(const Polynomial& otherA,
return polynomialFromStack(stk); return polynomialFromStack(stk);
} }
Polynomial Polynomial::compose(const Polynomial& otherA,
const Polynomial& otherB,
const Polynomial& otherC) const{
stack<monomial_t> stk;
for(int i = 0; i < nMon; i++)
compose(&mon[i], otherA, otherB, otherC, &stk);
return polynomialFromStack(stk);
}
void Polynomial::operator=(const Polynomial& other){ void Polynomial::operator=(const Polynomial& other){
if(mon) if(mon)
delete[] mon; delete[] mon;
...@@ -603,6 +614,26 @@ void Polynomial::compose(const Polynomial::monomial_t* src, ...@@ -603,6 +614,26 @@ void Polynomial::compose(const Polynomial::monomial_t* src,
} }
} }
void Polynomial::compose(const Polynomial::monomial_t* src,
Polynomial compA, Polynomial compB, Polynomial compC,
stack<Polynomial::monomial_t>* stk){
compA.power(src->power[0]);
compB.power(src->power[1]);
compC.power(src->power[2]);
compA.mul(compB);
compA.mul(compC);
compA.mul(src->coef);
const int size = compA.nMon;
for(int i = 0; i < size; i++){
if(compA.mon[i].coef != 0)
stk->push(compA.mon[i]);
}
}
Polynomial Polynomial:: Polynomial Polynomial::
polynomialFromStack(std::stack<Polynomial::monomial_t>& stk){ polynomialFromStack(std::stack<Polynomial::monomial_t>& stk){
Polynomial newP; Polynomial newP;
......
...@@ -68,6 +68,9 @@ class Polynomial{ ...@@ -68,6 +68,9 @@ class Polynomial{
Polynomial compose(const Polynomial& other) const; Polynomial compose(const Polynomial& other) const;
Polynomial compose(const Polynomial& otherA, Polynomial compose(const Polynomial& otherA,
const Polynomial& otherB) const; const Polynomial& otherB) const;
Polynomial compose(const Polynomial& otherA,
const Polynomial& otherB,
const Polynomial& otherC) const;
void operator=(const Polynomial& other); void operator=(const Polynomial& other);
...@@ -104,6 +107,10 @@ class Polynomial{ ...@@ -104,6 +107,10 @@ class Polynomial{
Polynomial compA, Polynomial compB, Polynomial compA, Polynomial compB,
std::stack<monomial_t>* stk); std::stack<monomial_t>* stk);
static void compose(const monomial_t* src,
Polynomial compA, Polynomial compB, Polynomial compC,
std::stack<monomial_t>* stk);
static Polynomial polynomialFromStack(std::stack<monomial_t>& stk); static Polynomial polynomialFromStack(std::stack<monomial_t>& stk);
static monomial_t* copyMonomial(const monomial_t* src, int size); static monomial_t* copyMonomial(const monomial_t* src, int size);
......
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