Manage global JacobiPols array inside struct

Works around emscripten issue, where the global array was not
constructed properly
This commit is contained in:
Matthias Hochsteger 2024-11-27 18:54:32 +01:00
parent 7570468686
commit 1c6d53f387
2 changed files with 17 additions and 15 deletions

View File

@ -405,18 +405,24 @@ namespace netgen
}
}
static NgArray<shared_ptr<RecPol>> jacpols2;
void CurvedElements::buildJacPols()
struct JacobiRecPols
{
if (!jacpols2.Size())
static constexpr size_t N = 100;
ArrayMem<unique_ptr<JacobiRecPol>, N> jacpols;
JacobiRecPols()
{
jacpols2.SetSize (100);
for (int i = 0; i < 100; i++)
jacpols2[i] = make_shared<JacobiRecPol> (100, i, 2);
jacpols.SetSize (N);
for (int i = 0; i < N; i++)
jacpols[i] = make_unique<JacobiRecPol>(N, i, 2);
}
const unique_ptr<JacobiRecPol> & operator[] (int i) {
return jacpols[i];
}
};
static JacobiRecPols jacpols2;
// compute face bubbles up to order n, 0 < y, y-x < 1, x+y < 1
template <class Tx, class Ty, class Ts>
@ -710,7 +716,6 @@ namespace netgen
ComputeGaussRule (aorder+4, xi, weight); // on (0,1)
buildJacPols();
PrintMessage (3, "Curving edges");
if (mesh.GetDimension() == 3 || rational)

View File

@ -38,7 +38,6 @@ class CurvedElements
bool rational;
bool ishighorder;
void buildJacPols();
public:
DLL_HEADER CurvedElements (const Mesh & amesh);
@ -56,8 +55,6 @@ public:
void DoArchive(Archive& ar)
{
if(ar.Input())
buildJacPols();
ar & edgeorder & faceorder & edgecoeffsindex & facecoeffsindex & edgecoeffs & facecoeffs
& edgeweight & order & rational & ishighorder;
}