Sierra Toolkit Version of the Day
UnitTestDeclareElement.cpp
00001 
00002 /*------------------------------------------------------------------------*/
00003 /*                 Copyright 2010, 2011 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/FEMHelpers.hpp>
00023 
00024 #include <stk_util/parallel/ParallelReduce.hpp>
00025 
00026 STKUNIT_UNIT_TEST( UnitTestDeclareElement , inject_shell )
00027 {
00028   // This tests creates a small HexFixture with two hexes then, in a separate
00029   // modification cycle, inserts a shell between the two elements.
00030 
00031   stk::ParallelMachine pm = MPI_COMM_WORLD ;
00032 
00033   // Create the fixture, adding a part for the shell
00034 
00035   stk::mesh::fixtures::HexFixture fixture( pm , 2 , 1 , 1 );
00036 
00037   const unsigned p_rank = fixture.m_bulk_data.parallel_rank();
00038 
00039   stk::mesh::Part & shell_part = stk::mesh::fem::declare_part<shards::ShellQuadrilateral<4> >( fixture.m_fem_meta, "shell_part");
00040 
00041   fixture.m_fem_meta.commit();
00042 
00043   fixture.generate_mesh();
00044 
00045   stk::mesh::Entity * elem = fixture.elem( 0 , 0 , 0 );
00046 
00047   fixture.m_bulk_data.modification_begin();
00048 
00049   bool no_throw = true;
00050 
00051   // Whoever owns the 0,0,0 element create the shell and insert it between
00052   // the two elements.
00053   if ( elem != NULL && p_rank == elem->owner_rank() ) {
00054     stk::mesh::EntityId elem_node[4] ;
00055     elem_node[0] = fixture.node_id( 1, 0, 0 );
00056     elem_node[1] = fixture.node_id( 1, 1, 0 );
00057     elem_node[2] = fixture.node_id( 1, 1, 1 );
00058     elem_node[3] = fixture.node_id( 1, 0, 1 );
00059 
00060     stk::mesh::EntityId elem_id = 3;
00061 
00062     try {
00063       stk::mesh::fem::declare_element( fixture.m_bulk_data, shell_part, elem_id, elem_node);
00064     }
00065     catch (...) {
00066       no_throw = false;
00067     }
00068 
00069   }
00070   fixture.m_bulk_data.modification_end();
00071 
00072   STKUNIT_EXPECT_TRUE(no_throw);
00073 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines