TEST(Mesh, HigherOrderLine1)
{
    UnstructuredMesh* msh = createLineElement(GeoLib::Point(0,0,0), GeoLib::Point(1,0,0), CoordinateSystemType::X);
    std::vector<IElement*> vec_edge;
    createEdgeElements(msh);
    ASSERT_EQ(1u, msh->getNumberOfEdges());
    MeshGenerator::generateHigherOrderUnstrucuredMesh(*msh, 2);

    IElement* e = 0;
    ASSERT_EQ(2u, msh->getNumberOfNodes(1));
    ASSERT_EQ(3u, msh->getNumberOfNodes(2));
    msh->setCurrentOrder(1);
    e = msh->getElement(0);
    ASSERT_EQ(2u, msh->getNumberOfNodes(1));
    ASSERT_EQ(2u, e->getNumberOfNodes());
    msh->setCurrentOrder(2);
    e = msh->getElement(0);
    ASSERT_EQ(3u, msh->getNumberOfNodes(2));
    ASSERT_EQ(3u, e->getNumberOfNodes());

    e->setCurrentOrder(1);
    ASSERT_EQ(2u, e->getNumberOfNodes());
    e->setCurrentOrder(2);
    ASSERT_EQ(3u, e->getNumberOfNodes());

    const GeoLib::Point* p = msh->getNodeCoordinatesRef(2);
    ASSERT_DOUBLE_EQ(0.5, (*p)[0]);
    ASSERT_DOUBLE_EQ(0., (*p)[1]);
    ASSERT_DOUBLE_EQ(0., (*p)[2]);

}
예제 #2
0
double calculateMeshMinimumEdgeLength(UnstructuredMesh &msh)
{
    std::vector<size_t> vec_edge_nodes;
    double min_edge_len = std::numeric_limits<double>::max();
    const size_t n_ele = msh.getNumberOfElements();
    for (size_t i=0; i<n_ele; i++) {
        MeshLib::IElement* e = msh.getElement(i);
        for (size_t j=0; j<e->getNumberOfEdges(); j++) {
            e->getNodeIDsOfEdges(j, vec_edge_nodes);
            assert (vec_edge_nodes.size() == 2);

            double edge_len = std::sqrt(GeoLib::sqrDist(msh.getNodeCoordinatesRef(vec_edge_nodes[0]), msh.getNodeCoordinatesRef(vec_edge_nodes[1])));
            min_edge_len = std::min(min_edge_len, edge_len);
        }
    }

    return min_edge_len;
}