Debian Codegraph @

packages/stk/stk_integration_tests/stk_mesh/face_creation/skin_mesh/IntegrationTestCheckExposedBoundary.cpp

raw
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2002 - 2008, 2010, 2011 National Technology & */
3 /* Engineering Solutions of Sandia, LLC (NTESS). Under the terms */
4 /* of Contract DE-NA0003525 with NTESS, there is a */
5 /* non-exclusive license for use of this work by or on behalf */
6 /* of the U.S. Government. Export of this program may require */
7 /* a license from the United States Government. */
8 /*--------------------------------------------------------------------*/
9
10 #include <gtest/gtest.h> // for AssertHelper, EXPECT_EQ, etc
11 #include <Ionit_Initializer.h> // for Initializer
12 #include <stddef.h> // for size_t, nullptr
13 #include <stk_io/StkMeshIoBroker.hpp> // for StkMeshIoBroker
14 #include <string> // for string
15 #include "mpi.h" // for MPI_COMM_WORLD
16 #include "stk_io/DatabasePurpose.hpp"
17 #include <stk_mesh/base/GetEntities.hpp>
18 #include <stk_mesh/base/Comm.hpp>
19 #include <stk_mesh/base/SkinBoundary.hpp>
20 #include <stk_unit_test_utils/ioUtils.hpp>
21 #include <stk_unit_test_utils/MeshFixture.hpp> // for MeshTestFixture
22 #include <stk_unit_test_utils/FaceCreationTestUtils.hpp>
23
24 namespace
25 {
26
27 class SkinnedMeshWithModifiedSkinPart : public stk::unit_test_util::MeshTestFixture
28 {
29 protected:
30 virtual void run_test(stk::mesh::BulkData::AutomaticAuraOption auraOption)
31 {
32 setup_empty_mesh(auraOption);
33 stk::unit_test_util::read_from_serial_file_and_decompose("ARA.e", get_bulk(), "cyclic");
34 stk::mesh::Part& skinnedPart = SideTestUtil::run_skin_mesh(get_bulk(), get_things_to_skin(get_bulk()));
35
36 run_modification(skinnedPart);
37 EXPECT_FALSE(stk::mesh::check_exposed_block_boundary_sides(get_bulk(), get_things_to_skin(get_bulk()), skinnedPart));
38 }
39
40 virtual void run_modification(stk::mesh::Part &skin) = 0;
41
42 stk::mesh::EntityVector get_faces(stk::mesh::Selector selector)
43 {
44 stk::mesh::EntityVector faces;
45 stk::mesh::get_selected_entities(selector, get_bulk().buckets(stk::topology::FACE_RANK), faces);
46 return faces;
47 }
48
49 stk::mesh::Selector get_things_to_skin(const stk::mesh::BulkData& bulkDataArg)
50 {
51 return bulkDataArg.mesh_meta_data().universal_part();
52 }
53 };
54
55 class SkinnedMeshWithExtraFace: public SkinnedMeshWithModifiedSkinPart
56 {
57 protected:
58 virtual void run_modification(stk::mesh::Part &skin)
59 {
60 get_bulk().modification_begin();
61 add_extra_face_to_skin(skin);
62 get_bulk().modification_end();
63 }
64
65 private:
66 void add_extra_face_to_skin(stk::mesh::Part &skin)
67 {
68 if(get_bulk().parallel_rank() == 0) {
69 stk::mesh::EntityVector notSkinFaces = get_faces(!skin);
70 ASSERT_EQ(1u, notSkinFaces.size());
71 get_bulk().change_entity_parts(notSkinFaces[0], stk::mesh::ConstPartVector{&skin});
72 }
73 }
74 };
75
76 class SkinnedMeshWithMissingFace: public SkinnedMeshWithModifiedSkinPart
77 {
78 protected:
79 virtual void run_modification(stk::mesh::Part &skin)
80 {
81 get_bulk().modification_begin();
82 remove_face_from_skin(skin);
83 get_bulk().modification_end();
84 }
85
86 private:
87 void remove_face_from_skin(stk::mesh::Part &skin)
88 {
89 stk::mesh::EntityVector skinFaces = get_faces(skin);
90 ASSERT_EQ(5u, skinFaces.size());
91 get_bulk().change_entity_parts(skinFaces[0], stk::mesh::ConstPartVector{}, stk::mesh::ConstPartVector{&skin});
92 }
93 };
94
95 TEST_F(SkinnedMeshWithExtraFace, skin_no_aura)
96 {
97 run_test_on_num_procs(2, stk::mesh::BulkData::NO_AUTO_AURA);
98 }
99
100 TEST_F(SkinnedMeshWithMissingFace, skin_no_aura)
101 {
102 run_test_on_num_procs(2, stk::mesh::BulkData::NO_AUTO_AURA);
103 }
104
105 }