Skip to content

Commit

Permalink
core submodule update (geometry module), tests adapted to geometry in…
Browse files Browse the repository at this point in the history
…terface
  • Loading branch information
AlePalu committed May 2, 2024
1 parent 811da5c commit 1526b19
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 225 deletions.
2 changes: 1 addition & 1 deletion fdaPDE/core
Submodule core updated 42 files
+98 −107 fdaPDE/finite_elements/basis/lagrangian_basis.h
+10 −12 fdaPDE/finite_elements/fem_assembler.h
+17 −22 fdaPDE/finite_elements/solvers/fem_solver_base.h
+10 −7 fdaPDE/geometry.h
+0 −114 fdaPDE/geometry/element.h
+16 −8 fdaPDE/geometry/hyperplane.h
+138 −0 fdaPDE/geometry/interval.h
+0 −6 fdaPDE/geometry/kd_tree.h
+0 −484 fdaPDE/geometry/mesh.h
+0 −75 fdaPDE/geometry/mesh_utils.h
+0 −47 fdaPDE/geometry/point_location/naive_search.h
+0 −54 fdaPDE/geometry/point_location/point_location.h
+0 −73 fdaPDE/geometry/point_location/tree_search.h
+56 −0 fdaPDE/geometry/segment.h
+179 −0 fdaPDE/geometry/simplex.h
+140 −0 fdaPDE/geometry/tetrahedron.h
+79 −0 fdaPDE/geometry/tree_search.h
+97 −0 fdaPDE/geometry/triangle.h
+454 −0 fdaPDE/geometry/triangulation.h
+122 −0 fdaPDE/geometry/utils.h
+295 −0 fdaPDE/geometry/voronoi.h
+26 −16 fdaPDE/geometry/walk_search.h
+72 −5 fdaPDE/linear_algebra/binary_matrix.h
+3 −4 fdaPDE/pde/pde.h
+59 −52 fdaPDE/utils/integration/integrator.h
+3 −1 fdaPDE/utils/symbols.h
+2 −2 test/main.cpp
+5 −13 test/run_tests.sh
+23 −3 test/src/binary_matrix_test.cpp
+0 −161 test/src/element_test.cpp
+8 −8 test/src/fem_operators_test.cpp
+15 −23 test/src/fem_pde_test.cpp
+6 −7 test/src/integration_test.cpp
+21 −24 test/src/lagrangian_basis_test.cpp
+0 −194 test/src/mesh_test.cpp
+8 −24 test/src/point_location_test.cpp
+119 −0 test/src/simplex_test.cpp
+119 −0 test/src/simplex_text.cpp
+5 −5 test/src/spline_test.cpp
+22 −30 test/src/utils/mesh_loader.h
+36 −30 test/src/utils/utils.h
+119 −0 test/src/voronoi_test.cpp
5 changes: 3 additions & 2 deletions test/src/centering_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using fdapde::core::FEM;
using fdapde::core::Grid;
using fdapde::core::laplacian;
using fdapde::core::PDE;
using fdapde::core::Triangulation;

#include "../../fdaPDE/models/regression/srpde.h"
#include "../../fdaPDE/models/regression/gcv.h"
Expand Down Expand Up @@ -54,12 +55,12 @@ using fdapde::testing::read_csv;
// GCV optimization: grid stochastic
TEST(centering_test, srpde_gcv_stochastic_grid) {
// define domain
MeshLoader<Mesh2D> domain("unit_square");
MeshLoader<Triangulation<2, 2>> domain("unit_square");
// import data from files
DMatrix<double> X = read_csv<double>("../data/models/centering/2D_test1/X.csv");
// define regularizing PDE
auto L = -laplacian<FEM>();
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_elements() * 3, 1);
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_cells() * 3, 1);
PDE<decltype(domain.mesh), decltype(L), DMatrix<double>, FEM, fem_order<1>> pde(domain.mesh, L, u);
// perform centering
DMatrix<double> lambda_grid(12, 1);
Expand Down
35 changes: 18 additions & 17 deletions test/src/fpca_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ using fdapde::core::FEM;
using fdapde::core::fem_order;
using fdapde::core::laplacian;
using fdapde::core::PDE;
using fdapde::core::Triangulation;

#include "../../fdaPDE/models/functional/fpca.h"
#include "../../fdaPDE/models/sampling_design.h"
Expand All @@ -40,7 +41,7 @@ using fdapde::testing::almost_equal;
using fdapde::testing::MeshLoader;
using fdapde::testing::read_csv;
using fdapde::testing::read_mtx;

