mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 13:50:33 +05:00
Fix growth vector calculation (do more vector reduction to avoid strange results from inverting badly conditioned matrix)
This commit is contained in:
parent
c27650af0a
commit
c27dbdef30
@ -63,22 +63,25 @@ Vec<3> CalcGrowthVector (FlatArray<Vec<3>> ns)
|
|||||||
for (auto j : Range(3))
|
for (auto j : Range(3))
|
||||||
mat(i, j) = ns[i][j];
|
mat(i, j) = ns[i][j];
|
||||||
|
|
||||||
if (fabs(mat.Det()) > 1e-6)
|
if (fabs(mat.Det()) > 1e-2)
|
||||||
{
|
{
|
||||||
DenseMatrix mat(3, 3);
|
DenseMatrix mat(3, 3);
|
||||||
for (auto i : Range(3))
|
for (auto i : Range(3))
|
||||||
for (auto j : Range(3))
|
for (auto j : Range(3))
|
||||||
mat(i, j) = ns[i] * ns[j];
|
mat(i, j) = ns[i] * ns[j];
|
||||||
Vector rhs(3);
|
if (fabs(mat.Det()) > 1e-2)
|
||||||
rhs = 1.;
|
{
|
||||||
Vector res(3);
|
Vector rhs(3);
|
||||||
DenseMatrix inv(3, ns.Size());
|
rhs = 1.;
|
||||||
CalcInverse(mat, inv);
|
Vector res(3);
|
||||||
inv.Mult(rhs, res);
|
DenseMatrix inv(3, ns.Size());
|
||||||
Vec<3> growth = 0.;
|
CalcInverse(mat, inv);
|
||||||
for (auto i : Range(ns))
|
inv.Mult(rhs, res);
|
||||||
growth += res[i] * ns[i];
|
Vec<3> growth = 0.;
|
||||||
return growth;
|
for (auto i : Range(ns))
|
||||||
|
growth += res[i] * ns[i];
|
||||||
|
return growth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto [maxpos1, maxpos2] = FindCloseVectors(ns);
|
auto [maxpos1, maxpos2] = FindCloseVectors(ns);
|
||||||
|
Loading…
Reference in New Issue
Block a user