Commit 9dca2a88 authored by jannick.wolters's avatar jannick.wolters
Browse files

added absolute path variable for tests folder to allow arbitrary binary...

added absolute path variable for tests folder to allow arbitrary binary placement; CTest now shows errors in case of failure; fixed all KiT-RT compiler warnings


Former-commit-id: 796f39b6
parent 77b8869b
......@@ -5,6 +5,8 @@ stages:
unit_tests:
stage: unit_tests
variables:
CTEST_OUTPUT_ON_FAILURE: TRUE
script:
- git submodule update --init --recursive
- cd code/build/release
......
......@@ -81,6 +81,7 @@ target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:RELEASE>:${KITR
### BUILD UNIT TESTS ############################
include( CTest )
set( CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/ext/Catch2/single_include/catch2 )
add_compile_definitions( TESTS_PATH="${CMAKE_SOURCE_DIR}/tests/" )
add_library( Catch INTERFACE )
target_include_directories( Catch INTERFACE ${CATCH_INCLUDE_DIR} )
file( GLOB_RECURSE TEST_SRCS RELATIVE ${CMAKE_SOURCE_DIR} "tests/*.cpp" )
......
......@@ -21,7 +21,7 @@ class QuadraticEntropy : public EntropyBase
inline double EntropyPrimeDual( double y ) override { return y; }
inline double EntropyHessianDual( double y ) override { return 1.0; }
inline double EntropyHessianDual( double /*y*/ ) override { return 1.0; }
inline bool CheckDomain( double z ) override { return std::isnan( z ); }
};
......
......@@ -43,7 +43,7 @@ class ProblemBase
* energies in vector energy
* @param energy is the energy the cross section is queried for
*/
virtual Vector GetTotalXSE( const Vector& energies ) { return Vector( 1 ); }
virtual Vector GetTotalXSE( const Vector& /*energies*/ ) { return Vector( 1 ); }
/**
* @brief GetScatteringXSE gives back vector (each energy) of scattering cross sections for energies
......@@ -86,7 +86,7 @@ class ProblemBase
scatteringXS: scattering cross section of the exact solution
@return: exact solution at x,y,t,scatteringXS
*/ // Default is set to 0. ~> if no analytical solution is available.
double virtual GetAnalyticalSolution( double x, double y, double t, double scatteringXS ) { return 0.0; }
double virtual GetAnalyticalSolution( double /*x*/, double /*y*/, double /*t*/, double /*scatteringXS*/ ) { return 0.0; }
/**
* @brief Physics constructor
......
......@@ -46,7 +46,7 @@ inline std::vector<std::string> Split( const std::string& s, char delimiter ) {
* \brief utility function for printing a VectorVector
* \param [in] VectorVector we want to print
*/
inline const void PrintVectorVector( const VectorVector vectorIn ) {
inline void PrintVectorVector( const VectorVector vectorIn ) {
unsigned dimOuter = vectorIn.size();
unsigned dimInner = vectorIn[0].size();
......
......@@ -28,7 +28,7 @@ Config::Config( string case_filename ) {
/*--- Set the case name to the base config file name without extension ---*/
auto cwd = std::filesystem::current_path();
auto relPath = std::filesystem::path( case_filename );
auto relPath = std::filesystem::relative( std::filesystem::path( case_filename ), cwd );
_fileName = relPath.filename().string();
_inputDir = cwd.string() + "/" + relPath.parent_path().string();
......
......@@ -366,8 +366,6 @@ Matrix createSU2MeshFromImage( std::string imageName, std::string SU2Filename )
ErrorMessages::Error( "Output directory '" + outDir.string() + "' does not exists!", CURRENT_FUNCTION );
}
_import_array();
std::string pyPath = KITRT_PYTHON_PATH;
if( !Py_IsInitialized() ) {
......
......@@ -28,7 +28,7 @@ std::string OptionBase::optionCheckMultipleValues( std::vector<std::string>& opt
return "";
}
std::string OptionBase::badValue( std::vector<std::string>& option_value, std::string type_id, std::string option_name ) {
std::string OptionBase::badValue( std::vector<std::string>& /*option_value*/, std::string type_id, std::string option_name ) {
std::string newString;
newString.append( option_name );
newString.append( ": improper option value for type " );
......
......@@ -2,7 +2,7 @@
LaxFriedrichsFlux::LaxFriedrichsFlux() : NumericalFlux() {}
double LaxFriedrichsFlux::Flux( const Vector& Omega, double psiL, double psiR, const Vector& n ) const {
double LaxFriedrichsFlux::Flux( const Vector& /*Omega*/, double /*psiL*/, double /*psiR*/, const Vector& /*n*/ ) const {
// double normN = norm( n );
// return 0.5 * inner( n, Omega ) * ( psiL + psiR ) - 0.5 * ( psiR - psiL ) * norm( n ) / _dt;
return -1.0;
......
......@@ -31,8 +31,8 @@ Vector UpwindFlux::Flux( const Matrix AxPlus,
const Matrix AxMinus,
const Matrix AyPlus,
const Matrix AyMinus,
const Matrix AzPlus,
const Matrix AzMinus,
const Matrix /*AzPlus*/,
const Matrix /*AzMinus*/,
const Vector psiL,
const Vector psiR,
const Vector n ) const {
......@@ -74,8 +74,8 @@ Vector UpwindFlux::Flux( const Matrix AxPlus,
*/
void UpwindFlux::FluxVanLeer( const Matrix& Ax,
const Matrix& AxAbs,
const Matrix& Ay,
const Matrix& AyAbs,
const Matrix& /*Ay*/,
const Matrix& /*AyAbs*/,
const Matrix& Az,
const Matrix& AzAbs,
const Vector& psiL,
......
......@@ -25,11 +25,11 @@ MLOptimizer::MLOptimizer( Config* settings ) : OptimizerBase( settings ) {
MLOptimizer::~MLOptimizer() { finalize_python(); }
void MLOptimizer::Solve( Vector& lambda, Vector& u, VectorVector& moments, unsigned idx_cell ) {
void MLOptimizer::Solve( Vector& lambda, Vector& u, VectorVector& /*moments*/, unsigned /*idx_cell*/ ) {
// Convert Vector to array
const unsigned input_size = u.size();
double nn_input[u.size()];
double* nn_input = new double[u.size()];
for( unsigned idx_sys = 0; idx_sys < input_size; idx_sys++ ) {
nn_input[idx_sys] = u[idx_sys];
......@@ -46,9 +46,10 @@ void MLOptimizer::Solve( Vector& lambda, Vector& u, VectorVector& moments, unsig
lambda[i] = nn_output[i];
}
// std::cout << std::endl;
delete[] nn_input;
}
void MLOptimizer::SolveMultiCell( VectorVector& lambda, VectorVector& u, VectorVector& moments ) {
void MLOptimizer::SolveMultiCell( VectorVector& lambda, VectorVector& u, VectorVector& /*moments*/ ) {
const unsigned batch_size = u.size(); // batch size = number of cells
const unsigned sol_dim = u[0].size(); // dimension of input vector = nTotalEntries
......@@ -56,7 +57,7 @@ void MLOptimizer::SolveMultiCell( VectorVector& lambda, VectorVector& u, VectorV
const unsigned n_size = batch_size * sol_dim; // length of input array
// Covert input to array
double nn_input[n_size];
double* nn_input = new double[n_size];
unsigned idx_input = 0;
for( unsigned idx_cell = 0; idx_cell < batch_size; idx_cell++ ) {
......@@ -75,6 +76,8 @@ void MLOptimizer::SolveMultiCell( VectorVector& lambda, VectorVector& u, VectorV
idx_output++;
}
}
delete[] nn_output;
}
void MLOptimizer::init_numpy() {
......
......@@ -21,7 +21,7 @@ VectorVector Checkerboard_SN::GetScatteringXS( const Vector& energies ) { return
VectorVector Checkerboard_SN::GetTotalXS( const Vector& energies ) { return VectorVector( energies.size(), _totalXS ); }
std::vector<VectorVector> Checkerboard_SN::GetExternalSource( const Vector& energies ) {
std::vector<VectorVector> Checkerboard_SN::GetExternalSource( const Vector& /*energies*/ ) {
VectorVector Q( _mesh->GetNumCells(), Vector( 1u, 0.0 ) );
auto cellMids = _mesh->GetCellMidPoints();
for( unsigned j = 0; j < cellMids.size(); ++j ) {
......@@ -77,7 +77,7 @@ VectorVector Checkerboard_PN::GetScatteringXS( const Vector& energies ) { return
VectorVector Checkerboard_PN::GetTotalXS( const Vector& energies ) { return VectorVector( energies.size(), _totalXS ); }
std::vector<VectorVector> Checkerboard_PN::GetExternalSource( const Vector& energies ) {
std::vector<VectorVector> Checkerboard_PN::GetExternalSource( const Vector& /*energies*/ ) {
VectorVector Q( _mesh->GetNumCells(), Vector( 1u, 0.0 ) );
auto cellMids = _mesh->GetCellMidPoints();
for( unsigned j = 0; j < cellMids.size(); ++j ) {
......
......@@ -38,7 +38,7 @@ VectorVector ElectronRT::SetupIC() {
return VectorVector( _mesh->GetNumCells(), Vector( _settings->GetNQuadPoints(), 1e-10 ) );
}
void ElectronRT::LoadXSH20( std::string fileSigmaS, std::string fileSigmaT ) {
void ElectronRT::LoadXSH20( std::string /*fileSigmaS*/, std::string /*fileSigmaT*/ ) {
// @TODO
}
......
......@@ -13,7 +13,7 @@ LineSource::LineSource( Config* settings, Mesh* mesh ) : ProblemBase( settings,
}
LineSource::~LineSource() {}
double LineSource::GetAnalyticalSolution( double x, double y, double t, double sigma_s ) {
double LineSource::GetAnalyticalSolution( double x, double y, double t, double /*sigma_s*/ ) {
double solution = 0.0;
double R = sqrt( x * x + y * y );
......@@ -117,7 +117,7 @@ VectorVector LineSource_SN::GetScatteringXS( const Vector& energies ) {
VectorVector LineSource_SN::GetTotalXS( const Vector& energies ) { return VectorVector( energies.size(), Vector( _mesh->GetNumCells(), _sigmaS ) ); }
std::vector<VectorVector> LineSource_SN::GetExternalSource( const Vector& energies ) {
std::vector<VectorVector> LineSource_SN::GetExternalSource( const Vector& /*energies*/ ) {
return std::vector<VectorVector>( 1u, std::vector<Vector>( _mesh->GetNumCells(), Vector( 1u, 0.0 ) ) );
}
......@@ -178,7 +178,7 @@ VectorVector LineSource_PN::GetScatteringXS( const Vector& energies ) {
VectorVector LineSource_PN::GetTotalXS( const Vector& energies ) { return VectorVector( energies.size(), Vector( _mesh->GetNumCells(), _sigmaS ) ); }
std::vector<VectorVector> LineSource_PN::GetExternalSource( const Vector& energies ) {
std::vector<VectorVector> LineSource_PN::GetExternalSource( const Vector& /*energies*/ ) {
return std::vector<VectorVector>( 1u, std::vector<Vector>( _mesh->GetNumCells(), Vector( 1u, 0.0 ) ) );
}
......
......@@ -18,11 +18,11 @@ double Cubic2DSpline::operator()( double x, double y ) {
double points[4][4];
for( int i = -1; i < 3; ++i ) {
unsigned idx_y;
idx_y = yId + i < 0 ? 0 : yId + i;
idx_y = static_cast<int>( yId ) + i < 0 ? 0 : yId + i;
idx_y = yId + i > _data.rows() - 1 ? _data.rows() - 1 : yId + i;
for( int j = -1; j < 3; ++j ) {
unsigned idx_x;
idx_x = xId + j < 0 ? 0 : xId + j;
idx_x = static_cast<int>( xId ) + j < 0 ? 0 : xId + j;
idx_x = xId + j > _data.columns() - 1 ? _data.columns() - 1 : xId + j;
points[i + 1][j + 1] = _data( idx_x, idx_y );
......
#include "toolboxes/reconstructor.h"
Reconstructor::Reconstructor( Config* settings ) {}
Reconstructor::Reconstructor( Config* /*settings*/ ) {}
double FortSign( double a, double b ) {
if( b > 0.0 ) return abs( a );
......@@ -24,7 +24,7 @@ double LSuperBee( double sL, double sR ) {
double LVanAlbaba( double sL, double sR ) { return ( sL * sL * sR + sL * sR * sR ) / ( sL * sL + sR * sR + 0.0000001 ); }
double LWENOJS( double x ) { return 0.0; }
double LWENOJS( double /*x*/ ) { return 0.0; }
double Reconstructor::ReconstructSlopeStruct( double uL, double uC, double uR, double dxL, double dxR, std::string limiter ) const {
double sL = ( uC - uL ) / dxL;
......
#include <cstdio>
#include <vtkCellData.h>
#include <vtkSmartPointer.h>
#include <vtkUnstructuredGrid.h>
......@@ -31,15 +32,15 @@ std::vector<double> readVTKFile( std::string filename ) {
}
TEST_CASE( "checkerboard_SN", "[validation_tests]" ) {
std::string config_file_name = "../tests/input/checkerboard.cfg";
std::string config_file_name = std::string( TESTS_PATH ) + "input/checkerboard.cfg";
Config* config = new Config( config_file_name );
Solver* solver = Solver::Create( config );
solver->Solve();
solver->Save();
auto test = readVTKFile( "../result/rtsn_test_checkerboard.vtk" );
auto reference = readVTKFile( "../tests/input/checkerboard_reference.vtk" );
auto test = readVTKFile( std::string( TESTS_PATH ) + "../result/rtsn_test_checkerboard.vtk" );
auto reference = readVTKFile( std::string( TESTS_PATH ) + "input/checkerboard_reference.vtk" );
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
......@@ -49,15 +50,15 @@ TEST_CASE( "checkerboard_SN", "[validation_tests]" ) {
}
TEST_CASE( "linesource_SN", "[validation_tests]" ) {
std::string config_file_name = "../tests/input/linesource_SN.cfg";
std::string config_file_name = std::string( TESTS_PATH ) + "input/linesource_SN.cfg";
Config* config = new Config( config_file_name );
Solver* solver = Solver::Create( config );
solver->Solve();
solver->Save();
auto test = readVTKFile( "../result/rtsn_test_linesource_SN.vtk" );
auto reference = readVTKFile( "../tests/input/linesource_SN_reference.vtk" );
auto test = readVTKFile( std::string( TESTS_PATH ) + "../result/rtsn_test_linesource_SN.vtk" );
auto reference = readVTKFile( std::string( TESTS_PATH ) + "input/linesource_SN_reference.vtk" );
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
......@@ -67,15 +68,15 @@ TEST_CASE( "linesource_SN", "[validation_tests]" ) {
}
TEST_CASE( "linesource_PN", "[validation_tests]" ) {
char config_file_name[MAX_STRING_SIZE] = "../tests/input/linesource_PN.cfg";
std::string config_file_name = std::string( TESTS_PATH ) + "input/linesource_PN.cfg";
Config* config = new Config( config_file_name );
Solver* solver = Solver::Create( config );
solver->Solve();
solver->Save();
auto test = readVTKFile( "../result/rtsn_test_linesource_PN.vtk" );
auto reference = readVTKFile( "../tests/input/linesource_PN_reference.vtk" );
auto test = readVTKFile( std::string( TESTS_PATH ) + "../result/rtsn_test_linesource_PN.vtk" );
auto reference = readVTKFile( std::string( TESTS_PATH ) + "input/linesource_PN_reference.vtk" );
double eps = 1e-3;
......@@ -88,15 +89,15 @@ TEST_CASE( "linesource_PN", "[validation_tests]" ) {
TEST_CASE( "linesource_MN", "[validation_tests]" ) {
SECTION( "Quadratic Entropy" ) {
char config_file_name[MAX_STRING_SIZE] = "../tests/input/linesource_MN_Quad.cfg";
std::string config_file_name = std::string( TESTS_PATH ) + "input/linesource_MN_Quad.cfg";
Config* config = new Config( config_file_name );
Solver* solver = Solver::Create( config );
solver->Solve();
solver->Save();
auto test = readVTKFile( "../result/rtsn_test_linesource_MN_Quad.vtk" );
auto reference = readVTKFile( "../tests/input/linesource_MN_Quad_reference.vtk" );
auto test = readVTKFile( std::string( TESTS_PATH ) + "../result/rtsn_test_linesource_MN_Quad.vtk" );
auto reference = readVTKFile( std::string( TESTS_PATH ) + "input/linesource_MN_Quad_reference.vtk" );
double eps = 1e-3;
......@@ -107,15 +108,15 @@ TEST_CASE( "linesource_MN", "[validation_tests]" ) {
}
SECTION( "Maxwell Boltzmann Entropy" ) {
char config_file_name[MAX_STRING_SIZE] = "../tests/input/linesource_MN_MB.cfg";
std::string config_file_name = std::string( TESTS_PATH ) + "input/linesource_MN_MB.cfg";
Config* config = new Config( config_file_name );
Solver* solver = Solver::Create( config );
solver->Solve();
solver->Save();
auto test = readVTKFile( "../result/rtsn_test_linesource_MN_MB.vtk" );
auto reference = readVTKFile( "../tests/input/linesource_MN_MB_reference.vtk" );
auto test = readVTKFile( std::string( TESTS_PATH ) + "../result/rtsn_test_linesource_MN_MB.vtk" );
auto reference = readVTKFile( std::string( TESTS_PATH ) + "input/linesource_MN_MB_reference.vtk" );
double eps = 1e-3;
REQUIRE( test.size() == reference.size() );
......
......@@ -2,8 +2,7 @@
#include "common/config.h"
TEST_CASE( "Read in Config Template" ) {
char filename[] = "../tests/input/unit_config.cfg";
std::string filename = std::string( TESTS_PATH ) + "input/unit_config.cfg";
// Load Settings from File
Config* config = new Config( filename );
......
......@@ -8,19 +8,19 @@
#include <iostream>
#include <sstream>
double Y0_0( double my, double phi ) { return sqrt( 1 / ( 4 * M_PI ) ); }
double Y0_0( double, double ) { return sqrt( 1 / ( 4 * M_PI ) ); }
double Y1_m1( double my, double phi ) { return -sqrt( 3 / ( 4 * M_PI ) ) * sqrt( 1 - my * my ) * sin( phi ); }
double Y1_0( double my, double phi ) { return sqrt( 3 / ( 4 * M_PI ) ) * my; }
double Y1_0( double my, double /*phi*/ ) { return sqrt( 3 / ( 4 * M_PI ) ) * my; }
double Y1_1( double my, double phi ) { return -sqrt( 3 / ( 4 * M_PI ) ) * sqrt( 1 - my * my ) * cos( phi ); }
double Y2_m2( double my, double phi ) { return sqrt( 15 / ( 16 * M_PI ) ) * ( 1 - my * my ) * sin( 2 * phi ); }
double Y2_m1( double my, double phi ) { return -1 * sqrt( 15 / ( 4 * M_PI ) ) * my * sqrt( 1 - my * my ) * sin( phi ); }
double Y2_0( double my, double phi ) { return sqrt( 5 / ( 16 * M_PI ) ) * ( 3 * my * my - 1 ); }
double Y2_0( double my, double /*phi*/ ) { return sqrt( 5 / ( 16 * M_PI ) ) * ( 3 * my * my - 1 ); }
double Y2_1( double my, double phi ) { return -1 * sqrt( 15 / ( 4 * M_PI ) ) * my * sqrt( 1 - my * my ) * cos( phi ); }
double Y2_2( double my, double phi ) { return sqrt( 15 / ( 16 * M_PI ) ) * ( 1 - my * my ) * cos( 2 * phi ); }
double P0_0( double my ) { return sqrt( 1 / ( 2 * M_PI ) ); }
double P0_0( double /*my*/ ) { return sqrt( 1 / ( 2 * M_PI ) ); }
double P1_0( double my ) { return sqrt( 3 / ( 2 * M_PI ) ) * my; }
double P1_1( double my ) { return -sqrt( 3 / ( 4 * M_PI ) ) * sqrt( 1 - my * my ); }
......@@ -30,7 +30,7 @@ double P2_2( double my ) { return sqrt( 15 / ( 16 * M_PI ) ) * ( 1 - my * my );
TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmonics]" ) {
char filename[] = "../tests/input/unit_harmonics.cfg";
std::string filename = std::string( TESTS_PATH ) + "input/unit_harmonics.cfg";
// Load Settings from File
Config* config = new Config( filename );
......
......@@ -9,11 +9,11 @@
#include "toolboxes/textprocessingtoolbox.h"
TEST_CASE( "convert image data to grayscale matrix", "[image I/O]" ) {
std::string config_file_name = "../tests/input/image_conversion.cfg";
std::string config_file_name = std::string( TESTS_PATH ) + "input/image_conversion.cfg";
Config* config = new Config( config_file_name ); // just to init spdlog
std::string testImage = "../tests/input/phantom.png";
std::string testImage = std::string( TESTS_PATH ) + "input/phantom.png";
std::string testMesh = config->GetMeshFile();
Matrix gsImage = createSU2MeshFromImage( testImage, testMesh );
......@@ -25,7 +25,7 @@ TEST_CASE( "convert image data to grayscale matrix", "[image I/O]" ) {
REQUIRE( blaze::max( gsImage ) <= 1.0 ); // upper bound
// load reference matrix from csv file
std::string refMatrixFile = "../tests/input/phantom.csv";
std::string refMatrixFile = std::string( TESTS_PATH ) + "input/phantom.csv";
std::ifstream data( refMatrixFile );
REQUIRE( data.is_open() );
std::string line;
......
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