rsvs3D  0.0.0
Codes for the c++ implementation of the 3D RSVS
voxel.hpp
Go to the documentation of this file.
1 
7 //===============================================
8 // Include Guards
9 #ifndef VOXEL_H_INCLUDED
10 #define VOXEL_H_INCLUDED
11 
12 //===============================================
13 // Levels of debuging Guards
14 #ifdef DEBUGLVL2 // All Debugging calls
15 #define DEBUGLVL1
16 #define TEST_VOXEL_SURF
17 #define TEST_VOXEL_VOLU
18 #define TEST_EIGENEXT
19 #define TEST_VOXEL_EDGE
20 #define TEST_VOXEL_VERT
21 #define TEST_VOXEL
22 #endif
23 
24 #ifdef DEBUGLVL1 // Debugging of new features.
25 //#define TEST_EIGENEXT
26 #endif
27 
28 //=================================
29 // forward declared dependencies
30 // class foo; //when you only need a pointer not the actual object
31 // and to avoid circular dependencies
32 
33 //=================================
34 // included dependencies
35 
36 #include <Eigen>
37 #include <iostream>
38 #include <numeric> // std::partial_sum
39 
40 #include "arraystructures.hpp"
41 #include "postprocessing.hpp"
42 
43 //==================================
44 // Code
45 // NOTE: function in a class definition are IMPLICITELY INLINED
46 // ie replaced by their code at compile time
47 // Templates
48 
61 template <class T> T cumsum(const T &matIn, int d)
62 {
63  T mat = matIn;
64  if (!d)
65  {
66  for (int i = 0; i < mat.rows(); ++i)
67  {
68  for (int j = 1; j < mat.cols(); ++j)
69  {
70  mat(i, j) += mat(i, j - 1);
71  }
72  }
73  }
74  else
75  {
76  for (int i = 1; i < mat.rows(); ++i)
77  {
78  for (int j = 0; j < mat.cols(); ++j)
79  {
80  mat(i, j) += mat(i - 1, j);
81  }
82  }
83  }
84  return (mat);
85 }
86 
99 template <class T> T cumprod(const T &matIn, int d)
100 {
101  T mat = matIn;
102  if (!d)
103  {
104  for (int i = 0; i < mat.rows(); ++i)
105  {
106  for (int j = 1; j < mat.cols(); ++j)
107  {
108  mat(i, j) *= mat(i, j - 1);
109  }
110  }
111  }
112  else
113  {
114  for (int i = 1; i < mat.rows(); ++i)
115  {
116  for (int j = 0; j < mat.cols(); ++j)
117  {
118  mat(i, j) *= mat(i - 1, j);
119  }
120  }
121  }
122  return (mat);
123 }
124 
125 // functions
126 int BuildBlockGrid(std::array<int, 3> &dimGrid, mesh &blockGrid);
127 int BuildBlockGrid(const Eigen::RowVector3i &dimGrid, mesh &blockGrid);
128 int BuildBlockVert(const Eigen::RowVector3i &dimGrid, mesh &blockGrid, int nVert, const Eigen::Matrix3i &edgeProp,
129  const Eigen::RowVector3i &nEdgeDim);
130 
131 int BuildBlockEdge(const Eigen::RowVector3i &dimGrid, mesh &blockGrid, int nEdge, const Eigen::RowVector3i &nEdgeDim,
132  const Eigen::RowVector3i &nSurfDim, const Eigen::Matrix3i &edgeProp,
133  const Eigen::Matrix3i &surfProp);
134 
135 int BuildBlockSurf(const Eigen::RowVector3i &dimGrid, int nSurf, mesh &blockGrid, const Eigen::Matrix3i &surfProp,
136  const Eigen::Matrix3i &edgeProp, const Eigen::RowVector3i &nSurfDim,
137  const Eigen::RowVector3i &nEdgeDim);
138 
139 int BuildBlockVolu(const Eigen::RowVector3i &dimGrid, int nVolu, mesh &blockGrid, const Eigen::RowVector3i &nSurfDim,
140  const Eigen::Matrix3i &surfProp);
141 // test functions
142 int Test_BuildBlockGrid_noout();
143 int Test_MeshOut();
144 int Test_MeshOut2();
145 int Test_MeshOut_Size(Eigen::RowVector3i dimGrid, bool runReOrder = false);
146 int Test_MeshReOrder();
147 
148 #endif // VOXEL_H_INCLUDED
Provide std::vector container with hashed index mapping.
Class for mesh handling.
Definition: mesh.hpp:592
Provide tecplot file formating for mesh and snake outputs.
T cumprod(const T &matIn, int d)
template which applies cumulative product to Eigen Matrix.
Definition: voxel.hpp:99
T cumsum(const T &matIn, int d)
template which applies cumulative sum to Eigen Matrix.
Definition: voxel.hpp:61