void get_parts_with_topology(stk::mesh::BulkData& mesh, stk::mesh::PartVector& parts, bool skip_topology_root_parts=false) { parts.clear(); stk::mesh::MetaData & fem_meta = stk::mesh::MetaData::get(mesh); const stk::mesh::PartVector& all_parts = fem_meta.get_parts(); stk::mesh::PartVector::const_iterator iter = all_parts.begin(), iter_end = all_parts.end(); const CellTopologyData* topology = shards::getCellTopologyData<Traits>(); for(; iter!=iter_end; ++iter) { stk::mesh::Part* part = *iter; if (fem_meta.get_cell_topology(*part).getCellTopologyData() == topology) { if (skip_topology_root_parts && stk::mesh::is_cell_topology_root_part(*part)) { continue; } parts.push_back(part); } } }
void check_parts_allowed(const stk::mesh::BucketVector &buckets, const stk::mesh::PartVector &parts_allowed) { for (unsigned i = 0; i < buckets.size(); ++i) { const stk::mesh::Bucket &bucket = *buckets[i]; const stk::mesh::PartVector &parts_found = bucket.supersets(); for (unsigned j = 0; j < parts_found.size(); ++j) { const stk::mesh::Part *part = parts_found[j]; bool found = (std::find(parts_allowed.begin(), parts_allowed.end(), part) != parts_allowed.end()); EXPECT_TRUE(found); } } }
void pack_part_names(stk::CommBuffer& buf, const stk::mesh::PartVector& parts) { for(size_t i=0; i<parts.size(); ++i) { pack_string(buf, parts[i]->name()); } }
std::string create_string_from_parts(const stk::mesh::PartVector& parts) { std::string names; for(size_t i=0; i<parts.size(); ++i) { names += parts[i]->name() + " "; } return names; }
void ModificationSummary::writeParts(std::ostringstream& os, const std::string &label, const stk::mesh::PartVector& parts) { if(!parts.empty()) { std::vector<std::string> names(parts.size()); for(size_t i = 0; i < parts.size(); ++i) { names[i] = parts[i]->name(); } std::sort(names.begin(), names.end()); os << "\t" << label << "\n"; for(size_t i = 0; i < names.size(); ++i) { os << "\t\t" << names[i] << std::endl; } } }
void pack_part_names_except(stk::CommBuffer& buf, const stk::mesh::PartVector& parts, stk::mesh::Part* skipPart) { for(size_t i=0; i<parts.size(); ++i) { if (skipPart==nullptr || parts[i]->mesh_meta_data_ordinal() != skipPart->mesh_meta_data_ordinal()) { pack_string(buf, parts[i]->name()); } } }
TEST(UnitTestRootTopology, TestRootTopologyPartGetters) { const int spatial_dim = 3; stk::mesh::MetaData meta(spatial_dim); meta.commit(); for (unsigned i = 0; i < num_test_topologies; ++i) { stk::mesh::Part &root_part1 = meta.get_topology_root_part(test_topologies[i]); stk::mesh::CellTopology cell_topo = stk::mesh::get_cell_topology(test_topologies[i]); stk::mesh::Part &root_part2 = meta.get_cell_topology_root_part(cell_topo); EXPECT_TRUE(root_part1 == root_part2); stk::topology root_topo = root_part1.topology(); // The root_topology_part has the same topology information as the original topology. EXPECT_TRUE(test_topologies[i] == root_topo); const stk::mesh::PartVector &subsets = root_part1.subsets(); const stk::mesh::PartVector &supersets = root_part1.supersets(); EXPECT_TRUE(subsets.empty()); EXPECT_EQ(1u, supersets.size()); EXPECT_EQ(&meta.universal_part(), supersets[0]); stk::mesh::Part &root_part3 = meta.get_part(root_part1.mesh_meta_data_ordinal()); EXPECT_TRUE(root_part1 == root_part3); stk::mesh::Part *root_part4 = meta.get_part(root_part1.name()); EXPECT_TRUE(root_part1 == *root_part4); const stk::mesh::PartVector &all_parts = meta.get_parts(); const stk::mesh::PartVector non_internal_parts = meta.get_mesh_parts(); EXPECT_TRUE(std::find(all_parts.begin(), all_parts.end(), &root_part1) != all_parts.end()); EXPECT_TRUE(std::find(non_internal_parts.begin(), non_internal_parts.end(), &root_part1) == non_internal_parts.end()); } }