Debian Codegraph @

packages/stk/stk_unit_tests/stk_mesh/UnitTestGhostingWithShared.cpp

raw
1 // Copyright 2002 - 2008, 2010, 2011 National Technology Engineering
2 // Solutions of Sandia, LLC (NTESS). Under the terms of Contract
3 // DE-NA0003525 with NTESS, the U.S. Government retains certain rights
4 // in this software.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials provided
16 // with the distribution.
17 //
18 // * Neither the name of NTESS nor the names of its contributors
19 // may be used to endorse or promote products derived from this
20 // software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34
35 #include <gtest/gtest.h> // for AssertHelper, EXPECT_EQ, etc
36 #include <stddef.h> // for size_t
37 #include <iostream> // for basic_ostream::operator<<
38 #include <set> // for set, etc
39 #include <stk_mesh/base/BulkData.hpp> // for BulkData
40 #include <stk_util/parallel/Parallel.hpp> // for parallel_machine_size, etc
41 #include <string> // for string
42 #include <utility> // for pair, make_pair
43 #include <vector> // for vector
44 #include <stk_unit_test_utils/BulkDataTester.hpp>
45 #include "mpi.h" // for MPI_COMM_WORLD, etc
46 #include "stk_io/DatabasePurpose.hpp" // for DatabasePurpose::READ_MESH
47 #include "stk_io/StkMeshIoBroker.hpp" // for StkMeshIoBroker
48 #include "stk_mesh/base/Bucket.hpp" // for Bucket
49 #include "stk_mesh/base/Entity.hpp" // for Entity
50 #include "stk_mesh/base/EntityKey.hpp" // for EntityKey, operator<<
51 #include "stk_mesh/base/EntityLess.hpp" // for EntityLess
52 #include "stk_mesh/base/Ghosting.hpp" // for Ghosting
53 #include "stk_mesh/base/MetaData.hpp" // for MetaData
54 #include "stk_mesh/base/Selector.hpp" // for Selector
55 #include "stk_mesh/base/Types.hpp" // for EntityProc, BucketVector, etc
56 #include "stk_mesh/baseImpl/MeshImplUtils.hpp"
57 #include "stk_topology/topology.hpp" // for topology, etc
58 #include "stk_unit_test_utils/ioUtils.hpp" // for fill_mesh_using_stk_io
59 #include "stk_unit_test_utils/BuildMesh.hpp"
60
61 using stk::unit_test_util::build_mesh;
62
63 TEST(UnitTestGhosting, ThreeElemSendElemWithNonOwnedNodes)
64 {
65 stk::ParallelMachine communicator = MPI_COMM_WORLD;
66
67 int numProcs = stk::parallel_machine_size(communicator);
68 if (numProcs != 3) {
69 return;
70 }
71
72 int procId = stk::parallel_machine_rank(communicator);
73
74 unsigned spatialDim = 3;
75 stk::mesh::MetaData meta(spatialDim);
76 stk::unit_test_util::BulkDataTester bulk(meta, communicator);
77 const std::string generatedMeshSpecification = "generated:1x1x3";
78 stk::io::fill_mesh(generatedMeshSpecification, bulk);
79 bulk.modification_begin();
80 stk::mesh::Ghosting& custom_shared_ghosting = bulk.create_ghosting("custom_shared");
81 stk::mesh::Ghosting& custom_shared_ghosting2= bulk.create_ghosting("custom_shared");
82 EXPECT_EQ(custom_shared_ghosting.ordinal(), custom_shared_ghosting2.ordinal());
83 bulk.modification_end();
84
85 stk::mesh::EntityProcVec ownedEntitiesToGhost;
86
87 if (procId == 1)
88 {
89 stk::mesh::Entity elem2 = bulk.get_entity(stk::topology::ELEM_RANK, 2);
90 int destProc = 2;
91 ownedEntitiesToGhost.push_back(stk::mesh::EntityProc(elem2, destProc));
92 }
93
94
95 stk::mesh::EntityProcVec entitiesWithClosure;
96 bulk.my_add_closure_entities(custom_shared_ghosting, ownedEntitiesToGhost, entitiesWithClosure);
97 stk::util::sort_and_unique(entitiesWithClosure, stk::mesh::EntityLess(bulk));
98
99 if (procId == 1)
100 {
101 std::vector<stk::mesh::EntityKey> gold_keys;
102 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 5));
103 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 6));
104 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 7));
105 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 8));
106 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 9));
107 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 10));
108 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 11));
109 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 12));
110
111 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::ELEM_RANK, 2));
112
113 ASSERT_EQ(gold_keys.size(), entitiesWithClosure.size());
114
115 int otherProc = 2;
116
117 unsigned i=0;
118 for(const stk::mesh::EntityProc& entProc : entitiesWithClosure) {
119 EXPECT_EQ(gold_keys[i], bulk.entity_key(entProc.first));
120 EXPECT_EQ(otherProc, entProc.second);
121 ++i;
122 }
123 }
124 else
125 {
126 ASSERT_TRUE(entitiesWithClosure.empty());
127 }
128
129 stk::mesh::impl::move_unowned_entities_for_owner_to_ghost(bulk, entitiesWithClosure);
130 stk::util::sort_and_unique(entitiesWithClosure, stk::mesh::EntityLess(bulk));
131
132 if (procId==0)
133 {
134 std::vector<stk::mesh::EntityKey> gold_keys;
135 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 5));
136 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 6));
137 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 7));
138 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 8));
139
140 ASSERT_EQ(gold_keys.size(), entitiesWithClosure.size());
141
142 int otherProc = 2;
143
144 unsigned i=0;
145 for(const stk::mesh::EntityProc& entProc : entitiesWithClosure) {
146 EXPECT_EQ(gold_keys[i], bulk.entity_key(entProc.first));
147 EXPECT_EQ(otherProc, entProc.second);
148 ++i;
149 }
150 }
151 else if (procId==1)
152 {
153 std::vector<stk::mesh::EntityKey> gold_keys;
154 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 9));
155 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 10));
156 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 11));
157 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 12));
158 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::ELEM_RANK, 2));
159
160 ASSERT_EQ(gold_keys.size(), entitiesWithClosure.size());
161
162 int otherProc = 2;
163
164 unsigned i=0;
165 for(const stk::mesh::EntityProc& entProc : entitiesWithClosure) {
166 EXPECT_EQ(gold_keys[i], bulk.entity_key(entProc.first));
167 EXPECT_EQ(otherProc, entProc.second);
168 ++i;
169 }
170 }
171 else
172 {
173 ASSERT_TRUE(entitiesWithClosure.empty());
174 }
175
176 bulk.modification_begin();
177
178 stk::mesh::Ghosting &ghosting = bulk.create_ghosting("custom ghost unit test");
179 bulk.my_ghost_entities_and_fields(ghosting, std::move(entitiesWithClosure));
180 bulk.my_internal_modification_end_for_change_ghosting();
181
182 if (procId == 0)
183 {
184 EXPECT_TRUE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 5), 2));
185 EXPECT_TRUE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 6), 2));
186 EXPECT_TRUE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 7), 2));
187 EXPECT_TRUE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 8), 2));
188 EXPECT_FALSE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::ELEM_RANK, 2), 2));
189 }
190 else if (procId == 1)
191 {
192 EXPECT_FALSE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 5), 2));
193 EXPECT_FALSE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 6), 2));
194 EXPECT_FALSE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 7), 2));
195 EXPECT_FALSE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 8), 2));
196 EXPECT_TRUE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 9), 2));
197 EXPECT_TRUE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 10), 2));
198 EXPECT_TRUE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 11), 2));
199 EXPECT_TRUE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::NODE_RANK, 12), 2));
200 EXPECT_TRUE(bulk.my_in_send_ghost(ghosting, stk::mesh::EntityKey(stk::topology::ELEM_RANK, 2), 2));
201 }
202 else if (procId == 2)
203 {
204 std::vector<stk::mesh::EntityKey> gold_keys;
205 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 5));
206 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 6));
207 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 7));
208 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 8));
209 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 9));
210 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 10));
211 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 11));
212 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::NODE_RANK, 12));
213 gold_keys.push_back(stk::mesh::EntityKey(stk::topology::ELEM_RANK, 2));
214
215 for (size_t i=0;i<gold_keys.size();++i)
216 {
217 stk::mesh::Entity entity = bulk.get_entity(gold_keys[i]);
218 ASSERT_TRUE(bulk.is_valid(entity));
219 ASSERT_TRUE(bulk.in_receive_ghost(ghosting, gold_keys[i]));
220 }
221 }
222 }
223
224 TEST(UnitTestGhosting, WithSharedFiltered)
225 {
226 stk::ParallelMachine communicator = MPI_COMM_WORLD;
227
228 int numProcs = stk::parallel_machine_size(communicator);
229 if (numProcs != 2) {
230 return;
231 }
232
233 stk::io::StkMeshIoBroker stkMeshIoBroker(communicator);
234 const std::string generatedMeshSpecification = "generated:1x1x6";
235 stkMeshIoBroker.add_mesh_database(generatedMeshSpecification, stk::io::READ_MESH);
236 stkMeshIoBroker.create_input_mesh();
237 stkMeshIoBroker.populate_bulk_data();
238
239 stk::mesh::MetaData &stkMeshMetaData = stkMeshIoBroker.meta_data();
240 stk::mesh::BulkData &stkMeshBulkData = stkMeshIoBroker.bulk_data();
241
242 stk::mesh::Selector shared_selector = stkMeshMetaData.globally_shared_part();
243
244 const stk::mesh::BucketVector& shared_buckets = stkMeshBulkData.get_buckets(stk::topology::NODE_RANK, shared_selector);
245
246 size_t num_shared_nodes = 0;
247 for(size_t i=0; i<shared_buckets.size(); ++i) {
248 num_shared_nodes += shared_buckets[i]->size();
249 }
250
251 const size_t expected_num_shared_nodes = 4;
252 EXPECT_EQ(expected_num_shared_nodes, num_shared_nodes);
253
254 stkMeshBulkData.modification_begin();
255
256 //we will attempt to ghost shared-and-owned entities from proc 0 to proc 1.
257 //they won't be allowed to be in the ghosting because they are already
258 //shared on proc 1.
259 int myProc = stkMeshBulkData.parallel_rank();
260 int otherProc = 1;
261 if (myProc != 0) otherProc = -1;//don't do ghosting if we are proc 1
262
263 stk::mesh::Ghosting& custom_shared_ghosting = stkMeshBulkData.create_ghosting("custom_shared");
264
265 std::vector<stk::mesh::EntityProc> send_shared;
266 if (otherProc != -1) {
267 for(size_t i=0; i<shared_buckets.size(); ++i) {
268 const stk::mesh::Bucket& bucket = *shared_buckets[i];
269 for(size_t j=0; j<bucket.size(); ++j) {
270 if (bucket.parallel_owner_rank(j) == myProc) {
271 send_shared.push_back(std::make_pair(bucket[j], otherProc));
272 }
273 }
274 }
275 }
276
277 stkMeshBulkData.change_ghosting(custom_shared_ghosting, send_shared);
278
279 stkMeshBulkData.modification_end();
280
281 std::vector<stk::mesh::EntityProc> custom_shared_send_list;
282 custom_shared_ghosting.send_list(custom_shared_send_list);
283
284 size_t expected_send_list_size = 0;
285 EXPECT_EQ(expected_send_list_size, custom_shared_send_list.size());
286 }
287
288 TEST(UnitTestGhosting, WithShared)
289 {
290 stk::ParallelMachine communicator = MPI_COMM_WORLD;
291
292 int numProcs = stk::parallel_machine_size(communicator);
293 if (numProcs != 3) {
294 GTEST_SKIP();
295 }
296
297 stk::io::StkMeshIoBroker stkMeshIoBroker(communicator);
298 const std::string generatedMeshSpecification = "generated:1x1x6";
299 stkMeshIoBroker.add_mesh_database(generatedMeshSpecification, stk::io::READ_MESH);
300 stkMeshIoBroker.create_input_mesh();
301 stkMeshIoBroker.populate_bulk_data();
302
303 stk::mesh::MetaData &stkMeshMetaData = stkMeshIoBroker.meta_data();
304 stk::mesh::BulkData &stkMeshBulkData = stkMeshIoBroker.bulk_data();
305
306 stk::mesh::Selector shared_selector = stkMeshMetaData.globally_shared_part();
307
308 const stk::mesh::BucketVector& shared_buckets = stkMeshBulkData.get_buckets(stk::topology::NODE_RANK, shared_selector);
309
310 size_t num_shared_nodes = 0;
311 for(size_t i=0; i<shared_buckets.size(); ++i) {
312 num_shared_nodes += shared_buckets[i]->size();
313 }
314
315 int myProc = stkMeshBulkData.parallel_rank();
316
317 size_t expected_num_shared_nodes = 4;
318 if (myProc == 1) expected_num_shared_nodes = 8;
319
320 EXPECT_EQ(expected_num_shared_nodes, num_shared_nodes);
321
322 stkMeshBulkData.modification_begin();
323
324 //we will ghost shared-and-owned entities from proc 0 to proc 2.
325 int otherProc = 2;
326 if (myProc != 0) otherProc = -1;//don't do ghosting
327
328 stk::mesh::Ghosting& custom_shared_ghosting = stkMeshBulkData.create_ghosting("custom_shared");
329
330 std::vector<stk::mesh::EntityProc> send_shared;
331 if (otherProc != -1) {
332 for(size_t i=0; i<shared_buckets.size(); ++i) {
333 const stk::mesh::Bucket& bucket = *shared_buckets[i];
334 for(size_t j=0; j<bucket.size(); ++j) {
335 if (bucket.parallel_owner_rank(j) == myProc) {
336 send_shared.push_back(std::make_pair(bucket[j], otherProc));
337 }
338 }
339 }
340 }
341
342 stkMeshBulkData.change_ghosting(custom_shared_ghosting, send_shared);
343
344 if (myProc == otherProc) {
345 stk::mesh::Entity node9 = stkMeshBulkData.get_entity(stk::topology::NODE_RANK,9);
346 stk::mesh::Entity node10 = stkMeshBulkData.get_entity(stk::topology::NODE_RANK,10);
347 stk::mesh::Entity node11 = stkMeshBulkData.get_entity(stk::topology::NODE_RANK,11);
348 stk::mesh::Entity node12 = stkMeshBulkData.get_entity(stk::topology::NODE_RANK,12);
349 EXPECT_EQ(stk::mesh::Created, stkMeshBulkData.state(node9));
350 EXPECT_EQ(stk::mesh::Created, stkMeshBulkData.state(node10));
351 EXPECT_EQ(stk::mesh::Created, stkMeshBulkData.state(node11));
352 EXPECT_EQ(stk::mesh::Created, stkMeshBulkData.state(node12));
353 }
354
355 stkMeshBulkData.modification_end();
356
357 std::vector<stk::mesh::EntityProc> custom_shared_send_list;
358 custom_shared_ghosting.send_list(custom_shared_send_list);
359
360 EXPECT_EQ(send_shared.size(), custom_shared_send_list.size());
361 if (myProc == 0) {
362 EXPECT_EQ(num_shared_nodes, custom_shared_send_list.size());
363 }
364 }
365
366 TEST(UnitTestGhosting, basic1Elem)
367 {
368 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 2) return;
369
370 unsigned spatialDim = 3;
371 std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, MPI_COMM_WORLD, stk::mesh::BulkData::NO_AUTO_AURA);
372 stk::mesh::BulkData& bulk = *bulkPtr;
373 const std::string generatedMeshSpecification = "generated:1x1x2";
374 stk::io::fill_mesh(generatedMeshSpecification, bulk);
375
376 std::vector<stk::mesh::EntityProc> send;
377 if (bulk.parallel_rank() == 0) {
378 send.emplace_back(bulk.get_entity(stk::topology::ELEM_RANK, 1), 1);
379 }
380 bulk.modification_begin();
381 stk::mesh::Ghosting& ghosting = bulk.create_ghosting("custom1");
382 bulk.change_ghosting(ghosting, send, std::vector<stk::mesh::EntityKey>());
383 bulk.modification_end();
384 }
385
386 void create_mesh_with_1_tri_per_proc(stk::mesh::BulkData& bulk)
387 {
388 std::vector<stk::mesh::EntityId> nodeIds[] = { {1, 3, 2}, {2, 3, 4} };
389 stk::mesh::EntityId elemIds[] = {1, 2};
390
391 stk::mesh::Part& tri2dPart = bulk.mesh_meta_data().get_topology_root_part(stk::topology::TRI_3_2D);
392 stk::mesh::PartVector elemParts = {&tri2dPart};
393 const int myProc = bulk.parallel_rank();
394 const int otherProc = 1 - myProc;
395
396 bulk.modification_begin();
397 stk::mesh::declare_element(bulk, elemParts, elemIds[myProc], nodeIds[myProc]);
398 bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK, 2), otherProc);
399 bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK, 3), otherProc);
400 bulk.modification_end();
401 }
402
403 void delete_node_2_and_connect_node_5_to_elem_1(stk::mesh::BulkData& bulk)
404 {
405 bulk.modification_begin();
406 {
407 std::ostringstream os;
408 os<<"P"<<bulk.parallel_rank()<<" **** doing test mod ****" << std::endl;
409 std::cerr<<os.str();
410 stk::parallel_machine_barrier(bulk.parallel());
411 }
412 if (bulk.parallel_rank() == 0) {
413 stk::mesh::Entity node5 = bulk.declare_node(5);
414 stk::mesh::Entity node2 = bulk.get_entity(stk::topology::NODE_RANK, 2);
415 stk::mesh::Entity elem1 = bulk.get_entity(stk::topology::ELEM_RANK, 1);
416 stk::mesh::Entity elem2 = bulk.get_entity(stk::topology::ELEM_RANK, 2);
417
418 bulk.destroy_relation(elem1, node2, 2);
419 bulk.destroy_relation(elem2, node2, 0);
420 bulk.destroy_entity(elem2);
421 bulk.destroy_entity(node2);
422 bulk.declare_relation(elem1, node5, 2);
423 }
424 bulk.modification_end();
425 }
426
427 TEST(UnitTestGhosting, sharedBecomesAuraGhost)
428 {
429 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 2) { GTEST_SKIP(); }
430
431 const unsigned spatialDim = 2;
432 std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(spatialDim, MPI_COMM_WORLD, stk::mesh::BulkData::AUTO_AURA);
433 stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data();
434 stk::mesh::BulkData& bulk = *bulkPtr;
435
436 /*Create this mesh:
437
438 P0 P1
439 2* *2
440 /| |\
441 / | | \
442 1* | | *4
443 \ | | /
444 \| |/
445 3* *3
446
447 nodes 2 and 3 are shared, aura ghosts node 1 to P1 and node 4 to P0
448 */
449
450 create_mesh_with_1_tri_per_proc(bulk);
451
452 stk::mesh::EntityVector sharedNodes;
453 stk::mesh::get_selected_entities(meta.globally_shared_part(),
454 bulk.buckets(stk::topology::NODE_RANK), sharedNodes);
455 EXPECT_EQ(2u, sharedNodes.size());
456
457 stk::mesh::Selector ghosts = !(meta.locally_owned_part() | meta.globally_shared_part());
458 stk::mesh::EntityVector ghostNodes;
459 stk::mesh::get_selected_entities(ghosts, bulk.buckets(stk::topology::NODE_RANK), ghostNodes);
460 EXPECT_EQ(1u, ghostNodes.size());
461
462 /*Now change the mesh to be this:
463
464 P0 P1
465 5* *2
466 /| |\
467 / | | \
468 1* | | *4
469 \ | | /
470 \| |/
471 3* *3
472 i.e., on P0: disconnect node 2 from elem 1 and elem 2, destroy node 2
473 node 3 still shared, aura ghosts nodes 1 and 5 to P1 and nodes 2 and 4 to P0
474 */
475
476 delete_node_2_and_connect_node_5_to_elem_1(bulk);
477
478 stk::mesh::get_selected_entities(meta.globally_shared_part(),
479 bulk.buckets(stk::topology::NODE_RANK), sharedNodes);
480 EXPECT_EQ(1u, sharedNodes.size());
481
482 stk::mesh::get_selected_entities(ghosts, bulk.buckets(stk::topology::NODE_RANK), ghostNodes);
483 EXPECT_EQ(2u, ghostNodes.size());
484 }
485