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