Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

Commit 144b36ba authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

added examples to integrate methods

parent c27b2e73
......@@ -8,12 +8,13 @@ namespace AMDiS
{
namespace Impl
{
template <class GridFct, class GridView, class QuadProvider>
auto integrateImpl(GridFct&& gridFct, GridView const& gridView, QuadProvider makeQuad)
template <class GF, class GridView, class QuadProvider>
auto integrateImpl(GF&& gf, GridView const& gridView, QuadProvider makeQuad)
{
auto localFct = localFunction(gridFct);
auto localFct = localFunction(std::forward<GF>(gf));
using Range = typename std::decay_t<GridFct>::Range;
using GridFct = std::decay_t<GF>;
using Range = typename GridFct::Range;
Range result(0);
for (auto const& element : elements(gridView)) {
......@@ -33,7 +34,15 @@ namespace AMDiS
} // end namespace Impl
/// Integrate expression with quadrature rule determined by polynomial order of expression
/// \brief Integrate expression with quadrature rule determined by polynomial order of expression
/**
* **Example:**
* ```
* double i1 = integrate(prob.solution(0), prob.gridView());
* double i2 = integrate(X(0) + X(1), prob.gridView());
* double i3 = integrate([](auto const& x) { return x[0] + x[1]; }, prob.gridView()); // ERROR
* ```
**/
template <class Expr, class GridView>
auto integrate(Expr&& expr, GridView const& gridView)
{
......@@ -47,17 +56,24 @@ namespace AMDiS
#if AMDIS_HAS_CXX_CONSTEXPR_IF
if constexpr(expr_has_order)
return Impl::integrateImpl(gridFct, gridView, makeQuad);
return Impl::integrateImpl(std::forward<decltype(gridFct)>(gridFct), gridView, makeQuad);
else
return 0.0;
#else
return Dune::Hybrid::ifElse(bool_<expr_has_order>,
[&](auto) { return Impl::integrateImpl(gridFct, gridView, makeQuad); },
[&](auto) { return Impl::integrateImpl(std::forward<decltype(gridFct)>(gridFct), gridView, makeQuad); },
[ ](auto) { return 0.0; });
#endif
}
/// Integrate expression with quadrature rule provided
/**
* **Example:**
* ```
* auto quad = Dune::QuadratureRules<double,DIM>::rule(Dune::GeometryTypes::triangle, 1);
* double i4 = integrate([](auto const& x) { return x[0]; }, prob.gridView(), quad); // OK
* ```
**/
template <class Expr, class GridView,
class QuadratureRule = Dune::QuadratureRule<typename GridView::ctype, GridView::dimension>>
auto integrate(Expr&& expr, GridView const& gridView, QuadratureRule const& quad)
......@@ -68,6 +84,12 @@ namespace AMDiS
}
/// Integrate expression with quadrature rule determined by provided polynomial `degree`
/**
* **Example:**
* ```
* double i5 = integrate([](auto const& x) { return x[0]; }, prob.gridView(), 1); // OK
* ```
**/
template <class Expr, class GridView>
auto integrate(Expr&& expr, GridView const& gridView, int degree,
Dune::QuadratureType::Enum qt = Dune::QuadratureType::GaussLegendre)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment