14 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
16 #include <stk_util/parallel/Parallel.hpp>
18 #include <stk_mesh/base/Types.hpp>
19 #include <stk_mesh/base/MetaData.hpp>
20 #include <stk_mesh/base/Entity.hpp>
21 #include <stk_mesh/base/EntityKey.hpp>
22 #include <stk_mesh/base/Field.hpp>
23 #include <stk_mesh/base/Bucket.hpp>
24 #include <stk_mesh/base/BulkData.hpp>
25 #include <stk_mesh/base/Ghosting.hpp>
26 #include <stk_mesh/base/Field.hpp>
28 #include <stk_mesh/baseImpl/EntityRepository.hpp>
30 #include <stk_mesh/fem/FEMMetaData.hpp>
41 using stk_classic::mesh::impl::PartRepository;
42 using stk_classic::mesh::impl::EntityRepository;
48 STKUNIT_UNIT_TEST(UnitTestEntity,testEntityKey)
65 STKUNIT_ASSERT( 1 ==
entity_id( key_good_0_1) );
66 STKUNIT_ASSERT( 1 ==
entity_id( key_good_1_1) );
67 STKUNIT_ASSERT( 10 ==
entity_id( key_good_2_10) );
69 STKUNIT_ASSERT( key_order_1_12 < key_order_2_10);
70 STKUNIT_ASSERT( !( key_order_1_12 > key_order_2_10));
73 STKUNIT_ASSERT_THROW(
EntityKey( ~0u , 1 ) , std::logic_error );
74 STKUNIT_ASSERT_THROW(
EntityKey( 0 , ~stk_classic::mesh::EntityKey::raw_key_type(0) ) , std::logic_error );
79 STKUNIT_UNIT_TEST(UnitTestEntity,testEntityRepository)
82 const int spatial_dimension = 3;
83 MetaData meta(stk_classic::mesh::fem::entity_rank_names(spatial_dimension));
84 Part & part = meta.declare_part(
"another part");
85 MPI_Barrier( MPI_COMM_WORLD );
90 std::vector<stk_classic::mesh::Part *> add_part;
99 add_part.push_back ( & part );
101 bulk.modification_begin();
104 for ( id_base = 0 ; id_base < 97 ; ++id_base )
106 int new_id = size * id_base + rank;
107 bulk.declare_entity( 0 , new_id+1 , add_part );
110 int new_id = size * (++id_base) + rank;
113 bool use_memory_pool =
false;
114 stk_classic::mesh::impl::EntityRepository e(use_memory_pool);
116 e.comm_clear( elem );
118 e.comm_clear_ghosting( elem );
122 STKUNIT_ASSERT_FALSE(e.erase_ghosting(elem, ghost));
124 const stk_classic::mesh::EntityCommInfo comm_info( ghost.
ordinal() , 0 );
126 STKUNIT_ASSERT_FALSE(e.erase_comm_info(elem, comm_info));
128 STKUNIT_ASSERT(e.insert_comm_info(elem, comm_info));
133 STKUNIT_ASSERT_THROW(bulk.modification_end(), std::runtime_error);
135 bulk.modification_begin();
146 STKUNIT_ASSERT_THROW(
161 typedef std::map<EntityKey,Entity*> EntityMap;
162 EntityMap entity_map_array;
169 Bucket *nil_bucket = bulk.buckets(3)[0];
170 e.destroy_later(elem2, nil_bucket);
172 STKUNIT_ASSERT_THROW(e.destroy_later(elem2, nil_bucket), std::runtime_error);
176 Bucket *nil_bucket2 = bulk.buckets(0)[0];
178 STKUNIT_ASSERT ( nil_bucket2 != NULL);
180 e.destroy_later(elem3, nil_bucket2);
182 STKUNIT_ASSERT_THROW(bulk.modification_end(), std::runtime_error);
184 bulk.modification_begin();
186 STKUNIT_ASSERT_THROW(e.destroy_later(elem2, nil_bucket), std::runtime_error);
188 STKUNIT_ASSERT_THROW(bulk.modification_end(), std::runtime_error);
190 bulk.modification_begin();
191 STKUNIT_ASSERT_THROW(bulk.modification_end(), std::runtime_error);