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

#include <MCGIDI_sampling.hpp>

Public Member Functions

LUPI_HOST_DEVICE DomainHash ()
LUPI_HOST_DEVICE DomainHash (std::size_t a_bins, double a_domainMin, double a_domainMax)
LUPI_HOST_DEVICE DomainHash (DomainHash const &a_domainHash)
LUPI_HOST_DEVICE std::size_t bins () const
LUPI_HOST_DEVICE double domainMin () const
LUPI_HOST_DEVICE double domainMax () const
LUPI_HOST_DEVICE double u_domainMin () const
LUPI_HOST_DEVICE double u_domainMax () const
LUPI_HOST_DEVICE double inverse_du () const
LUPI_HOST_DEVICE std::size_t index (double a_domain) const
LUPI_HOST_DEVICE Vector< std::size_t > map (Vector< double > const &a_domainValues) const
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
LUPI_HOST void print (bool a_printValues) const

Detailed Description

This class stores the data needed for logarithmic hash look up of a domain. This is used to find a cross section given a projectile's energy.

Definition at line 24 of file MCGIDI_sampling.hpp.

Constructor & Destructor Documentation

◆ DomainHash() [1/3]

LUPI_HOST_DEVICE MCGIDI::DomainHash::DomainHash ( )

Default constructor used when broadcasting a Protare as needed by MPI or GPUs.

Definition at line 22 of file MCGIDI_domainHash.cc.

22 :
23 m_bins( 0 ),
24 m_domainMin( 0.0 ),
25 m_domainMax( 0.0 ),
26 m_u_domainMin( 0.0 ),
27 m_u_domainMax( 0.0 ),
28 m_inverse_du( 0.0 ) {
29
30}

Referenced by DomainHash().

◆ DomainHash() [2/3]

LUPI_HOST_DEVICE MCGIDI::DomainHash::DomainHash ( std::size_t a_bins,
double a_domainMin,
double a_domainMax )
Parameters
a_bins[in] The number of bins for the hahs function.
a_domainMin[in] The minimum value of the energy domain for the hash function.
a_domainMax[in] The maximum value of the energy domain for the hash function.

Definition at line 38 of file MCGIDI_domainHash.cc.

38 :
39 m_bins( a_bins ),
40 m_domainMin( a_domainMin ),
41 m_domainMax( a_domainMax ),
42 m_u_domainMin( log( a_domainMin ) ),
43 m_u_domainMax( log( a_domainMax ) ),
44 m_inverse_du( static_cast<double>( a_bins ) / ( m_u_domainMax - m_u_domainMin ) ) {
45
46}

◆ DomainHash() [3/3]

LUPI_HOST_DEVICE MCGIDI::DomainHash::DomainHash ( DomainHash const & a_domainHash)
Parameters
a_domainHash[in] The DomainHash instance to copy.

Definition at line 52 of file MCGIDI_domainHash.cc.

52 :
53 m_bins( a_domainHash.bins( ) ),
54 m_domainMin( a_domainHash.domainMin( ) ),
55 m_domainMax( a_domainHash.domainMax( ) ),
56 m_u_domainMin( a_domainHash.u_domainMin( ) ),
57 m_u_domainMax( a_domainHash.u_domainMax( ) ),
58 m_inverse_du( a_domainHash.inverse_du( ) ) {
59}

Member Function Documentation

◆ bins()

LUPI_HOST_DEVICE std::size_t MCGIDI::DomainHash::bins ( ) const
inline

Returns the value of the m_bins.

Definition at line 39 of file MCGIDI_sampling.hpp.

Referenced by DomainHash(), and print().

◆ domainMax()

LUPI_HOST_DEVICE double MCGIDI::DomainHash::domainMax ( ) const
inline

Returns the value of the m_domainMax.

Definition at line 41 of file MCGIDI_sampling.hpp.

Referenced by DomainHash().

◆ domainMin()

LUPI_HOST_DEVICE double MCGIDI::DomainHash::domainMin ( ) const
inline

Returns the value of the m_domainMax.

Definition at line 40 of file MCGIDI_sampling.hpp.

Referenced by DomainHash().

◆ index()

LUPI_HOST_DEVICE std::size_t MCGIDI::DomainHash::index ( double a_domain) const

This method returns the hash index given the domain value a_domain. If a_domain is less than m_domainMin, the returned index is 0. If a_domain is greater than m_domainMax, the returned index is m_bins + 1. Otherwise, the returned index is in the range [1, m_bins].

Parameters
a_domain[in] The domain value that the hash index is to be returned for.
Returns
The hash index.

Definition at line 71 of file MCGIDI_domainHash.cc.

