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

#include <MCGIDI_functions.hpp>

Inheritance diagram for MCGIDI::Functions::Regions1d:

Public Member Functions

LUPI_HOST_DEVICE Regions1d ()
LUPI_HOST Regions1d (GIDI::Functions::Regions1d const &a_regions1d)
LUPI_HOST_DEVICE ~Regions1d ()
LUPI_HOST_DEVICE void append (Function1d_d2 *a_function1d)
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_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 201 of file MCGIDI_functions.hpp.

Constructor & Destructor Documentation

◆ Regions1d() [1/2]

LUPI_HOST_DEVICE MCGIDI::Functions::Regions1d::Regions1d ( )

Definition at line 668 of file MCGIDI_functions.cc.

668 :
669 m_Xs( ),
670 m_functions1d( ) {
671
673}

◆ Regions1d() [2/2]

LUPI_HOST MCGIDI::Functions::Regions1d::Regions1d ( GIDI::Functions::Regions1d const & a_regions1d)

Definition at line 677 of file MCGIDI_functions.cc.

677 :
678 Function1d_d1( a_regions1d.domainMin( ), a_regions1d.domainMax( ), Interpolation::LINLIN, a_regions1d.outerDomainValue( ) ) {
679
681
682 m_Xs.reserve( a_regions1d.size( ) + 1 );
683 m_functions1d.reserve( a_regions1d.size( ) );
684 for( std::size_t i1 = 0; i1 < a_regions1d.size( ); ++i1 ) append( parseFunction1d_d2( a_regions1d[i1] ) );
685}
LUPI_HOST_DEVICE void append(Function1d_d2 *a_function1d)
LUPI_HOST Function1d_d2 * parseFunction1d_d2(GIDI::Functions::Function1dForm const *form1d)

◆ ~Regions1d()

LUPI_HOST_DEVICE MCGIDI::Functions::Regions1d::~Regions1d ( )

Definition at line 690 of file MCGIDI_functions.cc.

690 {
691
692 for( std::size_t i1 = 0; i1 < m_functions1d.size( ); ++i1 ) delete m_functions1d[i1];
693}

Member Function Documentation

◆ append()

LUPI_HOST_DEVICE void MCGIDI::Functions::Regions1d::append ( Function1d_d2 * a_function1d)

Definition at line 697 of file MCGIDI_functions.cc.

697 {
698
699 if( m_functions1d.size( ) == 0 ) m_Xs.push_back( a_function1d->domainMin( ) );
700 m_Xs.push_back( a_function1d->domainMax( ) );
701
702 m_functions1d.push_back( a_function1d );
703}

Referenced by Regions1d().

◆ evaluate()

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

Definition at line 707 of file MCGIDI_functions.cc.

707 {
708
709 int intLower = binarySearchVector( a_x1, m_Xs );
710
711 if( intLower < 0 ) {
712 if( intLower == -1 ) { // a_x1 > last value of m_Xs.
713 return( m_functions1d.back( )->evaluate( a_x1 ) );
714 }
715 intLower = 0; // a_x1 < last value of m_Xs.
716 }
717
718 std::size_t lower = static_cast<std::size_t>( intLower );
719
720 return( m_functions1d[lower]->evaluate( a_x1 ) );
721}
LUPI_HOST_DEVICE double evaluate(double a_x1) const
LUPI_HOST_DEVICE int binarySearchVector(double a_x, Vector< double > const &a_Xs, bool a_boundIndex=false)
Definition MCGIDI.hpp:318

Referenced by evaluate().

◆ serialize()

LUPI_HOST_DEVICE void MCGIDI::Functions::Regions1d::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 731 of file MCGIDI_functions.cc.

731 {
732
733 Function1d::serialize( a_buffer, a_mode );
734 DATA_MEMBER_VECTOR_DOUBLE( m_Xs, a_buffer, a_mode );
735
736 std::size_t vectorSize = m_functions1d.size( );
737 int vectorSizeInt = (int) vectorSize;
738 DATA_MEMBER_INT( vectorSizeInt, a_buffer, a_mode );
739 vectorSize = (std::size_t) vectorSizeInt;
740 if( a_mode == LUPI::DataBuffer::Mode::Unpack ) m_functions1d.resize( vectorSize, &a_buffer.m_placement );
741 if( a_mode == LUPI::DataBuffer::Mode::Memory ) a_buffer.m_placement += m_functions1d.internalSize();
742 for( std::size_t vectorIndex = 0; vectorIndex < vectorSize; ++vectorIndex ) {
743 m_functions1d[vectorIndex] = serializeFunction1d_d2( a_buffer, a_mode, m_functions1d[vectorIndex] );
744 }
745}
#define DATA_MEMBER_VECTOR_DOUBLE(member, buf, mode)
#define DATA_MEMBER_INT( member, buf, mode)
LUPI_HOST_DEVICE void serialize(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
LUPI_HOST_DEVICE Functions::Function1d_d2 * serializeFunction1d_d2(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, Functions::Function1d_d2 *a_function1d)

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