diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7743c8b83096cc8fefc053d789188ade3f8384fe..75e883e505e248ef333c80f688e7dad2f2a519cc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ unit_tests: script: - git submodule update --init --recursive - cd code/build/debug - - cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON ../../ + - cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DBUILD_CODE_COV=ON ../../ - ninja - OMP_NUM_THREADS=1 ./unit_tests -r junit > unit_tests_report.xml - gcovr -e ../../ext/ -e ../../tests/ -r ../../ diff --git a/.gitmodules b/.gitmodules index a55e5ce3bc535e9e2101fba4b087ed8a490be97d..74d819bf6e2977a97e3aa5dc19c0500019a72bbe 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,3 @@ [submodule "code/ext/blaze"] path = code/ext/blaze url = https://bitbucket.org/blaze-lib/blaze.git -[submodule "code/ext/parmetis"] - path = code/ext/parmetis - url = https://github.com/slydex/parmetis.git -[submodule "code/ext/neuralEntropy"] - path = code/ext/neuralEntropy - url = https://github.com/ScSteffen/neuralEntropy.git diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 2d787c89ade68260e49e9a981847433e81ae4686..4b8ed4ea2d800adb357ad5006f7569588ccd2d1e 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1,10 +1,12 @@ -cmake_minimum_required( VERSION 3.12.4 ) +cmake_minimum_required( VERSION 3.16 ) project( KiT-RT VERSION 0.1.0 LANGUAGES CXX ) ### OPTIONS ##################################### -option( BUILD_TESTS "builds all available unit tests" OFF ) +option( BUILD_TESTING "builds all available unit tests" OFF ) option( BUILD_GUI "additionally builds a user interface" OFF ) option( BUILD_DOC "builds Doxygen and Sphinx documentation" OFF ) +option( BUILD_UNITY "enables unity build for faster compile times" ON ) +option( BUILD_CODE_COV "enables compiler option required for code coverage analysis" OFF ) ################################################# @@ -14,6 +16,11 @@ set( CMAKE_CXX_STANDARD_REQUIRED ON ) set( KITRT_RELEASE_OPTIONS -march=native -w ) set( KITRT_RELWITHDEBINFO_OPTIONS -march=native -pg -no-pie ) set( KITRT_DEBUG_OPTIONS -Wall -Wextra -Wpedantic ) +if( BUILD_UNITY AND NOT BUILD_CODE_COV ) + message( STATUS "Unity build enabled" ) + set( CMAKE_UNITY_BUILD ON ) + set( CMAKE_UNITY_BUILD_BATCH_SIZE 0 ) +endif() ################################################# @@ -49,17 +56,10 @@ endif() include( blaze-cache-config ) include_directories( ${CMAKE_SOURCE_DIR}/ext/blaze ) -add_compile_definitions( METIS_EXPORT= ) -set( DISABLE_PARMETIS_PROGRAMS ON ) -set( ParMETIS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ext/parmetis ) -include_directories( ${ParMETIS_PATH}/include ) -include_directories( ${ParMETIS_PATH}/metis/include ) -add_subdirectory( ${ParMETIS_PATH} ) - include_directories( ${CMAKE_SOURCE_DIR}/ext/cpptoml/include ) include_directories( ${CMAKE_SOURCE_DIR}/ext/spdlog/include ) -set( CORE_LIBRARIES ${Python3_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MPI_LIBRARIES} ${VTK_LIBRARIES} OpenMP::OpenMP_CXX parmetis -lstdc++fs ) +set( CORE_LIBRARIES ${Python3_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MPI_LIBRARIES} ${VTK_LIBRARIES} OpenMP::OpenMP_CXX -lstdc++fs ) ################################################# @@ -94,7 +94,7 @@ target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$:${KITR ### BUILD UNIT TESTS ############################ -if( BUILD_TESTS ) +if( BUILD_TESTING ) include( CTest ) set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/ext/Catch2/contrib ${CMAKE_MODULE_PATH} ) include( Catch ) @@ -110,10 +110,16 @@ if( BUILD_TESTS ) target_compile_definitions( unit_tests PUBLIC TESTS_PATH="${CMAKE_SOURCE_DIR}/tests/" ) target_link_libraries( unit_tests Catch ${CORE_LIBRARIES} ) target_compile_options( unit_tests PUBLIC "$<$:${KITRT_DEBUG_OPTIONS}>" ) - if( CMAKE_COMPILER_IS_GNUCXX ) - set( CODE_COVERAGE_OPTIONS --coverage -g -O0 -w ) - target_compile_options( unit_tests PUBLIC "$<$:${CODE_COVERAGE_OPTIONS}>" ) - target_link_libraries( unit_tests Catch gcov ) + if( BUILD_CODE_COV ) + if( CMAKE_COMPILER_IS_GNUCXX ) + set( CODE_COVERAGE_OPTIONS --coverage -g -O0 -w ) + target_compile_options( unit_tests PUBLIC "$<$:${CODE_COVERAGE_OPTIONS}>" ) + target_link_libraries( unit_tests Catch gcov ) + else() + message( FATAL_ERROR "Code coverage is currently only supported for gcc!" ) + endif() + else() + target_link_libraries( unit_tests Catch ) endif() target_compile_options( unit_tests PUBLIC "$<$:${KITRT_RELWITHDEBINFO_OPTIONS}>" ) target_compile_options( unit_tests PUBLIC "$<$:${KITRT_RELEASE_OPTIONS}>" ) @@ -153,7 +159,7 @@ if( BUILD_DOC ) set( DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR} ) set( DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/docs/doxygen ) - set( DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/html/index.html ) + set( DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml ) set( DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/../doc/Doxyfile.in ) set( DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ) configure_file( ${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY ) diff --git a/code/ext/Catch2 b/code/ext/Catch2 index 0e9bae1cdb5d7bcd967bcab10539805cc3bccb32..e8cdfdca87ebacd993befdd08ea6aa7e8068ef3d 160000 --- a/code/ext/Catch2 +++ b/code/ext/Catch2 @@ -1 +1 @@ -Subproject commit 0e9bae1cdb5d7bcd967bcab10539805cc3bccb32 +Subproject commit e8cdfdca87ebacd993befdd08ea6aa7e8068ef3d diff --git a/code/ext/neuralEntropy b/code/ext/neuralEntropy deleted file mode 160000 index e1eab3b76738638e7db7a5f2bd62e72c923c717a..0000000000000000000000000000000000000000 --- a/code/ext/neuralEntropy +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e1eab3b76738638e7db7a5f2bd62e72c923c717a diff --git a/code/ext/parmetis b/code/ext/parmetis deleted file mode 160000 index 263c94a262be616484b0bbeb33a6677411f25fbb..0000000000000000000000000000000000000000 --- a/code/ext/parmetis +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 263c94a262be616484b0bbeb33a6677411f25fbb diff --git a/code/include/common/config.h b/code/include/common/config.h index afc0718df10f54722c72cce7897c8d1a4a60b001..420b1430a8207b270e31c9f30cd7c8152737727c 100644 --- a/code/include/common/config.h +++ b/code/include/common/config.h @@ -1,6 +1,6 @@ /*! * @file config.h - * @brief: Class to handle all options and their pre and postprocessing. + * @brief Class to handle all options and their pre and postprocessing. * DO NOT CREATE SETTERS FOR THIS CLASS! ALL OPTIONS ARE CONSTANT (after SetPostprocessing). * * @author S. Schotthöfer @@ -27,7 +27,7 @@ class OptionBase; class Config { private: - std::string _fileName; /*!< @rief Name of the current file without extension */ + std::string _fileName; /*!< @brief Name of the current file without extension */ bool _baseConfig; // int _commRank, _commSize; /*!< @brief MPI rank and size.*/ // Not yet used!! @@ -48,8 +48,8 @@ class Config unsigned _nQuadPoints; // Mesh - unsigned _nCells; /*!< @brief: Number of cells in the mesh */ - unsigned short _dim; /*!< @brief: spatial dimensionality of the mesh/test case */ + unsigned _nCells; /*!< @brief Number of cells in the mesh */ + unsigned short _dim; /*!< @brief spatial dimensionality of the mesh/test case */ // Boundary Conditions /*!< @brief List of all Pairs (marker, BOUNDARY_TYPE), e.g. (farfield,DIRICHLET). @@ -95,7 +95,7 @@ class Config KERNEL_NAME _kernelName; /*!< @brief Scattering Kernel Name*/ // Spherical Basis - SPHERICAL_BASIS_NAME _sphericalBasisName; /*!< @brief: Name of the basis on the unit sphere */ + SPHERICAL_BASIS_NAME _sphericalBasisName; /*!< @brief Name of the basis on the unit sphere */ // Optimizer OPTIMIZER_NAME _entropyOptimizerName; /*!< @brief Choice of optimizer */ @@ -106,7 +106,7 @@ class Config bool _newtonFastMode; /*!< @brief If true, we skip the NewtonOptimizer for quadratic entropy and assign alpha = u */ // NeuralModel - unsigned short _neuralModel; /*!< @brief: Version number of the employed neural model */ + unsigned short _neuralModel; /*!< @brief Version number of the employed neural model */ // Output Options unsigned short _nVolumeOutput; /*!< @brief Number of volume outputs */ std::vector _volumeOutput; /*!< @brief Output groups for volume output*/ @@ -125,8 +125,11 @@ class Config bool _dataGeneratorMode; unsigned long _tainingSetSize; /*!< @brief Size of training data set for data generator */ unsigned long _maxValFirstMoment; /*!< @brief Size of training data set for data generator */ - double _RealizableSetEpsilonU0; /*! @brief Distance to 0 of the sampled moments to the boundary of the realizable set */ - double _RealizableSetEpsilonU1; /*!< @brief: norm(u_1)/u_0 !< _RealizableSetEpsilonU1 */ + double _RealizableSetEpsilonU0; /*!< @brief Distance to 0 of the sampled moments to the boundary of the realizable set */ + double _RealizableSetEpsilonU1; /*!< @brief norm(u_1)/u_0 !< _RealizableSetEpsilonU1 */ + bool _normalizedSampling; /*!< @brief Flag for sampling of normalized moments, i.e. u_0 =1 */ + bool _alphaSampling; /*!< @brief Flag for sampling alpha instead of u */ + bool _realizabilityRecons; /*!< @brief Turns realizability reconstruction on/off for u sampling */ // --- Parsing Functionality and Initializing of Options --- /*! @@ -162,9 +165,9 @@ class Config /*! * @brief breaks an input line from the config file into a set of tokens - * @param[in] str - the input line string - * @param[out] option_name - the name of the option found at the beginning of the line - * @param[out] option_value - the tokens found after the "=" sign on the line + * @param str the input line string + * @param option_name the name of the option found at the beginning of the line + * @param option_value the tokens found after the "=" sign on the line * @return false if the line is empty or a commment, true otherwise */ bool TokenizeString( std::string& str, std::string& option_name, std::vector& option_value ); @@ -298,7 +301,7 @@ class Config unsigned short inline GetNeuralModel() { return _neuralModel; } // Boundary Conditions - BOUNDARY_TYPE GetBoundaryType( std::string nameMarker ) const; /*! @brief Get Boundary Type of given marker */ + BOUNDARY_TYPE GetBoundaryType( std::string nameMarker ) const; /*!< @brief Get Boundary Type of given marker */ // Scattering Kernel KERNEL_NAME inline GetKernelName() const { return _kernelName; } @@ -324,14 +327,19 @@ class Config unsigned long inline GetMaxValFirstMoment() { return _maxValFirstMoment; } double GetRealizableSetEpsilonU0() { return _RealizableSetEpsilonU0; } double GetRealizableSetEpsilonU1() { return _RealizableSetEpsilonU1; } + bool inline GetNormalizedSampling() { return _normalizedSampling; } + bool inline GetAlphaSampling() { return _alphaSampling; } + bool inline GetRelizabilityReconsU() { return _realizabilityRecons; } // ---- Setters for option structure // This section is dangerous // Quadrature Structure - void SetNQuadPoints( unsigned nq ) { _nQuadPoints = nq; } /*! @brief Never change the nq! This is only for the test framework. */ - void SetQuadName( QUAD_NAME quadName ) { _quadName = quadName; } /*! @brief Never change the quadName! This is only for the test framework. */ - void SetQuadOrder( unsigned quadOrder ) { _quadOrder = quadOrder; } /*! @brief Never change the quadOrder! This is only for the test framework. */ - void SetSNAllGaussPts( bool useall ) { _allGaussPts = useall; } /*! @brief Never change the this! This is only for the test framework. */ + void SetNQuadPoints( unsigned nq ) { _nQuadPoints = nq; } /*!< @brief Never change the nq! This is only for the test framework. */ + void SetQuadName( QUAD_NAME quadName ) { _quadName = quadName; } /*!< @brief Never change the quadName! This is only for the test framework. */ + void SetQuadOrder( unsigned quadOrder ) { + _quadOrder = quadOrder; + } /*!< @brief Never change the quadOrder! This is only for the test framework. */ + void SetSNAllGaussPts( bool useall ) { _allGaussPts = useall; } /*!< @brief Never change the this! This is only for the test framework. */ // Mesh Structure void SetNCells( unsigned nCells ) { _nCells = nCells; } }; diff --git a/code/include/common/globalconstants.h b/code/include/common/globalconstants.h index f3df7983a6601b14125b00c9e488d06538fdeb08..f1fdb179f1ec35b112799f079a436692e7cc5a92 100644 --- a/code/include/common/globalconstants.h +++ b/code/include/common/globalconstants.h @@ -1,7 +1,6 @@ /*! - * \file GlobalConstants.h + * \file globalconstants.h * \brief All global defined (physical) constants, enums etc - * \author * \version 0.0 * */ @@ -59,6 +58,7 @@ enum QUAD_NAME { QUAD_MonteCarlo, QUAD_GaussLegendreTensorized, QUAD_GaussLegendre1D, + QUAD_GaussLegendreTensorized2D, QUAD_LevelSymmetric, QUAD_Lebedev, QUAD_LDFESA, diff --git a/code/include/common/io.h b/code/include/common/io.h index 45608232666dcef2137446404309189ff98ccaee..1f5153ef610416f837f47d09f94ec8f1558350ab 100644 --- a/code/include/common/io.h +++ b/code/include/common/io.h @@ -9,11 +9,11 @@ class Config; class Mesh; -/*! @brief: Function to export solver Volume output to VTK file. - * @param: filename: Filename of output file - * @param: outputFields: numerical output of the solver. Dimensions: (OutputGroupSize, OutputFieldSize, NumberMeshCells) - * @param: outputFieldNames: names of the outputfields. Dimensions: (OutputGroupSize, OutputFieldSize) - * @param: mesh: Mesh with cells (the mesh used for the computation) +/*! @brief Function to export solver Volume output to VTK file. + * @param fileName Filename of output file + * @param outputFields numerical output of the solver. Dimensions: (OutputGroupSize, OutputFieldSize, NumberMeshCells) + * @param outputFieldNames names of the outputfields. Dimensions: (OutputGroupSize, OutputFieldSize) + * @param mesh Mesh with cells (the mesh used for the computation) */ void ExportVTK( const std::string fileName, const std::vector>>& outputFields, diff --git a/code/include/common/mesh.h b/code/include/common/mesh.h index 0de9c637ada4ecc4d67aebda40e3d526fce4d4d3..bfd0c156cbac1015d4d90e874486d161a2a34a7d 100644 --- a/code/include/common/mesh.h +++ b/code/include/common/mesh.h @@ -10,59 +10,55 @@ #include #include -#include "metis.h" -#include "parmetis.h" #include "toolboxes/errormessages.h" #include "toolboxes/reconstructor.h" class Mesh { protected: - const unsigned _dim; /*! @brief: spatial dimension of the mesh, i.e. 1D,2D,3D */ - const unsigned _numCells; /*! @brief: number of cells in the mesh */ - const unsigned _numNodes; /*! @brief: number of nodes in the mesh (for node centered view)*/ - const unsigned _numNodesPerCell; /*! @brief: number of nodes per cell */ - const unsigned _numBoundaries; /*! @brief: number of boundary cells in the mesh */ - const unsigned _ghostCellID; /*! @brief: Id of the ghost cell. (we use only one ghost cell). equal to _numCells and therefore has the ID of the + const unsigned _dim; /*!< @brief spatial dimension of the mesh, i.e. 1D,2D,3D */ + const unsigned _numCells; /*!< @brief number of cells in the mesh */ + const unsigned _numNodes; /*!< @brief number of nodes in the mesh (for node centered view)*/ + const unsigned _numNodesPerCell; /*!< @brief number of nodes per cell */ + const unsigned _numBoundaries; /*!< @brief number of boundary cells in the mesh */ + const unsigned _ghostCellID; /*!< @brief Id of the ghost cell. (we use only one ghost cell). equal to _numCells and therefore has the ID of the last cell + 1 */ unsigned _numNodesPerBoundary; std::vector> _bounds; // ??? - std::vector _nodes; /*! @brief: nodes in the mesh. dimension:_numNodes<_dim> */ - std::vector> _cells; /*! @brief: cells in the mesh. dimension:_numCells<_numNodesPerCell> */ + std::vector _nodes; /*!< @brief nodes in the mesh. dimension:_numNodes<_dim> */ + std::vector> _cells; /*!< @brief cells in the mesh. dimension:_numCells<_numNodesPerCell> */ - /*! @brief: boundary cells in the mesh. Pair defines boundary type of the boundary nodes of the cell. numBoundaries<(1,numBoundaryNodes)>*/ + /*! @brief boundary cells in the mesh. Pair defines boundary type of the boundary nodes of the cell. numBoundaries<(1,numBoundaryNodes)>*/ std::vector>> _boundaries; - std::vector _cellAreas; /*! @brief: cell areas of the mesh. dimension: numCells*/ - std::vector _cellMidPoints; /*! @brief: cell midpoints of the mesh. dimension: numCells*/ - std::vector> _cellNeighbors; /*! @brief: neighbors of each cell. dimension: numCells*/ + std::vector _cellAreas; /*!< @brief cell areas of the mesh. dimension: numCells*/ + std::vector _cellMidPoints; /*!< @brief cell midpoints of the mesh. dimension: numCells*/ + std::vector> _cellNeighbors; /*!< @brief neighbors of each cell. dimension: numCells*/ - /*! @brief: outward facing normals of each side of each cell. dimension: numCells>, all + /*! @brief outward facing normals of each side of each cell. dimension: numCells>, all normals are facing away from the cell center, and scaled with the edge length */ std::vector> _cellNormals; - /*! @brief: Tags each cell with its boundary type. None means no boundary. dimension: numCells */ + /*! @brief Tags each cell with its boundary type. None means no boundary. dimension: numCells */ std::vector _cellBoundaryTypes; - std::vector _colors; /*! @brief: Color of each cell (for MPI mesh partitioning). dimension: numCells */ - blaze::CompressedMatrix _nodeNeighbors; /*! @brief: neighborshood relationship of nodes for (par-)metis */ + blaze::CompressedMatrix _nodeNeighbors; /*!< @brief neighborshood relationship of nodes for (par-)metis */ - void ComputeCellAreas(); /*! @brief: Computes only the areas of the mesh cells. Write to _cellAreas. */ - void ComputeCellMidpoints(); /*! @brief: Compute only the midpoints of the cells. Write to _cellMidPoints*/ - void ComputeConnectivity(); /*! @brief: Computes _cellNeighbors and _nodeNeighbors, i.e. neighborship relation in mesh*/ - void ComputePartitioning(); /*! @brief: Computes local partitioning for openMP */ + void ComputeCellAreas(); /*!< @brief Computes only the areas of the mesh cells. Write to _cellAreas. */ + void ComputeCellMidpoints(); /*!< @brief Compute only the midpoints of the cells. Write to _cellMidPoints*/ + void ComputeConnectivity(); /*!< @brief Computes _cellNeighbors and _nodeNeighbors, i.e. neighborship relation in mesh*/ - /*! @brief: Computes outward facing normal of two neighboring nodes nodeA and nodeB with common cellCellcenter. + /*! @brief Computes outward facing normal of two neighboring nodes nodeA and nodeB with common cellCellcenter. * Normals are scaled with their respective edge length - * @param: nodeA: first node - * @param: nodeB: neighboring node to nodeA - * @param: cellCenter: Center of the cell that has nodeA and nodeB as nodes. - * @return: outward facing normal */ + * @param nodeA: first node + * @param nodeB: neighboring node to nodeA + * @param cellCenter: Center of the cell that has nodeA and nodeB as nodes. + * @return outward facing normal */ Vector ComputeOutwardFacingNormal( const Vector& nodeA, const Vector& nodeB, const Vector& cellCenter ); - void ComputeBounds(); /*! @brief: Computes the spatial bounds of a 2D domain. */ + void ComputeBounds(); /*!< @brief Computes the spatial bounds of a 2D domain. */ public: Mesh() = delete; // no default constructor - /*! @brief: Constructor of mesh. Needs nodes, cells, and boundary descriptions as specified above. + /*! @brief Constructor of mesh. Needs nodes, cells, and boundary descriptions as specified above. * See LoadSU2MeshFromFile in io.cpp for setup information*/ Mesh( std::vector nodes, std::vector> cells, @@ -74,8 +70,8 @@ class Mesh inline unsigned GetNumNodes() const { return _numNodes; } inline unsigned GetNumNodesPerCell() const { return _numNodesPerCell; } - /*! @brief: Returns all node coordinates - * @return: dimension: numNodes x dim */ + /*! @brief Returns all node coordinates + * @return dimension: numNodes x dim */ const std::vector& GetNodes() const; /*! @brief Returns the mid point coordinates of each cell @@ -90,10 +86,6 @@ class Mesh * @return dimension: numCells */ const std::vector& GetCellAreas() const; - /*! @brief Return the color/ID of the mesh partition - * @return dimension: numCells */ - const std::vector& GetPartitionIDs() const; - /*! @brief Returns the neighbor cell IDs for every cell * @return dimension: numCells x numNodes */ const std::vector>& GetNeighbours() const; @@ -122,13 +114,13 @@ class Mesh // Not used void ComputeSlopes( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerY, const VectorVector& psi ) const; - /*! @brief:Structured mesh slope reconstruction with flux limiters. + /*! @brief Structured mesh slope reconstruction with flux limiters. * @param nq is number of quadrature points * @param psiDerX is slope in x direction (gets computed. Slope is stored here) * @param psiDerY is slope in y direction (gets computed. Slope is stored here) * @param psi is solution for which slope is computed */ void ReconstructSlopesS( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerY, const VectorVector& psi ) const; - /*! @brief: Use gauss theorem and limiters. For unstructured mesh * + /*! @brief Use gauss theorem and limiters. For unstructured mesh * * @param nq is number of quadrature points * @param psiDerX is slope in x direction (gets computed. Slope is stored here) * @param psiDerY is slope in y direction (gets computed. Slope is stored here) diff --git a/code/include/common/optionstructure.h b/code/include/common/optionstructure.h index fd588bdc35ea2c0876fa616821907cd84619f582..70db632063bb3b4dafa956e7abc2a4bf7e14fd19 100644 --- a/code/include/common/optionstructure.h +++ b/code/include/common/optionstructure.h @@ -1,9 +1,6 @@ /*! - * \file OptionStructure.h - * \brief Classes for different Options in rtsn - * \author S. Schotthoefer - * - * Disclaimer: This class structure was copied and modifed with open source permission from SU2 v7.0.3 https://su2code.github.io/ + * \file optionstructure.h + * \brief Classes for different Options in KiT-RT */ #ifndef OPTION_STRUCTURE_H @@ -19,28 +16,28 @@ class OptionBase { private: - std::vector _value; /*! @brief: String name of the option */ + std::vector _value; /*!< @brief String name of the option */ public: OptionBase() {} virtual ~OptionBase() = 0; - virtual std::string SetValue( std::vector value ); /*! @brief: Set string name of the option */ + virtual std::string SetValue( std::vector value ); /*!< @brief Set string name of the option */ - std::vector GetValue(); /*! @brief: Get string name of the option */ + std::vector GetValue(); /*!< @brief Get string name of the option */ - virtual void SetDefault() = 0; /*! @brief: Set default name for the option */ - /*! @brief: Check if an option is defined multiple times in a config file, if yes, return a string stating this. */ + virtual void SetDefault() = 0; /*!< @brief Set default name for the option */ + /*! @brief Check if an option is defined multiple times in a config file, if yes, return a string stating this. */ std::string OptionCheckMultipleValues( std::vector& option_value, std::string type_id, std::string option_name ); - /*! @brief: If a bad value for an option is detected, this function creates the corresponding output string. */ + /*! @brief If a bad value for an option is detected, this function creates the corresponding output string. */ std::string BadValue( std::vector& option_value, std::string type_id, std::string option_name ); }; class OptionDouble : public OptionBase { - double& _field; /*! @brief: Reference to the double field value */ - double _def; /*! @brief: Default value */ - std::string _name; /*! @brief: String identifier for the option */ + double& _field; /*!< @brief Reference to the double field value */ + double _def; /*!< @brief Default value */ + std::string _name; /*!< @brief String identifier for the option */ public: OptionDouble( std::string option_field_name, double& option_field, double default_value ); @@ -54,9 +51,9 @@ class OptionDouble : public OptionBase class OptionString : public OptionBase { - std::string& _field; /*! @brief: Reference to the string field value */ - std::string _def; /*! @brief: Default value */ - std::string _name; /*! @brief: string identifier for the option */ + std::string& _field; /*!< @brief Reference to the string field value */ + std::string _def; /*!< @brief Default value */ + std::string _name; /*!< @brief string identifier for the option */ public: OptionString( std::string option_field_name, std::string& option_field, std::string default_value ); @@ -70,9 +67,9 @@ class OptionString : public OptionBase class OptionInt : public OptionBase { - int& _field; /*! @brief: Reference to the int field value */ - int _def; /*! @brief: Default value */ - std::string _name; /*! @brief: string identifier for the option */ + int& _field; /*!< @brief Reference to the int field value */ + int _def; /*!< @brief Default value */ + std::string _name; /*!< @brief string identifier for the option */ public: OptionInt( std::string option_field_name, int& option_field, int default_value ); @@ -86,9 +83,9 @@ class OptionInt : public OptionBase class OptionULong : public OptionBase { - unsigned long& _field; /*! @brief: Reference to the unsigned long field value */ - unsigned long _def; /*! @brief: Default value */ - std::string _name; /*! @brief: string identifier for the option */ + unsigned long& _field; /*!< @brief Reference to the unsigned long field value */ + unsigned long _def; /*!< @brief Default value */ + std::string _name; /*!< @brief string identifier for the option */ public: OptionULong( std::string option_field_name, unsigned long& option_field, unsigned long default_value ); @@ -102,9 +99,9 @@ class OptionULong : public OptionBase class OptionUShort : public OptionBase { - unsigned short& _field; /*! @brief: Reference to the unsigned short field value */ - unsigned short _def; /*! @brief: Default value */ - std::string _name; /*! @brief: string identifier for the option */ + unsigned short& _field; /*!< @brief Reference to the unsigned short field value */ + unsigned short _def; /*!< @brief Default value */ + std::string _name; /*!< @brief string identifier for the option */ public: OptionUShort( std::string option_field_name, unsigned short& option_field, unsigned short default_value ); @@ -118,9 +115,9 @@ class OptionUShort : public OptionBase class OptionLong : public OptionBase { - long& _field; /*! @brief: Reference to the long field value */ - long _def; /*! @brief: Default value */ - std::string _name; /*! @brief: string identifier for the option */ + long& _field; /*!< @brief Reference to the long field value */ + long _def; /*!< @brief Default value */ + std::string _name; /*!< @brief string identifier for the option */ public: OptionLong( std::string option_field_name, long& option_field, long default_value ); @@ -134,9 +131,9 @@ class OptionLong : public OptionBase class OptionBool : public OptionBase { - bool& _field; /*! @brief: Reference to the bool field value */ - bool _def; /*! @brief: Default value */ - std::string _name; /*! @brief: string identifier for the option */ + bool& _field; /*!< @brief Reference to the bool field value */ + bool _def; /*!< @brief Default value */ + std::string _name; /*!< @brief string identifier for the option */ public: OptionBool( std::string option_field_name, bool& option_field, bool default_value ); @@ -150,9 +147,9 @@ class OptionBool : public OptionBase class OptionStringList : public OptionBase { - std::vector& _field; /*! @brief: Reference to the string list field value. no default value */ - std::string _name; /*! @brief: string identifier for the option */ - unsigned short& _size; /*! @brief: Size of string list */ + std::vector& _field; /*!< @brief Reference to the string list field value. no default value */ + std::string _name; /*!< @brief string identifier for the option */ + unsigned short& _size; /*!< @brief Size of string list */ public: OptionStringList( std::string option_field_name, unsigned short& list_size, std::vector& option_field ); @@ -169,10 +166,10 @@ class OptionStringList : public OptionBase template class OptionEnum : public OptionBase { - std::map _map; /*! @brief: Map */ - Tenum& _field; /*! @brief: Reference to the enum fieldname */ - Tenum _def; /*! @brief: Default value */ - std::string _name; /*! @brief: string identifier for the option */ + std::map _map; /*!< @brief Map */ + Tenum& _field; /*!< @brief Reference to the enum fieldname */ + Tenum _def; /*!< @brief Default value */ + std::string _name; /*!< @brief string identifier for the option */ public: OptionEnum( std::string option_field_name, const std::map m, Tenum& option_field, Tenum default_value ) @@ -212,10 +209,10 @@ template class OptionEnum : public OptionBase template class OptionEnumList : public OptionBase { - std::map _map; /*! @brief: Map */ - std::vector& _field; /*! @brief: Reference to the enum list fieldname. No default value */ - std::string _name; /*! @brief: string identifier for the option */ - unsigned short& _size; /*! @brief: Size of enum list */ + std::map _map; /*!< @brief Map */ + std::vector& _field; /*!< @brief Reference to the enum list fieldname. No default value */ + std::string _name; /*!< @brief string identifier for the option */ + unsigned short& _size; /*!< @brief Size of enum list */ public: OptionEnumList( std::string option_field_name, const std::map m, std::vector& option_field, unsigned short& list_size ) diff --git a/code/include/entropies/entropybase.h b/code/include/entropies/entropybase.h index 1c2c3f99a213beb251880267f812f7a7b125ab0b..23da4e4d6340a023c88c95a8acfc9cbfa66f36ff 100644 --- a/code/include/entropies/entropybase.h +++ b/code/include/entropies/entropybase.h @@ -13,40 +13,33 @@ class EntropyBase static EntropyBase* Create( Config* settings ); - /*! @brief: computes the entropy functional - * @param: z = point where the functional should be evaluated. + /*! @brief computes the entropy functional + * @param z = point where the functional should be evaluated. * z must be in domain of the functional * @returns: value of entropy functional at z */ virtual double Entropy( double z ) = 0; - /*! @brief: computes eta'(z).z must be in domain of the functional. - * @param: z = point where the derivative should be evaluated. */ + /*! @brief computes eta'(z).z must be in domain of the functional. + * @param z = point where the derivative should be evaluated. */ virtual double EntropyPrime( double z ) = 0; - /*! @brief: computes the dual of the entropy functional - * @param: z = point where the dual of the functional should be evaluated. - * z must be in domain of the duaö functional + /*! @brief computes the dual of the entropy functional + * @param y point where the dual of the functional should be evaluated. + * y must be in domain of the duaö functional * @returns: value of entropy functional at z */ virtual double EntropyDual( double y ) = 0; - // /*! @brief: computes m*eta_*'(alpha*m). alpha*m must be in domain of the functional - // * alpha, m and grad must be of same size. - // * @param: alpha = point where the derivative should be evaluated. - // * @param: m = moment vector - // * @param: grad: vector in which the resulting gradient is stored */ - // virtual void EntropyPrimeDual( Vector& alpha, Vector& m, Vector& grad ) = 0; - - /*! @brief: computes eta_*'(y). - * @param: y = point where the derivative should be evaluated. + /*! @brief computes eta_*'(y). + * @param y = point where the derivative should be evaluated. * @returns: value of the derivative of the entropy functional at y */ - virtual double EntropyPrimeDual( double z ) = 0; + virtual double EntropyPrimeDual( double y ) = 0; - /*! @brief: computes the hessian of the dual entropy functional - * @param: y = point where the hessian should be evaluated; + /*! @brief computes the hessian of the dual entropy functional + * @param y = point where the hessian should be evaluated; * @returns: value of the hessian at y */ virtual double EntropyHessianDual( double y ) = 0; - /*! @brief: checks, if value is in domain of entropy */ + /*! @brief checks, if value is in domain of entropy */ virtual bool CheckDomain( double z ) = 0; }; diff --git a/code/include/fluxes/laxfriedrichsflux.h b/code/include/fluxes/laxfriedrichsflux.h index 287684d54f716c1fe0a195afb897b1b3e4420002..b7237192cb05bb1174eff53a2b12b23a490e995d 100644 --- a/code/include/fluxes/laxfriedrichsflux.h +++ b/code/include/fluxes/laxfriedrichsflux.h @@ -5,7 +5,7 @@ class LaxFriedrichsFlux : public NumericalFlux { - double _dt; + // double _dt; public: /** diff --git a/code/include/fluxes/numericalflux.h b/code/include/fluxes/numericalflux.h index 2a5835e1a496556340145d9f0890a7e429fba904..2cdbe9dc11343f17dab9a39ab277d3644b0ad784 100644 --- a/code/include/fluxes/numericalflux.h +++ b/code/include/fluxes/numericalflux.h @@ -20,19 +20,18 @@ class NumericalFlux virtual double Flux( const Vector& Omega, double psiL, double psiR, const Vector& n ) const = 0; /** - * @brief Flux : Computes upwinding scheme for given flux jacobians of the PN Solver at a given edge and stores it in - * resultFlux - * @param AxPlus : Positive part of the flux jacobian in x direction - * @param AxMinus : Negative part of the flux jacobian in x direction - * @param AyPlus : Positive part of the flux jacobian in y direction - * @param AyMinus : Negative part of the flux jacobian in y direction - * @param AzPlus : Positive part of the flux jacobian in z direction - * @param AzMinus : Negative part of the flux jacobian in z direction - * @param psiL : Solution state of left hand side control volume - * @param psiR : Solution state of right hand side control volume - * @param n : Normal vector at the edge between left and right control volume - * @param resultFlux: Vector with resulting flux. - * @return : void + * @brief Flux Computes "Steger Warming" upwinding scheme for given flux jacobians of the PN Solver at a given edge and stores it in + * resultFlux + * @param AxPlus Positive part of the flux jacobian in x direction + * @param AxMinus Negative part of the flux jacobian in x direction + * @param AyPlus Positive part of the flux jacobian in y direction + * @param AyMinus Negative part of the flux jacobian in y direction + * @param AzPlus Positive part of the flux jacobian in z direction + * @param AzMinus Negative part of the flux jacobian in z direction + * @param psiL Solution state of left hand side control volume + * @param psiR Solution state of right hand side control volume + * @param n Normal vector at the edge between left and right control volume + * @return Vector with resulting flux. */ virtual Vector Flux( const Matrix AxPlus, const Matrix AxMinus, @@ -40,8 +39,8 @@ class NumericalFlux const Matrix AyMinus, const Matrix AzPlus, const Matrix AzMinus, - const Vector, - const Vector, + const Vector psiL, + const Vector psiR, const Vector n ) const = 0; virtual void FluxVanLeer( const Matrix& Ax, diff --git a/code/include/fluxes/upwindflux.h b/code/include/fluxes/upwindflux.h index fe40f193af1ad856e3c11a728161b7f0c3740eaa..842aff9ab471c87bf65b5d7379386a73b9b894a3 100644 --- a/code/include/fluxes/upwindflux.h +++ b/code/include/fluxes/upwindflux.h @@ -23,19 +23,18 @@ class UpwindFlux : public NumericalFlux double Flux( const Vector& Omega, double psiL, double psiR, const Vector& n ) const override; /** - * @brief Flux : Computes upwinding scheme for given flux jacobians of the PN Solver at a given edge and stores it in - * resultFlux - * @param AxPlus : Positive part of the flux jacobian in x direction - * @param AxMinus : Negative part of the flux jacobian in x direction - * @param AyPlus : Positive part of the flux jacobian in y direction - * @param AyMinus : Negative part of the flux jacobian in y direction - * @param AzPlus : Positive part of the flux jacobian in z direction - * @param AzMinus : Negative part of the flux jacobian in z direction - * @param psiL : Solution state of left hand side control volume - * @param psiR : Solution state of right hand side control volume - * @param n : Normal vector at the edge between left and right control volume - * @param resultFlux: Vector with resulting flux. - * @return : void + * @brief Flux Computes "Steger Warming" upwinding scheme for given flux jacobians of the PN Solver at a given edge and stores it in + * resultFlux + * @param AxPlus Positive part of the flux jacobian in x direction + * @param AxMinus Negative part of the flux jacobian in x direction + * @param AyPlus Positive part of the flux jacobian in y direction + * @param AyMinus Negative part of the flux jacobian in y direction + * @param AzPlus Positive part of the flux jacobian in z direction + * @param AzMinus Negative part of the flux jacobian in z direction + * @param psiL Solution state of left hand side control volume + * @param psiR Solution state of right hand side control volume + * @param n Normal vector at the edge between left and right control volume + * @return Vector with resulting flux */ Vector Flux( const Matrix AxPlus, const Matrix AxMinus, @@ -48,19 +47,19 @@ class UpwindFlux : public NumericalFlux const Vector n ) const override; /** - * @brief Flux : Computes upwinding scheme for given flux jacobians of the PN Solver at a given edge and stores it in - * resultFlux - * @param AxPlus : Positive part of the flux jacobian in x direction - * @param AxMinus : Negative part of the flux jacobian in x direction - * @param AyPlus : Positive part of the flux jacobian in y direction - * @param AyMinus : Negative part of the flux jacobian in y direction - * @param AzPlus : Positive part of the flux jacobian in z direction - * @param AzMinus : Negative part of the flux jacobian in z direction - * @param psiL : Solution state of left hand side control volume - * @param psiR : Solution state of right hand side control volume - * @param n : Normal vector at the edge between left and right control volume - * @param resultFlux: Vector with resulting flux. - * @return : void + * @brief Flux Computes "VanLeer" upwinding scheme for given flux jacobians of the PN Solver at a given edge and stores it in + * resultFlux + * @param Ax Flux jacobian in x direction + * @param AxAbs Absolute value of the flux jacobian in x direction + * @param Ay Flux jacobian in y direction + * @param AyAbs Absolute value of the flux jacobian in y direction + * @param Az Flux jacobian in z direction + * @param AzAbs Absolute value of the flux jacobian in z direction + * @param psiL Solution state of left hand side control volume + * @param psiR Solution state of right hand side control volume + * @param n Normal vector at the edge between left and right control volume + * @param resultFlux Vector with resulting flux. + * @return void */ void FluxVanLeer( const Matrix& Ax, const Matrix& AxAbs, diff --git a/code/include/kernels/scatteringkernelbase.h b/code/include/kernels/scatteringkernelbase.h index 7ff60be9c11fddbe1d9ef47cb8c9b77b9ede19e4..18038ca3f68c07007a5bfe7f152f7e7d5783b7b5 100644 --- a/code/include/kernels/scatteringkernelbase.h +++ b/code/include/kernels/scatteringkernelbase.h @@ -19,19 +19,19 @@ class ScatteringKernel ScatteringKernel() = delete; protected: - QuadratureBase* _quad; /*! @brief: Pointer to the quadrature used to compute the scattering integral */ + QuadratureBase* _quad; /*!< @brief Pointer to the quadrature used to compute the scattering integral */ public: - /*! @brief: Copies the pointer of quad. Does not create an own quad */ + /*! @brief Copies the pointer of quad. Does not create an own quad */ ScatteringKernel( QuadratureBase* quad ); virtual ~ScatteringKernel(); - /*! @brief: Computes the scattering kernel and for the whole SN system and stores it in a Matrix - @return: Matrix with discretized scattering kernel */ + /*! @brief Computes the scattering kernel and for the whole SN system and stores it in a Matrix + @return Matrix with discretized scattering kernel */ virtual Matrix GetScatteringKernel() = 0; - /*! @brief: Creates an object of the child class of ScatteringKernelBase corresponding to the enum KERNEL_NAME */ + /*! @brief Creates an object of the child class of ScatteringKernelBase corresponding to the enum KERNEL_NAME */ static ScatteringKernel* CreateScatteringKernel( KERNEL_NAME name, QuadratureBase* quad ); }; diff --git a/code/include/optimizers/mloptimizer.h b/code/include/optimizers/mloptimizer.h index 1eb5a290ad80bc08801b8ef76abe9a51b65b8816..4dcd59ba7952de310fd45074176d2bb6f567d7d4 100644 --- a/code/include/optimizers/mloptimizer.h +++ b/code/include/optimizers/mloptimizer.h @@ -16,32 +16,32 @@ class MLOptimizer : public OptimizerBase inline ~MLOptimizer(); - void Solve( Vector& lambda, Vector& u, const VectorVector& moments, unsigned idx_cell = 0 ) override; - void SolveMultiCell( VectorVector& lambda, VectorVector& u, const VectorVector& moments ) override; + void Solve( Vector& alpha, Vector& u, const VectorVector& moments, unsigned idx_cell = 0 ) override; + void SolveMultiCell( VectorVector& alpha, VectorVector& u, const VectorVector& moments ) override; private: - /*! @brief: Calls the tensorflow neural network for the entropy closure - * @param: inputDim : dimension of moment vector for a single cell - * @param: double* nnInput : moment vector as double array - * @return: Lagrange multiplyer alpha with size input_size + /*! @brief Calls the tensorflow neural network for the entropy closure + * @param inputDim dimension of moment vector for a single cell + * @param nnInput moment vector as double array (input to the neural network) + * @return alpha Lagrange multiplyer with size input_size */ double* callNetwork( const unsigned inputDim, double* nnInput ); - /*! @brief: Calls the tensorflow neural network for the entropy closure for the whole mesh - * @param: batchSize : number of cells in the mesh ==> batchsize for the network - * @param: inputDim : dimension of moment vector for a single cell - * @param: double* nnInput : moment vector as double array - * @return: Lagrange multiplyer alpha with size input_size + /*! @brief Calls the tensorflow neural network for the entropy closure for the whole mesh + * @param batchSize number of cells in the mesh ==> batchsize for the network + * @param inputDim dimension of moment vector for a single cell + * @param nnInput moment vector as double array (input to the neural network) + * @return alpha Lagrange multiplyer with size input_size */ double* callNetworkMultiCell( const unsigned batchSize, const unsigned inputDim, double* nnInput ); - /*! @brief: Initializes the Python module. Sets Path for Python, references Python module */ + /*! @brief Initializes the Python module. Sets Path for Python, references Python module */ void initializePython(); - /*! @brief: Initilizes numpy python module. */ + /*! @brief Initilizes numpy python module. */ void initNumpy(); - /*! @brief: Calls Python Funaction to initialize the tensorflow network. */ + /*! @brief Calls Python Funaction to initialize the tensorflow network. */ void initializeNetwork(); - /*! @brief: Finalizes the Python module. Dereferences Python */ + /*! @brief Finalizes the Python module. Dereferences Python */ void finalizePython(); // Python members diff --git a/code/include/optimizers/newtonoptimizer.h b/code/include/optimizers/newtonoptimizer.h index 728911f926c0f4b2e372fff00e64c870c2720ba4..8be0368e3891ecee58000d060cc423f16491b37b 100644 --- a/code/include/optimizers/newtonoptimizer.h +++ b/code/include/optimizers/newtonoptimizer.h @@ -18,30 +18,30 @@ class NewtonOptimizer : public OptimizerBase ~NewtonOptimizer(); - void Solve( Vector& lambda, Vector& sol, const VectorVector& moments, unsigned idx_cell = 0 ) override; - void SolveMultiCell( VectorVector& lambda, VectorVector& sol, const VectorVector& moments ) override; + void Solve( Vector& alpha, Vector& sol, const VectorVector& moments, unsigned idx_cell = 0 ) override; + void SolveMultiCell( VectorVector& alpha, VectorVector& sol, const VectorVector& moments ) override; - /*! @brief: Computes the objective function + /*! @brief Computes the objective function grad = - alpha*sol */ double ComputeObjFunc( Vector& alpha, Vector& sol, const VectorVector& moments ); private: - /*! @brief: Computes gradient of objective function and stores it in grad + /*! @brief Computes gradient of objective function and stores it in grad grad = - sol */ void ComputeGradient( Vector& alpha, Vector& sol, const VectorVector& moments, Vector& grad ); - /*! @brief: Computes hessian of objective function and stores it in hessian + /*! @brief Computes hessian of objective function and stores it in hessian grad = */ void ComputeHessian( Vector& alpha, const VectorVector& moments, Matrix& hessian ); - QuadratureBase* _quadrature; /*! @brief: used quadrature */ // THis is memory doubling! Try to use a pointer. - unsigned _nq; /*! @brief: number of quadrature points */ - Vector _weights; /*! @brief quadrature weights, dim(_weights) = (_nq) */ + QuadratureBase* _quadrature; /*!< @brief used quadrature */ // THis is memory doubling! Try to use a pointer. + unsigned _nq; /*!< @brief number of quadrature points */ + Vector _weights; /*!< @brief quadrature weights, dim(_weights) = (_nq) */ - double _epsilon; /*! @brief: Termination criterion for newton optimizer */ - unsigned short _maxIterations; /*! @brief: Max iterations of the newton solver */ - double _alpha; /*! @brief: Newton Step Size */ - unsigned short _maxLineSearches; /*! @brief: Max amount of line searches for Newton Algo */ + double _epsilon; /*!< @brief Termination criterion for newton optimizer */ + unsigned short _maxIterations; /*!< @brief Max iterations of the newton solver */ + double _alpha; /*!< @brief Newton Step Size */ + unsigned short _maxLineSearches; /*!< @brief Max amount of line searches for Newton Algo */ }; #endif // NEWTONOPTIMIZER_H diff --git a/code/include/optimizers/optimizerbase.h b/code/include/optimizers/optimizerbase.h index 10d3dbd0eb2dfb73fb613da0410e1ef7569b7281..c4ce64f8b896d1ba7b305d082c11416013402cf9 100644 --- a/code/include/optimizers/optimizerbase.h +++ b/code/include/optimizers/optimizerbase.h @@ -20,19 +20,25 @@ class OptimizerBase virtual ~OptimizerBase(); - /*! @brief: Optimizer creator: Depending on the chosen option, this function creates an object of the chosen child class of OptimizerBase */ + /*! @brief Optimizer creator: Depending on the chosen option, this function creates an object of the chosen child class of OptimizerBase */ static OptimizerBase* Create( Config* settings ); - /*! @brief : Computes the optimal Lagrange multilpiers for the dual entropy minimization problem - * @param : Vector u = pointer to vector of given moments. // Maybe use pointer for performance? - * @return : Vector alpha = optimal lagrange multipliers. Has the same length as Vector u. */ - virtual void Solve( Vector& lambda, Vector& u, const VectorVector& moments, unsigned idx_cell = 0 ) = 0; + /*! @brief Computes the optimal Lagrange multilpiers for the dual entropy minimization problem + * @param alpha vector where the solution Lagrange multipliers are saved to. + * @param u moment vector + * @param moments VectorVector to the moment basis evaluated at all quadpoints + * @param idx_cell index of the cell where alpha should be computed (out of u) */ + virtual void Solve( Vector& alpha, Vector& u, const VectorVector& moments, unsigned idx_cell = 0 ) = 0; - virtual void SolveMultiCell( VectorVector& lambda, VectorVector& u, const VectorVector& moments ) = 0; + /*! @brief Computes the optimal Lagrange multilpiers for the dual entropy minimization problem + * @param alpha vector where the solution Lagrange multipliers are saved to. + * @param u moment vector + * @param moments VectorVector to the moment basis evaluated at all quadpoints */ + virtual void SolveMultiCell( VectorVector& alpha, VectorVector& u, const VectorVector& moments ) = 0; protected: - EntropyBase* _entropy; /*! @brief: Class to handle entropy functional evaluations */ - Config* _settings; /*! @biref: Pointer to settings class of the solver */ + EntropyBase* _entropy; /*!< @brief Class to handle entropy functional evaluations */ + Config* _settings; /*!< @brief Pointer to settings class of the solver */ }; #endif // OPTIMIZERBASE_H diff --git a/code/include/problems/checkerboard.h b/code/include/problems/checkerboard.h index 96deded5ed58809b7776d9a79de472d82d447702..41bb833b78e640b1dfe54b49cf8b21bcc619f0c5 100644 --- a/code/include/problems/checkerboard.h +++ b/code/include/problems/checkerboard.h @@ -3,56 +3,59 @@ #include "problembase.h" +class SphericalBase; + class Checkerboard_SN : public ProblemBase { private: - Vector _scatteringXS; /*! @brief Vector of scattering crosssections */ - Vector _totalXS; /*! @brief Vector of total crosssections */ + Vector _scatteringXS; /*!< @brief Vector of scattering crosssections */ + Vector _totalXS; /*!< @brief Vector of total crosssections */ Checkerboard_SN() = delete; - bool isAbsorption( const Vector& pos ) const; /*! @return True if pos is in absorption region, False otherwise */ - bool isSource( const Vector& pos ) const; /*! @return True if pos is in source region, False otherwise */ + bool isAbsorption( const Vector& pos ) const; /*!< @return True if pos is in absorption region, False otherwise */ + bool isSource( const Vector& pos ) const; /*!< @return True if pos is in source region, False otherwise */ public: Checkerboard_SN( Config* settings, Mesh* mesh ); virtual ~Checkerboard_SN(); - virtual VectorVector GetScatteringXS( const Vector& energies ); - virtual VectorVector GetTotalXS( const Vector& energies ); - virtual std::vector GetExternalSource( const Vector& energies ); - virtual VectorVector SetupIC(); + virtual VectorVector GetScatteringXS( const Vector& energies ) override; + virtual VectorVector GetTotalXS( const Vector& energies ) override; + virtual std::vector GetExternalSource( const Vector& energies ) override; + virtual VectorVector SetupIC() override; }; -class Checkerboard_PN : public ProblemBase +class Checkerboard_Moment : public ProblemBase { private: - Vector _scatteringXS; /*! @brief Vector of scattering crosssections len: numCells */ - Vector _totalXS; /*! @brief Vector of total crosssections. len: numCells*/ + Vector _scatteringXS; /*!< @brief Vector of scattering crosssections len: numCells */ + Vector _totalXS; /*!< @brief Vector of total crosssections. len: numCells*/ + SphericalBase* _basis; /*!< @brief Class to compute and store current spherical harmonics basis */ - Checkerboard_PN() = delete; + Checkerboard_Moment() = delete; - bool isAbsorption( const Vector& pos ) const; /*! @return True if pos is in absorption region, False otherwise */ - bool isSource( const Vector& pos ) const; /*! @return True if pos is in source region, False otherwise */ + bool isAbsorption( const Vector& pos ) const; /*!< @return True if pos is in absorption region, False otherwise */ + bool isSource( const Vector& pos ) const; /*!< @return True if pos is in source region, False otherwise */ - /** + /*! * @brief Gets the global index for given order l of Legendre polynomials and given * order k of Legendre functions. * Note: This is code doubling from PNSolver::GlobalIndex - * @param l : order of Legendre polynomial - * @param k : order of Legendre function - * @returns global index + * @param l order of Legendre polynomial + * @param k order of Legendre function + * @returns globalIndex */ int GlobalIndex( int l, int k ) const; public: - Checkerboard_PN( Config* settings, Mesh* mesh ); - virtual ~Checkerboard_PN(); + Checkerboard_Moment( Config* settings, Mesh* mesh ); + virtual ~Checkerboard_Moment(); - virtual VectorVector GetScatteringXS( const Vector& energies ); - virtual VectorVector GetTotalXS( const Vector& energies ); - virtual std::vector GetExternalSource( const Vector& energies ); - virtual VectorVector SetupIC(); + virtual VectorVector GetScatteringXS( const Vector& energies ) override; + virtual VectorVector GetTotalXS( const Vector& energies ) override; + virtual std::vector GetExternalSource( const Vector& energies ) override; + virtual VectorVector SetupIC() override; }; #endif // CHECKERBOARD_H diff --git a/code/include/problems/electronrt.h b/code/include/problems/electronrt.h index 0b5cd93273e795b46399c816295f29e4c7d5b116..e1e373a0d54706a22478cd0c85f4a2fc96de379c 100644 --- a/code/include/problems/electronrt.h +++ b/code/include/problems/electronrt.h @@ -20,13 +20,18 @@ class ElectronRT : public ProblemBase ElectronRT( Config* settings, Mesh* mesh ); virtual ~ElectronRT(); - virtual VectorVector GetScatteringXS( const Vector& energies ); - virtual VectorVector GetTotalXS( const Vector& energies ); - virtual std::vector GetScatteringXSE( const Vector& energies, const Matrix& angles ); - virtual Vector GetTotalXSE( const Vector& energies ); - virtual std::vector GetExternalSource( const Vector& energies ); - virtual VectorVector SetupIC(); - std::vector GetDensity( const VectorVector& cellMidPoints ); + VectorVector GetScatteringXS( const Vector& energies ) override; + VectorVector GetTotalXS( const Vector& energies ) override; + std::vector GetScatteringXSE( const Vector& energies, const Matrix& angles ) override; + /** + * @brief GetTotalXSE gives back vector of total cross sections for + * energies in vector energy + * @param energies is the energy the cross section is queried for + */ + Vector GetTotalXSE( const Vector& energies ) override; + std::vector GetExternalSource( const Vector& energies ) override; + VectorVector SetupIC() override; + std::vector GetDensity( const VectorVector& cellMidPoints ) override; }; #endif // ELECTRONRT_H diff --git a/code/include/problems/epics.h b/code/include/problems/epics.h index c886de965a93cf65e2167e061294ab5f508fc9ef..cac05c4a7e7e04121b6d7870259149a16a511d23 100644 --- a/code/include/problems/epics.h +++ b/code/include/problems/epics.h @@ -53,8 +53,6 @@ class EPICS /** * @brief GetStoppingPower gives back vector of vectors of stopping powers for materials defined by density and energies in vector energy * @param energies is vector with energies - * @param density is vector with patient densities (at different spatial cells) - * @param sH2O is vector of stopping powers in water */ Vector GetStoppingPower( Vector energies ); diff --git a/code/include/problems/icru.h b/code/include/problems/icru.h index 17d0acc1f02ae81300301a71a592a7f7d68f3cb9..9879586cadbe0ceebe5c82a707971185b50c7bde 100644 --- a/code/include/problems/icru.h +++ b/code/include/problems/icru.h @@ -25,7 +25,7 @@ class Config; class ICRU { private: - Config* _settings; /*! @brief: Pointer to settings file of the solver */ + Config* _settings; /*!< @brief Pointer to settings file of the solver */ const unsigned materialID = 278; const ParticleType particle = ParticleType::ELECTRON; @@ -65,8 +65,8 @@ class ICRU double _BETA2; double _R1; - Vector _E, /*! @brief: User queried Energy */ - _QMU; /*! @brief:User queried mu */ + Vector _E, /*! @brief User queried Energy */ + _QMU; /*!< @brief User queried mu */ std::vector _ET, _ETL; std::vector _XMU, /* angular variable mu of dataset */ @@ -104,7 +104,7 @@ class ICRU ICRU() = delete; public: - /*! @brief: Constructor of ICRU class + /*! @brief Constructor of ICRU class * @arg: Vector& mu, = Vector of angles * @arg: Vector& energy, = Vector of energies * @arg: Config* settings = pointer to programm settings class @@ -113,18 +113,18 @@ class ICRU ~ICRU(){}; - /*! @brief: Computes the angular scattering cross sections and integrated XS by interpolating tabular data + /*! @brief Computes the angular scattering cross sections and integrated XS by interpolating tabular data * @arg: Matrix& angularXS = Matrix where the angular XS will be saved * @arg: Vector& integratedXS = Vector, where the integratedXS will be saved * @returns: void */ void GetAngularScatteringXS( Matrix& angularXS, Vector& integratedXS ); - /*! @brief: Computes the stopping power by interpolating tabular data + /*! @brief Computes the stopping power by interpolating tabular data * @arg: Vector& stoppingPower = Vector, where the stopping power will be saved * @returns: void */ void GetStoppingPower( Vector& stoppingPower ); - /*! @brief: Computes the transport coefficients by interpolating tabular data + /*! @brief Computes the transport coefficients by interpolating tabular data * @arg: Matrix& xi = Vector, where the stopping power will be saved * @returns: void */ void GetTransportCoefficients( Matrix& xi ); diff --git a/code/include/problems/isotropicsource2d.h b/code/include/problems/isotropicsource2d.h index adea0bcf0eafa582e9b3ab6a83909f1131567331..07ff120c9b2971685c6543633991ef2747e644a2 100644 --- a/code/include/problems/isotropicsource2d.h +++ b/code/include/problems/isotropicsource2d.h @@ -23,5 +23,4 @@ class IsotropicSource2D : public ElectronRT std::vector GetDensity( const VectorVector& cellMidPoints ); }; - -#endif // ISOTROPICSOURCE2D_H +#endif // ISOTROPICSOURCE2D_H diff --git a/code/include/problems/linesource.h b/code/include/problems/linesource.h index 9a258cfc6f9bf7bb69164b37ca200dd13e134d85..dc78f4f4fc92c562fb8b6c004830a821337d215b 100644 --- a/code/include/problems/linesource.h +++ b/code/include/problems/linesource.h @@ -9,34 +9,37 @@ class LineSource : public ProblemBase LineSource() = delete; protected: - double _sigmaS; /*!< @brief: Scattering coefficient */ + double _sigmaS; /*!< @brief Scattering coefficient */ public: LineSource( Config* settings, Mesh* mesh ); ~LineSource(); - /*!< @brief: Exact analytical solution for the Line Source Test Case at - @param: x: x coordinate of exact solution - y: y coordinate of exact solution - t: time of the exact solution - sigma_s: scattering cross section of the exact solution - @return: exact solution at x,y,t,scatteringXS + /*! @brief Exact analytical solution for the Line Source Test Case at + @param x coordinate of exact solution + @param y coordinate of exact solution + @param t time of the exact solution + @param sigma_s scattering cross section of the exact solution + @return exact solution at x,y,t,scatteringXS */ double GetAnalyticalSolution( double x, double y, double t, double sigma_s ) override; private: - /*!< @brief: Helper Functions to compute the analytic solution for sigma != 0 + /*! @brief Helper Functions to compute the analytic solution for sigma != 0 * (See publication: Garret,Hauck; Momentum Closures for Linear Kinetic Transport Equations) - @param: R = distance to origin - @param: t = time - @param: sigma = R/t + @param R distance to origin + @param t time */ double HelperIntRho_ptc( double R, double t ); - double HelperRho_ptc( double R, double t ); - double HelperRho_ptc1( double R, double t ); - double HelperRho_ptc2( double R, double t ); - double HelperIntRho_ptc2( double t, double gamma ); + double HelperRho_ptc( double R, + double t ); /*!< @brief helper to comput analytic line source solution. @param R distance to origin @param t time */ + double HelperRho_ptc1( double R, + double t ); /*!< @brief helper to comput analytic line source solution. @param R distance to origin @param t time */ + double HelperRho_ptc2( double R, + double t ); /*!< @brief helper to comput analytic line source solution. @param R distance to origin @param t time */ + double HelperIntRho_ptc2( double t, + double gamma ); /*!< @brief helper to comput analytic line source solution @param t time @param gamma equals R/t */ }; class LineSource_SN : public LineSource @@ -48,10 +51,10 @@ class LineSource_SN : public LineSource LineSource_SN( Config* settings, Mesh* mesh ); ~LineSource_SN(); - virtual VectorVector GetScatteringXS( const Vector& energies ); - virtual VectorVector GetTotalXS( const Vector& energies ); - virtual std::vector GetExternalSource( const Vector& energies ); - virtual VectorVector SetupIC(); + virtual VectorVector GetScatteringXS( const Vector& energies ) override; + virtual VectorVector GetTotalXS( const Vector& energies ) override; + virtual std::vector GetExternalSource( const Vector& energies ) override; + virtual VectorVector SetupIC() override; }; class LineSource_SN_Pseudo1D : public LineSource_SN @@ -74,6 +77,12 @@ class LineSource_SN_Pseudo1D_Physics : public LineSource_SN_Pseudo1D LineSource_SN_Pseudo1D_Physics( Config* settings, Mesh* mesh ); std::vector GetScatteringXSE( const Vector& energies, const Matrix& angles ) override; + + /** + * @brief GetTotalXSE gives back vector of total cross sections for + * energies in vector energy + * @param energies is the energy the cross section is queried for + */ Vector GetTotalXSE( const Vector& energies ) override; }; diff --git a/code/include/problems/problembase.h b/code/include/problems/problembase.h index 30f302fa4f667c1f0ad4d4429e883024134d37f0..21257391ae207add00f1a95d020ad1b4dd8fcc36 100644 --- a/code/include/problems/problembase.h +++ b/code/include/problems/problembase.h @@ -17,8 +17,8 @@ class ProblemBase Mesh* _mesh; EPICS* _physics; - std::vector _density; /*! @brief: vector with patient densities */ - std::vector _stoppingPower; /*! @brief: vector with stopping powers*/ + std::vector _density; /*!< @brief vector with patient densities */ + std::vector _stoppingPower; /*!< @brief vector with stopping powers*/ ProblemBase() = delete; @@ -27,29 +27,28 @@ class ProblemBase * @brief GetScatteringXS gives back vector (each energy) of vectors (each grid cell) * of scattering cross sections for materials defined by density and energies * in vector energy - * @param energy is the energy the cross section is queried for + * @param energies is the energy the cross section is queried for */ virtual VectorVector GetScatteringXS( const Vector& energies ) = 0; /** * @brief GetTotalXS gives back vector of vectors of total cross sections for * materials defined by density and energies in vector energy - * @param energy is the energy the cross section is queried for - * @param density is vector with patient densities (at different spatial cells) + * @param energies is the energy the cross section is queried for */ virtual VectorVector GetTotalXS( const Vector& energies ) = 0; /** * @brief GetTotalXSE gives back vector of total cross sections for * energies in vector energy - * @param energy is the energy the cross section is queried for */ virtual Vector GetTotalXSE( const Vector& /*energies*/ ) { return Vector( 1 ); } /** * @brief GetScatteringXSE gives back vector (each energy) of scattering cross sections for energies * in vector energy - * @param energy is the energy the cross section is queried for + * @param energies is the energy the cross section is queried for + * @param angles are the queried angles */ virtual std::vector GetScatteringXSE( const Vector& energies, const Matrix& angles ) { return std::vector( energies.size(), Matrix( angles.rows(), angles.columns() ) ); @@ -58,14 +57,15 @@ class ProblemBase /** * @brief GetScatteringXSE gives back vector (each energy) of scattering cross sections for energies * in vector energy - * @param energy is the energy the cross section is queried for + * @param energies is the energy the cross section is queried for + * @param angles are the queried angles */ virtual VectorVector GetScatteringXSE( const Vector& energies, const Vector& angles ); /** * @brief GetExternalSource gives back vector of vectors of source terms for each * energy, cell and angle - * @param energies is vector with energies + * @param energies is the energy the cross section is queried for */ virtual std::vector GetExternalSource( const Vector& energies ) = 0; @@ -87,18 +87,15 @@ class ProblemBase */ virtual VectorVector SetupIC() = 0; - /*!< @brief: Exact analytical solution for the Line Source Test Case at - @param: x: x coordinate of exact solution - y: y coordinate of exact solution - t: time of the exact solution - scatteringXS: scattering cross section of the exact solution - @return: exact solution at x,y,t,scatteringXS + /*! @brief Exact analytical solution for the Line Source Test Case. Returns 0 for all other test cases. + @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; } /** * @brief Physics constructor * @param settings stores all needed user information + * @param mesh for the test case */ ProblemBase( Config* settings, Mesh* mesh ); virtual ~ProblemBase(); @@ -106,7 +103,8 @@ class ProblemBase /** * @brief Create constructor * @param settings stores all needed information - * @return pointer to Physics + * @param mesh for the test case + * @return pointer to ProblemBase */ static ProblemBase* Create( Config* settings, Mesh* mesh ); }; diff --git a/code/include/quadratures/qgausschebyshev1D.h b/code/include/quadratures/qgausschebyshev1D.h index 4ef1b3324b18acf284cf780b2c0583c8f31a0569..bce30b60985edb0dee26a96f9b8690c739b71678 100644 --- a/code/include/quadratures/qgausschebyshev1D.h +++ b/code/include/quadratures/qgausschebyshev1D.h @@ -28,20 +28,19 @@ class QGaussChebyshev1D : public QuadratureBase void SetConnectivity() override; /*! @brief Integrates f(x,y,z) with the quadrature. - * @param double(f)( double x0, double x1, double x2 ) : density function that depends on a three spatial dimensions. - * @returns double result: result of the quadrature rule */ - double Integrate( double( f )( double x0, double x1, double x2 ) ) override; + * @param f density function that depends on a three spatial dimensions. + * @returns result of the quadrature rule */ + double Integrate( double ( *f )( double, double, double ) ) override; /*! @brief Integrates f(x,y,z) with the quadrature. - * @param double(f)( double my, double phi ) : density function that depends on a spherical coordinates. - * @returns double result: result of the quadrature rule */ - double IntegrateSpherical( double( f )( double my, double phi ) ) override; + * @param f density function that depends on a spherical coordinates. + * @returns result of the quadrature rule */ + double IntegrateSpherical( double ( *f )( double, double ) ) override; /*! @brief Integrates vector valued f(x,y,z) with the quadrature. Each dimension is integrated by itself. - * @param : double(f)( double x0, double x1, double x2 ) : density function that depends on a three spatial dimensions. - * @param : len : lenght of vector - * @returns double result: result of the quadrature rule (vector valued) */ - std::vector Integrate( std::vector( f )( double x0, double x1, double x2 ), unsigned /* len */ ) override; + * @param f density function that depends on a three spatial dimensions. + * @returns result of the quadrature rule (vector valued) */ + std::vector Integrate( std::vector ( *f )( double, double, double ), unsigned /* len */ ) override; }; #endif // QGAUSSCHEBYSHEV_H diff --git a/code/include/quadratures/qgausslegendre1D.h b/code/include/quadratures/qgausslegendre1D.h index 7df4e3c4c5ab21ba3db1b80d1d424c955759643d..3296fb05bee67e2fcf171d9eed886981e749ce12 100644 --- a/code/include/quadratures/qgausslegendre1D.h +++ b/code/include/quadratures/qgausslegendre1D.h @@ -29,20 +29,19 @@ class QGaussLegendre1D : public QuadratureBase void SetConnectivity() override; /*! @brief Integrates f(x,y,z) with the quadrature. - * @param double(f)( double x0, double x1, double x2 ) : density function that depends on a three spatial dimensions. - * @returns double result: result of the quadrature rule */ - double Integrate( double( f )( double x0, double x1, double x2 ) ) override; + * @param f density function that depends on a three spatial dimensions. + * @returns result of the quadrature rule */ + double Integrate( double ( *f )( double, double, double ) ) override; /*! @brief Integrates f(x,y,z) with the quadrature. - * @param double(f)( double my, double phi ) : density function that depends on a spherical coordinates. - * @returns double result: result of the quadrature rule */ - double IntegrateSpherical( double( f )( double my, double phi ) ) override; + * @param f density function that depends on a spherical coordinates. + * @returns result of the quadrature rule */ + double IntegrateSpherical( double ( *f )( double, double ) ) override; /*! @brief Integrates vector valued f(x,y,z) with the quadrature. Each dimension is integrated by itself. - * @param : double(f)( double x0, double x1, double x2 ) : density function that depends on a three spatial dimensions. - * @param : len : lenght of vector - * @returns double result: result of the quadrature rule (vector valued) */ - std::vector Integrate( std::vector( f )( double x0, double x1, double x2 ), unsigned /* len */ ) override; + * @param f density function that depends on a three spatial dimensions. + * @returns result of the quadrature rule (vector valued) */ + std::vector Integrate( std::vector ( *f )( double, double, double ), unsigned /* len */ ) override; }; #endif // QGAUSSLEGENDRE1D_H diff --git a/code/include/quadratures/qgausslegendretensorized.h b/code/include/quadratures/qgausslegendretensorized.h index 50b0c3a2702d2215525ac6f0af1b1f9a29a76ade..23fa7ccdbde6c624673ae7ba1f8b0db55ef71f3e 100644 --- a/code/include/quadratures/qgausslegendretensorized.h +++ b/code/include/quadratures/qgausslegendretensorized.h @@ -6,20 +6,35 @@ class QGaussLegendreTensorized : public QuadratureBase { // Implementation is done accordingly to Kendall Atkinson 1981, Australian Matematical Society. - private: + protected: double Pythag( const double a, const double b ); std::pair ComputeEigenValTriDiagMatrix( const Matrix& mat ); - bool CheckOrder(); + virtual bool CheckOrder(); public: QGaussLegendreTensorized( Config* settings ); virtual ~QGaussLegendreTensorized() {} - inline void SetName() override { _name = "Tensorized Gauss-Legendre quadrature"; } + virtual inline void SetName() override { _name = "Tensorized Gauss-Legendre quadrature"; } void SetNq() override; void SetPointsAndWeights() override; void SetConnectivity() override; }; +class QGaussLegendreTensorized2D : public QGaussLegendreTensorized +{ + // Implementation is done accordingly to Kendall Atkinson 1981, Australian Matematical Society. + private: + bool CheckOrder() override; + + public: + QGaussLegendreTensorized2D( Config* settings ); + + virtual ~QGaussLegendreTensorized2D() {} + + inline void SetName() override { _name = "Tensorized Gauss-Legendre quadrature 2D projection"; } + void SetNq() override; + void SetPointsAndWeights() override; +}; #endif // QGAUSSLEGENDRETENSORIZED_H diff --git a/code/include/quadratures/qlookupquadrature.h b/code/include/quadratures/qlookupquadrature.h index fe6e50fb420ab688e5d10e7c86aeffce41f80175..85d3dd944b4be691579b98f7317b36a1d1208d0d 100644 --- a/code/include/quadratures/qlookupquadrature.h +++ b/code/include/quadratures/qlookupquadrature.h @@ -14,18 +14,18 @@ class QLookupQuadrature : public QuadratureBase inline std::vector getAvailOrders() const { return _availableOrders; } /*! @returns: Vector with avalable orders for level symmetric quadrature */ - void printAvailOrders() const; /*! @brief: prints available orders */ + void printAvailOrders() const; /*!< @brief prints available orders */ protected: - bool CheckOrder(); /*! @brief checks if given order is available for this quadrature rule. */ - void SetNq() override; /*! @brief: Assumes, that _order is available in lookup table */ - void SetPointsAndWeights() override; /*! @brief reads in n_points gridpoints and -weights from given filename. */ + bool CheckOrder(); /*!< @brief checks if given order is available for this quadrature rule. */ + void SetNq() override; /*!< @brief Assumes, that _order is available in lookup table */ + void SetPointsAndWeights() override; /*!< @brief reads in n_points gridpoints and -weights from given filename. */ - virtual void SetAvailOrders() = 0; /*! @brief Sets vector with avaialbe Orders and corresponding vector with Nq. */ + virtual void SetAvailOrders() = 0; /*!< @brief Sets vector with avaialbe Orders and corresponding vector with Nq. */ - virtual std::string GetLookupTable() = 0; /*! @brief returns lookuptable of _order. Assumes order is available */ + virtual std::string GetLookupTable() = 0; /*!< @brief returns lookuptable of _order. Assumes order is available */ - std::vector _availableOrders; /*! @brief: Vector with available orders for lookup table */ - std::vector _nqByOrder; /*! @brief: Vector with number of quadrature points of each listed order */ + std::vector _availableOrders; /*!< @brief Vector with available orders for lookup table */ + std::vector _nqByOrder; /*!< @brief Vector with number of quadrature points of each listed order */ }; #endif // QLOOKUPQUADRATURE_H diff --git a/code/include/quadratures/qproduct.h b/code/include/quadratures/qproduct.h index d18d1ba0663823e8c44e7780bc059677480d9d86..0422b6e59605749e8da1f9f83005caf38c231586 100644 --- a/code/include/quadratures/qproduct.h +++ b/code/include/quadratures/qproduct.h @@ -1,5 +1,5 @@ /*! @file: qproduct.h - * @brief: Product quadrature implementation. Implementation is done accordingly to Kendall Atkinson 1981, Australian Matematical Society. + * @brief Product quadrature implementation. Implementation is done accordingly to Kendall Atkinson 1981, Australian Matematical Society. * @author: J. Kusch */ diff --git a/code/include/quadratures/quadraturebase.h b/code/include/quadratures/quadraturebase.h index 01e73fdc0eb8d8e1e98af865bcf0f57037a6538a..23678180ea7f1ef6a282ead19bd26ce957ad068f 100644 --- a/code/include/quadratures/quadraturebase.h +++ b/code/include/quadratures/quadraturebase.h @@ -1,5 +1,5 @@ /*! @file: quadraturebase.h - * @brief: Base class for all quadrature rules in KiT-RT + * @brief Base class for all quadrature rules in KiT-RT * @author: S. Schotthöfer */ @@ -14,50 +14,50 @@ class Config; class QuadratureBase { public: - /*! @brief: Constructor using settings class. This is the recommended constructor. - * @param: Config* settings: Settings class storing all important options. + /*! @brief Constructor using settings class. This is the recommended constructor. + * @param settings Settings class storing all important options. */ QuadratureBase( Config* settings ); - /*! @brief: Constructor using directly the order of the quadrature. Not applicable for GaussLegendre, that need additional options. + /*! @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 - void PrintWeights(); /*! @brief prints: Weight vector */ - void PrintPoints(); /*! @brief prints: Point vectorVector */ - void PrintPointsAndWeights(); /*! @brief prints: Point vectorVector with corresponding weight vector */ + void PrintWeights(); /*!< @brief prints: Weight vector */ + void PrintPoints(); /*!< @brief prints: Point vectorVector */ + void PrintPointsAndWeights(); /*!< @brief prints: Point vectorVector with corresponding weight vector */ /*! @brief sums up all entries of the weight vector. * @returns sum of all weights */ double SumUpWeights(); /*! @brief Integrates f(x,y,z) with the quadrature. - * @param double(f)( double x0, double x1, double x2 ) : density function that depends on a three spatial dimensions. - * @returns double result: result of the quadrature rule */ - virtual double Integrate( double( f )( double x0, double x1, double x2 ) ); + * @param f density function that depends on a three spatial dimensions. + * @returns result of the quadrature rule */ + virtual double Integrate( double ( *f )( double, double, double ) ); /*! @brief Integrates f(x,y,z) with the quadrature. - * @param double(f)( double my, double phi ) : density function that depends on a spherical coordinates. - * @returns double result: result of the quadrature rule */ - virtual double IntegrateSpherical( double( f )( double my, double phi ) ); + * @param f density function that depends on a spherical coordinates. + * @returns result of the quadrature rule */ + virtual double IntegrateSpherical( double ( *f )( double, double ) ); /*! @brief Integrates vector valued f(x,y,z) with the quadrature. Each dimension is integrated by itself. - * @param : double(f)( double x0, double x1, double x2 ) : density function that depends on a three spatial dimensions. - * @param : len : lenght of vector - * @returns double result: result of the quadrature rule (vector valued) */ - virtual std::vector Integrate( std::vector( f )( double x0, double x1, double x2 ), unsigned len ); + * @param f density function that depends on a three spatial dimensions. + * @param len lenght of vector + * @returns result of the quadrature rule (vector valued) */ + virtual std::vector Integrate( std::vector ( *f )( double, double, double ), unsigned len ); // Quadrature Hub /*! @brief Creates a quadrature rule with a given name and a given order. - * @param: Config* settings: Settings to handle quadrature options + * @param settings Settings to handle quadrature options * @returns Quadrature* quadrature: returns pointer to instance of the given derived quadrature class */ 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 */ + * @param name name of quadrature as enum + * @param quadOrder order of quadrature + * @returns pointer to instance of the given derived quadrature class */ static QuadratureBase* Create( QUAD_NAME name, unsigned quadOrder ); // Getter @@ -76,9 +76,9 @@ class QuadratureBase protected: // Setter inline void SetOrder( unsigned order ) { _order = order; } /*! @brief sets: order of the quadrature */ - virtual void SetName() = 0; /*! @brief Sets: name of the quadrature */ - virtual void SetNq() = 0; /*! @brief sets: number of gridpoints of the quadrature */ - virtual void SetConnectivity() = 0; /*! @brief sets: Connectivity Adjacency Matrix as VektorVektor*/ + virtual void SetName() = 0; /*!< @brief Sets: name of the quadrature */ + virtual void SetNq() = 0; /*!< @brief sets: number of gridpoints of the quadrature */ + virtual void SetConnectivity() = 0; /*!< @brief sets: Connectivity Adjacency Matrix as VektorVektor*/ /*! @brief Computes the a vector (length: nq) of (coordinates of) gridpoints used for the quadrature rule. * Computes the a vector (length: nq) of weights for the gridpoints. The indices match the gridpoints VectorVector. @@ -86,14 +86,14 @@ class QuadratureBase virtual void SetPointsAndWeights() = 0; // Member variables - Config* _settings; /*! @brief pointer to settings class that manages the solver */ - std::string _name; /*! @brief name of the quadrature */ - unsigned _order; /*! @brief order of the quadrature */ - unsigned _nq; /*! @brief number of gridpoints of the quadrature */ - VectorVector _points; /*! @brief gridpoints of the quadrature */ - VectorVector _pointsSphere; /*! @brief (my,phi)gridpoints of the quadrature in spherical cordinates */ - Vector _weights; /*! @brief weights of the gridpoints of the quadrature */ - VectorVectorU _connectivity; /*! @brief connectivity of the gripoints of the quadrature */ + Config* _settings; /*!< @brief pointer to settings class that manages the solver */ + std::string _name; /*!< @brief name of the quadrature */ + unsigned _order; /*!< @brief order of the quadrature */ + unsigned _nq; /*!< @brief number of gridpoints of the quadrature */ + VectorVector _points; /*!< @brief gridpoints of the quadrature */ + VectorVector _pointsSphere; /*!< @brief (my,phi)gridpoints of the quadrature in spherical cordinates */ + Vector _weights; /*!< @brief weights of the gridpoints of the quadrature */ + VectorVectorU _connectivity; /*!< @brief connectivity of the gripoints of the quadrature */ }; #endif // QUADRATURE_H diff --git a/code/include/solvers/csdsnsolver.h b/code/include/solvers/csdsnsolver.h index a972ed4d272070d002c15fba40b3ab6b9babd0dc..a939e7cafe68ba34b4b4d86d721d949c18c67b16 100644 --- a/code/include/solvers/csdsnsolver.h +++ b/code/include/solvers/csdsnsolver.h @@ -6,14 +6,14 @@ class CSDSNSolver : public SNSolver { private: - std::vector _dose; /*! @brief: TODO */ + std::vector _dose; /*!< @brief TODO */ // Physics acess - Vector _energies; /*! @brief: energy levels for CSD, lenght = _nEnergies */ - Vector _angle; /*! @brief: angles for SN */ + Vector _energies; /*!< @brief energy levels for CSD, lenght = _nEnergies */ + Vector _angle; /*!< @brief angles for SN */ - std::vector _sigmaSE; /*! @brief scattering cross section for all energies*/ - Vector _sigmaTE; /*! @brief total cross section for all energies*/ + std::vector _sigmaSE; /*!< @brief scattering cross section for all energies*/ + Vector _sigmaTE; /*!< @brief total cross section for all energies*/ public: /** diff --git a/code/include/solvers/csdsnsolverfp.h b/code/include/solvers/csdsnsolverfp.h index f1fd1ee55f3afb488034e9925e10103213e99e07..a6aaa99201f378687f815e7ab116d58f540b3661 100644 --- a/code/include/solvers/csdsnsolverfp.h +++ b/code/include/solvers/csdsnsolverfp.h @@ -8,27 +8,27 @@ class Physics; class CSDSNSolverFP : public SNSolver { private: - std::vector _dose; /*! @brief: TODO */ + std::vector _dose; /*!< @brief TODO */ // Physics acess - Vector _energies; /*! @brief: energy levels for CSD, length = _nEnergies */ - Vector _angle; /*! @brief: angles for SN */ + Vector _energies; /*!< @brief energy levels for CSD, length = _nEnergies */ + Vector _angle; /*!< @brief angles for SN */ - std::vector _sigmaSE; /*! @brief scattering cross section for all energies*/ - Vector _sigmaTE; /*! @brief total cross section for all energies*/ + std::vector _sigmaSE; /*!< @brief scattering cross section for all energies*/ + Vector _sigmaTE; /*!< @brief total cross section for all energies*/ - Matrix _L; /*! @brief Laplace Beltrami Matrix */ - Matrix _IL; /*! @brief Laplace Beltrami Matrix */ + Matrix _L; /*!< @brief Laplace Beltrami Matrix */ + 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 _alpha; /*!< @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 */ + bool _RT; /*!< @brief radiotherapy application (on/off), if true use crosssections + stopping powers from database */ - double _energyMin; /*! @brief minimal energy in energy grid*/ - double _energyMax; /*! @brief maximal energy in energy grid*/ + double _energyMin; /*!< @brief minimal energy in energy grid*/ + double _energyMax; /*!< @brief maximal energy in energy grid*/ public: /** diff --git a/code/include/solvers/csdsnsolvernotrafo.h b/code/include/solvers/csdsnsolvernotrafo.h index a2e8f0eb087601110bf9d966fb4837edbd965246..4de19f093a9744fc3b45fe11aa73b668d264dfcd 100644 --- a/code/include/solvers/csdsnsolvernotrafo.h +++ b/code/include/solvers/csdsnsolvernotrafo.h @@ -8,14 +8,14 @@ class Physics; class CSDSNSolverNoTrafo : public SNSolver { private: - std::vector _dose; /*! @brief: TODO */ + std::vector _dose; /*!< @brief TODO */ // Physics acess - Vector _energies; /*! @brief: energy levels for CSD, lenght = _nEnergies */ - Vector _angle; /*! @brief: angles for SN */ + Vector _energies; /*!< @brief energy levels for CSD, lenght = _nEnergies */ + Vector _angle; /*!< @brief angles for SN */ - std::vector _sigmaSE; /*! @brief scattering cross section for all energies*/ - Vector _sigmaTE; /*! @brief total cross section for all energies*/ + std::vector _sigmaSE; /*!< @brief scattering cross section for all energies*/ + Vector _sigmaTE; /*!< @brief total cross section for all energies*/ public: /** diff --git a/code/include/solvers/csdsolvertrafofp.h b/code/include/solvers/csdsolvertrafofp.h index fe42ec93a3f38fa7807bd23f4b514b6d635798a5..1cda2f759de4c2be67f23adfccd1ff95ee7e2a22 100644 --- a/code/include/solvers/csdsolvertrafofp.h +++ b/code/include/solvers/csdsolvertrafofp.h @@ -8,39 +8,39 @@ class Physics; class CSDSolverTrafoFP : public SNSolver { private: - std::vector _dose; /*! @brief: TODO */ + std::vector _dose; /*!< @brief TODO */ // Physics acess - Vector _energies; /*! @brief: energy levels for CSD, lenght = _nEnergies */ - Vector _angle; /*! @brief: angles for SN */ + Vector _energies; /*!< @brief energy levels for CSD, lenght = _nEnergies */ + Vector _angle; /*!< @brief angles for SN */ - std::vector _sigmaSE; /*! @brief scattering cross section for all energies*/ - Vector _sigmaTE; /*! @brief total cross section for all energies*/ + std::vector _sigmaSE; /*!< @brief scattering cross section for all energies*/ + Vector _sigmaTE; /*!< @brief total cross section for all energies*/ - Matrix _L; /*! @brief Laplace Beltrami Matrix */ - Matrix _IL; /*! @brief Laplace Beltrami Matrix */ + 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 _alpha2; /*! @brief Coefficient of GFP operators (see Olbrant 2010, Appendix B)*/ - double _beta; /*! @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)*/ - 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 */ + bool _RT; /*!< @brief radiotherapy application (on/off), if true use crosssections + stopping powers from database */ - double _energyMin; /*! @brief minimal energy in energy grid*/ - double _energyMax; /*! @brief maximal energy in energy grid*/ + double _energyMin; /*!< @brief minimal energy in energy grid*/ + double _energyMax; /*!< @brief maximal energy in energy grid*/ void GenerateEnergyGrid( bool refinement ); // Helper variables - Vector _energiesOrig; /*! @brief: original energy levels for CSD, lenght = _nEnergies */ - Matrix _identity; /*! @brif: identity matrix for FP scattering. Dim (_nq,_nq)*/ + Vector _energiesOrig; /*!< @brief original energy levels for CSD, lenght = _nEnergies */ + Matrix _identity; /*!< @brief: identity matrix for FP scattering. Dim (_nq,_nq)*/ public: /** @@ -60,7 +60,7 @@ class CSDSolverTrafoFP : public SNSolver void FVMUpdate( unsigned idx_energy ) override final; void FluxUpdate() override final; void IterPreprocessing( unsigned idx_pseudotime ) override final; - void virtual IterPostprocessing() override final; + void virtual IterPostprocessing( unsigned idx_pseudotime ) override final; void SolverPreprocessing() override final; }; diff --git a/code/include/solvers/csdsolvertrafofp2d.h b/code/include/solvers/csdsolvertrafofp2d.h index 453119488e9954cb0286e34dd9cfb17d9272c9b8..fe01331002297ce68441a3d4dc6d79af55c262c6 100644 --- a/code/include/solvers/csdsolvertrafofp2d.h +++ b/code/include/solvers/csdsolvertrafofp2d.h @@ -8,17 +8,17 @@ class Physics; class CSDSolverTrafoFP2D : public SNSolver { private: - std::vector _dose; /*! @brief: TODO */ + std::vector _dose; /*!< @brief TODO */ // Physics acess - Vector _energies; /*! @brief: energy levels for CSD, lenght = _nEnergies */ - Vector _angle; /*! @brief: angles for SN */ + Vector _energies; /*!< @brief energy levels for CSD, lenght = _nEnergies */ + Vector _angle; /*!< @brief angles for SN */ - std::vector _sigmaSE; /*! @brief scattering cross section for all energies*/ - Vector _sigmaTE; /*! @brief total cross section for all energies*/ + std::vector _sigmaSE; /*!< @brief scattering cross section for all energies*/ + Vector _sigmaTE; /*!< @brief total cross section for all energies*/ - Matrix _L; /*! @brief Laplace Beltrami Matrix */ - Matrix _IL; /*! @brief Laplace Beltrami Matrix */ + Matrix _L; /*!< @brief Laplace Beltrami Matrix */ + Matrix _IL; /*!< @brief Laplace Beltrami Matrix */ VectorVector _quadPoints; VectorVector _quadPointsSphere; @@ -44,9 +44,9 @@ class CSDSolverTrafoFP2D : public SNSolver double _energyMax; // Helper variables - Vector _energiesOrig; /*! @brief: original energy levels for CSD, lenght = _nEnergies */ - Matrix _identity; /*! @brif: identity matrix for FP scattering. Dim (_nq,_nq)*/ - double _densityMin; /*! @brief: Minimal density of _density vector */ + Vector _energiesOrig; /*!< @brief original energy levels for CSD, lenght = _nEnergies */ + Matrix _identity; /*!< @brief: identity matrix for FP scattering. Dim (_nq,_nq)*/ + double _densityMin; /*!< @brief Minimal density of _density vector */ void GenerateEnergyGrid( bool refinement ); @@ -72,7 +72,7 @@ class CSDSolverTrafoFP2D : public SNSolver void FVMUpdate( unsigned idx_energy ) override final; void FluxUpdate() override final; void IterPreprocessing( unsigned idx_pseudotime ) override final; - void virtual IterPostprocessing() override final; + void virtual IterPostprocessing( unsigned idx_pseudotime ) override final; void SolverPreprocessing() override final; }; diff --git a/code/include/solvers/csdsolvertrafofpsh2d.h b/code/include/solvers/csdsolvertrafofpsh2d.h index 51fb4eadbf0de596ed9b0624f3e37090c8a5704b..c10910a41826a8d9726735b5f80d4d555e481cdd 100644 --- a/code/include/solvers/csdsolvertrafofpsh2d.h +++ b/code/include/solvers/csdsolvertrafofpsh2d.h @@ -19,17 +19,17 @@ class Physics; class CSDSolverTrafoFPSH2D : public SNSolver { private: - std::vector _dose; /*! @brief: TODO */ + std::vector _dose; /*!< @brief TODO */ // Physics acess - Vector _energies; /*! @brief: energy levels for CSD, lenght = _nEnergies */ - Vector _angle; /*! @brief: angles for SN */ + Vector _energies; /*!< @brief energy levels for CSD, lenght = _nEnergies */ + Vector _angle; /*!< @brief angles for SN */ - std::vector _sigmaSE; /*! @brief scattering cross section for all energies*/ - Vector _sigmaTE; /*! @brief total cross section for all energies*/ + std::vector _sigmaSE; /*!< @brief scattering cross section for all energies*/ + Vector _sigmaTE; /*!< @brief total cross section for all energies*/ - Matrix _L; /*! @brief Laplace Beltrami Matrix */ - Matrix _IL; /*! @brief Laplace Beltrami Matrix */ + Matrix _L; /*!< @brief Laplace Beltrami Matrix */ + Matrix _IL; /*!< @brief Laplace Beltrami Matrix */ Matrix _O; Matrix _S; @@ -59,9 +59,9 @@ class CSDSolverTrafoFPSH2D : public SNSolver double _energyMax; // Helper variables - Vector _energiesOrig; /*! @brief: original energy levels for CSD, lenght = _nEnergies */ - Matrix _identity; /*! @brif: identity matrix for FP scattering. Dim (_nq,_nq)*/ - double _densityMin; /*! @brief: Minimal density of _density vector */ + Vector _energiesOrig; /*!< @brief original energy levels for CSD, lenght = _nEnergies */ + Matrix _identity; /*!< @brief: identity matrix for FP scattering. Dim (_nq,_nq)*/ + double _densityMin; /*!< @brief Minimal density of _density vector */ public: /** @@ -89,7 +89,7 @@ class CSDSolverTrafoFPSH2D : public SNSolver void FVMUpdate( unsigned idx_energy ) override final; void FluxUpdate() override final; void IterPreprocessing( unsigned idx_pseudotime ) override final; - void virtual IterPostprocessing() override final; + void virtual IterPostprocessing( unsigned idx_pseudotime ) override final; void SolverPreprocessing() override final; }; diff --git a/code/include/solvers/mnsolver.h b/code/include/solvers/mnsolver.h index 560a5f63b5cf0d14ba14b7b909776f8aedb18c53..683c6b1ae26c8c9c7818c064f8907974f84dd3a6 100644 --- a/code/include/solvers/mnsolver.h +++ b/code/include/solvers/mnsolver.h @@ -7,12 +7,12 @@ class EntropyBase; class SphericalBase; class OptimizerBase; -class MNSolver : public Solver +class MNSolver : public SolverBase { public: /** * @brief MNSolver constructor - * @param settings stores all needed information + * @param settings Config class that stores all needed information */ MNSolver( Config* settings ); @@ -21,57 +21,57 @@ class MNSolver : public Solver private: // --- Private member variables --- - unsigned _nTotalEntries; /*! @brief: Total number of equations in the system */ - unsigned short _LMaxDegree; /*! @brief: Max Order of Spherical Harmonics */ + unsigned _nSystem; /*!< @brief Total number of equations in the system */ + unsigned short _polyDegreeBasis; /*!< @brief Max polynomial degree of the basis */ // Moment basis - SphericalBase* _basis; /*! @brief: Class to compute and store current spherical harmonics basis */ - VectorVector _moments; /*! @brief: Moment Vector pre-computed at each quadrature point: dim= _nq x _nTotalEntries */ + SphericalBase* _basis; /*!< @brief Class to compute and store current spherical harmonics basis */ + VectorVector _moments; /*!< @brief Moment Vector pre-computed at each quadrature point: dim= _nq x _nTotalEntries */ // Scattering - Vector _scatterMatDiag; /*! @brief: Diagonal of the scattering matrix (its a diagonal matrix by construction) */ + Vector _scatterMatDiag; /*!< @brief Diagonal of the scattering matrix (its a diagonal matrix by construction) */ // Quadrature related members - VectorVector _quadPoints; /*! @brief quadrature points, dim(_quadPoints) = (_nq,spatialDim) */ - Vector _weights; /*! @brief quadrature weights, dim(_weights) = (_nq) */ - VectorVector _quadPointsSphere; /*! @brief (my,phi), dim(_quadPoints) = (_nq,2) */ + VectorVector _quadPoints; /*!< @brief quadrature points, dim(_quadPoints) = (_nq,spatialDim) */ + Vector _weights; /*!< @brief quadrature weights, dim(_weights) = (_nq) */ + VectorVector _quadPointsSphere; /*!< @brief (my,phi), dim(_quadPoints) = (_nq,2) */ // Entropy Optimization related members - EntropyBase* _entropy; /*! @brief: Class to handle entropy functionals */ - VectorVector _alpha; /*! @brief: Lagrange Multipliers for Minimal Entropy problem for each gridCell - Layout: _nCells x _nTotalEntries*/ - OptimizerBase* _optimizer; /*! @brief: Class to solve minimal entropy problem */ + EntropyBase* _entropy; /*!< @brief Class to handle entropy functionals */ + VectorVector _alpha; /*!< @brief Lagrange Multipliers for Minimal Entropy problem for each gridCell + Layout: _nCells x _nTotalEntries*/ + OptimizerBase* _optimizer; /*!< @brief Class to solve minimal entropy problem */ - VectorVector _solDx; /*! @brief: temporary storage of x-derivatives of alpha */ - VectorVector _solDy; /*! @brief: temporary storage of y-derivatives of alpha */ + VectorVector _solDx; /*!< @brief temporary storage of x-derivatives of alpha */ + VectorVector _solDy; /*!< @brief temporary storage of y-derivatives of alpha */ // ---- Private Member functions --- // IO void PrepareVolumeOutput() override; - void WriteVolumeOutput( unsigned idx_pseudoTime ) override; + void WriteVolumeOutput( unsigned idx_iter ) override; // Solver - void FVMUpdate( unsigned idx_energy ) override; + void FVMUpdate( unsigned idx_iter ) override; void FluxUpdate() override; - void IterPreprocessing( unsigned idx_pseudotime ) override; - void IterPostprocessing(); - /*! @brief : Construct flux by computing the Moment of the sum of FVM discretization at the interface of cell - * @param : idx_cell = current cell id - * @returns : sum over all neighbors of flux for all moments at interface of idx_cell, idx_neighbor */ + void IterPreprocessing( unsigned /*idx_iter*/ ) override; + void IterPostprocessing( unsigned /*idx_iter*/ ) override; + /*! @brief Construct flux by computing the Moment of the sum of FVM discretization at the interface of cell + * @param idx_cell current cell id + * @returns sum over all neighbors of flux for all moments at interface of idx_cell, idx_neighbor */ Vector ConstructFlux( unsigned idx_cell ); /*! @brief Corrects the solution _sol[idx_cell] to be realizable w.r.t. the reconstructed entropy (eta'(alpha*m)) - @param idx_cell = cell where the correction happens*/ + @param idx_cell cell where the correction happens*/ void ComputeRealizableSolution( unsigned idx_cell ); // Initialization of the solver - /*! @brief : Pre-Compute Moments at all quadrature points. */ + /*! @brief Pre-Compute Moments at all quadrature points. */ void ComputeMoments(); - /*! @brief: fucntion for computing and setting up EV matrix for scattering kernel */ + /*! @brief Function for computing and setting up EV matrix for scattering kernel */ void ComputeScatterMatrix(); // Helper - /*! @brief: Computes the radiative flux from the solution vector of the moment system */ - void ComputeRadFlux(); + /*! @brief Computes the radiative flux from the solution vector of the moment system */ + void ComputeRadFlux() override; }; #endif // MNSOLVER_H diff --git a/code/include/solvers/pnsolver.h b/code/include/solvers/pnsolver.h index 188af181730c1b10c3924704d1626daf8e797aa7..f9bd715f21084b498e6a75d84275bc5ba6a3be0b 100644 --- a/code/include/solvers/pnsolver.h +++ b/code/include/solvers/pnsolver.h @@ -3,7 +3,7 @@ #include "solvers/solverbase.h" -class PNSolver : public Solver +class PNSolver : public SolverBase { public: /*! @brief PNSolver constructor @@ -15,96 +15,135 @@ class PNSolver : public Solver virtual ~PNSolver() {} private: - unsigned _nTotalEntries; /*! @brief: total number of equations in the system */ - unsigned _LMaxDegree; /*! @brief: maximal degree of the spherical harmonics basis*/ + unsigned _nSystem; /*!< @brief total number of equations in the system */ + unsigned _polyDegreeBasis; /*!< @brief maximal degree of the spherical harmonics basis*/ // System Matrix for x, y and z flux // ==> not needed after computation of A+ and A- ==> maybe safe only temporarly and remove as member? - SymMatrix _Ax; /*! @brief: Flux Jacbioan in x direction */ - SymMatrix _Ay; /*! @brief: Flux Jacbioan in x direction */ - SymMatrix _Az; /*! @brief: Flux Jacbioan in x direction */ + SymMatrix _Ax; /*!< @brief Flux Jacbioan in x direction */ + SymMatrix _Ay; /*!< @brief Flux Jacbioan in x direction */ + SymMatrix _Az; /*!< @brief Flux Jacbioan in x direction */ // Upwinding Matrices - Matrix _AxPlus; /*! @brief: Flux Jacbioan in x direction, positive part */ - Matrix _AxMinus; /*! @brief: Flux Jacbioan in x direction, negative part */ - Matrix _AxAbs; /*! @brief: Flux Jacbioan in x direction, absolute part */ - Matrix _AyPlus; /*! @brief: Flux Jacbioan in y direction, positive part */ - Matrix _AyMinus; /*! @brief: Flux Jacbioan in y direction, negative part */ - Matrix _AyAbs; /*! @brief: Flux Jacbioan in y direction, absolute part */ - Matrix _AzPlus; /*! @brief: Flux Jacbioan in z direction, positive part */ - Matrix _AzMinus; /*! @brief: Flux Jacbioan in z direction, negative part */ - Matrix _AzAbs; /*! @brief: Flux Jacbioan in z direction, absolute part */ - - Vector _scatterMatDiag; /*! @brief: diagonal of the scattering matrix (its a diagonal matrix by construction). Contains eigenvalues of the + Matrix _AxPlus; /*!< @brief Flux Jacbioan in x direction, positive part */ + Matrix _AxMinus; /*!< @brief Flux Jacbioan in x direction, negative part */ + Matrix _AxAbs; /*!< @brief Flux Jacbioan in x direction, absolute part */ + Matrix _AyPlus; /*!< @brief Flux Jacbioan in y direction, positive part */ + Matrix _AyMinus; /*!< @brief Flux Jacbioan in y direction, negative part */ + Matrix _AyAbs; /*!< @brief Flux Jacbioan in y direction, absolute part */ + Matrix _AzPlus; /*!< @brief Flux Jacbioan in z direction, positive part */ + Matrix _AzMinus; /*!< @brief Flux Jacbioan in z direction, negative part */ + Matrix _AzAbs; /*!< @brief Flux Jacbioan in z direction, absolute part */ + + Vector _scatterMatDiag; /*!< @brief diagonal of the scattering matrix (its a diagonal matrix by construction). Contains eigenvalues of the scattering kernel. */ - VectorVector _solDx; /*! @brief: temporary storage of x-derivatives of solution */ - VectorVector _solDy; /*! @brief: temporary storage of y-derivatives of solution */ + VectorVector _solDx; /*!< @brief Temporary storage of x-derivatives of solution */ + VectorVector _solDy; /*!< @brief Temporary storage of y-derivatives of solution */ // ---- Member functions ---- // IO - /*! @brief Initializes the output groups and fields of this solver and names the fields */ void PrepareVolumeOutput() override; - /*! @brief Function that prepares VTK export and csv export of the current solver iteration - @returns: Mass of current iteration */ void WriteVolumeOutput( unsigned idx_pseudoTime ) override; // Solver void FVMUpdate( unsigned idx_energy ) override; void FluxUpdate() override; void IterPreprocessing( unsigned idx_pseudotime ) override; - void IterPostprocessing(); + void IterPostprocessing( unsigned idx_pseudotime ) override; // Helper - void ComputeRadFlux(); + void ComputeRadFlux() override; // Initialization of the Solver - /*! @brief: parameter functions for setting up system matrix - * @param: degree l, it must hold: 0 <= l <=_nq - * @param : order k, it must hold: -l <=k <= l + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l */ double AParam( int l, int k ) const; + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l + */ double BParam( int l, int k ) const; + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l + */ double CParam( int l, int k ) const; + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l + */ double DParam( int l, int k ) const; + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l + */ double EParam( int l, int k ) const; + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l + */ double FParam( int l, int k ) const; + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l + */ double CTilde( int l, int k ) const; + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l + */ double DTilde( int l, int k ) const; + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l + */ double ETilde( int l, int k ) const; + /*! @brief parameter functions for setting up system matrix + * @param l degree , it must hold: 0 <= l <=_nq + * @param k order , it must hold: -l <=k <= l + */ double FTilde( int l, int k ) const; - /*! @brief: mathematical + index functions. Helper functions for setting up system matrix. - * @param: k: arbitrary integer + /*! @brief mathematical + index functions. Helper functions for setting up system matrix. + * @param k: arbitrary integer */ int Sgn( int k ) const; + /*! @brief mathematical + index functions. Helper functions for setting up system matrix. + * @param k arbitrary integer + */ int kPlus( int k ) const; + /*! @brief mathematical + index functions. Helper functions for setting up system matrix. + * @param k arbitrary integer + */ int kMinus( int k ) const; - /*! @brief : computes the global index of the moment corresponding to basis function (l,k) - * @param : degree l, it must hold: 0 <= l <=_nq - * @param : order k, it must hold: -l <=k <= l - * @returns : global index + /*! @brief computes the global index of the moment corresponding to basis function (l,k) + * @param l degree l, it must hold: 0 <= l <=_nq + * @param k order k, it must hold: -l <=k <= l + * @returns global index */ int GlobalIndex( int l, int k ) const; - /*! @brief : Checks, if index invariant for global index holds - * @returns : True, if invariant holds, else false + /*! @brief Checks, if index invariant for global index holds + * @returns True, if invariant holds, else false */ bool CheckIndex( int l, int k ) const; - /*! @brief: function for computing and setting up system matrices */ + /*! @brief Function for computing and setting up system matrices */ void ComputeSystemMatrices(); - /*! @brief: function for computing and setting up flux matrices for upwinding */ + /*! @brief Function for computing and setting up flux matrices for upwinding */ void ComputeFluxComponents(); - /*! @brief: fucntion for computing and setting up EV matrix for scattering kernel */ + /*! @brief Function for computing and setting up EV matrix for scattering kernel */ void ComputeScatterMatrix(); - /*! @brief: Computes Legedre polinomial of oder l at point x */ + /*! @brief Computes Legedre polinomial of oder l at point x */ double LegendrePoly( double x, int l ); - /*! @brief: Sets Entries of FluxMatrices to zero, if they are below double precision, + /*! @brief Sets Entries of FluxMatrices to zero, if they are below double precision, * to prevent floating point inaccuracies later in the solver */ void CleanFluxMatrices(); diff --git a/code/include/solvers/snsolver.h b/code/include/solvers/snsolver.h index b52711926e61719894ccc2e319d48c02b7c745b4..a1f82e1a8c1377c177068e247e1df916103d3313 100644 --- a/code/include/solvers/snsolver.h +++ b/code/include/solvers/snsolver.h @@ -3,15 +3,15 @@ #include "solvers/solverbase.h" -class SNSolver : public Solver +class SNSolver : public SolverBase { protected: - Matrix _scatteringKernel; /*! @brief scattering kernel for the quadrature */ + Matrix _scatteringKernel; /*!< @brief scattering kernel for the quadrature */ // quadrature related numbers - VectorVector _quadPoints; /*! @brief quadrature points, dim(_quadPoints) = (_nq,spatialDim) */ - Vector _weights; /*! @brief quadrature weights, dim(_weights) = (_nq) */ + VectorVector _quadPoints; /*!< @brief quadrature points, dim(_quadPoints) = (_nq,spatialDim) */ + Vector _weights; /*!< @brief quadrature weights, dim(_weights) = (_nq) */ public: /*! @brief SNSolver constructor @@ -30,10 +30,10 @@ class SNSolver : public Solver void virtual FVMUpdate( unsigned idx_energy ) override; void virtual FluxUpdate() override; void virtual IterPreprocessing( unsigned idx_pseudotime ) override; - void virtual IterPostprocessing() override; + void virtual IterPostprocessing( unsigned idx_pseudotime ) override; // Helper - void ComputeRadFlux(); + void ComputeRadFlux() override; // --- Member variables --- }; diff --git a/code/include/solvers/solverbase.h b/code/include/solvers/solverbase.h index b536004eef8e369e216afe95eb2ba76af3e5aa1c..ac1a76eb2303053d6956b8df4775e72ad6266cff 100644 --- a/code/include/solvers/solverbase.h +++ b/code/include/solvers/solverbase.h @@ -16,114 +16,120 @@ class ProblemBase; class QuadratureBase; class Reconstructor; -class Solver +/*! @brief Base class for all solvers. */ +class SolverBase { protected: - Mesh* _mesh; /*! @brief mesh object for writing out information */ - NumericalFlux* _g; /*! @brief class for numerical flux */ - Config* _settings; /*! @brief config class for global information */ - ProblemBase* _problem; /*! @brief problem class for initial conditions */ + NumericalFlux* _g; /*!< @brief class for numerical flux */ + Config* _settings; /*!< @brief config class for global information */ + ProblemBase* _problem; /*!< @brief problem class for initial conditions */ // --------- Often used variables of member classes for faster access ---- - unsigned _nEnergies; /*! @brief number of energysteps, number of nodal energy values for CSD */ - unsigned _maxIter; /*! @brief number of time steps, for non CSD, this equals _nEnergies, for _csd, _maxIter = _nEnergies-1*/ + // Time or Energystepping + unsigned _maxIter; /*!< @brief number of time steps, for non CSD, this equals _nEnergies, for _csd, _maxIter = _nEnergies-1*/ + unsigned _nEnergies; /*!< @brief number of energysteps, number of nodal energy values for CSD */ + double _dE; /*!< @brief energy/time step size */ + Vector _energies; /*!< @brief energy groups used in the simulation [keV] */ - double _dE; /*! @brief energy/time step size */ - Vector _energies; // energy groups used in the simulation [keV] - std::vector _density; // patient density, dim(_density) = _nCells - Vector _s; // stopping power, dim(_s) = _nTimeSteps (only for csdsolver) - std::vector _Q; /*! @brief external source term */ - - VectorVector _sigmaS; /*! @brief scattering cross section for all energies. len: _nEnergies x numCells */ - VectorVector _sigmaT; /*! @brief total cross section for all energies. len: _nEnergies x numCells*/ + // Mesh related members + Mesh* _mesh; /*!< @brief mesh object for writing out information */ + unsigned _nCells; /*!< @brief number of spatial cells */ + std::vector _boundaryCells; /*!< @brief boundary type for all cells, dim(_boundary) = (_NCells) */ + std::vector _areas; /*!< @brief surface area of all spatial cells, dim(_areas) = _NCells */ + std::vector> + _normals; /*!< @brief edge normals multiplied by edge length, dim(_normals) = (_NCells,nEdgesPerCell,spatialDim) */ + std::vector> _neighbors; /*!< @brief edge neighbor cell ids, dim(_neighbors) = (_NCells,nEdgesPerCell) */ - // quadrature related numbers - QuadratureBase* _quadrature; /*! @brief quadrature to create members below */ - unsigned _nq; /*! @brief number of quadrature points */ + // slope related params + Reconstructor* _reconstructor; /*!< @brief reconstructor object for high-order scheme */ + unsigned _reconsOrder; /*!< @brief reconstruction order (current: 1 & 2) */ + VectorVector _psiDx; /*!< @brief slope of solutions in X direction */ + VectorVector _psiDy; /*!< @brief slope of solutions in Y direction */ + VectorVector _cellMidPoints; /*!< @brief middle point locations of elements */ + std::vector> _interfaceMidPoints; /*!< @brief middle point locations of edges */ - // VectorVector _quadPoints; /*! @brief quadrature points, dim(_quadPoints) = (_nSystem,spatialDim) */ - // Vector _weights; /*! @brief quadrature weights, dim(_weights) = (_NCells) */ + std::vector _density; /*!< @brief patient density, dim(_density) = _nCells (only for csdsolver) */ + Vector _s; /*!< @brief stopping power, dim(_s) = _maxIter (only for csdsolver) */ - // Mesh related members - unsigned _nCells; /*! @brief number of spatial cells */ - std::vector _boundaryCells; /*! boundary type for all cells, dim(_boundary) = (_NCells) */ - std::vector _areas; /*! @brief surface area of all spatial cells, dim(_areas) = _NCells */ - /*! @brief edge normals multiplied by edge length, dim(_normals) = (_NCells,nEdgesPerCell,spatialDim) */ - std::vector> _normals; - /*! @brief edge neighbor cell ids, dim(_neighbors) = (_NCells,nEdgesPerCell) */ - std::vector> _neighbors; + std::vector _Q; /*!< @brief external source term. Dim(_Q) = _maxIter x (_nCells x _nSystem) */ + VectorVector _sigmaS; /*!< @brief scattering cross section for all energies. len: _nEnergies x _nCells */ + VectorVector _sigmaT; /*!< @brief total cross section for all energies. len: _nEnergies x _nCells*/ - // slope related params - Reconstructor* _reconstructor; /*! @brief reconstructor object for high-order scheme */ - unsigned _reconsOrder; /*! @brief reconstruction order (current: 1 & 2) */ - VectorVector _psiDx; /*! @brief slope of solutions in X direction */ - VectorVector _psiDy; /*! @brief slope of solutions in Y direction */ - VectorVector _cellMidPoints; /*! @brief middle point locations of elements */ - std::vector> _interfaceMidPoints; /*! @brief middle point locations of edges */ + // quadrature related numbers + QuadratureBase* _quadrature; /*!< @brief pointer to quadrature class */ + unsigned _nq; /*!< @brief number of quadrature points */ // Solution related members - VectorVector _sol; /*! @brief solution of the PDE, e.g. angular flux or moments */ - std::vector _solverOutput; /*! @brief LEGACY: Outputfield for solver ==> Will be replaced by _outputFields in the near future */ + VectorVector _sol; /*!< @brief solution of the PDE, e.g. angular flux or moments */ + VectorVector _solNew; /*!< @brief VectorVector to store the new flux and later the new solution per iteration */ + Vector _fluxNew; /*!< @brief Vector to store the new Flux. Dim _nCells */ + Vector _flux; /*!< @brief Vector to store the old Flux. Dim _nCells*/ + + std::vector _solverOutput; /*!< @brief LEGACY: Outputfield for solver ==> Will be replaced by _outputFields in the near future */ // Output related members - std::vector>> _outputFields; /*! @brief: Solver Output: dimensions (GroupID,FieldID,CellID).*/ - std::vector> _outputFieldNames; /*! @brief: Names of the outputFields: dimensions (GroupID,FieldID) */ + std::vector>> _outputFields; /*!< @brief Solver Output: dimensions (GroupID,FieldID,CellID).*/ + std::vector> _outputFieldNames; /*!< @brief Names of the outputFields: dimensions (GroupID,FieldID) */ // we will have to add a further dimension for quadPoints and weights once we start with multilevel SN // Output related members - std::vector _screenOutputFields; /*! @brief: Solver Output: dimensions (FieldID). */ - std::vector _screenOutputFieldNames; /*! @brief: Names of the outputFields: dimensions (FieldID) */ + std::vector _screenOutputFields; /*!< @brief Solver Output: dimensions (FieldID). */ + std::vector _screenOutputFieldNames; /*!< @brief Names of the outputFields: dimensions (FieldID) */ // Output related members - std::vector _historyOutputFields; /*! @brief: Solver Output: dimensions (FieldID). */ - std::vector _historyOutputFieldNames; /*! @brief: Names of the outputFields: dimensions (FieldID) */ - - // Internal Members - VectorVector _solNew; /*! @brief: VectorVector to store the new flux and later the new solution per iteration */ // REPLACES psiNEW - Vector _fluxNew; /*! @brief: Vector to store the new Flux. Dim _nCells */ - Vector _flux; /*! @brief: Vector to store the old Flux. Dim _nCells*/ + std::vector _historyOutputFields; /*!< @brief Solver Output: dimensions (FieldID). */ + std::vector _historyOutputFieldNames; /*!< @brief Names of the outputFields: dimensions (FieldID) */ // ---- Member functions ---- // Solver - /*! @brief Performs preprocessing steps before the pseudo time iteration is started */ + /*! @brief Performs preprocessing steps before the pseudo time iteration is started*/ virtual void SolverPreprocessing(); - /*! @brief Performs preprocessing for the current solver iteration */ - virtual void IterPreprocessing( unsigned idx_pseudotime ) = 0; + /*! @brief Performs preprocessing for the current solver iteration + @param idx_iter current (peudo) time iteration */ + virtual void IterPreprocessing( unsigned idx_iter ) = 0; /*! @brief Performs postprocessing for the current solver iteration */ - virtual void IterPostprocessing() = 0; + virtual void IterPostprocessing( unsigned idx_pseudotime ) = 0; /*! @brief Constructs the flux update for the current iteration and stores it in psiNew*/ virtual void FluxUpdate() = 0; - /*! @brief Computes the finite Volume update step for the current iteration */ - virtual void FVMUpdate( unsigned idx_energy ) = 0; + /*! @brief Computes the finite Volume update step for the current iteration + @param idx_iter current (peudo) time iteration */ + virtual void FVMUpdate( unsigned idx_iter ) = 0; // Helper - /*! @brief ComputeTimeStep calculates the maximal stable time step */ + /*! @brief ComputeTimeStep calculates the maximal stable time step using the cfl number + @param cfl Courant-Friedrichs-Levy condition number */ double ComputeTimeStep( double cfl ) const; - /*! @brief: Computes the flux of the solution to check conservation properties */ + /*! @brief Computes the flux of the solution to check conservation properties */ virtual void ComputeRadFlux() = 0; // IO /*! @brief Initializes the output groups and fields of this solver and names the fields */ virtual void PrepareVolumeOutput() = 0; - /*! @brief Function that prepares VTK export and csv export of the current solver iteration */ - virtual void WriteVolumeOutput( unsigned iteration ) = 0; + /*! @brief Function that prepares VTK export and csv export of the current solver iteration + @param idx_iter current (pseudo) time iteration */ + virtual void WriteVolumeOutput( unsigned idx_iter ) = 0; /*! @brief Save Output solution at given energy (pseudo time) to VTK file. Write frequency is given by - option VOLUME_OUTPUT_FREQUENCY. Always prints last iteration without iteration affix.*/ - void PrintVolumeOutput( int currEnergy ) const; - /*! @brief: Initialized the output fields and their Names for the screenoutput */ + option VOLUME_OUTPUT_FREQUENCY. Always prints last iteration without iteration affix. + @param idx_iter current (pseudo) time iteration */ + void PrintVolumeOutput( int idx_iter ) const; + /*! @brief Initialized the output fields and their Names for the screenoutput */ void PrepareScreenOutput(); - /*! @brief Function that writes screen and history output fields */ - void WriteScalarOutput( unsigned iteration ); + + /*! @brief Function that writes screen and history output fields + @param idx_iter current (pseudo) time iteration */ + void WriteScalarOutput( unsigned idx_iter ); /*! @brief Prints ScreenOutputFields to Screen and to logger. Write frequency is given by - option SCREEN_OUTPUT_FREQUENCY. Always prints last iteration. */ - void PrintScreenOutput( unsigned iteration ); - /*! @brief: Initialized the historyOutputFields and their Names for history output. Write frequency is given by + option SCREEN_OUTPUT_FREQUENCY. Always prints last iteration. + @param idx_iter current (pseudo) time iteration */ + void PrintScreenOutput( unsigned idx_iter ); + /*! @brief Initialized the historyOutputFields and their Names for history output. Write frequency is given by option HISTORY_OUTPUT_FREQUENCY. Always prints last iteration. */ void PrepareHistoryOutput(); - /*! @brief Prints HistoryOutputFields to logger */ - void PrintHistoryOutput( unsigned iteration ); + /*! @brief Prints HistoryOutputFields to logger + @param idx_iter current (pseudo) time iteration */ + void PrintHistoryOutput( unsigned idx_iter ); /*! @brief Pre Solver Screen and Logger Output */ void DrawPreSolverOutput(); /*! @brief Post Solver Screen and Logger Output */ @@ -131,17 +137,17 @@ class Solver public: /*! @brief Solver constructor - * @param settings stores all needed information */ - Solver( Config* settings ); + * @param settings config class that stores all needed config information */ + SolverBase( Config* settings ); - virtual ~Solver(); + virtual ~SolverBase(); /*! @brief Create constructor - * @param settings stores all needed information - * @return pointer to Solver */ - static Solver* Create( Config* settings ); + * @param settings config class that stores all needed config information + * @return pointer to SolverBase */ + static SolverBase* Create( Config* settings ); - /*! @brief Solve functions runs main time loop */ + /*! @brief Solve functions runs main iteration loop. Components of the solve loop are pure virtual and subclassed by the child solvers. */ virtual void Solve(); /*! @brief Save Output solution to VTK file */ diff --git a/code/include/toolboxes/datagenerator.h b/code/include/toolboxes/datagenerator.h deleted file mode 100644 index 4592b207ecb8f15b2800e27c77f77649206c5bc3..0000000000000000000000000000000000000000 --- a/code/include/toolboxes/datagenerator.h +++ /dev/null @@ -1,82 +0,0 @@ -/*! - * \file datagenerator.h - * \brief Class to generate data for the neural entropy closure - * \author S. Schotthoefer - */ - -#ifndef DATAGENERATOR_H -#define DATAGENERATOR_H - -#include "common/typedef.h" -#include - -class SphericalBase; -class QuadratureBase; -class Config; -class NewtonOptimizer; -class EntropyBase; - -class nnDataGenerator -{ - public: - /*! @brief: Class constructor. Generates training data for neural network approaches using - * spherical harmonics and an entropy functional and the quadrature specified by - * the options file. - * @param: setSize: number of elements in training set - * basisSize: length of spherical harmonics basis (maybe redundant)*/ - nnDataGenerator( Config* settings ); - ~nnDataGenerator(); - - /*! @brief: computes the training data set. - * Realizable set is sampled uniformly. - * Prototype: 1D, u\in[0,100] */ - void computeTrainingData(); - - /*! @brief: Writes the training data to file - * Filename encryption: [TODO] */ - void writeTrainingDataToCSV(); - - private: - Config* _settings; /*! @brief config class for global information */ - - VectorVector _uSol; /*! @brief: vector with moments. Size: (setSize,basisSize)*/ - VectorVector _alpha; /*! @brief: vector with Lagrange multipliers. Size: (setSize,basisSize)*/ - std::vector _hEntropy; /*! @brief: vector with entropy values. Size: (setSize) */ - - unsigned long _setSize; /*! @brief: Size of the whole training Set */ - unsigned long - _gridSize; /*! @brief: Size of the grid discretizing moment U0 for higher order sampling (has different uses for different samplers)*/ - - unsigned short _LMaxDegree; /*! @brief: Max Order of Spherical Harmonics */ - unsigned _nTotalEntries; /*! @brief: Total number of equations in the system */ - - QuadratureBase* _quadrature; /*! @brief quadrature to create members below */ - unsigned _nq; /*! @brief number of quadrature points */ - VectorVector _quadPoints; /*! @brief quadrature points, dim(_quadPoints) = (_nq,spatialDim) */ - Vector _weights; /*! @brief quadrature weights, dim(_weights) = (_nq) */ - VectorVector _quadPointsSphere; /*! @brief (my,phi), dim(_quadPoints) = (_nq,2) */ - - SphericalBase* _basis; /*! @brief: Class to compute and store current spherical harmonics basis */ - VectorVector _moments; /*! @brief: Moment Vector pre-computed at each quadrature point: dim= _nq x _nTotalEntries */ - - NewtonOptimizer* _optimizer; /*! @brief: Class to solve minimal entropy problem */ - EntropyBase* _entropy; /*! @brief: Class to handle entropy functional evaluations */ - - // Main methods - void SampleSolutionU(); /*! @brief: Samples solution vectors u */ - void ComputeEntropyH_dual(); /*! @brief: Compute the entropy functional at (u,alpha) in dual formulation */ - void ComputeEntropyH_primal(); /*! @brief: Compute the entropy functional at (u,alpha) in primal formulation */ - - // IO routines - void PrintTrainingData(); /*! @brief : Print computed training data to csv file and screen */ - void PrintLoadScreen(); /*! @brief: Print screen IO*/ - // Helper functions - void ComputeMoments(); /*! @brief: Pre-Compute Moments at all quadrature points. */ - void CheckRealizability(); // Debugging helper - void ComputeRealizableSolution(); /*! @brief: make u the realizable moment to alpha, since Newton has roundoff errors. */ - - inline VectorVector GetuSol() { return _uSol; } /*! @brief: Get the computed solution vector uSol */ - inline VectorVector GetAlpha() { return _alpha; } /*! @brief: Get the computed vector alpha */ - inline std::vector GethEntropy() { return _hEntropy; } /*! @brief: Get the computed entropy value h */ -}; -#endif // DATAGENERATOR_H diff --git a/code/include/toolboxes/datagenerator1D.h b/code/include/toolboxes/datagenerator1D.h new file mode 100644 index 0000000000000000000000000000000000000000..8ce73470fe54df1f6f464219e4b5d0313e5449b3 --- /dev/null +++ b/code/include/toolboxes/datagenerator1D.h @@ -0,0 +1,31 @@ +/*! + * \file datagenerator1D.h + * \brief Class to generate data for the neural entropy closure in 1D spatial dimensions + * \author S. Schotthoefer + */ + +#ifndef DATAGENERATOR1D_H +#define DATAGENERATOR1D_H + +#include "toolboxes/datageneratorbase.h" + +class DataGenerator1D : public DataGeneratorBase +{ + public: + /*! @brief Class constructor. Generates training data for neural network approaches using + * spherical harmonics and an entropy functional and the quadrature specified by + * the options file. + * @param settings config class with global information*/ + DataGenerator1D( Config* settings ); + ~DataGenerator1D(); + + private: + // Main methods + void SampleSolutionU() override; /*!< @brief Samples solution vectors u */ + + // Helper functions + void ComputeMoments() override; /*!< @brief Pre-Compute Moments at all quadrature points. */ + void ComputeSetSize() override; /*!< @brief Computes the size of the training set, depending on the chosen settings.*/ + void CheckRealizability() override; // Debugging helper +}; +#endif // DATAGENERATOR1D_H diff --git a/code/include/toolboxes/datagenerator2D.h b/code/include/toolboxes/datagenerator2D.h new file mode 100644 index 0000000000000000000000000000000000000000..f0c96c29018d51717e7a2be4be6f6609fcf57932 --- /dev/null +++ b/code/include/toolboxes/datagenerator2D.h @@ -0,0 +1,31 @@ +/*! + * \file datagenerator3D.h + * \brief Class to generate data for the neural entropy closure in 3D spatial dimensions + * \author S. Schotthoefer + */ + +#ifndef DATAGENERATOR2D_H +#define DATAGENERATOR2D_H + +#include "toolboxes/datageneratorbase.h" + +class DataGenerator2D : public DataGeneratorBase +{ + public: + /*! @brief Class constructor. Generates training data for neural network approaches using + * spherical harmonics and an entropy functional and the quadrature specified by + * the options file. + * @param settings config class with global information*/ + DataGenerator2D( Config* settings ); + ~DataGenerator2D(); + + private: + // Main methods + void SampleSolutionU() override; /*!< @brief Samples solution vectors u */ + + // Helper functions + void ComputeMoments() override; /*!< @brief Pre-Compute Moments at all quadrature points. */ + void ComputeSetSize() override; /*!< @brief Computes the size of the training set, depending on the chosen settings.*/ + void CheckRealizability() override; // Debugging helper +}; +#endif // DATAGENERATOR2D_H diff --git a/code/include/toolboxes/datagenerator3D.h b/code/include/toolboxes/datagenerator3D.h new file mode 100644 index 0000000000000000000000000000000000000000..4dc08c50481d6e47fb33ac7c98445b76c12f372a --- /dev/null +++ b/code/include/toolboxes/datagenerator3D.h @@ -0,0 +1,31 @@ +/*! + * \file datagenerator3D.h + * \brief Class to generate data for the neural entropy closure in 3D spatial dimensions + * \author S. Schotthoefer + */ + +#ifndef DATAGENERATOR3D_H +#define DATAGENERATOR3D_H + +#include "toolboxes/datageneratorbase.h" + +class DataGenerator3D : public DataGeneratorBase +{ + public: + /*! @brief Class constructor. Generates training data for neural network approaches using + * spherical harmonics and an entropy functional and the quadrature specified by + * the options file. + * @param settings config class with global information*/ + DataGenerator3D( Config* settings ); + ~DataGenerator3D(); + + private: + // Main methods + void SampleSolutionU() override; /*!< @brief Samples solution vectors u */ + + // Helper functions + void ComputeMoments() override; /*!< @brief Pre-Compute Moments at all quadrature points. */ + void ComputeSetSize() override; /*!< @brief Computes the size of the training set, depending on the chosen settings.*/ + void CheckRealizability() override; // Debugging helper +}; +#endif // DATAGENERATOR3D_H diff --git a/code/include/toolboxes/datageneratorbase.h b/code/include/toolboxes/datageneratorbase.h new file mode 100644 index 0000000000000000000000000000000000000000..d86529671a38c7640f89926c7837aaf7a3a205f4 --- /dev/null +++ b/code/include/toolboxes/datageneratorbase.h @@ -0,0 +1,86 @@ +/*! + * \file datageneratorbase.h + * \brief Class to generate data for the neural entropy closure + * \author S. Schotthoefer + */ + +#ifndef DATAGENERATOR_H +#define DATAGENERATOR_H + +#include "common/typedef.h" +#include + +class SphericalBase; +class QuadratureBase; +class Config; +class NewtonOptimizer; +class EntropyBase; + +class DataGeneratorBase +{ + public: + /*! @brief Class constructor. Generates training data for neural network approaches using + * spherical harmonics and an entropy functional and the quadrature specified by + * the options file. + * @param settings config class with global information*/ + DataGeneratorBase( Config* settings ); + virtual ~DataGeneratorBase(); + + /*! @brief Create a datagenerator (1D or 3D) + * @param settings Pointer to the config file + * @returns Pointer to the createt basis class */ + static DataGeneratorBase* Create( Config* settings ); + + /*! @brief computes the training data set. + * Realizable set is sampled uniformly. + * Prototype: 1D, u in [0,100] */ + void ComputeTrainingData(); + + inline VectorVector GetuSol() { return _uSol; } /*! @brief Get the computed solution vector uSol */ + inline VectorVector GetAlpha() { return _alpha; } /*! @brief Get the computed vector alpha */ + inline std::vector GethEntropy() { return _hEntropy; } /*! @brief Get the computed entropy value h */ + + protected: + Config* _settings; /*!< @brief config class for global information */ + + VectorVector _uSol; /*!< @brief vector with moments. Size: (setSize,basisSize)*/ + VectorVector _alpha; /*!< @brief vector with Lagrange multipliers. Size: (setSize,basisSize)*/ + std::vector _hEntropy; /*!< @brief vector with entropy values. Size: (setSize) */ + + unsigned long _setSize; /*!< @brief Size of the whole training Set */ + unsigned long + _gridSize; /*!< @brief Size of the grid discretizing moment U0 for higher order sampling (has different uses for different samplers)*/ + + unsigned short _maxPolyDegree; /*!< @brief Max Order of Spherical Harmonics */ + unsigned _nTotalEntries; /*!< @brief Total number of equations in the system */ + + QuadratureBase* _quadrature; /*!< @brief quadrature to create members below */ + unsigned _nq; /*!< @brief number of quadrature points */ + VectorVector _quadPoints; /*!< @brief quadrature points, dim(_quadPoints) = (_nq,spatialDim) */ + Vector _weights; /*!< @brief quadrature weights, dim(_weights) = (_nq) */ + VectorVector _quadPointsSphere; /*!< @brief (my,phi), dim(_quadPoints) = (_nq,2) */ + + SphericalBase* _basis; /*!< @brief Class to compute and store current spherical harmonics basis */ + VectorVector _moments; /*!< @brief Moment Vector pre-computed at each quadrature point: dim= _nq x _nTotalEntries */ + + NewtonOptimizer* _optimizer; /*!< @brief Class to solve minimal entropy problem */ + EntropyBase* _entropy; /*!< @brief Class to handle entropy functional evaluations */ + + // Main methods + virtual void SampleSolutionU() = 0; /*!< @brief Samples solution vectors u */ + void SampleMultiplierAlpha(); /*!< @brief Sample Lagrange multipliers alpha */ + void ComputeEntropyH_dual(); /*!< @brief Compute the entropy functional at (u,alpha) in dual formulation */ + void ComputeEntropyH_primal(); /*!< @brief Compute the entropy functional at (u,alpha) in primal formulation */ + void ComputeRealizableSolution(); /*!< @brief make u the realizable moment to alpha, since Newton has roundoff errors. */ + + // IO routines + void PrintTrainingData(); /*!< @brief : Print computed training data to csv file and screen */ + void PrintLoadScreen(); /*!< @brief Print screen IO*/ + + // Helper functions + virtual void ComputeMoments() = 0; /*!< @brief Pre-Compute Moments at all quadrature points. */ + virtual void CheckRealizability() = 0; /*!< @brief Debugging helper. Will be removed */ + virtual void ComputeSetSize() = 0; /*!< @brief Computes the size of the training set, depending on the chosen settings.*/ + void AdaptBasisSize(); /*!< @brief In case of normal sampling, deletes zero order basis for dimension reduction. */ +}; +#endif // DATAGENERATOR_H diff --git a/code/include/toolboxes/errormessages.h b/code/include/toolboxes/errormessages.h index 81936b41ab1dff0a3a252875517b1aaddd044f39..597936a13c24c901743f8d23d67536d55065d6f8 100644 --- a/code/include/toolboxes/errormessages.h +++ b/code/include/toolboxes/errormessages.h @@ -1,11 +1,11 @@ /*! - * \file CRTSNError.h + * \file errormessages.h * \brief Class to handle Error Messages * \author S. Schotthoefer */ -#ifndef CRTSNERROR_H -#define CRTSNERROR_H +#ifndef ERRORMESSAGES_H +#define ERRORMESSAGES_H #include "spdlog/spdlog.h" @@ -106,7 +106,7 @@ class ErrorMessages } }; -#endif // CRTSNERROR_H +#endif // ERRORMESSAGES_H /* Depending on the compiler, define the correct macro to get the current function name */ diff --git a/code/include/toolboxes/interpolation.h b/code/include/toolboxes/interpolation.h index bfcb545fb3ab84167979825d8d2c2d1761dd0c82..1c54e2b16799efdd1d3d79418ebd2021ccb36fcf 100644 --- a/code/include/toolboxes/interpolation.h +++ b/code/include/toolboxes/interpolation.h @@ -14,9 +14,10 @@ class Interpolation private: unsigned _dim; - Vector _x, _y; - Matrix _data; - TYPE _type; + Vector _x; /*!< @brief x input data */ + Vector _y; /*!< @brief y input data */ + Matrix _data; /*!< @brief data matrix w.r.t. x and y grid */ + TYPE _type; /*!< @brief type of interpolation (linear, loglinear, cubic) */ Interpolation() = delete; @@ -37,55 +38,56 @@ class Interpolation // In constructor tabulated values are initialised /*! * @brief constructor linear interpolation for std::vector input - * @param[in] x - table values for x - * @param[in] y - table values for y - * @param[in] type - linear or cubic interpolation + * @param x table values for x + * @param y table values for y + * @param type linear or cubic interpolation */ Interpolation( const std::vector& x, const std::vector& y, TYPE type = linear ); /*! * @brief constructor linear interpolation for Vector input - * @param[in] x - table values for x - * @param[in] y - table values for y - * @param[in] type - linear or cubic interpolation + * @param x table values for x + * @param y table values for y + * @param type linear or cubic interpolation */ Interpolation( const Vector& x, const Vector& y, TYPE type = linear ); /*! * @brief constructor cubic interpolation - * @param[in] x - table values for x - * @param[in] y - table values for y - * @param[in] type - linear or cubic interpolation + * @param x table values for x + * @param y table values for y + * @param data matrix w.r.t x y grid + * @param type of interpolation (linear, loglinear, cubic) */ Interpolation( const Vector& x, const Vector& y, const Matrix& data, TYPE type = cubic ); // Here the interpolation between the previously defined table values is performed /*! * @brief defines one dimensional interpolation at x - * @param[in] x - value at which to interpolate - * @param[out] y - corresponding interpolated y value + * @param x value at which to interpolate + * @returns corresponding interpolated y value */ double operator()( double x ) const; /*! * @brief defines interpolation for a Vector of values - * @param[in] v - values at which to interpolate - * @param[out] y - corresponding interpolated values + * @param v values at which to interpolate + * @returns corresponding interpolated values */ Vector operator()( Vector v ) const; /*! * @brief defines interpolation for a std::vector of values - * @param[in] v - values at which to interpolate - * @param[out] y - corresponding interpolated values + * @param v values at which to interpolate + * @returns corresponding interpolated values */ std::vector operator()( std::vector v ) const; /*! * @brief defines 2D interpolation at x and y - * @param[in] x - value at which to interpolate - * @param[in] y - value at which to interpolate - * @param[out] data - corresponding interpolated value + * @param x value at which to interpolate + * @param y value at which to interpolate + * @returns corresponding interpolated value */ double operator()( double x, double y ) const; }; diff --git a/code/include/toolboxes/reconstructor.h b/code/include/toolboxes/reconstructor.h index 9ad2a8a65e82177ddf70c2894cdc215f39869599..0f61968c956cda505107e6a2a6480a979b16aa7c 100644 --- a/code/include/toolboxes/reconstructor.h +++ b/code/include/toolboxes/reconstructor.h @@ -1,6 +1,6 @@ /*! * @file: reconstructor.h - * @brief: Class to create second order (in space) schemes for the advection solver. + * @brief Class to create second order (in space) schemes for the advection solver. * This class is currently unused. But in the future, the second order capabilities of the code * may be stored here. * @author: T. Xiao @@ -30,22 +30,14 @@ class Reconstructor /*! Method 1: structured developing * @brief Slope of angular flux psi inside a given cell - * @param Omega fixed ordinate for flux computation - * @param psiL left solution state - * @param psiR right solution state - * @param n scaled normal vector of given edge + * @param uL left solution state + * @param uC center solution state + * @param uR right solution state + * @param dxL left slope + * @param dxR right slope + * @param limiter name of the applied limiter (invalid argument results in disabled limiter) * @return reconstructed slope */ - - /** Method 2: unstructured developing - * @brief Slope of angular flux psi inside a given cell - * @param Omega fixed ordinate for flux computation - * @param psiL left solution state - * @param psiR right solution state - * @param n scaled normal vector of given edge - * @return reconstructed slope - */ - virtual double ReconstructSlopeStruct( double uL, double uC, double uR, double dxL, double dxR, std::string limiter ) const; }; diff --git a/code/include/toolboxes/sphericalbase.h b/code/include/toolboxes/sphericalbase.h index acd54d31d3db2af40f70ec5c75f6d1a6d3ac8715..534375d7385df6bd962730dabf810ed3fdeba786 100644 --- a/code/include/toolboxes/sphericalbase.h +++ b/code/include/toolboxes/sphericalbase.h @@ -17,38 +17,39 @@ class SphericalBase SphericalBase() {} virtual ~SphericalBase() {} - /*! @brief: Create a set of basis functions on the unit sphere defined in settings - * @param: Pointer to the config file - * @returns: Pointer to the createt basis class */ + /*! @brief Create a set of basis functions on the unit sphere defined in settings + * @param settings pointer to the config object + * @returns Pointer to the createt basis class + */ static SphericalBase* Create( Config* settings ); - /*! @brief : Computes all N basis functions at point (my, phi) - * @param : my = cos(theta) - spherical coordinate, -1 <= x <= 1 - * @param : phi - spherical coordinate, 0 <= phi <= 2*pi - * @return : vector of basis functions at point (my, phi) with size N + /*! @brief Computes all N basis functions at point (my, phi) + * @param my cos(theta) - spherical coordinate, -1 <= x <= 1 + * @param phi spherical coordinate, 0 <= phi <= 2*pi + * @return vector of basis functions at point (my, phi) with size N */ virtual Vector ComputeSphericalBasis( double my, double phi ) = 0; - /*! @brief : Computes all basis functions at point (x, y, z) on the unit sphere - * @param : x,y,z = coordinates on unit sphere - * @return : vector of basis functions at point (x,y,z) with size N + /*! @brief Computes all basis functions at point (x, y, z) on the unit sphere + * @param x,y,z coordinates on unit sphere + * @return vector of basis functions at point (x,y,z) with size N */ virtual Vector ComputeSphericalBasis( double x, double y, double z ) = 0; - /*! @brief : Return size of complete Basisvector */ + /*! @brief Return size of complete Basisvector */ virtual unsigned GetBasisSize() = 0; - /*! @brief: Return number of basis functions with degree equals to currDegree - * @param: currDegree must be smaller equals _LMaxDegree */ + /*! @brief Return number of basis functions with degree equals to currDegree + * @param currDegree must be smaller equals _LMaxDegree */ virtual unsigned GetCurrDegreeSize( unsigned currDegree ) = 0; - /*! @brief: Computes global index of basis vector depending on order k and degree l - * @param: l_degree = degree of polynomials l = 0,1,2,3,... - * @param: k_order = order of element of degree l. !ATTENTION. Requirements are different for monomials and harmonics! */ + /*! @brief Computes global index of basis vector depending on order k and degree l + * @param l_degree = degree of polynomials l = 0,1,2,3,... + * @param k_order = order of element of degree l. !ATTENTION. Requirements are different for monomials and harmonics! */ virtual unsigned GetGlobalIndexBasis( int l_degree, int k_order ) = 0; protected: - /*! @brief: maximal (polynomial) degree of the spherical basis (this is "L" in the comments)*/ + /*! @brief maximal (polynomial) degree of the spherical basis (this is "L" in the comments)*/ unsigned _LMaxDegree; }; diff --git a/code/include/toolboxes/sphericalharmonics.h b/code/include/toolboxes/sphericalharmonics.h index 9c4dc2d1dd827c855052a47ecf50bc82135be08c..6a68dc134d79aaf1417a5d8ebb23e199a400be60 100644 --- a/code/include/toolboxes/sphericalharmonics.h +++ b/code/include/toolboxes/sphericalharmonics.h @@ -18,52 +18,54 @@ class SphericalHarmonics : public SphericalBase { public: - /*! @brief : Sets up class for spherical harmonics basis based on legendre - * polynoms and associated legendre polynoms up to degree L. - * The basis then consists of N = L² +2L basis functions. - * @param : L_degree - maximum degree of spherical harmonics basis, 0 <= L <= 1000 (upper bound + /*! @brief Sets up class for spherical harmonics basis based on legendre + * polynoms and associated legendre polynoms up to degree L. + * The basis then consists of N = L² +2L basis functions. + * @param L_degree - maximum degree of spherical harmonics basis, 0 <= L <= 1000 (upper bound * due to numerical stability) * */ SphericalHarmonics( unsigned L_degree ); - /*! @brief : Computes all N = L² +2L basis functions at point (my, phi) - * @param : my = cos(theta) - spherical coordinate, -1 <= x <= 1 - * @param : phi - spherical coordinate, 0 <= phi <= 2*pi - * @return : vector of basis functions at point (my, phi) with size N = L² +2L + /*! @brief Computes all N = L² +2L basis functions at point (my, phi) + * @param my = cos(theta) - spherical coordinate, -1 <= x <= 1 + * @param phi - spherical coordinate, 0 <= phi <= 2*pi + * @return vector of basis functions at point (my, phi) with size N = L² +2L */ Vector ComputeSphericalBasis( double my, double phi ) override; - /*! @brief : Computes all N = L² +2L basis functions at point (x, y, z) on the unit sphere - * @param : x,y,z = coordinates on unit sphere - * @return : vector of basis functions at point (x,y,z) with size N = L² +2L + /*! @brief Computes all N = L² +2L basis functions at point (x, y, z) on the unit sphere + * @param x coordinates on unit sphere + * @param y coordinates on unit sphere + * @param z coordinates on unit sphere + * @return vector of basis functions at point (x,y,z) with size N = L² +2L */ Vector ComputeSphericalBasis( double x, double y, double z ) override; - /*! @brief : Computes an entire set of (komplex congjugate) P_l^k and stores - * it in the vector _assLegendreP - * @param : my = cos(theta) - spherical coordinate, -1 <= my <= 1 - * @return : Associated Legendre Polynomial at my for all l and k + /*! @brief Computes an entire set of (komplex congjugate) P_l^k and stores + * it in the vector _assLegendreP + * @param my = cos(theta) - spherical coordinate, -1 <= my <= 1 + * @return Associated Legendre Polynomial at my for all l and k */ std::vector GetAssLegendrePoly( const double my ); - /*! @brief: Returns length of the basis, i.e. number of elements of the basis */ - unsigned GetBasisSize() override; + /*! @brief Returns length of the basis, i.e. number of elements of the basis */ + unsigned GetBasisSize() override final; - /*! @brief: Return number of basis functions with degree equals to currDegree - * @param: currDegreeL = degree of polynomials that are counted */ - unsigned GetCurrDegreeSize( unsigned currDegree ) override; + /*! @brief Return number of basis functions with degree equals to currDegree + * @param currDegree degree of polynomials that are counted */ + unsigned GetCurrDegreeSize( unsigned currDegree ) override final; - /*! @brief : helper function to get the global index for given k and l of - * the basis function Y_k^l. - * @param : l_degree - current degree of basis function, 0 <= l <= L - * @param : k_order - current order of basis function, -l <= k <= l */ - unsigned GetGlobalIndexBasis( int l_degree, int k_order ) override; + /*! @brief helper function to get the global index for given k and l of + * the basis function Y_k^l. + * @param l_degree - current degree of basis function, 0 <= l <= L + * @param k_order - current order of basis function, -l <= k <= l */ + unsigned GetGlobalIndexBasis( int l_degree, int k_order ) override final; private: - /*! @brief: maximal degree of the spherical harmonics basis (this is "L" in the comments)*/ + /*! @brief maximal degree of the spherical harmonics basis (this is "L" in the comments)*/ unsigned _LMaxDegree; - /*! @brief: coefficients for the computations of the basis + /*! @brief coefficients for the computations of the basis * length of _aParam, _bParam : L + (L*(L+1))/2 */ std::vector _aParam; @@ -75,32 +77,32 @@ class SphericalHarmonics : public SphericalBase */ std::vector _assLegendreP; - /*! @brief: spherical harmonic basis functions of + /*! @brief spherical harmonic basis functions of * degree 0 <= l <= L and order -l <= k <= l * length : N = L² +2L */ Vector _YBasis; - /*! @brief : helper function to get the global index for given k and l of - * the associated legendre polynomial P_k^l. - * @param : l_degree - current degree of basis function, 0 <= l <= L - * @param : k_order - current order of basis function, 0 <= k <= l + /*! @brief helper function to get the global index for given k and l of + * the associated legendre polynomial P_k^l. + * @param l_degree - current degree of basis function, 0 <= l <= L + * @param k_order - current order of basis function, 0 <= k <= l */ unsigned inline GlobalIdxAssLegendreP( unsigned l_degree, unsigned k_order ) { return k_order + ( l_degree * ( l_degree + 1 ) ) / 2; } - /*! @brief : computes values of a_param and b_param + /*! @brief computes values of a_param and b_param */ void ComputeCoefficients(); - /*! @brief : Computes an entire set of (komplex congjugate) P_l^k and stores - * it in the vector _assLegendreP - * @param : my = cos(theta) - spherical coordinate, -1 <= my <= 1 + /*! @brief Computes an entire set of (komplex congjugate) P_l^k and stores + * it in the vector _assLegendreP + * @param my equals cos(theta) - spherical coordinate, -1 <= my <= 1 */ void ComputeAssLegendrePoly( const double my ); - /*! @brief: Computes the spherical harmonics basis function up to degree _LmaxDegree at + /*! @brief Computes the spherical harmonics basis function up to degree _LmaxDegree at * polar coordinates (theta, psi) and stores the result in _YBasis; - * @param: spherical coordinate phi + * @param phi spherical coordinate */ void ComputeYBasis( const double phi ); }; diff --git a/code/include/toolboxes/sphericalmonomials.h b/code/include/toolboxes/sphericalmonomials.h index 23ce98a7380c3f4704e4c8dd06de5f1550d2c939..5e8e331e20a82985aad352d07e54f40cd99f2e24 100644 --- a/code/include/toolboxes/sphericalmonomials.h +++ b/code/include/toolboxes/sphericalmonomials.h @@ -14,84 +14,86 @@ class SphericalMonomials : public SphericalBase { public: - /*! @brief : Sets up class for monomial basis on sphere up to degree L. + /*! @brief Sets up class for monomial basis on sphere up to degree L. * The basis then consists of N = L. - * @param : L_degree - maximum degree of spherical harmonics basis, 0 <= L <= 1000 (upper bound + * @param L_degree maximum degree of spherical harmonics basis, 0 <= L <= 1000 (upper bound * due to numerical stability) * */ SphericalMonomials( unsigned L_degree ); - /*! @brief : Sets up class for monomial basis on sphere up to degree L. - * The basis then consists of N = L. - * @param : L_degree - maximum degree of spherical harmonics basis, 0 <= L <= 1000 (upper bound - * due to numerical stability) - * @param : spatialDim - spatial dimensioniality of the simulation + /*! @brief Sets up class for monomial basis on sphere up to degree L. + * The basis then consists of N = L. + * @param L_degree maximum degree of spherical harmonics basis, 0 <= L <= 1000 (upper bound + * due to numerical stability) + * @param spatialDim spatial dimensioniality of the simulation * */ SphericalMonomials( unsigned L_degree, unsigned short spatialDim ); - /*! @brief : Computes all N = L² +2L basis functions at point (my, phi) - * @param : my = cos(theta) - spherical coordinate, -1 <= x <= 1 - * @param : phi - spherical coordinate, 0 <= phi <= 2*pi - * @return : vector of basis functions at point (my, phi) with size N = L² +2L + /*! @brief Computes all N = L² +2L basis functions at point (my, phi) + * @param my cos(theta) - spherical coordinate, -1 <= x <= 1 + * @param phi spherical coordinate, 0 <= phi <= 2*pi + * @return vector of basis functions at point (my, phi) with size N = L² +2L */ Vector ComputeSphericalBasis( double my, double phi ) override; - /*! @brief : Computes all N = L² +2L basis functions at point (x, y, z) on the unit sphere - * @param : x,y,z = coordinates on unit sphere - * @return : vector of basis functions at point (x,y,z) with size N = L² +2L + /*! @brief Computes all N = L² +2L basis functions at point (x, y, z) on the unit sphere + * @param x = coordinates on unit sphere + * @param y = coordinates on unit sphere + * @param z = coordinates on unit sphere + * @return vector of basis functions at point (x,y,z) with size N = L² +2L */ Vector ComputeSphericalBasis( double x, double y, double z ) override; - /*! @brief: Computes the length of the basis vector for a given max degree and + /*! @brief Computes the length of the basis vector for a given max degree and * spatial dimension dim. len of a single oder: (degree + _spatialDim -1) over (degree) - * @return: lenght of whole basis */ + * @return lenght of whole basis */ unsigned GetBasisSize() override; - /*! @brief: Computes the amount of lin. independent monomials of degree currDegreeL and + /*! @brief Computes the amount of lin. independent monomials of degree currDegreeL and * spatial dimension dim. len of a single oder: (currDegreeL + _spatialDim -1) over (currDegreeL) - * @param: currDegreeL = degree of polynomials that are counted - * @return: lenght of a single dimension */ + * @param currDegreeL = degree of polynomials that are counted + * @return lenght of a single dimension */ unsigned GetCurrDegreeSize( unsigned currDegreeL ) override; - /*! @brief: Computes global index of basis vector depending on order k and degree l - * @param: l = degree of polynomials l = 0,1,2,3,... - * @param: k = order of element of degree l. 0 <=k <=GetCurrDegreeSize(l) */ + /*! @brief Computes global index of basis vector depending on order k and degree l + * @param l_degree degree of polynomials l = 0,1,2,3,... + * @param k_order order of element of degree l. 0 <=k <=GetCurrDegreeSize(l) */ unsigned GetGlobalIndexBasis( int l_degree, int k_order ) override; private: - /*! @brief: Spatial dimension of the unit sphere (1,2,3) */ + /*! @brief Spatial dimension of the unit sphere (1,2,3) */ unsigned _spatialDim; - /*! @brief: spherical monomial basis function vector of + /*! @brief spherical monomial basis function vector of * degree 0 <= l <= L * length : COmputed with ComputeBasisSize */ Vector _YBasis; - /*! @brief: Function to compute factorial of n (n!) in recursive manner */ + /*! @brief Function to compute factorial of n (n!) in recursive manner */ unsigned Factorial( unsigned n ); - /*! @brief: Function to compute first component of spherical unit vector + /*! @brief Function to compute first component of spherical unit vector * Omega_x = sqrt(1-my*my)*cos(phi) - * @return: first component of spherical unit vector */ + * @return first component of spherical unit vector */ double Omega_x( double my, double phi ); - /*! @brief: Function to compute first component of spherical unit vector + /*! @brief Function to compute first component of spherical unit vector * Omega_x = sqrt(1-my*my)*sin(phi) - * @return: first component of spherical unit vector */ + * @return first component of spherical unit vector */ double Omega_y( double my, double phi ); - /*! @brief: Function to compute first component of spherical unit vector + /*! @brief Function to compute first component of spherical unit vector * Omega_z = my - * @return: first component of spherical unit vector */ + * @return first component of spherical unit vector */ double Omega_z( double my ); - /*! @brief: Helper Function to compute basis^exponent. */ + /*! @brief Helper Function to compute basis^exponent. */ double Power( double basis, unsigned exponent ); - /*! @brief: Helper to compute the basis in 1D, 2D or 3D, depending on choice of _spatialDim */ - Vector ComputeSphericalBasis1D( double my, double phi ); - Vector ComputeSphericalBasis2D( double my, double phi ); + /*! @brief Helper to compute the basis in 1D, 2D or 3D, depending on choice of _spatialDim */ + Vector ComputeSphericalBasis1D( double my ); /*!< @brief Only Z achsis of the 3D case */ + Vector ComputeSphericalBasis2D( double my, double phi ); /*!< @brief Only X and Y achsis of the 3D case */ Vector ComputeSphericalBasis3D( double my, double phi ); }; #endif // SPHERICALMONOMIALS_H diff --git a/code/include/toolboxes/textprocessingtoolbox.h b/code/include/toolboxes/textprocessingtoolbox.h index 3388f9bc48b78718ad7d1b7ce5c83810b06779ab..ef170797abaf0d84a122e1dab24fbf76058f5fee 100644 --- a/code/include/toolboxes/textprocessingtoolbox.h +++ b/code/include/toolboxes/textprocessingtoolbox.h @@ -1,8 +1,6 @@ /*! - * \file TextProcessingToolbox.h + * \file textprocessingtoolbox.h * \brief File with helper functions for text processing - * - * */ #ifndef TEXTPROCESSINGTOOLBOX_H @@ -16,15 +14,15 @@ namespace TextProcessingToolbox { /*! - * \brief utility function for converting strings to uppercase - * \param[in,out] str - string we want to convert + * @brief utility function for converting strings to uppercase + * @param str - string to be converted */ inline void StringToUpperCase( std::string& str ) { std::transform( str.begin(), str.end(), str.begin(), ::toupper ); } /*! - * \brief utility function for splitting strings to at delimiter - * \param [in] str - string we want to split, delimiter - delimiter character - * [out] vector of string tokens that were separated by the delimiter + * @brief utility function for splitting strings to at delimiter + * @param s string to be split + * @param delimiter delimiter character */ inline std::vector Split( const std::string& s, char delimiter ) { std::vector tokens; @@ -37,14 +35,8 @@ inline std::vector Split( const std::string& s, char delimiter ) { } /*! - * \brief utility function for getting walltime - * \param [in,out] V - */ -// TODO - -/*! - * \brief utility function for printing a VectorVector - * \param [in] VectorVector we want to print + * @brief utility function for printing a VectorVector + * @param vectorIn VectorVector we want to print */ inline void PrintVectorVector( const VectorVector vectorIn ) { unsigned dimOuter = vectorIn.size(); @@ -62,15 +54,15 @@ inline void PrintVectorVector( const VectorVector vectorIn ) { } /*! - * \brief utility function for returning the last number in a string - * \param [in] string to be checked + * @brief utility function for returning the last number in a string + * @param str string to be checked */ inline int GetTrailingNumber( std::string const& str ) { return std::stoi( str.substr( str.find_first_of( "0123456789" ), str.length() - 1 ) ); } /*! - * \brief utility function for checking if a string has a certain ending - * \param [in] string to be checked - * \param [in] ending to be checked for + * @brief utility function for checking if a string has a certain ending + * @param value string to be checked + * @param ending string to be checked for */ inline bool StringEndsWith( std::string const& value, std::string const& ending ) { if( ending.size() > value.size() ) return false; diff --git a/code/input/DataGenerator1D.cfg b/code/input/DataGenerator1D.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6d8141eac18fd785b1be444f7acfd33dcb89befa --- /dev/null +++ b/code/input/DataGenerator1D.cfg @@ -0,0 +1,57 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% 1D Data Generator for % +% Neural Entropy Closure % +% Author % +% Date 17.02.2021 % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ---- Datagenerator settings ---- +DATA_GENERATOR_MODE = YES +TRAINING_SET_SIZE = 100000 +MAX_VALUE_FIRST_MOMENT = 1 +SPATIAL_DIM = 1 +MAX_MOMENT_SOLVER = 1 +REALIZABLE_SET_EPSILON_U1 = 0.01 +REALIZABLE_SET_EPSILON_U0 = 0.01 +NORMALIZED_SAMPLING = YES +ALPHA_SAMPLING = YES +REALIZABILITY_RECONS_U = NO + +% +% ---- File specifications ---- +% +% Output directory +OUTPUT_DIR = ../result +% Output file +OUTPUT_FILE = trainM11D +% Log directory +LOG_DIR = ../result/logs +LOG_FILE = dataGen1D + +% +% --- Spherical Basis ---- +% +% Choice of basis functions +SPHERICAL_BASIS = SPHERICAL_MONOMIALS +% +% --- Entropy settings ---- +% +ENTROPY_FUNCTIONAL = MAXWELL_BOLTZMANN +ENTROPY_OPTIMIZER = NEWTON +% +% ----- Newton Solver Specifications ---- +% +NEWTON_FAST_MODE = NO +NEWTON_ITER = 1000000 +NEWTON_EPSILON = 1e-7 +NEWTON_STEP_SIZE = 0.7 +NEWTON_LINE_SEARCH_ITER = 100000 +% +% ----- Quadrature ---- +% +% Quadrature Rule +QUAD_TYPE = GAUSS_LEGENDRE_1D +% Quadrature Order +%QUAD_ORDER = 200 +QUAD_ORDER = 100 +% diff --git a/code/input/DataGenerator2D.cfg b/code/input/DataGenerator2D.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e8ed20cf3ad185398fa95ef1d818f14754f17067 --- /dev/null +++ b/code/input/DataGenerator2D.cfg @@ -0,0 +1,53 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Data Generator for % +% Neural Entropy Closure % +% Author % +% Date 17.12.2020 % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ---- Global settings ---- +DATA_GENERATOR_MODE = YES +TRAINING_SET_SIZE = 10000 +MAX_VALUE_FIRST_MOMENT = 1 +REALIZABLE_SET_EPSILON_U0 = 0.003 +REALIZABLE_SET_EPSILON_U1 = 0.97 +SPATIAL_DIM = 2 +NORMALIZED_SAMPLING = YES + +% +% ---- File specifications ---- +% +% Output directory +OUTPUT_DIR = ../result +% Output file +OUTPUT_FILE = DataGenerator2D +% Log directory +LOG_DIR = ../result/logs +% +% --- Spherical Basis ---- +% +% Choice of basis functions +SPHERICAL_BASIS = SPHERICAL_MONOMIALS +% +% Maximal Moment degree +MAX_MOMENT_SOLVER = 1 +% +% --- Entropy settings ---- +ENTROPY_FUNCTIONAL = MAXWELL_BOLTZMANN +ENTROPY_OPTIMIZER = NEWTON +% +% ----- Newton Solver Specifications ---- +% +NEWTON_FAST_MODE = NO +NEWTON_ITER = 1000000 +NEWTON_EPSILON = 1e-7 +NEWTON_STEP_SIZE = 0.7 +NEWTON_LINE_SEARCH_ITER = 100000 +% +% ----- Quadrature ---- +% +% Quadrature Rule +QUAD_TYPE = GAUSS_LEGENDRE_TENSORIZED +% Quadrature Order +QUAD_ORDER = 20 +% diff --git a/code/input/DataGenerator.cfg b/code/input/DataGenerator3D.cfg similarity index 90% rename from code/input/DataGenerator.cfg rename to code/input/DataGenerator3D.cfg index d795d33a575689ad9e8713ebc739ed80b08c98a6..aadf5b97c636a1c53a1dd9dfb1ccf941b09e04b0 100644 --- a/code/input/DataGenerator.cfg +++ b/code/input/DataGenerator3D.cfg @@ -7,8 +7,8 @@ % % ---- Global settings ---- DATA_GENERATOR_MODE = YES -TRAINING_SET_SIZE = 500 -MAX_VALUE_FIRST_MOMENT = 20 +TRAINING_SET_SIZE = 20 +MAX_VALUE_FIRST_MOMENT = 5 REALIZABLE_SET_EPSILON_U0 = 0.05 REALIZABLE_SET_EPSILON_U1 = 0.97 % @@ -37,9 +37,9 @@ ENTROPY_OPTIMIZER = NEWTON % NEWTON_FAST_MODE = NO NEWTON_ITER = 1000000 -NEWTON_EPSILON = 0.01 +NEWTON_EPSILON = 0.0001 NEWTON_STEP_SIZE = 0.7 -NEWTON_LINE_SEARCH_ITER = 1000 +NEWTON_LINE_SEARCH_ITER = 100000 % % ----- Quadrature ---- % diff --git a/code/input/aircavity_csd_1d.cfg b/code/input/aircavity1D.cfg similarity index 100% rename from code/input/aircavity_csd_1d.cfg rename to code/input/aircavity1D.cfg diff --git a/code/input/checkerboard_MN.cfg b/code/input/checkerboard_MN.cfg index eb0bd6305211ede8b0b4e6701169df64b8705375..bac1944235c70966386265b1825ae7e3170e273a 100644 --- a/code/input/checkerboard_MN.cfg +++ b/code/input/checkerboard_MN.cfg @@ -8,7 +8,7 @@ % OUTPUT_DIR = ../result % Output file -OUTPUT_FILE = MN_checkerboard_Monomials +OUTPUT_FILE = MN_checkerboard % Log directory LOG_DIR = ../result/logs % Mesh File @@ -18,6 +18,7 @@ MESH_FILE = meshes/checkerboard.su2 % ---- Problem specifications ---- % PROBLEM = CHECKERBOARD +SPATIAL_DIM = 2 % % ---- Solver specifications ---- % diff --git a/code/input/example_csd.cfg b/code/input/example_csd.cfg index 18a467f4649cd8f627c8e15a7b20475ad1f3ec0e..fb5142a7fbc81882b68d4ae1bfc3f62aab9ce2e9 100644 --- a/code/input/example_csd.cfg +++ b/code/input/example_csd.cfg @@ -4,7 +4,6 @@ LOG_DIR = ../result/logs MESH_FILE = linesource_pseudo_1D.su2 PROBLEM = WATERPHANTOM SOLVER = CSD_SN_SOLVER -CONTINUOUS_SLOWING_DOWN = YES HYDROGEN_FILE = ENDL_H.txt OXYGEN_FILE = ENDL_O.txt KERNEL = ISOTROPIC_1D diff --git a/code/input/linesource_SN.cfg b/code/input/linesource_SN.cfg index a4eb0d07718e85fde6c2ac6b775e7aff7388b791..8255eb93e5367f24b1a73b9d6de1fe6c46ecbaa1 100644 --- a/code/input/linesource_SN.cfg +++ b/code/input/linesource_SN.cfg @@ -27,7 +27,7 @@ CFL_NUMBER = 0.7 % Final time for simulation TIME_FINAL = 0.5 % Reconstruction order -RECONS_ORDER = 2 +RECONS_ORDER = 1 % % ---- Boundary Conditions ---- diff --git a/code/input/phantom2d_csd.cfg b/code/input/phantom2d_csd.cfg deleted file mode 100644 index 1d416f41a884ccdfeacabdd74dd74559d1c3cbe1..0000000000000000000000000000000000000000 --- a/code/input/phantom2d_csd.cfg +++ /dev/null @@ -1,16 +0,0 @@ -OUTPUT_DIR = ../result -OUTPUT_FILE = phantom2d_csd_1MeV_fine_nosh_nq8 -LOG_DIR = ../result/logs -MESH_FILE = phantom2D.su2 -PROBLEM = PHANTOM2D -SOLVER = CSD_SN_FOKKERPLANCK_TRAFO_SOLVER_2D -HYDROGEN_FILE = ENDL_H.txt -OXYGEN_FILE = ENDL_O.txt -KERNEL = ISOTROPIC -CFL_NUMBER = 0.15 -TIME_FINAL = 1.0 -CLEAN_FLUX_MATRICES = NO - -BC_DIRICHLET = ( void ) -QUAD_TYPE = PRODUCT -QUAD_ORDER = 6 diff --git a/code/input/pointSource_sph_csd.cfg b/code/input/pointSource_sph_csd.cfg index c5988b1ba2dde72f470501bfb18205f945b2e27e..eda1cde1a9f60373d6953e1f3bb45f9f875e84ad 100644 --- a/code/input/pointSource_sph_csd.cfg +++ b/code/input/pointSource_sph_csd.cfg @@ -4,7 +4,6 @@ LOG_DIR = ../result/logs MESH_FILE = phantom2D_fine.su2 PROBLEM = ISOTROPICPOINTSOURCE2D SOLVER = CSD_SN_FOKKERPLANCK_TRAFO_SH_SOLVER_2D -CONTINUOUS_SLOWING_DOWN = YES HYDROGEN_FILE = ENDL_H.txt OXYGEN_FILE = ENDL_O.txt KERNEL = ISOTROPIC diff --git a/code/input/exampleWaterphantomCSD.cfg b/code/input/waterphantomCSD.cfg similarity index 100% rename from code/input/exampleWaterphantomCSD.cfg rename to code/input/waterphantomCSD.cfg diff --git a/code/input/waterphantom_1D.cfg b/code/input/waterphantom_1D.cfg new file mode 100644 index 0000000000000000000000000000000000000000..71c374a41dad9c6217ef2c0c6a2a9a4906b9696b --- /dev/null +++ b/code/input/waterphantom_1D.cfg @@ -0,0 +1,26 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Checkerboard Benchmarking File SN % +% Author % +% Date 01.12.2020 % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% + +OUTPUT_DIR = ../result +OUTPUT_FILE = example_csd_1d_10MeV_fine +LOG_DIR = ../result/logs +MESH_FILE = meshes/1DMesh.su2 +PROBLEM = WATERPHANTOM +SOLVER = CSD_SN_FOKKERPLANCK_TRAFO_SOLVER +HYDROGEN_FILE = ENDL_H.txt +OXYGEN_FILE = ENDL_O.txt +KERNEL = ISOTROPIC_1D +CFL_NUMBER = 0.008 +TIME_FINAL = 1.0 +CLEAN_FLUX_MATRICES = NO +MAX_ENERGY_CSD = 5 +VOLUME_OUTPUT = (MINIMAL, MEDICAL) + +BC_DIRICHLET = ( dirichlet ) +BC_NEUMANN = ( wall_low, wall_up ) +QUAD_TYPE = GAUSS_LEGENDRE_1D +QUAD_ORDER = 26 diff --git a/code/input/waterphantom_2D.cfg b/code/input/waterphantom_2D.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b1343198f0828df983f411494c216d0c661ae170 --- /dev/null +++ b/code/input/waterphantom_2D.cfg @@ -0,0 +1,42 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Waterphantom Benchmarking File CSD % +% Author % +% Date 15.01.2020 % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ---- File specifications ---- +% +OUTPUT_DIR = ../result +OUTPUT_FILE = phantom2d_csd_10MeV_fine +LOG_DIR = ../result/logs +MESH_FILE = meshes/phantom2D.su2 +CT_FILE = phantom.png + +% +% ---- Problem specifications ---- +% +PROBLEM = PHANTOM2D +HYDROGEN_FILE = ENDL_H.txt +OXYGEN_FILE = ENDL_O.txt +% +% ---- Solver specifications ---- +% +SOLVER = CSD_SN_FOKKERPLANCK_TRAFO_SOLVER_2D +KERNEL = ISOTROPIC +CFL_NUMBER = 0.15 +TIME_FINAL = 1.0 +% +% --- Boundary Conditions --- +% +BC_DIRICHLET = ( void ) +QUAD_TYPE = PRODUCT +QUAD_ORDER = 6 +% +% ----- Output ---- +% +VOLUME_OUTPUT = (MINIMAL, MEDICAL) +VOLUME_OUTPUT_FREQUENCY = 1 +SCREEN_OUTPUT = (ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT) +SCREEN_OUTPUT_FREQUENCY = 1 +HISTORY_OUTPUT = (ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT) +HISTORY_OUTPUT_FREQUENCY = 1 diff --git a/code/src/common/config.cpp b/code/src/common/config.cpp index bb65b5cbe81cc7c3ac522f591488bb7a082e48e5..09cc41d7b9a9d500ec2cf9a3674736102468bf4e 100644 --- a/code/src/common/config.cpp +++ b/code/src/common/config.cpp @@ -1,5 +1,5 @@ /*! - * \file Config.cpp + * \file config.cpp * \brief Class for different Options in rtsn * \author S. Schotthoefer * @@ -198,7 +198,7 @@ void Config::SetConfigOptions() { /* BEGIN_CONFIG_OPTIONS */ - /*! @par CONFIG_CATEGORY: Problem Definition @ingroup Config */ + /*! @par CONFIG_CATEGORY: Problem Definition \ingroup Config */ /*--- Options related to problem definition and partitioning ---*/ // File Structure related options @@ -216,8 +216,9 @@ void Config::SetConfigOptions() { AddStringOption( "CT_FILE", _ctFile, string( "../tests/input/phantom.png" ) ); // Quadrature relatated options - /*! @brief QUAD_TYPE \n DESCRIPTION: Type of Quadrature rule \n Options: see @link QUAD_NAME \endlink \n DEFAULT: QUAD_MonteCarlo \ingroup - * Config*/ + /*! @brief QUAD_TYPE \n DESCRIPTION: Type of Quadrature rule \n Options: see @link QUAD_NAME \endlink \n DEFAULT: QUAD_MonteCarlo + * \ingroup Config + */ AddEnumOption( "QUAD_TYPE", _quadName, Quadrature_Map, QUAD_MonteCarlo ); /*!\brief QUAD_ORDER \n DESCRIPTION: Order of Quadrature rule \n DEFAULT 2 \ingroup Config.*/ AddUnsignedShortOption( "QUAD_ORDER", _quadOrder, 1 ); @@ -259,10 +260,10 @@ void Config::SetConfigOptions() { // Linesource Testcase Options /*! @brief SCATTER_COEFF \n DESCRIPTION: Sets the scattering coefficient for the Linesource test case. \n DEFAULT 0.0 \ingroup Config */ - AddDoubleOption( "SCATTER_COEFF", _sigmaS, 0.0 ); + AddDoubleOption( "SCATTER_COEFF", _sigmaS, 1.0 ); // CSD related options - /*! @brief: MAX_ENERGY_CSD \n DESCRIPTION: Sets maximum energy for the CSD simulation.\n DEFAULT \ingroup Config */ + /*! @brief MAX_ENERGY_CSD \n DESCRIPTION: Sets maximum energy for the CSD simulation.\n DEFAULT \ingroup Config */ AddDoubleOption( "MAX_ENERGY_CSD", _maxEnergyCSD, 5.0 ); // Entropy related options @@ -278,8 +279,8 @@ void Config::SetConfigOptions() { AddUnsignedLongOption( "NEWTON_ITER", _newtonIter, 100 ); /*! @brief Step Size Newton Optmizers \n DESCRIPTION: Step size for Newton optimizer \n DEFAULT 10 \ingroup Config */ AddDoubleOption( "NEWTON_STEP_SIZE", _newtonStepSize, 0.1 ); - /*! @brief Max Iter for line search in Newton Optmizers \n DESCRIPTION: Max number of line search iter for newton optimizer \n DEFAULT 10 \ingroup - * Config */ + /*! @brief Max Iter for line search in Newton Optmizers \n DESCRIPTION: Max number of line search iter for newton optimizer \n DEFAULT 10 + * \ingroup Config */ AddUnsignedLongOption( "NEWTON_LINE_SEARCH_ITER", _newtonLineSearchIter, 100 ); /*! @brief Newton Fast mode \n DESCRIPTION: If true, we skip the Newton optimizer for Quadratic entropy and set alpha = u \n DEFAULT false * \ingroup Config */ @@ -330,6 +331,15 @@ void Config::SetConfigOptions() { /*! @brief norm(u_1)/u_0 is enforced to be smaller than _RealizableSetEpsilonU1 \n DESCRIPTION: Distance to the boundary of the realizable set \n * DEFAULT 0.1 \ingroup Config */ AddDoubleOption( "REALIZABLE_SET_EPSILON_U1", _RealizableSetEpsilonU1, 0.9 ); + /*! @brief Flag for sampling of normalized moments, i.e. u_0 =1 \n DESCRIPTION: Flag for sampling of normalized moments, i.e. u_0 =1 \n + * DEFAULT False \ingroup Config */ + AddBoolOption( "NORMALIZED_SAMPLING", _normalizedSampling, false ); + /*! @brief Flag for sampling the space of Legendre multipliers instead of the moments \n DESCRIPTION: Sample alpha instead of u \n DEFAULT False + * \ingroup Config */ + AddBoolOption( "ALPHA_SAMPLING", _alphaSampling, false ); + /*! @brief Flag for sampling the space of Legendre multipliers instead of the moments \n DESCRIPTION: Sample alpha instead of u \n DEFAULT False + * \ingroup Config */ + AddBoolOption( "REALIZABILITY_RECONS_U", _realizabilityRecons, true ); } void Config::SetConfigParsing( string case_filename ) { @@ -690,7 +700,7 @@ bool Config::TokenizeString( string& str, string& option_name, vector& o pos = str.find( "=" ); if( pos == string::npos ) { string errmsg = "Error in Config::TokenizeString(): line in the configuration file with no \"=\" sign. "; - errmsg += "\nLook for: \n str.length() = " + str.length(); + errmsg += "\nLook for: \n str.length() = " + std::to_string( str.length() ); spdlog::error( errmsg ); throw( -1 ); } diff --git a/code/src/common/io.cpp b/code/src/common/io.cpp index 6609804b9ca7258e535411c9384f6d414617f3c4..ec1b8ddcf2b922f965f93361498716dd1a4fb1d1 100644 --- a/code/src/common/io.cpp +++ b/code/src/common/io.cpp @@ -22,7 +22,6 @@ #include #include #include -//#include #include #include #include @@ -31,7 +30,6 @@ #include #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION -#define PY_ARRAY_UNIQUE_SYMBOL KITRT_IO_ARRAY_API #include using vtkPointsSP = vtkSmartPointer; @@ -41,7 +39,6 @@ using vtkCellArraySP = vtkSmartPointer; using vtkDoubleArraySP = vtkSmartPointer; using vtkUnstructuredGridWriterSP = vtkSmartPointer; using vtkCellDataToPointDataSP = vtkSmartPointer; -// using vtkPointDataToCellDataSP = vtkSmartPointer; void ExportVTK( const std::string fileName, const std::vector>>& outputFields, @@ -197,7 +194,8 @@ Mesh* LoadSU2MeshFromFile( const Config* settings ) { getline( ifs, line ); if( line.find( "MARKER_TAG", 0 ) != std::string::npos ) { markerTag = line.substr( line.find( "=" ) + 1 ); - auto end_pos = std::remove_if( markerTag.begin(), markerTag.end(), isspace ); + auto end_pos = std::remove_if( + markerTag.begin(), markerTag.end(), []( char c ) { return std::isspace( static_cast( c ) ); } ); markerTag.erase( end_pos, markerTag.end() ); btype = settings->GetBoundaryType( markerTag ); if( btype == BOUNDARY_TYPE::INVALID ) { diff --git a/code/src/common/mesh.cpp b/code/src/common/mesh.cpp index 8f62bb486e0c97383ae55155f3dc2e1a8ccaff67..ba56486440d990e58d53a4179968f0523dc88ece 100644 --- a/code/src/common/mesh.cpp +++ b/code/src/common/mesh.cpp @@ -17,7 +17,6 @@ Mesh::Mesh( std::vector nodes, ComputeCellAreas(); ComputeCellMidpoints(); ComputeConnectivity(); - // ComputePartitioning(); ComputeBounds(); } @@ -219,142 +218,6 @@ Vector Mesh::ComputeOutwardFacingNormal( const Vector& nodeA, const Vector& node return n; } -void Mesh::ComputePartitioning() { - int comm_size, comm_rank; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Comm_size( comm, &comm_size ); - MPI_Comm_rank( comm, &comm_rank ); - unsigned ompNumThreads = omp_get_max_threads(); - - // only run coloring if multiple OpenMP threads are present - if( ompNumThreads > 1 ) { - // setup adjacency relationship of nodes - blaze::CompressedMatrix adjMatrix( _numNodes, _numNodes ); - for( unsigned i = 0; i < _numNodes; ++i ) { - for( unsigned j = 0; j < _numCells; ++j ) { - for( unsigned k = 0; k < _numNodesPerCell; ++k ) { - if( i == _cells[j][k] ) { - if( k == 0 ) { - adjMatrix.set( i, _cells[j][_numNodesPerCell - 1], true ); - adjMatrix.set( i, _cells[j][1], true ); - } - else if( k == _numNodesPerCell - 1 ) { - adjMatrix.set( i, _cells[j][_numNodesPerCell - 2], true ); - adjMatrix.set( i, _cells[j][0], true ); - } - else { - adjMatrix.set( i, _cells[j][k - 1], true ); - adjMatrix.set( i, _cells[j][k + 1], true ); - } - } - } - } - } - - // for xadj and adjncy structure see parmetis documentation - std::vector xadj( _numNodes + 1 ); - int ctr = 0; - std::vector adjncy; - for( unsigned i = 0; i < _numNodes; ++i ) { - xadj[i] = ctr; - for( unsigned j = 0; j < _numNodes; ++j ) { - if( adjMatrix( i, j ) ) { - adjncy.push_back( static_cast( j ) ); - ctr++; - } - } - } - xadj[_numNodes] = ctr; - - std::vector partitions; - int edgecut = 0; - int ncon = 1; - int nparts = ompNumThreads; - real_t ubvec = static_cast( 1.05 ); // parameter taken from SU2 - - if( comm_size > 1 ) { // if multiple MPI threads -> use parmetis - // split adjacency information for each MPI thread -> see 'local' variables - std::vector local_xadj{ 0 }; - unsigned xadjChunk = std::ceil( static_cast( _numNodes ) / static_cast( comm_size ) ); - unsigned xadjStart = comm_rank * xadjChunk + 1; - unsigned adjncyStart; - for( unsigned i = 0; i < xadjChunk; ++i ) { - if( i == 0 ) adjncyStart = xadj[i + xadjStart - 1]; - local_xadj.push_back( xadj[i + xadjStart] ); - } - unsigned adjncyEnd = local_xadj.back(); - for( unsigned i = 1; i < local_xadj.size(); ++i ) { - local_xadj[i] -= xadj[xadjStart - 1]; - } - std::vector local_adjncy( adjncy.begin() + adjncyStart, adjncy.begin() + adjncyEnd ); - - // vtxdist describes what nodes are on which processor - see parmetis doc - std::vector vtxdist{ 0 }; - for( unsigned i = 1; i <= static_cast( comm_size ); i++ ) { - vtxdist.push_back( std::min( i * xadjChunk, _numNodes ) ); - } - - // weights setup set as in SU2 - real_t* tpwgts = new real_t[nparts]; - for( unsigned i = 0; i < static_cast( nparts ); ++i ) { - tpwgts[i] = 1.0 / static_cast( nparts ); - } - - // setup as in SU2 - int wgtflag = 0; - int numflag = 0; - int options[1]; - options[0] = 0; - - unsigned chunkSize = local_xadj.size() - 1; - int* part = new int[chunkSize]; - ParMETIS_V3_PartKway( vtxdist.data(), - local_xadj.data(), - local_adjncy.data(), - nullptr, - nullptr, - &wgtflag, - &numflag, - &ncon, - &nparts, - tpwgts, - &ubvec, - options, - &edgecut, - part, - &comm ); - partitions.resize( chunkSize * comm_size ); - MPI_Allgather( part, chunkSize, MPI_INT, partitions.data(), chunkSize, MPI_INT, comm ); // gather all information in partitions - partitions.resize( _numNodes ); - - // free memory - delete[] tpwgts; - } - else { // with a singular MPI thread -> use metis - int options[METIS_NOPTIONS]; - METIS_SetDefaultOptions( options ); - int nvtxs = _numNodes; - int vsize; - partitions.resize( _numNodes ); - METIS_PartGraphKway( - &nvtxs, &ncon, xadj.data(), adjncy.data(), nullptr, &vsize, nullptr, &nparts, nullptr, &ubvec, options, &edgecut, partitions.data() ); - } - - // extract coloring information - _colors.resize( _numCells ); - for( unsigned i = 0; i < _numCells; ++i ) { - std::map occurances; - for( unsigned j = 0; j < _numNodesPerCell; ++j ) { - ++occurances[partitions[_cells[i][j]]]; - } - _colors[i] = occurances.rbegin()->first; - } - } - else { - _colors.resize( _numCells, 0u ); - } -} - void Mesh::ComputeSlopes( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerY, const VectorVector& psi ) const { for( unsigned k = 0; k < nq; ++k ) { for( unsigned j = 0; j < _numCells; ++j ) { @@ -403,8 +266,8 @@ void Mesh::ReconstructSlopesS( unsigned nq, VectorVector& psiDerX, VectorVector& void Mesh::ReconstructSlopesU( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerY, const VectorVector& psi ) const { double phi; - //VectorVector dPsiMax = std::vector( _numCells, Vector( nq, 0.0 ) ); - //VectorVector dPsiMin = std::vector( _numCells, Vector( nq, 0.0 ) ); + // VectorVector dPsiMax = std::vector( _numCells, Vector( nq, 0.0 ) ); + // VectorVector dPsiMin = std::vector( _numCells, Vector( nq, 0.0 ) ); VectorVector dPsiMax( _numCells, Vector( nq, 0.0 ) ); VectorVector dPsiMin( _numCells, Vector( nq, 0.0 ) ); @@ -434,7 +297,7 @@ void Mesh::ReconstructSlopesU( unsigned nq, VectorVector& psiDerX, VectorVector& for( unsigned l = 0; l < _cellNeighbors[j].size(); ++l ) { // step 2: choose sample points // psiSample[j][k][l] = 0.5 * ( psi[j][k] + psi[_cellNeighbors[j][l]][k] ); // interface central points - psiSample[j][k][l] = psi[j][k] + + psiSample[j][k][l] = psi[j][k] + psiDerX[j][k] * ( _nodes[_cells[j][l]][0] - _cellMidPoints[j][0] ) + psiDerY[j][k] * ( _nodes[_cells[j][l]][1] - _cellMidPoints[j][1] ); // vertex points @@ -457,7 +320,7 @@ void Mesh::ReconstructSlopesU( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerX[j][k] *= phi; psiDerY[j][k] *= phi; */ - + double eps = 1e-6; // version 2: Venkatakrishnan limiter // step 1: calculate psi difference around neighbors and theoretical derivatives by Gauss theorem @@ -471,19 +334,20 @@ void Mesh::ReconstructSlopesU( unsigned nq, VectorVector& psiDerX, VectorVector& for( unsigned l = 0; l < _cellNeighbors[j].size(); ++l ) { // step 2: choose sample points - psiSample[j][k][l] = 10.0 * psiDerX[j][k] * (_cellMidPoints[_cellNeighbors[j][l]][0] - _cellMidPoints[j][0]) + - 10.0 * psiDerY[j][k] * (_cellMidPoints[_cellNeighbors[j][l]][1] - _cellMidPoints[j][1]); + psiSample[j][k][l] = 10.0 * psiDerX[j][k] * ( _cellMidPoints[_cellNeighbors[j][l]][0] - _cellMidPoints[j][0] ) + + 10.0 * psiDerY[j][k] * ( _cellMidPoints[_cellNeighbors[j][l]][1] - _cellMidPoints[j][1] ); // step 3: calculate Phi_ij at sample points if( psiSample[j][k][l] > 0.0 ) { - phiSample[j][k][l] = - (dPsiMax[j][k]*dPsiMax[j][k] + 2.0 * dPsiMax[j][k] * psiSample[j][k][l] + eps)/ - (dPsiMax[j][k]*dPsiMax[j][k] + dPsiMax[j][k] * psiSample[j][k][l] + 2.0 * psiSample[j][k][l] * psiSample[j][k][l] + eps); + phiSample[j][k][l] = + ( dPsiMax[j][k] * dPsiMax[j][k] + 2.0 * dPsiMax[j][k] * psiSample[j][k][l] + eps ) / + ( dPsiMax[j][k] * dPsiMax[j][k] + dPsiMax[j][k] * psiSample[j][k][l] + 2.0 * psiSample[j][k][l] * psiSample[j][k][l] + eps ); } else if( psiSample[j][k][l] < 0.0 ) { - phiSample[j][k][l] = - (dPsiMin[j][k]*dPsiMin[j][k] + 2.0 * dPsiMin[j][k] * psiSample[j][k][l] + eps)/ - (dPsiMin[j][k]*dPsiMin[j][k] + dPsiMin[j][k] * psiSample[j][k][l] + 2.0 * psiSample[j][k][l] * psiSample[j][k][l] + eps);; + phiSample[j][k][l] = + ( dPsiMin[j][k] * dPsiMin[j][k] + 2.0 * dPsiMin[j][k] * psiSample[j][k][l] + eps ) / + ( dPsiMin[j][k] * dPsiMin[j][k] + dPsiMin[j][k] * psiSample[j][k][l] + 2.0 * psiSample[j][k][l] * psiSample[j][k][l] + eps ); + ; } else { phiSample[j][k][l] = 1.0; @@ -492,15 +356,13 @@ void Mesh::ReconstructSlopesU( unsigned nq, VectorVector& psiDerX, VectorVector& // step 4: find minimum limiter function phi phi = min( phiSample[j][k] ); - //phi = fmin( 0.5, abs(phi) ); + // phi = fmin( 0.5, abs(phi) ); // step 5: limit the slope reconstructed from Gauss theorem psiDerX[j][k] *= phi; psiDerY[j][k] *= phi; - } } - } void Mesh::ComputeBounds() { @@ -517,7 +379,6 @@ const std::vector& Mesh::GetNodes() const { return _nodes; } const std::vector& Mesh::GetCellMidPoints() const { return _cellMidPoints; } const std::vector>& Mesh::GetCells() const { return _cells; } const std::vector& Mesh::GetCellAreas() const { return _cellAreas; } -const std::vector& Mesh::GetPartitionIDs() const { return _colors; } const std::vector>& Mesh::GetNeighbours() const { return _cellNeighbors; } const std::vector>& Mesh::GetNormals() const { return _cellNormals; } const std::vector& Mesh::GetBoundaryTypes() const { return _cellBoundaryTypes; } diff --git a/code/src/common/optionstructure.cpp b/code/src/common/optionstructure.cpp index ac39e7fce525f2b0ab73f9fcf1a20095ec17a5a7..048fa151e72b184ca331726d27a5416ed8008128 100644 --- a/code/src/common/optionstructure.cpp +++ b/code/src/common/optionstructure.cpp @@ -1,5 +1,5 @@ /*! - * \file Config.cpp + * \file config.cpp * \brief Classes for different Optiontypes in rtsn * \author S. Schotthoefer * diff --git a/code/src/fluxes/upwindflux.cpp b/code/src/fluxes/upwindflux.cpp index 5c3078db281973c23eb180cb4ff6ba2a32e06bdd..b46d91dcc7aac33c498092278c62b6425da1f743 100644 --- a/code/src/fluxes/upwindflux.cpp +++ b/code/src/fluxes/upwindflux.cpp @@ -3,7 +3,7 @@ UpwindFlux::UpwindFlux() : NumericalFlux() {} double UpwindFlux::Flux( const Vector& Omega, double psiL, double psiR, const Vector& n ) const { - double inner = Omega[0] * n[0] + Omega[1] * n[1]; + double inner = Omega[0] * n[0] + Omega[1] * n[1]; // Only use x and y axis in 2d case if( inner > 0 ) { return inner * psiL; } @@ -12,21 +12,6 @@ double UpwindFlux::Flux( const Vector& Omega, double psiL, double psiR, const Ve } } -/** - * @brief Flux : Computes upwinding scheme for given flux jacobians of the PN Solver at a given edge and stores it in - * resultFlux - * @param AxPlus : Positive part of the flux jacobian in x direction - * @param AxMinus : Negative part of the flux jacobian in x direction - * @param AyPlus : Positive part of the flux jacobian in y direction - * @param AyMinus : Negative part of the flux jacobian in y direction - * @param AzPlus : Positive part of the flux jacobian in z direction - * @param AzMinus : Negative part of the flux jacobian in z direction - * @param psiL : Solution state of left hand side control volume - * @param psiR : Solution state of right hand side control volume - * @param n : Normal vector at the edge between left and right control volume - * @return resultFlux: Vector with resulting flux. - */ - Vector UpwindFlux::Flux( const Matrix AxPlus, const Matrix AxMinus, const Matrix AyPlus, @@ -57,21 +42,6 @@ Vector UpwindFlux::Flux( const Matrix AxPlus, return resultFlux; } -/** - * @brief Flux : Computes upwinding scheme for given flux jacobians of the PN Solver at a given edge and stores it in - * resultFlux - * @param AxPlus : Positive part of the flux jacobian in x direction - * @param AxMinus : Negative part of the flux jacobian in x direction - * @param AyPlus : Positive part of the flux jacobian in y direction - * @param AyMinus : Negative part of the flux jacobian in y direction - * @param AzPlus : Positive part of the flux jacobian in z direction - * @param AzMinus : Negative part of the flux jacobian in z direction - * @param psiL : Solution state of left hand side control volume - * @param psiR : Solution state of right hand side control volume - * @param n : Normal vector at the edge between left and right control volume - * @param resultFlux: Vector with resulting flux. - * @return : void - */ void UpwindFlux::FluxVanLeer( const Matrix& Ax, const Matrix& AxAbs, const Matrix& /*Ay*/, diff --git a/code/src/main.cpp b/code/src/main.cpp index 0598d6b583b1fabd655417174c8418e96cea02ea..0a51c1936c548e97f58a357bc68e65d2412d3e7f 100644 --- a/code/src/main.cpp +++ b/code/src/main.cpp @@ -1,10 +1,11 @@ /*! @file: main.cpp - * @brief: Main method to call the KiT-RT solver suite + * @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 +#define PY_ARRAY_UNIQUE_SYMBOL KITRT_ARRAY_API #include #include @@ -12,7 +13,7 @@ #include "common/io.h" #include "solvers/solverbase.h" -#include "toolboxes/datagenerator.h" +#include "toolboxes/datageneratorbase.h" #ifdef BUILD_GUI #include @@ -42,13 +43,13 @@ int main( int argc, char** argv ) { if( config->GetDataGeneratorMode() ) { // Build Data generator - nnDataGenerator* datagen = new nnDataGenerator( config ); + DataGeneratorBase* datagen = DataGeneratorBase::Create( config ); // Generate Data and export - datagen->computeTrainingData(); + datagen->ComputeTrainingData(); } else { // Build solver - Solver* solver = Solver::Create( config ); + SolverBase* solver = SolverBase::Create( config ); // Run solver and export solver->Solve(); diff --git a/code/src/optimizers/mloptimizer.cpp b/code/src/optimizers/mloptimizer.cpp index 24fedd742eb9e5593e4a8c004191c0ebf7d772c7..9153dfc53ef4a121de31a586c07f0178d785535b 100644 --- a/code/src/optimizers/mloptimizer.cpp +++ b/code/src/optimizers/mloptimizer.cpp @@ -1,7 +1,6 @@ #define PY_SSIZE_T_CLEAN #include #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION -#define PY_ARRAY_UNIQUE_SYMBOL KITRT_MLOPT_ARRAY_API #include #include "common/config.h" @@ -29,7 +28,7 @@ MLOptimizer::MLOptimizer( Config* settings ) : OptimizerBase( settings ) { MLOptimizer::~MLOptimizer() { finalizePython(); } -void MLOptimizer::Solve( Vector& lambda, Vector& u, const VectorVector& /*moments*/, unsigned /*idx_cell*/ ) { +void MLOptimizer::Solve( Vector& alpha, Vector& u, const VectorVector& /*moments*/, unsigned /*idx_cell*/ ) { // Convert Vector to array const unsigned input_size = u.size(); @@ -47,13 +46,13 @@ void MLOptimizer::Solve( Vector& lambda, Vector& u, const VectorVector& /*moment for( unsigned i = 0; i < input_size; i++ ) { // std::cout << nn_output[i] << ", "; - lambda[i] = nn_output[i]; + alpha[i] = nn_output[i]; } // std::cout << std::endl; delete[] nn_input; } -void MLOptimizer::SolveMultiCell( VectorVector& lambda, VectorVector& u, const VectorVector& /*moments*/ ) { +void MLOptimizer::SolveMultiCell( VectorVector& alpha, VectorVector& u, const 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 @@ -76,7 +75,7 @@ void MLOptimizer::SolveMultiCell( VectorVector& lambda, VectorVector& u, const V unsigned idx_output = 0; for( unsigned idx_cell = 0; idx_cell < batch_size; idx_cell++ ) { for( unsigned idx_sys = 0; idx_sys < sol_dim; idx_sys++ ) { - lambda[idx_cell][idx_sys] = nn_output[idx_output]; + alpha[idx_cell][idx_sys] = nn_output[idx_output]; idx_output++; } } diff --git a/code/src/optimizers/newtonoptimizer.cpp b/code/src/optimizers/newtonoptimizer.cpp index 104b59db516fe62bfa522cd7fc5c8e92f1029ce8..e686480412aec63145b1c136c355301697f46078 100644 --- a/code/src/optimizers/newtonoptimizer.cpp +++ b/code/src/optimizers/newtonoptimizer.cpp @@ -9,6 +9,7 @@ #include "entropies/entropybase.h" #include "quadratures/quadraturebase.h" #include "toolboxes/errormessages.h" +#include "toolboxes/textprocessingtoolbox.h" #include @@ -68,25 +69,31 @@ void NewtonOptimizer::ComputeHessian( Vector& alpha, const VectorVector& moments } } -void NewtonOptimizer::SolveMultiCell( VectorVector& lambda, VectorVector& sol, const VectorVector& moments ) { +void NewtonOptimizer::SolveMultiCell( VectorVector& alpha, VectorVector& sol, const VectorVector& moments ) { - unsigned nCells = lambda.size(); + unsigned nCells = alpha.size(); // if we have quadratic entropy, then alpha = u; if( _settings->GetEntropyName() == QUADRATIC && _settings->GetNewtonFastMode() ) { for( unsigned idx_cell = 0; idx_cell < nCells; idx_cell++ ) { - lambda[idx_cell] = sol[idx_cell]; + alpha[idx_cell] = sol[idx_cell]; } return; } #pragma omp parallel for schedule( guided ) for( unsigned idx_cell = 0; idx_cell < nCells; idx_cell++ ) { - Solve( lambda[idx_cell], sol[idx_cell], moments, idx_cell ); + // std::cout << "Sol Vector" + // << "|" << sol[idx_cell] << "\n"; + + Solve( alpha[idx_cell], sol[idx_cell], moments, idx_cell ); + // if( idx_cell % 10000 == 0 ) { + // printf( "%d\n", idx_cell ); + //} } } -void NewtonOptimizer::Solve( Vector& lambda, Vector& sol, const VectorVector& moments, unsigned idx_cell ) { +void NewtonOptimizer::Solve( Vector& alpha, Vector& sol, const VectorVector& moments, unsigned idx_cell ) { /* solve the problem argmin ( -alpha*u)) * where alpha = Lagrange multiplier @@ -96,18 +103,18 @@ void NewtonOptimizer::Solve( Vector& lambda, Vector& sol, const VectorVector& mo // if we have quadratic entropy, then alpha = u; if( _settings->GetEntropyName() == QUADRATIC && _settings->GetNewtonFastMode() ) { - lambda = sol; + alpha = sol; return; } // Start Newton Algorithm - unsigned nSize = lambda.size(); + unsigned nSize = alpha.size(); Vector grad( nSize, 0.0 ); // check if initial guess is good enough - ComputeGradient( lambda, sol, moments, grad ); + ComputeGradient( alpha, sol, moments, grad ); if( norm( grad ) < _epsilon ) { return; @@ -117,60 +124,60 @@ void NewtonOptimizer::Solve( Vector& lambda, Vector& sol, const VectorVector& mo Matrix H( nSize, nSize, 0.0 ); // calculate initial Hessian and gradient - Vector dlambda = -grad; - ComputeHessian( lambda, moments, H ); + Vector dalpha = -grad; + ComputeHessian( alpha, moments, H ); // invert Hessian invert( H ); if( _maxIterations == 1 ) { - lambda = lambda - _alpha * H * grad; + alpha = alpha - _alpha * H * grad; return; } - Vector lambdaNew( nSize, 0.0 ); // New newton step - Vector dlambdaNew( nSize ); // Gradient at New newton step + Vector alphaNew( nSize, 0.0 ); // New newton step + Vector dalphaNew( nSize ); // Gradient at New newton step - lambdaNew = lambda - _alpha * H * grad; + alphaNew = alpha - _alpha * H * grad; // Compute Gradient of new point; - ComputeGradient( lambdaNew, sol, moments, dlambdaNew ); + ComputeGradient( alphaNew, sol, moments, dalphaNew ); // perform Newton iterations for( unsigned l = 0; l < _maxIterations; ++l ) { double stepSize = 1.0; if( l != 0 ) { - ComputeGradient( lambda, sol, moments, grad ); + ComputeGradient( alpha, sol, moments, grad ); - dlambda = -grad; - ComputeHessian( lambda, moments, H ); + dalpha = -grad; + ComputeHessian( alpha, moments, H ); invert( H ); - lambdaNew = lambda - _alpha * H * grad; - ComputeGradient( lambdaNew, sol, moments, dlambdaNew ); + alphaNew = alpha - _alpha * H * grad; + ComputeGradient( alphaNew, sol, moments, dalphaNew ); } // Line Search int lineSearchCounter = 0; - while( norm( dlambda ) < norm( dlambdaNew ) || !std::isfinite( norm( dlambdaNew ) ) ) { + while( norm( dalpha ) < norm( dalphaNew ) || !std::isfinite( norm( dalphaNew ) ) ) { stepSize *= 0.5; - lambdaNew = lambda - stepSize * _alpha * H * grad; - ComputeGradient( lambdaNew, sol, moments, dlambdaNew ); + alphaNew = alpha - stepSize * _alpha * H * grad; + ComputeGradient( alphaNew, sol, moments, dalphaNew ); // Check if FONC is fullfilled - if( norm( dlambdaNew ) < _epsilon ) { - lambda = lambdaNew; + if( norm( dalphaNew ) < _epsilon ) { + alpha = alphaNew; return; } else if( ++lineSearchCounter > _maxLineSearches ) { ErrorMessages::Error( "Newton needed too many refinement steps! at cell " + std::to_string( idx_cell ), CURRENT_FUNCTION ); } } - lambda = lambdaNew; - if( norm( dlambdaNew ) < _epsilon ) { - lambda = lambdaNew; + alpha = alphaNew; + if( norm( dalphaNew ) < _epsilon ) { + alpha = alphaNew; return; } } @@ -180,10 +187,14 @@ void NewtonOptimizer::Solve( Vector& lambda, Vector& sol, const VectorVector& mo } uSolString += ")."; - Vector u1 = { sol[1], sol[2], sol[3] }; - double normU1 = norm( u1 ); - ErrorMessages::Error( "Newton did not converge at cell " + std::to_string( idx_cell ) + "\n" + uSolString + - "\nNorm of gradient: " + std::to_string( norm( dlambdaNew ) ) + "\nObjective function value: " + - std::to_string( ComputeObjFunc( lambda, sol, moments ) ) + "\nBoundary Ratio: " + std::to_string( normU1 / sol[0] ), - CURRENT_FUNCTION ); + if( _settings->GetDim() != 1 ) { + Vector u1 = { sol[1], sol[2], sol[3] }; + double normU1 = norm( u1 ); + ErrorMessages::Error( "Newton did not converge at cell " + std::to_string( idx_cell ) + "\n" + uSolString + + "\nNorm of gradient: " + std::to_string( norm( dalphaNew ) ) + "\nObjective function value: " + + std::to_string( ComputeObjFunc( alpha, sol, moments ) ) + "\nBoundary Ratio: " + std::to_string( normU1 / sol[0] ), + CURRENT_FUNCTION ); + } + if( _settings->GetDim() == 1 ) { + } } diff --git a/code/src/problems/checkerboard.cpp b/code/src/problems/checkerboard.cpp index b98634844bac1f81fe00bb97e8f859b3f7b0b87d..5e939e9fb7ee6880f4bf3421dbf9cef5a8ca9166 100644 --- a/code/src/problems/checkerboard.cpp +++ b/code/src/problems/checkerboard.cpp @@ -1,6 +1,7 @@ #include "problems/checkerboard.h" #include "common/config.h" #include "common/mesh.h" +#include "toolboxes/sphericalbase.h" // ---- Checkerboard Sn ---- // Constructor for Ckeckerboard case with Sn @@ -66,9 +67,12 @@ bool Checkerboard_SN::isSource( const Vector& pos ) const { //////////////////////////////////////////////////////////////////////////////////////////////////// -// ---- Checkerboard Pn ---- +// ---- Checkerboard Moments ---- + // Constructor for checkerboard case with Pn -Checkerboard_PN::Checkerboard_PN( Config* settings, Mesh* mesh ) : ProblemBase( settings, mesh ) { +Checkerboard_Moment::Checkerboard_Moment( Config* settings, Mesh* mesh ) : ProblemBase( settings, mesh ) { + + _basis = SphericalBase::Create(_settings); _physics = nullptr; // Initialise crosssections = 1 (scattering) @@ -85,13 +89,15 @@ Checkerboard_PN::Checkerboard_PN( Config* settings, Mesh* mesh ) : ProblemBase( } } -Checkerboard_PN::~Checkerboard_PN() {} +Checkerboard_Moment::~Checkerboard_Moment() { + delete _basis; +} -VectorVector Checkerboard_PN::GetScatteringXS( const Vector& energies ) { return VectorVector( energies.size(), _scatteringXS ); } +VectorVector Checkerboard_Moment::GetScatteringXS( const Vector& energies ) { return VectorVector( energies.size(), _scatteringXS ); } -VectorVector Checkerboard_PN::GetTotalXS( const Vector& energies ) { return VectorVector( energies.size(), _totalXS ); } +VectorVector Checkerboard_Moment::GetTotalXS( const Vector& energies ) { return VectorVector( energies.size(), _totalXS ); } -std::vector Checkerboard_PN::GetExternalSource( const Vector& /*energies*/ ) { +std::vector Checkerboard_Moment::GetExternalSource( const Vector& /*energies*/ ) { VectorVector Q( _mesh->GetNumCells(), Vector( 1u, 0.0 ) ); auto cellMids = _mesh->GetCellMidPoints(); for( unsigned j = 0; j < cellMids.size(); ++j ) { @@ -100,13 +106,13 @@ std::vector Checkerboard_PN::GetExternalSource( const Vector& /*en return std::vector( 1u, Q ); } -VectorVector Checkerboard_PN::SetupIC() { - int ntotalEquations = GlobalIndex( _settings->GetMaxMomentDegree(), _settings->GetMaxMomentDegree() ) + 1; +VectorVector Checkerboard_Moment::SetupIC() { + int ntotalEquations = _basis->GetBasisSize(); VectorVector psi( _mesh->GetNumCells(), Vector( ntotalEquations, 1e-10 ) ); return psi; } -bool Checkerboard_PN::isAbsorption( const Vector& pos ) const { +bool Checkerboard_Moment::isAbsorption( const Vector& pos ) const { // Check whether pos is in absorption region std::vector lbounds{ 1, 2, 3, 4, 5 }; std::vector ubounds{ 2, 3, 4, 5, 6 }; @@ -121,16 +127,10 @@ bool Checkerboard_PN::isAbsorption( const Vector& pos ) const { return false; } -bool Checkerboard_PN::isSource( const Vector& pos ) const { +bool Checkerboard_Moment::isSource( const Vector& pos ) const { // Check whether pos is in source region if( pos[0] >= 3 && pos[0] <= 4 && pos[1] >= 3 && pos[1] <= 4 ) return true; else return false; } - -int Checkerboard_PN::GlobalIndex( int l, int k ) const { - int numIndicesPrevLevel = l * l; // number of previous indices untill level l-1 - int prevIndicesThisLevel = k + l; // number of previous indices in current level - return numIndicesPrevLevel + prevIndicesThisLevel; -} diff --git a/code/src/problems/icru.cpp b/code/src/problems/icru.cpp index 3466babe3bf12e71b6b22d7e298424aa9a17881b..17bc9eec0eb7f0442b2ad18071a4fc34b732409b 100644 --- a/code/src/problems/icru.cpp +++ b/code/src/problems/icru.cpp @@ -404,8 +404,8 @@ void ICRU::SPLINE( const std::vector& X, if( N < 4 ) { ErrorMessages::Error( "Too few points", CURRENT_FUNCTION ); } - unsigned N1 = N - 2; - unsigned N2 = N - 3; + unsigned N1 = N - 1; + unsigned N2 = N - 2; A.resize( N ); B.resize( N ); @@ -423,21 +423,21 @@ void ICRU::SPLINE( const std::vector& X, for( unsigned I = 0; I < N2; ++I ) { B[I] = 2.0e0 * ( A[I] + A[I + 1] ); - unsigned K = N1 - I; + unsigned K = N1 - I - 1; D[K] = 6.0e0 * ( D[K] - D[K - 1] ); } D[1] -= A[0] * S1; - D[N1] = D[N1] - A[N1] * SN; + D[N1 - 1] -= A[N1 - 1] * SN; - for( unsigned I = 1; I < N2 + 1; ++I ) { + for( unsigned I = 1; I < N2; ++I ) { double R = A[I] / B[I - 1]; B[I] -= R * A[I]; D[I + 1] -= R * D[I]; } - D[N1] = D[N1] / B[N2]; + D[N1 - 1] /= B[N2 - 1]; for( unsigned I = 1; I < N2; ++I ) { - unsigned K = N1 - I; + unsigned K = N1 - I - 1; D[K] = ( D[K] - A[K] * D[K + 1] ) / B[K - 1]; } D[N - 1] = SN; @@ -473,7 +473,7 @@ void ICRU::FINDI( std::vector X, double XC, unsigned N, unsigned& I ) { return; } I = 0; - unsigned I1 = N; + unsigned I1 = N - 1; while( I1 - I > 1 ) { double IT = ( I + I1 ) / 2; if( XC > X[IT] ) diff --git a/code/src/problems/linesource.cpp b/code/src/problems/linesource.cpp index 7678f1279193006114f10ec2de86115fe2fd5818..8c257dcebf16ad6b43e36b6996fb9e777e238b17 100644 --- a/code/src/problems/linesource.cpp +++ b/code/src/problems/linesource.cpp @@ -163,7 +163,6 @@ Vector LineSource_SN_Pseudo1D_Physics::GetTotalXSE( const Vector& energies ) { r // ---- LineSource_PN ---- - LineSource_PN::LineSource_PN( Config* settings, Mesh* mesh ) : LineSource( settings, mesh ) {} LineSource_PN::~LineSource_PN() {} diff --git a/code/src/problems/problembase.cpp b/code/src/problems/problembase.cpp index b678716c3f93355b4613962be3325ad0c5d305a5..66b628078cefcf7f273c3276c4e3c6266b294624 100644 --- a/code/src/problems/problembase.cpp +++ b/code/src/problems/problembase.cpp @@ -30,7 +30,7 @@ ProblemBase* ProblemBase::Create( Config* settings, Mesh* mesh ) { } case PROBLEM_Checkerboard: { if( settings->GetSolverName() == PN_SOLVER || settings->GetSolverName() == MN_SOLVER ) - return new Checkerboard_PN( settings, mesh ); + return new Checkerboard_Moment( settings, mesh ); else return new Checkerboard_SN( settings, mesh ); // default } diff --git a/code/src/quadratures/qgausschebyshev1D.cpp b/code/src/quadratures/qgausschebyshev1D.cpp index 83fed6c7113547c06159d01e89ef84fcc0146c9b..dd3e51ce4bdc15081385bcb2a40252421f5b80db 100644 --- a/code/src/quadratures/qgausschebyshev1D.cpp +++ b/code/src/quadratures/qgausschebyshev1D.cpp @@ -40,7 +40,7 @@ bool QGaussChebyshev1D::CheckOrder() { return true; // All orders viable } -double QGaussChebyshev1D::Integrate( double( f )( double x0, double x1, double x2 ) ) { // Not Safe! +double QGaussChebyshev1D::Integrate( double ( *f )( double, double, double ) ) { // Not Safe! double result = 0.0; double x = 0.0; double y = 0.0; @@ -54,12 +54,12 @@ double QGaussChebyshev1D::Integrate( double( f )( double x0, double x1, double x return result; } -double QGaussChebyshev1D::IntegrateSpherical( double( f )( double my, double phi ) ) { +double QGaussChebyshev1D::IntegrateSpherical( double ( *f )( double, double ) ) { ErrorMessages::Error( "This method is not applicable for 1D quadratures.\n", CURRENT_FUNCTION ); return f( 0, 0 ); } -std::vector QGaussChebyshev1D::Integrate( std::vector( f )( double x0, double x1, double x2 ), unsigned /* len */ ) { +std::vector QGaussChebyshev1D::Integrate( std::vector ( *f )( double, double, double ), unsigned /* len */ ) { ErrorMessages::Error( "This method is not applicable for 1D quadratures.\n", CURRENT_FUNCTION ); return { f( 0, 0, 0 ) }; } diff --git a/code/src/quadratures/qgausslegendre1D.cpp b/code/src/quadratures/qgausslegendre1D.cpp index bcd75e80da0e831bfd2763fd5cc01c391227e7d9..4ebe7de42e7d6add1f1c0ea10b5028ccac722c71 100644 --- a/code/src/quadratures/qgausslegendre1D.cpp +++ b/code/src/quadratures/qgausslegendre1D.cpp @@ -144,7 +144,7 @@ bool QGaussLegendre1D::CheckOrder() { return true; // All orders viable } -double QGaussLegendre1D::Integrate( double( f )( double x0, double x1, double x2 ) ) { // Not Safe! +double QGaussLegendre1D::Integrate( double ( *f )( double, double, double ) ) { // Not Safe! double result = 0.0; double x = 0.0; double y = 0.0; @@ -158,12 +158,12 @@ double QGaussLegendre1D::Integrate( double( f )( double x0, double x1, double x2 return result; } -double QGaussLegendre1D::IntegrateSpherical( double( f )( double my, double phi ) ) { +double QGaussLegendre1D::IntegrateSpherical( double ( *f )( double, double ) ) { ErrorMessages::Error( "This method is not applicable for 1D quadratures.\n", CURRENT_FUNCTION ); return f( 0, 0 ); } -std::vector QGaussLegendre1D::Integrate( std::vector( f )( double x0, double x1, double x2 ), unsigned /* len */ ) { +std::vector QGaussLegendre1D::Integrate( std::vector ( *f )( double, double, double ), unsigned /* len */ ) { ErrorMessages::Error( "This method is not applicable for 1D quadratures.\n", CURRENT_FUNCTION ); return { f( 0, 0, 0 ) }; } diff --git a/code/src/quadratures/qgausslegendretensorized2D.cpp b/code/src/quadratures/qgausslegendretensorized2D.cpp new file mode 100644 index 0000000000000000000000000000000000000000..35e2b3efe6224d87c0341e37c0b7dd357ec2ac8a --- /dev/null +++ b/code/src/quadratures/qgausslegendretensorized2D.cpp @@ -0,0 +1,87 @@ +#include "common/config.h" +#include "quadratures/qgausslegendretensorized.h" +#include "toolboxes/errormessages.h" + +QGaussLegendreTensorized2D::QGaussLegendreTensorized2D( Config* settings ) : QGaussLegendreTensorized( settings ) { + SetName(); + CheckOrder(); + SetNq(); + SetPointsAndWeights(); +} + +void QGaussLegendreTensorized2D::SetNq() { _nq = pow( GetOrder(), 2 ); } + +bool QGaussLegendreTensorized2D::CheckOrder() { + if( _order % 2 == 1 ) { // order needs to be even + ErrorMessages::Error( "ERROR! Order " + std::to_string( _order ) + " for " + GetName() + " not available. \n Order must be an even number. ", + CURRENT_FUNCTION ); + } + return true; +} + +void QGaussLegendreTensorized2D::SetPointsAndWeights() { + Vector nodes1D( _order ), weights1D( _order ); + + // construct companion matrix + Matrix CM( _order, _order, 0.0 ); + for( unsigned i = 0; i < _order - 1; ++i ) { + CM( i + 1, i ) = std::sqrt( 1 / ( 4 - 1 / std::pow( static_cast( i + 1 ), 2 ) ) ); + CM( i, i + 1 ) = std::sqrt( 1 / ( 4 - 1 / std::pow( static_cast( i + 1 ), 2 ) ) ); + } + + // compute eigenvalues and -vectors of the companion matrix + auto evSys = ComputeEigenValTriDiagMatrix( CM ); + + for( unsigned i = 0; i < _order; ++i ) { + if( std::fabs( evSys.first[i] ) < 1e-15 ) // avoid rounding errors + nodes1D[i] = 0; + else + nodes1D[i] = evSys.first[i]; + weights1D[i] = 2 * std::pow( evSys.second( 0, i ), 2 ); + } + + // sort nodes increasingly and also reorder weigths for consistency + std::vector sortOrder( nodes1D.size() ); + std::iota( sortOrder.begin(), sortOrder.end(), 0 ); + std::sort( sortOrder.begin(), sortOrder.end(), [&]( unsigned i, unsigned j ) { return nodes1D[i] < nodes1D[j]; } ); + Vector sorted_nodes( static_cast( sortOrder.size() ) ), sorted_weights( static_cast( sortOrder.size() ) ); + std::transform( sortOrder.begin(), sortOrder.end(), sorted_nodes.begin(), [&]( unsigned i ) { return nodes1D[i]; } ); + std::transform( sortOrder.begin(), sortOrder.end(), sorted_weights.begin(), [&]( unsigned i ) { return weights1D[i]; } ); + nodes1D = sorted_nodes; + weights1D = sorted_weights; + + // setup equidistant angle phi around z axis + Vector phi( 2 * _order ); + for( unsigned i = 0; i < 2 * _order; ++i ) { + phi[i] = ( i + 0.5 ) * M_PI / _order; + } + + unsigned range = std::floor( _order / 2.0 ); // comment (steffen): Only half of the points, due to projection + double normalizationFactor = .5; + + // resize points and weights + _points.resize( _nq ); + _pointsSphere.resize( _nq ); + for( auto& p : _points ) { + p.resize( 3 ); + } + for( auto& p : _pointsSphere ) { + p.resize( 2 ); + } + + _weights.resize( _nq ); + + // transform tensorized (x,y,z)-grid to spherical grid points + for( unsigned j = 0; j < range; ++j ) { + for( unsigned i = 0; i < 2 * _order; ++i ) { + _points[j * ( 2 * _order ) + i][0] = sqrt( 1 - nodes1D[j] * nodes1D[j] ) * std::cos( phi[i] ); + _points[j * ( 2 * _order ) + i][1] = sqrt( 1 - nodes1D[j] * nodes1D[j] ) * std::sin( phi[i] ); + _points[j * ( 2 * _order ) + i][2] = 0; + + _pointsSphere[j * ( 2 * _order ) + i][0] = nodes1D[j]; // my + _pointsSphere[j * ( 2 * _order ) + i][1] = phi[i]; // phi + + _weights[j * ( 2 * _order ) + i] = normalizationFactor * M_PI / _order * weights1D[j]; + } + } +} diff --git a/code/src/quadratures/quadraturebase.cpp b/code/src/quadratures/quadraturebase.cpp index 9e01bac0ab66d5afef797b5f2d1ab0a664a743ea..21ceac9907517111693a60b56bb47c4ae4dbdbc2 100644 --- a/code/src/quadratures/quadraturebase.cpp +++ b/code/src/quadratures/quadraturebase.cpp @@ -24,6 +24,8 @@ QuadratureBase* QuadratureBase::Create( Config* settings ) { case QUAD_MonteCarlo: return new QMonteCarlo( settings ); case QUAD_GaussLegendreTensorized: return new QGaussLegendreTensorized( settings ); case QUAD_GaussLegendre1D: return new QGaussLegendre1D( settings ); + case QUAD_GaussLegendreTensorized2D: return new QGaussLegendreTensorized2D( settings ); + case QUAD_GaussChebyshev1D: return new QGaussChebyshev1D( settings ); case QUAD_LevelSymmetric: return new QLevelSymmetric( settings ); case QUAD_LDFESA: return new QLDFESA( settings ); @@ -52,7 +54,7 @@ QuadratureBase* QuadratureBase::Create( QUAD_NAME name, unsigned quadOrder ) { return nullptr; } -double QuadratureBase::Integrate( double( f )( double x0, double x1, double x2 ) ) { +double QuadratureBase::Integrate( double ( *f )( double, double, double ) ) { double result = 0.0; for( unsigned i = 0; i < _nq; i++ ) { result += _weights[i] * f( _points[i][0], _points[i][1], _points[i][2] ); @@ -60,7 +62,7 @@ double QuadratureBase::Integrate( double( f )( double x0, double x1, double x2 ) return result; } -double QuadratureBase::IntegrateSpherical( double( f )( double my, double phi ) ) { +double QuadratureBase::IntegrateSpherical( double ( *f )( double, double ) ) { double result = 0.0; for( unsigned i = 0; i < _nq; i++ ) { result += _weights[i] * f( _pointsSphere[i][0], _pointsSphere[i][1] ); @@ -68,7 +70,7 @@ double QuadratureBase::IntegrateSpherical( double( f )( double my, double phi ) return result; } -std::vector QuadratureBase::Integrate( std::vector( f )( double x0, double x1, double x2 ), unsigned len ) { +std::vector QuadratureBase::Integrate( std::vector ( *f )( double, double, double ), unsigned len ) { std::vector result( len, 0.0 ); std::vector funcEval( len, 0.0 ); diff --git a/code/src/solvers/csdsolvertrafofp.cpp b/code/src/solvers/csdsolvertrafofp.cpp index d15ac76448a0fe76332400de1dad9e989c411970..7027f51889c862912e85dbc4e878ced504374f72 100644 --- a/code/src/solvers/csdsolvertrafofp.cpp +++ b/code/src/solvers/csdsolvertrafofp.cpp @@ -17,7 +17,7 @@ CSDSolverTrafoFP::CSDSolverTrafoFP( Config* settings ) : SNSolver( settings ) { // Set angle and energies _energies = Vector( _nEnergies, 0.0 ); // equidistant _energyMin = 1e-4 * 0.511; - _energyMax = 10e0; + _energyMax = _settings->GetMaxEnergyCSD(); // write equidistant energy grid (false) or refined grid (true) GenerateEnergyGrid( false ); @@ -183,10 +183,24 @@ void CSDSolverTrafoFP::FVMUpdate( unsigned /*idx_energy*/ ) { } } -void CSDSolverTrafoFP::IterPostprocessing() { +void CSDSolverTrafoFP::IterPostprocessing( unsigned idx_pseudotime ) { // --- Update Solution --- _sol = _solNew; + unsigned n = idx_pseudotime; + for( unsigned j = 0; j < _nCells; ++j ) { + _fluxNew[j] = dot( _sol[j], _weights ); + if( n > 0 ) { + _dose[j] += 0.5 * _dE * ( _fluxNew[j] * _s[_nEnergies - n - 1] + _flux[j] * _s[_nEnergies - n] ) / + _density[j]; // update dose with trapezoidal rule + } + else { + _dose[j] += _dE * _fluxNew[j] * _s[_nEnergies - n - 1] / _density[j]; + } + _solverOutput[j] = _fluxNew[j]; + _flux[j] = _fluxNew[j]; + } + // --- Compute Flux for solution and Screen Output --- ComputeRadFlux(); } @@ -340,16 +354,7 @@ void CSDSolverTrafoFP::WriteVolumeOutput( unsigned idx_pseudoTime ) { case MEDICAL: // Compute Dose for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { - if( idx_cell > 0 ) { - _outputFields[idx_group][0][idx_cell] += - 0.5 * _dE * - ( _fluxNew[idx_cell] * _s[_nEnergies - idx_pseudoTime - 1] + _flux[idx_cell] * _s[_nEnergies - idx_pseudoTime] ) / - _density[idx_cell]; // update dose with trapezoidal rule - } - else { - _outputFields[idx_group][0][idx_cell] += - _dE * _fluxNew[idx_cell] * _s[_nEnergies - idx_pseudoTime - 1] / _density[idx_cell]; - } + _outputFields[idx_group][0][idx_cell] = _dose[idx_cell]; } // Compute normalized dose _outputFields[idx_group][1] = _outputFields[idx_group][0]; diff --git a/code/src/solvers/csdsolvertrafofp2d.cpp b/code/src/solvers/csdsolvertrafofp2d.cpp index 1e80a25897a9c809c2908884ed9eef8f45d2ac1e..efd642f3f006908cd1513c2e46148dd908926ea0 100644 --- a/code/src/solvers/csdsolvertrafofp2d.cpp +++ b/code/src/solvers/csdsolvertrafofp2d.cpp @@ -247,16 +247,7 @@ void CSDSolverTrafoFP2D::WriteVolumeOutput( unsigned idx_pseudoTime ) { case MEDICAL: // Compute Dose for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { - if( idx_cell > 0 ) { - _outputFields[idx_group][0][idx_cell] += - 0.5 * _dE * - ( _fluxNew[idx_cell] * _s[_nEnergies - idx_pseudoTime - 1] + _flux[idx_cell] * _s[_nEnergies - idx_pseudoTime] ) / - _density[idx_cell]; // update dose with trapezoidal rule - } - else { - _outputFields[idx_group][0][idx_cell] += - _dE * _fluxNew[idx_cell] * _s[_nEnergies - idx_pseudoTime - 1] / _density[idx_cell]; - } + _outputFields[idx_group][0][idx_cell] += _dose[idx_cell]; } // Compute normalized dose _outputFields[idx_group][1] = _outputFields[idx_group][0]; @@ -358,13 +349,27 @@ void CSDSolverTrafoFP2D::IterPreprocessing( unsigned idx_pseudotime ) { } } -void CSDSolverTrafoFP2D::IterPostprocessing() { +void CSDSolverTrafoFP2D::IterPostprocessing( unsigned idx_pseudotime ) { + unsigned n = idx_pseudotime; // --- Update Solution --- for( unsigned j = 0; j < _nCells; ++j ) { if( _boundaryCells[j] == BOUNDARY_TYPE::DIRICHLET ) continue; _sol[j] = _solNew[j]; } + for( unsigned j = 0; j < _nCells; ++j ) { + _fluxNew[j] = dot( _sol[j], _weights ); + if( n > 0 ) { + _dose[j] += 0.5 * _dE * ( _fluxNew[j] * _s[_nEnergies - n - 1] + _flux[j] * _s[_nEnergies - n] ) / + _density[j]; // update dose with trapezoidal rule + } + else { + _dose[j] += _dE * _fluxNew[j] * _s[_nEnergies - n - 1] / _density[j]; + } + _solverOutput[j] = _fluxNew[j]; + _flux[j] = _fluxNew[j]; + } + // --- Compute Flux for solution and Screen Output --- ComputeRadFlux(); } diff --git a/code/src/solvers/csdsolvertrafofpsh2d.cpp b/code/src/solvers/csdsolvertrafofpsh2d.cpp index c46c84a988205b9bf9b13fb1d751e3f262e66db2..4a811d6eccbb1ab2db9e2576fbcf0108a0fd735d 100644 --- a/code/src/solvers/csdsolvertrafofpsh2d.cpp +++ b/code/src/solvers/csdsolvertrafofpsh2d.cpp @@ -95,7 +95,7 @@ CSDSolverTrafoFPSH2D::CSDSolverTrafoFPSH2D( Config* settings ) : SNSolver( setti blaze::column( Y, q ) = sph.ComputeSphericalBasis( _quadPointsSphere[q][0], _quadPointsSphere[q][1] ); } - _O = Y; + //_O = Y; _O = blaze::trans( Y ); _M = _O; // transposed to simplify weight multiplication. We will transpose _M later again @@ -357,16 +357,7 @@ void CSDSolverTrafoFPSH2D::WriteVolumeOutput( unsigned idx_pseudoTime ) { case MEDICAL: // Compute Dose for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { - if( idx_cell > 0 ) { - _outputFields[idx_group][0][idx_cell] += - 0.5 * _dE * - ( _fluxNew[idx_cell] * _s[_nEnergies - idx_pseudoTime - 1] + _flux[idx_cell] * _s[_nEnergies - idx_pseudoTime] ) / - _density[idx_cell]; // update dose with trapezoidal rule - } - else { - _outputFields[idx_group][0][idx_cell] += - _dE * _fluxNew[idx_cell] * _s[_nEnergies - idx_pseudoTime - 1] / _density[idx_cell]; - } + _outputFields[idx_group][0][idx_cell] += _dose[idx_cell]; } // Compute normalized dose _outputFields[idx_group][1] = _outputFields[idx_group][0]; @@ -468,7 +459,8 @@ void CSDSolverTrafoFPSH2D::IterPreprocessing( unsigned idx_pseudotime ) { } } -void CSDSolverTrafoFPSH2D::IterPostprocessing() { +void CSDSolverTrafoFPSH2D::IterPostprocessing( unsigned idx_pseudotime ) { + unsigned n = idx_pseudotime; for( unsigned j = 0; j < _nCells; ++j ) { if( _boundaryCells[j] == BOUNDARY_TYPE::DIRICHLET ) continue; _sol[j] = _solNew[j]; @@ -476,6 +468,19 @@ void CSDSolverTrafoFPSH2D::IterPostprocessing() { // --- Compute Flux for solution and Screen Output --- ComputeRadFlux(); + + for( unsigned j = 0; j < _nCells; ++j ) { + _fluxNew[j] = dot( _sol[j], _weights ); + if( n > 0 ) { + _dose[j] += 0.5 * _dE * ( _fluxNew[j] * _s[_nEnergies - n - 1] + _flux[j] * _s[_nEnergies - n] ) / + _density[j]; // update dose with trapezoidal rule + } + else { + _dose[j] += _dE * _fluxNew[j] * _s[_nEnergies - n - 1] / _density[j]; + } + _solverOutput[j] = _fluxNew[j]; + _flux[j] = _fluxNew[j]; + } } void CSDSolverTrafoFPSH2D::SolverPreprocessing() { diff --git a/code/src/solvers/mnsolver.cpp b/code/src/solvers/mnsolver.cpp index 688c9268167156be2b946f9d1be16b854927acca..5a1e855a3926100c1d48d095f9b1033a4400137b 100644 --- a/code/src/solvers/mnsolver.cpp +++ b/code/src/solvers/mnsolver.cpp @@ -17,11 +17,11 @@ #include -MNSolver::MNSolver( Config* settings ) : Solver( settings ) { +MNSolver::MNSolver( Config* settings ) : SolverBase( settings ) { - _LMaxDegree = settings->GetMaxMomentDegree(); - _basis = SphericalBase::Create( _settings ); - _nTotalEntries = _basis->GetBasisSize(); + _polyDegreeBasis = settings->GetMaxMomentDegree(); + _basis = SphericalBase::Create( _settings ); + _nSystem = _basis->GetBasisSize(); // build quadrature object and store quadrature points and weights _quadPoints = _quadrature->GetPoints(); @@ -31,11 +31,11 @@ MNSolver::MNSolver( Config* settings ) : Solver( settings ) { //_settings->SetNQuadPoints( _nq ); // Initialize temporary storages of alpha derivatives - _solDx = VectorVector( _nCells, Vector( _nTotalEntries, 0.0 ) ); - _solDy = VectorVector( _nCells, Vector( _nTotalEntries, 0.0 ) ); + _solDx = VectorVector( _nCells, Vector( _nSystem, 0.0 ) ); + _solDy = VectorVector( _nCells, Vector( _nSystem, 0.0 ) ); // Initialize Scatter Matrix -- - _scatterMatDiag = Vector( _nTotalEntries, 0.0 ); + _scatterMatDiag = Vector( _nSystem, 0.0 ); ComputeScatterMatrix(); // Initialize Entropy @@ -45,10 +45,10 @@ MNSolver::MNSolver( Config* settings ) : Solver( settings ) { _optimizer = OptimizerBase::Create( _settings ); // Initialize lagrange Multiplier - _alpha = VectorVector( _nCells, Vector( _nTotalEntries, 0.0 ) ); + _alpha = VectorVector( _nCells, Vector( _nSystem, 0.0 ) ); // Initialize and Pre-Compute Moments at quadrature points - _moments = VectorVector( _nq, Vector( _nTotalEntries, 0.0 ) ); + _moments = VectorVector( _nq, Vector( _nSystem, 0.0 ) ); ComputeMoments(); } @@ -63,7 +63,7 @@ void MNSolver::ComputeScatterMatrix() { // --- Isotropic --- _scatterMatDiag[0] = -1.0; - for( unsigned idx_diag = 1; idx_diag < _nTotalEntries; idx_diag++ ) { + for( unsigned idx_diag = 1; idx_diag < _nSystem; idx_diag++ ) { _scatterMatDiag[idx_diag] = 0.0; } } @@ -84,11 +84,11 @@ Vector MNSolver::ConstructFlux( unsigned idx_cell ) { //--- Integration of moments of flux --- double entropyL, entropyR, entropyFlux; - Vector flux( _nTotalEntries, 0.0 ); + Vector flux( _nSystem, 0.0 ); //--- Temporary storages of reconstructed alpha --- - Vector alphaL( _nTotalEntries, 0.0 ); - Vector alphaR( _nTotalEntries, 0.0 ); + Vector alphaL( _nSystem, 0.0 ); + Vector alphaR( _nSystem, 0.0 ); for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { entropyFlux = 0.0; // reset temorary flux @@ -152,7 +152,7 @@ void MNSolver::IterPreprocessing( unsigned /*idx_pseudotime*/ ) { } } -void MNSolver::IterPostprocessing() { +void MNSolver::IterPostprocessing( unsigned /*idx_iter*/ ) { // --- Update Solution --- _sol = _solNew; @@ -170,7 +170,7 @@ void MNSolver::ComputeRadFlux() { void MNSolver::FluxUpdate() { if( _reconsOrder > 1 ) { - _mesh->ReconstructSlopesU( _nTotalEntries, _solDx, _solDy, _alpha ); // unstructured reconstruction + _mesh->ReconstructSlopesU( _nSystem, _solDx, _solDy, _alpha ); // unstructured reconstruction } // Loop over the grid cells @@ -182,19 +182,19 @@ void MNSolver::FluxUpdate() { } } -void MNSolver::FVMUpdate( unsigned idx_energy ) { +void MNSolver::FVMUpdate( unsigned idx_iter ) { // Loop over the grid cells //#pragma omp parallel for for( unsigned idx_cell = 0; idx_cell < _nCells; idx_cell++ ) { // Dirichlet Boundaries stay if( _boundaryCells[idx_cell] == BOUNDARY_TYPE::DIRICHLET ) continue; // Flux update - for( unsigned idx_system = 0; idx_system < _nTotalEntries; idx_system++ ) { + for( unsigned idx_system = 0; idx_system < _nSystem; idx_system++ ) { _solNew[idx_cell][idx_system] = _sol[idx_cell][idx_system] - ( _dE / _areas[idx_cell] ) * _solNew[idx_cell][idx_system] /* cell averaged flux */ - _dE * _sol[idx_cell][idx_system] * - ( _sigmaT[idx_energy][idx_cell] /* absorbtion influence */ - + _sigmaS[idx_energy][idx_cell] * _scatterMatDiag[idx_system] ); /* scattering influence */ + ( _sigmaT[idx_iter][idx_cell] /* absorbtion influence */ + + _sigmaS[idx_iter][idx_cell] * _scatterMatDiag[idx_system] ); /* scattering influence */ } // Source Term _solNew[idx_cell][0] += _dE * _Q[0][idx_cell][0]; @@ -224,11 +224,11 @@ void MNSolver::PrepareVolumeOutput() { case MOMENTS: // As many entries as there are moments in the system - _outputFields[idx_group].resize( _nTotalEntries ); - _outputFieldNames[idx_group].resize( _nTotalEntries ); + _outputFields[idx_group].resize( _nSystem ); + _outputFieldNames[idx_group].resize( _nSystem ); if( _settings->GetSphericalBasisName() == SPHERICAL_HARMONICS ) { - for( int idx_l = 0; idx_l <= (int)_LMaxDegree; idx_l++ ) { + for( int idx_l = 0; idx_l <= (int)_polyDegreeBasis; idx_l++ ) { for( int idx_k = -idx_l; idx_k <= idx_l; idx_k++ ) { _outputFields[idx_group][_basis->GetGlobalIndexBasis( idx_l, idx_k )].resize( _nCells ); _outputFieldNames[idx_group][_basis->GetGlobalIndexBasis( idx_l, idx_k )] = @@ -237,7 +237,7 @@ void MNSolver::PrepareVolumeOutput() { } } else { - for( unsigned idx_l = 0; idx_l <= _LMaxDegree; idx_l++ ) { + for( unsigned idx_l = 0; idx_l <= _polyDegreeBasis; idx_l++ ) { unsigned maxOrder_k = _basis->GetCurrDegreeSize( idx_l ); for( unsigned idx_k = 0; idx_k < maxOrder_k; idx_k++ ) { _outputFields[idx_group][_basis->GetGlobalIndexBasis( idx_l, idx_k )].resize( _nCells ); @@ -250,11 +250,11 @@ void MNSolver::PrepareVolumeOutput() { case DUAL_MOMENTS: // As many entries as there are moments in the system - _outputFields[idx_group].resize( _nTotalEntries ); - _outputFieldNames[idx_group].resize( _nTotalEntries ); + _outputFields[idx_group].resize( _nSystem ); + _outputFieldNames[idx_group].resize( _nSystem ); if( _settings->GetSphericalBasisName() == SPHERICAL_HARMONICS ) { - for( int idx_l = 0; idx_l <= (int)_LMaxDegree; idx_l++ ) { + for( int idx_l = 0; idx_l <= (int)_polyDegreeBasis; idx_l++ ) { for( int idx_k = -idx_l; idx_k <= idx_l; idx_k++ ) { _outputFields[idx_group][_basis->GetGlobalIndexBasis( idx_l, idx_k )].resize( _nCells ); _outputFieldNames[idx_group][_basis->GetGlobalIndexBasis( idx_l, idx_k )] = @@ -263,7 +263,7 @@ void MNSolver::PrepareVolumeOutput() { } } else { - for( int idx_l = 0; idx_l <= (int)_LMaxDegree; idx_l++ ) { + for( int idx_l = 0; idx_l <= (int)_polyDegreeBasis; idx_l++ ) { unsigned maxOrder_k = _basis->GetCurrDegreeSize( idx_l ); for( unsigned idx_k = 0; idx_k < maxOrder_k; idx_k++ ) { _outputFields[idx_group][_basis->GetGlobalIndexBasis( idx_l, idx_k )].resize( _nCells ); @@ -287,12 +287,12 @@ void MNSolver::PrepareVolumeOutput() { } } -void MNSolver::WriteVolumeOutput( unsigned idx_pseudoTime ) { +void MNSolver::WriteVolumeOutput( unsigned idx_iter ) { unsigned nGroups = (unsigned)_settings->GetNVolumeOutput(); // Check if volume output fields are written to file this iteration - if( ( _settings->GetVolumeOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetVolumeOutputFrequency() == 0 ) || - ( idx_pseudoTime == _nEnergies - 1 ) /* need sol at last iteration */ ) { + if( ( _settings->GetVolumeOutputFrequency() != 0 && idx_iter % (unsigned)_settings->GetVolumeOutputFrequency() == 0 ) || + ( idx_iter == _nEnergies - 1 ) /* need sol at last iteration */ ) { for( unsigned idx_group = 0; idx_group < nGroups; idx_group++ ) { switch( _settings->GetVolumeOutput()[idx_group] ) { @@ -302,14 +302,14 @@ void MNSolver::WriteVolumeOutput( unsigned idx_pseudoTime ) { } break; case MOMENTS: - for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { + for( unsigned idx_sys = 0; idx_sys < _nSystem; idx_sys++ ) { for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { _outputFields[idx_group][idx_sys][idx_cell] = _sol[idx_cell][idx_sys]; } } break; case DUAL_MOMENTS: - for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { + for( unsigned idx_sys = 0; idx_sys < _nSystem; idx_sys++ ) { for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { _outputFields[idx_group][idx_sys][idx_cell] = _alpha[idx_cell][idx_sys]; } @@ -319,10 +319,10 @@ void MNSolver::WriteVolumeOutput( unsigned idx_pseudoTime ) { // Compute total "mass" of the system ==> to check conservation properties for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { - double time = idx_pseudoTime * _dE; + double time = idx_iter * _dE; _outputFields[idx_group][0][idx_cell] = _problem->GetAnalyticalSolution( - _mesh->GetCellMidPoints()[idx_cell][0], _mesh->GetCellMidPoints()[idx_cell][1], time, _sigmaS[idx_pseudoTime][idx_cell] ); + _mesh->GetCellMidPoints()[idx_cell][0], _mesh->GetCellMidPoints()[idx_cell][1], time, _sigmaS[idx_iter][idx_cell] ); } break; diff --git a/code/src/solvers/pnsolver.cpp b/code/src/solvers/pnsolver.cpp index 4c99e597e0c5abf63e512180f650697d1808b72c..29fe8e6212af7f2da8576efcf335c122d02bda93 100644 --- a/code/src/solvers/pnsolver.cpp +++ b/code/src/solvers/pnsolver.cpp @@ -10,31 +10,31 @@ #include "spdlog/spdlog.h" #include -PNSolver::PNSolver( Config* settings ) : Solver( settings ) { - _LMaxDegree = settings->GetMaxMomentDegree(); - _nTotalEntries = GlobalIndex( int( _LMaxDegree ), int( _LMaxDegree ) ) + 1; +PNSolver::PNSolver( Config* settings ) : SolverBase( settings ) { + _polyDegreeBasis = settings->GetMaxMomentDegree(); + _nSystem = GlobalIndex( int( _polyDegreeBasis ), int( _polyDegreeBasis ) ) + 1; // Initialize System Matrices - _Ax = SymMatrix( _nTotalEntries ); - _Ay = SymMatrix( _nTotalEntries ); - _Az = SymMatrix( _nTotalEntries ); - - _AxPlus = Matrix( _nTotalEntries, _nTotalEntries, 0 ); - _AxMinus = Matrix( _nTotalEntries, _nTotalEntries, 0 ); - _AxAbs = Matrix( _nTotalEntries, _nTotalEntries, 0 ); - _AyPlus = Matrix( _nTotalEntries, _nTotalEntries, 0 ); - _AyMinus = Matrix( _nTotalEntries, _nTotalEntries, 0 ); - _AyAbs = Matrix( _nTotalEntries, _nTotalEntries, 0 ); - _AzPlus = Matrix( _nTotalEntries, _nTotalEntries, 0 ); - _AzMinus = Matrix( _nTotalEntries, _nTotalEntries, 0 ); - _AzAbs = Matrix( _nTotalEntries, _nTotalEntries, 0 ); + _Ax = SymMatrix( _nSystem ); + _Ay = SymMatrix( _nSystem ); + _Az = SymMatrix( _nSystem ); + + _AxPlus = Matrix( _nSystem, _nSystem, 0 ); + _AxMinus = Matrix( _nSystem, _nSystem, 0 ); + _AxAbs = Matrix( _nSystem, _nSystem, 0 ); + _AyPlus = Matrix( _nSystem, _nSystem, 0 ); + _AyMinus = Matrix( _nSystem, _nSystem, 0 ); + _AyAbs = Matrix( _nSystem, _nSystem, 0 ); + _AzPlus = Matrix( _nSystem, _nSystem, 0 ); + _AzMinus = Matrix( _nSystem, _nSystem, 0 ); + _AzAbs = Matrix( _nSystem, _nSystem, 0 ); // Initialize Scatter Matrix - _scatterMatDiag = Vector( _nTotalEntries, 0 ); + _scatterMatDiag = Vector( _nSystem, 0 ); // Initialize temporary storages of solution derivatives - _solDx = VectorVector( _nCells, Vector( _nTotalEntries, 0.0 ) ); - _solDy = VectorVector( _nCells, Vector( _nTotalEntries, 0.0 ) ); + _solDx = VectorVector( _nCells, Vector( _nSystem, 0.0 ) ); + _solDy = VectorVector( _nCells, Vector( _nSystem, 0.0 ) ); // Fill System Matrices ComputeSystemMatrices(); @@ -53,11 +53,11 @@ PNSolver::PNSolver( Config* settings ) : Solver( settings ) { // TODO } -void PNSolver::IterPreprocessing( unsigned /*idx_pseudotime*/ ) { +void PNSolver::IterPreprocessing( unsigned /*idx_iter*/ ) { // Nothing to preprocess for PNSolver } -void PNSolver::IterPostprocessing() { +void PNSolver::IterPostprocessing( unsigned /*idx_iter*/ ) { // --- Update Solution --- _sol = _solNew; @@ -74,7 +74,7 @@ void PNSolver::ComputeRadFlux() { void PNSolver::FluxUpdate() { if( _reconsOrder > 1 ) { - _mesh->ReconstructSlopesU( _nTotalEntries, _solDx, _solDy, _sol ); // unstructured reconstruction + _mesh->ReconstructSlopesU( _nSystem, _solDx, _solDy, _sol ); // unstructured reconstruction //_mesh->ComputeSlopes( _nTotalEntries, _solDx, _solDy, _sol ); // unstructured reconstruction } // Vector solL( _nTotalEntries ); @@ -89,7 +89,7 @@ void PNSolver::FluxUpdate() { if( _boundaryCells[idx_cell] == BOUNDARY_TYPE::DIRICHLET ) continue; // Reset temporary variable psiNew - for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { + for( unsigned idx_sys = 0; idx_sys < _nSystem; idx_sys++ ) { _solNew[idx_cell][idx_sys] = 0.0; } @@ -159,7 +159,7 @@ void PNSolver::FVMUpdate( unsigned idx_energy ) { // Dirichlet cells stay at IC, farfield assumption if( _boundaryCells[idx_cell] == BOUNDARY_TYPE::DIRICHLET ) continue; // Flux update - for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { + for( unsigned idx_sys = 0; idx_sys < _nSystem; idx_sys++ ) { _solNew[idx_cell][idx_sys] = _sol[idx_cell][idx_sys] - ( _dE / _areas[idx_cell] ) * _solNew[idx_cell][idx_sys] /* cell averaged flux */ - _dE * _sol[idx_cell][idx_sys] * ( _sigmaT[idx_energy][idx_cell] /* absorbtion influence */ @@ -175,7 +175,7 @@ void PNSolver::ComputeSystemMatrices() { unsigned idx_row = 0; // loop over columns of A - for( int idx_lOrder = 0; idx_lOrder <= int( _LMaxDegree ); idx_lOrder++ ) { // index of legendre polynom + for( int idx_lOrder = 0; idx_lOrder <= int( _polyDegreeBasis ); idx_lOrder++ ) { // index of legendre polynom for( int idx_kOrder = -idx_lOrder; idx_kOrder <= idx_lOrder; idx_kOrder++ ) { // second index of legendre function idx_row = unsigned( GlobalIndex( idx_lOrder, idx_kOrder ) ); @@ -247,17 +247,17 @@ void PNSolver::ComputeSystemMatrices() { } void PNSolver::ComputeFluxComponents() { - Vector eigenValues( _nTotalEntries, 0 ); - Vector eigenValuesX( _nTotalEntries, 0 ); - Vector eigenValuesY( _nTotalEntries, 0 ); + Vector eigenValues( _nSystem, 0 ); + Vector eigenValuesX( _nSystem, 0 ); + Vector eigenValuesY( _nSystem, 0 ); - MatrixCol eigenVectors( _nTotalEntries, _nTotalEntries, 0 ); // ColumnMatrix for _AxPlus * eigenVectors Multiplication via SIMD + MatrixCol eigenVectors( _nSystem, _nSystem, 0 ); // ColumnMatrix for _AxPlus * eigenVectors Multiplication via SIMD // --- For x Direction --- { blaze::eigen( _Ax, eigenValues, eigenVectors ); // Compute Eigenvalues and Eigenvectors // Compute Flux Matrices A+ and A- - for( unsigned idx_ij = 0; idx_ij < _nTotalEntries; idx_ij++ ) { + for( unsigned idx_ij = 0; idx_ij < _nSystem; idx_ij++ ) { if( eigenValues[idx_ij] >= 0 ) { _AxPlus( idx_ij, idx_ij ) = eigenValues[idx_ij]; // positive part of Diagonal Matrix stored in _AxPlus _AxAbs( idx_ij, idx_ij ) = eigenValues[idx_ij]; @@ -283,7 +283,7 @@ void PNSolver::ComputeFluxComponents() { blaze::eigen( _Ay, eigenValues, eigenVectors ); // Compute Eigenvalues and Eigenvectors // Compute Flux Matrices A+ and A- - for( unsigned idx_ij = 0; idx_ij < _nTotalEntries; idx_ij++ ) { + for( unsigned idx_ij = 0; idx_ij < _nSystem; idx_ij++ ) { if( eigenValues[idx_ij] >= 0 ) { _AyPlus( idx_ij, idx_ij ) = eigenValues[idx_ij]; // positive part of Diagonal Matrix stored in _AxPlus _AyAbs( idx_ij, idx_ij ) = eigenValues[idx_ij]; @@ -309,7 +309,7 @@ void PNSolver::ComputeFluxComponents() { blaze::eigen( _Az, eigenValues, eigenVectors ); // Compute Eigenvalues and Eigenvectors // Compute Flux Matrices A+ and A- - for( unsigned idx_ij = 0; idx_ij < _nTotalEntries; idx_ij++ ) { + for( unsigned idx_ij = 0; idx_ij < _nSystem; idx_ij++ ) { if( eigenValues[idx_ij] >= 0 ) { _AzPlus( idx_ij, idx_ij ) = eigenValues[idx_ij]; // positive part of Diagonal Matrix stored in _AxPlus _AzAbs( idx_ij, idx_ij ) = eigenValues[idx_ij]; @@ -346,7 +346,7 @@ void PNSolver::ComputeScatterMatrix() { // --- Isotropic --- _scatterMatDiag[0] = -1.0; - for( unsigned idx_diag = 1; idx_diag < _nTotalEntries; idx_diag++ ) { + for( unsigned idx_diag = 1; idx_diag < _nSystem; idx_diag++ ) { _scatterMatDiag[idx_diag] = 0.0; } } @@ -393,10 +393,10 @@ void PNSolver::PrepareVolumeOutput() { case MOMENTS: // As many entries as there are moments in the system - _outputFields[idx_group].resize( _nTotalEntries ); - _outputFieldNames[idx_group].resize( _nTotalEntries ); + _outputFields[idx_group].resize( _nSystem ); + _outputFieldNames[idx_group].resize( _nSystem ); - for( int idx_l = 0; idx_l <= (int)_LMaxDegree; idx_l++ ) { + for( int idx_l = 0; idx_l <= (int)_polyDegreeBasis; idx_l++ ) { for( int idx_k = -idx_l; idx_k <= idx_l; idx_k++ ) { _outputFields[idx_group][GlobalIndex( idx_l, idx_k )].resize( _nCells ); @@ -423,7 +423,7 @@ void PNSolver::WriteVolumeOutput( unsigned idx_pseudoTime ) { } break; case MOMENTS: - for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { + for( unsigned idx_sys = 0; idx_sys < _nSystem; idx_sys++ ) { for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { _outputFields[idx_group][idx_sys][idx_cell] = _sol[idx_cell][idx_sys]; } @@ -436,8 +436,8 @@ void PNSolver::WriteVolumeOutput( unsigned idx_pseudoTime ) { } void PNSolver::CleanFluxMatrices() { - for( unsigned idx_row = 0; idx_row < _nTotalEntries; idx_row++ ) { - for( unsigned idx_col = 0; idx_col < _nTotalEntries; idx_col++ ) { + for( unsigned idx_row = 0; idx_row < _nSystem; idx_row++ ) { + for( unsigned idx_col = 0; idx_col < _nSystem; idx_col++ ) { if( std::abs( _AxAbs( idx_row, idx_col ) ) < 0.00000000001 ) _AxAbs( idx_row, idx_col ) = 0.0; if( std::abs( _AxPlus( idx_row, idx_col ) ) < 0.00000000001 ) _AxPlus( idx_row, idx_col ) = 0.0; if( std::abs( _AxMinus( idx_row, idx_col ) ) < 0.00000000001 ) _AxMinus( idx_row, idx_col ) = 0.0; @@ -514,7 +514,7 @@ int PNSolver::GlobalIndex( int l, int k ) const { } bool PNSolver::CheckIndex( int l, int k ) const { - if( l >= 0 && l <= int( _LMaxDegree ) ) { + if( l >= 0 && l <= int( _polyDegreeBasis ) ) { if( k >= -l && k <= l ) return true; } return false; diff --git a/code/src/solvers/snsolver.cpp b/code/src/solvers/snsolver.cpp index a3de1bf1b52a7a43717d6ffbe6f9361832ad76a4..a7cdf5ea44f1722c5126183db26f234d785080a3 100644 --- a/code/src/solvers/snsolver.cpp +++ b/code/src/solvers/snsolver.cpp @@ -13,7 +13,7 @@ #include #include -SNSolver::SNSolver( Config* settings ) : Solver( settings ) { +SNSolver::SNSolver( Config* settings ) : SolverBase( settings ) { _quadPoints = _quadrature->GetPoints(); _weights = _quadrature->GetWeights(); @@ -23,11 +23,11 @@ SNSolver::SNSolver( Config* settings ) : Solver( settings ) { delete k; } -void SNSolver::IterPreprocessing( unsigned /*idx_pseudotime*/ ) { +void SNSolver::IterPreprocessing( unsigned /*idx_iter*/ ) { // Nothing to do for SNSolver } -void SNSolver::IterPostprocessing() { +void SNSolver::IterPostprocessing( unsigned /*idx_iter*/ ) { // --- Update Solution --- _sol = _solNew; diff --git a/code/src/solvers/solverbase.cpp b/code/src/solvers/solverbase.cpp index e11e6520ad0a376f57385b8be22b76e234e37c49..4eea1aacbea4819606fa8f9aaa0fd60a0832ddac 100644 --- a/code/src/solvers/solverbase.cpp +++ b/code/src/solvers/solverbase.cpp @@ -18,7 +18,7 @@ #include -Solver::Solver( Config* settings ) { +SolverBase::SolverBase( Config* settings ) { _settings = settings; // @TODO save parameters from settings class @@ -94,13 +94,13 @@ Solver::Solver( Config* settings ) { //_density = std::vector( _mesh->GetCellMidPoints().size(), 0.0 ); } -Solver::~Solver() { +SolverBase::~SolverBase() { delete _quadrature; delete _mesh; delete _problem; } -Solver* Solver::Create( Config* settings ) { +SolverBase* SolverBase::Create( Config* settings ) { switch( settings->GetSolverName() ) { case SN_SOLVER: return new SNSolver( settings ); @@ -116,7 +116,7 @@ Solver* Solver::Create( Config* settings ) { return nullptr; // This code is never reached. Just to disable compiler warnings. } -void Solver::Solve() { +void SolverBase::Solve() { // --- Preprocessing --- @@ -146,7 +146,7 @@ void Solver::Solve() { FVMUpdate( iter ); // --- Iter Postprocessing --- - IterPostprocessing(); + IterPostprocessing( iter ); // --- Solver Output --- WriteVolumeOutput( iter ); @@ -161,9 +161,9 @@ void Solver::Solve() { DrawPostSolverOutput(); } -void Solver::PrintVolumeOutput() const { ExportVTK( _settings->GetOutputFile(), _outputFields, _outputFieldNames, _mesh ); } +void SolverBase::PrintVolumeOutput() const { ExportVTK( _settings->GetOutputFile(), _outputFields, _outputFieldNames, _mesh ); } -void Solver::PrintVolumeOutput( int currEnergy ) const { +void SolverBase::PrintVolumeOutput( int currEnergy ) const { if( _settings->GetVolumeOutputFrequency() != 0 && currEnergy % (unsigned)_settings->GetVolumeOutputFrequency() == 0 ) { ExportVTK( _settings->GetOutputFile() + "_" + std::to_string( currEnergy ), _outputFields, _outputFieldNames, _mesh ); } @@ -173,7 +173,7 @@ void Solver::PrintVolumeOutput( int currEnergy ) const { } // --- Helper --- -double Solver::ComputeTimeStep( double cfl ) const { +double SolverBase::ComputeTimeStep( double cfl ) const { double maxEdge = -1.0; for( unsigned j = 0; j < _nCells; j++ ) { for( unsigned l = 0; l < _normals[j].size(); l++ ) { @@ -185,7 +185,7 @@ double Solver::ComputeTimeStep( double cfl ) const { } // --- IO ---- -void Solver::PrepareScreenOutput() { +void SolverBase::PrepareScreenOutput() { unsigned nFields = (unsigned)_settings->GetNScreenOutput(); _screenOutputFieldNames.resize( nFields ); @@ -212,7 +212,7 @@ void Solver::PrepareScreenOutput() { } } -void Solver::WriteScalarOutput( unsigned iteration ) { +void SolverBase::WriteScalarOutput( unsigned iteration ) { unsigned nFields = (unsigned)_settings->GetNScreenOutput(); double mass = 0.0; @@ -251,7 +251,6 @@ void Solver::WriteScalarOutput( unsigned iteration ) { _screenOutputFields[idx_field] = 1; } break; - default: ErrorMessages::Error( "Screen output group not defined!", CURRENT_FUNCTION ); break; } } @@ -314,7 +313,7 @@ void Solver::WriteScalarOutput( unsigned iteration ) { } } -void Solver::PrintScreenOutput( unsigned iteration ) { +void SolverBase::PrintScreenOutput( unsigned iteration ) { int rank; MPI_Comm_rank( MPI_COMM_WORLD, &rank ); auto log = spdlog::get( "event" ); @@ -366,7 +365,7 @@ void Solver::PrintScreenOutput( unsigned iteration ) { } } -void Solver::PrepareHistoryOutput() { +void SolverBase::PrepareHistoryOutput() { unsigned nFields = (unsigned)_settings->GetNHistoryOutput(); _historyOutputFieldNames.resize( nFields ); @@ -393,7 +392,7 @@ void Solver::PrepareHistoryOutput() { } } -void Solver::PrintHistoryOutput( unsigned iteration ) { +void SolverBase::PrintHistoryOutput( unsigned iteration ) { int rank; MPI_Comm_rank( MPI_COMM_WORLD, &rank ); auto log = spdlog::get( "tabular" ); @@ -418,7 +417,7 @@ void Solver::PrintHistoryOutput( unsigned iteration ) { } } -void Solver::DrawPreSolverOutput() { +void SolverBase::DrawPreSolverOutput() { // MPI int rank; MPI_Comm_rank( MPI_COMM_WORLD, &rank ); @@ -463,7 +462,7 @@ void Solver::DrawPreSolverOutput() { } } -void Solver::DrawPostSolverOutput() { +void SolverBase::DrawPostSolverOutput() { // MPI int rank; MPI_Comm_rank( MPI_COMM_WORLD, &rank ); @@ -497,4 +496,4 @@ void Solver::DrawPostSolverOutput() { } } -void Solver::SolverPreprocessing() {} +void SolverBase::SolverPreprocessing() {} diff --git a/code/src/toolboxes/datagenerator1D.cpp b/code/src/toolboxes/datagenerator1D.cpp new file mode 100644 index 0000000000000000000000000000000000000000..af428df1ced03deb30fafe8456a0614798fd27ad --- /dev/null +++ b/code/src/toolboxes/datagenerator1D.cpp @@ -0,0 +1,334 @@ +/*! + * \file datagenerator1D.cpp + * \brief Class to generate data for the neural entropy closure + * \author S. Schotthoefer + */ + +#include "toolboxes/datagenerator1D.h" +#include "common/config.h" +#include "quadratures/quadraturebase.h" +#include "toolboxes/errormessages.h" +#include "toolboxes/sphericalbase.h" + +#include +#include + +DataGenerator1D::DataGenerator1D( Config* settings ) : DataGeneratorBase( settings ) { + ComputeMoments(); + + // AdaptBasisSize(); + + // Initialize Training Data + ComputeSetSize(); + + _uSol = VectorVector( _setSize, Vector( _nTotalEntries, 0.0 ) ); + _alpha = VectorVector( _setSize, Vector( _nTotalEntries, 0.0 ) ); + _hEntropy = std::vector( _setSize, 0.0 ); +} + +DataGenerator1D::~DataGenerator1D() {} + +void DataGenerator1D::ComputeMoments() { + double my, phi; + phi = 0; // placeholder. will not be used + + for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { + my = _quadPointsSphere[idx_quad][0]; + _moments[idx_quad] = _basis->ComputeSphericalBasis( my, phi ); + } +} + +void DataGenerator1D::SampleSolutionU() { + // Use necessary conditions from Monreal, Dissertation, Chapter 3.2.1, Page 26 + + // --- Determine stepsizes etc --- + + if( _maxPolyDegree == 0 ) { + // --- sample u in order 0 --- + // u_0 = <1*psi> + double du = _settings->GetMaxValFirstMoment() / (double)_gridSize; + + for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { + _uSol[idx_set][0] = du * idx_set; + } + } + else if( _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS && !_settings->GetNormalizedSampling() ) { + if( _maxPolyDegree == 1 ) { + unsigned c = 0; + double du = _settings->GetMaxValFirstMoment() / (double)_gridSize; + + double u0 = _settings->GetRealizableSetEpsilonU0(); + double u1; + double N1; // helper + // for( double u0 = _settings->GetRealizableSetEpsilonU0(); u0 < _settings->GetMaxValFirstMoment(); u0 += du ) { + while( u0 < _settings->GetMaxValFirstMoment() ) { + u1 = -u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N1 = u1 / u0; + while( N1 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + _uSol[c][0] = u0; // u0 by Monreals notation + _uSol[c][1] = u1; // u1 by Monreals notation + u1 += du; + N1 = u1 / u0; + c++; + } + u0 += du; + } + } + else if( _maxPolyDegree == 2 ) { + unsigned c = 0; + double du = _settings->GetMaxValFirstMoment() / (double)_gridSize; + + double u0 = _settings->GetRealizableSetEpsilonU0(); + double u1, u2; + double N1, N2; // helper + while( u0 < _settings->GetMaxValFirstMoment() ) { + u1 = -u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N1 = u1 / u0; + while( N1 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + u2 = u1 * u1 / u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N2 = u2 / u0; + while( N2 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + _uSol[c][0] = u0; // u0 (normalized i.e. N0) by Monreals notation + _uSol[c][1] = u1; // u1 (normalized i.e. N1) by Monreals notation + _uSol[c][2] = u2; // u2 (normalized i.e. N2) by Monreals notation + u2 += du; + N2 = u2 / u0; + c++; + } + u1 += du; + N1 = u1 / u0; + } + u0 += du; + } + } + else if( _maxPolyDegree == 3 ) { + unsigned c = 0; + double du = _settings->GetMaxValFirstMoment() / (double)_gridSize; + double u0 = _settings->GetRealizableSetEpsilonU0(); + double u1, u2, u3; + double N1, N2, N3; // helper + while( u0 < _settings->GetMaxValFirstMoment() ) { + u1 = -u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N1 = u1 / u0; + while( N1 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + u2 = u1 * u1 / u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N2 = u2 / u0; + while( u2 < u0 - _settings->GetRealizableSetEpsilonU0() ) { + u3 = -u2 + u0 * ( N1 + N2 ) * ( N1 + N2 ) / ( 1 + N1 ) + u0 * _settings->GetRealizableSetEpsilonU1(); + N3 = u3 / u0; + while( N3 < N2 - ( N1 - N2 ) * ( N1 - N2 ) / ( 1 - N1 ) - _settings->GetRealizableSetEpsilonU1() ) { + _uSol[c][0] = u0; // u0 by Monreals notation + _uSol[c][1] = u1; // u1 by Monreals notation + _uSol[c][2] = u2; // u2 by Monreals notation + _uSol[c][3] = u3; // u3 by Monreals notation + c++; + u3 += du; + N3 = u3 / u0; + } + u2 += du; + N2 = N3 / u0; + } + u1 += du; + N1 = u1 / u0; + } + u0 += du; + } + } + } + else if( _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS && _settings->GetNormalizedSampling() ) { + if( _maxPolyDegree == 1 ) { + // Carefull: This computes only normalized moments, i.e. sampling for u_0 = 1 + unsigned c = 0; + double dN = 2.0 / (double)_gridSize; + double N1 = -1.0 + _settings->GetRealizableSetEpsilonU0(); + while( N1 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { + _uSol[c][0] = 1; // u0 (normalized i.e. N0) by Monreals notation + _uSol[c][1] = N1; // u1 (normalized i.e. N1) by Monreals notation + N1 += dN; + c++; + } + } + if( _maxPolyDegree == 2 ) { + // Carefull: This computes only normalized moments, i.e. sampling for u_0 = 1 + unsigned c = 0; + double N1 = -1.0 + _settings->GetRealizableSetEpsilonU0(); + double N2; + double dN = 2.0 / (double)_gridSize; + while( N1 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { + N2 = N1 * N1 + _settings->GetRealizableSetEpsilonU0(); + while( N2 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { + _uSol[c][0] = 1; // u0 (normalized i.e. N0) by Monreals notation + _uSol[c][1] = N1; // u1 (normalized i.e. N1) by Monreals notation + _uSol[c][2] = N2; // u2 (normalized i.e. N2) by Monreals notation + N2 += dN; + c++; + } + N1 += dN; + } + } + if( _maxPolyDegree == 3 ) { + // Carefull: This computes only normalized moments, i.e. sampling for u_0 = 1, N1=0 + unsigned c = 0; + double N1 = 0 + _settings->GetRealizableSetEpsilonU0(); + double N2, N3; + double dN = 1.0 / (double)_gridSize; + N2 = N1 * N1 + _settings->GetRealizableSetEpsilonU0(); + while( N2 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { + N3 = -N2 + ( N1 + N2 ) * ( N1 + N2 ) / ( 1 + N1 ) + _settings->GetRealizableSetEpsilonU1(); + while( N3 < N2 - ( N1 - N2 ) * ( N1 - N2 ) / ( 1 - N1 ) - _settings->GetRealizableSetEpsilonU1() ) { + _uSol[c][0] = 1; // u0 by Monreals notation + _uSol[c][1] = N1; // u1 by Monreals notation + _uSol[c][2] = N2; // u2 by Monreals notation + _uSol[c][3] = N3; // u3 by Monreals notation + c++; + N3 += dN; + } + N2 += dN; + } + } + } + else { + ErrorMessages::Error( "Sampling for this configuration is not yet supported", CURRENT_FUNCTION ); + } +} + +void DataGenerator1D::CheckRealizability() { + // Todo +} + +void DataGenerator1D::ComputeSetSize() { + if( _maxPolyDegree == 0 ) { + } + else if( _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS && !_settings->GetNormalizedSampling() ) { + if( _maxPolyDegree == 1 ) { + unsigned c = 0; + double du = _settings->GetMaxValFirstMoment() / (double)_gridSize; + + double u0 = _settings->GetRealizableSetEpsilonU0(); + double u1; + double N1; // helper + while( u0 < _settings->GetMaxValFirstMoment() ) { + u1 = -u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N1 = u1 / u0; + while( N1 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + u1 += du; + N1 = u1 / u0; + c++; + } + u0 += du; + } + _setSize = c; + } + else if( _maxPolyDegree == 2 ) { + unsigned c = 0; + double du = _settings->GetMaxValFirstMoment() / (double)_gridSize; + + double u0 = _settings->GetRealizableSetEpsilonU0(); + double u1, u2; + double N1, N2; // helper + while( u0 < _settings->GetMaxValFirstMoment() ) { + u1 = -u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N1 = u1 / u0; + if( N1 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + while( N1 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + u2 = u1 * u1 / u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N2 = u2 / u0; + if( N2 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + while( N2 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + c++; + u2 += du; + N2 = u2 / u0; + } + } + u1 += du; + N1 = u1 / u0; + } + } + u0 += du; + } + _setSize = c; + } + else if( _maxPolyDegree == 3 ) { + unsigned c = 0; + double du = _settings->GetMaxValFirstMoment() / (double)_gridSize; + double u0 = _settings->GetRealizableSetEpsilonU0(); + double u1, u2, u3; + double N1, N2, N3; // helper + while( u0 < _settings->GetMaxValFirstMoment() ) { + u1 = -u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N1 = u1 / u0; + while( N1 < 1 - _settings->GetRealizableSetEpsilonU0() ) { + u2 = u1 * u1 / u0 + u0 * _settings->GetRealizableSetEpsilonU0(); + N2 = u2 / u0; + while( u2 < u0 - _settings->GetRealizableSetEpsilonU0() ) { + u3 = -u2 + u0 * ( N1 + N2 ) * ( N1 + N2 ) / ( 1 + N1 ) + u0 * _settings->GetRealizableSetEpsilonU1(); + N3 = u3 / u0; + while( N3 < N2 - ( N1 - N2 ) * ( N1 - N2 ) / ( 1 - N1 ) - _settings->GetRealizableSetEpsilonU1() ) { + u3 += du; + N3 = u3 / u0; + c++; + } + u2 += du; + N2 = u2 / u0; + } + u1 += du; + N1 = u1 / u0; + } + u0 += du; + } + _setSize = c; + } + else { + ErrorMessages::Error( "Sampling of training data of degree higher than 3 is not yet implemented.", CURRENT_FUNCTION ); + } + } + else if( _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS && _settings->GetNormalizedSampling() ) { + if( _maxPolyDegree == 1 ) { + // Carefull: This computes only normalized moments, i.e. sampling for u_0 = 1 + unsigned c = 0; + double dN = 2.0 / (double)_gridSize; + double N1 = -1.0 + _settings->GetRealizableSetEpsilonU0(); + while( N1 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { + N1 += dN; + c++; + } + _setSize = c; + } + else if( _maxPolyDegree == 2 ) { + // Carefull: This computes only normalized moments, i.e. sampling for u_0 = 1 + unsigned c = 0; + double N1 = -1.0 + _settings->GetRealizableSetEpsilonU0(); + double N2; + double dN = 2.0 / (double)_gridSize; + while( N1 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { + N2 = N1 * N1 + _settings->GetRealizableSetEpsilonU0(); + while( N2 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { + c++; + N2 += dN; + } + N1 += dN; + } + _setSize = c; + } + else if( _maxPolyDegree == 3 ) { + // Carefull: This computes only normalized moments, i.e. sampling for u_0 = 1, N1=0 + unsigned c = 0; + double N1 = 0 + _settings->GetRealizableSetEpsilonU0(); + double N2, N3; + double dN = 1.0 / (double)_gridSize; + N2 = N1 * N1 + _settings->GetRealizableSetEpsilonU0(); + while( N2 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { + N3 = -N2 + ( N1 + N2 ) * ( N1 + N2 ) / ( 1 + N1 ) + _settings->GetRealizableSetEpsilonU1(); + while( N3 < N2 - ( N1 - N2 ) * ( N1 - N2 ) / ( 1 - N1 ) - _settings->GetRealizableSetEpsilonU1() ) { + c++; + N3 += dN; + } + N2 += dN; + } + _setSize = c; + } + else { + ErrorMessages::Error( "Sampling of training data of degree higher than 3 is not yet implemented.", CURRENT_FUNCTION ); + } + } +} diff --git a/code/src/toolboxes/datagenerator2D.cpp b/code/src/toolboxes/datagenerator2D.cpp new file mode 100644 index 0000000000000000000000000000000000000000..34642cb62291b16d971ef30b0b6cc582ed822fea --- /dev/null +++ b/code/src/toolboxes/datagenerator2D.cpp @@ -0,0 +1,204 @@ +/*! + * \file datagenerator3D.cpp + * \brief Class to generate data for the neural entropy closure + * \author S. Schotthoefer + */ + +#include "toolboxes/datagenerator2D.h" +#include "common/config.h" +#include "quadratures/quadraturebase.h" +#include "toolboxes/errormessages.h" +#include "toolboxes/sphericalbase.h" + +#include +#include + +DataGenerator2D::DataGenerator2D( Config* settings ) : DataGeneratorBase( settings ) { + ComputeMoments(); + + AdaptBasisSize(); + + // Initialize Training Data + ComputeSetSize(); + + _uSol = VectorVector( _setSize, Vector( _nTotalEntries, 0.0 ) ); + _alpha = VectorVector( _setSize, Vector( _nTotalEntries, 0.0 ) ); + _hEntropy = std::vector( _setSize, 0.0 ); +} + +DataGenerator2D::~DataGenerator2D() {} + +void DataGenerator2D::ComputeMoments() { + double my, phi; + + for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { + my = _quadPointsSphere[idx_quad][0]; + phi = _quadPointsSphere[idx_quad][1]; + _moments[idx_quad] = _basis->ComputeSphericalBasis( my, phi ); + } +} + +void DataGenerator2D::SampleSolutionU() { + // Use necessary conditions from Monreal, Dissertation, Chapter 3.2.1, Page 26 + + // different processes for different + if( _maxPolyDegree == 0 ) { + // --- sample u in order 0 --- + // u_0 = <1*psi> + + // --- Determine stepsizes etc --- + double du0 = _settings->GetMaxValFirstMoment() / (double)_gridSize; + + for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { + _uSol[idx_set][0] = du0 * idx_set; + } + } + else if( _settings->GetNormalizedSampling() ) { + if( _maxPolyDegree == 1 && _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS ) { + // Sample points on unit sphere. + // Use MC sampling: x randUniform ==> r = sqrt(x)*u_0Max + // y radnUniform ==> a = 2*pi*y, + + // Create generator + std::default_random_engine generator; + std::uniform_real_distribution distribution( 0.0, 1.0 ); + + //#pragma omp parallel for schedule( guided ) + for( unsigned long idx_set = 0; idx_set < _setSize; idx_set++ ) { + double mu = std::sqrt( distribution( generator ) ); + double phi = 2 * M_PI * distribution( generator ); + + if( std::sqrt( 1 - mu * mu ) > _settings->GetRealizableSetEpsilonU1() ) { + idx_set--; + continue; + } + else { + _uSol[idx_set][0] = std::sqrt( 1 - mu * mu ) * std::cos( phi ); + _uSol[idx_set][1] = std::sqrt( 1 - mu * mu ) * std::sin( phi ); + } + } + } + else { + ErrorMessages::Error( "Sampling for this configuration is not yet supported", CURRENT_FUNCTION ); + } + } + else if( !_settings->GetNormalizedSampling() ) { + if( _maxPolyDegree == 1 && _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS ) { + // Sample points on unit sphere. + // Use MC sampling: x randUniform ==> r = sqrt(x)*u_0Max + // y radnUniform ==> a = 2*pi*y, + + // Create generator + std::default_random_engine generator; + std::uniform_real_distribution distribution( 0.0, 1.0 ); + + double du = 0.001; + long gridSize = (long)( (double)_settings->GetMaxValFirstMoment() / du ); + long c = 0; + for( long idx_set = 0; idx_set < gridSize; idx_set++ ) { + + double radiusU0 = du * ( idx_set + 1 ); + // Boundary correction + if( radiusU0 < _settings->GetRealizableSetEpsilonU0() ) { + radiusU0 = _settings->GetRealizableSetEpsilonU0(); // Boundary close to 0 + } + // number of points for unit circle should scale with (u_0)^2, + long currSetSize = ( (long)( radiusU0 * radiusU0 ) ) * _gridSize; + + for( long idx_currSet = 0; idx_currSet < currSetSize; idx_currSet++ ) { + double mu = std::sqrt( distribution( generator ) ); + double phi = 2 * M_PI * distribution( generator ); + if( std::sqrt( 1 - mu * mu ) > _settings->GetRealizableSetEpsilonU1() ) { + idx_set--; + continue; + } + else { + _uSol[c][0] = radiusU0; + _uSol[c][1] = radiusU0 * std::sqrt( 1 - mu * mu ) * std::cos( phi ); + _uSol[c][2] = radiusU0 * std::sqrt( 1 - mu * mu ) * std::sin( phi ); + c++; + } + } + } + } + else { + ErrorMessages::Error( "Sampling for this configuration is not yet supported", CURRENT_FUNCTION ); + } + } +} + +void DataGenerator2D::CheckRealizability() { + double epsilon = _settings->GetRealizableSetEpsilonU0(); + if( _maxPolyDegree == 1 ) { + //#pragma omp parallel for schedule( guided ) + for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { + double normU1 = 0.0; + Vector u1( 3, 0.0 ); + if( _uSol[idx_set][0] < epsilon ) { + if( std::abs( _uSol[idx_set][1] ) > 0 || std::abs( _uSol[idx_set][2] ) > 0 ) { + ErrorMessages::Error( "Moment not realizable [code 0]. Values: (" + std::to_string( _uSol[idx_set][0] ) + "|" + + std::to_string( _uSol[idx_set][1] ) + "|" + std::to_string( _uSol[idx_set][2] ) + ")", + CURRENT_FUNCTION ); + } + } + else { + u1 = { _uSol[idx_set][1], _uSol[idx_set][2] }; + normU1 = norm( u1 ); + if( normU1 / _uSol[idx_set][0] > _settings->GetRealizableSetEpsilonU1() ) { // Danger Hardcoded + std::cout << "normU1 / _uSol[" << idx_set << "][0]: " << normU1 / _uSol[idx_set][0] << "\n"; + std::cout << "normU1: " << normU1 << " | _uSol[idx_set][0] " << _uSol[idx_set][0] << "\n"; + ErrorMessages::Error( "Moment to close to boundary of realizable set [code 1].\nBoundary ratio: " + + std::to_string( normU1 / _uSol[idx_set][0] ), + CURRENT_FUNCTION ); + } + if( normU1 / _uSol[idx_set][0] <= 0 /*+ 0.5 * epsilon*/ ) { + // std::cout << "_uSol" << _uSol[idx_set][1] << " | " << _uSol[idx_set][2] << " | " << _uSol[idx_set][3] << " \n"; + // std::cout << "normU1 / _uSol[" << idx_set << "][0]: " << normU1 / _uSol[idx_set][0] << "\n"; + // std::cout << "normU1: " << normU1 << " | _uSol[idx_set][0] " << _uSol[idx_set][0] << "\n"; + ErrorMessages::Error( "Moment to close to boundary of realizable set [code 2].\nBoundary ratio: " + + std::to_string( normU1 / _uSol[idx_set][0] ), + CURRENT_FUNCTION ); + } + } + } + } +} + +void DataGenerator2D::ComputeSetSize() { + if( _maxPolyDegree == 0 ) { + } + else if( _settings->GetNormalizedSampling() ) { + if( _maxPolyDegree == 1 && _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS ) { + // Do nothing. Setsize is already given. + } + else { + ErrorMessages::Error( "Sampling for this configuration is not yet supported", CURRENT_FUNCTION ); + } + } + else if( !_settings->GetNormalizedSampling() ) { + if( _maxPolyDegree == 1 && _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS ) { + + double du = 0.001; + long gridSize = (long)( (double)_settings->GetMaxValFirstMoment() / du ); // Hardcoded + long c = 0; + for( long idx_set = 0; idx_set < gridSize; idx_set++ ) { + + double radiusU0 = du * ( idx_set + 1 ); + // Boundary correction + if( radiusU0 < _settings->GetRealizableSetEpsilonU0() ) { + radiusU0 = _settings->GetRealizableSetEpsilonU0(); // Boundary close to 0 + } + // number of points for unit circle should scale with (u_0)^2, + long currSetSize = ( (long)( radiusU0 * radiusU0 ) ) * _gridSize; + + for( long idx_currSet = 0; idx_currSet < currSetSize; idx_currSet++ ) { + c++; + } + } + _setSize = c; + } + else { + ErrorMessages::Error( "Sampling for this configuration is not yet supported", CURRENT_FUNCTION ); + } + } +} diff --git a/code/src/toolboxes/datagenerator.cpp b/code/src/toolboxes/datagenerator3D.cpp similarity index 50% rename from code/src/toolboxes/datagenerator.cpp rename to code/src/toolboxes/datagenerator3D.cpp index 3d5272ad030803c35e318d5843042bad49d14f9a..19647dfa335b02c8e6f134289253dbf22265d045 100644 --- a/code/src/toolboxes/datagenerator.cpp +++ b/code/src/toolboxes/datagenerator3D.cpp @@ -1,142 +1,51 @@ /*! - * \file datagenerator.cpp + * \file datagenerator3D.cpp * \brief Class to generate data for the neural entropy closure * \author S. Schotthoefer */ -#include "toolboxes/datagenerator.h" +#include "toolboxes/datagenerator3D.h" #include "common/config.h" -#include "entropies/entropybase.h" -#include "optimizers/newtonoptimizer.h" -#include "quadratures/qlebedev.h" #include "quadratures/quadraturebase.h" #include "toolboxes/errormessages.h" #include "toolboxes/sphericalbase.h" -#include "spdlog/spdlog.h" - #include #include -nnDataGenerator::nnDataGenerator( Config* settings ) { - _settings = settings; - _setSize = settings->GetTrainingDataSetSize(); - _gridSize = _setSize; - - _LMaxDegree = settings->GetMaxMomentDegree(); - - // Quadrature - _quadrature = QuadratureBase::Create( settings ); - _nq = _quadrature->GetNq(); - _quadPoints = _quadrature->GetPoints(); - _weights = _quadrature->GetWeights(); - _quadPointsSphere = _quadrature->GetPointsSphere(); - - // Spherical Harmonics - if( _settings->GetSphericalBasisName() == SPHERICAL_HARMONICS && _LMaxDegree > 0 ) { - ErrorMessages::Error( "No sampling algorithm for spherical harmonics basis with degree higher than 0 implemented", CURRENT_FUNCTION ); - } - _basis = SphericalBase::Create( _settings ); - - _nTotalEntries = _basis->GetBasisSize(); - - _moments = VectorVector( _nq, Vector( _nTotalEntries, 0.0 ) ); - +DataGenerator3D::DataGenerator3D( Config* settings ) : DataGeneratorBase( settings ) { ComputeMoments(); - // Optimizer - _optimizer = new NewtonOptimizer( _settings ); - - // Entropy - _entropy = EntropyBase::Create( _settings ); + AdaptBasisSize(); // Initialize Training Data - if( _LMaxDegree == 0 ) { - } - else if( _LMaxDegree == 1 ) { - // Sample points on unit sphere. - QuadratureBase* quad = QuadratureBase::Create( _settings ); - unsigned long nq = (unsigned long)quad->GetNq(); - - // Allocate memory. - _setSize = nq * _gridSize * ( _gridSize - 1 ) / 2; - - delete quad; - } - else if( _LMaxDegree == 2 && _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS && _settings->GetDim() == 1 ) { - // Carefull: This computes only normalized moments, i.e. sampling for u_0 = 1 - unsigned c = 1; - double N1 = -1.0 + _settings->GetRealizableSetEpsilonU0(); - double N2; - double dN = 2.0 / (double)_gridSize; - while( N1 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { - N2 = N1 * N1 + _settings->GetRealizableSetEpsilonU0(); - while( N2 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { - c++; - N2 += dN; - } - N1 += dN; - } - _setSize = c; - } - else { - ErrorMessages::Error( "Sampling of training data of degree higher than 1 is not yet implemented.", CURRENT_FUNCTION ); - } + ComputeSetSize(); _uSol = VectorVector( _setSize, Vector( _nTotalEntries, 0.0 ) ); _alpha = VectorVector( _setSize, Vector( _nTotalEntries, 0.0 ) ); _hEntropy = std::vector( _setSize, 0.0 ); } -nnDataGenerator::~nnDataGenerator() { - delete _quadrature; - delete _entropy; -} - -void nnDataGenerator::computeTrainingData() { - // Prototype: Only for _LMaxDegree == 1 - // Prototype: u is sampled from [0,100] - - // --- sample u --- - SampleSolutionU(); - - PrintLoadScreen(); - - // ---- Check realizability --- - CheckRealizability(); - - // --- compute alphas --- - _optimizer->SolveMultiCell( _alpha, _uSol, _moments ); - - // --- Postprocessing - ComputeRealizableSolution(); - - // --- compute entropy functional --- - ComputeEntropyH_primal(); - - // --- Print everything ---- - PrintTrainingData(); -} +DataGenerator3D::~DataGenerator3D() {} -void nnDataGenerator::ComputeMoments() { +void DataGenerator3D::ComputeMoments() { double my, phi; for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { - my = _quadPointsSphere[idx_quad][0]; - phi = _quadPointsSphere[idx_quad][1]; - + my = _quadPointsSphere[idx_quad][0]; + phi = _quadPointsSphere[idx_quad][1]; _moments[idx_quad] = _basis->ComputeSphericalBasis( my, phi ); } } -void nnDataGenerator::SampleSolutionU() { +void DataGenerator3D::SampleSolutionU() { // Use necessary conditions from Monreal, Dissertation, Chapter 3.2.1, Page 26 // --- Determine stepsizes etc --- double du0 = _settings->GetMaxValFirstMoment() / (double)_gridSize; // different processes for different - if( _LMaxDegree == 0 ) { + if( _maxPolyDegree == 0 ) { // --- sample u in order 0 --- // u_0 = <1*psi> @@ -144,7 +53,7 @@ void nnDataGenerator::SampleSolutionU() { _uSol[idx_set][0] = du0 * idx_set; } } - else if( _LMaxDegree == 1 && _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS ) { + else if( _maxPolyDegree == 1 && _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS ) { // Sample points on unit sphere. QuadratureBase* quad = QuadratureBase::Create( _settings ); VectorVector qpoints = quad->GetPoints(); // carthesian coordinates. @@ -196,77 +105,14 @@ void nnDataGenerator::SampleSolutionU() { } } } - else if( _LMaxDegree == 2 && _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS && _settings->GetDim() == 1 ) { - // Carefull: This computes only normalized moments, i.e. sampling for u_0 = 1 - unsigned c = 0; - double N1 = -1.0 + _settings->GetRealizableSetEpsilonU0(); - double N2; - double dN = 2.0 / (double)_gridSize; - while( N1 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { - N2 = N1 * N1 + _settings->GetRealizableSetEpsilonU0(); - while( N2 < 1.0 - _settings->GetRealizableSetEpsilonU0() ) { - _uSol[c][0] = 1; // u0 (normalized i.e. N0) by Monreals notation - _uSol[c][1] = N1; // u1 (normalized i.e. N1) by Monreals notation - _uSol[c][2] = N2; // u2 (normalized i.e. N2) by Monreals notation - N2 += dN; - c++; - } - N1 += dN; - } - } else { ErrorMessages::Error( "Sampling for this configuration is not yet supported", CURRENT_FUNCTION ); } } -void nnDataGenerator::ComputeEntropyH_dual() { -#pragma omp parallel for schedule( guided ) - for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { - _hEntropy[idx_set] = _optimizer->ComputeObjFunc( _alpha[idx_set], _uSol[idx_set], _moments ); - } -} - -void nnDataGenerator::ComputeEntropyH_primal() { -#pragma omp parallel for schedule( guided ) - for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { - double result = 0.0; - // Integrate (eta(eta'_*(alpha*m)) - for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { - result += _entropy->Entropy( _entropy->EntropyPrimeDual( dot( _alpha[idx_set], _moments[idx_quad] ) ) ) * _weights[idx_quad]; - } - _hEntropy[idx_set] = result; - } -} - -void nnDataGenerator::PrintTrainingData() { - auto log = spdlog::get( "event" ); - auto logCSV = spdlog::get( "tabular" ); - log->info( "---------------------- Data Generation Successful ------------------------" ); - - std::string uSolString = ""; - std::string alphaString = ""; - for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { - uSolString += "u_" + std::to_string( idx_sys ) + ","; - alphaString += "alpha_" + std::to_string( idx_sys ) + ","; - } - // log->info( uSolString + alphaString + "h" ); - logCSV->info( uSolString + alphaString + "h" ); - - for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { - std::string uSolString = ""; - std::string alphaString = ""; - for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { - uSolString += std::to_string( _uSol[idx_set][idx_sys] ) + ","; - alphaString += std::to_string( _alpha[idx_set][idx_sys] ) + ","; - } - // log->info( uSolString + alphaString + "{}", _hEntropy[idx_set] ); - logCSV->info( uSolString + alphaString + "{}", _hEntropy[idx_set] ); - } -} - -void nnDataGenerator::CheckRealizability() { +void DataGenerator3D::CheckRealizability() { double epsilon = _settings->GetRealizableSetEpsilonU0(); - if( _LMaxDegree == 1 ) { + if( _maxPolyDegree == 1 ) { #pragma omp parallel for schedule( guided ) for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { double normU1 = 0.0; @@ -302,20 +148,20 @@ void nnDataGenerator::CheckRealizability() { } } -void nnDataGenerator::ComputeRealizableSolution() { -#pragma omp parallel for schedule( guided ) - for( unsigned idx_sol = 0; idx_sol < _setSize; idx_sol++ ) { - double entropyReconstruction = 0.0; - _uSol[idx_sol] = 0; - for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { - // Make entropyReconstruction a member vector, s.t. it does not have to be re-evaluated in ConstructFlux - entropyReconstruction = _entropy->EntropyPrimeDual( blaze::dot( _alpha[idx_sol], _moments[idx_quad] ) ); - _uSol[idx_sol] += _moments[idx_quad] * ( _weights[idx_quad] * entropyReconstruction ); - } +void DataGenerator3D::ComputeSetSize() { + if( _maxPolyDegree == 0 ) { + } + else if( _maxPolyDegree == 1 && _settings->GetSphericalBasisName() == SPHERICAL_MONOMIALS ) { + // Sample points on unit sphere. + QuadratureBase* quad = QuadratureBase::Create( _settings ); + unsigned long nq = (unsigned long)quad->GetNq(); + + // Allocate memory. + _setSize = nq * _gridSize * ( _gridSize - 1 ) / 2; + + delete quad; + } + else { + ErrorMessages::Error( "Sampling of training data of degree higher than 1 is not yet implemented.", CURRENT_FUNCTION ); } -} -void nnDataGenerator::PrintLoadScreen() { - auto log = spdlog::get( "event" ); - log->info( "------------------------ Data Generation Starts --------------------------" ); - log->info( "| Generating {} datapoints.", _setSize ); } diff --git a/code/src/toolboxes/datageneratorbase.cpp b/code/src/toolboxes/datageneratorbase.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c286f7a43dfd591385c726b26ee4aa83c2d936f --- /dev/null +++ b/code/src/toolboxes/datageneratorbase.cpp @@ -0,0 +1,284 @@ +/*! + * \file datageneratorbase.cpp + * \brief Class to generate data for the neural entropy closure + * \author S. Schotthoefer + */ + +#include "toolboxes/datageneratorbase.h" +#include "common/config.h" +#include "entropies/entropybase.h" +#include "optimizers/newtonoptimizer.h" +#include "quadratures/quadraturebase.h" +#include "spdlog/spdlog.h" +#include "toolboxes/datagenerator1D.h" +#include "toolboxes/datagenerator2D.h" +#include "toolboxes/datagenerator3D.h" +#include "toolboxes/errormessages.h" +#include "toolboxes/sphericalbase.h" +#include "toolboxes/textprocessingtoolbox.h" + +#include +#include +#include +#include + +DataGeneratorBase::DataGeneratorBase( Config* settings ) { + _settings = settings; + _setSize = settings->GetTrainingDataSetSize(); + _gridSize = _setSize; + + _maxPolyDegree = settings->GetMaxMomentDegree(); + + // Check consistency between dimension of quadrature and sample basis + if( _settings->GetDim() == 1 ) { + if( _settings->GetQuadName() != QUAD_GaussLegendre1D && _settings->GetQuadName() != QUAD_GaussChebyshev1D ) { + ErrorMessages::Error( "For 1D Sampling, please choose a 1D quadrature rule.", CURRENT_FUNCTION ); + } + } + else { + if( _settings->GetQuadName() == QUAD_GaussLegendre1D || _settings->GetQuadName() == QUAD_GaussChebyshev1D ) { + ErrorMessages::Error( "For 3D Sampling, please choose a 3D quadrature rule.", CURRENT_FUNCTION ); + } + } + // Quadrature + _quadrature = QuadratureBase::Create( settings ); + _nq = _quadrature->GetNq(); + _quadPoints = _quadrature->GetPoints(); + _weights = _quadrature->GetWeights(); + _quadPointsSphere = _quadrature->GetPointsSphere(); + + // Spherical Harmonics + if( _settings->GetSphericalBasisName() == SPHERICAL_HARMONICS && _maxPolyDegree > 0 ) { + ErrorMessages::Error( "No sampling algorithm for spherical harmonics basis with degree higher than 0 implemented", CURRENT_FUNCTION ); + } + _basis = SphericalBase::Create( _settings ); + + _nTotalEntries = _basis->GetBasisSize(); + + _moments = VectorVector( _nq, Vector( _nTotalEntries, 0.0 ) ); + + // Optimizer + _optimizer = new NewtonOptimizer( _settings ); + + // Entropy + _entropy = EntropyBase::Create( _settings ); +} + +DataGeneratorBase::~DataGeneratorBase() { + delete _quadrature; + delete _entropy; +} + +DataGeneratorBase* DataGeneratorBase::Create( Config* settings ) { + switch( settings->GetDim() ) { + case 1: return new DataGenerator1D( settings ); + case 2: return new DataGenerator2D( settings ); + case 3: return new DataGenerator3D( settings ); + default: ErrorMessages::Error( "Sampling for more than 3 dimensions is not yet supported.", CURRENT_FUNCTION ); + } + return nullptr; +} + +void DataGeneratorBase::ComputeTrainingData() { + PrintLoadScreen(); + auto log = spdlog::get( "event" ); + + if( _settings->GetAlphaSampling() ) { + // --- sample alpha --- + SampleMultiplierAlpha(); + log->info( "| Multipliers sampled." ); + + log->info( "| Making moments realizable problems." ); + + // --- Postprocessing + ComputeRealizableSolution(); + } + else { + // --- sample u --- + SampleSolutionU(); + log->info( "| Moments sampled." ); + log->info( "| Start solving the optimization problems. This may take some minutes." ); + + // ---- Check realizability --- + CheckRealizability(); + + // --- compute alphas --- + + _optimizer->SolveMultiCell( _alpha, _uSol, _moments ); + + log->info( "| Making moments realizable problems." ); + + // --- Postprocessing + if( _settings->GetRelizabilityReconsU() ) { + ComputeRealizableSolution(); + } + } + + log->info( "| Compute entropies." ); + + // --- compute entropy functional --- + ComputeEntropyH_primal(); + + log->info( "| Print Solution." ); + + // --- Print everything ---- + PrintTrainingData(); +} + +void DataGeneratorBase::SampleMultiplierAlpha() { + double minAlphaValue = -50; + double maxAlphaValue = 50; + + if( _settings->GetNormalizedSampling() ) { + // compute reduced version of alpha and m + if( _maxPolyDegree == 0 ) { + ErrorMessages::Error( "Normalized sampling not meaningful for M0 closure", CURRENT_FUNCTION ); + } + VectorVector alphaRed = VectorVector( _setSize, Vector( _nTotalEntries - 1, 0.0 ) ); + VectorVector momentsRed = VectorVector( _nq, Vector( _nTotalEntries - 1, 0.0 ) ); + + for( unsigned idx_nq = 0; idx_nq < _nq; idx_nq++ ) { // copy (reduced) moments + for( unsigned idx_sys = 1; idx_sys < _nTotalEntries; idx_sys++ ) { + momentsRed[idx_nq][idx_sys - 1] = _moments[idx_nq][idx_sys]; + } + } + double dalpha = 0; + switch( _maxPolyDegree ) { + case 1: + // Sample alpha1 from [minAlphaValue, maxAlphaValue], then compute alpha_0 s.t. u_0 = 1 + dalpha = ( maxAlphaValue - minAlphaValue ) / (double)_setSize; + + for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { + alphaRed[idx_set][0] = minAlphaValue + idx_set * dalpha; + } + break; + default: ErrorMessages::Error( "Not yet implemented!", CURRENT_FUNCTION ); + } + + // Compute alpha_0 = log() // for maxwell boltzmann! only + for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { + double integral = 0.0; + // Integrate (eta(eta'_*(alpha*m)) + for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { + integral += _entropy->EntropyPrimeDual( dot( alphaRed[idx_set], momentsRed[idx_quad] ) ) * _weights[idx_quad]; + } + _alpha[idx_set][0] = -log( integral ); // log trafo + + // copy all other alphas to the member + for( unsigned idx_sys = 1; idx_sys < _nTotalEntries; idx_sys++ ) { + _alpha[idx_set][idx_sys] = alphaRed[idx_set][idx_sys - 1]; + } + } + } + else { + // non normalized sampling + // TODO + ErrorMessages::Error( "Not yet implemented!", CURRENT_FUNCTION ); + } +} + +void DataGeneratorBase::ComputeEntropyH_dual() { +#pragma omp parallel for schedule( guided ) + for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { + _hEntropy[idx_set] = _optimizer->ComputeObjFunc( _alpha[idx_set], _uSol[idx_set], _moments ); + } +} + +void DataGeneratorBase::ComputeEntropyH_primal() { +#pragma omp parallel for schedule( guided ) + for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { + double result = 0.0; + // Integrate (eta(eta'_*(alpha*m)) + for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { + result += _entropy->Entropy( _entropy->EntropyPrimeDual( dot( _alpha[idx_set], _moments[idx_quad] ) ) ) * _weights[idx_quad]; + } + _hEntropy[idx_set] = result; + } + + for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { + if( isnan( _hEntropy[idx_set] ) ) { + std::string msgU = "("; + std::string msgAlpha = "("; + for( unsigned idx_basis = 0; idx_basis < _nTotalEntries - 1; idx_basis++ ) { + msgU += std::to_string( _uSol[idx_set][idx_basis] ) + "|"; + msgAlpha += std::to_string( _alpha[idx_set][idx_basis] ) + "|"; + } + msgU += std::to_string( _uSol[idx_set][_nTotalEntries - 1] ) + ")"; + msgAlpha += std::to_string( _uSol[idx_set][_nTotalEntries - 1] ) + ")"; + + ErrorMessages::Error( "Value for h is NaN. This can happen near the boundary of the realizable set.\nu= " + msgU + + "\nalpha= " + msgAlpha + + "\nPlease adjust the Options " + "REALIZABLE_SET_EPSILON_U0 and REALIZABLE_SET_EPSILON_U1.", + CURRENT_FUNCTION ); + } + } +} + +void DataGeneratorBase::PrintTrainingData() { + auto log = spdlog::get( "event" ); + auto logCSV = spdlog::get( "tabular" ); + log->info( "---------------------- Data Generation Successful ------------------------" ); + + std::string uSolString = ""; + std::string alphaString = ""; + for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { + uSolString += "u_" + std::to_string( idx_sys ) + ","; + alphaString += "alpha_" + std::to_string( idx_sys ) + ","; + } + // log->info( uSolString + alphaString + "h" ); + logCSV->info( uSolString + alphaString + "h" ); + + for( unsigned idx_set = 0; idx_set < _setSize; idx_set++ ) { + + std::stringstream streamU, streamAlpha, streamH; + + for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { + streamU << std::fixed << std::setprecision( 12 ) << _uSol[idx_set][idx_sys] << ","; + streamAlpha << std::fixed << std::setprecision( 12 ) << _alpha[idx_set][idx_sys] << ","; + } + streamH << std::fixed << std::setprecision( 12 ) << _hEntropy[idx_set]; + + std::string uSolString = streamU.str(); + std::string alphaString = streamAlpha.str(); + std::string hString = streamH.str(); + + // log->info( uSolString + alphaString + hString ); + logCSV->info( uSolString + alphaString + hString ); + } +} + +void DataGeneratorBase::ComputeRealizableSolution() { +#pragma omp parallel for schedule( guided ) + for( unsigned idx_sol = 0; idx_sol < _setSize; idx_sol++ ) { + double entropyReconstruction = 0.0; + _uSol[idx_sol] = 0; + for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { + // Make entropyReconstruction a member vector, s.t. it does not have to be re-evaluated in ConstructFlux + entropyReconstruction = _entropy->EntropyPrimeDual( blaze::dot( _alpha[idx_sol], _moments[idx_quad] ) ); + _uSol[idx_sol] += _moments[idx_quad] * ( _weights[idx_quad] * entropyReconstruction ); + } + } +} + +void DataGeneratorBase::PrintLoadScreen() { + auto log = spdlog::get( "event" ); + log->info( "------------------------ Data Generation Starts --------------------------" ); + log->info( "| Generating {} datapoints.", _setSize ); +} + +void DataGeneratorBase::AdaptBasisSize() { + // Remove zero order Moment for dimension reduction + + if( _settings->GetNormalizedSampling() ) { + VectorVector momentTemp = _moments; + _nTotalEntries = _nTotalEntries - 1; + _moments = VectorVector( _nq, Vector( _nTotalEntries, 0.0 ) ); + + for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) { + for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { + _moments[idx_quad][idx_sys] = momentTemp[idx_quad][idx_sys + 1]; + } + } + } +} diff --git a/code/src/toolboxes/sphericalharmonics.cpp b/code/src/toolboxes/sphericalharmonics.cpp index e6b4745ad5351c71ccbb16faf34fa9643ff3182c..c0f7336fbb900be402dc043fadbb16d8fbe6a351 100644 --- a/code/src/toolboxes/sphericalharmonics.cpp +++ b/code/src/toolboxes/sphericalharmonics.cpp @@ -130,5 +130,4 @@ void SphericalHarmonics::ComputeYBasis( const double phi ) { _YBasis[GetGlobalIndexBasis( l_idx, k_idx )] = _assLegendreP[GlobalIdxAssLegendreP( l_idx, k_idx )] * c; } } - } diff --git a/code/src/toolboxes/sphericalmonomials.cpp b/code/src/toolboxes/sphericalmonomials.cpp index 25c3847abb21a39553b50750370e905bffeb226f..280c74074d40abd1431c0afb445d9deb17d322f7 100644 --- a/code/src/toolboxes/sphericalmonomials.cpp +++ b/code/src/toolboxes/sphericalmonomials.cpp @@ -24,22 +24,22 @@ SphericalMonomials::SphericalMonomials( unsigned L_degree, unsigned short spatia Vector SphericalMonomials::ComputeSphericalBasis( double my, double phi ) { switch( _spatialDim ) { - case 1: return ComputeSphericalBasis1D( my, phi ); break; + case 1: return ComputeSphericalBasis1D( my ); break; case 2: return ComputeSphericalBasis2D( my, phi ); break; default: return ComputeSphericalBasis3D( my, phi ); break; } } -Vector SphericalMonomials::ComputeSphericalBasis1D( double my, double phi ) { +Vector SphericalMonomials::ComputeSphericalBasis1D( double my ) { unsigned idx_vector = 0; unsigned a; - double omega_X; + double omega_Z; // go over all degrees of polynomials for( unsigned idx_degree = 0; idx_degree <= _LMaxDegree; idx_degree++ ) { // elem = Omega_x^a : a = idx_degree - omega_X = Omega_x( my, phi ); + omega_Z = Omega_z( my ); a = idx_degree; // a uniquely defined - _YBasis[idx_vector] = Power( omega_X, a ); + _YBasis[idx_vector] = Power( omega_Z, a ); idx_vector++; } return _YBasis; @@ -66,15 +66,14 @@ Vector SphericalMonomials::ComputeSphericalBasis2D( double my, double phi ) { Vector SphericalMonomials::ComputeSphericalBasis3D( double my, double phi ) { unsigned idx_vector = 0; - double omega_X, omega_Y, omega_Z; unsigned a, b, c; + double omega_X = Omega_x( my, phi ); + double omega_Y = Omega_y( my, phi ); + double omega_Z = Omega_z( my ); // go over all degrees of polynomials for( unsigned idx_degree = 0; idx_degree <= _LMaxDegree; idx_degree++ ) { // elem = Omega_x^a+ Omega_y^b +Omega_z^c : a+b+c = idx_degree - omega_X = Omega_x( my, phi ); - omega_Y = Omega_y( my, phi ); - omega_Z = Omega_z( my ); for( a = 0; a <= idx_degree; a++ ) { for( b = 0; b <= idx_degree - a; b++ ) { c = idx_degree - a - b; // c uniquely defined @@ -131,9 +130,9 @@ double SphericalMonomials::Omega_y( double my, double phi ) { return sqrt( 1 - m double SphericalMonomials::Omega_z( double my ) { return my; } double SphericalMonomials::Power( double basis, unsigned exponent ) { - if( exponent == 0 ) return 1.0; - double result = basis; - for( unsigned i = 1; i < exponent; i++ ) { + if( exponent == 0 ) return 1.0; // basis^0 + double result = basis; // basis^1 + for( unsigned i = 1; i < exponent; i++ ) { // exp> 1 result = result * basis; } return result; diff --git a/code/tests/catch2_main.cpp b/code/tests/catch2_main.cpp index ea5a7417c4609689e276d817639a19682e82975f..40dbb5b0064a2b0e3fa5b4896241866f7beec488 100644 --- a/code/tests/catch2_main.cpp +++ b/code/tests/catch2_main.cpp @@ -2,6 +2,7 @@ #include "catch.hpp" #include +#define PY_ARRAY_UNIQUE_SYMBOL KITRT_ARRAY_API #include #include diff --git a/code/tests/input/validation_tests/dataGenerator/validate_dataGen_csv_reference b/code/tests/input/validation_tests/dataGenerator/validate_dataGen_csv_reference index 542e60f7c4d58ec17f7121c7516732d190577689..b4e004626e7edb35c6d97a90f29716d54d87a1ef 100644 --- a/code/tests/input/validation_tests/dataGenerator/validate_dataGen_csv_reference +++ b/code/tests/input/validation_tests/dataGenerator/validate_dataGen_csv_reference @@ -1,129 +1,129 @@ -2021-02-19 15:26:51.242706 ,u_0,u_1,u_2,u_3,alpha_0,alpha_1,alpha_2,alpha_3,h -2021-02-19 15:26:51.242728 ,20.360217,2.775457,0.552073,-9.739846,-0.002440,0.489071,0.097282,-1.716286,-2.282440083785514 -2021-02-19 15:26:51.242735 ,20.360217,2.352919,1.572170,-9.739846,-0.002440,0.414615,0.277037,-1.716286,-2.2824400837855188 -2021-02-19 15:26:51.242741 ,20.360217,1.572170,2.352919,-9.739846,-0.002440,0.277037,0.414615,-1.716286,-2.2824400837855228 -2021-02-19 15:26:51.242747 ,20.360217,0.552073,2.775457,-9.739846,-0.002440,0.097282,0.489071,-1.716286,-2.282440083785519 -2021-02-19 15:26:51.242754 ,20.360217,-0.552073,2.775457,-9.739846,-0.002440,-0.097282,0.489071,-1.716286,-2.282440083785519 -2021-02-19 15:26:51.242760 ,20.360217,-1.572170,2.352919,-9.739846,-0.002440,-0.277037,0.414615,-1.716286,-2.282440083785528 -2021-02-19 15:26:51.242766 ,20.360217,-2.352919,1.572170,-9.739846,-0.002440,-0.414615,0.277037,-1.716286,-2.282440083785539 -2021-02-19 15:26:51.242772 ,20.360217,-2.775457,0.552073,-9.739846,-0.002440,-0.489071,0.097282,-1.716286,-2.2824400837855183 -2021-02-19 15:26:51.242778 ,20.360217,-2.775457,-0.552073,-9.739846,-0.002440,-0.489071,-0.097282,-1.716286,-2.282440083785521 -2021-02-19 15:26:51.242784 ,20.360217,-2.352919,-1.572170,-9.739846,-0.002440,-0.414615,-0.277037,-1.716286,-2.282440083785545 -2021-02-19 15:26:51.242791 ,20.360217,-1.572170,-2.352919,-9.739846,-0.002440,-0.277037,-0.414615,-1.716286,-2.282440083785531 -2021-02-19 15:26:51.242797 ,20.360217,-0.552073,-2.775457,-9.739846,-0.002440,-0.097282,-0.489071,-1.716286,-2.282440083785522 -2021-02-19 15:26:51.242803 ,20.360217,0.552073,-2.775457,-9.739846,-0.002440,0.097282,-0.489071,-1.716286,-2.2824400837855143 -2021-02-19 15:26:51.242809 ,20.360217,1.572170,-2.352919,-9.739846,-0.002440,0.277037,-0.414615,-1.716286,-2.282440083785516 -2021-02-19 15:26:51.242815 ,20.360217,2.352919,-1.572170,-9.739846,-0.002440,0.414615,-0.277037,-1.716286,-2.2824400837855174 -2021-02-19 15:26:51.242821 ,20.360217,2.775457,-0.552073,-9.739846,-0.002440,0.489071,-0.097282,-1.716286,-2.2824400837855134 -2021-02-19 15:26:51.242827 ,20.360217,6.012595,1.195979,-8.080278,-0.002440,1.059496,0.210747,-1.423849,-2.282440083785506 -2021-02-19 15:26:51.242834 ,20.360217,5.097232,3.405861,-8.080278,-0.002440,0.898198,0.600156,-1.423849,-2.2824400837855103 -2021-02-19 15:26:51.242840 ,20.360217,3.405861,5.097232,-8.080278,-0.002440,0.600156,0.898198,-1.423849,-2.2824400837855157 -2021-02-19 15:26:51.242846 ,20.360217,1.195979,6.012595,-8.080278,-0.002440,0.210747,1.059496,-1.423849,-2.2824400837855254 -2021-02-19 15:26:51.242852 ,20.360217,-1.195979,6.012595,-8.080278,-0.002440,-0.210747,1.059496,-1.423849,-2.282440083785526 -2021-02-19 15:26:51.242858 ,20.360217,-3.405861,5.097232,-8.080278,-0.002440,-0.600156,0.898198,-1.423849,-2.2824400837855223 -2021-02-19 15:26:51.242864 ,20.360217,-5.097232,3.405861,-8.080278,-0.002440,-0.898198,0.600156,-1.423849,-2.282440083785532 -2021-02-19 15:26:51.242870 ,20.360217,-6.012595,1.195979,-8.080278,-0.002440,-1.059496,0.210747,-1.423849,-2.2824400837855263 -2021-02-19 15:26:51.242876 ,20.360217,-6.012595,-1.195979,-8.080278,-0.002440,-1.059496,-0.210747,-1.423849,-2.2824400837855268 -2021-02-19 15:26:51.242882 ,20.360217,-5.097232,-3.405861,-8.080278,-0.002440,-0.898198,-0.600156,-1.423849,-2.282440083785532 -2021-02-19 15:26:51.242889 ,20.360217,-3.405861,-5.097232,-8.080278,-0.002440,-0.600156,-0.898198,-1.423849,-2.282440083785522 -2021-02-19 15:26:51.242895 ,20.360217,-1.195979,-6.012595,-8.080278,-0.002440,-0.210747,-1.059496,-1.423849,-2.282440083785527 -2021-02-19 15:26:51.242901 ,20.360217,1.195979,-6.012595,-8.080278,-0.002440,0.210747,-1.059496,-1.423849,-2.282440083785523 -2021-02-19 15:26:51.242907 ,20.360217,3.405861,-5.097232,-8.080278,-0.002440,0.600156,-0.898198,-1.423849,-2.2824400837855157 -2021-02-19 15:26:51.242913 ,20.360217,5.097232,-3.405861,-8.080278,-0.002440,0.898198,-0.600156,-1.423849,-2.282440083785511 -2021-02-19 15:26:51.242919 ,20.360217,6.012595,-1.195979,-8.080278,-0.002440,1.059496,-0.210747,-1.423849,-2.282440083785505 -2021-02-19 15:26:51.242925 ,20.360217,8.463260,1.683447,-5.330271,-0.002440,1.491335,0.296645,-0.939262,-2.2824400837854895 -2021-02-19 15:26:51.242946 ,20.360217,7.174806,4.794052,-5.330271,-0.002440,1.264293,0.844773,-0.939262,-2.2824400837854943 -2021-02-19 15:26:51.242952 ,20.360217,4.794052,7.174806,-5.330271,-0.002440,0.844773,1.264293,-0.939262,-2.282440083785509 -2021-02-19 15:26:51.242958 ,20.360217,1.683447,8.463260,-5.330271,-0.002440,0.296645,1.491335,-0.939262,-2.282440083785525 -2021-02-19 15:26:51.242964 ,20.360217,-1.683447,8.463260,-5.330271,-0.002440,-0.296645,1.491335,-0.939262,-2.282440083785528 -2021-02-19 15:26:51.242970 ,20.360217,-4.794052,7.174806,-5.330271,-0.002440,-0.844773,1.264293,-0.939262,-2.2824400837855214 -2021-02-19 15:26:51.242976 ,20.360217,-7.174806,4.794052,-5.330271,-0.002440,-1.264293,0.844773,-0.939262,-2.2824400837855197 -2021-02-19 15:26:51.242982 ,20.360217,-8.463260,1.683447,-5.330271,-0.002440,-1.491335,0.296645,-0.939262,-2.2824400837855294 -2021-02-19 15:26:51.242988 ,20.360217,-8.463260,-1.683447,-5.330271,-0.002440,-1.491335,-0.296645,-0.939262,-2.2824400837855294 -2021-02-19 15:26:51.242995 ,20.360217,-7.174806,-4.794052,-5.330271,-0.002440,-1.264293,-0.844773,-0.939262,-2.2824400837855197 -2021-02-19 15:26:51.243001 ,20.360217,-4.794052,-7.174806,-5.330271,-0.002440,-0.844773,-1.264293,-0.939262,-2.2824400837855245 -2021-02-19 15:26:51.243007 ,20.360217,-1.683447,-8.463260,-5.330271,-0.002440,-0.296645,-1.491335,-0.939262,-2.282440083785533 -2021-02-19 15:26:51.243013 ,20.360217,1.683447,-8.463260,-5.330271,-0.002440,0.296645,-1.491335,-0.939262,-2.282440083785527 -2021-02-19 15:26:51.243019 ,20.360217,4.794052,-7.174806,-5.330271,-0.002440,0.844773,-1.264293,-0.939262,-2.282440083785512 -2021-02-19 15:26:51.243025 ,20.360217,7.174806,-4.794052,-5.330271,-0.002440,1.264293,-0.844773,-0.939262,-2.2824400837854952 -2021-02-19 15:26:51.243031 ,20.360217,8.463260,-1.683447,-5.330271,-0.002440,1.491335,-0.296645,-0.939262,-2.282440083785491 -2021-02-19 15:26:51.243037 ,20.360217,9.778929,1.945150,-1.860506,-0.002440,1.723173,0.342760,-0.327845,-2.2824400837854912 -2021-02-19 15:26:51.243044 ,20.360217,8.290176,5.539319,-1.860506,-0.002440,1.460835,0.976099,-0.327845,-2.2824400837854997 -2021-02-19 15:26:51.243050 ,20.360217,5.539319,8.290176,-1.860506,-0.002440,0.976099,1.460835,-0.327845,-2.2824400837855126 -2021-02-19 15:26:51.243056 ,20.360217,1.945150,9.778929,-1.860506,-0.002440,0.342760,1.723173,-0.327845,-2.2824400837855237 -2021-02-19 15:26:51.243062 ,20.360217,-1.945150,9.778929,-1.860506,-0.002440,-0.342760,1.723173,-0.327845,-2.282440083785537 -2021-02-19 15:26:51.243068 ,20.360217,-5.539319,8.290176,-1.860506,-0.002440,-0.976099,1.460835,-0.327845,-2.282440083785529 -2021-02-19 15:26:51.243074 ,20.360217,-8.290176,5.539319,-1.860506,-0.002440,-1.460835,0.976099,-0.327845,-2.282440083785525 -2021-02-19 15:26:51.243080 ,20.360217,-9.778929,1.945150,-1.860506,-0.002440,-1.723173,0.342760,-0.327845,-2.282440083785531 -2021-02-19 15:26:51.243086 ,20.360217,-9.778929,-1.945150,-1.860506,-0.002440,-1.723173,-0.342760,-0.327845,-2.2824400837855365 -2021-02-19 15:26:51.243093 ,20.360217,-8.290176,-5.539319,-1.860506,-0.002440,-1.460835,-0.976099,-0.327845,-2.2824400837855245 -2021-02-19 15:26:51.243099 ,20.360217,-5.539319,-8.290176,-1.860506,-0.002440,-0.976099,-1.460835,-0.327845,-2.2824400837855294 -2021-02-19 15:26:51.243105 ,20.360217,-1.945150,-9.778929,-1.860506,-0.002440,-0.342760,-1.723173,-0.327845,-2.2824400837855374 -2021-02-19 15:26:51.243111 ,20.360217,1.945150,-9.778929,-1.860506,-0.002440,0.342760,-1.723173,-0.327845,-2.282440083785522 -2021-02-19 15:26:51.243117 ,20.360217,5.539319,-8.290176,-1.860506,-0.002440,0.976099,-1.460835,-0.327845,-2.282440083785511 -2021-02-19 15:26:51.243123 ,20.360217,8.290176,-5.539319,-1.860506,-0.002440,1.460835,-0.976099,-0.327845,-2.2824400837854983 -2021-02-19 15:26:51.243129 ,20.360217,9.778929,-1.945150,-1.860506,-0.002440,1.723173,-0.342760,-0.327845,-2.282440083785499 -2021-02-19 15:26:51.243135 ,20.360217,9.778929,1.945150,1.860506,-0.002440,1.723173,0.342760,0.327845,-2.2824400837854903 -2021-02-19 15:26:51.243147 ,20.360217,8.290176,5.539319,1.860506,-0.002440,1.460835,0.976099,0.327845,-2.2824400837854983 -2021-02-19 15:26:51.243153 ,20.360217,5.539319,8.290176,1.860506,-0.002440,0.976099,1.460835,0.327845,-2.282440083785513 -2021-02-19 15:26:51.243159 ,20.360217,1.945150,9.778929,1.860506,-0.002440,0.342760,1.723173,0.327845,-2.2824400837855228 -2021-02-19 15:26:51.243165 ,20.360217,-1.945150,9.778929,1.860506,-0.002440,-0.342760,1.723173,0.327845,-2.2824400837855356 -2021-02-19 15:26:51.243172 ,20.360217,-5.539319,8.290176,1.860506,-0.002440,-0.976099,1.460835,0.327845,-2.2824400837855348 -2021-02-19 15:26:51.243178 ,20.360217,-8.290176,5.539319,1.860506,-0.002440,-1.460835,0.976099,0.327845,-2.282440083785527 -2021-02-19 15:26:51.243184 ,20.360217,-9.778929,1.945150,1.860506,-0.002440,-1.723173,0.342760,0.327845,-2.2824400837855374 -2021-02-19 15:26:51.243190 ,20.360217,-9.778929,-1.945150,1.860506,-0.002440,-1.723173,-0.342760,0.327845,-2.282440083785535 -2021-02-19 15:26:51.243196 ,20.360217,-8.290176,-5.539319,1.860506,-0.002440,-1.460835,-0.976099,0.327845,-2.282440083785528 -2021-02-19 15:26:51.243202 ,20.360217,-5.539319,-8.290176,1.860506,-0.002440,-0.976099,-1.460835,0.327845,-2.28244008378553 -2021-02-19 15:26:51.243208 ,20.360217,-1.945150,-9.778929,1.860506,-0.002440,-0.342760,-1.723173,0.327845,-2.28244008378554 -2021-02-19 15:26:51.243214 ,20.360217,1.945150,-9.778929,1.860506,-0.002440,0.342760,-1.723173,0.327845,-2.2824400837855316 -2021-02-19 15:26:51.243220 ,20.360217,5.539319,-8.290176,1.860506,-0.002440,0.976099,-1.460835,0.327845,-2.2824400837855165 -2021-02-19 15:26:51.243227 ,20.360217,8.290176,-5.539319,1.860506,-0.002440,1.460835,-0.976099,0.327845,-2.2824400837854997 -2021-02-19 15:26:51.243233 ,20.360217,9.778929,-1.945150,1.860506,-0.002440,1.723173,-0.342760,0.327845,-2.2824400837854912 -2021-02-19 15:26:51.243239 ,20.360217,8.463260,1.683447,5.330271,-0.002440,1.491335,0.296645,0.939262,-2.2824400837854966 -2021-02-19 15:26:51.243245 ,20.360217,7.174806,4.794052,5.330271,-0.002440,1.264293,0.844773,0.939262,-2.2824400837854895 -2021-02-19 15:26:51.243251 ,20.360217,4.794052,7.174806,5.330271,-0.002440,0.844773,1.264293,0.939262,-2.282440083785509 -2021-02-19 15:26:51.243257 ,20.360217,1.683447,8.463260,5.330271,-0.002440,0.296645,1.491335,0.939262,-2.2824400837855263 -2021-02-19 15:26:51.243263 ,20.360217,-1.683447,8.463260,5.330271,-0.002440,-0.296645,1.491335,0.939262,-2.2824400837855343 -2021-02-19 15:26:51.243270 ,20.360217,-4.794052,7.174806,5.330271,-0.002440,-0.844773,1.264293,0.939262,-2.2824400837855183 -2021-02-19 15:26:51.243276 ,20.360217,-7.174806,4.794052,5.330271,-0.002440,-1.264293,0.844773,0.939262,-2.282440083785526 -2021-02-19 15:26:51.243282 ,20.360217,-8.463260,1.683447,5.330271,-0.002440,-1.491335,0.296645,0.939262,-2.28244008378553 -2021-02-19 15:26:51.243288 ,20.360217,-8.463260,-1.683447,5.330271,-0.002440,-1.491335,-0.296645,0.939262,-2.282440083785531 -2021-02-19 15:26:51.243294 ,20.360217,-7.174806,-4.794052,5.330271,-0.002440,-1.264293,-0.844773,0.939262,-2.2824400837855237 -2021-02-19 15:26:51.243300 ,20.360217,-4.794052,-7.174806,5.330271,-0.002440,-0.844773,-1.264293,0.939262,-2.2824400837855197 -2021-02-19 15:26:51.243306 ,20.360217,-1.683447,-8.463260,5.330271,-0.002440,-0.296645,-1.491335,0.939262,-2.28244008378553 -2021-02-19 15:26:51.243312 ,20.360217,1.683447,-8.463260,5.330271,-0.002440,0.296645,-1.491335,0.939262,-2.2824400837855254 -2021-02-19 15:26:51.243318 ,20.360217,4.794052,-7.174806,5.330271,-0.002440,0.844773,-1.264293,0.939262,-2.2824400837855165 -2021-02-19 15:26:51.243325 ,20.360217,7.174806,-4.794052,5.330271,-0.002440,1.264293,-0.844773,0.939262,-2.2824400837854957 -2021-02-19 15:26:51.243331 ,20.360217,8.463260,-1.683447,5.330271,-0.002440,1.491335,-0.296645,0.939262,-2.2824400837854872 -2021-02-19 15:26:51.243337 ,20.360217,6.012595,1.195979,8.080278,-0.002440,1.059496,0.210747,1.423849,-2.282440083785509 -2021-02-19 15:26:51.243343 ,20.360217,5.097232,3.405861,8.080278,-0.002440,0.898198,0.600156,1.423849,-2.2824400837855117 -2021-02-19 15:26:51.243352 ,20.360217,3.405861,5.097232,8.080278,-0.002440,0.600156,0.898198,1.423849,-2.2824400837855126 -2021-02-19 15:26:51.243358 ,20.360217,1.195979,6.012595,8.080278,-0.002440,0.210747,1.059496,1.423849,-2.282440083785519 -2021-02-19 15:26:51.243364 ,20.360217,-1.195979,6.012595,8.080278,-0.002440,-0.210747,1.059496,1.423849,-2.282440083785529 -2021-02-19 15:26:51.243371 ,20.360217,-3.405861,5.097232,8.080278,-0.002440,-0.600156,0.898198,1.423849,-2.2824400837855223 -2021-02-19 15:26:51.243377 ,20.360217,-5.097232,3.405861,8.080278,-0.002440,-0.898198,0.600156,1.423849,-2.282440083785531 -2021-02-19 15:26:51.243383 ,20.360217,-6.012595,1.195979,8.080278,-0.002440,-1.059496,0.210747,1.423849,-2.2824400837855263 -2021-02-19 15:26:51.243389 ,20.360217,-6.012595,-1.195979,8.080278,-0.002440,-1.059496,-0.210747,1.423849,-2.2824400837855294 -2021-02-19 15:26:51.243395 ,20.360217,-5.097232,-3.405861,8.080278,-0.002440,-0.898198,-0.600156,1.423849,-2.2824400837855308 -2021-02-19 15:26:51.243401 ,20.360217,-3.405861,-5.097232,8.080278,-0.002440,-0.600156,-0.898198,1.423849,-2.282440083785522 -2021-02-19 15:26:51.243408 ,20.360217,-1.195979,-6.012595,8.080278,-0.002440,-0.210747,-1.059496,1.423849,-2.282440083785531 -2021-02-19 15:26:51.243414 ,20.360217,1.195979,-6.012595,8.080278,-0.002440,0.210747,-1.059496,1.423849,-2.282440083785527 -2021-02-19 15:26:51.243420 ,20.360217,3.405861,-5.097232,8.080278,-0.002440,0.600156,-0.898198,1.423849,-2.2824400837855148 -2021-02-19 15:26:51.243426 ,20.360217,5.097232,-3.405861,8.080278,-0.002440,0.898198,-0.600156,1.423849,-2.2824400837855148 -2021-02-19 15:26:51.243432 ,20.360217,6.012595,-1.195979,8.080278,-0.002440,1.059496,-0.210747,1.423849,-2.282440083785507 -2021-02-19 15:26:51.243438 ,20.360217,2.775457,0.552073,9.739846,-0.002440,0.489071,0.097282,1.716286,-2.282440083785508 -2021-02-19 15:26:51.243445 ,20.360217,2.352919,1.572170,9.739846,-0.002440,0.414615,0.277037,1.716286,-2.282440083785513 -2021-02-19 15:26:51.243451 ,20.360217,1.572170,2.352919,9.739846,-0.002440,0.277037,0.414615,1.716286,-2.282440083785519 -2021-02-19 15:26:51.243457 ,20.360217,0.552073,2.775457,9.739846,-0.002440,0.097282,0.489071,1.716286,-2.2824400837855108 -2021-02-19 15:26:51.243463 ,20.360217,-0.552073,2.775457,9.739846,-0.002440,-0.097282,0.489071,1.716286,-2.2824400837855205 -2021-02-19 15:26:51.243469 ,20.360217,-1.572170,2.352919,9.739846,-0.002440,-0.277037,0.414615,1.716286,-2.282440083785531 -2021-02-19 15:26:51.243476 ,20.360217,-2.352919,1.572170,9.739846,-0.002440,-0.414615,0.277037,1.716286,-2.282440083785541 -2021-02-19 15:26:51.243482 ,20.360217,-2.775457,0.552073,9.739846,-0.002440,-0.489071,0.097282,1.716286,-2.2824400837855237 -2021-02-19 15:26:51.243488 ,20.360217,-2.775457,-0.552073,9.739846,-0.002440,-0.489071,-0.097282,1.716286,-2.2824400837855245 -2021-02-19 15:26:51.243494 ,20.360217,-2.352919,-1.572170,9.739846,-0.002440,-0.414615,-0.277037,1.716286,-2.282440083785536 -2021-02-19 15:26:51.243500 ,20.360217,-1.572170,-2.352919,9.739846,-0.002440,-0.277037,-0.414615,1.716286,-2.28244008378553 -2021-02-19 15:26:51.243507 ,20.360217,-0.552073,-2.775457,9.739846,-0.002440,-0.097282,-0.489071,1.716286,-2.282440083785516 -2021-02-19 15:26:51.243513 ,20.360217,0.552073,-2.775457,9.739846,-0.002440,0.097282,-0.489071,1.716286,-2.2824400837855148 -2021-02-19 15:26:51.243519 ,20.360217,1.572170,-2.352919,9.739846,-0.002440,0.277037,-0.414615,1.716286,-2.2824400837855174 -2021-02-19 15:26:51.243525 ,20.360217,2.352919,-1.572170,9.739846,-0.002440,0.414615,-0.277037,1.716286,-2.2824400837855126 -2021-02-19 15:26:51.243533 ,20.360217,2.775457,-0.552073,9.739846,-0.002440,0.489071,-0.097282,1.716286,-2.282440083785507 +2021-03-12 12:17:12.895981 ,u_0,u_1,u_2,u_3,alpha_0,alpha_1,alpha_2,alpha_3,h +2021-03-12 12:17:12.896029 ,20.360217192149,2.775457455351,0.552072813005,-9.739846265576,-0.002440446044,0.489071247650,0.097282319687,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896045 ,20.360217192149,2.352919217358,1.572170357789,-9.739846265576,-0.002440446044,0.414614583637,0.277036607756,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896059 ,20.360217192149,1.572170357789,2.352919217358,-9.739846265576,-0.002440446044,0.277036607756,0.414614583637,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896073 ,20.360217192149,0.552072813005,2.775457455351,-9.739846265576,-0.002440446044,0.097282319687,0.489071247650,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896087 ,20.360217192149,-0.552072813005,2.775457455351,-9.739846265576,-0.002440446044,-0.097282319687,0.489071247650,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896100 ,20.360217192149,-1.572170357789,2.352919217358,-9.739846265576,-0.002440446044,-0.277036607756,0.414614583637,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896114 ,20.360217192149,-2.352919217358,1.572170357789,-9.739846265576,-0.002440446044,-0.414614583637,0.277036607756,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896128 ,20.360217192149,-2.775457455351,0.552072813005,-9.739846265576,-0.002440446044,-0.489071247650,0.097282319687,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896141 ,20.360217192149,-2.775457455351,-0.552072813005,-9.739846265576,-0.002440446044,-0.489071247650,-0.097282319687,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896155 ,20.360217192149,-2.352919217358,-1.572170357789,-9.739846265576,-0.002440446044,-0.414614583637,-0.277036607756,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896168 ,20.360217192149,-1.572170357789,-2.352919217358,-9.739846265576,-0.002440446044,-0.277036607756,-0.414614583637,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896182 ,20.360217192149,-0.552072813005,-2.775457455351,-9.739846265576,-0.002440446044,-0.097282319687,-0.489071247650,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896195 ,20.360217192149,0.552072813005,-2.775457455351,-9.739846265576,-0.002440446044,0.097282319687,-0.489071247650,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896209 ,20.360217192149,1.572170357789,-2.352919217358,-9.739846265576,-0.002440446044,0.277036607756,-0.414614583637,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896222 ,20.360217192149,2.352919217358,-1.572170357789,-9.739846265576,-0.002440446044,0.414614583637,-0.277036607756,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896236 ,20.360217192149,2.775457455351,-0.552072813005,-9.739846265576,-0.002440446044,0.489071247650,-0.097282319687,-1.716285996688,-2.282440083786 +2021-03-12 12:17:12.896252 ,20.360217192149,6.012594628191,1.195979431588,-8.080278014440,-0.002440446044,1.059496390677,0.210746935300,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896271 ,20.360217192149,5.097231600355,3.405861267884,-8.080278014440,-0.002440446044,0.898197669555,0.600156495426,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896287 ,20.360217192149,3.405861267884,5.097231600355,-8.080278014440,-0.002440446044,0.600156495426,0.898197669555,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896303 ,20.360217192149,1.195979431588,6.012594628191,-8.080278014440,-0.002440446044,0.210746935300,1.059496390677,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896319 ,20.360217192149,-1.195979431588,6.012594628191,-8.080278014440,-0.002440446044,-0.210746935300,1.059496390677,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896335 ,20.360217192149,-3.405861267884,5.097231600355,-8.080278014440,-0.002440446044,-0.600156495426,0.898197669555,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896351 ,20.360217192149,-5.097231600355,3.405861267884,-8.080278014440,-0.002440446044,-0.898197669555,0.600156495426,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896366 ,20.360217192149,-6.012594628191,1.195979431588,-8.080278014440,-0.002440446044,-1.059496390677,0.210746935300,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896478 ,20.360217192149,-6.012594628191,-1.195979431588,-8.080278014440,-0.002440446044,-1.059496390677,-0.210746935300,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896495 ,20.360217192149,-5.097231600355,-3.405861267884,-8.080278014440,-0.002440446044,-0.898197669555,-0.600156495426,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896511 ,20.360217192149,-3.405861267884,-5.097231600355,-8.080278014440,-0.002440446044,-0.600156495426,-0.898197669555,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896527 ,20.360217192149,-1.195979431588,-6.012594628191,-8.080278014440,-0.002440446044,-0.210746935300,-1.059496390677,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896543 ,20.360217192149,1.195979431588,-6.012594628191,-8.080278014440,-0.002440446044,0.210746935300,-1.059496390677,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896559 ,20.360217192149,3.405861267884,-5.097231600355,-8.080278014440,-0.002440446044,0.600156495426,-0.898197669555,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896575 ,20.360217192149,5.097231600355,-3.405861267884,-8.080278014440,-0.002440446044,0.898197669555,-0.600156495426,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896591 ,20.360217192149,6.012594628191,-1.195979431588,-8.080278014440,-0.002440446044,1.059496390677,-0.210746935300,-1.423848757710,-2.282440083786 +2021-03-12 12:17:12.896607 ,20.360217192149,8.463260237138,1.683447129519,-5.330270694342,-0.002440446044,1.491335143827,0.296645004015,-0.939262150737,-2.282440083785 +2021-03-12 12:17:12.896623 ,20.360217192149,7.174805585679,4.794051823575,-5.330270694342,-0.002440446044,1.264292887166,0.844773499278,-0.939262150737,-2.282440083785 +2021-03-12 12:17:12.896639 ,20.360217192149,4.794051823575,7.174805585679,-5.330270694342,-0.002440446044,0.844773499278,1.264292887166,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896654 ,20.360217192149,1.683447129519,8.463260237138,-5.330270694342,-0.002440446044,0.296645004015,1.491335143827,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896670 ,20.360217192149,-1.683447129519,8.463260237138,-5.330270694342,-0.002440446044,-0.296645004015,1.491335143827,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896686 ,20.360217192149,-4.794051823575,7.174805585679,-5.330270694342,-0.002440446044,-0.844773499278,1.264292887166,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896702 ,20.360217192149,-7.174805585679,4.794051823575,-5.330270694342,-0.002440446044,-1.264292887166,0.844773499278,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896718 ,20.360217192149,-8.463260237138,1.683447129519,-5.330270694342,-0.002440446044,-1.491335143827,0.296645004015,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896734 ,20.360217192149,-8.463260237138,-1.683447129519,-5.330270694342,-0.002440446044,-1.491335143827,-0.296645004015,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896749 ,20.360217192149,-7.174805585679,-4.794051823575,-5.330270694342,-0.002440446044,-1.264292887166,-0.844773499278,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896765 ,20.360217192149,-4.794051823575,-7.174805585679,-5.330270694342,-0.002440446044,-0.844773499278,-1.264292887166,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896781 ,20.360217192149,-1.683447129519,-8.463260237138,-5.330270694342,-0.002440446044,-0.296645004015,-1.491335143827,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896796 ,20.360217192149,1.683447129519,-8.463260237138,-5.330270694342,-0.002440446044,0.296645004015,-1.491335143827,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896812 ,20.360217192149,4.794051823575,-7.174805585679,-5.330270694342,-0.002440446044,0.844773499278,-1.264292887166,-0.939262150737,-2.282440083786 +2021-03-12 12:17:12.896828 ,20.360217192149,7.174805585679,-4.794051823575,-5.330270694342,-0.002440446044,1.264292887166,-0.844773499278,-0.939262150737,-2.282440083785 +2021-03-12 12:17:12.896844 ,20.360217192149,8.463260237138,-1.683447129519,-5.330270694342,-0.002440446044,1.491335143827,-0.296645004015,-0.939262150737,-2.282440083785 +2021-03-12 12:17:12.896896 ,20.360217192149,9.778929486875,1.945150014673,-1.860506185294,-0.002440446044,1.723172962210,0.342760413318,-0.327845083537,-2.282440083785 +2021-03-12 12:17:12.896913 ,20.360217192149,8.290176118715,5.539318587114,-1.860506185294,-0.002440446044,1.460835499315,0.976099074157,-0.327845083537,-2.282440083785 +2021-03-12 12:17:12.896929 ,20.360217192149,5.539318587114,8.290176118715,-1.860506185294,-0.002440446044,0.976099074157,1.460835499315,-0.327845083537,-2.282440083786 +2021-03-12 12:17:12.896944 ,20.360217192149,1.945150014673,9.778929486875,-1.860506185294,-0.002440446044,0.342760413318,1.723172962210,-0.327845083536,-2.282440083786 +2021-03-12 12:17:12.896960 ,20.360217192149,-1.945150014673,9.778929486875,-1.860506185294,-0.002440446044,-0.342760413318,1.723172962210,-0.327845083536,-2.282440083786 +2021-03-12 12:17:12.896976 ,20.360217192149,-5.539318587114,8.290176118715,-1.860506185294,-0.002440446044,-0.976099074157,1.460835499315,-0.327845083537,-2.282440083786 +2021-03-12 12:17:12.896992 ,20.360217192149,-8.290176118715,5.539318587114,-1.860506185294,-0.002440446044,-1.460835499315,0.976099074157,-0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897008 ,20.360217192149,-9.778929486875,1.945150014673,-1.860506185294,-0.002440446044,-1.723172962210,0.342760413318,-0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897024 ,20.360217192149,-9.778929486875,-1.945150014673,-1.860506185294,-0.002440446044,-1.723172962210,-0.342760413318,-0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897040 ,20.360217192149,-8.290176118715,-5.539318587114,-1.860506185294,-0.002440446044,-1.460835499315,-0.976099074157,-0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897056 ,20.360217192149,-5.539318587114,-8.290176118715,-1.860506185294,-0.002440446044,-0.976099074157,-1.460835499315,-0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897072 ,20.360217192149,-1.945150014673,-9.778929486875,-1.860506185294,-0.002440446044,-0.342760413318,-1.723172962210,-0.327845083536,-2.282440083786 +2021-03-12 12:17:12.897088 ,20.360217192149,1.945150014673,-9.778929486875,-1.860506185294,-0.002440446044,0.342760413318,-1.723172962210,-0.327845083536,-2.282440083786 +2021-03-12 12:17:12.897103 ,20.360217192149,5.539318587114,-8.290176118715,-1.860506185294,-0.002440446044,0.976099074157,-1.460835499315,-0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897119 ,20.360217192149,8.290176118715,-5.539318587114,-1.860506185294,-0.002440446044,1.460835499315,-0.976099074157,-0.327845083537,-2.282440083785 +2021-03-12 12:17:12.897135 ,20.360217192149,9.778929486875,-1.945150014673,-1.860506185294,-0.002440446044,1.723172962210,-0.342760413318,-0.327845083537,-2.282440083785 +2021-03-12 12:17:12.897151 ,20.360217192149,9.778929486875,1.945150014673,1.860506185294,-0.002440446044,1.723172962210,0.342760413318,0.327845083537,-2.282440083785 +2021-03-12 12:17:12.897167 ,20.360217192149,8.290176118715,5.539318587114,1.860506185294,-0.002440446044,1.460835499315,0.976099074157,0.327845083537,-2.282440083785 +2021-03-12 12:17:12.897183 ,20.360217192149,5.539318587114,8.290176118715,1.860506185294,-0.002440446044,0.976099074157,1.460835499315,0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897199 ,20.360217192149,1.945150014673,9.778929486875,1.860506185294,-0.002440446044,0.342760413318,1.723172962210,0.327845083536,-2.282440083786 +2021-03-12 12:17:12.897215 ,20.360217192149,-1.945150014673,9.778929486875,1.860506185294,-0.002440446044,-0.342760413318,1.723172962210,0.327845083536,-2.282440083786 +2021-03-12 12:17:12.897231 ,20.360217192149,-5.539318587114,8.290176118715,1.860506185294,-0.002440446044,-0.976099074157,1.460835499315,0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897246 ,20.360217192149,-8.290176118715,5.539318587114,1.860506185294,-0.002440446044,-1.460835499315,0.976099074157,0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897262 ,20.360217192149,-9.778929486875,1.945150014673,1.860506185294,-0.002440446044,-1.723172962210,0.342760413318,0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897296 ,20.360217192149,-9.778929486875,-1.945150014673,1.860506185294,-0.002440446044,-1.723172962210,-0.342760413318,0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897313 ,20.360217192149,-8.290176118715,-5.539318587114,1.860506185294,-0.002440446044,-1.460835499315,-0.976099074157,0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897329 ,20.360217192149,-5.539318587114,-8.290176118715,1.860506185294,-0.002440446044,-0.976099074157,-1.460835499315,0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897345 ,20.360217192149,-1.945150014673,-9.778929486875,1.860506185294,-0.002440446044,-0.342760413318,-1.723172962210,0.327845083536,-2.282440083786 +2021-03-12 12:17:12.897361 ,20.360217192149,1.945150014673,-9.778929486875,1.860506185294,-0.002440446044,0.342760413318,-1.723172962210,0.327845083536,-2.282440083786 +2021-03-12 12:17:12.897377 ,20.360217192149,5.539318587114,-8.290176118715,1.860506185294,-0.002440446044,0.976099074157,-1.460835499315,0.327845083537,-2.282440083786 +2021-03-12 12:17:12.897393 ,20.360217192149,8.290176118715,-5.539318587114,1.860506185294,-0.002440446044,1.460835499315,-0.976099074157,0.327845083537,-2.282440083785 +2021-03-12 12:17:12.897409 ,20.360217192149,9.778929486875,-1.945150014673,1.860506185294,-0.002440446044,1.723172962210,-0.342760413318,0.327845083537,-2.282440083785 +2021-03-12 12:17:12.897425 ,20.360217192149,8.463260237138,1.683447129519,5.330270694342,-0.002440446044,1.491335143827,0.296645004015,0.939262150737,-2.282440083785 +2021-03-12 12:17:12.897441 ,20.360217192149,7.174805585679,4.794051823575,5.330270694342,-0.002440446044,1.264292887166,0.844773499278,0.939262150737,-2.282440083785 +2021-03-12 12:17:12.897457 ,20.360217192149,4.794051823575,7.174805585679,5.330270694342,-0.002440446044,0.844773499278,1.264292887166,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897473 ,20.360217192149,1.683447129519,8.463260237138,5.330270694342,-0.002440446044,0.296645004015,1.491335143827,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897489 ,20.360217192149,-1.683447129519,8.463260237138,5.330270694342,-0.002440446044,-0.296645004015,1.491335143827,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897505 ,20.360217192149,-4.794051823575,7.174805585679,5.330270694342,-0.002440446044,-0.844773499278,1.264292887166,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897521 ,20.360217192149,-7.174805585679,4.794051823575,5.330270694342,-0.002440446044,-1.264292887166,0.844773499278,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897537 ,20.360217192149,-8.463260237138,1.683447129519,5.330270694342,-0.002440446044,-1.491335143827,0.296645004015,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897552 ,20.360217192149,-8.463260237138,-1.683447129519,5.330270694342,-0.002440446044,-1.491335143827,-0.296645004015,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897568 ,20.360217192149,-7.174805585679,-4.794051823575,5.330270694342,-0.002440446044,-1.264292887166,-0.844773499278,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897584 ,20.360217192149,-4.794051823575,-7.174805585679,5.330270694342,-0.002440446044,-0.844773499278,-1.264292887166,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897600 ,20.360217192149,-1.683447129519,-8.463260237138,5.330270694342,-0.002440446044,-0.296645004015,-1.491335143827,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897616 ,20.360217192149,1.683447129519,-8.463260237138,5.330270694342,-0.002440446044,0.296645004015,-1.491335143827,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897632 ,20.360217192149,4.794051823575,-7.174805585679,5.330270694342,-0.002440446044,0.844773499278,-1.264292887166,0.939262150737,-2.282440083786 +2021-03-12 12:17:12.897647 ,20.360217192149,7.174805585679,-4.794051823575,5.330270694342,-0.002440446044,1.264292887166,-0.844773499278,0.939262150737,-2.282440083785 +2021-03-12 12:17:12.897663 ,20.360217192149,8.463260237138,-1.683447129519,5.330270694342,-0.002440446044,1.491335143827,-0.296645004015,0.939262150737,-2.282440083785 +2021-03-12 12:17:12.897679 ,20.360217192149,6.012594628191,1.195979431588,8.080278014440,-0.002440446044,1.059496390677,0.210746935300,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897703 ,20.360217192149,5.097231600355,3.405861267884,8.080278014440,-0.002440446044,0.898197669555,0.600156495426,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897720 ,20.360217192149,3.405861267884,5.097231600355,8.080278014440,-0.002440446044,0.600156495426,0.898197669555,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897736 ,20.360217192149,1.195979431588,6.012594628191,8.080278014440,-0.002440446044,0.210746935300,1.059496390677,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897752 ,20.360217192149,-1.195979431588,6.012594628191,8.080278014440,-0.002440446044,-0.210746935300,1.059496390677,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897768 ,20.360217192149,-3.405861267884,5.097231600355,8.080278014440,-0.002440446044,-0.600156495426,0.898197669555,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897784 ,20.360217192149,-5.097231600355,3.405861267884,8.080278014440,-0.002440446044,-0.898197669555,0.600156495426,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897800 ,20.360217192149,-6.012594628191,1.195979431588,8.080278014440,-0.002440446044,-1.059496390677,0.210746935300,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897816 ,20.360217192149,-6.012594628191,-1.195979431588,8.080278014440,-0.002440446044,-1.059496390677,-0.210746935300,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897832 ,20.360217192149,-5.097231600355,-3.405861267884,8.080278014440,-0.002440446044,-0.898197669555,-0.600156495426,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897849 ,20.360217192149,-3.405861267884,-5.097231600355,8.080278014440,-0.002440446044,-0.600156495426,-0.898197669555,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897865 ,20.360217192149,-1.195979431588,-6.012594628191,8.080278014440,-0.002440446044,-0.210746935300,-1.059496390677,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897881 ,20.360217192149,1.195979431588,-6.012594628191,8.080278014440,-0.002440446044,0.210746935300,-1.059496390677,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897897 ,20.360217192149,3.405861267884,-5.097231600355,8.080278014440,-0.002440446044,0.600156495426,-0.898197669555,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897913 ,20.360217192149,5.097231600355,-3.405861267884,8.080278014440,-0.002440446044,0.898197669555,-0.600156495426,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897929 ,20.360217192149,6.012594628191,-1.195979431588,8.080278014440,-0.002440446044,1.059496390677,-0.210746935300,1.423848757710,-2.282440083786 +2021-03-12 12:17:12.897945 ,20.360217192149,2.775457455351,0.552072813005,9.739846265576,-0.002440446044,0.489071247650,0.097282319687,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.897962 ,20.360217192149,2.352919217358,1.572170357789,9.739846265576,-0.002440446044,0.414614583637,0.277036607756,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.897978 ,20.360217192149,1.572170357789,2.352919217358,9.739846265576,-0.002440446044,0.277036607756,0.414614583637,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.897994 ,20.360217192149,0.552072813005,2.775457455351,9.739846265576,-0.002440446044,0.097282319687,0.489071247650,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898010 ,20.360217192149,-0.552072813005,2.775457455351,9.739846265576,-0.002440446044,-0.097282319687,0.489071247650,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898026 ,20.360217192149,-1.572170357789,2.352919217358,9.739846265576,-0.002440446044,-0.277036607756,0.414614583637,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898042 ,20.360217192149,-2.352919217358,1.572170357789,9.739846265576,-0.002440446044,-0.414614583637,0.277036607756,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898059 ,20.360217192149,-2.775457455351,0.552072813005,9.739846265576,-0.002440446044,-0.489071247650,0.097282319687,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898075 ,20.360217192149,-2.775457455351,-0.552072813005,9.739846265576,-0.002440446044,-0.489071247650,-0.097282319687,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898098 ,20.360217192149,-2.352919217358,-1.572170357789,9.739846265576,-0.002440446044,-0.414614583637,-0.277036607756,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898114 ,20.360217192149,-1.572170357789,-2.352919217358,9.739846265576,-0.002440446044,-0.277036607756,-0.414614583637,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898131 ,20.360217192149,-0.552072813005,-2.775457455351,9.739846265576,-0.002440446044,-0.097282319687,-0.489071247650,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898147 ,20.360217192149,0.552072813005,-2.775457455351,9.739846265576,-0.002440446044,0.097282319687,-0.489071247650,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898163 ,20.360217192149,1.572170357789,-2.352919217358,9.739846265576,-0.002440446044,0.277036607756,-0.414614583637,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898179 ,20.360217192149,2.352919217358,-1.572170357789,9.739846265576,-0.002440446044,0.414614583637,-0.277036607756,1.716285996688,-2.282440083786 +2021-03-12 12:17:12.898195 ,20.360217192149,2.775457455351,-0.552072813005,9.739846265576,-0.002440446044,0.489071247650,-0.097282319687,1.716285996688,-2.282440083786 diff --git a/code/tests/test_cases.cpp b/code/tests/test_cases.cpp index 14780b68c09fc5a329bb6faf5e7e248dd102be44..9fad188ce06145e8678e3c51009cbf7203baad2c 100644 --- a/code/tests/test_cases.cpp +++ b/code/tests/test_cases.cpp @@ -7,7 +7,7 @@ #include "common/config.h" #include "solvers/solverbase.h" -#include "toolboxes/datagenerator.h" +#include "toolboxes/datageneratorbase.h" using vtkUnstructuredGridReaderSP = vtkSmartPointer; @@ -36,8 +36,8 @@ TEST_CASE( "SN_SOLVER", "[validation_tests]" ) { SECTION( "checkerboard" ) { std::string config_file_name = std::string( TESTS_PATH ) + sn_fileDir + "checkerboard_SN.cfg"; - Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + Config* config = new Config( config_file_name ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); @@ -57,8 +57,8 @@ TEST_CASE( "SN_SOLVER", "[validation_tests]" ) { SECTION( "linesource" ) { std::string config_file_name = std::string( TESTS_PATH ) + sn_fileDir + "linesource_SN.cfg"; - Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + Config* config = new Config( config_file_name ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); @@ -80,8 +80,8 @@ TEST_CASE( "PN_SOLVER", "[validation_tests]" ) { SECTION( "checkerboard" ) { std::string config_file_name = std::string( TESTS_PATH ) + pn_fileDir + "checkerboard_PN.cfg"; - Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + Config* config = new Config( config_file_name ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); @@ -100,8 +100,8 @@ TEST_CASE( "PN_SOLVER", "[validation_tests]" ) { SECTION( "linesource" ) { std::string config_file_name = std::string( TESTS_PATH ) + pn_fileDir + "linesource_PN.cfg"; - Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + Config* config = new Config( config_file_name ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); @@ -125,8 +125,8 @@ TEST_CASE( "MN_SOLVER", "[validation_tests]" ) { SECTION( "checkerboard" ) { std::string config_file_name = std::string( TESTS_PATH ) + mn_fileDir + "checkerboard_MN.cfg"; - Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + Config* config = new Config( config_file_name ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); @@ -149,8 +149,8 @@ TEST_CASE( "MN_SOLVER", "[validation_tests]" ) { { std::string config_file_name = std::string( TESTS_PATH ) + mn_fileDir + "linesource_MN_Quad.cfg"; - Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + Config* config = new Config( config_file_name ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); @@ -170,8 +170,8 @@ TEST_CASE( "MN_SOLVER", "[validation_tests]" ) { { // --- Maxwell Boltzmann Entropy --- std::string config_file_name = std::string( TESTS_PATH ) + mn_fileDir + "linesource_MN_MB.cfg"; - Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + Config* config = new Config( config_file_name ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); @@ -197,7 +197,7 @@ TEST_CASE( "CSD_SN_FP_SOLVER", "[validation_tests]" ) { std::string config_file_name = std::string( TESTS_PATH ) + csd_sn_fileDir + "waterphantom_1D.cfg"; Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); auto test = readVTKFile( std::string( TESTS_PATH ) + "result/rtsn_test_waterphantom_1D_CSD_FP.vtk" ); @@ -220,7 +220,7 @@ TEST_CASE( "CSD_SN_FP_2D_SOLVER", "[validation_tests]" ) { std::string config_file_name = std::string( TESTS_PATH ) + csd_sn_fileDir + "waterphantom_2D.cfg"; Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); auto test = readVTKFile( std::string( TESTS_PATH ) + "result/rtsn_test_waterphantom_2D_CSD_FP.vtk" ); @@ -243,7 +243,7 @@ TEST_CASE( "CSD_SN_FP_SH_2D_SOLVER", "[validation_tests]" ) { std::string config_file_name = std::string( TESTS_PATH ) + csd_sn_fileDir + "waterphantom_2D_sh.cfg"; Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); solver->PrintVolumeOutput(); // solver->Save(); @@ -281,8 +281,8 @@ TEST_CASE( "screen_output", "[output]" ) { std::string historyLoggerReference = std::string( TESTS_PATH ) + out_fileDir + "validate_logger_csv_reference"; std::string historyLogger = std::string( TESTS_PATH ) + "result/logs/validate_logger_output_csv"; - Config* config = new Config( config_file_name ); - Solver* solver = Solver::Create( config ); + Config* config = new Config( config_file_name ); + SolverBase* solver = SolverBase::Create( config ); solver->Solve(); // Force Logger to flush @@ -370,9 +370,9 @@ TEST_CASE( "Test the Data Generator", "[dataGen]" ) { // Load Settings from File Config* config = new Config( config_file_name ); // Build Data generator - nnDataGenerator* datagen = new nnDataGenerator( config ); + DataGeneratorBase* datagen = DataGeneratorBase::Create( config ); // Generate Data and export - datagen->computeTrainingData(); + datagen->ComputeTrainingData(); // --- Force Logger to flush auto log = spdlog::get( "event" ); @@ -417,4 +417,6 @@ TEST_CASE( "Test the Data Generator", "[dataGen]" ) { count++; } REQUIRE( testPassed ); + + delete datagen; } diff --git a/code/tests/test_quadrature.cpp b/code/tests/test_quadrature.cpp index e795af376cb1c97eb328a7b49f85b30ea4eacdb0..10ae57a991669905586b3966b5db241a5bb9418d 100644 --- a/code/tests/test_quadrature.cpp +++ b/code/tests/test_quadrature.cpp @@ -5,13 +5,20 @@ #include -std::vector quadraturenames = { - QUAD_MonteCarlo, QUAD_GaussLegendreTensorized, QUAD_GaussLegendre1D, QUAD_LevelSymmetric, QUAD_Lebedev, QUAD_LDFESA, QUAD_Product }; +std::vector quadraturenames = { QUAD_MonteCarlo, + QUAD_GaussLegendreTensorized, + QUAD_GaussLegendre1D, + QUAD_GaussLegendreTensorized2D, + QUAD_LevelSymmetric, + QUAD_Lebedev, + QUAD_LDFESA, + QUAD_Product }; std::vector> quadratureorders = { { 4, 5, 6, 7 }, // Monte Carlo { 4, 6, 8, 10 }, // Gauss Legendre { 4, 6, 8, 10 }, // Gauss Legendre 1D + { 4, 6, 8, 10 }, // Gauss Legendre 2D { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 }, // Available Orders for LevelSymmetric { 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131 }, // Available orders for Lebedev @@ -67,8 +74,9 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) { config->SetQuadName( quadraturename ); lowAccuracyTesting = false; - if( quadraturename == QUAD_GaussLegendreTensorized || quadraturename == QUAD_GaussLegendre1D || quadraturename == QUAD_LevelSymmetric || - quadraturename == QUAD_Lebedev || quadraturename == QUAD_LDFESA || quadraturename == QUAD_Product ) + if( quadraturename == QUAD_GaussLegendreTensorized || quadraturename == QUAD_GaussLegendre1D || + quadraturename == QUAD_GaussLegendreTensorized2D || quadraturename == QUAD_LevelSymmetric || quadraturename == QUAD_Lebedev || + quadraturename == QUAD_LDFESA || quadraturename == QUAD_Product ) lowAccuracyTesting = true; for( auto quadratureorder : quadratureorders[quadraturename] ) { @@ -82,14 +90,18 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) { testPassed = false; PrintErrorMsg( config, std::abs( Q->SumUpWeights() - 2 ), Q->SumUpWeights(), lowAccuracyTesting ); } - + } + else if( quadraturename == QUAD_GaussLegendreTensorized2D ) { + if( !approxequal( Q->SumUpWeights(), M_PI, lowAccuracyTesting ) ) { + testPassed = false; + PrintErrorMsg( config, std::abs( Q->SumUpWeights() - M_PI ), Q->SumUpWeights(), lowAccuracyTesting ); + } } else { if( !approxequal( Q->SumUpWeights(), 4 * M_PI, lowAccuracyTesting ) ) { testPassed = false; PrintErrorMsg( config, std::abs( Q->SumUpWeights() - 4 * M_PI ), Q->SumUpWeights(), lowAccuracyTesting ); } - } // Special case for Gauss Legendre with half weights if( quadraturename == QUAD_GaussLegendreTensorized ) { @@ -118,11 +130,13 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) { config->SetQuadName( quadraturename ); lowAccuracyTesting = false; - if( quadraturename == QUAD_GaussLegendreTensorized || quadraturename == QUAD_GaussLegendre1D || quadraturename == QUAD_LevelSymmetric || - quadraturename == QUAD_Lebedev || quadraturename == QUAD_LDFESA ) + if( quadraturename == QUAD_GaussLegendreTensorized || quadraturename == QUAD_GaussLegendre1D || + quadraturename == QUAD_GaussLegendreTensorized2D || quadraturename == QUAD_LevelSymmetric || quadraturename == QUAD_Lebedev || + quadraturename == QUAD_LDFESA ) lowAccuracyTesting = true; - if( quadraturename == QUAD_GaussLegendre1D ) continue; // 1D test case not meaningful here + if( quadraturename == QUAD_GaussLegendre1D || quadraturename == QUAD_GaussLegendreTensorized2D ) + continue; // 1D and 2D test case not meaningful here for( auto quadratureorder : quadratureorders[quadraturename] ) { // Set quadOrder @@ -233,7 +247,13 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) { testPassed = false; PrintErrorMsg( config, std::abs( result - 0 ), result, lowAccuracyTesting ); } - + } + else if( quadraturename == QUAD_GaussLegendreTensorized2D ) { + result = Q->Integrate( sin ); + if( !approxequal( result, 0, lowAccuracyTesting ) ) { + testPassed = false; + PrintErrorMsg( config, std::abs( result - 0 ), result, lowAccuracyTesting ); + } } else { result = Q->Integrate( f ); @@ -241,7 +261,6 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) { testPassed = false; PrintErrorMsg( config, std::abs( result - 4.0 * M_PI ), result, lowAccuracyTesting ); } - } // Special case for Gauss Legendre with half weights @@ -256,7 +275,6 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) { printf( "Reduced number of quadrature was points used. \n" ); } - config->SetSNAllGaussPts( true ); } } @@ -295,12 +313,14 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) { printf( "y component incorrectly computed.\n" ); printf( "Faulty index is %d.\n", idx_nq ); } - result = Omega_z( pointsSphere[idx_nq][0], pointsSphere[idx_nq][1] ); - if( !approxequal( points[idx_nq][2], result, lowAccuracyTesting ) ) { - testPassed = false; - PrintErrorMsg( config, std::abs( result - points[idx_nq][2] ), result, lowAccuracyTesting ); - printf( "z component incorrectly computed.\n" ); - printf( "Faulty index is %d.\n", idx_nq ); + if( quadraturename != QUAD_GaussLegendreTensorized2D ) { + result = Omega_z( pointsSphere[idx_nq][0], pointsSphere[idx_nq][1] ); + if( !approxequal( points[idx_nq][2], result, lowAccuracyTesting ) ) { + testPassed = false; + PrintErrorMsg( config, std::abs( result - points[idx_nq][2] ), result, lowAccuracyTesting ); + printf( "z component incorrectly computed.\n" ); + printf( "Faulty index is %d.\n", idx_nq ); + } } } delete Q; @@ -335,7 +355,8 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) { QuadratureBase* Q = QuadratureBase::Create( config ); // Note: Leaving out Quad_GaussLegendreTensorized with half weights... (to be added) - if( quadraturename != QUAD_GaussLegendre1D && quadraturename != QUAD_MonteCarlo ) // MonteCarlo is too low order... + if( quadraturename != QUAD_GaussLegendreTensorized2D && quadraturename != QUAD_GaussLegendre1D && + quadraturename != QUAD_MonteCarlo ) // MonteCarlo is too low order... { if( quadraturename == QUAD_LevelSymmetric && quadratureorder == 20 ) continue; // Order 20 is somehow errorous result = Q->IntegrateSpherical( Omega_0 ); diff --git a/code/tests/test_sphericalBasis.cpp b/code/tests/test_sphericalBasis.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4d829d3066649e8a16ebd9a7bca8549fb4b8d326 --- /dev/null +++ b/code/tests/test_sphericalBasis.cpp @@ -0,0 +1,407 @@ +#include "catch.hpp" +#include "common/config.h" +#include "quadratures/qgausslegendretensorized.h" +#include "toolboxes/sphericalharmonics.h" +#include "toolboxes/sphericalmonomials.h" + +#include +#include +#include + +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_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_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 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 ); } + +double P2_0( double my ) { return sqrt( 5 / ( 8 * M_PI ) ) * ( 3 * my * my - 1 ); } +double P2_1( double my ) { return -1 * sqrt( 15 / ( 4 * M_PI ) ) * my * sqrt( 1 - my * my ); } +double P2_2( double my ) { return sqrt( 15 / ( 16 * M_PI ) ) * ( 1 - my * my ); } + +TEST_CASE( "test spherical harmonics basis ", "[spherical_harmonics]" ) { + + std::string filename = std::string( TESTS_PATH ) + "input/unit_tests/solvers/unit_harmonics.cfg"; + + // Load Settings from File + Config* config = new Config( filename ); + + unsigned maxMomentDegree = 2; + + SphericalHarmonics testBase( maxMomentDegree ); + + SECTION( "Test Global Indexing" ) { + bool indexingRight = true; + if( testBase.GetGlobalIndexBasis( 0, 0 ) != 0 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 1, -1 ) != 1 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 1, 0 ) != 2 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 1, 1 ) != 3 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, -2 ) != 4 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, -1 ) != 5 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, 0 ) != 6 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, 1 ) != 7 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, 2 ) != 8 ) indexingRight = false; + + REQUIRE( indexingRight ); + } + + SECTION( "Test against analytical solution" ) { + std::vector legendre; + Vector moment; + std::vector validLegendrePoly( 6, true ); + std::vector validMoment( 9, true ); + for( double my = -1.0; my < 1.0; my += 0.1 ) { + + legendre = testBase.GetAssLegendrePoly( my ); + + if( std::fabs( legendre[0] - P0_0( my ) ) > 1e2 * std::numeric_limits::epsilon() ) validLegendrePoly[0] = false; + if( std::fabs( legendre[1] - P1_0( my ) ) > 1e2 * std::numeric_limits::epsilon() ) validLegendrePoly[1] = false; + if( std::fabs( legendre[2] - P1_1( my ) ) > 1e2 * std::numeric_limits::epsilon() ) validLegendrePoly[2] = false; + if( std::fabs( legendre[3] - P2_0( my ) ) > 1e2 * std::numeric_limits::epsilon() ) validLegendrePoly[3] = false; + if( std::fabs( legendre[4] - P2_1( my ) ) > 1e2 * std::numeric_limits::epsilon() ) validLegendrePoly[4] = false; + if( std::fabs( legendre[5] - P2_2( my ) ) > 1e2 * std::numeric_limits::epsilon() ) validLegendrePoly[5] = false; + + for( double phi = 0.0; phi < 2 * M_PI; phi += 0.1 ) { + moment = testBase.ComputeSphericalBasis( my, phi ); + + if( std::fabs( moment[0] - Y0_0( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[0] = false; + if( std::fabs( moment[1] - Y1_m1( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[1] = false; + if( std::fabs( moment[2] - Y1_0( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[2] = false; + if( std::fabs( moment[3] - Y1_1( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[3] = false; + if( std::fabs( moment[4] - Y2_m2( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[4] = false; + if( std::fabs( moment[5] - Y2_m1( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[5] = false; + if( std::fabs( moment[6] - Y2_0( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[6] = false; + if( std::fabs( moment[7] - Y2_1( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[7] = false; + if( std::fabs( moment[8] - Y2_2( my, phi ) ) > 1e2 * std::numeric_limits::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 + + SECTION( "test to reference solution" ) { + + std::string text_line; + std::ifstream case_file; + + double my = 0.0; + double phi = 0.0; + + Vector values( 9, 0.0 ); + Vector result( 4, 0.0 ); + + case_file.open( "unit_test/solvers/harmonicBasis_reference.csv", std::ios::in ); + + getline( case_file, text_line ); + + bool errorWithinBounds = true; + while( getline( case_file, text_line ) ) { + + // give line to stringstream + std::stringstream ss( text_line ); + + // Read values + ss >> my >> phi >> values[0] >> values[1] >> values[2] >> values[3] >> values[4] >> values[5] >> values[6] >> values[7] >> values[8]; + + result = testBase.ComputeSphericalBasis( my, phi ); + + for( unsigned idx = 0; idx < 9; idx++ ) { + if( std::fabs( result[idx] - values[idx] ) > 1e2 * std::numeric_limits::epsilon() ) errorWithinBounds = false; + } + } + REQUIRE( errorWithinBounds ); + case_file.close(); + } + + SECTION( "test orthonormality - spherical coordinates" ) { + // Caution: Integration only works with spherical coordinates! + + QGaussLegendreTensorized quad( config ); + + double my, phi, w; + Vector moment = testBase.ComputeSphericalBasis( 0, 1, 0 ); + // 9 basis moments if degree = 2 + + Matrix results( moment.size(), moment.size(), 0.0 ); + + for( unsigned idx_quad = 0; idx_quad < quad.GetNq(); idx_quad++ ) { + my = quad.GetPointsSphere()[idx_quad][0]; + phi = quad.GetPointsSphere()[idx_quad][1]; + // z = quad.GetPoints()[idx_quad][2]; + w = quad.GetWeights()[idx_quad]; + moment = testBase.ComputeSphericalBasis( my, phi ); + + for( unsigned idx_row = 0; idx_row < 9; idx_row++ ) { + for( unsigned idx_col = 0; idx_col < 9; idx_col++ ) { + results( idx_row, idx_col ) += w * moment[idx_row] * moment[idx_col]; + } + } + } + + 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 ) { + // Orthogonality + if( std::fabs( results( idx_row, idx_col ) - 1.0 ) > 1e2 * std::numeric_limits::epsilon() ) orthogonality = false; + } + else { + // Normality + if( std::fabs( results( idx_row, idx_col ) ) > 1e2 * std::numeric_limits::epsilon() ) errorWithinBounds = false; + } + } + } + REQUIRE( errorWithinBounds ); + REQUIRE( orthogonality ); + } + + SECTION( "test parity - carthesian coordinates" ) { + + Vector moment1 = testBase.ComputeSphericalBasis( 0, 0 ); + Vector moment2 = testBase.ComputeSphericalBasis( 0, 0 ); + + // Parity in carthesian coordinates + QGaussLegendreTensorized quad( config ); + + 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]; + z = quad.GetPoints()[idx_quad][2]; + moment1 = testBase.ComputeSphericalBasis( x, y, z ); + moment2 = testBase.ComputeSphericalBasis( -x, -y, -z ); + + unsigned idx_sys; + double result = 0.; + + for( int l_idx = 0; l_idx <= int( maxMomentDegree ); l_idx++ ) { + for( int k_idx = -l_idx; k_idx <= l_idx; k_idx++ ) { + idx_sys = testBase.GetGlobalIndexBasis( l_idx, k_idx ); + + if( l_idx % 2 == 0 ) + result = moment2[idx_sys] - moment1[idx_sys]; + else + result = moment2[idx_sys] + moment1[idx_sys]; + + if( std::fabs( result ) > 1e2 * std::numeric_limits::epsilon() ) errorWithinBounds = false; + } + } + } + REQUIRE( errorWithinBounds ); + } + + SECTION( "test parity - polar coordinates" ) { + + Vector moment1 = testBase.ComputeSphericalBasis( 0, 0 ); + Vector moment2 = testBase.ComputeSphericalBasis( 0, 0 ); + + unsigned idx_sys; + 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 ); + moment1 = testBase.ComputeSphericalBasis( -my, M_PI + phi ); + + for( int l_idx = 0; l_idx <= int( maxMomentDegree ); l_idx++ ) { + for( int k_idx = -l_idx; k_idx <= l_idx; k_idx++ ) { + idx_sys = testBase.GetGlobalIndexBasis( l_idx, k_idx ); + + if( l_idx % 2 == 0 ) + result = moment2[idx_sys] - moment1[idx_sys]; + else + result = moment2[idx_sys] + moment1[idx_sys]; + + if( std::fabs( result ) > 1e2 * std::numeric_limits::epsilon() ) errorWithinBounds = false; + } + } + } + } + REQUIRE( errorWithinBounds ); + } +} + +double Omega_xBase( double my, double phi ) { return sqrt( 1 - my * my ) * sin( phi ); } +double Omega_yBase( double my, double phi ) { return sqrt( 1 - my * my ) * cos( phi ); } +double Omega_zBase( double my ) { return my; } + +double SphericalMonomial_0( double /* my */, double /* phi */ ) { return 1; } +double SphericalMonomial_1( double my, double /*phi*/ ) { return Omega_zBase( my ); } // omega_z +double SphericalMonomial_2( double my, double phi ) { return Omega_yBase( my, phi ); } // omega_y +double SphericalMonomial_3( double my, double phi ) { return Omega_xBase( my, phi ); } // omega_x +double SphericalMonomial_4( double my, double /*phi*/ ) { return Omega_zBase( my ) * Omega_zBase( my ); } // omega_z^2 +double SphericalMonomial_5( double my, double phi ) { return Omega_yBase( my, phi ) * Omega_zBase( my ); } // omega_y*omega_z +double SphericalMonomial_6( double my, double phi ) { return Omega_yBase( my, phi ) * Omega_yBase( my, phi ); } // omega_y^2 +double SphericalMonomial_7( double my, double phi ) { return Omega_xBase( my, phi ) * Omega_zBase( my ); } // omega_x*omega_z +double SphericalMonomial_8( double my, double phi ) { return Omega_xBase( my, phi ) * Omega_yBase( my, phi ); } // omega_x*omega_y +double SphericalMonomial_9( double my, double phi ) { return Omega_xBase( my, phi ) * Omega_xBase( my, phi ); } // omega_x^2 + +double SphericalMonomial_10( double my, double /*phi*/ ) { return Omega_zBase( my ) * Omega_zBase( my ) * Omega_zBase( my ); } // omega_z^3 +double SphericalMonomial_11( double my, double /*phi*/ ) { + return Omega_zBase( my ) * Omega_zBase( my ) * Omega_zBase( my ) * Omega_zBase( my ); +} // omega_z^4 + +TEST_CASE( "test spherical monomial basis", "[spherical_monomials]" ) { + unsigned maxMomentDegree = 2; //==> 6+3+1 basis functions + SphericalMonomials testBase( maxMomentDegree ); // Default constructor => _spatialDim = 3 + + SECTION( "Test Global Indexing Dim 3" ) { + + bool currDimRight = true; + if( testBase.GetCurrDegreeSize( 0 ) != 1 ) currDimRight = false; + if( testBase.GetCurrDegreeSize( 1 ) != 3 ) currDimRight = false; + if( testBase.GetCurrDegreeSize( 2 ) != 6 ) currDimRight = false; + + REQUIRE( currDimRight ); + + bool indexingRight = true; + if( testBase.GetGlobalIndexBasis( 0, 0 ) != 0 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 1, 0 ) != 1 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 1, 1 ) != 2 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 1, 2 ) != 3 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, 0 ) != 4 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, 1 ) != 5 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, 2 ) != 6 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, 3 ) != 7 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, 4 ) != 8 ) indexingRight = false; + if( testBase.GetGlobalIndexBasis( 2, 5 ) != 9 ) indexingRight = false; + + REQUIRE( indexingRight ); + } + + SECTION( "Test against analytical solution Dim 3" ) { + Vector moment; + std::vector validMoment( 10, true ); + for( double my = -1.0; my < 1.0; my += 0.1 ) { + + for( double phi = 0.0; phi < 2 * M_PI; phi += 0.1 ) { + moment = testBase.ComputeSphericalBasis( my, phi ); + + if( std::fabs( moment[0] - SphericalMonomial_0( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[0] = false; + if( std::fabs( moment[1] - SphericalMonomial_1( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[1] = false; + if( std::fabs( moment[2] - SphericalMonomial_2( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[2] = false; + if( std::fabs( moment[3] - SphericalMonomial_3( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[3] = false; + if( std::fabs( moment[4] - SphericalMonomial_4( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[4] = false; + if( std::fabs( moment[5] - SphericalMonomial_5( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[5] = false; + if( std::fabs( moment[6] - SphericalMonomial_6( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[6] = false; + if( std::fabs( moment[7] - SphericalMonomial_7( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[7] = false; + if( std::fabs( moment[8] - SphericalMonomial_8( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[8] = false; + if( std::fabs( moment[9] - SphericalMonomial_9( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[8] = false; + } + } + REQUIRE( std::all_of( validMoment.begin(), validMoment.end(), []( bool v ) { return v; } ) ); + } + + SphericalMonomials testBase2D( maxMomentDegree, 2 ); + + SECTION( "Test Global Indexing Dim 2" ) { + + bool currDimRight = true; + if( testBase2D.GetCurrDegreeSize( 0 ) != 1 ) currDimRight = false; + if( testBase2D.GetCurrDegreeSize( 1 ) != 2 ) currDimRight = false; + if( testBase2D.GetCurrDegreeSize( 2 ) != 3 ) currDimRight = false; + + REQUIRE( currDimRight ); + + bool indexingRight = true; + if( testBase2D.GetGlobalIndexBasis( 0, 0 ) != 0 ) indexingRight = false; + if( testBase2D.GetGlobalIndexBasis( 1, 0 ) != 1 ) indexingRight = false; + if( testBase2D.GetGlobalIndexBasis( 1, 1 ) != 2 ) indexingRight = false; + if( testBase2D.GetGlobalIndexBasis( 2, 0 ) != 3 ) indexingRight = false; + if( testBase2D.GetGlobalIndexBasis( 2, 1 ) != 4 ) indexingRight = false; + if( testBase2D.GetGlobalIndexBasis( 2, 2 ) != 5 ) indexingRight = false; + + REQUIRE( indexingRight ); + } + + SECTION( "Test against analytical solution Dim 2" ) { + Vector moment; + std::vector validMoment( 6, true ); + for( double my = -1.0; my < 1.0; my += 0.1 ) { + + for( double phi = 0.0; phi < 2 * M_PI; phi += 0.1 ) { + moment = testBase2D.ComputeSphericalBasis( my, phi ); + + if( std::fabs( moment[0] - SphericalMonomial_0( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[0] = false; + if( std::fabs( moment[1] - SphericalMonomial_2( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[1] = false; + if( std::fabs( moment[2] - SphericalMonomial_3( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[2] = false; + if( std::fabs( moment[3] - SphericalMonomial_6( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[3] = false; + if( std::fabs( moment[4] - SphericalMonomial_8( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[4] = false; + if( std::fabs( moment[5] - SphericalMonomial_9( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[5] = false; + } + } + REQUIRE( std::all_of( validMoment.begin(), validMoment.end(), []( bool v ) { return v; } ) ); + } + + SphericalMonomials testBase1D( maxMomentDegree, 1 ); + + SECTION( "Test Global Indexing Dim 1" ) { + + bool currDimRight = true; + if( testBase1D.GetCurrDegreeSize( 0 ) != 1 ) currDimRight = false; + if( testBase1D.GetCurrDegreeSize( 1 ) != 1 ) currDimRight = false; + if( testBase1D.GetCurrDegreeSize( 2 ) != 1 ) currDimRight = false; + + REQUIRE( currDimRight ); + + bool indexingRight = true; + if( testBase1D.GetGlobalIndexBasis( 0, 0 ) != 0 ) indexingRight = false; + if( testBase1D.GetGlobalIndexBasis( 1, 0 ) != 1 ) indexingRight = false; + if( testBase1D.GetGlobalIndexBasis( 2, 0 ) != 2 ) indexingRight = false; + + REQUIRE( indexingRight ); + } + + SECTION( "Test against analytical solution Dim 1" ) { + Vector moment; + std::vector validMoment( 3, true ); + for( double my = -1.0; my < 1.0; my += 0.1 ) { + + for( double phi = 0.0; phi < 2 * M_PI; phi += 0.1 ) { + moment = testBase1D.ComputeSphericalBasis( my, phi ); + + if( std::fabs( moment[0] - SphericalMonomial_0( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[0] = false; + if( std::fabs( moment[1] - SphericalMonomial_1( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[1] = false; + if( std::fabs( moment[2] - SphericalMonomial_4( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[2] = false; + } + } + + REQUIRE( std::all_of( validMoment.begin(), validMoment.end(), []( bool v ) { return v; } ) ); + } + + SphericalMonomials testBase1D_M4( 4, 1 ); + SECTION( "Test against analytical solution Dim 1 M4" ) { + Vector moment; + std::vector validMoment( 3, true ); + for( double my = -1.0; my < 1.0; my += 0.1 ) { + + for( double phi = 0.0; phi < 2 * M_PI; phi += 0.1 ) { + moment = testBase1D_M4.ComputeSphericalBasis( my, phi ); + + if( std::fabs( moment[0] - SphericalMonomial_0( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[0] = false; + if( std::fabs( moment[1] - SphericalMonomial_1( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[1] = false; + if( std::fabs( moment[2] - SphericalMonomial_4( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[2] = false; + if( std::fabs( moment[3] - SphericalMonomial_10( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[3] = false; + if( std::fabs( moment[4] - SphericalMonomial_11( my, phi ) ) > 1e2 * std::numeric_limits::epsilon() ) validMoment[4] = false; + } + } + + REQUIRE( std::all_of( validMoment.begin(), validMoment.end(), []( bool v ) { return v; } ) ); + } +} diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index cff5808d07ea3c07af8adf2cb0b43fdf9220306d..bef0cf3affc58c9c9d36aee31d3784fb837e56a4 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -482,19 +482,19 @@ NUM_PROC_THREADS = 1 # normally produced when WARNINGS is set to YES. # The default value is: NO. -EXTRACT_ALL = NO +EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = YES # If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual # methods of a class will be included in the documentation. # The default value is: NO. -EXTRACT_PRIV_VIRTUAL = NO +EXTRACT_PRIV_VIRTUAL = YES # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. @@ -1125,7 +1125,7 @@ IGNORE_PREFIX = # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. -GENERATE_HTML = YES +GENERATE_HTML = NO # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of diff --git a/doc/authors.rst b/doc/authors.rst index c74a7e5191e0de891e31f726ef8aca030540a668..990d9b91bf0d2acb5f2248c90071db7573ae6eba 100644 --- a/doc/authors.rst +++ b/doc/authors.rst @@ -7,15 +7,15 @@ Authors KiT-RT Software ***************** -+--------------------+------------------------+ -|Main contributors | - Jannick Wolters | -| | - Jonas Kusch | -| | - Steffen Schotthöfer | -| | - Tianbai Xiao | -| | - Pia Stammer | -+--------------------+------------------------+ -|Other contributors | | -+--------------------+------------------------+ ++--------------------+----------------------------------------+ +|Main contributors | - Jannick Wolters | +| | - Jonas Kusch | +| | - Steffen Schotthöfer | +| | - Tianbai Xiao (tianbai.xiao@kit.edu) | +| | - Pia Stammer | ++--------------------+----------------------------------------+ +|Other contributors | | ++--------------------+----------------------------------------+ ********************* KiT-RT Dokumentation diff --git a/doc/common/config.rst b/doc/common/config.rst index e0a517d15240d7c731944894d2d6ff0ae2c43e72..0697106890c798554a61e2517a30f5ab7a5f4c05 100644 --- a/doc/common/config.rst +++ b/doc/common/config.rst @@ -3,3 +3,5 @@ Config .. doxygenclass:: Config :members: + :protected-members: + :private-members: diff --git a/doc/common/mesh.rst b/doc/common/mesh.rst index 5a017409b33e2d61fe5d49408c78515fc7c5f2f1..81cbdd80503b09f5f1bf344380b78fa03b3b1c25 100644 --- a/doc/common/mesh.rst +++ b/doc/common/mesh.rst @@ -3,3 +3,6 @@ Mesh .. doxygenclass:: Mesh :members: + :protected-members: + :private-members: + diff --git a/doc/entropies/entropybase.rst b/doc/entropies/entropybase.rst index 5bf20b0675ffa04e4e5b4c3620b2c1033d93ddc4..9e1272492dfa510f616874b9fc807e9537432f50 100644 --- a/doc/entropies/entropybase.rst +++ b/doc/entropies/entropybase.rst @@ -3,3 +3,5 @@ EntropyBase .. doxygenclass:: EntropyBase :members: + :protected-members: + :private-members: diff --git a/doc/entropies/maxwellboltzmannentropy.rst b/doc/entropies/maxwellboltzmannentropy.rst index afe7eddc7f14d7f6aa3a0fbb7d16dcec7e0446d0..499442e97a445fbe2a16591ef3726d8a052cdec7 100644 --- a/doc/entropies/maxwellboltzmannentropy.rst +++ b/doc/entropies/maxwellboltzmannentropy.rst @@ -3,3 +3,5 @@ MaxwellBoltzmannEntropy .. doxygenclass:: MaxwellBoltzmannEntropy :members: + :protected-members: + :private-members: diff --git a/doc/entropies/quadraticentropy.rst b/doc/entropies/quadraticentropy.rst index 643efaf420a3d276f98768ba623ebdee2dc90509..1224c4427802c45d5b755c16c7eb1aafca5e7a27 100644 --- a/doc/entropies/quadraticentropy.rst +++ b/doc/entropies/quadraticentropy.rst @@ -3,3 +3,5 @@ QuadraticEntropy .. doxygenclass:: QuadraticEntropy :members: + :protected-members: + :private-members: diff --git a/doc/fluxes/laxfriedrichsflux.rst b/doc/fluxes/laxfriedrichsflux.rst index 51373deda1674e7a6f6ca7e50fc759cb2651f002..fba378965669a2d21bfd083d714b250acd4b72ef 100644 --- a/doc/fluxes/laxfriedrichsflux.rst +++ b/doc/fluxes/laxfriedrichsflux.rst @@ -3,3 +3,5 @@ LaxFriedrichsFlux .. doxygenclass:: LaxFriedrichsFlux :members: + :protected-members: + :private-members: diff --git a/doc/fluxes/numericalflux.rst b/doc/fluxes/numericalflux.rst index 5cbf947f86005d71d8324790c9a6d9cda95a865d..b765bc1c2dd23fe71efabfa89b23cd7e3f7d959e 100644 --- a/doc/fluxes/numericalflux.rst +++ b/doc/fluxes/numericalflux.rst @@ -3,3 +3,5 @@ NumericalFlux .. doxygenclass:: NumericalFlux :members: + :protected-members: + :private-members: diff --git a/doc/fluxes/upwindflux.rst b/doc/fluxes/upwindflux.rst index 48d9d35abc207fa429659e400c7239f9a0c82479..b9d6f1edc8c6afd1a610e5d1f8e23611f400695c 100644 --- a/doc/fluxes/upwindflux.rst +++ b/doc/fluxes/upwindflux.rst @@ -3,3 +3,5 @@ UpwindFlux .. doxygenclass:: UpwindFlux :members: + :protected-members: + :private-members: diff --git a/doc/implement.rst b/doc/implement.rst new file mode 100644 index 0000000000000000000000000000000000000000..3fc58ee05858b1e2144aab9150d6f207ebbcbdb5 --- /dev/null +++ b/doc/implement.rst @@ -0,0 +1,38 @@ +.. _implementation: + +================ +Implementation +================ + +Finite volume method +------------------------ + +In the KiT-RT, we employ the finite volume method (FVM) to model and compute the particle evolutions. +It's a generic method for conservation laws. +Consider the following PDE, + +.. math:: + + \frac{\partial \mathbf{u}}{\partial t}+\nabla \cdot \mathbf{f}(\mathbf{u})=\mathbf{0} + +Here, :math:`\mathbf{u}` represents any vector of states and +:math:`\mathbf{f}` represents the corresponding flux tensor. +To solve the equation numerically, we can sub-divide the spatial domain into finite cells. +For a particular cell :math:`i`, we take the volume integral over the total volume of the cell, which gives, + +.. math:: + + \int_{v_{i}} \frac{\partial \mathbf{u}}{\partial t} d v+\int_{v_{i}} \nabla \cdot \mathbf{f}(\mathbf{u}) d v=\mathbf{0}. + +On integrating the first term to get the volume average and applying the divergence theorem to the second, this yields + +.. math:: + + v_{i} \frac{d \overline{\mathbf{u}}_{i}}{d t}+\oint_{S_{i}} \mathbf{f}(\mathbf{u}) \cdot \mathbf{n} d S=\mathbf{0}, + +where :math:`S_i` represents the total surface area of the cell and :math:`\mathbf n` is a unit vector normal to the surface and pointing outward. +The equivalent formulation results + +.. math:: + + \frac{d \overline{\mathbf{u}}_{i}}{d t}+\frac{1}{v_{i}} \oint_{S_{i}} \mathbf{f}(\mathbf{u}) \cdot \mathbf{n} d S=\mathbf{0}. \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst index df99a890929213e49c611df3b8514aa5ae3e34a0..6cf4303efc970858e306f124fd052c9a4d608774 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,20 +1,55 @@ =========================================================== -KiT-RT - The kinetic transport solver for radiation therapy +KiT-RT: A kinetic transport solver for radiation therapy =========================================================== -The KiT-RT framework is a powerful open source platform for radiation transport. Its main focus is on radiotherapy planning in cancer treatment. To allow problem-specific method selection, the framework provides different deterministic solver types. This not only facilitates treatment planning, but also provides tools to investigate various research questions in the field of radiative transfer. This goal is supported by an easily extensible code structure that allows straightforward implementation of additional methods and techniques. +The KiT-RT framework is an open source project for radiation transport written in C++ programming language. +It is interested in the evolution of many-particle systems, e.g. photons, neutrons, electrons, etc. +Based on the finite volume method (FVM), it provides an efficient tool to solve the Boltzmann and related equations in multiple dimensions. +Special attention has been paid to the application of radiation therapy and treatment planning. +The framework provides rich deterministic solver types for different domain-specific problems. +A list of current supported models and equations is as follows. -The software is being developed by members of the group `CSMM `_ at the Karlsruhe Institute of Technology (KIT). For more information, please contact any of our authors (link to authors page). - --------- -Contents --------- +- linear Boltzmann (:math:`S_N`) equation +- spherical harmonics (:math:`P_N`) moment equations +- entropy-closure (:math:`M_N`) moment equations +- continuous slowing down equation + +The source code is publicly available on `Github `_. + +Design philosophy +------------------------ +The code hierarchy is designed as intuitive and neat as possible. +It's dedicated to providing a friendly interface for educational usage in kinetic theory and rich functionality for scientific research. +Benefiting from the brilliant expressiveness and low-overhead abstraction provided by the C++ programming language, we implement the easily extensible code structure, +which allow the users to focus on physics or easily extend the codes with their own methods. + + +What is new? +------------------------ +Finite volume method is a proven approach for simulating conservation laws. +Compared with the existing open-source softwares, e.g. OpenFOAM, SU2 and Clawpack, Kit-RT holds the novelty through the following points: + +- Comprehensive support for kinetic theory and phase-space equations +- Special focus on radiation therapy +- Lightweight design to ensure the flexibility for secondary development + + +How to get help? +------------------------ +The software is being developed by members of the group `CSMM `_ at the Karlsruhe Institute of Technology (KIT). +If you are interested in using KiT-RT or are trying to figure out how to use it, please feel free to get in touch with `us `_. +Do open an issue or pull request if you have questions, suggestions or solutions. + + +Table of contents +------------------------ .. toctree:: :maxdepth: 1 installation physics + implement configFiles cpp_doc developer_guide diff --git a/doc/installation.rst b/doc/installation.rst index 2a890cb6b5707a58e6560f8c795cac3342d18200..29ca464681f7d5047a51943d8181a2a54ee69902 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -57,9 +57,6 @@ The resulting executable will automatically be placed in the `code/bin` folder. Run ********** -Local -=========== - Execute the compiled binary from the `bin` folder and hand over a valid *TOML*-styled config file. Example from inside the `code` directory: @@ -75,56 +72,6 @@ OMP_NUM_THREADS=N mpirun -np J ./KiT-RT ../input/example.cfg with `N` equal to the number of shared memory threads and `J` equal to the number of distrubuted memory threads. -BwUniCluster -============== - -As VTK is not available on the bwUniCluster, it needs to be installed first. This just needs to be done once. Example: - -.. code-block:: bash - - module load devel/cmake/3.16 - module load compiler/gnu/9.2 - wget --no-check-certificate --quiet https://www.vtk.org/files/release/8.2/VTK-8.2.0.tar.gz - tar xzf VTK-8.2.0.tar.gz - mkdir VTK-build - cd VTK-build - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_DOCUMENTATION=OFF -DBUILD_TESTING=OFF - - DCMAKE_INSTALL_PREFIX=~/VTK-install ../VTK-8.2.0 - make -j - make install - cd - - rm -r VTK-8.2.0 VTK-build - - -Example for build and run on bwUniCluster: -Get the code - -.. code-block:: bash - - git clone https://git.scc.kit.edu/rtsn/rtsn.git KiT-RT - cd KiT-RT/ - git submodule init - git submodule update - -Append ``HINTS VTK_INSTALL_DIR` to the ``find_package( VTK ... )`` line in the CMakeLists.txt. E.g.: - -.. code-block:: bash - - find_package( VTK REQUIRED COMPONENTS vtkIOGeometry vtkFiltersCore HINTS ~/VTK-install ) - - -Compile it - -.. code-block:: bash - - module load devel/cmake/3.16 - module load compiler/gnu/9.2 - module load mpi/openmpi/4.0 - cd code/build/release/ - cmake -DCMAKE_BUILD_TYPE=Release ../../ - make -j - - --------------------------------------------------------------- Tests @@ -138,7 +85,3 @@ After compiling the framework as described above just run: The ``unit_tests`` executable will also be placed in in the build folder. - - - - diff --git a/doc/kernels/isotropic.rst b/doc/kernels/isotropic.rst index fa77e613eaf7b979d860036a98aba8eac64971ab..d1ababd36295b0d8ea595e5f13df48189e0f2d96 100644 --- a/doc/kernels/isotropic.rst +++ b/doc/kernels/isotropic.rst @@ -3,3 +3,5 @@ Isotropic .. doxygenclass:: Isotropic :members: + :protected-members: + :private-members: diff --git a/doc/kernels/isotropic1D.rst b/doc/kernels/isotropic1D.rst index 5ab7cf1e337a8fb99bb4b217b416358e6548f106..d113bde38ef220e898b7ea2a4f2fa24765bd7cd4 100644 --- a/doc/kernels/isotropic1D.rst +++ b/doc/kernels/isotropic1D.rst @@ -3,3 +3,5 @@ Isotropic1D .. doxygenclass:: Isotropic1D :members: + :protected-members: + :private-members: diff --git a/doc/kernels/scatteringkernel.rst b/doc/kernels/scatteringkernel.rst index 50037ed83ec734da7e40d216defb978f6f3125ae..2fb1ad08c54632b36b010e36a27abbef7507ac29 100644 --- a/doc/kernels/scatteringkernel.rst +++ b/doc/kernels/scatteringkernel.rst @@ -3,3 +3,5 @@ ScatteringKernel .. doxygenclass:: ScatteringKernel :members: + :protected-members: + :private-members: diff --git a/doc/optimizers/mloptimizer.rst b/doc/optimizers/mloptimizer.rst index b6e7e82823527736e5f4490c915dfeb11e18d263..f3ce06ddc6c56ba9a16f96a6e64b4d4bc29f7e15 100644 --- a/doc/optimizers/mloptimizer.rst +++ b/doc/optimizers/mloptimizer.rst @@ -3,3 +3,5 @@ MLOptimizer .. doxygenclass:: MLOptimizer :members: + :protected-members: + :private-members: diff --git a/doc/optimizers/newtonoptimizer.rst b/doc/optimizers/newtonoptimizer.rst index 6ea3e8f46e586892dff1726471d798d7832d6974..d639d53b3cdc7a05ecd485c917b7b4cdc3ef2dd6 100644 --- a/doc/optimizers/newtonoptimizer.rst +++ b/doc/optimizers/newtonoptimizer.rst @@ -3,3 +3,5 @@ NewtonOptimizer .. doxygenclass:: NewtonOptimizer :members: + :protected-members: + :private-members: diff --git a/doc/optimizers/optimizerbase.rst b/doc/optimizers/optimizerbase.rst index 83e902d9605fca4a421a8005d9a99588080fc0cd..9f648fc1bf746ae8497bf0b47c564e47ee69332d 100644 --- a/doc/optimizers/optimizerbase.rst +++ b/doc/optimizers/optimizerbase.rst @@ -3,3 +3,5 @@ OptimizerBase .. doxygenclass:: OptimizerBase :members: + :protected-members: + :private-members: diff --git a/doc/physics.rst b/doc/physics.rst index 64668d983586adca543ca7816f346062216d45e7..c8081c398155f2e1f3eba19d4019657a8b696034 100644 --- a/doc/physics.rst +++ b/doc/physics.rst @@ -1,81 +1,330 @@ ================ -Kinetic Theory +Theory ================ -The kinetic theory is dedicated to describe the dynamical behavior of a many-particle system through ensemble averaging. -Particles, e.g. molecules, photons, neutrons, electrons and plasmas, travel along the trajectories and undergo occasional collisions that change their directions and energies. -Such dynamics can be formulated via operator splitting approach in the Boltzmann equation, i.e. +The Boltzmann equation +---------------------- + +The particle transport phenomena enjoy rich academic research value and application prospects. +A many-particle system can exhibit different behaviors at characteristic different scales. +Down to the finest scale of a many-particle system, the Newton’s second law depicts particle motions via + +.. math:: + + F = m a, + +which leads + +.. math:: + + \frac{d x}{dt} = v, \ \frac{d v}{dt} = \frac{F}{m}. + +An intuitive numerical solution algorithm is to get the numerous particles on board and track the trajectories of them. +A typical example is the molecular dynamics (MD) method. +This is not going to be efficient since there are more than :math:`2\times 10^{25}` molecules per cubic meter in normal atmosphere, +and things get extremely complicated if the N-body interactions are counted all the time. + +Simplifications can be conducted to accelerate the numerical computation. +As an example, the Monte Carlo method employs certain particle models and conduct the interactions in a stochastic manner. +It significantly reduces the computational cost, while the trade-off is the artificial fluctuations. +Many realizations must be simulated successively to average the solutions and reduce the errors. + +An alternative strategy can be made from ensemble averaging, where the +coarse-grained modeling is used to provide a bottom-up view. +At the mean free path and collision time scale of particles. Such dynamics can be described with kinetic theory. +The Boltzmann equation can be formulated via an operator splitting approach, i.e. + +.. math:: + + \partial_{t} f(v)+v \cdot \nabla_{x} f(v)=\int_{\mathcal R^3} \int_{\mathcal S^2} k\left(v, v^{\prime}\right) \left(f\left(v^{\prime}\right)f\left(v_*^{\prime}\right)-f(v)f(v_*)\right) d\Omega d v_*, + +where the left and right hand sides model particle transports and collisions correspondingly. +The distribution function :math:`f` is the probability of finding a particle with certain location, and :math:`\{v, v_*\}` denotes the velocities of two classes of colliding particles. +The collision kernel :math:`k` models the strength of collisions at different velocities. + +Different collision models can be inserted into the Boltzmann equation. +In the KiT-RT solver, we are interested in the linear Boltzmann equation, where the particles don't interact with one another but scatter with the background material. +Therefore, the Boltzmann can be simplified as the linear equation with respect to :math:`f` + +.. math:: + + \partial_{t} f(v)+v \cdot \nabla_{x} f(v)=\int k\left(v, v^{\prime}\right)\left(f\left(v^{\prime}\right)-f(v)\right) d v^{\prime}-\tau f(v). + +For convenience, it is often reformulated with polar coordinates :math:`\{r, \phi, \theta \}`, + +.. math:: + + &\left[\frac{1}{v(E)} \partial_{t} +\Omega \cdot \nabla+\Sigma_t (t, r, E)\right] \psi(t, r, \Omega, E) \\ + &=\int_{0}^{\infty} d E^{\prime} \int_{\mathcal R^2} d \Omega^{\prime} \Sigma_{s}\left(r, \Omega^{\prime} \bullet \Omega, E^{\prime} \rightarrow E\right) \psi\left(t, r, \Omega^{\prime}, E^{\prime}\right) + Q(t, r, \Omega, E). + +The particle distribution :math:`\psi(r, \Omega, E, t)` here is often named as angular flux, :math:`\{\Sigma_s, \Sigma_t \}` are the scattering and total cross sections correspondingly, and :math:`Q` denotes a source term. + + +The spherical harmonics moment equations +---------------------------------------- + +The spherical harmonics (:math:`P_N`) method (cf. Brunner and Holloway [2005]) is one of several ways to solve the equation of radiative transfer. +It serves as an approximate method, i.e. the method of moments, to reduce the high dimensionality when the original kinetic equation of radiative transfer, which is formulated on a seven-dimensional domain. +Let us consider the radiative transfer equation in one-dimensional physical space with only one energy group, i.e. + +.. math:: + + \partial_{t} \psi(t, z, \mu) &+\mu \nabla_{z} \psi(t, z, \mu)+\Sigma_{t}(t, z) \psi(t, z, \mu) \\ + &=\int_{\mathcal S^{2}} \Sigma_{s}\left(t, z, \mu \cdot \Omega^{\prime}\right) \psi\left(t, z, \mu^{\prime}\right) d \mu^{\prime}+q(t, z, \mu), + +where :math:`\mu` is the projected angular variable on :math:`z` axis. + +To obtain the :math:`P_N` equations, we express the angular dependence of the distribution function in terms of a Fourier series, + +.. math:: + + \psi(t, z, \mu)=\sum_{\ell=0}^{\infty} \psi_{\ell}(t, z) \frac{2 \ell+1}{2} P_{\ell}(\mu), + +where :math:`P_{\ell}` are the Legendre polynomials. +These form an orthogonal basis of the space +of polynomials with respect to the standard scalar product on :math:`[−1, 1]`. +We can then obtain + +.. math:: + + \partial_{t} \psi_{\ell}+\partial_{z} \int_{=1}^{1} \mu P_{\ell} \psi \mathrm{d} \mu+\Sigma_{t \ell} \psi_{\ell}=q_{\ell}, + +where + +.. math:: + + \Sigma_{t \ell}=\Sigma_{t}-\Sigma_{s \ell}=\Sigma_{a}+\Sigma_{s 0}-\Sigma_{s \ell}, \quad \Sigma_{s \ell}=2 \pi \int_{-1}^{1} P_{\ell}(\mu) \Sigma_{s}(\mu) \mathrm{d} \mu. + +Two properties of the spherical harmonics are crucial for our method. These appear here as properties of the Legendre polynomials. First, we observe that, by this +procedure, we have diagonalized the scattering operator on the right-hand side (the +Legendre polynomials are the eigenfunctions of scattering operator). +Second, a general property of orthogonal polynomials is that they satisfy a recursion relation. In +particular, the Legendre polynomials satisfy + +.. math:: + + \mu P_{\ell}(\mu)=\frac{\ell}{2 \ell+1} P_{\ell-1}(\mu)+\frac{\ell+1}{2 \ell+1} P_{\ell+1}(\mu). + +Using this fact and truncating the expansion at :math:`\ell = N`, we arrive at the slab-geometry +:math:`P_N` equations, + +.. math:: + + \partial_{t} \psi_{\ell}+\partial_{z}\left(\frac{\ell+1}{2 \ell+1} \psi_{\ell+1}+\frac{\ell}{2 \ell+1} \psi_{\ell-1}\right)+\Sigma_{t \ell} \psi_{\ell}=q_{\ell}. + +The above method can be extended to multi-dimensional case with the help of spherical harmonics, which are defined as .. math:: - :label: boltzmann - \frac{\partial \psi}{\partial t}+v \cdot \nabla_x \psi = Q(\psi) + Y_{\ell}^{m}(\mu, \phi)=(-1)^{m} \sqrt{\frac{2 \ell+1}{4 \pi} \frac{(\ell-m) !}{(\ell+m) !}} e^{i m \phi} P_{\ell}^{m}(\mu), + +where :math:`\ell \leq 0` and :math:`\ell \leq m \leq -\ell`. + -where :math:`\psi` is the one-particle probability distribution function, :math:`v` is velocity and :math:`Q(\psi)` is the scattering term. -In the Kit-RT solver, we consider the liner Boltzmann equation +The entropy closure moment equations +------------------------------------ + +Another method of moments comes from the minimal principle of a convex entropy to close the moment system. +Derivation of such moment system begins with the choice of a vector-valued function +:math:`m: \mathbb{S}^{2} \rightarrow \mathbb{R}^{n}, \Omega \mapsto\left[m_{0}(\Omega), \ldots, m_{n-1}(\Omega)\right]^{T}`, +whose n components are linearly independent functions of :math:`\Omega`. +Evolution equations for the moments u(x, t) := +hmψ(x, ·, t)i are found by multiplying the transport equation by m and integrating +over all angles to give .. math:: - :label: linearbz - \partial_{t} f(v)+v \cdot \nabla_{x} f(v)=\sigma \int k\left(v, v^{\prime}\right)\left(f\left(v^{\prime}\right)-f(v)\right) d v^{\prime}-\tau f(v) + \frac{1}{v} \partial_{t} u+\nabla_{x} \cdot\langle\Omega m \psi\rangle=\langle m \mathcal{C}(\psi)\rangle. -where the particles don't interact with one another but scatter with the background material. -For convenience, we reformulate the particle velocity into polar coordinates. +The system above is not closed; a recipe, or closure, must be prescribed to express +unknown quantities in terms of the given moments. Often this is done via an +approximation for :math:`\psi` that depends on :math:`u`, -The physical world shows a diverse set of behaviors on different -characteristic scales. Consider the molecular motion of gases as an -example. Down to the finest scale of a many-particle system, the -Newton’s second law depicts particle motions via +.. math:: + + \psi(x, \Omega, t) \simeq \mathcal{E}(u(x, t))(\Omega). + +A general strategy for prescribing a closure is to +use the solution of a constrained optimization problem .. math:: + :label: closure - \mathbf{F} = m \mathbf{a} + \min_{g \in \operatorname{Dom}(\mathcal{H})} & \mathcal{H}(g) \\ + \quad \text { s.t. } & \langle\mathbf{m} g\rangle=\langle\mathbf{m} \psi\rangle=u, -As a first order system it reads +where :math:`\mathcal H(g)=\langle \eta(g) \rangle` and $\eta: \mathbb R \rightarrow \mathbb R$ +is a convex function that is related to +the entropy of the system. For photons, the physically relevant entropy comes from +Bose-Einstein statistics .. math:: - \frac{d \mathbf x}{dt} = \mathbf v, \ \frac{d \mathbf v}{dt} = \frac{\mathbf F}{m} + \eta(g)=\frac{2 k \nu^{2}}{v^{3}}\left[n_{g} \log \left(n_{g}\right)-\left(n_{g}+1\right) \log \left(n_{g}+1\right)\right], -An intuitive numerical algorithm is to get the numerous particles on -board and track the trajectories of them. A typical example is the -`Molecular Dynamics`_. This is not going to be efficient since there are -more than ``2e25`` molecules per cubic meter in normal atmosphere, and -things get even more complicated when you count on the N-body -interactions all the time. Some methods have been proposed to simplify -the computation. As an example, the `Direct simulation Monte Carlo`_ -employs certain molecular models and conduct the intermolecular -collisions in a stochastic manner. It significantly reduces the -computational cost, while the trade-off is the artificial fluctuations. -Many realizations must be simulated successively to average the -solutions and reduce the errors. +where :math:`n_g` is the occupation number associated with g, + +.. math:: -An alternative strategy is made from ensemble averaging, where the -coarse-grained modeling is used to provide a bottom-up view. At the mean -free path and collision time scale of molecules, particles travel freely -during most of time with mild intermolecular collisions. Such dynamics -can be described with an operator splitting approach, i.e. the kinetic -transport equation + n_{g}:=\frac{v^{2}}{2 h \nu^{3}} g. + +The solution of :eq:`closure` is expressed in terms of the Legendre dual + +.. math:: + + \eta_{*}(f)=-\frac{2 k \nu^{2}}{v^{3}} \log \left(1-\exp \left(-\frac{h \nu c}{k} f\right)\right). + +Let .. math:: - \frac{\partial f}{\partial t}+ \mathbf v \cdot \nabla_\mathbf x f + \mathbf a \cdot \nabla_\mathbf v f = Q(f) + \mathcal{B}(\boldsymbol{\alpha}):=\eta_{*}^{\prime}\left(\boldsymbol{\alpha}^{T} \mathbf{m}\right)=\frac{2 h \nu^{3}}{v^{2}} \frac{1}{\exp \left(-\frac{h \nu c}{k} \boldsymbol{\alpha}^{T} \mathbf{m}\right)-1}, -where the left and right hand sides model particle transports and -collisions correspondingly. Different collision models can be inserted -into such equation. If the particles only collide with a background -material one obtains linear Boltzmann collision operator +then the solution of :eq:`closure` is given by :math:`\mathcal B(\hat \alpha)`, where :math:`\hat \alpha= \hat \alpha(u)` solves the +dual problem .. math:: - Q(f)=\int_{\mathbb R^3} \mathcal B(\mathbf v_*, \mathbf v) \left[ f(\mathbf v_*)-f(\mathbf v)\right] d\mathbf v_* + \min _{\boldsymbol{\alpha} \in \mathbb{R}^{n}}\left\{\left\langle\eta_{*}\left(\boldsymbol{\alpha}^{T} \mathbf{m}\right)\right\rangle-\boldsymbol{\alpha}^{T} \mathbf{u}\right\}. + -where the collision kernel ``\mathcal B`` models the strength of -collisions at different velocities. If the interactions among particles -are considered, the collision operator becomes nonlinear. For example, -the two-body collision results in nonlinear Boltzmann equation +The continuous slowing down approximation +----------------------------------------- + +For the radiation therapy, the main goal is to compute the radiation dose accurately, which is defined as .. math:: - Q(f)=\int_{\mathbb R^3} \int_{\mathcal S^2} \mathcal B(\cos \beta, |\mathbf{v}-\mathbf{v_*}|) \left[ f(\mathbf v')f(\mathbf v_*')-f(\mathbf v)f(\mathbf v_*)\right] d\mathbf \Omega d\mathbf v_* + D(x)=\frac{1}{\rho(x)}\int_0^{\infty}\int_{\mathbb{S}^2}S(E,x)\psi(E,x,\Omega)\,d\Omega dE. + +where :math:`\rho(x)` is the background material density. +The angular flux :math:`\psi` can be approximated by a further approximation equation, i.e. the continuous slowing down (CSD) equation which reads +.. math:: + &-\partial_E\left(S(E,x)\psi(E,x,\Omega)\right)+\Omega\cdot\nabla_x\psi(E,x,\Omega)+\Sigma_t(E,x)\psi(E,x,\Omega) \\ + &= \int_{\mathbb{S}^2}\Sigma_s(E,x,\Omega\cdot\Omega')\psi(E,x,\Omega')d\Omega'. + +Here :math:`E\in\mathbb{R}_+` is energy, :math:`x\in D\subset \mathbb{R}^3` is the spatial domain and :math:`\Omega\in\mathbb{S}^2` is the direction of travel. +The stopping power :math:`S` is given by + +.. math:: + S(E,x) = \int_0^{\infty} E'\int_{-1}^1\Sigma(E,E',x,\mu)d\mu dE'. + +Let us assume there are no absorption effects, and thus the total cross section is given by + +.. math:: + + \Sigma_t(E,x) = \Sigma_{s,0}(E,x)=2\pi \int_{-1}^1\Sigma_s(E,x,\mu)d\mu. + +With a given :math:`\rho(x)`, we now make the following assumptions + +.. math:: + &S(E,x) = S^{H_2O}(E)\rho(x), \\ + &\Sigma_t(E,x) = \Sigma_t^{H_2O}(E)\rho(x), \\ + &\Sigma_s(E,x,\Omega\cdot\Omega') = \Sigma_s(E,\Omega\cdot\Omega')\rho(x). + +Leaving out the superscript :math:`H_2O`, the CSD equation can be simplified as + +.. math:: + :label: CSD2 + + &-\partial_E\left(\rho(x)S(E)\psi(E,x,\Omega)\right)+\Omega\cdot\nabla_x\psi(E,x,\Omega)+\rho(x)\Sigma_t(E)\psi(E,x,\Omega) \\ + &= \int_{\mathbb{S}^2}\rho(x)\Sigma_s(E,\Omega\cdot\Omega')\psi(E,x,\Omega')d\Omega'. + +Now, we bring this system in a form which resembles the standard Boltzmann equation. +Multiplying :eq:`CSD2` with :math:`S(E)` gives + +.. math:: + :label: CSD3 + + \begin{align} + -S(E)\partial_E\left(S(E)\rho(x)\psi(E,x,\Omega)\right)+&\Omega\cdot\nabla_x S(E)\psi(E,x,\Omega)+\Sigma_t(E)S(E)\rho(x)\psi(E,x,\Omega)\\ + &= \int_{\mathbb{S}^2}\Sigma_s(E,\Omega\cdot\Omega')S(E)\rho(x)\psi(E,x,\Omega')d\Omega'. + \end{align} + +Then, we substitute + +.. math:: + \widehat{\psi}(E,x,\Omega):= S(E)\rho(x)\psi(E,x,\Omega) + +into :eq:`CSD3`, which yields + +.. math:: + :label: CSD4 + + & -S(E)\partial_E\widehat{\psi}(E,x,\Omega)+\Omega\cdot\nabla_x \frac{\widehat{\psi}(E,x,\Omega)}{\rho}+\Sigma_t(E)\widehat{\psi}(E,x,\Omega) \\ + & = \int_{\mathbb{S}^2}\Sigma_s(E,\Omega\cdot\Omega')\widehat{\psi}(E,x,\Omega')d\Omega'. + +Now, to get rid of the stopping power in front of the energy derivative, we make use of the transformation + +.. math:: + :label: TildeE + + \widetilde{E}(E) = \int_0^E \frac{1}{S(E')}\,dE'. + +Now let us change to + +.. math:: + \widetilde{\widehat{\psi}}(\widetilde E,x,\Omega) := \widehat{\psi}(E(\widetilde E),x,\Omega) + +In this case, the energy derivative becomes + +.. math:: + \partial_{\widetilde{E}}\widetilde{\widehat{\psi}}(\widetilde E,x,\Omega) = \partial_{E}\widetilde{\widehat{\psi}}( E,x,\Omega)\partial_{\widetilde E }E(\widetilde E(\widetilde E) = \partial_{ E}\widetilde{\widehat{\psi}}(\widetilde E,x,\Omega){S(E(\widetilde E))}. + +And by rearranging the terms, we finally get + +.. math:: + \partial_{ E}\widetilde{\widehat{\psi}}(\widetilde E,x,\Omega) = \partial_{\widetilde{E}}\widetilde{\widehat{\psi}}(\widetilde E,x,\Omega)\frac{1}{S(E(\widetilde E))}, + +since :math:`S(E(\widetilde E))` is nonzero. +Therefore, substituting :math:`\widetilde E` in :eq:`CSD4` gives + +.. math:: + :label: CSD5 + + & -\partial_{\widetilde E}\widetilde{\widehat{\psi}}(\widetilde E,x,\Omega)+\Omega\cdot\nabla_x \frac{\widetilde{\widehat{\psi}}(\widetilde E,x,\Omega)}{\rho}+\widetilde\Sigma_t(\widetilde E)\widetilde{\widehat{\psi}}(\widetilde E,x,\Omega) \\ + & = \int_{\mathbb{S}^2}\widetilde\Sigma_s(\widetilde E,\Omega\cdot\Omega')\widetilde{\widehat{\psi}}(\widetilde E,x,\Omega')d\Omega'. + +Here, we define :math:`\widetilde\Sigma_{t}(\widetilde E):=\Sigma_t(E(\widetilde E))` and :math:`\widetilde\Sigma_{s}(\widetilde E,\Omega\cdot\Omega'):=\Sigma_s(E(\widetilde E),\Omega\cdot\Omega')`. Finally, to obtain a positive sign in front of the energy derivative, we transform to + +.. math:: + \bar{E}(\widetilde{E}) = \widetilde{E}_{\text{max}}-\widetilde{E}. + +Then, with :math:`\bar{\psi}(\bar{E},x,\Omega):=\widetilde{\widehat{\psi}}(\widetilde{E}(\bar{E}),x,\Omega)`, :math:`\bar\Sigma_{t}(\bar E):=\widetilde{\Sigma}_t(\widetilde{E}(\bar{E}))` as well as :math:`\bar\Sigma_{s}(\bar E,\Omega\cdot\Omega'):=\widetilde{\Sigma}_s(\widetilde{E}(\bar{E}),\Omega\cdot\Omega')` equation :eq:`CSD4` becomes + +.. math:: + :label: CSD6 + + \partial_{\bar{E}}\bar{\psi}(\bar{E},x,\Omega)+\Omega\cdot\nabla_x \frac{\bar{\psi}(\bar{E},x,\Omega)}{\rho}+\bar\Sigma_t(\bar E)\bar{\psi}(\bar{E},x,\Omega) = \int_{\mathbb{S}^2}\bar\Sigma_s(\bar{E},\Omega\cdot\Omega')\bar{\psi}(\bar{E},x,\Omega')d\Omega'. + +Dropping the bar notation and treating :math:`\bar E` as a pseudo-time :math:`t` gives a slightly modified version of the Boltzmann equation + +.. math:: + :label: CSDBoltzmann + + \partial_{t}\psi(t,x,\Omega)+&\Omega\cdot\nabla_x \frac{\psi(t,x,\Omega)}{\rho}+\Sigma_t(t)\psi(t,x,\Omega) = \int_{\mathbb{S}^2}\Sigma_s(t,\Omega\cdot\Omega')\psi(t,x,\Omega')d\Omega'\\ + &\psi(t=0,x,\Omega) = S(E_{\text{max}})\rho(x)\psi(E_{\text{max}},x,\Omega). + +We are interested in computing the dose, which (when again using the original energy :math:`E` and angular flux :math:`\psi`) reads + +.. math:: + D(x) = \int_0^{\infty} \int_{\mathbb{S}^2} S(E)\psi(E,x,\Omega)\,d\Omega dE = \int_0^{\infty} \int_{\mathbb{S}^2} \frac{1}{\rho(x)}\widehat\psi(E,x,\Omega)\,d\Omega dE. + +So let us check how we can compute the dose from our solution :math:`\bar \psi(\bar E,x,\Omega)`. For this, let us substitute + +.. math:: + + \bar E(E) = \tilde{E}(E_{max}) - \int_0^E \frac{1}{S(E')}dE'. + +We have + +.. math:: + + \frac{d\bar E(E)}{dE} = -\frac{1}{S(E)} + +which gives + +.. math:: + D(x) =& -\int_{\infty}^{0} \int_{\mathbb{S}^2} \frac{1}{\rho(x)}\bar \psi(\bar E,x,\Omega)\frac{1}{S(E(\bar E))}\,d\Omega d\bar E\\ + =& \int_{0}^{\infty} \frac{1}{\rho(x)S(E(\bar E))}\int_{\mathbb{S}^2} \bar \psi(\bar E,x,\Omega)\,d\Omega d\bar E. diff --git a/doc/problems/aircavity1d.rst b/doc/problems/aircavity1d.rst index 2e295be47af118d508b7cbff7ebbcd65acc710f0..dbd1a7c6be4b880a80c314614048bf6088e149bb 100644 --- a/doc/problems/aircavity1d.rst +++ b/doc/problems/aircavity1d.rst @@ -3,3 +3,5 @@ AirCavity1D .. doxygenclass:: AirCavity1D :members: + :protected-members: + :private-members: diff --git a/doc/problems/checkerboardpn.rst b/doc/problems/checkerboardpn.rst index d7a3535b95088743b185ebf6ed1609234e2f73bf..c70269932eb4510597c19fbcfd68ebbf9890a0e4 100644 --- a/doc/problems/checkerboardpn.rst +++ b/doc/problems/checkerboardpn.rst @@ -3,3 +3,5 @@ Checkerboard_PN .. doxygenclass:: Checkerboard_PN :members: + :protected-members: + :private-members: diff --git a/doc/problems/checkerboardsn.rst b/doc/problems/checkerboardsn.rst index dde91b46a051c2d336ef49eabd5c963dac318303..ef0141e617197aabb79ca71b1e1e5511d870c85f 100644 --- a/doc/problems/checkerboardsn.rst +++ b/doc/problems/checkerboardsn.rst @@ -3,3 +3,5 @@ Checkerboard_SN .. doxygenclass:: Checkerboard_SN :members: + :protected-members: + :private-members: diff --git a/doc/problems/electronrt.rst b/doc/problems/electronrt.rst index 1cdfc639927446db43ef267f3b3e9acae2417332..c6f514fa5784fd8f097674fda81c1a07e17ace57 100644 --- a/doc/problems/electronrt.rst +++ b/doc/problems/electronrt.rst @@ -3,3 +3,5 @@ ElectronRT .. doxygenclass:: ElectronRT :members: + :protected-members: + :private-members: diff --git a/doc/problems/icru.rst b/doc/problems/icru.rst index 1094a7a40f1af76a23de06ef26a7f7e047429311..7959a63cc17b53ca65248b91179c5428231d1bdd 100644 --- a/doc/problems/icru.rst +++ b/doc/problems/icru.rst @@ -3,3 +3,5 @@ ICRU .. doxygenclass:: ICRU :members: + :protected-members: + :private-members: diff --git a/doc/problems/linesource.rst b/doc/problems/linesource.rst index 0fbf744b5e4498387ea9bef17ccc0ebf4df6b65e..54ff448826f75dee49edf4482cfeb25d8eb6ae3c 100644 --- a/doc/problems/linesource.rst +++ b/doc/problems/linesource.rst @@ -3,3 +3,5 @@ LineSource .. doxygenclass:: LineSource :members: + :protected-members: + :private-members: diff --git a/doc/problems/linesourcepn.rst b/doc/problems/linesourcepn.rst index b1edbe6f7e3ca8a0107edd093d0766b0dd2a0c0b..ecd74a2c4575ef95ed928083eb6708948331bd81 100644 --- a/doc/problems/linesourcepn.rst +++ b/doc/problems/linesourcepn.rst @@ -3,3 +3,5 @@ LineSource_PN .. doxygenclass:: LineSource_PN :members: + :protected-members: + :private-members: diff --git a/doc/problems/linesourcesn.rst b/doc/problems/linesourcesn.rst index 31b35ac756f69a7aabe9d490c215810ec182ae69..d23c4a917cd47e4d88ef380f668ddc74a96b1f51 100644 --- a/doc/problems/linesourcesn.rst +++ b/doc/problems/linesourcesn.rst @@ -3,3 +3,5 @@ LineSource_SN .. doxygenclass:: LineSource_SN :members: + :protected-members: + :private-members: diff --git a/doc/problems/linesourcesnpseudo1d.rst b/doc/problems/linesourcesnpseudo1d.rst index e152d594835996d6351fbada7db9485a9b4b1f1a..f30a0c60d3b1aa04b75837b9ded136d56029c5c8 100644 --- a/doc/problems/linesourcesnpseudo1d.rst +++ b/doc/problems/linesourcesnpseudo1d.rst @@ -3,3 +3,5 @@ LineSource_SN_Pseudo1D .. doxygenclass:: LineSource_SN_Pseudo1D :members: + :protected-members: + :private-members: diff --git a/doc/problems/linesourcesnpseudo1dphysics.rst b/doc/problems/linesourcesnpseudo1dphysics.rst index 16a6ed795eb69d26ef2f72ddaeebdf4c22ade5d0..5a19bcf72c2bf7afe24e5fb81d9a568a03e478cf 100644 --- a/doc/problems/linesourcesnpseudo1dphysics.rst +++ b/doc/problems/linesourcesnpseudo1dphysics.rst @@ -3,3 +3,5 @@ LineSource_SN_Pseudo1D_Physics .. doxygenclass:: LineSource_SN_Pseudo1D_Physics :members: + :protected-members: + :private-members: diff --git a/doc/problems/musclebonelung.rst b/doc/problems/musclebonelung.rst index b824b1fe8f66cf02f2ee92edd233c27358c8c90d..1670a40e755a9a57af9a422af15a9ed2ec1fade0 100644 --- a/doc/problems/musclebonelung.rst +++ b/doc/problems/musclebonelung.rst @@ -3,3 +3,5 @@ MuscleBoneLung .. doxygenclass:: MuscleBoneLung :members: + :protected-members: + :private-members: diff --git a/doc/problems/phantom2d.rst b/doc/problems/phantom2d.rst index e98bfbdb52da2ef4da1a3a5a665fc558e7c7d8a7..d7711ded55f14088fa280c830f3e72cea221aaeb 100644 --- a/doc/problems/phantom2d.rst +++ b/doc/problems/phantom2d.rst @@ -1,5 +1,7 @@ Phantom2D -====== +========= .. doxygenclass:: Phantom2D :members: + :protected-members: + :private-members: diff --git a/doc/problems/problembase.rst b/doc/problems/problembase.rst index e99e68ab7751d9019efe14ec9c6491aaaa2d2d89..817e5be121ead20a773b790f4dca31854500e1e2 100644 --- a/doc/problems/problembase.rst +++ b/doc/problems/problembase.rst @@ -3,3 +3,5 @@ ProblemBase .. doxygenclass:: ProblemBase :members: + :protected-members: + :private-members: diff --git a/doc/problems/slabgeohg.rst b/doc/problems/slabgeohg.rst index ec36edbea7507a584f870f6a3423bab704fea2fb..efae7d9665bfd943e1c8896711590888350f989e 100644 --- a/doc/problems/slabgeohg.rst +++ b/doc/problems/slabgeohg.rst @@ -3,3 +3,5 @@ SlabGeoHG .. doxygenclass:: SlabGeoHG :members: + :protected-members: + :private-members: diff --git a/doc/problems/waterphantom.rst b/doc/problems/waterphantom.rst index 3084ff5b5b3f25d0de23007fca8867723fc608f0..b89fa5c09c0ae2f7bd82be51b499a6ebb4441329 100644 --- a/doc/problems/waterphantom.rst +++ b/doc/problems/waterphantom.rst @@ -3,3 +3,5 @@ WaterPhantom .. doxygenclass:: WaterPhantom :members: + :protected-members: + :private-members: diff --git a/doc/quadratures/qgausslegendre1D.rst b/doc/quadratures/qgausslegendre1D.rst index 384e4c650b4266fc98a44bb851d038fbfc98a5af..34858ccd0ec3fded41fb180c57bfbee6efd9f574 100644 --- a/doc/quadratures/qgausslegendre1D.rst +++ b/doc/quadratures/qgausslegendre1D.rst @@ -3,3 +3,5 @@ QGaussLegendre1D .. doxygenclass:: QGaussLegendre1D :members: + :protected-members: + :private-members: diff --git a/doc/quadratures/qgausslegendretensorized.rst b/doc/quadratures/qgausslegendretensorized.rst index 3998595e5e11df08c1d28966ad6c5fc07b36f256..8dd143255fb4467c16172f83e11fbce365c685cc 100644 --- a/doc/quadratures/qgausslegendretensorized.rst +++ b/doc/quadratures/qgausslegendretensorized.rst @@ -3,3 +3,5 @@ QGaussLegendreTensorized .. doxygenclass:: QGaussLegendreTensorized :members: + :protected-members: + :private-members: diff --git a/doc/quadratures/qldfesa.rst b/doc/quadratures/qldfesa.rst index eedea39a6003dbb99e311da834d945b81f41a308..8859bc2c0b79f160ad0de7ed5091f02a0e08c653 100644 --- a/doc/quadratures/qldfesa.rst +++ b/doc/quadratures/qldfesa.rst @@ -3,3 +3,5 @@ QLDFESA .. doxygenclass:: QLDFESA :members: + :protected-members: + :private-members: diff --git a/doc/quadratures/qlebedev.rst b/doc/quadratures/qlebedev.rst index 123e6b41099b685f7fd5ecef9a13f29a142a9b17..6e5b424d9c8e74da40cb96b9ec3f5c66cf226027 100644 --- a/doc/quadratures/qlebedev.rst +++ b/doc/quadratures/qlebedev.rst @@ -3,3 +3,5 @@ QLebedev .. doxygenclass:: QLebedev :members: + :protected-members: + :private-members: diff --git a/doc/quadratures/qlevelsymmetric.rst b/doc/quadratures/qlevelsymmetric.rst index ef6c46fccc90af19a774547e97c0c4f22522fa43..c6f7ddd8d40fc46bdb4853df8ced2915dc1d9ec4 100644 --- a/doc/quadratures/qlevelsymmetric.rst +++ b/doc/quadratures/qlevelsymmetric.rst @@ -3,3 +3,5 @@ QLevelSymmetric .. doxygenclass:: QLevelSymmetric :members: + :protected-members: + :private-members: diff --git a/doc/quadratures/qlookupquadrature.rst b/doc/quadratures/qlookupquadrature.rst index 1b430e965004970c3731e9b1e70d58f098f3e71d..55bb5a18b4c2a302f42d2d392e894756eaa03a4d 100644 --- a/doc/quadratures/qlookupquadrature.rst +++ b/doc/quadratures/qlookupquadrature.rst @@ -3,3 +3,5 @@ QLookupQuadrature .. doxygenclass:: QLookupQuadrature :members: + :protected-members: + :private-members: diff --git a/doc/quadratures/qmontecarlo.rst b/doc/quadratures/qmontecarlo.rst index 1252566112933d50039143db5ecbb0902e8a803b..2c448dc826615d27a0ff38f7a6369872edd1172d 100644 --- a/doc/quadratures/qmontecarlo.rst +++ b/doc/quadratures/qmontecarlo.rst @@ -3,3 +3,5 @@ QMonteCarlo .. doxygenclass:: QMonteCarlo :members: + :protected-members: + :private-members: diff --git a/doc/quadratures/qproduct.rst b/doc/quadratures/qproduct.rst index 039fffc328ad13e7a92b4e66ec1c8735aa96633f..c8ed8abffcff1cd5318cc2c197608904bb52c2fb 100644 --- a/doc/quadratures/qproduct.rst +++ b/doc/quadratures/qproduct.rst @@ -3,3 +3,5 @@ QProduct .. doxygenclass:: QProduct :members: + :protected-members: + :private-members: diff --git a/doc/quadratures/quadraturebase.rst b/doc/quadratures/quadraturebase.rst index cffd8f086b5aa67508b420df630d56435362452a..16710be10ef236ed8108a2f8b2d7831e05e6a5dd 100644 --- a/doc/quadratures/quadraturebase.rst +++ b/doc/quadratures/quadraturebase.rst @@ -3,3 +3,5 @@ QuadratureBase .. doxygenclass:: QuadratureBase :members: + :protected-members: + :private-members: diff --git a/doc/solvers/csdsnsolver.rst b/doc/solvers/csdsnsolver.rst index e8324bc9a7461dbaaa500917b40051c83d604c2a..a3483871db190a0456b85551d93c1beaba718c7c 100644 --- a/doc/solvers/csdsnsolver.rst +++ b/doc/solvers/csdsnsolver.rst @@ -3,3 +3,5 @@ CSDSNSolver .. doxygenclass:: CSDSNSolver :members: + :protected-members: + :private-members: diff --git a/doc/solvers/csdsnsolverfp.rst b/doc/solvers/csdsnsolverfp.rst index d29fa5240be145420700a9ef1c51d905c15f8ae2..5d88347b6eaf8f9b1ab571fb2ecb056fd6eba0e7 100644 --- a/doc/solvers/csdsnsolverfp.rst +++ b/doc/solvers/csdsnsolverfp.rst @@ -3,3 +3,5 @@ CSDSNSolverFP .. doxygenclass:: CSDSNSolverFP :members: + :protected-members: + :private-members: diff --git a/doc/solvers/csdsnsolvernotrafo.rst b/doc/solvers/csdsnsolvernotrafo.rst index e44332fe17c6f1e2681fddc12d4e9ee893030953..44597e843beb2a48b2a6b33854f634143cc46379 100644 --- a/doc/solvers/csdsnsolvernotrafo.rst +++ b/doc/solvers/csdsnsolvernotrafo.rst @@ -3,3 +3,5 @@ CSDSNSolverNoTrafo .. doxygenclass:: CSDSNSolverNoTrafo :members: + :protected-members: + :private-members: diff --git a/doc/solvers/csdsolvertrafofp.rst b/doc/solvers/csdsolvertrafofp.rst index ca8164307030f96822385fa28e67e7cbda2dfd36..fa88fb320ce7bdda66c29233a6470779aa59255e 100644 --- a/doc/solvers/csdsolvertrafofp.rst +++ b/doc/solvers/csdsolvertrafofp.rst @@ -3,3 +3,5 @@ CSDSolverTrafoFP .. doxygenclass:: CSDSolverTrafoFP :members: + :protected-members: + :private-members: diff --git a/doc/solvers/csdsolvertrafofp2d.rst b/doc/solvers/csdsolvertrafofp2d.rst index 4c2752c9be4a39294173b488753b784badd898bf..e9c013fc3f4da6a7e7d5ddaed0b9d9413030e087 100644 --- a/doc/solvers/csdsolvertrafofp2d.rst +++ b/doc/solvers/csdsolvertrafofp2d.rst @@ -3,3 +3,5 @@ CSDSolverTrafoFP2D .. doxygenclass:: CSDSolverTrafoFP2D :members: + :protected-members: + :private-members: diff --git a/doc/solvers/csdsolvertrafofpsh2d.rst b/doc/solvers/csdsolvertrafofpsh2d.rst index 4a7a30b55abe795cfbb9f2de4e6c907d2a01b488..cbaf4fbdcf97bf5a5d34df7052b954466e56e7fe 100644 --- a/doc/solvers/csdsolvertrafofpsh2d.rst +++ b/doc/solvers/csdsolvertrafofpsh2d.rst @@ -3,3 +3,5 @@ CSDSolverTrafoFPSH2D .. doxygenclass:: CSDSolverTrafoFPSH2D :members: + :protected-members: + :private-members: diff --git a/doc/solvers/index.rst b/doc/solvers/index.rst index 7cd552be625f30ba057c9aff1bc27a61955ee28e..76a094cc6a89428a1a8fd03fdf1ccaae658fb66c 100644 --- a/doc/solvers/index.rst +++ b/doc/solvers/index.rst @@ -4,7 +4,7 @@ Solvers .. toctree:: :maxdepth: 1 - solver + solverbase csdsnsolver csdsnsolverfp csdsnsolvernotrafo @@ -14,4 +14,3 @@ Solvers mnsolver pnsolver snsolver - snsolvermpi diff --git a/doc/solvers/mnsolver.rst b/doc/solvers/mnsolver.rst index 0260e2b2e04cc547a540316048a0d3ac959fab70..2ccbe0eacaa8fe0595f640f71243e05997a37348 100644 --- a/doc/solvers/mnsolver.rst +++ b/doc/solvers/mnsolver.rst @@ -3,3 +3,5 @@ MNSolver .. doxygenclass:: MNSolver :members: + :protected-members: + :private-members: diff --git a/doc/solvers/pnsolver.rst b/doc/solvers/pnsolver.rst index f52b587c0cac80f1131e06df529c1b8c381769f9..f64e42582890afd877b57537da3a5327de8067cc 100644 --- a/doc/solvers/pnsolver.rst +++ b/doc/solvers/pnsolver.rst @@ -3,3 +3,6 @@ PNSolver .. doxygenclass:: PNSolver :members: + :protected-members: + :private-members: + diff --git a/doc/solvers/snsolver.rst b/doc/solvers/snsolver.rst index 1c120eca0eeb87c88dd483f3db0dd0d31e1e8f5a..66772e9680433a8e8ec9eaba87e7753bb41fb085 100644 --- a/doc/solvers/snsolver.rst +++ b/doc/solvers/snsolver.rst @@ -3,3 +3,5 @@ SNSolver .. doxygenclass:: SNSolver :members: + :protected-members: + :private-members: diff --git a/doc/solvers/snsolvermpi.rst b/doc/solvers/snsolvermpi.rst deleted file mode 100644 index 176f519f422bd325c3b9c4d8a7eb86227c962abb..0000000000000000000000000000000000000000 --- a/doc/solvers/snsolvermpi.rst +++ /dev/null @@ -1,5 +0,0 @@ -SNSolverMPI -=========== - -.. doxygenclass:: SNSolverMPI - :members: diff --git a/doc/solvers/solver.rst b/doc/solvers/solver.rst deleted file mode 100644 index bdfef8c5baeb3b6fcbd482604be1413000597940..0000000000000000000000000000000000000000 --- a/doc/solvers/solver.rst +++ /dev/null @@ -1,5 +0,0 @@ -Solver -========== - -.. doxygenclass:: Solver - :members: diff --git a/doc/solvers/solverbase.rst b/doc/solvers/solverbase.rst new file mode 100644 index 0000000000000000000000000000000000000000..db2ff8ef85c9535a9b86f40196000d8d95846930 --- /dev/null +++ b/doc/solvers/solverbase.rst @@ -0,0 +1,7 @@ +SolverBase +========== + +.. doxygenclass:: SolverBase + :members: + :protected-members: + :private-members: diff --git a/doc/toolboxes/errormessages.rst b/doc/toolboxes/errormessages.rst index 9d05d5a511aa3c330b755b5e2c6f3b97459f4e79..8dbe40324a4dfbc51fcc3be9a3cf60d387c23c1d 100644 --- a/doc/toolboxes/errormessages.rst +++ b/doc/toolboxes/errormessages.rst @@ -3,3 +3,5 @@ ErrorMessages .. doxygenclass:: ErrorMessages :members: + :protected-members: + :private-members: diff --git a/doc/toolboxes/index.rst b/doc/toolboxes/index.rst index 48ee53827a660872d21b03814256f13258413387..ab666f1f58ae0fb815f8405c30163250733373c5 100644 --- a/doc/toolboxes/index.rst +++ b/doc/toolboxes/index.rst @@ -6,6 +6,5 @@ Toolboxes errormessages interpolation - physics reconstructor sphericalharmonics diff --git a/doc/toolboxes/interpolation.rst b/doc/toolboxes/interpolation.rst index 9877c13213db8d7375c75d5485559f234e26fe81..a03740a0a9e9a98de78e621efc5647a98138bafb 100644 --- a/doc/toolboxes/interpolation.rst +++ b/doc/toolboxes/interpolation.rst @@ -3,3 +3,5 @@ Interpolation .. doxygenclass:: Interpolation :members: + :protected-members: + :private-members: diff --git a/doc/toolboxes/physics.rst b/doc/toolboxes/physics.rst deleted file mode 100644 index ddb71163a1a21ddcdc454a65bb1a58de82617706..0000000000000000000000000000000000000000 --- a/doc/toolboxes/physics.rst +++ /dev/null @@ -1,5 +0,0 @@ -Physics -======= - -.. doxygenclass:: Physics - :members: diff --git a/doc/toolboxes/reconstructor.rst b/doc/toolboxes/reconstructor.rst index 69a5518f5e416edbc5a8b1cf1b9758ada65ea23e..7231c44f5ba1b5c7ee2fe6b077b9d30344cb1d95 100644 --- a/doc/toolboxes/reconstructor.rst +++ b/doc/toolboxes/reconstructor.rst @@ -3,3 +3,5 @@ Reconstructor .. doxygenclass:: Reconstructor :members: + :protected-members: + :private-members: diff --git a/doc/toolboxes/sphericalharmonics.rst b/doc/toolboxes/sphericalharmonics.rst index 071bcf917ea01d18b6981e2c956aeaae907fb239..92db111a3cc3ed7960cc2822868214acbbe1b086 100644 --- a/doc/toolboxes/sphericalharmonics.rst +++ b/doc/toolboxes/sphericalharmonics.rst @@ -3,3 +3,5 @@ SphericalHamonics .. doxygenclass:: SphericalHarmonics :members: + :protected-members: + :private-members: diff --git a/kitrt.png b/kitrt.png new file mode 100644 index 0000000000000000000000000000000000000000..676cec225e77e0ce8015a7986ee1b62db468a64d Binary files /dev/null and b/kitrt.png differ