Debian Codegraph @

packages/stk/stk_unit_tests/stk_mesh/UnitTestGetCellTopology.cpp

raw
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 #include <gtest/gtest.h>
36 #include <stk_util/stk_config.h>
37 #include <stk_mesh/base/MetaData.hpp>
38 #include <Shards_BasicTopologies.hpp>
39
40 namespace {
41
42 void test_mapping(stk::topology stkTopo, bool expectInvalid = false)
43 {
44 shards::CellTopology cellTopo = stk::mesh::get_cell_topology(stkTopo);
45
46 if (stkTopo == stk::topology::INVALID_TOPOLOGY || expectInvalid) {
47 EXPECT_FALSE(cellTopo.isValid()) << stkTopo;
48 return;
49 }
50
51 EXPECT_TRUE(cellTopo.isValid()) << stkTopo;
52 EXPECT_EQ(cellTopo.getNodeCount(), stkTopo.num_nodes()) << stkTopo;
53 EXPECT_EQ(cellTopo.getVertexCount(), stkTopo.num_vertices()) << stkTopo;
54 }
55
56 TEST( GetCellTopology, mappingTest )
57 {
58 constexpr bool expectInvalid = true;
59
60 test_mapping(stk::topology::NODE);
61 test_mapping(stk::topology::LINE_2);
62 test_mapping(stk::topology::LINE_3);
63 test_mapping(stk::topology::TRI_3);
64 test_mapping(stk::topology::TRI_4);
65 test_mapping(stk::topology::TRI_6);
66 test_mapping(stk::topology::QUAD_4);
67 test_mapping(stk::topology::QUAD_6, expectInvalid);
68 test_mapping(stk::topology::QUAD_8);
69 test_mapping(stk::topology::QUAD_9);
70 test_mapping(stk::topology::PARTICLE);
71 test_mapping(stk::topology::LINE_2_1D);
72 test_mapping(stk::topology::LINE_3_1D);
73 test_mapping(stk::topology::BEAM_2);
74 test_mapping(stk::topology::BEAM_3);
75 test_mapping(stk::topology::SHELL_LINE_2);
76 test_mapping(stk::topology::SHELL_LINE_3);
77 test_mapping(stk::topology::SPRING_2, expectInvalid);
78 test_mapping(stk::topology::SPRING_3, expectInvalid);
79 test_mapping(stk::topology::TRI_3_2D);
80 test_mapping(stk::topology::TRI_4_2D);
81 test_mapping(stk::topology::TRI_6_2D);
82 test_mapping(stk::topology::QUAD_4_2D);
83 test_mapping(stk::topology::QUAD_8_2D);
84 test_mapping(stk::topology::QUAD_9_2D);
85 test_mapping(stk::topology::SHELL_TRI_3);
86 test_mapping(stk::topology::SHELL_TRI_4, expectInvalid);
87 test_mapping(stk::topology::SHELL_TRI_6);
88 test_mapping(stk::topology::SHELL_QUAD_4);
89 test_mapping(stk::topology::SHELL_QUAD_8);
90 test_mapping(stk::topology::SHELL_QUAD_9);
91 test_mapping(stk::topology::TET_4);
92 test_mapping(stk::topology::TET_8);
93 test_mapping(stk::topology::TET_10);
94 test_mapping(stk::topology::TET_11);
95 test_mapping(stk::topology::PYRAMID_5);
96 test_mapping(stk::topology::PYRAMID_13);
97 test_mapping(stk::topology::PYRAMID_14);
98 test_mapping(stk::topology::WEDGE_6);
99 test_mapping(stk::topology::WEDGE_12, expectInvalid);
100 test_mapping(stk::topology::WEDGE_15);
101 test_mapping(stk::topology::WEDGE_18);
102 test_mapping(stk::topology::HEX_8);
103 test_mapping(stk::topology::HEX_20);
104 test_mapping(stk::topology::HEX_27);
105 }
106
107 } // empty namespace