| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2003 - 2022 by the deal.II authors |
| 5 |
// |
| 6 |
// This file is part of the deal.II library. |
| 7 |
// |
| 8 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 9 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 10 |
// governing the source code and code contributions can be found in |
| 11 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 12 |
// |
| 13 |
// ------------------------------------------------------------------------ |
| 14 |
|
| 15 |
|
| 16 |
#ifndef dealii_quadrature_selector_h |
| 17 |
#define dealii_quadrature_selector_h |
| 18 |
|
| 19 |
|
| 20 |
#include <deal.II/base/config.h> |
| 21 |
|
| 22 |
#include <deal.II/base/exceptions.h> |
| 23 |
#include <deal.II/base/quadrature.h> |
| 24 |
|
| 25 |
#include <string> |
| 26 |
|
| 27 |
DEAL_II_NAMESPACE_OPEN |
| 28 |
|
| 29 |
/** |
| 30 |
* This class implements the quadrature rule passed to its constructor as a |
| 31 |
* string. Supported quadratures are QGauss (of all orders), QMidpoint, |
| 32 |
* QMilne, QSimpson, QTrapezoid and QWeddle. |
| 33 |
* |
| 34 |
* This class is useful if you want to use flexible quadrature rules, that are |
| 35 |
* read from a parameter file (see ParameterHandler for this). |
| 36 |
* |
| 37 |
* @ingroup Quadrature |
| 38 |
*/ |
| 39 |
template <int dim> |
| 40 |
class QuadratureSelector : public Quadrature<dim> |
| 41 |
{ |
| 42 |
public: |
| 43 |
/** |
| 44 |
* Constructor. Takes the name of the quadrature rule (one of "gauss", |
| 45 |
* "milne", "weddle", etc) and, if it is "gauss", the number of quadrature |
| 46 |
* points in each coordinate direction. |
| 47 |
*/ |
| 48 |
QuadratureSelector(const std::string &s, const unsigned int order = 0); |
| 49 |
|
| 50 |
/** |
| 51 |
* This function returns all possible names for quadratures as a list |
| 52 |
* separated by <tt>|</tt>, so that you can use it for the definition of |
| 53 |
* parameter files (see ParameterHandler for details). |
| 54 |
*/ |
| 55 |
static std::string |
| 56 |
get_quadrature_names(); |
| 57 |
|
| 58 |
/** |
| 59 |
* @addtogroup Exceptions |
| 60 |
* @{ |
| 61 |
*/ |
| 62 |
|
| 63 |
|
| 64 |
/** |
| 65 |
* Exception |
| 66 |
*/ |
| 67 |
DeclException1(ExcInvalidQGaussOrder, |
| 68 |
int, |
| 69 |
<< "You tried to generate a QGauss object with an invalid " |
| 70 |
<< "number " << arg1 |
| 71 |
<< " of quadrature points in each coordinate " |
| 72 |
<< "direction. This number must be greater than or equal " |
| 73 |
<< "to 1."); |
| 74 |
/** |
| 75 |
* Exception |
| 76 |
*/ |
| 77 |
DeclException2(ExcInvalidOrder, |
| 78 |
std::string, |
| 79 |
unsigned int, |
| 80 |
<< "You tried to generate a " << arg1 |
| 81 |
<< " object; no order is needed for objects of this kind, but " |
| 82 |
<< arg2 << " was given as argument."); |
| 83 |
/** |
| 84 |
* Exception |
| 85 |
*/ |
| 86 |
DeclException1(ExcInvalidQuadrature, |
| 87 |
std::string, |
| 88 |
<< arg1 << " is not a valid name for a quadrature rule."); |
| 89 |
/** @} */ |
| 90 |
private: |
| 91 |
/** |
| 92 |
* This static function creates a quadrature object according to the name |
| 93 |
* given as a string, and the appropriate order (if the name is "gauss"). It |
| 94 |
* is called from the constructor. |
| 95 |
*/ |
| 96 |
static Quadrature<dim> |
| 97 |
create_quadrature(const std::string &s, const unsigned int order); |
| 98 |
}; |
| 99 |
DEAL_II_NAMESPACE_CLOSE |
| 100 |
|
| 101 |
#endif |