From bc4e30a311dcbc592d48051a16857e9e5d9f5af8 Mon Sep 17 00:00:00 2001 From: Kirill Terekhov Date: Tue, 18 Apr 2017 00:01:14 -0700 Subject: [PATCH] Few fixes Do not build Octree when opengl was not found. Constant correctness for dense matrices. --- Examples/MFD-ES/main.cpp | 6 +++--- Examples/Octree/CMakeLists.txt | 5 ++++- Source/Headers/inmost_dense.h | 21 ++++++++++++++------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Examples/MFD-ES/main.cpp b/Examples/MFD-ES/main.cpp index aed2c9c..127dd2a 100644 --- a/Examples/MFD-ES/main.cpp +++ b/Examples/MFD-ES/main.cpp @@ -373,7 +373,7 @@ int main(int argc,char ** argv) TagReal tag_Q; // Pressure update TagReal tag_F; // Forcing term TagRealArray tag_W; // Gradient matrix - TagInteger tag_i; // row number for current cell in back cell matrix + TagInteger tag_i; // row number for current face in back cell matrix if( m.GetProcessorsNumber() > 1 ) //skip for one processor job @@ -404,8 +404,8 @@ int main(int argc,char ** argv) { Cell c = m.CellByLocalID(it); ElementArray faces = c.getFaces(); //obtain faces of the cell - tag_W[c].resize(faces.size()*faces.size()); - Matrix W(tag_W[c],faces.size(),faces.size()); + Matrix W(tag_W[c]); + W.Resize(faces.size(),faces.size()); real xP[3]; //center of the cell real yF[3]; //center of the face real nF[3]; //normal to the face diff --git a/Examples/Octree/CMakeLists.txt b/Examples/Octree/CMakeLists.txt index 941eda5..4af4dce 100644 --- a/Examples/Octree/CMakeLists.txt +++ b/Examples/Octree/CMakeLists.txt @@ -48,6 +48,7 @@ if(OPENGL_FOUND) endif(GLUT_FOUND) else(OPENGL_FOUND) message("OpenGL not found for ${vtarget}") + endif(OPENGL_FOUND) if(USE_PARTITIONER_ZOLTAN) @@ -61,4 +62,6 @@ endif() endforeach(vtarget ${TARGETS}) - +if(NOT OPENGL_FOUND) + set_target_properties(Octree PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) +endif(NOT OPENGL_FOUND) diff --git a/Source/Headers/inmost_dense.h b/Source/Headers/inmost_dense.h index 8b880ce..8c7f0d1 100644 --- a/Source/Headers/inmost_dense.h +++ b/Source/Headers/inmost_dense.h @@ -794,13 +794,20 @@ namespace INMOST /// @param pn Number of rows. /// @param pm Number of columns. Matrix(const Var * pspace, enumerator pn, enumerator pm) : space(pspace,pspace+pn*pm), n(pn), m(pm) {} - /// Construct the matrix with the provided storage. + /// Construct the matrix with the provided storage with known size. /// Could be used to wrap existing array. + /// \warning The size of the provided container is assumed to be pn*pm. /// @param pspace Storage of elements of the matrix, stored in row-wise format. /// @param pn Number of rows. /// @param pm Number of columns. /// \todo Do we need reference for pspace or just pspace? - Matrix(storage_type pspace, enumerator pn, enumerator pm) : space(pspace), n(pn), m(pm) {} + Matrix(const storage_type & pspace, enumerator pn, enumerator pm) : space(pspace), n(pn), m(pm) {} + /// Construct the matrix with the provided storage and unknown size. + /// Could be used to wrap existing array. + /// \warning Have to call Resize afterwards. + /// @param pspace Storage of elements of the matrix, stored in row-wise format. + /// \todo Do we need reference for pspace or just pspace? + Matrix(const storage_type & pspace) : space(pspace), n(0), m(0) {} /// Construct a matrix with provided sizes. /// @param pn Number of rows. /// @param pm Number of columns. @@ -928,7 +935,7 @@ namespace INMOST /// @param size Size of the input array. /// @param matsize Size of the final tensor. /// @return Matrix of the tensor of size matsize by matsize. - static Matrix FromTensor(Var * K, enumerator size, enumerator matsize = 3) + static Matrix FromTensor(const Var * K, enumerator size, enumerator matsize = 3) { Matrix Kc(matsize,matsize); if( matsize == 1 ) @@ -1046,7 +1053,7 @@ namespace INMOST /// @param r Array of elements of the vector. /// @param size Size of the vector. /// @return Vector with contents of the array. - static Matrix FromVector(Var * r, enumerator size) + static Matrix FromVector(const Var * r, enumerator size) { return Matrix(r,size,1); } @@ -1054,7 +1061,7 @@ namespace INMOST /// @param r Array of diagonal elements. /// @param size Size of the matrix. /// @return Matrix with diagonal defined by array, other elements are zero. - static Matrix FromDiagonal(Var * r, enumerator size) + static Matrix FromDiagonal(const Var * r, enumerator size) { Matrix ret(size,size); ret.Zero(); @@ -1065,7 +1072,7 @@ namespace INMOST /// @param r Array of diagonal elements. /// @param size Size of the matrix. /// @return Matrix with diagonal defined by inverse of array elements. - static Matrix FromDiagonalInverse(Var * r, enumerator size) + static Matrix FromDiagonalInverse(const Var * r, enumerator size) { Matrix ret(size,size); ret.Zero(); @@ -1078,7 +1085,7 @@ namespace INMOST /// and vector. For a x b equivalent is CrossProduct(a)*b. /// @param vec Array of elements representing a vector. /// @return A matrix representing cross product. - static Matrix CrossProduct(Var vec[3]) + static Matrix CrossProduct(const Var vec[3]) { // | 0 -z y | // | z 0 -x | -- 2.26.2