Debian Codegraph @

packages/stk/stk_unit_tests/stk_mesh/UnitTestSelector.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 EXPECT_TRUE, TEST, etc
36 #include "stk_util/parallel/Parallel.hpp" // for parallel_machine_size, etc
37 #include <stk_mesh/base/Types.hpp> // for PartVector, BucketVector, etc
38 #include "stk_mesh/base/Bucket.hpp" // for Bucket
39 #include "stk_mesh/base/BulkData.hpp" // for BulkData
40 #include <stk_mesh/base/Part.hpp> // for Part
41 #include <stk_mesh/base/Selector.hpp> // for Selector, operator|, etc
42 #include "stk_mesh/base/MeshBuilder.hpp"
43 #include "stk_mesh/base/Entity.hpp" // for Entity
44 #include "stk_mesh/base/Field.hpp" // for Field
45 #include "stk_mesh/base/MetaData.hpp" // for MetaData, entity_rank_names
46 #include "stk_mesh/base/SkinBoundary.hpp"
47 #include "stk_topology/topology.hpp" // for topology, etc
48 #include "stk_unit_test_utils/stk_mesh_fixtures/SelectorFixture.hpp" // for SelectorFixture
49 #include "stk_unit_test_utils/stk_mesh_fixtures/HexFixture.hpp"
50 #include <algorithm> // for find
51 #include <array> // for array
52 #include <iostream> // for ostringstream, ostream, etc
53 #include <stddef.h> // for size_t
54 #include <stdexcept> // for logic_error
55 #include <string> // for basic_string, operator==, etc
56 #include <utility> // for pair
57 #include <vector> // for vector
58 namespace stk { namespace mesh { class Bucket; } }
59
60 namespace {
61
62 using stk::mesh::fixtures::SelectorFixture;
63
64 void test_selector_with_buckets(const SelectorFixture &selectorFixture, const stk::mesh::Selector &selector, bool gold_shouldEntityBeInSelector[]);
65 void test_selector_with_partitions(const SelectorFixture &selectorFixture, const stk::mesh::Selector &selector, bool gold_shouldEntityBeInSelector[]);
66
67 void initialize(SelectorFixture& fixture)
68 {
69 fixture.m_meta_data.commit();
70 fixture.m_bulk_data.modification_begin();
71 fixture.generate_mesh();
72 ASSERT_TRUE(fixture.m_bulk_data.modification_end());
73 }
74
75 /** \defgroup stk_mesh_selector_unit "stk::mesh::Selector Unit Testing"
76 * \addtogroup stk_mesh_selector_unit
77 * \{
78 *
79 * Selector unit testing environment. <br>
80 * A special set of mesh parts and entities are set up in the
81 * following configuration for the Selector unit testing.<br>
82 * Parts: PartA, PartB, PartC, PartD, PartU <br>
83 * PartU = MetaData.universal_part() <br>
84 * Entities: Entity1, Entity2, Entity3, Entity4, Entity5 <br>
85 *
86 * PartA contains Entity1, Entity2 <br>
87 * PartB contains Entity2, Entity3 <br>
88 * PartC contains Entity3, Entity4 <br>
89 * PartD contains no entities <br>
90 * Entity5 is not contained in any Part <br>
91 *
92 * <PRE>
93 * |----------|--|-------|--|----------| |-------------|
94 * |<--PartA---->| |<--PartC---->| | PartD |
95 * | |<---PartB--->| | | |
96 * | 1 |2 | |3 | 4 | 5 | |
97 * | | | | | | | |
98 * | | | | | | | |
99 * |----------|--|-------|--|----------| |-------------|
100 * </PRE>
101 *
102 * Note: The unit test names use the convention of "i" for
103 * intersection, "u" for union, and "c" for complement.
104 *
105 * */
106
107 TEST(Verify, selectorFixtureDoesNotSegFault)
108 {
109 {
110 SelectorFixture fix;
111 initialize(fix);
112 }
113 EXPECT_TRUE(true);
114 }
115
116 TEST(Verify, twoSelectorFixturesCreatedSequentiallyDoNotSegFault)
117 {
118 {
119 SelectorFixture fix;
120 initialize(fix);
121 }
122 {
123 SelectorFixture fix;
124 initialize(fix);
125 }
126 EXPECT_TRUE(true);
127 }
128
129
130 TEST(Verify, partASelector)
131 {
132 SelectorFixture fix;
133 initialize(fix);
134
135 stk::mesh::Selector partASelector(fix.m_partA);
136
137 const size_t numExpectedBuckets = 2;
138 EXPECT_EQ(numExpectedBuckets, partASelector.get_buckets(stk::topology::NODE_RANK).size());
139
140 EXPECT_FALSE(partASelector.is_empty(stk::topology::NODE_RANK));
141
142 const int numEntities = 5;
143 bool gold_shouldEntityBeInSelector[numEntities] = {true, true, false, false, false};
144
145 test_selector_with_buckets(fix, partASelector, gold_shouldEntityBeInSelector);
146 test_selector_with_partitions(fix, partASelector, gold_shouldEntityBeInSelector);
147 }
148
149 TEST(Verify, notPartASelector)
150 {
151 SelectorFixture fix;
152 initialize(fix);
153
154 stk::mesh::Selector notPartASelector = ! fix.m_partA;
155
156 const int numEntities = 5;
157 bool gold_shouldEntityBeInSelector[numEntities] = {false, false, true, true, true};
158
159 test_selector_with_buckets(fix, notPartASelector, gold_shouldEntityBeInSelector);
160 test_selector_with_partitions(fix, notPartASelector, gold_shouldEntityBeInSelector);
161 }
162
163 TEST(Verify, emptyPartSelector)
164 {
165 SelectorFixture fix;
166 initialize(fix);
167
168 stk::mesh::Selector selector( fix.m_partD );
169
170 EXPECT_TRUE(selector.is_empty(stk::topology::NODE_RANK));
171
172 const int numEntities = 5;
173 bool gold_shouldEntityBeInSelector[numEntities] = {false, false, false, false, false};
174
175 test_selector_with_buckets(fix, selector, gold_shouldEntityBeInSelector);
176 test_selector_with_partitions(fix, selector, gold_shouldEntityBeInSelector);
177 }
178
179 TEST(Verify, selectorEmptyDuringMeshMod)
180 {
181 const unsigned spatialDim=3;
182 stk::mesh::MeshBuilder builder(MPI_COMM_WORLD);
183 builder.set_spatial_dimension(spatialDim);
184 builder.set_entity_rank_names(stk::mesh::entity_rank_names());
185 std::shared_ptr<stk::mesh::BulkData> bulkPtr = builder.create();
186 stk::mesh::BulkData& bulk = *bulkPtr;
187 stk::mesh::MetaData& meta = bulk.mesh_meta_data();
188 stk::mesh::Part& block1 = meta.declare_part_with_topology("block_1", stk::topology::HEX_8);
189 meta.commit();
190
191 stk::mesh::Selector block1Selector = block1;
192 EXPECT_TRUE(block1Selector.is_empty(stk::topology::NODE_RANK));
193 EXPECT_TRUE(block1Selector.is_empty(stk::topology::ELEM_RANK));
194
195 bulk.modification_begin();
196
197 if (bulk.parallel_rank()==0) {
198
199 stk::mesh::EntityId elem1Id = 1;
200 stk::mesh::Entity elem1 = bulk.declare_element(elem1Id, stk::mesh::ConstPartVector{&block1});
201
202 EXPECT_FALSE(block1Selector.is_empty(stk::topology::ELEM_RANK));
203
204 stk::mesh::PartVector addParts;
205 stk::mesh::PartVector removeParts(1, &block1);
206 bulk.change_entity_parts(elem1, addParts, removeParts);
207
208 EXPECT_TRUE(block1Selector.is_empty(stk::topology::ELEM_RANK));
209
210 addParts.push_back(&block1);
211 removeParts.clear();
212
213 bulk.change_entity_parts(elem1, addParts, removeParts);
214
215 EXPECT_FALSE(block1Selector.is_empty(stk::topology::ELEM_RANK));
216 }
217
218 //cannot call modification_end which requires all elements, faces, edges to have connected nodes - which we have not defined
219 //bulk.modification_end();
220
221 if (bulk.parallel_rank()==0) {
222 EXPECT_FALSE(block1Selector.is_empty(stk::topology::ELEM_RANK));
223 }
224 else {
225 EXPECT_TRUE(block1Selector.is_empty(stk::topology::ELEM_RANK));
226 }
227 }
228
229 TEST(Verify, selector_declarePartSubset)
230 {
231 SelectorFixture fix;
232 stk::mesh::Part& partAsub = fix.m_meta_data.declare_part_with_topology("subPart", stk::topology::NODE);
233 fix.m_meta_data.declare_part_subset(fix.m_partA, partAsub);
234 EXPECT_EQ(1u, fix.m_fieldABC->restrictions().size());
235 const stk::mesh::Selector& fieldABCselector = fix.m_fieldABC->restrictions()[0].selector();
236 EXPECT_TRUE(fieldABCselector(partAsub));
237 }
238
239 TEST(Verify, complementOfPartASelector)
240 {
241 SelectorFixture fix;
242 initialize(fix);
243
244 stk::mesh::Part & partA = fix.m_partA;
245 stk::mesh::Selector partASelector(partA);
246
247 size_t expected_num_buckets = 2;
248 EXPECT_EQ(expected_num_buckets, partASelector.get_buckets(stk::topology::NODE_RANK).size());
249 EXPECT_FALSE(partASelector.is_empty(stk::topology::NODE_RANK));
250 EXPECT_TRUE(partASelector.is_empty(stk::topology::FACE_RANK));
251
252 stk::mesh::Selector partAComplementSelector = partASelector.complement();
253
254 expected_num_buckets = 3;
255 EXPECT_EQ(expected_num_buckets, partAComplementSelector.get_buckets(stk::topology::NODE_RANK).size());
256
257 const int numEntities = 5;
258 bool gold_shouldEntityBeInSelector[numEntities] = {false, false, true, true, true};
259
260 test_selector_with_buckets(fix, partAComplementSelector, gold_shouldEntityBeInSelector);
261 test_selector_with_partitions(fix, partAComplementSelector, gold_shouldEntityBeInSelector);
262 }
263
264 TEST(Verify, andedSelector)
265 {
266 SelectorFixture fix ;
267 initialize(fix);
268
269 stk::mesh::Part & partA = fix.m_partA;
270 stk::mesh::Part & partB = fix.m_partB;
271
272 stk::mesh::Selector andedSelector = partA & partB;
273 const int numEntities = 5;
274 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true, false, false, false};
275 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true, true , false, false};
276 bool gold_shouldEntityBeInAndedSelector[numEntities] = {false, true, false, false, false};
277 test_selector_with_buckets(fix, partA, gold_shouldEntityBeInPartASelector);
278 test_selector_with_buckets(fix, partB, gold_shouldEntityBeInPartBSelector);
279 test_selector_with_buckets(fix, andedSelector, gold_shouldEntityBeInAndedSelector);
280 }
281
282 TEST(Verify, oredSelector)
283 {
284 SelectorFixture fix ;
285 initialize(fix);
286
287 stk::mesh::Part & partA = fix.m_partA;
288 stk::mesh::Part & partB = fix.m_partB;
289
290 stk::mesh::Selector oredSelector = partA | partB;
291 const int numEntities = 5;
292 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true, false, false, false};
293 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true, true , false, false};
294 bool gold_shouldEntityBeInOredSelector[numEntities] = {true , true, true , false, false};
295 test_selector_with_buckets(fix, partA, gold_shouldEntityBeInPartASelector);
296 test_selector_with_buckets(fix, partB, gold_shouldEntityBeInPartBSelector);
297 test_selector_with_buckets(fix, oredSelector, gold_shouldEntityBeInOredSelector);
298 }
299
300 TEST(Verify, notAndedSelector)
301 {
302 SelectorFixture fix ;
303 initialize(fix);
304
305 stk::mesh::Part & partA = fix.m_partA;
306 stk::mesh::Part & partB = fix.m_partB;
307
308 stk::mesh::Selector notAndedSelector = !(partA & partB);
309
310 const int numEntities = 5;
311 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true , false, false, false};
312 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true , true , false, false};
313 bool gold_shouldEntityBeInAndedSelector[numEntities] = {true , false, true , true , true };
314 test_selector_with_buckets(fix, partA, gold_shouldEntityBeInPartASelector);
315 test_selector_with_buckets(fix, partB, gold_shouldEntityBeInPartBSelector);
316 test_selector_with_buckets(fix, notAndedSelector, gold_shouldEntityBeInAndedSelector);
317 }
318
319 TEST(Verify, noredSelector)
320 {
321 SelectorFixture fix ;
322 initialize(fix);
323
324 stk::mesh::Part & partA = fix.m_partA;
325 stk::mesh::Part & partB = fix.m_partB;
326
327 stk::mesh::Selector norSelector = !(partA | partB);
328 const int numEntities = 5;
329 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true , false, false, false};
330 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true , true , false, false};
331 bool gold_shouldEntityBeInOredSelector[numEntities] = {false, false, false, true , true };
332 test_selector_with_buckets(fix, partA, gold_shouldEntityBeInPartASelector);
333 test_selector_with_buckets(fix, partB, gold_shouldEntityBeInPartBSelector);
334 test_selector_with_buckets(fix, norSelector, gold_shouldEntityBeInOredSelector);
335 }
336
337 TEST(Verify, differenceSelector)
338 {
339 SelectorFixture fix ;
340 initialize(fix);
341
342 stk::mesh::Part & partA = fix.m_partA;
343 stk::mesh::Part & partB = fix.m_partB;
344
345 stk::mesh::Selector differenceSelector = partA - partB;
346 stk::mesh::Selector equivSelector = partA & !partB;
347 const int numEntities = 5;
348 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true , false, false, false};
349 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true , true , false, false};
350 bool gold_shouldEntityBeInDifferenceSelector[numEntities] = {true , false, false, false, false};
351 test_selector_with_buckets(fix, partA, gold_shouldEntityBeInPartASelector);
352 test_selector_with_buckets(fix, partB, gold_shouldEntityBeInPartBSelector);
353 test_selector_with_buckets(fix, differenceSelector, gold_shouldEntityBeInDifferenceSelector);
354 test_selector_with_buckets(fix, equivSelector, gold_shouldEntityBeInDifferenceSelector);
355 }
356
357 TEST(Verify, variousSelectorCombinations)
358 {
359 SelectorFixture fix ;
360 initialize(fix);
361
362 stk::mesh::Part & partA = fix.m_partA;
363 stk::mesh::Part & partB = fix.m_partB;
364 stk::mesh::Part & partC = fix.m_partC;
365
366 stk::mesh::Selector complexSelector = partA & !(partB | partC);
367
368 const int numEntities = 5;
369 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true , true , false, false};
370 bool gold_shouldEntityBeInPartCSelector[numEntities] = {false, false, true , true , false};
371 bool gold_shouldEntityBeInPartBOrPartCSelector[numEntities] = {false, true , true , true , false};
372 bool gold_shouldEntityNotBeInPartBOrPartCSelector[numEntities] = {true , false, false, false, true };
373 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true , false, false, false};
374 bool gold_shouldEntityBeInComplexSelector[numEntities] = {true , false, false, false, false};
375 test_selector_with_buckets(fix, partB, gold_shouldEntityBeInPartBSelector);
376 test_selector_with_buckets(fix, partC, gold_shouldEntityBeInPartCSelector);
377 test_selector_with_buckets(fix, partB|partC, gold_shouldEntityBeInPartBOrPartCSelector);
378 test_selector_with_buckets(fix, !(partB|partC), gold_shouldEntityNotBeInPartBOrPartCSelector);
379 test_selector_with_buckets(fix, partA, gold_shouldEntityBeInPartASelector);
380 test_selector_with_buckets(fix, complexSelector, gold_shouldEntityBeInComplexSelector);
381 }
382
383 TEST(Verify, complementOfSelectorComplement)
384 {
385 SelectorFixture fix ;
386 initialize(fix);
387
388 stk::mesh::Part & partA = fix.m_partA ;
389 stk::mesh::Part & partB = fix.m_partB ;
390 stk::mesh::Selector norSelector = (partA | partB).complement();
391
392 const int numEntities = 5;
393 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true , false, false, false};
394 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true , true , false, false};
395 bool gold_shouldEntityBeInNoredSelector[numEntities] = {false, false, false, true, true };
396 bool gold_shouldEntityBeInNotNoredSelector[numEntities] = {true , true , true , false, false};
397
398 test_selector_with_buckets(fix, partA, gold_shouldEntityBeInPartASelector);
399 test_selector_with_buckets(fix, partB, gold_shouldEntityBeInPartBSelector);
400 test_selector_with_buckets(fix, norSelector, gold_shouldEntityBeInNoredSelector);
401
402 stk::mesh::Selector selector = norSelector.complement();
403 test_selector_with_buckets(fix, selector, gold_shouldEntityBeInNotNoredSelector);
404 test_selector_with_buckets(fix, (partA | partB), gold_shouldEntityBeInNotNoredSelector);
405 }
406
407 TEST(Verify, complementOfDefaultConstructedSelector)
408 {
409 SelectorFixture fix ;
410 initialize(fix);
411
412 const int numEntities = 5;
413 bool goldEntityInDefaultCtor[numEntities] = {false, false, false, false, false};
414 bool goldEntityInDefaultCtorComplement[numEntities] = {true , true , true , true , true };
415
416 stk::mesh::Selector defaultConstructedSelector;
417 test_selector_with_buckets(fix, defaultConstructedSelector, goldEntityInDefaultCtor);
418
419 stk::mesh::Selector complementOfDefault = defaultConstructedSelector.complement();
420 test_selector_with_buckets(fix, complementOfDefault, goldEntityInDefaultCtorComplement);
421 }
422
423 TEST(Verify, usingPartVectorToSelectIntersection)
424 {
425 SelectorFixture fix ;
426 initialize(fix);
427
428 stk::mesh::PartVector parts ;
429 parts.push_back( & fix.m_partA );
430 parts.push_back( & fix.m_partB );
431 stk::mesh::Selector selector = selectIntersection(parts);
432
433 const int numEntities = 5;
434 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true, false, false, false};
435 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true, true , false, false};
436 bool gold_shouldEntityBeInAndedSelector[numEntities] = {false, true, false, false, false};
437 test_selector_with_buckets(fix, fix.m_partA, gold_shouldEntityBeInPartASelector);
438 test_selector_with_buckets(fix, fix.m_partB, gold_shouldEntityBeInPartBSelector);
439 test_selector_with_buckets(fix, selector, gold_shouldEntityBeInAndedSelector);
440
441 std::ostringstream msg;
442 msg << selector;
443 EXPECT_EQ("(PartA & PartB)", msg.str());
444 }
445
446 TEST(Verify, selectUnionIgnoresNullParts)
447 {
448 SelectorFixture fix ;
449 initialize(fix);
450
451 stk::mesh::PartVector parts ;
452 parts.push_back( & fix.m_partA );
453 parts.push_back( & fix.m_partB );
454 parts.push_back( & fix.m_partC );
455 stk::mesh::Selector selector = selectUnion(parts);
456
457 parts.insert(parts.begin(), nullptr);
458 parts.push_back(nullptr);
459 stk::mesh::Selector selector2 = selectUnion(parts);
460 EXPECT_TRUE(selector == selector2);
461 }
462
463 TEST(Verify, usingPartVectorToSelectUnion)
464 {
465 SelectorFixture fix ;
466 initialize(fix);
467
468 stk::mesh::PartVector parts ;
469 parts.push_back( & fix.m_partA );
470 parts.push_back( & fix.m_partB );
471 parts.push_back( & fix.m_partC );
472 stk::mesh::Selector selector = selectUnion(parts);
473
474 const int numEntities = 5;
475 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true , false, false, false};
476 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true , true , false, false};
477 bool gold_shouldEntityBeInPartAOrPartBSelector[numEntities] = {true , true , true , false, false};
478 bool gold_shouldEntityBeInPartCSelector[numEntities] = {false, false, true , true , false};
479 bool gold_shouldEntityBeInPartOredSelector[numEntities] = {true , true , true , true , false};
480 test_selector_with_buckets(fix, fix.m_partA, gold_shouldEntityBeInPartASelector);
481 test_selector_with_buckets(fix, fix.m_partB, gold_shouldEntityBeInPartBSelector);
482 test_selector_with_buckets(fix, (fix.m_partA | fix.m_partB), gold_shouldEntityBeInPartAOrPartBSelector);
483 test_selector_with_buckets(fix, fix.m_partC, gold_shouldEntityBeInPartCSelector);
484 test_selector_with_buckets(fix, selector, gold_shouldEntityBeInPartOredSelector);
485
486 std::ostringstream msg;
487 msg << selector;
488 std::cout << "msg.str() = " << msg.str() << std::endl;
489 EXPECT_EQ( "(PartA | PartB | PartC)", msg.str() );
490 }
491
492 TEST(Verify, defaultConstructorForSelector)
493 {
494 SelectorFixture fix ;
495 initialize(fix);
496
497 stk::mesh::Selector defaultConstructedSelector;
498
499 EXPECT_TRUE(defaultConstructedSelector.is_empty(stk::topology::NODE_RANK));
500
501 const stk::mesh::BucketVector& nodeBuckets = defaultConstructedSelector.get_buckets(stk::topology::NODE_RANK);
502 EXPECT_TRUE(nodeBuckets.empty());
503
504 const int numEntities = 5;
505 bool goldEntityInDefaultCtor[numEntities] = {false, false, false, false, false};
506
507 test_selector_with_buckets(fix, defaultConstructedSelector, goldEntityInDefaultCtor);
508 }
509
510 TEST(Verify, usingEqualityOperator)
511 {
512 SelectorFixture fix;
513 initialize(fix);
514
515 stk::mesh::Part & partA = fix.m_partA;
516 stk::mesh::Selector partASelector(partA);
517 stk::mesh::Selector anotherPartASelector(partA);
518 EXPECT_TRUE(partASelector == anotherPartASelector);
519
520 stk::mesh::Part & partB = fix.m_partB;
521 stk::mesh::Selector unionPartAPartB(partA | partB);
522 stk::mesh::Selector anotherUnionPartAPartB(partA | partB);
523 EXPECT_TRUE(unionPartAPartB == anotherUnionPartAPartB);
524
525 stk::mesh::Selector intersectionPartAPartB(partA & partB);
526 stk::mesh::Selector anotherIntersectionPartAPartB(partA & partB);
527 EXPECT_TRUE(intersectionPartAPartB == anotherIntersectionPartAPartB);
528
529 EXPECT_FALSE(unionPartAPartB == intersectionPartAPartB);
530
531 stk::mesh::Selector complementPartA(!partA);
532 stk::mesh::Selector anotherComplementPartA(!partA);
533 EXPECT_TRUE(complementPartA == anotherComplementPartA);
534
535 EXPECT_FALSE(partASelector == complementPartA);
536 EXPECT_FALSE(complementPartA == partASelector);
537
538 stk::mesh::Selector complementPartB(!partB);
539 EXPECT_FALSE(complementPartA == complementPartB);
540
541 stk::mesh::Selector notNotPartA(!!partA);
542 EXPECT_FALSE(partASelector == notNotPartA);
543 }
544
545 TEST(Verify, usingCopyConstructor)
546 {
547 SelectorFixture fix;
548 initialize(fix);
549
550 stk::mesh::Part & partA = fix.m_partA;
551 stk::mesh::Part & partB = fix.m_partB;
552 stk::mesh::Part & partC = fix.m_partC;
553 stk::mesh::Selector selector = (partA & partB) | partC;
554 stk::mesh::Selector anotherSelector(selector);
555 EXPECT_TRUE(selector == anotherSelector);
556 }
557
558
559 TEST(Verify, usingSelectField)
560 {
561 SelectorFixture fix ;
562 initialize(fix);
563
564 stk::mesh::Selector selectFieldA = stk::mesh::selectField(*fix.m_fieldA);
565 stk::mesh::Selector selectFieldABC = stk::mesh::selectField(*fix.m_fieldABC);
566
567 stk::mesh::Part & partA = fix.m_partA;
568 stk::mesh::Part & partB = fix.m_partB;
569 stk::mesh::Part & partC = fix.m_partC;
570 stk::mesh::Part & partD = fix.m_partD;
571
572 //
573 // Test selection of buckets
574 //
575 const int numEntities = 5;
576 bool gold_shouldEntityBeInPartASelector[numEntities] = {true , true , false, false, false};
577 bool gold_shouldEntityBeInPartBSelector[numEntities] = {false, true , true , false, false};
578 bool gold_shouldEntityBeInPartCSelector[numEntities] = {false, false, true , true , false};
579 bool gold_shouldEntityBeInPartsABCUnionSelector[numEntities] = {true , true , true , true , false};
580
581 test_selector_with_buckets(fix, selectFieldA, gold_shouldEntityBeInPartASelector);
582 test_selector_with_buckets(fix, fix.m_partB, gold_shouldEntityBeInPartBSelector);
583 test_selector_with_buckets(fix, fix.m_partC, gold_shouldEntityBeInPartCSelector);
584 test_selector_with_buckets(fix, selectFieldABC, gold_shouldEntityBeInPartsABCUnionSelector);
585
586 //
587 // Test selection of parts. Part selection returns true if there is overlap between the test part set
588 // and any part the field was registered on.
589 //
590 EXPECT_TRUE (selectFieldA(partA));
591 EXPECT_FALSE(selectFieldA(partB));
592 EXPECT_FALSE(selectFieldA(partC));
593 EXPECT_FALSE(selectFieldA(partD));
594
595 EXPECT_TRUE (selectFieldABC(partA));
596 EXPECT_TRUE (selectFieldABC(partB));
597 EXPECT_TRUE (selectFieldABC(partC));
598 EXPECT_FALSE(selectFieldABC(partD));
599
600
601 stk::mesh::PartVector partsAB;
602 partsAB.push_back(&partA);
603 partsAB.push_back(&partB);
604
605 stk::mesh::PartVector partsCD;
606 partsAB.push_back(&partC);
607 partsAB.push_back(&partD);
608
609 EXPECT_TRUE (selectFieldA(partsAB));
610 EXPECT_FALSE(selectFieldA(partsCD));
611
612 //
613 // Check selection of buckets also works in a mesh modification cycle
614 //
615 fix.get_NonconstBulkData().modification_begin("TEST MODIFICATION");
616
617 test_selector_with_buckets(fix, selectFieldA, gold_shouldEntityBeInPartASelector);
618 test_selector_with_buckets(fix, fix.m_partB, gold_shouldEntityBeInPartBSelector);
619 test_selector_with_buckets(fix, fix.m_partC, gold_shouldEntityBeInPartCSelector);
620 test_selector_with_buckets(fix, selectFieldABC, gold_shouldEntityBeInPartsABCUnionSelector);
621
622
623 fix.get_NonconstBulkData().modification_end();
624
625
626 }
627
628 TEST(Verify, selectorContainsPart)
629 {
630 SelectorFixture fix;
631 initialize(fix);
632
633 stk::mesh::Part & partA = fix.m_partA;
634 stk::mesh::Part & partB = fix.m_partB;
635 stk::mesh::Part & partC = fix.m_partC;
636 stk::mesh::Part & partD = fix.m_partD;
637 stk::mesh::Selector selector = partA | partB | (!partC) | partD;
638 std::cout << "select_part selector = " << selector << std::endl;
639 EXPECT_TRUE(selector(partA));
640 EXPECT_TRUE(selector(partB));
641 EXPECT_FALSE(selector(partC));
642 EXPECT_TRUE(selector(partD));
643
644 selector = partA | ((!((partA & partB) | partC)) & ((!partD) | partB));
645 EXPECT_TRUE(selector(partA));
646 EXPECT_TRUE(selector(partB));
647 EXPECT_FALSE(selector(partC));
648 EXPECT_FALSE(selector(partD));
649
650 selector = partC & (!partD);
651 EXPECT_FALSE(selector(partA));
652 EXPECT_FALSE(selector(partB));
653 EXPECT_TRUE(selector(partC));
654 EXPECT_FALSE(selector(partD));
655 }
656
657 TEST(Verify, printingOfSelectorUnion)
658 {
659 SelectorFixture fix ;
660 initialize(fix);
661
662 stk::mesh::Part & partA = fix.m_partA ;
663 stk::mesh::Part & partB = fix.m_partB ;
664 stk::mesh::Part & partC = fix.m_partC ;
665 stk::mesh::Part & partD = fix.m_partD ;
666 stk::mesh::Selector selector = partA | partB | partC | partD;
667 std::cout << "A|B|C|D = " << selector << std::endl;
668 std::ostringstream msg;
669 msg << selector;
670 EXPECT_EQ( "(PartA | PartB | PartC | PartD)" , msg.str() );
671 }
672
673 TEST(Verify, printingOfSelectorIntersection)
674 {
675 SelectorFixture fix ;
676 initialize(fix);
677
678 stk::mesh::Part & partA = fix.m_partA ;
679 stk::mesh::Part & partB = fix.m_partB ;
680 stk::mesh::Part & partC = fix.m_partC ;
681 stk::mesh::Selector selector = partA & partB & partC;
682 std::cout << "A&B&C = " << selector << std::endl;
683 std::ostringstream msg;
684 msg << selector;
685 EXPECT_TRUE( msg.str() == "(PartA & PartB & PartC)" );
686 }
687
688 TEST(Verify, printingOfGeneralSelector)
689 {
690 SelectorFixture fix ;
691 initialize(fix);
692
693 stk::mesh::Part & partA = fix.m_partA ;
694 stk::mesh::Part & partB = fix.m_partB ;
695 stk::mesh::Part & partC = fix.m_partC ;
696 stk::mesh::Part & partD = fix.m_partD ;
697 stk::mesh::Selector selector = partA | ( (!((partA & partB) | partC)) & ((!partD) | partB));
698 std::cout << "complicated selector = " << selector << std::endl;
699 std::ostringstream msg;
700 msg << selector;
701 EXPECT_EQ( "(PartA | (!(((PartA & PartB) | PartC)) & (!(PartD) | PartB)))" , msg.str() );
702 }
703
704 TEST(Verify, printingOfNothingForComplementOfDefaultSelector)
705 {
706 stk::mesh::Selector selectAll;
707 selectAll.complement();
708
709 stk::mesh::Selector anotherSelectAll;
710 anotherSelectAll.complement();
711
712 {
713 stk::mesh::Selector selectAllANDAll = selectAll & anotherSelectAll;
714 std::ostringstream description;
715 description << selectAllANDAll;
716 EXPECT_EQ( "(!(NOTHING) & !(NOTHING))", description.str());
717
718 //will throw because the selector doesn't have access to a mesh
719 EXPECT_THROW(selectAllANDAll.get_buckets(stk::topology::NODE_RANK), std::logic_error);
720 }
721 {
722 stk::mesh::Selector selectAllORAll = selectAll | anotherSelectAll;
723 std::ostringstream description;
724 description << selectAllORAll;
725 EXPECT_EQ( "(!(NOTHING) | !(NOTHING))", description.str());
726 }
727 }
728
729 TEST(Verify, usingLessThanOperator)
730 {
731 SelectorFixture fix ;
732 initialize(fix);
733
734 stk::mesh::Part & partA = fix.m_partA ;
735 stk::mesh::Part & partB = fix.m_partB ;
736 stk::mesh::Part & partC = fix.m_partC ;
737 stk::mesh::Part & partD = fix.m_partD ;
738
739 const unsigned ordA = partA.mesh_meta_data_ordinal();
740 const unsigned ordB = partB.mesh_meta_data_ordinal();
741 const unsigned ordC = partC.mesh_meta_data_ordinal();
742 const unsigned ordD = partD.mesh_meta_data_ordinal();
743
744 ASSERT_TRUE(ordA < ordB && ordB < ordC && ordC < ordD);
745
746 stk::mesh::Selector partASelector = partA;
747 EXPECT_FALSE(partASelector < partASelector);
748
749 stk::mesh::Selector partBSelector = partB;
750 EXPECT_TRUE(partASelector < partBSelector);
751
752 stk::mesh::Selector partAIntersectPartDSelector = partA & partD;
753 stk::mesh::Selector partBIntersectPartCSelector = partB & partC;
754 EXPECT_TRUE(partAIntersectPartDSelector < partBIntersectPartCSelector);
755
756 stk::mesh::Selector partCIntersectPartBSelectorOrderMatters = partC & partB;
757 stk::mesh::Selector partDIntersectPartASelectorOrderMatters = partD & partA;
758 EXPECT_TRUE(partDIntersectPartASelectorOrderMatters < partCIntersectPartBSelectorOrderMatters);
759
760 stk::mesh::Selector partAUnionPartBSelector = partA | partB;
761 stk::mesh::Selector partAIntersectPartBSelector = partA & partB;
762 EXPECT_TRUE(partASelector < partAUnionPartBSelector);
763 EXPECT_TRUE(partAUnionPartBSelector < partAIntersectPartBSelector);
764
765 stk::mesh::Selector partAUnionPartBIntersectPartCSelector = partAUnionPartBSelector & partC;
766 EXPECT_TRUE(partAUnionPartBSelector < partAUnionPartBIntersectPartCSelector);
767 }
768
769 void test_selector_with_buckets(const SelectorFixture &selectorFixture, const stk::mesh::Selector &selector, bool gold_shouldEntityBeInSelector[])
770 {
771 const stk::mesh::BulkData& stkMeshBulkData = selectorFixture.get_BulkData();
772 {
773 const stk::mesh::Bucket & bucket = stkMeshBulkData.bucket(selectorFixture.m_entity1);
774 bool result = selector(bucket);
775 EXPECT_EQ(gold_shouldEntityBeInSelector[0], result);
776 }
777 {
778 const stk::mesh::Bucket & bucket = stkMeshBulkData.bucket(selectorFixture.m_entity2);
779 bool result = selector(bucket);
780 EXPECT_EQ(gold_shouldEntityBeInSelector[1], result);
781 }
782 {
783 const stk::mesh::Bucket & bucket = stkMeshBulkData.bucket(selectorFixture.m_entity3);
784 bool result = selector(bucket);
785 EXPECT_EQ(gold_shouldEntityBeInSelector[2], result);
786 }
787 {
788 const stk::mesh::Bucket & bucket = stkMeshBulkData.bucket(selectorFixture.m_entity4);
789 bool result = selector(bucket);
790 EXPECT_EQ(gold_shouldEntityBeInSelector[3], result);
791 }
792 {
793 const stk::mesh::Bucket & bucket = stkMeshBulkData.bucket(selectorFixture.m_entity5);
794 bool result = selector(bucket);
795 EXPECT_EQ(gold_shouldEntityBeInSelector[4], result);
796 }
797 }
798
799 void test_selector_with_partitions(const SelectorFixture &selectorFixture, const stk::mesh::Selector &selector, bool gold_shouldEntityBeInSelector[])
800 {
801 const stk::mesh::BulkData& stkMeshBulkData = selectorFixture.get_BulkData();
802 {
803 const stk::mesh::impl::Partition* partition = stkMeshBulkData.bucket(selectorFixture.m_entity1).getPartition();
804 bool result = selector(*partition);
805 EXPECT_EQ(gold_shouldEntityBeInSelector[0], result);
806 }
807 {
808 const stk::mesh::impl::Partition* partition = stkMeshBulkData.bucket(selectorFixture.m_entity2).getPartition();
809 bool result = selector(*partition);
810 EXPECT_EQ(gold_shouldEntityBeInSelector[1], result);
811 }
812 {
813 const stk::mesh::impl::Partition* partition = stkMeshBulkData.bucket(selectorFixture.m_entity3).getPartition();
814 bool result = selector(*partition);
815 EXPECT_EQ(gold_shouldEntityBeInSelector[2], result);
816 }
817 {
818 const stk::mesh::impl::Partition* partition = stkMeshBulkData.bucket(selectorFixture.m_entity4).getPartition();
819 bool result = selector(*partition);
820 EXPECT_EQ(gold_shouldEntityBeInSelector[3], result);
821 }
822 {
823 const stk::mesh::impl::Partition* partition = stkMeshBulkData.bucket(selectorFixture.m_entity5).getPartition();
824 bool result = selector(*partition);
825 EXPECT_EQ(gold_shouldEntityBeInSelector[4], result);
826 }
827 }
828
829 std::shared_ptr<stk::mesh::BulkData> create_mesh(stk::ParallelMachine comm,
830 unsigned spatialDim)
831 {
832 stk::mesh::MeshBuilder builder(comm);
833 builder.set_spatial_dimension(spatialDim);
834 std::shared_ptr<stk::mesh::BulkData> bulk = builder.create();
835 return bulk;
836 }
837
838 void check_selector_does_not_return_root_topology_parts(stk::ParallelMachine pm, const std::string &part_name, stk::topology topo )
839 {
840 const unsigned spatialDim = 3;
841 std::shared_ptr<stk::mesh::BulkData> meshPtr = create_mesh(pm, spatialDim);
842 stk::mesh::BulkData& mesh = *meshPtr;
843 stk::mesh::MetaData& meta = mesh.mesh_meta_data();
844
845 stk::mesh::Part * part = &meta.declare_part_with_topology(part_name, topo);
846 meta.commit();
847
848 stk::mesh::Selector selector(*part);
849
850 stk::mesh::PartVector selectorParts;
851
852 selector.get_parts(selectorParts);
853
854 stk::mesh::Part &rootPart= meta.get_topology_root_part(topo);
855
856 auto iterator = std::find(selectorParts.begin(), selectorParts.end(), &rootPart );
857
858 EXPECT_EQ(1u, selectorParts.size());
859
860 EXPECT_TRUE(selectorParts.end() == iterator);
861
862 iterator = std::find(selectorParts.begin(), selectorParts.end(), part );
863
864 EXPECT_TRUE(selectorParts.end() != iterator);
865 }
866
867 TEST( UnitTestRootTopology, getPartsDoesNotFindAutoCreatedRootParts )
868 {
869 stk::ParallelMachine pm = MPI_COMM_WORLD;
870 int p_size = stk::parallel_machine_size(pm);
871
872 if(p_size > 1)
873 {
874 return;
875 }
876
877 std::vector < stk::topology > test_topologies {
878 stk::topology::NODE
879 //EDGE_RANK
880 , stk::topology::LINE_2
881 , stk::topology::LINE_3
882 //FACE_RANK
883 , stk::topology::TRI_3
884 , stk::topology::TRI_4
885 , stk::topology::TRI_6
886 , stk::topology::QUAD_4
887 , stk::topology::QUAD_6
888 , stk::topology::QUAD_8
889 , stk::topology::QUAD_9
890 //ELEMENT_RANK
891 , stk::topology::PARTICLE
892 , stk::topology::BEAM_2
893 , stk::topology::BEAM_3
894 , stk::topology::SHELL_TRI_3
895 // Cannot create SHELL_TRI_4 entities because Shards does not support!
896 // , stk::topology::SHELL_TRI_4
897 , stk::topology::SHELL_TRI_6
898 , stk::topology::SHELL_QUAD_4
899 , stk::topology::SHELL_QUAD_8
900 , stk::topology::SHELL_QUAD_9
901 , stk::topology::TET_4
902 , stk::topology::TET_8
903 , stk::topology::TET_10
904 , stk::topology::TET_11
905 , stk::topology::PYRAMID_5
906 , stk::topology::PYRAMID_13
907 , stk::topology::PYRAMID_14
908 , stk::topology::WEDGE_6
909 , stk::topology::WEDGE_15
910 , stk::topology::WEDGE_18
911 , stk::topology::HEX_8
912 , stk::topology::HEX_20
913 , stk::topology::HEX_27};
914
915 for (unsigned i = 0; i < test_topologies.size(); ++i)
916 {
917 check_selector_does_not_return_root_topology_parts(pm, "topo_part" , test_topologies[i]);
918 }
919 }
920
921 TEST(Selector, get_parts_intersection_ranked)
922 {
923 const unsigned spatialDim = 3;
924 stk::mesh::MetaData meta(spatialDim);
925
926 stk::mesh::Part& rankedPart = meta.declare_part("ranked", stk::topology::ELEM_RANK);
927 stk::mesh::Part& unrankedPart = meta.declare_part("unranked");
928 meta.commit();
929
930 EXPECT_TRUE(unrankedPart.primary_entity_rank() == stk::topology::INVALID_RANK);
931
932 //It doesn't seem right that an intersection selector should only return the ranked
933 //part in get_parts, but applications have come to depend on this. So this test
934 //codifies the behavior to make sure that stk testing will catch any unintentional
935 //breakages in stk changes.
936 stk::mesh::Selector selector1 = rankedPart & unrankedPart;
937 stk::mesh::PartVector selector1Parts;
938 selector1.get_parts(selector1Parts);
939 EXPECT_EQ(1u, selector1Parts.size());
940 EXPECT_EQ(rankedPart.mesh_meta_data_ordinal(), selector1Parts[0]->mesh_meta_data_ordinal());
941
942 stk::mesh::Selector selector2 = unrankedPart & rankedPart;
943 stk::mesh::PartVector selector2Parts;
944 selector1.get_parts(selector2Parts);
945 EXPECT_EQ(1u, selector2Parts.size());
946 EXPECT_EQ(rankedPart.mesh_meta_data_ordinal(), selector2Parts[0]->mesh_meta_data_ordinal());
947 }
948
949 TEST(Selector, partIntersection)
950 {
951 stk::ParallelMachine comm = stk::parallel_machine_world();
952 if (stk::parallel_machine_size(comm) != 1) { GTEST_SKIP(); }
953
954 std::shared_ptr<stk::mesh::BulkData> bulkPtr = stk::mesh::MeshBuilder(comm).set_spatial_dimension(3).create();
955 stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data();
956 stk::mesh::Part& sidePart = meta.declare_part_with_topology("sidePart", stk::topology::QUAD_4);
957 constexpr int NX=2, NY=2, NZ=2;
958 stk::mesh::fixtures::HexFixture::fill_mesh(NX, NY, NZ, *bulkPtr);
959 stk::mesh::create_exposed_block_boundary_sides(*bulkPtr, meta.universal_part(), {&sidePart});
960 EXPECT_EQ(24u, stk::mesh::count_entities(*bulkPtr, stk::topology::FACE_RANK, sidePart));
961
962 stk::mesh::Entity node1 = bulkPtr->get_entity(stk::topology::NODE_RANK, 1);
963 EXPECT_TRUE(bulkPtr->is_valid(node1));
964 const stk::mesh::Bucket& node1Bucket = bulkPtr->bucket(node1);
965
966 stk::mesh::Selector validIntersection = sidePart & meta.locally_owned_part();
967 EXPECT_TRUE(validIntersection(node1Bucket));
968 EXPECT_TRUE(validIntersection(node1Bucket.supersets()));
969 stk::mesh::impl::Partition& node1Partition = *node1Bucket.getPartition();
970 EXPECT_TRUE(validIntersection(node1Partition));
971
972 stk::mesh::Selector invalidIntersection = stk::mesh::Selector() & meta.locally_owned_part();
973 EXPECT_FALSE(invalidIntersection(node1Bucket));
974 EXPECT_FALSE(invalidIntersection(node1Bucket.supersets()));
975 EXPECT_FALSE(invalidIntersection(node1Partition));
976 }
977
978 TEST(Selector, selectUnion_clone_for_different_mesh)
979 {
980 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); }
981
982 constexpr unsigned spatialDim = 3;
983 stk::mesh::MetaData meta1(spatialDim);
984 std::string part1Name("myPart1"), part2Name("myPart2");
985 stk::mesh::PartVector parts1 = { &meta1.declare_part(part1Name), &meta1.declare_part(part2Name)};
986 stk::mesh::Selector select1 = stk::mesh::selectUnion(parts1);
987
988 stk::mesh::MetaData meta2;
989 meta2.declare_part(part1Name);
990 meta2.declare_part(part2Name);
991 meta2.initialize(spatialDim);
992
993 stk::mesh::Selector select2 = select1.clone_for_different_mesh(meta2);
994 stk::mesh::PartVector parts2;
995 select2.get_parts(parts2);
996
997 EXPECT_EQ(2u, parts2.size());
998 EXPECT_NE(parts2[0]->mesh_meta_data_ordinal(), parts1[0]->mesh_meta_data_ordinal());
999 EXPECT_NE(parts2[1]->mesh_meta_data_ordinal(), parts1[1]->mesh_meta_data_ordinal());
1000 EXPECT_EQ(parts2[0]->name(), part1Name);
1001 EXPECT_EQ(parts2[1]->name(), part2Name);
1002 }
1003
1004 TEST( UnitTestRootTopology, bucketAlsoHasAutoCreatedRootParts )
1005 {
1006 stk::ParallelMachine pm = MPI_COMM_WORLD;
1007 if (stk::parallel_machine_size(pm) > 1) { GTEST_SKIP(); }
1008
1009 const unsigned spatialDim = 3;
1010 std::shared_ptr<stk::mesh::BulkData> meshPtr = create_mesh(pm, spatialDim);
1011 stk::mesh::BulkData& mesh = *meshPtr;
1012 stk::mesh::MetaData& meta = mesh.mesh_meta_data();
1013
1014 stk::mesh::Part * triPart = &meta.declare_part_with_topology("tri_part", stk::topology::TRI_3);
1015 stk::mesh::Part * shellPart = &meta.declare_part_with_topology("shell_part", stk::topology::SHELL_TRI_3);
1016 meta.commit();
1017
1018 mesh.modification_begin();
1019
1020 std::array<int, 3> node_ids = {{1,2,3}};
1021 stk::mesh::ConstPartVector empty;
1022 stk::mesh::Entity shell3 = mesh.declare_element(1u, stk::mesh::ConstPartVector{shellPart});
1023 for(unsigned i = 0; i<node_ids.size(); ++i) {
1024 stk::mesh::Entity node = mesh.declare_node(node_ids[i], empty);
1025 mesh.declare_relation(shell3, node, i);
1026 }
1027 mesh.declare_element_side(shell3, 0u, stk::mesh::ConstPartVector{triPart} );
1028
1029 mesh.modification_end();
1030
1031 stk::mesh::Selector triSelector(*triPart);
1032
1033 const stk::mesh::BucketVector & buckets = mesh.get_buckets(stk::topology::FACE_RANK, triSelector);
1034
1035 EXPECT_EQ(1u, buckets.size());
1036
1037 {
1038 const stk::mesh::PartVector &triBucketParts = buckets[0]->supersets();
1039
1040 stk::mesh::Part &triRootPart= meta.get_topology_root_part(stk::topology::TRI_3);
1041
1042 auto triIterator = std::find(triBucketParts.begin(), triBucketParts.end(), &triRootPart );
1043
1044 EXPECT_TRUE(triBucketParts.end() != triIterator);
1045
1046 EXPECT_TRUE(triRootPart.contains(*triPart));
1047 }
1048 {
1049 stk::mesh::OrdinalVector ordinals;
1050 buckets[0]->supersets(ordinals);
1051
1052 stk::mesh::Part &triRootPart= meta.get_topology_root_part(stk::topology::TRI_3);
1053
1054 auto triIterator = std::find(ordinals.begin(), ordinals.end(), triRootPart.mesh_meta_data_ordinal());
1055
1056 EXPECT_TRUE(ordinals.end() != triIterator);
1057 }
1058 {
1059 std::pair<const unsigned *, const unsigned *> ords_range = buckets[0]->superset_part_ordinals();
1060
1061 stk::mesh::Part &triRootPart= meta.get_topology_root_part(stk::topology::TRI_3);
1062
1063 auto triIterator = std::find(ords_range.first, ords_range.second, triRootPart.mesh_meta_data_ordinal());
1064
1065 EXPECT_TRUE(ords_range.second != triIterator);
1066 }
1067 }
1068
1069 } // namespace