17 #include <deal.II/fe/fe_q_hierarchical.h> 18 #include <deal.II/fe/fe_nothing.h> 28 DEAL_II_NAMESPACE_OPEN
36 std::vector<unsigned int>
37 invert_numbering (
const std::vector<unsigned int> &in)
39 std::vector<unsigned int> out (in.size());
40 for (
unsigned int i=0; i<in.size(); ++i)
42 Assert (in[i] < out.size(),
43 ::ExcIndexRange(in[i],0,out.size()));
56 Polynomials::Hierarchical::generate_complete_basis(degree),
60 get_dpo_vector(degree),1, degree).dofs_per_cell, false),
62 get_dpo_vector(degree),1, degree).dofs_per_cell,
std::vector<bool>(1,true))),
63 face_renumber(face_fe_q_hierarchical_to_hierarchic_numbering (degree))
82 std::vector<FullMatrix<double> >
86 std::vector<FullMatrix<double> >
119 std::ostringstream namebuf;
120 namebuf <<
"FE_Q_Hierarchical<" << dim <<
">(" << this->
degree <<
")";
122 return namebuf.str();
129 std::vector<double> &,
130 const std::vector<double> &)
const 135 Assert (
false, ExcNotImplemented());
142 std::vector<double> &,
146 Assert (
false, ExcNotImplemented());
153 std::vector<double> &,
154 const VectorSlice<
const std::vector<std::vector<double> > > &)
const 156 Assert (
false, ExcNotImplemented());
178 ExcDimensionMismatch (matrix.
m(),
181 ExcDimensionMismatch (matrix.
m(),
182 source_fe->dofs_per_cell));
195 const std::vector<unsigned int> dof_map = this->
get_embedding_dofs(source_fe->degree);
196 for (
unsigned int j=0; j < dof_map.size(); j++)
197 matrix[dof_map[j]][j] = 1.;
202 const std::vector<unsigned int> dof_map = source_fe->get_embedding_dofs(this->
degree);
203 for (
unsigned int j=0; j < dof_map.size(); j++)
204 matrix[j][dof_map[j]] = 1.;
220 ExcMessage(
"Prolongation matrices are only available for isotropic refinement!"));
239 std::vector<std::pair<unsigned int, unsigned int> >
254 std::vector<std::pair<unsigned int, unsigned int> >
255 (1, std::make_pair (0U, 0U));
263 return std::vector<std::pair<unsigned int, unsigned int> > ();
267 Assert (
false, ExcNotImplemented());
268 return std::vector<std::pair<unsigned int, unsigned int> > ();
273 std::vector<std::pair<unsigned int, unsigned int> >
290 std::vector<std::pair<unsigned int, unsigned int> > res;
291 for (
unsigned int i = 0; i < std::min(this_dpl,other_dpl); i++)
292 res.push_back(std::make_pair (i, i));
302 return std::vector<std::pair<unsigned int, unsigned int> > ();
306 Assert (
false, ExcNotImplemented());
307 return std::vector<std::pair<unsigned int, unsigned int> > ();
312 std::vector<std::pair<unsigned int, unsigned int> >
329 std::vector<std::pair<unsigned int, unsigned int> > res;
330 for (
unsigned int i = 0; i < std::min(this_dpq,other_dpq); i++)
331 res.push_back(std::make_pair (i, i));
341 return std::vector<std::pair<unsigned int, unsigned int> > ();
345 Assert (
false, ExcNotImplemented());
346 return std::vector<std::pair<unsigned int, unsigned int> > ();
360 if (this->degree < fe_q_other->
degree)
361 return FiniteElementDomination::this_element_dominates;
362 else if (this->degree == fe_q_other->degree)
363 return FiniteElementDomination::either_element_can_dominate;
365 return FiniteElementDomination::other_element_dominates;
369 if (fe_nothing->is_dominating())
371 return FiniteElementDomination::other_element_dominates;
377 return FiniteElementDomination::no_requirements;
381 Assert (
false, ExcNotImplemented());
382 return FiniteElementDomination::neither_element_dominates;
445 for (
unsigned int c=0; c<GeometryInfo<1>::max_children_per_cell; ++c)
446 for (
unsigned int j=0; j<dofs_1d; ++j)
447 for (
unsigned int k=0; k<dofs_1d; ++k)
450 if ((j<=1) && (k<=1))
452 if (((c==0) && (j==0) && (k==0)) ||
453 ((c==1) && (j==1) && (k==1)))
454 dofs_cell[c](j,k) = 1.;
456 dofs_cell[c](j,k) = 0.;
458 if (((c==0) && (j==1)) || ((c==1) && (j==0)))
459 dofs_subcell[c](j,k) = .5;
460 else if (((c==0) && (k==0)) || ((c==1) && (k==1)))
461 dofs_subcell[c](j,k) = 1.;
463 dofs_subcell[c](j,k) = 0.;
466 else if ((j<=1) && (k>=2))
468 if (((c==0) && (j==1) && ((k % 2)==0)) ||
469 ((c==1) && (j==0) && ((k % 2)==0)))
470 dofs_subcell[c](j,k) = -1.;
473 else if ((j>=2) && (k>=2) && (j<=k))
476 for (
unsigned int i=1; i<=j; ++i)
477 factor *= ((
double) (k-i+1))/((double) i);
481 dofs_subcell[c](j,k) = ((k+j) % 2 == 0) ?
482 std::pow(.5,static_cast<double>(k))*factor :
483 -std::pow(.5,static_cast<double>(k))*factor;
484 dofs_cell[c](j,k) = std::pow(2.,static_cast<double>(j))*factor;
488 dofs_subcell[c](j,k) = std::pow(.5,static_cast<double>(k))*factor;
489 dofs_cell[c](j,k) = ((k+j) % 2 == 0) ?
490 std::pow(2.,static_cast<double>(j))*factor :
491 -std::pow(2.,static_cast<double>(j))*factor;
521 for (
unsigned int i=0; i<dofs_1d; ++i)
524 for (
unsigned int c=0; c<GeometryInfo<1>::max_children_per_cell; ++c)
525 for (
unsigned int i=0; i<dofs_1d; ++i)
526 for (
unsigned int j=2; j<dofs_1d; ++j)
528 dofs_subcell[c](j,i);
534 for (
unsigned int i=0; i<dofs_1d * dofs_1d; i++)
538 dofs_subcell[0](1,i % dofs_1d) *
539 dofs_subcell[0](1,(i - (i % dofs_1d)) / dofs_1d);
543 dofs_subcell[0](0, i % dofs_1d) *
544 dofs_subcell[0](1, (i - (i % dofs_1d)) / dofs_1d);
546 dofs_subcell[1](1, i % dofs_1d) *
547 dofs_subcell[0](1, (i - (i % dofs_1d)) / dofs_1d);
549 dofs_subcell[0](1, i % dofs_1d) *
550 dofs_subcell[0](0, (i - (i % dofs_1d)) / dofs_1d);
552 dofs_subcell[1](0, i % dofs_1d) *
553 dofs_subcell[1](1, (i - (i % dofs_1d)) / dofs_1d);
556 for (
unsigned int j=0; j<(degree-1); j++)
559 dofs_subcell[0](1, i % dofs_1d) *
560 dofs_subcell[0](2 + j, (i - (i % dofs_1d)) / dofs_1d);
562 dofs_subcell[0](1,i % dofs_1d) *
563 dofs_subcell[1](2 + j, (i - (i % dofs_1d)) / dofs_1d);
565 dofs_subcell[0](2 + j,i % dofs_1d) *
566 dofs_subcell[1](0, (i - (i % dofs_1d)) / dofs_1d);
568 dofs_subcell[1](2 + j, i % dofs_1d) *
569 dofs_subcell[0](1, (i - (i % dofs_1d)) / dofs_1d);
573 for (
unsigned int j=0; j<(degree-1); j++)
577 dofs_subcell[0](0, i % dofs_1d) *
578 dofs_subcell[0](2 + j, (i - (i % dofs_1d)) / dofs_1d);
580 dofs_subcell[0](0, i % dofs_1d) *
581 dofs_subcell[1](2 + j, (i - (i % dofs_1d)) / dofs_1d);
584 dofs_subcell[1](1, i % dofs_1d) *
585 dofs_subcell[0](2 + j, (i - (i % dofs_1d)) / dofs_1d);
587 dofs_subcell[1](1, i % dofs_1d) *
588 dofs_subcell[1](2 + j, (i - (i % dofs_1d)) / dofs_1d);
591 dofs_subcell[0](2 + j, i % dofs_1d) *
592 dofs_subcell[0](0, (i - (i % dofs_1d)) / dofs_1d);
594 dofs_subcell[1](2 + j, i % dofs_1d) *
595 dofs_subcell[0](0, (i - (i % dofs_1d)) / dofs_1d);
598 dofs_subcell[0](2 + j, i % dofs_1d) *
599 dofs_subcell[1](1, (i - (i % dofs_1d)) / dofs_1d);
601 dofs_subcell[1](2 + j, i % dofs_1d) *
602 dofs_subcell[1](1, (i - (i % dofs_1d)) / dofs_1d);
606 for (
unsigned int j=0; j<(degree-1); j++)
607 for (
unsigned int k=0; k<(degree-1); k++)
611 dofs_subcell[0](2 + j, i % dofs_1d) *
612 dofs_subcell[0](2 + k, (i - (i % dofs_1d)) / dofs_1d);
615 dofs_subcell[1](2 + j, i % dofs_1d) *
616 dofs_subcell[0](2 + k, (i - (i % dofs_1d)) / dofs_1d);
619 dofs_subcell[0](2 + j, i % dofs_1d) *
620 dofs_subcell[1](2 + k, (i - (i % dofs_1d)) / dofs_1d);
623 dofs_subcell[1](2 + j, i % dofs_1d) *
624 dofs_subcell[1](2 + k, (i - (i % dofs_1d)) / dofs_1d);
631 Assert (
false, ExcNotImplemented());
646 const std::vector<unsigned int> &renumber=
649 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
659 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
683 for (
unsigned int c=0; c<GeometryInfo<2>::max_children_per_cell; ++c)
686 const unsigned int c0 = c%2;
688 const unsigned int c1 = c/2;
691 dofs_subcell[c0](renumber[j] % dofs_1d,
692 renumber[i] % dofs_1d) *
693 dofs_subcell[c1]((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d,
694 (renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d);
697 dofs_cell[c0](renumber[j] % dofs_1d,
698 renumber[i] % dofs_1d) *
699 dofs_cell[c1]((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d,
700 (renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d);
707 for (
unsigned int c=0; c<GeometryInfo<3>::max_children_per_cell; ++c)
710 const unsigned int c0 = c%2;
712 const unsigned int c1 = (c%4)/2;
714 const unsigned int c2 = c/4;
717 dofs_subcell[c0](renumber[j] % dofs_1d,
718 renumber[i] % dofs_1d) *
719 dofs_subcell[c1](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d) % dofs_1d,
720 ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d) % dofs_1d) *
721 dofs_subcell[c2](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d - (((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d,
722 ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d - (((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d);
725 dofs_cell[c0](renumber[j] % dofs_1d,
726 renumber[i] % dofs_1d) *
727 dofs_cell[c1](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d) % dofs_1d,
728 ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d) % dofs_1d) *
729 dofs_cell[c2](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d - (((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d,
730 ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d - (((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d);
736 Assert (
false, ExcNotImplemented());
746 unsigned int n = this->
degree+1;
747 for (
unsigned int i=1; i<dim; ++i)
752 const std::vector<unsigned int> &index_map_inverse=
784 for (
unsigned int iz=0; iz <= ((dim>2) ? this->
degree : 0) ; ++iz)
785 for (
unsigned int iy=0; iy <= ((dim>1) ? this->
degree : 0) ; ++iy)
786 for (
unsigned int ix=0; ix<=this->
degree; ++ix)
830 Assert (
false, ExcImpossibleInDim(1));
841 Assert (
false, ExcImpossibleInDim(1));
859 (dynamic_cast<const FEQHierarchical *>(&x_source_fe) != 0),
861 ExcInterpolationNotImplemented());
864 ExcDimensionMismatch (interpolation_matrix.
n(),
867 ExcDimensionMismatch (interpolation_matrix.
m(),
889 ExcInterpolationNotImplemented ());
890 interpolation_matrix = 0;
903 interpolation_matrix (i, i) = 1;
910 for (
unsigned int i = 0; i < GeometryInfo<3>::vertices_per_face; ++i)
911 interpolation_matrix (i, i) = 1;
913 for (
unsigned int i = 0; i < this->
degree - 1; ++i)
915 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face; ++j)
916 interpolation_matrix (
920 for (
unsigned int j = 0; j < this->degree - 1; ++j)
921 interpolation_matrix (
937 const unsigned int subface,
947 (dynamic_cast<const FEQHierarchical *>(&x_source_fe) != 0),
949 ExcInterpolationNotImplemented());
952 ExcDimensionMismatch (interpolation_matrix.
n(),
955 ExcDimensionMismatch (interpolation_matrix.
m(),
976 ExcInterpolationNotImplemented ());
986 interpolation_matrix (0, 0) = 1.0;
987 interpolation_matrix (1, 0) = 0.5;
988 interpolation_matrix (1, 1) = 0.5;
992 interpolation_matrix (1, dof) = -1.0;
1000 for (
int i = 2; i < (int) this->dofs_per_face; ++i)
1002 interpolation_matrix (i, i) = std::pow (0.5, i);
1004 factorial_j = factorial_i;
1007 for (
int j = i + 1; j < (int) this->dofs_per_face; ++j)
1009 factorial_ij *= j - i;
1013 interpolation_matrix (i, j)
1014 = -1.0 * std::pow (0.5, j) *
1015 factorial_j / (factorial_i * factorial_ij);
1018 interpolation_matrix (i, j)
1019 = std::pow (0.5, j) *
1020 factorial_j / (factorial_i * factorial_ij);
1029 interpolation_matrix (0, 0) = 0.5;
1030 interpolation_matrix (0, 1) = 0.5;
1034 interpolation_matrix (0, dof) = -1.0;
1038 interpolation_matrix (1, 1) = 1.0;
1040 int factorial_i = 1;
1044 for (
int i = 2; i < (int) this->dofs_per_face; ++i)
1046 interpolation_matrix (i, i) = std::pow (0.5, i);
1048 factorial_j = factorial_i;
1051 for (
int j = i + 1; j < (int) this->dofs_per_face; ++j)
1053 factorial_ij *= j - i;
1055 interpolation_matrix (i, j)
1056 = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij);
1071 interpolation_matrix (0, 0) = 1.0;
1072 interpolation_matrix (1, 0) = 0.5;
1073 interpolation_matrix (1, 1) = 0.5;
1074 interpolation_matrix (2, 0) = 0.5;
1075 interpolation_matrix (2, 2) = 0.5;
1077 for (
unsigned int i = 0; i < this->
degree - 1;)
1079 for (
unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line)
1080 interpolation_matrix (3, i + line * (this->degree - 1) + 4) = -0.5;
1082 for (
unsigned int j = 0; j < this->degree - 1;)
1084 interpolation_matrix (3, i + (j + 4) * this->degree - j) = 1.0;
1088 interpolation_matrix (1, i + 2 * (this->degree + 1)) = -1.0;
1089 interpolation_matrix (2, i + 4) = -1.0;
1093 for (
unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex)
1094 interpolation_matrix (3, vertex) = 0.25;
1096 int factorial_i = 1;
1103 for (
int i = 2; i <= (int) this->degree; ++i)
1105 double tmp = std::pow (0.5, i);
1106 interpolation_matrix (i + 2, i + 2) = tmp;
1107 interpolation_matrix (i + 2 * source_fe.
degree, i + 2 * this->degree) = tmp;
1109 interpolation_matrix (i + source_fe.
degree + 1, i + 2) = tmp;
1110 interpolation_matrix (i + source_fe.
degree + 1, i + this->degree + 1) = tmp;
1111 interpolation_matrix (i + 3 * source_fe.
degree - 1, i + 2 * this->degree) = tmp;
1112 interpolation_matrix (i + 3 * source_fe.
degree - 1, i + 3 * this->degree - 1) = tmp;
1115 for (
unsigned int j = 0; j < this->degree - 1;)
1117 interpolation_matrix (i + source_fe.
degree + 1, (i + 2) * this->degree + j + 2 - i) = tmp;
1118 interpolation_matrix (i + 3 * source_fe.
degree - 1, i + (j + 4) * this->degree - j - 2) = tmp;
1124 for (
int j = 2; j <= (int) this->degree; ++j)
1126 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j);
1129 factorial_l = factorial_k;
1131 for (
int k = j + 1; k < (int) this->degree; ++k)
1133 factorial_kl *= k - j;
1137 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (k + 2) * this->degree - k) = -1.0 * std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl);
1140 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl);
1145 factorial_j = factorial_i;
1148 for (
int j = i + 1; j <= (int) this->degree; ++j)
1150 factorial_ij *= j - i;
1155 tmp = -1.0 * std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij);
1156 interpolation_matrix (i + 2, j + 2) = tmp;
1157 interpolation_matrix (i + 2 * source_fe.
degree, j + 2 * this->degree) = tmp;
1160 for (
int k = 2; k <= (int) this->degree; ++k)
1162 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
1164 factorial_l = factorial_k;
1167 for (
int l = k + 1; l <= (int) this->degree; ++l)
1169 factorial_kl *= l - k;
1173 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (l + 2) * this->degree - l) = -1.0 * tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl);
1176 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl);
1181 interpolation_matrix (i + source_fe.
degree + 1, j + 2) = tmp;
1182 interpolation_matrix (i + source_fe.
degree + 1, j + this->degree + 1) = tmp;
1183 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + 2 * this->degree) = tmp;
1184 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + 3 * this->degree - 1) = tmp;
1187 for (
unsigned int k = 0; k < this->degree - 1;)
1189 interpolation_matrix (i + source_fe.
degree + 1, (j + 2) * this->degree + k + 2 - j) = tmp;
1190 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + (k + 4) * this->degree - k - 2) = tmp;
1196 tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij);
1197 interpolation_matrix (i + 2, j + 2) = tmp;
1198 interpolation_matrix (i + 2 * source_fe.
degree, j + 2 * this->degree) = tmp;
1201 for (
int k = 2; k <= (int) this->degree; ++k)
1203 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
1205 factorial_l = factorial_k;
1208 for (
int l = k + 1; l <= (int) this->degree; ++l)
1210 factorial_kl *= l - k;
1214 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (l + 2) * this->degree - l) = -1.0 * tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl);
1217 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl);
1222 interpolation_matrix (i + source_fe.
degree + 1, j + 2) = tmp;
1223 interpolation_matrix (i + source_fe.
degree + 1, j + this->degree + 1) = tmp;
1224 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + 2 * this->degree) = tmp;
1225 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + 3 * this->degree - 1) = tmp;
1228 for (
unsigned int k = 0; k < this->degree - 1;)
1230 interpolation_matrix (i + source_fe.
degree + 1, (j + 2) * this->degree + k + 2 - j) = tmp;
1231 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + (k + 4) * this->degree - k - 2) = tmp;
1243 interpolation_matrix (0, 0) = 0.5;
1244 interpolation_matrix (0, 1) = 0.5;
1245 interpolation_matrix (1, 1) = 1.0;
1246 interpolation_matrix (3, 1) = 0.5;
1247 interpolation_matrix (3, 3) = 0.5;
1249 for (
unsigned int i = 0; i < this->
degree - 1;)
1251 for (
unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line)
1252 interpolation_matrix (2, i + line * (this->degree - 1) + 4) = -0.5;
1254 for (
unsigned int j = 0; j < this->degree - 1;)
1256 interpolation_matrix (2, i + (j + 4) * this->degree - j) = 1.0;
1260 interpolation_matrix (0, i + 2 * (this->degree + 1)) = -1.0;
1261 interpolation_matrix (3, i + this->degree + 3) = -1.0;
1265 for (
unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex)
1266 interpolation_matrix (2, vertex) = 0.25;
1268 int factorial_i = 1;
1275 for (
int i = 2; i <= (int) this->degree; ++i)
1277 double tmp = std::pow (0.5, i + 1);
1278 interpolation_matrix (i + 2, i + 2) = tmp;
1279 interpolation_matrix (i + 2, i + this->degree + 1) = tmp;
1280 interpolation_matrix (i + 3 * source_fe.
degree - 1, i + 2 * this->degree) = tmp;
1281 interpolation_matrix (i + 3 * source_fe.
degree - 1, i + 3 * this->degree - 1) = tmp;
1284 for (
unsigned int j = 0; j < this->degree - 1;)
1286 interpolation_matrix (i + 2, j + (i + 2) * this->degree + 2 - i) = tmp;
1287 interpolation_matrix (i + 3 * source_fe.
degree - 1, i + (j + 4) * this->degree - j - 2) = tmp;
1292 interpolation_matrix (i + source_fe.
degree + 1, i + this->degree + 1) = tmp;
1293 interpolation_matrix (i + 2 * source_fe.
degree, i + 2 * this->degree) = tmp;
1295 factorial_j = factorial_i;
1298 for (
int j = i + 1; j <= (int) this->degree; ++j)
1300 factorial_ij *= j - i;
1302 tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij);
1303 interpolation_matrix (i + 2 * source_fe.
degree, j + 2 * this->degree) = tmp;
1306 for (
int k = 2; k <= (int) this->degree; ++k)
1308 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
1310 factorial_l = factorial_k;
1313 for (
int l = k + 1; l <= (int) this->degree; ++l)
1315 factorial_kl *= l - k;
1319 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (l + 2) * this->degree - l) = -1.0 * tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl);
1322 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl);
1328 for (
unsigned int k = 0; k < this->degree - 1;)
1330 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + (k + 4) * this->degree - k - 2) = tmp;
1335 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + 2 * this->degree) = tmp;
1336 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + 3 * this->degree - 1) = tmp;
1341 interpolation_matrix (i + 2, j + 2) = tmp;
1342 interpolation_matrix (i + 2, j + this->degree + 1) = tmp;
1343 interpolation_matrix (i + source_fe.
degree + 1, j + this->degree + 1) = 2.0 * tmp;
1346 for (
unsigned int k = 0; k < this->degree - 1;)
1348 interpolation_matrix (i + 2, k + (j + 2) * this->degree + 2 - j) = tmp;
1355 for (
int j = 2; j <= (int) this->degree; ++j)
1357 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j);
1359 factorial_l = factorial_k;
1362 for (
int k = j + 1; k <= (int) this->degree; ++k)
1364 factorial_kl *= k - j;
1368 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (k + 2) * this->degree - k) = -1.0 * std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl);
1371 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl);
1381 interpolation_matrix (0, 0) = 0.5;
1382 interpolation_matrix (0, 2) = 0.5;
1383 interpolation_matrix (2, 2) = 1.0;
1384 interpolation_matrix (3, 2) = 0.5;
1385 interpolation_matrix (3, 3) = 0.5;
1387 for (
unsigned int i = 0; i < this->
degree - 1;)
1389 for (
unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line)
1390 interpolation_matrix (1, i + line * (this->degree - 1) + 4) = -0.5;
1392 for (
unsigned int j = 0; j < this->degree - 1;)
1394 interpolation_matrix (1, i + (j + 4) * this->degree - j) = 1.0;
1398 interpolation_matrix (0, i + 4) = -1.0;
1399 interpolation_matrix (3, i + 3 * this->degree + 1) = -1.0;
1403 for (
unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex)
1404 interpolation_matrix (1, vertex) = 0.25;
1406 int factorial_i = 1;
1413 for (
int i = 2; i <= (int) this->degree; ++i)
1415 double tmp = std::pow (0.5, i);
1416 interpolation_matrix (i + 2, i + 2) = tmp;
1417 interpolation_matrix (i + 3 * source_fe.
degree - 1, i + 3 * this->degree - 1) = tmp;
1419 interpolation_matrix (i + source_fe.
degree + 1, i + 2) = tmp;
1420 interpolation_matrix (i + source_fe.
degree + 1, i + this->degree + 1) = tmp;
1421 interpolation_matrix (i + 2 * source_fe.
degree, i + 2 * this->degree) = tmp;
1422 interpolation_matrix (i + 2 * source_fe.
degree, i + 3 * this->degree - 1) = tmp;
1425 for (
unsigned int j = 0; j < this->degree - 1;)
1427 interpolation_matrix (i + source_fe.
degree + 1, j + (i + 2) * this->degree + 2 - i) = tmp;
1428 interpolation_matrix (i + 2 * source_fe.
degree, i + (j + 4) * this->degree - j - 2) = tmp;
1434 for (
int j = 2; j <= (int) this->degree; ++j)
1436 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j);
1438 factorial_l = factorial_k;
1441 for (
int k = j + 1; k <= (int) this->degree; ++k)
1443 factorial_kl *= k - j;
1445 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl);
1450 factorial_j = factorial_i;
1453 for (
int j = i + 1; j <= (int) this->degree; ++j)
1455 factorial_ij *= j - i;
1457 tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij);
1458 interpolation_matrix (i + 2, j + 2) = tmp;
1461 for (
unsigned int k = 0; k < this->degree - 1;)
1463 interpolation_matrix (i + source_fe.
degree + 1, k + (j + 2) * this->degree + 2 - j) = tmp;
1468 interpolation_matrix (i + source_fe.
degree + 1, j + 2) = tmp;
1469 interpolation_matrix (i + source_fe.
degree + 1, j + this->degree + 1) = tmp;
1474 interpolation_matrix (i + 2 * source_fe.
degree, j + 2 * this->degree) = tmp;
1475 interpolation_matrix (i + 2 * source_fe.
degree, j + 3 * this->degree - 1) = tmp;
1477 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + 3 * this->degree - 1) = tmp;
1480 for (
int k = 2; k <= (int) this->degree; ++k)
1482 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
1484 factorial_l = factorial_k;
1487 for (
int l = k + 1; l <= (int) this->degree; ++l)
1489 factorial_kl *= l - k;
1491 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl);
1497 for (
unsigned int k = 0; k < this->degree - 1;)
1499 interpolation_matrix (i + 2 * source_fe.
degree, j + (k + 4) * this->degree - k - 2) = tmp;
1510 for (
unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex)
1511 interpolation_matrix (0, vertex) = 0.25;
1513 for (
unsigned int i = 0; i < this->
degree - 1;)
1515 for (
unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line)
1516 interpolation_matrix (0, i + line * (this->degree - 1) + 4) = -0.5;
1518 for (
unsigned int j = 0; j < this->degree - 1;)
1520 interpolation_matrix (0, i + (j + 4) * this->degree - j) = 1.0;
1524 interpolation_matrix (1, i + 4) = -1.0;
1525 interpolation_matrix (2, i + 3 * this->degree + 1) = -1.0;
1529 interpolation_matrix (1, 0) = 0.5;
1530 interpolation_matrix (1, 1) = 0.5;
1531 interpolation_matrix (2, 2) = 0.5;
1532 interpolation_matrix (2, 3) = 0.5;
1533 interpolation_matrix (3, 3) = 1.0;
1535 int factorial_i = 1;
1542 for (
int i = 2; i <= (int) this->degree; ++i)
1544 double tmp = std::pow (0.5, i + 1);
1545 interpolation_matrix (i + 2, i + 2) = tmp;
1546 interpolation_matrix (i + 2, i + this->degree + 1) = tmp;
1547 interpolation_matrix (i + 2 * source_fe.
degree, i + 2 * this->degree) = tmp;
1548 interpolation_matrix (i + 2 * source_fe.
degree, i + 3 * this->degree - 1) = tmp;
1551 for (
unsigned int j = 0; j < this->degree - 1;)
1553 interpolation_matrix (i + 2, j + (i + 2) * this->degree + 2 - i) = tmp;
1554 interpolation_matrix (i + 2 * source_fe.
degree, i + (j + 4) * this->degree - 2) = tmp;
1559 interpolation_matrix (i + source_fe.
degree + 1, i + this->degree + 1) = tmp;
1560 interpolation_matrix (i + 3 * source_fe.
degree - 1, i + 3 * this->degree - 1) = tmp;
1563 for (
int j = 2; j <= (int) this->degree; ++j)
1565 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j);
1567 factorial_l = factorial_k;
1570 for (
int k = j + 1; k <= (int) this->degree; ++k)
1572 factorial_kl *= k - j;
1574 interpolation_matrix (i + (j + 2) * source_fe.
degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl);
1579 factorial_j = factorial_i;
1582 for (
int j = i + 1; j <= (int) this->degree; ++j)
1584 factorial_ij *= j - i;
1586 tmp = std::pow (0.5, j + 1) * factorial_j / (factorial_i * factorial_ij);
1587 interpolation_matrix (i + 2, j + 2) = tmp;
1588 interpolation_matrix (i + 2, j + this->degree + 1) = tmp;
1589 interpolation_matrix (i + 2 * source_fe.
degree, j + 2 * this->degree) = tmp;
1590 interpolation_matrix (i + 2 * source_fe.
degree, j + 3 * this->degree - 1) = tmp;
1592 interpolation_matrix (i + source_fe.
degree + 1, j + this->degree + 1) = tmp;
1593 interpolation_matrix (i + 3 * source_fe.
degree - 1, j + 3 * this->degree - 1) = tmp;
1596 for (
int k = 2; k <= (int) this->degree; ++k)
1598 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
1600 factorial_l = factorial_k;
1603 for (
int l = k + 1; l <= (int) this->degree; ++l)
1605 factorial_kl *= l - k;
1607 interpolation_matrix (i + (k + 2) * source_fe.
degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl);
1613 for (
unsigned int k = 0; k < this->degree - 1;)
1615 interpolation_matrix (i + 2, k + (j + 2) * this->degree + 2 - j) = tmp;
1616 interpolation_matrix (i + 2 * source_fe.
degree, j + (k + 4) * this->degree - 2) = tmp;
1632 const unsigned int codim = dim-1;
1635 unsigned int n = this->
degree+1;
1636 for (
unsigned int i=1; i<codim; ++i)
1644 for (
unsigned int iz=0; iz <= ((codim>2) ? this->
degree : 0) ; ++iz)
1645 for (
unsigned int iy=0; iy <= ((codim>1) ? this->
degree : 0) ; ++iy)
1646 for (
unsigned int ix=0; ix<=this->
degree; ++ix)
1679 std::vector<unsigned int>
1682 std::vector<unsigned int> dpo(dim+1, 1U);
1683 for (
unsigned int i=1; i<dpo.size(); ++i)
1684 dpo[i]=dpo[i-1]*(deg-1);
1691 std::vector<unsigned int>
1702 const unsigned int n = degree+1;
1741 unsigned int next_index = 0;
1743 h2l[next_index++] = 0;
1744 h2l[next_index++] = 1;
1745 h2l[next_index++] = n;
1746 h2l[next_index++] = n+1;
1749 h2l[next_index++] = (2+i)*n;
1752 h2l[next_index++] = (2+i)*n+1;
1755 h2l[next_index++] = 2+i;
1758 h2l[next_index++] = n+2+i;
1761 ExcInternalError());
1764 h2l[next_index++] = (2+i)*n+2+j;
1773 unsigned int next_index = 0;
1774 const unsigned int n2=n*n;
1777 h2l[next_index++] = 0;
1778 h2l[next_index++] = 1;
1779 h2l[next_index++] = n;
1780 h2l[next_index++] = n+1;
1782 h2l[next_index++] = n2;
1783 h2l[next_index++] = n2+1;
1784 h2l[next_index++] = n2+n;
1785 h2l[next_index++] = n2+n+1;
1790 h2l[next_index++] = (2+i)*n;
1792 h2l[next_index++] = (2+i)*n+1;
1794 h2l[next_index++] = 2+i;
1796 h2l[next_index++] = n+2+i;
1799 h2l[next_index++] = n2+(2+i)*n;
1801 h2l[next_index++] = n2+(2+i)*n+1;
1803 h2l[next_index++] = n2+2+i;
1805 h2l[next_index++] = n2+n+2+i;
1808 h2l[next_index++] = (2+i)*n2;
1810 h2l[next_index++] = (2+i)*n2+1;
1812 h2l[next_index++] = (2+i)*n2+n;
1814 h2l[next_index++] = (2+i)*n2+n+1;
1818 ExcInternalError());
1822 h2l[next_index++] = (2+i)*n2+(2+j)*n;
1826 h2l[next_index++] = (2+i)*n2+(2+j)*n+1;
1830 h2l[next_index++] = (2+i)*n2+2+j;
1834 h2l[next_index++] = (2+i)*n2+n+2+j;
1838 h2l[next_index++] = (2+i)*n+2+j;
1842 h2l[next_index++] = n2+(2+i)*n+2+j;
1846 ExcInternalError());
1850 h2l[next_index++] = (2+i)*n2+(2+j)*n+2+k;
1858 Assert (
false, ExcNotImplemented());
1865 std::vector<unsigned int>
1877 std::vector<unsigned int>
1880 return std::vector<unsigned int> ();
1887 const unsigned int face_index)
const 1890 ExcIndexRange (shape_index, 0, this->dofs_per_cell));
1901 return (((shape_index == 0) && (face_index == 0)) ||
1902 ((shape_index == 1) && (face_index == 1)));
1911 const unsigned int face_index)
const 1914 ExcIndexRange (shape_index, 0, this->dofs_per_cell));
1936 const unsigned int vertex_no = shape_index;
1938 ExcInternalError());
1939 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_face; ++i)
1947 const unsigned int line_index
1950 ExcInternalError());
1952 for (
unsigned int i=0; i<GeometryInfo<dim>::lines_per_face; ++i)
1960 const unsigned int quad_index
1962 Assert (static_cast<signed int>(quad_index) <
1964 ExcInternalError());
1970 Assert (dim != 2, ExcInternalError());
1975 return (quad_index == face_index);
1977 Assert (
false, ExcNotImplemented());
1985 Assert (
false, ExcNotImplemented());
1990 Assert (
false, ExcInternalError());
1997 std::vector<unsigned int>
2001 ExcIndexRange(sub_degree, 1, this->degree));
2005 std::vector<unsigned int> embedding_dofs (sub_degree+1);
2006 for (
unsigned int i=0; i<(sub_degree+1); ++i)
2007 embedding_dofs[i] = i;
2009 return embedding_dofs;
2015 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
2016 embedding_dofs[i] = i;
2018 return embedding_dofs;
2020 else if (sub_degree==this->degree)
2022 std::vector<unsigned int> embedding_dofs (this->
dofs_per_cell);
2024 embedding_dofs[i] = i;
2026 return embedding_dofs;
2029 if ((dim==2) || (dim==3))
2031 std::vector<unsigned int> embedding_dofs ( (dim==2) ?
2032 (sub_degree+1) * (sub_degree+1) :
2033 (sub_degree+1) * (sub_degree+1) * (sub_degree+1) );
2035 for (
unsigned int i=0; i<( (dim==2) ?
2036 (sub_degree+1) * (sub_degree+1) :
2037 (sub_degree+1) * (sub_degree+1) * (sub_degree+1) ); ++i)
2041 embedding_dofs[i] = i;
2051 line * (this->degree-1) + j;
2067 face * (this->degree-1) * (this->degree-1) +
2068 k * (this->degree-1) + j;
2089 l * (this->degree-1) * (this->degree-1) + k * (this->degree-1) + j;
2093 return embedding_dofs;
2097 Assert(
false, ExcNotImplemented ());
2098 return std::vector<unsigned int> ();
2105 std::pair<Table<2,bool>, std::vector<unsigned int> >
2109 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
2110 constant_modes(0,i) =
true;
2112 constant_modes(0,i) =
false;
2113 return std::pair<Table<2,bool>, std::vector<unsigned int> >
2114 (constant_modes, std::vector<unsigned int>(1, 0));
2123 Assert (
false, ExcNotImplemented ());
2130 #include "fe_q_hierarchical.inst" 2133 DEAL_II_NAMESPACE_CLOSE
const unsigned int first_hex_index
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim > &fe_other) const
std::vector< std::vector< FullMatrix< double > > > restriction
FullMatrix< double > interface_constraints
virtual bool hp_constraints_are_implemented() const
::ExceptionBase & ExcMessage(std::string arg1)
const unsigned int dofs_per_quad
void initialize_embedding_and_restriction(const std::vector< FullMatrix< double > > &dofs_cell, const std::vector< FullMatrix< double > > &dofs_subcell)
const unsigned int degree
void initialize_unit_support_points()
void set_numbering(const std::vector< unsigned int > &renumber)
virtual FiniteElement< dim > * clone() const
const std::vector< unsigned int > face_renumber
#define AssertThrow(cond, exc)
virtual void get_interpolation_matrix(const FiniteElement< dim > &source, FullMatrix< double > &matrix) const
const unsigned int dofs_per_line
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
std::vector< unsigned int > get_embedding_dofs(const unsigned int sub_degree) const
virtual std::string get_name() const
std::vector< Point< dim > > unit_support_points
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const
const unsigned int first_quad_index
static std::vector< unsigned int > face_fe_q_hierarchical_to_hierarchic_numbering(const unsigned int degree)
std::vector< std::vector< FullMatrix< double > > > prolongation
const unsigned int dofs_per_hex
#define Assert(cond, exc)
std::vector< Point< dim-1 > > unit_face_support_points
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const
virtual std::string get_name() const =0
void initialize_constraints(const std::vector< FullMatrix< double > > &dofs_subcell)
virtual void get_subface_interpolation_matrix(const FiniteElement< dim > &source, const unsigned int subface, FullMatrix< double > &matrix) const
const std::vector< unsigned int > & get_numbering() const
const unsigned int dofs_per_cell
friend class FE_Q_Hierarchical
static std::vector< unsigned int > hierarchic_to_fe_q_hierarchical_numbering(const FiniteElementData< dim > &fe)
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim > &fe_other) const
virtual void interpolate(std::vector< double > &local_dofs, const std::vector< double > &values) const
unsigned int n_components() const
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_quad_dof_identities(const FiniteElement< dim > &fe_other) const
const unsigned int dofs_per_face
const std::vector< unsigned int > & get_numbering_inverse() const
const unsigned int first_line_index
void initialize_unit_face_support_points()
virtual void get_face_interpolation_matrix(const FiniteElement< dim > &source, FullMatrix< double > &matrix) const
const unsigned int dofs_per_vertex
virtual std::size_t memory_consumption() const
static std::vector< unsigned int > get_dpo_vector(const unsigned int degree)
virtual FiniteElementDomination::Domination compare_for_face_domination(const FiniteElement< dim > &fe_other) const
TensorProductPolynomials< dim > poly_space
TableIndices< 2 > interface_constraints_size() const
void build_dofs_cell(std::vector< FullMatrix< double > > &dofs_cell, std::vector< FullMatrix< double > > &dofs_subcell) const