Debian Codegraph @

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