BoundaryElementsAtPoint::BoundaryElementsAtPoint( MeshLib::Mesh const &mesh, MeshNodeSearcher &mshNodeSearcher, GeoLib::Point const &point) : _mesh(mesh), _point(point) { auto const node_ids = mshNodeSearcher.getMeshNodeIDs(_point); assert(node_ids.size() == 1); std::array<MeshLib::Node*, 1> const nodes = {{ const_cast<MeshLib::Node*>(_mesh.getNode(node_ids[0]))}}; _boundary_elements.push_back(new MeshLib::Point{nodes, node_ids[0]}); }
BoundaryElementsAlongPolyline::BoundaryElementsAlongPolyline( MeshLib::Mesh const& mesh, MeshNodeSearcher const& mshNodeSearcher, GeoLib::Polyline const& ply) : _mesh(mesh), _ply(ply) { // search nodes and elements located along the polyline auto node_ids_on_poly = mshNodeSearcher.getMeshNodeIDsAlongPolyline(ply); MeshLib::ElementSearch es(_mesh); es.searchByNodeIDs(node_ids_on_poly); auto &ele_ids_near_ply = es.getSearchedElementIDs(); // check all edges of the elements near the polyline for (auto ele_id : ele_ids_near_ply) { auto* e = _mesh.getElement(ele_id); // skip line elements if (e->getDimension() == 1) continue; // skip internal elements if (!e->isBoundaryElement()) continue; // find edges on the polyline for (unsigned i=0; i<e->getNumberOfEdges(); i++) { auto* edge = e->getEdge(i); // check if all edge nodes are along the polyline (if yes, store a distance) std::vector<std::size_t> edge_node_distances_along_ply; if (includesAllEdgeNodeIDs(node_ids_on_poly, *edge, edge_node_distances_along_ply)) { auto* new_edge = modifyEdgeNodeOrdering(*edge, ply, edge_node_distances_along_ply, node_ids_on_poly); if (edge != new_edge) delete edge; _boundary_elements.push_back(new_edge); } else { delete edge; } } } // sort picked edges according to a distance of their first node along the polyline std::sort(_boundary_elements.begin(), _boundary_elements.end(), [&](MeshLib::Element*e1, MeshLib::Element*e2) { std::size_t dist1 = std::distance(node_ids_on_poly.begin(), std::find(node_ids_on_poly.begin(), node_ids_on_poly.end(), e1->getNodeIndex(0))); std::size_t dist2 = std::distance(node_ids_on_poly.begin(), std::find(node_ids_on_poly.begin(), node_ids_on_poly.end(), e2->getNodeIndex(0))); return (dist1 < dist2); }); }
BoundaryElementsOnSurface::BoundaryElementsOnSurface( MeshLib::Mesh const& mesh, MeshNodeSearcher const& mshNodeSearcher, GeoLib::Surface const& sfc) : _mesh(mesh), _sfc(sfc) { // search elements near the surface auto node_ids_on_sfc = mshNodeSearcher.getMeshNodeIDsAlongSurface(sfc); MeshLib::ElementSearch es(_mesh); es.searchByNodeIDs(node_ids_on_sfc); auto &ele_ids_near_sfc = es.getSearchedElementIDs(); // get a list of faces made of the nodes for (auto ele_id : ele_ids_near_sfc) { auto* e = _mesh.getElement(ele_id); // skip internal elements if (!e->isBoundaryElement()) continue; // find faces on surface for (unsigned i=0; i<e->getNumberOfFaces(); i++) { auto* face = e->getFace(i); // check std::size_t cnt_match = 0; for (std::size_t j=0; j<face->getNumberOfBaseNodes(); j++) { if (std::find(node_ids_on_sfc.begin(), node_ids_on_sfc.end(), face->getNodeIndex(j)) != node_ids_on_sfc.end()) cnt_match++; else break; } // update the list if (cnt_match==face->getNumberOfBaseNodes()) { _boundary_elements.push_back(const_cast<MeshLib::Element*>(face)); } else delete face; } } }
BoundaryElementsAtPoint::BoundaryElementsAtPoint( MeshLib::Mesh const& mesh, MeshNodeSearcher const& mshNodeSearcher, GeoLib::Point const& point) : _mesh(mesh), _point(point) { auto const node_ids = mshNodeSearcher.getMeshNodeIDs(_point); if (node_ids.empty()) OGS_FATAL( "BoundaryElementsAtPoint: the mesh node searcher was unable to " "locate the point (%f, %f, %f) in the mesh.", _point[0], _point[1], _point[2]); if (node_ids.size() > 1) OGS_FATAL( "BoundaryElementsAtPoint: the mesh node searcher found %d points " "near the requested point (%f, %f, %f) in the mesh, while exactly " "one is expected.", node_ids.size(), _point[0], _point[1], _point[2]); std::array<MeshLib::Node*, 1> const nodes = {{ const_cast<MeshLib::Node*>(_mesh.getNode(node_ids[0]))}}; _boundary_elements.push_back(new MeshLib::Point{nodes, node_ids[0]}); }