12 #include <stk_util/unit_test_support/stk_utest_macros.hpp> 14 #include <stk_mesh/fixtures/BoxFixture.hpp> 15 #include <stk_mesh/fixtures/HexFixture.hpp> 16 #include <stk_mesh/fixtures/QuadFixture.hpp> 18 #include <stk_mesh/fem/FEMMetaData.hpp> 20 #include <stk_mesh/base/EntityComm.hpp> 21 #include <stk_mesh/base/FieldData.hpp> 31 void new_insert_transitive_closure( std::set<stk_classic::mesh::EntityProc,stk_classic::mesh::EntityLess> & ,
33 void new_comm_sync_send_recv(
35 std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > & new_send ,
36 std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > & new_recv );
38 void new_comm_recv_to_send(
40 const std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > & new_recv ,
41 std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > & new_send );
52 unsigned block_size = 1000) :
53 BoxFixture(pm, block_size),
55 m_cell_part ( m_fem_meta.
declare_part (
"Cell list" , 3 ) ),
56 m_part_A_0 ( m_fem_meta.
declare_part (
"Part A 0", 0 ) ),
57 m_part_A_1 ( m_fem_meta.
declare_part (
"Part A 1", 1 ) ),
58 m_part_A_2 ( m_fem_meta.
declare_part (
"Part A 2", 2 ) ),
59 m_part_A_3 ( m_fem_meta.
declare_part (
"Part A 3", 3 ) ),
60 m_part_A_superset ( m_fem_meta.
declare_part (
"Part A superset" ) ),
61 m_part_B_0 ( m_fem_meta.
declare_part (
"Part B 0", 0 ) ),
62 m_part_B_1 ( m_fem_meta.
declare_part (
"Part B 1", 1 ) ),
63 m_part_B_2 ( m_fem_meta.
declare_part (
"Part B 2", 2 ) ),
64 m_part_B_3 ( m_fem_meta.
declare_part (
"Part B 3", 3 ) ),
65 m_part_B_superset ( m_fem_meta.
declare_part (
"Part B superset" ) )
67 m_fem_meta.declare_part_subset ( m_part_A_superset , m_part_A_0 );
68 m_fem_meta.declare_part_subset ( m_part_A_superset , m_part_A_1 );
69 m_fem_meta.declare_part_subset ( m_part_A_superset , m_part_A_2 );
70 m_fem_meta.declare_part_subset ( m_part_A_superset , m_part_A_3 );
72 m_fem_meta.declare_part_subset ( m_part_B_superset , m_part_B_0 );
73 m_fem_meta.declare_part_subset ( m_part_B_superset , m_part_B_1 );
74 m_fem_meta.declare_part_subset ( m_part_B_superset , m_part_B_2 );
75 m_fem_meta.declare_part_subset ( m_part_B_superset , m_part_B_3 );
83 Part & get_test_part () {
return m_test_part; }
84 Part & get_cell_part () {
return m_cell_part; }
86 Part & get_part_a_0 () {
return m_part_A_0; }
87 Part & get_part_a_1 () {
return m_part_A_1; }
88 Part & get_part_a_2 () {
return m_part_A_2; }
89 Part & get_part_a_3 () {
return m_part_A_3; }
91 Part & get_part_a_superset () {
return m_part_A_superset; }
93 Part & get_part_b_0 () {
return m_part_B_0; }
94 Part & get_part_b_1 () {
return m_part_B_1; }
95 Part & get_part_b_2 () {
return m_part_B_2; }
96 Part & get_part_b_3 () {
return m_part_B_3; }
98 Part & get_part_b_superset () {
return m_part_B_superset; }
109 Part & m_part_A_superset;
116 Part & m_part_B_superset;
121 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyAssertOwnerDeletedEntity )
123 TestBoxFixture fixture;
128 add_part.push_back ( &new_part );
130 const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } };
131 int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } };
134 fixture.generate_boxes( root_box, local_box );
140 std::vector<stk_classic::mesh::Bucket *>::const_iterator cur_bucket = bulk.
buckets(3).begin();
141 while ( cur_bucket != bulk.
buckets(3).end() )
143 stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin();
144 while ( cur_entity != (*cur_bucket)->end() )
146 if ( cur_entity->owner_rank() == fixture.comm_rank() )
148 cell_to_delete = &*cur_entity;
156 STKUNIT_ASSERT ( cell_to_delete != NULL );
157 cell_to_delete_copy = cell_to_delete;
161 STKUNIT_ASSERT(
false == bulk.
destroy_entity( cell_to_delete_copy ) );
166 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyDetectsBadKey )
168 TestBoxFixture fixture;
173 add_part.push_back ( &new_part );
188 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyDetectsNonOwnerChange )
199 fixture.m_fem_meta.commit();
200 fixture.generate_mesh();
207 if ( p_size > 1 && shared_node && (p_rank == 0 || p_rank == 1) ) {
208 STKUNIT_ASSERT_GE(shared_node->
sharing().size(), 1u);
215 if (shared_node && p_rank != shared_node->
owner_rank()) {
225 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyGetEntityGuards )
227 TestBoxFixture fixture;
230 STKUNIT_ASSERT_THROW ( bulk.
get_entity ( 1 , 0 ) , std::logic_error );
234 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyExplicitAddInducedPart )
236 TestBoxFixture fixture;
248 cell_part_vector.push_back ( &fixture.get_cell_part () );
250 #ifdef SIERRA_MIGRATION 253 STKUNIT_ASSERT_THROW ( bulk.
change_entity_parts ( new_node , cell_part_vector ) , std::runtime_error );
282 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyDefaultPartAddition )
284 TestBoxFixture fixture;
291 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.fem_meta().universal_part() ) );
292 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.fem_meta().locally_owned_part() ) );
295 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyChangePartsSerial )
297 TestBoxFixture fixture;
301 create_parts.push_back ( &fixture.get_test_part() );
302 create_parts.push_back ( &fixture.get_part_a_3() );
303 remove_parts.push_back ( &fixture.get_part_a_3() );
304 add_parts.push_back ( &fixture.get_part_b_superset() );
305 add_parts.push_back ( &fixture.get_cell_part() );
311 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.get_test_part() ) );
312 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.get_part_a_3() ) );
313 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.get_part_a_superset() ) );
314 STKUNIT_ASSERT ( !new_cell.
bucket().
member ( fixture.get_part_b_superset() ) );
315 STKUNIT_ASSERT ( !new_cell.
bucket().
member ( fixture.get_cell_part() ) );
320 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.get_test_part() ) );
321 STKUNIT_ASSERT ( !new_cell.
bucket().
member ( fixture.get_part_a_3() ) );
322 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.get_part_a_superset() ) );
323 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.get_part_b_superset() ) );
324 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.get_cell_part() ) );
329 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.get_test_part() ) );
330 STKUNIT_ASSERT ( !new_cell.
bucket().
member ( fixture.get_part_a_3() ) );
331 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.get_part_a_superset() ) );
332 STKUNIT_ASSERT ( !new_cell.
bucket().
member ( fixture.get_part_b_superset() ) );
333 STKUNIT_ASSERT ( !new_cell.
bucket().
member ( fixture.get_cell_part() ) );
336 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.fem_meta().universal_part() ) );
337 STKUNIT_ASSERT ( new_cell.
bucket().
member ( fixture.fem_meta().locally_owned_part() ) );
340 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyParallelAddParts )
342 TestBoxFixture fixture;
346 const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } };
347 int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } };
349 add_part.push_back ( &fixture.get_part_a_0() );
352 fixture.generate_boxes( root_box, local_box );
357 for ( std::vector<stk_classic::mesh::Entity*>::const_iterator
359 cur_entity != bulk.
entity_comm().end() ; ++cur_entity ) {
361 if ( entity.entity_rank() == 0 ) {
362 if ( entity.owner_rank() == fixture.comm_rank() ) {
370 for ( std::vector<stk_classic::mesh::Entity*>::const_iterator
372 cur_entity != bulk.
entity_comm().end() ; ++cur_entity ) {
374 if ( entity.entity_rank() == 0 ) {
375 STKUNIT_ASSERT ( entity.bucket().member ( fixture.get_part_a_0 () ) );
380 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyInducedMembership )
382 TestBoxFixture fixture;
386 create_node_parts.push_back ( &fixture.get_part_a_0() );
387 create_cell_parts.push_back ( &fixture.get_cell_part() );
399 stk_classic::mesh::RelationIdentifier cell_node_rel_id = 0;
403 STKUNIT_ASSERT ( node.
bucket().
member ( fixture.get_cell_part() ) );
409 STKUNIT_ASSERT ( !node.
bucket().
member ( fixture.get_cell_part() ) );
412 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyCanRemoveFromSetWithDifferentRankSubset )
414 TestBoxFixture fixture;
418 add_parts.push_back ( &fixture.get_part_b_3() );
419 add_parts.push_back ( &fixture.get_part_a_superset() );
421 remove_parts.push_back ( &fixture.get_part_a_superset() );
432 STKUNIT_ASSERT ( e.
bucket().
member ( fixture.get_part_b_3() ) );
433 STKUNIT_ASSERT ( !e.
bucket().
member ( fixture.get_part_a_superset() ) );
437 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyCommonGhostingName )
440 TestBoxFixture fixture;
445 if ( fixture.comm_size() == 1 )
return;
447 if ( fixture.comm_rank() == 0 )
449 STKUNIT_ASSERT_THROW ( bulk.
create_ghosting (
"Name 1" ) , std::runtime_error );
453 STKUNIT_ASSERT_THROW ( bulk.
create_ghosting (
"Name 2" ) , std::runtime_error );
458 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyTrivialDestroyAllGhostings )
460 TestBoxFixture fixture;
462 if ( fixture.comm_size() == 1 )
return;
466 const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } };
467 int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } };
470 fixture.generate_boxes( root_box, local_box );
478 std::vector<stk_classic::mesh::Bucket *>::const_iterator cur_bucket = bulk.
buckets(3).begin();
479 unsigned send_rank = 0;
481 std::vector<stk_classic::mesh::EntityProc> to_send;
482 std::vector<stk_classic::mesh::Entity *> empty_vector;
483 while ( cur_bucket != bulk.
buckets(3).end() )
485 stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin();
486 while ( cur_entity != (*cur_bucket)->end() )
488 if ( cur_entity->owner_rank() == fixture.comm_rank() )
490 if ( send_rank == fixture.comm_size() ) send_rank = 0;
491 if ( send_rank != fixture.comm_rank() )
492 to_send.push_back ( std::make_pair ( &*cur_entity , send_rank ) );
504 std::vector<stk_classic::mesh::EntityProc> send_list ;
505 std::vector<stk_classic::mesh::Entity*> recv_list ;
509 STKUNIT_ASSERT ( ! send_list.empty() );
510 STKUNIT_ASSERT ( ! recv_list.empty() );
514 std::ostringstream oss;
522 std::vector<stk_classic::mesh::EntityProc> send_list ;
523 std::vector<stk_classic::mesh::Entity*> recv_list ;
524 ghosting.send_list( send_list );
525 ghosting.receive_list( recv_list );
527 STKUNIT_ASSERT ( send_list.empty() );
528 STKUNIT_ASSERT ( recv_list.empty() );
533 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyChangeGhostingGuards )
535 TestBoxFixture fixture1, fixture2;
539 const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } };
540 int local_box1[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } };
541 int local_box2[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } };
544 fixture1.generate_boxes( root_box, local_box1 );
548 fixture2.generate_boxes( root_box, local_box2 );
554 std::vector<stk_classic::mesh::EntityProc> to_send;
555 std::vector<stk_classic::mesh::Entity *> empty_vector;
556 std::vector<stk_classic::mesh::Bucket *>::const_iterator cur_bucket = bulk1.
buckets(3).begin();
557 unsigned send_rank = 0;
558 while ( cur_bucket != bulk1.
buckets(3).end() )
560 stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin();
561 while ( cur_entity != (*cur_bucket)->end() )
563 if ( cur_entity->owner_rank() == fixture1.comm_rank() )
565 if ( send_rank == fixture1.comm_size() ) send_rank = 0;
566 if ( send_rank != fixture1.comm_rank() )
567 to_send.push_back ( std::make_pair ( &*cur_entity , send_rank ) );
576 STKUNIT_ASSERT_THROW ( bulk2.
change_ghosting ( ghosting , to_send , empty_vector ) , std::runtime_error );
587 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyOtherGhostingGuards )
589 TestBoxFixture fixture;
592 const int root_box[3][2] = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } };
593 int local_box[3][2] = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } };
596 fixture.generate_boxes( root_box, local_box );
601 std::vector<stk_classic::mesh::EntityProc> to_send_unowned;
602 std::vector<stk_classic::mesh::EntityProc> empty_send;
603 std::vector<stk_classic::mesh::Entity *> to_remove_not_ghosted;
604 std::vector<stk_classic::mesh::Entity *> empty_remove;
605 std::vector<stk_classic::mesh::Bucket *>::const_iterator cur_bucket = bulk.
buckets(3).begin();
606 unsigned send_rank = 0;
607 while ( cur_bucket != bulk.
buckets(3).end() )
609 stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin();
610 while ( cur_entity != (*cur_bucket)->end() )
612 if ( cur_entity->owner_rank() != fixture.comm_rank() )
614 if ( send_rank == fixture.comm_size() ) send_rank = 0;
615 if ( send_rank != fixture.comm_rank() )
616 to_send_unowned.push_back ( std::make_pair ( &*cur_entity , send_rank ) );
621 to_remove_not_ghosted.push_back ( &*cur_entity );
629 if ( to_send_unowned.size() > 0 )
631 STKUNIT_ASSERT_THROW ( bulk.
change_ghosting ( ghosting , to_send_unowned , empty_remove ) , std::runtime_error );
638 if ( to_remove_not_ghosted.size() > 0 )
640 STKUNIT_ASSERT_THROW ( bulk.
change_ghosting ( ghosting , empty_send , to_remove_not_ghosted ) , std::runtime_error );
644 bulk.
change_ghosting ( ghosting , empty_send , to_remove_not_ghosted );
650 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyPartsOnCreate )
652 TestBoxFixture fixture;
658 create_vector.push_back ( &part_a );
668 create_vector.push_back ( &part_b );
678 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , verifyBoxGhosting )
681 if ( 8 < p_size ) { return ; }
684 fixture.m_fem_meta.commit();
685 fixture.generate_mesh();
687 for (
size_t iz = 0 ; iz < 3 ; ++iz ) {
688 for (
size_t iy = 0 ; iy < 3 ; ++iy ) {
689 for (
size_t ix = 0 ; ix < 3 ; ++ix ) {
691 STKUNIT_ASSERT( NULL != node );
693 STKUNIT_ASSERT( fixture.node_id(ix,iy,iz) == node->
identifier() );
694 stk_classic::mesh::fixtures::HexFixture::Scalar *
const node_coord =
696 STKUNIT_ASSERT( node_coord != NULL );
701 for (
size_t iz = 0 ; iz < 2 ; ++iz ) {
702 for (
size_t iy = 0 ; iy < 2 ; ++iy ) {
703 for (
size_t ix = 0 ; ix < 2 ; ++ix ) {
705 STKUNIT_ASSERT( NULL != elem );
708 STKUNIT_ASSERT_EQUAL( 8u , elem_nodes.size() );
709 stk_classic::mesh::fixtures::HexFixture::Scalar **
const elem_node_coord =
711 for (
size_t j = 0 ; j < elem_nodes.size() ; ++j ) {
712 STKUNIT_ASSERT_EQUAL( j , elem_nodes[j].identifier() );
713 stk_classic::mesh::fixtures::HexFixture::Scalar *
const node_coord =
715 STKUNIT_ASSERT( node_coord == elem_node_coord[ elem_nodes[j].identifier() ] );
717 if ( 8u == elem_nodes.size() ) {
718 STKUNIT_ASSERT( elem_nodes[0].entity() == fixture.node(ix,iy,iz));
719 STKUNIT_ASSERT( elem_nodes[1].entity() == fixture.node(ix+1,iy,iz));
720 STKUNIT_ASSERT( elem_nodes[2].entity() == fixture.node(ix+1,iy,iz+1));
721 STKUNIT_ASSERT( elem_nodes[3].entity() == fixture.node(ix,iy,iz+1));
722 STKUNIT_ASSERT( elem_nodes[4].entity() == fixture.node(ix,iy+1,iz));
723 STKUNIT_ASSERT( elem_nodes[5].entity() == fixture.node(ix+1,iy+1,iz));
724 STKUNIT_ASSERT( elem_nodes[6].entity() == fixture.node(ix+1,iy+1,iz+1));
725 STKUNIT_ASSERT( elem_nodes[7].entity() == fixture.node(ix,iy+1,iz+1));
733 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , testEntityComm )
739 const int spatial_dimension = 3;
742 fem_meta.
FEM_initialize(spatial_dimension, stk_classic::mesh::fem::entity_rank_names ( spatial_dimension ));
744 stk_classic::mesh::fem::CellTopology tet_top(shards::getCellTopologyData<shards::Tetrahedron<4> >());
748 stk_classic::mesh::fem::CellTopology node_top(shards::getCellTopologyData<shards::Node>());
759 put_field ( temperature , 3 , universal );
765 create_vector.push_back ( &part_a );
766 create_vector.push_back ( &part_b );
777 int new_id2 = size2 + rank_count2;
780 STKUNIT_ASSERT_EQUAL( elem2.
bucket().
member ( part_a ), true );
786 for ( id_base = 0 ; id_base < 99 ; ++id_base )
788 int new_id = size * id_base + rank_count;
790 STKUNIT_ASSERT_EQUAL( new_node.
bucket().
member ( part_a_0 ), false );
795 std::vector<stk_classic::mesh::EntityProc> add_send;
797 const std::vector<stk_classic::mesh::Bucket*> & buckets = bulk.
buckets( 0 );
799 std::vector<stk_classic::mesh::Bucket*>::const_iterator cur_bucket;
801 cur_bucket = buckets.begin();
803 unsigned send_rank = 0;
804 while ( cur_bucket != buckets.end() )
806 stk_classic::mesh::Bucket::iterator cur_entity = (*cur_bucket)->begin();
807 while ( cur_entity != (*cur_bucket)->end() )
809 if ( cur_entity->owner_rank() == rank_count )
811 if ( send_rank == size ) send_rank = 0;
812 if ( send_rank != rank_count )
813 add_send.push_back ( std::make_pair ( &*cur_entity , send_rank ) );
821 std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > new_send ;
822 std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > new_recv ;
829 for ( std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess >::iterator
830 i = new_recv.end() ; i != new_recv.begin() ; ) {
833 const unsigned erank = (*i)->entity_rank();
836 irel = (*i)->relations(); ! irel.empty() ; ++irel ) {
837 if ( irel->entity_rank() < erank &&
838 in_receive_ghost( ghosts , * irel->entity() ) ) {
839 new_recv.insert( irel->entity() );
845 new_comm_recv_to_send( bulk , new_recv , new_send );
850 for ( std::vector< stk_classic::mesh::EntityProc >::const_iterator
851 i = add_send.begin() ; i != add_send.end() ; ++i ) {
852 new_insert_transitive_closure( new_send , *i );
860 new_comm_sync_send_recv( bulk , new_send , new_recv );
872 stk_classic::CommAll comm( MPI_COMM_WORLD );
874 for ( std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator
875 j = new_send.begin(); j != new_send.end() ; ++j ) {
877 if ( ! in_ghost( ghosts , entity , j->second ) ) {
879 stk_classic::CommBuffer & buf = comm.send_buffer( j->second );
880 buf.pack<
unsigned>( entity.entity_rank() );
881 stk_classic::mesh::pack_entity_info( buf , entity );
882 stk_classic::mesh::pack_field_values( buf , entity );
886 comm.allocate_buffers( size / 4 );
888 for ( std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator
889 j = new_send.begin(); j != new_send.end() ; ++j ) {
891 if ( ! in_ghost( ghosts , entity , j->second ) ) {
893 stk_classic::CommBuffer & buf = comm.send_buffer( j->second );
894 buf.pack<
unsigned>( entity.entity_rank() );
895 stk_classic::mesh::pack_entity_info( buf , entity );
896 stk_classic::mesh::pack_field_values( buf , entity );
903 std::ostringstream error_msg ;
905 for (
unsigned rank = 0 ; rank < rank_count ; ++rank ) {
907 for (
unsigned p = 0 ; p < size ; ++p ) {
909 stk_classic::CommBuffer & buf = comm.recv_buffer(p);
911 while ( buf.remaining() ) {
917 unsigned this_rank = ~0u ;
918 buf.peek<
unsigned>( this_rank );
919 if ( this_rank != rank ) break ;
921 buf.unpack<
unsigned>( this_rank );
937 STKUNIT_UNIT_TEST ( UnitTestBulkData_new , testUninitializedMetaData )
958 void new_insert_transitive_closure( std::set<stk_classic::mesh::EntityProc,stk_classic::mesh::EntityLess> & new_send ,
964 if ( entry.second != entry.first->owner_rank() &&
965 ! in_shared( * entry.first , entry.second ) ) {
967 std::pair< std::set<stk_classic::mesh::EntityProc,stk_classic::mesh::EntityLess>::iterator ,
bool >
968 result = new_send.insert( entry );
970 if ( result.second ) {
973 const unsigned etype = entry.first->entity_rank();
976 for ( ; ! irel.empty() ; ++irel ) {
977 if ( irel->entity_rank() < etype ) {
979 new_insert_transitive_closure( new_send , tmp );
989 void new_comm_sync_send_recv(
991 std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > & new_send ,
992 std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > & new_recv )
997 stk_classic::CommAll all( mesh.
parallel() );
1001 for ( std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator
1002 i = new_send.begin() ; i != new_send.end() ; ++i ) {
1003 const unsigned owner = i->first->owner_rank();
1013 for ( std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator
1014 i = new_send.begin() ; i != new_send.end() ; ) {
1015 const unsigned owner = i->first->owner_rank();
1024 const uint64_t &proc = i->second;
1026 all.send_buffer( i->second ).pack(entity_key).pack(proc);
1031 all.send_buffer( owner ).pack(entity_key).pack(proc);
1035 std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess >::iterator jrem = i ; ++i ;
1036 new_send.erase( jrem );
1047 stk_classic::CommBuffer & buf = all.recv_buffer(p);
1048 while ( buf.remaining() ) {
1053 buf.unpack(entity_key).unpack(proc);
1060 STKUNIT_ASSERT( e != NULL );
1062 new_send.insert( tmp );
1064 else if ( e != NULL ) {
1069 new_recv.insert( e );
1075 void new_comm_recv_to_send(
1077 const std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess > & new_recv ,
1078 std::set< stk_classic::mesh::EntityProc , stk_classic::mesh::EntityLess > & new_send )
1082 stk_classic::CommAll all( mesh.
parallel() );
1084 for ( std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess >::const_iterator
1085 i = new_recv.begin() ; i != new_recv.end() ; ++i ) {
1086 const unsigned owner = (*i)->owner_rank();
1092 for ( std::set< stk_classic::mesh::Entity * , stk_classic::mesh::EntityLess >::const_iterator
1093 i = new_recv.begin() ; i != new_recv.end() ; ++i ) {
1094 const unsigned owner = (*i)->owner_rank();
1102 stk_classic::CommBuffer & buf = all.recv_buffer(p);
1103 while ( buf.remaining() ) {
1107 new_send.insert( tmp );
void declare_relation(Entity &e_from, Entity &e_to, const RelationIdentifier local_id)
Declare a relation and its converse between entities in the same mesh.
PairIterEntityComm sharing() const
Parallel processes which share this entity.
Ghosting & create_ghosting(const std::string &name)
Asymmetric parallel relations for owner-to-ghosted mesh entities.
const std::vector< Entity * > & entity_comm() const
All entities with communication information.
Data for ghosting mesh entities.
bool destroy_relation(Entity &e_from, Entity &e_to, const RelationIdentifier local_id)
Remove all relations between two entities.
FieldTraits< field_type >::data_type * field_data(const field_type &f, const Bucket::iterator i)
Pointer to the field data array.
Bucket & bucket() const
The bucket which holds this mesh entity's field data.
const std::vector< Bucket * > & buckets(EntityRank rank) const
Query all buckets of a given entity rank.
void change_ghosting(Ghosting &ghosts, const std::vector< EntityProc > &add_send, const std::vector< Entity *> &remove_receive)
Change the members of a ghosting list on the sending processor.
field_type & put_field(field_type &field, EntityRank entity_rank, const Part &part, const void *init_value=NULL)
Declare a field to exist for a given entity type and Part.
Ghosting & shared_aura() const
Query the shared-entity aura. Is likely to be stale if ownership or sharing has changed and the 'modi...
Entity * get_entity(EntityRank entity_rank, EntityId entity_id) const
Get entity with a given key.
Integer type for the entity keys, which is an encoding of the entity type and entity identifier...
std::pair< Entity *, unsigned > EntityProc
Pairing of an entity with a processor rank.
int parallel_rank()
function parallel_rank returns the rank of this processor in the current mpi communicator.
An application-defined subset of a problem domain.
unsigned parallel_machine_rank(ParallelMachine parallel_machine)
Member function parallel_machine_rank ...
void change_entity_parts(Entity &entity, const PartVector &add_parts, const PartVector &remove_parts=PartVector())
Change the parallel-locally-owned entity's part membership by adding and/or removing parts...
void destroy_all_ghosting()
Empty every single Ghosting. Same result, but more efficient than, calling change_ghosting to remove ...
ParallelMachine parallel() const
The parallel machine.
void receive_list(std::vector< Entity * > &) const
Entities ghosted on this processor from the owner.
bool modification_end()
Parallel synchronization of modifications and transition to the guaranteed parallel consistent state...
unsigned parallel_size() const
Size of the parallel machine.
bool modification_begin()
Begin a modification phase during which the mesh bulk data could become parallel inconsistent. This is a parallel synchronous call. The first time this method is called the mesh meta data is verified to be committed and parallel consistent. An exception is thrown if this verification fails.
PairIterRelation relations() const
All Entity relations for which this entity is a member. The relations are ordered from lowest entity-...
unsigned parallel_machine_size(ParallelMachine parallel_machine)
Member function parallel_machine_size ...
Manager for an integrated collection of entities, entity relations, and buckets of field data...
EntityId entity_id(const EntityKey &key)
Given an entity key, return the identifier for the entity.
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
Part & declare_part(FEMMetaData &meta_data, const std::string &name)
Declare a part with a given cell topology. This is just a convenient function that wraps FEMMetaData'...
void send_list(std::vector< EntityProc > &) const
Locally owned entities ghosted on other processors.
int parallel_size()
function parallel_size returns the number of processors in the current mpi communicator.
unsigned parallel_rank() const
Rank of the parallel machine's local processor.
Entity & declare_entity(EntityRank ent_rank, EntityId ent_id, const PartVector &parts)
Create or retrieve a locally owned entity of a given rank and id.
EntityId identifier() const
Identifier for this entity which is globally unique for a given entity type.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
EntityRank entity_rank(const EntityKey &key)
Given an entity key, return an entity type (rank).
bool destroy_entity(Entity *&entity)
Request the destruction an entity on the local process.
bool member(const Part &) const
Bucket is a subset of the given part.
unsigned owner_rank() const
Parallel processor rank of the processor which owns this entity.