|
Sierra Toolkit Version of the Day
|
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 00010 #include <stdexcept> 00011 00012 #include <stk_util/unit_test_support/stk_utest_macros.hpp> 00013 #include <stk_mesh/fixtures/QuadFixture.hpp> 00014 #include <stk_mesh/fixtures/HexFixture.hpp> 00015 #include <unit_tests/UnitTestMesh.hpp> 00016 00017 namespace { 00018 00019 } 00020 00021 //---------------------------------------------------------------------------- 00022 00023 STKUNIT_UNIT_TEST ( UnitTestCrackMesh , VerifyDestroy ) 00024 { 00025 stk::ParallelMachine pm = MPI_COMM_WORLD ; 00026 const unsigned p_rank = stk::parallel_machine_rank( pm ); 00027 00028 const unsigned nx = 3 , ny = 3 , nz = 3 ; 00029 00030 for ( unsigned iy = 0 ; iy < ny ; ++iy ) { 00031 for ( unsigned ix = 0 ; ix < nx ; ++ix ) { 00032 stk::mesh::fixtures::QuadFixture fixture( pm , nx , ny ); 00033 fixture.meta_data.commit(); 00034 fixture.generate_mesh(); 00035 00036 fixture.bulk_data.modification_begin(); 00037 00038 stk::mesh::Entity * elem = fixture.elem( ix , iy ); 00039 00040 if ( elem && p_rank == elem->owner_rank() ) { 00041 stk::mesh::Entity * tmp = elem ; 00042 fixture.bulk_data.destroy_entity( tmp ); 00043 } 00044 00045 fixture.bulk_data.modification_end(); 00046 00047 if ( elem ) { 00048 STKUNIT_EXPECT_TRUE ( elem->log_query() == stk::mesh::EntityLogDeleted ); 00049 } 00050 } 00051 } 00052 00053 for ( unsigned iz = 0 ; iz < nz ; ++iz ) { 00054 for ( unsigned iy = 0 ; iy < ny ; ++iy ) { 00055 for ( unsigned ix = 0 ; ix < nx ; ++ix ) { 00056 stk::mesh::fixtures::HexFixture fixture( pm , nx , ny , nz ); 00057 fixture.meta_data.commit(); 00058 fixture.generate_mesh(); 00059 00060 fixture.bulk_data.modification_begin(); 00061 00062 stk::mesh::Entity * elem = fixture.elem( ix , iy , iz ); 00063 00064 if ( elem && p_rank == elem->owner_rank() ) { 00065 stk::mesh::Entity * tmp = elem ; 00066 fixture.bulk_data.destroy_entity( tmp ); 00067 } 00068 00069 fixture.bulk_data.modification_end(); 00070 00071 if ( elem ) { 00072 STKUNIT_EXPECT_TRUE ( elem->log_query() == stk::mesh::EntityLogDeleted ); 00073 } 00074 } 00075 } 00076 } 00077 } 00078 00079 //---------------------------------------------------------------------------- 00080 00081 STKUNIT_UNIT_TEST ( UnitTestCrackMesh , verifyBoxGhosting ) 00082 { 00083 stk::mesh::fixtures::HexFixture fixture( MPI_COMM_WORLD, 2,2,2 ); 00084 fixture.meta_data.commit(); 00085 fixture.generate_mesh(); 00086 00087 stk::mesh::BulkData & mesh = fixture.bulk_data; 00088 00089 stk::mesh::Entity * const old_node = fixture.node(0,1,1); 00090 00091 stk::mesh::Entity * const right_element = fixture.elem(0,0,1); 00092 00093 unsigned right_ordinal = 0; 00094 unsigned new_node_id = 28; 00095 00096 if ( old_node && right_element ) { 00097 stk::mesh::PairIterRelation rel = old_node->relations(); 00098 00099 for (; rel.first != rel.second; ++rel) { 00100 if ( (rel.first->entity()) == right_element) { 00101 right_ordinal = rel.first->identifier(); 00102 } 00103 } 00104 } 00105 00106 mesh.modification_begin(); 00107 00108 //only crack the mesh if I own the element 00109 if ( right_element && 00110 right_element->owner_rank() == mesh.parallel_rank() ) { 00111 00112 const stk::mesh::PartVector no_parts; 00113 00114 stk::mesh::Entity & new_node = 00115 mesh.declare_entity(fixture.top_data.node_rank, new_node_id, no_parts); 00116 00117 mesh.destroy_relation(*right_element, *old_node); 00118 mesh.declare_relation(*right_element, new_node, right_ordinal); 00119 } 00120 00121 //copy parts 00122 00123 //copy field data 00124 00125 mesh.modification_end(); 00126 00127 if ( right_element ) { 00128 stk::mesh::PairIterRelation rel = right_element->relations(); 00129 stk::mesh::Entity & new_node = * (rel.first[right_ordinal].entity()); 00130 00131 STKUNIT_EXPECT_TRUE ( new_node.identifier() == new_node_id ); 00132 } 00133 } 00134 00135 //----------------------------------------------------------------------------