|
|
@ -273,7 +273,7 @@ void qConvBernstein(const xarray<real, N>& phi, |
|
|
|
// compute volume integral over {phi < 0} using AutoMixed strategy
|
|
|
|
if (!halfFaces.empty()) { |
|
|
|
ipquad.integrate(AutoMixed, q, [&](const uvector<real, N>& x, real w) { |
|
|
|
if (bernstein::evalBernsteinPoly(phi, x) >= 0) return; |
|
|
|
if (bernstein::evalBernsteinPoly(phi, x) <= 0) return; |
|
|
|
uvector<real, N> trueX = xmin + x * (xmax - xmin); |
|
|
|
// uvector<real, N> trueX = x;
|
|
|
|
// std::cout << "trueX: " << trueX << std::endl;
|
|
|
@ -705,10 +705,11 @@ void test8PlanesPowerDirectly() |
|
|
|
uvector<real, 3> xmin = -1, xmax = 1; |
|
|
|
uvector<real, 3> range = xmax - xmin; |
|
|
|
assert(all(range != 0)); |
|
|
|
uvector<real, 3> k = range; |
|
|
|
uvector<real, 3> bias = xmin; |
|
|
|
uvector<int, 3> ext = 2; |
|
|
|
std::vector<xarray<real, 3>> phiPowers(8, xarray<real, 3>(nullptr, ext)); |
|
|
|
uvector<real, 3> k = range; |
|
|
|
uvector<real, 3> bias = xmin; |
|
|
|
uvector<int, 3> ext = 2; |
|
|
|
const int planeNum = 8; |
|
|
|
std::vector<xarray<real, 3>> phiPowers(planeNum, xarray<real, 3>(nullptr, ext)); |
|
|
|
algoim_spark_alloc(real, |
|
|
|
phiPowers[0], |
|
|
|
phiPowers[1], |
|
|
@ -718,7 +719,7 @@ void test8PlanesPowerDirectly() |
|
|
|
phiPowers[5], |
|
|
|
phiPowers[6], |
|
|
|
phiPowers[7]); |
|
|
|
for (int i = 0; i < 8; i++) { |
|
|
|
for (int i = 0; i < planeNum; i++) { |
|
|
|
xarrayInit(phiPowers[i]); |
|
|
|
if (i & 1) { |
|
|
|
phiPowers[i].m(uvector<int, 3>(0, 0, 1)) = 1; |
|
|
@ -737,7 +738,7 @@ void test8PlanesPowerDirectly() |
|
|
|
} |
|
|
|
phiPowers[i].m(uvector<int, 3>(0, 0, 0)) = -1; |
|
|
|
} |
|
|
|
uvector<int, 3> resExt = 1 + phiPowers.size(); |
|
|
|
uvector<int, 3> resExt = 1 + planeNum; |
|
|
|
xarray<real, 3> phiPowerAll(nullptr, resExt), phiBernstein(nullptr, resExt); |
|
|
|
algoim_spark_alloc(real, phiPowerAll, phiBernstein); |
|
|
|
compositePower(phiPowers, 0, 0, 1, phiPowerAll); |
|
|
@ -816,21 +817,22 @@ void test3PlanesPowerDirectly() |
|
|
|
uvector<real, 3> xmin = -1, xmax = 1; |
|
|
|
uvector<real, 3> range = xmax - xmin; |
|
|
|
assert(all(range != 0)); |
|
|
|
uvector<real, 3> k = range; |
|
|
|
uvector<real, 3> bias = xmin; |
|
|
|
uvector<int, 3> ext = 2; |
|
|
|
std::vector<xarray<real, 3>> phiPowers(3, xarray<real, 3>(nullptr, ext)); |
|
|
|
uvector<real, 3> k = range; |
|
|
|
uvector<real, 3> bias = xmin; |
|
|
|
uvector<int, 3> ext = 2; |
|
|
|
const int planeNum = 3; |
|
|
|
std::vector<xarray<real, 3>> phiPowers(planeNum, xarray<real, 3>(nullptr, ext)); |
|
|
|
algoim_spark_alloc(real, phiPowers[0]); |
|
|
|
algoim_spark_alloc(real, phiPowers[1]); |
|
|
|
algoim_spark_alloc(real, phiPowers[2]); |
|
|
|
for (int i = 0; i < 3; i++) { xarrayInit(phiPowers[i]); } |
|
|
|
for (int i = 0; i < planeNum; i++) { xarrayInit(phiPowers[i]); } |
|
|
|
phiPowers[0].m(uvector<int, 3>(1, 0, 0)) = 1; |
|
|
|
phiPowers[0].m(uvector<int, 3>(0, 1, 0)) = 1; |
|
|
|
phiPowers[1].m(uvector<int, 3>(1, 0, 0)) = 1; |
|
|
|
phiPowers[1].m(uvector<int, 3>(0, 1, 0)) = -1; |
|
|
|
phiPowers[2].m(uvector<int, 3>(1, 0, 0)) = -1; |
|
|
|
phiPowers[2].m(uvector<int, 3>(0, 0, 0)) = -1; |
|
|
|
uvector<int, 3> resExt = 1 + phiPowers.size(); |
|
|
|
uvector<int, 3> resExt = 1 + planeNum; |
|
|
|
xarray<real, 3> phiPowerAll(nullptr, resExt), phiBernstein(nullptr, resExt); |
|
|
|
algoim_spark_alloc(real, phiPowerAll); |
|
|
|
algoim_spark_alloc(real, phiBernstein); |
|
|
@ -1039,15 +1041,16 @@ void test4PlanesPowerDirectly() |
|
|
|
uvector<real, 3> xmin = -1, xmax = 1; |
|
|
|
uvector<real, 3> range = xmax - xmin; |
|
|
|
assert(all(range != 0)); |
|
|
|
uvector<real, 3> k = range; |
|
|
|
uvector<real, 3> bias = xmin; |
|
|
|
uvector<int, 3> ext = 2; |
|
|
|
std::vector<xarray<real, 3>> phiPowers(4, xarray<real, 3>(nullptr, ext)); |
|
|
|
uvector<real, 3> k = range; |
|
|
|
uvector<real, 3> bias = xmin; |
|
|
|
uvector<int, 3> ext = 2; |
|
|
|
const int planeNum = 4; |
|
|
|
std::vector<xarray<real, 3>> phiPowers(planeNum, xarray<real, 3>(nullptr, ext)); |
|
|
|
algoim_spark_alloc(real, phiPowers[0]); |
|
|
|
algoim_spark_alloc(real, phiPowers[1]); |
|
|
|
algoim_spark_alloc(real, phiPowers[2]); |
|
|
|
algoim_spark_alloc(real, phiPowers[3]); |
|
|
|
for (int i = 0; i < 4; i++) { xarrayInit(phiPowers[i]); } |
|
|
|
for (int i = 0; i < planeNum; i++) { xarrayInit(phiPowers[i]); } |
|
|
|
phiPowers[0].m(uvector<int, 3>(1, 0, 0)) = 1; |
|
|
|
phiPowers[0].m(uvector<int, 3>(0, 1, 0)) = 1; |
|
|
|
phiPowers[1].m(uvector<int, 3>(1, 0, 0)) = 1; |
|
|
@ -1057,7 +1060,7 @@ void test4PlanesPowerDirectly() |
|
|
|
phiPowers[3].m(uvector<int, 3>(1, 0, 0)) = 1; |
|
|
|
phiPowers[3].m(uvector<int, 3>(0, 1, 0)) = 1; |
|
|
|
phiPowers[3].m(uvector<int, 3>(0, 0, 1)) = -1; |
|
|
|
uvector<int, 3> resExt = 1 + phiPowers.size(); |
|
|
|
uvector<int, 3> resExt = 1 + planeNum; |
|
|
|
xarray<real, 3> phiPowerAll(nullptr, resExt), phiBernstein(nullptr, resExt); |
|
|
|
algoim_spark_alloc(real, phiPowerAll); |
|
|
|
algoim_spark_alloc(real, phiBernstein); |
|
|
@ -1106,6 +1109,68 @@ void test4PlanesPowerDirectly() |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
void test2PlanesPowerDirectly() |
|
|
|
{ |
|
|
|
// a_x(x-c_x)^2 + a_y(y-c_y)^2 + a_z(x-c_z)^2 - r^2
|
|
|
|
uvector<real, 3> xmin = -1, xmax = 1; |
|
|
|
uvector<real, 3> range = xmax - xmin; |
|
|
|
assert(all(range != 0)); |
|
|
|
uvector<real, 3> k = range; |
|
|
|
uvector<real, 3> bias = xmin; |
|
|
|
uvector<int, 3> ext = 2; |
|
|
|
const int planeNum = 2; |
|
|
|
std::vector<xarray<real, 3>> phiPowers(planeNum, xarray<real, 3>(nullptr, ext)); |
|
|
|
algoim_spark_alloc(real, phiPowers[0]); |
|
|
|
algoim_spark_alloc(real, phiPowers[1]); |
|
|
|
for (int i = 0; i < planeNum; i++) { xarrayInit(phiPowers[i]); } |
|
|
|
phiPowers[0].m(uvector<int, 3>(1, 0, 0)) = -1; |
|
|
|
phiPowers[0].m(uvector<int, 3>(0, 0, 0)) = -0.8; |
|
|
|
phiPowers[1].m(uvector<int, 3>(0, 1, 0)) = 1; |
|
|
|
phiPowers[1].m(uvector<int, 3>(0, 0, 0)) = -0.8; |
|
|
|
uvector<int, 3> resExt = 1 + planeNum; |
|
|
|
xarray<real, 3> phiPowerAll(nullptr, resExt), phiBernstein(nullptr, resExt); |
|
|
|
algoim_spark_alloc(real, phiPowerAll); |
|
|
|
algoim_spark_alloc(real, phiBernstein); |
|
|
|
compositePower(phiPowers, 0, 0, 1, phiPowerAll); |
|
|
|
auto v = xarray2StdVector(phiPowerAll); |
|
|
|
|
|
|
|
uvector<real, 3> testX(0., 0.75, 0.2); |
|
|
|
|
|
|
|
real testEval = powerEvaluation(phiPowerAll, testX); |
|
|
|
std::cout << "eval power before trans:" << testEval << std::endl; |
|
|
|
|
|
|
|
powerTransformation(range, xmin, phiPowerAll); |
|
|
|
|
|
|
|
real testEvalAfterTrans = powerEvaluation(phiPowerAll, testX); |
|
|
|
std::cout << "eval power after trans:" << testEvalAfterTrans << std::endl; |
|
|
|
|
|
|
|
auto vAfterTrans = xarray2StdVector(phiPowerAll); |
|
|
|
auto integrand = [](const uvector<real, 3>& x) { return 1.0; }; |
|
|
|
power2BernsteinTensorProduct(phiPowerAll, phiBernstein); |
|
|
|
// bernstein::normalise(phiBernstein);
|
|
|
|
|
|
|
|
real testEval0 = powerEvaluation(phiPowers[0], testX); |
|
|
|
std::cout << "eval power0:" << testEval0 << std::endl; |
|
|
|
|
|
|
|
real testEval1 = powerEvaluation(phiPowers[1], testX); |
|
|
|
std::cout << "eval power1:" << testEval1 << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
real testEvalBernstein = bernstein::evalBernsteinPoly(phiBernstein, testX); |
|
|
|
auto vec = xarray2StdVector(phiBernstein); |
|
|
|
std::cout << "eval bernstein:" << testEvalBernstein << std::endl; |
|
|
|
std::cout << "test2PlanesPowerDirectly" << std::endl; |
|
|
|
qConvBernstein(phiBernstein, |
|
|
|
-1, |
|
|
|
1, |
|
|
|
integrand, |
|
|
|
10, |
|
|
|
{ |
|
|
|
{1, 0, 0, -0.8}, |
|
|
|
{0, 1, 0, -0.8}, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
void testMultiScale() |
|
|
|
{ |
|
|
|
auto phi0 = [](const uvector<real, 3>& xx) { |
|
|
@ -1183,13 +1248,12 @@ void testMain() |
|
|
|
// test8PlanesAlgoim();
|
|
|
|
// test8PlanesPowerDirectly();
|
|
|
|
|
|
|
|
|
|
|
|
// test4PlanesPowerDirectly();
|
|
|
|
// test4PlanesAlgoim();
|
|
|
|
|
|
|
|
test2PlanesPowerDirectly(); |
|
|
|
|
|
|
|
// testQuarterSphere();
|
|
|
|
|
|
|
|
// testPower2Bernstein();
|
|
|
|
int a = log(2.01); |
|
|
|
std::cout << "log(3) " << a << std::endl; |
|
|
|
} |
|
|
|