Commit 515eec7a authored by jannick.wolters's avatar jannick.wolters
Browse files

added automatic deletion of tests/results after the unit test ran; moved all...

added automatic deletion of tests/results after the unit test ran; moved all "REQUIRED" out of for loops lower the total number of assertions to a reasonable level


Former-commit-id: e86cb64b
parent d089a099
......@@ -2,6 +2,7 @@
#include "catch.hpp"
#include <Python.h>
#include <filesystem>
#include <mpi.h>
int main( int argc, char** argv ) {
......@@ -12,6 +13,9 @@ int main( int argc, char** argv ) {
const int result = Catch::Session().run( argc, argv );
if( Py_IsInitialized() ) Py_Finalize();
std::cout << std::string( TESTS_PATH ) + "result" << std::endl;
std::filesystem::remove_all( std::string( TESTS_PATH ) + "result" );
MPI_Finalize();
return result;
}
......@@ -43,9 +43,11 @@ TEST_CASE( "checkerboard_SN", "[validation_tests]" ) {
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < test.size(); ++i ) {
REQUIRE( std::fabs( test[i] - reference[i] ) < eps );
if( std::fabs( test[i] - reference[i] ) > eps ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
TEST_CASE( "checkerboard_PN", "[validation_tests]" ) {
......@@ -61,9 +63,11 @@ TEST_CASE( "checkerboard_PN", "[validation_tests]" ) {
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < test.size(); ++i ) {
REQUIRE( std::fabs( test[i] - reference[i] ) < eps );
if( std::fabs( test[i] - reference[i] ) > eps ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
TEST_CASE( "checkerboard_MN", "[validation_tests]" ) {
......@@ -79,9 +83,11 @@ TEST_CASE( "checkerboard_MN", "[validation_tests]" ) {
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < test.size(); ++i ) {
REQUIRE( std::fabs( test[i] - reference[i] ) < eps );
if( std::fabs( test[i] - reference[i] ) > eps ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
TEST_CASE( "linesource_SN", "[validation_tests]" ) {
......@@ -97,9 +103,11 @@ TEST_CASE( "linesource_SN", "[validation_tests]" ) {
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < test.size(); ++i ) {
REQUIRE( std::fabs( test[i] - reference[i] ) < eps );
if( std::fabs( test[i] - reference[i] ) > eps ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
TEST_CASE( "linesource_PN", "[validation_tests]" ) {
......@@ -116,9 +124,11 @@ TEST_CASE( "linesource_PN", "[validation_tests]" ) {
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < test.size(); ++i ) {
REQUIRE( std::fabs( test[i] - reference[i] ) < eps );
if( std::fabs( test[i] - reference[i] ) > eps ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
TEST_CASE( "linesource_MN", "[validation_tests]" ) {
......@@ -137,9 +147,11 @@ TEST_CASE( "linesource_MN", "[validation_tests]" ) {
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < test.size(); ++i ) {
REQUIRE( std::fabs( test[i] - reference[i] ) < eps );
if( std::fabs( test[i] - reference[i] ) > eps ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
SECTION( "Maxwell Boltzmann Entropy" ) {
......@@ -155,9 +167,11 @@ TEST_CASE( "linesource_MN", "[validation_tests]" ) {
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < test.size(); ++i ) {
REQUIRE( std::fabs( test[i] - reference[i] ) < eps );
if( std::fabs( test[i] - reference[i] ) > eps ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
}
......@@ -173,7 +187,6 @@ void tokenize( std::string const& str, const char delim, std::vector<std::string
}
TEST_CASE( "screen_output", "[output]" ) {
spdlog::drop_all(); // Make sure to write in own logging file
std::string config_file_name = std::string( TESTS_PATH ) + "input/validate_logger.cfg";
......@@ -198,7 +211,6 @@ TEST_CASE( "screen_output", "[output]" ) {
std::ifstream historyLoggerStream( historyLogger );
std::string line, lineRef;
bool lineValid;
const char delimScreen = '|';
const char delimHist = ',';
......@@ -213,22 +225,15 @@ TEST_CASE( "screen_output", "[output]" ) {
tokenize( line, delimScreen, out );
tokenize( lineRef, delimScreen, outRef );
if( out.size() != outRef.size() ) std::cout << lineRef << "\n" << line << "\n";
REQUIRE( out.size() == outRef.size() ); // Sanity check
bool lineValid = true;
for( unsigned idx_token = 1; idx_token < out.size(); idx_token++ ) { // Skip date ==> start from 1
lineValid = outRef[idx_token].compare( out[idx_token] ) == 0;
if( !lineValid ) {
std::cout << lineRef << "\n" << line << "\n";
}
REQUIRE( lineValid );
if( outRef[idx_token].compare( out[idx_token] ) != 0 ) lineValid = false;
}
REQUIRE( lineValid );
}
bool eqLen = screenLoggerReferenceStream.eof() && screenLoggerStream.eof();
if( !eqLen ) {
std::cout << "Files of unequal length!\n";
}
REQUIRE( eqLen ); // Files must be of same length
// --- History Logger
......@@ -241,20 +246,14 @@ TEST_CASE( "screen_output", "[output]" ) {
tokenize( line, delimHist, out );
tokenize( lineRef, delimHist, outRef );
if( out.size() != outRef.size() ) std::cout << lineRef << "\n" << line << "\n";
REQUIRE( out.size() == outRef.size() ); // sanity check
bool lineValid = true;
for( unsigned idx_token = 1; idx_token < out.size(); idx_token++ ) { // Skip date ==> start from 1
lineValid = outRef[idx_token].compare( out[idx_token] ) == 0;
if( !lineValid ) {
std::cout << lineRef << "\n" << line << "\n";
}
REQUIRE( lineValid );
if( outRef[idx_token].compare( out[idx_token] ) != 0 ) lineValid = false;
}
REQUIRE( lineValid );
}
eqLen = historyLoggerReferenceStream.eof() && historyLoggerStream.eof();
if( !eqLen ) {
std::cout << "Files of unequal length!\n";
}
REQUIRE( eqLen ); // Files must be of same length
}
......@@ -42,31 +42,35 @@ TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmoni
SECTION( "Test against analytical solution" ) {
std::vector<double> legendre;
Vector moment;
std::vector<bool> validLegendrePoly( 6, true );
std::vector<bool> validMoment( 9, true );
for( double my = -1.0; my < 1.0; my += 0.1 ) {
legendre = testBase.GetAssLegendrePoly( my );
REQUIRE( std::fabs( legendre[0] - P0_0( my ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( legendre[1] - P1_0( my ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( legendre[2] - P1_1( my ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( legendre[3] - P2_0( my ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( legendre[4] - P2_1( my ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( legendre[5] - P2_2( my ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( std::fabs( legendre[0] - P0_0( my ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validLegendrePoly[0] = false;
if( std::fabs( legendre[1] - P1_0( my ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validLegendrePoly[1] = false;
if( std::fabs( legendre[2] - P1_1( my ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validLegendrePoly[2] = false;
if( std::fabs( legendre[3] - P2_0( my ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validLegendrePoly[3] = false;
if( std::fabs( legendre[4] - P2_1( my ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validLegendrePoly[4] = false;
if( std::fabs( legendre[5] - P2_2( my ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validLegendrePoly[5] = false;
for( double phi = 0.0; phi < 2 * M_PI; phi += 0.1 ) {
moment = testBase.ComputeSphericalBasis( my, phi );
REQUIRE( std::fabs( moment[0] - Y0_0( my, phi ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( moment[1] - Y1_m1( my, phi ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( moment[2] - Y1_0( my, phi ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( moment[3] - Y1_1( my, phi ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( moment[4] - Y2_m2( my, phi ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( moment[5] - Y2_m1( my, phi ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( moment[6] - Y2_0( my, phi ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( moment[7] - Y2_1( my, phi ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
REQUIRE( std::fabs( moment[8] - Y2_2( my, phi ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( std::fabs( moment[0] - Y0_0( my, phi ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validMoment[0] = false;
if( std::fabs( moment[1] - Y1_m1( my, phi ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validMoment[1] = false;
if( std::fabs( moment[2] - Y1_0( my, phi ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validMoment[2] = false;
if( std::fabs( moment[3] - Y1_1( my, phi ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validMoment[3] = false;
if( std::fabs( moment[4] - Y2_m2( my, phi ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validMoment[4] = false;
if( std::fabs( moment[5] - Y2_m1( my, phi ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validMoment[5] = false;
if( std::fabs( moment[6] - Y2_0( my, phi ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validMoment[6] = false;
if( std::fabs( moment[7] - Y2_1( my, phi ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validMoment[7] = false;
if( std::fabs( moment[8] - Y2_2( my, phi ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) validMoment[8] = false;
}
}
REQUIRE( std::all_of( validLegendrePoly.begin(), validLegendrePoly.end(), []( bool v ) { return v; } ) );
REQUIRE( std::all_of( validMoment.begin(), validMoment.end(), []( bool v ) { return v; } ) );
}
// Remove title line
......@@ -86,6 +90,7 @@ TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmoni
getline( case_file, text_line );
bool errorWithinBounds = true;
while( getline( case_file, text_line ) ) {
// give line to stringstream
......@@ -97,9 +102,10 @@ TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmoni
result = testBase.ComputeSphericalBasis( my, phi );
for( unsigned idx = 0; idx < 9; idx++ ) {
REQUIRE( std::fabs( result[idx] - values[idx] ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( std::fabs( result[idx] - values[idx] ) > 1e2 * std::numeric_limits<double>::epsilon() ) errorWithinBounds = false;
}
}
REQUIRE( errorWithinBounds );
case_file.close();
}
......@@ -128,24 +134,22 @@ TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmoni
}
}
bool errorWithinBounds = true;
bool orthogonality = true;
for( unsigned idx_row = 0; idx_row < 9; idx_row++ ) {
for( unsigned idx_col = 0; idx_col < 9; idx_col++ ) {
if( idx_row == idx_col ) {
if( std::fabs( results( idx_row, idx_col ) - 1.0 ) > 1e2 * std::numeric_limits<double>::epsilon() ) {
std::cout << "Error in entry (" << idx_row << ", " << idx_col << ") with result." << results( idx_row, idx_col ) << std::endl;
}
// Orthogonality
REQUIRE( std::fabs( results( idx_row, idx_col ) - 1.0 ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( std::fabs( results( idx_row, idx_col ) - 1.0 ) > 1e2 * std::numeric_limits<double>::epsilon() ) orthogonality = false;
}
else {
if( std::fabs( results( idx_row, idx_col ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) {
std::cout << "Error in entry (" << idx_row << ", " << idx_col << ") with result." << results( idx_row, idx_col ) << std::endl;
}
// Normality
REQUIRE( std::fabs( results( idx_row, idx_col ) ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( std::fabs( results( idx_row, idx_col ) ) > 1e2 * std::numeric_limits<double>::epsilon() ) errorWithinBounds = false;
}
}
}
REQUIRE( errorWithinBounds );
REQUIRE( orthogonality );
}
SECTION( "test parity - carthesian coordinates" ) {
......@@ -158,6 +162,7 @@ TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmoni
double x, y, z;
bool errorWithinBounds = true;
for( unsigned idx_quad = 0; idx_quad < quad.GetNq(); idx_quad++ ) {
x = quad.GetPoints()[idx_quad][0];
y = quad.GetPoints()[idx_quad][1];
......@@ -177,10 +182,11 @@ TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmoni
else
result = moment2[idx_sys] + moment1[idx_sys];
REQUIRE( std::fabs( result ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( std::fabs( result ) > 1e2 * std::numeric_limits<double>::epsilon() ) errorWithinBounds = false;
}
}
}
REQUIRE( errorWithinBounds );
}
SECTION( "test parity - polar coordinates" ) {
......@@ -192,6 +198,7 @@ TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmoni
double result = 0.;
// // test in polar coordinates
bool errorWithinBounds = true;
for( double my = -1.0; my < 1.0; my += 0.1 ) {
for( double phi = 0.0; phi < 2 * M_PI; phi += 0.1 ) {
moment2 = testBase.ComputeSphericalBasis( my, phi );
......@@ -206,10 +213,11 @@ TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmoni
else
result = moment2[idx_sys] + moment1[idx_sys];
REQUIRE( std::fabs( result ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( std::fabs( result ) > 1e2 * std::numeric_limits<double>::epsilon() ) errorWithinBounds = false;
}
}
}
}
REQUIRE( errorWithinBounds );
}
}
......@@ -47,11 +47,13 @@ TEST_CASE( "convert image data to grayscale matrix", "[image I/O]" ) {
return x.size() == refMatrix[0].size();
} ) ); // consistency check if all columns of the read-in file have equal length
bool matricesEqual = true;
for( unsigned i = 0; i < gsImage.rows(); ++i ) {
for( unsigned j = 0; j < gsImage.columns(); ++j ) {
REQUIRE( refMatrix[i][j] == gsImage( i, j ) ); // all values match
if( refMatrix[i][j] != gsImage( i, j ) ) matricesEqual = false; // all values match
}
}
REQUIRE( matricesEqual );
}
SECTION( "interpolation of grayscale matrix onto the generated mesh" ) {
......
......@@ -34,9 +34,11 @@ TEST_CASE( "interpolation tests", "[interpolation]" ) {
Interpolation interp( x, y, Interpolation::linear );
Vector res = interp( xq );
REQUIRE( res.size() == ref.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < res.size(); ++i ) {
REQUIRE( std::fabs( res[i] - ref[i] ) < 1e-6 );
if( std::fabs( res[i] - ref[i] ) > 1e-6 ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
SECTION( "loglinear" ) {
......@@ -47,9 +49,11 @@ TEST_CASE( "interpolation tests", "[interpolation]" ) {
Interpolation interp( x, y, Interpolation::loglinear );
Vector res = interp( xq );
REQUIRE( res.size() == ref.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < res.size(); ++i ) {
REQUIRE( std::fabs( res[i] - ref[i] ) < 1e-6 );
if( std::fabs( res[i] - ref[i] ) > 1e-6 ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
SECTION( "cubic" ) {
......@@ -60,8 +64,10 @@ TEST_CASE( "interpolation tests", "[interpolation]" ) {
Interpolation interp( x, y, Interpolation::cubic );
Vector res = interp( xq );
REQUIRE( res.size() == ref.size() );
bool errorWithinBounds = true;
for( unsigned i = 0; i < res.size(); ++i ) {
REQUIRE( std::fabs( res[i] - ref[i] ) < 1e-6 );
if( std::fabs( res[i] - ref[i] ) > 1e-6 ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
}
......@@ -18,10 +18,13 @@ TEST_CASE( "test all scattering kernels", "[kernel]" ) {
auto weights = quad->GetWeights();
Isotropic kernel( quad );
Matrix scatteringMatrix = kernel.GetScatteringKernel();
bool errorWithinBounds = true;
for( unsigned i = 0; i < scatteringMatrix.rows(); ++i ) {
for( unsigned j = 0; j < scatteringMatrix.columns(); ++j ) {
REQUIRE( std::fabs( scatteringMatrix( i, j ) - ( weights[j] / ( 4 * M_PI ) ) ) < std::numeric_limits<double>::epsilon() );
if( std::fabs( scatteringMatrix( i, j ) - ( weights[j] / ( 4 * M_PI ) ) ) > std::numeric_limits<double>::epsilon() )
errorWithinBounds = false;
}
}
REQUIRE( errorWithinBounds );
}
}
......@@ -21,9 +21,10 @@ TEST_CASE( "unit mesh tests", "[mesh]" ) {
}
SECTION( "neighbor and faces are sorted equally" ) {
auto n = mesh->GetNormals();
auto neighbors = mesh->GetNeighbours();
double eps = 1e-7;
auto n = mesh->GetNormals();
auto neighbors = mesh->GetNeighbours();
double eps = 1e-7;
bool errorWithinBounds = true;
for( unsigned i = 0; i < mesh->GetNumCells(); ++i ) {
for( unsigned j = 0; j < mesh->GetNumNodesPerCell(); ++j ) {
unsigned pos;
......@@ -32,29 +33,35 @@ TEST_CASE( "unit mesh tests", "[mesh]" ) {
for( unsigned k = 0; k < neighbors[nID].size(); ++k ) {
if( neighbors[nID][k] == i ) pos = k;
}
REQUIRE( blaze::l2Norm( n[i][j] + n[nID][pos] ) < eps );
if( blaze::l2Norm( n[i][j] + n[nID][pos] ) > eps ) errorWithinBounds = false;
}
}
REQUIRE( errorWithinBounds );
}
SECTION( "sum over all normals yields zero" ) {
auto n = mesh->GetNormals();
double eps = 1e-7;
auto n = mesh->GetNormals();
double eps = 1e-7;
bool errorWithinBounds = true;
for( unsigned i = 0; i < mesh->GetNumCells(); ++i ) {
Vector sum( 2, 0.0 );
for( unsigned j = 0; j < mesh->GetNumNodesPerCell(); ++j ) {
sum += n[i][j];
}
REQUIRE( blaze::l2Norm( sum ) < eps );
if( blaze::l2Norm( sum ) > eps ) errorWithinBounds = false;
}
REQUIRE( errorWithinBounds );
}
SECTION( "mesh does not have any unassigned faces" ) {
auto neighbors = mesh->GetNeighbours();
auto boundaryType = mesh->GetBoundaryTypes();
auto neighbors = mesh->GetNeighbours();
auto boundaryType = mesh->GetBoundaryTypes();
bool noUnassignedFaces = true;
for( unsigned i = 0; i < mesh->GetNumCells(); ++i ) {
REQUIRE( ( neighbors[i].size() == mesh->GetNumNodesPerCell() ||
( neighbors[i].size() < mesh->GetNumNodesPerCell() && boundaryType[i] != BOUNDARY_TYPE::NONE ) ) );
if( !( neighbors[i].size() == mesh->GetNumNodesPerCell() ||
( neighbors[i].size() < mesh->GetNumNodesPerCell() && boundaryType[i] != BOUNDARY_TYPE::NONE ) ) )
noUnassignedFaces = false;
}
REQUIRE( noUnassignedFaces );
}
}
......@@ -30,6 +30,9 @@ TEST_CASE( "unit numericalflux tests", "[numericalflux]" ) {
Vector psiLVect{ 1.0, 2.0, 3.0, 4.0 };
Vector psiRVect{ 3.0, 4.0, 1.0, 2.0 };
bool fluxCancelingScalar = true;
bool fluxCancelingMatrix = true;
for( unsigned l = 0; l < 10; ++l ) {
Vector n( 2, 0.0 );
std::default_random_engine generator;
......@@ -56,16 +59,18 @@ TEST_CASE( "unit numericalflux tests", "[numericalflux]" ) {
// ---- Test all fluxes ----
// a) Upwinding methods - scalar
REQUIRE( std::fabs( g.Flux( omega, psiL, psiR, n ) - ( -g.Flux( omega, psiR, psiL, -n ) ) ) <
1e2 * std::numeric_limits<double>::epsilon() );
if( std::fabs( g.Flux( omega, psiL, psiR, n ) - ( -g.Flux( omega, psiR, psiL, -n ) ) ) > 1e2 * std::numeric_limits<double>::epsilon() )
fluxCancelingScalar = false;
// b) Upwinding methods - Systems MatrixFlux, 4x4 Matrices, i.e. P1 case;
resultFluxPlus = g.Flux( AxP, AxM, AyP, AyM, AyP, AyM, psiLVect, psiRVect, n );
resultFluxMinus = g.Flux( AxP, AxM, AyP, AyM, AyP, AyM, psiRVect, psiLVect, -n );
REQUIRE( blaze::norm( resultFluxPlus + resultFluxMinus ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( blaze::norm( resultFluxPlus + resultFluxMinus ) > 1e2 * std::numeric_limits<double>::epsilon() ) fluxCancelingMatrix = false;
}
REQUIRE( fluxCancelingScalar );
REQUIRE( fluxCancelingMatrix );
}
SECTION( "test consistency" ) {
......@@ -75,6 +80,9 @@ TEST_CASE( "unit numericalflux tests", "[numericalflux]" ) {
Vector resultFluxOrig( 4, 0 );
Vector psiLVect{ 1.0, 2.0, 3.0, 4.0 };
bool consitencyScalar = true;
bool consitencyMatrix = true;
for( unsigned l = 0; l < 10; ++l ) {
std::default_random_engine generator;
std::normal_distribution<double> distribution( -10.0, 10.0 );
......@@ -102,14 +110,16 @@ TEST_CASE( "unit numericalflux tests", "[numericalflux]" ) {
// a) Upwinding methods - scalar
REQUIRE( std::fabs( g.Flux( omega, psi, psi, n ) - inner * psi ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( std::fabs( g.Flux( omega, psi, psi, n ) - inner * psi ) > 1e2 * std::numeric_limits<double>::epsilon() ) consitencyScalar = false;
// b) Upwinding methods - MatrixFlux, 4x4 Matrices, i.e. P1 case;
resultFluxOrig = ( n[0] * ( AxP + AxM ) * psiLVect + +n[1] * ( AyP + AyM ) * psiLVect );
resultFlux = g.Flux( AxP, AxM, AyP, AyM, AyP, AyM, psiLVect, psiLVect, n );
REQUIRE( blaze::norm( resultFlux - resultFluxOrig ) < 1e2 * std::numeric_limits<double>::epsilon() );
if( blaze::norm( resultFlux - resultFluxOrig ) > 1e2 * std::numeric_limits<double>::epsilon() ) consitencyMatrix = false;
}
REQUIRE( consitencyScalar );
REQUIRE( consitencyMatrix );
}
}
......@@ -114,6 +114,8 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
// Set quadOrder
config->SetQuadOrder( quadratureorder );
bool errorWithinBounds = true;
QuadratureBase* Q = QuadratureBase::CreateQuadrature( config );
VectorVector points = Q->GetPoints();
for( unsigned i = 0; i < Q->GetNq(); i++ ) {
......@@ -126,7 +128,7 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
lowAccuracyTesting );
printf( "Computed result %.15f", norm( points[i] ) );
}
REQUIRE( approxequal( 1.0, norm( points[i] ), lowAccuracyTesting ) );
if( !approxequal( 1.0, norm( points[i] ), lowAccuracyTesting ) ) errorWithinBounds = false;
}
// Special case for Gauss Legendre with half weights
......@@ -147,11 +149,12 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
lowAccuracyTesting );
printf( "Computed result %.15f", norm( points[i] ) );
}
REQUIRE( approxequal( 1.0, norm( points[i] ), lowAccuracyTesting ) );
if( !approxequal( 1.0, norm( points[i] ), lowAccuracyTesting ) ) errorWithinBounds = false;
}
config->SetSNAllGaussPts( true );
}
REQUIRE( errorWithinBounds );
}
}
}
......
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