71 {
72
73 if( a_domain < m_domainMin ) return( 0 );
74 if( a_domain > m_domainMax ) return( m_bins + 1 );
75 double dIndex = m_inverse_du * ( log( a_domain ) - m_u_domainMin ) + 1;
76 return( static_cast<std::size_t>( dIndex ) );
77}

Referenced by map().

◆ inverse_du()

LUPI_HOST_DEVICE double MCGIDI::DomainHash::inverse_du ( ) const
inline

Returns the value of the m_inverse_du.

Definition at line 44 of file MCGIDI_sampling.hpp.

Referenced by DomainHash().

◆ map()

LUPI_HOST_DEVICE Vector< std::size_t > MCGIDI::DomainHash::map ( Vector< double > const & a_domainValues) const

This method returns the hash indices for the requested domain values a_domainValues.

Parameters
a_domainValues[in] The domain values.
Returns
The hash indices.

Definition at line 87 of file MCGIDI_domainHash.cc.

87 {
88
89 std::size_t i1, size( a_domainValues.size( ) );
90 Vector<std::size_t> indices( m_bins + 2, static_cast<std::size_t>( 0 ) );
91 std::size_t lastIndex = 0, currentIndex, i2 = 1;
92
93 for( i1 = 0; i1 < size; ++i1 ) {
94 currentIndex = index( a_domainValues[i1] );
95 if( currentIndex != lastIndex ) {
96 for( ; lastIndex < currentIndex; ++lastIndex, ++i2 ) {
97 indices[i2] = i1 - 1;
98 if( i1 == 0 ) indices[i2] = 0; // Special case.
99 }
100 }
101 }
102 for( ; i2 < ( m_bins + 2 ); ++i2 ) indices[i2] = indices[i2-1];
103 return( indices );
104}
LUPI_HOST_DEVICE std::size_t index(double a_domain) const

Referenced by MCGIDI::HeatedCrossSectionContinuousEnergy::HeatedCrossSectionContinuousEnergy().

◆ print()

LUPI_HOST void MCGIDI::DomainHash::print ( bool a_printValues) const

Prints the contents of this.

Parameters
a_printValues[in] If true, the domain values that divide the hash indices are also printed.

Definition at line 130 of file MCGIDI_domainHash.cc.

130 {
131#ifndef __CUDA_ARCH__
132 std::cout << "bins = " << m_bins << std::endl;
133 std::cout << " m_domainMin = " << m_domainMin << " << m_domainMax = " << m_domainMax << std::endl;
134 std::cout << " m_u_domainMin = " << m_u_domainMin << " << m_u_domainMax = " << m_u_domainMax << std::endl;
135 std::cout << " m_inverse_du = " << m_inverse_du << std::endl;
136 if( a_printValues ) {
137 double domain = m_domainMin, factor = pow( m_domainMax / m_domainMin, 1. / static_cast<double>( m_bins ) );
138
139 for( std::size_t i1 = 0; i1 < bins( ); ++i1, domain *= factor ) {
140 std::cout << LUPI::Misc::argumentsToString( " %14.7e", domain );
141 if( ( ( i1 + 1 ) % 10 ) == 0 ) std::cout << std::endl;
142 }
143 std::cout << LUPI::Misc::argumentsToString( " %14.7e", m_domainMax ) << std::endl;
144 }
145#endif
146}
LUPI_HOST_DEVICE std::size_t bins() const
std::string argumentsToString(char const *a_format,...)
Definition LUPI_misc.cc:305

◆ serialize()

LUPI_HOST_DEVICE void MCGIDI::DomainHash::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 114 of file MCGIDI_domainHash.cc.

114 {
115
116 DATA_MEMBER_SIZE_T( m_bins, a_buffer, a_mode );
117 DATA_MEMBER_DOUBLE( m_domainMin, a_buffer, a_mode );
118 DATA_MEMBER_DOUBLE( m_domainMax, a_buffer, a_mode );
119 DATA_MEMBER_DOUBLE( m_u_domainMin, a_buffer, a_mode );
120 DATA_MEMBER_DOUBLE( m_u_domainMax, a_buffer, a_mode );
121 DATA_MEMBER_DOUBLE( m_inverse_du, a_buffer, a_mode );
122}
#define DATA_MEMBER_SIZE_T(member, buf, mode)
#define DATA_MEMBER_DOUBLE(member, buf, mode)

◆ u_domainMax()

LUPI_HOST_DEVICE double MCGIDI::DomainHash::u_domainMax ( ) const
inline

Returns the value of the m_u_domainMax.

Definition at line 43 of file MCGIDI_sampling.hpp.

Referenced by DomainHash().

◆ u_domainMin()

LUPI_HOST_DEVICE double MCGIDI::DomainHash::u_domainMin ( ) const
inline

Returns the value of the m_u_domainMin.

Definition at line 42 of file MCGIDI_sampling.hpp.

Referenced by DomainHash().


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