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 only_proc_0_makes_a_face()
 {
     unsigned id = get_bulk().parallel_rank()+1;
     stk::mesh::Entity elem = get_bulk().get_entity(stk::topology::ELEM_RANK, id);
     stk::mesh::EntityVector nodes_of_face = get_nodes_of_face_for_this_proc();
     create_faces_only_one_proc(elem, nodes_of_face);
 }
 void create_faces(stk::mesh::Entity element, stk::mesh::EntityVector& nodes_of_face)
 {
     get_bulk().modification_begin();
     create_face_per_proc(element, nodes_of_face);
     test_that_num_sides_is_expected_value(2);
     get_bulk().modification_end();
 }
 void each_proc_make_face_on_proc_boundary()
 {
     unsigned id = get_bulk().parallel_rank()+1;
     stk::mesh::Entity elem = get_bulk().get_entity(stk::topology::ELEM_RANK, id);
     stk::mesh::EntityVector nodes_of_face = get_nodes_of_face_for_this_proc();
     create_faces(elem, nodes_of_face);
 }
 void create_face_per_proc(stk::mesh::Entity element, stk::mesh::EntityVector& nodes_of_face)
 {
     unsigned id = get_bulk().parallel_rank()+1;
     stk::topology side_topology = get_bulk().bucket(element).topology().side_topology();
     stk::mesh::Entity side = stk::unit_test_util::declare_element_to_sub_topology_with_nodes(get_bulk(), element, nodes_of_face, id, get_meta().side_rank(),
             get_meta().get_topology_root_part(side_topology));
     EXPECT_TRUE(get_bulk().is_valid(side));
 }
 virtual void create_faces_only_one_proc(stk::mesh::Entity element, stk::mesh::EntityVector& nodes_of_face)
 {
     get_bulk().modification_begin();
     if(get_bulk().parallel_rank()==0)
     {
         create_face_per_proc(element, nodes_of_face);
     }
     test_that_num_sides_is_expected_value(1);
     get_bulk().modification_end();
 }
 void expect_ids_are_parallel_unique(const unsigned expectedParallelSize)
 {
     size_t sizeBeforeSort = ids.size();
     stk::util::sort_and_unique(ids);
     EXPECT_EQ(sizeBeforeSort, ids.size());
     EXPECT_EQ(expectedParallelSize*get_bulk().parallel_size(), ids.size());
 }
 stk::mesh::EntityVector get_nodes_for_proc(const std::vector<unsigned>& face_node_ids)
 {
     stk::mesh::EntityVector nodes(face_node_ids.size());
     for(size_t n = 0; n < nodes.size(); ++n)
         nodes[n] = get_bulk().get_entity(stk::topology::NODE_RANK, face_node_ids[get_permuted_index(n)]);
     return nodes;
 }
 virtual unsigned get_permuted_index(unsigned i)
 {
     std::vector<std::vector<unsigned> > index_for_proc = {
             {0, 1, 2, 3},
             {3, 2, 1, 0}
     };
     return index_for_proc[get_bulk().parallel_rank()][i];
 }
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_that_num_sides_is_expected_value(size_t num_sides_gold)
 {
     std::vector<size_t> counts;
     stk::mesh::comm_mesh_counts(get_bulk(), counts);
     EXPECT_EQ(num_sides_gold, counts[get_meta().side_rank()]);
 }
 void test_that_one_face_exists_after_both_procs_create_face_on_proc_boundary()
 {
     get_bulk().initialize_face_adjacent_element_graph();
     each_proc_make_face_on_proc_boundary();
     test_that_num_sides_is_expected_value(1);
 }
 void test_that_each_proc_has_num_sides_with_expected_value(unsigned expected_num_sides)
 {
     unsigned num_local_sides = stk::mesh::count_selected_entities(get_bulk().mesh_meta_data().globally_shared_part(), get_bulk().buckets(get_bulk().mesh_meta_data().side_rank()));
     EXPECT_EQ(expected_num_sides, num_local_sides);
 }
Exemple #16
0
 int get_parallel_rank()
 {
     return get_bulk().parallel_rank();
 }