Import Geant4 11.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2025-06-26 09:17:29 +02:00
parent 20a218bbe1
commit a499fb82e9
1941 changed files with 203285 additions and 95593 deletions
@@ -24,63 +24,153 @@
// ********************************************************************
//
#ifndef G4GIDI_h_included
#define G4GIDI_h_included 1
#include <string>
#include <list>
#include <vector>
//using namespace std;
#include <list>
#include "G4Types.hh"
#include "G4GIDI_Misc.hh"
#include "G4GIDI_map.hh"
#include "G4GIDI_target.hh"
#include "G4GIDI_mass.hh"
#include <G4Types.hh>
#include <MCGIDI.hpp>
#ifndef G4GIDI_hh_included
#define G4GIDI_hh_included 1
#define channelID std::string
extern PoPI::Database G4GIDI_pops;
class G4GIDI_Product {
public:
int A, Z, m;
double kineticEnergy, px, py, pz;
double birthTimeSec;
};
class G4GIDI_target {
private:
MCGIDI::Protare *m_MCGIDI_protare;
std::string m_target;
std::string m_fileName;
int m_targetZ;
int m_targetA;
int m_targetM;
double m_targetMass;
MCGIDI::DomainHash m_domainHash;
MCGIDI::URR_protareInfos m_URR_protareInfos;
std::vector<int> m_elasticIndices;
std::vector<int> m_captureIndices;
std::vector<int> m_fissionIndices;
std::vector<int> m_othersIndices;
MCGIDI::Probabilities::ProbabilityBase2d const *m_elasticAngular;
public:
G4GIDI_target( PoPI::Database const &a_pops, MCGIDI::DomainHash const &a_domainHash, GIDI::Protare const &a_GIDI_protare,
MCGIDI::Protare *a_MCGIDI_protare );
~G4GIDI_target( );
std::string const *getName( ) const { return( &m_target ); }
std::string const *getFilename( ) const { return( &m_fileName ); }
int getZ( ) const { return( m_targetZ ); }
int getA( ) const { return( m_targetA ); }
int getM( ) const { return( m_targetM ); }
double getMass( ) const { return( m_targetMass ); }
// int getTemperatures( double *a_temperatures ) const ;
// int readTemperature( int index );
// std::string getEqualProbableBinSampleMethod( );
// int setEqualProbableBinSampleMethod( std::string const &a_method );
std::vector<int> const &elasticIndices( ) { return( m_elasticIndices ); }
std::vector<int> const &captureIndices( ) { return( m_captureIndices ); }
std::vector<int> const &fissionIndices( ) { return( m_fissionIndices ); }
std::vector<int> const &othersIndices( ) { return( m_othersIndices ); }
int getNumberOfChannels( ) const ;
int getNumberOfProductionChannels( ) const ;
channelID getChannelsID( int channelIndex ) const ;
std::vector<channelID> *getChannelIDs( ) const ;
std::vector<channelID> *getProductionChannelIDs( ) const ;
// std::vector<double> *getEnergyGridAtTIndex( int index );
double getTotalCrossSectionAtE( double a_energy, double a_temperature ) const ;
double getElasticCrossSectionAtE( double a_energy, double a_temperature ) const ;
double getCaptureCrossSectionAtE( double a_energy, double a_temperature ) const ;
double getFissionCrossSectionAtE( double a_energy, double a_temperature ) const ;
double getOthersCrossSectionAtE( double a_energy, double a_temperature ) const ;
double sumChannelCrossSectionAtE( std::vector<int> const &a_indices, double a_energy, double a_temperature ) const ;
double sumChannelCrossSectionAtE( int a_nIndices, int const *a_indices, double a_energy, double a_temperature ) const ;
int sampleChannelCrossSectionAtE( std::vector<int> const &a_indices, double a_energy, double a_temperature,
double (*a_rng)( void * ), void *a_rngState ) const ;
int sampleChannelCrossSectionAtE( int a_nIndices, int const *a_indices, double a_energy, double a_temperature,
double (*a_rng)( void * ), void *a_rngState ) const ;
double getElasticFinalState( double a_energy, double a_temperature, double (*a_rng)( void * ), void *a_rngState ) const ;
std::vector<G4GIDI_Product> *getCaptureFinalState( double a_energy, double a_temperature, double (*a_rng)( void * ), void *a_rngState ) const ;
std::vector<G4GIDI_Product> *getFissionFinalState( double a_energy, double a_temperature, double (*a_rng)( void * ), void *a_rngState ) const ;
std::vector<G4GIDI_Product> *getOthersFinalState( double a_energy, double a_temperature, double (*a_rng)( void * ), void *a_rngState ) const ;
std::vector<G4GIDI_Product> *getFinalState( std::vector<int> const &a_indices, double a_energy, double a_temperature,
double (*a_rng)( void * ), void *a_rngState ) const ;
std::vector<G4GIDI_Product> *getFinalState( int a_nIndices, int const *a_indices, double a_energy, double a_temperature,
double (*a_rng)( void * ), void *a_rngState ) const ;
// double getReactionsThreshold( int a_index ) const ;
// void getReactionsDomain( int a_index, double *a_EMin, double *a_EMax ) const ;
};
class G4GIDI {
private:
G4int projectileID;
std::string projectile;
std::list<G4GIDI_map *> dataDirectories;
std::vector<G4GIDI_target *> targets;
G4int init( G4int ip );
G4int m_projectileIP;
std::string m_projectile;
std::vector<GIDI::Map::Map *> m_maps;
std::vector<G4GIDI_target *> m_protares;
public:
G4GIDI( G4int ip, const std::string &dataDirectory );
G4GIDI( G4int ip, std::list<std::string> &dataDirectory );
G4GIDI( G4int a_ip, std::string const &a_dataDirectory );
G4GIDI( G4int a_ip, std::list<std::string> const &a_dataDirectory );
~G4GIDI( );
G4int numberOfDataDirectories( void );
G4int addDataDirectory( const std::string &dataDirectory );
G4int removeDataDirectory( const std::string &dataDirectory );
std::string getDataDirectoryAtIndex( G4int index );
std::vector<std::string> *getDataDirectories( void );
G4int projectileIP( ) const { return( m_projectileIP ); }
G4bool isThisDataAvailable( const std::string &lib_name, G4int iZ, G4int iA, G4int iM = 0 );
G4bool isThisDataAvailable( const std::string &lib_name, const std::string &targetName );
G4int numberOfDataDirectories( ) const { return( static_cast<G4int>( m_maps.size( ) ) ); }
G4int addDataDirectory( std::string const &a_dataDirectory );
G4int removeDataDirectory( std::string const &a_dataDirectory );
std::string const getDataDirectoryAtIndex( G4int a_index ) const ;
std::vector<std::string> *getDataDirectories( ) const ;
char *dataFilename( const std::string &lib_name, G4int iZ, G4int iA, G4int iM = 0 );
char *dataFilename( const std::string &lib_name, const std::string &targetName );
bool isThisDataAvailable( std::string const &a_lib_name, G4int a_Z, G4int a_A, G4int a_M = 0 ) const ;
bool isThisDataAvailable( std::string const &a_lib_name, std::string const &a_targetName ) const ;
std::vector<std::string> *getNamesOfAvailableLibraries( G4int iZ, G4int iA, G4int iM = 0 );
std::vector<std::string> *getNamesOfAvailableLibraries( const std::string &targetName );
std::string dataFilename( std::string const &lib_name, G4int a_Z, G4int a_A, G4int a_M = 0 ) const ;
std::string dataFilename( std::string const &lib_name, std::string const &a_targetName ) const ;
std::vector<std::string> *getNamesOfAvailableTargets( void );
std::vector<std::string> *getNamesOfAvailableLibraries( G4int a_Z, G4int a_A, G4int a_M = 0 ) const ;
std::vector<std::string> *getNamesOfAvailableLibraries( std::string const &a_targetName ) const ;
G4GIDI_target *readTarget( const std::string &lib_name, G4int iZ, G4int iA, G4int iM = 0, G4bool bind = true );
G4GIDI_target *readTarget( const std::string &lib_name, const std::string &targetName, G4bool bind = true );
std::vector<std::string> *getNamesOfAvailableTargets( ) const ;
G4GIDI_target *getAlreadyReadTarget( G4int iZ, G4int iA, G4int iM = 0 );
G4GIDI_target *getAlreadyReadTarget( const std::string &targetName );
G4GIDI_target *readTarget( std::string const &lib_name, G4int a_Z, G4int a_A, G4int a_M = 0, bool a_bind = true );
G4GIDI_target *readTarget( std::string const &lib_name, std::string const &a_targetName, bool a_bind = true );
G4int freeTarget( G4int iZ, G4int iA, G4int iM = 0 );
G4int freeTarget( const std::string &targetSymbol );
G4int freeTarget( G4GIDI_target *target );
G4GIDI_target *getAlreadyReadTarget( G4int a_Z, G4int a_A, G4int a_M = 0 );
G4GIDI_target *getAlreadyReadTarget( std::string const &a_targetName );
std::vector<std::string> *getListOfReadTargetsNames( void );
G4int freeTarget( G4int a_Z, G4int a_A, G4int a_M = 0 );
G4int freeTarget( std::string const &a_targetSymbol );
G4int freeTarget( G4GIDI_target *a_target );
std::vector<std::string> *getListOfReadTargetsNames( );
};
#endif // End of G4GIDI_h_included
std::string G4GIDI_version( );
int G4GIDI_versionMajor( );
int G4GIDI_versionMinor( );
int G4GIDI_versionPatchLevel( );
std::string G4GIDI_GitHash( );
void G4GIDI_initialize( std::string const &a_dataPath );
std::string G4GIDI_Misc_Z_toSymbol( int a_Z );
std::string G4GIDI_Misc_Z_A_m_ToName( int a_Z, int a_A, int a_M );
#endif // End of G4GIDI_hh_included
@@ -1,39 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef G4GIDI_Misc_h_included
#define G4GIDI_Misc_h_included 1
#include <MCGIDI_map.h>
char *G4GIDI_Misc_Z_A_m_ToName( int iZ, int iA, int im = 0 );
char *G4GIDI_Misc_channelCompound( char *particle1, char *particle2 );
int getNamesOfAvailableTargets_walker( GIDI::MCGIDI_mapEntry *entry, int level, void *userData );
#endif // End of G4GIDI_Misc_h_included
@@ -1,51 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef G4GIDI_map_h_included
#define G4GIDI_map_h_included 1
#include <string>
//using namespace std;
#include <MCGIDI_map.h>
class G4GIDI_map {
public:
GIDI::statusMessageReporting smr;
GIDI::MCGIDI_map *map;
G4GIDI_map( const std::string &dataDirectory );
~G4GIDI_map( );
std::string path( void );
std::string fileName( void );
};
#endif // End of G4GIDI_map_h_included
@@ -1,36 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef G4GIDI_mass_h_included
#define G4GIDI_mass_h_included 1
double G4GIDI_targetMass( const char *targetSymbol );
double G4GIDI_Z_AMass( int iZ, int iA );
#endif // End of G4GIDI_mass_h_included
@@ -1,115 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef G4GIDI_target_h_included
#define G4GIDI_target_h_included 1
#include <vector>
#include <string>
//using namespace std;
#include <statusMessageReporting.h>
#include <MCGIDI.h>
typedef struct crossSectionData_s crossSectionData;
typedef struct G4GIDI_Product_s G4GIDI_Product;
struct crossSectionData_s {
int start, end;
std::vector<double> crossSection;
};
#define channelID std::string
struct G4GIDI_Product_s {
int A, Z, m;
double kineticEnergy, px, py, pz;
double birthTimeSec;
};
class G4GIDI_target {
public:
void init( const char *fileName );
std::string equalProbableBinSampleMethod;
int nElasticIndices, nCaptureIndices, nFissionIndices, nOthersIndices;
int *elasticIndices, *captureIndices, *fissionIndices, *othersIndices;
public:
GIDI::statusMessageReporting smr;
int projectilesPOPID;
std::string name;
std::string sourceFilename;
double mass;
GIDI::MCGIDI_target *target;
G4GIDI_target( const char *fileName );
G4GIDI_target( std::string const &fileName );
~G4GIDI_target( );
std::string *getName( void );
std::string *getFilename( void );
int getZ( void );
int getA( void );
int getM( void );
double getMass( void );
int getTemperatures( double *temperatures );
int readTemperature( int index );
std::string getEqualProbableBinSampleMethod( void );
int setEqualProbableBinSampleMethod( std::string method );
int getNumberOfChannels( void );
int getNumberOfProductionChannels( void );
channelID getChannelsID( int channelIndex );
std::vector<channelID> *getChannelIDs( void );
std::vector<channelID> *getProductionChannelIDs( void );
std::vector<double> *getEnergyGridAtTIndex( int index );
double getTotalCrossSectionAtE( double e_in, double temperature );
double getElasticCrossSectionAtE( double e_in, double temperature );
double getCaptureCrossSectionAtE( double e_in, double temperature );
double getFissionCrossSectionAtE( double e_in, double temperature );
double getOthersCrossSectionAtE( double e_in, double temperature );
double sumChannelCrossSectionAtE( int nIndices, int *indices, double e_in, double temperature );
int sampleChannelCrossSectionAtE( int nIndices, int *indices, double e_in, double temperature, double (*rng)( void * ), void *rngState );
double getElasticFinalState( double e_in, double temperature, double (*rng)( void * ), void *rngState );
std::vector<G4GIDI_Product> *getCaptureFinalState( double e_in, double temperature, double (*rng)( void * ), void *rngState );
std::vector<G4GIDI_Product> *getFissionFinalState( double e_in, double temperature, double (*rng)( void * ), void *rngState );
std::vector<G4GIDI_Product> *getOthersFinalState( double e_in, double temperature, double (*rng)( void * ), void *rngState );
std::vector<G4GIDI_Product> *getFinalState( int nIndices, int *indices, double e_in, double temperature, double (*rng)( void * ), void *rngState );
double getReactionsThreshold( int index );
double getReactionsDomain( int index, double *EMin, double *EMax );
};
#endif // End of G4GIDI_target_h_included
@@ -35,8 +35,9 @@
// Derived calculational constants
// GIDI is developped at Lawrence Livermore National Laboratory
// Class Description - End
// 170912 First implementation done by T. Koi (SLAC/EPP)
//
// 2012-09-17 T. Koi (SLAC/EPP): First implementation
// 2024-07-17 D.M.Wright (LLNL): Added GetFatalEnergyCheckLevels()
#include "G4LENDModel.hh"
@@ -59,7 +60,10 @@ class G4LENDCombinedModel : public G4LENDModel
G4bool HasData( const G4DynamicParticle* , G4int iZ , G4int iA , G4int iM,
const G4Isotope* , const G4Element* , const G4Material* );
G4LENDModel* channel_selected; // used in GetFatalEnergyCheckLevels()
virtual const std::pair<G4double, G4double> GetFatalEnergyCheckLevels() const;
private:
G4LENDCombinedCrossSection* crossSection;
G4LENDElastic* elastic;
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,174 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef GIDI_data_hpp_included
#define GIDI_data_hpp_included 1
#include <stdio.h>
#include <string>
#include <vector>
namespace GIDI {
/*
============================================================
=========================== Data1d =========================
============================================================
*/
class Data1d { // BRB: currently not used.
private:
std::vector<double> m_xs;
std::vector<double> m_ys;
public:
Data1d( std::size_t a_number, double const *const a_xs );
Data1d( std::size_t a_number, double const *const a_xs, double const *const a_ys );
Data1d( std::vector<double> const &a_xs );
Data1d( std::vector<double> const &a_xs, std::vector<double> const &a_ys );
Data1d( Data1d const &a_1dData );
~Data1d( );
std::size_t size( ) const { return( m_xs.size( ) ); }
Data1d operator+( double a_value ) const ;
Data1d &operator+=( double a_value );
Data1d operator+( Data1d const &a_rhs ) const ;
Data1d &operator+=( Data1d const &a_rhs );
Data1d operator-( double a_value ) const ;
Data1d &operator-=( double a_value );
Data1d operator-( Data1d const &a_rhs ) const ;
Data1d &operator-=( Data1d const &a_rhs );
Data1d operator*( double a_value ) const ;
Data1d &operator*=( double a_value );
Data1d operator/( double a_value ) const ;
Data1d &operator/=( double a_value );
void print( std::string const &a_prefix ) const ;
};
/*
============================================================
========================== Vector ==========================
============================================================
*/
class Vector {
private:
std::vector<double> m_vector; /**< The list of elements, each is a double instance. */
void writeWithBoundaries2( FILE *a_file, char const *a_format, std::vector<double> const &a_boundaries, double a_epsilon ) const ;
public:
Vector( std::size_t a_number = 0 );
Vector( std::vector<double> const &a_values );
Vector( std::size_t a_number, double const *a_values );
Vector( Vector const &a_vector );
~Vector( );
Vector &operator=( Vector const &a_rhs );
std::size_t size( ) const { return( m_vector.size( ) ); } /**< Returns a number of elements of *this*. */
void resize( std::size_t a_number, double a_value = 0.0 ) { m_vector.resize( a_number, a_value ); } /**< Resizes *this* to *a_number* elements. For details, see std::vector.resize. */
std::vector<double> &data( ) { return( m_vector ); }
double &operator[]( std::size_t a_index ) { return( m_vector[a_index] ); } /**< Returns a reference to the (*a_index*-1)th element. */
double operator[]( std::size_t a_index ) const { return( m_vector[a_index] ); } /**< Returns a reference to the (*a_index*-1)th element. */
Vector operator+( double a_value ) const ;
Vector &operator+=( double a_value );
Vector operator+( Vector const &a_rhs ) const ;
Vector &operator+=( Vector const &a_rhs );
Vector operator-( double a_value ) const ;
Vector &operator-=( double a_value );
Vector operator-( Vector const &a_rhs ) const ;
Vector &operator-=( Vector const &a_rhs );
Vector operator*( double a_value ) const ;
Vector &operator*=( double a_value );
Vector operator/( double a_value ) const ;
Vector &operator/=( double a_value );
void reverse( );
void setToValueInFlatRange( std::size_t a_start, std::size_t a_end, double a_value );
double sum( );
void print( std::string const &a_prefix ) const ;
void write( FILE *a_file, std::string const &a_prefix ) const ;
void writeWithBoundaries( FILE *a_file, char const *a_format, std::vector<double> const &a_boundaries, double a_epsilon ) const ;
};
/*
============================================================
========================== Matrix ==========================
============================================================
*/
class Matrix {
private:
std::vector<Vector> m_matrix; /**< The list of rows, each is a Vector instance. */
public:
Matrix( std::size_t a_rows, std::size_t a_columns );
Matrix( Matrix const &a_gidi_matrix );
~Matrix( );
Matrix &operator=( Matrix const &a_rhs );
std::size_t size( ) const { return( m_matrix.size( ) ); } /**< Returns the number of rows or *this*. */
Vector &operator[]( std::size_t a_index ) { return( m_matrix[a_index] ); } /**< Returns a reference to the (*a_index*-1)th row. */
Vector const &operator[]( std::size_t a_index ) const { return( m_matrix[a_index] ); } /**< Returns a reference to the (*a_index*-1)th row. */
/** Sets the cell at row **a_row** and column **a_column** to **a_value**. */
void operator()( std::size_t a_row /**< The cell's row. */,
std::size_t a_column /**< The cell's row. */,
double a_value /**< The value to put in the cell. */ )
{ m_matrix[a_row][a_column] = a_value; }
std::vector<Vector> const &matrix( ) const { return( m_matrix ); }
Matrix operator+( double a_value ) const ;
Matrix &operator+=( double a_value );
Matrix operator+( Matrix const &a_rhs ) const ;
Matrix &operator+=( Matrix const &a_rhs );
Matrix operator-( double a_value ) const ;
Matrix &operator-=( double a_value );
Matrix operator-( Matrix const &a_rhs ) const ;
Matrix &operator-=( Matrix const &a_rhs );
Matrix operator*( double a_value ) const ;
Matrix &operator*=( double a_value );
Matrix operator/( double a_value ) const ;
Matrix &operator/=( double a_value );
std::size_t numberOfColumns( ) const ;
/** Sets the cell at row **a_row** and column **a_column** to **a_value**. */
void set( std::size_t a_row /**< The cell's row. */,
std::size_t a_column /**< The cell's row. */,
double a_value /**< The value to put in the cell. */ )
{ m_matrix[a_row][a_column] = a_value; }
/** Sets the row at **a_row** to **a_vector**. */
void set( std::size_t a_row /**< The row to set. */,
Vector const &a_vector /**< The Vector to set at row **a_row**. */ )
{ m_matrix[a_row] = a_vector; }
void push_back( Vector const &a_vector );
Matrix transpose( );
void reverse( );
void print( std::string const &a_prefixForRow ) const ;
};
}
#endif // End of GIDI_data_hpp_included
@@ -1,243 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#define GIDI_USE_BDFLS 0
#ifndef GIDI_settings_hpp_included
#define GIDI_settings_hpp_included 1
#include <string>
#include <vector>
#include <map>
#include <ptwX.h>
#include <ptwXY.h>
#include <statusMessageReporting.h>
/* Disable Effective C++ warnings in GIDI header files. */
#if defined( __INTEL_COMPILER )
#pragma warning( push )
#if __INTEL_COMPILER > 1399
#pragma warning( disable:2021 )
#elif __INTEL_COMPILER > 1199
#pragma warning( disable:2304 )
#endif
#endif
#define GIDI_settings_projectileEnergyMode_continuousEnergy 1
#define GIDI_settings_projectileEnergyMode_grouped ( 1 << 1 )
#define GIDI_settings_projectileEnergyMode_fixedGrid ( 1 << 2 )
class GIDI_settings_group {
private:
std::string mLabel;
std::vector<double> mBoundaries;
public:
GIDI_settings_group( std::string const &label = "empty", int size = 0 );
GIDI_settings_group( std::string const &label, int length, double const *values );
GIDI_settings_group( std::string const &label, std::vector<double> const &boundaries );
GIDI_settings_group( GIDI_settings_group const &group );
GIDI_settings_group& operator=( const GIDI_settings_group &group );
~GIDI_settings_group( );
inline double operator[]( int const index ) const { return( mBoundaries[index] ); }
inline int size( void ) const { return( (int) mBoundaries.size( ) ); }
inline int getNumberOfGroups( void ) const { return( (int) ( mBoundaries.size( ) - 1 ) ); }
inline double const *pointer( void ) const { return( &(mBoundaries[0]) ); }
void setFromCDoubleArray( int length, double *values );
inline std::string getLabel( ) const { return( mLabel ); }
int getGroupIndexFromEnergy( double energy, bool encloseOutOfRange ) const;
inline bool isLabel( std::string &label ) const { return( label == mLabel ); }
void print( bool outline = false, int valuesPerLine = 10 ) const;
private:
void initialize( std::string const &label, int size, int length, double const *values );
};
#if GIDI_USE_BDFLS
#include <cbdfls.h>
class GIDI_settings_groups_from_bdfls {
private:
std::vector<GIDI_settings_group> mGroups;
public:
GIDI_settings_groups_from_bdfls( std::string const &fileName );
GIDI_settings_groups_from_bdfls( char const *fileName );
GIDI_settings_groups_from_bdfls( cbdfls_file const *bdfls );
~GIDI_settings_groups_from_bdfls( );
GIDI_settings_group getViaGID( int gid ) const;
std::vector<std::string> getLabels( void ) const;
std::vector<int> getGIDs( void ) const;
void print( bool outline = true, int valuesPerLine = 10 ) const;
private:
void initialize( char const *fileName );
void initialize2( cbdfls_file const *bdfls );
};
#endif
/**
This class stores the flux for one Legendre order (see class GIDI_settings_flux).
*/
class GIDI_settings_flux_order {
private:
int mOrder; /**< The Legendre order of the flux. */
std::vector<double> mEnergies; /**< List of flux energies. */
std::vector<double> mFluxes; /**< List of flux values - one for each element of mEnergies. */
public:
GIDI_settings_flux_order( int order /**< The Legendre order for this flux data. */ );
GIDI_settings_flux_order( int order /**< The Legendre order for this flux data. */,
int length /**< The number or values in energies and fluxes. */,
double const *energies /**< List of energies where flux is given. */,
double const *fluxes /**< List of flux value for each energies value. */ );
GIDI_settings_flux_order( int order /**< The Legendre order for this flux data. */,
std::vector<double> const &energies /**< List of energies where flux is given. */,
std::vector<double> const &fluxes /**< List of flux value for each energies value. */ );
GIDI_settings_flux_order( GIDI_settings_flux_order const &fluxOrder /**< Legendre flux order to copy. */ );
GIDI_settings_flux_order& operator=( const GIDI_settings_flux_order &fluxOrder );
~GIDI_settings_flux_order( );
inline int getOrder( void ) const { return( mOrder ); }
inline int size( void ) const { return( (int) mEnergies.size( ) ); }
inline double const *getEnergies( void ) const { return( &(mEnergies[0]) ); }
inline double const *getFluxes( void ) const { return( &(mFluxes[0]) ); }
void print( int valuesPerLine = 10 ) const;
private:
void initialize( int order, int length, double const *energies, double const *fluxes );
};
class GIDI_settings_flux {
private:
std::string mLabel; /**< Label for the flux. */
double mTemperature;
std::vector<GIDI_settings_flux_order> mFluxOrders; /**< List of fluxes for each Legendre order, l, sorted by Legendre order starting with l = 0. */
public:
GIDI_settings_flux( std::string const &label, double temperature_MeV );
GIDI_settings_flux( char const *label, double temperature_MeV );
GIDI_settings_flux( GIDI_settings_flux const &flux );
GIDI_settings_flux& operator=( const GIDI_settings_flux &flux );
~GIDI_settings_flux( );
GIDI_settings_flux_order const *operator[]( int order ) const;
inline int getMaxOrder( void ) const { return( (int) mFluxOrders.size( ) - 1 ); }
inline int size( void ) const { return( (int) mFluxOrders.size( ) ); }
inline std::string getLabel( ) const { return( mLabel ); }
inline bool isLabel( std::string const &label ) const { return( label == mLabel ); }
inline bool isLabel( char const *label ) const { return( label == mLabel ); }
inline double getTemperature( ) const { return( mTemperature ); }
void addFluxOrder( GIDI_settings_flux_order const &fluxOrder );
void print( bool outline = true, int valuesPerLine = 10 ) const;
};
#if GIDI_USE_BDFLS
class GIDI_settings_fluxes_from_bdfls {
private:
std::vector<GIDI_settings_flux> mFluxes;
public:
GIDI_settings_fluxes_from_bdfls( std::string const &fileName, double temperature_MeV );
GIDI_settings_fluxes_from_bdfls( char const *fileName, double temperature_MeV );
GIDI_settings_fluxes_from_bdfls( cbdfls_file const *bdfls, double temperature_MeV );
~GIDI_settings_fluxes_from_bdfls( );
GIDI_settings_flux getViaFID( int fid );
std::vector<std::string> getLabels( void );
std::vector<int> getFIDs( void );
void print( bool outline = true, int valuesPerLine = 10 );
private:
void initialize( char const *fileName, double temperature_MeV );
void initialize2( cbdfls_file const *bdfls, double temperature_MeV );
};
#endif
class GIDI_settings_processedFlux {
private:
GIDI_settings_flux mFlux;
std::vector<GIDI::ptwXYPoints *> mFluxXY; /* Same as mFlux but stored as ptwXYPoints for each l-order. */
std::vector<GIDI::ptwXPoints *> mGroupedFlux; /* mFlux grouped using mGroupX, and stored as ptwXPoints for each l-order. */
public:
GIDI_settings_processedFlux( GIDI_settings_flux const &flux, GIDI::ptwXPoints *groupX );
GIDI_settings_processedFlux( GIDI_settings_processedFlux const &flux );
GIDI_settings_processedFlux& operator=( const GIDI_settings_processedFlux &flux );
~GIDI_settings_processedFlux( );
inline double getTemperature( ) const { return( mFlux.getTemperature( ) ); }
GIDI::ptwXPoints *groupFunction( GIDI::statusMessageReporting *smr, GIDI::ptwXPoints *groupX, GIDI::ptwXYPoints *ptwXY1, int order ) const;
};
class GIDI_settings_particle {
private:
int mPoPId;
bool mTransporting;
int mEnergyMode;
GIDI_settings_group mGroup;
GIDI::ptwXPoints *mGroupX; /* Same as mGroup but stored as ptwXPoints. */
std::vector<GIDI_settings_processedFlux> mProcessedFluxes;
public:
GIDI_settings_particle( int PoPId, bool transporting, int energyMode );
GIDI_settings_particle( GIDI_settings_particle const &particle );
int initialize( int PoPId, bool transporting, int energyMode );
~GIDI_settings_particle( );
int addFlux( GIDI::statusMessageReporting *smr, GIDI_settings_flux const &flux );
GIDI_settings_processedFlux const *nearestFluxToTemperature( double temperature ) const;
inline int getGroupIndexFromEnergy( double e_in, bool encloseOutOfRange ) const { return( mGroup.getGroupIndexFromEnergy( e_in, encloseOutOfRange ) ); };
inline int getNumberOfGroups( void ) const { return( mGroup.getNumberOfGroups( ) ); };
inline int getPoPId( void ) const { return( mPoPId ); }
inline int getEnergyMode( void ) const { return( mEnergyMode ); }
inline bool getTransporting( void ) const { return( mTransporting ); }
inline GIDI_settings_group getGroup( void ) const { return( mGroup ); }
GIDI_settings_flux const *getFlux( double temperature ) const;
GIDI::ptwXPoints *groupFunction( GIDI::statusMessageReporting *smr, GIDI::ptwXYPoints *ptwXY1, double temperature, int order ) const;
void setGroup( GIDI_settings_group const &group );
inline bool isEnergyMode_continuous( void ) const { return( this->mEnergyMode & GIDI_settings_projectileEnergyMode_continuousEnergy ); }
inline bool isEnergyMode_grouped( void ) const { return( this->mEnergyMode & GIDI_settings_projectileEnergyMode_grouped ); }
inline bool isEnergyMode_fixedGrid( void ) const { return( this->mEnergyMode & GIDI_settings_projectileEnergyMode_fixedGrid ); }
private:
GIDI_settings_flux const *getProcessedFlux( double temperature ) const;
};
class GIDI_settings {
private:
std::map<int, GIDI_settings_particle> mParticles;
public:
GIDI_settings( );
~GIDI_settings( );
int addParticle( GIDI_settings_particle const &particle );
GIDI_settings_particle const *getParticle( int PoPId ) const;
int eraseParticle( int PoPId );
void releaseMemory( ) { mParticles.clear( ); }
};
#if defined( __INTEL_COMPILER )
#pragma warning( pop )
#endif
#endif // End of GIDI_settings_hpp_included
@@ -0,0 +1,369 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef GUPI_hpp_included
#define GUPI_hpp_included 1
#include <list>
#include <map>
#include <LUPI_dataBuffer.hpp>
#include <LUPI.hpp>
#include <HAPI.hpp>
namespace GUPI {
class Entry;
class Suite;
typedef Entry *(*GUPI_parseSuite)( Suite *a_parent, HAPI::Node const &a_node );
#define GUPI_documentationChars "documentation"
#define GUPI_titleChars "title"
#define GUPI_abstractChars "abstract"
#define GUPI_bodyChars "body"
#define GUPI_endfCompatibleChars "endfCompatible"
#define GUPI_doiChars "doi"
#define GUPI_publicationDateChars "publicationDate"
#define GUPI_versionChars "version"
/*
============================================================
======================== WriteInfo =========================
============================================================
*/
class WriteInfo {
public:
std::list<std::string> m_lines;
std::string m_incrementalIndent;
int m_valuesPerLine;
std::string m_sep;
WriteInfo( std::string const &a_incrementalIndent = " ", int a_valuesPerLine = 100, std::string const &a_sep = " " );
std::string incrementalIndent( std::string const &indent ) { return( indent + m_incrementalIndent ); }
void push_back( std::string const &a_line ) { m_lines.push_back( a_line ); }
void addNodeStarter( std::string const &indent, std::string const &a_moniker, std::string const &a_attributes = "" ) {
m_lines.push_back( indent + "<" + a_moniker + a_attributes + ">" ); }
void addNodeStarterEnder( std::string const &indent, std::string const &a_moniker, std::string const &a_attributes = "" ) {
m_lines.push_back( indent + "<" + a_moniker + a_attributes + "/>" ); }
void addNodeEnder( std::string const &a_moniker ) { m_lines.back( ) += "</" + a_moniker + ">"; }
std::string addAttribute( std::string const &a_name, std::string const &a_value ) const { return( " " + a_name + "=\"" + a_value + "\"" ); }
std::string nodeStarter( std::string const &indent, std::string const &a_moniker, std::string const &a_attributes = "" )
{ return( indent + "<" + a_moniker + a_attributes + ">" ); }
std::string nodeEnder( std::string const &a_moniker ) { return( "</" + a_moniker + ">" ); }
void print( );
void clear( ) { m_lines.clear( ); } /**< Clears the contents of *m_lines*. */
};
/*
============================================================
========================= Ancestry =========================
============================================================
*/
class Ancestry {
public:
/* *********************************************************************************************************//**
* Constructs and returns the key name/value for the *this* node.
*
* @return The constructed key name/value.
***********************************************************************************************************/
static std::string buildXLinkItemKey( std::string const &a_name, std::string const &a_key ) {
if( a_key.size( ) == 0 ) return( "" );
return( "[@" + a_name + "='" + a_key + "']" );
}
private:
std::string m_moniker; /**< The node's name (i.e., moniker). */
Ancestry *m_ancestor; /**< The parent node of *this*. */
std::string m_attribute; /**< The name of the attribute in the node that uniquely identifies the node when the parent node containing other child nodes with the same moniker. */
Ancestry *findInAncestry2( std::size_t a_index, std::vector<std::string> const &a_segments );
Ancestry const *findInAncestry2( std::size_t a_index, std::vector<std::string> const &a_segments ) const ;
public:
Ancestry( std::string const &a_moniker, std::string const &a_attribute = "" );
virtual ~Ancestry( );
Ancestry &operator=( Ancestry const &a_ancestry );
std::string const &moniker( ) const { return( m_moniker ); } /**< Returns the value of the *m_moniker* member. */
void setMoniker( std::string const &a_moniker ) { m_moniker = a_moniker; } /**< Set the value of the *m_moniker* member to *a_moniker*. */
Ancestry *ancestor( ) { return( m_ancestor ); } /**< Returns the value of the *m_ancestor* member. */
Ancestry const *ancestor( ) const { return( m_ancestor ); } /**< Returns the value of the *m_ancestor* member. */
void setAncestor( Ancestry *a_ancestor ) { m_ancestor = a_ancestor; } /**< Sets the *m_ancestor* member to *a_ancestor*. */
std::string attribute( ) const { return( m_attribute ); } /**< Returns the value of the *m_attribute* member. */
Ancestry *root( );
Ancestry const *root( ) const ;
bool isChild( Ancestry *a_instance ) { return( this == a_instance->m_ancestor ); } /**< Returns true if *a_instance* is a child of *this*. */
bool isParent( Ancestry *a_parent ) { return( this->m_ancestor == a_parent ); } /**< Returns true if *a_instance* is the parent of *this*. */
bool isRoot( ) const { return( this->m_ancestor == nullptr ); } /**< Returns true if *this* is the root ancestor. */
Ancestry *findInAncestry( std::string const &a_href );
Ancestry const *findInAncestry( std::string const &a_href ) const ;
/* *********************************************************************************************************//**
* Used to tranverse **GNDS** nodes. This method returns a pointer to a derived class' *a_item* member or nullptr if none exists.
*
* @param a_item [in] The name of the class member whose pointer is to be return.
* @return The pointer to the class member or nullptr if class does not have a member named a_item.
***********************************************************************************************************/
virtual Ancestry *findInAncestry3( std::string const &a_item ) = 0;
virtual Ancestry const *findInAncestry3( std::string const &a_item ) const = 0;
virtual LUPI_HOST void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
virtual std::string xlinkItemKey( ) const { return( "" ); } /**< Returns the value of *this*'s key. */
std::string toXLink( ) const ;
virtual void toXMLList( WriteInfo &a_writeInfo, std::string const &a_indent = "" ) const ;
void printXML( ) const ;
};
/*
============================================================
========================== Entry ===========================
============================================================
*/
class Entry : public Ancestry {
private:
std::string m_keyName; /**< The name of the key used by the parent suite to reference *this* entry. */
std::string m_keyValue; /**< The key used by the parent suite to reference *this* entry. */
public:
Entry( std::string const &a_moniker, std::string const &a_keyName, std::string const &a_keyValue );
Entry( HAPI::Node const &a_node, std::string const &a_keyName );
~Entry( );
std::string const &keyName( ) const { return( m_keyName ); } /**< Returns a const reference to the *m_keyName* member. */
std::string const &keyValue( ) const { return( m_keyValue ); } /**< Returns a const reference to the *m_keyValue* member. */
Ancestry *findInAncestry3( LUPI_maybeUnused std::string const &a_item ) { return( nullptr ); }
Ancestry const *findInAncestry3( LUPI_maybeUnused std::string const &a_item ) const { return( nullptr ); }
LUPI_HOST void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
std::string xlinkItemKey( ) const {
if( m_keyValue == "" ) return( "" );
return( buildXLinkItemKey( m_keyName, m_keyValue ) );
}
};
/*
============================================================
========================== Text ============================
============================================================
*/
class Text : public Ancestry {
public:
enum class Encoding {
utf8,
ascii
};
enum class Markup {
none,
xml,
html,
latex
};
private:
std::string m_body;
Encoding m_encoding;
Markup m_markup;
std::string m_label;
public:
Text( HAPI::Node const &a_node );
~Text( );
std::string const &body( ) const { return m_body; }
Encoding encoding( ) const { return m_encoding; }
Markup markup( ) const { return m_markup; }
std::string const &label( ) const { return m_label; }
Ancestry *findInAncestry3( LUPI_maybeUnused std::string const &a_item ) { return( nullptr ); }
Ancestry const *findInAncestry3( LUPI_maybeUnused std::string const &a_item ) const { return( nullptr ); }
};
/*
============================================================
===================== Documentation ========================
============================================================
*/
class Documentation : public Ancestry {
private:
std::string m_doi; /**< The name of the key used by the parent suite to reference *this* entry. */
std::string m_publicationDate; /**< The key used by the parent suite to reference *this* entry. */
std::string m_version;
Text m_title;
Text m_abstract;
Text m_body;
public:
// Documentation(std::string const &a_moniker, Text const &a_doi, std::string const &a_publicationDate, Text const &a_version);
Documentation(HAPI::Node const &a_node);
~Documentation( );
std::string const &doi( ) const { return m_doi; }
std::string const &publicationDate( ) const { return m_publicationDate; }
std::string const &version( ) const { return m_version; }
Text const &title( ) const { return m_title; }
Text const &abstract( ) const { return m_abstract; }
Text const &body( ) const { return m_body; }
Ancestry *findInAncestry3( LUPI_maybeUnused std::string const &a_item ) { return( nullptr ); }
Ancestry const *findInAncestry3( LUPI_maybeUnused std::string const &a_item ) const { return( nullptr ); }
};
/*
============================================================
=========================== Suite ==========================
============================================================
*/
class Suite : public Ancestry {
public:
typedef std::vector<Entry *> Entries; /**< The typedef the the *m_entries* member. */
private:
std::string m_keyName; /**< The name of the key used to look up items in the suite. */
mutable Entries m_entries; /**< The list of nodes stored within *this*. */
std::map<std::string,int> m_map; /**< A map of *this* node labels to their index in *m_entries*. */
Suite( Suite const *a_suite ); // FIXME, should we make public or private copy constructor? Making private for now.
public:
Suite( std::string const &a_keyName );
Suite( std::string const &a_moniker, std::string const &a_keyName );
Suite( HAPI::Node const &a_node, std::string const &a_keyName, GUPI_parseSuite a_parseSuite );
~Suite( );
std::string const &keyName( ) const { return( m_keyName ); } /**< Returns a const reference to the *m_keyName* member. */
std::size_t size( ) const { return( m_entries.size( ) ); } /**< Returns the number of node contained by *this*. */
int operator[]( std::string const &a_label ) const ;
typedef Entries::iterator iterator;
typedef Entries::const_iterator const_iterator;
iterator begin( ) { return m_entries.begin( ); } /**< The C++ begin iterator for *this*. */
const_iterator begin( ) const { return m_entries.begin( ); } /**< The C++ const begin iterator for *this*. */
iterator end( ) { return m_entries.end( ); } /**< The C++ end iterator for *this*. */
const_iterator end( ) const { return m_entries.end( ); } /**< The C++ const end iterator for *this*. */
template<typename T> T *get( std::size_t a_Index );
template<typename T> T const *get( std::size_t a_Index ) const ;
template<typename T> T *get( std::string const &a_label );
template<typename T> T const *get( std::string const &a_label ) const ;
void parse( HAPI::Node const &a_node, GUPI_parseSuite a_parseSuite );
void add( Entry *a_entry );
iterator find( std::string const &a_label );
const_iterator find( std::string const &a_label ) const ;
bool has( std::string const &a_label ) const { return( find( a_label ) != m_entries.end( ) ); }
Ancestry *findInAncestry3( std::string const &a_item );
Ancestry const *findInAncestry3( std::string const &a_item ) const ;
std::vector<iterator> findAllOfMoniker( std::string const &a_moniker ) ;
std::vector<const_iterator> findAllOfMoniker( std::string const &a_moniker ) const ;
void toXMLList( WriteInfo &a_writeInfo, std::string const &a_indent = "" ) const ;
void printEntryLabels( std::string const &a_header ) const ;
};
/* *********************************************************************************************************//**
* Returns the node at index *a_index*.
*
* @param a_index [in] The index of the node to return.
*
* @return The node at index *a_index*.
***********************************************************************************************************/
template<typename T> T *Suite::get( std::size_t a_index ) {
Entry *entry = m_entries[a_index];
T *object = dynamic_cast<T *>( entry );
if( object == nullptr ) throw LUPI::Exception( "GIDI::Suite::get( std::size_t ): invalid cast" );
return( object );
}
/* *********************************************************************************************************//**
* Returns the node at index *a_index*.
*
* @param a_index [in] The index of the node to return.
*
* @return The node at index *a_index*.
***********************************************************************************************************/
template<typename T> T const *Suite::get( std::size_t a_index ) const {
Entry *entry = m_entries[a_index];
T *object = dynamic_cast<T *>( entry );
if( object == nullptr ) throw LUPI::Exception( "GIDI::Suite::get( std::size_t ): invalid cast" );
return( object );
}
/* *********************************************************************************************************//**
* Returns the node with label *a_label*.
*
* @param a_label [in] The label of the node to return.
*
* @return The node with label *a_label*.
***********************************************************************************************************/
template<typename T> T *Suite::get( std::string const &a_label ) {
int index = (*this)[a_label];
Entry *entry = m_entries[index];
T *object = dynamic_cast<T *>( entry );
if( object == nullptr ) throw LUPI::Exception( "GIDI::Suite::get( std::string const & ): invalid cast" );
return( object );
}
/* *********************************************************************************************************//**
* Returns the node with label *a_label*.
*
* @param a_label [in] The label of the node to return.
*
* @return The node with label *a_label*.
***********************************************************************************************************/
template<typename T> T const *Suite::get( std::string const &a_label ) const {
int index = (*this)[a_label];
Entry *entry = m_entries[index];
T *object = dynamic_cast<T *>( entry );
if( object == nullptr ) throw LUPI::Exception( "GIDI::Suite::get( std::string const & ): invalid cast" );
return( object );
}
} // End of namespace GUPI.
#endif // GUPI_hpp_included
@@ -0,0 +1,420 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef HAPI_hpp_included
#define HAPI_hpp_included 1
#include <string>
#include <stdlib.h>
#include <vector>
#include <stdexcept>
#include <nf_buffer.h>
#include <nf_utilities.h>
#define HAPI_USE_PUGIXML 1
#ifdef HAPI_USE_PUGIXML
#include <pugixml.hpp>
#endif
#ifdef HAPI_USE_HDF5
#include <hdf5.h>
#endif
#include <LUPI.hpp>
namespace HAPI {
enum class NodeInteralType { pugiXML, HDF5 };
// container classes for reading in from various data sources:
/*
============================================================
========================= Attribute ========================
============================================================
*/
class Node_internal;
class Attribute {
private:
Node_internal *m_node;
std::string m_name;
//std::string m_value;
public:
inline Attribute() : m_node(nullptr), m_name() {}
inline Attribute(Node_internal *a_node, std::string const a_name) :
m_node(a_node),
m_name(a_name)
{
}
~Attribute() = default;
//std::string const &name() const { return( m_name ); }
inline std::string const value() const;
inline int as_int() const;
inline long as_long() const;
inline double as_double() const;
};
/*
============================================================
=========================== Text ===========================
============================================================
*/
class Text {
private:
std::string m_text;
public:
Text();
Text(std::string const a_text);
~Text();
std::string const &get() const { return( m_text ); }
};
/*
============================================================
================== Data_internal (base class) ==============
============================================================
*/
class Data_internal {
public:
Data_internal() { };
virtual ~Data_internal() = 0;
//std::string const getDataType();
//virtual template <typename T> T read() = 0;
virtual void getDoubles(nf_Buffer<double> &buffer) = 0;
virtual void getInts(nf_Buffer<int> &buffer) = 0;
virtual int length() const = 0;
};
/*
============================================================
=================== Node_internal (base class) =============
============================================================
*/
class Node_internal {
private:
NodeInteralType m_type;
public:
Node_internal( NodeInteralType a_type );
Node_internal( Node_internal const &a_node );
virtual ~Node_internal() = 0;
NodeInteralType type( ) const { return( m_type ); }
virtual std::string attribute(const char* name) = 0;
virtual int attribute_as_int(const char* name) = 0;
virtual long attribute_as_long(const char* name) = 0;
virtual double attribute_as_double(const char* name) = 0;
virtual Node_internal *child(const char* name) = 0;
virtual Node_internal *first_child() = 0;
virtual Node_internal *next_sibling() = 0;
virtual void to_next_sibling() = 0;
virtual Node_internal *copy() = 0;
virtual std::string name() const = 0;
virtual bool empty() const = 0;
virtual Text text() const = 0;
virtual Data_internal *data() const = 0;
};
inline std::string const Attribute::value() const { return( m_node->attribute( m_name.c_str()) ); }
inline int Attribute::as_int() const { return( m_node->attribute_as_int(m_name.c_str()) ); }
inline long Attribute::as_long() const { return( m_node->attribute_as_long(m_name.c_str()) ); }
inline double Attribute::as_double() const { return( m_node->attribute_as_double(m_name.c_str()) ); }
/*
============================================================
=========================== Data ===========================
============================================================
*/
class Data {
private:
Data_internal *m_data;
public:
Data();
Data( Data_internal *a_data );
~Data();
void getDoubles(nf_Buffer<double> &buffer);
void getInts(nf_Buffer<int> &buffer);
int length() const;
};
/*
============================================================
============================ Node ==========================
============================================================
*/
class Node {
private:
Node_internal *m_node;
public:
Node();
Node( Node_internal *a_node );
Node( Node const &a_node );
~Node();
inline Attribute attribute(const char* a_name) const{
return Attribute(m_node, a_name);
}
inline std::string attribute_as_string(const char* a_name) const{
if(m_node == nullptr){
return "";
}
return m_node->attribute(a_name);
}
inline int attribute_as_int(const char* a_name) const{
if(m_node == nullptr){
return 0;
}
return m_node->attribute_as_int(a_name);
}
inline long attribute_as_long(const char* a_name) const{
if(m_node == nullptr){
return 0;
}
return m_node->attribute_as_long(a_name);
}
inline double attribute_as_double(const char* a_name) const{
if(m_node == nullptr){
return 0.0;
}
return m_node->attribute_as_double(a_name);
}
Node child(const char* name) const;
Node first_child() const;
Node next_sibling() const;
void to_next_sibling() const;
Node &operator=(const Node &other);
std::string name() const;
bool empty() const;
Text text() const;
Data data() const;
};
/*
============================================================
======================= File (base class) ==================
============================================================
*/
class File {
public:
File() { };
virtual ~File() = 0;
virtual Node child(const char* name) = 0;
virtual Node first_child() = 0;
virtual std::string name() const = 0;
};
/*
============================================================
=============== Data Manager (for hybrid files) ============
============================================================
*/
class DataManager {
public:
DataManager() {};
virtual ~DataManager() {};
static DataManager* m_instance;
public:
virtual void getDoubles(nf_Buffer<double> &result, size_t startIndex, size_t endIndex) = 0;
virtual void getInts(nf_Buffer<int> &result, size_t startIndex, size_t endIndex) = 0;
};
#ifdef HAPI_USE_PUGIXML
/*
============================================================
===================== XML using Pugi =======================
============================================================
*/
class PugiXMLNode : public Node_internal {
private:
pugi::xml_node m_node;
public:
PugiXMLNode();
PugiXMLNode(pugi::xml_node a_node);
PugiXMLNode(const PugiXMLNode &other);
virtual ~PugiXMLNode();
std::string attribute(const char* name);
int attribute_as_int(const char* name);
long attribute_as_long(const char* name);
double attribute_as_double(const char* name);
Node_internal *child(char const *name);
Node_internal *first_child();
Node_internal *next_sibling();
void to_next_sibling();
Node_internal *copy();
Node_internal &operator=(const PugiXMLNode &other);
std::string name() const;
bool empty() const;
Text text() const;
Data_internal *data() const;
};
class PugiXMLData : public Data_internal {
private:
pugi::xml_node m_node;
int m_length;
public:
PugiXMLData();
PugiXMLData(pugi::xml_node a_node);
virtual ~PugiXMLData();
void getDoubles(nf_Buffer<double> &buffer);
void getInts(nf_Buffer<int> &buffer);
int length() const;
};
class PugiXMLFile : public File {
private:
std::string m_name;
pugi::xml_document m_doc;
public:
PugiXMLFile();
PugiXMLFile(char const *filename, std::string const &a_callingFunctionName);
virtual ~PugiXMLFile();
Node child(char const *name);
Node first_child();
std::string name() const;
};
#endif
#ifdef HAPI_USE_HDF5
/*
============================================================
=========================== HDF ============================
============================================================
*/
typedef struct {
std::string name;
std::string xmlName; // HDF sometimes mangles names, need original name here
size_t index;
hid_t node_id;
} childInfo;
class HDFNode : public Node_internal {
private:
hid_t m_node_id;
hid_t m_parent_id;
size_t m_index;
std::vector<childInfo> m_siblings;
std::vector<childInfo> m_children;
public:
HDFNode();
HDFNode(hid_t a_node_id, hid_t a_parent_id, size_t a_index, std::vector<childInfo> a_siblings);
explicit HDFNode(hid_t a_file_id);
HDFNode(const HDFNode &other);
virtual ~HDFNode();
//Attribute attribute(char const *name);
std::string attribute(const char* name);
int attribute_as_int(const char* name);
long attribute_as_long(const char* name);
double attribute_as_double(const char* name);
Node_internal *child(char const *name);
Node_internal *first_child();
Node_internal *next_sibling();
void to_next_sibling();
Node_internal *copy();
Node_internal &operator=(const HDFNode &other);
std::string name() const;
bool empty() const;
Text text() const;
Data_internal *data() const;
};
class HDFData : public Data_internal {
private:
hid_t m_node_id;
hid_t m_dataspace_id;
int m_length;
public:
HDFData();
explicit HDFData(hid_t node_id);
virtual ~HDFData();
void getDoubles(nf_Buffer<double> &buffer);
void getInts(nf_Buffer<int> &buffer);
int length() const;
};
class HDFFile : public File {
private:
std::string m_name;
hid_t m_doc;
HDFNode *m_doc_as_node;
public:
HDFFile();
explicit HDFFile(char const *filename);
virtual ~HDFFile();
Node child(char const *name);
Node first_child();
std::string name() const;
};
class HDFDataManager : public DataManager{
private:
std::string m_filename;
bool m_iDataPresent;
bool m_dDataPresent;
hid_t m_file_id;
hid_t m_dataset_ints, m_dataset_doubles;
hid_t m_dataspace_ints, m_dataspace_doubles;
hsize_t m_stride[1], m_block[1];
size_t m_num_double_reads;
size_t m_num_double_elem;
size_t m_num_int_reads;
size_t m_num_int_elem;
public:
HDFDataManager(std::string const &filename);
virtual ~HDFDataManager();
virtual void getDoubles(nf_Buffer<double> &result, size_t startIndex, size_t endIndex);
virtual void getInts(nf_Buffer<int> &result, size_t startIndex, size_t endIndex);
};
#endif
} // end of namespace 'HAPI'
#endif // End of HAPI_hpp_included
@@ -0,0 +1,446 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef LUPI_hpp_included
#define LUPI_hpp_included 1
#include <sys/stat.h>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <stdexcept>
#include <iostream>
#ifndef _WIN32
#include <time.h>
#include <sys/time.h>
#endif
#include <LUPI_defines.hpp>
#include <statusMessageReporting.h>
#define LUPI_XML_verionEncoding "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
#ifndef LUPI_PATH_MAX
#define LUPI_PATH_MAX ( 4 * 4096 )
#endif
#if defined (GIDIP_HAVE_COMPILER_FLOATING_POINT_EXCEPTIONS)
void LUPI_FPE_enable( char const *a_file, int a_line );
void LUPI_FPE_disable_and_clear( char const *a_file, int a_line );
void LUPI_FPE_test( char const *a_file, int a_line );
#endif
namespace LUPI {
#ifdef _WIN32
#define LUPI_FILE_SEPARATOR "\\"
#else
#define LUPI_FILE_SEPARATOR "/"
#endif
#define GNDS_formatVersion_1_10Chars "1.10"
#define GNDS_formatVersion_2_0Chars "2.0"
#define GNDS_formatVersion_2_0_LLNL_4Chars "2.0.LLNL_4"
void deprecatedFunction( std::string const &a_functionName, std::string const &a_replacementName, std::string const &a_asOf );
/*
============================================================
====================== FormatVersion =======================
============================================================
*/
class FormatVersion {
private:
std::string m_format; /**< The GNDS format version. */
int m_major; /**< The GNDS format major value as an integer. */
int m_minor; /**< The GNDS format minor value as an integer. */
std::string m_patch; /**< The GNDS format patch string. This will be an empty string except for unofficial formats. */
public:
FormatVersion( );
FormatVersion( std::string const &a_formatVersion );
FormatVersion( FormatVersion const &a_formatVersion );
FormatVersion &operator=( FormatVersion const &a_rhs );
std::string const &format( ) const { return( m_format ); }
int major( ) const { return( m_major ); }
int minor( ) const { return( m_minor ); }
std::string const &patch( ) const { return( m_patch ); }
bool setFormat( std::string const &a_formatVersion );
bool supported( ) const ;
};
/*
============================================================
========================= Exception ========================
============================================================
*/
class Exception : public std::runtime_error {
public :
explicit Exception( std::string const &a_message );
};
/*
============================================================
================== StatusMessageReporting ==================
============================================================
*/
class StatusMessageReporting {
public:
enum class Status { ok, info, warning, error };
private:
statusMessageReporting m_smr;
public:
StatusMessageReporting( );
~StatusMessageReporting( );
statusMessageReporting *smr( ) { return( &m_smr ); }
bool isOk( ) { return( smr_isOk( &m_smr ) ); }
bool isInfo( ) { return( smr_isInfo( &m_smr ) ); }
bool isWarning( ) { return( smr_isWarning( &m_smr ) ); }
bool isError( ) { return( smr_isError( &m_smr ) ); }
void clear( ) { smr_release( &m_smr ); }
std::string constructMessage( std::string a_prefix, int a_reports = 1, bool a_clear = false );
std::string constructFullMessage( std::string a_prefix, int a_reports = 1, bool a_clear = false );
};
/*
============================================================
====================== ArgumentParser ======================
============================================================
*/
enum class ArgumentType { True, False, Count, Store, Append, Positional };
class ArgumentBase;
class ArgumentParser {
private:
std::string m_codeName; /**< The name of the code that is using **ArgumentParser**. */
std::string m_descriptor; /**< The descriptor that is printed when help (i.e., '-h') is entered. */
std::vector<ArgumentBase *> m_arguments; /**< The list of arguments (positional and optional) supported. */
void add2( ArgumentBase *a_argumentBase );
public:
ArgumentParser( std::string const &a_codeName, std::string const &a_descriptor = "" );
~ArgumentParser( );
std::string const &codeName( ) const { return( m_codeName ); }
std::string const &descriptor( ) const { return( m_descriptor ); }
template<typename T> T *add( std::string const &a_name, std::string const &a_descriptor, int a_minimumNeeded = 1, int a_maximumNeeded = 1 );
ArgumentBase *add( ArgumentType a_argumentType, std::string const &a_name, std::string const &a_descriptor,
int a_minimumNeeded = -2, int a_maximumNeeded = -2 );
void addAlias( std::string const &a_name, std::string const &a_alias );
void addAlias( ArgumentBase const * const a_argumentBase, std::string const &a_alias );
bool hasName( std::string const &a_name ) const ;
bool isOptionalArgument( std::string const &a_name ) const ;
void parse( int a_argc, char **a_argv, bool a_printArguments = true );
template<typename T> T *get( std::size_t a_name );
void help( ) const ;
void usage( ) const ;
virtual void printStatus( std::string a_indent ) const ;
};
/* *********************************************************************************************************//**
* Creates a new argument, adds the argument to *this* and returns a pointer the the newly created argument.
*
* @param a_name [in] The name of the argument.
* @param a_descriptor [in] The argument's description, displayed when the help option is enetered.
* @param a_minimumNeeded [in] The minimum number of required time *this* argument must be entered.
* @param a_maximumNeeded [in] The maximum number of required time *this* argument must be entered.
*
* @return A pointer to the created argument.
***********************************************************************************************************/
template<typename T> T *ArgumentParser::add( std::string const &a_name, std::string const &a_descriptor, int a_minimumNeeded, int a_maximumNeeded ) {
T *argument = new T( a_name, a_descriptor, a_minimumNeeded, a_maximumNeeded );
add2( argument );
return( argument );
}
/*
============================================================
======================= ArgumentBase =======================
============================================================
*/
class ArgumentBase {
private:
ArgumentType m_argumentType; /**< The enum for arguent type of *this*. */
std::vector<std::string> m_names; /**< The allowed names for *this*. */
std::string m_descriptor; /**< The desciption printed help. */
int m_minimumNeeded; /**< Minimum number of times *this* argument is required on the command line. */
int m_maximumNeeded; /**< Maximum number of times *this* argument is required on the command line. */
int m_counts; /**< The number of time this argument was entered on the command line. */
std::vector<std::string> m_values; /**< list of values entered for this argument. Only used for types Store, Append and Positional. */
void addAlias( std::string const &a_name ); /**< Adds the alias *a_name* to *this*. */
virtual std::string printStatus2( ) const ; /**< For internal use. Called by method **printStatus**. */
virtual void printStatus3( std::string const &a_indent ) const ;
friend void ArgumentParser::addAlias( std::string const &a_name, std::string const &a_alias );
public:
ArgumentBase( ArgumentType a_argumentType, std::string const &a_name, std::string const &a_descriptor, int a_minimumNeeded, int a_maximumNeeded );
virtual ~ArgumentBase( ) = 0 ;
ArgumentType argumentType( ) const { return( m_argumentType ); }
std::string const &name( ) const { return( m_names[0] ); }
std::vector<std::string> const &names( ) { return( m_names ); }
bool hasName( std::string const &a_name ) const ;
std::string const &descriptor( ) const { return( m_descriptor ); }
int minimumNeeded( ) const { return( m_minimumNeeded ); }
int maximumNeeded( ) const { return( m_maximumNeeded ); }
int counts( ) const { return( m_counts ); }
virtual std::string const &value( std::size_t a_index = 0 ) const ;
std::vector<std::string> const &values( ) const { return( m_values ); }
virtual bool isOptionalArgument( ) const { return( true ); }
virtual bool requiresAValue( ) const { return( false ); }
virtual int parse( ArgumentParser const &a_argumentParser, int a_index, int a_argc, char **a_argv );
std::string usage( bool a_requiredOption ) const ;
void printStatus( std::string a_indent ) const ;
};
/*
============================================================
======================= OptionBoolean ======================
============================================================
*/
class OptionBoolean : public ArgumentBase {
private:
bool m_default;
public:
OptionBoolean( ArgumentType a_argumentType, std::string const &a_name, std::string const &a_descriptor, bool a_default );
virtual ~OptionBoolean( ) = 0 ;
bool _default( ) const { return( m_default ); }
std::string printStatus2( ) const ;
};
/*
============================================================
======================== OptionTrue ========================
============================================================
*/
class OptionTrue : public OptionBoolean {
public:
OptionTrue( std::string const &a_name, std::string const &a_descriptor = "", int a_minimumNeeded = 0, int a_maximumNeeded = -1 );
~OptionTrue( ) { }
};
/*
============================================================
======================= OptionFalse ========================
============================================================
*/
class OptionFalse : public OptionBoolean {
public:
OptionFalse( std::string const &a_name, std::string const &a_descriptor = "", int a_minimumNeeded = 0, int a_maximumNeeded = -1 );
~OptionFalse( ) { }
};
/*
============================================================
====================== OptionCounter =======================
============================================================
*/
class OptionCounter : public ArgumentBase {
public:
OptionCounter( std::string const &a_name, std::string const &a_descriptor = "", int a_minimumNeeded = 0, int a_maximumNeeded = -1 );
~OptionCounter( ) { }
std::string printStatus2( ) const ;
};
/*
============================================================
======================= OptionStore ========================
============================================================
*/
class OptionStore : public ArgumentBase {
public:
OptionStore( std::string const &a_name, std::string const &a_descriptor = "", int a_minimumNeeded = 0, int a_maximumNeeded = -1 );
~OptionStore( ) { }
std::string const &value( std::size_t a_index = 0 ) const ;
bool requiresAValue( ) const { return( true ); }
void printStatus3( std::string const &a_indent ) const ;
};
/*
============================================================
======================= OptionAppend =======================
============================================================
*/
class OptionAppend : public ArgumentBase {
public:
OptionAppend( std::string const &a_name, std::string const &a_descriptor = "", int a_minimumNeeded = 0, int a_maximumNeeded = -1 );
~OptionAppend( ) { }
bool requiresAValue( ) const { return( true ); }
void printStatus3( std::string const &a_indent ) const ;
};
/*
============================================================
======================== Positional ========================
============================================================
*/
class Positional : public ArgumentBase {
public:
Positional( std::string const &a_name, std::string const &a_descriptor = "", int a_minimumNeeded = 1, int a_maximumNeeded = 1 );
~Positional( ) { }
bool isOptionalArgument( ) const { return( false ); }
bool requiresAValue( ) const { return( true ); }
void printStatus3( std::string const &a_indent ) const ;
};
/*
============================================================
======================== DeltaTime =========================
============================================================
*/
#ifndef _WIN32
#define LUPI_DeltaTime_toStringFormatIncremental "incremental: CPU %8.3fs, wall %8.3fs"
#define LUPI_DeltaTime_toStringFormatTotal "total: CPU %8.3fs, wall %8.3fs"
class DeltaTime {
private:
double m_CPU_time;
double m_wallTime;
double m_CPU_timeIncremental;
double m_wallTimeIncremental;
public:
DeltaTime( );
DeltaTime( double a_CPU_time, double a_wallTime, double a_CPU_timeIncremental, double a_wallTimeIncremental );
DeltaTime( DeltaTime const &deltaTime );
~DeltaTime( ) { }
double CPU_time( ) const { return( m_CPU_time ); }
double wallTime( ) const { return( m_wallTime ); }
double CPU_timeIncremental( ) const { return( m_CPU_timeIncremental ); }
double wallTimeIncremental( ) const { return( m_wallTimeIncremental ); }
std::string toString( std::string a_formatIncremental = LUPI_DeltaTime_toStringFormatIncremental,
std::string a_format = LUPI_DeltaTime_toStringFormatTotal, std::string a_sep = "; " );
};
/*
============================================================
========================== Timer ===========================
============================================================
*/
class Timer {
private:
clock_t m_CPU_time;
struct timeval m_wallTime;
clock_t m_CPU_timeIncremental;
struct timeval m_wallTimeIncremental;
public:
Timer( );
~Timer( ) { }
DeltaTime deltaTime( );
DeltaTime deltaTimeAndReset( );
void reset( );
};
#endif // End of not _WIN32 defined.
namespace FileInfo { // Should be using std::filesystem stuff but this requires C++ 17.
std::string realPath( std::string const &a_path );
std::string _basename( std::string const &a_path );
std::string basenameWithoutExtension( std::string const &a_path );
std::string _dirname( std::string const &a_path );
bool exists( std::string const &a_path );
bool isDirectory( std::string const &a_path );
bool createDirectories( std::string const &a_path );
/*
============================================================
========================= FileStat =========================
============================================================
*/
class FileStat {
private:
std::string m_path; /**< The path that is stat-ed. */
struct stat m_stat; /**< The stat for the path. */
public:
FileStat( std::string const &a_path );
std::string const &path( ) const { return( m_path ); } /**< Returns a reference to the **m_path** member. */
struct stat const &statRef( ) const { return( m_stat ); } /**< Returns a reference to the **m_stat** member. */
bool exists( );
bool isDirectory( ) const { return( ( m_stat.st_mode & S_IFMT ) == S_IFDIR ); } /**< Returns *true* if the path is a directory and *false* otherwise. */
bool isRegularFile( ) const { return( ( m_stat.st_mode & S_IFMT ) == S_IFREG ); } /**< Returns *true* if the path is a regular file and *false* otherwise. */
};
} // End of namespace FileInfo.
// Miscellaneous functions
namespace Misc {
std::string stripString( std::string const &a_string, bool a_left = true, bool a_right = true );
std::vector<std::string> splitString( std::string const &a_string, char a_delimiter, bool a_strip = false );
std::vector<std::string> splitString( std::string const &a_string, std::string const &a_delimiter, bool a_strip = false );
std::vector<std::string> splitXLinkString( std::string const &a_string );
bool stringToInt( std::string const &a_string, int &a_value );
std::string argumentsToString( char const *a_format, ... );
std::string doubleToString3( char const *a_format, double a_value, bool a_reduceBits = false );
std::string doubleToShortestString( double a_value, int a_significantDigits = 15, int a_favorEFormBy = 0 );
void printCommand( std::string const &a_indent, int a_argc, char **a_argv );
} // End of namespace Misc.
} // End of namespace LUPI.
#endif // LUPI_hpp_included
@@ -0,0 +1,462 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef LUPI_data_buffer_hpp_included
#define LUPI_data_buffer_hpp_included 1
#include <cstdint>
#include <LUPI_defines.hpp>
#include <LUPI_declareMacro.hpp>
namespace LUPI {
/*
============================================================
========================= DataBuffer =======================
============================================================
*/
class DataBuffer {
public:
std::size_t m_intIndex;
std::size_t m_floatIndex;
std::size_t m_doubleIndex;
std::size_t m_charIndex;
std::size_t m_longIndex;
int *m_intData;
float *m_floatData;
double *m_doubleData;
char *m_charData;
std::uint64_t *m_longData;
// For unpacking into pre-allocated memory
char *m_placementStart;
char *m_placement;
std::size_t m_maxPlacementSize;
// If m_sharedPlacementStart is not a nullPtr, place int and double vector information here
// m_sharedMaxPlacementSize is how much shared memory will be used.
char *m_sharedPlacementStart;
char *m_sharedPlacement;
std::size_t m_sharedMaxPlacementSize;
enum class Mode { Count, Pack, Unpack, Reset, Memory };
LUPI_HOST_DEVICE DataBuffer( void ) :
m_intIndex( 0 ),
m_floatIndex( 0 ),
m_doubleIndex( 0 ),
m_charIndex( 0 ),
m_longIndex( 0 ),
m_intData( nullptr ),
m_floatData( nullptr ),
m_doubleData( nullptr ),
m_charData( nullptr ),
m_longData( nullptr ),
m_placementStart( nullptr ),
m_placement( nullptr ),
m_maxPlacementSize( 0 ),
m_sharedPlacementStart( nullptr ),
m_sharedPlacement( nullptr ),
m_sharedMaxPlacementSize( 0 ) {
}
LUPI_HOST_DEVICE DataBuffer( DataBuffer const &rhs ) :
m_intIndex( 0 ),
m_floatIndex( 0 ),
m_doubleIndex( 0 ),
m_charIndex( 0 ),
m_longIndex( 0 ),
m_intData( nullptr ),
m_floatData( nullptr ),
m_doubleData( nullptr ),
m_charData( nullptr ),
m_longData( nullptr ),
m_placementStart( nullptr ),
m_placement( nullptr ),
m_maxPlacementSize( 0 ),
m_sharedPlacementStart( nullptr ),
m_sharedPlacement( nullptr ),
m_sharedMaxPlacementSize( 0 ) {
if( rhs.m_placementStart == nullptr ) m_placementStart = rhs.m_placementStart; // Only to stop compiler warning of unused variable as cannot get [[maybe_unused]] to work.
}
LUPI_HOST_DEVICE ~DataBuffer( ) {
delete [] m_intData;
delete [] m_floatData;
delete [] m_doubleData;
delete [] m_charData;
delete [] m_longData;
}
LUPI_HOST_DEVICE void zeroIndexes( void ) {
m_intIndex = m_floatIndex = m_doubleIndex = m_charIndex = m_longIndex = 0;
}
LUPI_HOST_DEVICE void copyIndexes( DataBuffer const &a_input ) {
m_intIndex = a_input.m_intIndex;
m_floatIndex = a_input.m_floatIndex;
m_doubleIndex = a_input.m_doubleIndex;
m_charIndex = a_input.m_charIndex;
m_longIndex = a_input.m_longIndex;
}
LUPI_HOST_DEVICE void simpleCopy( DataBuffer const &a_input ) {
m_intIndex = a_input.m_intIndex;
m_floatIndex = a_input.m_floatIndex;
m_doubleIndex = a_input.m_doubleIndex;
m_charIndex = a_input.m_charIndex;
m_longIndex = a_input.m_longIndex;
m_intData = a_input.m_intData;
m_floatData = a_input.m_floatData;
m_doubleData = a_input.m_doubleData;
m_charData = a_input.m_charData;
m_longData = a_input.m_longData;
m_placementStart = a_input.m_placementStart;
m_placement = a_input.m_placement;
m_maxPlacementSize = a_input.m_maxPlacementSize;
m_sharedPlacementStart = a_input.m_sharedPlacementStart;
m_sharedPlacement = a_input.m_sharedPlacement;
m_sharedMaxPlacementSize = a_input.m_sharedMaxPlacementSize;
}
// Useful for temporary buffers that we don't want destroying the data in the destructor
LUPI_HOST_DEVICE void nullOutPointers( void ) {
m_intData = nullptr;
m_floatData = nullptr;
m_doubleData = nullptr;
m_charData = nullptr;
m_longData = nullptr;
}
LUPI_HOST_DEVICE void allocateBuffers( void ) {
m_intData = new int[m_intIndex];
m_floatData = new float[m_floatIndex];
m_doubleData = new double[m_doubleIndex];
m_charData = new char[m_charIndex];
m_longData = new std::uint64_t[m_longIndex];
}
LUPI_HOST_DEVICE void freeMemory( void ) {
delete [] m_intData;
delete [] m_floatData;
delete [] m_doubleData;
delete [] m_charData;
delete [] m_longData;
zeroIndexes( );
nullOutPointers( );
}
LUPI_HOST_DEVICE bool compareIndexes( LUPI_maybeUnused char const *a_file, LUPI_maybeUnused int a_line, DataBuffer const &a_input ) {
return( ( a_input.m_intIndex == m_intIndex ) && ( a_input.m_floatIndex == m_floatIndex ) &&
( a_input.m_doubleIndex == m_doubleIndex ) &&
( a_input.m_charIndex == m_charIndex ) && ( a_input.m_longIndex == m_longIndex ) );
}
LUPI_HOST_DEVICE void incrementPlacement(std::size_t a_delta) {
std::size_t sub = a_delta % 8;
if (sub != 0) a_delta += (8-sub);
m_placement += a_delta;
}
LUPI_HOST_DEVICE void incrementSharedPlacement(std::size_t a_delta) {
std::size_t sub = a_delta % 8;
if (sub != 0) a_delta += (8-sub);
m_sharedPlacement += a_delta;
}
// Returns true if data buffer has not gone over any memory limits
LUPI_HOST_DEVICE bool validate() {
if (m_placementStart == 0 && m_sharedPlacementStart == 0) return true;
if (m_placement > m_maxPlacementSize + m_placementStart) return false;
if (m_sharedPlacement > m_sharedMaxPlacementSize + m_sharedPlacementStart) return false;
return true;
}
#if defined(__CUDACC__) || defined (__HIP__)
#ifdef __CUDACC__
#define LUPI_GPU_MALLOC cudaMalloc
#define LUPI_GPU_MEMCPY cudaMemcpy
#define LUPI_GPU_HTOD cudaMemcpyHostToDevice
#else
#define LUPI_GPU_MALLOC hipMalloc
#define LUPI_GPU_MEMCPY hipMemcpy
#define LUPI_GPU_HTOD hipMemcpyHostToDevice
#endif
// Copy this host object to the device and return its pointer
LUPI_HOST DataBuffer *copyToDevice(std::size_t a_cpuSize, char *&a_protarePtr) {
DataBuffer *devicePtr = nullptr;
DataBuffer buf_tmp;
buf_tmp.copyIndexes(*this);
buf_tmp.m_maxPlacementSize = a_cpuSize;
gpuErrorCheck( LUPI_GPU_MALLOC( (void **) &buf_tmp.m_intData, sizeof(int) * m_intIndex) );
gpuErrorCheck( LUPI_GPU_MEMCPY( buf_tmp.m_intData, m_intData, sizeof(int) * m_intIndex, LUPI_GPU_HTOD ) );
gpuErrorCheck( LUPI_GPU_MALLOC( (void **) &buf_tmp.m_floatData, sizeof(float) * m_floatIndex ) );
gpuErrorCheck( LUPI_GPU_MEMCPY( buf_tmp.m_floatData, m_floatData, sizeof(float) * m_floatIndex, LUPI_GPU_HTOD ) );
gpuErrorCheck( LUPI_GPU_MALLOC( (void **) &buf_tmp.m_doubleData, sizeof(double) * m_doubleIndex ) );
gpuErrorCheck( LUPI_GPU_MEMCPY( buf_tmp.m_doubleData, m_doubleData, sizeof(double) * m_doubleIndex, LUPI_GPU_HTOD ) );
gpuErrorCheck( LUPI_GPU_MALLOC( (void **) &buf_tmp.m_charData, sizeof(char) * m_charIndex ) );
gpuErrorCheck( LUPI_GPU_MEMCPY( buf_tmp.m_charData, m_charData, sizeof(char) * m_charIndex, LUPI_GPU_HTOD ) );
gpuErrorCheck( LUPI_GPU_MALLOC( (void **) &buf_tmp.m_longData, sizeof(std::uint64_t) * m_longIndex ) );
gpuErrorCheck( LUPI_GPU_MEMCPY( buf_tmp.m_longData, m_longData, sizeof(std::uint64_t) * m_longIndex, LUPI_GPU_HTOD ) );
gpuErrorCheck( LUPI_GPU_MALLOC( (void **) &buf_tmp.m_placementStart, buf_tmp.m_maxPlacementSize ) );
// Set to 0 for easier byte comparisons. This may be removed after testing is done
//gpuErrorCheck( cudaMemset( (void *) buf_tmp.m_placementStart, 0, buf_tmp.m_maxPlacementSize ) );
buf_tmp.m_placement = buf_tmp.m_placementStart;
a_protarePtr = buf_tmp.m_placementStart;
gpuErrorCheck( LUPI_GPU_MALLOC( (void **) &devicePtr, sizeof(DataBuffer) ) );
gpuErrorCheck( LUPI_GPU_MEMCPY( devicePtr, &buf_tmp, sizeof(DataBuffer), LUPI_GPU_HTOD ) );
// Don't need destructor trying to free the device memory.
buf_tmp.nullOutPointers( );
return devicePtr;
}
#undef LUPI_GPU_MALLOC
#undef LUPI_GPU_MEMCPY
#undef LUPI_GPU_HTOD
#endif
private:
DataBuffer &operator=( DataBuffer const &tmp ); // disable assignment operator
};
} // End of namespace LUPI.
#define DATA_MEMBER_SIMPLE(member, buffer, index, mode) \
{if ( mode == LUPI::DataBuffer::Mode::Count ) {(index)++; } \
else if ( mode == LUPI::DataBuffer::Mode::Pack ) {(buffer)[ (index)++ ] = (member); } \
else if ( mode == LUPI::DataBuffer::Mode::Unpack ) {member = (buffer)[ (index)++ ]; } \
else if ( mode == LUPI::DataBuffer::Mode::Reset ) {(index)++; member = 0; }}
#define DATA_MEMBER_CAST(member, buf, mode, someType) \
{if ( mode == LUPI::DataBuffer::Mode::Count ) {((buf).m_intIndex)++; } \
else if ( mode == LUPI::DataBuffer::Mode::Pack ) {(buf).m_intData[ ((buf).m_intIndex)++ ] = (int)(member); } \
else if ( mode == LUPI::DataBuffer::Mode::Unpack ) {member = (someType) (buf).m_intData[ ((buf).m_intIndex)++ ]; } \
else if ( mode == LUPI::DataBuffer::Mode::Reset ) {((buf).m_intIndex)++; member = (someType) 0; }}
#define DATA_MEMBER_CHAR( member, buf, mode) DATA_MEMBER_SIMPLE(member, (buf).m_charData, (buf).m_charIndex, mode)
#define DATA_MEMBER_INT( member, buf, mode) DATA_MEMBER_SIMPLE(member, (buf).m_intData, (buf).m_intIndex, mode)
#define DATA_MEMBER_FLOAT(member, buf, mode) DATA_MEMBER_SIMPLE(member, (buf).m_floatData, (buf).m_floatIndex, mode)
#define DATA_MEMBER_DOUBLE(member, buf, mode) DATA_MEMBER_SIMPLE(member, (buf).m_doubleData, (buf).m_doubleIndex, mode)
#define DATA_MEMBER_STRING(member, buf, mode) \
{if ( mode == LUPI::DataBuffer::Mode::Count ) {((buf).m_charIndex) += member.size(); ((buf).m_intIndex)++; } \
else if ( mode == LUPI::DataBuffer::Mode::Pack ) {std::size_t array_size = member.size(); \
(buf).m_intData[((buf).m_intIndex)++] = array_size; \
for (std::size_t size_index = 0; size_index < array_size; size_index++)\
{(buf).m_charData[ ((buf).m_charIndex)++ ] = (member[size_index]); }} \
else if ( mode == LUPI::DataBuffer::Mode::Unpack ) {std::size_t array_size = (buf).m_intData[((buf).m_intIndex)++]; \
member.resize(array_size, &(buf).m_placement); \
for (std::size_t size_index = 0; size_index < array_size; size_index++) \
{member[size_index] = (buf).m_charData[ ((buf).m_charIndex)++ ]; }} \
else if ( mode == LUPI::DataBuffer::Mode::Reset ) {std::size_t array_size = member.size(); \
for (std::size_t size_index = 0; size_index < array_size; size_index++) \
{((buf).m_charIndex)++; member[size_index] = '\0'; }} \
else if ( mode == LUPI::DataBuffer::Mode::Memory ) { (buf).incrementPlacement(sizeof(char) * (member.size()+1)); } }
#define DATA_MEMBER_STD_STRING(member, buf, mode) { \
if ( mode == LUPI::DataBuffer::Mode::Count ) \
{((buf).m_charIndex) += member.size(); ((buf).m_intIndex)++; } \
else if ( mode == LUPI::DataBuffer::Mode::Pack ) {std::size_t array_size = member.size(); \
(buf).m_intData[((buf).m_intIndex)++] = array_size; \
for (std::size_t size_index = 0; size_index < array_size; size_index++)\
{(buf).m_charData[((buf).m_charIndex)++] = (member[size_index]); }} \
else if ( mode == LUPI::DataBuffer::Mode::Unpack ) {std::size_t array_size = (buf).m_intData[((buf).m_intIndex)++]; \
member.resize(array_size); \
for (std::size_t size_index = 0; size_index < array_size; size_index++) \
{member[size_index] = (buf).m_charData[ ((buf).m_charIndex)++ ]; }} }
#if LUPI_WARP_SIZE > 1 && defined(LUPI_ON_GPU)
#define DATA_MEMBER_VECTOR_FLOAT(member, buf, mode) \
{ \
std::size_t vector_size = member.size(); \
DATA_MEMBER_INT(vector_size, (buf), mode); \
if ( mode == LUPI::DataBuffer::Mode::Unpack ) member.resize(vector_size, &(buf).m_placement); \
std::size_t bufferIndex = (buf).m_floatIndex; \
for ( std::size_t member_index = 0; member_index < vector_size; member_index += LUPI_WARP_SIZE, bufferIndex += LUPI_WARP_SIZE ) \
{ \
std::size_t thrMemberId = member_index + LUPI_THREADID; \
if (thrMemberId >= vector_size) continue; \
member[thrMemberId] = (buf).m_floatData[bufferIndex + LUPI_THREADID]; \
} \
(buf).m_floatIndex += vector_size; \
}
#define DATA_MEMBER_VECTOR_DOUBLE(member, buf, mode) \
{ \
std::size_t vector_size = member.size(); \
DATA_MEMBER_INT(vector_size, (buf), mode); \
if ( mode == LUPI::DataBuffer::Mode::Unpack ) member.resize(vector_size, &(buf).m_placement); \
std::size_t bufferIndex = (buf).m_doubleIndex; \
for ( std::size_t member_index = 0; member_index < vector_size; member_index += LUPI_WARP_SIZE, bufferIndex += LUPI_WARP_SIZE ) \
{ \
std::size_t thrMemberId = member_index + LUPI_THREADID; \
if (thrMemberId >= vector_size) continue; \
member[thrMemberId] = (buf).m_doubleData[bufferIndex + LUPI_THREADID]; \
} \
(buf).m_doubleIndex += vector_size; \
}
#else
#define DATA_MEMBER_VECTOR_FLOAT(member, buf, mode) \
{ \
std::size_t vector_size = member.size(); \
DATA_MEMBER_INT(vector_size, (buf), mode); \
if ( mode == LUPI::DataBuffer::Mode::Unpack ) { \
if ((buf).m_sharedPlacement == nullptr) { \
member.resize(vector_size, &(buf).m_placement); \
} else { \
member.resize(vector_size, &(buf).m_sharedPlacement); \
} \
}\
if ( mode == LUPI::DataBuffer::Mode::Memory ) { \
(buf).incrementSharedPlacement(sizeof(float) * member.capacity()); \
} \
for ( std::size_t member_index = 0; member_index < vector_size; member_index++ ) \
{ \
DATA_MEMBER_FLOAT(member[member_index], (buf), mode); \
} \
}
#define DATA_MEMBER_VECTOR_DOUBLE(member, buf, mode) \
{ \
std::size_t vector_size = member.size(); \
DATA_MEMBER_INT(vector_size, (buf), mode); \
if ( mode == LUPI::DataBuffer::Mode::Unpack ) { \
if ((buf).m_sharedPlacement == nullptr) { \
member.resize(vector_size, &(buf).m_placement); \
} else { \
member.resize(vector_size, &(buf).m_sharedPlacement); \
} \
}\
if ( mode == LUPI::DataBuffer::Mode::Memory ) { \
(buf).incrementSharedPlacement(sizeof(double) * member.capacity()); \
} \
for ( std::size_t member_index = 0; member_index < vector_size; member_index++ ) \
{ \
DATA_MEMBER_DOUBLE(member[member_index], (buf), mode); \
} \
}
#endif
#if LUPI_WARP_SIZE > 1 && defined(LUPI_ON_GPU)
#define DATA_MEMBER_VECTOR_INT(member, buf, mode) \
{ \
std::size_t vector_size = member.size(); \
DATA_MEMBER_INT(vector_size, (buf), mode); \
if ( mode == LUPI::DataBuffer::Mode::Unpack ) member.resize(vector_size, &(buf).m_placement); \
std::size_t bufferIndex = (buf).m_intIndex; \
for ( std::size_t member_index = 0; member_index < vector_size; member_index += LUPI_WARP_SIZE, bufferIndex += LUPI_WARP_SIZE ) \
{ \
std::size_t thrMemberId = member_index + LUPI_THREADID; \
if (thrMemberId >= vector_size) continue; \
member[thrMemberId] = (buf).m_intData[bufferIndex + LUPI_THREADID]; \
} \
(buf).m_intIndex += vector_size; \
}
#else
#define DATA_MEMBER_VECTOR_INT(member, buf, mode) \
{ \
std::size_t vector_size = member.size(); \
DATA_MEMBER_INT(vector_size, (buf), mode); \
if ( mode == LUPI::DataBuffer::Mode::Unpack ) { \
if ((buf).m_sharedPlacement == nullptr) { \
member.resize(vector_size, &(buf).m_placement); \
} else { \
member.resize(vector_size, &(buf).m_sharedPlacement); \
} \
}\
if ( mode == LUPI::DataBuffer::Mode::Memory ) { \
(buf).incrementSharedPlacement(sizeof(int) * member.capacity()); \
} \
for ( std::size_t member_index = 0; member_index < vector_size; member_index++ ) \
{ \
DATA_MEMBER_INT(member[member_index], (buf), mode); \
} \
}
#endif
#if LUPI_WARP_SIZE > 1 && defined(LUPI_ON_GPU)
#define DATA_MEMBER_VECTOR_BOOL(member, buf, mode) \
{ \
std::size_t vector_size = member.size(); \
DATA_MEMBER_INT(vector_size, (buf), mode); \
if ( mode == LUPI::DataBuffer::Mode::Unpack ) member.resize(vector_size, &(buf).m_placement); \
std::size_t bufferIndex = (buf).m_intIndex; \
for ( std::size_t member_index = 0; member_index < vector_size; member_index += LUPI_WARP_SIZE, bufferIndex += LUPI_WARP_SIZE ) \
{ \
std::size_t thrMemberId = member_index + LUPI_THREADID; \
if (thrMemberId >= vector_size) continue; \
member[thrMemberId] = (buf).m_intData[bufferIndex + LUPI_THREADID]; \
} \
(buf).m_intIndex += vector_size; \
}
#else
#define DATA_MEMBER_VECTOR_BOOL(member, buf, mode) \
{ \
std::size_t vector_size = member.size(); \
DATA_MEMBER_INT(vector_size, (buf), mode); \
if ( mode == LUPI::DataBuffer::Mode::Unpack ) { \
if ((buf).m_sharedPlacement == nullptr) { \
member.resize(vector_size, &(buf).m_placement); \
} else { \
member.resize(vector_size, &(buf).m_sharedPlacement); \
} \
}\
if ( mode == LUPI::DataBuffer::Mode::Memory ) { \
(buf).incrementSharedPlacement(sizeof(int) * member.capacity()); \
} \
for ( std::size_t member_index = 0; member_index < vector_size; member_index++ ) \
{ \
DATA_MEMBER_CAST(member[member_index], (buf), mode, bool); \
} \
}
#endif
#if LUPI_WARP_SIZE > 1 && defined(LUPI_ON_GPU)
#define DATA_MEMBER_CHAR_ARRAY( member, buf, mode ) { \
std::size_t array_size = sizeof( member ); \
std::size_t bufferIndex = (buf).m_charIndex; \
for ( std::size_t member_index = 0; member_index < array_size; member_index += LUPI_WARP_SIZE, bufferIndex += LUPI_WARP_SIZE ) { \
std::size_t thrMemberId = member_index + LUPI_THREADID; \
if( thrMemberId >= array_size ) continue; \
member[thrMemberId] = (buf).m_charData[bufferIndex + LUPI_THREADID]; \
} \
(buf).m_charIndex += array_size; \
}
#else
#define DATA_MEMBER_CHAR_ARRAY( member, buf, mode ) { \
std::size_t array_size = sizeof( member ); \
for ( std::size_t member_index = 0; member_index < array_size; member_index++ ) DATA_MEMBER_CHAR( member[member_index], (buf), mode ); \
}
#endif
#endif // End of LUPI_data_buffer_hpp_included
@@ -0,0 +1,90 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef LUPI_declare_macro_hpp_included
#define LUPI_declare_macro_hpp_included
#include <LUPI_defines.hpp>
// Default, if LUPI_HIP_INLINE is not defined, is to use an attribute function
// to inform HIP not to inline the function.
// This is quite useful for the publicly installed header files for code robustness
// However, when compiling the source, one should be able to disable
// this within the library itself for faster code. To do so
// the define -DLUPI_HIP_INLINE can be added to the compiler flags, and
// the define will evaluate to nothing, so the compiler is welcome to do
// its optimizations.
#ifdef LUPI_HIP_INLINE
#define LUPI_HIP_INLINE_ATTRIBUTE
#else
#define LUPI_HIP_INLINE_ATTRIBUTE __attribute__ ((noinline))
#endif
#define gpuErrorCheck(ans) { gpuAssert((ans), __FILE__, __LINE__); }
#if defined(__HIP_DEVICE_COMPILE__) || defined(__CUDA_ARCH__)
#define LUPI_ON_GPU 1
#endif
#ifdef __CUDACC__
#include <cstdio>
#define LUPI_HOST __host__
#define LUPI_DEVICE __device__
#define LUPI_HOST_DEVICE __host__ __device__
#define LUPI_THROW(arg) printf("%s", arg)
#define LUPI_WARP_SIZE 32
#define LUPI_THREADID threadIdx.x
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"GPUASSERT: %s File: %s line: %d\n", cudaGetErrorString(code), file, line);
if (abort) exit(code);
}
}
#elif HAVE_OPENMP_TARGET
#define LUPI_HOST
#define LUPI_DEVICE
#define LUPI_HOST_DEVICE
#define LUPI_THROW(arg) printf("%s", arg)
#define LUPI_WARP_SIZE 1
#define LUPI_THREADID
inline void gpuAssert(int code, const char *file, int line, bool abort=true) {}
#elif defined(__HIP__)
#include <hip/hip_version.h>
#include <hip/hip_runtime.h>
#include <hip/hip_runtime_api.h>
#include <hip/hip_common.h>
#define LUPI_HOST __host__
#define LUPI_DEVICE __device__
#define LUPI_HOST_DEVICE LUPI_HIP_INLINE_ATTRIBUTE __host__ __device__
#define LUPI_THROW(arg)
#define LUPI_WARP_SIZE 1
#define LUPI_THREADID hipThreadIdx_x
inline void gpuAssert(hipError_t code, const char *file, int line, bool do_abort=true)
{
if (code == hipSuccess) { return; }
printf("GPUassert code %d: %s %s %d\n", code, hipGetErrorString(code), file, line);
if (do_abort) { abort(); }
}
#else
#define LUPI_HOST
#define LUPI_DEVICE
#define LUPI_HOST_DEVICE
#define LUPI_THROW(arg) throw arg
#define LUPI_WARP_SIZE 1
#define LUPI_THREADID
inline void gpuAssert(LUPI_maybeUnused int code, LUPI_maybeUnused const char *file, LUPI_maybeUnused int line, LUPI_maybeUnused bool abort=true) {}
#endif
#endif // End of LUPI_declare_macro_hpp_included
@@ -0,0 +1,19 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef LUPI_defines_hpp_included
#define LUPI_defines_hpp_included 1
#if __cplusplus > 201402L
#define LUPI_maybeUnused [[maybe_unused]]
#else
#define LUPI_maybeUnused
#endif
#endif // LUPI_defines_hpp_included
@@ -1,780 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef MCGIDI_h_included
#define MCGIDI_h_included
#define MCGIDI_VERSION_MAJOR 1
#define MCGIDI_VERSION_MINOR 0
#define MCGIDI_VERSION_PATCHLEVEL 0
#include <GIDI_settings.hh>
#include <map>
#include <vector>
#include <statusMessageReporting.h>
#include <ptwXY.h>
#include <xDataTOM.h>
#include "MCGIDI_mass.h"
#include "MCGIDI_map.h"
/* Disable Effective C++ warnings in GIDI code. */
#if __INTEL_COMPILER > 1399
#pragma warning( disable:2021 )
#pragma warning( disable:593 )
#pragma warning( disable:111 )
#elif __INTEL_COMPILER > 1199
#pragma warning( disable:2304 )
#endif
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
typedef struct MCGIDI_GammaBranching_s MCGIDI_GammaBranching;
typedef struct MCGIDI_POP_s MCGIDI_POP;
typedef struct MCGIDI_POPs_s MCGIDI_POPs;
typedef struct MCGIDI_particle_s MCGIDI_particle;
typedef struct MCGIDI_target_s MCGIDI_target;
typedef struct MCGIDI_target_heated_info_s MCGIDI_target_heated_info;
typedef struct MCGIDI_target_heated_sorted_s MCGIDI_target_heated_sorted;
typedef struct MCGIDI_target_heated_s MCGIDI_target_heated;
typedef struct MCGIDI_reaction_s MCGIDI_reaction;
typedef struct MCGIDI_outputChannel_s MCGIDI_outputChannel;
typedef struct MCGIDI_product_s MCGIDI_product;
typedef struct MCGIDI_distribution_s MCGIDI_distribution;
typedef struct MCGIDI_KalbachMann_s MCGIDI_KalbachMann;
typedef struct MCGIDI_KalbachMann_ras_s MCGIDI_KalbachMann_ras;
typedef struct MCGIDI_pdfOfX_s MCGIDI_pdfOfX;
typedef struct MCGIDI_pdfsOfXGivenW_s MCGIDI_pdfsOfXGivenW;
typedef struct MCGIDI_pdfsOfXGivenW_sampled_s MCGIDI_pdfsOfXGivenW_sampled;
typedef struct MCGIDI_angular_s MCGIDI_angular;
typedef struct MCGIDI_energyWeightedFunctional_s MCGIDI_energyWeightedFunctional;
typedef struct MCGIDI_energyWeightedFunctionals_s MCGIDI_energyWeightedFunctionals;
typedef struct MCGIDI_energyNBodyPhaseSpace_s MCGIDI_energyNBodyPhaseSpace;
typedef struct MCGIDI_energy_s MCGIDI_energy;
typedef struct MCGIDI_energyAngular_s MCGIDI_energyAngular;
typedef struct MCGIDI_angularEnergy_s MCGIDI_angularEnergy;
typedef struct MCGIDI_decaySamplingInfo_s MCGIDI_decaySamplingInfo;
typedef struct MCGIDI_productsInfo_s MCGIDI_productsInfo;
typedef struct MCGIDI_productInfo_s MCGIDI_productInfo;
typedef struct MCGIDI_sampledProductsData_s MCGIDI_sampledProductsData;
typedef struct MCGIDI_sampledProductsDatas_s MCGIDI_sampledProductsDatas;
#if defined __cplusplus
}
}
#endif
enum MCGIDI_quantityLookupMode {
MCGIDI_quantityLookupMode_pointwise /**< Pointwise data are used to determine a quantity's value an energy E. */,
MCGIDI_quantityLookupMode_grouped /**< Grouped data are used to determine a quantity's value an energy E. */
};
class MCGIDI_quantitiesLookupModes {
private:
int mProjectilesPOPID;
double mProjectileEnergy;
int mGroupIndex;
double mProjectileEnergyForGroupIndex;
double mTemperature;
enum MCGIDI_quantityLookupMode mCrossSectionMode;
enum MCGIDI_quantityLookupMode mMultiplicityMode;
public:
MCGIDI_quantitiesLookupModes( int projectilesPOPID );
~MCGIDI_quantitiesLookupModes( );
inline double getProjectileEnergy( void ) const { return( mProjectileEnergy ); }
void setProjectileEnergy( double e_in ) { mProjectileEnergy = e_in; }
inline int getGroupIndex( void ) const { return( mGroupIndex ); }
int setGroupIndex( GIDI_settings const &settings, bool encloseOutOfRange );
inline double getTemperature( void ) const { return( mTemperature ); }
void setTemperature( double temperature ) { mTemperature = temperature; }
enum MCGIDI_quantityLookupMode getMode( std::string const &quantity ) const;
enum MCGIDI_quantityLookupMode getCrossSectionMode( void ) const { return( mCrossSectionMode ); };
std::vector<std::string> getListOfLookupQuanities( ) const;
void setMode( std::string const &quantity, enum MCGIDI_quantityLookupMode mode );
void setCrossSectionMode( enum MCGIDI_quantityLookupMode mode ) { mCrossSectionMode = mode; };
void setModeAll( enum MCGIDI_quantityLookupMode mode );
};
typedef struct MCGIDI_samplingMultiplicityBias_s MCGIDI_samplingMultiplicityBias;
struct MCGIDI_samplingMultiplicityBias_s {
int PoPID;
double multiplicityFactor;
};
class MCGIDI_samplingMethods {
public:
MCGIDI_samplingMethods( );
~MCGIDI_samplingMethods( );
};
class MCGIDI_samplingSettings {
private: // This is user input.
enum GIDI::xDataTOM_frame mWantFrame;
bool mWantVelocities;
double (*mRng)( void * );
void *mRngState;
std::vector<struct MCGIDI_samplingMultiplicityBias_s> mSamplingMultiplicityBiases;
public: // Temporary variables used in MCGIDI sampling routines.
enum GIDI::xDataTOM_frame mGotFrame;
GIDI::MCGIDI_POP *mPoP;
double mMu;
double mEp;
public:
MCGIDI_samplingSettings( enum GIDI::xDataTOM_frame frame, bool wantVelocities, double (*rng)( void * ), void *rngState );
~MCGIDI_samplingSettings( );
inline double getProductMultiplicityBias( int PoPID ) const {
for( int i1 = 0; i1 < (int) mSamplingMultiplicityBiases.size( ); ++i1 ) {
if( PoPID == mSamplingMultiplicityBiases[i1].PoPID ) return( mSamplingMultiplicityBiases[i1].multiplicityFactor );
}
return( 1. ); }
int setProductMultiplicityBias( GIDI::statusMessageReporting *smr, int PoPID, double fractor );
};
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
enum MCGIDI_transportability { /**< This enum is used to give the transportability status for a particle in a reaction or target. */
MCGIDI_transportability_unknown, /**< Particle is not a product of this reaction or target. */
MCGIDI_transportability_none, /**< Particle is a product but has not distribution data. */
MCGIDI_transportability_partial, /**< Particle is a product and has some distribution data. */
MCGIDI_transportability_full }; /**< Particle is a product and all needed distribution data. */
#if defined __cplusplus
}
}
#endif
typedef std::map<int, enum GIDI::MCGIDI_transportability> transportabilitiesMap;
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
#define MCGIDI_crossSectionType_grouped 1
#define MCGIDI_crossSectionType_pointwise 2
#define MCGIDI_nullReaction -10001
#define MCGIDI_speedOfLight_cm_sec 2.99792458e10
#define MCGIDI_AMU2MeV 931.494028
enum MCGIDI_reactionType {
MCGIDI_reactionType_unknown_e, /* This should never happen. */
MCGIDI_reactionType_null_e, /* Only occurs when sampling with from grouped cross sections and the projectile is below threshold. */
MCGIDI_reactionType_elastic_e, /* A nuclear elastic reaction. */
MCGIDI_reactionType_scattering_e, /* A nuclear reaction where the projectile and target are products as well as gammas,
excluding reactions that are MCGIDI_reactionType_elastic_e and
MCGIDI_reactionType_nuclearLevelTransition_e. */
MCGIDI_reactionType_nuclearIsomerTransmutation_e, /* A nuclear that changes N or Z and is not one of the others.*/
MCGIDI_reactionType_nuclearLevelTransition_e, /* Reaction in which the residual is the same isotope as the target but in a
different nuclear level. Mainly for meta-stables. */
MCGIDI_reactionType_capture_e, /* A nuclear capture reaction. */
MCGIDI_reactionType_fission_e, /* A nuclear fission reaction. */
MCGIDI_reactionType_sumOfRemainingOutputChannels_e, /* ENDF MT 5 reactions. */
MCGIDI_reactionType_atomic_e
};
enum MCGIDI_channelGenre { MCGIDI_channelGenre_undefined_e, MCGIDI_channelGenre_twoBody_e, MCGIDI_channelGenre_uncorrelated_e,
MCGIDI_channelGenre_sumOfRemaining_e, MCGIDI_channelGenre_twoBodyDecay_e, MCGIDI_channelGenre_uncorrelatedDecay_e };
enum MCGIDI_productMultiplicityType { MCGIDI_productMultiplicityType_invalid_e, MCGIDI_productMultiplicityType_unknown_e, MCGIDI_productMultiplicityType_integer_e,
MCGIDI_productMultiplicityType_energyDependent_e, MCGIDI_productMultiplicityType_gammaBranching_e, MCGIDI_productMultiplicityType_mixed_e };
enum MCGIDI_distributionType { MCGIDI_distributionType_none_e, MCGIDI_distributionType_unknown_e, MCGIDI_distributionType_angular_e,
MCGIDI_distributionType_KalbachMann_e, MCGIDI_distributionType_uncorrelated_e, MCGIDI_distributionType_energyAngular_e,
MCGIDI_distributionType_angularEnergy_e };
enum MCGIDI_angularType { MCGIDI_angularType_isotropic, MCGIDI_angularType_recoil, MCGIDI_angularType_linear };
enum MCGIDI_energyType { MCGIDI_energyType_unknown, MCGIDI_energyType_primaryGamma, MCGIDI_energyType_discreteGamma,
MCGIDI_energyType_linear, MCGIDI_energyType_generalEvaporation, MCGIDI_energyType_simpleMaxwellianFission, MCGIDI_energyType_evaporation,
MCGIDI_energyType_Watt, MCGIDI_energyType_MadlandNix, MCGIDI_energyType_NBodyPhaseSpace, MCGIDI_energyType_weightedFunctional };
extern const char *MCGIDI_productGenre_unknown, *MCGIDI_productGenre_twoBody_angular, *MCGIDI_productGenre_twoBody_formFactor,
*MCGIDI_productGenre_NBody_angular_energy, *MCGIDI_productGenre_NBody_pairProduction;
#define MCGIDI_particleLevel_continuum -1
#define MCGIDI_particleLevel_sum -2
struct MCGIDI_GammaBranching_s {
MCGIDI_POP *finalLevel;
double probability;
};
struct MCGIDI_POP_s {
MCGIDI_POP *next;
MCGIDI_POP *parent;
char *name;
int globalPoPsIndex; /* Index of particle in the PoPs library if particle can be return to packages using */
int Z, A, level, m; /* this library. Otherwise, -1. */
double mass_MeV;
double level_MeV;
int numberOfGammaBranchs;
MCGIDI_GammaBranching *gammas;
};
struct MCGIDI_POPs_s {
int numberOfPOPs, size, increment;
MCGIDI_POP *first, *last, **sorted;
};
struct MCGIDI_particle_s {
MCGIDI_particle *prior;
MCGIDI_particle *next;
int ordinal;
int Z, A, m;
double mass_MeV;
char *name;
};
struct MCGIDI_decaySamplingInfo_s {
enum xDataTOM_frame frame; /* The frame the product data are in. */
int isVelocity; /* See struct MCGIDI_sampledProductsData_s for meaning. This is user input. */
double (*rng)( void * ); /* User supplied rng. */
void *rngState; /* User supplied rng state. */
MCGIDI_POP *pop; /* pop for the sampled product. */
double mu; /* mu = cos( theta ) for the sampled product. Frame is given by frame member. */
double Ep; /* Energy of the product. Frame is given by frame member. */
};
struct MCGIDI_productInfo_s {
int globalPoPsIndex;
enum MCGIDI_productMultiplicityType productMultiplicityType;
int multiplicity;
int transportable;
};
struct MCGIDI_productsInfo_s {
int numberOfProducts;
int numberOfAllocatedProducts;
MCGIDI_productInfo *productInfo;
};
struct MCGIDI_sampledProductsData_s {
int isVelocity; /* If true, px_vx, py_vy and pz_vz are velocities otherwise momenta. */
MCGIDI_POP *pop;
double kineticEnergy;
double px_vx;
double py_vy;
double pz_vz;
int delayedNeutronIndex;
double delayedNeutronRate;
double birthTimeSec; /* Some products, like delayed fission neutrons, are to appear (be born) later. */
};
struct MCGIDI_sampledProductsDatas_s {
int numberOfProducts;
int numberAllocated;
int incrementSize;
MCGIDI_sampledProductsData *products;
};
struct MCGIDI_pdfOfX_s {
int numberOfXs;
double *Xs;
double *pdf;
double *cdf;
};
struct MCGIDI_pdfsOfXGivenW_s {
int numberOfWs;
ptwXY_interpolation interpolationWY, interpolationXY;
double *Ws;
MCGIDI_pdfOfX *dist;
};
struct MCGIDI_pdfsOfXGivenW_sampled_s {
statusMessageReporting *smr;
ptwXY_interpolation interpolationWY, interpolationXY;
int iW, iX1, iX2;
double x, w, frac;
};
struct MCGIDI_angular_s {
enum xDataTOM_frame frame;
enum MCGIDI_angularType type;
MCGIDI_angular *recoilProduct;
MCGIDI_pdfsOfXGivenW dists;
double projectileMass_MeV, targetMass_MeV, productMass_MeV, residualMass_MeV;
};
struct MCGIDI_energyWeightedFunctional_s {
ptwXYPoints *weight;
MCGIDI_energy *energy;
};
struct MCGIDI_energyWeightedFunctionals_s {
int numberOfWeights;
MCGIDI_energyWeightedFunctional weightedFunctional[4]; /* ??????????? Hardwired for no good reason. Will handle up to a (z,4n) reaction. */
};
struct MCGIDI_energyNBodyPhaseSpace_s {
int numberOfProducts;
double mass, massFactor, e_inCOMFactor, Q_MeV;
};
struct MCGIDI_energy_s {
enum xDataTOM_frame frame;
enum MCGIDI_energyType type;
double gammaEnergy_MeV;
double primaryGammaMassFactor;
double e_inCOMFactor;
MCGIDI_pdfsOfXGivenW dists;
double U;
ptwXYPoints *theta, *Watt_a, *Watt_b;
ptwXY_interpolation gInterpolation;
MCGIDI_pdfOfX g;
MCGIDI_energyWeightedFunctionals weightedFunctionals;
MCGIDI_energyNBodyPhaseSpace NBodyPhaseSpace;
};
struct MCGIDI_energyAngular_s {
enum xDataTOM_frame frame;
MCGIDI_pdfsOfXGivenW pdfOfEpGivenE;
MCGIDI_pdfsOfXGivenW *pdfOfMuGivenEAndEp; /* The number of MCGIDI_pdfsOfXGivenW allocated is given by pdfOfEpGivenE.numberOfWs. */
};
struct MCGIDI_angularEnergy_s {
enum xDataTOM_frame frame;
MCGIDI_pdfsOfXGivenW pdfOfMuGivenE;
MCGIDI_pdfsOfXGivenW *pdfOfEpGivenEAndMu; /* The number of MCGIDI_pdfsOfXGivenW allocated is given by pdfOfMuGivenE.numberOfWs. */
};
struct MCGIDI_KalbachMann_ras_s {
double *rs;
double *as;
};
struct MCGIDI_KalbachMann_s {
enum xDataTOM_frame frame;
double energyToMeVFactor, massFactor, Sa, Sb, Ma, mb; /* Needed if a(E,E') is caluclated from the formula. */
MCGIDI_pdfsOfXGivenW dists; /* Sa currently not used. */
MCGIDI_KalbachMann_ras *ras;
};
struct MCGIDI_distribution_s {
MCGIDI_product *product;
enum MCGIDI_distributionType type;
MCGIDI_angular *angular; /* All distribution forms must have a frame member. */
MCGIDI_energy *energy;
MCGIDI_energyAngular *energyAngular;
MCGIDI_angularEnergy *angularEnergy;
MCGIDI_KalbachMann *KalbachMann;
};
struct MCGIDI_outputChannel_s {
enum MCGIDI_channelGenre genre;
MCGIDI_reaction *reaction; /* This is only used for output channels. */
MCGIDI_product *parent; /* This is only used for decay channels. */
int QIsFloat;
double Q;
int numberOfProducts;
MCGIDI_product *products;
};
struct MCGIDI_product_s {
MCGIDI_POP *pop;
char *label;
MCGIDI_outputChannel *outputChannel;
int multiplicity; /* If 0, the multiplicity is either 'energyDependent' or 'partialProduction'. */
int delayedNeutronIndex;
double delayedNeutronRate;
ptwXYPoints *multiplicityVsEnergy;
ptwXYPoints *norms;
int numberOfPiecewiseMultiplicities;
ptwXYPoints **piecewiseMultiplicities;
MCGIDI_distribution distribution;
MCGIDI_outputChannel decayChannel;
};
struct MCGIDI_reaction_s {
MCGIDI_target_heated *target;
int ENDF_MT, ENDL_C, ENDL_S;
enum MCGIDI_reactionType reactionType;
char const *outputChannelStr;
xDataTOM_attributionList attributes; /* Do not free, owned by attributes. */
int domainValuesPresent; /* True if cross section data defined so EMin and EMax are value. */
int thresholdGroupIndex; /* For grouped data, the group index where threshold starts. */
double thresholdGroupDomain; /* This is groupEnergy[thresholdGroupIndex+1] - EMin. */
double thresholdGroupedDeltaCrossSection; /* The adjusted group cross section in group thresholdGroupIndex. */
double EMin, EMax, finalQ; /* BRB, EMin is used as threshold. However, some reactions, especially charged particle */
ptwXYPoints *crossSection; /* have effective thresholds much higher than EMin, may need to handle these differently??????? */
ptwXPoints *crossSectionGrouped;
MCGIDI_outputChannel outputChannel;
MCGIDI_productsInfo productsInfo; /* See MCGIDI_reaction_ParseDetermineReactionProducts for description. */
transportabilitiesMap *transportabilities;
};
struct MCGIDI_target_heated_s {
int ordinal;
char *path; /* Partial path of input file. */
char *absPath; /* Full absolute path of input file. */
MCGIDI_POPs pops;
MCGIDI_POP *projectilePOP;
MCGIDI_POP *targetPOP;
xDataTOM_attributionList attributes;
char *contents;
double temperature_MeV;
double EMin, EMax;
ptwXYPoints *crossSection;
ptwXPoints *crossSectionGrouped;
ptwXPoints *crossSectionGroupedForSampling;
int numberOfReactions;
MCGIDI_reaction *reactions;
transportabilitiesMap *transportabilities;
};
struct MCGIDI_target_heated_info_s {
int ordinal;
double temperature;
char *path; /* Full path of input file. */
char *contents;
MCGIDI_target_heated *heatedTarget;
};
struct MCGIDI_target_s {
char *path; /* Full path of input file. */
char *absPath; /* Full absolute path of input file. */
MCGIDI_POP *projectilePOP;
MCGIDI_POP *targetPOP;
xDataTOM_attributionList attributes;
int nHeatedTargets, nReadHeatedTargets;
MCGIDI_target_heated *baseHeatedTarget; /* The lowest temperature whose contents is "all" data, (e.g, not just "crossSection"). */
MCGIDI_target_heated_info *heatedTargets; /* List of heated targets in order by temperature. */
MCGIDI_target_heated_info **readHeatedTargets; /* List of "read in" heated targets in order by temperature. */
};
char const *MCGIDI_version( void );
int MCGIDI_versionMajor( void );
int MCGIDI_versionMinor( void );
int MCGIDI_versionPatchLevel( void );
/*
* Routines in MCGIDI_target.c
*/
MCGIDI_target *MCGIDI_target_new( statusMessageReporting *smr );
int MCGIDI_target_initialize( statusMessageReporting *smr, MCGIDI_target *target );
MCGIDI_target *MCGIDI_target_newRead( statusMessageReporting *smr, const char *fileName );
int MCGIDI_target_readFromMapViaPoPIDs( statusMessageReporting *smr, MCGIDI_target *target, MCGIDI_map *map, const char *evaluation,
int projectile_PoPID, int target_PoPID );
int MCGIDI_target_readFromMap( statusMessageReporting *smr, MCGIDI_target *target, MCGIDI_map *map, const char *evaluation, const char *projectileName,
const char *targetName );
MCGIDI_target *MCGIDI_target_newReadFromMapViaPoPIDs( statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation,
int projectile_PoPID, int target_PoPID );
MCGIDI_target *MCGIDI_target_newReadFromMap( statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, const char *projectileName,
const char *targetName );
MCGIDI_target *MCGIDI_target_free( statusMessageReporting *smr, MCGIDI_target *target );
int MCGIDI_target_release( statusMessageReporting *smr, MCGIDI_target *target );
int MCGIDI_target_read( statusMessageReporting *smr, MCGIDI_target *target, const char *fileName );
char const *MCGIDI_target_getAttributesValue( statusMessageReporting *smr, MCGIDI_target *target, char const *name );
int MCGIDI_target_getTemperatures( statusMessageReporting *smr, MCGIDI_target *target, double *temperatures );
int MCGIDI_target_readHeatedTarget( statusMessageReporting *smr, MCGIDI_target *target, int index );
MCGIDI_target_heated *MCGIDI_target_getHeatedTargetAtIndex_ReadIfNeeded( statusMessageReporting *smr, MCGIDI_target *target, int index );
MCGIDI_target_heated *MCGIDI_target_getHeatedTargetAtTIndex( statusMessageReporting *smr, MCGIDI_target *target, int index );
int MCGIDI_target_numberOfReactions( statusMessageReporting *smr, MCGIDI_target *target );
enum MCGIDI_reactionType MCGIDI_target_getReactionTypeAtIndex( statusMessageReporting *smr, MCGIDI_target *target, int index );
MCGIDI_reaction *MCGIDI_target_getReactionAtIndex( MCGIDI_target *target, int index );
MCGIDI_reaction *MCGIDI_target_getReactionAtIndex_smr( statusMessageReporting *smr, MCGIDI_target *target, int index );
int MCGIDI_target_numberOfProductionReactions( statusMessageReporting *smr, MCGIDI_target *target );
transportabilitiesMap const *MCGIDI_target_getUniqueProducts( statusMessageReporting *smr, MCGIDI_target *target );
int MCGIDI_target_recast( statusMessageReporting *smr, MCGIDI_target *target, GIDI_settings &settings );
int MCGIDI_target_getDomain( statusMessageReporting *smr, MCGIDI_target *target, double *EMin, double *EMax );
double MCGIDI_target_getTotalCrossSectionAtTAndE( statusMessageReporting *smr, MCGIDI_target *target, MCGIDI_quantitiesLookupModes &modes,
bool sampling );
double MCGIDI_target_getIndexReactionCrossSectionAtE( statusMessageReporting *smr, MCGIDI_target *target, int index, MCGIDI_quantitiesLookupModes &modes,
bool sampling );
int MCGIDI_target_sampleReaction( statusMessageReporting *smr, MCGIDI_target *target, MCGIDI_quantitiesLookupModes &modes, double totalXSec,
double (*userrng)( void * ), void *rngState );
int MCGIDI_target_sampleNullReactionProductsAtE( statusMessageReporting *smr, MCGIDI_target *target,
MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo, MCGIDI_sampledProductsDatas *productDatas );
int MCGIDI_target_sampleIndexReactionProductsAtE( statusMessageReporting *smr, MCGIDI_target *target, int index,
MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo, MCGIDI_sampledProductsDatas *productData );
double MCGIDI_target_getIndexReactionFinalQ( statusMessageReporting *smr, MCGIDI_target *target, int index, MCGIDI_quantitiesLookupModes &modes );
/*
* Routines in MCGIDI_target_heated.c
*/
MCGIDI_target_heated *MCGIDI_target_heated_new( statusMessageReporting *smr );
int MCGIDI_target_heated_initialize( statusMessageReporting *smr, MCGIDI_target_heated *target );
MCGIDI_target_heated *MCGIDI_target_heated_newRead( statusMessageReporting *smr, const char *fileName );
MCGIDI_target_heated *MCGIDI_target_heated_free( statusMessageReporting *smr, MCGIDI_target_heated *target );
int MCGIDI_target_heated_release( statusMessageReporting *smr, MCGIDI_target_heated *target );
int MCGIDI_target_heated_read( statusMessageReporting *smr, MCGIDI_target_heated *target, const char *fileName );
int MCGIDI_target_heated_numberOfReactions( statusMessageReporting *smr, MCGIDI_target_heated *target );
int MCGIDI_target_heated_numberOfProductionReactions( statusMessageReporting *smr, MCGIDI_target_heated *target );
MCGIDI_reaction *MCGIDI_target_heated_getReactionAtIndex( MCGIDI_target_heated *target, int index );
MCGIDI_reaction *MCGIDI_target_heated_getReactionAtIndex_smr( statusMessageReporting *smr, MCGIDI_target_heated *target, int index );
#if 0
MCGIDI_reaction *MCGIDI_target_heated_getProductionReactionAtIndex( MCGIDI_target_heated *target, int index );
#endif
MCGIDI_POP *MCGIDI_target_heated_getPOPForProjectile( statusMessageReporting *smr, MCGIDI_target_heated *target );
MCGIDI_POP *MCGIDI_target_heated_getPOPForTarget( statusMessageReporting *smr, MCGIDI_target_heated *target );
double MCGIDI_target_heated_getProjectileMass_MeV( statusMessageReporting *smr, MCGIDI_target_heated *target );
double MCGIDI_target_heated_getTargetMass_MeV( statusMessageReporting *smr, MCGIDI_target_heated *target );
int MCGIDI_target_heated_getEnergyGrid( statusMessageReporting *smr, MCGIDI_target_heated *target, double **energyGrid );
double MCGIDI_target_heated_getTotalCrossSectionAtE( statusMessageReporting *smr, MCGIDI_target_heated *target, MCGIDI_quantitiesLookupModes &modes,
bool sampling );
double MCGIDI_target_heated_getIndexReactionCrossSectionAtE( statusMessageReporting *smr, MCGIDI_target_heated *target, int index,
MCGIDI_quantitiesLookupModes &modes, bool sampling );
int MCGIDI_target_heated_sampleIndexReactionProductsAtE( statusMessageReporting *smr, MCGIDI_target_heated *target, int index,
MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo, MCGIDI_sampledProductsDatas *productData );
double MCGIDI_target_heated_getReactionsThreshold( statusMessageReporting *smr, MCGIDI_target_heated *target, int index );
int MCGIDI_target_heated_getReactionsDomain( statusMessageReporting *smr, MCGIDI_target_heated *target, int index, double *EMin, double *EMax );
double MCGIDI_target_heated_getIndexReactionFinalQ( statusMessageReporting *smr, MCGIDI_target_heated *target, int index,
MCGIDI_quantitiesLookupModes &modes );
transportabilitiesMap const *MCGIDI_target_heated_getUniqueProducts( statusMessageReporting *smr, MCGIDI_target_heated *target );
int MCGIDI_target_heated_recast( statusMessageReporting *smr, MCGIDI_target_heated *target, GIDI_settings &settings );
/*
* Routines in MCGIDI_reaction.c
*/
MCGIDI_reaction *MCGIDI_reaction_new( statusMessageReporting *smr );
int MCGIDI_reaction_initialize( statusMessageReporting *smr, MCGIDI_reaction *reaction );
MCGIDI_reaction *MCGIDI_reaction_free( statusMessageReporting *smr, MCGIDI_reaction *reaction );
int MCGIDI_reaction_release( statusMessageReporting *smr, MCGIDI_reaction *reaction );
int MCGIDI_reaction_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_target_heated *target,
MCGIDI_POPs *pops, MCGIDI_reaction *reaction );
enum MCGIDI_reactionType MCGIDI_reaction_getReactionType( statusMessageReporting *smr, MCGIDI_reaction *reaction );
MCGIDI_target_heated *MCGIDI_reaction_getTargetHeated( statusMessageReporting *smr, MCGIDI_reaction *reaction );
double MCGIDI_reaction_getProjectileMass_MeV( statusMessageReporting *smr, MCGIDI_reaction *reaction );
double MCGIDI_reaction_getTargetMass_MeV( statusMessageReporting *smr, MCGIDI_reaction *reaction );
int MCGIDI_reaction_getDomain( statusMessageReporting *smr, MCGIDI_reaction *reaction, double *EMin, double *EMax );
int MCGIDI_reaction_fixDomains( statusMessageReporting *smr, MCGIDI_reaction *reaction, double EMin, double EMax, nfu_status *status );
double MCGIDI_reaction_getCrossSectionAtE( statusMessageReporting *smr, MCGIDI_reaction *reaction, MCGIDI_quantitiesLookupModes &modes, bool sampling );
double MCGIDI_reaction_getFinalQ( statusMessageReporting *smr, MCGIDI_reaction *reaction, MCGIDI_quantitiesLookupModes &modes );
int MCGIDI_reaction_getENDF_MTNumber( MCGIDI_reaction *reaction );
int MCGIDI_reaction_getENDL_CSNumbers( MCGIDI_reaction *reaction, int *S );
int MCGIDI_reaction_recast( statusMessageReporting *smr, MCGIDI_reaction *reaction, GIDI_settings &settings,
GIDI_settings_particle const *projectileSettings, double temperature_MeV, ptwXPoints *totalGroupedCrossSection );
MCGIDI_productsInfo *MCGIDI_reaction_getProductsInfo( MCGIDI_reaction *reaction );
int MCGIDI_productsInfo_getNumberOfUniqueProducts( MCGIDI_productsInfo *productsInfo );
int MCGIDI_productsInfo_getPoPsIndexAtIndex( MCGIDI_productsInfo *productsInfo, int index );
enum MCGIDI_productMultiplicityType MCGIDI_productsInfo_getMultiplicityTypeAtIndex( MCGIDI_productsInfo *productsInfo, int index );
int MCGIDI_productsInfo_getIntegerMultiplicityAtIndex( MCGIDI_productsInfo *productsInfo, int index );
int MCGIDI_productsInfo_getTransportableAtIndex( MCGIDI_productsInfo *productsInfo, int index );
/*
* Routines in MCGIDI_pop.c
*/
MCGIDI_POPs *MCGIDI_POPs_new( statusMessageReporting *smr, int size );
int MCGIDI_POPs_initial( statusMessageReporting *smr, MCGIDI_POPs *pops, int size );
void *MCGIDI_POPs_free( MCGIDI_POPs *pops );
int MCGIDI_POPs_release( MCGIDI_POPs *pops );
MCGIDI_POP *MCGIDI_POPs_addParticleIfNeeded( statusMessageReporting *smr, MCGIDI_POPs *pops, char const *name, double mass_MeV,
double level_MeV, MCGIDI_POP *parent, int globalParticle );
int MCGIDI_POPs_findParticleIndex( MCGIDI_POPs *pops, char const *name );
MCGIDI_POP *MCGIDI_POPs_findParticle( MCGIDI_POPs *pops, char const *name );
void MCGIDI_POPs_writeSortedList( MCGIDI_POPs *pops, FILE *f );
void MCGIDI_POPs_printSortedList( MCGIDI_POPs *pops );
MCGIDI_POP *MCGIDI_POP_new( statusMessageReporting *smr, char const *name, double mass_MeV, double level_MeV, MCGIDI_POP *parent );
MCGIDI_POP *MCGIDI_POP_free( MCGIDI_POP *pop );
MCGIDI_POP *MCGIDI_POP_release( MCGIDI_POP *pop );
double MCGIDI_POP_getMass_MeV( MCGIDI_POP *pop );
/*
* Routines in MCGIDI_particle.c
*/
MCGIDI_particle *MCGIDI_particle_new( statusMessageReporting *smr );
int MCGIDI_particle_initialize( statusMessageReporting *smr, MCGIDI_particle *particle );
MCGIDI_particle *MCGIDI_particle_free( statusMessageReporting *smr, MCGIDI_particle *particle );
int MCGIDI_particle_release( statusMessageReporting *smr, MCGIDI_particle *particle );
int MCGIDI_particle_freeInternalList( statusMessageReporting *smr );
MCGIDI_particle *MCGIDI_particle_getInternalID( statusMessageReporting *smr, const char * const name, MCGIDI_POPs *pops );
int MCGIDI_particle_printInternalSortedList( statusMessageReporting *smr );
/*
* Routines in MCGIDI_outputChannel.c
*/
MCGIDI_outputChannel *MCGIDI_outputChannel_new( statusMessageReporting *smr );
int MCGIDI_outputChannel_initialize( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel );
MCGIDI_outputChannel *MCGIDI_outputChannel_free( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel );
int MCGIDI_outputChannel_release( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel );
int MCGIDI_outputChannel_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_POPs *pops, MCGIDI_outputChannel *outputChannel,
MCGIDI_reaction *reaction, MCGIDI_product *parent );
int MCGIDI_outputChannel_numberOfProducts( MCGIDI_outputChannel *outputChannel );
MCGIDI_product *MCGIDI_outputChannel_getProductAtIndex( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel, int i );
int MCGIDI_outputChannel_getDomain( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel, double *EMin, double *EMax );
MCGIDI_target_heated *MCGIDI_outputChannel_getTargetHeated( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel );
double MCGIDI_outputChannel_getProjectileMass_MeV( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel );
double MCGIDI_outputChannel_getTargetMass_MeV( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel );
double MCGIDI_outputChannel_getQ_MeV( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel, double e_in );
double MCGIDI_outputChannel_getFinalQ( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel, double e_in );
int MCGIDI_outputChannel_sampleProductsAtE( statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel, MCGIDI_quantitiesLookupModes &modes,
MCGIDI_decaySamplingInfo *decaySamplingInfo, MCGIDI_sampledProductsDatas *productDatas, double *masses );
/*
* Routines in MCGIDI_product.c
*/
MCGIDI_product *MCGIDI_product_new( statusMessageReporting *smr );
int MCGIDI_product_initialize( statusMessageReporting *smr, MCGIDI_product *product );
MCGIDI_product *MCGIDI_product_free( statusMessageReporting *smr, MCGIDI_product *product );
int MCGIDI_product_release( statusMessageReporting *smr, MCGIDI_product *product );
int MCGIDI_product_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_outputChannel *outputChannel,
MCGIDI_POPs *pops, MCGIDI_product *product, int *delayedNeutronIndex );
int MCGIDI_product_getDomain( statusMessageReporting *smr, MCGIDI_product *product, double *EMin, double *EMax );
int MCGIDI_product_setTwoBodyMasses( statusMessageReporting *smr, MCGIDI_product *product, double projectileMass_MeV, double targetMass_MeV,
double productMass_MeV, double residualMass_MeV );
double MCGIDI_product_getMass_MeV( statusMessageReporting *smr, MCGIDI_product *product );
MCGIDI_target_heated *MCGIDI_product_getTargetHeated( statusMessageReporting *smr, MCGIDI_product *product );
double MCGIDI_product_getProjectileMass_MeV( statusMessageReporting *smr, MCGIDI_product *product );
double MCGIDI_product_getTargetMass_MeV( statusMessageReporting *smr, MCGIDI_product *product );
int MCGIDI_product_sampleMultiplicity( statusMessageReporting *smr, MCGIDI_product *product, double e_in, double r );
int MCGIDI_product_sampleMu( statusMessageReporting *smr, MCGIDI_product *product, MCGIDI_quantitiesLookupModes &modes,
MCGIDI_decaySamplingInfo *decaySamplingInfo );
int MCGIDI_sampledProducts_initialize( statusMessageReporting *smr, MCGIDI_sampledProductsDatas *sampledProductsDatas, int incrementSize );
int MCGIDI_sampledProducts_release( statusMessageReporting *smr, MCGIDI_sampledProductsDatas *sampledProductsDatas );
int MCGIDI_sampledProducts_remalloc( statusMessageReporting *smr, MCGIDI_sampledProductsDatas *sampledProductsDatas );
int MCGIDI_sampledProducts_addProduct( statusMessageReporting *smr, MCGIDI_sampledProductsDatas *sampledProductsDatas,
MCGIDI_sampledProductsData *sampledProductsData );
int MCGIDI_sampledProducts_number( MCGIDI_sampledProductsDatas *sampledProductsDatas );
MCGIDI_sampledProductsData *MCGIDI_sampledProducts_getProductAtIndex( MCGIDI_sampledProductsDatas *sampledProductsDatas, int index );
/*
* Routines in MCGIDI_distribution.c
*/
MCGIDI_distribution *MCGIDI_distribution_new( statusMessageReporting *smr );
int MCGIDI_distribution_initialize( statusMessageReporting *smr, MCGIDI_distribution *distribution );
MCGIDI_distribution *MCGIDI_distribution_free( statusMessageReporting *smr, MCGIDI_distribution *distribution );
int MCGIDI_distribution_release( statusMessageReporting *smr, MCGIDI_distribution *distribution );
int MCGIDI_distribution_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_product *product, MCGIDI_POPs *pops, ptwXYPoints *norms );
/*
* Routines in MCGIDI_angular.c
*/
MCGIDI_angular *MCGIDI_angular_new( statusMessageReporting *smr );
int MCGIDI_angular_initialize( statusMessageReporting *smr, MCGIDI_angular *angular );
MCGIDI_angular *MCGIDI_angular_free( statusMessageReporting *smr, MCGIDI_angular *angular );
int MCGIDI_angular_release( statusMessageReporting *smr, MCGIDI_angular *angular );
int MCGIDI_angular_setTwoBodyMasses( statusMessageReporting *smr, MCGIDI_angular *angular, double projectileMass_MeV, double targetMass_MeV,
double productMass_MeV, double residualMass_MeV );
int MCGIDI_angular_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution, ptwXYPoints *norms );
int MCGIDI_angular_sampleMu( statusMessageReporting *smr, MCGIDI_angular *angular, MCGIDI_quantitiesLookupModes &modes,
MCGIDI_decaySamplingInfo *decaySamplingInfo );
/*
* Routines in MCGIDI_energy.c
*/
MCGIDI_energy *MCGIDI_energy_new( statusMessageReporting *smr );
int MCGIDI_energy_initialize( statusMessageReporting *smr, MCGIDI_energy *energy );
MCGIDI_energy *MCGIDI_energy_free( statusMessageReporting *smr, MCGIDI_energy *energy );
int MCGIDI_energy_release( statusMessageReporting *smr, MCGIDI_energy *energy );
int MCGIDI_energy_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution, ptwXYPoints *norms,
enum MCGIDI_energyType energyType, double gammaEnergy_MeV );
int MCGIDI_energy_sampleEnergy( statusMessageReporting *smr, MCGIDI_energy *energy, MCGIDI_quantitiesLookupModes &modes,
MCGIDI_decaySamplingInfo *decaySamplingInfo );
/*
* Routines in MCGIDI_energyAngular.c
*/
int MCGIDI_energyAngular_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution );
MCGIDI_energyAngular *MCGIDI_energyAngular_new( statusMessageReporting *smr );
int MCGIDI_energyAngular_initialize( statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular );
MCGIDI_energyAngular *MCGIDI_energyAngular_free( statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular );
int MCGIDI_energyAngular_release( statusMessageReporting *smr, MCGIDI_energyAngular *energyAngular );
int MCGIDI_energyAngular_sampleDistribution( statusMessageReporting *smr, MCGIDI_distribution *distribution, MCGIDI_quantitiesLookupModes &modes,
MCGIDI_decaySamplingInfo *decaySamplingInfo );
/*
* Routines in MCGIDI_angularEnergy.c
*/
MCGIDI_angularEnergy *MCGIDI_angularEnergy_new( statusMessageReporting *smr );
int MCGIDI_angularEnergy_initialize( statusMessageReporting *smr, MCGIDI_angularEnergy *energyAngular );
MCGIDI_angularEnergy *MCGIDI_angularEnergy_free( statusMessageReporting *smr, MCGIDI_angularEnergy *energyAngular );
int MCGIDI_angularEnergy_release( statusMessageReporting *smr, MCGIDI_angularEnergy *energyAngular );
int MCGIDI_angularEnergy_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution );
int MCGIDI_angularEnergy_sampleDistribution( statusMessageReporting *smr, MCGIDI_angularEnergy *angularEnergy, MCGIDI_quantitiesLookupModes &modes,
MCGIDI_decaySamplingInfo *decaySamplingInfo );
/*
* Routines in MCGIDI_KalbachMann.c
*/
MCGIDI_KalbachMann *MCGIDI_KalbachMann_new( statusMessageReporting *smr, ptwXY_interpolation interpolationWY, ptwXY_interpolation interpolationXY );
int MCGIDI_KalbachMann_initialize( statusMessageReporting *smr, MCGIDI_KalbachMann *KalbachMann, ptwXY_interpolation interpolationWY, ptwXY_interpolation interpolationXY );
MCGIDI_KalbachMann *MCGIDI_KalbachMann_free( statusMessageReporting *smr, MCGIDI_KalbachMann *KalbachMann );
int MCGIDI_KalbachMann_release( statusMessageReporting *smr, MCGIDI_KalbachMann *KalbachMann );
int MCGIDI_KalbachMann_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution );
int MCGIDI_KalbachMann_sampleEp( statusMessageReporting *smr, MCGIDI_KalbachMann *KalbachMann, MCGIDI_quantitiesLookupModes &modes,
MCGIDI_decaySamplingInfo *decaySamplingInfo );
/*
* Routines in MCGIDI_uncorrelated.c
*/
int MCGIDI_uncorrelated_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution, ptwXYPoints *norms,
enum MCGIDI_energyType energyType, double gammaEnergy_MeV );
int MCGIDI_uncorrelated_sampleDistribution( statusMessageReporting *smr, MCGIDI_distribution *distribution, MCGIDI_quantitiesLookupModes &modes,
MCGIDI_decaySamplingInfo *decaySamplingInfo );
/*
* Routines in MCGIDI_LLNLAngular_angularEnergy.c
*/
int MCGIDI_LLNLAngular_angularEnergy_parseFromTOM( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_distribution *distribution );
/*
* Routines in MCGIDI_kinetics.c
*/
int MCGIDI_kinetics_2BodyReaction( statusMessageReporting *smr, MCGIDI_angular *angular, double K, double mu, double phi,
MCGIDI_sampledProductsData *outgoingData );
int MCGIDI_kinetics_COMKineticEnergy2LabEnergyAndMomentum( statusMessageReporting *smr, double beta, double e_kinetic_com, double mu, double phi,
double m3cc, double m4cc, MCGIDI_sampledProductsData *outgoingData );
int MCGIDI_kinetics_COM2Lab( statusMessageReporting *smr, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo, double masses[3] );
/*
* Routines in MCGIDI_sampling.c
*/
int MCGIDI_sampling_pdfsOfXGivenW_initialize( statusMessageReporting *smr, MCGIDI_pdfsOfXGivenW *dists );
int MCGIDI_sampling_pdfsOfXGivenW_release( statusMessageReporting *smr, MCGIDI_pdfsOfXGivenW *dists );
int MCGIDI_sampling_pdfsOfX_release( statusMessageReporting *smr, MCGIDI_pdfOfX *dist );
int MCGIDI_sampling_sampleX_from_pdfsOfXGivenW( MCGIDI_pdfsOfXGivenW *dists, MCGIDI_pdfsOfXGivenW_sampled *sampled, double r );
int MCGIDI_sampling_sampleX_from_pdfOfX( MCGIDI_pdfOfX *dist, MCGIDI_pdfsOfXGivenW_sampled *sampled, double r );
int MCGIDI_sampling_doubleDistribution( statusMessageReporting *smr, MCGIDI_pdfsOfXGivenW *pdfOfWGivenV, MCGIDI_pdfsOfXGivenW *pdfOfXGivenVAndW,
MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo );
int MCGIDI_sampling_interpolationValues( statusMessageReporting *smr, ptwXY_interpolation interpolation, double *ws, double y1, double y2, double *y );
double MCGIDI_sampling_ptwXY_getValueAtX( ptwXYPoints *ptwXY, double x1 );
/*
* Routines in MCGIDI_misc.c
*/
int MCGIDI_misc_NumberOfZSymbols( void );
const char *MCGIDI_misc_ZToSymbol( int iZ );
int MCGIDI_misc_symbolToZ( const char *Z );
int MCGIDI_miscNameToZAm( statusMessageReporting *smr, const char *name, int *Z, int *A, int *m, int *level );
xDataTOM_Int MCGIDI_misc_binarySearch( xDataTOM_Int n, double *ds, double d );
int MCGIDI_misc_PQUStringToDouble( statusMessageReporting *smr, char const *str, char const *unit, double conversion, double *value );
int MCGIDI_misc_PQUStringToDoubleInUnitOf( statusMessageReporting *smr, char const *str, char const *toUnit, double *value );
void MCGIDI_misc_updateTransportabilitiesMap( transportabilitiesMap *transportabilities, int PoPID, enum MCGIDI_transportability transportability );
void MCGIDI_misc_updateTransportabilitiesMap2( transportabilitiesMap *transportabilities, int PoPID, int transportable );
#if defined __cplusplus
}
}
#endif
#endif /* End of MCGIDI_h_included. */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,463 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef MCGIDI_distributions_hpp_included
#define MCGIDI_distributions_hpp_included 1
#include <LUPI_declareMacro.hpp>
namespace MCGIDI {
namespace Distributions {
enum class Type { none, unspecified, angularTwoBody, KalbachMann, uncorrelated, branching3d, energyAngularMC, angularEnergyMC,
coherentPhotoAtomicScattering, incoherentPhotoAtomicScattering, incoherentPhotoAtomicScatteringElectron, incoherentBoundToFreePhotoAtomicScattering, pairProductionGamma,
coherentElasticTNSL, incoherentElasticTNSL };
/*
============================================================
======================= Distribution =======================
============================================================
*/
class Distribution {
private:
Type m_type; /**< Specifies the Type of the distribution. */
GIDI::Frame m_productFrame; /**< Specifies the frame the product data are given in. */
double m_projectileMass; /**< The mass of the projectile. */
double m_targetMass; /**< The mass of the target. */
double m_productMass; /**< The mass of the first product. */
public:
LUPI_HOST_DEVICE Distribution( );
LUPI_HOST Distribution( Type a_type, GIDI::Distributions::Distribution const &a_distribution, SetupInfo &a_setupInfo );
LUPI_HOST Distribution( Type a_type, GIDI::Frame a_productFrame, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION ~Distribution( ) MCGIDI_TRUE_VIRTUAL;
LUPI_HOST_DEVICE Type type( ) const { return( m_type ); } /**< Returns the value of the **m_type**. */
LUPI_HOST_DEVICE GIDI::Frame productFrame( ) const { return( m_productFrame ); } /**< Returns the value of the **m_productFrame**. */
LUPI_HOST_DEVICE double projectileMass( ) const { return( m_projectileMass ); } /**< Returns the value of the **m_projectileMass**. */
LUPI_HOST_DEVICE double targetMass( ) const { return( m_targetMass ); } /**< Returns the value of the **m_targetMass**. */
LUPI_HOST_DEVICE double productMass( ) const { return( m_productMass ); } /**< Returns the value of the **m_productMass**. */
LUPI_HOST void setModelDBRC_data( Sampling::Upscatter::ModelDBRC_data *a_modelDBRC_data );
template <typename RNG>
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const MCGIDI_TRUE_VIRTUAL;
template <typename RNG>
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const MCGIDI_TRUE_VIRTUAL;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
====================== AngularTwoBody ======================
============================================================
*/
class AngularTwoBody : public Distribution {
private:
double m_residualMass; /**< The mass of the second product (often the residual). */
double m_Q; /**< FIX ME. */
double m_twoBodyThreshold; /**< This is the T_1 value needed to do two-body kinematics (i.e., in the equation (K_{com,3_4} = m_2 * (K_1 - T_1) / (m_1 + m_2)). */
bool m_Upscatter; /**< Set to true if reaction is elastic which is the only reaction upscatter Model B is applied to. */
Probabilities::ProbabilityBase2d_d1 *m_angular; /**< The 2d angular probability. */
Sampling::Upscatter::ModelDBRC_data *m_modelDBRC_data; /**< The cross section and other data needed for neutron elastic upscatter model DBRC. */
template <typename RNG>
LUPI_HOST_DEVICE bool upscatterModelB( double a_kineticLab, Sampling::Input &a_input, RNG && a_rng ) const ;
public:
LUPI_HOST_DEVICE AngularTwoBody( );
LUPI_HOST AngularTwoBody( GIDI::Distributions::AngularTwoBody const &a_angularTwoBody, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~AngularTwoBody( );
LUPI_HOST_DEVICE double residualMass( ) const { return( m_residualMass ); } /**< Returns the value of the **m_residualMass**. */
LUPI_HOST_DEVICE double Q( ) const { return( m_Q ); } /**< Returns the value of the **m_Q**. */
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d_d1 *angular( ) const { return( m_angular ); } /**< Returns the value of the **m_angular**. */
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
LUPI_HOST_DEVICE bool Upscatter( ) const { return( m_Upscatter ); } /**< Returns the value of the **m_Upscatter**. */
LUPI_HOST void setModelDBRC_data2( Sampling::Upscatter::ModelDBRC_data *a_modelDBRC_data );
};
/*
============================================================
======================= Uncorrelated =======================
============================================================
*/
class Uncorrelated : public Distribution {
private:
Probabilities::ProbabilityBase2d_d1 *m_angular; /**< The angular probability P(mu|E). */
Probabilities::ProbabilityBase2d *m_energy; /**< The energy probability P(E'|E). */
public:
LUPI_HOST_DEVICE Uncorrelated( );
LUPI_HOST Uncorrelated( GIDI::Distributions::Uncorrelated const &a_uncorrelated, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~Uncorrelated( );
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d_d1 *angular( ) const { return( m_angular ); } /**< Returns the value of the **m_angular**. */
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d *energy( ) const { return( m_energy ); } /**< Returns the value of the **m_energy**. */
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
======================== Branching3d =======================
============================================================
*/
class Branching3d : public Distribution {
private:
int m_initialStateIndex;
public:
LUPI_HOST_DEVICE Branching3d( );
LUPI_HOST Branching3d( GIDI::Distributions::Branching3d const &a_branching3d, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~Branching3d( );
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
====================== EnergyAngularMC =====================
============================================================
*/
class EnergyAngularMC : public Distribution {
private:
Probabilities::ProbabilityBase2d_d1 *m_energy; /**< The energy probability P(E'|E). */
Probabilities::ProbabilityBase3d *m_angularGivenEnergy; /**< The angular probability given E', P(mu|E,E'). */
public:
LUPI_HOST_DEVICE EnergyAngularMC( );
LUPI_HOST EnergyAngularMC( GIDI::Distributions::EnergyAngularMC const &a_energyAngularMC, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~EnergyAngularMC( );
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d_d1 *energy( ) const { return( m_energy ); } /**< Returns the value of the **m_energy**. */
LUPI_HOST_DEVICE Probabilities::ProbabilityBase3d *angularGivenEnergy( ) const { return( m_angularGivenEnergy ); } /**< Returns the value of the **m_angularGivenEnergy**. */
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
====================== AngularEnergyMC =====================
============================================================
*/
class AngularEnergyMC : public Distribution {
private:
Probabilities::ProbabilityBase2d_d1 *m_angular; /**< The angular probability P(mu|E). */
Probabilities::ProbabilityBase3d *m_energyGivenAngular; /**< The energy probability P(E'|E,mu). */
public:
LUPI_HOST_DEVICE AngularEnergyMC( );
LUPI_HOST AngularEnergyMC( GIDI::Distributions::AngularEnergyMC const &a_angularEnergyMC, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~AngularEnergyMC( );
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d_d1 *angular( ) const { return( m_angular ); } /**< Returns the value of the **m_angular**. */
LUPI_HOST_DEVICE Probabilities::ProbabilityBase3d *energyGivenAngular( ) const { return( m_energyGivenAngular ); } /**< Returns the value of the **m_energyGivenAngular**. */
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
======================== KalbachMann =======================
============================================================
*/
class KalbachMann : public Distribution {
private:
double m_energyToMeVFactor; /**< The factor that converts energies to MeV. */
double m_eb_massFactor; /**< FIX ME */
Probabilities::ProbabilityBase2d_d1 *m_f; /**< The energy probability P(E'|E). */
Functions::Function2d *m_r; /**< The Kalbach-Mann r(E,E') function. */
Functions::Function2d *m_a; /**< The Kalbach-Mann a(E,E') function. */
public:
LUPI_HOST_DEVICE KalbachMann( );
LUPI_HOST KalbachMann( GIDI::Distributions::KalbachMann const &a_KalbachMann, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~KalbachMann( );
LUPI_HOST_DEVICE double energyToMeVFactor( ) const { return( m_energyToMeVFactor ); } /**< Returns the value of the **m_energyToMeVFactor**. */
LUPI_HOST_DEVICE double eb_massFactor( ) const { return( m_eb_massFactor ); } /**< Returns the value of the **m_eb_massFactor**. */
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d_d1 *f( ) const { return( m_f ); } /**< Returns the value of the **m_f**. */
LUPI_HOST_DEVICE Functions::Function2d *r( ) const { return( m_r ); } /**< Returns the value of the **m_r**. */
LUPI_HOST_DEVICE Functions::Function2d *a( ) const { return( m_a ); } /**< Returns the value of the **m_a**. */
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
LUPI_HOST_DEVICE double evaluate( double E_in_lab, double E_out, double mu );
};
/*
============================================================
=============== CoherentPhotoAtomicScattering ==============
============================================================
*/
class CoherentPhotoAtomicScattering : public Distribution {
private:
bool m_anomalousDataPresent; /**< FIX ME */
Vector<double> m_energies; /**< FIX ME */
Vector<double> m_formFactor; /**< FIX ME */
Vector<double> m_a; /**< FIX ME */
Vector<double> m_integratedFormFactor; /**< FIX ME */
Vector<double> m_integratedFormFactorSquared; /**< FIX ME */
Vector<double> m_probabilityNorm1_1; /**< FIX ME */
Vector<double> m_probabilityNorm1_3; /**< FIX ME */
Vector<double> m_probabilityNorm1_5; /**< FIX ME */
Vector<double> m_probabilityNorm2_1; /**< FIX ME */
Vector<double> m_probabilityNorm2_3; /**< FIX ME */
Vector<double> m_probabilityNorm2_5; /**< FIX ME */
Functions::Function1d_d1 *m_realAnomalousFactor; /**< The real part of the anomalous scattering factor. */
Functions::Function1d_d1 *m_imaginaryAnomalousFactor; /**< The imaginary part of the anomalous scattering factor. */
LUPI_HOST_DEVICE double Z_a( double a_Z, double a_a ) const ;
public:
LUPI_HOST_DEVICE CoherentPhotoAtomicScattering( );
LUPI_HOST CoherentPhotoAtomicScattering( GIDI::Distributions::CoherentPhotoAtomicScattering const &a_coherentPhotoAtomicScattering, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~CoherentPhotoAtomicScattering( );
LUPI_HOST_DEVICE double evaluate( double a_energyIn, double a_mu ) const ;
LUPI_HOST_DEVICE double evaluateFormFactor( double a_energyIn, double a_mu ) const ;
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
============== IncoherentPhotoAtomicScattering =============
============================================================
*/
class IncoherentPhotoAtomicScattering : public Distribution {
private:
Vector<double> m_energies; /**< FIX ME */
Vector<double> m_scatteringFactor; /**< FIX ME */
Vector<double> m_a; /**< FIX ME */
public:
LUPI_HOST_DEVICE IncoherentPhotoAtomicScattering( );
LUPI_HOST IncoherentPhotoAtomicScattering( GIDI::Distributions::IncoherentPhotoAtomicScattering const &a_incoherentPhotoAtomicScattering, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~IncoherentPhotoAtomicScattering( );
LUPI_HOST_DEVICE double energyRatio( double a_energyIn, double a_mu ) const ;
LUPI_HOST_DEVICE double evaluateKleinNishina( double a_energyIn, double a_mu ) const ;
LUPI_HOST_DEVICE double evaluateScatteringFactor( double a_X ) const ;
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
/*
LUPI_HOST_DEVICE double evaluate( double E_in_lab, double mu );
*/
};
/*
=======================================================================
============== IncoherentBoundToFreePhotoAtomicScattering =============
=======================================================================
*/
class IncoherentBoundToFreePhotoAtomicScattering : public Distribution {
private:
//Vector<double> m_energies;
//Vector<double> m_ComptonProfile;
Vector<double> m_occupationNumber;
//Vector<double> m_a;
Vector<double> m_pz;
double m_bindingEnergy;
public:
LUPI_HOST_DEVICE IncoherentBoundToFreePhotoAtomicScattering( );
LUPI_HOST IncoherentBoundToFreePhotoAtomicScattering( GIDI::Distributions::IncoherentBoundToFreePhotoAtomicScattering const &a_incoherentPhotoAtomicScattering, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~IncoherentBoundToFreePhotoAtomicScattering( );
LUPI_HOST_DEVICE double energyRatio( double a_energyIn, double a_mu ) const ;
LUPI_HOST_DEVICE double evaluateKleinNishina( double a_energyIn, double a_mu ) const ;
LUPI_HOST_DEVICE double evaluateOccupationNumber( double a_X, double a_mu ) const;
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========== IncoherentPhotoAtomicScatteringElectron =========
============================================================
*/
class IncoherentPhotoAtomicScatteringElectron : public Distribution {
public:
LUPI_HOST_DEVICE IncoherentPhotoAtomicScatteringElectron( );
LUPI_HOST IncoherentPhotoAtomicScatteringElectron( SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~IncoherentPhotoAtomicScatteringElectron( );
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_energy, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
==================== PairProductionGamma ===================
============================================================
*/
class PairProductionGamma : public Distribution {
private:
bool m_firstSampled; /**< When sampling photons for pair production, the photons must be emitted back-to-back. The flag help do this. */
public:
LUPI_HOST_DEVICE PairProductionGamma( );
LUPI_HOST PairProductionGamma( SetupInfo &a_setupInfo, bool a_firstSampled );
LUPI_HOST_DEVICE ~PairProductionGamma( );
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
==================== CoherentElasticTNSL ===================
============================================================
*/
class CoherentElasticTNSL : public Distribution {
private:
Interpolation m_temperatureInterpolation;
Vector<double> m_temperatures;
Vector<double> m_energies;
Vector<double> m_S_table;
public:
LUPI_HOST_DEVICE CoherentElasticTNSL( );
LUPI_HOST CoherentElasticTNSL( GIDI::DoubleDifferentialCrossSection::n_ThermalNeutronScatteringLaw::CoherentElastic const *a_coherentElasticTNSL,
SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~CoherentElasticTNSL( ) {}
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_energy, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
==================== IncoherentElasticTNSL ===================
============================================================
*/
class IncoherentElasticTNSL : public Distribution {
private:
double m_temperatureToMeV_K;
Functions::Function1d_d1 *m_DebyeWallerIntegral;
public:
LUPI_HOST_DEVICE IncoherentElasticTNSL( );
LUPI_HOST IncoherentElasticTNSL( GIDI::DoubleDifferentialCrossSection::n_ThermalNeutronScatteringLaw::IncoherentElastic const *a_incoherentElasticTNSL,
SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~IncoherentElasticTNSL( ) {}
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_energy, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
Functions::Function1d *DebyeWallerIntegral( ) { return( m_DebyeWallerIntegral ); }
Functions::Function1d const *DebyeWallerIntegral( ) const { return( m_DebyeWallerIntegral ); }
};
/*
============================================================
======================= Unspecified ========================
============================================================
*/
class Unspecified : public Distribution {
public:
LUPI_HOST_DEVICE Unspecified( );
LUPI_HOST Unspecified( GIDI::Distributions::Distribution const &a_distribution, SetupInfo &a_setupInfo );
LUPI_HOST_DEVICE ~Unspecified( );
template <typename RNG>
LUPI_HOST_DEVICE void sample( double a_X, Sampling::Input &a_input, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double angleBiasing( Reaction const *a_reaction, double a_temperature, double a_energy_in, double a_mu_lab,
RNG && a_rng, double &a_energy_out ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========================== Others ==========================
============================================================
*/
LUPI_HOST Distribution *parseGIDI( GIDI::Suite const &a_distribution, SetupInfo &a_setupInfo, Transporting::MC const &a_settings );
LUPI_HOST_DEVICE Type DistributionType( Distribution const *a_distribution );
}
}
#endif // End of MCGIDI_distributions_hpp_included
@@ -1,27 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef MCGIDI_fromTOM_h_included
#define MCGIDI_fromTOM_h_included
#include <xDataTOM_importXML_private.h>
#include "MCGIDI.h"
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
ptwXYPoints *MCGIDI_fromTOM_XYs_to_ptwXYPoints_linear( statusMessageReporting *smr, xDataTOM_XYs *XYs, enum ptwXY_interpolation_e interpolation );
int MCGIDI_fromTOM_pdfsOfXGivenW( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_pdfsOfXGivenW *dists, ptwXYPoints *norms,
char const *toUnits[3] );
int MCGIDI_fromTOM_pdfOfX( statusMessageReporting *smr, ptwXYPoints *pdfXY, MCGIDI_pdfOfX *dist, double *norm );
int MCGIDI_fromTOM_interpolation( statusMessageReporting *smr, xDataTOM_element *element, int index, enum ptwXY_interpolation_e *interpolation );
#if defined __cplusplus
}
}
#endif
#endif /* End of MCGIDI_fromTOM_h_included. */
@@ -0,0 +1,825 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef MCGIDI_functions_hpp_included
#define MCGIDI_functions_hpp_included 1
#include <nf_utilities.h>
#include <ptwXY.h>
#include <LUPI_dataBuffer.hpp>
namespace MCGIDI {
enum class Interpolation { LINLIN, LINLOG, LOGLIN, LOGLOG, FLAT, OTHER };
enum class Function1dType { none, constant, XYs, polyomial, gridded, regions, branching, TerrellFissionNeutronMultiplicityModel };
enum class Function2dType { none, XYs };
enum class ProbabilityBase1dType { none, xs_pdf_cdf };
enum class ProbabilityBase2dType { none, XYs, regions, isotropic, discreteGamma, primaryGamma, recoil, NBodyPhaseSpace, evaporation,
generalEvaporation, simpleMaxwellianFission, Watt, weightedFunctionals };
enum class ProbabilityBase3dType { none, XYs };
namespace Functions {
/*
============================================================
====================== FunctionBase ========================
============================================================
*/
class FunctionBase {
private:
int m_dimension;
double m_domainMin;
double m_domainMax;
Interpolation m_interpolation;
double m_outerDomainValue;
public:
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 );
LUPI_HOST_DEVICE virtual ~FunctionBase( ) = 0;
LUPI_HOST_DEVICE Interpolation interpolation( ) const { return( m_interpolation ); }
LUPI_HOST_DEVICE double domainMin( ) const { return( m_domainMin ); }
LUPI_HOST_DEVICE double domainMax( ) const { return( m_domainMax ); }
LUPI_HOST_DEVICE double outerDomainValue( ) const { return( m_outerDomainValue ); }
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
======================== Function1d ========================
============================================================
*/
class Function1d : public FunctionBase {
protected:
Function1dType m_type;
public:
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 { return( m_type ); }
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 );
};
/*
============================================================
====================== Function1d_d1 =======================
============================================================
*/
class Function1d_d1 : public Function1d {
public:
LUPI_HOST_DEVICE Function1d_d1( ) :
Function1d( ) { }
LUPI_HOST_DEVICE Function1d_d1( double a_domainMin, double a_domainMax, Interpolation a_interpolation, double a_outerDomainValue = 0 ) :
Function1d( a_domainMin, a_domainMax, a_interpolation, a_outerDomainValue ) { }
LUPI_HOST_DEVICE double evaluate( double a_x1 ) const ;
};
/*
============================================================
====================== Function1d_d2 =======================
============================================================
*/
class Function1d_d2 : public Function1d_d1 {
public:
LUPI_HOST_DEVICE Function1d_d2( ) :
Function1d_d1( ) { }
LUPI_HOST_DEVICE Function1d_d2( double a_domainMin, double a_domainMax, Interpolation a_interpolation, double a_outerDomainValue = 0 ) :
Function1d_d1( a_domainMin, a_domainMax, a_interpolation, a_outerDomainValue ) { }
LUPI_HOST_DEVICE double evaluate( double a_x1 ) const ;
};
/*
============================================================
======================== Constant1d ========================
============================================================
*/
class Constant1d : public Function1d_d2 {
private:
double m_value;
public:
LUPI_HOST_DEVICE Constant1d( );
LUPI_HOST_DEVICE Constant1d( double a_domainMin, double a_domainMax, double a_value, double a_outerDomainValue = 0 );
LUPI_HOST Constant1d( GIDI::Functions::Constant1d const &a_constant1d );
LUPI_HOST_DEVICE ~Constant1d( );
LUPI_HOST_DEVICE double evaluate( LUPI_maybeUnused double a_x1 ) const { return( m_value ); }
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
=========================== XYs1d ==========================
============================================================
*/
class XYs1d : public Function1d_d2 {
private:
Vector<double> m_Xs;
Vector<double> m_Ys;
public:
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 );
};
/*
============================================================
======================= Polynomial1d =======================
============================================================
*/
class Polynomial1d : public Function1d_d2 {
private:
Vector<double> m_coefficients;
Vector<double> m_coefficientsReversed;
public:
LUPI_HOST_DEVICE Polynomial1d( );
LUPI_HOST Polynomial1d( double a_domainMin, double a_domainMax, Vector<double> const &a_coefficients, double a_outerDomainValue = 0 );
LUPI_HOST Polynomial1d( GIDI::Functions::Polynomial1d const &a_polynomial1d );
LUPI_HOST_DEVICE ~Polynomial1d( );
LUPI_HOST_DEVICE Vector<double> const &coefficients( ) const { return( m_coefficients ); }
LUPI_HOST_DEVICE double evaluate( double a_x1 ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========================= Gridded1d ========================
============================================================
*/
class Gridded1d : public Function1d_d2 {
private:
Vector<double> m_grid;
Vector<double> m_data;
public:
LUPI_HOST_DEVICE Gridded1d( );
LUPI_HOST Gridded1d( GIDI::Functions::Gridded1d const &a_gridded1d );
LUPI_HOST_DEVICE ~Gridded1d( );
LUPI_HOST_DEVICE double evaluate( double a_x1 ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========================= Regions1d ========================
============================================================
*/
class Regions1d : public Function1d_d1 {
private:
Vector<double> m_Xs;
Vector<Function1d_d2 *> m_functions1d;
public:
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 );
};
/*
============================================================
======================== Branching1d =======================
============================================================
*/
class Branching1d : public Function1d_d2 {
private:
int m_initialStateIndex;
public:
LUPI_HOST_DEVICE Branching1d( );
LUPI_HOST Branching1d( SetupInfo &a_setupInfo, GIDI::Functions::Branching1d const &a_branching1d );
LUPI_HOST_DEVICE ~Branching1d( );
LUPI_HOST_DEVICE int initialStateIndex( ) const { return( m_initialStateIndex ); }
LUPI_HOST_DEVICE double evaluate( double a_x1 ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========== TerrellFissionNeutronMultiplicityModel ==========
============================================================
*/
class TerrellFissionNeutronMultiplicityModel : public Function1d {
private:
double m_width;
Function1d_d1 *m_multiplicity;
public:
LUPI_HOST_DEVICE TerrellFissionNeutronMultiplicityModel( );
LUPI_HOST TerrellFissionNeutronMultiplicityModel( double a_width, Function1d_d1 *a_multiplicity );
LUPI_HOST_DEVICE ~TerrellFissionNeutronMultiplicityModel( );
template <typename RNG>
LUPI_HOST_DEVICE int sampleBoundingInteger( double a_energy, RNG && a_rng ) const ;
LUPI_HOST_DEVICE double evaluate( double a_energy ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
======================== Function2d ========================
============================================================
*/
class Function2d : public FunctionBase {
protected:
Function2dType m_type;
public:
LUPI_HOST_DEVICE Function2d( );
LUPI_HOST Function2d( double a_domainMin, double a_domainMax, Interpolation a_interpolation, double a_outerDomainValue = 0 );
LUPI_HOST_DEVICE ~Function2d( );
LUPI_HOST_DEVICE Function2dType type( ) const { return m_type; }
LUPI_HOST_DEVICE String typeString( ) const ;
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double evaluate( double a_x2, double a_x1 ) const MCGIDI_TRUE_VIRTUAL;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
=========================== XYs2d ==========================
============================================================
*/
class XYs2d : public Function2d {
private:
Vector<double> m_Xs;
Vector<Function1d_d1 *> m_functions1d;
public:
LUPI_HOST_DEVICE XYs2d( );
LUPI_HOST XYs2d( GIDI::Functions::XYs2d const &a_XYs2d );
LUPI_HOST_DEVICE ~XYs2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========================== others ==========================
============================================================
*/
LUPI_HOST Function1d *parseMultiplicityFunction1d( SetupInfo &a_setupInfo, Transporting::MC const &a_settings, GIDI::Suite const &a_suite );
LUPI_HOST Function1d_d1 *parseFunction1d_d1( Transporting::MC const &a_settings, GIDI::Suite const &a_suite );
LUPI_HOST Function1d_d1 *parseFunction1d_d1( GIDI::Functions::Function1dForm const *form1d );
LUPI_HOST Function1d_d2 *parseFunction1d_d2( GIDI::Functions::Function1dForm const *form1d );
LUPI_HOST Function2d *parseFunction2d( Transporting::MC const &a_settings, GIDI::Suite const &a_suite );
LUPI_HOST Function2d *parseFunction2d( GIDI::Functions::Function2dForm const *form2d );
} // End of namespace Functions.
/*
============================================================
============================================================
================== namespace Probabilities ==================
============================================================
============================================================
*/
namespace Probabilities {
/*
============================================================
===================== ProbabilityBase ======================
============================================================
*/
class ProbabilityBase : public Functions::FunctionBase {
protected:
Vector<double> m_Xs;
public:
LUPI_HOST_DEVICE ProbabilityBase( );
LUPI_HOST ProbabilityBase( GIDI::Functions::FunctionForm const &a_probabilty );
LUPI_HOST ProbabilityBase( GIDI::Functions::FunctionForm const &a_probabilty, Vector<double> const &a_Xs );
LUPI_HOST_DEVICE ~ProbabilityBase( );
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
===================== ProbabilityBase1d ====================
============================================================
*/
class ProbabilityBase1d : public ProbabilityBase {
protected:
ProbabilityBase1dType m_type;
public:
LUPI_HOST_DEVICE ProbabilityBase1d( );
LUPI_HOST ProbabilityBase1d( GIDI::Functions::FunctionForm const &a_probabilty, Vector<double> const &a_Xs );
LUPI_HOST_DEVICE ~ProbabilityBase1d( );
LUPI_HOST_DEVICE ProbabilityBase1dType type( ) const { return m_type; }
LUPI_HOST_DEVICE String typeString( ) const ;
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double evaluate( double a_x1 ) const MCGIDI_TRUE_VIRTUAL;
template <typename RNG>
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double sample( double a_rngValue, RNG && a_rng ) const MCGIDI_TRUE_VIRTUAL;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
======================= Xs_pdf_cdf1d =======================
============================================================
*/
class Xs_pdf_cdf1d : public ProbabilityBase1d {
private:
Vector<double> m_pdf;
Vector<double> m_cdf;
public:
LUPI_HOST_DEVICE Xs_pdf_cdf1d( );
LUPI_HOST Xs_pdf_cdf1d( GIDI::Functions::Xs_pdf_cdf1d const &a_xs_pdf_cdf1d );
LUPI_HOST_DEVICE ~Xs_pdf_cdf1d( );
LUPI_HOST_DEVICE double evaluate( double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
===================== ProbabilityBase2d ====================
============================================================
*/
class ProbabilityBase2d : public ProbabilityBase {
protected:
ProbabilityBase2dType m_type;
public:
LUPI_HOST_DEVICE ProbabilityBase2d( );
LUPI_HOST ProbabilityBase2d( GIDI::Functions::FunctionForm const &a_probabilty );
LUPI_HOST ProbabilityBase2d( GIDI::Functions::FunctionForm const &a_probabilty, Vector<double> const &a_Xs );
LUPI_HOST_DEVICE ~ProbabilityBase2d( );
LUPI_HOST_DEVICE ProbabilityBase2dType type( ) const { return m_type; }
LUPI_HOST_DEVICE String typeString( ) const ;
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double evaluate( double a_x2, double a_x1 ) const MCGIDI_TRUE_VIRTUAL;
template <typename RNG>
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double sample( double a_x2, double a_rngValue, RNG && a_rng ) const MCGIDI_TRUE_VIRTUAL;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
=================== ProbabilityBase2d_d1 ===================
============================================================
*/
class ProbabilityBase2d_d1 : public ProbabilityBase2d {
public:
LUPI_HOST_DEVICE ProbabilityBase2d_d1( ) :
ProbabilityBase2d( ) { }
LUPI_HOST ProbabilityBase2d_d1( GIDI::Functions::FunctionForm const &a_probabilty ) :
ProbabilityBase2d( a_probabilty ) { }
LUPI_HOST ProbabilityBase2d_d1( GIDI::Functions::FunctionForm const &a_probabilty, Vector<double> const &a_Xs ) :
ProbabilityBase2d( a_probabilty, a_Xs ) { }
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample2dOf3d( double a_x2, double a_rngValue, RNG && a_rng, double *a_x1_1, double *a_x1_2 ) const ;
};
/*
============================================================
=================== ProbabilityBase2d_d2 ===================
============================================================
*/
class ProbabilityBase2d_d2 : public ProbabilityBase2d_d1 {
public:
LUPI_HOST_DEVICE ProbabilityBase2d_d2( ) :
ProbabilityBase2d_d1( ) { }
LUPI_HOST ProbabilityBase2d_d2( GIDI::Functions::FunctionForm const &a_probabilty ) :
ProbabilityBase2d_d1( a_probabilty ) { }
LUPI_HOST ProbabilityBase2d_d2( GIDI::Functions::FunctionForm const &a_probabilty, Vector<double> const &a_Xs ) :
ProbabilityBase2d_d1( a_probabilty, a_Xs ) { }
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample2dOf3d( double a_x2, double a_rngValue, RNG && a_rng, double *a_x1_1, double *a_x1_2 ) const ;
};
/*
============================================================
========================== XYs2d ===========================
============================================================
*/
class XYs2d : public ProbabilityBase2d_d2 {
private:
Vector<ProbabilityBase1d *> m_probabilities;
public:
LUPI_HOST_DEVICE XYs2d( );
LUPI_HOST XYs2d( GIDI::Functions::XYs2d const &a_XYs2d );
LUPI_HOST_DEVICE ~XYs2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample2dOf3d( double a_x2, double a_rngValue, RNG && a_rng, double *a_x1_1, double *a_x1_2 ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
======================== Regions2d =========================
============================================================
*/
class Regions2d : public ProbabilityBase2d_d1 {
private:
Vector<ProbabilityBase2d_d2 *> m_probabilities;
public:
LUPI_HOST_DEVICE Regions2d( );
LUPI_HOST Regions2d( GIDI::Functions::Regions2d const &a_regions2d );
LUPI_HOST_DEVICE ~Regions2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
======================== Isotropic2d =======================
============================================================
*/
class Isotropic2d : public ProbabilityBase2d_d2 {
public:
LUPI_HOST_DEVICE Isotropic2d( );
LUPI_HOST Isotropic2d( GIDI::Functions::Isotropic2d const &a_isotropic2d );
LUPI_HOST_DEVICE ~Isotropic2d( );
LUPI_HOST_DEVICE double evaluate( LUPI_maybeUnused double a_x2, LUPI_maybeUnused double a_x1 ) const { return( 0.5 ); }
template <typename RNG>
LUPI_HOST_DEVICE double sample( LUPI_maybeUnused double a_x2, double a_rngValue, LUPI_maybeUnused RNG && a_rng ) const { return( 1. - 2. * a_rngValue ); }
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode ) {
ProbabilityBase2d::serialize( a_buffer, a_mode ); }
};
/*
============================================================
====================== DiscreteGamma2d =====================
============================================================
*/
class DiscreteGamma2d : public ProbabilityBase2d_d2 {
private:
double m_value;
public:
LUPI_HOST_DEVICE DiscreteGamma2d( );
LUPI_HOST DiscreteGamma2d( GIDI::Functions::DiscreteGamma2d const &a_discreteGamma2d );
LUPI_HOST_DEVICE ~DiscreteGamma2d( );
LUPI_HOST_DEVICE double evaluate( LUPI_maybeUnused double a_x2, LUPI_maybeUnused double a_x1 ) const { return( m_value ); } // FIXME This is wrong, should be something like 1 when domainMin <= a_x1 <= domainMax ), I think. I.e., should be a probability.
template <typename RNG>
LUPI_HOST_DEVICE double sample( LUPI_maybeUnused double a_x2, LUPI_maybeUnused double a_rngValue, LUPI_maybeUnused RNG && a_rng ) const { return( m_value ); }
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
====================== PrimaryGamma2d =====================
============================================================
*/
class PrimaryGamma2d : public ProbabilityBase2d_d2 {
private:
double m_primaryEnergy;
double m_massFactor;
String m_finalState;
int m_initialStateIndex;
public:
LUPI_HOST_DEVICE PrimaryGamma2d( );
LUPI_HOST PrimaryGamma2d( GIDI::Functions::PrimaryGamma2d const &a_primaryGamma2d, SetupInfo *a_setupInfo );
LUPI_HOST_DEVICE ~PrimaryGamma2d( );
double primaryEnergy( ) const { return( m_primaryEnergy ); } /**< Returns the value of the *m_primaryEnergy* member. */
double massFactor( ) const { return( m_massFactor ); } /**< Returns the value of the *m_massFactor* member. */
String const &finalState( ) const { return( m_finalState ); } /**< Returns a const reference to the *m_finalState* member. */
int initialStateIndex( ) const { return( m_initialStateIndex ); } /**< Returns the value of the *m_initialStateIndex* member. */
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, LUPI_maybeUnused double a_rngValue, LUPI_maybeUnused RNG && a_rng ) const { return( m_primaryEnergy + a_x2 * m_massFactor ); }
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========================= Recoil2d =========================
============================================================
*/
class Recoil2d: public ProbabilityBase2d_d2 {
private:
String m_xlink;
public:
LUPI_HOST_DEVICE Recoil2d( );
LUPI_HOST Recoil2d( GIDI::Functions::Recoil2d const &a_recoil2d );
LUPI_HOST_DEVICE ~Recoil2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
==================== NBodyPhaseSpace2d =====================
============================================================
*/
class NBodyPhaseSpace2d : public ProbabilityBase2d_d2 {
private:
int m_numberOfProducts;
double m_mass;
double m_energy_in_COMFactor;
double m_massFactor;
double m_Q;
ProbabilityBase1d *m_dist;
public:
LUPI_HOST_DEVICE NBodyPhaseSpace2d( );
LUPI_HOST NBodyPhaseSpace2d( GIDI::Functions::NBodyPhaseSpace2d const &a_NBodyPhaseSpace2d, SetupInfo *a_setupInfo );
LUPI_HOST_DEVICE ~NBodyPhaseSpace2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
====================== Evaporation2d =======================
============================================================
*/
class Evaporation2d: public ProbabilityBase2d_d2 {
private:
double m_U;
Functions::Function1d_d1 *m_theta;
public:
LUPI_HOST_DEVICE Evaporation2d( );
LUPI_HOST Evaporation2d( GIDI::Functions::Evaporation2d const &a_generalEvaporation2d );
LUPI_HOST_DEVICE ~Evaporation2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
=================== GeneralEvaporation2d ===================
============================================================
*/
class GeneralEvaporation2d: public ProbabilityBase2d_d2 {
private:
Functions::Function1d_d1 *m_theta;
ProbabilityBase1d *m_g;
public:
LUPI_HOST_DEVICE GeneralEvaporation2d( );
LUPI_HOST GeneralEvaporation2d( GIDI::Functions::GeneralEvaporation2d const &a_generalEvaporation2d );
LUPI_HOST_DEVICE ~GeneralEvaporation2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
================= SimpleMaxwellianFission2d ================
============================================================
*/
class SimpleMaxwellianFission2d: public ProbabilityBase2d_d2 {
private:
double m_U;
Functions::Function1d_d1 *m_theta;
public:
LUPI_HOST_DEVICE SimpleMaxwellianFission2d( );
LUPI_HOST SimpleMaxwellianFission2d( GIDI::Functions::SimpleMaxwellianFission2d const &a_simpleMaxwellianFission2d );
LUPI_HOST_DEVICE ~SimpleMaxwellianFission2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========================== Watt2d ==========================
============================================================
*/
class Watt2d : public ProbabilityBase2d_d2 {
private:
double m_U;
Functions::Function1d_d1 *m_a;
Functions::Function1d_d1 *m_b;
public:
LUPI_HOST_DEVICE Watt2d( );
LUPI_HOST Watt2d( GIDI::Functions::Watt2d const &a_Watt2d );
LUPI_HOST_DEVICE ~Watt2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
=================== WeightedFunctionals2d ==================
============================================================
*/
class WeightedFunctionals2d: public ProbabilityBase2d {
private:
Vector<Functions::Function1d_d1 *> m_weight;
Vector<ProbabilityBase2d_d1 *> m_energy;
public:
LUPI_HOST_DEVICE WeightedFunctionals2d( );
LUPI_HOST WeightedFunctionals2d( GIDI::Functions::WeightedFunctionals2d const &a_weightedFunctionals2d );
LUPI_HOST_DEVICE ~WeightedFunctionals2d( );
LUPI_HOST_DEVICE double evaluate( double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x2, double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
===================== ProbabilityBase3d ====================
============================================================
*/
class ProbabilityBase3d : public ProbabilityBase {
protected:
ProbabilityBase3dType m_type;
public:
LUPI_HOST_DEVICE ProbabilityBase3d( );
LUPI_HOST ProbabilityBase3d( GIDI::Functions::FunctionForm const &a_probabilty, Vector<double> const &a_Xs );
LUPI_HOST_DEVICE ~ProbabilityBase3d( );
LUPI_HOST_DEVICE ProbabilityBase3dType type( ) const { return m_type; }
LUPI_HOST_DEVICE String typeString( ) const ;
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double evaluate( double a_x3, double a_x2, double a_x1 ) const MCGIDI_TRUE_VIRTUAL;
template <typename RNG>
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double sample( double a_x3, double a_x2_1, double a_x2_2, double a_rngValue, RNG && a_rng ) const MCGIDI_TRUE_VIRTUAL;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========================== XYs3d ===========================
============================================================
*/
class XYs3d : public ProbabilityBase3d {
private:
Vector<ProbabilityBase2d_d1 *> m_probabilities;
public:
LUPI_HOST_DEVICE XYs3d( );
LUPI_HOST XYs3d( GIDI::Functions::XYs3d const &a_XYs3d );
LUPI_HOST_DEVICE ~XYs3d( );
LUPI_HOST_DEVICE double evaluate( double a_x3, double a_x2, double a_x1 ) const ;
template <typename RNG>
LUPI_HOST_DEVICE double sample( double a_x3, double a_x2_1, double a_x2_2, double a_rngValue, RNG && a_rng ) const ;
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
/*
============================================================
========================== others ==========================
============================================================
*/
LUPI_HOST ProbabilityBase1d *parseProbability1d( Transporting::MC const &a_settings, GIDI::Suite const &a_suite );
LUPI_HOST ProbabilityBase1d *parseProbability1d( GIDI::Functions::Function1dForm const *form1d );
LUPI_HOST ProbabilityBase2d *parseProbability2d( Transporting::MC const &a_settings, GIDI::Suite const &a_suite, SetupInfo *a_setupInfo );
LUPI_HOST ProbabilityBase2d *parseProbability2d( GIDI::Functions::Function2dForm const *form2d, SetupInfo *a_setupInfo );
LUPI_HOST ProbabilityBase2d_d1 *parseProbability2d_d1( GIDI::Functions::Function2dForm const *form2d, SetupInfo *a_setupInfo );
LUPI_HOST ProbabilityBase2d_d2 *parseProbability2d_d2( GIDI::Functions::Function2dForm const *form2d, SetupInfo *a_setupInfo );
LUPI_HOST ProbabilityBase3d *parseProbability3d( Transporting::MC const &a_settings, GIDI::Suite const &a_suite );
LUPI_HOST ProbabilityBase3d *parseProbability3d( GIDI::Functions::Function3dForm const *form3d );
} // End of namespace Probabilities.
/*
============================================================
========================== others ==========================
============================================================
*/
LUPI_HOST_DEVICE Interpolation GIDI2MCGIDI_interpolation( ptwXY_interpolation a_interpolation );
LUPI_HOST_DEVICE Function1dType Function1dClass( Functions::Function1d *funct );
LUPI_HOST_DEVICE Functions::Function1d *serializeFunction1d( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, Functions::Function1d *a_function1d );
LUPI_HOST_DEVICE Functions::Function1d_d1 *serializeFunction1d_d1( LUPI::DataBuffer &a_buffer,
LUPI::DataBuffer::Mode a_mode, Functions::Function1d_d1 *a_function1d );
LUPI_HOST_DEVICE Functions::Function1d_d2 *serializeFunction1d_d2( LUPI::DataBuffer &a_buffer,
LUPI::DataBuffer::Mode a_mode, Functions::Function1d_d2 *a_function1d );
LUPI_HOST_DEVICE Function2dType Function2dClass( Functions::Function2d *funct );
LUPI_HOST_DEVICE Functions::Function2d *serializeFunction2d( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, Functions::Function2d *a_function2d );
LUPI_HOST_DEVICE ProbabilityBase1dType ProbabilityBase1dClass( Probabilities::ProbabilityBase1d *funct );
LUPI_HOST_DEVICE Probabilities::ProbabilityBase1d *serializeProbability1d( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, Probabilities::ProbabilityBase1d *a_probability1d );
LUPI_HOST_DEVICE ProbabilityBase2dType ProbabilityBase2dClass( Probabilities::ProbabilityBase2d *funct );
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d *serializeProbability2d( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode,
Probabilities::ProbabilityBase2d *a_probability2d );
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d_d1 *serializeProbability2d_d1( LUPI::DataBuffer &a_buffer,
LUPI::DataBuffer::Mode a_mode, Probabilities::ProbabilityBase2d_d1 *a_probability2d );
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d_d2 *serializeProbability2d_d2( LUPI::DataBuffer &a_buffer,
LUPI::DataBuffer::Mode a_mode, Probabilities::ProbabilityBase2d_d2 *a_probability2d );
LUPI_HOST_DEVICE ProbabilityBase3dType ProbabilityBase3dClass( Probabilities::ProbabilityBase3d *funct );
LUPI_HOST_DEVICE Probabilities::ProbabilityBase3d *serializeProbability3d( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, Probabilities::ProbabilityBase3d *a_probability3d );
} // End of namespace MCGIDI.
#endif // End of MCGIDI_functions_hpp_included
File diff suppressed because it is too large Load Diff
@@ -1,74 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef MCGIDI_map_h_included
#define MCGIDI_map_h_included
#include <statusMessageReporting.h>
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
enum MCGIDI_map_status { MCGIDI_map_status_Ok, MCGIDI_map_status_memory, MCGIDI_map_status_mapParsing,
MCGIDI_map_status_UnknownType };
enum MCGIDI_mapEntry_type { MCGIDI_mapEntry_type_target, MCGIDI_mapEntry_type_path };
typedef struct MCGIDI_map_s MCGIDI_map;
typedef struct MCGIDI_mapEntry_s MCGIDI_mapEntry;
typedef struct MCGIDI_map_smr_s MCGIDI_map_smr;
struct MCGIDI_map_smr_s {
smr_userInterface smrUserInterface;
MCGIDI_map *map;
};
struct MCGIDI_mapEntry_s {
MCGIDI_mapEntry *next;
enum MCGIDI_mapEntry_type type;
MCGIDI_map *parent;
char *schema;
char *path;
char *evaluation;
char *projectile;
char *targetName;
int globalPoPsIndexProjectile, globalPoPsIndexTarget;
MCGIDI_map *map;
};
struct MCGIDI_map_s {
enum MCGIDI_map_status status;
MCGIDI_map_smr smrUserInterface;
char *path;
char *mapFileName;
int numberOfEntries;
MCGIDI_mapEntry *mapEntries;
};
MCGIDI_map *MCGIDI_map_new( statusMessageReporting *smr );
int MCGIDI_map_initialize( statusMessageReporting *smr, MCGIDI_map *map );
MCGIDI_map *MCGIDI_map_readFile( statusMessageReporting *smr, const char *basePath, const char *mapFileName );
void *MCGIDI_map_free( statusMessageReporting *smr, MCGIDI_map *map );
void MCGIDI_map_release( statusMessageReporting *smr, MCGIDI_map *map );
MCGIDI_mapEntry *MCGIDI_map_getFirstEntry( MCGIDI_map *map );
MCGIDI_mapEntry *MCGIDI_map_getNextEntry( MCGIDI_mapEntry *entry );
int MCGIDI_map_addTarget( statusMessageReporting *smr, MCGIDI_map *map, const char *method, const char *path, const char *evaluation, const char *projectile, const char *targetName );
int MCGIDI_map_addPath( statusMessageReporting *smr, MCGIDI_map *map, const char *path );
char *MCGIDI_map_findTargetViaPoPIDs( statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, int projectile_PoPID, int target_PoPID );
char *MCGIDI_map_findTarget( statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, const char *projectile, const char *targetName );
MCGIDI_map *MCGIDI_map_findAllOfTargetViaPoPIDs( statusMessageReporting *smr, MCGIDI_map *map, int projectile_PoPID, int target_PoPID );
MCGIDI_map *MCGIDI_map_findAllOfTarget( statusMessageReporting *smr, MCGIDI_map *map, const char *projectile, const char *targetName );
char *MCGIDI_map_getFullPath( statusMessageReporting *smr, MCGIDI_map *map, const char *endPath );
char *MCGIDI_map_getTargetsFullPath( statusMessageReporting *smr, MCGIDI_mapEntry *target );
int MCGIDI_map_walkTree( statusMessageReporting *smr, MCGIDI_map *map, int (*handler)( MCGIDI_mapEntry *entry, int level, void *userData), void *userData );
char *MCGIDI_map_toXMLString( statusMessageReporting *smr, MCGIDI_map *map );
void MCGIDI_map_simpleWrite( FILE *f, MCGIDI_map *map );
#if defined __cplusplus
}
}
#endif
#endif /* End of MCGIDI_map_h_included. */
@@ -1,20 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef MCGIDI_mass_h_included
#define MCGIDI_mass_h_included
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
double MCGIDI_particleMass_AMU( statusMessageReporting *smr, const char *name );
#if defined __cplusplus
}
}
#endif
#endif /* End of MCGIDI_mass_h_included. */
@@ -1,47 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef MCGIDI_misc_h_included
#define MCGIDI_misc_h_included
#include <statusMessageReporting.h>
#include <xDataTOM_importXML_private.h>
#include "MCGIDI_private.h"
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
char const *MCGIDI_misc_pointerToTOMAttributeIfAllOk( statusMessageReporting *smr, char const *path, int required,
xDataTOM_attributionList *attributes, char const *name, char const *file, int line );
char const *MCGIDI_misc_pointerToAttributeIfAllOk( statusMessageReporting *smr, xDataXML_element *element, char const *path, int required,
xDataTOM_attributionList *attributes, char const *name, char const *file, int line );
int MCGIDI_misc_setMessageError_Element( statusMessageReporting *smr, void *userInterface, xDataXML_element *element, char const *file, int line, int code,
char const *fmt, ... );
char *MCGIDI_misc_getAbsPath( statusMessageReporting *smr, char const *fileName );
int MCGIDI_misc_copyXMLAttributesToTOM( statusMessageReporting *smr, xDataTOM_attributionList *TOM, xDataXML_attributionList *XML );
#define MCGIDI_misc_pointerToTOMAttributeIfAllOk2( smr, required, attributes, name ) \
MCGIDI_misc_pointerToTOMAttributeIfAllOk( smr, NULL, required, attributes, name, __FILE__, __LINE__ )
#define MCGIDI_misc_pointerToTOMAttributeIfAllOk3( smr, path, required, attributes, name ) \
MCGIDI_misc_pointerToTOMAttributeIfAllOk( smr, path, required, attributes, name, __FILE__, __LINE__ )
#define MCGIDI_misc_pointerToAttributeIfAllOk2( smr, element, required, attributes, name ) \
MCGIDI_misc_pointerToAttributeIfAllOk( smr, element, NULL, required, attributes, name, __FILE__, __LINE__ )
#define MCGIDI_misc_pointerToAttributeIfAllOk3( smr, path, required, attributes, name ) \
MCGIDI_misc_pointerToAttributeIfAllOk( smr, NULL, path, required, attributes, name, __FILE__, __LINE__ )
enum xDataTOM_frame MCGIDI_misc_getProductFrame( statusMessageReporting *smr, xDataTOM_element *frameElement );
double MCGIDI_misc_getUnitConversionFactor( statusMessageReporting *smr, char const *fromUnit, char const *toUnit );
ptwXYPoints *MCGIDI_misc_dataFromXYs2ptwXYPointsInUnitsOf( statusMessageReporting *smr, xDataTOM_XYs *XYs,
ptwXY_interpolation interpolation, char const *units[2] );
ptwXYPoints *MCGIDI_misc_dataFromElement2ptwXYPointsInUnitsOf( statusMessageReporting *smr, xDataTOM_element *linear, char const *toUnits[2] );
#if defined __cplusplus
}
}
#endif
#endif /* End of MCGIDI_misc_h_included. */
@@ -1,20 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef MCGIDI_private_h_included
#define MCGIDI_private_h_included
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
#define MCGIDI_token_productFrame "productFrame"
#if defined __cplusplus
}
}
#endif
#endif /* End of MCGIDI_private_h_included. */
@@ -0,0 +1,305 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef MCGIDI_sampling_hpp_included
#define MCGIDI_sampling_hpp_included 1
#include <LUPI_declareMacro.hpp>
#include <MCGIDI_vector.hpp>
#include <MCGIDI_string.hpp>
namespace MCGIDI {
/*
============================================================
======================= DomainHash =========================
============================================================
*/
class DomainHash {
private:
int m_bins; /**< The number of bins for the hash. */
double m_domainMin; /**< The minimum domain value for the hash. */
double m_domainMax; /**< The maximum domain value for the hash. */
double m_u_domainMin; /**< The log of m_domainMin ). */
double m_u_domainMax; /**< The log of m_domainMax ). */
double m_inverse_du; /**< The value *m_bins* / ( *m_u_domainMax* - *m_u_domainMin* ). */
public:
LUPI_HOST_DEVICE DomainHash( );
LUPI_HOST_DEVICE DomainHash( int a_bins, double a_domainMin, double a_domainMax );
LUPI_HOST_DEVICE DomainHash( DomainHash const &a_domainHash );
LUPI_HOST_DEVICE int bins( ) const { return( m_bins ); } /**< Returns the value of the **m_bins**. */
LUPI_HOST_DEVICE double domainMin( ) const { return( m_domainMin ); } /**< Returns the value of the **m_domainMax**. */
LUPI_HOST_DEVICE double domainMax( ) const { return( m_domainMax ); } /**< Returns the value of the **m_domainMax**. */
LUPI_HOST_DEVICE double u_domainMin( ) const { return( m_u_domainMin ); } /**< Returns the value of the **m_u_domainMin**. */
LUPI_HOST_DEVICE double u_domainMax( ) const { return( m_u_domainMax ); } /**< Returns the value of the **m_u_domainMax**. */
LUPI_HOST_DEVICE double inverse_du( ) const { return( m_inverse_du ); } /**< Returns the value of the **m_inverse_du**. */
LUPI_HOST_DEVICE int index( double a_domain ) const ;
LUPI_HOST_DEVICE Vector<int> 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 ;
};
namespace Sampling {
enum class SampledType { firstTwoBody, secondTwoBody, uncorrelatedBody, unspecified, photon };
LUPI_HOST_DEVICE int evaluationForHashIndex( int a_hashIndex, Vector<int> const &a_hashIndices, double a_energy,
Vector<double> const &a_energies, double *a_energyFraction );
namespace Upscatter {
enum class Model { none, A, B, BSnLimits, DBRC };
/*
============================================================
===================== ModelDBRC_data =======================
============================================================
*/
class ModelDBRC_data {
public:
double m_neutronMass; /**< The mass of the neutron. */
double m_targetMass; /**< The mass of the target. */
Vector<double> m_energies; /**< The energy grid for the cross section. */
Vector<double> m_crossSections; /**< The cross sections corresponding to the energy grid. */
Vector<int> m_hashIndices; /**< The indicies for the energy hash function. */
MCGIDI::DomainHash m_domainHash; /**< The hash "function". */
public:
LUPI_HOST_DEVICE ModelDBRC_data( );
LUPI_HOST ModelDBRC_data( double a_neutronMass, double a_targetMass, Vector<double> const &a_energies, Vector<double> const &a_crossSections,
DomainHash const &a_domainHash );
LUPI_HOST_DEVICE ~ModelDBRC_data( );
LUPI_HOST_DEVICE double evaluate( double a_energy );
LUPI_HOST_DEVICE double targetThermalSpeed( double a_temperature );
LUPI_HOST_DEVICE double crossSectionMax( double a_energy, double a_targetThermalSpeed );
LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
};
LUPI_HOST_DEVICE ModelDBRC_data *serializeModelDBRC_data( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, ModelDBRC_data *a_modelDBRC_data );
} // End of namespace Upscatter.
/*
============================================================
================ ClientRandomNumberGenerator ===============
============================================================
*/
class ClientRandomNumberGenerator {
private:
double (*m_generator)( void * ); /**< User supplied generator. */
void *m_state; /**< User supplied state. */
public:
LUPI_HOST_DEVICE ClientRandomNumberGenerator( double (*a_generator)( void * ), void *a_state );
LUPI_HOST_DEVICE double (*generator( ))( void * ) { return( m_generator ); }
LUPI_HOST_DEVICE void *state( ) { return( m_state ); }
LUPI_HOST_DEVICE double Double( ) { return( m_generator( m_state ) ); }
// The following are deprecated.
LUPI_HOST_DEVICE double (*rng( ))( void * ) { return( generator( ) ); }
LUPI_HOST_DEVICE void *rngState( ) { return( state( ) ); }
LUPI_HOST_DEVICE double dRng( ) { return( Double( ) ); }
};
/*
============================================================
=================== Client Code RNG Data ===================
============================================================
*/
class ClientCodeRNGData : public ClientRandomNumberGenerator {
public:
LUPI_HOST_DEVICE ClientCodeRNGData( double (*a_generator)( void * ), void *a_state );
};
/*
============================================================
=========================== Input ==========================
============================================================
*/
class Input {
private:
bool m_wantVelocity = true ; /**< See member m_isVelocity in class Product for meaning. This is user input. */
public:
double m_temperature = 0.0; /**< Set by user. */
Upscatter::Model m_upscatterModel = Upscatter::Model::none; /**< The upscatter model to use when sampling a target's velocity. */
// The rest of the members are set by MCGIDI methods.
// These five are used for upscatter model A.
bool m_dataInTargetFrame = false; /**< **true if the data are in the target's frame and **false** otherwise. */
double m_projectileBeta = 0.0; /**< The beta = speed / c of the projectile. */
double m_relativeMu = 0.0; /**< BRB */
double m_targetBeta = 0.0; /**< The beta = speed / c of the target. */
double m_relativeBeta = 0.0; /**< The beta = speed / c of the relative speed between the projectile and the target.*/
double m_projectileEnergy = 0.0; /**< The energy of the projectile. */
SampledType m_sampledType = SampledType::uncorrelatedBody; /**< BRB */
Reaction const *m_reaction = nullptr; /**< The current reaction whose products are being sampled. */
double m_projectileMass = 0.0; /**< The mass of the projectile. */
double m_targetMass = 0.0; /**< The mass of the target. */
GIDI::Frame m_frame = GIDI::Frame::lab; /**< The frame the product data are returned in. */
int m_numberOfDBRC_rejections = 0; /**< For the DBRC upscattering model, this is the number of rejections + 1 per product sample. */
double m_mu = 0.0; /**< The sampled mu = cos( theta ) for the product. */
double m_phi = 0.0; /**< The sampled phi for the product. */
double m_energyOut1 = 0.0; /**< The sampled energy of the product. */
double m_px_vx1 = 0.0; /**< Variable used for two-body sampling. */
double m_py_vy1 = 0.0; /**< Variable used for two-body sampling. */
double m_pz_vz1 = 0.0; /**< Variable used for two-body sampling. */
double m_energyOut2 = 0.0; /**< The sampled energy of the second product for a two-body interaction. */
double m_px_vx2 = 0.0; /**< Variable used for two-body sampling. */
double m_py_vy2 = 0.0; /**< Variable used for two-body sampling. */
double m_pz_vz2 = 0.0; /**< Variable used for two-body sampling. */
int m_delayedNeutronIndex = -1; /**< If the product is a delayed neutron, this is its index. */
double m_delayedNeutronDecayRate = 0.0; /**< If the product is a delayed neutron, this is its decay rate. */
int m_GRIN_intermediateResidual = -1; /**< For special GRIN product sampling, this is the GNDS intid of the intermediate residual. */
LUPI_HOST_DEVICE Input( bool a_wantVelocity, Upscatter::Model a_upscatterModel );
LUPI_HOST_DEVICE bool wantVelocity( ) const { return( m_wantVelocity ); } /**< BRB */
};
/*
============================================================
========================== Product =========================
============================================================
*/
class Product {
public:
SampledType m_sampledType;
bool m_isVelocity; /**< If true, m_px_vx, m_py_vy and m_pz_vz are velocities otherwise momenta. */
int m_productIntid; /**< The intid of the sampled product. */
int m_productIndex; /**< The index of the sampled product. */
int m_userProductIndex; /**< The user particle index of the sampled product. */
int m_numberOfDBRC_rejections; /**< For the DBRC upscattering model, this is the number of rejections + 1 per product sample. */
double m_productMass; /**< The mass of the sampled product. */
double m_kineticEnergy; /**< The kinetic energy of the sampled product. */
double m_px_vx; /**< The velocity or momentum along the x-axis of the sampled product. */
double m_py_vy; /**< The velocity or momentum along the y-axis of the sampled product. */
double m_pz_vz; /**< The velocity or momentum along the z-axis of the sampled product. The z-axis is along the direction of the projectile's velolcity. */
int m_delayedNeutronIndex; /**< If the product is a delayed neutron, this is its index. */
double m_delayedNeutronDecayRate; /**< If the product is a delayed neutron, this is its decay rate. */
double m_birthTimeSec; /**< Some products, like delayed fission neutrons, are to appear (be born) later. This is the time in seconds that such a particle should be born since the interaction. */
};
/*
============================================================
====================== ProductHandler ======================
============================================================
*/
class ProductHandler {
public:
LUPI_HOST_DEVICE ProductHandler( ) {}
LUPI_HOST_DEVICE ~ProductHandler( ) {}
template <typename RNG, typename PUSHBACK>
LUPI_HOST_DEVICE void add( double a_projectileEnergy, int a_productIntid, int a_productIndex, int a_userProductIndex, double a_productMass, Input &a_input,
RNG && a_rng, PUSHBACK && push_back, bool isPhoton );
};
/*
============================================================
================ StdVectorProductHandler ===================
============================================================
*/
#ifdef __CUDACC__
#define MCGIDI_CUDACC_numberOfProducts 1000
class StdVectorProductHandler : public ProductHandler {
private:
std::size_t m_size;
Product m_products[1024];
public:
LUPI_HOST_DEVICE StdVectorProductHandler( ) : m_size( 0 ) { }
LUPI_HOST_DEVICE ~StdVectorProductHandler( ) { }
LUPI_HOST_DEVICE std::size_t size( ) { return( m_size ); }
LUPI_HOST_DEVICE Product &operator[]( long a_index ) { return( m_products[a_index] ); }
LUPI_HOST_DEVICE void push_back( Product &a_product ) {
if( m_size < MCGIDI_CUDACC_numberOfProducts ) {
m_products[m_size] = a_product;
++m_size;
}
}
LUPI_HOST_DEVICE void clear( ) { m_size = 0; }
};
#else
class StdVectorProductHandler : public ProductHandler {
private:
std::vector<Product> m_products; /**< The list of products sampled. */
public:
LUPI_HOST_DEVICE StdVectorProductHandler( ) : m_products( ) { }
LUPI_HOST_DEVICE ~StdVectorProductHandler( ) { }
LUPI_HOST_DEVICE std::size_t size( ) { return( m_products.size( ) ); }
LUPI_HOST_DEVICE Product &operator[]( long a_index ) { return( m_products[a_index] ); }
LUPI_HOST_DEVICE std::vector<Product> &products( ) { return( m_products ); }
LUPI_HOST_DEVICE void push_back( Product &a_product ) { m_products.push_back( a_product ); }
LUPI_HOST_DEVICE void clear( ) { m_products.clear( ); }
};
#endif
/*
============================================================
============== MCGIDIVectorProductHandler ==================
============================================================
*/
class MCGIDIVectorProductHandler : public ProductHandler {
private:
Vector<Product> m_products; /**< The list of products sampled. */
public:
LUPI_HOST_DEVICE MCGIDIVectorProductHandler( std::size_t a_size = 20 ) :
m_products( ) {
m_products.reserve( a_size );
}
LUPI_HOST_DEVICE ~MCGIDIVectorProductHandler( ) {}
LUPI_HOST_DEVICE std::size_t size( ) { return( m_products.size( ) ); }
LUPI_HOST_DEVICE Product const &operator[]( std::size_t a_index ) const { return( m_products[a_index] ); }
LUPI_HOST_DEVICE Vector<Product> const &products( ) const { return( m_products ); }
LUPI_HOST_DEVICE void push_back( Product &a_product ) { m_products.push_back( a_product ); }
LUPI_HOST_DEVICE void clear( ) { m_products.clear( ); }
};
} // End of namespace Sampling.
} // End of namespace MCGIDI.
#endif // End of MCGIDI_sampling_hpp_included
@@ -0,0 +1,174 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef MCGIDI_STRING_HPP
#define MCGIDI_STRING_HPP
/* Modified from Karsten Burger's version 2017
* Made changes to make it more compatible with GPUs.
* Allow for data to be initialized to nullptr.
*
* Modified from public domain software:
* Karsten Burger 2014
*
* Sourceforge project "Simple C++ String Class"
* http://sourceforge.net/projects/simplecstringclass/
* This a simple C++ string class based on class my_string by
* Christian Stigen Larsen, 2007, http://csl.name/programming/my_string/
*
* It only uses the C-string functions and is thus independent of the
* standard C++ library.
*
* It is public domain, in the hope, that you find it useful.
* Please note that there is no guarantee of any kind: it is supplied
* without any warranty; without even the implied warranty of
* merchantability or fitness for a particular purpose.
*
* You can probably replace std::string with this one in many
* cases, but a lot of stuff is missing, and I would recommend
* you stick to std::string anyway.
*
* I want to point out that there is nothing fancy about this class.
* It keeps every string in its own buffer, and copies as often as
* needed.
* The data always contains a trailing NUL char.
*
* However, I believe that is a good approach. For instance, it
* uses malloc rather than new, which makes it possible to use
* realloc. On many systems, realloc will try to use up "invisible"
* space that was used by malloc to pad a string for memory alignment.
* That makes it potentially fast for small concatenations.
*
* I don't propose to use this class for anything practical, since
* we already have std::string, but it may be an interesting read
* for C++ novices at the very least. Also, additional functions can
* easily be expanded.
*
* Also I met a case, where I had to avoid std::string because of
* link problems with an application using mixed libraries, especially
* one compiled with an old Intel compiler icc 7.
*
* Bugs/suggestions to info [at) dr-burger ]dot[ com
* or via the Sourceforge project page.
*/
#include <sys/types.h> // size_t
#include <stdexcept>
#include <LUPI_declareMacro.hpp>
/** @brief Simple C++ string class, useful as replacement for
std::string if this cannot be used, or just for fun.
*/
namespace MCGIDI {
class String
{
char* p; ///< The data
size_t allocated_; ///< The allocated memory size (including trailing NUL)
size_t size_; ///< The currently used memory size (excluding trailing NUL)
public:
typedef size_t size_type;
static const size_type npos;
LUPI_HOST_DEVICE String();
LUPI_HOST_DEVICE ~String();
LUPI_HOST_DEVICE String(const String&);
LUPI_HOST_DEVICE String(const char*);
LUPI_HOST_DEVICE String& operator=(const char*);
LUPI_HOST_DEVICE String& operator=(const String&);
LUPI_HOST_DEVICE String& operator+=(const String&);
LUPI_HOST_DEVICE String& operator+=(const char*);
LUPI_HOST_DEVICE String& operator+=(char);
LUPI_HOST_DEVICE void push_back(char);
friend String
LUPI_HOST_DEVICE operator+(const String& lhs, const String& rhs);
LUPI_HOST_DEVICE bool operator==(const char*) const;
LUPI_HOST_DEVICE bool operator==(const String&) const;
LUPI_HOST_DEVICE void clear(); // set string to empty string (memory remains reserved)
LUPI_HOST_DEVICE void clearMemory(); // set string to empty string (memory is free'd)
LUPI_HOST_DEVICE size_type size() const { return size_; } ///< size without terminating NUL
LUPI_HOST_DEVICE size_type length() const { return size_; } ///< as size()
// size if fully used
LUPI_HOST_DEVICE size_type capacity() const { return allocated_-1; }
// 8 byte alligned size
LUPI_HOST_DEVICE long internalSize() const {
long delta = allocated_;
long sub = delta % 8;
if (sub != 0) delta += (8-sub);
return delta * sizeof(char);
}
LUPI_HOST_DEVICE bool empty() const { return size_ == 0; }
LUPI_HOST_DEVICE const char* c_str() const { return p; } ///< raw data
/** Reserve internal string memory so that n characters can be put into the
string (plus 1 for the NUL char). If there is already enough memory,
nothing happens, if not, the memory will be realloated to exactly this
amount.
*/
LUPI_HOST_DEVICE void reserve( size_type n, char ** address = nullptr);
/** Resize string. If n is less than the current size, the string will be truncated.
If n is larger, then the memory will be reallocated to exactly this amount, and
the additional characters will be NUL characters.
*/
LUPI_HOST_DEVICE void resize( size_type n, char ** address = nullptr);
/** Resize string. If n is less than the current size, the string will be truncated.
If n is larger, then the memory will be reallocated to exactly this amount, and
the additional characters will be c characters.
*/
LUPI_HOST_DEVICE void resize( size_type n, char c, char ** address = nullptr);
/// swap contents
LUPI_HOST_DEVICE void swap( String& );
LUPI_HOST_DEVICE String substr(const size_type pos, size_type length) const;
// unchecked access:
LUPI_HOST_DEVICE char& operator[](const size_type i) { return p[i]; }
LUPI_HOST_DEVICE char operator[](const size_type i) const { return p[i]; }
// checked access:
LUPI_HOST_DEVICE char& at(const size_type i);
LUPI_HOST_DEVICE char at(const size_type i) const;
/// erase len characters at position pos
LUPI_HOST_DEVICE String& erase(size_type pos, size_type len);
/// Append n characters of a string
LUPI_HOST_DEVICE String& append(const char* str, size_type n);
LUPI_HOST_DEVICE int compare( size_type pos, size_type len, const String& str ) const;
LUPI_HOST_DEVICE int compare( size_type pos, size_type len, const char* str ) const;
private:
// reallocate the internal memory
LUPI_HOST_DEVICE void my_realloc( size_type n, char ** address = nullptr);
LUPI_HOST_DEVICE char* strdup_never_null(const char* other);
};
// class
LUPI_HOST_DEVICE bool operator<(const String&, const String&);
}
#endif
@@ -0,0 +1,468 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef MCGIDI_VECTOR_HPP
#define MCGIDI_VECTOR_HPP
#define CPU_MEM false
#define UVM_MEM true
#ifdef HAVE_OPENMP_TARGET
#ifdef USE_OPENMP_NO_GPU
#define VAR_MEM false
#else
#define VAR_MEM true
#endif
#else
#define VAR_MEM false
#endif
typedef int MCGIDI_VectorSizeType;
#define MCGIDI_SWAP(a,b,type) {type ttttttttt=a;a=b;b=ttttttttt;}
#if defined(__CUDACC__) && !defined(__CUDA_ARCH__)
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#endif
#if defined(__HIP__)
#include <hip/hip_version.h>
#include <hip/hip_runtime.h>
#include <hip/hip_runtime_api.h>
#include <hip/hip_common.h>
#endif
#include <string.h>
#include <stdio.h>
#include "cassert"
#include <algorithm>
#include <LUPI_declareMacro.hpp>
#include <vector>
namespace MCGIDI {
template <class T>
class Vector
{
private:
T* _data;
std::size_t _capacity;
std::size_t _size;
bool _mem_type;
public:
typedef T* iterator;
typedef T* const_iterator;
LUPI_HOST_DEVICE Vector() : _data(0), _capacity(0), _size(0), _mem_type(CPU_MEM) {};
LUPI_HOST_DEVICE Vector( std::size_t s, bool mem_flag = CPU_MEM ) : _data(0), _capacity(s), _size(s), _mem_type(mem_flag)
{
if( s == 0 ){ _data = nullptr; return;}
switch ((int)_mem_type){
case CPU_MEM:
_data = new T [_capacity];
break;
case UVM_MEM:
{
void *ptr = nullptr;
#if defined(__CUDACC__) && !defined(__CUDA_ARCH__)
cudaMallocManaged(&ptr, _capacity*sizeof(T), cudaMemAttachGlobal);
#elif defined(__HIP__) && !defined(__HIP_DEVICE_COMPILE__)
hipMallocManaged(&ptr, _capacity*sizeof(T), hipMemAttachGlobal);
#endif
_data = new(ptr) T[_capacity];
break;
}
default:
_data = new T [_capacity];
break;
}
}
LUPI_HOST_DEVICE Vector( std::size_t s, const T& d, bool mem_flag = CPU_MEM ) : _data(0), _capacity(s), _size(s), _mem_type(mem_flag)
{
if( s == 0 ){ _data = nullptr; return;}
switch ( (int) _mem_type){
case CPU_MEM:
_data = new T [_capacity];
break;
case UVM_MEM:
{
void *ptr = nullptr;
#if defined(__CUDACC__) && !defined(__CUDA_ARCH__)
cudaMallocManaged(&ptr, _capacity*sizeof(T), cudaMemAttachGlobal);
#elif defined(__HIP__) && !defined(__HIP_DEVICE_COMPILE__)
hipMallocManaged(&ptr, _capacity*sizeof(T), hipMemAttachGlobal);
#endif
_data = new(ptr) T[_capacity];
break;
}
default:
_data = new T [_capacity];
break;
}
for (std::size_t ii = 0; ii < _capacity; ++ii)
_data[ii] = d;
}
LUPI_HOST_DEVICE Vector(const Vector<T>& aa )
: _data(0), _capacity(aa._capacity), _size(aa._size), _mem_type(aa._mem_type)
{
if( _capacity == 0 ){ _data = nullptr; return; }
switch ( (int) _mem_type){
case CPU_MEM:
_data = new T [_capacity];
break;
case UVM_MEM:
{
void *ptr = nullptr;
#if defined(__CUDACC__) && !defined(__CUDA_ARCH__)
cudaMallocManaged(&ptr, _capacity*sizeof(T), cudaMemAttachGlobal);
#elif defined(__HIP__) && !defined(__HIP_DEVICE_COMPILE__)
hipMallocManaged(&ptr, _capacity*sizeof(T), hipMemAttachGlobal);
#endif
_data = new(ptr) T[_capacity];
break;
}
default:
_data = new T [_capacity];
break;
}
for (std::size_t ii=0; ii<_size; ++ii)
_data[ii] = aa._data[ii];
}
LUPI_HOST Vector(const std::vector<T>& aa )
: _data(0), _capacity(aa.size()), _size(aa.size()), _mem_type(CPU_MEM)
{
if( _capacity == 0 ){ _data = nullptr; return;}
switch ( (int) _mem_type){
case CPU_MEM:
_data = new T [_capacity];
break;
case UVM_MEM:
{
void *ptr = nullptr;
#if defined(__CUDACC__) && !defined(__CUDA_ARCH__)
cudaMallocManaged(&ptr, _capacity*sizeof(T), cudaMemAttachGlobal);
#elif defined(__HIP__) && !defined(__HIP_DEVICE_COMPILE__)
hipMallocManaged(&ptr, _capacity*sizeof(T), hipMemAttachGlobal);
#endif
_data = new(ptr) T[_capacity];
break;
}
default:
_data = new T [_capacity];
break;
}
for (std::size_t ii=0; ii<_size; ++ii)
_data[ii] = aa[ii];
}
LUPI_HOST_DEVICE ~Vector() {
switch ( (int) _mem_type){
case CPU_MEM:
delete[] _data;
break;
case UVM_MEM:
for (std::size_t i=0; i < _size; ++i)
_data[i].~T();
#if defined(__CUDACC__) && !defined(__CUDA_ARCH__)
cudaFree(_data);
#elif defined(__HIP__) && !defined(__HIP_DEVICE_COMPILE__)
hipFree(_data);
#endif
break;
default:
delete[] _data;
break;
}
}
LUPI_HOST_DEVICE iterator begin() { return _data; }
LUPI_HOST_DEVICE const_iterator begin() const { return _data; }
LUPI_HOST_DEVICE iterator end() { return _data + _size; }
LUPI_HOST_DEVICE const_iterator end() const { return _data + _size; }
/// Needed for copy-swap idiom
LUPI_HOST_DEVICE void swap(Vector<T>& other)
{
MCGIDI_SWAP(_data, other._data, T*);
MCGIDI_SWAP(_capacity, other._capacity, std::size_t);
MCGIDI_SWAP(_size, other._size, std::size_t);
MCGIDI_SWAP(_mem_type, other._mem_type, bool);
}
/// Implement assignment using copy-swap idiom
LUPI_HOST_DEVICE Vector<T>& operator=(const Vector<T>& aa)
{
if (&aa != this)
{
Vector<T> temp(aa);
this->swap(temp);
}
return *this;
}
LUPI_HOST Vector<T>& operator=(const std::vector<T>& aa)
{
Vector<T> temp(aa);
this->swap(temp);
return *this;
}
LUPI_HOST_DEVICE int get_mem_type()
{
return _mem_type;
}
LUPI_HOST_DEVICE void push_back( const T& dataElem )
{
assert( _size < _capacity );
_data[_size] = dataElem;
_size++;
}
LUPI_HOST_DEVICE const T& operator[]( std::size_t index ) const
{
// assert( index < _capacity );
// assert( index >= 0); comment out pointless assertion size_t type is >= 0 by definition
return _data[index];
}
LUPI_HOST_DEVICE T& operator[]( std::size_t index )
{
// assert( index < _capacity );
// assert( index >= 0); comment out pointless assertion size_t type is >= 0 by definition
return _data[index];
}
LUPI_HOST_DEVICE std::size_t capacity() const
{
return _capacity;
}
LUPI_HOST_DEVICE std::size_t size() const
{
return _size;
}
LUPI_HOST_DEVICE T& back()
{
return _data[_size-1];
}
LUPI_HOST_DEVICE T& back() const
{
return _data[_size-1];
}
LUPI_HOST_DEVICE void reserve( std::size_t s, char ** address = nullptr, bool mem_flag = CPU_MEM )
{
if (s == _capacity) return;
assert( _capacity == 0 );
_capacity = s;
_mem_type = mem_flag;
if( s == 0 ){ _data = nullptr; return;}
switch ( (int) _mem_type){
case CPU_MEM:
if (address == nullptr || *address == nullptr) _data = new T [_capacity];
else {
_data = new(*address) T [_capacity];
*address += sizeof(T) * _capacity;
}
break;
case UVM_MEM:
{
void *ptr = nullptr;
#if defined(__CUDACC__) && !defined(__CUDA_ARCH__)
cudaMallocManaged(&ptr, _capacity*sizeof(T), cudaMemAttachGlobal);
#elif defined(__HIP__) && !defined(__HIP_DEVICE_COMPILE__)
hipMallocManaged(&ptr, _capacity*sizeof(T), hipMemAttachGlobal);
#endif
_data = new(ptr) T[_capacity];
break;
}
default:
if (address == nullptr || *address == nullptr) _data = new T [_capacity];
else {
_data = new(*address) T [_capacity];
*address += sizeof(T) * _capacity;
}
break;
}
}
LUPI_HOST_DEVICE void resize( std::size_t s, char ** address = nullptr, bool mem_flag = CPU_MEM )
{
if (_capacity != 0) {
assert( _capacity >= s);
_size = s;
return;
}
assert( _capacity == 0 );
_capacity = s;
_size = s;
_mem_type = mem_flag;
if( s == 0 ){ _data = nullptr; return;}
switch ( (int) _mem_type){
case CPU_MEM:
if (address == nullptr || *address == nullptr) {
_data = new T [_capacity];
}
else {
_data = new(*address) T [_capacity];
std::size_t delta = sizeof(T) * _capacity;
std::size_t sub = delta % 8;
if (sub != 0) delta += (8-sub);
*address += delta;
}
break;
case UVM_MEM:
{
void *ptr = nullptr;
#if defined(__CUDACC__) && !defined(__CUDA_ARCH__)
cudaMallocManaged(&ptr, _capacity*sizeof(T), cudaMemAttachGlobal);
#elif defined(__HIP__) && !defined(__HIP_DEVICE_COMPILE__)
hipMallocManaged(&ptr, _capacity*sizeof(T), hipMemAttachGlobal);
#endif
_data = new(ptr) T[_capacity];
break;
}
default:
if (address == nullptr || *address == nullptr) _data = new T [_capacity];
else {
_data = new(*address) T [_capacity];
std::size_t delta = sizeof(T) * _capacity;
std::size_t sub = delta % 8;
if (sub != 0) delta += (8-sub);
*address += delta;
}
break;
}
}
LUPI_HOST_DEVICE void resize( std::size_t s, const T& d, char ** address = nullptr, bool mem_flag = CPU_MEM )
{
assert( _capacity == 0 );
_capacity = s;
_size = s;
_mem_type = mem_flag;
if( s == 0 ){ _data = nullptr; return;}
switch ( (int) _mem_type){
case CPU_MEM:
if (address == nullptr || *address == nullptr) _data = new T [_capacity];
else {
_data = new(*address) T [_capacity];
std::size_t delta = sizeof(T) * _capacity;
std::size_t sub = delta % 8;
if (sub != 0) delta += (8-sub);
*address += delta;
}
break;
case UVM_MEM:
{
void *ptr = nullptr;
#if defined(__CUDACC__) && !defined(__CUDA_ARCH__)
cudaMallocManaged(&ptr, _capacity*sizeof(T), cudaMemAttachGlobal);
#elif defined(__HIP__) && !defined(__HIP_DEVICE_COMPILE__)
hipMallocManaged(&ptr, _capacity*sizeof(T), hipMemAttachGlobal);
#endif
_data = new(ptr) T[_capacity];
break;
}
default:
if (address == nullptr || *address == nullptr) _data = new T [_capacity];
else {
_data = new(*address) T [_capacity];
std::size_t delta = sizeof(T) * _capacity;
std::size_t sub = delta % 8;
if (sub != 0) delta += (8-sub);
*address += delta;
*address += sizeof(T) * _capacity;
}
break;
}
for (std::size_t ii = 0; ii < _capacity; ++ii)
_data[ii] = d;
}
LUPI_HOST_DEVICE bool empty() const
{
return ( _size == 0 );
}
LUPI_HOST_DEVICE void eraseEnd( std::size_t NewEnd )
{
assert( NewEnd <= _size );
_size = NewEnd;
}
LUPI_HOST_DEVICE void pop_back()
{
assert(_size > 0);
_size--;
}
LUPI_HOST_DEVICE void clear()
{
_size = 0;
}
LUPI_HOST_DEVICE void appendList( std::size_t listSize, T* list )
{
assert( _size + listSize < _capacity );
for( std::size_t i = _size; i < _size + listSize; i++ )
{
_data[i] = list[ i-_size ];
}
}
//Atomically retrieve an availible index then increment that index some amount
LUPI_HOST_DEVICE std::size_t atomic_Index_Inc( std::size_t inc )
{
if (_size+inc > _capacity)
{MCGIDI_PRINTF("inc too much (size %d, inc %d cap %d)\n", _size, inc, _capacity); abort(); }
assert(_size+inc <= _capacity);
std::size_t pos;
// #include "mc_omp_atomic_capture.hh"
{pos = _size; _size = _size + inc;}
return pos;
}
// This will not work for a vector of base classes.
LUPI_HOST_DEVICE std::size_t internalSize() const {
std::size_t delta = sizeof(T) * _size;
std::size_t sub = delta % 8;
if (sub != 0) delta += (8-sub);
return delta;
}
LUPI_HOST_DEVICE void forceCreate(std::size_t a_size, T* a_data) {
_capacity = a_size;
_size = a_size;
_data = a_data;
}
};
}
#endif
File diff suppressed because it is too large Load Diff
@@ -1,126 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef PoPs_h_included
#define PoPs_h_included
/* Disable Effective C++ warnings in PoP code. */
#if __INTEL_COMPILER > 1399
#pragma warning( disable:593 )
#endif
#include <statusMessageReporting.h>
/*
* MPI stuff.
*/
#ifdef PoPs_MPI
#include <mpi.h>
#endif
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
#define POPS_VERSION_MAJOR 1
#define POPS_VERSION_MINOR 0
#define POPS_VERSION_PATCHLEVEL 5
#define PoPs_packageSymbol "PoPs (properties of particles)"
#define PoPs_packageName PoPs_packageSymbol " (properties of particles)"
typedef struct PoP_s PoP;
enum PoPs_errorTokens { PoPs_errorToken_Okay, PoPs_errorToken_badName, PoPs_errorToken_badIndex, PoPs_errorToken_badUnitConversion };
enum PoPs_genre { PoPs_genre_invalid, PoPs_genre_unknown, PoPs_genre_alias, PoPs_genre_photon, PoPs_genre_lepton,
PoPs_genre_quark, PoPs_genre_meson, PoPs_genre_baryon, PoPs_genre_nucleus, PoPs_genre_atom };
/*
* In the following struct, 'index' is the index of the particle (proper or aliased) in the list of particles. If a particle
* is a proper particle its properIndex is -1. Otherwise, it is the index of the aliased particle's proper particle. If a proper
* particle does not have an aliased particle referring to it, aliasIndex is -1. If a proper particle has aliaes particles,
* its aliasIndex is the index of its first aliased particle. If a second alias is added to a proper particle, then its first
* aliased particle's aliasIndex is the index of that particle, and so on. The last aliased particle added has aliasIndex = -1.
*/
struct PoP_s { /* Any changes here must be reflected in functions PoP_initialize and PoP_copyParticle and in file PoPs_Bcast.c logic. */
int index, properIndex, aliasIndex;
enum PoPs_genre genre;
char const *name;
int Z, A, l;
double mass; /* Mass to be added to base. */
char const *massUnit;
};
extern int PoPs_smr_ID;
const char *PoPs_version( void );
int PoPs_versionMajor( void );
int PoPs_versionMinor( void );
int PoPs_versionPatchLevel( void );
int PoPs_register( void );
int PoPs_readDatabase( statusMessageReporting *smr, char const *fileName );
int PoPs_release( statusMessageReporting *smr );
PoP *PoPs_addParticleIfNeeded( statusMessageReporting *smr, PoP *pop );
PoP *PoPs_copyAddParticleIfNeeded( statusMessageReporting *smr, PoP *pop );
PoP *PoPs_addAliasIfNeeded( statusMessageReporting *smr, char const *name, char const *alias );
int PoPs_numberOfParticle( void );
int PoPs_particleIndex( char const *name );
int PoPs_particleIndex_smr( statusMessageReporting *smr, char const *name, char const *file, int line, char const *func );
char const *PoPs_getName_atIndex( statusMessageReporting *smr, int index );
double PoPs_getMassInUnitOf( statusMessageReporting *smr, char const *name, char const *unit );
double PoPs_getMassInUnitOf_atIndex( statusMessageReporting *smr, int index, char const *unit );
enum PoPs_genre PoPs_getGenre( statusMessageReporting *smr, char const *name );
enum PoPs_genre PoPs_getGenre_atIndex( statusMessageReporting *smr, int index );
int PoPs_getZ_A_l( statusMessageReporting *smr, char const *name, int *Z, int *A, int *l );
int PoPs_getZ_A_l_atIndex( statusMessageReporting *smr, int index, int *Z, int *A, int *l );
int PoPs_hasNucleus( statusMessageReporting *smr, char const *name, int protonIsNucleus );
int PoPs_hasNucleus_atIndex( statusMessageReporting *smr, int index, int protonIsNucleus );
char const *PoPs_getAtomsName( statusMessageReporting *smr, char const *name );
char const *PoPs_getAtomsName_atIndex( statusMessageReporting *smr, int index );
int PoPs_getAtomsIndex( statusMessageReporting *smr, char const *name );
int PoPs_getAtomsIndex_atIndex( statusMessageReporting *smr, int index );
PoP *PoPs_getParticle_atIndex( int index );
char const *PoPs_genreTokenToString( enum PoPs_genre genre );
void PoPs_print( int sorted );
void PoPs_write( FILE *f, int sorted );
PoP *PoP_new( statusMessageReporting *smr );
int PoP_initialize( statusMessageReporting *smr, PoP *pop );
int PoP_release( PoP *pop );
PoP *PoP_free( PoP *pop );
int PoP_copyParticle( statusMessageReporting *smr, PoP *desc, PoP *src );
PoP *PoP_makeParticle( statusMessageReporting *smr, enum PoPs_genre genre, char const *name, double mass, char const *massUnit );
int PoP_setZ_A_l( statusMessageReporting *smr, PoP *pop, int Z, int A, int l );
int PoP_getIndex( PoP *pop );
char const *PoP_getName( PoP *pop );
int PoPs_particleReadDatabase( statusMessageReporting *smr, char const *name );
PoP *PoPs_particleCreateLoadInfo( statusMessageReporting *smr, const char *name );
int PoPs_particleLoadInfo( statusMessageReporting *smr, const char *name, PoP *pop );
double PoP_getMassInUnitOf( statusMessageReporting *smr, PoP *pop, char const *unit );
PoP *PoP_makeAlias( statusMessageReporting *smr, char const *name, char const *alias );
int PoPs_unitConversionRatio( char const *_from, char const *_to, double *ratio );
int lPoPs_addParticleIfNeeded( statusMessageReporting *smr, char const *name, char const *special );
/*
* MPI stuff.
*/
#ifdef PoPs_MPI
int PoPs_Bcast( statusMessageReporting *smr, MPI_Comm comm, int bossRank );
#endif
/* Use the next function with caution as it is only for initial testing of the package and will soon be gone. */
int PoPs_setBDFLS_File( char const *name );
#if defined __cplusplus
}
}
#endif
#endif /* End of PoPs_h_included. */
@@ -1,22 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef PoPs_Bcast_private_h_included
#define PoPs_Bcast_private_h_included
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
int PoPs_Bcast2( statusMessageReporting *smr, MPI_Comm comm, int bossRank, unitsDB *unitsRoot, PoPs *popsRoot );
#if defined __cplusplus
}
}
#endif
#endif /* End of PoPs_Bcast_private_h_included. */
File diff suppressed because it is too large Load Diff
@@ -1,22 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef PoPs_mass_h_included
#define PoPs_mass_h_included
#include <statusMessageReporting.h>
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
double PoPs_particleMass_AMU( statusMessageReporting *smr, char const *name );
#if defined __cplusplus
}
}
#endif
#endif /* End of PoPs_mass_h_included. */
@@ -1,41 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef PoPs_private_h_included
#define PoPs_private_h_included
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
typedef struct unitsDB_s unitsDB;
typedef struct PoPs_s PoPs;
struct unitsDB_s {
int numberOfUnits;
int allocated;
char const **unsorted;
};
struct PoPs_s {
int numberOfParticles;
int allocated;
PoP **pops;
PoP **sorted;
};
int PoPs_releasePrivate( statusMessageReporting *smr );
char const *unitsDB_addUnitIfNeeded( statusMessageReporting *smr, char const *unit );
int unitsDB_index( statusMessageReporting *smr, char const *unit );
char const *unitsDB_stringFromIndex( statusMessageReporting *smr, int index );
#if defined __cplusplus
}
}
#endif
#endif /* End of PoPs_private_h_included. */
@@ -0,0 +1,130 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef RISI_hpp_included
#define RISI_hpp_included 1
#include <map>
#include <set>
#include <LUPI.hpp>
namespace GIDI {
namespace RISI {
class Projectile;
class Reaction {
public:
double m_effectiveThreshold; /**< The effective threshold for the reaction. */
std::vector<std::string> m_products; /**< The list of final products for the reaction. */
std::vector<int> m_multiplicities; /**< The multiplicities for each product in *m_products*. */
std::vector<std::string> m_intermediates; /**< The list of intermediates products for the reaction. */
std::string m_process; /**< The process for the reaction. */
std::string m_reactionLabel; /**< The label of the reaction. */
std::string m_convarianceFlag; /**< A flag indicating if covariance data are present for the reaction. */
public:
Reaction( double a_effectiveThreshold, std::vector<std::string> const &a_products, std::vector<int> const &a_multiplicities,
std::vector<std::string> const &a_intermediates, std::string const &a_process, std::string const &reactionLabel,
std::string const &convarianceFlag );
void products( double a_energyMax, std::set<std::string> &a_products ) const ;
};
class Protare {
private:
int m_addMode; /**< Indicates which method **add** calls. */
std::string m_projectile; /**< The PoPs id for the projectile. */
std::string m_target; /**< The PoPs id for the target. */
std::string m_evaluation; /**< The evaluation for the protare. */
double m_energyConversionFactor; /**< Factor to convert from file energy units to user energy units. */
std::map<std::string, std::string> m_aliases; /**< The list of meta-stable aliases in the protare. */
std::vector<Reaction *> m_reactions; /**< The list of **Reaction** instances for the protare. */
public:
Protare( std::string const &a_projectile, std::string const &a_target, std::string const &a_evaluation,
std::string const &a_protareEnergyUnit, std::string const &a_requestedEnergyUnit );
~Protare();
std::string const &projectile( ) { return( m_projectile ); }
std::string const &target( ) { return( m_target ); }
std::string const &evaluation( ) { return( m_evaluation ); }
void Oops( std::vector<std::string> const &a_elements );
void addAlias( std::vector<std::string> const &a_elements );
void setAddingAliases( ) { m_addMode = 1; } /**< Tells **add** method to call the **addAlias** method. */
void addReaction( std::vector<std::string> const &a_elements );
void setAddingReactions( ) { m_addMode = 2; } /**< Tells **add** method to call the **addReaction** method. */
void add( std::vector<std::string> const &a_elements );
void products( Projectile const *a_projectile, int a_level, int a_maxLevel, double a_energyMax, std::map<std::string, int> &a_products ) const ;
};
class Target {
private:
std::string m_id;
std::vector<Protare *> m_protares;
public:
Target( std::string const &a_id ) :
m_id( a_id ) {
}
~Target( );
void add( Protare *a_protare );
void products( Projectile const *a_projectile, int a_level, int a_maxLevel, double a_energyMax, std::map<std::string, int> &a_products ) const ;
void print( std::string const &a_indent = "" ) const ;
};
class Projectile {
private:
std::string m_id;
std::map<std::string, Target *> m_targets;
public:
Projectile( std::string const &a_id ) :
m_id( a_id ) {
}
~Projectile( );
void add( Protare *a_protare );
void products( std::string const &a_target, int a_level, int a_maxLevel, double a_energyMax, std::map<std::string, int> &a_products ) const ;
void print( std::string const &a_indent = "" ) const ;
};
class Projectiles {
private:
std::map<std::string, Projectile *> m_projectiles;
public:
Projectiles( ) {}
~Projectiles( );
void add( Protare *a_protare );
void clear( );
std::vector<std::string> products( std::string const &a_projectile, std::vector<std::string> const &a_seedTargets, int a_maxLevel,
double a_energyMax ) const ;
void print( std::string const &a_indent = "" ) const ;
};
void readRIS( std::string const &a_fileName, std::string const &a_energyUnit, Projectiles &a_projectiles );
} // End of namespace RISI.
} // End of namespace GIDI.
#endif // End of RISI_hpp_included
@@ -0,0 +1,5 @@
#define G4GIDI_MAJOR 1
#define G4GIDI_MINOR 1
#define G4GIDI_PATCHLEVEL 13
#define G4GIDI_VERSION "1.1.13"
#define G4GIDI_GIT "62db2f9b95bcd850c8821e70db50c4c94874cc4d"
@@ -1,5 +1,9 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
@@ -11,16 +15,16 @@
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
#define nf_Legendre_minMaxOrder 4
#define nf_Legendre_maxMaxOrder 64
#define nf_Legendre_maxMaxOrder 128
#define nf_Legendre_sizeIncrement 8
typedef struct nf_Legendre_s nf_Legendre;
struct nf_Legendre_s {
nfu_status status;
int maxOrder;
int allocated; /* Will never be less than nf_Legendre_minMaxOrder. */
double *Cls;
@@ -31,21 +35,22 @@ typedef nfu_status (*nf_Legendre_GaussianQuadrature_callback)( double x, double
/*
* Methods in nf_Legendre.c
*/
nf_Legendre *nf_Legendre_new( int initialSize, int maxOrder, double *Cls, nfu_status *status );
nfu_status nf_Legendre_setup( nf_Legendre *nfL, int initialSize, int maxOrder );
nfu_status nf_Legendre_release( nf_Legendre *nfL );
nf_Legendre *nf_Legendre_new( statusMessageReporting *smr, int initialSize, int maxOrder, double *Cls );
nfu_status nf_Legendre_initialize( statusMessageReporting *smr, nf_Legendre *nfL, int initialSize, int maxOrder );
nfu_status nf_Legendre_release( statusMessageReporting *smr, nf_Legendre *nfL );
nf_Legendre *nf_Legendre_free( nf_Legendre *nfL );
nf_Legendre *nf_Legendre_clone( nf_Legendre *nfL, nfu_status *status );
nfu_status nf_Legendre_reallocateCls( nf_Legendre *Legendre, int size, int forceSmallerResize );
int nf_Legendre_maxOrder( nf_Legendre *Legendre );
int nf_Legendre_allocated( nf_Legendre *Legendre );
double nf_Legendre_getCl( nf_Legendre *Legendre, int l, nfu_status *status );
nfu_status nf_Legendre_setCl( nf_Legendre *Legendre, int l, double Cl );
nfu_status nf_Legendre_normalize( nf_Legendre *Legendre );
double nf_Legendre_evauluateAtMu( nf_Legendre *nfL, double mu, nfu_status *status );
nf_Legendre *nf_Legendre_clone( statusMessageReporting *smr, nf_Legendre *nfL );
nfu_status nf_Legendre_reallocateCls( statusMessageReporting *smr, nf_Legendre *Legendre, int size, int forceSmallerResize );
nfu_status nf_Legendre_maxOrder( statusMessageReporting *smr, nf_Legendre *Legendre, int *maxOrder );
nfu_status nf_Legendre_allocated( statusMessageReporting *smr, nf_Legendre *Legendre, int *allocated );
nfu_status nf_Legendre_getCl( statusMessageReporting *smr, nf_Legendre *Legendre, int l, double *Cl );
nfu_status nf_Legendre_setCl( statusMessageReporting *smr, nf_Legendre *Legendre, int l, double Cl );
nfu_status nf_Legendre_normalize( statusMessageReporting *smr, nf_Legendre *Legendre );
nfu_status nf_Legendre_evauluateAtMu( statusMessageReporting *smr, nf_Legendre *nfL, double mu, double *P );
double nf_Legendre_PofL_atMu( int l, double mu );
ptwXYPoints *nf_Legendre_to_ptwXY( nf_Legendre *nfL, double accuracy, int biSectionMax, int checkForRoots, nfu_status *status );
nf_Legendre *nf_Legendre_from_ptwXY( ptwXYPoints *ptwXY, int maxOrder, nfu_status *status );
ptwXYPoints *nf_Legendre_to_ptwXY( statusMessageReporting *smr, nf_Legendre *nfL, double accuracy, int biSectionMax,
int checkForRoots );
nf_Legendre *nf_Legendre_from_ptwXY( statusMessageReporting *smr, ptwXYPoints *ptwXY, int maxOrder );
/*
* Methods in nf_Legendre_GaussianQuadrature.c
@@ -54,7 +59,6 @@ nfu_status nf_Legendre_GaussianQuadrature( int degree, double x1, double x2, nf_
#if defined __cplusplus
}
}
#endif
#endif /* End of nf_Legendre_h_included. */
@@ -0,0 +1,128 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef nf_buffer_h_included
#define nf_buffer_h_included
#if defined __cplusplus
#include <iterator>
template<typename T>
class nf_Buffer {
private:
T *m_data;
size_t m_length;
public:
using iterator = T*;
using const_iterator = T const *;
inline
constexpr
nf_Buffer() noexcept : m_data(nullptr), m_length(0) {}
inline
nf_Buffer(nf_Buffer const &c) :
m_data(new T[c.m_length]),
m_length(c.m_length)
{
for(size_t i = 0;i < m_length;++ i){
m_data[i] = c.m_data[i];
}
}
inline
~nf_Buffer() noexcept {
deallocate();
}
inline
constexpr
size_t size() const noexcept { return m_length; }
inline
void clear(T value){
for(size_t i = 0;i < m_length;++ i){
m_data[i] = value;
}
}
inline
void allocate(size_t length){
deallocate();
m_length = length;
m_data = new T[length];
}
inline
void deallocate() noexcept {
delete[] m_data;
m_length = 0;
}
inline
void resize(size_t length){
allocate(length);
}
inline
std::vector<T> vector() const {
return std::vector<T>(cbegin(), cend());
}
inline
T* data() noexcept {return m_data;}
inline
constexpr
T const * data() const noexcept {return m_data;}
template<typename I>
inline
T& operator[](I idx) noexcept {return m_data[idx];}
template<typename I>
inline
constexpr
T const & operator[](I idx) const noexcept {return m_data[idx];}
inline
iterator begin() noexcept { return m_data; }
inline
constexpr
const_iterator begin() const noexcept { return m_data; }
inline
iterator end() noexcept { return m_data + m_length; }
inline
constexpr
const_iterator end() const noexcept { return m_data + m_length; }
inline
constexpr
const_iterator cbegin() const noexcept { return m_data; }
inline
constexpr
const_iterator cend() const noexcept { return m_data + m_length; }
};
#endif
#endif /* End of nf_buffer_h_included. */
@@ -1,5 +1,9 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
@@ -11,7 +15,6 @@
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
#define nf_GnG_adaptiveQuadrature_MaxMaxDepth 20
@@ -24,7 +27,6 @@ nfu_status nf_GnG_adaptiveQuadrature( nf_GnG_adaptiveQuadrature_callback quadrat
#if defined __cplusplus
}
}
#endif
#endif /* End of nf_integration_h_included. */
@@ -1,44 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef specialFunctions_h_included
#define specialFunctions_h_included
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>
#include "nf_utilities.h"
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
double nf_polevl( double x, double coef[], int N );
double nf_p1evl( double x, double coef[], int N );
double nf_exponentialIntegral( int n, double x, nfu_status *status );
double nf_gammaFunction( double x, nfu_status *status );
double nf_logGammaFunction( double x, nfu_status *status );
double nf_incompleteGammaFunction( double a, double x, nfu_status *status );
double nf_incompleteGammaFunctionComplementary( double a, double x, nfu_status *status );
double nf_amc_log_factorial( int );
double nf_amc_factorial( int );
double nf_amc_wigner_3j( int, int, int, int, int, int );
double nf_amc_wigner_6j( int, int, int, int, int, int );
double nf_amc_wigner_9j( int, int, int, int, int, int, int, int, int );
double nf_amc_racah( int, int, int, int, int, int );
double nf_amc_clebsh_gordan( int, int, int, int, int );
double nf_amc_z_coefficient( int, int, int, int, int, int );
double nf_amc_zbar_coefficient( int, int, int, int, int, int );
double nf_amc_reduced_matrix_element( int, int, int, int, int, int, int );
#if defined __cplusplus
}
}
#endif
#endif /* End of ptwXY_h_included. */
@@ -1,17 +1,31 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef nf_utilities_h_included
#define nf_utilities_h_included
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
#include <math.h>
#define NUMERICALFUNCTIONS_SVN_VERSION 110+
#include <statusMessageReporting.h>
extern int nfu_SMR_libraryID;
#ifdef __APPLE__
#ifndef NFU_USEHEAP
#define NFU_USEHEAP 1
#endif
#endif
#define nf_floatToShortestString_trimZeros ( 1 << 0 )
#define nf_floatToShortestString_keepPeriod ( 1 << 1 )
@@ -19,40 +33,69 @@
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
typedef enum nfu_status_e { nfu_Okay, nfu_mallocError, nfu_insufficientMemory,
nfu_badIndex, nfu_XNotAscending, nfu_badIndexForX, nfu_XOutsideDomain,
nfu_invalidInterpolation, nfu_badSelf, nfu_divByZero, nfu_unsupportedInterpolationConversion,
nfu_unsupportedInterpolation, nfu_empty, nfu_tooFewPoints, nfu_domainsNotMutual,
nfu_badInput, nfu_badNorm, nfu_badIntegrationInput, nfu_otherInterpolation,
nfu_failedToConverge, nfu_oddNumberOfValues } nfu_status;
typedef enum nfu_status_e {
nfu_Okay,
nfu_Error,
nfu_badSelf,
nfu_mallocError,
nfu_insufficientMemory,
nfu_badIndex,
nfu_XNotAscending,
nfu_badIndexForX,
nfu_XOutsideDomain,
nfu_invalidInterpolation,
nfu_divByZero,
nfu_unsupportedInterpolationConversion,
nfu_unsupportedInterpolation,
nfu_empty,
nfu_tooFewPoints,
nfu_domainsNotMutual,
nfu_badInput,
nfu_badNorm,
nfu_badIntegrationInput,
nfu_otherInterpolation,
nfu_flatInterpolation,
nfu_failedToConverge,
nfu_oddNumberOfValues,
nfu_badLogValue
} nfu_status;
/*
* Functions in nf_utilities.c
*/
int nfu_setup( void );
double nfu_getNAN( void );
int nfu_isNAN( double d );
double nfu_getInfinity( double sign );
const char *nfu_statusMessage( nfu_status status );
void nfu_setMemoryDebugMode( int mode );
void nfu_printMsg( char const *fmt, ... );
void nfu_printErrorMsg( char const *fmt, ... );
/*
* These function are to be deleted when conversion to statusMessageReporting is completed.
*/
void *nfu_malloc( size_t size );
void *nfu_calloc( size_t size, size_t n );
void *nfu_realloc( size_t size, void *old );
void *nfu_free( void *p );
void nfu_printMsg( char *fmt, ... );
void nfu_printErrorMsg( char *fmt, ... );
/*
* Functions in nf_stringToInt32s.c
*/
int32_t *nfu_stringToListOfInt32s( statusMessageReporting *smr, char const *str, char sep, int64_t *numberConverted, char **endCharacter );
int nfu_stringToInt32( statusMessageReporting *smr, char const *str, char **endCharacter, int32_t *value );
/*
* Functions in nf_stringToDoubles.c
*/
nfu_status nfu_stringToListOfDoubles( char const *str, int64_t *numberConverted, double **doublePtr, char **endCharacter );
double *nfu_stringToListOfDoubles( statusMessageReporting *smr, char const *str, char sep, int64_t *numberConverted,
char **endCharacter, int useSystem_strtod );
double nf_strtod( char const *ptr, char **endCharacter );
char *nf_floatToShortestString( double value, int significantDigits, int favorEFormBy, int flags );
#if defined __cplusplus
}
}
#endif
#endif /* End of nf_utilities_h_included. */
@@ -1,5 +1,9 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
@@ -13,7 +17,6 @@
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
#define ptwX_minimumSize 10
@@ -32,56 +35,57 @@ typedef
/*
* Routines in ptwX_core.c
*/
ptwXPoints *ptwX_new( int64_t size, nfu_status *status );
nfu_status ptwX_setup( ptwXPoints *ptwX, int64_t size );
ptwXPoints *ptwX_create( int64_t size, int64_t length, double const *xs, nfu_status *status );
ptwXPoints *ptwX_createLine( int64_t size, int64_t length, double slope, double offset, nfu_status *status );
nfu_status ptwX_copy( ptwXPoints *dest, ptwXPoints *src );
ptwXPoints *ptwX_clone( ptwXPoints *ptwX, nfu_status *status );
ptwXPoints *ptwX_slice( ptwXPoints *ptwX, int64_t index1, int64_t index2, nfu_status *status );
nfu_status ptwX_reallocatePoints( ptwXPoints *ptwX, int64_t size, int forceSmallerResize );
nfu_status ptwX_clear( ptwXPoints *ptwX );
nfu_status ptwX_release( ptwXPoints *ptwX );
ptwXPoints *ptwX_new( statusMessageReporting *smr, int64_t size );
nfu_status ptwX_initialize( statusMessageReporting *smr, ptwXPoints *ptwX, int64_t size );
ptwXPoints *ptwX_create( statusMessageReporting *smr, int64_t size, int64_t length, double const *xs );
ptwXPoints *ptwX_createLine( statusMessageReporting *smr, int64_t size, int64_t length, double slope, double offset );
nfu_status ptwX_copy( statusMessageReporting *smr, ptwXPoints *dest, ptwXPoints *src );
ptwXPoints *ptwX_clone( statusMessageReporting *smr, ptwXPoints *ptwX );
ptwXPoints *ptwX_slice( statusMessageReporting *smr, ptwXPoints *ptwX, int64_t index1, int64_t index2 );
nfu_status ptwX_reallocatePoints( statusMessageReporting *smr, ptwXPoints *ptwX, int64_t size, int forceSmallerResize );
nfu_status ptwX_clear( statusMessageReporting *smr, ptwXPoints *ptwX );
nfu_status ptwX_release( statusMessageReporting *smr, ptwXPoints *ptwX );
ptwXPoints *ptwX_free( ptwXPoints *ptwX );
int64_t ptwX_length( ptwXPoints *ptwX );
nfu_status ptwX_setData( ptwXPoints *ptwX, int64_t length, double const *xs );
nfu_status ptwX_deletePoints( ptwXPoints *ptwX, int64_t i1, int64_t i2 );
double *ptwX_getPointAtIndex( ptwXPoints *ptwX, int64_t index );
int64_t ptwX_length( statusMessageReporting *smr, ptwXPoints *ptwX );
nfu_status ptwX_setData( statusMessageReporting *smr, ptwXPoints *ptwX, int64_t length, double const *xs );
nfu_status ptwX_deletePoints( statusMessageReporting *smr, ptwXPoints *ptwX, int64_t i1, int64_t i2 );
double *ptwX_getPointAtIndex( statusMessageReporting *smr, ptwXPoints *ptwX, int64_t index );
double ptwX_getPointAtIndex_Unsafely( ptwXPoints *ptwX, int64_t index );
nfu_status ptwX_setPointAtIndex( ptwXPoints *ptwX, int64_t index, double x );
nfu_status ptwX_insertPointsAtIndex( ptwXPoints *ptwX, int64_t index, int64_t n1, double const *xs );
int ptwX_ascendingOrder( ptwXPoints *ptwX );
ptwXPoints *ptwX_fromString( char const *str, char **endCharacter, nfu_status *status );
nfu_status ptwX_countOccurrences( ptwXPoints *ptwX, double value, int *count );
nfu_status ptwX_reverse( ptwXPoints *ptwX );
nfu_status ptwX_sort( ptwXPoints *ptwX, enum ptwX_sort_order order );
nfu_status ptwX_closesDifference( ptwXPoints *ptwX, double value, int64_t *index, double *difference );
nfu_status ptwX_closesDifferenceInRange( ptwXPoints *ptwX, int64_t i1, int64_t i2, double value, int64_t *index, double *difference );
ptwXPoints *ptwX_unique( ptwXPoints *ptwX, int order, nfu_status *status );
nfu_status ptwX_setPointAtIndex( statusMessageReporting *smr, ptwXPoints *ptwX, int64_t index, double x );
nfu_status ptwX_insertPointsAtIndex( statusMessageReporting *smr, ptwXPoints *ptwX, int64_t index, int64_t n1, double const *xs );
nfu_status ptwX_ascendingOrder( statusMessageReporting *smr, ptwXPoints *ptwX, int *order );
ptwXPoints *ptwX_fromString( statusMessageReporting *smr, char const *str, char sep, char **endCharacter );
int ptwX_countOccurrences( statusMessageReporting *smr, ptwXPoints *ptwX, double value );
nfu_status ptwX_reverse( statusMessageReporting *smr, ptwXPoints *ptwX );
nfu_status ptwX_sort( statusMessageReporting *smr, ptwXPoints *ptwX, enum ptwX_sort_order order );
nfu_status ptwX_closesDifference( statusMessageReporting *smr, ptwXPoints *ptwX, double value, int64_t *index, double *difference );
nfu_status ptwX_closesDifferenceInRange( statusMessageReporting *smr, ptwXPoints *ptwX, int64_t i1, int64_t i2,
double value, int64_t *index, double *difference );
ptwXPoints *ptwX_unique( statusMessageReporting *smr, ptwXPoints *ptwX, int order );
nfu_status ptwX_abs( ptwXPoints *ptwX );
nfu_status ptwX_neg( ptwXPoints *ptwX );
nfu_status ptwX_add_double( ptwXPoints *ptwX, double value );
nfu_status ptwX_mul_double( ptwXPoints *ptwX, double value );
nfu_status ptwX_slopeOffset( ptwXPoints *ptwX, double slope, double offset );
nfu_status ptwX_add_ptwX( ptwXPoints *ptwX1, ptwXPoints *ptwX2 );
nfu_status ptwX_sub_ptwX( ptwXPoints *ptwX1, ptwXPoints *ptwX2 );
nfu_status ptwX_abs( statusMessageReporting *smr, ptwXPoints *ptwX );
nfu_status ptwX_neg( statusMessageReporting *smr, ptwXPoints *ptwX );
nfu_status ptwX_add_double( statusMessageReporting *smr, ptwXPoints *ptwX, double value );
nfu_status ptwX_mul_double( statusMessageReporting *smr, ptwXPoints *ptwX, double value );
nfu_status ptwX_slopeOffset( statusMessageReporting *smr, ptwXPoints *ptwX, double slope, double offset );
nfu_status ptwX_add_ptwX( statusMessageReporting *smr, ptwXPoints *ptwX1, ptwXPoints *ptwX2 );
nfu_status ptwX_sub_ptwX( statusMessageReporting *smr, ptwXPoints *ptwX1, ptwXPoints *ptwX2 );
nfu_status ptwX_xMinMax( ptwXPoints *ptwX, double *xMin, double *xMax );
nfu_status ptwX_range( statusMessageReporting *smr, ptwXPoints *ptwX, double *rangeMin, double *rangeMax );
nfu_status ptwX_compare( ptwXPoints *ptwX1, ptwXPoints *ptwX2, int *comparison );
int ptwX_close( ptwXPoints *ptwX1, ptwXPoints *ptwX2, int epsilonFactor, double epsilon, nfu_status *status );
nfu_status ptwX_compare( statusMessageReporting *smr, ptwXPoints *ptwX1, ptwXPoints *ptwX2, int *comparison );
nfu_status ptwX_close( statusMessageReporting *smr, ptwXPoints *ptwX1, ptwXPoints *ptwX2, int epsilonFactor, double epsilon,
int *index );
/*
* Routines in ptwX_misc.c
*/
void ptwX_simpleWrite( ptwXPoints const *ptwX, FILE *f, char const *format );
void ptwX_simplePrint( ptwXPoints const *ptwX, char const *format );
nfu_status ptwX_simpleWrite( statusMessageReporting *smr, ptwXPoints const *ptwX, FILE *f, char const *format );
nfu_status ptwX_simplePrint( statusMessageReporting *smr, ptwXPoints const *ptwX, char const *format );
#if defined __cplusplus
}
}
#endif
#endif /* End of ptwX_h_included. */
@@ -1,5 +1,9 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
@@ -14,7 +18,6 @@
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
#define ptwXY_minimumSize 10 /* This must be > 0 otherwise some logic will fail. */
@@ -31,9 +34,8 @@ typedef enum ptwXY_group_normType_e { ptwXY_group_normType_none, ptwXY_group_nor
#define ptwXY_union_fill 1 /* If filling, union is filled with y value of first ptw. */
#define ptwXY_union_trim 2 /* If trimming, union in only over common domain of ptw1 and ptw2. */
#define ptwXY_union_mergeClosePoints 4 /* If true, union calls ptwXY_mergeClosePoints with eps = 4 * DBL_EPSILON. */
typedef enum ptwXY_sigma_e { ptwXY_sigma_none, ptwXY_sigma_plusMinus, ptwXY_sigma_Minus, ptwXY_sigma_plus } ptwXY_sigma;
typedef enum ptwXY_interpolation_e { ptwXY_interpolationLinLin, ptwXY_interpolationLinLog, ptwXY_interpolationLogLin, ptwXY_interpolationLogLog,
ptwXY_interpolationFlat, ptwXY_interpolationOther } ptwXY_interpolation;
typedef enum ptwXY_interpolation_e { ptwXY_interpolationLinLin, ptwXY_interpolationLogLin, ptwXY_interpolationLinLog,
ptwXY_interpolationLogLog, ptwXY_interpolationFlat, ptwXY_interpolationOther } ptwXY_interpolation;
/*
* The function ptwXY_getPointsAroundX determines where an x fits into a ptwXY instance. It returns/sets the following.
@@ -55,22 +57,15 @@ typedef enum ptwXY_interpolation_e { ptwXY_interpolationLinLin, ptwXY_interpolat
* greaterThanXPoint is set to point's information for closes point with point's x > x
*/
typedef enum ptwXY_lessEqualGreaterX_e { ptwXY_lessEqualGreaterX_empty, ptwXY_lessEqualGreaterX_lessThan, ptwXY_lessEqualGreaterX_equal,
ptwXY_lessEqualGreaterX_between, ptwXY_lessEqualGreaterX_greater } ptwXY_lessEqualGreaterX;
ptwXY_lessEqualGreaterX_between, ptwXY_lessEqualGreaterX_greater, ptwXY_lessEqualGreaterX_Error } ptwXY_lessEqualGreaterX;
typedef
struct ptwXYPoint_s {
double x, y;
} ptwXYPoint;
typedef nfu_status (*ptwXY_createFromFunction_callback)( double x, double *y, void *argList );
typedef nfu_status (*ptwXY_applyFunction_callback)( ptwXYPoint *point, void *argList );
typedef nfu_status (*ptwXY_getValue_callback)( void *argList, double x, double *y, double x1, double y1, double x2, double y2 );
typedef struct {
char const *interpolationString;
ptwXY_getValue_callback getValueFunc;
void *argList;
} ptwXY_interpolationOtherInfo;
typedef nfu_status (*ptwXY_createFromFunction_callback)( statusMessageReporting *smr, double x, double *y, void *argList );
typedef nfu_status (*ptwXY_applyFunction_callback)( statusMessageReporting *smr, ptwXYPoint *point, void *argList );
typedef
struct ptwXYOverflowPoint_s {
@@ -83,9 +78,8 @@ typedef
typedef
struct ptwXYPoints_s {
nfu_status status;
ptwXY_sigma typeX, typeY;
ptwXY_interpolation interpolation;
ptwXY_interpolationOtherInfo interpolationOtherInfo;
char const *interpolationString;
int userFlag;
double biSectionMax;
double accuracy;
@@ -103,27 +97,37 @@ typedef
/*
* Routines in ptwXY_core.c
*/
ptwXYPoints *ptwXY_new( ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo, double biSectionMax,
double accuracy, int64_t primarySize, int64_t secondarySize, nfu_status *status, int userFlag );
nfu_status ptwXY_setup( ptwXYPoints *ptwXY, ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo,
double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int userFlag );
ptwXYPoints *ptwXY_create( ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo,
double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int64_t length, double const *xy,
nfu_status *status, int userFlag );
ptwXYPoints *ptwXY_createFrom_Xs_Ys( ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo,
double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int64_t length, double const *Xs,
double const *Ys, nfu_status *status, int userFlag );
ptwXYPoints *ptwXY_new( statusMessageReporting *smr, ptwXY_interpolation interpolation, char const *interpolationString,
double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int userFlag );
ptwXYPoints *ptwXY_new2( statusMessageReporting *smr, ptwXY_interpolation interpolation, int64_t primarySize, int64_t secondarySize );
nfu_status ptwXY_initialize( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXY_interpolation interpolation,
char const *interpolationString, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize,
int userFlag );
ptwXYPoints *ptwXY_create( statusMessageReporting *smr, ptwXY_interpolation interpolation, char const *interpolationString,
double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int64_t length, double const *xy,
int userFlag );
ptwXYPoints *ptwXY_create2( statusMessageReporting *smr, ptwXY_interpolation interpolation,
int64_t primarySize, int64_t secondarySize, int64_t length, double const *xy, int userFlag );
ptwXYPoints *ptwXY_createFrom_Xs_Ys( statusMessageReporting *smr, ptwXY_interpolation interpolation,
char const *interpolationString, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize,
int64_t length, double const *Xs, double const *Ys, int userFlag );
ptwXYPoints *ptwXY_createFrom_Xs_Ys2( statusMessageReporting *smr, ptwXY_interpolation interpolation,
int64_t primarySize, int64_t secondarySize, int64_t length, double const *Xs, double const *Ys, int userFlag );
nfu_status ptwXY_copy( ptwXYPoints *dest, ptwXYPoints *src );
ptwXYPoints *ptwXY_clone( ptwXYPoints *ptwXY, nfu_status *status );
ptwXYPoints *ptwXY_cloneToInterpolation( ptwXYPoints *ptwXY, ptwXY_interpolation interpolationTo, nfu_status *status );
ptwXYPoints *ptwXY_slice( ptwXYPoints *ptwXY, int64_t index1, int64_t index2, int64_t secondarySize, nfu_status *status );
ptwXYPoints *ptwXY_xSlice( ptwXYPoints *ptwXY, double xMin, double xMax, int64_t secondarySize, int fill, nfu_status *status );
ptwXYPoints *ptwXY_xMinSlice( ptwXYPoints *ptwXY, double xMin, int64_t secondarySize, int fill, nfu_status *status );
ptwXYPoints *ptwXY_xMaxSlice( ptwXYPoints *ptwXY, double xMax, int64_t secondarySize, int fill, nfu_status *status );
nfu_status ptwXY_copy( statusMessageReporting *smr, ptwXYPoints *dest, ptwXYPoints *src );
nfu_status ptwXY_copyPointsOnly( statusMessageReporting *smr, ptwXYPoints *dest, ptwXYPoints *src );
ptwXYPoints *ptwXY_clone( statusMessageReporting *smr, ptwXYPoints *ptwXY );
ptwXYPoints *ptwXY_clone2( statusMessageReporting *smr, ptwXYPoints const *ptwXY );
ptwXYPoints *ptwXY_cloneToInterpolation( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXY_interpolation interpolationTo );
ptwXYPoints *ptwXY_slice( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t index1, int64_t index2, int64_t secondarySize );
ptwXYPoints *ptwXY_domainSlice( statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, double domainMax,
int64_t secondarySize, int fill );
ptwXYPoints *ptwXY_domainMinSlice( statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, int64_t secondarySize, int fill );
ptwXYPoints *ptwXY_domainMaxSlice( statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMax, int64_t secondarySize, int fill );
ptwXY_interpolation ptwXY_getInterpolation( ptwXYPoints *ptwXY );
char const *ptwXY_getInterpolationString( ptwXYPoints *ptwXY );
nfu_status ptwXY_setInterpolationString( ptwXYPoints *ptwXY, char const *interpolationString );
nfu_status ptwXY_getStatus( ptwXYPoints *ptwXY );
int ptwXY_getUserFlag( ptwXYPoints *ptwXY );
void ptwXY_setUserFlag( ptwXYPoints *ptwXY, int userFlag );
@@ -132,155 +136,185 @@ double ptwXY_setAccuracy( ptwXYPoints *ptwXY, double accuracy );
double ptwXY_getBiSectionMax( ptwXYPoints *ptwXY );
double ptwXY_setBiSectionMax( ptwXYPoints *ptwXY, double biSectionMax );
nfu_status ptwXY_reallocatePoints( ptwXYPoints *ptwXY, int64_t size, int forceSmallerResize );
nfu_status ptwXY_reallocateOverflowPoints( ptwXYPoints *ptwXY, int64_t size );
nfu_status ptwXY_coalescePoints( ptwXYPoints *ptwXY, int64_t size, ptwXYPoint *newPoint, int forceSmallerResize );
nfu_status ptwXY_simpleCoalescePoints( ptwXYPoints *ptwXY );
nfu_status ptwXY_reallocatePoints( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t size, int forceSmallerResize );
nfu_status ptwXY_reallocateOverflowPoints( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t size );
nfu_status ptwXY_coalescePoints( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t size, ptwXYPoint *newPoint,
int forceSmallerResize );
nfu_status ptwXY_simpleCoalescePoints( statusMessageReporting *smr, ptwXYPoints *ptwXY );
nfu_status ptwXY_clear( ptwXYPoints *ptwXY );
nfu_status ptwXY_release( ptwXYPoints *ptwXY );
nfu_status ptwXY_clear( statusMessageReporting *smr, ptwXYPoints *ptwXY );
nfu_status ptwXY_release( statusMessageReporting *smr, ptwXYPoints *ptwXY );
ptwXYPoints *ptwXY_free( ptwXYPoints *ptwXY );
int64_t ptwXY_length( ptwXYPoints *ptwXY );
int64_t ptwXY_getNonOverflowLength( ptwXYPoints const *ptwXY );
int64_t ptwXY_length( statusMessageReporting *smr, ptwXYPoints *ptwXY );
int64_t ptwXY_getNonOverflowLength( statusMessageReporting *smr, ptwXYPoints const *ptwXY );
nfu_status ptwXY_setXYData( ptwXYPoints *ptwXY, int64_t length, double const *xy );
nfu_status ptwXY_setXYDataFromXsAndYs( ptwXYPoints *ptwXY, int64_t length, double const *x, double const *y );
nfu_status ptwXY_deletePoints( ptwXYPoints *ptwXY, int64_t i1, int64_t i2 );
ptwXYPoint *ptwXY_getPointAtIndex( ptwXYPoints *ptwXY, int64_t index );
ptwXYPoint *ptwXY_getPointAtIndex_Unsafely( ptwXYPoints *ptwXY, int64_t index );
nfu_status ptwXY_getXYPairAtIndex( ptwXYPoints *ptwXY, int64_t index, double *x, double *y );
ptwXY_lessEqualGreaterX ptwXY_getPointsAroundX( ptwXYPoints *ptwXY, double x, ptwXYOverflowPoint *lessThanEqualXPoint, ptwXYOverflowPoint *greaterThanXPoint );
ptwXY_lessEqualGreaterX ptwXY_getPointsAroundX_closeIsEqual( ptwXYPoints *ptwXY, double x, ptwXYOverflowPoint *lessThanEqualXPoint,
ptwXYOverflowPoint *greaterThanXPoint, double eps, int *closeIsEqual, ptwXYPoint **closePoint );
nfu_status ptwXY_getValueAtX( ptwXYPoints *ptwXY, double x, double *y );
nfu_status ptwXY_setValueAtX( ptwXYPoints *ptwXY, double x, double y );
nfu_status ptwXY_setValueAtX_overrideIfClose( ptwXYPoints *ptwXY, double x, double y, double eps, int override );
nfu_status ptwXY_mergeFromXsAndYs( ptwXYPoints *ptwXY, int length, double *xs, double *ys );
nfu_status ptwXY_mergeFromXYs( ptwXYPoints *ptwXY, int length, double *xys );
nfu_status ptwXY_appendXY( ptwXYPoints *ptwXY, double x, double y );
nfu_status ptwXY_setXYPairAtIndex( ptwXYPoints *ptwXY, int64_t index, double x, double y );
nfu_status ptwXY_startIndex( statusMessageReporting *a_smr, ptwXYPoints *a_ptwXY, double a_x, int64_t *a_startIndex, int64_t *a_length );
nfu_status ptwXY_setXYData( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t length, double const *xy );
nfu_status ptwXY_setXYDataFromXsAndYs( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t length, double const *x, double const *y );
nfu_status ptwXY_deletePoints( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t i1, int64_t i2 );
nfu_status ptwXY_getLowerIndexBoundingX( statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, int64_t *index );
ptwXYPoint *ptwXY_getPointAtIndex( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t index );
ptwXYPoint *ptwXY_getPointAtIndex_Unsafely( ptwXYPoints const *ptwXY, int64_t index );
nfu_status ptwXY_getXYPairAtIndex( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t index, double *x, double *y );
ptwXY_lessEqualGreaterX ptwXY_getPointsAroundX( statusMessageReporting *smr, ptwXYPoints *ptwXY, double x,
ptwXYOverflowPoint *lessThanEqualXPoint, ptwXYOverflowPoint *greaterThanXPoint );
ptwXY_lessEqualGreaterX ptwXY_getPointsAroundX_closeIsEqual( statusMessageReporting *smr, ptwXYPoints *ptwXY, double x,
ptwXYOverflowPoint *lessThanEqualXPoint, ptwXYOverflowPoint *greaterThanXPoint, double eps, int *closeIsEqual,
ptwXYPoint **closePoint );
nfu_status ptwXY_getValueAtX( statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, double *y );
nfu_status ptwXY_setValueAtX( statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, double y );
nfu_status ptwXY_setValueAtX_overrideIfClose( statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, double y, double eps, int override );
nfu_status ptwXY_mergeFromXsAndYs( statusMessageReporting *smr, ptwXYPoints *ptwXY, int length, double *xs, double *ys );
nfu_status ptwXY_mergeFromXYs( statusMessageReporting *smr, ptwXYPoints *ptwXY, int length, double *xys );
nfu_status ptwXY_appendXY( statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, double y );
nfu_status ptwXY_setXYPairAtIndex( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t index, double x, double y );
nfu_status ptwXY_getSlopeAtX( ptwXYPoints *ptwXY, double x, const char side, double *slope );
nfu_status ptwXY_getSlopeAtX( statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, char side, double *slope );
double ptwXY_getXMinAndFrom( ptwXYPoints *ptwXY, ptwXY_dataFrom *dataFrom );
double ptwXY_getXMin( ptwXYPoints *ptwXY );
double ptwXY_getXMaxAndFrom( ptwXYPoints *ptwXY, ptwXY_dataFrom *dataFrom );
double ptwXY_getXMax( ptwXYPoints *ptwXY );
double ptwXY_getYMin( ptwXYPoints *ptwXY );
double ptwXY_getYMax( ptwXYPoints *ptwXY );
nfu_status ptwXY_domainMinAndFrom( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXY_dataFrom *dataFrom, double *value );
nfu_status ptwXY_domainMin( statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value );
nfu_status ptwXY_domainMaxAndFrom( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXY_dataFrom *dataFrom, double *value );
nfu_status ptwXY_domainMax( statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value );
nfu_status ptwXY_range( statusMessageReporting *smr, ptwXYPoints *ptwXY, double *rangeMin, double *rangeMax );
nfu_status ptwXY_rangeMin( statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value );
nfu_status ptwXY_rangeMax( statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value );
char const *ptwXY_interpolationToString( ptwXY_interpolation interpolation );
ptwXY_interpolation ptwXY_stringToInterpolation( char const *interpolationString );
/*
* Methods in ptwXY_methods.c
*/
nfu_status ptwXY_clip( ptwXYPoints *ptwXY1, double yMin, double yMax );
nfu_status ptwXY_thicken( ptwXYPoints *ptwXY1, int sectionSubdivideMax, double dxMax, double fxMax );
ptwXYPoints *ptwXY_thin( ptwXYPoints *ptwXY1, double accuracy, nfu_status *status );
nfu_status ptwXY_trim( ptwXYPoints *ptwXY );
nfu_status ptwXY_clip( statusMessageReporting *smr, ptwXYPoints *ptwXY1, double rangeMin, double rangeMax );
nfu_status ptwXY_thicken( statusMessageReporting *smr, ptwXYPoints *ptwXY1, int sectionSubdivideMax,
double dDomainMax, double fDomainMax );
ptwXYPoints *ptwXY_thin( statusMessageReporting *smr, ptwXYPoints *ptwXY1, double accuracy );
ptwXYPoints *ptwXY_thinDomain( statusMessageReporting *smr, ptwXYPoints *ptwXY1, double epsilon );
nfu_status ptwXY_trim( statusMessageReporting *smr, ptwXYPoints *ptwXY );
ptwXYPoints *ptwXY_union( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, nfu_status *status, int unionOptions );
ptwXYPoints *ptwXY_union( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, int unionOptions );
nfu_status ptwXY_scaleOffsetXAndY( ptwXYPoints *ptwXY, double xScale, double xOffset, double yScale, double yOffset );
nfu_status ptwXY_scaleOffsetXAndY( statusMessageReporting *smr, ptwXYPoints *ptwXY, double xScale, double xOffset,
double yScale, double yOffset );
nfu_status ptwXY_scaleAndOffsetDomainWith_ptwXYs( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXYPoints *offset, ptwXYPoints *slope, int skipLastPoint );
/*
* Functions in ptwXY_unitaryOperators.c
*/
nfu_status ptwXY_abs( ptwXYPoints *ptwXY );
nfu_status ptwXY_neg( ptwXYPoints *ptwXY );
nfu_status ptwXY_abs( statusMessageReporting *smr, ptwXYPoints *ptwXY );
nfu_status ptwXY_neg( statusMessageReporting *smr, ptwXYPoints *ptwXY );
/*
* Functions in ptwXY_binaryOperators.c
*/
nfu_status ptwXY_slopeOffset( ptwXYPoints *ptwXY, double slope, double offset );
nfu_status ptwXY_add_double( ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_sub_doubleFrom( ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_sub_fromDouble( ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_mul_double( ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_div_doubleFrom( ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_div_fromDouble( ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_mod( ptwXYPoints *ptwXY, double m, int pythonMod );
nfu_status ptwXY_slopeOffset( statusMessageReporting *smr, ptwXYPoints *ptwXY, double slope, double offset );
nfu_status ptwXY_add_double( statusMessageReporting *smr, ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_sub_doubleFrom( statusMessageReporting *smr, ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_sub_fromDouble( statusMessageReporting *smr, ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_mul_double( statusMessageReporting *smr, ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_div_doubleFrom( statusMessageReporting *smr, ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_div_fromDouble( statusMessageReporting *smr, ptwXYPoints *ptwXY, double value );
nfu_status ptwXY_mod( statusMessageReporting *smr, ptwXYPoints *ptwXY, double m, int pythonMod );
ptwXYPoints *ptwXY_binary_ptwXY( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, double v1, double v2, double v1v2, nfu_status *status );
ptwXYPoints *ptwXY_add_ptwXY( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, nfu_status *status );
ptwXYPoints *ptwXY_sub_ptwXY( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, nfu_status *status );
ptwXYPoints *ptwXY_mul_ptwXY( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, nfu_status *status );
ptwXYPoints *ptwXY_mul2_ptwXY( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, nfu_status *status );
ptwXYPoints *ptwXY_div_ptwXY( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, nfu_status *status, int safeDivide );
ptwXYPoints *ptwXY_binary_ptwXY( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2,
double v1, double v2, double v1v2 );
ptwXYPoints *ptwXY_add_ptwXY( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2 );
ptwXYPoints *ptwXY_sub_ptwXY( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2 );
ptwXYPoints *ptwXY_mul_ptwXY( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2 );
ptwXYPoints *ptwXY_mul2_ptwXY( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2 );
ptwXYPoints *ptwXY_div_ptwXY( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, int safeDivide );
/*
* Functions in ptwXY_functions.c
*/
nfu_status ptwXY_pow( ptwXYPoints *ptwXY, double p );
nfu_status ptwXY_exp( ptwXYPoints *ptwXY, double a );
ptwXYPoints *ptwXY_convolution( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, nfu_status *status, int mode );
nfu_status ptwXY_pow( statusMessageReporting *smr, ptwXYPoints *ptwXY, double p );
nfu_status ptwXY_exp( statusMessageReporting *smr, ptwXYPoints *ptwXY, double a );
ptwXYPoints *ptwXY_convolution( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, int mode );
ptwXYPoints *ptwXY_inverse( statusMessageReporting *smr, ptwXYPoints *ptwXY );
/*
* Functions in ptwXY_interpolation.c
*/
nfu_status ptwXY_interpolatePoint( ptwXY_interpolation interpolation, double x, double *y, double x1, double y1, double x2, double y2 );
ptwXYPoints *ptwXY_flatInterpolationToLinear( ptwXYPoints *ptwXY, double lowerEps, double upperEps, nfu_status *status );
ptwXYPoints *ptwXY_toOtherInterpolation( ptwXYPoints *ptwXY, ptwXY_interpolation interpolation, double accuracy, nfu_status *status );
ptwXYPoints *ptwXY_unitbaseInterpolate( double w, double w1, ptwXYPoints *ptwXY1, double w2, ptwXYPoints *ptwXY2, nfu_status *status );
ptwXYPoints *ptwXY_toUnitbase( ptwXYPoints *ptwXY, nfu_status *status );
ptwXYPoints *ptwXY_fromUnitbase( ptwXYPoints *ptwXY, double xMin, double xMax, nfu_status *status );
nfu_status ptwXY_interpolatePoint( statusMessageReporting *smr, ptwXY_interpolation interpolation, double x, double *y,
double x1, double y1, double x2, double y2 );
ptwXYPoints *ptwXY_flatInterpolationToLinear( statusMessageReporting *smr, ptwXYPoints *ptwXY, double lowerEps, double upperEps );
ptwXYPoints *ptwXY_toOtherInterpolation( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXY_interpolation interpolation,
double accuracy );
ptwXYPoints *ptwXY_unitbaseInterpolate( statusMessageReporting *smr, double w, double w1, ptwXYPoints *ptwXY1,
double w2, ptwXYPoints *ptwXY2, int scaleRange );
ptwXYPoints *ptwXY_toUnitbase( statusMessageReporting *smr, ptwXYPoints *ptwXY, int scaleRange );
ptwXYPoints *ptwXY_fromUnitbase( statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, double domainMax,
int scaleRange );
/*
* Functions in ptwXY_convenient.c
*/
ptwXPoints *ptwXY_getXArray( ptwXYPoints *ptwXY, nfu_status *status );
nfu_status ptwXY_dullEdges( ptwXYPoints *ptwXY, double lowerEps, double upperEps, int positiveXOnly );
nfu_status ptwXY_mergeClosePoints( ptwXYPoints *ptwXY, double epsilon );
ptwXYPoints *ptwXY_intersectionWith_ptwX( ptwXYPoints *ptwXY, ptwXPoints *ptwX, nfu_status *status );
nfu_status ptwXY_areDomainsMutual( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2 );
nfu_status ptwXY_tweakDomainsToMutualify( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, int epsilonFactor, double epsilon );
nfu_status ptwXY_mutualifyDomains( ptwXYPoints *ptwXY1, double lowerEps1, double upperEps1, int positiveXOnly1,
ptwXYPoints *ptwXY2, double lowerEps2, double upperEps2, int positiveXOnly2 );
nfu_status ptwXY_copyToC_XY( ptwXYPoints *ptwXY, int64_t index1, int64_t index2, int64_t allocatedSize, int64_t *numberOfPoints, double *xy );
nfu_status ptwXY_valueTo_ptwXAndY( ptwXYPoints *ptwXY, double **xs, double **ys );
ptwXYPoints *ptwXY_valueTo_ptwXY( double x1, double x2, double y, nfu_status *status );
ptwXYPoints *ptwXY_createGaussianCenteredSigma1( double accuracy, nfu_status *status );
ptwXYPoints *ptwXY_createGaussian( double accuracy, double xCenter, double sigma, double amplitude, double xMin, double xMax,
double dullEps, nfu_status *status );
ptwXPoints *ptwXY_getXArray( statusMessageReporting *smr, ptwXYPoints *ptwXY );
ptwXPoints *ptwXY_ysMappedToXs( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXPoints *Xs, int64_t *offset );
nfu_status ptwXY_mapToXsAndAdd( statusMessageReporting *a_smr, ptwXYPoints *a_ptwXY, int64_t a_offset, int64_t a_length, double const *a_Xs,
double *a_results, double a_scaleFractor );
nfu_status ptwXY_dullEdges( statusMessageReporting *smr, ptwXYPoints *ptwXY, double lowerEps, double upperEps, int positiveXOnly );
nfu_status ptwXY_mergeClosePoints( statusMessageReporting *smr, ptwXYPoints *ptwXY, double epsilon );
ptwXYPoints *ptwXY_intersectionWith_ptwX( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXPoints *ptwX );
nfu_status ptwXY_areDomainsMutual( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2 );
nfu_status ptwXY_tweakDomainsToMutualify( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2,
int epsilonFactor, double epsilon );
nfu_status ptwXY_mutualifyDomains( statusMessageReporting *smr, ptwXYPoints *ptwXY1, double lowerEps1, double upperEps1,
int positiveXOnly1, ptwXYPoints *ptwXY2, double lowerEps2, double upperEps2, int positiveXOnly2 );
nfu_status ptwXY_copyToC_XY( statusMessageReporting *smr, ptwXYPoints *ptwXY, int64_t index1, int64_t index2,
int64_t allocatedSize, int64_t *numberOfPoints, double *xy );
nfu_status ptwXY_valuesToC_XsAndYs( statusMessageReporting *smr, ptwXYPoints *ptwXY, double **xs, double **ys );
ptwXYPoints *ptwXY_valueTo_ptwXY( statusMessageReporting *smr, double x1, double x2, double y );
ptwXYPoints *ptwXY_createGaussianCenteredSigma1( statusMessageReporting *smr, double accuracy );
ptwXYPoints *ptwXY_createGaussian( statusMessageReporting *smr, double accuracy, double xCenter, double sigma,
double amplitude, double domainMin, double domainMax, double dullEps );
/*
* Functions in ptwXY_misc.c
*/
double ptwXY_limitAccuracy( double accuracy );
void ptwXY_update_biSectionMax( ptwXYPoints *ptwXY1, double oldLength );
ptwXYPoints *ptwXY_createFromFunction( int n, double *xs, ptwXY_createFromFunction_callback func, void *argList, double accuracy, int checkForRoots,
int biSectionMax, nfu_status *status );
ptwXYPoints *ptwXY_createFromFunction2( ptwXPoints *xs, ptwXY_createFromFunction_callback func, void *argList, double accuracy, int checkForRoots,
int biSectionMax, nfu_status *status );
nfu_status ptwXY_applyFunction( ptwXYPoints *ptwXY1, ptwXY_applyFunction_callback func, void *argList, int checkForRoots );
ptwXYPoints *ptwXY_fromString( char const *str, ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo,
double biSectionMax, double accuracy, char **endCharacter, nfu_status *status );
ptwXYPoints *ptwXY_createFromFunction( statusMessageReporting *smr, int n, double *xs,
ptwXY_createFromFunction_callback func, void *argList, double accuracy, int checkForRoots, int biSectionMax );
ptwXYPoints *ptwXY_createFromFunction2( statusMessageReporting *smr, ptwXPoints *xs, ptwXY_createFromFunction_callback func,
void *argList, double accuracy, int checkForRoots, int biSectionMax );
nfu_status ptwXY_applyFunction( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXY_applyFunction_callback func,
void *argList, int checkForRoots );
ptwXYPoints *ptwXY_fromString( statusMessageReporting *smr, char const *str, char sep, ptwXY_interpolation interpolation, char const *interpolationString,
double biSectionMax, double accuracy, char **endCharacter, int useSystem_strtod );
void ptwXY_showInteralStructure( ptwXYPoints *ptwXY, FILE *f, int printPointersAsNull );
void ptwXY_simpleWrite( ptwXYPoints *ptwXY, FILE *f, char *format );
void ptwXY_simplePrint( ptwXYPoints *ptwXY, char *format );
void ptwXY_simpleWrite( ptwXYPoints *ptwXY, FILE *f, char const *format );
void ptwXY_simplePrint( ptwXYPoints *ptwXY, char const *format );
/*
* Functions in ptwXY_integration.c
*/
nfu_status ptwXY_f_integrate( ptwXY_interpolation interpolation, double x1, double y1, double x2, double y2, double *value );
double ptwXY_integrate( ptwXYPoints *ptwXY, double xMin, double xMax, nfu_status *status );
double ptwXY_integrateDomain( ptwXYPoints *ptwXY, nfu_status *status );
nfu_status ptwXY_normalize( ptwXYPoints *ptwXY1 );
double ptwXY_integrateDomainWithWeight_x( ptwXYPoints *ptwXY, nfu_status *status );
double ptwXY_integrateWithWeight_x( ptwXYPoints *ptwXY, double xMin, double xMax, nfu_status *status );
double ptwXY_integrateDomainWithWeight_sqrt_x( ptwXYPoints *ptwXY, nfu_status *status );
double ptwXY_integrateWithWeight_sqrt_x( ptwXYPoints *ptwXY, double xMin, double xMax, nfu_status *status );
ptwXPoints *ptwXY_groupOneFunction( ptwXYPoints *ptwXY, ptwXPoints *groupBoundaries, ptwXY_group_normType normType, ptwXPoints *ptwX_norm, nfu_status *status );
ptwXPoints *ptwXY_groupTwoFunctions( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, ptwXPoints *groupBoundaries, ptwXY_group_normType normType,
ptwXPoints *ptwX_norm, nfu_status *status );
ptwXPoints *ptwXY_groupThreeFunctions( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, ptwXYPoints *ptwXY3, ptwXPoints *groupBoundaries,
ptwXY_group_normType normType, ptwXPoints *ptwX_norm, nfu_status *status );
ptwXPoints *ptwXY_runningIntegral( ptwXYPoints *ptwXY, nfu_status *status );
double ptwXY_integrateWithFunction( ptwXYPoints *ptwXY, ptwXY_createFromFunction_callback func, void *argList,
double xMin, double xMax, int degree, int recursionLimit, double tolerance, nfu_status *status );
nfu_status ptwXY_f_integrate( statusMessageReporting *smr, ptwXY_interpolation interpolation, double x1, double y1,
double x2, double y2, double *value );
nfu_status ptwXY_integrate( statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, double domainMax, double *value );
nfu_status ptwXY_integrateDomain( statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value );
nfu_status ptwXY_normalize( statusMessageReporting *smr, ptwXYPoints *ptwXY1 );
nfu_status ptwXY_integrateDomainWithWeight_x( statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value );
nfu_status ptwXY_integrateWithWeight_x( statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, double domainMax,
double *value );
nfu_status ptwXY_integrateDomainWithWeight_sqrt_x( statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value );
nfu_status ptwXY_integrateWithWeight_sqrt_x( statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, double domainMax,
double *value );
ptwXPoints *ptwXY_groupOneFunction( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXPoints *groupBoundaries,
ptwXY_group_normType normType, ptwXPoints *ptwX_norm );
ptwXPoints *ptwXY_groupTwoFunctions( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2,
ptwXPoints *groupBoundaries, ptwXY_group_normType normType, ptwXPoints *ptwX_norm );
ptwXPoints *ptwXY_groupThreeFunctions( statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2,
ptwXYPoints *ptwXY3, ptwXPoints *groupBoundaries, ptwXY_group_normType normType, ptwXPoints *ptwX_norm );
ptwXPoints *ptwXY_runningIntegral( statusMessageReporting *smr, ptwXYPoints *ptwXY );
nfu_status ptwXY_integrateWithFunction( statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXY_createFromFunction_callback func,
void *argList, double domainMin, double domainMax, int degree, int recursionLimit, double tolerance,
double *value );
ptwXPoints *ptwXY_equalProbableBins( statusMessageReporting *smr, ptwXYPoints *ptwXY, int numberOfBins );
#if defined __cplusplus
}
}
#endif
#endif /* End of ptwXY_h_included. */
@@ -0,0 +1,77 @@
/**
* pugixml parser - version 1.13
* --------------------------------------------------------
* Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
* of this file.
*
* This work is based on the pugxml parser, which is:
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/
#ifndef HEADER_PUGICONFIG_HPP
#define HEADER_PUGICONFIG_HPP
// Uncomment this to enable wchar_t mode
// #define PUGIXML_WCHAR_MODE
// Uncomment this to enable compact mode
// #define PUGIXML_COMPACT
// Uncomment this to disable XPath
// #define PUGIXML_NO_XPATH
// Uncomment this to disable STL
// #define PUGIXML_NO_STL
// Uncomment this to disable exceptions
// #define PUGIXML_NO_EXCEPTIONS
// Set this to control attributes for public classes/functions, i.e.:
// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL
// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall
// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead
// Tune these constants to adjust memory-related behavior
// #define PUGIXML_MEMORY_PAGE_SIZE 32768
// #define PUGIXML_MEMORY_OUTPUT_STACK 10240
// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
// Tune this constant to adjust max nesting for XPath queries
// #define PUGIXML_XPATH_DEPTH_LIMIT 1024
// Uncomment this to switch to header-only version
// #define PUGIXML_HEADER_ONLY
// Uncomment this to enable long long support
// #define PUGIXML_HAS_LONG_LONG
#endif
/**
* Copyright (c) 2006-2022 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
File diff suppressed because it is too large Load Diff
@@ -1,16 +1,24 @@
/*
# <<BEGIN-copyright>>
# Copyright 2019, Lawrence Livermore National Security, LLC.
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
# <<END-copyright>>
*/
#ifndef statusMessageReporting_h_included
#define statusMessageReporting_h_included
#include <stdio.h>
#include <stdarg.h>
#ifdef WIN32
#ifdef _WIN32
#define __func__ __FUNCTION__
#endif
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
#define smr_unknownID 0
@@ -22,8 +30,7 @@
#define smr_maximumNumberOfRegisteredLibraries 128
#define smr_maximumFileNameSize 1024
#define smr_codeNULL 0
#define smr_codeFileIO -1
#define smr_codeMemoryAllocating -2
#define smr_codeMemoryAllocating 1
enum smr_status { smr_status_Ok = 0, smr_status_Info, smr_status_Warning, smr_status_Error };
typedef char *(*smr_userInterface)( void *userData );
@@ -40,7 +47,6 @@ typedef struct statusMessageReport {
typedef struct statusMessageReporting {
enum smr_status verbosity;
int append; /* If 0, only one report allowed, else add to next list. */
statusMessageReport report;
} statusMessageReporting;
@@ -49,13 +55,13 @@ int smr_cleanup( void );
int smr_registerLibrary( char const *libraryName );
int smr_numberOfRegisteredLibraries( void );
char const *smr_getRegisteredLibrariesName( int ID );
char const *smr_getRegisteredLibrarysName( int ID );
statusMessageReporting *smr_new( statusMessageReporting *smr, enum smr_status verbosity, int append );
int smr_initialize( statusMessageReporting *smr, enum smr_status verbosity, int append );
statusMessageReporting *smr_new( statusMessageReporting *smr, enum smr_status verbosity );
int smr_initialize( statusMessageReporting *smr, enum smr_status verbosity );
statusMessageReporting *smr_clone( statusMessageReporting const *smr );
void smr_release( statusMessageReporting *smr );
void *smr_free( statusMessageReporting **smr );
statusMessageReporting *smr_clone( statusMessageReporting *smr );
int smr_setReportInfo( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, ... );
int smr_vsetReportInfo( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, va_list *args );
@@ -64,38 +70,37 @@ int smr_vsetReportWarning( statusMessageReporting *smr, void *userInterface, cha
int smr_setReportError( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, ... );
int smr_vsetReportError( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, va_list *args );
enum smr_status smr_highestStatus( statusMessageReporting *smr );
int smr_isOk( statusMessageReporting *smr );
int smr_isInfo( statusMessageReporting *smr );
int smr_isWarning( statusMessageReporting *smr );
int smr_isError( statusMessageReporting *smr );
int smr_isWarningOrError( statusMessageReporting *smr );
enum smr_status smr_highestStatus( statusMessageReporting const *smr );
int smr_isOk( statusMessageReporting const *smr );
int smr_isInfo( statusMessageReporting const *smr );
int smr_isWarning( statusMessageReporting const *smr );
int smr_isError( statusMessageReporting const *smr );
int smr_isWarningOrError( statusMessageReporting const *smr );
int smr_isReportOk( statusMessageReport *report );
int smr_isReportInfo( statusMessageReport *report );
int smr_isReportWarning( statusMessageReport *report );
int smr_isReportError( statusMessageReport *report );
int smr_isReportWarningOrError( statusMessageReport *report );
int smr_isReportOk( statusMessageReport const *report );
int smr_isReportInfo( statusMessageReport const *report );
int smr_isReportWarning( statusMessageReport const *report );
int smr_isReportError( statusMessageReport const *report );
int smr_isReportWarningOrError( statusMessageReport const *report );
int smr_numberOfReports( statusMessageReporting *smr );
statusMessageReport *smr_firstReport( statusMessageReporting *smr );
statusMessageReport *smr_nextReport( statusMessageReport *report );
int smr_numberOfReports( statusMessageReporting const *smr );
statusMessageReport const *smr_firstReport( statusMessageReporting const *smr );
statusMessageReport const *smr_nextReport( statusMessageReport const *report );
enum smr_status smr_getVerbosity( statusMessageReporting *smr );
int smr_getAppend( statusMessageReporting *smr );
enum smr_status smr_getVerbosity( statusMessageReporting const *smr );
int smr_getLibraryID( statusMessageReport *report );
int smr_getCode( statusMessageReport *report );
int smr_getLine( statusMessageReport *report );
char const *smr_getFile( statusMessageReport *report );
char const *smr_getFunction( statusMessageReport *report );
char const *smr_getMessage( statusMessageReport *report );
char *smr_copyMessage( statusMessageReport *report );
char *smr_copyFullMessage( statusMessageReport *report );
int smr_getLibraryID( statusMessageReport const *report );
int smr_getCode( statusMessageReport const *report );
int smr_getLine( statusMessageReport const *report );
char const *smr_getFile( statusMessageReport const *report );
char const *smr_getFunction( statusMessageReport const *report );
char const *smr_getMessage( statusMessageReport const *report );
char *smr_copyMessage( statusMessageReport const *report );
char *smr_copyFullMessage( statusMessageReport const *report );
void smr_print( statusMessageReporting *smr, int clear );
void smr_write( statusMessageReporting *smr, FILE *f, int clear );
void smr_reportPrint( statusMessageReport *report );
void smr_reportWrite( statusMessageReport *report, FILE *f );
void smr_reportPrint( statusMessageReport const *report );
void smr_reportWrite( statusMessageReport const *report, FILE *f );
char const *smr_statusToString( enum smr_status status );
@@ -110,6 +115,7 @@ char *smr_allocateCopyStringN( statusMessageReporting *smr, char const *s, size_
#define smr_malloc2( smr, size, zero, forItem ) smr_malloc( smr, size, zero, forItem, __FILE__, __LINE__, __func__ )
#define smr_realloc2( smr, old, size, forItem ) smr_realloc( smr, old, size, forItem, __FILE__, __LINE__, __func__ )
#define smr_freeMemory2( p ) smr_freeMemory( (void **) &p )
#define smr_allocateCopyString2( smr, s, forItem ) smr_allocateCopyString( smr, s, forItem, __FILE__, __LINE__, __func__ )
#define smr_allocateCopyStringN2( smr, s, n, forItem ) smr_allocateCopyStringN( smr, s, n, forItem, __FILE__, __LINE__, __func__ )
@@ -135,7 +141,6 @@ char *smr_allocateCopyStringN( statusMessageReporting *smr, char const *s, size_
#if defined __cplusplus
}
}
#endif
#endif /* End of statusMessageReporting_h_included. */
@@ -1,356 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef xDataTOM_h_included
#define xDataTOM_h_included
#include <statusMessageReporting.h>
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
typedef int xDataTOM_Int;
/* Note: xDataTOM_interpolationFlag_flat must be last for current logic in xDataTOM_interpolation.c to work. */
enum xDataTOM_interpolationFlag { xDataTOM_interpolationFlag_invalid, xDataTOM_interpolationFlag_linear, xDataTOM_interpolationFlag_log,
xDataTOM_interpolationFlag_byRegion, xDataTOM_interpolationFlag_flat };
enum xDataTOM_interpolationQualifier { xDataTOM_interpolationQualifier_invalid, xDataTOM_interpolationQualifier_dependent,
xDataTOM_interpolationQualifier_none, xDataTOM_interpolationQualifier_unitBase, xDataTOM_interpolationQualifier_correspondingPoints };
enum xDataTOM_frame { xDataTOM_frame_invalid, xDataTOM_frame_lab, xDataTOM_frame_centerOfMass };
enum xDataTOM_subAxesType { xDataTOM_subAxesType_proxy, xDataTOM_subAxesType_intepolationAxes };
enum xDataTOM_KalbachMannType { xDataTOM_KalbachMannType_fr, xDataTOM_KalbachMannType_fra };
typedef struct xDataTOM_interpolation_s xDataTOM_interpolation;
typedef struct xDataTOM_axis_s xDataTOM_axis;
typedef struct xDataTOM_axes_s xDataTOM_axes;
typedef struct xDataTOM_subAxes_s xDataTOM_subAxes;
typedef struct xDataTOM_XYs_s xDataTOM_XYs;
typedef struct xDataTOM_regionsXYs_s xDataTOM_regionsXYs;
typedef struct xDataTOM_W_XYs_s xDataTOM_W_XYs;
typedef struct xDataTOM_V_W_XYs_s xDataTOM_V_W_XYs;
typedef struct xDataTOM_LegendreSeries_s xDataTOM_LegendreSeries;
typedef struct xDataTOM_W_XYs_LegendreSeries_s xDataTOM_W_XYs_LegendreSeries;
typedef struct xDataTOM_regionsW_XYs_LegendreSeries_s xDataTOM_regionsW_XYs_LegendreSeries;
typedef struct xDataTOM_V_W_XYs_LegendreSeries_s xDataTOM_V_W_XYs_LegendreSeries;
typedef struct xDataTOM_KalbachMannCoefficients_s xDataTOM_KalbachMannCoefficients;
typedef struct xDataTOM_KalbachMann_s xDataTOM_KalbachMann;
typedef struct xDataTOM_polynomial_s xDataTOM_polynomial;
typedef struct xDataTOM_xDataInfo_s xDataTOM_xDataInfo;
typedef struct xDataTOM_attribute_s xDataTOM_attribute;
typedef struct xDataTOM_attributionList_s xDataTOM_attributionList;
typedef struct xDataTOM_elementListItem_s xDataTOM_elementListItem;
typedef struct xDataTOM_elementList_s xDataTOM_elementList;
typedef struct xDataTOM_element_s xDataTOM_element;
typedef struct xDataTOM_TOM_s xDataTOM_TOM;
typedef int (*xDataTOM_sortElementFunc)( const void *, const void * );
struct xDataTOM_interpolation_s {
enum xDataTOM_interpolationFlag independent, dependent;
enum xDataTOM_interpolationQualifier qualifier;
};
struct xDataTOM_axis_s {
int index;
char *label;
char *unit;
xDataTOM_interpolation interpolation;
};
struct xDataTOM_axes_s {
int numberOfAxes;
xDataTOM_axis *axis;
};
struct xDataTOM_subAxes_s {
enum xDataTOM_subAxesType type;
int offset;
xDataTOM_axes *axes;
xDataTOM_interpolation interpolation;
};
struct xDataTOM_XYs_s {
int index, length;
double value, accuracy;
xDataTOM_subAxes subAxes;
double *data;
};
struct xDataTOM_regionsXYs_s {
int length;
xDataTOM_axes *axes;
xDataTOM_XYs *XYs;
};
struct xDataTOM_W_XYs_s {
int index, length;
double value;
xDataTOM_subAxes subAxes;
xDataTOM_XYs *XYs;
};
struct xDataTOM_V_W_XYs_s {
int length;
xDataTOM_subAxes subAxes;
xDataTOM_W_XYs *W_XYs;
};
struct xDataTOM_LegendreSeries_s {
int index, length;
double value;
double *LegendreSeries;
};
struct xDataTOM_W_XYs_LegendreSeries_s {
int index, length;
double value;
xDataTOM_subAxes subAxes;
xDataTOM_LegendreSeries *LegendreSeries;
};
struct xDataTOM_regionsW_XYs_LegendreSeries_s {
int length;
xDataTOM_axes *axes;
xDataTOM_W_XYs_LegendreSeries *W_XYs_LegendreSeries;
};
struct xDataTOM_V_W_XYs_LegendreSeries_s {
int length;
xDataTOM_subAxes subAxes;
xDataTOM_W_XYs_LegendreSeries *W_XYs_LegendreSeries;
};
struct xDataTOM_KalbachMannCoefficients_s {
int index, length;
double value;
double *coefficients;
};
struct xDataTOM_KalbachMann_s {
enum xDataTOM_KalbachMannType type;
int numberOfEnergies;
xDataTOM_subAxes subAxes;
xDataTOM_KalbachMannCoefficients *coefficients;
};
struct xDataTOM_polynomial_s {
int length;
xDataTOM_subAxes subAxes;
double *coefficients;
};
struct xDataTOM_xDataInfo_s {
const char *ID;
xDataTOM_element *element;
xDataTOM_axes axes;
void *data;
};
struct xDataTOM_attribute_s {
xDataTOM_attribute *next;
char *name;
char *value;
};
struct xDataTOM_attributionList_s {
int number;
xDataTOM_attribute *attributes;
};
struct xDataTOM_elementListItem_s {
xDataTOM_element *element;
const char *sortString;
};
struct xDataTOM_elementList_s {
int n;
xDataTOM_elementListItem *items;
};
struct xDataTOM_element_s {
int ordinal; /* Counting from 0. */
int index; /* Value from "index" attribute if present or -1. */
xDataTOM_element *parent;
xDataTOM_element *next;
char *name;
xDataTOM_attributionList attributes;
int numberOfChildren;
xDataTOM_element *children;
xDataTOM_xDataInfo xDataInfo;
};
struct xDataTOM_TOM_s {
char *fileName;
char *realFileName;
xDataTOM_element root;
};
/*
* Stuff in common/xDataTOM.c
*/
xDataTOM_TOM *xDataTOM_importFile( statusMessageReporting *smr, const char *fileName );
xDataTOM_TOM *xDataTOM_mallocTOM( statusMessageReporting *smr );
int xDataTOM_initializeTOM( statusMessageReporting *smr, xDataTOM_TOM *doc );
void *xDataTOM_freeTOM( statusMessageReporting *smr, xDataTOM_TOM **TOM );
int xDataTOM_setFileNameTOM( statusMessageReporting *smr, xDataTOM_TOM *doc, const char *fileName );
void xDataTOM_displayTree( statusMessageReporting *smr, xDataTOM_TOM *TOM, int printAttributes );
xDataTOM_element *xDataTOM_mallocElement( statusMessageReporting *smr, xDataTOM_element *parent, int ordinal, int index, char const *name );
void xDataTOM_freeElement( xDataTOM_element **element );
void xDataTOM_releaseElement( xDataTOM_element *element );
xDataTOM_element *xDataTOM_addElementInElement( statusMessageReporting *smr, xDataTOM_element *parent, int index, char const *name );
xDataTOM_element *xDataTOM_getDocumentsElement( xDataTOM_TOM *TOM );
xDataTOM_element *xDataTOME_getFirstElement( xDataTOM_element *element );
xDataTOM_element *xDataTOME_getNextElement( xDataTOM_element *element );
xDataTOM_element *xDataTOME_getOneElementByName( statusMessageReporting *smr, xDataTOM_element *element, char const *name, int required );
int xDataTOM_numberOfElementsByName( statusMessageReporting *smr, xDataTOM_element *element, char const *name );
int xDataTOME_addAttribute( statusMessageReporting *smr, xDataTOM_element *element, char const *name, char const *value );
char const *xDataTOM_getAttributesValueInElement( xDataTOM_element *element, char const *name );
int xDataTOME_copyAttributionList( statusMessageReporting *smr, xDataTOM_attributionList *desc, xDataTOM_element *element );
int xDataTOME_convertAttributeToInteger( statusMessageReporting *smr, xDataTOM_element *element, char const *name, int *n );
int xDataTOME_convertAttributeToDouble( statusMessageReporting *smr, xDataTOM_element *element, char const *name, double *d );
int xDataTOME_convertAttributeToDoubleWithUnit( statusMessageReporting *smr, xDataTOM_element *element, char const *name, double *d, char *unit );
int xDataTOME_getInterpolation( statusMessageReporting *smr, xDataTOM_element *element, int index,
enum xDataTOM_interpolationFlag *independent, enum xDataTOM_interpolationFlag *dependent, enum xDataTOM_interpolationQualifier *qualifier );
void xDataTOMAL_initial( statusMessageReporting *smr, xDataTOM_attributionList *attributes );
void xDataTOMAL_release( xDataTOM_attributionList *attributes );
int xDataTOMAL_addAttribute( statusMessageReporting *smr, xDataTOM_attributionList *attributes, char const *name, char const *value );
char const *xDataTOMAL_getAttributesValue( xDataTOM_attributionList *attributes, char const *name );
int xDataTOMAL_copyAttributionList( statusMessageReporting *smr, xDataTOM_attributionList *desc, xDataTOM_attributionList *src );
int xDataTOMAL_convertAttributeToInteger( statusMessageReporting *smr, xDataTOM_attributionList *attributes, char const *name, int *n );
int xDataTOMAL_convertAttributeToDouble( statusMessageReporting *smr, xDataTOM_attributionList *attributes, char const *name, double *d );
void *xData_initializeData( statusMessageReporting *smr, xDataTOM_element *TE, char const *ID, size_t size );
int xDataTOM_isXDataID( xDataTOM_element *TE, char const *ID );
/*
* Stuff in common/xDataTOMMisc.c
*/
char *xDataTOMMisc_getAbsPath( statusMessageReporting *smr, const char *fileName );
int xDataTOM_setMessageError_ReturnInt( int value, statusMessageReporting *smr, void *userData, const char *file, int line, int code, const char *fmt, ... );
xDataTOM_element *xDataTOM_getLinksElement( statusMessageReporting *smr, xDataTOM_element *element, char const *link );
#define xDataTOMMisc_allocateCopyString2( smr, s, forItem ) xDataTOMMisc_allocateCopyString( smr, s, forItem, __FILE__, __LINE__ )
/*
* Stuff in common/xDataTOM_interpolation.c
*/
int xDataTOM_interpolation_set( statusMessageReporting *smr, xDataTOM_interpolation *interpolation, enum xDataTOM_interpolationFlag independent,
enum xDataTOM_interpolationFlag dependent, enum xDataTOM_interpolationQualifier qualifier );
int xDataTOM_interpolation_setFromString( statusMessageReporting *smr, xDataTOM_interpolation *interpolation, char const *str );
int xDataTOM_interpolation_copy( statusMessageReporting *smr, xDataTOM_interpolation *desc, xDataTOM_interpolation *src );
/*
* Stuff in common/xDataTOM_axes.c
*/
int xDataTOM_axes_initialize( statusMessageReporting *smr, xDataTOM_axes *axes, int numberOfAxes );
int xDataTOM_axes_release( xDataTOM_axes *axes );
char const *xDataTOM_axes_getLabel( statusMessageReporting *smr, xDataTOM_axes *axes, int index );
char const *xDataTOM_axes_getUnit( statusMessageReporting *smr, xDataTOM_axes *axes, int index );
int xDataTOM_axes_getInterpolation( statusMessageReporting *smr, xDataTOM_axes *axes, int index, enum xDataTOM_interpolationFlag *independent,
enum xDataTOM_interpolationFlag *dependent, enum xDataTOM_interpolationQualifier *qualifier );
int xDataTOM_subAxes_initialize( statusMessageReporting *smr, xDataTOM_subAxes *subAxes, enum xDataTOM_subAxesType type, int offset,
xDataTOM_axes *axes, xDataTOM_interpolation *interpolation );
int xDataTOM_subAxes_release( xDataTOM_subAxes *subAxes );
char const *xDataTOM_subAxes_getLabel( statusMessageReporting *smr, xDataTOM_subAxes *subAxes, int index );
char const *xDataTOM_subAxes_getUnit( statusMessageReporting *smr, xDataTOM_subAxes *subAxes, int index );
xDataTOM_axis *xDataTOM_axis_new( statusMessageReporting *smr, int index, char const *label, char const *unit, xDataTOM_interpolation *interpolation );
int xDataTOM_axis_initialize( statusMessageReporting *smr, xDataTOM_axis *axis, int index, char const *label, char const *unit,
xDataTOM_interpolation *interpolation );
xDataTOM_axis *xDataTOM_axis_release( statusMessageReporting *smr, xDataTOM_axis *axis );
enum xDataTOM_frame xDataTOM_axis_stringToFrame( statusMessageReporting *smr, char const *frame );
char const *xDataTOM_axis_frameToString( statusMessageReporting *smr, enum xDataTOM_frame frame );
/*
* Stuff in common/xDataTOM_XYs.c
*/
int xDataTOM_XYs_free( xDataTOM_xDataInfo *xDI );
int xDataTOM_XYs_release( xDataTOM_XYs *XYs );
int xDataTOM_XYs_getData( xDataTOM_XYs *XYs, double **data );
int xDataTOM_XYs_getDataFromXDataInfo( xDataTOM_xDataInfo *xDI, double **data );
/*
* Stuff in common/xDataTOM_regionsXYs.c
*/
int xDataTOM_regionsXYs_free( xDataTOM_xDataInfo *xDI );
/*
* Stuff in common/xDataTOM_W_XYs.c
*/
xDataTOM_W_XYs *xDataTOM_W_XYs_new( statusMessageReporting *smr, int index, int length, double value, xDataTOM_axes *axes, int axesOffset );
int xDataTOM_W_XYs_initialize( statusMessageReporting *smr, xDataTOM_W_XYs *W_XYs, int index, int length, double value, xDataTOM_axes *axes,
int axesOffset );
xDataTOM_W_XYs *xDataTOM_W_XYs_free( xDataTOM_W_XYs *W_XYs );
int xDataTOM_W_XYs_freeFrom_xDataInfo( xDataTOM_xDataInfo *xDI );
int xDataTOM_W_XYs_release( xDataTOM_W_XYs *W_XYs );
xDataTOM_xDataInfo *xDataTOME_getXData( xDataTOM_element *TE );
void *xDataTOME_getXDataIfID( statusMessageReporting *smr, xDataTOM_element *TE, char const *ID );
/*
* Stuff in common/xDataTOM_V_W_XYs.c
*/
int xDataTOM_V_W_XYs_initialize( statusMessageReporting *smr, xDataTOM_V_W_XYs *V_W_XYs, int length, xDataTOM_axes *axes );
int xDataTOM_V_W_XYs_free( xDataTOM_xDataInfo *xDI );
/*
* Stuff in common/xDataTOM_LegendreSeries.c
*/
int xDataTOM_LegendreSeries_initialize( statusMessageReporting *smr, xDataTOM_LegendreSeries *LegendreSeries, int index, int length, double value );
int xDataTOM_LegendreSeries_release( xDataTOM_LegendreSeries *LegendreSeries );
/*
* Stuff in common/xDataTOM_W_XYs_LegendreSeries.c
*/
int xDataTOM_W_XYs_LegendreSeries_initialize( statusMessageReporting *smr, xDataTOM_W_XYs_LegendreSeries *W_XYs_LegendreSeries, int index,
int length, double value, enum xDataTOM_subAxesType subAxesType, xDataTOM_axes *axes, xDataTOM_interpolation *interpolation );
int xDataTOM_W_XYs_LegendreSeries_free( xDataTOM_xDataInfo *xDI );
int xDataTOM_W_XYs_LegendreSeries_release( xDataTOM_W_XYs_LegendreSeries *W_XYs_LegendreSeries );
/*
* Stuff in common/xDataTOM_regionsW_XYs_LegendreSeries.c
*/
int xDataTOM_regionsW_XYs_LegendreSeries_initialize( statusMessageReporting *smr, xDataTOM_regionsW_XYs_LegendreSeries *regionsW_XYs_LegendreSeries,
int length, xDataTOM_axes *axes );
int xDataTOM_regionsW_XYs_LegendreSeries_free( xDataTOM_xDataInfo *xDI );
int xDataTOM_regionsW_XYs_LegendreSeries_release( xDataTOM_regionsW_XYs_LegendreSeries *regionsW_XYs_LegendreSeries );
/*
* Stuff in common/xDataTOM_V_W_XYs_LegendreSeries.c
*/
int xDataTOM_V_W_XYs_LegendreSeries_initialize( statusMessageReporting *smr, xDataTOM_V_W_XYs_LegendreSeries *V_W_XYs_LegendreSeries,
int length, xDataTOM_axes *axes );
int xDataTOM_V_W_XYs_LegendreSeries_free( xDataTOM_xDataInfo *xDI );
/*
* Stuff in common/xDataTOM_KalbachMann.c
*/
int xDataTOM_KalbachMann_initialize( statusMessageReporting *smr, xDataTOM_KalbachMann *KalbachMann, int length, xDataTOM_axes *axes );
int xDataTOM_KalbachMann_free( xDataTOM_xDataInfo *xDI );
int xDataTOM_KalbachMann_release( xDataTOM_KalbachMann *KalbachMann );
/*
* Stuff in common/xDataTOM_polynomial.c
*/
int xDataTOM_polynomial_initialize( statusMessageReporting *smr, xDataTOM_polynomial *polynomial, int length, xDataTOM_axes *axes );
int xDataTOM_polynomial_free( xDataTOM_xDataInfo *xDI );
int xDataTOM_polynomial_release( xDataTOM_polynomial *polynomial );
int xDataTOM_polynomial_getData( xDataTOM_polynomial *polynomial, double **data );
int xDataTOM_polynomial_getDataFromXDataInfo( xDataTOM_xDataInfo *xDI, double **data );
#if defined __cplusplus
}
}
#endif
#endif /* End of xDataTOM_h_included. */
@@ -1,250 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef xDataTOM_importXML_private_h_included
#define xDataTOM_importXML_private_h_included
#include <expat.h>
#include <statusMessageReporting.h>
#include <xDataTOM_private.h>
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
#ifndef XMLCALL
#define XMLCALL
#endif
#ifndef XML_Char
#define XML_Char char
#endif
#ifndef XML_Size
#define XML_Size long
#endif
typedef struct xDataXMLType_s xDataXMLType;
enum xDataXML_status { xDataXML_statusParsing = 1, xDataXML_statusCompleted, xDataXML_statusError };
enum xDataXML_errorCodes { xDataXML_errNone, xDataXML_errXML_ParserCreate, xDataXML_errFileError, xDataXML_errXMLParser };
enum xDataXML_itemMode { xDataXML_itemModeEnd = 0, xDataXML_itemModeElement, xDataXML_itemModeText };
enum xDataXML_xDataType { xDataXML_xDataType_Ok, xDataXML_xDataType_ConvertingToData, xDataXML_xDataType_ConvertingToString };
typedef struct xDataTOM_importXMLTOM_s xDataTOM_importXMLTOM;
typedef struct xDataXML_attribute_s xDataXML_attribute;
typedef struct xDataXML_document_s xDataXML_document;
typedef struct xDataXML_docInfo_s xDataXML_docInfo;
typedef struct xDataXML_attributionList_s xDataXML_attributionList;
typedef struct xDataXML_element_s xDataXML_element;
typedef struct xDataXML_elementList_s xDataXML_elementList;
typedef struct xDataXML_elementListItem_s xDataXML_elementListItem;
typedef struct xDataXML_rootElement_s xDataXML_rootElement;
typedef struct xDataXML_text_s xDataXML_text;
typedef struct xDataXML_smr_s xDataXML_smr;
typedef struct xDataXML_item_s xDataXML_item;
struct xDataXML_docInfo_s {
size_t line;
size_t column;
};
struct xDataXML_attribute_s {
char *name;
char *value;
};
struct xDataXML_attributionList_s {
int number;
size_t size;
xDataXML_attribute *attributes;
};
struct xDataXML_text_s {
xDataXML_docInfo docInfo;
size_t allocated;
size_t length;
char *text;
};
typedef int (*xDTXML_toDataFunction)( statusMessageReporting *smr, xDataXMLType *, xDataXML_attributionList *, char const * );
typedef char *(*xDTXML_toStringFunction)( statusMessageReporting *smr, xDataXMLType * );
typedef int (*xDTXML_releaseFunction)( statusMessageReporting *smr, xDataXMLType * );
struct xDataXML_elementListItem_s {
xDataXML_element *element;
const char *sortString;
};
struct xDataXML_elementList_s {
int n;
xDataXML_elementListItem *items;
};
struct xDataXMLType_s {
enum xDataXML_xDataType status;
const char *ID;
xDataXML_element *element;
xDTXML_toDataFunction toData;
xDTXML_toStringFunction toString;
xDTXML_releaseFunction release;
int indexPresent, startPresent, endPresent, lengthPresent;
xDataTOM_Int index, start, end, length;
void *data;
};
struct xDataXML_rootElement_s {
xDataXML_document *xData_doc;
xDataXML_element *parentElement;
xDataXML_rootElement *parentRoot;
int depth;
int numberOfElements;
xDataXML_element *children;
xDataXML_element *currentChild;
};
struct xDataXML_element_s {
xDataXML_docInfo docInfo;
int ordinal; /* Counting from 0. */
int index; /* Value from "index" attribute if present or -1 */
int accessed; /* For the convenience of the users, not used internally. */
xDataXML_rootElement *parentRoot;
xDataXML_rootElement childrenRoot;
xDataXML_element *next;
char *name; /* Allocated in xData_parseAddElementToRoot. */
char *fullName; /* Allocated in xData_parseAddElementToRoot. */
xDataXML_attributionList attributes; /* attributes->abbributes is allocated in xData_parseAddElementToRoot. */
xDataXMLType xDataTypeInfo;
size_t textOffset;
xDataXML_text text;
};
struct xDataXML_smr_s {
smr_userInterface smrUserInterface;
xDataXML_document *doc;
};
struct xDataXML_document_s {
enum xDataXML_status status;
enum xDataXML_errorCodes error;
enum XML_Error err;
XML_Size err_line, err_column;
char *fileName;
char *realFileName;
xDataXML_smr smrUserInterface;
statusMessageReporting *smr;
XML_Parser xmlParser;
xDataXML_rootElement root;
xDataXML_rootElement *currentRoot;
};
struct xDataXML_item_s {
xDataXML_element *parentElement;
xDataXML_element *element;
enum xDataXML_itemMode mode;
size_t textOffset;
size_t textLength;
char *text;
};
xDataTOM_TOM *xDataXML_importFile( statusMessageReporting *smr, char const *fileName );
xDataXML_document *xDataXML_importFile2( statusMessageReporting *smr, char const *fileName );
void *xDataXML_freeDoc( statusMessageReporting *smr, xDataXML_document *doc );
int xDataXML_parseIsError( xDataXML_document *doc );
xDataXML_element *xDataXML_getDocumentsElement( xDataXML_document *doc );
xDataXML_element *xDataXML_getFirstElement( xDataXML_element *element );
xDataXML_element *xDataXML_getNextElement( xDataXML_element *element );
enum xDataXML_itemMode xDataXML_getFirstItem( xDataXML_element *element, xDataXML_item *item );
enum xDataXML_itemMode xDataXML_getNextItem( xDataXML_item *item );
int xDataXML_isAttributeInList( xDataXML_attributionList *attributes, char const *name );
int xDataXML_isAttributeInElement( xDataXML_element *element, char const *name );
char *xDataXML_getAttributesValue( xDataXML_attributionList *attributes, char const *name );
char const *xDataXML_getAttributesValueInElement( xDataXML_element *element, char const *name );
int xDataXML_attributeListLength( xDataXML_attributionList *attributes );
xDataXML_attribute *xDataXML_attributeByIndex( xDataXML_attributionList *attributes, int index );
int xDataXML_getCommonData( statusMessageReporting *smr, xDataXML_element *element, xDataTOM_Int *index, xDataTOM_Int *start, xDataTOM_Int *end,
xDataTOM_Int *length );
int xDataXML_xDataTypeConvertAttributes( statusMessageReporting *smr, xDataXML_element *element );
xDataTOM_Int xDataXML_convertAttributeTo_xDataTOM_Int( statusMessageReporting *smr, xDataXML_element *element, char const *name, xDataTOM_Int *n, int required );
int xDataXML_convertAttributeToDouble( statusMessageReporting *smr, xDataXML_element *element, char const *name, double *d, int required );
int xDataXML_numberOfElementsByTagName( statusMessageReporting *smr, xDataXML_element *element, char const *tagName );
xDataXML_elementList *xDataXML_getElementsByTagName( statusMessageReporting *smr, xDataXML_element *element, char const *tagName );
xDataXML_element *xDataXML_getOneElementByTagName( statusMessageReporting *smr, xDataXML_element *element, char *name, int required );
void xDataXML_freeElementList( statusMessageReporting *smr, xDataXML_elementList *list );
int xDataXML_is_xDataType( statusMessageReporting *smr, xDataXMLType *xDT, char const * const type, int setMsg );
char const *xDataXML_getFileName( xDataXML_document *doc );
char const *xDataXML_getRealFileName( xDataXML_document *doc );
xDataXML_document *xDataXML_getElementsDocument( xDataXML_element *element );
void *xDataXML_get_smrUserInterfaceFromDocument( xDataXML_document *doc );
void *xDataXML_get_smrUserInterfaceFromElement( xDataXML_element *element );
int xDataXML_stringTo_xDataTOM_Int( statusMessageReporting *smr, void *smrUserInterface, char const *c, xDataTOM_Int *value, char const *endings, char **e );
int xDataXML_stringTo_double( statusMessageReporting *smr, void *smrUserInterface, char const *c, double *value, char const *endings, char **e );
int xDataXML_addToAccessed( statusMessageReporting *smr, xDataXML_element *element, int increment );
int xDataXML_getAccessed( statusMessageReporting *smr, xDataXML_element *element );
void *xDataXML_initializeData( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE, char const *ID, size_t size );
/*
c Stuff in xDataTOM_importXML_axes.c
*/
int xDataXML_axesElememtToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_axes *axes );
int xDataXML_axesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_axes *axes );
/*
c Stuff in xDataTOM_importXML_XYs.c
*/
int xDataXML_XYsToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE );
int xDataXML_XYsDataToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_XYs *XYs, int index, int length, double value, double accuracy,
enum xDataTOM_subAxesType subAxesType, int axesOffest, xDataTOM_axes *axes, xDataTOM_interpolation *interpolation );
int xDataXML_stringToDoubles( statusMessageReporting *smr, xDataXML_element *XE, char const *s, int length, double *d );
/*
c Stuff in xDataTOM_importXML_regionsXYs.c
*/
int xDataXML_regionsXYsToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE );
/*
c Stuff in xDataTOM_importXML_W_XYs.c
*/
int xDataXML_W_XYsToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE );
int xDataXML_W_XYsDataToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_W_XYs *W_XYs, int index, double value, xDataTOM_axes *axes,
int axesOffset );
/*
c Stuff in xDataTOM_importXML_V_W_XYs.c
*/
int xDataXML_V_W_XYsToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE );
/*
c Stuff in xDataTOM_importXML_W_XYs_LegendreSeries.c
*/
int xDataXML_W_XYs_LegendreSeriesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE );
int xDataXML_W_XYs_LegendreSeries_LegendreSeriesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_LegendreSeries *LegendreSeries );
/*
c Stuff in xDataTOM_importXML_regionsW_XYs_LegendreSeries.c
*/
int xDataXML_regionsW_XYs_LegendreSeriesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE );
/*
c Stuff in xDataTOM_importXML_V_W_XYs_LegendreSeries.c
*/
int xDataXML_V_W_XYs_LegendreSeriesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE );
/*
c Stuff in xDataTOM_importXML_polynomial.c
*/
int xDataXML_polynomialToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE );
/*
c Stuff in xDataTOM_importXML_KalbachMann.c
*/
int xDataXML_KalbachMannToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE );
#if defined __cplusplus
}
}
#endif
#endif /* End of xDataTOM_importXML_private_h_included. */
@@ -1,32 +0,0 @@
/*
# <<BEGIN-copyright>>
# <<END-copyright>>
*/
#ifndef xDataTOM_private_h_included
#define xDataTOM_private_h_included
#include "xDataTOM.h"
#if defined __cplusplus
extern "C" {
namespace GIDI {
#endif
extern int xDataTOM_smrLibraryID;
extern char const *xDataTOM_XYs_ID;
extern char const *xDataTOM_regionsXYs_ID;
extern char const *xDataTOM_W_XYs_ID;
extern char const *xDataTOM_V_W_XYs_ID;
extern char const *xDataTOM_W_XYs_LegendreSeries_ID;
extern char const *xDataTOM_regionsW_XYs_LegendreSeries_ID;
extern char const *xDataTOM_V_W_XYs_LegendreSeries_ID;
extern char const *xDataTOM_KalbachMann_ID;
extern char const *xDataTOM_polynomial_ID;
#if defined __cplusplus
}
}
#endif
#endif /* End of xDataTOM_private_h_included. */