| 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 |
#include <utility> |
| 10 |
|
| 11 |
#include <dune/common/exceptions.hh> |
| 12 |
#include <dune/common/hybridutilities.hh> |
| 13 |
|
| 14 |
#include <dune/localfunctions/meta/power.hh> |
| 15 |
#include <dune/localfunctions/monomial.hh> |
| 16 |
|
| 17 |
#include "geometries.hh" |
| 18 |
#include "test-fe.hh" |
| 19 |
|
| 20 |
// tolerance for floating-point comparisons |
| 21 |
// be a little bit more lenient here than usual, the momom local basis |
| 22 |
// is known to become more and more unstable with increasing order |
| 23 |
static const double eps = 1e-8; |
| 24 |
// stepsize for numerical differentiation |
| 25 |
static const double delta = 1e-5; |
| 26 |
|
| 27 |
|
| 28 |
template<int dimD, int dimR,int p> |
| 29 |
static void Order(int &result) |
| 30 |
{ |
| 31 |
std::cout << "== Checking global-valued Power elements (with " |
| 32 |
<< "dimR=" << dimR << ") wrapping Monom elements (with " |
| 33 |
<< "dimD=" << dimD << ", p=" << p << ")" << std::endl; |
| 34 |
|
| 35 |
typedef TestGeometries<double, dimD> TestGeos; |
| 36 |
static const TestGeos testGeos; |
| 37 |
|
| 38 |
typedef typename TestGeos::Geometry Geometry; |
| 39 |
typedef Dune::MonomialFiniteElementFactory<Geometry, double, p> |
| 40 |
BackendFEFactory; |
| 41 |
BackendFEFactory backendFEFactory; |
| 42 |
|
| 43 |
typedef typename BackendFEFactory::FiniteElement BackendFE; |
| 44 |
Dune::PowerFiniteElementFactory<BackendFE, dimR> feFactory; |
| 45 |
|
| 46 |
for(std::size_t i = 0; i < testGeos.size(); ++i) { |
| 47 |
const Geometry &geo = testGeos[i]; |
| 48 |
|
| 49 |
std::cout << "=== GeometryType " << geo.type() << std::endl; |
| 50 |
|
| 51 |
bool success = |
| 52 |
testFE(geo, feFactory.make(backendFEFactory.make(geo)), eps, |
| 53 |
delta); |
| 54 |
|
| 55 |
if(success && result != 1) |
| 56 |
result = 0; |
| 57 |
else |
| 58 |
result = 1; |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
template<int dimD,int dimR> |
| 63 |
static void DimR(int &result) |
| 64 |
{ |
| 65 |
Dune::Hybrid::forEach(std::make_index_sequence<4>{},[&](auto i){Order<dimD,dimR,i>(result);}); |
| 66 |
} |
| 67 |
|
| 68 |
template<int dimD> |
| 69 |
static void DimD(int &result) |
| 70 |
{ |
| 71 |
Dune::Hybrid::forEach(std::make_index_sequence<4>{},[&](auto i){DimR<dimD,i>(result);}); |
| 72 |
} |
| 73 |
|
| 74 |
int main(int argc, char** argv) { |
| 75 |
try { |
| 76 |
int result = 77; |
| 77 |
|
| 78 |
Dune::Hybrid::forEach(std::make_index_sequence<3>{},[&](auto i){DimD<i+1>(result);}); |
| 79 |
|
| 80 |
return result; |
| 81 |
} |
| 82 |
catch (const Dune::Exception& e) { |
| 83 |
std::cerr << e << std::endl; |
| 84 |
throw; |
| 85 |
} |
| 86 |
} |