Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
polynomials_rannacher_turek.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2015 - 2020 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_polynomials_rannacher_turek_h
18 #define dealii_polynomials_rannacher_turek_h
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/point.h>
24 #include <deal.II/base/tensor.h>
25 
26 #include <vector>
27 
29 
30 
43 template <int dim>
45 {
46 public:
50  static const unsigned int dimension = dim;
51 
56 
60  double
61  compute_value(const unsigned int i, const Point<dim> &p) const;
62 
68  template <int order>
70  compute_derivative(const unsigned int i, const Point<dim> &p) const;
71 
76  compute_grad(const unsigned int i, const Point<dim> &p) const;
77 
82  compute_grad_grad(const unsigned int i, const Point<dim> &p) const;
83 
90  void
91  evaluate(const Point<dim> & unit_point,
92  std::vector<double> & values,
93  std::vector<Tensor<1, dim>> &grads,
94  std::vector<Tensor<2, dim>> &grad_grads,
95  std::vector<Tensor<3, dim>> &third_derivatives,
96  std::vector<Tensor<4, dim>> &fourth_derivatives) const override;
97 
101  std::string
102  name() const override;
103 
107  virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
108  clone() const override;
109 };
110 
111 
112 namespace internal
113 {
114  namespace PolynomialsRannacherTurekImplementation
115  {
116  template <int order, int dim>
117  inline Tensor<order, dim>
118  compute_derivative(const unsigned int, const Point<dim> &)
119  {
120  Assert(dim == 2, ExcNotImplemented());
121  return Tensor<order, dim>();
122  }
123 
124 
125  template <int order>
126  inline Tensor<order, 2>
127  compute_derivative(const unsigned int i, const Point<2> &p)
128  {
129  const unsigned int dim = 2;
130 
131  Tensor<order, dim> derivative;
132  switch (order)
133  {
134  case 1:
135  {
136  Tensor<1, dim> &grad =
137  *reinterpret_cast<Tensor<1, dim> *>(&derivative);
138  if (i == 0)
139  {
140  grad[0] = -2.5 + 3 * p(0);
141  grad[1] = 1.5 - 3 * p(1);
142  }
143  else if (i == 1)
144  {
145  grad[0] = -0.5 + 3.0 * p(0);
146  grad[1] = 1.5 - 3.0 * p(1);
147  }
148  else if (i == 2)
149  {
150  grad[0] = 1.5 - 3.0 * p(0);
151  grad[1] = -2.5 + 3.0 * p(1);
152  }
153  else if (i == 3)
154  {
155  grad[0] = 1.5 - 3.0 * p(0);
156  grad[1] = -0.5 + 3.0 * p(1);
157  }
158  else
159  {
160  Assert(false, ExcNotImplemented());
161  }
162  return derivative;
163  }
164  case 2:
165  {
166  Tensor<2, dim> &grad_grad =
167  *reinterpret_cast<Tensor<2, dim> *>(&derivative);
168  if (i == 0)
169  {
170  grad_grad[0][0] = 3;
171  grad_grad[0][1] = 0;
172  grad_grad[1][0] = 0;
173  grad_grad[1][1] = -3;
174  }
175  else if (i == 1)
176  {
177  grad_grad[0][0] = 3;
178  grad_grad[0][1] = 0;
179  grad_grad[1][0] = 0;
180  grad_grad[1][1] = -3;
181  }
182  else if (i == 2)
183  {
184  grad_grad[0][0] = -3;
185  grad_grad[0][1] = 0;
186  grad_grad[1][0] = 0;
187  grad_grad[1][1] = 3;
188  }
189  else if (i == 3)
190  {
191  grad_grad[0][0] = -3;
192  grad_grad[0][1] = 0;
193  grad_grad[1][0] = 0;
194  grad_grad[1][1] = 3;
195  }
196  return derivative;
197  }
198  default:
199  {
200  // higher derivatives are all zero
201  return Tensor<order, dim>();
202  }
203  }
204  }
205  } // namespace PolynomialsRannacherTurekImplementation
206 } // namespace internal
207 
208 
209 
210 // template functions
211 template <int dim>
212 template <int order>
215  const Point<dim> & p) const
216 {
218  order>(i, p);
219 }
220 
221 
222 
223 template <int dim>
224 inline std::string
226 {
227  return "RannacherTurek";
228 }
229 
230 
232 
233 #endif
PolynomialsRannacherTurek::compute_value
double compute_value(const unsigned int i, const Point< dim > &p) const
Definition: polynomials_rannacher_turek.cc:35
StandardExceptions::ExcNotImplemented
static ::ExceptionBase & ExcNotImplemented()
PolynomialsRannacherTurek::compute_derivative
Tensor< order, dim > compute_derivative(const unsigned int i, const Point< dim > &p) const
Definition: polynomials_rannacher_turek.h:214
PolynomialsRannacherTurek::compute_grad
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
Definition: polynomials_rannacher_turek.cc:68
PolynomialsRannacherTurek::PolynomialsRannacherTurek
PolynomialsRannacherTurek()
Definition: polynomials_rannacher_turek.cc:25
scalar_polynomials_base.h
tensor.h
PolynomialsRannacherTurek::compute_grad_grad
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const
Definition: polynomials_rannacher_turek.cc:105
Tensor
Definition: tensor.h:450
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
internal::PolynomialsRannacherTurekImplementation::compute_derivative
Tensor< order, dim > compute_derivative(const unsigned int, const Point< dim > &)
Definition: polynomials_rannacher_turek.h:118
PolynomialsRannacherTurek::clone
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const override
Definition: polynomials_rannacher_turek.cc:195
PolynomialsRannacherTurek::name
std::string name() const override
Definition: polynomials_rannacher_turek.h:225
Assert
#define Assert(cond, exc)
Definition: exceptions.h:1419
Point< dim >
config.h
internal
Definition: aligned_vector.h:369
PolynomialsRannacherTurek
Definition: polynomials_rannacher_turek.h:44
PolynomialsRannacherTurek::dimension
static const unsigned int dimension
Definition: polynomials_rannacher_turek.h:50
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
PolynomialsRannacherTurek::evaluate
void evaluate(const Point< dim > &unit_point, std::vector< double > &values, std::vector< Tensor< 1, dim >> &grads, std::vector< Tensor< 2, dim >> &grad_grads, std::vector< Tensor< 3, dim >> &third_derivatives, std::vector< Tensor< 4, dim >> &fourth_derivatives) const override
Definition: polynomials_rannacher_turek.cc:146
ScalarPolynomialsBase
Definition: scalar_polynomials_base.h:63
point.h