LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
whitney_one_basis_expansion_test.cc
1
5#include <whitney_one_basis_expansion_coeffs.h>
6
10int main(int argc, char *argv[]) {
11 if (argc != 2) {
12 std::cerr << "Usage: " << argv[0] << " max_refinement_level " << std::endl;
13 exit(1);
14 }
15
16 unsigned refinement_level = atoi(argv[1]);
17 std::cout << "max_refinement_level : " << refinement_level << std::endl;
18
19 // mathematica function output requries the following helpers
20 auto Power = [](double a, double b) -> double { return std::pow(a, b); };
21 auto Sin = [](double a) -> double { return std::sin(a); };
22 auto Cos = [](double a) -> double { return std::cos(a); };
23 auto Sqrt = [](double a) -> double { return std::sqrt(a); };
24
25 // Compute the analytic solution of the problem
26 auto u = [&](const Eigen::Vector3d x_vec) -> Eigen::Vector3d {
27 // first scale to the circle
28 Eigen::Vector3d x_ = x_vec / x_vec.norm();
29 double x = x_(0);
30 double y = x_(1);
31 double z = x_(2);
32
33 Eigen::VectorXd ret(3);
34
35 // mathematica autocompute
36 ret << (-(x * z * Sin(x)) + (Power(y, 2) + Power(z, 2)) * Sin(y) -
37 x * y * Sin(z)) /
38 (Power(x, 2) + Power(y, 2) + Power(z, 2)),
39 (-(y * z * Sin(x)) - x * y * Sin(y) +
40 (Power(x, 2) + Power(z, 2)) * Sin(z)) /
41 (Power(x, 2) + Power(y, 2) + Power(z, 2)),
42 ((Power(x, 2) + Power(y, 2)) * Sin(x) - z * (x * Sin(y) + y * Sin(z))) /
43 (Power(x, 2) + Power(y, 2) + Power(z, 2));
44 return ret;
45 };
46
48 refinement_level, u);
49
50 return 0;
51}
static void Experiemnt(unsigned refinement_level, std::function< Eigen::Vector3d(const Eigen::Vector3d &)> u)