#include #include // This must be included separately. #include // Example using PolyhedronShape with realistic 3D objects. // http://e6.ijs.si/medusa/wiki/index.php/Realistic_3D_models // Needs CGAL (https://www.cgal.org/). using namespace mm; // NOLINT int main() { std::string filename = "../../test/testdata/bunny.off"; PolytopeShape bunny = PolytopeShape::fromOFF(filename); double dx = 2.5; DomainDiscretization domain = bunny.discretizeBoundaryWithStep(dx); GeneralFill fill; fill.seed(0); fill(domain, dx); int N = domain.size(); prn(N); domain.findSupport(FindClosest(25)); RBFFD, Vec3d, ScaleToClosest> approx({}, 2); auto storage = domain.template computeShapes(approx); Eigen::SparseMatrix M(N, N); Eigen::VectorXd rhs(N); rhs.setZero(); auto op = storage.implicitOperators(M, rhs); M.reserve(storage.supportSizes()); for (int i : domain.interior()) { 0.1*op.grad(i, -1) + 2.0*op.lap(i) = -1.0; } for (int i : domain.boundary()) { op.value(i) = 0.0; } Eigen::BiCGSTAB> solver; solver.preconditioner().setDroptol(1e-4); solver.preconditioner().setFillfactor(20); solver.compute(M); ScalarFieldd u = solver.solve(rhs); HDF hdf("bunny_poisson.h5", HDF::DESTROY); hdf.writeDouble2DArray("pos", domain.positions()); hdf.writeEigen("sol", u); return 0; }