Debian Codegraph @

packages/stk/stk_unit_tests/stk_mesh/face_creation/skin_mesh/UnitTestSkinMeshUseCaseUtils.hpp

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 #ifndef _UnitTestSkinMeshUseCaseUtils_hpp_
35 #define _UnitTestSkinMeshUseCaseUtils_hpp_
36
37 #include <vector>
38 #include <algorithm>
39 #include <stdlib.h>
40
41 #include <stk_topology/topology.hpp>
42 #include <stk_mesh/base/BulkData.hpp>
43 #include <stk_mesh/base/MetaData.hpp>
44 #include <stk_mesh/base/Comm.hpp>
45 #include <stk_mesh/base/GetEntities.hpp>
46 #include <stk_mesh/base/FEMHelpers.hpp>
47 #include <stk_mesh/baseImpl/MeshImplUtils.hpp>
48 #include <stk_mesh/base/Field.hpp>
49
50 #include <stk_mesh/base/SkinMesh.hpp>
51 #include <stk_mesh/base/CreateFaces.hpp>
52 #include <stk_mesh/baseImpl/elementGraph/ElemElemGraph.hpp>
53 #include <stk_mesh/baseImpl/elementGraph/ElemElemGraphImpl.hpp>
54
55 #include <stk_util/parallel/Parallel.hpp>
56 #include <stk_util/parallel/ParallelVectorConcat.hpp>
57 #include <stk_util/parallel/ParallelComm.hpp>
58 #include <stk_util/environment/WallTime.hpp>
59 #include <stk_util/environment/memory_util.hpp>
60 #include <stk_util/parallel/CommSparse.hpp>
61 #include <stk_util/util/ReportHandler.hpp>
62
63 #include <stk_io/IossBridge.hpp>
64 #include <stk_io/StkMeshIoBroker.hpp> // for StkMeshIoBroker
65
66 #include <stk_unit_test_utils/ElemGraphTestUtils.hpp>
67 #include <stk_unit_test_utils/ioUtils.hpp>
68 #include <stk_unit_test_utils/getOption.h>
69
70 #include "stk_unit_test_utils/unittestMeshUtils.hpp"
71 #include <stk_unit_test_utils/MeshFixture.hpp>
72
73 #include "../../SetupKeyholeMesh.hpp"
74
75 #include "stk_unit_test_utils/stk_mesh_fixtures/QuadFixture.hpp" // for QuadFixture
76 #include "stk_unit_test_utils/stk_mesh_fixtures/degenerate_mesh.hpp"
77 #include "stk_unit_test_utils/stk_mesh_fixtures/heterogeneous_mesh.hpp"
78
79 namespace {
80
81 using namespace stk::mesh::impl;
82 using namespace stk::mesh;
83
84 inline stk::mesh::PartVector get_skin_parts(stk::mesh::MetaData &meta)
85 {
86 stk::mesh::PartVector skin_parts;
87 skin_parts.push_back(meta.get_part("skin"));
88 skin_parts.push_back(meta.get_part("active"));
89 return skin_parts;
90 }
91
92 inline void make_2_hex_mesh_with_element1_inactive(stk::mesh::BulkData& bulkData)
93 {
94 stk::mesh::MetaData &meta = bulkData.mesh_meta_data();
95 meta.declare_part_with_topology("skin", stk::topology::QUAD_4);
96 stk::mesh::Part& active = meta.declare_part("active");
97 stk::io::fill_mesh("generated:1x1x2", bulkData);
98
99 stk::mesh::EntityVector entitiesToMakeActive;
100 std::vector<stk::mesh::PartVector> add_parts;
101 std::vector<stk::mesh::PartVector> rm_parts;
102
103 stk::mesh::EntityRank rank = stk::topology::ELEM_RANK;
104 stk::mesh::Entity element1 = bulkData.get_entity(rank, 1);
105
106 if(bulkData.is_valid(element1) && bulkData.bucket(element1).owned())
107 {
108 entitiesToMakeActive.push_back(element1);
109 add_parts.push_back(stk::mesh::PartVector(1, &active));
110 rm_parts.push_back(stk::mesh::PartVector());
111 }
112 bulkData.batch_change_entity_parts(entitiesToMakeActive, add_parts, rm_parts);
113 }
114
115 } // namespace
116
117 #endif
118
119