Debian Codegraph @

packages/stk/stk_unit_tests/stk_mesh/UnitTestBucket.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 "stk_mesh/base/Types.hpp" // for PartVector, BucketVector, etc
36 #include "stk_topology/topology.hpp" // for topology, etc
37 #include "stk_unit_test_utils/stk_mesh_fixtures/TestHexFixture.hpp"
38 #include "stk_unit_test_utils/stk_mesh_fixtures/BoxFixture.hpp" // for BoxFixture
39 #include <gtest/gtest.h>
40 #include <sstream> // for ostringstream, etc
41 #include <stddef.h> // for size_t
42 #include <stk_mesh/base/Bucket.hpp> // for has_superset, Bucket, etc
43 #include <stk_mesh/base/BulkData.hpp> // for BulkData
44 #include <stk_mesh/base/MeshBuilder.hpp>
45 #include <stk_mesh/base/FEMHelpers.hpp>
46 #include <stk_mesh/base/Field.hpp> // for Field
47 #include <stk_mesh/base/MetaData.hpp> // for MetaData, put_field_on_mesh
48 #include <stk_mesh/base/GetNgpField.hpp>
49 #include <stk_unit_test_utils/FaceTestingUtils.hpp>
50 #include <stk_util/parallel/Parallel.hpp> // for ParallelMachine, etc
51 #include <string> // for string, basic_string, etc
52 #include <vector> // for vector, etc
53
54 namespace stk { namespace mesh { class FieldBase; } }
55 namespace stk { namespace mesh { class Part; } }
56 namespace stk { namespace mesh { class Selector; } }
57 namespace stk { namespace mesh { struct Entity; } }
58 namespace stk { namespace mesh { class Part; } }
59
60 using stk::mesh::MetaData;
61 using stk::mesh::BulkData;
62 using stk::mesh::Part;
63 using stk::mesh::PartVector;
64 using stk::mesh::EntityRank;
65 using stk::mesh::EntityId;
66 using stk::mesh::PairIterEntityComm;
67 using stk::mesh::Entity;
68 using stk::mesh::Bucket;
69 using stk::mesh::BucketIterator;
70 using stk::mesh::Selector;
71 using stk::mesh::Field;
72 using stk::mesh::FieldBase;
73 using stk::mesh::put_field_on_mesh;
74 using stk::mesh::BucketVector;
75
76 typedef Field<double> ScalarFieldType;
77
78 namespace {
79
80 TEST(UnitTestingOfBucket, testBucket)
81 {
82 // Unit test the Part functionality in isolation:
83
84 stk::ParallelMachine pm = MPI_COMM_WORLD;
85 MPI_Barrier( pm );
86
87 // Create a mesh for testing buckets...
88
89 // Create dummy names for entity ranks to be given to MetaData
90 std::vector<std::string> entity_names(5);
91 for ( size_t i = 0 ; i < 5 ; ++i ) {
92 std::ostringstream name ;
93 name << "EntityRank" << i ;
94 entity_names[i] = name.str();
95 }
96
97 // Create MetaData, BulkData
98 unsigned max_bucket_size = 4;
99 stk::mesh::fixtures::BoxFixture fixture(pm, stk::mesh::BulkData::AUTO_AURA, max_bucket_size, entity_names);
100 MetaData& meta = fixture.fem_meta();
101 BulkData& bulk = fixture.bulk_data();
102 // Create two scalar fields, temperature and volume. Put temperature
103 // on all the nodes and put volume on all the elements.
104 unsigned number_of_states = 4;
105
106 ScalarFieldType & temperature = meta.declare_field<double>(stk::topology::NODE_RANK, "temperature", number_of_states);
107 ScalarFieldType & volume = meta.declare_field<double>(stk::topology::ELEMENT_RANK, "volume", number_of_states);
108 Part & universal = meta.universal_part ();
109 put_field_on_mesh ( temperature , universal , nullptr);
110 put_field_on_mesh ( volume , universal , nullptr);
111 meta.commit();
112
113 // Generate the mesh
114 int root_box[3][2] = { { 0,4 } , { 0,5 } , { 0,6 } };
115 int local_box[3][2] = { { 0,0 } , { 0,0 } , { 0,0 } };
116 bulk.modification_begin();
117 fixture.generate_boxes( root_box, local_box );
118 ASSERT_TRUE(bulk.modification_end());
119
120 // First, test for streaming IO;
121 {
122 std::string gold1;
123 gold1 = "Bucket( EntityRank0 : {UNIVERSAL} {OWNS} {FEM_ROOT_CELL_TOPOLOGY_PART_HEXAHEDRON_8} elem_part )";
124 Bucket *b1 = bulk.buckets(stk::topology::NODE_RANK)[0];
125 std::stringstream out1_str;
126 out1_str << (*b1);
127 bool equal = (gold1 == out1_str.str());
128 ASSERT_TRUE(equal)<<"expected str="<<gold1<<", but actual="<<out1_str.str();
129 }
130
131 // Second, update state of bucket until circular cue is filled
132 {
133 /* Need to set some data in state, rotate look for it, rotate 3 more times
134 and look for it again */
135 for ( size_t i = 0 ; i != 10 ; ++i )
136 bulk.update_field_data_states();
137 }
138
139 // next, check has_superset (...) and membership functions
140 {
141 PartVector tmp(2) ;
142 tmp[0] = & meta.universal_part();
143 tmp[1] = & meta.locally_owned_part();
144 ASSERT_TRUE ( has_superset ( *bulk.buckets(stk::topology::NODE_RANK)[0] , tmp ) );
145 ASSERT_TRUE ( bulk.buckets(stk::topology::NODE_RANK)[0]->member_any ( tmp ) );
146 ASSERT_TRUE ( bulk.buckets(stk::topology::NODE_RANK)[0]->member_all ( tmp ) );
147 ASSERT_TRUE ( bulk.buckets(stk::topology::NODE_RANK)[0]->member ( **meta.get_parts().begin() ) );
148 }
149 }
150
151 TEST(UnitTestingOfBucket, bucketSortChangeEntityId)
152 {
153 const unsigned spatialDim=3;
154 stk::mesh::MeshBuilder builder(MPI_COMM_WORLD);
155 builder.set_spatial_dimension(spatialDim);
156 std::shared_ptr<stk::mesh::BulkData> bulkPtr = builder.create();
157 stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data();
158 stk::mesh::Part& part = meta.declare_part_with_topology("node_part", stk::topology::NODE);
159 meta.commit();
160 stk::mesh::BulkData& bulk = *bulkPtr;
161 if (bulk.parallel_size() > 1) {
162 return;
163 }
164 stk::mesh::EntityId nodeID=1;
165 bulk.modification_begin();
166 bulk.declare_node(nodeID, stk::mesh::ConstPartVector{&part});
167 nodeID=3;
168 bulk.declare_node(nodeID, stk::mesh::ConstPartVector{&part});
169 nodeID=5;
170 bulk.declare_node(nodeID, stk::mesh::ConstPartVector{&part});
171 bulk.modification_end();
172
173 const stk::mesh::BucketVector& node_buckets_1 = bulk.get_buckets(stk::topology::NODE_RANK, meta.universal_part());
174 size_t expected_num_buckets = 1;
175 EXPECT_EQ(expected_num_buckets, node_buckets_1.size());
176 size_t expected_bucket_size = 3;
177 EXPECT_EQ(expected_bucket_size, node_buckets_1[0]->size());
178
179 stk::mesh::Entity node3 = (*node_buckets_1[0])[1];
180 stk::mesh::EntityId node3ID = 3;
181 EXPECT_EQ(node3ID, bulk.identifier(node3));
182
183 stk::mesh::Entity node5 = (*node_buckets_1[0])[2];
184
185 bulk.modification_begin();
186 stk::mesh::EntityId node2ID = 2;
187 bulk.change_entity_id(node2ID, node5);
188 bulk.modification_end();
189
190 const stk::mesh::BucketVector& node_buckets_2 = bulk.get_buckets(stk::topology::NODE_RANK, meta.universal_part());
191
192 stk::mesh::Entity node2 = (*node_buckets_2[0])[1];
193 EXPECT_EQ(node2ID, bulk.identifier(node2));
194 }
195
196 void test_nodes_and_permutation(stk::mesh::BulkData& bulk, stk::mesh::Entity elem, stk::mesh::Entity side, stk::mesh::EntityVector& nodes)
197 {
198 stk::mesh::EntityRank rank = bulk.entity_rank(side);
199 Entity const *rels_itr = bulk.begin_nodes(side);
200 unsigned num_nodes = bulk.num_nodes(side);
201
202 for(unsigned i=0;i<num_nodes;++i)
203 {
204 EXPECT_EQ(nodes[i], rels_itr[i]);
205 }
206
207 stk::mesh::Permutation const *perms = bulk.begin_permutations(side, stk::topology::ELEM_RANK);
208 std::pair<stk::mesh::ConnectivityOrdinal, stk::mesh::Permutation> ordinalAndPermutation =
209 stk::mesh::get_ordinal_and_permutation(bulk, elem, rank, nodes);
210
211 stk::mesh::Permutation gold_permutation = ordinalAndPermutation.second;
212 ASSERT_TRUE(gold_permutation!=stk::mesh::INVALID_PERMUTATION);
213
214 unsigned sides_element_offset = stk::mesh::INVALID_CONNECTIVITY_ORDINAL;
215 unsigned num_elems = bulk.num_elements(side);
216 const stk::mesh::Entity *elements = bulk.begin_elements(side);
217 for (unsigned i=0;i<num_elems;++i)
218 {
219 if (elements[i]==elem)
220 {
221 sides_element_offset = static_cast<stk::mesh::ConnectivityOrdinal>(i);
222 break;
223 }
224 }
225
226 EXPECT_EQ(gold_permutation, perms[sides_element_offset]);
227
228 stk::mesh::ConnectivityOrdinal elements_side_offset = stk::mesh::INVALID_CONNECTIVITY_ORDINAL;
229
230 unsigned num_sides = bulk.num_connectivity(elem, rank);
231 const stk::mesh::Entity *sides = bulk.begin(elem, rank);
232 for (unsigned i=0;i<num_sides;++i)
233 {
234 if (sides[i]==side)
235 {
236 elements_side_offset = static_cast<stk::mesh::ConnectivityOrdinal>(i);
237 break;
238 }
239 }
240
241 stk::mesh::Permutation const *perms2 = bulk.begin_permutations(elem, rank);
242 EXPECT_EQ(gold_permutation, perms2[elements_side_offset]);
243 }
244
245 bool does_rank_have_permutation(stk::mesh::EntityRank rank)
246 {
247 return rank > stk::topology::NODE_RANK && rank < stk::topology::CONSTRAINT_RANK;
248 }
249
250 class BucketHex : public stk::mesh::fixtures::TestHexFixture {};
251
252 TEST_F(BucketHex, testing_valid_permutation_on_various_ranks)
253 {
254 const int num_procs_this_test_works_for = 1;
255 if (stk::parallel_machine_size(MPI_COMM_WORLD) == num_procs_this_test_works_for)
256 {
257 const unsigned num_entity_rank_ranks = 5;
258 std::vector< std::string > entity_rank_names(num_entity_rank_ranks);
259 entity_rank_names[stk::topology::NODE_RANK] = std::string("NODE");
260 entity_rank_names[stk::topology::EDGE_RANK] = std::string("EDGE");
261 entity_rank_names[stk::topology::FACE_RANK] = std::string("FACE");
262 entity_rank_names[stk::topology::ELEM_RANK] = std::string("ELEMENT");
263 entity_rank_names[stk::topology::CONSTRAINT_RANK] = std::string("CONSTRAINT");
264
265 setup_mesh(1, 1, 1, entity_rank_names);
266 stk::mesh::MetaData& meta = get_meta();
267 stk::mesh::BulkData& bulk = get_bulk();
268
269 const unsigned num_nodes_on_one_hex = 8;
270 stk::mesh::EntityVector nodes(num_nodes_on_one_hex);
271 for (size_t i=0;i<nodes.size();++i)
272 {
273 stk::mesh::EntityId id = i+1;
274 nodes[i] = bulk.get_entity(stk::topology::NODE_RANK, id);
275 }
276
277 stk::mesh::EntityId id = 1;
278 stk::mesh::EntityVector entities(5);
279 entities[stk::topology::NODE_RANK] = bulk.get_entity(stk::topology::NODE_RANK, id);
280 entities[stk::topology::ELEM_RANK] = bulk.get_entity(stk::topology::ELEM_RANK, id);
281
282 bulk.modification_begin();
283
284 entities[stk::topology::CONSTRAINT_RANK] = bulk.declare_entity(stk::topology::CONSTRAINT_RANK, id, meta.universal_part());
285
286 enum node { FIRST_NODE=0, SECOND_NODE=1, THIRD_NODE=2, FOURTH_NODE=3};
287
288 const unsigned num_nodes_on_edge = 2;
289 stk::mesh::EntityVector edge_nodes(num_nodes_on_edge);
290 edge_nodes[FIRST_NODE] = nodes[FIRST_NODE];
291 edge_nodes[SECOND_NODE] = nodes[SECOND_NODE];
292
293 entities[stk::topology::EDGE_RANK] = stk::unit_test_util::declare_element_to_edge_with_nodes(bulk, entities[stk::topology::ELEM_RANK],
294 edge_nodes, id, meta.get_topology_root_part(stk::topology::LINE_2));
295
296 const unsigned num_nodes_on_face = 4;
297 stk::mesh::EntityVector face_nodes(num_nodes_on_face);
298 face_nodes[FIRST_NODE] = nodes[FIRST_NODE];
299 face_nodes[SECOND_NODE] = nodes[SECOND_NODE];
300 face_nodes[THIRD_NODE] = nodes[FOURTH_NODE];
301 face_nodes[FOURTH_NODE] = nodes[THIRD_NODE];
302
303 entities[stk::topology::FACE_RANK] = stk::unit_test_util::declare_element_side_with_nodes(bulk, entities[stk::topology::ELEM_RANK],
304 face_nodes, id, meta.get_topology_root_part(stk::topology::QUAD_4));
305
306 bulk.modification_end();
307
308 for (stk::mesh::EntityRank irank=stk::topology::BEGIN_RANK; irank<stk::topology::END_RANK; ++irank)
309 {
310 for (size_t i=0;i<entities.size();++i)
311 {
312 ASSERT_TRUE(bulk.is_valid(entities[i]));
313 stk::mesh::EntityRank target_rank = irank;
314 stk::mesh::EntityRank from_rank = bulk.entity_rank(entities[i]);
315 if (does_rank_have_permutation(target_rank) && does_rank_have_permutation(from_rank))
316 {
317 EXPECT_TRUE(bulk.has_permutation(entities[i], irank));
318 }
319 else
320 {
321 EXPECT_FALSE(bulk.has_permutation(entities[i], irank));
322 }
323 }
324 }
325 }
326 }
327
328 TEST_F(BucketHex, changing_conn_on_bucket_for_face_to_element)
329 {
330 if (stk::parallel_machine_size(MPI_COMM_WORLD) == 1)
331 {
332 setup_mesh(1, 1, 1);
333 stk::mesh::MetaData& meta = get_meta();
334 stk::mesh::BulkData& bulk = get_bulk();
335
336 unsigned face_node_ids[] = { 5, 6, 8, 7 };
337 stk::mesh::EntityVector nodes(4);
338 for (size_t i=0;i<nodes.size();++i)
339 {
340 nodes[i] = bulk.get_entity(stk::topology::NODE_RANK, face_node_ids[i]);
341 }
342
343 stk::mesh::Entity elem = bulk.get_entity(stk::topology::ELEM_RANK, 1);
344 bulk.modification_begin();
345 stk::mesh::Entity side = stk::unit_test_util::declare_element_side_with_nodes(bulk, elem, nodes, 1, meta.get_topology_root_part(stk::topology::QUAD_4));
346 bulk.modification_end();
347
348 test_nodes_and_permutation(bulk, elem, side, nodes);
349
350 unsigned new_face_node_ids[] = { 5, 7, 8, 6 };
351 stk::mesh::EntityVector new_nodes(4);
352 for (size_t i=0;i<new_nodes.size();++i)
353 {
354 new_nodes[i] = bulk.get_entity(stk::topology::NODE_RANK, new_face_node_ids[i]);
355 }
356
357 std::pair<stk::mesh::ConnectivityOrdinal, stk::mesh::Permutation> ordinalAndPermutation =
358 stk::mesh::get_ordinal_and_permutation(bulk, elem, stk::topology::FACE_RANK, new_nodes);
359
360 stk::mesh::Permutation new_permutation = ordinalAndPermutation.second;
361
362 unsigned faces_element_offset = stk::mesh::INVALID_CONNECTIVITY_ORDINAL;
363 const stk::mesh::ConnectedEntities elements = bulk.get_connected_entities(side, stk::topology::ELEM_RANK);
364 for (unsigned i=0;i<elements.size();++i)
365 {
366 if (elements[i]==elem)
367 {
368 faces_element_offset = static_cast<stk::mesh::ConnectivityOrdinal>(i);
369 break;
370 }
371 }
372
373 unsigned elements_face_offset = stk::mesh::INVALID_CONNECTIVITY_ORDINAL;
374 const stk::mesh::ConnectedEntities faces = bulk.get_connected_entities(elem, stk::topology::FACE_RANK);
375 for (unsigned i=0;i<faces.size();++i)
376 {
377 if (faces[i]==side)
378 {
379 elements_face_offset = static_cast<stk::mesh::ConnectivityOrdinal>(i);
380 break;
381 }
382 }
383
384 ASSERT_TRUE(elements_face_offset!=stk::mesh::INVALID_CONNECTIVITY_ORDINAL);
385
386 stk::mesh::unit_test::BucketTester& bucket_side = static_cast<stk::mesh::unit_test::BucketTester&>(bulk.bucket(side));
387 bucket_side.my_change_connected_nodes(bulk.bucket_ordinal(side), &new_nodes[0]);
388 bucket_side.my_change_existing_permutation_for_connected_element(bulk.bucket_ordinal(side), faces_element_offset, new_permutation);
389
390 stk::mesh::unit_test::BucketTester& bucket_elem = static_cast<stk::mesh::unit_test::BucketTester&>(bulk.bucket(elem));
391
392 bucket_elem.my_change_existing_permutation_for_connected_face(bulk.bucket_ordinal(elem), elements_face_offset, new_permutation);
393
394 test_nodes_and_permutation(bulk, elem, side, new_nodes);
395 }
396 }
397
398 TEST_F(BucketHex, changing_conn_on_bucket_for_edge_to_element)
399 {
400 if (stk::parallel_machine_size(MPI_COMM_WORLD) == 1)
401 {
402 setup_mesh(1, 1, 1);
403 stk::mesh::MetaData& meta = get_meta();
404 stk::mesh::BulkData& bulk = get_bulk();
405
406 unsigned edge_node_ids[] = { 5, 6 };
407 stk::mesh::EntityVector nodes(2);
408 for (size_t i=0;i<nodes.size();++i)
409 nodes[i] = bulk.get_entity(stk::topology::NODE_RANK, edge_node_ids[i]);
410
411 stk::mesh::Entity elem = bulk.get_entity(stk::topology::ELEM_RANK, 1);
412 bulk.modification_begin();
413 stk::mesh::Entity edge = stk::unit_test_util::declare_element_to_edge_with_nodes(bulk, elem, nodes, 1, meta.get_topology_root_part(stk::topology::LINE_2));
414 bulk.modification_end();
415
416 test_nodes_and_permutation(bulk, elem, edge, nodes);
417
418 unsigned new_face_node_ids[] = { 6, 5 };
419 stk::mesh::EntityVector new_nodes(2);
420 for (size_t i=0;i<new_nodes.size();++i)
421 new_nodes[i] = bulk.get_entity(stk::topology::NODE_RANK, new_face_node_ids[i]);
422
423 std::pair<stk::mesh::ConnectivityOrdinal, stk::mesh::Permutation> ordinalAndPermutation =
424 stk::mesh::get_ordinal_and_permutation(bulk, elem, stk::topology::EDGE_RANK, new_nodes);
425
426 stk::mesh::Permutation new_permutation = ordinalAndPermutation.second;
427
428 unsigned edges_element_offset = stk::mesh::INVALID_CONNECTIVITY_ORDINAL;
429 unsigned num_elems = bulk.num_elements(edge);
430 const stk::mesh::Entity *elements = bulk.begin_elements(edge);
431 for (unsigned i=0;i<num_elems;++i)
432 {
433 if (elements[i]==elem)
434 {
435 edges_element_offset = static_cast<stk::mesh::ConnectivityOrdinal>(i);
436 break;
437 }
438 }
439
440 unsigned elements_edge_offset = stk::mesh::INVALID_CONNECTIVITY_ORDINAL;
441 unsigned num_edges = bulk.num_edges(elem);
442 const stk::mesh::Entity *edges = bulk.begin_edges(elem);
443 for (unsigned i=0;i<num_edges;++i)
444 {
445 if (edges[i]==edge)
446 {
447 elements_edge_offset = static_cast<stk::mesh::ConnectivityOrdinal>(i);
448 break;
449 }
450 }
451
452 ASSERT_TRUE(elements_edge_offset != stk::mesh::INVALID_CONNECTIVITY_ORDINAL);
453
454 stk::mesh::unit_test::BucketTester& bucket_edge = static_cast<stk::mesh::unit_test::BucketTester&>(bulk.bucket(edge));
455
456 bucket_edge.my_change_connected_nodes(bulk.bucket_ordinal(edge), &new_nodes[0]);
457 bucket_edge.my_change_existing_permutation_for_connected_element(bulk.bucket_ordinal(edge), edges_element_offset, new_permutation);
458
459 stk::mesh::unit_test::BucketTester& bucket_elem = static_cast<stk::mesh::unit_test::BucketTester&>(bulk.bucket(elem));
460
461 bucket_elem.my_change_existing_permutation_for_connected_edge(bulk.bucket_ordinal(elem), elements_edge_offset, new_permutation);
462
463 test_nodes_and_permutation(bulk, elem, edge, new_nodes);
464 }
465 }
466
467 #ifdef STK_USE_DEVICE_MESH
468 void do_nonmodifying_debug_check(const stk::mesh::BulkData & bulk, const stk::mesh::FieldBase & coordsField)
469 {
470 const stk::mesh::BucketVector & buckets = bulk.buckets(stk::topology::NODE_RANK);
471 ASSERT_EQ(buckets.size(), 1u);
472
473 buckets[0]->check_size_invariant();
474
475 EXPECT_FALSE(buckets[0]->get_ngp_field_bucket_is_modified(coordsField.mesh_meta_data_ordinal()));
476 }
477
478 void do_modifying_entity_creation(stk::mesh::BulkData & bulk, const stk::mesh::FieldBase & coordsField)
479 {
480 unsigned face_node_ids[] = { 5, 6, 8, 7 };
481 stk::mesh::EntityVector nodes(4);
482 for (size_t i = 0 ; i < nodes.size(); ++i) {
483 nodes[i] = bulk.get_entity(stk::topology::NODE_RANK, face_node_ids[i]);
484 }
485
486 const stk::mesh::MetaData & meta = bulk.mesh_meta_data();
487 stk::mesh::Entity elem = bulk.get_entity(stk::topology::ELEM_RANK, 1);
488 bulk.modification_begin();
489 stk::unit_test_util::declare_element_side_with_nodes(bulk, elem, nodes, 1, meta.get_topology_root_part(stk::topology::QUAD_4));
490 bulk.modification_end();
491
492 const stk::mesh::BucketVector & buckets = bulk.buckets(stk::topology::NODE_RANK);
493 ASSERT_EQ(buckets.size(), 2u);
494 EXPECT_TRUE(buckets[0]->get_ngp_field_bucket_is_modified(coordsField.mesh_meta_data_ordinal()));
495 EXPECT_TRUE(buckets[1]->get_ngp_field_bucket_is_modified(coordsField.mesh_meta_data_ordinal()));
496 }
497
498 TEST_F(BucketHex, checkModifiedStatus)
499 {
500 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
501
502 setup_mesh(1, 1, 1);
503 stk::mesh::MetaData& meta = get_meta();
504 stk::mesh::BulkData& bulk = get_bulk();
505
506 const stk::mesh::FieldBase & coordsField = *meta.coordinate_field();
507 stk::mesh::get_updated_ngp_field<double>(coordsField);
508
509 do_nonmodifying_debug_check(bulk, coordsField);
510 do_modifying_entity_creation(bulk, coordsField);
511 }
512 #endif
513
514 }