Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MCGIDI_particle.cc File Reference
#include <string.h>
#include "MCGIDI.h"
Include dependency graph for MCGIDI_particle.cc:

Go to the source code of this file.

Functions

MCGIDI_particleMCGIDI_particle_new (statusMessageReporting *smr)
 
int MCGIDI_particle_initialize (statusMessageReporting *, MCGIDI_particle *particle)
 
MCGIDI_particleMCGIDI_particle_free (statusMessageReporting *smr, MCGIDI_particle *particle)
 
int MCGIDI_particle_release (statusMessageReporting *, MCGIDI_particle *particle)
 
int MCGIDI_particle_freeInternalList (statusMessageReporting *smr)
 
MCGIDI_particleMCGIDI_particle_getInternalID (statusMessageReporting *smr, const char *const name, MCGIDI_POPs *pops)
 
int MCGIDI_particle_printInternalSortedList (statusMessageReporting *)
 

Variables

static int initialSizeOfList = 1000
 
static int incrementalSizeOfList = 1000
 
static int numberOfParticles = 0
 
static int sizeOfParticleSortedList = 0
 
static MCGIDI_particle ** particleSortedList = NULL
 
static MCGIDI_particleparticleList = NULL
 
static MCGIDI_particleparticleListEnd = NULL
 

Function Documentation

MCGIDI_particle* MCGIDI_particle_free ( statusMessageReporting smr,
MCGIDI_particle particle 
)

Definition at line 39 of file MCGIDI_particle.cc.

39  {
40 
41  int i, j;
43 
44  for( i = 0, p = particleSortedList; i < numberOfParticles; i++, p++ ) {
45  if( *p == particle ) {
46  numberOfParticles--;
47  for( j = i; j < numberOfParticles; j++, p++ ) *p = p[1];
48  break;
49  }
50  }
51  if( particle == particleListEnd ) particleListEnd = particle->prior;
52  if( particle == particleList ) particleList = particle->next;
53  if( particle->prior != NULL ) particle->prior->next = particle->next;
54  if( particle->next != NULL ) particle->next->prior = particle->prior;
55  MCGIDI_particle_release( smr, particle );
56  smr_freeMemory( (void **) &particle );
57  return( NULL );
58 }
MCGIDI_particle * prior
Definition: MCGIDI.h:247
static int numberOfParticles
static MCGIDI_particle * particleListEnd
const char * p
Definition: xmltok.h:285
static MCGIDI_particle ** particleSortedList
static MCGIDI_particle * particleList
void * smr_freeMemory(void **p)
MCGIDI_particle * next
Definition: MCGIDI.h:248
int MCGIDI_particle_release(statusMessageReporting *smr, MCGIDI_particle *particle)

Here is the call graph for this function:

Here is the caller graph for this function:

int MCGIDI_particle_freeInternalList ( statusMessageReporting smr)

Definition at line 70 of file MCGIDI_particle.cc.

70  {
71 
72  while( particleList != NULL ) MCGIDI_particle_free( smr, particleList ); // Loop checking, 11.06.2015, T. Koi
74  return( 0 );
75 }
static MCGIDI_particle ** particleSortedList
static MCGIDI_particle * particleList
MCGIDI_particle * MCGIDI_particle_free(statusMessageReporting *smr, MCGIDI_particle *particle)
void * smr_freeMemory(void **p)

Here is the call graph for this function:

MCGIDI_particle* MCGIDI_particle_getInternalID ( statusMessageReporting smr,
const char *const  name,
MCGIDI_POPs pops 
)

Definition at line 79 of file MCGIDI_particle.cc.

