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 ExactSolutionMWR_A::value(const Point<2>& r, const unsigned int component) const
22 {
23  if (r.norm() < a) {
24  return -0.25 * mu * J_f * (r[0] * r[0] + r[1] * r[1]) + A_0;
25  } else {
26  return -0.25 * mu_0 * J_f * a * a *
27  log(exp(mu_r) * (r[0] * r[0] + r[1] * r[1]) / (a * a)) +
28  A_0;
29  }
30 }
31 
32 Tensor<1, 2>
33 ExactSolutionMWR_A::gradient(const Point<2>& r,
34  const unsigned int component) const
35 {
36  Point<2> grad_A;
37 
38  if (r.norm() <= a) {
39  grad_A(0) = -0.5 * mu * J_f * r[0];
40  grad_A(1) = -0.5 * mu * J_f * r[1];
41  } else {
42  grad_A(0) = -0.5 * mu_0 * J_f * a * a * r[0] / (r[0] * r[0] + r[1] * r[1]);
43  grad_A(1) = -0.5 * mu_0 * J_f * a * a * r[1] / (r[0] * r[0] + r[1] * r[1]);
44  }
45 
46  return grad_A;
47 }
48 
49 void
50 ExactSolutionMWR_H::vector_value_list(const std::vector<Point<2>>& r,
51  std::vector<Vector<double>>& values) const
52 {
53  Assert(values.size() == r.size(),
54  ExcDimensionMismatch(values.size(), r.size()));
55 
56  Tensor<1, 2> grad_A;
57  double coef;
58 
59  for (unsigned int i = 0; i < r.size(); i++) {
60  if (r[i].norm() < a) {
61  coef = mu;
62  } else {
63  coef = mu_0;
64  }
65 
66  grad_A = A.gradient(r[i]);
67  values[i][0] = grad_A[1] / coef;
68  values[i][1] = -grad_A[0] / coef;
69  }
70 }
71 
72 void
73 ExactSolutionMWR_B::vector_value_list(const std::vector<Point<2>>& r,
74  std::vector<Vector<double>>& values) const
75 {
76  Assert(values.size() == r.size(),
77  ExcDimensionMismatch(values.size(), r.size()));
78 
79  Tensor<1, 2> grad_A;
80 
81  for (unsigned int i = 0; i < r.size(); i++) {
82  grad_A = A.gradient(r[i]);
83  values[i][0] = grad_A[1];
84  values[i][1] = -grad_A[0];
85  }
86 }
87 
88 #pragma GCC diagnostic pop