Commit 4a3c5b47 authored by Timo Koch's avatar Timo Koch
Browse files

[test] Add test for refinement quadrature rule for simplex

parent 4686d3fc
......@@ -6,3 +6,4 @@ dumux_add_test(SOURCES test_2d2d_intersection.cc LABELS unit)
dumux_add_test(SOURCES test_2d3d_intersection.cc LABELS unit)
dumux_add_test(SOURCES test_graham_convex_hull.cc LABELS unit)
dumux_add_test(SOURCES test_makegeometry.cc LABELS unit)
dumux_add_test(SOURCES test_refinementquadraturerule.cc LABELS unit)
#include <config.h>
#include <iostream>
#include <array>
#include <dune/common/fvector.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/float_cmp.hh>
#include <dumux/common/geometry/refinementquadraturerule.hh>
#include <dune/geometry/affinegeometry.hh>
int main (int argc, char *argv[]) try
{
using namespace Dumux;
// make a simplex
const auto simplex = Dune::AffineGeometry<double, 2, 3>(
Dune::GeometryTypes::simplex(2),
std::array<Dune::FieldVector<double, 3>, 3>{{{0.0, 0.0, 1.0}, {2.0, 3.0, 4.0}, {3.0, -1.0, 1.0}}}
);
// make quadrature rule
const auto quad = RefinementQuadratureRule<double, 2>(Dune::GeometryTypes::simplex(2), /*refinementlevels=*/3);
// integrate volume
double volume = 0.0;
for (const auto& qp : quad)
volume += qp.weight()*simplex.integrationElement(qp.position());
if (Dune::FloatCmp::ne(volume, simplex.volume()))
DUNE_THROW(Dune::Exception, "Integration yields wrong simplex volume: " << volume << ", should be " << simplex.volume());
return 0;
}
// //////////////////////////////////
// Error handler
// /////////////////////////////////
catch (const Dune::Exception& e) {
std::cout << e << std::endl;
return 1;
}
Supports Markdown
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