--- /dev/null
+//---------------------------- quadrature_selector.h ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2003 by the deal authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- quadrature_selector.h ---------------------------
+
+#ifndef __deal2__quadrature_selector_h
+#define __deal2__quadrature_selector_h
+
+
+#include <base/quadrature.h>
+#include <base/exceptions.h>
+
+
+/**
+ * This class implements the quadrature rule passed to its constructor
+ * as a string. Supported quadratures are @ref{QGauss} (of all
+ * orders), @ref{QMidpoint}, @ref{QMilne}, @ref{QSimpson},
+ * @ref{QTrapez} and @ref{QWeddle}.
+ *
+ * This class is useful if you want to use flexible quadrature rules,
+ * that are read from a parameter file (see @ref{ParameterHandler} for
+ * this).
+ *
+ * @author Ralf Schulz, 2003
+ */
+
+template<int dim>
+class QuadratureSelector : public Quadrature<dim>
+{
+ public:
+ /**
+ * Constructor. Takes the name of
+ * the quadrature rule (one of
+ * "gauss", "milne", "weddle",
+ * etc) and, if it iss "gauss",
+ * the order of the quadrature
+ * rule as argument.
+ */
+ QuadratureSelector (const std::string &s,
+ const unsigned int order=0);
+
+ /**
+ * This function returns all
+ * possible names for quadratures
+ * as a list separated by @p{|},
+ * so that you can use it for the
+ * definition of parameter files
+ * (see @ref{ParameterHandler} for
+ * details).
+ */
+ static std::string get_quadrature_names();
+
+ /**
+ * Exception
+ */
+ DeclException1 (ExcInvalidQGaussOrder,
+ int,
+ << "You tried to generate QGauss with an invalid order of "
+ << arg1 << " (must be >= 2)");
+ /**
+ * Exception
+ */
+ DeclException2 (ExcInvalidOrder,
+ std::string,
+ unsigned int,
+ << "You tried to generate a " << arg1
+ << " object; no order is needed (" << arg2
+ << " was given as parameter)");
+ /**
+ * Exception
+ */
+ DeclException1 (ExcInvalidQuadrature,
+ std::string,
+ << arg1
+ << " is not a valid quadrature name for a quadrature rule");
+
+ private:
+ /**
+ * This static function creates a
+ * quadrature object according to
+ * the name given as a string,
+ * and the appropriate order (if
+ * the name is "gauss"). It is
+ * called from the constructor.
+ */
+ static
+ Quadrature<dim>
+ create_quadrature (const std::string &s,
+ const unsigned int order);
+};
+
+#endif
--- /dev/null
+//---------------------------- quadrature_selector.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2003 by the deal authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- quadrature_selector.cc ---------------------------
+
+
+#include <base/quadrature_selector.h>
+#include <base/quadrature_lib.h>
+
+
+template <int dim>
+Quadrature<dim>
+QuadratureSelector<dim>::
+create_quadrature (const std::string &s,
+ const unsigned int order)
+{
+ if(s == "gauss")
+ {
+ AssertThrow(order >= 2, ExcInvalidQGaussOrder(order));
+ switch(order)
+ {
+ case 2: return QGauss2<dim>();
+ case 3: return QGauss3<dim>();
+ case 4: return QGauss4<dim>();
+ case 5: return QGauss5<dim>();
+ case 6: return QGauss6<dim>();
+ case 7: return QGauss7<dim>();
+ default: return QGauss<dim>(order);
+ }
+ }
+ else
+ {
+ AssertThrow(order == 0, ExcInvalidOrder(s, order));
+
+ if (s == "midpoint") return QMidpoint<dim>();
+ else if (s == "milne") return QMilne<dim>();
+ else if (s == "simpson") return QSimpson<dim>();
+ else if (s == "trapez") return QTrapez<dim>();
+ else if (s == "weddle") return QWeddle<dim>();
+ }
+
+ // we didn't find this name
+ AssertThrow (false, ExcInvalidQuadrature(s));
+ // return something to suppress
+ // stupid warnings by some
+ // compilers
+ return QGauss2<dim>();
+}
+
+
+
+template <int dim>
+QuadratureSelector<dim>::QuadratureSelector (const std::string &s,
+ const unsigned int order)
+ :
+ Quadrature<dim> (create_quadrature(s, order).get_points(),
+ create_quadrature(s, order).get_weights())
+{
+}
+
+
+
+template <int dim>
+std::string
+QuadratureSelector<dim>::get_quadrature_names()
+{
+ return std::string("gauss|midpoint|milne|simpson|trapez|weddle");
+}
+
+
+
+// explicit instantiations
+template class QuadratureSelector<1>;
+template class QuadratureSelector<2>;
+template class QuadratureSelector<3>;
<h3>base</h3>
<ol>
+ <li> <p> New: There is now a class <code
+ class="class">QuadratureSelector</code> that allows to select a
+ quadrature formula based on a string argument and possibly a
+ number indicating the order of the formula.
+ <br>
+ (Ralf B. Schulz 2002/10/29)
+ </p>
+
<li> <p> Fixed: The constructor of the <code class="class">QGauss</code> class
computed positions and weights of quadrature points in long double accuracy.
However, on machines where long double is the same as double, it therefore
<ol>
<li> <p>
Changed: The <code
-< class="member">SolutionTransfer::interpolate</code>
+ <class="member">SolutionTransfer::interpolate</code>
<br>
(Brent Bailey, WB 2003/10/22 and RH 2003/10/24)
</p>