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