Reference documentation for deal.II version 9.0.0
quadrature_selector.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2003 - 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/quadrature_selector.h>
17 #include <deal.II/base/quadrature_lib.h>
18 
19 DEAL_II_NAMESPACE_OPEN
20 
21 
22 template <int dim>
25 create_quadrature (const std::string &s,
26  const unsigned int order)
27 {
28  if (s == "gauss")
29  {
30  AssertThrow(order >= 1, ExcInvalidQGaussOrder(order));
31  return QGauss<dim>(order);
32  }
33  else
34  {
35  AssertThrow(order == 0, ExcInvalidOrder(s, order));
36 
37  if (s == "midpoint") return QMidpoint<dim>();
38  else if (s == "milne") return QMilne<dim>();
39  else if (s == "simpson") return QSimpson<dim>();
40  else if (s == "trapez") return QTrapez<dim>();
41  else if (s == "weddle") return QWeddle<dim>();
42  }
43 
44  // we didn't find this name
45  AssertThrow (false, ExcInvalidQuadrature(s));
46  // return something to suppress
47  // stupid warnings by some
48  // compilers
49  return Quadrature<dim>();
50 }
51 
52 
53 
54 template <int dim>
56  const unsigned int order)
57  :
58  Quadrature<dim> (create_quadrature(s, order).get_points(),
59  create_quadrature(s, order).get_weights())
60 {
61 }
62 
63 
64 
65 template <int dim>
66 std::string
68 {
69  return std::string("gauss|midpoint|milne|simpson|trapez|weddle");
70 }
71 
72 
73 
74 // explicit instantiations
75 template class QuadratureSelector<1>;
76 template class QuadratureSelector<2>;
77 template class QuadratureSelector<3>;
78 
79 DEAL_II_NAMESPACE_CLOSE
static Quadrature< dim > create_quadrature(const std::string &s, const unsigned int order)
static std::string get_quadrature_names()
#define AssertThrow(cond, exc)
Definition: exceptions.h:1221
QuadratureSelector(const std::string &s, const unsigned int order=0)