| 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 <iostream> |
| 7 |
|
| 8 |
#include <dune/localfunctions/raviartthomas/raviartthomassimplex.hh> |
| 9 |
#include <dune/localfunctions/raviartthomas/raviartthomascube.hh> |
| 10 |
#include <dune/localfunctions/raviartthomas/raviartthomas02d.hh> |
| 11 |
#include <dune/localfunctions/raviartthomas/raviartthomas03d.hh> |
| 12 |
#include <dune/localfunctions/raviartthomas/raviartthomaslfecache.hh> |
| 13 |
#include <dune/localfunctions/raviartthomas/raviartthomas12d.hh> |
| 14 |
#include <dune/localfunctions/raviartthomas.hh> |
| 15 |
|
| 16 |
#include <dune/localfunctions/test/test-localfe.hh> |
| 17 |
|
| 18 |
int main(int argc, char** argv) |
| 19 |
{ |
| 20 |
bool success = true; |
| 21 |
|
| 22 |
Dune::RaviartThomasSimplexLocalFiniteElement<2,double,double> rt0simplex2dlfem(Dune::GeometryTypes::simplex(2),0); |
| 23 |
TEST_FE3(rt0simplex2dlfem, DisableNone, 2); |
| 24 |
|
| 25 |
Dune::RaviartThomasSimplexLocalFiniteElement<2,double,double> rt1simplex2dlfem(Dune::GeometryTypes::simplex(2),1); |
| 26 |
TEST_FE3(rt1simplex2dlfem, DisableNone,2); |
| 27 |
|
| 28 |
Dune::RaviartThomasSimplexLocalFiniteElement<3,double,double> rt0simplex3dlfem(Dune::GeometryTypes::simplex(3),0); |
| 29 |
TEST_FE3(rt0simplex3dlfem,DisableNone,2); |
| 30 |
|
| 31 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,0> rt0cube2dlfem; |
| 32 |
TEST_FE(rt0cube2dlfem); |
| 33 |
for (unsigned int s = 0; s < 16; s++) |
| 34 |
{ |
| 35 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,0> rt0cube2dlfem(s); |
| 36 |
TEST_FE(rt0cube2dlfem); |
| 37 |
} |
| 38 |
|
| 39 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,3,0> rt0cube3dlfem; |
| 40 |
TEST_FE(rt0cube3dlfem); |
| 41 |
for (unsigned int s = 0; s < 64; s++) |
| 42 |
{ |
| 43 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,3,0> rt0cube3dlfem(s); |
| 44 |
TEST_FE(rt0cube3dlfem); |
| 45 |
} |
| 46 |
|
| 47 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,1> rt1cube2dlfem; |
| 48 |
TEST_FE(rt1cube2dlfem); |
| 49 |
for (unsigned int s = 0; s < 16; s++) |
| 50 |
{ |
| 51 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,1> rt1cube2dlfem(s); |
| 52 |
TEST_FE(rt1cube2dlfem); |
| 53 |
} |
| 54 |
|
| 55 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,3,1> rt1cube3dlfem; |
| 56 |
TEST_FE(rt1cube3dlfem); |
| 57 |
for (unsigned int s = 0; s < 64; s++) |
| 58 |
{ |
| 59 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,3,1> rt1cube3dlfem(s); |
| 60 |
TEST_FE(rt1cube3dlfem); |
| 61 |
} |
| 62 |
|
| 63 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,2> rt2cube2dlfem; |
| 64 |
TEST_FE(rt2cube2dlfem); |
| 65 |
for (unsigned int s = 0; s < 16; s++) |
| 66 |
{ |
| 67 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,2> rt2cube2dlfem(s); |
| 68 |
TEST_FE(rt2cube2dlfem); |
| 69 |
} |
| 70 |
|
| 71 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,3> rt3cube2dlfem; |
| 72 |
TEST_FE(rt3cube2dlfem); |
| 73 |
for (unsigned int s = 0; s < 64; s++) |
| 74 |
{ |
| 75 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,3> rt3cube2dlfem(s); |
| 76 |
TEST_FE(rt3cube2dlfem); |
| 77 |
} |
| 78 |
|
| 79 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,4> rt4cube2dlfem; |
| 80 |
TEST_FE(rt4cube2dlfem); |
| 81 |
for (unsigned int s = 0; s < 16; s++) |
| 82 |
{ |
| 83 |
Dune::RaviartThomasCubeLocalFiniteElement<double,double,2,4> rt4cube2dlfem(s); |
| 84 |
TEST_FE(rt4cube2dlfem); |
| 85 |
} |
| 86 |
|
| 87 |
Dune::RT0Cube2DLocalFiniteElement<double,double> rt0cube2dlfemDedicated; |
| 88 |
TEST_FE(rt0cube2dlfemDedicated); |
| 89 |
for (unsigned int s = 0; s < 16; s++) |
| 90 |
{ |
| 91 |
Dune::RT0Cube2DLocalFiniteElement<double,double> rt0cube2dlfemDedicated(s); |
| 92 |
TEST_FE(rt0cube2dlfemDedicated); |
| 93 |
} |
| 94 |
|
| 95 |
Dune::RT1Cube2DLocalFiniteElement<double,double> rt1cube2dlfemDedicated; |
| 96 |
TEST_FE(rt1cube2dlfemDedicated); |
| 97 |
for (unsigned int s = 0; s < 16; s++) |
| 98 |
{ |
| 99 |
Dune::RT1Cube2DLocalFiniteElement<double,double> rt1cube2dlfemDedicated(s); |
| 100 |
TEST_FE(rt1cube2dlfemDedicated); |
| 101 |
} |
| 102 |
|
| 103 |
Dune::RT02DLocalFiniteElement<double,double> rt02dlfemDedicated; |
| 104 |
TEST_FE(rt02dlfemDedicated); |
| 105 |
for (unsigned int s = 0; s < 8; s++) |
| 106 |
{ |
| 107 |
Dune::RT02DLocalFiniteElement<double,double> rt02dlfemDedicated(s); |
| 108 |
TEST_FE(rt02dlfemDedicated); |
| 109 |
} |
| 110 |
|
| 111 |
Dune::RT12DLocalFiniteElement<double,double> rt12dlfemDedicated; |
| 112 |
TEST_FE(rt12dlfemDedicated); |
| 113 |
for (unsigned int s = 0; s < 8; s++) |
| 114 |
{ |
| 115 |
Dune::RT12DLocalFiniteElement<double,double> rt12dlfemDedicated(s); |
| 116 |
TEST_FE(rt12dlfemDedicated); |
| 117 |
} |
| 118 |
|
| 119 |
Dune::RT03DLocalFiniteElement<double,double> rt03dlfemDedicated; |
| 120 |
TEST_FE(rt03dlfemDedicated); |
| 121 |
for (unsigned int s = 0; s < 16; s++) |
| 122 |
{ |
| 123 |
Dune::RT03DLocalFiniteElement<double,double> rt03dlfemDedicated(s); |
| 124 |
TEST_FE(rt03dlfemDedicated); |
| 125 |
} |
| 126 |
|
| 127 |
Dune::RT0Cube3DLocalFiniteElement<double,double> rt0cube3dlfemDedicated; |
| 128 |
TEST_FE(rt0cube3dlfemDedicated); |
| 129 |
for (unsigned int s = 0; s < 64; s++) |
| 130 |
{ |
| 131 |
Dune::RT0Cube3DLocalFiniteElement<double,double> rt0cube3dlfemDedicated(s); |
| 132 |
TEST_FE(rt0cube3dlfemDedicated); |
| 133 |
} |
| 134 |
|
| 135 |
Dune::RT1Cube3DLocalFiniteElement<double,double> rt1cube3dlfemDedicated; |
| 136 |
TEST_FE(rt1cube3dlfemDedicated); |
| 137 |
for (unsigned int s = 0; s < 64; s++) |
| 138 |
{ |
| 139 |
Dune::RT1Cube3DLocalFiniteElement<double,double> rt1cube3dlfemDedicated(s); |
| 140 |
TEST_FE(rt1cube3dlfemDedicated); |
| 141 |
} |
| 142 |
|
| 143 |
// Pyramid shapefunctions are not differentiable on the plane where xi[0]=xi[1]. |
| 144 |
// So let's skip test points on this plane |
| 145 |
auto xySkip = [](const Dune::FieldVector<double,3>& xi){return std::abs(xi[0]-xi[1]) < 1e-8;}; |
| 146 |
|
| 147 |
Dune::RT0PyramidLocalFiniteElement<double,double> rt0pyramidlfemDedicated; |
| 148 |
TEST_FE4(rt0pyramidlfemDedicated, DisableNone, 0, xySkip); |
| 149 |
for (unsigned int s = 0; s < 32; s++) |
| 150 |
{ |
| 151 |
Dune::RT0PyramidLocalFiniteElement<double,double> rt0pyramidlfemDedicated(s); |
| 152 |
TEST_FE4(rt0pyramidlfemDedicated, DisableNone, 0, xySkip); |
| 153 |
} |
| 154 |
|
| 155 |
Dune::RT0PrismLocalFiniteElement<double,double> rt0prismlfemDedicated; |
| 156 |
TEST_FE(rt0prismlfemDedicated); |
| 157 |
for (unsigned int s = 0; s < 32; s++) |
| 158 |
{ |
| 159 |
Dune::RT0PrismLocalFiniteElement<double,double> rt0prismlfemDedicated(s); |
| 160 |
TEST_FE(rt0prismlfemDedicated); |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
// Test the RaviartThomasLocalFiniteElementCache |
| 165 |
Dune::RaviartThomasLocalFiniteElementCache<double,double,2,0> lagrangeLFECache; |
| 166 |
TEST_FE(lagrangeLFECache.get(Dune::GeometryTypes::simplex(2))); |
| 167 |
TEST_FE(lagrangeLFECache.get(Dune::GeometryTypes::cube(2))); |
| 168 |
|
| 169 |
// Test whether asking the cache for an element of the wrong dimension throws an exception |
| 170 |
bool lagrangeLFESuccess = false; |
| 171 |
try { |
| 172 |
auto doesntExist = lagrangeLFECache.get(Dune::GeometryTypes::simplex(1)); |
| 173 |
} catch (Dune::Exception& e) |
| 174 |
{ |
| 175 |
lagrangeLFESuccess = true; |
| 176 |
} |
| 177 |
success &= lagrangeLFESuccess; |
| 178 |
|
| 179 |
return success ? 0 : 1; |
| 180 |
} |