| 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 |
|
| 37 |
#include <algorithm> |
| 38 |
#include <stk_io/FillMesh.hpp> |
| 39 |
#include <stk_io/IossBridge.hpp> |
| 40 |
#include <stk_mesh/base/CompositeRank.hpp> |
| 41 |
#include <stk_mesh/base/GetEntities.hpp> |
| 42 |
#include <stk_mesh/base/MetaData.hpp> |
| 43 |
#include <stk_mesh/base/Part.hpp> |
| 44 |
#include <stk_mesh/base/Selector.hpp> |
| 45 |
#include <stk_ngp_test/ngp_test.hpp> |
| 46 |
#include <stk_topology/topology.hpp> |
| 47 |
#include <stk_unit_test_utils/TextMesh.hpp> |
| 48 |
|
| 49 |
#include "Assembly.hpp" |
| 50 |
|
| 51 |
namespace stk |
| 52 |
{ |
| 53 |
namespace io |
| 54 |
{ |
| 55 |
namespace unit_test |
| 56 |
{ |
| 57 |
|
| 58 |
class GetAssemblyEntities : public stk::io::unit_test::Assembly |
| 59 |
{ |
| 60 |
protected: |
| 61 |
struct BucketTestData { |
| 62 |
BucketTestData() : topology(stk::topology::INVALID_TOPOLOGY) {} |
| 63 |
|
| 64 |
BucketTestData(stk::topology topology_, const std::vector<size_t>& entitiesPerBucket_ = {}) |
| 65 |
: topology(topology_), entitiesPerBucket(entitiesPerBucket_) |
| 66 |
{ |
| 67 |
} |
| 68 |
|
| 69 |
stk::topology topology; |
| 70 |
std::vector<size_t> entitiesPerBucket; |
| 71 |
}; |
| 72 |
|
| 73 |
struct EntityTestData { |
| 74 |
EntityTestData() : numUniqueLeaves(0) {} |
| 75 |
|
| 76 |
EntityTestData(size_t numUniqueLeaves_, const stk::mesh::EntityIdVector& ids_) |
| 77 |
: numUniqueLeaves(numUniqueLeaves_), ids(ids_) |
| 78 |
{ |
| 79 |
} |
| 80 |
|
| 81 |
size_t numUniqueLeaves; |
| 82 |
stk::mesh::EntityIdVector ids; |
| 83 |
}; |
| 84 |
|
| 85 |
void verify_num_elements(size_t goldCount) |
| 86 |
{ |
| 87 |
std::vector<size_t> counts; |
| 88 |
stk::mesh::count_entities(get_meta().universal_part(), get_bulk(), counts); |
| 89 |
EXPECT_EQ(goldCount, counts[stk::topology::ELEM_RANK]); |
| 90 |
} |
| 91 |
|
| 92 |
void verify_single_element( |
| 93 |
stk::mesh::EntityId elemId, stk::topology topology, const stk::mesh::EntityIdVector& nodeIds) |
| 94 |
{ |
| 95 |
stk::mesh::Entity element = get_bulk().get_entity(stk::topology::ELEM_RANK, elemId); |
| 96 |
EXPECT_TRUE(get_bulk().is_valid(element)); |
| 97 |
EXPECT_EQ(topology, get_bulk().bucket(element).topology()); |
| 98 |
verify_nodes_on_element(element, nodeIds); |
| 99 |
} |
| 100 |
|
| 101 |
void verify_nodes_on_element(stk::mesh::Entity element, const stk::mesh::EntityIdVector& goldNodeIds) |
| 102 |
{ |
| 103 |
stk::mesh::EntityVector nodes(get_bulk().begin_nodes(element), get_bulk().end_nodes(element)); |
| 104 |
EXPECT_EQ(goldNodeIds, get_node_ids(nodes)); |
| 105 |
} |
| 106 |
|
| 107 |
stk::mesh::EntityIdVector get_node_ids(const stk::mesh::EntityVector& nodes) |
| 108 |
{ |
| 109 |
stk::mesh::EntityIdVector nodeIds; |
| 110 |
for (const stk::mesh::Entity& node : nodes) { |
| 111 |
nodeIds.emplace_back(get_bulk().identifier(node)); |
| 112 |
} |
| 113 |
return nodeIds; |
| 114 |
} |
| 115 |
|
| 116 |
void test_get_buckets(stk::mesh::Part& assemblyPart, stk::mesh::EntityRank rank, const BucketTestData& gold) |
| 117 |
{ |
| 118 |
stk::mesh::PartVector parts = stk::io::get_unique_leaf_parts(get_meta(), assemblyPart.name()); |
| 119 |
EXPECT_EQ(1u, parts.size()); |
| 120 |
|
| 121 |
stk::mesh::Selector assemblySelector(assemblyPart); |
| 122 |
stk::mesh::BucketVector buckets = get_bulk().get_buckets(rank, assemblySelector); |
| 123 |
EXPECT_EQ(gold.entitiesPerBucket.size(), buckets.size()); |
| 124 |
|
| 125 |
for (size_t i = 0; i < buckets.size(); ++i) { |
| 126 |
auto bucket = buckets[i]; |
| 127 |
EXPECT_EQ(gold.topology, bucket->topology()); |
| 128 |
EXPECT_EQ(gold.entitiesPerBucket[i], bucket->size()); |
| 129 |
EXPECT_TRUE(bucket->member_any(parts)); |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
stk::mesh::EntityVector get_sorted_entities_from_ids(stk::mesh::EntityRank rank, const stk::mesh::EntityIdVector& ids) |
| 134 |
{ |
| 135 |
stk::mesh::EntityVector entities; |
| 136 |
entities.reserve(ids.size()); |
| 137 |
|
| 138 |
for (auto id : ids) { |
| 139 |
stk::mesh::Entity entity = get_bulk().get_entity(rank, id); |
| 140 |
EXPECT_TRUE(get_bulk().is_valid(entity)) << "Invalid entity id: " << id << " of rank: " << rank; |
| 141 |
entities.push_back(entity); |
| 142 |
} |
| 143 |
std::sort(entities.begin(), entities.end(), stk::mesh::EntityLess(get_bulk())); |
| 144 |
|
| 145 |
return entities; |
| 146 |
} |
| 147 |
|
| 148 |
void compare_selected_entities( |
| 149 |
stk::mesh::Part& assemblyPart, stk::mesh::EntityRank rank, const stk::mesh::EntityIdVector& goldIds) |
| 150 |
{ |
| 151 |
stk::mesh::EntityVector goldEntities = get_sorted_entities_from_ids(rank, goldIds); |
| 152 |
|
| 153 |
stk::mesh::Selector assemblySelector(assemblyPart); |
| 154 |
stk::mesh::EntityVector entities; |
| 155 |
stk::mesh::get_entities(get_bulk(), rank, assemblySelector, entities); |
| 156 |
EXPECT_EQ(goldEntities.size(), entities.size()); |
| 157 |
|
| 158 |
for (auto entity : entities) { |
| 159 |
stk::mesh::EntityKey key = get_bulk().entity_key(entity); |
| 160 |
EXPECT_TRUE( |
| 161 |
std::binary_search(goldEntities.begin(), goldEntities.end(), entity, stk::mesh::EntityLess(get_bulk()))) |
| 162 |
<< "Could not find selected entity: " << key << " in gold list"; |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
void test_get_entities(stk::mesh::Part& assemblyPart, stk::mesh::EntityRank rank, const EntityTestData& gold) |
| 167 |
{ |
| 168 |
stk::mesh::PartVector parts = stk::io::get_unique_leaf_parts(get_meta(), assemblyPart.name()); |
| 169 |
EXPECT_EQ(gold.numUniqueLeaves, parts.size()); |
| 170 |
compare_selected_entities(assemblyPart, rank, gold.ids); |
| 171 |
} |
| 172 |
|
| 173 |
stk::mesh::Part& setup_single_particle_mesh() |
| 174 |
{ |
| 175 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 176 |
|
| 177 |
const std::string assemblyName("simpleAssembly"); |
| 178 |
stk::mesh::Part& assemblyPart = create_single_particle_assembly(assemblyName, 10); |
| 179 |
create_single_particle_mesh(); |
| 180 |
return assemblyPart; |
| 181 |
} |
| 182 |
|
| 183 |
void create_single_particle_mesh() |
| 184 |
{ |
| 185 |
std::string meshDesc = "textmesh:0,1,PARTICLE,1,block_1"; |
| 186 |
stk::io::fill_mesh(meshDesc, get_bulk()); |
| 187 |
} |
| 188 |
|
| 189 |
stk::mesh::Part& create_single_particle_assembly(const std::string& assemblyName, int id) |
| 190 |
{ |
| 191 |
const std::vector<std::string> partNames{"block_1"}; |
| 192 |
|
| 193 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, id); |
| 194 |
stk::mesh::Part& block1Part = create_io_part(partNames[0], 1, stk::topology::PARTICLE); |
| 195 |
declare_subsets(assemblyPart, {&block1Part}); |
| 196 |
|
| 197 |
return assemblyPart; |
| 198 |
} |
| 199 |
|
| 200 |
stk::mesh::Part& setup_single_hex_mesh(stk::mesh::EntityRank assemblyRank = stk::topology::INVALID_RANK) |
| 201 |
{ |
| 202 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 203 |
|
| 204 |
const std::string assemblyName("simpleAssembly"); |
| 205 |
stk::mesh::Part& assemblyPart = create_single_hex_assembly(assemblyName, 10, assemblyRank); |
| 206 |
create_single_hex_mesh(); |
| 207 |
return assemblyPart; |
| 208 |
} |
| 209 |
|
| 210 |
void create_single_hex_mesh() |
| 211 |
{ |
| 212 |
std::string meshDesc = "textmesh:0,1,HEX_8,1,2,3,4,5,6,7,8,block_1"; |
| 213 |
stk::io::fill_mesh(meshDesc, get_bulk()); |
| 214 |
} |
| 215 |
|
| 216 |
stk::mesh::Part& create_single_hex_assembly(const std::string& assemblyName, int id, |
| 217 |
stk::mesh::EntityRank assemblyRank = stk::topology::INVALID_RANK) |
| 218 |
{ |
| 219 |
const std::vector<std::string> partNames{"block_1"}; |
| 220 |
|
| 221 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, id, assemblyRank); |
| 222 |
stk::mesh::Part& block1Part = create_io_part(partNames[0], 1); |
| 223 |
declare_subsets(assemblyPart, {&block1Part}); |
| 224 |
|
| 225 |
return assemblyPart; |
| 226 |
} |
| 227 |
|
| 228 |
stk::mesh::Part& setup_two_hex_mesh_with_block_in_assembly(const std::string& assemblyBlock) |
| 229 |
{ |
| 230 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 231 |
|
| 232 |
const std::string assemblyName("simpleAssembly"); |
| 233 |
stk::mesh::Part& assemblyPart = create_two_hex_blocks_and_assembly_from_block(assemblyName, 10, assemblyBlock); |
| 234 |
create_two_hex_mesh(); |
| 235 |
|
| 236 |
return assemblyPart; |
| 237 |
} |
| 238 |
|
| 239 |
void create_two_hex_mesh() |
| 240 |
{ |
| 241 |
std::string meshDesc = |
| 242 |
"textmesh:" |
| 243 |
"0,1,HEX_8,1,2,3,4,5, 6, 7, 8,block_1\n" |
| 244 |
"0,2,HEX_8,5,6,7,8,9,10,11,12,block_2"; |
| 245 |
stk::io::fill_mesh(meshDesc, get_bulk()); |
| 246 |
|
| 247 |
verify_num_elements(2); |
| 248 |
verify_single_element(1, stk::topology::HEX_8, stk::mesh::EntityIdVector{1, 2, 3, 4, 5, 6, 7, 8}); |
| 249 |
verify_single_element(2, stk::topology::HEX_8, stk::mesh::EntityIdVector{5, 6, 7, 8, 9, 10, 11, 12}); |
| 250 |
} |
| 251 |
|
| 252 |
stk::mesh::Part& create_two_hex_blocks_and_assembly_from_block( |
| 253 |
const std::string& assemblyName, int id, const std::string& assemblyBlock) |
| 254 |
{ |
| 255 |
return create_two_blocks_and_assembly_from_block( |
| 256 |
assemblyName, id, assemblyBlock, {stk::topology::HEX_8, stk::topology::HEX_8}); |
| 257 |
} |
| 258 |
|
| 259 |
stk::mesh::Part& setup_hex_pyramid_mesh_with_block_in_assembly(const std::string& assemblyBlock) |
| 260 |
{ |
| 261 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 262 |
|
| 263 |
const std::string assemblyName("simpleAssembly"); |
| 264 |
stk::mesh::Part& assemblyPart = create_hex_pyramid_blocks_and_assembly_from_block(assemblyName, 10, assemblyBlock); |
| 265 |
create_hex_pyramid_mesh(); |
| 266 |
|
| 267 |
return assemblyPart; |
| 268 |
} |
| 269 |
|
| 270 |
void create_hex_pyramid_mesh() |
| 271 |
{ |
| 272 |
std::string meshDesc = |
| 273 |
"textmesh:" |
| 274 |
"0,1,HEX_8,1,2,3,4,5,6,7,8,block_1\n" |
| 275 |
"0,2,PYRAMID_5,5,6,7,8,9,block_2"; |
| 276 |
stk::io::fill_mesh(meshDesc, get_bulk()); |
| 277 |
|
| 278 |
verify_num_elements(2); |
| 279 |
verify_single_element(1, stk::topology::HEX_8, stk::mesh::EntityIdVector{1, 2, 3, 4, 5, 6, 7, 8}); |
| 280 |
verify_single_element(2, stk::topology::PYRAMID_5, stk::mesh::EntityIdVector{5, 6, 7, 8, 9}); |
| 281 |
} |
| 282 |
|
| 283 |
stk::mesh::Part& create_hex_pyramid_blocks_and_assembly_from_block( |
| 284 |
const std::string& assemblyName, int id, const std::string& assemblyBlock) |
| 285 |
{ |
| 286 |
return create_two_blocks_and_assembly_from_block( |
| 287 |
assemblyName, id, assemblyBlock, {stk::topology::HEX_8, stk::topology::PYRAMID_5}); |
| 288 |
} |
| 289 |
|
| 290 |
stk::mesh::Part& create_two_blocks_and_assembly_from_block(const std::string& assemblyName, |
| 291 |
int id, |
| 292 |
const std::string& assemblyBlock, |
| 293 |
const std::vector<stk::topology>& blockTopologies) |
| 294 |
{ |
| 295 |
const std::vector<std::string> partNames{"block_1", "block_2"}; |
| 296 |
assert((assemblyBlock == partNames[0]) || (assemblyBlock == partNames[1])); |
| 297 |
assert(blockTopologies.size() == 2); |
| 298 |
|
| 299 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, id); |
| 300 |
stk::mesh::Part& block1Part = create_io_part(partNames[0], 1, blockTopologies[0]); |
| 301 |
stk::mesh::Part& block2Part = create_io_part(partNames[1], 2, blockTopologies[1]); |
| 302 |
|
| 303 |
if (assemblyBlock == partNames[0]) { |
| 304 |
declare_subsets(assemblyPart, {&block1Part}); |
| 305 |
} else if (assemblyBlock == partNames[1]) { |
| 306 |
declare_subsets(assemblyPart, {&block2Part}); |
| 307 |
} |
| 308 |
|
| 309 |
return assemblyPart; |
| 310 |
} |
| 311 |
}; |
| 312 |
|
| 313 |
TEST_F(GetAssemblyEntities, noEntities) |
| 314 |
{ |
| 315 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 316 |
|
| 317 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 318 |
|
| 319 |
const std::string assemblyName("myAssembly"); |
| 320 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 100); |
| 321 |
|
| 322 |
test_assembly_part_attributes(assemblyPart); |
| 323 |
test_get_entities(assemblyPart, stk::topology::ELEM_RANK, EntityTestData(0, {})); |
| 324 |
test_get_entities(assemblyPart, stk::topology::FACE_RANK, EntityTestData(0, {})); |
| 325 |
test_get_entities(assemblyPart, stk::topology::EDGE_RANK, EntityTestData(0, {})); |
| 326 |
test_get_entities(assemblyPart, stk::topology::NODE_RANK, EntityTestData(0, {})); |
| 327 |
} |
| 328 |
|
| 329 |
TEST_F(GetAssemblyEntities, singleParticle_getElementBucket) |
| 330 |
{ |
| 331 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 332 |
|
| 333 |
stk::mesh::Part& assemblyPart = setup_single_particle_mesh(); |
| 334 |
|
| 335 |
test_assembly_part_attributes(assemblyPart); |
| 336 |
test_get_buckets(assemblyPart, stk::topology::ELEM_RANK, BucketTestData(stk::topology::PARTICLE, {1})); |
| 337 |
} |
| 338 |
|
| 339 |
TEST_F(GetAssemblyEntities, singleParticle_getElement) |
| 340 |
{ |
| 341 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 342 |
|
| 343 |
stk::mesh::Part& assemblyPart = setup_single_particle_mesh(); |
| 344 |
|
| 345 |
test_assembly_part_attributes(assemblyPart); |
| 346 |
test_get_entities(assemblyPart, stk::topology::ELEM_RANK, EntityTestData(1, {1})); |
| 347 |
} |
| 348 |
|
| 349 |
TEST_F(GetAssemblyEntities, singleParticle_getNodeBucket) |
| 350 |
{ |
| 351 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 352 |
|
| 353 |
stk::mesh::Part& assemblyPart = setup_single_particle_mesh(); |
| 354 |
|
| 355 |
test_assembly_part_attributes(assemblyPart); |
| 356 |
test_get_buckets(assemblyPart, stk::topology::NODE_RANK, BucketTestData(stk::topology::NODE, {1})); |
| 357 |
} |
| 358 |
|
| 359 |
TEST_F(GetAssemblyEntities, singleParticle_getNode) |
| 360 |
{ |
| 361 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 362 |
|
| 363 |
stk::mesh::Part& assemblyPart = setup_single_particle_mesh(); |
| 364 |
|
| 365 |
test_assembly_part_attributes(assemblyPart); |
| 366 |
test_get_entities(assemblyPart, stk::topology::NODE_RANK, EntityTestData(1, {1})); |
| 367 |
} |
| 368 |
|
| 369 |
TEST_F(GetAssemblyEntities, singleHex_getElementBucket) |
| 370 |
{ |
| 371 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 372 |
|
| 373 |
stk::mesh::Part& assemblyPart = setup_single_hex_mesh(); |
| 374 |
|
| 375 |
test_assembly_part_attributes(assemblyPart); |
| 376 |
test_get_buckets(assemblyPart, stk::topology::ELEM_RANK, BucketTestData(stk::topology::HEX_8, {1})); |
| 377 |
} |
| 378 |
|
| 379 |
TEST_F(GetAssemblyEntities, singleHex_getElementBucket_rankedAssemblyPart) |
| 380 |
{ |
| 381 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 382 |
|
| 383 |
stk::mesh::Part& assemblyPart = setup_single_hex_mesh(stk::topology::ELEM_RANK); |
| 384 |
|
| 385 |
test_assembly_part_attributes(assemblyPart); |
| 386 |
test_get_buckets(assemblyPart, stk::topology::ELEM_RANK, BucketTestData(stk::topology::HEX_8, {1})); |
| 387 |
} |
| 388 |
|
| 389 |
TEST_F(GetAssemblyEntities, singleHex_getElement) |
| 390 |
{ |
| 391 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 392 |
|
| 393 |
stk::mesh::Part& assemblyPart = setup_single_hex_mesh(); |
| 394 |
|
| 395 |
test_assembly_part_attributes(assemblyPart); |
| 396 |
test_get_entities(assemblyPart, stk::topology::ELEM_RANK, EntityTestData(1, {1})); |
| 397 |
} |
| 398 |
|
| 399 |
TEST_F(GetAssemblyEntities, singleHex_getNodeBucket) |
| 400 |
{ |
| 401 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 402 |
|
| 403 |
stk::mesh::Part& assemblyPart = setup_single_hex_mesh(); |
| 404 |
|
| 405 |
test_assembly_part_attributes(assemblyPart); |
| 406 |
test_get_buckets(assemblyPart, stk::topology::NODE_RANK, BucketTestData(stk::topology::NODE, {8})); |
| 407 |
} |
| 408 |
|
| 409 |
TEST_F(GetAssemblyEntities, singleHex_getNodes) |
| 410 |
{ |
| 411 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 412 |
|
| 413 |
stk::mesh::Part& assemblyPart = setup_single_hex_mesh(); |
| 414 |
|
| 415 |
test_assembly_part_attributes(assemblyPart); |
| 416 |
test_get_entities(assemblyPart, stk::topology::NODE_RANK, EntityTestData(1, {1, 2, 3, 4, 5, 6, 7, 8})); |
| 417 |
} |
| 418 |
|
| 419 |
TEST_F(GetAssemblyEntities, twoHexDifferentBlocks_getElementBucket) |
| 420 |
{ |
| 421 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 422 |
|
| 423 |
const std::string assemblyBlock("block_1"); |
| 424 |
stk::mesh::Part& assemblyPart = setup_two_hex_mesh_with_block_in_assembly(assemblyBlock); |
| 425 |
|
| 426 |
test_assembly_part_attributes(assemblyPart); |
| 427 |
test_get_buckets(assemblyPart, stk::topology::ELEM_RANK, BucketTestData(stk::topology::HEX_8, {1})); |
| 428 |
} |
| 429 |
|
| 430 |
TEST_F(GetAssemblyEntities, twoHexDifferentBlocks_getElement) |
| 431 |
{ |
| 432 |
if (stk::parallel_machine_size(get_comm()) != 1) { GTEST_SKIP(); } |
| 433 |
|
| 434 |
const std::string assemblyBlock("block_1"); |
| 435 |
stk::mesh::Part& assemblyPart = setup_two_hex_mesh_with_block_in_assembly(assemblyBlock); |
| 436 |
|
| 437 |
test_assembly_part_attributes(assemblyPart); |
| 438 |
test_get_entities(assemblyPart, stk::topology::ELEM_RANK, EntityTestData(1, {1})); |
| 439 |
} |
| 440 |
|
| 441 |
TEST_F(GetAssemblyEntities, twoHexDifferentBlocks_getNodeBuckets) |
| 442 |
{ |
| 443 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 444 |
return; |
| 445 |
} |
| 446 |
|
| 447 |
const std::string assemblyBlock("block_1"); |
| 448 |
stk::mesh::Part& assemblyPart = setup_two_hex_mesh_with_block_in_assembly(assemblyBlock); |
| 449 |
|
| 450 |
test_assembly_part_attributes(assemblyPart); |
| 451 |
test_get_buckets(assemblyPart, stk::topology::NODE_RANK, BucketTestData(stk::topology::NODE, {4, 4})); |
| 452 |
} |
| 453 |
|
| 454 |
TEST_F(GetAssemblyEntities, twoHexDifferentBlocks_getNodes) |
| 455 |
{ |
| 456 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 457 |
return; |
| 458 |
} |
| 459 |
|
| 460 |
const std::string assemblyBlock("block_2"); |
| 461 |
stk::mesh::Part& assemblyPart = setup_two_hex_mesh_with_block_in_assembly(assemblyBlock); |
| 462 |
|
| 463 |
test_assembly_part_attributes(assemblyPart); |
| 464 |
test_get_entities(assemblyPart, stk::topology::NODE_RANK, EntityTestData(1, {5, 6, 7, 8, 9, 10, 11, 12})); |
| 465 |
} |
| 466 |
|
| 467 |
TEST_F(GetAssemblyEntities, hexPyramidMesh_getElementBucketOnHex) |
| 468 |
{ |
| 469 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 470 |
return; |
| 471 |
} |
| 472 |
|
| 473 |
const std::string assemblyBlock("block_1"); |
| 474 |
stk::mesh::Part& assemblyPart = setup_hex_pyramid_mesh_with_block_in_assembly(assemblyBlock); |
| 475 |
|
| 476 |
test_assembly_part_attributes(assemblyPart); |
| 477 |
test_get_buckets(assemblyPart, stk::topology::ELEM_RANK, BucketTestData(stk::topology::HEX_8, {1})); |
| 478 |
} |
| 479 |
|
| 480 |
TEST_F(GetAssemblyEntities, hexPyramidMesh_getElementBucketOnPyramid) |
| 481 |
{ |
| 482 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 483 |
return; |
| 484 |
} |
| 485 |
|
| 486 |
const std::string assemblyBlock("block_2"); |
| 487 |
stk::mesh::Part& assemblyPart = setup_hex_pyramid_mesh_with_block_in_assembly(assemblyBlock); |
| 488 |
|
| 489 |
test_assembly_part_attributes(assemblyPart); |
| 490 |
test_get_buckets(assemblyPart, stk::topology::ELEM_RANK, BucketTestData(stk::topology::PYRAMID_5, {1})); |
| 491 |
} |
| 492 |
|
| 493 |
TEST_F(GetAssemblyEntities, hexPyramidMesh_getElementOnHex) |
| 494 |
{ |
| 495 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 496 |
return; |
| 497 |
} |
| 498 |
|
| 499 |
const std::string assemblyBlock("block_1"); |
| 500 |
stk::mesh::Part& assemblyPart = setup_hex_pyramid_mesh_with_block_in_assembly(assemblyBlock); |
| 501 |
|
| 502 |
test_assembly_part_attributes(assemblyPart); |
| 503 |
test_get_entities(assemblyPart, stk::topology::ELEM_RANK, EntityTestData(1, {1})); |
| 504 |
} |
| 505 |
|
| 506 |
TEST_F(GetAssemblyEntities, hexPyramidMesh_getElementOnPyramid) |
| 507 |
{ |
| 508 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 509 |
return; |
| 510 |
} |
| 511 |
|
| 512 |
const std::string assemblyBlock("block_2"); |
| 513 |
stk::mesh::Part& assemblyPart = setup_hex_pyramid_mesh_with_block_in_assembly(assemblyBlock); |
| 514 |
|
| 515 |
test_assembly_part_attributes(assemblyPart); |
| 516 |
test_get_entities(assemblyPart, stk::topology::ELEM_RANK, EntityTestData(1, {2})); |
| 517 |
} |
| 518 |
|
| 519 |
TEST_F(GetAssemblyEntities, hexPyramidMesh_getNodeBucketsOnHex) |
| 520 |
{ |
| 521 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 522 |
return; |
| 523 |
} |
| 524 |
|
| 525 |
const std::string assemblyBlock("block_1"); |
| 526 |
stk::mesh::Part& assemblyPart = setup_hex_pyramid_mesh_with_block_in_assembly(assemblyBlock); |
| 527 |
|
| 528 |
test_assembly_part_attributes(assemblyPart); |
| 529 |
test_get_buckets(assemblyPart, stk::topology::NODE_RANK, BucketTestData(stk::topology::NODE, {4, 4})); |
| 530 |
} |
| 531 |
|
| 532 |
TEST_F(GetAssemblyEntities, hexPyramidMesh_getNodeBucketsOnPyramid) |
| 533 |
{ |
| 534 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 535 |
return; |
| 536 |
} |
| 537 |
|
| 538 |
const std::string assemblyBlock("block_2"); |
| 539 |
stk::mesh::Part& assemblyPart = setup_hex_pyramid_mesh_with_block_in_assembly(assemblyBlock); |
| 540 |
|
| 541 |
test_assembly_part_attributes(assemblyPart); |
| 542 |
test_get_buckets(assemblyPart, stk::topology::NODE_RANK, BucketTestData(stk::topology::NODE, {1, 4})); |
| 543 |
} |
| 544 |
|
| 545 |
TEST_F(GetAssemblyEntities, hexPyramidMesh_getNodesOnHex) |
| 546 |
{ |
| 547 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 548 |
return; |
| 549 |
} |
| 550 |
|
| 551 |
const std::string assemblyBlock("block_1"); |
| 552 |
stk::mesh::Part& assemblyPart = setup_hex_pyramid_mesh_with_block_in_assembly(assemblyBlock); |
| 553 |
|
| 554 |
test_assembly_part_attributes(assemblyPart); |
| 555 |
test_get_entities(assemblyPart, stk::topology::NODE_RANK, EntityTestData(1, {1, 2, 3, 4, 5, 6, 7, 8})); |
| 556 |
} |
| 557 |
|
| 558 |
TEST_F(GetAssemblyEntities, hexPyramidMesh_getNodesOnPyramid) |
| 559 |
{ |
| 560 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 561 |
return; |
| 562 |
} |
| 563 |
|
| 564 |
const std::string assemblyBlock("block_2"); |
| 565 |
stk::mesh::Part& assemblyPart = setup_hex_pyramid_mesh_with_block_in_assembly(assemblyBlock); |
| 566 |
|
| 567 |
test_assembly_part_attributes(assemblyPart); |
| 568 |
test_get_entities(assemblyPart, stk::topology::NODE_RANK, EntityTestData(1, {5, 6, 7, 8, 9})); |
| 569 |
} |
| 570 |
|
| 571 |
// (ID) = nodeset assembly nodes |
| 572 |
// [ID] = sideset assembly faces |
| 573 |
// {ID} = element block assembly elements |
| 574 |
// |
| 575 |
// 3--------------7------------(11)-------------15 |
| 576 |
// /| /| /| /| |
| 577 |
// / | / | / | / | |
| 578 |
// / | / | / | / | |
| 579 |
// 4--------------8------------(12)-------------16 | |
| 580 |
// | | | | | | | | |
| 581 |
// [15] | | {1} | | 2 | | 3 | | [36] |
| 582 |
// | | | | | | | | |
| 583 |
// | 2----------|---6----------|-(10)---------|---14 |
| 584 |
// Y | / | / | / | / |
| 585 |
// | X | / | / | / | / |
| 586 |
// | / |/ |/ |/ |/ |
| 587 |
// |/ 1--------------5-------------(9)-------------13 |
| 588 |
// ------Z |
| 589 |
|
| 590 |
TEST_F(GetAssemblyEntities, heterogeneousAssemblies) |
| 591 |
{ |
| 592 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 593 |
return; |
| 594 |
} |
| 595 |
|
| 596 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 597 |
|
| 598 |
const std::string assemblyName("simpleAssembly"); |
| 599 |
|
| 600 |
stk::mesh::Part& block1Assembly = create_assembly("block1Assembly", 10); |
| 601 |
stk::mesh::Part& surface1Assembly = create_assembly("surface1Assembly", 11); |
| 602 |
stk::mesh::Part& surface2Assembly = create_assembly("surface2Assembly", 12); |
| 603 |
stk::mesh::Part& surface1And2Assembly = create_assembly("surface1And2Assembly", 13); |
| 604 |
stk::mesh::Part& block1AndSurface1And2Assembly = create_assembly("block1AndSurface1And2Assembly", 14); |
| 605 |
stk::mesh::Part& nodeset1Assembly = create_assembly("nodeset1Assembly", 15); |
| 606 |
stk::mesh::Part& block1AndSurface1And2AndNodeset1Assembly = |
| 607 |
create_assembly("block1AndSurface1And2AndNodeset1Assembly", 16); |
| 608 |
|
| 609 |
stk::mesh::Part& block1 = create_io_part("block_1", 1, stk::topology::HEX_8); |
| 610 |
stk::mesh::Part& block2 = create_io_part("block_2", 2, stk::topology::HEX_8); |
| 611 |
stk::mesh::Part& surface1 = create_io_part("surface_1", 1, stk::topology::QUAD_4); |
| 612 |
stk::mesh::Part& surface2 = create_io_part("surface_2", 2, stk::topology::QUAD_4); |
| 613 |
stk::mesh::Part& nodeset1 = create_io_part("nodelist_1", 1, stk::topology::NODE); |
| 614 |
|
| 615 |
stk::io::fill_mesh("generated:1x1x3|sideset:zZ", get_bulk()); |
| 616 |
|
| 617 |
move_element(2, block1, block2); |
| 618 |
move_element(3, block1, block2); |
| 619 |
|
| 620 |
add_nodes({9, 10, 11, 12}, nodeset1); |
| 621 |
|
| 622 |
declare_subsets(block1Assembly, {&block1}); |
| 623 |
declare_subsets(surface1Assembly, {&surface1}); |
| 624 |
declare_subsets(surface2Assembly, {&surface2}); |
| 625 |
declare_subsets(surface1And2Assembly, {&surface1Assembly, &surface2Assembly}); |
| 626 |
declare_subsets(block1AndSurface1And2Assembly, {&block1Assembly, &surface1Assembly, &surface2Assembly}); |
| 627 |
declare_subsets(nodeset1Assembly, {&nodeset1}); |
| 628 |
declare_subsets( |
| 629 |
block1AndSurface1And2AndNodeset1Assembly, {&block1Assembly, &surface1Assembly, &surface2Assembly, &nodeset1}); |
| 630 |
|
| 631 |
EXPECT_EQ(stk::topology::ELEM_RANK, stk::mesh::CompositeRank::get_rank(block1Assembly)); |
| 632 |
EXPECT_EQ(stk::topology::FACE_RANK, stk::mesh::CompositeRank::get_rank(surface1Assembly)); |
| 633 |
EXPECT_EQ(stk::topology::FACE_RANK, stk::mesh::CompositeRank::get_rank(surface2Assembly)); |
| 634 |
EXPECT_EQ(stk::topology::FACE_RANK, stk::mesh::CompositeRank::get_rank(surface1And2Assembly)); |
| 635 |
EXPECT_EQ(stk::topology::INVALID_RANK, stk::mesh::CompositeRank::get_rank(block1AndSurface1And2Assembly)); |
| 636 |
EXPECT_EQ(stk::topology::NODE_RANK, stk::mesh::CompositeRank::get_rank(nodeset1Assembly)); |
| 637 |
EXPECT_EQ(stk::topology::INVALID_RANK, stk::mesh::CompositeRank::get_rank(block1AndSurface1And2AndNodeset1Assembly)); |
| 638 |
|
| 639 |
test_assembly_part_attributes(block1Assembly); |
| 640 |
test_assembly_part_attributes(surface1Assembly); |
| 641 |
test_assembly_part_attributes(surface2Assembly); |
| 642 |
test_assembly_part_attributes(surface1And2Assembly); |
| 643 |
test_assembly_part_attributes(block1AndSurface1And2Assembly); |
| 644 |
test_assembly_part_attributes(nodeset1Assembly); |
| 645 |
test_assembly_part_attributes(block1AndSurface1And2AndNodeset1Assembly); |
| 646 |
|
| 647 |
compare_selected_entities(block1Assembly, stk::topology::ELEM_RANK, {1}); |
| 648 |
compare_selected_entities(block1Assembly, stk::topology::FACE_RANK, {15}); |
| 649 |
compare_selected_entities(block1Assembly, stk::topology::EDGE_RANK, {}); |
| 650 |
compare_selected_entities(block1Assembly, stk::topology::NODE_RANK, {1, 2, 3, 4, 5, 6, 7, 8}); |
| 651 |
|
| 652 |
compare_selected_entities(surface1Assembly, stk::topology::FACE_RANK, {15}); |
| 653 |
compare_selected_entities(surface1Assembly, stk::topology::EDGE_RANK, {}); |
| 654 |
compare_selected_entities(surface1Assembly, stk::topology::NODE_RANK, {1, 2, 3, 4}); |
| 655 |
|
| 656 |
compare_selected_entities(surface2Assembly, stk::topology::FACE_RANK, {36}); |
| 657 |
compare_selected_entities(surface2Assembly, stk::topology::EDGE_RANK, {}); |
| 658 |
compare_selected_entities(surface2Assembly, stk::topology::NODE_RANK, {13, 14, 15, 16}); |
| 659 |
|
| 660 |
compare_selected_entities(surface1And2Assembly, stk::topology::FACE_RANK, {15, 36}); |
| 661 |
compare_selected_entities(surface1And2Assembly, stk::topology::EDGE_RANK, {}); |
| 662 |
compare_selected_entities(surface1And2Assembly, stk::topology::NODE_RANK, {1, 2, 3, 4, 13, 14, 15, 16}); |
| 663 |
|
| 664 |
compare_selected_entities(block1AndSurface1And2Assembly, stk::topology::ELEM_RANK, {1}); |
| 665 |
compare_selected_entities(block1AndSurface1And2Assembly, stk::topology::FACE_RANK, {15, 36}); |
| 666 |
compare_selected_entities(block1AndSurface1And2Assembly, stk::topology::EDGE_RANK, {}); |
| 667 |
compare_selected_entities( |
| 668 |
block1AndSurface1And2Assembly, stk::topology::NODE_RANK, {1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 15, 16}); |
| 669 |
|
| 670 |
compare_selected_entities(nodeset1Assembly, stk::topology::NODE_RANK, {9, 10, 11, 12}); |
| 671 |
|
| 672 |
compare_selected_entities(block1AndSurface1And2AndNodeset1Assembly, stk::topology::ELEM_RANK, {1}); |
| 673 |
compare_selected_entities(block1AndSurface1And2AndNodeset1Assembly, stk::topology::FACE_RANK, {15, 36}); |
| 674 |
compare_selected_entities(block1AndSurface1And2AndNodeset1Assembly, stk::topology::EDGE_RANK, {}); |
| 675 |
compare_selected_entities(block1AndSurface1And2AndNodeset1Assembly, stk::topology::NODE_RANK, |
| 676 |
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); |
| 677 |
} |
| 678 |
|
| 679 |
} // namespace unit_test |
| 680 |
} // namespace io |
| 681 |
} // namespace stk |