Logbook  (07-04-2025)
Static problems
static_vector_input.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 <deal.II/base/types.h>
13 #define BOOST_ALLOW_DEPRECATED_HEADERS
14 
15 #include "exact_solution.hpp"
16 #include "static_vector_input.hpp"
17 #include <math.h>
18 
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wunused-parameter"
21 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
22 
23 //-----------------------------------------------------------------------------
24 //-------- Stage 0. Calculating current vector potential, T, given Jf ---------
25 //-----------------------------------------------------------------------------
26 
27 template<>
28 void
30  const std::vector<Point<3>>& r,
31  types::material_id mid,
32  unsigned int cuid,
33  std::vector<double>& values) const
34 {
35  Assert(r.size() == values.size(),
36  ExcDimensionMismatch(r.size(), values.size()));
37 
38  for (unsigned int i = 0; i < values.size(); i++)
39  values[i] = 1.0;
40 }
41 
42 template<>
43 void
45  const std::vector<Point<3>>& r,
46  types::material_id mid,
47  unsigned int cuid,
48  std::vector<Tensor<1, 3>>& values) const
49 {
50  Assert(r.size() == values.size(),
51  ExcDimensionMismatch(r.size(), values.size()));
52 
53  if ((mid == mid_1) || (mid == mid_2))
54  for (unsigned int i = 0; i < values.size(); i++) {
55  values[i][0] = 0.0;
56  values[i][1] = 0.0;
57  values[i][2] = 0.0;
58  }
59 
60  if (mid == mid_3)
61  for (unsigned int i = 0; i < values.size(); i++) {
62  values[i][0] = -K_0 * r[i][1];
63  values[i][1] = K_0 * r[i][0];
64  values[i][2] = 0.0;
65  }
66 }
67 
68 template<>
69 void
70 StaticVectorSolver::Gamma<3, 0>::value_list(const std::vector<Point<3>>& r,
71  const std::vector<Tensor<1, 3>>& n,
72  types::boundary_id bid,
73  types::material_id mid,
74  unsigned int cuid,
75  unsigned int fuid,
76  std::vector<double>& values) const
77 {
78  Assert(r.size() == values.size(),
79  ExcDimensionMismatch(r.size(), values.size()));
80 
81  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
82 
83  for (unsigned int i = 0; i < values.size(); i++)
84  values[i] = 0.0;
85 }
86 
87 template<>
88 void
90  const std::vector<Point<3>>& r,
91  const std::vector<Tensor<1, 3>>& n,
92  types::boundary_id bid,
93  types::material_id mid,
94  unsigned int cuid,
95  unsigned int fuid,
96  std::vector<Tensor<1, 3>>& values) const
97 {
98  Assert(r.size() == values.size(),
99  ExcDimensionMismatch(r.size(), values.size()));
100 
101  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
102 
103  for (unsigned int i = 0; i < r.size(); i++) {
104  values[i][0] = 0.0;
105  values[i][1] = 0.0;
106  values[i][2] = 0.0;
107  }
108 }
109 
110 template<>
111 void
113  const std::vector<Point<3>>& r,
114  const std::vector<Tensor<1, 3>>& n,
115  types::material_id mid,
116  unsigned int cuid,
117  unsigned int fuid,
118  std::vector<Tensor<1, 3>>& values) const
119 {
120  Assert(r.size() == values.size(),
121  ExcDimensionMismatch(r.size(), values.size()));
122 
123  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
124 
125  for (unsigned int i = 0; i < values.size(); i++) {
126  values[i][0] = 0.0;
127  values[i][1] = 0.0;
128  values[i][2] = 0.0;
129  }
130 }
131 
132 template<>
133 double
135  const unsigned int component) const
136 {
137  return 1.0;
138 }
139 
140 //-----------------------------------------------------------------------------
141 // Stage 1. Calculating Jf given T (projection) to check if the Stage 0 was ok.
142 //-----------------------------------------------------------------------------
143 
144 template<>
145 double
147  const unsigned int component) const
148 {
149  if (r.norm() > d2)
150  return 0.0;
151 
152  return 1.0;
153 }
154 
155 //-----------------------------------------------------------------------------
156 // Stage 2. Calculating vector potential, A, given T --------------------------
157 //-----------------------------------------------------------------------------
158 
159 template<>
160 void
162  const std::vector<Point<3>>& r,
163  types::material_id mid,
164  unsigned int cuid,
165  std::vector<double>& values) const
166 {
167  Assert(r.size() == values.size(),
168  ExcDimensionMismatch(r.size(), values.size()));
169 
170  if ((mid == mid_1) || (mid == mid_3))
171  for (unsigned int i = 0; i < values.size(); i++)
172  values[i] = mu_0;
173 
174  if (mid == mid_2)
175  for (unsigned int i = 0; i < values.size(); i++)
176  values[i] = mu;
177 }
178 
179 template<>
180 void
182  const std::vector<Point<3>>& r,
183  types::material_id mid,
184  unsigned int cuid,
185  std::vector<Tensor<1, 3>>& values) const
186 {
187  Assert(r.size() == values.size(),
188  ExcDimensionMismatch(r.size(), values.size()));
189 
190  for (unsigned int i = 0; i < values.size(); i++) {
191  values[i][0] = 0.0;
192  values[i][1] = 0.0;
193  values[i][2] = 0.0;
194  }
195 }
196 
197 template<>
198 void
199 StaticVectorSolver::Gamma<3, 2>::value_list(const std::vector<Point<3>>& r,
200  const std::vector<Tensor<1, 3>>& n,
201  types::boundary_id bid,
202  types::material_id mid,
203  unsigned int cuid,
204  unsigned int fuid,
205  std::vector<double>& values) const
206 {
207  Assert(r.size() == values.size(),
208  ExcDimensionMismatch(r.size(), values.size()));
209 
210  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
211 
212  for (unsigned int i = 0; i < values.size(); i++)
213  values[i] = 1.0 / (mu_0 * r[i].norm());
214 }
215 
216 template<>
217 void
219  const std::vector<Point<3>>& r,
220  const std::vector<Tensor<1, 3>>& n,
221  types::boundary_id bid,
222  types::material_id mid,
223  unsigned int cuid,
224  unsigned int fuid,
225  std::vector<Tensor<1, 3>>& values) const
226 {
227  Assert(r.size() == values.size(),
228  ExcDimensionMismatch(r.size(), values.size()));
229 
230  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
231 
232  for (unsigned int i = 0; i < r.size(); i++) {
233  values[i][0] = 0.0;
234  values[i][1] = 0.0;
235  values[i][2] = 0.0;
236  }
237 }
238 
239 template<>
240 void
242  const std::vector<Point<3>>& r,
243  const std::vector<Tensor<1, 3>>& n,
244  types::material_id mid,
245  unsigned int cuid,
246  unsigned int fuid,
247  std::vector<Tensor<1, 3>>& values) const
248 {
249  Assert(r.size() == values.size(),
250  ExcDimensionMismatch(r.size(), values.size()));
251 
252  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
253 
254  for (unsigned int i = 0; i < values.size(); i++) {
255  values[i][0] = 0.0;
256  values[i][1] = 0.0;
257  values[i][2] = 0.0;
258  }
259 }
260 
261 template<>
262 double
264  const unsigned int component) const
265 {
266  return 1.0;
267 }
268 //-----------------------------------------------------------------------------
269 //-------- Stage 3. Calculating B given A -------------------------------------
270 //-----------------------------------------------------------------------------
271 
272 template<>
273 double
275  const unsigned int component) const
276 {
277  if (r.norm() > d2)
278  return 0.0;
279 
280  return 1.0;
281 }
282 
283 #pragma GCC diagnostic pop
void value_list(const std::vector< Point< dim >> &r, const std::vector< Tensor< 1, dim >> &n, types::material_id mid, unsigned int cuid, unsigned int fuid, std::vector< Tensor< 1, dim >> &values) const
Computes values of the surface free-current density, , on the right-hand side of the continuity condi...
void value_list(const std::vector< Point< dim >> &r, const std::vector< Tensor< 1, dim >> &n, types::boundary_id bid, types::material_id mid, unsigned int cuid, unsigned int fuid, std::vector< double > &values) const
Computes values of the parameter of the Robin boundary condition at quadrature points.
void value_list(const std::vector< Point< dim >> &r, types::material_id mid, unsigned int cuid, std::vector< Tensor< 1, dim >> &values) const
Computes the vector field on the right-hand side of the partial differential equation.
void value_list(const std::vector< Point< dim >> &r, const std::vector< Tensor< 1, dim >> &n, types::boundary_id bid, types::material_id mid, unsigned int cuid, unsigned int fuid, std::vector< Tensor< 1, dim >> &values) const
Computes values of the vector field on the right-hand side of the Robin boundary condition at quadra...
void value_list(const std::vector< Point< dim >> &r, types::material_id mid, unsigned int cuid, std::vector< double > &values) const
Computes values of permeability, , at quadrature points.
virtual double value(const Point< dim > &r, const unsigned int component=0) const override final
Returns the value of weight at point r. All error norms, , , and , at point r will be multiplied by t...