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 2. Calculating vector potential, A, given T --------------------------
25 //-----------------------------------------------------------------------------
26 
27 template<>
28 void
30  const std::vector<Point<2>>& 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] = permeability(r[i][0], r[i][1], mu_0);
40 }
41 
42 template<>
43 void
45  const std::vector<Point<2>>& r,
46  types::material_id mid,
47  unsigned int cuid,
48  std::vector<Tensor<1, 2>>& values) const
49 {
50  Assert(r.size() == values.size(),
51  ExcDimensionMismatch(r.size(), values.size()));
52 
53  for (unsigned int i = 0; i < values.size(); i++) {
54  values[i][0] = 0.0;
55  values[i][1] = 0.0;
56  values[i][2] = 0.0;
57  }
58 }
59 
60 template<>
61 void
62 StaticVectorSolver::Gamma<2, 2>::value_list(const std::vector<Point<2>>& r,
63  const std::vector<Tensor<1, 2>>& n,
64  types::boundary_id bid,
65  types::material_id mid,
66  unsigned int cuid,
67  unsigned int fuid,
68  std::vector<double>& values) const
69 {
70  Assert(r.size() == values.size(),
71  ExcDimensionMismatch(r.size(), values.size()));
72 
73  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
74 
75  for (unsigned int i = 0; i < values.size(); i++)
76  values[i] = robin_gamma(r[i][0], r[i][1], mu_0);
77 }
78 
79 template<>
80 void
82  const std::vector<Point<2>>& r,
83  const std::vector<Tensor<1, 2>>& n,
84  types::boundary_id bid,
85  types::material_id mid,
86  unsigned int cuid,
87  unsigned int fuid,
88  std::vector<Tensor<1, 2>>& values) const
89 {
90  Assert(r.size() == values.size(),
91  ExcDimensionMismatch(r.size(), values.size()));
92 
93  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
94 
95  Assert(bid == bid_robin, ExcMessage("bid is wrong"));
96 
97  Tensor<1, 2> A;
98  double mu, gamma, T;
99 
100  for (unsigned int i = 0; i < r.size(); i++) {
101  mu = permeability(r[i][0], r[i][1], mu_0);
102  gamma = robin_gamma(r[i][0], r[i][1], mu_0);
103  T = current_vector_potential(r[i][0], r[i][1], mu_0, k);
104  A = magnetic_vector_potential(r[i][0], r[i][1], k);
105 
106  values[i][0] =
107  n[i][1] * T + gamma * n[i][1] * (n[i][0] * A[1] - n[i][1] * A[0]);
108  values[i][1] =
109  -n[i][0] * T - gamma * n[i][0] * (n[i][0] * A[1] - n[i][1] * A[0]);
110  }
111 }
112 
113 template<>
114 void
116  const std::vector<Point<2>>& r,
117  const std::vector<Tensor<1, 2>>& n,
118  types::material_id mid,
119  unsigned int cuid,
120  unsigned int fuid,
121  std::vector<Tensor<1, 2>>& values) const
122 {
123  Assert(r.size() == values.size(),
124  ExcDimensionMismatch(r.size(), values.size()));
125 
126  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
127 
128  for (unsigned int i = 0; i < values.size(); i++) {
129  values[i][0] = 0.0;
130  values[i][1] = 0.0;
131  values[i][2] = 0.0;
132  }
133 }
134 
135 template<>
136 double
138  const unsigned int component) const
139 {
140  return 1.0;
141 }
142 
143 //-----------------------------------------------------------------------------
144 //-------- Stage 3. Calculating B given A -------------------------------------
145 //-----------------------------------------------------------------------------
146 
147 template<>
148 double
150  const unsigned int component) const
151 {
152  return 1.0;
153 }
154 
155 #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...