Commit 8bae28f8 authored by steffen.schotthoefer's avatar steffen.schotthoefer
Browse files

Merge branch 'compile_speedup' into 'master'

Compile speedup

Closes #82

See merge request !33
parents 66b4e207 48ceb815
Pipeline #121502 passed with stage
in 17 minutes and 4 seconds
......@@ -8,7 +8,7 @@ unit_tests:
script:
- git submodule update --init --recursive
- cd code/build/release
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ../../
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -Dbuild_tests=ON ../../
- ninja
- OMP_NUM_THREADS=1 ./unit_tests -r junit > unit_tests_report.xml
- gcovr -e ../../ext/ -e ../../tests/ -r ../../
......
cmake_minimum_required( VERSION 3.12.4 )
project( KiT-RT VERSION 0.1.0 LANGUAGES CXX )
### OPTIONS #####################################
option( build_tests "enables compiling of unit_tests" OFF )
#################################################
### COMPILER ####################################
set( CMAKE_CXX_STANDARD 17 )
......@@ -81,26 +84,27 @@ target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:RELEASE>:${KITR
### BUILD UNIT TESTS ############################
include( CTest )
set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/ext/Catch2/contrib ${CMAKE_MODULE_PATH} )
include( Catch )
set( CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/ext/Catch2/single_include/catch2 )
add_compile_definitions( BUILD_TESTING )
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" )
list( REMOVE_ITEM SRCS "src/main.cpp" )
add_executable( unit_tests ${TEST_SRCS} ${SRCS} ${EXT_SRCS} )
target_link_libraries( unit_tests Catch ${CORE_LIBRARIES} )
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:DEBUG>:${KITRT_DEBUG_OPTIONS}>" )
if( CMAKE_COMPILER_IS_GNUCXX )
set( CODE_COVERAGE_OPTIONS --coverage -g -O0 -w )
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:DEBUG>:${CODE_COVERAGE_OPTIONS}>" )
target_link_libraries( unit_tests Catch gcov )
if( build_tests )
include( CTest )
set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/ext/Catch2/contrib ${CMAKE_MODULE_PATH} )
include( Catch )
set( CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/ext/Catch2/single_include/catch2 )
add_compile_definitions( BUILD_TESTING )
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" )
list( REMOVE_ITEM SRCS "src/main.cpp" )
add_executable( unit_tests ${TEST_SRCS} ${SRCS} ${EXT_SRCS} )
target_link_libraries( unit_tests Catch ${CORE_LIBRARIES} )
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:DEBUG>:${KITRT_DEBUG_OPTIONS}>" )
if( CMAKE_COMPILER_IS_GNUCXX )
set( CODE_COVERAGE_OPTIONS --coverage -g -O0 -w )
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:DEBUG>:${CODE_COVERAGE_OPTIONS}>" )
target_link_libraries( unit_tests Catch gcov )
endif()
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:RELWITHDEBINFO>:${KITRT_RELWITHDEBINFO_OPTIONS}>" )
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:RELEASE>:${KITRT_RELEASE_OPTIONS}>" )
catch_discover_tests( unit_tests )
endif()
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:RELWITHDEBINFO>:${KITRT_RELWITHDEBINFO_OPTIONS}>" )
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:RELEASE>:${KITRT_RELEASE_OPTIONS}>" )
catch_discover_tests( unit_tests )
enable_testing()
#################################################
......@@ -22,7 +22,7 @@ class OptionBase
std::vector<std::string> _value; /*! @brief: String name of the option */
public:
OptionBase(){};
OptionBase() {}
virtual ~OptionBase() = 0;
virtual std::string SetValue( std::vector<std::string> value ); /*! @brief: Set string name of the option */
......@@ -45,7 +45,7 @@ class OptionDouble : public OptionBase
public:
OptionDouble( std::string option_field_name, double& option_field, double default_value );
~OptionDouble() override{};
~OptionDouble() override {}
std::string SetValue( std::vector<std::string> option_value ) override;
......@@ -61,7 +61,7 @@ class OptionString : public OptionBase
public:
OptionString( std::string option_field_name, std::string& option_field, std::string default_value );
~OptionString() override{};
~OptionString() override {}
std::string SetValue( std::vector<std::string> option_value ) override;
......@@ -77,7 +77,7 @@ class OptionInt : public OptionBase
public:
OptionInt( std::string option_field_name, int& option_field, int default_value );
~OptionInt() override{};
~OptionInt() override {}
std::string SetValue( std::vector<std::string> option_value ) override;
......@@ -93,7 +93,7 @@ class OptionULong : public OptionBase
public:
OptionULong( std::string option_field_name, unsigned long& option_field, unsigned long default_value );
~OptionULong() override{};
~OptionULong() override {}
std::string SetValue( std::vector<std::string> option_value ) override;
......@@ -109,7 +109,7 @@ class OptionUShort : public OptionBase
public:
OptionUShort( std::string option_field_name, unsigned short& option_field, unsigned short default_value );
~OptionUShort() override{};
~OptionUShort() override {}
std::string SetValue( std::vector<std::string> option_value ) override;
......@@ -125,7 +125,7 @@ class OptionLong : public OptionBase
public:
OptionLong( std::string option_field_name, long& option_field, long default_value );
~OptionLong() override{};
~OptionLong() override {}
std::string SetValue( std::vector<std::string> option_value ) override;
......@@ -141,7 +141,7 @@ class OptionBool : public OptionBase
public:
OptionBool( std::string option_field_name, bool& option_field, bool default_value );
~OptionBool() override{};
~OptionBool() override {}
std::string SetValue( std::vector<std::string> option_value ) override;
......@@ -157,7 +157,7 @@ class OptionStringList : public OptionBase
public:
OptionStringList( std::string option_field_name, unsigned short& list_size, std::vector<std::string>& option_field );
~OptionStringList() override{};
~OptionStringList() override {}
std::string SetValue( std::vector<std::string> option_value ) override;
......
......@@ -5,6 +5,7 @@
* Disclaimer: This is copied from the code distributed with the ICRU 77 report
* Link: https://icru.org/home/reports/elastic-scattering-of-electrons-and-positrons-icru-report-77
*/
#ifndef ICRU_H
#define ICRU_H
......
/*! @file: qproduct.h
* @brief: Product quadrature implementation. Implementation is done accordingly to Kendall Atkinson 1981, Australian Matematical Society.
* @author: J. Kusch
*/
#ifndef PRODUCTQUADRATURE_H
#define PRODUCTQUADRATURE_H
#include "quadraturebase.h"
class ProductQuadrature : public QuadratureBase
class QProduct : public QuadratureBase
{
// Implementation is done accordingly to Kendall Atkinson 1981, Australian Matematical Society.
private:
double Pythag( const double a, const double b );
std::pair<Vector, Matrix> ComputeEigenValTriDiagMatrix( const Matrix& mat );
bool CheckOrder();
public:
ProductQuadrature( Config* settings );
ProductQuadrature( unsigned order );
QProduct( Config* settings );
QProduct( unsigned order );
virtual ~ProductQuadrature() {}
virtual ~QProduct() {}
inline void SetName() override { _name = "Product quadrature"; }
inline void SetNq() override { _nq = 4 * pow( GetOrder(), 2 ); }
......
/*! @file: quadraturebase.h
* @brief: Base class for all quadrature rules in KiT-RT
* @author: S. Schotthöfer
*/
#ifndef QUADRATURE_H
#define QUADRATURE_H
......@@ -9,8 +14,13 @@ class Config;
class QuadratureBase
{
public:
/*! @brief: Constructor using settings class. This is the recommended constructor.
* @param: Config* settings: Settings class storing all important options.
*/
QuadratureBase( Config* settings );
QuadratureBase( unsigned order ); // Only for productquadrature... refactor this!
/*! @brief: Constructor using directly the order of the quadrature. Not applicable for GaussLegendre, that need additional options.
It sets member _settings = nulltpr.*/
QuadratureBase( unsigned order );
virtual ~QuadratureBase() {}
// Aux functions
......@@ -37,13 +47,13 @@ class QuadratureBase
/*! @brief Creates a quadrature rule with a given name and a given order.
* @param: Config* settings: Settings to handle quadrature options
* @returns Quadrature* quadrature: returns pointer to instance of the given derived quadrature class */
static QuadratureBase* CreateQuadrature( Config* settings );
static QuadratureBase* Create( Config* settings );
/*! @brief Creates a quadrature rule with a given name and a given order.
* @param: name: name of quadrature as enum
* @param: quadOrder: order of quadrature
* @returns Quadrature* quadrature: returns pointer to instance of the given derived quadrature class */
static QuadratureBase* CreateQuadrature( QUAD_NAME name, unsigned quadOrder );
static QuadratureBase* Create( QUAD_NAME name, unsigned quadOrder );
// Getter
inline std::string GetName() const { return _name; } /*! @returns std::string _name: name of the quadrature */
......
#ifndef CSDSNSOLVER_H
#define CSDSNSOLVER_H
#include "icru.h"
#include "solvers/snsolver.h"
class CSDSNSolver : public SNSolver
......
#ifndef CSDSNSOLVERFP_H
#define CSDSNSOLVERFP_H
#include "icru.h"
#include "solvers/snsolver.h"
class Physics;
......@@ -22,9 +21,9 @@ class CSDSNSolverFP : public SNSolver
Matrix _IL; /*! @brief Laplace Beltrami Matrix */
double _alpha; /*! @brief Coefficient of GFP operators (see Olbrant 2010, eq. (8)*/
double _beta; /*! @brief Coefficient of GFP operators (see Olbrant 2010, eq. (8)*/
double _beta; /*! @brief Coefficient of GFP operators (see Olbrant 2010, eq. (8)*/
Matrix _xi; /*! @brief matrix of transport coefficients */
Matrix _xi; /*! @brief matrix of transport coefficients */
bool _RT; /*! @brief radiotherapy application (on/off), if true use crosssections + stopping powers from database */
......
#ifndef CSDSNSOLVERNOTRAFO_H
#define CSDSNSOLVERNOTRAFO_H
#include "icru.h"
#include "solvers/snsolver.h"
class Physics;
......
#ifndef CSDSOLVERTRAFOFP_H
#define CSDSOLVERTRAFOFP_H
#include "icru.h"
#include "solvers/snsolver.h"
class Physics;
......@@ -21,15 +20,16 @@ class CSDSolverTrafoFP : public SNSolver
Matrix _L; /*! @brief Laplace Beltrami Matrix */
Matrix _IL; /*! @brief Laplace Beltrami Matrix */
double _alpha; /*! @brief Coefficient of GFP operators (see Olbrant 2010, Appendix B)*/
double _alpha; /*! @brief Coefficient of GFP operators (see Olbrant 2010, Appendix B)*/
double _alpha2; /*! @brief Coefficient of GFP operators (see Olbrant 2010, Appendix B)*/
double _beta; /*! @brief Coefficient of GFP operators (see Olbrant 2010, Appendix B)*/
double _beta; /*! @brief Coefficient of GFP operators (see Olbrant 2010, Appendix B)*/
Matrix _xi; /*! @brief matrix of transport coefficients */
Matrix _xi; /*! @brief matrix of transport coefficients */
Vector _xi1;
Vector _xi2;
unsigned _FPMethod; /*! @brief Encodes different ways of computing coefficients alpha, alpha2 & beta, _FPMethod == 1, 2 ,3 stand for methods with increasing accuracy (see Olbrant 2010, Appendix B)*/
unsigned _FPMethod; /*! @brief Encodes different ways of computing coefficients alpha, alpha2 & beta, _FPMethod == 1, 2 ,3 stand for methods with
increasing accuracy (see Olbrant 2010, Appendix B)*/
bool _RT; /*! @brief radiotherapy application (on/off), if true use crosssections + stopping powers from database */
......
#ifndef CSDSOLVERTRAFOFP2D_H
#define CSDSOLVERTRAFOFP2D_H
#include "icru.h"
#include "solvers/snsolver.h"
class Physics;
......
......@@ -8,12 +8,11 @@
#include "common/config.h"
#include "common/io.h"
#include "fluxes/numericalflux.h"
#include "icru.h"
#include "kernels/scatteringkernelbase.h"
#include "problems/problembase.h"
#include "quadratures/quadraturebase.h"
#include "solvers/snsolver.h"
#include "sphericalharmonics.h"
#include "toolboxes/sphericalharmonics.h"
class Physics;
......
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Checkerboard Benchmarking File SN %
% Author <Jonas Kusch> %
% Date 01.12.2020 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
OUTPUT_DIR = ../result
OUTPUT_FILE = example_csd_1d_10MeV_fine
LOG_DIR = ../result/logs
......
......@@ -16,7 +16,6 @@
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_sinks.h"
#include "spdlog/spdlog.h"
#include <cassert>
#include <filesystem>
#include <fstream>
#include <mpi.h>
......@@ -74,6 +73,12 @@ Config::Config( string case_filename ) {
Config::~Config( void ) {
// Delete all introduced arrays!
// delete _option map values proberly
for( auto const& x : _optionMap ) {
delete x.second;
_optionMap.erase( x.first );
}
}
// ---- Add Options ----
......@@ -493,6 +498,11 @@ void Config::SetPostprocessing() {
CURRENT_FUNCTION );
}
break;
case CSD_SN_NOTRAFO_SOLVER:
case CSD_SN_FOKKERPLANCK_SOLVER:
case CSD_SN_FOKKERPLANCK_TRAFO_SOLVER:
case CSD_SN_FOKKERPLANCK_TRAFO_SOLVER_2D:
case CSD_SN_FOKKERPLANCK_TRAFO_SH_SOLVER_2D:
case CSD_SN_SOLVER:
supportedGroups = { MINIMAL, DOSE };
if( supportedGroups.end() == std::find( supportedGroups.begin(), supportedGroups.end(), _volumeOutput[idx_volOutput] ) ) {
......
/*! @file: main.cpp
* @brief: Main method to call the KiT-RT solver suite
* @author: J. Kusch, S. Schotthöfer, P. Stammer, J. Wolters, T. Xiao
* @version: 0.1
*/
#include <Python.h>
#include <mpi.h>
#include <string>
#include "common/config.h"
#include "common/io.h"
#include "solvers/solverbase.h"
#include "common/config.h"
#include "solvers/sphericalharmonics.h"
#include <fstream>
#include <iostream>
#include <string>
// ----
#include "optimizers/optimizerbase.h"
#include "quadratures/qgausslegendretensorized.h"
#include "quadratures/qmontecarlo.h"
#include "solvers/sphericalharmonics.h"
double testFunc( double my, double phi ) { return my * my + phi; }
double testFunc2( double x, double y, double z ) { return x + y + z; }
int main( int argc, char** argv ) {
MPI_Init( &argc, &argv );
wchar_t* program = Py_DecodeLocale( argv[0], NULL );
......
......@@ -6,7 +6,7 @@
#include "toolboxes/errormessages.h"
NewtonOptimizer::NewtonOptimizer( Config* settings ) : OptimizerBase( settings ) {
_quadrature = QuadratureBase::CreateQuadrature( settings );
_quadrature = QuadratureBase::Create( settings );
_nq = _quadrature->GetNq();
_weights = _quadrature->GetWeights();
_quadPointsSphere = _quadrature->GetPointsSphere();
......
......@@ -27,7 +27,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 ) {
......@@ -91,7 +91,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 ) {
......
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