Reference documentation for deal.II version 8.4.2
fe.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2015 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/base/memory_consumption.h>
17 #include <deal.II/fe/mapping.h>
18 #include <deal.II/fe/fe.h>
19 #include <deal.II/fe/fe_values.h>
20 #include <deal.II/base/quadrature.h>
21 #include <deal.II/base/qprojector.h>
22 #include <deal.II/grid/tria.h>
23 #include <deal.II/grid/tria_iterator.h>
24 #include <deal.II/dofs/dof_accessor.h>
25 #include <deal.II/grid/tria_boundary.h>
26 
27 #include <algorithm>
28 #include <functional>
29 #include <numeric>
30 
31 DEAL_II_NAMESPACE_OPEN
32 
33 
34 /*------------------------------- FiniteElement ----------------------*/
35 
36 
37 template <int dim, int spacedim>
39  update_each(update_default)
40 {}
41 
42 
43 
44 template <int dim, int spacedim>
46 {}
47 
48 
49 
50 template <int dim, int spacedim>
51 std::size_t
53 {
54  return sizeof(*this);
55 }
56 
57 
58 
59 template <int dim, int spacedim>
62  const std::vector<bool> &r_i_a_f,
63  const std::vector<ComponentMask> &nonzero_c)
64  :
65  FiniteElementData<dim> (fe_data),
67  this->dofs_per_quad : 0 ,
68  dim==3 ? 8 : 0),
70  this->dofs_per_line : 0),
74  std::make_pair(std::make_pair(0U, 0U), 0U)),
75 
76  // Special handling of vectors of length one: in this case, we
77  // assume that all entries were supposed to be equal
78  restriction_is_additive_flags(r_i_a_f.size() == 1
79  ?
80  std::vector<bool> (fe_data.dofs_per_cell, r_i_a_f[0])
81  :
82  r_i_a_f),
83  nonzero_components (nonzero_c.size() == 1
84  ?
85  std::vector<ComponentMask> (fe_data.dofs_per_cell, nonzero_c[0])
86  :
87  nonzero_c),
89 {
90  this->set_primitivity(std::find_if (n_nonzero_components_table.begin(),
92  std::bind2nd(std::not_equal_to<unsigned int>(),
93  1U))
95 
96 
98  ExcDimensionMismatch(restriction_is_additive_flags.size(),
99  this->dofs_per_cell));
101  for (unsigned int i=0; i<nonzero_components.size(); ++i)
102  {
103  Assert (nonzero_components[i].size() == this->n_components(),
104  ExcInternalError());
105  Assert (nonzero_components[i].n_selected_components ()
106  >= 1,
107  ExcInternalError());
109  ExcInternalError());
111  ExcInternalError());
112  }
113 
114  // initialize some tables in the default way, i.e. if there is only one
115  // (vector-)component; if the element is not primitive, leave these tables
116  // empty.
117  if (this->is_primitive())
118  {
121  for (unsigned int j=0 ; j<this->dofs_per_cell ; ++j)
122  system_to_component_table[j] = std::pair<unsigned,unsigned>(0,j);
123  for (unsigned int j=0 ; j<this->dofs_per_face ; ++j)
124  face_system_to_component_table[j] = std::pair<unsigned,unsigned>(0,j);
125  }
126 
127  for (unsigned int j=0 ; j<this->dofs_per_cell ; ++j)
128  system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j);
129  for (unsigned int j=0 ; j<this->dofs_per_face ; ++j)
130  face_system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j);
131 
132  // Fill with default value; may be changed by constructor of derived class.
134 
135  // initialize the restriction and prolongation matrices. the default
136  // constructor of FullMatrix<dim> initializes them with size zero
139  for (unsigned int ref=RefinementCase<dim>::cut_x;
140  ref<RefinementCase<dim>::isotropic_refinement+1; ++ref)
141  {
142  prolongation[ref-1].resize (GeometryInfo<dim>::
143  n_children(RefinementCase<dim>(ref)),
145  restriction[ref-1].resize (GeometryInfo<dim>::
146  n_children(RefinementCase<dim>(ref)),
148  }
149 
151 }
152 
153 
154 
155 template <int dim, int spacedim>
157 {}
158 
159 
160 
161 
162 template <int dim, int spacedim>
163 double
165  const Point<dim> &) const
166 {
167  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
168  return 0.;
169 }
170 
171 
172 
173 template <int dim, int spacedim>
174 double
176  const Point<dim> &,
177  const unsigned int) const
178 {
179  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
180  return 0.;
181 }
182 
183 
184 
185 template <int dim, int spacedim>
188  const Point<dim> &) const
189 {
190  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
191  return Tensor<1,dim> ();
192 }
193 
194 
195 
196 template <int dim, int spacedim>
199  const Point<dim> &,
200  const unsigned int) const
201 {
202  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
203  return Tensor<1,dim> ();
204 }
205 
206 
207 
208 template <int dim, int spacedim>
211  const Point<dim> &) const
212 {
213  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
214  return Tensor<2,dim> ();
215 }
216 
217 
218 
219 template <int dim, int spacedim>
222  const Point<dim> &,
223  const unsigned int) const
224 {
225  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
226  return Tensor<2,dim> ();
227 }
228 
229 
230 
231 template <int dim, int spacedim>
234  const Point<dim> &) const
235 {
236  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
237  return Tensor<3,dim> ();
238 }
239 
240 
241 
242 template <int dim, int spacedim>
245  const Point<dim> &,
246  const unsigned int) const
247 {
248  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
249  return Tensor<3,dim> ();
250 }
251 
252 
253 
254 template <int dim, int spacedim>
257  const Point<dim> &) const
258 {
259  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
260  return Tensor<4,dim> ();
261 }
262 
263 
264 
265 template <int dim, int spacedim>
268  const Point<dim> &,
269  const unsigned int) const
270 {
271  AssertThrow(false, ExcUnitShapeValuesDoNotExist());
272  return Tensor<4,dim> ();
273 }
274 
275 
276 template <int dim, int spacedim>
277 void
279  const bool isotropic_restriction_only,
280  const bool isotropic_prolongation_only)
281 {
282  for (unsigned int ref_case=RefinementCase<dim>::cut_x;
283  ref_case <= RefinementCase<dim>::isotropic_refinement; ++ref_case)
284  {
285  const unsigned int nc = GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
286 
287  for (unsigned int i=0; i<nc; ++i)
288  {
289  if (this->restriction[ref_case-1][i].m() != this->dofs_per_cell
290  &&
291  (!isotropic_restriction_only || ref_case==RefinementCase<dim>::isotropic_refinement))
292  this->restriction[ref_case-1][i].reinit (this->dofs_per_cell,
293  this->dofs_per_cell);
294  if (this->prolongation[ref_case-1][i].m() != this->dofs_per_cell
295  &&
296  (!isotropic_prolongation_only || ref_case==RefinementCase<dim>::isotropic_refinement))
297  this->prolongation[ref_case-1][i].reinit (this->dofs_per_cell,
298  this->dofs_per_cell);
299  }
300  }
301 }
302 
303 
304 template <int dim, int spacedim>
305 const FullMatrix<double> &
307  const RefinementCase<dim> &refinement_case) const
308 {
310  ExcIndexRange(refinement_case,0,RefinementCase<dim>::isotropic_refinement+1));
311  Assert (refinement_case!=RefinementCase<dim>::no_refinement,
312  ExcMessage("Restriction matrices are only available for refined cells!"));
314  ExcIndexRange(child,0,GeometryInfo<dim>::n_children(RefinementCase<dim>(refinement_case))));
315  // we use refinement_case-1 here. the -1 takes care of the origin of the
316  // vector, as for RefinementCase<dim>::no_refinement (=0) there is no data
317  // available and so the vector indices are shifted
318  Assert (restriction[refinement_case-1][child].n() == this->dofs_per_cell, ExcProjectionVoid());
319  return restriction[refinement_case-1][child];
320 }
321 
322 
323 
324 template <int dim, int spacedim>
325 const FullMatrix<double> &
327  const RefinementCase<dim> &refinement_case) const
328 {
330  ExcIndexRange(refinement_case,0,RefinementCase<dim>::isotropic_refinement+1));
331  Assert (refinement_case!=RefinementCase<dim>::no_refinement,
332  ExcMessage("Prolongation matrices are only available for refined cells!"));
334  ExcIndexRange(child,0,GeometryInfo<dim>::n_children(RefinementCase<dim>(refinement_case))));
335  // we use refinement_case-1 here. the -1 takes care
336  // of the origin of the vector, as for
337  // RefinementCase::no_refinement (=0) there is no
338  // data available and so the vector indices
339  // are shifted
340  Assert (prolongation[refinement_case-1][child].n() == this->dofs_per_cell, ExcEmbeddingVoid());
341  return prolongation[refinement_case-1][child];
342 }
343 
344 
345 //TODO:[GK] This is probably not the most efficient way of doing this.
346 template <int dim, int spacedim>
347 unsigned int
349 {
350  Assert (index < this->n_components(),
351  ExcIndexRange(index, 0, this->n_components()));
352 
353  return first_block_of_base(component_to_base_table[index].first.first)
354  + component_to_base_table[index].second;
355 }
356 
357 
358 template <int dim, int spacedim>
362 {
363  AssertIndexRange(scalar.component, this->n_components());
364 
365 //TODO: it would be nice to verify that it is indeed possible
366 // to select this scalar component, i.e., that it is not part
367 // of a non-primitive element. unfortunately, there is no simple
368 // way to write such a condition...
369 
370  std::vector<bool> mask (this->n_components(), false);
371  mask[scalar.component] = true;
372  return mask;
373 }
374 
375 
376 template <int dim, int spacedim>
380 {
381  AssertIndexRange(vector.first_vector_component+dim-1, this->n_components());
382 
383  //TODO: it would be nice to verify that it is indeed possible
384  // to select these vector components, i.e., that they don't span
385  // beyond the beginning or end of anon-primitive element.
386  // unfortunately, there is no simple way to write such a condition...
387 
388  std::vector<bool> mask (this->n_components(), false);
389  for (unsigned int c=vector.first_vector_component; c<vector.first_vector_component+dim; ++c)
390  mask[c] = true;
391  return mask;
392 }
393 
394 
395 template <int dim, int spacedim>
399 {
402  this->n_components());
403 
404  //TODO: it would be nice to verify that it is indeed possible
405  // to select these vector components, i.e., that they don't span
406  // beyond the beginning or end of anon-primitive element.
407  // unfortunately, there is no simple way to write such a condition...
408 
409  std::vector<bool> mask (this->n_components(), false);
410  for (unsigned int c=sym_tensor.first_tensor_component;
412  mask[c] = true;
413  return mask;
414 }
415 
416 
417 
418 template <int dim, int spacedim>
422 {
423  // if we get a block mask that represents all blocks, then
424  // do the same for the returned component mask
425  if (block_mask.represents_the_all_selected_mask())
426  return ComponentMask();
427 
428  AssertDimension(block_mask.size(), this->n_blocks());
429 
430  std::vector<bool> component_mask (this->n_components(), false);
431  for (unsigned int c=0; c<this->n_components(); ++c)
432  if (block_mask[component_to_block_index(c)] == true)
433  component_mask[c] = true;
434 
435  return component_mask;
436 }
437 
438 
439 
440 template <int dim, int spacedim>
441 BlockMask
444 {
445  // simply create the corresponding component mask (a simpler
446  // process) and then convert it to a block mask
447  return block_mask(component_mask(scalar));
448 }
449 
450 
451 template <int dim, int spacedim>
452 BlockMask
455 {
456  // simply create the corresponding component mask (a simpler
457  // process) and then convert it to a block mask
458  return block_mask(component_mask(vector));
459 }
460 
461 
462 template <int dim, int spacedim>
463 BlockMask
466 {
467  // simply create the corresponding component mask (a simpler
468  // process) and then convert it to a block mask
469  return block_mask(component_mask(sym_tensor));
470 }
471 
472 
473 
474 template <int dim, int spacedim>
475 BlockMask
478 {
479  // if we get a component mask that represents all component, then
480  // do the same for the returned block mask
481  if (component_mask.represents_the_all_selected_mask())
482  return BlockMask();
483 
484  AssertDimension(component_mask.size(), this->n_components());
485 
486  // walk over all of the components
487  // of this finite element and see
488  // if we need to set the
489  // corresponding block. inside the
490  // block, walk over all the
491  // components that correspond to
492  // this block and make sure the
493  // component mask is set for all of
494  // them
495  std::vector<bool> block_mask (this->n_blocks(), false);
496  for (unsigned int c=0; c<this->n_components();)
497  {
498  const unsigned int block = component_to_block_index(c);
499  if (component_mask[c] == true)
500  block_mask[block] = true;
501 
502  // now check all of the other
503  // components that correspond
504  // to this block
505  ++c;
506  while ((c<this->n_components())
507  &&
508  (component_to_block_index(c) == block))
509  {
510  Assert (component_mask[c] == block_mask[block],
511  ExcMessage ("The component mask argument given to this function "
512  "is not a mask where the individual components belonging "
513  "to one block of the finite element are either all "
514  "selected or not selected. You can't call this function "
515  "with a component mask that splits blocks."));
516  ++c;
517  }
518  }
519 
520 
521  return block_mask;
522 }
523 
524 
525 
526 template <int dim, int spacedim>
527 unsigned int
529 face_to_cell_index (const unsigned int face_index,
530  const unsigned int face,
531  const bool face_orientation,
532  const bool face_flip,
533  const bool face_rotation) const
534 {
535  Assert (face_index < this->dofs_per_face,
536  ExcIndexRange(face_index, 0, this->dofs_per_face));
538  ExcIndexRange(face, 0, GeometryInfo<dim>::faces_per_cell));
539 
540 //TODO: we could presumably solve the 3d case below using the
541 // adjust_quad_dof_index_for_face_orientation_table field. for the
542 // 2d case, we can't use adjust_line_dof_index_for_line_orientation_table
543 // since that array is empty (presumably because we thought that
544 // there are no flipped edges in 2d, but these can happen in
545 // DoFTools::make_periodicity_constraints, for example). so we
546 // would need to either fill this field, or rely on derived classes
547 // implementing this function, as we currently do
548 
549  // see the function's documentation for an explanation of this
550  // assertion -- in essence, derived classes have to implement
551  // an overloaded version of this function if we are to use any
552  // other than standard orientation
553  if ((face_orientation != true) || (face_flip != false) || (face_rotation != false))
554  Assert ((this->dofs_per_line <= 1) && (this->dofs_per_quad <= 1),
555  ExcMessage ("The function in this base class can not handle this case. "
556  "Rather, the derived class you are using must provide "
557  "an overloaded version but apparently hasn't done so. See "
558  "the documentation of this function for more information."));
559 
560  // we need to distinguish between DoFs on vertices, lines and in 3d quads.
561  // do so in a sequence of if-else statements
562  if (face_index < this->first_face_line_index)
563  // DoF is on a vertex
564  {
565  // get the number of the vertex on the face that corresponds to this DoF,
566  // along with the number of the DoF on this vertex
567  const unsigned int face_vertex = face_index / this->dofs_per_vertex;
568  const unsigned int dof_index_on_vertex = face_index % this->dofs_per_vertex;
569 
570  // then get the number of this vertex on the cell and translate
571  // this to a DoF number on the cell
572  return (GeometryInfo<dim>::face_to_cell_vertices(face, face_vertex,
573  face_orientation,
574  face_flip,
575  face_rotation)
576  * this->dofs_per_vertex
577  +
578  dof_index_on_vertex);
579  }
580  else if (face_index < this->first_face_quad_index)
581  // DoF is on a face
582  {
583  // do the same kind of translation as before. we need to only consider
584  // DoFs on the lines, i.e., ignoring those on the vertices
585  const unsigned int index = face_index - this->first_face_line_index;
586 
587  const unsigned int face_line = index / this->dofs_per_line;
588  const unsigned int dof_index_on_line = index % this->dofs_per_line;
589 
590  return (this->first_line_index
591  + GeometryInfo<dim>::face_to_cell_lines(face, face_line,
592  face_orientation,
593  face_flip,
594  face_rotation)
595  * this->dofs_per_line
596  +
597  dof_index_on_line);
598  }
599  else
600  // DoF is on a quad
601  {
602  Assert (dim >= 3, ExcInternalError());
603 
604  // ignore vertex and line dofs
605  const unsigned int index = face_index - this->first_face_quad_index;
606 
607  return (this->first_quad_index
608  + face * this->dofs_per_quad
609  + index);
610  }
611 }
612 
613 
614 
615 
616 template <int dim, int spacedim>
617 unsigned int
619  const bool face_orientation,
620  const bool face_flip,
621  const bool face_rotation) const
622 {
623  // general template for 1D and 2D: not
624  // implemented. in fact, the function
625  // shouldn't even be called unless we are
626  // in 3d, so throw an internal error
627  Assert (dim==3, ExcInternalError());
628  if (dim < 3)
629  return index;
630 
631  // adjust dofs on 3d faces if the face is
632  // flipped. note that we query a table that
633  // derived elements need to have set up
634  // front. the exception are discontinuous
635  // elements for which there should be no
636  // face dofs anyway (i.e. dofs_per_quad==0
637  // in 3d), so we don't need the table, but
638  // the function should also not have been
639  // called
640  Assert (index<this->dofs_per_quad, ExcIndexRange(index,0,this->dofs_per_quad));
642  ExcInternalError());
643  return index+adjust_quad_dof_index_for_face_orientation_table(index,4*face_orientation+2*face_flip+face_rotation);
644 }
645 
646 
647 
648 template <int dim, int spacedim>
649 unsigned int
651  const bool line_orientation) const
652 {
653  // general template for 1D and 2D: do
654  // nothing. Do not throw an Assertion,
655  // however, in order to allow to call this
656  // function in 2D as well
657  if (dim<3)
658  return index;
659 
660  Assert (index<this->dofs_per_line, ExcIndexRange(index,0,this->dofs_per_line));
662  ExcInternalError());
663  if (line_orientation)
664  return index;
665  else
667 }
668 
669 
670 
671 template <int dim, int spacedim>
672 bool
674 {
675  for (unsigned int ref_case=RefinementCase<dim>::cut_x;
676  ref_case<RefinementCase<dim>::isotropic_refinement+1; ++ref_case)
677  for (unsigned int c=0;
678  c<GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case)); ++c)
679  {
680  // make sure also the lazily initialized matrices are created
682  Assert ((prolongation[ref_case-1][c].m() == this->dofs_per_cell) ||
683  (prolongation[ref_case-1][c].m() == 0),
684  ExcInternalError());
685  Assert ((prolongation[ref_case-1][c].n() == this->dofs_per_cell) ||
686  (prolongation[ref_case-1][c].n() == 0),
687  ExcInternalError());
688  if ((prolongation[ref_case-1][c].m() == 0) ||
689  (prolongation[ref_case-1][c].n() == 0))
690  return false;
691  }
692  return true;
693 }
694 
695 
696 
697 template <int dim, int spacedim>
698 bool
700 {
701  for (unsigned int ref_case=RefinementCase<dim>::cut_x;
702  ref_case<RefinementCase<dim>::isotropic_refinement+1; ++ref_case)
703  for (unsigned int c=0;
704  c<GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case)); ++c)
705  {
706  // make sure also the lazily initialized matrices are created
708  Assert ((restriction[ref_case-1][c].m() == this->dofs_per_cell) ||
709  (restriction[ref_case-1][c].m() == 0),
710  ExcInternalError());
711  Assert ((restriction[ref_case-1][c].n() == this->dofs_per_cell) ||
712  (restriction[ref_case-1][c].n() == 0),
713  ExcInternalError());
714  if ((restriction[ref_case-1][c].m() == 0) ||
715  (restriction[ref_case-1][c].n() == 0))
716  return false;
717  }
718  return true;
719 }
720 
721 
722 
723 template <int dim, int spacedim>
724 bool
726 {
728 
729  for (unsigned int c=0;
730  c<GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case)); ++c)
731  {
732  // make sure also the lazily initialized matrices are created
734  Assert ((prolongation[ref_case-1][c].m() == this->dofs_per_cell) ||
735  (prolongation[ref_case-1][c].m() == 0),
736  ExcInternalError());
737  Assert ((prolongation[ref_case-1][c].n() == this->dofs_per_cell) ||
738  (prolongation[ref_case-1][c].n() == 0),
739  ExcInternalError());
740  if ((prolongation[ref_case-1][c].m() == 0) ||
741  (prolongation[ref_case-1][c].n() == 0))
742  return false;
743  }
744  return true;
745 }
746 
747 
748 
749 template <int dim, int spacedim>
750 bool
752 {
754 
755  for (unsigned int c=0;
756  c<GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case)); ++c)
757  {
758  // make sure also the lazily initialized matrices are created
760  Assert ((restriction[ref_case-1][c].m() == this->dofs_per_cell) ||
761  (restriction[ref_case-1][c].m() == 0),
762  ExcInternalError());
763  Assert ((restriction[ref_case-1][c].n() == this->dofs_per_cell) ||
764  (restriction[ref_case-1][c].n() == 0),
765  ExcInternalError());
766  if ((restriction[ref_case-1][c].m() == 0) ||
767  (restriction[ref_case-1][c].n() == 0))
768  return false;
769  }
770  return true;
771 }
772 
773 
774 
775 template <int dim, int spacedim>
776 bool
778 {
780  return (this->dofs_per_face == 0) || (interface_constraints.m() != 0);
781  else
782  return false;
783 }
784 
785 
786 
787 template <int dim, int spacedim>
788 bool
790 {
791  return false;
792 }
793 
794 
795 
796 template <int dim, int spacedim>
797 const FullMatrix<double> &
799 {
800  (void)subface_case;
802  ExcMessage("Constraints for this element are only implemented "
803  "for the case that faces are refined isotropically "
804  "(which is always the case in 2d, and in 3d requires "
805  "that the neighboring cell of a coarse cell presents "
806  "exactly four children on the common face)."));
807  Assert ((this->dofs_per_face == 0) || (interface_constraints.m() != 0),
808  ExcMessage ("The finite element for which you try to obtain "
809  "hanging node constraints does not appear to "
810  "implement them."));
811 
812  if (dim==1)
814  ExcWrongInterfaceMatrixSize(interface_constraints.m(),
816 
817  return interface_constraints;
818 }
819 
820 
821 
822 template <int dim, int spacedim>
825 {
826  switch (dim)
827  {
828  case 1:
829  return TableIndices<2> (0U, 0U);
830  case 2:
831  return TableIndices<2> (this->dofs_per_vertex +
832  2*this->dofs_per_line,
833  this->dofs_per_face);
834  case 3:
835  return TableIndices<2> (5*this->dofs_per_vertex +
836  12*this->dofs_per_line +
837  4*this->dofs_per_quad,
838  this->dofs_per_face);
839  default:
840  Assert (false, ExcNotImplemented());
841  };
844 }
845 
846 
847 
848 template <int dim, int spacedim>
849 void
852  FullMatrix<double> &) const
853 {
854  // by default, no interpolation
855  // implemented. so throw exception,
856  // as documentation says
857  typedef FiniteElement<dim,spacedim> FEE;
858  AssertThrow (false,
859  typename FEE::
860  ExcInterpolationNotImplemented());
861 }
862 
863 
864 
865 template <int dim, int spacedim>
866 void
869  FullMatrix<double> &) const
870 {
871  // by default, no interpolation
872  // implemented. so throw exception,
873  // as documentation says
874  typedef FiniteElement<dim,spacedim> FEE;
875  AssertThrow (false,
876  typename FEE::
877  ExcInterpolationNotImplemented());
878 }
879 
880 
881 
882 template <int dim, int spacedim>
883 void
886  const unsigned int,
887  FullMatrix<double> &) const
888 {
889  // by default, no interpolation
890  // implemented. so throw exception,
891  // as documentation says
892  typedef FiniteElement<dim,spacedim> FEE;
893  AssertThrow (false,
894  typename FEE::ExcInterpolationNotImplemented());
895 }
896 
897 
898 
899 template <int dim, int spacedim>
900 std::vector<std::pair<unsigned int, unsigned int> >
903 {
904  Assert (false, ExcNotImplemented());
905  return std::vector<std::pair<unsigned int, unsigned int> > ();
906 }
907 
908 
909 
910 template <int dim, int spacedim>
911 std::vector<std::pair<unsigned int, unsigned int> >
914 {
915  Assert (false, ExcNotImplemented());
916  return std::vector<std::pair<unsigned int, unsigned int> > ();
917 }
918 
919 
920 
921 template <int dim, int spacedim>
922 std::vector<std::pair<unsigned int, unsigned int> >
925 {
926  Assert (false, ExcNotImplemented());
927  return std::vector<std::pair<unsigned int, unsigned int> > ();
928 }
929 
930 
931 
932 template <int dim, int spacedim>
936 {
937  Assert (false, ExcNotImplemented());
938  return FiniteElementDomination::neither_element_dominates;
939 }
940 
941 
942 
943 template <int dim, int spacedim>
944 bool
946 {
947  return ((static_cast<const FiniteElementData<dim>&>(*this) ==
948  static_cast<const FiniteElementData<dim>&>(f)) &&
950 }
951 
952 
953 
954 template <int dim, int spacedim>
955 const std::vector<Point<dim> > &
957 {
958  // a finite element may define
959  // support points, but only if
960  // there are as many as there are
961  // degrees of freedom
962  Assert ((unit_support_points.size() == 0) ||
963  (unit_support_points.size() == this->dofs_per_cell),
964  ExcInternalError());
965  return unit_support_points;
966 }
967 
968 
969 
970 template <int dim, int spacedim>
971 bool
973 {
974  return (unit_support_points.size() != 0);
975 }
976 
977 
978 
979 template <int dim, int spacedim>
980 const std::vector<Point<dim> > &
982 {
983  // a finite element may define
984  // support points, but only if
985  // there are as many as there are
986  // degrees of freedom
987  return ((generalized_support_points.size() == 0)
990 }
991 
992 
993 
994 template <int dim, int spacedim>
995 bool
997 {
998  return (get_generalized_support_points().size() != 0);
999 }
1000 
1001 
1002 
1003 template <int dim, int spacedim>
1004 Point<dim>
1005 FiniteElement<dim,spacedim>::unit_support_point (const unsigned int index) const
1006 {
1007  Assert (index < this->dofs_per_cell,
1008  ExcIndexRange (index, 0, this->dofs_per_cell));
1009  Assert (unit_support_points.size() == this->dofs_per_cell,
1010  ExcFEHasNoSupportPoints ());
1011  return unit_support_points[index];
1012 }
1013 
1014 
1015 
1016 template <int dim, int spacedim>
1017 const std::vector<Point<dim-1> > &
1019 {
1020  // a finite element may define
1021  // support points, but only if
1022  // there are as many as there are
1023  // degrees of freedom on a face
1024  Assert ((unit_face_support_points.size() == 0) ||
1025  (unit_face_support_points.size() == this->dofs_per_face),
1026  ExcInternalError());
1027  return unit_face_support_points;
1028 }
1029 
1030 
1031 
1032 template <int dim, int spacedim>
1033 bool
1035 {
1036  return (unit_face_support_points.size() != 0);
1037 }
1038 
1039 
1040 
1041 template <int dim, int spacedim>
1042 const std::vector<Point<dim-1> > &
1044 {
1045  // a finite element may define
1046  // support points, but only if
1047  // there are as many as there are
1048  // degrees of freedom on a face
1049  return ((generalized_face_support_points.size() == 0)
1052 }
1053 
1054 
1055 
1056 template <int dim, int spacedim>
1057 bool
1059 {
1060  return (generalized_face_support_points.size() != 0);
1061 }
1062 
1063 
1064 
1065 template <int dim, int spacedim>
1066 Point<dim-1>
1068 {
1069  Assert (index < this->dofs_per_face,
1070  ExcIndexRange (index, 0, this->dofs_per_face));
1072  ExcFEHasNoSupportPoints ());
1073  return unit_face_support_points[index];
1074 }
1075 
1076 
1077 
1078 template <int dim, int spacedim>
1079 bool
1081  const unsigned int,
1082  const unsigned int) const
1083 {
1084  return true;
1085 }
1086 
1087 
1088 
1089 template <int dim, int spacedim>
1090 std::pair<Table<2,bool>, std::vector<unsigned int> >
1092 {
1093  Assert (false, ExcNotImplemented());
1094  return std::pair<Table<2,bool>, std::vector<unsigned int> >
1095  (Table<2,bool>(this->n_components(), this->dofs_per_cell),
1096  std::vector<unsigned int>(this->n_components()));
1097 }
1098 
1099 
1100 
1101 template <int dim, int spacedim>
1102 void
1104  std::vector<double> &local_dofs,
1105  const std::vector<double> &values) const
1106 {
1107  Assert (has_support_points(), ExcFEHasNoSupportPoints());
1108  Assert (values.size() == unit_support_points.size(),
1109  ExcDimensionMismatch(values.size(), unit_support_points.size()));
1110  Assert (local_dofs.size() == this->dofs_per_cell,
1111  ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell));
1112  Assert (this->n_components() == 1,
1113  ExcDimensionMismatch(this->n_components(), 1));
1114 
1115  std::copy(values.begin(), values.end(), local_dofs.begin());
1116 }
1117 
1118 
1119 
1120 
1121 template <int dim, int spacedim>
1122 void
1124  std::vector<double> &local_dofs,
1125  const std::vector<Vector<double> > &values,
1126  unsigned int offset) const
1127 {
1128  Assert (has_support_points(), ExcFEHasNoSupportPoints());
1129  Assert (values.size() == unit_support_points.size(),
1130  ExcDimensionMismatch(values.size(), unit_support_points.size()));
1131  Assert (local_dofs.size() == this->dofs_per_cell,
1132  ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell));
1133  Assert (values[0].size() >= offset+this->n_components(),
1134  ExcDimensionMismatch(values[0].size(),offset+this->n_components()));
1135 
1136  for (unsigned int i=0; i<this->dofs_per_cell; ++i)
1137  {
1138  const std::pair<unsigned int, unsigned int> index
1139  = this->system_to_component_index(i);
1140  local_dofs[i] = values[i](offset+index.first);
1141  }
1142 }
1143 
1144 
1145 
1146 
1147 template <int dim, int spacedim>
1148 void
1150  std::vector<double> &local_dofs,
1151  const VectorSlice<const std::vector<std::vector<double> > > &values) const
1152 {
1153  Assert (has_support_points(), ExcFEHasNoSupportPoints());
1154  Assert (values[0].size() == unit_support_points.size(),
1155  ExcDimensionMismatch(values.size(), unit_support_points.size()));
1156  Assert (local_dofs.size() == this->dofs_per_cell,
1157  ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell));
1158  Assert (values.size() == this->n_components(),
1159  ExcDimensionMismatch(values.size(), this->n_components()));
1160 
1161  for (unsigned int i=0; i<this->dofs_per_cell; ++i)
1162  {
1163  const std::pair<unsigned int, unsigned int> index
1164  = this->system_to_component_index(i);
1165  local_dofs[i] = values[index.first][i];
1166  }
1167 }
1168 
1169 
1170 
1171 template <int dim, int spacedim>
1172 std::size_t
1174 {
1175  return (sizeof(FiniteElementData<dim>) +
1187 }
1188 
1189 
1190 
1191 template <int dim, int spacedim>
1192 std::vector<unsigned int>
1194  const std::vector<ComponentMask> &nonzero_components)
1195 {
1196  std::vector<unsigned int> retval (nonzero_components.size());
1197  for (unsigned int i=0; i<nonzero_components.size(); ++i)
1198  retval[i] = nonzero_components[i].n_selected_components();
1199  return retval;
1200 }
1201 
1202 
1203 
1204 /*------------------------------- FiniteElement ----------------------*/
1205 
1206 template <int dim, int spacedim>
1209  const Mapping<dim,spacedim> &mapping,
1210  const Quadrature<dim-1> &quadrature,
1212 {
1213  return get_data (flags, mapping,
1215  output_data);
1216 }
1217 
1218 
1219 
1220 template <int dim, int spacedim>
1223  const Mapping<dim,spacedim> &mapping,
1224  const Quadrature<dim-1> &quadrature,
1226 {
1227  return get_data (flags, mapping,
1229  output_data);
1230 }
1231 
1232 
1233 
1234 template <int dim, int spacedim>
1236 FiniteElement<dim,spacedim>::base_element(const unsigned int index) const
1237 {
1238  (void)index;
1239  Assert (index==0, ExcIndexRange(index,0,1));
1240  // This function should not be
1241  // called for a system element
1242  Assert (base_to_block_indices.size() == 1, ExcInternalError());
1243  return *this;
1244 }
1245 
1246 
1247 
1248 /*------------------------------- Explicit Instantiations -------------*/
1249 #include "fe.inst"
1250 
1251 
1252 DEAL_II_NAMESPACE_CLOSE
bool represents_the_all_selected_mask() const
Definition: block_mask.h:340
size_type m() const
bool is_primitive() const
static const unsigned int invalid_unsigned_int
Definition: types.h:164
BlockMask block_mask(const FEValuesExtractors::Scalar &scalar) const
Definition: fe.cc:443
virtual Tensor< 2, dim > shape_grad_grad_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
Definition: fe.cc:221
std::vector< std::vector< FullMatrix< double > > > restriction
Definition: fe.h:2106
const unsigned int components
Definition: fe_base.h:293
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1052
virtual std::size_t memory_consumption() const
Definition: fe.cc:52
const std::vector< Point< dim-1 > > & get_unit_face_support_points() const
Definition: fe.cc:1018
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix) const
Definition: fe.cc:868
virtual InternalDataBase * get_data(const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const Quadrature< dim > &quadrature, ::internal::FEValues::FiniteElementRelatedData< dim, spacedim > &output_data) const =0
std::vector< Point< dim > > generalized_support_points
Definition: fe.h:2157
virtual Tensor< 3, dim > shape_3rd_derivative(const unsigned int i, const Point< dim > &p) const
Definition: fe.cc:233
FullMatrix< double > interface_constraints
Definition: fe.h:2132
FiniteElement(const FiniteElementData< dim > &fe_data, const std::vector< bool > &restriction_is_additive_flags, const std::vector< ComponentMask > &nonzero_components)
Definition: fe.cc:61
virtual double shape_value_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
Definition: fe.cc:175
virtual void get_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix) const
Definition: fe.cc:851
virtual Point< dim > unit_support_point(const unsigned int index) const
Definition: fe.cc:1005
bool restriction_is_implemented() const
Definition: fe.cc:699
const std::vector< Point< dim > > & get_generalized_support_points() const
Definition: fe.cc:981
virtual void interpolate(std::vector< double > &local_dofs, const std::vector< double > &values) const
Definition: fe.cc:1103
virtual Tensor< 1, dim > shape_grad(const unsigned int i, const Point< dim > &p) const
Definition: fe.cc:187
virtual Tensor< 3, dim > shape_3rd_derivative_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
Definition: fe.cc:244
::ExceptionBase & ExcMessage(std::string arg1)
#define AssertIndexRange(index, range)
Definition: exceptions.h:1081
const unsigned int dofs_per_quad
Definition: fe_base.h:238
Table< 2, int > adjust_quad_dof_index_for_face_orientation_table
Definition: fe.h:2180
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_quad_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const
Definition: fe.cc:924
bool isotropic_prolongation_is_implemented() const
Definition: fe.cc:725
std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > component_to_base_table
Definition: fe.h:2260
bool has_generalized_support_points() const
Definition: fe.cc:996
bool represents_the_all_selected_mask() const
STL namespace.
ComponentMask component_mask(const FEValuesExtractors::Scalar &scalar) const
Definition: fe.cc:361
#define AssertThrow(cond, exc)
Definition: exceptions.h:358
static std::vector< unsigned int > compute_n_nonzero_components(const std::vector< ComponentMask > &nonzero_components)
Definition: fe.cc:1193
std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > face_system_to_base_table
Definition: fe.h:2236
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
Definition: fe.cc:326
const std::vector< unsigned int > n_nonzero_components_table
Definition: fe.h:2285
const unsigned int dofs_per_line
Definition: fe_base.h:232
size_type n_elements() const
unsigned int n_blocks() const
bool has_face_support_points() const
Definition: fe.cc:1034
bool operator==(const FiniteElement< dim, spacedim > &) const
Definition: fe.cc:945
std::vector< Point< dim > > unit_support_points
Definition: fe.h:2144
const unsigned int first_face_line_index
Definition: fe_base.h:264
bool has_support_points() const
Definition: fe.cc:972
unsigned int component_to_block_index(const unsigned int component) const
Definition: fe.cc:348
const FullMatrix< double > & constraints(const ::internal::SubfaceCase< dim > &subface_case=::internal::SubfaceCase< dim >::case_isotropic) const
Definition: fe.cc:798
static unsigned int n_children(const RefinementCase< dim > &refinement_case)
virtual Tensor< 1, dim > shape_grad_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
Definition: fe.cc:198
const unsigned int first_quad_index
Definition: fe_base.h:254
virtual std::size_t memory_consumption() const
Definition: fe.cc:1173
size_type n() const
virtual ~FiniteElement()
Definition: fe.cc:156
No update.
std::vector< std::vector< FullMatrix< double > > > prolongation
Definition: fe.h:2120
#define Assert(cond, exc)
Definition: exceptions.h:294
UpdateFlags
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
Definition: fe.cc:306
Abstract base class for mapping classes.
Definition: dof_tools.h:52
std::vector< Point< dim-1 > > unit_face_support_points
Definition: fe.h:2151
void reinit(const unsigned int n_blocks, const size_type n_elements_per_block)
virtual void get_subface_interpolation_matrix(const FiniteElement< dim, spacedim > &source, const unsigned int subface, FullMatrix< double > &matrix) const
Definition: fe.cc:885
bool constraints_are_implemented(const ::internal::SubfaceCase< dim > &subface_case=::internal::SubfaceCase< dim >::case_isotropic) const
Definition: fe.cc:777
unsigned int size() const
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const
Definition: fe.cc:1236
bool has_generalized_face_support_points() const
Definition: fe.cc:1058
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const
Definition: fe.cc:902
virtual unsigned int face_to_cell_index(const unsigned int face_dof_index, const unsigned int face, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false) const
Definition: fe.cc:529
virtual InternalDataBase * get_face_data(const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const Quadrature< dim-1 > &quadrature, ::internal::FEValues::FiniteElementRelatedData< dim, spacedim > &output_data) const
Definition: fe.cc:1208
virtual Point< dim-1 > unit_face_support_point(const unsigned int index) const
Definition: fe.cc:1067
virtual ~InternalDataBase()
Definition: fe.cc:45
const unsigned int dofs_per_cell
Definition: fe_base.h:283
std::vector< Point< dim-1 > > generalized_face_support_points
Definition: fe.h:2163
types::global_dof_index first_block_of_base(const unsigned int b) const
Definition: fe.h:2852
unsigned int adjust_line_dof_index_for_line_orientation(const unsigned int index, const bool line_orientation) const
Definition: fe.cc:650
const std::vector< Point< dim > > & get_unit_support_points() const
Definition: fe.cc:956
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const
Definition: fe.cc:913
std::pair< unsigned int, unsigned int > system_to_component_index(const unsigned int index) const
Definition: fe.h:2742
virtual double shape_value(const unsigned int i, const Point< dim > &p) const
Definition: fe.cc:164
unsigned int n_components() const
const unsigned int first_face_quad_index
Definition: fe_base.h:269
std::vector< std::pair< unsigned int, unsigned int > > system_to_component_table
Definition: fe.h:2200
virtual bool hp_constraints_are_implemented() const
Definition: fe.cc:789
const unsigned int dofs_per_face
Definition: fe_base.h:276
bool prolongation_is_implemented() const
Definition: fe.cc:673
const unsigned int first_line_index
Definition: fe_base.h:249
virtual Tensor< 4, dim > shape_4th_derivative_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
Definition: fe.cc:267
virtual Tensor< 2, dim > shape_grad_grad(const unsigned int i, const Point< dim > &p) const
Definition: fe.cc:210
const std::vector< ComponentMask > nonzero_components
Definition: fe.h:2276
void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false)
Definition: fe.cc:278
const unsigned int dofs_per_vertex
Definition: fe_base.h:226
virtual InternalDataBase * get_subface_data(const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const Quadrature< dim-1 > &quadrature, ::internal::FEValues::FiniteElementRelatedData< dim, spacedim > &output_data) const
Definition: fe.cc:1222
std::vector< std::pair< unsigned int, unsigned int > > face_system_to_component_table
Definition: fe.h:2211
bool isotropic_restriction_is_implemented() const
Definition: fe.cc:751
BlockIndices base_to_block_indices
Definition: fe.h:2242
void set_primitivity(const bool value)
virtual Tensor< 4, dim > shape_4th_derivative(const unsigned int i, const Point< dim > &p) const
Definition: fe.cc:256
unsigned int size() const
Definition: block_mask.h:255
unsigned int size() const
unsigned int adjust_quad_dof_index_for_face_orientation(const unsigned int index, const bool face_orientation, const bool face_flip, const bool face_rotation) const
Definition: fe.cc:618
std::vector< int > adjust_line_dof_index_for_line_orientation_table
Definition: fe.h:2195
TableIndices< 2 > interface_constraints_size() const
Definition: fe.cc:824
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const
Definition: fe.cc:1091
void fill(InputIterator entries, const bool C_style_indexing=true)
const std::vector< bool > restriction_is_additive_flags
Definition: fe.h:2267
virtual FiniteElementDomination::Domination compare_for_face_domination(const FiniteElement< dim, spacedim > &fe_other) const
Definition: fe.cc:935
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const
Definition: fe.cc:1080
std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > system_to_base_table
Definition: fe.h:2230