Sierra Toolkit Version of the Day
UnitTestDeclareElement.cpp
00001 
00002 /*------------------------------------------------------------------------*/
00003 /*                 Copyright 2010 Sandia Corporation.                     */
00004 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00005 /*  license for use of this work by or on behalf of the U.S. Government.  */
00006 /*  Export of this program may require a license from the                 */
00007 /*  United States Government.                                             */
00008 /*------------------------------------------------------------------------*/
00009 
00010 
00011 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
00012 
00013 #include <Shards_BasicTopologies.hpp>
00014 
00015 #include <stk_mesh/fixtures/HexFixture.hpp>
00016 
00017 #include <stk_mesh/base/BulkModification.hpp>
00018 #include <stk_mesh/base/MetaData.hpp>
00019 #include <stk_mesh/base/BulkData.hpp>
00020 #include <stk_mesh/base/Entity.hpp>
00021 
00022 #include <stk_mesh/fem/EntityRanks.hpp>
00023 #include <stk_mesh/fem/TopologyHelpers.hpp>
00024 #include <stk_mesh/fem/Stencils.hpp>
00025 
00026 #include <stk_util/parallel/ParallelReduce.hpp>
00027 
00028 STKUNIT_UNIT_TEST( UnitTestDeclareElement , inject_shell ) {
00029 
00030   stk::ParallelMachine pm = MPI_COMM_WORLD ;
00031 
00032   stk::mesh::fixtures::HexFixture fixture( pm , 2 , 1 , 1 );
00033   stk::mesh::TopologicalMetaData & top_data = fixture.top_data;
00034 
00035   const unsigned p_rank = fixture.bulk_data.parallel_rank();
00036 
00037   stk::mesh::Part & shell_part = top_data.declare_part<shards::ShellQuadrilateral<4> >("shell_part");
00038 
00039   fixture.meta_data.commit();
00040 
00041   fixture.generate_mesh();
00042 
00043   stk::mesh::Entity * elem = fixture.elem( 0 , 0 , 0 );
00044 
00045   fixture.bulk_data.modification_begin();
00046 
00047   bool no_throw = true;
00048 
00049   if ( elem != NULL && p_rank == elem->owner_rank() ) {
00050     //add shell between the two elements
00051 
00052     stk::mesh::EntityId elem_node[4] ;
00053 
00054     elem_node[0] = fixture.node_id( 1, 0, 0 );
00055     elem_node[1] = fixture.node_id( 1, 1, 0 );
00056     elem_node[2] = fixture.node_id( 1, 1, 1 );
00057     elem_node[3] = fixture.node_id( 1, 0, 1 );
00058 
00059     stk::mesh::EntityId elem_id = 3;
00060 
00061     try {
00062       stk::mesh::declare_element( fixture.bulk_data, shell_part, elem_id, elem_node);
00063     }
00064     catch (...) {
00065       no_throw = false;
00066     }
00067 
00068   }
00069   fixture.bulk_data.modification_end();
00070 
00071   STKUNIT_EXPECT_TRUE(no_throw);
00072 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends