Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
MCGIDI::Functions::XYs1d Class Reference

#include <MCGIDI_functions.hpp>

Inheritance diagram for MCGIDI::Functions::XYs1d:

Public Member Functions

LUPI_HOST_DEVICE XYs1d ()
LUPI_HOST XYs1d (Interpolation a_interpolation, Vector< double > a_Xs, Vector< double > a_Ys, double a_outerDomainValue=0)
LUPI_HOST XYs1d (GIDI::Functions::XYs1d const &a_XYs1d)
LUPI_HOST_DEVICE ~XYs1d ()
LUPI_HOST_DEVICE double evaluate (double a_x1) const
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
Public Member Functions inherited from MCGIDI::Functions::Function1d_d2
LUPI_HOST_DEVICE Function1d_d2 ()
LUPI_HOST_DEVICE Function1d_d2 (double a_domainMin, double a_domainMax, Interpolation a_interpolation, double a_outerDomainValue=0)
LUPI_HOST_DEVICE double evaluate (double a_x1) const
Public Member Functions inherited from MCGIDI::Functions::Function1d_d1
LUPI_HOST_DEVICE Function1d_d1 ()
LUPI_HOST_DEVICE Function1d_d1 (double a_domainMin, double a_domainMax, Interpolation a_interpolation, double a_outerDomainValue=0)
LUPI_HOST_DEVICE double evaluate (double a_x1) const
Public Member Functions inherited from MCGIDI::Functions::Function1d
LUPI_HOST_DEVICE Function1d ()
LUPI_HOST_DEVICE Function1d (double a_domainMin, double a_domainMax, Interpolation a_interpolation, double a_outerDomainValue=0)
LUPI_HOST_DEVICE ~Function1d ()
LUPI_HOST_DEVICE Function1dType type () const
LUPI_HOST_DEVICE String typeString () const
template<typename RNG>
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION int sampleBoundingInteger (double a_x1, RNG &&a_rng) const
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double evaluate (double a_x1) const MCGIDI_TRUE_VIRTUAL
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
template<typename RNG>
LUPI_HOST_DEVICE int sampleBoundingInteger (double a_x1, RNG &&a_rng) const
Public Member Functions inherited from MCGIDI::Functions::FunctionBase
LUPI_HOST_DEVICE FunctionBase ()
LUPI_HOST FunctionBase (GIDI::Functions::FunctionForm const &a_function)
LUPI_HOST_DEVICE FunctionBase (int a_dimension, double a_domainMin, double a_domainMax, Interpolation a_interpolation, double a_outerDomainValue=0)
virtual LUPI_HOST_DEVICE ~FunctionBase ()=0
LUPI_HOST_DEVICE Interpolation interpolation () const
LUPI_HOST_DEVICE double domainMin () const
LUPI_HOST_DEVICE double domainMax () const
LUPI_HOST_DEVICE double outerDomainValue () const
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)

Additional Inherited Members

Protected Attributes inherited from MCGIDI::Functions::Function1d
Function1dType m_type

Detailed Description

Definition at line 138 of file MCGIDI_functions.hpp.

Constructor & Destructor Documentation

◆ XYs1d() [1/3]

LUPI_HOST_DEVICE MCGIDI::Functions::XYs1d::XYs1d ( )

Definition at line 435 of file MCGIDI_functions.cc.

435 :
436 m_Xs( ),
437 m_Ys( ) {
438
440}

◆ XYs1d() [2/3]

LUPI_HOST MCGIDI::Functions::XYs1d::XYs1d ( Interpolation a_interpolation,
Vector< double > a_Xs,
Vector< double > a_Ys,
double a_outerDomainValue = 0 )

Definition at line 444 of file MCGIDI_functions.cc.

444 :
445 Function1d_d2( a_Xs[0], a_Xs.back( ), a_interpolation, a_outerDomainValue ),
446 m_Xs( a_Xs ),
447 m_Ys( a_Ys ) {
448
450}

◆ XYs1d() [3/3]

LUPI_HOST MCGIDI::Functions::XYs1d::XYs1d ( GIDI::Functions::XYs1d const & a_XYs1d)

Definition at line 454 of file MCGIDI_functions.cc.

