Debian Codegraph @

dune/localfunctions/test/test-edges0.5.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
13 #include <dune/geometry/type.hh>
14 #include <dune/geometry/generalvertexorder.hh>
15
16 #include <dune/localfunctions/whitney/edges0.5.hh>
17
18 #include "geometries.hh"
19 #include "test-fe.hh"
20
21 template<std::size_t dim>
22 void testEdgeS0_5(int &result) {
23 // tolerance for floating-point comparisons
24 static const double eps = 1e-9;
25 // stepsize for numerical differentiation
26 static const double delta = 1e-5;
27
28 std::cout << "== Checking global-valued EdgeS0_5 elements (with "
29 << "dim=" << dim << ")" << std::endl;
30
31 Dune::GeometryType gt(Dune::GeometryTypes::simplex(dim));
32
33 typedef TestGeometries<double, dim> TestGeos;
34 static const TestGeos testGeos;
35
36 typedef typename TestGeos::Geometry Geometry;
37 const Geometry &geo = testGeos.get(gt);
38
39 static_assert(dim <= 3, "Need to update vertexIds array for dim > 3");
40 std::size_t vertexIds[] = {0, 1, 2, 3};
41 Dune::GeneralVertexOrder<dim, std::size_t>
42 vo(gt, vertexIds+0, vertexIds+dim+1);
43
44 Dune::EdgeS0_5FiniteElementFactory<Geometry, double> feFactory;
45 bool success = testFE(geo, feFactory.make(geo, vo), eps, delta);
46
47 if(success && result != 1)
48 result = 0;
49 else
50 result = 1;
51 }
52
53 int main(int argc, char** argv) {
54 try {
55 int result = 77;
56
57 testEdgeS0_5<2>(result);
58 testEdgeS0_5<3>(result);
59
60 return result;
61 }
62 catch (const Dune::Exception& e) {
63 std::cout << e << std::endl;
64 throw;
65 }
66 }