Reference documentation for deal.II version 9.5.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\}}\)
Loading...
Searching...
No Matches
tensor_product_polynomials_const.cc
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2012 - 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
19
20#include <memory>
21
23
24
25
26/* ------------------- TensorProductPolynomialsConst -------------- */
27
28
29
30template <int dim>
31void
33{
34 std::array<unsigned int, dim> ix;
35 for (unsigned int i = 0; i < tensor_polys.n(); ++i)
36 {
37 tensor_polys.compute_index(i, ix);
38 out << i << "\t";
39 for (unsigned int d = 0; d < dim; ++d)
40 out << ix[d] << " ";
41 out << std::endl;
42 }
43}
44
45
46
47template <int dim>
48void
50 const std::vector<unsigned int> &renumber)
51{
52 Assert(renumber.size() == index_map.size(),
53 ExcDimensionMismatch(renumber.size(), index_map.size()));
54
55 index_map = renumber;
56 for (unsigned int i = 0; i < index_map.size(); ++i)
57 index_map_inverse[index_map[i]] = i;
58
59 std::vector<unsigned int> renumber_base;
60 for (unsigned int i = 0; i < tensor_polys.n(); ++i)
61 renumber_base.push_back(renumber[i]);
62
63 tensor_polys.set_numbering(renumber_base);
64}
65
66
67template <int dim>
68double
70 const Point<dim> & p) const
71{
72 const unsigned int max_indices = tensor_polys.n();
73 Assert(i <= max_indices, ExcInternalError());
74
75 // treat the regular basis functions
76 if (i < max_indices)
77 return tensor_polys.compute_value(i, p);
78 else
79 // this is for the constant function
80 return 1.;
81}
82
83
84
85template <>
86double
88 const Point<0> &) const
89{
90 Assert(false, ExcNotImplemented());
91 return 0.;
92}
93
94
95template <int dim>
98 const Point<dim> & p) const
99{
100 const unsigned int max_indices = tensor_polys.n();
101 Assert(i <= max_indices, ExcInternalError());
102
103 // treat the regular basis functions
104 if (i < max_indices)
105 return tensor_polys.compute_grad(i, p);
106 else
107 // this is for the constant function
108 return Tensor<1, dim>();
109}
110
111template <int dim>
114 const Point<dim> &p) const
115{
116 const unsigned int max_indices = tensor_polys.n();
117 Assert(i <= max_indices, ExcInternalError());
118
119 // treat the regular basis functions
120 if (i < max_indices)
121 return tensor_polys.compute_grad_grad(i, p);
122 else
123 // this is for the constant function
124 return Tensor<2, dim>();
125}
126
127template <int dim>
128void
130 const Point<dim> & p,
131 std::vector<double> & values,
132 std::vector<Tensor<1, dim>> &grads,
133 std::vector<Tensor<2, dim>> &grad_grads,
134 std::vector<Tensor<3, dim>> &third_derivatives,
135 std::vector<Tensor<4, dim>> &fourth_derivatives) const
136{
137 Assert(values.size() == tensor_polys.n() + 1 || values.size() == 0,
138 ExcDimensionMismatch2(values.size(), tensor_polys.n() + 1, 0));
139 Assert(grads.size() == tensor_polys.n() + 1 || grads.size() == 0,
140 ExcDimensionMismatch2(grads.size(), tensor_polys.n() + 1, 0));
141 Assert(grad_grads.size() == tensor_polys.n() + 1 || grad_grads.size() == 0,
142 ExcDimensionMismatch2(grad_grads.size(), tensor_polys.n() + 1, 0));
143 Assert(third_derivatives.size() == tensor_polys.n() + 1 ||
144 third_derivatives.size() == 0,
145 ExcDimensionMismatch2(third_derivatives.size(),
146 tensor_polys.n() + 1,
147 0));
148 Assert(fourth_derivatives.size() == tensor_polys.n() + 1 ||
149 fourth_derivatives.size() == 0,
150 ExcDimensionMismatch2(fourth_derivatives.size(),
151 tensor_polys.n() + 1,
152 0));
153
154 // remove slot for const value, go into the base class compute method and
155 // finally append the const value again
156 bool do_values = false, do_grads = false, do_grad_grads = false;
157 bool do_3rd_derivatives = false, do_4th_derivatives = false;
158 if (values.empty() == false)
159 {
160 values.pop_back();
161 do_values = true;
162 }
163 if (grads.empty() == false)
164 {
165 grads.pop_back();
166 do_grads = true;
167 }
168 if (grad_grads.empty() == false)
169 {
170 grad_grads.pop_back();
171 do_grad_grads = true;
172 }
173 if (third_derivatives.empty() == false)
174 {
175 third_derivatives.resize(tensor_polys.n());
176 do_3rd_derivatives = true;
177 }
178 if (fourth_derivatives.empty() == false)
179 {
180 fourth_derivatives.resize(tensor_polys.n());
181 do_4th_derivatives = true;
182 }
183
184 tensor_polys.evaluate(
185 p, values, grads, grad_grads, third_derivatives, fourth_derivatives);
186
187 // for dgq node: values =1, grads=0, grads_grads=0, third_derivatives=0,
188 // fourth_derivatives=0
189 if (do_values)
190 values.push_back(1.);
191 if (do_grads)
192 grads.emplace_back();
193 if (do_grad_grads)
194 grad_grads.emplace_back();
195 if (do_3rd_derivatives)
196 third_derivatives.emplace_back();
197 if (do_4th_derivatives)
198 fourth_derivatives.emplace_back();
199}
200
201
202
203template <int dim>
204std::unique_ptr<ScalarPolynomialsBase<dim>>
206{
207 return std::make_unique<TensorProductPolynomialsConst<dim>>(*this);
208}
209
210
211/* ------------------- explicit instantiations -------------- */
215
Definition point.h:112
double compute_value(const unsigned int i, const Point< dim > &p) const override
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const override
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const override
void set_numbering(const std::vector< unsigned int > &renumber)
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const override
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
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch2(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)