Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
tensor_product_polynomials_const.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2012 - 2018 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 #include <deal.II/base/exceptions.h>
18 #include <deal.II/base/tensor_product_polynomials_const.h>
19 
20 DEAL_II_NAMESPACE_OPEN
21 
22 
23 
24 /* ------------------- TensorProductPolynomialsConst -------------- */
25 
26 
27 template <int dim>
28 double
30  const Point<dim> & p) const
31 {
32  const unsigned int max_indices = this->n_tensor_pols;
33  Assert(i <= max_indices, ExcInternalError());
34 
35  // treat the regular basis functions
36  if (i < max_indices)
38  else
39  // this is for the constant function
40  return 1.;
41 }
42 
43 
44 
45 template <>
46 double
48  const Point<0> &) const
49 {
50  Assert(false, ExcNotImplemented());
51  return 0.;
52 }
53 
54 
55 template <int dim>
58  const Point<dim> & p) const
59 {
60  const unsigned int max_indices = this->n_tensor_pols;
61  Assert(i <= max_indices, ExcInternalError());
62 
63  // treat the regular basis functions
64  if (i < max_indices)
66  else
67  // this is for the constant function
68  return Tensor<1, dim>();
69 }
70 
71 template <int dim>
74  const Point<dim> &p) const
75 {
76  const unsigned int max_indices = this->n_tensor_pols;
77  Assert(i <= max_indices, ExcInternalError());
78 
79  // treat the regular basis functions
80  if (i < max_indices)
82  else
83  // this is for the constant function
84  return Tensor<2, dim>();
85 }
86 
87 template <int dim>
88 void
90  const Point<dim> & p,
91  std::vector<double> & values,
92  std::vector<Tensor<1, dim>> &grads,
93  std::vector<Tensor<2, dim>> &grad_grads,
94  std::vector<Tensor<3, dim>> &third_derivatives,
95  std::vector<Tensor<4, dim>> &fourth_derivatives) const
96 {
97  Assert(values.size() == this->n_tensor_pols + 1 || values.size() == 0,
98  ExcDimensionMismatch2(values.size(), this->n_tensor_pols + 1, 0));
99  Assert(grads.size() == this->n_tensor_pols + 1 || grads.size() == 0,
100  ExcDimensionMismatch2(grads.size(), this->n_tensor_pols + 1, 0));
101  Assert(grad_grads.size() == this->n_tensor_pols + 1 || grad_grads.size() == 0,
102  ExcDimensionMismatch2(grad_grads.size(), this->n_tensor_pols + 1, 0));
103  Assert(third_derivatives.size() == this->n_tensor_pols + 1 ||
104  third_derivatives.size() == 0,
105  ExcDimensionMismatch2(third_derivatives.size(),
106  this->n_tensor_pols + 1,
107  0));
108  Assert(fourth_derivatives.size() == this->n_tensor_pols + 1 ||
109  fourth_derivatives.size() == 0,
110  ExcDimensionMismatch2(fourth_derivatives.size(),
111  this->n_tensor_pols + 1,
112  0));
113 
114  // remove slot for const value, go into the base class compute method and
115  // finally append the const value again
116  bool do_values = false, do_grads = false, do_grad_grads = false;
117  bool do_3rd_derivatives = false, do_4th_derivatives = false;
118  if (values.empty() == false)
119  {
120  values.pop_back();
121  do_values = true;
122  }
123  if (grads.empty() == false)
124  {
125  grads.pop_back();
126  do_grads = true;
127  }
128  if (grad_grads.empty() == false)
129  {
130  grad_grads.pop_back();
131  do_grad_grads = true;
132  }
133  if (third_derivatives.empty() == false)
134  {
135  third_derivatives.resize(this->n_tensor_pols);
136  do_3rd_derivatives = true;
137  }
138  if (fourth_derivatives.empty() == false)
139  {
140  fourth_derivatives.resize(this->n_tensor_pols);
141  do_4th_derivatives = true;
142  }
143 
145  p, values, grads, grad_grads, third_derivatives, fourth_derivatives);
146 
147  // for dgq node: values =1, grads=0, grads_grads=0, third_derivatives=0,
148  // fourth_derivatives=0
149  if (do_values)
150  values.push_back(1.);
151  if (do_grads)
152  grads.emplace_back();
153  if (do_grad_grads)
154  grad_grads.emplace_back();
155  if (do_3rd_derivatives)
156  third_derivatives.emplace_back();
157  if (do_4th_derivatives)
158  fourth_derivatives.emplace_back();
159 }
160 
161 
162 /* ------------------- explicit instantiations -------------- */
163 template class TensorProductPolynomialsConst<1>;
164 template class TensorProductPolynomialsConst<2>;
165 template class TensorProductPolynomialsConst<3>;
166 
167 DEAL_II_NAMESPACE_CLOSE
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
double compute_value(const unsigned int i, const Point< dim > &p) const
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
static ::ExceptionBase & ExcDimensionMismatch2(int arg1, int arg2, int arg3)
void compute(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
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const
void compute(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
#define Assert(cond, exc)
Definition: exceptions.h:1407
static ::ExceptionBase & ExcNotImplemented()
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const
double compute_value(const unsigned int i, const Point< dim > &p) const
static ::ExceptionBase & ExcInternalError()