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 #include <cmath>
14 
15 #pragma GCC diagnostic push
16 #pragma GCC diagnostic ignored "-Wunused-parameter"
17 
18 using namespace dealii;
19 using namespace std;
20 
21 template<>
23 {
24  alpha = 1.0 / (ep_1 * log(b / d) + ep_2 * log(d / a));
25  beta = (ep_1 / ep_2) * log(b / d);
26 }
27 
28 template<>
29 double
30 ExactSolutionINT_PHI<2>::value(const Point<2>& r,
31  const unsigned int component) const
32 {
33  if (r.norm() < d)
34  return (-alpha * ep_2 * (log(r.norm() / d) - beta));
35  else
36  return (-alpha * ep_1 * log(r.norm() / b));
37 }
38 
39 template<>
40 Tensor<1, 2>
41 ExactSolutionINT_PHI<2>::gradient(const Point<2>& r,
42  const unsigned int component) const
43 {
44  if (r.norm() < d)
45  return -alpha * ep_2 * (1 / r.square()) * r;
46  else
47  return -alpha * ep_1 * (1 / r.square()) * r;
48 }
49 
50 template<>
52 {
53  alpha = 1.0 / (ep_1 * (1.0 / b - 1.0 / d) + ep_2 * (1.0 / d - 1.0 / a));
54  beta = 1.0 / d + (ep_1 / ep_2) * (1.0 / b - 1.0 / d);
55 }
56 
57 template<>
58 double
59 ExactSolutionINT_PHI<3>::value(const Point<3>& r,
60  const unsigned int component) const
61 {
62  if (r.norm() < d)
63  return (-alpha * ep_2 * (1.0 / r.norm() - beta));
64  else
65  return (-alpha * ep_1 * (1.0 / r.norm() - 1.0 / b));
66 }
67 
68 template<>
69 Tensor<1, 3>
70 ExactSolutionINT_PHI<3>::gradient(const Point<3>& r,
71  const unsigned int component) const
72 {
73  if (r.norm() < d)
74  return alpha * ep_2 * r / pow(r.norm(), 3);
75  else
76  return alpha * ep_1 * r / pow(r.norm(), 3);
77 }
78 
79 template<>
80 void
82  const std::vector<Point<2>>& r,
83  std::vector<Vector<double>>& values) const
84 {
85  Assert(values.size() == r.size(),
86  ExcDimensionMismatch(values.size(), r.size()));
87 
88  Tensor<1, 2> phi;
89 
90  for (unsigned int i = 0; i < r.size(); i++) {
91  phi = PHI.gradient(r[i]);
92 
93  values[i][0] = -phi[0];
94  values[i][1] = -phi[1];
95  }
96 }
97 
98 template<>
99 void
101  const std::vector<Point<3>>& r,
102  std::vector<Vector<double>>& values) const
103 {
104  Assert(values.size() == r.size(),
105  ExcDimensionMismatch(values.size(), r.size()));
106 
107  Tensor<1, 3> phi;
108 
109  for (unsigned int i = 0; i < r.size(); i++) {
110  phi = PHI.gradient(r[i]);
111 
112  values[i][0] = -phi[0];
113  values[i][1] = -phi[1];
114  values[i][2] = -phi[2];
115  }
116 }
117 
118 template<>
119 void
121  const std::vector<Point<2>>& r,
122  std::vector<Vector<double>>& values) const
123 {
124  Assert(values.size() == r.size(),
125  ExcDimensionMismatch(values.size(), r.size()));
126 
127  double ep;
128  Tensor<1, 2> phi;
129 
130  for (unsigned int i = 0; i < r.size(); i++) {
131  ep = ep_2;
132 
133  if (r[i].norm() < d)
134  ep = ep_1;
135 
136  phi = PHI.gradient(r[i]);
137 
138  values[i][0] = -ep * phi[0];
139  values[i][1] = -ep * phi[1];
140  }
141 }
142 
143 template<>
144 void
146  const std::vector<Point<3>>& r,
147  std::vector<Vector<double>>& values) const
148 {
149  Assert(values.size() == r.size(),
150  ExcDimensionMismatch(values.size(), r.size()));
151 
152  double ep;
153  Tensor<1, 3> phi;
154 
155  for (unsigned int i = 0; i < r.size(); i++) {
156  ep = ep_2;
157 
158  if (r[i].norm() < d)
159  ep = ep_1;
160 
161  phi = PHI.gradient(r[i]);
162 
163  values[i][0] = -ep * phi[0];
164  values[i][1] = -ep * phi[1];
165  values[i][2] = -ep * phi[2];
166  }
167 }
168 #pragma GCC diagnostic pop
Describes the exact solution, , of the Interface between dielectrics (int/) numerical experiment.
Describes the exact solution, , of the Interface between dielectrics (int/) numerical experiment.
Describes the exact solution, , of the Interface between dielectrics (int/) numerical experiment.