Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
fe_values.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2003 - 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 #include <deal.II/fe/mapping_q1.h>
17 
18 #include <deal.II/hp/fe_values.h>
19 
20 DEAL_II_NAMESPACE_OPEN
21 
22 namespace internal
23 {
24  namespace hp
25  {
26  // -------------------------- FEValuesBase -------------------------
27 
28  template <int dim, int q_dim, class FEValuesType>
30  const ::hp::MappingCollection<dim, FEValuesType::space_dimension>
31  &mapping_collection,
32  const ::hp::FECollection<dim, FEValuesType::space_dimension>
33  & fe_collection,
34  const ::hp::QCollection<q_dim> &q_collection,
35  const UpdateFlags update_flags)
36  : fe_collection(&fe_collection)
37  , mapping_collection(&mapping_collection)
38  , q_collection(q_collection)
39  , fe_values_table(fe_collection.size(),
40  mapping_collection.size(),
41  q_collection.size())
42  , present_fe_values_index(numbers::invalid_unsigned_int,
43  numbers::invalid_unsigned_int,
44  numbers::invalid_unsigned_int)
45  , update_flags(update_flags)
46  {}
47 
48 
49  template <int dim, int q_dim, class FEValuesType>
51  const ::hp::FECollection<dim, FEValuesType::space_dimension>
52  & fe_collection,
53  const ::hp::QCollection<q_dim> &q_collection,
54  const UpdateFlags update_flags)
55  : fe_collection(&fe_collection)
56  , mapping_collection(
57  &::hp::StaticMappingQ1<dim, FEValuesType::space_dimension>::
58  mapping_collection)
59  , q_collection(q_collection)
60  , fe_values_table(fe_collection.size(), 1, q_collection.size())
61  , present_fe_values_index(numbers::invalid_unsigned_int,
62  numbers::invalid_unsigned_int,
63  numbers::invalid_unsigned_int)
64  , update_flags(update_flags)
65  {}
66 
67 
68 
69  template <int dim, int q_dim, class FEValuesType>
70  FEValuesType &
72  const unsigned int fe_index,
73  const unsigned int mapping_index,
74  const unsigned int q_index)
75  {
76  Assert(fe_index < fe_collection->size(),
77  ExcIndexRange(fe_index, 0, fe_collection->size()));
78  Assert(mapping_index < mapping_collection->size(),
79  ExcIndexRange(mapping_index, 0, mapping_collection->size()));
80  Assert(q_index < q_collection.size(),
81  ExcIndexRange(q_index, 0, q_collection.size()));
82 
83 
84  // set the triple of indices
85  // that we want to work with
86  present_fe_values_index =
87  TableIndices<3>(fe_index, mapping_index, q_index);
88 
89  // first check whether we
90  // already have an object for
91  // this particular combination
92  // of indices
93  if (fe_values_table(present_fe_values_index).get() == nullptr)
94  fe_values_table(present_fe_values_index) =
95  std::make_shared<FEValuesType>((*mapping_collection)[mapping_index],
96  (*fe_collection)[fe_index],
97  q_collection[q_index],
98  update_flags);
99 
100  // now there definitely is one!
101  return *fe_values_table(present_fe_values_index);
102  }
103  } // namespace hp
104 } // namespace internal
105 
106 
107 
108 namespace hp
109 {
110  // -------------------------- FEValues -------------------------
111 
112 
113  template <int dim, int spacedim>
116  const hp::FECollection<dim, spacedim> & fe_collection,
117  const hp::QCollection<dim> & q_collection,
118  const UpdateFlags update_flags)
119  : internal::hp::FEValuesBase<dim, dim, ::FEValues<dim, spacedim>>(
120  mapping,
121  fe_collection,
122  q_collection,
123  update_flags)
124  {}
125 
126 
127  template <int dim, int spacedim>
129  const hp::FECollection<dim, spacedim> &fe_collection,
130  const hp::QCollection<dim> & q_collection,
131  const UpdateFlags update_flags)
132  : internal::hp::FEValuesBase<dim, dim, ::FEValues<dim, spacedim>>(
133  fe_collection,
134  q_collection,
135  update_flags)
136  {}
137 
138 
139  template <int dim, int spacedim>
140  template <typename DoFHandlerType, bool lda>
141  void
144  const unsigned int q_index,
145  const unsigned int mapping_index,
146  const unsigned int fe_index)
147  {
148  // determine which indices we
149  // should actually use
150  unsigned int real_q_index = q_index, real_mapping_index = mapping_index,
151  real_fe_index = fe_index;
152 
153  if (real_q_index == numbers::invalid_unsigned_int)
154  {
155  if (this->q_collection.size() > 1)
156  real_q_index = cell->active_fe_index();
157  else
158  real_q_index = 0;
159  }
160 
161  if (real_mapping_index == numbers::invalid_unsigned_int)
162  {
163  if (this->mapping_collection->size() > 1)
164  real_mapping_index = cell->active_fe_index();
165  else
166  real_mapping_index = 0;
167  }
168 
169  if (real_fe_index == numbers::invalid_unsigned_int)
170  real_fe_index = cell->active_fe_index();
171 
172  // some checks
173  Assert(real_q_index < this->q_collection.size(),
174  ExcIndexRange(real_q_index, 0, this->q_collection.size()));
175  Assert(real_mapping_index < this->mapping_collection->size(),
176  ExcIndexRange(real_mapping_index,
177  0,
178  this->mapping_collection->size()));
179  Assert(real_fe_index < this->fe_collection->size(),
180  ExcIndexRange(real_fe_index, 0, this->fe_collection->size()));
181 
182  // now finally actually get the
183  // corresponding object and
184  // initialize it
185  this->select_fe_values(real_fe_index, real_mapping_index, real_q_index)
186  .reinit(cell);
187  }
188 
189 
190 
191  template <int dim, int spacedim>
192  void
194  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
195  const unsigned int q_index,
196  const unsigned int mapping_index,
197  const unsigned int fe_index)
198  {
199  // determine which indices we
200  // should actually use
201  unsigned int real_q_index = q_index, real_mapping_index = mapping_index,
202  real_fe_index = fe_index;
203 
204  if (real_q_index == numbers::invalid_unsigned_int)
205  real_q_index = 0;
206 
207  if (real_mapping_index == numbers::invalid_unsigned_int)
208  real_mapping_index = 0;
209 
210  if (real_fe_index == numbers::invalid_unsigned_int)
211  real_fe_index = 0;
212 
213  // some checks
214  Assert(real_q_index < this->q_collection.size(),
215  ExcIndexRange(real_q_index, 0, this->q_collection.size()));
216  Assert(real_mapping_index < this->mapping_collection->size(),
217  ExcIndexRange(real_mapping_index,
218  0,
219  this->mapping_collection->size()));
220  Assert(real_fe_index < this->fe_collection->size(),
221  ExcIndexRange(real_fe_index, 0, this->fe_collection->size()));
222 
223  // now finally actually get the
224  // corresponding object and
225  // initialize it
226  this->select_fe_values(real_fe_index, real_mapping_index, real_q_index)
227  .reinit(cell);
228  }
229 
230 
231  // -------------------------- FEFaceValues -------------------------
232 
233 
234  template <int dim, int spacedim>
237  const hp::FECollection<dim, spacedim> & fe_collection,
238  const hp::QCollection<dim - 1> & q_collection,
239  const UpdateFlags update_flags)
240  : internal::hp::
241  FEValuesBase<dim, dim - 1, ::FEFaceValues<dim, spacedim>>(
242  mapping,
243  fe_collection,
244  q_collection,
245  update_flags)
246  {}
247 
248 
249  template <int dim, int spacedim>
251  const hp::FECollection<dim, spacedim> &fe_collection,
252  const hp::QCollection<dim - 1> & q_collection,
253  const UpdateFlags update_flags)
254  : internal::hp::
255  FEValuesBase<dim, dim - 1, ::FEFaceValues<dim, spacedim>>(
256  fe_collection,
257  q_collection,
258  update_flags)
259  {}
260 
261 
262  template <int dim, int spacedim>
263  template <typename DoFHandlerType, bool lda>
264  void
267  const unsigned int face_no,
268  const unsigned int q_index,
269  const unsigned int mapping_index,
270  const unsigned int fe_index)
271  {
272  // determine which indices we
273  // should actually use
274  unsigned int real_q_index = q_index, real_mapping_index = mapping_index,
275  real_fe_index = fe_index;
276 
277  if (real_q_index == numbers::invalid_unsigned_int)
278  {
279  if (this->q_collection.size() > 1)
280  real_q_index = cell->active_fe_index();
281  else
282  real_q_index = 0;
283  }
284 
285  if (real_mapping_index == numbers::invalid_unsigned_int)
286  {
287  if (this->mapping_collection->size() > 1)
288  real_mapping_index = cell->active_fe_index();
289  else
290  real_mapping_index = 0;
291  }
292 
293  if (real_fe_index == numbers::invalid_unsigned_int)
294  real_fe_index = cell->active_fe_index();
295 
296  // some checks
297  Assert(real_q_index < this->q_collection.size(),
298  ExcIndexRange(real_q_index, 0, this->q_collection.size()));
299  Assert(real_mapping_index < this->mapping_collection->size(),
300  ExcIndexRange(real_mapping_index,
301  0,
302  this->mapping_collection->size()));
303  Assert(real_fe_index < this->fe_collection->size(),
304  ExcIndexRange(real_fe_index, 0, this->fe_collection->size()));
305 
306  // now finally actually get the
307  // corresponding object and
308  // initialize it
309  this->select_fe_values(real_fe_index, real_mapping_index, real_q_index)
310  .reinit(cell, face_no);
311  }
312 
313 
314 
315  template <int dim, int spacedim>
316  void
318  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
319  const unsigned int face_no,
320  const unsigned int q_index,
321  const unsigned int mapping_index,
322  const unsigned int fe_index)
323  {
324  // determine which indices we
325  // should actually use
326  unsigned int real_q_index = q_index, real_mapping_index = mapping_index,
327  real_fe_index = fe_index;
328 
329  if (real_q_index == numbers::invalid_unsigned_int)
330  real_q_index = 0;
331 
332  if (real_mapping_index == numbers::invalid_unsigned_int)
333  real_mapping_index = 0;
334 
335  if (real_fe_index == numbers::invalid_unsigned_int)
336  real_fe_index = 0;
337 
338  // some checks
339  Assert(real_q_index < this->q_collection.size(),
340  ExcIndexRange(real_q_index, 0, this->q_collection.size()));
341  Assert(real_mapping_index < this->mapping_collection->size(),
342  ExcIndexRange(real_mapping_index,
343  0,
344  this->mapping_collection->size()));
345  Assert(real_fe_index < this->fe_collection->size(),
346  ExcIndexRange(real_fe_index, 0, this->fe_collection->size()));
347 
348  // now finally actually get the
349  // corresponding object and
350  // initialize it
351  this->select_fe_values(real_fe_index, real_mapping_index, real_q_index)
352  .reinit(cell, face_no);
353  }
354 
355 
356  // -------------------------- FESubfaceValues -------------------------
357 
358 
359  template <int dim, int spacedim>
362  const hp::FECollection<dim, spacedim> & fe_collection,
363  const hp::QCollection<dim - 1> & q_collection,
364  const UpdateFlags update_flags)
365  : internal::hp::
366  FEValuesBase<dim, dim - 1, ::FESubfaceValues<dim, spacedim>>(
367  mapping,
368  fe_collection,
369  q_collection,
370  update_flags)
371  {}
372 
373 
374  template <int dim, int spacedim>
376  const hp::FECollection<dim, spacedim> &fe_collection,
377  const hp::QCollection<dim - 1> & q_collection,
378  const UpdateFlags update_flags)
379  : internal::hp::
380  FEValuesBase<dim, dim - 1, ::FESubfaceValues<dim, spacedim>>(
381  fe_collection,
382  q_collection,
383  update_flags)
384  {}
385 
386 
387  template <int dim, int spacedim>
388  template <typename DoFHandlerType, bool lda>
389  void
392  const unsigned int face_no,
393  const unsigned int subface_no,
394  const unsigned int q_index,
395  const unsigned int mapping_index,
396  const unsigned int fe_index)
397  {
398  // determine which indices we
399  // should actually use
400  unsigned int real_q_index = q_index, real_mapping_index = mapping_index,
401  real_fe_index = fe_index;
402 
403  if (real_q_index == numbers::invalid_unsigned_int)
404  {
405  if (this->q_collection.size() > 1)
406  real_q_index = cell->active_fe_index();
407  else
408  real_q_index = 0;
409  }
410 
411  if (real_mapping_index == numbers::invalid_unsigned_int)
412  {
413  if (this->mapping_collection->size() > 1)
414  real_mapping_index = cell->active_fe_index();
415  else
416  real_mapping_index = 0;
417  }
418 
419  if (real_fe_index == numbers::invalid_unsigned_int)
420  real_fe_index = cell->active_fe_index();
421 
422  // some checks
423  Assert(real_q_index < this->q_collection.size(),
424  ExcIndexRange(real_q_index, 0, this->q_collection.size()));
425  Assert(real_mapping_index < this->mapping_collection->size(),
426  ExcIndexRange(real_mapping_index,
427  0,
428  this->mapping_collection->size()));
429  Assert(real_fe_index < this->fe_collection->size(),
430  ExcIndexRange(real_fe_index, 0, this->fe_collection->size()));
431 
432  // now finally actually get the
433  // corresponding object and
434  // initialize it
435  this->select_fe_values(real_fe_index, real_mapping_index, real_q_index)
436  .reinit(cell, face_no, subface_no);
437  }
438 
439 
440 
441  template <int dim, int spacedim>
442  void
444  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
445  const unsigned int face_no,
446  const unsigned int subface_no,
447  const unsigned int q_index,
448  const unsigned int mapping_index,
449  const unsigned int fe_index)
450  {
451  // determine which indices we
452  // should actually use
453  unsigned int real_q_index = q_index, real_mapping_index = mapping_index,
454  real_fe_index = fe_index;
455 
456  if (real_q_index == numbers::invalid_unsigned_int)
457  real_q_index = 0;
458 
459  if (real_mapping_index == numbers::invalid_unsigned_int)
460  real_mapping_index = 0;
461 
462  if (real_fe_index == numbers::invalid_unsigned_int)
463  real_fe_index = 0;
464 
465  // some checks
466  Assert(real_q_index < this->q_collection.size(),
467  ExcIndexRange(real_q_index, 0, this->q_collection.size()));
468  Assert(real_mapping_index < this->mapping_collection->size(),
469  ExcIndexRange(real_mapping_index,
470  0,
471  this->mapping_collection->size()));
472  Assert(real_fe_index < this->fe_collection->size(),
473  ExcIndexRange(real_fe_index, 0, this->fe_collection->size()));
474 
475  // now finally actually get the
476  // corresponding object and
477  // initialize it
478  this->select_fe_values(real_fe_index, real_mapping_index, real_q_index)
479  .reinit(cell, face_no, subface_no);
480  }
481 } // namespace hp
482 
483 
484 // explicit instantiations
485 #include "fe_values.inst"
486 
487 
488 DEAL_II_NAMESPACE_CLOSE
static const unsigned int invalid_unsigned_int
Definition: types.h:173
FEValuesType & select_fe_values(const unsigned int fe_index, const unsigned int mapping_index, const unsigned int q_index)
Definition: fe_values.cc:71
void reinit(const TriaIterator< DoFCellAccessor< DoFHandlerType, lda >> cell, const unsigned int face_no, const unsigned int subface_no, const unsigned int q_index=numbers::invalid_unsigned_int, const unsigned int mapping_index=numbers::invalid_unsigned_int, const unsigned int fe_index=numbers::invalid_unsigned_int)
Definition: fe_values.cc:390
FEValuesBase(const unsigned int n_q_points, const unsigned int dofs_per_cell, const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const FiniteElement< dim, spacedim > &fe)
Definition: fe_values.cc:3082
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
FEValuesBase(const ::hp::MappingCollection< dim, FEValuesType::space_dimension > &mapping_collection, const ::hp::FECollection< dim, FEValuesType::space_dimension > &fe_collection, const ::hp::QCollection< q_dim > &q_collection, const ::UpdateFlags update_flags)
#define Assert(cond, exc)
Definition: exceptions.h:1407
UpdateFlags
FEFaceValues(const hp::MappingCollection< dim, spacedim > &mapping_collection, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim - 1 > &q_collection, const UpdateFlags update_flags)
Definition: fe_values.cc:235
void reinit(const TriaIterator< DoFCellAccessor< DoFHandlerType, lda >> cell, const unsigned int q_index=numbers::invalid_unsigned_int, const unsigned int mapping_index=numbers::invalid_unsigned_int, const unsigned int fe_index=numbers::invalid_unsigned_int)
Definition: fe_values.cc:142
Definition: hp.h:117
FEValues(const ::hp::MappingCollection< dim, spacedim > &mapping_collection, const ::hp::FECollection< dim, spacedim > &fe_collection, const ::hp::QCollection< dim > &q_collection, const UpdateFlags update_flags)
Definition: fe.h:38
FEValues(const Mapping< dim, spacedim > &mapping, const FiniteElement< dim, spacedim > &fe, const Quadrature< dim > &quadrature, const UpdateFlags update_flags)
Definition: fe_values.cc:4412
FESubfaceValues(const hp::MappingCollection< dim, spacedim > &mapping_collection, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim - 1 > &q_collection, const UpdateFlags update_flags)
Definition: fe_values.cc:360
void reinit(const TriaIterator< DoFCellAccessor< DoFHandlerType, lda >> cell, const unsigned int face_no, const unsigned int q_index=numbers::invalid_unsigned_int, const unsigned int mapping_index=numbers::invalid_unsigned_int, const unsigned int fe_index=numbers::invalid_unsigned_int)
Definition: fe_values.cc:265