TEST_F(LocalIds, using_entities) { if (get_parallel_size() == 1) { setup_mesh("generated:2x2x2", stk::mesh::BulkData::AUTO_AURA); BulkDataHelper bulkDataHelper(get_bulk()); typedef stk::mesh::Field<double, stk::mesh::Cartesian3d> CoordFieldType; CoordFieldType *coords = get_meta().get_field<CoordFieldType>(stk::topology::NODE_RANK, "coordinates"); unsigned elemIndex = 0; const stk::mesh::BucketVector& elemBuckets = get_bulk().buckets(stk::topology::ELEM_RANK); for(size_t i=0;i<elemBuckets.size();++i) { const stk::mesh::Bucket& bucket = *elemBuckets[i]; for(size_t j=0;j<bucket.size();++j) { Entities nodes = bulkDataHelper.get_nodes(bucket[j]); for(unsigned k=0;k<nodes.size();++k) { double *node_data = stk::mesh::field_data(*coords, nodes[k]); EXPECT_NEAR(gold_x_coordinates[elemIndex][k], node_data[0], 1.e-6); } ++elemIndex; } } } }
void test() { typedef typename viennagrid::result_of::cell_tag<MeshType>::type CellTag; typedef typename viennagrid::result_of::facet_tag<MeshType>::type FacetTag; typedef typename viennagrid::result_of::line<MeshType>::type EdgeType; MeshType mesh; setup_mesh(mesh); //SegmentType seg; //seg.add(simplex); //std::cout << "Vertices in Segment: " << seg.size<0>() << std::endl; //std::cout << "Edges in Segment: " << seg.size<1>() << std::endl; //std::cout << "Facets in Segment: " << seg.size<CellTag::dim-1>() << std::endl; //std::cout << "Cells in Segment: " << seg.size<CellTag::dim>() << std::endl; std::cout << "Printing vertices in mesh:" << std::endl; print_elements<viennagrid::vertex_tag>(mesh); std::cout << "Printing edges in mesh:" << std::endl; print_elements<viennagrid::line_tag>(mesh); std::cout << "Printing facets in mesh:" << std::endl; print_elements<FacetTag>(mesh); std::cout << "Printing cells in mesh:" << std::endl; print_elements<CellTag>(mesh); //Test for const-iterators: std::cout << "Test for const iterator: " << std::endl; typedef typename viennagrid::result_of::const_line_range<MeshType>::type EdgeContainer; EdgeContainer edges(mesh); //edges.begin()->print(); std::cout << *(edges.begin()) << std::endl; typedef typename viennagrid::result_of::const_vertex_range<EdgeType>::type VertexOnEdgeContainer; VertexOnEdgeContainer vertices_on_edge(*(edges.begin())); for (typename viennagrid::result_of::iterator<VertexOnEdgeContainer>::type voe_it = vertices_on_edge.begin(); voe_it != vertices_on_edge.end(); ++voe_it) std::cout << *voe_it << std::endl; }
TEST_F(DGTetFixture, tet) { std::vector<stk::mesh::EntityIdVector> tet_conn = { {1, 2, 3, 4}, // id 1 {2, 3, 4, 5} // id 2 }; std::vector< std::vector<double> > node_coords= { {0, 0, 0}, // 1 {1, 0, 0}, // 2 {0, 1, 0}, // 3 {0.5, 0.5, 1.0}, // 6...just kidding, it's 4 {1.0, 1.0, 1.0} }; setup_mesh(tet_conn, node_coords); stk::unit_test_util::write_mesh_using_stk_io("mike.g", get_bulk(), get_bulk().parallel()); ////////////////////////////////////////////////////////////////////////////////////// stk::mesh::EntityVector elements; stk::mesh::get_selected_entities(get_meta().locally_owned_part(), get_bulk().buckets(stk::topology::ELEM_RANK), elements); std::cerr << "num elements: " << elements.size() << std::endl; stk::mesh::create_exposed_boundary_sides(get_bulk(), get_meta().locally_owned_part(), {get_skin_part()}); unsigned num_faces = get_bulk().num_faces(elements[0]); const stk::mesh::Entity* faces = get_bulk().begin_faces(elements[0]); std::cerr << "num faces: " << num_faces << std::endl; for(unsigned i=0;i<num_faces;i++) { stk::mesh::Entity face = faces[i]; unsigned num_nodes = get_bulk().num_nodes(face); const stk::mesh::Entity* nodes = get_bulk().begin_nodes(face); for(unsigned j=0;j<num_nodes;++j) { std::cerr << "Node " << j+1 << " of face " << i+1 << " is " << get_bulk().identifier(nodes[j]) << std::endl; double *nodeCoord = static_cast<double*>(stk::mesh::field_data(*get_coord_field(), nodes[j])); std::cerr << "Has coordinates: " << nodeCoord[0] << " " << nodeCoord[1] << " " << nodeCoord[2] << std::endl; } } }
TEST_F(LocalIds, using_local_ids) { if (get_parallel_size() == 1) { setup_mesh("generated:2x2x2", stk::mesh::BulkData::AUTO_AURA); LocalIdBulkData localIdBulkData(get_bulk()); for(size_t i=0;i<localIdBulkData.num_elements();++i) { std::vector<unsigned> connectivity = localIdBulkData.get_nodes(i); for(size_t j=0;j<connectivity.size();++j) { double* node_data = localIdBulkData.get_coordinates(connectivity[j]); EXPECT_NEAR(gold_x_coordinates[i][j], node_data[0], 1.e-6); } } } }
SideIdPoolInitialIdsTest() { setup_mesh("generated:1x1x4", stk::mesh::BulkData::AUTO_AURA); sideIdPool = new SideIdPoolTester(get_bulk()); }
void test(viennagrid::quadrilateral_2d_mesh) { typedef viennagrid::quadrilateral_2d_mesh Mesh; typedef viennagrid::quadrilateral_tag CellTag; typedef viennagrid::result_of::point<Mesh>::type PointType; typedef viennagrid::result_of::element<Mesh, CellTag>::type CellType; Mesh mesh; setup_mesh(mesh); PointType A(0, 0); PointType B(1, 0); PointType C(2, 0); PointType D(3, 0); PointType E(4, 0); PointType F(0, 1); PointType G(1, 1); PointType H(3, 1); PointType I(4, 1); PointType J(0, 2); PointType K(2, 2); PointType L(5, 2); PointType M(5, 3); PointType N(0, 4); PointType O(1, 4); PointType P(4, 4); PointType Q(2, 5); PointType R(3, 5); CellType quad = viennagrid::elements<CellTag>(mesh)[0]; // // Distance checks for quadrilateral // std::cout << "Distance of point A to quadrilateral... "; fuzzy_check( viennagrid::distance(A, quad), 3.0 * std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point B to quadrilateral... "; fuzzy_check( viennagrid::distance(B, quad), std::sqrt(2.0) ); std::cout << "Distance of point C to quadrilateral... "; fuzzy_check( viennagrid::distance(C, quad), 1.0 ); std::cout << "Distance of point D to quadrilateral... "; fuzzy_check( viennagrid::distance(D, quad), std::sqrt(2.0) ); std::cout << "Distance of point E to quadrilateral... "; fuzzy_check( viennagrid::distance(E, quad), 3.0 * std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point F to quadrilateral... "; fuzzy_check( viennagrid::distance(F, quad), std::sqrt(2.0) ); std::cout << "Distance of point G to quadrilateral... "; fuzzy_check( viennagrid::distance(G, quad), std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point H to quadrilateral... "; fuzzy_check( viennagrid::distance(H, quad), std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point I to quadrilateral... "; fuzzy_check( viennagrid::distance(I, quad), std::sqrt(2.0) ); std::cout << "Distance of point J to quadrilateral... "; fuzzy_check( viennagrid::distance(J, quad), 1.0 ); std::cout << "Distance of point K to quadrilateral... "; fuzzy_check( viennagrid::distance(K, quad), 0.0 ); std::cout << "Distance of point L to quadrilateral... "; fuzzy_check( viennagrid::distance(L, quad), 2.0 ); std::cout << "Distance of point M to quadrilateral... "; fuzzy_check( viennagrid::distance(M, quad), 2.0 ); std::cout << "Distance of point N to quadrilateral... "; fuzzy_check( viennagrid::distance(N, quad), std::sqrt(5.0) ); std::cout << "Distance of point O to quadrilateral... "; fuzzy_check( viennagrid::distance(O, quad), 4.0 / std::sqrt(5.0) ); std::cout << "Distance of point P to quadrilateral... "; fuzzy_check( viennagrid::distance(P, quad), std::sqrt(2.0) ); std::cout << "Distance of point Q to quadrilateral... "; fuzzy_check( viennagrid::distance(Q, quad), std::sqrt(5.0) ); std::cout << "Distance of point R to quadrilateral... "; fuzzy_check( viennagrid::distance(quad, R), 2.0 ); }
void test(viennagrid::triangular_2d_mesh) { typedef viennagrid::triangular_2d_mesh Mesh; typedef viennagrid::triangle_tag CellTag; typedef viennagrid::result_of::point<Mesh>::type PointType; typedef viennagrid::result_of::element<Mesh, CellTag>::type CellType; Mesh mesh; setup_mesh(mesh); PointType A(0, 0); PointType B(1, 0); PointType C(2, 0); PointType D(3, 0); PointType E(4, 0); PointType F(0, 1); PointType G(1, 1); PointType H(3, 1); PointType I(4, 1); PointType J(0, 2); PointType K(2, 2); PointType L(5, 2); PointType M(5, 3); PointType N(0, 4); PointType O(1, 4); PointType P(4, 4); PointType Q(2, 5); PointType R(3, 5); CellType t0 = viennagrid::elements<CellTag>(mesh)[0]; CellType t1 = viennagrid::elements<CellTag>(mesh)[1]; // // Distance checks for t0 // std::cout << "Distance of point A to triangle t0... "; fuzzy_check( viennagrid::distance(A, t0), 3.0 * std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point B to triangle t0... "; fuzzy_check( viennagrid::distance(B, t0), std::sqrt(2.0) ); std::cout << "Distance of point C to triangle t0... "; fuzzy_check( viennagrid::distance(C, t0), 1.0 ); std::cout << "Distance of point D to triangle t0... "; fuzzy_check( viennagrid::distance(D, t0), std::sqrt(2.0) ); std::cout << "Distance of point E to triangle t0... "; fuzzy_check( viennagrid::distance(E, t0), std::sqrt(5.0) ); std::cout << "Distance of point F to triangle t0... "; fuzzy_check( viennagrid::distance(F, t0), std::sqrt(2.0) ); std::cout << "Distance of point G to triangle t0... "; fuzzy_check( viennagrid::distance(G, t0), std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point H to triangle t0... "; fuzzy_check( viennagrid::distance(H, t0), 2.0 / std::sqrt(5.0) ); std::cout << "Distance of point I to triangle t0... "; fuzzy_check( viennagrid::distance(I, t0), 4.0 / std::sqrt(5.0) ); std::cout << "Distance of point J to triangle t0... "; fuzzy_check( viennagrid::distance(J, t0), 1.0 ); std::cout << "Distance of point K to triangle t0... "; fuzzy_check( viennagrid::distance(K, t0), 0.0 ); std::cout << "Distance of point L to triangle t0... "; fuzzy_check( viennagrid::distance(L, t0), std::sqrt(5.0) ); std::cout << "Distance of point M to triangle t0... "; fuzzy_check( viennagrid::distance(M, t0), 2.0 ); std::cout << "Distance of point N to triangle t0... "; fuzzy_check( viennagrid::distance(N, t0), std::sqrt(5.0) ); std::cout << "Distance of point O to triangle t0... "; fuzzy_check( viennagrid::distance(O, t0), 4.0 / std::sqrt(5.0) ); std::cout << "Distance of point P to triangle t0... "; fuzzy_check( viennagrid::distance(P, t0), std::sqrt(2.0) ); std::cout << "Distance of point Q to triangle t0... "; fuzzy_check( viennagrid::distance(Q, t0), std::sqrt(5.0) ); std::cout << "Distance of point R to triangle t0... "; fuzzy_check( viennagrid::distance(t0, R), 2.0 ); std::cout << std::endl; // // Distance checks for t1 // std::cout << "Distance of point A to triangle t1... "; fuzzy_check( viennagrid::distance(A, t1), std::sqrt(5.0) ); std::cout << "Distance of point B to triangle t1... "; fuzzy_check( viennagrid::distance(B, t1), std::sqrt(2.0) ); std::cout << "Distance of point C to triangle t1... "; fuzzy_check( viennagrid::distance(C, t1), 1.0 ); std::cout << "Distance of point D to triangle t1... "; fuzzy_check( viennagrid::distance(D, t1), std::sqrt(2.0) ); std::cout << "Distance of point E to triangle t1... "; fuzzy_check( viennagrid::distance(E, t1), 3.0 * std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point F to triangle t1... "; fuzzy_check( viennagrid::distance(F, t1), 2.0 ); std::cout << "Distance of point G to triangle t1... "; fuzzy_check( viennagrid::distance(G, t1), 1.0 ); std::cout << "Distance of point H to triangle t1... "; fuzzy_check( viennagrid::distance(H, t1), std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point I to triangle t1... "; fuzzy_check( viennagrid::distance(I, t1), std::sqrt(2.0) ); std::cout << "Distance of point J to triangle t1... "; fuzzy_check( viennagrid::distance(J, t1), std::sqrt(5.0) ); std::cout << "Distance of point K to triangle t1... "; fuzzy_check( viennagrid::distance(K, t1), 0.5 / std::sqrt(1.25) ); std::cout << "Distance of point L to triangle t1... "; fuzzy_check( viennagrid::distance(L, t1), 2.0 ); std::cout << "Distance of point M to triangle t1... "; fuzzy_check( viennagrid::distance(M, t1), 2.0 ); std::cout << "Distance of point N to triangle t1... "; double s = ( std::sqrt(5.0) + std::sqrt(10.0) + std::sqrt(13.0) ) / 2.0; //semiperimeter fuzzy_check( viennagrid::distance(N, t1), std::sqrt( s * (s - std::sqrt(5.0)) * (s - std::sqrt(10.0)) * (s - std::sqrt(13.0)) ) * 2.0 / std::sqrt(5.0) ); //Heron's formula std::cout << "Distance of point O to triangle t1... "; fuzzy_check( viennagrid::distance(O, t1), std::sqrt(5.0) ); std::cout << "Distance of point P to triangle t1... "; fuzzy_check( viennagrid::distance(P, t1), std::sqrt(2.0) ); std::cout << "Distance of point Q to triangle t1... "; fuzzy_check( viennagrid::distance(Q, t1), std::sqrt(5.0) ); std::cout << "Distance of point R to triangle t1... "; fuzzy_check( viennagrid::distance(R, t1), 2.0 ); }
void test(viennagrid::line_2d_mesh) { typedef viennagrid::line_2d_mesh Mesh; typedef viennagrid::line_tag CellTag; typedef viennagrid::result_of::point<Mesh>::type PointType; typedef viennagrid::result_of::element<Mesh, CellTag>::type CellType; Mesh mesh; setup_mesh(mesh); PointType A(0, 0); PointType B(1, 0); PointType C(2, 0); PointType D(3, 0); PointType E(4, 0); PointType F(0, 1); PointType G(1, 1); PointType H(3, 1); PointType I(4, 1); PointType J(0, 2); PointType K(2, 2); PointType L(5, 2); PointType M(5, 3); PointType N(0, 4); PointType O(1, 4); PointType P(4, 4); PointType Q(2, 5); PointType R(3, 5); CellType line0 = viennagrid::elements<CellTag>(mesh)[0]; CellType line1 = viennagrid::elements<CellTag>(mesh)[1]; CellType line2 = viennagrid::elements<CellTag>(mesh)[2]; CellType line3 = viennagrid::elements<CellTag>(mesh)[3]; CellType line = viennagrid::elements<CellTag>(mesh)[4]; // // Distance checks for points to line // std::cout << "Distance of point A to line... "; fuzzy_check( viennagrid::distance(A, line), std::sqrt(5.0) ); std::cout << "Distance of point B to line... "; fuzzy_check( viennagrid::distance(B, line), std::sqrt(2.0) ); std::cout << "Distance of point C to line... "; fuzzy_check( viennagrid::distance(C, line), 1.0 ); std::cout << "Distance of point D to line... "; fuzzy_check( viennagrid::distance(D, line), std::sqrt(2.0) ); std::cout << "Distance of point E to line... "; fuzzy_check( viennagrid::distance(E, line), 3.0 * std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point F to line... "; fuzzy_check( viennagrid::distance(F, line), 2.0 ); std::cout << "Distance of point G to line... "; fuzzy_check( viennagrid::distance(G, line), 1.0 ); std::cout << "Distance of point H to line... "; fuzzy_check( viennagrid::distance(H, line), std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point I to line... "; fuzzy_check( viennagrid::distance(I, line), std::sqrt(2.0) ); std::cout << "Distance of point J to line... "; fuzzy_check( viennagrid::distance(J, line), std::sqrt(5.0) ); std::cout << "Distance of point K to line... "; fuzzy_check( viennagrid::distance(K, line), std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point L to line... "; fuzzy_check( viennagrid::distance(L, line), 2.0 ); std::cout << "Distance of point M to line... "; fuzzy_check( viennagrid::distance(M, line), std::sqrt(5.0) ); std::cout << "Distance of point N to line... "; fuzzy_check( viennagrid::distance(N, line), 5.0 * std::sqrt(2.0) / 2.0 ); std::cout << "Distance of point O to line... "; fuzzy_check( viennagrid::distance(O, line), 2.0 * std::sqrt(2.0) ); std::cout << "Distance of point P to line... "; fuzzy_check( viennagrid::distance(P, line), std::sqrt(5.0) ); std::cout << "Distance of point Q to line... "; fuzzy_check( viennagrid::distance(Q, line), std::sqrt(10.0) ); std::cout << "Distance of point R to line... "; fuzzy_check( viennagrid::distance(R, line), 3.0 ); // // Distance checks line to line // std::cout << "Distance of line0 to line0... "; fuzzy_check( viennagrid::distance(line0, line0), 0.0 ); std::cout << "Distance of line0 to line1... "; double s01 = ( 3.0 + std::sqrt(5.0) + std::sqrt(20.0) ) / 2.0; double dist01 = std::sqrt( s01 * (s01 - 3.0) * (s01 - std::sqrt(5.0)) * (s01 - std::sqrt(20.0)) ) * 2.0 / std::sqrt(20.0); fuzzy_check( viennagrid::distance(line0, line1), dist01 ); std::cout << "Distance of line0 to line2... "; fuzzy_check( viennagrid::distance(line0, line2), 0.0 ); std::cout << "Distance of line0 to line3... "; double s03 = ( 2.0 + std::sqrt(8.0) + std::sqrt(20.0) ) / 2.0; double dist03 = std::sqrt( s03 * (s03 - 2.0) * (s03 - std::sqrt(8.0)) * (s03 - std::sqrt(20.0)) ) * 2.0 / std::sqrt(20.0); fuzzy_check( viennagrid::distance(line0, line3), dist03 ); std::cout << "Distance of line1 to line0... "; fuzzy_check( viennagrid::distance(line1, line0), dist01 ); std::cout << "Distance of line1 to line1... "; fuzzy_check( viennagrid::distance(line1, line1), 0.0 ); std::cout << "Distance of line1 to line2... "; fuzzy_check( viennagrid::distance(line1, line2), 0.0 ); std::cout << "Distance of line1 to line3... "; fuzzy_check( viennagrid::distance(line1, line3), std::sqrt(5.0) ); std::cout << "Distance of line2 to line0... "; fuzzy_check( viennagrid::distance(line2, line0), 0.0 ); std::cout << "Distance of line2 to line1... "; fuzzy_check( viennagrid::distance(line2, line1), 0.0 ); std::cout << "Distance of line2 to line2... "; fuzzy_check( viennagrid::distance(line2, line2), 0.0 ); std::cout << "Distance of line2 to line3... "; fuzzy_check( viennagrid::distance(line2, line3), std::sqrt(2.0) / 2.0 ); std::cout << "Distance of line3 to line0... "; fuzzy_check( viennagrid::distance(line3, line0), dist03 ); std::cout << "Distance of line3 to line1... "; fuzzy_check( viennagrid::distance(line3, line1), std::sqrt(5.0) ); std::cout << "Distance of line3 to line2... "; fuzzy_check( viennagrid::distance(line3, line2), std::sqrt(2.0) / 2.0 ); std::cout << "Distance of line3 to line3... "; fuzzy_check( viennagrid::distance(line3, line3), 0.0 ); }
int main() { typedef viennagrid::line_1d_mesh MeshType; std::cout << "* main(): Creating mesh..." << std::endl; MeshType mesh; //create mesh: setup_mesh(mesh); typedef viennagrid::result_of::vertex<MeshType>::type VertexType; typedef viennagrid::result_of::line<MeshType>::type EdgeType; typedef viennagrid::result_of::cell<MeshType>::type CellType; typedef viennagrid::result_of::const_cell_handle<MeshType>::type ConstCellHandleType; std::deque<double> interface_areas; std::deque< viennagrid::result_of::voronoi_cell_contribution<ConstCellHandleType>::type > interface_contributions; std::deque<double> vertex_box_volumes; std::deque< viennagrid::result_of::voronoi_cell_contribution<ConstCellHandleType>::type > vertex_box_volume_contributions; std::deque<double> edge_box_volumes; std::deque< viennagrid::result_of::voronoi_cell_contribution<ConstCellHandleType>::type > edge_box_volume_contributions; //set up dual grid info: viennagrid::apply_voronoi<CellType>( mesh, viennagrid::make_accessor<EdgeType>(interface_areas), viennagrid::make_accessor<EdgeType>(interface_contributions), viennagrid::make_accessor<VertexType>(vertex_box_volumes), viennagrid::make_accessor<VertexType>(vertex_box_volume_contributions), viennagrid::make_accessor<EdgeType>(edge_box_volumes), viennagrid::make_accessor<EdgeType>(edge_box_volume_contributions) ); //output results: output_voronoi_info(mesh, viennagrid::make_accessor<VertexType>(vertex_box_volumes), viennagrid::make_accessor<VertexType>(vertex_box_volume_contributions), viennagrid::make_accessor<EdgeType>(interface_areas), viennagrid::make_accessor<EdgeType>(interface_contributions)); std::cout << std::endl; std::cout << viennagrid::cells(mesh)[0] << std::endl; std::cout << std::endl; std::cout << "Circumcenter of cell #0: " << viennagrid::circumcenter(viennagrid::cells(mesh)[0]) << std::endl; std::cout << "Circumcenter of cell #1: " << viennagrid::circumcenter(viennagrid::cells(mesh)[1]) << std::endl; std::cout << "Circumcenter of cell #2: " << viennagrid::circumcenter(viennagrid::cells(mesh)[2]) << std::endl; std::cout << "Circumcenter of cell #3: " << viennagrid::circumcenter(viennagrid::cells(mesh)[3]) << std::endl; std::cout << "-----------------------" << std::endl; std::cout << "Centroid of cell #0: " << viennagrid::centroid(viennagrid::cells(mesh)[0]) << std::endl; std::cout << "Centroid of cell #1: " << viennagrid::centroid(viennagrid::cells(mesh)[1]) << std::endl; std::cout << "Centroid of cell #2: " << viennagrid::centroid(viennagrid::cells(mesh)[2]) << std::endl; std::cout << "Centroid of cell #3: " << viennagrid::centroid(viennagrid::cells(mesh)[3]) << std::endl; // Check Voronoi volumes: voronoi_volume_check(mesh, viennagrid::make_accessor<VertexType>(vertex_box_volumes), viennagrid::make_accessor<VertexType>(vertex_box_volume_contributions), viennagrid::make_accessor<EdgeType>(edge_box_volume_contributions) ); //write to vtk: viennagrid::io::vtk_writer<MeshType> my_vtk_writer; my_vtk_writer(mesh, "voronoi_line"); std::cout << "*******************************" << std::endl; std::cout << "* Test finished successfully! *" << std::endl; std::cout << "*******************************" << std::endl; return EXIT_SUCCESS; }
inline void test(viennagrid::line_1d_mesh) { typedef viennagrid::line_1d_mesh Mesh; typedef viennagrid::line_tag CellTag; typedef viennagrid::result_of::point<Mesh>::type PointType; typedef viennagrid::result_of::element<Mesh, CellTag>::type CellType; Mesh mesh; setup_mesh(mesh); PointType A(0); PointType B(1.0); PointType C(1.5); PointType D(2.0); PointType E(2.5); PointType F(3.0); PointType G(3.5); PointType H(4.0); CellType line0 = viennagrid::elements<CellTag>(mesh)[0]; CellType line1 = viennagrid::elements<CellTag>(mesh)[1]; CellType line2 = viennagrid::elements<CellTag>(mesh)[2]; // // Distance checks for t0 // std::cout << "Distance of point A to line0... "; fuzzy_check( viennagrid::distance(A, line0), 2.0 ); std::cout << "Distance of point B to line0... "; fuzzy_check( viennagrid::distance(B, line0), 1.0 ); std::cout << "Distance of point C to line0... "; fuzzy_check( viennagrid::distance(C, line0), 0.5 ); std::cout << "Distance of point D to line0... "; fuzzy_check( viennagrid::distance(D, line0), 0 ); std::cout << "Distance of point E to line0... "; fuzzy_check( viennagrid::distance(E, line0), 0 ); std::cout << "Distance of point F to line0... "; fuzzy_check( viennagrid::distance(F, line0), 0 ); std::cout << "Distance of point G to line0... "; fuzzy_check( viennagrid::distance(G, line0), 0.5 ); std::cout << "Distance of point H to line0... "; fuzzy_check( viennagrid::distance(H, line0), 1.0 ); std::cout << "Distance of point H to line0... "; fuzzy_check( viennagrid::distance(H, line0), 1.0 ); std::cout << std::endl; // // Distance line to line // std::cout << "Distance of line0 to line0... "; fuzzy_check( viennagrid::distance(line0, line0), 0.0 ); std::cout << "Distance of line0 to line1... "; fuzzy_check( viennagrid::distance(line0, line1), 2.0 ); std::cout << "Distance of line0 to line2... "; fuzzy_check( viennagrid::distance(line0, line2), 0.0 ); std::cout << "Distance of line1 to line0... "; fuzzy_check( viennagrid::distance(line1, line0), 2.0 ); std::cout << "Distance of line1 to line1... "; fuzzy_check( viennagrid::distance(line1, line1), 0.0 ); std::cout << "Distance of line1 to line2... "; fuzzy_check( viennagrid::distance(line1, line2), 0.0 ); std::cout << "Distance of line1 to line0... "; fuzzy_check( viennagrid::distance(line2, line0), 0.0 ); std::cout << "Distance of line1 to line1... "; fuzzy_check( viennagrid::distance(line2, line1), 0.0 ); std::cout << "Distance of line1 to line2... "; fuzzy_check( viennagrid::distance(line2, line2), 0.0 ); }