13 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
15 #include <stk_util/parallel/Parallel.hpp>
17 #include <stk_mesh/base/BulkData.hpp>
18 #include <stk_mesh/base/GetEntities.hpp>
19 #include <stk_mesh/base/EntityComm.hpp>
20 #include <stk_mesh/base/Comm.hpp>
22 #include <stk_mesh/fixtures/BoxFixture.hpp>
23 #include <stk_mesh/fixtures/RingFixture.hpp>
25 #include <unit_tests/UnitTestModificationEndWrapper.hpp>
26 #include <unit_tests/UnitTestRingFixture.hpp>
37 using stk_classic::mesh::BaseEntityRank;
41 using stk_classic::mesh::EntityId;
43 using stk_classic::mesh::EntityVector;
44 using stk_classic::mesh::EntityRank;
49 const EntityRank NODE_RANK = FEMMetaData::NODE_RANK;
52 void printEntity(std::ostringstream& msg,
Entity *entity)
54 msg <<
" :: " << print_entity_key(entity) <<
":o[" << entity->
owner_rank() <<
"]:l[" << entity->
log_query()
57 msg <<
"(" << ec->ghost_id <<
"," << ec->proc <<
")";
62 void printNode(std::ostringstream& msg,
Entity *node)
64 printEntity(msg, node);
65 PairIterRelation rels = node->
relations();
66 for (
unsigned i = 0; i < rels.size(); i++)
68 Entity *entity = rels[i].entity();
70 printEntity(msg, entity);
74 void printBuckets(std::ostringstream& msg,
BulkData& mesh)
76 const std::vector<Bucket*> & buckets = mesh.
buckets(0);
77 for (
unsigned i=0; i < buckets.size(); i++)
79 const Bucket& bucket = *buckets[i];
80 msg <<
" bucket[" << i <<
"] = ";
81 size_t bucket_size = bucket.
size();
82 for (
unsigned ie=0; ie < bucket_size; ie++)
84 msg << bucket[ie].identifier() <<
", ";
89 static void checkBuckets(
BulkData& mesh)
91 const std::vector<Bucket*> & buckets = mesh.
buckets(0);
92 for (
unsigned i=0; i < buckets.size(); i++)
94 Bucket* bucket = buckets[i];
99 STKUNIT_UNIT_TEST(UnitTestingOfBulkData, test_other_ghosting_2)
117 EntityId elems_0[][4] = { {100, 21, 50, 0}, {201, 21, 32, 1}, {302, 32, 50, 2},
118 {500, 41, 70, 0}, {301, 41, 42, 1}, {402, 42, 70, 2} };
120 EntityId nodes_0[][2] = { {21,1}, {50,0}, {32, 2}, {41, 1}, {42, 1}, {70, 0} };
122 unsigned nelems =
sizeof(elems_0)/4/
sizeof(EntityId);
123 unsigned nnodes =
sizeof(nodes_0)/2/
sizeof(EntityId);
128 const unsigned spatial_dim = 2;
130 std::vector<std::string> entity_rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dim);
131 entity_rank_names.push_back(
"FAMILY_TREE");
133 FEMMetaData meta_data(spatial_dim, entity_rank_names);
137 unsigned max_bucket_size = 1;
138 BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm, max_bucket_size);
143 if (p_size != 3)
return;
153 const EntityRank elem_rank = meta_data.element_rank();
158 for (
unsigned ielem=0; ielem < nelems; ielem++)
160 if (elems_0[ielem][3] == p_rank)
162 elem = &mesh.
declare_entity(elem_rank, elems_0[ielem][0], empty_parts);
166 nodes.push_back( &mesh.
declare_entity(NODE_RANK, elems_0[ielem][2], empty_parts) );
167 nodes.push_back( &mesh.
declare_entity(NODE_RANK, elems_0[ielem][1], empty_parts) );
183 std::vector<EntityProc> change;
185 for (
unsigned inode=0; inode < nnodes; inode++)
187 node1 = mesh.
get_entity(0, nodes_0[inode][0]);
190 unsigned dest = nodes_0[inode][1];
192 change.push_back(eproc);
202 MPI_Barrier(MPI_COMM_WORLD);
216 STKUNIT_ASSERT(did_it_elem);
218 STKUNIT_ASSERT(did_it);