An open source method of characteristics neutron transport code.
Vector.h
Go to the documentation of this file.
1 
8 #ifndef SRC_VECTOR_H_
9 #define SRC_VECTOR_H_
10 
11 
12 #ifdef __cplusplus
13 #include <math.h>
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include <map>
17 #include <vector>
18 #include <string>
19 #include <iostream>
20 #include <sstream>
21 #include <iomanip>
22 #include "log.h"
23 #include "pairwise_sum.h"
24 #endif
25 
26 
27 class Vector {
28  private:
30  CMFD_PRECISION* _array;
31  int _num_rows;
32  int _num_x;
33  int _num_y;
34  int _num_z;
35  int _num_groups;
36 
38  omp_lock_t* _cell_locks;
39 
40  void setNumX(int num_x);
41  void setNumY(int num_y);
42  void setNumZ(int num_z);
43  void setNumGroups(int num_groups);
44 
45  public:
46  Vector(omp_lock_t* cell_locks, int num_x = 1, int num_y = 1, int num_z = 1,
47  int num_groups = 1);
48  virtual ~Vector();
49 
50  /* Worker functions */
51  void incrementValue(int cell, int group, CMFD_PRECISION val);
52  void incrementValues(int cell, int group_start, int group_end,
53  CMFD_PRECISION* vals);
54  void clear();
55  void scaleByValue(CMFD_PRECISION val);
56  void printString();
57  void copyTo(Vector* vector);
58 
59  /* Getter functions */
60  CMFD_PRECISION getValue(int cell, int group);
61  CMFD_PRECISION* getArray();
62  int getNumX();
63  int getNumY();
64  int getNumZ();
65  int getNumGroups();
66  int getNumRows();
67  double getSum();
68  omp_lock_t* getCellLocks();
69 
70  /* Setter functions */
71  void setValue(int cell, int group, CMFD_PRECISION val);
72  void setValues(int cell, int group_start, int group_end,
73  CMFD_PRECISION* vals);
74  void setAll(CMFD_PRECISION val);
75 };
76 
77 #endif // SRC_VECTOR_H_
void setAll(CMFD_PRECISION val)
Fill vector with a value.
Definition: Vector.cpp:125
CMFD_PRECISION * getArray()
Get the array describing the vector.
Definition: Vector.cpp:265
void setValues(int cell, int group_start, int group_end, CMFD_PRECISION *vals)
Set values in the vector.
Definition: Vector.cpp:171
Definition: Vector.h:27
int getNumY()
Get the number of cells in the y dimension.
Definition: Vector.cpp:283
void incrementValue(int cell, int group, CMFD_PRECISION val)
Increment a value in the vector.
Definition: Vector.cpp:60
CMFD_PRECISION getValue(int cell, int group)
Get a value at location described by a given cell and group index.
Definition: Vector.cpp:256
void copyTo(Vector *vector)
Copy the values from the current vector to an input vector.
Definition: Vector.cpp:246
omp_lock_t * getCellLocks()
Return the array of cell locks for atomic cell operations.
Definition: Vector.cpp:384
int getNumZ()
Get the number of cells in the z dimension.
Definition: Vector.cpp:292
void scaleByValue(CMFD_PRECISION val)
Scales the vector by a given value.
Definition: Vector.cpp:212
void setValue(int cell, int group, CMFD_PRECISION val)
Set a value in the vector.
Definition: Vector.cpp:140
int getNumX()
Get the number of cells in the x dimension.
Definition: Vector.cpp:274
void clear()
Clear all values in the vector.
Definition: Vector.cpp:203
virtual ~Vector()
Destructor deletes the arrays used to represent the vector.
Definition: Vector.cpp:43
int getNumGroups()
Get the number of groups in each cell.
Definition: Vector.cpp:301
int getNumRows()
Get the number of rows in the vector.
Definition: Vector.cpp:310
void printString()
Print the vector object to the log file.
Definition: Vector.cpp:223
Vector(omp_lock_t *cell_locks, int num_x=1, int num_y=1, int num_z=1, int num_groups=1)
Constructor initializes Vector object as a floating point array and sets the vector dimensions...
Definition: Vector.cpp:17
double getSum()
Get the sum of all the values in the vector.
Definition: Vector.cpp:319
void incrementValues(int cell, int group_start, int group_end, CMFD_PRECISION *vals)
Increment values in the vector.
Definition: Vector.cpp:92
Utility function for the accurate pairwise sum of a list of floating point numbers.
Utility functions for writing log messages to the screen.