Logbook  (07-04-2025)
Static problems
static_scalar_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_scalar_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<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] = 1.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<double>& 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] = 1.0;
55 }
56 
57 template<>
58 void
59 StaticScalarSolver::PdeRhs<2, 0>::value_list(const std::vector<Point<2>>& r,
60  types::material_id mid,
61  unsigned int cuid,
62  std::vector<double>& values) const
63 {
64  Assert(r.size() == values.size(),
65  ExcDimensionMismatch(r.size(), values.size()));
66 
67  for (unsigned int i = 0; i < values.size(); i++)
68  values[i] = 0.0;
69 }
70 
71 template<>
72 void
74  const std::vector<Point<2>>& r,
75  types::material_id mid,
76  unsigned int cuid,
77  std::vector<Tensor<1, 2>>& values) const
78 {
79  Assert(r.size() == values.size(),
80  ExcDimensionMismatch(r.size(), values.size()));
81 
82  Tensor<1, 2> Jf;
83 
84  for (unsigned int i = 0; i < values.size(); i++) {
85  Jf = volume_free_current_density(r[i][0], r[i][1], mu_0, k);
86 
87  values[i][0] = Jf[0];
88  values[i][1] = Jf[1];
89  }
90 }
91 
92 template<>
93 void
94 StaticScalarSolver::Gamma<2, 0>::value_list(const std::vector<Point<2>>& r,
95  const std::vector<Tensor<1, 2>>& n,
96  types::boundary_id bid,
97  types::material_id mid,
98  unsigned int cuid,
99  unsigned int fuid,
100  std::vector<double>& values) const
101 {
102  Assert(r.size() == values.size(),
103  ExcDimensionMismatch(r.size(), values.size()));
104 
105  Assert(r.size() == n.size(), ExcDimensionMismatch(r.size(), n.size()));
106 
107  for (unsigned int i = 0; i < values.size(); i++)
108  values[i] = 0;
109 }
110 
111 template<>
112 void
114  const std::vector<Point<2>>& r,
115  const std::vector<Tensor<1, 2>>& n,
116  types::boundary_id bid,
117  types::material_id mid,
118  unsigned int cuid,
119  unsigned int fuid,
120  std::vector<double>& values) const
121 {
122 
123  Assert(r.size() == values.size(),
124  ExcDimensionMismatch(r.size(), values.size()));
125 
126  Tensor<1, 2> Jf;
127 
128  for (unsigned int i = 0; i < r.size(); i++) {
129  Jf = volume_free_current_density(r[i][0], r[i][1], mu_0, k);
130 
131  values[i] = -n[i][0] * Jf[1] + n[i][1] * Jf[0];
132  }
133 }
134 
135 template<>
136 void
138  const std::vector<Point<2>>& r,
139  const std::vector<Tensor<1, 2>>& n,
140  types::material_id mid,
141  unsigned int cuid,
142  unsigned int fuid,
143  std::vector<double>& values) const
144 {
145  Assert(r.size() == values.size(),
146  ExcDimensionMismatch(r.size(), values.size()));
147 
148  for (unsigned int i = 0; i < values.size(); i++)
149  values[i] = 0.0;
150 }
151 
152 template<>
153 double
155  const unsigned int component) const
156 {
157  return 1.0;
158 }
159 
160 //-----------------------------------------------------------------------------
161 // Stage 1. Calculating Jf given T (projection) to check if the Stage 0 was ok.
162 //-----------------------------------------------------------------------------
163 
164 template<>
165 double
167  const unsigned int component) const
168 {
169  return 1.0;
170 }
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< double > &values) const
Computes the right-hand side of the second continuity condition ( , , , or ).
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 the coefficient 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 two-dimensional free-current density on the right-hand side of the partial differential...
void value_list(const std::vector< Point< dim >> &r, types::material_id mid, unsigned int cuid, std::vector< double > &values) const
Computes the right-hand side of the div-grad partial differential equation at quadrature points.
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 the right-hand side of the Robin boundary condition ( or ).
void value_list(const std::vector< Point< dim >> &r, types::material_id mid, unsigned int cuid, std::vector< double > &values) const
Computes the values of the coefficient 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...