Commit 6ad18a7c authored by jonas.kusch's avatar jonas.kusch
Browse files

Merge branch 'sprint1' of https://git.scc.kit.edu/rtsn/rtsn into sprint1

parents 4e3639ea eb85ae06
...@@ -103,6 +103,7 @@ enum SOLVER_NAME { ...@@ -103,6 +103,7 @@ enum SOLVER_NAME {
CSD_SN_FOKKERPLANCK_SOLVER, CSD_SN_FOKKERPLANCK_SOLVER,
CSD_SN_FOKKERPLANCK_TRAFO_SOLVER, CSD_SN_FOKKERPLANCK_TRAFO_SOLVER,
CSD_SN_FOKKERPLANCK_TRAFO_SOLVER_2D, CSD_SN_FOKKERPLANCK_TRAFO_SOLVER_2D,
CSD_SN_FOKKERPLANCK_TRAFO_SH_SOLVER_2D,
PN_SOLVER, PN_SOLVER,
MN_SOLVER MN_SOLVER
}; };
...@@ -113,6 +114,7 @@ inline std::map<std::string, SOLVER_NAME> Solver_Map{ { "SN_SOLVER", SN_SOLVER } ...@@ -113,6 +114,7 @@ inline std::map<std::string, SOLVER_NAME> Solver_Map{ { "SN_SOLVER", SN_SOLVER }
{ "CSD_SN_FOKKERPLANCK_SOLVER", CSD_SN_FOKKERPLANCK_SOLVER }, { "CSD_SN_FOKKERPLANCK_SOLVER", CSD_SN_FOKKERPLANCK_SOLVER },
{ "CSD_SN_FOKKERPLANCK_TRAFO_SOLVER", CSD_SN_FOKKERPLANCK_TRAFO_SOLVER }, { "CSD_SN_FOKKERPLANCK_TRAFO_SOLVER", CSD_SN_FOKKERPLANCK_TRAFO_SOLVER },
{ "CSD_SN_FOKKERPLANCK_TRAFO_SOLVER_2D", CSD_SN_FOKKERPLANCK_TRAFO_SOLVER_2D }, { "CSD_SN_FOKKERPLANCK_TRAFO_SOLVER_2D", CSD_SN_FOKKERPLANCK_TRAFO_SOLVER_2D },
{ "CSD_SN_FOKKERPLANCK_TRAFO_SH_SOLVER_2D", CSD_SN_FOKKERPLANCK_TRAFO_SH_SOLVER_2D },
{ "PN_SOLVER", PN_SOLVER }, { "PN_SOLVER", PN_SOLVER },
{ "MN_SOLVER", MN_SOLVER } }; { "MN_SOLVER", MN_SOLVER } };
......
/*! /*!
* @file io.h * @file: io.h
* @brief Creates required input from given config file * @brief: Creates required input from given config file
* @author: J. Wolters
*/ */
#ifndef IO_H #ifndef IO_H
#define IO_H #define IO_H
...@@ -30,7 +32,6 @@ void ExportVTK( const std::string fileName, ...@@ -30,7 +32,6 @@ void ExportVTK( const std::string fileName,
*/ */
Mesh* LoadSU2MeshFromFile( const Config* settings ); Mesh* LoadSU2MeshFromFile( const Config* settings );
/*! /*!
* @brief Parses arguments given when calling program from command line * @brief Parses arguments given when calling program from command line
* @param[in] argc - number arguments * @param[in] argc - number arguments
......
...@@ -21,7 +21,8 @@ class Mesh ...@@ -21,7 +21,8 @@ class Mesh
const unsigned _numNodes; /*! @brief: number of nodes in the mesh (for node centered view)*/ 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 _numNodesPerCell; /*! @brief: number of nodes per cell */
const unsigned _numBoundaries; /*! @brief: number of boundary cells in the mesh */ const unsigned _numBoundaries; /*! @brief: number of boundary cells in the mesh */
const unsigned _ghostCellID; // used for what? /*! @brief: equal to _numCells and therefore has the ID of the last cell + 1 */ 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 */
std::vector<std::pair<double, double>> _bounds; // ??? std::vector<std::pair<double, double>> _bounds; // ???
...@@ -44,8 +45,8 @@ class Mesh ...@@ -44,8 +45,8 @@ class Mesh
void ComputeCellAreas(); /*! @brief: Computes only the areas of the mesh cells. Write to _cellAreas. */ 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 ComputeCellMidpoints(); /*! @brief: Compute only the midpoints of the cells. Write to _cellMidPoints*/
void ComputeConnectivity(); /*! @brief: Computes ??? */ void ComputeConnectivity(); /*! @brief: Computes _cellNeighbors and _nodeNeighbors, i.e. neighborship relation in mesh*/
void ComputePartitioning(); /*! @brief: Computes ??? */ void ComputePartitioning(); /*! @brief: Computes local partitioning for openMP */
/*! @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 * Normals are scaled with their respective edge length
...@@ -54,7 +55,7 @@ class Mesh ...@@ -54,7 +55,7 @@ class Mesh
* @param: cellCenter: Center of the cell that has nodeA and nodeB as nodes. * @param: cellCenter: Center of the cell that has nodeA and nodeB as nodes.
* @return: outward facing normal */ * @return: outward facing normal */
Vector ComputeOutwardFacingNormal( const Vector& nodeA, const Vector& nodeB, const Vector& cellCenter ); Vector ComputeOutwardFacingNormal( const Vector& nodeA, const Vector& nodeB, const Vector& cellCenter );
void ComputeBounds(); /*! @brief: Computes ??? */ void ComputeBounds(); /*! @brief: Computes the spatial bounds of a 2D domain. */
public: public:
Mesh() = delete; // no default constructor Mesh() = delete; // no default constructor
...@@ -111,7 +112,7 @@ class Mesh ...@@ -111,7 +112,7 @@ class Mesh
* @return dimension: scalar */ * @return dimension: scalar */
double GetDistanceToOrigin( unsigned idx_cell ) const; double GetDistanceToOrigin( unsigned idx_cell ) const;
/*! @brief ComputeSlopes calculates the slope in every cell into x and y direction /*! @brief ComputeSlopes calculates the slope in every cell into x and y direction using the divergence theorem.
* @param nq is number of quadrature points * @param nq is number of quadrature points
* @param psiDerX is slope in x direction (gets computed. Slope is stored here) * @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 psiDerY is slope in y direction (gets computed. Slope is stored here)
...@@ -119,7 +120,17 @@ class Mesh ...@@ -119,7 +120,17 @@ class Mesh
// Not used // Not used
void ComputeSlopes( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerY, const VectorVector& psi ) const; void ComputeSlopes( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerY, const VectorVector& psi ) const;
/*! @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; void ReconstructSlopesS( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerY, const VectorVector& psi ) const;
/*! @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)
* @param psi is solution for which slope is computed */
void ReconstructSlopesU( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerY, const VectorVector& psi ) const; void ReconstructSlopesU( unsigned nq, VectorVector& psiDerX, VectorVector& psiDerY, const VectorVector& psi ) const;
}; };
......
/*!
* @file isotropic1D.h
* @brief Class for computing an isotropic scattering kernel of kinetic equations
* @author ?
*/
#ifndef ISOTROPIC_H #ifndef ISOTROPIC_H
#define ISOTROPIC_H #define ISOTROPIC_H
......
/*!
* @file isotropic1D.h
* @brief Class for computing an isotropic scattering kernel of 1D kinetic equations
* @author ?
*/
#ifndef ISOTROPIC1D_H #ifndef ISOTROPIC1D_H
#define ISOTROPIC1D_H #define ISOTROPIC1D_H
......
/*!
* @file scatteringkernelbase.h
* @brief Base class for computing the scattering kernel of kinetic equations
* @author ?
*/
#ifndef SCATTERINGKERNELBASE_CPP #ifndef SCATTERINGKERNELBASE_CPP
#define SCATTERINGKERNELBASE_CPP #define SCATTERINGKERNELBASE_CPP
...@@ -13,14 +19,19 @@ class ScatteringKernel ...@@ -13,14 +19,19 @@ class ScatteringKernel
ScatteringKernel() = delete; ScatteringKernel() = delete;
protected: protected:
QuadratureBase* _quad; QuadratureBase* _quad; /*! @brief: Pointer to the quadrature used to compute the scattering integral */
public: public:
/*! @brief: Copies the pointer of quad. Does not create an own quad */
ScatteringKernel( QuadratureBase* quad ); ScatteringKernel( QuadratureBase* quad );
virtual ~ScatteringKernel(); 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 */
virtual Matrix GetScatteringKernel() = 0; virtual Matrix GetScatteringKernel() = 0;
/*! @brief: Creates an object of the child class of ScatteringKernelBase corresponding to the enum KERNEL_NAME */
static ScatteringKernel* CreateScatteringKernel( KERNEL_NAME name, QuadratureBase* quad ); static ScatteringKernel* CreateScatteringKernel( KERNEL_NAME name, QuadratureBase* quad );
}; };
......
/*!
* @file newtonoptimizer.h
* @brief class for solving the minimal entropy optimization problem using a newton optimizer with line search.
* @author S. Schotthöfer
*/
#ifndef NEWTONOPTIMIZER_H #ifndef NEWTONOPTIMIZER_H
#define NEWTONOPTIMIZER_H #define NEWTONOPTIMIZER_H
...@@ -10,7 +16,7 @@ class NewtonOptimizer : public OptimizerBase ...@@ -10,7 +16,7 @@ class NewtonOptimizer : public OptimizerBase
public: public:
NewtonOptimizer( Config* settings ); NewtonOptimizer( Config* settings );
inline ~NewtonOptimizer() {} ~NewtonOptimizer();
void Solve( Vector& lambda, Vector& u, VectorVector& moments ) override; void Solve( Vector& lambda, Vector& u, VectorVector& moments ) override;
......
/*!
* @file optimizerbase.h
* @brief Base class for solving the minimal entropy optimization problem
* @author S. Schotthöfer
*/
#ifndef OPTIMIZERBASE_H #ifndef OPTIMIZERBASE_H
#define OPTIMIZERBASE_H #define OPTIMIZERBASE_H
#include "common/typedef.h" #include "common/typedef.h"
#include "entropies/entropybase.h"
// Foward declaration // Foward declaration
class Config; class Config;
class EntropyBase;
class OptimizerBase class OptimizerBase
{ {
public: public:
OptimizerBase( Config* settings ); OptimizerBase( Config* settings );
virtual inline ~OptimizerBase() { delete _entropy; } ~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 ); static OptimizerBase* Create( Config* settings );
/*! @brief : Computes the optimal Lagrange multilpiers for the dual entropy minimization problem /*! @brief : Computes the optimal Lagrange multilpiers for the dual entropy minimization problem
...@@ -23,7 +30,7 @@ class OptimizerBase ...@@ -23,7 +30,7 @@ class OptimizerBase
protected: protected:
EntropyBase* _entropy; /*! @brief: Class to handle entropy functional evaluations */ EntropyBase* _entropy; /*! @brief: Class to handle entropy functional evaluations */
Config* _settings; Config* _settings; /*! @biref: Pointer to settings class of the solver */
}; };
#endif // OPTIMIZERBASE_H #endif // OPTIMIZERBASE_H
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
class Checkerboard_SN : public ProblemBase class Checkerboard_SN : public ProblemBase
{ {
private: private:
Vector _scatteringXS; Vector _scatteringXS; /*! @brief Vector of scattering crosssections */
Vector _totalXS; Vector _totalXS; /*! @brief Vector of total crosssections */
Checkerboard_SN() = delete; Checkerboard_SN() = delete;
bool isAbsorption( const Vector& pos ) const; bool isAbsorption( const Vector& pos ) const; /*! @return True if pos is in absorption region, False otherwise */
bool isSource( const Vector& pos ) const; bool isSource( const Vector& pos ) const; /*! @return True if pos is in source region, False otherwise */
public: public:
Checkerboard_SN( Config* settings, Mesh* mesh ); Checkerboard_SN( Config* settings, Mesh* mesh );
...@@ -27,13 +27,22 @@ class Checkerboard_SN : public ProblemBase ...@@ -27,13 +27,22 @@ class Checkerboard_SN : public ProblemBase
class Checkerboard_PN : public ProblemBase class Checkerboard_PN : public ProblemBase
{ {
private: private:
Vector _scatteringXS; Vector _scatteringXS; /*! @brief Vector of scattering crosssections */
Vector _totalXS; Vector _totalXS; /*! @brief Vector of total crosssections */
Checkerboard_PN() = delete; Checkerboard_PN() = delete;
bool isAbsorption( const Vector& pos ) const; bool isAbsorption( const Vector& pos ) const; /*! @return True if pos is in absorption region, False otherwise */
bool isSource( const Vector& pos ) const; 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
*/
int GlobalIndex( int l, int k ) const; int GlobalIndex( int l, int k ) const;
public: public:
......
...@@ -16,8 +16,8 @@ class ProblemBase ...@@ -16,8 +16,8 @@ class ProblemBase
Mesh* _mesh; Mesh* _mesh;
Physics* _physics; Physics* _physics;
std::vector<double> _density; std::vector<double> _density; /*! @brief: vector with patient densities */
std::vector<double> _stoppingPower; std::vector<double> _stoppingPower; /*! @brief: vector with stopping powers*/
ProblemBase() = delete; ProblemBase() = delete;
...@@ -37,6 +37,7 @@ class ProblemBase ...@@ -37,6 +37,7 @@ class ProblemBase
* @param density is vector with patient densities (at different spatial cells) * @param density is vector with patient densities (at different spatial cells)
*/ */
virtual VectorVector GetTotalXS( const Vector& energies ) = 0; virtual VectorVector GetTotalXS( const Vector& energies ) = 0;
/** /**
* @brief GetTotalXSE gives back vector of total cross sections for * @brief GetTotalXSE gives back vector of total cross sections for
* energies in vector energy * energies in vector energy
......
/*!
* @file: reconstructor.h
* @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
*/
#ifndef RECONSTRUCTOR_H #ifndef RECONSTRUCTOR_H
#define RECONSTRUCTOR_H #define RECONSTRUCTOR_H
#include "common/config.h" #include <string>
#include "common/typedef.h"
class Config;
class Reconstructor class Reconstructor
{ {
...@@ -13,7 +22,7 @@ class Reconstructor ...@@ -13,7 +22,7 @@ class Reconstructor
*/ */
Reconstructor( Config* settings ); Reconstructor( Config* settings );
/** Method 1: structured developing /*! Method 1: structured developing
* @brief Slope of angular flux psi inside a given cell * @brief Slope of angular flux psi inside a given cell
* @param Omega fixed ordinate for flux computation * @param Omega fixed ordinate for flux computation
* @param psiL left solution state * @param psiL left solution state
......
...@@ -12,7 +12,7 @@ class CSDSNSolverFP : public SNSolver ...@@ -12,7 +12,7 @@ class CSDSNSolverFP : public SNSolver
std::vector<double> _dose; /*! @brief: TODO */ std::vector<double> _dose; /*! @brief: TODO */
// Physics acess // Physics acess
Vector _energies; /*! @brief: energy levels for CSD, lenght = _nEnergies */ Vector _energies; /*! @brief: energy levels for CSD, length = _nEnergies */
Vector _angle; /*! @brief: angles for SN */ Vector _angle; /*! @brief: angles for SN */
std::vector<Matrix> _sigmaSE; /*! @brief scattering cross section for all energies*/ std::vector<Matrix> _sigmaSE; /*! @brief scattering cross section for all energies*/
...@@ -21,17 +21,15 @@ class CSDSNSolverFP : public SNSolver ...@@ -21,17 +21,15 @@ class CSDSNSolverFP : public SNSolver
Matrix _L; /*! @brief Laplace Beltrami Matrix */ Matrix _L; /*! @brief Laplace Beltrami Matrix */
Matrix _IL; /*! @brief Laplace Beltrami Matrix */ Matrix _IL; /*! @brief Laplace Beltrami Matrix */
double _alpha; double _alpha; /*! @brief Coefficient of GFP operators (see Olbrant 2010, eq. (8)*/
double _beta; double _beta; /*! @brief Coefficient of GFP operators (see Olbrant 2010, eq. (8)*/
Vector _xi1; Matrix _xi; /*! @brief matrix of transport coefficients */
Vector _xi2;
Matrix _xi;
bool _RT; bool _RT; /*! @brief radiotherapy application (on/off), if true use crosssections + stopping powers from database */
double _energyMin; double _energyMin; /*! @brief minimal energy in energy grid*/
double _energyMax; double _energyMax; /*! @brief maximal energy in energy grid*/
public: public:
/** /**
......
...@@ -21,20 +21,20 @@ class CSDSolverTrafoFP : public SNSolver ...@@ -21,20 +21,20 @@ class CSDSolverTrafoFP : public SNSolver
Matrix _L; /*! @brief Laplace Beltrami Matrix */ Matrix _L; /*! @brief Laplace Beltrami Matrix */
Matrix _IL; /*! @brief Laplace Beltrami Matrix */ Matrix _IL; /*! @brief Laplace Beltrami Matrix */
double _alpha; double _alpha; /*! @brief Coefficient of GFP operators (see Olbrant 2010, Appendix B)*/
double _alpha2; double _alpha2; /*! @brief Coefficient of GFP operators (see Olbrant 2010, Appendix B)*/
double _beta; double _beta; /*! @brief Coefficient of GFP operators (see Olbrant 2010, Appendix B)*/
Matrix _xi; /*! @brief matrix of transport coefficients */
Vector _xi1; Vector _xi1;
Vector _xi2; Vector _xi2;
Matrix _xi;
unsigned _FPMethod; 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; bool _RT; /*! @brief radiotherapy application (on/off), if true use crosssections + stopping powers from database */
double _energyMin; double _energyMin; /*! @brief minimal energy in energy grid*/
double _energyMax; double _energyMax; /*! @brief maximal energy in energy grid*/
void GenerateEnergyGrid( bool refinement ); void GenerateEnergyGrid( bool refinement );
......
#ifndef CSDSOLVERTRAFOFPSH2D_H
#define CSDSOLVERTRAFOFPSH2D_H
// externals
#include "spdlog/spdlog.h"
#include <mpi.h>
#include "common/config.h"
#include "common/io.h"
#include "fluxes/numericalflux.h"
#include "icru.h"
#include "kernels/scatteringkernelbase.h"
#include "problems/problembase.h"
#include "quadratures/quadraturebase.h"
#include "solvers/snsolver.h"
#include "sphericalharmonics.h"
class Physics;
class CSDSolverTrafoFPSH2D : public SNSolver
{
private:
std::vector<double> _dose; /*! @brief: TODO */
// Physics acess
Vector _energies; /*! @brief: energy levels for CSD, lenght = _nEnergies */
Vector _angle; /*! @brief: angles for SN */
std::vector<Matrix> _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 _O;
Matrix _S;
Matrix _M;
VectorVector _quadPoints;
VectorVector _quadPointsSphere;
Vector _weights;
Vector _mu;
Vector _phi;
Vector _wp;
Vector _wa;
double _alpha;
double _alpha2;
double _beta;
Vector _xi1;
Vector _xi2;
Matrix _xi;
unsigned _FPMethod;
bool _RT;
double _energyMin;
double _energyMax;
void GenerateEnergyGrid( bool refinement );
public:
/**
* @brief CSDSolverTrafoFP2D constructor
* @param settings stores all needed information
*/
CSDSolverTrafoFPSH2D( Config* settings );
/**
* @brief Solve functions runs main time loop
*/
virtual void Solve();
/**
* @brief Output solution to VTK file
*/
virtual void Save() const;
virtual void Save( int currEnergy ) const;
};
#endif // CSDSOLVERTRAFOFPSH2D_H
#include "optimizers/newtonoptimizer.h" #include "optimizers/newtonoptimizer.h"
#include "common/config.h" #include "common/config.h"
#include "entropies/entropybase.h"
#include "quadratures/quadraturebase.h" #include "quadratures/quadraturebase.h"
#include "toolboxes/errormessages.h" #include "toolboxes/errormessages.h"
...@@ -15,6 +16,8 @@ NewtonOptimizer::NewtonOptimizer( Config* settings ) : OptimizerBase( settings ) ...@@ -15,6 +16,8 @@ NewtonOptimizer::NewtonOptimizer( Config* settings ) : OptimizerBase( settings )
_epsilon = settings->GetNewtonOptimizerEpsilon(); _epsilon = settings->GetNewtonOptimizerEpsilon();
} }
NewtonOptimizer::~NewtonOptimizer() { delete _quadrature; }
double NewtonOptimizer::ComputeObjFunc( Vector& alpha, Vector& sol, VectorVector& moments ) { double NewtonOptimizer::ComputeObjFunc( Vector& alpha, Vector& sol, VectorVector& moments ) {
double result = 0.0; double result = 0.0;
......
#include "optimizers/optimizerbase.h" #include "optimizers/optimizerbase.h"
#include "common/config.h" #include "common/config.h"
#include "entropies/entropybase.h"
#include "optimizers/newtonoptimizer.h" #include "optimizers/newtonoptimizer.h"
OptimizerBase::OptimizerBase( Config* settings ) { OptimizerBase::OptimizerBase( Config* settings ) {
...@@ -7,6 +8,8 @@ OptimizerBase::OptimizerBase( Config* settings ) { ...@@ -7,6 +8,8 @@ OptimizerBase::OptimizerBase( Config* settings ) {
_settings = settings; _settings = settings;
}