Amandus: Simulations based on multilevel Schwarz methods
function.h
Go to the documentation of this file.
1 /**********************************************************************
2  * Copyright (C) 2011 - 2014 by the authors
3  * Distributed under the MIT License
4  *
5  * See the files AUTHORS and LICENSE in the project root directory
6  *
7  **********************************************************************/
8 
9 #ifndef __stokes_function_h
10 #define __stokes_function_h
11 
12 #include <deal.II/base/flow_function.h>
13 
14 using namespace dealii;
15 using namespace Functions;
16 
18 {
19 template <int dim>
20 class StokesPolynomial : public FlowFunction<dim>
21 {
22 public:
23  virtual void vector_values(const std::vector<Point<dim>>& points,
24  std::vector<std::vector<double>>& values) const;
25  virtual void vector_gradients(const std::vector<Point<dim>>& points,
26  std::vector<std::vector<Tensor<1, dim>>>& gradients) const;
27  virtual void vector_laplacians(const std::vector<Point<dim>>& points,
28  std::vector<std::vector<double>>& values) const;
29 };
30 
31 template <int dim>
32 void
33 StokesPolynomial<dim>::vector_values(const std::vector<Point<dim>>& points,
34  std::vector<std::vector<double>>& values) const
35 {
36  unsigned int n = points.size();
37 
38  Assert(values.size() == dim + 1, ExcDimensionMismatch(values.size(), dim + 1));
39  for (unsigned int d = 0; d < dim + 1; ++d)
40  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
41 
42  for (unsigned int k = 0; k < n; ++k)
43  {
44  const Point<dim>& p = points[k];
45  const double x = p(0);
46  const double y = p(1);
47 
48  if (dim == 2)
49  {
50  values[0][k] = 3. * x * y * y - x * x * x;
51  values[1][k] = 3. * x * x * y - y * y * y;
52  values[2][k] = 0. + this->mean_pressure;
53  }
54  else
55  {
56  Assert(false, ExcNotImplemented());
57  }
58  }
59 }
60 
61 template <int dim>
62 void
63 StokesPolynomial<dim>::vector_gradients(const std::vector<Point<dim>>& points,
64  std::vector<std::vector<Tensor<1, dim>>>& values) const
65 {
66  unsigned int n = points.size();
67 
68  Assert(values.size() == dim + 1, ExcDimensionMismatch(values.size(), dim + 1));
69  for (unsigned int d = 0; d < dim + 1; ++d)
70  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
71 
72  for (unsigned int k = 0; k < n; ++k)
73  {
74  const Point<dim>& p = points[k];
75  const double x = p(0);
76  const double y = p(1);
77 
78  if (dim == 2)
79  {
80  values[0][k][0] = 3. * y * y - 3. * x * x;
81  values[0][k][1] = 6. * x * y;
82  values[1][k][0] = 6. * x * y;
83  values[1][k][1] = 3. * x * x - 3. * y * y;
84  values[2][k][0] = 0.;
85  values[2][k][1] = 0.;
86  }
87  else
88  {
89  Assert(false, ExcNotImplemented());
90  }
91  }
92 }
93 
94 template <int dim>
95 void
96 StokesPolynomial<dim>::vector_laplacians(const std::vector<Point<dim>>& points,
97  std::vector<std::vector<double>>& values) const
98 {
99  unsigned int n = points.size();
100 
101  Assert(values.size() == dim + 1, ExcDimensionMismatch(values.size(), dim + 1));
102  for (unsigned int d = 0; d < dim + 1; ++d)
103  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
104 
105  for (unsigned int k = 0; k < n; ++k)
106  {
107  /*const Point<dim>& p = points[k];
108  const double x = p(0);
109  const double y = p(1);*/
110 
111  if (dim == 2)
112  {
113  values[0][k] = 0.;
114  values[1][k] = 0.;
115  values[2][k] = 0.;
116  }
117  else
118  {
119  Assert(false, ExcNotImplemented());
120  }
121  }
122 }
123 }
124 
125 #endif
Definition: function.h:17
Definition: function.h:20