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 #define BOOST_ALLOW_DEPRECATED_HEADERS
13 
14 #include "static_scalar_input.hpp"
15 #include <math.h>
16 
17 using namespace StaticScalarSolver;
18 using namespace std;
19 
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-Wunused-parameter"
22 
23 template<>
24 void
25 TheCoefficient<2>::value_list(const std::vector<Point<2>>& r,
26  types::material_id mid,
27  unsigned int cuid,
28  std::vector<double>& values) const
29 {
30  Assert(r.size() == values.size(),
31  ExcDimensionMismatch(r.size(), values.size()));
32 
33  for (unsigned int i = 0; i < values.size(); i++) {
34  if (mid == mid_1)
35  values[i] = mu_1;
36 
37  if (mid == mid_2)
38  values[i] = mu_2;
39 
40  if (mid == mid_3)
41  values[i] = mu_3;
42  }
43 }
44 
45 template<>
46 void
47 TheCoefficient<3>::value_list(const std::vector<Point<3>>& r,
48  types::material_id mid,
49  unsigned int cuid,
50  std::vector<double>& values) const
51 {
52  Assert(r.size() == values.size(),
53  ExcDimensionMismatch(r.size(), values.size()));
54 
55  for (unsigned int i = 0; i < values.size(); i++) {
56  if (mid == mid_1)
57  values[i] = mu_1;
58 
59  if (mid == mid_2)
60  values[i] = mu_2;
61 
62  if (mid == mid_3)
63  values[i] = mu_3;
64  }
65 }
66 
67 template<>
68 void
69 PdeRhs<2>::value_list(const std::vector<Point<2>>& r,
70  types::material_id mid,
71  unsigned int cuid,
72  std::vector<double>& values) const
73 {
74  Assert(r.size() == values.size(),
75  ExcDimensionMismatch(r.size(), values.size()));
76 
77  for (unsigned int i = 0; i < values.size(); i++)
78  values[i] = 0.0;
79 }
80 
81 template<>
82 void
83 PdeRhs<3>::value_list(const std::vector<Point<3>>& r,
84  types::material_id mid,
85  unsigned int cuid,
86  std::vector<double>& values) const
87 {
88  Assert(r.size() == values.size(),
89  ExcDimensionMismatch(r.size(), values.size()));
90 
91  for (unsigned int i = 0; i < values.size(); i++)
92  values[i] = 0.0;
93 }
94 
95 template<>
96 void
97 PdeRhsCvp<2>::value_list(const std::vector<Point<2>>& r,
98  types::material_id mid,
99  unsigned int cuid,
100  std::vector<Tensor<1, 2>>& values) const
101 {
102  Assert(r.size() == values.size(),
103  ExcDimensionMismatch(r.size(), values.size()));
104 
105  for (unsigned int i = 0; i < values.size(); i++) {
106  values[i][0] = 0.0;
107  values[i][1] = 0.0;
108  }
109 }
110 
111 template<>
112 void
113 PdeRhsCvp<3>::value_list(const std::vector<Point<3>>& r,
114  types::material_id mid,
115  unsigned int cuid,
116  std::vector<Tensor<1, 3>>& values) const
117 {
118  Assert(r.size() == values.size(),
119  ExcDimensionMismatch(r.size(), values.size()));
120 
121  for (unsigned int i = 0; i < values.size(); i++) {
122  values[i][0] = 0.0;
123  values[i][1] = 0.0;
124  values[i][2] = 0.0;
125  }
126 }
127 
128 template<>
129 void
130 Gamma<2>::value_list(const std::vector<Point<2>>& r,
131  const std::vector<Tensor<1, 2>>& n,
132  types::boundary_id bid,
133  types::material_id mid,
134  unsigned int cuid,
135  unsigned int fuid,
136  std::vector<double>& values) const
137 {
138  Assert(r.size() == values.size(),
139  ExcDimensionMismatch(r.size(), values.size()));
140 
141  for (unsigned int i = 0; i < values.size(); i++)
142  values[i] = 0.0;
143 }
144 
145 template<>
146 void
147 Gamma<3>::value_list(const std::vector<Point<3>>& r,
148  const std::vector<Tensor<1, 3>>& n,
149  types::boundary_id bid,
150  types::material_id mid,
151  unsigned int cuid,
152  unsigned int fuid,
153  std::vector<double>& values) const
154 {
155  Assert(r.size() == values.size(),
156  ExcDimensionMismatch(r.size(), values.size()));
157 
158  for (unsigned int i = 0; i < values.size(); i++)
159  values[i] = 0.0;
160 }
161 
162 template<>
163 void
164 RobinRhs<2>::value_list(const std::vector<Point<2>>& r,
165  const std::vector<Tensor<1, 2>>& n,
166  types::boundary_id bid,
167  types::material_id mid,
168  unsigned int cuid,
169  unsigned int fuid,
170  std::vector<double>& values) const
171 {
172 
173  Assert(r.size() == values.size(),
174  ExcDimensionMismatch(r.size(), values.size()));
175 
176  for (unsigned int i = 0; i < values.size(); i++)
177  values[i] = 0.0;
178 }
179 
180 template<>
181 void
182 RobinRhs<3>::value_list(const std::vector<Point<3>>& r,
183  const std::vector<Tensor<1, 3>>& n,
184  types::boundary_id bid,
185  types::material_id mid,
186  unsigned int cuid,
187  unsigned int fuid,
188  std::vector<double>& values) const
189 {
190 
191  Assert(r.size() == values.size(),
192  ExcDimensionMismatch(r.size(), values.size()));
193 
194  for (unsigned int i = 0; i < values.size(); i++)
195  values[i] = 0.0;
196 }
197 
198 template<>
199 void
200 FreeSurfaceCharge<2>::value_list(const std::vector<Point<2>>& r,
201  const std::vector<Tensor<1, 2>>& n,
202  types::material_id mid,
203  unsigned int cuid,
204  unsigned int fuid,
205  std::vector<double>& values) const
206 {
207  Assert(r.size() == values.size(),
208  ExcDimensionMismatch(r.size(), values.size()));
209 
210  for (unsigned int i = 0; i < values.size(); i++) {
211  if ((cuid == 1) && (fuid == 1)) {
212  values[i] = -(mu_2 - mu_1) * (n[i] * j_hat);
213  }
214 
215  if ((cuid == 2) && (fuid == 2)) {
216  values[i] = -(mu_3 - mu_2) * (n[i] * j_hat);
217  }
218  }
219 }
220 
221 template<>
222 void
223 FreeSurfaceCharge<3>::value_list(const std::vector<Point<3>>& r,
224  const std::vector<Tensor<1, 3>>& n,
225  types::material_id mid,
226  unsigned int cuid,
227  unsigned int fuid,
228  std::vector<double>& values) const
229 {
230  Assert(r.size() == values.size(),
231  ExcDimensionMismatch(r.size(), values.size()));
232 
233  for (unsigned int i = 0; i < values.size(); i++) {
234  if ((cuid == 1) && (fuid == 1)) {
235  values[i] = -(mu_2 - mu_1) * (n[i] * k_hat);
236  }
237 
238  if ((cuid == 2) && (fuid == 2)) {
239  values[i] = -(mu_3 - mu_2) * (n[i] * k_hat);
240  }
241  }
242 }
243 
244 template<>
245 double
246 Weight<2>::value(const Point<2>& r, const unsigned int component) const
247 {
248  if (((std::abs(r[0]) - d_2) < eps) && ((std::abs(r[1]) - d_2) < eps)) {
249  return 1.0;
250  }
251 
252  return 0.0;
253 }
254 
255 template<>
256 double
257 Weight<3>::value(const Point<3>& r, const unsigned int component) const
258 {
259  if (((std::abs(r[0]) - d_2) < eps) && ((std::abs(r[1]) - d_2) < eps) &&
260  ((std::abs(r[2]) - d_2) < eps)) {
261  return 1.0;
262  }
263 
264  return 0.0;
265 }
266 
267 #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< 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...