| 1 |
#include <stk_mesh/base/GetEntities.hpp> |
| 2 |
#include <stk_unit_test_utils/unittestMeshUtils.hpp> |
| 3 |
#include <stk_mesh/base/Comm.hpp> |
| 4 |
#include <stk_mesh/base/FEMHelpers.hpp> |
| 5 |
#include <stk_unit_test_utils/BulkDataTester.hpp> |
| 6 |
#include "../FaceCreatorFixture.hpp" |
| 7 |
#include <stk_mesh/baseImpl/elementGraph/ElemElemGraph.hpp> |
| 8 |
|
| 9 |
namespace |
| 10 |
{ |
| 11 |
|
| 12 |
class UnitTestFaceSharingUsingGraph : public FaceCreatorFixture |
| 13 |
{ |
| 14 |
protected: |
| 15 |
virtual void test_that_one_face_exists_on_both_procs_after_only_one_proc_makes_face() |
| 16 |
{ |
| 17 |
only_proc_0_makes_a_face(); |
| 18 |
test_that_num_sides_is_expected_value(1); |
| 19 |
unsigned num_faces_this_proc = stk::mesh::count_selected_entities(get_meta().locally_owned_part(), get_bulk().buckets(get_meta().side_rank())); |
| 20 |
test_that_num_sides_is_correct(num_faces_this_proc); |
| 21 |
} |
| 22 |
|
| 23 |
virtual void create_faces_only_one_proc(stk::mesh::Entity element, stk::mesh::EntityVector& nodes_of_face) |
| 24 |
{ |
| 25 |
get_bulk().modification_begin(); |
| 26 |
if(get_bulk().parallel_rank()==0) |
| 27 |
{ |
| 28 |
create_face_per_proc(element, nodes_of_face); |
| 29 |
} |
| 30 |
test_that_num_sides_is_expected_value(1); |
| 31 |
|
| 32 |
get_bulk().modification_end(); |
| 33 |
} |
| 34 |
|
| 35 |
int get_proc_rank() |
| 36 |
{ |
| 37 |
return get_bulk().parallel_rank(); |
| 38 |
} |
| 39 |
|
| 40 |
void test_that_num_sides_is_correct(unsigned num_faces_this_proc) |
| 41 |
{ |
| 42 |
std::vector<unsigned> gold_num_faces_per_proc={1,0}; |
| 43 |
EXPECT_EQ(gold_num_faces_per_proc[get_proc_rank()], num_faces_this_proc); |
| 44 |
} |
| 45 |
|
| 46 |
void run(stk::mesh::BulkData::AutomaticAuraOption auraOption) |
| 47 |
{ |
| 48 |
setup_mesh("generated:1x1x2", auraOption); |
| 49 |
test_that_one_face_exists_on_both_procs_after_only_one_proc_makes_face(); |
| 50 |
|
| 51 |
stk::mesh::EntityVector sides; |
| 52 |
stk::mesh::get_selected_entities(get_meta().globally_shared_part(), get_bulk().buckets(get_meta().side_rank()), sides); |
| 53 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(get_meta().globally_shared_part(), get_bulk().buckets(stk::topology::NODE_RANK))); |
| 54 |
ASSERT_EQ(1u, sides.size()); |
| 55 |
ASSERT_EQ(4u, get_bulk().num_nodes(sides[0])); |
| 56 |
const stk::mesh::Entity *nodes = get_bulk().begin_nodes(sides[0]); |
| 57 |
EXPECT_EQ(5u, get_bulk().identifier(nodes[0])); |
| 58 |
EXPECT_EQ(6u, get_bulk().identifier(nodes[1])); |
| 59 |
EXPECT_EQ(8u, get_bulk().identifier(nodes[2])); |
| 60 |
EXPECT_EQ(7u, get_bulk().identifier(nodes[3])); |
| 61 |
} |
| 62 |
}; |
| 63 |
|
| 64 |
/////////////////////////////////////////////////////////////////// |
| 65 |
|
| 66 |
TEST_F(UnitTestFaceSharingUsingGraph, twoHexesTwoProcsCreateOneFaceWithAura) |
| 67 |
{ |
| 68 |
if(stk::parallel_machine_size(get_comm())==2) |
| 69 |
run(stk::mesh::BulkData::AUTO_AURA); |
| 70 |
} |
| 71 |
|
| 72 |
TEST_F(UnitTestFaceSharingUsingGraph, twoHexesTwoProcsCreateOneFaceWithoutAura) |
| 73 |
{ |
| 74 |
if(stk::parallel_machine_size(get_comm())==2) |
| 75 |
run(stk::mesh::BulkData::NO_AUTO_AURA); |
| 76 |
} |
| 77 |
|
| 78 |
} |