#pragma once #include #include #include "geometry.h" #include "sha-surface-mesh/matmesh.h" namespace da::sha { class PhysicalDomain { private: igl::FastWindingNumberBVH fwn_bvh; public: // Boundary Conditions std::vector> NBCRelBBox; std::vector> NBCBBox; std::vector NBCVal; std::vector> DBCRelBBox; std::vector> DBCBBox; std::vector DBCVal; int nNBC; std::vector> NBC; int nDBC; std::vector> DBC; bool use_Nitsche = false; // penalty coefficient for Nitsche method double penaltyNitsche = 1e10; public: MatMesh3 mesh_; Eigen::MatrixXd V1; std::vector Tri; int numV, numF; Eigen::Matrix bbox; // bounding box of physical domain Eigen::RowVector3d lenBBox; // length of bounding box in 3 dimensions public: explicit PhysicalDomain(const MatMesh3 &mesh, const std::vector> &p_NBCRelBBox, const std::vector &p_NBCVal, const std::vector> &p_DBCRelBBox, const std::vector &p_DBCVal); public: // after modification of V, update bbox, triangle and fwn_bvh void Update(); // given query Q (global coordinates), return W (their domain index) // 0: fictitious domain // 1: physical domain // domain index corresponds to the material index void GetDomainID(const Eigen::MatrixXd &Q, Eigen::VectorXi &domainID) const; // initialize boundary conditions void InitializeBoundaryConditions(); /** * Directly set boundary conditions, use Nitsche method for DBC * @param p_nNBC number of Neumann BC * @param p_NBC Neumann BC * @param p_nDBC number of Dirichlet BC * @param DBC Dirichlet BC */ void SetBoundaryConditions( int p_nNBC, const std::vector> &p_NBC, int p_nDBC, const std::vector> &DBC, double p_penaltyNitsche); // debug void WriteNBCToVtk(const fs_path &path); void WriteDBCToObj(const fs_path &path); void WriteV1MeshToObj(const fs_path &path); }; } // namespace da::sha