crouzeix_raviart_massmatrix.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
  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 CROUZEIX_RAVIART_MASSMATRIX_H
  9. #define CROUZEIX_RAVIART_MASSMATRIX_H
  10. #include <Eigen/Dense>
  11. #include <Eigen/Sparse>
  12. namespace igl
  13. {
  14. // CROUZEIX_RAVIART_MASSMATRIX Compute the Crouzeix-Raviart mass matrix where
  15. // M(e,e) is just the sum of the areas of the triangles on either side of an
  16. // edge e.
  17. //
  18. // See for example "Discrete Quadratic Curvature Energies" [Wardetzky, Bergou,
  19. // Harmon, Zorin, Grinspun 2007]
  20. //
  21. // Templates:
  22. // MT type of eigen sparse matrix for M (e.g. double for
  23. // SparseMatrix<double>)
  24. // DerivedV derived type of eigen matrix for V (e.g. derived from
  25. // MatrixXd)
  26. // DerivedF derived type of eigen matrix for F (e.g. derived from
  27. // MatrixXi)
  28. // DerivedE derived type of eigen matrix for E (e.g. derived from
  29. // MatrixXi)
  30. // Inputs:
  31. // V #V by dim list of vertex positions
  32. // F #F by 3 list of triangle indices
  33. // Outputs:
  34. // M #E by #E edge-based diagonal mass matrix
  35. // E #E by 2 list of edges
  36. // EMAP #F*3 list of indices mapping allE to E
  37. //
  38. //
  39. template <typename MT, typename DerivedV, typename DerivedF, typename DerivedE, typename DerivedEMAP>
  40. void crouzeix_raviart_massmatrix(
  41. const Eigen::PlainObjectBase<DerivedV> & V,
  42. const Eigen::PlainObjectBase<DerivedF> & F,
  43. Eigen::SparseMatrix<MT> & M,
  44. Eigen::PlainObjectBase<DerivedE> & E,
  45. Eigen::PlainObjectBase<DerivedEMAP> & EMAP);
  46. // wrapper if E and EMAP are already computed (better match!)
  47. template <typename MT, typename DerivedV, typename DerivedF, typename DerivedE, typename DerivedEMAP>
  48. void crouzeix_raviart_massmatrix(
  49. const Eigen::PlainObjectBase<DerivedV> & V,
  50. const Eigen::PlainObjectBase<DerivedF> & F,
  51. const Eigen::PlainObjectBase<DerivedE> & E,
  52. const Eigen::PlainObjectBase<DerivedEMAP> & EMAP,
  53. Eigen::SparseMatrix<MT> & M);
  54. }
  55. #ifndef IGL_STATIC_LIBRARY
  56. # include "crouzeix_raviart_massmatrix.cpp"
  57. #endif
  58. #endif