| 1 |
// Copyright 2002 - 2008, 2010, 2011 National Technology Engineering |
| 2 |
// Solutions of Sandia, LLC (NTESS). Under the terms of Contract |
| 3 |
// DE-NA0003525 with NTESS, the U.S. Government retains certain rights |
| 4 |
// in this software. |
| 5 |
// |
| 6 |
// Redistribution and use in source and binary forms, with or without |
| 7 |
// modification, are permitted provided that the following conditions are |
| 8 |
// met: |
| 9 |
// |
| 10 |
// * Redistributions of source code must retain the above copyright |
| 11 |
// notice, this list of conditions and the following disclaimer. |
| 12 |
// |
| 13 |
// * Redistributions in binary form must reproduce the above |
| 14 |
// copyright notice, this list of conditions and the following |
| 15 |
// disclaimer in the documentation and/or other materials provided |
| 16 |
// with the distribution. |
| 17 |
// |
| 18 |
// * Neither the name of NTESS nor the names of its contributors |
| 19 |
// may be used to endorse or promote products derived from this |
| 20 |
// software without specific prior written permission. |
| 21 |
// |
| 22 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 |
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 |
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 |
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 26 |
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 27 |
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 28 |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 29 |
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 30 |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 31 |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 32 |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 |
// |
| 34 |
|
| 35 |
// ####################### Start Clang Header Tool Managed Headers ######################## |
| 36 |
// clang-format off |
| 37 |
#include <gtest/gtest.h> // for AssertHelper, etc |
| 38 |
#include <stk_mesh/base/BulkData.hpp> // for BulkData |
| 39 |
#include <stk_mesh/base/MeshBuilder.hpp> |
| 40 |
#include <stk_mesh/base/Entity.hpp> // for Entity |
| 41 |
#include <stk_mesh/base/FEMHelpers.hpp> // for declare_element |
| 42 |
#include <stk_mesh/base/MetaData.hpp> // for MetaData |
| 43 |
#include <stk_mesh/base/SkinMesh.hpp> // for skin_mesh |
| 44 |
#include <stk_mesh/base/Types.hpp> // for EntityId, etc |
| 45 |
#include <stk_util/parallel/Parallel.hpp> |
| 46 |
#include "mpi.h" // for MPI_COMM_WORLD, etc |
| 47 |
#include "stk_topology/topology.hpp" // for topology, etc |
| 48 |
namespace stk { namespace mesh { class Part; } } |
| 49 |
// clang-format on |
| 50 |
// ####################### End Clang Header Tool Managed Headers ######################## |
| 51 |
namespace stk { namespace mesh { class Bucket; } } |
| 52 |
|
| 53 |
using stk::mesh::EntityId; |
| 54 |
using stk::mesh::EntityRank; |
| 55 |
using stk::mesh::MetaData; |
| 56 |
|
| 57 |
//--------------------------------------------------------------------------------------- |
| 58 |
|
| 59 |
TEST( UnitTestSkin, SkinPocket) |
| 60 |
{ |
| 61 |
enum { SpatialDim = 3 }; |
| 62 |
|
| 63 |
stk::ParallelMachine pm = MPI_COMM_WORLD ; |
| 64 |
const unsigned p_rank = stk::parallel_machine_rank( pm ); |
| 65 |
const unsigned p_size = stk::parallel_machine_size( pm ); |
| 66 |
|
| 67 |
stk::mesh::MeshBuilder builder(pm); |
| 68 |
builder.set_spatial_dimension(SpatialDim); |
| 69 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = builder.create(); |
| 70 |
stk::mesh::BulkData& bulk_data = *bulkPtr; |
| 71 |
stk::mesh::MetaData& fem_meta = bulk_data.mesh_meta_data(); |
| 72 |
stk::mesh::Part & hex_part = fem_meta.declare_part_with_topology( "hex_part", stk::topology::HEX_8 ); |
| 73 |
const EntityRank element_rank = stk::topology::ELEMENT_RANK; |
| 74 |
const EntityRank side_rank = fem_meta.side_rank(); |
| 75 |
|
| 76 |
//create and skin a 2 hex-element mesh with a pocket |
| 77 |
//in a normal mesh 6 and 13 would be the same node |
| 78 |
// |
| 79 |
// 8-------7-------12 |
| 80 |
// /| /|\ /| |
| 81 |
// / | / | \ / | |
| 82 |
// 5-------6 | 13-11 | |
| 83 |
// | 4----|--3/---|--10 |
| 84 |
// | / | // | / |
| 85 |
// |/ |// |/ |
| 86 |
// 1-------2-------9 |
| 87 |
// |
| 88 |
|
| 89 |
fem_meta.commit(); |
| 90 |
|
| 91 |
bulk_data.modification_begin(); |
| 92 |
|
| 93 |
// declare left element on first process |
| 94 |
if (p_rank == 0) |
| 95 |
{ |
| 96 |
EntityId element_id = 1; |
| 97 |
stk::mesh::EntityIdVector node_ids { 1, 2, 3, 4, 5, 6, 7, 8}; |
| 98 |
|
| 99 |
stk::mesh::declare_element( bulk_data, hex_part, element_id, node_ids); |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
// declare right element on last process |
| 104 |
if (p_rank == p_size -1) |
| 105 |
{ |
| 106 |
EntityId element_id = 2; |
| 107 |
stk::mesh::EntityIdVector node_ids { 2, 9, 10, 3, 13, 11, 12, 7}; |
| 108 |
|
| 109 |
stk::mesh::declare_element( bulk_data, hex_part, element_id, node_ids); |
| 110 |
} |
| 111 |
|
| 112 |
bulk_data.modification_end(); |
| 113 |
|
| 114 |
//skin the mesh |
| 115 |
stk::mesh::skin_mesh(bulk_data); |
| 116 |
|
| 117 |
//each element should have 6 faces attached to it |
| 118 |
for (EntityId element_id = 1; element_id < 3; ++element_id) { |
| 119 |
stk::mesh::Entity element = bulk_data.get_entity( element_rank, element_id); |
| 120 |
if ( bulk_data.is_valid(element) ) { |
| 121 |
EXPECT_EQ( bulk_data.num_connectivity(element, side_rank), 6u); |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
|