LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
whitney_one_curl_convergence_test.cc
1
5#include <whitney_one_curl_test.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_one = [&](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 << -y, x, 0;
37 return ret;
38 };
39
40 // Compute the analytic solution of the problem
41 auto u_two = [&](const Eigen::Vector3d x_vec) -> double {
42 // first scale to the circle
43 Eigen::Vector3d x_ = x_vec / x_vec.norm();
44 double x = x_(0);
45 double y = x_(1);
46 double z = x_(2);
47
48 return sin(z);
49 };
50
51 double ana_sol = -7.5691944739878640736;
52
54 test.SetAnaSol(ana_sol);
55 test.SetFunctions(u_two, u_one);
56 test.Compute(refinement_level);
57
58 return 0;
59}
Tests convergence of the below bilinear form on the Mesh to the analytical solution.
void Compute(int max_ref)
Computes the error up to the refinemet level 'max_ref'.
void SetAnaSol(double sol)
Sets the value of the analytical solution .
void SetFunctions(std::function< double(const Eigen::Matrix< double, 3, 1 > &)> v, std::function< Eigen::Matrix< double, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> u)
Sets the test functions.