Logbook  (07-04-2025)
Static problems
exact_solution.hpp
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 #ifndef ExactSolutionsSLDI_H__
13 #define ExactSolutionsSLDI_H__
14 
15 #include <deal.II/base/function.h>
16 #include <deal.II/base/point.h>
17 #include <deal.II/base/tensor.h>
18 
19 #include <deal.II/lac/vector.h>
20 
21 #include <cmath>
22 
23 #include "constants.hpp"
24 #include "settings.hpp"
25 
26 using namespace dealii;
27 
33 template<int dim>
35  : public Function<dim>
36  , public SettingsSLDI
37 {
38 public:
40 
41  virtual double value(const Point<dim>& r,
42  const unsigned int component = 0) const override final;
43 
44  virtual Tensor<1, dim> gradient(
45  const Point<dim>& r,
46  const unsigned int component = 0) const override final;
47 
48 private:
49  double OMEGA, alpha_1, beta_1, gamma_1, delta_1;
50 };
51 
57 template<int dim>
59  : public Function<dim>
60  , public SettingsSLDI
61 {
62 public:
64  : Function<dim>(dim)
65  {
66  }
67 
68  virtual void vector_value_list(
69  const std::vector<Point<dim>>& r,
70  std::vector<Vector<double>>& values) const final;
71 
72 private:
74 };
75 
81 template<int dim>
83  : public Function<dim>
84  , public SettingsSLDI
85 {
86 public:
88  : Function<dim>(dim)
89  {
90  }
91 
92  virtual void vector_value_list(
93  const std::vector<Point<dim>>& r,
94  std::vector<Vector<double>>& values) const final;
95 
96 private:
98 };
99 
100 template<int dim>
101 void
103  const std::vector<Point<dim>>& r,
104  std::vector<Vector<double>>& values) const
105 {
106  Assert(values.size() == r.size(),
107  ExcDimensionMismatch(values.size(), r.size()));
108 
109  Tensor<1, dim> grad;
110 
111  for (unsigned int i = 0; i < r.size(); i++) {
112  grad = psi.gradient(r[i]);
113 
114  for (unsigned int j = 0; j < dim; j++)
115  values[i][j] = -grad[j];
116  }
117 }
118 
119 template<int dim>
120 void
122  const std::vector<Point<dim>>& r,
123  std::vector<Vector<double>>& values) const
124 {
125  Assert(values.size() == r.size(),
126  ExcDimensionMismatch(values.size(), r.size()));
127 
128  Tensor<1, dim> grad;
129  double mu;
130 
131  for (unsigned int i = 0; i < r.size(); i++) {
132  if (r[i].norm() < a) {
133  // Inside the shield.
134  mu = mu_1;
135  } else if (r[i].norm() < b) {
136  // In the wall of the shield.
137  mu = mu_2;
138  } else {
139  // Outside the shield.
140  mu = mu_3;
141  }
142 
143  grad = psi.gradient(r[i]);
144 
145  for (unsigned int j = 0; j < dim; j++)
146  values[i][j] = -mu * grad[j];
147  }
148 }
149 
150 #endif
Describes exact solution, , of the Magnetostatic shield - 1 (sld-i/) numerical experiment in two and ...
Describes exact solution, , of the Magnetostatic shield - 1 (sld-i/) numerical experiment in two and ...
Describes exact solution, , of the Magnetostatic shield - 1 (sld-i/) numerical experiment in two and ...
Global settings for the Magnetostatic shield - 1 (sld-i/) numerical experiment.
Definition: settings.hpp:33