An open source method of characteristics neutron transport code.
Matrix.h
Go to the documentation of this file.
1 
8 #ifndef MATRIX_H_
9 #define MATRIX_H_
10 
11 
12 #ifdef __cplusplus
13 #include <math.h>
14 #include <map>
15 #include <vector>
16 #include <string>
17 #include <iostream>
18 #include <sstream>
19 #include <stdlib.h>
20 #include <iomanip>
21 #include "log.h"
22 #include "constants.h"
23 #endif
24 
25 
26 class Matrix {
27 
28 private:
29 
31  std::vector< std::map<int, CMFD_PRECISION> > _LIL;
32 
34  CMFD_PRECISION* _A;
35  int* _IA;
36  int* _JA;
37  CMFD_PRECISION* _DIAG;
38 
39  bool _modified;
40  int _num_x;
41  int _num_y;
42  int _num_z;
43  int _num_groups;
44  int _num_rows;
45 
47  omp_lock_t* _cell_locks;
48 
49  void convertToCSR();
50  void setNumX(int num_x);
51  void setNumY(int num_y);
52  void setNumZ(int num_z);
53  void setNumGroups(int num_groups);
54 
55 public:
56  Matrix(omp_lock_t* cell_locks, int num_x=1, int num_y=1, int num_z=1,
57  int num_groups=1);
58  virtual ~Matrix();
59 
60  /* Worker functions */
61  void incrementValue(int cell_from, int group_from, int cell_to, int group_to,
62  CMFD_PRECISION val);
63  void clear();
64  void printString();
65  void transpose();
66 
67  /* Getter functions */
68  CMFD_PRECISION getValue(int cell_from, int group_from, int cell_to,
69  int group_to);
70  CMFD_PRECISION* getA();
71  int* getIA();
72  int* getJA();
73  CMFD_PRECISION* getDiag();
74  int getNumX();
75  int getNumY();
76  int getNumZ();
77  int getNumGroups();
78  int getNumRows();
79  int getNNZ();
80  omp_lock_t* getCellLocks();
81 
82  /* Setter functions */
83  void setValue(int cell_from, int group_from, int cell_to, int group_to,
84  CMFD_PRECISION val);
85 };
86 
87 #endif /* MATRIX_H_ */
int getNumY()
Get the number of cells in the y dimension.
Definition: Matrix.cpp:343
void clear()
Clear all values in the matrix list of lists.
Definition: Matrix.cpp:165
Math constants and comparision tolerances.
void printString()
Print the matrix object to the log file.
Definition: Matrix.cpp:234
Matrix(omp_lock_t *cell_locks, int num_x=1, int num_y=1, int num_z=1, int num_groups=1)
Constructor initializes Matrix as a vector of maps and sets the matrix dimensions.
Definition: Matrix.cpp:20
omp_lock_t * getCellLocks()
Return the array of cell locks for atomic cell operations.
Definition: Matrix.cpp:498
int getNumZ()
Get the number of cells in the z dimension.
Definition: Matrix.cpp:352
int getNumX()
Get the number of cells in the x dimension.
Definition: Matrix.cpp:334
int * getJA()
Get the JA component of the CSR form of the matrix object.
Definition: Matrix.cpp:308
int * getIA()
Get the IA component of the CSR form of the matrix object.
Definition: Matrix.cpp:295
Definition: Matrix.h:26
int getNumRows()
Get the number of rows in the matrix.
Definition: Matrix.cpp:370
int getNNZ()
Get the number of non-zero values in the matrix.
Definition: Matrix.cpp:379
CMFD_PRECISION getValue(int cell_from, int group_from, int cell_to, int group_to)
Get a value in the matrix.
Definition: Matrix.cpp:270
void incrementValue(int cell_from, int group_from, int cell_to, int group_to, CMFD_PRECISION val)
Increment a value in the matrix.
Definition: Matrix.cpp:85
void setValue(int cell_from, int group_from, int cell_to, int group_to, CMFD_PRECISION val)
Set a value in the matrix.
Definition: Matrix.cpp:130
void transpose()
Transpose the matrix in place.
Definition: Matrix.cpp:453
CMFD_PRECISION * getA()
Get the A component of the CSR form of the matrix object.
Definition: Matrix.cpp:282
CMFD_PRECISION * getDiag()
Get the diagonal component of the matrix object.
Definition: Matrix.cpp:321
int getNumGroups()
Get the number of groups in each cell.
Definition: Matrix.cpp:361
Utility functions for writing log messages to the screen.
virtual ~Matrix()
Destructor clears list of lists and deletes the arrays used to represent the matrix in CSR form...
Definition: Matrix.cpp:52