cr_vector_mass.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2020 Oded Stein <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_CR_VECTOR_MASS
  9. #define IGL_CR_VECTOR_MASS
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. /// Computes the CR vector mass matrix, using an arrangement of all parallel
  16. /// degrees of freedom first, and all perpendicular degrees of freedom next.
  17. /// See Oded Stein, Max Wardetzky, Alec Jacobson, Eitan Grinspun, 2020.
  18. /// "A Simple Discretization of the Vector Dirichlet Energy"
  19. ///
  20. /// @param[in] V #V by 3 list of mesh vertex positions
  21. /// @param[in] F #F by 3 list of mesh face indices into rows of V
  22. /// @param[in] E #F by 3 a mapping from each halfedge to each edge
  23. /// @param[in] oE #F by 3 the orientation (e.g., -1 or 1) of each halfedge
  24. /// compared to the orientation of the actual edge, as computed with
  25. /// orient_halfedges. will be computed if not provided.
  26. /// @param[out] L 2*|HE| by 2*|HE| computed Mass matrix
  27. template <typename DerivedV, typename DerivedF, typename DerivedE,
  28. typename DerivedOE, typename ScalarM>
  29. IGL_INLINE void
  30. cr_vector_mass(
  31. const Eigen::MatrixBase<DerivedV>& V,
  32. const Eigen::MatrixBase<DerivedF>& F,
  33. const Eigen::MatrixBase<DerivedE>& E,
  34. const Eigen::MatrixBase<DerivedOE>& oE,
  35. Eigen::SparseMatrix<ScalarM>& M);
  36. /// \overload
  37. ///
  38. /// \brief `E` and `oE` are computed and output.
  39. template <typename DerivedV, typename DerivedF, typename DerivedE,
  40. typename DerivedOE, typename ScalarM>
  41. IGL_INLINE void
  42. cr_vector_mass(
  43. const Eigen::MatrixBase<DerivedV>& V,
  44. const Eigen::MatrixBase<DerivedF>& F,
  45. Eigen::PlainObjectBase<DerivedE>& E,
  46. Eigen::PlainObjectBase<DerivedOE>& oE,
  47. Eigen::SparseMatrix<ScalarM>& M);
  48. /// \overload
  49. /// \brief intrinsic version.
  50. ///
  51. /// @param[in] l_sq #F by 3 list of squared edge lengths of each halfedge
  52. /// @param[in] dA #F list of double areas
  53. ///
  54. /// \fileinfo
  55. template <typename DerivedF, typename DerivedL_sq, typename DeriveddA,
  56. typename DerivedE, typename DerivedOE, typename ScalarM>
  57. IGL_INLINE void
  58. cr_vector_mass_intrinsic(
  59. const Eigen::MatrixBase<DerivedF>& F,
  60. const Eigen::MatrixBase<DerivedL_sq>& l_sq,
  61. const Eigen::MatrixBase<DeriveddA>& dA,
  62. const Eigen::MatrixBase<DerivedE>& E,
  63. const Eigen::MatrixBase<DerivedOE>& oE,
  64. Eigen::SparseMatrix<ScalarM>& M);
  65. /// \overload
  66. /// \fileinfo
  67. template <typename DerivedF, typename DerivedL_sq, typename DerivedE,
  68. typename DerivedOE, typename ScalarM>
  69. IGL_INLINE void
  70. cr_vector_mass_intrinsic(
  71. const Eigen::MatrixBase<DerivedF>& F,
  72. const Eigen::MatrixBase<DerivedL_sq>& l_sq,
  73. const Eigen::MatrixBase<DerivedE>& E,
  74. const Eigen::MatrixBase<DerivedOE>& oE,
  75. Eigen::SparseMatrix<ScalarM>& M);
  76. }
  77. #ifndef IGL_STATIC_LIBRARY
  78. # include "cr_vector_mass.cpp"
  79. #endif
  80. #endif