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)
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_2)
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  Tensor<1, 3> Jf;
104 
105  for (unsigned int i = 0; i < r.size(); i++) {
106  values[i][0] = 0.0;
107  values[i][1] = 0.0;
108  values[i][2] = 0.0;
109  }
110 }
111 
112 template<>
113 void
115  const std::vector<Point<3>>& r,
116  const std::vector<Tensor<1, 3>>& n,
117  types::material_id mid,
118  unsigned int cuid,
119  unsigned int fuid,
120  std::vector<Tensor<1, 3>>& values) const
121 {
122  Assert(r.size() == values.size(),
123  ExcDimensionMismatch(r.size(), values.size()));
124 
125  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
126 
127  for (unsigned int i = 0; i < values.size(); i++) {
128  values[i][0] = 0.0;
129  values[i][1] = 0.0;
130  values[i][2] = 0.0;
131  }
132 }
133 
134 template<>
135 double
137  const unsigned int component) const
138 {
139  return 1.0;
140 }
141 
142 //-----------------------------------------------------------------------------
143 // Stage 1. Calculating Jf given T (projection) to check if the Stage 0 was ok.
144 //-----------------------------------------------------------------------------
145 
146 template<>
147 double
149  const unsigned int component) const
150 {
151  if (r.norm() > d2)
152  return 0.0;
153 
154  return 1.0;
155 }
156 
157 //-----------------------------------------------------------------------------
158 // Stage 2. Calculating vector potential, A, given T --------------------------
159 //-----------------------------------------------------------------------------
160 
161 template<>
162 void
164  const std::vector<Point<3>>& r,
165  types::material_id mid,
166  unsigned int cuid,
167  std::vector<double>& values) const
168 {
169  Assert(r.size() == values.size(),
170  ExcDimensionMismatch(r.size(), values.size()));
171 
172  for (unsigned int i = 0; i < values.size(); i++)
173  values[i] = mu_0;
174 }
175 
176 template<>
177 void
179  const std::vector<Point<3>>& r,
180  types::material_id mid,
181  unsigned int cuid,
182  std::vector<Tensor<1, 3>>& values) const
183 {
184  Assert(r.size() == values.size(),
185  ExcDimensionMismatch(r.size(), values.size()));
186 
187  for (unsigned int i = 0; i < values.size(); i++) {
188  values[i][0] = 0.0;
189  values[i][1] = 0.0;
190  values[i][2] = 0.0;
191  }
192 }
193 
194 template<>
195 void
196 StaticVectorSolver::Gamma<3, 2>::value_list(const std::vector<Point<3>>& r,
197  const std::vector<Tensor<1, 3>>& n,
198  types::boundary_id bid,
199  types::material_id mid,
200  unsigned int cuid,
201  unsigned int fuid,
202  std::vector<double>& values) const
203 {
204  Assert(r.size() == values.size(),
205  ExcDimensionMismatch(r.size(), values.size()));
206 
207  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
208 
209  for (unsigned int i = 0; i < values.size(); i++)
210  values[i] = 1.0 / (mu_0 * r[i].norm());
211 }
212 
213 template<>
214 void
216  const std::vector<Point<3>>& r,
217  const std::vector<Tensor<1, 3>>& n,
218  types::boundary_id bid,
219  types::material_id mid,
220  unsigned int cuid,
221  unsigned int fuid,
222  std::vector<Tensor<1, 3>>& values) const
223 {
224  Assert(r.size() == values.size(),
225  ExcDimensionMismatch(r.size(), values.size()));
226 
227  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
228 
229  for (unsigned int i = 0; i < r.size(); i++) {
230  values[i] = 0.0;
231  }
232 }
233 
234 template<>
235 void
237  const std::vector<Point<3>>& r,
238  const std::vector<Tensor<1, 3>>& n,
239  types::material_id mid,
240  unsigned int cuid,
241  unsigned int fuid,
242  std::vector<Tensor<1, 3>>& values) const
243 {
244  Assert(r.size() == values.size(),
245  ExcDimensionMismatch(r.size(), values.size()));
246 
247  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
248 
249  for (unsigned int i = 0; i < values.size(); i++) {
250  values[i][0] = 0.0;
251  values[i][1] = 0.0;
252  values[i][2] = 0.0;
253  }
254 }
255 
256 template<>
257 double
259  const unsigned int component) const
260 {
261  return 1.0;
262 }
263 //-----------------------------------------------------------------------------
264 //-------- Stage 3. Calculating B given A -------------------------------------
265 //-----------------------------------------------------------------------------
266 
267 template<>
268 double
270  const unsigned int component) const
271 {
272  if (r.norm() > d2)
273  return 0.0;
274 
275  return 1.0;
276 }
277 
278 #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...