Commit efd57c28 authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de

Merge branch 'feature/add-unit-tests' into 'master'

assembleGlobalBasisTransferMatrix: add more unit testing

See merge request !72
parents 47c20c52 6340e58a
Pipeline #28357 passed with stage
in 12 minutes and 8 seconds
......@@ -136,6 +136,41 @@ bool testPowerBasis(const GW0& gw0, const GW1& gw1)
}
template<int order0, int order1, class GW0, class GW1>
bool testOrder(const GW0& gw0, const GW1& gw1)
{
// our test funcion for interpolation
auto f = [](const auto& x)
{
FieldVector<double,3> y;
y = 1.;
for( auto xs : x )
{
y[0] += std::sin(xs);
y[1] += 2*xs +5.;
y[2] += 3*xs*xs;
}
return y;
};
using namespace Functions::BasisFactory;
auto lagrange0 = makeBasis(gw0, power<3>(lagrange<order0>(),blockedInterleaved()));
auto lagrange1 = makeBasis(gw1, power<3>(lagrange<order1>(),blockedInterleaved()));
BCRSMatrix<FieldMatrix<double,3,3>> matrix;
BlockVector<FieldVector<double,3>> coeffs0, coeffs1;
const auto diff = checkInterpolation(matrix, f, lagrange0, coeffs0, lagrange1, coeffs1);
std::cout << " test interpolation P" << order0 << " -> P" << order1 << " : error = " << diff << std::endl;
return diff < 1e-12;
}
template<int order, class GW0, class GW1>
bool testRaviartThomas(const GW0& gw0, const GW1& gw1)
{
......@@ -251,6 +286,14 @@ bool checkTransferMatrix(const GW0& gw0, const GW1& gw1)
if constexpr ( GW0::dimension==2 )
passed = passed and testRaviartThomas<0>(gw0,gw1);
// 2D: check lagrange interpolation for different orders on the same grid
if constexpr ( GW0::dimension < 3 )
{
passed = passed and testOrder<1,2>(gw1,gw1);
passed = passed and testOrder<2,3>(gw1,gw1);
passed = passed and testOrder<1,3>(gw1,gw1);
}
return passed;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment