MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / GetIBernsteinBasis

Function GetIBernsteinBasis

comp/webgui.cpp:47–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47Matrix<double> GetIBernsteinBasis(ngfem::ELEMENT_TYPE etype, int order) {
48 std::map<std::pair<ngfem::ELEMENT_TYPE, int>, Matrix<double>> cache;
49 if(cache.count({etype, order})) return cache[{etype, order}];
50 if (etype == ET_SEGM) {
51 Matrix<double> ret(order + 1, order + 1);
52 ret = 0.;
53 for (auto i : Range(order + 1))
54 for (auto j : Range(order + 1))
55 ret(i, j) = Bernstein(1. * i / order, j, order);
56 CalcInverse(ret);
57 cache.insert({{etype, order}, ret});
58 return ret;
59 }
60
61 if (etype == ET_TRIG) {
62 int n = (order + 1) * (order + 2) / 2;
63 Matrix<double> ret(n, n);
64 int ii = 0;
65 for (auto ix : Range(order + 1))
66 for (auto iy : Range(order + 1 - ix)) {
67 int jj = 0;
68 for (auto jx : Range(order + 1))
69 for (auto jy : Range(order + 1 - jx))
70 ret(ii, jj++) =
71 BernsteinTrig(1. * ix / order, 1. * iy / order, jx, jy, order);
72 ii++;
73 }
74 CalcInverse(ret);
75 cache.insert({{etype, order}, ret});
76 return ret;
77 }
78 throw Exception("Element type not supported");
79}
80
81const IntegrationRule & GetElementPoints(ngfem::ELEMENT_TYPE etype, int order) {
82 static std::map<std::pair<ngfem::ELEMENT_TYPE, int>, IntegrationRule> cache;

Callers 1

MapBernsteinFunction · 0.85

Calls 4

BernsteinFunction · 0.70
BernsteinTrigFunction · 0.70
RangeFunction · 0.50
CalcInverseFunction · 0.50

Tested by

no test coverage detected