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 
19 double
20 ExactSolutionCVPII_T::value(const Point<2>& r,
21  const unsigned int component) const
22 {
23  if (r.norm() < SettingsCVPII::a)
24  return 0.5 * (b * b - a * a);
25 
26  if (r.norm() > SettingsCVPII::b)
27  return 0.0;
28 
29  return -0.5 * (r[0] * r[0] + r[1] * r[1] - b * b);
30 }
31 
32 Tensor<1, 2>
33 ExactSolutionCVPII_T::gradient(const Point<2>& r,
34  const unsigned int component) const
35 {
36  if (r.norm() < SettingsCVPII::a)
37  return Point<2>();
38 
39  if (r.norm() > SettingsCVPII::b)
40  return Point<2>();
41 
42  return -r;
43 }
44 
45 ExactSolutionCVPII_Jf::ExactSolutionCVPII_Jf()
46  : Function<2>(2)
47 {
48 }
49 
50 void
51 ExactSolutionCVPII_Jf::vector_value_list(
52  const std::vector<Point<2>>& r,
53  std::vector<Vector<double>>& values) const
54 {
55  Assert(values.size() == r.size(),
56  ExcDimensionMismatch(values.size(), r.size()));
57 
58  auto v = values.begin();
59  for (auto p : r) {
60  if ((p.norm() > SettingsCVPII::a) && (p.norm() < SettingsCVPII::b)) {
61  (*v)[0] = -p[1];
62  (*v)[1] = p[0];
63  } else {
64  (*v)[0] = 0.0;
65  (*v)[1] = 0.0;
66  }
67 
68  v++;
69  }
70 }
const double b
The outer radius of the coil.
Definition: settings.hpp:55
const double a
The inner radius of the coil.
Definition: settings.hpp:50