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 template<>
21 double
22 ExactSolutionRHO_PHI<2>::value(const Point<2>& r,
23  const unsigned int component) const
24 {
25 
26  if (r.norm() <= a) {
27  return rho_0 * pow(a, 2) * (1.0 + 2.0 * log(b / a) - pow(r.norm() / a, 2)) /
28  (4.0 * ep_0);
29  } else {
30  return rho_0 * pow(a, 2) * log(b / r.norm()) / (2.0 * ep_0);
31  }
32 
33  return 0.0;
34 }
35 
36 template<>
37 Tensor<1, 2>
38 ExactSolutionRHO_PHI<2>::gradient(const Point<2>& r,
39  const unsigned int component) const
40 {
41 
42  if (r.norm() <= a) {
43  return -rho_0 * r / (2 * ep_0);
44  } else {
45  return -rho_0 * pow(a, 2) * r / (2.0 * ep_0 * r.norm_square());
46  }
47 
48  return Point<2>();
49 }
50 
51 template<>
52 double
53 ExactSolutionRHO_PHI<3>::value(const Point<3>& r,
54  const unsigned int component) const
55 {
56  if (r.norm() <= a) {
57  return rho_0 *
58  (pow(a, 2) + 2.0 * pow(a, 3) * (1.0 / a - 1.0 / b) -
59  r.norm_square()) /
60  (6.0 * ep_0);
61  } else {
62  return rho_0 * pow(a, 3) * (1.0 / r.norm() - 1.0 / b) / (3.0 * ep_0);
63  }
64  return 0.0;
65 }
66 
67 template<>
68 Tensor<1, 3>
69 ExactSolutionRHO_PHI<3>::gradient(const Point<3>& r,
70  const unsigned int component) const
71 {
72  if (r.norm() < a) {
73  return -rho_0 * r / (3.0 * ep_0);
74  } else {
75  return -rho_0 * pow(a, 3) * r / (3.0 * ep_0 * pow(r.norm(), 3));
76  }
77 
78  return Point<3>();
79 }
80 
81 #pragma GCC diagnostic pop
Describes exact solution, , of the Volume charge (rho/) numerical experiment in two and three dimensi...