Debian Codegraph @

dune/localfunctions/test/globalmonomialfunctionstest.cc

raw
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5
6 #include <cstddef>
7 #include <iostream>
8 #include <ostream>
9
10 #include <dune/common/exceptions.hh>
11 #include <dune/common/fvector.hh>
12 #include <dune/common/hybridutilities.hh>
13
14 #include <dune/geometry/type.hh>
15 #include <dune/geometry/generalvertexorder.hh>
16
17 #include <dune/localfunctions/monomial.hh>
18
19 #include "geometries.hh"
20 #include "test-fe.hh"
21
22 // tolerance for floating-point comparisons
23 const double eps = 1e-9;
24 // stepsize for numerical differentiation
25 const double delta = 1e-5;
26
27 template<int dim,int p>
28 static void Order(int &result)
29 {
30 std::cout << "== Checking global-valued monomial elements (with "
31 << "dim=" << dim << ", p=" << p << ")" << std::endl;
32
33 typedef TestGeometries<double, dim> TestGeos;
34 static const TestGeos testGeos;
35
36 typedef typename TestGeos::Geometry Geometry;
37 Dune::MonomialFiniteElementFactory<Geometry, double, p> feFactory;
38
39 for(std::size_t i = 0; i < testGeos.size(); ++i) {
40 const Geometry &geo = testGeos[i];
41
42 std::cout << "=== GeometryType " << geo.type() << std::endl;
43
44 bool success = testFE(geo, feFactory.make(geo), eps, delta);
45
46 if(success && result != 1)
47 result = 0;
48 else
49 result = 1;
50 }
51 }
52
53 template<int dim>
54 static void Dim(int &result)
55 {
56 Dune::Hybrid::forEach(std::make_index_sequence<4>{},[&](auto i){Order<dim,i>(result);});
57 }
58
59 int main(int argc, char** argv) {
60 try {
61 int result = 77;
62
63 Dune::Hybrid::forEach(std::make_index_sequence<3>{},[&](auto i){Dim<i+1>(result);});
64
65 return result;
66 }
67 catch (const Dune::Exception& e) {
68 std::cerr << e << std::endl;
69 throw;
70 }
71 }