basix
basix copied to clipboard
Test the cpp interface
Currently all the tests use the Python interface (via wrapper.cpp).
It would be good to add tests that directly interface through cpp so we can test this without having to use the dolfin tests
Simple "failing" example that we could test in c++:
#include <Eigen/Core>
#include <basix.h>
#include <iostream>
int main()
{
int handle = basix::register_element("Lagrange", "triangle", 1);
int tdim = 2;
int num_points = 2;
int d = 3;
Eigen::Array<double, -1, -1, Eigen::RowMajor> basis_values(
(tdim + 1) * num_points, d);
Eigen::Array<double, -1, -1, Eigen::RowMajor> x(num_points, tdim);
x.row(0) << 0, 0;
x.row(1) << 0.5, 0.5;
basix::tabulate(handle, basis_values.data(), 1, x.data(), num_points);
std::cout << basis_values;
for (int i = 0; i < num_points; i++)
{
Eigen::Array<double, -1, -1, Eigen::RowMajor> basis_values_i((tdim + 1), d);
basix::tabulate(handle, basis_values_i.data(), 1, x.row(i).data(), 1);
std::cout << " \n\n" << basis_values_i;
}
return 0;
}