test_kernel.cpp 1.09 KB
Newer Older
1
2
3
#include <numeric>

#include "catch.hpp"
4
#include "common/config.h"
5
#include "kernels/isotropic.h"
6
#include "quadratures/quadraturebase.h"
7
8

TEST_CASE( "test all scattering kernels", "[kernel]" ) {
Steffen Schotthöfer's avatar
Steffen Schotthöfer committed
9
    std::string filename = std::string( TESTS_PATH ) + "input/unit_tests/kernels/unit_kernel.cfg";
10
11
12
13
14

    // Load Settings from File
    Config* config = new Config( filename );

    QuadratureBase* quad = QuadratureBase::CreateQuadrature( config );    //@TODO: swap out for different quadrature rule
15
16

    SECTION( "isotropic scattering kernel" ) {
17

18
19
20
        auto weights = quad->GetWeights();
        Isotropic kernel( quad );
        Matrix scatteringMatrix = kernel.GetScatteringKernel();
21
        bool errorWithinBounds  = true;
22
23
        for( unsigned i = 0; i < scatteringMatrix.rows(); ++i ) {
            for( unsigned j = 0; j < scatteringMatrix.columns(); ++j ) {
24
25
                if( std::fabs( scatteringMatrix( i, j ) - ( weights[j] / ( 4 * M_PI ) ) ) > std::numeric_limits<double>::epsilon() )
                    errorWithinBounds = false;
26
27
            }
        }
28
        REQUIRE( errorWithinBounds );
29
30
    }
}