Logbook  (07-04-2025)
Static problems
exact_solution.cpp
1 /******************************************************************************
2  * Copyright (C) Siarhei Uzunbajakau, 2023.
3  *
4  * This program is free software. You can use, modify, and redistribute it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation, either version 3 or (at your option) any later version.
7  * This program is distributed without any warranty.
8  *
9  * Refer to COPYING.LESSER for more details.
10  ******************************************************************************/
11 
12 #include "exact_solution.hpp"
13 
14 #pragma GCC diagnostic push
15 #pragma GCC diagnostic ignored "-Wunused-parameter"
16 
17 using namespace dealii;
18 using namespace std;
19 
20 double
21 ExactSolutionSSOLIIAXI_A::value(const Point<2>& p,
22  const unsigned int component) const
23 {
24  double s = p.norm();
25  double r = p[0];
26 
27  double rG1 = mu_0 * K_0 * pow(r, 2) / 3.0;
28  double rG2 = mu_0 * K_0 * pow(r, 2) / (3.0 * pow(s, 3));
29 
30  if (s < a)
31  return 0.5 * (pow(b, 2) - pow(a, 2)) * rG1;
32 
33  if (s < b)
34  return (0.5 * (pow(b, 2) - pow(s, 2)) * rG1 +
35  0.2 * (pow(s, 5) - pow(a, 5)) * rG2);
36 
37  return 0.2 * (pow(b, 5) - pow(a, 5)) * rG2;
38 }
39 
40 Tensor<1, 2>
41 ExactSolutionSSOLIIAXI_A::gradient(const Point<2>& p,
42  const unsigned int component) const
43 {
44  Point<2> grad_A, L1, L2;
45 
46  double s = p.norm();
47  double r = p[0];
48  double z = p[1];
49  double M = (1.0 / 3.0) * mu_0 * K_0;
50 
51  L1(0) = 2.0 * M * r;
52  L1(1) = 0.0;
53 
54  L2(0) = M * (2.0 * r / pow(s, 3) - 3.0 * pow(r, 3) / pow(s, 5));
55  L2(1) = -M * 3.0 * pow(r, 2) * z / pow(s, 5);
56 
57  if (s < a) {
58  grad_A = 0.5 * (pow(b, 2) - pow(a, 2)) * L1;
59  } else if (s < b) {
60  grad_A =
61  0.5 * (pow(b, 2) - pow(s, 2)) * L1 + 0.2 * (pow(s, 5) - pow(a, 5)) * L2;
62  } else {
63  grad_A = 0.2 * (pow(b, 5) - pow(a, 5)) * L2;
64  }
65 
66  return grad_A;
67 }
68 
69 void
70 ExactSolutionSSOLIIAXI_B::vector_value_list(
71  const std::vector<Point<2>>& r,
72  std::vector<Vector<double>>& values) const
73 {
74  Assert(values.size() == r.size(),
75  ExcDimensionMismatch(values.size(), r.size()));
76 
77  Tensor<1, 3> B;
78 
79  for (unsigned int i = 0; i < values.size(); i++) {
80  B = magnetic_field(0.0, r[i][0], r[i][1], K_0, mu_0, a, b);
81 
82  values[i][0] = r[i][0] * B[1];
83  values[i][1] = r[i][0] * B[2];
84  }
85 }
86 
87 void
88 ExactSolutionSSOLIIAXI_H::vector_value_list(
89  const std::vector<Point<2>>& r,
90  std::vector<Vector<double>>& values) const
91 {
92  Assert(values.size() == r.size(),
93  ExcDimensionMismatch(values.size(), r.size()));
94 
95  B.vector_value_list(r, values);
96 
97  for (unsigned int i = 0; i < r.size(); i++) {
98  values[i][0] = values[i][0] / mu_0;
99  values[i][1] = values[i][1] / mu_0;
100  }
101 }
102 
103 #pragma GCC diagnostic pop