#include <Eigen/Core>
#include "gtest/gtest.h"
TEST(Interpolants, PUApproximant1D) {
BoxShape<Vec1d> b(0, 1);
DomainDiscretization<Vec1d> domain = b.discretizeBoundaryWithStep(0.01);
int support_size = 2;
domain.findSupport(FindClosest(support_size));
Eigen::VectorXd values(2);
for (int i = 0; i < values.size(); i++) {
values[i] = static_cast<double>(i);
}
RBFFD<Polyharmonic<double>,
Vec1d, ScaleToClosest> approx({3}, Monomials<Vec1d>(2));
Range<Vec1d> test_points(1);
test_points[0] =
Vec1d(0.5);
double effective_radius = 1.0;
approx);
EXPECT_NEAR(0.5, value[0], 1e-15);
}
TEST(Interpolants, PUApproximant2D) {
BoxShape<Vec2d> b(0, 1);
DomainDiscretization<Vec2d> domain = b.discretizeWithStep(0.05);
int support_size = 15;
domain.findSupport(FindClosest(support_size));
Eigen::VectorXd values(domain.size());
values.setOnes();
RBFFD<Polyharmonic<double>,
Vec2d, ScaleToClosest> approx({3}, Monomials<Vec2d>(2));
BoxShape<Vec2d> b_test(0, 1);
DomainDiscretization<Vec2d> domain_test = b_test.discretizeWithStep(0.1);
auto test_points = domain_test.positions();
double effective_radius = 1.0;
auto interpolated_values =
for (auto value : interpolated_values) {
EXPECT_NEAR(1, value, 1e-15);
}
}
TEST(Interpolants, PUApproximant2DNotConstant) {
BoxShape<Vec2d> b(0, 1);
DomainDiscretization<Vec2d> domain = b.discretizeBoundaryWithStep(1);
int support_size = 4;
domain.findSupport(FindClosest(support_size));
int N = domain.size();
Eigen::VectorXd values(N);
for (int i = 0; i < N; i++) {
values[i] = i;
}
RBFFD<Polyharmonic<double>,
Vec2d, ScaleToClosest> approx({3}, Monomials<Vec2d>(2));
Range<Vec2d> test_points;
test_points.push_back(
Vec2d(0.5, 0.5));
double effective_radius = 1.0;
auto num_values =
EXPECT_NEAR(1, num_values[0], 1e-15);
}
TEST(Interpolants, PUApproximant3D) {
BoxShape<Vec3d> b(0, 1);
DomainDiscretization<Vec3d> domain = b.discretizeWithStep(0.1);
int support_size = 30;
domain.findSupport(FindClosest(support_size));
Eigen::VectorXd values(domain.size());
values.setOnes();
RBFFD<Polyharmonic<double>,
Vec3d, ScaleToClosest> approx({3}, Monomials<Vec3d>(2));
BoxShape<Vec3d> b_test(0, 1);
DomainDiscretization<Vec3d> domain_test = b_test.discretizeWithStep(0.2);
auto test_points = domain_test.positions();
double effective_radius = 1.0;
auto interpolated_values =
for (auto value : interpolated_values) {
EXPECT_NEAR(1, value, 1e-15);
}
}
TEST(Interpolants, PUApproximantKDTree1D) {
BoxShape<Vec1d> b(0, 1);
DomainDiscretization<Vec1d> domain = b.discretizeBoundaryWithStep(0.01);
int support_size = 2;
domain.findSupport(FindClosest(support_size));
Eigen::VectorXd values(2);
for (int i = 0; i < values.size(); i++) {
values[i] = static_cast<double>(i);
}
RBFFD<Polyharmonic<double>,
Vec1d, ScaleToClosest> approx({3}, Monomials<Vec1d>(2));
Range<Vec1d> test_points(1);
test_points[0] =
Vec1d(0.5);
KDTree<Vec1d> tree(test_points);
double effective_radius = 1.0;
approx);
EXPECT_NEAR(0.5, value[0], 1e-15);
}
TEST(Interpolants, PUApproximantKDTree2D) {
BoxShape<Vec2d> b(0, 1);
DomainDiscretization<Vec2d> domain = b.discretizeWithStep(0.05);
int support_size = 15;
domain.findSupport(FindClosest(support_size));
Eigen::VectorXd values(domain.size());
values.setOnes();
RBFFD<Polyharmonic<double>,
Vec2d, ScaleToClosest> approx({3}, Monomials<Vec2d>(2));
BoxShape<Vec2d> b_test(0, 1);
DomainDiscretization<Vec2d> domain_test = b_test.discretizeWithStep(0.1);
auto test_points = domain_test.positions();
KDTree<Vec2d> tree(test_points);
double effective_radius = 1.0;
auto interpolated_values =
for (auto value : interpolated_values) {
EXPECT_NEAR(1, value, 1e-15);
}
}
TEST(Interpolants, PUApproximantKDTree3D) {
BoxShape<Vec3d> b(0, 1);
DomainDiscretization<Vec3d> domain = b.discretizeWithStep(0.1);
int support_size = 30;
domain.findSupport(FindClosest(support_size));
Eigen::VectorXd values(domain.size());
values.setOnes();
RBFFD<Polyharmonic<double>,
Vec3d, ScaleToClosest> approx({3}, Monomials<Vec3d>(2));
BoxShape<Vec3d> b_test(0, 1);
DomainDiscretization<Vec3d> domain_test = b_test.discretizeWithStep(0.2);
auto test_points = domain_test.positions();
KDTree<Vec3d> tree(test_points);
double effective_radius = 1.0;
auto interpolated_values =
for (auto value : interpolated_values) {
EXPECT_NEAR(1, value, 1e-15);
}
}
}