Debian Codegraph @

packages/stk/stk_integration_tests/stk_io/CheckSupportedInternalSidesetCases.cpp

raw
1 #include <gtest/gtest.h> // for AssertHelper, EXPECT_EQ, etc
2 #include <stddef.h> // for size_t, nullptr
3 #include <stk_io/StkMeshIoBroker.hpp> // for StkMeshIoBroker
4 #include <string> // for string
5 #include "mpi.h" // for MPI_COMM_WORLD
6 #include <stk_io/DatabasePurpose.hpp>
7 #include <stk_mesh/base/Comm.hpp>
8 #include <stk_mesh/base/MetaData.hpp>
9 #include <stk_io/FillMesh.hpp>
10 #include <stk_io/StkIoUtils.hpp>
11 #include <Ioss_SideSet.h>
12 #include <Ioss_SideBlock.h>
13 #include <stk_mesh/base/SideSetEntry.hpp>
14 #include <stk_mesh/base/SideSetUtil.hpp>
15 #include <stk_mesh/base/GetEntities.hpp>
16 #include <stk_mesh/base/ExodusTranslator.hpp>
17 #include <stk_unit_test_utils/getOption.h>
18 #include <stk_unit_test_utils/BuildMesh.hpp>
19 #include "stk_mesh/baseImpl/elementGraph/ElemElemGraph.hpp"
20
21 using stk::unit_test_util::build_mesh_no_simple_fields;
22
23 namespace
24 {
25
26 stk::mesh::EntityVector get_sides(const stk::mesh::BulkData &bulkData, const stk::mesh::Part& sidesetPart)
27 {
28 const stk::mesh::MetaData &meta = bulkData.mesh_meta_data();
29 stk::mesh::EntityVector sides;
30 stk::mesh::Selector sideSelector = sidesetPart & ( meta.locally_owned_part() | meta.globally_shared_part());
31 stk::mesh::get_selected_entities(sideSelector, bulkData.buckets(meta.side_rank()), sides);
32 return sides;
33 }
34
35 bool is_sideset_case_supported(const std::string& input_file_name, stk::mesh::BulkData::AutomaticAuraOption auraOption)
36 {
37 bool supported = true;
38 if(stk::parallel_machine_size(MPI_COMM_WORLD) < 3)
39 {
40 stk::ParallelMachine comm = MPI_COMM_WORLD;
41
42 std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh_no_simple_fields(comm, auraOption);
43 stk::mesh::MetaData& meta = bulk->mesh_meta_data();
44 stk::io::fill_mesh_with_auto_decomp(input_file_name, *bulk);
45
46 const stk::mesh::ElemElemGraph &graph = bulk->get_face_adjacent_element_graph();
47 stk::mesh::impl::ParallelPartInfo parallelPartInfo;
48 stk::mesh::impl::populate_part_ordinals_for_remote_edges(*bulk, graph, parallelPartInfo);
49
50 const stk::mesh::PartVector& allparts = meta.get_mesh_parts();
51 for(auto sidesetPart : allparts)
52 {
53 if(stk::mesh::is_side_set(*sidesetPart))
54 supported = supported & stk::mesh::does_not_contain_internal_sideset(*bulk, get_sides(*bulk, *sidesetPart), parallelPartInfo);
55 }
56 }
57 return supported;
58 }
59
60 void test_supported_sideset_cases_with_aura_option(stk::mesh::BulkData::AutomaticAuraOption auraOption)
61 {
62 std::string exodusFileName = stk::unit_test_util::get_option("-i", "none");
63
64 if(exodusFileName=="none")
65 {
66 if(stk::parallel_machine_size(MPI_COMM_WORLD) <= 2)
67 {
68 std::vector<std::string> files ={"ADA.e", "ARA.e", "ALA.e"};
69 for(std::string& filename : files)
70 EXPECT_FALSE(is_sideset_case_supported(filename, auraOption));
71 }
72 }
73 else
74 {
75 if(is_sideset_case_supported(exodusFileName, auraOption))
76 std::cerr << "Sidesets in file are OK\n";
77 else
78 std::cerr << "Sidesets in file are not supported\n";
79 }
80 }
81
82 TEST(StkIo, unsupported_cases_with_aura)
83 {
84 test_supported_sideset_cases_with_aura_option(stk::mesh::BulkData::AUTO_AURA);
85 }
86
87 TEST(StkIo, unsupported_cases_without_aura)
88 {
89 test_supported_sideset_cases_with_aura_option(stk::mesh::BulkData::NO_AUTO_AURA);
90 }
91
92 }