-
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.
- Loading branch information
Showing
6 changed files
with
2,068 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
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,256 @@ | ||
#ifndef NJOY_DRYAD_TABULATEDFORMFACTOR | ||
#define NJOY_DRYAD_TABULATEDFORMFACTOR | ||
|
||
// system includes | ||
#include <vector> | ||
|
||
// other includes | ||
#include "dryad/type-aliases.hpp" | ||
#include "scion/math/InterpolationTable.hpp" | ||
|
||
namespace njoy { | ||
namespace dryad { | ||
|
||
/** | ||
* @class | ||
* @brief A form factor table | ||
*/ | ||
class TabulatedFormFactor : | ||
protected scion::math::InterpolationTable< double, double > { | ||
|
||
public: | ||
|
||
/* type aliases */ | ||
using InterpolationTable::XType; | ||
using InterpolationTable::YType; | ||
|
||
/* constructor */ | ||
|
||
#include "dryad/TabulatedFormFactor/src/ctor.hpp" | ||
|
||
/* methods */ | ||
|
||
/** | ||
* @brief Return the energy values | ||
*/ | ||
const std::vector< double >& energies() const noexcept { | ||
|
||
return this->x(); | ||
} | ||
|
||
/** | ||
* @brief Return the form factor values | ||
*/ | ||
const std::vector< double >& values() const noexcept { | ||
|
||
return this->y(); | ||
} | ||
|
||
/** | ||
* @brief Return the lower energy limit | ||
*/ | ||
double lowerEnergyLimit() const noexcept { | ||
|
||
return this->x().front(); | ||
} | ||
|
||
/** | ||
* @brief Return the upper energy limit | ||
*/ | ||
double upperEnergyLimit() 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 form factor table | ||
* | ||
* @param[in] tolerance the linearisation tolerance | ||
*/ | ||
TabulatedFormFactor linearise( ToleranceConvergence tolerance = {} ) const { | ||
|
||
return TabulatedFormFactor( InterpolationTable::linearise( tolerance ) ); | ||
} | ||
|
||
/** | ||
* @brief Inplace scalar addition | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedFormFactor& operator+=( double right ) { | ||
|
||
InterpolationTable::operator+=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief Inplace scalar subtraction | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedFormFactor& operator-=( double right ) { | ||
|
||
InterpolationTable::operator-=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief Inplace scalar multiplication | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedFormFactor& operator*=( double right ) { | ||
|
||
InterpolationTable::operator*=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief Inplace scalar division | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedFormFactor& operator/=( double right ) { | ||
|
||
InterpolationTable::operator/=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief TabulatedFormFactor and scalar addition | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedFormFactor operator+( double right ) const { | ||
|
||
return InterpolationTable::operator+( right ); | ||
} | ||
|
||
/** | ||
* @brief TabulatedFormFactor and scalar subtraction | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedFormFactor operator-( double right ) const { | ||
|
||
return InterpolationTable::operator-( right ); | ||
} | ||
|
||
/** | ||
* @brief TabulatedFormFactor and scalar multiplication | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedFormFactor operator*( double right ) const { | ||
|
||
return InterpolationTable::operator*( right ); | ||
} | ||
|
||
/** | ||
* @brief TabulatedFormFactor and scalar division | ||
* | ||
* @param[in] right the scalar | ||
*/ | ||
TabulatedFormFactor operator/( double right ) const { | ||
|
||
return InterpolationTable::operator/( right ); | ||
} | ||
|
||
/** | ||
* @brief Unary minus | ||
*/ | ||
TabulatedFormFactor operator-() const { | ||
|
||
return InterpolationTable::operator-(); | ||
} | ||
|
||
/** | ||
* @brief Inplace TabulatedFormFactor addition | ||
* | ||
* @param[in] right the table | ||
*/ | ||
TabulatedFormFactor& operator+=( const TabulatedFormFactor& right ) { | ||
|
||
InterpolationTable::operator+=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief Inplace TabulatedFormFactor subtraction | ||
* | ||
* @param[in] right the table | ||
*/ | ||
TabulatedFormFactor& operator-=( const TabulatedFormFactor& right ) { | ||
|
||
InterpolationTable::operator-=( right ); | ||
return *this; | ||
} | ||
|
||
/** | ||
* @brief TabulatedFormFactor and TabulatedFormFactor addition | ||
* | ||
* @param[in] right the table | ||
*/ | ||
TabulatedFormFactor operator+( const TabulatedFormFactor& right ) const { | ||
|
||
return InterpolationTable::operator+( right ); | ||
} | ||
|
||
/** | ||
* @brief TabulatedFormFactor and TabulatedFormFactor subtraction | ||
* | ||
* @param[in] right the table | ||
*/ | ||
TabulatedFormFactor operator-( const TabulatedFormFactor& right ) const { | ||
|
||
return InterpolationTable::operator-( right ); | ||
} | ||
}; | ||
|
||
/** | ||
* @brief Scalar and TabulatedFormFactor addition | ||
* | ||
* @param[in] left the scalar | ||
* @param[in] right the table | ||
*/ | ||
inline TabulatedFormFactor operator+( double left, const TabulatedFormFactor& right ) { | ||
|
||
return right + left; | ||
} | ||
|
||
/** | ||
* @brief Scalar and TabulatedFormFactor subtraction | ||
* | ||
* @param[in] left the scalar | ||
* @param[in] right the table | ||
*/ | ||
inline TabulatedFormFactor operator-( double left, const TabulatedFormFactor& right ) { | ||
|
||
auto result = -right; | ||
result += left; | ||
return result; | ||
} | ||
|
||
/** | ||
* @brief Scalar and TabulatedFormFactor multiplication | ||
* | ||
* @param[in] left the scalar | ||
* @param[in] right the table | ||
*/ | ||
inline TabulatedFormFactor operator*( double left, const TabulatedFormFactor& 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 Private constructor | ||
* | ||
* @param table the interpolation table | ||
*/ | ||
TabulatedFormFactor( InterpolationTable< double, double > table ) : | ||
InterpolationTable( std::move( table ) ) {} | ||
|
||
public: | ||
|
||
TabulatedFormFactor( const TabulatedFormFactor& ) = default; | ||
TabulatedFormFactor( TabulatedFormFactor&& ) = default; | ||
|
||
TabulatedFormFactor& operator=( const TabulatedFormFactor& ) = default; | ||
TabulatedFormFactor& operator=( TabulatedFormFactor&& ) = default; | ||
|
||
/** | ||
* @brief Constructor | ||
* | ||
* @param energies the energy values | ||
* @param values the form factor values | ||
* @param boundaries the boundaries of the interpolation regions | ||
* @param interpolants the interpolation types of the interpolation regions | ||
*/ | ||
TabulatedFormFactor( std::vector< double > energies, | ||
std::vector< double > values, | ||
std::vector< std::size_t > boundaries, | ||
std::vector< InterpolationType > interpolants ) : | ||
InterpolationTable( std::move( energies ), std::move( values ), | ||
std::move( boundaries ), std::move( interpolants ) ) {} | ||
|
||
/** | ||
* @brief Constructor for a form factor using a single interpolation zone | ||
* | ||
* @param energies the energy values | ||
* @param values the form factor values | ||
* @param interpolant the interpolation type of the data (default lin-lin) | ||
*/ | ||
TabulatedFormFactor( std::vector< double > energies, | ||
std::vector< double > values, | ||
InterpolationType interpolant = InterpolationType::LinearLinear ) : | ||
InterpolationTable( std::move( energies ), 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( TabulatedFormFactor TabulatedFormFactor.test.cpp ) |
Oops, something went wrong.