Commit 7a0f27b4 by vijaysm

### Merged in vijaysm/add-eigen-support (pull request #248)

Add support for Eigen library for Dense matrix/vector algebra in MOAB
 ... ... @@ -1449,7 +1449,7 @@ bool VolMap::solve_inverse( const CartVect& x, CartVect& xi, double tol ) const det = J.determinant(); if (det < std::numeric_limits::epsilon()) return false; xi -= J.inverse(1.0/det) * delta; xi -= J.inverse() * delta; delta = evaluate( xi ) - x; } return true; ... ...
 ... ... @@ -61,7 +61,7 @@ namespace moab { } // new params tries to eliminate residual *cvparams -= J.inverse(1.0/det) * res; *cvparams -= J.inverse() * res; // get the new forward-evaluated position, and its difference from the target pt rval = (*eval)(params, verts, ndim, ... ...
 ... ... @@ -35,7 +35,7 @@ namespace moab } ErrorCode LinearTet::evalFcn(const double *params, const double *field, const int /*ndim*/, const int num_tuples, double */*work*/, double *result) { double* /*work*/, double *result) { assert(params && field && num_tuples > 0); std::vector f0(num_tuples); std::copy(field, field+num_tuples, f0.begin()); ... ... @@ -50,7 +50,7 @@ namespace moab return MB_SUCCESS; } ErrorCode LinearTet::integrateFcn(const double *field, const double */*verts*/, const int nverts, const int /*ndim*/, const int num_tuples, ErrorCode LinearTet::integrateFcn(const double *field, const double* /*verts*/, const int nverts, const int /*ndim*/, const int num_tuples, double *work, double *result) { assert(field && num_tuples > 0); ... ... @@ -122,9 +122,11 @@ namespace moab CartVect res = new_pos - *cvposn; Matrix3 J; rval = (*jacob)(cvparams->array(), verts, nverts, ndim, work, J[0]); #ifndef NDEBUG double det = J.determinant(); assert(det > std::numeric_limits::epsilon()); Matrix3 Ji = J.inverse(1.0/det); #endif Matrix3 Ji = J.inverse(); int iters=0; // while |res| larger than tol ... ...
 ... ... @@ -119,9 +119,11 @@ namespace moab CartVect res = new_pos - *cvposn; Matrix3 J; rval = (*jacob)(cvparams->array(), verts, nverts, ndim, work, J[0]); #ifndef NDEBUG double det = J.determinant(); assert(det > std::numeric_limits::epsilon()); Matrix3 Ji = J.inverse(1.0/det); #endif Matrix3 Ji = J.inverse(); int iters=0; // while |res| larger than tol ... ...
 ... ... @@ -14,6 +14,8 @@ if PARALLEL AM_CPPFLAGS += -I$(srcdir)/parallel endif include moab/EigenHeaders SUBDIRS += io LocalDiscretization verdict RefineMesh . libMOAB_la_LIBADD += io/libmoabio.la LocalDiscretization/libLocalDiscretization.la verdict/libmoabverdict.la RefineMesh/libRefineMesh.la ... ... @@ -219,6 +221,7 @@ nobase_libMOAB_la_include_HEADERS = \ moab/Util.hpp \ moab/WriteUtilIface.hpp \ moab/WriterIface.hpp \$(EIGEN_INST_HDRS) \ MBEntityType.h \ MBCN.h \ MBCN_protos.h \ ... ...
This diff is collapsed.
 ... ... @@ -361,7 +361,7 @@ static ErrorCode split_box( Interface* instance, centroid += coords[j]; centroid /= conn_len; if ((box.axis[axis] % (centroid - box.center)) < 0.0) if ((box.axis(axis) % (centroid - box.center)) < 0.0) left_list.insert( *i ); else right_list.insert( *i ); ... ... @@ -380,7 +380,7 @@ ErrorCode OrientedBoxTreeTool::build_tree( const Range& entities, ErrorCode rval; if (entities.empty()) { CartVect axis[3] = { CartVect(0.), CartVect(0.), CartVect(0.) }; Matrix3 axis; tmp_box = OrientedBox( axis, CartVect(0.) ); } else { ... ... @@ -472,7 +472,7 @@ static ErrorCode split_sets( Interface* , std::list::const_iterator i; for (i = sets.begin(); i != sets.end(); ++i) { CartVect centroid(i->box_data.center / i->box_data.area); if ((box.axis[axis] % (centroid - box.center)) < 0.0) if ((box.axis(axis) % (centroid - box.center)) < 0.0) left.push_back( *i ); else right.push_back( *i ); ... ... @@ -1879,9 +1879,9 @@ ErrorCode TreeNodePrinter::print_geometry( EntityHandle node ) outputStream << box.center << " Radius: " << box.inner_radius() << " - " << box.outer_radius() << std::endl << '+' << box.axis[0] << " : " << length[0] << std::endl << 'x' << box.axis[1] << " : " << length[1] << std::endl << 'x' << box.axis[2] << " : " << length[2] << std::endl; << '+' << box.axis(0) << " : " << length[0] << std::endl << 'x' << box.axis(1) << " : " << length[1] << std::endl << 'x' << box.axis(2) << " : " << length[2] << std::endl; return MB_SUCCESS; } ... ...
 #include #include #include "SmoothFace.hpp" #include #include #include #include #include "SmoothFace.hpp" #include "assert.h" // included in the header now // #include "Range.hpp" // #include "CartVect.hpp" // some defines from CUBIT #define GEOMETRY_RESABS 1.e-6 #define CUBIT_DBL_MAX 1.e+30 //#define DBL_EPSILON 1.e-8 #include #define mbsqr(a) ((a)*(a)) #define mbcube(a) (mbsqr(a) * (a)) #define mbquart(a) (mbsqr(a) * mbsqr(a)) namespace moab { ... ... @@ -845,19 +840,19 @@ ErrorCode SmoothFace::eval_bezier_patch(EntityHandle tri, CartVect &areacoord, ctrl_pts[4] = vN[1]; // //i=4; j=0; k=0; double B = quart(areacoord[0]); double B = mbquart(areacoord[0]); pt += B * ctrl_pts[0]; //i=3; j=1; k=0; B = 4.0 * cube(areacoord[0]) * areacoord[1]; B = 4.0 * mbcube(areacoord[0]) * areacoord[1]; pt += B * ctrl_pts[1]; //i=2; j=2; k=0; B = 6.0 * sqr(areacoord[0]) * sqr(areacoord[1]); B = 6.0 * mbsqr(areacoord[0]) * mbsqr(areacoord[1]); pt += B * ctrl_pts[2]; //i=1; j=3; k=0; B = 4.0 * areacoord[0] * cube(areacoord[1]); B = 4.0 * areacoord[0] * mbcube(areacoord[1]); pt += B * ctrl_pts[3]; //edge = facet->edge(0); ... ... @@ -869,19 +864,19 @@ ErrorCode SmoothFace::eval_bezier_patch(EntityHandle tri, CartVect &areacoord, ctrl_pts[4] = vN[2]; // //i=0; j=4; k=0; B = quart(areacoord[1]); B = mbquart(areacoord[1]); pt += B * ctrl_pts[0]; //i=0; j=3; k=1; B = 4.0 * cube(areacoord[1]) * areacoord[2]; B = 4.0 * mbcube(areacoord[1]) * areacoord[2]; pt += B * ctrl_pts[1]; //i=0; j=2; k=2; B = 6.0 * sqr(areacoord[1]) * sqr(areacoord[2]); B = 6.0 * mbsqr(areacoord[1]) * mbsqr(areacoord[2]); pt += B * ctrl_pts[2]; //i=0; j=1; k=3; B = 4.0 * areacoord[1] * cube(areacoord[2]); B = 4.0 * areacoord[1] * mbcube(areacoord[2]); pt += B * ctrl_pts[3]; //edge = facet->edge(1); ... ... @@ -893,31 +888,31 @@ ErrorCode SmoothFace::eval_bezier_patch(EntityHandle tri, CartVect &areacoord, ctrl_pts[4] = vN[0]; // //i=0; j=0; k=4; B = quart(areacoord[2]); B = mbquart(areacoord[2]); pt += B * ctrl_pts[0]; //i=1; j=0; k=3; B = 4.0 * areacoord[0] * cube(areacoord[2]); B = 4.0 * areacoord[0] * mbcube(areacoord[2]); pt += B * ctrl_pts[1]; //i=2; j=0; k=2; B = 6.0 * sqr(areacoord[0]) * sqr(areacoord[2]); B = 6.0 * mbsqr(areacoord[0]) * mbsqr(areacoord[2]); pt += B * ctrl_pts[2]; //i=3; j=0; k=1; B = 4.0 * cube(areacoord[0]) * areacoord[2]; B = 4.0 * mbcube(areacoord[0]) * areacoord[2]; pt += B * ctrl_pts[3]; //i=2; j=1; k=1; B = 12.0 * sqr(areacoord[0]) * areacoord[1] * areacoord[2]; B = 12.0 * mbsqr(areacoord[0]) * areacoord[1] * areacoord[2]; pt += B * P_facet[0]; //i=1; j=2; k=1; B = 12.0 * areacoord[0] * sqr(areacoord[1]) * areacoord[2]; B = 12.0 * areacoord[0] * mbsqr(areacoord[1]) * areacoord[2]; pt += B * P_facet[1]; //i=1; j=1; k=2; B = 12.0 * areacoord[0] * areacoord[1] * sqr(areacoord[2]); B = 12.0 * areacoord[0] * areacoord[1] * mbsqr(areacoord[2]); pt += B * P_facet[2]; return MB_SUCCESS; ... ... @@ -1001,7 +996,7 @@ void SmoothFace::facet_area_coordinate(EntityHandle facet, p[2][1], p[2][2]); if (fabs(area2) < tol) { areacoord = CartVect(-CUBIT_DBL_MAX);// .set( -CUBIT_DBL_MAX, -CUBIT_DBL_MAX, -CUBIT_DBL_MAX ); areacoord = CartVect(-std::numeric_limits::min());// .set( -std::numeric_limits::min(), -std::numeric_limits::min(), -std::numeric_limits::min() ); } else if (within_tolerance(p[0], pt_on_plane, GEOMETRY_RESABS)) { ... ... @@ -1037,7 +1032,7 @@ void SmoothFace::facet_area_coordinate(EntityHandle facet, p[2][0], p[2][2]); if (fabs(area2) < tol) { areacoord = CartVect(-CUBIT_DBL_MAX);//.set( -CUBIT_DBL_MAX, -CUBIT_DBL_MAX, -CUBIT_DBL_MAX ); areacoord = CartVect(-std::numeric_limits::min());//.set( -std::numeric_limits::min(), -std::numeric_limits::min(), -std::numeric_limits::min() ); } else if (within_tolerance(p[0], pt_on_plane, GEOMETRY_RESABS)) { ... ... @@ -1076,7 +1071,7 @@ void SmoothFace::facet_area_coordinate(EntityHandle facet, p[2][0], p[2][1]); if (fabs(area2) < tol) { areacoord = CartVect(-CUBIT_DBL_MAX);//.set( -CUBIT_DBL_MAX, -CUBIT_DBL_MAX, -CUBIT_DBL_MAX ); areacoord = CartVect(-std::numeric_limits::min());//.set( -std::numeric_limits::min(), -std::numeric_limits::min(), -std::numeric_limits::min() ); } else if (within_tolerance(p[0], pt_on_plane, GEOMETRY_RESABS)) { ... ... @@ -1874,27 +1869,27 @@ ErrorCode SmoothFace::eval_bezier_patch_normal(EntityHandle facet, //i=3; j=0; k=0; //double Bsum = 0.0; double B = cube(areacoord[0]); double B = mbcube(areacoord[0]); //Bsum += B; normal += B * Nijk[0]; //i=2; j=1; k=0; B = 3.0 * sqr(areacoord[0]) * areacoord[1]; B = 3.0 * mbsqr(areacoord[0]) * areacoord[1]; //Bsum += B; normal += B * Nijk[1]; //i=1; j=2; k=0; B = 3.0 * areacoord[0] * sqr(areacoord[1]); B = 3.0 * areacoord[0] * mbsqr(areacoord[1]); //Bsum += B; normal += B * Nijk[2]; //i=0; j=3; k=0; B = cube(areacoord[1]); B = mbcube(areacoord[1]); //Bsum += B; normal += B * Nijk[3]; //i=2; j=0; k=1; B = 3.0 * sqr(areacoord[0]) * areacoord[2]; B = 3.0 * mbsqr(areacoord[0]) * areacoord[2]; //Bsum += B; normal += B * Nijk[4]; ... ... @@ -1904,22 +1899,22 @@ ErrorCode SmoothFace::eval_bezier_patch_normal(EntityHandle facet, normal += B * Nijk[5]; //i=0; j=2; k=1; B = 3.0 * sqr(areacoord[1]) * areacoord[2]; B = 3.0 * mbsqr(areacoord[1]) * areacoord[2]; //Bsum += B; normal += B * Nijk[6]; //i=1; j=0; k=2; B = 3.0 * areacoord[0] * sqr(areacoord[2]); B = 3.0 * areacoord[0] * mbsqr(areacoord[2]); //Bsum += B; normal += B * Nijk[7]; //i=0; j=1; k=2; B = 3.0 * areacoord[1] * sqr(areacoord[2]); B = 3.0 * areacoord[1] * mbsqr(areacoord[2]); //Bsum += B; normal += B * Nijk[8]; //i=0; j=0; k=3; B = cube(areacoord[2]); B = mbcube(areacoord[2]); //Bsum += B; normal += B * Nijk[9]; ... ...
 #ifndef SMOOTH_FACE_EVAL_HPP #define SMOOTH_FACE_EVAL_HPP // do we really need iMesh here; maybe go directly to MOAB //#include "iMesh.h" #include "moab/Interface.hpp" #include "moab/Range.hpp" #include "moab/CartVect.hpp" #include "MBTagConventions.hpp" #include "moab/Types.hpp" #define determ3(p1,q1,p2,q2,p3,q3) ((q3)*((p2)-(p1)) + (q2)*((p1)-(p3)) + (q1)*((p3)-(p2))) #define sqr(a) ((a)*(a)) #define cube(a) (sqr(a) * (a)) #define quart(a) (sqr(a) * sqr(a)) #define blend(x) (-2.0*(x)*(x)*(x) + 3.0*(x)*(x)) #include #include #include //#include "MBEntityHandle.hpp" #define determ3(p1,q1,p2,q2,p3,q3) ((q3)*((p2)-(p1)) + (q2)*((p1)-(p3)) + (q1)*((p3)-(p2))) #define blend(x) (-2.0*(x)*(x)*(x) + 3.0*(x)*(x)) // work only with CAMAL > = 500 // #if CAMAL_VERSION < 500 // #else #include "moab/GeomTopoTool.hpp" ... ...
 include(RegexUtils) test_escape_string_as_regex() file(GLOB Eigen_directory_files "*") escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") foreach(f${Eigen_directory_files}) if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") list(APPEND Eigen_directory_files_to_install ${f}) endif() endforeach(f${Eigen_directory_files}) install(FILES ${Eigen_directory_files_to_install} DESTINATION${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel ) add_subdirectory(src)
 // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_CHOLESKY_MODULE_H #define EIGEN_CHOLESKY_MODULE_H #include "Core" #include "src/Core/util/DisableStupidWarnings.h" /** \defgroup Cholesky_Module Cholesky module * * * * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. * Those decompositions are also accessible via the following methods: * - MatrixBase::llt() * - MatrixBase::ldlt() * - SelfAdjointView::llt() * - SelfAdjointView::ldlt() * * \code * #include * \endcode */ #include "src/Cholesky/LLT.h" #include "src/Cholesky/LDLT.h" #ifdef EIGEN_USE_LAPACKE #include "src/Cholesky/LLT_MKL.h" #endif #include "src/Core/util/ReenableStupidWarnings.h" #endif // EIGEN_CHOLESKY_MODULE_H /* vim: set filetype=cpp et sw=2 ts=2 ai: */
 // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H #define EIGEN_CHOLMODSUPPORT_MODULE_H #include "SparseCore" #include "src/Core/util/DisableStupidWarnings.h" extern "C" { #include } /** \ingroup Support_modules * \defgroup CholmodSupport_Module CholmodSupport module * * This module provides an interface to the Cholmod library which is part of the suitesparse package. * It provides the two following main factorization classes: * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). * * For the sake of completeness, this module also propose the two following classes: * - class CholmodSimplicialLLT * - class CholmodSimplicialLDLT * Note that these classes does not bring any particular advantage compared to the built-in * SimplicialLLT and SimplicialLDLT factorization classes. * * \code * #include * \endcode * * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. * The dependencies depend on how cholmod has been compiled. * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. * */ #include "src/CholmodSupport/CholmodSupport.h" #include "src/Core/util/ReenableStupidWarnings.h" #endif // EIGEN_CHOLMODSUPPORT_MODULE_H
This diff is collapsed.
 #include "Core" #include "LU" #include "Cholesky" #include "QR" #include "SVD" #include "Geometry" #include "Eigenvalues"
 #include "Dense" #include "Sparse"
 // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_EIGENVALUES_MODULE_H #define EIGEN_EIGENVALUES_MODULE_H #include "Core" #include "src/Core/util/DisableStupidWarnings.h" #include "Cholesky" #include "Jacobi" #include "Householder" #include "LU" #include "Geometry" /** \defgroup Eigenvalues_Module Eigenvalues module * * * * This module mainly provides various eigenvalue solvers. * This module also provides some MatrixBase methods, including: * - MatrixBase::eigenvalues(), * - MatrixBase::operatorNorm() * * \code * #include * \endcode */ #include "src/Eigenvalues/Tridiagonalization.h" #include "src/Eigenvalues/RealSchur.h" #include "src/Eigenvalues/EigenSolver.h" #include "src/Eigenvalues/SelfAdjointEigenSolver.h" #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" #include "src/Eigenvalues/HessenbergDecomposition.h" #include "src/Eigenvalues/ComplexSchur.h" #include "src/Eigenvalues/ComplexEigenSolver.h" #include "src/Eigenvalues/RealQZ.h" #include "src/Eigenvalues/GeneralizedEigenSolver.h" #include "src/Eigenvalues/MatrixBaseEigenvalues.h" #ifdef EIGEN_USE_LAPACKE #include "src/Eigenvalues/RealSchur_MKL.h" #include "src/Eigenvalues/ComplexSchur_MKL.h" #include "src/Eigenvalues/SelfAdjointEigenSolver_MKL.h" #endif #include "src/Core/util/ReenableStupidWarnings.h" #endif // EIGEN_EIGENVALUES_MODULE_H /* vim: set filetype=cpp et sw=2 ts=2 ai: */