79  {
80 
81  int i, iCmp, min, mid, max, Z, A, m, level;
82  MCGIDI_particle *particle;
83  MCGIDI_POP *pop;
84 
85  iCmp = 0;
86  min = mid = 0;
87  max = numberOfParticles;
88  while( min != max ) { // Loop checking, 11.06.2015, T. Koi
89  mid = ( min + max ) / 2;
90  iCmp = strcmp( name, particleSortedList[mid]->name );
91  if( iCmp == 0 ) return( particleSortedList[mid] );
92  if( iCmp < 0 ) {
93  max = mid - 1;
94  if( mid == 0 ) max = 0; }
95  else {
96  min = mid + 1;
97  if( min > max ) min = max;
98  }
99  }
100  mid = min;
101  if( numberOfParticles > 0 ) {
102  iCmp = strcmp( name, particleSortedList[mid]->name );
103  if( iCmp == 0 ) return( particleSortedList[mid] );
104  if( ( iCmp < 0 ) && ( mid != 0 ) ) {
105  mid--;
106  iCmp = strcmp( name, particleSortedList[mid]->name );
107  }
108  }
109 
110  if( ( particle = MCGIDI_particle_new( smr ) ) == NULL ) return( NULL );
111  if( ( particle->name = smr_allocateCopyString( smr, name, "particle->name", __FILE__, __LINE__, __func__ ) ) == NULL ) goto err;
112  if( MCGIDI_miscNameToZAm( smr, name, &Z, &A, &m, &level ) != 0 ) goto err;
113  particle->prior = NULL;
114  particle->next = NULL;
115  particle->Z = Z;
116  particle->A = A;
117  particle->m = m;
118  if( ( pop = MCGIDI_POPs_findParticle( pops, name ) ) == NULL ) { /* This should not happend. */
119  particle->mass_MeV = MCGIDI_AMU2MeV * MCGIDI_particleMass_AMU( smr, name ); }
120  else {
121  particle->mass_MeV = pop->mass_MeV;
122  }
123  if( !smr_isOk( smr ) ) goto err;
124 
126  if( sizeOfParticleSortedList == 0 ) {
128  else {
130  }
132  "particleSortedList" ) ) == NULL ) goto err;
133  }
134 
135  if( particleList == NULL ) {
136  particle->ordinal = 0;
137  particleListEnd = particleList = particle; }
138  else {
139  particle->ordinal = particleListEnd->ordinal + 1;
140  particle->prior = particleListEnd;
141  particleListEnd->next = particle;
142  particleListEnd = particle;
143  }
144 
145  if( ( mid != 0 ) || ( iCmp > 0 ) ) mid++;
146  for( i = numberOfParticles; i > mid; i-- ) particleSortedList[i] = particleSortedList[i-1];
147  particleSortedList[mid] = particle;
149 
150  return( particle );
151 
152 err:
153  MCGIDI_particle_free( smr, particle );
154  return( NULL );
155 }
const XML_Char * name
Definition: expat.h:151
MCGIDI_particle * prior
Definition: MCGIDI.h:247
static int numberOfParticles
double MCGIDI_particleMass_AMU(statusMessageReporting *smr, const char *name)
Definition: MCGIDI_mass.cc:853
static MCGIDI_particle * particleListEnd
static int initialSizeOfList
MCGIDI_POP * MCGIDI_POPs_findParticle(MCGIDI_POPs *pops, char const *name)
Definition: MCGIDI_pop.cc:133
static MCGIDI_particle ** particleSortedList
double mass_MeV
Definition: MCGIDI.h:251
static int sizeOfParticleSortedList
#define MCGIDI_AMU2MeV
Definition: MCGIDI.h:184
static MCGIDI_particle * particleList
double A(double temperature)
static constexpr double m
Definition: G4SIunits.hh:129
MCGIDI_particle * MCGIDI_particle_free(statusMessageReporting *smr, MCGIDI_particle *particle)
int smr_isOk(statusMessageReporting *smr)
char * smr_allocateCopyString(statusMessageReporting *smr, char const *s, char const *forItem, char const *file, int line, char const *function)
MCGIDI_particle * MCGIDI_particle_new(statusMessageReporting *smr)
int MCGIDI_miscNameToZAm(statusMessageReporting *smr, const char *name, int *Z, int *A, int *m, int *level)
Definition: MCGIDI_misc.cc:81
double mass_MeV
Definition: MCGIDI.h:235
MCGIDI_particle * next
Definition: MCGIDI.h:248
static int incrementalSizeOfList
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
#define smr_realloc2(smr, old, size, forItem)

Here is the call graph for this function:

int MCGIDI_particle_initialize ( statusMessageReporting ,
MCGIDI_particle particle 
)

Definition at line 31 of file MCGIDI_particle.cc.

31  {
32 
33  memset( particle, 0, sizeof( MCGIDI_particle ) );
34  return( 0 );
35 }

Here is the caller graph for this function:

MCGIDI_particle* MCGIDI_particle_new ( statusMessageReporting smr)

Definition at line 20 of file MCGIDI_particle.cc.

20  {
21 
22  MCGIDI_particle *particle = (MCGIDI_particle *) smr_malloc2( smr, sizeof( MCGIDI_particle ), 0, "particle" );
23 
24  if( particle == NULL ) return( NULL );
25  MCGIDI_particle_initialize( smr, particle );
26  return( particle );
27 }
#define smr_malloc2(smr, size, zero, forItem)
int MCGIDI_particle_initialize(statusMessageReporting *smr, MCGIDI_particle *particle)

Here is the call graph for this function:

Here is the caller graph for this function:

int MCGIDI_particle_printInternalSortedList ( statusMessageReporting )

Definition at line 159 of file MCGIDI_particle.cc.

159  {
160 
161  int i;
162 
163  for( i = 0; i < numberOfParticles; i++ ) printf( "%s\n", particleSortedList[i]->name );
164  return( 0 );
165 }
const XML_Char * name
Definition: expat.h:151
static int numberOfParticles
static MCGIDI_particle ** particleSortedList
int MCGIDI_particle_release ( statusMessageReporting ,
MCGIDI_particle particle 
)

Definition at line 62 of file MCGIDI_particle.cc.

62  {
63 
64  smr_freeMemory( (void **) &(particle->name) );
65  return( 0 );
66 }
void * smr_freeMemory(void **p)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int incrementalSizeOfList = 1000
static

Definition at line 13 of file MCGIDI_particle.cc.

int initialSizeOfList = 1000
static

Definition at line 13 of file MCGIDI_particle.cc.

int numberOfParticles = 0
static

Definition at line 14 of file MCGIDI_particle.cc.

MCGIDI_particle* particleList = NULL
static

Definition at line 16 of file MCGIDI_particle.cc.

MCGIDI_particle * particleListEnd = NULL
static

Definition at line 16 of file MCGIDI_particle.cc.

MCGIDI_particle** particleSortedList = NULL
static

Definition at line 15 of file MCGIDI_particle.cc.

int sizeOfParticleSortedList = 0
static

Definition at line 14 of file MCGIDI_particle.cc.