454 :
455 Function1d_d2( a_XYs1d.domainMin( ), a_XYs1d.domainMax( ), GIDI2MCGIDI_interpolation( a_XYs1d.interpolation( ) ), a_XYs1d.outerDomainValue( ) ) {
456
458 std::size_t size = a_XYs1d.size( );
459
460 m_Xs.resize( size );
461 m_Ys.resize( size );
462 for( std::size_t i1 = 0; i1 < size; ++i1 ) {
463 std::pair<double, double> xy = a_XYs1d[i1];
464 m_Xs[i1] = xy.first;
465 m_Ys[i1] = xy.second;
466 }
467}
LUPI_HOST_DEVICE Interpolation GIDI2MCGIDI_interpolation(ptwXY_interpolation a_interpolation)

◆ ~XYs1d()

LUPI_HOST_DEVICE MCGIDI::Functions::XYs1d::~XYs1d ( )

Definition at line 472 of file MCGIDI_functions.cc.

472 {
473
474}

Member Function Documentation

◆ evaluate()

LUPI_HOST_DEVICE double MCGIDI::Functions::XYs1d::evaluate ( double a_x1) const

Definition at line 478 of file MCGIDI_functions.cc.

478 {
479
480 int intLower = binarySearchVector( a_x1, m_Xs );
481
482 if( intLower < 0 ) {
483 if( intLower == -2 ) return( m_Ys[0] );
484 return( m_Ys.back( ) );
485 }
486 std::size_t lower = static_cast<std::size_t>( intLower );
487
488 double evaluatedValue = 0.0;
489 double y1 = m_Ys[lower];
490
492 evaluatedValue = y1; }
493 else {
494 double x1 = m_Xs[lower];
495 double x2 = m_Xs[lower+1];
496 double y2 = m_Ys[lower+1];
497
499 double fraction = ( x2 - a_x1 ) / ( x2 - x1 );
500 evaluatedValue = fraction * y1 + ( 1 - fraction ) * y2; }
501 else if( interpolation( ) == Interpolation::LINLOG ) {
502 double fraction = log( x2 / a_x1 ) / log( x2 / x1 );
503 evaluatedValue = fraction * y1 + ( 1 - fraction ) * y2; }
504 else if( interpolation( ) == Interpolation::LOGLIN ) {
505 double fraction = ( x2 - a_x1 ) / ( x2 - x1 );
506 evaluatedValue = exp( fraction * log( y1 ) + ( 1 - fraction ) * log( y2 ) ); }
507 else if( interpolation( ) == Interpolation::LOGLOG ) {
508 double fraction = log( x2 / a_x1 ) / log( x2 / x1 );
509 evaluatedValue = exp( fraction * log( y1 ) + ( 1 - fraction ) * log( y2 ) ); }
510 else {
511 LUPI_THROW( "XYs1d::evaluate: unsupport interpolation." );
512 }
513 }
514
515 return( evaluatedValue );
516}
#define LUPI_THROW(arg)
LUPI_HOST_DEVICE Interpolation interpolation() const
LUPI_HOST_DEVICE int binarySearchVector(double a_x, Vector< double > const &a_Xs, bool a_boundIndex=false)
Definition MCGIDI.hpp:318

◆ serialize()

LUPI_HOST_DEVICE void MCGIDI::Functions::XYs1d::serialize ( LUPI::DataBuffer & a_buffer,
LUPI::DataBuffer::Mode a_mode )

This method serializes this for broadcasting as needed for MPI and GPUs. The method can count the number of required bytes, pack this or unpack this depending on a_mode.

Parameters
a_buffer[in] The buffer to read or write data to depending on a_mode.
a_mode[in] Specifies the action of this method.

Definition at line 526 of file MCGIDI_functions.cc.

526 {
527
528 Function1d::serialize( a_buffer, a_mode );
529 DATA_MEMBER_VECTOR_DOUBLE( m_Xs, a_buffer, a_mode );
530 DATA_MEMBER_VECTOR_DOUBLE( m_Ys, a_buffer, a_mode );
531}
#define DATA_MEMBER_VECTOR_DOUBLE(member, buf, mode)
LUPI_HOST_DEVICE void serialize(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)

The documentation for this class was generated from the following files: