-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting work on TabulatedAngularDistribution
- Loading branch information
Showing
5 changed files
with
2,058 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
#ifndef NJOY_DRYAD_TABULATEDANGULARDISTRIBUTION | ||
#define NJOY_DRYAD_TABULATEDANGULARDISTRIBUTION | ||
|
||
// system includes | ||
#include <vector> | ||
|
||
// other includes | ||
#include "dryad/type-aliases.hpp" | ||
#include "scion/math/InterpolationTable.hpp" | ||
|
||
namespace njoy { | ||
namespace dryad { | ||
|
||
/** | ||
* @class | ||
* @brief An angular distribution table | ||
*/ | ||
class TabulatedAngularDistribution : | ||
protected scion::math::InterpolationTable< double, double > { | ||
|
||
public: | ||
|
||
/* constructor */ | ||
#include "dryad/TabulatedAngularDistribution/src/ctor.hpp" | ||
|
||
/* methods */ | ||
|
||
/** | ||
* @brief Return the cosine values | ||
*/ | ||
const std::vector< double >& cosines() const noexcept { | ||
|
||
return this->x(); | ||
} | ||
|
||
/** | ||
* @brief Return the probability values | ||
*/ | ||
const std::vector< double >& values() const noexcept { | ||
|
||
return this->y(); | ||
} | ||
|
||
/** | ||
* @brief Return the lower cosine limit | ||
*/ | ||
double lowerCosineLimit() const noexcept { | ||
|
||
return this->x().front(); | ||
} | ||
|
||
/** | ||
* @brief Return the upper cosine limit | ||
*/ | ||
double upperCosineLimit() const noexcept { | ||
|
||
return this->x().back(); | ||
} | ||
|
||
using InterpolationTable::boundaries; | ||
using InterpolationTable::interpolants; | ||
using InterpolationTable::numberPoints; | ||
using InterpolationTable::numberRegions; | ||
using InterpolationTable::isLinearised; | ||
|
||
using InterpolationTable::operator(); | ||
|
||
/** | ||
* @brief Return a linearised angular distribution table | ||
* | ||
* @param[in] tolerance the linearisation tolerance | ||
*/ | ||
TabulatedAngularDistribution linearise( ToleranceConvergence tolerance = {} ) const { | ||
|
||
return TabulatedAngularDistribution( InterpolationTable::linearise( tolerance ) ); | ||
} | ||
|
||
/** | ||
* @brief Inplace scalar addition | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedAngularDistribution& operator+=( double right ) { | ||
|
||
InterpolationTable::operator+=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief Inplace scalar subtraction | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedAngularDistribution& operator-=( double right ) { | ||
|
||
InterpolationTable::operator-=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief Inplace scalar multiplication | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedAngularDistribution& operator*=( double right ) { | ||
|
||
InterpolationTable::operator*=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief Inplace scalar division | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedAngularDistribution& operator/=( double right ) { | ||
|
||
InterpolationTable::operator/=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief TabulatedAngularDistribution and scalar addition | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedAngularDistribution operator+( double right ) const { | ||
|
||
return InterpolationTable::operator+( right ); | ||
} | ||
|
||
/** | ||
* @brief TabulatedAngularDistribution and scalar subtraction | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedAngularDistribution operator-( double right ) const { | ||
|
||
return InterpolationTable::operator-( right ); | ||
} | ||
|
||
/** | ||
* @brief TabulatedAngularDistribution and scalar multiplication | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedAngularDistribution operator*( double right ) const { | ||
|
||
return InterpolationTable::operator*( right ); | ||
} | ||
|
||
/** | ||
* @brief TabulatedAngularDistribution and scalar division | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedAngularDistribution operator/( double right ) const { | ||
|
||
return InterpolationTable::operator/( right ); | ||
} | ||
|
||
/** | ||
* @brief Unary minus | ||
*/ | ||
TabulatedAngularDistribution operator-() const { | ||
|
||
return InterpolationTable::operator-(); | ||
} | ||
|
||
/** | ||
* @brief Inplace TabulatedAngularDistribution addition | ||
* | ||
* @param[in] right the table | ||
*/ | ||
TabulatedAngularDistribution& operator+=( const TabulatedAngularDistribution& right ) { | ||
|
||
InterpolationTable::operator+=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief Inplace TabulatedAngularDistribution subtraction | ||
* | ||
* @param[in] right the table | ||
*/ | ||
TabulatedAngularDistribution& operator-=( const TabulatedAngularDistribution& right ) { | ||
|
||
InterpolationTable::operator-=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief TabulatedAngularDistribution and TabulatedAngularDistribution addition | ||
* | ||
* @param[in] right the table | ||
*/ | ||
TabulatedAngularDistribution operator+( const TabulatedAngularDistribution& right ) const { | ||
|
||
return InterpolationTable::operator+( right ); | ||
} | ||
|
||
/** | ||
* @brief TabulatedAngularDistribution and TabulatedAngularDistribution subtraction | ||
* | ||
* @param[in] right the table | ||
*/ | ||
TabulatedAngularDistribution operator-( const TabulatedAngularDistribution& right ) const { | ||
|
||
return InterpolationTable::operator-( right ); | ||
} | ||
}; | ||
|
||
/** | ||
* @brief Scalar and TabulatedAngularDistribution addition | ||
* | ||
* @param[in] left the scalar | ||
* @param[in] right the table | ||
*/ | ||
inline TabulatedAngularDistribution operator+( double left, const TabulatedAngularDistribution& right ) { | ||
|
||
return right + left; | ||
} | ||
|
||
/** | ||
* @brief Scalar and TabulatedAngularDistribution subtraction | ||
* | ||
* @param[in] left the scalar | ||
* @param[in] right the table | ||
*/ | ||
inline TabulatedAngularDistribution operator-( double left, const TabulatedAngularDistribution& right ) { | ||
|
||
auto result = -right; | ||
result += left; | ||
return result; | ||
} | ||
|
||
/** | ||
* @brief Scalar and TabulatedAngularDistribution multiplication | ||
* | ||
* @param[in] left the scalar | ||
* @param[in] right the table | ||
*/ | ||
inline TabulatedAngularDistribution operator*( double left, const TabulatedAngularDistribution& right ) { | ||
|
||
return right * left; | ||
} | ||
|
||
} // dryad namespace | ||
} // njoy namespace | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
private: | ||
|
||
/** | ||
* @brief Constructor for probability data | ||
* | ||
* @param table the interpolation table | ||
*/ | ||
TabulatedAngularDistribution( InterpolationTable< double, double > table ) : | ||
InterpolationTable( std::move( table ) ) {} | ||
|
||
public: | ||
|
||
TabulatedAngularDistribution( const TabulatedAngularDistribution& ) = default; | ||
TabulatedAngularDistribution( TabulatedAngularDistribution&& ) = default; | ||
|
||
TabulatedAngularDistribution& operator=( const TabulatedAngularDistribution& ) = default; | ||
TabulatedAngularDistribution& operator=( TabulatedAngularDistribution&& ) = default; | ||
|
||
/** | ||
* @brief Constructor | ||
* | ||
* @param cosines the cosine values | ||
* @param values the probability values | ||
* @param boundaries the boundaries of the interpolation regions | ||
* @param interpolants the interpolation types of the interpolation regions | ||
*/ | ||
TabulatedAngularDistribution( std::vector< double > cosines, | ||
std::vector< double > values, | ||
std::vector< std::size_t > boundaries, | ||
std::vector< InterpolationType > interpolants ) : | ||
InterpolationTable( std::move( cosines ), std::move( values ), | ||
std::move( boundaries ), std::move( interpolants ) ) {} | ||
|
||
/** | ||
* @brief Constructor for a probability using a single interpolation zone | ||
* | ||
* @param cosines the cosine values | ||
* @param values the probability values | ||
* @param interpolant the interpolation type of the data (default lin-lin) | ||
*/ | ||
TabulatedAngularDistribution( std::vector< double > cosines, | ||
std::vector< double > values, | ||
InterpolationType interpolant = InterpolationType::LinearLinear ) : | ||
InterpolationTable( std::move( cosines ), std::move( values ), interpolant ) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_cpp_test( TabulatedAngularDistribution TabulatedAngularDistribution.test.cpp ) |
Oops, something went wrong.