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

#include <MCGIDI_functions.hpp>

Inheritance diagram for MCGIDI::Functions::Function1d:

Public Member Functions

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)

Protected Attributes

Function1dType m_type

Detailed Description

Definition at line 62 of file MCGIDI_functions.hpp.

Constructor & Destructor Documentation

◆ Function1d() [1/2]

◆ Function1d() [2/2]

LUPI_HOST_DEVICE MCGIDI::Functions::Function1d::Function1d ( double a_domainMin,
double a_domainMax,
Interpolation a_interpolation,
double a_outerDomainValue = 0 )

Definition at line 136 of file MCGIDI_functions.cc.

136 :
137 FunctionBase( 1, a_domainMin, a_domainMax, a_interpolation, a_outerDomainValue ),
139
140}

◆ ~Function1d()

LUPI_HOST_DEVICE MCGIDI::Functions::Function1d::~Function1d ( )

Definition at line 145 of file MCGIDI_functions.cc.

145 {
146
147}

Member Function Documentation

◆ evaluate()

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

Returns the value of the function at a_x1.

Parameters
a_x1[in] The x-value to evaluate the function at.
Returns
The value of the function at a_x1.

Definition at line 197 of file MCGIDI_functions.cc.

197 {
198
199 double value = 0.0;
200
201 switch( type( ) ) {
203 break;
205 value = static_cast<Constant1d const *>( this )->evaluate( a_x1 );
206 break;
208 value = static_cast<XYs1d const *>( this )->evaluate( a_x1 );
209 break;
211 value = static_cast<Polynomial1d const *>( this )->evaluate( a_x1 );
212 break;
214 value = static_cast<Gridded1d const *>( this )->evaluate( a_x1 );
215 break;
217 value = static_cast<Regions1d const *>( this )->evaluate( a_x1 );
218 break;
220 value = static_cast<Branching1d const *>( this )->evaluate( a_x1 );
221 break;
223 value = static_cast<TerrellFissionNeutronMultiplicityModel const *>( this )->evaluate( a_x1 );
224 break;
225 }
226
227 return( value );
228}
LUPI_HOST_DEVICE Function1dType type() const
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double evaluate(double a_x1) const MCGIDI_TRUE_VIRTUAL

Referenced by evaluate(), and sampleBoundingInteger().

◆ sampleBoundingInteger() [1/2]

template<typename RNG>
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION int MCGIDI::Functions::Function1d::sampleBoundingInteger ( double a_x1,
RNG && a_rng ) const

Referenced by sampleBoundingInteger().

◆ sampleBoundingInteger() [2/2]

template<typename RNG>
LUPI_HOST_DEVICE int MCGIDI::Functions::Function1d::sampleBoundingInteger ( double a_x1,
RNG && a_rng ) const

Definition at line 1593 of file MCGIDI_headerSource.hpp.

1593 {
1594
1596 return( static_cast<TerrellFissionNeutronMultiplicityModel const *>( this )->sampleBoundingInteger( a_x1, a_rng ) );
1597
1598 double d_value = evaluate( a_x1 );
1599 int iValue = (int) d_value;
1600 if( iValue == d_value ) return( iValue );
1601 if( d_value - iValue > a_rng( ) ) ++iValue;
1602
1603 return( iValue );
1604}
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION int sampleBoundingInteger(double a_x1, RNG &&a_rng) const

◆ serialize()

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

238 {
239
240 FunctionBase::serialize( a_buffer, a_mode );
241
242 int type = 0;
243 if( a_mode != LUPI::DataBuffer::Mode::Unpack ) {
244 switch( m_type ) {
246 break;
248 type = 1;
249 break;
251 type = 2;
252 break;
254 type = 3;
255 break;
257 type = 4;
258 break;
260 type = 5;
261 break;
263 type = 6;
264 break;
266 type = 7;
267 break;
268 }
269 }
270 DATA_MEMBER_INT( type, a_buffer, a_mode );
271 if( a_mode == LUPI::DataBuffer::Mode::Unpack ) {
272 switch( type ) {
273 case 0 :
275 break;
276 case 1 :
278 break;
279 case 2 :
281 break;
282 case 3 :
284 break;
285 case 4 :
287 break;
288 case 5 :
290 break;
291 case 6 :
293 break;
294 case 7 :
296 break;
297 }
298 }
299}
#define DATA_MEMBER_INT( member, buf, mode)
LUPI_HOST_DEVICE void serialize(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)

Referenced by MCGIDI::Functions::Branching1d::serialize(), MCGIDI::Functions::Constant1d::serialize(), MCGIDI::Functions::Gridded1d::serialize(), MCGIDI::Functions::Polynomial1d::serialize(), MCGIDI::Functions::Regions1d::serialize(), MCGIDI::Functions::TerrellFissionNeutronMultiplicityModel::serialize(), and MCGIDI::Functions::XYs1d::serialize().

◆ type()

◆ typeString()

LUPI_HOST_DEVICE String MCGIDI::Functions::Function1d::typeString ( ) const

Returns a String representation of the Function1d type of this.

Returns
A String instance.

Definition at line 155 of file MCGIDI_functions.cc.

155 {
156
157 String typeStr( "Function1d::" );
158
159 switch( m_type ) {
161 typeStr += "none";
162 break;
164 typeStr += "constant";
165 break;
167 typeStr += "XYs";
168 break;
170 typeStr += "polyomial";
171 break;
173 typeStr += "gridded";
174 break;
176 typeStr += "regions";
177 break;
179 typeStr += "branching";
180 break;
182 typeStr += "TerrellFissionNeutronMultiplicityModel";
183 break;
184 }
185
186 return( typeStr );
187}

Referenced by MCGIDI::Functions::Function1d_d1::evaluate(), MCGIDI::Functions::Function1d_d2::evaluate(), MCGIDI::serializeFunction1d(), MCGIDI::serializeFunction1d_d1(), and MCGIDI::serializeFunction1d_d2().

Member Data Documentation

◆ m_type


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