10 #include <stk_util/unit_test_support/stk_utest_macros.hpp> 12 #include <stk_mesh/fixtures/BoxFixture.hpp> 14 #include <stk_mesh/base/MetaData.hpp> 15 #include <stk_mesh/base/BulkData.hpp> 16 #include <stk_mesh/base/Entity.hpp> 17 #include <stk_mesh/base/Selector.hpp> 18 #include <stk_mesh/base/GetEntities.hpp> 24 using stk_classic::mesh::EntityId;
25 using stk_classic::mesh::EntityRank;
30 const EntityRank NODE_RANK = FEMMetaData::NODE_RANK;
35 static void expose_box_partition(
int ip ,
int up ,
int axis ,
45 STKUNIT_UNIT_TEST( UnitTestBoxFixture, verifyBoxFixture )
55 const BoxFixture::BOX root_box = { { 0 , 4 } , { 0 , 5 } , { 0 , 6 } };
56 BoxFixture::BOX local_box = { { 0 , 0 } , { 0 , 0 } , { 0 , 0 } };
60 BulkData& bulk = fixture.bulk_data();
67 BoxFixture::BOX *
const p_box =
new BoxFixture::BOX[ p_size ];
68 ExposePartition::expose_box_partition( 0, p_size, 2, root_box, &p_box[0] );
73 fixture.generate_boxes( root_box, local_box );
75 const unsigned nx = local_box[0][1] - local_box[0][0] ;
76 const unsigned ny = local_box[1][1] - local_box[1][0] ;
77 const unsigned nz = local_box[2][1] - local_box[2][0] ;
79 const unsigned e_local = nx * ny * nz ;
80 const unsigned n_local = ( nx + 1 ) * ( ny + 1 ) * ( nz + 1 );
82 const unsigned ngx = root_box[0][1] - root_box[0][0] ;
83 const unsigned ngy = root_box[1][1] - root_box[1][0] ;
85 std::vector<unsigned> local_count ;
89 for (
int k = local_box[2][0] ; k < local_box[2][1] ; ++k ) {
90 for (
int j = local_box[1][0] ; j < local_box[1][1] ; ++j ) {
91 for (
int i = local_box[0][0] ; i < local_box[0][1] ; ++i ) {
93 const EntityId n0= 1 + (i+0) + (j+0) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1);
94 const EntityId n1= 1 + (i+1) + (j+0) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1);
95 const EntityId n2= 1 + (i+1) + (j+1) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1);
96 const EntityId n3= 1 + (i+0) + (j+1) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1);
97 const EntityId n4= 1 + (i+0) + (j+0) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1);
98 const EntityId n5= 1 + (i+1) + (j+0) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1);
99 const EntityId n6= 1 + (i+1) + (j+1) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1);
100 const EntityId n7= 1 + (i+0) + (j+1) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1);
102 const EntityId elem_id = 1 + i + j * ngx + k * ngx * ngy;
104 std::vector<Entity*> nodes(8);
116 std::vector<Entity*> elems ;
118 STKUNIT_ASSERT_EQUAL( elems.size() , size_t(1) );
119 STKUNIT_ASSERT_EQUAL( elems[0] , elem );
122 STKUNIT_ASSERT_EQUAL( elems.size() , size_t(1) );
123 STKUNIT_ASSERT_EQUAL( elems[0] , elem );
130 Selector select_used = select_owned |
135 STKUNIT_ASSERT_EQUAL( e_local , local_count[3] );
136 STKUNIT_ASSERT_EQUAL( 0u , local_count[2] );
137 STKUNIT_ASSERT_EQUAL( 0u , local_count[1] );
138 STKUNIT_ASSERT_EQUAL( n_local , local_count[0] );
145 STKUNIT_ASSERT_EQUAL( local_count[3] , e_local );
146 STKUNIT_ASSERT_EQUAL( local_count[2] , 0u );
147 STKUNIT_ASSERT_EQUAL( local_count[1] , 0u );
148 STKUNIT_ASSERT_EQUAL( local_count[0] , n_local );
150 for (
int k = local_box[2][0] ; k <= local_box[2][1] ; ++k ) {
151 for (
int j = local_box[1][0] ; j <= local_box[1][1] ; ++j ) {
152 for (
int i = local_box[0][0] ; i <= local_box[0][1] ; ++i ) {
153 EntityRank node_type = 0;
154 EntityId node_id = 1 + i + j * (ngx+1) + k * (ngx+1) * (ngy+1);
156 STKUNIT_ASSERT( node != NULL );
159 ( k == local_box[2][0] && k != root_box[2][0] ) ||
160 ( k == local_box[2][1] && k != root_box[2][1] ) ||
161 ( j == local_box[1][0] && j != root_box[1][0] ) ||
162 ( j == local_box[1][1] && j != root_box[1][1] ) ||
163 ( i == local_box[0][0] && i != root_box[0][0] ) ||
164 ( i == local_box[0][1] && i != root_box[0][1] );
166 STKUNIT_ASSERT_EQUAL( shared , ! node->sharing().empty() );
172 size_t count_shared_node_pairs = 0 ;
173 for (
unsigned p = 0 ; p < p_size ; ++p )
if ( p != p_rank ) {
174 for (
int k = p_box[p][2][0] ; k <= p_box[p][2][1] ; ++k )
175 if ( local_box[2][0] <= k && k <= local_box[2][1] ) {
177 for (
int j = p_box[p][1][0] ; j <= p_box[p][1][1] ; ++j )
178 if ( local_box[1][0] <= j && j <= local_box[1][1] ) {
180 for (
int i = p_box[p][0][0] ; i <= p_box[p][0][1] ; ++i )
181 if ( local_box[0][0] <= i && i <= local_box[0][1] ) {
183 EntityRank node_type = 0;
184 EntityId node_id = 1 + i + j * (ngx+1) + k * (ngx+1) * (ngy+1);
186 STKUNIT_ASSERT( node != NULL );
189 for ( ; ! iter.empty() && iter->proc != p ; ++iter );
190 STKUNIT_ASSERT( ! iter.empty() );
192 ++count_shared_node_pairs ;
198 size_t count_shared_entities = 0 ;
199 for (std::vector<Entity*>::const_iterator
204 count_shared_entities += ec.size();
206 STKUNIT_ASSERT_EQUAL( count_shared_entities , count_shared_node_pairs );
const std::vector< Entity * > & entity_comm() const
All entities with communication information.
This is a class for selecting buckets based on a set of meshparts and set logic.
Entity * get_entity(EntityRank entity_rank, EntityId entity_id) const
Get entity with a given key.
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.
Manager for an integrated collection of entities, entity relations, and buckets of field data...
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
void count_entities(const Selector &selector, const BulkData &mesh, std::vector< EntityRank > &count)
Local count selected entities of each type.
void get_entities_through_relations(const std::vector< Entity *> &entities, std::vector< Entity *> &entities_related)
Query which mesh entities have a relation to all of the input mesh entities.
unsigned parallel_rank() const
Rank of the parallel machine's local processor.
static void box_partition(int ip, int up, int axis, const BOX box, BOX p_box[])