16 #include <deal.II/base/geometry_info.h> 17 #include <deal.II/base/quadrature.h> 18 #include <deal.II/base/qprojector.h> 19 #include <deal.II/base/memory_consumption.h> 20 #include <deal.II/base/utilities.h> 21 #include <deal.II/base/std_cxx14/memory.h> 27 DEAL_II_NAMESPACE_OPEN
33 quadrature_points (n_q),
35 is_tensor_product_flag (false)
43 quadrature_points (n_q,
Point<dim>()),
45 is_tensor_product_flag (dim==1)
53 const std::vector<double> &w)
56 quadrature_points = p;
64 const std::vector<double> &weights)
66 quadrature_points(points),
68 is_tensor_product_flag (dim==1)
79 quadrature_points(points),
80 weights(points.size(),
std::numeric_limits<double>::infinity()),
81 is_tensor_product_flag (dim==1)
92 quadrature_points(
std::vector<
Point<dim> > (1, point)),
93 weights(
std::vector<double> (1, 1.)),
94 is_tensor_product_flag (true),
97 for (
unsigned int i=0; i<dim; ++i)
99 const std::vector<Point<1> > quad_vec_1d (1,
Point<1>(
point[i]));
109 quadrature_points(
std::vector<
Point<1> > (1, point)),
110 weights(
std::vector<double> (1, 1.)),
111 is_tensor_product_flag (true)
130 quadrature_points (q1.size() * q2.size()),
131 weights (q1.size() * q2.size()),
132 is_tensor_product_flag (q1.is_tensor_product())
134 unsigned int present_index = 0;
135 for (
unsigned int i2=0; i2<q2.
size(); ++i2)
136 for (
unsigned int i1=0; i1<q1.
size(); ++i1)
141 for (
unsigned int d=0; d<dim-1; ++d)
156 for (
unsigned int i=0; i<
size(); ++i)
167 tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, dim>> ();
168 for (
unsigned int i=0; i<dim-1; ++i)
170 (*tensor_basis)[dim-1] = q2;
180 quadrature_points (q2.size()),
182 is_tensor_product_flag (true)
184 unsigned int present_index = 0;
185 for (
unsigned int i2=0; i2<q2.
size(); ++i2)
202 for (
unsigned int i=0; i<
size(); ++i)
220 is_tensor_product_flag (false)
241 quadrature_points (
Utilities::fixed_power<dim>(q.size())),
242 weights (
Utilities::fixed_power<dim>(q.size())),
243 is_tensor_product_flag(true)
247 const unsigned int n0 = q.
size();
248 const unsigned int n1 = (dim>1) ? n0 : 1;
249 const unsigned int n2 = (dim>2) ? n0 : 1;
252 for (
unsigned int i2=0; i2<n2; ++i2)
253 for (
unsigned int i1=0; i1<n1; ++i1)
254 for (
unsigned int i0=0; i0<n0; ++i0)
269 tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, dim>> ();
270 for (
unsigned int i=0; i<dim; ++i)
280 quadrature_points (q.quadrature_points),
282 is_tensor_product_flag (q.is_tensor_product_flag)
297 if (dim >1 && is_tensor_product_flag)
299 if (tensor_basis ==
nullptr)
300 tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, dim>> (*q.
tensor_basis);
331 typename std::conditional<dim==1, std::array<Quadrature<1>, dim>,
const std::array<Quadrature<1>,dim>&>::type
334 Assert (this->is_tensor_product_flag ==
true,
335 ExcMessage(
"This function only makes sense if " 336 "this object represents a tensor product!"));
339 return *tensor_basis;
345 std::array<Quadrature<1>, 1>
349 ExcMessage(
"This function only makes sense if " 350 "this object represents a tensor product!"));
352 return std::array<Quadrature<1>, 1> {{*
this}};
364 for (
unsigned int k1=0; k1<qx.
size(); ++k1)
391 for (
unsigned int k2=0; k2<qy.
size(); ++k2)
392 for (
unsigned int k1=0; k1<qx.
size(); ++k1)
400 const std::array<Quadrature<1>, 2> q_array {{qx, qy}};
401 this->
tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, 2>>(q_array);
410 :
Quadrature<dim>(qx.size()*qy.size()*qz.size())
421 :
Quadrature<3>(qx.size()*qy.size()*qz.size())
424 for (
unsigned int k3=0; k3<qz.
size(); ++k3)
425 for (
unsigned int k2=0; k2<qy.
size(); ++k2)
426 for (
unsigned int k1=0; k1<qx.
size(); ++k1)
435 const std::array<Quadrature<1>, 3> q_array {{qx, qy, qz}};
436 this->
tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, 3>>(q_array);
449 std::vector<Point<2> > q_points (q.
size());
450 std::vector<double> weights (q.
size());
451 for (
unsigned int i=0; i<q.
size(); ++i)
453 q_points[i][0] = q.
point(i)[1];
454 q_points[i][1] = q.
point(i)[0];
466 const unsigned int n_times)
468 std::vector<Point<2> > q_points (q.
size());
469 std::vector<double> weights (q.
size());
470 for (
unsigned int i=0; i<q.
size(); ++i)
476 q_points[i][0] = q.
point(i)[0];
477 q_points[i][1] = q.
point(i)[1];
481 q_points[i][0] = 1.0 - q.
point(i)[1];
482 q_points[i][1] = q.
point(i)[0];
486 q_points[i][0] = 1.0 - q.
point(i)[0];
487 q_points[i][1] = 1.0 - q.
point(i)[1];
491 q_points[i][0] = q.
point(i)[1];
492 q_points[i][1] = 1.0 - q.
point(i)[0];
506 const unsigned int face_no,
509 const unsigned int dim=1;
521 const unsigned int face_no,
524 const unsigned int dim=2;
529 for (
unsigned int p=0; p<quadrature.
size(); ++p)
554 const unsigned int face_no,
557 const unsigned int dim=3;
562 for (
unsigned int p=0; p<quadrature.
size(); ++p)
567 quadrature.
point(p)(0),
568 quadrature.
point(p)(1));
572 quadrature.
point(p)(0),
573 quadrature.
point(p)(1));
578 quadrature.
point(p)(0));
583 quadrature.
point(p)(0));
587 quadrature.
point(p)(1),
592 quadrature.
point(p)(1),
606 const unsigned int face_no,
611 const unsigned int dim=1;
623 const unsigned int face_no,
624 const unsigned int subface_no,
628 const unsigned int dim=2;
635 for (
unsigned int p=0; p<quadrature.
size(); ++p)
703 const unsigned int face_no,
704 const unsigned int subface_no,
708 const unsigned int dim=3;
717 double const_value=face_no%2;
726 const_index = face_no/2;
755 switch ((
unsigned char)ref_case)
759 xi_translation = subface_no%2 * 0.5;
763 eta_translation = subface_no%2 * 0.5;
768 xi_translation = int(subface_no%2) * 0.5;
769 eta_translation = int(subface_no/2) * 0.5;
777 for (
unsigned int p=0; p<quadrature.
size(); ++p)
779 q_points[p][xi_index] = xi_scale * quadrature.
point(p)(0) + xi_translation;
780 q_points[p][eta_index] = eta_scale * quadrature.
point(p)(1) + eta_translation;
781 q_points[p][const_index] = const_value;
790 const unsigned int dim = 1;
792 const unsigned int n_points = 1,
796 std::vector<Point<dim> > q_points;
797 q_points.reserve(n_points * n_faces);
798 std::vector <Point<dim> > help(n_points);
803 for (
unsigned int face=0; face<n_faces; ++face)
805 project_to_face(quadrature, face, help);
806 std::copy (help.begin(), help.end(),
807 std::back_inserter (q_points));
811 std::vector<double> weights;
812 weights.reserve (n_points * n_faces);
813 for (
unsigned int face=0; face<n_faces; ++face)
816 std::back_inserter (weights));
818 Assert (q_points.size() == n_points * n_faces,
820 Assert (weights.size() == n_points * n_faces,
832 const unsigned int dim = 2;
834 const unsigned int n_points = quadrature.size(),
838 std::vector<Point<dim> > q_points;
839 q_points.reserve(n_points * n_faces);
840 std::vector <Point<dim> > help(n_points);
844 for (
unsigned int face=0; face<n_faces; ++face)
846 project_to_face(quadrature, face, help);
847 std::copy (help.begin(), help.end(),
848 std::back_inserter (q_points));
852 std::vector<double> weights;
853 weights.reserve (n_points * n_faces);
854 for (
unsigned int face=0; face<n_faces; ++face)
855 std::copy (quadrature.get_weights().begin(),
856 quadrature.get_weights().end(),
857 std::back_inserter (weights));
859 Assert (q_points.size() == n_points * n_faces,
861 Assert (weights.size() == n_points * n_faces,
873 const unsigned int dim = 3;
875 SubQuadrature q_reflected=reflect (quadrature);
890 const unsigned int n_points = quadrature.size(),
894 std::vector<Point<dim> > q_points;
895 q_points.reserve(n_points * n_faces * 8);
896 std::vector <Point<dim> > help(n_points);
898 std::vector<double> weights;
899 weights.reserve (n_points * n_faces * 8);
905 for (
unsigned int mutation=0; mutation<8; ++mutation)
909 for (
unsigned int face=0; face<n_faces; ++face)
911 project_to_face(q[mutation], face, help);
912 std::copy (help.begin(), help.end(),
913 std::back_inserter (q_points));
917 for (
unsigned int face=0; face<n_faces; ++face)
918 std::copy (q[mutation].get_weights().begin(),
919 q[mutation].get_weights().end(),
920 std::back_inserter (weights));
924 Assert (q_points.size() == n_points * n_faces * 8,
926 Assert (weights.size() == n_points * n_faces * 8,
938 const unsigned int dim = 1;
940 const unsigned int n_points = 1,
945 std::vector<Point<dim> > q_points;
946 q_points.reserve (n_points * n_faces * subfaces_per_face);
947 std::vector <Point<dim> > help(n_points);
951 for (
unsigned int face=0; face<n_faces; ++face)
952 for (
unsigned int subface=0; subface<subfaces_per_face; ++subface)
954 project_to_subface(quadrature, face, subface, help);
955 std::copy (help.begin(), help.end(),
956 std::back_inserter (q_points));
960 std::vector<double> weights;
961 weights.reserve (n_points * n_faces * subfaces_per_face);
962 for (
unsigned int face=0; face<n_faces; ++face)
963 for (
unsigned int subface=0; subface<subfaces_per_face; ++subface)
966 std::back_inserter (weights));
968 Assert (q_points.size() == n_points * n_faces * subfaces_per_face,
970 Assert (weights.size() == n_points * n_faces * subfaces_per_face,
982 const unsigned int dim = 2;
984 const unsigned int n_points = quadrature.size(),
989 std::vector<Point<dim> > q_points;
990 q_points.reserve (n_points * n_faces * subfaces_per_face);
991 std::vector <Point<dim> > help(n_points);
995 for (
unsigned int face=0; face<n_faces; ++face)
996 for (
unsigned int subface=0; subface<subfaces_per_face; ++subface)
998 project_to_subface(quadrature, face, subface, help);
999 std::copy (help.begin(), help.end(),
1000 std::back_inserter (q_points));
1004 std::vector<double> weights;
1005 weights.reserve (n_points * n_faces * subfaces_per_face);
1006 for (
unsigned int face=0; face<n_faces; ++face)
1007 for (
unsigned int subface=0; subface<subfaces_per_face; ++subface)
1008 std::copy (quadrature.get_weights().begin(),
1009 quadrature.get_weights().end(),
1010 std::back_inserter (weights));
1012 Assert (q_points.size() == n_points * n_faces * subfaces_per_face,
1014 Assert (weights.size() == n_points * n_faces * subfaces_per_face,
1026 const unsigned int dim = 3;
1027 SubQuadrature q_reflected=reflect (quadrature);
1040 const unsigned int n_points = quadrature.size(),
1042 total_subfaces_per_face = 2 + 2 + 4;
1045 std::vector<Point<dim> > q_points;
1046 q_points.reserve (n_points * n_faces * total_subfaces_per_face * 8);
1047 std::vector <Point<dim> > help(n_points);
1049 std::vector<double> weights;
1050 weights.reserve (n_points * n_faces * total_subfaces_per_face * 8);
1056 for (
unsigned int mutation=0; mutation<8; ++mutation)
1060 for (
unsigned int face=0; face<n_faces; ++face)
1064 for (
unsigned int subface=0; subface<GeometryInfo<dim-1>::n_children(
RefinementCase<dim-1>(ref_case)); ++subface)
1066 project_to_subface(q[mutation], face, subface, help,
1068 std::copy (help.begin(), help.end(),
1069 std::back_inserter (q_points));
1073 for (
unsigned int face=0; face<n_faces; ++face)
1077 for (
unsigned int subface=0; subface<GeometryInfo<dim-1>::n_children(
RefinementCase<dim-1>(ref_case)); ++subface)
1078 std::copy (q[mutation].get_weights().begin(),
1079 q[mutation].get_weights().end(),
1080 std::back_inserter (weights));
1083 Assert (q_points.size() == n_points * n_faces * total_subfaces_per_face * 8,
1085 Assert (weights.size() == n_points * n_faces * total_subfaces_per_face * 8,
1097 const unsigned int child_no)
1102 const unsigned int n_q_points = quadrature.
size();
1104 std::vector<Point<dim> > q_points(n_q_points);
1105 for (
unsigned int i=0; i<n_q_points; ++i)
1107 quadrature.
point(i), child_no);
1112 std::vector<double> weights = quadrature.
get_weights ();
1113 for (
unsigned int i=0; i<n_q_points; ++i)
1124 const unsigned int n_points = quadrature.
size(),
1127 std::vector<Point<dim> > q_points(n_points * n_children);
1128 std::vector<double> weights(n_points * n_children);
1132 for (
unsigned int child=0; child<n_children; ++child)
1135 for (
unsigned int i=0; i<n_points; ++i)
1137 q_points[child*n_points+i] = help.
point(i);
1138 weights[child*n_points+i] = help.
weight(i);
1154 const unsigned int n = quadrature.
size();
1155 std::vector<Point<dim> > points(n);
1156 std::vector<double> weights(n);
1157 const double length = p1.
distance(p2);
1159 for (
unsigned int k=0; k<n; ++k)
1161 const double alpha = quadrature.
point(k)(0);
1162 points[k] = alpha * p2;
1163 points[k] += (1.-alpha) * p1;
1164 weights[k] = length * quadrature.
weight(k);
1175 const bool face_orientation,
1176 const bool face_flip,
1177 const bool face_rotation,
1178 const unsigned int n_quadrature_points)
1187 return face_no * n_quadrature_points;
1212 static const unsigned int offset[2][2][2]=
1223 + offset[face_orientation][face_flip][face_rotation])
1224 * n_quadrature_points);
1238 subface (
const unsigned int face_no,
1239 const unsigned int subface_no,
1243 const unsigned int n_quadrature_points,
1253 * n_quadrature_points);
1261 subface (
const unsigned int face_no,
1262 const unsigned int subface_no,
1266 const unsigned int n_quadrature_points,
1276 * n_quadrature_points);
1283 subface (
const unsigned int face_no,
1284 const unsigned int subface_no,
1285 const bool face_orientation,
1286 const bool face_flip,
1287 const bool face_rotation,
1288 const unsigned int n_quadrature_points,
1291 const unsigned int dim = 3;
1322 const unsigned int total_subfaces_per_face=8;
1339 static const unsigned int orientation_offset[2][2][2]=
1382 static const unsigned int ref_case_offset[3]=
1481 static const unsigned int 1519 const RefinementCase<dim-1> equ_ref_case=equivalent_refine_case[ref_case][subface_no];
1520 const unsigned int equ_subface_no=equivalent_subface_number[ref_case][subface_no];
1526 final_ref_case = (face_orientation==face_rotation
1528 ref_case_permutation[equ_ref_case]
1567 return (((face_no * total_subfaces_per_face
1568 + ref_case_offset[final_ref_case-1]
1570 + orientation_offset[face_orientation][face_flip][face_rotation]
1572 * n_quadrature_points);
1580 const unsigned int face_no)
1582 std::vector<Point<dim> > points(quadrature.
size());
1591 const unsigned int face_no,
1592 const unsigned int subface_no,
1595 std::vector<Point<dim> > points(quadrature.
size());
1605 namespace QIteratedImplementation
1609 bool uses_both_endpoints(
const Quadrature<1> &base_quadrature)
1611 bool at_left =
false,
1613 for (
unsigned int i = 0; i<base_quadrature.
size(); ++i)
1621 return (at_left && at_right);
1733 const unsigned int )
1744 const unsigned int n_copies)
1746 Quadrature<1> (
internal::QIteratedImplementation::uses_both_endpoints(base_quadrature) ?
1747 (base_quadrature.size()-1) * n_copies + 1 :
1748 base_quadrature.size() * n_copies)
1754 if (!internal::QIteratedImplementation::uses_both_endpoints(base_quadrature))
1759 unsigned int next_point = 0;
1760 for (
unsigned int copy=0; copy<n_copies; ++copy)
1761 for (
unsigned int q_point=0; q_point<base_quadrature.
size(); ++q_point)
1763 this->quadrature_points[next_point]
1766 (1.0*copy)/n_copies);
1767 this->weights[next_point]
1768 = base_quadrature.
weight(q_point) / n_copies;
1776 unsigned int next_point = 0;
1783 double double_point_weight = 0;
1784 unsigned int n_end_points = 0;
1785 for (
unsigned int i=0; i<base_quadrature.
size(); ++i)
1791 double_point_weight += base_quadrature.
weight(i);
1795 double_point_weight /= n_copies;
1800 Assert (n_end_points == 2, ExcInvalidQuadratureFormula());
1803 for (
unsigned int copy=0; copy<n_copies; ++copy)
1804 for (
unsigned int q_point=0; q_point<base_quadrature.
size(); ++q_point)
1814 this->quadrature_points[next_point]
1817 (1.0*copy)/n_copies);
1824 if ((copy != n_copies-1) &&
1826 this->weights[next_point] = double_point_weight;
1828 this->weights[next_point] = base_quadrature.
weight(q_point) /
1836 double sum_of_weights = 0;
1837 for (
unsigned int i=0; i<this->size(); ++i)
1838 sum_of_weights += this->weight(i);
1839 Assert (std::fabs(sum_of_weights-1) < 1e-13,
1857 const unsigned int N)
1880 DEAL_II_NAMESPACE_CLOSE
static const unsigned int invalid_unsigned_int
static Quadrature< dim > project_to_child(const Quadrature< dim > &quadrature, const unsigned int child_no)
#define AssertDimension(dim1, dim2)
std::vector< double > weights
const std::vector< double > & get_weights() const
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Quadrature(const unsigned int n_quadrature_points=0)
static Quadrature< 2 > rotate(const Quadrature< 2 > &q, const unsigned int n_times)
#define AssertIndexRange(index, range)
const Point< dim > & point(const unsigned int i) const
std::conditional< dim==1, std::array< Quadrature< 1 >, dim >, const std::array< Quadrature< 1 >, dim > & >::type get_tensor_basis() const
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
Quadrature & operator=(const Quadrature< dim > &)
static Quadrature< dim > project_to_all_subfaces(const SubQuadrature &quadrature)
static Quadrature< dim > project_to_line(const Quadrature< 1 > &quadrature, const Point< dim > &p1, const Point< dim > &p2)
QAnisotropic(const Quadrature< 1 > &qx)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
void initialize(const std::vector< Point< dim > > &points, const std::vector< double > &weights)
T sum(const T &t, const MPI_Comm &mpi_communicator)
static unsigned int child_cell_on_face(const RefinementCase< dim > &ref_case, const unsigned int face, const unsigned int subface, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false, const RefinementCase< dim-1 > &face_refinement_case=RefinementCase< dim-1 >::isotropic_refinement)
#define Assert(cond, exc)
static void project_to_subface(const SubQuadrature &quadrature, const unsigned int face_no, const unsigned int subface_no, std::vector< Point< dim > > &q_points, const RefinementCase< dim-1 > &ref_case=RefinementCase< dim-1 >::isotropic_refinement)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
std::size_t memory_consumption() const
std::unique_ptr< std::array< Quadrature< 1 >, dim > > tensor_basis
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
bool is_tensor_product_flag
std::vector< Point< dim > > quadrature_points
unsigned int size() const
static Quadrature< 2 > reflect(const Quadrature< 2 > &q)
static Quadrature< dim > project_to_all_faces(const SubQuadrature &quadrature)
bool operator==(const Quadrature< dim > &p) const
static void project_to_face(const SubQuadrature &quadrature, const unsigned int face_no, std::vector< Point< dim > > &q_points)
QIterated(const Quadrature< 1 > &base_quadrature, const unsigned int n_copies)
static DataSetDescriptor subface(const unsigned int face_no, const unsigned int subface_no, const bool face_orientation, const bool face_flip, const bool face_rotation, const unsigned int n_quadrature_points, const internal::SubfaceCase< dim > ref_case=internal::SubfaceCase< dim >::case_isotropic)
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcZero()
static Quadrature< dim > project_to_all_children(const Quadrature< dim > &quadrature)
double weight(const unsigned int i) const
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
static ::ExceptionBase & ExcInternalError()
static DataSetDescriptor face(const unsigned int face_no, const bool face_orientation, const bool face_flip, const bool face_rotation, const unsigned int n_quadrature_points)