Sierra Toolkit Version of the Day
UnitTestCreateAdjacentEntities.cpp
00001 
00002 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
00003 
00004 #include <stk_util/parallel/Parallel.hpp>
00005 
00006 #include <stk_mesh/base/MetaData.hpp>
00007 #include <stk_mesh/base/BulkData.hpp>
00008 #include <stk_mesh/base/Entity.hpp>
00009 #include <stk_mesh/base/GetEntities.hpp>
00010 #include <stk_mesh/base/Selector.hpp>
00011 #include <stk_mesh/base/GetBuckets.hpp>
00012 #include <stk_mesh/base/Comm.hpp>
00013 
00014 #include <stk_mesh/fem/CreateAdjacentEntities.hpp>
00015 #include <stk_mesh/fem/FEMHelpers.hpp>
00016 
00017 #include <stk_mesh/fixtures/HexFixture.hpp>
00018 #include <stk_mesh/fixtures/QuadFixture.hpp>
00019 
00020 #include <stk_util/parallel/ParallelReduce.hpp>
00021 
00022 #include <Shards_BasicTopologies.hpp>
00023 
00024 #include <iomanip>
00025 #include <algorithm>
00026 #include <sstream>
00027 
00028 STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testCreateAdjacentEntities3x1x1 )
00029 {
00030   const size_t NX = 3;
00031   const size_t NY = 1;
00032   const size_t NZ = 1;
00033 
00034   stk::mesh::fixtures::HexFixture fixture(MPI_COMM_WORLD, NX, NY, NZ);
00035 
00036   fixture.m_fem_meta.commit();
00037   fixture.generate_mesh();
00038 
00039   {
00040     std::vector<size_t> counts ;
00041     stk::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts);
00042 
00043     STKUNIT_EXPECT_EQ( counts[0] , 16u ); // nodes
00044     STKUNIT_EXPECT_EQ( counts[1] , 0u );  // edges
00045     STKUNIT_EXPECT_EQ( counts[2] , 0u );  // faces
00046     STKUNIT_EXPECT_EQ( counts[3] , 3u ); // elements
00047   }
00048 
00049   stk::mesh::PartVector empty_add_parts;
00050 
00051   stk::mesh::create_adjacent_entities(fixture.m_bulk_data, empty_add_parts);
00052 
00053   {
00054     std::vector<size_t> counts ;
00055     stk::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts);
00056 
00057     STKUNIT_EXPECT_EQ( counts[0] , 16u );
00058     STKUNIT_EXPECT_EQ( counts[1] , 28u );
00059     STKUNIT_EXPECT_EQ( counts[2] , 16u );
00060     STKUNIT_EXPECT_EQ( counts[3] , 3u );
00061   }
00062 }
00063 
00064 STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testCreateAdjacentEntities3x3x3 )
00065 {
00066   const size_t elem_rank = 3;
00067   const size_t face_rank = 2;
00068   const size_t edge_rank = 1;
00069   const size_t node_rank = 0;
00070 
00071   const size_t NX = 3;
00072   const size_t NY = 3;
00073   const size_t NZ = 3;
00074 
00075   stk::mesh::fixtures::HexFixture fixture(MPI_COMM_WORLD, NX, NY, NZ);
00076 
00077   fixture.m_fem_meta.commit();
00078   fixture.generate_mesh();
00079 
00080   {
00081     std::vector<size_t> counts ;
00082     stk::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts);
00083 
00084     STKUNIT_EXPECT_EQ( counts[node_rank] , 64u ); // nodes
00085     STKUNIT_EXPECT_EQ( counts[edge_rank] , 0u );  // edges
00086     STKUNIT_EXPECT_EQ( counts[face_rank] , 0u );  // faces
00087     STKUNIT_EXPECT_EQ( counts[elem_rank] , 27u ); // elements
00088   }
00089 
00090   stk::mesh::PartVector empty_add_parts;
00091 
00092   stk::mesh::create_adjacent_entities(fixture.m_bulk_data, empty_add_parts);
00093 
00094   {
00095     std::vector<size_t> counts ;
00096     stk::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts);
00097 
00098     STKUNIT_EXPECT_EQ( 64u, counts[node_rank] ); // nodes
00099     STKUNIT_EXPECT_EQ( 144u, counts[edge_rank] );  // edges
00100     STKUNIT_EXPECT_EQ( 108u, counts[face_rank] );  // faces
00101     STKUNIT_EXPECT_EQ( 27u, counts[elem_rank]  ); // elements
00102   }
00103 
00104   stk::mesh::BucketVector  elem_buckets = fixture.m_bulk_data.buckets(elem_rank);
00105   for ( stk::mesh::BucketVector::iterator b_itr = elem_buckets.begin();
00106        b_itr != elem_buckets.end();
00107        ++b_itr
00108       )
00109   {
00110     stk::mesh::Bucket & b = **b_itr;
00111     for ( size_t i = 0; i< b.size(); ++i) {
00112       stk::mesh::Entity & elem = b[i];
00113 
00114       STKUNIT_EXPECT_EQ( 6u, elem.relations(face_rank).size() );
00115       STKUNIT_EXPECT_EQ( 12u, elem.relations(edge_rank).size() );
00116       STKUNIT_EXPECT_EQ( 8u,  elem.relations(node_rank).size() );
00117 
00118     }
00119   }
00120 
00121   stk::mesh::BucketVector  face_buckets = fixture.m_bulk_data.buckets(face_rank);
00122   for ( stk::mesh::BucketVector::iterator b_itr = face_buckets.begin();
00123        b_itr != face_buckets.end();
00124        ++b_itr
00125       )
00126   {
00127     stk::mesh::Bucket & b = **b_itr;
00128     for ( size_t i = 0; i< b.size(); ++i) {
00129       stk::mesh::Entity & face = b[i];
00130       STKUNIT_EXPECT_EQ( 4u,face.relations(edge_rank).size());
00131       STKUNIT_EXPECT_EQ( 4u, face.relations(node_rank).size() );
00132     }
00133   }
00134 
00135   stk::mesh::BucketVector  edge_buckets = fixture.m_bulk_data.buckets(edge_rank);
00136   for ( stk::mesh::BucketVector::iterator b_itr = edge_buckets.begin();
00137        b_itr != edge_buckets.end();
00138        ++b_itr
00139       )
00140   {
00141     stk::mesh::Bucket & b = **b_itr;
00142     for ( size_t i = 0; i< b.size(); ++i) {
00143       stk::mesh::Entity & edge = b[i];
00144       STKUNIT_EXPECT_EQ( 2u, edge.relations(node_rank).size() );
00145     }
00146   }
00147 }
00148 
00149 STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testCreateAdjacentEntities3x3 )
00150 {
00151   const size_t elem_rank = 2;
00152   const size_t edge_rank = 1;
00153   const size_t node_rank = 0;
00154 
00155   const size_t NX = 3;
00156   const size_t NY = 3;
00157 
00158   stk::mesh::fixtures::QuadFixture fixture(MPI_COMM_WORLD, NX, NY);
00159 
00160   fixture.m_fem_meta.commit();
00161   fixture.generate_mesh();
00162 
00163   {
00164     std::vector<size_t> counts ;
00165     stk::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts);
00166 
00167     STKUNIT_EXPECT_EQ( counts[node_rank] , 16u ); // nodes
00168     STKUNIT_EXPECT_EQ( counts[edge_rank] , 0u );  // edges
00169     STKUNIT_EXPECT_EQ( counts[elem_rank] , 9u ); // elements
00170   }
00171 
00172   stk::mesh::PartVector empty_add_parts;
00173 
00174   stk::mesh::create_adjacent_entities(fixture.m_bulk_data, empty_add_parts);
00175 
00176   {
00177     std::vector<size_t> counts ;
00178     stk::mesh::fem::comm_mesh_counts( fixture.m_bulk_data , counts);
00179 
00180     STKUNIT_EXPECT_EQ( 16u, counts[node_rank] ); // nodes
00181     STKUNIT_EXPECT_EQ( 24u, counts[edge_rank] );  // edges
00182     STKUNIT_EXPECT_EQ( 9u, counts[elem_rank]  ); // elements
00183   }
00184 
00185   stk::mesh::BucketVector  elem_buckets = fixture.m_bulk_data.buckets(elem_rank);
00186   for ( stk::mesh::BucketVector::iterator b_itr = elem_buckets.begin();
00187        b_itr != elem_buckets.end();
00188        ++b_itr
00189       )
00190   {
00191     stk::mesh::Bucket & b = **b_itr;
00192     for ( size_t i = 0; i< b.size(); ++i) {
00193       stk::mesh::Entity & elem = b[i];
00194 
00195       STKUNIT_EXPECT_EQ( 4u, elem.relations(edge_rank).size() );
00196       STKUNIT_EXPECT_EQ( 4u,  elem.relations(node_rank).size() );
00197 
00198     }
00199   }
00200 
00201   stk::mesh::BucketVector  edge_buckets = fixture.m_bulk_data.buckets(edge_rank);
00202   for ( stk::mesh::BucketVector::iterator b_itr = edge_buckets.begin();
00203        b_itr != edge_buckets.end();
00204        ++b_itr
00205       )
00206   {
00207     stk::mesh::Bucket & b = **b_itr;
00208     for ( size_t i = 0; i< b.size(); ++i) {
00209       stk::mesh::Entity & edge = b[i];
00210       STKUNIT_EXPECT_EQ( 2u, edge.relations(node_rank).size() );
00211     }
00212   }
00213 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends