| 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 |
#include <gtest/gtest.h> |
| 35 |
#include <stk_io/StkMeshIoBroker.hpp> |
| 36 |
#include <stk_mesh/base/Part.hpp> |
| 37 |
#include <stk_mesh/base/SkinBoundary.hpp> |
| 38 |
#include <stk_mesh/base/GetEntities.hpp> |
| 39 |
#include <stk_unit_test_utils/TextMesh.hpp> |
| 40 |
#include <stk_unit_test_utils/MeshFixture.hpp> // for MeshTestFixture |
| 41 |
#include <stk_unit_test_utils/BuildMesh.hpp> |
| 42 |
|
| 43 |
#include <unistd.h> |
| 44 |
|
| 45 |
using stk::unit_test_util::build_mesh; |
| 46 |
|
| 47 |
class StkTopologyTest : public stk::unit_test_util::MeshFixture |
| 48 |
{ |
| 49 |
public: |
| 50 |
StkTopologyTest() |
| 51 |
{ |
| 52 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 53 |
} |
| 54 |
|
| 55 |
void init_mesh_with_wedge12_element(stk::mesh::BulkData& bulk) |
| 56 |
{ |
| 57 |
std::string meshDesc = "0,1,WEDGE_12,1,2,3,4,5,6,7,8,9,10,11,12"; |
| 58 |
stk::unit_test_util::setup_text_mesh(bulk, meshDesc); |
| 59 |
stk::mesh::create_all_sides(bulk, bulk.mesh_meta_data().universal_part(), {}, true); |
| 60 |
} |
| 61 |
|
| 62 |
stk::topology get_element_topology(const stk::mesh::BulkData& bulk) |
| 63 |
{ |
| 64 |
stk::mesh::EntityVector elements; |
| 65 |
stk::mesh::get_entities(bulk, stk::topology::ELEMENT_RANK, elements); |
| 66 |
EXPECT_EQ(elements.size(), 1u); |
| 67 |
return bulk.bucket(elements[0]).topology(); |
| 68 |
} |
| 69 |
|
| 70 |
void output_mesh(stk::mesh::BulkData& bulk, const std::string& fileName) |
| 71 |
{ |
| 72 |
stk::io::write_mesh(fileName, bulk); |
| 73 |
} |
| 74 |
|
| 75 |
void check_mesh_has_wedge12(stk::mesh::BulkData& bulk) |
| 76 |
{ |
| 77 |
EXPECT_EQ(get_element_topology(bulk), stk::topology::WEDGE_12); |
| 78 |
|
| 79 |
stk::mesh::Entity elem = bulk.get_entity(stk::topology::ELEM_RANK, 1); |
| 80 |
EXPECT_TRUE(bulk.is_valid(elem)); |
| 81 |
const stk::mesh::Entity* faces = bulk.begin_faces(elem); |
| 82 |
EXPECT_EQ(5u, bulk.num_faces(elem)); |
| 83 |
EXPECT_EQ(bulk.bucket(faces[0]).topology(), stk::topology::QUAD_6); |
| 84 |
EXPECT_EQ(bulk.bucket(faces[1]).topology(), stk::topology::QUAD_6); |
| 85 |
EXPECT_EQ(bulk.bucket(faces[2]).topology(), stk::topology::QUAD_6); |
| 86 |
EXPECT_EQ(bulk.bucket(faces[3]).topology(), stk::topology::TRI_6); |
| 87 |
EXPECT_EQ(bulk.bucket(faces[4]).topology(), stk::topology::TRI_6); |
| 88 |
} |
| 89 |
}; |
| 90 |
|
| 91 |
TEST_F(StkTopologyTest, createWedge12OnMesh) |
| 92 |
{ |
| 93 |
if(get_parallel_size() != 1) { return; } |
| 94 |
|
| 95 |
init_mesh_with_wedge12_element(get_bulk()); |
| 96 |
check_mesh_has_wedge12(get_bulk()); |
| 97 |
} |
| 98 |
|
| 99 |
TEST_F(StkTopologyTest, writeWedge12ToExodusFile) |
| 100 |
{ |
| 101 |
if(get_parallel_size() != 1) { return; } |
| 102 |
|
| 103 |
const std::string fileName = "single_wedge_case.e"; |
| 104 |
init_mesh_with_wedge12_element(get_bulk()); |
| 105 |
|
| 106 |
output_mesh(get_bulk(), fileName); |
| 107 |
|
| 108 |
std::shared_ptr<stk::mesh::BulkData> newBulkPtr = build_mesh(3, get_comm()); |
| 109 |
stk::mesh::BulkData& newBulk = *newBulkPtr; |
| 110 |
stk::mesh::MetaData& newMeta = newBulk.mesh_meta_data(); |
| 111 |
stk::io::fill_mesh(fileName, newBulk); |
| 112 |
stk::mesh::create_all_sides(newBulk, newMeta.universal_part(), {}, true); |
| 113 |
|
| 114 |
check_mesh_has_wedge12(newBulk); |
| 115 |
|
| 116 |
unlink(fileName.c_str()); |
| 117 |
} |