LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
dirac_operator_debug_only_zero.cc
1
9#include <dirac_operator_experiment.h>
10
11using lf::uscalfe::operator-;
12using complex = std::complex<double>;
13
18int main(int argc, char *argv[]) {
19 if (argc != 4 && argc != 5) {
20 std::cerr << "Usage: " << argv[0]
21 << " max_refinement_level min_k max_k step=0.1 " << std::endl;
22 exit(1);
23 }
24
25 double min_k;
26 double max_k;
27 double step = 0.1;
28 const unsigned refinement_level = atoi(argv[1]);
29 sscanf(argv[2], "%lf", &min_k);
30 sscanf(argv[3], "%lf", &max_k);
31 if (argc == 5) sscanf(argv[4], "%lf", &step);
32 std::cout << "max_refinement_level : " << refinement_level << std::endl;
33 std::cout << "min_k : " << min_k << ", max_k = " << max_k
34 << " step = " << step << std::endl;
35
36 // needs to be a reference such that it can be reassigned
37 double &k = min_k;
38
39 std::vector<unsigned> refinement_levels(refinement_level + 1);
40 for (int i = 0; i < refinement_level + 1; i++) {
41 refinement_levels[i] = i;
42 }
43
44 std::vector<double> ks;
45 for (double i = min_k; i <= max_k; i += step) {
46 ks.push_back(i);
47 }
48
49 // mathematica function output requries the following helpers
50 auto Power = [](complex a, complex b) -> complex { return std::pow(a, b); };
51 auto Complex = [](double a, double b) -> complex { return complex(a, b); };
52 auto Sin = [](complex a) -> complex { return std::sin(a); };
53 auto Cos = [](complex a) -> complex { return std::cos(a); };
54 auto Sqrt = [](complex a) -> complex { return std::sqrt(a); };
55
56 // righthandside for the zero and two form
57 auto f_zero = [&](const Eigen::Vector3d &x_vec) -> complex {
58 // first scale to the circle
59 Eigen::Vector3d x_ = x_vec;
60 double x = x_(0);
61 double y = x_(1);
62 double z = x_(2);
63
64 // autogenerated by mathematica
65 complex ret = Complex(0, 1) * k * (Cos(y) + Sin(x) + Sin(z));
66 return ret;
67 };
68
69 // righthandside for the one form
70 auto f_one = [&](const Eigen::Vector3d &x_vec) -> Eigen::VectorXcd {
71 // first scale to the circle
72 Eigen::Vector3d x_ = x_vec;
73 double x = x_(0);
74 double y = x_(1);
75 double z = x_(2);
76
77 // autogenerated by mathematica
78 Eigen::VectorXcd ret(3);
79 ret << ((Power(y, 2) + Power(z, 2)) * Cos(x) - x * z * Cos(z) +
80 x * y * Sin(y)) /
81 (Power(x, 2) + Power(y, 2) + Power(z, 2)),
82 -((x * y * Cos(x) + y * z * Cos(z) +
83 (Power(x, 2) + Power(z, 2)) * Sin(y)) /
84 (Power(x, 2) + Power(y, 2) + Power(z, 2))),
85 (-(x * z * Cos(x)) + (Power(x, 2) + Power(y, 2)) * Cos(z) +
86 y * z * Sin(y)) /
87 (Power(x, 2) + Power(y, 2) + Power(z, 2));
88 return ret;
89 };
90
91 // righthandside for the two form
92 auto f_two = [&](const Eigen::Vector3d &x_vec) -> complex {
93 // first scale to the circle
94 Eigen::Vector3d x_ = x_vec;
95 double x = x_(0);
96 double y = x_(1);
97 double z = x_(2);
98
99 // autogenerated by mathematica
100 complex ret = 0;
101 return ret;
102 };
103
104 // Compute the analytic solution of the problem
105 auto u_zero = [&](const Eigen::Vector3d x_vec) -> complex {
106 // first scale to the circle
107 Eigen::Vector3d x_ = x_vec;
108 double x = x_(0);
109 double y = x_(1);
110 double z = x_(2);
111
112 return Cos(y) + Sin(x) + Sin(z);
113 };
114
115 // Compute the analytic solution of the problem
116 auto u_one = [&](const Eigen::Vector3d x_vec) -> Eigen::Vector3cd {
117 // first scale to the circle
118 Eigen::Vector3d x_ = x_vec;
119 double x = x_(0);
120 double y = x_(1);
121 double z = x_(2);
122
123 Eigen::VectorXcd ret(3);
124
125 ret << 0, 0, 0;
126 return ret;
127 };
128
129 // Compute the analytic solution of the problem
130 auto u_two = [&](const Eigen::Vector3d x_vec) -> complex {
131 // first scale to the circle
132 Eigen::Vector3d x_ = x_vec;
133 double x = x_(0);
134 double y = x_(1);
135 double z = x_(2);
136
137 return 0;
138 };
139
141 u_zero, u_one, u_two, f_zero, f_one, f_two, k, "debug_only_zero");
142
143 experiment.Compute(refinement_levels, ks);
144
145 return 0;
146}
Creates and solves the discretised Dirac Operator source problems for a given list of levels and valu...