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 ExactSolutionINTAXI_PHI<true>::value(const Point<2>& p,
31  const unsigned int component) const
32 {
33  Point<2> r;
34  r[0] = p[0];
35  r[1] = 0.0;
36 
37  if (r.norm() < d)
38  return (-alpha * ep_2 * (log(r.norm() / d) - beta));
39  else
40  return (-alpha * ep_1 * log(r.norm() / b));
41 }
42 
43 template<>
44 Tensor<1, 2>
46  const unsigned int component) const
47 {
48  Point<2> r;
49  r[0] = p[0];
50  r[1] = 0.0;
51 
52  if (r.norm() < d)
53  return -alpha * ep_2 * (1 / r.square()) * r;
54  else
55  return -alpha * ep_1 * (1 / r.square()) * r;
56 }
57 
58 template<>
60 {
61  alpha = 1.0 / (ep_1 * (1.0 / b - 1.0 / d) + ep_2 * (1.0 / d - 1.0 / a));
62  beta = 1.0 / d + (ep_1 / ep_2) * (1.0 / b - 1.0 / d);
63 }
64 
65 template<>
66 double
68  const unsigned int component) const
69 {
70  Point<2> r;
71  r[0] = p[0];
72  r[1] = p[1];
73 
74  if (r.norm() < d)
75  return (-alpha * ep_2 * (1.0 / r.norm() - beta));
76  else
77  return (-alpha * ep_1 * (1.0 / r.norm() - 1.0 / b));
78 }
79 
80 template<>
81 Tensor<1, 2>
83  const unsigned int component) const
84 {
85  Point<2> r;
86  r[0] = p[0];
87  r[1] = p[1];
88 
89  if (r.norm() < d)
90  return alpha * ep_2 * r / pow(r.norm(), 3);
91  else
92  return alpha * ep_1 * r / pow(r.norm(), 3);
93 }
94 
95 template<>
96 void
98  const std::vector<Point<2>>& r,
99  std::vector<Vector<double>>& values) const
100 {
101  Assert(values.size() == r.size(),
102  ExcDimensionMismatch(values.size(), r.size()));
103 
104  Tensor<1, 2> phi;
105 
106  for (unsigned int i = 0; i < r.size(); i++) {
107  phi = PHI.gradient(r[i]);
108 
109  values[i][0] = -phi[0];
110  values[i][1] = -phi[1];
111  }
112 }
113 
114 template<>
115 void
117  const std::vector<Point<2>>& r,
118  std::vector<Vector<double>>& values) const
119 {
120  Assert(values.size() == r.size(),
121  ExcDimensionMismatch(values.size(), r.size()));
122 
123  Tensor<1, 2> phi;
124 
125  for (unsigned int i = 0; i < r.size(); i++) {
126  phi = PHI.gradient(r[i]);
127 
128  values[i][0] = -phi[0];
129  values[i][1] = -phi[1];
130  }
131 }
132 
133 template<>
134 void
136  const std::vector<Point<2>>& r,
137  std::vector<Vector<double>>& values) const
138 {
139  Assert(values.size() == r.size(),
140  ExcDimensionMismatch(values.size(), r.size()));
141 
142  double ep;
143  Tensor<1, 2> phi;
144 
145  for (unsigned int i = 0; i < r.size(); i++) {
146  ep = ep_2;
147 
148  if (r[i][0] < d)
149  ep = ep_1;
150 
151  phi = PHI.gradient(r[i]);
152 
153  values[i][0] = -ep * phi[0];
154  values[i][1] = -ep * phi[1];
155  }
156 }
157 
158 template<>
159 void
161  const std::vector<Point<2>>& r,
162  std::vector<Vector<double>>& values) const
163 {
164  Assert(values.size() == r.size(),
165  ExcDimensionMismatch(values.size(), r.size()));
166 
167  double ep;
168  Tensor<1, 2> phi;
169 
170  for (unsigned int i = 0; i < r.size(); i++) {
171  ep = ep_2;
172 
173  if (r[i].norm() < d)
174  ep = ep_1;
175 
176  phi = PHI.gradient(r[i]);
177 
178  values[i][0] = -ep * phi[0];
179  values[i][1] = -ep * phi[1];
180  }
181 }
182 
183 #pragma GCC diagnostic pop
Describes exact solution, , of the Axisymmetric - interface between dielectrics (int-axi/) numerical ...
Describes exact solution, , of the Axisymmetric - interface between dielectrics (int-axi/) numerical ...
Describes exact solution, , of the Axisymmetric - interface between dielectrics (int-axi/) numerical ...