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 using namespace std;
19 
20 template<>
21 double
22 ExactSolutionMMS_PHI<2>::value(const Point<2>& r, unsigned int component) const
23 {
24  return (cos(k * r[0]) + cos(k * r[1]));
25 }
26 
27 template<>
28 Tensor<1, 2>
29 ExactSolutionMMS_PHI<2>::gradient(const Point<2>& r,
30  unsigned int component) const
31 {
32  Tensor<1, 2> p;
33 
34  p[0] = -k * sin(k * r[0]);
35  p[1] = -k * sin(k * r[1]);
36 
37  return p;
38 }
39 
40 template<>
41 double
42 ExactSolutionMMS_PHI<3>::value(const Point<3>& r, unsigned int componet) const
43 {
44  return (cos(k * r[0]) + cos(k * r[1]) + cos(k * r[2]));
45 }
46 
47 template<>
48 Tensor<1, 3>
49 ExactSolutionMMS_PHI<3>::gradient(const Point<3>& r,
50  unsigned int component) const
51 {
52  Tensor<1, 3> p;
53 
54  p[0] = -k * sin(k * r[0]);
55  p[1] = -k * sin(k * r[1]);
56  p[2] = -k * sin(k * r[2]);
57 
58  return p;
59 }
60 
61 template<>
62 void
64  const std::vector<Point<2>>& r,
65  std::vector<Vector<double>>& values) const
66 {
67  Assert(values.size() == r.size(),
68  ExcDimensionMismatch(values.size(), r.size()));
69 
70  for (unsigned int i = 0; i < r.size(); i++) {
71  values[i][0] = k * sin(k * r[i][0]);
72  values[i][1] = k * sin(k * r[i][1]);
73  }
74 }
75 
76 template<>
77 void
79  const std::vector<Point<3>>& r,
80  std::vector<Vector<double>>& values) const
81 {
82  Assert(values.size() == r.size(),
83  ExcDimensionMismatch(values.size(), r.size()));
84 
85  for (unsigned int i = 0; i < r.size(); i++) {
86  values[i][0] = k * sin(k * r[i][0]);
87  values[i][1] = k * sin(k * r[i][1]);
88  values[i][2] = k * sin(k * r[i][2]);
89  }
90 }
91 
92 template<>
93 void
95  const std::vector<Point<2>>& r,
96  std::vector<Vector<double>>& values) const
97 {
98  Assert(values.size() == r.size(),
99  ExcDimensionMismatch(values.size(), r.size()));
100 
101  double alpha;
102 
103  for (unsigned int i = 0; i < r.size(); i++) {
104  alpha = ep_0 * k * (pow(r[i][0], 2.0) * pow(r[i][1], 2.0) + 1.0);
105 
106  values[i][0] = alpha * sin(k * r[i][0]);
107  values[i][1] = alpha * sin(k * r[i][1]);
108  }
109 }
110 
111 template<>
112 void
114  const std::vector<Point<3>>& r,
115  std::vector<Vector<double>>& values) const
116 {
117  Assert(values.size() == r.size(),
118  ExcDimensionMismatch(values.size(), r.size()));
119 
120  double alpha;
121 
122  for (unsigned int i = 0; i < r.size(); i++) {
123  alpha = ep_0 * k *
124  (pow(r[i][0], 2.0) * pow(r[i][1], 2.0) * pow(r[i][2], 2.0) + 1.0);
125 
126  values[i][0] = alpha * sin(k * r[i][0]);
127  values[i][1] = alpha * sin(k * r[i][1]);
128  values[i][2] = alpha * sin(k * r[i][2]);
129  }
130 }
131 
132 #pragma GCC diagnostic pop
Describes exact solution, , of the Method of manufactured solutions (mms/) numerical experiment in tw...
Describes exact solution, , of the Method of manufactured solutions (mms/) numerical experiment in tw...
Describes exact solution, , of the Method of manufactured solutions (mms/) numerical experiment in tw...