Sierra Toolkit Version of the Day
UnitTestGenerateNewEntities.cpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
00010 
00011 #include <stk_util/parallel/Parallel.hpp>
00012 
00013 #include <Shards_BasicTopologies.hpp>
00014 
00015 #include <stk_mesh/base/MetaData.hpp>
00016 #include <stk_mesh/base/BulkData.hpp>
00017 #include <stk_mesh/base/Entity.hpp>
00018 #include <stk_mesh/base/GetEntities.hpp>
00019 
00020 #include <stk_mesh/fem/FEMMetaData.hpp>
00021 
00022 namespace {
00023 
00024 const stk::mesh::EntityRank NODE_RANK = stk::mesh::fem::FEMMetaData::NODE_RANK;
00025 
00026 STKUNIT_UNIT_TEST( UnitTestStkMeshGenerateNewEntities , testUnit )
00027 {
00028   // Test BulkData's generate_new_entities method.
00029 
00030   stk::ParallelMachine pm(MPI_COMM_WORLD);
00031 
00032   const int spatial_dimension = 3;
00033   stk::mesh::fem::FEMMetaData meta_data( spatial_dimension );
00034   stk::mesh::BulkData bulk_data( stk::mesh::fem::FEMMetaData::get_meta_data(meta_data) , pm );
00035 
00036   meta_data.commit();
00037 
00038   const stk::mesh::PartVector no_parts;
00039 
00040   bulk_data.modification_begin();
00041 
00042   bulk_data.declare_entity(NODE_RANK, bulk_data.parallel_rank() + 1, no_parts);
00043 
00044   bulk_data.modification_end();
00045 
00046   // Create a request vector for 2 new nodes on each processor
00047   size_t num_nodes_requested = 2;
00048   std::vector<size_t> requests(meta_data.entity_rank_count(), 0);
00049   requests[0] = num_nodes_requested;
00050 
00051   bulk_data.modification_begin();
00052 
00053   // generate_new_entities creates new blank entities of the requested ranks
00054   stk::mesh::EntityVector new_nodes;
00055   bulk_data.generate_new_entities(requests, new_nodes);
00056   STKUNIT_ASSERT_EQ(new_nodes.size(), num_nodes_requested);
00057 
00058   // confirm that the nodes we created earlier are not in the new entities
00059   for (stk::mesh::EntityVector::const_iterator itr = new_nodes.begin();
00060        itr != new_nodes.end(); ++itr) {
00061     STKUNIT_ASSERT_GT((*itr)->identifier(), bulk_data.parallel_size());
00062   }
00063 
00064   bulk_data.modification_end();
00065 }
00066 
00067 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines