An open source method of characteristics neutron transport code.
Material.h
Go to the documentation of this file.
1 
8 #ifndef MATERIAL_H_
9 #define MATERIAL_H_
10 
11 #ifdef __cplusplus
12 #ifdef SWIG
13 #include "Python.h"
14 #endif
15 #include "constants.h"
16 #include "log.h"
17 #include "linalg.h"
18 #include <sstream>
19 #include <string.h>
20 #include <stdlib.h>
21 #include <math.h>
22 #include <malloc.h>
23 #endif
24 
25 #ifdef INTEL
26 
27 #define MM_MALLOC(size,alignment) _mm_malloc(size, alignment)
28 
30 #define MM_FREE(array) _mm_free(array)
31 
32 #else
33 
34 #define MM_MALLOC(size,alignment) memalign(alignment, size)
35 
37 #define MM_FREE(array) free(array)
38 #endif
39 
40 
41 int material_id();
42 void reset_material_id();
44 
45 
51 class Material {
52 
53 private:
54 
56  int _id;
57 
59  char* _name;
60 
62  double _volume;
63 
65  int _num_instances;
66 
68  int _num_groups;
69 
71  FP_PRECISION* _sigma_t;
72 
74  FP_PRECISION _max_sigma_t;
75 
77  FP_PRECISION* _sigma_s;
78 
80  FP_PRECISION* _sigma_a;
81 
83  FP_PRECISION* _sigma_f;
84 
87  FP_PRECISION* _nu_sigma_f;
88 
90  FP_PRECISION* _chi;
91 
93  FP_PRECISION* _fiss_matrix;
94 
97  bool _fissionable;
98 
101  bool _data_aligned;
102 
104  int _num_vector_groups;
105 
106 public:
107  Material(int id=0, const char* name="");
108  virtual ~Material();
109 
110  int getId() const;
111  char* getName() const;
112  double getVolume();
113  int getNumInstances();
114  int getNumEnergyGroups() const;
115  FP_PRECISION* getSigmaT();
116  FP_PRECISION getMaxSigmaT();
117  FP_PRECISION* getSigmaS();
118  FP_PRECISION* getSigmaA();
119  FP_PRECISION* getSigmaF();
120  FP_PRECISION* getNuSigmaF();
121  FP_PRECISION* getChi();
122  FP_PRECISION* getFissionMatrix();
123  FP_PRECISION getSigmaTByGroup(int group);
124  FP_PRECISION getSigmaSByGroup(int origin, int destination);
125  FP_PRECISION getSigmaAByGroup(int group);
126  FP_PRECISION getSigmaFByGroup(int group);
127  FP_PRECISION getNuSigmaFByGroup(int group);
128  FP_PRECISION getChiByGroup(int group);
129  FP_PRECISION getFissionMatrixByGroup(int origin, int destination);
130  bool isFissionable();
131  bool isDataAligned();
132  int getNumVectorGroups();
133 
134  void setName(const char* name);
135  void setVolume(double volume);
136  void incrementVolume(double volume);
137  void setNumInstances(int num_instances);
138  void incrementNumInstances();
139  void setNumEnergyGroups(const int num_groups);
140 
141  void setSigmaT(double* xs, int num_groups);
142  void setSigmaS(double* xs, int num_groups);
143  void setSigmaF(double* xs, int num_groups);
144  void setNuSigmaF(double* xs, int num_groups);
145  void setChi(double* xs, int num_groups);
146 
147  void setSigmaTByGroup(double xs, int group);
148  void setSigmaFByGroup(double xs, int group);
149  void setNuSigmaFByGroup(double xs, int group);
150  void setSigmaSByGroup(double xs, int origin, int destination);
151  void setChiByGroup(double xs, int group);
152  void setSigmaAByGroup(double xs, int group);
153 
154  void buildFissionMatrix();
156  void alignData();
157  Material* clone();
158 
159  std::string toString();
160  void printString();
161 };
162 
163 
164 #endif /* MATERIAL_H_ */
FP_PRECISION getNuSigmaFByGroup(int group)
Get the Material&#39;s nu-fission cross section for some energy group.
Definition: Material.cpp:400
void setNuSigmaFByGroup(double xs, int group)
Set the Material&#39;s fission cross-section multiplied by for some energy group.
Definition: Material.cpp:861
int getNumEnergyGroups() const
Returns the number of energy groups for this Material&#39;s nuclear data.
Definition: Material.cpp:186
void reset_material_id()
Resets the auto-generated unique Material ID counter to 1,000,000.
Definition: Material.cpp:25
FP_PRECISION * getSigmaF()
Return the array of the Material&#39;s fission cross-sections.
Definition: Material.cpp:259
void transposeProductionMatrices()
Transposes the scattering and fission matrices.
Definition: Material.cpp:1091
FP_PRECISION * getChi()
Return the array of the Material&#39;s chi .
Definition: Material.cpp:287
void setSigmaSByGroup(double xs, int origin, int destination)
Set the Material&#39;s scattering cross-section for some energy group.
Definition: Material.cpp:741
int getNumInstances()
Return the number of instances of this Material in the Geometry.
Definition: Material.cpp:177
double getVolume()
Return the aggregate volume/area of all instances of this Material.
Definition: Material.cpp:166
void setChi(double *xs, int num_groups)
Set the Material&#39;s array of chi values.
Definition: Material.cpp:894
Math constants and comparision tolerances.
FP_PRECISION * getSigmaA()
Return the array of the Material&#39;s absorption group cross-sections.
Definition: Material.cpp:230
FP_PRECISION * getSigmaS()
Return the array of the Material&#39;s scattering cross-section matrix.
Definition: Material.cpp:217
void setVolume(double volume)
Set the volume/area of the Material.
Definition: Material.cpp:503
Material(int id=0, const char *name="")
Constructor sets the ID and unique ID for the Material.
Definition: Material.cpp:50
FP_PRECISION getFissionMatrixByGroup(int origin, int destination)
Get the Material&#39;s fission matrix for some energy group.
Definition: Material.cpp:437
Material * clone()
Create a duplicate of the Material.
Definition: Material.cpp:1111
int getId() const
Return the Material&#39;s user-defined ID.
Definition: Material.cpp:146
FP_PRECISION getSigmaTByGroup(int group)
Get the Material&#39;s total cross section for some energy group.
Definition: Material.cpp:313
FP_PRECISION * getNuSigmaF()
Return the array of the Material&#39;s fission cross-sections multiplied by nu .
Definition: Material.cpp:274
int material_id()
Returns an auto-generated unique Material ID.
Definition: Material.cpp:15
void setSigmaS(double *xs, int num_groups)
Set the Material&#39;s 2D array of scattering cross-sections.
Definition: Material.cpp:721
int getNumVectorGroups()
Returns the rounded up number of energy groups to fill an integral number of vector lengths...
Definition: Material.cpp:475
void printString()
Prints a string representation of all of the Material&#39;s attributes to the console.
Definition: Material.cpp:1200
void setSigmaFByGroup(double xs, int group)
Set the Material&#39;s fission cross-section for some energy group.
Definition: Material.cpp:799
void setSigmaTByGroup(double xs, int group)
Set the Material&#39;s total cross-section for some energy group.
Definition: Material.cpp:657
void setName(const char *name)
Sets the name of the Material.
Definition: Material.cpp:484
void setNuSigmaF(double *xs, int num_groups)
Set the Material&#39;s array of fission cross-sections multiplied by .
Definition: Material.cpp:820
void incrementNumInstances()
Increment the number of instances of this Material.
Definition: Material.cpp:533
void setChiByGroup(double xs, int group)
Set the Material&#39;s chi value for some energy group.
Definition: Material.cpp:918
FP_PRECISION getSigmaFByGroup(int group)
Get the Material&#39;s fission cross section for some energy group.
Definition: Material.cpp:382
void incrementVolume(double volume)
Increment the volume/area of the Material by some amount.
Definition: Material.cpp:514
FP_PRECISION getChiByGroup(int group)
Get the Material&#39;s fission spectrum for some energy group.
Definition: Material.cpp:418
The Material class represents a unique material and its relevant nuclear data (i.e., multigroup cross-sections) for neutron transport.
Definition: Material.h:51
bool isFissionable()
Returns whether or not the Material contains a fissionable (non-zero) fission cross-section.
Definition: Material.cpp:456
virtual ~Material()
Destructor deletes all cross-section data structures from memory.
Definition: Material.cpp:90
void setSigmaT(double *xs, int num_groups)
Set the Material&#39;s array of total cross-sections.
Definition: Material.cpp:628
FP_PRECISION getSigmaSByGroup(int origin, int destination)
Get the Material&#39;s scattering cross section for some energy group.
Definition: Material.cpp:332
bool isDataAligned()
Returns true if the data is vector aligned, false otherwise (default).
Definition: Material.cpp:465
std::string toString()
Converts this Material&#39;s attributes to a character array representation.
Definition: Material.cpp:1144
void setNumInstances(int num_instances)
Set the number of instances of this Material.
Definition: Material.cpp:523
FP_PRECISION getMaxSigmaT()
Return the maximum of the Material&#39;s total cross-sections.
Definition: Material.cpp:208
void setNumEnergyGroups(const int num_groups)
Set the number of energy groups for this Material.
Definition: Material.cpp:542
void maximize_material_id(int material_id)
Maximize the auto-generated unique Material ID counter.
Definition: Material.cpp:39
void setSigmaAByGroup(double xs, int group)
Set the Material&#39;s absorption cross-section for some energy group.
Definition: Material.cpp:937
void alignData()
Reallocates the Material&#39;s cross-section data structures along word-aligned boundaries.
Definition: Material.cpp:993
FP_PRECISION * getFissionMatrix()
Return the array of the Material&#39;s fission matrix.
Definition: Material.cpp:300
Utility functions for writing log messages to the screen.
FP_PRECISION getSigmaAByGroup(int group)
Get the Material&#39;s absorption cross section for some energy group.
Definition: Material.cpp:352
FP_PRECISION * getSigmaT()
Return the array of the Material&#39;s total cross-sections.
Definition: Material.cpp:195
char * getName() const
Return the user-defined name of the Material.
Definition: Material.cpp:155
void setSigmaF(double *xs, int num_groups)
Set the Material&#39;s array of fission cross-sections.
Definition: Material.cpp:772
void buildFissionMatrix()
Builds the fission matrix from chi and the fission cross-section.
Definition: Material.cpp:956