1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
// Gmsh - Copyright (C) 1997-2021 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
//
// Contributed by Ismail Badia.
// Reference : "Higher-Order Finite Element Methods"; Pavel Solin, Karel
// Segeth ,
// Ivo Dolezel , Chapman and Hall/CRC; Edition : Har/Cdr (2003).
#include "HierarchicalBasisHcurlLine.h"
HierarchicalBasisHcurlLine::HierarchicalBasisHcurlLine(int order)
{
_nvertex = 2;
_nedge = 1;
_nfaceTri = 0;
_nfaceQuad = 0;
_nVertexFunction = 0;
_nEdgeFunction = order + 1;
_nQuadFaceFunction = 0;
_nTriFaceFunction = 0;
_nBubbleFunction = 0;
_pe = order;
}
HierarchicalBasisHcurlLine::~HierarchicalBasisHcurlLine() {}
unsigned int HierarchicalBasisHcurlLine::getNumberOfOrientations() const
{
return 2; // factorial 2
}
double HierarchicalBasisHcurlLine::_affineCoordinate(int j, double u)
{
switch(j) {
case(1): return 0.5 * (1 + u);
case(2): return 0.5 * (1 - u);
default: throw std::string("j must be : 1<=j<=2");
}
}
double HierarchicalBasisHcurlLine::dotProduct(const std::vector<double> &u,
const std::vector<double> &v)
{
return u[0] * v[0] + u[1] * v[1] + u[2] * v[2];
}
void HierarchicalBasisHcurlLine::generateHcurlBasis(
double const &u, double const &v, double const &w,
std::vector<std::vector<double> > &edgeBasis,
std::vector<std::vector<double> > &faceBasis,
std::vector<std::vector<double> > &bubbleBasis)
{
double lambda1 = _affineCoordinate(1, u);
double lambda2 = _affineCoordinate(2, u);
std::vector<double> t1 = std::vector<double>(3, 0);
t1[0] = 1;
std::vector<double> n1 = std::vector<double>(3, 0);
n1[0] = 1;
std::vector<double> n2 = std::vector<double>(3, 0);
n2[0] = -1;
// Whitney functions
std::vector<double> psie_0(3, 0);
std::vector<double> psie_1(3, 0);
for(int i = 0; i < 3; i++) {
psie_0[i] = lambda1 * n2[i] / dotProduct(n2, t1) +
lambda2 * n1[i] / dotProduct(n1, t1);
psie_1[i] = lambda1 * n2[i] / dotProduct(n2, t1) -
lambda2 * n1[i] / dotProduct(n1, t1);
}
double sub = lambda1 - lambda2;
std::vector<double> legendreVector(_pe, 0);
for(unsigned int k = 0; k < legendreVector.size(); k++) {
legendreVector[k] = OrthogonalPoly::EvalLegendre(k, sub);
}
int edgeIt = 0;
for(int j = 0; j < 3; j++) { edgeBasis[edgeIt][j] = psie_0[j]; }
edgeIt++;
if(_pe >= 1) {
for(int j = 0; j < 3; j++) { edgeBasis[edgeIt][j] = psie_1[j]; }
edgeIt++;
for(int iedge = 2; iedge <= _pe; iedge++) {
for(int j = 0; j < 3; j++) {
edgeBasis[edgeIt][j] = (2 * float(iedge) - 1) / float(iedge) *
legendreVector[iedge - 1] * psie_1[j] -
(float(iedge) - 1) / float(iedge) *
legendreVector[iedge - 2] * psie_0[j];
}
edgeIt++;
}
}
}
void HierarchicalBasisHcurlLine::orientEdge(
int const &flagOrientation, int const &edgeNumber,
std::vector<std::vector<double> > &edgeFunctions,
const std::vector<std::vector<double> > &eTablePositiveFlag,
const std::vector<std::vector<double> > &eTableNegativeFlag)
{
if(flagOrientation == -1) {
for(int k = 0; k <= _pe; k++) {
edgeFunctions[k][0] = eTableNegativeFlag[k][0];
edgeFunctions[k][1] = eTableNegativeFlag[k][1];
edgeFunctions[k][2] = eTableNegativeFlag[k][2];
}
}
else {
for(int k = 0; k <= _pe; k++) {
edgeFunctions[k][0] = eTablePositiveFlag[k][0];
edgeFunctions[k][1] = eTablePositiveFlag[k][1];
edgeFunctions[k][2] = eTablePositiveFlag[k][2];
}
}
}
void HierarchicalBasisHcurlLine::orientEdgeFunctionsForNegativeFlag(
std::vector<std::vector<double> > &edgeFunctions)
{
for(int k = 0; k <= _pe; k++) {
if(k % 2 == 0) {
edgeFunctions[k][0] = edgeFunctions[k][0] * (-1);
edgeFunctions[k][1] = edgeFunctions[k][1] * (-1);
edgeFunctions[k][2] = edgeFunctions[k][2] * (-1);
}
}
}
void HierarchicalBasisHcurlLine::generateCurlBasis(
double const &u, double const &v, double const &w,
std::vector<std::vector<double> > &edgeBasis,
std::vector<std::vector<double> > &faceBasis,
std::vector<std::vector<double> > &bubbleBasis)
{
// zero for all orders
}
void HierarchicalBasisHcurlLine::getKeysInfo(std::vector<int> &functionTypeInfo,
std::vector<int> &orderInfo)
{
for(int k = 0; k <= _pe; k++) {
orderInfo[k] = k;
functionTypeInfo[k] = 1;
}
}
|