Sierra Toolkit  Version of the Day
UnitTestDeclareElement.cpp
1 
2 /*------------------------------------------------------------------------*/
3 /* Copyright 2010, 2011 Sandia Corporation. */
4 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
5 /* license for use of this work by or on behalf of the U.S. Government. */
6 /* Export of this program may require a license from the */
7 /* United States Government. */
8 /*------------------------------------------------------------------------*/
9 
10 
11 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
12 
13 #include <Shards_BasicTopologies.hpp>
14 
15 #include <stk_mesh/fixtures/HexFixture.hpp>
16 
17 #include <stk_mesh/base/BulkModification.hpp>
18 #include <stk_mesh/base/MetaData.hpp>
19 #include <stk_mesh/base/BulkData.hpp>
20 #include <stk_mesh/base/Entity.hpp>
21 
22 #include <stk_mesh/fem/FEMHelpers.hpp>
23 
24 #include <stk_util/parallel/ParallelReduce.hpp>
25 
26 STKUNIT_UNIT_TEST( UnitTestDeclareElement , inject_shell )
27 {
28  // This tests creates a small HexFixture with two hexes then, in a separate
29  // modification cycle, inserts a shell between the two elements.
30 
31  stk_classic::ParallelMachine pm = MPI_COMM_WORLD ;
32 
33  // Create the fixture, adding a part for the shell
34 
35  stk_classic::mesh::fixtures::HexFixture fixture( pm , 2 , 1 , 1 );
36 
37  const unsigned p_rank = fixture.m_bulk_data.parallel_rank();
38 
39  stk_classic::mesh::Part & shell_part = stk_classic::mesh::fem::declare_part<shards::ShellQuadrilateral<4> >( fixture.m_fem_meta, "shell_part");
40 
41  fixture.m_fem_meta.commit();
42 
43  fixture.generate_mesh();
44 
45  stk_classic::mesh::Entity * elem = fixture.elem( 0 , 0 , 0 );
46 
47  fixture.m_bulk_data.modification_begin();
48 
49  bool no_throw = true;
50 
51  // Whoever owns the 0,0,0 element create the shell and insert it between
52  // the two elements.
53  if ( elem != NULL && p_rank == elem->owner_rank() ) {
54  stk_classic::mesh::EntityId elem_node[4] ;
55  elem_node[0] = fixture.node_id( 1, 0, 0 );
56  elem_node[1] = fixture.node_id( 1, 1, 0 );
57  elem_node[2] = fixture.node_id( 1, 1, 1 );
58  elem_node[3] = fixture.node_id( 1, 0, 1 );
59 
60  stk_classic::mesh::EntityId elem_id = 3;
61 
62  try {
63  stk_classic::mesh::fem::declare_element( fixture.m_bulk_data, shell_part, elem_id, elem_node);
64  }
65  catch (...) {
66  no_throw = false;
67  }
68 
69  }
70  fixture.m_bulk_data.modification_end();
71 
72  STKUNIT_EXPECT_TRUE(no_throw);
73 }
Entity & declare_element(BulkData &mesh, Part &part, const EntityId elem_id, const EntityId node_id[])
Declare an element member of a Part with a CellTopology and nodes conformal to that topology...
Definition: FEMHelpers.cpp:72
An application-defined subset of a problem domain.
Definition: Part.hpp:49
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
Definition: Entity.hpp:120
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
unsigned owner_rank() const
Parallel processor rank of the processor which owns this entity.
Definition: Entity.hpp:175