void testPointLocatorTree() { UniquePtr<PointLocatorBase> locator = _mesh->sub_point_locator(); Point top_point(0.5, 0.5); const Elem* top_elem = (*locator)(top_point); CPPUNIT_ASSERT(top_elem); // We should have gotten back the top quad CPPUNIT_ASSERT_EQUAL( (dof_id_type)0, top_elem->id() ); Point bottom_point(0.5, -0.5); const Elem* bottom_elem = (*locator)(bottom_point); CPPUNIT_ASSERT(bottom_elem); // We should have gotten back the bottom quad CPPUNIT_ASSERT_EQUAL( (dof_id_type)1, bottom_elem->id() ); // Test getting back the edge { std::set<subdomain_id_type> subdomain_id; subdomain_id.insert(1); Point interface_point( 0.5, 0.0 ); const Elem* interface_elem = (*locator)(interface_point, &subdomain_id); CPPUNIT_ASSERT(interface_elem); // We should have gotten back the overlapping edge element CPPUNIT_ASSERT_EQUAL( (dof_id_type)2, interface_elem->id() ); } }
void build_mesh() { _mesh = new SerialMesh(*TestCommWorld); /* (0,1) (1,1) x---------------x | | | | | | | | | | x---------------x (0,0) (1,0) | | | | | | | | x---------------x (0,-1) (1,-1) */ _mesh->set_mesh_dimension(2); _mesh->add_point( Point(0.0,-1.0), 4 ); _mesh->add_point( Point(1.0,-1.0), 5 ); _mesh->add_point( Point(1.0, 0.0), 1 ); _mesh->add_point( Point(1.0, 1.0), 2 ); _mesh->add_point( Point(0.0, 1.0), 3 ); _mesh->add_point( Point(0.0, 0.0), 0 ); { Elem* elem_top = _mesh->add_elem( new Quad4 ); elem_top->set_node(0) = _mesh->node_ptr(0); elem_top->set_node(1) = _mesh->node_ptr(1); elem_top->set_node(2) = _mesh->node_ptr(2); elem_top->set_node(3) = _mesh->node_ptr(3); Elem* elem_bottom = _mesh->add_elem( new Quad4 ); elem_bottom->set_node(0) = _mesh->node_ptr(4); elem_bottom->set_node(1) = _mesh->node_ptr(5); elem_bottom->set_node(2) = _mesh->node_ptr(1); elem_bottom->set_node(3) = _mesh->node_ptr(0); } // libMesh will renumber, but we numbered according to its scheme // anyway. We do this because when we call uniformly_refine subsequenly, // it's going use skip_renumber=false. _mesh->prepare_for_use(false /*skip_renumber*/); // get a point locator _point_locator = _mesh->sub_point_locator(); }