|
@@ -7,25 +7,26 @@
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
#include "crouzeix_raviart_massmatrix.h"
|
|
#include "crouzeix_raviart_massmatrix.h"
|
|
#include "unique_simplices.h"
|
|
#include "unique_simplices.h"
|
|
-#include "all_edges.h"
|
|
|
|
|
|
+#include "oriented_facets.h"
|
|
|
|
|
|
#include "is_edge_manifold.h"
|
|
#include "is_edge_manifold.h"
|
|
#include "doublearea.h"
|
|
#include "doublearea.h"
|
|
|
|
+#include "volume.h"
|
|
|
|
|
|
#include <cassert>
|
|
#include <cassert>
|
|
#include <vector>
|
|
#include <vector>
|
|
|
|
|
|
template <typename MT, typename DerivedV, typename DerivedF, typename DerivedE, typename DerivedEMAP>
|
|
template <typename MT, typename DerivedV, typename DerivedF, typename DerivedE, typename DerivedEMAP>
|
|
void igl::crouzeix_raviart_massmatrix(
|
|
void igl::crouzeix_raviart_massmatrix(
|
|
- const Eigen::PlainObjectBase<DerivedV> & V,
|
|
|
|
- const Eigen::PlainObjectBase<DerivedF> & F,
|
|
|
|
|
|
+ const Eigen::MatrixBase<DerivedV> & V,
|
|
|
|
+ const Eigen::MatrixBase<DerivedF> & F,
|
|
Eigen::SparseMatrix<MT> & M,
|
|
Eigen::SparseMatrix<MT> & M,
|
|
Eigen::PlainObjectBase<DerivedE> & E,
|
|
Eigen::PlainObjectBase<DerivedE> & E,
|
|
Eigen::PlainObjectBase<DerivedEMAP> & EMAP)
|
|
Eigen::PlainObjectBase<DerivedEMAP> & EMAP)
|
|
{
|
|
{
|
|
- // All occurances of directed edges
|
|
|
|
|
|
+ // All occurances of directed "facets"
|
|
Eigen::MatrixXi allE;
|
|
Eigen::MatrixXi allE;
|
|
- all_edges(F,allE);
|
|
|
|
|
|
+ oriented_facets(F,allE);
|
|
Eigen::VectorXi _1;
|
|
Eigen::VectorXi _1;
|
|
unique_simplices(allE,E,_1,EMAP);
|
|
unique_simplices(allE,E,_1,EMAP);
|
|
return crouzeix_raviart_massmatrix(V,F,E,EMAP,M);
|
|
return crouzeix_raviart_massmatrix(V,F,E,EMAP,M);
|
|
@@ -33,28 +34,42 @@ void igl::crouzeix_raviart_massmatrix(
|
|
|
|
|
|
template <typename MT, typename DerivedV, typename DerivedF, typename DerivedE, typename DerivedEMAP>
|
|
template <typename MT, typename DerivedV, typename DerivedF, typename DerivedE, typename DerivedEMAP>
|
|
void igl::crouzeix_raviart_massmatrix(
|
|
void igl::crouzeix_raviart_massmatrix(
|
|
- const Eigen::PlainObjectBase<DerivedV> & V,
|
|
|
|
- const Eigen::PlainObjectBase<DerivedF> & F,
|
|
|
|
- const Eigen::PlainObjectBase<DerivedE> & E,
|
|
|
|
- const Eigen::PlainObjectBase<DerivedEMAP> & EMAP,
|
|
|
|
|
|
+ const Eigen::MatrixBase<DerivedV> & V,
|
|
|
|
+ const Eigen::MatrixBase<DerivedF> & F,
|
|
|
|
+ const Eigen::MatrixBase<DerivedE> & E,
|
|
|
|
+ const Eigen::MatrixBase<DerivedEMAP> & EMAP,
|
|
Eigen::SparseMatrix<MT> & M)
|
|
Eigen::SparseMatrix<MT> & M)
|
|
{
|
|
{
|
|
using namespace Eigen;
|
|
using namespace Eigen;
|
|
using namespace std;
|
|
using namespace std;
|
|
- assert(F.cols() == 3);
|
|
|
|
- // Mesh should be edge-manifold
|
|
|
|
- assert(is_edge_manifold(F));
|
|
|
|
|
|
+ // Mesh should be edge-manifold (TODO: replace `is_edge_manifold` with
|
|
|
|
+ // `is_facet_manifold`)
|
|
|
|
+ assert(F.cols() != 3 || is_edge_manifold(F));
|
|
// number of elements (triangles)
|
|
// number of elements (triangles)
|
|
- int m = F.rows();
|
|
|
|
- // Get triangle areas
|
|
|
|
|
|
+ const int m = F.rows();
|
|
|
|
+ // Get triangle areas/volumes
|
|
VectorXd TA;
|
|
VectorXd TA;
|
|
- doublearea(V,F,TA);
|
|
|
|
- vector<Triplet<MT> > MIJV(3*m);
|
|
|
|
|
|
+ // Element simplex size
|
|
|
|
+ const int ss = F.cols();
|
|
|
|
+ switch(ss)
|
|
|
|
+ {
|
|
|
|
+ default:
|
|
|
|
+ assert(false && "Unsupported simplex size");
|
|
|
|
+ case 3:
|
|
|
|
+ doublearea(V,F,TA);
|
|
|
|
+ TA *= 0.5;
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ volume(V,F,TA);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ vector<Triplet<MT> > MIJV(ss*m);
|
|
|
|
+ assert(EMAP.size() == m*ss);
|
|
for(int f = 0;f<m;f++)
|
|
for(int f = 0;f<m;f++)
|
|
{
|
|
{
|
|
- for(int c = 0;c<3;c++)
|
|
|
|
|
|
+ for(int c = 0;c<ss;c++)
|
|
{
|
|
{
|
|
- MIJV[f+m*c] = Triplet<MT>(EMAP(f+m*c),EMAP(f+m*c),TA(f)*0.5);
|
|
|
|
|
|
+ MIJV[f+m*c] = Triplet<MT>(EMAP(f+m*c),EMAP(f+m*c),TA(f)/(double)(ss));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
M.resize(E.rows(),E.rows());
|
|
M.resize(E.rows(),E.rows());
|
|
@@ -63,6 +78,8 @@ void igl::crouzeix_raviart_massmatrix(
|
|
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
// Explicit template instantiation
|
|
// Explicit template instantiation
|
|
-template void igl::crouzeix_raviart_massmatrix<double, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<double, 0, int>&);
|
|
|
|
-template void igl::crouzeix_raviart_massmatrix<float, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<float, 0, int>&);
|
|
|
|
|
|
+// generated by autoexplicit.sh
|
|
|
|
+template void igl::crouzeix_raviart_massmatrix<double, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
|
|
|
+template void igl::crouzeix_raviart_massmatrix<double, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<double, 0, int>&);
|
|
|
|
+template void igl::crouzeix_raviart_massmatrix<float, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<float, 0, int>&);
|
|
#endif
|
|
#endif
|