/*
// test 1
// domain: unit square [1,1] x [1,1]
// sampling: locations = nodes
Expand All @@ -51,12 +52,12 @@ using fdapde::testing::read_mtx;
// solver: sequential (power iteration)
TEST(fpca_test, laplacian_samplingatnodes_sequential) {
// define domain
MeshLoader<Mesh2D> domain("unit_square");
MeshLoader<Triangulation<2, 2>> domain("unit_square");
// import data from files
DMatrix<double> y = read_csv<double>("../data/models/fpca/2D_test1/y.csv");
// define regularizing PDE
auto L = -laplacian<FEM>();
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_elements() * 3, 1);
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_cells() * 3, 1);
PDE<decltype(domain.mesh), decltype(L), DMatrix<double>, FEM, fem_order<1>> pde(domain.mesh, L, u);
// define model
double lambda_D = 1e-2;
Expand Down Expand Up @@ -84,12 +85,12 @@ TEST(fpca_test, laplacian_samplingatnodes_sequential) {
// solver: monolithic (rsvd)
TEST(fpca_test, laplacian_samplingatnodes_monolithic) {
// define domain
MeshLoader<Mesh2D> domain("unit_square");
MeshLoader<Triangulation<2, 2>> domain("unit_square");
// import data from files
DMatrix<double> y = read_csv<double>("../data/models/fpca/2D_test1/y.csv");
// define regularizing PDE
auto L = -laplacian<FEM>();
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_elements() * 3, 1);
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_cells() * 3, 1);
PDE<decltype(domain.mesh), decltype(L), DMatrix<double>, FEM, fem_order<1>> problem(domain.mesh, L, u);
// define model
double lambda_D = 1e-2;
Expand All @@ -106,7 +107,7 @@ TEST(fpca_test, laplacian_samplingatnodes_monolithic) {
EXPECT_TRUE(almost_equal(model.Psi() * model.loadings(), "../data/models/fpca/2D_test1/loadings_mon.mtx"));
EXPECT_TRUE(almost_equal(model.scores(), "../data/models/fpca/2D_test1/scores_mon.mtx" ));
}

*/
// test 3
// domain: unit square [1,1] x [1,1]
// sampling: locations != nodes
Expand All @@ -117,13 +118,13 @@ TEST(fpca_test, laplacian_samplingatnodes_monolithic) {
// solver: sequential (power iteration) + GCV \lambda selection
TEST(fpca_test, laplacian_samplingatlocations_sequential_gcv) {
// define domain
MeshLoader<Mesh2D> domain("unit_square");
MeshLoader<Triangulation<2, 2>> domain("unit_square");
// import data from files
DMatrix<double> locs = read_csv<double>("../data/models/fpca/2D_test2/locs.csv");
DMatrix<double> y = read_csv<double>("../data/models/fpca/2D_test2/y.csv");
// define regularizing PDE
auto L = -laplacian<FEM>();
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_elements() * 3, 1);
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_cells() * 3, 1);
PDE<decltype(domain.mesh), decltype(L), DMatrix<double>, FEM, fem_order<1>> pde(domain.mesh, L, u);
// grid of smoothing parameters
DMatrix<double> lambda_grid(20, 1);
Expand Down Expand Up @@ -156,13 +157,13 @@ TEST(fpca_test, laplacian_samplingatlocations_sequential_gcv) {
// solver: sequential (power iteration) + KCV \lambda selection
TEST(fpca_test, laplacian_samplingatlocations_sequential_kcv) {
// define domain
MeshLoader<Mesh2D> domain("unit_square");
MeshLoader<Triangulation<2, 2>> domain("unit_square");
// import data from files
DMatrix<double> locs = read_csv<double>("../data/models/fpca/2D_test3/locs.csv");
DMatrix<double> y = read_csv<double>("../data/models/fpca/2D_test3/y.csv");
// define regularizing PDE
auto L = -laplacian<FEM>();
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_elements() * 3, 1);
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_cells() * 3, 1);
PDE<decltype(domain.mesh), decltype(L), DMatrix<double>, FEM, fem_order<1>> problem(domain.mesh, L, u);
// grid of smoothing parameters
DMatrix<double> lambda_grid(20, 1);
Expand Down Expand Up @@ -195,18 +196,18 @@ TEST(fpca_test, laplacian_samplingatlocations_sequential_kcv) {
// solver: sequential (power iteration)
// TEST(fpca_test, laplacian_samplingatnodes_separable_sequential) {
// // define time domain
// Mesh<1, 1> time_mesh(0, 1, 14);
// Triangulation<1, 1> time_mesh(0, 1, 14);
// // define domain and regularizing PDE
// MeshLoader<Mesh2D> domain("unit_square15");
// MeshLoader<Triangulation<2, 2>> domain("unit_square15");
// // import data from files
// DMatrix<double> y = read_csv<double>("../data/models/fpca/2D_test5/y.csv");
// // define regularizing PDE in space
// auto Ld = -laplacian<FEM>();
// DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_elements() * 3 * time_mesh.n_nodes(), 1);
// PDE<Mesh<2, 2>, decltype(Ld), DMatrix<double>, FEM, fem_order<1>> space_penalty(domain.mesh, Ld, u);
// DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_cells() * 3 * time_mesh.n_nodes(), 1);
// PDE<Triangulation<2, 2>, decltype(Ld), DMatrix<double>, FEM, fem_order<1>> space_penalty(domain.mesh, Ld, u);
// // define regularizing PDE in time
// auto Lt = -bilaplacian<SPLINE>();
// PDE<Mesh<1, 1>, decltype(Lt), DMatrix<double>, SPLINE, spline_order<3>> time_penalty(time_mesh, Lt);
// PDE<Triangulation<1, 1>, decltype(Lt), DMatrix<double>, SPLINE, spline_order<3>> time_penalty(time_mesh, Lt);
// // define model
// double lambda_D = std::pow(10, -3.6); // 1e-3.6
// double lambda_T = std::pow(10, -2.2); // 1e-2.2
Expand Down Expand Up @@ -235,12 +236,12 @@ TEST(fpca_test, laplacian_samplingatlocations_sequential_kcv) {
// missing data: yes
TEST(fpca_test, laplacian_samplingatnodes_nocalibration_missingdata) {
// define domain
MeshLoader<Mesh2D> domain("unit_square_coarse");
MeshLoader<Triangulation<2, 2>> domain("unit_square_coarse");
// import data from files
DMatrix<double> y = read_csv<double>("../data/models/fpca/2D_test4/y.csv");
// define regularizing PDE
auto L = -laplacian<FEM>();
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_elements() * 3, 1);
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_cells() * 3, 1);
PDE<decltype(domain.mesh), decltype(L), DMatrix<double>, FEM, fem_order<1>> problem(domain.mesh, L, u);
// define model
double lambda_D = 1e-2;
Expand Down
9 changes: 5 additions & 4 deletions test/src/fpls_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ using fdapde::core::fem_order;
using fdapde::core::laplacian;
using fdapde::core::PDE;
using fdapde::core::Grid;
using fdapde::core::Triangulation;

#include "../../fdaPDE/models/regression/srpde.h"
using fdapde::models::SRPDE;
Expand Down Expand Up @@ -59,13 +60,13 @@ using fdapde::testing::read_mtx;
// solver: sequential (power iteration) without calibration
TEST(fpls_test, laplacian_samplingatnodes_sequential_off) {
// define domain
MeshLoader<Mesh2D> domain("unit_square");
MeshLoader<Triangulation<2, 2>> domain("unit_square");
// import data from files
DMatrix<double> X = read_csv<double>("../data/models/fpls/2D_test1/X.csv");
DMatrix<double> Y = read_csv<double>("../data/models/fpls/2D_test1/Y.csv");
// define regularizing PDE
auto L = -laplacian<FEM>();
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_elements() * 3, 1);
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_cells() * 3, 1);
PDE<decltype(domain.mesh), decltype(L), DMatrix<double>, FEM, fem_order<1>> pde(domain.mesh, L, u);
// define model
double lambda_D = 10.0;
Expand Down Expand Up @@ -104,13 +105,13 @@ TEST(fpls_test, laplacian_samplingatnodes_sequential_off) {
// solver: sequential (power iteration) with GCV calibration
TEST(fpls_test, laplacian_samplingatnodes_sequential_gcv) {
// define domain
MeshLoader<Mesh2D> domain("unit_square");
MeshLoader<Triangulation<2, 2>> domain("unit_square");
// import data from files
DMatrix<double> X = read_csv<double>("../data/models/fpls/2D_test2/X.csv");
DMatrix<double> Y = read_csv<double>("../data/models/fpls/2D_test2/Y.csv");
// define regularizing PDE
auto L = -laplacian<FEM>();
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_elements() * 3, 1);
DMatrix<double> u = DMatrix<double>::Zero(domain.mesh.n_cells() * 3, 1);
PDE<decltype(domain.mesh), decltype(L), DMatrix<double>, FEM, fem_order<1>> pde(domain.mesh, L, u);
// define model
std::size_t seed = 476813;
Expand Down
Loading

0 comments on commit 1526b19

Please sign in to comment.